Blink WHUT Board PIO1_8 LED tested OK.
// ***********************************************************************
// Program - Fong Blink02
// Function - Blink LED
// Author - TL Fong
// Build - 2013.08.20.01
// Date - 2013aug20hkt1040
// Hardware - LPC1114/301, LPC1114/102,
// Software - GCC ARM 4.7, CoIDE 1.7.4, CoLinkEx 1.1, Flash Magic v7.51
// ***********************************************************************
#include "lpc11xx_syscon.h"
#include "lpc11xx_gpio.h"
#include "lpc11xx_iocon.h"
// ***********************************************************************
// Constants definition
// ***********************************************************************
#define HIGH_LEVEL 1
#define LOW_LEVEL 0
#define OUTPUT_DIRECTION 1
#define INPUT_DIRECTION 0
// ***********************************************************************
// Functions
// ***********************************************************************
void systemInitialization();
void delayTenthSecond(int count);
void setPio05Direction(int direction);
void setPio05OutputHigh();
void setPio05OutputLow();
void setPio18Output(int logicLevel);
void setPio18Direction(int direction);
void setPio18OutputHigh();
void setPio18OutputLow();
void setPio18Output(int logicLevel);
// ***********************************************************************
// Main function
// ***********************************************************************
void FongBlink02() // Blink WHUT Board PIO1_8 LED
{
systemInitialization();
// setPio05Direction(OUTPUT_DIRECTION);
setPio18Direction(OUTPUT_DIRECTION);
while(1)
{
//setPio05Output(LOW_LEVEL);
setPio18Output(LOW_LEVEL);
delayTenthSecond(2);
// setPio05Output(HIGH_LEVEL);
setPio18Output(HIGH_LEVEL);
delayTenthSecond(10);
}
}
// ***********************************************************************
// Delay functions
// ***********************************************************************
void delayTenthSecond(int count)
{
int i, j, k;
for (i = 0; i < count; i++)
{
for (j = 0; j < 0x4; j++)
{
for (k = 0; k < 0x000BB00; k++)
{
}
}
}
}
// ***********************************************************************
// System initialization functions
// ***********************************************************************
void systemInitialization()
{
/* Enable GPIO block clock */
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);
}
// ***********************************************************************
// GPIO functions
// ***********************************************************************
// *** PIO0_5 ***
void setPio05Direction(int direction)
{
/* Set pin to GPIO */
IOCON_SetPinFunc(IOCON_PIO0_5, PIO0_5_FUN_PIO);
/* Set pin direction */
if (direction == OUTPUT_DIRECTION)
GPIO_SetDir(PORT0, GPIO_Pin_5, 1);
else
GPIO_SetDir(PORT0, GPIO_Pin_5, 0);
}
void setPio05OutputHigh()
{
GPIO_SetBits(PORT0, GPIO_Pin_5);
}
void setPio05OutputLow()
{
GPIO_ResetBits(PORT0, GPIO_Pin_5);
}
void setPio05Output(int logicLevel)
{
if (logicLevel == HIGH_LEVEL)
GPIO_SetBits(PORT0, GPIO_Pin_5);
else
GPIO_ResetBits(PORT0, GPIO_Pin_5);
}
// *** PIO1_8 ***
void setPio18Direction(int direction)
{
/* Set pin to GPIO */
IOCON_SetPinFunc(IOCON_PIO1_8, PIO1_8_FUN_PIO);
/* Set pin direction */
if (direction == OUTPUT_DIRECTION)
GPIO_SetDir(PORT1, GPIO_Pin_8, 1);
else
GPIO_SetDir(PORT1, GPIO_Pin_8, 0);
}
void setPio18OutputHigh()
{
GPIO_SetBits(PORT1, GPIO_Pin_8);
}
void setPio18OutputLow()
{
GPIO_ResetBits(PORT1, GPIO_Pin_8);
}
void setPio18Output(int logicLevel)
{
if (logicLevel == HIGH_LEVEL)
GPIO_SetBits(PORT1, GPIO_Pin_8);
else
GPIO_ResetBits(PORT1, GPIO_Pin_8);
}
// ***********************************************************************
// End
// ***********************************************************************
No comments:
Post a Comment