diff options
author | Yaotian Feng <codetector@codetector.cn> | 2019-09-25 14:52:17 -0400 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-09-25 11:52:17 -0700 |
commit | c61d7d7cb001498e6edf09a9ebc6124c1fe6ed97 (patch) | |
tree | 74045b30c256bed3b533b786edd2af06ee20ced0 /keyboards/ergodox_stm32/ergodox_stm32.c | |
parent | eac4ce972d951855ee168705b46bc9421a4d4deb (diff) | |
download | qmk_firmware-c61d7d7cb001498e6edf09a9ebc6124c1fe6ed97.tar.gz qmk_firmware-c61d7d7cb001498e6edf09a9ebc6124c1fe6ed97.zip |
[Keyboard] Added support for ErgoDox with STM32 Microcontroller (#5398)
* Began Work On STM32 Ergodox
Changes to be committed:
new file: keyboards/ergodox_stm32/config.h
new file: keyboards/ergodox_stm32/rules.mk
* test
* Now it compile. Not linking thou
* Screw this Linker. It links now!
* Blinkly Keyboard
* bootloader test code
* Working on matrix / i2c stuff
* Progress (LED Blink)
* Progress on MCP_23017 Status Flag
* [WIP]
* update
* Works! Remeber to change back the bootloader address when the new bootloadrer is ready.
* Time to go debug the i2c
* Finally, it now works with PCB Rev 1.0.2
* updated for rev.2 pcb
* minor compilation fix
* Why when debugger is enabled then everything works.
* Remeber to call init functions.
* Update arm i2c driver to support STM32F103 series device.
* fix include once header. Replaced with #pragma once.
* complication test
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 0000000000..176fb3f43a --- /dev/null +++ b/keyboards/ergodox_stm32/ergodox_stm32.c @@ -0,0 +1,65 @@ +#include "i2c_master.h" +#include QMK_KEYBOARD_H + +extern inline void ergodox_board_led_1_on(void); +extern inline void ergodox_board_led_2_on(void); +extern inline void ergodox_board_led_3_on(void); +extern inline void ergodox_board_led_1_off(void); +extern inline void ergodox_board_led_2_off(void); +extern inline void ergodox_board_led_3_off(void); +extern inline void ergodox_led_all_off(void); + +volatile int mcp23017_status = 0x20; +uint8_t i2c_initializied = 0; + +void matrix_init_kb(void) +{ + // Init LED Ports + palSetPadMode(GPIOA, 10, PAL_MODE_OUTPUT_PUSHPULL); // LED 1 + palSetPadMode(GPIOA, 9, PAL_MODE_OUTPUT_PUSHPULL); // LED 2 + palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED 3 + + ergodox_blink_all_leds(); + + matrix_init_user(); +} + +void ergodox_blink_all_leds(void) +{ + ergodox_led_all_off(); + // ergodox_led_all_set(LED_BRIGHTNESS_DEFAULT); + ergodox_board_led_1_on(); + wait_ms(50); + ergodox_board_led_2_on(); + wait_ms(50); + ergodox_board_led_3_on(); + wait_ms(50); + ergodox_board_led_1_off(); + wait_ms(50); + ergodox_board_led_2_off(); + wait_ms(50); + ergodox_board_led_3_off(); +} + +uint8_t init_mcp23017(void) { + if (!i2c_initializied) { + i2c_init(); + i2c_initializied = 1; + } + + uint8_t data[2]; + data[0] = 0x0; + data[1] = 0b00111111; + mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_IODIRA, data, 2, 50000); + if (mcp23017_status) goto out; + data[0] = 0xFFU; + mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, data, 1, 5000); + if (mcp23017_status) goto out; + mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPPUB, data+1, 1, 2); + if (mcp23017_status) goto out; + + out: + return mcp23017_status; + // i2c_readReg(I2C_ADDR, ); +} + |