首页 > 编程知识 正文

嵌入式软件开发流程,嵌入式软件开发步骤

时间:2023-05-06 02:05:39 阅读:185822 作者:3979

文章列表嵌入式开发|嵌入式软件框架《一》常见软件框架介绍与选择

文章目录系列文章目录序言1、cola os程序框架1.cola _ init2. cola _ device3. cola _ OS task任务创建4.cola_os stime定时器创建2、cola os软件

首先,在包括单片机开发在内的嵌入式软件开发中,软件架构是开发者必须认真考虑的问题。 软件架构对整个系统的稳定性和可靠性非常重要,合适的软件架构不仅结构清晰,而且易于开发。 本教程中使用的框架是参考rt_threadlinux的优秀思想设计的,cola os

一. cola os操作系统程序框架

1.cola_init cola_init文件是系统初始化文件,设计思想参考linux的initcall机制,并参考链接:

inux的initcall机制(用于编译到内核的驱动程序) )。

2.cola_device cola_device是硬件抽象层,抽象硬件具有以下功能,功能参考rt_thread :

structCola_device_ops{int(init ) cola_device_t *dev ); int(*open ) ) cola_device_t *dev,int oflag ); int(*close ) ) cola_device_t *dev ); int(*read ) ) cola_device_t *dev,int pos,void *buffer,int size ); int(*write ) ) cola_device_t *dev,int pos,const void *buffer,int size ); int(*peek ) ) cola_device_t *dev,int pos,void *buffer,int size; int(*control ) ) cola_device_t *dev、int cmd、void *args ); int(*config ) ) cola_device_t *dev、void *args、void *var; (; 将每个硬件虚拟化为一个设备,并通过链表连接。

驱动用例:

串行发送数据:

URT_dev=Cola_device_find(UART1); //首先找到串行端口assert(UART_dev )的COLA_device_write(UART_dev,0,g_buf,ret ); //发送数据3.cola _ OS任务任务cola os的创建是一个系统调度轮询文件,该系统调度的本质也采用了while大循环原理。 但是,如果将各函数配置在链表中,while循环就会从头到尾在链表中循环,执行链表中的函数。

API:/*创建主循环任务*.intcola _ task _ create (task _ t * task,cbFunc func ); 例行程序:

1 .首先决定一个任务结构体,任务

static task_t radio_task; 2 .在2.while(1)中定义循环函数。

调用staticvoidradio _ task _ CB (void * arg,uint32_t event )//循环函数)3.API将函数注册到循环链接列表中。

COLA_task_create(radio_task,radio_task_cb ); 4.cola_os stime定时器创建Stimer软件定时器原理在1ms中断过程中不断地轮询定时器链表,如果出现,设置标记,在while大循环中检测到该标记

API:/*创建定时任务*.intcola _ timer _ create (task _ t * timer,cbFunc func ); /*定时任务启动one _ shot:timer _ always周期时间timer_one_shottime_ms:定时时间*/intcola _ timer _ start (task _ t ) 例行程序:

1 .首先创建软件定时器结构。

static stimer radio_timer; 2 .编写计时器回调函数和到需要执行的时间为止的计时器函数。

调用staticvoidradio _ timer _ CB (void * arg,uint32_t event ) /计时器回调函数)4.API将函数注册到时间任务链接列表中。

Cola_timer_create(radio_timer,radio_timer_cb ); 5 .启动计时器。

每1s运行一次:

Cola_timer_start(radio_timer,TIMER_ALWAYS,1000 ); 定时50s,只运行1次:

Cola_timer_start(radio_timer,TIMER_ONE_SHOT,50000 ); 6 .停止计时器。

Cola_Timer_stop(radio_Timer ); 二. cola os源代码下载:下载

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。