From a0a430d9fea17afec17a063d7c608648dad603b8 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 16 Nov 2023 20:42:19 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0INA226=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/device/ina226/dev_ina226.cpp | 75 ++++++++++++++++++++++++-------- src/device/ina226/dev_ina226.hpp | 17 +++++++- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/src/device/ina226/dev_ina226.cpp b/src/device/ina226/dev_ina226.cpp index b5e1a9ba..68950fc3 100644 --- a/src/device/ina226/dev_ina226.cpp +++ b/src/device/ina226/dev_ina226.cpp @@ -81,7 +81,16 @@ using namespace Device; static uint8_t i2c_buff[8] = {0}; -Ina226::Ina226(Param& param) : param_(param), info_tp_("ina226_info") { +Ina226::Ina226(Param& param) + : param_(param), + current_offset_("ina226_offset"), + cmd_(this, Cali, "ina226_cali"), + max_current_(param.resistance * 81.92f), + current_lsb_(max_current_ / 32768.0f), + power_lsb_(current_lsb_ * 25), + cali_(static_cast(0.00512f / current_lsb_ / param.resistance * + 1000.0f)), + info_tp_("ina226_info") { bsp_i2c_mem_read(param.i2c, param.device_id, INA226_MANUF_ID, i2c_buff, 2, true); while (strcmp(reinterpret_cast(i2c_buff), "TI") != 0) { @@ -99,29 +108,57 @@ Ina226::Ina226(Param& param) : param_(param), info_tp_("ina226_info") { /* Calibration Register */ *reinterpret_cast(i2c_buff) = - ((param.cali & 0xff) << 8 | (param.cali & 0xff00) >> 8); + ((cali_ & 0xff) << 8 | (cali_ & 0xff00) >> 8); bsp_i2c_mem_write(param.i2c, param.device_id, INA226_CALIB, i2c_buff, 2, true); auto ina_task = [](Ina226* ina) { - bsp_i2c_mem_read(ina->param_.i2c, ina->param_.device_id, INA226_SHUNTV, - i2c_buff, 2, true); - bsp_i2c_mem_read(ina->param_.i2c, ina->param_.device_id, INA226_BUSV, - i2c_buff + 2, 2, true); - bsp_i2c_mem_read(ina->param_.i2c, ina->param_.device_id, INA226_POWER, - i2c_buff + 4, 2, true); - bsp_i2c_mem_read(ina->param_.i2c, ina->param_.device_id, INA226_CURRENT, - i2c_buff + 6, 2, true); - ina->info_.shunt_volt = - static_cast(i2c_buff[0] << 8 | i2c_buff[1]) * 0.0000025f; - ina->info_.bus_volt = - static_cast(i2c_buff[2] << 8 | i2c_buff[3]) * 0.00125f; - ina->info_.current = - static_cast(i2c_buff[6] << 8 | i2c_buff[7]) * 0.000000305f; - ina->info_.power = - static_cast(i2c_buff[4] << 8 | i2c_buff[5]) * 0.025f; + ina->GetData(); ina->info_tp_.Publish(ina->info_); }; + timer_ = System::Timer::Create(ina_task, this, 10); +} + +void Ina226::GetData() { + bsp_i2c_mem_read(param_.i2c, param_.device_id, INA226_SHUNTV, i2c_buff, 2, + true); + bsp_i2c_mem_read(param_.i2c, param_.device_id, INA226_BUSV, i2c_buff + 2, 2, + true); + bsp_i2c_mem_read(param_.i2c, param_.device_id, INA226_POWER, i2c_buff + 4, 2, + true); + bsp_i2c_mem_read(param_.i2c, param_.device_id, INA226_CURRENT, i2c_buff + 6, + 2, true); + info_.shunt_volt = + static_cast(i2c_buff[0] << 8 | i2c_buff[1]) * 0.0000025f; + info_.bus_volt = + static_cast(i2c_buff[2] << 8 | i2c_buff[3]) * 0.00125f; + info_.current = + static_cast(i2c_buff[6] << 8 | i2c_buff[7]) * current_lsb_ - + current_offset_; + info_.power = static_cast(i2c_buff[4] << 8 | i2c_buff[5]) * power_lsb_; +} + +int Ina226::Cali(Ina226* ina, int argc, char** argv) { + XB_UNUSED(argc); + XB_UNUSED(argv); + + printf("Start cali ina226 current\r\n"); + System::Timer::Stop(ina->timer_); + ina->current_offset_.data_ = 0; + + float offset = 0.0f; + + for (int i = 0; i < 100; i++) { + ina->GetData(); + offset += ina->info_.current * 0.01f; + printf("%d/100", i); + System::Thread::Sleep(10); + ms_clear_line(); + } + + ina->current_offset_.Set(offset); + + System::Timer::Start(ina->timer_); - System::Timer::Create(ina_task, this, 10); + return 0; } diff --git a/src/device/ina226/dev_ina226.hpp b/src/device/ina226/dev_ina226.hpp index a1cb7277..dcaacd91 100644 --- a/src/device/ina226/dev_ina226.hpp +++ b/src/device/ina226/dev_ina226.hpp @@ -9,7 +9,7 @@ class Ina226 { typedef struct { uint8_t device_id; bsp_i2c_t i2c; - uint16_t cali; + float resistance; } Param; typedef struct { @@ -21,9 +21,24 @@ class Ina226 { Ina226(Param ¶m); + static int Cali(Ina226 *ina, int argc, char **argv); + + void GetData(); + Param param_; Info info_; + System::Database::Key current_offset_; + + System::Term::Command cmd_; + + float max_current_; + float current_lsb_; + float power_lsb_; + uint32_t cali_; + + System::Timer::TimerHandle timer_; + Message::Topic info_tp_; }; } // namespace Device From 0fbd66d8db0718eadef40cd2e39eb539f0ddf343 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 16 Nov 2023 20:42:31 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=9B=B4=E5=A5=BD=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2835aa85..d1761aa2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -15,7 +15,8 @@ "ms-vscode.hexeditor", "davidanson.vscode-markdownlint", "marus25.cortex-debug", - "xyz.local-history" + "xyz.local-history", + "usernamehw.errorlens" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] From 7a79261b08e1ebd5451af8327f59f04a0552d5e9 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Tue, 28 Nov 2023 23:31:47 +0800 Subject: [PATCH 03/15] Fix canfd --- hw/bsp/atom/drivers/bsp_can.c | 14 +- hw/bsp/dual_canfd/drivers/bsp.c | 2 + hw/bsp/dual_canfd/drivers/bsp_can.c | 22 +- hw/bsp/dual_canfd/drivers/hal/.mxproject | 2 +- .../drivers/hal/Core/Src/stm32g0xx_hal_msp.c | 8 +- hw/bsp/dual_canfd/drivers/hal/Makefile | 2 +- hw/bsp/dual_canfd/drivers/hal/hal.ioc | 10 +- lib/one-message | 2 +- src/device/canfd/dev_canfd.cpp | 11 +- src/device/canfd/dev_canfd.hpp | 2 +- src/module/canfd_imu/mod_canfd_imu.cpp | 2 +- src/module/canfd_to_uart/Kconfig | 0 src/module/canfd_to_uart/info.cmake | 6 + .../canfd_to_uart/mod_canfd_to_uart.cpp | 5 + .../canfd_to_uart/mod_canfd_to_uart.hpp | 189 ++++++++++++++++++ src/robot/canfd_to_uart/robot.hpp | 3 + 16 files changed, 249 insertions(+), 31 deletions(-) create mode 100644 src/module/canfd_to_uart/Kconfig create mode 100644 src/module/canfd_to_uart/info.cmake create mode 100644 src/module/canfd_to_uart/mod_canfd_to_uart.cpp create mode 100644 src/module/canfd_to_uart/mod_canfd_to_uart.hpp diff --git a/hw/bsp/atom/drivers/bsp_can.c b/hw/bsp/atom/drivers/bsp_can.c index dce1ca86..59c737fe 100644 --- a/hw/bsp/atom/drivers/bsp_can.c +++ b/hw/bsp/atom/drivers/bsp_can.c @@ -119,15 +119,17 @@ static const uint8_t DLCtoBytes[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64}; static void can_rx_cb_fn(bsp_can_t can) { - if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { - while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), FDCAN_RX_FIFO0, - &rx_buff[can].header, - rx_buff[can].data) == HAL_OK) { - if (rx_buff[can].header.FDFormat == FDCAN_CLASSIC_CAN) { + while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), FDCAN_RX_FIFO0, + &rx_buff[can].header, + rx_buff[can].data) == HAL_OK) { + if (rx_buff[can].header.FDFormat == FDCAN_CLASSIC_CAN) { + if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { callback_list[can][CAN_RX_MSG_CALLBACK].fn( can, rx_buff[can].header.Identifier, rx_buff[can].data, callback_list[can][CAN_RX_MSG_CALLBACK].arg); - } else { + } + } else { + if (callback_list[can][CANFD_RX_MSG_CALLBACK].fn) { bsp_canfd_data_t data = { .data = rx_buff[can].data, .size = DLCtoBytes[rx_buff[can].header.DataLength >> 16U]}; diff --git a/hw/bsp/dual_canfd/drivers/bsp.c b/hw/bsp/dual_canfd/drivers/bsp.c index bb883ba8..03978474 100644 --- a/hw/bsp/dual_canfd/drivers/bsp.c +++ b/hw/bsp/dual_canfd/drivers/bsp.c @@ -23,4 +23,6 @@ void bsp_init() { MX_LPUART1_UART_Init(); MX_FDCAN1_Init(); MX_FDCAN2_Init(); + + bsp_uart_init(); } diff --git a/hw/bsp/dual_canfd/drivers/bsp_can.c b/hw/bsp/dual_canfd/drivers/bsp_can.c index 511448d9..93b8ff52 100644 --- a/hw/bsp/dual_canfd/drivers/bsp_can.c +++ b/hw/bsp/dual_canfd/drivers/bsp_can.c @@ -44,7 +44,7 @@ static bsp_can_t can_get(FDCAN_HandleTypeDef *hcan) { if (hcan->Instance == FDCAN1) { return BSP_CAN_1; } else if (hcan->Instance == FDCAN2) { - return BSP_CAN_1; + return BSP_CAN_2; } else { return BSP_CAN_ERR; } @@ -106,16 +106,18 @@ void bsp_can_init(void) { static const uint8_t DLCtoBytes[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64}; -static void can_rx_cb_fn(bsp_can_t can) { - if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { - while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), FDCAN_RX_FIFO0, - &rx_buff[can].header, - rx_buff[can].data) == HAL_OK) { - if (rx_buff[can].header.FDFormat == FDCAN_CLASSIC_CAN) { +static void can_rx_cb_fn(bsp_can_t can, uint32_t fifo) { + while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), fifo, + &rx_buff[can].header, + rx_buff[can].data) == HAL_OK) { + if (rx_buff[can].header.FDFormat == FDCAN_CLASSIC_CAN) { + if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { callback_list[can][CAN_RX_MSG_CALLBACK].fn( can, rx_buff[can].header.Identifier, rx_buff[can].data, callback_list[can][CAN_RX_MSG_CALLBACK].arg); - } else { + } + } else { + if (callback_list[can][CANFD_RX_MSG_CALLBACK].fn) { bsp_canfd_data_t data = { .data = rx_buff[can].data, .size = DLCtoBytes[rx_buff[can].header.DataLength >> 16U]}; @@ -130,12 +132,12 @@ static void can_rx_cb_fn(bsp_can_t can) { void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hcan, uint32_t RxFifo0ITs) { (void)RxFifo0ITs; - can_rx_cb_fn(can_get(hcan)); + can_rx_cb_fn(can_get(hcan), FDCAN_RX_FIFO0); } void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hcan, uint32_t RxFifo1ITs) { (void)RxFifo1ITs; - can_rx_cb_fn(can_get(hcan)); + can_rx_cb_fn(can_get(hcan), FDCAN_RX_FIFO1); } bsp_status_t bsp_can_register_callback( diff --git a/hw/bsp/dual_canfd/drivers/hal/.mxproject b/hw/bsp/dual_canfd/drivers/hal/.mxproject index 53f81afd..b09ee427 100644 --- a/hw/bsp/dual_canfd/drivers/hal/.mxproject +++ b/hw/bsp/dual_canfd/drivers/hal/.mxproject @@ -1,5 +1,5 @@ [PreviousLibFiles] -LibFiles=Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_fdcan.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_crs.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_lpuart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_fdcan.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dma.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dmamux.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_fdcan.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_crs.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_lpuart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0b1xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_cm7.h; +LibFiles=Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_fdcan.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_crs.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_lpuart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_fdcan.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dma.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dmamux.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_fdcan.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_crs.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_lpuart.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_uart_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0b1xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_armv81mml.h; [PreviousUsedMakefileFiles] SourceFiles=Core/Src/main.c;Core/Src/stm32g0xx_it.c;Core/Src/stm32g0xx_hal_msp.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;Core/Src/system_stm32g0xx.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;Core/Src/system_stm32g0xx.c;;; diff --git a/hw/bsp/dual_canfd/drivers/hal/Core/Src/stm32g0xx_hal_msp.c b/hw/bsp/dual_canfd/drivers/hal/Core/Src/stm32g0xx_hal_msp.c index 548b0193..934ee1a4 100644 --- a/hw/bsp/dual_canfd/drivers/hal/Core/Src/stm32g0xx_hal_msp.c +++ b/hw/bsp/dual_canfd/drivers/hal/Core/Src/stm32g0xx_hal_msp.c @@ -127,9 +127,9 @@ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* hfdcan) HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /* FDCAN1 interrupt Init */ - HAL_NVIC_SetPriority(TIM16_FDCAN_IT0_IRQn, 0, 0); + HAL_NVIC_SetPriority(TIM16_FDCAN_IT0_IRQn, 1, 0); HAL_NVIC_EnableIRQ(TIM16_FDCAN_IT0_IRQn); - HAL_NVIC_SetPriority(TIM17_FDCAN_IT1_IRQn, 3, 0); + HAL_NVIC_SetPriority(TIM17_FDCAN_IT1_IRQn, 1, 0); HAL_NVIC_EnableIRQ(TIM17_FDCAN_IT1_IRQn); /* USER CODE BEGIN FDCAN1_MspInit 1 */ @@ -170,9 +170,9 @@ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* hfdcan) HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* FDCAN2 interrupt Init */ - HAL_NVIC_SetPriority(TIM16_FDCAN_IT0_IRQn, 0, 0); + HAL_NVIC_SetPriority(TIM16_FDCAN_IT0_IRQn, 1, 0); HAL_NVIC_EnableIRQ(TIM16_FDCAN_IT0_IRQn); - HAL_NVIC_SetPriority(TIM17_FDCAN_IT1_IRQn, 3, 0); + HAL_NVIC_SetPriority(TIM17_FDCAN_IT1_IRQn, 1, 0); HAL_NVIC_EnableIRQ(TIM17_FDCAN_IT1_IRQn); /* USER CODE BEGIN FDCAN2_MspInit 1 */ diff --git a/hw/bsp/dual_canfd/drivers/hal/Makefile b/hw/bsp/dual_canfd/drivers/hal/Makefile index f497146b..63e4b16d 100644 --- a/hw/bsp/dual_canfd/drivers/hal/Makefile +++ b/hw/bsp/dual_canfd/drivers/hal/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Thu Sep 14 23:13:19 CST 2023] +# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Tue Nov 28 23:14:33 CST 2023] ########################################################################################################################## # ------------------------------------------------ diff --git a/hw/bsp/dual_canfd/drivers/hal/hal.ioc b/hw/bsp/dual_canfd/drivers/hal/hal.ioc index 09b3c6bb..5f721d02 100644 --- a/hw/bsp/dual_canfd/drivers/hal/hal.ioc +++ b/hw/bsp/dual_canfd/drivers/hal/hal.ioc @@ -102,8 +102,8 @@ Mcu.PinsNb=10 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32G0B1CBTx -MxCube.Version=6.9.1 -MxDb.Version=DB.6.0.91 +MxCube.Version=6.9.2 +MxDb.Version=DB.6.0.92 NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true NVIC.DMA1_Channel2_3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true NVIC.ForceEnableDMAVector=true @@ -112,9 +112,9 @@ NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:false -NVIC.TIM16_FDCAN_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.TIM17_FDCAN_IT1_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:true -NVIC.USART3_4_5_6_LPUART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.TIM16_FDCAN_IT0_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true +NVIC.TIM17_FDCAN_IT1_IRQn=true\:1\:0\:true\:false\:true\:false\:true\:true +NVIC.USART3_4_5_6_LPUART1_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true PA13.Mode=Serial_Wire PA13.Signal=SYS_SWDIO PA14-BOOT0.Mode=Serial_Wire diff --git a/lib/one-message b/lib/one-message index f6171f1c..e73e9c01 160000 --- a/lib/one-message +++ b/lib/one-message @@ -1 +1 @@ -Subproject commit f6171f1c8cb2686b41ef64114dd4509ce246bd04 +Subproject commit e73e9c0173140b66b8608d32bdf7b8fd044f0a42 diff --git a/src/device/canfd/dev_canfd.cpp b/src/device/canfd/dev_canfd.cpp index 6b3001b7..4ac4b920 100644 --- a/src/device/canfd/dev_canfd.cpp +++ b/src/device/canfd/dev_canfd.cpp @@ -39,7 +39,7 @@ Can::Can() { fd_pack[can].index = id; - memcpy(&fd_pack[can].data, data, sizeof(bsp_canfd_data_t)); + memcpy(&fd_pack[can].info, data, sizeof(bsp_canfd_data_t)); canfd_tp_[can]->Publish(fd_pack[can]); }; @@ -96,3 +96,12 @@ bool Can::Subscribe(Message::Topic& tp, bsp_can_t can, om_member_size_of(Pack, index), index, num); return true; } + +bool Can::SubscribeFD(Message::Topic& tp, bsp_can_t can, + uint32_t index, uint32_t num) { + ASSERT(num > 0); + + canfd_tp_[can]->RangeDivide(tp, sizeof(Pack), offsetof(Pack, index), + om_member_size_of(Pack, index), index, num); + return true; +} diff --git a/src/device/canfd/dev_canfd.hpp b/src/device/canfd/dev_canfd.hpp index 1381313f..116db600 100644 --- a/src/device/canfd/dev_canfd.hpp +++ b/src/device/canfd/dev_canfd.hpp @@ -14,7 +14,7 @@ class Can { typedef struct { uint32_t index; - bsp_canfd_data_t data; + bsp_canfd_data_t info; } FDPack; Can(); diff --git a/src/module/canfd_imu/mod_canfd_imu.cpp b/src/module/canfd_imu/mod_canfd_imu.cpp index 3e42695a..e8ddf3d9 100644 --- a/src/module/canfd_imu/mod_canfd_imu.cpp +++ b/src/module/canfd_imu/mod_canfd_imu.cpp @@ -12,7 +12,7 @@ using namespace Module; CanfdImu::CanfdImu() : data_tp_("canfd_imu"), uart_output_("imu_uart", true), - canfd_output_("imu_canfd", false), + canfd_output_("imu_canfd", true), id_("canfd_imu_id", 0x30), cycle_("canfd_imu_cycle", 10), cmd_(this, SetCMD, "set_imu") { diff --git a/src/module/canfd_to_uart/Kconfig b/src/module/canfd_to_uart/Kconfig new file mode 100644 index 00000000..e69de29b diff --git a/src/module/canfd_to_uart/info.cmake b/src/module/canfd_to_uart/info.cmake new file mode 100644 index 00000000..35463fe0 --- /dev/null +++ b/src/module/canfd_to_uart/info.cmake @@ -0,0 +1,6 @@ +CHECK_SUB_ENABLE(MODULE_ENABLE module) +if(${MODULE_ENABLE}) + file(GLOB CUR_SOURCES "${SUB_DIR}/*.cpp") + SUB_ADD_SRC(CUR_SOURCES) + SUB_ADD_INC(SUB_DIR) +endif() \ No newline at end of file diff --git a/src/module/canfd_to_uart/mod_canfd_to_uart.cpp b/src/module/canfd_to_uart/mod_canfd_to_uart.cpp new file mode 100644 index 00000000..3d5cadaf --- /dev/null +++ b/src/module/canfd_to_uart/mod_canfd_to_uart.cpp @@ -0,0 +1,5 @@ +#include "mod_canfd_to_uart.hpp" + +using namespace Module; + +FDCanToUart* FDCanToUart::self_; diff --git a/src/module/canfd_to_uart/mod_canfd_to_uart.hpp b/src/module/canfd_to_uart/mod_canfd_to_uart.hpp new file mode 100644 index 00000000..171e68c9 --- /dev/null +++ b/src/module/canfd_to_uart/mod_canfd_to_uart.hpp @@ -0,0 +1,189 @@ +#include "bsp_uart.h" +#include "comp_crc8.hpp" +#include "dev_canfd.hpp" +#include "module.hpp" + +namespace Module { +class FDCanToUart { + public: + typedef struct __attribute__((packed)) { + uint8_t prefix; + uint8_t id; + uint32_t index; + uint8_t data_len : 7; + uint8_t fd : 1; + uint8_t crc8; + } UartDataHeader; + FDCanToUart() : uart_received(0), uart_sent(1) { + self_ = this; + + om_fifo_create(&uart_rx_fifo, new uint8_t[256], 256, sizeof(uint8_t)); + + Message::Topic* fd_tp[BSP_CAN_NUM]; + Message::Topic* tp[BSP_CAN_NUM]; + + for (int i = 0; i < BSP_CAN_NUM; i++) { + can_id_[i] = i; + curr_uart_tx_buff[i] = uart_tx_buff[i][0]; + } + + auto uart_tx_cplt_cb = [](void* arg) { + XB_UNUSED(arg); + self_->uart_sent.Post(); + }; + + auto uart_rx_cplt_cb = [](void* arg) { + XB_UNUSED(arg); + om_fifo_writes(&self_->uart_rx_fifo, self_->uart_rx_buff, + bsp_uart_get_count(BSP_UART_MCU)); + + bsp_uart_receive(BSP_UART_MCU, self_->uart_rx_buff, + sizeof(self_->uart_rx_buff), false); + static uint8_t prase_buff[sizeof(UartDataHeader) + 65] = {}; + UartDataHeader* header = reinterpret_cast(&prase_buff); + uint32_t len = om_fifo_readable_item_count(&self_->uart_rx_fifo); + while (len > sizeof(UartDataHeader) + sizeof(uint8_t)) { + om_fifo_peek(&self_->uart_rx_fifo, &header); + len--; + if (header->prefix != 0xa5) { + om_fifo_pop(&self_->uart_rx_fifo); + continue; + } + + om_fifo_reads(&self_->uart_rx_fifo, prase_buff, sizeof(UartDataHeader)); + len -= sizeof(UartDataHeader); + if (!Component::CRC8::Verify(prase_buff, sizeof(UartDataHeader))) { + }; + + if (header->data_len + 1 > len) { + continue; + } + + om_fifo_reads(&self_->uart_rx_fifo, prase_buff + sizeof(UartDataHeader), + header->data_len + 1); + len -= header->data_len + 1; + if (!Component::CRC8::Verify( + prase_buff, sizeof(UartDataHeader) + header->data_len + 1)) { + continue; + } + + static Device::Can::FDPack pack = {}; + pack.info.size = header->data_len; + pack.info.data = prase_buff + sizeof(UartDataHeader); + pack.index = header->index; + + if (header->fd) { + Device::Can::SendFDExtPack( + static_cast(header->id), header->index, + prase_buff + sizeof(UartDataHeader), header->data_len); + } else { + static Device::Can::Pack pack = {}; + memcpy(pack.data, prase_buff + sizeof(UartDataHeader), 8); + pack.index = header->index; + Device::Can::SendExtPack(static_cast(header->id), pack); + } + } + }; + + bsp_uart_register_callback(BSP_UART_MCU, BSP_UART_IDLE_LINE_CB, + uart_rx_cplt_cb, this); + + bsp_uart_register_callback(BSP_UART_MCU, BSP_UART_TX_CPLT_CB, + uart_tx_cplt_cb, this); + + auto canfd_rx_fun = [](Device::Can::FDPack& pack, uint8_t* can) { + if (self_->curr_uart_tx_buff[*can] == self_->uart_tx_buff[*can][0]) { + self_->curr_uart_tx_buff[*can] = self_->uart_tx_buff[*can][1]; + } else { + self_->curr_uart_tx_buff[*can] = self_->uart_tx_buff[*can][0]; + } + + uint8_t* buff = self_->curr_uart_tx_buff[*can]; + UartDataHeader* header = reinterpret_cast(buff); + buff += sizeof(UartDataHeader); + + header->prefix = 0xa5; + header->data_len = pack.info.size; + header->id = *can; + header->index = pack.index; + header->fd = true; + header->crc8 = Component::CRC8::Calculate( + reinterpret_cast(header), + sizeof(UartDataHeader) - sizeof(uint8_t), CRC8_INIT); + memcpy(buff, pack.info.data, pack.info.size); + buff += pack.info.size; + *buff = Component::CRC8::Calculate( + reinterpret_cast(header), + sizeof(UartDataHeader) + pack.info.size, CRC8_INIT); + if (self_->uart_sent.Wait(UINT32_MAX)) { + bsp_uart_transmit( + BSP_UART_MCU, self_->curr_uart_tx_buff[*can], + sizeof(UartDataHeader) + pack.info.size + sizeof(uint8_t), false); + } + return false; + }; + + auto can_rx_fun = [](Device::Can::Pack& pack, uint8_t* can) { + if (self_->curr_uart_tx_buff[*can] == self_->uart_tx_buff[*can][0]) { + self_->curr_uart_tx_buff[*can] = self_->uart_tx_buff[*can][1]; + } else { + self_->curr_uart_tx_buff[*can] = self_->uart_tx_buff[*can][0]; + } + + uint8_t* buff = self_->curr_uart_tx_buff[*can]; + UartDataHeader* header = reinterpret_cast(buff); + buff += sizeof(UartDataHeader); + + header->prefix = 0xa5; + header->data_len = 8; + header->id = *can; + header->index = pack.index; + header->fd = false; + header->crc8 = Component::CRC8::Calculate( + reinterpret_cast(header), + sizeof(UartDataHeader) - sizeof(uint8_t), CRC8_INIT); + memcpy(buff, pack.data, 8); + buff += 8; + *buff = Component::CRC8::Calculate(reinterpret_cast(header), + sizeof(UartDataHeader) + 8, CRC8_INIT); + if (self_->uart_sent.Wait(UINT32_MAX)) { + bsp_uart_transmit(BSP_UART_MCU, buff, + sizeof(UartDataHeader) + 8 + sizeof(uint8_t), false); + } + return false; + }; + + for (int i = 0; i < BSP_CAN_NUM; i++) { + fd_tp[i] = new Message::Topic( + (std::string("trans_canfd") + std::to_string(i)).c_str()); + tp[i] = new Message::Topic( + (std::string("trans_can") + std::to_string(i)).c_str()); + + Device::Can::SubscribeFD(*fd_tp[i], static_cast(i), 0, + UINT32_MAX); + + Device::Can::Subscribe(*tp[i], static_cast(i), 0, UINT32_MAX); + + fd_tp[i]->RegisterCallback(canfd_rx_fun, &can_id_[i]); + tp[i]->RegisterCallback(can_rx_fun, &can_id_[i]); + } + } + + struct __attribute__((packed)) { + UartDataHeader header; + uint8_t buff[65]; + } can_buff_[BSP_CAN_NUM]; + + uint8_t* curr_uart_tx_buff[BSP_CAN_NUM]; + + uint8_t uart_rx_buff[256]; + uint8_t uart_tx_buff[BSP_CAN_NUM][2][256]; + + System::Semaphore uart_received, uart_sent; + om_fifo_t uart_rx_fifo; + + uint8_t can_id_[BSP_CAN_NUM]; + + static FDCanToUart* self_; +}; +} // namespace Module diff --git a/src/robot/canfd_to_uart/robot.hpp b/src/robot/canfd_to_uart/robot.hpp index 47a69880..0d035d2e 100644 --- a/src/robot/canfd_to_uart/robot.hpp +++ b/src/robot/canfd_to_uart/robot.hpp @@ -2,6 +2,8 @@ #include "dev_blink_led.hpp" #include "dev_canfd.hpp" +#include "mod_canfd_to_uart.hpp" + void robot_init(); namespace Robot { @@ -13,6 +15,7 @@ class CanFdToUart { Device::BlinkLED led_; Device::Can can_; + Module::FDCanToUart fdcan_to_uart; CanFdToUart(Param& param) : led_(param.led) {} }; From 7ed7ccea5967d3c8baf779798731597174a2508c Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Wed, 29 Nov 2023 02:00:25 +0800 Subject: [PATCH 04/15] fix dual_canfd config. --- hw/bsp/dual_canfd/config/canfd_to_uart.config | 128 +++++++++--------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/hw/bsp/dual_canfd/config/canfd_to_uart.config b/hw/bsp/dual_canfd/config/canfd_to_uart.config index 77a9285e..c55a3672 100644 --- a/hw/bsp/dual_canfd/config/canfd_to_uart.config +++ b/hw/bsp/dual_canfd/config/canfd_to_uart.config @@ -1,40 +1,43 @@ -CONFIG_auto_generated_config_prefix_board-dual_canfd=y -# CONFIG_auto_generated_config_prefix_board-atom_bl is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-mangopi_r818 is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -# CONFIG_auto_generated_config_prefix_board-atom is not set +# CONFIG_auto_generated_config_prefix_board-rm-c is not set # CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set # CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-rm-c is not set +# CONFIG_auto_generated_config_prefix_board-atom_bl is not set +# CONFIG_auto_generated_config_prefix_board-atom is not set +CONFIG_auto_generated_config_prefix_board-dual_canfd=y # CONFIG_auto_generated_config_prefix_board-microswitch is not set +# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set +# CONFIG_auto_generated_config_prefix_board-MiniPC is not set # CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -# CONFIG_auto_generated_config_prefix_system-Bootloader is not set -# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set +# CONFIG_auto_generated_config_prefix_board-mangopi_r818 is not set +# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set +# CONFIG_auto_generated_config_prefix_board-c-mini is not set +# CONFIG_auto_generated_config_prefix_board-ble_imu is not set +# CONFIG_auto_generated_config_prefix_board-ems is not set CONFIG_auto_generated_config_prefix_system-None=y +# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set +# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set # CONFIG_auto_generated_config_prefix_system-Linux is not set -# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-canfd_imu is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -CONFIG_auto_generated_config_prefix_robot-canfd_to_uart=y +# CONFIG_auto_generated_config_prefix_system-Bootloader is not set # CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set +# CONFIG_auto_generated_config_prefix_robot-engineer is not set # CONFIG_auto_generated_config_prefix_robot-bootloader is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set # CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set # CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set +# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-blink is not set +# CONFIG_auto_generated_config_prefix_robot-sentry is not set +# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set # CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set +# CONFIG_auto_generated_config_prefix_robot-hero is not set +# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set +# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set +# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set +# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set +CONFIG_auto_generated_config_prefix_robot-canfd_to_uart=y +# CONFIG_auto_generated_config_prefix_robot-canfd_imu is not set +# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-ems is not set # # 组件 @@ -43,58 +46,59 @@ CONFIG_auto_generated_config_prefix_robot-canfd_to_uart=y # # 设备 # -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -CONFIG_auto_generated_config_prefix_device-canfd=y -# CONFIG_auto_generated_config_prefix_device-motor is not set +# CONFIG_auto_generated_config_prefix_device-wearlab is not set +# CONFIG_auto_generated_config_prefix_device-icm42688 is not set # CONFIG_auto_generated_config_prefix_device-ahrs-9 is not set -# CONFIG_auto_generated_config_prefix_device-mmc5603 is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set +# CONFIG_auto_generated_config_prefix_device-imu is not set +# CONFIG_auto_generated_config_prefix_device-ahrs is not set +# CONFIG_auto_generated_config_prefix_device-dr16 is not set # CONFIG_auto_generated_config_prefix_device-mech is not set +# CONFIG_auto_generated_config_prefix_device-microswitch is not set +# CONFIG_auto_generated_config_prefix_device-net_config is not set +# CONFIG_auto_generated_config_prefix_device-laser is not set +# CONFIG_auto_generated_config_prefix_device-ina226 is not set +# CONFIG_auto_generated_config_prefix_device-simulator is not set # CONFIG_auto_generated_config_prefix_device-buzzer is not set # CONFIG_auto_generated_config_prefix_device-tof is not set +# CONFIG_auto_generated_config_prefix_device-custom_controller is not set CONFIG_auto_generated_config_prefix_device-blink_led=y -# CONFIG_auto_generated_config_prefix_device-icm42688 is not set -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set +# CONFIG_auto_generated_config_prefix_device-led_rgb is not set +CONFIG_auto_generated_config_prefix_device-canfd=y +# CONFIG_auto_generated_config_prefix_device-motor is not set +# CONFIG_auto_generated_config_prefix_device-cap is not set +# CONFIG_auto_generated_config_prefix_device-can is not set # CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-net_config is not set -# CONFIG_auto_generated_config_prefix_device-wearlab is not set -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set +# CONFIG_auto_generated_config_prefix_device-servo is not set +# CONFIG_auto_generated_config_prefix_device-bmi088 is not set +# CONFIG_auto_generated_config_prefix_device-mmc5603 is not set +# CONFIG_auto_generated_config_prefix_device-referee is not set # end of 设备 # # 模块 # # CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-canfd_imu is not set +# CONFIG_auto_generated_config_prefix_module-uart_update is not set +# CONFIG_auto_generated_config_prefix_module-uart_udp is not set # CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -CONFIG_auto_generated_config_prefix_module-performance=y +# CONFIG_auto_generated_config_prefix_module-balance is not set +# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set # CONFIG_auto_generated_config_prefix_module-uart_udp_client is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set # CONFIG_auto_generated_config_prefix_module-ore_collect is not set +# CONFIG_auto_generated_config_prefix_module-microswitch is not set +# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set # CONFIG_auto_generated_config_prefix_module-can_usart is not set +# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set +# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set +# CONFIG_auto_generated_config_prefix_module-custom_controller is not set +# CONFIG_auto_generated_config_prefix_module-can_imu is not set # CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -CONFIG_auto_generated_config_prefix_module-dual_canfd_to_uart=y -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set +CONFIG_auto_generated_config_prefix_module-performance=y +CONFIG_auto_generated_config_prefix_module-canfd_to_uart=y # CONFIG_auto_generated_config_prefix_module-topic_share_uart is not set -# CONFIG_auto_generated_config_prefix_module-uart_update is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-wl_uart_udp is not set +# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set +# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set +# CONFIG_auto_generated_config_prefix_module-canfd_imu is not set +# CONFIG_auto_generated_config_prefix_module-launcher is not set +# CONFIG_auto_generated_config_prefix_module-ems_ctrl is not set # end of 模块 From 441fd263913507c221cb08840137c0a8a4c591fb Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 30 Nov 2023 03:29:12 +0800 Subject: [PATCH 05/15] update r818 bsp --- hw/bsp/mangopi_r818/config/udp_to_uart.config | 94 -------- .../config/udp_to_uart_client.config | 104 +++++---- hw/bsp/mangopi_r818/drivers/CMakeLists.txt | 4 +- hw/bsp/mangopi_r818/drivers/bsp_can.cpp | 220 ++++++++++++++++++ hw/bsp/mangopi_r818/drivers/bsp_can.h | 55 +++++ hw/bsp/mangopi_r818/drivers/bsp_uart.c | 2 +- 6 files changed, 342 insertions(+), 137 deletions(-) delete mode 100644 hw/bsp/mangopi_r818/config/udp_to_uart.config create mode 100644 hw/bsp/mangopi_r818/drivers/bsp_can.cpp create mode 100644 hw/bsp/mangopi_r818/drivers/bsp_can.h diff --git a/hw/bsp/mangopi_r818/config/udp_to_uart.config b/hw/bsp/mangopi_r818/config/udp_to_uart.config deleted file mode 100644 index 9fdb06bf..00000000 --- a/hw/bsp/mangopi_r818/config/udp_to_uart.config +++ /dev/null @@ -1,94 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -CONFIG_auto_generated_config_prefix_board-mangopi_r818=y -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_board-wl_f103_can is not set -# CONFIG_auto_generated_config_prefix_board-demo-board is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set -# CONFIG_auto_generated_config_prefix_system-None is not set -CONFIG_auto_generated_config_prefix_system-Linux=y -CONFIG_INIT_TASK_STACK_DEPTH=0 - -# -# Linux -# -CONFIG_TERM_LOG_UDP_SERVER=y -CONFIG_TERM_LOG_UDP_SERVER_PORT=1230 -# end of Linux - -CONFIG_auto_generated_config_prefix_robot-udp_to_uart=y -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set -# CONFIG_auto_generated_config_prefix_robot-demo-robot is not set - -# -# 组件 -# -# CONFIG_auto_generated_config_prefix_component-demo-component is not set -# end of 组件 - -# -# 设备 -# -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -# CONFIG_auto_generated_config_prefix_device-motor is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set -CONFIG_auto_generated_config_prefix_device-net_config=y -CONFIG_auto_generated_config_prefix_device-wearlab=y -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -# CONFIG_auto_generated_config_prefix_device-demo-device is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -CONFIG_auto_generated_config_prefix_module-uart_udp=y -CONFIG_auto_generated_config_prefix_module-topic_share_uart=y -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-wl_can_usart is not set -# CONFIG_auto_generated_config_prefix_module-demo-module is not set -# end of 模块 diff --git a/hw/bsp/mangopi_r818/config/udp_to_uart_client.config b/hw/bsp/mangopi_r818/config/udp_to_uart_client.config index 2d4819cb..83a7055d 100644 --- a/hw/bsp/mangopi_r818/config/udp_to_uart_client.config +++ b/hw/bsp/mangopi_r818/config/udp_to_uart_client.config @@ -1,17 +1,23 @@ -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set +# CONFIG_auto_generated_config_prefix_board-rm-c is not set +# CONFIG_auto_generated_config_prefix_board-node_imu is not set +# CONFIG_auto_generated_config_prefix_board-f103_can is not set +# CONFIG_auto_generated_config_prefix_board-atom_bl is not set +# CONFIG_auto_generated_config_prefix_board-atom is not set +# CONFIG_auto_generated_config_prefix_board-dual_canfd is not set # CONFIG_auto_generated_config_prefix_board-microswitch is not set # CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set +# CONFIG_auto_generated_config_prefix_board-MiniPC is not set +# CONFIG_auto_generated_config_prefix_board-Webots is not set CONFIG_auto_generated_config_prefix_board-mangopi_r818=y -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set -CONFIG_auto_generated_config_prefix_system-Linux=y +# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set +# CONFIG_auto_generated_config_prefix_board-c-mini is not set +# CONFIG_auto_generated_config_prefix_board-ble_imu is not set +# CONFIG_auto_generated_config_prefix_board-ems is not set # CONFIG_auto_generated_config_prefix_system-None is not set +# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set # CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set +CONFIG_auto_generated_config_prefix_system-Linux=y +# CONFIG_auto_generated_config_prefix_system-Bootloader is not set CONFIG_INIT_TASK_STACK_DEPTH=0 # @@ -21,21 +27,26 @@ CONFIG_TERM_LOG_UDP_SERVER=y CONFIG_TERM_LOG_UDP_SERVER_PORT=1230 # end of Linux -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-dart is not set +# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set # CONFIG_auto_generated_config_prefix_robot-engineer is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set +# CONFIG_auto_generated_config_prefix_robot-bootloader is not set +# CONFIG_auto_generated_config_prefix_robot-infantry is not set # CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set -# CONFIG_auto_generated_config_prefix_robot-dart is not set +# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-blink is not set # CONFIG_auto_generated_config_prefix_robot-sentry is not set +# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set +# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set +# CONFIG_auto_generated_config_prefix_robot-hero is not set +# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set +# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set +# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set # CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set +# CONFIG_auto_generated_config_prefix_robot-canfd_to_uart is not set +# CONFIG_auto_generated_config_prefix_robot-canfd_imu is not set CONFIG_auto_generated_config_prefix_robot-udp_to_uart=y -# CONFIG_auto_generated_config_prefix_robot-infantry is not set +# CONFIG_auto_generated_config_prefix_robot-ems is not set # # 组件 @@ -44,47 +55,58 @@ CONFIG_auto_generated_config_prefix_robot-udp_to_uart=y # # 设备 # +CONFIG_auto_generated_config_prefix_device-wearlab=y +# CONFIG_auto_generated_config_prefix_device-icm42688 is not set +# CONFIG_auto_generated_config_prefix_device-ahrs-9 is not set # CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set # CONFIG_auto_generated_config_prefix_device-ahrs is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y +# CONFIG_auto_generated_config_prefix_device-dr16 is not set # CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set # CONFIG_auto_generated_config_prefix_device-microswitch is not set -# CONFIG_auto_generated_config_prefix_device-can is not set CONFIG_auto_generated_config_prefix_device-net_config=y -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set +# CONFIG_auto_generated_config_prefix_device-laser is not set +# CONFIG_auto_generated_config_prefix_device-ina226 is not set # CONFIG_auto_generated_config_prefix_device-simulator is not set -CONFIG_auto_generated_config_prefix_device-wearlab=y # CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-motor is not set # CONFIG_auto_generated_config_prefix_device-tof is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set +# CONFIG_auto_generated_config_prefix_device-custom_controller is not set +CONFIG_auto_generated_config_prefix_device-blink_led=y +# CONFIG_auto_generated_config_prefix_device-led_rgb is not set +CONFIG_auto_generated_config_prefix_device-canfd=y +# CONFIG_auto_generated_config_prefix_device-motor is not set +# CONFIG_auto_generated_config_prefix_device-cap is not set +# CONFIG_auto_generated_config_prefix_device-can is not set +# CONFIG_auto_generated_config_prefix_device-ai is not set # CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set +# CONFIG_auto_generated_config_prefix_device-bmi088 is not set +# CONFIG_auto_generated_config_prefix_device-mmc5603 is not set +# CONFIG_auto_generated_config_prefix_device-referee is not set # end of 设备 # # 模块 # -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set # CONFIG_auto_generated_config_prefix_module-gimbal is not set +# CONFIG_auto_generated_config_prefix_module-uart_update is not set +# CONFIG_auto_generated_config_prefix_module-chassis is not set # CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set +# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set +CONFIG_auto_generated_config_prefix_module-uart_udp_client=y +# CONFIG_auto_generated_config_prefix_module-ore_collect is not set # CONFIG_auto_generated_config_prefix_module-microswitch is not set -CONFIG_auto_generated_config_prefix_module-topic_share_uart=y # CONFIG_auto_generated_config_prefix_module-wheel_leg is not set # CONFIG_auto_generated_config_prefix_module-can_usart is not set +# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set # CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -CONFIG_auto_generated_config_prefix_module-uart_udp_client=y -CONFIG_UART_TO_UDP_UDP_CLIENT_IP="192.168.1.1" -CONFIG_UART_TO_UDP_UDP_CLIENT_PORT=1234 +# CONFIG_auto_generated_config_prefix_module-custom_controller is not set # CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-wl_uart_udp is not set +# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set +# CONFIG_auto_generated_config_prefix_module-performance is not set +# CONFIG_auto_generated_config_prefix_module-canfd_to_uart is not set +CONFIG_auto_generated_config_prefix_module-topic_share_uart=y +# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set +# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set +# CONFIG_auto_generated_config_prefix_module-canfd_imu is not set +# CONFIG_auto_generated_config_prefix_module-launcher is not set +# CONFIG_auto_generated_config_prefix_module-ems_ctrl is not set # end of 模块 diff --git a/hw/bsp/mangopi_r818/drivers/CMakeLists.txt b/hw/bsp/mangopi_r818/drivers/CMakeLists.txt index 285747e0..206f33ba 100644 --- a/hw/bsp/mangopi_r818/drivers/CMakeLists.txt +++ b/hw/bsp/mangopi_r818/drivers/CMakeLists.txt @@ -4,7 +4,9 @@ file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c") add_library(${PROJECT_NAME} STATIC) -target_sources(${PROJECT_NAME} PRIVATE ${${PROJECT_NAME}_SOURCES}) +target_sources(${PROJECT_NAME} + PRIVATE ${${PROJECT_NAME}_SOURCES} + PRIVATE bsp_can.cpp) include(${MCU_DIR}/linux/driver/CMakeLists.txt) diff --git a/hw/bsp/mangopi_r818/drivers/bsp_can.cpp b/hw/bsp/mangopi_r818/drivers/bsp_can.cpp new file mode 100644 index 00000000..a164ebfe --- /dev/null +++ b/hw/bsp/mangopi_r818/drivers/bsp_can.cpp @@ -0,0 +1,220 @@ +#include "bsp_can.h" + +#include + +#include + +#include "bsp_def.h" +#include "bsp_uart.h" + +#define CRC8_INIT 0Xff + +typedef struct __attribute__((packed)) { + uint8_t prefix; + uint8_t id; + uint32_t index; + uint8_t data_len : 7; + uint8_t fd : 1; + uint8_t crc8; +} UartDataHeader; + +enum { BSP_CAN_UART1, BSP_CAN_UART2, BSP_CAN_UART_NUM }; + +typedef struct { + void (*fn)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg); + void *arg; +} can_callback_t; + +static const std::array CRC8_TAB = { + 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, + 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, + 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, + 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, + 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, + 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, + 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, + 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, + 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, + 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, + 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, + 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, + 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, + 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, + 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, + 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, + 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, + 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, + 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, + 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, + 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, + 0xd7, 0x89, 0x6b, 0x35}; + +uint8_t calculate(const uint8_t *buf, size_t len, uint8_t crc) { + /* loop over the buffer data */ + while (len-- > 0) { + crc = CRC8_TAB[(crc ^ *buf++) & 0xff]; + } + return crc; +} + +bool verify(const uint8_t *buf, size_t len) { + if (len < 2) { + return false; + } + + uint8_t expected = calculate(buf, len - sizeof(uint8_t), CRC8_INIT); + return expected == buf[len - sizeof(uint8_t)]; +} + +static can_callback_t callback_list[BSP_CAN_NUM][BSP_CAN_CB_NUM]; + +static uint8_t uart_rx_buff[64][BSP_CAN_UART_NUM]; + +static uint8_t uart_tx_buff[128][BSP_CAN_UART_NUM]; + +static pthread_mutex_t tx_mutex[BSP_CAN_UART_NUM] = {PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER}; + +inline bsp_can_t bsp_can_get(bsp_uart_t uart, uint8_t id) { + return static_cast(uart * 2 + id); +} + +inline bsp_uart_t bsp_can_get_uart(bsp_can_t can) { + if (can < BSP_CAN_2) { + return BSP_UART_1; + } else { + return BSP_UART_2; + } +} + +inline uint8_t bsp_can_get_id(bsp_can_t can) { return can % 2; } + +void bsp_can_init(void) { + auto uart_rx_thread_fn = [](void *arg) { + bsp_uart_t uart = *static_cast(arg); + + while (true) { + auto index = uart_rx_buff[uart]; + memset(uart_rx_buff[uart], 0, sizeof(uart_rx_buff[uart])); + do { + bsp_uart_receive(uart, uart_rx_buff[uart], sizeof(uint8_t), true); + } while (*uart_rx_buff[uart] != 0xa5); + + index++; + + bsp_uart_receive(uart, index, sizeof(UartDataHeader) - 1, true); + index += sizeof(UartDataHeader) - 1; + + if (!verify(uart_rx_buff[uart], sizeof(UartDataHeader))) { + continue; + } + + auto header = reinterpret_cast(uart_rx_buff[uart]); + + bsp_uart_receive(uart, index, header->data_len + 1, true); + + if (!verify(uart_rx_buff[uart], + sizeof(UartDataHeader) + header->data_len + 1)) { + continue; + } + + if (header->fd) { + if (callback_list[bsp_can_get(uart, header->id)][CANFD_RX_MSG_CALLBACK] + .fn) { + bsp_canfd_data_t data = {.size = header->data_len, .data = index}; + callback_list[bsp_can_get(uart, header->id)][CANFD_RX_MSG_CALLBACK] + .fn(bsp_can_get(uart, header->id), header->index, + reinterpret_cast(&data), + callback_list[bsp_can_get(uart, header->id)] + [CANFD_RX_MSG_CALLBACK] + .arg); + } else { + if (callback_list[bsp_can_get(uart, header->id)][CAN_RX_MSG_CALLBACK] + .fn) { + callback_list[bsp_can_get(uart, header->id)][CAN_RX_MSG_CALLBACK] + .fn(bsp_can_get(uart, header->id), header->index, index, + callback_list[bsp_can_get(uart, header->id)] + [CAN_RX_MSG_CALLBACK] + .arg); + } + } + } + } + + return static_cast(0); + }; + static bsp_uart_t uart[BSP_CAN_UART_NUM]; + static pthread_t thread[BSP_CAN_UART_NUM]; + + for (int i = 0; i < BSP_CAN_UART_NUM; i++) { + uart[i] = static_cast(i); + pthread_create(&thread[i], NULL, uart_rx_thread_fn, &uart[i]); + } +} + +bsp_status_t bsp_can_register_callback( + bsp_can_t can, bsp_can_callback_t type, + void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), + void *callback_arg) { + XB_ASSERT(callback); + XB_ASSERT(type != BSP_CAN_CB_NUM); + + callback_list[can][type].fn = callback; + callback_list[can][type].arg = callback_arg; + return BSP_OK; +}; + +bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, + uint32_t id, uint8_t *data) { + if (format == CAN_FORMAT_STD) { + XB_ASSERT(false); + } + + auto uart = bsp_can_get_uart(can); + + pthread_mutex_lock(&tx_mutex[uart]); + auto header = reinterpret_cast(uart_tx_buff[uart]); + header->prefix = 0xa5; + header->id = bsp_can_get_id(can); + header->data_len = 8; + header->fd = false; + header->index = id; + header->crc8 = calculate(reinterpret_cast(header), + sizeof(UartDataHeader) - 1, CRC8_INIT); + memcpy(uart_tx_buff[uart] + sizeof(UartDataHeader), data, 8); + *(uart_tx_buff[uart] + sizeof(UartDataHeader) + 8) = + calculate(uart_tx_buff[uart], sizeof(UartDataHeader) + 8, CRC8_INIT); + bsp_uart_transmit(uart, uart_tx_buff[uart], sizeof(UartDataHeader) + 9, true); + pthread_mutex_unlock(&tx_mutex[uart]); + return BSP_OK; +} + +bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, + uint32_t id, uint8_t *data, size_t size) { + if (format == CAN_FORMAT_STD) { + XB_ASSERT(false); + } + + if (size > 64) { + XB_ASSERT(false); + } + + auto uart = bsp_can_get_uart(can); + + pthread_mutex_lock(&tx_mutex[uart]); + auto header = reinterpret_cast(uart_tx_buff[uart]); + header->prefix = 0xa5; + header->id = bsp_can_get_id(can); + header->data_len = size; + header->fd = true; + header->index = id; + header->crc8 = calculate(reinterpret_cast(header), + sizeof(UartDataHeader) - 1, CRC8_INIT); + memcpy(uart_tx_buff[uart] + sizeof(UartDataHeader), data, size); + *(uart_tx_buff[uart] + sizeof(UartDataHeader) + size) = + calculate(uart_tx_buff[uart], sizeof(UartDataHeader) + size, CRC8_INIT); + bsp_uart_transmit(uart, uart_tx_buff[uart], sizeof(UartDataHeader) + size + 1, + true); + pthread_mutex_unlock(&tx_mutex[uart]); + return BSP_OK; +} diff --git a/hw/bsp/mangopi_r818/drivers/bsp_can.h b/hw/bsp/mangopi_r818/drivers/bsp_can.h new file mode 100644 index 00000000..46c32f44 --- /dev/null +++ b/hw/bsp/mangopi_r818/drivers/bsp_can.h @@ -0,0 +1,55 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bsp.h" + +typedef enum { + BSP_CAN_1, + BSP_CAN_2, + BSP_CAN_3, + BSP_CAN_4, + BSP_CAN_NUM, + BSP_CAN_ERR, +} bsp_can_t; + +typedef enum { + CAN_RX_MSG_CALLBACK, + CAN_TX_CPLT_CALLBACK, + CANFD_RX_MSG_CALLBACK, + CANFD_TX_CPLT_CALLBACK, + BSP_CAN_CB_NUM +} bsp_can_callback_t; + +typedef enum { + CAN_FORMAT_STD, + CAN_FORMAT_EXT, +} bsp_can_format_t; + +typedef struct { + uint8_t data[8]; +} bsp_can_data_t; + +typedef struct { + size_t size; + uint8_t *data; +} bsp_canfd_data_t; + +void bsp_can_init(void); +bsp_status_t bsp_can_register_callback( + bsp_can_t can, bsp_can_callback_t type, + void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), + void *callback_arg); +bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, + uint32_t id, uint8_t *data); + +bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, + uint32_t id, uint8_t *data, size_t size); + +bsp_status_t bsp_can_get_msg(bsp_can_t can, uint8_t *data, uint32_t *index); + +#ifdef __cplusplus +} +#endif diff --git a/hw/bsp/mangopi_r818/drivers/bsp_uart.c b/hw/bsp/mangopi_r818/drivers/bsp_uart.c index 7d30bbcc..7ade3130 100644 --- a/hw/bsp/mangopi_r818/drivers/bsp_uart.c +++ b/hw/bsp/mangopi_r818/drivers/bsp_uart.c @@ -21,7 +21,7 @@ static int rx_count[BSP_UART_NUM]; static bool uart_block[BSP_UART_NUM]; -static const char *uart_dev_path[] = {"/dev/ttyCH343USB0", "/dev/ttyCH343USB1", +static const char *uart_dev_path[] = {"/dev/ttyACM0", "/dev/ttyACM1", "/dev/ttyS4"}; static const uint32_t UART_SPEED[] = {9000000, 9000000, 115200}; From a78220673341736a86a01cb6f72e0fc29755573d Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 30 Nov 2023 03:29:39 +0800 Subject: [PATCH 06/15] update wearlab protocol --- src/device/wearlab/wearlab.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/device/wearlab/wearlab.hpp b/src/device/wearlab/wearlab.hpp index 753a5072..7e1153fb 100644 --- a/src/device/wearlab/wearlab.hpp +++ b/src/device/wearlab/wearlab.hpp @@ -10,16 +10,6 @@ class WearLab { uint8_t end; } UartData; - typedef struct __attribute__((packed)) { - uint32_t time; - uint8_t device_id : 6; //设备ID - uint8_t area_id; //区域ID - uint16_t device_type : 12; //设备类型 - uint8_t data_type : 6; //数据类型 - - uint8_t data[8]; //数据 - } UdpData; - typedef union { struct __attribute__((packed)) { uint32_t device_type : 12; @@ -31,6 +21,17 @@ class WearLab { uint32_t raw; } CanHeader; + typedef struct __attribute__((packed)) { + uint8_t prefix; + uint32_t time; + uint8_t area_id; //区域ID + + CanHeader can_header; + + uint8_t data_len : 7; + uint8_t fd : 1; + } UdpDataHeader; + typedef struct __attribute__((packed)) { double data1; } CanData1; From c4b2a82faf079447b2e37312d77f1c41d8f89eb4 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 30 Nov 2023 03:32:30 +0800 Subject: [PATCH 07/15] rewrite udp<->uart --- src/module/uart_udp/Kconfig | 0 src/module/uart_udp/info.cmake | 6 - src/module/uart_udp/mod_uart_udp.cpp | 3 - src/module/uart_udp/mod_uart_udp.hpp | 193 -------------- src/module/uart_udp_client/mod_uart_udp.cpp | 2 + src/module/uart_udp_client/mod_uart_udp.hpp | 282 ++++++++------------ src/robot/udp_to_uart/robot.cpp | 6 - src/robot/udp_to_uart/robot.hpp | 8 +- 8 files changed, 120 insertions(+), 380 deletions(-) delete mode 100644 src/module/uart_udp/Kconfig delete mode 100644 src/module/uart_udp/info.cmake delete mode 100644 src/module/uart_udp/mod_uart_udp.cpp delete mode 100644 src/module/uart_udp/mod_uart_udp.hpp diff --git a/src/module/uart_udp/Kconfig b/src/module/uart_udp/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/src/module/uart_udp/info.cmake b/src/module/uart_udp/info.cmake deleted file mode 100644 index 35463fe0..00000000 --- a/src/module/uart_udp/info.cmake +++ /dev/null @@ -1,6 +0,0 @@ -CHECK_SUB_ENABLE(MODULE_ENABLE module) -if(${MODULE_ENABLE}) - file(GLOB CUR_SOURCES "${SUB_DIR}/*.cpp") - SUB_ADD_SRC(CUR_SOURCES) - SUB_ADD_INC(SUB_DIR) -endif() \ No newline at end of file diff --git a/src/module/uart_udp/mod_uart_udp.cpp b/src/module/uart_udp/mod_uart_udp.cpp deleted file mode 100644 index 89ed8d6a..00000000 --- a/src/module/uart_udp/mod_uart_udp.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "mod_uart_udp.hpp" - -using namespace Module; diff --git a/src/module/uart_udp/mod_uart_udp.hpp b/src/module/uart_udp/mod_uart_udp.hpp deleted file mode 100644 index 53631576..00000000 --- a/src/module/uart_udp/mod_uart_udp.hpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "bsp_time.h" -#include "bsp_uart.h" -#include "bsp_udp_server.h" -#include "module.hpp" -#include "wearlab.hpp" - -namespace Module { -class UartToUDP { - public: - typedef struct { - int port; - bsp_uart_t start_uart; - bsp_uart_t end_uart; - } Param; - - UartToUDP(Param& param) - : param_(param), udp_trans_buff(128), num_lock_(true), udp_tx_sem_(0) { - for (int i = param.start_uart; i <= param_.end_uart; i++) { - udp_rx_sem_[i] = new System::Semaphore(false); - count[i] = 0; - last_log_time[i] = 0; - } - - bsp_udp_server_init(&udp_server_, param.port); - - auto udp_rx_cb = [](void* arg, void* buff, uint32_t size) { - UartToUDP* udp = static_cast(arg); - if (size == sizeof(Device::WearLab::UdpData)) { - Device::WearLab::UdpData* data = - static_cast(buff); - - memcpy(&udp->udp_rx_[data->area_id], data, - sizeof(Device::WearLab::UdpData)); - udp->udp_rx_sem_[data->area_id]->Post(); - OMLOG_PASS("udp pack received."); - return; - } - - OMLOG_ERROR("udp receive pack error. len:%d", size); - }; - - bsp_udp_server_register_callback(&udp_server_, BSP_UDP_RX_CPLT_CB, - udp_rx_cb, this); - - auto uart_rx_thread_fn = [](UartToUDP* uart_udp) { - uart_udp->num_lock_.Wait(UINT32_MAX); - bsp_uart_t uart = static_cast(uart_udp->num_); - uart_udp->num_++; - uart_udp->num_lock_.Post(); - - uint8_t prefix = 0; - - while (true) { - do { - bsp_uart_receive(uart, &prefix, sizeof(prefix), true); - } while (prefix != 0xa5); - - prefix = 0; - - bsp_uart_receive(uart, - reinterpret_cast(&uart_udp->uart_rx_[uart]), - sizeof(uart_udp->uart_rx_[uart]), true); - if (uart_udp->uart_rx_[uart].end != 0xe3) { - bsp_uart_abort_receive(uart); - OMLOG_ERROR("uart %d receive data error. end:%d", uart, - uart_udp->uart_rx_[uart].end); - continue; - } else { - uart_udp->header_[uart].raw = uart_udp->uart_rx_[uart].id; - uart_udp->udp_tx_[uart].time = bsp_time_get_ms(); - uart_udp->udp_tx_[uart].device_id = - uart_udp->header_[uart].data.device_id; - uart_udp->udp_tx_[uart].area_id = uart; - uart_udp->udp_tx_[uart].device_type = - uart_udp->header_[uart].data.device_type; - uart_udp->udp_tx_[uart].data_type = - uart_udp->header_[uart].data.data_type; - memcpy(uart_udp->udp_tx_[uart].data, uart_udp->uart_rx_[uart].data, - 8); - uart_udp->count[uart]++; - - if (uart_udp->udp_tx_[uart].time - uart_udp->last_log_time[uart] > - 1000) { - while (uart_udp->udp_tx_[uart].time - - uart_udp->last_log_time[uart] > - 1000) { - uart_udp->last_log_time[uart] += 1000; - } - OMLOG_NOTICE("uart %d get count %d at 1s", uart, - uart_udp->count[uart]); - uart_udp->count[uart] = 0; - } - - uart_udp->udp_trans_buff.Send(uart_udp->udp_tx_[uart]); - uart_udp->udp_tx_sem_.Post(); - } - } - }; - - auto uart_tx_thread_fn = [](UartToUDP* uart_udp) { - bsp_uart_t uart = static_cast(uart_udp->num_); - - while (true) { - uart_udp->udp_rx_sem_[uart]->Wait(UINT32_MAX); - uart_udp->uart_tx_[uart].id = uart_udp->udp_rx_[uart].device_id; - memcpy(uart_udp->uart_tx_[uart].data, uart_udp->udp_rx_[uart].data, 8); - bsp_uart_transmit(uart, - reinterpret_cast(&uart_udp->uart_tx_[uart]), - sizeof(uart_udp->uart_tx_[uart]), true); - } - }; - - auto udp_rx_thread_fn = [](UartToUDP* uart_udp) { - bsp_udp_server_start(&uart_udp->udp_server_); - while (true) { - System::Thread::Sleep(UINT32_MAX); - } - }; - - auto udp_tx_thread_fn = [](UartToUDP* uart_udp) { - std::array trans_buff; - uint32_t buff_num = 0; - - while (true) { - uart_udp->udp_tx_sem_.Wait(UINT32_MAX); - buff_num = uart_udp->udp_tx_sem_.Value() + 1; - - uart_udp->udp_trans_buff.Receive(trans_buff[0]); - - for (uint32_t i = 1; i < buff_num; i++) { - uart_udp->udp_tx_sem_.Wait(UINT32_MAX); - uart_udp->udp_trans_buff.Receive(trans_buff[i]); - } - - bsp_udp_server_transmit(&uart_udp->udp_server_, - reinterpret_cast(&trans_buff), - sizeof(trans_buff[0]) * buff_num); - } - }; - - for (int i = param_.start_uart; i <= param_.end_uart; i++) { - uart_tx_thread_[i].Create( - uart_tx_thread_fn, this, - (std::string("uart_to_udp_tx_") + std::to_string(i)).c_str(), 512, - System::Thread::HIGH); - } - - udp_rx_thread_.Create(udp_rx_thread_fn, this, "udp_rx_thread", 512, - System::Thread::HIGH); - - udp_tx_thread_.Create(udp_tx_thread_fn, this, "udp_tx_thread", 512, - System::Thread::HIGH); - - System::Thread::Sleep(100); - - for (int i = param_.start_uart; i <= param_.end_uart; i++) { - uart_rx_thread_[i].Create( - uart_rx_thread_fn, this, - (std::string("uart_to_udp_rx_") + std::to_string(i)).c_str(), 512, - System::Thread::HIGH); - } - } - - Param param_; - - std::array uart_rx_{}; - std::array uart_tx_{}; - std::array udp_rx_{}; - std::array udp_tx_{}; - std::array header_{}; - std::array uart_rx_thread_; - std::array uart_tx_thread_; - - std::array udp_rx_sem_{}; - - System::Queue udp_trans_buff; - - System::Semaphore num_lock_; - int num_ = 0; - - System::Thread udp_rx_thread_; - - System::Thread udp_tx_thread_; - - System::Semaphore udp_tx_sem_; - - bsp_udp_server_t udp_server_{}; - - std::array count{}; - - std::array last_log_time{}; -}; -} // namespace Module diff --git a/src/module/uart_udp_client/mod_uart_udp.cpp b/src/module/uart_udp_client/mod_uart_udp.cpp index 89ed8d6a..61f6cb10 100644 --- a/src/module/uart_udp_client/mod_uart_udp.cpp +++ b/src/module/uart_udp_client/mod_uart_udp.cpp @@ -1,3 +1,5 @@ #include "mod_uart_udp.hpp" using namespace Module; + +UartToUDP* UartToUDP::self_; diff --git a/src/module/uart_udp_client/mod_uart_udp.hpp b/src/module/uart_udp_client/mod_uart_udp.hpp index 95f81a8d..4b9c70d9 100644 --- a/src/module/uart_udp_client/mod_uart_udp.hpp +++ b/src/module/uart_udp_client/mod_uart_udp.hpp @@ -3,50 +3,18 @@ #include "bsp_dns_client.h" #include "bsp_time.h" -#include "bsp_uart.h" #include "bsp_udp_client.h" +#include "comp_crc8.hpp" +#include "dev_canfd.hpp" #include "udp_param.h" #include "wearlab.hpp" namespace Module { class UartToUDP { public: - typedef struct { - uint32_t id; - int port; - bsp_uart_t start_uart; - bsp_uart_t end_uart; - } Param; - - typedef struct __attribute__((packed)) { - Device::WearLab::CanHeader id; - Component::Type::Quaternion quat_; - Component::Type::Vector3 gyro_; - Component::Type::Vector3 accl_; - uint16_t res; - } Data; - - typedef struct __attribute__((packed)) { - uint32_t time; - Data data; - } TimedData; - - UartToUDP(Param& param) - : param_(param), - wl_imu_data_("wl_imu_data"), - udp_trans_buff(128), - num_lock_(true), - udp_tx_sem_(0) { - for (int i = param.start_uart; i <= param_.end_uart; i++) { - udp_rx_sem_[i] = new System::Semaphore(false); - count[i] = 0; - last_log_time[i] = 0; - } - - for (auto& buff : wl_remote_) { - buff = new Message::Remote(512, 10); - buff->AddTopic("wl_imu_data"); - } + UartToUDP() { + self_ = this; + om_fifo_create(&udp_tx_fifo_, new uint8_t[512], 512, sizeof(uint8_t)); bsp_dns_addr_t addrs; while (true) { @@ -66,85 +34,37 @@ class UartToUDP { reinterpret_cast(&addrs)); auto udp_rx_cb = [](void* arg, void* buff, uint32_t size) { - UartToUDP* udp = static_cast(arg); - if (size == sizeof(Device::WearLab::UdpData)) { - Device::WearLab::UdpData* data = - static_cast(buff); - - memcpy(&udp->udp_rx_[data->area_id], data, - sizeof(Device::WearLab::UdpData)); - udp->udp_rx_sem_[data->area_id]->Post(); - OMLOG_PASS("udp pack received."); + XB_UNUSED(arg); + + if (*reinterpret_cast(buff) != 0xa5) { return; } - OMLOG_ERROR("udp receive pack error. len:%d", size); - }; - - bsp_udp_client_register_callback(&udp_client_, BSP_UDP_RX_CPLT_CB, - udp_rx_cb, this); - - auto uart_rx_thread_fn = [](UartToUDP* uart_udp) { - uart_udp->num_lock_.Wait(UINT32_MAX); - bsp_uart_t uart = static_cast(uart_udp->num_); - uart_udp->num_++; - uart_udp->num_lock_.Post(); - - uint8_t prefix = 0; - - while (true) { - do { - bsp_uart_receive(uart, &prefix, sizeof(prefix), true); - } while (prefix != 0xa5); - - prefix = 0; - - bsp_uart_receive(uart, - reinterpret_cast(&uart_udp->uart_rx_[uart]), - sizeof(uart_udp->uart_rx_[uart]), true); - if (uart_udp->uart_rx_[uart].end != 0xe3) { - bsp_uart_abort_receive(uart); - OMLOG_ERROR("uart %d receive data error. end:%d", uart, - uart_udp->uart_rx_[uart].end); - continue; - } else { - uint32_t time = bsp_time_get_ms(); - - uart_udp->header_[uart].raw = uart_udp->uart_rx_[uart].id; - - uart_udp->count[uart]++; - - if (time - uart_udp->last_log_time[uart] > 1000) { - if (time - uart_udp->last_log_time[uart] > 1000) { - uart_udp->last_log_time[uart] += 1000; - } - OMLOG_NOTICE("uart %d get count %d at 1s", uart, - uart_udp->count[uart]); - uart_udp->count[uart] = 0; - } - - if (uart_udp->wl_remote_[uart_udp->header_[uart].data.device_id] - ->PraseData(uart_udp->uart_rx_[uart].data, - sizeof(uart_udp->uart_rx_[uart].data))) { - OMLOG_PASS("Topic Pack prase ok."); - } - } + if (!Component::CRC8::Verify(static_cast(buff), size)) { + return; } - }; - auto uart_tx_thread_fn = [](UartToUDP* uart_udp) { - bsp_uart_t uart = static_cast(uart_udp->num_); + auto header = static_cast(buff); - while (true) { - uart_udp->udp_rx_sem_[uart]->Wait(UINT32_MAX); - uart_udp->uart_tx_[uart].id = uart_udp->udp_rx_[uart].device_id; - memcpy(uart_udp->uart_tx_[uart].data, uart_udp->udp_rx_[uart].data, 8); - bsp_uart_transmit(uart, - reinterpret_cast(&uart_udp->uart_tx_[uart]), - sizeof(uart_udp->uart_tx_[uart]), true); + if (header->fd) { + Device::Can::SendFDExtPack(static_cast(header->area_id), + header->can_header.raw, + reinterpret_cast(header) + + sizeof(Device::WearLab::UdpDataHeader), + size); + } else { + Device::Can::Pack pack = {.index = header->can_header.raw}; + memcpy(pack.data, + reinterpret_cast(header) + + sizeof(Device::WearLab::UdpDataHeader), + 8); + Device::Can::SendExtPack(static_cast(header->area_id), pack); } }; + bsp_udp_client_register_callback(&udp_client_, BSP_UDP_RX_CPLT_CB, + udp_rx_cb, this); + auto udp_rx_thread_fn = [](UartToUDP* uart_udp) { bsp_udp_client_start(&uart_udp->udp_client_); while (true) { @@ -152,48 +72,103 @@ class UartToUDP { } }; - auto msg_rx_cb = [](Data& data, UartToUDP* udp) { - TimedData timed_date = {bsp_time_get_ms(), data}; - udp->udp_trans_buff.Send(timed_date); - udp->udp_tx_sem_.Post(); + auto udp_tx_thread_fn = [](UartToUDP* uart_udp) { + uint8_t tx_buff[512]; + + while (true) { + uart_udp->udp_tx_sem_.Lock(); + + uart_udp->udp_tx_mutex_.Lock(); + + auto size = om_fifo_readable_item_count(&uart_udp->udp_tx_fifo_); + om_fifo_reads(&uart_udp->udp_tx_fifo_, tx_buff, size); + + uart_udp->udp_tx_mutex_.Unlock(); - static int i = 0; + bsp_udp_client_transmit(&uart_udp->udp_client_, tx_buff, size); + } + }; - i++; + Message::Topic* fd_tp[BSP_CAN_NUM]; + Message::Topic* tp[BSP_CAN_NUM]; - OMLOG_WARNING("%d", i); + auto canfd_rx_fun = [](Device::Can::FDPack& pack, uint8_t* can) { + if (*can >= 0) { + return false; + } + static uint8_t udp_tx_buff[BSP_CAN_NUM][256] = {}; + + auto header = + reinterpret_cast(udp_tx_buff[*can]); + + header->time = bsp_time_get(); + header->prefix = 0xa5; + header->can_header.raw = pack.index; + header->area_id = *can; + header->data_len = pack.info.size; + header->fd = true; + + memcpy(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader), + pack.info.data, pack.info.size); + *(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader) + + pack.info.size) = + Component::CRC8::Calculate( + udp_tx_buff[*can], sizeof(*header) + pack.info.size, CRC8_INIT); + self_->udp_tx_mutex_.Lock(); + om_fifo_writes( + &self_->udp_tx_fifo_, header, + sizeof(Device::WearLab::UdpDataHeader) + pack.info.size + 1); + self_->udp_tx_mutex_.Unlock(); + self_->udp_tx_sem_.Unlock(); return true; }; - wl_imu_data_.RegisterCallback(msg_rx_cb, this); + auto can_rx_fun = [](Device::Can::Pack& pack, uint8_t* can) { + if (*can >= 0) { + return false; + } - auto udp_tx_thread_fn = [](UartToUDP* uart_udp) { - std::array trans_buff; - uint32_t buff_num = 0; + static uint8_t udp_tx_buff[BSP_CAN_NUM][256] = {}; + + auto header = + reinterpret_cast(udp_tx_buff[*can]); + + header->time = bsp_time_get(); + header->prefix = 0xa5; + header->can_header.raw = pack.index; + header->area_id = *can; + header->data_len = 8; + header->fd = false; + + memcpy(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader), + pack.data, 8); + *(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader) + 8) = + Component::CRC8::Calculate(udp_tx_buff[*can], sizeof(*header) + 8, + CRC8_INIT); + self_->udp_tx_mutex_.Lock(); + om_fifo_writes(&self_->udp_tx_fifo_, header, + sizeof(Device::WearLab::UdpDataHeader) + 9); + self_->udp_tx_mutex_.Unlock(); + self_->udp_tx_sem_.Unlock(); + return true; + }; - while (true) { - uart_udp->udp_tx_sem_.Wait(UINT32_MAX); - buff_num = uart_udp->udp_tx_sem_.Value() + 1; + for (int i = 0; i < BSP_CAN_NUM; i++) { + can_id_[i] = i; - uart_udp->udp_trans_buff.Receive(trans_buff[0]); + fd_tp[i] = new Message::Topic( + (std::string("trans_canfd") + std::to_string(i)).c_str()); + tp[i] = new Message::Topic( + (std::string("trans_can") + std::to_string(i)).c_str()); - for (uint32_t i = 1; i < buff_num; i++) { - uart_udp->udp_tx_sem_.Wait(UINT32_MAX); - uart_udp->udp_trans_buff.Receive(trans_buff[i]); - } + Device::Can::SubscribeFD(*fd_tp[i], static_cast(i), 0, + UINT32_MAX); - bsp_udp_client_transmit(&uart_udp->udp_client_, - reinterpret_cast(&trans_buff), - sizeof(trans_buff[0]) * buff_num); - } - }; + Device::Can::Subscribe(*tp[i], static_cast(i), 0, UINT32_MAX); - for (int i = param_.start_uart; i <= param_.end_uart; i++) { - uart_tx_thread_[i].Create( - uart_tx_thread_fn, this, - (std::string("uart_to_udp_tx_") + std::to_string(i)).c_str(), 512, - System::Thread::HIGH); + fd_tp[i]->RegisterCallback(canfd_rx_fun, &can_id_[i]); + tp[i]->RegisterCallback(can_rx_fun, &can_id_[i]); } udp_rx_thread_.Create(udp_rx_thread_fn, this, "udp_rx_thread", 512, @@ -201,47 +176,20 @@ class UartToUDP { udp_tx_thread_.Create(udp_tx_thread_fn, this, "udp_tx_thread", 512, System::Thread::HIGH); - - System::Thread::Sleep(100); - - for (int i = param_.start_uart; i <= param_.end_uart; i++) { - uart_rx_thread_[i].Create( - uart_rx_thread_fn, this, - (std::string("uart_to_udp_rx_") + std::to_string(i)).c_str(), 512, - System::Thread::HIGH); - } } - Param param_; - - std::array uart_rx_{}; - std::array uart_tx_{}; - std::array udp_rx_{}; - std::array header_{}; - std::array uart_rx_thread_; - std::array uart_tx_thread_; + static UartToUDP* self_; - Message::Topic wl_imu_data_; + om_fifo_t udp_tx_fifo_; - std::array wl_remote_; + uint8_t can_id_[BSP_CAN_NUM]; - std::array udp_rx_sem_{}; - - System::Queue udp_trans_buff; - - System::Semaphore num_lock_; - int num_ = 0; + System::Mutex udp_tx_mutex_, udp_tx_sem_; System::Thread udp_rx_thread_; System::Thread udp_tx_thread_; - System::Semaphore udp_tx_sem_; - bsp_udp_client_t udp_client_{}; - - std::array count{}; - - std::array last_log_time{}; }; } // namespace Module diff --git a/src/robot/udp_to_uart/robot.cpp b/src/robot/udp_to_uart/robot.cpp index 596994a7..c4a0ec0c 100644 --- a/src/robot/udp_to_uart/robot.cpp +++ b/src/robot/udp_to_uart/robot.cpp @@ -10,12 +10,6 @@ Robot::UdpToUart::Param param = { .timeout = 200, }, - .uart_udp = { - .port = 4321, - .start_uart = BSP_UART_1, - .end_uart = BSP_UART_2 - }, - .topic_share = { .topic_name = {"net_info"}, .block = true, diff --git a/src/robot/udp_to_uart/robot.hpp b/src/robot/udp_to_uart/robot.hpp index 3ce3e5f3..22fbd62a 100644 --- a/src/robot/udp_to_uart/robot.hpp +++ b/src/robot/udp_to_uart/robot.hpp @@ -1,4 +1,5 @@ #include "dev_blink_led.hpp" +#include "dev_canfd.hpp" #include "dev_net_config.hpp" #include "mod_topic_share_uart.hpp" #include "mod_uart_udp.hpp" @@ -9,18 +10,15 @@ class UdpToUart { public: typedef struct Param { Device::BlinkLED::Param led{}; - Module::UartToUDP::Param uart_udp{}; Module::TopicShareClientUart::Param topic_share; } Param; Device::BlinkLED led_; + Device::Can can_; Device::NetConfig net_config_; Module::TopicShareClientUart topic_share_; Module::UartToUDP uart_udp_; - UdpToUart(Param& param) - : led_(param.led), - topic_share_(param.topic_share), - uart_udp_(param.uart_udp) {} + UdpToUart(Param& param) : led_(param.led), topic_share_(param.topic_share) {} }; } // namespace Robot From 287d3db35b866b40a0c67794f16a47f1ff18799f Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 30 Nov 2023 03:33:02 +0800 Subject: [PATCH 08/15] fix Linux yield --- src/system/Linux/thread.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/Linux/thread.hpp b/src/system/Linux/thread.hpp index ca2bef3a..b60a0192 100644 --- a/src/system/Linux/thread.hpp +++ b/src/system/Linux/thread.hpp @@ -101,7 +101,7 @@ class Thread { void Delete() { pthread_cancel(this->handle_); } - static void Yield() { pthread_yield(); } + static void Yield() { sched_yield(); } pthread_t handle_; }; From 3090f07098aa59c623f1fd692dad6963922ebc8d Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Thu, 30 Nov 2023 03:54:02 +0800 Subject: [PATCH 09/15] canfd_imu support canfd control --- src/module/canfd_imu/mod_canfd_imu.cpp | 33 +++++++++++++++++++++++++- src/module/canfd_imu/mod_canfd_imu.hpp | 12 ++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/module/canfd_imu/mod_canfd_imu.cpp b/src/module/canfd_imu/mod_canfd_imu.cpp index e8ddf3d9..e844bcfb 100644 --- a/src/module/canfd_imu/mod_canfd_imu.cpp +++ b/src/module/canfd_imu/mod_canfd_imu.cpp @@ -16,6 +16,37 @@ CanfdImu::CanfdImu() id_("canfd_imu_id", 0x30), cycle_("canfd_imu_cycle", 10), cmd_(this, SetCMD, "set_imu") { + auto cmd_cb = [](Device::Can::FDPack &pack, CanfdImu *imu) { + if (pack.info.size != sizeof(ControlData)) { + return false; + } + + ControlData *data = reinterpret_cast(pack.info.data); + if (data->id != imu->id_) { + imu->id_.Set(data->id); + bsp_sys_reset(); + } + if (data->cycle != imu->cycle_) { + imu->cycle_.Set(data->cycle); + } + if (static_cast(data->uart_output) != imu->uart_output_) { + imu->id_.Set(data->uart_output); + } + if (static_cast(data->canfd_output) != imu->canfd_output_) { + imu->id_.Set(data->canfd_output); + } + return true; + }; + + auto cmd_tp = new Message::Topic("imu_cmd"); + + CanHeader tmp; + tmp.data = {.device_type = IMU_9, .data_type = CONTROL, .device_id = id_}; + + cmd_tp->RegisterCallback(cmd_cb, this); + + Device::Can::SubscribeFD(*cmd_tp, BSP_CAN_1, tmp.raw, 1); + auto thread_fn = [](CanfdImu *imu) { auto magn_sub = Message::Subscriber("magn"); auto quat_sub = @@ -32,7 +63,7 @@ CanfdImu::CanfdImu() quat_sub.DumpData(imu->data_.raw.quat_); imu->header_.data = { - .device_type = 0x01, .data_type = 0x01, .device_id = imu->id_}; + .device_type = IMU_9, .data_type = FEEDBACK, .device_id = imu->id_}; imu->data_.raw.time = bsp_time_get_ms(); diff --git a/src/module/canfd_imu/mod_canfd_imu.hpp b/src/module/canfd_imu/mod_canfd_imu.hpp index 83e2e8bf..b4256537 100644 --- a/src/module/canfd_imu/mod_canfd_imu.hpp +++ b/src/module/canfd_imu/mod_canfd_imu.hpp @@ -5,6 +5,10 @@ namespace Module { class CanfdImu { public: + typedef enum { IMU_9 = 2 } DeviceType; + + typedef enum { FEEDBACK = 1, CONTROL } DataType; + typedef union { struct __attribute__((packed)) { uint32_t device_type : 12; @@ -29,6 +33,14 @@ class CanfdImu { uint8_t crc8; } Data; + typedef struct __attribute__((packed)) { + uint16_t id; + uint16_t cycle; + uint8_t uart_output; + uint8_t canfd_output; + uint16_t res; + } ControlData; + Data data_; CanHeader header_; From 6f1eb5808ad6357fdb9c2678056a87c1baeecfa7 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:10:13 +0800 Subject: [PATCH 10/15] Fix canfd --- hw/bsp/dual_canfd/drivers/hal/Makefile | 2 +- hw/bsp/dual_canfd/drivers/hal/hal.ioc | 3 ++- hw/bsp/mangopi_r818/drivers/bsp_can.cpp | 5 +++-- src/device/canfd/dev_canfd.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/bsp/dual_canfd/drivers/hal/Makefile b/hw/bsp/dual_canfd/drivers/hal/Makefile index 63e4b16d..41f83729 100644 --- a/hw/bsp/dual_canfd/drivers/hal/Makefile +++ b/hw/bsp/dual_canfd/drivers/hal/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Tue Nov 28 23:14:33 CST 2023] +# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Mon Dec 04 12:24:30 CST 2023] ########################################################################################################################## # ------------------------------------------------ diff --git a/hw/bsp/dual_canfd/drivers/hal/hal.ioc b/hw/bsp/dual_canfd/drivers/hal/hal.ioc index 5f721d02..1d17a3ca 100644 --- a/hw/bsp/dual_canfd/drivers/hal/hal.ioc +++ b/hw/bsp/dual_canfd/drivers/hal/hal.ioc @@ -74,7 +74,8 @@ File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false LPUART1.BaudRate=9000000 -LPUART1.IPParameters=BaudRate,WordLength +LPUART1.IPParameters=BaudRate,WordLength,Parity +LPUART1.Parity=UART_PARITY_NONE LPUART1.WordLength=UART_WORDLENGTH_8B Mcu.CPN=STM32G0B1CBT6 Mcu.Family=STM32G0 diff --git a/hw/bsp/mangopi_r818/drivers/bsp_can.cpp b/hw/bsp/mangopi_r818/drivers/bsp_can.cpp index a164ebfe..2d1765bc 100644 --- a/hw/bsp/mangopi_r818/drivers/bsp_can.cpp +++ b/hw/bsp/mangopi_r818/drivers/bsp_can.cpp @@ -1,5 +1,6 @@ #include "bsp_can.h" +#include #include #include @@ -80,7 +81,7 @@ inline bsp_can_t bsp_can_get(bsp_uart_t uart, uint8_t id) { } inline bsp_uart_t bsp_can_get_uart(bsp_can_t can) { - if (can < BSP_CAN_2) { + if (can <= BSP_CAN_2) { return BSP_UART_1; } else { return BSP_UART_2; @@ -95,7 +96,6 @@ void bsp_can_init(void) { while (true) { auto index = uart_rx_buff[uart]; - memset(uart_rx_buff[uart], 0, sizeof(uart_rx_buff[uart])); do { bsp_uart_receive(uart, uart_rx_buff[uart], sizeof(uint8_t), true); } while (*uart_rx_buff[uart] != 0xa5); @@ -143,6 +143,7 @@ void bsp_can_init(void) { return static_cast(0); }; + static bsp_uart_t uart[BSP_CAN_UART_NUM]; static pthread_t thread[BSP_CAN_UART_NUM]; diff --git a/src/device/canfd/dev_canfd.cpp b/src/device/canfd/dev_canfd.cpp index 4ac4b920..1693e507 100644 --- a/src/device/canfd/dev_canfd.cpp +++ b/src/device/canfd/dev_canfd.cpp @@ -101,7 +101,7 @@ bool Can::SubscribeFD(Message::Topic& tp, bsp_can_t can, uint32_t index, uint32_t num) { ASSERT(num > 0); - canfd_tp_[can]->RangeDivide(tp, sizeof(Pack), offsetof(Pack, index), + canfd_tp_[can]->RangeDivide(tp, sizeof(FDPack), offsetof(FDPack, index), om_member_size_of(Pack, index), index, num); return true; } From 7f7d2abaa90e6167eeddf9e603e592ea5bef8e07 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:11:06 +0800 Subject: [PATCH 11/15] R818 use ch357 --- hw/bsp/mangopi_r818/drivers/bsp_uart.c | 178 ++++++++++++++++++++----- 1 file changed, 146 insertions(+), 32 deletions(-) diff --git a/hw/bsp/mangopi_r818/drivers/bsp_uart.c b/hw/bsp/mangopi_r818/drivers/bsp_uart.c index 7ade3130..fd4d8013 100644 --- a/hw/bsp/mangopi_r818/drivers/bsp_uart.c +++ b/hw/bsp/mangopi_r818/drivers/bsp_uart.c @@ -21,49 +21,160 @@ static int rx_count[BSP_UART_NUM]; static bool uart_block[BSP_UART_NUM]; -static const char *uart_dev_path[] = {"/dev/ttyACM0", "/dev/ttyACM1", +static const char *uart_dev_path[] = {"/dev/ttyCH343USB1", "/dev/ttyCH343USB0", "/dev/ttyS4"}; static const uint32_t UART_SPEED[] = {9000000, 9000000, 115200}; -void bsp_uart_init() { - for (int i = 0; i < BSP_UART_NUM; i++) { - uart_fd[i] = open(uart_dev_path[i], O_RDWR | O_NOCTTY); - printf("uart %s dev id:%d\n", uart_dev_path, uart_fd[i]); - assert(uart_fd[i] != -1); - struct termios tty_cfg; +static int libtty_setcustombaudrate(int fd, int baudrate) { + struct termios2 tio; + + if (ioctl(fd, TCGETS2, &tio)) { + perror("TCGETS2"); + return -1; + } + + tio.c_cflag &= ~CBAUD; + tio.c_cflag |= BOTHER; + tio.c_ispeed = baudrate; + tio.c_ospeed = baudrate; + + if (ioctl(fd, TCSETS2, &tio)) { + perror("TCSETS2"); + return -1; + } + + if (ioctl(fd, TCGETS2, &tio)) { + perror("TCGETS2"); + return -1; + } + + return 0; +} + +static int libtty_open(const char *devname) { + int fd = open(devname, O_RDWR | O_NOCTTY | O_NDELAY); + int flags = 0; + + if (fd < 0) { + perror("open device failed"); + return -1; + } + + flags = fcntl(fd, F_GETFL, 0); + flags &= ~O_NONBLOCK; + if (fcntl(fd, F_SETFL, flags) < 0) { + printf("fcntl failed.\n"); + return -1; + } - tcgetattr(uart_fd[i], &tty_cfg); + if (isatty(fd) == 0) { + printf("not tty device.\n"); + return -1; + } else + printf("tty device test ok.\n"); - tty_cfg.c_cflag &= ~PARENB; - tty_cfg.c_iflag &= ~INPCK; - tty_cfg.c_cflag &= ~CSTOPB; - tty_cfg.c_cflag &= ~CRTSCTS; + return fd; +} + +static int libtty_setopt(int fd, int speed, int databits, int stopbits, + char parity, char hardflow) { + struct termios newtio; + struct termios oldtio; + + bzero(&newtio, sizeof(newtio)); + bzero(&oldtio, sizeof(oldtio)); + + if (tcgetattr(fd, &oldtio) != 0) { + perror("tcgetattr"); + return -1; + } + newtio.c_cflag |= CLOCAL | CREAD; + newtio.c_cflag &= ~CSIZE; + + /* set data bits */ + switch (databits) { + case 5: + newtio.c_cflag |= CS5; + break; + case 6: + newtio.c_cflag |= CS6; + break; + case 7: + newtio.c_cflag |= CS7; + break; + case 8: + newtio.c_cflag |= CS8; + break; + default: + fprintf(stderr, "unsupported data size\n"); + return -1; + } + + /* set parity */ + switch (parity) { + case 'n': + case 'N': + newtio.c_cflag &= ~PARENB; /* Clear parity enable */ + newtio.c_iflag &= ~INPCK; /* Disable input parity check */ + break; + case 'o': + case 'O': + newtio.c_cflag |= (PARODD | PARENB); /* Odd parity instead of even */ + newtio.c_iflag |= INPCK; /* Enable input parity check */ + break; + case 'e': + case 'E': + newtio.c_cflag |= PARENB; /* Enable parity */ + newtio.c_cflag &= ~PARODD; /* Even parity instead of odd */ + newtio.c_iflag |= INPCK; /* Enable input parity check */ + break; + default: + fprintf(stderr, "unsupported parity\n"); + return -1; + } - struct termios2 tio; + /* set stop bits */ + switch (stopbits) { + case 1: + newtio.c_cflag &= ~CSTOPB; + break; + case 2: + newtio.c_cflag |= CSTOPB; + break; + default: + perror("unsupported stop bits\n"); + return -1; + } + + if (hardflow) + newtio.c_cflag |= CRTSCTS; + else + newtio.c_cflag &= ~CRTSCTS; - ioctl(uart_fd[i], TCGETS2, &tio); - tio.c_cflag &= ~CBAUD; - tio.c_cflag |= BOTHER; - tio.c_ispeed = UART_SPEED[i]; - tio.c_ospeed = UART_SPEED[i]; - ioctl(uart_fd[i], TCSETS2, &tio); + newtio.c_cc[VTIME] = 10; /* Time-out value (tenths of a second) [!ICANON]. */ + newtio.c_cc[VMIN] = 0; /* Minimum number of bytes read at once [!ICANON]. */ - // 一般必设置的标志 - tty_cfg.c_cflag |= (CLOCAL | CREAD); - tty_cfg.c_oflag &= ~(OPOST); - tty_cfg.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); - tty_cfg.c_iflag &= ~(ICRNL | INLCR | IGNCR | IXON | IXOFF | IXANY); + tcflush(fd, TCIOFLUSH); - tty_cfg.c_cc[VMIN] = 16; + if (tcsetattr(fd, TCSANOW, &newtio) != 0) { + perror("tcsetattr"); + return -1; + } - // 清空输入输出缓冲区 - tcflush(uart_fd[i], TCIOFLUSH); + /* set tty speed */ + if (libtty_setcustombaudrate(fd, speed) != 0) { + perror("setbaudrate"); + return -1; + } - tty_cfg.c_cflag &= ~CSIZE; - tty_cfg.c_cflag |= CS8; + return 0; +} - tcsetattr(uart_fd[i], TCSANOW, &tty_cfg); +void bsp_uart_init() { + for (int i = 0; i < BSP_UART_NUM; i++) { + uart_fd[i] = libtty_open(uart_dev_path[i]); + libtty_setopt(uart_fd[i], UART_SPEED[i], 8, 1, 'n', 0); } } @@ -101,10 +212,13 @@ bsp_status_t bsp_uart_receive(bsp_uart_t uart, uint8_t *buff, size_t size, uart_block[uart] = block; } +rework: rx_count[uart] = read(uart_fd[uart], buff, size); - if (rx_count[uart] < 0) { - assert(false); + while (rx_count[uart] != (int)(size)) { + size -= rx_count[uart]; + buff += rx_count[uart]; + goto rework; return BSP_ERR; } From 4f5ae1b371bec5e1d0e581cca0d31e6c2fda210b Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:12:35 +0800 Subject: [PATCH 12/15] Fix canfd_to_uart --- src/module/canfd_to_uart/mod_canfd_to_uart.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/module/canfd_to_uart/mod_canfd_to_uart.hpp b/src/module/canfd_to_uart/mod_canfd_to_uart.hpp index 171e68c9..e15b7e38 100644 --- a/src/module/canfd_to_uart/mod_canfd_to_uart.hpp +++ b/src/module/canfd_to_uart/mod_canfd_to_uart.hpp @@ -34,6 +34,7 @@ class FDCanToUart { auto uart_rx_cplt_cb = [](void* arg) { XB_UNUSED(arg); + bsp_uart_abort_receive(BSP_UART_MCU); om_fifo_writes(&self_->uart_rx_fifo, self_->uart_rx_buff, bsp_uart_get_count(BSP_UART_MCU)); @@ -43,10 +44,10 @@ class FDCanToUart { UartDataHeader* header = reinterpret_cast(&prase_buff); uint32_t len = om_fifo_readable_item_count(&self_->uart_rx_fifo); while (len > sizeof(UartDataHeader) + sizeof(uint8_t)) { - om_fifo_peek(&self_->uart_rx_fifo, &header); - len--; + om_fifo_peek(&self_->uart_rx_fifo, header); if (header->prefix != 0xa5) { om_fifo_pop(&self_->uart_rx_fifo); + len--; continue; } @@ -117,7 +118,7 @@ class FDCanToUart { sizeof(UartDataHeader) + pack.info.size, CRC8_INIT); if (self_->uart_sent.Wait(UINT32_MAX)) { bsp_uart_transmit( - BSP_UART_MCU, self_->curr_uart_tx_buff[*can], + BSP_UART_MCU, reinterpret_cast(header), sizeof(UartDataHeader) + pack.info.size + sizeof(uint8_t), false); } return false; @@ -167,6 +168,9 @@ class FDCanToUart { fd_tp[i]->RegisterCallback(canfd_rx_fun, &can_id_[i]); tp[i]->RegisterCallback(can_rx_fun, &can_id_[i]); } + + bsp_uart_receive(BSP_UART_MCU, self_->uart_rx_buff, + sizeof(self_->uart_rx_buff), false); } struct __attribute__((packed)) { @@ -176,8 +180,8 @@ class FDCanToUart { uint8_t* curr_uart_tx_buff[BSP_CAN_NUM]; - uint8_t uart_rx_buff[256]; - uint8_t uart_tx_buff[BSP_CAN_NUM][2][256]; + uint8_t uart_rx_buff[256] = {}; + uint8_t uart_tx_buff[BSP_CAN_NUM][2][256] = {}; System::Semaphore uart_received, uart_sent; om_fifo_t uart_rx_fifo; From 4c389c30194dd77c88b90bbb1e4f110fc8194fbc Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:13:09 +0800 Subject: [PATCH 13/15] Fix api Timer::SetCycle --- src/system/FreeRTOS/timer.hpp | 2 +- src/system/Linux/timer.hpp | 2 +- src/system/Linux_Webots/timer.hpp | 2 +- src/system/None/timer.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/system/FreeRTOS/timer.hpp b/src/system/FreeRTOS/timer.hpp index acb1d36f..7a0359bb 100644 --- a/src/system/FreeRTOS/timer.hpp +++ b/src/system/FreeRTOS/timer.hpp @@ -49,7 +49,7 @@ class Timer { static void Stop(TimerHandle& handle) { handle->data_.running = false; } - void SetCycle(TimerHandle& timer, uint32_t cycle) { + static void SetCycle(TimerHandle& timer, uint32_t cycle) { timer->data_.cycle = cycle; } diff --git a/src/system/Linux/timer.hpp b/src/system/Linux/timer.hpp index 126cf438..d925fe37 100644 --- a/src/system/Linux/timer.hpp +++ b/src/system/Linux/timer.hpp @@ -47,7 +47,7 @@ class Timer { static void Stop(TimerHandle& handle) { handle->data_.running = false; } - void SetCycle(TimerHandle& timer, uint32_t cycle) { + static void SetCycle(TimerHandle& timer, uint32_t cycle) { timer->data_.cycle = cycle; } diff --git a/src/system/Linux_Webots/timer.hpp b/src/system/Linux_Webots/timer.hpp index 126cf438..d925fe37 100644 --- a/src/system/Linux_Webots/timer.hpp +++ b/src/system/Linux_Webots/timer.hpp @@ -47,7 +47,7 @@ class Timer { static void Stop(TimerHandle& handle) { handle->data_.running = false; } - void SetCycle(TimerHandle& timer, uint32_t cycle) { + static void SetCycle(TimerHandle& timer, uint32_t cycle) { timer->data_.cycle = cycle; } diff --git a/src/system/None/timer.hpp b/src/system/None/timer.hpp index 126cf438..d925fe37 100644 --- a/src/system/None/timer.hpp +++ b/src/system/None/timer.hpp @@ -47,7 +47,7 @@ class Timer { static void Stop(TimerHandle& handle) { handle->data_.running = false; } - void SetCycle(TimerHandle& timer, uint32_t cycle) { + static void SetCycle(TimerHandle& timer, uint32_t cycle) { timer->data_.cycle = cycle; } From 146054492a0c17f2e950f8d332660c76db7bdbd7 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:14:58 +0800 Subject: [PATCH 14/15] remve ClangTidy rule: cert-err34-c --- .clangd | 1 + 1 file changed, 1 insertion(+) diff --git a/.clangd b/.clangd index c99f2d4f..8af43555 100644 --- a/.clangd +++ b/.clangd @@ -18,6 +18,7 @@ Diagnostics: cppcoreguidelines-pro-type-member-init, misc-no-recursion, cert-env33-c, + cert-err34-c, cert-err58-cpp, cert-msc*, concurrency-mt-unsafe, From 7482da01f7d2d0266ea73c297f765cbf3da452a0 Mon Sep 17 00:00:00 2001 From: xiao <2592509183@qq.com> Date: Mon, 4 Dec 2023 14:48:37 +0800 Subject: [PATCH 15/15] remove atom&&wearlab --- hw/bsp/atom/Kconfig | 0 hw/bsp/atom/board.cmake | 55 -- hw/bsp/atom/config/blink.config | 96 --- hw/bsp/atom/config/canfd_imu.config | 112 --- hw/bsp/atom/debug/atom.jdebug | 336 --------- hw/bsp/atom/debug/launch.json | 21 - hw/bsp/atom/drivers/CMakeLists.txt | 28 - hw/bsp/atom/drivers/bsp.c | 33 - hw/bsp/atom/drivers/bsp.h | 18 - hw/bsp/atom/drivers/bsp_can.c | 241 ------- hw/bsp/atom/drivers/bsp_can.h | 52 -- hw/bsp/atom/drivers/bsp_flash.c | 43 -- hw/bsp/atom/drivers/bsp_flash.h | 17 - hw/bsp/atom/drivers/bsp_gpio.c | 98 --- hw/bsp/atom/drivers/bsp_gpio.h | 28 - hw/bsp/atom/drivers/bsp_i2c.c | 149 ---- hw/bsp/atom/drivers/bsp_i2c.h | 42 -- hw/bsp/atom/drivers/bsp_spi.c | 123 ---- hw/bsp/atom/drivers/bsp_spi.h | 44 -- hw/bsp/atom/drivers/bsp_sys.h | 33 - hw/bsp/atom/drivers/bsp_time.c | 21 - hw/bsp/atom/drivers/bsp_time.h | 17 - hw/bsp/atom/drivers/bsp_uart.c | 137 ---- hw/bsp/atom/drivers/bsp_uart.h | 47 -- hw/bsp/atom/drivers/bsp_usb.c | 85 --- hw/bsp/atom/drivers/bsp_usb.h | 40 -- hw/bsp/atom/drivers/flash/CMakeLists.txt | 34 - hw/bsp/atom/drivers/flash/mf_config.h | 66 -- hw/bsp/atom/drivers/hal/.mxproject | 26 - hw/bsp/atom/drivers/hal/CMakeLists.txt | 29 - hw/bsp/atom/drivers/hal/Core/Inc/main.h | 85 --- .../atom/drivers/hal/Core/Inc/stm32_assert.h | 57 -- .../drivers/hal/Core/Inc/stm32g4xx_hal_conf.h | 380 ----------- .../atom/drivers/hal/Core/Inc/stm32g4xx_it.h | 78 --- hw/bsp/atom/drivers/hal/Core/Src/main.c | 500 -------------- .../drivers/hal/Core/Src/stm32g4xx_hal_msp.c | 641 ------------------ .../hal/Core/Src/stm32g4xx_hal_timebase_tim.c | 126 ---- .../atom/drivers/hal/Core/Src/stm32g4xx_it.c | 386 ----------- .../drivers/hal/Core/Src/system_stm32g4xx.c | 285 -------- hw/bsp/atom/drivers/hal/Makefile | 198 ------ .../atom/drivers/hal/STM32G431KBUx_FLASH.ld | 189 ------ hw/bsp/atom/drivers/hal/hal.ioc | 387 ----------- hw/bsp/atom/drivers/hal/startup_stm32g431xx.s | 497 -------------- hw/bsp/atom/drivers/rtos/CMakeLists.txt | 33 - hw/bsp/atom/drivers/rtos/FreeRTOSConfig.h | 184 ----- hw/bsp/atom/drivers/rtos/rtos.c | 79 --- hw/bsp/atom/ld/LinkerScripts.ld | 187 ----- hw/bsp/atom/ld/LinkerScripts_with_bl.ld | 187 ----- hw/bsp/atom/main.cpp | 9 - hw/bsp/atom/toolchain.cmake | 76 --- hw/bsp/atom_bl/Kconfig | 0 hw/bsp/atom_bl/board.cmake | 34 - hw/bsp/atom_bl/config/bootloader.config | 94 --- hw/bsp/atom_bl/debug/atom.jdebug | 337 --------- hw/bsp/atom_bl/debug/launch.json | 21 - hw/bsp/atom_bl/drivers/CMakeLists.txt | 25 - hw/bsp/atom_bl/drivers/bsp.c | 25 - hw/bsp/atom_bl/drivers/bsp.h | 18 - hw/bsp/atom_bl/drivers/bsp_can.c | 192 ------ hw/bsp/atom_bl/drivers/bsp_can.h | 43 -- hw/bsp/atom_bl/drivers/bsp_flash.c | 60 -- hw/bsp/atom_bl/drivers/bsp_flash.h | 19 - hw/bsp/atom_bl/drivers/bsp_gpio.c | 53 -- hw/bsp/atom_bl/drivers/bsp_gpio.h | 23 - hw/bsp/atom_bl/drivers/bsp_sys.h | 65 -- hw/bsp/atom_bl/drivers/bsp_time.c | 19 - hw/bsp/atom_bl/drivers/bsp_time.h | 17 - hw/bsp/atom_bl/drivers/bsp_uart.c | 62 -- hw/bsp/atom_bl/drivers/bsp_uart.h | 47 -- hw/bsp/atom_bl/drivers/bsp_usb.c | 27 - hw/bsp/atom_bl/drivers/bsp_usb.h | 40 -- hw/bsp/atom_bl/drivers/hal/.mxproject | 26 - hw/bsp/atom_bl/drivers/hal/CMakeLists.txt | 28 - hw/bsp/atom_bl/drivers/hal/Core/Inc/main.h | 85 --- .../drivers/hal/Core/Inc/stm32_assert.h | 53 -- .../drivers/hal/Core/Inc/stm32g4xx_hal_conf.h | 380 ----------- .../drivers/hal/Core/Inc/stm32g4xx_it.h | 68 -- hw/bsp/atom_bl/drivers/hal/Core/Src/main.c | 351 ---------- .../drivers/hal/Core/Src/stm32g4xx_hal_msp.c | 223 ------ .../drivers/hal/Core/Src/stm32g4xx_it.c | 229 ------- .../drivers/hal/Core/Src/system_stm32g4xx.c | 285 -------- hw/bsp/atom_bl/drivers/hal/Makefile | 200 ------ .../drivers/hal/STM32G431KBUx_FLASH.ld | 189 ------ hw/bsp/atom_bl/drivers/hal/hal.ioc | 169 ----- .../atom_bl/drivers/hal/startup_stm32g431xx.s | 497 -------------- hw/bsp/atom_bl/ld/LinkerScripts.ld | 187 ----- hw/bsp/atom_bl/main.cpp | 7 - hw/bsp/atom_bl/toolchain.cmake | 76 --- .../config/udp_to_uart_client.config | 112 --- hw/bsp/node_imu/config/can_imu_wearlab.config | 98 --- src/device/wearlab/Kconfig | 0 src/device/wearlab/info.cmake | 8 - src/device/wearlab/wearlab.hpp | 58 -- src/module/canfd_imu/Kconfig | 0 src/module/canfd_imu/info.cmake | 6 - src/module/canfd_imu/mod_canfd_imu.cpp | 139 ---- src/module/canfd_imu/mod_canfd_imu.hpp | 66 -- src/module/uart_udp_client/Kconfig | 0 src/module/uart_udp_client/info.cmake | 6 - src/module/uart_udp_client/mod_uart_udp.cpp | 5 - src/module/uart_udp_client/mod_uart_udp.hpp | 195 ------ src/module/uart_udp_client/udp_param.h | 2 - src/robot/canfd_imu/Kconfig | 0 src/robot/canfd_imu/robot.cpp | 35 - src/robot/canfd_imu/robot.hpp | 29 - 105 files changed, 11668 deletions(-) delete mode 100644 hw/bsp/atom/Kconfig delete mode 100644 hw/bsp/atom/board.cmake delete mode 100644 hw/bsp/atom/config/blink.config delete mode 100644 hw/bsp/atom/config/canfd_imu.config delete mode 100644 hw/bsp/atom/debug/atom.jdebug delete mode 100644 hw/bsp/atom/debug/launch.json delete mode 100644 hw/bsp/atom/drivers/CMakeLists.txt delete mode 100644 hw/bsp/atom/drivers/bsp.c delete mode 100644 hw/bsp/atom/drivers/bsp.h delete mode 100644 hw/bsp/atom/drivers/bsp_can.c delete mode 100644 hw/bsp/atom/drivers/bsp_can.h delete mode 100644 hw/bsp/atom/drivers/bsp_flash.c delete mode 100644 hw/bsp/atom/drivers/bsp_flash.h delete mode 100644 hw/bsp/atom/drivers/bsp_gpio.c delete mode 100644 hw/bsp/atom/drivers/bsp_gpio.h delete mode 100644 hw/bsp/atom/drivers/bsp_i2c.c delete mode 100644 hw/bsp/atom/drivers/bsp_i2c.h delete mode 100644 hw/bsp/atom/drivers/bsp_spi.c delete mode 100644 hw/bsp/atom/drivers/bsp_spi.h delete mode 100644 hw/bsp/atom/drivers/bsp_sys.h delete mode 100644 hw/bsp/atom/drivers/bsp_time.c delete mode 100644 hw/bsp/atom/drivers/bsp_time.h delete mode 100644 hw/bsp/atom/drivers/bsp_uart.c delete mode 100644 hw/bsp/atom/drivers/bsp_uart.h delete mode 100644 hw/bsp/atom/drivers/bsp_usb.c delete mode 100644 hw/bsp/atom/drivers/bsp_usb.h delete mode 100644 hw/bsp/atom/drivers/flash/CMakeLists.txt delete mode 100644 hw/bsp/atom/drivers/flash/mf_config.h delete mode 100644 hw/bsp/atom/drivers/hal/.mxproject delete mode 100644 hw/bsp/atom/drivers/hal/CMakeLists.txt delete mode 100644 hw/bsp/atom/drivers/hal/Core/Inc/main.h delete mode 100644 hw/bsp/atom/drivers/hal/Core/Inc/stm32_assert.h delete mode 100644 hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h delete mode 100644 hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_it.h delete mode 100644 hw/bsp/atom/drivers/hal/Core/Src/main.c delete mode 100644 hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_msp.c delete mode 100644 hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_timebase_tim.c delete mode 100644 hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_it.c delete mode 100644 hw/bsp/atom/drivers/hal/Core/Src/system_stm32g4xx.c delete mode 100644 hw/bsp/atom/drivers/hal/Makefile delete mode 100644 hw/bsp/atom/drivers/hal/STM32G431KBUx_FLASH.ld delete mode 100644 hw/bsp/atom/drivers/hal/hal.ioc delete mode 100644 hw/bsp/atom/drivers/hal/startup_stm32g431xx.s delete mode 100644 hw/bsp/atom/drivers/rtos/CMakeLists.txt delete mode 100644 hw/bsp/atom/drivers/rtos/FreeRTOSConfig.h delete mode 100644 hw/bsp/atom/drivers/rtos/rtos.c delete mode 100644 hw/bsp/atom/ld/LinkerScripts.ld delete mode 100644 hw/bsp/atom/ld/LinkerScripts_with_bl.ld delete mode 100644 hw/bsp/atom/main.cpp delete mode 100644 hw/bsp/atom/toolchain.cmake delete mode 100644 hw/bsp/atom_bl/Kconfig delete mode 100644 hw/bsp/atom_bl/board.cmake delete mode 100644 hw/bsp/atom_bl/config/bootloader.config delete mode 100644 hw/bsp/atom_bl/debug/atom.jdebug delete mode 100644 hw/bsp/atom_bl/debug/launch.json delete mode 100644 hw/bsp/atom_bl/drivers/CMakeLists.txt delete mode 100644 hw/bsp/atom_bl/drivers/bsp.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_can.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_can.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_flash.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_flash.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_gpio.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_gpio.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_sys.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_time.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_time.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_uart.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_uart.h delete mode 100644 hw/bsp/atom_bl/drivers/bsp_usb.c delete mode 100644 hw/bsp/atom_bl/drivers/bsp_usb.h delete mode 100644 hw/bsp/atom_bl/drivers/hal/.mxproject delete mode 100644 hw/bsp/atom_bl/drivers/hal/CMakeLists.txt delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Inc/main.h delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32_assert.h delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_it.h delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Src/main.c delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_hal_msp.c delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_it.c delete mode 100644 hw/bsp/atom_bl/drivers/hal/Core/Src/system_stm32g4xx.c delete mode 100644 hw/bsp/atom_bl/drivers/hal/Makefile delete mode 100644 hw/bsp/atom_bl/drivers/hal/STM32G431KBUx_FLASH.ld delete mode 100644 hw/bsp/atom_bl/drivers/hal/hal.ioc delete mode 100644 hw/bsp/atom_bl/drivers/hal/startup_stm32g431xx.s delete mode 100644 hw/bsp/atom_bl/ld/LinkerScripts.ld delete mode 100644 hw/bsp/atom_bl/main.cpp delete mode 100644 hw/bsp/atom_bl/toolchain.cmake delete mode 100644 hw/bsp/mangopi_r818/config/udp_to_uart_client.config delete mode 100644 hw/bsp/node_imu/config/can_imu_wearlab.config delete mode 100644 src/device/wearlab/Kconfig delete mode 100644 src/device/wearlab/info.cmake delete mode 100644 src/device/wearlab/wearlab.hpp delete mode 100644 src/module/canfd_imu/Kconfig delete mode 100644 src/module/canfd_imu/info.cmake delete mode 100644 src/module/canfd_imu/mod_canfd_imu.cpp delete mode 100644 src/module/canfd_imu/mod_canfd_imu.hpp delete mode 100644 src/module/uart_udp_client/Kconfig delete mode 100644 src/module/uart_udp_client/info.cmake delete mode 100644 src/module/uart_udp_client/mod_uart_udp.cpp delete mode 100644 src/module/uart_udp_client/mod_uart_udp.hpp delete mode 100644 src/module/uart_udp_client/udp_param.h delete mode 100644 src/robot/canfd_imu/Kconfig delete mode 100644 src/robot/canfd_imu/robot.cpp delete mode 100644 src/robot/canfd_imu/robot.hpp diff --git a/hw/bsp/atom/Kconfig b/hw/bsp/atom/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/hw/bsp/atom/board.cmake b/hw/bsp/atom/board.cmake deleted file mode 100644 index 6efeb645..00000000 --- a/hw/bsp/atom/board.cmake +++ /dev/null @@ -1,55 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -add_compile_definitions(STM32G431xx) - -set(HAL_DIR ${MCU_DIR}/st/stm32g4xx_hal_driver) -set(STM32_CMSIS_DIR ${MCU_DIR}/st/cmsis_device_g4) -set(ARM_CMSIS_DIR ${LIB_DIR}/cmsis_5) - -include(${MCU_DIR}/st/cmake/mcu_stm32g4.cmake) -include(${MCU_DIR}/st/cmake/toolchain_utils.cmake) - -add_subdirectory(${BOARD_DIR}/drivers) - -add_executable(${PROJECT_NAME}.elf ${BOARD_DIR}/main.cpp) - -add_executable(${PROJECT_NAME}_with_bl.elf ${BOARD_DIR}/main.cpp) - -target_link_libraries( - ${PROJECT_NAME}.elf - PUBLIC bsp - PUBLIC system - PUBLIC robot) - -target_link_libraries( - ${PROJECT_NAME}_with_bl.elf - PUBLIC bsp - PUBLIC system - PUBLIC robot) - - -target_include_directories( - ${PROJECT_NAME}.elf - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE $ - PRIVATE $ - PRIVATE $ -) - -target_include_directories( - ${PROJECT_NAME}_with_bl.elf - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE $ - PRIVATE $ - PRIVATE $ -) - -target_link_options(${PROJECT_NAME}_with_bl.elf PRIVATE "-T${BOARD_DIR}/ld/LinkerScripts_with_bl.ld") - -create_hex_output(${PROJECT_NAME}) -create_bin_output(${PROJECT_NAME}) -print_section_sizes(${PROJECT_NAME}.elf) - -create_hex_output(${PROJECT_NAME}_with_bl) -create_bin_output(${PROJECT_NAME}_with_bl) -print_section_sizes(${PROJECT_NAME}_with_bl.elf) diff --git a/hw/bsp/atom/config/blink.config b/hw/bsp/atom/config/blink.config deleted file mode 100644 index 50d2acc1..00000000 --- a/hw/bsp/atom/config/blink.config +++ /dev/null @@ -1,96 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -CONFIG_auto_generated_config_prefix_board-atom=y -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-mangopi_r818 is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -# CONFIG_auto_generated_config_prefix_system-None is not set -CONFIG_auto_generated_config_prefix_system-FreeRTOS=y -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -# CONFIG_auto_generated_config_prefix_system-Linux is not set - -# -# FreeRTOS -# -CONFIG_INIT_TASK_STACK_DEPTH=1024 -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_USB_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_TERM_TASK_STACK_DEPTH=512 -# end of FreeRTOS - -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -CONFIG_auto_generated_config_prefix_robot-blink=y -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set - -# -# 组件 -# - -# -# 设备 -# -# CONFIG_auto_generated_config_prefix_device-wearlab is not set -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -# CONFIG_auto_generated_config_prefix_device-net_config is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-motor is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp_client is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -CONFIG_auto_generated_config_prefix_module-performance=y -# CONFIG_auto_generated_config_prefix_module-topic_share_uart is not set -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# end of 模块 diff --git a/hw/bsp/atom/config/canfd_imu.config b/hw/bsp/atom/config/canfd_imu.config deleted file mode 100644 index 5d1ac3a8..00000000 --- a/hw/bsp/atom/config/canfd_imu.config +++ /dev/null @@ -1,112 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-dual_canfd is not set -# CONFIG_auto_generated_config_prefix_board-atom_bl is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-mangopi_r818 is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -CONFIG_auto_generated_config_prefix_board-atom=y -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -# CONFIG_auto_generated_config_prefix_system-Bootloader is not set -CONFIG_auto_generated_config_prefix_system-FreeRTOS=y -# CONFIG_auto_generated_config_prefix_system-None is not set -# CONFIG_auto_generated_config_prefix_system-Linux is not set -CONFIG_INIT_TASK_STACK_DEPTH=768 - -# -# FreeRTOS -# -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_USB_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_TERM_TASK_STACK_DEPTH=384 -# end of FreeRTOS - -# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -CONFIG_auto_generated_config_prefix_robot-canfd_imu=y -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-canfd_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-bootloader is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set - -# -# 组件 -# - -# -# 设备 -# -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -CONFIG_auto_generated_config_prefix_device-canfd=y -# CONFIG_auto_generated_config_prefix_device-motor is not set -CONFIG_auto_generated_config_prefix_device-ahrs-9=y -CONFIG_DEVICE_AHRS_TASK_STACK_DEPTH=256 -CONFIG_auto_generated_config_prefix_device-mmc5603=y -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y -CONFIG_auto_generated_config_prefix_device-icm42688=y -CONFIG_DEVICE_ICM42688_TASK_STACK_DEPTH=256 -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-net_config is not set -# CONFIG_auto_generated_config_prefix_device-wearlab is not set -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -CONFIG_auto_generated_config_prefix_module-canfd_imu=y -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-performance is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp_client is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-dual_canfd_to_uart is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set -# CONFIG_auto_generated_config_prefix_module-topic_share_uart is not set -# CONFIG_auto_generated_config_prefix_module-uart_update is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-wl_uart_udp is not set -# end of 模块 diff --git a/hw/bsp/atom/debug/atom.jdebug b/hw/bsp/atom/debug/atom.jdebug deleted file mode 100644 index 9d5f8145..00000000 --- a/hw/bsp/atom/debug/atom.jdebug +++ /dev/null @@ -1,336 +0,0 @@ -/********************************************************************* -* (c) SEGGER Microcontroller GmbH * -* The Embedded Experts * -* www.segger.com * -********************************************************************** - -File : rm_c.jdebug -Created : 12 Feb 2023 19:50 -Ozone Version : V3.24g -*/ - -/********************************************************************* -* -* OnProjectLoad -* -* Function description -* Project load routine. Required. -* -********************************************************************** -*/ -void OnProjectLoad (void) { -// -// Dialog-generated settings -// -Project.AddPathSubstitute ("../../../../hw/bsp/rm-c/debug", "$(ProjectDir)"); -Project.AddPathSubstitute ("../../../../hw/bsp/rm-c/debug", "$(ProjectDir)"); -Project.SetDevice ("STM32g431KB"); -Project.SetHostIF ("USB", ""); -Project.SetTargetIF ("SWD"); -Project.SetTIFSpeed ("4 MHz"); -Project.AddSvdFile ("../../../../lib/cmsis_svd/data/STMicro/STM32G431xx.svd"); -// -// User settings -// -File.Open ("../../../../build/xrobot.elf"); -} - -/********************************************************************* -* -* OnStartupComplete -* -* Function description -* Called when program execution has reached/passed -* the startup completion point. Optional. -* -********************************************************************** -*/ -//void OnStartupComplete (void) { -//} - -/********************************************************************* -* -* TargetReset -* -* Function description -* Replaces the default target device reset routine. Optional. -* -* Notes -* This example demonstrates the usage when -* debugging an application in RAM on a Cortex-M target device. -* -********************************************************************** -*/ -//void TargetReset (void) { -// -// unsigned int SP ; -// unsigned int PC ; -// unsigned int VectorTableAddr ; -// -// VectorTableAddr = Elf.GetBaseAddr() ; -// // -// // Set up initial stack pointer -// // -// if (VectorTableAddr != 0xFFFFFFFF) { -// SP = Target.ReadU32(VectorTableAddr) ; -// Target.SetReg("SP", SP) ; -// } -// // -// // Set up entry point PC -// // -// PC = Elf.GetEntryPointPC() ; -// -// if (PC != 0xFFFFFFFF) { -// Target.SetReg("PC", PC) ; -// } else if (VectorTableAddr != 0xFFFFFFFF) { -// PC = Target.ReadU32(VectorTableAddr + 4) ; -// Target.SetReg("PC", PC) ; -// } else { -// Util.Error("Project file error: failed to set entry point PC", 1) ; -// } -//} - -/********************************************************************* -* -* BeforeTargetReset -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetReset (void) { -//} - -/********************************************************************* -* -* AfterTargetReset -* -* Function description -* Event handler routine. Optional. -* The default implementation initializes SP and PC to reset values. -** -********************************************************************** -*/ -void AfterTargetReset (void) { -_SetupTarget() ; -} - -/********************************************************************* -* -* DebugStart -* -* Function description -* Replaces the default debug session startup routine. Optional. -* -********************************************************************** -*/ -//void DebugStart (void) { -//} - -/********************************************************************* -* -* TargetConnect -* -* Function description -* Replaces the default target IF connection routine. Optional. -* -********************************************************************** -*/ -//void TargetConnect (void) { -//} - -/********************************************************************* -* -* BeforeTargetConnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetConnect (void) { -//} - -/********************************************************************* -* -* AfterTargetConnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetConnect (void) { -//} - -/********************************************************************* -* -* TargetDownload -* -* Function description -* Replaces the default program download routine. Optional. -* -********************************************************************** -*/ -//void TargetDownload (void) { -//} - -/********************************************************************* -* -* BeforeTargetDownload -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetDownload (void) { -//} - -/********************************************************************* -* -* AfterTargetDownload -* -* Function description -* Event handler routine. Optional. -* The default implementation initializes SP and PC to reset values. -* -********************************************************************** -*/ -void AfterTargetDownload (void) { -_SetupTarget() ; -} - -/********************************************************************* -* -* BeforeTargetDisconnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetDisconnect (void) { -//} - -/********************************************************************* -* -* AfterTargetDisconnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetDisconnect (void) { -//} - -/********************************************************************* -* -* AfterTargetHalt -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetHalt (void) { -//} - -/********************************************************************* -* -* BeforeTargetResume -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetResume (void) { -//} - -/********************************************************************* -* -* OnSnapshotLoad -* -* Function description -* Called upon loading a snapshot. Optional. -* -* Additional information -* This function is used to restore the target state in cases -* where values cannot simply be written to the target. -* Typical use: GPIO clock needs to be enabled, before -* GPIO is configured. -* -********************************************************************** -*/ -//void OnSnapshotLoad (void) { -//} - -/********************************************************************* -* -* OnSnapshotSave -* -* Function description -* Called upon saving a snapshot. Optional. -* -* Additional information -* This function is usually used to save values of the target -* state which can either not be trivially read, -* or need to be restored in a specific way or order. -* Typically use: Memory Mapped Registers, -* such as PLL and GPIO configuration. -* -********************************************************************** -*/ -//void OnSnapshotSave (void) { -//} - -/********************************************************************* -* -* OnError -* -* Function description -* Called when an error ocurred. Optional. -* -********************************************************************** -*/ -//void OnError (void) { -//} - -/********************************************************************* -* -* _SetupTarget -* -* Function description -* Setup the target. -* Called by AfterTargetReset() and AfterTargetDownload(). -* -* Auto-generated function. May be overridden by Ozone. -* -********************************************************************** -*/ -void _SetupTarget(void) { -unsigned int SP ; -unsigned int PC ; -unsigned int VectorTableAddr ; - -VectorTableAddr = Elf.GetBaseAddr() ; -// -// Set up initial stack pointer -// -SP = Target.ReadU32(VectorTableAddr) ; -if (SP != 0xFFFFFFFF) { -Target.SetReg("SP", SP) ; -} -// -// Set up entry point PC -// -PC = Elf.GetEntryPointPC() ; -if (PC != 0xFFFFFFFF) { -Target.SetReg("PC", PC) ; -} else { -Util.Error("Project script error: failed to set up entry point PC", 1) ; -} -} diff --git a/hw/bsp/atom/debug/launch.json b/hw/bsp/atom/debug/launch.json deleted file mode 100644 index be866af4..00000000 --- a/hw/bsp/atom/debug/launch.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "configurations": [ - { - "name": "ARM-Debug", - "cwd": "${workspaceRoot}", - "executable": "${workspaceRoot}/build/xrobot.elf", - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "device": "STM32G431KB", - "interface": "swd", - "runToEntryPoint": "main", - "svdFile": "${workspaceRoot}/lib/cmsis_svd/data/STMicro/STM32G431xx.svd", - "configFiles": [ - "", - "" - ] - } - ], - "version": "0.2.0" -} diff --git a/hw/bsp/atom/drivers/CMakeLists.txt b/hw/bsp/atom/drivers/CMakeLists.txt deleted file mode 100644 index c49a80ab..00000000 --- a/hw/bsp/atom/drivers/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -project(bsp) - -file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c") - -add_library(${PROJECT_NAME} STATIC) - -target_sources(${PROJECT_NAME} PRIVATE ${${PROJECT_NAME}_SOURCES}) - -include(${MCU_DIR}/default/CMakeLists.txt) - -target_link_libraries( - ${PROJECT_NAME} - PUBLIC hal - PUBLIC flash - PUBLIC rtos) - -target_include_directories( - ${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ - PUBLIC $ - PUBLIC $) - -add_dependencies(${PROJECT_NAME} hal flash rtos) - -add_subdirectory(${BOARD_DIR}/drivers/hal) -add_subdirectory(${BOARD_DIR}/drivers/rtos) -add_subdirectory(${BOARD_DIR}/drivers/flash) diff --git a/hw/bsp/atom/drivers/bsp.c b/hw/bsp/atom/drivers/bsp.c deleted file mode 100644 index 8728b2df..00000000 --- a/hw/bsp/atom/drivers/bsp.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "bsp.h" - -#include "bsp_can.h" -#include "bsp_uart.h" -#include "main.h" -#include "stm32g4xx_hal_i2c.h" -#include "stm32g4xx_hal_msp.c" -#include "stm32g4xx_hal_tim.h" -#include "stm32g4xx_it.c" - -extern TIM_HandleTypeDef htim15; - -void bsp_init() { - uwTickPrio = TICK_INT_PRIORITY; - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. - */ - HAL_Init(); - - /* Configure the system clock */ - SystemClock_Config(); - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - MX_FDCAN1_Init(); - MX_USART2_UART_Init(); - MX_I2C1_Init(); - MX_SPI1_Init(); - HAL_TIM_Base_Stop_IT(&htim15); - - bsp_uart_init(); -} diff --git a/hw/bsp/atom/drivers/bsp.h b/hw/bsp/atom/drivers/bsp.h deleted file mode 100644 index 3141bcb4..00000000 --- a/hw/bsp/atom/drivers/bsp.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp_def.h" - -typedef struct { - void (*fn)(void *); - void *arg; -} bsp_callback_t; - -void bsp_init(void); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_can.c b/hw/bsp/atom/drivers/bsp_can.c deleted file mode 100644 index 59c737fe..00000000 --- a/hw/bsp/atom/drivers/bsp_can.c +++ /dev/null @@ -1,241 +0,0 @@ -#include "bsp_can.h" - -#include "FreeRTOS.h" -#include "bsp_def.h" -#include "main.h" -#include "semphr.h" -#include "stm32g4xx_hal_fdcan.h" -#include "task.h" - -typedef struct { - FDCAN_RxHeaderTypeDef header; - uint8_t data[64]; -} can_raw_rx_t; - -typedef struct { - FDCAN_HandleTypeDef header; - uint8_t data[8]; -} can_raw_tx_t; - -typedef struct { - void (*fn)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg); - void *arg; -} can_callback_t; - -extern FDCAN_HandleTypeDef hfdcan1; - -static can_callback_t callback_list[BSP_CAN_NUM][BSP_CAN_CB_NUM]; - -static bool bsp_can_initd = false; - -static can_raw_rx_t rx_buff[BSP_CAN_NUM]; - -static SemaphoreHandle_t rx_cplt_wait_sem[BSP_CAN_NUM]; - -FDCAN_HandleTypeDef *bsp_can_get_handle(bsp_can_t can) { - switch (can) { - case BSP_CAN_1: - return &hfdcan1; - default: - return NULL; - } -} - -static bsp_can_t can_get(FDCAN_HandleTypeDef *hcan) { - if (hcan->Instance == FDCAN1) { - return BSP_CAN_1; - } else { - return BSP_CAN_ERR; - } -} - -void HAL_FDCAN_TxBufferCompleteCallback(FDCAN_HandleTypeDef *hcan, - uint32_t BufferIndexes) { - (void)BufferIndexes; - BaseType_t px_higher_priority_task_woken = 0; - xSemaphoreGiveFromISR(rx_cplt_wait_sem[can_get(hcan)], - &px_higher_priority_task_woken); - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } -} - -void HAL_FDCAN_TxBufferAbortCallback(FDCAN_HandleTypeDef *hcan, - uint32_t BufferIndexes) { - (void)BufferIndexes; - BaseType_t px_higher_priority_task_woken = 0; - xSemaphoreGiveFromISR(rx_cplt_wait_sem[can_get(hcan)], - &px_higher_priority_task_woken); - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } -} - -void HAL_FDCAN_ErrorCallback(FDCAN_HandleTypeDef *hcan) { - hcan->ErrorCode &= ~FDCAN_FLAG_ARB_PROTOCOL_ERROR; - BaseType_t px_higher_priority_task_woken = 0; - xSemaphoreGiveFromISR(rx_cplt_wait_sem[can_get(hcan)], - &px_higher_priority_task_woken); - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } -} - -void bsp_can_init(void) { - for (int i = 0; i < BSP_CAN_NUM; i++) { - rx_cplt_wait_sem[i] = xSemaphoreCreateBinary(); - } - - FDCAN_FilterTypeDef can_filter = {0}; - - can_filter.IdType = FDCAN_STANDARD_ID; - can_filter.FilterIndex = 0; - can_filter.FilterType = FDCAN_FILTER_MASK; - can_filter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; - can_filter.FilterID1 = 0x0000; - can_filter.FilterID2 = 0x0000; - if (HAL_FDCAN_ConfigFilter(&hfdcan1, &can_filter) != HAL_OK) { - XB_ASSERT(false); - } - - can_filter.IdType = FDCAN_EXTENDED_ID; - can_filter.FilterIndex = 1; - can_filter.FilterType = FDCAN_FILTER_MASK; - can_filter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; - can_filter.FilterID1 = 0x0000; - can_filter.FilterID2 = 0x0000; - if (HAL_FDCAN_ConfigFilter(&hfdcan1, &can_filter) != HAL_OK) { - XB_ASSERT(false); - } - - HAL_FDCAN_Start(&hfdcan1); //开启FDCAN - HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0); - HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_TX_FIFO_EMPTY, 0); - - bsp_can_initd = true; -} - -static const uint8_t DLCtoBytes[] = {0, 1, 2, 3, 4, 5, 6, 7, - 8, 12, 16, 20, 24, 32, 48, 64}; - -static void can_rx_cb_fn(bsp_can_t can) { - while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), FDCAN_RX_FIFO0, - &rx_buff[can].header, - rx_buff[can].data) == HAL_OK) { - if (rx_buff[can].header.FDFormat == FDCAN_CLASSIC_CAN) { - if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { - callback_list[can][CAN_RX_MSG_CALLBACK].fn( - can, rx_buff[can].header.Identifier, rx_buff[can].data, - callback_list[can][CAN_RX_MSG_CALLBACK].arg); - } - } else { - if (callback_list[can][CANFD_RX_MSG_CALLBACK].fn) { - bsp_canfd_data_t data = { - .data = rx_buff[can].data, - .size = DLCtoBytes[rx_buff[can].header.DataLength >> 16U]}; - - callback_list[can][CANFD_RX_MSG_CALLBACK].fn( - can, rx_buff[can].header.Identifier, (uint8_t *)&data, - callback_list[can][CANFD_RX_MSG_CALLBACK].arg); - } - } - } -} - -void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hcan, uint32_t RxFifo0ITs) { - (void)RxFifo0ITs; - can_rx_cb_fn(can_get(hcan)); -} - -bsp_status_t bsp_can_register_callback( - bsp_can_t can, bsp_can_callback_t type, - void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), - void *callback_arg) { - assert_param(callback); - assert_param(type != BSP_CAN_CB_NUM); - - callback_list[can][type].fn = callback; - callback_list[can][type].arg = callback_arg; - return BSP_OK; -} - -bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data) { - FDCAN_TxHeaderTypeDef header; - - header.Identifier = id; - - if (format == CAN_FORMAT_STD) { - header.IdType = FDCAN_STANDARD_ID; - } else { - header.IdType = FDCAN_EXTENDED_ID; - } - - header.TxFrameType = FDCAN_DATA_FRAME; - header.DataLength = FDCAN_DLC_BYTES_8; - header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; - header.BitRateSwitch = FDCAN_BRS_OFF; - header.FDFormat = FDCAN_CLASSIC_CAN; - header.TxEventFifoControl = FDCAN_STORE_TX_EVENTS; - header.MessageMarker = 0x01; - while ((bsp_can_get_handle(can)->Instance->TXFQS & FDCAN_TXFQS_TFQF) != 0U) { - xSemaphoreTake(rx_cplt_wait_sem[can], 1); - } - - return HAL_FDCAN_AddMessageToTxFifoQ(bsp_can_get_handle(can), &header, - data) == HAL_OK - ? BSP_OK - : BSP_ERR; -} - -static const uint32_t FDCAN_PACK_LEN_MAP[16] = { - FDCAN_DLC_BYTES_0, FDCAN_DLC_BYTES_1, FDCAN_DLC_BYTES_2, - FDCAN_DLC_BYTES_3, FDCAN_DLC_BYTES_4, FDCAN_DLC_BYTES_5, - FDCAN_DLC_BYTES_6, FDCAN_DLC_BYTES_7, FDCAN_DLC_BYTES_8, - FDCAN_DLC_BYTES_12, FDCAN_DLC_BYTES_16, FDCAN_DLC_BYTES_20, - FDCAN_DLC_BYTES_24, FDCAN_DLC_BYTES_32, FDCAN_DLC_BYTES_48, - FDCAN_DLC_BYTES_64, -}; - -bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data, size_t size) { - FDCAN_TxHeaderTypeDef header; - - XB_ASSERT(size <= 64); - - header.Identifier = id; - - if (format == CAN_FORMAT_STD) { - header.IdType = FDCAN_STANDARD_ID; - } else { - header.IdType = FDCAN_EXTENDED_ID; - } - - header.TxFrameType = FDCAN_DATA_FRAME; - - if (size <= 8) { - header.DataLength = FDCAN_PACK_LEN_MAP[size]; - } else if (size <= 24) { - header.DataLength = FDCAN_PACK_LEN_MAP[(size - 9) / 4 + 1 + 8]; - } else if (size < 32) { - header.DataLength = FDCAN_DLC_BYTES_32; - } else if (size < 48) { - header.DataLength = FDCAN_DLC_BYTES_48; - } else { - header.DataLength = FDCAN_DLC_BYTES_64; - } - - header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; - header.BitRateSwitch = FDCAN_BRS_ON; - header.FDFormat = FDCAN_FD_CAN; - header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; - header.MessageMarker = 0x00; - while ((bsp_can_get_handle(can)->Instance->TXFQS & FDCAN_TXFQS_TFQF) != 0U) { - xSemaphoreTake(rx_cplt_wait_sem[can], 1); - } - - return HAL_FDCAN_AddMessageToTxFifoQ(bsp_can_get_handle(can), &header, - data) == HAL_OK - ? BSP_OK - : BSP_ERR; -} diff --git a/hw/bsp/atom/drivers/bsp_can.h b/hw/bsp/atom/drivers/bsp_can.h deleted file mode 100644 index bcf82815..00000000 --- a/hw/bsp/atom/drivers/bsp_can.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -typedef enum { - BSP_CAN_1, - BSP_CAN_NUM, - BSP_CAN_ERR, -} bsp_can_t; - -typedef enum { - CAN_RX_MSG_CALLBACK, - CAN_TX_CPLT_CALLBACK, - CANFD_RX_MSG_CALLBACK, - CANFD_TX_CPLT_CALLBACK, - BSP_CAN_CB_NUM -} bsp_can_callback_t; - -typedef enum { - CAN_FORMAT_STD, - CAN_FORMAT_EXT, -} bsp_can_format_t; - -typedef struct { - uint8_t data[8]; -} bsp_can_data_t; - -typedef struct { - size_t size; - uint8_t *data; -} bsp_canfd_data_t; - -void bsp_can_init(void); -bsp_status_t bsp_can_register_callback( - bsp_can_t can, bsp_can_callback_t type, - void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), - void *callback_arg); -bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data); - -bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data, size_t size); - -bsp_status_t bsp_can_get_msg(bsp_can_t can, uint8_t *data, uint32_t *index); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_flash.c b/hw/bsp/atom/drivers/bsp_flash.c deleted file mode 100644 index 4ca75bcd..00000000 --- a/hw/bsp/atom/drivers/bsp_flash.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "bsp_flash.h" - -#include "mf.h" - -bsp_status_t bsp_flash_init() { - mf_init(); - return BSP_OK; -} - -size_t bsp_flash_check_blog(const char *name) { - mf_key_info_t *key = mf_search_key(name); - - if (key) { - return key->data_size; - } else { - return 0; - } -} - -void bsp_flash_get_blog(const char *name, uint8_t *buff, uint32_t len) { - mf_key_info_t *key = mf_search_key(name); - - if (key == NULL) { - return; - } - - if (key->data_size != len) { - return; - } - - memcpy(buff, mf_get_key_data(key), len); -} - -void bsp_flash_set_blog(const char *name, const uint8_t *buff, uint32_t len) { - mf_key_info_t *key = mf_search_key(name); - - if (key != NULL && key->data_size != len) { - return; - } - - mf_add_key(name, (uint8_t *)buff, len); - mf_save(); -} diff --git a/hw/bsp/atom/drivers/bsp_flash.h b/hw/bsp/atom/drivers/bsp_flash.h deleted file mode 100644 index 0928f152..00000000 --- a/hw/bsp/atom/drivers/bsp_flash.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -bsp_status_t bsp_flash_init(); - -size_t bsp_flash_check_blog(const char* name); - -void bsp_flash_get_blog(const char* name, uint8_t* buff, uint32_t len); - -void bsp_flash_set_blog(const char* name, const uint8_t* buff, uint32_t len); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_gpio.c b/hw/bsp/atom/drivers/bsp_gpio.c deleted file mode 100644 index a7aa390a..00000000 --- a/hw/bsp/atom/drivers/bsp_gpio.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "bsp_gpio.h" - -#include "main.h" - -typedef struct { - uint16_t pin; - GPIO_TypeDef *gpio; -} bsp_gpio_map_t; - -static const bsp_gpio_map_t BSP_GPIO_MAP[BSP_GPIO_NUM] = { - {IMU_CS_Pin, IMU_CS_GPIO_Port}, - {IMU_INT1_Pin, IMU_INT1_GPIO_Port}, - {IMU_INT2_Pin, IMU_INT2_GPIO_Port}, - {LED_RUN_Pin, LED_RUN_GPIO_Port}, -}; - -static bsp_callback_t callback_list[16]; - -void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - for (uint8_t i = 0; i < 16; i++) { - if (GPIO_Pin & (1 << i)) { - __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); - bsp_callback_t cb = callback_list[i]; - - if (cb.fn) { - cb.fn(cb.arg); - } - } - } -} - -bsp_status_t bsp_gpio_register_callback(bsp_gpio_t gpio, - void (*callback)(void *), - void *callback_arg) { - assert_param(callback); - - uint16_t pin = BSP_GPIO_MAP[gpio].pin; - - for (uint8_t i = 0; i < 16; i++) { - if (pin & (1 << i)) { - callback_list[i].fn = callback; - callback_list[i].arg = callback_arg; - return BSP_OK; - } - } - return BSP_ERR; -} - -bsp_status_t bsp_gpio_enable_irq(bsp_gpio_t gpio) { - switch (gpio) { - case BSP_GPIO_IMU_INT_1: - HAL_NVIC_EnableIRQ(IMU_INT1_EXTI_IRQn); - break; - - case BSP_GPIO_IMU_INT_2: - HAL_NVIC_EnableIRQ(IMU_INT2_EXTI_IRQn); - break; - /* - case XXX_Pin: - HAL_NVIC_EnableIRQ(XXX_IRQn); - break; - */ - - default: - return BSP_ERR; - } - return BSP_OK; -} - -bsp_status_t bsp_gpio_disable_irq(bsp_gpio_t gpio) { - switch (gpio) { - case BSP_GPIO_IMU_INT_1: - HAL_NVIC_DisableIRQ(IMU_INT1_EXTI_IRQn); - break; - - case BSP_GPIO_IMU_INT_2: - HAL_NVIC_DisableIRQ(IMU_INT2_EXTI_IRQn); - break; - /* - case XXX_Pin: - HAL_NVIC_EnableIRQ(XXX_IRQn); - break; - */ - - default: - return BSP_ERR; - } - return BSP_OK; -} - -inline bsp_status_t bsp_gpio_write_pin(bsp_gpio_t gpio, bool value) { - HAL_GPIO_WritePin(BSP_GPIO_MAP[gpio].gpio, BSP_GPIO_MAP[gpio].pin, value); - return BSP_OK; -} - -inline bool bsp_gpio_read_pin(bsp_gpio_t gpio) { - return HAL_GPIO_ReadPin(BSP_GPIO_MAP[gpio].gpio, BSP_GPIO_MAP[gpio].pin); -} diff --git a/hw/bsp/atom/drivers/bsp_gpio.h b/hw/bsp/atom/drivers/bsp_gpio.h deleted file mode 100644 index b4ed372e..00000000 --- a/hw/bsp/atom/drivers/bsp_gpio.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -typedef enum { - BSP_GPIO_IMU_CS, - BSP_GPIO_IMU_INT_1, - BSP_GPIO_IMU_INT_2, - BSP_GPIO_LED, - BSP_GPIO_NUM, -} bsp_gpio_t; - -bsp_status_t bsp_gpio_register_callback(bsp_gpio_t gpio, - void (*callback)(void *), - void *callback_arg); - -bsp_status_t bsp_gpio_enable_irq(bsp_gpio_t gpio); -bsp_status_t bsp_gpio_disable_irq(bsp_gpio_t gpio); -bsp_status_t bsp_gpio_write_pin(bsp_gpio_t gpio, bool value); -bool bsp_gpio_read_pin(bsp_gpio_t gpio); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_i2c.c b/hw/bsp/atom/drivers/bsp_i2c.c deleted file mode 100644 index a8164b87..00000000 --- a/hw/bsp/atom/drivers/bsp_i2c.c +++ /dev/null @@ -1,149 +0,0 @@ -#include "bsp_i2c.h" - -#include "bsp_def.h" -#include "main.h" -#include "stm32g4xx_hal_i2c.h" - -extern I2C_HandleTypeDef hi2c1; - -static bsp_callback_t callback_list[BSP_I2C_NUM][BSP_I2C_CB_NUM]; - -static bsp_i2c_t i2c_get(I2C_HandleTypeDef *hi2c) { - if (hi2c->Instance == I2C1) { - return BSP_I2C_MAGN; - } - /* - else if (hi2c->Instance == I2CX) - return BSP_I2C_XXX; - */ - else { - return BSP_I2C_ERR; - } -} - -static void bsp_i2c_callback(bsp_i2c_callback_t cb_type, - I2C_HandleTypeDef *hi2c) { - bsp_i2c_t bsp_i2c = i2c_get(hi2c); - if (bsp_i2c != BSP_I2C_ERR) { - bsp_callback_t cb = callback_list[bsp_i2c][cb_type]; - - if (cb.fn) { - cb.fn(cb.arg); - } - } -} - -void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) { - bsp_i2c_callback(BSP_I2C_RX_CPLT_CB, hi2c); -} - -void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c) { - bsp_i2c_callback(BSP_I2C_TX_CPLT_CB, hi2c); -} - -void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) { - bsp_i2c_callback(BSP_I2C_RX_CPLT_CB, hi2c); -} - -void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c) { - bsp_i2c_callback(BSP_I2C_TX_CPLT_CB, hi2c); -} - -I2C_HandleTypeDef *bsp_i2c_get_handle(bsp_i2c_t i2c) { - switch (i2c) { - case BSP_I2C_MAGN: - return &hi2c1; - /* - case BSP_I2C_XXX: - return &hi2cX; - */ - default: - return NULL; - } -} - -bsp_status_t bsp_i2c_register_callback(bsp_i2c_t i2c, bsp_i2c_callback_t type, - void (*callback)(void *), - void *callback_arg) { - assert_param(callback); - assert_param(type != BSP_I2C_CB_NUM); - - callback_list[i2c][type].fn = callback; - callback_list[i2c][type].arg = callback_arg; - return BSP_OK; -} - -bsp_status_t bsp_i2c_transmit(bsp_i2c_t i2c, uint8_t addr, uint8_t *data, - size_t size, bool block) { - if (block) { - return HAL_I2C_Master_Transmit(bsp_i2c_get_handle(i2c), addr, data, size, - 10) == HAL_OK - ? BSP_OK - : BSP_ERR; - } else { - return HAL_I2C_Master_Transmit_DMA(bsp_i2c_get_handle(i2c), addr, data, - size) == HAL_OK - ? BSP_OK - : BSP_ERR; - } -} - -bsp_status_t bsp_i2c_receive(bsp_i2c_t i2c, uint8_t addr, uint8_t *buff, - size_t size, bool block) { - if (block) { - return HAL_I2C_Master_Receive(bsp_i2c_get_handle(i2c), addr, buff, size, - 10) == HAL_OK - ? BSP_OK - : BSP_ERR; - } else { - return HAL_I2C_Master_Receive_DMA(bsp_i2c_get_handle(i2c), addr, buff, - size) == HAL_OK - ? BSP_OK - : BSP_ERR; - } -} - -uint8_t bsp_i2c_mem_read_byte(bsp_i2c_t i2c, uint8_t addr, uint8_t reg) { - uint8_t buff = 0; - HAL_I2C_Mem_Read(bsp_i2c_get_handle(i2c), addr, reg, I2C_MEMADD_SIZE_8BIT, - &buff, 1, 10); - return buff; -} - -bsp_status_t bsp_i2c_mem_write_byte(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t data) { - return HAL_I2C_Mem_Write(bsp_i2c_get_handle(i2c), addr, reg, - I2C_MEMADD_SIZE_8BIT, &data, 1, 10) == HAL_OK - ? BSP_OK - : BSP_ERR; -} - -bsp_status_t bsp_i2c_mem_read(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t *data, size_t size, bool block) { - if (block) { - return HAL_I2C_Mem_Read(bsp_i2c_get_handle(i2c), addr, reg, - I2C_MEMADD_SIZE_8BIT, data, size, 10) == HAL_OK - ? BSP_OK - : BSP_ERR; - } else { - return HAL_I2C_Mem_Read_DMA(bsp_i2c_get_handle(i2c), addr, reg, - I2C_MEMADD_SIZE_8BIT, data, size) == HAL_OK - ? BSP_OK - : BSP_ERR; - } -} - -bsp_status_t bsp_i2c_mem_write(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t *buff, size_t size, bool block) { - if (block) { - return HAL_I2C_Mem_Write(bsp_i2c_get_handle(i2c), addr, reg, - I2C_MEMADD_SIZE_8BIT, buff, size, 10) == HAL_OK - ? BSP_OK - : BSP_ERR; - } else { - return HAL_I2C_Mem_Write_DMA(bsp_i2c_get_handle(i2c), addr, reg, - I2C_MEMADD_SIZE_8BIT, buff, size) == HAL_OK - ? BSP_OK - : BSP_ERR; - } -} diff --git a/hw/bsp/atom/drivers/bsp_i2c.h b/hw/bsp/atom/drivers/bsp_i2c.h deleted file mode 100644 index de175b71..00000000 --- a/hw/bsp/atom/drivers/bsp_i2c.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -/* 要添加使用I2C的新设备,需要先在此添加对应的枚举值 */ - -/* I2C实体枚举,与设备对应 */ -typedef enum { - BSP_I2C_MAGN, - /* BSP_I2C_XXX,*/ - BSP_I2C_NUM, - BSP_I2C_ERR, -} bsp_i2c_t; - -typedef enum { - BSP_I2C_TX_CPLT_CB, - BSP_I2C_RX_CPLT_CB, - BSP_I2C_CB_NUM, -} bsp_i2c_callback_t; - -bsp_status_t bsp_i2c_register_callback(bsp_i2c_t i2c, bsp_i2c_callback_t type, - void (*callback)(void *), - void *callback_arg); -bsp_status_t bsp_i2c_transmit(bsp_i2c_t i2c, uint8_t addr, uint8_t *data, - size_t size, bool block); -bsp_status_t bsp_i2c_receive(bsp_i2c_t i2c, uint8_t addr, uint8_t *buff, - size_t size, bool block); -uint8_t bsp_i2c_mem_read_byte(bsp_i2c_t i2c, uint8_t addr, uint8_t reg); -bsp_status_t bsp_i2c_mem_write_byte(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t data); -bsp_status_t bsp_i2c_mem_read(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t *data, size_t size, bool block); -bsp_status_t bsp_i2c_mem_write(bsp_i2c_t i2c, uint8_t addr, uint8_t reg, - uint8_t *buff, size_t size, bool block); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_spi.c b/hw/bsp/atom/drivers/bsp_spi.c deleted file mode 100644 index 0e7c7716..00000000 --- a/hw/bsp/atom/drivers/bsp_spi.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "bsp_spi.h" - -#include "main.h" - -extern SPI_HandleTypeDef hspi1; - -static bsp_callback_t callback_list[BSP_SPI_NUM][BSP_SPI_CB_NUM]; - -static bsp_spi_t spi_get(SPI_HandleTypeDef *hspi) { - if (hspi->Instance == SPI1) { - return BSP_SPI_IMU; - } - /* - else if (hspi->Instance == SPIX) - return BSP_SPI_XXX; - */ - else { - return BSP_SPI_ERR; - } -} - -static void bsp_spi_callback(bsp_spi_callback_t cb_type, - SPI_HandleTypeDef *hspi) { - bsp_spi_t bsp_spi = spi_get(hspi); - if (bsp_spi != BSP_SPI_ERR) { - bsp_callback_t cb = callback_list[bsp_spi][cb_type]; - - if (cb.fn) { - cb.fn(cb.arg); - } - } -} - -void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) { - bsp_spi_callback(BSP_SPI_RX_CPLT_CB, hspi); -} - -void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) { - bsp_spi_callback(BSP_SPI_TX_CPLT_CB, hspi); -} - -SPI_HandleTypeDef *bsp_spi_get_handle(bsp_spi_t spi) { - switch (spi) { - case BSP_SPI_IMU: - return &hspi1; - /* - case BSP_SPI_XXX: - return &hspiX; - */ - default: - return NULL; - } -} - -bsp_status_t bsp_spi_register_callback(bsp_spi_t spi, bsp_spi_callback_t type, - void (*callback)(void *), - void *callback_arg) { - assert_param(callback); - assert_param(type != BSP_SPI_CB_NUM); - - callback_list[spi][type].fn = callback; - callback_list[spi][type].arg = callback_arg; - return BSP_OK; -} - -bsp_status_t bsp_spi_transmit_receive(bsp_spi_t spi, uint8_t *recv_data, - const uint8_t *trans_data, size_t size, - bool block) { - if (block) { - return HAL_SPI_TransmitReceive(bsp_spi_get_handle(spi), - (uint8_t *)trans_data, recv_data, size, - 10) != HAL_OK; - } else { - return HAL_SPI_TransmitReceive_DMA(bsp_spi_get_handle(spi), - (uint8_t *)trans_data, recv_data, - size) != HAL_OK; - } -} - -bsp_status_t bsp_spi_transmit(bsp_spi_t spi, const uint8_t *data, size_t size, - bool block) { - if (block) { - return HAL_SPI_Transmit(bsp_spi_get_handle(spi), (uint8_t *)data, size, - 10) != HAL_OK; - } else { - return HAL_SPI_Transmit_DMA(bsp_spi_get_handle(spi), (uint8_t *)data, - size) != HAL_OK; - } -} - -bsp_status_t bsp_spi_receive(bsp_spi_t spi, uint8_t *buff, size_t size, - bool block) { - if (block) { - return HAL_SPI_Receive(bsp_spi_get_handle(spi), buff, size, 10) != HAL_OK; - } else { - return HAL_SPI_Receive_DMA(bsp_spi_get_handle(spi), buff, size) != HAL_OK; - } -} - -uint8_t bsp_spi_mem_read_byte(bsp_spi_t spi, uint8_t reg) { - uint8_t tmp[2] = {reg | 0x80, 0x00}; - bsp_spi_transmit_receive(spi, tmp, tmp, 2u, true); - return tmp[1]; -} - -bsp_status_t bsp_spi_mem_write_byte(bsp_spi_t spi, uint8_t reg, uint8_t data) { - uint8_t tmp[2] = {reg & 0x7f, data}; - return bsp_spi_transmit(spi, tmp, 2u, true); -} - -bsp_status_t bsp_spi_mem_read(bsp_spi_t spi, uint8_t reg, uint8_t *buff, - size_t size, bool block) { - reg = reg | 0x80; - bsp_spi_transmit(spi, ®, 1u, true); - return bsp_spi_receive(spi, buff, size, block); -} - -bsp_status_t bsp_spi_mem_write(bsp_spi_t spi, uint8_t reg, const uint8_t *buff, - size_t size, bool block) { - reg = reg & 0x7f; - bsp_spi_transmit(spi, ®, 1u, true); - return bsp_spi_transmit(spi, buff, size, block); -} diff --git a/hw/bsp/atom/drivers/bsp_spi.h b/hw/bsp/atom/drivers/bsp_spi.h deleted file mode 100644 index 136126f6..00000000 --- a/hw/bsp/atom/drivers/bsp_spi.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -/* 要添加使用SPI的新设备,需要先在此添加对应的枚举值 */ - -/* SPI实体枚举,与设备对应 */ -typedef enum { - BSP_SPI_IMU, - /* BSP_SPI_XXX,*/ - BSP_SPI_NUM, - BSP_SPI_ERR, -} bsp_spi_t; - -typedef enum { - BSP_SPI_TX_CPLT_CB, - BSP_SPI_RX_CPLT_CB, - BSP_SPI_CB_NUM, -} bsp_spi_callback_t; - -bsp_status_t bsp_spi_register_callback(bsp_spi_t spi, bsp_spi_callback_t type, - void (*callback)(void *), - void *callback_arg); -bsp_status_t bsp_spi_transmit_receive(bsp_spi_t spi, uint8_t *recv_data, - const uint8_t *trans_data, size_t size, - bool block); -bsp_status_t bsp_spi_transmit(bsp_spi_t spi, const uint8_t *data, size_t size, - bool block); -bsp_status_t bsp_spi_receive(bsp_spi_t spi, uint8_t *buff, size_t size, - bool block); -uint8_t bsp_spi_mem_read_byte(bsp_spi_t spi, uint8_t reg); -bsp_status_t bsp_spi_mem_write_byte(bsp_spi_t spi, uint8_t reg, uint8_t data); -bsp_status_t bsp_spi_mem_read(bsp_spi_t spi, uint8_t reg, uint8_t *buff, - size_t size, bool block); -bsp_status_t bsp_spi_mem_write(bsp_spi_t spi, uint8_t reg, const uint8_t *buff, - size_t size, bool block); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_sys.h b/hw/bsp/atom/drivers/bsp_sys.h deleted file mode 100644 index fcc00a91..00000000 --- a/hw/bsp/atom/drivers/bsp_sys.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "bsp_def.h" -#include "main.h" - -/* 软件复位 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_reset(void) { - __set_FAULTMASK(1); - NVIC_SystemReset(); -} - -/* 关机 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_shutdown( - void) { - HAL_PWR_EnterSTANDBYMode(); -} - -/* 睡眠模式 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_sleep(void) { - HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); -} - -/* 停止模式 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_stop(void) { - HAL_PWR_EnterSTANDBYMode(); -} - -/* 中断状态 */ -__attribute__((always_inline, unused)) static inline bool bsp_sys_in_isr(void) { - uint32_t result; - __asm__ volatile("MRS %0, ipsr" : "=r"(result)); - return (result); -} diff --git a/hw/bsp/atom/drivers/bsp_time.c b/hw/bsp/atom/drivers/bsp_time.c deleted file mode 100644 index 5ad74d58..00000000 --- a/hw/bsp/atom/drivers/bsp_time.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "bsp_time.h" - -#include "FreeRTOS.h" -#include "main.h" -#include "task.h" - -uint32_t bsp_time_get_ms() { return xTaskGetTickCount(); } - -uint64_t bsp_time_get_us() { - uint32_t ms_old = xTaskGetTickCount(); - uint32_t tick_value_old = SysTick->VAL; - uint32_t ms_new = xTaskGetTickCount(); - uint32_t tick_value_new = SysTick->VAL; - if (ms_old == ms_new) { - return ms_new * 1000 + 1000 - tick_value_old * 1000 / (SysTick->LOAD + 1); - } else { - return ms_new * 1000 + 1000 - tick_value_new * 1000 / (SysTick->LOAD + 1); - } -} - -uint64_t bsp_time_get() __attribute__((alias("bsp_time_get_us"))); diff --git a/hw/bsp/atom/drivers/bsp_time.h b/hw/bsp/atom/drivers/bsp_time.h deleted file mode 100644 index 55c2485e..00000000 --- a/hw/bsp/atom/drivers/bsp_time.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -uint32_t bsp_time_get_ms(); - -uint64_t bsp_time_get_us(); - -uint64_t bsp_time_get(); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_uart.c b/hw/bsp/atom/drivers/bsp_uart.c deleted file mode 100644 index dc635428..00000000 --- a/hw/bsp/atom/drivers/bsp_uart.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "bsp_uart.h" - -#include "main.h" -#include "stm32g4xx_hal_dma.h" -#include "stm32g4xx_it.h" - -extern UART_HandleTypeDef huart2; -extern DMA_HandleTypeDef hdma_usart2_rx; -extern DMA_HandleTypeDef hdma_usart2_tx; - -static bsp_callback_t callback_list[BSP_UART_NUM][BSP_UART_CB_NUM]; - -static bsp_uart_t uart_get(UART_HandleTypeDef *huart) { - if (huart->Instance == USART2) { - return BSP_UART_MCU; - } /* - else if (huart->Instance == USARTX) - return BSP_UART_XXX; - */ - else { - return BSP_UART_ERR; - } -} - -static void bsp_uart_callback(bsp_uart_callback_t cb_type, - UART_HandleTypeDef *huart) { - bsp_uart_t bsp_uart = uart_get(huart); - if (bsp_uart != BSP_UART_ERR) { - bsp_callback_t cb = callback_list[bsp_uart][cb_type]; - - if (cb.fn) { - cb.fn(cb.arg); - } - } -} - -void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_TX_CPLT_CB, huart); -} - -void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_TX_HALF_CPLT_CB, huart); -} - -void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_RX_CPLT_CB, huart); -} - -void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_RX_HALF_CPLT_CB, huart); -} - -void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_ERROR_CB, huart); -} - -void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_ABORT_CPLT_CB, huart); -} - -void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_ABORT_TX_CPLT_CB, huart); -} - -void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart) { - bsp_uart_callback(BSP_UART_ABORT_RX_CPLT_CB, huart); -} - -void bsp_uart_irq_handler(UART_HandleTypeDef *huart) { - if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE)) { - __HAL_UART_CLEAR_IDLEFLAG(huart); - bsp_uart_callback(BSP_UART_IDLE_LINE_CB, huart); - } -} - -UART_HandleTypeDef *bsp_uart_get_handle(bsp_uart_t uart) { - switch (uart) { - case BSP_UART_MCU: - return &huart2; - /* - case BSP_UART_XXX: - return &huartX; - */ - default: - return NULL; - } -} - -void bsp_uart_init() { - HAL_UART_RegisterUserCallback(bsp_uart_irq_handler); - __HAL_UART_ENABLE_IT(bsp_uart_get_handle(BSP_UART_MCU), UART_IT_IDLE); -} - -bsp_status_t bsp_uart_register_callback(bsp_uart_t uart, - bsp_uart_callback_t type, - void (*callback)(void *), - void *callback_arg) { - assert_param(callback); - assert_param(type != BSP_UART_CB_NUM); - - callback_list[uart][type].fn = callback; - callback_list[uart][type].arg = callback_arg; - return BSP_OK; -} - -bsp_status_t bsp_uart_transmit(bsp_uart_t uart, uint8_t *data, size_t size, - bool block) { - if (block) { - return HAL_UART_Transmit(bsp_uart_get_handle(uart), data, size, 10) != - HAL_OK; - } else { - return HAL_UART_Transmit_DMA(bsp_uart_get_handle(uart), data, size) != - HAL_OK; - } -} - -bsp_status_t bsp_uart_receive(bsp_uart_t uart, uint8_t *buff, size_t size, - bool block) { - if (block) { - return HAL_UART_Receive(bsp_uart_get_handle(uart), buff, size, 10) != - HAL_OK; - } else { - return HAL_UART_Receive_DMA(bsp_uart_get_handle(uart), buff, size) != - HAL_OK; - } -} - -uint32_t bsp_uart_get_count(bsp_uart_t uart) { - return bsp_uart_get_handle(uart)->RxXferSize - - __HAL_DMA_GET_COUNTER(bsp_uart_get_handle(BSP_UART_MCU)->hdmarx); -} - -bsp_status_t bsp_uart_abort_receive(bsp_uart_t uart) { - HAL_UART_AbortReceive_IT(bsp_uart_get_handle(uart)); - - return BSP_OK; -} diff --git a/hw/bsp/atom/drivers/bsp_uart.h b/hw/bsp/atom/drivers/bsp_uart.h deleted file mode 100644 index 5bd45ddd..00000000 --- a/hw/bsp/atom/drivers/bsp_uart.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" -#include "main.h" - -/* 要添加使用UART的新设备,需要先在此添加对应的枚举值 */ - -/* UART实体枚举,与设备对应 */ -typedef enum { - BSP_UART_MCU, - /* BSP_UART_XXX, */ - BSP_UART_NUM, - BSP_UART_ERR, -} bsp_uart_t; - -/* UART支持的中断回调函数类型,具体参考HAL中定义 */ -typedef enum { - BSP_UART_TX_HALF_CPLT_CB, - BSP_UART_TX_CPLT_CB, - BSP_UART_RX_HALF_CPLT_CB, - BSP_UART_RX_CPLT_CB, - BSP_UART_ERROR_CB, - BSP_UART_ABORT_CPLT_CB, - BSP_UART_ABORT_TX_CPLT_CB, - BSP_UART_ABORT_RX_CPLT_CB, - BSP_UART_IDLE_LINE_CB, - BSP_UART_CB_NUM, -} bsp_uart_callback_t; - -void bsp_uart_init(); -uint32_t bsp_uart_get_count(bsp_uart_t uart); -bsp_status_t bsp_uart_register_callback(bsp_uart_t uart, - bsp_uart_callback_t type, - void (*callback)(void *), - void *callback_arg); -bsp_status_t bsp_uart_transmit(bsp_uart_t uart, uint8_t *data, size_t size, - bool block); -bsp_status_t bsp_uart_receive(bsp_uart_t uart, uint8_t *buff, size_t size, - bool block); -bsp_status_t bsp_uart_abort_receive(bsp_uart_t uart); -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/bsp_usb.c b/hw/bsp/atom/drivers/bsp_usb.c deleted file mode 100644 index 60838738..00000000 --- a/hw/bsp/atom/drivers/bsp_usb.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "bsp_usb.h" - -#include "FreeRTOS.h" -#include "bsp_def.h" -#include "bsp_uart.h" -#include "main.h" -#include "portmacro.h" -#include "semphr.h" - -static SemaphoreHandle_t sem; - -static uint8_t usb_rx_buff[100] = {0}, usb_buff_len = 0, usb_buff_index = 0; - -static volatile bool connected = false, avail = false; - -static void uart_tx_cb(void *arg) { - XB_UNUSED(arg); - BaseType_t px_higher_priority_task_woken = 0; - xSemaphoreGiveFromISR(sem, &px_higher_priority_task_woken); - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } -} - -bsp_status_t bsp_usb_transmit(const uint8_t *buffer, uint32_t len) { - bsp_uart_transmit(BSP_UART_MCU, (uint8_t *)(buffer), len, false); - xSemaphoreTake(sem, 10); - return BSP_OK; -} - -char bsp_usb_read_char(void) { - if (avail) { - char data = usb_rx_buff[usb_buff_index++]; - if (usb_buff_index >= usb_buff_len) { - avail = false; - } - return data; - } else { - return 0; - } -} - -size_t bsp_usb_read(uint8_t *buffer, uint32_t len) { - if (avail) { - uint32_t count = 0; - while (usb_buff_index < usb_buff_len && count < len) { - buffer[count++] = usb_rx_buff[usb_buff_index++]; - } - - return count; - } else { - return 0; - } -} - -bool bsp_usb_connect(void) { return connected; } - -size_t bsp_usb_avail(void) { return avail; } - -static void uart_rx_cb(void *arg) { - (void)(arg); - if (!connected) { - connected = true; - bsp_uart_abort_receive(BSP_UART_MCU); - bsp_uart_receive(BSP_UART_MCU, usb_rx_buff, sizeof(usb_rx_buff), false); - return; - } - usb_buff_len = bsp_uart_get_count(BSP_UART_MCU); - usb_buff_index = 0; - avail = true; - bsp_uart_abort_receive(BSP_UART_MCU); - bsp_uart_receive(BSP_UART_MCU, usb_rx_buff, sizeof(usb_rx_buff), false); -} - -void bsp_usb_init() { - bsp_uart_register_callback(BSP_UART_MCU, BSP_UART_IDLE_LINE_CB, uart_rx_cb, - NULL); - bsp_uart_register_callback(BSP_UART_MCU, BSP_UART_TX_CPLT_CB, uart_tx_cb, - NULL); - bsp_uart_receive(BSP_UART_MCU, usb_rx_buff, sizeof(usb_rx_buff), false); - - sem = xSemaphoreCreateBinary(); -} - -void bsp_usb_update() {} diff --git a/hw/bsp/atom/drivers/bsp_usb.h b/hw/bsp/atom/drivers/bsp_usb.h deleted file mode 100644 index ccc8097e..00000000 --- a/hw/bsp/atom/drivers/bsp_usb.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -/* Exported constants ------------------------------------------------------- */ -/* Exported macro ----------------------------------------------------------- */ -/* Exported types ----------------------------------------------------------- */ - -typedef enum { - BSP_USB_CDC, - /* BSP_USB_XXX, */ - BSP_USB_NUM, - BSP_USB_ERR, -} bsp_usb_t; - -/* USB支持的中断回调函数类型 */ -typedef enum { - BSP_USB_RX_CPLT_CB, - BSP_USB_CB_NUM, -} bsp_usb_callback_t; -/* Exported functions prototypes -------------------------------------------- */ -bool bsp_usb_connect(void); /* USB已连接 */ -size_t bsp_usb_avail(void); /* USB有数据 */ -char bsp_usb_read_char(); /* 获取缓存数据 */ -size_t bsp_usb_read(uint8_t *buffer, uint32_t len); -bsp_status_t bsp_usb_transmit(const uint8_t *buffer, uint32_t len); -void bsp_usb_init(void); -void bsp_usb_update(void); - -bsp_status_t bsp_usb_register_callback(bsp_usb_t usb, bsp_usb_callback_t type, - void (*callback)(void *), - void *callback_arg); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom/drivers/flash/CMakeLists.txt b/hw/bsp/atom/drivers/flash/CMakeLists.txt deleted file mode 100644 index c390df7a..00000000 --- a/hw/bsp/atom/drivers/flash/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -add_subdirectory(${LIB_DIR}/MiniFlashDB mf.out) - -project(flash) - -add_compile_options(-w) - -add_library(${PROJECT_NAME} STATIC) - -target_sources(${PROJECT_NAME} - PRIVATE ${${PROJECT_NAME}_SOURCES} -) - -target_link_libraries(${PROJECT_NAME} - PUBLIC hal - PUBLIC MiniFlash -) - -target_include_directories(MiniFlash - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ -) - -target_include_directories(${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ - PUBLIC $ -) - -add_dependencies(${PROJECT_NAME} - hal - MiniFlash -) diff --git a/hw/bsp/atom/drivers/flash/mf_config.h b/hw/bsp/atom/drivers/flash/mf_config.h deleted file mode 100644 index 2688cadd..00000000 --- a/hw/bsp/atom/drivers/flash/mf_config.h +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - -#include "stm32g4xx_hal.h" - -/* 一块FLASH空间的大小 */ -#define MF_FLASH_BLOCK_SIZE (2048) - -/* 主FLASH地址 */ -#define MF_FLASH_MAIN_ADDR (0x0801F000) - -/* 备份FLASH地址 */ -#define MF_FLASH_BACKUP_ADDR (0x0801F000 + MF_FLASH_BLOCK_SIZE) - -/* Flash读写函数 */ -#define MF_ERASE mf_erase -#define MF_WRITE mf_write - -__attribute__((unused)) static void mf_erase(uint32_t addr) { - FLASH_EraseInitTypeDef flash_erase; - - uint32_t sector_error = 0; - - HAL_FLASH_Unlock(); - - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); - - /* You can add your code under here. */ - flash_erase.NbPages = 1; - flash_erase.Banks = FLASH_BANK_1; - flash_erase.Page = (addr - FLASH_BASE) / FLASH_PAGE_SIZE; - flash_erase.TypeErase = FLASH_TYPEERASE_PAGES; - - /* Erase FLASH*/ - HAL_FLASHEx_Erase(&flash_erase, §or_error); - - HAL_FLASH_Lock(); -} - -__attribute__((unused)) static void mf_write(uint32_t addr, void *buf) { - uint32_t startaddr = 0; - uint8_t *data = buf; - - if (HAL_FLASH_Unlock() != HAL_OK) { - return; - } - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); - - startaddr = addr; - - /* HW needs an aligned addr to program flash, which data - * parameters doesn't ensure */ - /* case where data is aligned, so let's avoid any copy */ - while ((addr < (startaddr + MF_FLASH_BLOCK_SIZE))) { - if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, addr, - *((uint64_t *)data)) == HAL_OK) { - addr = addr + 8; - data = data + 8; - } else { - break; - } - } - - HAL_FLASH_Lock(); -} diff --git a/hw/bsp/atom/drivers/hal/.mxproject b/hw/bsp/atom/drivers/hal/.mxproject deleted file mode 100644 index 6b0e6b7b..00000000 --- a/hw/bsp/atom/drivers/hal/.mxproject +++ /dev/null @@ -1,26 +0,0 @@ -[PreviousLibFiles] -LibFiles=Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_spi.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_spi_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_usart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_lpuart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart_ex.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_spi.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_spi_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_usart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_lpuart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart_ex.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g431xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/system_stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_armv81mml.h; - -[PreviousUsedMakefileFiles] -SourceFiles=Core/Src/main.c;Core/Src/stm32g4xx_it.c;Core/Src/stm32g4xx_hal_msp.c;Core/Src/stm32g4xx_hal_timebase_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;;; -HeaderPath=/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Include;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Include;Core/Inc; -CDefines=USE_HAL_DRIVER;STM32G431xx;USE_HAL_DRIVER;USE_HAL_DRIVER; - -[PreviousGenFiles] -AdvancedFolderStructure=true -HeaderFileListSize=3 -HeaderFiles#0=../Core/Inc/stm32g4xx_it.h -HeaderFiles#1=../Core/Inc/stm32g4xx_hal_conf.h -HeaderFiles#2=../Core/Inc/main.h -HeaderFolderListSize=1 -HeaderPath#0=../Core/Inc -HeaderFiles=; -SourceFileListSize=4 -SourceFiles#0=../Core/Src/stm32g4xx_it.c -SourceFiles#1=../Core/Src/stm32g4xx_hal_msp.c -SourceFiles#2=../Core/Src/stm32g4xx_hal_timebase_tim.c -SourceFiles#3=../Core/Src/main.c -SourceFolderListSize=1 -SourcePath#0=../Core/Src -SourceFiles=; - diff --git a/hw/bsp/atom/drivers/hal/CMakeLists.txt b/hw/bsp/atom/drivers/hal/CMakeLists.txt deleted file mode 100644 index 1a7d8893..00000000 --- a/hw/bsp/atom/drivers/hal/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -add_compile_options(-w) - -project(hal) - -file(GLOB ${PROJECT_NAME}_SOURCES_MX "${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/*.c") -file(GLOB ${PROJECT_NAME}_SOURCES_HAL "${HAL_DIR}/Src/*.c") - -list(FILTER ${PROJECT_NAME}_SOURCES_HAL EXCLUDE REGEX ".*template.c$") -list(FILTER ${PROJECT_NAME}_SOURCES_MX EXCLUDE REGEX "system_stm32g4xx.c$") - -add_library(${PROJECT_NAME} OBJECT) - -target_sources( - ${PROJECT_NAME} - PRIVATE ${${PROJECT_NAME}_SOURCES_HAL} - PRIVATE ${${PROJECT_NAME}_SOURCES_MX} - PRIVATE ${STM32_CMSIS_DIR}/Source/Templates/system_stm32g4xx.c - PRIVATE ${STM32_CMSIS_DIR}/Source/Templates/gcc/startup_stm32g431xx.s) - -target_include_directories( - ${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core/Src - PUBLIC ${HAL_DIR}/Inc - PUBLIC ${STM32_CMSIS_DIR}/Include - PUBLIC ${ARM_CMSIS_DIR}/CMSIS/Core/Include - PRIVATE $) diff --git a/hw/bsp/atom/drivers/hal/Core/Inc/main.h b/hw/bsp/atom/drivers/hal/Core/Inc/main.h deleted file mode 100644 index 867add5b..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Inc/main.h +++ /dev/null @@ -1,85 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); -void MX_GPIO_Init(void); -void MX_DMA_Init(void); -void MX_FDCAN1_Init(void); -void MX_I2C1_Init(void); -void MX_SPI1_Init(void); -void MX_USART2_UART_Init(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define IMU_INT1_Pin GPIO_PIN_0 -#define IMU_INT1_GPIO_Port GPIOA -#define IMU_INT1_EXTI_IRQn EXTI0_IRQn -#define IMU_INT2_Pin GPIO_PIN_1 -#define IMU_INT2_GPIO_Port GPIOA -#define IMU_INT2_EXTI_IRQn EXTI1_IRQn -#define IMU_CS_Pin GPIO_PIN_4 -#define IMU_CS_GPIO_Port GPIOA -#define LED_RUN_Pin GPIO_PIN_0 -#define LED_RUN_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ -void SystemClock_Config(void); -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/hw/bsp/atom/drivers/hal/Core/Inc/stm32_assert.h b/hw/bsp/atom/drivers/hal/Core/Inc/stm32_assert.h deleted file mode 100644 index 5dcf42f7..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Inc/stm32_assert.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_assert.h - * @author MCD Application Team - * @brief STM32 assert file. - * This file should be copied to the application folder and renamed - * to stm32_assert.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32_ASSERT_H -#define __STM32_ASSERT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Includes ------------------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) \ - ((expr) ? (void)0U : assert_failed((uint8_t*)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t* file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32_ASSERT_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h b/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 901123f5..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,380 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - - /*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -/*#define HAL_CRC_MODULE_ENABLED */ -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -/*#define HAL_SRAM_MODULE_ENABLED */ -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high precision clock to - * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. - * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency - * which is subject to manufacturing process variations. - */ -#if !defined (HSI48_VALUE) - #define HSI48_VALUE (48000000UL) /*!< Value of the Internal High Speed oscillator for USB FS/RNG in Hz. - The real value my vary depending on manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system frequency - */ -#if !defined (LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S and SAI clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_it.h b/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b8a73c80..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,78 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "main.h" -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void DebugMon_Handler(void); -void EXTI0_IRQHandler(void); -void EXTI1_IRQHandler(void); -void DMA1_Channel1_IRQHandler(void); -void DMA1_Channel2_IRQHandler(void); -void DMA1_Channel3_IRQHandler(void); -void DMA1_Channel4_IRQHandler(void); -void DMA1_Channel5_IRQHandler(void); -void DMA1_Channel6_IRQHandler(void); -void FDCAN1_IT0_IRQHandler(void); -void FDCAN1_IT1_IRQHandler(void); -void TIM1_BRK_TIM15_IRQHandler(void); -void I2C1_EV_IRQHandler(void); -void SPI1_IRQHandler(void); -void USART2_IRQHandler(void); -void DMA2_Channel1_IRQHandler(void); -void DMA2_Channel2_IRQHandler(void); -/* USER CODE BEGIN EFP */ -void HAL_UART_RegisterUserCallback(void (*fn)(UART_HandleTypeDef *huart)); -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/hw/bsp/atom/drivers/hal/Core/Src/main.c b/hw/bsp/atom/drivers/hal/Core/Src/main.c deleted file mode 100644 index 631b86c9..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Src/main.c +++ /dev/null @@ -1,500 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -FDCAN_HandleTypeDef hfdcan1; - -I2C_HandleTypeDef hi2c1; -DMA_HandleTypeDef hdma_i2c1_rx; -DMA_HandleTypeDef hdma_i2c1_tx; - -SPI_HandleTypeDef hspi1; -DMA_HandleTypeDef hdma_spi1_rx; -DMA_HandleTypeDef hdma_spi1_tx; - -UART_HandleTypeDef huart1; -UART_HandleTypeDef huart2; -DMA_HandleTypeDef hdma_usart1_rx; -DMA_HandleTypeDef hdma_usart1_tx; -DMA_HandleTypeDef hdma_usart2_rx; -DMA_HandleTypeDef hdma_usart2_tx; - -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_USART1_UART_Init(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - - /** Configure the main internal regulator output voltage - */ - HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST); - - /** Initializes the RCC Oscillators according to the specified parameters - * in the RCC_OscInitTypeDef structure. - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; - RCC_OscInitStruct.HSIState = RCC_HSI_ON; - RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; - RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4; - RCC_OscInitStruct.PLL.PLLN = 80; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; - RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - Error_Handler(); - } - - /** Initializes the CPU, AHB and APB buses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) - { - Error_Handler(); - } -} - -/** - * @brief FDCAN1 Initialization Function - * @param None - * @retval None - */ -void MX_FDCAN1_Init(void) -{ - - /* USER CODE BEGIN FDCAN1_Init 0 */ - - /* USER CODE END FDCAN1_Init 0 */ - - /* USER CODE BEGIN FDCAN1_Init 1 */ - - /* USER CODE END FDCAN1_Init 1 */ - hfdcan1.Instance = FDCAN1; - hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1; - hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS; - hfdcan1.Init.Mode = FDCAN_MODE_NORMAL; - hfdcan1.Init.AutoRetransmission = ENABLE; - hfdcan1.Init.TransmitPause = DISABLE; - hfdcan1.Init.ProtocolException = DISABLE; - hfdcan1.Init.NominalPrescaler = 10; - hfdcan1.Init.NominalSyncJumpWidth = 16; - hfdcan1.Init.NominalTimeSeg1 = 13; - hfdcan1.Init.NominalTimeSeg2 = 2; - hfdcan1.Init.DataPrescaler = 2; - hfdcan1.Init.DataSyncJumpWidth = 16; - hfdcan1.Init.DataTimeSeg1 = 13; - hfdcan1.Init.DataTimeSeg2 = 2; - hfdcan1.Init.StdFiltersNbr = 2; - hfdcan1.Init.ExtFiltersNbr = 2; - hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN FDCAN1_Init 2 */ - - /* USER CODE END FDCAN1_Init 2 */ - -} - -/** - * @brief I2C1 Initialization Function - * @param None - * @retval None - */ -void MX_I2C1_Init(void) -{ - - /* USER CODE BEGIN I2C1_Init 0 */ - - /* USER CODE END I2C1_Init 0 */ - - /* USER CODE BEGIN I2C1_Init 1 */ - - /* USER CODE END I2C1_Init 1 */ - hi2c1.Instance = I2C1; - hi2c1.Init.Timing = 0x00F07BFF; - hi2c1.Init.OwnAddress1 = 0; - hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - hi2c1.Init.OwnAddress2 = 0; - hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; - hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - if (HAL_I2C_Init(&hi2c1) != HAL_OK) - { - Error_Handler(); - } - - /** Configure Analogue filter - */ - if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) - { - Error_Handler(); - } - - /** Configure Digital filter - */ - if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN I2C1_Init 2 */ - - /* USER CODE END I2C1_Init 2 */ - -} - -/** - * @brief SPI1 Initialization Function - * @param None - * @retval None - */ -void MX_SPI1_Init(void) -{ - - /* USER CODE BEGIN SPI1_Init 0 */ - - /* USER CODE END SPI1_Init 0 */ - - /* USER CODE BEGIN SPI1_Init 1 */ - - /* USER CODE END SPI1_Init 1 */ - /* SPI1 parameter configuration*/ - hspi1.Instance = SPI1; - hspi1.Init.Mode = SPI_MODE_MASTER; - hspi1.Init.Direction = SPI_DIRECTION_2LINES; - hspi1.Init.DataSize = SPI_DATASIZE_8BIT; - hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; - hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi1.Init.TIMode = SPI_TIMODE_DISABLE; - hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi1.Init.CRCPolynomial = 7; - hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; - hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; - if (HAL_SPI_Init(&hspi1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI1_Init 2 */ - - /* USER CODE END SPI1_Init 2 */ - -} - -/** - * @brief USART1 Initialization Function - * @param None - * @retval None - */ -static void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - huart1.Instance = USART1; - huart1.Init.BaudRate = 115200; - huart1.Init.WordLength = UART_WORDLENGTH_8B; - huart1.Init.StopBits = UART_STOPBITS_1; - huart1.Init.Parity = UART_PARITY_NONE; - huart1.Init.Mode = UART_MODE_TX_RX; - huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart1.Init.OverSampling = UART_OVERSAMPLING_16; - huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; - huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart1) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ - -} - -/** - * @brief USART2 Initialization Function - * @param None - * @retval None - */ -void MX_USART2_UART_Init(void) -{ - - /* USER CODE BEGIN USART2_Init 0 */ - - /* USER CODE END USART2_Init 0 */ - - /* USER CODE BEGIN USART2_Init 1 */ - - /* USER CODE END USART2_Init 1 */ - huart2.Instance = USART2; - huart2.Init.BaudRate = 1000000; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX_RX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1; - huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart2) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART2_Init 2 */ - - /* USER CODE END USART2_Init 2 */ - -} - -/** - * Enable DMA controller clock - */ -void MX_DMA_Init(void) -{ - - /* DMA controller clock enable */ - __HAL_RCC_DMAMUX1_CLK_ENABLE(); - __HAL_RCC_DMA1_CLK_ENABLE(); - __HAL_RCC_DMA2_CLK_ENABLE(); - - /* DMA interrupt init */ - /* DMA1_Channel1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); - /* DMA1_Channel2_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn); - /* DMA1_Channel3_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn); - /* DMA1_Channel4_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn); - /* DMA1_Channel5_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn); - /* DMA1_Channel6_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn); - /* DMA2_Channel1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Channel1_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA2_Channel1_IRQn); - /* DMA2_Channel2_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Channel2_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA2_Channel2_IRQn); - -} - -/** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ -void MX_GPIO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; -/* USER CODE BEGIN MX_GPIO_Init_1 */ -/* USER CODE END MX_GPIO_Init_1 */ - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(IMU_CS_GPIO_Port, IMU_CS_Pin, GPIO_PIN_SET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LED_RUN_GPIO_Port, LED_RUN_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pins : IMU_INT1_Pin IMU_INT2_Pin */ - GPIO_InitStruct.Pin = IMU_INT1_Pin|IMU_INT2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pin : IMU_CS_Pin */ - GPIO_InitStruct.Pin = IMU_CS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(IMU_CS_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : LED_RUN_Pin */ - GPIO_InitStruct.Pin = LED_RUN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_RUN_GPIO_Port, &GPIO_InitStruct); - - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI0_IRQn); - - HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI1_IRQn); - -/* USER CODE BEGIN MX_GPIO_Init_2 */ -/* USER CODE END MX_GPIO_Init_2 */ -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief Period elapsed callback in non blocking mode - * @note This function is called when TIM15 interrupt took place, inside - * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment - * a global variable "uwTick" used as application time base. - * @param htim : TIM handle - * @retval None - */ -void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) -{ - /* USER CODE BEGIN Callback 0 */ - - /* USER CODE END Callback 0 */ - if (htim->Instance == TIM15) { - HAL_IncTick(); - } - /* USER CODE BEGIN Callback 1 */ - - /* USER CODE END Callback 1 */ -} - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - __disable_irq(); - while (1) { - } - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, - line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_msp.c b/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index f25e4003..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,641 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ -extern DMA_HandleTypeDef hdma_i2c1_rx; - -extern DMA_HandleTypeDef hdma_i2c1_tx; - -extern DMA_HandleTypeDef hdma_spi1_rx; - -extern DMA_HandleTypeDef hdma_spi1_tx; - -extern DMA_HandleTypeDef hdma_usart1_rx; - -extern DMA_HandleTypeDef hdma_usart1_tx; - -extern DMA_HandleTypeDef hdma_usart2_rx; - -extern DMA_HandleTypeDef hdma_usart2_tx; - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - /* PendSV_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/** -* @brief FDCAN MSP Initialization -* This function configures the hardware resources used in this example -* @param hfdcan: FDCAN handle pointer -* @retval None -*/ -void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* hfdcan) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - if(hfdcan->Instance==FDCAN1) - { - /* USER CODE BEGIN FDCAN1_MspInit 0 */ - - /* USER CODE END FDCAN1_MspInit 0 */ - - /** Initializes the peripherals clocks - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_FDCAN; - PeriphClkInit.FdcanClockSelection = RCC_FDCANCLKSOURCE_PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - /* Peripheral clock enable */ - __HAL_RCC_FDCAN_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**FDCAN1 GPIO Configuration - PA11 ------> FDCAN1_RX - PA12 ------> FDCAN1_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* FDCAN1 interrupt Init */ - HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn); - HAL_NVIC_SetPriority(FDCAN1_IT1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(FDCAN1_IT1_IRQn); - /* USER CODE BEGIN FDCAN1_MspInit 1 */ - - /* USER CODE END FDCAN1_MspInit 1 */ - } - -} - -/** -* @brief FDCAN MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hfdcan: FDCAN handle pointer -* @retval None -*/ -void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* hfdcan) -{ - if(hfdcan->Instance==FDCAN1) - { - /* USER CODE BEGIN FDCAN1_MspDeInit 0 */ - - /* USER CODE END FDCAN1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_FDCAN_CLK_DISABLE(); - - /**FDCAN1 GPIO Configuration - PA11 ------> FDCAN1_RX - PA12 ------> FDCAN1_TX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); - - /* FDCAN1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(FDCAN1_IT0_IRQn); - HAL_NVIC_DisableIRQ(FDCAN1_IT1_IRQn); - /* USER CODE BEGIN FDCAN1_MspDeInit 1 */ - - /* USER CODE END FDCAN1_MspDeInit 1 */ - } - -} - -/** -* @brief I2C MSP Initialization -* This function configures the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspInit 0 */ - - /* USER CODE END I2C1_MspInit 0 */ - - /** Initializes the peripherals clocks - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1; - PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2C1 GPIO Configuration - PA15 ------> I2C1_SCL - PB7 ------> I2C1_SDA - */ - GPIO_InitStruct.Pin = GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_I2C1_CLK_ENABLE(); - - /* I2C1 DMA Init */ - /* I2C1_RX Init */ - hdma_i2c1_rx.Instance = DMA1_Channel3; - hdma_i2c1_rx.Init.Request = DMA_REQUEST_I2C1_RX; - hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_i2c1_rx.Init.Mode = DMA_NORMAL; - hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_i2c1_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hi2c,hdmarx,hdma_i2c1_rx); - - /* I2C1_TX Init */ - hdma_i2c1_tx.Instance = DMA1_Channel4; - hdma_i2c1_tx.Init.Request = DMA_REQUEST_I2C1_TX; - hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_i2c1_tx.Init.Mode = DMA_NORMAL; - hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_i2c1_tx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hi2c,hdmatx,hdma_i2c1_tx); - - /* I2C1 interrupt Init */ - HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(I2C1_EV_IRQn); - /* USER CODE BEGIN I2C1_MspInit 1 */ - - /* USER CODE END I2C1_MspInit 1 */ - } - -} - -/** -* @brief I2C MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) -{ - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspDeInit 0 */ - - /* USER CODE END I2C1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_I2C1_CLK_DISABLE(); - - /**I2C1 GPIO Configuration - PA15 ------> I2C1_SCL - PB7 ------> I2C1_SDA - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15); - - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7); - - /* I2C1 DMA DeInit */ - HAL_DMA_DeInit(hi2c->hdmarx); - HAL_DMA_DeInit(hi2c->hdmatx); - - /* I2C1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(I2C1_EV_IRQn); - /* USER CODE BEGIN I2C1_MspDeInit 1 */ - - /* USER CODE END I2C1_MspDeInit 1 */ - } - -} - -/** -* @brief SPI MSP Initialization -* This function configures the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspInit 0 */ - - /* USER CODE END SPI1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_SPI1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**SPI1 GPIO Configuration - PA5 ------> SPI1_SCK - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - */ - GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_6; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* SPI1 DMA Init */ - /* SPI1_RX Init */ - hdma_spi1_rx.Instance = DMA1_Channel5; - hdma_spi1_rx.Init.Request = DMA_REQUEST_SPI1_RX; - hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_spi1_rx.Init.Mode = DMA_NORMAL; - hdma_spi1_rx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_spi1_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hspi,hdmarx,hdma_spi1_rx); - - /* SPI1_TX Init */ - hdma_spi1_tx.Instance = DMA1_Channel6; - hdma_spi1_tx.Init.Request = DMA_REQUEST_SPI1_TX; - hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_spi1_tx.Init.Mode = DMA_NORMAL; - hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx); - - /* SPI1 interrupt Init */ - HAL_NVIC_SetPriority(SPI1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SPI1_IRQn); - /* USER CODE BEGIN SPI1_MspInit 1 */ - - /* USER CODE END SPI1_MspInit 1 */ - } - -} - -/** -* @brief SPI MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) -{ - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspDeInit 0 */ - - /* USER CODE END SPI1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI1_CLK_DISABLE(); - - /**SPI1 GPIO Configuration - PA5 ------> SPI1_SCK - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); - - /* SPI1 DMA DeInit */ - HAL_DMA_DeInit(hspi->hdmarx); - HAL_DMA_DeInit(hspi->hdmatx); - - /* SPI1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(SPI1_IRQn); - /* USER CODE BEGIN SPI1_MspDeInit 1 */ - - /* USER CODE END SPI1_MspDeInit 1 */ - } - -} - -/** -* @brief UART MSP Initialization -* This function configures the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - if(huart->Instance==USART1) - { - /* USER CODE BEGIN USART1_MspInit 0 */ - - /* USER CODE END USART1_MspInit 0 */ - - /** Initializes the peripherals clocks - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; - PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - /* Peripheral clock enable */ - __HAL_RCC_USART1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART1 GPIO Configuration - PA9 ------> USART1_TX - PA10 ------> USART1_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF7_USART1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USART1 DMA Init */ - /* USART1_RX Init */ - hdma_usart1_rx.Instance = DMA2_Channel1; - hdma_usart1_rx.Init.Request = DMA_REQUEST_USART1_RX; - hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart1_rx.Init.Mode = DMA_NORMAL; - hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx); - - /* USART1_TX Init */ - hdma_usart1_tx.Instance = DMA2_Channel2; - hdma_usart1_tx.Init.Request = DMA_REQUEST_USART1_TX; - hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart1_tx.Init.Mode = DMA_NORMAL; - hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmatx,hdma_usart1_tx); - - /* USER CODE BEGIN USART1_MspInit 1 */ - - /* USER CODE END USART1_MspInit 1 */ - } - else if(huart->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspInit 0 */ - - /* USER CODE END USART2_MspInit 0 */ - - /** Initializes the peripherals clocks - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2; - PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - /* Peripheral clock enable */ - __HAL_RCC_USART2_CLK_ENABLE(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USART2 GPIO Configuration - PB3 ------> USART2_TX - PB4 ------> USART2_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF7_USART2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USART2 DMA Init */ - /* USART2_RX Init */ - hdma_usart2_rx.Instance = DMA1_Channel1; - hdma_usart2_rx.Init.Request = DMA_REQUEST_USART2_RX; - hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart2_rx.Init.Mode = DMA_NORMAL; - hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmarx,hdma_usart2_rx); - - /* USART2_TX Init */ - hdma_usart2_tx.Instance = DMA1_Channel2; - hdma_usart2_tx.Init.Request = DMA_REQUEST_USART2_TX; - hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart2_tx.Init.Mode = DMA_NORMAL; - hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_usart2_tx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmatx,hdma_usart2_tx); - - /* USART2 interrupt Init */ - HAL_NVIC_SetPriority(USART2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(USART2_IRQn); - /* USER CODE BEGIN USART2_MspInit 1 */ - - /* USER CODE END USART2_MspInit 1 */ - } - -} - -/** -* @brief UART MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) -{ - if(huart->Instance==USART1) - { - /* USER CODE BEGIN USART1_MspDeInit 0 */ - - /* USER CODE END USART1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART1_CLK_DISABLE(); - - /**USART1 GPIO Configuration - PA9 ------> USART1_TX - PA10 ------> USART1_RX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); - - /* USART1 DMA DeInit */ - HAL_DMA_DeInit(huart->hdmarx); - HAL_DMA_DeInit(huart->hdmatx); - /* USER CODE BEGIN USART1_MspDeInit 1 */ - - /* USER CODE END USART1_MspDeInit 1 */ - } - else if(huart->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspDeInit 0 */ - - /* USER CODE END USART2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART2_CLK_DISABLE(); - - /**USART2 GPIO Configuration - PB3 ------> USART2_TX - PB4 ------> USART2_RX - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_4); - - /* USART2 DMA DeInit */ - HAL_DMA_DeInit(huart->hdmarx); - HAL_DMA_DeInit(huart->hdmatx); - - /* USART2 interrupt DeInit */ - HAL_NVIC_DisableIRQ(USART2_IRQn); - /* USER CODE BEGIN USART2_MspDeInit 1 */ - - /* USER CODE END USART2_MspDeInit 1 */ - } - -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_timebase_tim.c b/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_timebase_tim.c deleted file mode 100644 index 3a598650..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_hal_timebase_tim.c +++ /dev/null @@ -1,126 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_timebase_tim.c - * @brief HAL time base based on the hardware TIM. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_hal_tim.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -TIM_HandleTypeDef htim15; -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/** - * @brief This function configures the TIM15 as a time base source. - * The time source is configured to have 1ms time base with a dedicated - * Tick interrupt priority. - * @note This function is called automatically at the beginning of program after - * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). - * @param TickPriority: Tick interrupt priority. - * @retval HAL status - */ -HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) -{ - RCC_ClkInitTypeDef clkconfig; - uint32_t uwTimclock = 0; - uint32_t uwPrescalerValue = 0; - uint32_t pFLatency; - HAL_StatusTypeDef status; - - /* Enable TIM15 clock */ - __HAL_RCC_TIM15_CLK_ENABLE(); - - /* Get clock configuration */ - HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); - - /* Compute TIM15 clock */ - uwTimclock = HAL_RCC_GetPCLK2Freq(); - - /* Compute the prescaler value to have TIM15 counter clock equal to 1MHz */ - uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); - - /* Initialize TIM15 */ - htim15.Instance = TIM15; - - /* Initialize TIMx peripheral as follow: - - + Period = [(TIM15CLK/1000) - 1]. to have a (1/1000) s time base. - + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. - + ClockDivision = 0 - + Counter direction = Up - */ - htim15.Init.Period = (1000000U / 1000U) - 1U; - htim15.Init.Prescaler = uwPrescalerValue; - htim15.Init.ClockDivision = 0; - htim15.Init.CounterMode = TIM_COUNTERMODE_UP; - - status = HAL_TIM_Base_Init(&htim15); - if (status == HAL_OK) - { - /* Start the TIM time Base generation in interrupt mode */ - status = HAL_TIM_Base_Start_IT(&htim15); - if (status == HAL_OK) - { - /* Enable the TIM15 global Interrupt */ - HAL_NVIC_EnableIRQ(TIM1_BRK_TIM15_IRQn); - /* Configure the SysTick IRQ priority */ - if (TickPriority < (1UL << __NVIC_PRIO_BITS)) - { - /* Configure the TIM IRQ priority */ - HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, TickPriority, 0U); - uwTickPrio = TickPriority; - } - else - { - status = HAL_ERROR; - } - } - } - - /* Return function status */ - return status; -} - -/** - * @brief Suspend Tick increment. - * @note Disable the tick increment by disabling TIM15 update interrupt. - * @param None - * @retval None - */ -void HAL_SuspendTick(void) -{ - /* Disable TIM15 update Interrupt */ - __HAL_TIM_DISABLE_IT(&htim15, TIM_IT_UPDATE); -} - -/** - * @brief Resume Tick increment. - * @note Enable the tick increment by Enabling TIM15 update interrupt. - * @param None - * @retval None - */ -void HAL_ResumeTick(void) -{ - /* Enable TIM15 Update interrupt */ - __HAL_TIM_ENABLE_IT(&htim15, TIM_IT_UPDATE); -} - diff --git a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_it.c b/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_it.c deleted file mode 100644 index e3e5c8d7..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,386 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32g4xx_it.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ -void (*user_uart_irq_handler)(UART_HandleTypeDef *huart) = NULL; -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -extern FDCAN_HandleTypeDef hfdcan1; -extern DMA_HandleTypeDef hdma_i2c1_rx; -extern DMA_HandleTypeDef hdma_i2c1_tx; -extern I2C_HandleTypeDef hi2c1; -extern DMA_HandleTypeDef hdma_spi1_rx; -extern DMA_HandleTypeDef hdma_spi1_tx; -extern SPI_HandleTypeDef hspi1; -extern DMA_HandleTypeDef hdma_usart1_rx; -extern DMA_HandleTypeDef hdma_usart1_tx; -extern DMA_HandleTypeDef hdma_usart2_rx; -extern DMA_HandleTypeDef hdma_usart2_tx; -extern UART_HandleTypeDef huart2; -extern TIM_HandleTypeDef htim15; - -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ - -/** - * @brief This function handles EXTI line0 interrupt. - */ -void EXTI0_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI0_IRQn 0 */ - - /* USER CODE END EXTI0_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(IMU_INT1_Pin); - /* USER CODE BEGIN EXTI0_IRQn 1 */ - - /* USER CODE END EXTI0_IRQn 1 */ -} - -/** - * @brief This function handles EXTI line1 interrupt. - */ -void EXTI1_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI1_IRQn 0 */ - - /* USER CODE END EXTI1_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(IMU_INT2_Pin); - /* USER CODE BEGIN EXTI1_IRQn 1 */ - - /* USER CODE END EXTI1_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel1 global interrupt. - */ -void DMA1_Channel1_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */ - - /* USER CODE END DMA1_Channel1_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_usart2_rx); - /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */ - - /* USER CODE END DMA1_Channel1_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel2 global interrupt. - */ -void DMA1_Channel2_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel2_IRQn 0 */ - - /* USER CODE END DMA1_Channel2_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_usart2_tx); - /* USER CODE BEGIN DMA1_Channel2_IRQn 1 */ - - /* USER CODE END DMA1_Channel2_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel3 global interrupt. - */ -void DMA1_Channel3_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */ - - /* USER CODE END DMA1_Channel3_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_i2c1_rx); - /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */ - - /* USER CODE END DMA1_Channel3_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel4 global interrupt. - */ -void DMA1_Channel4_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel4_IRQn 0 */ - - /* USER CODE END DMA1_Channel4_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_i2c1_tx); - /* USER CODE BEGIN DMA1_Channel4_IRQn 1 */ - - /* USER CODE END DMA1_Channel4_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel5 global interrupt. - */ -void DMA1_Channel5_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */ - - /* USER CODE END DMA1_Channel5_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_spi1_rx); - /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */ - - /* USER CODE END DMA1_Channel5_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel6 global interrupt. - */ -void DMA1_Channel6_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */ - - /* USER CODE END DMA1_Channel6_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_spi1_tx); - /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */ - - /* USER CODE END DMA1_Channel6_IRQn 1 */ -} - -/** - * @brief This function handles FDCAN1 interrupt 0. - */ -void FDCAN1_IT0_IRQHandler(void) -{ - /* USER CODE BEGIN FDCAN1_IT0_IRQn 0 */ - - /* USER CODE END FDCAN1_IT0_IRQn 0 */ - HAL_FDCAN_IRQHandler(&hfdcan1); - /* USER CODE BEGIN FDCAN1_IT0_IRQn 1 */ - - /* USER CODE END FDCAN1_IT0_IRQn 1 */ -} - -/** - * @brief This function handles FDCAN1 interrupt 1. - */ -void FDCAN1_IT1_IRQHandler(void) -{ - /* USER CODE BEGIN FDCAN1_IT1_IRQn 0 */ - - /* USER CODE END FDCAN1_IT1_IRQn 0 */ - HAL_FDCAN_IRQHandler(&hfdcan1); - /* USER CODE BEGIN FDCAN1_IT1_IRQn 1 */ - - /* USER CODE END FDCAN1_IT1_IRQn 1 */ -} - -/** - * @brief This function handles TIM1 break interrupt and TIM15 global interrupt. - */ -void TIM1_BRK_TIM15_IRQHandler(void) -{ - /* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 0 */ - - /* USER CODE END TIM1_BRK_TIM15_IRQn 0 */ - HAL_TIM_IRQHandler(&htim15); - /* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 1 */ - - /* USER CODE END TIM1_BRK_TIM15_IRQn 1 */ -} - -/** - * @brief This function handles I2C1 event interrupt / I2C1 wake-up interrupt through EXTI line 23. - */ -void I2C1_EV_IRQHandler(void) -{ - /* USER CODE BEGIN I2C1_EV_IRQn 0 */ - - /* USER CODE END I2C1_EV_IRQn 0 */ - HAL_I2C_EV_IRQHandler(&hi2c1); - /* USER CODE BEGIN I2C1_EV_IRQn 1 */ - - /* USER CODE END I2C1_EV_IRQn 1 */ -} - -/** - * @brief This function handles SPI1 global interrupt. - */ -void SPI1_IRQHandler(void) -{ - /* USER CODE BEGIN SPI1_IRQn 0 */ - - /* USER CODE END SPI1_IRQn 0 */ - HAL_SPI_IRQHandler(&hspi1); - /* USER CODE BEGIN SPI1_IRQn 1 */ - - /* USER CODE END SPI1_IRQn 1 */ -} - -/** - * @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26. - */ -void USART2_IRQHandler(void) -{ - /* USER CODE BEGIN USART2_IRQn 0 */ - - /* USER CODE END USART2_IRQn 0 */ - HAL_UART_IRQHandler(&huart2); - /* USER CODE BEGIN USART2_IRQn 1 */ - user_uart_irq_handler(&huart2); - /* USER CODE END USART2_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 channel1 global interrupt. - */ -void DMA2_Channel1_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Channel1_IRQn 0 */ - - /* USER CODE END DMA2_Channel1_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_usart1_rx); - /* USER CODE BEGIN DMA2_Channel1_IRQn 1 */ - - /* USER CODE END DMA2_Channel1_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 channel2 global interrupt. - */ -void DMA2_Channel2_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Channel2_IRQn 0 */ - - /* USER CODE END DMA2_Channel2_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_usart1_tx); - /* USER CODE BEGIN DMA2_Channel2_IRQn 1 */ - - /* USER CODE END DMA2_Channel2_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ -void HAL_UART_RegisterUserCallback(void (*fn)(UART_HandleTypeDef *huart)) { - user_uart_irq_handler = fn; -} -/* USER CODE END 1 */ diff --git a/hw/bsp/atom/drivers/hal/Core/Src/system_stm32g4xx.c b/hw/bsp/atom/drivers/hal/Core/Src/system_stm32g4xx.c deleted file mode 100644 index a9313426..00000000 --- a/hw/bsp/atom/drivers/hal/Core/Src/system_stm32g4xx.c +++ /dev/null @@ -1,285 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32g4xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32g4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to - * configure the system clock before to branch to main program. - * - * This file configures the system clock as follows: - *============================================================================= - *----------------------------------------------------------------------------- - * System Clock source | HSI - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 1 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 1 - *----------------------------------------------------------------------------- - * PLL_M | 1 - *----------------------------------------------------------------------------- - * PLL_N | 16 - *----------------------------------------------------------------------------- - * PLL_P | 7 - *----------------------------------------------------------------------------- - * PLL_Q | 2 - *----------------------------------------------------------------------------- - * PLL_R | 2 - *----------------------------------------------------------------------------- - * Require 48MHz for RNG | Disabled - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32g4xx_system - * @{ - */ - -/** @addtogroup STM32G4xx_System_Private_Includes - * @{ - */ - -#include "stm32g4xx.h" - -#if !defined (HSE_VALUE) - #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSI_VALUE) - #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/* Note: Following vector table addresses must be defined in line with linker - configuration. */ -/*!< Uncomment the following line if you need to relocate the vector table - anywhere in Flash or Sram, else the vector table is kept at the automatic - remap of boot address selected */ -#define USER_VECT_TAB_ADDRESS - -#if defined(USER_VECT_TAB_ADDRESS) -/*!< Uncomment the following line if you need to relocate your vector Table - in Sram else user remap will be done in Flash. */ -/* #define VECT_TAB_SRAM */ -#if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#else -#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00005000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -/******************************************************************************/ -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Variables - * @{ - */ - /* The SystemCoreClock variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = HSI_VALUE; - - const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; - const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ - -void SystemInit(void) -{ - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ - #endif - - /* Configure the Vector Table location add offset address ------------------*/ -#if defined(USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 24 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp, pllvco, pllr, pllsource, pllm; - - /* Get SYSCLK source -------------------------------------------------------*/ - switch (RCC->CFGR & RCC_CFGR_SWS) - { - case 0x04: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - - case 0x08: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case 0x0C: /* PLL used as system clock source */ - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); - pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; - if (pllsource == 0x02UL) /* HSI used as PLL clock source */ - { - pllvco = (HSI_VALUE / pllm); - } - else /* HSE used as PLL clock source */ - { - pllvco = (HSE_VALUE / pllm); - } - pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); - pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; - SystemCoreClock = pllvco/pllr; - break; - - default: - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - diff --git a/hw/bsp/atom/drivers/hal/Makefile b/hw/bsp/atom/drivers/hal/Makefile deleted file mode 100644 index d301abac..00000000 --- a/hw/bsp/atom/drivers/hal/Makefile +++ /dev/null @@ -1,198 +0,0 @@ -########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Sun Nov 05 11:19:30 CST 2023] -########################################################################################################################## - -# ------------------------------------------------ -# Generic Makefile (based on gcc) -# -# ChangeLog : -# 2017-02-10 - Several enhancements + project update mode -# 2015-07-22 - first version -# ------------------------------------------------ - -###################################### -# target -###################################### -TARGET = hal - - -###################################### -# building variables -###################################### -# debug build? -DEBUG = 1 -# optimization -OPT = -Og - - -####################################### -# paths -####################################### -# Build path -BUILD_DIR = build - -###################################### -# source -###################################### -# C sources -C_SOURCES = \ -Core/Src/main.c \ -Core/Src/stm32g4xx_it.c \ -Core/Src/stm32g4xx_hal_msp.c \ -Core/Src/stm32g4xx_hal_timebase_tim.c \ -Core/Src/system_stm32g4xx.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c - -# ASM sources -ASM_SOURCES = \ -startup_stm32g431xx.s - - -####################################### -# binaries -####################################### -PREFIX = arm-none-eabi- -# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) -# either it can be added to the PATH environment variable. -ifdef GCC_PATH -CC = $(GCC_PATH)/$(PREFIX)gcc -AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp -CP = $(GCC_PATH)/$(PREFIX)objcopy -SZ = $(GCC_PATH)/$(PREFIX)size -else -CC = $(PREFIX)gcc -AS = $(PREFIX)gcc -x assembler-with-cpp -CP = $(PREFIX)objcopy -SZ = $(PREFIX)size -endif -HEX = $(CP) -O ihex -BIN = $(CP) -O binary -S - -####################################### -# CFLAGS -####################################### -# cpu -CPU = -mcpu=cortex-m4 - -# fpu -FPU = -mfpu=fpv4-sp-d16 - -# float-abi -FLOAT-ABI = -mfloat-abi=hard - -# mcu -MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) - -# macros for gcc -# AS defines -AS_DEFS = - -# C defines -C_DEFS = \ --DUSE_HAL_DRIVER \ --DSTM32G431xx - - -# AS includes -AS_INCLUDES = - -# C includes -C_INCLUDES = \ --ICore/Inc \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Include \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Include - - -# compile gcc flags -ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -ifeq ($(DEBUG), 1) -CFLAGS += -g -gdwarf-2 -endif - - -# Generate dependency information -CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" - - -####################################### -# LDFLAGS -####################################### -# link script -LDSCRIPT = STM32G431KBUx_FLASH.ld - -# libraries -LIBS = -lc -lm -lnosys -LIBDIR = -LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections - -# default action: build all -all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin - - -####################################### -# build the application -####################################### -# list of objects -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) -vpath %.c $(sort $(dir $(C_SOURCES))) -# list of ASM program objects -OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) -vpath %.s $(sort $(dir $(ASM_SOURCES))) - -$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ - -$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - $(SZ) $@ - -$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(HEX) $< $@ - -$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(BIN) $< $@ - -$(BUILD_DIR): - mkdir $@ - -####################################### -# clean up -####################################### -clean: - -rm -fR $(BUILD_DIR) - -####################################### -# dependencies -####################################### --include $(wildcard $(BUILD_DIR)/*.d) - -# *** EOF *** diff --git a/hw/bsp/atom/drivers/hal/STM32G431KBUx_FLASH.ld b/hw/bsp/atom/drivers/hal/STM32G431KBUx_FLASH.ld deleted file mode 100644 index 8d062d53..00000000 --- a/hw/bsp/atom/drivers/hal/STM32G431KBUx_FLASH.ld +++ /dev/null @@ -1,189 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : STM32CubeMX -** -** Abstract : Linker script for STM32G431KBUx series -** 128Kbytes FLASH and 32Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - diff --git a/hw/bsp/atom/drivers/hal/hal.ioc b/hw/bsp/atom/drivers/hal/hal.ioc deleted file mode 100644 index d9cd9f7f..00000000 --- a/hw/bsp/atom/drivers/hal/hal.ioc +++ /dev/null @@ -1,387 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -CAD.formats= -CAD.pinconfig= -CAD.provider= -Dma.I2C1_RX.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.I2C1_RX.0.EventEnable=DISABLE -Dma.I2C1_RX.0.Instance=DMA1_Channel3 -Dma.I2C1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.I2C1_RX.0.MemInc=DMA_MINC_ENABLE -Dma.I2C1_RX.0.Mode=DMA_NORMAL -Dma.I2C1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.I2C1_RX.0.PeriphInc=DMA_PINC_DISABLE -Dma.I2C1_RX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.I2C1_RX.0.Priority=DMA_PRIORITY_LOW -Dma.I2C1_RX.0.RequestNumber=1 -Dma.I2C1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.I2C1_RX.0.SignalID=NONE -Dma.I2C1_RX.0.SyncEnable=DISABLE -Dma.I2C1_RX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.I2C1_RX.0.SyncRequestNumber=1 -Dma.I2C1_RX.0.SyncSignalID=NONE -Dma.I2C1_TX.1.Direction=DMA_MEMORY_TO_PERIPH -Dma.I2C1_TX.1.EventEnable=DISABLE -Dma.I2C1_TX.1.Instance=DMA1_Channel4 -Dma.I2C1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.I2C1_TX.1.MemInc=DMA_MINC_ENABLE -Dma.I2C1_TX.1.Mode=DMA_NORMAL -Dma.I2C1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.I2C1_TX.1.PeriphInc=DMA_PINC_DISABLE -Dma.I2C1_TX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.I2C1_TX.1.Priority=DMA_PRIORITY_LOW -Dma.I2C1_TX.1.RequestNumber=1 -Dma.I2C1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.I2C1_TX.1.SignalID=NONE -Dma.I2C1_TX.1.SyncEnable=DISABLE -Dma.I2C1_TX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.I2C1_TX.1.SyncRequestNumber=1 -Dma.I2C1_TX.1.SyncSignalID=NONE -Dma.Request0=I2C1_RX -Dma.Request1=I2C1_TX -Dma.Request2=USART2_RX -Dma.Request3=USART2_TX -Dma.Request4=SPI1_RX -Dma.Request5=SPI1_TX -Dma.Request6=USART1_RX -Dma.Request7=USART1_TX -Dma.RequestsNb=8 -Dma.SPI1_RX.4.Direction=DMA_PERIPH_TO_MEMORY -Dma.SPI1_RX.4.EventEnable=DISABLE -Dma.SPI1_RX.4.Instance=DMA1_Channel5 -Dma.SPI1_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.SPI1_RX.4.MemInc=DMA_MINC_ENABLE -Dma.SPI1_RX.4.Mode=DMA_NORMAL -Dma.SPI1_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SPI1_RX.4.PeriphInc=DMA_PINC_DISABLE -Dma.SPI1_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.SPI1_RX.4.Priority=DMA_PRIORITY_LOW -Dma.SPI1_RX.4.RequestNumber=1 -Dma.SPI1_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SPI1_RX.4.SignalID=NONE -Dma.SPI1_RX.4.SyncEnable=DISABLE -Dma.SPI1_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.SPI1_RX.4.SyncRequestNumber=1 -Dma.SPI1_RX.4.SyncSignalID=NONE -Dma.SPI1_TX.5.Direction=DMA_MEMORY_TO_PERIPH -Dma.SPI1_TX.5.EventEnable=DISABLE -Dma.SPI1_TX.5.Instance=DMA1_Channel6 -Dma.SPI1_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.SPI1_TX.5.MemInc=DMA_MINC_ENABLE -Dma.SPI1_TX.5.Mode=DMA_NORMAL -Dma.SPI1_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SPI1_TX.5.PeriphInc=DMA_PINC_DISABLE -Dma.SPI1_TX.5.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.SPI1_TX.5.Priority=DMA_PRIORITY_LOW -Dma.SPI1_TX.5.RequestNumber=1 -Dma.SPI1_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SPI1_TX.5.SignalID=NONE -Dma.SPI1_TX.5.SyncEnable=DISABLE -Dma.SPI1_TX.5.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.SPI1_TX.5.SyncRequestNumber=1 -Dma.SPI1_TX.5.SyncSignalID=NONE -Dma.USART1_RX.6.Direction=DMA_PERIPH_TO_MEMORY -Dma.USART1_RX.6.EventEnable=DISABLE -Dma.USART1_RX.6.Instance=DMA2_Channel1 -Dma.USART1_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART1_RX.6.MemInc=DMA_MINC_ENABLE -Dma.USART1_RX.6.Mode=DMA_NORMAL -Dma.USART1_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART1_RX.6.PeriphInc=DMA_PINC_DISABLE -Dma.USART1_RX.6.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.USART1_RX.6.Priority=DMA_PRIORITY_LOW -Dma.USART1_RX.6.RequestNumber=1 -Dma.USART1_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART1_RX.6.SignalID=NONE -Dma.USART1_RX.6.SyncEnable=DISABLE -Dma.USART1_RX.6.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.USART1_RX.6.SyncRequestNumber=1 -Dma.USART1_RX.6.SyncSignalID=NONE -Dma.USART1_TX.7.Direction=DMA_MEMORY_TO_PERIPH -Dma.USART1_TX.7.EventEnable=DISABLE -Dma.USART1_TX.7.Instance=DMA2_Channel2 -Dma.USART1_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART1_TX.7.MemInc=DMA_MINC_ENABLE -Dma.USART1_TX.7.Mode=DMA_NORMAL -Dma.USART1_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART1_TX.7.PeriphInc=DMA_PINC_DISABLE -Dma.USART1_TX.7.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.USART1_TX.7.Priority=DMA_PRIORITY_LOW -Dma.USART1_TX.7.RequestNumber=1 -Dma.USART1_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART1_TX.7.SignalID=NONE -Dma.USART1_TX.7.SyncEnable=DISABLE -Dma.USART1_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.USART1_TX.7.SyncRequestNumber=1 -Dma.USART1_TX.7.SyncSignalID=NONE -Dma.USART2_RX.2.Direction=DMA_PERIPH_TO_MEMORY -Dma.USART2_RX.2.EventEnable=DISABLE -Dma.USART2_RX.2.Instance=DMA1_Channel1 -Dma.USART2_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART2_RX.2.MemInc=DMA_MINC_ENABLE -Dma.USART2_RX.2.Mode=DMA_NORMAL -Dma.USART2_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART2_RX.2.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_RX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.USART2_RX.2.Priority=DMA_PRIORITY_LOW -Dma.USART2_RX.2.RequestNumber=1 -Dma.USART2_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART2_RX.2.SignalID=NONE -Dma.USART2_RX.2.SyncEnable=DISABLE -Dma.USART2_RX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.USART2_RX.2.SyncRequestNumber=1 -Dma.USART2_RX.2.SyncSignalID=NONE -Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH -Dma.USART2_TX.3.EventEnable=DISABLE -Dma.USART2_TX.3.Instance=DMA1_Channel2 -Dma.USART2_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART2_TX.3.MemInc=DMA_MINC_ENABLE -Dma.USART2_TX.3.Mode=DMA_NORMAL -Dma.USART2_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART2_TX.3.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_TX.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.USART2_TX.3.Priority=DMA_PRIORITY_LOW -Dma.USART2_TX.3.RequestNumber=1 -Dma.USART2_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART2_TX.3.SignalID=NONE -Dma.USART2_TX.3.SyncEnable=DISABLE -Dma.USART2_TX.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.USART2_TX.3.SyncRequestNumber=1 -Dma.USART2_TX.3.SyncSignalID=NONE -FDCAN1.AutoRetransmission=ENABLE -FDCAN1.CalculateBaudRateNominal=1000000 -FDCAN1.CalculateTimeBitNominal=1000 -FDCAN1.CalculateTimeQuantumNominal=62.5 -FDCAN1.DataPrescaler=2 -FDCAN1.DataSyncJumpWidth=16 -FDCAN1.DataTimeSeg1=13 -FDCAN1.DataTimeSeg2=2 -FDCAN1.ExtFiltersNbr=2 -FDCAN1.FrameFormat=FDCAN_FRAME_FD_BRS -FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,AutoRetransmission,TransmitPause,NominalSyncJumpWidth,DataPrescaler,DataTimeSeg1,DataTimeSeg2,DataSyncJumpWidth,NominalPrescaler,NominalTimeSeg1,StdFiltersNbr,ExtFiltersNbr -FDCAN1.NominalPrescaler=10 -FDCAN1.NominalSyncJumpWidth=16 -FDCAN1.NominalTimeSeg1=13 -FDCAN1.StdFiltersNbr=2 -FDCAN1.TransmitPause=DISABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -I2C1.I2C_Speed_Mode=I2C_Fast -I2C1.IPParameters=Timing,I2C_Speed_Mode -I2C1.Timing=0x00F07BFF -KeepUserPlacement=false -Mcu.CPN=STM32G431KBU6 -Mcu.Family=STM32G4 -Mcu.IP0=DMA -Mcu.IP1=FDCAN1 -Mcu.IP2=I2C1 -Mcu.IP3=NVIC -Mcu.IP4=RCC -Mcu.IP5=SPI1 -Mcu.IP6=SYS -Mcu.IP7=USART1 -Mcu.IP8=USART2 -Mcu.IPNb=9 -Mcu.Name=STM32G431K(6-8-B)Ux -Mcu.Package=UFQFPN32 -Mcu.Pin0=PA0 -Mcu.Pin1=PA1 -Mcu.Pin10=PA12 -Mcu.Pin11=PA13 -Mcu.Pin12=PA14 -Mcu.Pin13=PA15 -Mcu.Pin14=PB3 -Mcu.Pin15=PB4 -Mcu.Pin16=PB7 -Mcu.Pin17=VP_SYS_VS_tim15 -Mcu.Pin2=PA4 -Mcu.Pin3=PA5 -Mcu.Pin4=PA6 -Mcu.Pin5=PA7 -Mcu.Pin6=PB0 -Mcu.Pin7=PA9 -Mcu.Pin8=PA10 -Mcu.Pin9=PA11 -Mcu.PinsNb=18 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G431KBUx -MxCube.Version=6.9.2 -MxDb.Version=DB.6.0.92 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DMA1_Channel1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA1_Channel2_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA1_Channel3_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA1_Channel4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA1_Channel5_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA1_Channel6_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -NVIC.DMA2_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -NVIC.DMA2_Channel2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.EXTI0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.EXTI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.FDCAN1_IT0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.FDCAN1_IT1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false -NVIC.I2C1_EV_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PendSV_IRQn=true\:15\:0\:true\:false\:false\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SPI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false -NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:false\:false\:true\:false -NVIC.TIM1_BRK_TIM15_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true -NVIC.TimeBase=TIM1_BRK_TIM15_IRQn -NVIC.TimeBaseIP=TIM15 -NVIC.USART2_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA0.GPIOParameters=GPIO_PuPd,GPIO_Label -PA0.GPIO_Label=IMU_INT1 -PA0.GPIO_PuPd=GPIO_PULLDOWN -PA0.Locked=true -PA0.Signal=GPXTI0 -PA1.GPIOParameters=GPIO_PuPd,GPIO_Label -PA1.GPIO_Label=IMU_INT2 -PA1.GPIO_PuPd=GPIO_PULLDOWN -PA1.Locked=true -PA1.Signal=GPXTI1 -PA10.Mode=Asynchronous -PA10.Signal=USART1_RX -PA11.Mode=FDCAN_Activate -PA11.Signal=FDCAN1_RX -PA12.Mode=FDCAN_Activate -PA12.Signal=FDCAN1_TX -PA13.Mode=Serial_Wire -PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire -PA14.Signal=SYS_JTCK-SWCLK -PA15.Mode=I2C -PA15.Signal=I2C1_SCL -PA4.GPIOParameters=PinState,GPIO_Label -PA4.GPIO_Label=IMU_CS -PA4.Locked=true -PA4.PinState=GPIO_PIN_SET -PA4.Signal=GPIO_Output -PA5.GPIOParameters=GPIO_PuPd -PA5.GPIO_PuPd=GPIO_PULLUP -PA5.Mode=Full_Duplex_Master -PA5.Signal=SPI1_SCK -PA6.GPIOParameters=GPIO_PuPd -PA6.GPIO_PuPd=GPIO_PULLDOWN -PA6.Mode=Full_Duplex_Master -PA6.Signal=SPI1_MISO -PA7.GPIOParameters=GPIO_PuPd -PA7.GPIO_PuPd=GPIO_PULLUP -PA7.Mode=Full_Duplex_Master -PA7.Signal=SPI1_MOSI -PA9.Mode=Asynchronous -PA9.Signal=USART1_TX -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=LED_RUN -PB0.Locked=true -PB0.Signal=GPIO_Output -PB3.Locked=true -PB3.Mode=Asynchronous -PB3.Signal=USART2_TX -PB4.Locked=true -PB4.Mode=Asynchronous -PB4.Signal=USART2_RX -PB7.Locked=true -PB7.Mode=I2C -PB7.Signal=I2C1_SDA -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=false -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G431KBUx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.5.1 -ProjectManager.FreePins=false -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=2 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=true -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=hal.ioc -ProjectManager.ProjectName=hal -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-false,3-MX_DMA_Init-DMA-false-HAL-false,4-MX_FDCAN1_Init-FDCAN1-false-HAL-false,5-MX_I2C1_Init-I2C1-false-HAL-false,6-MX_SPI1_Init-SPI1-false-HAL-false,7-MX_USART2_UART_Init-USART2-false-HAL-false,8-MX_USART1_UART_Init-USART1-false-HAL-true -RCC.ADC12Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HSE_VALUE=8000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLM,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLM=RCC_PLLM_DIV4 -RCC.PLLN=80 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PWRFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=4000000 -RCC.VCOOutputFreq_Value=320000000 -SH.GPXTI0.0=GPIO_EXTI0 -SH.GPXTI0.ConfNb=1 -SH.GPXTI1.0=GPIO_EXTI1 -SH.GPXTI1.ConfNb=1 -SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 -SPI1.CLKPhase=SPI_PHASE_1EDGE -SPI1.CLKPolarity=SPI_POLARITY_LOW -SPI1.CalculateBaudRate=10.0 MBits/s -SPI1.DataSize=SPI_DATASIZE_8BIT -SPI1.Direction=SPI_DIRECTION_2LINES -SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate,CLKPolarity,CLKPhase,DataSize -SPI1.Mode=SPI_MODE_MASTER -SPI1.VirtualType=VM_MASTER -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -USART2.BaudRate=1000000 -USART2.IPParameters=VirtualMode-Asynchronous,BaudRate -USART2.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_tim15.Mode=TIM15 -VP_SYS_VS_tim15.Signal=SYS_VS_tim15 -board=custom diff --git a/hw/bsp/atom/drivers/hal/startup_stm32g431xx.s b/hw/bsp/atom/drivers/hal/startup_stm32g431xx.s deleted file mode 100644 index 9ea4773a..00000000 --- a/hw/bsp/atom/drivers/hal/startup_stm32g431xx.s +++ /dev/null @@ -1,497 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32g431xx.s - * @author MCD Application Team - * @brief STM32G431xx devices vector table GCC toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address, - * - Configure the clock system - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M4 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - - .syntax unified - .cpu cortex-m4 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss - -.equ BootRAM, 0xF1E0F85F -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - ldr r0, =_estack - mov sp, r0 /* set stack pointer */ - -/* Copy the data segment initializers from flash to SRAM */ - ldr r0, =_sdata - ldr r1, =_edata - ldr r2, =_sidata - movs r3, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r4, [r2, r3] - str r4, [r0, r3] - adds r3, r3, #4 - -LoopCopyDataInit: - adds r4, r0, r3 - cmp r4, r1 - bcc CopyDataInit - -/* Zero fill the bss segment. */ - ldr r2, =_sbss - ldr r4, =_ebss - movs r3, #0 - b LoopFillZerobss - -FillZerobss: - str r3, [r2] - adds r2, r2, #4 - -LoopFillZerobss: - cmp r2, r4 - bcc FillZerobss - -/* Call the clock system intitialization function.*/ - bl SystemInit -/* Call static constructors */ - bl __libc_init_array -/* Call the application's entry point.*/ - bl main - -LoopForever: - b LoopForever - -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * - * @param None - * @retval : None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex-M4. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - .word WWDG_IRQHandler - .word PVD_PVM_IRQHandler - .word RTC_TAMP_LSECSS_IRQHandler - .word RTC_WKUP_IRQHandler - .word FLASH_IRQHandler - .word RCC_IRQHandler - .word EXTI0_IRQHandler - .word EXTI1_IRQHandler - .word EXTI2_IRQHandler - .word EXTI3_IRQHandler - .word EXTI4_IRQHandler - .word DMA1_Channel1_IRQHandler - .word DMA1_Channel2_IRQHandler - .word DMA1_Channel3_IRQHandler - .word DMA1_Channel4_IRQHandler - .word DMA1_Channel5_IRQHandler - .word DMA1_Channel6_IRQHandler - .word 0 - .word ADC1_2_IRQHandler - .word USB_HP_IRQHandler - .word USB_LP_IRQHandler - .word FDCAN1_IT0_IRQHandler - .word FDCAN1_IT1_IRQHandler - .word EXTI9_5_IRQHandler - .word TIM1_BRK_TIM15_IRQHandler - .word TIM1_UP_TIM16_IRQHandler - .word TIM1_TRG_COM_TIM17_IRQHandler - .word TIM1_CC_IRQHandler - .word TIM2_IRQHandler - .word TIM3_IRQHandler - .word TIM4_IRQHandler - .word I2C1_EV_IRQHandler - .word I2C1_ER_IRQHandler - .word I2C2_EV_IRQHandler - .word I2C2_ER_IRQHandler - .word SPI1_IRQHandler - .word SPI2_IRQHandler - .word USART1_IRQHandler - .word USART2_IRQHandler - .word USART3_IRQHandler - .word EXTI15_10_IRQHandler - .word RTC_Alarm_IRQHandler - .word USBWakeUp_IRQHandler - .word TIM8_BRK_IRQHandler - .word TIM8_UP_IRQHandler - .word TIM8_TRG_COM_IRQHandler - .word TIM8_CC_IRQHandler - .word 0 - .word 0 - .word LPTIM1_IRQHandler - .word 0 - .word SPI3_IRQHandler - .word UART4_IRQHandler - .word 0 - .word TIM6_DAC_IRQHandler - .word TIM7_IRQHandler - .word DMA2_Channel1_IRQHandler - .word DMA2_Channel2_IRQHandler - .word DMA2_Channel3_IRQHandler - .word DMA2_Channel4_IRQHandler - .word DMA2_Channel5_IRQHandler - .word 0 - .word 0 - .word UCPD1_IRQHandler - .word COMP1_2_3_IRQHandler - .word COMP4_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word CRS_IRQHandler - .word SAI1_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word FPU_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word RNG_IRQHandler - .word LPUART1_IRQHandler - .word I2C3_EV_IRQHandler - .word I2C3_ER_IRQHandler - .word DMAMUX_OVR_IRQHandler - .word 0 - .word 0 - .word DMA2_Channel6_IRQHandler - .word 0 - .word 0 - .word CORDIC_IRQHandler - .word FMAC_IRQHandler - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_PVM_IRQHandler - .thumb_set PVD_PVM_IRQHandler,Default_Handler - - .weak RTC_TAMP_LSECSS_IRQHandler - .thumb_set RTC_TAMP_LSECSS_IRQHandler,Default_Handler - - .weak RTC_WKUP_IRQHandler - .thumb_set RTC_WKUP_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Channel1_IRQHandler - .thumb_set DMA1_Channel1_IRQHandler,Default_Handler - - .weak DMA1_Channel2_IRQHandler - .thumb_set DMA1_Channel2_IRQHandler,Default_Handler - - .weak DMA1_Channel3_IRQHandler - .thumb_set DMA1_Channel3_IRQHandler,Default_Handler - - .weak DMA1_Channel4_IRQHandler - .thumb_set DMA1_Channel4_IRQHandler,Default_Handler - - .weak DMA1_Channel5_IRQHandler - .thumb_set DMA1_Channel5_IRQHandler,Default_Handler - - .weak DMA1_Channel6_IRQHandler - .thumb_set DMA1_Channel6_IRQHandler,Default_Handler - - .weak ADC1_2_IRQHandler - .thumb_set ADC1_2_IRQHandler,Default_Handler - - .weak USB_HP_IRQHandler - .thumb_set USB_HP_IRQHandler,Default_Handler - - .weak USB_LP_IRQHandler - .thumb_set USB_LP_IRQHandler,Default_Handler - - .weak FDCAN1_IT0_IRQHandler - .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler - - .weak FDCAN1_IT1_IRQHandler - .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_TIM15_IRQHandler - .thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler - - .weak TIM1_UP_TIM16_IRQHandler - .thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_TIM17_IRQHandler - .thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTC_Alarm_IRQHandler - .thumb_set RTC_Alarm_IRQHandler,Default_Handler - - .weak USBWakeUp_IRQHandler - .thumb_set USBWakeUp_IRQHandler,Default_Handler - - .weak TIM8_BRK_IRQHandler - .thumb_set TIM8_BRK_IRQHandler,Default_Handler - - .weak TIM8_UP_IRQHandler - .thumb_set TIM8_UP_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_IRQHandler - .thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak LPTIM1_IRQHandler - .thumb_set LPTIM1_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak TIM6_DAC_IRQHandler - .thumb_set TIM6_DAC_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Channel1_IRQHandler - .thumb_set DMA2_Channel1_IRQHandler,Default_Handler - - .weak DMA2_Channel2_IRQHandler - .thumb_set DMA2_Channel2_IRQHandler,Default_Handler - - .weak DMA2_Channel3_IRQHandler - .thumb_set DMA2_Channel3_IRQHandler,Default_Handler - - .weak DMA2_Channel4_IRQHandler - .thumb_set DMA2_Channel4_IRQHandler,Default_Handler - - .weak DMA2_Channel5_IRQHandler - .thumb_set DMA2_Channel5_IRQHandler,Default_Handler - - .weak UCPD1_IRQHandler - .thumb_set UCPD1_IRQHandler,Default_Handler - - .weak COMP1_2_3_IRQHandler - .thumb_set COMP1_2_3_IRQHandler,Default_Handler - - .weak COMP4_IRQHandler - .thumb_set COMP4_IRQHandler,Default_Handler - - .weak CRS_IRQHandler - .thumb_set CRS_IRQHandler,Default_Handler - - .weak SAI1_IRQHandler - .thumb_set SAI1_IRQHandler,Default_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Default_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Default_Handler - - .weak LPUART1_IRQHandler - .thumb_set LPUART1_IRQHandler,Default_Handler - - .weak I2C3_EV_IRQHandler - .thumb_set I2C3_EV_IRQHandler,Default_Handler - - .weak I2C3_ER_IRQHandler - .thumb_set I2C3_ER_IRQHandler,Default_Handler - - .weak DMAMUX_OVR_IRQHandler - .thumb_set DMAMUX_OVR_IRQHandler,Default_Handler - - .weak DMA2_Channel6_IRQHandler - .thumb_set DMA2_Channel6_IRQHandler,Default_Handler - - .weak CORDIC_IRQHandler - .thumb_set CORDIC_IRQHandler,Default_Handler - - .weak FMAC_IRQHandler - .thumb_set FMAC_IRQHandler,Default_Handler - diff --git a/hw/bsp/atom/drivers/rtos/CMakeLists.txt b/hw/bsp/atom/drivers/rtos/CMakeLists.txt deleted file mode 100644 index 52856805..00000000 --- a/hw/bsp/atom/drivers/rtos/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -cmake_minimum_required(VERSION 3.11) -project(rtos) - -file(GLOB ${PROJECT_NAME}_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/*.c" - "${LIB_DIR}/freertos/*.c" - "${LIB_DIR}/freertos/portable/MemMang/heap_4.c" -) - -list(FILTER ${PROJECT_NAME}_SOURCES EXCLUDE REGEX "stream_buffer.c$") - - -add_library(${PROJECT_NAME} STATIC) - -target_sources(${PROJECT_NAME} - PRIVATE ${${PROJECT_NAME}_SOURCES} - PRIVATE ${LIB_DIR}/freertos/portable/GCC/ARM_CM4F/port.c -) - -target_link_libraries(${PROJECT_NAME} - PRIVATE hal -) - -target_include_directories(${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC ${LIB_DIR}/freertos/include - PUBLIC ${LIB_DIR}/freertos/portable/GCC/ARM_CM4F - PRIVATE $ -) - -add_dependencies(${PROJECT_NAME} - hal -) diff --git a/hw/bsp/atom/drivers/rtos/FreeRTOSConfig.h b/hw/bsp/atom/drivers/rtos/FreeRTOSConfig.h deleted file mode 100644 index ef4908fe..00000000 --- a/hw/bsp/atom/drivers/rtos/FreeRTOSConfig.h +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/* - * FreeRTOS Kernel V10.3.1 - * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights - * Reserved. Portion Copyright (C) 2019 StMicroelectronics, Inc. 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! - */ -/* USER CODE END Header */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * These parameters and more are described within the 'configuration' section of - *the FreeRTOS API documentation available on the FreeRTOS.org web site. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -/* USER CODE BEGIN Includes */ -/* Section where include file can be added */ -/* USER CODE END Includes */ - -/* Ensure definitions are only used by the compiler, and not by the assembler. - */ -#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) - -#include -extern uint32_t SystemCoreClock; -void xPortSysTickHandler(void); -/* USER CODE BEGIN 0 */ -/* USER CODE END 0 */ - -#endif - -#define configENABLE_FPU 1 -#define configENABLE_MPU 0 - -#define configUSE_PREEMPTION 1 -#define configUSE_TICKLESS_IDLE 0 -#define configSUPPORT_STATIC_ALLOCATION 0 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ (SystemCoreClock) -#define configTICK_RATE_HZ (1000) -#define configMAX_PRIORITIES (6) -#define configMINIMAL_STACK_SIZE (128) -#define configTOTAL_HEAP_SIZE (0x4FFF) -#define configAPPLICATION_ALLOCATED_HEAP 1 -#define configMAX_TASK_NAME_LEN (16) -#define configGENERATE_RUN_TIME_STATS 0 -#define configUSE_TASK_NOTIFICATIONS 1 -#define configUSE_16_BIT_TICKS 0 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 0 -#define configCHECK_FOR_STACK_OVERFLOW 1 -#define configUSE_RECURSIVE_MUTEXES 0 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configENABLE_BACKWARD_COMPATIBILITY 0 -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#define configRECORD_STACK_HIGH_ADDRESS 1 -#define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 -#define configUSE_NEWLIB_REENTRANT 0 - -#ifdef MCU_DEBUG_BUILD -#define configUSE_TRACE_FACILITY 1 -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 -#else -#define configUSE_TRACE_FACILITY 0 -#define configUSE_STATS_FORMATTING_FUNCTIONS 0 -#endif - -/* Defaults to size_t for backward compatibility, but can be changed - if lengths will always be less than the number of bytes in a size_t. */ -#define configMESSAGE_BUFFER_LENGTH_TYPE size_t - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES (2) - -/* Software timer definitions. */ -#define configUSE_TIMERS 0 -#define configTIMER_TASK_PRIORITY (2) -#define configTIMER_QUEUE_LENGTH 10 -#define configTIMER_TASK_STACK_DEPTH 256 - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 0 -#define INCLUDE_uxTaskPriorityGet 0 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_xEventGroupSetBitFromISR 0 -#define INCLUDE_xTimerPendFunctionCall 0 -#define INCLUDE_xQueueGetMutexHolder 0 -#define INCLUDE_xSemaphoreGetMutexHolder 0 -#define INCLUDE_pcTaskGetTaskName 0 -#define INCLUDE_uxTaskGetStackHighWaterMark 0 -#define INCLUDE_uxTaskGetStackHighWaterMark2 0 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_eTaskGetState 0 -#define INCLUDE_xTaskAbortDelay 0 -#define INCLUDE_xTaskGetHandle 1 - -/* Cortex-M specific definitions. */ -#ifdef __NVIC_PRIO_BITS -/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ -#define configPRIO_BITS __NVIC_PRIO_BITS -#else -#define configPRIO_BITS 4 -#endif - -/* The lowest interrupt priority that can be used in a call to a "set priority" -function. */ -#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1 << configPRIO_BITS) - 1) - -/* The highest interrupt priority that can be used by any interrupt service -routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL -INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER -PRIORITY THAN THIS! (higher priorities are lower numeric values. */ -#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 - -/* Interrupt priorities used by the kernel port layer itself. These are generic -to all Cortex-M ports, and do not rely on any particular library functions. */ -#define configKERNEL_INTERRUPT_PRIORITY \ - (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) -/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY \ - (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -/* USER CODE BEGIN 1 */ -#define configASSERT(x) \ - if ((x) == 0) { \ - taskDISABLE_INTERRUPTS(); \ - for (;;) \ - ; \ - } -/* USER CODE END 1 */ - -/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS -standard names. */ -#define vPortSVCHandler SVC_Handler -#define xPortPendSVHandler PendSV_Handler - -/* Definitions needed when configGENERATE_RUN_TIME_STATS is on */ - -#endif /* FREERTOS_CONFIG_H */ diff --git a/hw/bsp/atom/drivers/rtos/rtos.c b/hw/bsp/atom/drivers/rtos/rtos.c deleted file mode 100644 index 79ba7a54..00000000 --- a/hw/bsp/atom/drivers/rtos/rtos.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Includes ------------------------------------------------------------------*/ -#include "FreeRTOS.h" -#include "task.h" - -/* FreeRTOS Heap */ -uint8_t ucHeap[configTOTAL_HEAP_SIZE]; - -void SysTick_Handler(void) { -#if (INCLUDE_xTaskGetSchedulerState == 1) - if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { -#endif /* INCLUDE_xTaskGetSchedulerState */ - xPortSysTickHandler(); -#if (INCLUDE_xTaskGetSchedulerState == 1) - } -#endif -} - -void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) { - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is - called if a stack overflow is detected. */ - - (void)xTask; - (void)pcTaskName; - taskDISABLE_INTERRUPTS(); - while (1) { - } -} - -/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide - * an implementation of vApplicationGetIdleTaskMemory() to provide the memory - * that is used by the Idle task. */ -void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, - StackType_t **ppxIdleTaskStackBuffer, - uint32_t *pulIdleTaskStackSize) { - /* If the buffers to be provided to the Idle task are declared inside this - * function then they must be declared static - otherwise they will be - * allocated on the stack and so not exists after this function exits. */ - static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; - - /* Pass out a pointer to the StaticTask_t structure in which the Idle task's - state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; - - /* Pass out the array that will be used as the Idle task's stack. */ - *ppxIdleTaskStackBuffer = uxIdleTaskStack; - - /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; -} - -/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so - * the application must provide an implementation of - * vApplicationGetTimerTaskMemory() to provide the memory that is used by the - * Timer service task. */ -void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, - StackType_t **ppxTimerTaskStackBuffer, - uint32_t *pulTimerTaskStackSize) { - /* If the buffers to be provided to the Timer task are declared inside this - * function then they must be declared static - otherwise they will be - * allocated on the stack and so not exists after this function exits. */ - static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; - - /* Pass out a pointer to the StaticTask_t structure in which the Timer - task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; - - /* Pass out the array that will be used as the Timer task's stack. */ - *ppxTimerTaskStackBuffer = uxTimerTaskStack; - - /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; -} diff --git a/hw/bsp/atom/ld/LinkerScripts.ld b/hw/bsp/atom/ld/LinkerScripts.ld deleted file mode 100644 index c0c29021..00000000 --- a/hw/bsp/atom/ld/LinkerScripts.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : STM32CubeMX -** -** Abstract : Linker script for STM32G431KBUx series -** 128Kbytes FLASH and 32Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 124K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/hw/bsp/atom/ld/LinkerScripts_with_bl.ld b/hw/bsp/atom/ld/LinkerScripts_with_bl.ld deleted file mode 100644 index aec84504..00000000 --- a/hw/bsp/atom/ld/LinkerScripts_with_bl.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : STM32CubeMX -** -** Abstract : Linker script for STM32G431KBUx series -** 128Kbytes FLASH and 32Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -FLASH (rx) : ORIGIN = 0x8005000, LENGTH = 104K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/hw/bsp/atom/main.cpp b/hw/bsp/atom/main.cpp deleted file mode 100644 index 13ae9be0..00000000 --- a/hw/bsp/atom/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "bsp.h" -#include "robot.hpp" - -int main() { - bsp_init(); - robot_init(); -} diff --git a/hw/bsp/atom/toolchain.cmake b/hw/bsp/atom/toolchain.cmake deleted file mode 100644 index f63e007e..00000000 --- a/hw/bsp/atom/toolchain.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# Target definition -set(CMAKE_SYSTEM_NAME Generic) -set(CMAKE_SYSTEM_PROCESSOR ARM) - -# Toolchain settings -set(CMAKE_LINKER arm-none-eabi-ld) -set(CMAKE_AR arm-none-eabi-ar) -set(CMAKE_SIZE arm-none-eabi-size) -set(CMAKE_OBJCOPY arm-none-eabi-objcopy) -set(CMAKE_OBJDUMP arm-none-eabi-objdump) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -# this makes the test compiles use static library option so that we don't need -# to pre-set linker flags and scripts -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -set(CLANG_TARGET arm-none-eabi) -set(GNU_COMPILER arm-none-eabi) - -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_ASM_COMPILER clang) - -execute_process( - COMMAND arm-none-eabi-gcc -print-sysroot - OUTPUT_VARIABLE GCC_ARM_NONE_EABI_ROOT - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -if(NOT EXISTS ${GCC_ARM_NONE_EABI_ROOT}) - if(NOT EXISTS /usr/lib/arm-none-eabi OR NOT EXISTS /usr/include/newlib) - message(FATAL_ERROR "Could not find arm-none-eabi toolchain.") - endif() - file(GLOB GCC_ARM_NONE_EABI_INCLUDE - "/usr/include/newlib/c++/*/cstddef") - - get_filename_component(GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_INCLUDE}" DIRECTORY) - add_compile_options( - --sysroot=/usr/lib/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE} - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/../../ - ) -else() - -file(GLOB_RECURSE GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_ROOT}/include/c++/*/cstddef") - -get_filename_component(GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_INCLUDE}" DIRECTORY) - -add_compile_options( - -isystem${GCC_ARM_NONE_EABI_INCLUDE} - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi/include - -isystem${GCC_ARM_NONE_EABI_ROOT}/include -) -endif() - -add_compile_options( - --target=${CLANG_TARGET} -) - -# Use GUN linker. Because this project use nano and nosys lib, but lld.ld do not -# support specs files. -set(CMAKE_C_LINK_EXECUTABLE - "${GNU_COMPILER}-gcc -o -lc" -) -set(CMAKE_CXX_LINK_EXECUTABLE - "${GNU_COMPILER}-g++ -o -lc" -) diff --git a/hw/bsp/atom_bl/Kconfig b/hw/bsp/atom_bl/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/hw/bsp/atom_bl/board.cmake b/hw/bsp/atom_bl/board.cmake deleted file mode 100644 index 5c857b3d..00000000 --- a/hw/bsp/atom_bl/board.cmake +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -add_compile_definitions(STM32G431xx USE_FULL_LL_DRIVER) - -set(HAL_DIR ${MCU_DIR}/st/stm32g4xx_hal_driver) -set(STM32_CMSIS_DIR ${MCU_DIR}/st/cmsis_device_g4) -set(ARM_CMSIS_DIR ${LIB_DIR}/cmsis_5) - -set(SUPPORT_DECIMAL_SPECIFIERS 0) -include(${MCU_DIR}/st/cmake/mcu_stm32g4.cmake) -include(${MCU_DIR}/st/cmake/toolchain_utils.cmake) - -add_subdirectory(${BOARD_DIR}/drivers) - -add_executable(${PROJECT_NAME}.elf ${BOARD_DIR}/main.cpp) - -target_link_libraries( - ${PROJECT_NAME}.elf - PUBLIC bsp - PUBLIC system - PUBLIC robot) - - -target_include_directories( - ${PROJECT_NAME}.elf - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE $ - PRIVATE $ - PRIVATE $ -) - -create_hex_output(${PROJECT_NAME}) -create_bin_output(${PROJECT_NAME}) -print_section_sizes(${PROJECT_NAME}.elf) diff --git a/hw/bsp/atom_bl/config/bootloader.config b/hw/bsp/atom_bl/config/bootloader.config deleted file mode 100644 index ce977b61..00000000 --- a/hw/bsp/atom_bl/config/bootloader.config +++ /dev/null @@ -1,94 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -CONFIG_auto_generated_config_prefix_board-atom_bl=y -# CONFIG_auto_generated_config_prefix_board-atom is not set -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-mangopi_r818_with_ch348 is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -# CONFIG_auto_generated_config_prefix_system-None is not set -# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -# CONFIG_auto_generated_config_prefix_system-Linux is not set -CONFIG_auto_generated_config_prefix_system-Bootloader=y -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -CONFIG_auto_generated_config_prefix_robot-bootloader=y -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-canfd_imu is not set -# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set - -# -# 组件 -# - -# -# 设备 -# -# CONFIG_auto_generated_config_prefix_device-wearlab is not set -# CONFIG_auto_generated_config_prefix_device-icm42688 is not set -# CONFIG_auto_generated_config_prefix_device-ahrs-9 is not set -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -# CONFIG_auto_generated_config_prefix_device-net_config is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -# CONFIG_auto_generated_config_prefix_device-blink_led is not set -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-motor is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-mmc5603 is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -CONFIG_auto_generated_config_prefix_module-uart_update=y -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp_client is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-performance is not set -# CONFIG_auto_generated_config_prefix_module-topic_share_uart is not set -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# end of 模块 diff --git a/hw/bsp/atom_bl/debug/atom.jdebug b/hw/bsp/atom_bl/debug/atom.jdebug deleted file mode 100644 index 06ac1035..00000000 --- a/hw/bsp/atom_bl/debug/atom.jdebug +++ /dev/null @@ -1,337 +0,0 @@ -/********************************************************************* -* (c) SEGGER Microcontroller GmbH * -* The Embedded Experts * -* www.segger.com * -********************************************************************** - -File : rm_c.jdebug -Created : 12 Feb 2023 19:50 -Ozone Version : V3.24g -*/ - -/********************************************************************* -* -* OnProjectLoad -* -* Function description -* Project load routine. Required. -* -********************************************************************** -*/ -void OnProjectLoad (void) { - Edit.SysVar (VAR_HSS_SPEED, FREQ_200_HZ); - // - // Dialog-generated settings - // - Project.AddPathSubstitute ("../../../../hw/bsp/rm-c/debug", "$(ProjectDir)"); - Project.AddPathSubstitute ("../../../../hw/bsp/rm-c/debug", "$(ProjectDir)"); - Project.SetDevice ("STM32g431KB"); - Project.SetHostIF ("USB", ""); - Project.SetTargetIF ("SWD"); - Project.SetTIFSpeed ("4 MHz"); - Project.AddSvdFile ("../../../../lib/cmsis_svd/data/STMicro/STM32G431xx.svd"); - // - // User settings - // - File.Open ("../../../../build/xrobot.elf"); -} - -/********************************************************************* -* -* OnStartupComplete -* -* Function description -* Called when program execution has reached/passed -* the startup completion point. Optional. -* -********************************************************************** -*/ -//void OnStartupComplete (void) { -//} - -/********************************************************************* -* -* TargetReset -* -* Function description -* Replaces the default target device reset routine. Optional. -* -* Notes -* This example demonstrates the usage when -* debugging an application in RAM on a Cortex-M target device. -* -********************************************************************** -*/ -//void TargetReset (void) { -// -// unsigned int SP ; -// unsigned int PC ; -// unsigned int VectorTableAddr ; -// -// VectorTableAddr = Elf.GetBaseAddr() ; -// // -// // Set up initial stack pointer -// // -// if (VectorTableAddr != 0xFFFFFFFF) { -// SP = Target.ReadU32(VectorTableAddr) ; -// Target.SetReg("SP", SP) ; -// } -// // -// // Set up entry point PC -// // -// PC = Elf.GetEntryPointPC() ; -// -// if (PC != 0xFFFFFFFF) { -// Target.SetReg("PC", PC) ; -// } else if (VectorTableAddr != 0xFFFFFFFF) { -// PC = Target.ReadU32(VectorTableAddr + 4) ; -// Target.SetReg("PC", PC) ; -// } else { -// Util.Error("Project file error: failed to set entry point PC", 1) ; -// } -//} - -/********************************************************************* -* -* BeforeTargetReset -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetReset (void) { -//} - -/********************************************************************* -* -* AfterTargetReset -* -* Function description -* Event handler routine. Optional. -* The default implementation initializes SP and PC to reset values. -** -********************************************************************** -*/ -void AfterTargetReset (void) { -_SetupTarget() ; -} - -/********************************************************************* -* -* DebugStart -* -* Function description -* Replaces the default debug session startup routine. Optional. -* -********************************************************************** -*/ -//void DebugStart (void) { -//} - -/********************************************************************* -* -* TargetConnect -* -* Function description -* Replaces the default target IF connection routine. Optional. -* -********************************************************************** -*/ -//void TargetConnect (void) { -//} - -/********************************************************************* -* -* BeforeTargetConnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetConnect (void) { -//} - -/********************************************************************* -* -* AfterTargetConnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetConnect (void) { -//} - -/********************************************************************* -* -* TargetDownload -* -* Function description -* Replaces the default program download routine. Optional. -* -********************************************************************** -*/ -//void TargetDownload (void) { -//} - -/********************************************************************* -* -* BeforeTargetDownload -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetDownload (void) { -//} - -/********************************************************************* -* -* AfterTargetDownload -* -* Function description -* Event handler routine. Optional. -* The default implementation initializes SP and PC to reset values. -* -********************************************************************** -*/ -void AfterTargetDownload (void) { -_SetupTarget() ; -} - -/********************************************************************* -* -* BeforeTargetDisconnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetDisconnect (void) { -//} - -/********************************************************************* -* -* AfterTargetDisconnect -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetDisconnect (void) { -//} - -/********************************************************************* -* -* AfterTargetHalt -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void AfterTargetHalt (void) { -//} - -/********************************************************************* -* -* BeforeTargetResume -* -* Function description -* Event handler routine. Optional. -* -********************************************************************** -*/ -//void BeforeTargetResume (void) { -//} - -/********************************************************************* -* -* OnSnapshotLoad -* -* Function description -* Called upon loading a snapshot. Optional. -* -* Additional information -* This function is used to restore the target state in cases -* where values cannot simply be written to the target. -* Typical use: GPIO clock needs to be enabled, before -* GPIO is configured. -* -********************************************************************** -*/ -//void OnSnapshotLoad (void) { -//} - -/********************************************************************* -* -* OnSnapshotSave -* -* Function description -* Called upon saving a snapshot. Optional. -* -* Additional information -* This function is usually used to save values of the target -* state which can either not be trivially read, -* or need to be restored in a specific way or order. -* Typically use: Memory Mapped Registers, -* such as PLL and GPIO configuration. -* -********************************************************************** -*/ -//void OnSnapshotSave (void) { -//} - -/********************************************************************* -* -* OnError -* -* Function description -* Called when an error ocurred. Optional. -* -********************************************************************** -*/ -//void OnError (void) { -//} - -/********************************************************************* -* -* _SetupTarget -* -* Function description -* Setup the target. -* Called by AfterTargetReset() and AfterTargetDownload(). -* -* Auto-generated function. May be overridden by Ozone. -* -********************************************************************** -*/ -void _SetupTarget(void) { -unsigned int SP ; -unsigned int PC ; -unsigned int VectorTableAddr ; - -VectorTableAddr = Elf.GetBaseAddr() ; -// -// Set up initial stack pointer -// -SP = Target.ReadU32(VectorTableAddr) ; -if (SP != 0xFFFFFFFF) { -Target.SetReg("SP", SP) ; -} -// -// Set up entry point PC -// -PC = Elf.GetEntryPointPC() ; -if (PC != 0xFFFFFFFF) { -Target.SetReg("PC", PC) ; -} else { -Util.Error("Project script error: failed to set up entry point PC", 1) ; -} -} diff --git a/hw/bsp/atom_bl/debug/launch.json b/hw/bsp/atom_bl/debug/launch.json deleted file mode 100644 index be866af4..00000000 --- a/hw/bsp/atom_bl/debug/launch.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "configurations": [ - { - "name": "ARM-Debug", - "cwd": "${workspaceRoot}", - "executable": "${workspaceRoot}/build/xrobot.elf", - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "device": "STM32G431KB", - "interface": "swd", - "runToEntryPoint": "main", - "svdFile": "${workspaceRoot}/lib/cmsis_svd/data/STMicro/STM32G431xx.svd", - "configFiles": [ - "", - "" - ] - } - ], - "version": "0.2.0" -} diff --git a/hw/bsp/atom_bl/drivers/CMakeLists.txt b/hw/bsp/atom_bl/drivers/CMakeLists.txt deleted file mode 100644 index 955d2483..00000000 --- a/hw/bsp/atom_bl/drivers/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -project(bsp) - -set(CMAKE_C_FLAGS_DEBUG "-Os") -set(CMAKE_ASM_FLAGS_DEBUG "-Os") - -file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c") - -add_library(${PROJECT_NAME} STATIC) - -target_sources(${PROJECT_NAME} PRIVATE ${${PROJECT_NAME}_SOURCES}) - -include(${MCU_DIR}/default/CMakeLists.txt) - -target_link_libraries( - ${PROJECT_NAME} - PUBLIC hal) - -target_include_directories( - ${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $) - -add_dependencies(${PROJECT_NAME} hal) - -add_subdirectory(${BOARD_DIR}/drivers/hal) diff --git a/hw/bsp/atom_bl/drivers/bsp.c b/hw/bsp/atom_bl/drivers/bsp.c deleted file mode 100644 index 8a7d6954..00000000 --- a/hw/bsp/atom_bl/drivers/bsp.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "bsp.h" - -#include "bsp_can.h" -#include "bsp_uart.h" -#include "main.h" -#include "stm32g4xx_hal_i2c.h" -#include "stm32g4xx_hal_msp.c" -#include "stm32g4xx_hal_tim.h" -#include "stm32g4xx_it.c" - -void bsp_init() { - uwTickPrio = TICK_INT_PRIORITY; - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. - */ - HAL_Init(); - - /* Configure the system clock */ - SystemClock_Config(); - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_FDCAN1_Init(); - MX_USART2_UART_Init(); -} diff --git a/hw/bsp/atom_bl/drivers/bsp.h b/hw/bsp/atom_bl/drivers/bsp.h deleted file mode 100644 index 3141bcb4..00000000 --- a/hw/bsp/atom_bl/drivers/bsp.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp_def.h" - -typedef struct { - void (*fn)(void *); - void *arg; -} bsp_callback_t; - -void bsp_init(void); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_can.c b/hw/bsp/atom_bl/drivers/bsp_can.c deleted file mode 100644 index 5822138b..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_can.c +++ /dev/null @@ -1,192 +0,0 @@ -#include "bsp_can.h" - -#include "bsp_def.h" -#include "cmsis_gcc.h" -#include "main.h" -#include "stm32g4xx_hal_fdcan.h" - -typedef struct { - FDCAN_RxHeaderTypeDef header; - uint8_t data[64]; -} can_raw_rx_t; - -typedef struct { - FDCAN_HandleTypeDef header; - uint8_t data[8]; -} can_raw_tx_t; - -typedef struct { - void (*fn)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg); - void *arg; -} can_callback_t; - -extern FDCAN_HandleTypeDef hfdcan1; - -static can_callback_t callback_list[BSP_CAN_NUM][BSP_CAN_CB_NUM]; - -static bool bsp_can_initd = false; - -static can_raw_rx_t rx_buff[BSP_CAN_NUM]; - -FDCAN_HandleTypeDef *bsp_can_get_handle(bsp_can_t can) { - switch (can) { - case BSP_CAN_1: - return &hfdcan1; - default: - return NULL; - } -} - -static bsp_can_t can_get(FDCAN_HandleTypeDef *hcan) { - if (hcan->Instance == FDCAN1) { - return BSP_CAN_1; - } else { - return BSP_CAN_ERR; - } -} - -void bsp_can_init(void) { - FDCAN_FilterTypeDef can_filter = {0}; - - can_filter.IdType = FDCAN_STANDARD_ID; - can_filter.FilterIndex = 0; - can_filter.FilterType = FDCAN_FILTER_MASK; - can_filter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; - can_filter.FilterID1 = 0x0000; - can_filter.FilterID2 = 0x0000; - if (HAL_FDCAN_ConfigFilter(&hfdcan1, &can_filter) != HAL_OK) { - XB_ASSERT(false); - } - - can_filter.IdType = FDCAN_EXTENDED_ID; - can_filter.FilterIndex = 1; - can_filter.FilterType = FDCAN_FILTER_MASK; - can_filter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; - can_filter.FilterID1 = 0x0000; - can_filter.FilterID2 = 0x0000; - if (HAL_FDCAN_ConfigFilter(&hfdcan1, &can_filter) != HAL_OK) { - XB_ASSERT(false); - } - - HAL_FDCAN_Start(&hfdcan1); //开启FDCAN - HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0); - HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_TX_FIFO_EMPTY, 0); - - bsp_can_initd = true; -} - -static void can_rx_cb_fn(bsp_can_t can) { - if (callback_list[can][CAN_RX_MSG_CALLBACK].fn) { - while (HAL_FDCAN_GetRxMessage(bsp_can_get_handle(can), FDCAN_RX_FIFO0, - &rx_buff[can].header, - rx_buff[can].data) == HAL_OK) { - if (rx_buff[can].header.IdType == FDCAN_STANDARD_ID) { - callback_list[can][CAN_RX_MSG_CALLBACK].fn( - can, rx_buff[can].header.Identifier, rx_buff[can].data, - callback_list[can][CAN_RX_MSG_CALLBACK].arg); - } else { - callback_list[can][CANFD_RX_MSG_CALLBACK].fn( - can, rx_buff[can].header.Identifier, rx_buff[can].data, - callback_list[can][CANFD_RX_MSG_CALLBACK].arg); - } - } - } -} - -void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hcan, uint32_t RxFifo0ITs) { - (void)RxFifo0ITs; - can_rx_cb_fn(can_get(hcan)); -} - -bsp_status_t bsp_can_register_callback( - bsp_can_t can, bsp_can_callback_t type, - void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), - void *callback_arg) { - assert_param(callback); - assert_param(type != BSP_CAN_CB_NUM); - - callback_list[can][type].fn = callback; - callback_list[can][type].arg = callback_arg; - return BSP_OK; -} - -bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data) { - FDCAN_TxHeaderTypeDef header; - - header.Identifier = id; - - if (format == CAN_FORMAT_STD) { - header.IdType = FDCAN_STANDARD_ID; - } else { - header.IdType = FDCAN_EXTENDED_ID; - } - - header.TxFrameType = FDCAN_DATA_FRAME; - header.DataLength = FDCAN_DLC_BYTES_8; - header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; - header.BitRateSwitch = FDCAN_BRS_OFF; - header.FDFormat = FDCAN_CLASSIC_CAN; - header.TxEventFifoControl = FDCAN_STORE_TX_EVENTS; - header.MessageMarker = 0x01; - while ((bsp_can_get_handle(can)->Instance->TXFQS & FDCAN_TXFQS_TFQF) != 0U) { - __NOP(); - } - - return HAL_FDCAN_AddMessageToTxFifoQ(bsp_can_get_handle(can), &header, - data) == HAL_OK - ? BSP_OK - : BSP_ERR; -} - -static const uint32_t FDCAN_PACK_LEN_MAP[16] = { - FDCAN_DLC_BYTES_0, FDCAN_DLC_BYTES_1, FDCAN_DLC_BYTES_2, - FDCAN_DLC_BYTES_3, FDCAN_DLC_BYTES_4, FDCAN_DLC_BYTES_5, - FDCAN_DLC_BYTES_6, FDCAN_DLC_BYTES_7, FDCAN_DLC_BYTES_8, - FDCAN_DLC_BYTES_12, FDCAN_DLC_BYTES_16, FDCAN_DLC_BYTES_20, - FDCAN_DLC_BYTES_24, FDCAN_DLC_BYTES_32, FDCAN_DLC_BYTES_48, - FDCAN_DLC_BYTES_64, -}; - -bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data, size_t size) { - FDCAN_TxHeaderTypeDef header; - - XB_ASSERT(size <= 64); - - header.Identifier = id; - - if (format == CAN_FORMAT_STD) { - header.IdType = FDCAN_STANDARD_ID; - } else { - header.IdType = FDCAN_EXTENDED_ID; - } - - header.TxFrameType = FDCAN_DATA_FRAME; - - if (size <= 8) { - header.DataLength = FDCAN_PACK_LEN_MAP[size]; - } else if (size <= 24) { - header.DataLength = FDCAN_PACK_LEN_MAP[(size - 9) / 4 + 1 + 8]; - } else if (size < 32) { - header.DataLength = FDCAN_DLC_BYTES_32; - } else if (size < 48) { - header.DataLength = FDCAN_DLC_BYTES_48; - } else { - header.DataLength = FDCAN_DLC_BYTES_64; - } - - header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; - header.BitRateSwitch = FDCAN_BRS_OFF; - header.FDFormat = FDCAN_FD_CAN; - header.TxEventFifoControl = FDCAN_STORE_TX_EVENTS; - header.MessageMarker = 0x01; - while ((bsp_can_get_handle(can)->Instance->TXFQS & FDCAN_TXFQS_TFQF) != 0U) { - __NOP(); - } - - return HAL_FDCAN_AddMessageToTxFifoQ(bsp_can_get_handle(can), &header, - data) == HAL_OK - ? BSP_OK - : BSP_ERR; -} diff --git a/hw/bsp/atom_bl/drivers/bsp_can.h b/hw/bsp/atom_bl/drivers/bsp_can.h deleted file mode 100644 index 26a0ed4b..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_can.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -typedef enum { - BSP_CAN_1, - BSP_CAN_NUM, - BSP_CAN_ERR, -} bsp_can_t; - -typedef enum { - CAN_RX_MSG_CALLBACK, - CAN_TX_CPLT_CALLBACK, - CANFD_RX_MSG_CALLBACK, - CANFD_TX_CPLT_CALLBACK, - BSP_CAN_CB_NUM -} bsp_can_callback_t; - -typedef enum { - CAN_FORMAT_STD, - CAN_FORMAT_EXT, -} bsp_can_format_t; - -void bsp_can_init(void); -bsp_status_t bsp_can_register_callback( - bsp_can_t can, bsp_can_callback_t type, - void (*callback)(bsp_can_t can, uint32_t id, uint8_t *data, void *arg), - void *callback_arg); -bsp_status_t bsp_can_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data); - -bsp_status_t bsp_canfd_trans_packet(bsp_can_t can, bsp_can_format_t format, - uint32_t id, uint8_t *data, size_t size); - -bsp_status_t bsp_can_get_msg(bsp_can_t can, uint8_t *data, uint32_t *index); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_flash.c b/hw/bsp/atom_bl/drivers/bsp_flash.c deleted file mode 100644 index 4f0eb6d0..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_flash.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "bsp_flash.h" - -#include "bsp_def.h" -#include "stm32g4xx_hal.h" - -bsp_status_t bsp_flash_init(); - -bsp_status_t bsp_flash_wirte(void* addr, size_t size, const void* buff) { - void* startaddr = addr; - const uint8_t* data = buff; - - if (HAL_FLASH_Unlock() != HAL_OK) { - return BSP_ERR; - } - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); - - /* HW needs an aligned addr to program flash, which data - * parameters doesn't ensure */ - /* case where data is aligned, so let's avoid any copy */ - while ((addr < (startaddr + size))) { - if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, (uint32_t)addr, - *((uint64_t*)data)) == HAL_OK) { - addr = addr + 8; - data = data + 8; - } else { - break; - } - } - - HAL_FLASH_Lock(); - - return BSP_OK; -} - -bsp_status_t bsp_flash_erase(void* addr, size_t size) { - FLASH_EraseInitTypeDef flash_erase; - - void* startaddr = addr; - - uint32_t sector_error = 0; - - HAL_FLASH_Unlock(); - - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); - - while (addr < startaddr + size) { - flash_erase.NbPages = 1; - flash_erase.Banks = FLASH_BANK_1; - flash_erase.Page = ((uint32_t)(addr)-FLASH_BASE) / FLASH_PAGE_SIZE; - flash_erase.TypeErase = FLASH_TYPEERASE_PAGES; - addr += BSP_FLASH_BLOCK_SIZE; - } - - /* Erase FLASH*/ - HAL_FLASHEx_Erase(&flash_erase, §or_error); - - HAL_FLASH_Lock(); - - return BSP_OK; -} diff --git a/hw/bsp/atom_bl/drivers/bsp_flash.h b/hw/bsp/atom_bl/drivers/bsp_flash.h deleted file mode 100644 index c545aa4c..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_flash.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -#define BSP_FLASH_BLOCK_SIZE (2048) -#define BSP_FLASH_APP_ADDR (0x8005000) -#define BSP_FLASH_APP_SIZE (1024 * 104) - -bsp_status_t bsp_flash_init(); - -bsp_status_t bsp_flash_wirte(void* addr, size_t size, const void* buff); - -bsp_status_t bsp_flash_erase(void* addr, size_t size); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_gpio.c b/hw/bsp/atom_bl/drivers/bsp_gpio.c deleted file mode 100644 index b8788beb..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_gpio.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "bsp_gpio.h" - -#include "main.h" - -typedef struct { - uint16_t pin; - GPIO_TypeDef *gpio; -} bsp_gpio_map_t; - -static const bsp_gpio_map_t BSP_GPIO_MAP[BSP_GPIO_NUM] = { - {LED_RUN_Pin, LED_RUN_GPIO_Port}, -}; - -static bsp_callback_t callback_list[16]; - -void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - for (uint8_t i = 0; i < 16; i++) { - if (GPIO_Pin & (1 << i)) { - __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); - bsp_callback_t cb = callback_list[i]; - - if (cb.fn) { - cb.fn(cb.arg); - } - } - } -} - -bsp_status_t bsp_gpio_register_callback(bsp_gpio_t gpio, - void (*callback)(void *), - void *callback_arg) { - assert_param(callback); - - uint16_t pin = BSP_GPIO_MAP[gpio].pin; - - for (uint8_t i = 0; i < 16; i++) { - if (pin & (1 << i)) { - callback_list[i].fn = callback; - callback_list[i].arg = callback_arg; - return BSP_OK; - } - } - return BSP_ERR; -} - -inline bsp_status_t bsp_gpio_write_pin(bsp_gpio_t gpio, bool value) { - HAL_GPIO_WritePin(BSP_GPIO_MAP[gpio].gpio, BSP_GPIO_MAP[gpio].pin, value); - return BSP_OK; -} - -inline bool bsp_gpio_read_pin(bsp_gpio_t gpio) { - return HAL_GPIO_ReadPin(BSP_GPIO_MAP[gpio].gpio, BSP_GPIO_MAP[gpio].pin); -} diff --git a/hw/bsp/atom_bl/drivers/bsp_gpio.h b/hw/bsp/atom_bl/drivers/bsp_gpio.h deleted file mode 100644 index 76a26dec..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_gpio.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -typedef enum { - BSP_GPIO_LED, - BSP_GPIO_NUM, -} bsp_gpio_t; - -bsp_status_t bsp_gpio_register_callback(bsp_gpio_t gpio, - void (*callback)(void *), - void *callback_arg); - -bsp_status_t bsp_gpio_write_pin(bsp_gpio_t gpio, bool value); -bool bsp_gpio_read_pin(bsp_gpio_t gpio); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_sys.h b/hw/bsp/atom_bl/drivers/bsp_sys.h deleted file mode 100644 index 3c2d35aa..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_sys.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include "bsp_def.h" -#include "main.h" -#include "stm32g4xx_hal_uart.h" - -/* 软件复位 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_reset(void) { - __set_FAULTMASK(1); - NVIC_SystemReset(); -} - -/* 关机 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_shutdown( - void) { - HAL_PWR_EnterSTANDBYMode(); -} - -/* 进入Bootloader */ -__attribute__((always_inline, unused)) static inline void bsp_sys_bootloader( - void) { - __enable_irq(); - HAL_RCC_DeInit(); - HAL_DeInit(); - SysTick->CTRL = SysTick->LOAD = SysTick->VAL = 0; - __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(); - - const uint32_t p = (*((uint32_t *)0x1FFF0000)); - __set_MSP(p); - - void (*SysMemBootJump)(void); - SysMemBootJump = (void (*)(void))(*((uint32_t *)0x1FFF0004)); - SysMemBootJump(); - - NVIC_SystemReset(); -} - -/* 进入APP */ -__attribute__((always_inline, unused)) static inline void bsp_sys_jump_app( - void) { - HAL_RCC_DeInit(); - HAL_DeInit(); - __set_MSP(0x08005000); - SCB->VTOR = 0x08005000; - static void (*APP_FUN)(); - APP_FUN = *(void (**)())(0x08005004); - APP_FUN(); -} - -/* 睡眠模式 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_sleep(void) { - HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); -} - -/* 停止模式 */ -__attribute__((always_inline, unused)) static inline void bsp_sys_stop(void) { - HAL_PWR_EnterSTANDBYMode(); -} - -/* 中断状态 */ -__attribute__((always_inline, unused)) static inline bool bsp_sys_in_isr(void) { - uint32_t result; - __asm__ volatile("MRS %0, ipsr" : "=r"(result)); - return (result); -} diff --git a/hw/bsp/atom_bl/drivers/bsp_time.c b/hw/bsp/atom_bl/drivers/bsp_time.c deleted file mode 100644 index c89851fa..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_time.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "bsp_time.h" - -#include "main.h" - -uint32_t bsp_time_get_ms() { return HAL_GetTick(); } - -uint64_t bsp_time_get_us() { - uint32_t ms_old = HAL_GetTick(); - uint32_t tick_value_old = SysTick->VAL; - uint32_t ms_new = HAL_GetTick(); - uint32_t tick_value_new = SysTick->VAL; - if (ms_old == ms_new) { - return ms_new * 1000 + 1000 - tick_value_old * 1000 / (SysTick->LOAD + 1); - } else { - return ms_new * 1000 + 1000 - tick_value_new * 1000 / (SysTick->LOAD + 1); - } -} - -uint64_t bsp_time_get() __attribute__((alias("bsp_time_get_us"))); diff --git a/hw/bsp/atom_bl/drivers/bsp_time.h b/hw/bsp/atom_bl/drivers/bsp_time.h deleted file mode 100644 index 55c2485e..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_time.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -uint32_t bsp_time_get_ms(); - -uint64_t bsp_time_get_us(); - -uint64_t bsp_time_get(); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_uart.c b/hw/bsp/atom_bl/drivers/bsp_uart.c deleted file mode 100644 index 26de48c0..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_uart.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "bsp_uart.h" - -#include "bsp_def.h" -#include "main.h" -#include "stm32g4xx_hal.h" -#include "stm32g4xx_it.h" - -uint8_t bsp_usart2_read_byte(void) { - uint32_t tick = HAL_GetTick(); - while (!LL_USART_IsActiveFlag_RXNE_RXFNE(USART2) && - HAL_GetTick() - tick < 25) { - } - - return LL_USART_ReceiveData8(USART2); -} - -void bsp_usart2_send_byte(uint8_t Byte) { - uint32_t tick = HAL_GetTick(); - LL_USART_TransmitData8(USART2, (Byte & 0xFF)); - while (!LL_USART_IsActiveFlag_TC(USART2) && HAL_GetTick() - tick < 25) { - } -} - -bsp_status_t bsp_uart_transmit(bsp_uart_t uart, uint8_t *data, size_t size, - bool block) { - XB_UNUSED(uart); - - if (block) { - while (size--) { - bsp_usart2_send_byte(*(data++)); - } - } else { - XB_ASSERT(false); - } - - return BSP_OK; -} - -bsp_status_t bsp_uart_receive(bsp_uart_t uart, uint8_t *buff, size_t size, - bool block) { - XB_UNUSED(uart); - - if (block) { - while (size--) { - *(buff++) = bsp_usart2_read_byte(); - } - } else { - XB_ASSERT(false); - } - - return BSP_OK; -} - -uint32_t bsp_uart_get_count(bsp_uart_t uart) { - XB_UNUSED(uart); - return 0; -} - -bsp_status_t bsp_uart_abort_receive(bsp_uart_t uart) { - XB_UNUSED(uart); - return BSP_OK; -} diff --git a/hw/bsp/atom_bl/drivers/bsp_uart.h b/hw/bsp/atom_bl/drivers/bsp_uart.h deleted file mode 100644 index 5bd45ddd..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_uart.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" -#include "main.h" - -/* 要添加使用UART的新设备,需要先在此添加对应的枚举值 */ - -/* UART实体枚举,与设备对应 */ -typedef enum { - BSP_UART_MCU, - /* BSP_UART_XXX, */ - BSP_UART_NUM, - BSP_UART_ERR, -} bsp_uart_t; - -/* UART支持的中断回调函数类型,具体参考HAL中定义 */ -typedef enum { - BSP_UART_TX_HALF_CPLT_CB, - BSP_UART_TX_CPLT_CB, - BSP_UART_RX_HALF_CPLT_CB, - BSP_UART_RX_CPLT_CB, - BSP_UART_ERROR_CB, - BSP_UART_ABORT_CPLT_CB, - BSP_UART_ABORT_TX_CPLT_CB, - BSP_UART_ABORT_RX_CPLT_CB, - BSP_UART_IDLE_LINE_CB, - BSP_UART_CB_NUM, -} bsp_uart_callback_t; - -void bsp_uart_init(); -uint32_t bsp_uart_get_count(bsp_uart_t uart); -bsp_status_t bsp_uart_register_callback(bsp_uart_t uart, - bsp_uart_callback_t type, - void (*callback)(void *), - void *callback_arg); -bsp_status_t bsp_uart_transmit(bsp_uart_t uart, uint8_t *data, size_t size, - bool block); -bsp_status_t bsp_uart_receive(bsp_uart_t uart, uint8_t *buff, size_t size, - bool block); -bsp_status_t bsp_uart_abort_receive(bsp_uart_t uart); -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/bsp_usb.c b/hw/bsp/atom_bl/drivers/bsp_usb.c deleted file mode 100644 index 4ee5f2f7..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_usb.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "bsp_usb.h" - -#include "bsp_def.h" -#include "bsp_uart.h" -#include "main.h" - -extern uint8_t bsp_usart2_read_byte(void); - -bsp_status_t bsp_usb_transmit(const uint8_t *buffer, uint32_t len) { - bsp_uart_transmit(BSP_UART_MCU, (uint8_t *)(buffer), len, true); - return BSP_OK; -} - -char bsp_usb_read_char(void) { return bsp_usart2_read_byte(); } - -size_t bsp_usb_read(uint8_t *buffer, uint32_t len) { - bsp_uart_receive(BSP_UART_MCU, buffer, len, true); - return len; -} - -bool bsp_usb_connect(void) { return false; } - -size_t bsp_usb_avail(void) { return 0; } - -void bsp_usb_init() {} - -void bsp_usb_update() {} diff --git a/hw/bsp/atom_bl/drivers/bsp_usb.h b/hw/bsp/atom_bl/drivers/bsp_usb.h deleted file mode 100644 index ccc8097e..00000000 --- a/hw/bsp/atom_bl/drivers/bsp_usb.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bsp.h" - -/* Exported constants ------------------------------------------------------- */ -/* Exported macro ----------------------------------------------------------- */ -/* Exported types ----------------------------------------------------------- */ - -typedef enum { - BSP_USB_CDC, - /* BSP_USB_XXX, */ - BSP_USB_NUM, - BSP_USB_ERR, -} bsp_usb_t; - -/* USB支持的中断回调函数类型 */ -typedef enum { - BSP_USB_RX_CPLT_CB, - BSP_USB_CB_NUM, -} bsp_usb_callback_t; -/* Exported functions prototypes -------------------------------------------- */ -bool bsp_usb_connect(void); /* USB已连接 */ -size_t bsp_usb_avail(void); /* USB有数据 */ -char bsp_usb_read_char(); /* 获取缓存数据 */ -size_t bsp_usb_read(uint8_t *buffer, uint32_t len); -bsp_status_t bsp_usb_transmit(const uint8_t *buffer, uint32_t len); -void bsp_usb_init(void); -void bsp_usb_update(void); - -bsp_status_t bsp_usb_register_callback(bsp_usb_t usb, bsp_usb_callback_t type, - void (*callback)(void *), - void *callback_arg); - -#ifdef __cplusplus -} -#endif diff --git a/hw/bsp/atom_bl/drivers/hal/.mxproject b/hw/bsp/atom_bl/drivers/hal/.mxproject deleted file mode 100644 index d08aeb62..00000000 --- a/hw/bsp/atom_bl/drivers/hal/.mxproject +++ /dev/null @@ -1,26 +0,0 @@ -[PreviousLibFiles] -LibFiles=Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_usart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_lpuart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart_ex.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usart.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_dma.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_usart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_lpuart.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_uart_ex.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g431xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/system_stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_armv81mml.h; - -[PreviousUsedMakefileFiles] -SourceFiles=Core/Src/main.c;Core/Src/stm32g4xx_it.c;Core/Src/stm32g4xx_hal_msp.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usart.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_rcc.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_dma.c;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;;; -HeaderPath=/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Include;/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Include;Core/Inc; -CDefines=USE_FULL_LL_DRIVER;USE_HAL_DRIVER;STM32G431xx;USE_FULL_LL_DRIVER;USE_HAL_DRIVER;USE_HAL_DRIVER; - -[PreviousGenFiles] -AdvancedFolderStructure=true -HeaderFileListSize=4 -HeaderFiles#0=../Core/Inc/stm32g4xx_it.h -HeaderFiles#1=../Core/Inc/stm32_assert.h -HeaderFiles#2=../Core/Inc/stm32g4xx_hal_conf.h -HeaderFiles#3=../Core/Inc/main.h -HeaderFolderListSize=1 -HeaderPath#0=../Core/Inc -HeaderFiles=; -SourceFileListSize=3 -SourceFiles#0=../Core/Src/stm32g4xx_it.c -SourceFiles#1=../Core/Src/stm32g4xx_hal_msp.c -SourceFiles#2=../Core/Src/main.c -SourceFolderListSize=1 -SourcePath#0=../Core/Src -SourceFiles=; - diff --git a/hw/bsp/atom_bl/drivers/hal/CMakeLists.txt b/hw/bsp/atom_bl/drivers/hal/CMakeLists.txt deleted file mode 100644 index cb4b1fa2..00000000 --- a/hw/bsp/atom_bl/drivers/hal/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -add_compile_options(-w) - -project(hal) - -file(GLOB ${PROJECT_NAME}_SOURCES_MX "${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/*.c") -file(GLOB ${PROJECT_NAME}_SOURCES_HAL "${HAL_DIR}/Src/*.c") - -list(FILTER ${PROJECT_NAME}_SOURCES_HAL EXCLUDE REGEX ".*template.c$") -list(FILTER ${PROJECT_NAME}_SOURCES_MX EXCLUDE REGEX "system_stm32g4xx.c$") - -add_library(${PROJECT_NAME} OBJECT) - -target_sources( - ${PROJECT_NAME} - PRIVATE ${${PROJECT_NAME}_SOURCES_HAL} - PRIVATE ${${PROJECT_NAME}_SOURCES_MX} - PRIVATE ${STM32_CMSIS_DIR}/Source/Templates/system_stm32g4xx.c - PRIVATE ${STM32_CMSIS_DIR}/Source/Templates/gcc/startup_stm32g431xx.s) - -target_include_directories( - ${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core/Src - PUBLIC ${HAL_DIR}/Inc - PUBLIC ${STM32_CMSIS_DIR}/Include - PUBLIC ${ARM_CMSIS_DIR}/CMSIS/Core/Include) diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Inc/main.h b/hw/bsp/atom_bl/drivers/hal/Core/Inc/main.h deleted file mode 100644 index 45611c01..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Inc/main.h +++ /dev/null @@ -1,85 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_utils.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_gpio.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); -void MX_GPIO_Init(void); -void MX_FDCAN1_Init(void); -void MX_USART2_UART_Init(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define LED_RUN_Pin LL_GPIO_PIN_0 -#define LED_RUN_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ -void SystemClock_Config(void); -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32_assert.h b/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32_assert.h deleted file mode 100644 index 3e124e43..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32_assert.h +++ /dev/null @@ -1,53 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32_assert.h - * @brief STM32 assert file. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32_ASSERT_H -#define __STM32_ASSERT_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Includes ------------------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32_ASSERT_H */ - diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h b/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 86fb89ba..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,380 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - - /*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -/*#define HAL_CRC_MODULE_ENABLED */ -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -#define HAL_UART_MODULE_ENABLED -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high precision clock to - * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. - * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency - * which is subject to manufacturing process variations. - */ -#if !defined (HSI48_VALUE) - #define HSI48_VALUE (48000000UL) /*!< Value of the Internal High Speed oscillator for USB FS/RNG in Hz. - The real value my vary depending on manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system frequency - */ -#if !defined (LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S and SAI clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (0UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_it.h b/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index fdcfb51c..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,68 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "main.h" -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN1_IT0_IRQHandler(void); -void USART2_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Src/main.c b/hw/bsp/atom_bl/drivers/hal/Core/Src/main.c deleted file mode 100644 index 291a0631..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Src/main.c +++ /dev/null @@ -1,351 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -FDCAN_HandleTypeDef hfdcan1; - -UART_HandleTypeDef huart1; - -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_USART1_UART_Init(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) - { - } - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while(LL_RCC_HSI_IsReady() != 1) - { - } - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 80, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while(LL_RCC_PLL_IsReady() != 1) - { - } - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); - /* Wait till System clock is ready */ - while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) - { - } - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i !=0; i--); - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(160000000); - - /* Update the time base */ - if (HAL_InitTick (TICK_INT_PRIORITY) != HAL_OK) - { - Error_Handler(); - } -} - -/** - * @brief FDCAN1 Initialization Function - * @param None - * @retval None - */ -void MX_FDCAN1_Init(void) -{ - - /* USER CODE BEGIN FDCAN1_Init 0 */ - - /* USER CODE END FDCAN1_Init 0 */ - - /* USER CODE BEGIN FDCAN1_Init 1 */ - - /* USER CODE END FDCAN1_Init 1 */ - hfdcan1.Instance = FDCAN1; - hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1; - hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS; - hfdcan1.Init.Mode = FDCAN_MODE_NORMAL; - hfdcan1.Init.AutoRetransmission = ENABLE; - hfdcan1.Init.TransmitPause = ENABLE; - hfdcan1.Init.ProtocolException = DISABLE; - hfdcan1.Init.NominalPrescaler = 32; - hfdcan1.Init.NominalSyncJumpWidth = 16; - hfdcan1.Init.NominalTimeSeg1 = 2; - hfdcan1.Init.NominalTimeSeg2 = 2; - hfdcan1.Init.DataPrescaler = 4; - hfdcan1.Init.DataSyncJumpWidth = 5; - hfdcan1.Init.DataTimeSeg1 = 5; - hfdcan1.Init.DataTimeSeg2 = 2; - hfdcan1.Init.StdFiltersNbr = 1; - hfdcan1.Init.ExtFiltersNbr = 1; - hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN FDCAN1_Init 2 */ - - /* USER CODE END FDCAN1_Init 2 */ - -} - -/** - * @brief USART1 Initialization Function - * @param None - * @retval None - */ -static void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - huart1.Instance = USART1; - huart1.Init.BaudRate = 115200; - huart1.Init.WordLength = UART_WORDLENGTH_8B; - huart1.Init.StopBits = UART_STOPBITS_1; - huart1.Init.Parity = UART_PARITY_NONE; - huart1.Init.Mode = UART_MODE_TX_RX; - huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart1.Init.OverSampling = UART_OVERSAMPLING_16; - huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; - huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart1) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } - if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ - -} - -/** - * @brief USART2 Initialization Function - * @param None - * @retval None - */ -void MX_USART2_UART_Init(void) -{ - - /* USER CODE BEGIN USART2_Init 0 */ - - /* USER CODE END USART2_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART2_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART2 GPIO Configuration - PB3 ------> USART2_TX - PB4 ------> USART2_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USART2 interrupt Init */ - NVIC_SetPriority(USART2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0)); - NVIC_EnableIRQ(USART2_IRQn); - - /* USER CODE BEGIN USART2_Init 1 */ - - /* USER CODE END USART2_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_EVEN; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART2, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART2, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART2, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART2); - LL_USART_ConfigAsyncMode(USART2); - - /* USER CODE BEGIN WKUPType USART2 */ - - /* USER CODE END WKUPType USART2 */ - - LL_USART_Enable(USART2); - - /* Polling USART2 initialisation */ - while((!(LL_USART_IsActiveFlag_TEACK(USART2))) || (!(LL_USART_IsActiveFlag_REACK(USART2)))) - { - } - /* USER CODE BEGIN USART2_Init 2 */ - - /* USER CODE END USART2_Init 2 */ - -} - -/** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ -void MX_GPIO_Init(void) -{ - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; -/* USER CODE BEGIN MX_GPIO_Init_1 */ -/* USER CODE END MX_GPIO_Init_1 */ - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - - /**/ - LL_GPIO_ResetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin); - - /**/ - GPIO_InitStruct.Pin = LED_RUN_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_RUN_GPIO_Port, &GPIO_InitStruct); - -/* USER CODE BEGIN MX_GPIO_Init_2 */ -/* USER CODE END MX_GPIO_Init_2 */ -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - __disable_irq(); - while (1) { - } - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, - line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_hal_msp.c b/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index ff809a06..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,223 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - /* PendSV_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/** -* @brief FDCAN MSP Initialization -* This function configures the hardware resources used in this example -* @param hfdcan: FDCAN handle pointer -* @retval None -*/ -void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* hfdcan) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hfdcan->Instance==FDCAN1) - { - /* USER CODE BEGIN FDCAN1_MspInit 0 */ - - /* USER CODE END FDCAN1_MspInit 0 */ - LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - __HAL_RCC_FDCAN_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**FDCAN1 GPIO Configuration - PA11 ------> FDCAN1_RX - PA12 ------> FDCAN1_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* FDCAN1 interrupt Init */ - HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn); - /* USER CODE BEGIN FDCAN1_MspInit 1 */ - - /* USER CODE END FDCAN1_MspInit 1 */ - } - -} - -/** -* @brief FDCAN MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hfdcan: FDCAN handle pointer -* @retval None -*/ -void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* hfdcan) -{ - if(hfdcan->Instance==FDCAN1) - { - /* USER CODE BEGIN FDCAN1_MspDeInit 0 */ - - /* USER CODE END FDCAN1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_FDCAN_CLK_DISABLE(); - - /**FDCAN1 GPIO Configuration - PA11 ------> FDCAN1_RX - PA12 ------> FDCAN1_TX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); - - /* FDCAN1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(FDCAN1_IT0_IRQn); - /* USER CODE BEGIN FDCAN1_MspDeInit 1 */ - - /* USER CODE END FDCAN1_MspDeInit 1 */ - } - -} - -/** -* @brief UART MSP Initialization -* This function configures the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(huart->Instance==USART1) - { - /* USER CODE BEGIN USART1_MspInit 0 */ - - /* USER CODE END USART1_MspInit 0 */ - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - __HAL_RCC_USART1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART1 GPIO Configuration - PA9 ------> USART1_TX - PA10 ------> USART1_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF7_USART1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_MspInit 1 */ - - /* USER CODE END USART1_MspInit 1 */ - } - -} - -/** -* @brief UART MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) -{ - if(huart->Instance==USART1) - { - /* USER CODE BEGIN USART1_MspDeInit 0 */ - - /* USER CODE END USART1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART1_CLK_DISABLE(); - - /**USART1 GPIO Configuration - PA9 ------> USART1_TX - PA10 ------> USART1_RX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); - - /* USER CODE BEGIN USART1_MspDeInit 1 */ - - /* USER CODE END USART1_MspDeInit 1 */ - } - -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_it.c b/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_it.c deleted file mode 100644 index 3d7158af..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,229 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32g4xx_it.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -extern FDCAN_HandleTypeDef hfdcan1; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ - -/** - * @brief This function handles FDCAN1 interrupt 0. - */ -void FDCAN1_IT0_IRQHandler(void) -{ - /* USER CODE BEGIN FDCAN1_IT0_IRQn 0 */ - - /* USER CODE END FDCAN1_IT0_IRQn 0 */ - HAL_FDCAN_IRQHandler(&hfdcan1); - /* USER CODE BEGIN FDCAN1_IT0_IRQn 1 */ - - /* USER CODE END FDCAN1_IT0_IRQn 1 */ -} - -/** - * @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26. - */ -void USART2_IRQHandler(void) -{ - /* USER CODE BEGIN USART2_IRQn 0 */ - - /* USER CODE END USART2_IRQn 0 */ - /* USER CODE BEGIN USART2_IRQn 1 */ - - /* USER CODE END USART2_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/hw/bsp/atom_bl/drivers/hal/Core/Src/system_stm32g4xx.c b/hw/bsp/atom_bl/drivers/hal/Core/Src/system_stm32g4xx.c deleted file mode 100644 index bd75bcb6..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Core/Src/system_stm32g4xx.c +++ /dev/null @@ -1,285 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32g4xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32g4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to - * configure the system clock before to branch to main program. - * - * This file configures the system clock as follows: - *============================================================================= - *----------------------------------------------------------------------------- - * System Clock source | HSI - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 1 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 1 - *----------------------------------------------------------------------------- - * PLL_M | 1 - *----------------------------------------------------------------------------- - * PLL_N | 16 - *----------------------------------------------------------------------------- - * PLL_P | 7 - *----------------------------------------------------------------------------- - * PLL_Q | 2 - *----------------------------------------------------------------------------- - * PLL_R | 2 - *----------------------------------------------------------------------------- - * Require 48MHz for RNG | Disabled - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32g4xx_system - * @{ - */ - -/** @addtogroup STM32G4xx_System_Private_Includes - * @{ - */ - -#include "stm32g4xx.h" - -#if !defined (HSE_VALUE) - #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSI_VALUE) - #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/* Note: Following vector table addresses must be defined in line with linker - configuration. */ -/*!< Uncomment the following line if you need to relocate the vector table - anywhere in Flash or Sram, else the vector table is kept at the automatic - remap of boot address selected */ -/* #define USER_VECT_TAB_ADDRESS */ - -#if defined(USER_VECT_TAB_ADDRESS) -/*!< Uncomment the following line if you need to relocate your vector Table - in Sram else user remap will be done in Flash. */ -/* #define VECT_TAB_SRAM */ -#if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#else -#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00005000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -/******************************************************************************/ -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Variables - * @{ - */ - /* The SystemCoreClock variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = HSI_VALUE; - - const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; - const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ - -void SystemInit(void) -{ - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ - #endif - - /* Configure the Vector Table location add offset address ------------------*/ -#if defined(USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 24 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp, pllvco, pllr, pllsource, pllm; - - /* Get SYSCLK source -------------------------------------------------------*/ - switch (RCC->CFGR & RCC_CFGR_SWS) - { - case 0x04: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - - case 0x08: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case 0x0C: /* PLL used as system clock source */ - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); - pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; - if (pllsource == 0x02UL) /* HSI used as PLL clock source */ - { - pllvco = (HSI_VALUE / pllm); - } - else /* HSE used as PLL clock source */ - { - pllvco = (HSE_VALUE / pllm); - } - pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); - pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; - SystemCoreClock = pllvco/pllr; - break; - - default: - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - diff --git a/hw/bsp/atom_bl/drivers/hal/Makefile b/hw/bsp/atom_bl/drivers/hal/Makefile deleted file mode 100644 index 7e0d939d..00000000 --- a/hw/bsp/atom_bl/drivers/hal/Makefile +++ /dev/null @@ -1,200 +0,0 @@ -########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Sun Nov 05 11:18:56 CST 2023] -########################################################################################################################## - -# ------------------------------------------------ -# Generic Makefile (based on gcc) -# -# ChangeLog : -# 2017-02-10 - Several enhancements + project update mode -# 2015-07-22 - first version -# ------------------------------------------------ - -###################################### -# target -###################################### -TARGET = hal - - -###################################### -# building variables -###################################### -# debug build? -DEBUG = 1 -# optimization -OPT = -Og - - -####################################### -# paths -####################################### -# Build path -BUILD_DIR = build - -###################################### -# source -###################################### -# C sources -C_SOURCES = \ -Core/Src/main.c \ -Core/Src/stm32g4xx_it.c \ -Core/Src/stm32g4xx_hal_msp.c \ -Core/Src/system_stm32g4xx.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_gpio.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_dma.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usart.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_rcc.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c \ -/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c - -# ASM sources -ASM_SOURCES = \ -startup_stm32g431xx.s - - -####################################### -# binaries -####################################### -PREFIX = arm-none-eabi- -# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) -# either it can be added to the PATH environment variable. -ifdef GCC_PATH -CC = $(GCC_PATH)/$(PREFIX)gcc -AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp -CP = $(GCC_PATH)/$(PREFIX)objcopy -SZ = $(GCC_PATH)/$(PREFIX)size -else -CC = $(PREFIX)gcc -AS = $(PREFIX)gcc -x assembler-with-cpp -CP = $(PREFIX)objcopy -SZ = $(PREFIX)size -endif -HEX = $(CP) -O ihex -BIN = $(CP) -O binary -S - -####################################### -# CFLAGS -####################################### -# cpu -CPU = -mcpu=cortex-m4 - -# fpu -FPU = -mfpu=fpv4-sp-d16 - -# float-abi -FLOAT-ABI = -mfloat-abi=hard - -# mcu -MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) - -# macros for gcc -# AS defines -AS_DEFS = - -# C defines -C_DEFS = \ --DUSE_HAL_DRIVER \ --DSTM32G431xx \ --DUSE_FULL_LL_DRIVER - - -# AS includes -AS_INCLUDES = - -# C includes -C_INCLUDES = \ --ICore/Inc \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Device/ST/STM32G4xx/Include \ --I/home/xiao/STM32Cube/Repository/STM32Cube_FW_G4_V1.5.1/Drivers/CMSIS/Include - - -# compile gcc flags -ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -ifeq ($(DEBUG), 1) -CFLAGS += -g -gdwarf-2 -endif - - -# Generate dependency information -CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" - - -####################################### -# LDFLAGS -####################################### -# link script -LDSCRIPT = STM32G431KBUx_FLASH.ld - -# libraries -LIBS = -lc -lm -lnosys -LIBDIR = -LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections - -# default action: build all -all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin - - -####################################### -# build the application -####################################### -# list of objects -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) -vpath %.c $(sort $(dir $(C_SOURCES))) -# list of ASM program objects -OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) -vpath %.s $(sort $(dir $(ASM_SOURCES))) - -$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ - -$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - $(SZ) $@ - -$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(HEX) $< $@ - -$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(BIN) $< $@ - -$(BUILD_DIR): - mkdir $@ - -####################################### -# clean up -####################################### -clean: - -rm -fR $(BUILD_DIR) - -####################################### -# dependencies -####################################### --include $(wildcard $(BUILD_DIR)/*.d) - -# *** EOF *** diff --git a/hw/bsp/atom_bl/drivers/hal/STM32G431KBUx_FLASH.ld b/hw/bsp/atom_bl/drivers/hal/STM32G431KBUx_FLASH.ld deleted file mode 100644 index 8d062d53..00000000 --- a/hw/bsp/atom_bl/drivers/hal/STM32G431KBUx_FLASH.ld +++ /dev/null @@ -1,189 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : STM32CubeMX -** -** Abstract : Linker script for STM32G431KBUx series -** 128Kbytes FLASH and 32Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - diff --git a/hw/bsp/atom_bl/drivers/hal/hal.ioc b/hw/bsp/atom_bl/drivers/hal/hal.ioc deleted file mode 100644 index 6310eb3a..00000000 --- a/hw/bsp/atom_bl/drivers/hal/hal.ioc +++ /dev/null @@ -1,169 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -CAD.formats= -CAD.pinconfig= -CAD.provider= -FDCAN1.AutoRetransmission=ENABLE -FDCAN1.CalculateBaudRateNominal=1000000 -FDCAN1.CalculateTimeBitNominal=1000 -FDCAN1.CalculateTimeQuantumNominal=200.0 -FDCAN1.DataPrescaler=4 -FDCAN1.DataSyncJumpWidth=5 -FDCAN1.DataTimeSeg1=5 -FDCAN1.DataTimeSeg2=2 -FDCAN1.ExtFiltersNbr=1 -FDCAN1.FrameFormat=FDCAN_FRAME_FD_BRS -FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,AutoRetransmission,TransmitPause,NominalSyncJumpWidth,DataPrescaler,DataTimeSeg1,DataTimeSeg2,DataSyncJumpWidth,NominalPrescaler,NominalTimeSeg1,StdFiltersNbr,ExtFiltersNbr -FDCAN1.NominalPrescaler=32 -FDCAN1.NominalSyncJumpWidth=16 -FDCAN1.NominalTimeSeg1=2 -FDCAN1.StdFiltersNbr=1 -FDCAN1.TransmitPause=ENABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -KeepUserPlacement=false -Mcu.CPN=STM32G431KBU6 -Mcu.Family=STM32G4 -Mcu.IP0=FDCAN1 -Mcu.IP1=NVIC -Mcu.IP2=RCC -Mcu.IP3=SYS -Mcu.IP4=USART1 -Mcu.IP5=USART2 -Mcu.IPNb=6 -Mcu.Name=STM32G431K(6-8-B)Ux -Mcu.Package=UFQFPN32 -Mcu.Pin0=PB0 -Mcu.Pin1=PA9 -Mcu.Pin2=PA10 -Mcu.Pin3=PA11 -Mcu.Pin4=PA12 -Mcu.Pin5=PA13 -Mcu.Pin6=PA14 -Mcu.Pin7=PB3 -Mcu.Pin8=PB4 -Mcu.Pin9=VP_SYS_VS_Systick -Mcu.PinsNb=10 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G431KBUx -MxCube.Version=6.9.2 -MxDb.Version=DB.6.0.92 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN1_IT0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PendSV_IRQn=true\:15\:0\:true\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:false -NVIC.USART2_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA10.Mode=Asynchronous -PA10.Signal=USART1_RX -PA11.Mode=FDCAN_Activate -PA11.Signal=FDCAN1_RX -PA12.Mode=FDCAN_Activate -PA12.Signal=FDCAN1_TX -PA13.Mode=Serial_Wire -PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire -PA14.Signal=SYS_JTCK-SWCLK -PA9.Mode=Asynchronous -PA9.Signal=USART1_TX -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=LED_RUN -PB0.Locked=true -PB0.Signal=GPIO_Output -PB3.Locked=true -PB3.Mode=Asynchronous -PB3.Signal=USART2_TX -PB4.Locked=true -PB4.Mode=Asynchronous -PB4.Signal=USART2_RX -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=false -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G431KBUx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.5.1 -ProjectManager.FreePins=false -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=2 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=true -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=hal.ioc -ProjectManager.ProjectName=hal -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-false,3-MX_FDCAN1_Init-FDCAN1-false-HAL-false,4-MX_USART2_UART_Init-USART2-false-LL-false -RCC.ADC12Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HSE_VALUE=8000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLM,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLM=RCC_PLLM_DIV4 -RCC.PLLN=80 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PWRFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=4000000 -RCC.VCOOutputFreq_Value=320000000 -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -USART2.BaudRate=115200 -USART2.IPParameters=VirtualMode-Asynchronous,BaudRate,Parity,WordLength -USART2.Parity=PARITY_EVEN -USART2.VirtualMode-Asynchronous=VM_ASYNC -USART2.WordLength=WORDLENGTH_8B -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -board=custom diff --git a/hw/bsp/atom_bl/drivers/hal/startup_stm32g431xx.s b/hw/bsp/atom_bl/drivers/hal/startup_stm32g431xx.s deleted file mode 100644 index 9ea4773a..00000000 --- a/hw/bsp/atom_bl/drivers/hal/startup_stm32g431xx.s +++ /dev/null @@ -1,497 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32g431xx.s - * @author MCD Application Team - * @brief STM32G431xx devices vector table GCC toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address, - * - Configure the clock system - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M4 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - - .syntax unified - .cpu cortex-m4 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss - -.equ BootRAM, 0xF1E0F85F -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - ldr r0, =_estack - mov sp, r0 /* set stack pointer */ - -/* Copy the data segment initializers from flash to SRAM */ - ldr r0, =_sdata - ldr r1, =_edata - ldr r2, =_sidata - movs r3, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r4, [r2, r3] - str r4, [r0, r3] - adds r3, r3, #4 - -LoopCopyDataInit: - adds r4, r0, r3 - cmp r4, r1 - bcc CopyDataInit - -/* Zero fill the bss segment. */ - ldr r2, =_sbss - ldr r4, =_ebss - movs r3, #0 - b LoopFillZerobss - -FillZerobss: - str r3, [r2] - adds r2, r2, #4 - -LoopFillZerobss: - cmp r2, r4 - bcc FillZerobss - -/* Call the clock system intitialization function.*/ - bl SystemInit -/* Call static constructors */ - bl __libc_init_array -/* Call the application's entry point.*/ - bl main - -LoopForever: - b LoopForever - -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * - * @param None - * @retval : None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex-M4. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - .word WWDG_IRQHandler - .word PVD_PVM_IRQHandler - .word RTC_TAMP_LSECSS_IRQHandler - .word RTC_WKUP_IRQHandler - .word FLASH_IRQHandler - .word RCC_IRQHandler - .word EXTI0_IRQHandler - .word EXTI1_IRQHandler - .word EXTI2_IRQHandler - .word EXTI3_IRQHandler - .word EXTI4_IRQHandler - .word DMA1_Channel1_IRQHandler - .word DMA1_Channel2_IRQHandler - .word DMA1_Channel3_IRQHandler - .word DMA1_Channel4_IRQHandler - .word DMA1_Channel5_IRQHandler - .word DMA1_Channel6_IRQHandler - .word 0 - .word ADC1_2_IRQHandler - .word USB_HP_IRQHandler - .word USB_LP_IRQHandler - .word FDCAN1_IT0_IRQHandler - .word FDCAN1_IT1_IRQHandler - .word EXTI9_5_IRQHandler - .word TIM1_BRK_TIM15_IRQHandler - .word TIM1_UP_TIM16_IRQHandler - .word TIM1_TRG_COM_TIM17_IRQHandler - .word TIM1_CC_IRQHandler - .word TIM2_IRQHandler - .word TIM3_IRQHandler - .word TIM4_IRQHandler - .word I2C1_EV_IRQHandler - .word I2C1_ER_IRQHandler - .word I2C2_EV_IRQHandler - .word I2C2_ER_IRQHandler - .word SPI1_IRQHandler - .word SPI2_IRQHandler - .word USART1_IRQHandler - .word USART2_IRQHandler - .word USART3_IRQHandler - .word EXTI15_10_IRQHandler - .word RTC_Alarm_IRQHandler - .word USBWakeUp_IRQHandler - .word TIM8_BRK_IRQHandler - .word TIM8_UP_IRQHandler - .word TIM8_TRG_COM_IRQHandler - .word TIM8_CC_IRQHandler - .word 0 - .word 0 - .word LPTIM1_IRQHandler - .word 0 - .word SPI3_IRQHandler - .word UART4_IRQHandler - .word 0 - .word TIM6_DAC_IRQHandler - .word TIM7_IRQHandler - .word DMA2_Channel1_IRQHandler - .word DMA2_Channel2_IRQHandler - .word DMA2_Channel3_IRQHandler - .word DMA2_Channel4_IRQHandler - .word DMA2_Channel5_IRQHandler - .word 0 - .word 0 - .word UCPD1_IRQHandler - .word COMP1_2_3_IRQHandler - .word COMP4_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word CRS_IRQHandler - .word SAI1_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word FPU_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word RNG_IRQHandler - .word LPUART1_IRQHandler - .word I2C3_EV_IRQHandler - .word I2C3_ER_IRQHandler - .word DMAMUX_OVR_IRQHandler - .word 0 - .word 0 - .word DMA2_Channel6_IRQHandler - .word 0 - .word 0 - .word CORDIC_IRQHandler - .word FMAC_IRQHandler - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_PVM_IRQHandler - .thumb_set PVD_PVM_IRQHandler,Default_Handler - - .weak RTC_TAMP_LSECSS_IRQHandler - .thumb_set RTC_TAMP_LSECSS_IRQHandler,Default_Handler - - .weak RTC_WKUP_IRQHandler - .thumb_set RTC_WKUP_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Channel1_IRQHandler - .thumb_set DMA1_Channel1_IRQHandler,Default_Handler - - .weak DMA1_Channel2_IRQHandler - .thumb_set DMA1_Channel2_IRQHandler,Default_Handler - - .weak DMA1_Channel3_IRQHandler - .thumb_set DMA1_Channel3_IRQHandler,Default_Handler - - .weak DMA1_Channel4_IRQHandler - .thumb_set DMA1_Channel4_IRQHandler,Default_Handler - - .weak DMA1_Channel5_IRQHandler - .thumb_set DMA1_Channel5_IRQHandler,Default_Handler - - .weak DMA1_Channel6_IRQHandler - .thumb_set DMA1_Channel6_IRQHandler,Default_Handler - - .weak ADC1_2_IRQHandler - .thumb_set ADC1_2_IRQHandler,Default_Handler - - .weak USB_HP_IRQHandler - .thumb_set USB_HP_IRQHandler,Default_Handler - - .weak USB_LP_IRQHandler - .thumb_set USB_LP_IRQHandler,Default_Handler - - .weak FDCAN1_IT0_IRQHandler - .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler - - .weak FDCAN1_IT1_IRQHandler - .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_TIM15_IRQHandler - .thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler - - .weak TIM1_UP_TIM16_IRQHandler - .thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_TIM17_IRQHandler - .thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTC_Alarm_IRQHandler - .thumb_set RTC_Alarm_IRQHandler,Default_Handler - - .weak USBWakeUp_IRQHandler - .thumb_set USBWakeUp_IRQHandler,Default_Handler - - .weak TIM8_BRK_IRQHandler - .thumb_set TIM8_BRK_IRQHandler,Default_Handler - - .weak TIM8_UP_IRQHandler - .thumb_set TIM8_UP_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_IRQHandler - .thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak LPTIM1_IRQHandler - .thumb_set LPTIM1_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak TIM6_DAC_IRQHandler - .thumb_set TIM6_DAC_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Channel1_IRQHandler - .thumb_set DMA2_Channel1_IRQHandler,Default_Handler - - .weak DMA2_Channel2_IRQHandler - .thumb_set DMA2_Channel2_IRQHandler,Default_Handler - - .weak DMA2_Channel3_IRQHandler - .thumb_set DMA2_Channel3_IRQHandler,Default_Handler - - .weak DMA2_Channel4_IRQHandler - .thumb_set DMA2_Channel4_IRQHandler,Default_Handler - - .weak DMA2_Channel5_IRQHandler - .thumb_set DMA2_Channel5_IRQHandler,Default_Handler - - .weak UCPD1_IRQHandler - .thumb_set UCPD1_IRQHandler,Default_Handler - - .weak COMP1_2_3_IRQHandler - .thumb_set COMP1_2_3_IRQHandler,Default_Handler - - .weak COMP4_IRQHandler - .thumb_set COMP4_IRQHandler,Default_Handler - - .weak CRS_IRQHandler - .thumb_set CRS_IRQHandler,Default_Handler - - .weak SAI1_IRQHandler - .thumb_set SAI1_IRQHandler,Default_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Default_Handler - - .weak RNG_IRQHandler - .thumb_set RNG_IRQHandler,Default_Handler - - .weak LPUART1_IRQHandler - .thumb_set LPUART1_IRQHandler,Default_Handler - - .weak I2C3_EV_IRQHandler - .thumb_set I2C3_EV_IRQHandler,Default_Handler - - .weak I2C3_ER_IRQHandler - .thumb_set I2C3_ER_IRQHandler,Default_Handler - - .weak DMAMUX_OVR_IRQHandler - .thumb_set DMAMUX_OVR_IRQHandler,Default_Handler - - .weak DMA2_Channel6_IRQHandler - .thumb_set DMA2_Channel6_IRQHandler,Default_Handler - - .weak CORDIC_IRQHandler - .thumb_set CORDIC_IRQHandler,Default_Handler - - .weak FMAC_IRQHandler - .thumb_set FMAC_IRQHandler,Default_Handler - diff --git a/hw/bsp/atom_bl/ld/LinkerScripts.ld b/hw/bsp/atom_bl/ld/LinkerScripts.ld deleted file mode 100644 index 39b15a67..00000000 --- a/hw/bsp/atom_bl/ld/LinkerScripts.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : STM32CubeMX -** -** Abstract : Linker script for STM32G431KBUx series -** 128Kbytes FLASH and 32Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 20K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/hw/bsp/atom_bl/main.cpp b/hw/bsp/atom_bl/main.cpp deleted file mode 100644 index f0d291ff..00000000 --- a/hw/bsp/atom_bl/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "bsp.h" -#include "robot.hpp" - -int main() { - bsp_init(); - robot_init(); -} diff --git a/hw/bsp/atom_bl/toolchain.cmake b/hw/bsp/atom_bl/toolchain.cmake deleted file mode 100644 index f63e007e..00000000 --- a/hw/bsp/atom_bl/toolchain.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# Target definition -set(CMAKE_SYSTEM_NAME Generic) -set(CMAKE_SYSTEM_PROCESSOR ARM) - -# Toolchain settings -set(CMAKE_LINKER arm-none-eabi-ld) -set(CMAKE_AR arm-none-eabi-ar) -set(CMAKE_SIZE arm-none-eabi-size) -set(CMAKE_OBJCOPY arm-none-eabi-objcopy) -set(CMAKE_OBJDUMP arm-none-eabi-objdump) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -# this makes the test compiles use static library option so that we don't need -# to pre-set linker flags and scripts -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -set(CLANG_TARGET arm-none-eabi) -set(GNU_COMPILER arm-none-eabi) - -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_ASM_COMPILER clang) - -execute_process( - COMMAND arm-none-eabi-gcc -print-sysroot - OUTPUT_VARIABLE GCC_ARM_NONE_EABI_ROOT - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -if(NOT EXISTS ${GCC_ARM_NONE_EABI_ROOT}) - if(NOT EXISTS /usr/lib/arm-none-eabi OR NOT EXISTS /usr/include/newlib) - message(FATAL_ERROR "Could not find arm-none-eabi toolchain.") - endif() - file(GLOB GCC_ARM_NONE_EABI_INCLUDE - "/usr/include/newlib/c++/*/cstddef") - - get_filename_component(GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_INCLUDE}" DIRECTORY) - add_compile_options( - --sysroot=/usr/lib/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE} - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/../../ - ) -else() - -file(GLOB_RECURSE GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_ROOT}/include/c++/*/cstddef") - -get_filename_component(GCC_ARM_NONE_EABI_INCLUDE - "${GCC_ARM_NONE_EABI_INCLUDE}" DIRECTORY) - -add_compile_options( - -isystem${GCC_ARM_NONE_EABI_INCLUDE} - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi - -isystem${GCC_ARM_NONE_EABI_INCLUDE}/arm-none-eabi/include - -isystem${GCC_ARM_NONE_EABI_ROOT}/include -) -endif() - -add_compile_options( - --target=${CLANG_TARGET} -) - -# Use GUN linker. Because this project use nano and nosys lib, but lld.ld do not -# support specs files. -set(CMAKE_C_LINK_EXECUTABLE - "${GNU_COMPILER}-gcc -o -lc" -) -set(CMAKE_CXX_LINK_EXECUTABLE - "${GNU_COMPILER}-g++ -o -lc" -) diff --git a/hw/bsp/mangopi_r818/config/udp_to_uart_client.config b/hw/bsp/mangopi_r818/config/udp_to_uart_client.config deleted file mode 100644 index 83a7055d..00000000 --- a/hw/bsp/mangopi_r818/config/udp_to_uart_client.config +++ /dev/null @@ -1,112 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-node_imu is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_board-atom_bl is not set -# CONFIG_auto_generated_config_prefix_board-atom is not set -# CONFIG_auto_generated_config_prefix_board-dual_canfd is not set -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -CONFIG_auto_generated_config_prefix_board-mangopi_r818=y -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -# CONFIG_auto_generated_config_prefix_board-ble_imu is not set -# CONFIG_auto_generated_config_prefix_board-ems is not set -# CONFIG_auto_generated_config_prefix_system-None is not set -# CONFIG_auto_generated_config_prefix_system-FreeRTOS is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -CONFIG_auto_generated_config_prefix_system-Linux=y -# CONFIG_auto_generated_config_prefix_system-Bootloader is not set -CONFIG_INIT_TASK_STACK_DEPTH=0 - -# -# Linux -# -CONFIG_TERM_LOG_UDP_SERVER=y -CONFIG_TERM_LOG_UDP_SERVER_PORT=1230 -# end of Linux - -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -# CONFIG_auto_generated_config_prefix_robot-bootloader is not set -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-wearlab_imu is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-canfd_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-canfd_imu is not set -CONFIG_auto_generated_config_prefix_robot-udp_to_uart=y -# CONFIG_auto_generated_config_prefix_robot-ems is not set - -# -# 组件 -# - -# -# 设备 -# -CONFIG_auto_generated_config_prefix_device-wearlab=y -# CONFIG_auto_generated_config_prefix_device-icm42688 is not set -# CONFIG_auto_generated_config_prefix_device-ahrs-9 is not set -# CONFIG_auto_generated_config_prefix_device-imu is not set -# CONFIG_auto_generated_config_prefix_device-ahrs is not set -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -CONFIG_auto_generated_config_prefix_device-net_config=y -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-ina226 is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -CONFIG_auto_generated_config_prefix_device-canfd=y -# CONFIG_auto_generated_config_prefix_device-motor is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-can is not set -# CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-bmi088 is not set -# CONFIG_auto_generated_config_prefix_device-mmc5603 is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-uart_update is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -CONFIG_auto_generated_config_prefix_module-uart_udp_client=y -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-performance is not set -# CONFIG_auto_generated_config_prefix_module-canfd_to_uart is not set -CONFIG_auto_generated_config_prefix_module-topic_share_uart=y -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-can_imu_wearlab is not set -# CONFIG_auto_generated_config_prefix_module-canfd_imu is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-ems_ctrl is not set -# end of 模块 diff --git a/hw/bsp/node_imu/config/can_imu_wearlab.config b/hw/bsp/node_imu/config/can_imu_wearlab.config deleted file mode 100644 index f44d4630..00000000 --- a/hw/bsp/node_imu/config/can_imu_wearlab.config +++ /dev/null @@ -1,98 +0,0 @@ -# CONFIG_auto_generated_config_prefix_board-esp32-c3-idf is not set -# CONFIG_auto_generated_config_prefix_board-mangopi_r818 is not set -# CONFIG_auto_generated_config_prefix_board-c-mini is not set -CONFIG_auto_generated_config_prefix_board-node_imu=y -# CONFIG_auto_generated_config_prefix_board-esp32-c3-arduino is not set -# CONFIG_auto_generated_config_prefix_board-f103_can is not set -# CONFIG_auto_generated_config_prefix_board-MiniPC is not set -# CONFIG_auto_generated_config_prefix_board-rm-c is not set -# CONFIG_auto_generated_config_prefix_board-microswitch is not set -# CONFIG_auto_generated_config_prefix_board-Webots is not set -# CONFIG_auto_generated_config_prefix_system-Linux_Webots is not set -CONFIG_auto_generated_config_prefix_system-FreeRTOS=y -# CONFIG_auto_generated_config_prefix_system-None is not set -# CONFIG_auto_generated_config_prefix_system-Linux is not set -CONFIG_INIT_TASK_STACK_DEPTH=1024 - -# -# FreeRTOS -# -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_USB_TASK_STACK_DEPTH=256 -CONFIG_FREERTOS_TERM_TASK_STACK_DEPTH=512 -# end of FreeRTOS - -# CONFIG_auto_generated_config_prefix_robot-udp_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-hero is not set -# CONFIG_auto_generated_config_prefix_robot-balance_infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sentry is not set -# CONFIG_auto_generated_config_prefix_robot-uart_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-dart is not set -# CONFIG_auto_generated_config_prefix_robot-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_robot-can_to_uart is not set -# CONFIG_auto_generated_config_prefix_robot-custom_controller is not set -# CONFIG_auto_generated_config_prefix_robot-infantry is not set -# CONFIG_auto_generated_config_prefix_robot-sim_mecanum is not set -# CONFIG_auto_generated_config_prefix_robot-blink is not set -# CONFIG_auto_generated_config_prefix_robot-microswitch is not set -# CONFIG_auto_generated_config_prefix_robot-sim_balance is not set -# CONFIG_auto_generated_config_prefix_robot-engineer is not set -CONFIG_auto_generated_config_prefix_robot-wearlab_imu=y - -# -# 组件 -# - -# -# 设备 -# -# CONFIG_auto_generated_config_prefix_device-servo is not set -# CONFIG_auto_generated_config_prefix_device-simulator is not set -# CONFIG_auto_generated_config_prefix_device-cap is not set -# CONFIG_auto_generated_config_prefix_device-led_rgb is not set -# CONFIG_auto_generated_config_prefix_device-referee is not set -# CONFIG_auto_generated_config_prefix_device-laser is not set -# CONFIG_auto_generated_config_prefix_device-custom_controller is not set -CONFIG_auto_generated_config_prefix_device-can=y -# CONFIG_auto_generated_config_prefix_device-motor is not set -CONFIG_auto_generated_config_prefix_device-bmi088=y -CONFIG_DEVICE_BMI088_TASK_STACK_DEPTH=256 -# CONFIG_auto_generated_config_prefix_device-mech is not set -# CONFIG_auto_generated_config_prefix_device-buzzer is not set -# CONFIG_auto_generated_config_prefix_device-tof is not set -CONFIG_auto_generated_config_prefix_device-blink_led=y -# CONFIG_auto_generated_config_prefix_device-dr16 is not set -CONFIG_auto_generated_config_prefix_device-ahrs=y -CONFIG_DEVICE_AHRS_TASK_STACK_DEPTH=256 -# CONFIG_auto_generated_config_prefix_device-ai is not set -# CONFIG_auto_generated_config_prefix_device-net_config is not set -CONFIG_auto_generated_config_prefix_device-wearlab=y -CONFIG_auto_generated_config_prefix_device-imu=y -CONFIG_DEVICE_CAN_IMU_TASK_STACK_DEPTH=256 -# CONFIG_auto_generated_config_prefix_device-microswitch is not set -# end of 设备 - -# -# 模块 -# -# CONFIG_auto_generated_config_prefix_module-gimbal is not set -# CONFIG_auto_generated_config_prefix_module-balance is not set -# CONFIG_auto_generated_config_prefix_module-chassis is not set -# CONFIG_auto_generated_config_prefix_module-dart_launcher is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp_client is not set -# CONFIG_auto_generated_config_prefix_module-ble_net_config is not set -# CONFIG_auto_generated_config_prefix_module-engineer_chassis is not set -# CONFIG_auto_generated_config_prefix_module-launcher is not set -# CONFIG_auto_generated_config_prefix_module-custom_controller is not set -# CONFIG_auto_generated_config_prefix_module-ore_collect is not set -# CONFIG_auto_generated_config_prefix_module-can_usart is not set -# CONFIG_auto_generated_config_prefix_module-free_gimbal is not set -# CONFIG_auto_generated_config_prefix_module-uart_udp is not set -CONFIG_auto_generated_config_prefix_module-can_imu_wearlab=y -CONFIG_MODULE_CAN_IMU_TASK_STACK_DEPTH=256 -# CONFIG_auto_generated_config_prefix_module-topic_share_uart is not set -# CONFIG_auto_generated_config_prefix_module-microswitch is not set -# CONFIG_auto_generated_config_prefix_module-can_imu is not set -# CONFIG_auto_generated_config_prefix_module-wheel_leg is not set -# CONFIG_auto_generated_config_prefix_module-dart_gimbal is not set -# end of 模块 diff --git a/src/device/wearlab/Kconfig b/src/device/wearlab/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/src/device/wearlab/info.cmake b/src/device/wearlab/info.cmake deleted file mode 100644 index 3685d3f5..00000000 --- a/src/device/wearlab/info.cmake +++ /dev/null @@ -1,8 +0,0 @@ -CHECK_SUB_ENABLE(MODULE_ENABLE device) - -if(${MODULE_ENABLE}) - file(GLOB CUR_SOURCES "${SUB_DIR}/*.cpp") - - SUB_ADD_SRC(CUR_SOURCES) - SUB_ADD_INC(SUB_DIR) -endif() diff --git a/src/device/wearlab/wearlab.hpp b/src/device/wearlab/wearlab.hpp deleted file mode 100644 index 7e1153fb..00000000 --- a/src/device/wearlab/wearlab.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -namespace Device { -class WearLab { - public: - typedef struct __attribute__((packed)) { - uint32_t id; - - uint8_t data[8]; - uint8_t end; - } UartData; - - typedef union { - struct __attribute__((packed)) { - uint32_t device_type : 12; - uint32_t data_type : 6; - uint32_t device_id : 6; - uint32_t res : 8; - } data; - - uint32_t raw; - } CanHeader; - - typedef struct __attribute__((packed)) { - uint8_t prefix; - uint32_t time; - uint8_t area_id; //区域ID - - CanHeader can_header; - - uint8_t data_len : 7; - uint8_t fd : 1; - } UdpDataHeader; - - typedef struct __attribute__((packed)) { - double data1; - } CanData1; - - typedef struct __attribute__((packed)) { - float data1; - float data2; - } CanData2; - - typedef struct __attribute__((packed)) { - int32_t data1_symbol : 1; - uint32_t data1 : 20; - int32_t data2_symbol : 1; - uint32_t data2 : 20; - int32_t data3_symbol : 1; - uint32_t data3 : 20; - int32_t res : 1; - } CanData3; - - typedef struct __attribute__((packed)) { - int16_t data[4]; - } CanData4; -}; -} // namespace Device diff --git a/src/module/canfd_imu/Kconfig b/src/module/canfd_imu/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/src/module/canfd_imu/info.cmake b/src/module/canfd_imu/info.cmake deleted file mode 100644 index 35463fe0..00000000 --- a/src/module/canfd_imu/info.cmake +++ /dev/null @@ -1,6 +0,0 @@ -CHECK_SUB_ENABLE(MODULE_ENABLE module) -if(${MODULE_ENABLE}) - file(GLOB CUR_SOURCES "${SUB_DIR}/*.cpp") - SUB_ADD_SRC(CUR_SOURCES) - SUB_ADD_INC(SUB_DIR) -endif() \ No newline at end of file diff --git a/src/module/canfd_imu/mod_canfd_imu.cpp b/src/module/canfd_imu/mod_canfd_imu.cpp deleted file mode 100644 index e844bcfb..00000000 --- a/src/module/canfd_imu/mod_canfd_imu.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "mod_canfd_imu.hpp" - -#include - -#include "bsp_can.h" -#include "bsp_time.h" -#include "bsp_uart.h" -#include "dev_canfd.hpp" - -using namespace Module; - -CanfdImu::CanfdImu() - : data_tp_("canfd_imu"), - uart_output_("imu_uart", true), - canfd_output_("imu_canfd", true), - id_("canfd_imu_id", 0x30), - cycle_("canfd_imu_cycle", 10), - cmd_(this, SetCMD, "set_imu") { - auto cmd_cb = [](Device::Can::FDPack &pack, CanfdImu *imu) { - if (pack.info.size != sizeof(ControlData)) { - return false; - } - - ControlData *data = reinterpret_cast(pack.info.data); - if (data->id != imu->id_) { - imu->id_.Set(data->id); - bsp_sys_reset(); - } - if (data->cycle != imu->cycle_) { - imu->cycle_.Set(data->cycle); - } - if (static_cast(data->uart_output) != imu->uart_output_) { - imu->id_.Set(data->uart_output); - } - if (static_cast(data->canfd_output) != imu->canfd_output_) { - imu->id_.Set(data->canfd_output); - } - return true; - }; - - auto cmd_tp = new Message::Topic("imu_cmd"); - - CanHeader tmp; - tmp.data = {.device_type = IMU_9, .data_type = CONTROL, .device_id = id_}; - - cmd_tp->RegisterCallback(cmd_cb, this); - - Device::Can::SubscribeFD(*cmd_tp, BSP_CAN_1, tmp.raw, 1); - - auto thread_fn = [](CanfdImu *imu) { - auto magn_sub = Message::Subscriber("magn"); - auto quat_sub = - Message::Subscriber("imu_quat"); - auto gyro_sub = Message::Subscriber("imu_gyro"); - auto accl_sub = Message::Subscriber("imu_accl"); - - uint32_t last_wakeup = bsp_time_get_ms(); - - while (true) { - accl_sub.DumpData(imu->data_.raw.accl_); - gyro_sub.DumpData(imu->data_.raw.gyro_); - magn_sub.DumpData(imu->data_.raw.magn_); - quat_sub.DumpData(imu->data_.raw.quat_); - - imu->header_.data = { - .device_type = IMU_9, .data_type = FEEDBACK, .device_id = imu->id_}; - - imu->data_.raw.time = bsp_time_get_ms(); - - if (imu->canfd_output_) { - Device::Can::SendFDExtPack(BSP_CAN_1, imu->header_.raw, - reinterpret_cast(&imu->data_.raw), - sizeof(imu->data_.raw)); - } - - if (imu->uart_output_) { - imu->data_.prefix = 0xa5; - imu->data_.id = imu->id_; - imu->data_.crc8 = Component::CRC8::Calculate( - reinterpret_cast(&imu->data_), - sizeof(imu->data_) - sizeof(uint8_t), CRC8_INIT); - bsp_uart_transmit(BSP_UART_MCU, - reinterpret_cast(&imu->data_), - sizeof(Data), false); - } - imu->thread_.SleepUntil(imu->cycle_, last_wakeup); - } - }; - - this->thread_.Create(thread_fn, this, "canfd_imu", 384, - System::Thread::REALTIME); -} - -int CanfdImu::SetCMD(CanfdImu *imu, int argc, char **argv) { - imu->uart_output_.data_ = false; - printf("\n"); - if (argc == 1) { - printf("set_delay [time] 设置发送延时ms\r\n"); - printf("set_can_id [id] 设置can id\r\n"); - printf("enable [uart/canfd] 开启输出\r\n"); - printf("disable [uart/canfd] 关闭输出\r\n"); - } else if (argc == 3 && strcmp(argv[1], "set_delay") == 0) { - int delay = std::stoi(argv[2]); - - if (delay > 1000) { - delay = 1000; - } - - if (delay < 1) { - delay = 1; - } - - imu->cycle_.Set(delay); - - printf("delay:%d\r\n", delay); - } else if (argc == 3 && strcmp(argv[1], "enable") == 0) { - if (strcmp(argv[2], "uart") == 0) { - imu->uart_output_.Set(true); - } else if (strcmp(argv[2], "canfd") == 0) { - imu->canfd_output_.Set(true); - } - } else if (argc == 3 && strcmp(argv[1], "disable") == 0) { - if (strcmp(argv[2], "uart") == 0) { - imu->uart_output_.Set(false); - } else if (strcmp(argv[2], "canfd") == 0) { - imu->canfd_output_.Set(false); - } - } else if (argc == 3 && strcmp(argv[1], "set_can_id") == 0) { - int id = std::stoi(argv[2]); - - imu->id_.Set(id); - - printf("can_id:%d\r\n", id); - } else { - printf("命令错误\r\n"); - } - - return 0; -} diff --git a/src/module/canfd_imu/mod_canfd_imu.hpp b/src/module/canfd_imu/mod_canfd_imu.hpp deleted file mode 100644 index b4256537..00000000 --- a/src/module/canfd_imu/mod_canfd_imu.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#include - -#include "module.hpp" - -namespace Module { -class CanfdImu { - public: - typedef enum { IMU_9 = 2 } DeviceType; - - typedef enum { FEEDBACK = 1, CONTROL } DataType; - - typedef union { - struct __attribute__((packed)) { - uint32_t device_type : 12; - uint32_t data_type : 6; - uint32_t device_id : 6; - uint32_t res : 8; - } data; - - uint32_t raw; - } CanHeader; - - typedef struct __attribute__((packed)) { - uint8_t prefix; - uint8_t id; - struct __attribute__((packed)) { - uint32_t time; - Component::Type::Quaternion quat_; - Component::Type::Vector3 gyro_; - Component::Type::Vector3 accl_; - Component::Type::Vector3 magn_; - } raw; - uint8_t crc8; - } Data; - - typedef struct __attribute__((packed)) { - uint16_t id; - uint16_t cycle; - uint8_t uart_output; - uint8_t canfd_output; - uint16_t res; - } ControlData; - - Data data_; - - CanHeader header_; - - Message::Topic data_tp_; - - System::Thread thread_; - - System::Database::Key uart_output_; - - System::Database::Key canfd_output_; - - System::Database::Key id_; - - System::Database::Key cycle_; - - System::Term::Command cmd_; - - CanfdImu(); - - static int SetCMD(CanfdImu* imu, int argc, char** argv); -}; -} // namespace Module diff --git a/src/module/uart_udp_client/Kconfig b/src/module/uart_udp_client/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/src/module/uart_udp_client/info.cmake b/src/module/uart_udp_client/info.cmake deleted file mode 100644 index 35463fe0..00000000 --- a/src/module/uart_udp_client/info.cmake +++ /dev/null @@ -1,6 +0,0 @@ -CHECK_SUB_ENABLE(MODULE_ENABLE module) -if(${MODULE_ENABLE}) - file(GLOB CUR_SOURCES "${SUB_DIR}/*.cpp") - SUB_ADD_SRC(CUR_SOURCES) - SUB_ADD_INC(SUB_DIR) -endif() \ No newline at end of file diff --git a/src/module/uart_udp_client/mod_uart_udp.cpp b/src/module/uart_udp_client/mod_uart_udp.cpp deleted file mode 100644 index 61f6cb10..00000000 --- a/src/module/uart_udp_client/mod_uart_udp.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "mod_uart_udp.hpp" - -using namespace Module; - -UartToUDP* UartToUDP::self_; diff --git a/src/module/uart_udp_client/mod_uart_udp.hpp b/src/module/uart_udp_client/mod_uart_udp.hpp deleted file mode 100644 index 4b9c70d9..00000000 --- a/src/module/uart_udp_client/mod_uart_udp.hpp +++ /dev/null @@ -1,195 +0,0 @@ -#include -#include - -#include "bsp_dns_client.h" -#include "bsp_time.h" -#include "bsp_udp_client.h" -#include "comp_crc8.hpp" -#include "dev_canfd.hpp" -#include "udp_param.h" -#include "wearlab.hpp" - -namespace Module { -class UartToUDP { - public: - UartToUDP() { - self_ = this; - om_fifo_create(&udp_tx_fifo_, new uint8_t[512], 512, sizeof(uint8_t)); - - bsp_dns_addr_t addrs; - while (true) { - auto ans = bsp_dns_prase_domain(UDP_DOMAIN, &addrs); - if (ans != BSP_OK) { - OMLOG_ERROR("Prase domain failed:%s", UDP_DOMAIN); - OMLOG_WARNING("Sleep 5s to wait network ready"); - System::Thread::Sleep(5000); - } else { - OMLOG_PASS("Prase domain done:%s", UDP_DOMAIN); - OMLOG_NOTICE("Server ip:%s", &addrs); - break; - } - } - - bsp_udp_client_init(&udp_client_, UDP_PORT, - reinterpret_cast(&addrs)); - - auto udp_rx_cb = [](void* arg, void* buff, uint32_t size) { - XB_UNUSED(arg); - - if (*reinterpret_cast(buff) != 0xa5) { - return; - } - - if (!Component::CRC8::Verify(static_cast(buff), size)) { - return; - } - - auto header = static_cast(buff); - - if (header->fd) { - Device::Can::SendFDExtPack(static_cast(header->area_id), - header->can_header.raw, - reinterpret_cast(header) + - sizeof(Device::WearLab::UdpDataHeader), - size); - } else { - Device::Can::Pack pack = {.index = header->can_header.raw}; - memcpy(pack.data, - reinterpret_cast(header) + - sizeof(Device::WearLab::UdpDataHeader), - 8); - Device::Can::SendExtPack(static_cast(header->area_id), pack); - } - }; - - bsp_udp_client_register_callback(&udp_client_, BSP_UDP_RX_CPLT_CB, - udp_rx_cb, this); - - auto udp_rx_thread_fn = [](UartToUDP* uart_udp) { - bsp_udp_client_start(&uart_udp->udp_client_); - while (true) { - System::Thread::Sleep(UINT32_MAX); - } - }; - - auto udp_tx_thread_fn = [](UartToUDP* uart_udp) { - uint8_t tx_buff[512]; - - while (true) { - uart_udp->udp_tx_sem_.Lock(); - - uart_udp->udp_tx_mutex_.Lock(); - - auto size = om_fifo_readable_item_count(&uart_udp->udp_tx_fifo_); - om_fifo_reads(&uart_udp->udp_tx_fifo_, tx_buff, size); - - uart_udp->udp_tx_mutex_.Unlock(); - - bsp_udp_client_transmit(&uart_udp->udp_client_, tx_buff, size); - } - }; - - Message::Topic* fd_tp[BSP_CAN_NUM]; - Message::Topic* tp[BSP_CAN_NUM]; - - auto canfd_rx_fun = [](Device::Can::FDPack& pack, uint8_t* can) { - if (*can >= 0) { - return false; - } - - static uint8_t udp_tx_buff[BSP_CAN_NUM][256] = {}; - - auto header = - reinterpret_cast(udp_tx_buff[*can]); - - header->time = bsp_time_get(); - header->prefix = 0xa5; - header->can_header.raw = pack.index; - header->area_id = *can; - header->data_len = pack.info.size; - header->fd = true; - - memcpy(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader), - pack.info.data, pack.info.size); - *(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader) + - pack.info.size) = - Component::CRC8::Calculate( - udp_tx_buff[*can], sizeof(*header) + pack.info.size, CRC8_INIT); - self_->udp_tx_mutex_.Lock(); - om_fifo_writes( - &self_->udp_tx_fifo_, header, - sizeof(Device::WearLab::UdpDataHeader) + pack.info.size + 1); - self_->udp_tx_mutex_.Unlock(); - self_->udp_tx_sem_.Unlock(); - return true; - }; - - auto can_rx_fun = [](Device::Can::Pack& pack, uint8_t* can) { - if (*can >= 0) { - return false; - } - - static uint8_t udp_tx_buff[BSP_CAN_NUM][256] = {}; - - auto header = - reinterpret_cast(udp_tx_buff[*can]); - - header->time = bsp_time_get(); - header->prefix = 0xa5; - header->can_header.raw = pack.index; - header->area_id = *can; - header->data_len = 8; - header->fd = false; - - memcpy(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader), - pack.data, 8); - *(udp_tx_buff[*can] + sizeof(Device::WearLab::UdpDataHeader) + 8) = - Component::CRC8::Calculate(udp_tx_buff[*can], sizeof(*header) + 8, - CRC8_INIT); - self_->udp_tx_mutex_.Lock(); - om_fifo_writes(&self_->udp_tx_fifo_, header, - sizeof(Device::WearLab::UdpDataHeader) + 9); - self_->udp_tx_mutex_.Unlock(); - self_->udp_tx_sem_.Unlock(); - return true; - }; - - for (int i = 0; i < BSP_CAN_NUM; i++) { - can_id_[i] = i; - - fd_tp[i] = new Message::Topic( - (std::string("trans_canfd") + std::to_string(i)).c_str()); - tp[i] = new Message::Topic( - (std::string("trans_can") + std::to_string(i)).c_str()); - - Device::Can::SubscribeFD(*fd_tp[i], static_cast(i), 0, - UINT32_MAX); - - Device::Can::Subscribe(*tp[i], static_cast(i), 0, UINT32_MAX); - - fd_tp[i]->RegisterCallback(canfd_rx_fun, &can_id_[i]); - tp[i]->RegisterCallback(can_rx_fun, &can_id_[i]); - } - - udp_rx_thread_.Create(udp_rx_thread_fn, this, "udp_rx_thread", 512, - System::Thread::HIGH); - - udp_tx_thread_.Create(udp_tx_thread_fn, this, "udp_tx_thread", 512, - System::Thread::HIGH); - } - - static UartToUDP* self_; - - om_fifo_t udp_tx_fifo_; - - uint8_t can_id_[BSP_CAN_NUM]; - - System::Mutex udp_tx_mutex_, udp_tx_sem_; - - System::Thread udp_rx_thread_; - - System::Thread udp_tx_thread_; - - bsp_udp_client_t udp_client_{}; -}; -} // namespace Module diff --git a/src/module/uart_udp_client/udp_param.h b/src/module/uart_udp_client/udp_param.h deleted file mode 100644 index 57043cbc..00000000 --- a/src/module/uart_udp_client/udp_param.h +++ /dev/null @@ -1,2 +0,0 @@ -#define UDP_PORT (4321) -#define UDP_DOMAIN ("127.0.0.1") diff --git a/src/robot/canfd_imu/Kconfig b/src/robot/canfd_imu/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/src/robot/canfd_imu/robot.cpp b/src/robot/canfd_imu/robot.cpp deleted file mode 100644 index ce200f31..00000000 --- a/src/robot/canfd_imu/robot.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "robot.hpp" - -#include "system.hpp" - -/* clang-format off */ -Robot::WearLabIMU::Param param = { - .imu_rot = - { - .rot_mat = - { - {+1, +0, +0}, - {+0, +1, +0}, - {+0, +0, +1}, - }, - }, - - .magn_rot = { - .rot_mat = - { - {+0, +1, +0}, - {-1, +0, +0}, - {+0, +0, +1}, - }, - }, - - .led = { - .gpio = BSP_GPIO_LED, - .timeout = 200, - } -}; -/* clang-format on */ - -void robot_init() { - System::Start(param); -} diff --git a/src/robot/canfd_imu/robot.hpp b/src/robot/canfd_imu/robot.hpp deleted file mode 100644 index 3a3662ce..00000000 --- a/src/robot/canfd_imu/robot.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "dev_ahrs.hpp" -#include "dev_blink_led.hpp" -#include "dev_canfd.hpp" -#include "dev_icm42688.hpp" -#include "dev_mmc5603.hpp" -#include "mod_canfd_imu.hpp" - -void robot_init(); -namespace Robot { -class WearLabIMU { - public: - typedef struct Param { - Device::ICM42688::Rotation imu_rot{}; - Device::MMC5603::Rotation magn_rot{}; - Device::BlinkLED::Param led{}; - } Param; - - Device::AHRS ahrs_; - Device::ICM42688 icm42688_; - Device::BlinkLED led_; - Device::Can can_; - Device::MMC5603 mmc5603_; - - Module::CanfdImu canfd_imu_; - - WearLabIMU(Param& param) - : icm42688_(param.imu_rot), led_(param.led), mmc5603_(param.magn_rot) {} -}; -} // namespace Robot