Driver XBEE semble enfin marcher correctement

This commit is contained in:
vezde 2023-04-11 17:14:18 +02:00
parent c6ad9b7094
commit aa83f00d28
15 changed files with 521 additions and 377 deletions

View file

@ -110,15 +110,40 @@
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1151842665" name="Resource Custom Build Step Output Type"/> <outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1151842665" name="Resource Custom Build Step Output Type"/>
</tool> </tool>
</fileInfo> </fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.2043503841" name="main.c" rcbsApplicability="disable" resourcePath="Core/Src/main.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.346617134"> <fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.1752824616" name="commands.c" rcbsApplicability="disable" resourcePath="Application/commands.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.2065737495">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.346617134" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.2065737495" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646">
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1496459642" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1535445780" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1660271606" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool> </tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.216781005" name="Resource Custom Build Step"> <tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1545965840" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.2033552080" name="Resource Custom Build Step Input Type"> <inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1314783453" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency"/> <additionalInput kind="additionalinputdependency" paths=""/>
</inputType> </inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.664489298" name="Resource Custom Build Step Output Type"/> <outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.930101754" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.1827743340" name="application.c" rcbsApplicability="disable" resourcePath="Application/application.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.2011451410">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.2011451410" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1397894115" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1629958820" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.389963892" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.115340338" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1700687045" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.306963435" name="xbee.c" rcbsApplicability="disable" resourcePath="Application/xbee.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.277959437">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.277959437" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.980636813" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1291936146" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1344848918" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1895641321" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.840380300" name="Resource Custom Build Step Output Type"/>
</tool> </tool>
</fileInfo> </fileInfo>
<sourceEntries> <sourceEntries>

View file

@ -38,6 +38,8 @@ typedef struct {
int32_t motor_right; int32_t motor_right;
char endOfMouvement; char endOfMouvement;
char powerOffRequired; char powerOffRequired;
uint16_t senderAddress;
uint8_t rfProblem;
} APPLICATION_Infos; } APPLICATION_Infos;
@ -83,8 +85,8 @@ void APPLICATION_Init(void) {
/* Init de la partie RF / reception des messages */ /* Init de la partie RF / reception des messages */
XBEE_Init(); XBEE_Init();
BATTERIE_Init(); //BATTERIE_Init();
MOTEURS_Init(); //MOTEURS_Init();
/* Create the task without using any dynamic memory allocation. */ /* Create the task without using any dynamic memory allocation. */
xHandleApplicationMain = xTaskCreateStatic( xHandleApplicationMain = xTaskCreateStatic(
@ -112,8 +114,8 @@ void APPLICATION_Init(void) {
void APPLICATION_MainThread(void* params) { void APPLICATION_MainThread(void* params) {
MESSAGE_Typedef msg; MESSAGE_Typedef msg;
XBEE_INCOMING_FRAME *xbeeFrame;
char *cmd;
CMD_Generic* decodedCmd; CMD_Generic* decodedCmd;
while (1) { while (1) {
@ -121,54 +123,84 @@ void APPLICATION_MainThread(void* params) {
switch (msg.id) { switch (msg.id) {
case MSG_ID_XBEE_CMD: case MSG_ID_XBEE_CMD:
cmd = (char*)msg.data; // systemInfos.senderAddress = 0x81;
decodedCmd = cmdDecode(cmd); // systemInfos.cmd = 0;
// cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
//
// if (msg.data != NULL)
// free (msg.data);
if (decodedCmd==CMD_DECODE_UNKNOWN) xbeeFrame = (XBEE_INCOMING_FRAME*)msg.data;
cmdSendAnswer(ANS_UNKNOWN);
else {
systemInfos.cmd = decodedCmd->type;
systemTimeout.inactivityCnt = 0;
/* Manage answer to command, when possible if (xbeeFrame != NULL) {
* (further treatment of the command will be done in APPLICATION_StateMachine) */ systemInfos.senderAddress = xbeeFrame->source_addr;
switch (decodedCmd->type) {
case CMD_PING: switch (xbeeFrame->type) {
case CMD_TEST: case XBEE_RX_16BIT_PACKET_TYPE:
case CMD_DEBUG: decodedCmd = cmdDecode(xbeeFrame->data,xbeeFrame->length);
case CMD_POWER_OFF:
cmdSendAnswer(ANS_OK); 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; break;
case CMD_GET_BATTERY:
cmdSendBatteryLevel(systemInfos.batteryVoltage); case XBEE_TX_STATUS_TYPE:
break; if (xbeeFrame->ack == 0) {
case CMD_GET_VERSION: if (systemInfos.rfProblem !=0)
cmdSendVersion(SYSTEM_VERSION); systemInfos.rfProblem--;
break; } else {
case CMD_GET_BUSY_STATE: if (systemInfos.rfProblem !=255)
if (systemInfos.state == stateInMouvement) systemInfos.rfProblem++;
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;
break; break;
default: default:
/* All others commands must be processed in state machine
* in order to find what action to do and what answer to give
*/
break; break;
} }
free(decodedCmd); // if (xbeeFrame->data != NULL)
// free(xbeeFrame->data);
free(xbeeFrame);
} }
free(cmd);
break; break;
case MSG_ID_BAT_NIVEAU: case MSG_ID_BAT_NIVEAU:
@ -232,16 +264,16 @@ void APPLICATION_StateMachine() {
(systemInfos.state == stateRun) || (systemInfos.state == stateRun) ||
(systemInfos.state == stateInMouvement)) { (systemInfos.state == stateInMouvement)) {
/* command RESET is only applicable in those 3 states, otherwise it is rejected */ /* command RESET is only applicable in those 3 states, otherwise it is rejected */
cmdSendAnswer(ANS_OK); cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
APPLICATION_TransitionToNewState(stateIdle); APPLICATION_TransitionToNewState(stateIdle);
} else } else
cmdSendAnswer(ANS_ERR); cmdSendAnswer(systemInfos.senderAddress, ANS_ERR);
break; break;
case CMD_START_WITH_WATCHDOG: case CMD_START_WITH_WATCHDOG:
case CMD_START_WITHOUT_WATCHDOG: case CMD_START_WITHOUT_WATCHDOG:
if (systemInfos.state == stateIdle) { if (systemInfos.state == stateIdle) {
/* only state where START cmd is accepted */ /* only state where START cmd is accepted */
cmdSendAnswer(ANS_OK); cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
APPLICATION_TransitionToNewState(stateRun); APPLICATION_TransitionToNewState(stateRun);
@ -251,15 +283,15 @@ void APPLICATION_StateMachine() {
systemTimeout.watchdogMissedCnt=0; systemTimeout.watchdogMissedCnt=0;
} }
} else } else
cmdSendAnswer(ANS_ERR); cmdSendAnswer(systemInfos.senderAddress, ANS_ERR);
break; break;
case CMD_RESET_WATCHDOG: case CMD_RESET_WATCHDOG:
if ((systemInfos.state == stateRun) || (systemInfos.state == stateInMouvement)) { if ((systemInfos.state == stateRun) || (systemInfos.state == stateInMouvement)) {
if ((systemTimeout.watchdogEnabled ==0 ) || if ((systemTimeout.watchdogEnabled ==0 ) ||
((systemTimeout.watchdogCnt>=APPLICATION_WATCHDOG_MIN) && (systemTimeout.watchdogCnt<=APPLICATION_WATCHDOG_MAX))) ((systemTimeout.watchdogCnt>=APPLICATION_WATCHDOG_MIN) && (systemTimeout.watchdogCnt<=APPLICATION_WATCHDOG_MAX)))
cmdSendAnswer(ANS_OK); cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
else else
cmdSendAnswer(ANS_ERR); cmdSendAnswer(systemInfos.senderAddress, ANS_ERR);
systemTimeout.watchdogCnt =0; systemTimeout.watchdogCnt =0;
} }
@ -271,17 +303,17 @@ void APPLICATION_StateMachine() {
if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance !=0)) || if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance !=0)) ||
((systemInfos.cmd == CMD_TURN) && (systemInfos.turns !=0))) { ((systemInfos.cmd == CMD_TURN) && (systemInfos.turns !=0))) {
systemInfos.endOfMouvement = 0; systemInfos.endOfMouvement = 0;
cmdSendAnswer(ANS_OK); cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
APPLICATION_TransitionToNewState(stateInMouvement); APPLICATION_TransitionToNewState(stateInMouvement);
} // if TURN and MOVE are sent without parameter, do nothing: we are still in run state } // 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 } 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)) || if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance ==0)) ||
((systemInfos.cmd == CMD_TURN) && (systemInfos.turns ==0))) { ((systemInfos.cmd == CMD_TURN) && (systemInfos.turns ==0))) {
systemInfos.endOfMouvement = 1; systemInfos.endOfMouvement = 1;
cmdSendAnswer(ANS_OK); cmdSendAnswer(systemInfos.senderAddress, ANS_OK);
} }
} else } else
cmdSendAnswer(ANS_ERR); cmdSendAnswer(systemInfos.senderAddress, ANS_ERR);
break; break;
default: // commands no common for every states default: // commands no common for every states
break; break;

View file

@ -12,22 +12,44 @@
/* Definition des commandes */ /* Definition des commandes */
CMD_Generic* cmdDecode(char* cmd) { CMD_Generic* cmdDecode(char* cmd, uint8_t length) {
CMD_Generic* decodedCmd; 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: case CMD_MOVE:
decodedCmd = (CMD_Generic*)malloc(sizeof(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; break;
case CMD_TURN: case CMD_TURN:
decodedCmd = (CMD_Generic*)malloc(sizeof(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]; sscanf (&rawCmd[1], "%d", &val);
((CMD_Turn*)decodedCmd)->turns = ((CMD_Turn*)decodedCmd)->turns * 1.4;
((CMD_Turn*)decodedCmd)->turns = (int16_t) val;
((CMD_Turn*)decodedCmd)->turns = ((CMD_Turn*)decodedCmd)->turns * 1.4;
}
break; break;
case CMD_PING: case CMD_PING:
@ -43,22 +65,29 @@ CMD_Generic* cmdDecode(char* cmd) {
case CMD_POWER_OFF: case CMD_POWER_OFF:
decodedCmd = (CMD_Generic*)malloc(sizeof(CMD_Generic)); decodedCmd = (CMD_Generic*)malloc(sizeof(CMD_Generic));
decodedCmd->type = cmd[0]; decodedCmd->type = cmd[0];
break;
default: default:
decodedCmd = CMD_DECODE_UNKNOWN; decodedCmd = CMD_DECODE_UNKNOWN;
} }
endTime=SysTick->VAL;
if (endTime>startTime)
duration = (uint32_t)(SysTick->LOAD+1)-endTime+startTime;
else
duration = startTime-endTime;
return decodedCmd; return decodedCmd;
} }
void cmdSendAnswer(uint8_t ans) { void cmdSendAnswer(uint16_t address, uint8_t ans) {
ANS_Generic answer; ANS_Generic answer;
answer.ans = ans; 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; ANS_Battery answer;
char localLevel=level; char localLevel=level;
@ -68,19 +97,19 @@ void cmdSendBatteryLevel(char level) {
answer.ans = ANS_OK; answer.ans = ANS_OK;
answer.bat_level = localLevel; 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; ANS_Version answer;
answer.ans = ANS_OK; 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; ANS_Busy_State answer;
answer.ans = ANS_OK; answer.ans = ANS_OK;
@ -88,5 +117,5 @@ void cmdSendBusyState(uint8_t state) {
if (answer.state >1) answer.state=0; if (answer.state >1) answer.state=0;
XBEE_SendData((char*)&answer, sizeof (answer)); XBEE_SendData(address, (char*)&answer, sizeof (answer));
} }

View file

@ -10,31 +10,39 @@
#include "application.h" #include "application.h"
#define CMD_NONE 0x0 typedef enum {
#define CMD_PING 0x1 CMD_NONE=0x0,
#define CMD_RESET 0x2 CMD_PING,
#define CMD_START_WITH_WATCHDOG 0x3 CMD_RESET,
#define CMD_RESET_WATCHDOG 0x4 CMD_START_WITH_WATCHDOG,
#define CMD_GET_BATTERY 0x5 CMD_RESET_WATCHDOG,
#define CMD_GET_VERSION 0x6 CMD_GET_BATTERY,
#define CMD_START_WITHOUT_WATCHDOG 0x7 CMD_GET_VERSION,
#define CMD_MOVE 0x8 CMD_START_WITHOUT_WATCHDOG,
#define CMD_TURN 0x9 CMD_MOVE,
#define CMD_GET_BUSY_STATE 0xA CMD_TURN,
#define CMD_TEST 0xB CMD_GET_BUSY_STATE,
#define CMD_DEBUG 0xC CMD_TEST,
#define CMD_POWER_OFF 0xD CMD_DEBUG,
CMD_POWER_OFF
} CMD_CommandsType;
#define ANS_OK 0x80 typedef enum {
#define ANS_ERR 0x81 ANS_OK=0x80,
#define ANS_UNKNOWN 0x82 ANS_ERR,
ANS_UNKNOWN
} CMD_AnswersType;
#define ANS_BAT_OK 0x2 typedef enum {
#define ANS_BAT_LOW 0x1 ANS_BAT_EMPTY=0,
#define ANS_BAT_EMPTY 0x0 ANS_BAT_LOW,
ANS_BAT_OK
} CMD_BatteryLevelType;
#define ANS_STATE_NOT_BUSY 0x0 typedef enum {
#define ANS_STATE_BUSY 0x1 ANS_STATE_NOT_BUSY=0,
ANS_STATE_BUSY
} CMD_BusyType;
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
uint8_t type; uint8_t type;
@ -56,7 +64,7 @@ typedef struct __attribute__((packed)) {
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
uint8_t ans; uint8_t ans;
uint8_t version; char version[6];
} ANS_Version; } ANS_Version;
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
@ -72,10 +80,10 @@ typedef struct __attribute__((packed)) {
#define CMD_DECODE_INVALID ((CMD_Generic*)NULL) #define CMD_DECODE_INVALID ((CMD_Generic*)NULL)
#define CMD_DECODE_UNKNOWN ((CMD_Generic*)UINT32_MAX) #define CMD_DECODE_UNKNOWN ((CMD_Generic*)UINT32_MAX)
CMD_Generic* cmdDecode(char* cmd); CMD_Generic* cmdDecode(char* cmd, uint8_t length);
void cmdSendAnswer(uint8_t ans); void cmdSendAnswer(uint16_t address, uint8_t ans);
void cmdSendBatteryLevel(char level); void cmdSendBatteryLevel(uint16_t address, char level);
void cmdSendVersion(); void cmdSendVersion(uint16_t address);
void cmdSendBusyState(uint8_t state); void cmdSendBusyState(uint16_t address, uint8_t state);
#endif /* INC_CMD_H_ */ #endif /* INC_CMD_H_ */

View file

@ -7,7 +7,7 @@
#include "stm32l0xx_hal.h" #include "stm32l0xx_hal.h"
#include "cmsis_os.h" #include "cmsis_os.h"
#define SYSTEM_VERSION_STR "version 2.0\r" #define SYSTEM_VERSION_STR "2.0"
#define SYSTEM_VERSION 0x20 #define SYSTEM_VERSION 0x20
#define STACK_SIZE 0x100 #define STACK_SIZE 0x100

View file

@ -42,12 +42,6 @@ typedef struct {
MOTEURS_EtatMoteur MOTEURS_EtatMoteurGauche, MOTEURS_EtatMoteurDroit = {0}; MOTEURS_EtatMoteur MOTEURS_EtatMoteurGauche, MOTEURS_EtatMoteurDroit = {0};
MOTEURS_EtatDiff MOTEURS_EtatDifferentiel; 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_Kp 15
#define MOTEUR_DELAY 3 #define MOTEUR_DELAY 3
@ -101,6 +95,8 @@ void MOTEURS_Init(void) {
xStackMoteursAsservissement, /* Array to use as the task's stack. */ xStackMoteursAsservissement, /* Array to use as the task's stack. */
&xTaskMoteursAsservissement); /* Variable to hold the task's data structure. */ &xTaskMoteursAsservissement); /* Variable to hold the task's data structure. */
vTaskSuspend(xHandleMoteursAsservissement); // On ne lance la tache d'asservissement que lorsque'une commande moteur arrive vTaskSuspend(xHandleMoteursAsservissement); // On ne lance la tache d'asservissement que lorsque'une commande moteur arrive
MOTEURS_DesactiveAlim();
} }
void MOTEURS_Avance(uint32_t distance) { void MOTEURS_Avance(uint32_t distance) {
@ -136,19 +132,37 @@ void MOTEURS_TachePrincipale(void* params) {
switch (msg.id) { switch (msg.id) {
case MSG_ID_MOTEURS_MOVE: case MSG_ID_MOTEURS_MOVE:
distance = *((uint32_t*)msg.data); 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); vTaskResume(xHandleMoteursAsservissement);
break; break;
case MSG_ID_MOTEURS_TURN: case MSG_ID_MOTEURS_TURN:
tours = *((uint32_t*)msg.data); 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); vTaskResume(xHandleMoteursAsservissement);
break; break;
case MSG_ID_MOTEURS_STOP: case MSG_ID_MOTEURS_STOP:
// TODO: trucs a faire ici MOTEURS_EtatDifferentiel.distance = 0;
vTaskSuspend(xHandleMoteursAsservissement); 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; break;
default: default:
break; break;
@ -181,8 +195,14 @@ void MOTEURS_TacheAsservissement( void* params ) {
deltaD = MOTEURS_EtatMoteurDroit.consigne - encodeurDroit; deltaD = MOTEURS_EtatMoteurDroit.consigne - encodeurDroit;
if (((MOTEURS_EtatMoteurDroit.consigne ==0) && (MOTEURS_EtatMoteurGauche.consigne ==0)) && if (((MOTEURS_EtatMoteurDroit.consigne ==0) && (MOTEURS_EtatMoteurGauche.consigne ==0)) &&
((deltaD==0) && (deltaG==0))) MOTEURS_DesactiveAlim(); ((deltaD==0) && (deltaG==0))) {
else MOTEURS_ActiveAlim(); MOTEURS_DesactiveAlim();
vTaskSuspend(xHandleMoteursAsservissement);
}
else if (MOTEURS_EtatAlim() == GPIO_PIN_RESET) {
MOTEURS_ActiveAlim();
}
if (deltaG !=0) { if (deltaG !=0) {
MOTEURS_EtatMoteurGauche.commande = MOTEURS_EtatMoteurGauche.commande + MOTEUR_Kp*deltaG; MOTEURS_EtatMoteurGauche.commande = MOTEURS_EtatMoteurGauche.commande + MOTEUR_Kp*deltaG;

View file

@ -10,6 +10,7 @@
#include "semphr.h" #include "semphr.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "stm32l0xx_ll_usart.h"
extern UART_HandleTypeDef hlpuart1; extern UART_HandleTypeDef hlpuart1;
extern DMA_HandleTypeDef hdma_lpuart1_tx; extern DMA_HandleTypeDef hdma_lpuart1_tx;
@ -28,15 +29,23 @@ StaticTask_t xTaskXbeeRX;
StackType_t xStackXbeeRX[ STACK_SIZE ]; StackType_t xStackXbeeRX[ STACK_SIZE ];
TaskHandle_t xHandleXbeeRX = NULL; TaskHandle_t xHandleXbeeRX = NULL;
uint8_t txBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0};
uint16_t txIndex;
uint16_t txDataToSend;
void XBEE_RxThread(void* params); void XBEE_RxThread(void* params);
SemaphoreHandle_t xHandleSemaphoreRX = NULL; SemaphoreHandle_t xHandleSemaphoreRX = NULL;
StaticSemaphore_t xSemaphoreRx; StaticSemaphore_t xSemaphoreRx;
uint8_t* rxBuffer; uint8_t rxBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0};
uint8_t rxWaitForACK; //uint8_t rxWaitForACK =0;
uint8_t rxPhase; 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_HEADER 1
#define XBEE_RX_PHASE_BODY 2 #define XBEE_RX_PHASE_BODY 2
@ -46,15 +55,27 @@ SemaphoreHandle_t xHandleSemaphoreTX_ACK = NULL;
StaticSemaphore_t xSemaphoreTX; StaticSemaphore_t xSemaphoreTX;
StaticSemaphore_t xSemaphoreTX_ACK; StaticSemaphore_t xSemaphoreTX_ACK;
uint8_t* txBuffer;
void XBEE_Init(void) { void XBEE_Init(void) {
xHandleSemaphoreTX = xSemaphoreCreateBinaryStatic( &xSemaphoreTX ); xHandleSemaphoreTX = xSemaphoreCreateBinaryStatic( &xSemaphoreTX );
xHandleSemaphoreTX_ACK = xSemaphoreCreateBinaryStatic( &xSemaphoreTX_ACK ); xHandleSemaphoreTX_ACK = xSemaphoreCreateBinaryStatic( &xSemaphoreTX_ACK );
xSemaphoreGive(xHandleSemaphoreTX); xSemaphoreGive(xHandleSemaphoreTX);
//xSemaphoreTake(xHandleSemaphoreTX_ACK);
rxBuffer=(uint8_t*)malloc(XBEE_RX_BUFFER_MAX_LENGTH); xHandleSemaphoreRX = xSemaphoreCreateBinaryStatic( &xSemaphoreRx );
rxWaitForACK = 0;
/* 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 ****/ /**** Support functions ****/
@ -110,33 +131,6 @@ char* XBEE_EncodeWithEscapeChar(char* data, int length, int *encodedLength) {
return encodedData; 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 * 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 * \param frameLength length of frame
* \return new frame (allocated) containing escaped data * \return new frame (allocated) containing escaped data
*/ */
char* XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination, int* frameLength) { void XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination, char* frame, int* frameLength) {
uint8_t checksum; uint8_t checksum=0;
char* frame; uint16_t localLength=0;
char* p;
int encodedLength; localLength = length+9;
char *encodedData = XBEE_EncodeWithEscapeChar(data, length, &encodedLength);
*frameLength= encodedLength+9; frame[0] = (char)XBEE_FRAME_SOF_CHAR;
frame = (char*)malloc(*frameLength); frame[1] = (char)((uint16_t)(localLength-4)>>8);
frame[2] = (char)((uint16_t)(localLength-4));
frame[0] = '~';
frame[1] = (char)((uint16_t)(*frameLength-3)>>8);
frame[2] = (char)((uint16_t)(*frameLength-3));
frame[3] = (char)XBEE_TX_16BIT_REQUEST_TYPE; frame[3] = (char)XBEE_TX_16BIT_REQUEST_TYPE;
frame[4] = 0x1; frame[4] = 0x1;
@ -167,22 +158,25 @@ char* XBEE_EncodeTransmissionFrame(char* data, int length, uint16_t destination,
frame[7] = 0x0; frame[7] = 0x0;
char* p_data = encodedData; for (p = &frame[8]; p< (data + length); p++) {
for (char *p=&frame[8]; p<&frame[8] + encodedLength; p++, p_data++) { if ((*data == (char)XBEE_API_ESCAPE_CHAR) || (*data == (char)XBEE_API_START_OF_FRAME) ||
*p= *p_data; (*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 */ /* calcul du checksum */
checksum =0; for (int i=3; i<(localLength-1); i++) {
for (int i=3; i<*frameLength; i++) {
checksum += (uint8_t)frame[i]; checksum += (uint8_t)frame[i];
} }
frame[*frameLength] = 0xFF-checksum; *p = 0xFF-checksum;
*frameLength = localLength;
free ((void*)encodedData);
return frame;
} }
/** /**
@ -207,7 +201,8 @@ XBEE_Status XBEE_DecodeFrame(char* rawFrame, XBEE_INCOMING_FRAME** incomingFrame
uint16_t rawFrameLength; uint16_t rawFrameLength;
uint8_t checksum; uint8_t checksum;
XBEE_Status status = XBEE_OK; XBEE_Status status = XBEE_OK;
int incomingDataLength = 0; int allocatedSize;
int dataSize;
int i; int i;
@ -223,34 +218,56 @@ XBEE_Status XBEE_DecodeFrame(char* rawFrame, XBEE_INCOMING_FRAME** incomingFrame
if (checksum != 0xFF) if (checksum != 0xFF)
return XBEE_INVALID_FRAME; 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) { switch (frame_type) {
case XBEE_RX_16BIT_PACKET_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 */ /* Get source address */
(*incomingFrame)->source_addr = (((uint16_t)rawFrame[4])<<8) + (uint16_t)rawFrame[5]; (*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; (*incomingFrame)->ack = 0;
for (i=0; i<dataSize; i++)
(*incomingFrame)->data[i] = rawFrame[i+8];
break; break;
case XBEE_MODEM_STATUS_TYPE: 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)->modem_status = rawFrame[4];
(*incomingFrame)->data=0x0; (*incomingFrame)->data[0]=0x0;
(*incomingFrame)->length = 0;
break; break;
case XBEE_TX_STATUS_TYPE: 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)->ack = rawFrame[5];
(*incomingFrame)->data=0x0; (*incomingFrame)->data[0]=0x0;
(*incomingFrame)->length = 0;
break; break;
case XBEE_EXTENDED_TX_STATUS_TYPE: 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)->ack = rawFrame[8];
(*incomingFrame)->data=0x0; (*incomingFrame)->data[0]=0x0;
(*incomingFrame)->length = 0;
break; break;
default: default:
free (*incomingFrame); *incomingFrame=NULL;
return XBEE_INVALID_FRAME; return XBEE_INVALID_FRAME;
}; };
} else status = 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 * \param length length of data to send
* \return status of decoding: XBEE_OK if decoding is successful, * \return status of decoding: XBEE_OK if decoding is successful,
* XBEE_TX_ERROR in case of sending error, * 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 XBEE_SendData(uint16_t address, char* data, int length) {
int data_length;
BaseType_t state; BaseType_t state;
XBEE_INCOMING_FRAME* incomingFrame; int status = XBEE_OK;
// Prevents successive calls to overlap // Prevents successive calls to overlap
state = xSemaphoreTake(xHandleSemaphoreTX, pdMS_TO_TICKS(XBEE_TX_SEMAPHORE_WAIT)); // wait max 500 ms (to avoid interlocking) 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 if answer is false, it means timeout appends
We should probably reset something in "else" branch */ We should probably reset something in "else" branch */
/* TODO: stuff to do here for converting data into API frame */ XBEE_EncodeTransmissionFrame(data, length, address, (char*) txBuffer, (int*)&txDataToSend);
txBuffer = (uint8_t*)XBEE_EncodeWithEscapeChar(data, length, &data_length);
if (txBuffer!=NULL) { LL_USART_TransmitData8(hlpuart1.Instance, txBuffer[0]);
if (HAL_UART_Transmit_DMA(&hlpuart1, txBuffer, data_length)!= HAL_OK) txIndex =1;
return XBEE_TX_ERROR; LL_USART_EnableIT_TXE(hlpuart1.Instance); // enable TX Interrupt
else { } else status= XBEE_TX_TIMEOUT;
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;
return length; return status;
} }
/** void XBEE_TX_IRQHandler(void) {
* DMA Interrupt request for transmission. Call when transmission is finished
*
* \param UartHandle not used
*/
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE; 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 ); xSemaphoreGiveFromISR( xHandleSemaphoreTX, &xHigherPriorityTaskWoken );
}
/* If xHigherPriorityTaskWoken was set to true you if (xHigherPriorityTaskWoken) {
we should yield. The actual macro used here is /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch
port specific. */ should be performed to ensure the interrupt returns directly to the highest
portYIELD_FROM_ISR(xHigherPriorityTaskWoken ); 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 *****/ /***** Rx Part *****/
@ -335,53 +334,78 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle) {
* \param params not used * \param params not used
*/ */
void XBEE_RxThread(void* params) { void XBEE_RxThread(void* params) {
BaseType_t state; XBEE_INCOMING_FRAME *incomingFrame;
XBEE_INCOMING_FRAME* incomingFrame;
rxPhase= XBEE_RX_PHASE_HEADER; rxPhase= XBEE_RX_PHASE_SOF;
while (HAL_UART_Receive_DMA(&hlpuart1, rxBuffer, 3)== HAL_OK); // start reception of frame 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 // endless task
while (1) { while (1) {
while ((state = xSemaphoreTake(xHandleSemaphoreRX, portMAX_DELAY))==pdTRUE); // wait forever if (xSemaphoreTake(xHandleSemaphoreRX, portMAX_DELAY)==pdTRUE) { // wait forever
/* Process frame */ /* Process frame */
if (XBEE_DecodeFrame((char*) rxBuffer, &incomingFrame)==XBEE_OK) // frame is valid if (XBEE_DecodeFrame((char*) rxBuffer, &incomingFrame)==XBEE_OK) { // frame is valid
if (incomingFrame != 0x0) // frame is valid if (incomingFrame != 0x0) // frame is valid
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_XBEE_CMD, (QueueHandle_t)0x0, (void*)incomingFrame); 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; i<XBEE_RX_BUFFER_MAX_LENGTH; i++)
rxBuffer[i]=0xFF;
}
} }
} }
/** void XBEE_RX_IRQHandler(void) {
* DMA IRQ handler for reception. Receive a complete frame send send event to sending frame in case of acknowledge frame or to receive task otherwise
*
* \param UartHandle not used
*/
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
uint16_t frameLength; uint8_t data;
if (rxPhase == XBEE_RX_PHASE_HEADER) { // we just received header part data = LL_USART_ReceiveData8(hlpuart1.Instance); // lecture de l'octet reçu
frameLength=XBEE_GetFrameLength(rxBuffer); /* Compute body part of the frame + checksum */
if (HAL_UART_Receive_DMA(&hlpuart1, rxBuffer+3, frameLength+1)== HAL_OK) { switch (rxPhase) {
/* Reception of body part started successfully */ case XBEE_RX_PHASE_SOF:
rxPhase = XBEE_RX_PHASE_BODY; if (data == XBEE_FRAME_SOF_CHAR) {
} else { rxBuffer[0] = data;
/* Failed to start reception of body rxPhase = XBEE_RX_PHASE_HEADER;
* Restart reception of header */ rxIndex = 1;
while (HAL_UART_Receive_DMA(&hlpuart1, rxBuffer, 3)!= HAL_OK); // try to receive header
} }
} else { // we just received body part. Frame is complete break;
if (rxWaitForACK) { case XBEE_RX_PHASE_HEADER:
xSemaphoreGiveFromISR( xHandleSemaphoreTX_ACK, &xHigherPriorityTaskWoken); /* Send event to sending function */ rxBuffer[rxIndex] = data;
xSemaphoreGiveFromISR( xHandleSemaphoreTX, &xHigherPriorityTaskWoken ); /* Allow new sending data */ rxIndex ++;
} else {
if (rxIndex==3) {
// header reçu, calcul de la longueur de la frame
rxFrameLength = (((uint16_t)rxBuffer[1]) << 8) + (uint16_t)rxBuffer[2];
rxDataToReceive = rxFrameLength +1; // +1 for checksum
rxPhase = XBEE_RX_PHASE_BODY;
}
break;
case XBEE_RX_PHASE_BODY:
rxBuffer[rxIndex] = data;
if (rxBuffer[rxIndex-1] == XBEE_API_ESCAPE_CHAR)
rxBuffer[rxIndex-1] = rxBuffer[rxIndex] ^ 0x20;
else {
rxIndex++;
rxDataToReceive--;
}
if (!rxDataToReceive) {
rxIndex=0;
rxPhase = XBEE_RX_PHASE_SOF;
xSemaphoreGiveFromISR( xHandleSemaphoreRX, &xHigherPriorityTaskWoken ); /* send event to receive task to process received task */ xSemaphoreGiveFromISR( xHandleSemaphoreRX, &xHigherPriorityTaskWoken ); /* send event to receive task to process received task */
} }
break;
rxPhase = XBEE_RX_PHASE_HEADER; default:
while (HAL_UART_Receive_DMA(&hlpuart1, rxBuffer, 3)!= HAL_OK); // try to receive header while(1);
} }
if (xHigherPriorityTaskWoken) { if (xHigherPriorityTaskWoken) {
@ -392,3 +416,25 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) {
portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
} }
} }
/**
* DMA IRQ handler for reception. Receive a complete frame send send event to sending frame in case of acknowledge frame or to receive task otherwise
*
* \param UartHandle not used
*/
void LPUART1_IRQHandler(void) {
if (LL_USART_IsActiveFlag_RXNE(hlpuart1.Instance)) {
XBEE_RX_IRQHandler();
} else if (LL_USART_IsActiveFlag_TXE(hlpuart1.Instance)) {
XBEE_TX_IRQHandler();
} else {
if (LL_USART_IsActiveFlag_TC(hlpuart1.Instance))
LL_USART_DisableIT_TC(hlpuart1.Instance);
else if (LL_USART_IsActiveFlag_IDLE(hlpuart1.Instance))
LL_USART_ClearFlag_IDLE(hlpuart1.Instance);
else if (LL_USART_IsActiveFlag_ORE(hlpuart1.Instance)) {
LL_USART_ClearFlag_ORE(hlpuart1.Instance);
}
}
}

View file

@ -17,20 +17,21 @@ typedef enum {
XBEE_RX_TIMEOUT=-3, XBEE_RX_TIMEOUT=-3,
XBEE_RX_ERROR=-4, XBEE_RX_ERROR=-4,
XBEE_TX_ERROR=-5, XBEE_TX_ERROR=-5,
XBEE_INVALID_FRAME=-6 XBEE_INVALID_FRAME=-6,
XBEE_TX_TIMEOUT=-7,
} XBEE_Status; } XBEE_Status;
#define XBEE_RX_PACKET_TYPE 0x90 #define XBEE_RX_PACKET_TYPE 0x90
#define XBEE_RX_EXPLICIT_TYPE 0x91 #define XBEE_RX_EXPLICIT_TYPE 0x91
#define XBEE_TX_STATUS_TYPE 0x89 #define XBEE_TX_STATUS_TYPE 0x89
#define XBEE_AT_CMD_RESPONSE_TYPE 0x88 #define XBEE_AT_CMD_RESPONSE_TYPE 0x88
#define XBEE_MODEM_STATUS_TYPE 0x8A #define XBEE_MODEM_STATUS_TYPE 0x8A
#define XBEE_EXTENDED_TX_STATUS_TYPE 0x8B #define XBEE_EXTENDED_TX_STATUS_TYPE 0x8B
#define XBEE_LOCAL_AT_CMD_TYPE 0x08 #define XBEE_LOCAL_AT_CMD_TYPE 0x08
#define XBEE_TX_REQUEST_TYPE 0x10 #define XBEE_TX_REQUEST_TYPE 0x10
#define XBEE_TX_EXPLICIT_TYPE 0x11 #define XBEE_TX_EXPLICIT_TYPE 0x11
#define XBEE_TX_16BIT_REQUEST_TYPE 0x01 #define XBEE_TX_16BIT_REQUEST_TYPE 0x01
#define XBEE_RX_16BIT_PACKET_TYPE 0x81 #define XBEE_RX_16BIT_PACKET_TYPE 0x81
#define XBEE_AT_STATUS_SUCCESS 0 #define XBEE_AT_STATUS_SUCCESS 0
#define XBEE_AT_STATUS_ERROR 1 #define XBEE_AT_STATUS_ERROR 1
@ -49,15 +50,18 @@ typedef enum {
#define XBEE_RX_OPTIONS_BRODCASTED 0x02 #define XBEE_RX_OPTIONS_BRODCASTED 0x02
#define XBEE_RX_OPTIONS_PAN_BROADCASTED 0x04 #define XBEE_RX_OPTIONS_PAN_BROADCASTED 0x04
#define XBEE_FRAME_SOF_CHAR 0x7E // '~'
typedef struct { typedef struct {
uint8_t type; uint8_t type;
uint16_t source_addr; uint16_t source_addr;
char* data; uint8_t length;
char ack; char ack;
char modem_status; char modem_status;
char data[];
} XBEE_INCOMING_FRAME; } XBEE_INCOMING_FRAME;
void XBEE_Init(void); void XBEE_Init(void);
int XBEE_SendData(char* data, int length); int XBEE_SendData(uint16_t address, char* data, int length);
#endif /* INC_XBEE_H_ */ #endif /* INC_XBEE_H_ */

View file

@ -65,7 +65,7 @@
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)1024) #define configTOTAL_HEAP_SIZE ((size_t)1024)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 25 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1 #define configUSE_MUTEXES 1

View file

@ -46,7 +46,6 @@ ADC_HandleTypeDef hadc;
UART_HandleTypeDef hlpuart1; UART_HandleTypeDef hlpuart1;
DMA_HandleTypeDef hdma_lpuart1_tx; DMA_HandleTypeDef hdma_lpuart1_tx;
DMA_HandleTypeDef hdma_lpuart1_rx;
TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim3;
@ -300,7 +299,8 @@ static void MX_LPUART1_UART_Init(void)
hlpuart1.Init.Mode = UART_MODE_TX_RX; hlpuart1.Init.Mode = UART_MODE_TX_RX;
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_DMADISABLEONERROR_INIT;
hlpuart1.AdvancedInit.DMADisableonRxError = UART_ADVFEATURE_DMA_DISABLEONRXERROR;
if (HAL_UART_Init(&hlpuart1) != HAL_OK) if (HAL_UART_Init(&hlpuart1) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
@ -738,8 +738,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
HAL_IncTick(); HAL_IncTick();
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
if ((htim->Instance == TIM2) || (htim->Instance == TIM21)) /* Timers des encodeurs */
MOTEURS_TimerEncodeurUpdate(htim);
/* USER CODE END Callback 1 */ /* USER CODE END Callback 1 */
} }

View file

@ -26,8 +26,6 @@
/* USER CODE END Includes */ /* USER CODE END Includes */
extern DMA_HandleTypeDef hdma_lpuart1_tx; extern DMA_HandleTypeDef hdma_lpuart1_tx;
extern DMA_HandleTypeDef hdma_lpuart1_rx;
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */ /* USER CODE BEGIN TD */
@ -197,23 +195,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
__HAL_LINKDMA(huart,hdmatx,hdma_lpuart1_tx); __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 */ /* LPUART1 interrupt Init */
HAL_NVIC_SetPriority(LPUART1_IRQn, 3, 0); HAL_NVIC_SetPriority(LPUART1_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(LPUART1_IRQn); HAL_NVIC_EnableIRQ(LPUART1_IRQn);
@ -248,7 +229,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
/* LPUART1 DMA DeInit */ /* LPUART1 DMA DeInit */
HAL_DMA_DeInit(huart->hdmatx); HAL_DMA_DeInit(huart->hdmatx);
HAL_DMA_DeInit(huart->hdmarx);
/* LPUART1 interrupt DeInit */ /* LPUART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(LPUART1_IRQn); HAL_NVIC_DisableIRQ(LPUART1_IRQn);

View file

@ -58,7 +58,6 @@
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern ADC_HandleTypeDef hadc; extern ADC_HandleTypeDef hadc;
extern DMA_HandleTypeDef hdma_lpuart1_tx; extern DMA_HandleTypeDef hdma_lpuart1_tx;
extern DMA_HandleTypeDef hdma_lpuart1_rx;
extern UART_HandleTypeDef hlpuart1; extern UART_HandleTypeDef hlpuart1;
extern TIM_HandleTypeDef htim2; extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim21; extern TIM_HandleTypeDef htim21;
@ -139,17 +138,16 @@ void EXTI4_15_IRQHandler(void)
/** /**
* @brief This function handles DMA1 channel 2 and channel 3 interrupts. * @brief This function handles DMA1 channel 2 and channel 3 interrupts.
*/ */
void DMA1_Channel2_3_IRQHandler(void) //void DMA1_Channel2_3_IRQHandler(void)
{ //{
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */ // /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */
//
/* USER CODE END DMA1_Channel2_3_IRQn 0 */ // /* USER CODE END DMA1_Channel2_3_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_lpuart1_tx); // HAL_DMA_IRQHandler(&hdma_lpuart1_tx);
HAL_DMA_IRQHandler(&hdma_lpuart1_rx); // /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */ //
// /* USER CODE END 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). * @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. * @brief This function handles LPUART1 global interrupt / LPUART1 wake-up interrupt through EXTI line 28.
*/ */
void LPUART1_IRQHandler(void) //void LPUART1_IRQHandler(void)
{ //{
/* USER CODE BEGIN LPUART1_IRQn 0 */ // /* USER CODE BEGIN LPUART1_IRQn 0 */
//
/* USER CODE END LPUART1_IRQn 0 */ // /* USER CODE END LPUART1_IRQn 0 */
HAL_UART_IRQHandler(&hlpuart1); // HAL_UART_IRQHandler(&hlpuart1);
/* USER CODE BEGIN LPUART1_IRQn 1 */ // /* USER CODE BEGIN LPUART1_IRQn 1 */
//
/* USER CODE END LPUART1_IRQn 1 */ // /* USER CODE END LPUART1_IRQn 1 */
} //}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */

View file

@ -1,8 +1,8 @@
/** /**
****************************************************************************** ******************************************************************************
* @file startup_stm32l010x6.s * @file startup_stm32l071xx.s
* @author MCD Application Team * @author MCD Application Team
* @brief STM32L010x6 Devices vector table for GCC toolchain. * @brief STM32L071xx Devices vector table for GCC toolchain.
* This module performs: * This module performs:
* - Set the initial SP * - Set the initial SP
* - Set the initial PC == Reset_Handler, * - Set the initial PC == Reset_Handler,
@ -14,13 +14,12 @@
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.
* *
* This software component is licensed by ST under BSD 3-Clause license, * This software is licensed under terms that can be found in the LICENSE file
* the "License"; You may not use this file except in compliance with the * in the root directory of this software component.
* License. You may obtain a copy of the License at: * If no LICENSE file comes with this software, it is provided AS-IS.
* opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
@ -51,27 +50,10 @@ defined in linker script */
Reset_Handler: Reset_Handler:
ldr r0, =_estack ldr r0, =_estack
mov sp, r0 /* set stack pointer */ 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 */ /* Copy the data segment initializers from flash to SRAM */
ldr r0, =_sdata ldr r0, =_sdata
ldr r1, =_edata ldr r1, =_edata
@ -103,8 +85,6 @@ LoopFillZerobss:
cmp r2, r4 cmp r2, r4
bcc FillZerobss bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */ /* Call static constructors */
bl __libc_init_array bl __libc_init_array
/* Call the application's entry point.*/ /* Call the application's entry point.*/
@ -159,7 +139,7 @@ g_pfnVectors:
.word PendSV_Handler .word PendSV_Handler
.word SysTick_Handler .word SysTick_Handler
.word WWDG_IRQHandler /* Window WatchDog */ .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 RTC_IRQHandler /* RTC through the EXTI line */
.word FLASH_IRQHandler /* FLASH */ .word FLASH_IRQHandler /* FLASH */
.word RCC_IRQHandler /* RCC */ .word RCC_IRQHandler /* RCC */
@ -170,22 +150,22 @@ g_pfnVectors:
.word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */ .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */
.word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */ .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 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 LPTIM1_IRQHandler /* LPTIM1 */
.word 0 /* Reserved */ .word USART4_5_IRQHandler /* USART4 and USART 5 */
.word TIM2_IRQHandler /* TIM2 */ .word TIM2_IRQHandler /* TIM2 */
.word 0 /* Reserved */ .word TIM3_IRQHandler /* TIM3 */
.word 0 /* Reserved */ .word TIM6_IRQHandler /* TIM6 and DAC */
.word 0 /* Reserved */ .word TIM7_IRQHandler /* TIM7 */
.word 0 /* Reserved */ .word 0 /* Reserved */
.word TIM21_IRQHandler /* TIM21 */ .word TIM21_IRQHandler /* TIM21 */
.word 0 /* Reserved */ .word I2C3_IRQHandler /* I2C3 */
.word 0 /* Reserved */ .word TIM22_IRQHandler /* TIM22 */
.word I2C1_IRQHandler /* I2C1 */ .word I2C1_IRQHandler /* I2C1 */
.word 0 /* Reserved */ .word I2C2_IRQHandler /* I2C2 */
.word SPI1_IRQHandler /* SPI1 */ .word SPI1_IRQHandler /* SPI1 */
.word 0 /* Reserved */ .word SPI2_IRQHandler /* SPI2 */
.word 0 /* Reserved */ .word USART1_IRQHandler /* USART1 */
.word USART2_IRQHandler /* USART2 */ .word USART2_IRQHandler /* USART2 */
.word LPUART1_IRQHandler /* LPUART1 */ .word LPUART1_IRQHandler /* LPUART1 */
.word 0 /* Reserved */ .word 0 /* Reserved */
@ -217,6 +197,9 @@ g_pfnVectors:
.weak WWDG_IRQHandler .weak WWDG_IRQHandler
.thumb_set WWDG_IRQHandler,Default_Handler .thumb_set WWDG_IRQHandler,Default_Handler
.weak PVD_IRQHandler
.thumb_set PVD_IRQHandler,Default_Handler
.weak RTC_IRQHandler .weak RTC_IRQHandler
.thumb_set RTC_IRQHandler,Default_Handler .thumb_set RTC_IRQHandler,Default_Handler
@ -244,24 +227,51 @@ g_pfnVectors:
.weak DMA1_Channel4_5_6_7_IRQHandler .weak DMA1_Channel4_5_6_7_IRQHandler
.thumb_set DMA1_Channel4_5_6_7_IRQHandler,Default_Handler .thumb_set DMA1_Channel4_5_6_7_IRQHandler,Default_Handler
.weak ADC1_IRQHandler .weak ADC1_COMP_IRQHandler
.thumb_set ADC1_IRQHandler,Default_Handler .thumb_set ADC1_COMP_IRQHandler,Default_Handler
.weak LPTIM1_IRQHandler .weak LPTIM1_IRQHandler
.thumb_set LPTIM1_IRQHandler,Default_Handler .thumb_set LPTIM1_IRQHandler,Default_Handler
.weak USART4_5_IRQHandler
.thumb_set USART4_5_IRQHandler,Default_Handler
.weak TIM2_IRQHandler .weak TIM2_IRQHandler
.thumb_set TIM2_IRQHandler,Default_Handler .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 .weak TIM21_IRQHandler
.thumb_set TIM21_IRQHandler,Default_Handler .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 .weak I2C1_IRQHandler
.thumb_set I2C1_IRQHandler,Default_Handler .thumb_set I2C1_IRQHandler,Default_Handler
.weak I2C2_IRQHandler
.thumb_set I2C2_IRQHandler,Default_Handler
.weak SPI1_IRQHandler .weak SPI1_IRQHandler
.thumb_set SPI1_IRQHandler,Default_Handler .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 .weak USART2_IRQHandler
.thumb_set USART2_IRQHandler,Default_Handler .thumb_set USART2_IRQHandler,Default_Handler
@ -271,5 +281,4 @@ g_pfnVectors:
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -35,13 +35,13 @@
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="true"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value="49FF67064970535516370687"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value="49FF67064970535516370687"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/> <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/> <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="freertos"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/> <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="ARM_CM0"/>
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/> <intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
@ -73,6 +73,7 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/> <listEntry value="4"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/> <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&lt;gdbmemoryBlockExpression address=&quot;536875216&quot; label=&quot;rxBuffer&quot;/&gt;&lt;gdbmemoryBlockExpression address=&quot;536875132&quot; label=&quot;txBuffer&quot;/&gt;&lt;/memoryBlockExpressionList&gt;"/>
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/> <stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="rxBuffer"/>
</launchConfiguration> </launchConfiguration>

View file

@ -5,15 +5,6 @@ ADC.SamplingTime=ADC_SAMPLETIME_160CYCLES_5
CAD.formats= CAD.formats=
CAD.pinconfig= CAD.pinconfig=
CAD.provider= 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.Direction=DMA_MEMORY_TO_PERIPH
Dma.LPUART1_TX.0.Instance=DMA1_Channel2 Dma.LPUART1_TX.0.Instance=DMA1_Channel2
Dma.LPUART1_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE 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.Priority=DMA_PRIORITY_HIGH
Dma.LPUART1_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority Dma.LPUART1_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
Dma.Request0=LPUART1_TX Dma.Request0=LPUART1_TX
Dma.Request1=LPUART1_RX Dma.RequestsNb=1
Dma.RequestsNb=2
FREERTOS.INCLUDE_pcTaskGetTaskName=1 FREERTOS.INCLUDE_pcTaskGetTaskName=1
FREERTOS.INCLUDE_xEventGroupSetBitFromISR=1 FREERTOS.INCLUDE_xEventGroupSetBitFromISR=1
FREERTOS.INCLUDE_xTaskAbortDelay=1 FREERTOS.INCLUDE_xTaskAbortDelay=1
FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1 FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1
FREERTOS.INCLUDE_xTaskGetHandle=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.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
FREERTOS.configMAX_TASK_NAME_LEN=25
FREERTOS.configTICK_RATE_HZ=1000 FREERTOS.configTICK_RATE_HZ=1000
FREERTOS.configTOTAL_HEAP_SIZE=1024 FREERTOS.configTOTAL_HEAP_SIZE=1024
FREERTOS.configUSE_NEWLIB_REENTRANT=1 FREERTOS.configUSE_NEWLIB_REENTRANT=1
@ -41,7 +32,8 @@ File.Version=6
GPIO.groupedBy=Group By Peripherals GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false KeepUserPlacement=false
LPUART1.BaudRate=115200 LPUART1.BaudRate=115200
LPUART1.IPParameters=BaudRate,WordLength LPUART1.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR
LPUART1.IPParameters=BaudRate,WordLength,DMADisableonRxErrorParam
LPUART1.WordLength=UART_WORDLENGTH_8B LPUART1.WordLength=UART_WORDLENGTH_8B
Mcu.CPN=STM32L071CBT3 Mcu.CPN=STM32L071CBT3
Mcu.Family=STM32L0 Mcu.Family=STM32L0
@ -100,7 +92,7 @@ Mcu.UserName=STM32L071CBTx
MxCube.Version=6.7.0 MxCube.Version=6.7.0
MxDb.Version=DB.6.0.70 MxDb.Version=DB.6.0.70
NVIC.ADC1_COMP_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true 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.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.EXTI4_15_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=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.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.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.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.TimeBase=TIM6_IRQn
NVIC.TimeBaseIP=TIM6 NVIC.TimeBaseIP=TIM6
PA0.GPIOParameters=GPIO_Label PA0.GPIOParameters=GPIO_Label
@ -126,9 +118,10 @@ PA1.GPIOParameters=GPIO_Label
PA1.GPIO_Label=ENC_PHA_GAUCHE PA1.GPIO_Label=ENC_PHA_GAUCHE
PA1.Locked=true PA1.Locked=true
PA1.Signal=GPIO_Input PA1.Signal=GPIO_Input
PA10.GPIOParameters=GPIO_Label PA10.GPIOParameters=PinState,GPIO_Label
PA10.GPIO_Label=XBEE_RESET PA10.GPIO_Label=XBEE_RESET
PA10.Locked=true PA10.Locked=true
PA10.PinState=GPIO_PIN_RESET
PA10.Signal=GPIO_Output PA10.Signal=GPIO_Output
PA11.GPIOParameters=GPIO_Label PA11.GPIOParameters=GPIO_Label
PA11.GPIO_Label=LED_SEG_F PA11.GPIO_Label=LED_SEG_F