diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index bb29a1d..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=GBK diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index a9a3a57..4980171 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -87,7 +87,7 @@ /* Software timer definitions. */ #define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY ( 2 ) +#define configTIMER_TASK_PRIORITY ( 3 ) #define configTIMER_QUEUE_LENGTH 10 #define configTIMER_TASK_STACK_DEPTH 1024 diff --git a/dbdb_liquid_path_control_v2.ioc b/dbdb_liquid_path_control_v2.ioc index 8c14390..bfbe262 100644 --- a/dbdb_liquid_path_control_v2.ioc +++ b/dbdb_liquid_path_control_v2.ioc @@ -39,12 +39,13 @@ Dma.USART3_TX.1.Priority=DMA_PRIORITY_LOW Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode FREERTOS.FootprintOK=true FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1 -FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_TIMERS +FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_TIMERS,configTIMER_TASK_PRIORITY FREERTOS.Tasks01=defaultTask,-3,1024,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 FREERTOS.configENABLE_FPU=1 FREERTOS.configMINIMAL_STACK_SIZE=512 FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 +FREERTOS.configTIMER_TASK_PRIORITY=3 FREERTOS.configTOTAL_HEAP_SIZE=30000 FREERTOS.configUSE_COUNTING_SEMAPHORES=1 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 diff --git a/iflytop_canbus_protocol b/iflytop_canbus_protocol index b0a5cf9..fd05c9d 160000 --- a/iflytop_canbus_protocol +++ b/iflytop_canbus_protocol @@ -1 +1 @@ -Subproject commit b0a5cf97b53f265eaaf0e3cf1e0aaa2364d2b358 +Subproject commit fd05c9d4f6c74f29f550399ec3c238eab0295d37 diff --git a/usrc/service/config_service.cpp b/usrc/base/config_service.cpp similarity index 92% rename from usrc/service/config_service.cpp rename to usrc/base/config_service.cpp index 426c51d..fdc178c 100644 --- a/usrc/service/config_service.cpp +++ b/usrc/base/config_service.cpp @@ -1,6 +1,6 @@ #include "config_service.hpp" -#include "project_dep.hpp" +#include "zsdk/zsdk.hpp" static config_t _config; static config_t _default_val_config; @@ -20,7 +20,7 @@ static void create_default_config(config_t *default_cfg) { // void config_init(void) { ZLOGI(TAG, "config_init"); - // flash初始化 + // flash锟斤拷始锟斤拷 _default_val_config.configMark = FLASH_MASK_VAL; _default_val_config.placeHolder = 0; @@ -31,7 +31,7 @@ void config_init(void) { zflash_factory_reset(); } - // 打印配置信息 + // 锟斤拷印锟斤拷锟斤拷锟斤拷息 dump_config(&_config); } config_t *config_get(void) { return &_config; } diff --git a/usrc/service/config_service.hpp b/usrc/base/config_service.hpp similarity index 88% rename from usrc/service/config_service.hpp rename to usrc/base/config_service.hpp index 41ce47d..5473e71 100644 --- a/usrc/service/config_service.hpp +++ b/usrc/base/config_service.hpp @@ -7,7 +7,7 @@ typedef struct { uint32_t configMark; uint32_t placeHolder; - uint32_t checksum; // 不需要编辑 + uint32_t checksum; // } config_t; void config_init(void); diff --git a/usrc/base/device_info.cpp b/usrc/base/device_info.cpp new file mode 100644 index 0000000..fb66dae --- /dev/null +++ b/usrc/base/device_info.cpp @@ -0,0 +1,11 @@ +#include "device_info.hpp" + +#include "iflytop_canbus_protocol/iflytop_canbus_protocol.hpp" + +uint16_t deviceInfo_init() { return 0; } +uint16_t deviceInfo_getBoardId() { return DEVICE_ID; } +uint16_t deviceInfo_getProjectId() { return kdraw_bar_disinfection_box; } +uint16_t deviceInfo_getBoardType() { return kBoardType_LiquidCtrl; } +uint16_t deviceInfo_getProtocolVersion() { return PROTOCOL_VERSION; } +uint16_t deviceInfo_getSoftwareVersion() { return SOFTWARE_VERSION; } +uint16_t deviceInfo_getHardwareVersion() { return HARDWARE_VERSION; } diff --git a/usrc/base/device_info.hpp b/usrc/base/device_info.hpp new file mode 100644 index 0000000..8f7182e --- /dev/null +++ b/usrc/base/device_info.hpp @@ -0,0 +1,20 @@ +#include +#include + +#include "project_configs.h" +#include "base/config_service.hpp" +#include "zsdk/zsdk.hpp" + +// uint16_t boardType; +// uint16_t projectId; +// uint16_t protcol_version; +// uint16_t software_version; +// uint16_t hardware_version; + +uint16_t deviceInfo_init(); +uint16_t deviceInfo_getBoardId(); +uint16_t deviceInfo_getProjectId(); +uint16_t deviceInfo_getBoardType(); +uint16_t deviceInfo_getProtocolVersion(); +uint16_t deviceInfo_getSoftwareVersion(); +uint16_t deviceInfo_getHardwareVersion(); diff --git a/usrc/gpio_mgr.cpp b/usrc/gpio_mgr.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/usrc/gpio_mgr.hpp b/usrc/gpio_mgr.hpp deleted file mode 100644 index eec5a90..0000000 --- a/usrc/gpio_mgr.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once -namespace zwsd { -} // namespace zwsd \ No newline at end of file diff --git a/usrc/main.cpp b/usrc/main.cpp index 342af20..8973378 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -1,7 +1,10 @@ #include #include -#include "service/config_service.hpp" +#include "base/config_service.hpp" +#include "base/device_info.hpp" +#include "protocol_impl/protocol_impl_service.hpp" +#include "zsdk/zcanreceiver/zcanreceiver.hpp" #include "zsdk/zsdk.hpp" #define TAG "main" @@ -32,22 +35,23 @@ void debug_light_ctrl() { } void umain() { - int32_t count = 0; - - ZLOGI(TAG, "%s: %d.%d.%d", PROJECT, VERSION_MAIN(PC_VERSION), VERSION_SUB(PC_VERSION), VERSION_FIX(PC_VERSION)); - ZLOGI(TAG, "sn: %s", sn_get_str()); + m_debugled.initAsOutput(DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false); config_init(); + deviceInfo_init(); - m_debugled.initAsOutput(DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false); + ZLOGI(TAG, "%s ", PROJECT); + ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION); + ZLOGI(TAG, "pversion: %d", deviceInfo_getProtocolVersion()); + ZLOGI(TAG, "sn : %s", sn_get_str()); + ZLOGI(TAG, "boardId : %d", deviceInfo_getBoardId()); - ZLOGI(TAG, "system init done"); + protocol_impl_service_init(); + ZLOGI(TAG, "system init done"); SysMgr::ins()->regTaskId(osThreadGetId()); - SysMgr::ins()->dumpSysInfo(); - while (true) { - osDelay(10); + osDelay(1); debug_light_ctrl(); } } diff --git a/usrc/project_configs.h b/usrc/project_configs.h index a0db516..f223f5c 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,9 +1,4 @@ #pragma once -#define VERSION(main, sub, fix) (main << 16 | sub << 8 | fix << 0) - -#define VERSION_MAIN(version) ((version >> 16) & 0xFF) -#define VERSION_SUB(version) ((version >> 8) & 0xFF) -#define VERSION_FIX(version) ((version >> 0) & 0xFF) /*********************************************************************************************************************** * PROJECT_CONFIG * @@ -13,7 +8,8 @@ * @brief 鍩虹閰嶇疆 * */ -#define PC_VERSION VERSION(1, 0, 0) +#define SOFTWARE_VERSION 1 +#define HARDWARE_VERSION 1 #define PROJECT "dbdb_liquid_path_control" #define SN_HEADER "SN" #define DEVICE_ID (2) diff --git a/usrc/project_dep.hpp b/usrc/project_dep.hpp deleted file mode 100644 index 6c77ac9..0000000 --- a/usrc/project_dep.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "zsdk/zsdk.hpp" \ No newline at end of file diff --git a/usrc/protocol_impl/protocol_impl_service.cpp b/usrc/protocol_impl/protocol_impl_service.cpp new file mode 100644 index 0000000..eca2ca6 --- /dev/null +++ b/usrc/protocol_impl/protocol_impl_service.cpp @@ -0,0 +1,74 @@ +#include "protocol_impl_service.hpp" + +#include "base/device_info.hpp" +#include "zsdk/zcanreceiver/zcanreceiver.hpp" +#define TAG "PROTO" + +/*********************************************************************************************************************** + * FUNCTION_LIST * + ***********************************************************************************************************************/ + +/*********************************************************************************************************************** + * VAR_LIST * + ***********************************************************************************************************************/ + +static osTimerId HeartReportTimerId; +static osThreadId PacketRxThreadId; + +/*********************************************************************************************************************** + * FUNCTION_IMPL * + ***********************************************************************************************************************/ +static void zcanbus_on_rx(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { // + zcanbus_packet_t* packet = (zcanbus_packet_t*)rawpacket; + + if (packet->function_id == kcmd_read_board_info) { + static ack_read_board_info_data_t ack; + ack.boardType = deviceInfo_getBoardType(); + + ack.projectId = deviceInfo_getProjectId(); + ack.protcol_version = deviceInfo_getProtocolVersion(); + ack.software_version = deviceInfo_getSoftwareVersion(); + ack.hardware_version = deviceInfo_getHardwareVersion(); + + zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); + } +} + +static void zcanbus_on_connected(bool connected) { + if (connected) { + ZLOGI(TAG, "connected to host"); + } else { + ZLOGI(TAG, "disconnected from host"); + } +} + +/*********************************************************************************************************************** + * SCHEDULER * + ***********************************************************************************************************************/ +static void onHeartReportTimer(void const* argument) { + static report_heatpacket_data_t heatpacket; + heatpacket.boardType = deviceInfo_getBoardType(); + zcanbus_send_report(kreport_heatpacket, (uint8_t*)&heatpacket, sizeof(heatpacket)); +} +static void onPacketRxThreadStart(void const* argument) { + while (true) { + zcanbus_schedule(); + osDelay(1); + } +} + +/*********************************************************************************************************************** + * EXT * + ***********************************************************************************************************************/ +void protocol_impl_service_init() { // + zcanbus_init(deviceInfo_getBoardId()); + zcanbus_reglistener(zcanbus_on_rx); + zcanbus_reg_on_connected_listener(zcanbus_on_connected); + + osTimerDef(HeartReportTimer, onHeartReportTimer); + HeartReportTimerId = osTimerCreate(osTimer(HeartReportTimer), osTimerPeriodic, NULL); + osTimerStart(HeartReportTimerId, HEART_PACKET_PERIOD_MS); + + osThreadDef(PacketRxThread, onPacketRxThreadStart, osPriorityNormal, 1024, NULL); + PacketRxThreadId = osThreadCreate(osThread(PacketRxThread), NULL); +} diff --git a/usrc/protocol_impl/protocol_impl_service.hpp b/usrc/protocol_impl/protocol_impl_service.hpp new file mode 100644 index 0000000..f892d18 --- /dev/null +++ b/usrc/protocol_impl/protocol_impl_service.hpp @@ -0,0 +1,10 @@ +#include +#include + +#include "base/config_service.hpp" +#include "zsdk/zsdk.hpp" + +void protocol_impl_service_init(); + +// void zcanbus_on_rx(uint8_t from, uint8_t to, uint8_t *packet, size_t len); +// void zcanbus_on_connected(bool connected); \ No newline at end of file diff --git a/zsdk b/zsdk index dd7948a..87de1df 160000 --- a/zsdk +++ b/zsdk @@ -1 +1 @@ -Subproject commit dd7948a6ee79997de985c1d8c3b4afd75bc40947 +Subproject commit 87de1df69a31ca63c98db607ba3851f3e201c857