Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
led_tsk.cpp
00001 /* 00002 # 00003 # Copyright (C) 2010-2013, audin 00004 # 2013/08: Modify for mbed for LPC1114FN28 00005 # 2013/07: Modify for LPCOpen Platform. 00006 # 2011/04, 2012/11 00007 # 2010/11 00008 # http://avr.paslog.jp 00009 # This file is licensed under the MIT License. 00010 # 00011 */ 00012 00013 #include "mbed.h" 00014 #include "led_tsk.h" 00015 #include "Scheduler.h" 00016 00017 static int max_val = 0; 00018 static int val = 0; 00019 #define sio_get_led_blink_speed() 9 /* fixed preiod */ 00020 00021 /* for CQ MyARM ,lpc1114fn28 */ 00022 DigitalOut led1(LED1); 00023 DigitalOut led2(LED2); 00024 #define led1_on() led1=0 /* Negative on */ 00025 #define led1_off() led1=1 00026 #define led2_on() led2=1 00027 #define led2_off() led2=0 00028 00029 /******************* 00030 00031 * LED1 init 00032 00033 *******************/ 00034 void led_init(void) 00035 { 00036 led1_off(); /* first off */ 00037 } 00038 00039 /******************* 00040 00041 * Fake PWM 00042 00043 *******************/ 00044 static void pwm( int ms ) 00045 { 00046 led1_on(); 00047 taskWait( ms ); 00048 led1_off(); 00049 taskWait( max_val - val); 00050 } 00051 00052 /******************* 00053 00054 * LED task 00055 00056 *******************/ 00057 void led_task( void) 00058 { 00059 led_tsk( (void *)0 ); /* Just stub */ 00060 } 00061 00062 void led_tsk( void *pvParameters ) 00063 { 00064 ( void ) pvParameters; // not used 00065 led_init(); 00066 const int MIN_VAL = 0; 00067 static int dir = 1; 00068 while( 1 ) { 00069 if( ( val >= max_val) || ( val <= MIN_VAL) ) { 00070 max_val = sio_get_led_blink_speed() + 3 ; // change period 00071 max_val <<= 1; // adjust time 00072 if( val <= MIN_VAL ) { 00073 dir = 1; 00074 taskWait( 1000 ); // wait 1src if led off 00075 } else { 00076 dir = -1; 00077 val = max_val; 00078 } 00079 } 00080 val += dir; 00081 pwm( val ); 00082 } 00083 } 00084 00085 /******************* 00086 00087 * LED2 init 00088 00089 *******************/ 00090 void led2_init(void) 00091 { 00092 led2_off(); /* first off */ 00093 } 00094 00095 void led2_task( void ) 00096 { 00097 led2_init(); 00098 while( 1 ) { 00099 led2_on(); 00100 taskWait(2000); 00101 led2_off(); 00102 taskWait(2000); 00103 } 00104 } 00105
Generated on Wed Jul 20 2022 01:49:52 by
1.7.2