Shuto Naruse
/
Eurobot2012_Beacons
Eurobot2012_Beacons
main.cpp@0:b8be0a00c4f8, 2012-04-18 (annotated)
- Committer:
- narshu
- Date:
- Wed Apr 18 21:08:20 2012 +0000
- Revision:
- 0:b8be0a00c4f8
- Child:
- 1:b0aa1251016a
complete beacon code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
narshu | 0:b8be0a00c4f8 | 1 | #define BEACON_1 |
narshu | 0:b8be0a00c4f8 | 2 | #include "defines.h" |
narshu | 0:b8be0a00c4f8 | 3 | #include "mbed.h" |
narshu | 0:b8be0a00c4f8 | 4 | #include "RF12B.h" |
narshu | 0:b8be0a00c4f8 | 5 | |
narshu | 0:b8be0a00c4f8 | 6 | |
narshu | 0:b8be0a00c4f8 | 7 | PwmOut IRled(p21); |
narshu | 0:b8be0a00c4f8 | 8 | |
narshu | 0:b8be0a00c4f8 | 9 | Serial pc(USBTX, USBRX); // tx, rx |
narshu | 0:b8be0a00c4f8 | 10 | |
narshu | 0:b8be0a00c4f8 | 11 | RF12B RF_Beacon(p5, p6, p7, p11, p14, p20); //RF module |
narshu | 0:b8be0a00c4f8 | 12 | |
narshu | 0:b8be0a00c4f8 | 13 | void turnON (void); |
narshu | 0:b8be0a00c4f8 | 14 | void turnOFF (void); |
narshu | 0:b8be0a00c4f8 | 15 | |
narshu | 0:b8be0a00c4f8 | 16 | // interrupt driven |
narshu | 0:b8be0a00c4f8 | 17 | Timeout toggle; |
narshu | 0:b8be0a00c4f8 | 18 | |
narshu | 0:b8be0a00c4f8 | 19 | char data_in; |
narshu | 0:b8be0a00c4f8 | 20 | |
narshu | 0:b8be0a00c4f8 | 21 | int main() { |
narshu | 0:b8be0a00c4f8 | 22 | RF_Beacon.setCode(CODE); |
narshu | 0:b8be0a00c4f8 | 23 | IRled.period_us(T_CARRIER); |
narshu | 0:b8be0a00c4f8 | 24 | toggle.attach_us(&turnON, 1000); |
narshu | 0:b8be0a00c4f8 | 25 | pc.printf("Beacon Side \n"); |
narshu | 0:b8be0a00c4f8 | 26 | while (1) { |
narshu | 0:b8be0a00c4f8 | 27 | } |
narshu | 0:b8be0a00c4f8 | 28 | } |
narshu | 0:b8be0a00c4f8 | 29 | |
narshu | 0:b8be0a00c4f8 | 30 | void turnON (void) { |
narshu | 0:b8be0a00c4f8 | 31 | IRled.pulsewidth_us(0); // note: the IR led is ON when this is low |
narshu | 0:b8be0a00c4f8 | 32 | toggle.attach_us(&turnOFF, T_CARRIER * ON_CYCLE); |
narshu | 0:b8be0a00c4f8 | 33 | } |
narshu | 0:b8be0a00c4f8 | 34 | |
narshu | 0:b8be0a00c4f8 | 35 | void turnOFF (void) { |
narshu | 0:b8be0a00c4f8 | 36 | IRled.pulsewidth_us(13); // note: the IR led is ON when this is low |
narshu | 0:b8be0a00c4f8 | 37 | toggle.attach_us(&turnON, T_CARRIER * OFF_CYCLE); |
narshu | 0:b8be0a00c4f8 | 38 | } |