1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
tmk_keyboard_custom/keyboard/ghpad/ledmap.c

74 lines
1.6 KiB
C
Raw Permalink Normal View History

#include <avr/pgmspace.h>
#include "ledmap.h"
#include "debug.h"
#ifdef LEDMAP_ENABLE
2014-11-25 09:46:18 +00:00
static const uint16_t ledmaps[LED_COUNT] PROGMEM = {
[0] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // LEDS1 - PB2
[1] = LEDMAP_BACKLIGHT, // LEDS6 - PF7
[2] = LEDMAP_BACKLIGHT, // LEDS11 - PF6
[3] = LEDMAP_BACKLIGHT, // LEDS16 - PF5
[4] = LEDMAP_BACKLIGHT, // PWM - PB5
};
2014-11-25 09:46:18 +00:00
ledmap_t ledmap_get_code(uint8_t index)
{
2014-11-25 09:46:18 +00:00
return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) };
}
void ledmap_led_init(void)
{
DDRB |= (1<<PB2);
PORTB |= (1<<PB2);
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
DDRB |= (1<<PB5);
PORTB &= ~(1<<PB5);
}
void ledmap_led_on(uint8_t index)
{
switch (index) {
case 0:
PORTB &= ~(1<<PB2);
break;
case 1:
PORTF &= ~(1<<PF7);
break;
case 2:
PORTF &= ~(1<<PF6);
break;
case 3:
PORTF &= ~(1<<PF5);
break;
case 4:
PORTB |= (1<<PB5);
break;
}
}
void ledmap_led_off(uint8_t index)
{
switch (index) {
case 0:
PORTB |= (1<<PB2);
break;
case 1:
PORTF |= (1<<PF7);
break;
case 2:
PORTF |= (1<<PF6);
break;
case 3:
PORTF |= (1<<PF5);
break;
case 4:
PORTB &= ~(1<<PB5);
break;
}
}
#endif