Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] developing a library for gpio lpc1768

Status
Not open for further replies.

h.galeh

Member level 3
Joined
Apr 16, 2008
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Tehran, Iran, Iran
Activity points
1,690
I am defining a library for gpio easeing work . so that you can program micro as easy as possible without hardware challenge
but its macros has problems
please help to make it



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __GPIO_H
#define __GPIO_H
//////////////////////////////////////////////////////////////////
#define PORT0 1
#define PORT1 2
#define PORT2 3
#define PORT3 4
#define PORT4 5
//////////////////////////////////////////////////////////////////
 
#define PIN(n) (1UL<<n)
 
 
//////////////////////////////////////////////////////////////////      
 
#define SELECT_PORT(n)  
    #if n==PORT0
        #define PORT             ((LPC_GPIO_TypeDef      *) LPC_GPIO0_BASE    )
    #elif n==PORT1                  
        #define PORT             ((LPC_GPIO_TypeDef      *) LPC_GPIO1_BASE    )
    #elif   n==PORT2                
        #define PORT             ((LPC_GPIO_TypeDef      *) LPC_GPIO2_BASE    ) 
    #elif n==PORT3                  
        #define PORT             ((LPC_GPIO_TypeDef      *) LPC_GPIO3_BASE    )
    #elif n==PORT4                  
        #define PORT             ((LPC_GPIO_TypeDef      *) LPC_GPIO4_BASE    ) 
    #endif 
 
 
//////////////////////////////////////////////////////////////
 
                            
 
 
 
/////////////////////////////////////////////////////////////
   #ifdef PORT
    #define KEY(n) {((PORT->FIOPIN&PIN(n)) == PIN(n))}
    #define SET(n) {PORT->FIOSET = PIN(n)             }
    #define CLR(n) {PORT->FIOCLR = PIN(n)             }
    #define CONFIG_OUT(n) {PORT->FIODIR= PORT->(FIODIR|PIN(n))}
    #define CONFIG_IN(n) {PORT->FIODIR= (PORT->FIODIR&~PIN(n))}
  #endif
 
#endif

 
Last edited by a moderator:

it is not necessary to make a library for it
since CMSIS is a complete set of codes available for configuring pripherials
to use it
go to examples of IAR or keil
refer to CMSIS folder
folder named "driver" is its library there.
you can freely add it anywhere inside your code
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top