Simple PWM test : RGB Led The color changes according to the data received on serial...
authorNathael Pajani <nathael.pajani@ed3l.fr>
Thu, 7 Nov 2013 02:06:06 +0000 (03:06 +0100)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:04 +0000 (17:03 +0100)
drivers/serial.c

index 612856e..5a1ee3a 100644 (file)
@@ -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) {