From: Jan Michel Date: Mon, 23 Jan 2017 11:05:57 +0000 (+0100) Subject: fixes & more LED for DAQi X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=cd44acff1472f2507e20c664a48665c8e167328c;p=avr.git fixes & more LED for DAQi --- diff --git a/atmega32u4/daqi/daqi.c b/atmega32u4/daqi/daqi.c index 0d99a42..9c1bd67 100644 --- a/atmega32u4/daqi/daqi.c +++ b/atmega32u4/daqi/daqi.c @@ -15,20 +15,22 @@ uint8_t buffer[BUFFERSIZE]; uint8_t pointer = 0; -uint8_t red[NUM_LEDS] = {0xff}; -uint8_t green[NUM_LEDS] = {0xff}; -uint8_t blue[NUM_LEDS] = {0xff}; +uint8_t red[NUM_LEDS] = {0x06,0x06,0x06,0x06,0x06}; +uint8_t green[NUM_LEDS] = {0x09,0x09,0x09,0x09,0x09}; +uint8_t blue[NUM_LEDS] = {0x10,0x10,0x10,0x10,0x10}; void init(void) { LED_RGB_OUT(); LED_RGB_LOW(); + DDRD |= (1<= '0' && c<='9') return c-'0'; if(c >= 'a' && c<='f') return c-'a'+10; if(c >= 'A' && c<='F') return c-'A'+10; return -1; } -uint8_t configuration_led(char* h) { +uint8_t configuration_led(uint8_t* h) { uint8_t l = hex2int(*h); red[l] = hex2int(*(h+1))*16+hex2int(*(h+2)); green[l] = hex2int(*(h+3))*16+hex2int(*(h+4)); @@ -76,21 +79,24 @@ uint8_t configuration_led(char* h) { __attribute__((naked)) int main(void) { init(); usb_init(); + led_update(); while (1) { int n = usb_serial_getchar(); if (n >= 0) { buffer[pointer++] = n; + usb_serial_putchar_nowait(n); if(pointer>BUFFERSIZE) { pointer = 0; } - if(n == 10) { - if(pointer >= 9 && buffer[0] == '#') { - configuration_led(buffer+1); - } + if(pointer >= 8 && buffer[0] == '#') { + configuration_led(buffer+1); pointer = 0; } } + if (n == 0x0a || n == 0x0d || buffer[0] != '#') { + pointer = 0; + } } } diff --git a/atmega32u4/daqi/usb_serial.c b/atmega32u4/daqi/usb_serial.c index 2c12a9c..7b79e00 100644 --- a/atmega32u4/daqi/usb_serial.c +++ b/atmega32u4/daqi/usb_serial.c @@ -60,7 +60,7 @@ // Udev rules (in /etc/udev/rules.d) can define persistent device // names linked to this serial number, as well as permissions, owner // and group settings. -#define STR_SERIAL_NUMBER L"00001" +#define STR_SERIAL_NUMBER L"00002" // Mac OS-X and Linux automatically load the correct drivers. On // Windows, even though the driver is supplied by Microsoft, an