Skip to content

Commit 2e28b4f

Browse files
author
JeromeGalan
authored
Merge pull request #122 from Luos-io/rc_2.0.1
Release 2.0.1
2 parents 85787f9 + 1cda586 commit 2e28b4f

29 files changed

+226
-208
lines changed

Bootloader/bootloader_core.c

+26-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ uint16_t data_index = 0;
3737
uint16_t residual_space = (uint16_t)BUFFER_SIZE;
3838
uint32_t nb_bytes = 0;
3939
uint8_t crc = 0;
40+
bool load_flag = false;
4041
uint16_t source_id = 0; // used to save source_id, ie gate_id
4142
uint32_t tickstart = 0;
4243
#endif
@@ -150,7 +151,7 @@ uint8_t LuosBootloader_IsEnoughSpace(uint32_t binary_size)
150151

151152
/******************************************************************************
152153
* @brief process binary data received from the gate
153-
* @param None
154+
* @param None
154155
* @return None
155156
******************************************************************************/
156157
void LuosBootloader_EraseMemory(void)
@@ -160,7 +161,7 @@ void LuosBootloader_EraseMemory(void)
160161

161162
/******************************************************************************
162163
* @brief process binary data received from the gate
163-
* @param None
164+
* @param None
164165
* @return None
165166
******************************************************************************/
166167
void LuosBootloader_ProcessData(void)
@@ -198,8 +199,8 @@ void LuosBootloader_ProcessData(void)
198199
}
199200

200201
/******************************************************************************
201-
* @brief Save the current page when BIN_END command is received
202-
* @param None
202+
* @brief Save the current page when BIN_END command is received
203+
* @param None
203204
* @return None
204205
******************************************************************************/
205206
void LuosBootloader_SaveLastData(void)
@@ -209,7 +210,7 @@ void LuosBootloader_SaveLastData(void)
209210

210211
/******************************************************************************
211212
* @brief compute crc 8 for each data
212-
* @param data pointer, data len
213+
* @param data pointer, data len
213214
* @return crc
214215
******************************************************************************/
215216
void crc8(const uint8_t *data, uint8_t *crc, uint16_t polynome)
@@ -237,7 +238,7 @@ void crc8(const uint8_t *data, uint8_t *crc, uint16_t polynome)
237238

238239
/******************************************************************************
239240
* @brief compute crc for the whole binary
240-
* @param data pointer, data len
241+
* @param data pointer, data len
241242
* @return crc
242243
******************************************************************************/
243244
uint8_t compute_crc(void)
@@ -316,13 +317,14 @@ void LuosBootloader_Loop(void)
316317
{
317318
switch (LuosBootloader_GetMode())
318319
{
319-
case APPLICATION_MODE:
320+
case JUMP_TO_APP_MODE:
320321
// boot the application programmed in dedicated flash partition
321322
LuosBootloader_DeInit();
322323
LuosBootloader_JumpToApp();
323324
break;
324325

325-
case BOOTLOADER_MODE:
326+
case BOOT_MODE:
327+
case APP_RELOAD_MODE:
326328
default:
327329
break;
328330
}
@@ -344,7 +346,7 @@ void LuosBootloader_MsgHandler(msg_t *input)
344346
case BOOTLOADER_START:
345347
// We're in the app,
346348
// set bootloader mode, save node ID and reboot
347-
LuosHAL_SetMode((uint8_t)BOOTLOADER_MODE);
349+
LuosHAL_SetMode((uint8_t)APP_RELOAD_MODE);
348350
LuosBootloader_SaveNodeID();
349351
LuosHAL_Reboot();
350352
break;
@@ -410,13 +412,26 @@ void LuosBootloader_MsgHandler(msg_t *input)
410412
LuosBootloader_SendCrc(BOOTLOADER_CRC_RESP, crc);
411413
break;
412414

415+
case BOOTLOADER_APP_SAVED:
416+
// set load flag
417+
load_flag = true;
418+
break;
419+
413420
case BOOTLOADER_STOP:
414421
source_id = input->header.source;
415422
bootloader_data_size = input->header.size - sizeof(char);
416423
memcpy(bootloader_data, &(input->data[1]), bootloader_data_size);
417424

418-
// save boot_mode in flash
419-
LuosHAL_SetMode((uint8_t)APPLICATION_MODE);
425+
// save bootloader mode in flash
426+
if (load_flag || (LuosBootloader_GetMode() == APP_RELOAD_MODE))
427+
{
428+
LuosHAL_SetMode((uint8_t)JUMP_TO_APP_MODE);
429+
}
430+
else
431+
{
432+
LuosHAL_SetMode((uint8_t)BOOT_MODE);
433+
}
434+
420435
// wait for the command to be send to all nodes
421436
tickstart = LuosHAL_GetSystick();
422437
while ((LuosHAL_GetSystick() - tickstart) < 1000)

Bootloader/bootloader_core.h

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
******************************************************************************/
1515
typedef enum
1616
{
17-
BOOTLOADER_MODE,
18-
APPLICATION_MODE
17+
BOOT_MODE,
18+
JUMP_TO_APP_MODE,
19+
APP_RELOAD_MODE,
1920
} bootloader_mode_t;
2021

2122
#define BOOTLOADER_RCV_COMMAND 0x01
@@ -31,6 +32,7 @@ typedef enum
3132
BOOTLOADER_BIN_CHUNK,
3233
BOOTLOADER_BIN_END,
3334
BOOTLOADER_CRC_TEST,
35+
BOOTLOADER_APP_SAVED,
3436
BOOTLOADER_READY_RESP = BOOTLOADER_SND_COMMAND,
3537
BOOTLOADER_BIN_HEADER_RESP,
3638
BOOTLOADER_ERASE_RESP,
@@ -40,16 +42,6 @@ typedef enum
4042
BOOTLOADER_ERROR_SIZE = BOOTLOADER_ERROR_COMMAND,
4143
} bootloader_cmd_t;
4244

43-
typedef enum
44-
{
45-
BOOTLOADER_START_STATE,
46-
BOOTLOADER_READY_STATE,
47-
BOOTLOADER_STOP_STATE,
48-
BOOTLOADER_ERASE_STATE,
49-
BOOTLOADER_BIN_CHUNK_STATE,
50-
BOOTLOADER_CRC_TEST_STATE,
51-
} bootloader_state_t;
52-
5345
/*******************************************************************************
5446
* Variables
5547
******************************************************************************/

Profiles/Motor/profile_motor.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void ProfileMotor_link(uint8_t profile_mode, profile_motor_t *profile_motor)
103103
* @brief Create a service with a linked profile
104104
* @param profile data structure
105105
* @param callback used by the service
106-
* @param alias
107-
* @param revision
106+
* @param alias
107+
* @param revision
108108
* @return service pointer
109109
******************************************************************************/
110110
service_t *ProfileMotor_CreateService(profile_motor_t *profile_motor, SERVICE_CB callback, const char *alias, revision_t revision)

Profiles/Servo_motor/profile_servo_motor.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ void ProfileServo_link(uint8_t profile_mode, profile_servo_motor_t *profile_serv
283283
* @brief Create a service with a linked profile
284284
* @param profile data structure
285285
* @param callback used by the service
286-
* @param alias
287-
* @param revision
286+
* @param alias
287+
* @param revision
288288
* @return service pointer
289289
******************************************************************************/
290290
service_t *ProfileServo_CreateService(profile_servo_motor_t *profile_servo_motor, SERVICE_CB callback, const char *alias, revision_t revision)

Profiles/Servo_motor/profile_servo_motor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ typedef struct
6565
linear_position_t linear_position;
6666
linear_speed_t linear_speed;
6767

68-
//configs
68+
// configs
6969
float motor_reduction;
7070
float resolution;
7171
linear_position_t wheel_diameter;
7272
asserv_pid_t position_pid;
7373
asserv_pid_t speed_pid;
7474

75-
//streaming
75+
// streaming
7676
control_t control;
7777
streaming_channel_t trajectory;
7878
streaming_channel_t measurement;

Profiles/State/profile_state.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ void ProfileState_link(uint8_t profile_mode, profile_state_t *profile_state)
6464
* @brief Create a service with a linked profile
6565
* @param profile data structure
6666
* @param callback used by the service
67-
* @param alias
68-
* @param revision
67+
* @param alias
68+
* @param revision
6969
* @return service pointer
7070
******************************************************************************/
7171
service_t *ProfileState_CreateService(profile_state_t *profile_state, SERVICE_CB callback, const char *alias, revision_t revision)

Profiles/Voltage/profile_voltage.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void ProfileVoltage_link(uint8_t profile_mode, profile_voltage_t *profile_voltag
8989
* @brief Create a service with a linked profile
9090
* @param profile data structure
9191
* @param callback used by the service
92-
* @param alias
93-
* @param revision
92+
* @param alias
93+
* @param revision
9494
* @return service pointer
9595
******************************************************************************/
9696
service_t *ProfileVoltage_CreateService(profile_voltage_t *profile_voltage, SERVICE_CB callback, const char *alias, revision_t revision)

Profiles/Voltage/profile_voltage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct
2121
access_t access;
2222
voltage_t voltage;
2323

24-
//streaming
24+
// streaming
2525
control_t control;
2626
streaming_channel_t signal;
2727
time_luos_t sampling_period;

Robus/inc/port_manager.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
******************************************************************************/
1919
typedef struct
2020
{
21-
//Port manager
22-
volatile uint8_t activ; //last Port where thereis activity
23-
volatile uint8_t keepLine; //status of the line poked by your node
21+
// Port manager
22+
volatile uint8_t activ; // last Port where thereis activity
23+
volatile uint8_t keepLine; // status of the line poked by your node
2424
} PortMng_t;
2525
/*******************************************************************************
2626
* Function

Robus/inc/robus_struct.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ typedef struct __attribute__((__packed__))
108108
uint16_t multicast_target_bank[MAX_MULTICAST_ADDRESS]; /*!< multicast target bank. */
109109
uint16_t dead_service_spotted; /*!< The ID of a service that don't reply to a lot of ACK msg */
110110

111-
//variable stat on robus com for ll_service
111+
// variable stat on robus com for ll_service
112112
ll_stats_t ll_stat;
113113
} ll_service_t;
114114

Robus/src/msg_alloc.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static inline error_return_t MsgAlloc_DoWeHaveSpace(void *to)
397397
void MsgAlloc_InvalidMsg(void)
398398
{
399399
//******** Remove the header by reseting data_ptr *********
400-
//clean the memory zone
400+
// clean the memory zone
401401
if (mem_clear_needed == true)
402402
{
403403
mem_clear_needed = false;
@@ -548,7 +548,7 @@ void MsgAlloc_ValidHeader(uint8_t valid, uint16_t data_size)
548548
void MsgAlloc_EndMsg(void)
549549
{
550550
//******** End the message **********
551-
//clean the memory zone
551+
// clean the memory zone
552552
if (mem_clear_needed == true)
553553
{
554554
// No luos_loop make it for us outside of IRQ, we have to make it
@@ -607,7 +607,7 @@ void MsgAlloc_EndMsg(void)
607607
// data_ptr data_end_estimation
608608
// current_msg
609609
//
610-
//data_ptr is actually 2 bytes after the message data because of the CRC. Remove the CRC.
610+
// data_ptr is actually 2 bytes after the message data because of the CRC. Remove the CRC.
611611
data_ptr -= CRC_SIZE;
612612
// Check data ptr alignement
613613
if ((uint32_t)data_ptr % 2 == 1)
@@ -1027,7 +1027,7 @@ error_return_t MsgAlloc_PullMsg(ll_service_t *target_service, msg_t **returned_m
10271027
// | etc... | | etc... |
10281028
// +---------+ +---------+
10291029
//
1030-
//find the oldest message allocated to this service
1030+
// find the oldest message allocated to this service
10311031
for (uint16_t i = 0; i < luos_tasks_stack_id; i++)
10321032
{
10331033
if (luos_tasks[i].ll_service_pt == target_service)
@@ -1088,7 +1088,7 @@ error_return_t MsgAlloc_PullMsgFromLuosTask(uint16_t luos_task_id, msg_t **retur
10881088
// | LAST | | 0 |
10891089
// +---------+ +---------+
10901090
//
1091-
//find the oldest message allocated to this service
1091+
// find the oldest message allocated to this service
10921092
if (luos_task_id < luos_tasks_stack_id)
10931093
{
10941094
used_msg = luos_tasks[luos_task_id].msg_pt;
@@ -1479,7 +1479,7 @@ error_return_t MsgAlloc_SetTxTask(ll_service_t *ll_service_pt, uint8_t *data, ui
14791479
LuosHAL_SetIrqState(true);
14801480
return FAILED;
14811481
}
1482-
//move everything at the begining of the buffer
1482+
// move everything at the begining of the buffer
14831483
tx_msg = (void *)msg_buffer;
14841484
current_msg = (msg_t *)((uint32_t)msg_buffer + decay_size);
14851485
data_ptr = (uint8_t *)((uint32_t)current_msg + progression_size);
@@ -1637,7 +1637,7 @@ error_return_t MsgAlloc_SetTxTask(ll_service_t *ll_service_pt, uint8_t *data, ui
16371637
}
16381638
#endif
16391639

1640-
//finish the Tx copy (with Ack if necessary)
1640+
// finish the Tx copy (with Ack if necessary)
16411641
if (ack != 0)
16421642
{
16431643
// msg_buffer : add Ack
@@ -1666,7 +1666,7 @@ error_return_t MsgAlloc_SetTxTask(ll_service_t *ll_service_pt, uint8_t *data, ui
16661666
((char *)tx_msg)[size - 1] = (uint8_t)(crc >> 8);
16671667
}
16681668

1669-
//manage localhost (exclude EXTERNALHOST)
1669+
// manage localhost (exclude EXTERNALHOST)
16701670
if (localhost != EXTERNALHOST)
16711671
{
16721672
// This is a localhost (LOCALHOST or MULTIHOST) message copy it as a message task

Robus/src/reception.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ void Recep_GetHeader(volatile uint8_t *data)
6262
// Check if we have all we need.
6363
switch (data_count)
6464
{
65-
case 1: //reset CRC computation
65+
case 1: // reset CRC computation
6666
ctx.tx.lock = true;
6767
// Switch the transmit status to disable to be sure to not interpreat the end timeout as an end of transmission.
6868
ctx.tx.status = TX_DISABLE;
6969
crc_val = 0xFFFF;
7070
break;
7171

72-
case 3: //check if message is for the node
72+
case 3: // check if message is for the node
7373
if (Recep_NodeConcerned((header_t *)&current_msg->header) == false)
7474
{
7575
MsgAlloc_ValidHeader(false, data_size);
@@ -78,7 +78,7 @@ void Recep_GetHeader(volatile uint8_t *data)
7878
}
7979
break;
8080

81-
case (sizeof(header_t)): //Process at the header
81+
case (sizeof(header_t)): // Process at the header
8282
#ifdef DEBUG
8383
printf("*******header data*******\n");
8484
printf("protocol : 0x%04x\n", current_msg->header.protocol); /*!< Protocol version. */
@@ -436,15 +436,15 @@ void Recep_InterpretMsgProtocol(msg_t *msg)
436436
{
437437
if (Trgt_MulticastTargetBank((ll_service_t *)&ctx.ll_service_table[i], msg->header.target))
438438
{
439-
//TODO manage multiple slave concerned
439+
// TODO manage multiple slave concerned
440440
MsgAlloc_LuosTaskAlloc((ll_service_t *)&ctx.ll_service_table[i], msg);
441441
return;
442442
}
443443
}
444444
break;
445445
case NODEIDACK:
446446
case NODEID:
447-
if (msg->header.target == DEFAULTID) //on default ID it's always a luos command create only one task
447+
if (msg->header.target == DEFAULTID) // on default ID it's always a luos command create only one task
448448
{
449449
MsgAlloc_LuosTaskAlloc((ll_service_t *)&ctx.ll_service_table[0], msg);
450450
return;

Robus/src/robus.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ static error_return_t Robus_ResetNetworkDetection(ll_service_t *ll_service)
266266

267267
do
268268
{
269-
//msg send not blocking
269+
// msg send not blocking
270270
Robus_SendMsg(ll_service, &msg);
271-
//need to wait until tx msg before clear msg alloc
271+
// need to wait until tx msg before clear msg alloc
272272
while (MsgAlloc_TxAllComplete() != SUCCEED)
273273
;
274274

Robus/src/transmission.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
******************************************************************************/
77

88
/******************************* Description of the TX process ************************************************************************
9-
*
9+
*
1010
* | Luos_send
1111
* | |
1212
* | |
@@ -38,7 +38,7 @@
3838
* --->| RX[1] |--->| =DISABLE |-----+ | | Collision |-+---+
3939
* +----------+ +----------+ | +-----------+ |
4040
* +-----------------+
41-
*
41+
*
4242
************************************************************************************************************************************/
4343

4444
#include <transmission.h>

0 commit comments

Comments
 (0)