diff options
author | tmk <nobody@nowhere> | 2012-10-21 22:12:36 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2012-10-21 22:12:36 +0900 |
commit | edce1d19a6af040df994243e7b6b1851e3eccebc (patch) | |
tree | 3f8d385a39979dcabdefea019e9671503cda8eba /converter/sun_usb | |
parent | 454f7bc71657020d0574e849dad92a14e71230c4 (diff) | |
download | qmk_firmware-edce1d19a6af040df994243e7b6b1851e3eccebc.tar.gz qmk_firmware-edce1d19a6af040df994243e7b6b1851e3eccebc.zip |
Add LED feature to Sun converter
Diffstat (limited to 'converter/sun_usb')
-rw-r--r-- | converter/sun_usb/config.h | 17 | ||||
-rw-r--r-- | converter/sun_usb/led.c | 10 |
2 files changed, 25 insertions, 2 deletions
diff --git a/converter/sun_usb/config.h b/converter/sun_usb/config.h index 66961d9330..b4f0ff977a 100644 --- a/converter/sun_usb/config.h +++ b/converter/sun_usb/config.h @@ -43,8 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. * asynchronous, negative logic, 1200baud, no flow control * 1-start bit, 8-data bit, non parity, 1-stop bit */ -#define SERIAL_NEGATIVE_LOGIC #define SERIAL_BAUD 1200 + #define SERIAL_RXD_DDR DDRD #define SERIAL_RXD_PORT PORTD #define SERIAL_RXD_PIN PIND @@ -63,5 +63,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* clear interrupt flag */ \ EIFR = (1<<INTF2); \ } while (0) +#define SERIAL_RXD_READ() (~SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT)) + +#define SERIAL_TXD_DDR DDRD +#define SERIAL_TXD_PORT PORTD +#define SERIAL_TXD_PIN PIND +#define SERIAL_TXD_BIT 3 +/* negative logic */ +#define SERIAL_TXD_ON() do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0) +#define SERIAL_TXD_OFF() do { SERIAL_TXD_PORT |= (1<<SERIAL_TXD_BIT); } while (0) +#define SERIAL_TXD_INIT() do { \ + /* pin configuration: output */ \ + SERIAL_TXD_DDR |= (1<<SERIAL_TXD_BIT); \ + /* idle */ \ + SERIAL_TXD_ON(); \ +} while (0) #endif diff --git a/converter/sun_usb/led.c b/converter/sun_usb/led.c index 5490ec0c62..48c3f1c2b2 100644 --- a/converter/sun_usb/led.c +++ b/converter/sun_usb/led.c @@ -16,10 +16,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "stdint.h" +#include "serial.h" #include "led.h" void led_set(uint8_t usb_led) { - // not supported now + uint8_t sun_led = 0; + if (usb_led & (1<<USB_LED_NUM_LOCK)) sun_led |= (1<<0); + 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_CAPS_LOCK)) sun_led |= (1<<3); + + serial_send(0x0E); + serial_send(sun_led); } |