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

Committer:
71GA
Date:
2015-05-02
Revision:
1:6eac03db3e22
Parent:
0:f527456a69f2

File content as of revision 1:6eac03db3e22:

#include "LPC4088-ioconfig.h"
#include "LPC4088-gpio.h"

void delay(void);

int main(){


    
    //nastavitev P1.13 kot GPIO, no pull-up, no hysteresis, not inverted, standard, push-pull
    IOCON_P1_13 = IOCON_P1_13 & !(0x67F);
    
    //nastavitev P1.13 kot output
    DIR1 = DIR1 | (1<<13);
    
    //nastavitev P1.13 maske
    MASK1 = MASK1 & !(1<<13);

    
    
    //nastavitev P2.10 kot GPIO, pull-down, no hysteresis, not inverted, standard, push-pull
    IOCON_P2_10 = IOCON_P2_10 & !(0x67F);
    
    //nastavitev P2.10 kot input
    DIR2 = DIR2 & !(1<<10);
    
    //nastavitev P2.10 maske
    MASK2 = MASK2 & !(1<<10);
    
    
    while(1){
        
        //preverimo, ce je tipka prizgana
        if((PIN2 & (1<<10)) == (1<<10)){
            
            //prizgemo P1.13 preko celotnega porta
            PIN1 = PIN1 | (1<<13);
        
            delay();

            //ugasnemo P1.13 preko celotnega porta
            PIN1 = PIN1 & !(1<<13);
        
            delay();
        
        }
    }
}


void delay(void){
    volatile int stej = 1000000;
    while(stej){
        stej = stej - 1;
    }
}