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.
main.cpp@0:86326b7285e2, 2019-11-22 (annotated)
- Committer:
- mlosa010
- Date:
- Fri Nov 22 22:02:42 2019 +0000
- Revision:
- 0:86326b7285e2
button blinking pulldown
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mlosa010 | 0:86326b7285e2 | 1 | #include "mbed.h" |
| mlosa010 | 0:86326b7285e2 | 2 | |
| mlosa010 | 0:86326b7285e2 | 3 | #define FIO1DIR (*(volatile unsigned int*)(0x2009C020)) |
| mlosa010 | 0:86326b7285e2 | 4 | #define SET (*(volatile unsigned int*)(0x2009C034)) |
| mlosa010 | 0:86326b7285e2 | 5 | #define CLR (*(volatile unsigned int*)(0x2009C03C)) |
| mlosa010 | 0:86326b7285e2 | 6 | #define FIO2DIR (*(volatile unsigned char*) (0x2009C040)) |
| mlosa010 | 0:86326b7285e2 | 7 | #define FIO2PIN (*(volatile unsigned char*)(0x2009C054)) |
| mlosa010 | 0:86326b7285e2 | 8 | inline void delay(void); |
| mlosa010 | 0:86326b7285e2 | 9 | int main() { |
| mlosa010 | 0:86326b7285e2 | 10 | FIO2DIR = 0x00; |
| mlosa010 | 0:86326b7285e2 | 11 | FIO1DIR = 0xFFFFFFFF; |
| mlosa010 | 0:86326b7285e2 | 12 | while(1) { |
| mlosa010 | 0:86326b7285e2 | 13 | if((FIO2PIN&0x01)==1){ |
| mlosa010 | 0:86326b7285e2 | 14 | SET |= (1<<18); |
| mlosa010 | 0:86326b7285e2 | 15 | delay(); |
| mlosa010 | 0:86326b7285e2 | 16 | SET &= (0<<18)|(0<<20); |
| mlosa010 | 0:86326b7285e2 | 17 | delay(); |
| mlosa010 | 0:86326b7285e2 | 18 | }else{ |
| mlosa010 | 0:86326b7285e2 | 19 | SET |= (1<<20); |
| mlosa010 | 0:86326b7285e2 | 20 | delay(); |
| mlosa010 | 0:86326b7285e2 | 21 | SET &= (0<<20)|(0<<18); |
| mlosa010 | 0:86326b7285e2 | 22 | delay(); |
| mlosa010 | 0:86326b7285e2 | 23 | } |
| mlosa010 | 0:86326b7285e2 | 24 | } |
| mlosa010 | 0:86326b7285e2 | 25 | } |
| mlosa010 | 0:86326b7285e2 | 26 | |
| mlosa010 | 0:86326b7285e2 | 27 | inline void delay(void){ |
| mlosa010 | 0:86326b7285e2 | 28 | |
| mlosa010 | 0:86326b7285e2 | 29 | for (int i=0; i<2000000; i++){ |
| mlosa010 | 0:86326b7285e2 | 30 | i++; |
| mlosa010 | 0:86326b7285e2 | 31 | i--; |
| mlosa010 | 0:86326b7285e2 | 32 | } |
| mlosa010 | 0:86326b7285e2 | 33 | } |