From f1847cdf6b5104095f0997ff7e6bbb6a053a0d36 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Thu, 17 Nov 2022 15:01:59 +0100 Subject: [PATCH] add rs485 shell, project not working! --- ADIS_tinyK22_SplitFlap/source/IncludeMcuLibConfig.h | 5 +++-- ADIS_tinyK22_SplitFlap/source/platform.c | 8 ++++++++ ADIS_tinyK22_SplitFlap/source/rs485.c | 2 +- ADIS_tinyK22_SplitFlap/source/shell.c | 5 +++++ ADIS_tinyK22_SplitFlap/source/shell.h | 8 ++++++++ ADIS_tinyK22_SplitFlap/source/splitflap.h | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ADIS_tinyK22_SplitFlap/source/IncludeMcuLibConfig.h b/ADIS_tinyK22_SplitFlap/source/IncludeMcuLibConfig.h index dbfd7fd..2dd3b8e 100644 --- a/ADIS_tinyK22_SplitFlap/source/IncludeMcuLibConfig.h +++ b/ADIS_tinyK22_SplitFlap/source/IncludeMcuLibConfig.h @@ -115,7 +115,7 @@ add_compile_options(-include "../config/IncludeMcuLibConfig.h") /* ------------------- RTOS ---------------------------*/ #define McuLib_CONFIG_SDK_USE_FREERTOS (1) /* #define configUSE_SEGGER_SYSTEM_VIEWER_HOOKS (1) */ -/* #define configTOTAL_HEAP_SIZE (24*1024) */ +/*#define configTOTAL_HEAP_SIZE (24*1024)*/ /* #define configUSE_HEAP_SECTION_NAME (1) */ /* #define configHEAP_SECTION_NAME_STRING ".bss.$SRAM_LOWER.FreeRTOS" */ /* ------------------- FatFS ---------------------------*/ @@ -129,6 +129,7 @@ add_compile_options(-include "../config/IncludeMcuLibConfig.h") #define McuMinINI_CONFIG_FLASH_NVM_ADDR_START ((0+512*1024)-McuMinINI_CONFIG_FLASH_NVM_BLOCK_SIZE) #define McuMinINI_CONFIG_FLASH_NVM_BLOCK_SIZE (0x800) #define McuMinINI_CONFIG_FLASH_NVM_MAX_DATA_SIZE (0x800) /* must be 64, 128, 256, ... */ - +/* RS485 */ +#define McuUart485_CONFIG_USE_RS_485 (1) #endif /* INCLUDEMCULIBCONFIG_H_ */ diff --git a/ADIS_tinyK22_SplitFlap/source/platform.c b/ADIS_tinyK22_SplitFlap/source/platform.c index b29a668..7b34cfc 100644 --- a/ADIS_tinyK22_SplitFlap/source/platform.c +++ b/ADIS_tinyK22_SplitFlap/source/platform.c @@ -25,6 +25,9 @@ #include "MinIni/McuMinINI.h" #include "minIni/McuFlash.h" #endif +#if PL_CONFIG_USE_RS485 + #include "rs485.h" +#endif void PL_Init(void){ @@ -32,6 +35,7 @@ void PL_Init(void){ CLOCK_EnableClock(kCLOCK_PortA); CLOCK_EnableClock(kCLOCK_PortB); CLOCK_EnableClock(kCLOCK_PortC); + CLOCK_EnableClock(kCLOCK_PortD); /* NVMC init */ #if PL_CONFIG_USE_NVMC @@ -50,6 +54,9 @@ void PL_Init(void){ McuLED_Init(); McuULN2003_Init(); McuRTT_Init(); +#if PL_CONFIG_USE_RS485 + RS485_Init(); +#endif McuShell_Init(); McuShellUart_Init(); McuLog_Init(); @@ -81,4 +88,5 @@ void PL_Deinit(void){ #if PL_CONFIG_USE_NVMC NVMC_Deinit(); #endif + } diff --git a/ADIS_tinyK22_SplitFlap/source/rs485.c b/ADIS_tinyK22_SplitFlap/source/rs485.c index 36e9304..0ba7418 100644 --- a/ADIS_tinyK22_SplitFlap/source/rs485.c +++ b/ADIS_tinyK22_SplitFlap/source/rs485.c @@ -20,7 +20,7 @@ #if PL_CONFIG_USE_WDT #include "watchdog.h" #endif -#include "stepper.h" +//#include "stepper.h" typedef enum RS485_Response_e { RS485_RESPONSE_CONTINUE, /* continue scanning and parsing */ diff --git a/ADIS_tinyK22_SplitFlap/source/shell.c b/ADIS_tinyK22_SplitFlap/source/shell.c index 12f97b8..e6fe6cc 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.c +++ b/ADIS_tinyK22_SplitFlap/source/shell.c @@ -16,6 +16,7 @@ #include "minIni/McuMinINI.h" #include "minIni/McuFlash.h" #include "nvmc.h" +#include "rs485.h" #define SHELL_CMD_ELEM_SIZE (sizeof(Shell_cmd_s)) @@ -143,6 +144,7 @@ static const McuShell_ParseCommandCallback CmdParserTable[] = ini_ParseCommand, McuMinINI_ParseCommand, NVMC_ParseCommand, + RS485_ParseCommand, NULL /* Sentinel */ }; @@ -182,6 +184,9 @@ void SHELL_SendString(const unsigned char *str) { } } +void SHELL_SendStringToIO(const unsigned char *str, McuShell_ConstStdIOType *io){ + McuShell_SendStr(str, io->stdOut); +} static void ShellTask(void *pv) { int i; diff --git a/ADIS_tinyK22_SplitFlap/source/shell.h b/ADIS_tinyK22_SplitFlap/source/shell.h index b289017..09cb3d7 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.h +++ b/ADIS_tinyK22_SplitFlap/source/shell.h @@ -76,6 +76,14 @@ void SHELL_SendChar(unsigned char ch); */ uint8_t SHELL_ParseCommandIO(const unsigned char *command, McuShell_ConstStdIOType *io, bool silent); +/*! +* \brief Parses a command with a given standard I/O channel +* \param command Command to be parsed +* \param io I/O to be used. If NULL, the standard default I/O will be used +* \param silent If parsing shall be silent or not +* \return Error code, ERR_OK for no error +*/ +void SHELL_SendStringToIO(const unsigned char *str, McuShell_ConstStdIOType *io); /*! * \brief Module de-initialization */ diff --git a/ADIS_tinyK22_SplitFlap/source/splitflap.h b/ADIS_tinyK22_SplitFlap/source/splitflap.h index d2fb71e..c884af6 100644 --- a/ADIS_tinyK22_SplitFlap/source/splitflap.h +++ b/ADIS_tinyK22_SplitFlap/source/splitflap.h @@ -16,7 +16,7 @@ #include /****** SETTINGS ******/ -#define SPLITFLAP_CONFIG_USE_FREERTOS_HEAP 0 +#define SPLITFLAP_CONFIG_USE_FREERTOS_HEAP 1 #define SPLITFLAP_STEPS_ONE_ROUND 512 #define SPLITFLAP_AMOUNT_OF_SEGMENTS (sizeof(SF_Letters)/sizeof(SF_Letters[0])) #define SPLITFLAP_STEPS_PER_SEGMENT ((float)SPLITFLAP_STEPS_ONE_ROUND/(float)SPLITFLAP_AMOUNT_OF_SEGMENTS)