# stm32f030gftl **Repository Path**: QianMenDianZi/stm32f030gftl ## Basic Information - **Project Name**: stm32f030gftl - **Description**: 1、基于rt-thread,stm32f030k6t6,通用单芯片方案。2、bs83b12c i2c触摸标准片。3、图正指纹模组 - **Primary Language**: C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2019-01-09 - **Last Updated**: 2024-10-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # stm32f030gftl ## 介绍 1. 基于rt-thread,stm32f030k6t6,通用单芯片方案。 2. bs83b12c i2c触摸标准片。 3. 图正指纹模组 ## 使用说明 1. cpu:stm32f030k6t6,触摸ic:bs83b12c,指纹:贝尔赛克。 2. rtos:rt_thread,drive:serial,i2c。 ## 硬件接口 1. led OK_LED --> LED_GREEN: PB0 ERR_LED --> LED_RED : PA7 SET_LED --> LED_WHITE: PB1 2. i2c TCH_SDA --> PA11 TCH_SCL --> PA12 3. serial UART1_TX --> PA2 UART1_RX --> PA3 4. misc DCT --> PA6 LED --> PA9 ALARM --> PA5 5. exti wkup FINGER_WAKE --> PA8 TOUCHKEY_WAKE --> PA0 F1_WAKE --> PB7 SHAKE_WAKE --> PA4 6. voice VOICE PULSE --> PB4 VOICE RST --> PB3 VOICE BUSY --> PB5 ## 启动流程分析 1. startup_stm32f0xx.s上电和复位入口 ```assembly ; Reset handler routine Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main IMPORT SystemInit LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ``` 2. startup.c,main函数入口 ```c int main(void) { /* disable interrupt first */ rt_hw_interrupt_disable(); data_struct_init(); /* startup RT-Thread RTOS */ rtthread_startup(); return 0; } ``` 3.startup.c,mian函数关闭中断唯一调用的函数 ```c void rtthread_startup(void) { /* init board */ rt_hw_board_init(); /* show version */ rt_show_version(); /* init tick */ rt_system_tick_init(); /* init kernel object */ rt_system_object_init(); /* init timer system */ rt_system_timer_init(); #ifdef RT_USING_HEAP rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); #endif /* init scheduler system */ rt_system_scheduler_init(); /* init application */ rt_application_init(); /* init timer thread */ rt_system_timer_thread_init(); /* init idle thread */ rt_thread_idle_init(); /* start scheduler */ rt_system_scheduler_start(); /* never reach here */ return ; } ``` 4. board.c系统时钟和串口初始化,开闭coompentment初始化 ```c /** * This function will initial STM32 board. */ void rt_hw_board_init() { /* NVIC Configuration */ NVIC_Configuration(); /* Configure the SysTick */ RCC_Configuration(); SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); /* Initial usart deriver, and set console device */ rt_hw_usart_init(); #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif /* Print RCC freq info */ #ifdef PRINT_RCC_FREQ_INFO print_rcc_freq_info(); #endif /* Call components board initial (use INIT_BOARD_EXPORT()) */ #ifdef RT_USING_COMPONENTS_INIT rt_components_board_init(); #endif } ``` 5. application.c创建并启动主线程,从主线程开始为用户编写内容。 ```c int rt_application_init() { rt_thread_t init_thread; #if (RT_THREAD_PRIORITY_MAX == 32) init_thread = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 512, 8, 20); #else init_thread = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 512, 80, 20); #endif if(init_thread != RT_NULL) rt_thread_startup(init_thread); return 0; } ``` ## 优先级和堆栈分配 1. 系统上电后最先创建init_thread,这个线程是一次性线程,在init_thread中创建了pm_thread 这个线程是自始至终一直处于就绪态的。 2. pm_thread 中根据系统状态初始化硬件和线程。 3. RT-Thread 线程的优先级是表示线程被调度的优先程度。每个线程都具有优先级,线程越重要,赋予的优先级就应越高,- 线程被调度的可能才会越大。 RT-Thread 最大支持 256 个线程优先级 (0\~255),数值越小的优先级越高,0 为最高优先级。在一些资源比较紧张的系统中,可以根据实际情况选择只支持 8 个或 32 个优先级的系统配置;对于 ARM Cortex-M 系列,普遍采用 32 个优先级。最低优先级默认分配给空闲线程使用,用户一般不使用。在系统中,当有比当前线程优先级更高的线程就绪时,当前线程将立刻被换出,高优先级线程抢占处理器运行。 | 线程名称 | 堆栈大小 | 线程优先级 | 时间片 | | ------------- | -------- | ---------- | ------ | | init_thread | 512 | 20 | 20 | | pm_thread | 1024 | 21 | 20 | | button_thread | 512 | 22 | 1 | | led_thread | 512 | 22 | 1 | | finger_thread | | | |