From: Nathael Pajani Date: Thu, 7 Nov 2013 02:06:06 +0000 (+0100) Subject: Simple PWM test : RGB Led The color changes according to the data received on serial... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=e3fc4f7feaa8efee8983cba4890b04db08a8e71a;p=soft%2Flpc122x%2Fcore Simple PWM test : RGB Led The color changes according to the data received on serial line Note that 0.0.0 is white while black is at 200.200.200 --- diff --git a/drivers/serial.c b/drivers/serial.c index 612856e..5a1ee3a 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -30,6 +30,7 @@ #include "core/lpc_core_cm0.h" #include "core/system.h" #include "lib/string.h" +#include "drivers/timers.h" #define SERIAL_OUT_BUFF_SIZE 64 struct uart_device @@ -76,9 +77,15 @@ static void UART_Handler(struct uart_device* uart) uint32_t intr = uart->regs->func.intr_pending; if ((intr & LPC_UART_INT_MASK) == LPC_UART_INT_RX) { + static int i = 0; uint8_t data = uart->regs->func.buffer; /* Echo */ uart->regs->func.buffer = data; + /* Change RGB Led color */ + timer_set_match(LPC_TIMER_32B1, i++, data); + if (i > 2) { + i = 0; + } } /* We are currently sending, send next char */ if ((intr & LPC_UART_INT_MASK) == LPC_UART_INT_TX) {