Content originally posted in LPCWare by arthemuz@hotmail.com on Thu Jan 09 10:15:19 MST 2014
#include "driver_config.h"
#include "target_config.h"
#include "timer32.h"
#include "gpio.h"
#include "uart.h"
#include <string.h>
extern volatile uint32_t UARTCount;
extern volatile uint8_t UARTBuffer[BUFSIZE];
int main (void)
{
UARTInit(UART_BAUD);
#if MODEM_TEST
ModemInit();
#endif
int i = 0, on=0;
/* Basic chip initialization is taken care of in SystemInit() called
* from the startup code. SystemInit() and chip settings are defined
* in the CMSIS system_<part family>.c file.
*/
/* Initialize 32-bit timer 0. TIME_INTERVAL is defined as 10mS */
/* You may also want to use the Cortex SysTick timer to do this */
init_timer32(0, TIME_INTERVAL);
/* Enable timer 0. Our interrupt handler will begin incrementing
* the TimeTick global each time timer 0 matches and resets.
*/
enable_timer32(0);
/* Initialize GPIO (sets up clock) */
GPIOInit();
/* Set LED port pin to output */
GPIOSetDir( LED_PORT, LED_BIT, 1 );
//Init7Segment();
while (1) /* Loop forever */
{
/* Each time we wake up... */
/* Check TimeTick to see whether to set or clear the LED I/O pin */
if ( (timer32_0_counter%(LED_TOGGLE_TICKS/COUNT_MAX)) < ((LED_TOGGLE_TICKS/COUNT_MAX)/2) )
{
GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
on=0;
} else
{
GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
if(!on)
{
i++;
}
on=1;
const char* welcomeMsg = "UART3 Online:\r\n";
//SystemInit();//Called by startup code
LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
UARTSend((uint8_t *)welcomeMsg , strlen(welcomeMsg) );
LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
if ( UARTCount != 0 )
{
LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
UARTSend( (uint8_t *)UARTBuffer, UARTCount );
UARTCount = 0;
LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
}
}
/* Go to sleep to save power between timer interrupts */
__WFI();
}
}