diff --git a/MDK-ARM/MR16.uvguix.yxm23 b/MDK-ARM/MR16.uvguix.yxm23 index 961f88b..b184aa3 100644 --- a/MDK-ARM/MR16.uvguix.yxm23 +++ b/MDK-ARM/MR16.uvguix.yxm23 @@ -110,8 +110,8 @@ 0 - 2058 - 0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000001B000000150000000100000020443A5C435542454D585C4D5231365C557365725C7461736B5C726164696F2E630000000007726164696F2E6300000000C5D4F200FFFFFFFF1E443A5C435542454D585C4D5231365C436F72655C5372635C6D61696E2E6300000000066D61696E2E6300000000FFDC7800FFFFFFFF21443A5C435542454D585C4D5231365C557365725C6D6F64756C655C6D7231362E6800000000066D7231362E6800000000BECEA100FFFFFFFF2E443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C6B6579537461747573436865636B2E6800000000106B6579537461747573436865636B2E6800000000F0A0A100FFFFFFFF2B443A5C435542454D585C4D5231365C557365725C6465766963655C6C63645F6472697665725C6C63642E6800000000056C63642E6800000000BCA8E100FFFFFFFF24443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C637263382E680000000006637263382E68000000009CC1B600FFFFFFFF2B443A5C435542454D585C4D5231365C557365725C6465766963655C6C63645F6472697665725C6C63642E6300000000056C63642E6300000000F7B88600FFFFFFFF1D443A5C435542454D585C4D5231365C557365725C6273705C7370692E6800000000057370692E6800000000D9ADC200FFFFFFFF1D443A5C435542454D585C4D5231365C557365725C6273705C7370692E6300000000057370692E6300000000A5C2D700FFFFFFFF21443A5C435542454D585C4D5231365C557365725C6D6F64756C655C6D7231362E6300000000066D7231362E6300000000B3A6BE00FFFFFFFF31443A5C435542454D585C4D5231365C557365725C6465766963655C7378313238315F6472697665725C7378313238312E6800000000087378313238312E6800000000EAD6A300FFFFFFFF31443A5C435542454D585C4D5231365C557365725C6465766963655C7378313238315F6472697665725C7378313238312E6300000000087378313238312E6300000000F6FA7D00FFFFFFFF2C443A5C435542454D585C4D5231365C4D444B2D41524D5C737461727475705F73746D33326631303378622E730000000015737461727475705F73746D33326631303378622E7300000000B5E99D00FFFFFFFF2C443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C4672656552544F535F434C492E68000000000E4672656552544F535F434C492E68000000005FC3CF00FFFFFFFF1E443A5C435542454D585C4D5231365C557365725C6273705C74696D652E63000000000674696D652E6300000000C1838300FFFFFFFF1E443A5C435542454D585C4D5231365C557365725C6273705C74696D652E68000000000674696D652E6800000000CACAD500FFFFFFFF2C443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C6672656572746F735F636C692E63000000000E6672656572746F735F636C692E6300000000C5D4F200FFFFFFFF24443A5C435542454D585C4D5231365C557365725C7461736B5C757365725F7461736B2E63000000000B757365725F7461736B2E6300000000FFDC7800FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C7461736B5C696E69742E630000000006696E69742E6300000000BECEA100FFFFFFFF24443A5C435542454D585C4D5231365C557365725C7461736B5C757365725F7461736B2E68000000000B757365725F7461736B2E6800000000F0A0A100FFFFFFFF1F443A5C435542454D585C4D5231365C436F72655C5372635C75736172742E63000000000775736172742E6300000000BCA8E100FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C6273705C666C6173682E630000000007666C6173682E63000000009CC1B600FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C6273705C666C6173682E680000000007666C6173682E6800000000F7B88600FFFFFFFF49443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C4C65676163795C73746D33325F68616C5F6C65676163792E68000000001273746D33325F68616C5F6C65676163792E6800000000D9ADC200FFFFFFFF48443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C73746D3332663178785F68616C5F666C6173685F65782E68000000001873746D3332663178785F68616C5F666C6173685F65782E6800000000A5C2D700FFFFFFFF45443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C5372635C73746D3332663178785F68616C5F666C6173682E63000000001573746D3332663178785F68616C5F666C6173682E6300000000B3A6BE00FFFFFFFF45443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C73746D3332663178785F68616C5F666C6173682E68000000001573746D3332663178785F68616C5F666C6173682E6800000000EAD6A300FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000000001000066000000AB06000075030000 + 2119 + 0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000001C000000090000000100000020443A5C435542454D585C4D5231365C557365725C7461736B5C726164696F2E630000000007726164696F2E6300000000C5D4F200FFFFFFFF1E443A5C435542454D585C4D5231365C436F72655C5372635C6D61696E2E6300000000066D61696E2E6300000000FFDC7800FFFFFFFF21443A5C435542454D585C4D5231365C557365725C6D6F64756C655C6D7231362E6800000000066D7231362E6800000000BECEA100FFFFFFFF2E443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C6B6579537461747573436865636B2E6800000000106B6579537461747573436865636B2E6800000000F0A0A100FFFFFFFF2B443A5C435542454D585C4D5231365C557365725C6465766963655C6C63645F6472697665725C6C63642E6800000000056C63642E6800000000BCA8E100FFFFFFFF24443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C637263382E680000000006637263382E68000000009CC1B600FFFFFFFF2B443A5C435542454D585C4D5231365C557365725C6465766963655C6C63645F6472697665725C6C63642E6300000000056C63642E6300000000F7B88600FFFFFFFF1D443A5C435542454D585C4D5231365C557365725C6273705C7370692E6800000000057370692E6800000000D9ADC200FFFFFFFF1D443A5C435542454D585C4D5231365C557365725C6273705C7370692E6300000000057370692E6300000000A5C2D700FFFFFFFF21443A5C435542454D585C4D5231365C557365725C6D6F64756C655C6D7231362E6300000000066D7231362E6300000000B3A6BE00FFFFFFFF31443A5C435542454D585C4D5231365C557365725C6465766963655C7378313238315F6472697665725C7378313238312E6800000000087378313238312E6800000000EAD6A300FFFFFFFF31443A5C435542454D585C4D5231365C557365725C6465766963655C7378313238315F6472697665725C7378313238312E6300000000087378313238312E6300000000F6FA7D00FFFFFFFF2C443A5C435542454D585C4D5231365C4D444B2D41524D5C737461727475705F73746D33326631303378622E730000000015737461727475705F73746D33326631303378622E7300000000B5E99D00FFFFFFFF2C443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C4672656552544F535F434C492E68000000000E4672656552544F535F434C492E68000000005FC3CF00FFFFFFFF1E443A5C435542454D585C4D5231365C557365725C6273705C74696D652E63000000000674696D652E6300000000C1838300FFFFFFFF1E443A5C435542454D585C4D5231365C557365725C6273705C74696D652E68000000000674696D652E6800000000CACAD500FFFFFFFF2C443A5C435542454D585C4D5231365C557365725C636F6D706F6E656E745C6672656572746F735F636C692E63000000000E6672656572746F735F636C692E6300000000C5D4F200FFFFFFFF24443A5C435542454D585C4D5231365C557365725C7461736B5C757365725F7461736B2E63000000000B757365725F7461736B2E6300000000FFDC7800FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C7461736B5C696E69742E630000000006696E69742E6300000000BECEA100FFFFFFFF24443A5C435542454D585C4D5231365C557365725C7461736B5C757365725F7461736B2E68000000000B757365725F7461736B2E6800000000F0A0A100FFFFFFFF1F443A5C435542454D585C4D5231365C436F72655C5372635C75736172742E63000000000775736172742E6300000000BCA8E100FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C6273705C666C6173682E630000000007666C6173682E63000000009CC1B600FFFFFFFF1F443A5C435542454D585C4D5231365C557365725C6273705C666C6173682E680000000007666C6173682E6800000000F7B88600FFFFFFFF49443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C4C65676163795C73746D33325F68616C5F6C65676163792E68000000001273746D33325F68616C5F6C65676163792E6800000000D9ADC200FFFFFFFF48443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C73746D3332663178785F68616C5F666C6173685F65782E68000000001873746D3332663178785F68616C5F666C6173685F65782E6800000000A5C2D700FFFFFFFF45443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C5372635C73746D3332663178785F68616C5F666C6173682E63000000001573746D3332663178785F68616C5F666C6173682E6300000000B3A6BE00FFFFFFFF45443A5C435542454D585C4D5231365C447269766572735C53544D3332463178785F48414C5F4472697665725C496E635C73746D3332663178785F68616C5F666C6173682E68000000001573746D3332663178785F68616C5F666C6173682E6800000000EAD6A300FFFFFFFF23443A5C435542454D585C4D5231365C557365725C6D6F64756C655C636F6E6669672E680000000008636F6E6669672E6800000000F6FA7D00FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000000001000066000000AB06000075030000 @@ -3603,12 +3603,12 @@ 0 100 - 21 + 9 ..\User\task\radio.c - 32 - 21 - 45 + 0 + 1 + 1 1 0 @@ -3687,9 +3687,9 @@ ..\User\module\mr16.c - 0 - 150 - 170 + 23 + 240 + 265 1 0 @@ -3795,9 +3795,9 @@ ..\User\bsp\flash.c - 56 + 47 25 - 41 + 46 1 0 @@ -3847,6 +3847,15 @@ 0 + + ../User/module/config.h + 12 + 1 + 15 + 1 + + 0 + diff --git a/MDK-ARM/MR16/MR16.axf b/MDK-ARM/MR16/MR16.axf deleted file mode 100644 index 15a6d1d..0000000 Binary files a/MDK-ARM/MR16/MR16.axf and /dev/null differ diff --git a/MDK-ARM/MR16/MR16.build_log.htm b/MDK-ARM/MR16/MR16.build_log.htm index 5d61562..84d3273 100644 --- a/MDK-ARM/MR16/MR16.build_log.htm +++ b/MDK-ARM/MR16/MR16.build_log.htm @@ -29,19 +29,51 @@ Project File Date: 12/03/2025 Build target 'MR16' Note: source file '..\User\bsp\gpio.c' - object file renamed from 'MR16\gpio.o' to 'MR16\gpio_1.o'. Note: source file '..\User\bsp\spi.c' - object file renamed from 'MR16\spi.o' to 'MR16\spi_1.o'. -compiling flash.c... compiling radio.c... ../User/task/user_task.h(80): warning: #1-D: last line of file ends without a newline #endif -../User/module/mr16.h(97): warning: #1-D: last line of file ends without a newline +../User/module/mr16.h(96): warning: #1-D: last line of file ends without a newline #endif +..\User\task\radio.c(43): error: #167: argument of type "MR16_Param_t" is incompatible with parameter of type "MR16_Param_t *" + MR16_Init(&mr16,Config_Get()->mr16,MR16_MODE_RC, RADIOMODE_FLRC); ..\User\task\radio.c(56): warning: #1-D: last line of file ends without a newline } -..\User\task\radio.c: 3 warnings, 0 errors -linking... -Program Size: Code=32780 RO-data=13892 RW-data=256 ZI-data=18912 -FromELF: creating hex file... -"MR16\MR16.axf" - 0 Error(s), 3 Warning(s). +..\User\task\radio.c: 3 warnings, 1 error +compiling mr16.c... +../User/module/mr16.h(96): warning: #1-D: last line of file ends without a newline + #endif +../User/bsp/gpio.h(59): warning: #1-D: last line of file ends without a newline + #endif +..\User\module\mr16.c(85): warning: #1295-D: Deprecated declaration MR16_CLI_Init - give arg types + int8_t MR16_CLI_Init(); +..\User\module\mr16.c(92): warning: #546-D: transfer of control bypasses initialization of: + variable "RXheader" (declared at line 100) + switch (source) { + ^ +..\User\module\mr16.c(152): warning: #940-D: missing return statement at end of non-void function "MR16_UI_PowerON" + } +..\User\module\mr16.c(156): warning: #940-D: missing return statement at end of non-void function "MR16_UI_Home" + } +..\User\module\mr16.c(160): warning: #940-D: missing return statement at end of non-void function "MR16_UI_Setting" + } +..\User\module\mr16.c(172): warning: #188-D: enumerated type mixed with another type + LCD_Init(1); +..\User\module\mr16.c(176): warning: #940-D: missing return statement at end of non-void function "MR16_Init" + } +..\User\module\mr16.c(232): warning: #940-D: missing return statement at end of non-void function "MR16_Main" + } +..\User\module\mr16.c(265): error: #171: invalid type conversion + BSP_Flash_WriteBytes(ADDR_FLASH_SECTOR(200), (const uint16_t*)Config_Get()->mr16, sizeof(MR16_Param_t)); +..\User\module\mr16.c(350): warning: #1-D: last line of file ends without a newline + } +..\User\module\mr16.c(350): warning: #940-D: missing return statement at end of non-void function "MR16_CLI_Init" + } +..\User\module\mr16.c(79): warning: #550-D: variable "MR16_FSM" was set but never used + static MR16_FSM_t MR16_FSM = MR16_FSM_NONE; +..\User\module\mr16.c(81): warning: #177-D: variable "MR16_SettingFSM" was declared but never referenced + static MR16_SettingFSM_t MR16_SettingFSM=MR16_SETTINGFSM_home; +..\User\module\mr16.c: 14 warnings, 1 error +"MR16\MR16.axf" - 2 Error(s), 17 Warning(s).

Software Packages used:

@@ -65,6 +97,7 @@ Package Vendor: Keil * Component: ARM::CMSIS:CORE:5.4.0 Include file: CMSIS\Core\Include\tz_context.h +Target not created. Build Time Elapsed: 00:00:02 diff --git a/MDK-ARM/MR16/MR16_MR16.dep b/MDK-ARM/MR16/MR16_MR16.dep index c1ba6d5..79e7e28 100644 --- a/MDK-ARM/MR16/MR16_MR16.dep +++ b/MDK-ARM/MR16/MR16_MR16.dep @@ -1180,7 +1180,7 @@ I (D:\cangming\ARM\ARMCC\include\stdio.h)(0x5E8E3CC2) F (..\User\device\lcd_driver\lcd.h)(0x692ABE66)() F (..\User\device\lcd_driver\lcd_lib.h)(0x692ABE66)() F (..\User\device\sx1281_driver\radio.h)(0x692C10EB)() -F (..\User\device\sx1281_driver\sx1281.c)(0x692FD9D0)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\sx1281.o --omf_browse mr16\sx1281.crf --depend mr16\sx1281.d) +F (..\User\device\sx1281_driver\sx1281.c)(0x693055D0)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\sx1281.o --omf_browse mr16\sx1281.crf --depend mr16\sx1281.d) I (..\User\device\sx1281_driver\sx1281_driver.h)(0x692DCACF) I (D:\cangming\ARM\ARMCC\include\stdint.h)(0x5E8E3CC2) I (D:\cangming\ARM\ARMCC\include\stdbool.h)(0x5E8E3CC2) @@ -1226,9 +1226,9 @@ I (../User/device/sx1281_driver/sx1281_boards.h)(0x69248C05) I (../User/device/sx1281_driver/sx1281_driver_gpio.h)(0x691D7D06) I (../User/device/sx1281_driver/sx1281_driver_spi.h)(0x5ACC746C) I (../User/device/sx1281_driver/sx1281_driver_uart.h)(0x692B9B3E) -I (../User/device/sx1281_driver/sx1281.h)(0x69303977) +I (../User/device/sx1281_driver/sx1281.h)(0x693056E4) I (../User/device/device.h)(0x692EA1CD) -F (..\User\device\sx1281_driver\sx1281.h)(0x69303977)() +F (..\User\device\sx1281_driver\sx1281.h)(0x693056E4)() F (..\User\device\sx1281_driver\sx1281_boards.h)(0x69248C05)() F (..\User\device\sx1281_driver\sx1281_driver.c)(0x692C1006)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\sx1281_driver.o --omf_browse mr16\sx1281_driver.crf --depend mr16\sx1281_driver.d) I (D:\cangming\ARM\ARMCC\include\string.h)(0x5E8E3CC2) @@ -1529,11 +1529,11 @@ I (D:\cangming\ARM\ARMCC\include\stdbool.h)(0x5E8E3CC2) I (D:\cangming\ARM\ARMCC\include\stddef.h)(0x5E8E3CC2) I (D:\cangming\ARM\ARMCC\include\stdio.h)(0x5E8E3CC2) F (..\User\component\ui.h)(0x692EA1CD)() -F (..\User\module\mr16.c)(0x69303CFD)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\mr16.o --omf_browse mr16\mr16.crf --depend mr16\mr16.d) -I (../User/module/mr16.h)(0x692FE6F1) +F (..\User\module\mr16.c)(0x69305BCF)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\mr16.o --omf_browse mr16\mr16.crf --depend mr16\mr16.d) +I (../User/module/mr16.h)(0x693057A1) I (D:\cangming\ARM\ARMCC\include\stdint.h)(0x5E8E3CC2) I (D:\cangming\ARM\ARMCC\include\stdbool.h)(0x5E8E3CC2) -I (../User/device/sx1281_driver/sx1281.h)(0x69303977) +I (../User/device/sx1281_driver/sx1281.h)(0x693056E4) I (../User/device/sx1281_driver/sx1281_driver.h)(0x692DCACF) I (D:\cangming\ARM\ARMCC\include\math.h)(0x5E8E3CC2) I (../User/device/device.h)(0x692EA1CD) @@ -1567,13 +1567,14 @@ I (../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h)(0x67480A20) I (../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h)(0x67480A20) I (D:\cangming\ARM\ARMCC\include\string.h)(0x5E8E3CC2) I (D:\cangming\ARM\ARMCC\include\stdio.h)(0x5E8E3CC2) +I (../User/bsp/flash.h)(0x69304D87) +I (../User/bsp/bsp.h)(0x692EA1CC) I (../Core/Inc/usart.h)(0x692EE31B) I (../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h)(0x67480A20) I (../User/device/sx1281_driver/radio.h)(0x692C10EB) I (../User/device/lcd_driver/lcd.h)(0x692ABE66) I (../User/bsp/spi.h)(0x692ECA05) I (../Core/Inc/spi.h)(0x691B56EA) -I (../User/bsp/bsp.h)(0x692EA1CC) I (../User/bsp/gpio.h)(0x692EA1CC) I (../User/component/FreeRTOS_CLI.h)(0x692ECE2B) I (../Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h)(0x67480A20) @@ -1583,7 +1584,8 @@ I (../Middlewares/Third_Party/FreeRTOS/Source/include/portable.h)(0x67480A20) I (../Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h)(0x67480A20) I (../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h)(0x67480A20) I (../Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h)(0x67480A20) -F (..\User\module\mr16.h)(0x692FE6F1)() +I (../User/module/config.h)(0x69305B59) +F (..\User\module\mr16.h)(0x693057A1)() F (..\User\task\init.c)(0x692EA1CB)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\init.o --omf_browse mr16\init.crf --depend mr16\init.d) I (../User/task/user_task.h)(0x692EA1CB) I (../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h)(0x67480A20) @@ -1613,7 +1615,7 @@ I (../Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h)(0x67480A20 I (../Middlewares/Third_Party/FreeRTOS/Source/include/task.h)(0x67480A20) I (../Middlewares/Third_Party/FreeRTOS/Source/include/list.h)(0x67480A20) F (..\User\task\user_task.h)(0x692EA1CB)() -F (..\User\task\radio.c)(0x69304D86)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\radio.o --omf_browse mr16\radio.crf --depend mr16\radio.d) +F (..\User\task\radio.c)(0x693058C5)(--c99 -c --cpu Cortex-M3 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc -I ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I ../Drivers/CMSIS/Include -I ../sx1281-driver-c -I ../User -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3 -I.\RTE\_MR16 -ID:\cangming\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID:\cangming\keil\STM32F1xx_DFP\2.0.0\Device\Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F103xB -o mr16\radio.o --omf_browse mr16\radio.crf --depend mr16\radio.d) I (../User/task/user_task.h)(0x692EA1CB) I (../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h)(0x67480A20) I (D:\cangming\ARM\ARMCC\include\stdint.h)(0x5E8E3CC2) @@ -1656,12 +1658,13 @@ I (../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h)(0x67480A20) I (../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h)(0x67480A20) I (../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h)(0x67480A20) I (../Core/Inc/usart.h)(0x692EE31B) -I (../User/module/mr16.h)(0x692FE6F1) +I (../User/module/mr16.h)(0x693057A1) I (D:\cangming\ARM\ARMCC\include\stdbool.h)(0x5E8E3CC2) -I (../User/device/sx1281_driver/sx1281.h)(0x69303977) +I (../User/device/sx1281_driver/sx1281.h)(0x693056E4) I (../User/device/sx1281_driver/sx1281_driver.h)(0x692DCACF) I (D:\cangming\ARM\ARMCC\include\math.h)(0x5E8E3CC2) I (../User/device/device.h)(0x692EA1CD) I (../User/bsp/flash.h)(0x69304D87) I (../User/bsp/bsp.h)(0x692EA1CC) I (../User/device/sx1281_driver/radio.h)(0x692C10EB) +I (../User/module/config.h)(0x69305B59) diff --git a/MDK-ARM/MR16/mr16.crf b/MDK-ARM/MR16/mr16.crf index 40c3f48..c74bf7c 100644 Binary files a/MDK-ARM/MR16/mr16.crf and b/MDK-ARM/MR16/mr16.crf differ diff --git a/MDK-ARM/MR16/mr16.d b/MDK-ARM/MR16/mr16.d index 4a95075..fb14232 100644 --- a/MDK-ARM/MR16/mr16.d +++ b/MDK-ARM/MR16/mr16.d @@ -37,13 +37,14 @@ mr16\mr16.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h mr16\mr16.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h mr16\mr16.o: D:\cangming\ARM\ARMCC\Bin\..\include\string.h mr16\mr16.o: D:\cangming\ARM\ARMCC\Bin\..\include\stdio.h +mr16\mr16.o: ../User/bsp/flash.h +mr16\mr16.o: ../User/bsp/bsp.h mr16\mr16.o: ../Core/Inc/usart.h mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.h mr16\mr16.o: ../User/device/sx1281_driver/radio.h mr16\mr16.o: ../User/device/lcd_driver/lcd.h mr16\mr16.o: ../User/bsp/spi.h mr16\mr16.o: ../Core/Inc/spi.h -mr16\mr16.o: ../User/bsp/bsp.h mr16\mr16.o: ../User/bsp/gpio.h mr16\mr16.o: ../User/component/FreeRTOS_CLI.h mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h @@ -53,3 +54,4 @@ mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/include/portable.h mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h mr16\mr16.o: ../Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h +mr16\mr16.o: ../User/module/config.h diff --git a/MDK-ARM/MR16/mr16.o b/MDK-ARM/MR16/mr16.o deleted file mode 100644 index dfed657..0000000 Binary files a/MDK-ARM/MR16/mr16.o and /dev/null differ diff --git a/MDK-ARM/MR16/radio.crf b/MDK-ARM/MR16/radio.crf index ad321fc..9966231 100644 Binary files a/MDK-ARM/MR16/radio.crf and b/MDK-ARM/MR16/radio.crf differ diff --git a/MDK-ARM/MR16/radio.d b/MDK-ARM/MR16/radio.d index ec9e118..1770b53 100644 --- a/MDK-ARM/MR16/radio.d +++ b/MDK-ARM/MR16/radio.d @@ -51,3 +51,4 @@ mr16\radio.o: ../User/device/device.h mr16\radio.o: ../User/bsp/flash.h mr16\radio.o: ../User/bsp/bsp.h mr16\radio.o: ../User/device/sx1281_driver/radio.h +mr16\radio.o: ../User/module/config.h diff --git a/MDK-ARM/MR16/radio.o b/MDK-ARM/MR16/radio.o deleted file mode 100644 index 60ae812..0000000 Binary files a/MDK-ARM/MR16/radio.o and /dev/null differ diff --git a/MDK-ARM/MR16/sx1281.crf b/MDK-ARM/MR16/sx1281.crf index 9775219..c38c4a4 100644 Binary files a/MDK-ARM/MR16/sx1281.crf and b/MDK-ARM/MR16/sx1281.crf differ diff --git a/MDK-ARM/MR16/sx1281.o b/MDK-ARM/MR16/sx1281.o index 938997d..31d5ba4 100644 Binary files a/MDK-ARM/MR16/sx1281.o and b/MDK-ARM/MR16/sx1281.o differ diff --git a/User/bsp/flash.c b/User/bsp/flash.c index 225c6df..6b55615 100644 --- a/User/bsp/flash.c +++ b/User/bsp/flash.c @@ -38,7 +38,7 @@ void BSP_Flash_EraseSector(uint32_t sector) { } } -void BSP_Flash_WriteBytes(uint32_t address, const uint16_t *buf, size_t len) { +void BSP_Flash_WriteBytes(uint32_t address, const uint8_t *buf, size_t len) { HAL_FLASH_Unlock(); while (len > 0) { while (FLASH_WaitForLastOperation(50) != HAL_OK) diff --git a/User/bsp/flash.h b/User/bsp/flash.h index c7b6764..6dccfee 100644 --- a/User/bsp/flash.h +++ b/User/bsp/flash.h @@ -58,7 +58,7 @@ F表示768KB(超大容量xl), G表示1024KB(超大容量xl), */ /* Exported types ------------------------------------------------------------ */ /* Exported functions prototypes --------------------------------------------- */ void BSP_Flash_EraseSector(uint32_t sector); -void BSP_Flash_WriteBytes(uint32_t address, const uint16_t *buf, size_t len); +void BSP_Flash_WriteBytes(uint32_t address, const uint8_t *buf, size_t len); void BSP_Flash_ReadBytes(uint32_t address, void *buf, size_t len); #ifdef __cplusplus diff --git a/User/device/sx1281_driver/sx1281.c b/User/device/sx1281_driver/sx1281.c index 80b9377..e7bd08d 100644 --- a/User/device/sx1281_driver/sx1281.c +++ b/User/device/sx1281_driver/sx1281.c @@ -269,11 +269,13 @@ typedef union BleAdvHeaders_t ble_header_adv; -int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode) { +int8_t SX1281_Init(SX1281_t *radio, SX1281_Params_t *param,SX1281_RadioMode_t mode) { if (radio==NULL) { return DEVICE_ERR; } - radio->param.radioMode = mode; + radio->param=param; + + radio->param->radioMode = mode; SX1281_BSPInit() ; HAL_Delay( 500 );/* let DC/DC power ramp up */ @@ -287,10 +289,10 @@ int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode) { printf( "\n\n\r Radio firmware version 0x%x\n\n\r", Radio.GetFirmwareVersion( ) ); #endif //SX1281_VIEW - radio->param.baudrate.ble=RF_BAUDRATE_BLE_1M; - radio->param.baudrate.lora=RF_BAUDRATE_LORA_005K; - radio->param.baudrate.gfks=RF_BAUDRATE_GFSK_125K; - radio->param.baudrate.flrc=RF_BAUDRATE_FLRC_130K; + radio->param->baudrate.ble=RF_BAUDRATE_BLE_1M; + radio->param->baudrate.lora=RF_BAUDRATE_LORA_005K; + radio->param->baudrate.gfks=RF_BAUDRATE_GFSK_125K; + radio->param->baudrate.flrc=RF_BAUDRATE_FLRC_130K; /* 根据模式选择属性 */ switch (mode) { @@ -298,80 +300,80 @@ int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode) { #ifdef SX1281_VIEW printf( "\nrunning in BLE mode\n\r" ); #endif //SX1281_VIEW - radio->param.modulationParams.PacketType = PACKET_TYPE_BLE; - radio->param.modulationParams.Params.Ble.BitrateBandwidth - = bleConfigList[radio->param.baudrate.ble].BitrateBandwidth; - radio->param.modulationParams.Params.Ble.ModulationIndex - = bleConfigList[radio->param.baudrate.ble].ModulationIndex; - radio->param.modulationParams.Params.Ble.ModulationShaping - = bleConfigList[radio->param.baudrate.ble].ModulationShaping; + radio->param->modulationParams.PacketType = PACKET_TYPE_BLE; + radio->param->modulationParams.Params.Ble.BitrateBandwidth + = bleConfigList[radio->param->baudrate.ble].BitrateBandwidth; + radio->param->modulationParams.Params.Ble.ModulationIndex + = bleConfigList[radio->param->baudrate.ble].ModulationIndex; + radio->param->modulationParams.Params.Ble.ModulationShaping + = bleConfigList[radio->param->baudrate.ble].ModulationShaping; - radio->param.packetParams.PacketType = PACKET_TYPE_BLE; - radio->param.packetParams.Params.Ble.BlePacketType = BLE_EYELONG_1_0; - radio->param.packetParams.Params.Ble.ConnectionState = BLE_ADVERTISER; - radio->param.packetParams.Params.Ble.CrcField = BLE_CRC_3B; - radio->param.packetParams.Params.Ble.Whitening = RADIO_WHITENING_ON; + radio->param->packetParams.PacketType = PACKET_TYPE_BLE; + radio->param->packetParams.Params.Ble.BlePacketType = BLE_EYELONG_1_0; + radio->param->packetParams.Params.Ble.ConnectionState = BLE_ADVERTISER; + radio->param->packetParams.Params.Ble.CrcField = BLE_CRC_3B; + radio->param->packetParams.Params.Ble.Whitening = RADIO_WHITENING_ON; break; case RADIOMODE_LORA: #ifdef SX1281_VIEW printf( "\nrunning in LORA mode\n\r" ); #endif //SX1281_VIEW - radio->param.modulationParams.PacketType = PACKET_TYPE_LORA; - radio->param.modulationParams.Params.LoRa.SpreadingFactor - = loraConfigList[radio->param.baudrate.lora].SpreadingFactor; - radio->param.modulationParams.Params.LoRa.Bandwidth - = loraConfigList[radio->param.baudrate.lora].Bandwidth; - radio->param.modulationParams.Params.LoRa.CodingRate - = loraConfigList[radio->param.baudrate.lora].CodingRate; + radio->param->modulationParams.PacketType = PACKET_TYPE_LORA; + radio->param->modulationParams.Params.LoRa.SpreadingFactor + = loraConfigList[radio->param->baudrate.lora].SpreadingFactor; + radio->param->modulationParams.Params.LoRa.Bandwidth + = loraConfigList[radio->param->baudrate.lora].Bandwidth; + radio->param->modulationParams.Params.LoRa.CodingRate + = loraConfigList[radio->param->baudrate.lora].CodingRate; - radio->param.packetParams.PacketType = PACKET_TYPE_LORA; - radio->param.packetParams.Params.LoRa.PreambleLength = 12; - radio->param.packetParams.Params.LoRa.HeaderType = LORA_PACKET_VARIABLE_LENGTH; - radio->param.packetParams.Params.LoRa.PayloadLength = BUFFER_SIZE; - radio->param.packetParams.Params.LoRa.CrcMode = LORA_CRC_ON; - radio->param.packetParams.Params.LoRa.InvertIQ = LORA_IQ_NORMAL; + radio->param->packetParams.PacketType = PACKET_TYPE_LORA; + radio->param->packetParams.Params.LoRa.PreambleLength = 12; + radio->param->packetParams.Params.LoRa.HeaderType = LORA_PACKET_VARIABLE_LENGTH; + radio->param->packetParams.Params.LoRa.PayloadLength = BUFFER_SIZE; + radio->param->packetParams.Params.LoRa.CrcMode = LORA_CRC_ON; + radio->param->packetParams.Params.LoRa.InvertIQ = LORA_IQ_NORMAL; break; case RADIOMODE_GFSK: #ifdef SX1281_VIEW printf( "\nrunning in GFSK mode\n\r" ); #endif //SX1281_VIEW - radio->param.modulationParams.PacketType = PACKET_TYPE_GFSK; - radio->param.modulationParams.Params.Gfsk.BitrateBandwidth - = gfskConfigList[radio->param.baudrate.gfks].BitrateBandwidth; - radio->param.modulationParams.Params.Gfsk.ModulationIndex - = gfskConfigList[radio->param.baudrate.gfks].ModulationIndex; - radio->param.modulationParams.Params.Gfsk.ModulationShaping - = gfskConfigList[radio->param.baudrate.gfks].ModulationShaping; + radio->param->modulationParams.PacketType = PACKET_TYPE_GFSK; + radio->param->modulationParams.Params.Gfsk.BitrateBandwidth + = gfskConfigList[radio->param->baudrate.gfks].BitrateBandwidth; + radio->param->modulationParams.Params.Gfsk.ModulationIndex + = gfskConfigList[radio->param->baudrate.gfks].ModulationIndex; + radio->param->modulationParams.Params.Gfsk.ModulationShaping + = gfskConfigList[radio->param->baudrate.gfks].ModulationShaping; - radio->param.packetParams.PacketType = PACKET_TYPE_GFSK; - radio->param.packetParams.Params.Gfsk.PreambleLength = PREAMBLE_LENGTH_32_BITS; - radio->param.packetParams.Params.Gfsk.SyncWordLength = GFS_SYNCWORD_LENGTH_5_BYTE; - radio->param.packetParams.Params.Gfsk.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; - radio->param.packetParams.Params.Gfsk.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; - radio->param.packetParams.Params.Gfsk.PayloadLength = BUFFER_SIZE; - radio->param.packetParams.Params.Gfsk.CrcLength = RADIO_CRC_3_BYTES; - radio->param.packetParams.Params.Gfsk.Whitening = RADIO_WHITENING_ON; + radio->param->packetParams.PacketType = PACKET_TYPE_GFSK; + radio->param->packetParams.Params.Gfsk.PreambleLength = PREAMBLE_LENGTH_32_BITS; + radio->param->packetParams.Params.Gfsk.SyncWordLength = GFS_SYNCWORD_LENGTH_5_BYTE; + radio->param->packetParams.Params.Gfsk.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; + radio->param->packetParams.Params.Gfsk.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; + radio->param->packetParams.Params.Gfsk.PayloadLength = BUFFER_SIZE; + radio->param->packetParams.Params.Gfsk.CrcLength = RADIO_CRC_3_BYTES; + radio->param->packetParams.Params.Gfsk.Whitening = RADIO_WHITENING_ON; break; case RADIOMODE_FLRC: #ifdef SX1281_VIEW printf( "\nrunning in FLRC mode\n\r" ); #endif //SX1281_VIEW - radio->param.modulationParams.PacketType = PACKET_TYPE_FLRC; - radio->param.modulationParams.Params.Flrc.BitrateBandwidth - = flrcConfigList[radio->param.baudrate.flrc].BitrateBandwidth; - radio->param.modulationParams.Params.Flrc.CodingRate - = flrcConfigList[radio->param.baudrate.flrc].CodingRate; - radio->param.modulationParams.Params.Flrc.ModulationShaping - = flrcConfigList[radio->param.baudrate.flrc].ModulationShaping; + radio->param->modulationParams.PacketType = PACKET_TYPE_FLRC; + radio->param->modulationParams.Params.Flrc.BitrateBandwidth + = flrcConfigList[radio->param->baudrate.flrc].BitrateBandwidth; + radio->param->modulationParams.Params.Flrc.CodingRate + = flrcConfigList[radio->param->baudrate.flrc].CodingRate; + radio->param->modulationParams.Params.Flrc.ModulationShaping + = flrcConfigList[radio->param->baudrate.flrc].ModulationShaping; - radio->param.packetParams.PacketType = PACKET_TYPE_FLRC; - radio->param.packetParams.Params.Flrc.PreambleLength = PREAMBLE_LENGTH_32_BITS; - radio->param.packetParams.Params.Flrc.SyncWordLength = FLRC_SYNCWORD_LENGTH_4_BYTE; - radio->param.packetParams.Params.Flrc.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; - radio->param.packetParams.Params.Flrc.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; - radio->param.packetParams.Params.Flrc.PayloadLength = BUFFER_SIZE; - radio->param.packetParams.Params.Flrc.CrcLength = RADIO_CRC_3_BYTES; - radio->param.packetParams.Params.Flrc.Whitening = RADIO_WHITENING_OFF; + radio->param->packetParams.PacketType = PACKET_TYPE_FLRC; + radio->param->packetParams.Params.Flrc.PreambleLength = PREAMBLE_LENGTH_32_BITS; + radio->param->packetParams.Params.Flrc.SyncWordLength = FLRC_SYNCWORD_LENGTH_4_BYTE; + radio->param->packetParams.Params.Flrc.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; + radio->param->packetParams.Params.Flrc.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; + radio->param->packetParams.Params.Flrc.PayloadLength = BUFFER_SIZE; + radio->param->packetParams.Params.Flrc.CrcLength = RADIO_CRC_3_BYTES; + radio->param->packetParams.Params.Flrc.Whitening = RADIO_WHITENING_OFF; break; default: @@ -379,36 +381,36 @@ int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode) { } /* 默认功率13dBm */ - radio->param.txOutputPower=13; - radio->param.rampTime=RADIO_RAMP_02_US; - radio->param.rfFrequency=2426000000; + radio->param->txOutputPower=13; + radio->param->rampTime=RADIO_RAMP_02_US; + radio->param->rfFrequency=2426000000; // 设置同步字 - if (radio->param.radioMode==RADIOMODE_GFSK) { + if (radio->param->radioMode==RADIOMODE_GFSK) { uint8_t sync1[5] = {0x12, 0x34, 0x56, 0x78, 0x9A}; uint8_t sync2[5] = {0x23, 0x45, 0x67, 0x89, 0xAB}; uint8_t sync3[5] = {0x34, 0x56, 0x78, 0x9A, 0xBC}; - memcpy(radio->param.syncWord.gfsk.first, sync1, sizeof(sync1)); - memcpy(radio->param.syncWord.gfsk.second, sync2, sizeof(sync2)); - memcpy(radio->param.syncWord.gfsk.third, sync3, sizeof(sync3)); + memcpy(radio->param->syncWord.gfsk.first, sync1, sizeof(sync1)); + memcpy(radio->param->syncWord.gfsk.second, sync2, sizeof(sync2)); + memcpy(radio->param->syncWord.gfsk.third, sync3, sizeof(sync3)); //if()一10000,二100000,三1000000 Radio.SetSyncWord(1, sync1); // 设置第一个同步字 } - if (radio->param.radioMode==RADIOMODE_FLRC) { + if (radio->param->radioMode==RADIOMODE_FLRC) { uint8_t sync1[4] = {0x12, 0x23, 0x34, 0x45}; uint8_t sync2[4] = {0x56, 0x67, 0x78, 0x89}; uint8_t sync3[4] = {0x9A, 0xAB, 0xBC, 0xCD}; - memcpy(radio->param.syncWord.gfsk.first, sync1, sizeof(sync1)); - memcpy(radio->param.syncWord.gfsk.second, sync2, sizeof(sync2)); - memcpy(radio->param.syncWord.gfsk.third, sync3, sizeof(sync3)); + memcpy(radio->param->syncWord.gfsk.first, sync1, sizeof(sync1)); + memcpy(radio->param->syncWord.gfsk.second, sync2, sizeof(sync2)); + memcpy(radio->param->syncWord.gfsk.third, sync3, sizeof(sync3)); } /* 设置属性 */ Radio.SetStandby( STDBY_RC ); - Radio.SetPacketType( radio->param.modulationParams.PacketType );//包类型 - Radio.SetModulationParams( &radio->param.modulationParams );//调制属性 - Radio.SetPacketParams( &radio->param.packetParams );//包属性 - Radio.SetRfFrequency( radio->param.rfFrequency );//设置射频工作中心频率 + Radio.SetPacketType( radio->param->modulationParams.PacketType );//包类型 + Radio.SetModulationParams( &radio->param->modulationParams );//调制属性 + Radio.SetPacketParams( &radio->param->packetParams );//包属性 + Radio.SetRfFrequency( radio->param->rfFrequency );//设置射频工作中心频率 Radio.SetBufferBaseAddresses( 0x00, 0x00 );//缓冲区起始地址 - Radio.SetTxParams( radio->param.txOutputPower, radio->param.rampTime);//发送属性 + Radio.SetTxParams( radio->param->txOutputPower, radio->param->rampTime);//发送属性 #ifdef SX1281_INTERRUP_MODE /* 中断模式 */ @@ -420,7 +422,7 @@ int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode) { #endif /* 还没搞懂这里是干啥的 */ - // if (radio->param.radioMode==RADIOMODE_BLE) { + // if (radio->param->radioMode==RADIOMODE_BLE) { // // only used in GENERIC and BLE mode // Radio.SetSyncWord( 1, ( uint8_t[] ){ 0xDD, 0xA0, 0x96, 0x69, 0xDD } ); // Radio.WriteRegister(0x9c7, 0x55 ); @@ -440,17 +442,17 @@ int8_t SX1281_SetRFFrequency(SX1281_t *radio, uint32_t frequency) { return DEVICE_ERR; } Radio.SetStandby( STDBY_RC ); - Radio.SetPacketType( radio->param.modulationParams.PacketType ); + Radio.SetPacketType( radio->param->modulationParams.PacketType ); - radio->param.rfFrequency=frequency; - Radio.SetRfFrequency( radio->param.rfFrequency );//设置射频工作中心频率 + radio->param->rfFrequency=frequency; + Radio.SetRfFrequency( radio->param->rfFrequency );//设置射频工作中心频率 return DEVICE_OK; } /////蓝牙还没研究明白 void SetBLEAdvertisingPacket(SX1281_t *radio, uint8_t *data, uint8_t length) { - // if (radio->param.radioMode != RADIOMODE_BLE) { + // if (radio->param->radioMode != RADIOMODE_BLE) { // printf("Error: Not in BLE mode\n"); // return; // } @@ -503,7 +505,7 @@ void SetBLEAdvertisingPacket(SX1281_t *radio, uint8_t *data, uint8_t length) { // Radio.SetPacketParams(&packetParams); // // 设置频率 - BLE广告信道38: 2426000000 Hz - // Radio.SetRfFrequency(radio->param.rfFrequency); + // Radio.SetRfFrequency(radio->param->rfFrequency); // // 设置BLE特定参数 // Radio.SetSyncWord(1, (uint8_t[]){0xDD, 0xA0, 0x96, 0x69, 0xDD}); @@ -528,6 +530,7 @@ void SetBLEAdvertisingPacket(SX1281_t *radio, uint8_t *data, uint8_t length) { int8_t SX1281_SetRXSingle(SX1281_t *radio) { radio->appMode=APPMODE_RXSINGLE; + radio->param->RadioRole=RadioRoleRX; Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); return DEVICE_OK; @@ -535,6 +538,7 @@ int8_t SX1281_SetRXSingle(SX1281_t *radio) { int8_t SX1281_SetRXSuccessive(SX1281_t *radio) { radio->appMode=APPMODE_RXSUCCESSIVE; + radio->param->RadioRole=RadioRoleRX; Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, 0xFFFF } ); return DEVICE_OK; @@ -542,6 +546,7 @@ int8_t SX1281_SetRXSuccessive(SX1281_t *radio) { int8_t SX1281_SetTX (SX1281_t *radio,uint8_t *data,uint8_t datalength) { radio->appMode=APPMODE_TX; + radio->param->RadioRole=RadioRoleTX; Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); Radio.SendPayload(data,datalength, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE }); return DEVICE_OK; @@ -553,36 +558,36 @@ int8_t SX1281_SetMode(SX1281_t *radio, SX1281_RadioMode_t mode) { return DEVICE_ERR; } Radio.SetStandby( STDBY_RC ); - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - radio->param.radioMode = mode; - switch (radio->param.radioMode) { + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + radio->param->radioMode = mode; + switch (radio->param->radioMode) { case RADIOMODE_BLE: - radio->param.modulationParams.PacketType = PACKET_TYPE_BLE; - radio->param.packetParams.PacketType = PACKET_TYPE_BLE; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); - Radio.SetPacketParams( &radio->param.packetParams ); + radio->param->modulationParams.PacketType = PACKET_TYPE_BLE; + radio->param->packetParams.PacketType = PACKET_TYPE_BLE; + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); + Radio.SetPacketParams( &radio->param->packetParams ); break; case RADIOMODE_LORA: - radio->param.modulationParams.PacketType = PACKET_TYPE_LORA; - radio->param.packetParams.PacketType = PACKET_TYPE_LORA; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); - Radio.SetPacketParams( &radio->param.packetParams ); + radio->param->modulationParams.PacketType = PACKET_TYPE_LORA; + radio->param->packetParams.PacketType = PACKET_TYPE_LORA; + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); + Radio.SetPacketParams( &radio->param->packetParams ); break; case RADIOMODE_GFSK: - radio->param.modulationParams.PacketType = PACKET_TYPE_GFSK; - radio->param.packetParams.PacketType = PACKET_TYPE_LORA; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); - Radio.SetPacketParams( &radio->param.packetParams ); + radio->param->modulationParams.PacketType = PACKET_TYPE_GFSK; + radio->param->packetParams.PacketType = PACKET_TYPE_LORA; + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); + Radio.SetPacketParams( &radio->param->packetParams ); break; case RADIOMODE_FLRC: - radio->param.modulationParams.PacketType = PACKET_TYPE_FLRC; - radio->param.packetParams.PacketType = PACKET_TYPE_LORA; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); - Radio.SetPacketParams( &radio->param.packetParams ); + radio->param->modulationParams.PacketType = PACKET_TYPE_FLRC; + radio->param->packetParams.PacketType = PACKET_TYPE_LORA; + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); + Radio.SetPacketParams( &radio->param->packetParams ); break; default: return DEVICE_ERR; @@ -595,18 +600,18 @@ int8_t SX1281_SetBLEBaudrate(SX1281_t *radio, SX1281_BLEBaudrate_t baudrate) { if (radio==NULL) { return DEVICE_ERR; } - radio->param.baudrate.ble=baudrate; + radio->param->baudrate.ble=baudrate; Radio.SetStandby( STDBY_RC ); - radio->param.modulationParams.Params.Ble.BitrateBandwidth - = bleConfigList[radio->param.baudrate.ble].BitrateBandwidth; - radio->param.modulationParams.Params.Ble.ModulationIndex - = bleConfigList[radio->param.baudrate.ble].ModulationIndex; - radio->param.modulationParams.Params.Ble.ModulationShaping - = bleConfigList[radio->param.baudrate.ble].ModulationShaping; + radio->param->modulationParams.Params.Ble.BitrateBandwidth + = bleConfigList[radio->param->baudrate.ble].BitrateBandwidth; + radio->param->modulationParams.Params.Ble.ModulationIndex + = bleConfigList[radio->param->baudrate.ble].ModulationIndex; + radio->param->modulationParams.Params.Ble.ModulationShaping + = bleConfigList[radio->param->baudrate.ble].ModulationShaping; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); return DEVICE_OK; } @@ -615,18 +620,18 @@ int8_t SX1281_SetLORABaudrate(SX1281_t *radio, SX1281_LORABaudrate_t baudrate) { if (radio==NULL) { return DEVICE_ERR; } - radio->param.baudrate.lora=baudrate; + radio->param->baudrate.lora=baudrate; Radio.SetStandby( STDBY_RC ); - radio->param.modulationParams.Params.LoRa.SpreadingFactor - = loraConfigList[radio->param.baudrate.lora].SpreadingFactor; - radio->param.modulationParams.Params.LoRa.Bandwidth - = loraConfigList[radio->param.baudrate.lora].Bandwidth; - radio->param.modulationParams.Params.LoRa.CodingRate - = loraConfigList[radio->param.baudrate.lora].CodingRate; + radio->param->modulationParams.Params.LoRa.SpreadingFactor + = loraConfigList[radio->param->baudrate.lora].SpreadingFactor; + radio->param->modulationParams.Params.LoRa.Bandwidth + = loraConfigList[radio->param->baudrate.lora].Bandwidth; + radio->param->modulationParams.Params.LoRa.CodingRate + = loraConfigList[radio->param->baudrate.lora].CodingRate; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); return DEVICE_OK; } @@ -635,18 +640,18 @@ int8_t SX1281_SetGFSKBaudrate(SX1281_t *radio, SX1281_GFKSBaudrate_t baudrate) { if (radio==NULL) { return DEVICE_ERR; } - radio->param.baudrate.gfks=baudrate; + radio->param->baudrate.gfks=baudrate; Radio.SetStandby( STDBY_RC ); - radio->param.modulationParams.Params.Gfsk.BitrateBandwidth - = gfskConfigList[radio->param.baudrate.gfks].BitrateBandwidth; - radio->param.modulationParams.Params.Gfsk.ModulationIndex - = gfskConfigList[radio->param.baudrate.gfks].ModulationIndex; - radio->param.modulationParams.Params.Gfsk.ModulationShaping - = gfskConfigList[radio->param.baudrate.gfks].ModulationShaping; + radio->param->modulationParams.Params.Gfsk.BitrateBandwidth + = gfskConfigList[radio->param->baudrate.gfks].BitrateBandwidth; + radio->param->modulationParams.Params.Gfsk.ModulationIndex + = gfskConfigList[radio->param->baudrate.gfks].ModulationIndex; + radio->param->modulationParams.Params.Gfsk.ModulationShaping + = gfskConfigList[radio->param->baudrate.gfks].ModulationShaping; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); return DEVICE_OK; } @@ -655,18 +660,18 @@ int8_t SX1281_SetFLRCBaudrate(SX1281_t *radio, SX1281_FLRCBaudrate_t baudrate) { if (radio==NULL) { return DEVICE_ERR; } - radio->param.baudrate.flrc=baudrate; + radio->param->baudrate.flrc=baudrate; Radio.SetStandby( STDBY_RC ); - radio->param.modulationParams.Params.Flrc.BitrateBandwidth - = flrcConfigList[radio->param.baudrate.flrc].BitrateBandwidth; - radio->param.modulationParams.Params.Flrc.CodingRate - = flrcConfigList[radio->param.baudrate.flrc].CodingRate; - radio->param.modulationParams.Params.Flrc.ModulationShaping - = flrcConfigList[radio->param.baudrate.flrc].ModulationShaping; + radio->param->modulationParams.Params.Flrc.BitrateBandwidth + = flrcConfigList[radio->param->baudrate.flrc].BitrateBandwidth; + radio->param->modulationParams.Params.Flrc.CodingRate + = flrcConfigList[radio->param->baudrate.flrc].CodingRate; + radio->param->modulationParams.Params.Flrc.ModulationShaping + = flrcConfigList[radio->param->baudrate.flrc].ModulationShaping; - Radio.SetPacketType( radio->param.modulationParams.PacketType ); - Radio.SetModulationParams( &radio->param.modulationParams ); + Radio.SetPacketType( radio->param->modulationParams.PacketType ); + Radio.SetModulationParams( &radio->param->modulationParams ); return DEVICE_OK; } @@ -679,17 +684,17 @@ int8_t SX1281_SetPayloadLength(SX1281_t *radio, uint8_t length) { return DEVICE_ERR; } Radio.SetStandby( STDBY_RC ); - switch (radio->param.packetParams.PacketType) { + switch (radio->param->packetParams.PacketType) { case PACKET_TYPE_BLE: //蓝牙待更新 break; case PACKET_TYPE_GFSK: case PACKET_TYPE_LORA: case PACKET_TYPE_FLRC: - radio->param.packetParams.Params.Flrc.PayloadLength=length; - radio->param.packetParams.Params.Gfsk.PayloadLength=length; - radio->param.packetParams.Params.LoRa.PayloadLength=length; - Radio.SetPacketParams( &radio->param.packetParams ); + radio->param->packetParams.Params.Flrc.PayloadLength=length; + radio->param->packetParams.Params.Gfsk.PayloadLength=length; + radio->param->packetParams.Params.LoRa.PayloadLength=length; + Radio.SetPacketParams( &radio->param->packetParams ); break; case PACKET_TYPE_RANGING: case PACKET_TYPE_NONE: diff --git a/User/device/sx1281_driver/sx1281.h b/User/device/sx1281_driver/sx1281.h index d856ecc..5e6e219 100644 --- a/User/device/sx1281_driver/sx1281.h +++ b/User/device/sx1281_driver/sx1281.h @@ -107,6 +107,12 @@ typedef struct { }SX1281_SyncWord_t; typedef struct { + enum{ + RadioRoleNONE=0, + RadioRoleTX, + RadioRoleRX, + }RadioRole; + SX1281_RadioMode_t radioMode; SX1281_SyncWord_t syncWord; @@ -119,14 +125,14 @@ typedef struct { int8_t txOutputPower;//发射功率 The range of the output power is [-18..+13] dBm RadioRampTimes_t rampTime;//发射斜坡时间 - SX1281_Baudrate_t baudrate;//LORA,FLRC模式下不同调制方式的波特率 + SX1281_Baudrate_t baudrate;//不同调制方式的波特率 }SX1281_Params_t; typedef struct { SX1281_AppMode_t appMode; - SX1281_Params_t param; + SX1281_Params_t *param; SX1281_States_t appState; @@ -139,7 +145,7 @@ typedef struct { /* Exported functions prototypes -------------------------------------------- */ /* USER FUNCTION BEGIN */ -int8_t SX1281_Init(SX1281_t *radio, SX1281_RadioMode_t mode); +int8_t SX1281_Init(SX1281_t *radio, SX1281_Params_t *param,SX1281_RadioMode_t mode); int8_t SX1281_SetMode(SX1281_t *radio, SX1281_RadioMode_t mode); int8_t SX1281_SetRXSingle(SX1281_t *radio); diff --git a/User/module/config.c b/User/module/config.c index c890ae0..3772b58 100644 --- a/User/module/config.c +++ b/User/module/config.c @@ -4,9 +4,6 @@ /* Includes ----------------------------------------------------------------- */ #include "module/config.h" -#include "bsp/can.h" -#include "device/motor_dm.h" -#include "module/cmd.h" #include /* Private typedef ---------------------------------------------------------- */ /* Private define ----------------------------------------------------------- */ @@ -16,8 +13,11 @@ /* Exported variables ------------------------------------------------------- */ // 机器人参数配置 -Config_RobotParam_t robot_config = { - +Config_t robot_config = { + .mr16={ + .TX_ID=0x0001, + + } }; @@ -28,6 +28,6 @@ Config_RobotParam_t robot_config = { * @brief 获取机器人配置参数 * @return 机器人配置参数指针 */ -Config_RobotParam_t* Config_GetRobotParam(void) { +Config_t* Config_GetRobotParam(void) { return &robot_config; } \ No newline at end of file diff --git a/User/module/config.h b/User/module/config.h index 8ac3595..74d13f1 100644 --- a/User/module/config.h +++ b/User/module/config.h @@ -9,11 +9,11 @@ extern "C" { #endif #include - - +#include "device/sx1281_driver/sx1281.h" +#include "module/mr16.h" typedef struct { - -} Config_RobotParam_t; + MR16_Param_t mr16; +} Config_t; /* Exported functions prototypes -------------------------------------------- */ @@ -21,7 +21,7 @@ typedef struct { * @brief 获取机器人配置参数 * @return 机器人配置参数指针 */ -Config_RobotParam_t* Config_GetRobotParam(void); +Config_t* Config_Get(void); #ifdef __cplusplus } #endif diff --git a/User/module/mr16.c b/User/module/mr16.c index b74ac24..a81550b 100644 --- a/User/module/mr16.c +++ b/User/module/mr16.c @@ -6,11 +6,16 @@ #include #include #include + +#include "bsp/flash.h" +#include "device/sx1281_driver/sx1281.h" #include "usart.h" #include "device/sx1281_driver/radio.h" #include "device/lcd_driver/lcd.h" #include "device/sx1281_driver/sx1281_driver.h" #include "component/FreeRTOS_CLI.h" + +#include "module/config.h" /* USER INCLUDE BEGIN */ /* USER INCLUDE END */ @@ -71,8 +76,6 @@ extern uint8_t uart2_data[255],uart2_datalength; uint8_t radioRXBuffer[BUFFER_SIZE]; uint8_t radioRXSize; -static MR16_Mode_t MR16_Mode = MR16_MODE_NONE; - static MR16_FSM_t MR16_FSM = MR16_FSM_NONE; static MR16_SettingFSM_t MR16_SettingFSM=MR16_SETTINGFSM_home; @@ -96,7 +99,7 @@ int8_t SX1281_Callback(SX1281_States_t source) { radioRXBuffer[radioRXSize+1] = 0; uint16_t RXheader=(uint16_t)radioRXBuffer[1]<<8 & (uint16_t)radioRXBuffer[0]; for (int i=0; i<3; i++) { - if (RXheader==mr16.RX_ID[i]){ + if (RXheader==mr16.param->RX_ID[i]){ mr16.packetCount[i]++; } } @@ -143,13 +146,26 @@ int8_t SX1281_Callback(SX1281_States_t source) { } /* Exported functions ------------------------------------------------------- */ -int8_t MR16_Init(MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode) { +int8_t MR16_UI_PowerON() { + + LCD_DrawBitmap(logo_M,180,80,64,64,CRIMSON,MSB); +} + +int8_t MR16_UI_Home() { + +} + +int8_t MR16_UI_Setting() { + +} + +int8_t MR16_Init(MR16_t *mr16, MR16_Param_t *param, MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode) { MR16_CLI_Init(); - - MR16_Mode=mr16Mode; + mr16->param=param; + mr16->param->mode=mr16Mode; MR16_FSM=MR16_FSM_INIT; - SX1281_Init(&radio, radioMode); + SX1281_Init(&radio, ¶m->radioParams, radioMode); // SX1281_SetTX(&radio,uart_data,data_length); SX1281_SetRXSuccessive(&radio); // LCD显示 @@ -159,22 +175,6 @@ int8_t MR16_Init(MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode) { LCD_DrawBitmap(logo_M,180,80,64,64,CRIMSON,MSB); } -int8_t MR16_UI_PowerON() { - - LCD_DrawBitmap(logo_M,180,80,64,64,CRIMSON,MSB); -} - -int8_t MR16_UI_Home() { - - - -} - -int8_t MR16_UI_Setting() { - -} - - bool UART2_IdleFlag = false; void MR16_NotifyUARTIdle(void) { @@ -182,11 +182,11 @@ void MR16_NotifyUARTIdle(void) } char cInputBuffer[256]; char cOutputBuffer[256]; -int8_t MR16_Main(MR16_t mr16, uint8_t data[],uint8_t data_length) { +int8_t MR16_Main(MR16_t *mr16, uint8_t data[],uint8_t data_length) { if (UART2_IdleFlag==true) { UART2_IdleFlag = false; - mr16.mode=MR16_MODE_SETTING; + mr16->param->mode=MR16_MODE_SETTING; if (uart2_datalength > 0 && uart2_datalength < sizeof(cInputBuffer)) { memcpy(cInputBuffer, uart2_data, uart2_datalength); @@ -206,31 +206,15 @@ int8_t MR16_Main(MR16_t mr16, uint8_t data[],uint8_t data_length) { } while (xMore == pdTRUE); } - switch (mr16.mode) { + switch (mr16->param->mode) { case MR16_MODE_RFUART: break; case MR16_MODE_RC: - switch (MR16_FSM) { - case MR16_FSM_INIT: - if (radio.appMode==APPMODE_RXSINGLE||radio.appMode==APPMODE_RXSUCCESSIVE) {MR16_FSM=MR16_FSM_RX;} - else if (radio.appMode==APPMODE_TX) {MR16_FSM=MR16_FSM_TX;} - break; - case MR16_FSM_TX: - SX1281_Running(&radio); - SX1281_SetTX(&radio,data, data_length); - break; - case MR16_FSM_RX: - SX1281_Running(&radio); - break; - default: - break; - } - switch (radio.appMode) { case APPMODE_TX: SX1281_Running(&radio); - SX1281_SetTX(&radio,mr16.txbuffer,mr16.txbuffer[2]+5); + SX1281_SetTX(&radio,mr16->txbuffer,mr16->txbuffer[2]+5); break; case APPMODE_RXSUCCESSIVE: SX1281_Running(&radio); @@ -275,14 +259,18 @@ static BaseType_t mr16CommandHandler( char *pcWriteBuffer, size_t xWriteBufferLe arg2[c2] = '\0'; } - - if (strcasecmp(arg1, "mode") == 0) { + if (strcasecmp(arg1, "save") == 0) { + // 保存配置到Flash + BSP_Flash_EraseSector(200); + BSP_Flash_WriteBytes(ADDR_FLASH_SECTOR(200), (const uint8_t*)&Config_Get()->mr16, sizeof(MR16_Param_t)); + snprintf(pcWriteBuffer, xWriteBufferLen, "Configuration saved to Flash!\r\n"); + } else if (strcasecmp(arg1, "mode") == 0) { if (arg2[0] != '\0') { if (strcasecmp(arg2, "RFUART") == 0) { - mr16.mode = MR16_MODE_RFUART; + mr16.param->mode = MR16_MODE_RFUART; snprintf(pcWriteBuffer, xWriteBufferLen, "mode set to: %s\r\n", arg2); } else if (strcasecmp(arg2, "RC") == 0) { - mr16.mode = MR16_MODE_RC; + mr16.param->mode = MR16_MODE_RC; snprintf(pcWriteBuffer, xWriteBufferLen, "mode set to: %s\r\n", arg2); } else { snprintf(pcWriteBuffer, xWriteBufferLen, "Invalid mode: %s\r\n", arg2); @@ -293,19 +281,17 @@ static BaseType_t mr16CommandHandler( char *pcWriteBuffer, size_t xWriteBufferLe } else if (strcasecmp(arg1, "tx") == 0){ SX1281_SetTX(&radio,mr16.txbuffer,mr16.txbuffer[2]+5); } else if (strcasecmp(arg1, "rx") == 0){ - - - + SX1281_SetRXSuccessive(&radio); } else if (strcasecmp(arg1, "rxid1") == 0) { if (arg2[0] != '\0') { uint16_t rxid; sscanf(arg2, "%hx", &rxid); if(rxid >0x0001 && rxid <0xFFFE){ - mr16.RX_ID[0] = rxid; - snprintf(pcWriteBuffer, xWriteBufferLen, "RXID1 set to: 0x%04X\r\n", mr16.RX_ID[0]); + mr16.param->RX_ID[0] = rxid; + snprintf(pcWriteBuffer, xWriteBufferLen, "RXID1 set to: 0x%04X\r\n", mr16.param->RX_ID[0]); }else{ snprintf(pcWriteBuffer, xWriteBufferLen, "RXID1 set failed: invalid value\r\n"); - snprintf(pcWriteBuffer, xWriteBufferLen, "RXID1 now: 0x%04X\r\n", mr16.RX_ID[0]); + snprintf(pcWriteBuffer, xWriteBufferLen, "RXID1 now: 0x%04X\r\n", mr16.param->RX_ID[0]); } } } @@ -349,7 +335,7 @@ static BaseType_t radioCommandHandler( char *pcWriteBuffer, size_t xWriteBufferL int8_t MR16_CLI_Init() { static const CLI_Command_Definition_t mr16Command = { "mr16", // 命令名 - "mr16 \r\n", // 帮助信息 + "mr16 \r\n", // 帮助信息 mr16CommandHandler, // 处理函数 -1 // 可变参数数量 }; diff --git a/User/module/mr16.h b/User/module/mr16.h index ddc54b3..8ae181a 100644 --- a/User/module/mr16.h +++ b/User/module/mr16.h @@ -60,34 +60,33 @@ typedef struct { uint16_t crc; }MR16_TXBuffer_t; +typedef struct { + SX1281_Params_t radioParams; + MR16_Mode_t mode; + uint16_t TX_ID; + uint16_t RX_ID[3];//最多识别三台设备的信号 +}MR16_Param_t; typedef struct { - enum{ - RadioRoleTX, - RadioRoleRX, - }RadioRole; - - MR16_Mode_t mode; + MR16_Param_t *param; MR16_Data_t *data; - + /* - [0]header1 - [1]header2 + [0]header1(TXID_highbyte) + [1]header2(TXID_lowbyte) [2]datalength(<=122) [...]data [2+datalength+1]crc_highbyte [2+datalength+2]crc_lowbyte */ uint8_t txbuffer[127]; - - uint16_t TX_ID; - uint16_t RX_ID[3];//最多识别三台设备的信号 + uint32_t packetCount[3]; }MR16_t; /* Exported functions prototypes -------------------------------------------- */ -int8_t MR16_Init(MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode); -int8_t MR16_Main(MR16_t mr16, uint8_t data[],uint8_t data_length); +int8_t MR16_Init(MR16_t *mr16,MR16_Param_t *param,MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode); +int8_t MR16_Main(MR16_t *mr16, uint8_t data[],uint8_t data_length); /* USER FUNCTION BEGIN */ /* USER FUNCTION END */ diff --git a/User/task/radio.c b/User/task/radio.c index e16eef8..b34e7b6 100644 --- a/User/task/radio.c +++ b/User/task/radio.c @@ -12,7 +12,7 @@ #include "bsp/flash.h" #include "device/sx1281_driver/radio.h" #include "device/sx1281_driver/sx1281.h" - +#include "module/config.h" #include "module/mr16.h" /* USER INCLUDE END */ @@ -40,7 +40,7 @@ void Task_radio(void *argument) { uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */ /* USER CODE INIT BEGIN */ __HAL_UART_ENABLE_IT(&huart2,UART_IT_IDLE); - MR16_Init(MR16_MODE_RC, RADIOMODE_FLRC); + MR16_Init(&mr16,Config_Get()->mr16,MR16_MODE_RC, RADIOMODE_FLRC); // mr16.RX_ID[0]=0x1234; // BSP_Flash_ReadBytes(0x8000); /* USER CODE INIT END */ @@ -48,7 +48,7 @@ __HAL_UART_ENABLE_IT(&huart2,UART_IT_IDLE); while (1) { tick += delay_tick; /* 计算下一个唤醒时刻 */ /* USER CODE BEGIN */ - MR16_Main(mr16, txdata,sizeof(txdata)); + MR16_Main(&mr16, txdata,sizeof(txdata)); /* USER CODE END */ osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */ }