Program which demonstrates the usage of the IOCONFIG & GPIO peripherals. Program only blinks the LED based on 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@0:2636b9dea739, 2015-05-02 (annotated)
- Committer:
- 71GA
- Date:
- Sat May 02 17:17:05 2015 +0000
- Revision:
- 0:2636b9dea739
First commit for this program.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
71GA | 0:2636b9dea739 | 1 | #include "LPC4088-ioconfig.h" |
71GA | 0:2636b9dea739 | 2 | #include "LPC4088-system.h" |
71GA | 0:2636b9dea739 | 3 | #include "LPC4088-gpio.h" |
71GA | 0:2636b9dea739 | 4 | |
71GA | 0:2636b9dea739 | 5 | |
71GA | 0:2636b9dea739 | 6 | void delay(void); |
71GA | 0:2636b9dea739 | 7 | |
71GA | 0:2636b9dea739 | 8 | int main(){ |
71GA | 0:2636b9dea739 | 9 | |
71GA | 0:2636b9dea739 | 10 | //nastavitev P1.13 kot GPIO, no pull-up, no hysteresis, not inverted, standard, push-pull |
71GA | 0:2636b9dea739 | 11 | IOCON_P1_13 = IOCON_P1_13 & !(0x67F); |
71GA | 0:2636b9dea739 | 12 | |
71GA | 0:2636b9dea739 | 13 | //vklop GPIO periferije (nepotrebno) |
71GA | 0:2636b9dea739 | 14 | PCONP = PCONP | (1<<15); |
71GA | 0:2636b9dea739 | 15 | |
71GA | 0:2636b9dea739 | 16 | //nastavitev P1.13 kot output |
71GA | 0:2636b9dea739 | 17 | DIR1 = DIR1 | (1<<13); |
71GA | 0:2636b9dea739 | 18 | |
71GA | 0:2636b9dea739 | 19 | //nastavitev P1.13 maske |
71GA | 0:2636b9dea739 | 20 | MASK1 = MASK1 & !(1<<13); |
71GA | 0:2636b9dea739 | 21 | |
71GA | 0:2636b9dea739 | 22 | while(1){ |
71GA | 0:2636b9dea739 | 23 | |
71GA | 0:2636b9dea739 | 24 | //prizgemo P1.13 preko celotnega porta |
71GA | 0:2636b9dea739 | 25 | PIN1 = PIN1 | (1<<13); |
71GA | 0:2636b9dea739 | 26 | |
71GA | 0:2636b9dea739 | 27 | delay(); |
71GA | 0:2636b9dea739 | 28 | |
71GA | 0:2636b9dea739 | 29 | //prizgemo P1.13 preko celotnega porta |
71GA | 0:2636b9dea739 | 30 | PIN1 = PIN1 & !(1<<13); |
71GA | 0:2636b9dea739 | 31 | |
71GA | 0:2636b9dea739 | 32 | delay(); |
71GA | 0:2636b9dea739 | 33 | |
71GA | 0:2636b9dea739 | 34 | } |
71GA | 0:2636b9dea739 | 35 | } |
71GA | 0:2636b9dea739 | 36 | |
71GA | 0:2636b9dea739 | 37 | |
71GA | 0:2636b9dea739 | 38 | void delay(void){ |
71GA | 0:2636b9dea739 | 39 | volatile int stej = 10000000; |
71GA | 0:2636b9dea739 | 40 | while(stej){ |
71GA | 0:2636b9dea739 | 41 | stej = stej - 1; |
71GA | 0:2636b9dea739 | 42 | } |
71GA | 0:2636b9dea739 | 43 | } |