A Ricker is a simple Ticker but using the RIT rather than Timer3
example1.h@0:5684eed14bda, 2011-03-11 (annotated)
- Committer:
- AjK
- Date:
- Fri Mar 11 18:28:13 2011 +0000
- Revision:
- 0:5684eed14bda
0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:5684eed14bda | 1 | |
AjK | 0:5684eed14bda | 2 | /* Example using a Ricker to make a callback to a C style function */ |
AjK | 0:5684eed14bda | 3 | |
AjK | 0:5684eed14bda | 4 | #include "mbed.h" |
AjK | 0:5684eed14bda | 5 | #include "Ricker.h" |
AjK | 0:5684eed14bda | 6 | |
AjK | 0:5684eed14bda | 7 | DigitalOut led1(LED1); |
AjK | 0:5684eed14bda | 8 | DigitalOut led2(LED2); |
AjK | 0:5684eed14bda | 9 | DigitalOut led3(LED3); |
AjK | 0:5684eed14bda | 10 | DigitalOut led4(LED4); |
AjK | 0:5684eed14bda | 11 | |
AjK | 0:5684eed14bda | 12 | Ticker t1; // Standard Mbed Ticker |
AjK | 0:5684eed14bda | 13 | Ticker t2; // Standard Mbed Ticker |
AjK | 0:5684eed14bda | 14 | Ricker r3; // A Ricker |
AjK | 0:5684eed14bda | 15 | Ricker r4; // A Ricker |
AjK | 0:5684eed14bda | 16 | |
AjK | 0:5684eed14bda | 17 | void cb1(void) { led1 = !led1; } |
AjK | 0:5684eed14bda | 18 | void cb2(void) { led2 = !led2; } |
AjK | 0:5684eed14bda | 19 | void cb3(void) { led3 = !led3; } |
AjK | 0:5684eed14bda | 20 | void cb4(void) { led4 = !led4; } |
AjK | 0:5684eed14bda | 21 | |
AjK | 0:5684eed14bda | 22 | int main() { |
AjK | 0:5684eed14bda | 23 | |
AjK | 0:5684eed14bda | 24 | led1 = 1; |
AjK | 0:5684eed14bda | 25 | led3 = 1; |
AjK | 0:5684eed14bda | 26 | |
AjK | 0:5684eed14bda | 27 | t1.attach(&cb1, 0.25); |
AjK | 0:5684eed14bda | 28 | t2.attach(&cb2, 0.25); |
AjK | 0:5684eed14bda | 29 | r3.attach(&cb3, 0.25); |
AjK | 0:5684eed14bda | 30 | r4.attach(&cb4, 0.25); |
AjK | 0:5684eed14bda | 31 | |
AjK | 0:5684eed14bda | 32 | while(1) { } |
AjK | 0:5684eed14bda | 33 | } |