diff --git a/software/dumber3/.cproject b/software/dumber3/.cproject index ebef7c1..3f27520 100644 --- a/software/dumber3/.cproject +++ b/software/dumber3/.cproject @@ -110,15 +110,40 @@ - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + diff --git a/software/dumber3/Application/application.c b/software/dumber3/Application/application.c index 0d10da8..6541af4 100644 --- a/software/dumber3/Application/application.c +++ b/software/dumber3/Application/application.c @@ -38,6 +38,8 @@ typedef struct { int32_t motor_right; char endOfMouvement; char powerOffRequired; + uint16_t senderAddress; + uint8_t rfProblem; } APPLICATION_Infos; @@ -83,8 +85,8 @@ void APPLICATION_Init(void) { /* Init de la partie RF / reception des messages */ XBEE_Init(); - BATTERIE_Init(); - MOTEURS_Init(); + //BATTERIE_Init(); + //MOTEURS_Init(); /* Create the task without using any dynamic memory allocation. */ xHandleApplicationMain = xTaskCreateStatic( @@ -112,8 +114,8 @@ void APPLICATION_Init(void) { void APPLICATION_MainThread(void* params) { MESSAGE_Typedef msg; + XBEE_INCOMING_FRAME *xbeeFrame; - char *cmd; CMD_Generic* decodedCmd; while (1) { @@ -121,54 +123,84 @@ void APPLICATION_MainThread(void* params) { switch (msg.id) { case MSG_ID_XBEE_CMD: - cmd = (char*)msg.data; - decodedCmd = cmdDecode(cmd); +// systemInfos.senderAddress = 0x81; +// systemInfos.cmd = 0; +// cmdSendAnswer(systemInfos.senderAddress, ANS_OK); +// +// if (msg.data != NULL) +// free (msg.data); - if (decodedCmd==CMD_DECODE_UNKNOWN) - cmdSendAnswer(ANS_UNKNOWN); - else { - systemInfos.cmd = decodedCmd->type; - systemTimeout.inactivityCnt = 0; + xbeeFrame = (XBEE_INCOMING_FRAME*)msg.data; - /* Manage answer to command, when possible - * (further treatment of the command will be done in APPLICATION_StateMachine) */ - switch (decodedCmd->type) { - case CMD_PING: - case CMD_TEST: - case CMD_DEBUG: - case CMD_POWER_OFF: - cmdSendAnswer(ANS_OK); + if (xbeeFrame != NULL) { + systemInfos.senderAddress = xbeeFrame->source_addr; + + switch (xbeeFrame->type) { + case XBEE_RX_16BIT_PACKET_TYPE: + decodedCmd = cmdDecode(xbeeFrame->data,xbeeFrame->length); + + if (decodedCmd==CMD_DECODE_UNKNOWN) + cmdSendAnswer(systemInfos.senderAddress, ANS_UNKNOWN); + else { + systemInfos.cmd = decodedCmd->type; + systemTimeout.inactivityCnt = 0; + + /* Manage answer to command, when possible + * (further treatment of the command will be done in APPLICATION_StateMachine) */ + switch (decodedCmd->type) { + case CMD_PING: + case CMD_TEST: + case CMD_DEBUG: + case CMD_POWER_OFF: + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); + break; + case CMD_GET_BATTERY: + cmdSendBatteryLevel(systemInfos.senderAddress, systemInfos.batteryVoltage); + break; + case CMD_GET_VERSION: + cmdSendVersion(SYSTEM_VERSION); + break; + case CMD_GET_BUSY_STATE: + if (systemInfos.state == stateInMouvement) + cmdSendBusyState(systemInfos.senderAddress, 0x1); + else + cmdSendBusyState(systemInfos.senderAddress, 0x0); + break; + case CMD_MOVE: + systemInfos.distance = ((CMD_Move*)decodedCmd)->distance; + break; + case CMD_TURN: + systemInfos.turns = ((CMD_Turn*)decodedCmd)->turns; + break; + default: + /* All others commands must be processed in state machine + * in order to find what action to do and what answer to give + */ + break; + } + free(decodedCmd); + } break; - case CMD_GET_BATTERY: - cmdSendBatteryLevel(systemInfos.batteryVoltage); - break; - case CMD_GET_VERSION: - cmdSendVersion(SYSTEM_VERSION); - break; - case CMD_GET_BUSY_STATE: - if (systemInfos.state == stateInMouvement) - cmdSendBusyState(0x1); - else - cmdSendBusyState(0x0); - break; - case CMD_MOVE: - systemInfos.distance = ((CMD_Move*)decodedCmd)->distance; - break; - case CMD_TURN: - systemInfos.turns = ((CMD_Turn*)decodedCmd)->turns; + + case XBEE_TX_STATUS_TYPE: + if (xbeeFrame->ack == 0) { + if (systemInfos.rfProblem !=0) + systemInfos.rfProblem--; + } else { + if (systemInfos.rfProblem !=255) + systemInfos.rfProblem++; + } break; + default: - /* All others commands must be processed in state machine - * in order to find what action to do and what answer to give - */ break; } - free(decodedCmd); +// if (xbeeFrame->data != NULL) +// free(xbeeFrame->data); + + free(xbeeFrame); } - - free(cmd); - break; case MSG_ID_BAT_NIVEAU: @@ -232,16 +264,16 @@ void APPLICATION_StateMachine() { (systemInfos.state == stateRun) || (systemInfos.state == stateInMouvement)) { /* command RESET is only applicable in those 3 states, otherwise it is rejected */ - cmdSendAnswer(ANS_OK); + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); APPLICATION_TransitionToNewState(stateIdle); } else - cmdSendAnswer(ANS_ERR); + cmdSendAnswer(systemInfos.senderAddress, ANS_ERR); break; case CMD_START_WITH_WATCHDOG: case CMD_START_WITHOUT_WATCHDOG: if (systemInfos.state == stateIdle) { /* only state where START cmd is accepted */ - cmdSendAnswer(ANS_OK); + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); APPLICATION_TransitionToNewState(stateRun); @@ -251,15 +283,15 @@ void APPLICATION_StateMachine() { systemTimeout.watchdogMissedCnt=0; } } else - cmdSendAnswer(ANS_ERR); + cmdSendAnswer(systemInfos.senderAddress, ANS_ERR); break; case CMD_RESET_WATCHDOG: if ((systemInfos.state == stateRun) || (systemInfos.state == stateInMouvement)) { if ((systemTimeout.watchdogEnabled ==0 ) || ((systemTimeout.watchdogCnt>=APPLICATION_WATCHDOG_MIN) && (systemTimeout.watchdogCnt<=APPLICATION_WATCHDOG_MAX))) - cmdSendAnswer(ANS_OK); + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); else - cmdSendAnswer(ANS_ERR); + cmdSendAnswer(systemInfos.senderAddress, ANS_ERR); systemTimeout.watchdogCnt =0; } @@ -271,17 +303,17 @@ void APPLICATION_StateMachine() { if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance !=0)) || ((systemInfos.cmd == CMD_TURN) && (systemInfos.turns !=0))) { systemInfos.endOfMouvement = 0; - cmdSendAnswer(ANS_OK); + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); APPLICATION_TransitionToNewState(stateInMouvement); } // if TURN and MOVE are sent without parameter, do nothing: we are still in run state } else if (systemInfos.state == stateInMouvement) { // in this state, MOVE and TURN cmds are accepted only if they come with no parameter if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance ==0)) || ((systemInfos.cmd == CMD_TURN) && (systemInfos.turns ==0))) { systemInfos.endOfMouvement = 1; - cmdSendAnswer(ANS_OK); + cmdSendAnswer(systemInfos.senderAddress, ANS_OK); } } else - cmdSendAnswer(ANS_ERR); + cmdSendAnswer(systemInfos.senderAddress, ANS_ERR); break; default: // commands no common for every states break; diff --git a/software/dumber3/Application/commands.c b/software/dumber3/Application/commands.c index 5a03e87..cb24f3f 100644 --- a/software/dumber3/Application/commands.c +++ b/software/dumber3/Application/commands.c @@ -12,22 +12,44 @@ /* Definition des commandes */ -CMD_Generic* cmdDecode(char* cmd) { +CMD_Generic* cmdDecode(char* cmd, uint8_t length) { CMD_Generic* decodedCmd; + char cmd_type = cmd[0]; + int val; + uint32_t startTime, endTime; + volatile uint32_t duration; - switch (cmd[0]) + startTime = SysTick->VAL; + + switch (cmd_type) { case CMD_MOVE: decodedCmd = (CMD_Generic*)malloc(sizeof(CMD_Move)); - ((CMD_Move*)decodedCmd)->distance = ((uint16_t)cmd[1]<<8) + (uint16_t)cmd[2]; + decodedCmd->type = cmd[0]; + { + char rawCmd[length+1]; + memcpy((void*)rawCmd, (void*)cmd, length); + rawCmd[length] = (char)0; /* 0 ending string */ + + sscanf (&rawCmd[1], "%d", &val); + + ((CMD_Move*)decodedCmd)->distance= (int16_t) val; + } break; case CMD_TURN: decodedCmd = (CMD_Generic*)malloc(sizeof(CMD_Turn)); + decodedCmd->type = cmd[0]; + { + char rawCmd[length+1]; + memcpy((void*)rawCmd, (void*)cmd, length); + rawCmd[length] = (char)0; /* 0 ending string */ - ((CMD_Turn*)decodedCmd)->turns = ((uint16_t)cmd[1]<<8) + (uint16_t)cmd[2]; - ((CMD_Turn*)decodedCmd)->turns = ((CMD_Turn*)decodedCmd)->turns * 1.4; + sscanf (&rawCmd[1], "%d", &val); + ((CMD_Turn*)decodedCmd)->turns = (int16_t) val; + ((CMD_Turn*)decodedCmd)->turns = ((CMD_Turn*)decodedCmd)->turns * 1.4; + } break; case CMD_PING: @@ -43,22 +65,29 @@ CMD_Generic* cmdDecode(char* cmd) { case CMD_POWER_OFF: decodedCmd = (CMD_Generic*)malloc(sizeof(CMD_Generic)); decodedCmd->type = cmd[0]; - + break; default: decodedCmd = CMD_DECODE_UNKNOWN; } + endTime=SysTick->VAL; + + if (endTime>startTime) + duration = (uint32_t)(SysTick->LOAD+1)-endTime+startTime; + else + duration = startTime-endTime; + return decodedCmd; } -void cmdSendAnswer(uint8_t ans) { +void cmdSendAnswer(uint16_t address, uint8_t ans) { ANS_Generic answer; answer.ans = ans; - XBEE_SendData((char*)&answer, sizeof (answer)); + XBEE_SendData(address, (char*)&answer, sizeof (answer)); } -void cmdSendBatteryLevel(char level) { +void cmdSendBatteryLevel(uint16_t address, char level) { ANS_Battery answer; char localLevel=level; @@ -68,19 +97,19 @@ void cmdSendBatteryLevel(char level) { answer.ans = ANS_OK; answer.bat_level = localLevel; - XBEE_SendData((char*)&answer, sizeof (answer)); + XBEE_SendData(address, (char*)&answer, sizeof (answer)); } -void cmdSendVersion() { +void cmdSendVersion(uint16_t address) { ANS_Version answer; answer.ans = ANS_OK; - answer.version = SYSTEM_VERSION; + strcpy (answer.version, SYSTEM_VERSION_STR); - XBEE_SendData((char*)&answer, sizeof (answer)); + XBEE_SendData(address, (char*)&answer, sizeof (answer)); } -void cmdSendBusyState(uint8_t state) { +void cmdSendBusyState(uint16_t address, uint8_t state) { ANS_Busy_State answer; answer.ans = ANS_OK; @@ -88,5 +117,5 @@ void cmdSendBusyState(uint8_t state) { if (answer.state >1) answer.state=0; - XBEE_SendData((char*)&answer, sizeof (answer)); + XBEE_SendData(address, (char*)&answer, sizeof (answer)); } diff --git a/software/dumber3/Application/commands.h b/software/dumber3/Application/commands.h index bfbde3c..e0fe68a 100644 --- a/software/dumber3/Application/commands.h +++ b/software/dumber3/Application/commands.h @@ -10,31 +10,39 @@ #include "application.h" -#define CMD_NONE 0x0 -#define CMD_PING 0x1 -#define CMD_RESET 0x2 -#define CMD_START_WITH_WATCHDOG 0x3 -#define CMD_RESET_WATCHDOG 0x4 -#define CMD_GET_BATTERY 0x5 -#define CMD_GET_VERSION 0x6 -#define CMD_START_WITHOUT_WATCHDOG 0x7 -#define CMD_MOVE 0x8 -#define CMD_TURN 0x9 -#define CMD_GET_BUSY_STATE 0xA -#define CMD_TEST 0xB -#define CMD_DEBUG 0xC -#define CMD_POWER_OFF 0xD +typedef enum { + CMD_NONE=0x0, + CMD_PING, + CMD_RESET, + CMD_START_WITH_WATCHDOG, + CMD_RESET_WATCHDOG, + CMD_GET_BATTERY, + CMD_GET_VERSION, + CMD_START_WITHOUT_WATCHDOG, + CMD_MOVE, + CMD_TURN, + CMD_GET_BUSY_STATE, + CMD_TEST, + CMD_DEBUG, + CMD_POWER_OFF +} CMD_CommandsType; -#define ANS_OK 0x80 -#define ANS_ERR 0x81 -#define ANS_UNKNOWN 0x82 +typedef enum { + ANS_OK=0x80, + ANS_ERR, + ANS_UNKNOWN +} CMD_AnswersType; -#define ANS_BAT_OK 0x2 -#define ANS_BAT_LOW 0x1 -#define ANS_BAT_EMPTY 0x0 +typedef enum { + ANS_BAT_EMPTY=0, + ANS_BAT_LOW, + ANS_BAT_OK +} CMD_BatteryLevelType; -#define ANS_STATE_NOT_BUSY 0x0 -#define ANS_STATE_BUSY 0x1 +typedef enum { + ANS_STATE_NOT_BUSY=0, + ANS_STATE_BUSY +} CMD_BusyType; typedef struct __attribute__((packed)) { uint8_t type; @@ -56,7 +64,7 @@ typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) { uint8_t ans; - uint8_t version; + char version[6]; } ANS_Version; typedef struct __attribute__((packed)) { @@ -72,10 +80,10 @@ typedef struct __attribute__((packed)) { #define CMD_DECODE_INVALID ((CMD_Generic*)NULL) #define CMD_DECODE_UNKNOWN ((CMD_Generic*)UINT32_MAX) -CMD_Generic* cmdDecode(char* cmd); -void cmdSendAnswer(uint8_t ans); -void cmdSendBatteryLevel(char level); -void cmdSendVersion(); -void cmdSendBusyState(uint8_t state); +CMD_Generic* cmdDecode(char* cmd, uint8_t length); +void cmdSendAnswer(uint16_t address, uint8_t ans); +void cmdSendBatteryLevel(uint16_t address, char level); +void cmdSendVersion(uint16_t address); +void cmdSendBusyState(uint16_t address, uint8_t state); #endif /* INC_CMD_H_ */ diff --git a/software/dumber3/Application/config.h b/software/dumber3/Application/config.h index a5c5edc..5394937 100644 --- a/software/dumber3/Application/config.h +++ b/software/dumber3/Application/config.h @@ -7,7 +7,7 @@ #include "stm32l0xx_hal.h" #include "cmsis_os.h" -#define SYSTEM_VERSION_STR "version 2.0\r" +#define SYSTEM_VERSION_STR "2.0" #define SYSTEM_VERSION 0x20 #define STACK_SIZE 0x100 diff --git a/software/dumber3/Application/moteurs.c b/software/dumber3/Application/moteurs.c index 63fbd16..52c11db 100644 --- a/software/dumber3/Application/moteurs.c +++ b/software/dumber3/Application/moteurs.c @@ -42,12 +42,6 @@ typedef struct { MOTEURS_EtatMoteur MOTEURS_EtatMoteurGauche, MOTEURS_EtatMoteurDroit = {0}; MOTEURS_EtatDiff MOTEURS_EtatDifferentiel; -uint16_t MOTEUR_DerniereValEncodeursG; -uint16_t MOTEUR_DerniereValEncodeursD; - -#define MOTEUR_GAUCHE 0 -#define MOTEUR_DROIT 1 - #define MOTEUR_Kp 15 #define MOTEUR_DELAY 3 @@ -101,6 +95,8 @@ void MOTEURS_Init(void) { xStackMoteursAsservissement, /* Array to use as the task's stack. */ &xTaskMoteursAsservissement); /* Variable to hold the task's data structure. */ vTaskSuspend(xHandleMoteursAsservissement); // On ne lance la tache d'asservissement que lorsque'une commande moteur arrive + + MOTEURS_DesactiveAlim(); } void MOTEURS_Avance(uint32_t distance) { @@ -136,19 +132,37 @@ void MOTEURS_TachePrincipale(void* params) { switch (msg.id) { case MSG_ID_MOTEURS_MOVE: distance = *((uint32_t*)msg.data); + MOTEURS_EtatDifferentiel.distance = distance; + MOTEURS_EtatDifferentiel.tours = 0; + + MOTEURS_EtatMoteurGauche.consigne=50; + MOTEURS_EtatMoteurDroit.consigne=50; - // TODO: trucs a faire ici vTaskResume(xHandleMoteursAsservissement); break; case MSG_ID_MOTEURS_TURN: tours = *((uint32_t*)msg.data); + MOTEURS_EtatDifferentiel.distance = 0; + MOTEURS_EtatDifferentiel.tours = tours; + + MOTEURS_EtatMoteurGauche.consigne=50; + MOTEURS_EtatMoteurDroit.consigne=50; - // TODO: trucs a faire ici vTaskResume(xHandleMoteursAsservissement); break; case MSG_ID_MOTEURS_STOP: - // TODO: trucs a faire ici - vTaskSuspend(xHandleMoteursAsservissement); + MOTEURS_EtatDifferentiel.distance = 0; + MOTEURS_EtatDifferentiel.tours = 0; + + MOTEURS_EtatMoteurGauche.consigne=0; + MOTEURS_EtatMoteurDroit.consigne=0; + if ((MOTEURS_CorrectionEncodeur(MOTEURS_EtatMoteurGauche.encodeur) ==0) && + (MOTEURS_CorrectionEncodeur(MOTEURS_EtatMoteurDroit.encodeur) ==0)) + // Les moteurs sont déjà arretés + vTaskSuspend(xHandleMoteursAsservissement); + else + // Les moteurs tournent encore + vTaskResume(xHandleMoteursAsservissement); break; default: break; @@ -181,8 +195,14 @@ void MOTEURS_TacheAsservissement( void* params ) { deltaD = MOTEURS_EtatMoteurDroit.consigne - encodeurDroit; if (((MOTEURS_EtatMoteurDroit.consigne ==0) && (MOTEURS_EtatMoteurGauche.consigne ==0)) && - ((deltaD==0) && (deltaG==0))) MOTEURS_DesactiveAlim(); - else MOTEURS_ActiveAlim(); + ((deltaD==0) && (deltaG==0))) { + MOTEURS_DesactiveAlim(); + + vTaskSuspend(xHandleMoteursAsservissement); + } + else if (MOTEURS_EtatAlim() == GPIO_PIN_RESET) { + MOTEURS_ActiveAlim(); + } if (deltaG !=0) { MOTEURS_EtatMoteurGauche.commande = MOTEURS_EtatMoteurGauche.commande + MOTEUR_Kp*deltaG; diff --git a/software/dumber3/Application/xbee.c b/software/dumber3/Application/xbee.c index 110cbfc..e4fecd0 100644 --- a/software/dumber3/Application/xbee.c +++ b/software/dumber3/Application/xbee.c @@ -10,6 +10,7 @@ #include "semphr.h" #include #include +#include "stm32l0xx_ll_usart.h" extern UART_HandleTypeDef hlpuart1; extern DMA_HandleTypeDef hdma_lpuart1_tx; @@ -28,15 +29,23 @@ StaticTask_t xTaskXbeeRX; StackType_t xStackXbeeRX[ STACK_SIZE ]; TaskHandle_t xHandleXbeeRX = NULL; +uint8_t txBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0}; +uint16_t txIndex; +uint16_t txDataToSend; + void XBEE_RxThread(void* params); SemaphoreHandle_t xHandleSemaphoreRX = NULL; StaticSemaphore_t xSemaphoreRx; -uint8_t* rxBuffer; -uint8_t rxWaitForACK; +uint8_t rxBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0}; +//uint8_t rxWaitForACK =0; uint8_t rxPhase; +uint16_t rxFrameLength; +uint16_t rxDataToReceive; +uint16_t rxIndex; +#define XBEE_RX_PHASE_SOF 0 #define XBEE_RX_PHASE_HEADER 1 #define XBEE_RX_PHASE_BODY 2 @@ -46,15 +55,27 @@ SemaphoreHandle_t xHandleSemaphoreTX_ACK = NULL; StaticSemaphore_t xSemaphoreTX; StaticSemaphore_t xSemaphoreTX_ACK; -uint8_t* txBuffer; - void XBEE_Init(void) { xHandleSemaphoreTX = xSemaphoreCreateBinaryStatic( &xSemaphoreTX ); xHandleSemaphoreTX_ACK = xSemaphoreCreateBinaryStatic( &xSemaphoreTX_ACK ); xSemaphoreGive(xHandleSemaphoreTX); + //xSemaphoreTake(xHandleSemaphoreTX_ACK); - rxBuffer=(uint8_t*)malloc(XBEE_RX_BUFFER_MAX_LENGTH); - rxWaitForACK = 0; + xHandleSemaphoreRX = xSemaphoreCreateBinaryStatic( &xSemaphoreRx ); + + /* Create the task without using any dynamic memory allocation. */ + xHandleXbeeRX = xTaskCreateStatic( + XBEE_RxThread, /* Function that implements the task. */ + "XBEE Rx", /* Text name for the task. */ + STACK_SIZE, /* Number of indexes in the xStack array. */ + NULL, /* Parameter passed into the task. */ + PriorityMoteurs,/* Priority at which the task is created. */ + xStackXbeeRX, /* Array to use as the task's stack. */ + &xTaskXbeeRX); /* Variable to hold the task's data structure. */ + vTaskResume(xHandleXbeeRX); + + /* Enable Xbee */ + HAL_GPIO_WritePin(XBEE_RESET_GPIO_Port, XBEE_RESET_Pin, GPIO_PIN_SET); } /**** Support functions ****/ @@ -110,33 +131,6 @@ char* XBEE_EncodeWithEscapeChar(char* data, int length, int *encodedLength) { return encodedData; } -/** - * Convert escaped data into raw data. Create a new buffer that is returned - * - * \param encodedData pointer on encoded data - * \param encodedLength length of encoded data - * \param length length of raw data - * \return new buffer allocated without escaped char - */ -char* XBEE_DecodeWithoutEscapeChar(char* encodedData, int encodedLength, int *length) { - char* data = (char*)malloc(encodedLength); // on prévoit un buffer aussi grand que celui avec caractère d'echappement, - // au cas où aucun caractère d'echappement ne serait present - *length = encodedLength; // par défaut, on considère que les données brutes ont la même taille que - // celles avec caractères d'echappement. - - for (char* p=data; p< (data + encodedLength); p++) { - if (*encodedData == (char)XBEE_API_ESCAPE_CHAR) { - encodedData++; // on saute le caractere d'echappement - *p = (char) (*encodedData & 0x20); - } else - *p = *encodedData; - - encodedData++; - } - - return data; -} - /** * Get a raw buffer and convert it into a transmission frame * @@ -146,19 +140,16 @@ char* XBEE_DecodeWithoutEscapeChar(char* encodedData, int encodedLength, int *le * \param frameLength length of frame * \return new frame (allocated) containing escaped data */ -char* XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination, int* frameLength) { - uint8_t checksum; - char* frame; +void XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination, char* frame, int* frameLength) { + uint8_t checksum=0; + uint16_t localLength=0; + char* p; - int encodedLength; - char *encodedData = XBEE_EncodeWithEscapeChar(data, length, &encodedLength); + localLength = length+9; - *frameLength= encodedLength+9; - frame = (char*)malloc(*frameLength); - - frame[0] = '~'; - frame[1] = (char)((uint16_t)(*frameLength-3)>>8); - frame[2] = (char)((uint16_t)(*frameLength-3)); + frame[0] = (char)XBEE_FRAME_SOF_CHAR; + frame[1] = (char)((uint16_t)(localLength-4)>>8); + frame[2] = (char)((uint16_t)(localLength-4)); frame[3] = (char)XBEE_TX_16BIT_REQUEST_TYPE; frame[4] = 0x1; @@ -167,22 +158,25 @@ char* XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination, frame[7] = 0x0; - char* p_data = encodedData; - for (char *p=&frame[8]; p<&frame[8] + encodedLength; p++, p_data++) { - *p= *p_data; + for (p = &frame[8]; p< (data + length); p++) { + if ((*data == (char)XBEE_API_ESCAPE_CHAR) || (*data == (char)XBEE_API_START_OF_FRAME) || + (*data == (char)XBEE_API_XOFF) ||(*data == (char)XBEE_API_XON)) { + *p = (char) XBEE_API_ESCAPE_CHAR; + p++; + *p = *data^0x20; + } else + *p = *data; + + data++; } /* calcul du checksum */ - checksum =0; - for (int i=3; i<*frameLength; i++) { + for (int i=3; i<(localLength-1); i++) { checksum += (uint8_t)frame[i]; } - frame[*frameLength] = 0xFF-checksum; - - free ((void*)encodedData); - - return frame; + *p = 0xFF-checksum; + *frameLength = localLength; } /** @@ -207,7 +201,8 @@ XBEE_Status XBEE_DecodeFrame(char* rawFrame, XBEE_INCOMING_FRAME** incomingFrame uint16_t rawFrameLength; uint8_t checksum; XBEE_Status status = XBEE_OK; - int incomingDataLength = 0; + int allocatedSize; + int dataSize; int i; @@ -223,34 +218,56 @@ XBEE_Status XBEE_DecodeFrame(char* rawFrame, XBEE_INCOMING_FRAME** incomingFrame if (checksum != 0xFF) return XBEE_INVALID_FRAME; - *incomingFrame = (XBEE_INCOMING_FRAME*) malloc(sizeof(XBEE_INCOMING_FRAME)); /* Allocate a generic frame struct */ - (*incomingFrame)->type = frame_type; - switch (frame_type) { case XBEE_RX_16BIT_PACKET_TYPE: + dataSize = rawFrameLength-5; // there is 5 bytes of "other" data than truly data bytes in a frame + allocatedSize = sizeof(XBEE_INCOMING_FRAME)+dataSize; + + *incomingFrame = (XBEE_INCOMING_FRAME*) malloc(allocatedSize); /* Allocate a generic frame struct */ + (*incomingFrame)->type = frame_type; + /* Get source address */ (*incomingFrame)->source_addr = (((uint16_t)rawFrame[4])<<8) + (uint16_t)rawFrame[5]; - (*incomingFrame)->data = XBEE_DecodeWithoutEscapeChar(&rawFrame[8], rawFrameLength-6, &incomingDataLength); + //XBEE_DecodeWithoutEscapeChar(&rawFrame[8], rawFrameLength-5, (*incomingFrame)->data, &incomingDataLength); // Data = Frame length -5 + (*incomingFrame)->length = (uint8_t)(dataSize); (*incomingFrame)->ack = 0; + + for (i=0; idata[i] = rawFrame[i+8]; + break; case XBEE_MODEM_STATUS_TYPE: + allocatedSize = sizeof(XBEE_INCOMING_FRAME); // no data + *incomingFrame = (XBEE_INCOMING_FRAME*) malloc(allocatedSize); /* Allocate a generic frame struct */ + + (*incomingFrame)->type = frame_type; + (*incomingFrame)->modem_status = rawFrame[4]; - (*incomingFrame)->data=0x0; + (*incomingFrame)->data[0]=0x0; + (*incomingFrame)->length = 0; break; case XBEE_TX_STATUS_TYPE: + allocatedSize = sizeof(XBEE_INCOMING_FRAME); // no data + *incomingFrame = (XBEE_INCOMING_FRAME*) malloc(allocatedSize); /* Allocate a generic frame struct */ + (*incomingFrame)->ack = rawFrame[5]; - (*incomingFrame)->data=0x0; + (*incomingFrame)->data[0]=0x0; + (*incomingFrame)->length = 0; break; case XBEE_EXTENDED_TX_STATUS_TYPE: + allocatedSize = sizeof(XBEE_INCOMING_FRAME); // no data + *incomingFrame = (XBEE_INCOMING_FRAME*) malloc(allocatedSize); /* Allocate a generic frame struct */ + (*incomingFrame)->ack = rawFrame[8]; - (*incomingFrame)->data=0x0; + (*incomingFrame)->data[0]=0x0; + (*incomingFrame)->length = 0; break; default: - free (*incomingFrame); + *incomingFrame=NULL; return XBEE_INVALID_FRAME; }; } else status = XBEE_INVALID_FRAME; @@ -267,12 +284,11 @@ XBEE_Status XBEE_DecodeFrame(char* rawFrame, XBEE_INCOMING_FRAME** incomingFrame * \param length length of data to send * \return status of decoding: XBEE_OK if decoding is successful, * XBEE_TX_ERROR in case of sending error, - * XBEE_TX_ACK_ERROR in case frame was not acknowledge by detination part + * XBEE_TX_TIMEOUT in case semaphore takes too long */ -int XBEE_SendData(char* data, int length) { - int data_length; +int XBEE_SendData(uint16_t address, char* data, int length) { BaseType_t state; - XBEE_INCOMING_FRAME* incomingFrame; + int status = XBEE_OK; // Prevents successive calls to overlap state = xSemaphoreTake(xHandleSemaphoreTX, pdMS_TO_TICKS(XBEE_TX_SEMAPHORE_WAIT)); // wait max 500 ms (to avoid interlocking) @@ -281,50 +297,33 @@ int XBEE_SendData(char* data, int length) { if answer is false, it means timeout appends We should probably reset something in "else" branch */ - /* TODO: stuff to do here for converting data into API frame */ - txBuffer = (uint8_t*)XBEE_EncodeWithEscapeChar(data, length, &data_length); + XBEE_EncodeTransmissionFrame(data, length, address, (char*) txBuffer, (int*)&txDataToSend); - if (txBuffer!=NULL) { - if (HAL_UART_Transmit_DMA(&hlpuart1, txBuffer, data_length)!= HAL_OK) - return XBEE_TX_ERROR; - else { - rxWaitForACK = 1; /* wait for TX ack */ - // Wait for ACK frame after TX - state = xSemaphoreTake(xHandleSemaphoreTX_ACK, pdMS_TO_TICKS(XBEE_TX_SEMAPHORE_WAIT)); // wait max 500 ms (to avoid interlocking) - if (XBEE_DecodeFrame((char*) rxBuffer, &incomingFrame)!=XBEE_OK) - return XBEE_TX_ACK_ERROR; - else { - if (incomingFrame == 0x0) - return XBEE_TX_ACK_ERROR; - else if ((incomingFrame->type != XBEE_TX_STATUS_TYPE) || (incomingFrame->ack != XBEE_TX_STATUS_SUCCESS)) { - free ((XBEE_INCOMING_FRAME*) incomingFrame); - return XBEE_TX_ACK_ERROR; - } - } - } - } else return XBEE_TX_ERROR; - } else return XBEE_TX_ERROR; + LL_USART_TransmitData8(hlpuart1.Instance, txBuffer[0]); + txIndex =1; + LL_USART_EnableIT_TXE(hlpuart1.Instance); // enable TX Interrupt + } else status= XBEE_TX_TIMEOUT; - return length; + return status; } -/** - * DMA Interrupt request for transmission. Call when transmission is finished - * - * \param UartHandle not used - */ -void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle) { +void XBEE_TX_IRQHandler(void) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; - /* Free transmit buffer */ - free (txBuffer); - if (rxWaitForACK != 1) /* we are waiting for an acknowledge frame, so do not give semaphore yet */ + LL_USART_TransmitData8(hlpuart1.Instance, txBuffer[txIndex]); + txIndex++; + if (txIndex == txDataToSend) { + LL_USART_DisableIT_TXE(hlpuart1.Instance); xSemaphoreGiveFromISR( xHandleSemaphoreTX, &xHigherPriorityTaskWoken ); + } - /* If xHigherPriorityTaskWoken was set to true you - we should yield. The actual macro used here is - port specific. */ - portYIELD_FROM_ISR(xHigherPriorityTaskWoken ); + if (xHigherPriorityTaskWoken) { + /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch + should be performed to ensure the interrupt returns directly to the highest + priority task. The macro used for this purpose is dependent on the port in + use and may be called portEND_SWITCHING_ISR(). */ + portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + } } /***** Rx Part *****/ @@ -335,53 +334,78 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle) { * \param params not used */ void XBEE_RxThread(void* params) { - BaseType_t state; - XBEE_INCOMING_FRAME* incomingFrame; + XBEE_INCOMING_FRAME *incomingFrame; - rxPhase= XBEE_RX_PHASE_HEADER; - while (HAL_UART_Receive_DMA(&hlpuart1, rxBuffer, 3)== HAL_OK); // start reception of frame + rxPhase= XBEE_RX_PHASE_SOF; + rxFrameLength=0; + rxDataToReceive=1; + rxIndex=0; + + while (HAL_UART_Receive_IT(&hlpuart1, rxBuffer, 1)!= HAL_OK); // try starting reception of frame + LL_USART_Disable(hlpuart1.Instance); + LL_USART_DisableOverrunDetect(hlpuart1.Instance); + LL_USART_Enable(hlpuart1.Instance); // endless task while (1) { - while ((state = xSemaphoreTake(xHandleSemaphoreRX, portMAX_DELAY))==pdTRUE); // wait forever + if (xSemaphoreTake(xHandleSemaphoreRX, portMAX_DELAY)==pdTRUE) { // wait forever - /* Process frame */ - if (XBEE_DecodeFrame((char*) rxBuffer, &incomingFrame)==XBEE_OK) // frame is valid - if (incomingFrame != 0x0) // frame is valid - MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_XBEE_CMD, (QueueHandle_t)0x0, (void*)incomingFrame); + /* Process frame */ + if (XBEE_DecodeFrame((char*) rxBuffer, &incomingFrame)==XBEE_OK) { // frame is valid + if (incomingFrame != 0x0) // frame is valid + MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_XBEE_CMD, (QueueHandle_t)0x0, (void*)incomingFrame); + // if (rxBuffer[3]== XBEE_RX_16BIT_PACKET_TYPE) { + // MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_XBEE_CMD, (QueueHandle_t)0x0, (void*)0x0); + } + + for (int i=0; iInstance == TIM2) || (htim->Instance == TIM21)) /* Timers des encodeurs */ - MOTEURS_TimerEncodeurUpdate(htim); + /* USER CODE END Callback 1 */ } diff --git a/software/dumber3/Core/Src/stm32l0xx_hal_msp.c b/software/dumber3/Core/Src/stm32l0xx_hal_msp.c index 55b68b4..ddb595c 100644 --- a/software/dumber3/Core/Src/stm32l0xx_hal_msp.c +++ b/software/dumber3/Core/Src/stm32l0xx_hal_msp.c @@ -26,8 +26,6 @@ /* USER CODE END Includes */ extern DMA_HandleTypeDef hdma_lpuart1_tx; -extern DMA_HandleTypeDef hdma_lpuart1_rx; - /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ @@ -197,23 +195,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) __HAL_LINKDMA(huart,hdmatx,hdma_lpuart1_tx); - /* LPUART1_RX Init */ - hdma_lpuart1_rx.Instance = DMA1_Channel3; - hdma_lpuart1_rx.Init.Request = DMA_REQUEST_5; - hdma_lpuart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_lpuart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_lpuart1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_lpuart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_lpuart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_lpuart1_rx.Init.Mode = DMA_NORMAL; - hdma_lpuart1_rx.Init.Priority = DMA_PRIORITY_HIGH; - if (HAL_DMA_Init(&hdma_lpuart1_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmarx,hdma_lpuart1_rx); - /* LPUART1 interrupt Init */ HAL_NVIC_SetPriority(LPUART1_IRQn, 3, 0); HAL_NVIC_EnableIRQ(LPUART1_IRQn); @@ -248,7 +229,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* LPUART1 DMA DeInit */ HAL_DMA_DeInit(huart->hdmatx); - HAL_DMA_DeInit(huart->hdmarx); /* LPUART1 interrupt DeInit */ HAL_NVIC_DisableIRQ(LPUART1_IRQn); diff --git a/software/dumber3/Core/Src/stm32l0xx_it.c b/software/dumber3/Core/Src/stm32l0xx_it.c index 3fb0851..81ae58a 100644 --- a/software/dumber3/Core/Src/stm32l0xx_it.c +++ b/software/dumber3/Core/Src/stm32l0xx_it.c @@ -58,7 +58,6 @@ /* External variables --------------------------------------------------------*/ extern ADC_HandleTypeDef hadc; extern DMA_HandleTypeDef hdma_lpuart1_tx; -extern DMA_HandleTypeDef hdma_lpuart1_rx; extern UART_HandleTypeDef hlpuart1; extern TIM_HandleTypeDef htim2; extern TIM_HandleTypeDef htim21; @@ -139,17 +138,16 @@ void EXTI4_15_IRQHandler(void) /** * @brief This function handles DMA1 channel 2 and channel 3 interrupts. */ -void DMA1_Channel2_3_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */ - - /* USER CODE END DMA1_Channel2_3_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_lpuart1_tx); - HAL_DMA_IRQHandler(&hdma_lpuart1_rx); - /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */ - - /* USER CODE END DMA1_Channel2_3_IRQn 1 */ -} +//void DMA1_Channel2_3_IRQHandler(void) +//{ +// /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */ +// +// /* USER CODE END DMA1_Channel2_3_IRQn 0 */ +// HAL_DMA_IRQHandler(&hdma_lpuart1_tx); +// /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */ +// +// /* USER CODE END DMA1_Channel2_3_IRQn 1 */ +//} /** * @brief This function handles ADC, COMP1 and COMP2 interrupts (COMP interrupts through EXTI lines 21 and 22). @@ -210,16 +208,16 @@ void TIM21_IRQHandler(void) /** * @brief This function handles LPUART1 global interrupt / LPUART1 wake-up interrupt through EXTI line 28. */ -void LPUART1_IRQHandler(void) -{ - /* USER CODE BEGIN LPUART1_IRQn 0 */ - - /* USER CODE END LPUART1_IRQn 0 */ - HAL_UART_IRQHandler(&hlpuart1); - /* USER CODE BEGIN LPUART1_IRQn 1 */ - - /* USER CODE END LPUART1_IRQn 1 */ -} +//void LPUART1_IRQHandler(void) +//{ +// /* USER CODE BEGIN LPUART1_IRQn 0 */ +// +// /* USER CODE END LPUART1_IRQn 0 */ +// HAL_UART_IRQHandler(&hlpuart1); +// /* USER CODE BEGIN LPUART1_IRQn 1 */ +// +// /* USER CODE END LPUART1_IRQn 1 */ +//} /* USER CODE BEGIN 1 */ diff --git a/software/dumber3/Core/Startup/startup_stm32l010c6tx.s b/software/dumber3/Core/Startup/startup_stm32l071xx.s similarity index 74% rename from software/dumber3/Core/Startup/startup_stm32l010c6tx.s rename to software/dumber3/Core/Startup/startup_stm32l071xx.s index 02454dd..ca9b315 100644 --- a/software/dumber3/Core/Startup/startup_stm32l010c6tx.s +++ b/software/dumber3/Core/Startup/startup_stm32l071xx.s @@ -1,8 +1,8 @@ /** ****************************************************************************** - * @file startup_stm32l010x6.s + * @file startup_stm32l071xx.s * @author MCD Application Team - * @brief STM32L010x6 Devices vector table for GCC toolchain. + * @brief STM32L071xx Devices vector table for GCC toolchain. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, @@ -14,13 +14,12 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2016 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2016 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ @@ -51,27 +50,10 @@ defined in linker script */ Reset_Handler: ldr r0, =_estack mov sp, r0 /* set stack pointer */ + +/* Call the clock system initialization function.*/ + bl SystemInit -/*Check if boot space corresponds to system memory*/ - - LDR R0,=0x00000004 - LDR R1, [R0] - LSRS R1, R1, #24 - LDR R2,=0x1F - CMP R1, R2 - BNE ApplicationStart - - /*SYSCFG clock enable*/ - LDR R0,=0x40021034 - LDR R1,=0x00000001 - STR R1, [R0] - -/*Set CFGR1 register with flash memory remap at address 0*/ - LDR R0,=0x40010000 - LDR R1,=0x00000000 - STR R1, [R0] - -ApplicationStart: /* Copy the data segment initializers from flash to SRAM */ ldr r0, =_sdata ldr r1, =_edata @@ -103,8 +85,6 @@ LoopFillZerobss: cmp r2, r4 bcc FillZerobss -/* Call the clock system intitialization function.*/ - bl SystemInit /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ @@ -159,7 +139,7 @@ g_pfnVectors: .word PendSV_Handler .word SysTick_Handler .word WWDG_IRQHandler /* Window WatchDog */ - .word 0 /* Reserved */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ .word RTC_IRQHandler /* RTC through the EXTI line */ .word FLASH_IRQHandler /* FLASH */ .word RCC_IRQHandler /* RCC */ @@ -170,22 +150,22 @@ g_pfnVectors: .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */ .word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */ .word DMA1_Channel4_5_6_7_IRQHandler /* DMA1 Channel 4, Channel 5, Channel 6 and Channel 7*/ - .word ADC1_IRQHandler /* ADC1 */ + .word ADC1_COMP_IRQHandler /* ADC1, COMP1 and COMP2 */ .word LPTIM1_IRQHandler /* LPTIM1 */ - .word 0 /* Reserved */ + .word USART4_5_IRQHandler /* USART4 and USART 5 */ .word TIM2_IRQHandler /* TIM2 */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM6_IRQHandler /* TIM6 and DAC */ + .word TIM7_IRQHandler /* TIM7 */ + .word 0 /* Reserved */ .word TIM21_IRQHandler /* TIM21 */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ + .word I2C3_IRQHandler /* I2C3 */ + .word TIM22_IRQHandler /* TIM22 */ .word I2C1_IRQHandler /* I2C1 */ - .word 0 /* Reserved */ + .word I2C2_IRQHandler /* I2C2 */ .word SPI1_IRQHandler /* SPI1 */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ .word USART2_IRQHandler /* USART2 */ .word LPUART1_IRQHandler /* LPUART1 */ .word 0 /* Reserved */ @@ -217,6 +197,9 @@ g_pfnVectors: .weak WWDG_IRQHandler .thumb_set WWDG_IRQHandler,Default_Handler + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + .weak RTC_IRQHandler .thumb_set RTC_IRQHandler,Default_Handler @@ -244,24 +227,51 @@ g_pfnVectors: .weak DMA1_Channel4_5_6_7_IRQHandler .thumb_set DMA1_Channel4_5_6_7_IRQHandler,Default_Handler - .weak ADC1_IRQHandler - .thumb_set ADC1_IRQHandler,Default_Handler + .weak ADC1_COMP_IRQHandler + .thumb_set ADC1_COMP_IRQHandler,Default_Handler .weak LPTIM1_IRQHandler .thumb_set LPTIM1_IRQHandler,Default_Handler + .weak USART4_5_IRQHandler + .thumb_set USART4_5_IRQHandler,Default_Handler + .weak TIM2_IRQHandler .thumb_set TIM2_IRQHandler,Default_Handler + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM6_IRQHandler + .thumb_set TIM6_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + .weak TIM21_IRQHandler .thumb_set TIM21_IRQHandler,Default_Handler + .weak I2C3_IRQHandler + .thumb_set I2C3_IRQHandler,Default_Handler + + .weak TIM22_IRQHandler + .thumb_set TIM22_IRQHandler,Default_Handler + .weak I2C1_IRQHandler .thumb_set I2C1_IRQHandler,Default_Handler + .weak I2C2_IRQHandler + .thumb_set I2C2_IRQHandler,Default_Handler + .weak SPI1_IRQHandler .thumb_set SPI1_IRQHandler,Default_Handler + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + .weak USART2_IRQHandler .thumb_set USART2_IRQHandler,Default_Handler @@ -271,5 +281,4 @@ g_pfnVectors: -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/software/dumber3/Dumber3 Debug.launch b/software/dumber3/Dumber3 Debug.launch index 986c379..98197f0 100644 --- a/software/dumber3/Dumber3 Debug.launch +++ b/software/dumber3/Dumber3 Debug.launch @@ -35,13 +35,13 @@ - + - + - + - + @@ -73,6 +73,7 @@ - + + diff --git a/software/dumber3/Dumber3.ioc b/software/dumber3/Dumber3.ioc index 443b4f5..22f821e 100644 --- a/software/dumber3/Dumber3.ioc +++ b/software/dumber3/Dumber3.ioc @@ -5,15 +5,6 @@ ADC.SamplingTime=ADC_SAMPLETIME_160CYCLES_5 CAD.formats= CAD.pinconfig= CAD.provider= -Dma.LPUART1_RX.1.Direction=DMA_PERIPH_TO_MEMORY -Dma.LPUART1_RX.1.Instance=DMA1_Channel3 -Dma.LPUART1_RX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.LPUART1_RX.1.MemInc=DMA_MINC_ENABLE -Dma.LPUART1_RX.1.Mode=DMA_NORMAL -Dma.LPUART1_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.LPUART1_RX.1.PeriphInc=DMA_PINC_DISABLE -Dma.LPUART1_RX.1.Priority=DMA_PRIORITY_HIGH -Dma.LPUART1_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority Dma.LPUART1_TX.0.Direction=DMA_MEMORY_TO_PERIPH Dma.LPUART1_TX.0.Instance=DMA1_Channel2 Dma.LPUART1_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE @@ -24,15 +15,15 @@ Dma.LPUART1_TX.0.PeriphInc=DMA_PINC_DISABLE Dma.LPUART1_TX.0.Priority=DMA_PRIORITY_HIGH Dma.LPUART1_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority Dma.Request0=LPUART1_TX -Dma.Request1=LPUART1_RX -Dma.RequestsNb=2 +Dma.RequestsNb=1 FREERTOS.INCLUDE_pcTaskGetTaskName=1 FREERTOS.INCLUDE_xEventGroupSetBitFromISR=1 FREERTOS.INCLUDE_xTaskAbortDelay=1 FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1 FREERTOS.INCLUDE_xTaskGetHandle=1 -FREERTOS.IPParameters=Tasks01,configTICK_RATE_HZ,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetHandle,INCLUDE_xTaskAbortDelay,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_pcTaskGetTaskName,INCLUDE_xTaskGetCurrentTaskHandle,configTOTAL_HEAP_SIZE,configUSE_NEWLIB_REENTRANT +FREERTOS.IPParameters=Tasks01,configTICK_RATE_HZ,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetHandle,INCLUDE_xTaskAbortDelay,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_pcTaskGetTaskName,INCLUDE_xTaskGetCurrentTaskHandle,configTOTAL_HEAP_SIZE,configUSE_NEWLIB_REENTRANT,configMAX_TASK_NAME_LEN FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configMAX_TASK_NAME_LEN=25 FREERTOS.configTICK_RATE_HZ=1000 FREERTOS.configTOTAL_HEAP_SIZE=1024 FREERTOS.configUSE_NEWLIB_REENTRANT=1 @@ -41,7 +32,8 @@ File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false LPUART1.BaudRate=115200 -LPUART1.IPParameters=BaudRate,WordLength +LPUART1.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR +LPUART1.IPParameters=BaudRate,WordLength,DMADisableonRxErrorParam LPUART1.WordLength=UART_WORDLENGTH_8B Mcu.CPN=STM32L071CBT3 Mcu.Family=STM32L0 @@ -100,7 +92,7 @@ Mcu.UserName=STM32L071CBTx MxCube.Version=6.7.0 MxDb.Version=DB.6.0.70 NVIC.ADC1_COMP_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.DMA1_Channel2_3_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DMA1_Channel2_3_IRQn=true\:3\:0\:true\:false\:true\:true\:false\:true\:true NVIC.EXTI2_3_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true NVIC.EXTI4_15_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true @@ -115,7 +107,7 @@ NVIC.SavedSystickIrqHandlerGenerated=true NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:false\:true\:false\:true\:false NVIC.TIM21_IRQn=true\:1\:0\:true\:false\:true\:false\:true\:true\:true NVIC.TIM2_IRQn=true\:1\:0\:true\:false\:true\:false\:true\:true\:true -NVIC.TIM6_IRQn=true\:3\:0\:true\:false\:true\:false\:true\:true\:true +NVIC.TIM6_IRQn=true\:3\:0\:false\:false\:true\:false\:false\:true\:true NVIC.TimeBase=TIM6_IRQn NVIC.TimeBaseIP=TIM6 PA0.GPIOParameters=GPIO_Label @@ -126,9 +118,10 @@ PA1.GPIOParameters=GPIO_Label PA1.GPIO_Label=ENC_PHA_GAUCHE PA1.Locked=true PA1.Signal=GPIO_Input -PA10.GPIOParameters=GPIO_Label +PA10.GPIOParameters=PinState,GPIO_Label PA10.GPIO_Label=XBEE_RESET PA10.Locked=true +PA10.PinState=GPIO_PIN_RESET PA10.Signal=GPIO_Output PA11.GPIOParameters=GPIO_Label PA11.GPIO_Label=LED_SEG_F