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 ...
随机推荐
- C#实现不安装Oracle客户端访问远程服务器数据!!
概述: C#通过使用ADO的方式在未安装Oracle数据库的前提下,客户端程序远程访问服务器,会出现:“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或 ...
- YII内置验证规则
required: 必填字段验证, 来自 CRequiredValidator类的别名 array(‘字段名列表用逗号隔开’, ‘required’), 就这样的一个小小的写法,可以让字段前面加 ...
- 又一枚神器:nginx
一直听说过nginx的大名,也自己装过,但是未直接使用其各种牛X的功能. 今天试用了一下,只能用两字感叹:牛逼!比如它提供的配置检查功能,真是贴心极了,又比如我想要的静态内容浏览器端缓存功能,动态内容 ...
- Drupal 7.23:函数drupal_alter()注释
/** * Passes alterable variables to specific hook_TYPE_alter() implementations. * * This dispatch fu ...
- D.xml
pre{ line-height:1; color:#1e1e1e; background-color:#f0f0f0; font-size:16px;}.sysFunc{color:#627cf6; ...
- Sunday算法(字符串查找、匹配)
字符串查找算法中,最著名的两个是KMP算法(Knuth-Morris-Pratt)和BM算法(Boyer-Moore).两个算法在最坏情况下均具有线性的查找时间.但是在实用上,KMP算法并不比最简单的 ...
- Wiki动画回顾系列序&&目录
嘛,前前后后看了太多动画,我自己一直想做的事也是喜欢能做一款acg相关的应用,但一直没有好的点子,当然纠结到最后还是需要一个比较好的社区来让大家加入进来.一直有人让我给他们推番,而我也慢慢懂得“人心” ...
- Sunrise Release Version History
Sunrise Release Version History 1.4.1.0 1.1.0.0 1.0.1.0
- 33条C#、.Net经典面试题目及答案
33条C#..Net经典面试题目及答案[zt] 本文集中了多条常见的C#..Net经典面试题目例如".NET中类和结构的区别"."ASP.NET页面之间传递值的几种方式? ...
- [转载]我读过最好的Epoll模型讲解
转载来自:http://blog.csdn.net/mango_song/article/details/42643971 首先我们来定义流的概念,一个流可以是文件,socket,pipe等等可以进行 ...