Prototype
Dependencies: mbed ButtonEventDemo
New.cpp@11:052b2fb7d5c7, 2019-12-02 (annotated)
- Committer:
- Kelrath1984
- Date:
- Mon Dec 02 18:26:43 2019 +0000
- Revision:
- 11:052b2fb7d5c7
Mask/Bitmanipulator Prototype(LPC1768)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kelrath1984 | 11:052b2fb7d5c7 | 1 | #include "mbed.h" |
Kelrath1984 | 11:052b2fb7d5c7 | 2 | |
Kelrath1984 | 11:052b2fb7d5c7 | 3 | #define STICKDOWN p12 |
Kelrath1984 | 11:052b2fb7d5c7 | 4 | #define STICKUP p15 |
Kelrath1984 | 11:052b2fb7d5c7 | 5 | #define PUSH p14 |
Kelrath1984 | 11:052b2fb7d5c7 | 6 | #define LEFT p13 |
Kelrath1984 | 11:052b2fb7d5c7 | 7 | #define RIGHT p16 |
Kelrath1984 | 11:052b2fb7d5c7 | 8 | |
Kelrath1984 | 11:052b2fb7d5c7 | 9 | BusOut Led(LED4,LED3,LED2,LED1); |
Kelrath1984 | 11:052b2fb7d5c7 | 10 | BusIn Stick(STICKUP, STICKDOWN, LEFT, RIGHT); |
Kelrath1984 | 11:052b2fb7d5c7 | 11 | |
Kelrath1984 | 11:052b2fb7d5c7 | 12 | int main() |
Kelrath1984 | 11:052b2fb7d5c7 | 13 | { |
Kelrath1984 | 11:052b2fb7d5c7 | 14 | bool state=0; |
Kelrath1984 | 11:052b2fb7d5c7 | 15 | uint8_t mask=0x0F; |
Kelrath1984 | 11:052b2fb7d5c7 | 16 | uint8_t value=0x0F; |
Kelrath1984 | 11:052b2fb7d5c7 | 17 | |
Kelrath1984 | 11:052b2fb7d5c7 | 18 | while(1) |
Kelrath1984 | 11:052b2fb7d5c7 | 19 | { |
Kelrath1984 | 11:052b2fb7d5c7 | 20 | Led=mask&value; |
Kelrath1984 | 11:052b2fb7d5c7 | 21 | |
Kelrath1984 | 11:052b2fb7d5c7 | 22 | |
Kelrath1984 | 11:052b2fb7d5c7 | 23 | if(Stick==4&&!state) |
Kelrath1984 | 11:052b2fb7d5c7 | 24 | { |
Kelrath1984 | 11:052b2fb7d5c7 | 25 | mask=mask<<1; |
Kelrath1984 | 11:052b2fb7d5c7 | 26 | } |
Kelrath1984 | 11:052b2fb7d5c7 | 27 | |
Kelrath1984 | 11:052b2fb7d5c7 | 28 | if(Stick&0xF) |
Kelrath1984 | 11:052b2fb7d5c7 | 29 | { |
Kelrath1984 | 11:052b2fb7d5c7 | 30 | state=1; |
Kelrath1984 | 11:052b2fb7d5c7 | 31 | } |
Kelrath1984 | 11:052b2fb7d5c7 | 32 | else |
Kelrath1984 | 11:052b2fb7d5c7 | 33 | { |
Kelrath1984 | 11:052b2fb7d5c7 | 34 | state=0; |
Kelrath1984 | 11:052b2fb7d5c7 | 35 | } |
Kelrath1984 | 11:052b2fb7d5c7 | 36 | } |
Kelrath1984 | 11:052b2fb7d5c7 | 37 | } |
Kelrath1984 | 11:052b2fb7d5c7 | 38 | |
Kelrath1984 | 11:052b2fb7d5c7 | 39 | |
Kelrath1984 | 11:052b2fb7d5c7 | 40 |