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.
Fork of ECE_4180_Lab1_P1_Arm by
main.cpp@0:94cb0da877bc, 2016-09-07 (annotated)
- Committer:
- zbraun6
- Date:
- Wed Sep 07 20:54:08 2016 +0000
- Revision:
- 0:94cb0da877bc
- Child:
- 1:1d27be3b634d
ARM ;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| zbraun6 | 0:94cb0da877bc | 1 | #include "mbed.h" |
| zbraun6 | 0:94cb0da877bc | 2 | // This program will blink LED1 and LED4 |
| zbraun6 | 0:94cb0da877bc | 3 | // using assembly language for LED1 and |
| zbraun6 | 0:94cb0da877bc | 4 | // API functions for LED4 |
| zbraun6 | 0:94cb0da877bc | 5 | // declare external assembly language function (in a *.s file) |
| zbraun6 | 0:94cb0da877bc | 6 | extern "C" int my_asm(int value); |
| zbraun6 | 0:94cb0da877bc | 7 | // declare LED outputs – let C set them up as output bits |
| zbraun6 | 0:94cb0da877bc | 8 | DigitalOut myled1(LED1); |
| zbraun6 | 0:94cb0da877bc | 9 | DigitalOut myled4(LED4); |
| zbraun6 | 0:94cb0da877bc | 10 | DigitalOut digOut(p30); |
| zbraun6 | 0:94cb0da877bc | 11 | DigitalIn digIn(p21); |
| zbraun6 | 0:94cb0da877bc | 12 | |
| zbraun6 | 0:94cb0da877bc | 13 | int main() { |
| zbraun6 | 0:94cb0da877bc | 14 | int value = 0; |
| zbraun6 | 0:94cb0da877bc | 15 | while(1) { |
| zbraun6 | 0:94cb0da877bc | 16 | if (digIn) { |
| zbraun6 | 0:94cb0da877bc | 17 | value = 1; |
| zbraun6 | 0:94cb0da877bc | 18 | } else { |
| zbraun6 | 0:94cb0da877bc | 19 | value = 0; |
| zbraun6 | 0:94cb0da877bc | 20 | } |
| zbraun6 | 0:94cb0da877bc | 21 | |
| zbraun6 | 0:94cb0da877bc | 22 | |
| zbraun6 | 0:94cb0da877bc | 23 | // loop forever |
| zbraun6 | 0:94cb0da877bc | 24 | |
| zbraun6 | 0:94cb0da877bc | 25 | //call assembly language function to control LED1 |
| zbraun6 | 0:94cb0da877bc | 26 | my_asm(value); |
| zbraun6 | 0:94cb0da877bc | 27 | //API function to control LED4 |
| zbraun6 | 0:94cb0da877bc | 28 | // myled4 = value; |
| zbraun6 | 0:94cb0da877bc | 29 | // flip value and wait |
| zbraun6 | 0:94cb0da877bc | 30 | |
| zbraun6 | 0:94cb0da877bc | 31 | wait(0.2); |
| zbraun6 | 0:94cb0da877bc | 32 | } |
| zbraun6 | 0:94cb0da877bc | 33 | } |
