diff options
Diffstat (limited to 'keyboards/ergodox_stm32/ergodox_stm32.c')
| -rw-r--r-- | keyboards/ergodox_stm32/ergodox_stm32.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/keyboards/ergodox_stm32/ergodox_stm32.c b/keyboards/ergodox_stm32/ergodox_stm32.c new file mode 100644 index 000000000..176fb3f43 --- /dev/null +++ b/keyboards/ergodox_stm32/ergodox_stm32.c | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | #include "i2c_master.h" | ||
| 2 | #include QMK_KEYBOARD_H | ||
| 3 | |||
| 4 | extern inline void ergodox_board_led_1_on(void); | ||
| 5 | extern inline void ergodox_board_led_2_on(void); | ||
| 6 | extern inline void ergodox_board_led_3_on(void); | ||
| 7 | extern inline void ergodox_board_led_1_off(void); | ||
| 8 | extern inline void ergodox_board_led_2_off(void); | ||
| 9 | extern inline void ergodox_board_led_3_off(void); | ||
| 10 | extern inline void ergodox_led_all_off(void); | ||
| 11 | |||
| 12 | volatile int mcp23017_status = 0x20; | ||
| 13 | uint8_t i2c_initializied = 0; | ||
| 14 | |||
| 15 | void matrix_init_kb(void) | ||
| 16 | { | ||
| 17 | // Init LED Ports | ||
| 18 | palSetPadMode(GPIOA, 10, PAL_MODE_OUTPUT_PUSHPULL); // LED 1 | ||
| 19 | palSetPadMode(GPIOA, 9, PAL_MODE_OUTPUT_PUSHPULL); // LED 2 | ||
| 20 | palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED 3 | ||
| 21 | |||
| 22 | ergodox_blink_all_leds(); | ||
| 23 | |||
| 24 | matrix_init_user(); | ||
| 25 | } | ||
| 26 | |||
| 27 | void ergodox_blink_all_leds(void) | ||
| 28 | { | ||
| 29 | ergodox_led_all_off(); | ||
| 30 | // ergodox_led_all_set(LED_BRIGHTNESS_DEFAULT); | ||
| 31 | ergodox_board_led_1_on(); | ||
| 32 | wait_ms(50); | ||
| 33 | ergodox_board_led_2_on(); | ||
| 34 | wait_ms(50); | ||
| 35 | ergodox_board_led_3_on(); | ||
| 36 | wait_ms(50); | ||
| 37 | ergodox_board_led_1_off(); | ||
| 38 | wait_ms(50); | ||
| 39 | ergodox_board_led_2_off(); | ||
| 40 | wait_ms(50); | ||
| 41 | ergodox_board_led_3_off(); | ||
| 42 | } | ||
| 43 | |||
| 44 | uint8_t init_mcp23017(void) { | ||
| 45 | if (!i2c_initializied) { | ||
| 46 | i2c_init(); | ||
| 47 | i2c_initializied = 1; | ||
| 48 | } | ||
| 49 | |||
| 50 | uint8_t data[2]; | ||
| 51 | data[0] = 0x0; | ||
| 52 | data[1] = 0b00111111; | ||
| 53 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_IODIRA, data, 2, 50000); | ||
| 54 | if (mcp23017_status) goto out; | ||
| 55 | data[0] = 0xFFU; | ||
| 56 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, data, 1, 5000); | ||
| 57 | if (mcp23017_status) goto out; | ||
| 58 | mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPPUB, data+1, 1, 2); | ||
| 59 | if (mcp23017_status) goto out; | ||
| 60 | |||
| 61 | out: | ||
| 62 | return mcp23017_status; | ||
| 63 | // i2c_readReg(I2C_ADDR, ); | ||
| 64 | } | ||
| 65 | |||
