cola_os|cola_os(v1.2.0)版本发布增加国产单片机SWM181例程

一、前言

基于一段时间的优化cola os发布了1.2.0版本。

  1. 增加串口使用例程
  2. 优化任务管理
  3. 增加SWM181国产MCU例程

二、代码介绍

cola os说明

三、os代码

#ifndef _COLA_OS_H_
#define _COLA_OS_H_


#include <stdint.h>
#include <stdbool.h>

#define COLA_VERSION      1 
#define COLA_SUBVERSION   2
#define COLA_REVISION     0


//任务事件
enum EVENT_SIG
{
    SIG_ALARM = 1 << 0,
    SIG_DATA  = 1 << 1,
    SIG_NOTE  = 1 << 2,
    SIG_UART  = 1 << 3,
    SIG_RADIO = 1 << 4,
    SIG_GPRS  = 1 << 5,
    SIG_USR1  = 1 << 8,
    SIG_USR2  = 1 << 9,
    SYS_EVENT_MSG  = 1 << 15,
};


enum
{
    TIMER_ALWAYS     = 0x00,
    TIMER_ONE_SHOT   = 0x01,
};

enum
{
    TASK_IDLE        = 0x00,
    TASK_BUSY        = 0x01,
};

typedef void (*cbFunc)(void *arg,uint32_t event);

typedef struct task_s
{
    uint8_t     timerNum;    //定时编号
    uint32_t    period;      //定时周期
    bool        oneShot;     //true只执行一次
    bool        start;       //开始启动
    uint32_t    timerTick;   //定时计数
    bool        run;         //任务运行标志 
    bool        taskFlag;    //任务标志是主任务还是定时任务
    uint32_t    event;       //驱动事件  
    cbFunc      func;        //回调函数
	bool        isBusy;      //用于低功耗控制
    void*       usr;          //用户接口
    struct task_s *next;
}task_t;

#define stimer    task_t
extern volatile unsigned int jiffies;
/*
    主循环任务创建
*/
int cola_task_create(task_t *task,cbFunc func,void *arg);
/*
    主循环任务删除
*/
int cola_task_delete(task_t *task);
/*
    任务遍历,放到while(1)循环中
*/
void cola_task_loop(void);
/*
    定时任务创建
*/
int cola_timer_create(task_t *timer,cbFunc func,void *arg);
/*
    启动定时任务
    one_shot:TIMER_ALWAYS   循环定时
              TIMER_ONE_SHOT 只运行一次
    time_ms :定时时间
*/
int cola_timer_start(task_t *timer,bool one_shot,uint32_t time_ms);
/*
    停止定时任务
*/
int cola_timer_stop(task_t *timer);

/*
    删除定时任务
*/
int cola_timer_delete(task_t *timer);

/*
    定时任务遍历,放到1ms ticker中
*/
void cola_timer_ticker(void);
/*
    设置任务事件
*/
int  cola_set_event(task_t *task,uint32_t sig_id);
/*
    取消任务事件
*/
int  cola_clear_event(task_t *task,uint32_t sig_id);
/*
    阻塞延时函数
*/
void cola_delay_ms(uint32_t ms);
/*
    设置休眠函数接口
*/
int cola_set_sleep_handel(cbFunc func);
#endif 

四、运行log

在这里插入图片描述

五、代码下载

代码下载

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值