In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "LiteOS bare metal driver transplant 05-E53_SF1 expansion board driver method is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "LiteOS bare metal driver transplant 05-E53_SF1 expansion board driver method is what" it!
1.E53_SF1 expansion Board and its driver about E53 Standard Interface
The E of E53 interface standard is taken from the English initials of Expansion, and the size of the board is 5 × 3cm, so E53 is used as the prefix to name the case expansion board of 5cm*3cm type. Any development board that meets the standard design can be directly adapted to the E53 expansion board.
The E53 expansion board is designed according to different application scenarios, restoring the real application scene on the expansion board to the maximum extent, and the extension boards in different cases are named suffixes according to different application scenarios. For example: E53 smart SC1 Smart City SC is the abbreviation of smart city, SC1 represents the street lamp of smart city, and SC2 represents the smart manhole cover of smart city.
In terms of electrical characteristics, the E53 extended interface includes commonly used sensor communication interfaces in the sensing layer of the Internet of things, such as 5V, 3.3V, GND, SPI, UART, IIC, ADC, DAC, etc., which can adapt to various sensors and leave four common GPIO, as shown in the figure:
E53_SF1 intelligent fire protection expansion board
The E53_SF1 expansion board adopts the E53 standard interface, including a combustible gas sensor MQ-2, a passive buzzer and a LED, in which the passive buzzer uses a timer to output PWM signal control, LED uses ordinary GPIO control, and the combustible gas sensor data is read by ADC.
If you are not familiar with the driver of the MQ-2 sensor and passive buzzer on the expansion board, please read the embedded basic tutorial first.
two。 Migrate E53_SF1 driver to LiteOS copy bare metal driver files to LiteOS project
The driver file used in this article will directly generate the timer TIM16 initialization configuration code and ADC initialization configuration code for PWM, so there is no need to copy other underlying files.
The driver file is already included in the default project provided in IoT-Studio, and there is no need to add it again, as shown in the figure:
Add driver file path
Because the entire project of LiteOS is built using make, after copying the driver file, you need to add the path to the driver file to makefile and add compilation.
Previously, we added it directly in project.mk. Here, we use a more simple and effective method to configure directly in user_demo.mk. These driver file paths will be added only when the demo is enabled, without causing conflicts:
Add the following code to user_demo.mk:
# example for e53_sf1_driver_demoifeq ($(CONFIG_USER_DEMO), "e53_sf1_driver_demo") user_hardware_src = ${wildcard $(TOP_DIR) / targets/STM32L431_BearPi/Hardware/E53_SF1/*.c} user_hardware_inc =-I ${wildcard $(TOP_DIR) / targets/STM32L431_BearPi/Hardware/E53_SF1} endif
The locations are as follows:
At this point, copy the file to the LiteOS project, and add the newly copied file path to the makefile. If the demo is opened, add the project compilation and complete the migration of the driver.
3. The use of E53_SF1 bare metal driver to initialize E53_SF1 expansion board
In the first article, two ways to initialize a device in LiteOS are described in detail:
Initialize before the system starts scheduling: the device can be used by any task in the system at any time
Initialize in a task: the device is generally only used in this task
The E53_SF1 expansion board driver transplanted in this paper does not need multiple tasks to operate, but only needs the operation of the sensor data acquisition task, so the initialization is placed in the data acquisition task.
Operate the E53_SF1 expansion board
Next, first create a folder (if you already have one, don't create it again) to hold the code for this series of tutorial labs:
Create a file in this folder:
Write code:
# include # include "lcd.h" # include "E53_SF1.h" / * stores the sensor data of the E53_SF1 expansion board. You can view the semaphore * / osal_semp_t sync_semp defined in E53_SF1.h * / E53_SF1_Data_TypeDef E53 for synchronization between data acquisition and data processing tasks. / * data acquisition task-low priority * / static int data_collect_task_entry () {/ * initialize the expansion board * / Init_E53_SF1 (); while (1) {/ * read the data on the expansion board and store it in the data structure E53_SF1_Data * / E53_SF1_Read_Data () / * when the data is read, release the semaphore and wake up the data processing task * / osal_semp_post (sync_semp); / * task sleep 2s * / osal_task_sleep (2x1000) }} / * data processing task-High priority * / static int data_deal_task_entry () {/ * smoke_value- current data, old-smoke_value- last data * / int smoke_value = 0, old_smoke_value = 0; / * LCD screen removal to prevent interference with display * / LCD_Clear (WHITE) While (1) {/ * waits for semaphores, blocking and waiting * / osal_semp_pend (sync_semp, cn_osal_timeout_forever) before indicating that data has not been collected; / * semaphores wait, wake up, start processing data * / old_smoke_value = smoke_value; smoke_value = (int) E53_SF1_Data.Smoke_Value Printf ("Smoke Value is% d\ r\ n", smoke_value); LCD_ShowString (10,100,200,16,16, "Smoke Value is:"); LCD_ShowNum (140,100, smoke_value, 5,16); / * threshold is 100, automatically turn on or off LED or buzzer * / if (old_smoke_value)
< 100 && smoke_value >{E53_SF1_LED_StatusSet (ON); E53_SF1_Beep_StatusSet (ON); printf ("Beep and Light ON!\ r\ n");} else if (old_smoke_value > 100 & & smoke_value
< 100) { E53_SF1_LED_StatusSet(OFF); E53_SF1_Beep_StatusSet(OFF); printf("Beep and Light OFF!\r\n"); } }}/* 标准demo启动函数,函数名不要修改,否则会影响下一步实验 */int standard_app_demo_main(){ /* 创建信号量 */ osal_semp_create(&sync_semp, 1, 0); /* 数据处理任务的优先级应高于数据采集任务 */ osal_task_create("data_collect",data_collect_task_entry,NULL,0x400,NULL,3); osal_task_create("data_deal",data_deal_task_entry,NULL,0x400,NULL,2); return 0;} 然后按照之前的方法,在 user_demo.mk 中将e53_sf1_driver_demo.c文件添加到makefile中,加入编译: 最后在.sdkconfig中配置开启宏定义: 编译,烧录,即可看到实验现象。 LCD屏幕上显示当前传感器采集的烟感值,并且每2s更新一次。 当烟感值高于100时,E53_SF1扩展板的LED灯自动点亮,蜂鸣器开始鸣叫: 当烟感值低于100时,E53_SF1扩展板的LED灯自动熄灭,蜂鸣器关闭鸣叫: 另外,打开IoT-Studio自带的串口终端,可以查看到串口输出的工作信息: linkmain:V1.2.1 AT 09:31:53 ON Dec 8 2019 Smoke Value is 0WELCOME TO IOT_LINK SHELLLiteOS:/>Smoke Value is 0Smoke Value is 0Smoke Value is 0Smoke Value is 0Smoke Value is 279Beep and Light on smoke Value is 103Smoke Value is 88Beep and Light off smoke Value is 0Smoke Value is 278Beep and Light on smoke Value is 27Beep and Light OFF! Thank you for your reading, the above is the content of "what is the LiteOS bare metal driver transplanting 05-E53_SF1 expansion board driver method". After the study of this article, I believe you have a deeper understanding of what the LiteOS bare metal driver transplant 05-E53_SF1 expansion board driver method is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.