From e3fc4f7feaa8efee8983cba4890b04db08a8e71a Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 7 Nov 2013 03:06:06 +0100 Subject: [PATCH] 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 --- drivers/serial.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) { -- 2.43.0