// *** CooCox Blinky ***
void BlinkExp();
int main(void)
{
//automatically added by CoIDE
BlinkExp();
while(1)
{
}
}
BlinkExp();
#include "lpc11xx_syscon.h"
#include "lpc11xx_gpio.h"
void BlinkExp()
{
int i, j;
/* Enable GPIO block clock */
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);
/* If PIO2_9 had been set to other function, set it to PIO function.
* NOTE: Component IOCON should be checked */
//IOCON_SetPinFunc(IOCON_PIO2_9, PIO2_9_FUN_PIO);
/* Set PIO2_9 as output. */
GPIO_SetDir(PORT2, GPIO_Pin_9, 1);
while(1) {
/* Delay some time */
for(i=0; i<20; i++) {
for(j=0; j<10000; j++) {
}
}
/* Output high level */
GPIO_SetBits(PORT2, GPIO_Pin_9);
/* Delay some time */
for(i=0; i<20; i++) {
for(j=0; j<10000; j++) {
}
}
/* Output low level */
GPIO_ResetBits(PORT2, GPIO_Pin_9);
}
}
GPIO: LPC11xx General Purpose I\O Driver
Overview
There are 4 GPIO ports (each port have 11 pins) and up to 42 General Purpose I/O pins. Each pins can be configured as input or output and can serve as an edge- or level- sensitive interrupt request. It is able to set GPIO bits without affecting any other pins in a single write operation.
Usage
If the GPIO block clock had been disabled, enable it using SYSCON_AHBPeriphClockCmd().
Set the pins as input or output using GPIO_SetDir().
For output pins, output 1 or 0 using GPIO_SetBits() or GPIO_ResetBits().
Using GPIO_ReadInput() to get input status.
Using GPIO_EventInit() to configure the pins as an edge- or level- sensitive interrupt request.
Enable the port interrupt in NVIC using GPIO_PortIntCmd(ENABLE).
Then when the interrupt condition is met, it will enter GPIO ISR.
Source files
lpc11xx_gpio.h
lpc11xx_gpio.c
Dependency
SYSCON
.END
No comments:
Post a Comment