0waring
This commit is contained in:
parent
0cc68b08e4
commit
63c1d05a61
13
.clangd
Normal file
13
.clangd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Add:
|
||||||
|
- '-ferror-limit=0'
|
||||||
|
- '-Wno-implicit-int'
|
||||||
|
CompilationDatabase: build/Debug
|
||||||
|
Remove:
|
||||||
|
- "--multi-lib-config=*"
|
||||||
|
Diagnostics:
|
||||||
|
Suppress:
|
||||||
|
- unused-includes
|
||||||
|
- unknown_typename
|
||||||
|
- unknown_typename_suggest
|
||||||
|
- typename_requires_specqual
|
||||||
21
.vscode/c_cpp_properties.json
vendored
Normal file
21
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "STM32",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"Core/Inc",
|
||||||
|
"Drivers/STM32H7xx_HAL_Driver/Inc",
|
||||||
|
"Drivers/STM32H7xx_HAL_Driver/Inc/Legacy",
|
||||||
|
"Drivers/CMSIS/Device/ST/STM32H7xx/Include",
|
||||||
|
"Drivers/CMSIS/Include",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
|
"compileCommands": "${workspaceFolder}/build/Debug/compile_commands.json",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -6,5 +6,10 @@
|
|||||||
"cmake.preferredGenerators": [
|
"cmake.preferredGenerators": [
|
||||||
"Ninja"
|
"Ninja"
|
||||||
],
|
],
|
||||||
"stm32cube-ide-clangd.path": "cube"
|
"stm32cube-ide-clangd.path": "cube",
|
||||||
|
"stm32cube-ide-clangd.arguments": [
|
||||||
|
"starm-clangd",
|
||||||
|
"--query-driver=${env:CUBE_BUNDLE_PATH}/st-arm-clang/19.1.6+st.10/bin/starm-clang",
|
||||||
|
"--query-driver=${env:CUBE_BUNDLE_PATH}/st-arm-clang/19.1.6+st.10/bin/starm-clang++"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@ -61,7 +61,6 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|||||||
User/component/crc8.c
|
User/component/crc8.c
|
||||||
User/component/error_detect.c
|
User/component/error_detect.c
|
||||||
User/component/filter.c
|
User/component/filter.c
|
||||||
User/component/freertos_cli.c
|
|
||||||
User/component/limiter.c
|
User/component/limiter.c
|
||||||
User/component/mixer.c
|
User/component/mixer.c
|
||||||
User/component/pid.c
|
User/component/pid.c
|
||||||
|
|||||||
@ -44,7 +44,7 @@ static BSP_CAN_t CAN_Get(CAN_HandleTypeDef *hcan);
|
|||||||
static osMessageQueueId_t BSP_CAN_FindQueue(BSP_CAN_t can, uint32_t can_id);
|
static osMessageQueueId_t BSP_CAN_FindQueue(BSP_CAN_t can, uint32_t can_id);
|
||||||
static int8_t BSP_CAN_CreateIdQueue(BSP_CAN_t can, uint32_t can_id, uint8_t queue_size);
|
static int8_t BSP_CAN_CreateIdQueue(BSP_CAN_t can, uint32_t can_id, uint8_t queue_size);
|
||||||
static void BSP_CAN_RxFifo0Callback(void);
|
static void BSP_CAN_RxFifo0Callback(void);
|
||||||
static void BSP_CAN_RxFifo1Callback(void);
|
// static void BSP_CAN_RxFifo1Callback(void);
|
||||||
static void BSP_CAN_TxCompleteCallback(void);
|
static void BSP_CAN_TxCompleteCallback(void);
|
||||||
static BSP_CAN_FrameType_t BSP_CAN_GetFrameType(CAN_RxHeaderTypeDef *header);
|
static BSP_CAN_FrameType_t BSP_CAN_GetFrameType(CAN_RxHeaderTypeDef *header);
|
||||||
static uint32_t BSP_CAN_DefaultIdParser(uint32_t original_id, BSP_CAN_FrameType_t frame_type);
|
static uint32_t BSP_CAN_DefaultIdParser(uint32_t original_id, BSP_CAN_FrameType_t frame_type);
|
||||||
@ -281,34 +281,34 @@ static void BSP_CAN_RxFifo0Callback(void) {
|
|||||||
/**
|
/**
|
||||||
* @brief FIFO1接收处理函数
|
* @brief FIFO1接收处理函数
|
||||||
*/
|
*/
|
||||||
static void BSP_CAN_RxFifo1Callback(void) {
|
// static void BSP_CAN_RxFifo1Callback(void) {
|
||||||
CAN_RxHeaderTypeDef rx_header;
|
// CAN_RxHeaderTypeDef rx_header;
|
||||||
uint8_t rx_data[BSP_CAN_MAX_DLC];
|
// uint8_t rx_data[BSP_CAN_MAX_DLC];
|
||||||
for (int can_idx = 0; can_idx < BSP_CAN_NUM; can_idx++) {
|
// for (int can_idx = 0; can_idx < BSP_CAN_NUM; can_idx++) {
|
||||||
CAN_HandleTypeDef *hcan = BSP_CAN_GetHandle((BSP_CAN_t)can_idx);
|
// CAN_HandleTypeDef *hcan = BSP_CAN_GetHandle((BSP_CAN_t)can_idx);
|
||||||
if (hcan == NULL) continue;
|
// if (hcan == NULL) continue;
|
||||||
while (HAL_CAN_GetRxFifoFillLevel(hcan, CAN_RX_FIFO1) > 0) {
|
// while (HAL_CAN_GetRxFifoFillLevel(hcan, CAN_RX_FIFO1) > 0) {
|
||||||
if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO1, &rx_header, rx_data) == HAL_OK) {
|
// if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO1, &rx_header, rx_data) == HAL_OK) {
|
||||||
uint32_t original_id = (rx_header.IDE == CAN_ID_STD) ? rx_header.StdId : rx_header.ExtId;
|
// uint32_t original_id = (rx_header.IDE == CAN_ID_STD) ? rx_header.StdId : rx_header.ExtId;
|
||||||
BSP_CAN_FrameType_t frame_type = BSP_CAN_GetFrameType(&rx_header);
|
// BSP_CAN_FrameType_t frame_type = BSP_CAN_GetFrameType(&rx_header);
|
||||||
uint32_t parsed_id = BSP_CAN_ParseId(original_id, frame_type);
|
// uint32_t parsed_id = BSP_CAN_ParseId(original_id, frame_type);
|
||||||
osMessageQueueId_t queue = BSP_CAN_FindQueue((BSP_CAN_t)can_idx, parsed_id);
|
// osMessageQueueId_t queue = BSP_CAN_FindQueue((BSP_CAN_t)can_idx, parsed_id);
|
||||||
if (queue != NULL) {
|
// if (queue != NULL) {
|
||||||
BSP_CAN_Message_t msg = {0};
|
// BSP_CAN_Message_t msg = {0};
|
||||||
msg.frame_type = frame_type;
|
// msg.frame_type = frame_type;
|
||||||
msg.original_id = original_id;
|
// msg.original_id = original_id;
|
||||||
msg.parsed_id = parsed_id;
|
// msg.parsed_id = parsed_id;
|
||||||
msg.dlc = rx_header.DLC;
|
// msg.dlc = rx_header.DLC;
|
||||||
if (rx_header.RTR == CAN_RTR_DATA) {
|
// if (rx_header.RTR == CAN_RTR_DATA) {
|
||||||
memcpy(msg.data, rx_data, rx_header.DLC);
|
// memcpy(msg.data, rx_data, rx_header.DLC);
|
||||||
}
|
// }
|
||||||
msg.timestamp = HAL_GetTick();
|
// msg.timestamp = HAL_GetTick();
|
||||||
osMessageQueuePut(queue, &msg, 0, BSP_CAN_TIMEOUT_IMMEDIATE);
|
// osMessageQueuePut(queue, &msg, 0, BSP_CAN_TIMEOUT_IMMEDIATE);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* HAL Callback Functions --------------------------------------------------- */
|
/* HAL Callback Functions --------------------------------------------------- */
|
||||||
void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef *hcan) {
|
void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef *hcan) {
|
||||||
|
|||||||
@ -1,352 +0,0 @@
|
|||||||
/*
|
|
||||||
* FreeRTOS+CLI V1.0.4
|
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
* http://www.FreeRTOS.org
|
|
||||||
* http://aws.amazon.com/freertos
|
|
||||||
*
|
|
||||||
* 1 tab == 4 spaces!
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Standard includes. */
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
|
||||||
#include "FreeRTOS.h"
|
|
||||||
#include "task.h"
|
|
||||||
|
|
||||||
/* Utils includes. */
|
|
||||||
#include "FreeRTOS_CLI.h"
|
|
||||||
|
|
||||||
/* If the application writer needs to place the buffer used by the CLI at a
|
|
||||||
fixed address then set configAPPLICATION_PROVIDES_cOutputBuffer to 1 in
|
|
||||||
FreeRTOSConfig.h, then declare an array with the following name and size in
|
|
||||||
one of the application files:
|
|
||||||
char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ];
|
|
||||||
*/
|
|
||||||
#ifndef configAPPLICATION_PROVIDES_cOutputBuffer
|
|
||||||
#define configAPPLICATION_PROVIDES_cOutputBuffer 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct xCOMMAND_INPUT_LIST
|
|
||||||
{
|
|
||||||
const CLI_Command_Definition_t *pxCommandLineDefinition;
|
|
||||||
struct xCOMMAND_INPUT_LIST *pxNext;
|
|
||||||
} CLI_Definition_List_Item_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The callback function that is executed when "help" is entered. This is the
|
|
||||||
* only default command that is always present.
|
|
||||||
*/
|
|
||||||
static BaseType_t prvHelpCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the number of parameters that follow the command name.
|
|
||||||
*/
|
|
||||||
static int8_t prvGetNumberOfParameters( const char *pcCommandString );
|
|
||||||
|
|
||||||
/* The definition of the "help" command. This command is always at the front
|
|
||||||
of the list of registered commands. */
|
|
||||||
static const CLI_Command_Definition_t xHelpCommand =
|
|
||||||
{
|
|
||||||
"help",
|
|
||||||
"\r\nhelp:\r\n Lists all the registered commands\r\n\r\n",
|
|
||||||
prvHelpCommand,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The definition of the list of commands. Commands that are registered are
|
|
||||||
added to this list. */
|
|
||||||
static CLI_Definition_List_Item_t xRegisteredCommands =
|
|
||||||
{
|
|
||||||
&xHelpCommand, /* The first command in the list is always the help command, defined in this file. */
|
|
||||||
NULL /* The next pointer is initialised to NULL, as there are no other registered commands yet. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* A buffer into which command outputs can be written is declared here, rather
|
|
||||||
than in the command console implementation, to allow multiple command consoles
|
|
||||||
to share the same buffer. For example, an application may allow access to the
|
|
||||||
command interpreter by UART and by Ethernet. Sharing a buffer is done purely
|
|
||||||
to save RAM. Note, however, that the command console itself is not re-entrant,
|
|
||||||
so only one command interpreter interface can be used at any one time. For that
|
|
||||||
reason, no attempt at providing mutual exclusion to the cOutputBuffer array is
|
|
||||||
attempted.
|
|
||||||
|
|
||||||
configAPPLICATION_PROVIDES_cOutputBuffer is provided to allow the application
|
|
||||||
writer to provide their own cOutputBuffer declaration in cases where the
|
|
||||||
buffer needs to be placed at a fixed address (rather than by the linker). */
|
|
||||||
|
|
||||||
#if( configAPPLICATION_PROVIDES_cOutputBuffer == 0 )
|
|
||||||
static char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ];
|
|
||||||
#else
|
|
||||||
extern char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
BaseType_t FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister )
|
|
||||||
{
|
|
||||||
static CLI_Definition_List_Item_t *pxLastCommandInList = &xRegisteredCommands;
|
|
||||||
CLI_Definition_List_Item_t *pxNewListItem;
|
|
||||||
BaseType_t xReturn = pdFAIL;
|
|
||||||
|
|
||||||
/* Check the parameter is not NULL. */
|
|
||||||
configASSERT( pxCommandToRegister );
|
|
||||||
|
|
||||||
/* Create a new list item that will reference the command being registered. */
|
|
||||||
pxNewListItem = ( CLI_Definition_List_Item_t * ) pvPortMalloc( sizeof( CLI_Definition_List_Item_t ) );
|
|
||||||
configASSERT( pxNewListItem );
|
|
||||||
|
|
||||||
if( pxNewListItem != NULL )
|
|
||||||
{
|
|
||||||
taskENTER_CRITICAL();
|
|
||||||
{
|
|
||||||
/* Reference the command being registered from the newly created
|
|
||||||
list item. */
|
|
||||||
pxNewListItem->pxCommandLineDefinition = pxCommandToRegister;
|
|
||||||
|
|
||||||
/* The new list item will get added to the end of the list, so
|
|
||||||
pxNext has nowhere to point. */
|
|
||||||
pxNewListItem->pxNext = NULL;
|
|
||||||
|
|
||||||
/* Add the newly created list item to the end of the already existing
|
|
||||||
list. */
|
|
||||||
pxLastCommandInList->pxNext = pxNewListItem;
|
|
||||||
|
|
||||||
/* Set the end of list marker to the new list item. */
|
|
||||||
pxLastCommandInList = pxNewListItem;
|
|
||||||
}
|
|
||||||
taskEXIT_CRITICAL();
|
|
||||||
|
|
||||||
xReturn = pdPASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xReturn;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, char * pcWriteBuffer, size_t xWriteBufferLen )
|
|
||||||
{
|
|
||||||
static const CLI_Definition_List_Item_t *pxCommand = NULL;
|
|
||||||
BaseType_t xReturn = pdTRUE;
|
|
||||||
const char *pcRegisteredCommandString;
|
|
||||||
size_t xCommandStringLength;
|
|
||||||
|
|
||||||
/* Note: This function is not re-entrant. It must not be called from more
|
|
||||||
thank one task. */
|
|
||||||
|
|
||||||
if( pxCommand == NULL )
|
|
||||||
{
|
|
||||||
/* Search for the command string in the list of registered commands. */
|
|
||||||
for( pxCommand = &xRegisteredCommands; pxCommand != NULL; pxCommand = pxCommand->pxNext )
|
|
||||||
{
|
|
||||||
pcRegisteredCommandString = pxCommand->pxCommandLineDefinition->pcCommand;
|
|
||||||
xCommandStringLength = strlen( pcRegisteredCommandString );
|
|
||||||
|
|
||||||
/* To ensure the string lengths match exactly, so as not to pick up
|
|
||||||
a sub-string of a longer command, check the byte after the expected
|
|
||||||
end of the string is either the end of the string or a space before
|
|
||||||
a parameter. */
|
|
||||||
if( ( pcCommandInput[ xCommandStringLength ] == ' ' ) || ( pcCommandInput[ xCommandStringLength ] == 0x00 ) )
|
|
||||||
{
|
|
||||||
if( strncmp( pcCommandInput, pcRegisteredCommandString, xCommandStringLength ) == 0 )
|
|
||||||
{
|
|
||||||
/* The command has been found. Check it has the expected
|
|
||||||
number of parameters. If cExpectedNumberOfParameters is -1,
|
|
||||||
then there could be a variable number of parameters and no
|
|
||||||
check is made. */
|
|
||||||
if( pxCommand->pxCommandLineDefinition->cExpectedNumberOfParameters >= 0 )
|
|
||||||
{
|
|
||||||
if( prvGetNumberOfParameters( pcCommandInput ) != pxCommand->pxCommandLineDefinition->cExpectedNumberOfParameters )
|
|
||||||
{
|
|
||||||
xReturn = pdFALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( pxCommand != NULL ) && ( xReturn == pdFALSE ) )
|
|
||||||
{
|
|
||||||
/* The command was found, but the number of parameters with the command
|
|
||||||
was incorrect. */
|
|
||||||
strncpy( pcWriteBuffer, "Incorrect command parameter(s). Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen );
|
|
||||||
pxCommand = NULL;
|
|
||||||
}
|
|
||||||
else if( pxCommand != NULL )
|
|
||||||
{
|
|
||||||
/* Call the callback function that is registered to this command. */
|
|
||||||
xReturn = pxCommand->pxCommandLineDefinition->pxCommandInterpreter( pcWriteBuffer, xWriteBufferLen, pcCommandInput );
|
|
||||||
|
|
||||||
/* If xReturn is pdFALSE, then no further strings will be returned
|
|
||||||
after this one, and pxCommand can be reset to NULL ready to search
|
|
||||||
for the next entered command. */
|
|
||||||
if( xReturn == pdFALSE )
|
|
||||||
{
|
|
||||||
pxCommand = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* pxCommand was NULL, the command was not found. */
|
|
||||||
strncpy( pcWriteBuffer, "Command not recognised. Enter 'help' to view a list of available commands.\r\n\r\n", xWriteBufferLen );
|
|
||||||
xReturn = pdFALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xReturn;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
char *FreeRTOS_CLIGetOutputBuffer( void )
|
|
||||||
{
|
|
||||||
return cOutputBuffer;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
const char *FreeRTOS_CLIGetParameter( const char *pcCommandString, UBaseType_t uxWantedParameter, BaseType_t *pxParameterStringLength )
|
|
||||||
{
|
|
||||||
UBaseType_t uxParametersFound = 0;
|
|
||||||
const char *pcReturn = NULL;
|
|
||||||
|
|
||||||
*pxParameterStringLength = 0;
|
|
||||||
|
|
||||||
while( uxParametersFound < uxWantedParameter )
|
|
||||||
{
|
|
||||||
/* Index the character pointer past the current word. If this is the start
|
|
||||||
of the command string then the first word is the command itself. */
|
|
||||||
while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) != ' ' ) )
|
|
||||||
{
|
|
||||||
pcCommandString++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the start of the next string. */
|
|
||||||
while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) == ' ' ) )
|
|
||||||
{
|
|
||||||
pcCommandString++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Was a string found? */
|
|
||||||
if( *pcCommandString != 0x00 )
|
|
||||||
{
|
|
||||||
/* Is this the start of the required parameter? */
|
|
||||||
uxParametersFound++;
|
|
||||||
|
|
||||||
if( uxParametersFound == uxWantedParameter )
|
|
||||||
{
|
|
||||||
/* How long is the parameter? */
|
|
||||||
pcReturn = pcCommandString;
|
|
||||||
while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) != ' ' ) )
|
|
||||||
{
|
|
||||||
( *pxParameterStringLength )++;
|
|
||||||
pcCommandString++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *pxParameterStringLength == 0 )
|
|
||||||
{
|
|
||||||
pcReturn = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pcReturn;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
static BaseType_t prvHelpCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
|
||||||
{
|
|
||||||
static const CLI_Definition_List_Item_t * pxCommand = NULL;
|
|
||||||
BaseType_t xReturn;
|
|
||||||
|
|
||||||
( void ) pcCommandString;
|
|
||||||
|
|
||||||
if( pxCommand == NULL )
|
|
||||||
{
|
|
||||||
/* Reset the pxCommand pointer back to the start of the list. */
|
|
||||||
pxCommand = &xRegisteredCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the next command help string, before moving the pointer on to
|
|
||||||
the next command in the list. */
|
|
||||||
strncpy( pcWriteBuffer, pxCommand->pxCommandLineDefinition->pcHelpString, xWriteBufferLen );
|
|
||||||
pxCommand = pxCommand->pxNext;
|
|
||||||
|
|
||||||
if( pxCommand == NULL )
|
|
||||||
{
|
|
||||||
/* There are no more commands in the list, so there will be no more
|
|
||||||
strings to return after this one and pdFALSE should be returned. */
|
|
||||||
xReturn = pdFALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xReturn = pdTRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xReturn;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
static int8_t prvGetNumberOfParameters( const char *pcCommandString )
|
|
||||||
{
|
|
||||||
int8_t cParameters = 0;
|
|
||||||
BaseType_t xLastCharacterWasSpace = pdFALSE;
|
|
||||||
|
|
||||||
/* Count the number of space delimited words in pcCommandString. */
|
|
||||||
while( *pcCommandString != 0x00 )
|
|
||||||
{
|
|
||||||
if( ( *pcCommandString ) == ' ' )
|
|
||||||
{
|
|
||||||
if( xLastCharacterWasSpace != pdTRUE )
|
|
||||||
{
|
|
||||||
cParameters++;
|
|
||||||
xLastCharacterWasSpace = pdTRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xLastCharacterWasSpace = pdFALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcCommandString++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the command string ended with spaces, then there will have been too
|
|
||||||
many parameters counted. */
|
|
||||||
if( xLastCharacterWasSpace == pdTRUE )
|
|
||||||
{
|
|
||||||
cParameters--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The value returned is one less than the number of space delimited words,
|
|
||||||
as the first word should be the command itself. */
|
|
||||||
return cParameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* FreeRTOS+CLI V1.0.4
|
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
* http://www.FreeRTOS.org
|
|
||||||
* http://aws.amazon.com/freertos
|
|
||||||
*
|
|
||||||
* 1 tab == 4 spaces!
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMMAND_INTERPRETER_H
|
|
||||||
#define COMMAND_INTERPRETER_H
|
|
||||||
|
|
||||||
/* This config should be defined in FreeRTOSConfig.h. But due to the limition of CubeMX I put it here. */
|
|
||||||
#define configCOMMAND_INT_MAX_OUTPUT_SIZE 512
|
|
||||||
|
|
||||||
/* The prototype to which callback functions used to process command line
|
|
||||||
commands must comply. pcWriteBuffer is a buffer into which the output from
|
|
||||||
executing the command can be written, xWriteBufferLen is the length, in bytes of
|
|
||||||
the pcWriteBuffer buffer, and pcCommandString is the entire string as input by
|
|
||||||
the user (from which parameters can be extracted).*/
|
|
||||||
typedef BaseType_t (*pdCOMMAND_LINE_CALLBACK)( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
|
||||||
|
|
||||||
/* The structure that defines command line commands. A command line command
|
|
||||||
should be defined by declaring a const structure of this type. */
|
|
||||||
typedef struct xCOMMAND_LINE_INPUT
|
|
||||||
{
|
|
||||||
const char * const pcCommand; /* The command that causes pxCommandInterpreter to be executed. For example "help". Must be all lower case. */
|
|
||||||
const char * const pcHelpString; /* String that describes how to use the command. Should start with the command itself, and end with "\r\n". For example "help: Returns a list of all the commands\r\n". */
|
|
||||||
const pdCOMMAND_LINE_CALLBACK pxCommandInterpreter; /* A pointer to the callback function that will return the output generated by the command. */
|
|
||||||
int8_t cExpectedNumberOfParameters; /* Commands expect a fixed number of parameters, which may be zero. */
|
|
||||||
} CLI_Command_Definition_t;
|
|
||||||
|
|
||||||
/* For backward compatibility. */
|
|
||||||
#define xCommandLineInput CLI_Command_Definition_t
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Register the command passed in using the pxCommandToRegister parameter.
|
|
||||||
* Registering a command adds the command to the list of commands that are
|
|
||||||
* handled by the command interpreter. Once a command has been registered it
|
|
||||||
* can be executed from the command line.
|
|
||||||
*/
|
|
||||||
BaseType_t FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Runs the command interpreter for the command string "pcCommandInput". Any
|
|
||||||
* output generated by running the command will be placed into pcWriteBuffer.
|
|
||||||
* xWriteBufferLen must indicate the size, in bytes, of the buffer pointed to
|
|
||||||
* by pcWriteBuffer.
|
|
||||||
*
|
|
||||||
* FreeRTOS_CLIProcessCommand should be called repeatedly until it returns pdFALSE.
|
|
||||||
*
|
|
||||||
* pcCmdIntProcessCommand is not reentrant. It must not be called from more
|
|
||||||
* than one task - or at least - by more than one task at a time.
|
|
||||||
*/
|
|
||||||
BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, char * pcWriteBuffer, size_t xWriteBufferLen );
|
|
||||||
|
|
||||||
/*---------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A buffer into which command outputs can be written is declared in the
|
|
||||||
* main command interpreter, rather than in the command console implementation,
|
|
||||||
* to allow application that provide access to the command console via multiple
|
|
||||||
* interfaces to share a buffer, and therefore save RAM. Note, however, that
|
|
||||||
* the command interpreter itself is not re-entrant, so only one command
|
|
||||||
* console interface can be used at any one time. For that reason, no attempt
|
|
||||||
* is made to provide any mutual exclusion mechanism on the output buffer.
|
|
||||||
*
|
|
||||||
* FreeRTOS_CLIGetOutputBuffer() returns the address of the output buffer.
|
|
||||||
*/
|
|
||||||
char *FreeRTOS_CLIGetOutputBuffer( void );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return a pointer to the xParameterNumber'th word in pcCommandString.
|
|
||||||
*/
|
|
||||||
const char *FreeRTOS_CLIGetParameter( const char *pcCommandString, UBaseType_t uxWantedParameter, BaseType_t *pxParameterStringLength );
|
|
||||||
|
|
||||||
#endif /* COMMAND_INTERPRETER_H */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,6 @@ static int8_t MOTOR_DM_SendMITCmd(MOTOR_DM_t *motor, MOTOR_MIT_Output_t *output)
|
|||||||
|
|
||||||
uint8_t data[8];
|
uint8_t data[8];
|
||||||
uint16_t pos_tmp,vel_tmp,kp_tmp,kd_tmp,tor_tmp;
|
uint16_t pos_tmp,vel_tmp,kp_tmp,kd_tmp,tor_tmp;
|
||||||
uint16_t id = motor->param.can_id;
|
|
||||||
|
|
||||||
pos_tmp = float_to_uint(output->angle, DM_P_MIN , DM_P_MAX, 16);
|
pos_tmp = float_to_uint(output->angle, DM_P_MIN , DM_P_MAX, 16);
|
||||||
vel_tmp = float_to_uint(output->velocity, DM_V_MIN , DM_V_MAX, 12);
|
vel_tmp = float_to_uint(output->velocity, DM_V_MIN , DM_V_MAX, 12);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user