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

Files at this revision

API Documentation at this revision

Comitter:
71GA
Date:
Sat May 02 17:17:05 2015 +0000
Commit message:
First commit for this program.

Changed in this revision

LPC4088-gpio.h Show annotated file Show diff for this revision Revisions of this file
LPC4088-ioconfig.h Show annotated file Show diff for this revision Revisions of this file
LPC4088-system.h Show annotated file Show diff for this revision Revisions of this file
main.c Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2636b9dea739 LPC4088-gpio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC4088-gpio.h	Sat May 02 17:17:05 2015 +0000
@@ -0,0 +1,52 @@
+//definicija registrov za periferijo GPIO
+
+//GPIO
+#define DIR0           (*((volatile unsigned int *) 0x20098000))    //Port0
+#define MASK0          (*((volatile unsigned int *) 0x20098010))
+#define PIN0           (*((volatile unsigned int *) 0x20098014))
+#define SET0           (*((volatile unsigned int *) 0x20098018))
+#define CLR0           (*((volatile unsigned int *) 0x2009801C))
+
+#define DIR1           (*((volatile unsigned int *) 0x20098020))    //Port1
+#define MASK1          (*((volatile unsigned int *) 0x20098030))
+#define PIN1           (*((volatile unsigned int *) 0x20098034))
+#define SET1           (*((volatile unsigned int *) 0x20098038))
+#define CLR1           (*((volatile unsigned int *) 0x2009803C))
+
+#define DIR2           (*((volatile unsigned int *) 0x20098040))    //Port2
+#define MASK2          (*((volatile unsigned int *) 0x20098050))
+#define PIN2           (*((volatile unsigned int *) 0x20098054))
+#define SET2           (*((volatile unsigned int *) 0x20098058))
+#define CLR2           (*((volatile unsigned int *) 0x2009805C))
+
+#define DIR3           (*((volatile unsigned int *) 0x20098060))    //Port3
+#define MASK3          (*((volatile unsigned int *) 0x20098070))
+#define PIN3           (*((volatile unsigned int *) 0x20098074))
+#define SET3           (*((volatile unsigned int *) 0x20098078))
+#define CLR3           (*((volatile unsigned int *) 0x2009807C))
+
+#define DIR4           (*((volatile unsigned int *) 0x20098080))    //Port4
+#define MASK4          (*((volatile unsigned int *) 0x20098090))
+#define PIN4           (*((volatile unsigned int *) 0x20098094))
+#define SET4           (*((volatile unsigned int *) 0x20098098))
+#define CLR4           (*((volatile unsigned int *) 0x2009809C))
+
+#define DIR5           (*((volatile unsigned int *) 0x200980A0))    //Port5
+#define MASK5          (*((volatile unsigned int *) 0x200980B0))
+#define PIN5           (*((volatile unsigned int *) 0x200980B4))
+#define SET5           (*((volatile unsigned int *) 0x200980B8))
+#define CLR5           (*((volatile unsigned int *) 0x200980BC))
+
+
+//GPIO interrupts
+#define int_STATUS     (*((volatile unsigned int *) 0x40028080))
+#define int_STATR0     (*((volatile unsigned int *) 0x40028084))
+#define int_STATF0     (*((volatile unsigned int *) 0x40028088))
+#define int_CLR0       (*((volatile unsigned int *) 0x4002808C))
+#define int_ENR0       (*((volatile unsigned int *) 0x40028090))
+#define int_ENF0       (*((volatile unsigned int *) 0x40028094))
+#define int_STATR2     (*((volatile unsigned int *) 0x400280A4))
+#define int_STATF2     (*((volatile unsigned int *) 0x400280A8))
+#define int_CLR2       (*((volatile unsigned int *) 0x400280AC))
+#define int_ENR2       (*((volatile unsigned int *) 0x400280B0))
+#define int_ENF2       (*((volatile unsigned int *) 0x400280B4))
diff -r 000000000000 -r 2636b9dea739 LPC4088-ioconfig.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC4088-ioconfig.h	Sat May 02 17:17:05 2015 +0000
@@ -0,0 +1,178 @@
+//Definicije registrov za periferijo IOCONFIG
+
+//Port 0
+#define IOCON_P0_0           (*((volatile unsigned int *) 0x4002C000))      //D (IOCON type)
+#define IOCON_P0_1           (*((volatile unsigned int *) 0x4002C004))      //D
+#define IOCON_P0_2           (*((volatile unsigned int *) 0x4002C008))      //D
+#define IOCON_P0_3           (*((volatile unsigned int *) 0x4002C00C))      //D
+#define IOCON_P0_4           (*((volatile unsigned int *) 0x4002C010))      //D
+#define IOCON_P0_5           (*((volatile unsigned int *) 0x4002C014))      //D
+#define IOCON_P0_6           (*((volatile unsigned int *) 0x4002C018))      //D
+#define IOCON_P0_7           (*((volatile unsigned int *) 0x4002C01C))      //W
+#define IOCON_P0_8           (*((volatile unsigned int *) 0x4002C020))      //W
+#define IOCON_P0_9           (*((volatile unsigned int *) 0x4002C024))      //W
+#define IOCON_P0_10          (*((volatile unsigned int *) 0x4002C028))      //D
+#define IOCON_P0_11          (*((volatile unsigned int *) 0x4002C02C))      //D
+#define IOCON_P0_12          (*((volatile unsigned int *) 0x4002C030))      //A
+#define IOCON_P0_13          (*((volatile unsigned int *) 0x4002C034))      //A
+#define IOCON_P0_14          (*((volatile unsigned int *) 0x4002C038))      //D
+#define IOCON_P0_15          (*((volatile unsigned int *) 0x4002C03C))      //D
+#define IOCON_P0_16          (*((volatile unsigned int *) 0x4002C040))      //D
+#define IOCON_P0_17          (*((volatile unsigned int *) 0x4002C044))      //D
+#define IOCON_P0_18          (*((volatile unsigned int *) 0x4002C048))      //D
+#define IOCON_P0_19          (*((volatile unsigned int *) 0x4002C04C))      //D
+#define IOCON_P0_20          (*((volatile unsigned int *) 0x4002C050))      //D
+#define IOCON_P0_21          (*((volatile unsigned int *) 0x4002C054))      //D
+#define IOCON_P0_22          (*((volatile unsigned int *) 0x4002C058))      //D
+#define IOCON_P0_23          (*((volatile unsigned int *) 0x4002C05C))      //A
+#define IOCON_P0_24          (*((volatile unsigned int *) 0x4002C060))      //A
+#define IOCON_P0_25          (*((volatile unsigned int *) 0x4002C064))      //A
+#define IOCON_P0_26          (*((volatile unsigned int *) 0x4002C068))      //A
+#define IOCON_P0_27          (*((volatile unsigned int *) 0x4002C06C))      //I
+#define IOCON_P0_28          (*((volatile unsigned int *) 0x4002C070))      //I
+#define IOCON_P0_29          (*((volatile unsigned int *) 0x4002C074))      //U
+#define IOCON_P0_30          (*((volatile unsigned int *) 0x4002C078))      //U
+#define IOCON_P0_31          (*((volatile unsigned int *) 0x4002C07C))      //U
+
+//Port 1
+#define IOCON_P1_0           (*((volatile unsigned int *) 0x4002C080))      //D (IOCON type)
+#define IOCON_P1_1           (*((volatile unsigned int *) 0x4002C084))      //D
+#define IOCON_P1_2           (*((volatile unsigned int *) 0x4002C088))      //D
+#define IOCON_P1_3           (*((volatile unsigned int *) 0x4002C08C))      //D
+#define IOCON_P1_4           (*((volatile unsigned int *) 0x4002C090))      //D
+#define IOCON_P1_5           (*((volatile unsigned int *) 0x4002C094))      //W
+#define IOCON_P1_6           (*((volatile unsigned int *) 0x4002C098))      //W
+#define IOCON_P1_7           (*((volatile unsigned int *) 0x4002C09C))      //W
+#define IOCON_P1_8           (*((volatile unsigned int *) 0x4002C0A0))      //D
+#define IOCON_P1_9           (*((volatile unsigned int *) 0x4002C0A4))      //D
+#define IOCON_P1_10          (*((volatile unsigned int *) 0x4002C0A8))      //D
+#define IOCON_P1_11          (*((volatile unsigned int *) 0x4002C0AC))      //D
+#define IOCON_P1_12          (*((volatile unsigned int *) 0x4002C0B0))      //D
+#define IOCON_P1_13          (*((volatile unsigned int *) 0x4002C0B4))      //D
+#define IOCON_P1_14          (*((volatile unsigned int *) 0x4002C0B8))      //W
+#define IOCON_P1_15          (*((volatile unsigned int *) 0x4002C0BC))      //D
+#define IOCON_P1_16          (*((volatile unsigned int *) 0x4002C0C0))      //W
+#define IOCON_P1_17          (*((volatile unsigned int *) 0x4002C0C4))      //W
+#define IOCON_P1_18          (*((volatile unsigned int *) 0x4002C0C8))      //D
+#define IOCON_P1_19          (*((volatile unsigned int *) 0x4002C0CC))      //D
+#define IOCON_P1_20          (*((volatile unsigned int *) 0x4002C0D0))      //D
+#define IOCON_P1_21          (*((volatile unsigned int *) 0x4002C0D4))      //D
+#define IOCON_P1_22          (*((volatile unsigned int *) 0x4002C0D8))      //D
+#define IOCON_P1_23          (*((volatile unsigned int *) 0x4002C0DC))      //D
+#define IOCON_P1_24          (*((volatile unsigned int *) 0x4002C0E0))      //D
+#define IOCON_P1_25          (*((volatile unsigned int *) 0x4002C0E4))      //D
+#define IOCON_P1_26          (*((volatile unsigned int *) 0x4002C0E8))      //D
+#define IOCON_P1_27          (*((volatile unsigned int *) 0x4002C0EC))      //D
+#define IOCON_P1_28          (*((volatile unsigned int *) 0x4002C0F0))      //D
+#define IOCON_P1_29          (*((volatile unsigned int *) 0x4002C0F4))      //D
+#define IOCON_P1_30          (*((volatile unsigned int *) 0x4002C0F8))      //A
+#define IOCON_P1_31          (*((volatile unsigned int *) 0x4002C0FC))      //A
+
+//Port 2
+#define IOCON_P2_0           (*((volatile unsigned int *) 0x4002C100))      //D (IOCON type)
+#define IOCON_P2_1           (*((volatile unsigned int *) 0x4002C104))      //D
+#define IOCON_P2_2           (*((volatile unsigned int *) 0x4002C108))      //D
+#define IOCON_P2_3           (*((volatile unsigned int *) 0x4002C10C))      //D
+#define IOCON_P2_4           (*((volatile unsigned int *) 0x4002C110))      //D
+#define IOCON_P2_5           (*((volatile unsigned int *) 0x4002C114))      //D
+#define IOCON_P2_6           (*((volatile unsigned int *) 0x4002C118))      //D
+#define IOCON_P2_7           (*((volatile unsigned int *) 0x4002C11C))      //D
+#define IOCON_P2_8           (*((volatile unsigned int *) 0x4002C120))      //D
+#define IOCON_P2_9           (*((volatile unsigned int *) 0x4002C124))      //D
+#define IOCON_P2_10          (*((volatile unsigned int *) 0x4002C128))      //D
+#define IOCON_P2_11          (*((volatile unsigned int *) 0x4002C12C))      //D
+#define IOCON_P2_12          (*((volatile unsigned int *) 0x4002C130))      //D
+#define IOCON_P2_13          (*((volatile unsigned int *) 0x4002C134))      //D
+#define IOCON_P2_14          (*((volatile unsigned int *) 0x4002C138))      //D
+#define IOCON_P2_15          (*((volatile unsigned int *) 0x4002C13C))      //D
+#define IOCON_P2_16          (*((volatile unsigned int *) 0x4002C140))      //D
+#define IOCON_P2_17          (*((volatile unsigned int *) 0x4002C144))      //D
+#define IOCON_P2_18          (*((volatile unsigned int *) 0x4002C148))      //D
+#define IOCON_P2_19          (*((volatile unsigned int *) 0x4002C14C))      //D
+#define IOCON_P2_20          (*((volatile unsigned int *) 0x4002C150))      //D
+#define IOCON_P2_21          (*((volatile unsigned int *) 0x4002C154))      //D
+#define IOCON_P2_22          (*((volatile unsigned int *) 0x4002C158))      //D
+#define IOCON_P2_23          (*((volatile unsigned int *) 0x4002C15C))      //D
+#define IOCON_P2_24          (*((volatile unsigned int *) 0x4002C160))      //D
+#define IOCON_P2_25          (*((volatile unsigned int *) 0x4002C164))      //D
+#define IOCON_P2_26          (*((volatile unsigned int *) 0x4002C168))      //D
+#define IOCON_P2_27          (*((volatile unsigned int *) 0x4002C16C))      //D
+#define IOCON_P2_28          (*((volatile unsigned int *) 0x4002C170))      //D
+#define IOCON_P2_29          (*((volatile unsigned int *) 0x4002C174))      //D
+#define IOCON_P2_30          (*((volatile unsigned int *) 0x4002C178))      //D
+#define IOCON_P2_31          (*((volatile unsigned int *) 0x4002C17C))      //D
+
+//Port 3
+#define IOCON_P3_0           (*((volatile unsigned int *) 0x4002C180))      //D (IOCON type)
+#define IOCON_P3_1           (*((volatile unsigned int *) 0x4002C184))      //D
+#define IOCON_P3_2           (*((volatile unsigned int *) 0x4002C188))      //D
+#define IOCON_P3_3           (*((volatile unsigned int *) 0x4002C18C))      //D
+#define IOCON_P3_4           (*((volatile unsigned int *) 0x4002C190))      //D
+#define IOCON_P3_5           (*((volatile unsigned int *) 0x4002C194))      //D
+#define IOCON_P3_6           (*((volatile unsigned int *) 0x4002C198))      //D
+#define IOCON_P3_7           (*((volatile unsigned int *) 0x4002C19C))      //D
+#define IOCON_P3_8           (*((volatile unsigned int *) 0x4002C1A0))      //D
+#define IOCON_P3_9           (*((volatile unsigned int *) 0x4002C1A4))      //D
+#define IOCON_P3_10          (*((volatile unsigned int *) 0x4002C1A8))      //D
+#define IOCON_P3_11          (*((volatile unsigned int *) 0x4002C1AC))      //D
+#define IOCON_P3_12          (*((volatile unsigned int *) 0x4002C1B0))      //D
+#define IOCON_P3_13          (*((volatile unsigned int *) 0x4002C1B4))      //D
+#define IOCON_P3_14          (*((volatile unsigned int *) 0x4002C1B8))      //D
+#define IOCON_P3_15          (*((volatile unsigned int *) 0x4002C1BC))      //D
+#define IOCON_P3_16          (*((volatile unsigned int *) 0x4002C1C0))      //D
+#define IOCON_P3_17          (*((volatile unsigned int *) 0x4002C1C4))      //D
+#define IOCON_P3_18          (*((volatile unsigned int *) 0x4002C1C8))      //D
+#define IOCON_P3_19          (*((volatile unsigned int *) 0x4002C1CC))      //D
+#define IOCON_P3_20          (*((volatile unsigned int *) 0x4002C1D0))      //D
+#define IOCON_P3_21          (*((volatile unsigned int *) 0x4002C1D4))      //D
+#define IOCON_P3_22          (*((volatile unsigned int *) 0x4002C1D8))      //D
+#define IOCON_P3_23          (*((volatile unsigned int *) 0x4002C1DC))      //D
+#define IOCON_P3_24          (*((volatile unsigned int *) 0x4002C1E0))      //D
+#define IOCON_P3_25          (*((volatile unsigned int *) 0x4002C1E4))      //D
+#define IOCON_P3_26          (*((volatile unsigned int *) 0x4002C1E8))      //D
+#define IOCON_P3_27          (*((volatile unsigned int *) 0x4002C1EC))      //D
+#define IOCON_P3_28          (*((volatile unsigned int *) 0x4002C1F0))      //D
+#define IOCON_P3_29          (*((volatile unsigned int *) 0x4002C1F4))      //D
+#define IOCON_P3_30          (*((volatile unsigned int *) 0x4002C1F8))      //D
+#define IOCON_P3_31          (*((volatile unsigned int *) 0x4002C1FC))      //D
+
+//Port 4
+#define IOCON_P4_0           (*((volatile unsigned int *) 0x4002C200))      //D (IOCON type)
+#define IOCON_P4_1           (*((volatile unsigned int *) 0x4002C204))      //D
+#define IOCON_P4_2           (*((volatile unsigned int *) 0x4002C208))      //D
+#define IOCON_P4_3           (*((volatile unsigned int *) 0x4002C20C))      //D
+#define IOCON_P4_4           (*((volatile unsigned int *) 0x4002C210))      //D
+#define IOCON_P4_5           (*((volatile unsigned int *) 0x4002C214))      //D
+#define IOCON_P4_6           (*((volatile unsigned int *) 0x4002C218))      //D
+#define IOCON_P4_7           (*((volatile unsigned int *) 0x4002C21C))      //D
+#define IOCON_P4_8           (*((volatile unsigned int *) 0x4002C220))      //D
+#define IOCON_P4_9           (*((volatile unsigned int *) 0x4002C224))      //D
+#define IOCON_P4_10          (*((volatile unsigned int *) 0x4002C228))      //D
+#define IOCON_P4_11          (*((volatile unsigned int *) 0x4002C22C))      //D
+#define IOCON_P4_12          (*((volatile unsigned int *) 0x4002C230))      //D
+#define IOCON_P4_13          (*((volatile unsigned int *) 0x4002C234))      //D
+#define IOCON_P4_14          (*((volatile unsigned int *) 0x4002C238))      //D
+#define IOCON_P4_15          (*((volatile unsigned int *) 0x4002C23C))      //D
+#define IOCON_P4_16          (*((volatile unsigned int *) 0x4002C240))      //D
+#define IOCON_P4_17          (*((volatile unsigned int *) 0x4002C244))      //D
+#define IOCON_P4_18          (*((volatile unsigned int *) 0x4002C248))      //D
+#define IOCON_P4_19          (*((volatile unsigned int *) 0x4002C24C))      //D
+#define IOCON_P4_20          (*((volatile unsigned int *) 0x4002C250))      //D
+#define IOCON_P4_21          (*((volatile unsigned int *) 0x4002C254))      //D
+#define IOCON_P4_22          (*((volatile unsigned int *) 0x4002C258))      //D
+#define IOCON_P4_23          (*((volatile unsigned int *) 0x4002C25C))      //D
+#define IOCON_P4_24          (*((volatile unsigned int *) 0x4002C260))      //D
+#define IOCON_P4_25          (*((volatile unsigned int *) 0x4002C264))      //D
+#define IOCON_P4_26          (*((volatile unsigned int *) 0x4002C268))      //D
+#define IOCON_P4_27          (*((volatile unsigned int *) 0x4002C26C))      //D
+#define IOCON_P4_28          (*((volatile unsigned int *) 0x4002C270))      //D
+#define IOCON_P4_29          (*((volatile unsigned int *) 0x4002C274))      //D
+#define IOCON_P4_30          (*((volatile unsigned int *) 0x4002C278))      //D
+#define IOCON_P4_31          (*((volatile unsigned int *) 0x4002C27C))      //D
+
+//Port 5
+#define IOCON_P5_0           (*((volatile unsigned int *) 0x4002C280))      //D (IOCON type)
+#define IOCON_P5_1           (*((volatile unsigned int *) 0x4002C284))      //D
+#define IOCON_P5_2           (*((volatile unsigned int *) 0x4002C288))      //I
+#define IOCON_P5_3           (*((volatile unsigned int *) 0x4002C28C))      //I
+#define IOCON_P5_4           (*((volatile unsigned int *) 0x4002C290))      //D
\ No newline at end of file
diff -r 000000000000 -r 2636b9dea739 LPC4088-system.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC4088-system.h	Sat May 02 17:17:05 2015 +0000
@@ -0,0 +1,3 @@
+//LPC4088 sistemski in clock registri
+
+#define PCONP             (*((volatile unsigned int *) 0x400FC0C4))
\ No newline at end of file
diff -r 000000000000 -r 2636b9dea739 main.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.c	Sat May 02 17:17:05 2015 +0000
@@ -0,0 +1,43 @@
+#include "LPC4088-ioconfig.h"
+#include "LPC4088-system.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);
+    
+    //vklop GPIO periferije (nepotrebno)
+    PCONP = PCONP | (1<<15);    
+
+    //nastavitev P1.13 kot output
+    DIR1 = DIR1 | (1<<13);
+    
+    //nastavitev P1.13 maske
+    MASK1 = MASK1 & !(1<<13);
+    
+    while(1){
+
+        //prizgemo P1.13 preko celotnega porta
+        PIN1 = PIN1 | (1<<13);
+        
+        delay();
+
+        //prizgemo P1.13 preko celotnega porta
+        PIN1 = PIN1 & !(1<<13);
+        
+        delay();
+        
+    }
+}
+
+
+void delay(void){
+    volatile int stej = 10000000;
+    while(stej){
+        stej = stej - 1;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 2636b9dea739 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat May 02 17:17:05 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file