Extra problem 2 for HW 1
main.cpp@0:9b0b3bdf816e, 2015-02-18 (annotated)
- Committer:
- lzzcd001
- Date:
- Wed Feb 18 14:48:30 2015 +0000
- Revision:
- 0:9b0b3bdf816e
Extra problem 2 for HW 1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lzzcd001 | 0:9b0b3bdf816e | 1 | #include "mbed.h" |
| lzzcd001 | 0:9b0b3bdf816e | 2 | // This program will blink LED1 and LED4 |
| lzzcd001 | 0:9b0b3bdf816e | 3 | // using assembly language for LED1 and |
| lzzcd001 | 0:9b0b3bdf816e | 4 | // API functions for LED4 |
| lzzcd001 | 0:9b0b3bdf816e | 5 | // declare external assembly language function (in a *.s file) |
| lzzcd001 | 0:9b0b3bdf816e | 6 | extern "C" int my_asm(); |
| lzzcd001 | 0:9b0b3bdf816e | 7 | // declare LED outputs – let C set them up as output bits |
| lzzcd001 | 0:9b0b3bdf816e | 8 | DigitalIn sw(p5); |
| lzzcd001 | 0:9b0b3bdf816e | 9 | DigitalOut led(p10); |
| lzzcd001 | 0:9b0b3bdf816e | 10 | DigitalOut myled1(LED1); |
| lzzcd001 | 0:9b0b3bdf816e | 11 | DigitalOut myled4(LED4); |
| lzzcd001 | 0:9b0b3bdf816e | 12 | |
| lzzcd001 | 0:9b0b3bdf816e | 13 | int main() { |
| lzzcd001 | 0:9b0b3bdf816e | 14 | // loop forever |
| lzzcd001 | 0:9b0b3bdf816e | 15 | while(1) { |
| lzzcd001 | 0:9b0b3bdf816e | 16 | //call assembly language function to control LED1 |
| lzzcd001 | 0:9b0b3bdf816e | 17 | my_asm(); |
| lzzcd001 | 0:9b0b3bdf816e | 18 | wait(0.2); |
| lzzcd001 | 0:9b0b3bdf816e | 19 | } |
| lzzcd001 | 0:9b0b3bdf816e | 20 | } |