diff options
| author | MakotoKurauchi <pluis@me.com> | 2019-10-17 03:01:49 +0900 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-10-16 11:01:49 -0700 |
| commit | 881f27b461189e6a02ecbaee0b5bcb3d85fc2b76 (patch) | |
| tree | a050021ce63faea50486c1b618654a2ff522d9f6 /keyboards/helix/local_drivers | |
| parent | 81f36ab74dca703c46e1d94e6d5b63365449e9d7 (diff) | |
| download | qmk_firmware-881f27b461189e6a02ecbaee0b5bcb3d85fc2b76.tar.gz qmk_firmware-881f27b461189e6a02ecbaee0b5bcb3d85fc2b76.zip | |
[Keyboard] Cleanup helix rules options (#6952)
* add temporary test shell-spript
* Use LINK_TIME_OPTIMIZATION_ENABLE instead of Link_Time_Optimization
No change in build result.
* Helix config.h use '#pragma once'
No change in build result.
* Helix helix.h,rev?/rev?.h,pico/pico.h use '#pragma once'
No change in build result.
* Use drivers/avr/pro_micro.h instead of keyboards/helix/pro_micro.h
No change in build result.
* remove keyboards/helix/{rev2|pico}/serial_config.h
No change in build result.
* 'HELIX_ROWS' macro is now referenced only in rev1/config.h and rev2/config.h.
No change in build result.
* The contents of helix/rules.mk were distributed to subdirectories.
This is a preparation to create a new subdirectory for helix code using split_common.
No change in build result.
remove 'USE_I2C = yes', 'SUBPROJECT_rev1 = no' from keyboards/helix/rules.mk.
follow code move from keyboards/helix/rules.mk to keyboards/helix/{rev1,rev2,pico}/rules.mk.
----
SRC += i2c.c
SRC += serial.c
SRC += ssd1306.c
CUSTOM_MATRIX = yes
---
* helix/{i2c.[ch], serial.[ch], ssd1306.[ch]} move into helix/local_drivers/
No change in build result.
* Simplified 'helix/pico/keymap/*/rules.mk' using KEYBOARD_LOCAL_FEATURES_MK.
No change in build result.
* add keyboards/helix/pico/local_features.mk
* add 'KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk' into keyboards/helix/pico/rules.mk
* remove HELIX_CUSTOMISE_MSG from keyboards/helix/pico/keymaps/*/rules.mk
* remove HELIX= process from keyboards/helix/pico/keymaps/*/rules.mk
* remove convert code(helix to standaerd) from keyboards/helix/pico/keymaps/*/rules.mk
* add 'include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))' into keyboards/helix/pico/keymaps/*/rules.mk
* Simplified 'helix/rev2/keymap/*/rules.mk' using KEYBOARD_LOCAL_FEATURES_MK.
No change in build result.
* add keyboards/helix/rev2/local_features.mk
* add 'KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk' into keyboards/helix/rev2/rules.mk
* remove HELIX_CUSTOMISE_MSG from keyboards/helix/rev2/keymaps/*/rules.mk
* remove HELIX= process from keyboards/helix/rev2/keymaps/*/rules.mk
* remove convert code(helix to standaerd) from keyboards/helix/rev2/keymaps/*/rules.mk
* add 'include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))' into keyboards/helix/rev2/keymaps/*/rules.mk
* Added helix keyboard build NEW method.
No change in build result.
## Helix build
$ make helix:default ## no oled, no backlight, no underglow
$ make helix/rev2/back:default ## no oled, with backlight, no underglow
$ make helix/rev2/under:default ## no oled, no backlight, with underglow
$ make helix/rev2/oled:default ## with oled, no backlight, not underglow
$ make helix/rev2/oled/back:default ## with oled, with backlight, no underglow
$ make helix/rev2/back/oled:default ## with oled, with backlight, no underglow
$ make helix/rev2/oled/under:default ## with oled, no backlight, with underglow
$ make helix/rev2/under/oled:default ## with oled, no backlight, with underglow
## Helix pico build
$ make helix/pico:default ## no oled, no backlight, no underglow
$ make helix/pico/back:default ## no oled, with backlight, no underglow
$ make helix/pico/under:default ## no oled, no backlight, with underglow
$ make helix/pico/oled:default ## with oled, no backlight, not underglow
* add temporary test shell-spript
* test end remove test script. Revert "add temporary test shell-spript"
This reverts commit 5dac20cd0f8b4bc192edb2313652c1635f829657.
* test end remove test script. Revert "add temporary test shell-spript"
This reverts commit ec49f63b2dc0f2b3fe8c1c36ffa615cee2f7e3ed.
* Extended the 'HELIX=' option. add keyword 'verbose', 'no_ani'.
No change in build result.
* update keyboards/helix/{rev2,pico}/keymaps/default/readme.md
* rename KEYBOARD_TOP_DIR to HELIX_TOP_DIR in rules.mk
* update keyboards/helix/{rev2,pico}/keymaps/default/readme_jp.md
* rm keyboards/helix/pico/oled/rules.mk
* update helix's readmes. All the ':avrdude' was replaced with ':flash'.
* remove F_CPU, ARCH, F_USB, INTERRUPT_CONTROL_ENDPOINT from helix/rules.mk
No change in build result.
Diffstat (limited to 'keyboards/helix/local_drivers')
| -rw-r--r-- | keyboards/helix/local_drivers/i2c.c | 162 | ||||
| -rw-r--r-- | keyboards/helix/local_drivers/i2c.h | 49 | ||||
| -rw-r--r-- | keyboards/helix/local_drivers/serial.c | 590 | ||||
| -rw-r--r-- | keyboards/helix/local_drivers/serial.h | 89 | ||||
| -rw-r--r-- | keyboards/helix/local_drivers/ssd1306.c | 342 | ||||
| -rw-r--r-- | keyboards/helix/local_drivers/ssd1306.h | 93 |
6 files changed, 1325 insertions, 0 deletions
diff --git a/keyboards/helix/local_drivers/i2c.c b/keyboards/helix/local_drivers/i2c.c new file mode 100644 index 000000000..4bee5c639 --- /dev/null +++ b/keyboards/helix/local_drivers/i2c.c | |||
| @@ -0,0 +1,162 @@ | |||
| 1 | #include <util/twi.h> | ||
| 2 | #include <avr/io.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <avr/interrupt.h> | ||
| 5 | #include <util/twi.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | #include "i2c.h" | ||
| 8 | |||
| 9 | #ifdef USE_I2C | ||
| 10 | |||
| 11 | // Limits the amount of we wait for any one i2c transaction. | ||
| 12 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | ||
| 13 | // 9 bits, a single transaction will take around 90μs to complete. | ||
| 14 | // | ||
| 15 | // (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit | ||
| 16 | // poll loop takes at least 8 clock cycles to execute | ||
| 17 | #define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 | ||
| 18 | |||
| 19 | #define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) | ||
| 20 | |||
| 21 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 22 | |||
| 23 | static volatile uint8_t slave_buffer_pos; | ||
| 24 | static volatile bool slave_has_register_set = false; | ||
| 25 | |||
| 26 | // Wait for an i2c operation to finish | ||
| 27 | inline static | ||
| 28 | void i2c_delay(void) { | ||
| 29 | uint16_t lim = 0; | ||
| 30 | while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT) | ||
| 31 | lim++; | ||
| 32 | |||
| 33 | // easier way, but will wait slightly longer | ||
| 34 | // _delay_us(100); | ||
| 35 | } | ||
| 36 | |||
| 37 | // Setup twi to run at 100kHz or 400kHz (see ./i2c.h SCL_CLOCK) | ||
| 38 | void i2c_master_init(void) { | ||
| 39 | // no prescaler | ||
| 40 | TWSR = 0; | ||
| 41 | // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10. | ||
| 42 | // Check datasheets for more info. | ||
| 43 | TWBR = ((F_CPU/SCL_CLOCK)-16)/2; | ||
| 44 | } | ||
| 45 | |||
| 46 | // Start a transaction with the given i2c slave address. The direction of the | ||
| 47 | // transfer is set with I2C_READ and I2C_WRITE. | ||
| 48 | // returns: 0 => success | ||
| 49 | // 1 => error | ||
| 50 | uint8_t i2c_master_start(uint8_t address) { | ||
| 51 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA); | ||
| 52 | |||
| 53 | i2c_delay(); | ||
| 54 | |||
| 55 | // check that we started successfully | ||
| 56 | if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START)) | ||
| 57 | return 1; | ||
| 58 | |||
| 59 | TWDR = address; | ||
| 60 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 61 | |||
| 62 | i2c_delay(); | ||
| 63 | |||
| 64 | if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) ) | ||
| 65 | return 1; // slave did not acknowledge | ||
| 66 | else | ||
| 67 | return 0; // success | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | // Finish the i2c transaction. | ||
| 72 | void i2c_master_stop(void) { | ||
| 73 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
| 74 | |||
| 75 | uint16_t lim = 0; | ||
| 76 | while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT) | ||
| 77 | lim++; | ||
| 78 | } | ||
| 79 | |||
| 80 | // Write one byte to the i2c slave. | ||
| 81 | // returns 0 => slave ACK | ||
| 82 | // 1 => slave NACK | ||
| 83 | uint8_t i2c_master_write(uint8_t data) { | ||
| 84 | TWDR = data; | ||
| 85 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 86 | |||
| 87 | i2c_delay(); | ||
| 88 | |||
| 89 | // check if the slave acknowledged us | ||
| 90 | return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1; | ||
| 91 | } | ||
| 92 | |||
| 93 | // Read one byte from the i2c slave. If ack=1 the slave is acknowledged, | ||
| 94 | // if ack=0 the acknowledge bit is not set. | ||
| 95 | // returns: byte read from i2c device | ||
| 96 | uint8_t i2c_master_read(int ack) { | ||
| 97 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
| 98 | |||
| 99 | i2c_delay(); | ||
| 100 | return TWDR; | ||
| 101 | } | ||
| 102 | |||
| 103 | void i2c_reset_state(void) { | ||
| 104 | TWCR = 0; | ||
| 105 | } | ||
| 106 | |||
| 107 | void i2c_slave_init(uint8_t address) { | ||
| 108 | TWAR = address << 0; // slave i2c address | ||
| 109 | // TWEN - twi enable | ||
| 110 | // TWEA - enable address acknowledgement | ||
| 111 | // TWINT - twi interrupt flag | ||
| 112 | // TWIE - enable the twi interrupt | ||
| 113 | TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN); | ||
| 114 | } | ||
| 115 | |||
| 116 | ISR(TWI_vect); | ||
| 117 | |||
| 118 | ISR(TWI_vect) { | ||
| 119 | uint8_t ack = 1; | ||
| 120 | switch(TW_STATUS) { | ||
| 121 | case TW_SR_SLA_ACK: | ||
| 122 | // this device has been addressed as a slave receiver | ||
| 123 | slave_has_register_set = false; | ||
| 124 | break; | ||
| 125 | |||
| 126 | case TW_SR_DATA_ACK: | ||
| 127 | // this device has received data as a slave receiver | ||
| 128 | // The first byte that we receive in this transaction sets the location | ||
| 129 | // of the read/write location of the slaves memory that it exposes over | ||
| 130 | // i2c. After that, bytes will be written at slave_buffer_pos, incrementing | ||
| 131 | // slave_buffer_pos after each write. | ||
| 132 | if(!slave_has_register_set) { | ||
| 133 | slave_buffer_pos = TWDR; | ||
| 134 | // don't acknowledge the master if this memory loctaion is out of bounds | ||
| 135 | if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) { | ||
| 136 | ack = 0; | ||
| 137 | slave_buffer_pos = 0; | ||
| 138 | } | ||
| 139 | slave_has_register_set = true; | ||
| 140 | } else { | ||
| 141 | i2c_slave_buffer[slave_buffer_pos] = TWDR; | ||
| 142 | BUFFER_POS_INC(); | ||
| 143 | } | ||
| 144 | break; | ||
| 145 | |||
| 146 | case TW_ST_SLA_ACK: | ||
| 147 | case TW_ST_DATA_ACK: | ||
| 148 | // master has addressed this device as a slave transmitter and is | ||
| 149 | // requesting data. | ||
| 150 | TWDR = i2c_slave_buffer[slave_buffer_pos]; | ||
| 151 | BUFFER_POS_INC(); | ||
| 152 | break; | ||
| 153 | |||
| 154 | case TW_BUS_ERROR: // something went wrong, reset twi state | ||
| 155 | TWCR = 0; | ||
| 156 | default: | ||
| 157 | break; | ||
| 158 | } | ||
| 159 | // Reset everything, so we are ready for the next TWI interrupt | ||
| 160 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); | ||
| 161 | } | ||
| 162 | #endif | ||
diff --git a/keyboards/helix/local_drivers/i2c.h b/keyboards/helix/local_drivers/i2c.h new file mode 100644 index 000000000..47cf6bd1b --- /dev/null +++ b/keyboards/helix/local_drivers/i2c.h | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | #ifndef I2C_H | ||
| 2 | #define I2C_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | |||
| 6 | #ifndef F_CPU | ||
| 7 | #define F_CPU 16000000UL | ||
| 8 | #endif | ||
| 9 | |||
| 10 | #define I2C_READ 1 | ||
| 11 | #define I2C_WRITE 0 | ||
| 12 | |||
| 13 | #define I2C_ACK 1 | ||
| 14 | #define I2C_NACK 0 | ||
| 15 | |||
| 16 | #define SLAVE_BUFFER_SIZE 0x10 | ||
| 17 | |||
| 18 | // i2c SCL clock frequency 400kHz | ||
| 19 | #define SCL_CLOCK 400000L | ||
| 20 | |||
| 21 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 22 | |||
| 23 | void i2c_master_init(void); | ||
| 24 | uint8_t i2c_master_start(uint8_t address); | ||
| 25 | void i2c_master_stop(void); | ||
| 26 | uint8_t i2c_master_write(uint8_t data); | ||
| 27 | uint8_t i2c_master_read(int); | ||
| 28 | void i2c_reset_state(void); | ||
| 29 | void i2c_slave_init(uint8_t address); | ||
| 30 | |||
| 31 | |||
| 32 | static inline unsigned char i2c_start_read(unsigned char addr) { | ||
| 33 | return i2c_master_start((addr << 1) | I2C_READ); | ||
| 34 | } | ||
| 35 | |||
| 36 | static inline unsigned char i2c_start_write(unsigned char addr) { | ||
| 37 | return i2c_master_start((addr << 1) | I2C_WRITE); | ||
| 38 | } | ||
| 39 | |||
| 40 | // from SSD1306 scrips | ||
| 41 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
| 42 | extern void i2c_start_wait(unsigned char addr); | ||
| 43 | extern unsigned char i2c_readAck(void); | ||
| 44 | extern unsigned char i2c_readNak(void); | ||
| 45 | extern unsigned char i2c_read(unsigned char ack); | ||
| 46 | |||
| 47 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | ||
| 48 | |||
| 49 | #endif | ||
diff --git a/keyboards/helix/local_drivers/serial.c b/keyboards/helix/local_drivers/serial.c new file mode 100644 index 000000000..6006ebf1b --- /dev/null +++ b/keyboards/helix/local_drivers/serial.c | |||
| @@ -0,0 +1,590 @@ | |||
| 1 | /* | ||
| 2 | * WARNING: be careful changing this code, it is very timing dependent | ||
| 3 | * | ||
| 4 | * 2018-10-28 checked | ||
| 5 | * avr-gcc 4.9.2 | ||
| 6 | * avr-gcc 5.4.0 | ||
| 7 | * avr-gcc 7.3.0 | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef F_CPU | ||
| 11 | #define F_CPU 16000000 | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #include <avr/io.h> | ||
| 15 | #include <avr/interrupt.h> | ||
| 16 | #include <util/delay.h> | ||
| 17 | #include <stddef.h> | ||
| 18 | #include <stdbool.h> | ||
| 19 | #include "serial.h" | ||
| 20 | //#include <pro_micro.h> | ||
| 21 | |||
| 22 | #ifdef SOFT_SERIAL_PIN | ||
| 23 | |||
| 24 | #ifdef __AVR_ATmega32U4__ | ||
| 25 | // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial. | ||
| 26 | #ifdef USE_I2C | ||
| 27 | #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1 | ||
| 28 | #error Using ATmega32U4 I2C, so can not use PD0, PD1 | ||
| 29 | #endif | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3 | ||
| 33 | #define SERIAL_PIN_DDR DDRD | ||
| 34 | #define SERIAL_PIN_PORT PORTD | ||
| 35 | #define SERIAL_PIN_INPUT PIND | ||
| 36 | #if SOFT_SERIAL_PIN == D0 | ||
| 37 | #define SERIAL_PIN_MASK _BV(PD0) | ||
| 38 | #define EIMSK_BIT _BV(INT0) | ||
| 39 | #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01))) | ||
| 40 | #define SERIAL_PIN_INTERRUPT INT0_vect | ||
| 41 | #elif SOFT_SERIAL_PIN == D1 | ||
| 42 | #define SERIAL_PIN_MASK _BV(PD1) | ||
| 43 | #define EIMSK_BIT _BV(INT1) | ||
| 44 | #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11))) | ||
| 45 | #define SERIAL_PIN_INTERRUPT INT1_vect | ||
| 46 | #elif SOFT_SERIAL_PIN == D2 | ||
| 47 | #define SERIAL_PIN_MASK _BV(PD2) | ||
| 48 | #define EIMSK_BIT _BV(INT2) | ||
| 49 | #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21))) | ||
| 50 | #define SERIAL_PIN_INTERRUPT INT2_vect | ||
| 51 | #elif SOFT_SERIAL_PIN == D3 | ||
| 52 | #define SERIAL_PIN_MASK _BV(PD3) | ||
| 53 | #define EIMSK_BIT _BV(INT3) | ||
| 54 | #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31))) | ||
| 55 | #define SERIAL_PIN_INTERRUPT INT3_vect | ||
| 56 | #endif | ||
| 57 | #elif SOFT_SERIAL_PIN == E6 | ||
| 58 | #define SERIAL_PIN_DDR DDRE | ||
| 59 | #define SERIAL_PIN_PORT PORTE | ||
| 60 | #define SERIAL_PIN_INPUT PINE | ||
| 61 | #define SERIAL_PIN_MASK _BV(PE6) | ||
| 62 | #define EIMSK_BIT _BV(INT6) | ||
| 63 | #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61))) | ||
| 64 | #define SERIAL_PIN_INTERRUPT INT6_vect | ||
| 65 | #else | ||
| 66 | #error invalid SOFT_SERIAL_PIN value | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #else | ||
| 70 | #error serial.c now support ATmega32U4 only | ||
| 71 | #endif | ||
| 72 | |||
| 73 | //////////////// for backward compatibility //////////////////////////////// | ||
| 74 | #if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) | ||
| 75 | /* --- USE OLD API (compatible with let's split serial.c) */ | ||
| 76 | #if SERIAL_SLAVE_BUFFER_LENGTH > 0 | ||
| 77 | uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; | ||
| 78 | #endif | ||
| 79 | #if SERIAL_MASTER_BUFFER_LENGTH > 0 | ||
| 80 | uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; | ||
| 81 | #endif | ||
| 82 | uint8_t volatile status0 = 0; | ||
| 83 | |||
| 84 | SSTD_t transactions[] = { | ||
| 85 | { (uint8_t *)&status0, | ||
| 86 | #if SERIAL_MASTER_BUFFER_LENGTH > 0 | ||
| 87 | sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer, | ||
| 88 | #else | ||
| 89 | 0, (uint8_t *)NULL, | ||
| 90 | #endif | ||
| 91 | #if SERIAL_SLAVE_BUFFER_LENGTH > 0 | ||
| 92 | sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer | ||
| 93 | #else | ||
| 94 | 0, (uint8_t *)NULL, | ||
| 95 | #endif | ||
| 96 | } | ||
| 97 | }; | ||
| 98 | |||
| 99 | void serial_master_init(void) | ||
| 100 | { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } | ||
| 101 | |||
| 102 | void serial_slave_init(void) | ||
| 103 | { soft_serial_target_init(transactions, TID_LIMIT(transactions)); } | ||
| 104 | |||
| 105 | // 0 => no error | ||
| 106 | // 1 => slave did not respond | ||
| 107 | // 2 => checksum error | ||
| 108 | int serial_update_buffers() | ||
| 109 | { | ||
| 110 | int result; | ||
| 111 | result = soft_serial_transaction(); | ||
| 112 | return result; | ||
| 113 | } | ||
| 114 | |||
| 115 | #endif // end of OLD API (compatible with let's split serial.c) | ||
| 116 | //////////////////////////////////////////////////////////////////////////// | ||
| 117 | |||
| 118 | #define ALWAYS_INLINE __attribute__((always_inline)) | ||
| 119 | #define NO_INLINE __attribute__((noinline)) | ||
| 120 | #define _delay_sub_us(x) __builtin_avr_delay_cycles(x) | ||
| 121 | |||
| 122 | // parity check | ||
| 123 | #define ODD_PARITY 1 | ||
| 124 | #define EVEN_PARITY 0 | ||
| 125 | #define PARITY EVEN_PARITY | ||
| 126 | |||
| 127 | #ifdef SERIAL_DELAY | ||
| 128 | // custom setup in config.h | ||
| 129 | // #define TID_SEND_ADJUST 2 | ||
| 130 | // #define SERIAL_DELAY 6 // micro sec | ||
| 131 | // #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 132 | // #define READ_WRITE_WIDTH_ADJUST 8 // cycles | ||
| 133 | #else | ||
| 134 | // ============ Standard setups ============ | ||
| 135 | |||
| 136 | #ifndef SELECT_SOFT_SERIAL_SPEED | ||
| 137 | #define SELECT_SOFT_SERIAL_SPEED 1 | ||
| 138 | // 0: about 189kbps | ||
| 139 | // 1: about 137kbps (default) | ||
| 140 | // 2: about 75kbps | ||
| 141 | // 3: about 39kbps | ||
| 142 | // 4: about 26kbps | ||
| 143 | // 5: about 20kbps | ||
| 144 | #endif | ||
| 145 | |||
| 146 | #if __GNUC__ < 6 | ||
| 147 | #define TID_SEND_ADJUST 14 | ||
| 148 | #else | ||
| 149 | #define TID_SEND_ADJUST 2 | ||
| 150 | #endif | ||
| 151 | |||
| 152 | #if SELECT_SOFT_SERIAL_SPEED == 0 | ||
| 153 | // Very High speed | ||
| 154 | #define SERIAL_DELAY 4 // micro sec | ||
| 155 | #if __GNUC__ < 6 | ||
| 156 | #define READ_WRITE_START_ADJUST 33 // cycles | ||
| 157 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 158 | #else | ||
| 159 | #define READ_WRITE_START_ADJUST 34 // cycles | ||
| 160 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 161 | #endif | ||
| 162 | #elif SELECT_SOFT_SERIAL_SPEED == 1 | ||
| 163 | // High speed | ||
| 164 | #define SERIAL_DELAY 6 // micro sec | ||
| 165 | #if __GNUC__ < 6 | ||
| 166 | #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 167 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 168 | #else | ||
| 169 | #define READ_WRITE_START_ADJUST 33 // cycles | ||
| 170 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 171 | #endif | ||
| 172 | #elif SELECT_SOFT_SERIAL_SPEED == 2 | ||
| 173 | // Middle speed | ||
| 174 | #define SERIAL_DELAY 12 // micro sec | ||
| 175 | #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 176 | #if __GNUC__ < 6 | ||
| 177 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 178 | #else | ||
| 179 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 180 | #endif | ||
| 181 | #elif SELECT_SOFT_SERIAL_SPEED == 3 | ||
| 182 | // Low speed | ||
| 183 | #define SERIAL_DELAY 24 // micro sec | ||
| 184 | #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 185 | #if __GNUC__ < 6 | ||
| 186 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 187 | #else | ||
| 188 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 189 | #endif | ||
| 190 | #elif SELECT_SOFT_SERIAL_SPEED == 4 | ||
| 191 | // Very Low speed | ||
| 192 | #define SERIAL_DELAY 36 // micro sec | ||
| 193 | #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 194 | #if __GNUC__ < 6 | ||
| 195 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 196 | #else | ||
| 197 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 198 | #endif | ||
| 199 | #elif SELECT_SOFT_SERIAL_SPEED == 5 | ||
| 200 | // Ultra Low speed | ||
| 201 | #define SERIAL_DELAY 48 // micro sec | ||
| 202 | #define READ_WRITE_START_ADJUST 30 // cycles | ||
| 203 | #if __GNUC__ < 6 | ||
| 204 | #define READ_WRITE_WIDTH_ADJUST 3 // cycles | ||
| 205 | #else | ||
| 206 | #define READ_WRITE_WIDTH_ADJUST 7 // cycles | ||
| 207 | #endif | ||
| 208 | #else | ||
| 209 | #error invalid SELECT_SOFT_SERIAL_SPEED value | ||
| 210 | #endif /* SELECT_SOFT_SERIAL_SPEED */ | ||
| 211 | #endif /* SERIAL_DELAY */ | ||
| 212 | |||
| 213 | #define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2) | ||
| 214 | #define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2) | ||
| 215 | |||
| 216 | #define SLAVE_INT_WIDTH_US 1 | ||
| 217 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 218 | #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY | ||
| 219 | #else | ||
| 220 | #define SLAVE_INT_ACK_WIDTH_UNIT 2 | ||
| 221 | #define SLAVE_INT_ACK_WIDTH 4 | ||
| 222 | #endif | ||
| 223 | |||
| 224 | static SSTD_t *Transaction_table = NULL; | ||
| 225 | static uint8_t Transaction_table_size = 0; | ||
| 226 | |||
| 227 | inline static void serial_delay(void) ALWAYS_INLINE; | ||
| 228 | inline static | ||
| 229 | void serial_delay(void) { | ||
| 230 | _delay_us(SERIAL_DELAY); | ||
| 231 | } | ||
| 232 | |||
| 233 | inline static void serial_delay_half1(void) ALWAYS_INLINE; | ||
| 234 | inline static | ||
| 235 | void serial_delay_half1(void) { | ||
| 236 | _delay_us(SERIAL_DELAY_HALF1); | ||
| 237 | } | ||
| 238 | |||
| 239 | inline static void serial_delay_half2(void) ALWAYS_INLINE; | ||
| 240 | inline static | ||
| 241 | void serial_delay_half2(void) { | ||
| 242 | _delay_us(SERIAL_DELAY_HALF2); | ||
| 243 | } | ||
| 244 | |||
| 245 | inline static void serial_output(void) ALWAYS_INLINE; | ||
| 246 | inline static | ||
| 247 | void serial_output(void) { | ||
| 248 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
| 249 | } | ||
| 250 | |||
| 251 | // make the serial pin an input with pull-up resistor | ||
| 252 | inline static void serial_input_with_pullup(void) ALWAYS_INLINE; | ||
| 253 | inline static | ||
| 254 | void serial_input_with_pullup(void) { | ||
| 255 | SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; | ||
| 256 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
| 257 | } | ||
| 258 | |||
| 259 | inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; | ||
| 260 | inline static | ||
| 261 | uint8_t serial_read_pin(void) { | ||
| 262 | return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); | ||
| 263 | } | ||
| 264 | |||
| 265 | inline static void serial_low(void) ALWAYS_INLINE; | ||
| 266 | inline static | ||
| 267 | void serial_low(void) { | ||
| 268 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
| 269 | } | ||
| 270 | |||
| 271 | inline static void serial_high(void) ALWAYS_INLINE; | ||
| 272 | inline static | ||
| 273 | void serial_high(void) { | ||
| 274 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
| 275 | } | ||
| 276 | |||
| 277 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) | ||
| 278 | { | ||
| 279 | Transaction_table = sstd_table; | ||
| 280 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
| 281 | serial_output(); | ||
| 282 | serial_high(); | ||
| 283 | } | ||
| 284 | |||
| 285 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) | ||
| 286 | { | ||
| 287 | Transaction_table = sstd_table; | ||
| 288 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
| 289 | serial_input_with_pullup(); | ||
| 290 | |||
| 291 | // Enable INT0-INT3,INT6 | ||
| 292 | EIMSK |= EIMSK_BIT; | ||
| 293 | #if SERIAL_PIN_MASK == _BV(PE6) | ||
| 294 | // Trigger on falling edge of INT6 | ||
| 295 | EICRB &= EICRx_BIT; | ||
| 296 | #else | ||
| 297 | // Trigger on falling edge of INT0-INT3 | ||
| 298 | EICRA &= EICRx_BIT; | ||
| 299 | #endif | ||
| 300 | } | ||
| 301 | |||
| 302 | // Used by the sender to synchronize timing with the reciver. | ||
| 303 | static void sync_recv(void) NO_INLINE; | ||
| 304 | static | ||
| 305 | void sync_recv(void) { | ||
| 306 | for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) { | ||
| 307 | } | ||
| 308 | // This shouldn't hang if the target disconnects because the | ||
| 309 | // serial line will float to high if the target does disconnect. | ||
| 310 | while (!serial_read_pin()); | ||
| 311 | } | ||
| 312 | |||
| 313 | // Used by the reciver to send a synchronization signal to the sender. | ||
| 314 | static void sync_send(void) NO_INLINE; | ||
| 315 | static | ||
| 316 | void sync_send(void) { | ||
| 317 | serial_low(); | ||
| 318 | serial_delay(); | ||
| 319 | serial_high(); | ||
| 320 | } | ||
| 321 | |||
| 322 | // Reads a byte from the serial line | ||
| 323 | static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE; | ||
| 324 | static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) { | ||
| 325 | uint8_t byte, i, p, pb; | ||
| 326 | |||
| 327 | _delay_sub_us(READ_WRITE_START_ADJUST); | ||
| 328 | for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) { | ||
| 329 | serial_delay_half1(); // read the middle of pulses | ||
| 330 | if( serial_read_pin() ) { | ||
| 331 | byte = (byte << 1) | 1; p ^= 1; | ||
| 332 | } else { | ||
| 333 | byte = (byte << 1) | 0; p ^= 0; | ||
| 334 | } | ||
| 335 | _delay_sub_us(READ_WRITE_WIDTH_ADJUST); | ||
| 336 | serial_delay_half2(); | ||
| 337 | } | ||
| 338 | /* recive parity bit */ | ||
| 339 | serial_delay_half1(); // read the middle of pulses | ||
| 340 | pb = serial_read_pin(); | ||
| 341 | _delay_sub_us(READ_WRITE_WIDTH_ADJUST); | ||
| 342 | serial_delay_half2(); | ||
| 343 | |||
| 344 | *pterrcount += (p != pb)? 1 : 0; | ||
| 345 | |||
| 346 | return byte; | ||
| 347 | } | ||
| 348 | |||
| 349 | // Sends a byte with MSB ordering | ||
| 350 | void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE; | ||
| 351 | void serial_write_chunk(uint8_t data, uint8_t bit) { | ||
| 352 | uint8_t b, p; | ||
| 353 | for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) { | ||
| 354 | if(data & b) { | ||
| 355 | serial_high(); p ^= 1; | ||
| 356 | } else { | ||
| 357 | serial_low(); p ^= 0; | ||
| 358 | } | ||
| 359 | serial_delay(); | ||
| 360 | } | ||
| 361 | /* send parity bit */ | ||
| 362 | if(p & 1) { serial_high(); } | ||
| 363 | else { serial_low(); } | ||
| 364 | serial_delay(); | ||
| 365 | |||
| 366 | serial_low(); // sync_send() / senc_recv() need raise edge | ||
| 367 | } | ||
| 368 | |||
| 369 | static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE; | ||
| 370 | static | ||
| 371 | void serial_send_packet(uint8_t *buffer, uint8_t size) { | ||
| 372 | for (uint8_t i = 0; i < size; ++i) { | ||
| 373 | uint8_t data; | ||
| 374 | data = buffer[i]; | ||
| 375 | sync_send(); | ||
| 376 | serial_write_chunk(data,8); | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE; | ||
| 381 | static | ||
| 382 | uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) { | ||
| 383 | uint8_t pecount = 0; | ||
| 384 | for (uint8_t i = 0; i < size; ++i) { | ||
| 385 | uint8_t data; | ||
| 386 | sync_recv(); | ||
| 387 | data = serial_read_chunk(&pecount, 8); | ||
| 388 | buffer[i] = data; | ||
| 389 | } | ||
| 390 | return pecount == 0; | ||
| 391 | } | ||
| 392 | |||
| 393 | inline static | ||
| 394 | void change_sender2reciver(void) { | ||
| 395 | sync_send(); //0 | ||
| 396 | serial_delay_half1(); //1 | ||
| 397 | serial_low(); //2 | ||
| 398 | serial_input_with_pullup(); //2 | ||
| 399 | serial_delay_half1(); //3 | ||
| 400 | } | ||
| 401 | |||
| 402 | inline static | ||
| 403 | void change_reciver2sender(void) { | ||
| 404 | sync_recv(); //0 | ||
| 405 | serial_delay(); //1 | ||
| 406 | serial_low(); //3 | ||
| 407 | serial_output(); //3 | ||
| 408 | serial_delay_half1(); //4 | ||
| 409 | } | ||
| 410 | |||
| 411 | static inline uint8_t nibble_bits_count(uint8_t bits) | ||
| 412 | { | ||
| 413 | bits = (bits & 0x5) + (bits >> 1 & 0x5); | ||
| 414 | bits = (bits & 0x3) + (bits >> 2 & 0x3); | ||
| 415 | return bits; | ||
| 416 | } | ||
| 417 | |||
| 418 | // interrupt handle to be used by the target device | ||
| 419 | ISR(SERIAL_PIN_INTERRUPT) { | ||
| 420 | |||
| 421 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 422 | serial_low(); | ||
| 423 | serial_output(); | ||
| 424 | SSTD_t *trans = Transaction_table; | ||
| 425 | #else | ||
| 426 | // recive transaction table index | ||
| 427 | uint8_t tid, bits; | ||
| 428 | uint8_t pecount = 0; | ||
| 429 | sync_recv(); | ||
| 430 | bits = serial_read_chunk(&pecount,7); | ||
| 431 | tid = bits>>3; | ||
| 432 | bits = (bits&7) != nibble_bits_count(tid); | ||
| 433 | if( bits || pecount> 0 || tid > Transaction_table_size ) { | ||
| 434 | return; | ||
| 435 | } | ||
| 436 | serial_delay_half1(); | ||
| 437 | |||
| 438 | serial_high(); // response step1 low->high | ||
| 439 | serial_output(); | ||
| 440 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH); | ||
| 441 | SSTD_t *trans = &Transaction_table[tid]; | ||
| 442 | serial_low(); // response step2 ack high->low | ||
| 443 | #endif | ||
| 444 | |||
| 445 | // target send phase | ||
| 446 | if( trans->target2initiator_buffer_size > 0 ) | ||
| 447 | serial_send_packet((uint8_t *)trans->target2initiator_buffer, | ||
| 448 | trans->target2initiator_buffer_size); | ||
| 449 | // target switch to input | ||
| 450 | change_sender2reciver(); | ||
| 451 | |||
| 452 | // target recive phase | ||
| 453 | if( trans->initiator2target_buffer_size > 0 ) { | ||
| 454 | if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer, | ||
| 455 | trans->initiator2target_buffer_size) ) { | ||
| 456 | *trans->status = TRANSACTION_ACCEPTED; | ||
| 457 | } else { | ||
| 458 | *trans->status = TRANSACTION_DATA_ERROR; | ||
| 459 | } | ||
| 460 | } else { | ||
| 461 | *trans->status = TRANSACTION_ACCEPTED; | ||
| 462 | } | ||
| 463 | |||
| 464 | sync_recv(); //weit initiator output to high | ||
| 465 | } | ||
| 466 | |||
| 467 | ///////// | ||
| 468 | // start transaction by initiator | ||
| 469 | // | ||
| 470 | // int soft_serial_transaction(int sstd_index) | ||
| 471 | // | ||
| 472 | // Returns: | ||
| 473 | // TRANSACTION_END | ||
| 474 | // TRANSACTION_NO_RESPONSE | ||
| 475 | // TRANSACTION_DATA_ERROR | ||
| 476 | // this code is very time dependent, so we need to disable interrupts | ||
| 477 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 478 | int soft_serial_transaction(void) { | ||
| 479 | SSTD_t *trans = Transaction_table; | ||
| 480 | #else | ||
| 481 | int soft_serial_transaction(int sstd_index) { | ||
| 482 | if( sstd_index > Transaction_table_size ) | ||
| 483 | return TRANSACTION_TYPE_ERROR; | ||
| 484 | SSTD_t *trans = &Transaction_table[sstd_index]; | ||
| 485 | #endif | ||
| 486 | cli(); | ||
| 487 | |||
| 488 | // signal to the target that we want to start a transaction | ||
| 489 | serial_output(); | ||
| 490 | serial_low(); | ||
| 491 | _delay_us(SLAVE_INT_WIDTH_US); | ||
| 492 | |||
| 493 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 494 | // wait for the target response | ||
| 495 | serial_input_with_pullup(); | ||
| 496 | _delay_us(SLAVE_INT_RESPONSE_TIME); | ||
| 497 | |||
| 498 | // check if the target is present | ||
| 499 | if (serial_read_pin()) { | ||
| 500 | // target failed to pull the line low, assume not present | ||
| 501 | serial_output(); | ||
| 502 | serial_high(); | ||
| 503 | *trans->status = TRANSACTION_NO_RESPONSE; | ||
| 504 | sei(); | ||
| 505 | return TRANSACTION_NO_RESPONSE; | ||
| 506 | } | ||
| 507 | |||
| 508 | #else | ||
| 509 | // send transaction table index | ||
| 510 | int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index)); | ||
| 511 | sync_send(); | ||
| 512 | _delay_sub_us(TID_SEND_ADJUST); | ||
| 513 | serial_write_chunk(tid, 7); | ||
| 514 | serial_delay_half1(); | ||
| 515 | |||
| 516 | // wait for the target response (step1 low->high) | ||
| 517 | serial_input_with_pullup(); | ||
| 518 | while( !serial_read_pin() ) { | ||
| 519 | _delay_sub_us(2); | ||
| 520 | } | ||
| 521 | |||
| 522 | // check if the target is present (step2 high->low) | ||
| 523 | for( int i = 0; serial_read_pin(); i++ ) { | ||
| 524 | if (i > SLAVE_INT_ACK_WIDTH + 1) { | ||
| 525 | // slave failed to pull the line low, assume not present | ||
| 526 | serial_output(); | ||
| 527 | serial_high(); | ||
| 528 | *trans->status = TRANSACTION_NO_RESPONSE; | ||
| 529 | sei(); | ||
| 530 | return TRANSACTION_NO_RESPONSE; | ||
| 531 | } | ||
| 532 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT); | ||
| 533 | } | ||
| 534 | #endif | ||
| 535 | |||
| 536 | // initiator recive phase | ||
| 537 | // if the target is present syncronize with it | ||
| 538 | if( trans->target2initiator_buffer_size > 0 ) { | ||
| 539 | if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer, | ||
| 540 | trans->target2initiator_buffer_size) ) { | ||
| 541 | serial_output(); | ||
| 542 | serial_high(); | ||
| 543 | *trans->status = TRANSACTION_DATA_ERROR; | ||
| 544 | sei(); | ||
| 545 | return TRANSACTION_DATA_ERROR; | ||
| 546 | } | ||
| 547 | } | ||
| 548 | |||
| 549 | // initiator switch to output | ||
| 550 | change_reciver2sender(); | ||
| 551 | |||
| 552 | // initiator send phase | ||
| 553 | if( trans->initiator2target_buffer_size > 0 ) { | ||
| 554 | serial_send_packet((uint8_t *)trans->initiator2target_buffer, | ||
| 555 | trans->initiator2target_buffer_size); | ||
| 556 | } | ||
| 557 | |||
| 558 | // always, release the line when not in use | ||
| 559 | sync_send(); | ||
| 560 | |||
| 561 | *trans->status = TRANSACTION_END; | ||
| 562 | sei(); | ||
| 563 | return TRANSACTION_END; | ||
| 564 | } | ||
| 565 | |||
| 566 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
| 567 | int soft_serial_get_and_clean_status(int sstd_index) { | ||
| 568 | SSTD_t *trans = &Transaction_table[sstd_index]; | ||
| 569 | cli(); | ||
| 570 | int retval = *trans->status; | ||
| 571 | *trans->status = 0;; | ||
| 572 | sei(); | ||
| 573 | return retval; | ||
| 574 | } | ||
| 575 | #endif | ||
| 576 | |||
| 577 | #endif | ||
| 578 | |||
| 579 | // Helix serial.c history | ||
| 580 | // 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc) | ||
| 581 | // 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4) | ||
| 582 | // (adjusted with avr-gcc 4.9.2) | ||
| 583 | // 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78) | ||
| 584 | // (adjusted with avr-gcc 4.9.2) | ||
| 585 | // 2018-8-11 add support multi-type transaction (#3608, feb5e4aae) | ||
| 586 | // (adjusted with avr-gcc 4.9.2) | ||
| 587 | // 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff) | ||
| 588 | // (adjusted with avr-gcc 7.3.0) | ||
| 589 | // 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66) | ||
| 590 | // (adjusted with avr-gcc 5.4.0, 7.3.0) | ||
diff --git a/keyboards/helix/local_drivers/serial.h b/keyboards/helix/local_drivers/serial.h new file mode 100644 index 000000000..2e53928df --- /dev/null +++ b/keyboards/helix/local_drivers/serial.h | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | #ifndef SOFT_SERIAL_H | ||
| 2 | #define SOFT_SERIAL_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | |||
| 6 | // ///////////////////////////////////////////////////////////////// | ||
| 7 | // Need Soft Serial defines in config.h | ||
| 8 | // ///////////////////////////////////////////////////////////////// | ||
| 9 | // ex. | ||
| 10 | // #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 | ||
| 11 | // OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 | ||
| 12 | // // 1: about 137kbps (default) | ||
| 13 | // // 2: about 75kbps | ||
| 14 | // // 3: about 39kbps | ||
| 15 | // // 4: about 26kbps | ||
| 16 | // // 5: about 20kbps | ||
| 17 | // | ||
| 18 | // //// USE OLD API (compatible with let's split serial.c) | ||
| 19 | // ex. | ||
| 20 | // #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
| 21 | // #define SERIAL_MASTER_BUFFER_LENGTH 1 | ||
| 22 | // | ||
| 23 | // //// USE NEW API | ||
| 24 | // //// USE simple API (using signle-type transaction function) | ||
| 25 | // #define SERIAL_USE_SINGLE_TRANSACTION | ||
| 26 | // //// USE flexible API (using multi-type transaction function) | ||
| 27 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
| 28 | // | ||
| 29 | // ///////////////////////////////////////////////////////////////// | ||
| 30 | |||
| 31 | |||
| 32 | //////////////// for backward compatibility //////////////////////////////// | ||
| 33 | #if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) | ||
| 34 | /* --- USE OLD API (compatible with let's split serial.c) */ | ||
| 35 | #if SERIAL_SLAVE_BUFFER_LENGTH > 0 | ||
| 36 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
| 37 | #endif | ||
| 38 | #if SERIAL_MASTER_BUFFER_LENGTH > 0 | ||
| 39 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
| 40 | #endif | ||
| 41 | |||
| 42 | void serial_master_init(void); | ||
| 43 | void serial_slave_init(void); | ||
| 44 | int serial_update_buffers(void); | ||
| 45 | |||
| 46 | #endif // end of USE OLD API | ||
| 47 | //////////////////////////////////////////////////////////////////////////// | ||
| 48 | |||
| 49 | // Soft Serial Transaction Descriptor | ||
| 50 | typedef struct _SSTD_t { | ||
| 51 | uint8_t *status; | ||
| 52 | uint8_t initiator2target_buffer_size; | ||
| 53 | uint8_t *initiator2target_buffer; | ||
| 54 | uint8_t target2initiator_buffer_size; | ||
| 55 | uint8_t *target2initiator_buffer; | ||
| 56 | } SSTD_t; | ||
| 57 | #define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t)) | ||
| 58 | |||
| 59 | // initiator is transaction start side | ||
| 60 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); | ||
| 61 | // target is interrupt accept side | ||
| 62 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); | ||
| 63 | |||
| 64 | // initiator resullt | ||
| 65 | #define TRANSACTION_END 0 | ||
| 66 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
| 67 | #define TRANSACTION_DATA_ERROR 0x2 | ||
| 68 | #define TRANSACTION_TYPE_ERROR 0x4 | ||
| 69 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 70 | int soft_serial_transaction(void); | ||
| 71 | #else | ||
| 72 | int soft_serial_transaction(int sstd_index); | ||
| 73 | #endif | ||
| 74 | |||
| 75 | // target status | ||
| 76 | // *SSTD_t.status has | ||
| 77 | // initiator: | ||
| 78 | // TRANSACTION_END | ||
| 79 | // or TRANSACTION_NO_RESPONSE | ||
| 80 | // or TRANSACTION_DATA_ERROR | ||
| 81 | // target: | ||
| 82 | // TRANSACTION_DATA_ERROR | ||
| 83 | // or TRANSACTION_ACCEPTED | ||
| 84 | #define TRANSACTION_ACCEPTED 0x8 | ||
| 85 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
| 86 | int soft_serial_get_and_clean_status(int sstd_index); | ||
| 87 | #endif | ||
| 88 | |||
| 89 | #endif /* SOFT_SERIAL_H */ | ||
diff --git a/keyboards/helix/local_drivers/ssd1306.c b/keyboards/helix/local_drivers/ssd1306.c new file mode 100644 index 000000000..dd3290ba0 --- /dev/null +++ b/keyboards/helix/local_drivers/ssd1306.c | |||
| @@ -0,0 +1,342 @@ | |||
| 1 | |||
| 2 | #ifdef SSD1306OLED | ||
| 3 | |||
| 4 | #include "ssd1306.h" | ||
| 5 | #include "i2c.h" | ||
| 6 | #include <string.h> | ||
| 7 | #include "print.h" | ||
| 8 | #ifndef LOCAL_GLCDFONT | ||
| 9 | #include "common/glcdfont.c" | ||
| 10 | #else | ||
| 11 | #include <helixfont.h> | ||
| 12 | #endif | ||
| 13 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 14 | #include "adafruit_ble.h" | ||
| 15 | #endif | ||
| 16 | #ifdef PROTOCOL_LUFA | ||
| 17 | #include "lufa.h" | ||
| 18 | #endif | ||
| 19 | #include "sendchar.h" | ||
| 20 | #include "timer.h" | ||
| 21 | |||
| 22 | // Set this to 1 to help diagnose early startup problems | ||
| 23 | // when testing power-on with ble. Turn it off otherwise, | ||
| 24 | // as the latency of printing most of the debug info messes | ||
| 25 | // with the matrix scan, causing keys to drop. | ||
| 26 | #define DEBUG_TO_SCREEN 0 | ||
| 27 | |||
| 28 | //static uint16_t last_battery_update; | ||
| 29 | //static uint32_t vbat; | ||
| 30 | //#define BatteryUpdateInterval 10000 /* milliseconds */ | ||
| 31 | |||
| 32 | // 'last_flush' is declared as uint16_t, | ||
| 33 | // so this must be less than 65535 | ||
| 34 | #define ScreenOffInterval 60000 /* milliseconds */ | ||
| 35 | #if DEBUG_TO_SCREEN | ||
| 36 | static uint8_t displaying; | ||
| 37 | #endif | ||
| 38 | static uint16_t last_flush; | ||
| 39 | |||
| 40 | static bool force_dirty = true; | ||
| 41 | |||
| 42 | // Write command sequence. | ||
| 43 | // Returns true on success. | ||
| 44 | static inline bool _send_cmd1(uint8_t cmd) { | ||
| 45 | bool res = false; | ||
| 46 | |||
| 47 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 48 | xprintf("failed to start write to %d\n", SSD1306_ADDRESS); | ||
| 49 | goto done; | ||
| 50 | } | ||
| 51 | |||
| 52 | if (i2c_master_write(0x0 /* command byte follows */)) { | ||
| 53 | print("failed to write control byte\n"); | ||
| 54 | |||
| 55 | goto done; | ||
| 56 | } | ||
| 57 | |||
| 58 | if (i2c_master_write(cmd)) { | ||
| 59 | xprintf("failed to write command %d\n", cmd); | ||
| 60 | goto done; | ||
| 61 | } | ||
| 62 | res = true; | ||
| 63 | done: | ||
| 64 | i2c_master_stop(); | ||
| 65 | return res; | ||
| 66 | } | ||
| 67 | |||
| 68 | // Write 2-byte command sequence. | ||
| 69 | // Returns true on success | ||
| 70 | static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { | ||
| 71 | if (!_send_cmd1(cmd)) { | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | return _send_cmd1(opr); | ||
| 75 | } | ||
| 76 | |||
| 77 | // Write 3-byte command sequence. | ||
| 78 | // Returns true on success | ||
| 79 | static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { | ||
| 80 | if (!_send_cmd1(cmd)) { | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | if (!_send_cmd1(opr1)) { | ||
| 84 | return false; | ||
| 85 | } | ||
| 86 | return _send_cmd1(opr2); | ||
| 87 | } | ||
| 88 | |||
| 89 | #define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} | ||
| 90 | #define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} | ||
| 91 | #define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} | ||
| 92 | |||
| 93 | static void clear_display(void) { | ||
| 94 | matrix_clear(&display); | ||
| 95 | |||
| 96 | // Clear all of the display bits (there can be random noise | ||
| 97 | // in the RAM on startup) | ||
| 98 | send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); | ||
| 99 | send_cmd3(ColumnAddr, 0, DisplayWidth - 1); | ||
| 100 | |||
| 101 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 102 | goto done; | ||
| 103 | } | ||
| 104 | if (i2c_master_write(0x40)) { | ||
| 105 | // Data mode | ||
| 106 | goto done; | ||
| 107 | } | ||
| 108 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
| 109 | for (uint8_t col = 0; col < DisplayWidth; ++col) { | ||
| 110 | i2c_master_write(0); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | display.dirty = false; | ||
| 115 | |||
| 116 | done: | ||
| 117 | i2c_master_stop(); | ||
| 118 | } | ||
| 119 | |||
| 120 | #if DEBUG_TO_SCREEN | ||
| 121 | #undef sendchar | ||
| 122 | static int8_t capture_sendchar(uint8_t c) { | ||
| 123 | sendchar(c); | ||
| 124 | iota_gfx_write_char(c); | ||
| 125 | |||
| 126 | if (!displaying) { | ||
| 127 | iota_gfx_flush(); | ||
| 128 | } | ||
| 129 | return 0; | ||
| 130 | } | ||
| 131 | #endif | ||
| 132 | |||
| 133 | bool iota_gfx_init(bool rotate) { | ||
| 134 | bool success = false; | ||
| 135 | |||
| 136 | i2c_master_init(); | ||
| 137 | send_cmd1(DisplayOff); | ||
| 138 | send_cmd2(SetDisplayClockDiv, 0x80); | ||
| 139 | send_cmd2(SetMultiPlex, DisplayHeight - 1); | ||
| 140 | |||
| 141 | send_cmd2(SetDisplayOffset, 0); | ||
| 142 | |||
| 143 | |||
| 144 | send_cmd1(SetStartLine | 0x0); | ||
| 145 | send_cmd2(SetChargePump, 0x14 /* Enable */); | ||
| 146 | send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); | ||
| 147 | |||
| 148 | if(rotate){ | ||
| 149 | // the following Flip the display orientation 180 degrees | ||
| 150 | send_cmd1(SegRemap); | ||
| 151 | send_cmd1(ComScanInc); | ||
| 152 | }else{ | ||
| 153 | // Flips the display orientation 0 degrees | ||
| 154 | send_cmd1(SegRemap | 0x1); | ||
| 155 | send_cmd1(ComScanDec); | ||
| 156 | } | ||
| 157 | |||
| 158 | send_cmd2(SetComPins, 0x2); | ||
| 159 | send_cmd2(SetContrast, 0x8f); | ||
| 160 | send_cmd2(SetPreCharge, 0xf1); | ||
| 161 | send_cmd2(SetVComDetect, 0x40); | ||
| 162 | send_cmd1(DisplayAllOnResume); | ||
| 163 | send_cmd1(NormalDisplay); | ||
| 164 | send_cmd1(DeActivateScroll); | ||
| 165 | send_cmd1(DisplayOn); | ||
| 166 | |||
| 167 | send_cmd2(SetContrast, 0); // Dim | ||
| 168 | |||
| 169 | clear_display(); | ||
| 170 | |||
| 171 | success = true; | ||
| 172 | |||
| 173 | iota_gfx_flush(); | ||
| 174 | |||
| 175 | #if DEBUG_TO_SCREEN | ||
| 176 | print_set_sendchar(capture_sendchar); | ||
| 177 | #endif | ||
| 178 | |||
| 179 | done: | ||
| 180 | return success; | ||
| 181 | } | ||
| 182 | |||
| 183 | bool iota_gfx_off(void) { | ||
| 184 | bool success = false; | ||
| 185 | |||
| 186 | send_cmd1(DisplayOff); | ||
| 187 | success = true; | ||
| 188 | |||
| 189 | done: | ||
| 190 | return success; | ||
| 191 | } | ||
| 192 | |||
| 193 | bool iota_gfx_on(void) { | ||
| 194 | bool success = false; | ||
| 195 | |||
| 196 | send_cmd1(DisplayOn); | ||
| 197 | success = true; | ||
| 198 | |||
| 199 | done: | ||
| 200 | return success; | ||
| 201 | } | ||
| 202 | |||
| 203 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { | ||
| 204 | *matrix->cursor = c; | ||
| 205 | ++matrix->cursor; | ||
| 206 | |||
| 207 | if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { | ||
| 208 | // We went off the end; scroll the display upwards by one line | ||
| 209 | memmove(&matrix->display[0], &matrix->display[1], | ||
| 210 | MatrixCols * (MatrixRows - 1)); | ||
| 211 | matrix->cursor = &matrix->display[MatrixRows - 1][0]; | ||
| 212 | memset(matrix->cursor, ' ', MatrixCols); | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { | ||
| 217 | matrix->dirty = true; | ||
| 218 | |||
| 219 | if (c == '\n') { | ||
| 220 | // Clear to end of line from the cursor and then move to the | ||
| 221 | // start of the next line | ||
| 222 | uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; | ||
| 223 | |||
| 224 | while (cursor_col++ < MatrixCols) { | ||
| 225 | matrix_write_char_inner(matrix, ' '); | ||
| 226 | } | ||
| 227 | return; | ||
| 228 | } | ||
| 229 | |||
| 230 | matrix_write_char_inner(matrix, c); | ||
| 231 | } | ||
| 232 | |||
| 233 | void iota_gfx_write_char(uint8_t c) { | ||
| 234 | matrix_write_char(&display, c); | ||
| 235 | } | ||
| 236 | |||
| 237 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { | ||
| 238 | const char *end = data + strlen(data); | ||
| 239 | while (data < end) { | ||
| 240 | matrix_write_char(matrix, *data); | ||
| 241 | ++data; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | void iota_gfx_write(const char *data) { | ||
| 246 | matrix_write(&display, data); | ||
| 247 | } | ||
| 248 | |||
| 249 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | ||
| 250 | while (true) { | ||
| 251 | uint8_t c = pgm_read_byte(data); | ||
| 252 | if (c == 0) { | ||
| 253 | return; | ||
| 254 | } | ||
| 255 | matrix_write_char(matrix, c); | ||
| 256 | ++data; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | void iota_gfx_write_P(const char *data) { | ||
| 261 | matrix_write_P(&display, data); | ||
| 262 | } | ||
| 263 | |||
| 264 | void matrix_clear(struct CharacterMatrix *matrix) { | ||
| 265 | memset(matrix->display, ' ', sizeof(matrix->display)); | ||
| 266 | matrix->cursor = &matrix->display[0][0]; | ||
| 267 | matrix->dirty = true; | ||
| 268 | } | ||
| 269 | |||
| 270 | void iota_gfx_clear_screen(void) { | ||
| 271 | matrix_clear(&display); | ||
| 272 | } | ||
| 273 | |||
| 274 | void matrix_render(struct CharacterMatrix *matrix) { | ||
| 275 | last_flush = timer_read(); | ||
| 276 | iota_gfx_on(); | ||
| 277 | #if DEBUG_TO_SCREEN | ||
| 278 | ++displaying; | ||
| 279 | #endif | ||
| 280 | |||
| 281 | // Move to the home position | ||
| 282 | send_cmd3(PageAddr, 0, MatrixRows - 1); | ||
| 283 | send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); | ||
| 284 | |||
| 285 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 286 | goto done; | ||
| 287 | } | ||
| 288 | if (i2c_master_write(0x40)) { | ||
| 289 | // Data mode | ||
| 290 | goto done; | ||
| 291 | } | ||
| 292 | |||
| 293 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
| 294 | for (uint8_t col = 0; col < MatrixCols; ++col) { | ||
| 295 | const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); | ||
| 296 | |||
| 297 | for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { | ||
| 298 | uint8_t colBits = pgm_read_byte(glyph + glyphCol); | ||
| 299 | i2c_master_write(colBits); | ||
| 300 | } | ||
| 301 | |||
| 302 | // 1 column of space between chars (it's not included in the glyph) | ||
| 303 | //i2c_master_write(0); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | matrix->dirty = false; | ||
| 308 | |||
| 309 | done: | ||
| 310 | i2c_master_stop(); | ||
| 311 | #if DEBUG_TO_SCREEN | ||
| 312 | --displaying; | ||
| 313 | #endif | ||
| 314 | } | ||
| 315 | |||
| 316 | void iota_gfx_flush(void) { | ||
| 317 | matrix_render(&display); | ||
| 318 | } | ||
| 319 | |||
| 320 | __attribute__ ((weak)) | ||
| 321 | void iota_gfx_task_user(void) { | ||
| 322 | } | ||
| 323 | |||
| 324 | void iota_gfx_task(void) { | ||
| 325 | iota_gfx_task_user(); | ||
| 326 | |||
| 327 | if (display.dirty|| force_dirty) { | ||
| 328 | iota_gfx_flush(); | ||
| 329 | force_dirty = false; | ||
| 330 | } | ||
| 331 | |||
| 332 | if (timer_elapsed(last_flush) > ScreenOffInterval) { | ||
| 333 | iota_gfx_off(); | ||
| 334 | } | ||
| 335 | } | ||
| 336 | |||
| 337 | bool process_record_gfx(uint16_t keycode, keyrecord_t *record) { | ||
| 338 | force_dirty = true; | ||
| 339 | return true; | ||
| 340 | } | ||
| 341 | |||
| 342 | #endif | ||
diff --git a/keyboards/helix/local_drivers/ssd1306.h b/keyboards/helix/local_drivers/ssd1306.h new file mode 100644 index 000000000..9cf6983b7 --- /dev/null +++ b/keyboards/helix/local_drivers/ssd1306.h | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | #ifndef SSD1306_H | ||
| 2 | #define SSD1306_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include <stdio.h> | ||
| 6 | #include "pincontrol.h" | ||
| 7 | #include "action.h" | ||
| 8 | |||
| 9 | enum ssd1306_cmds { | ||
| 10 | DisplayOff = 0xAE, | ||
| 11 | DisplayOn = 0xAF, | ||
| 12 | |||
| 13 | SetContrast = 0x81, | ||
| 14 | DisplayAllOnResume = 0xA4, | ||
| 15 | |||
| 16 | DisplayAllOn = 0xA5, | ||
| 17 | NormalDisplay = 0xA6, | ||
| 18 | InvertDisplay = 0xA7, | ||
| 19 | SetDisplayOffset = 0xD3, | ||
| 20 | SetComPins = 0xda, | ||
| 21 | SetVComDetect = 0xdb, | ||
| 22 | SetDisplayClockDiv = 0xD5, | ||
| 23 | SetPreCharge = 0xd9, | ||
| 24 | SetMultiPlex = 0xa8, | ||
| 25 | SetLowColumn = 0x00, | ||
| 26 | SetHighColumn = 0x10, | ||
| 27 | SetStartLine = 0x40, | ||
| 28 | |||
| 29 | SetMemoryMode = 0x20, | ||
| 30 | ColumnAddr = 0x21, | ||
| 31 | PageAddr = 0x22, | ||
| 32 | |||
| 33 | ComScanInc = 0xc0, | ||
| 34 | ComScanDec = 0xc8, | ||
| 35 | SegRemap = 0xa0, | ||
| 36 | SetChargePump = 0x8d, | ||
| 37 | ExternalVcc = 0x01, | ||
| 38 | SwitchCapVcc = 0x02, | ||
| 39 | |||
| 40 | ActivateScroll = 0x2f, | ||
| 41 | DeActivateScroll = 0x2e, | ||
| 42 | SetVerticalScrollArea = 0xa3, | ||
| 43 | RightHorizontalScroll = 0x26, | ||
| 44 | LeftHorizontalScroll = 0x27, | ||
| 45 | VerticalAndRightHorizontalScroll = 0x29, | ||
| 46 | VerticalAndLeftHorizontalScroll = 0x2a, | ||
| 47 | }; | ||
| 48 | |||
| 49 | // Controls the SSD1306 128x32 OLED display via i2c | ||
| 50 | |||
| 51 | #ifndef SSD1306_ADDRESS | ||
| 52 | #define SSD1306_ADDRESS 0x3C | ||
| 53 | #endif | ||
| 54 | |||
| 55 | #define DisplayHeight 32 | ||
| 56 | #define DisplayWidth 128 | ||
| 57 | |||
| 58 | #define FontHeight 8 | ||
| 59 | #define FontWidth 6 | ||
| 60 | |||
| 61 | #define MatrixRows (DisplayHeight / FontHeight) | ||
| 62 | #define MatrixCols (DisplayWidth / FontWidth) | ||
| 63 | |||
| 64 | struct CharacterMatrix { | ||
| 65 | uint8_t display[MatrixRows][MatrixCols]; | ||
| 66 | uint8_t *cursor; | ||
| 67 | bool dirty; | ||
| 68 | }; | ||
| 69 | |||
| 70 | struct CharacterMatrix display; | ||
| 71 | |||
| 72 | bool iota_gfx_init(bool rotate); | ||
| 73 | void iota_gfx_task(void); | ||
| 74 | bool iota_gfx_off(void); | ||
| 75 | bool iota_gfx_on(void); | ||
| 76 | void iota_gfx_flush(void); | ||
| 77 | void iota_gfx_write_char(uint8_t c); | ||
| 78 | void iota_gfx_write(const char *data); | ||
| 79 | void iota_gfx_write_P(const char *data); | ||
| 80 | void iota_gfx_clear_screen(void); | ||
| 81 | |||
| 82 | void iota_gfx_task_user(void); | ||
| 83 | |||
| 84 | void matrix_clear(struct CharacterMatrix *matrix); | ||
| 85 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); | ||
| 86 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); | ||
| 87 | void matrix_write(struct CharacterMatrix *matrix, const char *data); | ||
| 88 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); | ||
| 89 | void matrix_render(struct CharacterMatrix *matrix); | ||
| 90 | |||
| 91 | bool process_record_gfx(uint16_t keycode, keyrecord_t *record); | ||
| 92 | |||
| 93 | #endif | ||
