Convert some AVR GPIO operations to macros (#23424)

This commit is contained in:
Ryan 2024-05-02 19:48:49 +10:00 committed by GitHub
parent 7220715dd1
commit 61c7c1f74c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
71 changed files with 877 additions and 840 deletions

View File

@ -25,16 +25,14 @@ bool led_update_kb(led_t led_state)
if (res) {
if (led_state.caps_lock) {
// output low
DDRB |= (1<<0);
PORTB &= ~(1<<0);
DDRD |= (1<<5);
PORTD &= ~(1<<5);
gpio_set_pin_output(B0);
gpio_write_pin_low(B0);
gpio_set_pin_output(D5);
gpio_write_pin_low(D5);
} else {
// Hi-Z
DDRB &= ~(1<<0);
PORTB &= ~(1<<0);
DDRD &= ~(1<<5);
PORTD &= ~(1<<5);
gpio_set_pin_input(B0);
gpio_set_pin_input(D5);
}
}
return false;

View File

@ -126,14 +126,18 @@ void matrix_print(void)
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
PORTF |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
DDRE &= ~(1<<6);
PORTE |= (1<<6);
DDRD &= ~(1<<7);
PORTD |= (1<<7);
DDRB &= ~(1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6);
PORTB |= (1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6);
gpio_set_pin_input_high(F4);
gpio_set_pin_input_high(F5);
gpio_set_pin_input_high(F6);
gpio_set_pin_input_high(F7);
gpio_set_pin_input_high(E6);
gpio_set_pin_input_high(D7);
gpio_set_pin_input_high(B1);
gpio_set_pin_input_high(B2);
gpio_set_pin_input_high(B3);
gpio_set_pin_input_high(B4);
gpio_set_pin_input_high(B5);
gpio_set_pin_input_high(B6);
}
static matrix_row_t read_cols(void)
@ -160,10 +164,10 @@ static matrix_row_t read_cols(void)
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00010011;
PORTD &= ~0b00010011;
DDRC &= ~0b01000000;
PORTC &= ~0b01000000;
gpio_set_pin_input(C6);
gpio_set_pin_input(D0);
gpio_set_pin_input(D1);
gpio_set_pin_input(D4);
}
static void select_row(uint8_t row)
@ -171,20 +175,20 @@ static void select_row(uint8_t row)
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<1);
PORTD &= ~(1<<1);
gpio_set_pin_output(D1);
gpio_write_pin_low(D1);
break;
case 1:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
gpio_set_pin_output(D0);
gpio_write_pin_low(D0);
break;
case 2:
DDRD |= (1<<4);
PORTD &= ~(1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_low(D4);
break;
case 3:
DDRC |= (1<<6);
PORTC &= ~(1<<6);
gpio_set_pin_output(C6);
gpio_write_pin_low(C6);
break;
}
}

View File

@ -65,8 +65,8 @@ void matrix_init(void)
#endif
// 85 REST
DDRD |= _BV(PD7);
PORTD |= _BV(PD7);
gpio_set_pin_output(D7);
gpio_write_pin_high(D7);
// initialize row and col
init_rows();
@ -143,36 +143,35 @@ static void init_cols(void)
DDRD &= 0b00011100;
PORTD |= 0b11100011;
DDRB &= ~(_BV(PB6) | _BV(PB7)| _BV(PB0));
PORTB |= (_BV(PB6) | _BV(PB7)| _BV(PB0));
gpio_set_pin_input_high(B0);
gpio_set_pin_input_high(B6);
gpio_set_pin_input_high(B7);
DDRE &= ~_BV(PE6);
PORTE |= _BV(PE6);
gpio_set_pin_input_high(E6);
DDRC &= ~_BV(PC7);
PORTC |= _BV(PC7);
gpio_set_pin_input_high(C7);
}
static matrix_row_t read_cols(void)
{
return (PINF&_BV(PF7) ? 0 : (1<<0)) |
(PINF&_BV(PF6) ? 0 : (1<<1)) |
(PINF&_BV(PF5) ? 0 : (1<<2)) |
(PINF&_BV(PF4) ? 0 : (1<<3)) |
(PINF&_BV(PF1) ? 0 : (1<<4)) |
(PINF&_BV(PF0) ? 0 : (1<<5)) |
(PINE&_BV(PE6) ? 0 : (1<<6)) |
(PIND&_BV(PD7) ? 0 : (1<<7)) |
(PIND&_BV(PD6) ? 0 : (1<<8)) |
(PIND&_BV(PD5) ? 0 : (1<<9)) |
(PIND&_BV(PD1) ? 0 : (1<<10)) |
(PIND&_BV(PD0) ? 0 : (1<<11)) |
(PINB&_BV(PB7) ? 0 : (1<<12)) |
(PINB&_BV(PB6) ? 0 : (1<<13)) |
(PINB&_BV(PB0) ? 0 : (1<<14)) |
(PINC&_BV(PC7) ? 0 : (1<<15));
return (gpio_read_pin(F7) ? 0 : (1<<0)) |
(gpio_read_pin(F6) ? 0 : (1<<1)) |
(gpio_read_pin(F5) ? 0 : (1<<2)) |
(gpio_read_pin(F4) ? 0 : (1<<3)) |
(gpio_read_pin(F1) ? 0 : (1<<4)) |
(gpio_read_pin(F0) ? 0 : (1<<5)) |
(gpio_read_pin(E6) ? 0 : (1<<6)) |
(gpio_read_pin(D7) ? 0 : (1<<7)) |
(gpio_read_pin(D6) ? 0 : (1<<8)) |
(gpio_read_pin(D5) ? 0 : (1<<9)) |
(gpio_read_pin(D1) ? 0 : (1<<10)) |
(gpio_read_pin(D0) ? 0 : (1<<11)) |
(gpio_read_pin(B7) ? 0 : (1<<12)) |
(gpio_read_pin(B6) ? 0 : (1<<13)) |
(gpio_read_pin(B0) ? 0 : (1<<14)) |
(gpio_read_pin(C7) ? 0 : (1<<15));
}
/* Row pin configuration
@ -184,21 +183,23 @@ static matrix_row_t read_cols(void)
static void init_rows(void)
{
DDRB |= (1<<PB1 | 1<<PB2 | 1<<PB3);
gpio_set_pin_input(B1);
gpio_set_pin_input(B2);
gpio_set_pin_input(B3);
}
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
PORTB |= (1<<PB1);
PORTB |= (1<<PB2);
PORTB |= (1<<PB3);
gpio_write_pin_high(B1);
gpio_write_pin_high(B2);
gpio_write_pin_high(B3);
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
(row & (1<<0)) ? (PORTB |= (1<<PB3)) : (PORTB &= ~(1<<PB3));
(row & (1<<1)) ? (PORTB |= (1<<PB2)) : (PORTB &= ~(1<<PB2));
(row & (1<<2)) ? (PORTB |= (1<<PB1)) : (PORTB &= ~(1<<PB1));
gpio_write_pin(B3, row & (1<<0));
gpio_write_pin(B2, row & (1<<1));
gpio_write_pin(B1, row & (1<<2));
}

View File

@ -54,15 +54,13 @@ void matrix_init_kb(void) {
TCCR1B = 0b00001001; // set and configure fast PWM
// (tied to Vcc for hardware convenience)
DDRB &= ~(1<<4); // set B(4) as input
PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled
// unused pins - D4, D5, E6
// set as input with internal pull-up enabled
DDRD &= ~(1<<5 | 1<<4);
DDRE &= ~(1<<6);
PORTD |= (1<<5 | 1<<4);
PORTE |= (1<<6);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(E6);
keyboard_config.raw = eeconfig_read_kb();
bajjak_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );

View File

@ -2,19 +2,56 @@
#include "quantum.h"
inline void sixshooter_led_0_on(void) { DDRB |= (1<<6); PORTB |= (1<<6); }
inline void sixshooter_led_1_on(void) { DDRC |= (1<<7); PORTC |= (1<<7); }
inline void sixshooter_led_2_on(void) { DDRD |= (1<<0); PORTD |= (1<<0); }
inline void sixshooter_led_3_on(void) { DDRB |= (1<<5); PORTB |= (1<<5); }
inline void sixshooter_led_4_on(void) { DDRD |= (1<<7); PORTD |= (1<<7); }
inline void sixshooter_led_5_on(void) { DDRB |= (1<<7); PORTB |= (1<<7); }
#define SIXSHOOTER_LED_0_PIN B6
#define SIXSHOOTER_LED_1_PIN C7
#define SIXSHOOTER_LED_2_PIN D0
#define SIXSHOOTER_LED_3_PIN B5
#define SIXSHOOTER_LED_4_PIN D7
#define SIXSHOOTER_LED_5_PIN B7
inline void sixshooter_led_0_off(void) { DDRB &= ~(1<<6); PORTB &= ~(1<<6); }
inline void sixshooter_led_1_off(void) { DDRC &= ~(1<<7); PORTC &= ~(1<<7); }
inline void sixshooter_led_2_off(void) { DDRD &= ~(1<<0); PORTD &= ~(1<<0); }
inline void sixshooter_led_3_off(void) { DDRB &= ~(1<<5); PORTB &= ~(1<<5); }
inline void sixshooter_led_4_off(void) { DDRD &= ~(1<<7); PORTD &= ~(1<<7); }
inline void sixshooter_led_5_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); }
inline void sixshooter_led_0_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_0_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_0_PIN);
}
inline void sixshooter_led_1_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_1_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_1_PIN);
}
inline void sixshooter_led_2_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_2_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_2_PIN);
}
inline void sixshooter_led_3_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_3_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_3_PIN);
}
inline void sixshooter_led_4_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_4_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_4_PIN);
}
inline void sixshooter_led_5_on(void) {
gpio_set_pin_output(SIXSHOOTER_LED_5_PIN);
gpio_write_pin_high(SIXSHOOTER_LED_5_PIN);
}
inline void sixshooter_led_0_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_0_PIN);
}
inline void sixshooter_led_1_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_1_PIN);
}
inline void sixshooter_led_2_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_2_PIN);
}
inline void sixshooter_led_3_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_3_PIN);
}
inline void sixshooter_led_4_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_4_PIN);
}
inline void sixshooter_led_5_off(void) {
gpio_set_pin_input(SIXSHOOTER_LED_5_PIN);
}
inline void sixshooter_led_all_on(void) {
sixshooter_led_0_on();

View File

@ -4,8 +4,8 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
// Turn status LED on
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
matrix_init_user();
}

View File

@ -4,26 +4,26 @@
void backlight_init_ports(void) {
print("init_backlight_pin()\n");
// Set our LED pins as output
DDRD |= (1<<6); // Esc
DDRB |= (1<<7); // Page Up
DDRD |= (1<<4); // Arrows
gpio_set_pin_output(D6); // Esc
gpio_set_pin_output(B7); // Page Up
gpio_set_pin_output(D4); // Arrows
// Set our LED pins low
PORTD &= ~(1<<6); // Esc
PORTB &= ~(1<<7); // Page Up
PORTD &= ~(1<<4); // Arrows
gpio_write_pin_low(D6); // Esc
gpio_write_pin_low(B7); // Page Up
gpio_write_pin_low(D4); // Arrows
}
void backlight_set(uint8_t level) {
if ( level == 0 ) {
// Turn off light
PORTD |= (1<<6); // Esc
PORTB |= (1<<7); // Page Up
PORTD |= (1<<4); // Arrows
gpio_write_pin_high(D6); // Esc
gpio_write_pin_high(B7); // Page Up
gpio_write_pin_high(D4); // Arrows
} else {
// Turn on light
PORTD &= ~(1<<6); // Esc
PORTB &= ~(1<<7); // Page Up
PORTD &= ~(1<<4); // Arrows
gpio_write_pin_low(D6); // Esc
gpio_write_pin_low(B7); // Page Up
gpio_write_pin_low(D4); // Arrows
}
}

View File

@ -4,26 +4,26 @@
void backlight_init_ports(void) {
print("init_backlight_pin()\n");
// Set our LED pins as output
DDRD |= (1<<6); // Esc
DDRB |= (1<<7); // Page Up
DDRD |= (1<<4); // Arrows
gpio_set_pin_output(D6); // Esc
gpio_set_pin_output(B7); // Page Up
gpio_set_pin_output(D4); // Arrows
// Set our LED pins low
PORTD &= ~(1<<6); // Esc
PORTB &= ~(1<<7); // Page Up
PORTD &= ~(1<<4); // Arrows
gpio_write_pin_low(D6); // Esc
gpio_write_pin_low(B7); // Page Up
gpio_write_pin_low(D4); // Arrows
}
void backlight_set(uint8_t level) {
if ( level == 0 ) {
// Turn off light
PORTD |= (1<<6); // Esc
PORTB |= (1<<7); // Page Up
PORTD |= (1<<4); // Arrows
gpio_write_pin_high(D6); // Esc
gpio_write_pin_high(B7); // Page Up
gpio_write_pin_high(D4); // Arrows
} else {
// Turn on light
PORTD &= ~(1<<6); // Esc
PORTB &= ~(1<<7); // Page Up
PORTD &= ~(1<<4); // Arrows
gpio_write_pin_low(D6); // Esc
gpio_write_pin_low(B7); // Page Up
gpio_write_pin_low(D4); // Arrows
}
}

View File

@ -4,26 +4,26 @@
void backlight_init_ports(void) {
print("init_backlight_pin()\n");
// Set our LED pins as output
DDRD |= (1<<0); // Esc
DDRD |= (1<<4); // Page Up
DDRD |= (1<<1); // Arrows
gpio_set_pin_output(D0); // Esc
gpio_set_pin_output(D4); // Page Up
gpio_set_pin_output(D1); // Arrows
// Set our LED pins low
PORTD &= ~(1<<0); // Esc
PORTD &= ~(1<<4); // Page Up
PORTD &= ~(1<<1); // Arrows
gpio_write_pin_low(D0); // Esc
gpio_write_pin_low(D4); // Page Up
gpio_write_pin_low(D1); // Arrows
}
void backlight_set(uint8_t level) {
if ( level == 0 ) {
// Turn off light
PORTD |= (1<<0); // Esc
PORTD |= (1<<4); // Page Up
PORTD |= (1<<1); // Arrows
gpio_write_pin_high(D0); // Esc
gpio_write_pin_high(D4); // Page Up
gpio_write_pin_high(D1); // Arrows
} else {
// Turn on light
PORTD &= ~(1<<0); // Esc
PORTD &= ~(1<<4); // Page Up
PORTD &= ~(1<<1); // Arrows
gpio_write_pin_low(D0); // Esc
gpio_write_pin_low(D4); // Page Up
gpio_write_pin_low(D1); // Arrows
}
}

View File

@ -82,17 +82,17 @@ void matrix_scan_user(void) {
// switch, and then into the diode, then into one of the columns into the
// matrix. the reset pin can be used to reset the entire counter.
#define RESET _BV(PB0)
#define SCLK _BV(PB1)
#define SDATA _BV(PB3)
#define LED _BV(PD6)
#define HP_46010A_RESET_PIN B0
#define HP_46010A_SCLK_PIN B1
#define HP_46010A_SDATA_PIN B3
#define HP_46010A_LED_PIN D6
inline
static
void SCLK_increment(void) {
PORTB &= ~SCLK ;
gpio_write_pin_low(HP_46010A_SCLK_PIN);
_delay_us( 4 ) ; // make sure the line is stable
PORTB |= SCLK ;
gpio_write_pin_high(HP_46010A_SCLK_PIN);
_delay_us( 4 ) ;
return ;
@ -101,9 +101,9 @@ void SCLK_increment(void) {
inline
static
void Matrix_Reset(void) {
PORTB |= RESET ;
gpio_write_pin_high(HP_46010A_RESET_PIN);
_delay_us( 4 ) ; // make sure the line is stable
PORTB &= ~RESET ;
gpio_write_pin_low(HP_46010A_RESET_PIN);
return ;
}
@ -116,7 +116,7 @@ uint8_t Matrix_ReceiveByte (void) {
for ( uint8_t bit = 0; bit < MATRIX_COLS; ++bit ) {
// toggle the clock
SCLK_increment();
temp = (PINB & SDATA) << 4 ;
temp = gpio_read_pin(HP_46010A_SDATA_PIN) << 4 ;
received |= temp >> bit ;
}
@ -138,18 +138,19 @@ void Matrix_ThrowByte(void) {
void matrix_init (void) {
// debug_matrix = 1;
// PB0 (SS) and PB1 (SCLK) set to outputs
DDRB |= RESET | SCLK ;
gpio_set_pin_output(HP_46010A_RESET_PIN);
gpio_set_pin_output(HP_46010A_SCLK_PIN);
// PB2, is unused, and PB3 is our serial input
DDRB &= ~SDATA ;
gpio_set_pin_input(HP_46010A_SDATA_PIN);
// SS is reset for this board, and is active High
// SCLK is the serial clock and is active High
PORTB &= ~RESET ;
PORTB |= SCLK ;
gpio_write_pin_low(HP_46010A_RESET_PIN);
gpio_write_pin_high(HP_46010A_SCLK_PIN);
// led pin
DDRD |= LED ;
PORTD &= ~LED ;
gpio_set_pin_output(HP_46010A_LED_PIN);
gpio_write_pin_low(HP_46010A_LED_PIN);
matrix_init_kb();

View File

@ -74,8 +74,8 @@ uint8_t matrix_cols(void)
void matrix_init(void)
{
/* DDRD |= (1<<6); */
/* PORTD |= (1<<6); */
/* gpio_set_pin_output(D6); */
/* gpio_write_pin_high(D6); */
debug_enable = true;
uart_init(1200);
@ -99,7 +99,7 @@ void matrix_init(void)
/* } */
/* print(" Done\n"); */
/* PORTD &= ~(1<<6); */
/* gpio_write_pin_low(D6) */
matrix_init_kb();
return;

View File

@ -40,32 +40,16 @@ void set_led(int idx, bool enable) {
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case BL1:
if (record->event.pressed) {
PORTB |= (1 << 4);
} else {
PORTB &= ~(1 << 4);
}
gpio_write_pin(B4, record->event.pressed);
return false;
case BL2:
if (record->event.pressed) {
PORTB |= (1 << 5);
} else {
PORTB &= ~(1 << 5);
}
gpio_write_pin(B5, record->event.pressed);
return false;
case BL3:
if (record->event.pressed) {
PORTB |= (1 << 6);
} else {
PORTB &= ~(1 << 6);
}
gpio_write_pin(B6, record->event.pressed);
return false;
case BL4:
if (record->event.pressed) {
PORTB |= (1 << 7);
} else {
PORTB &= ~(1 << 7);
}
gpio_write_pin(B7, record->event.pressed);
return false;
}
return true;
@ -73,6 +57,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
void matrix_init_user(void) {
/* set LED row pins to output and low */
DDRB |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7);
PORTB &= ~(1 << 4) & ~(1 << 5) & ~(1 << 6) & ~(1 << 7);
gpio_set_pin_output(B4);
gpio_set_pin_output(B5);
gpio_set_pin_output(B6);
gpio_set_pin_output(B7);
gpio_write_pin_low(B4);
gpio_write_pin_low(B5);
gpio_write_pin_low(B6);
gpio_write_pin_low(B7);
}

View File

@ -2,6 +2,9 @@
#include "quantum.h"
#define DO60_CAPS_LOCK_LED_PIN B2
#define DO60_BACKLIGHT_PIN F4
/* DO60 LEDs
* GPIO pads
* 0 F7 not connected
@ -13,11 +16,21 @@
*/
/*
inline void do60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); }
inline void do60_bl_led_on(void) { DDRF |= (1<<4); PORTF &= ~(1<<4); }
inline void do60_caps_led_on(void) {
gpio_set_pin_output(DO60_CAPS_LOCK_LED_PIN);
gpio_write_pin_low(DO60_CAPS_LOCK_LED_PIN);
}
inline void do60_bl_led_on(void) {
gpio_set_pin_output(DO60_BACKLIGHT_PIN);
gpio_write_pin_low(DO60_BACKLIGHT_PIN);
}
inline void do60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); }
inline void do60_bl_led_off(void) { DDRF &= ~(1<<4); PORTF &= ~(1<<4); }
inline void do60_caps_led_off(void) {
gpio_set_pin_input(DO60_CAPS_LOCK_LED_PIN);
}
inline void do60_bl_led_off(void) {
gpio_set_pin_input(DO60_BACKLIGHT_PIN);
}
*/
inline void setdefaultrgb(void){ rgblight_sethsv(100,100,100); }

View File

@ -24,13 +24,11 @@ extern inline void ergodox_board_led_on(void);
extern inline void ergodox_right_led_1_on(void);
extern inline void ergodox_right_led_2_on(void);
extern inline void ergodox_right_led_3_on(void);
extern inline void ergodox_right_led_on(uint8_t led);
extern inline void ergodox_board_led_off(void);
extern inline void ergodox_right_led_1_off(void);
extern inline void ergodox_right_led_2_off(void);
extern inline void ergodox_right_led_3_off(void);
extern inline void ergodox_right_led_off(uint8_t led);
extern inline void ergodox_led_all_on(void);
extern inline void ergodox_led_all_off(void);
@ -53,17 +51,14 @@ void matrix_init_kb(void) {
TCCR1B = 0b00001001; // set and configure fast PWM
// (tied to Vcc for hardware convenience)
DDRB &= ~(1 << 4); // set B(4) as input
PORTB &= ~(1 << 4); // set B(4) internal pull-up disabled
gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled
// unused pins - C7, D4, D5, D7, E6
// unused pins - C7, D4, D5, E6
// set as input with internal pull-up enabled
DDRC &= ~(1 << 7);
DDRD &= ~(1 << 5 | 1 << 4);
DDRE &= ~(1 << 6);
PORTC |= (1 << 7);
PORTD |= (1 << 5 | 1 << 4);
PORTE |= (1 << 6);
gpio_set_pin_input_high(C7);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(E6);
keyboard_config.raw = eeconfig_read_kb();
ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4);

View File

@ -51,18 +51,40 @@ uint8_t ergodox_left_leds_update(void);
#define LED_BRIGHTNESS_HI 255
#endif
#define ERGODOX_EZ_BOARD_LED_PIN D6
#define ERGODOX_EZ_RIGHT_LED_1_PIN B5
#define ERGODOX_EZ_RIGHT_LED_2_PIN B6
#define ERGODOX_EZ_RIGHT_LED_3_PIN B7
inline void ergodox_board_led_on(void) { DDRD |= (1<<6); PORTD |= (1<<6); }
inline void ergodox_right_led_1_on(void) { DDRB |= (1<<5); PORTB |= (1<<5); }
inline void ergodox_right_led_2_on(void) { DDRB |= (1<<6); PORTB |= (1<<6); }
inline void ergodox_right_led_3_on(void) { DDRB |= (1<<7); PORTB |= (1<<7); }
inline void ergodox_right_led_on(uint8_t led) { DDRB |= (1<<(led+4)); PORTB |= (1<<(led+4)); }
inline void ergodox_board_led_on(void) {
gpio_set_pin_output(ERGODOX_EZ_BOARD_LED_PIN);
gpio_write_pin_high(ERGODOX_EZ_BOARD_LED_PIN);
}
inline void ergodox_right_led_1_on(void) {
gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_1_PIN);
gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_1_PIN);
}
inline void ergodox_right_led_2_on(void) {
gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_2_PIN);
gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_2_PIN);
}
inline void ergodox_right_led_3_on(void) {
gpio_set_pin_output(ERGODOX_EZ_RIGHT_LED_3_PIN);
gpio_write_pin_high(ERGODOX_EZ_RIGHT_LED_3_PIN);
}
inline void ergodox_board_led_off(void) { DDRD &= ~(1<<6); PORTD &= ~(1<<6); }
inline void ergodox_right_led_1_off(void) { DDRB &= ~(1<<5); PORTB &= ~(1<<5); }
inline void ergodox_right_led_2_off(void) { DDRB &= ~(1<<6); PORTB &= ~(1<<6); }
inline void ergodox_right_led_3_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); }
inline void ergodox_right_led_off(uint8_t led) { DDRB &= ~(1<<(led+4)); PORTB &= ~(1<<(led+4)); }
inline void ergodox_board_led_off(void) {
gpio_set_pin_input(ERGODOX_EZ_BOARD_LED_PIN);
}
inline void ergodox_right_led_1_off(void) {
gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_1_PIN);
}
inline void ergodox_right_led_2_off(void) {
gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_2_PIN);
}
inline void ergodox_right_led_3_off(void) {
gpio_set_pin_input(ERGODOX_EZ_RIGHT_LED_3_PIN);
}
#ifdef LEFT_LEDS
bool ergodox_left_led_1;

View File

@ -5,25 +5,30 @@ i2c_status_t mcp23018_status = 0x20;
void matrix_init_kb(void) {
// (tied to Vcc for hardware convenience)
//DDRB &= ~(1<<4); // set B(4) as input
//PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
//gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled
// unused pins
// set as input with internal pull-up enabled
DDRB &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
PORTB |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
gpio_set_pin_input_high(B4);
gpio_set_pin_input_high(B5);
gpio_set_pin_input_high(B6);
gpio_set_pin_input_high(B7);
DDRC &= ~(1<<7 | 1<<6);
PORTC |= (1<<7 | 1<<6);
gpio_set_pin_input_high(C6);
gpio_set_pin_input_high(C7);
DDRD &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
PORTD |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(D6);
gpio_set_pin_input_high(D7);
DDRE &= ~(1<<6);
PORTE |= (1<<6);
gpio_set_pin_input_high(E6);
DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7);
PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7);
gpio_set_pin_input_high(D0);
gpio_set_pin_input_high(D1);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D6);
gpio_set_pin_input_high(D7);
matrix_init_user();
}

View File

@ -7,17 +7,16 @@ void matrix_init_kb(void) {
steno_set_mode(STENO_MODE_GEMINI); // or STENO_MODE_BOLT
// (tied to Vcc for hardware convenience)
//DDRB &= ~(1<<4); // set B(4) as input
//PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
//gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled
// unused pins - C7, D4, D5, D7, E6
// unused pins - C7, D4, D5, D6, D7, E6
// set as input with internal pull-up enabled
DDRC &= ~(1<<7);
DDRD &= ~(1<<5 | 1<<4 | 1<<6 | 1<<7);
DDRE &= ~(1<<6);
PORTC |= (1<<7);
PORTD |= (1<<5 | 1<<4 | 1<<6 | 1<<7);
PORTE |= (1<<6);
gpio_set_pin_input_high(C7);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(D6);
gpio_set_pin_input_high(D7);
gpio_set_pin_input_high(E6);
matrix_init_user();
}

View File

@ -5,17 +5,16 @@ i2c_status_t mcp23018_status = 0x20;
void matrix_init_kb(void) {
// (tied to Vcc for hardware convenience)
//DDRB &= ~(1<<4); // set B(4) as input
//PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
//gpio_set_pin_input(B4); // set B(4) as input, internal pull-up disabled
// unused pins - C7, D4, D5, D7, E6
// unused pins - C7, D4, D5, D6, D7, E6
// set as input with internal pull-up enabled
DDRC &= ~(1<<7);
DDRD &= ~(1<<5 | 1<<4 | 1<<6 | 1<<7);
DDRE &= ~(1<<6);
PORTC |= (1<<7);
PORTD |= (1<<5 | 1<<4 | 1<<6 | 1<<7);
PORTE |= (1<<6);
gpio_set_pin_input_high(C7);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(D6);
gpio_set_pin_input_high(D7);
gpio_set_pin_input_high(E6);
matrix_init_user();
}

View File

@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
)
};

View File

@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PCMM, KC_PDOT, KC_PENT
)
};

View File

@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PCMM, KC_PDOT, KC_PENT
)
};

View File

@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
)
};

View File

@ -11,4 +11,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
)
};

View File

@ -1,10 +1,12 @@
#include "chimera_ergo.h"
void led_init(void) {
DDRD |= (1<<1);
PORTD |= (1<<1);
DDRF |= (1<<4) | (1<<5);
PORTF |= (1<<4) | (1<<5);
gpio_set_pin_output(CHIMERA_ERGO_GREEN_LED_PIN);
gpio_write_pin_high(CHIMERA_ERGO_GREEN_LED_PIN);
gpio_set_pin_output(CHIMERA_ERGO_BLUE_LED_PIN);
gpio_write_pin_high(CHIMERA_ERGO_BLUE_LED_PIN);
gpio_set_pin_output(CHIMERA_ERGO_RED_LED_PIN);
gpio_write_pin_high(CHIMERA_ERGO_RED_LED_PIN);
}

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define CHIMERA_ERGO_RED_LED_PIN F5
#define CHIMERA_ERGO_GREEN_LED_PIN D1
#define CHIMERA_ERGO_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(CHIMERA_ERGO_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(CHIMERA_ERGO_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(CHIMERA_ERGO_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(CHIMERA_ERGO_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(CHIMERA_ERGO_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(CHIMERA_ERGO_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -1,10 +1,12 @@
#include "chimera_ls.h"
void led_init(void) {
DDRD |= (1<<1);
PORTD |= (1<<1);
DDRF |= (1<<4) | (1<<5);
PORTF |= (1<<4) | (1<<5);
gpio_set_pin_output(CHIMERA_LS_GREEN_LED_PIN);
gpio_write_pin_high(CHIMERA_LS_GREEN_LED_PIN);
gpio_set_pin_output(CHIMERA_LS_BLUE_LED_PIN);
gpio_write_pin_high(CHIMERA_LS_BLUE_LED_PIN);
gpio_set_pin_output(CHIMERA_LS_RED_LED_PIN);
gpio_write_pin_high(CHIMERA_LS_RED_LED_PIN);
}

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define CHIMERA_LS_RED_LED_PIN F5
#define CHIMERA_LS_GREEN_LED_PIN D1
#define CHIMERA_LS_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(CHIMERA_LS_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(CHIMERA_LS_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(CHIMERA_LS_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(CHIMERA_LS_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(CHIMERA_LS_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(CHIMERA_LS_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -1,10 +1,12 @@
#include "chimera_ortho.h"
void led_init(void) {
DDRD |= (1<<1);
PORTD |= (1<<1);
DDRF |= (1<<4) | (1<<5);
PORTF |= (1<<4) | (1<<5);
gpio_set_pin_output(CHIMERA_ORTHO_GREEN_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_GREEN_LED_PIN);
gpio_set_pin_output(CHIMERA_ORTHO_BLUE_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_BLUE_LED_PIN);
gpio_set_pin_output(CHIMERA_ORTHO_RED_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_RED_LED_PIN);
}

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define CHIMERA_ORTHO_RED_LED_PIN F5
#define CHIMERA_ORTHO_GREEN_LED_PIN D1
#define CHIMERA_ORTHO_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(CHIMERA_ORTHO_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(CHIMERA_ORTHO_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(CHIMERA_ORTHO_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(CHIMERA_ORTHO_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(CHIMERA_ORTHO_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(CHIMERA_ORTHO_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -1,12 +1,12 @@
#include "chimera_ortho_plus.h"
void led_init(void) {
setPinOutput(D1);
setPinOutput(F4);
setPinOutput(F5);
writePinHigh(D1);
writePinHigh(F4);
writePinHigh(F5);
gpio_set_pin_output(CHIMERA_ORTHO_PLUS_GREEN_LED_PIN);
gpio_set_pin_output(CHIMERA_ORTHO_PLUS_BLUE_LED_PIN);
gpio_set_pin_output(CHIMERA_ORTHO_PLUS_RED_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_PLUS_GREEN_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_PLUS_BLUE_LED_PIN);
gpio_write_pin_high(CHIMERA_ORTHO_PLUS_RED_LED_PIN);
}

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define CHIMERA_ORTHO_PLUS_RED_LED_PIN F5
#define CHIMERA_ORTHO_PLUS_GREEN_LED_PIN D1
#define CHIMERA_ORTHO_PLUS_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(CHIMERA_ORTHO_PLUS_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(CHIMERA_ORTHO_PLUS_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(CHIMERA_ORTHO_PLUS_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(CHIMERA_ORTHO_PLUS_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(CHIMERA_ORTHO_PLUS_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(CHIMERA_ORTHO_PLUS_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off

View File

@ -100,21 +100,19 @@ bool led_update_user(led_t led_state)
{
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
} else {
// Hi-Z
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
gpio_set_pin_input(D6);
}
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
gpio_set_pin_output(C7);
gpio_write_pin_low(C7);
} else {
// Hi-Z
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
gpio_set_pin_input(C7);
}
return false;
}

View File

@ -12,7 +12,7 @@
k19, k1A, k17 \
) { \
{ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A }, \
{ k10, k11, k12, k13, k14, k15, k16, k17, XXX, k19, k1A } \
{ k10, k11, k12, k13, k14, k15, k16, k17, KC_NO, k19, k1A } \
}
enum layers {
@ -113,21 +113,19 @@ bool led_update_user(led_t led_state)
{
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
} else {
// Hi-Z
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
gpio_set_pin_input(D6);
}
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
gpio_set_pin_output(C7);
gpio_write_pin_low(C7);
} else {
// Hi-Z
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
gpio_set_pin_input(C7);
}
return false;
}

View File

@ -100,21 +100,19 @@ bool led_update_user(led_t led_state)
{
if (led_state.caps_lock) {
// output high
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
} else {
// Hi-Z
DDRD &= ~(1<<6);
PORTD &= ~(1<<6);
gpio_set_pin_input(D6);
}
if (led_state.num_lock) {
// output low
DDRC |= (1<<7);
PORTC |= ~(1<<7);
gpio_set_pin_output(C7);
gpio_write_pin_low(C7);
} else {
// Hi-Z
DDRC &= ~(1<<7);
PORTC &= ~(1<<7);
gpio_set_pin_input(C7);
}
return false;
}

View File

@ -3,8 +3,8 @@
void matrix_init_kb(void) {
// Turn status LED on
//DDRE |= (1<<6);
PORTE |= (1<<6);
//gpio_set_pin_output(E6);
gpio_write_pin_high(E6);
matrix_init_user();
};

View File

@ -99,27 +99,27 @@ static void select_row(uint8_t row) {
*/
if (row & (1<<0)) {
PORTE |= (1<<6);
gpio_write_pin_high(E6);
} else {
PORTE &= ~(1<<6);
gpio_write_pin_low(E6);
}
if (row & (1<<1)) {
PORTB |= (1<<7);
gpio_write_pin_high(B7);
} else {
PORTB &= ~(1<<7);
gpio_write_pin_low(B7);
}
if (row & (1<<2)) {
PORTD |= (1<<0);
gpio_write_pin_high(D0);
} else {
PORTD &= ~(1<<0);
gpio_write_pin_low(D0);
}
if (row & (1<<3)) {
PORTD |= (1<<1);
gpio_write_pin_high(D1);
} else {
PORTD &= ~(1<<1);
gpio_write_pin_low(D1);
}
}

View File

@ -4,13 +4,11 @@ extern inline void frenchdev_board_led_on(void);
extern inline void frenchdev_led_1_on(void);
extern inline void frenchdev_led_2_on(void);
extern inline void frenchdev_led_3_on(void);
extern inline void frenchdev_led_on(uint8_t led);
extern inline void frenchdev_board_led_off(void);
extern inline void frenchdev_led_1_off(void);
extern inline void frenchdev_led_2_off(void);
extern inline void frenchdev_led_3_off(void);
extern inline void frenchdev_led_off(uint8_t led);
extern inline void frenchdev_led_all_on(void);
extern inline void frenchdev_led_all_off(void);
@ -32,12 +30,11 @@ void matrix_init_kb(void) {
// unused pins - D4, D5, D7, E6
// unused pins - D4, D5, E6
// set as input with internal pull-ip enabled
DDRD &= ~(1<<5 | 1<<4);
DDRE &= ~(1<<6);
PORTD |= (1<<5 | 1<<4);
PORTE |= (1<<6);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(E6);
frenchdev_blink_all_leds();
frenchdev_blink_all_leds();

View File

@ -27,18 +27,40 @@ uint8_t init_mcp23018(void);
#define LED_BRIGHTNESS_LO 15
#define LED_BRIGHTNESS_HI 255
#define FRENCHDEV_BOARD_LED_PIN D6
#define FRENCHDEV_LED_1_PIN B5
#define FRENCHDEV_LED_2_PIN B6
#define FRENCHDEV_LED_3_PIN B7
inline void frenchdev_board_led_on(void) { DDRD |= (1<<6); PORTD |= (1<<6); }
inline void frenchdev_led_1_on(void) { DDRB |= (1<<5); PORTB |= (1<<5); }
inline void frenchdev_led_2_on(void) { DDRB |= (1<<6); PORTB |= (1<<6); }
inline void frenchdev_led_3_on(void) { DDRB |= (1<<7); PORTB |= (1<<7); }
inline void frenchdev_led_on(uint8_t led) { DDRB |= (1<<(led+4)); PORTB |= (1<<(led+4)); }
inline void frenchdev_board_led_on(void) {
gpio_set_pin_output(FRENCHDEV_BOARD_LED_PIN);
gpio_write_pin_high(FRENCHDEV_BOARD_LED_PIN);
}
inline void frenchdev_led_1_on(void) {
gpio_set_pin_output(FRENCHDEV_LED_1_PIN);
gpio_write_pin_high(FRENCHDEV_LED_1_PIN);
}
inline void frenchdev_led_2_on(void) {
gpio_set_pin_output(FRENCHDEV_LED_2_PIN);
gpio_write_pin_high(FRENCHDEV_LED_2_PIN);
}
inline void frenchdev_led_3_on(void) {
gpio_set_pin_output(FRENCHDEV_LED_3_PIN);
gpio_write_pin_high(FRENCHDEV_LED_3_PIN);
}
inline void frenchdev_board_led_off(void) { DDRD &= ~(1<<6); PORTD &= ~(1<<6); }
inline void frenchdev_led_1_off(void) { DDRB &= ~(1<<5); PORTB &= ~(1<<5); }
inline void frenchdev_led_2_off(void) { DDRB &= ~(1<<6); PORTB &= ~(1<<6); }
inline void frenchdev_led_3_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); }
inline void frenchdev_led_off(uint8_t led) { DDRB &= ~(1<<(led+4)); PORTB &= ~(1<<(led+4)); }
inline void frenchdev_board_led_off(void) {
gpio_set_pin_input(FRENCHDEV_BOARD_LED_PIN);
}
inline void frenchdev_led_1_off(void) {
gpio_set_pin_input(FRENCHDEV_LED_1_PIN);
}
inline void frenchdev_led_2_off(void) {
gpio_set_pin_input(FRENCHDEV_LED_2_PIN);
}
inline void frenchdev_led_3_off(void) {
gpio_set_pin_input(FRENCHDEV_LED_3_PIN);
}
inline void frenchdev_led_all_on(void)
{

View File

@ -213,8 +213,12 @@ static void init_cols(void)
// init on teensy
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
PORTF |= (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
gpio_set_pin_input_high(F0);
gpio_set_pin_input_high(F1);
gpio_set_pin_input_high(F4);
gpio_set_pin_input_high(F5);
gpio_set_pin_input_high(F6);
gpio_set_pin_input_high(F7);
}
static matrix_row_t read_cols(uint8_t row)
@ -265,12 +269,14 @@ static void unselect_rows(void)
// unselect on teensy
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
PORTB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
DDRD &= ~(1<<2 | 1<<3);
PORTD &= ~(1<<2 | 1<<3);
DDRC &= ~(1<<6 | 1<<7);
PORTC &= ~(1<<6 | 1<<7);
gpio_set_pin_input(B0);
gpio_set_pin_input(B1);
gpio_set_pin_input(B2);
gpio_set_pin_input(B3);
gpio_set_pin_input(D2);
gpio_set_pin_input(D3);
gpio_set_pin_input(C6);
gpio_set_pin_input(C7);
}
static void select_row(uint8_t row)
@ -290,36 +296,36 @@ static void select_row(uint8_t row)
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 8:
DDRB |= (1<<0);
PORTB &= ~(1<<0);
gpio_set_pin_output(B0);
gpio_write_pin_low(B0);
break;
case 9:
DDRB |= (1<<1);
PORTB &= ~(1<<1);
gpio_set_pin_output(B1);
gpio_write_pin_low(B1);
break;
case 10:
DDRB |= (1<<2);
PORTB &= ~(1<<2);
gpio_set_pin_output(B2);
gpio_write_pin_low(B2);
break;
case 11:
DDRB |= (1<<3);
PORTB &= ~(1<<3);
gpio_set_pin_output(B3);
gpio_write_pin_low(B3);
break;
case 12:
DDRD |= (1<<2);
PORTD &= ~(1<<3);
gpio_set_pin_output(D2);
gpio_write_pin_low(D2);
break;
case 13:
DDRD |= (1<<3);
PORTD &= ~(1<<3);
gpio_set_pin_output(D3);
gpio_write_pin_low(D3);
break;
case 14:
DDRC |= (1<<6);
PORTC &= ~(1<<6);
gpio_set_pin_output(C6);
gpio_write_pin_low(C6);
break;
case 15:
DDRC |= (1<<7);
PORTC &= ~(1<<7);
gpio_set_pin_output(C7);
gpio_write_pin_low(C7);
break;
}
}

View File

@ -3,11 +3,11 @@
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
DDRC |= (1<<6);
PORTC &= ~(1<<6);
gpio_set_pin_output(C6);
gpio_write_pin_low(C6);
DDRD |= (1<<4);
PORTD &= ~(1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_low(D4);
matrix_init_user();

View File

@ -33,22 +33,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
case TO(HDN):
if (record->event.pressed) {
PORTC |= (1 << 6); // PC6 goes high
gpio_write_pin_high(C6);
}
return true;
case TO(OSY):
if (record->event.pressed) {
PORTC &= ~(1 << 6); // PC6 goes high
PORTD |= (1<<4);
gpio_write_pin_low(C6);
gpio_write_pin_high(D4);
}
return true;
case TO(DEF):
if (record->event.pressed) {
PORTD &= ~(1 << 4); // PC6 goes high
gpio_write_pin_low(D4);
}
return true;

View File

@ -6,8 +6,8 @@ void matrix_init_kb(void) {
// runs once when the firmware starts up
// Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS)
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
matrix_init_user();
};

View File

@ -4,17 +4,46 @@
#include <stdint.h>
#include <stdbool.h>
#define HOTDOX_BOARD_LED_PIN B7
#define HOTDOX_RIGHT_LED_1_PIN B5
#define HOTDOX_RIGHT_LED_2_PIN B6
#define HOTDOX_RIGHT_LED_3_PIN B4
void init_ergodox(void);
inline void ergodox_board_led_on(void) { DDRB |= (1<<PB7); PORTB |= (1<<PB7); }
inline void ergodox_right_led_1_on(void) { DDRB |= (1<<PB5); PORTB &= ~(1<<PB5); }
inline void ergodox_right_led_2_on(void) { DDRB |= (1<<PB6); PORTB &= ~(1<<PB6); }
inline void ergodox_right_led_3_on(void) { DDRB |= (1<<PB4); PORTB &= ~(1<<PB4); }
inline void ergodox_board_led_on(void) {
gpio_set_pin_output(HOTDOX_BOARD_LED_PIN);
gpio_write_pin_high(HOTDOX_BOARD_LED_PIN);
}
inline void ergodox_right_led_1_on(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_1_PIN);
gpio_write_pin_low(HOTDOX_RIGHT_LED_1_PIN);
}
inline void ergodox_right_led_2_on(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_2_PIN);
gpio_write_pin_low(HOTDOX_RIGHT_LED_2_PIN);
}
inline void ergodox_right_led_3_on(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_3_PIN);
gpio_write_pin_low(HOTDOX_RIGHT_LED_3_PIN);
}
inline void ergodox_board_led_off(void) { DDRB |= (1<<PB7); PORTB &= ~(1<<PB7); }
inline void ergodox_right_led_1_off(void) { DDRB |= (1<<PB5); PORTB |= (1<<PB5); }
inline void ergodox_right_led_2_off(void) { DDRB |= (1<<PB6); PORTB |= (1<<PB6); }
inline void ergodox_right_led_3_off(void) { DDRB |= (1<<PB4); PORTB |= (1<<PB4); }
inline void ergodox_board_led_off(void) {
gpio_set_pin_output(HOTDOX_BOARD_LED_PIN);
gpio_write_pin_low(HOTDOX_BOARD_LED_PIN);
}
inline void ergodox_right_led_1_off(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_1_PIN);
gpio_write_pin_high(HOTDOX_RIGHT_LED_1_PIN);
}
inline void ergodox_right_led_2_off(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_2_PIN);
gpio_write_pin_high(HOTDOX_RIGHT_LED_2_PIN);
}
inline void ergodox_right_led_3_off(void) {
gpio_set_pin_output(HOTDOX_RIGHT_LED_3_PIN);
gpio_write_pin_high(HOTDOX_RIGHT_LED_3_PIN);
}
inline void ergodox_right_led_on(uint8_t l) {
switch (l) {

View File

@ -163,14 +163,15 @@ void matrix_print(void)
static void init_cols(void)
{
// Pro Micro
DDRB &= ~(1<<PB0 | 1<<PB1 | 1<<PB2 | 1<<PB3);
PORTB |= (1<<PB0 | 1<<PB1 | 1<<PB2 | 1<<PB3);
gpio_set_pin_input_high(B0);
gpio_set_pin_input_high(B1);
gpio_set_pin_input_high(B2);
gpio_set_pin_input_high(B3);
DDRD &= ~(1<<PD2 | 1<<PD3);
PORTD |= (1<<PD2 | 1<<PD3);
gpio_set_pin_input_high(D2);
gpio_set_pin_input_high(D3);
DDRC &= ~(1<<PC6);
PORTC |= (1<<PC6);
gpio_set_pin_input_high(C6);
left_init();
}
@ -195,8 +196,12 @@ static matrix_row_t read_cols(uint8_t row)
static void unselect_rows(void)
{
// Pro Micro
DDRF &= ~(1<<PF7 | 1<< PF6 | 1<<PF5 | 1<<PF4 | 1<<PF1 | 1<<PF0);
PORTF &= ~(1<<PF7 | 1<< PF6 | 1<<PF5 | 1<<PF4 | 1<<PF1 | 1<<PF0);
gpio_set_pin_input(F0);
gpio_set_pin_input(F1);
gpio_set_pin_input(F4);
gpio_set_pin_input(F5);
gpio_set_pin_input(F6);
gpio_set_pin_input(F7);
left_unselect_rows();
}
@ -206,28 +211,28 @@ static void select_row(uint8_t row)
// Pro Micro
switch (row) {
case 5:
DDRF |= (1<<PF0);
PORTF &= ~(1<<PF0);
gpio_set_pin_output(F0);
gpio_write_pin_low(F0);
break;
case 4:
DDRF |= (1<<PF1);
PORTF &= ~(1<<PF1);
gpio_set_pin_output(F1);
gpio_write_pin_low(F1);
break;
case 3:
DDRF |= (1<<PF4);
PORTF &= ~(1<<PF4);
gpio_set_pin_output(F4);
gpio_write_pin_low(F4);
break;
case 2:
DDRF |= (1<<PF5);
PORTF &= ~(1<<PF5);
gpio_set_pin_output(F5);
gpio_write_pin_low(F5);
break;
case 1:
DDRF |= (1<<PF6);
PORTF &= ~(1<<PF6);
gpio_set_pin_output(F6);
gpio_write_pin_low(F6);
break;
case 0:
DDRF |= (1<<PF7);
PORTF &= ~(1<<PF7);
gpio_set_pin_output(F7);
gpio_write_pin_low(F7);
break;
}

View File

@ -65,12 +65,11 @@ static void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
static void init(void) {
// Enable high current pathway to LEDs - this does violate the USB spec though! (1.6 amps...)
DDRE |= _BV(6);
PORTE &= ~_BV(6);
gpio_set_pin_output(E6);
gpio_write_pin_low(E6);
// Overcurrent check input
DDRB &= ~_BV(4);
PORTB &= ~_BV(4);
gpio_set_pin_input(B4);
}
static void flush(void) {

View File

@ -69,8 +69,8 @@ static int i2c_set_keyscan_interval(int hand, int delay) {
void matrix_init(void) {
/* Ensure scanner power is on - else right hand will not work */
DDRC |= _BV(7);
PORTC |= _BV(7);
gpio_set_pin_output(C7);
gpio_write_pin_high(C7);
i2c_init();
i2c_set_keyscan_interval(LEFT, 2);

View File

@ -18,9 +18,22 @@
#include "quantum.h"
// Functions for setting LEDs on toggle keys
inline void caps_led_on(void) { DDRD |= (1<<7); PORTD &= ~(1<<7); }
inline void caps_led_off(void) { DDRD &= ~(1<<7); PORTD &= ~(1<<7); }
#define KIRA75_CAPS_LOCK_LED_PIN D7
#define KIRA75_NUM_LOCK_LED_PIN D6
inline void num_led_on(void) { DDRD |= (1<<6); PORTD &= ~(1<<6); }
inline void num_led_off(void) { DDRD &= ~(1<<6); PORTD &= ~(1<<6); }
// Functions for setting LEDs on toggle keys
inline void caps_led_on(void) {
gpio_set_pin_output(KIRA75_CAPS_LOCK_LED_PIN);
gpio_write_pin_low(KIRA75_CAPS_LOCK_LED_PIN);
}
inline void caps_led_off(void) {
gpio_set_pin_input(KIRA75_CAPS_LOCK_LED_PIN);
}
inline void num_led_on(void) {
gpio_set_pin_output(KIRA75_NUM_LOCK_LED_PIN);
gpio_write_pin_low(KIRA75_NUM_LOCK_LED_PIN);
}
inline void num_led_off(void) {
gpio_set_pin_input(KIRA75_NUM_LOCK_LED_PIN);
}

View File

@ -194,11 +194,13 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
* Caps lock uses its own pin E2
*/
static void init_rows(void) {
DDRD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // IN
PORTD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // LO
gpio_set_pin_input(D0);
gpio_set_pin_input(D1);
gpio_set_pin_input(D2);
gpio_set_pin_input(D3);
gpio_set_pin_input(D5);
DDRE &= ~(1<<2); // IN
PORTE |= (1<<2); // HI
gpio_set_pin_input_high(E2);
}
/* Columns 0 - 16
@ -224,87 +226,103 @@ static void init_rows(void) {
* col 16: B4
*/
static void unselect_cols(void) {
DDRB |= (1<<5) | (1<<6) | (1<<0) | (1<<7) | (1<<4); // OUT
PORTB &= ~((1<<5) | (1<<6) | (1<<0) | (1<<7) | (1<<4)); // LO
gpio_set_pin_output(B0);
gpio_set_pin_output(B4);
gpio_set_pin_output(B5);
gpio_set_pin_output(B6);
gpio_set_pin_output(B7);
gpio_write_pin_low(B0);
gpio_write_pin_low(B4);
gpio_write_pin_low(B5);
gpio_write_pin_low(B6);
gpio_write_pin_low(B7);
DDRD |= (1<<4) | (1<<6) | (1<<7); // OUT
PORTD &= ~((1<<4) | (1<<6) | (1<<7)); // LO
gpio_set_pin_output(D4);
gpio_set_pin_output(D6);
gpio_set_pin_output(D7);
gpio_write_pin_low(D4);
gpio_write_pin_low(D6);
gpio_write_pin_low(D7);
DDRE |= (1<<6); // OUT
PORTE &= ~((1<<6)); // LO
gpio_set_pin_output(E6);
gpio_write_pin_low(E6);
DDRF |= (1<<0) | (1<<1); // OUT
PORTF &= ~((1<<0) | (1<<1)); // LO
gpio_set_pin_output(F0);
gpio_set_pin_output(F1);
gpio_write_pin_low(F0);
gpio_write_pin_low(F1);
DDRC |= (1<<7) | (1<<6); // OUT
PORTC &= ~((1<<7) | (1<<6)); // LO
gpio_set_pin_output(C6);
gpio_set_pin_output(C7);
gpio_write_pin_low(C6);
gpio_write_pin_low(C7);
}
static void select_col(uint8_t col)
{
switch (col) {
case 0:
PORTB |= (1<<5); // HI
gpio_write_pin_high(B5); // HI
break;
case 1:
PORTB |= (1<<6); // HI
gpio_write_pin_high(B6); // HI
break;
case 2:
PORTC |= (1<<6); // HI
gpio_write_pin_high(C6); // HI
break;
case 3:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F0); // HI
break;
case 4:
PORTC |= (1<<6); // HI
PORTF |= (1<<1); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F1); // HI
break;
case 5:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
PORTF |= (1<<1); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F0); // HI
gpio_write_pin_high(F1); // HI
break;
case 6:
PORTC |= (1<<6); // HI
PORTC |= (1<<7); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(C7); // HI
break;
case 7:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
PORTC |= (1<<7); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F0); // HI
gpio_write_pin_high(C7); // HI
break;
case 8:
PORTC |= (1<<6); // HI
PORTF |= (1<<1); // HI
PORTC |= (1<<7); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F1); // HI
gpio_write_pin_high(C7); // HI
break;
case 9:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
PORTF |= (1<<1); // HI
PORTC |= (1<<7); // HI
gpio_write_pin_high(C6); // HI
gpio_write_pin_high(F0); // HI
gpio_write_pin_high(F1); // HI
gpio_write_pin_high(C7); // HI
break;
case 10:
PORTE |= (1<<6); // HI
gpio_write_pin_high(E6); // HI
break;
case 11:
PORTB |= (1<<0); // HI
gpio_write_pin_high(B0); // HI
break;
case 12:
PORTB |= (1<<7); // HI
gpio_write_pin_high(B7); // HI
break;
case 13:
PORTD |= (1<<4); // HI
gpio_write_pin_high(D4); // HI
break;
case 14:
PORTD |= (1<<6); // HI
gpio_write_pin_high(D6); // HI
break;
case 15:
PORTD |= (1<<7); // HI
gpio_write_pin_high(D7); // HI
break;
case 16:
PORTB |= (1<<4); // HI
gpio_write_pin_high(B4); // HI
break;
}
}

View File

@ -135,51 +135,51 @@ void set_switch_led(int ledId, bool state) {
if(state) {
switch(ledId) {
case 1:
PORTD |= (1<<7);
gpio_write_pin_high(D7);
break;
case 2:
if((PINB & (1 << 7)) != 0) {
PORTC |= (1<<6);
if(gpio_read_pin(B7)) {
gpio_write_pin_high(C6);
} else {
PORTC |= (1<<7);
gpio_write_pin_high(C7);
}
break;
case 3:
PORTD |= (1<<4);
gpio_write_pin_high(D4);
break;
case 4:
PORTE |= (1<<6);
gpio_write_pin_high(E6);
break;
case 5:
PORTB |= (1<<4);
gpio_write_pin_high(B4);
break;
case 6:
PORTD |= (1<<6);
gpio_write_pin_high(D6);
break;
}
} else {
switch(ledId) {
case 1:
PORTD &= ~(1<<7);
gpio_write_pin_low(D7);
break;
case 2:
if((PINB & (1 << 7)) != 0) {
PORTC &= ~(1<<6);
if(gpio_read_pin(B7)) {
gpio_write_pin_low(C6);
} else {
PORTC &= ~(1<<7);
gpio_write_pin_low(C7);
}
break;
case 3:
PORTD &= ~(1<<4);
gpio_write_pin_low(D4);
break;
case 4:
PORTE &= ~(1<<6);
gpio_write_pin_low(E6);
break;
case 5:
PORTB &= ~(1<<4);
gpio_write_pin_low(B4);
break;
case 6:
PORTD &= ~(1<<6);
gpio_write_pin_low(D6);
break;
}
}
@ -187,88 +187,88 @@ void set_switch_led(int ledId, bool state) {
void set_layer_led(int layerId) {
PORTD |= (1<<5);
PORTB &= ~(1<<6);
PORTB |= (1<<0);
gpio_write_pin_high(D5);
gpio_write_pin_low(B6);
gpio_write_pin_high(B0);
switch(layerId) {
case 0:
PORTD &= ~(1<<5);
gpio_write_pin_low(D5);
break;
case 1:
PORTB |= (1<<6);
gpio_write_pin_high(B6);
break;
case 2:
PORTB &= ~(1<<0);
gpio_write_pin_low(B0);
break;
}
}
void led_init_ports_user(void) {
// led voor switch #1
DDRD |= (1<<7);
PORTD &= ~(1<<7);
gpio_set_pin_output(D7);
gpio_write_pin_low(D7);
// led voor switch #2
DDRC |= (1<<6);
DDRC |= (1<<7);
PORTC &= ~(1<<6);
PORTC &= ~(1<<7);
gpio_set_pin_output(C6);
gpio_set_pin_output(C7);
gpio_write_pin_low(C6);
gpio_write_pin_low(C7);
// led voor switch #3
DDRD |= (1<<4);
PORTD &= ~(1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_low(D4);
// led voor switch #4
DDRE |= (1<<6);
PORTE &= ~(1<<6);
gpio_set_pin_output(E6);
gpio_write_pin_low(E6);
// led voor switch #5
DDRB |= (1<<4);
PORTB &= ~(1<<4);
gpio_set_pin_output(B4);
gpio_write_pin_low(B4);
// led voor switch #6
DDRD |= (1<<6);
PORTD &= ~(1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_low(D6);
/*
DDRD |= (1<<7);
PORTD |= (1<<7);
gpio_set_pin_output(D7);
gpio_write_pin_high(D7);
DDRC |= (1<<6);
PORTC |= (1<<6);
gpio_set_pin_output(C6);
gpio_write_pin_high(C6);
DDRD |= (1<<4);
PORTD |= (1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_high(D4);
DDRE |= (1<<6);
PORTE |= (1<<6);
gpio_set_pin_output(E6);
gpio_write_pin_high(E6);
DDRB |= (1<<4);
PORTB |= (1<<4);
gpio_set_pin_output(B4);
gpio_write_pin_high(B4);
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
// */
DDRD |= (1<<5);
DDRB |= (1<<6);
DDRB |= (1<<0);
gpio_set_pin_output(D5);
gpio_set_pin_output(B6);
gpio_set_pin_output(B0);
//led_set_layer(0);
}
void matrix_init_user(void) {
led_init_ports_user();
PORTB |= (1 << 7);
DDRB &= ~(1<<7);
gpio_write_pin_high(B7);
gpio_set_pin_input(B7);
PORTD |= (1<<7);
PORTC |= (1<<6);
PORTC |= (1<<7);
PORTD |= (1<<4);
PORTE |= (1<<6);
PORTB |= (1<<4);
PORTD |= (1<<6);
gpio_write_pin_high(D7);
gpio_write_pin_high(C6);
gpio_write_pin_high(C7);
gpio_write_pin_high(D4);
gpio_write_pin_high(E6);
gpio_write_pin_high(B4);
gpio_write_pin_high(D6);
set_layer_led(0);
}

View File

@ -61,51 +61,51 @@ void set_switch_led(int ledId, bool state) {
if(state) {
switch(ledId) {
case 1:
PORTD |= (1<<7);
gpio_write_pin_high(D7);
break;
case 2:
if((PINB & (1 << 7)) != 0) {
PORTC |= (1<<6);
if(gpio_read_pin(B7)) {
gpio_write_pin_high(C6);
} else {
PORTC |= (1<<7);
gpio_write_pin_high(C7);
}
break;
case 3:
PORTD |= (1<<4);
gpio_write_pin_high(D4);
break;
case 4:
PORTE |= (1<<6);
gpio_write_pin_high(E6);
break;
case 5:
PORTB |= (1<<4);
gpio_write_pin_high(B4);
break;
case 6:
PORTD |= (1<<6);
gpio_write_pin_high(D6);
break;
}
} else {
switch(ledId) {
case 1:
PORTD &= ~(1<<7);
gpio_write_pin_low(D7);
break;
case 2:
if((PINB & (1 << 7)) != 0) {
PORTC &= ~(1<<6);
if(gpio_read_pin(B7)) {
gpio_write_pin_low(C6);
} else {
PORTC &= ~(1<<7);
gpio_write_pin_low(C7);
}
break;
case 3:
PORTD &= ~(1<<4);
gpio_write_pin_low(D4);
break;
case 4:
PORTE &= ~(1<<6);
gpio_write_pin_low(E6);
break;
case 5:
PORTB &= ~(1<<4);
gpio_write_pin_low(B4);
break;
case 6:
PORTD &= ~(1<<6);
gpio_write_pin_low(D6);
break;
}
}
@ -113,88 +113,88 @@ void set_switch_led(int ledId, bool state) {
void set_layer_led(int layerId) {
PORTD |= (1<<5);
PORTB &= ~(1<<6);
PORTB |= (1<<0);
gpio_write_pin_high(D5);
gpio_write_pin_low(B6);
gpio_write_pin_high(B0);
switch(layerId) {
case 0:
PORTD &= ~(1<<5);
gpio_write_pin_low(D5);
break;
case 1:
PORTB |= (1<<6);
gpio_write_pin_high(B6);
break;
case 2:
PORTB &= ~(1<<0);
gpio_write_pin_low(B0);
break;
}
}
void led_init_ports_user(void) {
// led voor switch #1
DDRD |= (1<<7);
PORTD &= ~(1<<7);
gpio_set_pin_output(D7);
gpio_write_pin_low(D7);
// led voor switch #2
DDRC |= (1<<6);
DDRC |= (1<<7);
PORTC &= ~(1<<6);
PORTC &= ~(1<<7);
gpio_set_pin_output(C6);
gpio_set_pin_output(C7);
gpio_write_pin_low(C6);
gpio_write_pin_low(C7);
// led voor switch #3
DDRD |= (1<<4);
PORTD &= ~(1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_low(D4);
// led voor switch #4
DDRE |= (1<<6);
PORTE &= ~(1<<6);
gpio_set_pin_output(E6);
gpio_write_pin_low(E6);
// led voor switch #5
DDRB |= (1<<4);
PORTB &= ~(1<<4);
gpio_set_pin_output(B4);
gpio_write_pin_low(B4);
// led voor switch #6
DDRD |= (1<<6);
PORTD &= ~(1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_low(D6);
/*
DDRD |= (1<<7);
PORTD |= (1<<7);
gpio_set_pin_output(D7);
gpio_write_pin_high(D7);
DDRC |= (1<<6);
PORTC |= (1<<6);
gpio_set_pin_output(C6);
gpio_write_pin_high(C6);
DDRD |= (1<<4);
PORTD |= (1<<4);
gpio_set_pin_output(D4);
gpio_write_pin_high(D4);
DDRE |= (1<<6);
PORTE |= (1<<6);
gpio_set_pin_output(E6);
gpio_write_pin_high(E6);
DDRB |= (1<<4);
PORTB |= (1<<4);
gpio_set_pin_output(B4);
gpio_write_pin_high(B4);
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
// */
DDRD |= (1<<5);
DDRB |= (1<<6);
DDRB |= (1<<0);
gpio_set_pin_output(D5);
gpio_set_pin_output(B6);
gpio_set_pin_output(B0);
//led_set_layer(0);
}
void matrix_init_user(void) {
led_init_ports_user();
PORTB |= (1 << 7);
DDRB &= ~(1<<7);
gpio_write_pin_high(B7);
gpio_set_pin_input(B7);
PORTD |= (1<<7);
PORTC |= (1<<6);
PORTC |= (1<<7);
PORTD |= (1<<4);
PORTE |= (1<<6);
PORTB |= (1<<4);
PORTD |= (1<<6);
gpio_write_pin_high(D7);
gpio_write_pin_high(C6);
gpio_write_pin_high(C7);
gpio_write_pin_high(D4);
gpio_write_pin_high(E6);
gpio_write_pin_high(B4);
gpio_write_pin_high(D6);
set_layer_led(0);
}

View File

@ -1,9 +1,12 @@
#include "the50.h"
#define THE50_LED_PIN B7
void the50_led_on(void) {
DDRB |= (1 << 7); PORTB &= ~(1 << 7);
gpio_set_pin_output(THE50_LED_PIN);
gpio_write_pin_low(THE50_LED_PIN);
}
void the50_led_off(void) {
DDRB &= ~(1 << 7); PORTB &= ~(1 << 7);
gpio_set_pin_input(THE50_LED_PIN);
}

View File

@ -1,10 +1,12 @@
#include "mitosis.h"
void led_init(void) {
DDRD |= (1<<1); // Pin to green, set as output
PORTD |= (1<<1); // Turn it off
DDRF |= (1<<4) | (1<<5); // Pins to red and blue, set as output
PORTF |= (1<<4) | (1<<5); // Turn them off
gpio_set_pin_output(MITOSIS_GREEN_LED_PIN);
gpio_write_pin_high(MITOSIS_GREEN_LED_PIN);
gpio_set_pin_output(MITOSIS_BLUE_LED_PIN);
gpio_write_pin_high(MITOSIS_BLUE_LED_PIN);
gpio_set_pin_output(MITOSIS_RED_LED_PIN);
gpio_write_pin_high(MITOSIS_RED_LED_PIN);
}
void matrix_init_kb(void) {

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define MITOSIS_RED_LED_PIN F5
#define MITOSIS_GREEN_LED_PIN D1
#define MITOSIS_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(MITOSIS_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(MITOSIS_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(MITOSIS_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(MITOSIS_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(MITOSIS_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(MITOSIS_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -72,10 +72,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
bool led_update_user(led_t led_state) {
if (led_state.caps_lock) {
DDRB |= (1 << 6); PORTB |= (1 << 6);
gpio_set_pin_output(B6);
gpio_write_pin_high(B6);
}
else {
DDRB &= ~(1 << 6); PORTB &= ~(1 << 6);
gpio_set_pin_input(B6);
}
return false;
}

View File

@ -3,6 +3,9 @@
#include "quantum.h"
#include "led.h"
#define ORG60_CAPS_LOCK_LED_PIN B2
#define ORG60_BACKLIGHT_PIN F5
/* Org60 LEDs
* GPIO pads
* 0 F7 not connected
@ -12,8 +15,18 @@
* B2 Capslock LED
* B0 not connected
*/
inline void org60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); }
inline void org60_bl_led_on(void) { DDRF |= (1<<5); PORTF &= ~(1<<5); }
inline void org60_caps_led_on(void) {
gpio_set_pin_output(ORG60_CAPS_LOCK_LED_PIN);
gpio_write_pin_low(ORG60_CAPS_LOCK_LED_PIN);
}
inline void org60_bl_led_on(void) {
gpio_set_pin_output(ORG60_BACKLIGHT_PIN);
gpio_write_pin_low(ORG60_BACKLIGHT_PIN);
}
inline void org60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); }
inline void org60_bl_led_off(void) { DDRF &= ~(1<<5); PORTF &= ~(1<<5); }
inline void org60_caps_led_off(void) {
gpio_set_pin_input(ORG60_CAPS_LOCK_LED_PIN);
}
inline void org60_bl_led_off(void) {
gpio_set_pin_input(ORG60_BACKLIGHT_PIN);
}

View File

@ -99,8 +99,8 @@ led_config_t g_led_config = { {
void matrix_init_kb(void) {
// Turn status LED on
DDRD |= (1<<6);
PORTD |= (1<<6);
gpio_set_pin_output(D6);
gpio_write_pin_high(D6);
matrix_init_user();
}

View File

@ -146,18 +146,20 @@ layer_state_t layer_state_set_user(layer_state_t state) {
// settings for LED on receiver
void led_init(void) {
DDRD |= (1<<1);
PORTD |= (1<<1);
DDRF |= (1<<4) | (1<<5);
PORTF |= (1<<4) | (1<<5);
gpio_set_pin_output(D1);
gpio_write_pin_high(D1);
gpio_set_pin_output(F4);
gpio_write_pin_high(F4);
gpio_set_pin_output(F5);
gpio_write_pin_high(F5);
}
#define red_led_off PORTF |= (1<<5)
#define red_led_on PORTF &= ~(1<<5)
#define blu_led_off PORTF |= (1<<4)
#define blu_led_on PORTF &= ~(1<<4)
#define grn_led_off PORTD |= (1<<1)
#define grn_led_on PORTD &= ~(1<<1)
#define red_led_off gpio_write_pin_high(F5)
#define red_led_on gpio_write_pin_low(F5)
#define blu_led_off gpio_write_pin_high(F4)
#define blu_led_on gpio_write_pin_low(F4)
#define grn_led_off gpio_write_pin_high(D1)
#define grn_led_on gpio_write_pin_low(D1)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off

View File

@ -1,12 +1,12 @@
#include "rev1.h"
void led_init(void) {
setPinOutput(D1); // Pin to green, set as output
writePinHigh(D1); // Turn it off
setPinOutput(F4); // Pins to red and blue, set as output
setPinOutput(F5);
writePinHigh(F4); // Turn them off
writePinHigh(F5);
gpio_set_pin_output(UNI660_GREEN_LED_PIN);
gpio_write_pin_high(UNI660_GREEN_LED_PIN);
gpio_set_pin_output(UNI660_BLUE_LED_PIN);
gpio_write_pin_high(UNI660_BLUE_LED_PIN);
gpio_set_pin_output(UNI660_RED_LED_PIN);
gpio_write_pin_high(UNI660_RED_LED_PIN);
}
void matrix_init_kb(void) {

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off writePinHigh(F5)
#define red_led_on writePinLow(F5)
#define blu_led_off writePinHigh(F4)
#define blu_led_on writePinLow(F4)
#define grn_led_off writePinHigh(D1)
#define grn_led_on writePinLow(D1)
#define UNI660_RED_LED_PIN F5
#define UNI660_GREEN_LED_PIN D1
#define UNI660_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(UNI660_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(UNI660_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(UNI660_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(UNI660_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(UNI660_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(UNI660_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -1,12 +1,12 @@
#include "rev2.h"
void led_init(void) {
setPinOutput(D1); // Pin to green, set as output
writePinHigh(D1); // Turn it off
setPinOutput(F4); // Pins to red and blue, set as output
setPinOutput(F5);
writePinHigh(F4); // Turn them off
writePinHigh(F5);
gpio_set_pin_output(UNI660_GREEN_LED_PIN);
gpio_write_pin_high(UNI660_GREEN_LED_PIN);
gpio_set_pin_output(UNI660_BLUE_LED_PIN);
gpio_write_pin_high(UNI660_BLUE_LED_PIN);
gpio_set_pin_output(UNI660_RED_LED_PIN);
gpio_write_pin_high(UNI660_RED_LED_PIN);
}
void matrix_init_kb(void) {

View File

@ -2,12 +2,16 @@
#include "quantum.h"
#define red_led_off writePinHigh(F5)
#define red_led_on writePinLow(F5)
#define blu_led_off writePinHigh(F4)
#define blu_led_on writePinLow(F4)
#define grn_led_off writePinHigh(D1)
#define grn_led_on writePinLow(D1)
#define UNI660_RED_LED_PIN F5
#define UNI660_GREEN_LED_PIN D1
#define UNI660_BLUE_LED_PIN F4
#define red_led_off gpio_write_pin_high(UNI660_RED_LED_PIN)
#define red_led_on gpio_write_pin_low(UNI660_RED_LED_PIN)
#define blu_led_off gpio_write_pin_high(UNI660_BLUE_LED_PIN)
#define blu_led_on gpio_write_pin_low(UNI660_BLUE_LED_PIN)
#define grn_led_off gpio_write_pin_high(UNI660_GREEN_LED_PIN)
#define grn_led_on gpio_write_pin_low(UNI660_GREEN_LED_PIN)
#define set_led_off red_led_off; grn_led_off; blu_led_off
#define set_led_red red_led_on; grn_led_off; blu_led_off
@ -17,27 +21,3 @@
#define set_led_magenta red_led_on; grn_led_off; blu_led_on
#define set_led_cyan red_led_off; grn_led_on; blu_led_on
#define set_led_white red_led_on; grn_led_on; blu_led_on
/*
#define LED_B 5
#define LED_R 6
#define LED_G 7
#define all_leds_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define red_led_on PORTF |= (1<<LED_R)
#define red_led_off PORTF &= ~(1<<LED_R)
#define grn_led_on PORTF |= (1<<LED_G)
#define grn_led_off PORTF &= ~(1<<LED_G)
#define blu_led_on PORTF |= (1<<LED_B)
#define blu_led_off PORTF &= ~(1<<LED_B)
#define set_led_off PORTF &= ~(1<<LED_B) & ~(1<<LED_R) & ~(1<<LED_G)
#define set_led_red PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_G) | (1<<LED_R)
#define set_led_blue PORTF = PORTF & ~(1<<LED_G) & ~(1<<LED_R) | (1<<LED_B)
#define set_led_green PORTF = PORTF & ~(1<<LED_B) & ~(1<<LED_R) | (1<<LED_G)
#define set_led_yellow PORTF = PORTF & ~(1<<LED_B) | (1<<LED_R) | (1<<LED_G)
#define set_led_magenta PORTF = PORTF & ~(1<<LED_G) | (1<<LED_R) | (1<<LED_B)
#define set_led_cyan PORTF = PORTF & ~(1<<LED_R) | (1<<LED_B) | (1<<LED_G)
#define set_led_white PORTF |= (1<<LED_B) | (1<<LED_R) | (1<<LED_G)
*/

View File

@ -1,7 +1,5 @@
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <util/delay.h>
// LUFA
#include "lufa.h"
@ -9,6 +7,8 @@
#include "sendchar.h"
#include "debug.h"
#include "keyboard.h"
#include "gpio.h"
#include "wait.h"
#include "led.h"
/* LED ping configuration */
@ -16,16 +16,16 @@
//#define LEONARDO_LED
#if defined(TMK_LED)
// For TMK converter and Teensy
#define LED_TX_INIT (DDRD |= (1<<6))
#define LED_TX_ON (PORTD |= (1<<6))
#define LED_TX_OFF (PORTD &= ~(1<<6))
#define LED_TX_TOGGLE (PORTD ^= (1<<6))
#define LED_TX_INIT gpio_set_pin_output(D6)
#define LED_TX_ON gpio_write_pin_high(D6)
#define LED_TX_OFF gpio_write_pin_low(D6)
#define LED_TX_TOGGLE gpio_toggle_pin(D6)
#elif defined(LEONARDO_LED)
// For Leonardo(TX LED)
#define LED_TX_INIT (DDRD |= (1<<5))
#define LED_TX_ON (PORTD &= ~(1<<5))
#define LED_TX_OFF (PORTD |= (1<<5))
#define LED_TX_TOGGLE (PORTD ^= (1<<5))
#define LED_TX_INIT gpio_set_pin_output(D5)
#define LED_TX_ON gpio_write_pin_low(D5)
#define LED_TX_OFF gpio_write_pin_high(D5)
#define LED_TX_TOGGLE gpio_toggle_pin(D5)
#else
#define LED_TX_INIT
#define LED_TX_ON

View File

@ -71,13 +71,12 @@ uint8_t matrix_cols(void)
void matrix_init(void)
{
DDRC &= ~(1<<7);
PORTC |= (1<<7);
DDRB &= ~(1<<7 | 1<<5);
PORTB |= (1<<7 | 1<<5);
DDRD &= ~(1<<6 | 1<<4 | 1<<1);
PORTD |= (1<<6 | 1<<4 | 1<<1);
gpio_set_pin_input_high(C7);
gpio_set_pin_input_high(B5);
gpio_set_pin_input_high(B7);
gpio_set_pin_input_high(D1);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D6);
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;

View File

@ -4,27 +4,26 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
DDRC |= (1<<4);
PORTC &= ~(1<<4);
gpio_set_pin_output(C4);
gpio_write_pin_low(C4);
gpio_set_pin_output(C6);
gpio_write_pin_low(C6);
DDRC |= (1<<6);
PORTC &= ~(1<<6);
gpio_set_pin_output(B6);
gpio_write_pin_low(B6);
DDRB |= (1<<6);
PORTB &= ~(1<<6);
gpio_set_pin_output(B4);
gpio_write_pin_low(B4);
DDRB |= (1<<4);
PORTB &= ~(1<<4);
gpio_set_pin_output(D5);
gpio_write_pin_low(D5);
DDRD |= (1<<5);
PORTD &= ~(1<<5);
gpio_set_pin_output(D2);
gpio_write_pin_low(D2);
DDRD |= (1<<2);
PORTD &= ~(1<<2);
DDRD |= (1<<3);
PORTD &= ~(1<<3);
gpio_set_pin_output(D3);
gpio_write_pin_low(D3);
matrix_init_user();
};

View File

@ -19,14 +19,14 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
DDRB |= (1 << PB0); //init B0
PORTB &= ~(1 << PB0); //turn on B0
DDRB |= (1 << PB1);
PORTB |= (1<<PB1); //turn off B1
DDRB |= (1 << PB2);
PORTB |= (1<<PB2);
DDRB |= (1 << PB3);
PORTB |= (1<<PB3);
gpio_set_pin_output(B0);
gpio_write_pin_low(B0);
gpio_set_pin_output(B1);
gpio_write_pin_high(B1);
gpio_set_pin_output(B2);
gpio_write_pin_high(B2);
gpio_set_pin_output(B3);
gpio_write_pin_high(B3);
matrix_init_user();
}
@ -49,32 +49,16 @@ bool process_indicator_led_kb(layer_state_t state)
if(process_indicator_led_user(state))
{
// if on layer 0, turn on B0 LED, otherwise off.
if (get_highest_layer(state) == 0) {
PORTB &= ~(1<<PB0);
} else {
PORTB |= (1<<PB0);
}
gpio_write_pin(B0, get_highest_layer(state) != 0);
// if on layer 1, turn on B1 LED, otherwise off.
if (get_highest_layer(state) == 1) {
PORTB &= ~(1<<PB1);
} else {
PORTB |= (1<<PB1);
}
gpio_write_pin(B1, get_highest_layer(state) != 1);
// if on layer 2, turn on B2 LED, otherwise off.
if (get_highest_layer(state) == 2) {
PORTB &= ~(1<<PB2);
} else {
PORTB |= (1<<PB2);
}
gpio_write_pin(B2, get_highest_layer(state) != 2);
// if on layer 3, turn on B3 LED, otherwise off.
if (get_highest_layer(state) == 3) {
PORTB &= ~(1<<PB3);
} else {
PORTB |= (1<<PB3);
}
gpio_write_pin(B3, get_highest_layer(state) != 3);
}
return true;

View File

@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGB_STEP 16
#define RGB_RED_PIN PF6
#define RGB_GREEN_PIN PF5
#define RGB_BLUE_PIN PF4
#define RGB_RED_PIN F6
#define RGB_GREEN_PIN F5
#define RGB_BLUE_PIN F4
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE

View File

@ -115,18 +115,22 @@ void rgb_timer_init(void) {
}
void rgb_init(void) {
DDRF |= (_BV(PF6) | _BV(PF5) | _BV(PF4));
PORTF |= (_BV(PF6) | _BV(PF5) | _BV(PF4));
gpio_set_pin_output(F4);
gpio_set_pin_output(F5);
gpio_set_pin_output(F6);
gpio_write_pin_high(F4);
gpio_write_pin_high(F5);
gpio_write_pin_high(F6);
rgb_timer_init();
}
void set_rgb_pin_on(uint8_t pin) {
PORTF &= ~_BV(pin);
void set_rgb_pin_on(pin_t pin) {
gpio_write_pin_low(pin);
}
void set_rgb_pin_off(uint8_t pin) {
PORTF |= _BV(pin);
void set_rgb_pin_off(pin_t pin) {
gpio_write_pin_high(pin);
}
ISR(TIMER3_COMPA_vect)

View File

@ -23,24 +23,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
bool led_update_user(led_t led_state) {
DDRB |= (1 << 4) | (1 << 5) | (1 << 6);
gpio_set_pin_output(B4);
gpio_set_pin_output(B5);
gpio_set_pin_output(B6);
if (led_state.num_lock) {
PORTB |= (1 << 4);
} else {
PORTB &= ~(1 << 4);
}
gpio_write_pin(B4, led_state.num_lock);
gpio_write_pin(B5, led_state.caps_lock);
gpio_write_pin(B6, led_state.scroll_lock);
if (led_state.caps_lock) {
PORTB |= (1 << 5);
} else {
PORTB &= ~(1 << 5);
}
if (led_state.scroll_lock) {
PORTB |= (1 << 6);
} else {
PORTB &= ~(1 << 6);
}
return false;
}

View File

@ -2629,15 +2629,12 @@ void backlight_debug_led( bool state )
{
if (state)
{
// Output high.
DDRE |= (1<<6);
PORTE |= (1<<6);
gpio_set_pin_output(E6);
gpio_write_pin_high(E6);
}
else
{
// Output low.
DDRE &= ~(1<<6);
PORTE &= ~(1<<6);
gpio_set_pin_input(E6);
}
}
#endif // defined(RGB_DEBUGGING_ONLY)

View File

@ -2,6 +2,9 @@
#include "quantum.h"
#define XD60_CAPS_LOCK_LED_PIN B2
#define XD60_BACKLIGHT_PIN F5
/* XD60 LEDs
* GPIO pads
* 0 F7 not connected
@ -11,8 +14,18 @@
* B2 Capslock LED
* B0 not connected
*/
inline void xd60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); }
inline void xd60_bl_led_on(void) { DDRF |= (1<<5); PORTF &= ~(1<<5); }
inline void xd60_caps_led_on(void) {
gpio_set_pin_output(XD60_CAPS_LOCK_LED_PIN);
gpio_write_pin_low(XD60_CAPS_LOCK_LED_PIN);
}
inline void xd60_bl_led_on(void) {
gpio_set_pin_output(XD60_BACKLIGHT_PIN);
gpio_write_pin_low(XD60_BACKLIGHT_PIN);
}
inline void xd60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); }
inline void xd60_bl_led_off(void) { DDRF &= ~(1<<5); PORTF &= ~(1<<5); }
inline void xd60_caps_led_off(void) {
gpio_set_pin_input(XD60_CAPS_LOCK_LED_PIN);
}
inline void xd60_bl_led_off(void) {
gpio_set_pin_input(XD60_BACKLIGHT_PIN);
}

View File

@ -43,7 +43,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case YD68_RGB_PWR:
if (record->event.pressed) {
// when keycode YD68_RGB_PWR is pressed
PORTE ^= (1<<2);
gpio_toggle_pin(E2);
} else {
// when keycode YD68_RGB_PWR is released
}