CMSIS Example - Mail and Timer
#include <stdint.h>
#include "bsp-fifisdr.h"
#include "lpclib.h"
#include "task-gui.h"
#define GUI_QUEUE_LENGTH (4)
typedef struct {
uint8_t opcode;
} GUI_Message;
/** Message opcodes for GUI task. */
enum {
GUI_OPCODE_LED_TICK,
};
/** Identifiers for OS timers. */
enum {
GUI_TIMERMAGIC_LED,
};
/** Local task context. */
static struct {
osMailQId queue;
osTimerId ledTick;
int led;
} gui;
static void GUI_osalCallback (void const *pArgument)
{
(void) pArgument;
if (gui.queue == NULL) {
return;
}
GUI_Message *pMessage = osMailAlloc(gui.queue, );
if (pMessage == NULL) {
return;
}
pMessage->opcode = GUI_OPCODE_LED_TICK;
osMailPut(gui.queue, pMessage);
}
osMailQDef(guiQueue, GUI_QUEUE_LENGTH, GUI_Message);
osTimerDef(led, GUI_osalCallback);
void GUI_task (const void *pArgs)
{
(void) pArgs;
GUI_Message *pMessage;
osEvent event;
gui.queue = osMailCreate(osMailQ(guiQueue), NULL);
gui.ledTick = osTimerCreate(osTimer(led), osTimerPeriodic, (void *)GUI_TIMERMAGIC_LED);
osTimerStart(gui.ledTick, );
while () {
/* Is there a new message? */
event = osMailGet(gui.queue, osWaitForever);
if (event.status == osEventMail) {
pMessage = (GUI_Message *)event.value.p;
switch (pMessage->opcode) {
case GUI_OPCODE_LED_TICK:
gui.led = gui.led ^ ;
BSP_setLed(gui.led);
break;
}
osMailFree(gui.queue, pMessage);
}
}
}
CMSIS Example - Mail and Timer的更多相关文章
- CMSIS Example - Mail and Message
/*---------------------------------------------------------------------------- * RL-ARM - RTX *----- ...
- 利用windows服务+timer或者windows任务计划程序+控制台进行进行每日邮件推送
1.邮件发送代码 using System.Text; using System.Net; using System.Net.Mail; using System.Reflection; using ...
- CMSIS OS None
/* ---------------------------------------------------------------------- * Copyright (C) 2011 ARM L ...
- CMSIS RTOS -- embOS segger
#ifndef __CMSIS_OS_H__ #define __CMSIS_OS_H__ #include <stdint.h> #include <stddef.h> #i ...
- 几种任务调度的 Java 实现方法与比较Timer,ScheduledExecutor,Quartz,JCronTab
几种任务调度的 Java 实现方法与比较 综观目前的 Web 应用,多数应用都具备任务调度的功能.本文由浅入深介绍了几种任务调度的 Java 实现方法,包括 Timer,Scheduler, Quar ...
- Python撰写mail
版本1 指定邮箱进行发送 """ 说明:指定账户密码进行邮件发送 由312051952@qq.com-->c4kaichen@163.com "&qu ...
- Linux 定时任务 crontab 和 Systemd Timer
一.说说八卦 说到定时任务,我们常用的就是 crond 服务,但是我们不知道还有另外一种定时方式,那就是 systemd,我们常用 systemd 来管理我们的服务,但是我们却不知道,我们还可以通 ...
- SysTick Software Timer
#ifndef __SYSTEM_H__ #define __SYSTEM_H__ #include <stdint.h> #include <stddef.h> #inclu ...
- C++ Timer
Timer机制 这里所说的Timer机制是定时器(Timer),例如在Javascript中就提供定时执行代码的功能.但是在C++标准中暂时没有实现这一功能的函数. Javascript中的Timer ...
随机推荐
- 解决 RaspberryPi 树莓派 NTP服务异常 无法自动同步时间
sudo nano /etc/ntp.conf 然后找到 # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server ...
- ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
use mysql mysql> select host, user from user; 将相应用户数据表中的host字段改成'%': update user set host='%' whe ...
- linux静态与动态库创建及使用实例
一,gcc基础语法: 基本语法结构:(由以下四部分组成) gcc -o 可执行文件名 依赖文件集(*.c/*.o) 依赖库文件及其头文件集(由-I或-L与-l指明) gcc 依赖文件集(*.c/*.o ...
- HEAD
Branches are just pointers to commits Every branch is simply a named pointer to a commit. A special ...
- PHP生成静态页面
生成静态页面的本质就是读取缓存中的信息,然后写到一个生成的html页面中. 一.用ob_start和ob_get_contents生成静态页面 //打开缓存 <?phpob_start();// ...
- C#读写文件总结
1.使用FileStream读写文件 文件头: using System; using System.Collections.Generic; using System.Text; using ...
- python+selenium环境搭建
这里主要基于windows平台. 下载python.http://python.org/getit/ 下载setuptools [python的基础包工具].http://pypi.python.or ...
- Linux man命令数字含义
1,用户在shell环境中可以操作的命令或可执行文件 2,系统内核可调用的函数与工具等,即由内核提供的函数. 如open,write之类的(通过这个,可以很方便的查到调用这个函数时需要加什么头文件 ...
- 大数据处理-bitmap是个神马东西
1. Bit Map算法简介 所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素.由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省. 2. B ...
- Python单例模式研究
方法一 import threading class Singleton(object): __instance = None __lock = threading.Lock() # used t ...