Program which demonstrates the usage of the IOCONFIG & GPIO peripherals. Program only blinks the LED based on the push of the button embedded on the LPC4088 QSB. Blinking is done using the primitive delay function which only makes microprocessor busy for some time. Source code is split - we keep register definitions in header files away from the main source file.
Dependencies: mbed
main.c@1:6eac03db3e22, 2015-05-02 (annotated)
- Committer:
- 71GA
- Date:
- Sat May 02 17:23:20 2015 +0000
- Revision:
- 1:6eac03db3e22
- Parent:
- 0:f527456a69f2
First commit of this program.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
71GA | 0:f527456a69f2 | 1 | #include "LPC4088-ioconfig.h" |
71GA | 0:f527456a69f2 | 2 | #include "LPC4088-gpio.h" |
71GA | 0:f527456a69f2 | 3 | |
71GA | 0:f527456a69f2 | 4 | void delay(void); |
71GA | 0:f527456a69f2 | 5 | |
71GA | 0:f527456a69f2 | 6 | int main(){ |
71GA | 0:f527456a69f2 | 7 | |
71GA | 0:f527456a69f2 | 8 | |
71GA | 0:f527456a69f2 | 9 | |
71GA | 0:f527456a69f2 | 10 | //nastavitev P1.13 kot GPIO, no pull-up, no hysteresis, not inverted, standard, push-pull |
71GA | 0:f527456a69f2 | 11 | IOCON_P1_13 = IOCON_P1_13 & !(0x67F); |
71GA | 0:f527456a69f2 | 12 | |
71GA | 0:f527456a69f2 | 13 | //nastavitev P1.13 kot output |
71GA | 0:f527456a69f2 | 14 | DIR1 = DIR1 | (1<<13); |
71GA | 0:f527456a69f2 | 15 | |
71GA | 0:f527456a69f2 | 16 | //nastavitev P1.13 maske |
71GA | 0:f527456a69f2 | 17 | MASK1 = MASK1 & !(1<<13); |
71GA | 0:f527456a69f2 | 18 | |
71GA | 0:f527456a69f2 | 19 | |
71GA | 0:f527456a69f2 | 20 | |
71GA | 0:f527456a69f2 | 21 | //nastavitev P2.10 kot GPIO, pull-down, no hysteresis, not inverted, standard, push-pull |
71GA | 0:f527456a69f2 | 22 | IOCON_P2_10 = IOCON_P2_10 & !(0x67F); |
71GA | 0:f527456a69f2 | 23 | |
71GA | 0:f527456a69f2 | 24 | //nastavitev P2.10 kot input |
71GA | 0:f527456a69f2 | 25 | DIR2 = DIR2 & !(1<<10); |
71GA | 0:f527456a69f2 | 26 | |
71GA | 0:f527456a69f2 | 27 | //nastavitev P2.10 maske |
71GA | 0:f527456a69f2 | 28 | MASK2 = MASK2 & !(1<<10); |
71GA | 0:f527456a69f2 | 29 | |
71GA | 0:f527456a69f2 | 30 | |
71GA | 0:f527456a69f2 | 31 | while(1){ |
71GA | 0:f527456a69f2 | 32 | |
71GA | 0:f527456a69f2 | 33 | //preverimo, ce je tipka prizgana |
71GA | 0:f527456a69f2 | 34 | if((PIN2 & (1<<10)) == (1<<10)){ |
71GA | 0:f527456a69f2 | 35 | |
71GA | 0:f527456a69f2 | 36 | //prizgemo P1.13 preko celotnega porta |
71GA | 0:f527456a69f2 | 37 | PIN1 = PIN1 | (1<<13); |
71GA | 0:f527456a69f2 | 38 | |
71GA | 0:f527456a69f2 | 39 | delay(); |
71GA | 0:f527456a69f2 | 40 | |
71GA | 1:6eac03db3e22 | 41 | //ugasnemo P1.13 preko celotnega porta |
71GA | 0:f527456a69f2 | 42 | PIN1 = PIN1 & !(1<<13); |
71GA | 0:f527456a69f2 | 43 | |
71GA | 0:f527456a69f2 | 44 | delay(); |
71GA | 0:f527456a69f2 | 45 | |
71GA | 0:f527456a69f2 | 46 | } |
71GA | 0:f527456a69f2 | 47 | } |
71GA | 0:f527456a69f2 | 48 | } |
71GA | 0:f527456a69f2 | 49 | |
71GA | 0:f527456a69f2 | 50 | |
71GA | 0:f527456a69f2 | 51 | void delay(void){ |
71GA | 0:f527456a69f2 | 52 | volatile int stej = 1000000; |
71GA | 0:f527456a69f2 | 53 | while(stej){ |
71GA | 0:f527456a69f2 | 54 | stej = stej - 1; |
71GA | 0:f527456a69f2 | 55 | } |
71GA | 0:f527456a69f2 | 56 | } |