[Tiny OS]tiny OS를 이용한 LED 구동
LED 한번에 on시킨후 off 시킴
/******************************************************************************/
/* */
/* Copyright (c) HANBACK ELECTRONICS */
/* All rights reserved. */
/* */
/* http://www.hanback.com */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/*============================================================================*/
/* Permission to use, copy, modify, and distribute this software and its */
/* documentation are reserved by above authors and Hanback electronics. */
/* The above copyright notice and authors must be described in this software. */
/*============================================================================*/
/* */
/******************************************************************************/
module BlinkM {
uses {
interface Boot;
interface Leds;
interface BusyWait<TMicro, uint16_t>;
}
}
implementation {
task void led_task();
event void Boot.booted() {
post led_task();
}
task void led_task();
call Leds.led0On();
call Leds.led1On();
call Leds.led2On();
call BusyWait.wait(300000);
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
}
}
LED 하나씩 토글 시킨다.[단 토글함수를 사용하지 않음]
////////////////////////////////////////////////////////////
/******************************************************************************/
/* */
/* Copyright (c) HANBACK ELECTRONICS */
/* All rights reserved. */
/* */
/* http://www.hanback.com */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/*============================================================================*/
/* Permission to use, copy, modify, and distribute this software and its */
/* documentation are reserved by above authors and Hanback electronics. */
/* The above copyright notice and authors must be described in this software. */
/*============================================================================*/
/* */
/******************************************************************************/
module BlinkM {
uses {
interface Boot;
interface Leds;
interface BusyWait<TMicro, uint16_t>;
}
}
implementation {
task void led_task();
event void Boot.booted() {
post led_task();
}
task void led_task(){
int i;
while(1){
call Leds.led0On();
call BusyWait.wait(300000);
call Leds.led0Off();
call Leds.led1On();
call BusyWait.wait(300000);
call Leds.led1Off();
call Leds.led2On();
call BusyWait.wait(300000);
call Leds.led2Off();
}
}
}
파도타기 입니다.
/******************************************************************************/
/* */
/* Copyright (c) HANBACK ELECTRONICS */
/* All rights reserved. */
/* */
/* http://www.hanback.com */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/*============================================================================*/
/* Permission to use, copy, modify, and distribute this software and its */
/* documentation are reserved by above authors and Hanback electronics. */
/* The above copyright notice and authors must be described in this software. */
/*============================================================================*/
/* */
/******************************************************************************/
module BlinkM {
uses {
interface Boot;
interface Leds;
interface BusyWait<TMicro, uint16_t>;
}
}
implementation {
task void led_task();
event void Boot.booted() {
post led_task();
}
task void led_task(){
int i=0;
while(1){
if(i==0){
call Leds.led0On();
call BusyWait.wait(300000);
call Leds.led0Off();
call Leds.led1On();
call BusyWait.wait(300000);
call Leds.led1Off();
call Leds.led2On();
call BusyWait.wait(300000);
call Leds.led2Off();
i=1;
}
if(i==1){
call Leds.led2On();
call BusyWait.wait(300000);
call Leds.led2Off();
call Leds.led1On();
call BusyWait.wait(300000);
call Leds.led1Off();
call Leds.led0On();
call BusyWait.wait(300000);
call Leds.led0Off();
i=0;
}
}
}
}
응용편
/******************************************************************************/
/* */
/* Copyright (c) HANBACK ELECTRONICS */
/* All rights reserved. */
/* */
/* http://www.hanback.com */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/*============================================================================*/
/* Permission to use, copy, modify, and distribute this software and its */
/* documentation are reserved by above authors and Hanback electronics. */
/* The above copyright notice and authors must be described in this software. */
/*============================================================================*/
/* */
/******************************************************************************/
module BlinkM {
uses {
interface Boot;
interface Leds;
interface BusyWait<TMicro, uint16_t>;
}
}
implementation {
task void led_task();
event void Boot.booted() {
post led_task();
}
task void led_task(){
int i=0;
for(i=0; i<30; i++){
call Leds.led2Toggle();
call BusyWait.wait(300000);
}
call BusyWait.wait(300000);
for(i=0; i<30; i++){
call Leds.led1Toggle();
call Leds.led2Toggle();
call BusyWait.wait(300000);
}
call BusyWait.wait(300000);
for(i=0; i<30; i++){
call Leds.led0Toggle();
call Leds.led2Toggle();
call Leds.led1Toggle();
call BusyWait.wait(300000);
}
call BusyWait.wait(300000);
call Leds.led0Off();
call Leds.led1Off();
call Leds.led1Off();
}
}