Browse Source

sun_usb: Fix LED status update at startup

master
tmk 9 years ago
parent
commit
49b0c7e5ef
2 changed files with 17 additions and 0 deletions
  1. 2
    0
      converter/sun_usb/led.c
  2. 15
    0
      converter/sun_usb/matrix.c

+ 2
- 0
converter/sun_usb/led.c View File

#include "stdint.h" #include "stdint.h"
#include "serial.h" #include "serial.h"
#include "led.h" #include "led.h"
#include "debug.h"




void led_set(uint8_t usb_led) void led_set(uint8_t usb_led)
if (usb_led & (1<<USB_LED_COMPOSE)) sun_led |= (1<<1); if (usb_led & (1<<USB_LED_COMPOSE)) sun_led |= (1<<1);
if (usb_led & (1<<USB_LED_SCROLL_LOCK)) sun_led |= (1<<2); if (usb_led & (1<<USB_LED_SCROLL_LOCK)) sun_led |= (1<<2);
if (usb_led & (1<<USB_LED_CAPS_LOCK)) sun_led |= (1<<3); if (usb_led & (1<<USB_LED_CAPS_LOCK)) sun_led |= (1<<3);
xprintf("LED: %02X\n", usb_led);


serial_send(0x0E); serial_send(0x0E);
serial_send(sun_led); serial_send(sun_led);

+ 15
- 0
converter/sun_usb/matrix.c View File

// initialize matrix state: all keys off // initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;


// wait for keyboard coming up
// otherwise LED status update fails
print("Reseting ");
while (1) {
print(".");
while (serial_recv());
serial_send(0x01);
_delay_ms(500);
if (serial_recv() == 0xFF) {
_delay_ms(500);
if (serial_recv() == 0x04)
break;
}
}
print(" Done\n");
return; return;
} }