Skip to content

Commit

Permalink
ESTOP TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
elia-nese committed May 6, 2022
1 parent ad795cc commit 206f3c5
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 16 deletions.
Binary file modified .vs/crh-power/v14/.atsuo
Binary file not shown.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# sw-power
Software for the power board
##Programmation du SAMD20E

--[I2C]

Micro en slave, PI en master, programmation des commandes de communication avec priorité
Communication avec la batterie Mavic DJI
https://github.com/czipis/mavic-mini-battery-info/blob/master/mavic-mini-battery-info.ino

--[Interface]

Programmation d'une interface en python
ou
LVGL (techno à voir avec Kevin Jordil)
1 change: 1 addition & 0 deletions crh-power/atmel_start_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define USER2 GPIO(GPIO_PORTA, 5)
#define PA08 GPIO(GPIO_PORTA, 8)
#define PA09 GPIO(GPIO_PORTA, 9)
#define eSTOP GPIO(GPIO_PORTA, 10)
#define nALERT GPIO(GPIO_PORTA, 11)
#define I2C_PW_FAULT GPIO(GPIO_PORTA, 14)
#define I2C_PW_EN GPIO(GPIO_PORTA, 15)
Expand Down
13 changes: 12 additions & 1 deletion crh-power/crh-power.cproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<OverrideVtorValue>exception_table</OverrideVtorValue>
<BootSegment>2</BootSegment>
<ResetRule>0</ResetRule>
<eraseonlaunchrule>0</eraseonlaunchrule>
<eraseonlaunchrule>1</eraseonlaunchrule>
<EraseKey />
<AsfFrameworkConfig>
<framework-data xmlns="">
Expand Down Expand Up @@ -177,6 +177,17 @@
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<avrtoolinterfaceclock>2000000</avrtoolinterfaceclock>
<custom>
<ToolOptions xmlns="">
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>SWD</InterfaceName>
</ToolOptions>
<ToolType xmlns="">custom</ToolType>
<ToolNumber xmlns="">
</ToolNumber>
<ToolName xmlns="">Custom Programming Tool</ToolName>
</custom>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
Expand Down
15 changes: 14 additions & 1 deletion crh-power/driver_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,20 @@ void system_init(void)
gpio_set_pin_direction(USER2, GPIO_DIRECTION_OUT);

gpio_set_pin_function(USER2, GPIO_PIN_FUNCTION_OFF);

// GPIO on PA10

// Set pin direction to input
gpio_set_pin_direction(eSTOP, GPIO_DIRECTION_IN);

gpio_set_pin_pull_mode(eSTOP,
// <y> Pull configuration
// <id> pad_pull_config
// <GPIO_PULL_OFF"> Off
// <GPIO_PULL_UP"> Pull-up
// <GPIO_PULL_DOWN"> Pull-down
GPIO_PULL_UP);

gpio_set_pin_function(eSTOP, GPIO_PIN_FUNCTION_OFF);
// GPIO on PA11

// Set pin direction to input
Expand Down
78 changes: 64 additions & 14 deletions crh-power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,79 @@

#include "examples/driver_examples.h"


#define DATALENGTH 32

int main(void)
{
/* Initializes MCU, drivers and middleware */
atmel_start_init();
//io_read_t(0xAD);

// io_read_t(0xAD);
TIMER_0_example();
gpio_set_pin_level(EN_5V, true);
gpio_set_pin_level(EN_12V, true);
gpio_set_pin_level(ENABLE_5V_POWER, true);
gpio_set_pin_level(ENABLE_5V_POWER, true);
gpio_set_pin_level(ENABLE_VBAT_POWER, true);
I2C_0_init();
I2C_0_example();
I2C_1_init();
I2C_1_example();




I2C_0_init();
I2C_0_example();
i2c_s_async_enable(&I2C_0);

I2C_1_init();
I2C_1_example();
i2c_s_async_enable(&I2C_1);

/* Replace with your application code */
while (1) {

// sending smth to pi via i2c, if pi doesn't respond, shut it off
while (1)
{
// battery voltage
/*if (_i2c_s_sync_read_byte(&I2C_0) == 0x03) // only for testing -> later modify to look
{
_i2c_s_async_write_byte(&I2C_0, 0xAD);
gpio_set_pin_level(EN_5V,false);
// if (!_i2c_s_async_write_byte(I2C_1, 0x00)) // I2C_1
// {
// gpio_set_pin_level(EN_5V, false);
// }
// else if (!gpio_get_pin_level(EN_5V))
// {
// gpio_set_pin_level(EN_5V, true);
// }
}*/
if (!gpio_get_pin_level(eSTOP))
{

gpio_set_pin_level(ENABLE_5V_POWER, false);
gpio_set_pin_level(ENABLE_VBAT_POWER, false);

//write to PI via I2C to shut down Techno soft
}
/*if (_i2c_s_sync_read_byte(&I2C_1) == 0x01) // only for testing -> later modify to look
{
gpio_set_pin_level(EN_5V, false);
// if (!_i2c_s_async_write_byte(I2C_1, 0x00)) // I2C_1
// {
// gpio_set_pin_level(EN_5V, false);
// }
// else if (!gpio_get_pin_level(EN_5V))
// {
// gpio_set_pin_level(EN_5V, true);
// }
}
}
// reading voltage/current outputs + flags and errors from LTC via i2c
// reading battery capacity and voltage/current output
// 0x0F - remaining capacity
// 0x10 - full capacity
// battery percentage = (remaining capacity / full capacity) * 100*/
}
}

0 comments on commit 206f3c5

Please sign in to comment.