diff --git a/.gitignore b/.gitignore index c35f466..dc25f22 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,7 @@ ncscope.* tags .idea -.vscode + .history CMakeLists.txt cmake-build-debug diff --git a/.vscode/.cortex-debug.registers.state.json b/.vscode/.cortex-debug.registers.state.json new file mode 100644 index 0000000..9189a15 --- /dev/null +++ b/.vscode/.cortex-debug.registers.state.json @@ -0,0 +1 @@ +[{"node":"xpsr","expanded":true},{"node":"control","expanded":true}] \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..9cd7830 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,36 @@ +{ + "configurations": [ + { + "name": "Win32", + "defines": [ + "HAVE_CCONFIG_H", + "HC32L073", + "RT_USING_NEWLIB", + "USE_DDL_DRIVER", + "__DEBUG", + "__RTTHREAD__" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "/usr/bin/arm-none-eabi-gcc", + "cStandard": "c99", + "cppStandard": "c++11", + "includePath": [ + "/home/bookshiyi/repos/motion_ec", + "/home/bookshiyi/repos/motion_ec/Libraries/CMSIS/Device/HDSC/HC32L073/Include", + "/home/bookshiyi/repos/motion_ec/Libraries/CMSIS/Include", + "/home/bookshiyi/repos/motion_ec/Libraries/HC32L073_StdPeriph_Driver/inc", + "/home/bookshiyi/repos/motion_ec/applications", + "/home/bookshiyi/repos/motion_ec/board", + "/home/bookshiyi/repos/motion_ec/drivers", + "/home/bookshiyi/repos/motion_ec/rt-thread/components/drivers/include", + "/home/bookshiyi/repos/motion_ec/rt-thread/components/finsh", + "/home/bookshiyi/repos/motion_ec/rt-thread/components/libc/compilers/common", + "/home/bookshiyi/repos/motion_ec/rt-thread/components/libc/compilers/gcc/newlib", + "/home/bookshiyi/repos/motion_ec/rt-thread/include", + "/home/bookshiyi/repos/motion_ec/rt-thread/libcpu/arm/common", + "/home/bookshiyi/repos/motion_ec/rt-thread/libcpu/arm/cortex-m0" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1411be9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,54 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + {//Build & Download & Debug + "cwd": "${workspaceRoot}", + "executable": "hc32L073.elf", + "name": "Build & Download & Debug", + "request": "launch", + "type": "cortex-debug", + "showDevDebugOutput": true, + "interface": "swd", + "runToMain": true, + "servertype": "pyocd" , + "targetId": "hc32l072kata", + + // "svdFile": "core/HC32L07X.svd", + "svdFile": "Libraries/HC32L073KATA.svd", + // "cmsisPack": "HDSC.HC32L07X.1.1.0.pack", + + "armToolchainPath": "/usr/bin/", + "preLaunchTask": "Build", + "preLaunchCommands": [ + "load", + ], + "preRestartCommands": [ + "monitor reset" + ] + }, + {//Debug + "cwd": "${workspaceRoot}", + "executable": "hc32L073.elf", + "name": "Debug", + "request": "launch", + "type": "cortex-debug", + "showDevDebugOutput": true, + "interface": "swd", + "runToMain": true, + "servertype": "pyocd" , + "targetId": "hc32l072kata", + "svdFile": "Libraries/HC32L073KATA.svd", + + "armToolchainPath": "/usr/bin/", + "preLaunchCommands": [ + "load", + ], + "preRestartCommands": [ + "monitor reset" + ] + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..911219f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "RTT_Studio.Build.Parallel_Jobs": "8", + "files.associations": { + "*.tpp": "cpp", + "*.cu": "cpp", + "*.tcu": "cpp", + "*.json": "json", + "*.txt": "txt", + "board.h": "c", + "gpio.h": "c", + "drv_gpio.h": "c", + "system_hc32l07x.h": "c", + "hc32l07x.h": "c" + }, + "cortex-debug.variableUseNaturalFormat": false +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..67892b3 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,54 @@ +{ + "version": "2.0.0", + "options": { + + "cwd": "${workspaceFolder}" + }, + "tasks": [ + + { + "label": "Download", + "type": "shell", + "command": "pyocd load -t hc32l072kata rtthread.bin", + "detail":"pyocd load -t hc32l072kata rtthread.bin", + "group": "build" + }, + { + "label": "Build & Download", + "type": "shell", + "command": "scons && pyocd load -t hc32l072kata rtthread.bin", + "detail":"scons && pyocd load -t hc32l072kata rtthread.bin", + "group": "build" + }, + + { + "label": "Probe", + "type": "shell", + "command": "pyocd list -p", + "detail":"pyocd list -p", + "group": "build" + }, + + { + "label": "Build", + "type": "shell", + "command": "scons -j8", + "detail":"scons -j8", + "group": "build" + }, + { + "label": "Rebuild", + "type": "shell", + "command": "scons -c && scons -j8", + "detail":"scons -c && scons -j8", + "group": "build" + }, + { + "label": "Clean", + "type": "shell", + "command": "scons -c", + "detail":"scons -c", + "group": "build" + } + ] +} \ No newline at end of file diff --git a/Libraries/CMSIS/Device/HDSC/HC32L073/Include/board_motion.h b/Libraries/CMSIS/Device/HDSC/HC32L073/Include/board_motion.h index 5513acc..7991ff2 100644 --- a/Libraries/CMSIS/Device/HDSC/HC32L073/Include/board_motion.h +++ b/Libraries/CMSIS/Device/HDSC/HC32L073/Include/board_motion.h @@ -1,3 +1,10 @@ +/* + * @Description: + * @Date: 2022-01-10 17:05:41 + * @LastEditors: CK.Zh + * @LastEditTime: 2022-01-12 14:00:39 + * @FilePath: /motion_ec/Libraries/CMSIS/Device/HDSC/HC32L073/Include/board_motion.h + */ #ifndef __BOARD_CONF_H__ #define __BOARD_CONF_H__ @@ -5,13 +12,13 @@ #include "gpio.h" -//hc32最小系统 -#define RUN_LED_PORT GpioPortC -#define RUN_LED_PIN GpioPin13 +// //hc32最小系统 +// #define RUN_LED_PORT GpioPortC +// #define RUN_LED_PIN GpioPin13 -//motion -#define PWR_LED_PORT GpioPortB -#define PWR_LED_PIN GpioPin10 +// //motion +// #define PWR_LED_PORT GpioPortB +// #define PWR_LED_PIN GpioPin10 //XTH #define SYSTEM_XTH (12*1000*1000u) //12MHZ diff --git a/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c b/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c index 092ef68..83b7566 100644 --- a/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c +++ b/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c @@ -2,8 +2,8 @@ * @Description: * @Date: 2022-01-06 16:18:23 * @LastEditors: CK.Zh - * @LastEditTime: 2022-01-10 12:02:32 - * @FilePath: /rt-thread/bsp/hc32l073/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c + * @LastEditTime: 2022-01-12 17:24:59 + * @FilePath: /motion_ec/Libraries/CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c */ /****************************************************************************** * Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. @@ -178,7 +178,7 @@ void SysTick_Handler(void) void PORTA_IRQHandler(void) { #if (INT_CALLBACK_ON == INT_CALLBACK_PORTA) - PortA_IRQHandler(); + Gpio_IRQHandler(0); #endif } @@ -191,7 +191,7 @@ void PORTA_IRQHandler(void) void PORTB_IRQHandler(void) { #if (INT_CALLBACK_ON == INT_CALLBACK_PORTB) - PortB_IRQHandler(); + Gpio_IRQHandler(1); #endif } @@ -204,11 +204,11 @@ void PORTB_IRQHandler(void) void PORTC_E_IRQHandler(void) { #if (INT_CALLBACK_ON == INT_CALLBACK_PORTC) - PortC_IRQHandler(); + Gpio_IRQHandler(2); #endif #if (INT_CALLBACK_ON == INT_CALLBACK_PORTE) - PortE_IRQHandler(); + Gpio_IRQHandler(3); #endif } @@ -221,11 +221,11 @@ void PORTC_E_IRQHandler(void) void PORTD_F_IRQHandler(void) { #if (INT_CALLBACK_ON == INT_CALLBACK_PORTD) - PortD_IRQHandler(); + Gpio_IRQHandler(4); #endif #if (INT_CALLBACK_ON == INT_CALLBACK_PORTF) - PortF_IRQHandler(); + Gpio_IRQHandler(5); #endif } diff --git a/Libraries/HC32L073_StdPeriph_Driver/inc/gpio.h b/Libraries/HC32L073_StdPeriph_Driver/inc/gpio.h index 7739208..b46c3f1 100755 --- a/Libraries/HC32L073_StdPeriph_Driver/inc/gpio.h +++ b/Libraries/HC32L073_StdPeriph_Driver/inc/gpio.h @@ -1,3 +1,10 @@ +/* + * @Description: + * @Date: 2022-01-10 17:05:41 + * @LastEditors: CK.Zh + * @LastEditTime: 2022-01-12 17:22:57 + * @FilePath: /motion_ec/Libraries/HC32L073_StdPeriph_Driver/inc/gpio.h + */ /******************************************************************************* * Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. * diff --git a/applications/main.c b/applications/main.c index 595c316..d4decca 100644 --- a/applications/main.c +++ b/applications/main.c @@ -2,7 +2,7 @@ * @Description: * @Date: 2022-01-10 17:05:41 * @LastEditors: CK.Zh - * @LastEditTime: 2022-01-11 16:59:05 + * @LastEditTime: 2022-01-13 12:14:46 * @FilePath: /motion_ec/applications/main.c */ /* @@ -25,9 +25,9 @@ #include -#define LOG_TAG "MAIN" -#define LOG_LVL LOG_LVL_DBG -#include +// #define LOG_TAG "MAIN" +// #define LOG_LVL LOG_LVL_DBG +// #include /******************************************************************************* * Local type definitions ('typedef') @@ -58,7 +58,9 @@ ******************************************************************************/ void key_handler(void *param) { - flag = ~flag; + flag = ~flag; + char *a = param;// 获取参数 + rt_kprintf("key down! %s\n",a); } @@ -73,18 +75,21 @@ void key_handler(void *param) ******************************************************************************/ int32_t main(void) { - LOG_I("Go to main function"); - rt_pin_mode(BUZZ_CTL_PIN, PIN_MODE_OUTPUT); - rt_pin_mode(PWR_LED_PIN, PIN_MODE_OUTPUT); - rt_pin_mode(PWR_BTN, PIN_MODE_INPUT); - rt_pin_mode(FUN_BTN, PIN_MODE_INPUT); + //DEBUG + rt_pin_mode(TEST_LED_PIN, PIN_MODE_OUTPUT); + + // LOG_I("Go to main function"); + rt_pin_mode(EC_BUZZ_CTL_PIN, PIN_MODE_OUTPUT); + rt_pin_mode(EC_PWR_LED_PIN, PIN_MODE_OUTPUT); + rt_pin_mode(EC_PWR_BTN, PIN_MODE_INPUT); + rt_pin_attach_irq(EC_PWR_BTN, PIN_IRQ_MODE_FALLING, key_handler, (void*)"callback args"); + rt_pin_irq_enable(EC_PWR_BTN, PIN_IRQ_ENABLE); - rt_pin_attach_irq(PWR_BTN, PIN_IRQ_MODE_FALLING, key_handler, RT_NULL); - rt_pin_irq_enable(PWR_BTN, PIN_IRQ_ENABLE); - rt_pin_attach_irq(FUN_BTN, PIN_IRQ_MODE_FALLING, key_handler, RT_NULL); - rt_pin_irq_enable(FUN_BTN, PIN_IRQ_ENABLE); + rt_pin_mode(EC_FUN_BTN, PIN_MODE_INPUT); + rt_pin_attach_irq(EC_FUN_BTN, PIN_IRQ_MODE_FALLING, key_handler, (void*)"callback args"); + rt_pin_irq_enable(EC_FUN_BTN, PIN_IRQ_ENABLE); @@ -92,17 +97,21 @@ int32_t main(void) { if (flag == 0) { - rt_pin_write(PWR_LED_PIN, PIN_HIGH); + rt_pin_write(EC_PWR_LED_PIN, PIN_HIGH); + rt_pin_write(TEST_LED_PIN, PIN_HIGH); rt_thread_delay(500); - rt_pin_write(PWR_LED_PIN, PIN_LOW); + rt_pin_write(EC_PWR_LED_PIN, PIN_LOW); + rt_pin_write(TEST_LED_PIN, PIN_LOW); rt_thread_delay(500); } else { - rt_pin_write(PWR_LED_PIN, PIN_HIGH); - rt_thread_delay(2000); - rt_pin_write(PWR_LED_PIN, PIN_LOW); - rt_thread_delay(2000); + rt_pin_write(EC_PWR_LED_PIN, PIN_HIGH); + rt_pin_write(TEST_LED_PIN, PIN_HIGH); + rt_thread_delay(100); + rt_pin_write(EC_PWR_LED_PIN, PIN_LOW); + rt_pin_write(TEST_LED_PIN, PIN_LOW); + rt_thread_delay(100); } } } diff --git a/board/board.h b/board/board.h index 3205bef..07e82b4 100644 --- a/board/board.h +++ b/board/board.h @@ -2,7 +2,7 @@ * @Description: * @Date: 2022-01-06 14:31:32 * @LastEditors: CK.Zh - * @LastEditTime: 2022-01-11 18:12:23 + * @LastEditTime: 2022-01-13 12:13:28 * @FilePath: /motion_ec/board/board.h */ /* @@ -46,6 +46,9 @@ extern int __bss_end; #define HEAP_END SRAM_END #endif +// debug +#define TEST_LED_PIN GET_PIN(C, 13) + //MISC #define EC_PWR_BTN GET_PIN(B, 11) #define EC_PWR_LED_PIN GET_PIN(B, 10)