EmbeddedRelated.com
Forums

LPC17xx.n header file Questions

Started by hrh1818 May 31, 2010
The following code snippet comes from an
example that came with a development board.

// Set GPIO - P1_24, P1_25, P1_28, P1_29 - to be outputs
LPC_GPIO1->FIODIR |= LED_ALL;

LPC17xx.h contains the following #define
#define LPC_GPIO1 ((LPC_GPIO_TypeDef *) LPC_GPIO1_BASE )

What is the meaning of " * " in this context. Multiplying
a type definition by a memory address has me mystified. Is it
possible * is the symbol meaning pointer in this context?

Are there any Web Sites that explain how to use a complicated
header file like LPC17xx.h? Usage examples are nice but I am
hoping to find something that speeds up the learning process.

Howard
The following information is provided for those who need to
see the full macro definitions.

The definition of LPC_GPIO_TypeDef is provided at the end
of this message. It was placed there because of its length and
it was interfering with the readability of this message.

LPC_GPI01_BASE is defined by the following #define in LPC17xx.h
#define LPC_GPIO1_BASE (LPC_GPIO_BASE + 0x00020)

LPC_GPIO_BASE is defined by the following #define in LPC17xx.h
#define LPC_GPIO_BASE (0x2009C000UL)

LED_ALL is defined by the following #define in
a .h header file that comes with the example.
#define LED_ALL (LED_2 | LED_3 | LED_4 | LED_5)

// LED_2, LED_3, LED_4 and LED_5 are defined as
// Led 2 is P1_24
#define LED_2 (1 << 24)
// Led 3 is P1_25
#define LED_3 (1 << 25)
// Led 4 is P1_28
#define LED_4 (1 << 28)
// Led 5 is P1_29
#define LED_5 (1 << 29)

// The following is the typedef for LPC_GPIO_TypeDef
typedef struct
{
union {
__IO uint32_t FIODIR;
struct {
__IO uint16_t FIODIRL;
__IO uint16_t FIODIRH;
};
struct {
__IO uint8_t FIODIR0;
__IO uint8_t FIODIR1;
__IO uint8_t FIODIR2;
__IO uint8_t FIODIR3;
};
};
uint32_t RESERVED0[3];
union {
__IO uint32_t FIOMASK;
struct {
__IO uint16_t FIOMASKL;
__IO uint16_t FIOMASKH;
};
struct {
__IO uint8_t FIOMASK0;
__IO uint8_t FIOMASK1;
__IO uint8_t FIOMASK2;
__IO uint8_t FIOMASK3;
};
};
union {
__IO uint32_t FIOPIN;
struct {
__IO uint16_t FIOPINL;
__IO uint16_t FIOPINH;
};
struct {
__IO uint8_t FIOPIN0;
__IO uint8_t FIOPIN1;
__IO uint8_t FIOPIN2;
__IO uint8_t FIOPIN3;
};
};
union {
__IO uint32_t FIOSET;
struct {
__IO uint16_t FIOSETL;
__IO uint16_t FIOSETH;
};
struct {
__IO uint8_t FIOSET0;
__IO uint8_t FIOSET1;
__IO uint8_t FIOSET2;
__IO uint8_t FIOSET3;
};
};
union {
__O uint32_t FIOCLR;
struct {
__O uint16_t FIOCLRL;
__O uint16_t FIOCLRH;
};
struct {
__O uint8_t FIOCLR0;
__O uint8_t FIOCLR1;
__O uint8_t FIOCLR2;
__O uint8_t FIOCLR3;
};
};
} LPC_GPIO_TypeDef;

An Engineer's Guide to the LPC2100 Series

Hello hrh1818,

Monday, May 31, 2010, 5:28:17 PM, you wrote:

h> LPC17xx.h contains the following #define
h> #define LPC_GPIO1 ((LPC_GPIO_TypeDef *) LPC_GPIO1_BASE )
h> What is the meaning of " * " in this context. Multiplying
h> a type definition by a memory address has me mystified. Is it
h> possible * is the symbol meaning pointer in this context?

Sounds like you need to read up on pointers in C.

--
WBR,
Igor mailto:s...@mail.ru