Documentation finie, reprise potentielle a prevoir pour retirer des balises inutiles

This commit is contained in:
dimercur 2024-01-11 15:36:58 +01:00
parent d21c4b2ea3
commit ae59f19ecc
13 changed files with 715 additions and 207 deletions

View file

@ -74,54 +74,6 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1896077029" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.129867327" name="stm32l0xx_hal_uart_ex.c" rcbsApplicability="disable" resourcePath="Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.648558844">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.648558844" 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.347850982" 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.1104330500" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1659546583" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1432031452" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.415746645" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.2080129162" name="stm32l0xx_hal_uart.c" rcbsApplicability="disable" resourcePath="Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.620188347">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.620188347" 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.1125301886" 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.190607955" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.465455954" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1630632169" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.15440907" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.1932647075" name="stm32l0xx_hal_dma.c" rcbsApplicability="disable" resourcePath="Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_dma.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.1807227080">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.1807227080" 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.1457095105" 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.1399198488" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.737656347" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.689637588" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1151842665" 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>
<sourceEntries>
<entry excluding="Xbee-API|XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Application"/>
<entry excluding="XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
@ -341,7 +293,7 @@
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.789962441" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.53808517" name="batterie.c" rcbsApplicability="disable" resourcePath="Application/batterie.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638">
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.53808517" name="batterie.c" rcbsApplicability="disable" resourcePath="Application/battery.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2016549754" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" 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.457387693" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>

View file

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1588895534946134039" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1588895534946134039" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -27,7 +27,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1588895534946134039" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View file

@ -1,13 +1,49 @@
/*
* messages.c
/**
******************************************************************************
* @file messages.c
* @brief messages handler body
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: 14 sept. 2022
* Author: dimercur
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#include "messages.h"
#include "stdlib.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup MESSAGES
* Messages module handles mailbox and messages communication support between tasks
* @{
*/
/** @addtogroup MESSAGES_Private Private
* @{
*/
#define QUEUE_SIZE 5
QueueHandle_t LEDS_Mailbox;
@ -15,6 +51,12 @@ QueueHandle_t MOTORS_Mailbox;
QueueHandle_t APPLICATION_Mailbox;
QueueHandle_t XBEE_Mailbox;
/**
* @brief Function for initializing messaging system
*
* @param None
* @return None
*/
void MESSAGE_Init(void) {
LEDS_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
MOTORS_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
@ -22,6 +64,15 @@ void MESSAGE_Init(void) {
XBEE_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
}
/**
* @brief Return first message a given mailbox
*
* @param[in] mbx Mailbox reference
* @return First message in mailbox
*
* @remark This function is blocking until a message is received.
* If mailbox is not empty when calling the function, return immediatly with first message in mailbox
*/
MESSAGE_Typedef MESSAGE_ReadMailbox(QueueHandle_t mbx) {
MESSAGE_Typedef msg= {0};
char msg_received =0;
@ -37,6 +88,16 @@ MESSAGE_Typedef MESSAGE_ReadMailbox(QueueHandle_t mbx) {
return msg;
}
/**
* @brief Return first message a given mailbox (non blocking)
*
* @param[in] mbx Mailbox reference
* @return First message in mailbox
*
* @remark This function is non blocking.
* If mailbox is empty when calling the function, a message structure is still returned with \ref MSG_ID_NO_MESSAGE
* in message id field
*/
MESSAGE_Typedef MESSAGE_ReadMailboxNoDelay(QueueHandle_t mbx) {
MESSAGE_Typedef msg= {0};
@ -46,6 +107,18 @@ MESSAGE_Typedef MESSAGE_ReadMailboxNoDelay(QueueHandle_t mbx) {
return msg;
}
/**
* @brief Post a message in a mailbox with given id and data
*
* @param[in] mbx_dest Destination mailbox
* @param[in] id id of message (as found in \ref msg_id_def "Message ID definitions")
* @param[in] mbx_sender Sender mailbox (may be null if no answer is expected)
* @param[in] data Reference to data to store in message structure
* @return None
*
* @remark This function is non blocking.
* If mailbox is full when calling the function, error will be ignored silently
*/
void MESSAGE_SendMailbox(QueueHandle_t mbx_dest, uint16_t id, QueueHandle_t mbx_sender, void *data){
MESSAGE_Typedef msg;
@ -58,6 +131,19 @@ void MESSAGE_SendMailbox(QueueHandle_t mbx_dest, uint16_t id, QueueHandle_t mbx_
}
}
/**
* @brief Post, from an ISR, a message in a mailbox with given id and data
*
* @param[in] mbx_dest Destination mailbox
* @param[in] id id of message (as found in \ref msg_id_def "Message ID definitions")
* @param[in] mbx_sender Sender mailbox (may be null if no answer is expected)
* @param[in] data Reference to data to store in message structure
* @param[in] xHigherPriorityTaskWoken Reference to flag indicating if a context switch is to be done at end of ISR
* @return None
*
* @remark This function is non blocking.
* If mailbox is full when calling the function, error will be ignored silently
*/
void MESSAGE_SendMailboxFromISR(QueueHandle_t mbx_dest, uint16_t id, QueueHandle_t mbx_sender, void *data, BaseType_t *xHigherPriorityTaskWoken) {
MESSAGE_Typedef msg;
@ -70,5 +156,14 @@ void MESSAGE_SendMailboxFromISR(QueueHandle_t mbx_dest, uint16_t id, QueueHandle
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View file

@ -1,8 +1,31 @@
/*
* messages.h
/**
******************************************************************************
* @file messages.h
* @brief messages handler header
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: 14 sept. 2022
* Author: dimercur
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#ifndef INC_MESSAGES_H_
@ -11,10 +34,23 @@
#include "application.h"
#include "queue.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup MESSAGES
* @{
*/
/** @addtogroup MESSAGES_Public Public
* @{
*/
/** Structure storing messages to be posted in mailbox */
typedef struct {
uint16_t id;
QueueHandle_t* sender;
void *data;
uint16_t id; /**< Id of message, as found in \ref msg_id_def "Message ID definitions" */
QueueHandle_t* sender; /**< reference to sender mailbox, in case of expected answer */
void *data; /**< reference to data */
} MESSAGE_Typedef;
extern QueueHandle_t LEDS_Mailbox;
@ -22,6 +58,12 @@ extern QueueHandle_t MOTORS_Mailbox;
extern QueueHandle_t APPLICATION_Mailbox;
extern QueueHandle_t XBEE_Mailbox;
/**
* @anchor msg_id_def
* @name Message ID definitions
* List of message identifiers
*/
///@{
#define MSG_ID_NO_MESSAGE 0x00
#define MSG_ID_LED_ETAT 0x10
@ -40,7 +82,6 @@ extern QueueHandle_t XBEE_Mailbox;
//#define MSG_ID_BAT_CHARGE_ON 0x23
//#define MSG_ID_BAT_CHARGE_OFF 0x24
#define MSG_ID_BUTTON_PRESSED 0x30
#define MSG_ID_MOTORS_STOP 0x40
@ -50,6 +91,7 @@ extern QueueHandle_t XBEE_Mailbox;
#define MSG_ID_XBEE_CMD 0x50
#define MSG_ID_XBEE_ANS 0x51
///@}
void MESSAGE_Init(void);
MESSAGE_Typedef MESSAGE_ReadMailbox(QueueHandle_t mbx);
@ -57,4 +99,16 @@ MESSAGE_Typedef MESSAGE_ReadMailboxNoDelay(QueueHandle_t mbx);
void MESSAGE_SendMailbox(QueueHandle_t mbx_dest, uint16_t id, QueueHandle_t mbx_sender, void *data);
void MESSAGE_SendMailboxFromISR(QueueHandle_t mbx_dest, uint16_t id, QueueHandle_t mbx_sender, void *data, BaseType_t *xHigherPriorityTaskWoken);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* INC_MESSAGES_H_ */

View file

@ -62,29 +62,35 @@ extern TIM_HandleTypeDef htim3;
#define MOTORS_MAX_COMMAND 200
#define MOTORS_MAX_ENCODER USHRT_MAX
/** Structure for storing motore (left or right) regulation state
* Used during regulation task for controlling motor */
/** Structure for storing motors (left or right) control state
* Used during control loop task for controlling motor
*/
typedef struct {
int16_t output; /**< */
int16_t set_point; /**< Xbee RF quality (not used)*/
uint16_t encoder; /**< Xbee RF quality (not used)*/
uint16_t encoderEdge; /**< Xbee RF quality (not used)*/
uint8_t slowMotor; /**< Xbee RF quality (not used)*/
int16_t output; /**< Output value to send to motor. Positive values for forward and negative values for backward
+/- 65535 for full power and 0 for motor stop */
int16_t setpoint; /**< Set point value for motor control*/
uint16_t encoder; /**< Number of encoder pulse acquired between last control loop iteration*/
uint16_t encoderEdge; /**< Delta T between two encoders pulse (the fastest the motor goes, the lowest the value is.
65536 means motor is stopped */
uint8_t slowMotor; /**< Flag for indicating that motor has stopped */
} MOTORS_MotorState;
/** Structure storing counters used for watchdog and system inactivity.
* Used notably to check if watchdog reset was missed or power down system because of inactivity */
/** Structure for storing differential control state.
* Used during top differentiel control loop, to ensure trjactory is strait */
typedef struct {
uint8_t type; /**< Xbee RF quality (not used)*/
int16_t output; /**< Xbee RF quality (not used)*/
int16_t set_point; /**< Xbee RF quality (not used)*/
int32_t distance; /**< Xbee RF quality (not used)*/
int32_t turns; /**< Xbee RF quality (not used)*/
uint8_t type; /**< not used */
int16_t output; /**< not used */
int16_t setpoint; /**< not used */
int32_t distance; /**< Distance to move on */
int32_t turns; /**< Number of turns to apply */
} MOTORS_DifferentialState;
MOTORS_MotorState MOTORS_LeftMotorState, MOTORS_RightMotorState = { 0 };
MOTORS_DifferentialState MOTORS_DiffState = { 0 };
/**
* Proportionnal constant for motor control loop
*/
#define MOTOR_Kp 300
/***** Tasks part *****/
@ -159,7 +165,7 @@ void EndMeasure(void) {
* @brief Function for initializing motors driver
*
* @param None
* @retval None
* @return None
*/
void MOTORS_Init(void) {
/* Désactive les alimentations des moteurs */
@ -194,10 +200,15 @@ void MOTORS_Init(void) {
}
/**
* @brief Function for initializing motors driver
* @brief Request a movment in strait line
*
* @param None
* @retval None
* @remark This function wrap a message sending to motors mailbox.
* In case of multiple call, only last one will be applied,
* with potentially some spurious movement when processing previous messages
*
* @param[in] distance Distance to move on, in mm.
* Positive values for forward movements and negative values for backward movements
* @return None
*/
void MOTORS_Move(int32_t distance) {
static int32_t dist;
@ -213,15 +224,20 @@ void MOTORS_Move(int32_t distance) {
}
/**
* @brief Function for initializing motors driver
* @brief Request a movement in rotation
*
* @param None
* @retval None
* @remark This function wrap a message sending to motors mailbox.
* In case of multiple call, only last one will be applied,
* with potentially some spurious movement when processing previous messages
*
* @param[in] rotations Angle of rotation to do in degree.
* Positive values for clockwise rotations and negative values for counterclockwise rotations
* @return None
*/
void MOTORS_Turn(int32_t tours) {
void MOTORS_Turn(int32_t rotations) {
static int32_t turns;
turns = tours;
turns = rotations;
if (turns) {
MOTORS_PowerOn();
@ -232,10 +248,14 @@ void MOTORS_Turn(int32_t tours) {
}
/**
* @brief Function for initializing motors driver
* @brief Request for stopping any movement
*
* @param None
* @retval None
* @remark This function wrap a message sending to motors mailbox.
* In case of multiple call, only last one will be applied,
* with potentially some spurious movement when processing previous messages
*
* @param None
* @return None
*/
void MOTORS_Stop(void) {
MOTORS_PowerOff();
@ -243,10 +263,12 @@ void MOTORS_Stop(void) {
APPLICATION_Mailbox, (void*) NULL);
}
/*
* @brief Tache de supervision des moteurs
* Gestion de la boite aux lettres moteurs, et supervision generale
* @param params non utilisé
/**
* @brief Handler task for motor control
* Manage mailbox et overall management
*
* @param[in] params Initial task parameters
* @return None
*/
void MOTORS_HandlerTask(void *params) {
MESSAGE_Typedef msg;
@ -262,11 +284,11 @@ void MOTORS_HandlerTask(void *params) {
MOTORS_DiffState.turns = 0;
if (distance > 0) {
MOTORS_LeftMotorState.set_point = 50;
MOTORS_RightMotorState.set_point = 50;
MOTORS_LeftMotorState.setpoint = 50;
MOTORS_RightMotorState.setpoint = 50;
} else {
MOTORS_LeftMotorState.set_point = -50;
MOTORS_RightMotorState.set_point = -50;
MOTORS_LeftMotorState.setpoint = -50;
MOTORS_RightMotorState.setpoint = -50;
}
vTaskResume(xHandleMotorsControl);
@ -278,11 +300,11 @@ void MOTORS_HandlerTask(void *params) {
MOTORS_DiffState.turns = tours;
if (tours > 0) {
MOTORS_LeftMotorState.set_point = -50;
MOTORS_RightMotorState.set_point = 50;
MOTORS_LeftMotorState.setpoint = -50;
MOTORS_RightMotorState.setpoint = 50;
} else {
MOTORS_LeftMotorState.set_point = 50;
MOTORS_RightMotorState.set_point = -50;
MOTORS_LeftMotorState.setpoint = 50;
MOTORS_RightMotorState.setpoint = -50;
}
vTaskResume(xHandleMotorsControl);
@ -292,8 +314,8 @@ void MOTORS_HandlerTask(void *params) {
MOTORS_DiffState.distance = 0;
MOTORS_DiffState.turns = 0;
MOTORS_LeftMotorState.set_point = 0;
MOTORS_RightMotorState.set_point = 0;
MOTORS_LeftMotorState.setpoint = 0;
MOTORS_RightMotorState.setpoint = 0;
if ((MOTORS_EncoderCorrection(MOTORS_LeftMotorState) == 0)
&& (MOTORS_EncoderCorrection(MOTORS_RightMotorState) == 0)) {
// Les moteurs sont déjà arrêtés
@ -311,10 +333,15 @@ void MOTORS_HandlerTask(void *params) {
}
}
/*
* @brief Tache d'asservissement, périodique (10ms)
/**
* @brief Control loop task
* Periodic task (3ms) for motor control loop
*
* @param params non utilisé
* @remark This task is started by \ref MOTORS_HandlerTask when receiving a movement message
* but task kill by itself when movement has finished
*
* @param[in] params Initial task parameters
* @return None
*/
void MOTORS_ControlTask(void *params) {
TickType_t xLastWakeTime;
@ -343,11 +370,11 @@ void MOTORS_ControlTask(void *params) {
* erreur est entre -32768 et 32767 selon la difference à apporter à la commande
*/
leftError = MOTORS_LeftMotorState.set_point - leftEncoder;
rightError = MOTORS_RightMotorState.set_point - rightEncoder;
leftError = MOTORS_LeftMotorState.setpoint - leftEncoder;
rightError = MOTORS_RightMotorState.setpoint - rightEncoder;
if (((MOTORS_RightMotorState.set_point == 0)
&& (MOTORS_LeftMotorState.set_point == 0))
if (((MOTORS_RightMotorState.setpoint == 0)
&& (MOTORS_LeftMotorState.setpoint == 0))
&& ((rightError == 0) && (leftError == 0))) {
MOTORS_PowerOff();
@ -356,14 +383,14 @@ void MOTORS_ControlTask(void *params) {
vTaskSuspend(xHandleMotorsControl);
}
if (MOTORS_LeftMotorState.set_point == 0)
if (MOTORS_LeftMotorState.setpoint == 0)
MOTORS_LeftMotorState.output = 0;
else {
if (leftError != 0) {
//locCmdG = (int32_t)MOTEURS_EtatMoteurGauche.commande + ((int32_t)MOTEUR_Kp*(int32_t)erreurG)/100;
locCmdG = ((int32_t) MOTOR_Kp * (int32_t) leftError) / 100;
if (MOTORS_LeftMotorState.set_point >= 0) {
if (MOTORS_LeftMotorState.setpoint >= 0) {
if (locCmdG < 0)
MOTORS_LeftMotorState.output = 0;
else if (locCmdG > SHRT_MAX)
@ -381,14 +408,14 @@ void MOTORS_ControlTask(void *params) {
}
}
if (MOTORS_RightMotorState.set_point == 0)
if (MOTORS_RightMotorState.setpoint == 0)
MOTORS_RightMotorState.output = 0;
else {
if (rightError != 0) {
//locCmdD = (int32_t)MOTEURS_EtatMoteurDroit.commande + ((int32_t)MOTEUR_Kp*(int32_t)erreurD)/100;
locCmdD = ((int32_t) MOTOR_Kp * (int32_t) rightError) / 100;
if (MOTORS_RightMotorState.set_point >= 0) {
if (MOTORS_RightMotorState.setpoint >= 0) {
if (locCmdD < 0)
MOTORS_RightMotorState.output = 0;
else if (locCmdD > SHRT_MAX)
@ -416,13 +443,29 @@ void MOTORS_ControlTask(void *params) {
}
}
/** Structure for encoder convertion
* The structure store a equivalent state point, associating a raw encoder value to a linearized corrected value
*/
typedef struct {
uint16_t encoder;
uint16_t correction;
uint16_t encoder; /**< Raw encoder value*/
uint16_t correction; /**< Corrected, linearized value, equivalent to raw encoder*/
} MOTORS_CorrectionPoint;
/**
* Number max of correction points for encoder
*/
#define MOTORS_MAX_CORRECTION_POINTS 16
/**
* Array of correction points, associating a raw encoder value and a linearized correction.
*
* Basically, encoders return delay between two signal edges. If motor is stopped, encoder return 65535 (\ref MOTORS_MAX_ENCODER).
* Then value tends towards zero as the motor accelerates. Resulting encoder output is not linear and
* reversed with respect to the setpoint.
*
* This table give several corresponding points, associating a raw, non linear and inverted encoder value to a linerized,
* corrected value that can be compared to setpoint
*/
const MOTORS_CorrectionPoint MOTORS_CorrectionPoints[MOTORS_MAX_CORRECTION_POINTS] =
{ { MOTORS_MAX_ENCODER - 1, 1 }, { 42000, 100 }, { 22000, 2500 }, {
18000, 5000 }, { 16500, 7500 }, { 15500, 10000 },
@ -432,11 +475,13 @@ const MOTORS_CorrectionPoint MOTORS_CorrectionPoints[MOTORS_MAX_CORRECTION_POINT
SHRT_MAX } // 32767
};
/*
* @brief Fonction de conversion des valeurs brutes de l'encodeur en valeur linearisées
/**
* @brief Function for converting raw encoder values to linearized values
*
* @param encodeur valeur brute de l'encodeur
* @return valeur linéarisée (entre -32768 et 32767)
* @remark This function use \ref MOTORS_CorrectionPoints for its conversion
*
* @param[in] state Current state of a motor, including raw encoder value
* @return Linearized value, from -32768 (full backward) to 32767 (full forward)
*/
int16_t MOTORS_EncoderCorrection(MOTORS_MotorState state) {
int16_t correction = 0;
@ -474,17 +519,17 @@ int16_t MOTORS_EncoderCorrection(MOTORS_MotorState state) {
/*
* Selon le sens de rotation du moteur (commande > 0 ou < 0), on corrige le signe du capteur
*/
if (state.set_point < 0)
if (state.setpoint < 0)
correction = -correction;
return correction;
}
/**
* @brief Function for initializing motors driver
* @brief Power off motor, disabling power regulator
*
* @param None
* @retval None
* @return None
*/
void MOTORS_PowerOff(void) {
LL_TIM_DisableCounter(TIM3);
@ -508,10 +553,10 @@ void MOTORS_PowerOff(void) {
}
/**
* @brief Function for initializing motors driver
* @brief Power on motor, enabling power regulator
*
* @param None
* @retval None
* @return None
*/
void MOTORS_PowerOn(void) {
LL_TIM_EnableCounter(TIM3);
@ -535,16 +580,21 @@ void MOTORS_PowerOn(void) {
}
/**
* @brief Active les encodeurs et le régulateur des moteur si nécessaire et
* règle la commande du moteur (entre -MOTEURS_MAX_COMMANDE et +MOTEURS_MAX_COMMANDE)
* On applique une "regle de 3"
* pour SHRT_MAX -> MOTEURS_MAX_COMMANDE
* pour 0 -> 0
* pour une commande C dans l'interval [0 .. 32767], la commande est
* commande = (C * MOTEURS_MAX_COMMANDE)/32767
* @brief Set command to motor
*
* @param[in] cmdGauche blablabla
* @param[in] cmdDroit blablabla
* This function drive motors directly. Values applied are output from regulation law.
* If power supply is not enabled (for motor and encoders), the function will enable it.
*
* Values provided are in the range [-SHRT_MAX; SHRT_MAX] and motor command must be
* in the range [-MOTORS_MAX_COMMAND et +MOTORS_MAX_COMMAND].
* The corresponding rule is used :
* - for SHRT_MAX -> MOTORS_MAX_COMMAND
* - for 0 -> 0
* - for a request R in range [0 .. SHRT_MAX], command = (R * MOTEURS_MAX_COMMANDE)/SHRT_MAX
*
* @param[in] leftMotor Request command for left motor
* @param[in] rightMotor Request command for right motor
* @return None
*/
void MOTORS_Set(int16_t leftMotor, int16_t rightMotor) {
int32_t leftValue, rightValue;
@ -576,10 +626,15 @@ void MOTORS_Set(int16_t leftMotor, int16_t rightMotor) {
}
}
/*
* @brief Recupere les mesures brutes des encodeurs et les enregistre dans la structure moteur correspondante
/**
* @brief Get raw values from encoders and store them in corresponding motor state
*
* @param[in] htim pointeur sur la reference du timer qui generé l'interruption
* @remark Encoder values are in fact timer counting time between to encoder pulses
*
* Also, manage distance and turn counter used for overall motor control
*
* @param[in] htim Pointer to timer reference that trigger interrupt
* @return None
*/
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
if (htim->Instance == TIM21) { /* moteur gauche */
@ -604,8 +659,8 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
else MOTORS_DiffState.distance++;
if (MOTORS_DiffState.distance==0) {
MOTORS_LeftMotorState.set_point=0;
MOTORS_RightMotorState.set_point=0;
MOTORS_LeftMotorState.setpoint=0;
MOTORS_RightMotorState.setpoint=0;
}
}
@ -614,8 +669,8 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
else MOTORS_DiffState.turns++;
if (MOTORS_DiffState.turns==0) {
MOTORS_LeftMotorState.set_point=0;
MOTORS_RightMotorState.set_point=0;
MOTORS_LeftMotorState.setpoint=0;
MOTORS_RightMotorState.setpoint=0;
}
}
@ -640,13 +695,15 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
}
}
/*
* @brief Gestionnaire d'interruption "overflow"
* Lorsque deux interruptions "overflow" sont arrivées sans que l'interruption capture n'arrive,
* cela signifie que le moteur est à l'arret.
* On met la valeur de l'encodeur à MOTEURS_MAX_ENCODEUR
/**
* @brief "overflow" interrupt handler
*
* @param[in] htim pointeur sur la reference du timer qui generé l'interruption
* When two "overflow" interrupts occure without an encoder interrupt happened,
* this means motor is halted.
* So, we set encoder value to MOTEURS_MAX_ENCODEUR
*
* @param[in] htim Pointer to timer reference that trigger interrupt
* @return None
*/
void MOTORS_TimerEncodeurUpdate(TIM_HandleTypeDef *htim) {
if (htim->Instance == TIM21) { /* moteur gauche */

View file

@ -1,6 +1,6 @@
/**
******************************************************************************
* @file motors.c
* @file motors.h
* @brief motors driver header
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023

View file

@ -1,8 +1,31 @@
/*
* panic.c
/**
******************************************************************************
* @file panic.c
* @brief panic handler body
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: Oct 11, 2023
* Author: dimercur
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#include "application.h"
@ -11,8 +34,24 @@
#include "panic.h"
#include "leds.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup PANIC
* Panic module handles non recoverable error and display an error message on leds
* @{
*/
/** @addtogroup PANIC_Private Private
* @{
*/
void PANIC_StopTasksAndWait(void);
/** @cond DOXYGEN_IGNORE_REF */
void MOTORS_PowerOff(void);
/** @endcond */
extern TaskHandle_t xHandleLedsHandler;
extern TaskHandle_t xHandleLedsAction;
@ -25,6 +64,14 @@ extern TaskHandle_t xHandleMotorsControl;
extern TaskHandle_t xHandleXbeeTXHandler;
extern TaskHandle_t xHandleXbeeRX;
/**
* @brief Handle an unrecoverable error and display corresponding error on leds
*
* @param[in] panicId Panic error (as found in \ref PANIC_Typedef)
* @return None
*
* @remark This function will never return (as it calls \ref PANIC_StopTasksAndWait).
*/
void PANIC_Raise(PANIC_Typedef panicId) {
switch (panicId) {
case panic_adc_err:
@ -44,6 +91,17 @@ void PANIC_Raise(PANIC_Typedef panicId) {
PANIC_StopTasksAndWait();
}
/**
* @brief Stop all task and stop system
*
* All tasks are stopped except led animation (otherwise animation will stop)
* and, at end, system enter power saving mode.
*
* @param None
* @return None
*
* @remark This function will never return (as it calls \ref PANIC_StopTasksAndWait).
*/
void PANIC_StopTasksAndWait(void){
TaskHandle_t currentTask;
currentTask = xTaskGetCurrentTaskHandle();
@ -92,3 +150,15 @@ void PANIC_StopTasksAndWait(void){
__WFE(); /* Attente infinie */
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View file

@ -1,19 +1,67 @@
/*
* panic.h
/**
******************************************************************************
* @file panic.h
* @brief panic handler header
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: Oct 11, 2023
* Author: dimercur
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#ifndef PANIC_H_
#define PANIC_H_
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup PANIC
* @{
*/
/** @addtogroup PANIC_Public Public
* @{
*/
/** Enumeration class defining possible panic sources */
typedef enum {
panic_charger_err=1, // erreur 1
panic_adc_err, // erreur 2
panic_malloc // erreur 3
panic_charger_err=1, /**< error related to battery charging */
panic_adc_err, /**< error related to battery voltage conversion */
panic_malloc /**< memory allocation failed (memory exhausted) */
} PANIC_Typedef;
void PANIC_Raise(PANIC_Typedef panicId);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* PANIC_H_ */

View file

@ -1,10 +1,32 @@
/*
* xbee.c
/**
******************************************************************************
* @file xbee.c
* @brief xbee driver body
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: Sep 12, 2022
* Author: dimercur
*/
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#include "xbee.h"
#include "semphr.h"
@ -12,17 +34,43 @@
#include <string.h>
#include "stm32l0xx_ll_usart.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup XBEE
* Xbee driver handles RF communications with supervisor
* @{
*/
/** @addtogroup XBEE_Private Private
* @{
*/
extern UART_HandleTypeDef hlpuart1;
extern DMA_HandleTypeDef hdma_lpuart1_tx;
extern DMA_HandleTypeDef hdma_lpuart1_rx;
/***** API2 escaped char *****/
/**
* @anchor xbee_api2_escape_chars
* @name XBEE API2 Escape characters
* List of escaped characters, not used yet (transparent mode)
*/
///@{
#define XBEE_API_ESCAPE_CHAR 0x7D
#define XBEE_API_START_OF_FRAME 0x7E
#define XBEE_API_XON 0x11
#define XBEE_API_XOFF 0x13
///@}
/**
* @anchor xbee_ending_char
* @name XBEE command ending char
* Ending character used in protocol between supervisor and robot
*/
///@{
#define XBEE_ENDING_CHAR '\r'
///@}
/***** TX part *****/
void XBEE_TxHandlerThread(void* params);
@ -66,6 +114,12 @@ SemaphoreHandle_t xHandleSemaphoreTX = NULL;
StaticSemaphore_t xSemaphoreTX;
//StaticSemaphore_t xSemaphoreTX_ACK;
/**
* @brief Function for initializing xbee system
*
* @param None
* @return None
*/
void XBEE_Init(void) {
xHandleSemaphoreTX = xSemaphoreCreateBinaryStatic( &xSemaphoreTX );
//xHandleSemaphoreTX_ACK = xSemaphoreCreateBinaryStatic( &xSemaphoreTX_ACK );
@ -103,7 +157,13 @@ void XBEE_Init(void) {
/**** Support functions ****/
/**** TX Part *****/
/**
* @brief Handler task for message to transmit (send to supervisor)
* Manage XBEE mailbox and send messages
*
* @param[in] params Initial task parameters
* @return None
*/
void XBEE_TxHandlerThread(void* params) {
MESSAGE_Typedef msg;
@ -119,12 +179,19 @@ void XBEE_TxHandlerThread(void* params) {
}
/**
* Send data. Create a transmission frame, add escape char to data and send it over UART
* @brief Send data.
*
* \param data raw data to send
* \return status of decoding: XBEE_OK if decoding is successful,
* XBEE_TX_ERROR in case of sending error,
* XBEE_TX_TIMEOUT in case semaphore takes too long
* Create a transmission frame, add escape char to data and send it over UART
*
* @remark Function is non blocking unless another transmission is still in progress
*
* @todo Change return status type from "int" to "\ref XBEE_Status"
*
* @param[in] data reference to raw data to send
* @return status of decoding (see \ref XBEE_Status)
* - XBEE_OK if decoding is successful,
* - XBEE_TX_ERROR in case of sending error,
* - XBEE_TX_TIMEOUT in case semaphore takes too long
*/
int XBEE_SendData(char* data) {
BaseType_t state;
@ -157,6 +224,15 @@ int XBEE_SendData(char* data) {
return status;
}
/**
* @brief Transmission interrupt handler
*
* This ISR is called when USART transmit register is empty, ready for a new char to be sent
* A Semaphore is used to signal end of transmission to \ref XBEE_SendData function
*
* @param None
* @return None
*/
void XBEE_TX_IRQHandler(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
@ -181,9 +257,12 @@ void XBEE_TX_IRQHandler(void) {
/***** Rx Part *****/
/**
* Reception thread. Wait for incoming frame, process it and send message to application
* @brief Handler task for message reception (received from supervisor)
*
* \param params not used
* Wait for incoming message and send them to application mailbox
*
* @param[in] params Initial task parameters
* @return None
*/
void XBEE_RxThread(void* params) {
char* incomingData;
@ -213,6 +292,15 @@ void XBEE_RxThread(void* params) {
}
}
/**
* @brief Reception interrupt handler
*
* This ISR is called when USART reception register is full, containing a newly received char
* A Semaphore is used to signal end of frame reception to \ref XBEE_RxThread function
*
* @param None
* @return None
*/
void XBEE_RX_IRQHandler(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
uint8_t data;
@ -243,9 +331,10 @@ 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
* @brief IRQ handler for UART.
*
* Dispatch IRQ event to transmission ISR (\ref XBEE_TX_IRQHandler), reception ISR (\ref XBEE_RX_IRQHandler) or clear errors flags
*
* \param UartHandle not used
*/
void LPUART1_IRQHandler(void) {
@ -268,3 +357,16 @@ void LPUART1_IRQHandler(void) {
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View file

@ -1,8 +1,31 @@
/*
* xbee.h
/**
******************************************************************************
* @file xbee.h
* @brief xbee driver header
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
* Created on: Sep 12, 2022
* Author: dimercur
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#ifndef INC_XBEE_H_
@ -10,17 +33,36 @@
#include "application.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup XBEE
* @{
*/
/** @addtogroup XBEE_Public Public
* @{
*/
/** Enumeration class defining status code (only used by \ref XBEE_SendData)*/
typedef enum {
XBEE_OK=0,
XBEE_CONFIG_ERROR=-1,
XBEE_TX_ACK_ERROR=-2,
XBEE_RX_TIMEOUT=-3,
XBEE_RX_ERROR=-4,
XBEE_TX_ERROR=-5,
XBEE_INVALID_FRAME=-6,
XBEE_TX_TIMEOUT=-7,
XBEE_OK=0, /**< Function is successful */
XBEE_CONFIG_ERROR=-1, /**< Configuration of XBEE gets an error (not used) */
XBEE_TX_ACK_ERROR=-2, /**< Tx transmission doesn't received acknowledgment (not used in transparent mode) */
XBEE_RX_TIMEOUT=-3, /**< Rx frame doesn't complete in time (not used in transparent mode) */
XBEE_RX_ERROR=-4, /**< Rx frame error while receiving (not used in transparent mode) */
XBEE_TX_ERROR=-5, /**< Tx frame error while sending */
XBEE_INVALID_FRAME=-6, /**< Rx frame is invalid (not used in transparent mode) */
XBEE_TX_TIMEOUT=-7, /**< Tx frame not sent in time */
} XBEE_Status;
/**
* @anchor xbee_frame_type
* @name XBEE API mode frame type
* List of message frame used in API mode (not used now)
*/
///@{
#define XBEE_RX_PACKET_TYPE 0x90
#define XBEE_RX_EXPLICIT_TYPE 0x91
#define XBEE_TX_STATUS_TYPE 0x89
@ -51,16 +93,30 @@ typedef enum {
#define XBEE_RX_OPTIONS_PAN_BROADCASTED 0x04
#define XBEE_FRAME_SOF_CHAR 0x7E // '~'
///@}
/** Structure class defining received frame (only for API mode, not used now)*/
typedef struct {
uint8_t type;
uint16_t source_addr;
uint8_t length;
char ack;
char modem_status;
char data[];
uint8_t type; /**< Frame type (see \ref xbee_frame_type "XBEE API mode frame type") */
uint16_t source_addr; /**< Address of sender */
uint8_t length; /**< Length of data part */
char ack; /**< ?? */
char modem_status; /**< ?? */
char data[]; /**< Data buffer */
} XBEE_INCOMING_FRAME;
void XBEE_Init(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* INC_XBEE_H_ */

View file

@ -996,13 +996,14 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = /home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/Drivers \
/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/Tests \
/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/TestsPlans \
/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/Debug \
/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/Release \
/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/workspace \
Middlewares
EXCLUDE = Drivers \
Tests \
TestsPlans \
Debug \
Release \
workspace \
Middlewares \
Application/Xbee-API
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded

View file

@ -0,0 +1,44 @@
# This is an genericBoard board with a single STM32L071CBTx chip
#
# Generated by STM32CubeIDE
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
source [find interface/stlink-dap.cfg]
set WORKAREASIZE 0x5000
transport select "dapdirect_swd"
set CHIPNAME STM32L071CBTx
set BOARDNAME genericBoard
# Enable debug when in low power modes
set ENABLE_LOW_POWER 1
# Stop Watchdog counters when halt
set STOP_WATCHDOG 1
# STlink Debug clock frequency
set CLOCK_FREQ 8000
# Reset configuration
# use hardware reset, connect under reset
# connect_assert_srst needed if low power mode application running (WFI...)
reset_config srst_only srst_nogate connect_assert_srst
set CONNECT_UNDER_RESET 1
set CORE_RESET 0
# ACCESS PORT NUMBER
set AP_NUM 0
# GDB PORT
set GDB_PORT 3333
# BCTM CPU variables
source [find target/stm32l0x.cfg]

View file

@ -1,5 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.device" value="STM32L071CB"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.endian" value="little"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.init_speed" value="4000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_check_serial_number" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_script_path" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_script_used" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.reset_strategy" value="type_0_normal"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.restart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Type 0: Normal&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Type 0: Normal&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;Type 0: Normal&quot;,&quot;fLaunchAttribute&quot;:&quot;type_0_normal&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.rtos_implementation" value="1"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_auto" value="true"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_irpre" value="0"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_pos" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.selected_rtos" value="RTOSPlugin_Azure"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
@ -20,11 +35,25 @@
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="3344"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="16000000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.CTI_ALLOW_HALT" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.CTI_SIGNAL_HALT" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_DEVICE_SHAREABLE_ALLOWED" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_INTERFACE" value="Swd"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_INTERFACE_FREQUENCY" value="8000000.0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_LOW_POWER_MODE_ALLOWED" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_RESET_MODE" value="connect_under_reset"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_STOP_WATCHDOG_THEN_HALTED_ALLOWED" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_GENERATOR_OPTION" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_NAME" value="&quot;${stm32cubeide_openocd_path}/openocd&quot;"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_OTHER_OPTIONS" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_RESTART_CONFIGURATIONS" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset halt&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Reset halt&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Reset halt&quot;,&quot;fLaunchAttribute&quot;:&quot;monitor reset halt&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset halt&quot;],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;Reset init&quot;,&quot;fLaunchAttribute&quot;:&quot;monitor reset init&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset init&quot;],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true},{&quot;fDisplayName&quot;:&quot;Reset init&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Reset init&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Reset halt&quot;,&quot;fLaunchAttribute&quot;:&quot;monitor reset halt&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset halt&quot;],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;Reset init&quot;,&quot;fLaunchAttribute&quot;:&quot;monitor reset init&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset init&quot;],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&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.openocd.OPENOCD_SCRIPT" value="${ProjDirPath}/Dumber3 Debug.cfg"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_SCRIPT_CHOICE" value="automated"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocdenable_rtos" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
@ -32,7 +61,7 @@
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/home/dimercur/Travail/git/dumber/software/dumber3/Debug/st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/home/dimercur/Documents/Travail/Depots-Git/dumber/software/dumber3/Debug/st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
@ -41,7 +70,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="enable"/>
<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}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="freertos"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
@ -51,9 +80,9 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.openocd"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>