aboutsummaryrefslogtreecommitdiff
path: root/led.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-05-04 02:22:31 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-05-04 02:22:31 +0200
commitf29443cd40f9050beedab3a822b6e0f24fb789cd (patch)
tree5f53eb3d8c904af00f13d58976c8d6f04ba6339e /led.c
parentaf302afcb0aaa08bd9c093b2c8ff20647a001919 (diff)
downloadtmk7637-f29443cd40f9050beedab3a822b6e0f24fb789cd.tar.gz
optimized the LED and buzzer wiring
* since we use timer 3 exclusively for the buzzer but trigger the pin using an IRQ handler, there is no longer any need to occupy a high-resolution pin for the buzzer. * PD5 became a new high resolution LED * PD0 became the new buzzer pin * rearranged the pins used for the different LEDs so that the distribution of high-resolution LEDs is symmetric * Timer 0 is no longer used/modified by setting LEDs. This avoids some workarounds as timer 0 is also used by tmk's timer module. * The song routines could be slightly improved using the timer module. * documented the LED and buzzer pinout in README
Diffstat (limited to 'led.c')
-rw-r--r--led.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/led.c b/led.c
index c7e5933..0d92563 100644
--- a/led.c
+++ b/led.c
@@ -40,33 +40,28 @@ void led_set(uint8_t usb_led)
else
PORTD |= (1 << PD3);
- /*
- * 1st LED on first row (G00).
- *
- * NOTE: This will automatically disable PWM mode, so it will not
- * interfere with timer 0 and tmk's timer module.
- */
- pwm_pd0_set_led(usb_led & (1 << USB_LED_NUM_LOCK) ? 255 : 0);
+ /* 1st LED on first row (G00). */
+ pwm_pb5_set_led(usb_led & (1 << USB_LED_NUM_LOCK) ? 255 : 0);
/* 2nd LED on first row (G01): Highlight keyclick mode. */
- pwm_pb7_set_led(keyclick_mode*255/(KEYCLICK_MAX-1));
+ pwm_pd1_set_led(keyclick_mode*255/(KEYCLICK_MAX-1));
/* 3rd LED on the first row (G02) */
- pwm_pd1_set_led(usb_led & (1 << USB_LED_COMPOSE) ? 255 : 0);
+ pwm_pb7_set_led(usb_led & (1 << USB_LED_COMPOSE) ? 255 : 0);
/*
* 4th LED (G03) are currently not triggerable via USB.
* Could be triggered as the "backlight".
*/
- pwm_pb6_set_led(0);
+ pwm_pb4_set_led(0);
/* 5th LED on the first row (G04) */
- pwm_pb4_set_led(usb_led & (1 << USB_LED_SCROLL_LOCK) ? 255 : 0);
+ pwm_pb6_set_led(usb_led & (1 << USB_LED_SCROLL_LOCK) ? 255 : 0);
/*
* 6th LED on the first row (G53).
*
- * Triggering this LED (PD2) will also enable the buzzer (PB5),
+ * Triggering this LED (PD2) will also enable the buzzer (PD0),
* so we have got a way to beep from userspace (see ./k7637-beep.sh).
*
* The original firmware also had the error display on G53
@@ -74,9 +69,9 @@ void led_set(uint8_t usb_led)
*/
if (usb_led & (1 << USB_LED_KANA)) {
PORTD &= ~(1 << PD2);
- pwm_pb5_set_tone(2200);
+ pwm_pd0_set_tone(2200);
} else {
PORTD |= (1 << PD2);
- pwm_pb5_set_tone(0);
+ pwm_pd0_set_tone(0);
}
}