diff options
| author | QMK Bot <hello@qmk.fm> | 2022-02-12 10:29:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-12 18:29:31 +0000 |
| commit | 63646e8906e062d1c1de3925cba70c4e3426a855 (patch) | |
| tree | 4e91648b77b838e1125cf86331d7e84bde6d07a9 | |
| parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
Format code according to conventions (#16322)
345 files changed, 4939 insertions, 3252 deletions
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp index 86581a1a48..19310767cf 100644 --- a/drivers/bluetooth/bluefruit_le.cpp +++ b/drivers/bluetooth/bluefruit_le.cpp | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
| 31 | #ifndef BLUEFRUIT_LE_SCK_DIVISOR | 31 | #ifndef BLUEFRUIT_LE_SCK_DIVISOR |
| 32 | # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE | 32 | # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define SAMPLE_BATTERY | 35 | #define SAMPLE_BATTERY |
| @@ -77,10 +77,10 @@ struct sdep_msg { | |||
| 77 | // information here. | 77 | // information here. |
| 78 | 78 | ||
| 79 | enum queue_type { | 79 | enum queue_type { |
| 80 | QTKeyReport, // 1-byte modifier + 6-byte key report | 80 | QTKeyReport, // 1-byte modifier + 6-byte key report |
| 81 | QTConsumer, // 16-bit key code | 81 | QTConsumer, // 16-bit key code |
| 82 | #ifdef MOUSE_ENABLE | 82 | #ifdef MOUSE_ENABLE |
| 83 | QTMouseMove, // 4-byte mouse report | 83 | QTMouseMove, // 4-byte mouse report |
| 84 | #endif | 84 | #endif |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| @@ -115,8 +115,8 @@ enum sdep_type { | |||
| 115 | SdepResponse = 0x20, | 115 | SdepResponse = 0x20, |
| 116 | SdepAlert = 0x40, | 116 | SdepAlert = 0x40, |
| 117 | SdepError = 0x80, | 117 | SdepError = 0x80, |
| 118 | SdepSlaveNotReady = 0xFE, // Try again later | 118 | SdepSlaveNotReady = 0xFE, // Try again later |
| 119 | SdepSlaveOverflow = 0xFF, // You read more data than is available | 119 | SdepSlaveOverflow = 0xFF, // You read more data than is available |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | enum ble_cmd { | 122 | enum ble_cmd { |
| @@ -306,13 +306,15 @@ static bool ble_init(void) { | |||
| 306 | wait_ms(10); | 306 | wait_ms(10); |
| 307 | writePinHigh(BLUEFRUIT_LE_RST_PIN); | 307 | writePinHigh(BLUEFRUIT_LE_RST_PIN); |
| 308 | 308 | ||
| 309 | wait_ms(1000); // Give it a second to initialize | 309 | wait_ms(1000); // Give it a second to initialize |
| 310 | 310 | ||
| 311 | state.initialized = true; | 311 | state.initialized = true; |
| 312 | return state.initialized; | 312 | return state.initialized; |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | static inline uint8_t min(uint8_t a, uint8_t b) { return a < b ? a : b; } | 315 | static inline uint8_t min(uint8_t a, uint8_t b) { |
| 316 | return a < b ? a : b; | ||
| 317 | } | ||
| 316 | 318 | ||
| 317 | static bool read_response(char *resp, uint16_t resplen, bool verbose) { | 319 | static bool read_response(char *resp, uint16_t resplen, bool verbose) { |
| 318 | char *dest = resp; | 320 | char *dest = resp; |
| @@ -424,7 +426,9 @@ bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) { | |||
| 424 | return at_command(cmdbuf, resp, resplen, verbose); | 426 | return at_command(cmdbuf, resp, resplen, verbose); |
| 425 | } | 427 | } |
| 426 | 428 | ||
| 427 | bool bluefruit_le_is_connected(void) { return state.is_connected; } | 429 | bool bluefruit_le_is_connected(void) { |
| 430 | return state.is_connected; | ||
| 431 | } | ||
| 428 | 432 | ||
| 429 | bool bluefruit_le_enable_keyboard(void) { | 433 | bool bluefruit_le_enable_keyboard(void) { |
| 430 | char resbuf[128]; | 434 | char resbuf[128]; |
| @@ -671,7 +675,9 @@ void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, | |||
| 671 | } | 675 | } |
| 672 | #endif | 676 | #endif |
| 673 | 677 | ||
| 674 | uint32_t bluefruit_le_read_battery_voltage(void) { return state.vbat; } | 678 | uint32_t bluefruit_le_read_battery_voltage(void) { |
| 679 | return state.vbat; | ||
| 680 | } | ||
| 675 | 681 | ||
| 676 | bool bluefruit_le_set_mode_leds(bool on) { | 682 | bool bluefruit_le_set_mode_leds(bool on) { |
| 677 | if (!state.configured) { | 683 | if (!state.configured) { |
diff --git a/drivers/bluetooth/outputselect.c b/drivers/bluetooth/outputselect.c index 44bc4a9aa3..b986ba274e 100644 --- a/drivers/bluetooth/outputselect.c +++ b/drivers/bluetooth/outputselect.c | |||
| @@ -52,7 +52,7 @@ uint8_t auto_detect_output(void) { | |||
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | #ifdef BLUETOOTH_ENABLE | 54 | #ifdef BLUETOOTH_ENABLE |
| 55 | return OUTPUT_BLUETOOTH; // should check if BT is connected here | 55 | return OUTPUT_BLUETOOTH; // should check if BT is connected here |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | return OUTPUT_NONE; | 58 | return OUTPUT_NONE; |
diff --git a/drivers/bluetooth/rn42.c b/drivers/bluetooth/rn42.c index 2ef40bb7e0..5d497cda20 100644 --- a/drivers/bluetooth/rn42.c +++ b/drivers/bluetooth/rn42.c | |||
| @@ -61,7 +61,9 @@ static inline uint16_t rn42_consumer_usage_to_bitmap(uint16_t usage) { | |||
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void rn42_init(void) { uart_init(RN42_BAUD_RATE); } | 64 | void rn42_init(void) { |
| 65 | uart_init(RN42_BAUD_RATE); | ||
| 66 | } | ||
| 65 | 67 | ||
| 66 | void rn42_send_keyboard(report_keyboard_t *report) { | 68 | void rn42_send_keyboard(report_keyboard_t *report) { |
| 67 | uart_write(0xFD); | 69 | uart_write(0xFD); |
| @@ -81,8 +83,8 @@ void rn42_send_mouse(report_mouse_t *report) { | |||
| 81 | uart_write(report->buttons); | 83 | uart_write(report->buttons); |
| 82 | uart_write(report->x); | 84 | uart_write(report->x); |
| 83 | uart_write(report->y); | 85 | uart_write(report->y); |
| 84 | uart_write(report->v); // should try sending the wheel v here | 86 | uart_write(report->v); // should try sending the wheel v here |
| 85 | uart_write(report->h); // should try sending the wheel h here | 87 | uart_write(report->h); // should try sending the wheel h here |
| 86 | uart_write(0x00); | 88 | uart_write(0x00); |
| 87 | } | 89 | } |
| 88 | 90 | ||
diff --git a/drivers/eeprom/eeprom_driver.c b/drivers/eeprom/eeprom_driver.c index 6ce47faf7d..885cf21981 100644 --- a/drivers/eeprom/eeprom_driver.c +++ b/drivers/eeprom/eeprom_driver.c | |||
| @@ -37,11 +37,17 @@ uint32_t eeprom_read_dword(const uint32_t *addr) { | |||
| 37 | return ret; | 37 | return ret; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | void eeprom_write_byte(uint8_t *addr, uint8_t value) { eeprom_write_block(&value, addr, 1); } | 40 | void eeprom_write_byte(uint8_t *addr, uint8_t value) { |
| 41 | eeprom_write_block(&value, addr, 1); | ||
| 42 | } | ||
| 41 | 43 | ||
| 42 | void eeprom_write_word(uint16_t *addr, uint16_t value) { eeprom_write_block(&value, addr, 2); } | 44 | void eeprom_write_word(uint16_t *addr, uint16_t value) { |
| 45 | eeprom_write_block(&value, addr, 2); | ||
| 46 | } | ||
| 43 | 47 | ||
| 44 | void eeprom_write_dword(uint32_t *addr, uint32_t value) { eeprom_write_block(&value, addr, 4); } | 48 | void eeprom_write_dword(uint32_t *addr, uint32_t value) { |
| 49 | eeprom_write_block(&value, addr, 4); | ||
| 50 | } | ||
| 45 | 51 | ||
| 46 | void eeprom_update_block(const void *buf, void *addr, size_t len) { | 52 | void eeprom_update_block(const void *buf, void *addr, size_t len) { |
| 47 | uint8_t read_buf[len]; | 53 | uint8_t read_buf[len]; |
diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c index 8e80ff544f..a74a010415 100644 --- a/drivers/eeprom/eeprom_i2c.c +++ b/drivers/eeprom/eeprom_i2c.c | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) | 43 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
| 44 | # include "timer.h" | 44 | # include "timer.h" |
| 45 | # include "debug.h" | 45 | # include "debug.h" |
| 46 | #endif // DEBUG_EEPROM_OUTPUT | 46 | #endif // DEBUG_EEPROM_OUTPUT |
| 47 | 47 | ||
| 48 | static inline void fill_target_address(uint8_t *buffer, const void *addr) { | 48 | static inline void fill_target_address(uint8_t *buffer, const void *addr) { |
| 49 | uintptr_t p = (uintptr_t)addr; | 49 | uintptr_t p = (uintptr_t)addr; |
| @@ -91,7 +91,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { | |||
| 91 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); | 91 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); |
| 92 | } | 92 | } |
| 93 | dprintf("\n"); | 93 | dprintf("\n"); |
| 94 | #endif // DEBUG_EEPROM_OUTPUT | 94 | #endif // DEBUG_EEPROM_OUTPUT |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | void eeprom_write_block(const void *buf, void *addr, size_t len) { | 97 | void eeprom_write_block(const void *buf, void *addr, size_t len) { |
| @@ -122,7 +122,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 122 | dprintf(" %02X", (int)(read_buf[i])); | 122 | dprintf(" %02X", (int)(read_buf[i])); |
| 123 | } | 123 | } |
| 124 | dprintf("\n"); | 124 | dprintf("\n"); |
| 125 | #endif // DEBUG_EEPROM_OUTPUT | 125 | #endif // DEBUG_EEPROM_OUTPUT |
| 126 | 126 | ||
| 127 | i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100); | 127 | i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100); |
| 128 | wait_ms(EXTERNAL_EEPROM_WRITE_TIME); | 128 | wait_ms(EXTERNAL_EEPROM_WRITE_TIME); |
diff --git a/drivers/eeprom/eeprom_spi.c b/drivers/eeprom/eeprom_spi.c index e273090854..25955498c4 100644 --- a/drivers/eeprom/eeprom_spi.c +++ b/drivers/eeprom/eeprom_spi.c | |||
| @@ -52,7 +52,9 @@ | |||
| 52 | # define EXTERNAL_EEPROM_SPI_TIMEOUT 100 | 52 | # define EXTERNAL_EEPROM_SPI_TIMEOUT 100 |
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | static bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } | 55 | static bool spi_eeprom_start(void) { |
| 56 | return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); | ||
| 57 | } | ||
| 56 | 58 | ||
| 57 | static spi_status_t spi_eeprom_wait_while_busy(int timeout) { | 59 | static spi_status_t spi_eeprom_wait_while_busy(int timeout) { |
| 58 | uint32_t deadline = timer_read32() + timeout; | 60 | uint32_t deadline = timer_read32() + timeout; |
| @@ -80,7 +82,9 @@ static void spi_eeprom_transmit_address(uintptr_t addr) { | |||
| 80 | 82 | ||
| 81 | //---------------------------------------------------------------------------------------------------------------------- | 83 | //---------------------------------------------------------------------------------------------------------------------- |
| 82 | 84 | ||
| 83 | void eeprom_driver_init(void) { spi_init(); } | 85 | void eeprom_driver_init(void) { |
| 86 | spi_init(); | ||
| 87 | } | ||
| 84 | 88 | ||
| 85 | void eeprom_driver_erase(void) { | 89 | void eeprom_driver_erase(void) { |
| 86 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) | 90 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
| @@ -135,7 +139,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { | |||
| 135 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); | 139 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); |
| 136 | } | 140 | } |
| 137 | dprintf("\n"); | 141 | dprintf("\n"); |
| 138 | #endif // DEBUG_EEPROM_OUTPUT | 142 | #endif // DEBUG_EEPROM_OUTPUT |
| 139 | 143 | ||
| 140 | spi_stop(); | 144 | spi_stop(); |
| 141 | } | 145 | } |
| @@ -192,7 +196,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 192 | dprintf(" %02X", (int)(uint8_t)(read_buf[i])); | 196 | dprintf(" %02X", (int)(uint8_t)(read_buf[i])); |
| 193 | } | 197 | } |
| 194 | dprintf("\n"); | 198 | dprintf("\n"); |
| 195 | #endif // DEBUG_EEPROM_OUTPUT | 199 | #endif // DEBUG_EEPROM_OUTPUT |
| 196 | 200 | ||
| 197 | spi_write(CMD_WRITE); | 201 | spi_write(CMD_WRITE); |
| 198 | spi_eeprom_transmit_address(target_addr); | 202 | spi_eeprom_transmit_address(target_addr); |
diff --git a/drivers/eeprom/eeprom_transient.c b/drivers/eeprom/eeprom_transient.c index b4c78c6f40..9dc4289c27 100644 --- a/drivers/eeprom/eeprom_transient.c +++ b/drivers/eeprom/eeprom_transient.c | |||
| @@ -30,9 +30,13 @@ size_t clamp_length(intptr_t offset, size_t len) { | |||
| 30 | return len; | 30 | return len; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void eeprom_driver_init(void) { eeprom_driver_erase(); } | 33 | void eeprom_driver_init(void) { |
| 34 | eeprom_driver_erase(); | ||
| 35 | } | ||
| 34 | 36 | ||
| 35 | void eeprom_driver_erase(void) { memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); } | 37 | void eeprom_driver_erase(void) { |
| 38 | memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); | ||
| 39 | } | ||
| 36 | 40 | ||
| 37 | void eeprom_read_block(void *buf, const void *addr, size_t len) { | 41 | void eeprom_read_block(void *buf, const void *addr, size_t len) { |
| 38 | intptr_t offset = (intptr_t)addr; | 42 | intptr_t offset = (intptr_t)addr; |
diff --git a/drivers/eeprom/eeprom_transient.h b/drivers/eeprom/eeprom_transient.h index d06189b246..687b8619fe 100644 --- a/drivers/eeprom/eeprom_transient.h +++ b/drivers/eeprom/eeprom_transient.h | |||
| @@ -21,5 +21,5 @@ | |||
| 21 | */ | 21 | */ |
| 22 | #ifndef TRANSIENT_EEPROM_SIZE | 22 | #ifndef TRANSIENT_EEPROM_SIZE |
| 23 | # include "eeconfig.h" | 23 | # include "eeconfig.h" |
| 24 | # define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO | 24 | # define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO |
| 25 | #endif | 25 | #endif |
diff --git a/drivers/flash/flash_spi.c b/drivers/flash/flash_spi.c index 2fa8891e38..f4cbf65159 100644 --- a/drivers/flash/flash_spi.c +++ b/drivers/flash/flash_spi.c | |||
| @@ -65,7 +65,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 65 | 65 | ||
| 66 | // #define DEBUG_FLASH_SPI_OUTPUT | 66 | // #define DEBUG_FLASH_SPI_OUTPUT |
| 67 | 67 | ||
| 68 | static bool spi_flash_start(void) { return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR); } | 68 | static bool spi_flash_start(void) { |
| 69 | return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR); | ||
| 70 | } | ||
| 69 | 71 | ||
| 70 | static flash_status_t spi_flash_wait_while_busy(void) { | 72 | static flash_status_t spi_flash_wait_while_busy(void) { |
| 71 | uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT; | 73 | uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT; |
| @@ -160,7 +162,9 @@ static flash_status_t spi_flash_transaction(uint8_t cmd, uint32_t addr, uint8_t | |||
| 160 | return response; | 162 | return response; |
| 161 | } | 163 | } |
| 162 | 164 | ||
| 163 | void flash_init(void) { spi_init(); } | 165 | void flash_init(void) { |
| 166 | spi_init(); | ||
| 167 | } | ||
| 164 | 168 | ||
| 165 | flash_status_t flash_erase_chip(void) { | 169 | flash_status_t flash_erase_chip(void) { |
| 166 | flash_status_t response = FLASH_STATUS_SUCCESS; | 170 | flash_status_t response = FLASH_STATUS_SUCCESS; |
| @@ -304,7 +308,7 @@ flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len) { | |||
| 304 | dprintf(" %02X", (int)(((uint8_t *)read_buf)[i])); | 308 | dprintf(" %02X", (int)(((uint8_t *)read_buf)[i])); |
| 305 | } | 309 | } |
| 306 | dprintf("\n"); | 310 | dprintf("\n"); |
| 307 | #endif // DEBUG_FLASH_SPI_OUTPUT | 311 | #endif // DEBUG_FLASH_SPI_OUTPUT |
| 308 | 312 | ||
| 309 | return response; | 313 | return response; |
| 310 | } | 314 | } |
| @@ -340,7 +344,7 @@ flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len) { | |||
| 340 | dprintf(" %02X", (int)(uint8_t)(write_buf[i])); | 344 | dprintf(" %02X", (int)(uint8_t)(write_buf[i])); |
| 341 | } | 345 | } |
| 342 | dprintf("\n"); | 346 | dprintf("\n"); |
| 343 | #endif // DEBUG_FLASH_SPI_OUTPUT | 347 | #endif // DEBUG_FLASH_SPI_OUTPUT |
| 344 | 348 | ||
| 345 | /* Perform the write. */ | 349 | /* Perform the write. */ |
| 346 | response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length); | 350 | response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length); |
diff --git a/drivers/gpio/mcp23018.c b/drivers/gpio/mcp23018.c index dc8ab03c50..41cbfe087e 100644 --- a/drivers/gpio/mcp23018.c +++ b/drivers/gpio/mcp23018.c | |||
| @@ -10,11 +10,11 @@ | |||
| 10 | #define TIMEOUT 100 | 10 | #define TIMEOUT 100 |
| 11 | 11 | ||
| 12 | enum { | 12 | enum { |
| 13 | CMD_IODIRA = 0x00, // i/o direction register | 13 | CMD_IODIRA = 0x00, // i/o direction register |
| 14 | CMD_IODIRB = 0x01, | 14 | CMD_IODIRB = 0x01, |
| 15 | CMD_GPPUA = 0x0C, // GPIO pull-up resistor register | 15 | CMD_GPPUA = 0x0C, // GPIO pull-up resistor register |
| 16 | CMD_GPPUB = 0x0D, | 16 | CMD_GPPUB = 0x0D, |
| 17 | CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT) | 17 | CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT) |
| 18 | CMD_GPIOB = 0x13, | 18 | CMD_GPIOB = 0x13, |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c index 5de2b354c9..5a1d2ca0af 100644 --- a/drivers/haptic/DRV2605L.c +++ b/drivers/haptic/DRV2605L.c | |||
| @@ -106,12 +106,14 @@ void DRV_init(void) { | |||
| 106 | 106 | ||
| 107 | void DRV_rtp_init(void) { | 107 | void DRV_rtp_init(void) { |
| 108 | DRV_write(DRV_GO, 0x00); | 108 | DRV_write(DRV_GO, 0x00); |
| 109 | DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt. | 109 | DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt. |
| 110 | DRV_write(DRV_MODE, 0x05); | 110 | DRV_write(DRV_MODE, 0x05); |
| 111 | DRV_write(DRV_GO, 0x01); | 111 | DRV_write(DRV_GO, 0x01); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | void DRV_amplitude(uint8_t amplitude) { DRV_write(DRV_RTP_INPUT, amplitude); } | 114 | void DRV_amplitude(uint8_t amplitude) { |
| 115 | DRV_write(DRV_RTP_INPUT, amplitude); | ||
| 116 | } | ||
| 115 | 117 | ||
| 116 | void DRV_pulse(uint8_t sequence) { | 118 | void DRV_pulse(uint8_t sequence) { |
| 117 | DRV_write(DRV_GO, 0x00); | 119 | DRV_write(DRV_GO, 0x00); |
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c index 7a09940f78..14d868bffe 100644 --- a/drivers/haptic/solenoid.c +++ b/drivers/haptic/solenoid.c | |||
| @@ -28,13 +28,21 @@ uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; | |||
| 28 | 28 | ||
| 29 | extern haptic_config_t haptic_config; | 29 | extern haptic_config_t haptic_config; |
| 30 | 30 | ||
| 31 | void solenoid_buzz_on(void) { haptic_set_buzz(1); } | 31 | void solenoid_buzz_on(void) { |
| 32 | haptic_set_buzz(1); | ||
| 33 | } | ||
| 32 | 34 | ||
| 33 | void solenoid_buzz_off(void) { haptic_set_buzz(0); } | 35 | void solenoid_buzz_off(void) { |
| 36 | haptic_set_buzz(0); | ||
| 37 | } | ||
| 34 | 38 | ||
| 35 | void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); } | 39 | void solenoid_set_buzz(int buzz) { |
| 40 | haptic_set_buzz(buzz); | ||
| 41 | } | ||
| 36 | 42 | ||
| 37 | void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; } | 43 | void solenoid_set_dwell(uint8_t dwell) { |
| 44 | solenoid_dwell = dwell; | ||
| 45 | } | ||
| 38 | 46 | ||
| 39 | void solenoid_stop(void) { | 47 | void solenoid_stop(void) { |
| 40 | SOLENOID_PIN_WRITE_INACTIVE(); | 48 | SOLENOID_PIN_WRITE_INACTIVE(); |
| @@ -89,4 +97,6 @@ void solenoid_setup(void) { | |||
| 89 | } | 97 | } |
| 90 | } | 98 | } |
| 91 | 99 | ||
| 92 | void solenoid_shutdown(void) { SOLENOID_PIN_WRITE_INACTIVE(); } | 100 | void solenoid_shutdown(void) { |
| 101 | SOLENOID_PIN_WRITE_INACTIVE(); | ||
| 102 | } | ||
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c index 49b13c00f1..47ee02804b 100644 --- a/drivers/lcd/st7565.c +++ b/drivers/lcd/st7565.c | |||
| @@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 39 | // Addressing Setting Commands | 39 | // Addressing Setting Commands |
| 40 | #define PAM_SETCOLUMN_LSB 0x00 | 40 | #define PAM_SETCOLUMN_LSB 0x00 |
| 41 | #define PAM_SETCOLUMN_MSB 0x10 | 41 | #define PAM_SETCOLUMN_MSB 0x10 |
| 42 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 | 42 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 |
| 43 | 43 | ||
| 44 | // Hardware Configuration Commands | 44 | // Hardware Configuration Commands |
| 45 | #define DISPLAY_START_LINE 0x40 | 45 | #define DISPLAY_START_LINE 0x40 |
| @@ -138,7 +138,9 @@ bool st7565_init(display_rotation_t rotation) { | |||
| 138 | return true; | 138 | return true; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | __attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; } | 141 | __attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { |
| 142 | return rotation; | ||
| 143 | } | ||
| 142 | 144 | ||
| 143 | void st7565_clear(void) { | 145 | void st7565_clear(void) { |
| 144 | memset(st7565_buffer, 0, sizeof(st7565_buffer)); | 146 | memset(st7565_buffer, 0, sizeof(st7565_buffer)); |
| @@ -212,7 +214,8 @@ void st7565_advance_page(bool clearPageRemainder) { | |||
| 212 | remaining = remaining / ST7565_FONT_WIDTH; | 214 | remaining = remaining / ST7565_FONT_WIDTH; |
| 213 | 215 | ||
| 214 | // Write empty character until next line | 216 | // Write empty character until next line |
| 215 | while (remaining--) st7565_write_char(' ', false); | 217 | while (remaining--) |
| 218 | st7565_write_char(' ', false); | ||
| 216 | } else { | 219 | } else { |
| 217 | // Next page index out of bounds? | 220 | // Next page index out of bounds? |
| 218 | if (index + remaining >= ST7565_MATRIX_SIZE) { | 221 | if (index + remaining >= ST7565_MATRIX_SIZE) { |
| @@ -263,7 +266,7 @@ void st7565_write_char(const char data, bool invert) { | |||
| 263 | _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); | 266 | _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); |
| 264 | 267 | ||
| 265 | // set the reder buffer data | 268 | // set the reder buffer data |
| 266 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index | 269 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index |
| 267 | if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) { | 270 | if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) { |
| 268 | memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH); | 271 | memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH); |
| 269 | } else { | 272 | } else { |
| @@ -389,7 +392,7 @@ void st7565_write_raw_P(const char *data, uint16_t size) { | |||
| 389 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); | 392 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); |
| 390 | } | 393 | } |
| 391 | } | 394 | } |
| 392 | #endif // defined(__AVR__) | 395 | #endif // defined(__AVR__) |
| 393 | 396 | ||
| 394 | bool st7565_on(void) { | 397 | bool st7565_on(void) { |
| 395 | if (!st7565_initialized) { | 398 | if (!st7565_initialized) { |
| @@ -429,7 +432,9 @@ bool st7565_off(void) { | |||
| 429 | 432 | ||
| 430 | __attribute__((weak)) void st7565_off_user(void) {} | 433 | __attribute__((weak)) void st7565_off_user(void) {} |
| 431 | 434 | ||
| 432 | bool st7565_is_on(void) { return st7565_active; } | 435 | bool st7565_is_on(void) { |
| 436 | return st7565_active; | ||
| 437 | } | ||
| 433 | 438 | ||
| 434 | bool st7565_invert(bool invert) { | 439 | bool st7565_invert(bool invert) { |
| 435 | if (!st7565_initialized) { | 440 | if (!st7565_initialized) { |
| @@ -445,9 +450,13 @@ bool st7565_invert(bool invert) { | |||
| 445 | return st7565_inverted; | 450 | return st7565_inverted; |
| 446 | } | 451 | } |
| 447 | 452 | ||
| 448 | uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } | 453 | uint8_t st7565_max_chars(void) { |
| 454 | return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; | ||
| 455 | } | ||
| 449 | 456 | ||
| 450 | uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } | 457 | uint8_t st7565_max_lines(void) { |
| 458 | return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; | ||
| 459 | } | ||
| 451 | 460 | ||
| 452 | void st7565_task(void) { | 461 | void st7565_task(void) { |
| 453 | if (!st7565_initialized) { | 462 | if (!st7565_initialized) { |
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h index d453dbe6da..0e42c8765b 100644 --- a/drivers/lcd/st7565.h +++ b/drivers/lcd/st7565.h | |||
| @@ -29,16 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 29 | # define ST7565_DISPLAY_HEIGHT 32 | 29 | # define ST7565_DISPLAY_HEIGHT 32 |
| 30 | #endif | 30 | #endif |
| 31 | #ifndef ST7565_MATRIX_SIZE | 31 | #ifndef ST7565_MATRIX_SIZE |
| 32 | # define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed) | 32 | # define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed) |
| 33 | #endif | 33 | #endif |
| 34 | #ifndef ST7565_BLOCK_TYPE | 34 | #ifndef ST7565_BLOCK_TYPE |
| 35 | # define ST7565_BLOCK_TYPE uint16_t | 35 | # define ST7565_BLOCK_TYPE uint16_t |
| 36 | #endif | 36 | #endif |
| 37 | #ifndef ST7565_BLOCK_COUNT | 37 | #ifndef ST7565_BLOCK_COUNT |
| 38 | # define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed) | 38 | # define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed) |
| 39 | #endif | 39 | #endif |
| 40 | #ifndef ST7565_BLOCK_SIZE | 40 | #ifndef ST7565_BLOCK_SIZE |
| 41 | # define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed) | 41 | # define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed) |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | // the column address corresponding to the first column in the display hardware | 44 | // the column address corresponding to the first column in the display hardware |
| @@ -174,7 +174,7 @@ void st7565_write_raw_P(const char *data, uint16_t size); | |||
| 174 | # define st7565_write_P(data, invert) st7565_write(data, invert) | 174 | # define st7565_write_P(data, invert) st7565_write(data, invert) |
| 175 | # define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert) | 175 | # define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert) |
| 176 | # define st7565_write_raw_P(data, size) st7565_write_raw(data, size) | 176 | # define st7565_write_raw_P(data, size) st7565_write_raw(data, size) |
| 177 | #endif // defined(__AVR__) | 177 | #endif // defined(__AVR__) |
| 178 | 178 | ||
| 179 | // Can be used to manually turn on the screen if it is off | 179 | // Can be used to manually turn on the screen if it is off |
| 180 | // Returns true if the screen was on or turns on | 180 | // Returns true if the screen was on or turns on |
diff --git a/drivers/led/apa102.c b/drivers/led/apa102.c index 00e7eb4505..f291948975 100644 --- a/drivers/led/apa102.c +++ b/drivers/led/apa102.c | |||
| @@ -20,15 +20,15 @@ | |||
| 20 | 20 | ||
| 21 | #ifndef APA102_NOPS | 21 | #ifndef APA102_NOPS |
| 22 | # if defined(__AVR__) | 22 | # if defined(__AVR__) |
| 23 | # define APA102_NOPS 0 // AVR at 16 MHz already spends 62.5 ns per clock, so no extra delay is needed | 23 | # define APA102_NOPS 0 // AVR at 16 MHz already spends 62.5 ns per clock, so no extra delay is needed |
| 24 | # elif defined(PROTOCOL_CHIBIOS) | 24 | # elif defined(PROTOCOL_CHIBIOS) |
| 25 | 25 | ||
| 26 | # include "hal.h" | 26 | # include "hal.h" |
| 27 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103) | 27 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103) |
| 28 | # define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns | 28 | # define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns |
| 29 | # else | 29 | # else |
| 30 | # error("APA102_NOPS configuration required") | 30 | # error("APA102_NOPS configuration required") |
| 31 | # define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot | 31 | # define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot |
| 32 | # endif | 32 | # endif |
| 33 | # endif | 33 | # endif |
| 34 | #endif | 34 | #endif |
| @@ -72,7 +72,9 @@ void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds) { | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | // Overwrite the default rgblight_call_driver to use apa102 driver | 74 | // Overwrite the default rgblight_call_driver to use apa102 driver |
| 75 | void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { apa102_setleds(start_led, num_leds); } | 75 | void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { |
| 76 | apa102_setleds(start_led, num_leds); | ||
| 77 | } | ||
| 76 | 78 | ||
| 77 | void static apa102_init(void) { | 79 | void static apa102_init(void) { |
| 78 | setPinOutput(RGB_DI_PIN); | 80 | setPinOutput(RGB_DI_PIN); |
diff --git a/drivers/led/aw20216.c b/drivers/led/aw20216.c index 2c7ff8f088..59389cdcd6 100644 --- a/drivers/led/aw20216.c +++ b/drivers/led/aw20216.c | |||
| @@ -23,17 +23,17 @@ | |||
| 23 | */ | 23 | */ |
| 24 | #define AWINIC_ID 0b1010 << 4 | 24 | #define AWINIC_ID 0b1010 << 4 |
| 25 | 25 | ||
| 26 | #define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers | 26 | #define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers |
| 27 | #define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control | 27 | #define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control |
| 28 | #define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control | 28 | #define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control |
| 29 | #define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice? | 29 | #define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice? |
| 30 | #define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control? | 30 | #define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control? |
| 31 | 31 | ||
| 32 | #define AW_WRITE 0 | 32 | #define AW_WRITE 0 |
| 33 | #define AW_READ 1 | 33 | #define AW_READ 1 |
| 34 | 34 | ||
| 35 | #define AW_REG_CONFIGURATION 0x00 // PG0 | 35 | #define AW_REG_CONFIGURATION 0x00 // PG0 |
| 36 | #define AW_REG_GLOBALCURRENT 0x01 // PG0 | 36 | #define AW_REG_GLOBALCURRENT 0x01 // PG0 |
| 37 | 37 | ||
| 38 | // Default value of AW_REG_CONFIGURATION | 38 | // Default value of AW_REG_CONFIGURATION |
| 39 | // D7:D4 = 1011, SWSEL (SW1~SW12 active) | 39 | // D7:D4 = 1011, SWSEL (SW1~SW12 active) |
diff --git a/drivers/led/issi/is31fl3731-simple.c b/drivers/led/issi/is31fl3731-simple.c index f51e2e38af..3abe9ea337 100644 --- a/drivers/led/issi/is31fl3731-simple.c +++ b/drivers/led/issi/is31fl3731-simple.c | |||
| @@ -42,13 +42,13 @@ | |||
| 42 | #define ISSI_REG_PICTUREFRAME 0x01 | 42 | #define ISSI_REG_PICTUREFRAME 0x01 |
| 43 | 43 | ||
| 44 | // Not defined in the datasheet -- See AN for IC | 44 | // Not defined in the datasheet -- See AN for IC |
| 45 | #define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting | 45 | #define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting |
| 46 | 46 | ||
| 47 | #define ISSI_REG_SHUTDOWN 0x0A | 47 | #define ISSI_REG_SHUTDOWN 0x0A |
| 48 | #define ISSI_REG_AUDIOSYNC 0x06 | 48 | #define ISSI_REG_AUDIOSYNC 0x06 |
| 49 | 49 | ||
| 50 | #define ISSI_COMMANDREGISTER 0xFD | 50 | #define ISSI_COMMANDREGISTER 0xFD |
| 51 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' | 51 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' |
| 52 | 52 | ||
| 53 | #ifndef ISSI_TIMEOUT | 53 | #ifndef ISSI_TIMEOUT |
| 54 | # define ISSI_TIMEOUT 100 | 54 | # define ISSI_TIMEOUT 100 |
| @@ -148,7 +148,7 @@ void IS31FL3731_init(uint8_t addr) { | |||
| 148 | 148 | ||
| 149 | // enable software shutdown | 149 | // enable software shutdown |
| 150 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); | 150 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); |
| 151 | #ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array | 151 | #ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array |
| 152 | IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); | 152 | IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); |
| 153 | #endif | 153 | #endif |
| 154 | 154 | ||
diff --git a/drivers/led/issi/is31fl3731.c b/drivers/led/issi/is31fl3731.c index e6190a6b90..9c6c29f081 100644 --- a/drivers/led/issi/is31fl3731.c +++ b/drivers/led/issi/is31fl3731.c | |||
| @@ -41,13 +41,13 @@ | |||
| 41 | #define ISSI_REG_PICTUREFRAME 0x01 | 41 | #define ISSI_REG_PICTUREFRAME 0x01 |
| 42 | 42 | ||
| 43 | // Not defined in the datasheet -- See AN for IC | 43 | // Not defined in the datasheet -- See AN for IC |
| 44 | #define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting | 44 | #define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting |
| 45 | 45 | ||
| 46 | #define ISSI_REG_SHUTDOWN 0x0A | 46 | #define ISSI_REG_SHUTDOWN 0x0A |
| 47 | #define ISSI_REG_AUDIOSYNC 0x06 | 47 | #define ISSI_REG_AUDIOSYNC 0x06 |
| 48 | 48 | ||
| 49 | #define ISSI_COMMANDREGISTER 0xFD | 49 | #define ISSI_COMMANDREGISTER 0xFD |
| 50 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' | 50 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' |
| 51 | 51 | ||
| 52 | #ifndef ISSI_TIMEOUT | 52 | #ifndef ISSI_TIMEOUT |
| 53 | # define ISSI_TIMEOUT 100 | 53 | # define ISSI_TIMEOUT 100 |
| @@ -136,7 +136,7 @@ void IS31FL3731_init(uint8_t addr) { | |||
| 136 | 136 | ||
| 137 | // enable software shutdown | 137 | // enable software shutdown |
| 138 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); | 138 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); |
| 139 | #ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array | 139 | #ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array |
| 140 | IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); | 140 | IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); |
| 141 | #endif | 141 | #endif |
| 142 | 142 | ||
diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c index 777895bf89..af006f756d 100644 --- a/drivers/led/issi/is31fl3733-simple.c +++ b/drivers/led/issi/is31fl3733-simple.c | |||
| @@ -39,16 +39,16 @@ | |||
| 39 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 39 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 40 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 40 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 41 | 41 | ||
| 42 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 | 42 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 43 | #define ISSI_PAGE_PWM 0x01 // PG1 | 43 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 44 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 | 44 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 45 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 | 45 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 46 | 46 | ||
| 47 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 | 47 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 48 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 | 48 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 49 | #define ISSI_REG_RESET 0x11 // PG3 | 49 | #define ISSI_REG_RESET 0x11 // PG3 |
| 50 | #define ISSI_REG_SWPULLUP 0x0F // PG3 | 50 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 51 | #define ISSI_REG_CSPULLUP 0x10 // PG3 | 51 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 52 | 52 | ||
| 53 | #ifndef ISSI_TIMEOUT | 53 | #ifndef ISSI_TIMEOUT |
| 54 | # define ISSI_TIMEOUT 100 | 54 | # define ISSI_TIMEOUT 100 |
| @@ -59,7 +59,7 @@ | |||
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| 61 | #ifndef ISSI_PWM_FREQUENCY | 61 | #ifndef ISSI_PWM_FREQUENCY |
| 62 | # define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only | 62 | # define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | #ifndef ISSI_SWPULLUP | 65 | #ifndef ISSI_SWPULLUP |
diff --git a/drivers/led/issi/is31fl3733-simple.h b/drivers/led/issi/is31fl3733-simple.h index f071db5e40..f5253e3101 100644 --- a/drivers/led/issi/is31fl3733-simple.h +++ b/drivers/led/issi/is31fl3733-simple.h | |||
| @@ -47,13 +47,13 @@ void IS31FL3733_set_led_control_register(uint8_t index, bool value); | |||
| 47 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); | 47 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); |
| 48 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); | 48 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); |
| 49 | 49 | ||
| 50 | #define PUR_0R 0x00 // No PUR resistor | 50 | #define PUR_0R 0x00 // No PUR resistor |
| 51 | #define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL | 51 | #define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL |
| 52 | #define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time | 52 | #define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time |
| 53 | #define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time | 53 | #define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time |
| 54 | #define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time | 54 | #define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time |
| 55 | #define PUR_16KR 0x06 // 16k Ohm resistor on all the time | 55 | #define PUR_16KR 0x06 // 16k Ohm resistor on all the time |
| 56 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL | 56 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL |
| 57 | 57 | ||
| 58 | #define A_1 0x00 | 58 | #define A_1 0x00 |
| 59 | #define A_2 0x01 | 59 | #define A_2 0x01 |
diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c index 696491d070..a2fdaa90fa 100644 --- a/drivers/led/issi/is31fl3733.c +++ b/drivers/led/issi/is31fl3733.c | |||
| @@ -38,16 +38,16 @@ | |||
| 38 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 38 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 39 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 39 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 40 | 40 | ||
| 41 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 | 41 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 42 | #define ISSI_PAGE_PWM 0x01 // PG1 | 42 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 43 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 | 43 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 44 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 | 44 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 45 | 45 | ||
| 46 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 | 46 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 47 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 | 47 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 48 | #define ISSI_REG_RESET 0x11 // PG3 | 48 | #define ISSI_REG_RESET 0x11 // PG3 |
| 49 | #define ISSI_REG_SWPULLUP 0x0F // PG3 | 49 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 50 | #define ISSI_REG_CSPULLUP 0x10 // PG3 | 50 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 51 | 51 | ||
| 52 | #ifndef ISSI_TIMEOUT | 52 | #ifndef ISSI_TIMEOUT |
| 53 | # define ISSI_TIMEOUT 100 | 53 | # define ISSI_TIMEOUT 100 |
| @@ -58,7 +58,7 @@ | |||
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| 60 | #ifndef ISSI_PWM_FREQUENCY | 60 | #ifndef ISSI_PWM_FREQUENCY |
| 61 | # define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only | 61 | # define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifndef ISSI_SWPULLUP | 64 | #ifndef ISSI_SWPULLUP |
diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h index c5d62fed85..7653dd17c0 100644 --- a/drivers/led/issi/is31fl3733.h +++ b/drivers/led/issi/is31fl3733.h | |||
| @@ -48,13 +48,13 @@ void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bo | |||
| 48 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); | 48 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); |
| 49 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); | 49 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); |
| 50 | 50 | ||
| 51 | #define PUR_0R 0x00 // No PUR resistor | 51 | #define PUR_0R 0x00 // No PUR resistor |
| 52 | #define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL | 52 | #define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL |
| 53 | #define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time | 53 | #define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time |
| 54 | #define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time | 54 | #define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time |
| 55 | #define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time | 55 | #define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time |
| 56 | #define PUR_16KR 0x06 // 16k Ohm resistor on all the time | 56 | #define PUR_16KR 0x06 // 16k Ohm resistor on all the time |
| 57 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL | 57 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL |
| 58 | 58 | ||
| 59 | #define A_1 0x00 | 59 | #define A_1 0x00 |
| 60 | #define A_2 0x01 | 60 | #define A_2 0x01 |
diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c index c9a871118d..7752a3f6cb 100644 --- a/drivers/led/issi/is31fl3736.c +++ b/drivers/led/issi/is31fl3736.c | |||
| @@ -36,16 +36,16 @@ | |||
| 36 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 36 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 37 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 37 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 38 | 38 | ||
| 39 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 | 39 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 40 | #define ISSI_PAGE_PWM 0x01 // PG1 | 40 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 41 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 | 41 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 42 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 | 42 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 43 | 43 | ||
| 44 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 | 44 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 45 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 | 45 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 46 | #define ISSI_REG_RESET 0x11 // PG3 | 46 | #define ISSI_REG_RESET 0x11 // PG3 |
| 47 | #define ISSI_REG_SWPULLUP 0x0F // PG3 | 47 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 48 | #define ISSI_REG_CSPULLUP 0x10 // PG3 | 48 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 49 | 49 | ||
| 50 | #ifndef ISSI_TIMEOUT | 50 | #ifndef ISSI_TIMEOUT |
| 51 | # define ISSI_TIMEOUT 100 | 51 | # define ISSI_TIMEOUT 100 |
diff --git a/drivers/led/issi/is31fl3736.h b/drivers/led/issi/is31fl3736.h index 9fbe1cc577..f126034615 100644 --- a/drivers/led/issi/is31fl3736.h +++ b/drivers/led/issi/is31fl3736.h | |||
| @@ -61,14 +61,14 @@ void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled); | |||
| 61 | void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2); | 61 | void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2); |
| 62 | void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2); | 62 | void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2); |
| 63 | 63 | ||
| 64 | #define PUR_0R 0x00 // No PUR resistor | 64 | #define PUR_0R 0x00 // No PUR resistor |
| 65 | #define PUR_05KR 0x01 // 0.5k Ohm resistor | 65 | #define PUR_05KR 0x01 // 0.5k Ohm resistor |
| 66 | #define PUR_1KR 0x02 // 1.0k Ohm resistor | 66 | #define PUR_1KR 0x02 // 1.0k Ohm resistor |
| 67 | #define PUR_2KR 0x03 // 2.0k Ohm resistor | 67 | #define PUR_2KR 0x03 // 2.0k Ohm resistor |
| 68 | #define PUR_4KR 0x04 // 4.0k Ohm resistor | 68 | #define PUR_4KR 0x04 // 4.0k Ohm resistor |
| 69 | #define PUR_8KR 0x05 // 8.0k Ohm resistor | 69 | #define PUR_8KR 0x05 // 8.0k Ohm resistor |
| 70 | #define PUR_16KR 0x06 // 16k Ohm resistor | 70 | #define PUR_16KR 0x06 // 16k Ohm resistor |
| 71 | #define PUR_32KR 0x07 // 32k Ohm resistor | 71 | #define PUR_32KR 0x07 // 32k Ohm resistor |
| 72 | 72 | ||
| 73 | #define A_1 0x00 | 73 | #define A_1 0x00 |
| 74 | #define A_2 0x02 | 74 | #define A_2 0x02 |
diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c index 0722e18869..9f2a13de45 100644 --- a/drivers/led/issi/is31fl3737.c +++ b/drivers/led/issi/is31fl3737.c | |||
| @@ -38,16 +38,16 @@ | |||
| 38 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 38 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 39 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 39 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 40 | 40 | ||
| 41 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 | 41 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 42 | #define ISSI_PAGE_PWM 0x01 // PG1 | 42 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 43 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 | 43 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 44 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 | 44 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 45 | 45 | ||
| 46 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 | 46 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 47 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 | 47 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 48 | #define ISSI_REG_RESET 0x11 // PG3 | 48 | #define ISSI_REG_RESET 0x11 // PG3 |
| 49 | #define ISSI_REG_SWPULLUP 0x0F // PG3 | 49 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 50 | #define ISSI_REG_CSPULLUP 0x10 // PG3 | 50 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 51 | 51 | ||
| 52 | #ifndef ISSI_TIMEOUT | 52 | #ifndef ISSI_TIMEOUT |
| 53 | # define ISSI_TIMEOUT 100 | 53 | # define ISSI_TIMEOUT 100 |
diff --git a/drivers/led/issi/is31fl3737.h b/drivers/led/issi/is31fl3737.h index 31b1a22267..ddb70a9df5 100644 --- a/drivers/led/issi/is31fl3737.h +++ b/drivers/led/issi/is31fl3737.h | |||
| @@ -48,14 +48,14 @@ void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bo | |||
| 48 | void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2); | 48 | void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2); |
| 49 | void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2); | 49 | void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2); |
| 50 | 50 | ||
| 51 | #define PUR_0R 0x00 // No PUR resistor | 51 | #define PUR_0R 0x00 // No PUR resistor |
| 52 | #define PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL | 52 | #define PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL |
| 53 | #define PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL | 53 | #define PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL |
| 54 | #define PUR_2KR 0x03 // 2.0k Ohm resistor in t_NOL | 54 | #define PUR_2KR 0x03 // 2.0k Ohm resistor in t_NOL |
| 55 | #define PUR_4KR 0x04 // 4.0k Ohm resistor in t_NOL | 55 | #define PUR_4KR 0x04 // 4.0k Ohm resistor in t_NOL |
| 56 | #define PUR_8KR 0x05 // 8.0k Ohm resistor in t_NOL | 56 | #define PUR_8KR 0x05 // 8.0k Ohm resistor in t_NOL |
| 57 | #define PUR_16KR 0x06 // 16k Ohm resistor in t_NOL | 57 | #define PUR_16KR 0x06 // 16k Ohm resistor in t_NOL |
| 58 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL | 58 | #define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL |
| 59 | 59 | ||
| 60 | #define A_1 0x00 | 60 | #define A_1 0x00 |
| 61 | #define A_2 0x01 | 61 | #define A_2 0x01 |
diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c index 8d347a5e60..393b0179b5 100644 --- a/drivers/led/issi/is31fl3741.c +++ b/drivers/led/issi/is31fl3741.c | |||
| @@ -42,16 +42,16 @@ | |||
| 42 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 42 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 43 | #define ISSI_IDREGISTER 0xFC | 43 | #define ISSI_IDREGISTER 0xFC |
| 44 | 44 | ||
| 45 | #define ISSI_PAGE_PWM0 0x00 // PG0 | 45 | #define ISSI_PAGE_PWM0 0x00 // PG0 |
| 46 | #define ISSI_PAGE_PWM1 0x01 // PG1 | 46 | #define ISSI_PAGE_PWM1 0x01 // PG1 |
| 47 | #define ISSI_PAGE_SCALING_0 0x02 // PG2 | 47 | #define ISSI_PAGE_SCALING_0 0x02 // PG2 |
| 48 | #define ISSI_PAGE_SCALING_1 0x03 // PG3 | 48 | #define ISSI_PAGE_SCALING_1 0x03 // PG3 |
| 49 | #define ISSI_PAGE_FUNCTION 0x04 // PG4 | 49 | #define ISSI_PAGE_FUNCTION 0x04 // PG4 |
| 50 | 50 | ||
| 51 | #define ISSI_REG_CONFIGURATION 0x00 // PG4 | 51 | #define ISSI_REG_CONFIGURATION 0x00 // PG4 |
| 52 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG4 | 52 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG4 |
| 53 | #define ISSI_REG_PULLDOWNUP 0x02 // PG4 | 53 | #define ISSI_REG_PULLDOWNUP 0x02 // PG4 |
| 54 | #define ISSI_REG_RESET 0x3F // PG4 | 54 | #define ISSI_REG_RESET 0x3F // PG4 |
| 55 | 55 | ||
| 56 | #ifndef ISSI_TIMEOUT | 56 | #ifndef ISSI_TIMEOUT |
| 57 | # define ISSI_TIMEOUT 100 | 57 | # define ISSI_TIMEOUT 100 |
diff --git a/drivers/led/issi/is31fl3741.h b/drivers/led/issi/is31fl3741.h index 8154f8be70..3bdb23bd2d 100644 --- a/drivers/led/issi/is31fl3741.h +++ b/drivers/led/issi/is31fl3741.h | |||
| @@ -51,14 +51,14 @@ void IS31FL3741_set_scaling_registers(const is31_led *pled, uint8_t red, uint8_t | |||
| 51 | 51 | ||
| 52 | void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue); | 52 | void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue); |
| 53 | 53 | ||
| 54 | #define PUR_0R 0x00 // No PUR resistor | 54 | #define PUR_0R 0x00 // No PUR resistor |
| 55 | #define PUR_05KR 0x01 // 0.5k Ohm resistor | 55 | #define PUR_05KR 0x01 // 0.5k Ohm resistor |
| 56 | #define PUR_1KR 0x02 // 1.0k Ohm resistor | 56 | #define PUR_1KR 0x02 // 1.0k Ohm resistor |
| 57 | #define PUR_2KR 0x03 // 2.0k Ohm resistor | 57 | #define PUR_2KR 0x03 // 2.0k Ohm resistor |
| 58 | #define PUR_4KR 0x04 // 4.0k Ohm resistor | 58 | #define PUR_4KR 0x04 // 4.0k Ohm resistor |
| 59 | #define PUR_8KR 0x05 // 8.0k Ohm resistor | 59 | #define PUR_8KR 0x05 // 8.0k Ohm resistor |
| 60 | #define PUR_16KR 0x06 // 16k Ohm resistor | 60 | #define PUR_16KR 0x06 // 16k Ohm resistor |
| 61 | #define PUR_32KR 0x07 // 32k Ohm resistor | 61 | #define PUR_32KR 0x07 // 32k Ohm resistor |
| 62 | 62 | ||
| 63 | #define CS1_SW1 0x00 | 63 | #define CS1_SW1 0x00 |
| 64 | #define CS2_SW1 0x01 | 64 | #define CS2_SW1 0x01 |
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 3b56d370dc..918b837f07 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
| @@ -34,16 +34,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 34 | # define OLED_DISPLAY_HEIGHT 64 | 34 | # define OLED_DISPLAY_HEIGHT 64 |
| 35 | # endif | 35 | # endif |
| 36 | # ifndef OLED_MATRIX_SIZE | 36 | # ifndef OLED_MATRIX_SIZE |
| 37 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) | 37 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) |
| 38 | # endif | 38 | # endif |
| 39 | # ifndef OLED_BLOCK_TYPE | 39 | # ifndef OLED_BLOCK_TYPE |
| 40 | # define OLED_BLOCK_TYPE uint16_t | 40 | # define OLED_BLOCK_TYPE uint16_t |
| 41 | # endif | 41 | # endif |
| 42 | # ifndef OLED_BLOCK_COUNT | 42 | # ifndef OLED_BLOCK_COUNT |
| 43 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) | 43 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) |
| 44 | # endif | 44 | # endif |
| 45 | # ifndef OLED_BLOCK_SIZE | 45 | # ifndef OLED_BLOCK_SIZE |
| 46 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 46 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 47 | # endif | 47 | # endif |
| 48 | # ifndef OLED_COM_PINS | 48 | # ifndef OLED_COM_PINS |
| 49 | # define OLED_COM_PINS COM_PINS_ALT | 49 | # define OLED_COM_PINS COM_PINS_ALT |
| @@ -68,7 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 68 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | 68 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: |
| 69 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } | 69 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } |
| 70 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } | 70 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } |
| 71 | #else // defined(OLED_DISPLAY_128X64) | 71 | #else // defined(OLED_DISPLAY_128X64) |
| 72 | // Default 128x32 | 72 | // Default 128x32 |
| 73 | # ifndef OLED_DISPLAY_WIDTH | 73 | # ifndef OLED_DISPLAY_WIDTH |
| 74 | # define OLED_DISPLAY_WIDTH 128 | 74 | # define OLED_DISPLAY_WIDTH 128 |
| @@ -77,16 +77,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 77 | # define OLED_DISPLAY_HEIGHT 32 | 77 | # define OLED_DISPLAY_HEIGHT 32 |
| 78 | # endif | 78 | # endif |
| 79 | # ifndef OLED_MATRIX_SIZE | 79 | # ifndef OLED_MATRIX_SIZE |
| 80 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) | 80 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) |
| 81 | # endif | 81 | # endif |
| 82 | # ifndef OLED_BLOCK_TYPE | 82 | # ifndef OLED_BLOCK_TYPE |
| 83 | # define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only | 83 | # define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only |
| 84 | # endif | 84 | # endif |
| 85 | # ifndef OLED_BLOCK_COUNT | 85 | # ifndef OLED_BLOCK_COUNT |
| 86 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) | 86 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) |
| 87 | # endif | 87 | # endif |
| 88 | # ifndef OLED_BLOCK_SIZE | 88 | # ifndef OLED_BLOCK_SIZE |
| 89 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 89 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 90 | # endif | 90 | # endif |
| 91 | # ifndef OLED_COM_PINS | 91 | # ifndef OLED_COM_PINS |
| 92 | # define OLED_COM_PINS COM_PINS_SEQ | 92 | # define OLED_COM_PINS COM_PINS_SEQ |
| @@ -105,7 +105,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 105 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | 105 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: |
| 106 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 106 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 107 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } | 107 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } |
| 108 | #endif // defined(OLED_DISPLAY_CUSTOM) | 108 | #endif // defined(OLED_DISPLAY_CUSTOM) |
| 109 | 109 | ||
| 110 | #if !defined(OLED_IC) | 110 | #if !defined(OLED_IC) |
| 111 | # define OLED_IC OLED_IC_SSD1306 | 111 | # define OLED_IC OLED_IC_SSD1306 |
| @@ -180,7 +180,7 @@ typedef enum { | |||
| 180 | OLED_ROTATION_0 = 0, | 180 | OLED_ROTATION_0 = 0, |
| 181 | OLED_ROTATION_90 = 1, | 181 | OLED_ROTATION_90 = 1, |
| 182 | OLED_ROTATION_180 = 2, | 182 | OLED_ROTATION_180 = 2, |
| 183 | OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 | 183 | OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 |
| 184 | } oled_rotation_t; | 184 | } oled_rotation_t; |
| 185 | 185 | ||
| 186 | // Initialize the oled display, rotating the rendered output based on the define passed in. | 186 | // Initialize the oled display, rotating the rendered output based on the define passed in. |
| @@ -262,7 +262,7 @@ void oled_write_raw_P(const char *data, uint16_t size); | |||
| 262 | # define oled_write_P(data, invert) oled_write(data, invert) | 262 | # define oled_write_P(data, invert) oled_write(data, invert) |
| 263 | # define oled_write_ln_P(data, invert) oled_write(data, invert) | 263 | # define oled_write_ln_P(data, invert) oled_write(data, invert) |
| 264 | # define oled_write_raw_P(data, size) oled_write_raw(data, size) | 264 | # define oled_write_raw_P(data, size) oled_write_raw(data, size) |
| 265 | #endif // defined(__AVR__) | 265 | #endif // defined(__AVR__) |
| 266 | 266 | ||
| 267 | // Can be used to manually turn on the screen if it is off | 267 | // Can be used to manually turn on the screen if it is off |
| 268 | // Returns true if the screen was on or turns on | 268 | // Returns true if the screen was on or turns on |
diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c index d9bd3c14bd..30cfeb5648 100644 --- a/drivers/oled/ssd1306_sh1106.c +++ b/drivers/oled/ssd1306_sh1106.c | |||
| @@ -53,7 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 53 | #define PAGE_ADDR 0x22 | 53 | #define PAGE_ADDR 0x22 |
| 54 | #define PAM_SETCOLUMN_LSB 0x00 | 54 | #define PAM_SETCOLUMN_LSB 0x00 |
| 55 | #define PAM_SETCOLUMN_MSB 0x10 | 55 | #define PAM_SETCOLUMN_MSB 0x10 |
| 56 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 | 56 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 |
| 57 | 57 | ||
| 58 | // Hardware Configuration Commands | 58 | // Hardware Configuration Commands |
| 59 | #define DISPLAY_START_LINE 0x40 | 59 | #define DISPLAY_START_LINE 0x40 |
| @@ -97,9 +97,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 97 | #define I2C_DATA 0x40 | 97 | #define I2C_DATA 0x40 |
| 98 | #if defined(__AVR__) | 98 | #if defined(__AVR__) |
| 99 | # define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) | 99 | # define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) |
| 100 | #else // defined(__AVR__) | 100 | #else // defined(__AVR__) |
| 101 | # define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) | 101 | # define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) |
| 102 | #endif // defined(__AVR__) | 102 | #endif // defined(__AVR__) |
| 103 | #define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) | 103 | #define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) |
| 104 | #define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT) | 104 | #define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT) |
| 105 | 105 | ||
| @@ -119,7 +119,7 @@ bool oled_inverted = false; | |||
| 119 | uint8_t oled_brightness = OLED_BRIGHTNESS; | 119 | uint8_t oled_brightness = OLED_BRIGHTNESS; |
| 120 | oled_rotation_t oled_rotation = 0; | 120 | oled_rotation_t oled_rotation = 0; |
| 121 | uint8_t oled_rotation_width = 0; | 121 | uint8_t oled_rotation_width = 0; |
| 122 | uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values | 122 | uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values |
| 123 | uint8_t oled_scroll_start = 0; | 123 | uint8_t oled_scroll_start = 0; |
| 124 | uint8_t oled_scroll_end = 7; | 124 | uint8_t oled_scroll_end = 7; |
| 125 | #if OLED_TIMEOUT > 0 | 125 | #if OLED_TIMEOUT > 0 |
| @@ -190,7 +190,7 @@ bool oled_init(oled_rotation_t rotation) { | |||
| 190 | #if (OLED_IC != OLED_IC_SH1106) | 190 | #if (OLED_IC != OLED_IC_SH1106) |
| 191 | // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) | 191 | // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) |
| 192 | MEMORY_MODE, | 192 | MEMORY_MODE, |
| 193 | 0x00, // Horizontal addressing mode | 193 | 0x00, // Horizontal addressing mode |
| 194 | #endif | 194 | #endif |
| 195 | }; | 195 | }; |
| 196 | if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { | 196 | if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { |
| @@ -232,8 +232,12 @@ bool oled_init(oled_rotation_t rotation) { | |||
| 232 | return true; | 232 | return true; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | __attribute__((weak)) oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return rotation; } | 235 | __attribute__((weak)) oled_rotation_t oled_init_kb(oled_rotation_t rotation) { |
| 236 | __attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } | 236 | return rotation; |
| 237 | } | ||
| 238 | __attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 239 | return rotation; | ||
| 240 | } | ||
| 237 | 241 | ||
| 238 | void oled_clear(void) { | 242 | void oled_clear(void) { |
| 239 | memset(oled_buffer, 0, sizeof(oled_buffer)); | 243 | memset(oled_buffer, 0, sizeof(oled_buffer)); |
| @@ -306,9 +310,9 @@ void oled_render(void) { | |||
| 306 | // Set column & page position | 310 | // Set column & page position |
| 307 | static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; | 311 | static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; |
| 308 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 312 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 309 | calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start | 313 | calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start |
| 310 | } else { | 314 | } else { |
| 311 | calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start | 315 | calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start |
| 312 | } | 316 | } |
| 313 | 317 | ||
| 314 | // Send column & page position | 318 | // Send column & page position |
| @@ -368,7 +372,8 @@ void oled_advance_page(bool clearPageRemainder) { | |||
| 368 | remaining = remaining / OLED_FONT_WIDTH; | 372 | remaining = remaining / OLED_FONT_WIDTH; |
| 369 | 373 | ||
| 370 | // Write empty character until next line | 374 | // Write empty character until next line |
| 371 | while (remaining--) oled_write_char(' ', false); | 375 | while (remaining--) |
| 376 | oled_write_char(' ', false); | ||
| 372 | } else { | 377 | } else { |
| 373 | // Next page index out of bounds? | 378 | // Next page index out of bounds? |
| 374 | if (index + remaining >= OLED_MATRIX_SIZE) { | 379 | if (index + remaining >= OLED_MATRIX_SIZE) { |
| @@ -419,7 +424,7 @@ void oled_write_char(const char data, bool invert) { | |||
| 419 | _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); | 424 | _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); |
| 420 | 425 | ||
| 421 | // set the reder buffer data | 426 | // set the reder buffer data |
| 422 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index | 427 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index |
| 423 | if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { | 428 | if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { |
| 424 | memset(oled_cursor, 0x00, OLED_FONT_WIDTH); | 429 | memset(oled_cursor, 0x00, OLED_FONT_WIDTH); |
| 425 | } else { | 430 | } else { |
| @@ -545,7 +550,7 @@ void oled_write_raw_P(const char *data, uint16_t size) { | |||
| 545 | oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); | 550 | oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); |
| 546 | } | 551 | } |
| 547 | } | 552 | } |
| 548 | #endif // defined(__AVR__) | 553 | #endif // defined(__AVR__) |
| 549 | 554 | ||
| 550 | bool oled_on(void) { | 555 | bool oled_on(void) { |
| 551 | if (!oled_initialized) { | 556 | if (!oled_initialized) { |
| @@ -595,7 +600,9 @@ bool oled_off(void) { | |||
| 595 | return !oled_active; | 600 | return !oled_active; |
| 596 | } | 601 | } |
| 597 | 602 | ||
| 598 | bool is_oled_on(void) { return oled_active; } | 603 | bool is_oled_on(void) { |
| 604 | return oled_active; | ||
| 605 | } | ||
| 599 | 606 | ||
| 600 | uint8_t oled_set_brightness(uint8_t level) { | 607 | uint8_t oled_set_brightness(uint8_t level) { |
| 601 | if (!oled_initialized) { | 608 | if (!oled_initialized) { |
| @@ -613,7 +620,9 @@ uint8_t oled_set_brightness(uint8_t level) { | |||
| 613 | return oled_brightness; | 620 | return oled_brightness; |
| 614 | } | 621 | } |
| 615 | 622 | ||
| 616 | uint8_t oled_get_brightness(void) { return oled_brightness; } | 623 | uint8_t oled_get_brightness(void) { |
| 624 | return oled_brightness; | ||
| 625 | } | ||
| 617 | 626 | ||
| 618 | // Set the specific 8 lines rows of the screen to scroll. | 627 | // Set the specific 8 lines rows of the screen to scroll. |
| 619 | // 0 is the default for start, and 7 for end, which is the entire | 628 | // 0 is the default for start, and 7 for end, which is the entire |
| @@ -693,7 +702,9 @@ bool oled_scroll_off(void) { | |||
| 693 | return !oled_scrolling; | 702 | return !oled_scrolling; |
| 694 | } | 703 | } |
| 695 | 704 | ||
| 696 | bool is_oled_scrolling(void) { return oled_scrolling; } | 705 | bool is_oled_scrolling(void) { |
| 706 | return oled_scrolling; | ||
| 707 | } | ||
| 697 | 708 | ||
| 698 | bool oled_invert(bool invert) { | 709 | bool oled_invert(bool invert) { |
| 699 | if (!oled_initialized) { | 710 | if (!oled_initialized) { |
| @@ -777,5 +788,9 @@ void oled_task(void) { | |||
| 777 | #endif | 788 | #endif |
| 778 | } | 789 | } |
| 779 | 790 | ||
| 780 | __attribute__((weak)) bool oled_task_kb(void) { return oled_task_user(); } | 791 | __attribute__((weak)) bool oled_task_kb(void) { |
| 781 | __attribute__((weak)) bool oled_task_user(void) { return true; } | 792 | return oled_task_user(); |
| 793 | } | ||
| 794 | __attribute__((weak)) bool oled_task_user(void) { | ||
| 795 | return true; | ||
| 796 | } | ||
diff --git a/drivers/ps2/ps2_busywait.c b/drivers/ps2/ps2_busywait.c index 983194eea8..c5a0183bb7 100644 --- a/drivers/ps2/ps2_busywait.c +++ b/drivers/ps2/ps2_busywait.c | |||
| @@ -71,12 +71,12 @@ uint8_t ps2_host_send(uint8_t data) { | |||
| 71 | 71 | ||
| 72 | /* terminate a transmission if we have */ | 72 | /* terminate a transmission if we have */ |
| 73 | inhibit(); | 73 | inhibit(); |
| 74 | wait_us(100); // 100us [4]p.13, [5]p.50 | 74 | wait_us(100); // 100us [4]p.13, [5]p.50 |
| 75 | 75 | ||
| 76 | /* 'Request to Send' and Start bit */ | 76 | /* 'Request to Send' and Start bit */ |
| 77 | data_lo(); | 77 | data_lo(); |
| 78 | clock_hi(); | 78 | clock_hi(); |
| 79 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 | 79 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 |
| 80 | 80 | ||
| 81 | /* Data bit */ | 81 | /* Data bit */ |
| 82 | for (uint8_t i = 0; i < 8; i++) { | 82 | for (uint8_t i = 0; i < 8; i++) { |
| @@ -143,7 +143,7 @@ uint8_t ps2_host_recv(void) { | |||
| 143 | idle(); | 143 | idle(); |
| 144 | 144 | ||
| 145 | /* start bit [1] */ | 145 | /* start bit [1] */ |
| 146 | WAIT(clock_lo, 100, 1); // TODO: this is enough? | 146 | WAIT(clock_lo, 100, 1); // TODO: this is enough? |
| 147 | WAIT(data_lo, 1, 2); | 147 | WAIT(data_lo, 1, 2); |
| 148 | WAIT(clock_hi, 50, 3); | 148 | WAIT(clock_hi, 50, 3); |
| 149 | 149 | ||
diff --git a/drivers/ps2/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c index 70debd02f7..c49b4f8b75 100644 --- a/drivers/ps2/ps2_interrupt.c +++ b/drivers/ps2/ps2_interrupt.c | |||
| @@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. | |||
| 43 | 43 | ||
| 44 | #if defined(__AVR__) | 44 | #if defined(__AVR__) |
| 45 | # include <avr/interrupt.h> | 45 | # include <avr/interrupt.h> |
| 46 | #elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ? | 46 | #elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ? |
| 47 | // chibiOS headers | 47 | // chibiOS headers |
| 48 | # include "ch.h" | 48 | # include "ch.h" |
| 49 | # include "hal.h" | 49 | # include "hal.h" |
| @@ -71,7 +71,9 @@ static inline void pbuf_clear(void); | |||
| 71 | 71 | ||
| 72 | #if defined(PROTOCOL_CHIBIOS) | 72 | #if defined(PROTOCOL_CHIBIOS) |
| 73 | void ps2_interrupt_service_routine(void); | 73 | void ps2_interrupt_service_routine(void); |
| 74 | void palCallback(void *arg) { ps2_interrupt_service_routine(); } | 74 | void palCallback(void *arg) { |
| 75 | ps2_interrupt_service_routine(); | ||
| 76 | } | ||
| 75 | 77 | ||
| 76 | # define PS2_INT_INIT() \ | 78 | # define PS2_INT_INIT() \ |
| 77 | { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \ | 79 | { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \ |
| @@ -85,7 +87,7 @@ void palCallback(void *arg) { ps2_interrupt_service_routine(); } | |||
| 85 | # define PS2_INT_OFF() \ | 87 | # define PS2_INT_OFF() \ |
| 86 | { palDisableLineEvent(PS2_CLOCK_PIN); } \ | 88 | { palDisableLineEvent(PS2_CLOCK_PIN); } \ |
| 87 | while (0) | 89 | while (0) |
| 88 | #endif // PROTOCOL_CHIBIOS | 90 | #endif // PROTOCOL_CHIBIOS |
| 89 | 91 | ||
| 90 | void ps2_host_init(void) { | 92 | void ps2_host_init(void) { |
| 91 | idle(); | 93 | idle(); |
| @@ -103,12 +105,12 @@ uint8_t ps2_host_send(uint8_t data) { | |||
| 103 | 105 | ||
| 104 | /* terminate a transmission if we have */ | 106 | /* terminate a transmission if we have */ |
| 105 | inhibit(); | 107 | inhibit(); |
| 106 | wait_us(100); // 100us [4]p.13, [5]p.50 | 108 | wait_us(100); // 100us [4]p.13, [5]p.50 |
| 107 | 109 | ||
| 108 | /* 'Request to Send' and Start bit */ | 110 | /* 'Request to Send' and Start bit */ |
| 109 | data_lo(); | 111 | data_lo(); |
| 110 | clock_hi(); | 112 | clock_hi(); |
| 111 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 | 113 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 |
| 112 | 114 | ||
| 113 | /* Data bit[2-9] */ | 115 | /* Data bit[2-9] */ |
| 114 | for (uint8_t i = 0; i < 8; i++) { | 116 | for (uint8_t i = 0; i < 8; i++) { |
| @@ -244,7 +246,9 @@ RETURN: | |||
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | #if defined(__AVR__) | 248 | #if defined(__AVR__) |
| 247 | ISR(PS2_INT_VECT) { ps2_interrupt_service_routine(); } | 249 | ISR(PS2_INT_VECT) { |
| 250 | ps2_interrupt_service_routine(); | ||
| 251 | } | ||
| 248 | #endif | 252 | #endif |
| 249 | 253 | ||
| 250 | /* send LED state to keyboard */ | 254 | /* send LED state to keyboard */ |
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c index 8a6668b410..ccb0a929ae 100644 --- a/drivers/ps2/ps2_mouse.c +++ b/drivers/ps2/ps2_mouse.c | |||
| @@ -42,7 +42,7 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report); | |||
| 42 | void ps2_mouse_init(void) { | 42 | void ps2_mouse_init(void) { |
| 43 | ps2_host_init(); | 43 | ps2_host_init(); |
| 44 | 44 | ||
| 45 | wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up | 45 | wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up |
| 46 | 46 | ||
| 47 | PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset"); | 47 | PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset"); |
| 48 | 48 | ||
| @@ -113,9 +113,13 @@ void ps2_mouse_task(void) { | |||
| 113 | ps2_mouse_clear_report(&mouse_report); | 113 | ps2_mouse_clear_report(&mouse_report); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | void ps2_mouse_disable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); } | 116 | void ps2_mouse_disable_data_reporting(void) { |
| 117 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); | ||
| 118 | } | ||
| 117 | 119 | ||
| 118 | void ps2_mouse_enable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); } | 120 | void ps2_mouse_enable_data_reporting(void) { |
| 121 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); | ||
| 122 | } | ||
| 119 | 123 | ||
| 120 | void ps2_mouse_set_remote_mode(void) { | 124 | void ps2_mouse_set_remote_mode(void) { |
| 121 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); | 125 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); |
| @@ -127,13 +131,21 @@ void ps2_mouse_set_stream_mode(void) { | |||
| 127 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | 131 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; |
| 128 | } | 132 | } |
| 129 | 133 | ||
| 130 | void ps2_mouse_set_scaling_2_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); } | 134 | void ps2_mouse_set_scaling_2_1(void) { |
| 135 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); | ||
| 136 | } | ||
| 131 | 137 | ||
| 132 | void ps2_mouse_set_scaling_1_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); } | 138 | void ps2_mouse_set_scaling_1_1(void) { |
| 139 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); | ||
| 140 | } | ||
| 133 | 141 | ||
| 134 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution"); } | 142 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { |
| 143 | PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution"); | ||
| 144 | } | ||
| 135 | 145 | ||
| 136 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate"); } | 146 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) { |
| 147 | PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate"); | ||
| 148 | } | ||
| 137 | 149 | ||
| 138 | /* ============================= HELPERS ============================ */ | 150 | /* ============================= HELPERS ============================ */ |
| 139 | 151 | ||
| @@ -165,7 +177,7 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report) | |||
| 165 | #ifdef PS2_MOUSE_INVERT_X | 177 | #ifdef PS2_MOUSE_INVERT_X |
| 166 | mouse_report->x = -mouse_report->x; | 178 | mouse_report->x = -mouse_report->x; |
| 167 | #endif | 179 | #endif |
| 168 | #ifndef PS2_MOUSE_INVERT_Y // NOTE if not! | 180 | #ifndef PS2_MOUSE_INVERT_Y // NOTE if not! |
| 169 | // invert coordinate of y to conform to USB HID mouse | 181 | // invert coordinate of y to conform to USB HID mouse |
| 170 | mouse_report->y = -mouse_report->y; | 182 | mouse_report->y = -mouse_report->y; |
| 171 | #endif | 183 | #endif |
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c index c23d24d5af..b76268fba2 100644 --- a/drivers/sensors/adns5050.c +++ b/drivers/sensors/adns5050.c | |||
| @@ -74,9 +74,13 @@ void adns5050_sync(void) { | |||
| 74 | writePinHigh(ADNS5050_CS_PIN); | 74 | writePinHigh(ADNS5050_CS_PIN); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | void adns5050_cs_select(void) { writePinLow(ADNS5050_CS_PIN); } | 77 | void adns5050_cs_select(void) { |
| 78 | writePinLow(ADNS5050_CS_PIN); | ||
| 79 | } | ||
| 78 | 80 | ||
| 79 | void adns5050_cs_deselect(void) { writePinHigh(ADNS5050_CS_PIN); } | 81 | void adns5050_cs_deselect(void) { |
| 82 | writePinHigh(ADNS5050_CS_PIN); | ||
| 83 | } | ||
| 80 | 84 | ||
| 81 | uint8_t adns5050_serial_read(void) { | 85 | uint8_t adns5050_serial_read(void) { |
| 82 | setPinInput(ADNS5050_SDIO_PIN); | 86 | setPinInput(ADNS5050_SDIO_PIN); |
| @@ -190,7 +194,7 @@ int8_t convert_twoscomp(uint8_t data) { | |||
| 190 | 194 | ||
| 191 | // Don't forget to use the definitions for CPI in the header file. | 195 | // Don't forget to use the definitions for CPI in the header file. |
| 192 | void adns5050_set_cpi(uint16_t cpi) { | 196 | void adns5050_set_cpi(uint16_t cpi) { |
| 193 | uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119 | 197 | uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119 |
| 194 | 198 | ||
| 195 | adns5050_write_reg(REG_MOUSE_CONTROL2, 0b10000 | cpival); | 199 | adns5050_write_reg(REG_MOUSE_CONTROL2, 0b10000 | cpival); |
| 196 | } | 200 | } |
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c index d167841968..3633f23e52 100644 --- a/drivers/sensors/adns9800.c +++ b/drivers/sensors/adns9800.c | |||
| @@ -77,7 +77,9 @@ | |||
| 77 | #define MSB1 0x80 | 77 | #define MSB1 0x80 |
| 78 | // clang-format on | 78 | // clang-format on |
| 79 | 79 | ||
| 80 | void adns9800_spi_start(void) { spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR); } | 80 | void adns9800_spi_start(void) { |
| 81 | spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR); | ||
| 82 | } | ||
| 81 | 83 | ||
| 82 | void adns9800_write(uint8_t reg_addr, uint8_t data) { | 84 | void adns9800_write(uint8_t reg_addr, uint8_t data) { |
| 83 | adns9800_spi_start(); | 85 | adns9800_spi_start(); |
diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c index 1666bed047..95f8cff23a 100644 --- a/drivers/sensors/analog_joystick.c +++ b/drivers/sensors/analog_joystick.c | |||
| @@ -24,7 +24,7 @@ uint16_t minAxisValue = ANALOG_JOYSTICK_AXIS_MIN; | |||
| 24 | uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX; | 24 | uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX; |
| 25 | 25 | ||
| 26 | uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX; | 26 | uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX; |
| 27 | uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement | 27 | uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement |
| 28 | 28 | ||
| 29 | int16_t xOrigin, yOrigin; | 29 | int16_t xOrigin, yOrigin; |
| 30 | 30 | ||
diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c index b807c4f076..2db7f916fe 100644 --- a/drivers/sensors/cirque_pinnacle.c +++ b/drivers/sensors/cirque_pinnacle.c | |||
| @@ -54,7 +54,9 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count); | |||
| 54 | void RAP_Write(uint8_t address, uint8_t data); | 54 | void RAP_Write(uint8_t address, uint8_t data); |
| 55 | 55 | ||
| 56 | #ifdef CONSOLE_ENABLE | 56 | #ifdef CONSOLE_ENABLE |
| 57 | void print_byte(uint8_t byte) { xprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } | 57 | void print_byte(uint8_t byte) { |
| 58 | xprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); | ||
| 59 | } | ||
| 58 | #endif | 60 | #endif |
| 59 | 61 | ||
| 60 | /* Logical Scaling Functions */ | 62 | /* Logical Scaling Functions */ |
| @@ -73,8 +75,12 @@ void ClipCoordinates(pinnacle_data_t* coordinates) { | |||
| 73 | } | 75 | } |
| 74 | } | 76 | } |
| 75 | 77 | ||
| 76 | uint16_t cirque_pinnacle_get_scale(void) { return scale_data; } | 78 | uint16_t cirque_pinnacle_get_scale(void) { |
| 77 | void cirque_pinnacle_set_scale(uint16_t scale) { scale_data = scale; } | 79 | return scale_data; |
| 80 | } | ||
| 81 | void cirque_pinnacle_set_scale(uint16_t scale) { | ||
| 82 | scale_data = scale; | ||
| 83 | } | ||
| 78 | 84 | ||
| 79 | // Scales data to desired X & Y resolution | 85 | // Scales data to desired X & Y resolution |
| 80 | void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) { | 86 | void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) { |
| @@ -105,13 +111,13 @@ void cirque_pinnacle_clear_flags() { | |||
| 105 | void cirque_pinnacle_enable_feed(bool feedEnable) { | 111 | void cirque_pinnacle_enable_feed(bool feedEnable) { |
| 106 | uint8_t temp; | 112 | uint8_t temp; |
| 107 | 113 | ||
| 108 | RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register | 114 | RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register |
| 109 | 115 | ||
| 110 | if (feedEnable) { | 116 | if (feedEnable) { |
| 111 | temp |= 0x01; // Set Feed Enable bit | 117 | temp |= 0x01; // Set Feed Enable bit |
| 112 | RAP_Write(0x04, temp); | 118 | RAP_Write(0x04, temp); |
| 113 | } else { | 119 | } else { |
| 114 | temp &= ~0x01; // Clear Feed Enable bit | 120 | temp &= ~0x01; // Clear Feed Enable bit |
| 115 | RAP_Write(0x04, temp); | 121 | RAP_Write(0x04, temp); |
| 116 | } | 122 | } |
| 117 | } | 123 | } |
| @@ -122,13 +128,13 @@ void cirque_pinnacle_enable_feed(bool feedEnable) { | |||
| 122 | void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { | 128 | void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { |
| 123 | uint8_t ERAControlValue = 0xFF; | 129 | uint8_t ERAControlValue = 0xFF; |
| 124 | 130 | ||
| 125 | cirque_pinnacle_enable_feed(false); // Disable feed | 131 | cirque_pinnacle_enable_feed(false); // Disable feed |
| 126 | 132 | ||
| 127 | RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address | 133 | RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address |
| 128 | RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address | 134 | RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address |
| 129 | 135 | ||
| 130 | for (uint16_t i = 0; i < count; i++) { | 136 | for (uint16_t i = 0; i < count; i++) { |
| 131 | RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle | 137 | RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle |
| 132 | 138 | ||
| 133 | // Wait for status register 0x1E to clear | 139 | // Wait for status register 0x1E to clear |
| 134 | do { | 140 | do { |
| @@ -145,14 +151,14 @@ void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { | |||
| 145 | void ERA_WriteByte(uint16_t address, uint8_t data) { | 151 | void ERA_WriteByte(uint16_t address, uint8_t data) { |
| 146 | uint8_t ERAControlValue = 0xFF; | 152 | uint8_t ERAControlValue = 0xFF; |
| 147 | 153 | ||
| 148 | cirque_pinnacle_enable_feed(false); // Disable feed | 154 | cirque_pinnacle_enable_feed(false); // Disable feed |
| 149 | 155 | ||
| 150 | RAP_Write(ERA_VALUE, data); // Send data byte to be written | 156 | RAP_Write(ERA_VALUE, data); // Send data byte to be written |
| 151 | 157 | ||
| 152 | RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address | 158 | RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address |
| 153 | RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address | 159 | RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address |
| 154 | 160 | ||
| 155 | RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle | 161 | RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle |
| 156 | 162 | ||
| 157 | // Wait for status register 0x1E to clear | 163 | // Wait for status register 0x1E to clear |
| 158 | do { | 164 | do { |
| @@ -166,7 +172,7 @@ void cirque_pinnacle_set_adc_attenuation(uint8_t adcGain) { | |||
| 166 | uint8_t temp = 0x00; | 172 | uint8_t temp = 0x00; |
| 167 | 173 | ||
| 168 | ERA_ReadBytes(0x0187, &temp, 1); | 174 | ERA_ReadBytes(0x0187, &temp, 1); |
| 169 | temp &= 0x3F; // clear top two bits | 175 | temp &= 0x3F; // clear top two bits |
| 170 | temp |= adcGain; | 176 | temp |= adcGain; |
| 171 | ERA_WriteByte(0x0187, temp); | 177 | ERA_WriteByte(0x0187, temp); |
| 172 | ERA_ReadBytes(0x0187, &temp, 1); | 178 | ERA_ReadBytes(0x0187, &temp, 1); |
diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h index db891122a6..c8cb360e03 100644 --- a/drivers/sensors/cirque_pinnacle.h +++ b/drivers/sensors/cirque_pinnacle.h | |||
| @@ -26,16 +26,16 @@ void cirque_pinnacle_set_scale(uint16_t scale); | |||
| 26 | 26 | ||
| 27 | // Coordinate scaling values | 27 | // Coordinate scaling values |
| 28 | #ifndef CIRQUE_PINNACLE_X_LOWER | 28 | #ifndef CIRQUE_PINNACLE_X_LOWER |
| 29 | # define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value | 29 | # define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value |
| 30 | #endif | 30 | #endif |
| 31 | #ifndef CIRQUE_PINNACLE_X_UPPER | 31 | #ifndef CIRQUE_PINNACLE_X_UPPER |
| 32 | # define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value | 32 | # define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value |
| 33 | #endif | 33 | #endif |
| 34 | #ifndef CIRQUE_PINNACLE_Y_LOWER | 34 | #ifndef CIRQUE_PINNACLE_Y_LOWER |
| 35 | # define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value | 35 | # define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value |
| 36 | #endif | 36 | #endif |
| 37 | #ifndef CIRQUE_PINNACLE_Y_UPPER | 37 | #ifndef CIRQUE_PINNACLE_Y_UPPER |
| 38 | # define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value | 38 | # define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value |
| 39 | #endif | 39 | #endif |
| 40 | #ifndef CIRQUE_PINNACLE_X_RANGE | 40 | #ifndef CIRQUE_PINNACLE_X_RANGE |
| 41 | # define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER) | 41 | # define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER) |
diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c index 81dd982b0c..8a38f1dcea 100644 --- a/drivers/sensors/cirque_pinnacle_i2c.c +++ b/drivers/sensors/cirque_pinnacle_i2c.c | |||
| @@ -14,7 +14,7 @@ extern bool touchpad_init; | |||
| 14 | /* RAP Functions */ | 14 | /* RAP Functions */ |
| 15 | // Reads <count> Pinnacle registers starting at <address> | 15 | // Reads <count> Pinnacle registers starting at <address> |
| 16 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | 16 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { |
| 17 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte | 17 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte |
| 18 | if (touchpad_init) { | 18 | if (touchpad_init) { |
| 19 | i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); | 19 | i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); |
| 20 | if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { | 20 | if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { |
| @@ -29,7 +29,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | |||
| 29 | 29 | ||
| 30 | // Writes single-byte <data> to <address> | 30 | // Writes single-byte <data> to <address> |
| 31 | void RAP_Write(uint8_t address, uint8_t data) { | 31 | void RAP_Write(uint8_t address, uint8_t data) { |
| 32 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte | 32 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte |
| 33 | 33 | ||
| 34 | if (touchpad_init) { | 34 | if (touchpad_init) { |
| 35 | if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { | 35 | if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { |
diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c index ed40abd9fa..e00e73eb8c 100644 --- a/drivers/sensors/cirque_pinnacle_spi.c +++ b/drivers/sensors/cirque_pinnacle_spi.c | |||
| @@ -13,14 +13,14 @@ extern bool touchpad_init; | |||
| 13 | /* RAP Functions */ | 13 | /* RAP Functions */ |
| 14 | // Reads <count> Pinnacle registers starting at <address> | 14 | // Reads <count> Pinnacle registers starting at <address> |
| 15 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | 15 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { |
| 16 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte | 16 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte |
| 17 | if (touchpad_init) { | 17 | if (touchpad_init) { |
| 18 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { | 18 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { |
| 19 | spi_write(cmdByte); | 19 | spi_write(cmdByte); |
| 20 | spi_read(); // filler | 20 | spi_read(); // filler |
| 21 | spi_read(); // filler | 21 | spi_read(); // filler |
| 22 | for (uint8_t i = 0; i < count; i++) { | 22 | for (uint8_t i = 0; i < count; i++) { |
| 23 | data[i] = spi_read(); // each sepsequent read gets another register's contents | 23 | data[i] = spi_read(); // each sepsequent read gets another register's contents |
| 24 | } | 24 | } |
| 25 | } else { | 25 | } else { |
| 26 | #ifdef CONSOLE_ENABLE | 26 | #ifdef CONSOLE_ENABLE |
| @@ -34,7 +34,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | |||
| 34 | 34 | ||
| 35 | // Writes single-byte <data> to <address> | 35 | // Writes single-byte <data> to <address> |
| 36 | void RAP_Write(uint8_t address, uint8_t data) { | 36 | void RAP_Write(uint8_t address, uint8_t data) { |
| 37 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte | 37 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte |
| 38 | 38 | ||
| 39 | if (touchpad_init) { | 39 | if (touchpad_init) { |
| 40 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { | 40 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { |
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index 2867e763bc..333e017a06 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c | |||
| @@ -33,7 +33,9 @@ | |||
| 33 | 33 | ||
| 34 | static uint16_t precision = 128; | 34 | static uint16_t precision = 128; |
| 35 | 35 | ||
| 36 | uint16_t pimoroni_trackball_get_cpi(void) { return (precision * 125); } | 36 | uint16_t pimoroni_trackball_get_cpi(void) { |
| 37 | return (precision * 125); | ||
| 38 | } | ||
| 37 | /** | 39 | /** |
| 38 | * @brief Sets the scaling value for pimoroni trackball | 40 | * @brief Sets the scaling value for pimoroni trackball |
| 39 | * | 41 | * |
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c index 8d1b08e22b..8c977be1c8 100644 --- a/drivers/sensors/pmw3360.c +++ b/drivers/sensors/pmw3360.c | |||
| @@ -86,7 +86,9 @@ | |||
| 86 | bool _inBurst = false; | 86 | bool _inBurst = false; |
| 87 | 87 | ||
| 88 | #ifdef CONSOLE_ENABLE | 88 | #ifdef CONSOLE_ENABLE |
| 89 | void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } | 89 | void print_byte(uint8_t byte) { |
| 90 | dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); | ||
| 91 | } | ||
| 90 | #endif | 92 | #endif |
| 91 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) | 93 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) |
| 92 | 94 | ||
| @@ -144,7 +146,7 @@ bool pmw3360_init(void) { | |||
| 144 | pmw3360_spi_start(); | 146 | pmw3360_spi_start(); |
| 145 | spi_stop(); | 147 | spi_stop(); |
| 146 | 148 | ||
| 147 | pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first | 149 | pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first |
| 148 | wait_ms(300); | 150 | wait_ms(300); |
| 149 | 151 | ||
| 150 | pmw3360_spi_start(); | 152 | pmw3360_spi_start(); |
| @@ -222,7 +224,7 @@ bool pmw3360_check_signature(void) { | |||
| 222 | uint8_t pid = pmw3360_read(REG_Product_ID); | 224 | uint8_t pid = pmw3360_read(REG_Product_ID); |
| 223 | uint8_t iv_pid = pmw3360_read(REG_Inverse_Product_ID); | 225 | uint8_t iv_pid = pmw3360_read(REG_Inverse_Product_ID); |
| 224 | uint8_t SROM_ver = pmw3360_read(REG_SROM_ID); | 226 | uint8_t SROM_ver = pmw3360_read(REG_SROM_ID); |
| 225 | return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 | 227 | return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 |
| 226 | } | 228 | } |
| 227 | 229 | ||
| 228 | uint16_t pmw3360_get_cpi(void) { | 230 | uint16_t pmw3360_get_cpi(void) { |
| @@ -248,17 +250,17 @@ report_pmw3360_t pmw3360_read_burst(void) { | |||
| 248 | 250 | ||
| 249 | pmw3360_spi_start(); | 251 | pmw3360_spi_start(); |
| 250 | spi_write(REG_Motion_Burst); | 252 | spi_write(REG_Motion_Burst); |
| 251 | wait_us(35); // waits for tSRAD_MOTBR | 253 | wait_us(35); // waits for tSRAD_MOTBR |
| 252 | 254 | ||
| 253 | report.motion = spi_read(); | 255 | report.motion = spi_read(); |
| 254 | spi_read(); // skip Observation | 256 | spi_read(); // skip Observation |
| 255 | // delta registers | 257 | // delta registers |
| 256 | report.dx = spi_read(); | 258 | report.dx = spi_read(); |
| 257 | report.mdx = spi_read(); | 259 | report.mdx = spi_read(); |
| 258 | report.dy = spi_read(); | 260 | report.dy = spi_read(); |
| 259 | report.mdy = spi_read(); | 261 | report.mdy = spi_read(); |
| 260 | 262 | ||
| 261 | if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. | 263 | if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. |
| 262 | _inBurst = false; | 264 | _inBurst = false; |
| 263 | } | 265 | } |
| 264 | 266 | ||
diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h index 4e17aa0c46..eec7295871 100644 --- a/drivers/sensors/pmw3360.h +++ b/drivers/sensors/pmw3360.h | |||
| @@ -58,11 +58,11 @@ | |||
| 58 | 58 | ||
| 59 | typedef struct { | 59 | typedef struct { |
| 60 | int8_t motion; | 60 | int8_t motion; |
| 61 | bool isMotion; // True if a motion is detected. | 61 | bool isMotion; // True if a motion is detected. |
| 62 | bool isOnSurface; // True when a chip is on a surface | 62 | bool isOnSurface; // True when a chip is on a surface |
| 63 | int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) | 63 | int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) |
| 64 | int8_t mdx; | 64 | int8_t mdx; |
| 65 | int16_t dy; // displacement on y directions. | 65 | int16_t dy; // displacement on y directions. |
| 66 | int8_t mdy; | 66 | int8_t mdy; |
| 67 | } report_pmw3360_t; | 67 | } report_pmw3360_t; |
| 68 | 68 | ||
diff --git a/drivers/sensors/pmw3389.c b/drivers/sensors/pmw3389.c index 963925bd38..828dafa134 100644 --- a/drivers/sensors/pmw3389.c +++ b/drivers/sensors/pmw3389.c | |||
| @@ -90,7 +90,9 @@ | |||
| 90 | bool _inBurst = false; | 90 | bool _inBurst = false; |
| 91 | 91 | ||
| 92 | #ifdef CONSOLE_ENABLE | 92 | #ifdef CONSOLE_ENABLE |
| 93 | void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } | 93 | void print_byte(uint8_t byte) { |
| 94 | dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); | ||
| 95 | } | ||
| 94 | #endif | 96 | #endif |
| 95 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) | 97 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) |
| 96 | 98 | ||
| @@ -148,7 +150,7 @@ bool pmw3389_init(void) { | |||
| 148 | pmw3389_spi_start(); | 150 | pmw3389_spi_start(); |
| 149 | spi_stop(); | 151 | spi_stop(); |
| 150 | 152 | ||
| 151 | pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first | 153 | pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first |
| 152 | wait_ms(300); | 154 | wait_ms(300); |
| 153 | 155 | ||
| 154 | pmw3389_spi_start(); | 156 | pmw3389_spi_start(); |
| @@ -226,7 +228,7 @@ bool pmw3389_check_signature(void) { | |||
| 226 | uint8_t pid = pmw3389_read(REG_Product_ID); | 228 | uint8_t pid = pmw3389_read(REG_Product_ID); |
| 227 | uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID); | 229 | uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID); |
| 228 | uint8_t SROM_ver = pmw3389_read(REG_SROM_ID); | 230 | uint8_t SROM_ver = pmw3389_read(REG_SROM_ID); |
| 229 | return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 | 231 | return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 |
| 230 | } | 232 | } |
| 231 | 233 | ||
| 232 | uint16_t pmw3389_get_cpi(void) { | 234 | uint16_t pmw3389_get_cpi(void) { |
| @@ -254,17 +256,17 @@ report_pmw3389_t pmw3389_read_burst(void) { | |||
| 254 | 256 | ||
| 255 | pmw3389_spi_start(); | 257 | pmw3389_spi_start(); |
| 256 | spi_write(REG_Motion_Burst); | 258 | spi_write(REG_Motion_Burst); |
| 257 | wait_us(35); // waits for tSRAD_MOTBR | 259 | wait_us(35); // waits for tSRAD_MOTBR |
| 258 | 260 | ||
| 259 | report.motion = spi_read(); | 261 | report.motion = spi_read(); |
| 260 | spi_read(); // skip Observation | 262 | spi_read(); // skip Observation |
| 261 | // delta registers | 263 | // delta registers |
| 262 | report.dx = spi_read(); | 264 | report.dx = spi_read(); |
| 263 | report.mdx = spi_read(); | 265 | report.mdx = spi_read(); |
| 264 | report.dy = spi_read(); | 266 | report.dy = spi_read(); |
| 265 | report.mdy = spi_read(); | 267 | report.mdy = spi_read(); |
| 266 | 268 | ||
| 267 | if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. | 269 | if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. |
| 268 | _inBurst = false; | 270 | _inBurst = false; |
| 269 | } | 271 | } |
| 270 | 272 | ||
diff --git a/drivers/sensors/pmw3389.h b/drivers/sensors/pmw3389.h index a7c95e6076..db4a763fe3 100644 --- a/drivers/sensors/pmw3389.h +++ b/drivers/sensors/pmw3389.h | |||
| @@ -59,11 +59,11 @@ | |||
| 59 | 59 | ||
| 60 | typedef struct { | 60 | typedef struct { |
| 61 | int8_t motion; | 61 | int8_t motion; |
| 62 | bool isMotion; // True if a motion is detected. | 62 | bool isMotion; // True if a motion is detected. |
| 63 | bool isOnSurface; // True when a chip is on a surface | 63 | bool isOnSurface; // True when a chip is on a surface |
| 64 | int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) | 64 | int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) |
| 65 | int8_t mdx; | 65 | int8_t mdx; |
| 66 | int16_t dy; // displacement on y directions. | 66 | int16_t dy; // displacement on y directions. |
| 67 | int8_t mdy; | 67 | int8_t mdy; |
| 68 | } report_pmw3389_t; | 68 | } report_pmw3389_t; |
| 69 | 69 | ||
diff --git a/drivers/usb2422.c b/drivers/usb2422.c index 62b919093b..8ee54b24ee 100644 --- a/drivers/usb2422.c +++ b/drivers/usb2422.c | |||
| @@ -352,7 +352,7 @@ void USB2422_init() { | |||
| 352 | setPinInput(USB2422_ACTIVE_PIN); | 352 | setPinInput(USB2422_ACTIVE_PIN); |
| 353 | #endif | 353 | #endif |
| 354 | 354 | ||
| 355 | i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration | 355 | i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | void USB2422_configure() { | 358 | void USB2422_configure() { |
| @@ -363,14 +363,14 @@ void USB2422_configure() { | |||
| 363 | // configure Usb2422 registers | 363 | // configure Usb2422 registers |
| 364 | config.VID.reg = USB2422_VENDOR_ID; | 364 | config.VID.reg = USB2422_VENDOR_ID; |
| 365 | config.PID.reg = USB2422_PRODUCT_ID; | 365 | config.PID.reg = USB2422_PRODUCT_ID; |
| 366 | config.DID.reg = USB2422_DEVICE_VER; // BCD format, eg 01.01 | 366 | config.DID.reg = USB2422_DEVICE_VER; // BCD format, eg 01.01 |
| 367 | config.CFG1.bit.SELF_BUS_PWR = 1; // self powered for now | 367 | config.CFG1.bit.SELF_BUS_PWR = 1; // self powered for now |
| 368 | config.CFG1.bit.HS_DISABLE = 1; // full or high speed | 368 | config.CFG1.bit.HS_DISABLE = 1; // full or high speed |
| 369 | // config.CFG2.bit.COMPOUND = 0; // compound device | 369 | // config.CFG2.bit.COMPOUND = 0; // compound device |
| 370 | config.CFG3.bit.STRING_EN = 1; // strings enabled | 370 | config.CFG3.bit.STRING_EN = 1; // strings enabled |
| 371 | // config.NRD.bit.PORT2_NR = 0; // MCU is non-removable | 371 | // config.NRD.bit.PORT2_NR = 0; // MCU is non-removable |
| 372 | config.MAXPB.reg = 20; // 0mA | 372 | config.MAXPB.reg = 20; // 0mA |
| 373 | config.HCMCB.reg = 20; // 0mA | 373 | config.HCMCB.reg = 20; // 0mA |
| 374 | config.MFRSL.reg = sizeof(USB2422_MANUFACTURER); | 374 | config.MFRSL.reg = sizeof(USB2422_MANUFACTURER); |
| 375 | config.PRDSL.reg = sizeof(USB2422_PRODUCT); | 375 | config.PRDSL.reg = sizeof(USB2422_PRODUCT); |
| 376 | config.SERSL.reg = sizeof(SERNAME); | 376 | config.SERSL.reg = sizeof(SERNAME); |
diff --git a/drivers/ws2812.h b/drivers/ws2812.h index 945b3d0728..5985b5340c 100644 --- a/drivers/ws2812.h +++ b/drivers/ws2812.h | |||
| @@ -33,19 +33,19 @@ | |||
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #ifndef WS2812_T1H | 35 | #ifndef WS2812_T1H |
| 36 | # define WS2812_T1H 900 // Width of a 1 bit in ns | 36 | # define WS2812_T1H 900 // Width of a 1 bit in ns |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #ifndef WS2812_T1L | 39 | #ifndef WS2812_T1L |
| 40 | # define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns | 40 | # define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | #ifndef WS2812_T0H | 43 | #ifndef WS2812_T0H |
| 44 | # define WS2812_T0H 350 // Width of a 0 bit in ns | 44 | # define WS2812_T0H 350 // Width of a 0 bit in ns |
| 45 | #endif | 45 | #endif |
| 46 | 46 | ||
| 47 | #ifndef WS2812_T0L | 47 | #ifndef WS2812_T0L |
| 48 | # define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns | 48 | # define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | /* | 51 | /* |
diff --git a/platforms/arm_atsam/bootloaders/md_boot.c b/platforms/arm_atsam/bootloaders/md_boot.c index 9cf16f3597..32cf850448 100644 --- a/platforms/arm_atsam/bootloaders/md_boot.c +++ b/platforms/arm_atsam/bootloaders/md_boot.c | |||
| @@ -26,20 +26,20 @@ extern uint32_t _eram; | |||
| 26 | // CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method. | 26 | // CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method. |
| 27 | void bootloader_jump(void) { | 27 | void bootloader_jump(void) { |
| 28 | #ifdef KEYBOARD_massdrop_ctrl | 28 | #ifdef KEYBOARD_massdrop_ctrl |
| 29 | uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; // The version to match (NULL terminated by compiler) | 29 | uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; // The version to match (NULL terminated by compiler) |
| 30 | uint8_t *ver_check = ver_ram_method; // Pointer to version match string for traversal | 30 | uint8_t *ver_check = ver_ram_method; // Pointer to version match string for traversal |
| 31 | uint8_t *ver_rom = (uint8_t *)0x21A0; // Pointer to address in ROM where this specific bootloader version would exist | 31 | uint8_t *ver_rom = (uint8_t *)0x21A0; // Pointer to address in ROM where this specific bootloader version would exist |
| 32 | 32 | ||
| 33 | while (*ver_check && *ver_rom == *ver_check) { // While there are check version characters to match and bootloader's version matches check's version | 33 | while (*ver_check && *ver_rom == *ver_check) { // While there are check version characters to match and bootloader's version matches check's version |
| 34 | ver_check++; // Move check version pointer to next character | 34 | ver_check++; // Move check version pointer to next character |
| 35 | ver_rom++; // Move ROM version pointer to next character | 35 | ver_rom++; // Move ROM version pointer to next character |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | if (!*ver_check) { // If check version pointer is NULL, all characters have matched | 38 | if (!*ver_check) { // If check version pointer is NULL, all characters have matched |
| 39 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM | 39 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM |
| 40 | NVIC_SystemReset(); // Perform system reset | 40 | NVIC_SystemReset(); // Perform system reset |
| 41 | while (1) | 41 | while (1) |
| 42 | ; // Won't get here | 42 | ; // Won't get here |
| 43 | } | 43 | } |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| @@ -61,5 +61,5 @@ void bootloader_jump(void) { | |||
| 61 | while (!WDT->CTRLA.bit.ENABLE) | 61 | while (!WDT->CTRLA.bit.ENABLE) |
| 62 | ; | 62 | ; |
| 63 | while (1) | 63 | while (1) |
| 64 | ; // Wait on timeout | 64 | ; // Wait on timeout |
| 65 | } | 65 | } |
diff --git a/platforms/arm_atsam/eeprom_samd.c b/platforms/arm_atsam/eeprom_samd.c index beaffeec30..1c1e031e5d 100644 --- a/platforms/arm_atsam/eeprom_samd.c +++ b/platforms/arm_atsam/eeprom_samd.c | |||
| @@ -155,7 +155,9 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); } | 158 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { |
| 159 | eeprom_write_byte(addr, value); | ||
| 160 | } | ||
| 159 | 161 | ||
| 160 | void eeprom_update_word(uint16_t *addr, uint16_t value) { | 162 | void eeprom_update_word(uint16_t *addr, uint16_t value) { |
| 161 | uint8_t *p = (uint8_t *)addr; | 163 | uint8_t *p = (uint8_t *)addr; |
diff --git a/platforms/arm_atsam/eeprom_samd.h b/platforms/arm_atsam/eeprom_samd.h index 7dbff9bfa1..878e72865c 100755..100644 --- a/platforms/arm_atsam/eeprom_samd.h +++ b/platforms/arm_atsam/eeprom_samd.h | |||
| @@ -4,5 +4,5 @@ | |||
| 4 | 4 | ||
| 5 | #ifndef EEPROM_SIZE | 5 | #ifndef EEPROM_SIZE |
| 6 | # include "eeconfig.h" | 6 | # include "eeconfig.h" |
| 7 | # define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO | 7 | # define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO |
| 8 | #endif | 8 | #endif |
diff --git a/platforms/arm_atsam/suspend.c b/platforms/arm_atsam/suspend.c index de2285bc5f..242e9c91a2 100644 --- a/platforms/arm_atsam/suspend.c +++ b/platforms/arm_atsam/suspend.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | void suspend_power_down(void) { | 10 | void suspend_power_down(void) { |
| 11 | #ifdef RGB_MATRIX_ENABLE | 11 | #ifdef RGB_MATRIX_ENABLE |
| 12 | I2C3733_Control_Set(0); // Disable LED driver | 12 | I2C3733_Control_Set(0); // Disable LED driver |
| 13 | #endif | 13 | #endif |
| 14 | 14 | ||
| 15 | suspend_power_down_kb(); | 15 | suspend_power_down_kb(); |
diff --git a/platforms/arm_atsam/timer.c b/platforms/arm_atsam/timer.c index b835dd5e75..cf01e3625e 100644 --- a/platforms/arm_atsam/timer.c +++ b/platforms/arm_atsam/timer.c | |||
| @@ -2,18 +2,34 @@ | |||
| 2 | #include "timer.h" | 2 | #include "timer.h" |
| 3 | #include "tmk_core/protocol/arm_atsam/clks.h" | 3 | #include "tmk_core/protocol/arm_atsam/clks.h" |
| 4 | 4 | ||
| 5 | void set_time(uint64_t tset) { ms_clk = tset; } | 5 | void set_time(uint64_t tset) { |
| 6 | ms_clk = tset; | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | void timer_init(void) { timer_clear(); } | 9 | void timer_init(void) { |
| 10 | timer_clear(); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | uint16_t timer_read(void) { return (uint16_t)ms_clk; } | 13 | uint16_t timer_read(void) { |
| 14 | return (uint16_t)ms_clk; | ||
| 15 | } | ||
| 10 | 16 | ||
| 11 | uint32_t timer_read32(void) { return (uint32_t)ms_clk; } | 17 | uint32_t timer_read32(void) { |
| 18 | return (uint32_t)ms_clk; | ||
| 19 | } | ||
| 12 | 20 | ||
| 13 | uint64_t timer_read64(void) { return ms_clk; } | 21 | uint64_t timer_read64(void) { |
| 22 | return ms_clk; | ||
| 23 | } | ||
| 14 | 24 | ||
| 15 | uint16_t timer_elapsed(uint16_t tlast) { return TIMER_DIFF_16(timer_read(), tlast); } | 25 | uint16_t timer_elapsed(uint16_t tlast) { |
| 26 | return TIMER_DIFF_16(timer_read(), tlast); | ||
| 27 | } | ||
| 16 | 28 | ||
| 17 | uint32_t timer_elapsed32(uint32_t tlast) { return TIMER_DIFF_32(timer_read32(), tlast); } | 29 | uint32_t timer_elapsed32(uint32_t tlast) { |
| 30 | return TIMER_DIFF_32(timer_read32(), tlast); | ||
| 31 | } | ||
| 18 | 32 | ||
| 19 | void timer_clear(void) { set_time(0); } | 33 | void timer_clear(void) { |
| 34 | set_time(0); | ||
| 35 | } | ||
diff --git a/platforms/avr/bootloaders/dfu.c b/platforms/avr/bootloaders/dfu.c index cb42821a93..06b2c8963a 100644 --- a/platforms/avr/bootloaders/dfu.c +++ b/platforms/avr/bootloaders/dfu.c | |||
| @@ -30,9 +30,9 @@ uint32_t reset_key __attribute__((section(".noinit,\"aw\",@nobits;"))); | |||
| 30 | 30 | ||
| 31 | __attribute__((weak)) void bootloader_jump(void) { | 31 | __attribute__((weak)) void bootloader_jump(void) { |
| 32 | UDCON = 1; | 32 | UDCON = 1; |
| 33 | USBCON = (1 << FRZCLK); // disable USB | 33 | USBCON = (1 << FRZCLK); // disable USB |
| 34 | UCSR1B = 0; | 34 | UCSR1B = 0; |
| 35 | _delay_ms(5); // 5 seems to work fine | 35 | _delay_ms(5); // 5 seems to work fine |
| 36 | 36 | ||
| 37 | // watchdog reset | 37 | // watchdog reset |
| 38 | reset_key = BOOTLOADER_RESET_KEY; | 38 | reset_key = BOOTLOADER_RESET_KEY; |
diff --git a/platforms/avr/bootloaders/halfkay.c b/platforms/avr/bootloaders/halfkay.c index 6ce2e19114..651696f988 100644 --- a/platforms/avr/bootloaders/halfkay.c +++ b/platforms/avr/bootloaders/halfkay.c | |||
| @@ -27,11 +27,11 @@ __attribute__((weak)) void bootloader_jump(void) { | |||
| 27 | // disable all peripherals | 27 | // disable all peripherals |
| 28 | // a shutdown call might make sense here | 28 | // a shutdown call might make sense here |
| 29 | UDCON = 1; | 29 | UDCON = 1; |
| 30 | USBCON = (1 << FRZCLK); // disable USB | 30 | USBCON = (1 << FRZCLK); // disable USB |
| 31 | UCSR1B = 0; | 31 | UCSR1B = 0; |
| 32 | _delay_ms(5); | 32 | _delay_ms(5); |
| 33 | 33 | ||
| 34 | #if defined(__AVR_AT90USB162__) // Teensy 1.0 | 34 | #if defined(__AVR_AT90USB162__) // Teensy 1.0 |
| 35 | EIMSK = 0; | 35 | EIMSK = 0; |
| 36 | PCICR = 0; | 36 | PCICR = 0; |
| 37 | SPCR = 0; | 37 | SPCR = 0; |
| @@ -47,7 +47,7 @@ __attribute__((weak)) void bootloader_jump(void) { | |||
| 47 | PORTC = 0; | 47 | PORTC = 0; |
| 48 | PORTD = 0; | 48 | PORTD = 0; |
| 49 | asm volatile("jmp 0x3E00"); | 49 | asm volatile("jmp 0x3E00"); |
| 50 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 | 50 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 |
| 51 | EIMSK = 0; | 51 | EIMSK = 0; |
| 52 | PCICR = 0; | 52 | PCICR = 0; |
| 53 | SPCR = 0; | 53 | SPCR = 0; |
| @@ -72,7 +72,7 @@ __attribute__((weak)) void bootloader_jump(void) { | |||
| 72 | PORTE = 0; | 72 | PORTE = 0; |
| 73 | PORTF = 0; | 73 | PORTF = 0; |
| 74 | asm volatile("jmp 0x7E00"); | 74 | asm volatile("jmp 0x7E00"); |
| 75 | #elif defined(__AVR_AT90USB646__) // Teensy++ 1.0 | 75 | #elif defined(__AVR_AT90USB646__) // Teensy++ 1.0 |
| 76 | EIMSK = 0; | 76 | EIMSK = 0; |
| 77 | PCICR = 0; | 77 | PCICR = 0; |
| 78 | SPCR = 0; | 78 | SPCR = 0; |
| @@ -98,7 +98,7 @@ __attribute__((weak)) void bootloader_jump(void) { | |||
| 98 | PORTE = 0; | 98 | PORTE = 0; |
| 99 | PORTF = 0; | 99 | PORTF = 0; |
| 100 | asm volatile("jmp 0xFC00"); | 100 | asm volatile("jmp 0xFC00"); |
| 101 | #elif defined(__AVR_AT90USB1286__) // Teensy++ 2.0 | 101 | #elif defined(__AVR_AT90USB1286__) // Teensy++ 2.0 |
| 102 | EIMSK = 0; | 102 | EIMSK = 0; |
| 103 | PCICR = 0; | 103 | PCICR = 0; |
| 104 | SPCR = 0; | 104 | SPCR = 0; |
diff --git a/platforms/avr/drivers/analog.c b/platforms/avr/drivers/analog.c index 628835ccef..ed4d563609 100644 --- a/platforms/avr/drivers/analog.c +++ b/platforms/avr/drivers/analog.c | |||
| @@ -21,9 +21,13 @@ | |||
| 21 | 21 | ||
| 22 | static uint8_t aref = ADC_REF_POWER; | 22 | static uint8_t aref = ADC_REF_POWER; |
| 23 | 23 | ||
| 24 | void analogReference(uint8_t mode) { aref = mode & (_BV(REFS1) | _BV(REFS0)); } | 24 | void analogReference(uint8_t mode) { |
| 25 | aref = mode & (_BV(REFS1) | _BV(REFS0)); | ||
| 26 | } | ||
| 25 | 27 | ||
| 26 | int16_t analogReadPin(pin_t pin) { return adc_read(pinToMux(pin)); } | 28 | int16_t analogReadPin(pin_t pin) { |
| 29 | return adc_read(pinToMux(pin)); | ||
| 30 | } | ||
| 27 | 31 | ||
| 28 | uint8_t pinToMux(pin_t pin) { | 32 | uint8_t pinToMux(pin_t pin) { |
| 29 | switch (pin) { | 33 | switch (pin) { |
diff --git a/platforms/avr/drivers/analog.h b/platforms/avr/drivers/analog.h index fa2fb0d89b..fb13e106ff 100644 --- a/platforms/avr/drivers/analog.h +++ b/platforms/avr/drivers/analog.h | |||
| @@ -32,21 +32,21 @@ int16_t adc_read(uint8_t mux); | |||
| 32 | } | 32 | } |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define ADC_REF_EXTERNAL 0 // AREF, Internal Vref turned off | 35 | #define ADC_REF_EXTERNAL 0 // AREF, Internal Vref turned off |
| 36 | #define ADC_REF_POWER _BV(REFS0) // AVCC with external capacitor on AREF pin | 36 | #define ADC_REF_POWER _BV(REFS0) // AVCC with external capacitor on AREF pin |
| 37 | #define ADC_REF_INTERNAL (_BV(REFS1) | _BV(REFS0)) // Internal 2.56V Voltage Reference with external capacitor on AREF pin (1.1V for 328P) | 37 | #define ADC_REF_INTERNAL (_BV(REFS1) | _BV(REFS0)) // Internal 2.56V Voltage Reference with external capacitor on AREF pin (1.1V for 328P) |
| 38 | 38 | ||
| 39 | // These prescaler values are for high speed mode, ADHSM = 1 | 39 | // These prescaler values are for high speed mode, ADHSM = 1 |
| 40 | #if F_CPU == 16000000L || F_CPU == 12000000L | 40 | #if F_CPU == 16000000L || F_CPU == 12000000L |
| 41 | # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS1)) // /64 | 41 | # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS1)) // /64 |
| 42 | #elif F_CPU == 8000000L | 42 | #elif F_CPU == 8000000L |
| 43 | # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS0)) // /32 | 43 | # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS0)) // /32 |
| 44 | #elif F_CPU == 4000000L | 44 | #elif F_CPU == 4000000L |
| 45 | # define ADC_PRESCALER (_BV(ADPS2)) // /16 | 45 | # define ADC_PRESCALER (_BV(ADPS2)) // /16 |
| 46 | #elif F_CPU == 2000000L | 46 | #elif F_CPU == 2000000L |
| 47 | # define ADC_PRESCALER (_BV(ADPS1) | _BV(ADPS0)) // /8 | 47 | # define ADC_PRESCALER (_BV(ADPS1) | _BV(ADPS0)) // /8 |
| 48 | #elif F_CPU == 1000000L | 48 | #elif F_CPU == 1000000L |
| 49 | # define ADC_PRESCALER _BV(ADPS1) // /4 | 49 | # define ADC_PRESCALER _BV(ADPS1) // /4 |
| 50 | #else | 50 | #else |
| 51 | # define ADC_PRESCALER _BV(ADPS0) // /2 | 51 | # define ADC_PRESCALER _BV(ADPS0) // /2 |
| 52 | #endif | 52 | #endif |
diff --git a/platforms/avr/drivers/audio_pwm_hardware.c b/platforms/avr/drivers/audio_pwm_hardware.c index df03a4558c..78776ee48a 100644 --- a/platforms/avr/drivers/audio_pwm_hardware.c +++ b/platforms/avr/drivers/audio_pwm_hardware.c | |||
| @@ -152,7 +152,7 @@ extern uint8_t note_timbre; | |||
| 152 | #ifdef AUDIO1_PIN_SET | 152 | #ifdef AUDIO1_PIN_SET |
| 153 | static float channel_1_frequency = 0.0f; | 153 | static float channel_1_frequency = 0.0f; |
| 154 | void channel_1_set_frequency(float freq) { | 154 | void channel_1_set_frequency(float freq) { |
| 155 | if (freq == 0.0f) // a pause/rest is a valid "note" with freq=0 | 155 | if (freq == 0.0f) // a pause/rest is a valid "note" with freq=0 |
| 156 | { | 156 | { |
| 157 | // disable the output, but keep the pwm-ISR going (with the previous | 157 | // disable the output, but keep the pwm-ISR going (with the previous |
| 158 | // frequency) so the audio-state keeps getting updated | 158 | // frequency) so the audio-state keeps getting updated |
| @@ -160,7 +160,7 @@ void channel_1_set_frequency(float freq) { | |||
| 160 | AUDIO1_TCCRxA &= ~(_BV(AUDIO1_COMxy1) | _BV(AUDIO1_COMxy0)); | 160 | AUDIO1_TCCRxA &= ~(_BV(AUDIO1_COMxy1) | _BV(AUDIO1_COMxy0)); |
| 161 | return; | 161 | return; |
| 162 | } else { | 162 | } else { |
| 163 | AUDIO1_TCCRxA |= _BV(AUDIO1_COMxy1); // enable output, PWM mode | 163 | AUDIO1_TCCRxA |= _BV(AUDIO1_COMxy1); // enable output, PWM mode |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | channel_1_frequency = freq; | 166 | channel_1_frequency = freq; |
| @@ -202,7 +202,9 @@ void channel_2_set_frequency(float freq) { | |||
| 202 | AUDIO2_OCRxy = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre / 100); | 202 | AUDIO2_OCRxy = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre / 100); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | float channel_2_get_frequency(void) { return channel_2_frequency; } | 205 | float channel_2_get_frequency(void) { |
| 206 | return channel_2_frequency; | ||
| 207 | } | ||
| 206 | 208 | ||
| 207 | void channel_2_start(void) { | 209 | void channel_2_start(void) { |
| 208 | AUDIO2_TIMSKx |= _BV(AUDIO2_OCIExy); | 210 | AUDIO2_TIMSKx |= _BV(AUDIO2_OCIExy); |
diff --git a/platforms/avr/drivers/glcdfont.c b/platforms/avr/drivers/glcdfont.c index 5e763b054f..57a21965de 100644 --- a/platforms/avr/drivers/glcdfont.c +++ b/platforms/avr/drivers/glcdfont.c | |||
| @@ -10,14 +10,14 @@ static const unsigned char font[] PROGMEM = { | |||
| 10 | 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, | 10 | 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, |
| 11 | 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, | 11 | 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, |
| 12 | 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, | 12 | 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, |
| 13 | 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut | 13 | 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut |
| 14 | 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut | 14 | 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut |
| 15 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut | 15 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut |
| 16 | 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut | 16 | 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut |
| 17 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code | 17 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code |
| 18 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block | 18 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block |
| 19 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block | 19 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block |
| 20 | 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, | 20 | 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, |
| 21 | 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta | 21 | 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta |
| 22 | 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP | 22 | 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP |
| 23 | }; | 23 | }; |
diff --git a/platforms/avr/drivers/hd44780.c b/platforms/avr/drivers/hd44780.c index f71069dece..f15d7d0da8 100644 --- a/platforms/avr/drivers/hd44780.c +++ b/platforms/avr/drivers/hd44780.c | |||
| @@ -262,7 +262,7 @@ static uint8_t lcd_waitbusy(void) | |||
| 262 | delay(LCD_DELAY_BUSY_FLAG); | 262 | delay(LCD_DELAY_BUSY_FLAG); |
| 263 | 263 | ||
| 264 | /* now read the address counter */ | 264 | /* now read the address counter */ |
| 265 | return (lcd_read(0)); // return address counter | 265 | return (lcd_read(0)); // return address counter |
| 266 | 266 | ||
| 267 | } /* lcd_waitbusy */ | 267 | } /* lcd_waitbusy */ |
| 268 | 268 | ||
| @@ -362,17 +362,23 @@ void lcd_gotoxy(uint8_t x, uint8_t y) { | |||
| 362 | 362 | ||
| 363 | /************************************************************************* | 363 | /************************************************************************* |
| 364 | *************************************************************************/ | 364 | *************************************************************************/ |
| 365 | int lcd_getxy(void) { return lcd_waitbusy(); } | 365 | int lcd_getxy(void) { |
| 366 | return lcd_waitbusy(); | ||
| 367 | } | ||
| 366 | 368 | ||
| 367 | /************************************************************************* | 369 | /************************************************************************* |
| 368 | Clear display and set cursor to home position | 370 | Clear display and set cursor to home position |
| 369 | *************************************************************************/ | 371 | *************************************************************************/ |
| 370 | void lcd_clrscr(void) { lcd_command(1 << LCD_CLR); } | 372 | void lcd_clrscr(void) { |
| 373 | lcd_command(1 << LCD_CLR); | ||
| 374 | } | ||
| 371 | 375 | ||
| 372 | /************************************************************************* | 376 | /************************************************************************* |
| 373 | Set cursor to home position | 377 | Set cursor to home position |
| 374 | *************************************************************************/ | 378 | *************************************************************************/ |
| 375 | void lcd_home(void) { lcd_command(1 << LCD_HOME); } | 379 | void lcd_home(void) { |
| 380 | lcd_command(1 << LCD_HOME); | ||
| 381 | } | ||
| 376 | 382 | ||
| 377 | /************************************************************************* | 383 | /************************************************************************* |
| 378 | Display character at current cursor position | 384 | Display character at current cursor position |
| @@ -382,7 +388,7 @@ Returns: none | |||
| 382 | void lcd_putc(char c) { | 388 | void lcd_putc(char c) { |
| 383 | uint8_t pos; | 389 | uint8_t pos; |
| 384 | 390 | ||
| 385 | pos = lcd_waitbusy(); // read busy-flag and address counter | 391 | pos = lcd_waitbusy(); // read busy-flag and address counter |
| 386 | if (c == '\n') { | 392 | if (c == '\n') { |
| 387 | lcd_newline(pos); | 393 | lcd_newline(pos); |
| 388 | } else { | 394 | } else { |
| @@ -483,8 +489,8 @@ void lcd_init(uint8_t dispAttr) { | |||
| 483 | delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */ | 489 | delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */ |
| 484 | 490 | ||
| 485 | /* initial write to lcd is 8bit */ | 491 | /* initial write to lcd is 8bit */ |
| 486 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4; | 492 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4; |
| 487 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4; | 493 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4; |
| 488 | lcd_e_toggle(); | 494 | lcd_e_toggle(); |
| 489 | delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */ | 495 | delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */ |
| 490 | 496 | ||
| @@ -497,7 +503,7 @@ void lcd_init(uint8_t dispAttr) { | |||
| 497 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ | 503 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ |
| 498 | 504 | ||
| 499 | /* now configure for 4bit mode */ | 505 | /* now configure for 4bit mode */ |
| 500 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4 | 506 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4 |
| 501 | lcd_e_toggle(); | 507 | lcd_e_toggle(); |
| 502 | delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */ | 508 | delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */ |
| 503 | 509 | ||
diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index d4024378ca..c1a7b5f72d 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c | |||
| @@ -25,12 +25,12 @@ | |||
| 25 | #include "wait.h" | 25 | #include "wait.h" |
| 26 | 26 | ||
| 27 | #ifndef F_SCL | 27 | #ifndef F_SCL |
| 28 | # define F_SCL 400000UL // SCL frequency | 28 | # define F_SCL 400000UL // SCL frequency |
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
| 31 | #ifndef I2C_START_RETRY_COUNT | 31 | #ifndef I2C_START_RETRY_COUNT |
| 32 | # define I2C_START_RETRY_COUNT 20 | 32 | # define I2C_START_RETRY_COUNT 20 |
| 33 | #endif // I2C_START_RETRY_COUNT | 33 | #endif // I2C_START_RETRY_COUNT |
| 34 | 34 | ||
| 35 | #define I2C_ACTION_READ 0x01 | 35 | #define I2C_ACTION_READ 0x01 |
| 36 | #define I2C_ACTION_WRITE 0x00 | 36 | #define I2C_ACTION_WRITE 0x00 |
| @@ -98,7 +98,7 @@ static i2c_status_t i2c_start_impl(uint8_t address, uint16_t timeout) { | |||
| 98 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | 98 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { |
| 99 | // Retry i2c_start_impl a bunch times in case the remote side has interrupts disabled. | 99 | // Retry i2c_start_impl a bunch times in case the remote side has interrupts disabled. |
| 100 | uint16_t timeout_timer = timer_read(); | 100 | uint16_t timeout_timer = timer_read(); |
| 101 | uint16_t time_slice = MAX(1, (timeout == (I2C_TIMEOUT_INFINITE)) ? 5 : (timeout / (I2C_START_RETRY_COUNT))); // if it's infinite, wait 1ms between attempts, otherwise split up the entire timeout into the number of retries | 101 | uint16_t time_slice = MAX(1, (timeout == (I2C_TIMEOUT_INFINITE)) ? 5 : (timeout / (I2C_START_RETRY_COUNT))); // if it's infinite, wait 1ms between attempts, otherwise split up the entire timeout into the number of retries |
| 102 | i2c_status_t status; | 102 | i2c_status_t status; |
| 103 | do { | 103 | do { |
| 104 | status = i2c_start_impl(address, time_slice); | 104 | status = i2c_start_impl(address, time_slice); |
diff --git a/platforms/avr/drivers/i2c_slave.c b/platforms/avr/drivers/i2c_slave.c index 2907f164c0..660d271be2 100644 --- a/platforms/avr/drivers/i2c_slave.c +++ b/platforms/avr/drivers/i2c_slave.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | # include "transactions.h" | 29 | # include "transactions.h" |
| 30 | 30 | ||
| 31 | static volatile bool is_callback_executor = false; | 31 | static volatile bool is_callback_executor = false; |
| 32 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 32 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 33 | 33 | ||
| 34 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; | 34 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; |
| 35 | 35 | ||
| @@ -57,7 +57,7 @@ ISR(TWI_vect) { | |||
| 57 | slave_has_register_set = false; | 57 | slave_has_register_set = false; |
| 58 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 58 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 59 | is_callback_executor = false; | 59 | is_callback_executor = false; |
| 60 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 60 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 61 | break; | 61 | break; |
| 62 | 62 | ||
| 63 | case TW_SR_DATA_ACK: | 63 | case TW_SR_DATA_ACK: |
| @@ -66,16 +66,16 @@ ISR(TWI_vect) { | |||
| 66 | if (!slave_has_register_set) { | 66 | if (!slave_has_register_set) { |
| 67 | buffer_address = TWDR; | 67 | buffer_address = TWDR; |
| 68 | 68 | ||
| 69 | if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack | 69 | if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack |
| 70 | ack = 0; | 70 | ack = 0; |
| 71 | buffer_address = 0; | 71 | buffer_address = 0; |
| 72 | } | 72 | } |
| 73 | slave_has_register_set = true; // address has been received now fill in buffer | 73 | slave_has_register_set = true; // address has been received now fill in buffer |
| 74 | 74 | ||
| 75 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 75 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 76 | // Work out if we're attempting to execute a callback | 76 | // Work out if we're attempting to execute a callback |
| 77 | is_callback_executor = buffer_address == split_transaction_table[I2C_EXECUTE_CALLBACK].initiator2target_offset; | 77 | is_callback_executor = buffer_address == split_transaction_table[I2C_EXECUTE_CALLBACK].initiator2target_offset; |
| 78 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 78 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 79 | } else { | 79 | } else { |
| 80 | i2c_slave_reg[buffer_address] = TWDR; | 80 | i2c_slave_reg[buffer_address] = TWDR; |
| 81 | buffer_address++; | 81 | buffer_address++; |
| @@ -88,7 +88,7 @@ ISR(TWI_vect) { | |||
| 88 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); | 88 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); |
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 91 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 92 | } | 92 | } |
| 93 | break; | 93 | break; |
| 94 | 94 | ||
diff --git a/platforms/avr/drivers/i2c_slave.h b/platforms/avr/drivers/i2c_slave.h index a8647c9da3..178b6a29df 100644 --- a/platforms/avr/drivers/i2c_slave.h +++ b/platforms/avr/drivers/i2c_slave.h | |||
| @@ -27,11 +27,11 @@ | |||
| 27 | # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 27 | # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 28 | # include "transport.h" | 28 | # include "transport.h" |
| 29 | # define I2C_SLAVE_REG_COUNT sizeof(split_shared_memory_t) | 29 | # define I2C_SLAVE_REG_COUNT sizeof(split_shared_memory_t) |
| 30 | # else // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 30 | # else // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 31 | # define I2C_SLAVE_REG_COUNT 30 | 31 | # define I2C_SLAVE_REG_COUNT 30 |
| 32 | # endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | 32 | # endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) |
| 33 | 33 | ||
| 34 | #endif // I2C_SLAVE_REG_COUNT | 34 | #endif // I2C_SLAVE_REG_COUNT |
| 35 | 35 | ||
| 36 | _Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); | 36 | _Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); |
| 37 | 37 | ||
diff --git a/platforms/avr/drivers/ps2/ps2_io.c b/platforms/avr/drivers/ps2/ps2_io.c index 7c826fbf1a..b75a1ab0be 100644 --- a/platforms/avr/drivers/ps2/ps2_io.c +++ b/platforms/avr/drivers/ps2/ps2_io.c | |||
| @@ -23,7 +23,9 @@ void clock_lo(void) { | |||
| 23 | setPinOutput(PS2_CLOCK_PIN); | 23 | setPinOutput(PS2_CLOCK_PIN); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | void clock_hi(void) { setPinInputHigh(PS2_CLOCK_PIN); } | 26 | void clock_hi(void) { |
| 27 | setPinInputHigh(PS2_CLOCK_PIN); | ||
| 28 | } | ||
| 27 | 29 | ||
| 28 | bool clock_in(void) { | 30 | bool clock_in(void) { |
| 29 | setPinInputHigh(PS2_CLOCK_PIN); | 31 | setPinInputHigh(PS2_CLOCK_PIN); |
| @@ -42,7 +44,9 @@ void data_lo(void) { | |||
| 42 | setPinOutput(PS2_DATA_PIN); | 44 | setPinOutput(PS2_DATA_PIN); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | void data_hi(void) { setPinInputHigh(PS2_DATA_PIN); } | 47 | void data_hi(void) { |
| 48 | setPinInputHigh(PS2_DATA_PIN); | ||
| 49 | } | ||
| 46 | 50 | ||
| 47 | bool data_in(void) { | 51 | bool data_in(void) { |
| 48 | setPinInputHigh(PS2_DATA_PIN); | 52 | setPinInputHigh(PS2_DATA_PIN); |
diff --git a/platforms/avr/drivers/ps2/ps2_usart.c b/platforms/avr/drivers/ps2/ps2_usart.c index 151cfcd68f..39ec930d4a 100644 --- a/platforms/avr/drivers/ps2/ps2_usart.c +++ b/platforms/avr/drivers/ps2/ps2_usart.c | |||
| @@ -76,7 +76,7 @@ static inline bool pbuf_has_data(void); | |||
| 76 | static inline void pbuf_clear(void); | 76 | static inline void pbuf_clear(void); |
| 77 | 77 | ||
| 78 | void ps2_host_init(void) { | 78 | void ps2_host_init(void) { |
| 79 | idle(); // without this many USART errors occur when cable is disconnected | 79 | idle(); // without this many USART errors occur when cable is disconnected |
| 80 | PS2_USART_INIT(); | 80 | PS2_USART_INIT(); |
| 81 | PS2_USART_RX_INT_ON(); | 81 | PS2_USART_RX_INT_ON(); |
| 82 | // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) | 82 | // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) |
| @@ -91,12 +91,12 @@ uint8_t ps2_host_send(uint8_t data) { | |||
| 91 | 91 | ||
| 92 | /* terminate a transmission if we have */ | 92 | /* terminate a transmission if we have */ |
| 93 | inhibit(); | 93 | inhibit(); |
| 94 | _delay_us(100); // [4]p.13 | 94 | _delay_us(100); // [4]p.13 |
| 95 | 95 | ||
| 96 | /* 'Request to Send' and Start bit */ | 96 | /* 'Request to Send' and Start bit */ |
| 97 | data_lo(); | 97 | data_lo(); |
| 98 | clock_hi(); | 98 | clock_hi(); |
| 99 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 | 99 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 |
| 100 | 100 | ||
| 101 | /* Data bit[2-9] */ | 101 | /* Data bit[2-9] */ |
| 102 | for (uint8_t i = 0; i < 8; i++) { | 102 | for (uint8_t i = 0; i < 8; i++) { |
| @@ -165,7 +165,7 @@ uint8_t ps2_host_recv(void) { | |||
| 165 | 165 | ||
| 166 | ISR(PS2_USART_RX_VECT) { | 166 | ISR(PS2_USART_RX_VECT) { |
| 167 | // TODO: request RESEND when error occurs? | 167 | // TODO: request RESEND when error occurs? |
| 168 | uint8_t error = PS2_USART_ERROR; // USART error should be read before data | 168 | uint8_t error = PS2_USART_ERROR; // USART error should be read before data |
| 169 | uint8_t data = PS2_USART_RX_DATA; | 169 | uint8_t data = PS2_USART_RX_DATA; |
| 170 | if (!error) { | 170 | if (!error) { |
| 171 | pbuf_enqueue(data); | 171 | pbuf_enqueue(data); |
diff --git a/platforms/avr/drivers/serial.c b/platforms/avr/drivers/serial.c index 62908e5875..6a36aa5f7f 100644 --- a/platforms/avr/drivers/serial.c +++ b/platforms/avr/drivers/serial.c | |||
| @@ -156,59 +156,59 @@ | |||
| 156 | 156 | ||
| 157 | # if SELECT_SOFT_SERIAL_SPEED == 0 | 157 | # if SELECT_SOFT_SERIAL_SPEED == 0 |
| 158 | // Very High speed | 158 | // Very High speed |
| 159 | # define SERIAL_DELAY 4 // micro sec | 159 | # define SERIAL_DELAY 4 // micro sec |
| 160 | # if __GNUC__ < 6 | 160 | # if __GNUC__ < 6 |
| 161 | # define READ_WRITE_START_ADJUST 33 // cycles | 161 | # define READ_WRITE_START_ADJUST 33 // cycles |
| 162 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 162 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 163 | # else | 163 | # else |
| 164 | # define READ_WRITE_START_ADJUST 34 // cycles | 164 | # define READ_WRITE_START_ADJUST 34 // cycles |
| 165 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 165 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 166 | # endif | 166 | # endif |
| 167 | # elif SELECT_SOFT_SERIAL_SPEED == 1 | 167 | # elif SELECT_SOFT_SERIAL_SPEED == 1 |
| 168 | // High speed | 168 | // High speed |
| 169 | # define SERIAL_DELAY 6 // micro sec | 169 | # define SERIAL_DELAY 6 // micro sec |
| 170 | # if __GNUC__ < 6 | 170 | # if __GNUC__ < 6 |
| 171 | # define READ_WRITE_START_ADJUST 30 // cycles | 171 | # define READ_WRITE_START_ADJUST 30 // cycles |
| 172 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 172 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 173 | # else | 173 | # else |
| 174 | # define READ_WRITE_START_ADJUST 33 // cycles | 174 | # define READ_WRITE_START_ADJUST 33 // cycles |
| 175 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 175 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 176 | # endif | 176 | # endif |
| 177 | # elif SELECT_SOFT_SERIAL_SPEED == 2 | 177 | # elif SELECT_SOFT_SERIAL_SPEED == 2 |
| 178 | // Middle speed | 178 | // Middle speed |
| 179 | # define SERIAL_DELAY 12 // micro sec | 179 | # define SERIAL_DELAY 12 // micro sec |
| 180 | # define READ_WRITE_START_ADJUST 30 // cycles | 180 | # define READ_WRITE_START_ADJUST 30 // cycles |
| 181 | # if __GNUC__ < 6 | 181 | # if __GNUC__ < 6 |
| 182 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 182 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 183 | # else | 183 | # else |
| 184 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 184 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 185 | # endif | 185 | # endif |
| 186 | # elif SELECT_SOFT_SERIAL_SPEED == 3 | 186 | # elif SELECT_SOFT_SERIAL_SPEED == 3 |
| 187 | // Low speed | 187 | // Low speed |
| 188 | # define SERIAL_DELAY 24 // micro sec | 188 | # define SERIAL_DELAY 24 // micro sec |
| 189 | # define READ_WRITE_START_ADJUST 30 // cycles | 189 | # define READ_WRITE_START_ADJUST 30 // cycles |
| 190 | # if __GNUC__ < 6 | 190 | # if __GNUC__ < 6 |
| 191 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 191 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 192 | # else | 192 | # else |
| 193 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 193 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 194 | # endif | 194 | # endif |
| 195 | # elif SELECT_SOFT_SERIAL_SPEED == 4 | 195 | # elif SELECT_SOFT_SERIAL_SPEED == 4 |
| 196 | // Very Low speed | 196 | // Very Low speed |
| 197 | # define SERIAL_DELAY 36 // micro sec | 197 | # define SERIAL_DELAY 36 // micro sec |
| 198 | # define READ_WRITE_START_ADJUST 30 // cycles | 198 | # define READ_WRITE_START_ADJUST 30 // cycles |
| 199 | # if __GNUC__ < 6 | 199 | # if __GNUC__ < 6 |
| 200 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 200 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 201 | # else | 201 | # else |
| 202 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 202 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 203 | # endif | 203 | # endif |
| 204 | # elif SELECT_SOFT_SERIAL_SPEED == 5 | 204 | # elif SELECT_SOFT_SERIAL_SPEED == 5 |
| 205 | // Ultra Low speed | 205 | // Ultra Low speed |
| 206 | # define SERIAL_DELAY 48 // micro sec | 206 | # define SERIAL_DELAY 48 // micro sec |
| 207 | # define READ_WRITE_START_ADJUST 30 // cycles | 207 | # define READ_WRITE_START_ADJUST 30 // cycles |
| 208 | # if __GNUC__ < 6 | 208 | # if __GNUC__ < 6 |
| 209 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles | 209 | # define READ_WRITE_WIDTH_ADJUST 3 // cycles |
| 210 | # else | 210 | # else |
| 211 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles | 211 | # define READ_WRITE_WIDTH_ADJUST 7 // cycles |
| 212 | # endif | 212 | # endif |
| 213 | # else | 213 | # else |
| 214 | # error invalid SELECT_SOFT_SERIAL_SPEED value | 214 | # error invalid SELECT_SOFT_SERIAL_SPEED value |
| @@ -223,29 +223,45 @@ | |||
| 223 | # define SLAVE_INT_ACK_WIDTH 4 | 223 | # define SLAVE_INT_ACK_WIDTH 4 |
| 224 | 224 | ||
| 225 | inline static void serial_delay(void) ALWAYS_INLINE; | 225 | inline static void serial_delay(void) ALWAYS_INLINE; |
| 226 | inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); } | 226 | inline static void serial_delay(void) { |
| 227 | _delay_us(SERIAL_DELAY); | ||
| 228 | } | ||
| 227 | 229 | ||
| 228 | inline static void serial_delay_half1(void) ALWAYS_INLINE; | 230 | inline static void serial_delay_half1(void) ALWAYS_INLINE; |
| 229 | inline static void serial_delay_half1(void) { _delay_us(SERIAL_DELAY_HALF1); } | 231 | inline static void serial_delay_half1(void) { |
| 232 | _delay_us(SERIAL_DELAY_HALF1); | ||
| 233 | } | ||
| 230 | 234 | ||
| 231 | inline static void serial_delay_half2(void) ALWAYS_INLINE; | 235 | inline static void serial_delay_half2(void) ALWAYS_INLINE; |
| 232 | inline static void serial_delay_half2(void) { _delay_us(SERIAL_DELAY_HALF2); } | 236 | inline static void serial_delay_half2(void) { |
| 237 | _delay_us(SERIAL_DELAY_HALF2); | ||
| 238 | } | ||
| 233 | 239 | ||
| 234 | inline static void serial_output(void) ALWAYS_INLINE; | 240 | inline static void serial_output(void) ALWAYS_INLINE; |
| 235 | inline static void serial_output(void) { setPinOutput(SOFT_SERIAL_PIN); } | 241 | inline static void serial_output(void) { |
| 242 | setPinOutput(SOFT_SERIAL_PIN); | ||
| 243 | } | ||
| 236 | 244 | ||
| 237 | // make the serial pin an input with pull-up resistor | 245 | // make the serial pin an input with pull-up resistor |
| 238 | inline static void serial_input_with_pullup(void) ALWAYS_INLINE; | 246 | inline static void serial_input_with_pullup(void) ALWAYS_INLINE; |
| 239 | inline static void serial_input_with_pullup(void) { setPinInputHigh(SOFT_SERIAL_PIN); } | 247 | inline static void serial_input_with_pullup(void) { |
| 248 | setPinInputHigh(SOFT_SERIAL_PIN); | ||
| 249 | } | ||
| 240 | 250 | ||
| 241 | inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; | 251 | inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; |
| 242 | inline static uint8_t serial_read_pin(void) { return !!readPin(SOFT_SERIAL_PIN); } | 252 | inline static uint8_t serial_read_pin(void) { |
| 253 | return !!readPin(SOFT_SERIAL_PIN); | ||
| 254 | } | ||
| 243 | 255 | ||
| 244 | inline static void serial_low(void) ALWAYS_INLINE; | 256 | inline static void serial_low(void) ALWAYS_INLINE; |
| 245 | inline static void serial_low(void) { writePinLow(SOFT_SERIAL_PIN); } | 257 | inline static void serial_low(void) { |
| 258 | writePinLow(SOFT_SERIAL_PIN); | ||
| 259 | } | ||
| 246 | 260 | ||
| 247 | inline static void serial_high(void) ALWAYS_INLINE; | 261 | inline static void serial_high(void) ALWAYS_INLINE; |
| 248 | inline static void serial_high(void) { writePinHigh(SOFT_SERIAL_PIN); } | 262 | inline static void serial_high(void) { |
| 263 | writePinHigh(SOFT_SERIAL_PIN); | ||
| 264 | } | ||
| 249 | 265 | ||
| 250 | void soft_serial_initiator_init(void) { | 266 | void soft_serial_initiator_init(void) { |
| 251 | serial_output(); | 267 | serial_output(); |
| @@ -286,7 +302,7 @@ static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) { | |||
| 286 | 302 | ||
| 287 | _delay_sub_us(READ_WRITE_START_ADJUST); | 303 | _delay_sub_us(READ_WRITE_START_ADJUST); |
| 288 | for (i = 0, byte = 0, p = PARITY; i < bit; i++) { | 304 | for (i = 0, byte = 0, p = PARITY; i < bit; i++) { |
| 289 | serial_delay_half1(); // read the middle of pulses | 305 | serial_delay_half1(); // read the middle of pulses |
| 290 | if (serial_read_pin()) { | 306 | if (serial_read_pin()) { |
| 291 | byte = (byte << 1) | 1; | 307 | byte = (byte << 1) | 1; |
| 292 | p ^= 1; | 308 | p ^= 1; |
| @@ -298,7 +314,7 @@ static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) { | |||
| 298 | serial_delay_half2(); | 314 | serial_delay_half2(); |
| 299 | } | 315 | } |
| 300 | /* recive parity bit */ | 316 | /* recive parity bit */ |
| 301 | serial_delay_half1(); // read the middle of pulses | 317 | serial_delay_half1(); // read the middle of pulses |
| 302 | pb = serial_read_pin(); | 318 | pb = serial_read_pin(); |
| 303 | _delay_sub_us(READ_WRITE_WIDTH_ADJUST); | 319 | _delay_sub_us(READ_WRITE_WIDTH_ADJUST); |
| 304 | serial_delay_half2(); | 320 | serial_delay_half2(); |
| @@ -330,7 +346,7 @@ void serial_write_chunk(uint8_t data, uint8_t bit) { | |||
| 330 | } | 346 | } |
| 331 | serial_delay(); | 347 | serial_delay(); |
| 332 | 348 | ||
| 333 | serial_low(); // sync_send() / senc_recv() need raise edge | 349 | serial_low(); // sync_send() / senc_recv() need raise edge |
| 334 | } | 350 | } |
| 335 | 351 | ||
| 336 | static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE; | 352 | static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE; |
| @@ -356,19 +372,19 @@ static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) { | |||
| 356 | } | 372 | } |
| 357 | 373 | ||
| 358 | inline static void change_sender2reciver(void) { | 374 | inline static void change_sender2reciver(void) { |
| 359 | sync_send(); // 0 | 375 | sync_send(); // 0 |
| 360 | serial_delay_half1(); // 1 | 376 | serial_delay_half1(); // 1 |
| 361 | serial_low(); // 2 | 377 | serial_low(); // 2 |
| 362 | serial_input_with_pullup(); // 2 | 378 | serial_input_with_pullup(); // 2 |
| 363 | serial_delay_half1(); // 3 | 379 | serial_delay_half1(); // 3 |
| 364 | } | 380 | } |
| 365 | 381 | ||
| 366 | inline static void change_reciver2sender(void) { | 382 | inline static void change_reciver2sender(void) { |
| 367 | sync_recv(); // 0 | 383 | sync_recv(); // 0 |
| 368 | serial_delay(); // 1 | 384 | serial_delay(); // 1 |
| 369 | serial_low(); // 3 | 385 | serial_low(); // 3 |
| 370 | serial_output(); // 3 | 386 | serial_output(); // 3 |
| 371 | serial_delay_half1(); // 4 | 387 | serial_delay_half1(); // 4 |
| 372 | } | 388 | } |
| 373 | 389 | ||
| 374 | static inline uint8_t nibble_bits_count(uint8_t bits) { | 390 | static inline uint8_t nibble_bits_count(uint8_t bits) { |
| @@ -391,11 +407,11 @@ ISR(SERIAL_PIN_INTERRUPT) { | |||
| 391 | } | 407 | } |
| 392 | serial_delay_half1(); | 408 | serial_delay_half1(); |
| 393 | 409 | ||
| 394 | serial_high(); // response step1 low->high | 410 | serial_high(); // response step1 low->high |
| 395 | serial_output(); | 411 | serial_output(); |
| 396 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT * SLAVE_INT_ACK_WIDTH); | 412 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT * SLAVE_INT_ACK_WIDTH); |
| 397 | split_transaction_desc_t *trans = &split_transaction_table[tid]; | 413 | split_transaction_desc_t *trans = &split_transaction_table[tid]; |
| 398 | serial_low(); // response step2 ack high->low | 414 | serial_low(); // response step2 ack high->low |
| 399 | 415 | ||
| 400 | // If the transaction has a callback, we can execute it now | 416 | // If the transaction has a callback, we can execute it now |
| 401 | if (trans->slave_callback) { | 417 | if (trans->slave_callback) { |
| @@ -412,7 +428,7 @@ ISR(SERIAL_PIN_INTERRUPT) { | |||
| 412 | serial_recive_packet((uint8_t *)split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size); | 428 | serial_recive_packet((uint8_t *)split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size); |
| 413 | } | 429 | } |
| 414 | 430 | ||
| 415 | sync_recv(); // weit initiator output to high | 431 | sync_recv(); // weit initiator output to high |
| 416 | } | 432 | } |
| 417 | 433 | ||
| 418 | ///////// | 434 | ///////// |
diff --git a/platforms/avr/drivers/spi_master.c b/platforms/avr/drivers/spi_master.c index 4e8fd3bcdf..ae9df03c02 100644 --- a/platforms/avr/drivers/spi_master.c +++ b/platforms/avr/drivers/spi_master.c | |||
| @@ -125,7 +125,7 @@ spi_status_t spi_write(uint8_t data) { | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | spi_status_t spi_read() { | 127 | spi_status_t spi_read() { |
| 128 | SPDR = 0x00; // Dummy | 128 | SPDR = 0x00; // Dummy |
| 129 | 129 | ||
| 130 | uint16_t timeout_timer = timer_read(); | 130 | uint16_t timeout_timer = timer_read(); |
| 131 | while (!(SPSR & _BV(SPIF))) { | 131 | while (!(SPSR & _BV(SPIF))) { |
diff --git a/platforms/avr/drivers/ssd1306.c b/platforms/avr/drivers/ssd1306.c index 1a09a2bcb7..7afbc09f00 100644 --- a/platforms/avr/drivers/ssd1306.c +++ b/platforms/avr/drivers/ssd1306.c | |||
| @@ -161,7 +161,7 @@ bool iota_gfx_init(void) { | |||
| 161 | send_cmd1(DeActivateScroll); | 161 | send_cmd1(DeActivateScroll); |
| 162 | send_cmd1(DisplayOn); | 162 | send_cmd1(DisplayOn); |
| 163 | 163 | ||
| 164 | send_cmd2(SetContrast, 0); // Dim | 164 | send_cmd2(SetContrast, 0); // Dim |
| 165 | 165 | ||
| 166 | clear_display(); | 166 | clear_display(); |
| 167 | 167 | ||
| @@ -226,7 +226,9 @@ void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { | |||
| 226 | matrix_write_char_inner(matrix, c); | 226 | matrix_write_char_inner(matrix, c); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | void iota_gfx_write_char(uint8_t c) { matrix_write_char(&display, c); } | 229 | void iota_gfx_write_char(uint8_t c) { |
| 230 | matrix_write_char(&display, c); | ||
| 231 | } | ||
| 230 | 232 | ||
| 231 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { | 233 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { |
| 232 | const char *end = data + strlen(data); | 234 | const char *end = data + strlen(data); |
| @@ -236,7 +238,9 @@ void matrix_write(struct CharacterMatrix *matrix, const char *data) { | |||
| 236 | } | 238 | } |
| 237 | } | 239 | } |
| 238 | 240 | ||
| 239 | void iota_gfx_write(const char *data) { matrix_write(&display, data); } | 241 | void iota_gfx_write(const char *data) { |
| 242 | matrix_write(&display, data); | ||
| 243 | } | ||
| 240 | 244 | ||
| 241 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | 245 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { |
| 242 | while (true) { | 246 | while (true) { |
| @@ -249,7 +253,9 @@ void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | |||
| 249 | } | 253 | } |
| 250 | } | 254 | } |
| 251 | 255 | ||
| 252 | void iota_gfx_write_P(const char *data) { matrix_write_P(&display, data); } | 256 | void iota_gfx_write_P(const char *data) { |
| 257 | matrix_write_P(&display, data); | ||
| 258 | } | ||
| 253 | 259 | ||
| 254 | void matrix_clear(struct CharacterMatrix *matrix) { | 260 | void matrix_clear(struct CharacterMatrix *matrix) { |
| 255 | memset(matrix->display, ' ', sizeof(matrix->display)); | 261 | memset(matrix->display, ' ', sizeof(matrix->display)); |
| @@ -257,7 +263,9 @@ void matrix_clear(struct CharacterMatrix *matrix) { | |||
| 257 | matrix->dirty = true; | 263 | matrix->dirty = true; |
| 258 | } | 264 | } |
| 259 | 265 | ||
| 260 | void iota_gfx_clear_screen(void) { matrix_clear(&display); } | 266 | void iota_gfx_clear_screen(void) { |
| 267 | matrix_clear(&display); | ||
| 268 | } | ||
| 261 | 269 | ||
| 262 | void matrix_render(struct CharacterMatrix *matrix) { | 270 | void matrix_render(struct CharacterMatrix *matrix) { |
| 263 | last_flush = timer_read(); | 271 | last_flush = timer_read(); |
| @@ -301,7 +309,9 @@ done: | |||
| 301 | # endif | 309 | # endif |
| 302 | } | 310 | } |
| 303 | 311 | ||
| 304 | void iota_gfx_flush(void) { matrix_render(&display); } | 312 | void iota_gfx_flush(void) { |
| 313 | matrix_render(&display); | ||
| 314 | } | ||
| 305 | 315 | ||
| 306 | __attribute__((weak)) void iota_gfx_task_user(void) {} | 316 | __attribute__((weak)) void iota_gfx_task_user(void) {} |
| 307 | 317 | ||
diff --git a/platforms/avr/drivers/uart.c b/platforms/avr/drivers/uart.c index 01cf6b1fb8..fd5caf9a78 100644 --- a/platforms/avr/drivers/uart.c +++ b/platforms/avr/drivers/uart.c | |||
| @@ -108,7 +108,7 @@ void uart_write(uint8_t data) { | |||
| 108 | // return immediately to avoid deadlock when interrupt is disabled(called from ISR) | 108 | // return immediately to avoid deadlock when interrupt is disabled(called from ISR) |
| 109 | if (tx_buffer_tail == i && (SREG & (1 << SREG_I)) == 0) return; | 109 | if (tx_buffer_tail == i && (SREG & (1 << SREG_I)) == 0) return; |
| 110 | while (tx_buffer_tail == i) | 110 | while (tx_buffer_tail == i) |
| 111 | ; // wait until space in buffer | 111 | ; // wait until space in buffer |
| 112 | // cli(); | 112 | // cli(); |
| 113 | tx_buffer[i] = data; | 113 | tx_buffer[i] = data; |
| 114 | tx_buffer_head = i; | 114 | tx_buffer_head = i; |
| @@ -121,7 +121,7 @@ uint8_t uart_read(void) { | |||
| 121 | uint8_t data, i; | 121 | uint8_t data, i; |
| 122 | 122 | ||
| 123 | while (rx_buffer_head == rx_buffer_tail) | 123 | while (rx_buffer_head == rx_buffer_tail) |
| 124 | ; // wait for character | 124 | ; // wait for character |
| 125 | i = rx_buffer_tail + 1; | 125 | i = rx_buffer_tail + 1; |
| 126 | if (i >= RX_BUFFER_SIZE) i = 0; | 126 | if (i >= RX_BUFFER_SIZE) i = 0; |
| 127 | data = rx_buffer[i]; | 127 | data = rx_buffer[i]; |
diff --git a/platforms/avr/drivers/ws2812.c b/platforms/avr/drivers/ws2812.c index 9150b3c520..c461ab3ba7 100644 --- a/platforms/avr/drivers/ws2812.c +++ b/platforms/avr/drivers/ws2812.c | |||
| @@ -110,7 +110,7 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t | |||
| 110 | 110 | ||
| 111 | asm volatile(" ldi %0,8 \n\t" | 111 | asm volatile(" ldi %0,8 \n\t" |
| 112 | "loop%=: \n\t" | 112 | "loop%=: \n\t" |
| 113 | " out %2,%3 \n\t" // '1' [01] '0' [01] - re | 113 | " out %2,%3 \n\t" // '1' [01] '0' [01] - re |
| 114 | #if (w1_nops & 1) | 114 | #if (w1_nops & 1) |
| 115 | w_nop1 | 115 | w_nop1 |
| 116 | #endif | 116 | #endif |
| @@ -126,9 +126,9 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t | |||
| 126 | #if (w1_nops & 16) | 126 | #if (w1_nops & 16) |
| 127 | w_nop16 | 127 | w_nop16 |
| 128 | #endif | 128 | #endif |
| 129 | " sbrs %1,7 \n\t" // '1' [03] '0' [02] | 129 | " sbrs %1,7 \n\t" // '1' [03] '0' [02] |
| 130 | " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low | 130 | " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low |
| 131 | " lsl %1 \n\t" // '1' [04] '0' [04] | 131 | " lsl %1 \n\t" // '1' [04] '0' [04] |
| 132 | #if (w2_nops & 1) | 132 | #if (w2_nops & 1) |
| 133 | w_nop1 | 133 | w_nop1 |
| 134 | #endif | 134 | #endif |
| @@ -144,7 +144,7 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t | |||
| 144 | #if (w2_nops & 16) | 144 | #if (w2_nops & 16) |
| 145 | w_nop16 | 145 | w_nop16 |
| 146 | #endif | 146 | #endif |
| 147 | " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high | 147 | " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high |
| 148 | #if (w3_nops & 1) | 148 | #if (w3_nops & 1) |
| 149 | w_nop1 | 149 | w_nop1 |
| 150 | #endif | 150 | #endif |
| @@ -161,8 +161,8 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t | |||
| 161 | w_nop16 | 161 | w_nop16 |
| 162 | #endif | 162 | #endif |
| 163 | 163 | ||
| 164 | " dec %0 \n\t" // '1' [+2] '0' [+2] | 164 | " dec %0 \n\t" // '1' [+2] '0' [+2] |
| 165 | " brne loop%=\n\t" // '1' [+3] '0' [+4] | 165 | " brne loop%=\n\t" // '1' [+3] '0' [+4] |
| 166 | : "=&d"(ctr) | 166 | : "=&d"(ctr) |
| 167 | : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGB_DI_PIN))), "r"(maskhi), "r"(masklo)); | 167 | : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGB_DI_PIN))), "r"(maskhi), "r"(masklo)); |
| 168 | } | 168 | } |
diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c index 1c332e24b6..709f382254 100644 --- a/platforms/avr/drivers/ws2812_i2c.c +++ b/platforms/avr/drivers/ws2812_i2c.c | |||
| @@ -13,7 +13,9 @@ | |||
| 13 | # define WS2812_TIMEOUT 100 | 13 | # define WS2812_TIMEOUT 100 |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | void ws2812_init(void) { i2c_init(); } | 16 | void ws2812_init(void) { |
| 17 | i2c_init(); | ||
| 18 | } | ||
| 17 | 19 | ||
| 18 | // Setleds for standard RGB | 20 | // Setleds for standard RGB |
| 19 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { | 21 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { |
diff --git a/platforms/avr/pin_defs.h b/platforms/avr/pin_defs.h index 23d948041d..3889704a87 100644 --- a/platforms/avr/pin_defs.h +++ b/platforms/avr/pin_defs.h | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include <avr/io.h> | 18 | #include <avr/io.h> |
| 19 | 19 | ||
| 20 | #define PORT_SHIFTER 4 // this may be 4 for all AVR chips | 20 | #define PORT_SHIFTER 4 // this may be 4 for all AVR chips |
| 21 | 21 | ||
| 22 | // If you want to add more to this list, reference the PINx definitions in these header | 22 | // If you want to add more to this list, reference the PINx definitions in these header |
| 23 | // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr | 23 | // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr |
diff --git a/platforms/avr/printf.c b/platforms/avr/printf.c index 9ad7a38693..062f70fa0b 100644 --- a/platforms/avr/printf.c +++ b/platforms/avr/printf.c | |||
| @@ -17,4 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | #include "xprintf.h" | 17 | #include "xprintf.h" |
| 18 | #include "sendchar.h" | 18 | #include "sendchar.h" |
| 19 | 19 | ||
| 20 | void print_set_sendchar(sendchar_func_t func) { xdev_out(func); } | 20 | void print_set_sendchar(sendchar_func_t func) { |
| 21 | xdev_out(func); | ||
| 22 | } | ||
diff --git a/platforms/avr/sleep_led.c b/platforms/avr/sleep_led.c index 9a3b52abe5..b05431633b 100644 --- a/platforms/avr/sleep_led.c +++ b/platforms/avr/sleep_led.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #if SLEEP_LED_TIMER == 1 | 12 | #if SLEEP_LED_TIMER == 1 |
| 13 | # define TCCRxB TCCR1B | 13 | # define TCCRxB TCCR1B |
| 14 | # define TIMERx_COMPA_vect TIMER1_COMPA_vect | 14 | # define TIMERx_COMPA_vect TIMER1_COMPA_vect |
| 15 | # if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register | 15 | # if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register |
| 16 | # define TIMSKx TIMSK | 16 | # define TIMSKx TIMSK |
| 17 | # else | 17 | # else |
| 18 | # define TIMSKx TIMSK1 | 18 | # define TIMSKx TIMSK1 |
diff --git a/platforms/avr/suspend.c b/platforms/avr/suspend.c index b615979439..1a7cd3b4ab 100644 --- a/platforms/avr/suspend.c +++ b/platforms/avr/suspend.c | |||
| @@ -81,7 +81,7 @@ ISR(WDT_vect) { | |||
| 81 | // compensate timer for sleep | 81 | // compensate timer for sleep |
| 82 | switch (wdt_timeout) { | 82 | switch (wdt_timeout) { |
| 83 | case WDTO_15MS: | 83 | case WDTO_15MS: |
| 84 | timer_count += 15 + 2; // WDTO_15MS + 2(from observation) | 84 | timer_count += 15 + 2; // WDTO_15MS + 2(from observation) |
| 85 | break; | 85 | break; |
| 86 | default:; | 86 | default:; |
| 87 | } | 87 | } |
diff --git a/platforms/avr/timer.c b/platforms/avr/timer.c index c2e6c6e081..9fb671ae8d 100644 --- a/platforms/avr/timer.c +++ b/platforms/avr/timer.c | |||
| @@ -73,7 +73,9 @@ void timer_init(void) { | |||
| 73 | * FIXME: needs doc | 73 | * FIXME: needs doc |
| 74 | */ | 74 | */ |
| 75 | inline void timer_clear(void) { | 75 | inline void timer_clear(void) { |
| 76 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { timer_count = 0; } | 76 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 77 | timer_count = 0; | ||
| 78 | } | ||
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | /** \brief timer read | 81 | /** \brief timer read |
| @@ -83,7 +85,9 @@ inline void timer_clear(void) { | |||
| 83 | inline uint16_t timer_read(void) { | 85 | inline uint16_t timer_read(void) { |
| 84 | uint32_t t; | 86 | uint32_t t; |
| 85 | 87 | ||
| 86 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { t = timer_count; } | 88 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 89 | t = timer_count; | ||
| 90 | } | ||
| 87 | 91 | ||
| 88 | return (t & 0xFFFF); | 92 | return (t & 0xFFFF); |
| 89 | } | 93 | } |
| @@ -95,7 +99,9 @@ inline uint16_t timer_read(void) { | |||
| 95 | inline uint32_t timer_read32(void) { | 99 | inline uint32_t timer_read32(void) { |
| 96 | uint32_t t; | 100 | uint32_t t; |
| 97 | 101 | ||
| 98 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { t = timer_count; } | 102 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 103 | t = timer_count; | ||
| 104 | } | ||
| 99 | 105 | ||
| 100 | return t; | 106 | return t; |
| 101 | } | 107 | } |
| @@ -107,7 +113,9 @@ inline uint32_t timer_read32(void) { | |||
| 107 | inline uint16_t timer_elapsed(uint16_t last) { | 113 | inline uint16_t timer_elapsed(uint16_t last) { |
| 108 | uint32_t t; | 114 | uint32_t t; |
| 109 | 115 | ||
| 110 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { t = timer_count; } | 116 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 117 | t = timer_count; | ||
| 118 | } | ||
| 111 | 119 | ||
| 112 | return TIMER_DIFF_16((t & 0xFFFF), last); | 120 | return TIMER_DIFF_16((t & 0xFFFF), last); |
| 113 | } | 121 | } |
| @@ -119,7 +127,9 @@ inline uint16_t timer_elapsed(uint16_t last) { | |||
| 119 | inline uint32_t timer_elapsed32(uint32_t last) { | 127 | inline uint32_t timer_elapsed32(uint32_t last) { |
| 120 | uint32_t t; | 128 | uint32_t t; |
| 121 | 129 | ||
| 122 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { t = timer_count; } | 130 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 131 | t = timer_count; | ||
| 132 | } | ||
| 123 | 133 | ||
| 124 | return TIMER_DIFF_32(t, last); | 134 | return TIMER_DIFF_32(t, last); |
| 125 | } | 135 | } |
| @@ -130,4 +140,6 @@ inline uint32_t timer_elapsed32(uint32_t last) { | |||
| 130 | #else | 140 | #else |
| 131 | # define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect | 141 | # define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect |
| 132 | #endif | 142 | #endif |
| 133 | ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK) { timer_count++; } | 143 | ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK) { |
| 144 | timer_count++; | ||
| 145 | } | ||
diff --git a/platforms/chibios/bootloaders/stm32_dfu.c b/platforms/chibios/bootloaders/stm32_dfu.c index 0a113570f7..0e74111367 100644 --- a/platforms/chibios/bootloaders/stm32_dfu.c +++ b/platforms/chibios/bootloaders/stm32_dfu.c | |||
| @@ -72,7 +72,7 @@ void enter_bootloader_mode_if_requested(void) {} | |||
| 72 | # define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) | 72 | # define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) |
| 73 | 73 | ||
| 74 | __attribute__((weak)) void bootloader_jump(void) { | 74 | __attribute__((weak)) void bootloader_jump(void) { |
| 75 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader | 75 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader |
| 76 | NVIC_SystemReset(); | 76 | NVIC_SystemReset(); |
| 77 | } | 77 | } |
| 78 | 78 | ||
diff --git a/platforms/chibios/bootloaders/stm32duino.c b/platforms/chibios/bootloaders/stm32duino.c index dd1d551fa9..53d3ba0adb 100644 --- a/platforms/chibios/bootloaders/stm32duino.c +++ b/platforms/chibios/bootloaders/stm32duino.c | |||
| @@ -18,4 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | #include <ch.h> | 19 | #include <ch.h> |
| 20 | 20 | ||
| 21 | __attribute__((weak)) void bootloader_jump(void) { NVIC_SystemReset(); } | 21 | __attribute__((weak)) void bootloader_jump(void) { |
| 22 | NVIC_SystemReset(); | ||
| 23 | } | ||
diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index 4e35736606..67d7541ba2 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #pragma once | 16 | #pragma once |
| 17 | 17 | ||
| 18 | #ifndef USB_VBUS_PIN | 18 | #ifndef USB_VBUS_PIN |
| 19 | # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used | 19 | # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | // STM32 compatibility | 22 | // STM32 compatibility |
| @@ -76,7 +76,7 @@ | |||
| 76 | 76 | ||
| 77 | # if defined(K20x) || defined(KL2x) | 77 | # if defined(K20x) || defined(KL2x) |
| 78 | # define USE_I2CV1 | 78 | # define USE_I2CV1 |
| 79 | # define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed | 79 | # define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed |
| 80 | # define USE_GPIOV1 | 80 | # define USE_GPIOV1 |
| 81 | # endif | 81 | # endif |
| 82 | #endif | 82 | #endif |
diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index eb437665f1..48a59fd290 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c | |||
| @@ -101,9 +101,9 @@ | |||
| 101 | 101 | ||
| 102 | // Options are 12, 10, 8, and 6 bit. | 102 | // Options are 12, 10, 8, and 6 bit. |
| 103 | #ifndef ADC_RESOLUTION | 103 | #ifndef ADC_RESOLUTION |
| 104 | # ifdef ADC_CFGR_RES_10BITS // ADCv3, ADCv4 | 104 | # ifdef ADC_CFGR_RES_10BITS // ADCv3, ADCv4 |
| 105 | # define ADC_RESOLUTION ADC_CFGR_RES_10BITS | 105 | # define ADC_RESOLUTION ADC_CFGR_RES_10BITS |
| 106 | # else // ADCv1, ADCv5, or the bodge for ADCv2 above | 106 | # else // ADCv1, ADCv5, or the bodge for ADCv2 above |
| 107 | # define ADC_RESOLUTION ADC_CFGR1_RES_10BIT | 107 | # define ADC_RESOLUTION ADC_CFGR1_RES_10BIT |
| 108 | # endif | 108 | # endif |
| 109 | #endif | 109 | #endif |
| @@ -123,7 +123,7 @@ static ADCConversionGroup adcConversionGroup = { | |||
| 123 | .smpr = ADC_SAMPLING_RATE, | 123 | .smpr = ADC_SAMPLING_RATE, |
| 124 | #elif defined(USE_ADCV2) | 124 | #elif defined(USE_ADCV2) |
| 125 | # if !defined(STM32F1XX) && !defined(GD32VF103) | 125 | # if !defined(STM32F1XX) && !defined(GD32VF103) |
| 126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... | 126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... |
| 127 | # endif | 127 | # endif |
| 128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), | 128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), |
| 129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), | 129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), |
diff --git a/platforms/chibios/drivers/analog.h b/platforms/chibios/drivers/analog.h index e61c394265..8a821719e3 100644 --- a/platforms/chibios/drivers/analog.h +++ b/platforms/chibios/drivers/analog.h | |||
| @@ -28,7 +28,9 @@ typedef struct { | |||
| 28 | uint8_t adc; | 28 | uint8_t adc; |
| 29 | } adc_mux; | 29 | } adc_mux; |
| 30 | #define TO_MUX(i, a) \ | 30 | #define TO_MUX(i, a) \ |
| 31 | (adc_mux) { i, a } | 31 | (adc_mux) { \ |
| 32 | i, a \ | ||
| 33 | } | ||
| 32 | 34 | ||
| 33 | int16_t analogReadPin(pin_t pin); | 35 | int16_t analogReadPin(pin_t pin); |
| 34 | int16_t analogReadPinAdc(pin_t pin, uint8_t adc); | 36 | int16_t analogReadPinAdc(pin_t pin, uint8_t adc); |
diff --git a/platforms/chibios/drivers/audio_dac_additive.c b/platforms/chibios/drivers/audio_dac_additive.c index db304adb87..db07c4b393 100644 --- a/platforms/chibios/drivers/audio_dac_additive.c +++ b/platforms/chibios/drivers/audio_dac_additive.c | |||
| @@ -52,19 +52,19 @@ static const dacsample_t dac_buffer_sine[AUDIO_DAC_BUFFER_SIZE] = { | |||
| 52 | // 256 values, max 4095 | 52 | // 256 values, max 4095 |
| 53 | 0x0, 0x1, 0x2, 0x6, 0xa, 0xf, 0x16, 0x1e, 0x27, 0x32, 0x3d, 0x4a, 0x58, 0x67, 0x78, 0x89, 0x9c, 0xb0, 0xc5, 0xdb, 0xf2, 0x10a, 0x123, 0x13e, 0x159, 0x175, 0x193, 0x1b1, 0x1d1, 0x1f1, 0x212, 0x235, 0x258, 0x27c, 0x2a0, 0x2c6, 0x2ed, 0x314, 0x33c, 0x365, 0x38e, 0x3b8, 0x3e3, 0x40e, 0x43a, 0x467, 0x494, 0x4c2, 0x4f0, 0x51f, 0x54e, 0x57d, 0x5ad, 0x5dd, 0x60e, 0x63f, 0x670, 0x6a1, 0x6d3, 0x705, 0x737, 0x769, 0x79b, 0x7cd, 0x800, 0x832, 0x864, 0x896, 0x8c8, 0x8fa, 0x92c, 0x95e, 0x98f, 0x9c0, 0x9f1, 0xa22, 0xa52, 0xa82, 0xab1, 0xae0, 0xb0f, 0xb3d, 0xb6b, 0xb98, 0xbc5, 0xbf1, 0xc1c, 0xc47, 0xc71, 0xc9a, 0xcc3, 0xceb, 0xd12, 0xd39, 0xd5f, 0xd83, 0xda7, 0xdca, 0xded, 0xe0e, 0xe2e, 0xe4e, 0xe6c, 0xe8a, 0xea6, 0xec1, 0xedc, 0xef5, 0xf0d, 0xf24, 0xf3a, 0xf4f, 0xf63, 0xf76, 0xf87, 0xf98, 0xfa7, 0xfb5, 0xfc2, 0xfcd, 0xfd8, 0xfe1, 0xfe9, 0xff0, 0xff5, 0xff9, 0xffd, 0xffe, | 53 | 0x0, 0x1, 0x2, 0x6, 0xa, 0xf, 0x16, 0x1e, 0x27, 0x32, 0x3d, 0x4a, 0x58, 0x67, 0x78, 0x89, 0x9c, 0xb0, 0xc5, 0xdb, 0xf2, 0x10a, 0x123, 0x13e, 0x159, 0x175, 0x193, 0x1b1, 0x1d1, 0x1f1, 0x212, 0x235, 0x258, 0x27c, 0x2a0, 0x2c6, 0x2ed, 0x314, 0x33c, 0x365, 0x38e, 0x3b8, 0x3e3, 0x40e, 0x43a, 0x467, 0x494, 0x4c2, 0x4f0, 0x51f, 0x54e, 0x57d, 0x5ad, 0x5dd, 0x60e, 0x63f, 0x670, 0x6a1, 0x6d3, 0x705, 0x737, 0x769, 0x79b, 0x7cd, 0x800, 0x832, 0x864, 0x896, 0x8c8, 0x8fa, 0x92c, 0x95e, 0x98f, 0x9c0, 0x9f1, 0xa22, 0xa52, 0xa82, 0xab1, 0xae0, 0xb0f, 0xb3d, 0xb6b, 0xb98, 0xbc5, 0xbf1, 0xc1c, 0xc47, 0xc71, 0xc9a, 0xcc3, 0xceb, 0xd12, 0xd39, 0xd5f, 0xd83, 0xda7, 0xdca, 0xded, 0xe0e, 0xe2e, 0xe4e, 0xe6c, 0xe8a, 0xea6, 0xec1, 0xedc, 0xef5, 0xf0d, 0xf24, 0xf3a, 0xf4f, 0xf63, 0xf76, 0xf87, 0xf98, 0xfa7, 0xfb5, 0xfc2, 0xfcd, 0xfd8, 0xfe1, 0xfe9, 0xff0, 0xff5, 0xff9, 0xffd, 0xffe, |
| 54 | 0xfff, 0xffe, 0xffd, 0xff9, 0xff5, 0xff0, 0xfe9, 0xfe1, 0xfd8, 0xfcd, 0xfc2, 0xfb5, 0xfa7, 0xf98, 0xf87, 0xf76, 0xf63, 0xf4f, 0xf3a, 0xf24, 0xf0d, 0xef5, 0xedc, 0xec1, 0xea6, 0xe8a, 0xe6c, 0xe4e, 0xe2e, 0xe0e, 0xded, 0xdca, 0xda7, 0xd83, 0xd5f, 0xd39, 0xd12, 0xceb, 0xcc3, 0xc9a, 0xc71, 0xc47, 0xc1c, 0xbf1, 0xbc5, 0xb98, 0xb6b, 0xb3d, 0xb0f, 0xae0, 0xab1, 0xa82, 0xa52, 0xa22, 0x9f1, 0x9c0, 0x98f, 0x95e, 0x92c, 0x8fa, 0x8c8, 0x896, 0x864, 0x832, 0x800, 0x7cd, 0x79b, 0x769, 0x737, 0x705, 0x6d3, 0x6a1, 0x670, 0x63f, 0x60e, 0x5dd, 0x5ad, 0x57d, 0x54e, 0x51f, 0x4f0, 0x4c2, 0x494, 0x467, 0x43a, 0x40e, 0x3e3, 0x3b8, 0x38e, 0x365, 0x33c, 0x314, 0x2ed, 0x2c6, 0x2a0, 0x27c, 0x258, 0x235, 0x212, 0x1f1, 0x1d1, 0x1b1, 0x193, 0x175, 0x159, 0x13e, 0x123, 0x10a, 0xf2, 0xdb, 0xc5, 0xb0, 0x9c, 0x89, 0x78, 0x67, 0x58, 0x4a, 0x3d, 0x32, 0x27, 0x1e, 0x16, 0xf, 0xa, 0x6, 0x2, 0x1}; | 54 | 0xfff, 0xffe, 0xffd, 0xff9, 0xff5, 0xff0, 0xfe9, 0xfe1, 0xfd8, 0xfcd, 0xfc2, 0xfb5, 0xfa7, 0xf98, 0xf87, 0xf76, 0xf63, 0xf4f, 0xf3a, 0xf24, 0xf0d, 0xef5, 0xedc, 0xec1, 0xea6, 0xe8a, 0xe6c, 0xe4e, 0xe2e, 0xe0e, 0xded, 0xdca, 0xda7, 0xd83, 0xd5f, 0xd39, 0xd12, 0xceb, 0xcc3, 0xc9a, 0xc71, 0xc47, 0xc1c, 0xbf1, 0xbc5, 0xb98, 0xb6b, 0xb3d, 0xb0f, 0xae0, 0xab1, 0xa82, 0xa52, 0xa22, 0x9f1, 0x9c0, 0x98f, 0x95e, 0x92c, 0x8fa, 0x8c8, 0x896, 0x864, 0x832, 0x800, 0x7cd, 0x79b, 0x769, 0x737, 0x705, 0x6d3, 0x6a1, 0x670, 0x63f, 0x60e, 0x5dd, 0x5ad, 0x57d, 0x54e, 0x51f, 0x4f0, 0x4c2, 0x494, 0x467, 0x43a, 0x40e, 0x3e3, 0x3b8, 0x38e, 0x365, 0x33c, 0x314, 0x2ed, 0x2c6, 0x2a0, 0x27c, 0x258, 0x235, 0x212, 0x1f1, 0x1d1, 0x1b1, 0x193, 0x175, 0x159, 0x13e, 0x123, 0x10a, 0xf2, 0xdb, 0xc5, 0xb0, 0x9c, 0x89, 0x78, 0x67, 0x58, 0x4a, 0x3d, 0x32, 0x27, 0x1e, 0x16, 0xf, 0xa, 0x6, 0x2, 0x1}; |
| 55 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_SINE | 55 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_SINE |
| 56 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE | 56 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE |
| 57 | static const dacsample_t dac_buffer_triangle[AUDIO_DAC_BUFFER_SIZE] = { | 57 | static const dacsample_t dac_buffer_triangle[AUDIO_DAC_BUFFER_SIZE] = { |
| 58 | // 256 values, max 4095 | 58 | // 256 values, max 4095 |
| 59 | 0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0, 0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0x3c0, 0x3e0, 0x400, 0x420, 0x440, 0x460, 0x480, 0x4a0, 0x4c0, 0x4e0, 0x500, 0x520, 0x540, 0x560, 0x580, 0x5a0, 0x5c0, 0x5e0, 0x600, 0x620, 0x640, 0x660, 0x680, 0x6a0, 0x6c0, 0x6e0, 0x700, 0x720, 0x740, 0x760, 0x780, 0x7a0, 0x7c0, 0x7e0, 0x800, 0x81f, 0x83f, 0x85f, 0x87f, 0x89f, 0x8bf, 0x8df, 0x8ff, 0x91f, 0x93f, 0x95f, 0x97f, 0x99f, 0x9bf, 0x9df, 0x9ff, 0xa1f, 0xa3f, 0xa5f, 0xa7f, 0xa9f, 0xabf, 0xadf, 0xaff, 0xb1f, 0xb3f, 0xb5f, 0xb7f, 0xb9f, 0xbbf, 0xbdf, 0xbff, 0xc1f, 0xc3f, 0xc5f, 0xc7f, 0xc9f, 0xcbf, 0xcdf, 0xcff, 0xd1f, 0xd3f, 0xd5f, 0xd7f, 0xd9f, 0xdbf, 0xddf, 0xdff, 0xe1f, 0xe3f, 0xe5f, 0xe7f, 0xe9f, 0xebf, 0xedf, 0xeff, 0xf1f, 0xf3f, 0xf5f, 0xf7f, 0xf9f, 0xfbf, 0xfdf, | 59 | 0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0, 0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0x3c0, 0x3e0, 0x400, 0x420, 0x440, 0x460, 0x480, 0x4a0, 0x4c0, 0x4e0, 0x500, 0x520, 0x540, 0x560, 0x580, 0x5a0, 0x5c0, 0x5e0, 0x600, 0x620, 0x640, 0x660, 0x680, 0x6a0, 0x6c0, 0x6e0, 0x700, 0x720, 0x740, 0x760, 0x780, 0x7a0, 0x7c0, 0x7e0, 0x800, 0x81f, 0x83f, 0x85f, 0x87f, 0x89f, 0x8bf, 0x8df, 0x8ff, 0x91f, 0x93f, 0x95f, 0x97f, 0x99f, 0x9bf, 0x9df, 0x9ff, 0xa1f, 0xa3f, 0xa5f, 0xa7f, 0xa9f, 0xabf, 0xadf, 0xaff, 0xb1f, 0xb3f, 0xb5f, 0xb7f, 0xb9f, 0xbbf, 0xbdf, 0xbff, 0xc1f, 0xc3f, 0xc5f, 0xc7f, 0xc9f, 0xcbf, 0xcdf, 0xcff, 0xd1f, 0xd3f, 0xd5f, 0xd7f, 0xd9f, 0xdbf, 0xddf, 0xdff, 0xe1f, 0xe3f, 0xe5f, 0xe7f, 0xe9f, 0xebf, 0xedf, 0xeff, 0xf1f, 0xf3f, 0xf5f, 0xf7f, 0xf9f, 0xfbf, 0xfdf, |
| 60 | 0xfff, 0xfdf, 0xfbf, 0xf9f, 0xf7f, 0xf5f, 0xf3f, 0xf1f, 0xeff, 0xedf, 0xebf, 0xe9f, 0xe7f, 0xe5f, 0xe3f, 0xe1f, 0xdff, 0xddf, 0xdbf, 0xd9f, 0xd7f, 0xd5f, 0xd3f, 0xd1f, 0xcff, 0xcdf, 0xcbf, 0xc9f, 0xc7f, 0xc5f, 0xc3f, 0xc1f, 0xbff, 0xbdf, 0xbbf, 0xb9f, 0xb7f, 0xb5f, 0xb3f, 0xb1f, 0xaff, 0xadf, 0xabf, 0xa9f, 0xa7f, 0xa5f, 0xa3f, 0xa1f, 0x9ff, 0x9df, 0x9bf, 0x99f, 0x97f, 0x95f, 0x93f, 0x91f, 0x8ff, 0x8df, 0x8bf, 0x89f, 0x87f, 0x85f, 0x83f, 0x81f, 0x800, 0x7e0, 0x7c0, 0x7a0, 0x780, 0x760, 0x740, 0x720, 0x700, 0x6e0, 0x6c0, 0x6a0, 0x680, 0x660, 0x640, 0x620, 0x600, 0x5e0, 0x5c0, 0x5a0, 0x580, 0x560, 0x540, 0x520, 0x500, 0x4e0, 0x4c0, 0x4a0, 0x480, 0x460, 0x440, 0x420, 0x400, 0x3e0, 0x3c0, 0x3a0, 0x380, 0x360, 0x340, 0x320, 0x300, 0x2e0, 0x2c0, 0x2a0, 0x280, 0x260, 0x240, 0x220, 0x200, 0x1e0, 0x1c0, 0x1a0, 0x180, 0x160, 0x140, 0x120, 0x100, 0xe0, 0xc0, 0xa0, 0x80, 0x60, 0x40, 0x20}; | 60 | 0xfff, 0xfdf, 0xfbf, 0xf9f, 0xf7f, 0xf5f, 0xf3f, 0xf1f, 0xeff, 0xedf, 0xebf, 0xe9f, 0xe7f, 0xe5f, 0xe3f, 0xe1f, 0xdff, 0xddf, 0xdbf, 0xd9f, 0xd7f, 0xd5f, 0xd3f, 0xd1f, 0xcff, 0xcdf, 0xcbf, 0xc9f, 0xc7f, 0xc5f, 0xc3f, 0xc1f, 0xbff, 0xbdf, 0xbbf, 0xb9f, 0xb7f, 0xb5f, 0xb3f, 0xb1f, 0xaff, 0xadf, 0xabf, 0xa9f, 0xa7f, 0xa5f, 0xa3f, 0xa1f, 0x9ff, 0x9df, 0x9bf, 0x99f, 0x97f, 0x95f, 0x93f, 0x91f, 0x8ff, 0x8df, 0x8bf, 0x89f, 0x87f, 0x85f, 0x83f, 0x81f, 0x800, 0x7e0, 0x7c0, 0x7a0, 0x780, 0x760, 0x740, 0x720, 0x700, 0x6e0, 0x6c0, 0x6a0, 0x680, 0x660, 0x640, 0x620, 0x600, 0x5e0, 0x5c0, 0x5a0, 0x580, 0x560, 0x540, 0x520, 0x500, 0x4e0, 0x4c0, 0x4a0, 0x480, 0x460, 0x440, 0x420, 0x400, 0x3e0, 0x3c0, 0x3a0, 0x380, 0x360, 0x340, 0x320, 0x300, 0x2e0, 0x2c0, 0x2a0, 0x280, 0x260, 0x240, 0x220, 0x200, 0x1e0, 0x1c0, 0x1a0, 0x180, 0x160, 0x140, 0x120, 0x100, 0xe0, 0xc0, 0xa0, 0x80, 0x60, 0x40, 0x20}; |
| 61 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE | 61 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE |
| 62 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE | 62 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE |
| 63 | static const dacsample_t dac_buffer_square[AUDIO_DAC_BUFFER_SIZE] = { | 63 | static const dacsample_t dac_buffer_square[AUDIO_DAC_BUFFER_SIZE] = { |
| 64 | [0 ... AUDIO_DAC_BUFFER_SIZE / 2 - 1] = 0, // first and | 64 | [0 ... AUDIO_DAC_BUFFER_SIZE / 2 - 1] = 0, // first and |
| 65 | [AUDIO_DAC_BUFFER_SIZE / 2 ... AUDIO_DAC_BUFFER_SIZE - 1] = AUDIO_DAC_SAMPLE_MAX, // second half | 65 | [AUDIO_DAC_BUFFER_SIZE / 2 ... AUDIO_DAC_BUFFER_SIZE - 1] = AUDIO_DAC_SAMPLE_MAX, // second half |
| 66 | }; | 66 | }; |
| 67 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE | 67 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE |
| 68 | /* | 68 | /* |
| 69 | // four steps: 0, 1/3, 2/3 and 1 | 69 | // four steps: 0, 1/3, 2/3 and 1 |
| 70 | static const dacsample_t dac_buffer_staircase[AUDIO_DAC_BUFFER_SIZE] = { | 70 | static const dacsample_t dac_buffer_staircase[AUDIO_DAC_BUFFER_SIZE] = { |
| @@ -77,7 +77,7 @@ static const dacsample_t dac_buffer_staircase[AUDIO_DAC_BUFFER_SIZE] = { | |||
| 77 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID | 77 | #ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID |
| 78 | static const dacsample_t dac_buffer_trapezoid[AUDIO_DAC_BUFFER_SIZE] = {0x0, 0x1f, 0x7f, 0xdf, 0x13f, 0x19f, 0x1ff, 0x25f, 0x2bf, 0x31f, 0x37f, 0x3df, 0x43f, 0x49f, 0x4ff, 0x55f, 0x5bf, 0x61f, 0x67f, 0x6df, 0x73f, 0x79f, 0x7ff, 0x85f, 0x8bf, 0x91f, 0x97f, 0x9df, 0xa3f, 0xa9f, 0xaff, 0xb5f, 0xbbf, 0xc1f, 0xc7f, 0xcdf, 0xd3f, 0xd9f, 0xdff, 0xe5f, 0xebf, 0xf1f, 0xf7f, 0xfdf, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | 78 | static const dacsample_t dac_buffer_trapezoid[AUDIO_DAC_BUFFER_SIZE] = {0x0, 0x1f, 0x7f, 0xdf, 0x13f, 0x19f, 0x1ff, 0x25f, 0x2bf, 0x31f, 0x37f, 0x3df, 0x43f, 0x49f, 0x4ff, 0x55f, 0x5bf, 0x61f, 0x67f, 0x6df, 0x73f, 0x79f, 0x7ff, 0x85f, 0x8bf, 0x91f, 0x97f, 0x9df, 0xa3f, 0xa9f, 0xaff, 0xb5f, 0xbbf, 0xc1f, 0xc7f, 0xcdf, 0xd3f, 0xd9f, 0xdff, 0xe5f, 0xebf, 0xf1f, 0xf7f, 0xfdf, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, |
| 79 | 0xfff, 0xfdf, 0xf7f, 0xf1f, 0xebf, 0xe5f, 0xdff, 0xd9f, 0xd3f, 0xcdf, 0xc7f, 0xc1f, 0xbbf, 0xb5f, 0xaff, 0xa9f, 0xa3f, 0x9df, 0x97f, 0x91f, 0x8bf, 0x85f, 0x7ff, 0x79f, 0x73f, 0x6df, 0x67f, 0x61f, 0x5bf, 0x55f, 0x4ff, 0x49f, 0x43f, 0x3df, 0x37f, 0x31f, 0x2bf, 0x25f, 0x1ff, 0x19f, 0x13f, 0xdf, 0x7f, 0x1f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; | 79 | 0xfff, 0xfdf, 0xf7f, 0xf1f, 0xebf, 0xe5f, 0xdff, 0xd9f, 0xd3f, 0xcdf, 0xc7f, 0xc1f, 0xbbf, 0xb5f, 0xaff, 0xa9f, 0xa3f, 0x9df, 0x97f, 0x91f, 0x8bf, 0x85f, 0x7ff, 0x79f, 0x73f, 0x6df, 0x67f, 0x61f, 0x5bf, 0x55f, 0x4ff, 0x49f, 0x43f, 0x3df, 0x37f, 0x31f, 0x2bf, 0x25f, 0x1ff, 0x19f, 0x13f, 0xdf, 0x7f, 0x1f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; |
| 80 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID | 80 | #endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID |
| 81 | 81 | ||
| 82 | static dacsample_t dac_buffer_empty[AUDIO_DAC_BUFFER_SIZE] = {AUDIO_DAC_OFF_VALUE}; | 82 | static dacsample_t dac_buffer_empty[AUDIO_DAC_BUFFER_SIZE] = {AUDIO_DAC_OFF_VALUE}; |
| 83 | 83 | ||
| @@ -98,7 +98,7 @@ typedef enum { | |||
| 98 | OUTPUT_REACHED_ZERO_BEFORE_OFF, | 98 | OUTPUT_REACHED_ZERO_BEFORE_OFF, |
| 99 | OUTPUT_OFF, | 99 | OUTPUT_OFF, |
| 100 | OUTPUT_OFF_1, | 100 | OUTPUT_OFF_1, |
| 101 | OUTPUT_OFF_2, // trailing off: giving the DAC two more conversion cycles until the AUDIO_DAC_OFF_VALUE reaches the output, then turn the timer off, which leaves the output at that level | 101 | OUTPUT_OFF_2, // trailing off: giving the DAC two more conversion cycles until the AUDIO_DAC_OFF_VALUE reaches the output, then turn the timer off, which leaves the output at that level |
| 102 | number_of_output_states | 102 | number_of_output_states |
| 103 | } output_states_t; | 103 | } output_states_t; |
| 104 | output_states_t state = OUTPUT_OFF_2; | 104 | output_states_t state = OUTPUT_OFF_2; |
| @@ -171,7 +171,7 @@ static void dac_end(DACDriver *dacp) { | |||
| 171 | 171 | ||
| 172 | // work on the other half of the buffer | 172 | // work on the other half of the buffer |
| 173 | if (dacIsBufferComplete(dacp)) { | 173 | if (dacIsBufferComplete(dacp)) { |
| 174 | sample_p += AUDIO_DAC_BUFFER_SIZE / 2; // 'half_index' | 174 | sample_p += AUDIO_DAC_BUFFER_SIZE / 2; // 'half_index' |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | for (uint8_t s = 0; s < AUDIO_DAC_BUFFER_SIZE / 2; s++) { | 177 | for (uint8_t s = 0; s < AUDIO_DAC_BUFFER_SIZE / 2; s++) { |
| @@ -196,8 +196,8 @@ static void dac_end(DACDriver *dacp) { | |||
| 196 | * * * | 196 | * * * |
| 197 | * =====*=*================================================= 0x0 | 197 | * =====*=*================================================= 0x0 |
| 198 | */ | 198 | */ |
| 199 | if (((sample_p[s] + (AUDIO_DAC_SAMPLE_MAX / 100)) > AUDIO_DAC_OFF_VALUE) && // value approaches from below | 199 | if (((sample_p[s] + (AUDIO_DAC_SAMPLE_MAX / 100)) > AUDIO_DAC_OFF_VALUE) && // value approaches from below |
| 200 | (sample_p[s] < (AUDIO_DAC_OFF_VALUE + (AUDIO_DAC_SAMPLE_MAX / 100))) // or above | 200 | (sample_p[s] < (AUDIO_DAC_OFF_VALUE + (AUDIO_DAC_SAMPLE_MAX / 100))) // or above |
| 201 | ) { | 201 | ) { |
| 202 | if ((OUTPUT_SHOULD_START == state) && (active_tones_snapshot_length > 0)) { | 202 | if ((OUTPUT_SHOULD_START == state) && (active_tones_snapshot_length > 0)) { |
| 203 | state = OUTPUT_RUN_NORMALLY; | 203 | state = OUTPUT_RUN_NORMALLY; |
| @@ -220,7 +220,7 @@ static void dac_end(DACDriver *dacp) { | |||
| 220 | // -> saves cpu cycles (?) | 220 | // -> saves cpu cycles (?) |
| 221 | for (uint8_t i = 0; i < active_tones; i++) { | 221 | for (uint8_t i = 0; i < active_tones; i++) { |
| 222 | float freq = audio_get_processed_frequency(i); | 222 | float freq = audio_get_processed_frequency(i); |
| 223 | if (freq > 0) { // disregard 'rest' notes, with valid frequency 0.0f; which would only lower the resulting waveform volume during the additive synthesis step | 223 | if (freq > 0) { // disregard 'rest' notes, with valid frequency 0.0f; which would only lower the resulting waveform volume during the additive synthesis step |
| 224 | active_tones_snapshot[active_tones_snapshot_length++] = freq; | 224 | active_tones_snapshot[active_tones_snapshot_length++] = freq; |
| 225 | } | 225 | } |
| 226 | } | 226 | } |
| @@ -321,7 +321,9 @@ void audio_driver_initialize() { | |||
| 321 | gptStart(&GPTD6, &gpt6cfg1); | 321 | gptStart(&GPTD6, &gpt6cfg1); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | void audio_driver_stop(void) { state = OUTPUT_SHOULD_STOP; } | 324 | void audio_driver_stop(void) { |
| 325 | state = OUTPUT_SHOULD_STOP; | ||
| 326 | } | ||
| 325 | 327 | ||
| 326 | void audio_driver_start(void) { | 328 | void audio_driver_start(void) { |
| 327 | gptStartContinuous(&GPTD6, 2U); | 329 | gptStartContinuous(&GPTD6, 2U); |
diff --git a/platforms/chibios/drivers/audio_dac_basic.c b/platforms/chibios/drivers/audio_dac_basic.c index fac6513506..64439a1e3c 100644 --- a/platforms/chibios/drivers/audio_dac_basic.c +++ b/platforms/chibios/drivers/audio_dac_basic.c | |||
| @@ -115,13 +115,15 @@ void channel_1_set_frequency(float freq) { | |||
| 115 | channel_1_frequency = freq; | 115 | channel_1_frequency = freq; |
| 116 | 116 | ||
| 117 | channel_1_stop(); | 117 | channel_1_stop(); |
| 118 | if (freq <= 0.0) // a pause/rest has freq=0 | 118 | if (freq <= 0.0) // a pause/rest has freq=0 |
| 119 | return; | 119 | return; |
| 120 | 120 | ||
| 121 | gpt6cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE; | 121 | gpt6cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE; |
| 122 | channel_1_start(); | 122 | channel_1_start(); |
| 123 | } | 123 | } |
| 124 | float channel_1_get_frequency(void) { return channel_1_frequency; } | 124 | float channel_1_get_frequency(void) { |
| 125 | return channel_1_frequency; | ||
| 126 | } | ||
| 125 | 127 | ||
| 126 | void channel_2_start(void) { | 128 | void channel_2_start(void) { |
| 127 | gptStart(&GPTD7, &gpt7cfg1); | 129 | gptStart(&GPTD7, &gpt7cfg1); |
| @@ -140,13 +142,15 @@ void channel_2_set_frequency(float freq) { | |||
| 140 | channel_2_frequency = freq; | 142 | channel_2_frequency = freq; |
| 141 | 143 | ||
| 142 | channel_2_stop(); | 144 | channel_2_stop(); |
| 143 | if (freq <= 0.0) // a pause/rest has freq=0 | 145 | if (freq <= 0.0) // a pause/rest has freq=0 |
| 144 | return; | 146 | return; |
| 145 | 147 | ||
| 146 | gpt7cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE; | 148 | gpt7cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE; |
| 147 | channel_2_start(); | 149 | channel_2_start(); |
| 148 | } | 150 | } |
| 149 | float channel_2_get_frequency(void) { return channel_2_frequency; } | 151 | float channel_2_get_frequency(void) { |
| 152 | return channel_2_frequency; | ||
| 153 | } | ||
| 150 | 154 | ||
| 151 | static void gpt_audio_state_cb(GPTDriver *gptp) { | 155 | static void gpt_audio_state_cb(GPTDriver *gptp) { |
| 152 | if (audio_update_state()) { | 156 | if (audio_update_state()) { |
| @@ -155,8 +159,8 @@ static void gpt_audio_state_cb(GPTDriver *gptp) { | |||
| 155 | channel_1_set_frequency(audio_get_processed_frequency(0)); | 159 | channel_1_set_frequency(audio_get_processed_frequency(0)); |
| 156 | channel_2_set_frequency(audio_get_processed_frequency(0)); | 160 | channel_2_set_frequency(audio_get_processed_frequency(0)); |
| 157 | 161 | ||
| 158 | #else // two separate audio outputs/speakers | 162 | #else // two separate audio outputs/speakers |
| 159 | // primary speaker on A4, optional secondary on A5 | 163 | // primary speaker on A4, optional secondary on A5 |
| 160 | if (AUDIO_PIN == A4) { | 164 | if (AUDIO_PIN == A4) { |
| 161 | channel_1_set_frequency(audio_get_processed_frequency(0)); | 165 | channel_1_set_frequency(audio_get_processed_frequency(0)); |
| 162 | if (AUDIO_PIN_ALT == A5) { | 166 | if (AUDIO_PIN_ALT == A5) { |
diff --git a/platforms/chibios/drivers/audio_pwm_hardware.c b/platforms/chibios/drivers/audio_pwm_hardware.c index cd40019ee7..710f397609 100644 --- a/platforms/chibios/drivers/audio_pwm_hardware.c +++ b/platforms/chibios/drivers/audio_pwm_hardware.c | |||
| @@ -72,7 +72,7 @@ static float channel_1_frequency = 0.0f; | |||
| 72 | void channel_1_set_frequency(float freq) { | 72 | void channel_1_set_frequency(float freq) { |
| 73 | channel_1_frequency = freq; | 73 | channel_1_frequency = freq; |
| 74 | 74 | ||
| 75 | if (freq <= 0.0) // a pause/rest has freq=0 | 75 | if (freq <= 0.0) // a pause/rest has freq=0 |
| 76 | return; | 76 | return; |
| 77 | 77 | ||
| 78 | pwmcnt_t period = (pwmCFG.frequency / freq); | 78 | pwmcnt_t period = (pwmCFG.frequency / freq); |
| @@ -82,14 +82,18 @@ void channel_1_set_frequency(float freq) { | |||
| 82 | PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100)); | 82 | PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100)); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | float channel_1_get_frequency(void) { return channel_1_frequency; } | 85 | float channel_1_get_frequency(void) { |
| 86 | return channel_1_frequency; | ||
| 87 | } | ||
| 86 | 88 | ||
| 87 | void channel_1_start(void) { | 89 | void channel_1_start(void) { |
| 88 | pwmStop(&AUDIO_PWM_DRIVER); | 90 | pwmStop(&AUDIO_PWM_DRIVER); |
| 89 | pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG); | 91 | pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG); |
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | void channel_1_stop(void) { pwmStop(&AUDIO_PWM_DRIVER); } | 94 | void channel_1_stop(void) { |
| 95 | pwmStop(&AUDIO_PWM_DRIVER); | ||
| 96 | } | ||
| 93 | 97 | ||
| 94 | static void gpt_callback(GPTDriver *gptp); | 98 | static void gpt_callback(GPTDriver *gptp); |
| 95 | GPTConfig gptCFG = { | 99 | GPTConfig gptCFG = { |
| @@ -108,9 +112,9 @@ void audio_driver_initialize(void) { | |||
| 108 | pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG); | 112 | pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG); |
| 109 | 113 | ||
| 110 | // connect the AUDIO_PIN to the PWM hardware | 114 | // connect the AUDIO_PIN to the PWM hardware |
| 111 | #if defined(USE_GPIOV1) // STM32F103C8 | 115 | #if defined(USE_GPIOV1) // STM32F103C8 |
| 112 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE_PUSHPULL); | 116 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE_PUSHPULL); |
| 113 | #else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command) | 117 | #else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command) |
| 114 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE(AUDIO_PWM_PAL_MODE)); | 118 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE(AUDIO_PWM_PAL_MODE)); |
| 115 | #endif | 119 | #endif |
| 116 | 120 | ||
| @@ -135,10 +139,10 @@ void audio_driver_stop(void) { | |||
| 135 | * and updates the pwm to output that frequency | 139 | * and updates the pwm to output that frequency |
| 136 | */ | 140 | */ |
| 137 | static void gpt_callback(GPTDriver *gptp) { | 141 | static void gpt_callback(GPTDriver *gptp) { |
| 138 | float freq; // TODO: freq_alt | 142 | float freq; // TODO: freq_alt |
| 139 | 143 | ||
| 140 | if (audio_update_state()) { | 144 | if (audio_update_state()) { |
| 141 | freq = audio_get_processed_frequency(0); // freq_alt would be index=1 | 145 | freq = audio_get_processed_frequency(0); // freq_alt would be index=1 |
| 142 | channel_1_set_frequency(freq); | 146 | channel_1_set_frequency(freq); |
| 143 | } | 147 | } |
| 144 | } | 148 | } |
diff --git a/platforms/chibios/drivers/audio_pwm_software.c b/platforms/chibios/drivers/audio_pwm_software.c index 15c3e98b6a..e01f86ea52 100644 --- a/platforms/chibios/drivers/audio_pwm_software.c +++ b/platforms/chibios/drivers/audio_pwm_software.c | |||
| @@ -57,7 +57,7 @@ static float channel_1_frequency = 0.0f; | |||
| 57 | void channel_1_set_frequency(float freq) { | 57 | void channel_1_set_frequency(float freq) { |
| 58 | channel_1_frequency = freq; | 58 | channel_1_frequency = freq; |
| 59 | 59 | ||
| 60 | if (freq <= 0.0) // a pause/rest has freq=0 | 60 | if (freq <= 0.0) // a pause/rest has freq=0 |
| 61 | return; | 61 | return; |
| 62 | 62 | ||
| 63 | pwmcnt_t period = (pwmCFG.frequency / freq); | 63 | pwmcnt_t period = (pwmCFG.frequency / freq); |
| @@ -68,7 +68,9 @@ void channel_1_set_frequency(float freq) { | |||
| 68 | PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100)); | 68 | PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100)); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | float channel_1_get_frequency(void) { return channel_1_frequency; } | 71 | float channel_1_get_frequency(void) { |
| 72 | return channel_1_frequency; | ||
| 73 | } | ||
| 72 | 74 | ||
| 73 | void channel_1_start(void) { | 75 | void channel_1_start(void) { |
| 74 | pwmStop(&AUDIO_PWM_DRIVER); | 76 | pwmStop(&AUDIO_PWM_DRIVER); |
| @@ -81,10 +83,10 @@ void channel_1_start(void) { | |||
| 81 | void channel_1_stop(void) { | 83 | void channel_1_stop(void) { |
| 82 | pwmStop(&AUDIO_PWM_DRIVER); | 84 | pwmStop(&AUDIO_PWM_DRIVER); |
| 83 | 85 | ||
| 84 | palClearLine(AUDIO_PIN); // leave the line low, after last note was played | 86 | palClearLine(AUDIO_PIN); // leave the line low, after last note was played |
| 85 | 87 | ||
| 86 | #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) | 88 | #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) |
| 87 | palClearLine(AUDIO_PIN_ALT); // leave the line low, after last note was played | 89 | palClearLine(AUDIO_PIN_ALT); // leave the line low, after last note was played |
| 88 | #endif | 90 | #endif |
| 89 | } | 91 | } |
| 90 | 92 | ||
| @@ -100,7 +102,7 @@ static void pwm_audio_period_callback(PWMDriver *pwmp) { | |||
| 100 | static void pwm_audio_channel_interrupt_callback(PWMDriver *pwmp) { | 102 | static void pwm_audio_channel_interrupt_callback(PWMDriver *pwmp) { |
| 101 | (void)pwmp; | 103 | (void)pwmp; |
| 102 | if (channel_1_frequency > 0) { | 104 | if (channel_1_frequency > 0) { |
| 103 | palSetLine(AUDIO_PIN); // generate a PWM signal on any pin, not necessarily the one connected to the timer | 105 | palSetLine(AUDIO_PIN); // generate a PWM signal on any pin, not necessarily the one connected to the timer |
| 104 | #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) | 106 | #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) |
| 105 | palClearLine(AUDIO_PIN_ALT); | 107 | palClearLine(AUDIO_PIN_ALT); |
| 106 | #endif | 108 | #endif |
| @@ -131,7 +133,7 @@ void audio_driver_initialize(void) { | |||
| 131 | palClearLine(AUDIO_PIN_ALT); | 133 | palClearLine(AUDIO_PIN_ALT); |
| 132 | #endif | 134 | #endif |
| 133 | 135 | ||
| 134 | pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER); // enable pwm callbacks | 136 | pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER); // enable pwm callbacks |
| 135 | pwmEnableChannelNotification(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1); | 137 | pwmEnableChannelNotification(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1); |
| 136 | 138 | ||
| 137 | gptStart(&AUDIO_STATE_TIMER, &gptCFG); | 139 | gptStart(&AUDIO_STATE_TIMER, &gptCFG); |
| @@ -155,10 +157,10 @@ void audio_driver_stop(void) { | |||
| 155 | * and updates the pwm to output that frequency | 157 | * and updates the pwm to output that frequency |
| 156 | */ | 158 | */ |
| 157 | static void gpt_callback(GPTDriver *gptp) { | 159 | static void gpt_callback(GPTDriver *gptp) { |
| 158 | float freq; // TODO: freq_alt | 160 | float freq; // TODO: freq_alt |
| 159 | 161 | ||
| 160 | if (audio_update_state()) { | 162 | if (audio_update_state()) { |
| 161 | freq = audio_get_processed_frequency(0); // freq_alt would be index=1 | 163 | freq = audio_get_processed_frequency(0); // freq_alt would be index=1 |
| 162 | channel_1_set_frequency(freq); | 164 | channel_1_set_frequency(freq); |
| 163 | } | 165 | } |
| 164 | } | 166 | } |
diff --git a/platforms/chibios/drivers/eeprom/eeprom_stm32_L0_L1.h b/platforms/chibios/drivers/eeprom/eeprom_stm32_L0_L1.h index a35defca8b..616d7ccbee 100644 --- a/platforms/chibios/drivers/eeprom/eeprom_stm32_L0_L1.h +++ b/platforms/chibios/drivers/eeprom/eeprom_stm32_L0_L1.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | # define STM32_ONBOARD_EEPROM_SIZE 1024 | 24 | # define STM32_ONBOARD_EEPROM_SIZE 1024 |
| 25 | # else | 25 | # else |
| 26 | # include "eeconfig.h" | 26 | # include "eeconfig.h" |
| 27 | # define STM32_ONBOARD_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO and EEPROM page sizing | 27 | # define STM32_ONBOARD_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO and EEPROM page sizing |
| 28 | # endif | 28 | # endif |
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index 4a5d4760d0..d10bdbabc1 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c | |||
| @@ -203,4 +203,6 @@ i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uin | |||
| 203 | return chibios_to_qmk(&status); | 203 | return chibios_to_qmk(&status); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | void i2c_stop(void) { i2cStop(&I2C_DRIVER); } | 206 | void i2c_stop(void) { |
| 207 | i2cStop(&I2C_DRIVER); | ||
| 208 | } | ||
diff --git a/platforms/chibios/drivers/serial.c b/platforms/chibios/drivers/serial.c index 17d0b32be8..6db5d85250 100644 --- a/platforms/chibios/drivers/serial.c +++ b/platforms/chibios/drivers/serial.c | |||
| @@ -50,14 +50,30 @@ | |||
| 50 | # error invalid SELECT_SOFT_SERIAL_SPEED value | 50 | # error invalid SELECT_SOFT_SERIAL_SPEED value |
| 51 | #endif | 51 | #endif |
| 52 | 52 | ||
| 53 | inline static void serial_delay(void) { wait_us(SERIAL_DELAY); } | 53 | inline static void serial_delay(void) { |
| 54 | inline static void serial_delay_half(void) { wait_us(SERIAL_DELAY / 2); } | 54 | wait_us(SERIAL_DELAY); |
| 55 | inline static void serial_delay_blip(void) { wait_us(1); } | 55 | } |
| 56 | inline static void serial_output(void) { setPinOutput(SOFT_SERIAL_PIN); } | 56 | inline static void serial_delay_half(void) { |
| 57 | inline static void serial_input(void) { setPinInputHigh(SOFT_SERIAL_PIN); } | 57 | wait_us(SERIAL_DELAY / 2); |
| 58 | inline static bool serial_read_pin(void) { return !!readPin(SOFT_SERIAL_PIN); } | 58 | } |
| 59 | inline static void serial_low(void) { writePinLow(SOFT_SERIAL_PIN); } | 59 | inline static void serial_delay_blip(void) { |
| 60 | inline static void serial_high(void) { writePinHigh(SOFT_SERIAL_PIN); } | 60 | wait_us(1); |
| 61 | } | ||
| 62 | inline static void serial_output(void) { | ||
| 63 | setPinOutput(SOFT_SERIAL_PIN); | ||
| 64 | } | ||
| 65 | inline static void serial_input(void) { | ||
| 66 | setPinInputHigh(SOFT_SERIAL_PIN); | ||
| 67 | } | ||
| 68 | inline static bool serial_read_pin(void) { | ||
| 69 | return !!readPin(SOFT_SERIAL_PIN); | ||
| 70 | } | ||
| 71 | inline static void serial_low(void) { | ||
| 72 | writePinLow(SOFT_SERIAL_PIN); | ||
| 73 | } | ||
| 74 | inline static void serial_high(void) { | ||
| 75 | writePinHigh(SOFT_SERIAL_PIN); | ||
| 76 | } | ||
| 61 | 77 | ||
| 62 | void interrupt_handler(void *arg); | 78 | void interrupt_handler(void *arg); |
| 63 | 79 | ||
| @@ -226,7 +242,7 @@ bool soft_serial_transaction(int sstd_index) { | |||
| 226 | 242 | ||
| 227 | uint8_t checksum = 0; | 243 | uint8_t checksum = 0; |
| 228 | // send data to the slave | 244 | // send data to the slave |
| 229 | serial_write_byte(sstd_index); // first chunk is transaction id | 245 | serial_write_byte(sstd_index); // first chunk is transaction id |
| 230 | sync_recv(); | 246 | sync_recv(); |
| 231 | 247 | ||
| 232 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { | 248 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { |
| @@ -238,7 +254,7 @@ bool soft_serial_transaction(int sstd_index) { | |||
| 238 | sync_recv(); | 254 | sync_recv(); |
| 239 | 255 | ||
| 240 | serial_delay(); | 256 | serial_delay(); |
| 241 | serial_delay(); // read mid pulses | 257 | serial_delay(); // read mid pulses |
| 242 | 258 | ||
| 243 | // receive data from the slave | 259 | // receive data from the slave |
| 244 | uint8_t checksum_computed = 0; | 260 | uint8_t checksum_computed = 0; |
diff --git a/platforms/chibios/drivers/serial_usart.c b/platforms/chibios/drivers/serial_usart.c index 42c476a374..85c64214d1 100644 --- a/platforms/chibios/drivers/serial_usart.c +++ b/platforms/chibios/drivers/serial_usart.c | |||
| @@ -238,7 +238,7 @@ void soft_serial_initiator_init(void) { | |||
| 238 | usart_master_init(&serial_driver); | 238 | usart_master_init(&serial_driver); |
| 239 | 239 | ||
| 240 | #if defined(MCU_STM32) && defined(SERIAL_USART_PIN_SWAP) | 240 | #if defined(MCU_STM32) && defined(SERIAL_USART_PIN_SWAP) |
| 241 | serial_config.cr2 |= USART_CR2_SWAP; // master has swapped TX/RX pins | 241 | serial_config.cr2 |= USART_CR2_SWAP; // master has swapped TX/RX pins |
| 242 | #endif | 242 | #endif |
| 243 | 243 | ||
| 244 | sdStart(serial_driver, &serial_config); | 244 | sdStart(serial_driver, &serial_config); |
diff --git a/platforms/chibios/drivers/serial_usart.h b/platforms/chibios/drivers/serial_usart.h index 7b135b31e0..81fe9e0113 100644 --- a/platforms/chibios/drivers/serial_usart.h +++ b/platforms/chibios/drivers/serial_usart.h | |||
| @@ -50,15 +50,15 @@ | |||
| 50 | #endif | 50 | #endif |
| 51 | 51 | ||
| 52 | #if !defined(USART_CR1_M0) | 52 | #if !defined(USART_CR1_M0) |
| 53 | # define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so | 53 | # define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so |
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | #if !defined(SERIAL_USART_CR1) | 56 | #if !defined(SERIAL_USART_CR1) |
| 57 | # define SERIAL_USART_CR1 (USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0) // parity enable, odd parity, 9 bit length | 57 | # define SERIAL_USART_CR1 (USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0) // parity enable, odd parity, 9 bit length |
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| 60 | #if !defined(SERIAL_USART_CR2) | 60 | #if !defined(SERIAL_USART_CR2) |
| 61 | # define SERIAL_USART_CR2 (USART_CR2_STOP_1) // 2 stop bits | 61 | # define SERIAL_USART_CR2 (USART_CR2_STOP_1) // 2 stop bits |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #if !defined(SERIAL_USART_CR3) | 64 | #if !defined(SERIAL_USART_CR3) |
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index dde0bb0597..998bace550 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c | |||
| @@ -115,7 +115,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { | |||
| 115 | 115 | ||
| 116 | #elif defined(HT32) | 116 | #elif defined(HT32) |
| 117 | spiConfig.cr0 = SPI_CR0_SELOEN; | 117 | spiConfig.cr0 = SPI_CR0_SELOEN; |
| 118 | spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode | 118 | spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode |
| 119 | 119 | ||
| 120 | if (lsbFirst) { | 120 | if (lsbFirst) { |
| 121 | spiConfig.cr1 |= SPI_CR1_FIRSTBIT; | 121 | spiConfig.cr1 |= SPI_CR1_FIRSTBIT; |
diff --git a/platforms/chibios/drivers/uart.c b/platforms/chibios/drivers/uart.c index d2ea5d6415..dbe991efa3 100644 --- a/platforms/chibios/drivers/uart.c +++ b/platforms/chibios/drivers/uart.c | |||
| @@ -43,7 +43,9 @@ void uart_init(uint32_t baud) { | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | void uart_write(uint8_t data) { sdPut(&SERIAL_DRIVER, c); } | 46 | void uart_write(uint8_t data) { |
| 47 | sdPut(&SERIAL_DRIVER, c); | ||
| 48 | } | ||
| 47 | 49 | ||
| 48 | uint8_t uart_read(void) { | 50 | uint8_t uart_read(void) { |
| 49 | msg_t res = sdGet(&SERIAL_DRIVER); | 51 | msg_t res = sdGet(&SERIAL_DRIVER); |
| @@ -51,8 +53,14 @@ uint8_t uart_read(void) { | |||
| 51 | return (uint8_t)res; | 53 | return (uint8_t)res; |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | void uart_transmit(const uint8_t *data, uint16_t length) { sdWrite(&SERIAL_DRIVER, data, length); } | 56 | void uart_transmit(const uint8_t *data, uint16_t length) { |
| 57 | sdWrite(&SERIAL_DRIVER, data, length); | ||
| 58 | } | ||
| 55 | 59 | ||
| 56 | void uart_receive(uint8_t *data, uint16_t length) { sdRead(&SERIAL_DRIVER, data, length); } | 60 | void uart_receive(uint8_t *data, uint16_t length) { |
| 61 | sdRead(&SERIAL_DRIVER, data, length); | ||
| 62 | } | ||
| 57 | 63 | ||
| 58 | bool uart_available(void) { return !sdGetWouldBlock(&SERIAL_DRIVER); } | 64 | bool uart_available(void) { |
| 65 | return !sdGetWouldBlock(&SERIAL_DRIVER); | ||
| 66 | } | ||
diff --git a/platforms/chibios/drivers/usbpd_stm32g4.c b/platforms/chibios/drivers/usbpd_stm32g4.c index f16ca8aeae..0096f22f07 100644 --- a/platforms/chibios/drivers/usbpd_stm32g4.c +++ b/platforms/chibios/drivers/usbpd_stm32g4.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #ifndef USBPD_UCPD1_CFG1 | 19 | #ifndef USBPD_UCPD1_CFG1 |
| 20 | # define USBPD_UCPD1_CFG1 (UCPD_CFG1_PSC_UCPDCLK_0 | UCPD_CFG1_TRANSWIN_3 | UCPD_CFG1_IFRGAP_4 | UCPD_CFG1_HBITCLKDIV_4) | 20 | # define USBPD_UCPD1_CFG1 (UCPD_CFG1_PSC_UCPDCLK_0 | UCPD_CFG1_TRANSWIN_3 | UCPD_CFG1_IFRGAP_4 | UCPD_CFG1_HBITCLKDIV_4) |
| 21 | #endif // USBPD_UCPD1_CFG1 | 21 | #endif // USBPD_UCPD1_CFG1 |
| 22 | 22 | ||
| 23 | // Initialises the USBPD subsystem | 23 | // Initialises the USBPD subsystem |
| 24 | __attribute__((weak)) void usbpd_init(void) { | 24 | __attribute__((weak)) void usbpd_init(void) { |
| @@ -64,7 +64,7 @@ __attribute__((weak)) usbpd_allowance_t usbpd_get_allowance(void) { | |||
| 64 | switch (vstate_max) { | 64 | switch (vstate_max) { |
| 65 | case 0: | 65 | case 0: |
| 66 | case 1: | 66 | case 1: |
| 67 | return USBPD_500MA; // Note that this is 500mA (i.e. max USB 2.0), not 900mA, as we're not using USB 3.1 as a sink device. | 67 | return USBPD_500MA; // Note that this is 500mA (i.e. max USB 2.0), not 900mA, as we're not using USB 3.1 as a sink device. |
| 68 | case 2: | 68 | case 2: |
| 69 | return USBPD_1500MA; | 69 | return USBPD_1500MA; |
| 70 | case 3: | 70 | case 3: |
diff --git a/platforms/chibios/drivers/ws2812.c b/platforms/chibios/drivers/ws2812.c index 7e870661de..1b3bb59842 100644 --- a/platforms/chibios/drivers/ws2812.c +++ b/platforms/chibios/drivers/ws2812.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | # define NOP_FUDGE 0.4 | 10 | # define NOP_FUDGE 0.4 |
| 11 | # else | 11 | # else |
| 12 | # error("NOP_FUDGE configuration required") | 12 | # error("NOP_FUDGE configuration required") |
| 13 | # define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot | 13 | # define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot |
| 14 | # endif | 14 | # endif |
| 15 | #endif | 15 | #endif |
| 16 | 16 | ||
| @@ -25,12 +25,12 @@ | |||
| 25 | // The reset gap can be 6000 ns, but depending on the LED strip it may have to be increased | 25 | // The reset gap can be 6000 ns, but depending on the LED strip it may have to be increased |
| 26 | // to values like 600000 ns. If it is too small, the pixels will show nothing most of the time. | 26 | // to values like 600000 ns. If it is too small, the pixels will show nothing most of the time. |
| 27 | #ifndef WS2812_RES | 27 | #ifndef WS2812_RES |
| 28 | # define WS2812_RES (1000 * WS2812_TRST_US) // Width of the low gap between bits to cause a frame to latch | 28 | # define WS2812_RES (1000 * WS2812_TRST_US) // Width of the low gap between bits to cause a frame to latch |
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
| 31 | #define NUMBER_NOPS 6 | 31 | #define NUMBER_NOPS 6 |
| 32 | #define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) | 32 | #define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) |
| 33 | #define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives | 33 | #define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives |
| 34 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | 34 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) |
| 35 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | 35 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) |
| 36 | 36 | ||
| @@ -67,7 +67,9 @@ void sendByte(uint8_t byte) { | |||
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | void ws2812_init(void) { palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); } | 70 | void ws2812_init(void) { |
| 71 | palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); | ||
| 72 | } | ||
| 71 | 73 | ||
| 72 | // Setleds for standard RGB | 74 | // Setleds for standard RGB |
| 73 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { | 75 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { |
diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c index 19ea3cfe8a..57187676d7 100644 --- a/platforms/chibios/drivers/ws2812_pwm.c +++ b/platforms/chibios/drivers/ws2812_pwm.c | |||
| @@ -11,19 +11,19 @@ | |||
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | #ifndef WS2812_PWM_DRIVER | 13 | #ifndef WS2812_PWM_DRIVER |
| 14 | # define WS2812_PWM_DRIVER PWMD2 // TIMx | 14 | # define WS2812_PWM_DRIVER PWMD2 // TIMx |
| 15 | #endif | 15 | #endif |
| 16 | #ifndef WS2812_PWM_CHANNEL | 16 | #ifndef WS2812_PWM_CHANNEL |
| 17 | # define WS2812_PWM_CHANNEL 2 // Channel | 17 | # define WS2812_PWM_CHANNEL 2 // Channel |
| 18 | #endif | 18 | #endif |
| 19 | #ifndef WS2812_PWM_PAL_MODE | 19 | #ifndef WS2812_PWM_PAL_MODE |
| 20 | # define WS2812_PWM_PAL_MODE 2 // DI Pin's alternate function value | 20 | # define WS2812_PWM_PAL_MODE 2 // DI Pin's alternate function value |
| 21 | #endif | 21 | #endif |
| 22 | #ifndef WS2812_DMA_STREAM | 22 | #ifndef WS2812_DMA_STREAM |
| 23 | # define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP | 23 | # define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP |
| 24 | #endif | 24 | #endif |
| 25 | #ifndef WS2812_DMA_CHANNEL | 25 | #ifndef WS2812_DMA_CHANNEL |
| 26 | # define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP | 26 | # define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP |
| 27 | #endif | 27 | #endif |
| 28 | #if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_DMAMUX_ID) | 28 | #if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_DMAMUX_ID) |
| 29 | # error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP" | 29 | # error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP" |
| @@ -56,7 +56,7 @@ | |||
| 56 | 56 | ||
| 57 | #ifndef WS2812_PWM_TARGET_PERIOD | 57 | #ifndef WS2812_PWM_TARGET_PERIOD |
| 58 | //# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...? | 58 | //# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...? |
| 59 | # define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1 | 59 | # define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1 |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | /* --- PRIVATE CONSTANTS ---------------------------------------------------- */ | 62 | /* --- PRIVATE CONSTANTS ---------------------------------------------------- */ |
| @@ -259,8 +259,10 @@ write/read to/from the other buffer). | |||
| 259 | void ws2812_init(void) { | 259 | void ws2812_init(void) { |
| 260 | // Initialize led frame buffer | 260 | // Initialize led frame buffer |
| 261 | uint32_t i; | 261 | uint32_t i; |
| 262 | for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle | 262 | for (i = 0; i < WS2812_COLOR_BIT_N; i++) |
| 263 | for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero | 263 | ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle |
| 264 | for (i = 0; i < WS2812_RESET_BIT_N; i++) | ||
| 265 | ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero | ||
| 264 | 266 | ||
| 265 | palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); | 267 | palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); |
| 266 | 268 | ||
| @@ -268,22 +270,22 @@ void ws2812_init(void) { | |||
| 268 | //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config | 270 | //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config |
| 269 | static const PWMConfig ws2812_pwm_config = { | 271 | static const PWMConfig ws2812_pwm_config = { |
| 270 | .frequency = WS2812_PWM_FREQUENCY, | 272 | .frequency = WS2812_PWM_FREQUENCY, |
| 271 | .period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben | 273 | .period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben |
| 272 | .callback = NULL, | 274 | .callback = NULL, |
| 273 | .channels = | 275 | .channels = |
| 274 | { | 276 | { |
| 275 | [0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled | 277 | [0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled |
| 276 | [WS2812_PWM_CHANNEL - 1] = {.mode = WS2812_PWM_OUTPUT_MODE, .callback = NULL}, // Turn on the channel we care about | 278 | [WS2812_PWM_CHANNEL - 1] = {.mode = WS2812_PWM_OUTPUT_MODE, .callback = NULL}, // Turn on the channel we care about |
| 277 | }, | 279 | }, |
| 278 | .cr2 = 0, | 280 | .cr2 = 0, |
| 279 | .dier = TIM_DIER_UDE, // DMA on update event for next period | 281 | .dier = TIM_DIER_UDE, // DMA on update event for next period |
| 280 | }; | 282 | }; |
| 281 | //#pragma GCC diagnostic pop // Restore command-line warning options | 283 | //#pragma GCC diagnostic pop // Restore command-line warning options |
| 282 | 284 | ||
| 283 | // Configure DMA | 285 | // Configure DMA |
| 284 | // dmaInit(); // Joe added this | 286 | // dmaInit(); // Joe added this |
| 285 | dmaStreamAlloc(WS2812_DMA_STREAM - STM32_DMA_STREAM(0), 10, NULL, NULL); | 287 | dmaStreamAlloc(WS2812_DMA_STREAM - STM32_DMA_STREAM(0), 10, NULL, NULL); |
| 286 | dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register | 288 | dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register |
| 287 | dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer); | 289 | dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer); |
| 288 | dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N); | 290 | dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N); |
| 289 | dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3)); | 291 | dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3)); |
| @@ -302,7 +304,7 @@ void ws2812_init(void) { | |||
| 302 | // ChibiOS driver code, so we don't have to do anything special to the timer. If we did, we'd have to start the timer, | 304 | // ChibiOS driver code, so we don't have to do anything special to the timer. If we did, we'd have to start the timer, |
| 303 | // disable counting, enable the channel, and then make whatever configuration changes we need. | 305 | // disable counting, enable the channel, and then make whatever configuration changes we need. |
| 304 | pwmStart(&WS2812_PWM_DRIVER, &ws2812_pwm_config); | 306 | pwmStart(&WS2812_PWM_DRIVER, &ws2812_pwm_config); |
| 305 | pwmEnableChannel(&WS2812_PWM_DRIVER, WS2812_PWM_CHANNEL - 1, 0); // Initial period is 0; output will be low until first duty cycle is DMA'd in | 307 | pwmEnableChannel(&WS2812_PWM_DRIVER, WS2812_PWM_CHANNEL - 1, 0); // Initial period is 0; output will be low until first duty cycle is DMA'd in |
| 306 | } | 308 | } |
| 307 | 309 | ||
| 308 | void ws2812_write_led(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b) { | 310 | void ws2812_write_led(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b) { |
diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c index ba471e0b8e..76191db165 100644 --- a/platforms/chibios/drivers/ws2812_spi.c +++ b/platforms/chibios/drivers/ws2812_spi.c | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_0) | 42 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_0) |
| 43 | #elif WS2812_SPI_DIVISOR == 8 | 43 | #elif WS2812_SPI_DIVISOR == 8 |
| 44 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1) | 44 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1) |
| 45 | #elif WS2812_SPI_DIVISOR == 16 // same as default | 45 | #elif WS2812_SPI_DIVISOR == 16 // same as default |
| 46 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) | 46 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) |
| 47 | #elif WS2812_SPI_DIVISOR == 32 | 47 | #elif WS2812_SPI_DIVISOR == 32 |
| 48 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2) | 48 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2) |
| @@ -53,14 +53,14 @@ | |||
| 53 | #elif WS2812_SPI_DIVISOR == 256 | 53 | #elif WS2812_SPI_DIVISOR == 256 |
| 54 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) | 54 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) |
| 55 | #else | 55 | #else |
| 56 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default | 56 | # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | // Use SPI circular buffer | 59 | // Use SPI circular buffer |
| 60 | #ifdef WS2812_SPI_USE_CIRCULAR_BUFFER | 60 | #ifdef WS2812_SPI_USE_CIRCULAR_BUFFER |
| 61 | # define WS2812_SPI_BUFFER_MODE 1 // circular buffer | 61 | # define WS2812_SPI_BUFFER_MODE 1 // circular buffer |
| 62 | #else | 62 | #else |
| 63 | # define WS2812_SPI_BUFFER_MODE 0 // normal buffer | 63 | # define WS2812_SPI_BUFFER_MODE 0 // normal buffer |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #if defined(USE_GPIOV1) | 66 | #if defined(USE_GPIOV1) |
| @@ -104,20 +104,30 @@ static void set_led_color_rgb(LED_TYPE color, int pos) { | |||
| 104 | uint8_t* tx_start = &txbuf[PREAMBLE_SIZE]; | 104 | uint8_t* tx_start = &txbuf[PREAMBLE_SIZE]; |
| 105 | 105 | ||
| 106 | #if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) | 106 | #if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) |
| 107 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.g, j); | 107 | for (int j = 0; j < 4; j++) |
| 108 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.r, j); | 108 | tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.g, j); |
| 109 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.b, j); | 109 | for (int j = 0; j < 4; j++) |
| 110 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.r, j); | ||
| 111 | for (int j = 0; j < 4; j++) | ||
| 112 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.b, j); | ||
| 110 | #elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB) | 113 | #elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB) |
| 111 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.r, j); | 114 | for (int j = 0; j < 4; j++) |
| 112 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); | 115 | tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.r, j); |
| 113 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.b, j); | 116 | for (int j = 0; j < 4; j++) |
| 117 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); | ||
| 118 | for (int j = 0; j < 4; j++) | ||
| 119 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.b, j); | ||
| 114 | #elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR) | 120 | #elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR) |
| 115 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.b, j); | 121 | for (int j = 0; j < 4; j++) |
| 116 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); | 122 | tx_start[BYTES_FOR_LED * pos + j] = get_protocol_eq(color.b, j); |
| 117 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j); | 123 | for (int j = 0; j < 4; j++) |
| 124 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); | ||
| 125 | for (int j = 0; j < 4; j++) | ||
| 126 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j); | ||
| 118 | #endif | 127 | #endif |
| 119 | #ifdef RGBW | 128 | #ifdef RGBW |
| 120 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j); | 129 | for (int j = 0; j < 4; j++) |
| 130 | tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j); | ||
| 121 | #endif | 131 | #endif |
| 122 | } | 132 | } |
| 123 | 133 | ||
| @@ -126,7 +136,7 @@ void ws2812_init(void) { | |||
| 126 | 136 | ||
| 127 | #ifdef WS2812_SPI_SCK_PIN | 137 | #ifdef WS2812_SPI_SCK_PIN |
| 128 | palSetLineMode(WS2812_SPI_SCK_PIN, WS2812_SCK_OUTPUT_MODE); | 138 | palSetLineMode(WS2812_SPI_SCK_PIN, WS2812_SCK_OUTPUT_MODE); |
| 129 | #endif // WS2812_SPI_SCK_PIN | 139 | #endif // WS2812_SPI_SCK_PIN |
| 130 | 140 | ||
| 131 | // TODO: more dynamic baudrate | 141 | // TODO: more dynamic baudrate |
| 132 | static const SPIConfig spicfg = {WS2812_SPI_BUFFER_MODE, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN), WS2812_SPI_DIVISOR_CR1_BR_X}; | 142 | static const SPIConfig spicfg = {WS2812_SPI_BUFFER_MODE, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN), WS2812_SPI_DIVISOR_CR1_BR_X}; |
diff --git a/platforms/chibios/eeprom_stm32.c b/platforms/chibios/eeprom_stm32.c index 8bf0b19c3d..a15bfe09ed 100644 --- a/platforms/chibios/eeprom_stm32.c +++ b/platforms/chibios/eeprom_stm32.c | |||
| @@ -560,9 +560,13 @@ uint16_t EEPROM_ReadDataWord(uint16_t Address) { | |||
| 560 | /***************************************************************************** | 560 | /***************************************************************************** |
| 561 | * Bind to eeprom_driver.c | 561 | * Bind to eeprom_driver.c |
| 562 | *******************************************************************************/ | 562 | *******************************************************************************/ |
| 563 | void eeprom_driver_init(void) { EEPROM_Init(); } | 563 | void eeprom_driver_init(void) { |
| 564 | EEPROM_Init(); | ||
| 565 | } | ||
| 564 | 566 | ||
| 565 | void eeprom_driver_erase(void) { EEPROM_Erase(); } | 567 | void eeprom_driver_erase(void) { |
| 568 | EEPROM_Erase(); | ||
| 569 | } | ||
| 566 | 570 | ||
| 567 | void eeprom_read_block(void *buf, const void *addr, size_t len) { | 571 | void eeprom_read_block(void *buf, const void *addr, size_t len) { |
| 568 | const uint8_t *src = (const uint8_t *)addr; | 572 | const uint8_t *src = (const uint8_t *)addr; |
diff --git a/platforms/chibios/eeprom_stm32_defs.h b/platforms/chibios/eeprom_stm32_defs.h index 581434eb5e..a6ceb41355 100644 --- a/platforms/chibios/eeprom_stm32_defs.h +++ b/platforms/chibios/eeprom_stm32_defs.h | |||
| @@ -20,41 +20,41 @@ | |||
| 20 | #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) | 20 | #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) |
| 21 | # if defined(STM32F103xB) || defined(STM32F042x6) || defined(GD32VF103C8) || defined(GD32VF103CB) | 21 | # if defined(STM32F103xB) || defined(STM32F042x6) || defined(GD32VF103C8) || defined(GD32VF103CB) |
| 22 | # ifndef FEE_PAGE_SIZE | 22 | # ifndef FEE_PAGE_SIZE |
| 23 | # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte | 23 | # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte |
| 24 | # endif | 24 | # endif |
| 25 | # ifndef FEE_PAGE_COUNT | 25 | # ifndef FEE_PAGE_COUNT |
| 26 | # define FEE_PAGE_COUNT 2 // How many pages are used | 26 | # define FEE_PAGE_COUNT 2 // How many pages are used |
| 27 | # endif | 27 | # endif |
| 28 | # elif defined(STM32F103xE) || defined(STM32F303xC) || defined(STM32F072xB) || defined(STM32F070xB) | 28 | # elif defined(STM32F103xE) || defined(STM32F303xC) || defined(STM32F072xB) || defined(STM32F070xB) |
| 29 | # ifndef FEE_PAGE_SIZE | 29 | # ifndef FEE_PAGE_SIZE |
| 30 | # define FEE_PAGE_SIZE 0x800 // Page size = 2KByte | 30 | # define FEE_PAGE_SIZE 0x800 // Page size = 2KByte |
| 31 | # endif | 31 | # endif |
| 32 | # ifndef FEE_PAGE_COUNT | 32 | # ifndef FEE_PAGE_COUNT |
| 33 | # define FEE_PAGE_COUNT 4 // How many pages are used | 33 | # define FEE_PAGE_COUNT 4 // How many pages are used |
| 34 | # endif | 34 | # endif |
| 35 | # elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) | 35 | # elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) |
| 36 | # ifndef FEE_PAGE_SIZE | 36 | # ifndef FEE_PAGE_SIZE |
| 37 | # define FEE_PAGE_SIZE 0x4000 // Page size = 16KByte | 37 | # define FEE_PAGE_SIZE 0x4000 // Page size = 16KByte |
| 38 | # endif | 38 | # endif |
| 39 | # ifndef FEE_PAGE_COUNT | 39 | # ifndef FEE_PAGE_COUNT |
| 40 | # define FEE_PAGE_COUNT 1 // How many pages are used | 40 | # define FEE_PAGE_COUNT 1 // How many pages are used |
| 41 | # endif | 41 | # endif |
| 42 | # endif | 42 | # endif |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | #if !defined(FEE_MCU_FLASH_SIZE) | 45 | #if !defined(FEE_MCU_FLASH_SIZE) |
| 46 | # if defined(STM32F042x6) | 46 | # if defined(STM32F042x6) |
| 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb | 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb |
| 48 | # elif defined(GD32VF103C8) | 48 | # elif defined(GD32VF103C8) |
| 49 | # define FEE_MCU_FLASH_SIZE 64 // Size in Kb | 49 | # define FEE_MCU_FLASH_SIZE 64 // Size in Kb |
| 50 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) || defined(GD32VF103CB) | 50 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) || defined(GD32VF103CB) |
| 51 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb | 51 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb |
| 52 | # elif defined(STM32F303xC) || defined(STM32F401xC) | 52 | # elif defined(STM32F303xC) || defined(STM32F401xC) |
| 53 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb | 53 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb |
| 54 | # elif defined(STM32F103xE) || defined(STM32F401xE) || defined(STM32F411xE) | 54 | # elif defined(STM32F103xE) || defined(STM32F401xE) || defined(STM32F411xE) |
| 55 | # define FEE_MCU_FLASH_SIZE 512 // Size in Kb | 55 | # define FEE_MCU_FLASH_SIZE 512 // Size in Kb |
| 56 | # elif defined(STM32F405xG) | 56 | # elif defined(STM32F405xG) |
| 57 | # define FEE_MCU_FLASH_SIZE 1024 // Size in Kb | 57 | # define FEE_MCU_FLASH_SIZE 1024 // Size in Kb |
| 58 | # endif | 58 | # endif |
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| @@ -62,7 +62,7 @@ | |||
| 62 | #if !defined(FEE_PAGE_BASE_ADDRESS) | 62 | #if !defined(FEE_PAGE_BASE_ADDRESS) |
| 63 | # if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) | 63 | # if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) |
| 64 | # ifndef FEE_PAGE_BASE_ADDRESS | 64 | # ifndef FEE_PAGE_BASE_ADDRESS |
| 65 | # define FEE_PAGE_BASE_ADDRESS 0x08004000 // bodge to force 2nd 16k page | 65 | # define FEE_PAGE_BASE_ADDRESS 0x08004000 // bodge to force 2nd 16k page |
| 66 | # endif | 66 | # endif |
| 67 | # else | 67 | # else |
| 68 | # ifndef FEE_FLASH_BASE | 68 | # ifndef FEE_FLASH_BASE |
diff --git a/platforms/chibios/eeprom_teensy.c b/platforms/chibios/eeprom_teensy.c index 575f51526e..c8777febde 100644 --- a/platforms/chibios/eeprom_teensy.c +++ b/platforms/chibios/eeprom_teensy.c | |||
| @@ -60,19 +60,19 @@ | |||
| 60 | 60 | ||
| 61 | // Minimum EEPROM Endurance | 61 | // Minimum EEPROM Endurance |
| 62 | // ------------------------ | 62 | // ------------------------ |
| 63 | # if (EEPROM_SIZE == 2048) // 35000 writes/byte or 70000 writes/word | 63 | # if (EEPROM_SIZE == 2048) // 35000 writes/byte or 70000 writes/word |
| 64 | # define EEESIZE 0x33 | 64 | # define EEESIZE 0x33 |
| 65 | # elif (EEPROM_SIZE == 1024) // 75000 writes/byte or 150000 writes/word | 65 | # elif (EEPROM_SIZE == 1024) // 75000 writes/byte or 150000 writes/word |
| 66 | # define EEESIZE 0x34 | 66 | # define EEESIZE 0x34 |
| 67 | # elif (EEPROM_SIZE == 512) // 155000 writes/byte or 310000 writes/word | 67 | # elif (EEPROM_SIZE == 512) // 155000 writes/byte or 310000 writes/word |
| 68 | # define EEESIZE 0x35 | 68 | # define EEESIZE 0x35 |
| 69 | # elif (EEPROM_SIZE == 256) // 315000 writes/byte or 630000 writes/word | 69 | # elif (EEPROM_SIZE == 256) // 315000 writes/byte or 630000 writes/word |
| 70 | # define EEESIZE 0x36 | 70 | # define EEESIZE 0x36 |
| 71 | # elif (EEPROM_SIZE == 128) // 635000 writes/byte or 1270000 writes/word | 71 | # elif (EEPROM_SIZE == 128) // 635000 writes/byte or 1270000 writes/word |
| 72 | # define EEESIZE 0x37 | 72 | # define EEESIZE 0x37 |
| 73 | # elif (EEPROM_SIZE == 64) // 1275000 writes/byte or 2550000 writes/word | 73 | # elif (EEPROM_SIZE == 64) // 1275000 writes/byte or 2550000 writes/word |
| 74 | # define EEESIZE 0x38 | 74 | # define EEESIZE 0x38 |
| 75 | # elif (EEPROM_SIZE == 32) // 2555000 writes/byte or 5110000 writes/word | 75 | # elif (EEPROM_SIZE == 32) // 2555000 writes/byte or 5110000 writes/word |
| 76 | # define EEESIZE 0x39 | 76 | # define EEESIZE 0x39 |
| 77 | # endif | 77 | # endif |
| 78 | 78 | ||
| @@ -88,9 +88,9 @@ void eeprom_initialize(void) { | |||
| 88 | if (FTFL->FCNFG & FTFL_FCNFG_RAMRDY) { | 88 | if (FTFL->FCNFG & FTFL_FCNFG_RAMRDY) { |
| 89 | // FlexRAM is configured as traditional RAM | 89 | // FlexRAM is configured as traditional RAM |
| 90 | // We need to reconfigure for EEPROM usage | 90 | // We need to reconfigure for EEPROM usage |
| 91 | FTFL->FCCOB0 = 0x80; // PGMPART = Program Partition Command | 91 | FTFL->FCCOB0 = 0x80; // PGMPART = Program Partition Command |
| 92 | FTFL->FCCOB4 = EEESIZE; // EEPROM Size | 92 | FTFL->FCCOB4 = EEESIZE; // EEPROM Size |
| 93 | FTFL->FCCOB5 = 0x03; // 0K for Dataflash, 32K for EEPROM backup | 93 | FTFL->FCCOB5 = 0x03; // 0K for Dataflash, 32K for EEPROM backup |
| 94 | __disable_irq(); | 94 | __disable_irq(); |
| 95 | // do_flash_cmd() must execute from RAM. Luckily the C syntax is simple... | 95 | // do_flash_cmd() must execute from RAM. Luckily the C syntax is simple... |
| 96 | (*((void (*)(volatile uint8_t *))((uint32_t)do_flash_cmd | 1)))(&(FTFL->FSTAT)); | 96 | (*((void (*)(volatile uint8_t *))((uint32_t)do_flash_cmd | 1)))(&(FTFL->FSTAT)); |
| @@ -98,7 +98,7 @@ void eeprom_initialize(void) { | |||
| 98 | status = FTFL->FSTAT; | 98 | status = FTFL->FSTAT; |
| 99 | if (status & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL)) { | 99 | if (status & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL)) { |
| 100 | FTFL->FSTAT = (status & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL)); | 100 | FTFL->FSTAT = (status & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL)); |
| 101 | return; // error | 101 | return; // error |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | // wait for eeprom to become ready (is this really necessary?) | 104 | // wait for eeprom to become ready (is this really necessary?) |
| @@ -162,7 +162,9 @@ void eeprom_read_block(void *buf, const void *addr, uint32_t len) { | |||
| 162 | * | 162 | * |
| 163 | * FIXME: needs doc | 163 | * FIXME: needs doc |
| 164 | */ | 164 | */ |
| 165 | int eeprom_is_ready(void) { return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0; } | 165 | int eeprom_is_ready(void) { |
| 166 | return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0; | ||
| 167 | } | ||
| 166 | 168 | ||
| 167 | /** \brief flexram wait | 169 | /** \brief flexram wait |
| 168 | * | 170 | * |
| @@ -486,7 +488,9 @@ void eeprom_read_block(void *buf, const void *addr, uint32_t len) { | |||
| 486 | } | 488 | } |
| 487 | } | 489 | } |
| 488 | 490 | ||
| 489 | int eeprom_is_ready(void) { return 1; } | 491 | int eeprom_is_ready(void) { |
| 492 | return 1; | ||
| 493 | } | ||
| 490 | 494 | ||
| 491 | void eeprom_write_word(uint16_t *addr, uint16_t value) { | 495 | void eeprom_write_word(uint16_t *addr, uint16_t value) { |
| 492 | uint8_t *p = (uint8_t *)addr; | 496 | uint8_t *p = (uint8_t *)addr; |
| @@ -515,7 +519,9 @@ void eeprom_write_block(const void *buf, void *addr, uint32_t len) { | |||
| 515 | #endif /* chip selection */ | 519 | #endif /* chip selection */ |
| 516 | // The update functions just calls write for now, but could probably be optimized | 520 | // The update functions just calls write for now, but could probably be optimized |
| 517 | 521 | ||
| 518 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); } | 522 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { |
| 523 | eeprom_write_byte(addr, value); | ||
| 524 | } | ||
| 519 | 525 | ||
| 520 | void eeprom_update_word(uint16_t *addr, uint16_t value) { | 526 | void eeprom_update_word(uint16_t *addr, uint16_t value) { |
| 521 | uint8_t *p = (uint8_t *)addr; | 527 | uint8_t *p = (uint8_t *)addr; |
diff --git a/platforms/chibios/gd32v_compatibility.h b/platforms/chibios/gd32v_compatibility.h index f4dcfd8c55..a3148fb6d2 100644 --- a/platforms/chibios/gd32v_compatibility.h +++ b/platforms/chibios/gd32v_compatibility.h | |||
| @@ -97,10 +97,10 @@ | |||
| 97 | /* Serial USART redefines. */ | 97 | /* Serial USART redefines. */ |
| 98 | #if HAL_USE_SERIAL | 98 | #if HAL_USE_SERIAL |
| 99 | # if !defined(SERIAL_USART_CR1) | 99 | # if !defined(SERIAL_USART_CR1) |
| 100 | # define SERIAL_USART_CR1 (USART_CTL0_PCEN | USART_CTL0_PM | USART_CTL0_WL) // parity enable, odd parity, 9 bit length | 100 | # define SERIAL_USART_CR1 (USART_CTL0_PCEN | USART_CTL0_PM | USART_CTL0_WL) // parity enable, odd parity, 9 bit length |
| 101 | # endif | 101 | # endif |
| 102 | # if !defined(SERIAL_USART_CR2) | 102 | # if !defined(SERIAL_USART_CR2) |
| 103 | # define SERIAL_USART_CR2 (USART_CTL1_STB_1) // 2 stop bits | 103 | # define SERIAL_USART_CR2 (USART_CTL1_STB_1) // 2 stop bits |
| 104 | # endif | 104 | # endif |
| 105 | # if !defined(SERIAL_USART_CR3) | 105 | # if !defined(SERIAL_USART_CR3) |
| 106 | # define SERIAL_USART_CR3 0x0 | 106 | # define SERIAL_USART_CR3 0x0 |
diff --git a/platforms/chibios/sleep_led.c b/platforms/chibios/sleep_led.c index 477056a454..a777d60468 100644 --- a/platforms/chibios/sleep_led.c +++ b/platforms/chibios/sleep_led.c | |||
| @@ -93,7 +93,7 @@ void sleep_led_init(void) { | |||
| 93 | /* Reset LPTMR settings */ | 93 | /* Reset LPTMR settings */ |
| 94 | LPTMR0->CSR = 0; | 94 | LPTMR0->CSR = 0; |
| 95 | /* Set the compare value */ | 95 | /* Set the compare value */ |
| 96 | LPTMR0->CMR = 0; // trigger on counter value (i.e. every time) | 96 | LPTMR0->CMR = 0; // trigger on counter value (i.e. every time) |
| 97 | 97 | ||
| 98 | /* Set up clock source and prescaler */ | 98 | /* Set up clock source and prescaler */ |
| 99 | /* Software PWM | 99 | /* Software PWM |
| @@ -118,11 +118,11 @@ void sleep_led_init(void) { | |||
| 118 | /* === OPTION 2 === */ | 118 | /* === OPTION 2 === */ |
| 119 | # if 1 | 119 | # if 1 |
| 120 | // nMHz IRC (n=4 on KL25Z, KL26Z and K20x; n=2 or 8 on KL27Z) | 120 | // nMHz IRC (n=4 on KL25Z, KL26Z and K20x; n=2 or 8 on KL27Z) |
| 121 | MCG->C2 |= MCG_C2_IRCS; // fast (4MHz) internal ref clock | 121 | MCG->C2 |= MCG_C2_IRCS; // fast (4MHz) internal ref clock |
| 122 | # if defined(KL27) // divide the 8MHz IRC by 2, to have the same MCGIRCLK speed as others | 122 | # if defined(KL27) // divide the 8MHz IRC by 2, to have the same MCGIRCLK speed as others |
| 123 | MCG->MC |= MCG_MC_LIRC_DIV2_DIV2; | 123 | MCG->MC |= MCG_MC_LIRC_DIV2_DIV2; |
| 124 | # endif /* KL27 */ | 124 | # endif /* KL27 */ |
| 125 | MCG->C1 |= MCG_C1_IRCLKEN; // enable internal ref clock | 125 | MCG->C1 |= MCG_C1_IRCLKEN; // enable internal ref clock |
| 126 | // to work in stop mode, also MCG_C1_IREFSTEN | 126 | // to work in stop mode, also MCG_C1_IREFSTEN |
| 127 | // Divide 4MHz by 2^N (N=6) => 62500 irqs/sec => | 127 | // Divide 4MHz by 2^N (N=6) => 62500 irqs/sec => |
| 128 | // => approx F=61, R=256, duration = 4 | 128 | // => approx F=61, R=256, duration = 4 |
| @@ -140,7 +140,7 @@ void sleep_led_init(void) { | |||
| 140 | /* === END OPTIONS === */ | 140 | /* === END OPTIONS === */ |
| 141 | 141 | ||
| 142 | /* Interrupt on TCF set (compare flag) */ | 142 | /* Interrupt on TCF set (compare flag) */ |
| 143 | nvicEnableVector(LPTMR0_IRQn, 2); // vector, priority | 143 | nvicEnableVector(LPTMR0_IRQn, 2); // vector, priority |
| 144 | LPTMR0->CSR |= LPTMRx_CSR_TIE; | 144 | LPTMR0->CSR |= LPTMRx_CSR_TIE; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| @@ -169,21 +169,33 @@ static void gptTimerCallback(GPTDriver *gptp) { | |||
| 169 | static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0}; | 169 | static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0}; |
| 170 | 170 | ||
| 171 | /* Initialise the timer */ | 171 | /* Initialise the timer */ |
| 172 | void sleep_led_init(void) { gptStart(&SLEEP_LED_GPT_DRIVER, &gptcfg); } | 172 | void sleep_led_init(void) { |
| 173 | gptStart(&SLEEP_LED_GPT_DRIVER, &gptcfg); | ||
| 174 | } | ||
| 173 | 175 | ||
| 174 | void sleep_led_enable(void) { gptStartContinuous(&SLEEP_LED_GPT_DRIVER, gptcfg.frequency / 0xFFFF); } | 176 | void sleep_led_enable(void) { |
| 177 | gptStartContinuous(&SLEEP_LED_GPT_DRIVER, gptcfg.frequency / 0xFFFF); | ||
| 178 | } | ||
| 175 | 179 | ||
| 176 | void sleep_led_disable(void) { gptStopTimer(&SLEEP_LED_GPT_DRIVER); } | 180 | void sleep_led_disable(void) { |
| 181 | gptStopTimer(&SLEEP_LED_GPT_DRIVER); | ||
| 182 | } | ||
| 177 | 183 | ||
| 178 | void sleep_led_toggle(void) { (SLEEP_LED_GPT_DRIVER.state == GPT_READY) ? sleep_led_enable() : sleep_led_disable(); } | 184 | void sleep_led_toggle(void) { |
| 185 | (SLEEP_LED_GPT_DRIVER.state == GPT_READY) ? sleep_led_enable() : sleep_led_disable(); | ||
| 186 | } | ||
| 179 | 187 | ||
| 180 | #else /* platform selection: not on familiar chips */ | 188 | #else /* platform selection: not on familiar chips */ |
| 181 | 189 | ||
| 182 | void sleep_led_init(void) {} | 190 | void sleep_led_init(void) {} |
| 183 | 191 | ||
| 184 | void sleep_led_enable(void) { led_set(1 << USB_LED_CAPS_LOCK); } | 192 | void sleep_led_enable(void) { |
| 193 | led_set(1 << USB_LED_CAPS_LOCK); | ||
| 194 | } | ||
| 185 | 195 | ||
| 186 | void sleep_led_disable(void) { led_set(0); } | 196 | void sleep_led_disable(void) { |
| 197 | led_set(0); | ||
| 198 | } | ||
| 187 | 199 | ||
| 188 | void sleep_led_toggle(void) { | 200 | void sleep_led_toggle(void) { |
| 189 | // not implemented | 201 | // not implemented |
diff --git a/platforms/chibios/syscall-fallbacks.c b/platforms/chibios/syscall-fallbacks.c index 7150a46326..86f7907bfc 100644 --- a/platforms/chibios/syscall-fallbacks.c +++ b/platforms/chibios/syscall-fallbacks.c | |||
| @@ -87,9 +87,13 @@ __attribute__((weak, used)) int _kill(int pid, int sig) { | |||
| 87 | return -1; | 87 | return -1; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | __attribute__((weak, used)) pid_t _getpid(void) { return 1; } | 90 | __attribute__((weak, used)) pid_t _getpid(void) { |
| 91 | return 1; | ||
| 92 | } | ||
| 91 | 93 | ||
| 92 | __attribute__((weak, used)) void _fini(void) { return; } | 94 | __attribute__((weak, used)) void _fini(void) { |
| 95 | return; | ||
| 96 | } | ||
| 93 | 97 | ||
| 94 | __attribute__((weak, used, noreturn)) void _exit(int i) { | 98 | __attribute__((weak, used, noreturn)) void _exit(int i) { |
| 95 | while (1) | 99 | while (1) |
diff --git a/platforms/chibios/timer.c b/platforms/chibios/timer.c index 74fdd7a6fc..e3bdfdcc37 100644 --- a/platforms/chibios/timer.c +++ b/platforms/chibios/timer.c | |||
| @@ -73,7 +73,9 @@ void timer_clear(void) { | |||
| 73 | chSysUnlock(); | 73 | chSysUnlock(); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | uint16_t timer_read(void) { return (uint16_t)timer_read32(); } | 76 | uint16_t timer_read(void) { |
| 77 | return (uint16_t)timer_read32(); | ||
| 78 | } | ||
| 77 | 79 | ||
| 78 | uint32_t timer_read32(void) { | 80 | uint32_t timer_read32(void) { |
| 79 | chSysLock(); | 81 | chSysLock(); |
| @@ -90,12 +92,16 @@ uint32_t timer_read32(void) { | |||
| 90 | ms_offset += OVERFLOW_ADJUST_MS; | 92 | ms_offset += OVERFLOW_ADJUST_MS; |
| 91 | } | 93 | } |
| 92 | last_ticks = ticks; | 94 | last_ticks = ticks; |
| 93 | uint32_t ms_offset_copy = ms_offset; // read while still holding the lock to ensure a consistent value | 95 | uint32_t ms_offset_copy = ms_offset; // read while still holding the lock to ensure a consistent value |
| 94 | chSysUnlock(); | 96 | chSysUnlock(); |
| 95 | 97 | ||
| 96 | return (uint32_t)TIME_I2MS(ticks) + ms_offset_copy; | 98 | return (uint32_t)TIME_I2MS(ticks) + ms_offset_copy; |
| 97 | } | 99 | } |
| 98 | 100 | ||
| 99 | uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } | 101 | uint16_t timer_elapsed(uint16_t last) { |
| 102 | return TIMER_DIFF_16(timer_read(), last); | ||
| 103 | } | ||
| 100 | 104 | ||
| 101 | uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); } | 105 | uint32_t timer_elapsed32(uint32_t last) { |
| 106 | return TIMER_DIFF_32(timer_read32(), last); | ||
| 107 | } | ||
diff --git a/platforms/suspend.c b/platforms/suspend.c index cd773764fa..fea23cbd02 100644 --- a/platforms/suspend.c +++ b/platforms/suspend.c | |||
| @@ -18,7 +18,9 @@ __attribute__((weak)) void suspend_power_down_user(void) {} | |||
| 18 | * | 18 | * |
| 19 | * FIXME: needs doc | 19 | * FIXME: needs doc |
| 20 | */ | 20 | */ |
| 21 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | 21 | __attribute__((weak)) void suspend_power_down_kb(void) { |
| 22 | suspend_power_down_user(); | ||
| 23 | } | ||
| 22 | 24 | ||
| 23 | /** \brief run user level code immediately after wakeup | 25 | /** \brief run user level code immediately after wakeup |
| 24 | * | 26 | * |
| @@ -30,7 +32,9 @@ __attribute__((weak)) void suspend_wakeup_init_user(void) {} | |||
| 30 | * | 32 | * |
| 31 | * FIXME: needs doc | 33 | * FIXME: needs doc |
| 32 | */ | 34 | */ |
| 33 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } | 35 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { |
| 36 | suspend_wakeup_init_user(); | ||
| 37 | } | ||
| 34 | 38 | ||
| 35 | /** \brief suspend wakeup condition | 39 | /** \brief suspend wakeup condition |
| 36 | * | 40 | * |
diff --git a/platforms/test/eeprom.c b/platforms/test/eeprom.c index e292faa644..d501745e55 100644 --- a/platforms/test/eeprom.c +++ b/platforms/test/eeprom.c | |||
| @@ -68,7 +68,9 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); } | 71 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { |
| 72 | eeprom_write_byte(addr, value); | ||
| 73 | } | ||
| 72 | 74 | ||
| 73 | void eeprom_update_word(uint16_t *addr, uint16_t value) { | 75 | void eeprom_update_word(uint16_t *addr, uint16_t value) { |
| 74 | uint8_t *p = (uint8_t *)addr; | 76 | uint8_t *p = (uint8_t *)addr; |
diff --git a/platforms/test/eeprom_stm32_tests.cpp b/platforms/test/eeprom_stm32_tests.cpp index 57f31d634f..d2c41fb77d 100644 --- a/platforms/test/eeprom_stm32_tests.cpp +++ b/platforms/test/eeprom_stm32_tests.cpp | |||
| @@ -60,7 +60,9 @@ class EepromStm32Test : public testing::Test { | |||
| 60 | ~EepromStm32Test() {} | 60 | ~EepromStm32Test() {} |
| 61 | 61 | ||
| 62 | protected: | 62 | protected: |
| 63 | void SetUp() override { EEPROM_Erase(); } | 63 | void SetUp() override { |
| 64 | EEPROM_Erase(); | ||
| 65 | } | ||
| 64 | 66 | ||
| 65 | void TearDown() override { | 67 | void TearDown() override { |
| 66 | #ifdef EEPROM_DEBUG | 68 | #ifdef EEPROM_DEBUG |
| @@ -83,7 +85,7 @@ TEST_F(EepromStm32Test, TestReadGarbage) { | |||
| 83 | garbage += i; | 85 | garbage += i; |
| 84 | FlashBuf[i] = garbage; | 86 | FlashBuf[i] = garbage; |
| 85 | } | 87 | } |
| 86 | EEPROM_Init(); // Just verify we don't crash | 88 | EEPROM_Init(); // Just verify we don't crash |
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | TEST_F(EepromStm32Test, TestWriteBadAddress) { | 91 | TEST_F(EepromStm32Test, TestWriteBadAddress) { |
| @@ -206,11 +208,11 @@ TEST_F(EepromStm32Test, TestReadWord) { | |||
| 206 | 208 | ||
| 207 | TEST_F(EepromStm32Test, TestWriteWord) { | 209 | TEST_F(EepromStm32Test, TestWriteWord) { |
| 208 | /* Direct compacted-area: Address < 0x80 */ | 210 | /* Direct compacted-area: Address < 0x80 */ |
| 209 | EEPROM_WriteDataWord(0, 0xdead); // Aligned | 211 | EEPROM_WriteDataWord(0, 0xdead); // Aligned |
| 210 | EEPROM_WriteDataWord(3, 0xbeef); // Unaligned | 212 | EEPROM_WriteDataWord(3, 0xbeef); // Unaligned |
| 211 | /* Direct compacted-area: Address >= 0x80 */ | 213 | /* Direct compacted-area: Address >= 0x80 */ |
| 212 | EEPROM_WriteDataWord(200, 0xabcd); // Aligned | 214 | EEPROM_WriteDataWord(200, 0xabcd); // Aligned |
| 213 | EEPROM_WriteDataWord(203, 0x9876); // Unaligned | 215 | EEPROM_WriteDataWord(203, 0x9876); // Unaligned |
| 214 | EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234); | 216 | EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234); |
| 215 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678); | 217 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678); |
| 216 | /* Write Log word zero-encoded */ | 218 | /* Write Log word zero-encoded */ |
| @@ -218,10 +220,10 @@ TEST_F(EepromStm32Test, TestWriteWord) { | |||
| 218 | /* Write Log word one-encoded */ | 220 | /* Write Log word one-encoded */ |
| 219 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1); | 221 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1); |
| 220 | /* Write Log word value aligned */ | 222 | /* Write Log word value aligned */ |
| 221 | EEPROM_WriteDataWord(200, 0x4321); // Aligned | 223 | EEPROM_WriteDataWord(200, 0x4321); // Aligned |
| 222 | /* Write Log word value unaligned */ | 224 | /* Write Log word value unaligned */ |
| 223 | EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte | 225 | EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte |
| 224 | EEPROM_WriteDataWord(203, 0xcdef); // Unaligned | 226 | EEPROM_WriteDataWord(203, 0xcdef); // Unaligned |
| 225 | /* Check values */ | 227 | /* Check values */ |
| 226 | /* Direct compacted-area */ | 228 | /* Direct compacted-area */ |
| 227 | EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE], (uint16_t)~0xdead); | 229 | EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE], (uint16_t)~0xdead); |
| @@ -249,11 +251,11 @@ TEST_F(EepromStm32Test, TestWriteWord) { | |||
| 249 | 251 | ||
| 250 | TEST_F(EepromStm32Test, TestWordRoundTrip) { | 252 | TEST_F(EepromStm32Test, TestWordRoundTrip) { |
| 251 | /* Direct compacted-area: Address < 0x80 */ | 253 | /* Direct compacted-area: Address < 0x80 */ |
| 252 | EEPROM_WriteDataWord(0, 0xdead); // Aligned | 254 | EEPROM_WriteDataWord(0, 0xdead); // Aligned |
| 253 | EEPROM_WriteDataWord(3, 0xbeef); // Unaligned | 255 | EEPROM_WriteDataWord(3, 0xbeef); // Unaligned |
| 254 | /* Direct compacted-area: Address >= 0x80 */ | 256 | /* Direct compacted-area: Address >= 0x80 */ |
| 255 | EEPROM_WriteDataWord(200, 0xabcd); // Aligned | 257 | EEPROM_WriteDataWord(200, 0xabcd); // Aligned |
| 256 | EEPROM_WriteDataWord(203, 0x9876); // Unaligned | 258 | EEPROM_WriteDataWord(203, 0x9876); // Unaligned |
| 257 | EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234); | 259 | EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234); |
| 258 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678); | 260 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678); |
| 259 | /* Check values */ | 261 | /* Check values */ |
| @@ -270,10 +272,10 @@ TEST_F(EepromStm32Test, TestWordRoundTrip) { | |||
| 270 | /* Write Log word one-encoded */ | 272 | /* Write Log word one-encoded */ |
| 271 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1); | 273 | EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1); |
| 272 | /* Write Log word value aligned */ | 274 | /* Write Log word value aligned */ |
| 273 | EEPROM_WriteDataWord(200, 0x4321); // Aligned | 275 | EEPROM_WriteDataWord(200, 0x4321); // Aligned |
| 274 | /* Write Log word value unaligned */ | 276 | /* Write Log word value unaligned */ |
| 275 | EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte | 277 | EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte |
| 276 | EEPROM_WriteDataWord(203, 0xcdef); // Unaligned | 278 | EEPROM_WriteDataWord(203, 0xcdef); // Unaligned |
| 277 | /* Check values */ | 279 | /* Check values */ |
| 278 | EEPROM_Init(); | 280 | EEPROM_Init(); |
| 279 | EXPECT_EQ(EEPROM_ReadDataWord(200), 0x4321); | 281 | EXPECT_EQ(EEPROM_ReadDataWord(200), 0x4321); |
| @@ -324,34 +326,34 @@ TEST_F(EepromStm32Test, TestByteWordBoundary) { | |||
| 324 | 326 | ||
| 325 | TEST_F(EepromStm32Test, TestDWordRoundTrip) { | 327 | TEST_F(EepromStm32Test, TestDWordRoundTrip) { |
| 326 | /* Direct compacted-area: Address < 0x80 */ | 328 | /* Direct compacted-area: Address < 0x80 */ |
| 327 | eeprom_write_dword((uint32_t*)0, 0xdeadbeef); // Aligned | 329 | eeprom_write_dword((uint32_t*)0, 0xdeadbeef); // Aligned |
| 328 | eeprom_write_dword((uint32_t*)9, 0x12345678); // Unaligned | 330 | eeprom_write_dword((uint32_t*)9, 0x12345678); // Unaligned |
| 329 | /* Direct compacted-area: Address >= 0x80 */ | 331 | /* Direct compacted-area: Address >= 0x80 */ |
| 330 | eeprom_write_dword((uint32_t*)200, 0xfacef00d); | 332 | eeprom_write_dword((uint32_t*)200, 0xfacef00d); |
| 331 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xba5eba11); // Aligned | 333 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xba5eba11); // Aligned |
| 332 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0xcafed00d); // Unaligned | 334 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0xcafed00d); // Unaligned |
| 333 | /* Check direct values */ | 335 | /* Check direct values */ |
| 334 | EEPROM_Init(); | 336 | EEPROM_Init(); |
| 335 | EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdeadbeef); | 337 | EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdeadbeef); |
| 336 | EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x12345678); | 338 | EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x12345678); |
| 337 | EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 0xfacef00d); | 339 | EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 0xfacef00d); |
| 338 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xba5eba11); // Aligned | 340 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xba5eba11); // Aligned |
| 339 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0xcafed00d); // Unaligned | 341 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0xcafed00d); // Unaligned |
| 340 | /* Write Log byte encoded */ | 342 | /* Write Log byte encoded */ |
| 341 | eeprom_write_dword((uint32_t*)0, 0xdecafbad); | 343 | eeprom_write_dword((uint32_t*)0, 0xdecafbad); |
| 342 | eeprom_write_dword((uint32_t*)9, 0x87654321); | 344 | eeprom_write_dword((uint32_t*)9, 0x87654321); |
| 343 | /* Write Log word encoded */ | 345 | /* Write Log word encoded */ |
| 344 | eeprom_write_dword((uint32_t*)200, 1); | 346 | eeprom_write_dword((uint32_t*)200, 1); |
| 345 | /* Write Log word value aligned */ | 347 | /* Write Log word value aligned */ |
| 346 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xdeadc0de); // Aligned | 348 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xdeadc0de); // Aligned |
| 347 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0x6789abcd); // Unaligned | 349 | eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0x6789abcd); // Unaligned |
| 348 | /* Check log values */ | 350 | /* Check log values */ |
| 349 | EEPROM_Init(); | 351 | EEPROM_Init(); |
| 350 | EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdecafbad); | 352 | EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdecafbad); |
| 351 | EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x87654321); | 353 | EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x87654321); |
| 352 | EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 1); | 354 | EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 1); |
| 353 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xdeadc0de); // Aligned | 355 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xdeadc0de); // Aligned |
| 354 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0x6789abcd); // Unaligned | 356 | EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0x6789abcd); // Unaligned |
| 355 | } | 357 | } |
| 356 | 358 | ||
| 357 | TEST_F(EepromStm32Test, TestBlockRoundTrip) { | 359 | TEST_F(EepromStm32Test, TestBlockRoundTrip) { |
diff --git a/platforms/test/flash_stm32_mock.c b/platforms/test/flash_stm32_mock.c index 222a004bc7..b6ab170f95 100644 --- a/platforms/test/flash_stm32_mock.c +++ b/platforms/test/flash_stm32_mock.c | |||
| @@ -44,6 +44,12 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) { | |||
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) { return FLASH_COMPLETE; } | 47 | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) { |
| 48 | void FLASH_Unlock(void) { flash_locked = false; } | 48 | return FLASH_COMPLETE; |
| 49 | void FLASH_Lock(void) { flash_locked = true; } | 49 | } |
| 50 | void FLASH_Unlock(void) { | ||
| 51 | flash_locked = false; | ||
| 52 | } | ||
| 53 | void FLASH_Lock(void) { | ||
| 54 | flash_locked = true; | ||
| 55 | } | ||
diff --git a/platforms/test/timer.c b/platforms/test/timer.c index 61c3a00201..e0acd1b16d 100644 --- a/platforms/test/timer.c +++ b/platforms/test/timer.c | |||
| @@ -18,16 +18,34 @@ | |||
| 18 | 18 | ||
| 19 | static uint32_t current_time = 0; | 19 | static uint32_t current_time = 0; |
| 20 | 20 | ||
| 21 | void timer_init(void) { current_time = 0; } | 21 | void timer_init(void) { |
| 22 | current_time = 0; | ||
| 23 | } | ||
| 22 | 24 | ||
| 23 | void timer_clear(void) { current_time = 0; } | 25 | void timer_clear(void) { |
| 26 | current_time = 0; | ||
| 27 | } | ||
| 24 | 28 | ||
| 25 | uint16_t timer_read(void) { return current_time & 0xFFFF; } | 29 | uint16_t timer_read(void) { |
| 26 | uint32_t timer_read32(void) { return current_time; } | 30 | return current_time & 0xFFFF; |
| 27 | uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } | 31 | } |
| 28 | uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); } | 32 | uint32_t timer_read32(void) { |
| 33 | return current_time; | ||
| 34 | } | ||
| 35 | uint16_t timer_elapsed(uint16_t last) { | ||
| 36 | return TIMER_DIFF_16(timer_read(), last); | ||
| 37 | } | ||
| 38 | uint32_t timer_elapsed32(uint32_t last) { | ||
| 39 | return TIMER_DIFF_32(timer_read32(), last); | ||
| 40 | } | ||
| 29 | 41 | ||
| 30 | void set_time(uint32_t t) { current_time = t; } | 42 | void set_time(uint32_t t) { |
| 31 | void advance_time(uint32_t ms) { current_time += ms; } | 43 | current_time = t; |
| 44 | } | ||
| 45 | void advance_time(uint32_t ms) { | ||
| 46 | current_time += ms; | ||
| 47 | } | ||
| 32 | 48 | ||
| 33 | void wait_ms(uint32_t ms) { advance_time(ms); } | 49 | void wait_ms(uint32_t ms) { |
| 50 | advance_time(ms); | ||
| 51 | } | ||
diff --git a/platforms/timer.h b/platforms/timer.h index 02e39e79e7..d55f40f0b0 100644 --- a/platforms/timer.h +++ b/platforms/timer.h | |||
| @@ -52,14 +52,22 @@ uint32_t timer_elapsed32(uint32_t last); | |||
| 52 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_16(a, b) | 52 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_16(a, b) |
| 53 | # define timer_expired_fast(current, future) timer_expired(current, future) | 53 | # define timer_expired_fast(current, future) timer_expired(current, future) |
| 54 | typedef uint16_t fast_timer_t; | 54 | typedef uint16_t fast_timer_t; |
| 55 | fast_timer_t inline timer_read_fast(void) { return timer_read(); } | 55 | fast_timer_t inline timer_read_fast(void) { |
| 56 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed(last); } | 56 | return timer_read(); |
| 57 | } | ||
| 58 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { | ||
| 59 | return timer_elapsed(last); | ||
| 60 | } | ||
| 57 | #else | 61 | #else |
| 58 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_32(a, b) | 62 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_32(a, b) |
| 59 | # define timer_expired_fast(current, future) timer_expired32(current, future) | 63 | # define timer_expired_fast(current, future) timer_expired32(current, future) |
| 60 | typedef uint32_t fast_timer_t; | 64 | typedef uint32_t fast_timer_t; |
| 61 | fast_timer_t inline timer_read_fast(void) { return timer_read32(); } | 65 | fast_timer_t inline timer_read_fast(void) { |
| 62 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed32(last); } | 66 | return timer_read32(); |
| 67 | } | ||
| 68 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { | ||
| 69 | return timer_elapsed32(last); | ||
| 70 | } | ||
| 63 | #endif | 71 | #endif |
| 64 | 72 | ||
| 65 | #ifdef __cplusplus | 73 | #ifdef __cplusplus |
diff --git a/quantum/action.c b/quantum/action.c index d932c01688..2bb1c34985 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
| @@ -53,14 +53,20 @@ int retro_tapping_counter = 0; | |||
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY | 55 | #ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY |
| 56 | __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; } | 56 | __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { |
| 57 | return false; | ||
| 58 | } | ||
| 57 | #endif | 59 | #endif |
| 58 | 60 | ||
| 59 | #ifdef RETRO_TAPPING_PER_KEY | 61 | #ifdef RETRO_TAPPING_PER_KEY |
| 60 | __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; } | 62 | __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { |
| 63 | return false; | ||
| 64 | } | ||
| 61 | #endif | 65 | #endif |
| 62 | 66 | ||
| 63 | __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { return true; } | 67 | __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { |
| 68 | return true; | ||
| 69 | } | ||
| 64 | 70 | ||
| 65 | /** \brief Called to execute an action. | 71 | /** \brief Called to execute an action. |
| 66 | * | 72 | * |
| @@ -163,10 +169,14 @@ void process_record_nocache(keyrecord_t *record) { | |||
| 163 | disable_action_cache = false; | 169 | disable_action_cache = false; |
| 164 | } | 170 | } |
| 165 | #else | 171 | #else |
| 166 | void process_record_nocache(keyrecord_t *record) { process_record(record); } | 172 | void process_record_nocache(keyrecord_t *record) { |
| 173 | process_record(record); | ||
| 174 | } | ||
| 167 | #endif | 175 | #endif |
| 168 | 176 | ||
| 169 | __attribute__((weak)) bool process_record_quantum(keyrecord_t *record) { return true; } | 177 | __attribute__((weak)) bool process_record_quantum(keyrecord_t *record) { |
| 178 | return true; | ||
| 179 | } | ||
| 170 | 180 | ||
| 171 | __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {} | 181 | __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {} |
| 172 | 182 | ||
| @@ -688,7 +698,7 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 688 | /* tap key */ | 698 | /* tap key */ |
| 689 | if (tap_count > 0) { | 699 | if (tap_count > 0) { |
| 690 | if (swap_held) { | 700 | if (swap_held) { |
| 691 | swap_hands = !swap_hands; // undo hold set up in _tap_hint | 701 | swap_hands = !swap_hands; // undo hold set up in _tap_hint |
| 692 | swap_held = false; | 702 | swap_held = false; |
| 693 | } | 703 | } |
| 694 | if (event.pressed) { | 704 | if (event.pressed) { |
| @@ -696,11 +706,11 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 696 | } else { | 706 | } else { |
| 697 | wait_ms(TAP_CODE_DELAY); | 707 | wait_ms(TAP_CODE_DELAY); |
| 698 | unregister_code(action.swap.code); | 708 | unregister_code(action.swap.code); |
| 699 | *record = (keyrecord_t){}; // hack: reset tap mode | 709 | *record = (keyrecord_t){}; // hack: reset tap mode |
| 700 | } | 710 | } |
| 701 | } else { | 711 | } else { |
| 702 | if (swap_held && !event.pressed) { | 712 | if (swap_held && !event.pressed) { |
| 703 | swap_hands = !swap_hands; // undo hold set up in _tap_hint | 713 | swap_hands = !swap_hands; // undo hold set up in _tap_hint |
| 704 | swap_held = false; | 714 | swap_held = false; |
| 705 | } | 715 | } |
| 706 | } | 716 | } |
| @@ -862,9 +872,13 @@ __attribute__((weak)) void register_code(uint8_t code) { | |||
| 862 | } | 872 | } |
| 863 | #ifdef EXTRAKEY_ENABLE | 873 | #ifdef EXTRAKEY_ENABLE |
| 864 | else if | 874 | else if |
| 865 | IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); } | 875 | IS_SYSTEM(code) { |
| 876 | host_system_send(KEYCODE2SYSTEM(code)); | ||
| 877 | } | ||
| 866 | else if | 878 | else if |
| 867 | IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); } | 879 | IS_CONSUMER(code) { |
| 880 | host_consumer_send(KEYCODE2CONSUMER(code)); | ||
| 881 | } | ||
| 868 | #endif | 882 | #endif |
| 869 | #ifdef MOUSEKEY_ENABLE | 883 | #ifdef MOUSEKEY_ENABLE |
| 870 | else if | 884 | else if |
| @@ -927,9 +941,13 @@ __attribute__((weak)) void unregister_code(uint8_t code) { | |||
| 927 | send_keyboard_report(); | 941 | send_keyboard_report(); |
| 928 | } | 942 | } |
| 929 | else if | 943 | else if |
| 930 | IS_SYSTEM(code) { host_system_send(0); } | 944 | IS_SYSTEM(code) { |
| 945 | host_system_send(0); | ||
| 946 | } | ||
| 931 | else if | 947 | else if |
| 932 | IS_CONSUMER(code) { host_consumer_send(0); } | 948 | IS_CONSUMER(code) { |
| 949 | host_consumer_send(0); | ||
| 950 | } | ||
| 933 | #ifdef MOUSEKEY_ENABLE | 951 | #ifdef MOUSEKEY_ENABLE |
| 934 | else if | 952 | else if |
| 935 | IS_MOUSEKEY(code) { | 953 | IS_MOUSEKEY(code) { |
| @@ -956,7 +974,9 @@ __attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) { | |||
| 956 | * | 974 | * |
| 957 | * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined. | 975 | * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined. |
| 958 | */ | 976 | */ |
| 959 | __attribute__((weak)) void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); } | 977 | __attribute__((weak)) void tap_code(uint8_t code) { |
| 978 | tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); | ||
| 979 | } | ||
| 960 | 980 | ||
| 961 | /** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately. | 981 | /** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately. |
| 962 | * | 982 | * |
| @@ -1100,7 +1120,9 @@ bool is_tap_action(action_t action) { | |||
| 1100 | * | 1120 | * |
| 1101 | * FIXME: Needs documentation. | 1121 | * FIXME: Needs documentation. |
| 1102 | */ | 1122 | */ |
| 1103 | void debug_event(keyevent_t event) { dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); } | 1123 | void debug_event(keyevent_t event) { |
| 1124 | dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); | ||
| 1125 | } | ||
| 1104 | /** \brief Debug print (FIXME: Needs better description) | 1126 | /** \brief Debug print (FIXME: Needs better description) |
| 1105 | * | 1127 | * |
| 1106 | * FIXME: Needs documentation. | 1128 | * FIXME: Needs documentation. |
diff --git a/quantum/action_layer.c b/quantum/action_layer.c index ed1a4bd20d..e20eedee40 100644 --- a/quantum/action_layer.c +++ b/quantum/action_layer.c | |||
| @@ -18,13 +18,17 @@ layer_state_t default_layer_state = 0; | |||
| 18 | * | 18 | * |
| 19 | * Run user code on default layer state change | 19 | * Run user code on default layer state change |
| 20 | */ | 20 | */ |
| 21 | __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) { return state; } | 21 | __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) { |
| 22 | return state; | ||
| 23 | } | ||
| 22 | 24 | ||
| 23 | /** \brief Default Layer State Set At Keyboard Level | 25 | /** \brief Default Layer State Set At Keyboard Level |
| 24 | * | 26 | * |
| 25 | * Run keyboard code on default layer state change | 27 | * Run keyboard code on default layer state change |
| 26 | */ | 28 | */ |
| 27 | __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) { return default_layer_state_set_user(state); } | 29 | __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) { |
| 30 | return default_layer_state_set_user(state); | ||
| 31 | } | ||
| 28 | 32 | ||
| 29 | /** \brief Default Layer State Set | 33 | /** \brief Default Layer State Set |
| 30 | * | 34 | * |
| @@ -39,9 +43,9 @@ static void default_layer_state_set(layer_state_t state) { | |||
| 39 | default_layer_debug(); | 43 | default_layer_debug(); |
| 40 | debug("\n"); | 44 | debug("\n"); |
| 41 | #ifdef STRICT_LAYER_RELEASE | 45 | #ifdef STRICT_LAYER_RELEASE |
| 42 | clear_keyboard_but_mods(); // To avoid stuck keys | 46 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 43 | #else | 47 | #else |
| 44 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys | 48 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys |
| 45 | #endif | 49 | #endif |
| 46 | } | 50 | } |
| 47 | 51 | ||
| @@ -49,30 +53,40 @@ static void default_layer_state_set(layer_state_t state) { | |||
| 49 | * | 53 | * |
| 50 | * Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit. | 54 | * Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit. |
| 51 | */ | 55 | */ |
| 52 | void default_layer_debug(void) { dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state)); } | 56 | void default_layer_debug(void) { |
| 57 | dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state)); | ||
| 58 | } | ||
| 53 | 59 | ||
| 54 | /** \brief Default Layer Set | 60 | /** \brief Default Layer Set |
| 55 | * | 61 | * |
| 56 | * Sets the default layer state. | 62 | * Sets the default layer state. |
| 57 | */ | 63 | */ |
| 58 | void default_layer_set(layer_state_t state) { default_layer_state_set(state); } | 64 | void default_layer_set(layer_state_t state) { |
| 65 | default_layer_state_set(state); | ||
| 66 | } | ||
| 59 | 67 | ||
| 60 | #ifndef NO_ACTION_LAYER | 68 | #ifndef NO_ACTION_LAYER |
| 61 | /** \brief Default Layer Or | 69 | /** \brief Default Layer Or |
| 62 | * | 70 | * |
| 63 | * Turns on the default layer based on matching bits between specifed layer and existing layer state | 71 | * Turns on the default layer based on matching bits between specifed layer and existing layer state |
| 64 | */ | 72 | */ |
| 65 | void default_layer_or(layer_state_t state) { default_layer_state_set(default_layer_state | state); } | 73 | void default_layer_or(layer_state_t state) { |
| 74 | default_layer_state_set(default_layer_state | state); | ||
| 75 | } | ||
| 66 | /** \brief Default Layer And | 76 | /** \brief Default Layer And |
| 67 | * | 77 | * |
| 68 | * Turns on default layer based on matching enabled bits between specifed layer and existing layer state | 78 | * Turns on default layer based on matching enabled bits between specifed layer and existing layer state |
| 69 | */ | 79 | */ |
| 70 | void default_layer_and(layer_state_t state) { default_layer_state_set(default_layer_state & state); } | 80 | void default_layer_and(layer_state_t state) { |
| 81 | default_layer_state_set(default_layer_state & state); | ||
| 82 | } | ||
| 71 | /** \brief Default Layer Xor | 83 | /** \brief Default Layer Xor |
| 72 | * | 84 | * |
| 73 | * Turns on default layer based on non-matching bits between specifed layer and existing layer state | 85 | * Turns on default layer based on non-matching bits between specifed layer and existing layer state |
| 74 | */ | 86 | */ |
| 75 | void default_layer_xor(layer_state_t state) { default_layer_state_set(default_layer_state ^ state); } | 87 | void default_layer_xor(layer_state_t state) { |
| 88 | default_layer_state_set(default_layer_state ^ state); | ||
| 89 | } | ||
| 76 | #endif | 90 | #endif |
| 77 | 91 | ||
| 78 | #ifndef NO_ACTION_LAYER | 92 | #ifndef NO_ACTION_LAYER |
| @@ -84,13 +98,17 @@ layer_state_t layer_state = 0; | |||
| 84 | * | 98 | * |
| 85 | * Runs user code on layer state change | 99 | * Runs user code on layer state change |
| 86 | */ | 100 | */ |
| 87 | __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { return state; } | 101 | __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { |
| 102 | return state; | ||
| 103 | } | ||
| 88 | 104 | ||
| 89 | /** \brief Layer state set keyboard | 105 | /** \brief Layer state set keyboard |
| 90 | * | 106 | * |
| 91 | * Runs keyboard code on layer state change | 107 | * Runs keyboard code on layer state change |
| 92 | */ | 108 | */ |
| 93 | __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { return layer_state_set_user(state); } | 109 | __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { |
| 110 | return layer_state_set_user(state); | ||
| 111 | } | ||
| 94 | 112 | ||
| 95 | /** \brief Layer state set | 113 | /** \brief Layer state set |
| 96 | * | 114 | * |
| @@ -105,9 +123,9 @@ void layer_state_set(layer_state_t state) { | |||
| 105 | layer_debug(); | 123 | layer_debug(); |
| 106 | dprintln(); | 124 | dprintln(); |
| 107 | # ifdef STRICT_LAYER_RELEASE | 125 | # ifdef STRICT_LAYER_RELEASE |
| 108 | clear_keyboard_but_mods(); // To avoid stuck keys | 126 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 109 | # else | 127 | # else |
| 110 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys | 128 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys |
| 111 | # endif | 129 | # endif |
| 112 | } | 130 | } |
| 113 | 131 | ||
| @@ -115,13 +133,17 @@ void layer_state_set(layer_state_t state) { | |||
| 115 | * | 133 | * |
| 116 | * Turn off all layers | 134 | * Turn off all layers |
| 117 | */ | 135 | */ |
| 118 | void layer_clear(void) { layer_state_set(0); } | 136 | void layer_clear(void) { |
| 137 | layer_state_set(0); | ||
| 138 | } | ||
| 119 | 139 | ||
| 120 | /** \brief Layer state is | 140 | /** \brief Layer state is |
| 121 | * | 141 | * |
| 122 | * Return whether the given state is on (it might still be shadowed by a higher state, though) | 142 | * Return whether the given state is on (it might still be shadowed by a higher state, though) |
| 123 | */ | 143 | */ |
| 124 | bool layer_state_is(uint8_t layer) { return layer_state_cmp(layer_state, layer); } | 144 | bool layer_state_is(uint8_t layer) { |
| 145 | return layer_state_cmp(layer_state, layer); | ||
| 146 | } | ||
| 125 | 147 | ||
| 126 | /** \brief Layer state compare | 148 | /** \brief Layer state compare |
| 127 | * | 149 | * |
| @@ -138,47 +160,63 @@ bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) { | |||
| 138 | * | 160 | * |
| 139 | * Turns on the given layer and turn off all other layers | 161 | * Turns on the given layer and turn off all other layers |
| 140 | */ | 162 | */ |
| 141 | void layer_move(uint8_t layer) { layer_state_set((layer_state_t)1 << layer); } | 163 | void layer_move(uint8_t layer) { |
| 164 | layer_state_set((layer_state_t)1 << layer); | ||
| 165 | } | ||
| 142 | 166 | ||
| 143 | /** \brief Layer on | 167 | /** \brief Layer on |
| 144 | * | 168 | * |
| 145 | * Turns on given layer | 169 | * Turns on given layer |
| 146 | */ | 170 | */ |
| 147 | void layer_on(uint8_t layer) { layer_state_set(layer_state | ((layer_state_t)1 << layer)); } | 171 | void layer_on(uint8_t layer) { |
| 172 | layer_state_set(layer_state | ((layer_state_t)1 << layer)); | ||
| 173 | } | ||
| 148 | 174 | ||
| 149 | /** \brief Layer off | 175 | /** \brief Layer off |
| 150 | * | 176 | * |
| 151 | * Turns off given layer | 177 | * Turns off given layer |
| 152 | */ | 178 | */ |
| 153 | void layer_off(uint8_t layer) { layer_state_set(layer_state & ~((layer_state_t)1 << layer)); } | 179 | void layer_off(uint8_t layer) { |
| 180 | layer_state_set(layer_state & ~((layer_state_t)1 << layer)); | ||
| 181 | } | ||
| 154 | 182 | ||
| 155 | /** \brief Layer invert | 183 | /** \brief Layer invert |
| 156 | * | 184 | * |
| 157 | * Toggle the given layer (set it if it's unset, or unset it if it's set) | 185 | * Toggle the given layer (set it if it's unset, or unset it if it's set) |
| 158 | */ | 186 | */ |
| 159 | void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); } | 187 | void layer_invert(uint8_t layer) { |
| 188 | layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); | ||
| 189 | } | ||
| 160 | 190 | ||
| 161 | /** \brief Layer or | 191 | /** \brief Layer or |
| 162 | * | 192 | * |
| 163 | * Turns on layers based on matching bits between specifed layer and existing layer state | 193 | * Turns on layers based on matching bits between specifed layer and existing layer state |
| 164 | */ | 194 | */ |
| 165 | void layer_or(layer_state_t state) { layer_state_set(layer_state | state); } | 195 | void layer_or(layer_state_t state) { |
| 196 | layer_state_set(layer_state | state); | ||
| 197 | } | ||
| 166 | /** \brief Layer and | 198 | /** \brief Layer and |
| 167 | * | 199 | * |
| 168 | * Turns on layers based on matching enabled bits between specifed layer and existing layer state | 200 | * Turns on layers based on matching enabled bits between specifed layer and existing layer state |
| 169 | */ | 201 | */ |
| 170 | void layer_and(layer_state_t state) { layer_state_set(layer_state & state); } | 202 | void layer_and(layer_state_t state) { |
| 203 | layer_state_set(layer_state & state); | ||
| 204 | } | ||
| 171 | /** \brief Layer xor | 205 | /** \brief Layer xor |
| 172 | * | 206 | * |
| 173 | * Turns on layers based on non-matching bits between specifed layer and existing layer state | 207 | * Turns on layers based on non-matching bits between specifed layer and existing layer state |
| 174 | */ | 208 | */ |
| 175 | void layer_xor(layer_state_t state) { layer_state_set(layer_state ^ state); } | 209 | void layer_xor(layer_state_t state) { |
| 210 | layer_state_set(layer_state ^ state); | ||
| 211 | } | ||
| 176 | 212 | ||
| 177 | /** \brief Layer debug printing | 213 | /** \brief Layer debug printing |
| 178 | * | 214 | * |
| 179 | * Print out the hex value of the 32-bit layer state, as well as the value of the highest bit. | 215 | * Print out the hex value of the 32-bit layer state, as well as the value of the highest bit. |
| 180 | */ | 216 | */ |
| 181 | void layer_debug(void) { dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state)); } | 217 | void layer_debug(void) { |
| 218 | dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state)); | ||
| 219 | } | ||
| 182 | #endif | 220 | #endif |
| 183 | 221 | ||
| 184 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) | 222 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) |
| @@ -276,4 +314,6 @@ uint8_t layer_switch_get_layer(keypos_t key) { | |||
| 276 | * | 314 | * |
| 277 | * Gets action code based on key position | 315 | * Gets action code based on key position |
| 278 | */ | 316 | */ |
| 279 | action_t layer_switch_get_action(keypos_t key) { return action_for_key(layer_switch_get_layer(key), key); } | 317 | action_t layer_switch_get_action(keypos_t key) { |
| 318 | return action_for_key(layer_switch_get_layer(key), key); | ||
| 319 | } | ||
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index 4ba38bee8d..6f8b4f8c56 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c | |||
| @@ -26,7 +26,9 @@ | |||
| 26 | 26 | ||
| 27 | uint16_t g_tapping_term = TAPPING_TERM; | 27 | uint16_t g_tapping_term = TAPPING_TERM; |
| 28 | 28 | ||
| 29 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return g_tapping_term; } | 29 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { |
| 30 | return g_tapping_term; | ||
| 31 | } | ||
| 30 | 32 | ||
| 31 | # ifdef TAPPING_TERM_PER_KEY | 33 | # ifdef TAPPING_TERM_PER_KEY |
| 32 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_record_keycode(&tapping_key, false), &tapping_key)) | 34 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_record_keycode(&tapping_key, false), &tapping_key)) |
| @@ -35,15 +37,21 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *r | |||
| 35 | # endif | 37 | # endif |
| 36 | 38 | ||
| 37 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | 39 | # ifdef TAPPING_FORCE_HOLD_PER_KEY |
| 38 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } | 40 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { |
| 41 | return false; | ||
| 42 | } | ||
| 39 | # endif | 43 | # endif |
| 40 | 44 | ||
| 41 | # ifdef PERMISSIVE_HOLD_PER_KEY | 45 | # ifdef PERMISSIVE_HOLD_PER_KEY |
| 42 | __attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; } | 46 | __attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { |
| 47 | return false; | ||
| 48 | } | ||
| 43 | # endif | 49 | # endif |
| 44 | 50 | ||
| 45 | # ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY | 51 | # ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY |
| 46 | __attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; } | 52 | __attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { |
| 53 | return false; | ||
| 54 | } | ||
| 47 | # endif | 55 | # endif |
| 48 | 56 | ||
| 49 | # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) | 57 | # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) |
diff --git a/quantum/action_util.c b/quantum/action_util.c index 9eb2a6d30d..64a1b6b30d 100644 --- a/quantum/action_util.c +++ b/quantum/action_util.c | |||
| @@ -43,8 +43,10 @@ extern inline void clear_keys(void); | |||
| 43 | #ifndef NO_ACTION_ONESHOT | 43 | #ifndef NO_ACTION_ONESHOT |
| 44 | static uint8_t oneshot_mods = 0; | 44 | static uint8_t oneshot_mods = 0; |
| 45 | static uint8_t oneshot_locked_mods = 0; | 45 | static uint8_t oneshot_locked_mods = 0; |
| 46 | uint8_t get_oneshot_locked_mods(void) { return oneshot_locked_mods; } | 46 | uint8_t get_oneshot_locked_mods(void) { |
| 47 | void set_oneshot_locked_mods(uint8_t mods) { | 47 | return oneshot_locked_mods; |
| 48 | } | ||
| 49 | void set_oneshot_locked_mods(uint8_t mods) { | ||
| 48 | if (mods != oneshot_locked_mods) { | 50 | if (mods != oneshot_locked_mods) { |
| 49 | oneshot_locked_mods = mods; | 51 | oneshot_locked_mods = mods; |
| 50 | oneshot_locked_mods_changed_kb(oneshot_locked_mods); | 52 | oneshot_locked_mods_changed_kb(oneshot_locked_mods); |
| @@ -58,9 +60,13 @@ void clear_oneshot_locked_mods(void) { | |||
| 58 | } | 60 | } |
| 59 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 61 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 60 | static uint16_t oneshot_time = 0; | 62 | static uint16_t oneshot_time = 0; |
| 61 | bool has_oneshot_mods_timed_out(void) { return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT; } | 63 | bool has_oneshot_mods_timed_out(void) { |
| 64 | return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT; | ||
| 65 | } | ||
| 62 | # else | 66 | # else |
| 63 | bool has_oneshot_mods_timed_out(void) { return false; } | 67 | bool has_oneshot_mods_timed_out(void) { |
| 68 | return false; | ||
| 69 | } | ||
| 64 | # endif | 70 | # endif |
| 65 | #endif | 71 | #endif |
| 66 | 72 | ||
| @@ -74,24 +80,32 @@ bool has_oneshot_mods_timed_out(void) { return false; } | |||
| 74 | */ | 80 | */ |
| 75 | static int8_t oneshot_layer_data = 0; | 81 | static int8_t oneshot_layer_data = 0; |
| 76 | 82 | ||
| 77 | inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } | 83 | inline uint8_t get_oneshot_layer(void) { |
| 78 | inline uint8_t get_oneshot_layer_state(void) { return oneshot_layer_data & 0b111; } | 84 | return oneshot_layer_data >> 3; |
| 85 | } | ||
| 86 | inline uint8_t get_oneshot_layer_state(void) { | ||
| 87 | return oneshot_layer_data & 0b111; | ||
| 88 | } | ||
| 79 | 89 | ||
| 80 | # ifdef SWAP_HANDS_ENABLE | 90 | # ifdef SWAP_HANDS_ENABLE |
| 81 | enum { | 91 | enum { |
| 82 | SHO_OFF, | 92 | SHO_OFF, |
| 83 | SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet | 93 | SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet |
| 84 | SHO_PRESSED, // Swap hands button is currently pressed | 94 | SHO_PRESSED, // Swap hands button is currently pressed |
| 85 | SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys | 95 | SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys |
| 86 | } swap_hands_oneshot = SHO_OFF; | 96 | } swap_hands_oneshot = SHO_OFF; |
| 87 | # endif | 97 | # endif |
| 88 | 98 | ||
| 89 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 99 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 90 | static uint16_t oneshot_layer_time = 0; | 100 | static uint16_t oneshot_layer_time = 0; |
| 91 | inline bool has_oneshot_layer_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED); } | 101 | inline bool has_oneshot_layer_timed_out() { |
| 102 | return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED); | ||
| 103 | } | ||
| 92 | # ifdef SWAP_HANDS_ENABLE | 104 | # ifdef SWAP_HANDS_ENABLE |
| 93 | static uint16_t oneshot_swaphands_time = 0; | 105 | static uint16_t oneshot_swaphands_time = 0; |
| 94 | inline bool has_oneshot_swaphands_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE); } | 106 | inline bool has_oneshot_swaphands_timed_out() { |
| 107 | return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE); | ||
| 108 | } | ||
| 95 | # endif | 109 | # endif |
| 96 | # endif | 110 | # endif |
| 97 | 111 | ||
| @@ -179,7 +193,9 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) { | |||
| 179 | * | 193 | * |
| 180 | * FIXME: needs doc | 194 | * FIXME: needs doc |
| 181 | */ | 195 | */ |
| 182 | bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } | 196 | bool is_oneshot_layer_active(void) { |
| 197 | return get_oneshot_layer_state(); | ||
| 198 | } | ||
| 183 | 199 | ||
| 184 | /** \brief set oneshot | 200 | /** \brief set oneshot |
| 185 | * | 201 | * |
| @@ -198,21 +214,29 @@ void oneshot_set(bool active) { | |||
| 198 | * | 214 | * |
| 199 | * FIXME: needs doc | 215 | * FIXME: needs doc |
| 200 | */ | 216 | */ |
| 201 | void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); } | 217 | void oneshot_toggle(void) { |
| 218 | oneshot_set(!keymap_config.oneshot_disable); | ||
| 219 | } | ||
| 202 | 220 | ||
| 203 | /** \brief enable oneshot | 221 | /** \brief enable oneshot |
| 204 | * | 222 | * |
| 205 | * FIXME: needs doc | 223 | * FIXME: needs doc |
| 206 | */ | 224 | */ |
| 207 | void oneshot_enable(void) { oneshot_set(true); } | 225 | void oneshot_enable(void) { |
| 226 | oneshot_set(true); | ||
| 227 | } | ||
| 208 | 228 | ||
| 209 | /** \brief disable oneshot | 229 | /** \brief disable oneshot |
| 210 | * | 230 | * |
| 211 | * FIXME: needs doc | 231 | * FIXME: needs doc |
| 212 | */ | 232 | */ |
| 213 | void oneshot_disable(void) { oneshot_set(false); } | 233 | void oneshot_disable(void) { |
| 234 | oneshot_set(false); | ||
| 235 | } | ||
| 214 | 236 | ||
| 215 | bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; } | 237 | bool is_oneshot_enabled(void) { |
| 238 | return keymap_config.oneshot_disable; | ||
| 239 | } | ||
| 216 | 240 | ||
| 217 | #endif | 241 | #endif |
| 218 | 242 | ||
| @@ -259,68 +283,96 @@ void send_keyboard_report(void) { | |||
| 259 | * | 283 | * |
| 260 | * FIXME: needs doc | 284 | * FIXME: needs doc |
| 261 | */ | 285 | */ |
| 262 | uint8_t get_mods(void) { return real_mods; } | 286 | uint8_t get_mods(void) { |
| 287 | return real_mods; | ||
| 288 | } | ||
| 263 | /** \brief add mods | 289 | /** \brief add mods |
| 264 | * | 290 | * |
| 265 | * FIXME: needs doc | 291 | * FIXME: needs doc |
| 266 | */ | 292 | */ |
| 267 | void add_mods(uint8_t mods) { real_mods |= mods; } | 293 | void add_mods(uint8_t mods) { |
| 294 | real_mods |= mods; | ||
| 295 | } | ||
| 268 | /** \brief del mods | 296 | /** \brief del mods |
| 269 | * | 297 | * |
| 270 | * FIXME: needs doc | 298 | * FIXME: needs doc |
| 271 | */ | 299 | */ |
| 272 | void del_mods(uint8_t mods) { real_mods &= ~mods; } | 300 | void del_mods(uint8_t mods) { |
| 301 | real_mods &= ~mods; | ||
| 302 | } | ||
| 273 | /** \brief set mods | 303 | /** \brief set mods |
| 274 | * | 304 | * |
| 275 | * FIXME: needs doc | 305 | * FIXME: needs doc |
| 276 | */ | 306 | */ |
| 277 | void set_mods(uint8_t mods) { real_mods = mods; } | 307 | void set_mods(uint8_t mods) { |
| 308 | real_mods = mods; | ||
| 309 | } | ||
| 278 | /** \brief clear mods | 310 | /** \brief clear mods |
| 279 | * | 311 | * |
| 280 | * FIXME: needs doc | 312 | * FIXME: needs doc |
| 281 | */ | 313 | */ |
| 282 | void clear_mods(void) { real_mods = 0; } | 314 | void clear_mods(void) { |
| 315 | real_mods = 0; | ||
| 316 | } | ||
| 283 | 317 | ||
| 284 | /** \brief get weak mods | 318 | /** \brief get weak mods |
| 285 | * | 319 | * |
| 286 | * FIXME: needs doc | 320 | * FIXME: needs doc |
| 287 | */ | 321 | */ |
| 288 | uint8_t get_weak_mods(void) { return weak_mods; } | 322 | uint8_t get_weak_mods(void) { |
| 323 | return weak_mods; | ||
| 324 | } | ||
| 289 | /** \brief add weak mods | 325 | /** \brief add weak mods |
| 290 | * | 326 | * |
| 291 | * FIXME: needs doc | 327 | * FIXME: needs doc |
| 292 | */ | 328 | */ |
| 293 | void add_weak_mods(uint8_t mods) { weak_mods |= mods; } | 329 | void add_weak_mods(uint8_t mods) { |
| 330 | weak_mods |= mods; | ||
| 331 | } | ||
| 294 | /** \brief del weak mods | 332 | /** \brief del weak mods |
| 295 | * | 333 | * |
| 296 | * FIXME: needs doc | 334 | * FIXME: needs doc |
| 297 | */ | 335 | */ |
| 298 | void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } | 336 | void del_weak_mods(uint8_t mods) { |
| 337 | weak_mods &= ~mods; | ||
| 338 | } | ||
| 299 | /** \brief set weak mods | 339 | /** \brief set weak mods |
| 300 | * | 340 | * |
| 301 | * FIXME: needs doc | 341 | * FIXME: needs doc |
| 302 | */ | 342 | */ |
| 303 | void set_weak_mods(uint8_t mods) { weak_mods = mods; } | 343 | void set_weak_mods(uint8_t mods) { |
| 344 | weak_mods = mods; | ||
| 345 | } | ||
| 304 | /** \brief clear weak mods | 346 | /** \brief clear weak mods |
| 305 | * | 347 | * |
| 306 | * FIXME: needs doc | 348 | * FIXME: needs doc |
| 307 | */ | 349 | */ |
| 308 | void clear_weak_mods(void) { weak_mods = 0; } | 350 | void clear_weak_mods(void) { |
| 351 | weak_mods = 0; | ||
| 352 | } | ||
| 309 | 353 | ||
| 310 | #ifdef KEY_OVERRIDE_ENABLE | 354 | #ifdef KEY_OVERRIDE_ENABLE |
| 311 | /** \brief set weak mods used by key overrides. DO not call this manually | 355 | /** \brief set weak mods used by key overrides. DO not call this manually |
| 312 | */ | 356 | */ |
| 313 | void set_weak_override_mods(uint8_t mods) { weak_override_mods = mods; } | 357 | void set_weak_override_mods(uint8_t mods) { |
| 358 | weak_override_mods = mods; | ||
| 359 | } | ||
| 314 | /** \brief clear weak mods used by key overrides. DO not call this manually | 360 | /** \brief clear weak mods used by key overrides. DO not call this manually |
| 315 | */ | 361 | */ |
| 316 | void clear_weak_override_mods(void) { weak_override_mods = 0; } | 362 | void clear_weak_override_mods(void) { |
| 363 | weak_override_mods = 0; | ||
| 364 | } | ||
| 317 | 365 | ||
| 318 | /** \brief set suppressed mods used by key overrides. DO not call this manually | 366 | /** \brief set suppressed mods used by key overrides. DO not call this manually |
| 319 | */ | 367 | */ |
| 320 | void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; } | 368 | void set_suppressed_override_mods(uint8_t mods) { |
| 369 | suppressed_mods = mods; | ||
| 370 | } | ||
| 321 | /** \brief clear suppressed mods used by key overrides. DO not call this manually | 371 | /** \brief clear suppressed mods used by key overrides. DO not call this manually |
| 322 | */ | 372 | */ |
| 323 | void clear_suppressed_override_mods(void) { suppressed_mods = 0; } | 373 | void clear_suppressed_override_mods(void) { |
| 374 | suppressed_mods = 0; | ||
| 375 | } | ||
| 324 | #endif | 376 | #endif |
| 325 | 377 | ||
| 326 | #ifndef NO_ACTION_ONESHOT | 378 | #ifndef NO_ACTION_ONESHOT |
| @@ -328,7 +380,9 @@ void clear_suppressed_override_mods(void) { suppressed_mods = 0; } | |||
| 328 | * | 380 | * |
| 329 | * FIXME: needs doc | 381 | * FIXME: needs doc |
| 330 | */ | 382 | */ |
| 331 | uint8_t get_oneshot_mods(void) { return oneshot_mods; } | 383 | uint8_t get_oneshot_mods(void) { |
| 384 | return oneshot_mods; | ||
| 385 | } | ||
| 332 | 386 | ||
| 333 | void add_oneshot_mods(uint8_t mods) { | 387 | void add_oneshot_mods(uint8_t mods) { |
| 334 | if ((oneshot_mods & mods) != mods) { | 388 | if ((oneshot_mods & mods) != mods) { |
| @@ -391,7 +445,9 @@ __attribute__((weak)) void oneshot_locked_mods_changed_user(uint8_t mods) {} | |||
| 391 | * | 445 | * |
| 392 | * \param mods Contains the active modifiers active after the change. | 446 | * \param mods Contains the active modifiers active after the change. |
| 393 | */ | 447 | */ |
| 394 | __attribute__((weak)) void oneshot_locked_mods_changed_kb(uint8_t mods) { oneshot_locked_mods_changed_user(mods); } | 448 | __attribute__((weak)) void oneshot_locked_mods_changed_kb(uint8_t mods) { |
| 449 | oneshot_locked_mods_changed_user(mods); | ||
| 450 | } | ||
| 395 | 451 | ||
| 396 | /** \brief Called when the one shot modifiers have been changed. | 452 | /** \brief Called when the one shot modifiers have been changed. |
| 397 | * | 453 | * |
| @@ -403,7 +459,9 @@ __attribute__((weak)) void oneshot_mods_changed_user(uint8_t mods) {} | |||
| 403 | * | 459 | * |
| 404 | * \param mods Contains the active modifiers active after the change. | 460 | * \param mods Contains the active modifiers active after the change. |
| 405 | */ | 461 | */ |
| 406 | __attribute__((weak)) void oneshot_mods_changed_kb(uint8_t mods) { oneshot_mods_changed_user(mods); } | 462 | __attribute__((weak)) void oneshot_mods_changed_kb(uint8_t mods) { |
| 463 | oneshot_mods_changed_user(mods); | ||
| 464 | } | ||
| 407 | 465 | ||
| 408 | /** \brief Called when the one shot layers have been changed. | 466 | /** \brief Called when the one shot layers have been changed. |
| 409 | * | 467 | * |
| @@ -415,10 +473,14 @@ __attribute__((weak)) void oneshot_layer_changed_user(uint8_t layer) {} | |||
| 415 | * | 473 | * |
| 416 | * \param layer Contains the layer that is toggled on, or zero when toggled off. | 474 | * \param layer Contains the layer that is toggled on, or zero when toggled off. |
| 417 | */ | 475 | */ |
| 418 | __attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) { oneshot_layer_changed_user(layer); } | 476 | __attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) { |
| 477 | oneshot_layer_changed_user(layer); | ||
| 478 | } | ||
| 419 | 479 | ||
| 420 | /** \brief inspect keyboard state | 480 | /** \brief inspect keyboard state |
| 421 | * | 481 | * |
| 422 | * FIXME: needs doc | 482 | * FIXME: needs doc |
| 423 | */ | 483 | */ |
| 424 | uint8_t has_anymod(void) { return bitpop(real_mods); } | 484 | uint8_t has_anymod(void) { |
| 485 | return bitpop(real_mods); | ||
| 486 | } | ||
diff --git a/quantum/action_util.h b/quantum/action_util.h index bfd0a6cf95..6f1f09c4bd 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h | |||
| @@ -29,11 +29,17 @@ extern report_keyboard_t *keyboard_report; | |||
| 29 | void send_keyboard_report(void); | 29 | void send_keyboard_report(void); |
| 30 | 30 | ||
| 31 | /* key */ | 31 | /* key */ |
| 32 | inline void add_key(uint8_t key) { add_key_to_report(keyboard_report, key); } | 32 | inline void add_key(uint8_t key) { |
| 33 | add_key_to_report(keyboard_report, key); | ||
| 34 | } | ||
| 33 | 35 | ||
| 34 | inline void del_key(uint8_t key) { del_key_from_report(keyboard_report, key); } | 36 | inline void del_key(uint8_t key) { |
| 37 | del_key_from_report(keyboard_report, key); | ||
| 38 | } | ||
| 35 | 39 | ||
| 36 | inline void clear_keys(void) { clear_keys_from_report(keyboard_report); } | 40 | inline void clear_keys(void) { |
| 41 | clear_keys_from_report(keyboard_report); | ||
| 42 | } | ||
| 37 | 43 | ||
| 38 | /* modifier */ | 44 | /* modifier */ |
| 39 | uint8_t get_mods(void); | 45 | uint8_t get_mods(void); |
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index b3d6389dd5..c6523b908c 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
| @@ -64,21 +64,21 @@ | |||
| 64 | #ifndef AUDIO_TONE_STACKSIZE | 64 | #ifndef AUDIO_TONE_STACKSIZE |
| 65 | # define AUDIO_TONE_STACKSIZE 8 | 65 | # define AUDIO_TONE_STACKSIZE 8 |
| 66 | #endif | 66 | #endif |
| 67 | uint8_t active_tones = 0; // number of tones pushed onto the stack by audio_play_tone - might be more than the hardware is able to reproduce at any single time | 67 | uint8_t active_tones = 0; // number of tones pushed onto the stack by audio_play_tone - might be more than the hardware is able to reproduce at any single time |
| 68 | musical_tone_t tones[AUDIO_TONE_STACKSIZE]; // stack of currently active tones | 68 | musical_tone_t tones[AUDIO_TONE_STACKSIZE]; // stack of currently active tones |
| 69 | 69 | ||
| 70 | bool playing_melody = false; // playing a SONG? | 70 | bool playing_melody = false; // playing a SONG? |
| 71 | bool playing_note = false; // or (possibly multiple simultaneous) tones | 71 | bool playing_note = false; // or (possibly multiple simultaneous) tones |
| 72 | bool state_changed = false; // global flag, which is set if anything changes with the active_tones | 72 | bool state_changed = false; // global flag, which is set if anything changes with the active_tones |
| 73 | 73 | ||
| 74 | // melody/SONG related state variables | 74 | // melody/SONG related state variables |
| 75 | float (*notes_pointer)[][2]; // SONG, an array of MUSICAL_NOTEs | 75 | float (*notes_pointer)[][2]; // SONG, an array of MUSICAL_NOTEs |
| 76 | uint16_t notes_count; // length of the notes_pointer array | 76 | uint16_t notes_count; // length of the notes_pointer array |
| 77 | bool notes_repeat; // PLAY_SONG or PLAY_LOOP? | 77 | bool notes_repeat; // PLAY_SONG or PLAY_LOOP? |
| 78 | uint16_t melody_current_note_duration = 0; // duration of the currently playing note from the active melody, in ms | 78 | uint16_t melody_current_note_duration = 0; // duration of the currently playing note from the active melody, in ms |
| 79 | uint8_t note_tempo = TEMPO_DEFAULT; // beats-per-minute | 79 | uint8_t note_tempo = TEMPO_DEFAULT; // beats-per-minute |
| 80 | uint16_t current_note = 0; // index into the array at notes_pointer | 80 | uint16_t current_note = 0; // index into the array at notes_pointer |
| 81 | bool note_resting = false; // if a short pause was introduced between two notes with the same frequency while playing a melody | 81 | bool note_resting = false; // if a short pause was introduced between two notes with the same frequency while playing a melody |
| 82 | uint16_t last_timestamp = 0; | 82 | uint16_t last_timestamp = 0; |
| 83 | 83 | ||
| 84 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING | 84 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING |
| @@ -86,7 +86,7 @@ uint16_t last_timestamp = 0; | |||
| 86 | # define AUDIO_MAX_SIMULTANEOUS_TONES 3 | 86 | # define AUDIO_MAX_SIMULTANEOUS_TONES 3 |
| 87 | # endif | 87 | # endif |
| 88 | uint16_t tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; | 88 | uint16_t tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; |
| 89 | uint8_t tone_multiplexing_index_shift = 0; // offset used on active-tone array access | 89 | uint8_t tone_multiplexing_index_shift = 0; // offset used on active-tone array access |
| 90 | #endif | 90 | #endif |
| 91 | 91 | ||
| 92 | // provided and used by voices.c | 92 | // provided and used by voices.c |
| @@ -123,12 +123,12 @@ void audio_init() { | |||
| 123 | eeconfig_init(); | 123 | eeconfig_init(); |
| 124 | } | 124 | } |
| 125 | audio_config.raw = eeconfig_read_audio(); | 125 | audio_config.raw = eeconfig_read_audio(); |
| 126 | #else // EEPROM settings | 126 | #else // EEPROM settings |
| 127 | audio_config.enable = true; | 127 | audio_config.enable = true; |
| 128 | # ifdef AUDIO_CLICKY_ON | 128 | # ifdef AUDIO_CLICKY_ON |
| 129 | audio_config.clicky_enable = true; | 129 | audio_config.clicky_enable = true; |
| 130 | # endif | 130 | # endif |
| 131 | #endif // EEPROM settings | 131 | #endif // EEPROM settings |
| 132 | 132 | ||
| 133 | for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) { | 133 | for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) { |
| 134 | tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0}; | 134 | tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0}; |
| @@ -181,7 +181,9 @@ void audio_off(void) { | |||
| 181 | eeconfig_update_audio(audio_config.raw); | 181 | eeconfig_update_audio(audio_config.raw); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | bool audio_is_on(void) { return (audio_config.enable != 0); } | 184 | bool audio_is_on(void) { |
| 185 | return (audio_config.enable != 0); | ||
| 186 | } | ||
| 185 | 187 | ||
| 186 | void audio_stop_all() { | 188 | void audio_stop_all() { |
| 187 | if (audio_driver_stopped) { | 189 | if (audio_driver_stopped) { |
| @@ -268,7 +270,7 @@ void audio_play_note(float pitch, uint16_t duration) { | |||
| 268 | tones[j] = tones[j + 1]; | 270 | tones[j] = tones[j + 1]; |
| 269 | tones[j + 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; | 271 | tones[j + 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; |
| 270 | } | 272 | } |
| 271 | return; // since this frequency played already, the hardware was already started | 273 | return; // since this frequency played already, the hardware was already started |
| 272 | } | 274 | } |
| 273 | } | 275 | } |
| 274 | 276 | ||
| @@ -286,7 +288,7 @@ void audio_play_note(float pitch, uint16_t duration) { | |||
| 286 | tones[active_tones - 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; | 288 | tones[active_tones - 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; |
| 287 | 289 | ||
| 288 | // TODO: needs to be handled per note/tone -> use its timestamp instead? | 290 | // TODO: needs to be handled per note/tone -> use its timestamp instead? |
| 289 | voices_timer = timer_read(); // reset to zero, for the effects added by voices.c | 291 | voices_timer = timer_read(); // reset to zero, for the effects added by voices.c |
| 290 | 292 | ||
| 291 | if (audio_driver_stopped) { | 293 | if (audio_driver_stopped) { |
| 292 | audio_driver_start(); | 294 | audio_driver_start(); |
| @@ -294,7 +296,9 @@ void audio_play_note(float pitch, uint16_t duration) { | |||
| 294 | } | 296 | } |
| 295 | } | 297 | } |
| 296 | 298 | ||
| 297 | void audio_play_tone(float pitch) { audio_play_note(pitch, 0xffff); } | 299 | void audio_play_tone(float pitch) { |
| 300 | audio_play_note(pitch, 0xffff); | ||
| 301 | } | ||
| 298 | 302 | ||
| 299 | void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) { | 303 | void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) { |
| 300 | if (!audio_config.enable) { | 304 | if (!audio_config.enable) { |
| @@ -316,7 +320,7 @@ void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) { | |||
| 316 | notes_count = n_count; | 320 | notes_count = n_count; |
| 317 | notes_repeat = n_repeat; | 321 | notes_repeat = n_repeat; |
| 318 | 322 | ||
| 319 | current_note = 0; // note in the melody-array/list at note_pointer | 323 | current_note = 0; // note in the melody-array/list at note_pointer |
| 320 | 324 | ||
| 321 | // start first note manually, which also starts the audio_driver | 325 | // start first note manually, which also starts the audio_driver |
| 322 | // all following/remaining notes are played by 'audio_update_state' | 326 | // all following/remaining notes are played by 'audio_update_state' |
| @@ -347,11 +351,17 @@ void audio_play_click(uint16_t delay, float pitch, uint16_t duration) { | |||
| 347 | } | 351 | } |
| 348 | } | 352 | } |
| 349 | 353 | ||
| 350 | bool audio_is_playing_note(void) { return playing_note; } | 354 | bool audio_is_playing_note(void) { |
| 355 | return playing_note; | ||
| 356 | } | ||
| 351 | 357 | ||
| 352 | bool audio_is_playing_melody(void) { return playing_melody; } | 358 | bool audio_is_playing_melody(void) { |
| 359 | return playing_melody; | ||
| 360 | } | ||
| 353 | 361 | ||
| 354 | uint8_t audio_get_number_of_active_tones(void) { return active_tones; } | 362 | uint8_t audio_get_number_of_active_tones(void) { |
| 363 | return active_tones; | ||
| 364 | } | ||
| 355 | 365 | ||
| 356 | float audio_get_frequency(uint8_t tone_index) { | 366 | float audio_get_frequency(uint8_t tone_index) { |
| 357 | if (tone_index >= active_tones) { | 367 | if (tone_index >= active_tones) { |
| @@ -370,7 +380,7 @@ float audio_get_processed_frequency(uint8_t tone_index) { | |||
| 370 | 380 | ||
| 371 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING | 381 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING |
| 372 | index = index - tone_multiplexing_index_shift; | 382 | index = index - tone_multiplexing_index_shift; |
| 373 | if (index < 0) // wrap around | 383 | if (index < 0) // wrap around |
| 374 | index += active_tones; | 384 | index += active_tones; |
| 375 | #endif | 385 | #endif |
| 376 | 386 | ||
| @@ -396,7 +406,7 @@ bool audio_update_state(void) { | |||
| 396 | last_timestamp = current_time; | 406 | last_timestamp = current_time; |
| 397 | uint16_t previous_note = current_note; | 407 | uint16_t previous_note = current_note; |
| 398 | current_note++; | 408 | current_note++; |
| 399 | voices_timer = timer_read(); // reset to zero, for the effects added by voices.c | 409 | voices_timer = timer_read(); // reset to zero, for the effects added by voices.c |
| 400 | 410 | ||
| 401 | if (current_note >= notes_count) { | 411 | if (current_note >= notes_count) { |
| 402 | if (notes_repeat) { | 412 | if (notes_repeat) { |
| @@ -466,11 +476,11 @@ bool audio_update_state(void) { | |||
| 466 | 476 | ||
| 467 | // housekeeping: stop notes that have no playtime left | 477 | // housekeeping: stop notes that have no playtime left |
| 468 | for (int i = 0; i < active_tones; i++) { | 478 | for (int i = 0; i < active_tones; i++) { |
| 469 | if ((tones[i].duration != 0xffff) // indefinitely playing notes, started by 'audio_play_tone' | 479 | if ((tones[i].duration != 0xffff) // indefinitely playing notes, started by 'audio_play_tone' |
| 470 | && (tones[i].duration != 0) // 'uninitialized' | 480 | && (tones[i].duration != 0) // 'uninitialized' |
| 471 | ) { | 481 | ) { |
| 472 | if (timer_elapsed(tones[i].time_started) >= tones[i].duration) { | 482 | if (timer_elapsed(tones[i].time_started) >= tones[i].duration) { |
| 473 | audio_stop_tone(tones[i].pitch); // also sets 'state_changed=true' | 483 | audio_stop_tone(tones[i].pitch); // also sets 'state_changed=true' |
| 474 | } | 484 | } |
| 475 | } | 485 | } |
| 476 | } | 486 | } |
| @@ -487,9 +497,15 @@ bool audio_update_state(void) { | |||
| 487 | 497 | ||
| 488 | // Tone-multiplexing functions | 498 | // Tone-multiplexing functions |
| 489 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING | 499 | #ifdef AUDIO_ENABLE_TONE_MULTIPLEXING |
| 490 | void audio_set_tone_multiplexing_rate(uint16_t rate) { tone_multiplexing_rate = rate; } | 500 | void audio_set_tone_multiplexing_rate(uint16_t rate) { |
| 491 | void audio_enable_tone_multiplexing(void) { tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; } | 501 | tone_multiplexing_rate = rate; |
| 492 | void audio_disable_tone_multiplexing(void) { tone_multiplexing_rate = 0; } | 502 | } |
| 503 | void audio_enable_tone_multiplexing(void) { | ||
| 504 | tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; | ||
| 505 | } | ||
| 506 | void audio_disable_tone_multiplexing(void) { | ||
| 507 | tone_multiplexing_rate = 0; | ||
| 508 | } | ||
| 493 | void audio_increase_tone_multiplexing_rate(uint16_t change) { | 509 | void audio_increase_tone_multiplexing_rate(uint16_t change) { |
| 494 | if ((0xffff - change) > tone_multiplexing_rate) { | 510 | if ((0xffff - change) > tone_multiplexing_rate) { |
| 495 | tone_multiplexing_rate += change; | 511 | tone_multiplexing_rate += change; |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 290d461f5a..fe23cf3ed1 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
| @@ -54,9 +54,9 @@ typedef union { | |||
| 54 | * "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)" | 54 | * "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)" |
| 55 | */ | 55 | */ |
| 56 | typedef struct { | 56 | typedef struct { |
| 57 | uint16_t time_started; // timestamp the tone/note was started, system time runs with 1ms resolution -> 16bit timer overflows every ~64 seconds, long enough under normal circumstances; but might be too soon for long-duration notes when the note_tempo is set to a very low value | 57 | uint16_t time_started; // timestamp the tone/note was started, system time runs with 1ms resolution -> 16bit timer overflows every ~64 seconds, long enough under normal circumstances; but might be too soon for long-duration notes when the note_tempo is set to a very low value |
| 58 | float pitch; // aka frequency, in Hz | 58 | float pitch; // aka frequency, in Hz |
| 59 | uint16_t duration; // in ms, converted from the musical_notes.h unit which has 64parts to a beat, factoring in the current tempo in beats-per-minute | 59 | uint16_t duration; // in ms, converted from the musical_notes.h unit which has 64parts to a beat, factoring in the current tempo in beats-per-minute |
| 60 | // float intensity; // aka volume [0,1] TODO: not used at the moment; pwm drivers can't handle it | 60 | // float intensity; // aka volume [0,1] TODO: not used at the moment; pwm drivers can't handle it |
| 61 | // uint8_t timbre; // range: [0,100] TODO: this currently kept track of globally, should we do this per tone instead? | 61 | // uint8_t timbre; // range: [0,100] TODO: this currently kept track of globally, should we do this per tone instead? |
| 62 | } musical_tone_t; | 62 | } musical_tone_t; |
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 8e80a016aa..3e425abb47 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | #if __has_include("user_song_list.h") | 23 | #if __has_include("user_song_list.h") |
| 24 | # include "user_song_list.h" | 24 | # include "user_song_list.h" |
| 25 | #endif // if file exists | 25 | #endif // if file exists |
| 26 | 26 | ||
| 27 | #define NO_SOUND | 27 | #define NO_SOUND |
| 28 | 28 | ||
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 8988d827e9..1c08a3af36 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c | |||
| @@ -32,11 +32,17 @@ voice_type voice = AUDIO_VOICE_DEFAULT; | |||
| 32 | voice_type voice = default_voice; | 32 | voice_type voice = default_voice; |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | void set_voice(voice_type v) { voice = v; } | 35 | void set_voice(voice_type v) { |
| 36 | voice = v; | ||
| 37 | } | ||
| 36 | 38 | ||
| 37 | void voice_iterate() { voice = (voice + 1) % number_of_voices; } | 39 | void voice_iterate() { |
| 40 | voice = (voice + 1) % number_of_voices; | ||
| 41 | } | ||
| 38 | 42 | ||
| 39 | void voice_deiterate() { voice = (voice - 1 + number_of_voices) % number_of_voices; } | 43 | void voice_deiterate() { |
| 44 | voice = (voice - 1 + number_of_voices) % number_of_voices; | ||
| 45 | } | ||
| 40 | 46 | ||
| 41 | #ifdef AUDIO_VOICES | 47 | #ifdef AUDIO_VOICES |
| 42 | float mod(float a, int b) { | 48 | float mod(float a, int b) { |
| @@ -67,8 +73,8 @@ float voice_envelope(float frequency) { | |||
| 67 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz | 73 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz |
| 68 | // __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); | 74 | // __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); |
| 69 | #ifdef AUDIO_VOICES | 75 | #ifdef AUDIO_VOICES |
| 70 | uint16_t envelope_index = timer_elapsed(voices_timer); // TODO: multiply in some factor? | 76 | uint16_t envelope_index = timer_elapsed(voices_timer); // TODO: multiply in some factor? |
| 71 | uint16_t compensated_index = envelope_index / 100; // TODO: correct factor would be? | 77 | uint16_t compensated_index = envelope_index / 100; // TODO: correct factor would be? |
| 72 | #endif | 78 | #endif |
| 73 | 79 | ||
| 74 | switch (voice) { | 80 | switch (voice) { |
| @@ -303,7 +309,7 @@ float voice_envelope(float frequency) { | |||
| 303 | // note_timbre = TIMBRE_25; | 309 | // note_timbre = TIMBRE_25; |
| 304 | // break; | 310 | // break; |
| 305 | 311 | ||
| 306 | #endif // AUDIO_VOICES | 312 | #endif // AUDIO_VOICES |
| 307 | 313 | ||
| 308 | default: | 314 | default: |
| 309 | break; | 315 | break; |
| @@ -318,19 +324,31 @@ float voice_envelope(float frequency) { | |||
| 318 | // TODO: where to keep track of the start-frequency? | 324 | // TODO: where to keep track of the start-frequency? |
| 319 | // frequency = voice_add_glissando(??, frequency); | 325 | // frequency = voice_add_glissando(??, frequency); |
| 320 | } | 326 | } |
| 321 | #endif // AUDIO_VOICES | 327 | #endif // AUDIO_VOICES |
| 322 | 328 | ||
| 323 | return frequency; | 329 | return frequency; |
| 324 | } | 330 | } |
| 325 | 331 | ||
| 326 | // Vibrato functions | 332 | // Vibrato functions |
| 327 | 333 | ||
| 328 | void voice_set_vibrato_rate(float rate) { vibrato_rate = rate; } | 334 | void voice_set_vibrato_rate(float rate) { |
| 329 | void voice_increase_vibrato_rate(float change) { vibrato_rate *= change; } | 335 | vibrato_rate = rate; |
| 330 | void voice_decrease_vibrato_rate(float change) { vibrato_rate /= change; } | 336 | } |
| 331 | void voice_set_vibrato_strength(float strength) { vibrato_strength = strength; } | 337 | void voice_increase_vibrato_rate(float change) { |
| 332 | void voice_increase_vibrato_strength(float change) { vibrato_strength *= change; } | 338 | vibrato_rate *= change; |
| 333 | void voice_decrease_vibrato_strength(float change) { vibrato_strength /= change; } | 339 | } |
| 340 | void voice_decrease_vibrato_rate(float change) { | ||
| 341 | vibrato_rate /= change; | ||
| 342 | } | ||
| 343 | void voice_set_vibrato_strength(float strength) { | ||
| 344 | vibrato_strength = strength; | ||
| 345 | } | ||
| 346 | void voice_increase_vibrato_strength(float change) { | ||
| 347 | vibrato_strength *= change; | ||
| 348 | } | ||
| 349 | void voice_decrease_vibrato_strength(float change) { | ||
| 350 | vibrato_strength /= change; | ||
| 351 | } | ||
| 334 | 352 | ||
| 335 | // Timbre functions | 353 | // Timbre functions |
| 336 | 354 | ||
| @@ -339,4 +357,6 @@ void voice_set_timbre(uint8_t timbre) { | |||
| 339 | note_timbre = timbre; | 357 | note_timbre = timbre; |
| 340 | } | 358 | } |
| 341 | } | 359 | } |
| 342 | uint8_t voice_get_timbre(void) { return note_timbre; } | 360 | uint8_t voice_get_timbre(void) { |
| 361 | return note_timbre; | ||
| 362 | } | ||
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h index 1f402e7e12..fcab9db556 100644 --- a/quantum/audio/voices.h +++ b/quantum/audio/voices.h | |||
| @@ -40,7 +40,7 @@ typedef enum { | |||
| 40 | // duty_third_down, | 40 | // duty_third_down, |
| 41 | // duty_fifth_third_down, | 41 | // duty_fifth_third_down, |
| 42 | #endif | 42 | #endif |
| 43 | number_of_voices // important that this is last | 43 | number_of_voices // important that this is last |
| 44 | } voice_type; | 44 | } voice_type; |
| 45 | 45 | ||
| 46 | void set_voice(voice_type v); | 46 | void set_voice(voice_type v); |
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index dfb98419e6..52ec086bb0 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c | |||
| @@ -95,10 +95,10 @@ void backlight_toggle(void) { | |||
| 95 | * FIXME: needs doc | 95 | * FIXME: needs doc |
| 96 | */ | 96 | */ |
| 97 | void backlight_enable(void) { | 97 | void backlight_enable(void) { |
| 98 | if (backlight_config.enable) return; // do nothing if backlight is already on | 98 | if (backlight_config.enable) return; // do nothing if backlight is already on |
| 99 | 99 | ||
| 100 | backlight_config.enable = true; | 100 | backlight_config.enable = true; |
| 101 | if (backlight_config.raw == 1) // enabled but level == 0 | 101 | if (backlight_config.raw == 1) // enabled but level == 0 |
| 102 | backlight_config.level = 1; | 102 | backlight_config.level = 1; |
| 103 | eeconfig_update_backlight(backlight_config.raw); | 103 | eeconfig_update_backlight(backlight_config.raw); |
| 104 | dprintf("backlight enable\n"); | 104 | dprintf("backlight enable\n"); |
| @@ -110,7 +110,7 @@ void backlight_enable(void) { | |||
| 110 | * FIXME: needs doc | 110 | * FIXME: needs doc |
| 111 | */ | 111 | */ |
| 112 | void backlight_disable(void) { | 112 | void backlight_disable(void) { |
| 113 | if (!backlight_config.enable) return; // do nothing if backlight is already off | 113 | if (!backlight_config.enable) return; // do nothing if backlight is already off |
| 114 | 114 | ||
| 115 | backlight_config.enable = false; | 115 | backlight_config.enable = false; |
| 116 | eeconfig_update_backlight(backlight_config.raw); | 116 | eeconfig_update_backlight(backlight_config.raw); |
| @@ -122,7 +122,9 @@ void backlight_disable(void) { | |||
| 122 | * | 122 | * |
| 123 | * FIXME: needs doc | 123 | * FIXME: needs doc |
| 124 | */ | 124 | */ |
| 125 | bool is_backlight_enabled(void) { return backlight_config.enable; } | 125 | bool is_backlight_enabled(void) { |
| 126 | return backlight_config.enable; | ||
| 127 | } | ||
| 126 | 128 | ||
| 127 | /** \brief Backlight step through levels | 129 | /** \brief Backlight step through levels |
| 128 | * | 130 | * |
| @@ -158,11 +160,17 @@ void backlight_level(uint8_t level) { | |||
| 158 | eeconfig_update_backlight(backlight_config.raw); | 160 | eeconfig_update_backlight(backlight_config.raw); |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } | 163 | uint8_t eeconfig_read_backlight(void) { |
| 164 | return eeprom_read_byte(EECONFIG_BACKLIGHT); | ||
| 165 | } | ||
| 162 | 166 | ||
| 163 | void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } | 167 | void eeconfig_update_backlight(uint8_t val) { |
| 168 | eeprom_update_byte(EECONFIG_BACKLIGHT, val); | ||
| 169 | } | ||
| 164 | 170 | ||
| 165 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } | 171 | void eeconfig_update_backlight_current(void) { |
| 172 | eeconfig_update_backlight(backlight_config.raw); | ||
| 173 | } | ||
| 166 | 174 | ||
| 167 | void eeconfig_update_backlight_default(void) { | 175 | void eeconfig_update_backlight_default(void) { |
| 168 | backlight_config.enable = 1; | 176 | backlight_config.enable = 1; |
| @@ -179,7 +187,9 @@ void eeconfig_update_backlight_default(void) { | |||
| 179 | * | 187 | * |
| 180 | * FIXME: needs doc | 188 | * FIXME: needs doc |
| 181 | */ | 189 | */ |
| 182 | uint8_t get_backlight_level(void) { return backlight_config.level; } | 190 | uint8_t get_backlight_level(void) { |
| 191 | return backlight_config.level; | ||
| 192 | } | ||
| 183 | 193 | ||
| 184 | #ifdef BACKLIGHT_BREATHING | 194 | #ifdef BACKLIGHT_BREATHING |
| 185 | /** \brief Backlight breathing toggle | 195 | /** \brief Backlight breathing toggle |
| @@ -200,7 +210,7 @@ void backlight_toggle_breathing(void) { | |||
| 200 | * FIXME: needs doc | 210 | * FIXME: needs doc |
| 201 | */ | 211 | */ |
| 202 | void backlight_enable_breathing(void) { | 212 | void backlight_enable_breathing(void) { |
| 203 | if (backlight_config.breathing) return; // do nothing if breathing is already on | 213 | if (backlight_config.breathing) return; // do nothing if breathing is already on |
| 204 | 214 | ||
| 205 | backlight_config.breathing = true; | 215 | backlight_config.breathing = true; |
| 206 | eeconfig_update_backlight(backlight_config.raw); | 216 | eeconfig_update_backlight(backlight_config.raw); |
| @@ -213,7 +223,7 @@ void backlight_enable_breathing(void) { | |||
| 213 | * FIXME: needs doc | 223 | * FIXME: needs doc |
| 214 | */ | 224 | */ |
| 215 | void backlight_disable_breathing(void) { | 225 | void backlight_disable_breathing(void) { |
| 216 | if (!backlight_config.breathing) return; // do nothing if breathing is already off | 226 | if (!backlight_config.breathing) return; // do nothing if breathing is already off |
| 217 | 227 | ||
| 218 | backlight_config.breathing = false; | 228 | backlight_config.breathing = false; |
| 219 | eeconfig_update_backlight(backlight_config.raw); | 229 | eeconfig_update_backlight(backlight_config.raw); |
| @@ -225,18 +235,30 @@ void backlight_disable_breathing(void) { | |||
| 225 | * | 235 | * |
| 226 | * FIXME: needs doc | 236 | * FIXME: needs doc |
| 227 | */ | 237 | */ |
| 228 | bool is_backlight_breathing(void) { return backlight_config.breathing; } | 238 | bool is_backlight_breathing(void) { |
| 239 | return backlight_config.breathing; | ||
| 240 | } | ||
| 229 | 241 | ||
| 230 | // following are marked as weak purely for backwards compatibility | 242 | // following are marked as weak purely for backwards compatibility |
| 231 | __attribute__((weak)) void breathing_period_set(uint8_t value) { breathing_period = value ? value : 1; } | 243 | __attribute__((weak)) void breathing_period_set(uint8_t value) { |
| 244 | breathing_period = value ? value : 1; | ||
| 245 | } | ||
| 232 | 246 | ||
| 233 | __attribute__((weak)) uint8_t get_breathing_period(void) { return breathing_period; } | 247 | __attribute__((weak)) uint8_t get_breathing_period(void) { |
| 248 | return breathing_period; | ||
| 249 | } | ||
| 234 | 250 | ||
| 235 | __attribute__((weak)) void breathing_period_default(void) { breathing_period_set(BREATHING_PERIOD); } | 251 | __attribute__((weak)) void breathing_period_default(void) { |
| 252 | breathing_period_set(BREATHING_PERIOD); | ||
| 253 | } | ||
| 236 | 254 | ||
| 237 | __attribute__((weak)) void breathing_period_inc(void) { breathing_period_set(breathing_period + 1); } | 255 | __attribute__((weak)) void breathing_period_inc(void) { |
| 256 | breathing_period_set(breathing_period + 1); | ||
| 257 | } | ||
| 238 | 258 | ||
| 239 | __attribute__((weak)) void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); } | 259 | __attribute__((weak)) void breathing_period_dec(void) { |
| 260 | breathing_period_set(breathing_period - 1); | ||
| 261 | } | ||
| 240 | 262 | ||
| 241 | __attribute__((weak)) void breathing_toggle(void) { | 263 | __attribute__((weak)) void breathing_toggle(void) { |
| 242 | if (is_breathing()) | 264 | if (is_breathing()) |
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index c30c70fd62..ff9c8de420 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h | |||
| @@ -39,7 +39,7 @@ typedef union { | |||
| 39 | struct { | 39 | struct { |
| 40 | bool enable : 1; | 40 | bool enable : 1; |
| 41 | bool breathing : 1; | 41 | bool breathing : 1; |
| 42 | uint8_t reserved : 1; // Reserved for possible future backlight modes | 42 | uint8_t reserved : 1; // Reserved for possible future backlight modes |
| 43 | uint8_t level : 5; | 43 | uint8_t level : 5; |
| 44 | }; | 44 | }; |
| 45 | } backlight_config_t; | 45 | } backlight_config_t; |
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index 9c972ae02e..f3a0252270 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c | |||
| @@ -136,7 +136,7 @@ | |||
| 136 | # define TCCRxB TCCR1B | 136 | # define TCCRxB TCCR1B |
| 137 | # define TIMERx_COMPA_vect TIMER1_COMPA_vect | 137 | # define TIMERx_COMPA_vect TIMER1_COMPA_vect |
| 138 | # define TIMERx_OVF_vect TIMER1_OVF_vect | 138 | # define TIMERx_OVF_vect TIMER1_OVF_vect |
| 139 | # if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register | 139 | # if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register |
| 140 | # define TIMSKx TIMSK | 140 | # define TIMSKx TIMSK |
| 141 | # else | 141 | # else |
| 142 | # define TIMSKx TIMSK1 | 142 | # define TIMSKx TIMSK1 |
| @@ -166,7 +166,7 @@ error("Please set 'BACKLIGHT_DRIVER = custom' within rules.mk") | |||
| 166 | error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk") | 166 | error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk") |
| 167 | #endif | 167 | #endif |
| 168 | 168 | ||
| 169 | #ifndef BACKLIGHT_PWM_TIMER // pwm through software | 169 | #ifndef BACKLIGHT_PWM_TIMER // pwm through software |
| 170 | 170 | ||
| 171 | static inline void enable_pwm(void) { | 171 | static inline void enable_pwm(void) { |
| 172 | # if BACKLIGHT_ON_STATE == 1 | 172 | # if BACKLIGHT_ON_STATE == 1 |
| @@ -203,7 +203,9 @@ static inline void disable_pwm(void) { | |||
| 203 | // or F_CPU/BACKLIGHT_CUSTOM_RESOLUTION if used. | 203 | // or F_CPU/BACKLIGHT_CUSTOM_RESOLUTION if used. |
| 204 | 204 | ||
| 205 | // Triggered when the counter reaches the OCRx value | 205 | // Triggered when the counter reaches the OCRx value |
| 206 | ISR(TIMERx_COMPA_vect) { backlight_pins_off(); } | 206 | ISR(TIMERx_COMPA_vect) { |
| 207 | backlight_pins_off(); | ||
| 208 | } | ||
| 207 | 209 | ||
| 208 | // Triggered when the counter reaches the TOP value | 210 | // Triggered when the counter reaches the TOP value |
| 209 | // this one triggers at F_CPU/ICRx = 16MHz/65536 =~ 244 Hz | 211 | // this one triggers at F_CPU/ICRx = 16MHz/65536 =~ 244 Hz |
| @@ -232,15 +234,15 @@ ISR(TIMERx_OVF_vect) { | |||
| 232 | 234 | ||
| 233 | // See http://jared.geek.nz/2013/feb/linear-led-pwm | 235 | // See http://jared.geek.nz/2013/feb/linear-led-pwm |
| 234 | static uint16_t cie_lightness(uint16_t v) { | 236 | static uint16_t cie_lightness(uint16_t v) { |
| 235 | if (v <= (uint32_t)ICRx / 12) // If the value is less than or equal to ~8% of max | 237 | if (v <= (uint32_t)ICRx / 12) // If the value is less than or equal to ~8% of max |
| 236 | { | 238 | { |
| 237 | return v / 9; // Same as dividing by 900% | 239 | return v / 9; // Same as dividing by 900% |
| 238 | } else { | 240 | } else { |
| 239 | // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math. | 241 | // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math. |
| 240 | uint32_t y = (((uint32_t)v + (uint32_t)ICRx / 6) << 5) / ((uint32_t)ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) | 242 | uint32_t y = (((uint32_t)v + (uint32_t)ICRx / 6) << 5) / ((uint32_t)ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) |
| 241 | uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) | 243 | uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) |
| 242 | 244 | ||
| 243 | if (out > ICRx) // Avoid overflows | 245 | if (out > ICRx) // Avoid overflows |
| 244 | { | 246 | { |
| 245 | out = ICRx; | 247 | out = ICRx; |
| 246 | } | 248 | } |
| @@ -249,10 +251,14 @@ static uint16_t cie_lightness(uint16_t v) { | |||
| 249 | } | 251 | } |
| 250 | 252 | ||
| 251 | // rescale the supplied backlight value to be in terms of the value limit // range for val is [0..ICRx]. PWM pin is high while the timer count is below val. | 253 | // rescale the supplied backlight value to be in terms of the value limit // range for val is [0..ICRx]. PWM pin is high while the timer count is below val. |
| 252 | static uint32_t rescale_limit_val(uint32_t val) { return (val * (BACKLIGHT_LIMIT_VAL + 1)) / 256; } | 254 | static uint32_t rescale_limit_val(uint32_t val) { |
| 255 | return (val * (BACKLIGHT_LIMIT_VAL + 1)) / 256; | ||
| 256 | } | ||
| 253 | 257 | ||
| 254 | // range for val is [0..ICRx]. PWM pin is high while the timer count is below val. | 258 | // range for val is [0..ICRx]. PWM pin is high while the timer count is below val. |
| 255 | static inline void set_pwm(uint16_t val) { OCRxx = val; } | 259 | static inline void set_pwm(uint16_t val) { |
| 260 | OCRxx = val; | ||
| 261 | } | ||
| 256 | 262 | ||
| 257 | void backlight_set(uint8_t level) { | 263 | void backlight_set(uint8_t level) { |
| 258 | if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; | 264 | if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; |
| @@ -303,7 +309,9 @@ static uint16_t breathing_freq_scale_factor = 2; | |||
| 303 | # ifdef BACKLIGHT_PWM_TIMER | 309 | # ifdef BACKLIGHT_PWM_TIMER |
| 304 | static bool breathing = false; | 310 | static bool breathing = false; |
| 305 | 311 | ||
| 306 | bool is_breathing(void) { return breathing; } | 312 | bool is_breathing(void) { |
| 313 | return breathing; | ||
| 314 | } | ||
| 307 | 315 | ||
| 308 | # define breathing_interrupt_enable() \ | 316 | # define breathing_interrupt_enable() \ |
| 309 | do { \ | 317 | do { \ |
| @@ -315,7 +323,9 @@ bool is_breathing(void) { return breathing; } | |||
| 315 | } while (0) | 323 | } while (0) |
| 316 | # else | 324 | # else |
| 317 | 325 | ||
| 318 | bool is_breathing(void) { return !!(TIMSKx & _BV(TOIEx)); } | 326 | bool is_breathing(void) { |
| 327 | return !!(TIMSKx & _BV(TOIEx)); | ||
| 328 | } | ||
| 319 | 329 | ||
| 320 | # define breathing_interrupt_enable() \ | 330 | # define breathing_interrupt_enable() \ |
| 321 | do { \ | 331 | do { \ |
| @@ -370,7 +380,9 @@ void breathing_self_disable(void) { | |||
| 370 | static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 380 | static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 371 | 381 | ||
| 372 | // Use this before the cie_lightness function. | 382 | // Use this before the cie_lightness function. |
| 373 | static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } | 383 | static inline uint16_t scale_backlight(uint16_t v) { |
| 384 | return v / BACKLIGHT_LEVELS * get_backlight_level(); | ||
| 385 | } | ||
| 374 | 386 | ||
| 375 | # ifdef BACKLIGHT_PWM_TIMER | 387 | # ifdef BACKLIGHT_PWM_TIMER |
| 376 | void breathing_task(void) | 388 | void breathing_task(void) |
| @@ -403,7 +415,7 @@ ISR(TIMERx_OVF_vect) | |||
| 403 | set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255)))); | 415 | set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255)))); |
| 404 | } | 416 | } |
| 405 | 417 | ||
| 406 | #endif // BACKLIGHT_BREATHING | 418 | #endif // BACKLIGHT_BREATHING |
| 407 | 419 | ||
| 408 | void backlight_init_ports(void) { | 420 | void backlight_init_ports(void) { |
| 409 | // Setup backlight pin as output and output to on state. | 421 | // Setup backlight pin as output and output to on state. |
| @@ -415,10 +427,10 @@ void backlight_init_ports(void) { | |||
| 415 | 427 | ||
| 416 | #ifdef BACKLIGHT_PWM_TIMER | 428 | #ifdef BACKLIGHT_PWM_TIMER |
| 417 | // TimerX setup, Fast PWM mode count to TOP set in ICRx | 429 | // TimerX setup, Fast PWM mode count to TOP set in ICRx |
| 418 | TCCRxA = _BV(WGM11); // = 0b00000010; | 430 | TCCRxA = _BV(WGM11); // = 0b00000010; |
| 419 | // clock select clk/1 | 431 | // clock select clk/1 |
| 420 | TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | 432 | TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; |
| 421 | #else // hardware PWM | 433 | #else // hardware PWM |
| 422 | // Pin PB7 = OCR1C (Timer 1, Channel C) | 434 | // Pin PB7 = OCR1C (Timer 1, Channel C) |
| 423 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 | 435 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 |
| 424 | // (i.e. start high, go low when counter matches.) | 436 | // (i.e. start high, go low when counter matches.) |
| @@ -430,8 +442,8 @@ void backlight_init_ports(void) { | |||
| 430 | "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]." | 442 | "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]." |
| 431 | "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)." | 443 | "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)." |
| 432 | */ | 444 | */ |
| 433 | TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; | 445 | TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; |
| 434 | TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | 446 | TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; |
| 435 | #endif | 447 | #endif |
| 436 | 448 | ||
| 437 | #ifdef BACKLIGHT_CUSTOM_RESOLUTION | 449 | #ifdef BACKLIGHT_CUSTOM_RESOLUTION |
diff --git a/quantum/backlight/backlight_chibios.c b/quantum/backlight/backlight_chibios.c index 7c6edd10d6..e8f9e70f78 100644 --- a/quantum/backlight/backlight_chibios.c +++ b/quantum/backlight/backlight_chibios.c | |||
| @@ -53,14 +53,14 @@ static PWMConfig pwmCFG = {0xFFFF, /* PWM clock frequency */ | |||
| 53 | 53 | ||
| 54 | // See http://jared.geek.nz/2013/feb/linear-led-pwm | 54 | // See http://jared.geek.nz/2013/feb/linear-led-pwm |
| 55 | static uint16_t cie_lightness(uint16_t v) { | 55 | static uint16_t cie_lightness(uint16_t v) { |
| 56 | if (v <= 5243) // if below 8% of max | 56 | if (v <= 5243) // if below 8% of max |
| 57 | return v / 9; // same as dividing by 900% | 57 | return v / 9; // same as dividing by 900% |
| 58 | else { | 58 | else { |
| 59 | uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare | 59 | uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare |
| 60 | // to get a useful result with integer division, we shift left in the expression above | 60 | // to get a useful result with integer division, we shift left in the expression above |
| 61 | // and revert what we've done again after squaring. | 61 | // and revert what we've done again after squaring. |
| 62 | y = y * y * y >> 8; | 62 | y = y * y * y >> 8; |
| 63 | if (y > 0xFFFFUL) // prevent overflow | 63 | if (y > 0xFFFFUL) // prevent overflow |
| 64 | return 0xFFFFU; | 64 | return 0xFFFFU; |
| 65 | else | 65 | else |
| 66 | return (uint16_t)y; | 66 | return (uint16_t)y; |
| @@ -117,7 +117,9 @@ static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, | |||
| 117 | 117 | ||
| 118 | void breathing_callback(PWMDriver *pwmp); | 118 | void breathing_callback(PWMDriver *pwmp); |
| 119 | 119 | ||
| 120 | bool is_breathing(void) { return pwmCFG.callback != NULL; } | 120 | bool is_breathing(void) { |
| 121 | return pwmCFG.callback != NULL; | ||
| 122 | } | ||
| 121 | 123 | ||
| 122 | void breathing_enable(void) { | 124 | void breathing_enable(void) { |
| 123 | pwmCFG.callback = breathing_callback; | 125 | pwmCFG.callback = breathing_callback; |
| @@ -133,7 +135,9 @@ void breathing_disable(void) { | |||
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | // Use this before the cie_lightness function. | 137 | // Use this before the cie_lightness function. |
| 136 | static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } | 138 | static inline uint16_t scale_backlight(uint16_t v) { |
| 139 | return v / BACKLIGHT_LEVELS * get_backlight_level(); | ||
| 140 | } | ||
| 137 | 141 | ||
| 138 | void breathing_callback(PWMDriver *pwmp) { | 142 | void breathing_callback(PWMDriver *pwmp) { |
| 139 | uint8_t breathing_period = get_breathing_period(); | 143 | uint8_t breathing_period = get_breathing_period(); |
diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c index 270a43c67e..e4c2e90b5f 100644 --- a/quantum/backlight/backlight_driver_common.c +++ b/quantum/backlight/backlight_driver_common.c | |||
| @@ -44,6 +44,10 @@ void backlight_pins_init(void) { | |||
| 44 | FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) | 44 | FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) } | 47 | void backlight_pins_on(void) { |
| 48 | FOR_EACH_LED(backlight_on(backlight_pin);) | ||
| 49 | } | ||
| 48 | 50 | ||
| 49 | void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) } | 51 | void backlight_pins_off(void) { |
| 52 | FOR_EACH_LED(backlight_off(backlight_pin);) | ||
| 53 | } | ||
diff --git a/quantum/backlight/backlight_software.c b/quantum/backlight/backlight_software.c index 709304f559..3d412cab52 100644 --- a/quantum/backlight/backlight_software.c +++ b/quantum/backlight/backlight_software.c | |||
| @@ -30,11 +30,17 @@ static const uint16_t backlight_duty_table[] = { | |||
| 30 | 30 | ||
| 31 | // clang-format on | 31 | // clang-format on |
| 32 | 32 | ||
| 33 | static uint8_t scale_backlight(uint8_t v) { return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS; } | 33 | static uint8_t scale_backlight(uint8_t v) { |
| 34 | return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS; | ||
| 35 | } | ||
| 34 | 36 | ||
| 35 | void backlight_init_ports(void) { backlight_pins_init(); } | 37 | void backlight_init_ports(void) { |
| 38 | backlight_pins_init(); | ||
| 39 | } | ||
| 36 | 40 | ||
| 37 | void backlight_set(uint8_t level) { s_duty_pattern = backlight_duty_table[scale_backlight(level)]; } | 41 | void backlight_set(uint8_t level) { |
| 42 | s_duty_pattern = backlight_duty_table[scale_backlight(level)]; | ||
| 43 | } | ||
| 38 | 44 | ||
| 39 | void backlight_task(void) { | 45 | void backlight_task(void) { |
| 40 | static uint8_t backlight_tick = 0; | 46 | static uint8_t backlight_tick = 0; |
diff --git a/quantum/backlight/backlight_timer.c b/quantum/backlight/backlight_timer.c index c32c35c154..82fb6a6a83 100644 --- a/quantum/backlight/backlight_timer.c +++ b/quantum/backlight/backlight_timer.c | |||
| @@ -14,14 +14,14 @@ static uint16_t backlight_timer_get_duty(void); | |||
| 14 | 14 | ||
| 15 | // See http://jared.geek.nz/2013/feb/linear-led-pwm | 15 | // See http://jared.geek.nz/2013/feb/linear-led-pwm |
| 16 | static uint16_t cie_lightness(uint16_t v) { | 16 | static uint16_t cie_lightness(uint16_t v) { |
| 17 | if (v <= 5243) // if below 8% of max | 17 | if (v <= 5243) // if below 8% of max |
| 18 | return v / 9; // same as dividing by 900% | 18 | return v / 9; // same as dividing by 900% |
| 19 | else { | 19 | else { |
| 20 | uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare | 20 | uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare |
| 21 | // to get a useful result with integer division, we shift left in the expression above | 21 | // to get a useful result with integer division, we shift left in the expression above |
| 22 | // and revert what we've done again after squaring. | 22 | // and revert what we've done again after squaring. |
| 23 | y = y * y * y >> 8; | 23 | y = y * y * y >> 8; |
| 24 | if (y > 0xFFFFUL) // prevent overflow | 24 | if (y > 0xFFFFUL) // prevent overflow |
| 25 | return 0xFFFFU; | 25 | return 0xFFFFU; |
| 26 | else | 26 | else |
| 27 | return (uint16_t)y; | 27 | return (uint16_t)y; |
| @@ -61,7 +61,9 @@ static void backlight_timer_top(void) { | |||
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static void backlight_timer_cmp(void) { backlight_pins_off(); } | 64 | static void backlight_timer_cmp(void) { |
| 65 | backlight_pins_off(); | ||
| 66 | } | ||
| 65 | 67 | ||
| 66 | void backlight_task(void) {} | 68 | void backlight_task(void) {} |
| 67 | 69 | ||
| @@ -77,7 +79,9 @@ static uint16_t breathing_counter = 0; | |||
| 77 | static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 79 | static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 78 | 80 | ||
| 79 | // Use this before the cie_lightness function. | 81 | // Use this before the cie_lightness function. |
| 80 | static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } | 82 | static inline uint16_t scale_backlight(uint16_t v) { |
| 83 | return v / BACKLIGHT_LEVELS * get_backlight_level(); | ||
| 84 | } | ||
| 81 | 85 | ||
| 82 | void breathing_task(void) { | 86 | void breathing_task(void) { |
| 83 | uint8_t breathing_period = get_breathing_period(); | 87 | uint8_t breathing_period = get_breathing_period(); |
| @@ -91,13 +95,17 @@ void breathing_task(void) { | |||
| 91 | backlight_timer_set_duty(cie_lightness(scale_backlight((uint16_t)breathing_table[index] * 256))); | 95 | backlight_timer_set_duty(cie_lightness(scale_backlight((uint16_t)breathing_table[index] * 256))); |
| 92 | } | 96 | } |
| 93 | 97 | ||
| 94 | bool is_breathing(void) { return breathing; } | 98 | bool is_breathing(void) { |
| 99 | return breathing; | ||
| 100 | } | ||
| 95 | 101 | ||
| 96 | void breathing_enable(void) { | 102 | void breathing_enable(void) { |
| 97 | breathing_counter = 0; | 103 | breathing_counter = 0; |
| 98 | breathing = true; | 104 | breathing = true; |
| 99 | } | 105 | } |
| 100 | void breathing_disable(void) { breathing = false; } | 106 | void breathing_disable(void) { |
| 107 | breathing = false; | ||
| 108 | } | ||
| 101 | 109 | ||
| 102 | void breathing_pulse(void) { | 110 | void breathing_pulse(void) { |
| 103 | backlight_set(is_backlight_enabled() ? 0 : BACKLIGHT_LEVELS); | 111 | backlight_set(is_backlight_enabled() ? 0 : BACKLIGHT_LEVELS); |
| @@ -140,8 +148,12 @@ static void timerCallback(void) { | |||
| 140 | } | 148 | } |
| 141 | } | 149 | } |
| 142 | 150 | ||
| 143 | static void backlight_timer_set_duty(uint16_t duty) { s_duty = duty; } | 151 | static void backlight_timer_set_duty(uint16_t duty) { |
| 144 | static uint16_t backlight_timer_get_duty(void) { return s_duty; } | 152 | s_duty = duty; |
| 153 | } | ||
| 154 | static uint16_t backlight_timer_get_duty(void) { | ||
| 155 | return s_duty; | ||
| 156 | } | ||
| 145 | 157 | ||
| 146 | // ChibiOS - Map GPT timer onto Software PWM | 158 | // ChibiOS - Map GPT timer onto Software PWM |
| 147 | static void gptTimerCallback(GPTDriver *gptp) { | 159 | static void gptTimerCallback(GPTDriver *gptp) { |
diff --git a/quantum/bitwise.c b/quantum/bitwise.c index 861cca0054..1868e14932 100644 --- a/quantum/bitwise.c +++ b/quantum/bitwise.c | |||
| @@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | // bit population - return number of on-bit | 20 | // bit population - return number of on-bit |
| 21 | __attribute__((noinline)) uint8_t bitpop(uint8_t bits) { | 21 | __attribute__((noinline)) uint8_t bitpop(uint8_t bits) { |
| 22 | uint8_t c; | 22 | uint8_t c; |
| 23 | for (c = 0; bits; c++) bits &= bits - 1; | 23 | for (c = 0; bits; c++) |
| 24 | bits &= bits - 1; | ||
| 24 | return c; | 25 | return c; |
| 25 | /* | 26 | /* |
| 26 | const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; | 27 | const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; |
| @@ -30,13 +31,15 @@ __attribute__((noinline)) uint8_t bitpop(uint8_t bits) { | |||
| 30 | 31 | ||
| 31 | uint8_t bitpop16(uint16_t bits) { | 32 | uint8_t bitpop16(uint16_t bits) { |
| 32 | uint8_t c; | 33 | uint8_t c; |
| 33 | for (c = 0; bits; c++) bits &= bits - 1; | 34 | for (c = 0; bits; c++) |
| 35 | bits &= bits - 1; | ||
| 34 | return c; | 36 | return c; |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | uint8_t bitpop32(uint32_t bits) { | 39 | uint8_t bitpop32(uint32_t bits) { |
| 38 | uint8_t c; | 40 | uint8_t c; |
| 39 | for (c = 0; bits; c++) bits &= bits - 1; | 41 | for (c = 0; bits; c++) |
| 42 | bits &= bits - 1; | ||
| 40 | return c; | 43 | return c; |
| 41 | } | 44 | } |
| 42 | 45 | ||
diff --git a/quantum/bootmagic/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c index 54bbf5a2ee..f63c71fc6b 100644 --- a/quantum/bootmagic/bootmagic_lite.c +++ b/quantum/bootmagic/bootmagic_lite.c | |||
| @@ -19,7 +19,9 @@ | |||
| 19 | * | 19 | * |
| 20 | * ...just incase someone wants to only change the eeprom behaviour | 20 | * ...just incase someone wants to only change the eeprom behaviour |
| 21 | */ | 21 | */ |
| 22 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { eeconfig_disable(); } | 22 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { |
| 23 | eeconfig_disable(); | ||
| 24 | } | ||
| 23 | 25 | ||
| 24 | /** \brief The lite version of TMK's bootmagic based on Wilba. | 26 | /** \brief The lite version of TMK's bootmagic based on Wilba. |
| 25 | * | 27 | * |
| @@ -57,4 +59,6 @@ __attribute__((weak)) void bootmagic_lite(void) { | |||
| 57 | } | 59 | } |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | void bootmagic(void) { bootmagic_lite(); } | 62 | void bootmagic(void) { |
| 63 | bootmagic_lite(); | ||
| 64 | } | ||
diff --git a/quantum/color.c b/quantum/color.c index 1c5128e4a2..c80078dbf2 100644 --- a/quantum/color.c +++ b/quantum/color.c | |||
| @@ -104,7 +104,9 @@ RGB hsv_to_rgb(HSV hsv) { | |||
| 104 | #endif | 104 | #endif |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); } | 107 | RGB hsv_to_rgb_nocie(HSV hsv) { |
| 108 | return hsv_to_rgb_impl(hsv, false); | ||
| 109 | } | ||
| 108 | 110 | ||
| 109 | #ifdef RGBW | 111 | #ifdef RGBW |
| 110 | # ifndef MIN | 112 | # ifndef MIN |
diff --git a/quantum/command.c b/quantum/command.c index 6d56a25ea1..f90d73207c 100644 --- a/quantum/command.c +++ b/quantum/command.c | |||
| @@ -446,7 +446,7 @@ static bool command_common(uint8_t code) { | |||
| 446 | 446 | ||
| 447 | // NKRO toggle | 447 | // NKRO toggle |
| 448 | case MAGIC_KC(MAGIC_KEY_NKRO): | 448 | case MAGIC_KC(MAGIC_KEY_NKRO): |
| 449 | clear_keyboard(); // clear to prevent stuck keys | 449 | clear_keyboard(); // clear to prevent stuck keys |
| 450 | keymap_config.nkro = !keymap_config.nkro; | 450 | keymap_config.nkro = !keymap_config.nkro; |
| 451 | if (keymap_config.nkro) { | 451 | if (keymap_config.nkro) { |
| 452 | print("NKRO: on\n"); | 452 | print("NKRO: on\n"); |
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c index 8cac1c37f9..47450992a4 100644 --- a/quantum/debounce/sym_defer_g.c +++ b/quantum/debounce/sym_defer_g.c | |||
| @@ -45,6 +45,6 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void debounce_free(void) {} | 47 | void debounce_free(void) {} |
| 48 | #else // no debouncing. | 48 | #else // no debouncing. |
| 49 | # include "none.c" | 49 | # include "none.c" |
| 50 | #endif | 50 | #endif |
diff --git a/quantum/debounce/sym_defer_pr.c b/quantum/debounce/sym_defer_pr.c index 8b33acc6a2..ce24f0922f 100644 --- a/quantum/debounce/sym_defer_pr.c +++ b/quantum/debounce/sym_defer_pr.c | |||
| @@ -69,4 +69,6 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | bool debounce_active(void) { return true; } | 72 | bool debounce_active(void) { |
| 73 | return true; | ||
| 74 | } | ||
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c index deec463649..fe3e88bb06 100644 --- a/quantum/debounce/sym_eager_pk.c +++ b/quantum/debounce/sym_eager_pk.c | |||
| @@ -131,7 +131,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui | |||
| 131 | if (*debounce_pointer == DEBOUNCE_ELAPSED) { | 131 | if (*debounce_pointer == DEBOUNCE_ELAPSED) { |
| 132 | *debounce_pointer = DEBOUNCE; | 132 | *debounce_pointer = DEBOUNCE; |
| 133 | counters_need_update = true; | 133 | counters_need_update = true; |
| 134 | existing_row ^= col_mask; // flip the bit. | 134 | existing_row ^= col_mask; // flip the bit. |
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | debounce_pointer++; | 137 | debounce_pointer++; |
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp index f9414e571d..0d5a7bb766 100644 --- a/quantum/debounce/tests/debounce_test_common.cpp +++ b/quantum/debounce/tests/debounce_test_common.cpp | |||
| @@ -31,7 +31,9 @@ void set_time(uint32_t t); | |||
| 31 | void advance_time(uint32_t ms); | 31 | void advance_time(uint32_t ms); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { events_.insert(events_.end(), events.begin(), events.end()); } | 34 | void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { |
| 35 | events_.insert(events_.end(), events.begin(), events.end()); | ||
| 36 | } | ||
| 35 | 37 | ||
| 36 | void DebounceTest::runEvents() { | 38 | void DebounceTest::runEvents() { |
| 37 | /* Run the test multiple times, from 1kHz to 10kHz scan rate */ | 39 | /* Run the test multiple times, from 1kHz to 10kHz scan rate */ |
diff --git a/quantum/deferred_exec.c b/quantum/deferred_exec.c index a64b451df2..a0046a9648 100644 --- a/quantum/deferred_exec.c +++ b/quantum/deferred_exec.c | |||
| @@ -157,7 +157,15 @@ void deferred_exec_advanced_task(deferred_executor_t *table, size_t table_count, | |||
| 157 | static uint32_t last_deferred_exec_check = 0; | 157 | static uint32_t last_deferred_exec_check = 0; |
| 158 | static deferred_executor_t basic_executors[MAX_DEFERRED_EXECUTORS] = {0}; | 158 | static deferred_executor_t basic_executors[MAX_DEFERRED_EXECUTORS] = {0}; |
| 159 | 159 | ||
| 160 | deferred_token defer_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) { return defer_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, delay_ms, callback, cb_arg); } | 160 | deferred_token defer_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) { |
| 161 | bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) { return extend_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token, delay_ms); } | 161 | return defer_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, delay_ms, callback, cb_arg); |
| 162 | bool cancel_deferred_exec(deferred_token token) { return cancel_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token); } | 162 | } |
| 163 | void deferred_exec_task(void) { deferred_exec_advanced_task(basic_executors, MAX_DEFERRED_EXECUTORS, &last_deferred_exec_check); } | 163 | bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) { |
| 164 | return extend_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token, delay_ms); | ||
| 165 | } | ||
| 166 | bool cancel_deferred_exec(deferred_token token) { | ||
| 167 | return cancel_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token); | ||
| 168 | } | ||
| 169 | void deferred_exec_task(void) { | ||
| 170 | deferred_exec_advanced_task(basic_executors, MAX_DEFERRED_EXECUTORS, &last_deferred_exec_check); | ||
| 171 | } | ||
diff --git a/quantum/digitizer.c b/quantum/digitizer.c index e299867429..7925129d0c 100644 --- a/quantum/digitizer.c +++ b/quantum/digitizer.c | |||
| @@ -24,9 +24,13 @@ __attribute__((weak)) void digitizer_send(void) { | |||
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | __attribute__((weak)) void digitizer_task(void) { digitizer_send(); } | 27 | __attribute__((weak)) void digitizer_task(void) { |
| 28 | digitizer_send(); | ||
| 29 | } | ||
| 28 | 30 | ||
| 29 | digitizer_t digitizer_get_report(void) { return digitizerReport; } | 31 | digitizer_t digitizer_get_report(void) { |
| 32 | return digitizerReport; | ||
| 33 | } | ||
| 30 | 34 | ||
| 31 | void digitizer_set_report(digitizer_t newDigitizerReport) { | 35 | void digitizer_set_report(digitizer_t newDigitizerReport) { |
| 32 | digitizerReport = newDigitizerReport; | 36 | digitizerReport = newDigitizerReport; |
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index 133ec85027..eee29aaf91 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c | |||
| @@ -52,13 +52,21 @@ static uint16_t scan_count; | |||
| 52 | static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; | 52 | static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; |
| 53 | static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; | 53 | static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; |
| 54 | 54 | ||
| 55 | __attribute__((weak)) bool dip_switch_update_user(uint8_t index, bool active) { return true; } | 55 | __attribute__((weak)) bool dip_switch_update_user(uint8_t index, bool active) { |
| 56 | return true; | ||
| 57 | } | ||
| 56 | 58 | ||
| 57 | __attribute__((weak)) bool dip_switch_update_kb(uint8_t index, bool active) { return dip_switch_update_user(index, active); } | 59 | __attribute__((weak)) bool dip_switch_update_kb(uint8_t index, bool active) { |
| 60 | return dip_switch_update_user(index, active); | ||
| 61 | } | ||
| 58 | 62 | ||
| 59 | __attribute__((weak)) bool dip_switch_update_mask_user(uint32_t state) { return true; } | 63 | __attribute__((weak)) bool dip_switch_update_mask_user(uint32_t state) { |
| 64 | return true; | ||
| 65 | } | ||
| 60 | 66 | ||
| 61 | __attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) { return dip_switch_update_mask_user(state); } | 67 | __attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) { |
| 68 | return dip_switch_update_mask_user(state); | ||
| 69 | } | ||
| 62 | 70 | ||
| 63 | void dip_switch_init(void) { | 71 | void dip_switch_init(void) { |
| 64 | #ifdef DIP_SWITCH_PINS | 72 | #ifdef DIP_SWITCH_PINS |
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 8f1f39bc0f..f070375ff3 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c | |||
| @@ -14,12 +14,12 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "keymap.h" // to get keymaps[][][] | 17 | #include "keymap.h" // to get keymaps[][][] |
| 18 | #include "eeprom.h" | 18 | #include "eeprom.h" |
| 19 | #include "progmem.h" // to read default from flash | 19 | #include "progmem.h" // to read default from flash |
| 20 | #include "quantum.h" // for send_string() | 20 | #include "quantum.h" // for send_string() |
| 21 | #include "dynamic_keymap.h" | 21 | #include "dynamic_keymap.h" |
| 22 | #include "via.h" // for default VIA_EEPROM_ADDR_END | 22 | #include "via.h" // for default VIA_EEPROM_ADDR_END |
| 23 | 23 | ||
| 24 | #ifndef DYNAMIC_KEYMAP_LAYER_COUNT | 24 | #ifndef DYNAMIC_KEYMAP_LAYER_COUNT |
| 25 | # define DYNAMIC_KEYMAP_LAYER_COUNT 4 | 25 | # define DYNAMIC_KEYMAP_LAYER_COUNT 4 |
| @@ -79,7 +79,9 @@ | |||
| 79 | # define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) | 79 | # define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; } | 82 | uint8_t dynamic_keymap_get_layer_count(void) { |
| 83 | return DYNAMIC_KEYMAP_LAYER_COUNT; | ||
| 84 | } | ||
| 83 | 85 | ||
| 84 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { | 86 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { |
| 85 | // TODO: optimize this with some left shifts | 87 | // TODO: optimize this with some left shifts |
| @@ -151,9 +153,13 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { | |||
| 151 | } | 153 | } |
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | uint8_t dynamic_keymap_macro_get_count(void) { return DYNAMIC_KEYMAP_MACRO_COUNT; } | 156 | uint8_t dynamic_keymap_macro_get_count(void) { |
| 157 | return DYNAMIC_KEYMAP_MACRO_COUNT; | ||
| 158 | } | ||
| 155 | 159 | ||
| 156 | uint16_t dynamic_keymap_macro_get_buffer_size(void) { return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; } | 160 | uint16_t dynamic_keymap_macro_get_buffer_size(void) { |
| 161 | return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; | ||
| 162 | } | ||
| 157 | 163 | ||
| 158 | void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { | 164 | void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { |
| 159 | void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); | 165 | void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); |
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 4c2ad2490c..14cd5887f4 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c | |||
| @@ -49,7 +49,7 @@ void eeconfig_init_quantum(void) { | |||
| 49 | eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0); | 49 | eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0); |
| 50 | eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); | 50 | eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); |
| 51 | eeprom_update_byte(EECONFIG_BACKLIGHT, 0); | 51 | eeprom_update_byte(EECONFIG_BACKLIGHT, 0); |
| 52 | eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default | 52 | eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default |
| 53 | eeprom_update_dword(EECONFIG_RGBLIGHT, 0); | 53 | eeprom_update_dword(EECONFIG_RGBLIGHT, 0); |
| 54 | eeprom_update_byte(EECONFIG_STENOMODE, 0); | 54 | eeprom_update_byte(EECONFIG_STENOMODE, 0); |
| 55 | eeprom_update_dword(EECONFIG_HAPTIC, 0); | 55 | eeprom_update_dword(EECONFIG_HAPTIC, 0); |
| @@ -90,13 +90,17 @@ void eeconfig_init_quantum(void) { | |||
| 90 | * | 90 | * |
| 91 | * FIXME: needs doc | 91 | * FIXME: needs doc |
| 92 | */ | 92 | */ |
| 93 | void eeconfig_init(void) { eeconfig_init_quantum(); } | 93 | void eeconfig_init(void) { |
| 94 | eeconfig_init_quantum(); | ||
| 95 | } | ||
| 94 | 96 | ||
| 95 | /** \brief eeconfig enable | 97 | /** \brief eeconfig enable |
| 96 | * | 98 | * |
| 97 | * FIXME: needs doc | 99 | * FIXME: needs doc |
| 98 | */ | 100 | */ |
| 99 | void eeconfig_enable(void) { eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); } | 101 | void eeconfig_enable(void) { |
| 102 | eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); | ||
| 103 | } | ||
| 100 | 104 | ||
| 101 | /** \brief eeconfig disable | 105 | /** \brief eeconfig disable |
| 102 | * | 106 | * |
| @@ -141,29 +145,39 @@ bool eeconfig_is_disabled(void) { | |||
| 141 | * | 145 | * |
| 142 | * FIXME: needs doc | 146 | * FIXME: needs doc |
| 143 | */ | 147 | */ |
| 144 | uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } | 148 | uint8_t eeconfig_read_debug(void) { |
| 149 | return eeprom_read_byte(EECONFIG_DEBUG); | ||
| 150 | } | ||
| 145 | /** \brief eeconfig update debug | 151 | /** \brief eeconfig update debug |
| 146 | * | 152 | * |
| 147 | * FIXME: needs doc | 153 | * FIXME: needs doc |
| 148 | */ | 154 | */ |
| 149 | void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); } | 155 | void eeconfig_update_debug(uint8_t val) { |
| 156 | eeprom_update_byte(EECONFIG_DEBUG, val); | ||
| 157 | } | ||
| 150 | 158 | ||
| 151 | /** \brief eeconfig read default layer | 159 | /** \brief eeconfig read default layer |
| 152 | * | 160 | * |
| 153 | * FIXME: needs doc | 161 | * FIXME: needs doc |
| 154 | */ | 162 | */ |
| 155 | uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } | 163 | uint8_t eeconfig_read_default_layer(void) { |
| 164 | return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); | ||
| 165 | } | ||
| 156 | /** \brief eeconfig update default layer | 166 | /** \brief eeconfig update default layer |
| 157 | * | 167 | * |
| 158 | * FIXME: needs doc | 168 | * FIXME: needs doc |
| 159 | */ | 169 | */ |
| 160 | void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); } | 170 | void eeconfig_update_default_layer(uint8_t val) { |
| 171 | eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); | ||
| 172 | } | ||
| 161 | 173 | ||
| 162 | /** \brief eeconfig read keymap | 174 | /** \brief eeconfig read keymap |
| 163 | * | 175 | * |
| 164 | * FIXME: needs doc | 176 | * FIXME: needs doc |
| 165 | */ | 177 | */ |
| 166 | uint16_t eeconfig_read_keymap(void) { return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8)); } | 178 | uint16_t eeconfig_read_keymap(void) { |
| 179 | return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8)); | ||
| 180 | } | ||
| 167 | /** \brief eeconfig update keymap | 181 | /** \brief eeconfig update keymap |
| 168 | * | 182 | * |
| 169 | * FIXME: needs doc | 183 | * FIXME: needs doc |
| @@ -177,53 +191,73 @@ void eeconfig_update_keymap(uint16_t val) { | |||
| 177 | * | 191 | * |
| 178 | * FIXME: needs doc | 192 | * FIXME: needs doc |
| 179 | */ | 193 | */ |
| 180 | uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); } | 194 | uint8_t eeconfig_read_audio(void) { |
| 195 | return eeprom_read_byte(EECONFIG_AUDIO); | ||
| 196 | } | ||
| 181 | /** \brief eeconfig update audio | 197 | /** \brief eeconfig update audio |
| 182 | * | 198 | * |
| 183 | * FIXME: needs doc | 199 | * FIXME: needs doc |
| 184 | */ | 200 | */ |
| 185 | void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); } | 201 | void eeconfig_update_audio(uint8_t val) { |
| 202 | eeprom_update_byte(EECONFIG_AUDIO, val); | ||
| 203 | } | ||
| 186 | 204 | ||
| 187 | /** \brief eeconfig read kb | 205 | /** \brief eeconfig read kb |
| 188 | * | 206 | * |
| 189 | * FIXME: needs doc | 207 | * FIXME: needs doc |
| 190 | */ | 208 | */ |
| 191 | uint32_t eeconfig_read_kb(void) { return eeprom_read_dword(EECONFIG_KEYBOARD); } | 209 | uint32_t eeconfig_read_kb(void) { |
| 210 | return eeprom_read_dword(EECONFIG_KEYBOARD); | ||
| 211 | } | ||
| 192 | /** \brief eeconfig update kb | 212 | /** \brief eeconfig update kb |
| 193 | * | 213 | * |
| 194 | * FIXME: needs doc | 214 | * FIXME: needs doc |
| 195 | */ | 215 | */ |
| 196 | void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); } | 216 | void eeconfig_update_kb(uint32_t val) { |
| 217 | eeprom_update_dword(EECONFIG_KEYBOARD, val); | ||
| 218 | } | ||
| 197 | 219 | ||
| 198 | /** \brief eeconfig read user | 220 | /** \brief eeconfig read user |
| 199 | * | 221 | * |
| 200 | * FIXME: needs doc | 222 | * FIXME: needs doc |
| 201 | */ | 223 | */ |
| 202 | uint32_t eeconfig_read_user(void) { return eeprom_read_dword(EECONFIG_USER); } | 224 | uint32_t eeconfig_read_user(void) { |
| 225 | return eeprom_read_dword(EECONFIG_USER); | ||
| 226 | } | ||
| 203 | /** \brief eeconfig update user | 227 | /** \brief eeconfig update user |
| 204 | * | 228 | * |
| 205 | * FIXME: needs doc | 229 | * FIXME: needs doc |
| 206 | */ | 230 | */ |
| 207 | void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); } | 231 | void eeconfig_update_user(uint32_t val) { |
| 232 | eeprom_update_dword(EECONFIG_USER, val); | ||
| 233 | } | ||
| 208 | 234 | ||
| 209 | /** \brief eeconfig read haptic | 235 | /** \brief eeconfig read haptic |
| 210 | * | 236 | * |
| 211 | * FIXME: needs doc | 237 | * FIXME: needs doc |
| 212 | */ | 238 | */ |
| 213 | uint32_t eeconfig_read_haptic(void) { return eeprom_read_dword(EECONFIG_HAPTIC); } | 239 | uint32_t eeconfig_read_haptic(void) { |
| 240 | return eeprom_read_dword(EECONFIG_HAPTIC); | ||
| 241 | } | ||
| 214 | /** \brief eeconfig update haptic | 242 | /** \brief eeconfig update haptic |
| 215 | * | 243 | * |
| 216 | * FIXME: needs doc | 244 | * FIXME: needs doc |
| 217 | */ | 245 | */ |
| 218 | void eeconfig_update_haptic(uint32_t val) { eeprom_update_dword(EECONFIG_HAPTIC, val); } | 246 | void eeconfig_update_haptic(uint32_t val) { |
| 247 | eeprom_update_dword(EECONFIG_HAPTIC, val); | ||
| 248 | } | ||
| 219 | 249 | ||
| 220 | /** \brief eeconfig read split handedness | 250 | /** \brief eeconfig read split handedness |
| 221 | * | 251 | * |
| 222 | * FIXME: needs doc | 252 | * FIXME: needs doc |
| 223 | */ | 253 | */ |
| 224 | bool eeconfig_read_handedness(void) { return !!eeprom_read_byte(EECONFIG_HANDEDNESS); } | 254 | bool eeconfig_read_handedness(void) { |
| 255 | return !!eeprom_read_byte(EECONFIG_HANDEDNESS); | ||
| 256 | } | ||
| 225 | /** \brief eeconfig update split handedness | 257 | /** \brief eeconfig update split handedness |
| 226 | * | 258 | * |
| 227 | * FIXME: needs doc | 259 | * FIXME: needs doc |
| 228 | */ | 260 | */ |
| 229 | void eeconfig_update_handedness(bool val) { eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); } | 261 | void eeconfig_update_handedness(bool val) { |
| 262 | eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); | ||
| 263 | } | ||
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 22d874273c..f3cd1867ab 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h | |||
| @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | 22 | ||
| 23 | #ifndef EECONFIG_MAGIC_NUMBER | 23 | #ifndef EECONFIG_MAGIC_NUMBER |
| 24 | # define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE9 // When changing, decrement this value to avoid future re-init issues | 24 | # define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE9 // When changing, decrement this value to avoid future re-init issues |
| 25 | #endif | 25 | #endif |
| 26 | #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF | 26 | #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF |
| 27 | 27 | ||
| @@ -112,28 +112,30 @@ void eeconfig_update_haptic(uint32_t val); | |||
| 112 | bool eeconfig_read_handedness(void); | 112 | bool eeconfig_read_handedness(void); |
| 113 | void eeconfig_update_handedness(bool val); | 113 | void eeconfig_update_handedness(bool val); |
| 114 | 114 | ||
| 115 | #define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ | 115 | #define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ |
| 116 | static uint8_t dirty_##name = false; \ | 116 | static uint8_t dirty_##name = false; \ |
| 117 | \ | 117 | \ |
| 118 | static inline void eeconfig_init_##name(void) { \ | 118 | static inline void eeconfig_init_##name(void) { \ |
| 119 | eeprom_read_block(&config, offset, sizeof(config)); \ | 119 | eeprom_read_block(&config, offset, sizeof(config)); \ |
| 120 | dirty_##name = false; \ | 120 | dirty_##name = false; \ |
| 121 | } \ | 121 | } \ |
| 122 | static inline void eeconfig_flush_##name(bool force) { \ | 122 | static inline void eeconfig_flush_##name(bool force) { \ |
| 123 | if (force || dirty_##name) { \ | 123 | if (force || dirty_##name) { \ |
| 124 | eeprom_update_block(&config, offset, sizeof(config)); \ | 124 | eeprom_update_block(&config, offset, sizeof(config)); \ |
| 125 | dirty_##name = false; \ | 125 | dirty_##name = false; \ |
| 126 | } \ | 126 | } \ |
| 127 | } \ | 127 | } \ |
| 128 | static inline void eeconfig_flush_##name##_task(uint16_t timeout) { \ | 128 | static inline void eeconfig_flush_##name##_task(uint16_t timeout) { \ |
| 129 | static uint16_t flush_timer = 0; \ | 129 | static uint16_t flush_timer = 0; \ |
| 130 | if (timer_elapsed(flush_timer) > timeout) { \ | 130 | if (timer_elapsed(flush_timer) > timeout) { \ |
| 131 | eeconfig_flush_##name(false); \ | 131 | eeconfig_flush_##name(false); \ |
| 132 | flush_timer = timer_read(); \ | 132 | flush_timer = timer_read(); \ |
| 133 | } \ | 133 | } \ |
| 134 | } \ | 134 | } \ |
| 135 | static inline void eeconfig_flag_##name(bool v) { dirty_##name |= v; } \ | 135 | static inline void eeconfig_flag_##name(bool v) { \ |
| 136 | static inline void eeconfig_write_##name(typeof(config) conf) { \ | 136 | dirty_##name |= v; \ |
| 137 | memcpy(&config, &conf, sizeof(config)); \ | 137 | } \ |
| 138 | eeconfig_flag_##name(true); \ | 138 | static inline void eeconfig_write_##name(typeof(config) conf) { \ |
| 139 | memcpy(&config, &conf, sizeof(config)); \ | ||
| 140 | eeconfig_flag_##name(true); \ | ||
| 139 | } | 141 | } |
diff --git a/quantum/encoder.c b/quantum/encoder.c index 8fb87281c2..59133f872a 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c | |||
| @@ -59,9 +59,13 @@ static uint8_t thisHand, thatHand; | |||
| 59 | static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; | 59 | static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } | 62 | __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { |
| 63 | return true; | ||
| 64 | } | ||
| 63 | 65 | ||
| 64 | __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } | 66 | __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { |
| 67 | return encoder_update_user(index, clockwise); | ||
| 68 | } | ||
| 65 | 69 | ||
| 66 | void encoder_init(void) { | 70 | void encoder_init(void) { |
| 67 | #if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT) | 71 | #if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT) |
| @@ -113,7 +117,7 @@ static bool encoder_update(uint8_t index, uint8_t state) { | |||
| 113 | changed = true; | 117 | changed = true; |
| 114 | encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); | 118 | encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); |
| 115 | } | 119 | } |
| 116 | if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise | 120 | if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise |
| 117 | encoder_value[index]--; | 121 | encoder_value[index]--; |
| 118 | changed = true; | 122 | changed = true; |
| 119 | encoder_update_kb(index, ENCODER_CLOCKWISE); | 123 | encoder_update_kb(index, ENCODER_CLOCKWISE); |
| @@ -140,7 +144,9 @@ bool encoder_read(void) { | |||
| 140 | #ifdef SPLIT_KEYBOARD | 144 | #ifdef SPLIT_KEYBOARD |
| 141 | void last_encoder_activity_trigger(void); | 145 | void last_encoder_activity_trigger(void); |
| 142 | 146 | ||
| 143 | void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); } | 147 | void encoder_state_raw(uint8_t* slave_state) { |
| 148 | memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); | ||
| 149 | } | ||
| 144 | 150 | ||
| 145 | void encoder_update_raw(uint8_t* slave_state) { | 151 | void encoder_update_raw(uint8_t* slave_state) { |
| 146 | bool changed = false; | 152 | bool changed = false; |
diff --git a/quantum/encoder/tests/mock.c b/quantum/encoder/tests/mock.c index d0506a938f..10a00cb8f2 100644 --- a/quantum/encoder/tests/mock.c +++ b/quantum/encoder/tests/mock.c | |||
| @@ -26,7 +26,9 @@ uint8_t mockSetPinInputHigh(pin_t pin) { | |||
| 26 | return 0; | 26 | return 0; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | bool mockReadPin(pin_t pin) { return pins[pin]; } | 29 | bool mockReadPin(pin_t pin) { |
| 30 | return pins[pin]; | ||
| 31 | } | ||
| 30 | 32 | ||
| 31 | bool setPin(pin_t pin, bool val) { | 33 | bool setPin(pin_t pin, bool val) { |
| 32 | pins[pin] = val; | 34 | pins[pin] = val; |
diff --git a/quantum/encoder/tests/mock_split.c b/quantum/encoder/tests/mock_split.c index 68bf3af599..dd3c26d958 100644 --- a/quantum/encoder/tests/mock_split.c +++ b/quantum/encoder/tests/mock_split.c | |||
| @@ -26,7 +26,9 @@ uint8_t mockSetPinInputHigh(pin_t pin) { | |||
| 26 | return 0; | 26 | return 0; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | bool mockReadPin(pin_t pin) { return pins[pin]; } | 29 | bool mockReadPin(pin_t pin) { |
| 30 | return pins[pin]; | ||
| 31 | } | ||
| 30 | 32 | ||
| 31 | bool setPin(pin_t pin, bool val) { | 33 | bool setPin(pin_t pin, bool val) { |
| 32 | pins[pin] = val; | 34 | pins[pin] = val; |
diff --git a/quantum/haptic.c b/quantum/haptic.c index f915acf946..31d1114806 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c | |||
| @@ -247,7 +247,9 @@ void haptic_set_dwell(uint8_t dwell) { | |||
| 247 | xprintf("haptic_config.dwell = %u\n", haptic_config.dwell); | 247 | xprintf("haptic_config.dwell = %u\n", haptic_config.dwell); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | uint8_t haptic_get_enable(void) { return haptic_config.enable; } | 250 | uint8_t haptic_get_enable(void) { |
| 251 | return haptic_config.enable; | ||
| 252 | } | ||
| 251 | 253 | ||
| 252 | uint8_t haptic_get_mode(void) { | 254 | uint8_t haptic_get_mode(void) { |
| 253 | if (!haptic_config.enable) { | 255 | if (!haptic_config.enable) { |
diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 6bb2800910..ba5609f0aa 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c | |||
| @@ -110,18 +110,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 110 | #endif | 110 | #endif |
| 111 | 111 | ||
| 112 | static uint32_t last_input_modification_time = 0; | 112 | static uint32_t last_input_modification_time = 0; |
| 113 | uint32_t last_input_activity_time(void) { return last_input_modification_time; } | 113 | uint32_t last_input_activity_time(void) { |
| 114 | uint32_t last_input_activity_elapsed(void) { return timer_elapsed32(last_input_modification_time); } | 114 | return last_input_modification_time; |
| 115 | } | ||
| 116 | uint32_t last_input_activity_elapsed(void) { | ||
| 117 | return timer_elapsed32(last_input_modification_time); | ||
| 118 | } | ||
| 115 | 119 | ||
| 116 | static uint32_t last_matrix_modification_time = 0; | 120 | static uint32_t last_matrix_modification_time = 0; |
| 117 | uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } | 121 | uint32_t last_matrix_activity_time(void) { |
| 118 | uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } | 122 | return last_matrix_modification_time; |
| 119 | void last_matrix_activity_trigger(void) { last_matrix_modification_time = last_input_modification_time = timer_read32(); } | 123 | } |
| 124 | uint32_t last_matrix_activity_elapsed(void) { | ||
| 125 | return timer_elapsed32(last_matrix_modification_time); | ||
| 126 | } | ||
| 127 | void last_matrix_activity_trigger(void) { | ||
| 128 | last_matrix_modification_time = last_input_modification_time = timer_read32(); | ||
| 129 | } | ||
| 120 | 130 | ||
| 121 | static uint32_t last_encoder_modification_time = 0; | 131 | static uint32_t last_encoder_modification_time = 0; |
| 122 | uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; } | 132 | uint32_t last_encoder_activity_time(void) { |
| 123 | uint32_t last_encoder_activity_elapsed(void) { return timer_elapsed32(last_encoder_modification_time); } | 133 | return last_encoder_modification_time; |
| 124 | void last_encoder_activity_trigger(void) { last_encoder_modification_time = last_input_modification_time = timer_read32(); } | 134 | } |
| 135 | uint32_t last_encoder_activity_elapsed(void) { | ||
| 136 | return timer_elapsed32(last_encoder_modification_time); | ||
| 137 | } | ||
| 138 | void last_encoder_activity_trigger(void) { | ||
| 139 | last_encoder_modification_time = last_input_modification_time = timer_read32(); | ||
| 140 | } | ||
| 125 | 141 | ||
| 126 | // Only enable this if console is enabled to print to | 142 | // Only enable this if console is enabled to print to |
| 127 | #if defined(DEBUG_MATRIX_SCAN_RATE) | 143 | #if defined(DEBUG_MATRIX_SCAN_RATE) |
| @@ -143,7 +159,9 @@ void matrix_scan_perf_task(void) { | |||
| 143 | } | 159 | } |
| 144 | } | 160 | } |
| 145 | 161 | ||
| 146 | uint32_t get_matrix_scan_rate(void) { return last_matrix_scan_count; } | 162 | uint32_t get_matrix_scan_rate(void) { |
| 163 | return last_matrix_scan_count; | ||
| 164 | } | ||
| 147 | #else | 165 | #else |
| 148 | # define matrix_scan_perf_task() | 166 | # define matrix_scan_perf_task() |
| 149 | #endif | 167 | #endif |
| @@ -163,7 +181,7 @@ static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { | |||
| 163 | } | 181 | } |
| 164 | 182 | ||
| 165 | static inline bool popcount_more_than_one(matrix_row_t rowdata) { | 183 | static inline bool popcount_more_than_one(matrix_row_t rowdata) { |
| 166 | rowdata &= rowdata - 1; // if there are less than two bits (keys) set, rowdata will become zero | 184 | rowdata &= rowdata - 1; // if there are less than two bits (keys) set, rowdata will become zero |
| 167 | return rowdata; | 185 | return rowdata; |
| 168 | } | 186 | } |
| 169 | 187 | ||
| @@ -220,7 +238,9 @@ __attribute__((weak)) void keyboard_pre_init_user(void) {} | |||
| 220 | * | 238 | * |
| 221 | * FIXME: needs doc | 239 | * FIXME: needs doc |
| 222 | */ | 240 | */ |
| 223 | __attribute__((weak)) void keyboard_pre_init_kb(void) { keyboard_pre_init_user(); } | 241 | __attribute__((weak)) void keyboard_pre_init_kb(void) { |
| 242 | keyboard_pre_init_user(); | ||
| 243 | } | ||
| 224 | 244 | ||
| 225 | /** \brief keyboard_post_init_user | 245 | /** \brief keyboard_post_init_user |
| 226 | * | 246 | * |
| @@ -234,7 +254,9 @@ __attribute__((weak)) void keyboard_post_init_user() {} | |||
| 234 | * FIXME: needs doc | 254 | * FIXME: needs doc |
| 235 | */ | 255 | */ |
| 236 | 256 | ||
| 237 | __attribute__((weak)) void keyboard_post_init_kb(void) { keyboard_post_init_user(); } | 257 | __attribute__((weak)) void keyboard_post_init_kb(void) { |
| 258 | keyboard_post_init_user(); | ||
| 259 | } | ||
| 238 | 260 | ||
| 239 | /** \brief keyboard_setup | 261 | /** \brief keyboard_setup |
| 240 | * | 262 | * |
| @@ -258,13 +280,17 @@ void keyboard_setup(void) { | |||
| 258 | * | 280 | * |
| 259 | * FIXME: needs doc | 281 | * FIXME: needs doc |
| 260 | */ | 282 | */ |
| 261 | __attribute__((weak)) bool is_keyboard_master(void) { return true; } | 283 | __attribute__((weak)) bool is_keyboard_master(void) { |
| 284 | return true; | ||
| 285 | } | ||
| 262 | 286 | ||
| 263 | /** \brief is_keyboard_left | 287 | /** \brief is_keyboard_left |
| 264 | * | 288 | * |
| 265 | * FIXME: needs doc | 289 | * FIXME: needs doc |
| 266 | */ | 290 | */ |
| 267 | __attribute__((weak)) bool is_keyboard_left(void) { return true; } | 291 | __attribute__((weak)) bool is_keyboard_left(void) { |
| 292 | return true; | ||
| 293 | } | ||
| 268 | 294 | ||
| 269 | #endif | 295 | #endif |
| 270 | 296 | ||
| @@ -273,7 +299,9 @@ __attribute__((weak)) bool is_keyboard_left(void) { return true; } | |||
| 273 | * Override this function if you have a condition where keypresses processing should change: | 299 | * Override this function if you have a condition where keypresses processing should change: |
| 274 | * - splits where the slave side needs to process for rgb/oled functionality | 300 | * - splits where the slave side needs to process for rgb/oled functionality |
| 275 | */ | 301 | */ |
| 276 | __attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); } | 302 | __attribute__((weak)) bool should_process_keypress(void) { |
| 303 | return is_keyboard_master(); | ||
| 304 | } | ||
| 277 | 305 | ||
| 278 | /** \brief housekeeping_task_kb | 306 | /** \brief housekeeping_task_kb |
| 279 | * | 307 | * |
diff --git a/quantum/keyboard.h b/quantum/keyboard.h index 9b0fb3cef8..e122b38264 100644 --- a/quantum/keyboard.h +++ b/quantum/keyboard.h | |||
| @@ -44,13 +44,21 @@ typedef struct { | |||
| 44 | * 1) (time == 0) to handle (keyevent_t){} as empty event | 44 | * 1) (time == 0) to handle (keyevent_t){} as empty event |
| 45 | * 2) Matrix(255, 255) to make TICK event available | 45 | * 2) Matrix(255, 255) to make TICK event available |
| 46 | */ | 46 | */ |
| 47 | static inline bool IS_NOEVENT(keyevent_t event) { return event.time == 0 || (event.key.row == 255 && event.key.col == 255); } | 47 | static inline bool IS_NOEVENT(keyevent_t event) { |
| 48 | static inline bool IS_PRESSED(keyevent_t event) { return (!IS_NOEVENT(event) && event.pressed); } | 48 | return event.time == 0 || (event.key.row == 255 && event.key.col == 255); |
| 49 | static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && !event.pressed); } | 49 | } |
| 50 | static inline bool IS_PRESSED(keyevent_t event) { | ||
| 51 | return (!IS_NOEVENT(event) && event.pressed); | ||
| 52 | } | ||
| 53 | static inline bool IS_RELEASED(keyevent_t event) { | ||
| 54 | return (!IS_NOEVENT(event) && !event.pressed); | ||
| 55 | } | ||
| 50 | 56 | ||
| 51 | /* Tick event */ | 57 | /* Tick event */ |
| 52 | #define TICK \ | 58 | #define TICK \ |
| 53 | (keyevent_t) { .key = (keypos_t){.row = 255, .col = 255}, .pressed = false, .time = (timer_read() | 1) } | 59 | (keyevent_t) { \ |
| 60 | .key = (keypos_t){.row = 255, .col = 255}, .pressed = false, .time = (timer_read() | 1) \ | ||
| 61 | } | ||
| 54 | 62 | ||
| 55 | /* it runs once at early stage of startup before keyboard_init. */ | 63 | /* it runs once at early stage of startup before keyboard_init. */ |
| 56 | void keyboard_setup(void); | 64 | void keyboard_setup(void); |
| @@ -68,18 +76,18 @@ void keyboard_pre_init_user(void); | |||
| 68 | void keyboard_post_init_kb(void); | 76 | void keyboard_post_init_kb(void); |
| 69 | void keyboard_post_init_user(void); | 77 | void keyboard_post_init_user(void); |
| 70 | 78 | ||
| 71 | void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol | 79 | void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol |
| 72 | void housekeeping_task_kb(void); // To be overridden by keyboard-level code | 80 | void housekeeping_task_kb(void); // To be overridden by keyboard-level code |
| 73 | void housekeeping_task_user(void); // To be overridden by user/keymap-level code | 81 | void housekeeping_task_user(void); // To be overridden by user/keymap-level code |
| 74 | 82 | ||
| 75 | uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity | 83 | uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity |
| 76 | uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity | 84 | uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity |
| 77 | 85 | ||
| 78 | uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity | 86 | uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity |
| 79 | uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity | 87 | uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity |
| 80 | 88 | ||
| 81 | uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity | 89 | uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity |
| 82 | uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity | 90 | uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity |
| 83 | 91 | ||
| 84 | uint32_t get_matrix_scan_rate(void); | 92 | uint32_t get_matrix_scan_rate(void); |
| 85 | 93 | ||
diff --git a/quantum/keycode.h b/quantum/keycode.h index a932550635..3c80a386d1 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h | |||
| @@ -251,7 +251,7 @@ enum hid_keyboard_keypad_usage { | |||
| 251 | KC_J, | 251 | KC_J, |
| 252 | KC_K, | 252 | KC_K, |
| 253 | KC_L, | 253 | KC_L, |
| 254 | KC_M, // 0x10 | 254 | KC_M, // 0x10 |
| 255 | KC_N, | 255 | KC_N, |
| 256 | KC_O, | 256 | KC_O, |
| 257 | KC_P, | 257 | KC_P, |
| @@ -267,7 +267,7 @@ enum hid_keyboard_keypad_usage { | |||
| 267 | KC_Z, | 267 | KC_Z, |
| 268 | KC_1, | 268 | KC_1, |
| 269 | KC_2, | 269 | KC_2, |
| 270 | KC_3, // 0x20 | 270 | KC_3, // 0x20 |
| 271 | KC_4, | 271 | KC_4, |
| 272 | KC_5, | 272 | KC_5, |
| 273 | KC_6, | 273 | KC_6, |
| @@ -283,7 +283,7 @@ enum hid_keyboard_keypad_usage { | |||
| 283 | KC_MINUS, | 283 | KC_MINUS, |
| 284 | KC_EQUAL, | 284 | KC_EQUAL, |
| 285 | KC_LEFT_BRACKET, | 285 | KC_LEFT_BRACKET, |
| 286 | KC_RIGHT_BRACKET, // 0x30 | 286 | KC_RIGHT_BRACKET, // 0x30 |
| 287 | KC_BACKSLASH, | 287 | KC_BACKSLASH, |
| 288 | KC_NONUS_HASH, | 288 | KC_NONUS_HASH, |
| 289 | KC_SEMICOLON, | 289 | KC_SEMICOLON, |
| @@ -299,7 +299,7 @@ enum hid_keyboard_keypad_usage { | |||
| 299 | KC_F4, | 299 | KC_F4, |
| 300 | KC_F5, | 300 | KC_F5, |
| 301 | KC_F6, | 301 | KC_F6, |
| 302 | KC_F7, // 0x40 | 302 | KC_F7, // 0x40 |
| 303 | KC_F8, | 303 | KC_F8, |
| 304 | KC_F9, | 304 | KC_F9, |
| 305 | KC_F10, | 305 | KC_F10, |
| @@ -315,7 +315,7 @@ enum hid_keyboard_keypad_usage { | |||
| 315 | KC_END, | 315 | KC_END, |
| 316 | KC_PAGE_DOWN, | 316 | KC_PAGE_DOWN, |
| 317 | KC_RIGHT, | 317 | KC_RIGHT, |
| 318 | KC_LEFT, // 0x50 | 318 | KC_LEFT, // 0x50 |
| 319 | KC_DOWN, | 319 | KC_DOWN, |
| 320 | KC_UP, | 320 | KC_UP, |
| 321 | KC_NUM_LOCK, | 321 | KC_NUM_LOCK, |
| @@ -331,7 +331,7 @@ enum hid_keyboard_keypad_usage { | |||
| 331 | KC_KP_5, | 331 | KC_KP_5, |
| 332 | KC_KP_6, | 332 | KC_KP_6, |
| 333 | KC_KP_7, | 333 | KC_KP_7, |
| 334 | KC_KP_8, // 0x60 | 334 | KC_KP_8, // 0x60 |
| 335 | KC_KP_9, | 335 | KC_KP_9, |
| 336 | KC_KP_0, | 336 | KC_KP_0, |
| 337 | KC_KP_DOT, | 337 | KC_KP_DOT, |
| @@ -347,7 +347,7 @@ enum hid_keyboard_keypad_usage { | |||
| 347 | KC_F18, | 347 | KC_F18, |
| 348 | KC_F19, | 348 | KC_F19, |
| 349 | KC_F20, | 349 | KC_F20, |
| 350 | KC_F21, // 0x70 | 350 | KC_F21, // 0x70 |
| 351 | KC_F22, | 351 | KC_F22, |
| 352 | KC_F23, | 352 | KC_F23, |
| 353 | KC_F24, | 353 | KC_F24, |
| @@ -363,7 +363,7 @@ enum hid_keyboard_keypad_usage { | |||
| 363 | KC_PASTE, | 363 | KC_PASTE, |
| 364 | KC_FIND, | 364 | KC_FIND, |
| 365 | KC_KB_MUTE, | 365 | KC_KB_MUTE, |
| 366 | KC_KB_VOLUME_UP, // 0x80 | 366 | KC_KB_VOLUME_UP, // 0x80 |
| 367 | KC_KB_VOLUME_DOWN, | 367 | KC_KB_VOLUME_DOWN, |
| 368 | KC_LOCKING_CAPS_LOCK, | 368 | KC_LOCKING_CAPS_LOCK, |
| 369 | KC_LOCKING_NUM_LOCK, | 369 | KC_LOCKING_NUM_LOCK, |
| @@ -379,7 +379,7 @@ enum hid_keyboard_keypad_usage { | |||
| 379 | KC_INTERNATIONAL_7, | 379 | KC_INTERNATIONAL_7, |
| 380 | KC_INTERNATIONAL_8, | 380 | KC_INTERNATIONAL_8, |
| 381 | KC_INTERNATIONAL_9, | 381 | KC_INTERNATIONAL_9, |
| 382 | KC_LANGUAGE_1, // 0x90 | 382 | KC_LANGUAGE_1, // 0x90 |
| 383 | KC_LANGUAGE_2, | 383 | KC_LANGUAGE_2, |
| 384 | KC_LANGUAGE_3, | 384 | KC_LANGUAGE_3, |
| 385 | KC_LANGUAGE_4, | 385 | KC_LANGUAGE_4, |
| @@ -395,7 +395,7 @@ enum hid_keyboard_keypad_usage { | |||
| 395 | KC_PRIOR, | 395 | KC_PRIOR, |
| 396 | KC_RETURN, | 396 | KC_RETURN, |
| 397 | KC_SEPARATOR, | 397 | KC_SEPARATOR, |
| 398 | KC_OUT, // 0xA0 | 398 | KC_OUT, // 0xA0 |
| 399 | KC_OPER, | 399 | KC_OPER, |
| 400 | KC_CLEAR_AGAIN, | 400 | KC_CLEAR_AGAIN, |
| 401 | KC_CRSEL, | 401 | KC_CRSEL, |
| @@ -488,7 +488,7 @@ enum internal_special_keycodes { | |||
| 488 | KC_MEDIA_STOP, | 488 | KC_MEDIA_STOP, |
| 489 | KC_MEDIA_PLAY_PAUSE, | 489 | KC_MEDIA_PLAY_PAUSE, |
| 490 | KC_MEDIA_SELECT, | 490 | KC_MEDIA_SELECT, |
| 491 | KC_MEDIA_EJECT, // 0xB0 | 491 | KC_MEDIA_EJECT, // 0xB0 |
| 492 | KC_MAIL, | 492 | KC_MAIL, |
| 493 | KC_CALCULATOR, | 493 | KC_CALCULATOR, |
| 494 | KC_MY_COMPUTER, | 494 | KC_MY_COMPUTER, |
| @@ -514,7 +514,7 @@ enum mouse_keys { | |||
| 514 | #endif | 514 | #endif |
| 515 | KC_MS_DOWN, | 515 | KC_MS_DOWN, |
| 516 | KC_MS_LEFT, | 516 | KC_MS_LEFT, |
| 517 | KC_MS_RIGHT, // 0xF0 | 517 | KC_MS_RIGHT, // 0xF0 |
| 518 | KC_MS_BTN1, | 518 | KC_MS_BTN1, |
| 519 | KC_MS_BTN2, | 519 | KC_MS_BTN2, |
| 520 | KC_MS_BTN3, | 520 | KC_MS_BTN3, |
| @@ -539,7 +539,7 @@ enum mouse_keys { | |||
| 539 | /* Acceleration */ | 539 | /* Acceleration */ |
| 540 | KC_MS_ACCEL0, | 540 | KC_MS_ACCEL0, |
| 541 | KC_MS_ACCEL1, | 541 | KC_MS_ACCEL1, |
| 542 | KC_MS_ACCEL2 // 0xFF | 542 | KC_MS_ACCEL2 // 0xFF |
| 543 | }; | 543 | }; |
| 544 | 544 | ||
| 545 | #include "keycode_legacy.h" | 545 | #include "keycode_legacy.h" |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index cd67f71a8f..a91b2a0b36 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -77,7 +77,7 @@ action_t action_for_keycode(uint16_t keycode) { | |||
| 77 | case QK_MODS ... QK_MODS_MAX:; | 77 | case QK_MODS ... QK_MODS_MAX:; |
| 78 | // Has a modifier | 78 | // Has a modifier |
| 79 | // Split it up | 79 | // Split it up |
| 80 | action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key | 80 | action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key |
| 81 | break; | 81 | break; |
| 82 | #ifndef NO_ACTION_LAYER | 82 | #ifndef NO_ACTION_LAYER |
| 83 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | 83 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: |
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h index 76d2f4f6b0..55a58a25b0 100644 --- a/quantum/keymap_extras/keymap_nordic.h +++ b/quantum/keymap_extras/keymap_nordic.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #define NO_ACUT KC_EQL | 24 | #define NO_ACUT KC_EQL |
| 25 | 25 | ||
| 26 | #define NO_AM KC_LBRC | 26 | #define NO_AM KC_LBRC |
| 27 | #define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout | 27 | #define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout |
| 28 | #define NO_AE KC_SCLN | 28 | #define NO_AE KC_SCLN |
| 29 | #define NO_OSLH KC_QUOT | 29 | #define NO_OSLH KC_QUOT |
| 30 | #define NO_APOS KC_NUHS | 30 | #define NO_APOS KC_NUHS |
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h index 310aa07409..e888ccd643 100644 --- a/quantum/keymap_extras/keymap_steno.h +++ b/quantum/keymap_extras/keymap_steno.h | |||
| @@ -70,7 +70,7 @@ enum steno_keycodes { | |||
| 70 | STN_NB, | 70 | STN_NB, |
| 71 | STN_NC, | 71 | STN_NC, |
| 72 | STN_ZR, | 72 | STN_ZR, |
| 73 | STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT | 73 | STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | #ifdef STENO_COMBINEDMAP | 76 | #ifdef STENO_COMBINEDMAP |
diff --git a/quantum/led.c b/quantum/led.c index 7b3f877208..c5ddbc22c5 100644 --- a/quantum/led.c +++ b/quantum/led.c | |||
| @@ -64,13 +64,17 @@ __attribute__((weak)) void led_set_user(uint8_t usb_led) {} | |||
| 64 | * | 64 | * |
| 65 | * \deprecated Use led_update_kb() instead. | 65 | * \deprecated Use led_update_kb() instead. |
| 66 | */ | 66 | */ |
| 67 | __attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } | 67 | __attribute__((weak)) void led_set_kb(uint8_t usb_led) { |
| 68 | led_set_user(usb_led); | ||
| 69 | } | ||
| 68 | 70 | ||
| 69 | /** \brief Lock LED update callback - keymap/user level | 71 | /** \brief Lock LED update callback - keymap/user level |
| 70 | * | 72 | * |
| 71 | * \return True if led_update_kb() should run its own code, false otherwise. | 73 | * \return True if led_update_kb() should run its own code, false otherwise. |
| 72 | */ | 74 | */ |
| 73 | __attribute__((weak)) bool led_update_user(led_t led_state) { return true; } | 75 | __attribute__((weak)) bool led_update_user(led_t led_state) { |
| 76 | return true; | ||
| 77 | } | ||
| 74 | 78 | ||
| 75 | /** \brief Lock LED update callback - keyboard level | 79 | /** \brief Lock LED update callback - keyboard level |
| 76 | * | 80 | * |
| @@ -156,7 +160,9 @@ void led_suspend(void) { | |||
| 156 | 160 | ||
| 157 | /** \brief Trigger behaviour on transition from suspend | 161 | /** \brief Trigger behaviour on transition from suspend |
| 158 | */ | 162 | */ |
| 159 | void led_wakeup(void) { led_set(host_keyboard_leds()); } | 163 | void led_wakeup(void) { |
| 164 | led_set(host_keyboard_leds()); | ||
| 165 | } | ||
| 160 | 166 | ||
| 161 | /** \brief set host led state | 167 | /** \brief set host led state |
| 162 | * | 168 | * |
diff --git a/quantum/led_matrix/animations/alpha_mods_anim.h b/quantum/led_matrix/animations/alpha_mods_anim.h index 4d017894a1..01acb3f933 100644 --- a/quantum/led_matrix/animations/alpha_mods_anim.h +++ b/quantum/led_matrix/animations/alpha_mods_anim.h | |||
| @@ -20,5 +20,5 @@ bool ALPHAS_MODS(effect_params_t* params) { | |||
| 20 | return led_matrix_check_finished_leds(led_max); | 20 | return led_matrix_check_finished_leds(led_max); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 23 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 24 | #endif // ENABLE_LED_MATRIX_ALPHAS_MODS | 24 | #endif // ENABLE_LED_MATRIX_ALPHAS_MODS |
diff --git a/quantum/led_matrix/animations/band_anim.h b/quantum/led_matrix/animations/band_anim.h index 293be4f67a..d9491849ea 100644 --- a/quantum/led_matrix/animations/band_anim.h +++ b/quantum/led_matrix/animations/band_anim.h | |||
| @@ -7,7 +7,9 @@ static uint8_t BAND_math(uint8_t val, uint8_t i, uint8_t time) { | |||
| 7 | return scale8(v < 0 ? 0 : v, val); | 7 | return scale8(v < 0 ? 0 : v, val); |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool BAND(effect_params_t* params) { return effect_runner_i(params, &BAND_math); } | 10 | bool BAND(effect_params_t* params) { |
| 11 | return effect_runner_i(params, &BAND_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_LED_MATRIX_BAND | 15 | #endif // ENABLE_LED_MATRIX_BAND |
diff --git a/quantum/led_matrix/animations/band_pinwheel_anim.h b/quantum/led_matrix/animations/band_pinwheel_anim.h index f47a3869ce..482d183eb6 100644 --- a/quantum/led_matrix/animations/band_pinwheel_anim.h +++ b/quantum/led_matrix/animations/band_pinwheel_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(BAND_PINWHEEL) | 2 | LED_MATRIX_EFFECT(BAND_PINWHEEL) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) { return scale8(val - time - atan2_8(dy, dx) * 3, val); } | 5 | static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) { |
| 6 | return scale8(val - time - atan2_8(dy, dx) * 3, val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool BAND_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_math); } | 9 | bool BAND_PINWHEEL(effect_params_t* params) { |
| 10 | return effect_runner_dx_dy(params, &BAND_PINWHEEL_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_BAND_PINWHEEL | 14 | #endif // ENABLE_LED_MATRIX_BAND_PINWHEEL |
diff --git a/quantum/led_matrix/animations/band_spiral_anim.h b/quantum/led_matrix/animations/band_spiral_anim.h index a4bd382181..ef93d19270 100644 --- a/quantum/led_matrix/animations/band_spiral_anim.h +++ b/quantum/led_matrix/animations/band_spiral_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(BAND_SPIRAL) | 2 | LED_MATRIX_EFFECT(BAND_SPIRAL) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(val + dist - time - atan2_8(dy, dx), val); } | 5 | static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { |
| 6 | return scale8(val + dist - time - atan2_8(dy, dx), val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool BAND_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math); } | 9 | bool BAND_SPIRAL(effect_params_t* params) { |
| 10 | return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_BAND_SPIRAL | 14 | #endif // ENABLE_LED_MATRIX_BAND_SPIRAL |
diff --git a/quantum/led_matrix/animations/breathing_anim.h b/quantum/led_matrix/animations/breathing_anim.h index 899925f516..0bd4cb0cc3 100644 --- a/quantum/led_matrix/animations/breathing_anim.h +++ b/quantum/led_matrix/animations/breathing_anim.h | |||
| @@ -15,5 +15,5 @@ bool BREATHING(effect_params_t* params) { | |||
| 15 | return led_matrix_check_finished_leds(led_max); | 15 | return led_matrix_check_finished_leds(led_max); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 18 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 19 | #endif // ENABLE_LED_MATRIX_BREATHING | 19 | #endif // ENABLE_LED_MATRIX_BREATHING |
diff --git a/quantum/led_matrix/animations/cycle_left_right_anim.h b/quantum/led_matrix/animations/cycle_left_right_anim.h index 1a8999b831..0a339e6d62 100644 --- a/quantum/led_matrix/animations/cycle_left_right_anim.h +++ b/quantum/led_matrix/animations/cycle_left_right_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) | 2 | LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].x - time, val); } | 5 | static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { |
| 6 | return scale8(g_led_config.point[i].x - time, val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } | 9 | bool CYCLE_LEFT_RIGHT(effect_params_t* params) { |
| 10 | return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT | 14 | #endif // ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT |
diff --git a/quantum/led_matrix/animations/cycle_out_in_anim.h b/quantum/led_matrix/animations/cycle_out_in_anim.h index 77d3a14b6f..8311d97fe8 100644 --- a/quantum/led_matrix/animations/cycle_out_in_anim.h +++ b/quantum/led_matrix/animations/cycle_out_in_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(CYCLE_OUT_IN) | 2 | LED_MATRIX_EFFECT(CYCLE_OUT_IN) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(3 * dist / 2 + time, val); } | 5 | static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { |
| 6 | return scale8(3 * dist / 2 + time, val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } | 9 | bool CYCLE_OUT_IN(effect_params_t* params) { |
| 10 | return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_CYCLE_OUT_IN | 14 | #endif // ENABLE_LED_MATRIX_CYCLE_OUT_IN |
diff --git a/quantum/led_matrix/animations/cycle_up_down_anim.h b/quantum/led_matrix/animations/cycle_up_down_anim.h index b25947199c..7e2d71a0f1 100644 --- a/quantum/led_matrix/animations/cycle_up_down_anim.h +++ b/quantum/led_matrix/animations/cycle_up_down_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(CYCLE_UP_DOWN) | 2 | LED_MATRIX_EFFECT(CYCLE_UP_DOWN) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].y - time, val); } | 5 | static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { |
| 6 | return scale8(g_led_config.point[i].y - time, val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } | 9 | bool CYCLE_UP_DOWN(effect_params_t* params) { |
| 10 | return effect_runner_i(params, &CYCLE_UP_DOWN_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_CYCLE_UP_DOWN | 14 | #endif // ENABLE_LED_MATRIX_CYCLE_UP_DOWN |
diff --git a/quantum/led_matrix/animations/dual_beacon_anim.h b/quantum/led_matrix/animations/dual_beacon_anim.h index 81735e323c..1dfb5ffe52 100644 --- a/quantum/led_matrix/animations/dual_beacon_anim.h +++ b/quantum/led_matrix/animations/dual_beacon_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(DUAL_BEACON) | 2 | LED_MATRIX_EFFECT(DUAL_BEACON) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val); } | 5 | static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { |
| 6 | return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } | 9 | bool DUAL_BEACON(effect_params_t* params) { |
| 10 | return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_DUAL_BEACON | 14 | #endif // ENABLE_LED_MATRIX_DUAL_BEACON |
diff --git a/quantum/led_matrix/animations/runners/effect_runner_reactive.h b/quantum/led_matrix/animations/runners/effect_runner_reactive.h index be3090aa53..8468458744 100644 --- a/quantum/led_matrix/animations/runners/effect_runner_reactive.h +++ b/quantum/led_matrix/animations/runners/effect_runner_reactive.h | |||
| @@ -25,4 +25,4 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) { | |||
| 25 | return led_matrix_check_finished_leds(led_max); | 25 | return led_matrix_check_finished_leds(led_max); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 28 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h index f6ffc825a1..aec4a6ffda 100644 --- a/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h +++ b/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h | |||
| @@ -23,4 +23,4 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react | |||
| 23 | return led_matrix_check_finished_leds(led_max); | 23 | return led_matrix_check_finished_leds(led_max); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 26 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/solid_anim.h b/quantum/led_matrix/animations/solid_anim.h index c728dbcc98..895542e152 100644 --- a/quantum/led_matrix/animations/solid_anim.h +++ b/quantum/led_matrix/animations/solid_anim.h | |||
| @@ -12,4 +12,4 @@ bool SOLID(effect_params_t* params) { | |||
| 12 | return led_matrix_check_finished_leds(led_max); | 12 | return led_matrix_check_finished_leds(led_max); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | #endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | #endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
diff --git a/quantum/led_matrix/animations/solid_reactive_cross.h b/quantum/led_matrix/animations/solid_reactive_cross.h index a149e9a929..55a2556996 100644 --- a/quantum/led_matrix/animations/solid_reactive_cross.h +++ b/quantum/led_matrix/animations/solid_reactive_cross.h | |||
| @@ -23,13 +23,17 @@ static uint8_t SOLID_REACTIVE_CROSS_math(uint8_t val, int16_t dx, int16_t dy, ui | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS | 25 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS |
| 26 | bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } | 26 | bool SOLID_REACTIVE_CROSS(effect_params_t* params) { |
| 27 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); | ||
| 28 | } | ||
| 27 | # endif | 29 | # endif |
| 28 | 30 | ||
| 29 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS | 31 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS |
| 30 | bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } | 32 | bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { |
| 33 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); | ||
| 34 | } | ||
| 31 | # endif | 35 | # endif |
| 32 | 36 | ||
| 33 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 37 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 34 | # endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS) | 38 | # endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS) |
| 35 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 39 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/solid_reactive_nexus.h b/quantum/led_matrix/animations/solid_reactive_nexus.h index 5a86e48c6c..b1ec54e3b1 100644 --- a/quantum/led_matrix/animations/solid_reactive_nexus.h +++ b/quantum/led_matrix/animations/solid_reactive_nexus.h | |||
| @@ -20,13 +20,17 @@ static uint8_t SOLID_REACTIVE_NEXUS_math(uint8_t val, int16_t dx, int16_t dy, ui | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS | 22 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS |
| 23 | bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } | 23 | bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { |
| 24 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); | ||
| 25 | } | ||
| 24 | # endif | 26 | # endif |
| 25 | 27 | ||
| 26 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS | 28 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS |
| 27 | bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } | 29 | bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { |
| 30 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); | ||
| 31 | } | ||
| 28 | # endif | 32 | # endif |
| 29 | 33 | ||
| 30 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 34 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 31 | # endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS) | 35 | # endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS) |
| 32 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 36 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/solid_reactive_simple_anim.h b/quantum/led_matrix/animations/solid_reactive_simple_anim.h index 14f5e90730..3b289c78dd 100644 --- a/quantum/led_matrix/animations/solid_reactive_simple_anim.h +++ b/quantum/led_matrix/animations/solid_reactive_simple_anim.h | |||
| @@ -3,10 +3,14 @@ | |||
| 3 | LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) | 3 | LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) |
| 4 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 4 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 5 | 5 | ||
| 6 | static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) { return scale8(255 - offset, val); } | 6 | static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) { |
| 7 | return scale8(255 - offset, val); | ||
| 8 | } | ||
| 7 | 9 | ||
| 8 | bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } | 10 | bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { |
| 11 | return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); | ||
| 12 | } | ||
| 9 | 13 | ||
| 10 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 11 | # endif // ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE | 15 | # endif // ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE |
| 12 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 16 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/solid_reactive_wide.h b/quantum/led_matrix/animations/solid_reactive_wide.h index 3aa88063a7..96338113f1 100644 --- a/quantum/led_matrix/animations/solid_reactive_wide.h +++ b/quantum/led_matrix/animations/solid_reactive_wide.h | |||
| @@ -18,13 +18,17 @@ static uint8_t SOLID_REACTIVE_WIDE_math(uint8_t val, int16_t dx, int16_t dy, uin | |||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE | 20 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE |
| 21 | bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } | 21 | bool SOLID_REACTIVE_WIDE(effect_params_t* params) { |
| 22 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); | ||
| 23 | } | ||
| 22 | # endif | 24 | # endif |
| 23 | 25 | ||
| 24 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE | 26 | # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE |
| 25 | bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } | 27 | bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { |
| 28 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); | ||
| 29 | } | ||
| 26 | # endif | 30 | # endif |
| 27 | 31 | ||
| 28 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 32 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 29 | # endif // !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) | 33 | # endif // !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) |
| 30 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 34 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/solid_splash_anim.h b/quantum/led_matrix/animations/solid_splash_anim.h index 17b692a09a..b8b6e8ea5e 100644 --- a/quantum/led_matrix/animations/solid_splash_anim.h +++ b/quantum/led_matrix/animations/solid_splash_anim.h | |||
| @@ -18,13 +18,17 @@ uint8_t SOLID_SPLASH_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uin | |||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | # ifdef ENABLE_LED_MATRIX_SOLID_SPLASH | 20 | # ifdef ENABLE_LED_MATRIX_SOLID_SPLASH |
| 21 | bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } | 21 | bool SOLID_SPLASH(effect_params_t* params) { |
| 22 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); | ||
| 23 | } | ||
| 22 | # endif | 24 | # endif |
| 23 | 25 | ||
| 24 | # ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH | 26 | # ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH |
| 25 | bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } | 27 | bool SOLID_MULTISPLASH(effect_params_t* params) { |
| 28 | return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); | ||
| 29 | } | ||
| 26 | # endif | 30 | # endif |
| 27 | 31 | ||
| 28 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 32 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 29 | # endif // defined(ENABLE_LED_MATRIX_SPLASH) || defined(ENABLE_LED_MATRIX_MULTISPLASH) | 33 | # endif // defined(ENABLE_LED_MATRIX_SPLASH) || defined(ENABLE_LED_MATRIX_MULTISPLASH) |
| 30 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 34 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/led_matrix/animations/wave_left_right_anim.h b/quantum/led_matrix/animations/wave_left_right_anim.h index 76487f8515..8dedd64738 100644 --- a/quantum/led_matrix/animations/wave_left_right_anim.h +++ b/quantum/led_matrix/animations/wave_left_right_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT) | 2 | LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].x - time), val); } | 5 | static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { |
| 6 | return scale8(sin8(g_led_config.point[i].x - time), val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool WAVE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &WAVE_LEFT_RIGHT_math); } | 9 | bool WAVE_LEFT_RIGHT(effect_params_t* params) { |
| 10 | return effect_runner_i(params, &WAVE_LEFT_RIGHT_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT | 14 | #endif // ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT |
diff --git a/quantum/led_matrix/animations/wave_up_down_anim.h b/quantum/led_matrix/animations/wave_up_down_anim.h index 94710f5c6e..4564f3e493 100644 --- a/quantum/led_matrix/animations/wave_up_down_anim.h +++ b/quantum/led_matrix/animations/wave_up_down_anim.h | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | LED_MATRIX_EFFECT(WAVE_UP_DOWN) | 2 | LED_MATRIX_EFFECT(WAVE_UP_DOWN) |
| 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].y - time), val); } | 5 | static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { |
| 6 | return scale8(sin8(g_led_config.point[i].y - time), val); | ||
| 7 | } | ||
| 6 | 8 | ||
| 7 | bool WAVE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &WAVE_UP_DOWN_math); } | 9 | bool WAVE_UP_DOWN(effect_params_t* params) { |
| 10 | return effect_runner_i(params, &WAVE_UP_DOWN_math); | ||
| 11 | } | ||
| 8 | 12 | ||
| 9 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS | 13 | # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS |
| 10 | #endif // ENABLE_LED_MATRIX_WAVE_UP_DOWN | 14 | #endif // ENABLE_LED_MATRIX_WAVE_UP_DOWN |
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index be1494e884..38ed79bed0 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c | |||
| @@ -88,14 +88,14 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; | |||
| 88 | #endif | 88 | #endif |
| 89 | 89 | ||
| 90 | // globals | 90 | // globals |
| 91 | led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr | 91 | led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr |
| 92 | uint32_t g_led_timer; | 92 | uint32_t g_led_timer; |
| 93 | #ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS | 93 | #ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS |
| 94 | uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; | 94 | uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; |
| 95 | #endif // LED_MATRIX_FRAMEBUFFER_EFFECTS | 95 | #endif // LED_MATRIX_FRAMEBUFFER_EFFECTS |
| 96 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 96 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 97 | last_hit_t g_last_hit_tracker; | 97 | last_hit_t g_last_hit_tracker; |
| 98 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 98 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 99 | 99 | ||
| 100 | // internals | 100 | // internals |
| 101 | static bool suspend_state = false; | 101 | static bool suspend_state = false; |
| @@ -105,13 +105,13 @@ static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; | |||
| 105 | static led_task_states led_task_state = SYNCING; | 105 | static led_task_states led_task_state = SYNCING; |
| 106 | #if LED_DISABLE_TIMEOUT > 0 | 106 | #if LED_DISABLE_TIMEOUT > 0 |
| 107 | static uint32_t led_anykey_timer; | 107 | static uint32_t led_anykey_timer; |
| 108 | #endif // LED_DISABLE_TIMEOUT > 0 | 108 | #endif // LED_DISABLE_TIMEOUT > 0 |
| 109 | 109 | ||
| 110 | // double buffers | 110 | // double buffers |
| 111 | static uint32_t led_timer_buffer; | 111 | static uint32_t led_timer_buffer; |
| 112 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 112 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 113 | static last_hit_t last_hit_buffer; | 113 | static last_hit_t last_hit_buffer; |
| 114 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 114 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 115 | 115 | ||
| 116 | // split led matrix | 116 | // split led matrix |
| 117 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 117 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| @@ -120,7 +120,9 @@ const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; | |||
| 120 | 120 | ||
| 121 | EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig); | 121 | EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig); |
| 122 | 122 | ||
| 123 | void eeconfig_update_led_matrix(void) { eeconfig_flush_led_matrix(true); } | 123 | void eeconfig_update_led_matrix(void) { |
| 124 | eeconfig_flush_led_matrix(true); | ||
| 125 | } | ||
| 124 | 126 | ||
| 125 | void eeconfig_update_led_matrix_default(void) { | 127 | void eeconfig_update_led_matrix_default(void) { |
| 126 | dprintf("eeconfig_update_led_matrix_default\n"); | 128 | dprintf("eeconfig_update_led_matrix_default\n"); |
| @@ -141,7 +143,9 @@ void eeconfig_debug_led_matrix(void) { | |||
| 141 | dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags); | 143 | dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags); |
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | __attribute__((weak)) uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } | 146 | __attribute__((weak)) uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { |
| 147 | return 0; | ||
| 148 | } | ||
| 145 | 149 | ||
| 146 | uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { | 150 | uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { |
| 147 | uint8_t led_count = led_matrix_map_row_column_to_led_kb(row, column, led_i); | 151 | uint8_t led_count = led_matrix_map_row_column_to_led_kb(row, column, led_i); |
| @@ -153,7 +157,9 @@ uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l | |||
| 153 | return led_count; | 157 | return led_count; |
| 154 | } | 158 | } |
| 155 | 159 | ||
| 156 | void led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); } | 160 | void led_matrix_update_pwm_buffers(void) { |
| 161 | led_matrix_driver.flush(); | ||
| 162 | } | ||
| 157 | 163 | ||
| 158 | void led_matrix_set_value(int index, uint8_t value) { | 164 | void led_matrix_set_value(int index, uint8_t value) { |
| 159 | #ifdef USE_CIE1931_CURVE | 165 | #ifdef USE_CIE1931_CURVE |
| @@ -164,7 +170,8 @@ void led_matrix_set_value(int index, uint8_t value) { | |||
| 164 | 170 | ||
| 165 | void led_matrix_set_value_all(uint8_t value) { | 171 | void led_matrix_set_value_all(uint8_t value) { |
| 166 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 172 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 167 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) led_matrix_set_value(i, value); | 173 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) |
| 174 | led_matrix_set_value(i, value); | ||
| 168 | #else | 175 | #else |
| 169 | # ifdef USE_CIE1931_CURVE | 176 | # ifdef USE_CIE1931_CURVE |
| 170 | led_matrix_driver.set_value_all(pgm_read_byte(&CIE1931_CURVE[value])); | 177 | led_matrix_driver.set_value_all(pgm_read_byte(&CIE1931_CURVE[value])); |
| @@ -180,7 +187,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 180 | #endif | 187 | #endif |
| 181 | #if LED_DISABLE_TIMEOUT > 0 | 188 | #if LED_DISABLE_TIMEOUT > 0 |
| 182 | led_anykey_timer = 0; | 189 | led_anykey_timer = 0; |
| 183 | #endif // LED_DISABLE_TIMEOUT > 0 | 190 | #endif // LED_DISABLE_TIMEOUT > 0 |
| 184 | 191 | ||
| 185 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 192 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 186 | uint8_t led[LED_HITS_TO_REMEMBER]; | 193 | uint8_t led[LED_HITS_TO_REMEMBER]; |
| @@ -190,7 +197,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 190 | if (!pressed) | 197 | if (!pressed) |
| 191 | # elif defined(LED_MATRIX_KEYPRESSES) | 198 | # elif defined(LED_MATRIX_KEYPRESSES) |
| 192 | if (pressed) | 199 | if (pressed) |
| 193 | # endif // defined(LED_MATRIX_KEYRELEASES) | 200 | # endif // defined(LED_MATRIX_KEYRELEASES) |
| 194 | { | 201 | { |
| 195 | led_count = led_matrix_map_row_column_to_led(row, col, led); | 202 | led_count = led_matrix_map_row_column_to_led(row, col, led); |
| 196 | } | 203 | } |
| @@ -198,7 +205,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 198 | if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { | 205 | if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { |
| 199 | memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); | 206 | memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 200 | memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); | 207 | memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 201 | memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit | 208 | memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit |
| 202 | memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); | 209 | memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 203 | last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; | 210 | last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; |
| 204 | } | 211 | } |
| @@ -211,13 +218,13 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 211 | last_hit_buffer.tick[index] = 0; | 218 | last_hit_buffer.tick[index] = 0; |
| 212 | last_hit_buffer.count++; | 219 | last_hit_buffer.count++; |
| 213 | } | 220 | } |
| 214 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 221 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 215 | 222 | ||
| 216 | #if defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) | 223 | #if defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) |
| 217 | if (led_matrix_eeconfig.mode == LED_MATRIX_TYPING_HEATMAP) { | 224 | if (led_matrix_eeconfig.mode == LED_MATRIX_TYPING_HEATMAP) { |
| 218 | process_led_matrix_typing_heatmap(row, col); | 225 | process_led_matrix_typing_heatmap(row, col); |
| 219 | } | 226 | } |
| 220 | #endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) | 227 | #endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) |
| 221 | } | 228 | } |
| 222 | 229 | ||
| 223 | static bool led_matrix_none(effect_params_t *params) { | 230 | static bool led_matrix_none(effect_params_t *params) { |
| @@ -232,7 +239,7 @@ static bool led_matrix_none(effect_params_t *params) { | |||
| 232 | static void led_task_timers(void) { | 239 | static void led_task_timers(void) { |
| 233 | #if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 | 240 | #if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 |
| 234 | uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); | 241 | uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); |
| 235 | #endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 | 242 | #endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 |
| 236 | led_timer_buffer = sync_timer_read32(); | 243 | led_timer_buffer = sync_timer_read32(); |
| 237 | 244 | ||
| 238 | // Update double buffer timers | 245 | // Update double buffer timers |
| @@ -244,7 +251,7 @@ static void led_task_timers(void) { | |||
| 244 | led_anykey_timer += deltaTime; | 251 | led_anykey_timer += deltaTime; |
| 245 | } | 252 | } |
| 246 | } | 253 | } |
| 247 | #endif // LED_DISABLE_TIMEOUT > 0 | 254 | #endif // LED_DISABLE_TIMEOUT > 0 |
| 248 | 255 | ||
| 249 | // Update double buffer last hit timers | 256 | // Update double buffer last hit timers |
| 250 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 257 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| @@ -256,7 +263,7 @@ static void led_task_timers(void) { | |||
| 256 | } | 263 | } |
| 257 | last_hit_buffer.tick[i] += deltaTime; | 264 | last_hit_buffer.tick[i] += deltaTime; |
| 258 | } | 265 | } |
| 259 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 266 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 260 | } | 267 | } |
| 261 | 268 | ||
| 262 | static void led_task_sync(void) { | 269 | static void led_task_sync(void) { |
| @@ -273,7 +280,7 @@ static void led_task_start(void) { | |||
| 273 | g_led_timer = led_timer_buffer; | 280 | g_led_timer = led_timer_buffer; |
| 274 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 281 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 275 | g_last_hit_tracker = last_hit_buffer; | 282 | g_last_hit_tracker = last_hit_buffer; |
| 276 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 283 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 277 | 284 | ||
| 278 | // next task | 285 | // next task |
| 279 | led_task_state = RENDERING; | 286 | led_task_state = RENDERING; |
| @@ -352,7 +359,7 @@ void led_matrix_task(void) { | |||
| 352 | bool suspend_backlight = suspend_state || | 359 | bool suspend_backlight = suspend_state || |
| 353 | #if LED_DISABLE_TIMEOUT > 0 | 360 | #if LED_DISABLE_TIMEOUT > 0 |
| 354 | (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) || | 361 | (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) || |
| 355 | #endif // LED_DISABLE_TIMEOUT > 0 | 362 | #endif // LED_DISABLE_TIMEOUT > 0 |
| 356 | false; | 363 | false; |
| 357 | 364 | ||
| 358 | uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode; | 365 | uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode; |
| @@ -421,7 +428,7 @@ void led_matrix_init(void) { | |||
| 421 | for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { | 428 | for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { |
| 422 | last_hit_buffer.tick[i] = UINT16_MAX; | 429 | last_hit_buffer.tick[i] = UINT16_MAX; |
| 423 | } | 430 | } |
| 424 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 431 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 425 | 432 | ||
| 426 | if (!eeconfig_is_enabled()) { | 433 | if (!eeconfig_is_enabled()) { |
| 427 | dprintf("led_matrix_init_drivers eeconfig is not enabled.\n"); | 434 | dprintf("led_matrix_init_drivers eeconfig is not enabled.\n"); |
| @@ -434,20 +441,22 @@ void led_matrix_init(void) { | |||
| 434 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); | 441 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); |
| 435 | eeconfig_update_led_matrix_default(); | 442 | eeconfig_update_led_matrix_default(); |
| 436 | } | 443 | } |
| 437 | eeconfig_debug_led_matrix(); // display current eeprom values | 444 | eeconfig_debug_led_matrix(); // display current eeprom values |
| 438 | } | 445 | } |
| 439 | 446 | ||
| 440 | void led_matrix_set_suspend_state(bool state) { | 447 | void led_matrix_set_suspend_state(bool state) { |
| 441 | #ifdef LED_DISABLE_WHEN_USB_SUSPENDED | 448 | #ifdef LED_DISABLE_WHEN_USB_SUSPENDED |
| 442 | if (state && !suspend_state && is_keyboard_master()) { // only run if turning off, and only once | 449 | if (state && !suspend_state && is_keyboard_master()) { // only run if turning off, and only once |
| 443 | led_task_render(0); // turn off all LEDs when suspending | 450 | led_task_render(0); // turn off all LEDs when suspending |
| 444 | led_task_flush(0); // and actually flash led state to LEDs | 451 | led_task_flush(0); // and actually flash led state to LEDs |
| 445 | } | 452 | } |
| 446 | suspend_state = state; | 453 | suspend_state = state; |
| 447 | #endif | 454 | #endif |
| 448 | } | 455 | } |
| 449 | 456 | ||
| 450 | bool led_matrix_get_suspend_state(void) { return suspend_state; } | 457 | bool led_matrix_get_suspend_state(void) { |
| 458 | return suspend_state; | ||
| 459 | } | ||
| 451 | 460 | ||
| 452 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | 461 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { |
| 453 | led_matrix_eeconfig.enable ^= 1; | 462 | led_matrix_eeconfig.enable ^= 1; |
| @@ -455,8 +464,12 @@ void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | |||
| 455 | eeconfig_flag_led_matrix(write_to_eeprom); | 464 | eeconfig_flag_led_matrix(write_to_eeprom); |
| 456 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); | 465 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); |
| 457 | } | 466 | } |
| 458 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } | 467 | void led_matrix_toggle_noeeprom(void) { |
| 459 | void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); } | 468 | led_matrix_toggle_eeprom_helper(false); |
| 469 | } | ||
| 470 | void led_matrix_toggle(void) { | ||
| 471 | led_matrix_toggle_eeprom_helper(true); | ||
| 472 | } | ||
| 460 | 473 | ||
| 461 | void led_matrix_enable(void) { | 474 | void led_matrix_enable(void) { |
| 462 | led_matrix_enable_noeeprom(); | 475 | led_matrix_enable_noeeprom(); |
| @@ -478,7 +491,9 @@ void led_matrix_disable_noeeprom(void) { | |||
| 478 | led_matrix_eeconfig.enable = 0; | 491 | led_matrix_eeconfig.enable = 0; |
| 479 | } | 492 | } |
| 480 | 493 | ||
| 481 | uint8_t led_matrix_is_enabled(void) { return led_matrix_eeconfig.enable; } | 494 | uint8_t led_matrix_is_enabled(void) { |
| 495 | return led_matrix_eeconfig.enable; | ||
| 496 | } | ||
| 482 | 497 | ||
| 483 | void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | 498 | void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { |
| 484 | if (!led_matrix_eeconfig.enable) { | 499 | if (!led_matrix_eeconfig.enable) { |
| @@ -495,24 +510,38 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 495 | eeconfig_flag_led_matrix(write_to_eeprom); | 510 | eeconfig_flag_led_matrix(write_to_eeprom); |
| 496 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); | 511 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); |
| 497 | } | 512 | } |
| 498 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } | 513 | void led_matrix_mode_noeeprom(uint8_t mode) { |
| 499 | void led_matrix_mode(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, true); } | 514 | led_matrix_mode_eeprom_helper(mode, false); |
| 515 | } | ||
| 516 | void led_matrix_mode(uint8_t mode) { | ||
| 517 | led_matrix_mode_eeprom_helper(mode, true); | ||
| 518 | } | ||
| 500 | 519 | ||
| 501 | uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; } | 520 | uint8_t led_matrix_get_mode(void) { |
| 521 | return led_matrix_eeconfig.mode; | ||
| 522 | } | ||
| 502 | 523 | ||
| 503 | void led_matrix_step_helper(bool write_to_eeprom) { | 524 | void led_matrix_step_helper(bool write_to_eeprom) { |
| 504 | uint8_t mode = led_matrix_eeconfig.mode + 1; | 525 | uint8_t mode = led_matrix_eeconfig.mode + 1; |
| 505 | led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); | 526 | led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); |
| 506 | } | 527 | } |
| 507 | void led_matrix_step_noeeprom(void) { led_matrix_step_helper(false); } | 528 | void led_matrix_step_noeeprom(void) { |
| 508 | void led_matrix_step(void) { led_matrix_step_helper(true); } | 529 | led_matrix_step_helper(false); |
| 530 | } | ||
| 531 | void led_matrix_step(void) { | ||
| 532 | led_matrix_step_helper(true); | ||
| 533 | } | ||
| 509 | 534 | ||
| 510 | void led_matrix_step_reverse_helper(bool write_to_eeprom) { | 535 | void led_matrix_step_reverse_helper(bool write_to_eeprom) { |
| 511 | uint8_t mode = led_matrix_eeconfig.mode - 1; | 536 | uint8_t mode = led_matrix_eeconfig.mode - 1; |
| 512 | led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); | 537 | led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); |
| 513 | } | 538 | } |
| 514 | void led_matrix_step_reverse_noeeprom(void) { led_matrix_step_reverse_helper(false); } | 539 | void led_matrix_step_reverse_noeeprom(void) { |
| 515 | void led_matrix_step_reverse(void) { led_matrix_step_reverse_helper(true); } | 540 | led_matrix_step_reverse_helper(false); |
| 541 | } | ||
| 542 | void led_matrix_step_reverse(void) { | ||
| 543 | led_matrix_step_reverse_helper(true); | ||
| 544 | } | ||
| 516 | 545 | ||
| 517 | void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { | 546 | void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { |
| 518 | if (!led_matrix_eeconfig.enable) { | 547 | if (!led_matrix_eeconfig.enable) { |
| @@ -522,37 +551,77 @@ void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { | |||
| 522 | eeconfig_flag_led_matrix(write_to_eeprom); | 551 | eeconfig_flag_led_matrix(write_to_eeprom); |
| 523 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); | 552 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); |
| 524 | } | 553 | } |
| 525 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } | 554 | void led_matrix_set_val_noeeprom(uint8_t val) { |
| 526 | void led_matrix_set_val(uint8_t val) { led_matrix_set_val_eeprom_helper(val, true); } | 555 | led_matrix_set_val_eeprom_helper(val, false); |
| 556 | } | ||
| 557 | void led_matrix_set_val(uint8_t val) { | ||
| 558 | led_matrix_set_val_eeprom_helper(val, true); | ||
| 559 | } | ||
| 527 | 560 | ||
| 528 | uint8_t led_matrix_get_val(void) { return led_matrix_eeconfig.val; } | 561 | uint8_t led_matrix_get_val(void) { |
| 562 | return led_matrix_eeconfig.val; | ||
| 563 | } | ||
| 529 | 564 | ||
| 530 | void led_matrix_increase_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } | 565 | void led_matrix_increase_val_helper(bool write_to_eeprom) { |
| 531 | void led_matrix_increase_val_noeeprom(void) { led_matrix_increase_val_helper(false); } | 566 | led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); |
| 532 | void led_matrix_increase_val(void) { led_matrix_increase_val_helper(true); } | 567 | } |
| 568 | void led_matrix_increase_val_noeeprom(void) { | ||
| 569 | led_matrix_increase_val_helper(false); | ||
| 570 | } | ||
| 571 | void led_matrix_increase_val(void) { | ||
| 572 | led_matrix_increase_val_helper(true); | ||
| 573 | } | ||
| 533 | 574 | ||
| 534 | void led_matrix_decrease_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } | 575 | void led_matrix_decrease_val_helper(bool write_to_eeprom) { |
| 535 | void led_matrix_decrease_val_noeeprom(void) { led_matrix_decrease_val_helper(false); } | 576 | led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); |
| 536 | void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); } | 577 | } |
| 578 | void led_matrix_decrease_val_noeeprom(void) { | ||
| 579 | led_matrix_decrease_val_helper(false); | ||
| 580 | } | ||
| 581 | void led_matrix_decrease_val(void) { | ||
| 582 | led_matrix_decrease_val_helper(true); | ||
| 583 | } | ||
| 537 | 584 | ||
| 538 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | 585 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
| 539 | led_matrix_eeconfig.speed = speed; | 586 | led_matrix_eeconfig.speed = speed; |
| 540 | eeconfig_flag_led_matrix(write_to_eeprom); | 587 | eeconfig_flag_led_matrix(write_to_eeprom); |
| 541 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); | 588 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); |
| 542 | } | 589 | } |
| 543 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } | 590 | void led_matrix_set_speed_noeeprom(uint8_t speed) { |
| 544 | void led_matrix_set_speed(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, true); } | 591 | led_matrix_set_speed_eeprom_helper(speed, false); |
| 592 | } | ||
| 593 | void led_matrix_set_speed(uint8_t speed) { | ||
| 594 | led_matrix_set_speed_eeprom_helper(speed, true); | ||
| 595 | } | ||
| 545 | 596 | ||
| 546 | uint8_t led_matrix_get_speed(void) { return led_matrix_eeconfig.speed; } | 597 | uint8_t led_matrix_get_speed(void) { |
| 598 | return led_matrix_eeconfig.speed; | ||
| 599 | } | ||
| 547 | 600 | ||
| 548 | void led_matrix_increase_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } | 601 | void led_matrix_increase_speed_helper(bool write_to_eeprom) { |
| 549 | void led_matrix_increase_speed_noeeprom(void) { led_matrix_increase_speed_helper(false); } | 602 | led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); |
| 550 | void led_matrix_increase_speed(void) { led_matrix_increase_speed_helper(true); } | 603 | } |
| 604 | void led_matrix_increase_speed_noeeprom(void) { | ||
| 605 | led_matrix_increase_speed_helper(false); | ||
| 606 | } | ||
| 607 | void led_matrix_increase_speed(void) { | ||
| 608 | led_matrix_increase_speed_helper(true); | ||
| 609 | } | ||
| 551 | 610 | ||
| 552 | void led_matrix_decrease_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } | 611 | void led_matrix_decrease_speed_helper(bool write_to_eeprom) { |
| 553 | void led_matrix_decrease_speed_noeeprom(void) { led_matrix_decrease_speed_helper(false); } | 612 | led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); |
| 554 | void led_matrix_decrease_speed(void) { led_matrix_decrease_speed_helper(true); } | 613 | } |
| 614 | void led_matrix_decrease_speed_noeeprom(void) { | ||
| 615 | led_matrix_decrease_speed_helper(false); | ||
| 616 | } | ||
| 617 | void led_matrix_decrease_speed(void) { | ||
| 618 | led_matrix_decrease_speed_helper(true); | ||
| 619 | } | ||
| 555 | 620 | ||
| 556 | led_flags_t led_matrix_get_flags(void) { return led_matrix_eeconfig.flags; } | 621 | led_flags_t led_matrix_get_flags(void) { |
| 622 | return led_matrix_eeconfig.flags; | ||
| 623 | } | ||
| 557 | 624 | ||
| 558 | void led_matrix_set_flags(led_flags_t flags) { led_matrix_eeconfig.flags = flags; } | 625 | void led_matrix_set_flags(led_flags_t flags) { |
| 626 | led_matrix_eeconfig.flags = flags; | ||
| 627 | } | ||
diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 61cdbd9b8e..3dc533100f 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | // Last led hit | 36 | // Last led hit |
| 37 | #ifndef LED_HITS_TO_REMEMBER | 37 | #ifndef LED_HITS_TO_REMEMBER |
| 38 | # define LED_HITS_TO_REMEMBER 8 | 38 | # define LED_HITS_TO_REMEMBER 8 |
| 39 | #endif // LED_HITS_TO_REMEMBER | 39 | #endif // LED_HITS_TO_REMEMBER |
| 40 | 40 | ||
| 41 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 41 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 42 | typedef struct PACKED { | 42 | typedef struct PACKED { |
| @@ -46,7 +46,7 @@ typedef struct PACKED { | |||
| 46 | uint8_t index[LED_HITS_TO_REMEMBER]; | 46 | uint8_t index[LED_HITS_TO_REMEMBER]; |
| 47 | uint16_t tick[LED_HITS_TO_REMEMBER]; | 47 | uint16_t tick[LED_HITS_TO_REMEMBER]; |
| 48 | } last_hit_t; | 48 | } last_hit_t; |
| 49 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | 49 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED |
| 50 | 50 | ||
| 51 | typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states; | 51 | typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states; |
| 52 | 52 | ||
| @@ -87,7 +87,7 @@ typedef union { | |||
| 87 | uint8_t mode : 6; | 87 | uint8_t mode : 6; |
| 88 | uint16_t reserved; | 88 | uint16_t reserved; |
| 89 | uint8_t val; | 89 | uint8_t val; |
| 90 | uint8_t speed; // EECONFIG needs to be increased to support this | 90 | uint8_t speed; // EECONFIG needs to be increased to support this |
| 91 | led_flags_t flags; | 91 | led_flags_t flags; |
| 92 | }; | 92 | }; |
| 93 | } led_eeconfig_t; | 93 | } led_eeconfig_t; |
diff --git a/quantum/logging/debug.c b/quantum/logging/debug.c index ea62deaa8c..ca7654eda2 100644 --- a/quantum/logging/debug.c +++ b/quantum/logging/debug.c | |||
| @@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | #include "debug.h" | 17 | #include "debug.h" |
| 18 | 18 | ||
| 19 | debug_config_t debug_config = { | 19 | debug_config_t debug_config = { |
| 20 | .enable = false, // | 20 | .enable = false, // |
| 21 | .matrix = false, // | 21 | .matrix = false, // |
| 22 | .keyboard = false, // | 22 | .keyboard = false, // |
| 23 | .mouse = false, // | 23 | .mouse = false, // |
| 24 | .reserved = 0 // | 24 | .reserved = 0 // |
| 25 | }; | 25 | }; |
diff --git a/quantum/logging/print.c b/quantum/logging/print.c index e8440e55ee..50a6b826ee 100644 --- a/quantum/logging/print.c +++ b/quantum/logging/print.c | |||
| @@ -19,9 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | 19 | ||
| 20 | // bind lib/printf to console interface - sendchar | 20 | // bind lib/printf to console interface - sendchar |
| 21 | 21 | ||
| 22 | static int8_t null_sendchar_func(uint8_t c) { return 0; } | 22 | static int8_t null_sendchar_func(uint8_t c) { |
| 23 | return 0; | ||
| 24 | } | ||
| 23 | static sendchar_func_t func = null_sendchar_func; | 25 | static sendchar_func_t func = null_sendchar_func; |
| 24 | 26 | ||
| 25 | void print_set_sendchar(sendchar_func_t send) { func = send; } | 27 | void print_set_sendchar(sendchar_func_t send) { |
| 28 | func = send; | ||
| 29 | } | ||
| 26 | 30 | ||
| 27 | void _putchar(char character) { func(character); } | 31 | void _putchar(char character) { |
| 32 | func(character); | ||
| 33 | } | ||
diff --git a/quantum/logging/print.h b/quantum/logging/print.h index 8c055f549e..aa72fc7074 100644 --- a/quantum/logging/print.h +++ b/quantum/logging/print.h | |||
| @@ -37,7 +37,7 @@ void print_set_sendchar(sendchar_func_t func); | |||
| 37 | # include_next "_print.h" /* Include the platforms print.h */ | 37 | # include_next "_print.h" /* Include the platforms print.h */ |
| 38 | # else | 38 | # else |
| 39 | // Fall back to lib/printf | 39 | // Fall back to lib/printf |
| 40 | # include "printf.h" // lib/printf/printf.h | 40 | # include "printf.h" // lib/printf/printf.h |
| 41 | 41 | ||
| 42 | // Create user & normal print defines | 42 | // Create user & normal print defines |
| 43 | # define print(s) printf(s) | 43 | # define print(s) printf(s) |
diff --git a/quantum/logging/sendchar.c b/quantum/logging/sendchar.c index 9422382f6f..5bc744b743 100644 --- a/quantum/logging/sendchar.c +++ b/quantum/logging/sendchar.c | |||
| @@ -17,4 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | #include "sendchar.h" | 17 | #include "sendchar.h" |
| 18 | 18 | ||
| 19 | /* default noop "null" implementation */ | 19 | /* default noop "null" implementation */ |
| 20 | __attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; } | 20 | __attribute__((weak)) int8_t sendchar(uint8_t c) { |
| 21 | return 0; | ||
| 22 | } | ||
diff --git a/quantum/main.c b/quantum/main.c index 6ed6b95741..faba668056 100644 --- a/quantum/main.c +++ b/quantum/main.c | |||
| @@ -45,7 +45,7 @@ void protocol_task(void) { | |||
| 45 | 45 | ||
| 46 | #ifdef DEFERRED_EXEC_ENABLE | 46 | #ifdef DEFERRED_EXEC_ENABLE |
| 47 | void deferred_exec_task(void); | 47 | void deferred_exec_task(void); |
| 48 | #endif // DEFERRED_EXEC_ENABLE | 48 | #endif // DEFERRED_EXEC_ENABLE |
| 49 | 49 | ||
| 50 | /** \brief Main | 50 | /** \brief Main |
| 51 | * | 51 | * |
| @@ -66,7 +66,7 @@ int main(void) { | |||
| 66 | #ifdef DEFERRED_EXEC_ENABLE | 66 | #ifdef DEFERRED_EXEC_ENABLE |
| 67 | // Run deferred executions | 67 | // Run deferred executions |
| 68 | deferred_exec_task(); | 68 | deferred_exec_task(); |
| 69 | #endif // DEFERRED_EXEC_ENABLE | 69 | #endif // DEFERRED_EXEC_ENABLE |
| 70 | 70 | ||
| 71 | housekeeping_task(); | 71 | housekeeping_task(); |
| 72 | } | 72 | } |
diff --git a/quantum/matrix.c b/quantum/matrix.c index 0b16184e12..db59b73754 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -51,15 +51,15 @@ static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS | |||
| 51 | #elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | 51 | #elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) |
| 52 | # ifdef MATRIX_ROW_PINS | 52 | # ifdef MATRIX_ROW_PINS |
| 53 | static SPLIT_MUTABLE_ROW pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS; | 53 | static SPLIT_MUTABLE_ROW pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS; |
| 54 | # endif // MATRIX_ROW_PINS | 54 | # endif // MATRIX_ROW_PINS |
| 55 | # ifdef MATRIX_COL_PINS | 55 | # ifdef MATRIX_COL_PINS |
| 56 | static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | 56 | static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; |
| 57 | # endif // MATRIX_COL_PINS | 57 | # endif // MATRIX_COL_PINS |
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| 60 | /* matrix state(1:on, 0:off) */ | 60 | /* matrix state(1:on, 0:off) */ |
| 61 | extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values | 61 | extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values |
| 62 | extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values | 62 | extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values |
| 63 | 63 | ||
| 64 | #ifdef SPLIT_KEYBOARD | 64 | #ifdef SPLIT_KEYBOARD |
| 65 | // row offsets for each hand | 65 | // row offsets for each hand |
| @@ -86,7 +86,9 @@ static inline void setPinOutput_writeHigh(pin_t pin) { | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | static inline void setPinInputHigh_atomic(pin_t pin) { | 88 | static inline void setPinInputHigh_atomic(pin_t pin) { |
| 89 | ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); } | 89 | ATOMIC_BLOCK_FORCEON { |
| 90 | setPinInputHigh(pin); | ||
| 91 | } | ||
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | static inline uint8_t readMatrixPin(pin_t pin) { | 94 | static inline uint8_t readMatrixPin(pin_t pin) { |
| @@ -171,8 +173,8 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] | |||
| 171 | // Start with a clear matrix row | 173 | // Start with a clear matrix row |
| 172 | matrix_row_t current_row_value = 0; | 174 | matrix_row_t current_row_value = 0; |
| 173 | 175 | ||
| 174 | if (!select_row(current_row)) { // Select row | 176 | if (!select_row(current_row)) { // Select row |
| 175 | return; // skip NO_PIN row | 177 | return; // skip NO_PIN row |
| 176 | } | 178 | } |
| 177 | matrix_output_select_delay(); | 179 | matrix_output_select_delay(); |
| 178 | 180 | ||
| @@ -187,7 +189,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] | |||
| 187 | 189 | ||
| 188 | // Unselect row | 190 | // Unselect row |
| 189 | unselect_row(current_row); | 191 | unselect_row(current_row); |
| 190 | matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH | 192 | matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH |
| 191 | 193 | ||
| 192 | // Update the matrix | 194 | // Update the matrix |
| 193 | current_matrix[current_row] = current_row_value; | 195 | current_matrix[current_row] = current_row_value; |
| @@ -234,8 +236,8 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] | |||
| 234 | bool key_pressed = false; | 236 | bool key_pressed = false; |
| 235 | 237 | ||
| 236 | // Select col | 238 | // Select col |
| 237 | if (!select_col(current_col)) { // select col | 239 | if (!select_col(current_col)) { // select col |
| 238 | return; // skip NO_PIN col | 240 | return; // skip NO_PIN col |
| 239 | } | 241 | } |
| 240 | matrix_output_select_delay(); | 242 | matrix_output_select_delay(); |
| 241 | 243 | ||
| @@ -254,13 +256,13 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] | |||
| 254 | 256 | ||
| 255 | // Unselect col | 257 | // Unselect col |
| 256 | unselect_col(current_col); | 258 | unselect_col(current_col); |
| 257 | matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH | 259 | matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH |
| 258 | } | 260 | } |
| 259 | 261 | ||
| 260 | # else | 262 | # else |
| 261 | # error DIODE_DIRECTION must be one of COL2ROW or ROW2COL! | 263 | # error DIODE_DIRECTION must be one of COL2ROW or ROW2COL! |
| 262 | # endif | 264 | # endif |
| 263 | # endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS) | 265 | # endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS) |
| 264 | #else | 266 | #else |
| 265 | # error DIODE_DIRECTION is not defined! | 267 | # error DIODE_DIRECTION is not defined! |
| 266 | #endif | 268 | #endif |
| @@ -311,7 +313,7 @@ void matrix_init(void) { | |||
| 311 | // Fallback implementation for keyboards not using the standard split_util.c | 313 | // Fallback implementation for keyboards not using the standard split_util.c |
| 312 | __attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { | 314 | __attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 313 | transport_master(master_matrix, slave_matrix); | 315 | transport_master(master_matrix, slave_matrix); |
| 314 | return true; // Treat the transport as always connected | 316 | return true; // Treat the transport as always connected |
| 315 | } | 317 | } |
| 316 | #endif | 318 | #endif |
| 317 | 319 | ||
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c index d67aaf508c..1497ceae71 100644 --- a/quantum/matrix_common.c +++ b/quantum/matrix_common.c | |||
| @@ -33,9 +33,13 @@ extern const matrix_row_t matrix_mask[]; | |||
| 33 | 33 | ||
| 34 | // user-defined overridable functions | 34 | // user-defined overridable functions |
| 35 | 35 | ||
| 36 | __attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } | 36 | __attribute__((weak)) void matrix_init_kb(void) { |
| 37 | matrix_init_user(); | ||
| 38 | } | ||
| 37 | 39 | ||
| 38 | __attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } | 40 | __attribute__((weak)) void matrix_scan_kb(void) { |
| 41 | matrix_scan_user(); | ||
| 42 | } | ||
| 39 | 43 | ||
| 40 | __attribute__((weak)) void matrix_init_user(void) {} | 44 | __attribute__((weak)) void matrix_init_user(void) {} |
| 41 | 45 | ||
| @@ -43,11 +47,17 @@ __attribute__((weak)) void matrix_scan_user(void) {} | |||
| 43 | 47 | ||
| 44 | // helper functions | 48 | // helper functions |
| 45 | 49 | ||
| 46 | inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } | 50 | inline uint8_t matrix_rows(void) { |
| 51 | return MATRIX_ROWS; | ||
| 52 | } | ||
| 47 | 53 | ||
| 48 | inline uint8_t matrix_cols(void) { return MATRIX_COLS; } | 54 | inline uint8_t matrix_cols(void) { |
| 55 | return MATRIX_COLS; | ||
| 56 | } | ||
| 49 | 57 | ||
| 50 | inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); } | 58 | inline bool matrix_is_on(uint8_t row, uint8_t col) { |
| 59 | return (matrix[row] & ((matrix_row_t)1 << col)); | ||
| 60 | } | ||
| 51 | 61 | ||
| 52 | inline matrix_row_t matrix_get_row(uint8_t row) { | 62 | inline matrix_row_t matrix_get_row(uint8_t row) { |
| 53 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | 63 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a |
| @@ -124,16 +134,26 @@ bool matrix_post_scan(void) { | |||
| 124 | #endif | 134 | #endif |
| 125 | 135 | ||
| 126 | /* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */ | 136 | /* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */ |
| 127 | __attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); } | 137 | __attribute__((weak)) void matrix_io_delay(void) { |
| 128 | __attribute__((weak)) void matrix_output_select_delay(void) { waitInputPinDelay(); } | 138 | wait_us(MATRIX_IO_DELAY); |
| 129 | __attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { matrix_io_delay(); } | 139 | } |
| 140 | __attribute__((weak)) void matrix_output_select_delay(void) { | ||
| 141 | waitInputPinDelay(); | ||
| 142 | } | ||
| 143 | __attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { | ||
| 144 | matrix_io_delay(); | ||
| 145 | } | ||
| 130 | 146 | ||
| 131 | // CUSTOM MATRIX 'LITE' | 147 | // CUSTOM MATRIX 'LITE' |
| 132 | __attribute__((weak)) void matrix_init_custom(void) {} | 148 | __attribute__((weak)) void matrix_init_custom(void) {} |
| 133 | __attribute__((weak)) bool matrix_scan_custom(matrix_row_t current_matrix[]) { return true; } | 149 | __attribute__((weak)) bool matrix_scan_custom(matrix_row_t current_matrix[]) { |
| 150 | return true; | ||
| 151 | } | ||
| 134 | 152 | ||
| 135 | #ifdef SPLIT_KEYBOARD | 153 | #ifdef SPLIT_KEYBOARD |
| 136 | __attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } | 154 | __attribute__((weak)) void matrix_slave_scan_kb(void) { |
| 155 | matrix_slave_scan_user(); | ||
| 156 | } | ||
| 137 | __attribute__((weak)) void matrix_slave_scan_user(void) {} | 157 | __attribute__((weak)) void matrix_slave_scan_user(void) {} |
| 138 | #endif | 158 | #endif |
| 139 | 159 | ||
| @@ -170,4 +190,6 @@ __attribute__((weak)) uint8_t matrix_scan(void) { | |||
| 170 | return changed; | 190 | return changed; |
| 171 | } | 191 | } |
| 172 | 192 | ||
| 173 | __attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) { return 0 != ((raw ? raw_matrix[row_index] : matrix[row_index]) & (MATRIX_ROW_SHIFTER << col_index)); } | 193 | __attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) { |
| 194 | return 0 != ((raw ? raw_matrix[row_index] : matrix[row_index]) & (MATRIX_ROW_SHIFTER << col_index)); | ||
| 195 | } | ||
diff --git a/quantum/mousekey.c b/quantum/mousekey.c index c2291fb397..8bafbf977a 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c | |||
| @@ -487,4 +487,6 @@ static void mousekey_debug(void) { | |||
| 487 | print(")\n"); | 487 | print(")\n"); |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | report_mouse_t mousekey_get_report(void) { return mouse_report; } | 490 | report_mouse_t mousekey_get_report(void) { |
| 491 | return mouse_report; | ||
| 492 | } | ||
diff --git a/quantum/pointing_device.c b/quantum/pointing_device.c index cce292e0bf..9627cab4b8 100644 --- a/quantum/pointing_device.c +++ b/quantum/pointing_device.c | |||
| @@ -39,7 +39,9 @@ uint16_t shared_cpi = 0; | |||
| 39 | * | 39 | * |
| 40 | * @param[in] new_mouse_report report_mouse_t | 40 | * @param[in] new_mouse_report report_mouse_t |
| 41 | */ | 41 | */ |
| 42 | void pointing_device_set_shared_report(report_mouse_t new_mouse_report) { shared_mouse_report = new_mouse_report; } | 42 | void pointing_device_set_shared_report(report_mouse_t new_mouse_report) { |
| 43 | shared_mouse_report = new_mouse_report; | ||
| 44 | } | ||
| 43 | 45 | ||
| 44 | /** | 46 | /** |
| 45 | * @brief Gets current pointing device CPI if supported | 47 | * @brief Gets current pointing device CPI if supported |
| @@ -50,7 +52,9 @@ void pointing_device_set_shared_report(report_mouse_t new_mouse_report) { shared | |||
| 50 | * | 52 | * |
| 51 | * @return cpi value as uint16_t | 53 | * @return cpi value as uint16_t |
| 52 | */ | 54 | */ |
| 53 | uint16_t pointing_device_get_shared_cpi(void) { return shared_cpi; } | 55 | uint16_t pointing_device_get_shared_cpi(void) { |
| 56 | return shared_cpi; | ||
| 57 | } | ||
| 54 | 58 | ||
| 55 | # if defined(POINTING_DEVICE_LEFT) | 59 | # if defined(POINTING_DEVICE_LEFT) |
| 56 | # define POINTING_DEVICE_THIS_SIDE is_keyboard_left() | 60 | # define POINTING_DEVICE_THIS_SIDE is_keyboard_left() |
| @@ -60,7 +64,7 @@ uint16_t pointing_device_get_shared_cpi(void) { return shared_cpi; } | |||
| 60 | # define POINTING_DEVICE_THIS_SIDE true | 64 | # define POINTING_DEVICE_THIS_SIDE true |
| 61 | # endif | 65 | # endif |
| 62 | 66 | ||
| 63 | #endif // defined(SPLIT_POINTING_ENABLE) | 67 | #endif // defined(SPLIT_POINTING_ENABLE) |
| 64 | 68 | ||
| 65 | static report_mouse_t local_mouse_report = {}; | 69 | static report_mouse_t local_mouse_report = {}; |
| 66 | 70 | ||
| @@ -73,7 +77,9 @@ extern const pointing_device_driver_t pointing_device_driver; | |||
| 73 | * @param[in] old report_mouse_t | 77 | * @param[in] old report_mouse_t |
| 74 | * @return bool result | 78 | * @return bool result |
| 75 | */ | 79 | */ |
| 76 | __attribute__((weak)) bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) { return memcmp(&new, &old, sizeof(new)); } | 80 | __attribute__((weak)) bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) { |
| 81 | return memcmp(&new, &old, sizeof(new)); | ||
| 82 | } | ||
| 77 | 83 | ||
| 78 | /** | 84 | /** |
| 79 | * @brief Keyboard level code pointing device initialisation | 85 | * @brief Keyboard level code pointing device initialisation |
| @@ -95,7 +101,9 @@ __attribute__((weak)) void pointing_device_init_user(void) {} | |||
| 95 | * @param[in] mouse_report report_mouse_t | 101 | * @param[in] mouse_report report_mouse_t |
| 96 | * @return report_mouse_t | 102 | * @return report_mouse_t |
| 97 | */ | 103 | */ |
| 98 | __attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { return pointing_device_task_user(mouse_report); } | 104 | __attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { |
| 105 | return pointing_device_task_user(mouse_report); | ||
| 106 | } | ||
| 99 | 107 | ||
| 100 | /** | 108 | /** |
| 101 | * @brief Weak function allowing for user level mouse report modification | 109 | * @brief Weak function allowing for user level mouse report modification |
| @@ -105,7 +113,9 @@ __attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mous | |||
| 105 | * @param[in] mouse_report report_mouse_t | 113 | * @param[in] mouse_report report_mouse_t |
| 106 | * @return report_mouse_t | 114 | * @return report_mouse_t |
| 107 | */ | 115 | */ |
| 108 | __attribute__((weak)) report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { return mouse_report; } | 116 | __attribute__((weak)) report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { |
| 117 | return mouse_report; | ||
| 118 | } | ||
| 109 | 119 | ||
| 110 | /** | 120 | /** |
| 111 | * @brief Handles pointing device buttons | 121 | * @brief Handles pointing device buttons |
| @@ -246,7 +256,7 @@ __attribute__((weak)) void pointing_device_task(void) { | |||
| 246 | # endif | 256 | # endif |
| 247 | #else | 257 | #else |
| 248 | local_mouse_report = pointing_device_driver.get_report(local_mouse_report); | 258 | local_mouse_report = pointing_device_driver.get_report(local_mouse_report); |
| 249 | #endif // defined(SPLIT_POINTING_ENABLE) | 259 | #endif // defined(SPLIT_POINTING_ENABLE) |
| 250 | 260 | ||
| 251 | // allow kb to intercept and modify report | 261 | // allow kb to intercept and modify report |
| 252 | #if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED) | 262 | #if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED) |
| @@ -275,14 +285,18 @@ __attribute__((weak)) void pointing_device_task(void) { | |||
| 275 | * | 285 | * |
| 276 | * @return report_mouse_t | 286 | * @return report_mouse_t |
| 277 | */ | 287 | */ |
| 278 | report_mouse_t pointing_device_get_report(void) { return local_mouse_report; } | 288 | report_mouse_t pointing_device_get_report(void) { |
| 289 | return local_mouse_report; | ||
| 290 | } | ||
| 279 | 291 | ||
| 280 | /** | 292 | /** |
| 281 | * @brief Sets mouse report used be pointing device task | 293 | * @brief Sets mouse report used be pointing device task |
| 282 | * | 294 | * |
| 283 | * @param[in] new_mouse_report | 295 | * @param[in] new_mouse_report |
| 284 | */ | 296 | */ |
| 285 | void pointing_device_set_report(report_mouse_t new_mouse_report) { local_mouse_report = new_mouse_report; } | 297 | void pointing_device_set_report(report_mouse_t new_mouse_report) { |
| 298 | local_mouse_report = new_mouse_report; | ||
| 299 | } | ||
| 286 | 300 | ||
| 287 | /** | 301 | /** |
| 288 | * @brief Gets current pointing device CPI if supported | 302 | * @brief Gets current pointing device CPI if supported |
| @@ -422,7 +436,9 @@ report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_repo | |||
| 422 | * @param[in] right_report report_mouse_t | 436 | * @param[in] right_report report_mouse_t |
| 423 | * @return pointing_device_task_combined_user(left_report, right_report) by default | 437 | * @return pointing_device_task_combined_user(left_report, right_report) by default |
| 424 | */ | 438 | */ |
| 425 | __attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report) { return pointing_device_task_combined_user(left_report, right_report); } | 439 | __attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report) { |
| 440 | return pointing_device_task_combined_user(left_report, right_report); | ||
| 441 | } | ||
| 426 | 442 | ||
| 427 | /** | 443 | /** |
| 428 | * @brief Weak function allowing for user level mouse report modification | 444 | * @brief Weak function allowing for user level mouse report modification |
| @@ -435,5 +451,7 @@ __attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mou | |||
| 435 | * @param[in] right_report report_mouse_t | 451 | * @param[in] right_report report_mouse_t |
| 436 | * @return pointing_device_combine_reports(left_report, right_report) by default | 452 | * @return pointing_device_combine_reports(left_report, right_report) by default |
| 437 | */ | 453 | */ |
| 438 | __attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report) { return pointing_device_combine_reports(left_report, right_report); } | 454 | __attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report) { |
| 455 | return pointing_device_combine_reports(left_report, right_report); | ||
| 456 | } | ||
| 439 | #endif | 457 | #endif |
diff --git a/quantum/pointing_device.h b/quantum/pointing_device.h index 8394c20952..5f3845227a 100644 --- a/quantum/pointing_device.h +++ b/quantum/pointing_device.h | |||
| @@ -103,5 +103,5 @@ report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, repor | |||
| 103 | report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report); | 103 | report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report); |
| 104 | report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report); | 104 | report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report); |
| 105 | report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report); | 105 | report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report); |
| 106 | # endif // defined(POINTING_DEVICE_COMBINED) | 106 | # endif // defined(POINTING_DEVICE_COMBINED) |
| 107 | #endif // defined(SPLIT_POINTING_ENABLE) | 107 | #endif // defined(SPLIT_POINTING_ENABLE) |
diff --git a/quantum/pointing_device_drivers.c b/quantum/pointing_device_drivers.c index 7702958f88..b8ef6e67e5 100644 --- a/quantum/pointing_device_drivers.c +++ b/quantum/pointing_device_drivers.c | |||
| @@ -120,7 +120,7 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { | |||
| 120 | int8_t report_x = 0, report_y = 0; | 120 | int8_t report_x = 0, report_y = 0; |
| 121 | static bool is_z_down = false; | 121 | static bool is_z_down = false; |
| 122 | 122 | ||
| 123 | cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); // Scale coordinates to arbitrary X, Y resolution | 123 | cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); // Scale coordinates to arbitrary X, Y resolution |
| 124 | 124 | ||
| 125 | if (x && y && touchData.xValue && touchData.yValue) { | 125 | if (x && y && touchData.xValue && touchData.yValue) { |
| 126 | report_x = (int8_t)(touchData.xValue - x); | 126 | report_x = (int8_t)(touchData.xValue - x); |
| @@ -207,11 +207,13 @@ const pointing_device_driver_t pointing_device_driver = { | |||
| 207 | }; | 207 | }; |
| 208 | // clang-format on | 208 | // clang-format on |
| 209 | #elif defined(POINTING_DEVICE_DRIVER_pmw3360) | 209 | #elif defined(POINTING_DEVICE_DRIVER_pmw3360) |
| 210 | static void pmw3360_device_init(void) { pmw3360_init(); } | 210 | static void pmw3360_device_init(void) { |
| 211 | pmw3360_init(); | ||
| 212 | } | ||
| 211 | 213 | ||
| 212 | report_mouse_t pmw3360_get_report(report_mouse_t mouse_report) { | 214 | report_mouse_t pmw3360_get_report(report_mouse_t mouse_report) { |
| 213 | report_pmw3360_t data = pmw3360_read_burst(); | 215 | report_pmw3360_t data = pmw3360_read_burst(); |
| 214 | static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state | 216 | static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state |
| 215 | 217 | ||
| 216 | if (data.isOnSurface && data.isMotion) { | 218 | if (data.isOnSurface && data.isMotion) { |
| 217 | // Reset timer if stopped moving | 219 | // Reset timer if stopped moving |
| @@ -243,11 +245,13 @@ const pointing_device_driver_t pointing_device_driver = { | |||
| 243 | }; | 245 | }; |
| 244 | // clang-format on | 246 | // clang-format on |
| 245 | #elif defined(POINTING_DEVICE_DRIVER_pmw3389) | 247 | #elif defined(POINTING_DEVICE_DRIVER_pmw3389) |
| 246 | static void pmw3389_device_init(void) { pmw3389_init(); } | 248 | static void pmw3389_device_init(void) { |
| 249 | pmw3389_init(); | ||
| 250 | } | ||
| 247 | 251 | ||
| 248 | report_mouse_t pmw3389_get_report(report_mouse_t mouse_report) { | 252 | report_mouse_t pmw3389_get_report(report_mouse_t mouse_report) { |
| 249 | report_pmw3389_t data = pmw3389_read_burst(); | 253 | report_pmw3389_t data = pmw3389_read_burst(); |
| 250 | static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state | 254 | static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state |
| 251 | 255 | ||
| 252 | if (data.isOnSurface && data.isMotion) { | 256 | if (data.isOnSurface && data.isMotion) { |
| 253 | // Reset timer if stopped moving | 257 | // Reset timer if stopped moving |
| @@ -280,9 +284,13 @@ const pointing_device_driver_t pointing_device_driver = { | |||
| 280 | // clang-format on | 284 | // clang-format on |
| 281 | #else | 285 | #else |
| 282 | __attribute__((weak)) void pointing_device_driver_init(void) {} | 286 | __attribute__((weak)) void pointing_device_driver_init(void) {} |
| 283 | __attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { return mouse_report; } | 287 | __attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { |
| 284 | __attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) { return 0; } | 288 | return mouse_report; |
| 285 | __attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {} | 289 | } |
| 290 | __attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) { | ||
| 291 | return 0; | ||
| 292 | } | ||
| 293 | __attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {} | ||
| 286 | 294 | ||
| 287 | // clang-format off | 295 | // clang-format off |
| 288 | const pointing_device_driver_t pointing_device_driver = { | 296 | const pointing_device_driver_t pointing_device_driver = { |
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index 23664721e8..e7fe453308 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c | |||
| @@ -50,11 +50,17 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { | |||
| 50 | return true; | 50 | return true; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | void process_audio_noteon(uint8_t note) { play_note(compute_freq_for_midi_note(note), 0xF); } | 53 | void process_audio_noteon(uint8_t note) { |
| 54 | play_note(compute_freq_for_midi_note(note), 0xF); | ||
| 55 | } | ||
| 54 | 56 | ||
| 55 | void process_audio_noteoff(uint8_t note) { stop_note(compute_freq_for_midi_note(note)); } | 57 | void process_audio_noteoff(uint8_t note) { |
| 58 | stop_note(compute_freq_for_midi_note(note)); | ||
| 59 | } | ||
| 56 | 60 | ||
| 57 | void process_audio_all_notes_off(void) { stop_all_notes(); } | 61 | void process_audio_all_notes_off(void) { |
| 62 | stop_all_notes(); | ||
| 63 | } | ||
| 58 | 64 | ||
| 59 | __attribute__((weak)) void audio_on_user() {} | 65 | __attribute__((weak)) void audio_on_user() {} |
| 60 | __attribute__((weak)) void audio_off_user() {} | 66 | __attribute__((weak)) void audio_off_user() {} |
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index bbc6367ff1..2150edd7b2 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c | |||
| @@ -62,7 +62,9 @@ static struct { | |||
| 62 | // clang-format on | 62 | // clang-format on |
| 63 | 63 | ||
| 64 | /** \brief Called on physical press, returns whether key should be added to Auto Shift */ | 64 | /** \brief Called on physical press, returns whether key should be added to Auto Shift */ |
| 65 | __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { return false; } | 65 | __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { |
| 66 | return false; | ||
| 67 | } | ||
| 66 | 68 | ||
| 67 | /** \brief Called on physical press, returns whether is Auto Shift key */ | 69 | /** \brief Called on physical press, returns whether is Auto Shift key */ |
| 68 | __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { | 70 | __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { |
| @@ -82,8 +84,12 @@ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *r | |||
| 82 | } | 84 | } |
| 83 | 85 | ||
| 84 | /** \brief Called to check whether defines should apply if PER_KEY is set for it */ | 86 | /** \brief Called to check whether defines should apply if PER_KEY is set for it */ |
| 85 | __attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) { return true; } | 87 | __attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) { |
| 86 | __attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) { return true; } | 88 | return true; |
| 89 | } | ||
| 90 | __attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) { | ||
| 91 | return true; | ||
| 92 | } | ||
| 87 | 93 | ||
| 88 | /** \brief Called when an Auto Shift key needs to be pressed */ | 94 | /** \brief Called when an Auto Shift key needs to be pressed */ |
| 89 | __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) { | 95 | __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) { |
| @@ -94,7 +100,9 @@ __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, | |||
| 94 | } | 100 | } |
| 95 | 101 | ||
| 96 | /** \brief Called when an Auto Shift key needs to be released */ | 102 | /** \brief Called when an Auto Shift key needs to be released */ |
| 97 | __attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) { unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); } | 103 | __attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) { |
| 104 | unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); | ||
| 105 | } | ||
| 98 | 106 | ||
| 99 | /** \brief Sets the shift state to use when keyrepeating, required by custom shifts */ | 107 | /** \brief Sets the shift state to use when keyrepeating, required by custom shifts */ |
| 100 | void set_autoshift_shift_state(uint16_t keycode, bool shifted) { | 108 | void set_autoshift_shift_state(uint16_t keycode, bool shifted) { |
| @@ -311,7 +319,9 @@ void autoshift_toggle(void) { | |||
| 311 | autoshift_flush_shift(); | 319 | autoshift_flush_shift(); |
| 312 | } | 320 | } |
| 313 | 321 | ||
| 314 | void autoshift_enable(void) { autoshift_flags.enabled = true; } | 322 | void autoshift_enable(void) { |
| 323 | autoshift_flags.enabled = true; | ||
| 324 | } | ||
| 315 | 325 | ||
| 316 | void autoshift_disable(void) { | 326 | void autoshift_disable(void) { |
| 317 | autoshift_flags.enabled = false; | 327 | autoshift_flags.enabled = false; |
| @@ -328,12 +338,20 @@ void autoshift_timer_report(void) { | |||
| 328 | } | 338 | } |
| 329 | # endif | 339 | # endif |
| 330 | 340 | ||
| 331 | bool get_autoshift_state(void) { return autoshift_flags.enabled; } | 341 | bool get_autoshift_state(void) { |
| 342 | return autoshift_flags.enabled; | ||
| 343 | } | ||
| 332 | 344 | ||
| 333 | uint16_t get_generic_autoshift_timeout() { return autoshift_timeout; } | 345 | uint16_t get_generic_autoshift_timeout() { |
| 334 | __attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) { return autoshift_timeout; } | 346 | return autoshift_timeout; |
| 347 | } | ||
| 348 | __attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) { | ||
| 349 | return autoshift_timeout; | ||
| 350 | } | ||
| 335 | 351 | ||
| 336 | void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } | 352 | void set_autoshift_timeout(uint16_t timeout) { |
| 353 | autoshift_timeout = timeout; | ||
| 354 | } | ||
| 337 | 355 | ||
| 338 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | 356 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { |
| 339 | // Note that record->event.time isn't reliable, see: | 357 | // Note that record->event.time isn't reliable, see: |
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c index 6ab382d4aa..9795734984 100644 --- a/quantum/process_keycode/process_clicky.c +++ b/quantum/process_keycode/process_clicky.c | |||
| @@ -5,40 +5,40 @@ | |||
| 5 | 5 | ||
| 6 | # ifndef AUDIO_CLICKY_DELAY_DURATION | 6 | # ifndef AUDIO_CLICKY_DELAY_DURATION |
| 7 | # define AUDIO_CLICKY_DELAY_DURATION 1 | 7 | # define AUDIO_CLICKY_DELAY_DURATION 1 |
| 8 | # endif // !AUDIO_CLICKY_DELAY_DURATION | 8 | # endif // !AUDIO_CLICKY_DELAY_DURATION |
| 9 | # ifndef AUDIO_CLICKY_FREQ_DEFAULT | 9 | # ifndef AUDIO_CLICKY_FREQ_DEFAULT |
| 10 | # define AUDIO_CLICKY_FREQ_DEFAULT 440.0f | 10 | # define AUDIO_CLICKY_FREQ_DEFAULT 440.0f |
| 11 | # endif // !AUDIO_CLICKY_FREQ_DEFAULT | 11 | # endif // !AUDIO_CLICKY_FREQ_DEFAULT |
| 12 | # ifndef AUDIO_CLICKY_FREQ_MIN | 12 | # ifndef AUDIO_CLICKY_FREQ_MIN |
| 13 | # define AUDIO_CLICKY_FREQ_MIN 65.0f | 13 | # define AUDIO_CLICKY_FREQ_MIN 65.0f |
| 14 | # endif // !AUDIO_CLICKY_FREQ_MIN | 14 | # endif // !AUDIO_CLICKY_FREQ_MIN |
| 15 | # ifndef AUDIO_CLICKY_FREQ_MAX | 15 | # ifndef AUDIO_CLICKY_FREQ_MAX |
| 16 | # define AUDIO_CLICKY_FREQ_MAX 1500.0f | 16 | # define AUDIO_CLICKY_FREQ_MAX 1500.0f |
| 17 | # endif // !AUDIO_CLICKY_FREQ_MAX | 17 | # endif // !AUDIO_CLICKY_FREQ_MAX |
| 18 | # ifndef AUDIO_CLICKY_FREQ_FACTOR | 18 | # ifndef AUDIO_CLICKY_FREQ_FACTOR |
| 19 | # define AUDIO_CLICKY_FREQ_FACTOR 1.18921f | 19 | # define AUDIO_CLICKY_FREQ_FACTOR 1.18921f |
| 20 | # endif // !AUDIO_CLICKY_FREQ_FACTOR | 20 | # endif // !AUDIO_CLICKY_FREQ_FACTOR |
| 21 | # ifndef AUDIO_CLICKY_FREQ_RANDOMNESS | 21 | # ifndef AUDIO_CLICKY_FREQ_RANDOMNESS |
| 22 | # define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f | 22 | # define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f |
| 23 | # endif // !AUDIO_CLICKY_FREQ_RANDOMNESS | 23 | # endif // !AUDIO_CLICKY_FREQ_RANDOMNESS |
| 24 | 24 | ||
| 25 | float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; | 25 | float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; |
| 26 | float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS; | 26 | float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS; |
| 27 | 27 | ||
| 28 | // the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky" | 28 | // the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky" |
| 29 | float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations | 29 | float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations |
| 30 | 30 | ||
| 31 | extern audio_config_t audio_config; | 31 | extern audio_config_t audio_config; |
| 32 | 32 | ||
| 33 | # ifndef NO_MUSIC_MODE | 33 | # ifndef NO_MUSIC_MODE |
| 34 | extern bool music_activated; | 34 | extern bool music_activated; |
| 35 | extern bool midi_activated; | 35 | extern bool midi_activated; |
| 36 | # endif // !NO_MUSIC_MODE | 36 | # endif // !NO_MUSIC_MODE |
| 37 | 37 | ||
| 38 | void clicky_play(void) { | 38 | void clicky_play(void) { |
| 39 | # ifndef NO_MUSIC_MODE | 39 | # ifndef NO_MUSIC_MODE |
| 40 | if (music_activated || midi_activated || !audio_config.enable) return; | 40 | if (music_activated || midi_activated || !audio_config.enable) return; |
| 41 | # endif // !NO_MUSIC_MODE | 41 | # endif // !NO_MUSIC_MODE |
| 42 | clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); | 42 | clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); |
| 43 | clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); | 43 | clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); |
| 44 | PLAY_SONG(clicky_song); | 44 | PLAY_SONG(clicky_song); |
| @@ -58,7 +58,9 @@ void clicky_freq_down(void) { | |||
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | void clicky_freq_reset(void) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } | 61 | void clicky_freq_reset(void) { |
| 62 | clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; | ||
| 63 | } | ||
| 62 | 64 | ||
| 63 | void clicky_toggle(void) { | 65 | void clicky_toggle(void) { |
| 64 | audio_config.clicky_enable ^= 1; | 66 | audio_config.clicky_enable ^= 1; |
| @@ -75,7 +77,9 @@ void clicky_off(void) { | |||
| 75 | eeconfig_update_audio(audio_config.raw); | 77 | eeconfig_update_audio(audio_config.raw); |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | bool is_clicky_on(void) { return (audio_config.clicky_enable != 0); } | 80 | bool is_clicky_on(void) { |
| 81 | return (audio_config.clicky_enable != 0); | ||
| 82 | } | ||
| 79 | 83 | ||
| 80 | bool process_clicky(uint16_t keycode, keyrecord_t *record) { | 84 | bool process_clicky(uint16_t keycode, keyrecord_t *record) { |
| 81 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { | 85 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { |
| @@ -101,8 +105,8 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) { | |||
| 101 | } | 105 | } |
| 102 | 106 | ||
| 103 | if (audio_config.enable && audio_config.clicky_enable) { | 107 | if (audio_config.enable && audio_config.clicky_enable) { |
| 104 | if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound | 108 | if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound |
| 105 | if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM | 109 | if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM |
| 106 | clicky_play(); | 110 | clicky_play(); |
| 107 | } | 111 | } |
| 108 | } | 112 | } |
| @@ -110,4 +114,4 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) { | |||
| 110 | return true; | 114 | return true; |
| 111 | } | 115 | } |
| 112 | 116 | ||
| 113 | #endif // AUDIO_CLICKY | 117 | #endif // AUDIO_CLICKY |
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 21fd737ab7..efaf8fe0e9 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -30,33 +30,45 @@ extern uint16_t COMBO_LEN; | |||
| 30 | __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} | 30 | __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} |
| 31 | 31 | ||
| 32 | #ifdef COMBO_MUST_HOLD_PER_COMBO | 32 | #ifdef COMBO_MUST_HOLD_PER_COMBO |
| 33 | __attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { return false; } | 33 | __attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { |
| 34 | return false; | ||
| 35 | } | ||
| 34 | #endif | 36 | #endif |
| 35 | 37 | ||
| 36 | #ifdef COMBO_MUST_TAP_PER_COMBO | 38 | #ifdef COMBO_MUST_TAP_PER_COMBO |
| 37 | __attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { return false; } | 39 | __attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { |
| 40 | return false; | ||
| 41 | } | ||
| 38 | #endif | 42 | #endif |
| 39 | 43 | ||
| 40 | #ifdef COMBO_TERM_PER_COMBO | 44 | #ifdef COMBO_TERM_PER_COMBO |
| 41 | __attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { return COMBO_TERM; } | 45 | __attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { |
| 46 | return COMBO_TERM; | ||
| 47 | } | ||
| 42 | #endif | 48 | #endif |
| 43 | 49 | ||
| 44 | #ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO | 50 | #ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO |
| 45 | __attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) { return true; } | 51 | __attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) { |
| 52 | return true; | ||
| 53 | } | ||
| 46 | #endif | 54 | #endif |
| 47 | 55 | ||
| 48 | #ifdef COMBO_PROCESS_KEY_RELEASE | 56 | #ifdef COMBO_PROCESS_KEY_RELEASE |
| 49 | __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { return false; } | 57 | __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { |
| 58 | return false; | ||
| 59 | } | ||
| 50 | #endif | 60 | #endif |
| 51 | 61 | ||
| 52 | #ifdef COMBO_SHOULD_TRIGGER | 62 | #ifdef COMBO_SHOULD_TRIGGER |
| 53 | __attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { return true; } | 63 | __attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { |
| 64 | return true; | ||
| 65 | } | ||
| 54 | #endif | 66 | #endif |
| 55 | 67 | ||
| 56 | #ifndef COMBO_NO_TIMER | 68 | #ifndef COMBO_NO_TIMER |
| 57 | static uint16_t timer = 0; | 69 | static uint16_t timer = 0; |
| 58 | #endif | 70 | #endif |
| 59 | static bool b_combo_enable = true; // defaults to enabled | 71 | static bool b_combo_enable = true; // defaults to enabled |
| 60 | static uint16_t longest_term = 0; | 72 | static uint16_t longest_term = 0; |
| 61 | 73 | ||
| 62 | typedef struct { | 74 | typedef struct { |
| @@ -462,7 +474,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 462 | // get possible longer waiting time for tap-/hold-only combos. | 474 | // get possible longer waiting time for tap-/hold-only combos. |
| 463 | longest_term = _get_wait_time(combo_index, combo); | 475 | longest_term = _get_wait_time(combo_index, combo); |
| 464 | } | 476 | } |
| 465 | } // if timer elapsed end | 477 | } // if timer elapsed end |
| 466 | } | 478 | } |
| 467 | } else { | 479 | } else { |
| 468 | // chord releases | 480 | // chord releases |
| @@ -477,7 +489,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 477 | else if (get_combo_must_tap(combo_index, combo)) { | 489 | else if (get_combo_must_tap(combo_index, combo)) { |
| 478 | // immediately apply tap-only combo | 490 | // immediately apply tap-only combo |
| 479 | apply_combo(combo_index, combo); | 491 | apply_combo(combo_index, combo); |
| 480 | apply_combos(); // also apply other prepared combos and dump key buffer | 492 | apply_combos(); // also apply other prepared combos and dump key buffer |
| 481 | # ifdef COMBO_PROCESS_KEY_RELEASE | 493 | # ifdef COMBO_PROCESS_KEY_RELEASE |
| 482 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { | 494 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { |
| 483 | release_combo(combo_index, combo); | 495 | release_combo(combo_index, combo); |
| @@ -559,7 +571,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
| 559 | key_buffer[key_buffer_size++] = (queued_record_t){ | 571 | key_buffer[key_buffer_size++] = (queued_record_t){ |
| 560 | .record = *record, | 572 | .record = *record, |
| 561 | .keycode = keycode, | 573 | .keycode = keycode, |
| 562 | .combo_index = -1, // this will be set when applying combos | 574 | .combo_index = -1, // this will be set when applying combos |
| 563 | }; | 575 | }; |
| 564 | } | 576 | } |
| 565 | } else { | 577 | } else { |
| @@ -598,7 +610,9 @@ void combo_task(void) { | |||
| 598 | #endif | 610 | #endif |
| 599 | } | 611 | } |
| 600 | 612 | ||
| 601 | void combo_enable(void) { b_combo_enable = true; } | 613 | void combo_enable(void) { |
| 614 | b_combo_enable = true; | ||
| 615 | } | ||
| 602 | 616 | ||
| 603 | void combo_disable(void) { | 617 | void combo_disable(void) { |
| 604 | #ifndef COMBO_NO_TIMER | 618 | #ifndef COMBO_NO_TIMER |
| @@ -618,4 +632,6 @@ void combo_toggle(void) { | |||
| 618 | } | 632 | } |
| 619 | } | 633 | } |
| 620 | 634 | ||
| 621 | bool is_combo_enabled(void) { return b_combo_enable; } | 635 | bool is_combo_enabled(void) { |
| 636 | return b_combo_enable; | ||
| 637 | } | ||
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c index 0feb634014..a1ada2d5a2 100644 --- a/quantum/process_keycode/process_dynamic_macro.c +++ b/quantum/process_keycode/process_dynamic_macro.c | |||
| @@ -29,13 +29,21 @@ void dynamic_macro_led_blink(void) { | |||
| 29 | 29 | ||
| 30 | /* User hooks for Dynamic Macros */ | 30 | /* User hooks for Dynamic Macros */ |
| 31 | 31 | ||
| 32 | __attribute__((weak)) void dynamic_macro_record_start_user(void) { dynamic_macro_led_blink(); } | 32 | __attribute__((weak)) void dynamic_macro_record_start_user(void) { |
| 33 | dynamic_macro_led_blink(); | ||
| 34 | } | ||
| 33 | 35 | ||
| 34 | __attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { dynamic_macro_led_blink(); } | 36 | __attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { |
| 37 | dynamic_macro_led_blink(); | ||
| 38 | } | ||
| 35 | 39 | ||
| 36 | __attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { dynamic_macro_led_blink(); } | 40 | __attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { |
| 41 | dynamic_macro_led_blink(); | ||
| 42 | } | ||
| 37 | 43 | ||
| 38 | __attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); } | 44 | __attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { |
| 45 | dynamic_macro_led_blink(); | ||
| 46 | } | ||
| 39 | 47 | ||
| 40 | /* Convenience macros used for retrieving the debug info. All of them | 48 | /* Convenience macros used for retrieving the debug info. All of them |
| 41 | * need a `direction` variable accessible at the call site. | 49 | * need a `direction` variable accessible at the call site. |
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index fa9c2c1dbc..2fb092c573 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c | |||
| @@ -74,7 +74,9 @@ void restorePinState(pin_t pin, uint16_t restoreState) { | |||
| 74 | #endif | 74 | #endif |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | __attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); } | 77 | __attribute__((weak)) bool process_joystick_analogread() { |
| 78 | return process_joystick_analogread_quantum(); | ||
| 79 | } | ||
| 78 | 80 | ||
| 79 | bool process_joystick_analogread_quantum() { | 81 | bool process_joystick_analogread_quantum() { |
| 80 | #if JOYSTICK_AXES_COUNT > 0 | 82 | #if JOYSTICK_AXES_COUNT > 0 |
diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c index 09b2725079..ad9683d106 100644 --- a/quantum/process_keycode/process_key_override.c +++ b/quantum/process_keycode/process_key_override.c | |||
| @@ -106,7 +106,9 @@ void key_override_toggle(void) { | |||
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | bool key_override_is_enabled(void) { return enabled; } | 109 | bool key_override_is_enabled(void) { |
| 110 | return enabled; | ||
| 111 | } | ||
| 110 | 112 | ||
| 111 | // Returns whether the modifiers that are pressed are such that the override should activate | 113 | // Returns whether the modifiers that are pressed are such that the override should activate |
| 112 | static bool key_override_matches_active_modifiers(const key_override_t *override, const uint8_t mods) { | 114 | static bool key_override_matches_active_modifiers(const key_override_t *override, const uint8_t mods) { |
| @@ -150,7 +152,7 @@ static void schedule_deferred_register(const uint16_t keycode) { | |||
| 150 | } else { | 152 | } else { |
| 151 | // Wait a very short time when a modifier event triggers the override to avoid false activations when e.g. a modifier is pressed just before a key is released (with the intention of pairing the modifier with a different key), or a modifier is lifted shortly before the trigger key is lifted. Operating systems by default reject modifier-events that happen very close to a non-modifier event. | 153 | // Wait a very short time when a modifier event triggers the override to avoid false activations when e.g. a modifier is pressed just before a key is released (with the intention of pairing the modifier with a different key), or a modifier is lifted shortly before the trigger key is lifted. Operating systems by default reject modifier-events that happen very close to a non-modifier event. |
| 152 | defer_reference_time = timer_read32(); | 154 | defer_reference_time = timer_read32(); |
| 153 | defer_delay = 50; // 50ms | 155 | defer_delay = 50; // 50ms |
| 154 | } | 156 | } |
| 155 | deferred_register = keycode; | 157 | deferred_register = keycode; |
| 156 | } | 158 | } |
| @@ -174,8 +176,8 @@ const key_override_t *clear_active_override(const bool allow_reregister) { | |||
| 174 | 176 | ||
| 175 | const uint8_t mod_free_replacement = clear_mods_from(active_override->replacement); | 177 | const uint8_t mod_free_replacement = clear_mods_from(active_override->replacement); |
| 176 | 178 | ||
| 177 | bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered | 179 | bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered |
| 178 | mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered | 180 | mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered |
| 179 | 181 | ||
| 180 | // Try firing the custom handler | 182 | // Try firing the custom handler |
| 181 | if (active_override->custom_action != NULL) { | 183 | if (active_override->custom_action != NULL) { |
| @@ -195,11 +197,11 @@ const key_override_t *clear_active_override(const bool allow_reregister) { | |||
| 195 | 197 | ||
| 196 | const uint16_t trigger = active_override->trigger; | 198 | const uint16_t trigger = active_override->trigger; |
| 197 | 199 | ||
| 198 | const bool reregister_trigger = allow_reregister && // Check if allowed from caller | 200 | const bool reregister_trigger = allow_reregister && // Check if allowed from caller |
| 199 | (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows | 201 | (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows |
| 200 | active_override_trigger_is_down && // Check if trigger is even down | 202 | active_override_trigger_is_down && // Check if trigger is even down |
| 201 | trigger != KC_NO && // KC_NO is never registered | 203 | trigger != KC_NO && // KC_NO is never registered |
| 202 | trigger < SAFE_RANGE; // A custom keycode should not be registered | 204 | trigger < SAFE_RANGE; // A custom keycode should not be registered |
| 203 | 205 | ||
| 204 | // Optionally re-register the trigger if it is still down | 206 | // Optionally re-register the trigger if it is still down |
| 205 | if (reregister_trigger) { | 207 | if (reregister_trigger) { |
| @@ -336,8 +338,8 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer, | |||
| 336 | 338 | ||
| 337 | const uint16_t mod_free_replacement = clear_mods_from(override->replacement); | 339 | const uint16_t mod_free_replacement = clear_mods_from(override->replacement); |
| 338 | 340 | ||
| 339 | bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered | 341 | bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered |
| 340 | mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered | 342 | mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered |
| 341 | 343 | ||
| 342 | // Try firing the custom handler | 344 | // Try firing the custom handler |
| 343 | if (override->custom_action != NULL) { | 345 | if (override->custom_action != NULL) { |
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index cf63f25141..c2fd02e5c7 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c | |||
| @@ -51,13 +51,13 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { | |||
| 51 | if (leading) { | 51 | if (leading) { |
| 52 | # ifndef LEADER_NO_TIMEOUT | 52 | # ifndef LEADER_NO_TIMEOUT |
| 53 | if (timer_elapsed(leader_time) < LEADER_TIMEOUT) | 53 | if (timer_elapsed(leader_time) < LEADER_TIMEOUT) |
| 54 | # endif // LEADER_NO_TIMEOUT | 54 | # endif // LEADER_NO_TIMEOUT |
| 55 | { | 55 | { |
| 56 | # ifndef LEADER_KEY_STRICT_KEY_PROCESSING | 56 | # ifndef LEADER_KEY_STRICT_KEY_PROCESSING |
| 57 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { | 57 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { |
| 58 | keycode = keycode & 0xFF; | 58 | keycode = keycode & 0xFF; |
| 59 | } | 59 | } |
| 60 | # endif // LEADER_KEY_STRICT_KEY_PROCESSING | 60 | # endif // LEADER_KEY_STRICT_KEY_PROCESSING |
| 61 | if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { | 61 | if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { |
| 62 | leader_sequence[leader_sequence_size] = keycode; | 62 | leader_sequence[leader_sequence_size] = keycode; |
| 63 | leader_sequence_size++; | 63 | leader_sequence_size++; |
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 6332be647c..10161adda3 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c | |||
| @@ -76,7 +76,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { | |||
| 76 | keymap_config.swap_backslash_backspace = true; | 76 | keymap_config.swap_backslash_backspace = true; |
| 77 | break; | 77 | break; |
| 78 | case MAGIC_HOST_NKRO: | 78 | case MAGIC_HOST_NKRO: |
| 79 | clear_keyboard(); // clear first buffer to prevent stuck keys | 79 | clear_keyboard(); // clear first buffer to prevent stuck keys |
| 80 | keymap_config.nkro = true; | 80 | keymap_config.nkro = true; |
| 81 | break; | 81 | break; |
| 82 | case MAGIC_SWAP_ALT_GUI: | 82 | case MAGIC_SWAP_ALT_GUI: |
| @@ -119,7 +119,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { | |||
| 119 | keymap_config.swap_backslash_backspace = false; | 119 | keymap_config.swap_backslash_backspace = false; |
| 120 | break; | 120 | break; |
| 121 | case MAGIC_UNHOST_NKRO: | 121 | case MAGIC_UNHOST_NKRO: |
| 122 | clear_keyboard(); // clear first buffer to prevent stuck keys | 122 | clear_keyboard(); // clear first buffer to prevent stuck keys |
| 123 | keymap_config.nkro = false; | 123 | keymap_config.nkro = false; |
| 124 | break; | 124 | break; |
| 125 | case MAGIC_UNSWAP_ALT_GUI: | 125 | case MAGIC_UNSWAP_ALT_GUI: |
| @@ -157,7 +157,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { | |||
| 157 | #endif | 157 | #endif |
| 158 | break; | 158 | break; |
| 159 | case MAGIC_TOGGLE_NKRO: | 159 | case MAGIC_TOGGLE_NKRO: |
| 160 | clear_keyboard(); // clear first buffer to prevent stuck keys | 160 | clear_keyboard(); // clear first buffer to prevent stuck keys |
| 161 | keymap_config.nkro = !keymap_config.nkro; | 161 | keymap_config.nkro = !keymap_config.nkro; |
| 162 | break; | 162 | break; |
| 163 | case MAGIC_EE_HANDS_LEFT: | 163 | case MAGIC_EE_HANDS_LEFT: |
| @@ -175,7 +175,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { | |||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | eeconfig_update_keymap(keymap_config.raw); | 177 | eeconfig_update_keymap(keymap_config.raw); |
| 178 | clear_keyboard(); // clear to prevent stuck keys | 178 | clear_keyboard(); // clear to prevent stuck keys |
| 179 | 179 | ||
| 180 | return false; | 180 | return false; |
| 181 | } | 181 | } |
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index 9632d2b757..c49c31a525 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c | |||
| @@ -22,13 +22,19 @@ | |||
| 22 | 22 | ||
| 23 | # ifdef MIDI_BASIC | 23 | # ifdef MIDI_BASIC |
| 24 | 24 | ||
| 25 | void process_midi_basic_noteon(uint8_t note) { midi_send_noteon(&midi_device, 0, note, 127); } | 25 | void process_midi_basic_noteon(uint8_t note) { |
| 26 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 27 | } | ||
| 26 | 28 | ||
| 27 | void process_midi_basic_noteoff(uint8_t note) { midi_send_noteoff(&midi_device, 0, note, 0); } | 29 | void process_midi_basic_noteoff(uint8_t note) { |
| 30 | midi_send_noteoff(&midi_device, 0, note, 0); | ||
| 31 | } | ||
| 28 | 32 | ||
| 29 | void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0); } | 33 | void process_midi_all_notes_off(void) { |
| 34 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 35 | } | ||
| 30 | 36 | ||
| 31 | # endif // MIDI_BASIC | 37 | # endif // MIDI_BASIC |
| 32 | 38 | ||
| 33 | # ifdef MIDI_ADVANCED | 39 | # ifdef MIDI_ADVANCED |
| 34 | 40 | ||
| @@ -41,7 +47,9 @@ static int8_t midi_modulation_step; | |||
| 41 | static uint16_t midi_modulation_timer; | 47 | static uint16_t midi_modulation_timer; |
| 42 | midi_config_t midi_config; | 48 | midi_config_t midi_config; |
| 43 | 49 | ||
| 44 | inline uint8_t compute_velocity(uint8_t setting) { return setting * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN)); } | 50 | inline uint8_t compute_velocity(uint8_t setting) { |
| 51 | return setting * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN)); | ||
| 52 | } | ||
| 45 | 53 | ||
| 46 | void midi_init(void) { | 54 | void midi_init(void) { |
| 47 | midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN; | 55 | midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN; |
| @@ -60,7 +68,9 @@ void midi_init(void) { | |||
| 60 | midi_modulation_timer = 0; | 68 | midi_modulation_timer = 0; |
| 61 | } | 69 | } |
| 62 | 70 | ||
| 63 | uint8_t midi_compute_note(uint16_t keycode) { return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose; } | 71 | uint8_t midi_compute_note(uint16_t keycode) { |
| 72 | return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose; | ||
| 73 | } | ||
| 64 | 74 | ||
| 65 | bool process_midi(uint16_t keycode, keyrecord_t *record) { | 75 | bool process_midi(uint16_t keycode, keyrecord_t *record) { |
| 66 | switch (keycode) { | 76 | switch (keycode) { |
| @@ -238,7 +248,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { | |||
| 238 | return true; | 248 | return true; |
| 239 | } | 249 | } |
| 240 | 250 | ||
| 241 | # endif // MIDI_ADVANCED | 251 | # endif // MIDI_ADVANCED |
| 242 | 252 | ||
| 243 | void midi_task(void) { | 253 | void midi_task(void) { |
| 244 | midi_device_process(&midi_device); | 254 | midi_device_process(&midi_device); |
| @@ -263,4 +273,4 @@ void midi_task(void) { | |||
| 263 | # endif | 273 | # endif |
| 264 | } | 274 | } |
| 265 | 275 | ||
| 266 | #endif // MIDI_ENABLE | 276 | #endif // MIDI_ENABLE |
diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h index 68c6eda666..e528c6ec0c 100644 --- a/quantum/process_keycode/process_midi.h +++ b/quantum/process_keycode/process_midi.h | |||
| @@ -49,6 +49,6 @@ bool process_midi(uint16_t keycode, keyrecord_t *record); | |||
| 49 | # define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) | 49 | # define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) |
| 50 | 50 | ||
| 51 | uint8_t midi_compute_note(uint16_t keycode); | 51 | uint8_t midi_compute_note(uint16_t keycode); |
| 52 | # endif // MIDI_ADVANCED | 52 | # endif // MIDI_ADVANCED |
| 53 | 53 | ||
| 54 | #endif // MIDI_ENABLE | 54 | #endif // MIDI_ENABLE |
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 6822c5e289..eeec0c28a4 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c | |||
| @@ -146,7 +146,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 146 | 146 | ||
| 147 | if (music_activated || midi_activated) { | 147 | if (music_activated || midi_activated) { |
| 148 | if (record->event.pressed) { | 148 | if (record->event.pressed) { |
| 149 | if (keycode == KC_LEFT_CTRL) { // Start recording | 149 | if (keycode == KC_LEFT_CTRL) { // Start recording |
| 150 | music_all_notes_off(); | 150 | music_all_notes_off(); |
| 151 | music_sequence_recording = true; | 151 | music_sequence_recording = true; |
| 152 | music_sequence_recorded = false; | 152 | music_sequence_recorded = false; |
| @@ -155,9 +155,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 155 | return false; | 155 | return false; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | if (keycode == KC_LEFT_ALT) { // Stop recording/playing | 158 | if (keycode == KC_LEFT_ALT) { // Stop recording/playing |
| 159 | music_all_notes_off(); | 159 | music_all_notes_off(); |
| 160 | if (music_sequence_recording) { // was recording | 160 | if (music_sequence_recording) { // was recording |
| 161 | music_sequence_recorded = true; | 161 | music_sequence_recorded = true; |
| 162 | } | 162 | } |
| 163 | music_sequence_recording = false; | 163 | music_sequence_recording = false; |
| @@ -165,7 +165,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 165 | return false; | 165 | return false; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | if (keycode == KC_LEFT_GUI && music_sequence_recorded) { // Start playing | 168 | if (keycode == KC_LEFT_GUI && music_sequence_recorded) { // Start playing |
| 169 | music_all_notes_off(); | 169 | music_all_notes_off(); |
| 170 | music_sequence_recording = false; | 170 | music_sequence_recording = false; |
| 171 | music_sequence_playing = true; | 171 | music_sequence_playing = true; |
| @@ -230,11 +230,17 @@ bool music_mask(uint16_t keycode) { | |||
| 230 | # endif | 230 | # endif |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | __attribute__((weak)) bool music_mask_kb(uint16_t keycode) { return music_mask_user(keycode); } | 233 | __attribute__((weak)) bool music_mask_kb(uint16_t keycode) { |
| 234 | return music_mask_user(keycode); | ||
| 235 | } | ||
| 234 | 236 | ||
| 235 | __attribute__((weak)) bool music_mask_user(uint16_t keycode) { return keycode < 0xFF; } | 237 | __attribute__((weak)) bool music_mask_user(uint16_t keycode) { |
| 238 | return keycode < 0xFF; | ||
| 239 | } | ||
| 236 | 240 | ||
| 237 | bool is_music_on(void) { return (music_activated != 0); } | 241 | bool is_music_on(void) { |
| 242 | return (music_activated != 0); | ||
| 243 | } | ||
| 238 | 244 | ||
| 239 | void music_toggle(void) { | 245 | void music_toggle(void) { |
| 240 | if (!music_activated) { | 246 | if (!music_activated) { |
| @@ -260,7 +266,9 @@ void music_off(void) { | |||
| 260 | # endif | 266 | # endif |
| 261 | } | 267 | } |
| 262 | 268 | ||
| 263 | bool is_midi_on(void) { return (midi_activated != 0); } | 269 | bool is_midi_on(void) { |
| 270 | return (midi_activated != 0); | ||
| 271 | } | ||
| 264 | 272 | ||
| 265 | void midi_toggle(void) { | 273 | void midi_toggle(void) { |
| 266 | if (!midi_activated) { | 274 | if (!midi_activated) { |
| @@ -315,4 +323,4 @@ __attribute__((weak)) void midi_on_user() {} | |||
| 315 | 323 | ||
| 316 | __attribute__((weak)) void music_scale_user() {} | 324 | __attribute__((weak)) void music_scale_user() {} |
| 317 | 325 | ||
| 318 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | 326 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) |
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h index e275cd9d26..83726a05ba 100644 --- a/quantum/process_keycode/process_music.h +++ b/quantum/process_keycode/process_music.h | |||
| @@ -51,8 +51,10 @@ bool music_mask_kb(uint16_t keycode); | |||
| 51 | bool music_mask_user(uint16_t keycode); | 51 | bool music_mask_user(uint16_t keycode); |
| 52 | 52 | ||
| 53 | # ifndef SCALE | 53 | # ifndef SCALE |
| 54 | # define SCALE \ | 54 | # define SCALE \ |
| 55 | (int8_t[]) { 0 + (12 * 0), 2 + (12 * 0), 4 + (12 * 0), 5 + (12 * 0), 7 + (12 * 0), 9 + (12 * 0), 11 + (12 * 0), 0 + (12 * 1), 2 + (12 * 1), 4 + (12 * 1), 5 + (12 * 1), 7 + (12 * 1), 9 + (12 * 1), 11 + (12 * 1), 0 + (12 * 2), 2 + (12 * 2), 4 + (12 * 2), 5 + (12 * 2), 7 + (12 * 2), 9 + (12 * 2), 11 + (12 * 2), 0 + (12 * 3), 2 + (12 * 3), 4 + (12 * 3), 5 + (12 * 3), 7 + (12 * 3), 9 + (12 * 3), 11 + (12 * 3), 0 + (12 * 4), 2 + (12 * 4), 4 + (12 * 4), 5 + (12 * 4), 7 + (12 * 4), 9 + (12 * 4), 11 + (12 * 4), } | 55 | (int8_t[]) { \ |
| 56 | 0 + (12 * 0), 2 + (12 * 0), 4 + (12 * 0), 5 + (12 * 0), 7 + (12 * 0), 9 + (12 * 0), 11 + (12 * 0), 0 + (12 * 1), 2 + (12 * 1), 4 + (12 * 1), 5 + (12 * 1), 7 + (12 * 1), 9 + (12 * 1), 11 + (12 * 1), 0 + (12 * 2), 2 + (12 * 2), 4 + (12 * 2), 5 + (12 * 2), 7 + (12 * 2), 9 + (12 * 2), 11 + (12 * 2), 0 + (12 * 3), 2 + (12 * 3), 4 + (12 * 3), 5 + (12 * 3), 7 + (12 * 3), 9 + (12 * 3), 11 + (12 * 3), 0 + (12 * 4), 2 + (12 * 4), 4 + (12 * 4), 5 + (12 * 4), 7 + (12 * 4), 9 + (12 * 4), 11 + (12 * 4), \ | ||
| 57 | } | ||
| 56 | # endif | 58 | # endif |
| 57 | 59 | ||
| 58 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | 60 | #endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) |
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c index 0801f078ef..6dd1f28c9b 100644 --- a/quantum/process_keycode/process_printer.c +++ b/quantum/process_keycode/process_printer.c | |||
| @@ -26,7 +26,9 @@ void enable_printing(void) { | |||
| 26 | uart_init(19200); | 26 | uart_init(19200); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void disable_printing(void) { printing_enabled = false; } | 29 | void disable_printing(void) { |
| 30 | printing_enabled = false; | ||
| 31 | } | ||
| 30 | 32 | ||
| 31 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | 33 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; |
| 32 | 34 | ||
| @@ -41,7 +43,8 @@ void print_char(char c) { | |||
| 41 | } | 43 | } |
| 42 | 44 | ||
| 43 | void print_string(char c[]) { | 45 | void print_string(char c[]) { |
| 44 | for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]); | 46 | for (uint8_t i = 0; i < strlen(c); i++) |
| 47 | print_char(c[i]); | ||
| 45 | } | 48 | } |
| 46 | 49 | ||
| 47 | void print_box_string(const char text[]) { | 50 | void print_box_string(const char text[]) { |
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c index 6c91bd27ef..88a9f33994 100644 --- a/quantum/process_keycode/process_printer_bb.c +++ b/quantum/process_keycode/process_printer_bb.c | |||
| @@ -25,13 +25,21 @@ uint8_t character_shift = 0; | |||
| 25 | #define SERIAL_PIN_MASK _BV(PD3) | 25 | #define SERIAL_PIN_MASK _BV(PD3) |
| 26 | #define SERIAL_DELAY 52 | 26 | #define SERIAL_DELAY 52 |
| 27 | 27 | ||
| 28 | inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); } | 28 | inline static void serial_delay(void) { |
| 29 | _delay_us(SERIAL_DELAY); | ||
| 30 | } | ||
| 29 | 31 | ||
| 30 | inline static void serial_high(void) { SERIAL_PIN_PORT |= SERIAL_PIN_MASK; } | 32 | inline static void serial_high(void) { |
| 33 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
| 34 | } | ||
| 31 | 35 | ||
| 32 | inline static void serial_low(void) { SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; } | 36 | inline static void serial_low(void) { |
| 37 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
| 38 | } | ||
| 33 | 39 | ||
| 34 | inline static void serial_output(void) { SERIAL_PIN_DDR |= SERIAL_PIN_MASK; } | 40 | inline static void serial_output(void) { |
| 41 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
| 42 | } | ||
| 35 | 43 | ||
| 36 | void enable_printing() { | 44 | void enable_printing() { |
| 37 | printing_enabled = true; | 45 | printing_enabled = true; |
| @@ -39,7 +47,9 @@ void enable_printing() { | |||
| 39 | serial_high(); | 47 | serial_high(); |
| 40 | } | 48 | } |
| 41 | 49 | ||
| 42 | void disable_printing() { printing_enabled = false; } | 50 | void disable_printing() { |
| 51 | printing_enabled = false; | ||
| 52 | } | ||
| 43 | 53 | ||
| 44 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | 54 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; |
| 45 | 55 | ||
| @@ -61,7 +71,8 @@ void print_char(char c) { | |||
| 61 | } | 71 | } |
| 62 | 72 | ||
| 63 | void print_string(char c[]) { | 73 | void print_string(char c[]) { |
| 64 | for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]); | 74 | for (uint8_t i = 0; i < strlen(c); i++) |
| 75 | print_char(c[i]); | ||
| 65 | } | 76 | } |
| 66 | 77 | ||
| 67 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | 78 | bool process_printer(uint16_t keycode, keyrecord_t *record) { |
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index 5d0bb313b4..12ee898212 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c | |||
| @@ -102,11 +102,17 @@ void steno_set_mode(steno_mode_t new_mode) { | |||
| 102 | /* override to intercept chords right before they get sent. | 102 | /* override to intercept chords right before they get sent. |
| 103 | * return zero to suppress normal sending behavior. | 103 | * return zero to suppress normal sending behavior. |
| 104 | */ | 104 | */ |
| 105 | __attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { return true; } | 105 | __attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { |
| 106 | return true; | ||
| 107 | } | ||
| 106 | 108 | ||
| 107 | __attribute__((weak)) bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed) { return true; } | 109 | __attribute__((weak)) bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed) { |
| 110 | return true; | ||
| 111 | } | ||
| 108 | 112 | ||
| 109 | __attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *record) { return true; } | 113 | __attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *record) { |
| 114 | return true; | ||
| 115 | } | ||
| 110 | 116 | ||
| 111 | static void send_steno_chord(void) { | 117 | static void send_steno_chord(void) { |
| 112 | if (send_steno_chord_user(mode, chord)) { | 118 | if (send_steno_chord_user(mode, chord)) { |
| @@ -114,11 +120,11 @@ static void send_steno_chord(void) { | |||
| 114 | case STENO_MODE_BOLT: | 120 | case STENO_MODE_BOLT: |
| 115 | send_steno_state(BOLT_STATE_SIZE, false); | 121 | send_steno_state(BOLT_STATE_SIZE, false); |
| 116 | #ifdef VIRTSER_ENABLE | 122 | #ifdef VIRTSER_ENABLE |
| 117 | virtser_send(0); // terminating byte | 123 | virtser_send(0); // terminating byte |
| 118 | #endif | 124 | #endif |
| 119 | break; | 125 | break; |
| 120 | case STENO_MODE_GEMINI: | 126 | case STENO_MODE_GEMINI: |
| 121 | chord[0] |= 0x80; // Indicate start of packet | 127 | chord[0] |= 0x80; // Indicate start of packet |
| 122 | send_steno_state(GEMINI_STATE_SIZE, true); | 128 | send_steno_state(GEMINI_STATE_SIZE, true); |
| 123 | break; | 129 | break; |
| 124 | } | 130 | } |
| @@ -126,9 +132,13 @@ static void send_steno_chord(void) { | |||
| 126 | steno_clear_state(); | 132 | steno_clear_state(); |
| 127 | } | 133 | } |
| 128 | 134 | ||
| 129 | uint8_t *steno_get_state(void) { return &state[0]; } | 135 | uint8_t *steno_get_state(void) { |
| 136 | return &state[0]; | ||
| 137 | } | ||
| 130 | 138 | ||
| 131 | uint8_t *steno_get_chord(void) { return &chord[0]; } | 139 | uint8_t *steno_get_chord(void) { |
| 140 | return &chord[0]; | ||
| 141 | } | ||
| 132 | 142 | ||
| 133 | static bool update_state_bolt(uint8_t key, bool press) { | 143 | static bool update_state_bolt(uint8_t key, bool press) { |
| 134 | uint8_t boltcode = pgm_read_byte(boltmap + key); | 144 | uint8_t boltcode = pgm_read_byte(boltmap + key); |
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 035c9c265d..e99119b2ae 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c | |||
| @@ -86,7 +86,9 @@ static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, voi | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) { _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap); } | 89 | static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) { |
| 90 | _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap); | ||
| 91 | } | ||
| 90 | 92 | ||
| 91 | static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) { | 93 | static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) { |
| 92 | if (action->state.finished) return; | 94 | if (action->state.finished) return; |
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c index a059f3a521..da1c4d506f 100644 --- a/quantum/process_keycode/process_terminal.c +++ b/quantum/process_keycode/process_terminal.c | |||
| @@ -27,12 +27,12 @@ | |||
| 27 | bool terminal_enabled = false; | 27 | bool terminal_enabled = false; |
| 28 | char buffer[80] = ""; | 28 | char buffer[80] = ""; |
| 29 | char cmd_buffer[CMD_BUFF_SIZE][80]; | 29 | char cmd_buffer[CMD_BUFF_SIZE][80]; |
| 30 | bool cmd_buffer_enabled = true; // replace with ifdef? | 30 | bool cmd_buffer_enabled = true; // replace with ifdef? |
| 31 | char newline[2] = "\n"; | 31 | char newline[2] = "\n"; |
| 32 | char arguments[6][20]; | 32 | char arguments[6][20]; |
| 33 | bool firstTime = true; | 33 | bool firstTime = true; |
| 34 | 34 | ||
| 35 | short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer | 35 | short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer |
| 36 | 36 | ||
| 37 | __attribute__((weak)) const char terminal_prompt[8] = "> "; | 37 | __attribute__((weak)) const char terminal_prompt[8] = "> "; |
| 38 | 38 | ||
| @@ -59,7 +59,8 @@ void enable_terminal(void) { | |||
| 59 | terminal_enabled = true; | 59 | terminal_enabled = true; |
| 60 | strcpy(buffer, ""); | 60 | strcpy(buffer, ""); |
| 61 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); | 61 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); |
| 62 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); | 62 | for (int i = 0; i < 6; i++) |
| 63 | strcpy(arguments[i], ""); | ||
| 63 | // select all text to start over | 64 | // select all text to start over |
| 64 | // SEND_STRING(SS_LCTL("a")); | 65 | // SEND_STRING(SS_LCTL("a")); |
| 65 | send_string(terminal_prompt); | 66 | send_string(terminal_prompt); |
| @@ -160,7 +161,7 @@ void print_cmd_buff(void) { | |||
| 160 | for (int i = 0; i < CMD_BUFF_SIZE; i++) { | 161 | for (int i = 0; i < CMD_BUFF_SIZE; i++) { |
| 161 | char tmpChar = ' '; | 162 | char tmpChar = ' '; |
| 162 | itoa(i, &tmpChar, 10); | 163 | itoa(i, &tmpChar, 10); |
| 163 | const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char * | 164 | const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char * |
| 164 | send_string(tmpCnstCharStr); | 165 | send_string(tmpCnstCharStr); |
| 165 | SEND_STRING(". "); | 166 | SEND_STRING(". "); |
| 166 | send_string(cmd_buffer[i]); | 167 | send_string(cmd_buffer[i]); |
| @@ -185,7 +186,7 @@ void terminal_help(void) { | |||
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | void command_not_found(void) { | 188 | void command_not_found(void) { |
| 188 | wait_ms(50); // sometimes buffer isnt grabbed quick enough | 189 | wait_ms(50); // sometimes buffer isnt grabbed quick enough |
| 189 | SEND_STRING("command \""); | 190 | SEND_STRING("command \""); |
| 190 | send_string(buffer); | 191 | send_string(buffer); |
| 191 | SEND_STRING("\" not found\n"); | 192 | SEND_STRING("\" not found\n"); |
| @@ -217,15 +218,16 @@ void process_terminal_command(void) { | |||
| 217 | 218 | ||
| 218 | if (terminal_enabled) { | 219 | if (terminal_enabled) { |
| 219 | strcpy(buffer, ""); | 220 | strcpy(buffer, ""); |
| 220 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); | 221 | for (int i = 0; i < 6; i++) |
| 222 | strcpy(arguments[i], ""); | ||
| 221 | SEND_STRING(SS_TAP(X_HOME)); | 223 | SEND_STRING(SS_TAP(X_HOME)); |
| 222 | send_string(terminal_prompt); | 224 | send_string(terminal_prompt); |
| 223 | } | 225 | } |
| 224 | } | 226 | } |
| 225 | void check_pos(void) { | 227 | void check_pos(void) { |
| 226 | if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down... | 228 | if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down... |
| 227 | current_cmd_buffer_pos = CMD_BUFF_SIZE - 1; | 229 | current_cmd_buffer_pos = CMD_BUFF_SIZE - 1; |
| 228 | } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up | 230 | } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up |
| 229 | current_cmd_buffer_pos = 0; | 231 | current_cmd_buffer_pos = 0; |
| 230 | } | 232 | } |
| 231 | } | 233 | } |
| @@ -278,33 +280,33 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 278 | case KC_RIGHT: | 280 | case KC_RIGHT: |
| 279 | return false; | 281 | return false; |
| 280 | break; | 282 | break; |
| 281 | case KC_UP: // 0 = recent | 283 | case KC_UP: // 0 = recent |
| 282 | check_pos(); // check our current buffer position is valid | 284 | check_pos(); // check our current buffer position is valid |
| 283 | if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything | 285 | if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything |
| 284 | str_len = strlen(buffer); | 286 | str_len = strlen(buffer); |
| 285 | for (int i = 0; i < str_len; ++i) { | 287 | for (int i = 0; i < str_len; ++i) { |
| 286 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already | 288 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
| 287 | // process_terminal(KC_BACKSPACE,record); | 289 | // process_terminal(KC_BACKSPACE,record); |
| 288 | } | 290 | } |
| 289 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); | 291 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); |
| 290 | 292 | ||
| 291 | send_string(buffer); | 293 | send_string(buffer); |
| 292 | ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again | 294 | ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again |
| 293 | } | 295 | } |
| 294 | return false; | 296 | return false; |
| 295 | break; | 297 | break; |
| 296 | case KC_DOWN: | 298 | case KC_DOWN: |
| 297 | check_pos(); | 299 | check_pos(); |
| 298 | if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything | 300 | if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything |
| 299 | str_len = strlen(buffer); | 301 | str_len = strlen(buffer); |
| 300 | for (int i = 0; i < str_len; ++i) { | 302 | for (int i = 0; i < str_len; ++i) { |
| 301 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already | 303 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
| 302 | // process_terminal(KC_BACKSPACE,record); | 304 | // process_terminal(KC_BACKSPACE,record); |
| 303 | } | 305 | } |
| 304 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); | 306 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); |
| 305 | 307 | ||
| 306 | send_string(buffer); | 308 | send_string(buffer); |
| 307 | --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again | 309 | --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again |
| 308 | } | 310 | } |
| 309 | return false; | 311 | return false; |
| 310 | break; | 312 | break; |
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index d084d2b66c..6a8d8f0ff6 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c | |||
| @@ -27,7 +27,7 @@ void qk_ucis_start(void) { | |||
| 27 | 27 | ||
| 28 | __attribute__((weak)) void qk_ucis_start_user(void) { | 28 | __attribute__((weak)) void qk_ucis_start_user(void) { |
| 29 | unicode_input_start(); | 29 | unicode_input_start(); |
| 30 | register_hex(0x2328); // ⌨ | 30 | register_hex(0x2328); // ⌨ |
| 31 | unicode_input_finish(); | 31 | unicode_input_finish(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 7685bb1c99..46b77e14ba 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -54,7 +54,9 @@ void unicode_input_mode_init(void) { | |||
| 54 | dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); | 54 | dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | uint8_t get_unicode_input_mode(void) { return unicode_config.input_mode; } | 57 | uint8_t get_unicode_input_mode(void) { |
| 58 | return unicode_config.input_mode; | ||
| 59 | } | ||
| 58 | 60 | ||
| 59 | void set_unicode_input_mode(uint8_t mode) { | 61 | void set_unicode_input_mode(uint8_t mode) { |
| 60 | unicode_config.input_mode = mode; | 62 | unicode_config.input_mode = mode; |
| @@ -76,7 +78,9 @@ void cycle_unicode_input_mode(int8_t offset) { | |||
| 76 | #endif | 78 | #endif |
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | void persist_unicode_input_mode(void) { eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); } | 81 | void persist_unicode_input_mode(void) { |
| 82 | eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); | ||
| 83 | } | ||
| 80 | 84 | ||
| 81 | __attribute__((weak)) void unicode_input_start(void) { | 85 | __attribute__((weak)) void unicode_input_start(void) { |
| 82 | unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; | 86 | unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; |
| @@ -90,8 +94,8 @@ __attribute__((weak)) void unicode_input_start(void) { | |||
| 90 | tap_code(KC_CAPS_LOCK); | 94 | tap_code(KC_CAPS_LOCK); |
| 91 | } | 95 | } |
| 92 | 96 | ||
| 93 | unicode_saved_mods = get_mods(); // Save current mods | 97 | unicode_saved_mods = get_mods(); // Save current mods |
| 94 | clear_mods(); // Unregister mods to start from a clean state | 98 | clear_mods(); // Unregister mods to start from a clean state |
| 95 | 99 | ||
| 96 | switch (unicode_config.input_mode) { | 100 | switch (unicode_config.input_mode) { |
| 97 | case UC_MAC: | 101 | case UC_MAC: |
| @@ -140,7 +144,7 @@ __attribute__((weak)) void unicode_input_finish(void) { | |||
| 140 | break; | 144 | break; |
| 141 | } | 145 | } |
| 142 | 146 | ||
| 143 | set_mods(unicode_saved_mods); // Reregister previously set mods | 147 | set_mods(unicode_saved_mods); // Reregister previously set mods |
| 144 | } | 148 | } |
| 145 | 149 | ||
| 146 | __attribute__((weak)) void unicode_input_cancel(void) { | 150 | __attribute__((weak)) void unicode_input_cancel(void) { |
| @@ -165,7 +169,7 @@ __attribute__((weak)) void unicode_input_cancel(void) { | |||
| 165 | break; | 169 | break; |
| 166 | } | 170 | } |
| 167 | 171 | ||
| 168 | set_mods(unicode_saved_mods); // Reregister previously set mods | 172 | set_mods(unicode_saved_mods); // Reregister previously set mods |
| 169 | } | 173 | } |
| 170 | 174 | ||
| 171 | // clang-format off | 175 | // clang-format off |
| @@ -262,16 +266,16 @@ void send_unicode_hex_string(const char *str) { | |||
| 262 | static const char *decode_utf8(const char *str, int32_t *code_point) { | 266 | static const char *decode_utf8(const char *str, int32_t *code_point) { |
| 263 | const char *next; | 267 | const char *next; |
| 264 | 268 | ||
| 265 | if (str[0] < 0x80) { // U+0000-007F | 269 | if (str[0] < 0x80) { // U+0000-007F |
| 266 | *code_point = str[0]; | 270 | *code_point = str[0]; |
| 267 | next = str + 1; | 271 | next = str + 1; |
| 268 | } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF | 272 | } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF |
| 269 | *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); | 273 | *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); |
| 270 | next = str + 2; | 274 | next = str + 2; |
| 271 | } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF | 275 | } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF |
| 272 | *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); | 276 | *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); |
| 273 | next = str + 3; | 277 | next = str + 3; |
| 274 | } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF | 278 | } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF |
| 275 | *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); | 279 | *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); |
| 276 | next = str + 4; | 280 | next = str + 4; |
| 277 | } else { | 281 | } else { |
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 72defb445e..1a6607c757 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h | |||
| @@ -59,12 +59,12 @@ | |||
| 59 | #define UC_OSX UC_MAC | 59 | #define UC_OSX UC_MAC |
| 60 | 60 | ||
| 61 | enum unicode_input_modes { | 61 | enum unicode_input_modes { |
| 62 | UC_MAC, // macOS using Unicode Hex Input | 62 | UC_MAC, // macOS using Unicode Hex Input |
| 63 | UC_LNX, // Linux using IBus | 63 | UC_LNX, // Linux using IBus |
| 64 | UC_WIN, // Windows using EnableHexNumpad | 64 | UC_WIN, // Windows using EnableHexNumpad |
| 65 | UC_BSD, // BSD (not implemented) | 65 | UC_BSD, // BSD (not implemented) |
| 66 | UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) | 66 | UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) |
| 67 | UC__COUNT // Number of available input modes (always leave at the end) | 67 | UC__COUNT // Number of available input modes (always leave at the end) |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | typedef union { | 70 | typedef union { |
diff --git a/quantum/programmable_button.c b/quantum/programmable_button.c index be828fd17c..a3ef42d82b 100644 --- a/quantum/programmable_button.c +++ b/quantum/programmable_button.c | |||
| @@ -22,16 +22,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | 22 | ||
| 23 | static uint32_t programmable_button_report = 0; | 23 | static uint32_t programmable_button_report = 0; |
| 24 | 24 | ||
| 25 | void programmable_button_clear(void) { programmable_button_report = 0; } | 25 | void programmable_button_clear(void) { |
| 26 | programmable_button_report = 0; | ||
| 27 | } | ||
| 26 | 28 | ||
| 27 | void programmable_button_send(void) { host_programmable_button_send(programmable_button_report); } | 29 | void programmable_button_send(void) { |
| 30 | host_programmable_button_send(programmable_button_report); | ||
| 31 | } | ||
| 28 | 32 | ||
| 29 | void programmable_button_on(uint8_t index) { programmable_button_report |= REPORT_BIT(index); } | 33 | void programmable_button_on(uint8_t index) { |
| 34 | programmable_button_report |= REPORT_BIT(index); | ||
| 35 | } | ||
| 30 | 36 | ||
| 31 | void programmable_button_off(uint8_t index) { programmable_button_report &= ~REPORT_BIT(index); } | 37 | void programmable_button_off(uint8_t index) { |
| 38 | programmable_button_report &= ~REPORT_BIT(index); | ||
| 39 | } | ||
| 32 | 40 | ||
| 33 | bool programmable_button_is_on(uint8_t index) { return !!(programmable_button_report & REPORT_BIT(index)); }; | 41 | bool programmable_button_is_on(uint8_t index) { |
| 42 | return !!(programmable_button_report & REPORT_BIT(index)); | ||
| 43 | }; | ||
| 34 | 44 | ||
| 35 | uint32_t programmable_button_get_report(void) { return programmable_button_report; }; | 45 | uint32_t programmable_button_get_report(void) { |
| 46 | return programmable_button_report; | ||
| 47 | }; | ||
| 36 | 48 | ||
| 37 | void programmable_button_set_report(uint32_t report) { programmable_button_report = report; } | 49 | void programmable_button_set_report(uint32_t report) { |
| 50 | programmable_button_report = report; | ||
| 51 | } | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index fb6220efa2..dce41c08ae 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -56,7 +56,7 @@ uint8_t extract_mod_bits(uint16_t code) { | |||
| 56 | 56 | ||
| 57 | uint8_t mods_to_send = 0; | 57 | uint8_t mods_to_send = 0; |
| 58 | 58 | ||
| 59 | if (code & QK_RMODS_MIN) { // Right mod flag is set | 59 | if (code & QK_RMODS_MIN) { // Right mod flag is set |
| 60 | if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL); | 60 | if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL); |
| 61 | if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT); | 61 | if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT); |
| 62 | if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT); | 62 | if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT); |
| @@ -71,7 +71,9 @@ uint8_t extract_mod_bits(uint16_t code) { | |||
| 71 | return mods_to_send; | 71 | return mods_to_send; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } | 74 | void do_code16(uint16_t code, void (*f)(uint8_t)) { |
| 75 | f(extract_mod_bits(code)); | ||
| 76 | } | ||
| 75 | 77 | ||
| 76 | __attribute__((weak)) void register_code16(uint16_t code) { | 78 | __attribute__((weak)) void register_code16(uint16_t code) { |
| 77 | if (IS_MOD(code) || code == KC_NO) { | 79 | if (IS_MOD(code) || code == KC_NO) { |
| @@ -101,13 +103,21 @@ __attribute__((weak)) void tap_code16(uint16_t code) { | |||
| 101 | unregister_code16(code); | 103 | unregister_code16(code); |
| 102 | } | 104 | } |
| 103 | 105 | ||
| 104 | __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; } | 106 | __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { |
| 107 | return true; | ||
| 108 | } | ||
| 105 | 109 | ||
| 106 | __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } | 110 | __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { |
| 111 | return process_record_user(keycode, record); | ||
| 112 | } | ||
| 107 | 113 | ||
| 108 | __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } | 114 | __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 115 | return true; | ||
| 116 | } | ||
| 109 | 117 | ||
| 110 | __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { post_process_record_user(keycode, record); } | 118 | __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { |
| 119 | post_process_record_user(keycode, record); | ||
| 120 | } | ||
| 111 | 121 | ||
| 112 | __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {} | 122 | __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {} |
| 113 | 123 | ||
| @@ -123,7 +133,8 @@ void reset_keyboard(void) { | |||
| 123 | uint16_t timer_start = timer_read(); | 133 | uint16_t timer_start = timer_read(); |
| 124 | PLAY_SONG(goodbye_song); | 134 | PLAY_SONG(goodbye_song); |
| 125 | shutdown_user(); | 135 | shutdown_user(); |
| 126 | while (timer_elapsed(timer_start) < 250) wait_ms(1); | 136 | while (timer_elapsed(timer_start) < 250) |
| 137 | wait_ms(1); | ||
| 127 | stop_all_notes(); | 138 | stop_all_notes(); |
| 128 | #else | 139 | #else |
| 129 | shutdown_user(); | 140 | shutdown_user(); |
| @@ -178,7 +189,7 @@ bool pre_process_record_quantum(keyrecord_t *record) { | |||
| 178 | true)) { | 189 | true)) { |
| 179 | return false; | 190 | return false; |
| 180 | } | 191 | } |
| 181 | return true; // continue processing | 192 | return true; // continue processing |
| 182 | } | 193 | } |
| 183 | 194 | ||
| 184 | /* Get keycode, and then call keyboard function */ | 195 | /* Get keycode, and then call keyboard function */ |
| @@ -367,11 +378,17 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ | |||
| 367 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); | 378 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); |
| 368 | } | 379 | } |
| 369 | 380 | ||
| 370 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } | 381 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { |
| 382 | layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); | ||
| 383 | } | ||
| 371 | 384 | ||
| 372 | // TODO: remove legacy api | 385 | // TODO: remove legacy api |
| 373 | void matrix_init_quantum() { matrix_init_kb(); } | 386 | void matrix_init_quantum() { |
| 374 | void matrix_scan_quantum() { matrix_scan_kb(); } | 387 | matrix_init_kb(); |
| 388 | } | ||
| 389 | void matrix_scan_quantum() { | ||
| 390 | matrix_scan_kb(); | ||
| 391 | } | ||
| 375 | 392 | ||
| 376 | //------------------------------------------------------------------------------ | 393 | //------------------------------------------------------------------------------ |
| 377 | // Override these functions in your keymap file to play different tunes on | 394 | // Override these functions in your keymap file to play different tunes on |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index b5b3566786..2552c48165 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -77,421 +77,421 @@ enum quantum_keycodes { | |||
| 77 | 77 | ||
| 78 | // Loose keycodes - to be used directly | 78 | // Loose keycodes - to be used directly |
| 79 | QK_BOOTLOADER = 0x5C00, | 79 | QK_BOOTLOADER = 0x5C00, |
| 80 | QK_DEBUG_TOGGLE, // 5C01 | 80 | QK_DEBUG_TOGGLE, // 5C01 |
| 81 | 81 | ||
| 82 | // Magic | 82 | // Magic |
| 83 | MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02 | 83 | MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02 |
| 84 | MAGIC_CAPSLOCK_TO_CONTROL, // 5C03 | 84 | MAGIC_CAPSLOCK_TO_CONTROL, // 5C03 |
| 85 | MAGIC_SWAP_LALT_LGUI, // 5C04 | 85 | MAGIC_SWAP_LALT_LGUI, // 5C04 |
| 86 | MAGIC_SWAP_RALT_RGUI, // 5C05 | 86 | MAGIC_SWAP_RALT_RGUI, // 5C05 |
| 87 | MAGIC_NO_GUI, // 5C06 | 87 | MAGIC_NO_GUI, // 5C06 |
| 88 | MAGIC_SWAP_GRAVE_ESC, // 5C07 | 88 | MAGIC_SWAP_GRAVE_ESC, // 5C07 |
| 89 | MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08 | 89 | MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08 |
| 90 | MAGIC_HOST_NKRO, // 5C09 | 90 | MAGIC_HOST_NKRO, // 5C09 |
| 91 | MAGIC_SWAP_ALT_GUI, // 5C0A | 91 | MAGIC_SWAP_ALT_GUI, // 5C0A |
| 92 | MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B | 92 | MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B |
| 93 | MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C | 93 | MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C |
| 94 | MAGIC_UNSWAP_LALT_LGUI, // 5C0D | 94 | MAGIC_UNSWAP_LALT_LGUI, // 5C0D |
| 95 | MAGIC_UNSWAP_RALT_RGUI, // 5C0E | 95 | MAGIC_UNSWAP_RALT_RGUI, // 5C0E |
| 96 | MAGIC_UNNO_GUI, // 5C0F | 96 | MAGIC_UNNO_GUI, // 5C0F |
| 97 | MAGIC_UNSWAP_GRAVE_ESC, // 5C10 | 97 | MAGIC_UNSWAP_GRAVE_ESC, // 5C10 |
| 98 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11 | 98 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11 |
| 99 | MAGIC_UNHOST_NKRO, // 5C12 | 99 | MAGIC_UNHOST_NKRO, // 5C12 |
| 100 | MAGIC_UNSWAP_ALT_GUI, // 5C13 | 100 | MAGIC_UNSWAP_ALT_GUI, // 5C13 |
| 101 | MAGIC_TOGGLE_NKRO, // 5C14 | 101 | MAGIC_TOGGLE_NKRO, // 5C14 |
| 102 | MAGIC_TOGGLE_ALT_GUI, // 5C15 | 102 | MAGIC_TOGGLE_ALT_GUI, // 5C15 |
| 103 | 103 | ||
| 104 | // Grave Escape | 104 | // Grave Escape |
| 105 | QK_GRAVE_ESCAPE, // 5C16 | 105 | QK_GRAVE_ESCAPE, // 5C16 |
| 106 | 106 | ||
| 107 | // Auto Shift | 107 | // Auto Shift |
| 108 | KC_ASUP, // 5C17 | 108 | KC_ASUP, // 5C17 |
| 109 | KC_ASDN, // 5C18 | 109 | KC_ASDN, // 5C18 |
| 110 | KC_ASRP, // 5C19 | 110 | KC_ASRP, // 5C19 |
| 111 | KC_ASTG, // 5C1A | 111 | KC_ASTG, // 5C1A |
| 112 | KC_ASON, // 5C1B | 112 | KC_ASON, // 5C1B |
| 113 | KC_ASOFF, // 5C1C | 113 | KC_ASOFF, // 5C1C |
| 114 | 114 | ||
| 115 | // Audio | 115 | // Audio |
| 116 | AU_ON, // 5C1D | 116 | AU_ON, // 5C1D |
| 117 | AU_OFF, // 5C1E | 117 | AU_OFF, // 5C1E |
| 118 | AU_TOG, // 5C1F | 118 | AU_TOG, // 5C1F |
| 119 | 119 | ||
| 120 | // Audio Clicky | 120 | // Audio Clicky |
| 121 | CLICKY_TOGGLE, // 5C20 | 121 | CLICKY_TOGGLE, // 5C20 |
| 122 | CLICKY_ENABLE, // 5C21 | 122 | CLICKY_ENABLE, // 5C21 |
| 123 | CLICKY_DISABLE, // 5C22 | 123 | CLICKY_DISABLE, // 5C22 |
| 124 | CLICKY_UP, // 5C23 | 124 | CLICKY_UP, // 5C23 |
| 125 | CLICKY_DOWN, // 5C24 | 125 | CLICKY_DOWN, // 5C24 |
| 126 | CLICKY_RESET, // 5C25 | 126 | CLICKY_RESET, // 5C25 |
| 127 | 127 | ||
| 128 | // Music mode | 128 | // Music mode |
| 129 | MU_ON, // 5C26 | 129 | MU_ON, // 5C26 |
| 130 | MU_OFF, // 5C27 | 130 | MU_OFF, // 5C27 |
| 131 | MU_TOG, // 5C28 | 131 | MU_TOG, // 5C28 |
| 132 | MU_MOD, // 5C29 | 132 | MU_MOD, // 5C29 |
| 133 | MUV_IN, // 5C2A | 133 | MUV_IN, // 5C2A |
| 134 | MUV_DE, // 5C2B | 134 | MUV_DE, // 5C2B |
| 135 | 135 | ||
| 136 | // MIDI | 136 | // MIDI |
| 137 | MI_ON, // 5C2C | 137 | MI_ON, // 5C2C |
| 138 | MI_OFF, // 5C2D | 138 | MI_OFF, // 5C2D |
| 139 | MI_TOG, // 5C2E | 139 | MI_TOG, // 5C2E |
| 140 | 140 | ||
| 141 | MI_C, // 5C2F | 141 | MI_C, // 5C2F |
| 142 | MI_Cs, // 5C30 | 142 | MI_Cs, // 5C30 |
| 143 | MI_Db = MI_Cs, | 143 | MI_Db = MI_Cs, |
| 144 | MI_D, // 5C31 | 144 | MI_D, // 5C31 |
| 145 | MI_Ds, // 5C32 | 145 | MI_Ds, // 5C32 |
| 146 | MI_Eb = MI_Ds, | 146 | MI_Eb = MI_Ds, |
| 147 | MI_E, // 5C33 | 147 | MI_E, // 5C33 |
| 148 | MI_F, // 5C34 | 148 | MI_F, // 5C34 |
| 149 | MI_Fs, // 5C35 | 149 | MI_Fs, // 5C35 |
| 150 | MI_Gb = MI_Fs, | 150 | MI_Gb = MI_Fs, |
| 151 | MI_G, // 5C36 | 151 | MI_G, // 5C36 |
| 152 | MI_Gs, // 5C37 | 152 | MI_Gs, // 5C37 |
| 153 | MI_Ab = MI_Gs, | 153 | MI_Ab = MI_Gs, |
| 154 | MI_A, // 5C38 | 154 | MI_A, // 5C38 |
| 155 | MI_As, // 5C39 | 155 | MI_As, // 5C39 |
| 156 | MI_Bb = MI_As, | 156 | MI_Bb = MI_As, |
| 157 | MI_B, // 5C3A | 157 | MI_B, // 5C3A |
| 158 | 158 | ||
| 159 | MI_C_1, // 5C3B | 159 | MI_C_1, // 5C3B |
| 160 | MI_Cs_1, // 5C3C | 160 | MI_Cs_1, // 5C3C |
| 161 | MI_Db_1 = MI_Cs_1, | 161 | MI_Db_1 = MI_Cs_1, |
| 162 | MI_D_1, // 5C3D | 162 | MI_D_1, // 5C3D |
| 163 | MI_Ds_1, // 5C3E | 163 | MI_Ds_1, // 5C3E |
| 164 | MI_Eb_1 = MI_Ds_1, | 164 | MI_Eb_1 = MI_Ds_1, |
| 165 | MI_E_1, // 5C3F | 165 | MI_E_1, // 5C3F |
| 166 | MI_F_1, // 5C40 | 166 | MI_F_1, // 5C40 |
| 167 | MI_Fs_1, // 5C41 | 167 | MI_Fs_1, // 5C41 |
| 168 | MI_Gb_1 = MI_Fs_1, | 168 | MI_Gb_1 = MI_Fs_1, |
| 169 | MI_G_1, // 5C42 | 169 | MI_G_1, // 5C42 |
| 170 | MI_Gs_1, // 5C43 | 170 | MI_Gs_1, // 5C43 |
| 171 | MI_Ab_1 = MI_Gs_1, | 171 | MI_Ab_1 = MI_Gs_1, |
| 172 | MI_A_1, // 5C44 | 172 | MI_A_1, // 5C44 |
| 173 | MI_As_1, // 5C45 | 173 | MI_As_1, // 5C45 |
| 174 | MI_Bb_1 = MI_As_1, | 174 | MI_Bb_1 = MI_As_1, |
| 175 | MI_B_1, // 5C46 | 175 | MI_B_1, // 5C46 |
| 176 | 176 | ||
| 177 | MI_C_2, // 5C47 | 177 | MI_C_2, // 5C47 |
| 178 | MI_Cs_2, // 5C48 | 178 | MI_Cs_2, // 5C48 |
| 179 | MI_Db_2 = MI_Cs_2, | 179 | MI_Db_2 = MI_Cs_2, |
| 180 | MI_D_2, // 5C49 | 180 | MI_D_2, // 5C49 |
| 181 | MI_Ds_2, // 5C4A | 181 | MI_Ds_2, // 5C4A |
| 182 | MI_Eb_2 = MI_Ds_2, | 182 | MI_Eb_2 = MI_Ds_2, |
| 183 | MI_E_2, // 5C4B | 183 | MI_E_2, // 5C4B |
| 184 | MI_F_2, // 5C4C | 184 | MI_F_2, // 5C4C |
| 185 | MI_Fs_2, // 5C4D | 185 | MI_Fs_2, // 5C4D |
| 186 | MI_Gb_2 = MI_Fs_2, | 186 | MI_Gb_2 = MI_Fs_2, |
| 187 | MI_G_2, // 5C4E | 187 | MI_G_2, // 5C4E |
| 188 | MI_Gs_2, // 5C4F | 188 | MI_Gs_2, // 5C4F |
| 189 | MI_Ab_2 = MI_Gs_2, | 189 | MI_Ab_2 = MI_Gs_2, |
| 190 | MI_A_2, // 5C50 | 190 | MI_A_2, // 5C50 |
| 191 | MI_As_2, // 5C51 | 191 | MI_As_2, // 5C51 |
| 192 | MI_Bb_2 = MI_As_2, | 192 | MI_Bb_2 = MI_As_2, |
| 193 | MI_B_2, // 5C52 | 193 | MI_B_2, // 5C52 |
| 194 | 194 | ||
| 195 | MI_C_3, // 5C53 | 195 | MI_C_3, // 5C53 |
| 196 | MI_Cs_3, // 5C54 | 196 | MI_Cs_3, // 5C54 |
| 197 | MI_Db_3 = MI_Cs_3, | 197 | MI_Db_3 = MI_Cs_3, |
| 198 | MI_D_3, // 5C55 | 198 | MI_D_3, // 5C55 |
| 199 | MI_Ds_3, // 5C56 | 199 | MI_Ds_3, // 5C56 |
| 200 | MI_Eb_3 = MI_Ds_3, | 200 | MI_Eb_3 = MI_Ds_3, |
| 201 | MI_E_3, // 5C57 | 201 | MI_E_3, // 5C57 |
| 202 | MI_F_3, // 5C58 | 202 | MI_F_3, // 5C58 |
| 203 | MI_Fs_3, // 5C59 | 203 | MI_Fs_3, // 5C59 |
| 204 | MI_Gb_3 = MI_Fs_3, | 204 | MI_Gb_3 = MI_Fs_3, |
| 205 | MI_G_3, // 5C5A | 205 | MI_G_3, // 5C5A |
| 206 | MI_Gs_3, // 5C5B | 206 | MI_Gs_3, // 5C5B |
| 207 | MI_Ab_3 = MI_Gs_3, | 207 | MI_Ab_3 = MI_Gs_3, |
| 208 | MI_A_3, // 5C5C | 208 | MI_A_3, // 5C5C |
| 209 | MI_As_3, // 5C5D | 209 | MI_As_3, // 5C5D |
| 210 | MI_Bb_3 = MI_As_3, | 210 | MI_Bb_3 = MI_As_3, |
| 211 | MI_B_3, // 5C5E | 211 | MI_B_3, // 5C5E |
| 212 | 212 | ||
| 213 | MI_C_4, // 5C5F | 213 | MI_C_4, // 5C5F |
| 214 | MI_Cs_4, // 5C60 | 214 | MI_Cs_4, // 5C60 |
| 215 | MI_Db_4 = MI_Cs_4, | 215 | MI_Db_4 = MI_Cs_4, |
| 216 | MI_D_4, // 5C61 | 216 | MI_D_4, // 5C61 |
| 217 | MI_Ds_4, // 5C62 | 217 | MI_Ds_4, // 5C62 |
| 218 | MI_Eb_4 = MI_Ds_4, | 218 | MI_Eb_4 = MI_Ds_4, |
| 219 | MI_E_4, // 5C63 | 219 | MI_E_4, // 5C63 |
| 220 | MI_F_4, // 5C64 | 220 | MI_F_4, // 5C64 |
| 221 | MI_Fs_4, // 5C65 | 221 | MI_Fs_4, // 5C65 |
| 222 | MI_Gb_4 = MI_Fs_4, | 222 | MI_Gb_4 = MI_Fs_4, |
| 223 | MI_G_4, // 5C66 | 223 | MI_G_4, // 5C66 |
| 224 | MI_Gs_4, // 5C67 | 224 | MI_Gs_4, // 5C67 |
| 225 | MI_Ab_4 = MI_Gs_4, | 225 | MI_Ab_4 = MI_Gs_4, |
| 226 | MI_A_4, // 5C68 | 226 | MI_A_4, // 5C68 |
| 227 | MI_As_4, // 5C69 | 227 | MI_As_4, // 5C69 |
| 228 | MI_Bb_4 = MI_As_4, | 228 | MI_Bb_4 = MI_As_4, |
| 229 | MI_B_4, // 5C6A | 229 | MI_B_4, // 5C6A |
| 230 | 230 | ||
| 231 | MI_C_5, // 5C6B | 231 | MI_C_5, // 5C6B |
| 232 | MI_Cs_5, // 5C6C | 232 | MI_Cs_5, // 5C6C |
| 233 | MI_Db_5 = MI_Cs_5, | 233 | MI_Db_5 = MI_Cs_5, |
| 234 | MI_D_5, // 5C6D | 234 | MI_D_5, // 5C6D |
| 235 | MI_Ds_5, // 5C6E | 235 | MI_Ds_5, // 5C6E |
| 236 | MI_Eb_5 = MI_Ds_5, | 236 | MI_Eb_5 = MI_Ds_5, |
| 237 | MI_E_5, // 5C6F | 237 | MI_E_5, // 5C6F |
| 238 | MI_F_5, // 5C70 | 238 | MI_F_5, // 5C70 |
| 239 | MI_Fs_5, // 5C71 | 239 | MI_Fs_5, // 5C71 |
| 240 | MI_Gb_5 = MI_Fs_5, | 240 | MI_Gb_5 = MI_Fs_5, |
| 241 | MI_G_5, // 5C72 | 241 | MI_G_5, // 5C72 |
| 242 | MI_Gs_5, // 5C73 | 242 | MI_Gs_5, // 5C73 |
| 243 | MI_Ab_5 = MI_Gs_5, | 243 | MI_Ab_5 = MI_Gs_5, |
| 244 | MI_A_5, // 5C74 | 244 | MI_A_5, // 5C74 |
| 245 | MI_As_5, // 5C75 | 245 | MI_As_5, // 5C75 |
| 246 | MI_Bb_5 = MI_As_5, | 246 | MI_Bb_5 = MI_As_5, |
| 247 | MI_B_5, // 5C76 | 247 | MI_B_5, // 5C76 |
| 248 | 248 | ||
| 249 | MI_OCT_N2, // 5C77 | 249 | MI_OCT_N2, // 5C77 |
| 250 | MI_OCT_N1, // 5C78 | 250 | MI_OCT_N1, // 5C78 |
| 251 | MI_OCT_0, // 5C79 | 251 | MI_OCT_0, // 5C79 |
| 252 | MI_OCT_1, // 5C7A | 252 | MI_OCT_1, // 5C7A |
| 253 | MI_OCT_2, // 5C7B | 253 | MI_OCT_2, // 5C7B |
| 254 | MI_OCT_3, // 5C7C | 254 | MI_OCT_3, // 5C7C |
| 255 | MI_OCT_4, // 5C7D | 255 | MI_OCT_4, // 5C7D |
| 256 | MI_OCT_5, // 5C7E | 256 | MI_OCT_5, // 5C7E |
| 257 | MI_OCT_6, // 5C7F | 257 | MI_OCT_6, // 5C7F |
| 258 | MI_OCT_7, // 5C80 | 258 | MI_OCT_7, // 5C80 |
| 259 | MI_OCTD, // 5C81 | 259 | MI_OCTD, // 5C81 |
| 260 | MI_OCTU, // 5C82 | 260 | MI_OCTU, // 5C82 |
| 261 | 261 | ||
| 262 | MI_TRNS_N6, // 5C83 | 262 | MI_TRNS_N6, // 5C83 |
| 263 | MI_TRNS_N5, // 5C84 | 263 | MI_TRNS_N5, // 5C84 |
| 264 | MI_TRNS_N4, // 5C85 | 264 | MI_TRNS_N4, // 5C85 |
| 265 | MI_TRNS_N3, // 5C86 | 265 | MI_TRNS_N3, // 5C86 |
| 266 | MI_TRNS_N2, // 5C87 | 266 | MI_TRNS_N2, // 5C87 |
| 267 | MI_TRNS_N1, // 5C88 | 267 | MI_TRNS_N1, // 5C88 |
| 268 | MI_TRNS_0, // 5C89 | 268 | MI_TRNS_0, // 5C89 |
| 269 | MI_TRNS_1, // 5C8A | 269 | MI_TRNS_1, // 5C8A |
| 270 | MI_TRNS_2, // 5C8B | 270 | MI_TRNS_2, // 5C8B |
| 271 | MI_TRNS_3, // 5C8C | 271 | MI_TRNS_3, // 5C8C |
| 272 | MI_TRNS_4, // 5C8D | 272 | MI_TRNS_4, // 5C8D |
| 273 | MI_TRNS_5, // 5C8E | 273 | MI_TRNS_5, // 5C8E |
| 274 | MI_TRNS_6, // 5C8F | 274 | MI_TRNS_6, // 5C8F |
| 275 | MI_TRNSD, // 5C90 | 275 | MI_TRNSD, // 5C90 |
| 276 | MI_TRNSU, // 5C91 | 276 | MI_TRNSU, // 5C91 |
| 277 | 277 | ||
| 278 | MI_VEL_0, // 5C92 | 278 | MI_VEL_0, // 5C92 |
| 279 | #ifdef VIA_ENABLE | 279 | #ifdef VIA_ENABLE |
| 280 | MI_VEL_1 = MI_VEL_0, | 280 | MI_VEL_1 = MI_VEL_0, |
| 281 | #else | 281 | #else |
| 282 | MI_VEL_1, // 5C93 | 282 | MI_VEL_1, // 5C93 |
| 283 | #endif | 283 | #endif |
| 284 | MI_VEL_2, // 5C94 | 284 | MI_VEL_2, // 5C94 |
| 285 | MI_VEL_3, // 5C95 | 285 | MI_VEL_3, // 5C95 |
| 286 | MI_VEL_4, // 5C96 | 286 | MI_VEL_4, // 5C96 |
| 287 | MI_VEL_5, // 5C97 | 287 | MI_VEL_5, // 5C97 |
| 288 | MI_VEL_6, // 5C98 | 288 | MI_VEL_6, // 5C98 |
| 289 | MI_VEL_7, // 5C99 | 289 | MI_VEL_7, // 5C99 |
| 290 | MI_VEL_8, // 5C9A | 290 | MI_VEL_8, // 5C9A |
| 291 | MI_VEL_9, // 5C9B | 291 | MI_VEL_9, // 5C9B |
| 292 | MI_VEL_10, // 5C9C | 292 | MI_VEL_10, // 5C9C |
| 293 | MI_VELD, // 5C9D | 293 | MI_VELD, // 5C9D |
| 294 | MI_VELU, // 5C9E | 294 | MI_VELU, // 5C9E |
| 295 | 295 | ||
| 296 | MI_CH1, // 5C9F | 296 | MI_CH1, // 5C9F |
| 297 | MI_CH2, // 5CA0 | 297 | MI_CH2, // 5CA0 |
| 298 | MI_CH3, // 5CA1 | 298 | MI_CH3, // 5CA1 |
| 299 | MI_CH4, // 5CA2 | 299 | MI_CH4, // 5CA2 |
| 300 | MI_CH5, // 5CA3 | 300 | MI_CH5, // 5CA3 |
| 301 | MI_CH6, // 5CA4 | 301 | MI_CH6, // 5CA4 |
| 302 | MI_CH7, // 5CA5 | 302 | MI_CH7, // 5CA5 |
| 303 | MI_CH8, // 5CA6 | 303 | MI_CH8, // 5CA6 |
| 304 | MI_CH9, // 5CA7 | 304 | MI_CH9, // 5CA7 |
| 305 | MI_CH10, // 5CA8 | 305 | MI_CH10, // 5CA8 |
| 306 | MI_CH11, // 5CA9 | 306 | MI_CH11, // 5CA9 |
| 307 | MI_CH12, // 5CAA | 307 | MI_CH12, // 5CAA |
| 308 | MI_CH13, // 5CAB | 308 | MI_CH13, // 5CAB |
| 309 | MI_CH14, // 5CAC | 309 | MI_CH14, // 5CAC |
| 310 | MI_CH15, // 5CAD | 310 | MI_CH15, // 5CAD |
| 311 | MI_CH16, // 5CAE | 311 | MI_CH16, // 5CAE |
| 312 | MI_CHD, // 5CAF | 312 | MI_CHD, // 5CAF |
| 313 | MI_CHU, // 5CB0 | 313 | MI_CHU, // 5CB0 |
| 314 | 314 | ||
| 315 | MI_ALLOFF, // 5CB1 | 315 | MI_ALLOFF, // 5CB1 |
| 316 | 316 | ||
| 317 | MI_SUS, // 5CB2 | 317 | MI_SUS, // 5CB2 |
| 318 | MI_PORT, // 5CB3 | 318 | MI_PORT, // 5CB3 |
| 319 | MI_SOST, // 5CB4 | 319 | MI_SOST, // 5CB4 |
| 320 | MI_SOFT, // 5CB5 | 320 | MI_SOFT, // 5CB5 |
| 321 | MI_LEG, // 5CB6 | 321 | MI_LEG, // 5CB6 |
| 322 | 322 | ||
| 323 | MI_MOD, // 5CB7 | 323 | MI_MOD, // 5CB7 |
| 324 | MI_MODSD, // 5CB8 | 324 | MI_MODSD, // 5CB8 |
| 325 | MI_MODSU, // 5CB9 | 325 | MI_MODSU, // 5CB9 |
| 326 | 326 | ||
| 327 | MI_BENDD, // 5CBA | 327 | MI_BENDD, // 5CBA |
| 328 | MI_BENDU, // 5CBB | 328 | MI_BENDU, // 5CBB |
| 329 | 329 | ||
| 330 | // Backlight | 330 | // Backlight |
| 331 | BL_ON, // 5CBC | 331 | BL_ON, // 5CBC |
| 332 | BL_OFF, // 5CBD | 332 | BL_OFF, // 5CBD |
| 333 | BL_DEC, // 5CBE | 333 | BL_DEC, // 5CBE |
| 334 | BL_INC, // 5CBF | 334 | BL_INC, // 5CBF |
| 335 | BL_TOGG, // 5CC0 | 335 | BL_TOGG, // 5CC0 |
| 336 | BL_STEP, // 5CC1 | 336 | BL_STEP, // 5CC1 |
| 337 | BL_BRTG, // 5CC2 | 337 | BL_BRTG, // 5CC2 |
| 338 | 338 | ||
| 339 | // RGB underglow/matrix | 339 | // RGB underglow/matrix |
| 340 | RGB_TOG, // 5CC3 | 340 | RGB_TOG, // 5CC3 |
| 341 | RGB_MODE_FORWARD, // 5CC4 | 341 | RGB_MODE_FORWARD, // 5CC4 |
| 342 | RGB_MODE_REVERSE, // 5CC5 | 342 | RGB_MODE_REVERSE, // 5CC5 |
| 343 | RGB_HUI, // 5CC6 | 343 | RGB_HUI, // 5CC6 |
| 344 | RGB_HUD, // 5CC7 | 344 | RGB_HUD, // 5CC7 |
| 345 | RGB_SAI, // 5CC8 | 345 | RGB_SAI, // 5CC8 |
| 346 | RGB_SAD, // 5CC9 | 346 | RGB_SAD, // 5CC9 |
| 347 | RGB_VAI, // 5CCA | 347 | RGB_VAI, // 5CCA |
| 348 | RGB_VAD, // 5CCB | 348 | RGB_VAD, // 5CCB |
| 349 | RGB_SPI, // 5CCC | 349 | RGB_SPI, // 5CCC |
| 350 | RGB_SPD, // 5CCD | 350 | RGB_SPD, // 5CCD |
| 351 | RGB_MODE_PLAIN, // 5CCE | 351 | RGB_MODE_PLAIN, // 5CCE |
| 352 | RGB_MODE_BREATHE, // 5CCF | 352 | RGB_MODE_BREATHE, // 5CCF |
| 353 | RGB_MODE_RAINBOW, // 5CD0 | 353 | RGB_MODE_RAINBOW, // 5CD0 |
| 354 | RGB_MODE_SWIRL, // 5CD1 | 354 | RGB_MODE_SWIRL, // 5CD1 |
| 355 | RGB_MODE_SNAKE, // 5CD2 | 355 | RGB_MODE_SNAKE, // 5CD2 |
| 356 | RGB_MODE_KNIGHT, // 5CD3 | 356 | RGB_MODE_KNIGHT, // 5CD3 |
| 357 | RGB_MODE_XMAS, // 5CD4 | 357 | RGB_MODE_XMAS, // 5CD4 |
| 358 | RGB_MODE_GRADIENT, // 5CD5 | 358 | RGB_MODE_GRADIENT, // 5CD5 |
| 359 | RGB_MODE_RGBTEST, // 5CD6 | 359 | RGB_MODE_RGBTEST, // 5CD6 |
| 360 | 360 | ||
| 361 | // Velocikey | 361 | // Velocikey |
| 362 | VLK_TOG, // 5CD7 | 362 | VLK_TOG, // 5CD7 |
| 363 | 363 | ||
| 364 | // Space Cadet | 364 | // Space Cadet |
| 365 | KC_LSPO, // 5CD8 | 365 | KC_LSPO, // 5CD8 |
| 366 | KC_RSPC, // 5CD9 | 366 | KC_RSPC, // 5CD9 |
| 367 | KC_SFTENT, // 5CDA | 367 | KC_SFTENT, // 5CDA |
| 368 | 368 | ||
| 369 | // Thermal Printer | 369 | // Thermal Printer |
| 370 | PRINT_ON, // 5CDB | 370 | PRINT_ON, // 5CDB |
| 371 | PRINT_OFF, // 5CDC | 371 | PRINT_OFF, // 5CDC |
| 372 | 372 | ||
| 373 | // Bluetooth: output selection | 373 | // Bluetooth: output selection |
| 374 | OUT_AUTO, // 5CDD | 374 | OUT_AUTO, // 5CDD |
| 375 | OUT_USB, // 5CDE | 375 | OUT_USB, // 5CDE |
| 376 | 376 | ||
| 377 | // Clear EEPROM | 377 | // Clear EEPROM |
| 378 | QK_CLEAR_EEPROM, // 5CDF | 378 | QK_CLEAR_EEPROM, // 5CDF |
| 379 | 379 | ||
| 380 | // Unicode | 380 | // Unicode |
| 381 | UNICODE_MODE_FORWARD, // 5CE0 | 381 | UNICODE_MODE_FORWARD, // 5CE0 |
| 382 | UNICODE_MODE_REVERSE, // 5CE1 | 382 | UNICODE_MODE_REVERSE, // 5CE1 |
| 383 | UNICODE_MODE_MAC, // 5CE2 | 383 | UNICODE_MODE_MAC, // 5CE2 |
| 384 | UNICODE_MODE_LNX, // 5CE3 | 384 | UNICODE_MODE_LNX, // 5CE3 |
| 385 | UNICODE_MODE_WIN, // 5CE4 | 385 | UNICODE_MODE_WIN, // 5CE4 |
| 386 | UNICODE_MODE_BSD, // 5CE5 | 386 | UNICODE_MODE_BSD, // 5CE5 |
| 387 | UNICODE_MODE_WINC, // 5CE6 | 387 | UNICODE_MODE_WINC, // 5CE6 |
| 388 | 388 | ||
| 389 | // Haptic | 389 | // Haptic |
| 390 | HPT_ON, // 5CE7 | 390 | HPT_ON, // 5CE7 |
| 391 | HPT_OFF, // 5CE8 | 391 | HPT_OFF, // 5CE8 |
| 392 | HPT_TOG, // 5CE9 | 392 | HPT_TOG, // 5CE9 |
| 393 | HPT_RST, // 5CEA | 393 | HPT_RST, // 5CEA |
| 394 | HPT_FBK, // 5CEB | 394 | HPT_FBK, // 5CEB |
| 395 | HPT_BUZ, // 5CEC | 395 | HPT_BUZ, // 5CEC |
| 396 | HPT_MODI, // 5CED | 396 | HPT_MODI, // 5CED |
| 397 | HPT_MODD, // 5CEE | 397 | HPT_MODD, // 5CEE |
| 398 | HPT_CONT, // 5CEF | 398 | HPT_CONT, // 5CEF |
| 399 | HPT_CONI, // 5CF0 | 399 | HPT_CONI, // 5CF0 |
| 400 | HPT_COND, // 5CF1 | 400 | HPT_COND, // 5CF1 |
| 401 | HPT_DWLI, // 5CF2 | 401 | HPT_DWLI, // 5CF2 |
| 402 | HPT_DWLD, // 5CF3 | 402 | HPT_DWLD, // 5CF3 |
| 403 | 403 | ||
| 404 | // Space Cadet (continued) | 404 | // Space Cadet (continued) |
| 405 | KC_LCPO, // 5CF4 | 405 | KC_LCPO, // 5CF4 |
| 406 | KC_RCPC, // 5CF5 | 406 | KC_RCPC, // 5CF5 |
| 407 | KC_LAPO, // 5CF6 | 407 | KC_LAPO, // 5CF6 |
| 408 | KC_RAPC, // 5CF7 | 408 | KC_RAPC, // 5CF7 |
| 409 | 409 | ||
| 410 | // Combos | 410 | // Combos |
| 411 | CMB_ON, // 5CF8 | 411 | CMB_ON, // 5CF8 |
| 412 | CMB_OFF, // 5CF9 | 412 | CMB_OFF, // 5CF9 |
| 413 | CMB_TOG, // 5CFA | 413 | CMB_TOG, // 5CFA |
| 414 | 414 | ||
| 415 | // Magic (continued) | 415 | // Magic (continued) |
| 416 | MAGIC_SWAP_LCTL_LGUI, // 5CFB | 416 | MAGIC_SWAP_LCTL_LGUI, // 5CFB |
| 417 | MAGIC_SWAP_RCTL_RGUI, // 5CFC | 417 | MAGIC_SWAP_RCTL_RGUI, // 5CFC |
| 418 | MAGIC_UNSWAP_LCTL_LGUI, // 5CFD | 418 | MAGIC_UNSWAP_LCTL_LGUI, // 5CFD |
| 419 | MAGIC_UNSWAP_RCTL_RGUI, // 5CFE | 419 | MAGIC_UNSWAP_RCTL_RGUI, // 5CFE |
| 420 | MAGIC_SWAP_CTL_GUI, // 5CFF | 420 | MAGIC_SWAP_CTL_GUI, // 5CFF |
| 421 | MAGIC_UNSWAP_CTL_GUI, // 5D00 | 421 | MAGIC_UNSWAP_CTL_GUI, // 5D00 |
| 422 | MAGIC_TOGGLE_CTL_GUI, // 5D01 | 422 | MAGIC_TOGGLE_CTL_GUI, // 5D01 |
| 423 | MAGIC_EE_HANDS_LEFT, // 5D02 | 423 | MAGIC_EE_HANDS_LEFT, // 5D02 |
| 424 | MAGIC_EE_HANDS_RIGHT, // 5D03 | 424 | MAGIC_EE_HANDS_RIGHT, // 5D03 |
| 425 | 425 | ||
| 426 | // Dynamic Macros | 426 | // Dynamic Macros |
| 427 | DYN_REC_START1, // 5D04 | 427 | DYN_REC_START1, // 5D04 |
| 428 | DYN_REC_START2, // 5D05 | 428 | DYN_REC_START2, // 5D05 |
| 429 | DYN_REC_STOP, // 5D06 | 429 | DYN_REC_STOP, // 5D06 |
| 430 | DYN_MACRO_PLAY1, // 5D07 | 430 | DYN_MACRO_PLAY1, // 5D07 |
| 431 | DYN_MACRO_PLAY2, // 5D08 | 431 | DYN_MACRO_PLAY2, // 5D08 |
| 432 | 432 | ||
| 433 | // Joystick | 433 | // Joystick |
| 434 | JS_BUTTON0, // 5D09 | 434 | JS_BUTTON0, // 5D09 |
| 435 | JS_BUTTON1, // 5D0A | 435 | JS_BUTTON1, // 5D0A |
| 436 | JS_BUTTON2, // 5D0B | 436 | JS_BUTTON2, // 5D0B |
| 437 | JS_BUTTON3, // 5D0C | 437 | JS_BUTTON3, // 5D0C |
| 438 | JS_BUTTON4, // 5D0D | 438 | JS_BUTTON4, // 5D0D |
| 439 | JS_BUTTON5, // 5D0E | 439 | JS_BUTTON5, // 5D0E |
| 440 | JS_BUTTON6, // 5D0F | 440 | JS_BUTTON6, // 5D0F |
| 441 | JS_BUTTON7, // 5D10 | 441 | JS_BUTTON7, // 5D10 |
| 442 | JS_BUTTON8, // 5D11 | 442 | JS_BUTTON8, // 5D11 |
| 443 | JS_BUTTON9, // 5D12 | 443 | JS_BUTTON9, // 5D12 |
| 444 | JS_BUTTON10, // 5D13 | 444 | JS_BUTTON10, // 5D13 |
| 445 | JS_BUTTON11, // 5D14 | 445 | JS_BUTTON11, // 5D14 |
| 446 | JS_BUTTON12, // 5D15 | 446 | JS_BUTTON12, // 5D15 |
| 447 | JS_BUTTON13, // 5D16 | 447 | JS_BUTTON13, // 5D16 |
| 448 | JS_BUTTON14, // 5D17 | 448 | JS_BUTTON14, // 5D17 |
| 449 | JS_BUTTON15, // 5D18 | 449 | JS_BUTTON15, // 5D18 |
| 450 | JS_BUTTON16, // 5D19 | 450 | JS_BUTTON16, // 5D19 |
| 451 | JS_BUTTON17, // 5D1A | 451 | JS_BUTTON17, // 5D1A |
| 452 | JS_BUTTON18, // 5D1B | 452 | JS_BUTTON18, // 5D1B |
| 453 | JS_BUTTON19, // 5D1C | 453 | JS_BUTTON19, // 5D1C |
| 454 | JS_BUTTON20, // 5D1D | 454 | JS_BUTTON20, // 5D1D |
| 455 | JS_BUTTON21, // 5D1E | 455 | JS_BUTTON21, // 5D1E |
| 456 | JS_BUTTON22, // 5D1F | 456 | JS_BUTTON22, // 5D1F |
| 457 | JS_BUTTON23, // 5D20 | 457 | JS_BUTTON23, // 5D20 |
| 458 | JS_BUTTON24, // 5D21 | 458 | JS_BUTTON24, // 5D21 |
| 459 | JS_BUTTON25, // 5D22 | 459 | JS_BUTTON25, // 5D22 |
| 460 | JS_BUTTON26, // 5D23 | 460 | JS_BUTTON26, // 5D23 |
| 461 | JS_BUTTON27, // 5D24 | 461 | JS_BUTTON27, // 5D24 |
| 462 | JS_BUTTON28, // 5D25 | 462 | JS_BUTTON28, // 5D25 |
| 463 | JS_BUTTON29, // 5D26 | 463 | JS_BUTTON29, // 5D26 |
| 464 | JS_BUTTON30, // 5D27 | 464 | JS_BUTTON30, // 5D27 |
| 465 | JS_BUTTON31, // 5D28 | 465 | JS_BUTTON31, // 5D28 |
| 466 | 466 | ||
| 467 | // Leader Key | 467 | // Leader Key |
| 468 | KC_LEAD, // 5D29 | 468 | KC_LEAD, // 5D29 |
| 469 | 469 | ||
| 470 | // Bluetooth: output selection (continued) | 470 | // Bluetooth: output selection (continued) |
| 471 | OUT_BT, // 5D2A | 471 | OUT_BT, // 5D2A |
| 472 | 472 | ||
| 473 | // Lock Key | 473 | // Lock Key |
| 474 | KC_LOCK, // 5D2B | 474 | KC_LOCK, // 5D2B |
| 475 | 475 | ||
| 476 | // Terminal | 476 | // Terminal |
| 477 | TERM_ON, // 5D2C | 477 | TERM_ON, // 5D2C |
| 478 | TERM_OFF, // 5D2D | 478 | TERM_OFF, // 5D2D |
| 479 | 479 | ||
| 480 | // Sequencer | 480 | // Sequencer |
| 481 | SQ_ON, // 5D2E | 481 | SQ_ON, // 5D2E |
| 482 | SQ_OFF, // 5D2F | 482 | SQ_OFF, // 5D2F |
| 483 | SQ_TOG, // 5D30 | 483 | SQ_TOG, // 5D30 |
| 484 | 484 | ||
| 485 | SQ_TMPD, // 5D31 | 485 | SQ_TMPD, // 5D31 |
| 486 | SQ_TMPU, // 5D32 | 486 | SQ_TMPU, // 5D32 |
| 487 | 487 | ||
| 488 | SQ_RESD, // 5D33 | 488 | SQ_RESD, // 5D33 |
| 489 | SQ_RESU, // 5D34 | 489 | SQ_RESU, // 5D34 |
| 490 | 490 | ||
| 491 | SQ_SALL, // 5D35 | 491 | SQ_SALL, // 5D35 |
| 492 | SQ_SCLR, // 5D36 | 492 | SQ_SCLR, // 5D36 |
| 493 | 493 | ||
| 494 | SEQUENCER_STEP_MIN, // 5D37 | 494 | SEQUENCER_STEP_MIN, // 5D37 |
| 495 | SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS, | 495 | SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS, |
| 496 | 496 | ||
| 497 | SEQUENCER_RESOLUTION_MIN, | 497 | SEQUENCER_RESOLUTION_MIN, |
| @@ -636,69 +636,69 @@ enum quantum_keycodes { | |||
| 636 | #define MOD_MEH 0x7 | 636 | #define MOD_MEH 0x7 |
| 637 | 637 | ||
| 638 | // US ANSI shifted keycode aliases | 638 | // US ANSI shifted keycode aliases |
| 639 | #define KC_TILDE LSFT(KC_GRAVE) // ~ | 639 | #define KC_TILDE LSFT(KC_GRAVE) // ~ |
| 640 | #define KC_TILD KC_TILDE | 640 | #define KC_TILD KC_TILDE |
| 641 | 641 | ||
| 642 | #define KC_EXCLAIM LSFT(KC_1) // ! | 642 | #define KC_EXCLAIM LSFT(KC_1) // ! |
| 643 | #define KC_EXLM KC_EXCLAIM | 643 | #define KC_EXLM KC_EXCLAIM |
| 644 | 644 | ||
| 645 | #define KC_AT LSFT(KC_2) // @ | 645 | #define KC_AT LSFT(KC_2) // @ |
| 646 | 646 | ||
| 647 | #define KC_HASH LSFT(KC_3) // # | 647 | #define KC_HASH LSFT(KC_3) // # |
| 648 | 648 | ||
| 649 | #define KC_DOLLAR LSFT(KC_4) // $ | 649 | #define KC_DOLLAR LSFT(KC_4) // $ |
| 650 | #define KC_DLR KC_DOLLAR | 650 | #define KC_DLR KC_DOLLAR |
| 651 | 651 | ||
| 652 | #define KC_PERCENT LSFT(KC_5) // % | 652 | #define KC_PERCENT LSFT(KC_5) // % |
| 653 | #define KC_PERC KC_PERCENT | 653 | #define KC_PERC KC_PERCENT |
| 654 | 654 | ||
| 655 | #define KC_CIRCUMFLEX LSFT(KC_6) // ^ | 655 | #define KC_CIRCUMFLEX LSFT(KC_6) // ^ |
| 656 | #define KC_CIRC KC_CIRCUMFLEX | 656 | #define KC_CIRC KC_CIRCUMFLEX |
| 657 | 657 | ||
| 658 | #define KC_AMPERSAND LSFT(KC_7) // & | 658 | #define KC_AMPERSAND LSFT(KC_7) // & |
| 659 | #define KC_AMPR KC_AMPERSAND | 659 | #define KC_AMPR KC_AMPERSAND |
| 660 | 660 | ||
| 661 | #define KC_ASTERISK LSFT(KC_8) // * | 661 | #define KC_ASTERISK LSFT(KC_8) // * |
| 662 | #define KC_ASTR KC_ASTERISK | 662 | #define KC_ASTR KC_ASTERISK |
| 663 | 663 | ||
| 664 | #define KC_LEFT_PAREN LSFT(KC_9) // ( | 664 | #define KC_LEFT_PAREN LSFT(KC_9) // ( |
| 665 | #define KC_LPRN KC_LEFT_PAREN | 665 | #define KC_LPRN KC_LEFT_PAREN |
| 666 | 666 | ||
| 667 | #define KC_RIGHT_PAREN LSFT(KC_0) // ) | 667 | #define KC_RIGHT_PAREN LSFT(KC_0) // ) |
| 668 | #define KC_RPRN KC_RIGHT_PAREN | 668 | #define KC_RPRN KC_RIGHT_PAREN |
| 669 | 669 | ||
| 670 | #define KC_UNDERSCORE LSFT(KC_MINUS) // _ | 670 | #define KC_UNDERSCORE LSFT(KC_MINUS) // _ |
| 671 | #define KC_UNDS KC_UNDERSCORE | 671 | #define KC_UNDS KC_UNDERSCORE |
| 672 | 672 | ||
| 673 | #define KC_PLUS LSFT(KC_EQUAL) // + | 673 | #define KC_PLUS LSFT(KC_EQUAL) // + |
| 674 | 674 | ||
| 675 | #define KC_LEFT_CURLY_BRACE LSFT(KC_LEFT_BRACKET) // { | 675 | #define KC_LEFT_CURLY_BRACE LSFT(KC_LEFT_BRACKET) // { |
| 676 | #define KC_LCBR KC_LEFT_CURLY_BRACE | 676 | #define KC_LCBR KC_LEFT_CURLY_BRACE |
| 677 | 677 | ||
| 678 | #define KC_RIGHT_CURLY_BRACE LSFT(KC_RIGHT_BRACKET) // } | 678 | #define KC_RIGHT_CURLY_BRACE LSFT(KC_RIGHT_BRACKET) // } |
| 679 | #define KC_RCBR KC_RIGHT_CURLY_BRACE | 679 | #define KC_RCBR KC_RIGHT_CURLY_BRACE |
| 680 | 680 | ||
| 681 | #define KC_LEFT_ANGLE_BRACKET LSFT(KC_COMMA) // < | 681 | #define KC_LEFT_ANGLE_BRACKET LSFT(KC_COMMA) // < |
| 682 | #define KC_LABK KC_LEFT_ANGLE_BRACKET | 682 | #define KC_LABK KC_LEFT_ANGLE_BRACKET |
| 683 | #define KC_LT KC_LEFT_ANGLE_BRACKET | 683 | #define KC_LT KC_LEFT_ANGLE_BRACKET |
| 684 | 684 | ||
| 685 | #define KC_RIGHT_ANGLE_BRACKET LSFT(KC_DOT) // > | 685 | #define KC_RIGHT_ANGLE_BRACKET LSFT(KC_DOT) // > |
| 686 | #define KC_RABK KC_RIGHT_ANGLE_BRACKET | 686 | #define KC_RABK KC_RIGHT_ANGLE_BRACKET |
| 687 | #define KC_GT KC_RIGHT_ANGLE_BRACKET | 687 | #define KC_GT KC_RIGHT_ANGLE_BRACKET |
| 688 | 688 | ||
| 689 | #define KC_COLON LSFT(KC_SEMICOLON) // : | 689 | #define KC_COLON LSFT(KC_SEMICOLON) // : |
| 690 | #define KC_COLN KC_COLON | 690 | #define KC_COLN KC_COLON |
| 691 | 691 | ||
| 692 | #define KC_PIPE LSFT(KC_BACKSLASH) // | | 692 | #define KC_PIPE LSFT(KC_BACKSLASH) // | |
| 693 | 693 | ||
| 694 | #define KC_QUESTION LSFT(KC_SLASH) // ? | 694 | #define KC_QUESTION LSFT(KC_SLASH) // ? |
| 695 | #define KC_QUES KC_QUESTION | 695 | #define KC_QUES KC_QUESTION |
| 696 | 696 | ||
| 697 | #define KC_DOUBLE_QUOTE LSFT(KC_QUOTE) // " | 697 | #define KC_DOUBLE_QUOTE LSFT(KC_QUOTE) // " |
| 698 | #define KC_DQUO KC_DOUBLE_QUOTE | 698 | #define KC_DQUO KC_DOUBLE_QUOTE |
| 699 | #define KC_DQT KC_DOUBLE_QUOTE | 699 | #define KC_DQT KC_DOUBLE_QUOTE |
| 700 | 700 | ||
| 701 | #define KC_DELT KC_DELETE // Del key (four letter code) | 701 | #define KC_DELT KC_DELETE // Del key (four letter code) |
| 702 | 702 | ||
| 703 | // Modified keycode aliases | 703 | // Modified keycode aliases |
| 704 | #define C(kc) LCTL(kc) | 704 | #define C(kc) LCTL(kc) |
| @@ -841,22 +841,22 @@ enum quantum_keycodes { | |||
| 841 | #define CMD_T(kc) LCMD_T(kc) | 841 | #define CMD_T(kc) LCMD_T(kc) |
| 842 | #define WIN_T(kc) LWIN_T(kc) | 842 | #define WIN_T(kc) LWIN_T(kc) |
| 843 | 843 | ||
| 844 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal | 844 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal |
| 845 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt | 845 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt |
| 846 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI | 846 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI |
| 847 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI | 847 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI |
| 848 | #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | 848 | #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ |
| 849 | #define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI | 849 | #define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI |
| 850 | #define SGUI_T(kc) LSG_T(kc) | 850 | #define SGUI_T(kc) LSG_T(kc) |
| 851 | #define SCMD_T(kc) LSG_T(kc) | 851 | #define SCMD_T(kc) LSG_T(kc) |
| 852 | #define SWIN_T(kc) LSG_T(kc) | 852 | #define SWIN_T(kc) LSG_T(kc) |
| 853 | #define LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) // Left Alt + GUI | 853 | #define LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) // Left Alt + GUI |
| 854 | #define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) // Right Shift + GUI | 854 | #define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) // Right Shift + GUI |
| 855 | #define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) // Right Alt + GUI | 855 | #define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) // Right Alt + GUI |
| 856 | #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt | 856 | #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt |
| 857 | #define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) // Left Shift + Alt | 857 | #define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) // Left Shift + Alt |
| 858 | #define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) // Right Shift + Alt | 858 | #define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) // Right Shift + Alt |
| 859 | #define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) // Right Control + Shift | 859 | #define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) // Right Control + Shift |
| 860 | #define SAGR_T(kc) RSA_T(kc) | 860 | #define SAGR_T(kc) RSA_T(kc) |
| 861 | 861 | ||
| 862 | #define ALL_T(kc) HYPR_T(kc) | 862 | #define ALL_T(kc) HYPR_T(kc) |
| @@ -870,14 +870,14 @@ enum quantum_keycodes { | |||
| 870 | #define UC(c) (QK_UNICODE | (c)) | 870 | #define UC(c) (QK_UNICODE | (c)) |
| 871 | // UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map | 871 | // UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map |
| 872 | #define X(i) (QK_UNICODEMAP | (i)) | 872 | #define X(i) (QK_UNICODEMAP | (i)) |
| 873 | #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j | 873 | #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j |
| 874 | 874 | ||
| 875 | #define UC_MOD UNICODE_MODE_FORWARD | 875 | #define UC_MOD UNICODE_MODE_FORWARD |
| 876 | #define UC_RMOD UNICODE_MODE_REVERSE | 876 | #define UC_RMOD UNICODE_MODE_REVERSE |
| 877 | 877 | ||
| 878 | #define UC_M_MA UNICODE_MODE_MAC | 878 | #define UC_M_MA UNICODE_MODE_MAC |
| 879 | #define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias | 879 | #define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias |
| 880 | #define UC_M_OS UNICODE_MODE_MAC // Deprecated alias | 880 | #define UC_M_OS UNICODE_MODE_MAC // Deprecated alias |
| 881 | #define UC_M_LN UNICODE_MODE_LNX | 881 | #define UC_M_LN UNICODE_MODE_LNX |
| 882 | #define UC_M_WI UNICODE_MODE_WIN | 882 | #define UC_M_WI UNICODE_MODE_WIN |
| 883 | #define UC_M_BS UNICODE_MODE_BSD | 883 | #define UC_M_BS UNICODE_MODE_BSD |
diff --git a/quantum/rgb_matrix/animations/alpha_mods_anim.h b/quantum/rgb_matrix/animations/alpha_mods_anim.h index d6136f1ba4..59b8381d69 100644 --- a/quantum/rgb_matrix/animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix/animations/alpha_mods_anim.h | |||
| @@ -22,5 +22,5 @@ bool ALPHAS_MODS(effect_params_t* params) { | |||
| 22 | return rgb_matrix_check_finished_leds(led_max); | 22 | return rgb_matrix_check_finished_leds(led_max); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 25 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 26 | #endif // ENABLE_RGB_MATRIX_ALPHAS_MODS | 26 | #endif // ENABLE_RGB_MATRIX_ALPHAS_MODS |
diff --git a/quantum/rgb_matrix/animations/breathing_anim.h b/quantum/rgb_matrix/animations/breathing_anim.h index 29187e1543..e9a3c96e1b 100644 --- a/quantum/rgb_matrix/animations/breathing_anim.h +++ b/quantum/rgb_matrix/animations/breathing_anim.h | |||
| @@ -16,5 +16,5 @@ bool BREATHING(effect_params_t* params) { | |||
| 16 | return rgb_matrix_check_finished_leds(led_max); | 16 | return rgb_matrix_check_finished_leds(led_max); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 19 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 20 | #endif // ENABLE_RGB_MATRIX_BREATHING | 20 | #endif // ENABLE_RGB_MATRIX_BREATHING |
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h index 0375d4937d..06aa8b5ed5 100644 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool BAND_PINWHEEL_SAT(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); } | 10 | bool BAND_PINWHEEL_SAT(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT | 15 | #endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT |
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h index e40bf4cd1f..bcbc319498 100644 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool BAND_PINWHEEL_VAL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); } | 10 | bool BAND_PINWHEEL_VAL(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL | 15 | #endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL |
diff --git a/quantum/rgb_matrix/animations/colorband_sat_anim.h b/quantum/rgb_matrix/animations/colorband_sat_anim.h index 1c4f7de575..cb0897ad3e 100644 --- a/quantum/rgb_matrix/animations/colorband_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_sat_anim.h | |||
| @@ -8,7 +8,9 @@ static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 8 | return hsv; | 8 | return hsv; |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | bool BAND_SAT(effect_params_t* params) { return effect_runner_i(params, &BAND_SAT_math); } | 11 | bool BAND_SAT(effect_params_t* params) { |
| 12 | return effect_runner_i(params, &BAND_SAT_math); | ||
| 13 | } | ||
| 12 | 14 | ||
| 13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 14 | #endif // ENABLE_RGB_MATRIX_BAND_SAT | 16 | #endif // ENABLE_RGB_MATRIX_BAND_SAT |
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h index cdd02b3797..d26eb37855 100644 --- a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool BAND_SPIRAL_SAT(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); } | 10 | bool BAND_SPIRAL_SAT(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT | 15 | #endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT |
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h index e1331eaebe..3ae34bb6f0 100644 --- a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool BAND_SPIRAL_VAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); } | 10 | bool BAND_SPIRAL_VAL(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL | 15 | #endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL |
diff --git a/quantum/rgb_matrix/animations/colorband_val_anim.h b/quantum/rgb_matrix/animations/colorband_val_anim.h index 02ee4add67..69c29f53a3 100644 --- a/quantum/rgb_matrix/animations/colorband_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_val_anim.h | |||
| @@ -8,7 +8,9 @@ static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 8 | return hsv; | 8 | return hsv; |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | bool BAND_VAL(effect_params_t* params) { return effect_runner_i(params, &BAND_VAL_math); } | 11 | bool BAND_VAL(effect_params_t* params) { |
| 12 | return effect_runner_i(params, &BAND_VAL_math); | ||
| 13 | } | ||
| 12 | 14 | ||
| 13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 14 | #endif // ENABLE_RGB_MATRIX_BAND_VAL | 16 | #endif // ENABLE_RGB_MATRIX_BAND_VAL |
diff --git a/quantum/rgb_matrix/animations/cycle_all_anim.h b/quantum/rgb_matrix/animations/cycle_all_anim.h index 3b73b9d385..d8c7220d95 100644 --- a/quantum/rgb_matrix/animations/cycle_all_anim.h +++ b/quantum/rgb_matrix/animations/cycle_all_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_ALL(effect_params_t* params) { return effect_runner_i(params, &CYCLE_ALL_math); } | 10 | bool CYCLE_ALL(effect_params_t* params) { |
| 11 | return effect_runner_i(params, &CYCLE_ALL_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_ALL | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_ALL |
diff --git a/quantum/rgb_matrix/animations/cycle_left_right_anim.h b/quantum/rgb_matrix/animations/cycle_left_right_anim.h index bf6a574069..84c2127aff 100644 --- a/quantum/rgb_matrix/animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix/animations/cycle_left_right_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } | 10 | bool CYCLE_LEFT_RIGHT(effect_params_t* params) { |
| 11 | return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT |
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_anim.h index 2bdb9d9375..9513fe9593 100644 --- a/quantum/rgb_matrix/animations/cycle_out_in_anim.h +++ b/quantum/rgb_matrix/animations/cycle_out_in_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } | 10 | bool CYCLE_OUT_IN(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN |
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h index 51979c44fe..3cca45f27a 100644 --- a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h +++ b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h | |||
| @@ -9,7 +9,9 @@ static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) | |||
| 9 | return hsv; | 9 | return hsv; |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); } | 12 | bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { |
| 13 | return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); | ||
| 14 | } | ||
| 13 | 15 | ||
| 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 16 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL | 17 | #endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL |
diff --git a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h index 10ba2b7c2c..de5993992c 100644 --- a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h +++ b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); } | 10 | bool CYCLE_PINWHEEL(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL |
diff --git a/quantum/rgb_matrix/animations/cycle_spiral_anim.h b/quantum/rgb_matrix/animations/cycle_spiral_anim.h index 482c7e7da6..904450179e 100644 --- a/quantum/rgb_matrix/animations/cycle_spiral_anim.h +++ b/quantum/rgb_matrix/animations/cycle_spiral_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); } | 10 | bool CYCLE_SPIRAL(effect_params_t* params) { |
| 11 | return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_SPIRAL | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_SPIRAL |
diff --git a/quantum/rgb_matrix/animations/cycle_up_down_anim.h b/quantum/rgb_matrix/animations/cycle_up_down_anim.h index 277edccb2f..dce05fecff 100644 --- a/quantum/rgb_matrix/animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix/animations/cycle_up_down_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } | 10 | bool CYCLE_UP_DOWN(effect_params_t* params) { |
| 11 | return effect_runner_i(params, &CYCLE_UP_DOWN_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN | 15 | #endif // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN |
diff --git a/quantum/rgb_matrix/animations/digital_rain_anim.h b/quantum/rgb_matrix/animations/digital_rain_anim.h index 8ce8fd7039..4633145ff6 100644 --- a/quantum/rgb_matrix/animations/digital_rain_anim.h +++ b/quantum/rgb_matrix/animations/digital_rain_anim.h | |||
| @@ -71,5 +71,5 @@ bool DIGITAL_RAIN(effect_params_t* params) { | |||
| 71 | return false; | 71 | return false; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 74 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 75 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) | 75 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) |
diff --git a/quantum/rgb_matrix/animations/dual_beacon_anim.h b/quantum/rgb_matrix/animations/dual_beacon_anim.h index dbe9b3ecf1..5585015b86 100644 --- a/quantum/rgb_matrix/animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix/animations/dual_beacon_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } | 10 | bool DUAL_BEACON(effect_params_t* params) { |
| 11 | return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_DUAL_BEACON | 15 | #endif // ENABLE_RGB_MATRIX_DUAL_BEACON |
diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h index 8bb5e570bd..ebb06f59f2 100644 --- a/quantum/rgb_matrix/animations/gradient_left_right_anim.h +++ b/quantum/rgb_matrix/animations/gradient_left_right_anim.h | |||
| @@ -18,5 +18,5 @@ bool GRADIENT_LEFT_RIGHT(effect_params_t* params) { | |||
| 18 | return rgb_matrix_check_finished_leds(led_max); | 18 | return rgb_matrix_check_finished_leds(led_max); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 22 | #endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT | 22 | #endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT |
diff --git a/quantum/rgb_matrix/animations/gradient_up_down_anim.h b/quantum/rgb_matrix/animations/gradient_up_down_anim.h index a5674583e3..febc3919a8 100644 --- a/quantum/rgb_matrix/animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix/animations/gradient_up_down_anim.h | |||
| @@ -18,5 +18,5 @@ bool GRADIENT_UP_DOWN(effect_params_t* params) { | |||
| 18 | return rgb_matrix_check_finished_leds(led_max); | 18 | return rgb_matrix_check_finished_leds(led_max); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 22 | #endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN | 22 | #endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN |
diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h index 82be1a4424..8537762832 100644 --- a/quantum/rgb_matrix/animations/hue_breathing_anim.h +++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h | |||
| @@ -18,5 +18,5 @@ bool HUE_BREATHING(effect_params_t* params) { | |||
| 18 | return rgb_matrix_check_finished_leds(led_max); | 18 | return rgb_matrix_check_finished_leds(led_max); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 22 | #endif // DISABLE_RGB_HUE_BREATHING | 22 | #endif // DISABLE_RGB_HUE_BREATHING |
diff --git a/quantum/rgb_matrix/animations/hue_pendulum_anim.h b/quantum/rgb_matrix/animations/hue_pendulum_anim.h index a6e1c1074d..7d8cbcdfb2 100644 --- a/quantum/rgb_matrix/animations/hue_pendulum_anim.h +++ b/quantum/rgb_matrix/animations/hue_pendulum_anim.h | |||
| @@ -11,7 +11,9 @@ static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 11 | return hsv; | 11 | return hsv; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | bool HUE_PENDULUM(effect_params_t* params) { return effect_runner_i(params, &HUE_PENDULUM_math); } | 14 | bool HUE_PENDULUM(effect_params_t* params) { |
| 15 | return effect_runner_i(params, &HUE_PENDULUM_math); | ||
| 16 | } | ||
| 15 | 17 | ||
| 16 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 18 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 17 | #endif // DISABLE_RGB_HUE_PENDULUM | 19 | #endif // DISABLE_RGB_HUE_PENDULUM |
diff --git a/quantum/rgb_matrix/animations/hue_wave_anim.h b/quantum/rgb_matrix/animations/hue_wave_anim.h index b1c72b7336..81aa7e139e 100644 --- a/quantum/rgb_matrix/animations/hue_wave_anim.h +++ b/quantum/rgb_matrix/animations/hue_wave_anim.h | |||
| @@ -11,7 +11,9 @@ static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 11 | return hsv; | 11 | return hsv; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | bool HUE_WAVE(effect_params_t* params) { return effect_runner_i(params, &HUE_WAVE_math); } | 14 | bool HUE_WAVE(effect_params_t* params) { |
| 15 | return effect_runner_i(params, &HUE_WAVE_math); | ||
| 16 | } | ||
| 15 | 17 | ||
| 16 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 18 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 17 | #endif // DISABLE_RGB_HUE_WAVE | 19 | #endif // DISABLE_RGB_HUE_WAVE |
diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h index 3ffb57eb35..31dffcbc5a 100644 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h | |||
| @@ -25,5 +25,5 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) { | |||
| 25 | return rgb_matrix_check_finished_leds(led_max); | 25 | return rgb_matrix_check_finished_leds(led_max); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 28 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 29 | #endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS | 29 | #endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS |
diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h index 312c87628c..714f5d174e 100644 --- a/quantum/rgb_matrix/animations/pixel_flow_anim.h +++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h | |||
| @@ -14,7 +14,9 @@ static bool PIXEL_FLOW(effect_params_t* params) { | |||
| 14 | return false; | 14 | return false; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } | 17 | inline uint32_t interval(void) { |
| 18 | return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); | ||
| 19 | } | ||
| 18 | 20 | ||
| 19 | if (params->init) { | 21 | if (params->init) { |
| 20 | // Clear LEDs and fill the state array | 22 | // Clear LEDs and fill the state array |
| @@ -45,5 +47,5 @@ static bool PIXEL_FLOW(effect_params_t* params) { | |||
| 45 | return rgb_matrix_check_finished_leds(led_max); | 47 | return rgb_matrix_check_finished_leds(led_max); |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 50 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 49 | #endif // ENABLE_RGB_MATRIX_PIXEL_FLOW | 51 | #endif // ENABLE_RGB_MATRIX_PIXEL_FLOW |
diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h index 35187b92de..906da1a48e 100644 --- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h +++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h | |||
| @@ -29,7 +29,9 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { | |||
| 29 | return false; | 29 | return false; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } | 32 | inline uint32_t interval(void) { |
| 33 | return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); | ||
| 34 | } | ||
| 33 | 35 | ||
| 34 | if (params->init) { | 36 | if (params->init) { |
| 35 | rgb_matrix_set_color_all(0, 0, 0); | 37 | rgb_matrix_set_color_all(0, 0, 0); |
| @@ -37,7 +39,7 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { | |||
| 37 | 39 | ||
| 38 | RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); | 40 | RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); |
| 39 | for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { | 41 | for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { |
| 40 | for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards | 42 | for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards |
| 41 | if (led[h][l]) { | 43 | if (led[h][l]) { |
| 42 | rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); | 44 | rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); |
| 43 | } else { | 45 | } else { |
| @@ -46,7 +48,7 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { | |||
| 46 | led[h][l] = led[h][l + 1]; | 48 | led[h][l] = led[h][l + 1]; |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards | 51 | for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards |
| 50 | if (led[h][r]) { | 52 | if (led[h][r]) { |
| 51 | rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); | 53 | rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); |
| 52 | } else { | 54 | } else { |
| @@ -74,5 +76,5 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { | |||
| 74 | wait_timer = g_rgb_timer + interval(); | 76 | wait_timer = g_rgb_timer + interval(); |
| 75 | return false; | 77 | return false; |
| 76 | } | 78 | } |
| 77 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 79 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 78 | #endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL | 80 | #endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL |
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h index 001649aa6e..03488b43df 100644 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h | |||
| @@ -24,7 +24,9 @@ static bool PIXEL_RAIN(effect_params_t* params) { | |||
| 24 | return false; | 24 | return false; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | inline uint32_t interval(void) { return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } | 27 | inline uint32_t interval(void) { |
| 28 | return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); | ||
| 29 | } | ||
| 28 | 30 | ||
| 29 | bool rain_pixel(uint8_t i, effect_params_t * params, bool off) { | 31 | bool rain_pixel(uint8_t i, effect_params_t * params, bool off) { |
| 30 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) { | 32 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) { |
| @@ -44,5 +46,5 @@ static bool PIXEL_RAIN(effect_params_t* params) { | |||
| 44 | return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2); | 46 | return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 49 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 48 | #endif // ENABLE_RGB_MATRIX_PIXEL_RAIN | 50 | #endif // ENABLE_RGB_MATRIX_PIXEL_RAIN |
diff --git a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h index cd529958db..bdcca5530f 100644 --- a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8 | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } | 10 | bool RAINBOW_BEACON(effect_params_t* params) { |
| 11 | return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_RAINBOW_BEACON | 15 | #endif // ENABLE_RGB_MATRIX_RAINBOW_BEACON |
diff --git a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h index 2f3de64e9d..f7b8f6c2f3 100644 --- a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } | 10 | bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { |
| 11 | return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON | 15 | #endif // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON |
diff --git a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h index dae2b5d190..91e31ea8cc 100644 --- a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h | |||
| @@ -7,7 +7,9 @@ static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, ui | |||
| 7 | return hsv; | 7 | return hsv; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } | 10 | bool RAINBOW_PINWHEELS(effect_params_t* params) { |
| 11 | return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); | ||
| 12 | } | ||
| 11 | 13 | ||
| 12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 13 | #endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS | 15 | #endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS |
diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h index 4b1b9dd9ec..2d4b53b7b0 100644 --- a/quantum/rgb_matrix/animations/raindrops_anim.h +++ b/quantum/rgb_matrix/animations/raindrops_anim.h | |||
| @@ -35,5 +35,5 @@ bool RAINDROPS(effect_params_t* params) { | |||
| 35 | return rgb_matrix_check_finished_leds(led_max); | 35 | return rgb_matrix_check_finished_leds(led_max); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 39 | #endif // ENABLE_RGB_MATRIX_RAINDROPS | 39 | #endif // ENABLE_RGB_MATRIX_RAINDROPS |
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h index d5c1a26cef..f9584d7071 100644 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h | |||
| @@ -26,4 +26,4 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) { | |||
| 26 | return rgb_matrix_check_finished_leds(led_max); | 26 | return rgb_matrix_check_finished_leds(led_max); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h index d3a6e4e72f..41020eb47f 100644 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h | |||
| @@ -26,4 +26,4 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react | |||
| 26 | return rgb_matrix_check_finished_leds(led_max); | 26 | return rgb_matrix_check_finished_leds(led_max); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_color_anim.h b/quantum/rgb_matrix/animations/solid_color_anim.h index 4209959468..c8762dcbc2 100644 --- a/quantum/rgb_matrix/animations/solid_color_anim.h +++ b/quantum/rgb_matrix/animations/solid_color_anim.h | |||
| @@ -12,4 +12,4 @@ bool SOLID_COLOR(effect_params_t* params) { | |||
| 12 | return rgb_matrix_check_finished_leds(led_max); | 12 | return rgb_matrix_check_finished_leds(led_max); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h index 360d05a67a..d3a7ebbdf7 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h | |||
| @@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { | |||
| 8 | return hsv; | 8 | return hsv; |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | bool SOLID_REACTIVE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_math); } | 11 | bool SOLID_REACTIVE(effect_params_t* params) { |
| 12 | return effect_runner_reactive(params, &SOLID_REACTIVE_math); | ||
| 13 | } | ||
| 12 | 14 | ||
| 13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 14 | # endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE | 16 | # endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE |
| 15 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 17 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_reactive_cross.h b/quantum/rgb_matrix/animations/solid_reactive_cross.h index 496651f8a5..043a369b73 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h | |||
| @@ -24,13 +24,17 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di | |||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | 26 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS |
| 27 | bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } | 27 | bool SOLID_REACTIVE_CROSS(effect_params_t* params) { |
| 28 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); | ||
| 29 | } | ||
| 28 | # endif | 30 | # endif |
| 29 | 31 | ||
| 30 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | 32 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS |
| 31 | bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } | 33 | bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { |
| 34 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); | ||
| 35 | } | ||
| 32 | # endif | 36 | # endif |
| 33 | 37 | ||
| 34 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 35 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | 39 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) |
| 36 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 40 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_reactive_nexus.h b/quantum/rgb_matrix/animations/solid_reactive_nexus.h index 3562e74a72..8d62a49fea 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h | |||
| @@ -22,13 +22,17 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | 24 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS |
| 25 | bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } | 25 | bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { |
| 26 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); | ||
| 27 | } | ||
| 26 | # endif | 28 | # endif |
| 27 | 29 | ||
| 28 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | 30 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS |
| 29 | bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } | 31 | bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { |
| 32 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); | ||
| 33 | } | ||
| 30 | # endif | 34 | # endif |
| 31 | 35 | ||
| 32 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 36 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 33 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | 37 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) |
| 34 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 38 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h index 69189f636b..0d0a424cf3 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h | |||
| @@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { | |||
| 8 | return hsv; | 8 | return hsv; |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } | 11 | bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { |
| 12 | return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); | ||
| 13 | } | ||
| 12 | 14 | ||
| 13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 15 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 14 | # endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE | 16 | # endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE |
| 15 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 17 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_reactive_wide.h b/quantum/rgb_matrix/animations/solid_reactive_wide.h index a613c7ff5f..7598796316 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h | |||
| @@ -19,13 +19,17 @@ static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dis | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | 21 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE |
| 22 | bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } | 22 | bool SOLID_REACTIVE_WIDE(effect_params_t* params) { |
| 23 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); | ||
| 24 | } | ||
| 23 | # endif | 25 | # endif |
| 24 | 26 | ||
| 25 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | 27 | # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE |
| 26 | bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } | 28 | bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { |
| 29 | return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); | ||
| 30 | } | ||
| 27 | # endif | 31 | # endif |
| 28 | 32 | ||
| 29 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 33 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 30 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | 34 | # endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) |
| 31 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 35 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/solid_splash_anim.h b/quantum/rgb_matrix/animations/solid_splash_anim.h index bd9c1cfe2b..77d6f8c5eb 100644 --- a/quantum/rgb_matrix/animations/solid_splash_anim.h +++ b/quantum/rgb_matrix/animations/solid_splash_anim.h | |||
| @@ -19,13 +19,17 @@ HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t ti | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | # ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH | 21 | # ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH |
| 22 | bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } | 22 | bool SOLID_SPLASH(effect_params_t* params) { |
| 23 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); | ||
| 24 | } | ||
| 23 | # endif | 25 | # endif |
| 24 | 26 | ||
| 25 | # ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH | 27 | # ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH |
| 26 | bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } | 28 | bool SOLID_MULTISPLASH(effect_params_t* params) { |
| 29 | return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); | ||
| 30 | } | ||
| 27 | # endif | 31 | # endif |
| 28 | 32 | ||
| 29 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 33 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 30 | # endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH) | 34 | # endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH) |
| 31 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 35 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/splash_anim.h b/quantum/rgb_matrix/animations/splash_anim.h index 382355e9ed..06459e1b0a 100644 --- a/quantum/rgb_matrix/animations/splash_anim.h +++ b/quantum/rgb_matrix/animations/splash_anim.h | |||
| @@ -20,13 +20,17 @@ HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | # ifdef ENABLE_RGB_MATRIX_SPLASH | 22 | # ifdef ENABLE_RGB_MATRIX_SPLASH |
| 23 | bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); } | 23 | bool SPLASH(effect_params_t* params) { |
| 24 | return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); | ||
| 25 | } | ||
| 24 | # endif | 26 | # endif |
| 25 | 27 | ||
| 26 | # ifdef ENABLE_RGB_MATRIX_MULTISPLASH | 28 | # ifdef ENABLE_RGB_MATRIX_MULTISPLASH |
| 27 | bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); } | 29 | bool MULTISPLASH(effect_params_t* params) { |
| 30 | return effect_runner_reactive_splash(0, params, &SPLASH_math); | ||
| 31 | } | ||
| 28 | # endif | 32 | # endif |
| 29 | 33 | ||
| 30 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 34 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 31 | # endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH) | 35 | # endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH) |
| 32 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 36 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
diff --git a/quantum/rgb_matrix/animations/typing_heatmap_anim.h b/quantum/rgb_matrix/animations/typing_heatmap_anim.h index b66667b9b8..f3a94280c0 100644 --- a/quantum/rgb_matrix/animations/typing_heatmap_anim.h +++ b/quantum/rgb_matrix/animations/typing_heatmap_anim.h | |||
| @@ -82,5 +82,5 @@ bool TYPING_HEATMAP(effect_params_t* params) { | |||
| 82 | return led_max < sizeof(g_rgb_frame_buffer); | 82 | return led_max < sizeof(g_rgb_frame_buffer); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 85 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 86 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) | 86 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) |
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 5a4556f097..f721dfc7f2 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c | |||
| @@ -31,7 +31,9 @@ const led_point_t k_rgb_matrix_center = {112, 32}; | |||
| 31 | const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; | 31 | const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } | 34 | __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { |
| 35 | return hsv_to_rgb(hsv); | ||
| 36 | } | ||
| 35 | 37 | ||
| 36 | // Generic effect runners | 38 | // Generic effect runners |
| 37 | #include "rgb_matrix_runners.inc" | 39 | #include "rgb_matrix_runners.inc" |
| @@ -109,14 +111,14 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv | |||
| 109 | #endif | 111 | #endif |
| 110 | 112 | ||
| 111 | // globals | 113 | // globals |
| 112 | rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr | 114 | rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr |
| 113 | uint32_t g_rgb_timer; | 115 | uint32_t g_rgb_timer; |
| 114 | #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS | 116 | #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS |
| 115 | uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; | 117 | uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; |
| 116 | #endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS | 118 | #endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS |
| 117 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 119 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 118 | last_hit_t g_last_hit_tracker; | 120 | last_hit_t g_last_hit_tracker; |
| 119 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 121 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 120 | 122 | ||
| 121 | // internals | 123 | // internals |
| 122 | static bool suspend_state = false; | 124 | static bool suspend_state = false; |
| @@ -126,13 +128,13 @@ static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; | |||
| 126 | static rgb_task_states rgb_task_state = SYNCING; | 128 | static rgb_task_states rgb_task_state = SYNCING; |
| 127 | #if RGB_DISABLE_TIMEOUT > 0 | 129 | #if RGB_DISABLE_TIMEOUT > 0 |
| 128 | static uint32_t rgb_anykey_timer; | 130 | static uint32_t rgb_anykey_timer; |
| 129 | #endif // RGB_DISABLE_TIMEOUT > 0 | 131 | #endif // RGB_DISABLE_TIMEOUT > 0 |
| 130 | 132 | ||
| 131 | // double buffers | 133 | // double buffers |
| 132 | static uint32_t rgb_timer_buffer; | 134 | static uint32_t rgb_timer_buffer; |
| 133 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 135 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 134 | static last_hit_t last_hit_buffer; | 136 | static last_hit_t last_hit_buffer; |
| 135 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 137 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 136 | 138 | ||
| 137 | // split rgb matrix | 139 | // split rgb matrix |
| 138 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 140 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| @@ -141,7 +143,9 @@ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; | |||
| 141 | 143 | ||
| 142 | EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); | 144 | EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); |
| 143 | 145 | ||
| 144 | void eeconfig_update_rgb_matrix(void) { eeconfig_flush_rgb_matrix(true); } | 146 | void eeconfig_update_rgb_matrix(void) { |
| 147 | eeconfig_flush_rgb_matrix(true); | ||
| 148 | } | ||
| 145 | 149 | ||
| 146 | void eeconfig_update_rgb_matrix_default(void) { | 150 | void eeconfig_update_rgb_matrix_default(void) { |
| 147 | dprintf("eeconfig_update_rgb_matrix_default\n"); | 151 | dprintf("eeconfig_update_rgb_matrix_default\n"); |
| @@ -168,13 +172,15 @@ void rgb_matrix_reload_from_eeprom(void) { | |||
| 168 | rgb_matrix_disable_noeeprom(); | 172 | rgb_matrix_disable_noeeprom(); |
| 169 | /* Reset back to what we have in eeprom */ | 173 | /* Reset back to what we have in eeprom */ |
| 170 | eeconfig_init_rgb_matrix(); | 174 | eeconfig_init_rgb_matrix(); |
| 171 | eeconfig_debug_rgb_matrix(); // display current eeprom values | 175 | eeconfig_debug_rgb_matrix(); // display current eeprom values |
| 172 | if (rgb_matrix_config.enable) { | 176 | if (rgb_matrix_config.enable) { |
| 173 | rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); | 177 | rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); |
| 174 | } | 178 | } |
| 175 | } | 179 | } |
| 176 | 180 | ||
| 177 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } | 181 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { |
| 182 | return 0; | ||
| 183 | } | ||
| 178 | 184 | ||
| 179 | uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { | 185 | uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { |
| 180 | uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); | 186 | uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); |
| @@ -186,13 +192,18 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l | |||
| 186 | return led_count; | 192 | return led_count; |
| 187 | } | 193 | } |
| 188 | 194 | ||
| 189 | void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } | 195 | void rgb_matrix_update_pwm_buffers(void) { |
| 196 | rgb_matrix_driver.flush(); | ||
| 197 | } | ||
| 190 | 198 | ||
| 191 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); } | 199 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 200 | rgb_matrix_driver.set_color(index, red, green, blue); | ||
| 201 | } | ||
| 192 | 202 | ||
| 193 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { | 203 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 194 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 204 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 195 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue); | 205 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) |
| 206 | rgb_matrix_set_color(i, red, green, blue); | ||
| 196 | #else | 207 | #else |
| 197 | rgb_matrix_driver.set_color_all(red, green, blue); | 208 | rgb_matrix_driver.set_color_all(red, green, blue); |
| 198 | #endif | 209 | #endif |
| @@ -204,7 +215,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 204 | #endif | 215 | #endif |
| 205 | #if RGB_DISABLE_TIMEOUT > 0 | 216 | #if RGB_DISABLE_TIMEOUT > 0 |
| 206 | rgb_anykey_timer = 0; | 217 | rgb_anykey_timer = 0; |
| 207 | #endif // RGB_DISABLE_TIMEOUT > 0 | 218 | #endif // RGB_DISABLE_TIMEOUT > 0 |
| 208 | 219 | ||
| 209 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 220 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 210 | uint8_t led[LED_HITS_TO_REMEMBER]; | 221 | uint8_t led[LED_HITS_TO_REMEMBER]; |
| @@ -214,7 +225,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 214 | if (!pressed) | 225 | if (!pressed) |
| 215 | # elif defined(RGB_MATRIX_KEYPRESSES) | 226 | # elif defined(RGB_MATRIX_KEYPRESSES) |
| 216 | if (pressed) | 227 | if (pressed) |
| 217 | # endif // defined(RGB_MATRIX_KEYRELEASES) | 228 | # endif // defined(RGB_MATRIX_KEYRELEASES) |
| 218 | { | 229 | { |
| 219 | led_count = rgb_matrix_map_row_column_to_led(row, col, led); | 230 | led_count = rgb_matrix_map_row_column_to_led(row, col, led); |
| 220 | } | 231 | } |
| @@ -222,7 +233,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 222 | if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { | 233 | if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { |
| 223 | memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); | 234 | memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 224 | memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); | 235 | memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 225 | memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit | 236 | memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit |
| 226 | memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); | 237 | memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); |
| 227 | last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; | 238 | last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; |
| 228 | } | 239 | } |
| @@ -235,13 +246,13 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 235 | last_hit_buffer.tick[index] = 0; | 246 | last_hit_buffer.tick[index] = 0; |
| 236 | last_hit_buffer.count++; | 247 | last_hit_buffer.count++; |
| 237 | } | 248 | } |
| 238 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 249 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 239 | 250 | ||
| 240 | #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) | 251 | #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) |
| 241 | if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { | 252 | if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { |
| 242 | process_rgb_matrix_typing_heatmap(row, col); | 253 | process_rgb_matrix_typing_heatmap(row, col); |
| 243 | } | 254 | } |
| 244 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) | 255 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) |
| 245 | } | 256 | } |
| 246 | 257 | ||
| 247 | void rgb_matrix_test(void) { | 258 | void rgb_matrix_test(void) { |
| @@ -280,7 +291,7 @@ static bool rgb_matrix_none(effect_params_t *params) { | |||
| 280 | static void rgb_task_timers(void) { | 291 | static void rgb_task_timers(void) { |
| 281 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 | 292 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 |
| 282 | uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); | 293 | uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); |
| 283 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 | 294 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 |
| 284 | rgb_timer_buffer = sync_timer_read32(); | 295 | rgb_timer_buffer = sync_timer_read32(); |
| 285 | 296 | ||
| 286 | // Update double buffer timers | 297 | // Update double buffer timers |
| @@ -288,7 +299,7 @@ static void rgb_task_timers(void) { | |||
| 288 | if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { | 299 | if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { |
| 289 | rgb_anykey_timer += deltaTime; | 300 | rgb_anykey_timer += deltaTime; |
| 290 | } | 301 | } |
| 291 | #endif // RGB_DISABLE_TIMEOUT > 0 | 302 | #endif // RGB_DISABLE_TIMEOUT > 0 |
| 292 | 303 | ||
| 293 | // Update double buffer last hit timers | 304 | // Update double buffer last hit timers |
| 294 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 305 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| @@ -300,7 +311,7 @@ static void rgb_task_timers(void) { | |||
| 300 | } | 311 | } |
| 301 | last_hit_buffer.tick[i] += deltaTime; | 312 | last_hit_buffer.tick[i] += deltaTime; |
| 302 | } | 313 | } |
| 303 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 314 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 304 | } | 315 | } |
| 305 | 316 | ||
| 306 | static void rgb_task_sync(void) { | 317 | static void rgb_task_sync(void) { |
| @@ -317,7 +328,7 @@ static void rgb_task_start(void) { | |||
| 317 | g_rgb_timer = rgb_timer_buffer; | 328 | g_rgb_timer = rgb_timer_buffer; |
| 318 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 329 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 319 | g_last_hit_tracker = last_hit_buffer; | 330 | g_last_hit_tracker = last_hit_buffer; |
| 320 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 331 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 321 | 332 | ||
| 322 | // next task | 333 | // next task |
| 323 | rgb_task_state = RENDERING; | 334 | rgb_task_state = RENDERING; |
| @@ -403,7 +414,7 @@ void rgb_matrix_task(void) { | |||
| 403 | bool suspend_backlight = suspend_state || | 414 | bool suspend_backlight = suspend_state || |
| 404 | #if RGB_DISABLE_TIMEOUT > 0 | 415 | #if RGB_DISABLE_TIMEOUT > 0 |
| 405 | (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || | 416 | (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || |
| 406 | #endif // RGB_DISABLE_TIMEOUT > 0 | 417 | #endif // RGB_DISABLE_TIMEOUT > 0 |
| 407 | false; | 418 | false; |
| 408 | 419 | ||
| 409 | uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; | 420 | uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; |
| @@ -472,7 +483,7 @@ void rgb_matrix_init(void) { | |||
| 472 | for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { | 483 | for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { |
| 473 | last_hit_buffer.tick[i] = UINT16_MAX; | 484 | last_hit_buffer.tick[i] = UINT16_MAX; |
| 474 | } | 485 | } |
| 475 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 486 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 476 | 487 | ||
| 477 | if (!eeconfig_is_enabled()) { | 488 | if (!eeconfig_is_enabled()) { |
| 478 | dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); | 489 | dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); |
| @@ -485,20 +496,22 @@ void rgb_matrix_init(void) { | |||
| 485 | dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); | 496 | dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); |
| 486 | eeconfig_update_rgb_matrix_default(); | 497 | eeconfig_update_rgb_matrix_default(); |
| 487 | } | 498 | } |
| 488 | eeconfig_debug_rgb_matrix(); // display current eeprom values | 499 | eeconfig_debug_rgb_matrix(); // display current eeprom values |
| 489 | } | 500 | } |
| 490 | 501 | ||
| 491 | void rgb_matrix_set_suspend_state(bool state) { | 502 | void rgb_matrix_set_suspend_state(bool state) { |
| 492 | #ifdef RGB_DISABLE_WHEN_USB_SUSPENDED | 503 | #ifdef RGB_DISABLE_WHEN_USB_SUSPENDED |
| 493 | if (state && !suspend_state) { // only run if turning off, and only once | 504 | if (state && !suspend_state) { // only run if turning off, and only once |
| 494 | rgb_task_render(0); // turn off all LEDs when suspending | 505 | rgb_task_render(0); // turn off all LEDs when suspending |
| 495 | rgb_task_flush(0); // and actually flash led state to LEDs | 506 | rgb_task_flush(0); // and actually flash led state to LEDs |
| 496 | } | 507 | } |
| 497 | suspend_state = state; | 508 | suspend_state = state; |
| 498 | #endif | 509 | #endif |
| 499 | } | 510 | } |
| 500 | 511 | ||
| 501 | bool rgb_matrix_get_suspend_state(void) { return suspend_state; } | 512 | bool rgb_matrix_get_suspend_state(void) { |
| 513 | return suspend_state; | ||
| 514 | } | ||
| 502 | 515 | ||
| 503 | void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | 516 | void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { |
| 504 | rgb_matrix_config.enable ^= 1; | 517 | rgb_matrix_config.enable ^= 1; |
| @@ -506,8 +519,12 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | |||
| 506 | eeconfig_flag_rgb_matrix(write_to_eeprom); | 519 | eeconfig_flag_rgb_matrix(write_to_eeprom); |
| 507 | dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); | 520 | dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); |
| 508 | } | 521 | } |
| 509 | void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } | 522 | void rgb_matrix_toggle_noeeprom(void) { |
| 510 | void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); } | 523 | rgb_matrix_toggle_eeprom_helper(false); |
| 524 | } | ||
| 525 | void rgb_matrix_toggle(void) { | ||
| 526 | rgb_matrix_toggle_eeprom_helper(true); | ||
| 527 | } | ||
| 511 | 528 | ||
| 512 | void rgb_matrix_enable(void) { | 529 | void rgb_matrix_enable(void) { |
| 513 | rgb_matrix_enable_noeeprom(); | 530 | rgb_matrix_enable_noeeprom(); |
| @@ -529,7 +546,9 @@ void rgb_matrix_disable_noeeprom(void) { | |||
| 529 | rgb_matrix_config.enable = 0; | 546 | rgb_matrix_config.enable = 0; |
| 530 | } | 547 | } |
| 531 | 548 | ||
| 532 | uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } | 549 | uint8_t rgb_matrix_is_enabled(void) { |
| 550 | return rgb_matrix_config.enable; | ||
| 551 | } | ||
| 533 | 552 | ||
| 534 | void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | 553 | void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { |
| 535 | if (!rgb_matrix_config.enable) { | 554 | if (!rgb_matrix_config.enable) { |
| @@ -546,24 +565,38 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 546 | eeconfig_flag_rgb_matrix(write_to_eeprom); | 565 | eeconfig_flag_rgb_matrix(write_to_eeprom); |
| 547 | dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); | 566 | dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); |
| 548 | } | 567 | } |
| 549 | void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); } | 568 | void rgb_matrix_mode_noeeprom(uint8_t mode) { |
| 550 | void rgb_matrix_mode(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, true); } | 569 | rgb_matrix_mode_eeprom_helper(mode, false); |
| 570 | } | ||
| 571 | void rgb_matrix_mode(uint8_t mode) { | ||
| 572 | rgb_matrix_mode_eeprom_helper(mode, true); | ||
| 573 | } | ||
| 551 | 574 | ||
| 552 | uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; } | 575 | uint8_t rgb_matrix_get_mode(void) { |
| 576 | return rgb_matrix_config.mode; | ||
| 577 | } | ||
| 553 | 578 | ||
| 554 | void rgb_matrix_step_helper(bool write_to_eeprom) { | 579 | void rgb_matrix_step_helper(bool write_to_eeprom) { |
| 555 | uint8_t mode = rgb_matrix_config.mode + 1; | 580 | uint8_t mode = rgb_matrix_config.mode + 1; |
| 556 | rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); | 581 | rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); |
| 557 | } | 582 | } |
| 558 | void rgb_matrix_step_noeeprom(void) { rgb_matrix_step_helper(false); } | 583 | void rgb_matrix_step_noeeprom(void) { |
| 559 | void rgb_matrix_step(void) { rgb_matrix_step_helper(true); } | 584 | rgb_matrix_step_helper(false); |
| 585 | } | ||
| 586 | void rgb_matrix_step(void) { | ||
| 587 | rgb_matrix_step_helper(true); | ||
| 588 | } | ||
| 560 | 589 | ||
| 561 | void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { | 590 | void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { |
| 562 | uint8_t mode = rgb_matrix_config.mode - 1; | 591 | uint8_t mode = rgb_matrix_config.mode - 1; |
| 563 | rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); | 592 | rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); |
| 564 | } | 593 | } |
| 565 | void rgb_matrix_step_reverse_noeeprom(void) { rgb_matrix_step_reverse_helper(false); } | 594 | void rgb_matrix_step_reverse_noeeprom(void) { |
| 566 | void rgb_matrix_step_reverse(void) { rgb_matrix_step_reverse_helper(true); } | 595 | rgb_matrix_step_reverse_helper(false); |
| 596 | } | ||
| 597 | void rgb_matrix_step_reverse(void) { | ||
| 598 | rgb_matrix_step_reverse_helper(true); | ||
| 599 | } | ||
| 567 | 600 | ||
| 568 | void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { | 601 | void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { |
| 569 | if (!rgb_matrix_config.enable) { | 602 | if (!rgb_matrix_config.enable) { |
| @@ -575,56 +608,126 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo | |||
| 575 | eeconfig_flag_rgb_matrix(write_to_eeprom); | 608 | eeconfig_flag_rgb_matrix(write_to_eeprom); |
| 576 | dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); | 609 | dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); |
| 577 | } | 610 | } |
| 578 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } | 611 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { |
| 579 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); } | 612 | rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); |
| 613 | } | ||
| 614 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 615 | rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); | ||
| 616 | } | ||
| 580 | 617 | ||
| 581 | HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } | 618 | HSV rgb_matrix_get_hsv(void) { |
| 582 | uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } | 619 | return rgb_matrix_config.hsv; |
| 583 | uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } | 620 | } |
| 584 | uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } | 621 | uint8_t rgb_matrix_get_hue(void) { |
| 622 | return rgb_matrix_config.hsv.h; | ||
| 623 | } | ||
| 624 | uint8_t rgb_matrix_get_sat(void) { | ||
| 625 | return rgb_matrix_config.hsv.s; | ||
| 626 | } | ||
| 627 | uint8_t rgb_matrix_get_val(void) { | ||
| 628 | return rgb_matrix_config.hsv.v; | ||
| 629 | } | ||
| 585 | 630 | ||
| 586 | void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } | 631 | void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { |
| 587 | void rgb_matrix_increase_hue_noeeprom(void) { rgb_matrix_increase_hue_helper(false); } | 632 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); |
| 588 | void rgb_matrix_increase_hue(void) { rgb_matrix_increase_hue_helper(true); } | 633 | } |
| 634 | void rgb_matrix_increase_hue_noeeprom(void) { | ||
| 635 | rgb_matrix_increase_hue_helper(false); | ||
| 636 | } | ||
| 637 | void rgb_matrix_increase_hue(void) { | ||
| 638 | rgb_matrix_increase_hue_helper(true); | ||
| 639 | } | ||
| 589 | 640 | ||
| 590 | void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } | 641 | void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { |
| 591 | void rgb_matrix_decrease_hue_noeeprom(void) { rgb_matrix_decrease_hue_helper(false); } | 642 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); |
| 592 | void rgb_matrix_decrease_hue(void) { rgb_matrix_decrease_hue_helper(true); } | 643 | } |
| 644 | void rgb_matrix_decrease_hue_noeeprom(void) { | ||
| 645 | rgb_matrix_decrease_hue_helper(false); | ||
| 646 | } | ||
| 647 | void rgb_matrix_decrease_hue(void) { | ||
| 648 | rgb_matrix_decrease_hue_helper(true); | ||
| 649 | } | ||
| 593 | 650 | ||
| 594 | void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } | 651 | void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { |
| 595 | void rgb_matrix_increase_sat_noeeprom(void) { rgb_matrix_increase_sat_helper(false); } | 652 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); |
| 596 | void rgb_matrix_increase_sat(void) { rgb_matrix_increase_sat_helper(true); } | 653 | } |
| 654 | void rgb_matrix_increase_sat_noeeprom(void) { | ||
| 655 | rgb_matrix_increase_sat_helper(false); | ||
| 656 | } | ||
| 657 | void rgb_matrix_increase_sat(void) { | ||
| 658 | rgb_matrix_increase_sat_helper(true); | ||
| 659 | } | ||
| 597 | 660 | ||
| 598 | void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } | 661 | void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { |
| 599 | void rgb_matrix_decrease_sat_noeeprom(void) { rgb_matrix_decrease_sat_helper(false); } | 662 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); |
| 600 | void rgb_matrix_decrease_sat(void) { rgb_matrix_decrease_sat_helper(true); } | 663 | } |
| 664 | void rgb_matrix_decrease_sat_noeeprom(void) { | ||
| 665 | rgb_matrix_decrease_sat_helper(false); | ||
| 666 | } | ||
| 667 | void rgb_matrix_decrease_sat(void) { | ||
| 668 | rgb_matrix_decrease_sat_helper(true); | ||
| 669 | } | ||
| 601 | 670 | ||
| 602 | void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } | 671 | void rgb_matrix_increase_val_helper(bool write_to_eeprom) { |
| 603 | void rgb_matrix_increase_val_noeeprom(void) { rgb_matrix_increase_val_helper(false); } | 672 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); |
| 604 | void rgb_matrix_increase_val(void) { rgb_matrix_increase_val_helper(true); } | 673 | } |
| 674 | void rgb_matrix_increase_val_noeeprom(void) { | ||
| 675 | rgb_matrix_increase_val_helper(false); | ||
| 676 | } | ||
| 677 | void rgb_matrix_increase_val(void) { | ||
| 678 | rgb_matrix_increase_val_helper(true); | ||
| 679 | } | ||
| 605 | 680 | ||
| 606 | void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } | 681 | void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { |
| 607 | void rgb_matrix_decrease_val_noeeprom(void) { rgb_matrix_decrease_val_helper(false); } | 682 | rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); |
| 608 | void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); } | 683 | } |
| 684 | void rgb_matrix_decrease_val_noeeprom(void) { | ||
| 685 | rgb_matrix_decrease_val_helper(false); | ||
| 686 | } | ||
| 687 | void rgb_matrix_decrease_val(void) { | ||
| 688 | rgb_matrix_decrease_val_helper(true); | ||
| 689 | } | ||
| 609 | 690 | ||
| 610 | void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | 691 | void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
| 611 | rgb_matrix_config.speed = speed; | 692 | rgb_matrix_config.speed = speed; |
| 612 | eeconfig_flag_rgb_matrix(write_to_eeprom); | 693 | eeconfig_flag_rgb_matrix(write_to_eeprom); |
| 613 | dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); | 694 | dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); |
| 614 | } | 695 | } |
| 615 | void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } | 696 | void rgb_matrix_set_speed_noeeprom(uint8_t speed) { |
| 616 | void rgb_matrix_set_speed(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, true); } | 697 | rgb_matrix_set_speed_eeprom_helper(speed, false); |
| 698 | } | ||
| 699 | void rgb_matrix_set_speed(uint8_t speed) { | ||
| 700 | rgb_matrix_set_speed_eeprom_helper(speed, true); | ||
| 701 | } | ||
| 617 | 702 | ||
| 618 | uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } | 703 | uint8_t rgb_matrix_get_speed(void) { |
| 704 | return rgb_matrix_config.speed; | ||
| 705 | } | ||
| 619 | 706 | ||
| 620 | void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } | 707 | void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { |
| 621 | void rgb_matrix_increase_speed_noeeprom(void) { rgb_matrix_increase_speed_helper(false); } | 708 | rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); |
| 622 | void rgb_matrix_increase_speed(void) { rgb_matrix_increase_speed_helper(true); } | 709 | } |
| 710 | void rgb_matrix_increase_speed_noeeprom(void) { | ||
| 711 | rgb_matrix_increase_speed_helper(false); | ||
| 712 | } | ||
| 713 | void rgb_matrix_increase_speed(void) { | ||
| 714 | rgb_matrix_increase_speed_helper(true); | ||
| 715 | } | ||
| 623 | 716 | ||
| 624 | void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } | 717 | void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { |
| 625 | void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } | 718 | rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); |
| 626 | void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } | 719 | } |
| 720 | void rgb_matrix_decrease_speed_noeeprom(void) { | ||
| 721 | rgb_matrix_decrease_speed_helper(false); | ||
| 722 | } | ||
| 723 | void rgb_matrix_decrease_speed(void) { | ||
| 724 | rgb_matrix_decrease_speed_helper(true); | ||
| 725 | } | ||
| 627 | 726 | ||
| 628 | led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; } | 727 | led_flags_t rgb_matrix_get_flags(void) { |
| 728 | return rgb_matrix_config.flags; | ||
| 729 | } | ||
| 629 | 730 | ||
| 630 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; } | 731 | void rgb_matrix_set_flags(led_flags_t flags) { |
| 732 | rgb_matrix_config.flags = flags; | ||
| 733 | } | ||
diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index df575d6577..d0ac4e4466 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | // Last led hit | 37 | // Last led hit |
| 38 | #ifndef LED_HITS_TO_REMEMBER | 38 | #ifndef LED_HITS_TO_REMEMBER |
| 39 | # define LED_HITS_TO_REMEMBER 8 | 39 | # define LED_HITS_TO_REMEMBER 8 |
| 40 | #endif // LED_HITS_TO_REMEMBER | 40 | #endif // LED_HITS_TO_REMEMBER |
| 41 | 41 | ||
| 42 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 42 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 43 | typedef struct PACKED { | 43 | typedef struct PACKED { |
| @@ -47,7 +47,7 @@ typedef struct PACKED { | |||
| 47 | uint8_t index[LED_HITS_TO_REMEMBER]; | 47 | uint8_t index[LED_HITS_TO_REMEMBER]; |
| 48 | uint16_t tick[LED_HITS_TO_REMEMBER]; | 48 | uint16_t tick[LED_HITS_TO_REMEMBER]; |
| 49 | } last_hit_t; | 49 | } last_hit_t; |
| 50 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 50 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 51 | 51 | ||
| 52 | typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; | 52 | typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; |
| 53 | 53 | ||
| @@ -88,7 +88,7 @@ typedef union { | |||
| 88 | uint8_t enable : 2; | 88 | uint8_t enable : 2; |
| 89 | uint8_t mode : 6; | 89 | uint8_t mode : 6; |
| 90 | HSV hsv; | 90 | HSV hsv; |
| 91 | uint8_t speed; // EECONFIG needs to be increased to support this | 91 | uint8_t speed; // EECONFIG needs to be increased to support this |
| 92 | led_flags_t flags; | 92 | led_flags_t flags; |
| 93 | }; | 93 | }; |
| 94 | } rgb_config_t; | 94 | } rgb_config_t; |
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 148dae78f4..8f933a6e51 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c | |||
| @@ -72,7 +72,7 @@ static uint8_t static_effect_table[] = { | |||
| 72 | #define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym, | 72 | #define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym, |
| 73 | #define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym, | 73 | #define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym, |
| 74 | static uint8_t mode_base_table[] = { | 74 | static uint8_t mode_base_table[] = { |
| 75 | 0, // RGBLIGHT_MODE_zero | 75 | 0, // RGBLIGHT_MODE_zero |
| 76 | #include "rgblight_modes.h" | 76 | #include "rgblight_modes.h" |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| @@ -96,7 +96,9 @@ static uint8_t mode_base_table[] = { | |||
| 96 | # define RGBLIGHT_DEFAULT_SPD 0 | 96 | # define RGBLIGHT_DEFAULT_SPD 0 |
| 97 | #endif | 97 | #endif |
| 98 | 98 | ||
| 99 | static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; } | 99 | static inline int is_static_effect(uint8_t mode) { |
| 100 | return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; | ||
| 101 | } | ||
| 100 | 102 | ||
| 101 | #ifdef RGBLIGHT_LED_MAP | 103 | #ifdef RGBLIGHT_LED_MAP |
| 102 | const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; | 104 | const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; |
| @@ -143,7 +145,9 @@ void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) { | |||
| 143 | rgblight_ranges.effect_num_leds = num_leds; | 145 | rgblight_ranges.effect_num_leds = num_leds; |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | __attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } | 148 | __attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { |
| 149 | return hsv_to_rgb(hsv); | ||
| 150 | } | ||
| 147 | 151 | ||
| 148 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | 152 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { |
| 149 | HSV hsv = {hue, sat, val}; | 153 | HSV hsv = {hue, sat, val}; |
| @@ -151,7 +155,9 @@ void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | |||
| 151 | setrgb(rgb.r, rgb.g, rgb.b, led1); | 155 | setrgb(rgb.r, rgb.g, rgb.b, led1); |
| 152 | } | 156 | } |
| 153 | 157 | ||
| 154 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); } | 158 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { |
| 159 | sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); | ||
| 160 | } | ||
| 155 | 161 | ||
| 156 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { | 162 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { |
| 157 | led1->r = r; | 163 | led1->r = r; |
| @@ -191,7 +197,9 @@ void eeconfig_update_rgblight(uint32_t val) { | |||
| 191 | #endif | 197 | #endif |
| 192 | } | 198 | } |
| 193 | 199 | ||
| 194 | void eeconfig_update_rgblight_current(void) { eeconfig_update_rgblight(rgblight_config.raw); } | 200 | void eeconfig_update_rgblight_current(void) { |
| 201 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 202 | } | ||
| 195 | 203 | ||
| 196 | void eeconfig_update_rgblight_default(void) { | 204 | void eeconfig_update_rgblight_default(void) { |
| 197 | rgblight_config.enable = 1; | 205 | rgblight_config.enable = 1; |
| @@ -238,9 +246,9 @@ void rgblight_init(void) { | |||
| 238 | } | 246 | } |
| 239 | rgblight_check_config(); | 247 | rgblight_check_config(); |
| 240 | 248 | ||
| 241 | eeconfig_debug_rgblight(); // display current eeprom values | 249 | eeconfig_debug_rgblight(); // display current eeprom values |
| 242 | 250 | ||
| 243 | rgblight_timer_init(); // setup the timer | 251 | rgblight_timer_init(); // setup the timer |
| 244 | 252 | ||
| 245 | if (rgblight_config.enable) { | 253 | if (rgblight_config.enable) { |
| 246 | rgblight_mode_noeeprom(rgblight_config.mode); | 254 | rgblight_mode_noeeprom(rgblight_config.mode); |
| @@ -254,13 +262,15 @@ void rgblight_reload_from_eeprom(void) { | |||
| 254 | rgblight_config.raw = eeconfig_read_rgblight(); | 262 | rgblight_config.raw = eeconfig_read_rgblight(); |
| 255 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; | 263 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; |
| 256 | rgblight_check_config(); | 264 | rgblight_check_config(); |
| 257 | eeconfig_debug_rgblight(); // display current eeprom values | 265 | eeconfig_debug_rgblight(); // display current eeprom values |
| 258 | if (rgblight_config.enable) { | 266 | if (rgblight_config.enable) { |
| 259 | rgblight_mode_noeeprom(rgblight_config.mode); | 267 | rgblight_mode_noeeprom(rgblight_config.mode); |
| 260 | } | 268 | } |
| 261 | } | 269 | } |
| 262 | 270 | ||
| 263 | uint32_t rgblight_read_dword(void) { return rgblight_config.raw; } | 271 | uint32_t rgblight_read_dword(void) { |
| 272 | return rgblight_config.raw; | ||
| 273 | } | ||
| 264 | 274 | ||
| 265 | void rgblight_update_dword(uint32_t dword) { | 275 | void rgblight_update_dword(uint32_t dword) { |
| 266 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; | 276 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; |
| @@ -296,8 +306,12 @@ void rgblight_step_helper(bool write_to_eeprom) { | |||
| 296 | } | 306 | } |
| 297 | rgblight_mode_eeprom_helper(mode, write_to_eeprom); | 307 | rgblight_mode_eeprom_helper(mode, write_to_eeprom); |
| 298 | } | 308 | } |
| 299 | void rgblight_step_noeeprom(void) { rgblight_step_helper(false); } | 309 | void rgblight_step_noeeprom(void) { |
| 300 | void rgblight_step(void) { rgblight_step_helper(true); } | 310 | rgblight_step_helper(false); |
| 311 | } | ||
| 312 | void rgblight_step(void) { | ||
| 313 | rgblight_step_helper(true); | ||
| 314 | } | ||
| 301 | void rgblight_step_reverse_helper(bool write_to_eeprom) { | 315 | void rgblight_step_reverse_helper(bool write_to_eeprom) { |
| 302 | uint8_t mode = 0; | 316 | uint8_t mode = 0; |
| 303 | mode = rgblight_config.mode - 1; | 317 | mode = rgblight_config.mode - 1; |
| @@ -306,8 +320,12 @@ void rgblight_step_reverse_helper(bool write_to_eeprom) { | |||
| 306 | } | 320 | } |
| 307 | rgblight_mode_eeprom_helper(mode, write_to_eeprom); | 321 | rgblight_mode_eeprom_helper(mode, write_to_eeprom); |
| 308 | } | 322 | } |
| 309 | void rgblight_step_reverse_noeeprom(void) { rgblight_step_reverse_helper(false); } | 323 | void rgblight_step_reverse_noeeprom(void) { |
| 310 | void rgblight_step_reverse(void) { rgblight_step_reverse_helper(true); } | 324 | rgblight_step_reverse_helper(false); |
| 325 | } | ||
| 326 | void rgblight_step_reverse(void) { | ||
| 327 | rgblight_step_reverse_helper(true); | ||
| 328 | } | ||
| 311 | 329 | ||
| 312 | uint8_t rgblight_get_mode(void) { | 330 | uint8_t rgblight_get_mode(void) { |
| 313 | if (!rgblight_config.enable) { | 331 | if (!rgblight_config.enable) { |
| @@ -346,9 +364,13 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 346 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 364 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 347 | } | 365 | } |
| 348 | 366 | ||
| 349 | void rgblight_mode(uint8_t mode) { rgblight_mode_eeprom_helper(mode, true); } | 367 | void rgblight_mode(uint8_t mode) { |
| 368 | rgblight_mode_eeprom_helper(mode, true); | ||
| 369 | } | ||
| 350 | 370 | ||
| 351 | void rgblight_mode_noeeprom(uint8_t mode) { rgblight_mode_eeprom_helper(mode, false); } | 371 | void rgblight_mode_noeeprom(uint8_t mode) { |
| 372 | rgblight_mode_eeprom_helper(mode, false); | ||
| 373 | } | ||
| 352 | 374 | ||
| 353 | void rgblight_toggle(void) { | 375 | void rgblight_toggle(void) { |
| 354 | dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); | 376 | dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); |
| @@ -401,64 +423,98 @@ void rgblight_disable_noeeprom(void) { | |||
| 401 | rgblight_set(); | 423 | rgblight_set(); |
| 402 | } | 424 | } |
| 403 | 425 | ||
| 404 | bool rgblight_is_enabled(void) { return rgblight_config.enable; } | 426 | bool rgblight_is_enabled(void) { |
| 427 | return rgblight_config.enable; | ||
| 428 | } | ||
| 405 | 429 | ||
| 406 | void rgblight_increase_hue_helper(bool write_to_eeprom) { | 430 | void rgblight_increase_hue_helper(bool write_to_eeprom) { |
| 407 | uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; | 431 | uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; |
| 408 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); | 432 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); |
| 409 | } | 433 | } |
| 410 | void rgblight_increase_hue_noeeprom(void) { rgblight_increase_hue_helper(false); } | 434 | void rgblight_increase_hue_noeeprom(void) { |
| 411 | void rgblight_increase_hue(void) { rgblight_increase_hue_helper(true); } | 435 | rgblight_increase_hue_helper(false); |
| 436 | } | ||
| 437 | void rgblight_increase_hue(void) { | ||
| 438 | rgblight_increase_hue_helper(true); | ||
| 439 | } | ||
| 412 | void rgblight_decrease_hue_helper(bool write_to_eeprom) { | 440 | void rgblight_decrease_hue_helper(bool write_to_eeprom) { |
| 413 | uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP; | 441 | uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP; |
| 414 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); | 442 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); |
| 415 | } | 443 | } |
| 416 | void rgblight_decrease_hue_noeeprom(void) { rgblight_decrease_hue_helper(false); } | 444 | void rgblight_decrease_hue_noeeprom(void) { |
| 417 | void rgblight_decrease_hue(void) { rgblight_decrease_hue_helper(true); } | 445 | rgblight_decrease_hue_helper(false); |
| 446 | } | ||
| 447 | void rgblight_decrease_hue(void) { | ||
| 448 | rgblight_decrease_hue_helper(true); | ||
| 449 | } | ||
| 418 | void rgblight_increase_sat_helper(bool write_to_eeprom) { | 450 | void rgblight_increase_sat_helper(bool write_to_eeprom) { |
| 419 | uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP); | 451 | uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP); |
| 420 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); | 452 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); |
| 421 | } | 453 | } |
| 422 | void rgblight_increase_sat_noeeprom(void) { rgblight_increase_sat_helper(false); } | 454 | void rgblight_increase_sat_noeeprom(void) { |
| 423 | void rgblight_increase_sat(void) { rgblight_increase_sat_helper(true); } | 455 | rgblight_increase_sat_helper(false); |
| 456 | } | ||
| 457 | void rgblight_increase_sat(void) { | ||
| 458 | rgblight_increase_sat_helper(true); | ||
| 459 | } | ||
| 424 | void rgblight_decrease_sat_helper(bool write_to_eeprom) { | 460 | void rgblight_decrease_sat_helper(bool write_to_eeprom) { |
| 425 | uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP); | 461 | uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP); |
| 426 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); | 462 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); |
| 427 | } | 463 | } |
| 428 | void rgblight_decrease_sat_noeeprom(void) { rgblight_decrease_sat_helper(false); } | 464 | void rgblight_decrease_sat_noeeprom(void) { |
| 429 | void rgblight_decrease_sat(void) { rgblight_decrease_sat_helper(true); } | 465 | rgblight_decrease_sat_helper(false); |
| 466 | } | ||
| 467 | void rgblight_decrease_sat(void) { | ||
| 468 | rgblight_decrease_sat_helper(true); | ||
| 469 | } | ||
| 430 | void rgblight_increase_val_helper(bool write_to_eeprom) { | 470 | void rgblight_increase_val_helper(bool write_to_eeprom) { |
| 431 | uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP); | 471 | uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP); |
| 432 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); | 472 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); |
| 433 | } | 473 | } |
| 434 | void rgblight_increase_val_noeeprom(void) { rgblight_increase_val_helper(false); } | 474 | void rgblight_increase_val_noeeprom(void) { |
| 435 | void rgblight_increase_val(void) { rgblight_increase_val_helper(true); } | 475 | rgblight_increase_val_helper(false); |
| 476 | } | ||
| 477 | void rgblight_increase_val(void) { | ||
| 478 | rgblight_increase_val_helper(true); | ||
| 479 | } | ||
| 436 | void rgblight_decrease_val_helper(bool write_to_eeprom) { | 480 | void rgblight_decrease_val_helper(bool write_to_eeprom) { |
| 437 | uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP); | 481 | uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP); |
| 438 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); | 482 | rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); |
| 439 | } | 483 | } |
| 440 | void rgblight_decrease_val_noeeprom(void) { rgblight_decrease_val_helper(false); } | 484 | void rgblight_decrease_val_noeeprom(void) { |
| 441 | void rgblight_decrease_val(void) { rgblight_decrease_val_helper(true); } | 485 | rgblight_decrease_val_helper(false); |
| 486 | } | ||
| 487 | void rgblight_decrease_val(void) { | ||
| 488 | rgblight_decrease_val_helper(true); | ||
| 489 | } | ||
| 442 | 490 | ||
| 443 | void rgblight_increase_speed_helper(bool write_to_eeprom) { | 491 | void rgblight_increase_speed_helper(bool write_to_eeprom) { |
| 444 | if (rgblight_config.speed < 3) rgblight_config.speed++; | 492 | if (rgblight_config.speed < 3) rgblight_config.speed++; |
| 445 | // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? | 493 | // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? |
| 446 | if (write_to_eeprom) { | 494 | if (write_to_eeprom) { |
| 447 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this | 495 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this |
| 448 | } | 496 | } |
| 449 | } | 497 | } |
| 450 | void rgblight_increase_speed(void) { rgblight_increase_speed_helper(true); } | 498 | void rgblight_increase_speed(void) { |
| 451 | void rgblight_increase_speed_noeeprom(void) { rgblight_increase_speed_helper(false); } | 499 | rgblight_increase_speed_helper(true); |
| 500 | } | ||
| 501 | void rgblight_increase_speed_noeeprom(void) { | ||
| 502 | rgblight_increase_speed_helper(false); | ||
| 503 | } | ||
| 452 | 504 | ||
| 453 | void rgblight_decrease_speed_helper(bool write_to_eeprom) { | 505 | void rgblight_decrease_speed_helper(bool write_to_eeprom) { |
| 454 | if (rgblight_config.speed > 0) rgblight_config.speed--; | 506 | if (rgblight_config.speed > 0) rgblight_config.speed--; |
| 455 | // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? | 507 | // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? |
| 456 | if (write_to_eeprom) { | 508 | if (write_to_eeprom) { |
| 457 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this | 509 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this |
| 458 | } | 510 | } |
| 459 | } | 511 | } |
| 460 | void rgblight_decrease_speed(void) { rgblight_decrease_speed_helper(true); } | 512 | void rgblight_decrease_speed(void) { |
| 461 | void rgblight_decrease_speed_noeeprom(void) { rgblight_decrease_speed_helper(false); } | 513 | rgblight_decrease_speed_helper(true); |
| 514 | } | ||
| 515 | void rgblight_decrease_speed_noeeprom(void) { | ||
| 516 | rgblight_decrease_speed_helper(false); | ||
| 517 | } | ||
| 462 | 518 | ||
| 463 | void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { | 519 | void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { |
| 464 | if (rgblight_config.enable) { | 520 | if (rgblight_config.enable) { |
| @@ -478,7 +534,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w | |||
| 478 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); | 534 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); |
| 479 | } else { | 535 | } else { |
| 480 | // all LEDs in same color | 536 | // all LEDs in same color |
| 481 | if (1 == 0) { // dummy | 537 | if (1 == 0) { // dummy |
| 482 | } | 538 | } |
| 483 | #ifdef RGBLIGHT_EFFECT_BREATHING | 539 | #ifdef RGBLIGHT_EFFECT_BREATHING |
| 484 | else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { | 540 | else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { |
| @@ -540,33 +596,51 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w | |||
| 540 | } | 596 | } |
| 541 | } | 597 | } |
| 542 | 598 | ||
| 543 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, true); } | 599 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { |
| 600 | rgblight_sethsv_eeprom_helper(hue, sat, val, true); | ||
| 601 | } | ||
| 544 | 602 | ||
| 545 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); } | 603 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { |
| 604 | rgblight_sethsv_eeprom_helper(hue, sat, val, false); | ||
| 605 | } | ||
| 546 | 606 | ||
| 547 | uint8_t rgblight_get_speed(void) { return rgblight_config.speed; } | 607 | uint8_t rgblight_get_speed(void) { |
| 608 | return rgblight_config.speed; | ||
| 609 | } | ||
| 548 | 610 | ||
| 549 | void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | 611 | void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
| 550 | rgblight_config.speed = speed; | 612 | rgblight_config.speed = speed; |
| 551 | if (write_to_eeprom) { | 613 | if (write_to_eeprom) { |
| 552 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this | 614 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this |
| 553 | dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); | 615 | dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); |
| 554 | } else { | 616 | } else { |
| 555 | dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); | 617 | dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); |
| 556 | } | 618 | } |
| 557 | } | 619 | } |
| 558 | 620 | ||
| 559 | void rgblight_set_speed(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, true); } | 621 | void rgblight_set_speed(uint8_t speed) { |
| 622 | rgblight_set_speed_eeprom_helper(speed, true); | ||
| 623 | } | ||
| 560 | 624 | ||
| 561 | void rgblight_set_speed_noeeprom(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, false); } | 625 | void rgblight_set_speed_noeeprom(uint8_t speed) { |
| 626 | rgblight_set_speed_eeprom_helper(speed, false); | ||
| 627 | } | ||
| 562 | 628 | ||
| 563 | uint8_t rgblight_get_hue(void) { return rgblight_config.hue; } | 629 | uint8_t rgblight_get_hue(void) { |
| 630 | return rgblight_config.hue; | ||
| 631 | } | ||
| 564 | 632 | ||
| 565 | uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } | 633 | uint8_t rgblight_get_sat(void) { |
| 634 | return rgblight_config.sat; | ||
| 635 | } | ||
| 566 | 636 | ||
| 567 | uint8_t rgblight_get_val(void) { return rgblight_config.val; } | 637 | uint8_t rgblight_get_val(void) { |
| 638 | return rgblight_config.val; | ||
| 639 | } | ||
| 568 | 640 | ||
| 569 | HSV rgblight_get_hsv(void) { return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; } | 641 | HSV rgblight_get_hsv(void) { |
| 642 | return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; | ||
| 643 | } | ||
| 570 | 644 | ||
| 571 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | 645 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { |
| 572 | if (!rgblight_config.enable) { | 646 | if (!rgblight_config.enable) { |
| @@ -648,14 +722,22 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, | |||
| 648 | } | 722 | } |
| 649 | 723 | ||
| 650 | #ifndef RGBLIGHT_SPLIT | 724 | #ifndef RGBLIGHT_SPLIT |
| 651 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2); } | 725 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { |
| 726 | rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2); | ||
| 727 | } | ||
| 652 | 728 | ||
| 653 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); } | 729 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { |
| 730 | rgblight_setrgb_range(r, g, b, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); | ||
| 731 | } | ||
| 654 | 732 | ||
| 655 | void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2); } | 733 | void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { |
| 734 | rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2); | ||
| 735 | } | ||
| 656 | 736 | ||
| 657 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); } | 737 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { |
| 658 | #endif // ifndef RGBLIGHT_SPLIT | 738 | rgblight_sethsv_range(hue, sat, val, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); |
| 739 | } | ||
| 740 | #endif // ifndef RGBLIGHT_SPLIT | ||
| 659 | 741 | ||
| 660 | #ifdef RGBLIGHT_LAYERS | 742 | #ifdef RGBLIGHT_LAYERS |
| 661 | void rgblight_set_layer_state(uint8_t layer, bool enabled) { | 743 | void rgblight_set_layer_state(uint8_t layer, bool enabled) { |
| @@ -693,18 +775,18 @@ static void rgblight_layers_write(void) { | |||
| 693 | // For each layer | 775 | // For each layer |
| 694 | for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { | 776 | for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { |
| 695 | if (!rgblight_get_layer_state(i)) { | 777 | if (!rgblight_get_layer_state(i)) { |
| 696 | continue; // Layer is disabled | 778 | continue; // Layer is disabled |
| 697 | } | 779 | } |
| 698 | const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr); | 780 | const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr); |
| 699 | if (segment_ptr == NULL) { | 781 | if (segment_ptr == NULL) { |
| 700 | break; // No more layers | 782 | break; // No more layers |
| 701 | } | 783 | } |
| 702 | // For each segment | 784 | // For each segment |
| 703 | while (1) { | 785 | while (1) { |
| 704 | rgblight_segment_t segment; | 786 | rgblight_segment_t segment; |
| 705 | memcpy_P(&segment, segment_ptr, sizeof(rgblight_segment_t)); | 787 | memcpy_P(&segment, segment_ptr, sizeof(rgblight_segment_t)); |
| 706 | if (segment.index == RGBLIGHT_END_SEGMENT_INDEX) { | 788 | if (segment.index == RGBLIGHT_END_SEGMENT_INDEX) { |
| 707 | break; // No more segments | 789 | break; // No more segments |
| 708 | } | 790 | } |
| 709 | // Write segment.count LEDs | 791 | // Write segment.count LEDs |
| 710 | LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; | 792 | LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; |
| @@ -726,7 +808,9 @@ static uint16_t _repeat_timer; | |||
| 726 | static uint8_t _times_remaining; | 808 | static uint8_t _times_remaining; |
| 727 | static uint16_t _dur; | 809 | static uint16_t _dur; |
| 728 | 810 | ||
| 729 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { rgblight_blink_layer_repeat(layer, duration_ms, 1); } | 811 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { |
| 812 | rgblight_blink_layer_repeat(layer, duration_ms, 1); | ||
| 813 | } | ||
| 730 | 814 | ||
| 731 | void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) { | 815 | void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) { |
| 732 | _times_remaining = times * 2; | 816 | _times_remaining = times * 2; |
| @@ -796,7 +880,9 @@ void rgblight_wakeup(void) { | |||
| 796 | 880 | ||
| 797 | #endif | 881 | #endif |
| 798 | 882 | ||
| 799 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } | 883 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { |
| 884 | ws2812_setleds(start_led, num_leds); | ||
| 885 | } | ||
| 800 | 886 | ||
| 801 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 887 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 802 | 888 | ||
| @@ -848,9 +934,13 @@ void rgblight_set(void) { | |||
| 848 | 934 | ||
| 849 | #ifdef RGBLIGHT_SPLIT | 935 | #ifdef RGBLIGHT_SPLIT |
| 850 | /* for split keyboard master side */ | 936 | /* for split keyboard master side */ |
| 851 | uint8_t rgblight_get_change_flags(void) { return rgblight_status.change_flags; } | 937 | uint8_t rgblight_get_change_flags(void) { |
| 938 | return rgblight_status.change_flags; | ||
| 939 | } | ||
| 852 | 940 | ||
| 853 | void rgblight_clear_change_flags(void) { rgblight_status.change_flags = 0; } | 941 | void rgblight_clear_change_flags(void) { |
| 942 | rgblight_status.change_flags = 0; | ||
| 943 | } | ||
| 854 | 944 | ||
| 855 | void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) { | 945 | void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) { |
| 856 | syncinfo->config = rgblight_config; | 946 | syncinfo->config = rgblight_config; |
| @@ -866,7 +956,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) { | |||
| 866 | # endif | 956 | # endif |
| 867 | if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) { | 957 | if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) { |
| 868 | if (syncinfo->config.enable) { | 958 | if (syncinfo->config.enable) { |
| 869 | rgblight_config.enable = 1; // == rgblight_enable_noeeprom(); | 959 | rgblight_config.enable = 1; // == rgblight_enable_noeeprom(); |
| 870 | rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom); | 960 | rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom); |
| 871 | } else { | 961 | } else { |
| 872 | rgblight_disable_noeeprom(); | 962 | rgblight_disable_noeeprom(); |
| @@ -945,12 +1035,12 @@ static void rgblight_effect_dummy(animation_status_t *anim) { | |||
| 945 | void rgblight_task(void) { | 1035 | void rgblight_task(void) { |
| 946 | if (rgblight_status.timer_enabled) { | 1036 | if (rgblight_status.timer_enabled) { |
| 947 | effect_func_t effect_func = rgblight_effect_dummy; | 1037 | effect_func_t effect_func = rgblight_effect_dummy; |
| 948 | uint16_t interval_time = 2000; // dummy interval | 1038 | uint16_t interval_time = 2000; // dummy interval |
| 949 | uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; | 1039 | uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; |
| 950 | animation_status.delta = delta; | 1040 | animation_status.delta = delta; |
| 951 | 1041 | ||
| 952 | // static light mode, do nothing here | 1042 | // static light mode, do nothing here |
| 953 | if (1 == 0) { // dummy | 1043 | if (1 == 0) { // dummy |
| 954 | } | 1044 | } |
| 955 | # ifdef RGBLIGHT_EFFECT_BREATHING | 1045 | # ifdef RGBLIGHT_EFFECT_BREATHING |
| 956 | else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { | 1046 | else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { |
| @@ -1016,7 +1106,7 @@ void rgblight_task(void) { | |||
| 1016 | if (animation_status.restart) { | 1106 | if (animation_status.restart) { |
| 1017 | animation_status.restart = false; | 1107 | animation_status.restart = false; |
| 1018 | animation_status.last_timer = sync_timer_read(); | 1108 | animation_status.last_timer = sync_timer_read(); |
| 1019 | animation_status.pos16 = 0; // restart signal to local each effect | 1109 | animation_status.pos16 = 0; // restart signal to local each effect |
| 1020 | } | 1110 | } |
| 1021 | uint16_t now = sync_timer_read(); | 1111 | uint16_t now = sync_timer_read(); |
| 1022 | if (timer_expired(now, animation_status.last_timer)) { | 1112 | if (timer_expired(now, animation_status.last_timer)) { |
| @@ -1055,7 +1145,7 @@ void rgblight_task(void) { | |||
| 1055 | 1145 | ||
| 1056 | # ifndef RGBLIGHT_EFFECT_BREATHE_CENTER | 1146 | # ifndef RGBLIGHT_EFFECT_BREATHE_CENTER |
| 1057 | # ifndef RGBLIGHT_BREATHE_TABLE_SIZE | 1147 | # ifndef RGBLIGHT_BREATHE_TABLE_SIZE |
| 1058 | # define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64 | 1148 | # define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64 |
| 1059 | # endif | 1149 | # endif |
| 1060 | # include <rgblight_breathe_table.h> | 1150 | # include <rgblight_breathe_table.h> |
| 1061 | # endif | 1151 | # endif |
| @@ -1131,7 +1221,7 @@ void rgblight_effect_snake(animation_status_t *anim) { | |||
| 1131 | } | 1221 | } |
| 1132 | 1222 | ||
| 1133 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 1223 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 1134 | if (anim->pos == 0) { // restart signal | 1224 | if (anim->pos == 0) { // restart signal |
| 1135 | if (increment == 1) { | 1225 | if (increment == 1) { |
| 1136 | pos = rgblight_ranges.effect_num_leds - 1; | 1226 | pos = rgblight_ranges.effect_num_leds - 1; |
| 1137 | } else { | 1227 | } else { |
| @@ -1194,7 +1284,7 @@ void rgblight_effect_knight(animation_status_t *anim) { | |||
| 1194 | uint8_t i, cur; | 1284 | uint8_t i, cur; |
| 1195 | 1285 | ||
| 1196 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 1286 | # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 1197 | if (anim->pos == 0) { // restart signal | 1287 | if (anim->pos == 0) { // restart signal |
| 1198 | anim->pos = 1; | 1288 | anim->pos = 1; |
| 1199 | low_bound = 0; | 1289 | low_bound = 0; |
| 1200 | high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; | 1290 | high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; |
| @@ -1347,8 +1437,12 @@ void rgblight_effect_twinkle(animation_status_t *anim) { | |||
| 1347 | const uint8_t bottom = breathe_calc(0); | 1437 | const uint8_t bottom = breathe_calc(0); |
| 1348 | const uint8_t top = breathe_calc(127); | 1438 | const uint8_t top = breathe_calc(127); |
| 1349 | 1439 | ||
| 1350 | uint8_t frac(uint8_t n, uint8_t d) { return (uint16_t)255 * n / d; } | 1440 | uint8_t frac(uint8_t n, uint8_t d) { |
| 1351 | uint8_t scale(uint16_t v, uint8_t scale) { return (v * scale) >> 8; } | 1441 | return (uint16_t)255 * n / d; |
| 1442 | } | ||
| 1443 | uint8_t scale(uint16_t v, uint8_t scale) { | ||
| 1444 | return (v * scale) >> 8; | ||
| 1445 | } | ||
| 1352 | 1446 | ||
| 1353 | for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { | 1447 | for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { |
| 1354 | TwinkleState *t = &(led_twinkle_state[i]); | 1448 | TwinkleState *t = &(led_twinkle_state[i]); |
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index 5b90b8f49e..7076dc41ac 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h | |||
| @@ -119,7 +119,7 @@ enum RGBLIGHT_EFFECT_MODE { | |||
| 119 | // sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 | 119 | // sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 |
| 120 | 120 | ||
| 121 | #ifndef RGBLIGHT_EFFECT_BREATHE_MAX | 121 | #ifndef RGBLIGHT_EFFECT_BREATHE_MAX |
| 122 | # define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 | 122 | # define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 |
| 123 | #endif | 123 | #endif |
| 124 | 124 | ||
| 125 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | 125 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH |
| @@ -177,8 +177,8 @@ enum RGBLIGHT_EFFECT_MODE { | |||
| 177 | 177 | ||
| 178 | #ifdef RGBLIGHT_LAYERS | 178 | #ifdef RGBLIGHT_LAYERS |
| 179 | typedef struct { | 179 | typedef struct { |
| 180 | uint8_t index; // The first LED to light | 180 | uint8_t index; // The first LED to light |
| 181 | uint8_t count; // The number of LEDs to light | 181 | uint8_t count; // The number of LEDs to light |
| 182 | uint8_t hue; | 182 | uint8_t hue; |
| 183 | uint8_t sat; | 183 | uint8_t sat; |
| 184 | uint8_t val; | 184 | uint8_t val; |
| @@ -241,7 +241,7 @@ typedef union { | |||
| 241 | uint8_t hue : 8; | 241 | uint8_t hue : 8; |
| 242 | uint8_t sat : 8; | 242 | uint8_t sat : 8; |
| 243 | uint8_t val : 8; | 243 | uint8_t val : 8; |
| 244 | uint8_t speed : 8; // EECONFIG needs to be increased to support this | 244 | uint8_t speed : 8; // EECONFIG needs to be increased to support this |
| 245 | }; | 245 | }; |
| 246 | } rgblight_config_t; | 246 | } rgblight_config_t; |
| 247 | 247 | ||
| @@ -271,7 +271,7 @@ extern rgblight_ranges_t rgblight_ranges; | |||
| 271 | 271 | ||
| 272 | /* === Utility Functions ===*/ | 272 | /* === Utility Functions ===*/ |
| 273 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); | 273 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); |
| 274 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check | 274 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check |
| 275 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); | 275 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); |
| 276 | 276 | ||
| 277 | /* === Low level Functions === */ | 277 | /* === Low level Functions === */ |
diff --git a/quantum/ring_buffer.h b/quantum/ring_buffer.h index 284745ca8e..85419de11b 100644 --- a/quantum/ring_buffer.h +++ b/quantum/ring_buffer.h | |||
| @@ -36,9 +36,13 @@ static inline uint8_t rbuf_dequeue(void) { | |||
| 36 | } | 36 | } |
| 37 | static inline bool rbuf_has_data(void) { | 37 | static inline bool rbuf_has_data(void) { |
| 38 | bool has_data; | 38 | bool has_data; |
| 39 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { has_data = (rbuf_head != rbuf_tail); } | 39 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 40 | has_data = (rbuf_head != rbuf_tail); | ||
| 41 | } | ||
| 40 | return has_data; | 42 | return has_data; |
| 41 | } | 43 | } |
| 42 | static inline void rbuf_clear(void) { | 44 | static inline void rbuf_clear(void) { |
| 43 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { rbuf_head = rbuf_tail = 0; } | 45 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 46 | rbuf_head = rbuf_tail = 0; | ||
| 47 | } | ||
| 44 | } | 48 | } |
diff --git a/quantum/send_string.c b/quantum/send_string.c index 1a7f7a1315..0de12ba12d 100644 --- a/quantum/send_string.c +++ b/quantum/send_string.c | |||
| @@ -142,9 +142,13 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { | |||
| 142 | // Note: we bit-pack in "reverse" order to optimize loading | 142 | // Note: we bit-pack in "reverse" order to optimize loading |
| 143 | #define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01) | 143 | #define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01) |
| 144 | 144 | ||
| 145 | void send_string(const char *str) { send_string_with_delay(str, 0); } | 145 | void send_string(const char *str) { |
| 146 | send_string_with_delay(str, 0); | ||
| 147 | } | ||
| 146 | 148 | ||
| 147 | void send_string_P(const char *str) { send_string_with_delay_P(str, 0); } | 149 | void send_string_P(const char *str) { |
| 150 | send_string_with_delay_P(str, 0); | ||
| 151 | } | ||
| 148 | 152 | ||
| 149 | void send_string_with_delay(const char *str, uint8_t interval) { | 153 | void send_string_with_delay(const char *str, uint8_t interval) { |
| 150 | while (1) { | 154 | while (1) { |
| @@ -173,7 +177,8 @@ void send_string_with_delay(const char *str, uint8_t interval) { | |||
| 173 | ms += keycode - '0'; | 177 | ms += keycode - '0'; |
| 174 | keycode = *(++str); | 178 | keycode = *(++str); |
| 175 | } | 179 | } |
| 176 | while (ms--) wait_ms(1); | 180 | while (ms--) |
| 181 | wait_ms(1); | ||
| 177 | } | 182 | } |
| 178 | } else { | 183 | } else { |
| 179 | send_char(ascii_code); | 184 | send_char(ascii_code); |
| @@ -182,7 +187,8 @@ void send_string_with_delay(const char *str, uint8_t interval) { | |||
| 182 | // interval | 187 | // interval |
| 183 | { | 188 | { |
| 184 | uint8_t ms = interval; | 189 | uint8_t ms = interval; |
| 185 | while (ms--) wait_ms(1); | 190 | while (ms--) |
| 191 | wait_ms(1); | ||
| 186 | } | 192 | } |
| 187 | } | 193 | } |
| 188 | } | 194 | } |
| @@ -214,7 +220,8 @@ void send_string_with_delay_P(const char *str, uint8_t interval) { | |||
| 214 | ms += keycode - '0'; | 220 | ms += keycode - '0'; |
| 215 | keycode = pgm_read_byte(++str); | 221 | keycode = pgm_read_byte(++str); |
| 216 | } | 222 | } |
| 217 | while (ms--) wait_ms(1); | 223 | while (ms--) |
| 224 | wait_ms(1); | ||
| 218 | } | 225 | } |
| 219 | } else { | 226 | } else { |
| 220 | send_char(ascii_code); | 227 | send_char(ascii_code); |
| @@ -223,14 +230,15 @@ void send_string_with_delay_P(const char *str, uint8_t interval) { | |||
| 223 | // interval | 230 | // interval |
| 224 | { | 231 | { |
| 225 | uint8_t ms = interval; | 232 | uint8_t ms = interval; |
| 226 | while (ms--) wait_ms(1); | 233 | while (ms--) |
| 234 | wait_ms(1); | ||
| 227 | } | 235 | } |
| 228 | } | 236 | } |
| 229 | } | 237 | } |
| 230 | 238 | ||
| 231 | void send_char(char ascii_code) { | 239 | void send_char(char ascii_code) { |
| 232 | #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) | 240 | #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) |
| 233 | if (ascii_code == '\a') { // BEL | 241 | if (ascii_code == '\a') { // BEL |
| 234 | PLAY_SONG(bell_song); | 242 | PLAY_SONG(bell_song); |
| 235 | return; | 243 | return; |
| 236 | } | 244 | } |
diff --git a/quantum/sequencer/sequencer.c b/quantum/sequencer/sequencer.c index 18a83661ec..2e92f7b3eb 100644 --- a/quantum/sequencer/sequencer.c +++ b/quantum/sequencer/sequencer.c | |||
| @@ -25,16 +25,18 @@ | |||
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | sequencer_config_t sequencer_config = { | 27 | sequencer_config_t sequencer_config = { |
| 28 | false, // enabled | 28 | false, // enabled |
| 29 | {false}, // steps | 29 | {false}, // steps |
| 30 | {0}, // track notes | 30 | {0}, // track notes |
| 31 | 60, // tempo | 31 | 60, // tempo |
| 32 | SQ_RES_4, // resolution | 32 | SQ_RES_4, // resolution |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | sequencer_state_t sequencer_internal_state = {0, 0, 0, 0, SEQUENCER_PHASE_ATTACK}; | 35 | sequencer_state_t sequencer_internal_state = {0, 0, 0, 0, SEQUENCER_PHASE_ATTACK}; |
| 36 | 36 | ||
| 37 | bool is_sequencer_on(void) { return sequencer_config.enabled; } | 37 | bool is_sequencer_on(void) { |
| 38 | return sequencer_config.enabled; | ||
| 39 | } | ||
| 38 | 40 | ||
| 39 | void sequencer_on(void) { | 41 | void sequencer_on(void) { |
| 40 | dprintln("sequencer on"); | 42 | dprintln("sequencer on"); |
| @@ -65,7 +67,9 @@ void sequencer_set_track_notes(const uint16_t track_notes[SEQUENCER_TRACKS]) { | |||
| 65 | } | 67 | } |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | bool is_sequencer_track_active(uint8_t track) { return (sequencer_internal_state.active_tracks >> track) & true; } | 70 | bool is_sequencer_track_active(uint8_t track) { |
| 71 | return (sequencer_internal_state.active_tracks >> track) & true; | ||
| 72 | } | ||
| 69 | 73 | ||
| 70 | void sequencer_set_track_activation(uint8_t track, bool value) { | 74 | void sequencer_set_track_activation(uint8_t track, bool value) { |
| 71 | if (value) { | 75 | if (value) { |
| @@ -76,7 +80,9 @@ void sequencer_set_track_activation(uint8_t track, bool value) { | |||
| 76 | dprintf("sequencer: track %d is %s\n", track, value ? "active" : "inactive"); | 80 | dprintf("sequencer: track %d is %s\n", track, value ? "active" : "inactive"); |
| 77 | } | 81 | } |
| 78 | 82 | ||
| 79 | void sequencer_toggle_track_activation(uint8_t track) { sequencer_set_track_activation(track, !is_sequencer_track_active(track)); } | 83 | void sequencer_toggle_track_activation(uint8_t track) { |
| 84 | sequencer_set_track_activation(track, !is_sequencer_track_active(track)); | ||
| 85 | } | ||
| 80 | 86 | ||
| 81 | void sequencer_toggle_single_active_track(uint8_t track) { | 87 | void sequencer_toggle_single_active_track(uint8_t track) { |
| 82 | if (is_sequencer_track_active(track)) { | 88 | if (is_sequencer_track_active(track)) { |
| @@ -86,9 +92,13 @@ void sequencer_toggle_single_active_track(uint8_t track) { | |||
| 86 | } | 92 | } |
| 87 | } | 93 | } |
| 88 | 94 | ||
| 89 | bool is_sequencer_step_on(uint8_t step) { return step < SEQUENCER_STEPS && (sequencer_config.steps[step] & sequencer_internal_state.active_tracks) > 0; } | 95 | bool is_sequencer_step_on(uint8_t step) { |
| 96 | return step < SEQUENCER_STEPS && (sequencer_config.steps[step] & sequencer_internal_state.active_tracks) > 0; | ||
| 97 | } | ||
| 90 | 98 | ||
| 91 | bool is_sequencer_step_on_for_track(uint8_t step, uint8_t track) { return step < SEQUENCER_STEPS && (sequencer_config.steps[step] >> track) & true; } | 99 | bool is_sequencer_step_on_for_track(uint8_t step, uint8_t track) { |
| 100 | return step < SEQUENCER_STEPS && (sequencer_config.steps[step] >> track) & true; | ||
| 101 | } | ||
| 92 | 102 | ||
| 93 | void sequencer_set_step(uint8_t step, bool value) { | 103 | void sequencer_set_step(uint8_t step, bool value) { |
| 94 | if (step < SEQUENCER_STEPS) { | 104 | if (step < SEQUENCER_STEPS) { |
| @@ -122,7 +132,9 @@ void sequencer_set_all_steps(bool value) { | |||
| 122 | dprintf("sequencer: all steps are %s\n", value ? "on" : "off"); | 132 | dprintf("sequencer: all steps are %s\n", value ? "on" : "off"); |
| 123 | } | 133 | } |
| 124 | 134 | ||
| 125 | uint8_t sequencer_get_tempo(void) { return sequencer_config.tempo; } | 135 | uint8_t sequencer_get_tempo(void) { |
| 136 | return sequencer_config.tempo; | ||
| 137 | } | ||
| 126 | 138 | ||
| 127 | void sequencer_set_tempo(uint8_t tempo) { | 139 | void sequencer_set_tempo(uint8_t tempo) { |
| 128 | if (tempo > 0) { | 140 | if (tempo > 0) { |
| @@ -142,9 +154,13 @@ void sequencer_increase_tempo(void) { | |||
| 142 | } | 154 | } |
| 143 | } | 155 | } |
| 144 | 156 | ||
| 145 | void sequencer_decrease_tempo(void) { sequencer_set_tempo(sequencer_config.tempo - 1); } | 157 | void sequencer_decrease_tempo(void) { |
| 158 | sequencer_set_tempo(sequencer_config.tempo - 1); | ||
| 159 | } | ||
| 146 | 160 | ||
| 147 | sequencer_resolution_t sequencer_get_resolution(void) { return sequencer_config.resolution; } | 161 | sequencer_resolution_t sequencer_get_resolution(void) { |
| 162 | return sequencer_config.resolution; | ||
| 163 | } | ||
| 148 | 164 | ||
| 149 | void sequencer_set_resolution(sequencer_resolution_t resolution) { | 165 | void sequencer_set_resolution(sequencer_resolution_t resolution) { |
| 150 | if (resolution >= 0 && resolution < SEQUENCER_RESOLUTIONS) { | 166 | if (resolution >= 0 && resolution < SEQUENCER_RESOLUTIONS) { |
| @@ -155,11 +171,17 @@ void sequencer_set_resolution(sequencer_resolution_t resolution) { | |||
| 155 | } | 171 | } |
| 156 | } | 172 | } |
| 157 | 173 | ||
| 158 | void sequencer_increase_resolution(void) { sequencer_set_resolution(sequencer_config.resolution + 1); } | 174 | void sequencer_increase_resolution(void) { |
| 175 | sequencer_set_resolution(sequencer_config.resolution + 1); | ||
| 176 | } | ||
| 159 | 177 | ||
| 160 | void sequencer_decrease_resolution(void) { sequencer_set_resolution(sequencer_config.resolution - 1); } | 178 | void sequencer_decrease_resolution(void) { |
| 179 | sequencer_set_resolution(sequencer_config.resolution - 1); | ||
| 180 | } | ||
| 161 | 181 | ||
| 162 | uint8_t sequencer_get_current_step(void) { return sequencer_internal_state.current_step; } | 182 | uint8_t sequencer_get_current_step(void) { |
| 183 | return sequencer_internal_state.current_step; | ||
| 184 | } | ||
| 163 | 185 | ||
| 164 | void sequencer_phase_attack(void) { | 186 | void sequencer_phase_attack(void) { |
| 165 | dprintf("sequencer: step %d\n", sequencer_internal_state.current_step); | 187 | dprintf("sequencer: step %d\n", sequencer_internal_state.current_step); |
| @@ -229,9 +251,13 @@ void sequencer_task(void) { | |||
| 229 | } | 251 | } |
| 230 | } | 252 | } |
| 231 | 253 | ||
| 232 | uint16_t sequencer_get_beat_duration(void) { return get_beat_duration(sequencer_config.tempo); } | 254 | uint16_t sequencer_get_beat_duration(void) { |
| 255 | return get_beat_duration(sequencer_config.tempo); | ||
| 256 | } | ||
| 233 | 257 | ||
| 234 | uint16_t sequencer_get_step_duration(void) { return get_step_duration(sequencer_config.tempo, sequencer_config.resolution); } | 258 | uint16_t sequencer_get_step_duration(void) { |
| 259 | return get_step_duration(sequencer_config.tempo, sequencer_config.resolution); | ||
| 260 | } | ||
| 235 | 261 | ||
| 236 | uint16_t get_beat_duration(uint8_t tempo) { | 262 | uint16_t get_beat_duration(uint8_t tempo) { |
| 237 | // Don’t crash in the unlikely case where the given tempo is 0 | 263 | // Don’t crash in the unlikely case where the given tempo is 0 |
diff --git a/quantum/sequencer/sequencer.h b/quantum/sequencer/sequencer.h index 4017ae764e..a8ea16eece 100644 --- a/quantum/sequencer/sequencer.h +++ b/quantum/sequencer/sequencer.h | |||
| @@ -48,7 +48,7 @@ typedef struct { | |||
| 48 | bool enabled; | 48 | bool enabled; |
| 49 | uint8_t steps[SEQUENCER_STEPS]; | 49 | uint8_t steps[SEQUENCER_STEPS]; |
| 50 | uint16_t track_notes[SEQUENCER_TRACKS]; | 50 | uint16_t track_notes[SEQUENCER_TRACKS]; |
| 51 | uint8_t tempo; // Is a maximum tempo of 255 reasonable? | 51 | uint8_t tempo; // Is a maximum tempo of 255 reasonable? |
| 52 | sequencer_resolution_t resolution; | 52 | sequencer_resolution_t resolution; |
| 53 | } sequencer_config_t; | 53 | } sequencer_config_t; |
| 54 | 54 | ||
| @@ -57,9 +57,9 @@ typedef struct { | |||
| 57 | * We use a "phase" state machine to delay some of the events. | 57 | * We use a "phase" state machine to delay some of the events. |
| 58 | */ | 58 | */ |
| 59 | typedef enum sequencer_phase_t { | 59 | typedef enum sequencer_phase_t { |
| 60 | SEQUENCER_PHASE_ATTACK, // t=0ms, send the MIDI note on signal | 60 | SEQUENCER_PHASE_ATTACK, // t=0ms, send the MIDI note on signal |
| 61 | SEQUENCER_PHASE_RELEASE, // t=SEQUENCER_PHASE_RELEASE_TIMEOUT ms, send the MIDI note off signal | 61 | SEQUENCER_PHASE_RELEASE, // t=SEQUENCER_PHASE_RELEASE_TIMEOUT ms, send the MIDI note off signal |
| 62 | SEQUENCER_PHASE_PAUSE // t=step duration ms, loop | 62 | SEQUENCER_PHASE_PAUSE // t=step duration ms, loop |
| 63 | } sequencer_phase_t; | 63 | } sequencer_phase_t; |
| 64 | 64 | ||
| 65 | typedef struct { | 65 | typedef struct { |
diff --git a/quantum/sequencer/tests/midi_mock.c b/quantum/sequencer/tests/midi_mock.c index 236e16f9d7..5bd945d615 100644 --- a/quantum/sequencer/tests/midi_mock.c +++ b/quantum/sequencer/tests/midi_mock.c | |||
| @@ -19,8 +19,14 @@ | |||
| 19 | uint16_t last_noteon = 0; | 19 | uint16_t last_noteon = 0; |
| 20 | uint16_t last_noteoff = 0; | 20 | uint16_t last_noteoff = 0; |
| 21 | 21 | ||
| 22 | uint16_t midi_compute_note(uint16_t keycode) { return keycode; } | 22 | uint16_t midi_compute_note(uint16_t keycode) { |
| 23 | return keycode; | ||
| 24 | } | ||
| 23 | 25 | ||
| 24 | void process_midi_basic_noteon(uint16_t note) { last_noteon = note; } | 26 | void process_midi_basic_noteon(uint16_t note) { |
| 27 | last_noteon = note; | ||
| 28 | } | ||
| 25 | 29 | ||
| 26 | void process_midi_basic_noteoff(uint16_t note) { last_noteoff = note; } | 30 | void process_midi_basic_noteoff(uint16_t note) { |
| 31 | last_noteoff = note; | ||
| 32 | } | ||
diff --git a/quantum/sequencer/tests/sequencer_tests.cpp b/quantum/sequencer/tests/sequencer_tests.cpp index 290605a52a..05e58e4111 100644 --- a/quantum/sequencer/tests/sequencer_tests.cpp +++ b/quantum/sequencer/tests/sequencer_tests.cpp | |||
| @@ -78,7 +78,9 @@ class SequencerTest : public ::testing::Test { | |||
| 78 | sequencer_state_t state_copy; | 78 | sequencer_state_t state_copy; |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | TEST_F(SequencerTest, TestOffByDefault) { EXPECT_EQ(is_sequencer_on(), false); } | 81 | TEST_F(SequencerTest, TestOffByDefault) { |
| 82 | EXPECT_EQ(is_sequencer_on(), false); | ||
| 83 | } | ||
| 82 | 84 | ||
| 83 | TEST_F(SequencerTest, TestOn) { | 85 | TEST_F(SequencerTest, TestOn) { |
| 84 | sequencer_config.enabled = false; | 86 | sequencer_config.enabled = false; |
diff --git a/quantum/split_common/post_config.h b/quantum/split_common/post_config.h index a4c0a1956b..8f79beb6ed 100644 --- a/quantum/split_common/post_config.h +++ b/quantum/split_common/post_config.h | |||
| @@ -5,6 +5,6 @@ | |||
| 5 | # endif | 5 | # endif |
| 6 | 6 | ||
| 7 | # ifndef F_SCL | 7 | # ifndef F_SCL |
| 8 | # define F_SCL 100000UL // SCL frequency | 8 | # define F_SCL 100000UL // SCL frequency |
| 9 | # endif | 9 | # endif |
| 10 | #endif | 10 | #endif |
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 35f0a9d181..7d50adf758 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -43,14 +43,14 @@ | |||
| 43 | // Set to 0 to disable the disconnection check altogether. | 43 | // Set to 0 to disable the disconnection check altogether. |
| 44 | #ifndef SPLIT_MAX_CONNECTION_ERRORS | 44 | #ifndef SPLIT_MAX_CONNECTION_ERRORS |
| 45 | # define SPLIT_MAX_CONNECTION_ERRORS 10 | 45 | # define SPLIT_MAX_CONNECTION_ERRORS 10 |
| 46 | #endif // SPLIT_MAX_CONNECTION_ERRORS | 46 | #endif // SPLIT_MAX_CONNECTION_ERRORS |
| 47 | 47 | ||
| 48 | // How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected. | 48 | // How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected. |
| 49 | // One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again. | 49 | // One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again. |
| 50 | // Set to 0 to disable communication throttling while disconnected | 50 | // Set to 0 to disable communication throttling while disconnected |
| 51 | #ifndef SPLIT_CONNECTION_CHECK_TIMEOUT | 51 | #ifndef SPLIT_CONNECTION_CHECK_TIMEOUT |
| 52 | # define SPLIT_CONNECTION_CHECK_TIMEOUT 500 | 52 | # define SPLIT_CONNECTION_CHECK_TIMEOUT 500 |
| 53 | #endif // SPLIT_CONNECTION_CHECK_TIMEOUT | 53 | #endif // SPLIT_CONNECTION_CHECK_TIMEOUT |
| 54 | 54 | ||
| 55 | static uint8_t connection_errors = 0; | 55 | static uint8_t connection_errors = 0; |
| 56 | 56 | ||
| @@ -68,7 +68,9 @@ static bool usbIsActive(void) { | |||
| 68 | return false; | 68 | return false; |
| 69 | } | 69 | } |
| 70 | #else | 70 | #else |
| 71 | static inline bool usbIsActive(void) { return usb_vbus_state(); } | 71 | static inline bool usbIsActive(void) { |
| 72 | return usb_vbus_state(); | ||
| 73 | } | ||
| 72 | #endif | 74 | #endif |
| 73 | 75 | ||
| 74 | #ifdef SPLIT_HAND_MATRIX_GRID | 76 | #ifdef SPLIT_HAND_MATRIX_GRID |
| @@ -83,7 +85,7 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) { | |||
| 83 | uint8_t pin_state = readPin(in_pin); | 85 | uint8_t pin_state = readPin(in_pin); |
| 84 | // Set out_pin to a setting that is less susceptible to noise. | 86 | // Set out_pin to a setting that is less susceptible to noise. |
| 85 | setPinInputHigh(out_pin); | 87 | setPinInputHigh(out_pin); |
| 86 | matrix_io_delay(); // Wait for the pull-up to go HIGH. | 88 | matrix_io_delay(); // Wait for the pull-up to go HIGH. |
| 87 | return pin_state; | 89 | return pin_state; |
| 88 | } | 90 | } |
| 89 | #endif | 91 | #endif |
| @@ -158,7 +160,9 @@ void split_post_init(void) { | |||
| 158 | } | 160 | } |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | bool is_transport_connected(void) { return connection_errors < SPLIT_MAX_CONNECTION_ERRORS; } | 163 | bool is_transport_connected(void) { |
| 164 | return connection_errors < SPLIT_MAX_CONNECTION_ERRORS; | ||
| 165 | } | ||
| 162 | 166 | ||
| 163 | bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { | 167 | bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 164 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 168 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| @@ -169,7 +173,7 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl | |||
| 169 | if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) { | 173 | if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) { |
| 170 | return false; | 174 | return false; |
| 171 | } | 175 | } |
| 172 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 176 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| 173 | 177 | ||
| 174 | __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix); | 178 | __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix); |
| 175 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 | 179 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 |
| @@ -186,10 +190,10 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl | |||
| 186 | return connected; | 190 | return connected; |
| 187 | } else if (is_disconnected) { | 191 | } else if (is_disconnected) { |
| 188 | dprintln("Target connected"); | 192 | dprintln("Target connected"); |
| 189 | # endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 193 | # endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| 190 | } | 194 | } |
| 191 | 195 | ||
| 192 | connection_errors = 0; | 196 | connection_errors = 0; |
| 193 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 | 197 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 |
| 194 | return true; | 198 | return true; |
| 195 | } | 199 | } |
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index aa71c3621e..761a8884f4 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h | |||
| @@ -19,87 +19,87 @@ | |||
| 19 | enum serial_transaction_id { | 19 | enum serial_transaction_id { |
| 20 | #ifdef USE_I2C | 20 | #ifdef USE_I2C |
| 21 | I2C_EXECUTE_CALLBACK, | 21 | I2C_EXECUTE_CALLBACK, |
| 22 | #endif // USE_I2C | 22 | #endif // USE_I2C |
| 23 | 23 | ||
| 24 | GET_SLAVE_MATRIX_CHECKSUM, | 24 | GET_SLAVE_MATRIX_CHECKSUM, |
| 25 | GET_SLAVE_MATRIX_DATA, | 25 | GET_SLAVE_MATRIX_DATA, |
| 26 | 26 | ||
| 27 | #ifdef SPLIT_TRANSPORT_MIRROR | 27 | #ifdef SPLIT_TRANSPORT_MIRROR |
| 28 | PUT_MASTER_MATRIX, | 28 | PUT_MASTER_MATRIX, |
| 29 | #endif // SPLIT_TRANSPORT_MIRROR | 29 | #endif // SPLIT_TRANSPORT_MIRROR |
| 30 | 30 | ||
| 31 | #ifdef ENCODER_ENABLE | 31 | #ifdef ENCODER_ENABLE |
| 32 | GET_ENCODERS_CHECKSUM, | 32 | GET_ENCODERS_CHECKSUM, |
| 33 | GET_ENCODERS_DATA, | 33 | GET_ENCODERS_DATA, |
| 34 | #endif // ENCODER_ENABLE | 34 | #endif // ENCODER_ENABLE |
| 35 | 35 | ||
| 36 | #ifndef DISABLE_SYNC_TIMER | 36 | #ifndef DISABLE_SYNC_TIMER |
| 37 | PUT_SYNC_TIMER, | 37 | PUT_SYNC_TIMER, |
| 38 | #endif // DISABLE_SYNC_TIMER | 38 | #endif // DISABLE_SYNC_TIMER |
| 39 | 39 | ||
| 40 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 40 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 41 | PUT_LAYER_STATE, | 41 | PUT_LAYER_STATE, |
| 42 | PUT_DEFAULT_LAYER_STATE, | 42 | PUT_DEFAULT_LAYER_STATE, |
| 43 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 43 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 44 | 44 | ||
| 45 | #ifdef SPLIT_LED_STATE_ENABLE | 45 | #ifdef SPLIT_LED_STATE_ENABLE |
| 46 | PUT_LED_STATE, | 46 | PUT_LED_STATE, |
| 47 | #endif // SPLIT_LED_STATE_ENABLE | 47 | #endif // SPLIT_LED_STATE_ENABLE |
| 48 | 48 | ||
| 49 | #ifdef SPLIT_MODS_ENABLE | 49 | #ifdef SPLIT_MODS_ENABLE |
| 50 | PUT_MODS, | 50 | PUT_MODS, |
| 51 | #endif // SPLIT_MODS_ENABLE | 51 | #endif // SPLIT_MODS_ENABLE |
| 52 | 52 | ||
| 53 | #ifdef BACKLIGHT_ENABLE | 53 | #ifdef BACKLIGHT_ENABLE |
| 54 | PUT_BACKLIGHT, | 54 | PUT_BACKLIGHT, |
| 55 | #endif // BACKLIGHT_ENABLE | 55 | #endif // BACKLIGHT_ENABLE |
| 56 | 56 | ||
| 57 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 57 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 58 | PUT_RGBLIGHT, | 58 | PUT_RGBLIGHT, |
| 59 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 59 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 60 | 60 | ||
| 61 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 61 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 62 | PUT_LED_MATRIX, | 62 | PUT_LED_MATRIX, |
| 63 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 63 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 64 | 64 | ||
| 65 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 65 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 66 | PUT_RGB_MATRIX, | 66 | PUT_RGB_MATRIX, |
| 67 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 67 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 68 | 68 | ||
| 69 | #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 69 | #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 70 | PUT_WPM, | 70 | PUT_WPM, |
| 71 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 71 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 72 | 72 | ||
| 73 | #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 73 | #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 74 | PUT_OLED, | 74 | PUT_OLED, |
| 75 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 75 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 76 | 76 | ||
| 77 | #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 77 | #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 78 | PUT_ST7565, | 78 | PUT_ST7565, |
| 79 | #endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 79 | #endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 80 | 80 | ||
| 81 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 81 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 82 | GET_POINTING_CHECKSUM, | 82 | GET_POINTING_CHECKSUM, |
| 83 | GET_POINTING_DATA, | 83 | GET_POINTING_DATA, |
| 84 | PUT_POINTING_CPI, | 84 | PUT_POINTING_CPI, |
| 85 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 85 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 86 | 86 | ||
| 87 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 87 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 88 | PUT_RPC_INFO, | 88 | PUT_RPC_INFO, |
| 89 | PUT_RPC_REQ_DATA, | 89 | PUT_RPC_REQ_DATA, |
| 90 | EXECUTE_RPC, | 90 | EXECUTE_RPC, |
| 91 | GET_RPC_RESP_DATA, | 91 | GET_RPC_RESP_DATA, |
| 92 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 92 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 93 | 93 | ||
| 94 | // keyboard-specific | 94 | // keyboard-specific |
| 95 | #ifdef SPLIT_TRANSACTION_IDS_KB | 95 | #ifdef SPLIT_TRANSACTION_IDS_KB |
| 96 | SPLIT_TRANSACTION_IDS_KB, | 96 | SPLIT_TRANSACTION_IDS_KB, |
| 97 | #endif // SPLIT_TRANSACTION_IDS_KB | 97 | #endif // SPLIT_TRANSACTION_IDS_KB |
| 98 | 98 | ||
| 99 | // user/keymap-specific | 99 | // user/keymap-specific |
| 100 | #ifdef SPLIT_TRANSACTION_IDS_USER | 100 | #ifdef SPLIT_TRANSACTION_IDS_USER |
| 101 | SPLIT_TRANSACTION_IDS_USER, | 101 | SPLIT_TRANSACTION_IDS_USER, |
| 102 | #endif // SPLIT_TRANSACTION_IDS_USER | 102 | #endif // SPLIT_TRANSACTION_IDS_USER |
| 103 | 103 | ||
| 104 | NUM_TOTAL_TRANSACTIONS | 104 | NUM_TOTAL_TRANSACTIONS |
| 105 | }; | 105 | }; |
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 4b059a2b8a..cffbccaeee 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | #ifndef FORCED_SYNC_THROTTLE_MS | 31 | #ifndef FORCED_SYNC_THROTTLE_MS |
| 32 | # define FORCED_SYNC_THROTTLE_MS 100 | 32 | # define FORCED_SYNC_THROTTLE_MS 100 |
| 33 | #endif // FORCED_SYNC_THROTTLE_MS | 33 | #endif // FORCED_SYNC_THROTTLE_MS |
| 34 | 34 | ||
| 35 | #define sizeof_member(type, member) sizeof(((type *)NULL)->member) | 35 | #define sizeof_member(type, member) sizeof(((type *)NULL)->member) |
| 36 | 36 | ||
| @@ -49,7 +49,7 @@ | |||
| 49 | // Forward-declare the RPC callback handlers | 49 | // Forward-declare the RPC callback handlers |
| 50 | void slave_rpc_info_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); | 50 | void slave_rpc_info_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); |
| 51 | void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); | 51 | void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); |
| 52 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 52 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 53 | 53 | ||
| 54 | //////////////////////////////////////////////////// | 54 | //////////////////////////////////////////////////// |
| 55 | // Helpers | 55 | // Helpers |
| @@ -63,7 +63,9 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_ | |||
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | bool this_okay = true; | 65 | bool this_okay = true; |
| 66 | ATOMIC_BLOCK_FORCEON { this_okay = handler(master_matrix, slave_matrix); }; | 66 | ATOMIC_BLOCK_FORCEON { |
| 67 | this_okay = handler(master_matrix, slave_matrix); | ||
| 68 | }; | ||
| 67 | if (this_okay) return true; | 69 | if (this_okay) return true; |
| 68 | } | 70 | } |
| 69 | dprintf("Failed to execute %s\n", prefix); | 71 | dprintf("Failed to execute %s\n", prefix); |
| @@ -75,9 +77,11 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_ | |||
| 75 | if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \ | 77 | if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \ |
| 76 | } while (0) | 78 | } while (0) |
| 77 | 79 | ||
| 78 | #define TRANSACTION_HANDLER_SLAVE(prefix) \ | 80 | #define TRANSACTION_HANDLER_SLAVE(prefix) \ |
| 79 | do { \ | 81 | do { \ |
| 80 | ATOMIC_BLOCK_FORCEON { prefix##_handlers_slave(master_matrix, slave_matrix); }; \ | 82 | ATOMIC_BLOCK_FORCEON { \ |
| 83 | prefix##_handlers_slave(master_matrix, slave_matrix); \ | ||
| 84 | }; \ | ||
| 81 | } while (0) | 85 | } while (0) |
| 82 | 86 | ||
| 83 | inline static bool read_if_checksum_mismatch(int8_t trans_id_checksum, int8_t trans_id_retrieve, uint32_t *last_update, void *destination, const void *equiv_shmem, size_t length) { | 87 | inline static bool read_if_checksum_mismatch(int8_t trans_id_checksum, int8_t trans_id_retrieve, uint32_t *last_update, void *destination, const void *equiv_shmem, size_t length) { |
| @@ -116,8 +120,8 @@ inline static bool send_if_data_mismatch(int8_t trans_id, uint32_t *last_update, | |||
| 116 | 120 | ||
| 117 | static bool slave_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { | 121 | static bool slave_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 118 | static uint32_t last_update = 0; | 122 | static uint32_t last_update = 0; |
| 119 | static matrix_row_t last_matrix[(MATRIX_ROWS) / 2] = {0}; // last successfully-read matrix, so we can replicate if there are checksum errors | 123 | static matrix_row_t last_matrix[(MATRIX_ROWS) / 2] = {0}; // last successfully-read matrix, so we can replicate if there are checksum errors |
| 120 | matrix_row_t temp_matrix[(MATRIX_ROWS) / 2]; // holding area while we test whether or not checksum is correct | 124 | matrix_row_t temp_matrix[(MATRIX_ROWS) / 2]; // holding area while we test whether or not checksum is correct |
| 121 | 125 | ||
| 122 | bool okay = read_if_checksum_mismatch(GET_SLAVE_MATRIX_CHECKSUM, GET_SLAVE_MATRIX_DATA, &last_update, temp_matrix, split_shmem->smatrix.matrix, sizeof(split_shmem->smatrix.matrix)); | 126 | bool okay = read_if_checksum_mismatch(GET_SLAVE_MATRIX_CHECKSUM, GET_SLAVE_MATRIX_DATA, &last_update, temp_matrix, split_shmem->smatrix.matrix, sizeof(split_shmem->smatrix.matrix)); |
| 123 | if (okay) { | 127 | if (okay) { |
| @@ -161,13 +165,13 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro | |||
| 161 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) | 165 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) |
| 162 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), | 166 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), |
| 163 | 167 | ||
| 164 | #else // SPLIT_TRANSPORT_MIRROR | 168 | #else // SPLIT_TRANSPORT_MIRROR |
| 165 | 169 | ||
| 166 | # define TRANSACTIONS_MASTER_MATRIX_MASTER() | 170 | # define TRANSACTIONS_MASTER_MATRIX_MASTER() |
| 167 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() | 171 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() |
| 168 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS | 172 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS |
| 169 | 173 | ||
| 170 | #endif // SPLIT_TRANSPORT_MIRROR | 174 | #endif // SPLIT_TRANSPORT_MIRROR |
| 171 | 175 | ||
| 172 | //////////////////////////////////////////////////// | 176 | //////////////////////////////////////////////////// |
| 173 | // Encoders | 177 | // Encoders |
| @@ -200,13 +204,13 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl | |||
| 200 | [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.state), | 204 | [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.state), |
| 201 | // clang-format on | 205 | // clang-format on |
| 202 | 206 | ||
| 203 | #else // ENCODER_ENABLE | 207 | #else // ENCODER_ENABLE |
| 204 | 208 | ||
| 205 | # define TRANSACTIONS_ENCODERS_MASTER() | 209 | # define TRANSACTIONS_ENCODERS_MASTER() |
| 206 | # define TRANSACTIONS_ENCODERS_SLAVE() | 210 | # define TRANSACTIONS_ENCODERS_SLAVE() |
| 207 | # define TRANSACTIONS_ENCODERS_REGISTRATIONS | 211 | # define TRANSACTIONS_ENCODERS_REGISTRATIONS |
| 208 | 212 | ||
| 209 | #endif // ENCODER_ENABLE | 213 | #endif // ENCODER_ENABLE |
| 210 | 214 | ||
| 211 | //////////////////////////////////////////////////// | 215 | //////////////////////////////////////////////////// |
| 212 | // Sync timer | 216 | // Sync timer |
| @@ -239,13 +243,13 @@ static void sync_timer_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
| 239 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) | 243 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) |
| 240 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), | 244 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), |
| 241 | 245 | ||
| 242 | #else // DISABLE_SYNC_TIMER | 246 | #else // DISABLE_SYNC_TIMER |
| 243 | 247 | ||
| 244 | # define TRANSACTIONS_SYNC_TIMER_MASTER() | 248 | # define TRANSACTIONS_SYNC_TIMER_MASTER() |
| 245 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() | 249 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() |
| 246 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS | 250 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS |
| 247 | 251 | ||
| 248 | #endif // DISABLE_SYNC_TIMER | 252 | #endif // DISABLE_SYNC_TIMER |
| 249 | 253 | ||
| 250 | //////////////////////////////////////////////////// | 254 | //////////////////////////////////////////////////// |
| 251 | // Layer state | 255 | // Layer state |
| @@ -276,13 +280,13 @@ static void layer_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_ | |||
| 276 | [PUT_DEFAULT_LAYER_STATE] = trans_initiator2target_initializer(layers.default_layer_state), | 280 | [PUT_DEFAULT_LAYER_STATE] = trans_initiator2target_initializer(layers.default_layer_state), |
| 277 | // clang-format on | 281 | // clang-format on |
| 278 | 282 | ||
| 279 | #else // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 283 | #else // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 280 | 284 | ||
| 281 | # define TRANSACTIONS_LAYER_STATE_MASTER() | 285 | # define TRANSACTIONS_LAYER_STATE_MASTER() |
| 282 | # define TRANSACTIONS_LAYER_STATE_SLAVE() | 286 | # define TRANSACTIONS_LAYER_STATE_SLAVE() |
| 283 | # define TRANSACTIONS_LAYER_STATE_REGISTRATIONS | 287 | # define TRANSACTIONS_LAYER_STATE_REGISTRATIONS |
| 284 | 288 | ||
| 285 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 289 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 286 | 290 | ||
| 287 | //////////////////////////////////////////////////// | 291 | //////////////////////////////////////////////////// |
| 288 | // LED state | 292 | // LED state |
| @@ -304,13 +308,13 @@ static void led_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
| 304 | # define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) | 308 | # define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) |
| 305 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), | 309 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), |
| 306 | 310 | ||
| 307 | #else // SPLIT_LED_STATE_ENABLE | 311 | #else // SPLIT_LED_STATE_ENABLE |
| 308 | 312 | ||
| 309 | # define TRANSACTIONS_LED_STATE_MASTER() | 313 | # define TRANSACTIONS_LED_STATE_MASTER() |
| 310 | # define TRANSACTIONS_LED_STATE_SLAVE() | 314 | # define TRANSACTIONS_LED_STATE_SLAVE() |
| 311 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS | 315 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS |
| 312 | 316 | ||
| 313 | #endif // SPLIT_LED_STATE_ENABLE | 317 | #endif // SPLIT_LED_STATE_ENABLE |
| 314 | 318 | ||
| 315 | //////////////////////////////////////////////////// | 319 | //////////////////////////////////////////////////// |
| 316 | // Mods | 320 | // Mods |
| @@ -336,7 +340,7 @@ static bool mods_handlers_master(matrix_row_t master_matrix[], matrix_row_t slav | |||
| 336 | if (!mods_need_sync && new_mods.oneshot_mods != split_shmem->mods.oneshot_mods) { | 340 | if (!mods_need_sync && new_mods.oneshot_mods != split_shmem->mods.oneshot_mods) { |
| 337 | mods_need_sync = true; | 341 | mods_need_sync = true; |
| 338 | } | 342 | } |
| 339 | # endif // NO_ACTION_ONESHOT | 343 | # endif // NO_ACTION_ONESHOT |
| 340 | 344 | ||
| 341 | bool okay = true; | 345 | bool okay = true; |
| 342 | if (mods_need_sync) { | 346 | if (mods_need_sync) { |
| @@ -361,13 +365,13 @@ static void mods_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave | |||
| 361 | # define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) | 365 | # define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) |
| 362 | # define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), | 366 | # define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), |
| 363 | 367 | ||
| 364 | #else // SPLIT_MODS_ENABLE | 368 | #else // SPLIT_MODS_ENABLE |
| 365 | 369 | ||
| 366 | # define TRANSACTIONS_MODS_MASTER() | 370 | # define TRANSACTIONS_MODS_MASTER() |
| 367 | # define TRANSACTIONS_MODS_SLAVE() | 371 | # define TRANSACTIONS_MODS_SLAVE() |
| 368 | # define TRANSACTIONS_MODS_REGISTRATIONS | 372 | # define TRANSACTIONS_MODS_REGISTRATIONS |
| 369 | 373 | ||
| 370 | #endif // SPLIT_MODS_ENABLE | 374 | #endif // SPLIT_MODS_ENABLE |
| 371 | 375 | ||
| 372 | //////////////////////////////////////////////////// | 376 | //////////////////////////////////////////////////// |
| 373 | // Backlight | 377 | // Backlight |
| @@ -380,19 +384,21 @@ static bool backlight_handlers_master(matrix_row_t master_matrix[], matrix_row_t | |||
| 380 | return send_if_condition(PUT_BACKLIGHT, &last_update, (level != split_shmem->backlight_level), &level, sizeof(level)); | 384 | return send_if_condition(PUT_BACKLIGHT, &last_update, (level != split_shmem->backlight_level), &level, sizeof(level)); |
| 381 | } | 385 | } |
| 382 | 386 | ||
| 383 | static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); } | 387 | static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 388 | backlight_set(split_shmem->backlight_level); | ||
| 389 | } | ||
| 384 | 390 | ||
| 385 | # define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) | 391 | # define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) |
| 386 | # define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) | 392 | # define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) |
| 387 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), | 393 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), |
| 388 | 394 | ||
| 389 | #else // BACKLIGHT_ENABLE | 395 | #else // BACKLIGHT_ENABLE |
| 390 | 396 | ||
| 391 | # define TRANSACTIONS_BACKLIGHT_MASTER() | 397 | # define TRANSACTIONS_BACKLIGHT_MASTER() |
| 392 | # define TRANSACTIONS_BACKLIGHT_SLAVE() | 398 | # define TRANSACTIONS_BACKLIGHT_SLAVE() |
| 393 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS | 399 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS |
| 394 | 400 | ||
| 395 | #endif // BACKLIGHT_ENABLE | 401 | #endif // BACKLIGHT_ENABLE |
| 396 | 402 | ||
| 397 | //////////////////////////////////////////////////// | 403 | //////////////////////////////////////////////////// |
| 398 | // RGBLIGHT | 404 | // RGBLIGHT |
| @@ -423,13 +429,13 @@ static void rgblight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s | |||
| 423 | # define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) | 429 | # define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) |
| 424 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), | 430 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), |
| 425 | 431 | ||
| 426 | #else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 432 | #else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 427 | 433 | ||
| 428 | # define TRANSACTIONS_RGBLIGHT_MASTER() | 434 | # define TRANSACTIONS_RGBLIGHT_MASTER() |
| 429 | # define TRANSACTIONS_RGBLIGHT_SLAVE() | 435 | # define TRANSACTIONS_RGBLIGHT_SLAVE() |
| 430 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS | 436 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS |
| 431 | 437 | ||
| 432 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 438 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 433 | 439 | ||
| 434 | //////////////////////////////////////////////////// | 440 | //////////////////////////////////////////////////// |
| 435 | // LED Matrix | 441 | // LED Matrix |
| @@ -453,13 +459,13 @@ static void led_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
| 453 | # define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) | 459 | # define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) |
| 454 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), | 460 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), |
| 455 | 461 | ||
| 456 | #else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 462 | #else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 457 | 463 | ||
| 458 | # define TRANSACTIONS_LED_MATRIX_MASTER() | 464 | # define TRANSACTIONS_LED_MATRIX_MASTER() |
| 459 | # define TRANSACTIONS_LED_MATRIX_SLAVE() | 465 | # define TRANSACTIONS_LED_MATRIX_SLAVE() |
| 460 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS | 466 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS |
| 461 | 467 | ||
| 462 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 468 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 463 | 469 | ||
| 464 | //////////////////////////////////////////////////// | 470 | //////////////////////////////////////////////////// |
| 465 | // RGB Matrix | 471 | // RGB Matrix |
| @@ -483,13 +489,13 @@ static void rgb_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
| 483 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) | 489 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) |
| 484 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), | 490 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), |
| 485 | 491 | ||
| 486 | #else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 492 | #else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 487 | 493 | ||
| 488 | # define TRANSACTIONS_RGB_MATRIX_MASTER() | 494 | # define TRANSACTIONS_RGB_MATRIX_MASTER() |
| 489 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() | 495 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() |
| 490 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS | 496 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS |
| 491 | 497 | ||
| 492 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 498 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 493 | 499 | ||
| 494 | //////////////////////////////////////////////////// | 500 | //////////////////////////////////////////////////// |
| 495 | // WPM | 501 | // WPM |
| @@ -502,19 +508,21 @@ static bool wpm_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave | |||
| 502 | return send_if_condition(PUT_WPM, &last_update, (current_wpm != split_shmem->current_wpm), ¤t_wpm, sizeof(current_wpm)); | 508 | return send_if_condition(PUT_WPM, &last_update, (current_wpm != split_shmem->current_wpm), ¤t_wpm, sizeof(current_wpm)); |
| 503 | } | 509 | } |
| 504 | 510 | ||
| 505 | static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); } | 511 | static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 512 | set_current_wpm(split_shmem->current_wpm); | ||
| 513 | } | ||
| 506 | 514 | ||
| 507 | # define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) | 515 | # define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) |
| 508 | # define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) | 516 | # define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) |
| 509 | # define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), | 517 | # define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), |
| 510 | 518 | ||
| 511 | #else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 519 | #else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 512 | 520 | ||
| 513 | # define TRANSACTIONS_WPM_MASTER() | 521 | # define TRANSACTIONS_WPM_MASTER() |
| 514 | # define TRANSACTIONS_WPM_SLAVE() | 522 | # define TRANSACTIONS_WPM_SLAVE() |
| 515 | # define TRANSACTIONS_WPM_REGISTRATIONS | 523 | # define TRANSACTIONS_WPM_REGISTRATIONS |
| 516 | 524 | ||
| 517 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 525 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 518 | 526 | ||
| 519 | //////////////////////////////////////////////////// | 527 | //////////////////////////////////////////////////// |
| 520 | // OLED | 528 | // OLED |
| @@ -539,13 +547,13 @@ static void oled_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave | |||
| 539 | # define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) | 547 | # define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) |
| 540 | # define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), | 548 | # define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), |
| 541 | 549 | ||
| 542 | #else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 550 | #else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 543 | 551 | ||
| 544 | # define TRANSACTIONS_OLED_MASTER() | 552 | # define TRANSACTIONS_OLED_MASTER() |
| 545 | # define TRANSACTIONS_OLED_SLAVE() | 553 | # define TRANSACTIONS_OLED_SLAVE() |
| 546 | # define TRANSACTIONS_OLED_REGISTRATIONS | 554 | # define TRANSACTIONS_OLED_REGISTRATIONS |
| 547 | 555 | ||
| 548 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 556 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 549 | 557 | ||
| 550 | //////////////////////////////////////////////////// | 558 | //////////////////////////////////////////////////// |
| 551 | // ST7565 | 559 | // ST7565 |
| @@ -570,13 +578,13 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla | |||
| 570 | # define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) | 578 | # define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) |
| 571 | # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), | 579 | # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), |
| 572 | 580 | ||
| 573 | #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 581 | #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 574 | 582 | ||
| 575 | # define TRANSACTIONS_ST7565_MASTER() | 583 | # define TRANSACTIONS_ST7565_MASTER() |
| 576 | # define TRANSACTIONS_ST7565_SLAVE() | 584 | # define TRANSACTIONS_ST7565_SLAVE() |
| 577 | # define TRANSACTIONS_ST7565_REGISTRATIONS | 585 | # define TRANSACTIONS_ST7565_REGISTRATIONS |
| 578 | 586 | ||
| 579 | #endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 587 | #endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 580 | 588 | ||
| 581 | //////////////////////////////////////////////////// | 589 | //////////////////////////////////////////////////// |
| 582 | // POINTING | 590 | // POINTING |
| @@ -631,7 +639,7 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s | |||
| 631 | } | 639 | } |
| 632 | last_exec = timer_read32(); | 640 | last_exec = timer_read32(); |
| 633 | # endif | 641 | # endif |
| 634 | temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL | 642 | temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL |
| 635 | if (split_shmem->pointing.cpi && memcmp(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)) != 0) { | 643 | if (split_shmem->pointing.cpi && memcmp(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)) != 0) { |
| 636 | if (pointing_device_driver.set_cpi) { | 644 | if (pointing_device_driver.set_cpi) { |
| 637 | pointing_device_driver.set_cpi(split_shmem->pointing.cpi); | 645 | pointing_device_driver.set_cpi(split_shmem->pointing.cpi); |
| @@ -648,13 +656,13 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s | |||
| 648 | # define TRANSACTIONS_POINTING_SLAVE() TRANSACTION_HANDLER_SLAVE(pointing) | 656 | # define TRANSACTIONS_POINTING_SLAVE() TRANSACTION_HANDLER_SLAVE(pointing) |
| 649 | # define TRANSACTIONS_POINTING_REGISTRATIONS [GET_POINTING_CHECKSUM] = trans_target2initiator_initializer(pointing.checksum), [GET_POINTING_DATA] = trans_target2initiator_initializer(pointing.report), [PUT_POINTING_CPI] = trans_initiator2target_initializer(pointing.cpi), | 657 | # define TRANSACTIONS_POINTING_REGISTRATIONS [GET_POINTING_CHECKSUM] = trans_target2initiator_initializer(pointing.checksum), [GET_POINTING_DATA] = trans_target2initiator_initializer(pointing.report), [PUT_POINTING_CPI] = trans_initiator2target_initializer(pointing.cpi), |
| 650 | 658 | ||
| 651 | #else // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 659 | #else // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 652 | 660 | ||
| 653 | # define TRANSACTIONS_POINTING_MASTER() | 661 | # define TRANSACTIONS_POINTING_MASTER() |
| 654 | # define TRANSACTIONS_POINTING_SLAVE() | 662 | # define TRANSACTIONS_POINTING_SLAVE() |
| 655 | # define TRANSACTIONS_POINTING_REGISTRATIONS | 663 | # define TRANSACTIONS_POINTING_REGISTRATIONS |
| 656 | 664 | ||
| 657 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 665 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 658 | 666 | ||
| 659 | //////////////////////////////////////////////////// | 667 | //////////////////////////////////////////////////// |
| 660 | 668 | ||
| @@ -664,7 +672,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { | |||
| 664 | 672 | ||
| 665 | #ifdef USE_I2C | 673 | #ifdef USE_I2C |
| 666 | [I2C_EXECUTE_CALLBACK] = trans_initiator2target_initializer(transaction_id), | 674 | [I2C_EXECUTE_CALLBACK] = trans_initiator2target_initializer(transaction_id), |
| 667 | #endif // USE_I2C | 675 | #endif // USE_I2C |
| 668 | 676 | ||
| 669 | // clang-format off | 677 | // clang-format off |
| 670 | TRANSACTIONS_SLAVE_MATRIX_REGISTRATIONS | 678 | TRANSACTIONS_SLAVE_MATRIX_REGISTRATIONS |
| @@ -689,7 +697,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { | |||
| 689 | [PUT_RPC_REQ_DATA] = trans_initiator2target_initializer(rpc_m2s_buffer), | 697 | [PUT_RPC_REQ_DATA] = trans_initiator2target_initializer(rpc_m2s_buffer), |
| 690 | [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.transaction_id, slave_rpc_exec_callback), | 698 | [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.transaction_id, slave_rpc_exec_callback), |
| 691 | [GET_RPC_RESP_DATA] = trans_target2initiator_initializer(rpc_s2m_buffer), | 699 | [GET_RPC_RESP_DATA] = trans_target2initiator_initializer(rpc_s2m_buffer), |
| 692 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 700 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 693 | }; | 701 | }; |
| 694 | 702 | ||
| 695 | bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { | 703 | bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| @@ -800,4 +808,4 @@ void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *i | |||
| 800 | } | 808 | } |
| 801 | } | 809 | } |
| 802 | 810 | ||
| 803 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 811 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 060ba8a927..aade3c98d7 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | # ifndef SLAVE_I2C_TIMEOUT | 27 | # ifndef SLAVE_I2C_TIMEOUT |
| 28 | # define SLAVE_I2C_TIMEOUT 100 | 28 | # define SLAVE_I2C_TIMEOUT 100 |
| 29 | # endif // SLAVE_I2C_TIMEOUT | 29 | # endif // SLAVE_I2C_TIMEOUT |
| 30 | 30 | ||
| 31 | # ifndef SLAVE_I2C_ADDRESS | 31 | # ifndef SLAVE_I2C_ADDRESS |
| 32 | # define SLAVE_I2C_ADDRESS 0x32 | 32 | # define SLAVE_I2C_ADDRESS 0x32 |
| @@ -40,8 +40,12 @@ _Static_assert(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shar | |||
| 40 | 40 | ||
| 41 | split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg; | 41 | split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg; |
| 42 | 42 | ||
| 43 | void transport_master_init(void) { i2c_init(); } | 43 | void transport_master_init(void) { |
| 44 | void transport_slave_init(void) { i2c_slave_init(SLAVE_I2C_ADDRESS); } | 44 | i2c_init(); |
| 45 | } | ||
| 46 | void transport_slave_init(void) { | ||
| 47 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
| 48 | } | ||
| 45 | 49 | ||
| 46 | i2c_status_t transport_trigger_callback(int8_t id) { | 50 | i2c_status_t transport_trigger_callback(int8_t id) { |
| 47 | // If there's no callback, indicate that we were successful | 51 | // If there's no callback, indicate that we were successful |
| @@ -82,15 +86,19 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, | |||
| 82 | return true; | 86 | return true; |
| 83 | } | 87 | } |
| 84 | 88 | ||
| 85 | #else // USE_I2C | 89 | #else // USE_I2C |
| 86 | 90 | ||
| 87 | # include "serial.h" | 91 | # include "serial.h" |
| 88 | 92 | ||
| 89 | static split_shared_memory_t shared_memory; | 93 | static split_shared_memory_t shared_memory; |
| 90 | split_shared_memory_t *const split_shmem = &shared_memory; | 94 | split_shared_memory_t *const split_shmem = &shared_memory; |
| 91 | 95 | ||
| 92 | void transport_master_init(void) { soft_serial_initiator_init(); } | 96 | void transport_master_init(void) { |
| 93 | void transport_slave_init(void) { soft_serial_target_init(); } | 97 | soft_serial_initiator_init(); |
| 98 | } | ||
| 99 | void transport_slave_init(void) { | ||
| 100 | soft_serial_target_init(); | ||
| 101 | } | ||
| 94 | 102 | ||
| 95 | bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length) { | 103 | bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length) { |
| 96 | split_transaction_desc_t *trans = &split_transaction_table[id]; | 104 | split_transaction_desc_t *trans = &split_transaction_table[id]; |
| @@ -111,8 +119,12 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, | |||
| 111 | return true; | 119 | return true; |
| 112 | } | 120 | } |
| 113 | 121 | ||
| 114 | #endif // USE_I2C | 122 | #endif // USE_I2C |
| 115 | 123 | ||
| 116 | bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { return transactions_master(master_matrix, slave_matrix); } | 124 | bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 125 | return transactions_master(master_matrix, slave_matrix); | ||
| 126 | } | ||
| 117 | 127 | ||
| 118 | void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { transactions_slave(master_matrix, slave_matrix); } | 128 | void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 129 | transactions_slave(master_matrix, slave_matrix); | ||
| 130 | } | ||
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h index 31b804908b..26bd136728 100644 --- a/quantum/split_common/transport.h +++ b/quantum/split_common/transport.h | |||
| @@ -25,11 +25,11 @@ | |||
| 25 | 25 | ||
| 26 | #ifndef RPC_M2S_BUFFER_SIZE | 26 | #ifndef RPC_M2S_BUFFER_SIZE |
| 27 | # define RPC_M2S_BUFFER_SIZE 32 | 27 | # define RPC_M2S_BUFFER_SIZE 32 |
| 28 | #endif // RPC_M2S_BUFFER_SIZE | 28 | #endif // RPC_M2S_BUFFER_SIZE |
| 29 | 29 | ||
| 30 | #ifndef RPC_S2M_BUFFER_SIZE | 30 | #ifndef RPC_S2M_BUFFER_SIZE |
| 31 | # define RPC_S2M_BUFFER_SIZE 32 | 31 | # define RPC_S2M_BUFFER_SIZE 32 |
| 32 | #endif // RPC_S2M_BUFFER_SIZE | 32 | #endif // RPC_S2M_BUFFER_SIZE |
| 33 | 33 | ||
| 34 | void transport_master_init(void); | 34 | void transport_master_init(void); |
| 35 | void transport_slave_init(void); | 35 | void transport_slave_init(void); |
| @@ -43,15 +43,15 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, | |||
| 43 | #ifdef ENCODER_ENABLE | 43 | #ifdef ENCODER_ENABLE |
| 44 | # include "encoder.h" | 44 | # include "encoder.h" |
| 45 | # define NUMBER_OF_ENCODERS (sizeof((pin_t[])ENCODERS_PAD_A) / sizeof(pin_t)) | 45 | # define NUMBER_OF_ENCODERS (sizeof((pin_t[])ENCODERS_PAD_A) / sizeof(pin_t)) |
| 46 | #endif // ENCODER_ENABLE | 46 | #endif // ENCODER_ENABLE |
| 47 | 47 | ||
| 48 | #ifdef BACKLIGHT_ENABLE | 48 | #ifdef BACKLIGHT_ENABLE |
| 49 | # include "backlight.h" | 49 | # include "backlight.h" |
| 50 | #endif // BACKLIGHT_ENABLE | 50 | #endif // BACKLIGHT_ENABLE |
| 51 | 51 | ||
| 52 | #ifdef RGBLIGHT_ENABLE | 52 | #ifdef RGBLIGHT_ENABLE |
| 53 | # include "rgblight.h" | 53 | # include "rgblight.h" |
| 54 | #endif // RGBLIGHT_ENABLE | 54 | #endif // RGBLIGHT_ENABLE |
| 55 | 55 | ||
| 56 | typedef struct _split_slave_matrix_sync_t { | 56 | typedef struct _split_slave_matrix_sync_t { |
| 57 | uint8_t checksum; | 57 | uint8_t checksum; |
| @@ -62,21 +62,21 @@ typedef struct _split_slave_matrix_sync_t { | |||
| 62 | typedef struct _split_master_matrix_sync_t { | 62 | typedef struct _split_master_matrix_sync_t { |
| 63 | matrix_row_t matrix[(MATRIX_ROWS) / 2]; | 63 | matrix_row_t matrix[(MATRIX_ROWS) / 2]; |
| 64 | } split_master_matrix_sync_t; | 64 | } split_master_matrix_sync_t; |
| 65 | #endif // SPLIT_TRANSPORT_MIRROR | 65 | #endif // SPLIT_TRANSPORT_MIRROR |
| 66 | 66 | ||
| 67 | #ifdef ENCODER_ENABLE | 67 | #ifdef ENCODER_ENABLE |
| 68 | typedef struct _split_slave_encoder_sync_t { | 68 | typedef struct _split_slave_encoder_sync_t { |
| 69 | uint8_t checksum; | 69 | uint8_t checksum; |
| 70 | uint8_t state[NUMBER_OF_ENCODERS]; | 70 | uint8_t state[NUMBER_OF_ENCODERS]; |
| 71 | } split_slave_encoder_sync_t; | 71 | } split_slave_encoder_sync_t; |
| 72 | #endif // ENCODER_ENABLE | 72 | #endif // ENCODER_ENABLE |
| 73 | 73 | ||
| 74 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 74 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 75 | typedef struct _split_layers_sync_t { | 75 | typedef struct _split_layers_sync_t { |
| 76 | layer_state_t layer_state; | 76 | layer_state_t layer_state; |
| 77 | layer_state_t default_layer_state; | 77 | layer_state_t default_layer_state; |
| 78 | } split_layers_sync_t; | 78 | } split_layers_sync_t; |
| 79 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 79 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 80 | 80 | ||
| 81 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 81 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 82 | # include "led_matrix.h" | 82 | # include "led_matrix.h" |
| @@ -85,7 +85,7 @@ typedef struct _led_matrix_sync_t { | |||
| 85 | led_eeconfig_t led_matrix; | 85 | led_eeconfig_t led_matrix; |
| 86 | bool led_suspend_state; | 86 | bool led_suspend_state; |
| 87 | } led_matrix_sync_t; | 87 | } led_matrix_sync_t; |
| 88 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 88 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 89 | 89 | ||
| 90 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 90 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 91 | # include "rgb_matrix.h" | 91 | # include "rgb_matrix.h" |
| @@ -94,7 +94,7 @@ typedef struct _rgb_matrix_sync_t { | |||
| 94 | rgb_config_t rgb_matrix; | 94 | rgb_config_t rgb_matrix; |
| 95 | bool rgb_suspend_state; | 95 | bool rgb_suspend_state; |
| 96 | } rgb_matrix_sync_t; | 96 | } rgb_matrix_sync_t; |
| 97 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 97 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 98 | 98 | ||
| 99 | #ifdef SPLIT_MODS_ENABLE | 99 | #ifdef SPLIT_MODS_ENABLE |
| 100 | typedef struct _split_mods_sync_t { | 100 | typedef struct _split_mods_sync_t { |
| @@ -102,9 +102,9 @@ typedef struct _split_mods_sync_t { | |||
| 102 | uint8_t weak_mods; | 102 | uint8_t weak_mods; |
| 103 | # ifndef NO_ACTION_ONESHOT | 103 | # ifndef NO_ACTION_ONESHOT |
| 104 | uint8_t oneshot_mods; | 104 | uint8_t oneshot_mods; |
| 105 | # endif // NO_ACTION_ONESHOT | 105 | # endif // NO_ACTION_ONESHOT |
| 106 | } split_mods_sync_t; | 106 | } split_mods_sync_t; |
| 107 | #endif // SPLIT_MODS_ENABLE | 107 | #endif // SPLIT_MODS_ENABLE |
| 108 | 108 | ||
| 109 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 109 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 110 | # include "pointing_device.h" | 110 | # include "pointing_device.h" |
| @@ -113,7 +113,7 @@ typedef struct _split_slave_pointing_sync_t { | |||
| 113 | report_mouse_t report; | 113 | report_mouse_t report; |
| 114 | uint16_t cpi; | 114 | uint16_t cpi; |
| 115 | } split_slave_pointing_sync_t; | 115 | } split_slave_pointing_sync_t; |
| 116 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 116 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 117 | 117 | ||
| 118 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 118 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 119 | typedef struct _rpc_sync_info_t { | 119 | typedef struct _rpc_sync_info_t { |
| @@ -121,76 +121,76 @@ typedef struct _rpc_sync_info_t { | |||
| 121 | uint8_t m2s_length; | 121 | uint8_t m2s_length; |
| 122 | uint8_t s2m_length; | 122 | uint8_t s2m_length; |
| 123 | } rpc_sync_info_t; | 123 | } rpc_sync_info_t; |
| 124 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 124 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 125 | 125 | ||
| 126 | typedef struct _split_shared_memory_t { | 126 | typedef struct _split_shared_memory_t { |
| 127 | #ifdef USE_I2C | 127 | #ifdef USE_I2C |
| 128 | int8_t transaction_id; | 128 | int8_t transaction_id; |
| 129 | #endif // USE_I2C | 129 | #endif // USE_I2C |
| 130 | 130 | ||
| 131 | split_slave_matrix_sync_t smatrix; | 131 | split_slave_matrix_sync_t smatrix; |
| 132 | 132 | ||
| 133 | #ifdef SPLIT_TRANSPORT_MIRROR | 133 | #ifdef SPLIT_TRANSPORT_MIRROR |
| 134 | split_master_matrix_sync_t mmatrix; | 134 | split_master_matrix_sync_t mmatrix; |
| 135 | #endif // SPLIT_TRANSPORT_MIRROR | 135 | #endif // SPLIT_TRANSPORT_MIRROR |
| 136 | 136 | ||
| 137 | #ifdef ENCODER_ENABLE | 137 | #ifdef ENCODER_ENABLE |
| 138 | split_slave_encoder_sync_t encoders; | 138 | split_slave_encoder_sync_t encoders; |
| 139 | #endif // ENCODER_ENABLE | 139 | #endif // ENCODER_ENABLE |
| 140 | 140 | ||
| 141 | #ifndef DISABLE_SYNC_TIMER | 141 | #ifndef DISABLE_SYNC_TIMER |
| 142 | uint32_t sync_timer; | 142 | uint32_t sync_timer; |
| 143 | #endif // DISABLE_SYNC_TIMER | 143 | #endif // DISABLE_SYNC_TIMER |
| 144 | 144 | ||
| 145 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 145 | #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 146 | split_layers_sync_t layers; | 146 | split_layers_sync_t layers; |
| 147 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) | 147 | #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) |
| 148 | 148 | ||
| 149 | #ifdef SPLIT_LED_STATE_ENABLE | 149 | #ifdef SPLIT_LED_STATE_ENABLE |
| 150 | uint8_t led_state; | 150 | uint8_t led_state; |
| 151 | #endif // SPLIT_LED_STATE_ENABLE | 151 | #endif // SPLIT_LED_STATE_ENABLE |
| 152 | 152 | ||
| 153 | #ifdef SPLIT_MODS_ENABLE | 153 | #ifdef SPLIT_MODS_ENABLE |
| 154 | split_mods_sync_t mods; | 154 | split_mods_sync_t mods; |
| 155 | #endif // SPLIT_MODS_ENABLE | 155 | #endif // SPLIT_MODS_ENABLE |
| 156 | 156 | ||
| 157 | #ifdef BACKLIGHT_ENABLE | 157 | #ifdef BACKLIGHT_ENABLE |
| 158 | uint8_t backlight_level; | 158 | uint8_t backlight_level; |
| 159 | #endif // BACKLIGHT_ENABLE | 159 | #endif // BACKLIGHT_ENABLE |
| 160 | 160 | ||
| 161 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 161 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 162 | rgblight_syncinfo_t rgblight_sync; | 162 | rgblight_syncinfo_t rgblight_sync; |
| 163 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 163 | #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| 164 | 164 | ||
| 165 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 165 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 166 | led_matrix_sync_t led_matrix_sync; | 166 | led_matrix_sync_t led_matrix_sync; |
| 167 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 167 | #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 168 | 168 | ||
| 169 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 169 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 170 | rgb_matrix_sync_t rgb_matrix_sync; | 170 | rgb_matrix_sync_t rgb_matrix_sync; |
| 171 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 171 | #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 172 | 172 | ||
| 173 | #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 173 | #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 174 | uint8_t current_wpm; | 174 | uint8_t current_wpm; |
| 175 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 175 | #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
| 176 | 176 | ||
| 177 | #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 177 | #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 178 | uint8_t current_oled_state; | 178 | uint8_t current_oled_state; |
| 179 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 179 | #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
| 180 | 180 | ||
| 181 | #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 181 | #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 182 | uint8_t current_st7565_state; | 182 | uint8_t current_st7565_state; |
| 183 | #endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 183 | #endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE) |
| 184 | 184 | ||
| 185 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 185 | #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 186 | split_slave_pointing_sync_t pointing; | 186 | split_slave_pointing_sync_t pointing; |
| 187 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) | 187 | #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) |
| 188 | 188 | ||
| 189 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 189 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 190 | rpc_sync_info_t rpc_info; | 190 | rpc_sync_info_t rpc_info; |
| 191 | uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE]; | 191 | uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE]; |
| 192 | uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE]; | 192 | uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE]; |
| 193 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 193 | #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
| 194 | } split_shared_memory_t; | 194 | } split_shared_memory_t; |
| 195 | 195 | ||
| 196 | extern split_shared_memory_t *const split_shmem; | 196 | extern split_shared_memory_t *const split_shmem; |
diff --git a/quantum/sync_timer.c b/quantum/sync_timer.c index de24b463b6..217891233f 100644 --- a/quantum/sync_timer.c +++ b/quantum/sync_timer.c | |||
| @@ -29,7 +29,9 @@ SOFTWARE. | |||
| 29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | 29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) |
| 30 | volatile int32_t sync_timer_ms; | 30 | volatile int32_t sync_timer_ms; |
| 31 | 31 | ||
| 32 | void sync_timer_init(void) { sync_timer_ms = 0; } | 32 | void sync_timer_init(void) { |
| 33 | sync_timer_ms = 0; | ||
| 34 | } | ||
| 33 | 35 | ||
| 34 | void sync_timer_update(uint32_t time) { | 36 | void sync_timer_update(uint32_t time) { |
| 35 | if (is_keyboard_master()) return; | 37 | if (is_keyboard_master()) return; |
diff --git a/quantum/velocikey.c b/quantum/velocikey.c index 6b7f82d950..58e14215bb 100644 --- a/quantum/velocikey.c +++ b/quantum/velocikey.c | |||
| @@ -13,7 +13,9 @@ | |||
| 13 | #define TYPING_SPEED_MAX_VALUE 200 | 13 | #define TYPING_SPEED_MAX_VALUE 200 |
| 14 | uint8_t typing_speed = 0; | 14 | uint8_t typing_speed = 0; |
| 15 | 15 | ||
| 16 | bool velocikey_enabled(void) { return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; } | 16 | bool velocikey_enabled(void) { |
| 17 | return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; | ||
| 18 | } | ||
| 17 | 19 | ||
| 18 | void velocikey_toggle(void) { | 20 | void velocikey_toggle(void) { |
| 19 | if (velocikey_enabled()) | 21 | if (velocikey_enabled()) |
| @@ -39,4 +41,6 @@ void velocikey_decelerate(void) { | |||
| 39 | } | 41 | } |
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); } | 44 | uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { |
| 45 | return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); | ||
| 46 | } | ||
diff --git a/quantum/via.c b/quantum/via.c index a3bd82d9b3..05ab799cbb 100644 --- a/quantum/via.c +++ b/quantum/via.c | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | #include "raw_hid.h" | 45 | #include "raw_hid.h" |
| 46 | #include "dynamic_keymap.h" | 46 | #include "dynamic_keymap.h" |
| 47 | #include "eeprom.h" | 47 | #include "eeprom.h" |
| 48 | #include "version.h" // for QMK_BUILDDATE used in EEPROM magic | 48 | #include "version.h" // for QMK_BUILDDATE used in EEPROM magic |
| 49 | #include "via_ensure_keycode.h" | 49 | #include "via_ensure_keycode.h" |
| 50 | 50 | ||
| 51 | // Forward declare some helpers. | 51 | // Forward declare some helpers. |
| @@ -62,7 +62,7 @@ void via_qmk_rgblight_get_value(uint8_t *data); | |||
| 62 | // Can be called in an overriding via_init_kb() to test if keyboard level code usage of | 62 | // Can be called in an overriding via_init_kb() to test if keyboard level code usage of |
| 63 | // EEPROM is invalid and use/save defaults. | 63 | // EEPROM is invalid and use/save defaults. |
| 64 | bool via_eeprom_is_valid(void) { | 64 | bool via_eeprom_is_valid(void) { |
| 65 | char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" | 65 | char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" |
| 66 | uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); | 66 | uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); |
| 67 | uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); | 67 | uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); |
| 68 | uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); | 68 | uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); |
| @@ -73,7 +73,7 @@ bool via_eeprom_is_valid(void) { | |||
| 73 | // Sets VIA/keyboard level usage of EEPROM to valid/invalid | 73 | // Sets VIA/keyboard level usage of EEPROM to valid/invalid |
| 74 | // Keyboard level code (eg. via_init_kb()) should not call this | 74 | // Keyboard level code (eg. via_init_kb()) should not call this |
| 75 | void via_eeprom_set_valid(bool valid) { | 75 | void via_eeprom_set_valid(bool valid) { |
| 76 | char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" | 76 | char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" |
| 77 | uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); | 77 | uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); |
| 78 | uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); | 78 | uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); |
| 79 | uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); | 79 | uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); |
| @@ -347,13 +347,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { | |||
| 347 | } | 347 | } |
| 348 | case id_dynamic_keymap_macro_get_buffer: { | 348 | case id_dynamic_keymap_macro_get_buffer: { |
| 349 | uint16_t offset = (command_data[0] << 8) | command_data[1]; | 349 | uint16_t offset = (command_data[0] << 8) | command_data[1]; |
| 350 | uint16_t size = command_data[2]; // size <= 28 | 350 | uint16_t size = command_data[2]; // size <= 28 |
| 351 | dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]); | 351 | dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]); |
| 352 | break; | 352 | break; |
| 353 | } | 353 | } |
| 354 | case id_dynamic_keymap_macro_set_buffer: { | 354 | case id_dynamic_keymap_macro_set_buffer: { |
| 355 | uint16_t offset = (command_data[0] << 8) | command_data[1]; | 355 | uint16_t offset = (command_data[0] << 8) | command_data[1]; |
| 356 | uint16_t size = command_data[2]; // size <= 28 | 356 | uint16_t size = command_data[2]; // size <= 28 |
| 357 | dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]); | 357 | dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]); |
| 358 | break; | 358 | break; |
| 359 | } | 359 | } |
| @@ -367,13 +367,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { | |||
| 367 | } | 367 | } |
| 368 | case id_dynamic_keymap_get_buffer: { | 368 | case id_dynamic_keymap_get_buffer: { |
| 369 | uint16_t offset = (command_data[0] << 8) | command_data[1]; | 369 | uint16_t offset = (command_data[0] << 8) | command_data[1]; |
| 370 | uint16_t size = command_data[2]; // size <= 28 | 370 | uint16_t size = command_data[2]; // size <= 28 |
| 371 | dynamic_keymap_get_buffer(offset, size, &command_data[3]); | 371 | dynamic_keymap_get_buffer(offset, size, &command_data[3]); |
| 372 | break; | 372 | break; |
| 373 | } | 373 | } |
| 374 | case id_dynamic_keymap_set_buffer: { | 374 | case id_dynamic_keymap_set_buffer: { |
| 375 | uint16_t offset = (command_data[0] << 8) | command_data[1]; | 375 | uint16_t offset = (command_data[0] << 8) | command_data[1]; |
| 376 | uint16_t size = command_data[2]; // size <= 28 | 376 | uint16_t size = command_data[2]; // size <= 28 |
| 377 | dynamic_keymap_set_buffer(offset, size, &command_data[3]); | 377 | dynamic_keymap_set_buffer(offset, size, &command_data[3]); |
| 378 | break; | 378 | break; |
| 379 | } | 379 | } |
| @@ -438,7 +438,7 @@ void via_qmk_backlight_set_value(uint8_t *data) { | |||
| 438 | } | 438 | } |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | #endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) | 441 | #endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) |
| 442 | 442 | ||
| 443 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | 443 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) |
| 444 | 444 | ||
| @@ -494,4 +494,4 @@ void via_qmk_rgblight_set_value(uint8_t *data) { | |||
| 494 | } | 494 | } |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | #endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE) | 497 | #endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE) |
diff --git a/quantum/via.h b/quantum/via.h index 5d16917dfa..ac29a58902 100644 --- a/quantum/via.h +++ b/quantum/via.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #pragma once | 17 | #pragma once |
| 18 | 18 | ||
| 19 | #include "eeconfig.h" // for EECONFIG_SIZE | 19 | #include "eeconfig.h" // for EECONFIG_SIZE |
| 20 | 20 | ||
| 21 | // Keyboard level code can change where VIA stores the magic. | 21 | // Keyboard level code can change where VIA stores the magic. |
| 22 | // The magic is the build date YYMMDD encoded as BCD in 3 bytes, | 22 | // The magic is the build date YYMMDD encoded as BCD in 3 bytes, |
| @@ -59,7 +59,7 @@ | |||
| 59 | #define VIA_PROTOCOL_VERSION 0x0009 | 59 | #define VIA_PROTOCOL_VERSION 0x0009 |
| 60 | 60 | ||
| 61 | enum via_command_id { | 61 | enum via_command_id { |
| 62 | id_get_protocol_version = 0x01, // always 0x01 | 62 | id_get_protocol_version = 0x01, // always 0x01 |
| 63 | id_get_keyboard_value = 0x02, | 63 | id_get_keyboard_value = 0x02, |
| 64 | id_set_keyboard_value = 0x03, | 64 | id_set_keyboard_value = 0x03, |
| 65 | id_dynamic_keymap_get_keycode = 0x04, | 65 | id_dynamic_keymap_get_keycode = 0x04, |
| @@ -82,7 +82,7 @@ enum via_command_id { | |||
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | enum via_keyboard_value_id { | 84 | enum via_keyboard_value_id { |
| 85 | id_uptime = 0x01, // | 85 | id_uptime = 0x01, // |
| 86 | id_layout_options = 0x02, | 86 | id_layout_options = 0x02, |
| 87 | id_switch_matrix_state = 0x03 | 87 | id_switch_matrix_state = 0x03 |
| 88 | }; | 88 | }; |
diff --git a/quantum/wpm.c b/quantum/wpm.c index 62d4128b8e..b2e6fe0430 100644 --- a/quantum/wpm.c +++ b/quantum/wpm.c | |||
| @@ -55,12 +55,20 @@ static uint8_t prev_wpm = 0; | |||
| 55 | static uint8_t next_wpm = 0; | 55 | static uint8_t next_wpm = 0; |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; } | 58 | void set_current_wpm(uint8_t new_wpm) { |
| 59 | uint8_t get_current_wpm(void) { return current_wpm; } | 59 | current_wpm = new_wpm; |
| 60 | } | ||
| 61 | uint8_t get_current_wpm(void) { | ||
| 62 | return current_wpm; | ||
| 63 | } | ||
| 60 | 64 | ||
| 61 | bool wpm_keycode(uint16_t keycode) { return wpm_keycode_kb(keycode); } | 65 | bool wpm_keycode(uint16_t keycode) { |
| 66 | return wpm_keycode_kb(keycode); | ||
| 67 | } | ||
| 62 | 68 | ||
| 63 | __attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { return wpm_keycode_user(keycode); } | 69 | __attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { |
| 70 | return wpm_keycode_user(keycode); | ||
| 71 | } | ||
| 64 | 72 | ||
| 65 | __attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) { | 73 | __attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) { |
| 66 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { | 74 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { |
| @@ -122,7 +130,7 @@ void decay_wpm(void) { | |||
| 122 | uint32_t duration = (((periods)*PERIOD_DURATION) + elapsed); | 130 | uint32_t duration = (((periods)*PERIOD_DURATION) + elapsed); |
| 123 | int32_t wpm_now = (60000 * presses) / (duration * WPM_ESTIMATED_WORD_SIZE); | 131 | int32_t wpm_now = (60000 * presses) / (duration * WPM_ESTIMATED_WORD_SIZE); |
| 124 | 132 | ||
| 125 | if (wpm_now < 0) // set some reasonable WPM measurement limits | 133 | if (wpm_now < 0) // set some reasonable WPM measurement limits |
| 126 | wpm_now = 0; | 134 | wpm_now = 0; |
| 127 | if (wpm_now > 240) wpm_now = 240; | 135 | if (wpm_now > 240) wpm_now = 240; |
| 128 | 136 | ||
| @@ -133,7 +141,7 @@ void decay_wpm(void) { | |||
| 133 | elapsed = 0; | 141 | elapsed = 0; |
| 134 | wpm_timer = timer_read32(); | 142 | wpm_timer = timer_read32(); |
| 135 | } | 143 | } |
| 136 | if (presses < 2) // don't guess high WPM based on a single keypress. | 144 | if (presses < 2) // don't guess high WPM based on a single keypress. |
| 137 | wpm_now = 0; | 145 | wpm_now = 0; |
| 138 | 146 | ||
| 139 | #if defined(WPM_LAUNCH_CONTROL) | 147 | #if defined(WPM_LAUNCH_CONTROL) |
| @@ -150,7 +158,7 @@ void decay_wpm(void) { | |||
| 150 | wpm_now = 0; | 158 | wpm_now = 0; |
| 151 | period_presses[0] = 0; | 159 | period_presses[0] = 0; |
| 152 | } | 160 | } |
| 153 | #endif // WPM_LAUNCH_CONTROL | 161 | #endif // WPM_LAUNCH_CONTROL |
| 154 | 162 | ||
| 155 | #if defined(WPM_UNFILTERED) | 163 | #if defined(WPM_UNFILTERED) |
| 156 | current_wpm = wpm_now; | 164 | current_wpm = wpm_now; |
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index e148c76beb..7908e64f7f 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp | |||
| @@ -36,7 +36,7 @@ std::vector<uint8_t> get_keys(const report_keyboard_t& report) { | |||
| 36 | std::sort(result.begin(), result.end()); | 36 | std::sort(result.begin(), result.end()); |
| 37 | return result; | 37 | return result; |
| 38 | } | 38 | } |
| 39 | } // namespace | 39 | } // namespace |
| 40 | 40 | ||
| 41 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { | 41 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { |
| 42 | auto lhskeys = get_keys(lhs); | 42 | auto lhskeys = get_keys(lhs); |
| @@ -72,8 +72,14 @@ KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; } | 75 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { |
| 76 | return m_report == report; | ||
| 77 | } | ||
| 76 | 78 | ||
| 77 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; } | 79 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { |
| 80 | *os << "is equal to " << m_report; | ||
| 81 | } | ||
| 78 | 82 | ||
| 79 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; } | 83 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { |
| 84 | *os << "is not equal to " << m_report; | ||
| 85 | } | ||
diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c index 9a92a801c7..7b24d560e3 100644 --- a/tests/test_common/matrix.c +++ b/tests/test_common/matrix.c | |||
| @@ -30,7 +30,9 @@ uint8_t matrix_scan(void) { | |||
| 30 | return 1; | 30 | return 1; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } | 33 | matrix_row_t matrix_get_row(uint8_t row) { |
| 34 | return matrix[row]; | ||
| 35 | } | ||
| 34 | 36 | ||
| 35 | void matrix_print(void) {} | 37 | void matrix_print(void) {} |
| 36 | 38 | ||
| @@ -38,10 +40,16 @@ void matrix_init_kb(void) {} | |||
| 38 | 40 | ||
| 39 | void matrix_scan_kb(void) {} | 41 | void matrix_scan_kb(void) {} |
| 40 | 42 | ||
| 41 | void press_key(uint8_t col, uint8_t row) { matrix[row] |= 1 << col; } | 43 | void press_key(uint8_t col, uint8_t row) { |
| 44 | matrix[row] |= 1 << col; | ||
| 45 | } | ||
| 42 | 46 | ||
| 43 | void release_key(uint8_t col, uint8_t row) { matrix[row] &= ~(1 << col); } | 47 | void release_key(uint8_t col, uint8_t row) { |
| 48 | matrix[row] &= ~(1 << col); | ||
| 49 | } | ||
| 44 | 50 | ||
| 45 | void clear_all_keys(void) { memset(matrix, 0, sizeof(matrix)); } | 51 | void clear_all_keys(void) { |
| 52 | memset(matrix, 0, sizeof(matrix)); | ||
| 53 | } | ||
| 46 | 54 | ||
| 47 | void led_set(uint8_t usb_led) {} | 55 | void led_set(uint8_t usb_led) {} |
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 2fa2b6a2e7..68f1dfd17d 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
| @@ -23,17 +23,27 @@ TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::sen | |||
| 23 | m_this = this; | 23 | m_this = this; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | TestDriver::~TestDriver() { m_this = nullptr; } | 26 | TestDriver::~TestDriver() { |
| 27 | m_this = nullptr; | ||
| 28 | } | ||
| 27 | 29 | ||
| 28 | uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; } | 30 | uint8_t TestDriver::keyboard_leds(void) { |
| 31 | return m_this->m_leds; | ||
| 32 | } | ||
| 29 | 33 | ||
| 30 | void TestDriver::send_keyboard(report_keyboard_t* report) { | 34 | void TestDriver::send_keyboard(report_keyboard_t* report) { |
| 31 | test_logger.trace() << *report; | 35 | test_logger.trace() << *report; |
| 32 | m_this->send_keyboard_mock(*report); | 36 | m_this->send_keyboard_mock(*report); |
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } | 39 | void TestDriver::send_mouse(report_mouse_t* report) { |
| 40 | m_this->send_mouse_mock(*report); | ||
| 41 | } | ||
| 36 | 42 | ||
| 37 | void TestDriver::send_system(uint16_t data) { m_this->send_system_mock(data); } | 43 | void TestDriver::send_system(uint16_t data) { |
| 44 | m_this->send_system_mock(data); | ||
| 45 | } | ||
| 38 | 46 | ||
| 39 | void TestDriver::send_consumer(uint16_t data) { m_this->send_consumer(data); } | 47 | void TestDriver::send_consumer(uint16_t data) { |
| 48 | m_this->send_consumer(data); | ||
| 49 | } | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index 91bf3e779e..c98a679554 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -55,7 +55,9 @@ void TestFixture::SetUpTestCase() { | |||
| 55 | 55 | ||
| 56 | void TestFixture::TearDownTestCase() {} | 56 | void TestFixture::TearDownTestCase() {} |
| 57 | 57 | ||
| 58 | TestFixture::TestFixture() { m_this = this; } | 58 | TestFixture::TestFixture() { |
| 59 | m_this = this; | ||
| 60 | } | ||
| 59 | 61 | ||
| 60 | TestFixture::~TestFixture() { | 62 | TestFixture::~TestFixture() { |
| 61 | test_logger.info() << "TestFixture clean-up start." << std::endl; | 63 | test_logger.info() << "TestFixture clean-up start." << std::endl; |
diff --git a/tests/test_common/test_logger.cpp b/tests/test_common/test_logger.cpp index 959fdde5ec..efc7719d13 100644 --- a/tests/test_common/test_logger.cpp +++ b/tests/test_common/test_logger.cpp | |||
| @@ -34,6 +34,10 @@ TestLogger& TestLogger::error() { | |||
| 34 | return *this; | 34 | return *this; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void TestLogger::reset() { this->m_log.str(""); }; | 37 | void TestLogger::reset() { |
| 38 | this->m_log.str(""); | ||
| 39 | }; | ||
| 38 | 40 | ||
| 39 | void TestLogger::print_log() { std::cerr << this->m_log.str(); } | 41 | void TestLogger::print_log() { |
| 42 | std::cerr << this->m_log.str(); | ||
| 43 | } | ||
diff --git a/tmk_core/protocol/arm_atsam/adc.c b/tmk_core/protocol/arm_atsam/adc.c index 1ef1b11d57..3afcbddf10 100644 --- a/tmk_core/protocol/arm_atsam/adc.c +++ b/tmk_core/protocol/arm_atsam/adc.c | |||
| @@ -27,10 +27,10 @@ uint16_t v_con_2_boot; | |||
| 27 | void ADC0_clock_init(void) { | 27 | void ADC0_clock_init(void) { |
| 28 | DBGC(DC_ADC0_CLOCK_INIT_BEGIN); | 28 | DBGC(DC_ADC0_CLOCK_INIT_BEGIN); |
| 29 | 29 | ||
| 30 | MCLK->APBDMASK.bit.ADC0_ = 1; // ADC0 Clock Enable | 30 | MCLK->APBDMASK.bit.ADC0_ = 1; // ADC0 Clock Enable |
| 31 | 31 | ||
| 32 | GCLK->PCHCTRL[ADC0_GCLK_ID].bit.GEN = GEN_OSC0; // Select generator clock | 32 | GCLK->PCHCTRL[ADC0_GCLK_ID].bit.GEN = GEN_OSC0; // Select generator clock |
| 33 | GCLK->PCHCTRL[ADC0_GCLK_ID].bit.CHEN = 1; // Enable peripheral clock | 33 | GCLK->PCHCTRL[ADC0_GCLK_ID].bit.CHEN = 1; // Enable peripheral clock |
| 34 | 34 | ||
| 35 | DBGC(DC_ADC0_CLOCK_INIT_COMPLETE); | 35 | DBGC(DC_ADC0_CLOCK_INIT_COMPLETE); |
| 36 | } | 36 | } |
| @@ -39,15 +39,15 @@ void ADC0_init(void) { | |||
| 39 | DBGC(DC_ADC0_INIT_BEGIN); | 39 | DBGC(DC_ADC0_INIT_BEGIN); |
| 40 | 40 | ||
| 41 | // MCU | 41 | // MCU |
| 42 | PORT->Group[1].DIRCLR.reg = 1 << 0; // PB00 as input 5V | 42 | PORT->Group[1].DIRCLR.reg = 1 << 0; // PB00 as input 5V |
| 43 | PORT->Group[1].DIRCLR.reg = 1 << 1; // PB01 as input CON2 | 43 | PORT->Group[1].DIRCLR.reg = 1 << 1; // PB01 as input CON2 |
| 44 | PORT->Group[1].DIRCLR.reg = 1 << 2; // PB02 as input CON1 | 44 | PORT->Group[1].DIRCLR.reg = 1 << 2; // PB02 as input CON1 |
| 45 | PORT->Group[1].PMUX[0].bit.PMUXE = 1; // PB00 mux select B ADC 5V | 45 | PORT->Group[1].PMUX[0].bit.PMUXE = 1; // PB00 mux select B ADC 5V |
| 46 | PORT->Group[1].PMUX[0].bit.PMUXO = 1; // PB01 mux select B ADC CON2 | 46 | PORT->Group[1].PMUX[0].bit.PMUXO = 1; // PB01 mux select B ADC CON2 |
| 47 | PORT->Group[1].PMUX[1].bit.PMUXE = 1; // PB02 mux select B ADC CON1 | 47 | PORT->Group[1].PMUX[1].bit.PMUXE = 1; // PB02 mux select B ADC CON1 |
| 48 | PORT->Group[1].PINCFG[0].bit.PMUXEN = 1; // PB01 mux ADC Enable 5V | 48 | PORT->Group[1].PINCFG[0].bit.PMUXEN = 1; // PB01 mux ADC Enable 5V |
| 49 | PORT->Group[1].PINCFG[1].bit.PMUXEN = 1; // PB01 mux ADC Enable CON2 | 49 | PORT->Group[1].PINCFG[1].bit.PMUXEN = 1; // PB01 mux ADC Enable CON2 |
| 50 | PORT->Group[1].PINCFG[2].bit.PMUXEN = 1; // PB02 mux ADC Enable CON1 | 50 | PORT->Group[1].PINCFG[2].bit.PMUXEN = 1; // PB02 mux ADC Enable CON1 |
| 51 | 51 | ||
| 52 | // ADC | 52 | // ADC |
| 53 | ADC0->CTRLA.bit.SWRST = 1; | 53 | ADC0->CTRLA.bit.SWRST = 1; |
| @@ -81,7 +81,7 @@ void ADC0_init(void) { | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | // Settling | 83 | // Settling |
| 84 | ADC0->SAMPCTRL.bit.SAMPLEN = 45; // Sampling Time Length: 1-63, 1 ADC CLK per | 84 | ADC0->SAMPCTRL.bit.SAMPLEN = 45; // Sampling Time Length: 1-63, 1 ADC CLK per |
| 85 | while (ADC0->SYNCBUSY.bit.SAMPCTRL) { | 85 | while (ADC0->SYNCBUSY.bit.SAMPCTRL) { |
| 86 | DBGC(DC_ADC0_SAMPCTRL_SYNCING_1); | 86 | DBGC(DC_ADC0_SAMPCTRL_SYNCING_1); |
| 87 | } | 87 | } |
diff --git a/tmk_core/protocol/arm_atsam/adc.h b/tmk_core/protocol/arm_atsam/adc.h index 9ab653e5a2..74fbb0e66f 100644 --- a/tmk_core/protocol/arm_atsam/adc.h +++ b/tmk_core/protocol/arm_atsam/adc.h | |||
| @@ -34,4 +34,4 @@ extern uint16_t v_con_2_boot; | |||
| 34 | void ADC0_clock_init(void); | 34 | void ADC0_clock_init(void); |
| 35 | void ADC0_init(void); | 35 | void ADC0_init(void); |
| 36 | 36 | ||
| 37 | #endif //_ADC_H_ | 37 | #endif //_ADC_H_ |
diff --git a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h index 319ff8487d..db9827f6a2 100644 --- a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h +++ b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h | |||
| @@ -42,6 +42,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 42 | # include "./usb/udc.h" | 42 | # include "./usb/udc.h" |
| 43 | # include "./usb/udi_cdc.h" | 43 | # include "./usb/udi_cdc.h" |
| 44 | 44 | ||
| 45 | #endif // MD_BOOTLOADER | 45 | #endif // MD_BOOTLOADER |
| 46 | 46 | ||
| 47 | #endif //_ARM_ATSAM_PROTOCOL_H_ | 47 | #endif //_ARM_ATSAM_PROTOCOL_H_ |
diff --git a/tmk_core/protocol/arm_atsam/clks.c b/tmk_core/protocol/arm_atsam/clks.c index 84ed6d83af..9b9475c616 100644 --- a/tmk_core/protocol/arm_atsam/clks.c +++ b/tmk_core/protocol/arm_atsam/clks.c | |||
| @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | volatile clk_t system_clks; | 22 | volatile clk_t system_clks; |
| 23 | volatile uint64_t ms_clk; | 23 | volatile uint64_t ms_clk; |
| 24 | uint32_t usec_delay_mult; | 24 | uint32_t usec_delay_mult; |
| 25 | #define USEC_DELAY_LOOP_CYCLES 3 // Sum of instruction cycles in us delay loop | 25 | #define USEC_DELAY_LOOP_CYCLES 3 // Sum of instruction cycles in us delay loop |
| 26 | 26 | ||
| 27 | const uint32_t sercom_apbbase[] = {(uint32_t)SERCOM0, (uint32_t)SERCOM1, (uint32_t)SERCOM2, (uint32_t)SERCOM3, (uint32_t)SERCOM4, (uint32_t)SERCOM5}; | 27 | const uint32_t sercom_apbbase[] = {(uint32_t)SERCOM0, (uint32_t)SERCOM1, (uint32_t)SERCOM2, (uint32_t)SERCOM3, (uint32_t)SERCOM4, (uint32_t)SERCOM5}; |
| 28 | const uint8_t sercom_pchan[] = {7, 8, 23, 24, 34, 35}; | 28 | const uint8_t sercom_pchan[] = {7, 8, 23, 24, 34, 35}; |
| @@ -59,9 +59,9 @@ void CLK_oscctrl_init(void) { | |||
| 59 | while (posctrl->Dpll[USE_DPLL_IND].DPLLSYNCBUSY.bit.ENABLE) { | 59 | while (posctrl->Dpll[USE_DPLL_IND].DPLLSYNCBUSY.bit.ENABLE) { |
| 60 | DBGC(DC_CLK_OSC_INIT_DPLL_SYNC_DISABLE); | 60 | DBGC(DC_CLK_OSC_INIT_DPLL_SYNC_DISABLE); |
| 61 | } | 61 | } |
| 62 | posctrl->Dpll[USE_DPLL_IND].DPLLCTRLB.bit.REFCLK = 2; // select XOSC0 (16MHz) | 62 | posctrl->Dpll[USE_DPLL_IND].DPLLCTRLB.bit.REFCLK = 2; // select XOSC0 (16MHz) |
| 63 | posctrl->Dpll[USE_DPLL_IND].DPLLCTRLB.bit.DIV = 7; // 16 MHz / (2 * (7 + 1)) = 1 MHz | 63 | posctrl->Dpll[USE_DPLL_IND].DPLLCTRLB.bit.DIV = 7; // 16 MHz / (2 * (7 + 1)) = 1 MHz |
| 64 | posctrl->Dpll[USE_DPLL_IND].DPLLRATIO.bit.LDR = PLL_RATIO; // 1 MHz * (PLL_RATIO(47) + 1) = 48MHz | 64 | posctrl->Dpll[USE_DPLL_IND].DPLLRATIO.bit.LDR = PLL_RATIO; // 1 MHz * (PLL_RATIO(47) + 1) = 48MHz |
| 65 | while (posctrl->Dpll[USE_DPLL_IND].DPLLSYNCBUSY.bit.DPLLRATIO) { | 65 | while (posctrl->Dpll[USE_DPLL_IND].DPLLSYNCBUSY.bit.DPLLRATIO) { |
| 66 | DBGC(DC_CLK_OSC_INIT_DPLL_SYNC_RATIO); | 66 | DBGC(DC_CLK_OSC_INIT_DPLL_SYNC_RATIO); |
| 67 | } | 67 | } |
| @@ -87,7 +87,7 @@ void CLK_oscctrl_init(void) { | |||
| 87 | system_clks.freq_gclk[0] = system_clks.freq_dpll[0]; | 87 | system_clks.freq_gclk[0] = system_clks.freq_dpll[0]; |
| 88 | 88 | ||
| 89 | usec_delay_mult = system_clks.freq_gclk[0] / (USEC_DELAY_LOOP_CYCLES * 1000000); | 89 | usec_delay_mult = system_clks.freq_gclk[0] / (USEC_DELAY_LOOP_CYCLES * 1000000); |
| 90 | if (usec_delay_mult < 1) usec_delay_mult = 1; // Never allow a multiplier of zero | 90 | if (usec_delay_mult < 1) usec_delay_mult = 1; // Never allow a multiplier of zero |
| 91 | 91 | ||
| 92 | DBGC(DC_CLK_OSC_INIT_COMPLETE); | 92 | DBGC(DC_CLK_OSC_INIT_COMPLETE); |
| 93 | } | 93 | } |
| @@ -240,7 +240,7 @@ uint32_t CLK_enable_timebase(void) { | |||
| 240 | // ptc4->COUNT16.DBGCTRL.bit.DBGRUN = 1; | 240 | // ptc4->COUNT16.DBGCTRL.bit.DBGRUN = 1; |
| 241 | 241 | ||
| 242 | // wave mode | 242 | // wave mode |
| 243 | ptc4->COUNT16.WAVE.bit.WAVEGEN = 1; // MFRQ match frequency mode, toggle each CC match | 243 | ptc4->COUNT16.WAVE.bit.WAVEGEN = 1; // MFRQ match frequency mode, toggle each CC match |
| 244 | // generate event for next stage | 244 | // generate event for next stage |
| 245 | ptc4->COUNT16.EVCTRL.bit.MCEO0 = 1; | 245 | ptc4->COUNT16.EVCTRL.bit.MCEO0 = 1; |
| 246 | 246 | ||
| @@ -272,9 +272,9 @@ uint32_t CLK_enable_timebase(void) { | |||
| 272 | DBGC(DC_CLK_ENABLE_TIMEBASE_TC0_SYNC_SWRST_2); | 272 | DBGC(DC_CLK_ENABLE_TIMEBASE_TC0_SYNC_SWRST_2); |
| 273 | } | 273 | } |
| 274 | // CTRLA as default | 274 | // CTRLA as default |
| 275 | ptc0->COUNT32.CTRLA.bit.MODE = 2; // 32 bit mode | 275 | ptc0->COUNT32.CTRLA.bit.MODE = 2; // 32 bit mode |
| 276 | ptc0->COUNT32.EVCTRL.bit.TCEI = 1; // enable incoming events | 276 | ptc0->COUNT32.EVCTRL.bit.TCEI = 1; // enable incoming events |
| 277 | ptc0->COUNT32.EVCTRL.bit.EVACT = 2; // count events | 277 | ptc0->COUNT32.EVCTRL.bit.EVACT = 2; // count events |
| 278 | 278 | ||
| 279 | DBGC(DC_CLK_ENABLE_TIMEBASE_TC0_COMPLETE); | 279 | DBGC(DC_CLK_ENABLE_TIMEBASE_TC0_COMPLETE); |
| 280 | 280 | ||
| @@ -284,10 +284,10 @@ uint32_t CLK_enable_timebase(void) { | |||
| 284 | pmclk->APBBMASK.bit.EVSYS_ = 1; | 284 | pmclk->APBBMASK.bit.EVSYS_ = 1; |
| 285 | pgclk->PCHCTRL[EVSYS_GCLK_ID_0].bit.GEN = GEN_TC45; | 285 | pgclk->PCHCTRL[EVSYS_GCLK_ID_0].bit.GEN = GEN_TC45; |
| 286 | pgclk->PCHCTRL[EVSYS_GCLK_ID_0].bit.CHEN = 1; | 286 | pgclk->PCHCTRL[EVSYS_GCLK_ID_0].bit.CHEN = 1; |
| 287 | pevsys->USER[44].reg = EVSYS_ID_USER_PORT_EV_0; // TC0 will get event channel 0 | 287 | pevsys->USER[44].reg = EVSYS_ID_USER_PORT_EV_0; // TC0 will get event channel 0 |
| 288 | pevsys->Channel[0].CHANNEL.bit.EDGSEL = EVSYS_CHANNEL_EDGSEL_RISING_EDGE_Val; // Rising edge | 288 | pevsys->Channel[0].CHANNEL.bit.EDGSEL = EVSYS_CHANNEL_EDGSEL_RISING_EDGE_Val; // Rising edge |
| 289 | pevsys->Channel[0].CHANNEL.bit.PATH = EVSYS_CHANNEL_PATH_SYNCHRONOUS_Val; // Synchronous | 289 | pevsys->Channel[0].CHANNEL.bit.PATH = EVSYS_CHANNEL_PATH_SYNCHRONOUS_Val; // Synchronous |
| 290 | pevsys->Channel[0].CHANNEL.bit.EVGEN = EVSYS_ID_GEN_TC4_MCX_0; // TC4 MC0 | 290 | pevsys->Channel[0].CHANNEL.bit.EVGEN = EVSYS_ID_GEN_TC4_MCX_0; // TC4 MC0 |
| 291 | 291 | ||
| 292 | DBGC(DC_CLK_ENABLE_TIMEBASE_EVSYS_COMPLETE); | 292 | DBGC(DC_CLK_ENABLE_TIMEBASE_EVSYS_COMPLETE); |
| 293 | 293 | ||
| @@ -301,15 +301,15 @@ uint32_t CLK_enable_timebase(void) { | |||
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | void CLK_delay_us(uint32_t usec) { | 303 | void CLK_delay_us(uint32_t usec) { |
| 304 | asm("CBZ R0, return\n\t" // If usec == 0, branch to return label | 304 | asm("CBZ R0, return\n\t" // If usec == 0, branch to return label |
| 305 | ); | 305 | ); |
| 306 | asm("MULS R0, %0\n\t" // Multiply R0(usec) by usec_delay_mult and store in R0 | 306 | asm("MULS R0, %0\n\t" // Multiply R0(usec) by usec_delay_mult and store in R0 |
| 307 | ".balign 16\n\t" // Ensure loop is aligned for fastest performance | 307 | ".balign 16\n\t" // Ensure loop is aligned for fastest performance |
| 308 | "loop: SUBS R0, #1\n\t" // Subtract 1 from R0 and update flags (1 cycle) | 308 | "loop: SUBS R0, #1\n\t" // Subtract 1 from R0 and update flags (1 cycle) |
| 309 | "BNE loop\n\t" // Branch if non-zero to loop label (2 cycles) NOTE: USEC_DELAY_LOOP_CYCLES is the sum of loop cycles | 309 | "BNE loop\n\t" // Branch if non-zero to loop label (2 cycles) NOTE: USEC_DELAY_LOOP_CYCLES is the sum of loop cycles |
| 310 | "return:\n\t" // Return label | 310 | "return:\n\t" // Return label |
| 311 | : // No output registers | 311 | : // No output registers |
| 312 | : "r"(usec_delay_mult) // For %0 | 312 | : "r"(usec_delay_mult) // For %0 |
| 313 | ); | 313 | ); |
| 314 | // Note: BX LR generated | 314 | // Note: BX LR generated |
| 315 | } | 315 | } |
diff --git a/tmk_core/protocol/arm_atsam/clks.h b/tmk_core/protocol/arm_atsam/clks.h index 72df3a8e3f..6ee71aff8f 100644 --- a/tmk_core/protocol/arm_atsam/clks.h +++ b/tmk_core/protocol/arm_atsam/clks.h | |||
| @@ -24,14 +24,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | # include "config_led.h" | 24 | # include "config_led.h" |
| 25 | # include "config.h" | 25 | # include "config.h" |
| 26 | 26 | ||
| 27 | #endif // MD_BOOTLOADER | 27 | #endif // MD_BOOTLOADER |
| 28 | 28 | ||
| 29 | #define PLL_RATIO 47 // mcu frequency ((X+1)MHz) | 29 | #define PLL_RATIO 47 // mcu frequency ((X+1)MHz) |
| 30 | #define FREQ_DFLL_DEFAULT 48000000 // DFLL frequency / usb clock | 30 | #define FREQ_DFLL_DEFAULT 48000000 // DFLL frequency / usb clock |
| 31 | #define FREQ_SPI_DEFAULT 1000000 // spi to 595 shift regs | 31 | #define FREQ_SPI_DEFAULT 1000000 // spi to 595 shift regs |
| 32 | #define FREQ_I2C0_DEFAULT 100000 // i2c to hub | 32 | #define FREQ_I2C0_DEFAULT 100000 // i2c to hub |
| 33 | #define FREQ_I2C1_DEFAULT I2C_HZ // i2c to LED drivers | 33 | #define FREQ_I2C1_DEFAULT I2C_HZ // i2c to LED drivers |
| 34 | #define FREQ_TC45_DEFAULT 1000000 // 1 usec resolution | 34 | #define FREQ_TC45_DEFAULT 1000000 // 1 usec resolution |
| 35 | 35 | ||
| 36 | // I2C1 Set ~Result PWM Time (2x Drivers) | 36 | // I2C1 Set ~Result PWM Time (2x Drivers) |
| 37 | // 1000000 1090000 | 37 | // 1000000 1090000 |
| @@ -44,10 +44,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | 44 | ||
| 45 | #define FREQ_XOSC0 16000000 | 45 | #define FREQ_XOSC0 16000000 |
| 46 | 46 | ||
| 47 | #define CHAN_SERCOM_SPI 2 // shift regs | 47 | #define CHAN_SERCOM_SPI 2 // shift regs |
| 48 | #define CHAN_SERCOM_I2C0 0 // hub | 48 | #define CHAN_SERCOM_I2C0 0 // hub |
| 49 | #define CHAN_SERCOM_I2C1 1 // led drivers | 49 | #define CHAN_SERCOM_I2C1 1 // led drivers |
| 50 | #define CHAN_SERCOM_UART 3 // debug util | 50 | #define CHAN_SERCOM_UART 3 // debug util |
| 51 | 51 | ||
| 52 | // Generator clock channels | 52 | // Generator clock channels |
| 53 | #define GEN_DPLL0 0 | 53 | #define GEN_DPLL0 0 |
| @@ -86,4 +86,4 @@ uint32_t CLK_set_i2c0_freq(uint8_t sercomn, uint32_t freq); | |||
| 86 | uint32_t CLK_set_i2c1_freq(uint8_t sercomn, uint32_t freq); | 86 | uint32_t CLK_set_i2c1_freq(uint8_t sercomn, uint32_t freq); |
| 87 | void CLK_init(void); | 87 | void CLK_init(void); |
| 88 | 88 | ||
| 89 | #endif // _CLKS_H_ | 89 | #endif // _CLKS_H_ |
diff --git a/tmk_core/protocol/arm_atsam/d51_util.c b/tmk_core/protocol/arm_atsam/d51_util.c index df596f7ba2..5903233085 100644 --- a/tmk_core/protocol/arm_atsam/d51_util.c +++ b/tmk_core/protocol/arm_atsam/d51_util.c | |||
| @@ -34,7 +34,8 @@ void dbg_print(uint32_t x) { | |||
| 34 | while (t >= 0) { | 34 | while (t >= 0) { |
| 35 | p2 = t; | 35 | p2 = t; |
| 36 | p = 1; | 36 | p = 1; |
| 37 | while (p2--) p *= 10; | 37 | while (p2--) |
| 38 | p *= 10; | ||
| 38 | n = x / p; | 39 | n = x / p; |
| 39 | x -= n * p; | 40 | x -= n * p; |
| 40 | if (!n) { | 41 | if (!n) { |
| @@ -55,7 +56,7 @@ void dbg_print(uint32_t x) { | |||
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | for (w = DBG_PAUSE; w; w--) | 58 | for (w = DBG_PAUSE; w; w--) |
| 58 | ; // Long pause after number is complete | 59 | ; // Long pause after number is complete |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | // Display unsigned 32-bit number through debug led | 62 | // Display unsigned 32-bit number through debug led |
| @@ -91,7 +92,8 @@ void dled_print(uint32_t x, uint8_t long_pause) { | |||
| 91 | while (t >= 0) { | 92 | while (t >= 0) { |
| 92 | p2 = t; | 93 | p2 = t; |
| 93 | p = 1; | 94 | p = 1; |
| 94 | while (p2--) p *= 10; | 95 | while (p2--) |
| 96 | p *= 10; | ||
| 95 | n = x / p; | 97 | n = x / p; |
| 96 | x -= n * p; | 98 | x -= n * p; |
| 97 | if (!n) { | 99 | if (!n) { |
| @@ -188,12 +190,12 @@ void debug_code_init(void) { | |||
| 188 | DBGC(DC_UNSET); | 190 | DBGC(DC_UNSET); |
| 189 | 191 | ||
| 190 | // Configure Ports for EIC | 192 | // Configure Ports for EIC |
| 191 | PORT->Group[DEBUG_BOOT_TRACING_PORT].DIRCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Input | 193 | PORT->Group[DEBUG_BOOT_TRACING_PORT].DIRCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Input |
| 192 | PORT->Group[DEBUG_BOOT_TRACING_PORT].OUTSET.reg = 1 << DEBUG_BOOT_TRACING_PIN; // High | 194 | PORT->Group[DEBUG_BOOT_TRACING_PORT].OUTSET.reg = 1 << DEBUG_BOOT_TRACING_PIN; // High |
| 193 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.INEN = 1; // Input Enable | 195 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.INEN = 1; // Input Enable |
| 194 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PULLEN = 1; // Pull Enable | 196 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PULLEN = 1; // Pull Enable |
| 195 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PMUXEN = 1; // Mux Enable | 197 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PMUXEN = 1; // Mux Enable |
| 196 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PMUX[DEBUG_BOOT_TRACING_PIN / 2].bit.PMUXO = 0; // Mux A | 198 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PMUX[DEBUG_BOOT_TRACING_PIN / 2].bit.PMUXO = 0; // Mux A |
| 197 | 199 | ||
| 198 | // Enable CLK_EIC_APB | 200 | // Enable CLK_EIC_APB |
| 199 | MCLK->APBAMASK.bit.EIC_ = 1; | 201 | MCLK->APBAMASK.bit.EIC_ = 1; |
| @@ -223,12 +225,12 @@ void debug_code_disable(void) { | |||
| 223 | } | 225 | } |
| 224 | 226 | ||
| 225 | // Default port configuration | 227 | // Default port configuration |
| 226 | PORT->Group[DEBUG_BOOT_TRACING_PORT].DIRCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Input | 228 | PORT->Group[DEBUG_BOOT_TRACING_PORT].DIRCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Input |
| 227 | PORT->Group[DEBUG_BOOT_TRACING_PORT].OUTCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Low | 229 | PORT->Group[DEBUG_BOOT_TRACING_PORT].OUTCLR.reg = 1 << DEBUG_BOOT_TRACING_PIN; // Low |
| 228 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.INEN = 0; // Input Disable | 230 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.INEN = 0; // Input Disable |
| 229 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PULLEN = 0; // Pull Disable | 231 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PULLEN = 0; // Pull Disable |
| 230 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PMUXEN = 0; // Mux Disable | 232 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PINCFG[DEBUG_BOOT_TRACING_PIN].bit.PMUXEN = 0; // Mux Disable |
| 231 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PMUX[DEBUG_BOOT_TRACING_PIN / 2].bit.PMUXO = 0; // Mux A | 233 | PORT->Group[DEBUG_BOOT_TRACING_PORT].PMUX[DEBUG_BOOT_TRACING_PIN / 2].bit.PMUXO = 0; // Mux A |
| 232 | 234 | ||
| 233 | // Disable CLK_EIC_APB | 235 | // Disable CLK_EIC_APB |
| 234 | MCLK->APBAMASK.bit.EIC_ = 0; | 236 | MCLK->APBAMASK.bit.EIC_ = 0; |
| @@ -239,4 +241,4 @@ void debug_code_disable(void) { | |||
| 239 | void debug_code_init(void) {} | 241 | void debug_code_init(void) {} |
| 240 | void debug_code_disable(void) {} | 242 | void debug_code_disable(void) {} |
| 241 | 243 | ||
| 242 | #endif // DEBUG_BOOT_TRACING_ENABLE | 244 | #endif // DEBUG_BOOT_TRACING_ENABLE |
diff --git a/tmk_core/protocol/arm_atsam/d51_util.h b/tmk_core/protocol/arm_atsam/d51_util.h index 89cf338d23..d301e55411 100644 --- a/tmk_core/protocol/arm_atsam/d51_util.h +++ b/tmk_core/protocol/arm_atsam/d51_util.h | |||
| @@ -219,6 +219,6 @@ enum debug_code_list { | |||
| 219 | # define DBGC(n) \ | 219 | # define DBGC(n) \ |
| 220 | {} | 220 | {} |
| 221 | 221 | ||
| 222 | #endif // DEBUG_BOOT_TRACING_ENABLE | 222 | #endif // DEBUG_BOOT_TRACING_ENABLE |
| 223 | 223 | ||
| 224 | #endif //_D51_UTIL_H_ | 224 | #endif //_D51_UTIL_H_ |
diff --git a/tmk_core/protocol/arm_atsam/i2c_master.c b/tmk_core/protocol/arm_atsam/i2c_master.c index af046625f4..6b0b9a703b 100644 --- a/tmk_core/protocol/arm_atsam/i2c_master.c +++ b/tmk_core/protocol/arm_atsam/i2c_master.c | |||
| @@ -26,21 +26,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | # include "config_led.h" | 26 | # include "config_led.h" |
| 27 | # include "matrix.h" | 27 | # include "matrix.h" |
| 28 | 28 | ||
| 29 | # define I2C_LED_USE_DMA 1 // Set 1 to use background DMA transfers for leds, Set 0 to use inline software transfers | 29 | # define I2C_LED_USE_DMA 1 // Set 1 to use background DMA transfers for leds, Set 0 to use inline software transfers |
| 30 | 30 | ||
| 31 | DmacDescriptor dmac_desc; | 31 | DmacDescriptor dmac_desc; |
| 32 | DmacDescriptor dmac_desc_wb; | 32 | DmacDescriptor dmac_desc_wb; |
| 33 | 33 | ||
| 34 | static uint8_t i2c_led_q[I2C_Q_SIZE]; // I2C queue circular buffer | 34 | static uint8_t i2c_led_q[I2C_Q_SIZE]; // I2C queue circular buffer |
| 35 | static uint8_t i2c_led_q_s; // Start of circular buffer | 35 | static uint8_t i2c_led_q_s; // Start of circular buffer |
| 36 | static uint8_t i2c_led_q_e; // End of circular buffer | 36 | static uint8_t i2c_led_q_e; // End of circular buffer |
| 37 | static uint8_t i2c_led_q_full; // Queue full counter for reset | 37 | static uint8_t i2c_led_q_full; // Queue full counter for reset |
| 38 | 38 | ||
| 39 | static uint8_t dma_sendbuf[I2C_DMA_MAX_SEND]; // Data being written to I2C | 39 | static uint8_t dma_sendbuf[I2C_DMA_MAX_SEND]; // Data being written to I2C |
| 40 | 40 | ||
| 41 | volatile uint8_t i2c_led_q_running; | 41 | volatile uint8_t i2c_led_q_running; |
| 42 | 42 | ||
| 43 | #endif // !defined(MD_BOOTLOADER) && defined(RGB_MATRIX_ENABLE) | 43 | #endif // !defined(MD_BOOTLOADER) && defined(RGB_MATRIX_ENABLE) |
| 44 | 44 | ||
| 45 | void i2c0_init(void) { | 45 | void i2c0_init(void) { |
| 46 | DBGC(DC_I2C0_INIT_BEGIN); | 46 | DBGC(DC_I2C0_INIT_BEGIN); |
| @@ -56,23 +56,23 @@ void i2c0_init(void) { | |||
| 56 | // I2C | 56 | // I2C |
| 57 | // Note: SW Reset handled in CLK_set_i2c0_freq clks.c | 57 | // Note: SW Reset handled in CLK_set_i2c0_freq clks.c |
| 58 | 58 | ||
| 59 | SERCOM0->I2CM.CTRLA.bit.MODE = 5; // Set master mode | 59 | SERCOM0->I2CM.CTRLA.bit.MODE = 5; // Set master mode |
| 60 | 60 | ||
| 61 | SERCOM0->I2CM.CTRLA.bit.SPEED = 0; // Set to 1 for Fast-mode Plus (FM+) up to 1 MHz | 61 | SERCOM0->I2CM.CTRLA.bit.SPEED = 0; // Set to 1 for Fast-mode Plus (FM+) up to 1 MHz |
| 62 | SERCOM0->I2CM.CTRLA.bit.RUNSTDBY = 1; // Enabled | 62 | SERCOM0->I2CM.CTRLA.bit.RUNSTDBY = 1; // Enabled |
| 63 | 63 | ||
| 64 | SERCOM0->I2CM.CTRLA.bit.ENABLE = 1; // Enable the device | 64 | SERCOM0->I2CM.CTRLA.bit.ENABLE = 1; // Enable the device |
| 65 | while (SERCOM0->I2CM.SYNCBUSY.bit.ENABLE) { | 65 | while (SERCOM0->I2CM.SYNCBUSY.bit.ENABLE) { |
| 66 | DBGC(DC_I2C0_INIT_SYNC_ENABLING); | 66 | DBGC(DC_I2C0_INIT_SYNC_ENABLING); |
| 67 | } // Wait for SYNCBUSY.ENABLE to clear | 67 | } // Wait for SYNCBUSY.ENABLE to clear |
| 68 | 68 | ||
| 69 | SERCOM0->I2CM.STATUS.bit.BUSSTATE = 1; // Force into IDLE state | 69 | SERCOM0->I2CM.STATUS.bit.BUSSTATE = 1; // Force into IDLE state |
| 70 | while (SERCOM0->I2CM.SYNCBUSY.bit.SYSOP) { | 70 | while (SERCOM0->I2CM.SYNCBUSY.bit.SYSOP) { |
| 71 | DBGC(DC_I2C0_INIT_SYNC_SYSOP); | 71 | DBGC(DC_I2C0_INIT_SYNC_SYSOP); |
| 72 | } | 72 | } |
| 73 | while (SERCOM0->I2CM.STATUS.bit.BUSSTATE != 1) { | 73 | while (SERCOM0->I2CM.STATUS.bit.BUSSTATE != 1) { |
| 74 | DBGC(DC_I2C0_INIT_WAIT_IDLE); | 74 | DBGC(DC_I2C0_INIT_WAIT_IDLE); |
| 75 | } // Wait while not idle | 75 | } // Wait while not idle |
| 76 | 76 | ||
| 77 | DBGC(DC_I2C0_INIT_COMPLETE); | 77 | DBGC(DC_I2C0_INIT_COMPLETE); |
| 78 | } | 78 | } |
| @@ -139,27 +139,27 @@ void i2c1_init(void) { | |||
| 139 | /* I2C */ | 139 | /* I2C */ |
| 140 | // Note: SW Reset handled in CLK_set_i2c1_freq clks.c | 140 | // Note: SW Reset handled in CLK_set_i2c1_freq clks.c |
| 141 | 141 | ||
| 142 | SERCOM1->I2CM.CTRLA.bit.MODE = 5; // MODE: Set master mode (No sync) | 142 | SERCOM1->I2CM.CTRLA.bit.MODE = 5; // MODE: Set master mode (No sync) |
| 143 | SERCOM1->I2CM.CTRLA.bit.SPEED = 1; // SPEED: Fm+ up to 1MHz (No sync) | 143 | SERCOM1->I2CM.CTRLA.bit.SPEED = 1; // SPEED: Fm+ up to 1MHz (No sync) |
| 144 | SERCOM1->I2CM.CTRLA.bit.RUNSTDBY = 1; // RUNSTBY: Enabled (No sync) | 144 | SERCOM1->I2CM.CTRLA.bit.RUNSTDBY = 1; // RUNSTBY: Enabled (No sync) |
| 145 | 145 | ||
| 146 | SERCOM1->I2CM.CTRLB.bit.SMEN = 1; // SMEN: Smart mode enabled (For DMA)(No sync) | 146 | SERCOM1->I2CM.CTRLB.bit.SMEN = 1; // SMEN: Smart mode enabled (For DMA)(No sync) |
| 147 | 147 | ||
| 148 | NVIC_EnableIRQ(SERCOM1_0_IRQn); | 148 | NVIC_EnableIRQ(SERCOM1_0_IRQn); |
| 149 | SERCOM1->I2CM.INTENSET.bit.ERROR = 1; | 149 | SERCOM1->I2CM.INTENSET.bit.ERROR = 1; |
| 150 | 150 | ||
| 151 | SERCOM1->I2CM.CTRLA.bit.ENABLE = 1; // ENABLE: Enable the device (sync SYNCBUSY.ENABLE) | 151 | SERCOM1->I2CM.CTRLA.bit.ENABLE = 1; // ENABLE: Enable the device (sync SYNCBUSY.ENABLE) |
| 152 | while (SERCOM1->I2CM.SYNCBUSY.bit.ENABLE) { | 152 | while (SERCOM1->I2CM.SYNCBUSY.bit.ENABLE) { |
| 153 | DBGC(DC_I2C1_INIT_SYNC_ENABLING); | 153 | DBGC(DC_I2C1_INIT_SYNC_ENABLING); |
| 154 | } // Wait for SYNCBUSY.ENABLE to clear | 154 | } // Wait for SYNCBUSY.ENABLE to clear |
| 155 | 155 | ||
| 156 | SERCOM1->I2CM.STATUS.bit.BUSSTATE = 1; // BUSSTATE: Force into IDLE state (sync SYNCBUSY.SYSOP) | 156 | SERCOM1->I2CM.STATUS.bit.BUSSTATE = 1; // BUSSTATE: Force into IDLE state (sync SYNCBUSY.SYSOP) |
| 157 | while (SERCOM1->I2CM.SYNCBUSY.bit.SYSOP) { | 157 | while (SERCOM1->I2CM.SYNCBUSY.bit.SYSOP) { |
| 158 | DBGC(DC_I2C1_INIT_SYNC_SYSOP); | 158 | DBGC(DC_I2C1_INIT_SYNC_SYSOP); |
| 159 | } | 159 | } |
| 160 | while (SERCOM1->I2CM.STATUS.bit.BUSSTATE != 1) { | 160 | while (SERCOM1->I2CM.STATUS.bit.BUSSTATE != 1) { |
| 161 | DBGC(DC_I2C1_INIT_WAIT_IDLE); | 161 | DBGC(DC_I2C1_INIT_WAIT_IDLE); |
| 162 | } // Wait while not idle | 162 | } // Wait while not idle |
| 163 | 163 | ||
| 164 | DBGC(DC_I2C1_INIT_COMPLETE); | 164 | DBGC(DC_I2C1_INIT_COMPLETE); |
| 165 | } | 165 | } |
| @@ -240,7 +240,7 @@ void i2c_led_send_onoff(uint8_t drvid) { | |||
| 240 | } | 240 | } |
| 241 | # endif | 241 | # endif |
| 242 | 242 | ||
| 243 | *issidrv[drvid].onoff = 0; // Force start location offset to zero | 243 | *issidrv[drvid].onoff = 0; // Force start location offset to zero |
| 244 | i2c1_transmit(issidrv[drvid].addr, issidrv[drvid].onoff, ISSI3733_PG0_BYTES, 0); | 244 | i2c1_transmit(issidrv[drvid].addr, issidrv[drvid].onoff, ISSI3733_PG0_BYTES, 0); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| @@ -265,7 +265,7 @@ void i2c_led_send_pwm(uint8_t drvid) { | |||
| 265 | } | 265 | } |
| 266 | # endif | 266 | # endif |
| 267 | 267 | ||
| 268 | *issidrv[drvid].pwm = 0; // Force start location offset to zero | 268 | *issidrv[drvid].pwm = 0; // Force start location offset to zero |
| 269 | i2c1_transmit(issidrv[drvid].addr, issidrv[drvid].pwm, ISSI3733_PG1_BYTES, 0); | 269 | i2c1_transmit(issidrv[drvid].addr, issidrv[drvid].pwm, ISSI3733_PG1_BYTES, 0); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| @@ -300,12 +300,12 @@ uint8_t I2C3733_Init_Drivers(void) { | |||
| 300 | // Set up master device | 300 | // Set up master device |
| 301 | i2c_led_send_CRWL(0); | 301 | i2c_led_send_CRWL(0); |
| 302 | i2c_led_select_page(0, 3); | 302 | i2c_led_select_page(0, 3); |
| 303 | i2c_led_send_mode_op_gcr(0, 0, ISSI3733_CR_SSD_NORMAL); // No SYNC due to brightness mismatch with second driver | 303 | i2c_led_send_mode_op_gcr(0, 0, ISSI3733_CR_SSD_NORMAL); // No SYNC due to brightness mismatch with second driver |
| 304 | 304 | ||
| 305 | // Set up slave device | 305 | // Set up slave device |
| 306 | i2c_led_send_CRWL(1); | 306 | i2c_led_send_CRWL(1); |
| 307 | i2c_led_select_page(1, 3); | 307 | i2c_led_select_page(1, 3); |
| 308 | i2c_led_send_mode_op_gcr(1, 0, ISSI3733_CR_SSD_NORMAL); // No SYNC due to brightness mismatch with first driver and slight flicker at rgb values 1,2 | 308 | i2c_led_send_mode_op_gcr(1, 0, ISSI3733_CR_SSD_NORMAL); // No SYNC due to brightness mismatch with first driver and slight flicker at rgb values 1,2 |
| 309 | 309 | ||
| 310 | i2c_led_send_CRWL(0); | 310 | i2c_led_send_CRWL(0); |
| 311 | i2c_led_select_page(0, 3); | 311 | i2c_led_select_page(0, 3); |
| @@ -326,41 +326,41 @@ void I2C_DMAC_LED_Init(void) { | |||
| 326 | DBGC(DC_I2C_DMAC_LED_INIT_BEGIN); | 326 | DBGC(DC_I2C_DMAC_LED_INIT_BEGIN); |
| 327 | 327 | ||
| 328 | // Disable device | 328 | // Disable device |
| 329 | dmac->CTRL.bit.DMAENABLE = 0; // Disable DMAC | 329 | dmac->CTRL.bit.DMAENABLE = 0; // Disable DMAC |
| 330 | while (dmac->CTRL.bit.DMAENABLE) { | 330 | while (dmac->CTRL.bit.DMAENABLE) { |
| 331 | } // Wait for disabled state in case of ongoing transfers | 331 | } // Wait for disabled state in case of ongoing transfers |
| 332 | dmac->CTRL.bit.SWRST = 1; // Software Reset DMAC | 332 | dmac->CTRL.bit.SWRST = 1; // Software Reset DMAC |
| 333 | while (dmac->CTRL.bit.SWRST) { | 333 | while (dmac->CTRL.bit.SWRST) { |
| 334 | } // Wait for software reset to complete | 334 | } // Wait for software reset to complete |
| 335 | 335 | ||
| 336 | // Configure device | 336 | // Configure device |
| 337 | dmac->BASEADDR.reg = (uint32_t)&dmac_desc; // Set descriptor base address | 337 | dmac->BASEADDR.reg = (uint32_t)&dmac_desc; // Set descriptor base address |
| 338 | dmac->WRBADDR.reg = (uint32_t)&dmac_desc_wb; // Set descriptor write back address | 338 | dmac->WRBADDR.reg = (uint32_t)&dmac_desc_wb; // Set descriptor write back address |
| 339 | dmac->CTRL.reg |= 0x0f00; // Handle all priorities (LVL0-3) | 339 | dmac->CTRL.reg |= 0x0f00; // Handle all priorities (LVL0-3) |
| 340 | 340 | ||
| 341 | // Disable channel | 341 | // Disable channel |
| 342 | dmac->Channel[0].CHCTRLA.bit.ENABLE = 0; // Disable the channel | 342 | dmac->Channel[0].CHCTRLA.bit.ENABLE = 0; // Disable the channel |
| 343 | while (dmac->Channel[0].CHCTRLA.bit.ENABLE) { | 343 | while (dmac->Channel[0].CHCTRLA.bit.ENABLE) { |
| 344 | } // Wait for disabled state in case of ongoing transfers | 344 | } // Wait for disabled state in case of ongoing transfers |
| 345 | dmac->Channel[0].CHCTRLA.bit.SWRST = 1; // Software Reset the channel | 345 | dmac->Channel[0].CHCTRLA.bit.SWRST = 1; // Software Reset the channel |
| 346 | while (dmac->Channel[0].CHCTRLA.bit.SWRST) { | 346 | while (dmac->Channel[0].CHCTRLA.bit.SWRST) { |
| 347 | } // Wait for software reset to complete | 347 | } // Wait for software reset to complete |
| 348 | 348 | ||
| 349 | // Configure channel | 349 | // Configure channel |
| 350 | dmac->Channel[0].CHCTRLA.bit.THRESHOLD = 0; // 1BEAT | 350 | dmac->Channel[0].CHCTRLA.bit.THRESHOLD = 0; // 1BEAT |
| 351 | dmac->Channel[0].CHCTRLA.bit.BURSTLEN = 0; // SINGLE | 351 | dmac->Channel[0].CHCTRLA.bit.BURSTLEN = 0; // SINGLE |
| 352 | dmac->Channel[0].CHCTRLA.bit.TRIGACT = 2; // BURST | 352 | dmac->Channel[0].CHCTRLA.bit.TRIGACT = 2; // BURST |
| 353 | dmac->Channel[0].CHCTRLA.bit.TRIGSRC = SERCOM1_DMAC_ID_TX; // Trigger source | 353 | dmac->Channel[0].CHCTRLA.bit.TRIGSRC = SERCOM1_DMAC_ID_TX; // Trigger source |
| 354 | dmac->Channel[0].CHCTRLA.bit.RUNSTDBY = 1; // Run in standby | 354 | dmac->Channel[0].CHCTRLA.bit.RUNSTDBY = 1; // Run in standby |
| 355 | 355 | ||
| 356 | NVIC_EnableIRQ(DMAC_0_IRQn); | 356 | NVIC_EnableIRQ(DMAC_0_IRQn); |
| 357 | dmac->Channel[0].CHINTENSET.bit.TCMPL = 1; | 357 | dmac->Channel[0].CHINTENSET.bit.TCMPL = 1; |
| 358 | dmac->Channel[0].CHINTENSET.bit.TERR = 1; | 358 | dmac->Channel[0].CHINTENSET.bit.TERR = 1; |
| 359 | 359 | ||
| 360 | // Enable device | 360 | // Enable device |
| 361 | dmac->CTRL.bit.DMAENABLE = 1; // Enable DMAC | 361 | dmac->CTRL.bit.DMAENABLE = 1; // Enable DMAC |
| 362 | while (dmac->CTRL.bit.DMAENABLE == 0) { | 362 | while (dmac->CTRL.bit.DMAENABLE == 0) { |
| 363 | } // Wait for enable state | 363 | } // Wait for enable state |
| 364 | 364 | ||
| 365 | DBGC(DC_I2C_DMAC_LED_INIT_COMPLETE); | 365 | DBGC(DC_I2C_DMAC_LED_INIT_COMPLETE); |
| 366 | } | 366 | } |
| @@ -377,14 +377,14 @@ void I2C3733_Control_Set(uint8_t state) { | |||
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | void i2c_led_desc_defaults(void) { | 379 | void i2c_led_desc_defaults(void) { |
| 380 | dmac_desc.BTCTRL.bit.STEPSIZE = 0; // SRCINC used in favor for auto 1 inc | 380 | dmac_desc.BTCTRL.bit.STEPSIZE = 0; // SRCINC used in favor for auto 1 inc |
| 381 | dmac_desc.BTCTRL.bit.STEPSEL = 0; // SRCINC used in favor for auto 1 inc | 381 | dmac_desc.BTCTRL.bit.STEPSEL = 0; // SRCINC used in favor for auto 1 inc |
| 382 | dmac_desc.BTCTRL.bit.DSTINC = 0; // The Destination Address Increment is disabled | 382 | dmac_desc.BTCTRL.bit.DSTINC = 0; // The Destination Address Increment is disabled |
| 383 | dmac_desc.BTCTRL.bit.SRCINC = 1; // The Source Address Increment is enabled (Inc by 1) | 383 | dmac_desc.BTCTRL.bit.SRCINC = 1; // The Source Address Increment is enabled (Inc by 1) |
| 384 | dmac_desc.BTCTRL.bit.BEATSIZE = 0; // 8-bit bus transfer | 384 | dmac_desc.BTCTRL.bit.BEATSIZE = 0; // 8-bit bus transfer |
| 385 | dmac_desc.BTCTRL.bit.BLOCKACT = 0; // Channel will be disabled if it is the last block transfer in the transaction | 385 | dmac_desc.BTCTRL.bit.BLOCKACT = 0; // Channel will be disabled if it is the last block transfer in the transaction |
| 386 | dmac_desc.BTCTRL.bit.EVOSEL = 0; // Event generation disabled | 386 | dmac_desc.BTCTRL.bit.EVOSEL = 0; // Event generation disabled |
| 387 | dmac_desc.BTCTRL.bit.VALID = 1; // Set dmac valid | 387 | dmac_desc.BTCTRL.bit.VALID = 1; // Set dmac valid |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | void i2c_led_prepare_send_dma(uint8_t *data, uint8_t len) { | 390 | void i2c_led_prepare_send_dma(uint8_t *data, uint8_t len) { |
| @@ -397,9 +397,9 @@ void i2c_led_prepare_send_dma(uint8_t *data, uint8_t len) { | |||
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | void i2c_led_begin_dma(uint8_t drvid) { | 399 | void i2c_led_begin_dma(uint8_t drvid) { |
| 400 | DMAC->Channel[0].CHCTRLA.bit.ENABLE = 1; // Enable the channel | 400 | DMAC->Channel[0].CHCTRLA.bit.ENABLE = 1; // Enable the channel |
| 401 | 401 | ||
| 402 | SERCOM1->I2CM.ADDR.reg = (dmac_desc.BTCNT.reg << 16) | 0x2000 | issidrv[drvid].addr; // Begin transfer | 402 | SERCOM1->I2CM.ADDR.reg = (dmac_desc.BTCNT.reg << 16) | 0x2000 | issidrv[drvid].addr; // Begin transfer |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | void i2c_led_send_CRWL_dma(uint8_t drvid) { | 405 | void i2c_led_send_CRWL_dma(uint8_t drvid) { |
| @@ -429,7 +429,7 @@ void i2c_led_send_GCR_dma(uint8_t drvid) { | |||
| 429 | void i2c_led_send_pwm_dma(uint8_t drvid) { | 429 | void i2c_led_send_pwm_dma(uint8_t drvid) { |
| 430 | // Note: This copies the CURRENT pwm buffer, which may be getting modified | 430 | // Note: This copies the CURRENT pwm buffer, which may be getting modified |
| 431 | memcpy(dma_sendbuf, issidrv[drvid].pwm, ISSI3733_PG1_BYTES); | 431 | memcpy(dma_sendbuf, issidrv[drvid].pwm, ISSI3733_PG1_BYTES); |
| 432 | *dma_sendbuf = 0; // Force start location offset to zero | 432 | *dma_sendbuf = 0; // Force start location offset to zero |
| 433 | i2c_led_prepare_send_dma(dma_sendbuf, ISSI3733_PG1_BYTES); | 433 | i2c_led_prepare_send_dma(dma_sendbuf, ISSI3733_PG1_BYTES); |
| 434 | 434 | ||
| 435 | i2c_led_begin_dma(drvid); | 435 | i2c_led_begin_dma(drvid); |
| @@ -438,7 +438,7 @@ void i2c_led_send_pwm_dma(uint8_t drvid) { | |||
| 438 | void i2c_led_send_onoff_dma(uint8_t drvid) { | 438 | void i2c_led_send_onoff_dma(uint8_t drvid) { |
| 439 | // Note: This copies the CURRENT onoff buffer, which may be getting modified | 439 | // Note: This copies the CURRENT onoff buffer, which may be getting modified |
| 440 | memcpy(dma_sendbuf, issidrv[drvid].onoff, ISSI3733_PG0_BYTES); | 440 | memcpy(dma_sendbuf, issidrv[drvid].onoff, ISSI3733_PG0_BYTES); |
| 441 | *dma_sendbuf = 0; // Force start location offset to zero | 441 | *dma_sendbuf = 0; // Force start location offset to zero |
| 442 | i2c_led_prepare_send_dma(dma_sendbuf, ISSI3733_PG0_BYTES); | 442 | i2c_led_prepare_send_dma(dma_sendbuf, ISSI3733_PG0_BYTES); |
| 443 | 443 | ||
| 444 | i2c_led_begin_dma(drvid); | 444 | i2c_led_begin_dma(drvid); |
| @@ -452,12 +452,16 @@ void i2c_led_q_init(void) { | |||
| 452 | i2c_led_q_full = 0; | 452 | i2c_led_q_full = 0; |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | uint8_t i2c_led_q_isempty(void) { return i2c_led_q_s == i2c_led_q_e; } | 455 | uint8_t i2c_led_q_isempty(void) { |
| 456 | return i2c_led_q_s == i2c_led_q_e; | ||
| 457 | } | ||
| 456 | 458 | ||
| 457 | uint8_t i2c_led_q_size(void) { return (i2c_led_q_e - i2c_led_q_s) % I2C_Q_SIZE; } | 459 | uint8_t i2c_led_q_size(void) { |
| 460 | return (i2c_led_q_e - i2c_led_q_s) % I2C_Q_SIZE; | ||
| 461 | } | ||
| 458 | 462 | ||
| 459 | uint8_t i2c_led_q_available(void) { | 463 | uint8_t i2c_led_q_available(void) { |
| 460 | return I2C_Q_SIZE - i2c_led_q_size() - 1; // Never allow end to meet start | 464 | return I2C_Q_SIZE - i2c_led_q_size() - 1; // Never allow end to meet start |
| 461 | } | 465 | } |
| 462 | 466 | ||
| 463 | void i2c_led_q_add(uint8_t cmd) { | 467 | void i2c_led_q_add(uint8_t cmd) { |
| @@ -466,11 +470,11 @@ void i2c_led_q_add(uint8_t cmd) { | |||
| 466 | // Assign command | 470 | // Assign command |
| 467 | i2c_led_q[i2c_led_q_e] = cmd; | 471 | i2c_led_q[i2c_led_q_e] = cmd; |
| 468 | 472 | ||
| 469 | i2c_led_q_e = (i2c_led_q_e + 1) % I2C_Q_SIZE; // Move end up one or wrap | 473 | i2c_led_q_e = (i2c_led_q_e + 1) % I2C_Q_SIZE; // Move end up one or wrap |
| 470 | } | 474 | } |
| 471 | 475 | ||
| 472 | void i2c_led_q_s_advance(void) { | 476 | void i2c_led_q_s_advance(void) { |
| 473 | i2c_led_q_s = (i2c_led_q_s + 1) % I2C_Q_SIZE; // Move start up one or wrap | 477 | i2c_led_q_s = (i2c_led_q_s + 1) % I2C_Q_SIZE; // Move start up one or wrap |
| 474 | } | 478 | } |
| 475 | 479 | ||
| 476 | // Always request room before adding commands | 480 | // Always request room before adding commands |
| @@ -480,7 +484,7 @@ uint8_t i2c_led_q_request_room(uint8_t request_size) { | |||
| 480 | if (request_size > i2c_led_q_available()) { | 484 | if (request_size > i2c_led_q_available()) { |
| 481 | i2c_led_q_full++; | 485 | i2c_led_q_full++; |
| 482 | 486 | ||
| 483 | if (i2c_led_q_full >= 100) // Give the queue a chance to clear up | 487 | if (i2c_led_q_full >= 100) // Give the queue a chance to clear up |
| 484 | { | 488 | { |
| 485 | DBG_LED_ON; | 489 | DBG_LED_ON; |
| 486 | I2C_DMAC_LED_Init(); | 490 | I2C_DMAC_LED_Init(); |
| @@ -554,7 +558,7 @@ uint8_t i2c_led_q_run(void) { | |||
| 554 | # endif | 558 | # endif |
| 555 | } | 559 | } |
| 556 | 560 | ||
| 557 | i2c_led_q_s_advance(); // Advance last run command or if the command byte was not serviced | 561 | i2c_led_q_s_advance(); // Advance last run command or if the command byte was not serviced |
| 558 | 562 | ||
| 559 | # if I2C_LED_USE_DMA != 1 | 563 | # if I2C_LED_USE_DMA != 1 |
| 560 | } | 564 | } |
| @@ -583,4 +587,4 @@ i2c_status_t i2c_transmit(uint8_t address, const uint8_t *data, uint16_t length, | |||
| 583 | return ret ? I2C_STATUS_SUCCESS : I2C_STATUS_ERROR; | 587 | return ret ? I2C_STATUS_SUCCESS : I2C_STATUS_ERROR; |
| 584 | } | 588 | } |
| 585 | 589 | ||
| 586 | #endif // !defined(MD_BOOTLOADER) && defined(RGB_MATRIX_ENABLE) | 590 | #endif // !defined(MD_BOOTLOADER) && defined(RGB_MATRIX_ENABLE) |
diff --git a/tmk_core/protocol/arm_atsam/i2c_master.h b/tmk_core/protocol/arm_atsam/i2c_master.h index e11235d447..5459923de4 100644 --- a/tmk_core/protocol/arm_atsam/i2c_master.h +++ b/tmk_core/protocol/arm_atsam/i2c_master.h | |||
| @@ -95,7 +95,7 @@ void i2c1_init(void); | |||
| 95 | uint8_t i2c1_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout); | 95 | uint8_t i2c1_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout); |
| 96 | void i2c1_stop(void); | 96 | void i2c1_stop(void); |
| 97 | 97 | ||
| 98 | #endif // MD_BOOTLOADER | 98 | #endif // MD_BOOTLOADER |
| 99 | 99 | ||
| 100 | void i2c0_init(void); | 100 | void i2c0_init(void); |
| 101 | uint8_t i2c0_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout); | 101 | uint8_t i2c0_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout); |
| @@ -110,4 +110,4 @@ typedef int16_t i2c_status_t; | |||
| 110 | void i2c_init(void); | 110 | void i2c_init(void); |
| 111 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout); | 111 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout); |
| 112 | 112 | ||
| 113 | #endif // _I2C_MASTER_H_ | 113 | #endif // _I2C_MASTER_H_ |
diff --git a/tmk_core/protocol/arm_atsam/issi3733_driver.h b/tmk_core/protocol/arm_atsam/issi3733_driver.h index bd29fe76b6..c01f147e13 100644 --- a/tmk_core/protocol/arm_atsam/issi3733_driver.h +++ b/tmk_core/protocol/arm_atsam/issi3733_driver.h | |||
| @@ -20,29 +20,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | // ISII3733 Registers | 21 | // ISII3733 Registers |
| 22 | 22 | ||
| 23 | #define ISSI3733_CMDR 0xFD // Command Register (Write Only) | 23 | #define ISSI3733_CMDR 0xFD // Command Register (Write Only) |
| 24 | 24 | ||
| 25 | #define ISSI3733_CMDRWL 0xFE // Command Register Write Lock (Read/Write) | 25 | #define ISSI3733_CMDRWL 0xFE // Command Register Write Lock (Read/Write) |
| 26 | #define ISSI3733_CMDRWL_WRITE_DISABLE 0x00 // Lock register | 26 | #define ISSI3733_CMDRWL_WRITE_DISABLE 0x00 // Lock register |
| 27 | #define ISSI3733_CMDRWL_WRITE_ENABLE_ONCE 0xC5 // Enable one write to register then reset to locked | 27 | #define ISSI3733_CMDRWL_WRITE_ENABLE_ONCE 0xC5 // Enable one write to register then reset to locked |
| 28 | 28 | ||
| 29 | #define ISSI3733_IMR 0xF0 // Interrupt Mask Register (Write Only) | 29 | #define ISSI3733_IMR 0xF0 // Interrupt Mask Register (Write Only) |
| 30 | #define ISSI3733_IMR_IAC_ON 0x08 // Auto Clear Interrupt Bit - Interrupt auto clear when INTB stay low exceeds 8ms | 30 | #define ISSI3733_IMR_IAC_ON 0x08 // Auto Clear Interrupt Bit - Interrupt auto clear when INTB stay low exceeds 8ms |
| 31 | #define ISSI3733_IMR_IAB_ON 0x04 // Auto Breath Interrupt Bit - Enable auto breath loop finish interrupt | 31 | #define ISSI3733_IMR_IAB_ON 0x04 // Auto Breath Interrupt Bit - Enable auto breath loop finish interrupt |
| 32 | #define ISSI3733_IMR_IS_ON 0x02 // Dot Short Interrupt Bit - Enable dot short interrupt | 32 | #define ISSI3733_IMR_IS_ON 0x02 // Dot Short Interrupt Bit - Enable dot short interrupt |
| 33 | #define ISSI3733_IMR_IO_ON 0x01 // Dot Open Interrupt Bit - Enable dot open interrupt | 33 | #define ISSI3733_IMR_IO_ON 0x01 // Dot Open Interrupt Bit - Enable dot open interrupt |
| 34 | 34 | ||
| 35 | #define ISSI3733_ISR 0xF1 // Interrupt Status Register (Read Only) | 35 | #define ISSI3733_ISR 0xF1 // Interrupt Status Register (Read Only) |
| 36 | #define ISSI3733_ISR_ABM3_FINISH 0x10 // Auto Breath Mode 3 Finish Bit - ABM3 finished | 36 | #define ISSI3733_ISR_ABM3_FINISH 0x10 // Auto Breath Mode 3 Finish Bit - ABM3 finished |
| 37 | #define ISSI3733_ISR_ABM2_FINISH 0x08 // Auto Breath Mode 2 Finish Bit - ABM2 finished | 37 | #define ISSI3733_ISR_ABM2_FINISH 0x08 // Auto Breath Mode 2 Finish Bit - ABM2 finished |
| 38 | #define ISSI3733_ISR_ABM1_FINISH 0x04 // Auto Breath Mode 1 Finish Bit - ABM1 finished | 38 | #define ISSI3733_ISR_ABM1_FINISH 0x04 // Auto Breath Mode 1 Finish Bit - ABM1 finished |
| 39 | #define ISSI3733_ISR_SB 0x02 // Short Bit - Shorted | 39 | #define ISSI3733_ISR_SB 0x02 // Short Bit - Shorted |
| 40 | #define ISSI3733_ISR_OB 0x01 // Open Bit - Opened | 40 | #define ISSI3733_ISR_OB 0x01 // Open Bit - Opened |
| 41 | 41 | ||
| 42 | #define ISSI3733_PG0 0x00 // LED Control Register | 42 | #define ISSI3733_PG0 0x00 // LED Control Register |
| 43 | #define ISSI3733_PG1 0x01 // PWM Register | 43 | #define ISSI3733_PG1 0x01 // PWM Register |
| 44 | #define ISSI3733_PG2 0x02 // Auto Breath Mode Register | 44 | #define ISSI3733_PG2 0x02 // Auto Breath Mode Register |
| 45 | #define ISSI3733_PG3 0x03 // Function Register | 45 | #define ISSI3733_PG3 0x03 // Function Register |
| 46 | 46 | ||
| 47 | #define ISSI3733_PG_ONOFF ISSI3733_PG0 | 47 | #define ISSI3733_PG_ONOFF ISSI3733_PG0 |
| 48 | #define ISSI3733_PG_OR ISSI3733_PG0 | 48 | #define ISSI3733_PG_OR ISSI3733_PG0 |
| @@ -51,88 +51,88 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 51 | #define ISSI3733_PG_ABM ISSI3733_PG2 | 51 | #define ISSI3733_PG_ABM ISSI3733_PG2 |
| 52 | #define ISSI3733_PG_FN ISSI3733_PG3 | 52 | #define ISSI3733_PG_FN ISSI3733_PG3 |
| 53 | 53 | ||
| 54 | #define ISSI3733_CR 0x00 // Configuration Register | 54 | #define ISSI3733_CR 0x00 // Configuration Register |
| 55 | 55 | ||
| 56 | // PG3: Configuration Register: Synchronize Configuration | 56 | // PG3: Configuration Register: Synchronize Configuration |
| 57 | #define ISSI3733_CR_SYNC_MASTER 0x40 // Master | 57 | #define ISSI3733_CR_SYNC_MASTER 0x40 // Master |
| 58 | #define ISSI3733_CR_SYNC_SLAVE 0x80 // Slave | 58 | #define ISSI3733_CR_SYNC_SLAVE 0x80 // Slave |
| 59 | #define ISSI3733_CR_SYNC_HIGH_IMP 0xC0 // High Impedance | 59 | #define ISSI3733_CR_SYNC_HIGH_IMP 0xC0 // High Impedance |
| 60 | 60 | ||
| 61 | // PG3: Configuration Register: Open/Short Detection Enable Bit | 61 | // PG3: Configuration Register: Open/Short Detection Enable Bit |
| 62 | //#define ISSI3733_CR_OSD_DISABLE 0x00 //Disable open/short detection | 62 | //#define ISSI3733_CR_OSD_DISABLE 0x00 //Disable open/short detection |
| 63 | #define ISSI3733_CR_OSD_ENABLE 0x04 // Enable open/short detection | 63 | #define ISSI3733_CR_OSD_ENABLE 0x04 // Enable open/short detection |
| 64 | 64 | ||
| 65 | // PG3: Configuration Register: Auto Breath Enable | 65 | // PG3: Configuration Register: Auto Breath Enable |
| 66 | //#define ISSI3733_CR_B_EN_PWM 0x00 //PWM Mode Enable | 66 | //#define ISSI3733_CR_B_EN_PWM 0x00 //PWM Mode Enable |
| 67 | #define ISSI3733_CR_B_EN_AUTO 0x02 // Auto Breath Mode Enable | 67 | #define ISSI3733_CR_B_EN_AUTO 0x02 // Auto Breath Mode Enable |
| 68 | 68 | ||
| 69 | // PG3: Configuration Register: Software Shutdown Control | 69 | // PG3: Configuration Register: Software Shutdown Control |
| 70 | //#define ISSI3733_CR_SSD_SHUTDOWN 0x00 //Software shutdown | 70 | //#define ISSI3733_CR_SSD_SHUTDOWN 0x00 //Software shutdown |
| 71 | #define ISSI3733_CR_SSD_NORMAL 0x01 // Normal operation | 71 | #define ISSI3733_CR_SSD_NORMAL 0x01 // Normal operation |
| 72 | 72 | ||
| 73 | #define ISSI3733_GCCR 0x01 // Global Current Control Register | 73 | #define ISSI3733_GCCR 0x01 // Global Current Control Register |
| 74 | 74 | ||
| 75 | // 1 Byte, Iout = (GCC / 256) * (840 / Rext) | 75 | // 1 Byte, Iout = (GCC / 256) * (840 / Rext) |
| 76 | // TODO: Give user define for Rext | 76 | // TODO: Give user define for Rext |
| 77 | 77 | ||
| 78 | // PG3: Auto Breath Control Register 1 | 78 | // PG3: Auto Breath Control Register 1 |
| 79 | #define ISSI3733_ABCR1_ABM1 0x02 // Auto Breath Control Register 1 of ABM-1 | 79 | #define ISSI3733_ABCR1_ABM1 0x02 // Auto Breath Control Register 1 of ABM-1 |
| 80 | #define ISSI3733_ABCR1_ABM2 0x06 // Auto Breath Control Register 1 of ABM-2 | 80 | #define ISSI3733_ABCR1_ABM2 0x06 // Auto Breath Control Register 1 of ABM-2 |
| 81 | #define ISSI3733_ABCR1_ABM3 0x0A // Auto Breath Control Register 1 of ABM-3 | 81 | #define ISSI3733_ABCR1_ABM3 0x0A // Auto Breath Control Register 1 of ABM-3 |
| 82 | 82 | ||
| 83 | // Rise time | 83 | // Rise time |
| 84 | #define ISSI3733_ABCR1_T1_0021 0x00 // 0.21s | 84 | #define ISSI3733_ABCR1_T1_0021 0x00 // 0.21s |
| 85 | #define ISSI3733_ABCR1_T1_0042 0x20 // 0.42s | 85 | #define ISSI3733_ABCR1_T1_0042 0x20 // 0.42s |
| 86 | #define ISSI3733_ABCR1_T1_0084 0x40 // 0.84s | 86 | #define ISSI3733_ABCR1_T1_0084 0x40 // 0.84s |
| 87 | #define ISSI3733_ABCR1_T1_0168 0x60 // 1.68s | 87 | #define ISSI3733_ABCR1_T1_0168 0x60 // 1.68s |
| 88 | #define ISSI3733_ABCR1_T1_0336 0x80 // 3.36s | 88 | #define ISSI3733_ABCR1_T1_0336 0x80 // 3.36s |
| 89 | #define ISSI3733_ABCR1_T1_0672 0xA0 // 6.72s | 89 | #define ISSI3733_ABCR1_T1_0672 0xA0 // 6.72s |
| 90 | #define ISSI3733_ABCR1_T1_1344 0xC0 // 13.44s | 90 | #define ISSI3733_ABCR1_T1_1344 0xC0 // 13.44s |
| 91 | #define ISSI3733_ABCR1_T1_2688 0xE0 // 26.88s | 91 | #define ISSI3733_ABCR1_T1_2688 0xE0 // 26.88s |
| 92 | 92 | ||
| 93 | // Max value time | 93 | // Max value time |
| 94 | #define ISSI3733_ABCR1_T2_0000 0x00 // 0s | 94 | #define ISSI3733_ABCR1_T2_0000 0x00 // 0s |
| 95 | #define ISSI3733_ABCR1_T2_0021 0x02 // 0.21s | 95 | #define ISSI3733_ABCR1_T2_0021 0x02 // 0.21s |
| 96 | #define ISSI3733_ABCR1_T2_0042 0x04 // 0.42s | 96 | #define ISSI3733_ABCR1_T2_0042 0x04 // 0.42s |
| 97 | #define ISSI3733_ABCR1_T2_0084 0x06 // 0.84s | 97 | #define ISSI3733_ABCR1_T2_0084 0x06 // 0.84s |
| 98 | #define ISSI3733_ABCR1_T2_0168 0x08 // 1.68s | 98 | #define ISSI3733_ABCR1_T2_0168 0x08 // 1.68s |
| 99 | #define ISSI3733_ABCR1_T2_0336 0x0A // 3.36s | 99 | #define ISSI3733_ABCR1_T2_0336 0x0A // 3.36s |
| 100 | #define ISSI3733_ABCR1_T2_0672 0x0C // 6.72s | 100 | #define ISSI3733_ABCR1_T2_0672 0x0C // 6.72s |
| 101 | #define ISSI3733_ABCR1_T2_1344 0x0E // 13.44s | 101 | #define ISSI3733_ABCR1_T2_1344 0x0E // 13.44s |
| 102 | #define ISSI3733_ABCR1_T2_2688 0x10 // 26.88s | 102 | #define ISSI3733_ABCR1_T2_2688 0x10 // 26.88s |
| 103 | 103 | ||
| 104 | // PG3: Auto Breath Control Register 2 | 104 | // PG3: Auto Breath Control Register 2 |
| 105 | #define ISSI3733_ABCR2_ABM1 0x03 // Auto Breath Control Register 2 of ABM-1 | 105 | #define ISSI3733_ABCR2_ABM1 0x03 // Auto Breath Control Register 2 of ABM-1 |
| 106 | #define ISSI3733_ABCR2_ABM2 0x07 // Auto Breath Control Register 2 of ABM-2 | 106 | #define ISSI3733_ABCR2_ABM2 0x07 // Auto Breath Control Register 2 of ABM-2 |
| 107 | #define ISSI3733_ABCR2_ABM3 0x0B // Auto Breath Control Register 2 of ABM-3 | 107 | #define ISSI3733_ABCR2_ABM3 0x0B // Auto Breath Control Register 2 of ABM-3 |
| 108 | 108 | ||
| 109 | // Fall time | 109 | // Fall time |
| 110 | #define ISSI3733_ABCR2_T3_0021 0x00 // 0.21s | 110 | #define ISSI3733_ABCR2_T3_0021 0x00 // 0.21s |
| 111 | #define ISSI3733_ABCR2_T3_0042 0x20 // 0.42s | 111 | #define ISSI3733_ABCR2_T3_0042 0x20 // 0.42s |
| 112 | #define ISSI3733_ABCR2_T3_0084 0x40 // 0.84s | 112 | #define ISSI3733_ABCR2_T3_0084 0x40 // 0.84s |
| 113 | #define ISSI3733_ABCR2_T3_0168 0x60 // 1.68s | 113 | #define ISSI3733_ABCR2_T3_0168 0x60 // 1.68s |
| 114 | #define ISSI3733_ABCR2_T3_0336 0x80 // 3.36s | 114 | #define ISSI3733_ABCR2_T3_0336 0x80 // 3.36s |
| 115 | #define ISSI3733_ABCR2_T3_0672 0xA0 // 6.72s | 115 | #define ISSI3733_ABCR2_T3_0672 0xA0 // 6.72s |
| 116 | #define ISSI3733_ABCR2_T3_1344 0xC0 // 13.44s | 116 | #define ISSI3733_ABCR2_T3_1344 0xC0 // 13.44s |
| 117 | #define ISSI3733_ABCR2_T3_2688 0xE0 // 26.88s | 117 | #define ISSI3733_ABCR2_T3_2688 0xE0 // 26.88s |
| 118 | 118 | ||
| 119 | // Min value time | 119 | // Min value time |
| 120 | #define ISSI3733_ABCR2_T4_0000 0x00 // 0s | 120 | #define ISSI3733_ABCR2_T4_0000 0x00 // 0s |
| 121 | #define ISSI3733_ABCR2_T4_0021 0x02 // 0.21s | 121 | #define ISSI3733_ABCR2_T4_0021 0x02 // 0.21s |
| 122 | #define ISSI3733_ABCR2_T4_0042 0x04 // 0.42s | 122 | #define ISSI3733_ABCR2_T4_0042 0x04 // 0.42s |
| 123 | #define ISSI3733_ABCR2_T4_0084 0x06 // 0.84s | 123 | #define ISSI3733_ABCR2_T4_0084 0x06 // 0.84s |
| 124 | #define ISSI3733_ABCR2_T4_0168 0x08 // 1.68s | 124 | #define ISSI3733_ABCR2_T4_0168 0x08 // 1.68s |
| 125 | #define ISSI3733_ABCR2_T4_0336 0x0A // 3.36s | 125 | #define ISSI3733_ABCR2_T4_0336 0x0A // 3.36s |
| 126 | #define ISSI3733_ABCR2_T4_0672 0x0C // 6.72s | 126 | #define ISSI3733_ABCR2_T4_0672 0x0C // 6.72s |
| 127 | #define ISSI3733_ABCR2_T4_1344 0x0E // 13.44s | 127 | #define ISSI3733_ABCR2_T4_1344 0x0E // 13.44s |
| 128 | #define ISSI3733_ABCR2_T4_2688 0x10 // 26.88s | 128 | #define ISSI3733_ABCR2_T4_2688 0x10 // 26.88s |
| 129 | #define ISSI3733_ABCR2_T4_5376 0x12 // 53.76s | 129 | #define ISSI3733_ABCR2_T4_5376 0x12 // 53.76s |
| 130 | #define ISSI3733_ABCR2_T4_10752 0x14 // 107.52s | 130 | #define ISSI3733_ABCR2_T4_10752 0x14 // 107.52s |
| 131 | 131 | ||
| 132 | // PG3: Auto Breath Control Register 3 | 132 | // PG3: Auto Breath Control Register 3 |
| 133 | #define ISSI3733_ABCR3_ABM1 0x04 // Auto Breath Control Register 3 of ABM-1 | 133 | #define ISSI3733_ABCR3_ABM1 0x04 // Auto Breath Control Register 3 of ABM-1 |
| 134 | #define ISSI3733_ABCR3_ABM2 0x08 // Auto Breath Control Register 3 of ABM-2 | 134 | #define ISSI3733_ABCR3_ABM2 0x08 // Auto Breath Control Register 3 of ABM-2 |
| 135 | #define ISSI3733_ABCR3_ABM3 0x0C // Auto Breath Control Register 3 of ABM-3 | 135 | #define ISSI3733_ABCR3_ABM3 0x0C // Auto Breath Control Register 3 of ABM-3 |
| 136 | 136 | ||
| 137 | #define ISSI3733_ABCR3_LTA_LOOP_ENDLESS 0x00 | 137 | #define ISSI3733_ABCR3_LTA_LOOP_ENDLESS 0x00 |
| 138 | #define ISSI3733_ABCR3_LTA_LOOP_1 0x01 | 138 | #define ISSI3733_ABCR3_LTA_LOOP_1 0x01 |
| @@ -158,44 +158,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 158 | #define ISSI3733_ABCR3_LB_T4 0x30 | 158 | #define ISSI3733_ABCR3_LB_T4 0x30 |
| 159 | 159 | ||
| 160 | // Loop End | 160 | // Loop End |
| 161 | #define ISSI3733_ABCR3_LE_T3 0x00 // End at Off state | 161 | #define ISSI3733_ABCR3_LE_T3 0x00 // End at Off state |
| 162 | #define ISSI3733_ABCR3_LE_T1 0x40 // End at On State | 162 | #define ISSI3733_ABCR3_LE_T1 0x40 // End at On State |
| 163 | 163 | ||
| 164 | // PG3: Auto Breath Control Register 4 | 164 | // PG3: Auto Breath Control Register 4 |
| 165 | #define ISSI3733_ABCR4_ABM1 0x05 // Auto Breath Control Register 4 of ABM-1 | 165 | #define ISSI3733_ABCR4_ABM1 0x05 // Auto Breath Control Register 4 of ABM-1 |
| 166 | #define ISSI3733_ABCR4_ABM2 0x09 // Auto Breath Control Register 4 of ABM-2 | 166 | #define ISSI3733_ABCR4_ABM2 0x09 // Auto Breath Control Register 4 of ABM-2 |
| 167 | #define ISSI3733_ABCR4_ABM3 0x0D // Auto Breath Control Register 4 of ABM-3 | 167 | #define ISSI3733_ABCR4_ABM3 0x0D // Auto Breath Control Register 4 of ABM-3 |
| 168 | 168 | ||
| 169 | #define ISSI3733_ABCR4_LTB_LOOP_ENDLESS 0x00 | 169 | #define ISSI3733_ABCR4_LTB_LOOP_ENDLESS 0x00 |
| 170 | // Or 8bit loop times | 170 | // Or 8bit loop times |
| 171 | 171 | ||
| 172 | // PG3: Time Update Register | 172 | // PG3: Time Update Register |
| 173 | #define ISSI3733_TUR 0x0E | 173 | #define ISSI3733_TUR 0x0E |
| 174 | #define ISSI3733_TUR_UPDATE 0x00 // Write to update 02h~0Dh time registers after configuring | 174 | #define ISSI3733_TUR_UPDATE 0x00 // Write to update 02h~0Dh time registers after configuring |
| 175 | 175 | ||
| 176 | // PG3: SWy Pull-Up Resistor Selection Register | 176 | // PG3: SWy Pull-Up Resistor Selection Register |
| 177 | #define ISSI3733_SWYR_PUR 0x0F | 177 | #define ISSI3733_SWYR_PUR 0x0F |
| 178 | #define ISSI3733_SWYR_PUR_NONE 0x00 // No pull-up resistor | 178 | #define ISSI3733_SWYR_PUR_NONE 0x00 // No pull-up resistor |
| 179 | #define ISSI3733_SWYR_PUR_500 0x01 // 0.5k Ohm | 179 | #define ISSI3733_SWYR_PUR_500 0x01 // 0.5k Ohm |
| 180 | #define ISSI3733_SWYR_PUR_1000 0x02 // 1.0k Ohm | 180 | #define ISSI3733_SWYR_PUR_1000 0x02 // 1.0k Ohm |
| 181 | #define ISSI3733_SWYR_PUR_2000 0x03 // 2.0k Ohm | 181 | #define ISSI3733_SWYR_PUR_2000 0x03 // 2.0k Ohm |
| 182 | #define ISSI3733_SWYR_PUR_4000 0x04 // 4.0k Ohm | 182 | #define ISSI3733_SWYR_PUR_4000 0x04 // 4.0k Ohm |
| 183 | #define ISSI3733_SWYR_PUR_8000 0x05 // 8.0k Ohm | 183 | #define ISSI3733_SWYR_PUR_8000 0x05 // 8.0k Ohm |
| 184 | #define ISSI3733_SWYR_PUR_16000 0x06 // 16k Ohm | 184 | #define ISSI3733_SWYR_PUR_16000 0x06 // 16k Ohm |
| 185 | #define ISSI3733_SWYR_PUR_32000 0x07 // 32k Ohm | 185 | #define ISSI3733_SWYR_PUR_32000 0x07 // 32k Ohm |
| 186 | 186 | ||
| 187 | // PG3: CSx Pull-Down Resistor Selection Register | 187 | // PG3: CSx Pull-Down Resistor Selection Register |
| 188 | #define ISSI3733_CSXR_PDR 0x10 | 188 | #define ISSI3733_CSXR_PDR 0x10 |
| 189 | #define ISSI3733_CSXR_PDR_NONE 0x00 // No pull-down resistor | 189 | #define ISSI3733_CSXR_PDR_NONE 0x00 // No pull-down resistor |
| 190 | #define ISSI3733_CSXR_PDR_500 0x01 // 0.5k Ohm | 190 | #define ISSI3733_CSXR_PDR_500 0x01 // 0.5k Ohm |
| 191 | #define ISSI3733_CSXR_PDR_1000 0x02 // 1.0k Ohm | 191 | #define ISSI3733_CSXR_PDR_1000 0x02 // 1.0k Ohm |
| 192 | #define ISSI3733_CSXR_PDR_2000 0x03 // 2.0k Ohm | 192 | #define ISSI3733_CSXR_PDR_2000 0x03 // 2.0k Ohm |
| 193 | #define ISSI3733_CSXR_PDR_4000 0x04 // 4.0k Ohm | 193 | #define ISSI3733_CSXR_PDR_4000 0x04 // 4.0k Ohm |
| 194 | #define ISSI3733_CSXR_PDR_8000 0x05 // 8.0k Ohm | 194 | #define ISSI3733_CSXR_PDR_8000 0x05 // 8.0k Ohm |
| 195 | #define ISSI3733_CSXR_PDR_16000 0x06 // 16k Ohm | 195 | #define ISSI3733_CSXR_PDR_16000 0x06 // 16k Ohm |
| 196 | #define ISSI3733_CSXR_PDR_32000 0x07 // 32k Ohm | 196 | #define ISSI3733_CSXR_PDR_32000 0x07 // 32k Ohm |
| 197 | 197 | ||
| 198 | // PG3: Reset Register | 198 | // PG3: Reset Register |
| 199 | #define ISSI3733_RR 0x11 // Read to reset all registers to default values | 199 | #define ISSI3733_RR 0x11 // Read to reset all registers to default values |
| 200 | 200 | ||
| 201 | #endif //_ISSI3733_DRIVER_H_ | 201 | #endif //_ISSI3733_DRIVER_H_ |
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index de12821a74..d092da8682 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c | |||
| @@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | // From keyboard's directory | 31 | // From keyboard's directory |
| 32 | #include "config_led.h" | 32 | #include "config_led.h" |
| 33 | 33 | ||
| 34 | uint8_t g_usb_state = USB_FSMSTATUS_FSMSTATE_OFF_Val; // Saved USB state from hardware value to detect changes | 34 | uint8_t g_usb_state = USB_FSMSTATUS_FSMSTATE_OFF_Val; // Saved USB state from hardware value to detect changes |
| 35 | 35 | ||
| 36 | void main_subtasks(void); | 36 | void main_subtasks(void); |
| 37 | uint8_t keyboard_leds(void); | 37 | uint8_t keyboard_leds(void); |
| @@ -42,7 +42,7 @@ void send_consumer(uint16_t data); | |||
| 42 | 42 | ||
| 43 | #ifdef DEFERRED_EXEC_ENABLE | 43 | #ifdef DEFERRED_EXEC_ENABLE |
| 44 | void deferred_exec_task(void); | 44 | void deferred_exec_task(void); |
| 45 | #endif // DEFERRED_EXEC_ENABLE | 45 | #endif // DEFERRED_EXEC_ENABLE |
| 46 | 46 | ||
| 47 | host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; | 47 | host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; |
| 48 | 48 | ||
| @@ -53,7 +53,7 @@ uint8_t keyboard_leds(void) { | |||
| 53 | if (keymap_config.nkro) | 53 | if (keymap_config.nkro) |
| 54 | return udi_hid_nkro_report_set; | 54 | return udi_hid_nkro_report_set; |
| 55 | else | 55 | else |
| 56 | #endif // NKRO_ENABLE | 56 | #endif // NKRO_ENABLE |
| 57 | return udi_hid_kbd_report_set; | 57 | return udi_hid_kbd_report_set; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -62,10 +62,10 @@ void send_keyboard(report_keyboard_t *report) { | |||
| 62 | 62 | ||
| 63 | #ifdef NKRO_ENABLE | 63 | #ifdef NKRO_ENABLE |
| 64 | if (!keymap_config.nkro) { | 64 | if (!keymap_config.nkro) { |
| 65 | #endif // NKRO_ENABLE | 65 | #endif // NKRO_ENABLE |
| 66 | while (udi_hid_kbd_b_report_trans_ongoing) { | 66 | while (udi_hid_kbd_b_report_trans_ongoing) { |
| 67 | main_subtasks(); | 67 | main_subtasks(); |
| 68 | } // Run other tasks while waiting for USB to be free | 68 | } // Run other tasks while waiting for USB to be free |
| 69 | 69 | ||
| 70 | irqflags = __get_PRIMASK(); | 70 | irqflags = __get_PRIMASK(); |
| 71 | __disable_irq(); | 71 | __disable_irq(); |
| @@ -81,7 +81,7 @@ void send_keyboard(report_keyboard_t *report) { | |||
| 81 | } else { | 81 | } else { |
| 82 | while (udi_hid_nkro_b_report_trans_ongoing) { | 82 | while (udi_hid_nkro_b_report_trans_ongoing) { |
| 83 | main_subtasks(); | 83 | main_subtasks(); |
| 84 | } // Run other tasks while waiting for USB to be free | 84 | } // Run other tasks while waiting for USB to be free |
| 85 | 85 | ||
| 86 | irqflags = __get_PRIMASK(); | 86 | irqflags = __get_PRIMASK(); |
| 87 | __disable_irq(); | 87 | __disable_irq(); |
| @@ -94,7 +94,7 @@ void send_keyboard(report_keyboard_t *report) { | |||
| 94 | __DMB(); | 94 | __DMB(); |
| 95 | __set_PRIMASK(irqflags); | 95 | __set_PRIMASK(irqflags); |
| 96 | } | 96 | } |
| 97 | #endif // NKRO_ENABLE | 97 | #endif // NKRO_ENABLE |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | void send_mouse(report_mouse_t *report) { | 100 | void send_mouse(report_mouse_t *report) { |
| @@ -111,7 +111,7 @@ void send_mouse(report_mouse_t *report) { | |||
| 111 | 111 | ||
| 112 | __DMB(); | 112 | __DMB(); |
| 113 | __set_PRIMASK(irqflags); | 113 | __set_PRIMASK(irqflags); |
| 114 | #endif // MOUSEKEY_ENABLE | 114 | #endif // MOUSEKEY_ENABLE |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | #ifdef EXTRAKEY_ENABLE | 117 | #ifdef EXTRAKEY_ENABLE |
| @@ -130,18 +130,18 @@ void send_extra(uint8_t report_id, uint16_t data) { | |||
| 130 | __DMB(); | 130 | __DMB(); |
| 131 | __set_PRIMASK(irqflags); | 131 | __set_PRIMASK(irqflags); |
| 132 | } | 132 | } |
| 133 | #endif // EXTRAKEY_ENABLE | 133 | #endif // EXTRAKEY_ENABLE |
| 134 | 134 | ||
| 135 | void send_system(uint16_t data) { | 135 | void send_system(uint16_t data) { |
| 136 | #ifdef EXTRAKEY_ENABLE | 136 | #ifdef EXTRAKEY_ENABLE |
| 137 | send_extra(REPORT_ID_SYSTEM, data); | 137 | send_extra(REPORT_ID_SYSTEM, data); |
| 138 | #endif // EXTRAKEY_ENABLE | 138 | #endif // EXTRAKEY_ENABLE |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | void send_consumer(uint16_t data) { | 141 | void send_consumer(uint16_t data) { |
| 142 | #ifdef EXTRAKEY_ENABLE | 142 | #ifdef EXTRAKEY_ENABLE |
| 143 | send_extra(REPORT_ID_CONSUMER, data); | 143 | send_extra(REPORT_ID_CONSUMER, data); |
| 144 | #endif // EXTRAKEY_ENABLE | 144 | #endif // EXTRAKEY_ENABLE |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | #ifdef CONSOLE_ENABLE | 147 | #ifdef CONSOLE_ENABLE |
| @@ -158,81 +158,81 @@ int8_t sendchar(uint8_t c) { | |||
| 158 | 158 | ||
| 159 | void main_subtask_console_flush(void) { | 159 | void main_subtask_console_flush(void) { |
| 160 | while (udi_hid_con_b_report_trans_ongoing) { | 160 | while (udi_hid_con_b_report_trans_ongoing) { |
| 161 | } // Wait for any previous transfers to complete | 161 | } // Wait for any previous transfers to complete |
| 162 | 162 | ||
| 163 | uint16_t result = console_printbuf_len; | 163 | uint16_t result = console_printbuf_len; |
| 164 | uint32_t irqflags; | 164 | uint32_t irqflags; |
| 165 | char * pconbuf = console_printbuf; // Pointer to start send from | 165 | char * pconbuf = console_printbuf; // Pointer to start send from |
| 166 | int send_out = CONSOLE_EPSIZE; // Bytes to send per transfer | 166 | int send_out = CONSOLE_EPSIZE; // Bytes to send per transfer |
| 167 | 167 | ||
| 168 | while (result > 0) { // While not error and bytes remain | 168 | while (result > 0) { // While not error and bytes remain |
| 169 | while (udi_hid_con_b_report_trans_ongoing) { | 169 | while (udi_hid_con_b_report_trans_ongoing) { |
| 170 | } // Wait for any previous transfers to complete | 170 | } // Wait for any previous transfers to complete |
| 171 | 171 | ||
| 172 | irqflags = __get_PRIMASK(); | 172 | irqflags = __get_PRIMASK(); |
| 173 | __disable_irq(); | 173 | __disable_irq(); |
| 174 | __DMB(); | 174 | __DMB(); |
| 175 | 175 | ||
| 176 | if (result < CONSOLE_EPSIZE) { // If remaining bytes are less than console epsize | 176 | if (result < CONSOLE_EPSIZE) { // If remaining bytes are less than console epsize |
| 177 | memset(udi_hid_con_report, 0, CONSOLE_EPSIZE); // Clear the buffer | 177 | memset(udi_hid_con_report, 0, CONSOLE_EPSIZE); // Clear the buffer |
| 178 | send_out = result; // Send remaining size | 178 | send_out = result; // Send remaining size |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | memcpy(udi_hid_con_report, pconbuf, send_out); // Copy data into the send buffer | 181 | memcpy(udi_hid_con_report, pconbuf, send_out); // Copy data into the send buffer |
| 182 | 182 | ||
| 183 | udi_hid_con_b_report_valid = 1; // Set report valid | 183 | udi_hid_con_b_report_valid = 1; // Set report valid |
| 184 | udi_hid_con_send_report(); // Send report | 184 | udi_hid_con_send_report(); // Send report |
| 185 | 185 | ||
| 186 | __DMB(); | 186 | __DMB(); |
| 187 | __set_PRIMASK(irqflags); | 187 | __set_PRIMASK(irqflags); |
| 188 | 188 | ||
| 189 | result -= send_out; // Decrement result by bytes sent | 189 | result -= send_out; // Decrement result by bytes sent |
| 190 | pconbuf += send_out; // Increment buffer point by bytes sent | 190 | pconbuf += send_out; // Increment buffer point by bytes sent |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | console_printbuf_len = 0; | 193 | console_printbuf_len = 0; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | #endif // CONSOLE_ENABLE | 196 | #endif // CONSOLE_ENABLE |
| 197 | 197 | ||
| 198 | void main_subtask_usb_state(void) { | 198 | void main_subtask_usb_state(void) { |
| 199 | static uint64_t fsmstate_on_delay = 0; // Delay timer to be sure USB is actually operating before bringing up hardware | 199 | static uint64_t fsmstate_on_delay = 0; // Delay timer to be sure USB is actually operating before bringing up hardware |
| 200 | uint8_t fsmstate_now = USB->DEVICE.FSMSTATUS.reg; // Current state from hardware register | 200 | uint8_t fsmstate_now = USB->DEVICE.FSMSTATUS.reg; // Current state from hardware register |
| 201 | 201 | ||
| 202 | if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_SUSPEND_Val) // If USB SUSPENDED | 202 | if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_SUSPEND_Val) // If USB SUSPENDED |
| 203 | { | 203 | { |
| 204 | fsmstate_on_delay = 0; // Clear ON delay timer | 204 | fsmstate_on_delay = 0; // Clear ON delay timer |
| 205 | 205 | ||
| 206 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_SUSPEND_Val) // If previously not SUSPENDED | 206 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_SUSPEND_Val) // If previously not SUSPENDED |
| 207 | { | 207 | { |
| 208 | suspend_power_down(); // Run suspend routine | 208 | suspend_power_down(); // Run suspend routine |
| 209 | g_usb_state = fsmstate_now; // Save current USB state | 209 | g_usb_state = fsmstate_now; // Save current USB state |
| 210 | } | 210 | } |
| 211 | } else if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_SLEEP_Val) // Else if USB SLEEPING | 211 | } else if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_SLEEP_Val) // Else if USB SLEEPING |
| 212 | { | 212 | { |
| 213 | fsmstate_on_delay = 0; // Clear ON delay timer | 213 | fsmstate_on_delay = 0; // Clear ON delay timer |
| 214 | 214 | ||
| 215 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_SLEEP_Val) // If previously not SLEEPING | 215 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_SLEEP_Val) // If previously not SLEEPING |
| 216 | { | 216 | { |
| 217 | suspend_power_down(); // Run suspend routine | 217 | suspend_power_down(); // Run suspend routine |
| 218 | g_usb_state = fsmstate_now; // Save current USB state | 218 | g_usb_state = fsmstate_now; // Save current USB state |
| 219 | } | 219 | } |
| 220 | } else if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_ON_Val) // Else if USB ON | 220 | } else if (fsmstate_now == USB_FSMSTATUS_FSMSTATE_ON_Val) // Else if USB ON |
| 221 | { | 221 | { |
| 222 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_ON_Val) // If previously not ON | 222 | if (g_usb_state != USB_FSMSTATUS_FSMSTATE_ON_Val) // If previously not ON |
| 223 | { | 223 | { |
| 224 | if (fsmstate_on_delay == 0) // If ON delay timer is cleared | 224 | if (fsmstate_on_delay == 0) // If ON delay timer is cleared |
| 225 | { | 225 | { |
| 226 | fsmstate_on_delay = timer_read64() + 250; // Set ON delay timer | 226 | fsmstate_on_delay = timer_read64() + 250; // Set ON delay timer |
| 227 | } else if (timer_read64() > fsmstate_on_delay) // Else if ON delay timer is active and timed out | 227 | } else if (timer_read64() > fsmstate_on_delay) // Else if ON delay timer is active and timed out |
| 228 | { | 228 | { |
| 229 | suspend_wakeup_init(); // Run wakeup routine | 229 | suspend_wakeup_init(); // Run wakeup routine |
| 230 | g_usb_state = fsmstate_now; // Save current USB state | 230 | g_usb_state = fsmstate_now; // Save current USB state |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | } else // Else if USB is in a state not being tracked | 233 | } else // Else if USB is in a state not being tracked |
| 234 | { | 234 | { |
| 235 | fsmstate_on_delay = 0; // Clear ON delay timer | 235 | fsmstate_on_delay = 0; // Clear ON delay timer |
| 236 | } | 236 | } |
| 237 | } | 237 | } |
| 238 | 238 | ||
| @@ -262,7 +262,9 @@ void main_subtask_usb_extra_device(void) { | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | #ifdef RAW_ENABLE | 264 | #ifdef RAW_ENABLE |
| 265 | void main_subtask_raw(void) { udi_hid_raw_receive_report(); } | 265 | void main_subtask_raw(void) { |
| 266 | udi_hid_raw_receive_report(); | ||
| 267 | } | ||
| 266 | #endif | 268 | #endif |
| 267 | 269 | ||
| 268 | void main_subtasks(void) { | 270 | void main_subtasks(void) { |
| @@ -296,7 +298,7 @@ int main(void) { | |||
| 296 | 298 | ||
| 297 | #ifdef RGB_MATRIX_ENABLE | 299 | #ifdef RGB_MATRIX_ENABLE |
| 298 | i2c1_init(); | 300 | i2c1_init(); |
| 299 | #endif // RGB_MATRIX_ENABLE | 301 | #endif // RGB_MATRIX_ENABLE |
| 300 | 302 | ||
| 301 | matrix_init(); | 303 | matrix_init(); |
| 302 | 304 | ||
| @@ -325,8 +327,9 @@ int main(void) { | |||
| 325 | 327 | ||
| 326 | i2c_led_q_init(); | 328 | i2c_led_q_init(); |
| 327 | 329 | ||
| 328 | for (uint8_t drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) I2C_LED_Q_ONOFF(drvid); // Queue data | 330 | for (uint8_t drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) |
| 329 | #endif // RGB_MATRIX_ENABLE | 331 | I2C_LED_Q_ONOFF(drvid); // Queue data |
| 332 | #endif // RGB_MATRIX_ENABLE | ||
| 330 | 333 | ||
| 331 | keyboard_setup(); | 334 | keyboard_setup(); |
| 332 | 335 | ||
| @@ -336,18 +339,18 @@ int main(void) { | |||
| 336 | 339 | ||
| 337 | #ifdef CONSOLE_ENABLE | 340 | #ifdef CONSOLE_ENABLE |
| 338 | uint64_t next_print = 0; | 341 | uint64_t next_print = 0; |
| 339 | #endif // CONSOLE_ENABLE | 342 | #endif // CONSOLE_ENABLE |
| 340 | 343 | ||
| 341 | v_5v_avg = adc_get(ADC_5V); | 344 | v_5v_avg = adc_get(ADC_5V); |
| 342 | 345 | ||
| 343 | debug_code_disable(); | 346 | debug_code_disable(); |
| 344 | 347 | ||
| 345 | while (1) { | 348 | while (1) { |
| 346 | main_subtasks(); // Note these tasks will also be run while waiting for USB keyboard polling intervals | 349 | main_subtasks(); // Note these tasks will also be run while waiting for USB keyboard polling intervals |
| 347 | 350 | ||
| 348 | if (g_usb_state == USB_FSMSTATUS_FSMSTATE_SUSPEND_Val || g_usb_state == USB_FSMSTATUS_FSMSTATE_SLEEP_Val) { | 351 | if (g_usb_state == USB_FSMSTATUS_FSMSTATE_SUSPEND_Val || g_usb_state == USB_FSMSTATUS_FSMSTATE_SLEEP_Val) { |
| 349 | if (suspend_wakeup_condition()) { | 352 | if (suspend_wakeup_condition()) { |
| 350 | udc_remotewakeup(); // Send remote wakeup signal | 353 | udc_remotewakeup(); // Send remote wakeup signal |
| 351 | wait_ms(50); | 354 | wait_ms(50); |
| 352 | } | 355 | } |
| 353 | 356 | ||
| @@ -362,12 +365,12 @@ int main(void) { | |||
| 362 | // Add any debug information here that you want to see very often | 365 | // Add any debug information here that you want to see very often |
| 363 | // dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired); | 366 | // dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired); |
| 364 | } | 367 | } |
| 365 | #endif // CONSOLE_ENABLE | 368 | #endif // CONSOLE_ENABLE |
| 366 | 369 | ||
| 367 | #ifdef DEFERRED_EXEC_ENABLE | 370 | #ifdef DEFERRED_EXEC_ENABLE |
| 368 | // Run deferred executions | 371 | // Run deferred executions |
| 369 | deferred_exec_task(); | 372 | deferred_exec_task(); |
| 370 | #endif // DEFERRED_EXEC_ENABLE | 373 | #endif // DEFERRED_EXEC_ENABLE |
| 371 | 374 | ||
| 372 | // Run housekeeping | 375 | // Run housekeeping |
| 373 | housekeeping_task(); | 376 | housekeeping_task(); |
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.h b/tmk_core/protocol/arm_atsam/main_arm_atsam.h index 5b088f0e20..78205e2e1b 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.h +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.h | |||
| @@ -20,4 +20,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | uint8_t keyboard_leds(void); | 21 | uint8_t keyboard_leds(void); |
| 22 | 22 | ||
| 23 | #endif //_MAIN_ARM_ATSAM_H_ | 23 | #endif //_MAIN_ARM_ATSAM_H_ |
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c index 0741584439..84ce3ee24b 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c | |||
| @@ -53,16 +53,20 @@ void eeconfig_update_md_led_default(void) { | |||
| 53 | eeconfig_flush_md_led(true); | 53 | eeconfig_flush_md_led(true); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void md_led_changed(void) { eeconfig_flag_md_led(true); } | 56 | void md_led_changed(void) { |
| 57 | eeconfig_flag_md_led(true); | ||
| 58 | } | ||
| 57 | 59 | ||
| 58 | // todo: use real task rather than this bodge | 60 | // todo: use real task rather than this bodge |
| 59 | void housekeeping_task_kb(void) { eeconfig_flush_md_led_task(FLUSH_TIMEOUT); } | 61 | void housekeeping_task_kb(void) { |
| 62 | eeconfig_flush_md_led_task(FLUSH_TIMEOUT); | ||
| 63 | } | ||
| 60 | 64 | ||
| 61 | __attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}}; | 65 | __attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}}; |
| 62 | static void md_rgb_matrix_config_override(int i); | 66 | static void md_rgb_matrix_config_override(int i); |
| 63 | # else | 67 | # else |
| 64 | uint8_t gcr_desired; | 68 | uint8_t gcr_desired; |
| 65 | # endif // USE_MASSDROP_CONFIGURATOR | 69 | # endif // USE_MASSDROP_CONFIGURATOR |
| 66 | 70 | ||
| 67 | void SERCOM1_0_Handler(void) { | 71 | void SERCOM1_0_Handler(void) { |
| 68 | if (SERCOM1->I2CM.INTFLAG.bit.ERROR) { | 72 | if (SERCOM1->I2CM.INTFLAG.bit.ERROR) { |
| @@ -125,9 +129,9 @@ void gcr_compute(void) { | |||
| 125 | if (v_5v < V5_CAT) { | 129 | if (v_5v < V5_CAT) { |
| 126 | I2C3733_Control_Set(0); | 130 | I2C3733_Control_Set(0); |
| 127 | // CDC_print("USB: WARNING: 5V catastrophic level reached! Disabling LED drivers!\r\n"); //Blocking print is bad here! | 131 | // CDC_print("USB: WARNING: 5V catastrophic level reached! Disabling LED drivers!\r\n"); //Blocking print is bad here! |
| 128 | v_5v_cat_hit = 20; //~100ms recover | 132 | v_5v_cat_hit = 20; //~100ms recover |
| 129 | gcr_actual = 0; // Minimize GCR | 133 | gcr_actual = 0; // Minimize GCR |
| 130 | usb_gcr_auto = 1; // Force auto mode enabled | 134 | usb_gcr_auto = 1; // Force auto mode enabled |
| 131 | return; | 135 | return; |
| 132 | } else if (v_5v_cat_hit > 1) { | 136 | } else if (v_5v_cat_hit > 1) { |
| 133 | v_5v_cat_hit--; | 137 | v_5v_cat_hit--; |
| @@ -157,24 +161,24 @@ void gcr_compute(void) { | |||
| 157 | gcr_min_counter = 0; | 161 | gcr_min_counter = 0; |
| 158 | } else if (action == ACT_GCR_INC) { | 162 | } else if (action == ACT_GCR_INC) { |
| 159 | if (LED_GCR_STEP_AUTO > LED_GCR_MAX - gcr_actual) | 163 | if (LED_GCR_STEP_AUTO > LED_GCR_MAX - gcr_actual) |
| 160 | gcr_actual = LED_GCR_MAX; // Obey max and prevent wrapping | 164 | gcr_actual = LED_GCR_MAX; // Obey max and prevent wrapping |
| 161 | else | 165 | else |
| 162 | gcr_actual += LED_GCR_STEP_AUTO; | 166 | gcr_actual += LED_GCR_STEP_AUTO; |
| 163 | gcr_min_counter = 0; | 167 | gcr_min_counter = 0; |
| 164 | } else if (action == ACT_GCR_DEC) { | 168 | } else if (action == ACT_GCR_DEC) { |
| 165 | if (LED_GCR_STEP_AUTO > gcr_actual) // Prevent wrapping | 169 | if (LED_GCR_STEP_AUTO > gcr_actual) // Prevent wrapping |
| 166 | { | 170 | { |
| 167 | gcr_actual = 0; | 171 | gcr_actual = 0; |
| 168 | // At this point, power can no longer be cut from the LED drivers, so focus on cutting out extra port if active | 172 | // At this point, power can no longer be cut from the LED drivers, so focus on cutting out extra port if active |
| 169 | if (usb_extra_state != USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG) // If not in a wait for replug state | 173 | if (usb_extra_state != USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG) // If not in a wait for replug state |
| 170 | { | 174 | { |
| 171 | if (usb_extra_state == USB_EXTRA_STATE_ENABLED) // If extra usb is enabled | 175 | if (usb_extra_state == USB_EXTRA_STATE_ENABLED) // If extra usb is enabled |
| 172 | { | 176 | { |
| 173 | gcr_min_counter++; | 177 | gcr_min_counter++; |
| 174 | if (gcr_min_counter > 200) // 5ms per check = 1s delay | 178 | if (gcr_min_counter > 200) // 5ms per check = 1s delay |
| 175 | { | 179 | { |
| 176 | USB_ExtraSetState(USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG); | 180 | USB_ExtraSetState(USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG); |
| 177 | usb_extra_manual = 0; // Force disable manual mode of extra port | 181 | usb_extra_manual = 0; // Force disable manual mode of extra port |
| 178 | if (usb_extra_manual) | 182 | if (usb_extra_manual) |
| 179 | CDC_print("USB: Disabling extra port until replug and manual mode toggle!\r\n"); | 183 | CDC_print("USB: Disabling extra port until replug and manual mode toggle!\r\n"); |
| 180 | else | 184 | else |
| @@ -275,11 +279,11 @@ static void flush(void) { | |||
| 275 | # ifdef USE_MASSDROP_CONFIGURATOR | 279 | # ifdef USE_MASSDROP_CONFIGURATOR |
| 276 | if (!led_enabled) { | 280 | if (!led_enabled) { |
| 277 | return; | 281 | return; |
| 278 | } // Prevent calculations and I2C traffic if LED drivers are not enabled | 282 | } // Prevent calculations and I2C traffic if LED drivers are not enabled |
| 279 | # else | 283 | # else |
| 280 | if (!sr_exp_data.bit.SDB_N) { | 284 | if (!sr_exp_data.bit.SDB_N) { |
| 281 | return; | 285 | return; |
| 282 | } // Prevent calculations and I2C traffic if LED drivers are not enabled | 286 | } // Prevent calculations and I2C traffic if LED drivers are not enabled |
| 283 | # endif | 287 | # endif |
| 284 | 288 | ||
| 285 | // Wait for previous transfer to complete | 289 | // Wait for previous transfer to complete |
| @@ -319,17 +323,19 @@ static void flush(void) { | |||
| 319 | pomod = (uint32_t)pomod % 10000; | 323 | pomod = (uint32_t)pomod % 10000; |
| 320 | pomod /= 100.0f; | 324 | pomod /= 100.0f; |
| 321 | 325 | ||
| 322 | # endif // USE_MASSDROP_CONFIGURATOR | 326 | # endif // USE_MASSDROP_CONFIGURATOR |
| 323 | 327 | ||
| 324 | uint8_t drvid; | 328 | uint8_t drvid; |
| 325 | 329 | ||
| 326 | // NOTE: GCR does not need to be timed with LED processing, but there is really no harm | 330 | // NOTE: GCR does not need to be timed with LED processing, but there is really no harm |
| 327 | if (gcr_actual != gcr_actual_last) { | 331 | if (gcr_actual != gcr_actual_last) { |
| 328 | for (drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) I2C_LED_Q_GCR(drvid); // Queue data | 332 | for (drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) |
| 333 | I2C_LED_Q_GCR(drvid); // Queue data | ||
| 329 | gcr_actual_last = gcr_actual; | 334 | gcr_actual_last = gcr_actual; |
| 330 | } | 335 | } |
| 331 | 336 | ||
| 332 | for (drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) I2C_LED_Q_PWM(drvid); // Queue data | 337 | for (drvid = 0; drvid < ISSI3733_DRIVER_COUNT; drvid++) |
| 338 | I2C_LED_Q_PWM(drvid); // Queue data | ||
| 333 | 339 | ||
| 334 | i2c_led_q_run(); | 340 | i2c_led_q_run(); |
| 335 | } | 341 | } |
| @@ -341,19 +347,19 @@ void md_rgb_matrix_indicators_advanced(uint8_t led_min, uint8_t led_max) { | |||
| 341 | if ( | 347 | if ( |
| 342 | # if USB_LED_NUM_LOCK_SCANCODE != 255 | 348 | # if USB_LED_NUM_LOCK_SCANCODE != 255 |
| 343 | (led_map[i].scan == USB_LED_NUM_LOCK_SCANCODE && (kbled & (1 << USB_LED_NUM_LOCK))) || | 349 | (led_map[i].scan == USB_LED_NUM_LOCK_SCANCODE && (kbled & (1 << USB_LED_NUM_LOCK))) || |
| 344 | # endif // NUM LOCK | 350 | # endif // NUM LOCK |
| 345 | # if USB_LED_CAPS_LOCK_SCANCODE != 255 | 351 | # if USB_LED_CAPS_LOCK_SCANCODE != 255 |
| 346 | (led_map[i].scan == USB_LED_CAPS_LOCK_SCANCODE && (kbled & (1 << USB_LED_CAPS_LOCK))) || | 352 | (led_map[i].scan == USB_LED_CAPS_LOCK_SCANCODE && (kbled & (1 << USB_LED_CAPS_LOCK))) || |
| 347 | # endif // CAPS LOCK | 353 | # endif // CAPS LOCK |
| 348 | # if USB_LED_SCROLL_LOCK_SCANCODE != 255 | 354 | # if USB_LED_SCROLL_LOCK_SCANCODE != 255 |
| 349 | (led_map[i].scan == USB_LED_SCROLL_LOCK_SCANCODE && (kbled & (1 << USB_LED_SCROLL_LOCK))) || | 355 | (led_map[i].scan == USB_LED_SCROLL_LOCK_SCANCODE && (kbled & (1 << USB_LED_SCROLL_LOCK))) || |
| 350 | # endif // SCROLL LOCK | 356 | # endif // SCROLL LOCK |
| 351 | # if USB_LED_COMPOSE_SCANCODE != 255 | 357 | # if USB_LED_COMPOSE_SCANCODE != 255 |
| 352 | (led_map[i].scan == USB_LED_COMPOSE_SCANCODE && (kbled & (1 << USB_LED_COMPOSE))) || | 358 | (led_map[i].scan == USB_LED_COMPOSE_SCANCODE && (kbled & (1 << USB_LED_COMPOSE))) || |
| 353 | # endif // COMPOSE | 359 | # endif // COMPOSE |
| 354 | # if USB_LED_KANA_SCANCODE != 255 | 360 | # if USB_LED_KANA_SCANCODE != 255 |
| 355 | (led_map[i].scan == USB_LED_KANA_SCANCODE && (kbled & (1 << USB_LED_KANA))) || | 361 | (led_map[i].scan == USB_LED_KANA_SCANCODE && (kbled & (1 << USB_LED_KANA))) || |
| 356 | # endif // KANA | 362 | # endif // KANA |
| 357 | (0)) { | 363 | (0)) { |
| 358 | if (rgb_matrix_get_flags() & LED_FLAG_INDICATOR) { | 364 | if (rgb_matrix_get_flags() & LED_FLAG_INDICATOR) { |
| 359 | led_buffer[i].r = 255 - led_buffer[i].r; | 365 | led_buffer[i].r = 255 - led_buffer[i].r; |
| @@ -378,7 +384,7 @@ static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, flo | |||
| 378 | float po; | 384 | float po; |
| 379 | 385 | ||
| 380 | while (f->end != 1) { | 386 | while (f->end != 1) { |
| 381 | po = pos; // Reset po for new frame | 387 | po = pos; // Reset po for new frame |
| 382 | 388 | ||
| 383 | // Add in any moving effects | 389 | // Add in any moving effects |
| 384 | if ((!led_animation_direction && f->ef & EF_SCR_R) || (led_animation_direction && (f->ef & EF_SCR_L))) { | 390 | if ((!led_animation_direction && f->ef & EF_SCR_R) || (led_animation_direction && (f->ef & EF_SCR_L))) { |
| @@ -413,17 +419,17 @@ static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, flo | |||
| 413 | 419 | ||
| 414 | // Add in any color effects | 420 | // Add in any color effects |
| 415 | if (f->ef & EF_OVER) { | 421 | if (f->ef & EF_OVER) { |
| 416 | *ro = (po * (f->re - f->rs)) + f->rs; // + 0.5; | 422 | *ro = (po * (f->re - f->rs)) + f->rs; // + 0.5; |
| 417 | *go = (po * (f->ge - f->gs)) + f->gs; // + 0.5; | 423 | *go = (po * (f->ge - f->gs)) + f->gs; // + 0.5; |
| 418 | *bo = (po * (f->be - f->bs)) + f->bs; // + 0.5; | 424 | *bo = (po * (f->be - f->bs)) + f->bs; // + 0.5; |
| 419 | } else if (f->ef & EF_SUBTRACT) { | 425 | } else if (f->ef & EF_SUBTRACT) { |
| 420 | *ro -= (po * (f->re - f->rs)) + f->rs; // + 0.5; | 426 | *ro -= (po * (f->re - f->rs)) + f->rs; // + 0.5; |
| 421 | *go -= (po * (f->ge - f->gs)) + f->gs; // + 0.5; | 427 | *go -= (po * (f->ge - f->gs)) + f->gs; // + 0.5; |
| 422 | *bo -= (po * (f->be - f->bs)) + f->bs; // + 0.5; | 428 | *bo -= (po * (f->be - f->bs)) + f->bs; // + 0.5; |
| 423 | } else { | 429 | } else { |
| 424 | *ro += (po * (f->re - f->rs)) + f->rs; // + 0.5; | 430 | *ro += (po * (f->re - f->rs)) + f->rs; // + 0.5; |
| 425 | *go += (po * (f->ge - f->gs)) + f->gs; // + 0.5; | 431 | *go += (po * (f->ge - f->gs)) + f->gs; // + 0.5; |
| 426 | *bo += (po * (f->be - f->bs)) + f->bs; // + 0.5; | 432 | *bo += (po * (f->be - f->bs)) + f->bs; // + 0.5; |
| 427 | } | 433 | } |
| 428 | 434 | ||
| 429 | f++; | 435 | f++; |
| @@ -471,10 +477,10 @@ static void md_rgb_matrix_config_override(int i) { | |||
| 471 | 477 | ||
| 472 | // Check if this applies to current index | 478 | // Check if this applies to current index |
| 473 | if (led_cur_instruction->flags & LED_FLAG_MATCH_ID) { | 479 | if (led_cur_instruction->flags & LED_FLAG_MATCH_ID) { |
| 474 | uint8_t modid = i / 32; // Calculate which id# contains the led bit | 480 | uint8_t modid = i / 32; // Calculate which id# contains the led bit |
| 475 | uint32_t modidbit = 1 << (i % 32); // Calculate the bit within the id# | 481 | uint32_t modidbit = 1 << (i % 32); // Calculate the bit within the id# |
| 476 | uint32_t* bitfield = &led_cur_instruction->id0 + modid; // Add modid as offset to id0 address. *bitfield is now idX of the led id | 482 | uint32_t* bitfield = &led_cur_instruction->id0 + modid; // Add modid as offset to id0 address. *bitfield is now idX of the led id |
| 477 | if (~(*bitfield) & modidbit) { // Check if led bit is not set in idX | 483 | if (~(*bitfield) & modidbit) { // Check if led bit is not set in idX |
| 478 | goto next_iter; | 484 | goto next_iter; |
| 479 | } | 485 | } |
| 480 | } | 486 | } |
| @@ -538,5 +544,5 @@ static void md_rgb_matrix_config_override(int i) { | |||
| 538 | led_buffer[i].b = (uint8_t)bo; | 544 | led_buffer[i].b = (uint8_t)bo; |
| 539 | } | 545 | } |
| 540 | 546 | ||
| 541 | # endif // USE_MASSDROP_CONFIGURATOR | 547 | # endif // USE_MASSDROP_CONFIGURATOR |
| 542 | #endif // RGB_MATRIX_ENABLE | 548 | #endif // RGB_MATRIX_ENABLE |
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h index deea12b888..f27da028a0 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h | |||
| @@ -31,10 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | #define ISSI3733_SW_COUNT 12 | 31 | #define ISSI3733_SW_COUNT 12 |
| 32 | 32 | ||
| 33 | #define ISSI3733_LED_RGB_COUNT ISSI3733_CS_COUNT *ISSI3733_SW_COUNT | 33 | #define ISSI3733_LED_RGB_COUNT ISSI3733_CS_COUNT *ISSI3733_SW_COUNT |
| 34 | #define ISSI3733_PG0_BYTES ISSI3733_LED_RGB_COUNT / 8 + 1 //+1 for first byte being memory start offset for I2C transfer | 34 | #define ISSI3733_PG0_BYTES ISSI3733_LED_RGB_COUNT / 8 + 1 //+1 for first byte being memory start offset for I2C transfer |
| 35 | #define ISSI3733_PG1_BYTES ISSI3733_LED_RGB_COUNT + 1 //+1 for first byte being memory start offset for I2C transfer | 35 | #define ISSI3733_PG1_BYTES ISSI3733_LED_RGB_COUNT + 1 //+1 for first byte being memory start offset for I2C transfer |
| 36 | #define ISSI3733_PG2_BYTES ISSI3733_LED_RGB_COUNT + 1 //+1 for first byte being memory start offset for I2C transfer | 36 | #define ISSI3733_PG2_BYTES ISSI3733_LED_RGB_COUNT + 1 //+1 for first byte being memory start offset for I2C transfer |
| 37 | #define ISSI3733_PG3_BYTES 18 + 1 //+1 for first byte being memory start offset for I2C transfer | 37 | #define ISSI3733_PG3_BYTES 18 + 1 //+1 for first byte being memory start offset for I2C transfer |
| 38 | 38 | ||
| 39 | #define ISSI3733_PG_ONOFF_BYTES ISSI3733_PG0_BYTES | 39 | #define ISSI3733_PG_ONOFF_BYTES ISSI3733_PG0_BYTES |
| 40 | #define ISSI3733_PG_OR_BYTES ISSI3733_PG0_BYTES | 40 | #define ISSI3733_PG_OR_BYTES ISSI3733_PG0_BYTES |
| @@ -44,38 +44,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define ISSI3733_PG_FN_BYTES ISSI3733_PG3_BYTES | 44 | #define ISSI3733_PG_FN_BYTES ISSI3733_PG3_BYTES |
| 45 | 45 | ||
| 46 | typedef struct issi3733_driver_s { | 46 | typedef struct issi3733_driver_s { |
| 47 | uint8_t addr; // Address of the driver according to wiring "ISSI3733: Table 1 Slave Address" | 47 | uint8_t addr; // Address of the driver according to wiring "ISSI3733: Table 1 Slave Address" |
| 48 | uint8_t onoff[ISSI3733_PG_ONOFF_BYTES]; // PG0 - LED Control Register - LED On/Off Register | 48 | uint8_t onoff[ISSI3733_PG_ONOFF_BYTES]; // PG0 - LED Control Register - LED On/Off Register |
| 49 | uint8_t open[ISSI3733_PG_OR_BYTES]; // PG0 - LED Control Register - LED Open Register | 49 | uint8_t open[ISSI3733_PG_OR_BYTES]; // PG0 - LED Control Register - LED Open Register |
| 50 | uint8_t shrt[ISSI3733_PG_SR_BYTES]; // PG0 - LED Control Register - LED Short Register | 50 | uint8_t shrt[ISSI3733_PG_SR_BYTES]; // PG0 - LED Control Register - LED Short Register |
| 51 | uint8_t pwm[ISSI3733_PG_PWM_BYTES]; // PG1 - PWM Register | 51 | uint8_t pwm[ISSI3733_PG_PWM_BYTES]; // PG1 - PWM Register |
| 52 | uint8_t abm[ISSI3733_PG_ABM_BYTES]; // PG2 - Auto Breath Mode Register | 52 | uint8_t abm[ISSI3733_PG_ABM_BYTES]; // PG2 - Auto Breath Mode Register |
| 53 | uint8_t conf[ISSI3733_PG_FN_BYTES]; // PG3 - Function Register | 53 | uint8_t conf[ISSI3733_PG_FN_BYTES]; // PG3 - Function Register |
| 54 | } issi3733_driver_t; | 54 | } issi3733_driver_t; |
| 55 | 55 | ||
| 56 | typedef struct issi3733_rgb_s { | 56 | typedef struct issi3733_rgb_s { |
| 57 | uint8_t *r; // Direct access into PWM data | 57 | uint8_t *r; // Direct access into PWM data |
| 58 | uint8_t *g; // Direct access into PWM data | 58 | uint8_t *g; // Direct access into PWM data |
| 59 | uint8_t *b; // Direct access into PWM data | 59 | uint8_t *b; // Direct access into PWM data |
| 60 | } issi3733_rgb_t; | 60 | } issi3733_rgb_t; |
| 61 | 61 | ||
| 62 | typedef struct issi3733_rgb_adr_s { | 62 | typedef struct issi3733_rgb_adr_s { |
| 63 | uint8_t drv; // Driver from given list | 63 | uint8_t drv; // Driver from given list |
| 64 | uint8_t cs; // CS | 64 | uint8_t cs; // CS |
| 65 | uint8_t swr; // SW Red | 65 | uint8_t swr; // SW Red |
| 66 | uint8_t swg; // SW Green | 66 | uint8_t swg; // SW Green |
| 67 | uint8_t swb; // SW Blue | 67 | uint8_t swb; // SW Blue |
| 68 | } issi3733_rgb_adr_t; | 68 | } issi3733_rgb_adr_t; |
| 69 | 69 | ||
| 70 | typedef struct issi3733_led_s { | 70 | typedef struct issi3733_led_s { |
| 71 | uint8_t id; // According to PCB ref | 71 | uint8_t id; // According to PCB ref |
| 72 | issi3733_rgb_t rgb; // PWM settings of R G B | 72 | issi3733_rgb_t rgb; // PWM settings of R G B |
| 73 | issi3733_rgb_adr_t adr; // Hardware addresses | 73 | issi3733_rgb_adr_t adr; // Hardware addresses |
| 74 | float x; // Physical position X | 74 | float x; // Physical position X |
| 75 | float y; // Physical position Y | 75 | float y; // Physical position Y |
| 76 | float px; // Physical position X in percent | 76 | float px; // Physical position X in percent |
| 77 | float py; // Physical position Y in percent | 77 | float py; // Physical position Y in percent |
| 78 | uint8_t scan; // Key scan code from wiring (set 0xFF if no key) | 78 | uint8_t scan; // Key scan code from wiring (set 0xFF if no key) |
| 79 | } issi3733_led_t; | 79 | } issi3733_led_t; |
| 80 | 80 | ||
| 81 | extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; | 81 | extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; |
| @@ -92,44 +92,44 @@ void md_rgb_matrix_indicators_advanced(uint8_t led_min, uint8_t led_max); | |||
| 92 | 92 | ||
| 93 | #ifdef USE_MASSDROP_CONFIGURATOR | 93 | #ifdef USE_MASSDROP_CONFIGURATOR |
| 94 | 94 | ||
| 95 | # define EF_NONE 0x00000000 // No effect | 95 | # define EF_NONE 0x00000000 // No effect |
| 96 | # define EF_OVER 0x00000001 // Overwrite any previous color information with new | 96 | # define EF_OVER 0x00000001 // Overwrite any previous color information with new |
| 97 | # define EF_SCR_L 0x00000002 // Scroll left | 97 | # define EF_SCR_L 0x00000002 // Scroll left |
| 98 | # define EF_SCR_R 0x00000004 // Scroll right | 98 | # define EF_SCR_R 0x00000004 // Scroll right |
| 99 | # define EF_SUBTRACT 0x00000008 // Subtract color values | 99 | # define EF_SUBTRACT 0x00000008 // Subtract color values |
| 100 | 100 | ||
| 101 | typedef struct led_setup_s { | 101 | typedef struct led_setup_s { |
| 102 | float hs; // Band begin at percent | 102 | float hs; // Band begin at percent |
| 103 | float he; // Band end at percent | 103 | float he; // Band end at percent |
| 104 | uint8_t rs; // Red start value | 104 | uint8_t rs; // Red start value |
| 105 | uint8_t re; // Red end value | 105 | uint8_t re; // Red end value |
| 106 | uint8_t gs; // Green start value | 106 | uint8_t gs; // Green start value |
| 107 | uint8_t ge; // Green end value | 107 | uint8_t ge; // Green end value |
| 108 | uint8_t bs; // Blue start value | 108 | uint8_t bs; // Blue start value |
| 109 | uint8_t be; // Blue end value | 109 | uint8_t be; // Blue end value |
| 110 | uint32_t ef; // Animation and color effects | 110 | uint32_t ef; // Animation and color effects |
| 111 | uint8_t end; // Set to signal end of the setup | 111 | uint8_t end; // Set to signal end of the setup |
| 112 | } led_setup_t; | 112 | } led_setup_t; |
| 113 | 113 | ||
| 114 | extern const uint8_t led_setups_count; | 114 | extern const uint8_t led_setups_count; |
| 115 | extern void * led_setups[]; | 115 | extern void * led_setups[]; |
| 116 | 116 | ||
| 117 | // LED Extra Instructions | 117 | // LED Extra Instructions |
| 118 | # define LED_FLAG_NULL 0x00 // Matching and coloring not used (default) | 118 | # define LED_FLAG_NULL 0x00 // Matching and coloring not used (default) |
| 119 | # define LED_FLAG_MATCH_ID 0x01 // Match on the ID of the LED (set id#'s to desired bit pattern, first LED is id 1) | 119 | # define LED_FLAG_MATCH_ID 0x01 // Match on the ID of the LED (set id#'s to desired bit pattern, first LED is id 1) |
| 120 | # define LED_FLAG_MATCH_LAYER 0x02 // Match on the current active layer (set layer to desired match layer) | 120 | # define LED_FLAG_MATCH_LAYER 0x02 // Match on the current active layer (set layer to desired match layer) |
| 121 | # define LED_FLAG_USE_RGB 0x10 // Use a specific RGB value (set r, g, b to desired output color values) | 121 | # define LED_FLAG_USE_RGB 0x10 // Use a specific RGB value (set r, g, b to desired output color values) |
| 122 | # define LED_FLAG_USE_PATTERN 0x20 // Use a specific pattern ID (set pattern_id to desired output pattern) | 122 | # define LED_FLAG_USE_PATTERN 0x20 // Use a specific pattern ID (set pattern_id to desired output pattern) |
| 123 | # define LED_FLAG_USE_ROTATE_PATTERN 0x40 // Use pattern the user has cycled to manually | 123 | # define LED_FLAG_USE_ROTATE_PATTERN 0x40 // Use pattern the user has cycled to manually |
| 124 | 124 | ||
| 125 | typedef struct led_instruction_s { | 125 | typedef struct led_instruction_s { |
| 126 | uint16_t flags; // Bitfield for LED instructions | 126 | uint16_t flags; // Bitfield for LED instructions |
| 127 | uint32_t id0; // Bitwise id, IDs 0-31 | 127 | uint32_t id0; // Bitwise id, IDs 0-31 |
| 128 | uint32_t id1; // Bitwise id, IDs 32-63 | 128 | uint32_t id1; // Bitwise id, IDs 32-63 |
| 129 | uint32_t id2; // Bitwise id, IDs 64-95 | 129 | uint32_t id2; // Bitwise id, IDs 64-95 |
| 130 | uint32_t id3; // Bitwise id, IDs 96-127 | 130 | uint32_t id3; // Bitwise id, IDs 96-127 |
| 131 | uint32_t id4; // Bitwise id, IDs 128-159 | 131 | uint32_t id4; // Bitwise id, IDs 128-159 |
| 132 | uint32_t id5; // Bitwise id, IDs 160-191 | 132 | uint32_t id5; // Bitwise id, IDs 160-191 |
| 133 | uint8_t layer; | 133 | uint8_t layer; |
| 134 | uint8_t r; | 134 | uint8_t r; |
| 135 | uint8_t g; | 135 | uint8_t g; |
| @@ -141,7 +141,7 @@ typedef struct led_instruction_s { | |||
| 141 | extern led_instruction_t led_instructions[]; | 141 | extern led_instruction_t led_instructions[]; |
| 142 | 142 | ||
| 143 | typedef struct led_config_s { | 143 | typedef struct led_config_s { |
| 144 | uint8_t ver; // assumed to be zero on eeprom reset | 144 | uint8_t ver; // assumed to be zero on eeprom reset |
| 145 | 145 | ||
| 146 | uint8_t desired_gcr; | 146 | uint8_t desired_gcr; |
| 147 | uint8_t animation_breathing; | 147 | uint8_t animation_breathing; |
| @@ -178,27 +178,27 @@ void md_led_changed(void); | |||
| 178 | # define led_ratio_brightness md_led_config.ratio_brightness | 178 | # define led_ratio_brightness md_led_config.ratio_brightness |
| 179 | # define led_edge_mode md_led_config.edge_mode | 179 | # define led_edge_mode md_led_config.edge_mode |
| 180 | 180 | ||
| 181 | # define LED_MODE_NORMAL 0 // Must be 0 | 181 | # define LED_MODE_NORMAL 0 // Must be 0 |
| 182 | # define LED_MODE_KEYS_ONLY 1 | 182 | # define LED_MODE_KEYS_ONLY 1 |
| 183 | # define LED_MODE_NON_KEYS_ONLY 2 | 183 | # define LED_MODE_NON_KEYS_ONLY 2 |
| 184 | # define LED_MODE_INDICATORS_ONLY 3 | 184 | # define LED_MODE_INDICATORS_ONLY 3 |
| 185 | # define LED_MODE_MAX_INDEX LED_MODE_INDICATORS_ONLY // Must be highest value | 185 | # define LED_MODE_MAX_INDEX LED_MODE_INDICATORS_ONLY // Must be highest value |
| 186 | 186 | ||
| 187 | # define LED_EDGE_MODE_ALL 0 // All edge LEDs are active (Must be 0) | 187 | # define LED_EDGE_MODE_ALL 0 // All edge LEDs are active (Must be 0) |
| 188 | # define LED_EDGE_MODE_ALTERNATE 1 // Alternate mode of edge LEDs are active (Intention is for 'only every other edge LED' to be active) | 188 | # define LED_EDGE_MODE_ALTERNATE 1 // Alternate mode of edge LEDs are active (Intention is for 'only every other edge LED' to be active) |
| 189 | # define LED_EDGE_MODE_MAX LED_EDGE_MODE_ALTERNATE // Must be the highest valued LED edge mode | 189 | # define LED_EDGE_MODE_MAX LED_EDGE_MODE_ALTERNATE // Must be the highest valued LED edge mode |
| 190 | 190 | ||
| 191 | # define LED_EDGE_FULL_MODE 255 // LEDs configured with this scan code will always be on for edge lighting modes | 191 | # define LED_EDGE_FULL_MODE 255 // LEDs configured with this scan code will always be on for edge lighting modes |
| 192 | # define LED_EDGE_ALT_MODE 254 // LEDs configured with this scan code will turn off in edge alternating mode | 192 | # define LED_EDGE_ALT_MODE 254 // LEDs configured with this scan code will turn off in edge alternating mode |
| 193 | # define LED_EDGE_MIN_SCAN 254 // LEDs configured with scan code >= to this are assigned as edge LEDs | 193 | # define LED_EDGE_MIN_SCAN 254 // LEDs configured with scan code >= to this are assigned as edge LEDs |
| 194 | # define LED_INDICATOR_SCAN 253 // LEDs configured as dedicated indicators | 194 | # define LED_INDICATOR_SCAN 253 // LEDs configured as dedicated indicators |
| 195 | 195 | ||
| 196 | # define LED_IS_KEY(scan) (scan < LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a key LED | 196 | # define LED_IS_KEY(scan) (scan < LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a key LED |
| 197 | # define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED | 197 | # define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED |
| 198 | # define LED_IS_EDGE_ALT(scan) (scan == LED_EDGE_ALT_MODE) // Return true if an LED's scan value indicates an alternate edge mode LED | 198 | # define LED_IS_EDGE_ALT(scan) (scan == LED_EDGE_ALT_MODE) // Return true if an LED's scan value indicates an alternate edge mode LED |
| 199 | # define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator | 199 | # define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator |
| 200 | #else | 200 | #else |
| 201 | extern uint8_t gcr_desired; | 201 | extern uint8_t gcr_desired; |
| 202 | #endif // USE_MASSDROP_CONFIGURATOR | 202 | #endif // USE_MASSDROP_CONFIGURATOR |
| 203 | 203 | ||
| 204 | #endif //_LED_MATRIX_H_ | 204 | #endif //_LED_MATRIX_H_ |
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c index 92b40b5b85..69b3ad574c 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c | |||
| @@ -97,5 +97,5 @@ void *led_setups[] = {leds_rainbow_s, leds_rainbow_ns, leds_teal_salmon, leds_ye | |||
| 97 | 97 | ||
| 98 | const uint8_t led_setups_count = sizeof(led_setups) / sizeof(led_setups[0]); | 98 | const uint8_t led_setups_count = sizeof(led_setups) / sizeof(led_setups[0]); |
| 99 | 99 | ||
| 100 | # endif // USE_MASSDROP_CONFIGURATOR | 100 | # endif // USE_MASSDROP_CONFIGURATOR |
| 101 | #endif // RGB_MATRIX_ENABLE \ No newline at end of file | 101 | #endif // RGB_MATRIX_ENABLE \ No newline at end of file |
diff --git a/tmk_core/protocol/arm_atsam/shift_register.c b/tmk_core/protocol/arm_atsam/shift_register.c index 8d63af1b59..3adb682aa8 100644 --- a/tmk_core/protocol/arm_atsam/shift_register.c +++ b/tmk_core/protocol/arm_atsam/shift_register.c | |||
| @@ -54,7 +54,9 @@ void shift_out_impl(const uint8_t *data, uint16_t length) { | |||
| 54 | 54 | ||
| 55 | #else | 55 | #else |
| 56 | 56 | ||
| 57 | void shift_init_impl(void) { spi_init(); } | 57 | void shift_init_impl(void) { |
| 58 | spi_init(); | ||
| 59 | } | ||
| 58 | 60 | ||
| 59 | void shift_out_impl(const uint8_t *data, uint16_t length) { | 61 | void shift_out_impl(const uint8_t *data, uint16_t length) { |
| 60 | spi_start(SR_EXP_RCLK_PIN, true, 0, 0); | 62 | spi_start(SR_EXP_RCLK_PIN, true, 0, 0); |
| @@ -67,7 +69,9 @@ void shift_out_impl(const uint8_t *data, uint16_t length) { | |||
| 67 | 69 | ||
| 68 | // *************************************************************** | 70 | // *************************************************************** |
| 69 | 71 | ||
| 70 | void shift_out(const uint8_t *data, uint16_t length) { shift_out_impl(data, length); } | 72 | void shift_out(const uint8_t *data, uint16_t length) { |
| 73 | shift_out_impl(data, length); | ||
| 74 | } | ||
| 71 | 75 | ||
| 72 | void shift_enable(void) { | 76 | void shift_enable(void) { |
| 73 | setPinOutput(SR_EXP_OE_PIN); | 77 | setPinOutput(SR_EXP_OE_PIN); |
| @@ -90,8 +94,8 @@ sr_exp_t sr_exp_data; | |||
| 90 | 94 | ||
| 91 | void SR_EXP_WriteData(void) { | 95 | void SR_EXP_WriteData(void) { |
| 92 | uint8_t data[2] = { | 96 | uint8_t data[2] = { |
| 93 | sr_exp_data.reg & 0xFF, // Shift in bits 7-0 | 97 | sr_exp_data.reg & 0xFF, // Shift in bits 7-0 |
| 94 | (sr_exp_data.reg >> 8) & 0xFF, // Shift in bits 15-8 | 98 | (sr_exp_data.reg >> 8) & 0xFF, // Shift in bits 15-8 |
| 95 | }; | 99 | }; |
| 96 | shift_out(data, 2); | 100 | shift_out(data, 2); |
| 97 | } | 101 | } |
diff --git a/tmk_core/protocol/arm_atsam/spi_master.c b/tmk_core/protocol/arm_atsam/spi_master.c index 9781d45b1e..3be82fac1d 100644 --- a/tmk_core/protocol/arm_atsam/spi_master.c +++ b/tmk_core/protocol/arm_atsam/spi_master.c | |||
| @@ -45,10 +45,10 @@ __attribute__((weak)) void spi_init(void) { | |||
| 45 | CLK_set_spi_freq(CHAN_SERCOM_SPI, FREQ_SPI_DEFAULT); | 45 | CLK_set_spi_freq(CHAN_SERCOM_SPI, FREQ_SPI_DEFAULT); |
| 46 | 46 | ||
| 47 | // Set up MCU SPI pins | 47 | // Set up MCU SPI pins |
| 48 | PORT->Group[SAMD_PORT(SPI_DATAOUT_PIN)].PMUX[SAMD_PIN(SPI_DATAOUT_PIN) / 2].bit.SPI_DATAOUT_MUX_SEL = SPI_DATAOUT_MUX; // MUX select for sercom | 48 | PORT->Group[SAMD_PORT(SPI_DATAOUT_PIN)].PMUX[SAMD_PIN(SPI_DATAOUT_PIN) / 2].bit.SPI_DATAOUT_MUX_SEL = SPI_DATAOUT_MUX; // MUX select for sercom |
| 49 | PORT->Group[SAMD_PORT(SPI_SCLK_PIN)].PMUX[SAMD_PIN(SPI_SCLK_PIN) / 2].bit.SPI_SCLK_MUX_SEL = SPI_SCLK_MUX; // MUX select for sercom | 49 | PORT->Group[SAMD_PORT(SPI_SCLK_PIN)].PMUX[SAMD_PIN(SPI_SCLK_PIN) / 2].bit.SPI_SCLK_MUX_SEL = SPI_SCLK_MUX; // MUX select for sercom |
| 50 | PORT->Group[SAMD_PORT(SPI_DATAOUT_PIN)].PINCFG[SAMD_PIN(SPI_DATAOUT_PIN)].bit.PMUXEN = 1; // MUX Enable | 50 | PORT->Group[SAMD_PORT(SPI_DATAOUT_PIN)].PINCFG[SAMD_PIN(SPI_DATAOUT_PIN)].bit.PMUXEN = 1; // MUX Enable |
| 51 | PORT->Group[SAMD_PORT(SPI_SCLK_PIN)].PINCFG[SAMD_PIN(SPI_SCLK_PIN)].bit.PMUXEN = 1; // MUX Enable | 51 | PORT->Group[SAMD_PORT(SPI_SCLK_PIN)].PINCFG[SAMD_PIN(SPI_SCLK_PIN)].bit.PMUXEN = 1; // MUX Enable |
| 52 | 52 | ||
| 53 | DBGC(DC_SPI_INIT_COMPLETE); | 53 | DBGC(DC_SPI_INIT_COMPLETE); |
| 54 | } | 54 | } |
| @@ -63,14 +63,14 @@ bool spi_start(pin_t csPin, bool lsbFirst, uint8_t mode, uint16_t divisor) { | |||
| 63 | setPinOutput(currentSelectPin); | 63 | setPinOutput(currentSelectPin); |
| 64 | writePinLow(currentSelectPin); | 64 | writePinLow(currentSelectPin); |
| 65 | 65 | ||
| 66 | SPI_SERCOM->SPI.CTRLA.bit.DORD = lsbFirst; // Data Order - LSB is transferred first | 66 | SPI_SERCOM->SPI.CTRLA.bit.DORD = lsbFirst; // Data Order - LSB is transferred first |
| 67 | SPI_SERCOM->SPI.CTRLA.bit.CPOL = 1; // Clock Polarity - SCK high when idle. Leading edge of cycle is falling. Trailing rising. | 67 | SPI_SERCOM->SPI.CTRLA.bit.CPOL = 1; // Clock Polarity - SCK high when idle. Leading edge of cycle is falling. Trailing rising. |
| 68 | SPI_SERCOM->SPI.CTRLA.bit.CPHA = 1; // Clock Phase - Leading Edge Falling, change, Trailing Edge - Rising, sample | 68 | SPI_SERCOM->SPI.CTRLA.bit.CPHA = 1; // Clock Phase - Leading Edge Falling, change, Trailing Edge - Rising, sample |
| 69 | SPI_SERCOM->SPI.CTRLA.bit.DIPO = 3; // Data In Pinout - SERCOM PAD[3] is used as data input (Configure away from DOPO. Not using input.) | 69 | SPI_SERCOM->SPI.CTRLA.bit.DIPO = 3; // Data In Pinout - SERCOM PAD[3] is used as data input (Configure away from DOPO. Not using input.) |
| 70 | SPI_SERCOM->SPI.CTRLA.bit.DOPO = 0; // Data Output PAD[0], Serial Clock PAD[1] | 70 | SPI_SERCOM->SPI.CTRLA.bit.DOPO = 0; // Data Output PAD[0], Serial Clock PAD[1] |
| 71 | SPI_SERCOM->SPI.CTRLA.bit.MODE = 3; // Operating Mode - Master operation | 71 | SPI_SERCOM->SPI.CTRLA.bit.MODE = 3; // Operating Mode - Master operation |
| 72 | 72 | ||
| 73 | SPI_SERCOM->SPI.CTRLA.bit.ENABLE = 1; // Enable - Peripheral is enabled or being enabled | 73 | SPI_SERCOM->SPI.CTRLA.bit.ENABLE = 1; // Enable - Peripheral is enabled or being enabled |
| 74 | while (SPI_SERCOM->SPI.SYNCBUSY.bit.ENABLE) { | 74 | while (SPI_SERCOM->SPI.SYNCBUSY.bit.ENABLE) { |
| 75 | DBGC(DC_SPI_SYNC_ENABLING); | 75 | DBGC(DC_SPI_SYNC_ENABLING); |
| 76 | } | 76 | } |
diff --git a/tmk_core/protocol/arm_atsam/usb/compiler.h b/tmk_core/protocol/arm_atsam/usb/compiler.h index 6ba2322340..517499f946 100644 --- a/tmk_core/protocol/arm_atsam/usb/compiler.h +++ b/tmk_core/protocol/arm_atsam/usb/compiler.h | |||
| @@ -876,66 +876,66 @@ typedef struct { | |||
| 876 | // kmod #define LOW 0 | 876 | // kmod #define LOW 0 |
| 877 | // kmod #define HIGH 1 | 877 | // kmod #define HIGH 1 |
| 878 | 878 | ||
| 879 | typedef int8_t S8; //!< 8-bit signed integer. | 879 | typedef int8_t S8; //!< 8-bit signed integer. |
| 880 | typedef uint8_t U8; //!< 8-bit unsigned integer. | 880 | typedef uint8_t U8; //!< 8-bit unsigned integer. |
| 881 | typedef int16_t S16; //!< 16-bit signed integer. | 881 | typedef int16_t S16; //!< 16-bit signed integer. |
| 882 | typedef uint16_t U16; //!< 16-bit unsigned integer. | 882 | typedef uint16_t U16; //!< 16-bit unsigned integer. |
| 883 | typedef int32_t S32; //!< 32-bit signed integer. | 883 | typedef int32_t S32; //!< 32-bit signed integer. |
| 884 | typedef uint32_t U32; //!< 32-bit unsigned integer. | 884 | typedef uint32_t U32; //!< 32-bit unsigned integer. |
| 885 | typedef int64_t S64; //!< 64-bit signed integer. | 885 | typedef int64_t S64; //!< 64-bit signed integer. |
| 886 | typedef uint64_t U64; //!< 64-bit unsigned integer. | 886 | typedef uint64_t U64; //!< 64-bit unsigned integer. |
| 887 | typedef float F32; //!< 32-bit floating-point number. | 887 | typedef float F32; //!< 32-bit floating-point number. |
| 888 | typedef double F64; //!< 64-bit floating-point number. | 888 | typedef double F64; //!< 64-bit floating-point number. |
| 889 | 889 | ||
| 890 | # define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16. | 890 | # define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16. |
| 891 | # define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16. | 891 | # define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16. |
| 892 | 892 | ||
| 893 | # define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32. | 893 | # define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32. |
| 894 | # define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32. | 894 | # define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32. |
| 895 | # define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. | 895 | # define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. |
| 896 | # define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. | 896 | # define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. |
| 897 | # define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. | 897 | # define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. |
| 898 | # define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. | 898 | # define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. |
| 899 | # define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. | 899 | # define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. |
| 900 | # define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. | 900 | # define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. |
| 901 | # define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. | 901 | # define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. |
| 902 | # define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. | 902 | # define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. |
| 903 | 903 | ||
| 904 | # define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64. | 904 | # define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64. |
| 905 | # define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64. | 905 | # define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64. |
| 906 | # define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64. | 906 | # define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64. |
| 907 | # define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64. | 907 | # define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64. |
| 908 | # define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64. | 908 | # define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64. |
| 909 | # define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64. | 909 | # define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64. |
| 910 | # define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64. | 910 | # define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64. |
| 911 | # define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64. | 911 | # define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64. |
| 912 | # define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64. | 912 | # define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64. |
| 913 | # define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64. | 913 | # define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64. |
| 914 | # define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64. | 914 | # define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64. |
| 915 | # define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64. | 915 | # define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64. |
| 916 | # define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64. | 916 | # define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64. |
| 917 | # define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64. | 917 | # define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64. |
| 918 | # define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64. | 918 | # define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64. |
| 919 | # define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64. | 919 | # define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64. |
| 920 | # define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64. | 920 | # define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64. |
| 921 | # define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64. | 921 | # define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64. |
| 922 | # define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64. | 922 | # define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64. |
| 923 | # define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64. | 923 | # define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64. |
| 924 | # define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64. | 924 | # define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64. |
| 925 | # define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64. | 925 | # define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64. |
| 926 | # define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64. | 926 | # define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64. |
| 927 | # define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64. | 927 | # define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64. |
| 928 | # define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64. | 928 | # define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64. |
| 929 | # define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64. | 929 | # define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64. |
| 930 | 930 | ||
| 931 | # define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32. | 931 | # define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32. |
| 932 | # define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32. | 932 | # define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32. |
| 933 | # define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32. | 933 | # define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32. |
| 934 | # define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32. | 934 | # define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32. |
| 935 | # define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32. | 935 | # define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32. |
| 936 | # define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32. | 936 | # define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32. |
| 937 | # define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32. | 937 | # define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32. |
| 938 | # define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32. | 938 | # define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32. |
| 939 | 939 | ||
| 940 | # if defined(__ICCARM__) | 940 | # if defined(__ICCARM__) |
| 941 | # define SHORTENUM __packed | 941 | # define SHORTENUM __packed |
| @@ -1031,7 +1031,9 @@ static inline void convert_16_bit_to_byte_address(uint16_t value, uint8_t *data) | |||
| 1031 | * @return 16-Bit value | 1031 | * @return 16-Bit value |
| 1032 | * @ingroup apiPalApi | 1032 | * @ingroup apiPalApi |
| 1033 | */ | 1033 | */ |
| 1034 | static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data) { return (data[0] | ((uint16_t)data[1] << 8)); } | 1034 | static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data) { |
| 1035 | return (data[0] | ((uint16_t)data[1] << 8)); | ||
| 1036 | } | ||
| 1035 | 1037 | ||
| 1036 | /* Converts a 4 Byte array into a 32-Bit value */ | 1038 | /* Converts a 4 Byte array into a 32-Bit value */ |
| 1037 | static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) { | 1039 | static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) { |
diff --git a/tmk_core/protocol/arm_atsam/usb/conf_usb.h b/tmk_core/protocol/arm_atsam/usb/conf_usb.h index 184a2e81dc..50d189a202 100644 --- a/tmk_core/protocol/arm_atsam/usb/conf_usb.h +++ b/tmk_core/protocol/arm_atsam/usb/conf_usb.h | |||
| @@ -59,7 +59,7 @@ | |||
| 59 | #define USB_DEVICE_VENDOR_ID VENDOR_ID | 59 | #define USB_DEVICE_VENDOR_ID VENDOR_ID |
| 60 | #define USB_DEVICE_PRODUCT_ID PRODUCT_ID | 60 | #define USB_DEVICE_PRODUCT_ID PRODUCT_ID |
| 61 | #define USB_DEVICE_VERSION DEVICE_VER | 61 | #define USB_DEVICE_VERSION DEVICE_VER |
| 62 | #define USB_DEVICE_POWER 500 // Consumption on Vbus line (mA) | 62 | #define USB_DEVICE_POWER 500 // Consumption on Vbus line (mA) |
| 63 | #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_BUS_POWERED) | 63 | #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_BUS_POWERED) |
| 64 | // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED) | 64 | // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED) |
| 65 | // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED) | 65 | // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED) |
| @@ -161,4 +161,4 @@ | |||
| 161 | #include "usb_main.h" | 161 | #include "usb_main.h" |
| 162 | #include "ui.h" | 162 | #include "ui.h" |
| 163 | 163 | ||
| 164 | #endif // _CONF_USB_H_ | 164 | #endif // _CONF_USB_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/main_usb.c b/tmk_core/protocol/arm_atsam/usb/main_usb.c index 5fcb9a9c61..ee6ed25b85 100644 --- a/tmk_core/protocol/arm_atsam/usb/main_usb.c +++ b/tmk_core/protocol/arm_atsam/usb/main_usb.c | |||
| @@ -25,15 +25,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | 25 | ||
| 26 | uint8_t keyboard_protocol = 1; | 26 | uint8_t keyboard_protocol = 1; |
| 27 | 27 | ||
| 28 | void main_suspend_action(void) { ui_powerdown(); } | 28 | void main_suspend_action(void) { |
| 29 | ui_powerdown(); | ||
| 30 | } | ||
| 29 | 31 | ||
| 30 | void main_resume_action(void) { ui_wakeup(); } | 32 | void main_resume_action(void) { |
| 33 | ui_wakeup(); | ||
| 34 | } | ||
| 31 | 35 | ||
| 32 | void main_sof_action(void) { ui_process(udd_get_frame_number()); } | 36 | void main_sof_action(void) { |
| 37 | ui_process(udd_get_frame_number()); | ||
| 38 | } | ||
| 33 | 39 | ||
| 34 | void main_remotewakeup_enable(void) { ui_wakeup_enable(); } | 40 | void main_remotewakeup_enable(void) { |
| 41 | ui_wakeup_enable(); | ||
| 42 | } | ||
| 35 | 43 | ||
| 36 | void main_remotewakeup_disable(void) { ui_wakeup_disable(); } | 44 | void main_remotewakeup_disable(void) { |
| 45 | ui_wakeup_disable(); | ||
| 46 | } | ||
| 37 | 47 | ||
| 38 | volatile bool main_b_kbd_enable = false; | 48 | volatile bool main_b_kbd_enable = false; |
| 39 | bool main_kbd_enable(void) { | 49 | bool main_kbd_enable(void) { |
| @@ -41,7 +51,9 @@ bool main_kbd_enable(void) { | |||
| 41 | return true; | 51 | return true; |
| 42 | } | 52 | } |
| 43 | 53 | ||
| 44 | void main_kbd_disable(void) { main_b_kbd_enable = false; } | 54 | void main_kbd_disable(void) { |
| 55 | main_b_kbd_enable = false; | ||
| 56 | } | ||
| 45 | 57 | ||
| 46 | #ifdef NKRO_ENABLE | 58 | #ifdef NKRO_ENABLE |
| 47 | volatile bool main_b_nkro_enable = false; | 59 | volatile bool main_b_nkro_enable = false; |
| @@ -50,7 +62,9 @@ bool main_nkro_enable(void) { | |||
| 50 | return true; | 62 | return true; |
| 51 | } | 63 | } |
| 52 | 64 | ||
| 53 | void main_nkro_disable(void) { main_b_nkro_enable = false; } | 65 | void main_nkro_disable(void) { |
| 66 | main_b_nkro_enable = false; | ||
| 67 | } | ||
| 54 | #endif | 68 | #endif |
| 55 | 69 | ||
| 56 | #ifdef EXTRAKEY_ENABLE | 70 | #ifdef EXTRAKEY_ENABLE |
| @@ -60,7 +74,9 @@ bool main_exk_enable(void) { | |||
| 60 | return true; | 74 | return true; |
| 61 | } | 75 | } |
| 62 | 76 | ||
| 63 | void main_exk_disable(void) { main_b_exk_enable = false; } | 77 | void main_exk_disable(void) { |
| 78 | main_b_exk_enable = false; | ||
| 79 | } | ||
| 64 | #endif | 80 | #endif |
| 65 | 81 | ||
| 66 | #ifdef CONSOLE_ENABLE | 82 | #ifdef CONSOLE_ENABLE |
| @@ -70,7 +86,9 @@ bool main_con_enable(void) { | |||
| 70 | return true; | 86 | return true; |
| 71 | } | 87 | } |
| 72 | 88 | ||
| 73 | void main_con_disable(void) { main_b_con_enable = false; } | 89 | void main_con_disable(void) { |
| 90 | main_b_con_enable = false; | ||
| 91 | } | ||
| 74 | #endif | 92 | #endif |
| 75 | 93 | ||
| 76 | #ifdef MOUSE_ENABLE | 94 | #ifdef MOUSE_ENABLE |
| @@ -80,7 +98,9 @@ bool main_mou_enable(void) { | |||
| 80 | return true; | 98 | return true; |
| 81 | } | 99 | } |
| 82 | 100 | ||
| 83 | void main_mou_disable(void) { main_b_mou_enable = false; } | 101 | void main_mou_disable(void) { |
| 102 | main_b_mou_enable = false; | ||
| 103 | } | ||
| 84 | #endif | 104 | #endif |
| 85 | 105 | ||
| 86 | #ifdef RAW_ENABLE | 106 | #ifdef RAW_ENABLE |
| @@ -90,7 +110,11 @@ bool main_raw_enable(void) { | |||
| 90 | return true; | 110 | return true; |
| 91 | } | 111 | } |
| 92 | 112 | ||
| 93 | void main_raw_disable(void) { main_b_raw_enable = false; } | 113 | void main_raw_disable(void) { |
| 114 | main_b_raw_enable = false; | ||
| 115 | } | ||
| 94 | 116 | ||
| 95 | void main_raw_receive(uint8_t *buffer, uint8_t len) { raw_hid_receive(buffer, len); } | 117 | void main_raw_receive(uint8_t *buffer, uint8_t len) { |
| 118 | raw_hid_receive(buffer, len); | ||
| 119 | } | ||
| 96 | #endif | 120 | #endif |
diff --git a/tmk_core/protocol/arm_atsam/usb/status_codes.h b/tmk_core/protocol/arm_atsam/usb/status_codes.h index a7a1230be0..72819a0d7d 100644 --- a/tmk_core/protocol/arm_atsam/usb/status_codes.h +++ b/tmk_core/protocol/arm_atsam/usb/status_codes.h | |||
| @@ -124,20 +124,20 @@ typedef enum status_code status_code_genare_t; | |||
| 124 | */ | 124 | */ |
| 125 | enum status_code_wireless { | 125 | enum status_code_wireless { |
| 126 | // STATUS_OK = 0, //!< Success | 126 | // STATUS_OK = 0, //!< Success |
| 127 | ERR_IO_ERROR = -1, //!< I/O error | 127 | ERR_IO_ERROR = -1, //!< I/O error |
| 128 | ERR_FLUSHED = -2, //!< Request flushed from queue | 128 | ERR_FLUSHED = -2, //!< Request flushed from queue |
| 129 | ERR_TIMEOUT = -3, //!< Operation timed out | 129 | ERR_TIMEOUT = -3, //!< Operation timed out |
| 130 | ERR_BAD_DATA = -4, //!< Data integrity check failed | 130 | ERR_BAD_DATA = -4, //!< Data integrity check failed |
| 131 | ERR_PROTOCOL = -5, //!< Protocol error | 131 | ERR_PROTOCOL = -5, //!< Protocol error |
| 132 | ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device | 132 | ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device |
| 133 | ERR_NO_MEMORY = -7, //!< Insufficient memory | 133 | ERR_NO_MEMORY = -7, //!< Insufficient memory |
| 134 | ERR_INVALID_ARG = -8, //!< Invalid argument | 134 | ERR_INVALID_ARG = -8, //!< Invalid argument |
| 135 | ERR_BAD_ADDRESS = -9, //!< Bad address | 135 | ERR_BAD_ADDRESS = -9, //!< Bad address |
| 136 | ERR_BUSY = -10, //!< Resource is busy | 136 | ERR_BUSY = -10, //!< Resource is busy |
| 137 | ERR_BAD_FORMAT = -11, //!< Data format not recognized | 137 | ERR_BAD_FORMAT = -11, //!< Data format not recognized |
| 138 | ERR_NO_TIMER = -12, //!< No timer available | 138 | ERR_NO_TIMER = -12, //!< No timer available |
| 139 | ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running | 139 | ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running |
| 140 | ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running | 140 | ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running |
| 141 | 141 | ||
| 142 | /** | 142 | /** |
| 143 | * \brief Operation in progress | 143 | * \brief Operation in progress |
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.c b/tmk_core/protocol/arm_atsam/usb/udc.c index 1f0c0d95d6..2a371c200a 100644 --- a/tmk_core/protocol/arm_atsam/usb/udc.c +++ b/tmk_core/protocol/arm_atsam/usb/udc.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | #include "udi.h" | 52 | #include "udi.h" |
| 53 | #include "udc.h" | 53 | #include "udc.h" |
| 54 | 54 | ||
| 55 | #define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY! | 55 | #define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY! |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | * \ingroup udc_group | 58 | * \ingroup udc_group |
| @@ -132,13 +132,13 @@ uint8_t bootloader_serial_number[BOOTLOADER_SERIAL_MAX_SIZE + 1] = ""; | |||
| 132 | static const uint8_t *udc_get_string_serial_name(void) { | 132 | static const uint8_t *udc_get_string_serial_name(void) { |
| 133 | #if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL | 133 | #if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL |
| 134 | uint32_t serial_ptrloc = (uint32_t)&_srom - 4; | 134 | uint32_t serial_ptrloc = (uint32_t)&_srom - 4; |
| 135 | uint32_t serial_address = *(uint32_t *)serial_ptrloc; // Address of bootloader's serial number if available | 135 | uint32_t serial_address = *(uint32_t *)serial_ptrloc; // Address of bootloader's serial number if available |
| 136 | 136 | ||
| 137 | if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) // Check for factory programmed serial address | 137 | if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) // Check for factory programmed serial address |
| 138 | { | 138 | { |
| 139 | if ((serial_address & 0xFF) % 4 == 0) // Check alignment | 139 | if ((serial_address & 0xFF) % 4 == 0) // Check alignment |
| 140 | { | 140 | { |
| 141 | uint16_t *serial_use = (uint16_t *)(serial_address); // Point to address of string in rom | 141 | uint16_t *serial_use = (uint16_t *)(serial_address); // Point to address of string in rom |
| 142 | uint8_t serial_length = 0; | 142 | uint8_t serial_length = 0; |
| 143 | 143 | ||
| 144 | while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) && serial_length < BOOTLOADER_SERIAL_MAX_SIZE) { | 144 | while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) && serial_length < BOOTLOADER_SERIAL_MAX_SIZE) { |
| @@ -149,7 +149,7 @@ static const uint8_t *udc_get_string_serial_name(void) { | |||
| 149 | 149 | ||
| 150 | usb_device_serial_name_size = serial_length; | 150 | usb_device_serial_name_size = serial_length; |
| 151 | 151 | ||
| 152 | return bootloader_serial_number; // Use serial programmed into bootloader rom | 152 | return bootloader_serial_number; // Use serial programmed into bootloader rom |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| 155 | #endif | 155 | #endif |
| @@ -157,9 +157,9 @@ static const uint8_t *udc_get_string_serial_name(void) { | |||
| 157 | usb_device_serial_name_size = USB_DEVICE_SERIAL_NAME_SIZE; | 157 | usb_device_serial_name_size = USB_DEVICE_SERIAL_NAME_SIZE; |
| 158 | 158 | ||
| 159 | #if defined USB_DEVICE_SERIAL_NAME | 159 | #if defined USB_DEVICE_SERIAL_NAME |
| 160 | return (const uint8_t *)USB_DEVICE_SERIAL_NAME; // Use serial supplied by keyboard's config.h | 160 | return (const uint8_t *)USB_DEVICE_SERIAL_NAME; // Use serial supplied by keyboard's config.h |
| 161 | #else | 161 | #else |
| 162 | return 0; // No serial supplied | 162 | return 0; // No serial supplied |
| 163 | #endif | 163 | #endif |
| 164 | } | 164 | } |
| 165 | 165 | ||
| @@ -169,7 +169,7 @@ static const uint8_t *udc_get_string_serial_name(void) { | |||
| 169 | */ | 169 | */ |
| 170 | #ifndef BOOTLOADER_SERIAL_MAX_SIZE | 170 | #ifndef BOOTLOADER_SERIAL_MAX_SIZE |
| 171 | # define BOOTLOADER_SERIAL_MAX_SIZE 0 | 171 | # define BOOTLOADER_SERIAL_MAX_SIZE 0 |
| 172 | #endif // BOOTLOADER_SERIAL_MAX_SIZE | 172 | #endif // BOOTLOADER_SERIAL_MAX_SIZE |
| 173 | struct udc_string_desc_t { | 173 | struct udc_string_desc_t { |
| 174 | usb_str_desc_t header; | 174 | usb_str_desc_t header; |
| 175 | le16_t string[Max(Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE), BOOTLOADER_SERIAL_MAX_SIZE)]; | 175 | le16_t string[Max(Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE), BOOTLOADER_SERIAL_MAX_SIZE)]; |
| @@ -178,14 +178,18 @@ COMPILER_WORD_ALIGNED | |||
| 178 | static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {.header.bDescriptorType = USB_DT_STRING}; | 178 | static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {.header.bDescriptorType = USB_DT_STRING}; |
| 179 | //! @} | 179 | //! @} |
| 180 | 180 | ||
| 181 | usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void) { return udc_ptr_iface; } | 181 | usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void) { |
| 182 | return udc_ptr_iface; | ||
| 183 | } | ||
| 182 | 184 | ||
| 183 | /** | 185 | /** |
| 184 | * \brief Returns a value to check the end of USB Configuration descriptor | 186 | * \brief Returns a value to check the end of USB Configuration descriptor |
| 185 | * | 187 | * |
| 186 | * \return address after the last byte of USB Configuration descriptor | 188 | * \return address after the last byte of USB Configuration descriptor |
| 187 | */ | 189 | */ |
| 188 | static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void) { return (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)udc_ptr_conf->desc + le16_to_cpu(udc_ptr_conf->desc->wTotalLength)); } | 190 | static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void) { |
| 191 | return (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)udc_ptr_conf->desc + le16_to_cpu(udc_ptr_conf->desc->wTotalLength)); | ||
| 192 | } | ||
| 189 | 193 | ||
| 190 | #if (0 != USB_DEVICE_MAX_EP) | 194 | #if (0 != USB_DEVICE_MAX_EP) |
| 191 | /** | 195 | /** |
| @@ -209,15 +213,15 @@ static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t | |||
| 209 | // If new interface descriptor is found, | 213 | // If new interface descriptor is found, |
| 210 | // then it is the end of the current global interface descriptor | 214 | // then it is the end of the current global interface descriptor |
| 211 | if (USB_DT_INTERFACE == desc->bDescriptorType) { | 215 | if (USB_DT_INTERFACE == desc->bDescriptorType) { |
| 212 | break; // End of global interface descriptor | 216 | break; // End of global interface descriptor |
| 213 | } | 217 | } |
| 214 | if (desc_id == desc->bDescriptorType) { | 218 | if (desc_id == desc->bDescriptorType) { |
| 215 | return desc; // Specific descriptor found | 219 | return desc; // Specific descriptor found |
| 216 | } | 220 | } |
| 217 | // Go to next descriptor | 221 | // Go to next descriptor |
| 218 | desc = (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)desc + desc->bLength); | 222 | desc = (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)desc + desc->bLength); |
| 219 | } | 223 | } |
| 220 | return NULL; // No specific descriptor found | 224 | return NULL; // No specific descriptor found |
| 221 | } | 225 | } |
| 222 | #endif | 226 | #endif |
| 223 | 227 | ||
| @@ -251,13 +255,13 @@ static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num) { | |||
| 251 | // A interface descriptor is found | 255 | // A interface descriptor is found |
| 252 | // Check interface and alternate setting number | 256 | // Check interface and alternate setting number |
| 253 | if ((iface_num == udc_ptr_iface->bInterfaceNumber) && (setting_num == udc_ptr_iface->bAlternateSetting)) { | 257 | if ((iface_num == udc_ptr_iface->bInterfaceNumber) && (setting_num == udc_ptr_iface->bAlternateSetting)) { |
| 254 | return true; // Interface found | 258 | return true; // Interface found |
| 255 | } | 259 | } |
| 256 | } | 260 | } |
| 257 | // Go to next descriptor | 261 | // Go to next descriptor |
| 258 | udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)((uint8_t *)udc_ptr_iface + udc_ptr_iface->bLength); | 262 | udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)((uint8_t *)udc_ptr_iface + udc_ptr_iface->bLength); |
| 259 | } | 263 | } |
| 260 | return false; // Interface not found | 264 | return false; // Interface not found |
| 261 | } | 265 | } |
| 262 | 266 | ||
| 263 | /** | 267 | /** |
| @@ -343,7 +347,9 @@ static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num) { | |||
| 343 | 347 | ||
| 344 | /*! \brief Start the USB Device stack | 348 | /*! \brief Start the USB Device stack |
| 345 | */ | 349 | */ |
| 346 | void udc_start(void) { udd_enable(); } | 350 | void udc_start(void) { |
| 351 | udd_enable(); | ||
| 352 | } | ||
| 347 | 353 | ||
| 348 | /*! \brief Stop the USB Device stack | 354 | /*! \brief Stop the USB Device stack |
| 349 | */ | 355 | */ |
| @@ -510,7 +516,7 @@ static bool udc_req_std_dev_set_feature(void) { | |||
| 510 | udd_g_ctrlreq.callback = udd_test_mode_packet; | 516 | udd_g_ctrlreq.callback = udd_test_mode_packet; |
| 511 | return true; | 517 | return true; |
| 512 | 518 | ||
| 513 | case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports | 519 | case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports |
| 514 | default: | 520 | default: |
| 515 | break; | 521 | break; |
| 516 | } | 522 | } |
| @@ -544,7 +550,9 @@ static bool udc_req_std_ep_set_feature(void) { | |||
| 544 | * \brief Change the address of device | 550 | * \brief Change the address of device |
| 545 | * Callback called at the end of request set address | 551 | * Callback called at the end of request set address |
| 546 | */ | 552 | */ |
| 547 | static void udc_valid_address(void) { udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F); } | 553 | static void udc_valid_address(void) { |
| 554 | udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F); | ||
| 555 | } | ||
| 548 | 556 | ||
| 549 | /** | 557 | /** |
| 550 | * \brief Standard device request to set device address | 558 | * \brief Standard device request to set device address |
| @@ -763,7 +771,7 @@ static bool udc_req_std_dev_set_configuration(void) { | |||
| 763 | // Enable new configuration | 771 | // Enable new configuration |
| 764 | udc_num_configuration = udd_g_ctrlreq.req.wValue & 0xFF; | 772 | udc_num_configuration = udd_g_ctrlreq.req.wValue & 0xFF; |
| 765 | if (udc_num_configuration == 0) { | 773 | if (udc_num_configuration == 0) { |
| 766 | return true; // Default empty configuration requested | 774 | return true; // Default empty configuration requested |
| 767 | } | 775 | } |
| 768 | // Update pointer of the configuration descriptor | 776 | // Update pointer of the configuration descriptor |
| 769 | #ifdef USB_DEVICE_HS_SUPPORT | 777 | #ifdef USB_DEVICE_HS_SUPPORT |
| @@ -796,10 +804,10 @@ static bool udc_req_std_iface_get_setting(void) { | |||
| 796 | udi_api_t UDC_DESC_STORAGE *udi_api; | 804 | udi_api_t UDC_DESC_STORAGE *udi_api; |
| 797 | 805 | ||
| 798 | if (udd_g_ctrlreq.req.wLength != 1) { | 806 | if (udd_g_ctrlreq.req.wLength != 1) { |
| 799 | return false; // Error in request | 807 | return false; // Error in request |
| 800 | } | 808 | } |
| 801 | if (!udc_num_configuration) { | 809 | if (!udc_num_configuration) { |
| 802 | return false; // The device is not is configured state yet | 810 | return false; // The device is not is configured state yet |
| 803 | } | 811 | } |
| 804 | 812 | ||
| 805 | // Check the interface number included in the request | 813 | // Check the interface number included in the request |
| @@ -832,10 +840,10 @@ static bool udc_req_std_iface_set_setting(void) { | |||
| 832 | uint8_t iface_num, setting_num; | 840 | uint8_t iface_num, setting_num; |
| 833 | 841 | ||
| 834 | if (udd_g_ctrlreq.req.wLength) { | 842 | if (udd_g_ctrlreq.req.wLength) { |
| 835 | return false; // Error in request | 843 | return false; // Error in request |
| 836 | } | 844 | } |
| 837 | if (!udc_num_configuration) { | 845 | if (!udc_num_configuration) { |
| 838 | return false; // The device is not is configured state yet | 846 | return false; // The device is not is configured state yet |
| 839 | } | 847 | } |
| 840 | 848 | ||
| 841 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; | 849 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; |
| @@ -859,7 +867,7 @@ static bool udc_reqstd(void) { | |||
| 859 | if (Udd_setup_is_in()) { | 867 | if (Udd_setup_is_in()) { |
| 860 | // GET Standard Requests | 868 | // GET Standard Requests |
| 861 | if (udd_g_ctrlreq.req.wLength == 0) { | 869 | if (udd_g_ctrlreq.req.wLength == 0) { |
| 862 | return false; // Error for USB host | 870 | return false; // Error for USB host |
| 863 | } | 871 | } |
| 864 | 872 | ||
| 865 | if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) { | 873 | if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) { |
| @@ -953,7 +961,7 @@ static bool udc_req_iface(void) { | |||
| 953 | udi_api_t UDC_DESC_STORAGE *udi_api; | 961 | udi_api_t UDC_DESC_STORAGE *udi_api; |
| 954 | 962 | ||
| 955 | if (0 == udc_num_configuration) { | 963 | if (0 == udc_num_configuration) { |
| 956 | return false; // The device is not is configured state yet | 964 | return false; // The device is not is configured state yet |
| 957 | } | 965 | } |
| 958 | // Check interface number | 966 | // Check interface number |
| 959 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; | 967 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; |
| @@ -987,7 +995,7 @@ static bool udc_req_ep(void) { | |||
| 987 | udi_api_t UDC_DESC_STORAGE *udi_api; | 995 | udi_api_t UDC_DESC_STORAGE *udi_api; |
| 988 | 996 | ||
| 989 | if (0 == udc_num_configuration) { | 997 | if (0 == udc_num_configuration) { |
| 990 | return false; // The device is not is configured state yet | 998 | return false; // The device is not is configured state yet |
| 991 | } | 999 | } |
| 992 | // Send this request on all enabled interfaces | 1000 | // Send this request on all enabled interfaces |
| 993 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; | 1001 | iface_num = udd_g_ctrlreq.req.wIndex & 0xFF; |
| @@ -1027,7 +1035,7 @@ bool udc_process_setup(void) { | |||
| 1027 | 1035 | ||
| 1028 | if (Udd_setup_is_in()) { | 1036 | if (Udd_setup_is_in()) { |
| 1029 | if (udd_g_ctrlreq.req.wLength == 0) { | 1037 | if (udd_g_ctrlreq.req.wLength == 0) { |
| 1030 | return false; // Error from USB host | 1038 | return false; // Error from USB host |
| 1031 | } | 1039 | } |
| 1032 | } | 1040 | } |
| 1033 | 1041 | ||
| @@ -1055,7 +1063,7 @@ bool udc_process_setup(void) { | |||
| 1055 | // Here SETUP request unknown by UDC and UDIs | 1063 | // Here SETUP request unknown by UDC and UDIs |
| 1056 | #ifdef USB_DEVICE_SPECIFIC_REQUEST | 1064 | #ifdef USB_DEVICE_SPECIFIC_REQUEST |
| 1057 | // Try to decode it in specific callback | 1065 | // Try to decode it in specific callback |
| 1058 | return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,... | 1066 | return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,... |
| 1059 | #else | 1067 | #else |
| 1060 | return false; | 1068 | return false; |
| 1061 | #endif | 1069 | #endif |
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.h b/tmk_core/protocol/arm_atsam/usb/udc.h index 8d33307d3c..f2144059eb 100644 --- a/tmk_core/protocol/arm_atsam/usb/udc.h +++ b/tmk_core/protocol/arm_atsam/usb/udc.h | |||
| @@ -172,7 +172,9 @@ extern "C" { | |||
| 172 | } | 172 | } |
| 173 | \endcode | 173 | \endcode |
| 174 | */ | 174 | */ |
| 175 | static inline bool udc_include_vbus_monitoring(void) { return udd_include_vbus_monitoring(); } | 175 | static inline bool udc_include_vbus_monitoring(void) { |
| 176 | return udd_include_vbus_monitoring(); | ||
| 177 | } | ||
| 176 | 178 | ||
| 177 | /*! \brief Start the USB Device stack | 179 | /*! \brief Start the USB Device stack |
| 178 | */ | 180 | */ |
| @@ -189,19 +191,25 @@ void udc_stop(void); | |||
| 189 | * then it will attach device when an acceptable Vbus | 191 | * then it will attach device when an acceptable Vbus |
| 190 | * level from the host is detected. | 192 | * level from the host is detected. |
| 191 | */ | 193 | */ |
| 192 | static inline void udc_attach(void) { udd_attach(); } | 194 | static inline void udc_attach(void) { |
| 195 | udd_attach(); | ||
| 196 | } | ||
| 193 | 197 | ||
| 194 | /** | 198 | /** |
| 195 | * \brief Detaches the device from the bus | 199 | * \brief Detaches the device from the bus |
| 196 | * | 200 | * |
| 197 | * The driver must remove pull-up on USB line D- or D+. | 201 | * The driver must remove pull-up on USB line D- or D+. |
| 198 | */ | 202 | */ |
| 199 | static inline void udc_detach(void) { udd_detach(); } | 203 | static inline void udc_detach(void) { |
| 204 | udd_detach(); | ||
| 205 | } | ||
| 200 | 206 | ||
| 201 | /*! \brief The USB driver sends a resume signal called \e "Upstream Resume" | 207 | /*! \brief The USB driver sends a resume signal called \e "Upstream Resume" |
| 202 | * This is authorized only when the remote wakeup feature is enabled by host. | 208 | * This is authorized only when the remote wakeup feature is enabled by host. |
| 203 | */ | 209 | */ |
| 204 | inline void udc_remotewakeup(void) { udd_send_remotewakeup(); } | 210 | inline void udc_remotewakeup(void) { |
| 211 | udd_send_remotewakeup(); | ||
| 212 | } | ||
| 205 | 213 | ||
| 206 | /** | 214 | /** |
| 207 | * \brief Returns a pointer on the current interface descriptor | 215 | * \brief Returns a pointer on the current interface descriptor |
| @@ -245,4 +253,4 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void); | |||
| 245 | } | 253 | } |
| 246 | #endif | 254 | #endif |
| 247 | 255 | ||
| 248 | #endif // _UDC_H_ | 256 | #endif // _UDC_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udc_desc.h b/tmk_core/protocol/arm_atsam/usb/udc_desc.h index 39ea153b40..50861da964 100644 --- a/tmk_core/protocol/arm_atsam/usb/udc_desc.h +++ b/tmk_core/protocol/arm_atsam/usb/udc_desc.h | |||
| @@ -129,4 +129,4 @@ extern UDC_DESC_STORAGE udc_config_t udc_config; | |||
| 129 | #ifdef __cplusplus | 129 | #ifdef __cplusplus |
| 130 | } | 130 | } |
| 131 | #endif | 131 | #endif |
| 132 | #endif // _UDC_DESC_H_ | 132 | #endif // _UDC_DESC_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udd.h b/tmk_core/protocol/arm_atsam/usb/udd.h index 805b761a77..d9f58baf0b 100644 --- a/tmk_core/protocol/arm_atsam/usb/udd.h +++ b/tmk_core/protocol/arm_atsam/usb/udd.h | |||
| @@ -381,4 +381,4 @@ extern void udc_sof_notify(void); | |||
| 381 | #ifdef __cplusplus | 381 | #ifdef __cplusplus |
| 382 | } | 382 | } |
| 383 | #endif | 383 | #endif |
| 384 | #endif // _UDD_H_ | 384 | #endif // _UDD_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi.h b/tmk_core/protocol/arm_atsam/usb/udi.h index 89942cce4d..60b117f3ca 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi.h +++ b/tmk_core/protocol/arm_atsam/usb/udi.h | |||
| @@ -130,4 +130,4 @@ typedef struct { | |||
| 130 | #ifdef __cplusplus | 130 | #ifdef __cplusplus |
| 131 | } | 131 | } |
| 132 | #endif | 132 | #endif |
| 133 | #endif // _UDI_H_ | 133 | #endif // _UDI_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c index 27db4017c4..0391b49f66 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c | |||
| @@ -386,7 +386,7 @@ bool udi_cdc_comm_setup(void) { | |||
| 386 | switch (udd_g_ctrlreq.req.bRequest) { | 386 | switch (udd_g_ctrlreq.req.bRequest) { |
| 387 | case USB_REQ_CDC_GET_LINE_CODING: | 387 | case USB_REQ_CDC_GET_LINE_CODING: |
| 388 | // Get configuration of CDC line | 388 | // Get configuration of CDC line |
| 389 | if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host | 389 | if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host |
| 390 | udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port]; | 390 | udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port]; |
| 391 | udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t); | 391 | udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t); |
| 392 | return true; | 392 | return true; |
| @@ -400,7 +400,7 @@ bool udi_cdc_comm_setup(void) { | |||
| 400 | switch (udd_g_ctrlreq.req.bRequest) { | 400 | switch (udd_g_ctrlreq.req.bRequest) { |
| 401 | case USB_REQ_CDC_SET_LINE_CODING: | 401 | case USB_REQ_CDC_SET_LINE_CODING: |
| 402 | // Change configuration of CDC line | 402 | // Change configuration of CDC line |
| 403 | if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host | 403 | if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host |
| 404 | udd_g_ctrlreq.callback = udi_cdc_line_coding_received; | 404 | udd_g_ctrlreq.callback = udi_cdc_line_coding_received; |
| 405 | udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port]; | 405 | udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port]; |
| 406 | udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t); | 406 | udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t); |
| @@ -417,15 +417,15 @@ bool udi_cdc_comm_setup(void) { | |||
| 417 | } | 417 | } |
| 418 | } | 418 | } |
| 419 | } | 419 | } |
| 420 | return false; // request Not supported | 420 | return false; // request Not supported |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | bool udi_cdc_data_setup(void) { | 423 | bool udi_cdc_data_setup(void) { |
| 424 | return false; // request Not supported | 424 | return false; // request Not supported |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | uint8_t udi_cdc_getsetting(void) { | 427 | uint8_t udi_cdc_getsetting(void) { |
| 428 | return 0; // CDC don't have multiple alternate setting | 428 | return 0; // CDC don't have multiple alternate setting |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | void udi_cdc_data_sof_notify(void) { | 431 | void udi_cdc_data_sof_notify(void) { |
| @@ -476,7 +476,7 @@ static void udi_cdc_line_coding_received(void) { | |||
| 476 | 476 | ||
| 477 | static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) { | 477 | static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) { |
| 478 | udd_ep_id_t ep_comm; | 478 | udd_ep_id_t ep_comm; |
| 479 | uint32_t irqflags; // irqflags_t | 479 | uint32_t irqflags; // irqflags_t |
| 480 | 480 | ||
| 481 | //#if UDI_CDC_PORT_NB == 1 // To optimize code | 481 | //#if UDI_CDC_PORT_NB == 1 // To optimize code |
| 482 | port = 0; | 482 | port = 0; |
| @@ -514,7 +514,7 @@ static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) | |||
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | static void udi_cdc_ctrl_state_notify(uint8_t port, udd_ep_id_t ep) { | 516 | static void udi_cdc_ctrl_state_notify(uint8_t port, udd_ep_id_t ep) { |
| 517 | # if UDI_CDC_PORT_NB == 1 // To optimize code | 517 | # if UDI_CDC_PORT_NB == 1 // To optimize code |
| 518 | port = 0; | 518 | port = 0; |
| 519 | # endif | 519 | # endif |
| 520 | 520 | ||
| @@ -562,7 +562,7 @@ static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n, | |||
| 562 | //------- Internal routines to process data transfer | 562 | //------- Internal routines to process data transfer |
| 563 | 563 | ||
| 564 | static bool udi_cdc_rx_start(uint8_t port) { | 564 | static bool udi_cdc_rx_start(uint8_t port) { |
| 565 | uint32_t irqflags; // irqflags_t | 565 | uint32_t irqflags; // irqflags_t |
| 566 | uint8_t buf_sel_trans; | 566 | uint8_t buf_sel_trans; |
| 567 | udd_ep_id_t ep; | 567 | udd_ep_id_t ep; |
| 568 | 568 | ||
| @@ -685,7 +685,7 @@ static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t | |||
| 685 | } | 685 | } |
| 686 | 686 | ||
| 687 | static void udi_cdc_tx_send(uint8_t port) { | 687 | static void udi_cdc_tx_send(uint8_t port) { |
| 688 | uint32_t irqflags; // irqflags_t | 688 | uint32_t irqflags; // irqflags_t |
| 689 | uint8_t buf_sel_trans; | 689 | uint8_t buf_sel_trans; |
| 690 | bool b_short_packet; | 690 | bool b_short_packet; |
| 691 | udd_ep_id_t ep; | 691 | udd_ep_id_t ep; |
| @@ -696,15 +696,15 @@ static void udi_cdc_tx_send(uint8_t port) { | |||
| 696 | //#endif | 696 | //#endif |
| 697 | 697 | ||
| 698 | if (udi_cdc_tx_trans_ongoing[port]) { | 698 | if (udi_cdc_tx_trans_ongoing[port]) { |
| 699 | return; // Already on going or wait next SOF to send next data | 699 | return; // Already on going or wait next SOF to send next data |
| 700 | } | 700 | } |
| 701 | if (udd_is_high_speed()) { | 701 | if (udd_is_high_speed()) { |
| 702 | if (udi_cdc_tx_sof_num[port] == udd_get_micro_frame_number()) { | 702 | if (udi_cdc_tx_sof_num[port] == udd_get_micro_frame_number()) { |
| 703 | return; // Wait next SOF to send next data | 703 | return; // Wait next SOF to send next data |
| 704 | } | 704 | } |
| 705 | } else { | 705 | } else { |
| 706 | if (udi_cdc_tx_sof_num[port] == udd_get_frame_number()) { | 706 | if (udi_cdc_tx_sof_num[port] == udd_get_frame_number()) { |
| 707 | return; // Wait next SOF to send next data | 707 | return; // Wait next SOF to send next data |
| 708 | } | 708 | } |
| 709 | } | 709 | } |
| 710 | 710 | ||
| @@ -743,7 +743,7 @@ static void udi_cdc_tx_send(uint8_t port) { | |||
| 743 | udi_cdc_tx_sof_num[port] = udd_get_frame_number(); | 743 | udi_cdc_tx_sof_num[port] = udd_get_frame_number(); |
| 744 | } | 744 | } |
| 745 | } else { | 745 | } else { |
| 746 | udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF | 746 | udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF |
| 747 | } | 747 | } |
| 748 | 748 | ||
| 749 | /* | 749 | /* |
| @@ -768,28 +768,48 @@ static void udi_cdc_tx_send(uint8_t port) { | |||
| 768 | //--------------------------------------------- | 768 | //--------------------------------------------- |
| 769 | //------- Application interface | 769 | //------- Application interface |
| 770 | 770 | ||
| 771 | void udi_cdc_ctrl_signal_dcd(bool b_set) { udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DCD); } | 771 | void udi_cdc_ctrl_signal_dcd(bool b_set) { |
| 772 | udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DCD); | ||
| 773 | } | ||
| 772 | 774 | ||
| 773 | void udi_cdc_ctrl_signal_dsr(bool b_set) { udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR); } | 775 | void udi_cdc_ctrl_signal_dsr(bool b_set) { |
| 776 | udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR); | ||
| 777 | } | ||
| 774 | 778 | ||
| 775 | void udi_cdc_signal_framing_error(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING); } | 779 | void udi_cdc_signal_framing_error(void) { |
| 780 | udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING); | ||
| 781 | } | ||
| 776 | 782 | ||
| 777 | void udi_cdc_signal_parity_error(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY); } | 783 | void udi_cdc_signal_parity_error(void) { |
| 784 | udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY); | ||
| 785 | } | ||
| 778 | 786 | ||
| 779 | void udi_cdc_signal_overrun(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN); } | 787 | void udi_cdc_signal_overrun(void) { |
| 788 | udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN); | ||
| 789 | } | ||
| 780 | 790 | ||
| 781 | void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set) { udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DCD); } | 791 | void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set) { |
| 792 | udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DCD); | ||
| 793 | } | ||
| 782 | 794 | ||
| 783 | void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set) { udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DSR); } | 795 | void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set) { |
| 796 | udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DSR); | ||
| 797 | } | ||
| 784 | 798 | ||
| 785 | void udi_cdc_multi_signal_framing_error(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_FRAMING); } | 799 | void udi_cdc_multi_signal_framing_error(uint8_t port) { |
| 800 | udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_FRAMING); | ||
| 801 | } | ||
| 786 | 802 | ||
| 787 | void udi_cdc_multi_signal_parity_error(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_PARITY); } | 803 | void udi_cdc_multi_signal_parity_error(uint8_t port) { |
| 804 | udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_PARITY); | ||
| 805 | } | ||
| 788 | 806 | ||
| 789 | void udi_cdc_multi_signal_overrun(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_OVERRUN); } | 807 | void udi_cdc_multi_signal_overrun(uint8_t port) { |
| 808 | udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_OVERRUN); | ||
| 809 | } | ||
| 790 | 810 | ||
| 791 | iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port) { | 811 | iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port) { |
| 792 | uint32_t irqflags; // irqflags_t | 812 | uint32_t irqflags; // irqflags_t |
| 793 | uint16_t pos; | 813 | uint16_t pos; |
| 794 | iram_size_t nb_received; | 814 | iram_size_t nb_received; |
| 795 | 815 | ||
| @@ -807,14 +827,20 @@ iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port) { | |||
| 807 | return nb_received; | 827 | return nb_received; |
| 808 | } | 828 | } |
| 809 | 829 | ||
| 810 | iram_size_t udi_cdc_get_nb_received_data(void) { return udi_cdc_multi_get_nb_received_data(0); } | 830 | iram_size_t udi_cdc_get_nb_received_data(void) { |
| 831 | return udi_cdc_multi_get_nb_received_data(0); | ||
| 832 | } | ||
| 811 | 833 | ||
| 812 | bool udi_cdc_multi_is_rx_ready(uint8_t port) { return (udi_cdc_multi_get_nb_received_data(port) > 0); } | 834 | bool udi_cdc_multi_is_rx_ready(uint8_t port) { |
| 835 | return (udi_cdc_multi_get_nb_received_data(port) > 0); | ||
| 836 | } | ||
| 813 | 837 | ||
| 814 | bool udi_cdc_is_rx_ready(void) { return udi_cdc_multi_is_rx_ready(0); } | 838 | bool udi_cdc_is_rx_ready(void) { |
| 839 | return udi_cdc_multi_is_rx_ready(0); | ||
| 840 | } | ||
| 815 | 841 | ||
| 816 | int udi_cdc_multi_getc(uint8_t port) { | 842 | int udi_cdc_multi_getc(uint8_t port) { |
| 817 | uint32_t irqflags; // irqflags_t | 843 | uint32_t irqflags; // irqflags_t |
| 818 | int rx_data = 0; | 844 | int rx_data = 0; |
| 819 | bool b_databit_9; | 845 | bool b_databit_9; |
| 820 | uint16_t pos; | 846 | uint16_t pos; |
| @@ -859,10 +885,12 @@ udi_cdc_getc_process_one_byte: | |||
| 859 | return rx_data; | 885 | return rx_data; |
| 860 | } | 886 | } |
| 861 | 887 | ||
| 862 | int udi_cdc_getc(void) { return udi_cdc_multi_getc(0); } | 888 | int udi_cdc_getc(void) { |
| 889 | return udi_cdc_multi_getc(0); | ||
| 890 | } | ||
| 863 | 891 | ||
| 864 | iram_size_t udi_cdc_multi_read_buf(uint8_t port, void *buf, iram_size_t size) { | 892 | iram_size_t udi_cdc_multi_read_buf(uint8_t port, void *buf, iram_size_t size) { |
| 865 | uint32_t irqflags; // irqflags_t | 893 | uint32_t irqflags; // irqflags_t |
| 866 | uint8_t * ptr_buf = (uint8_t *)buf; | 894 | uint8_t * ptr_buf = (uint8_t *)buf; |
| 867 | iram_size_t copy_nb; | 895 | iram_size_t copy_nb; |
| 868 | uint16_t pos; | 896 | uint16_t pos; |
| @@ -912,7 +940,7 @@ static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void *buf, iram_s | |||
| 912 | iram_size_t nb_avail_data; | 940 | iram_size_t nb_avail_data; |
| 913 | uint16_t pos; | 941 | uint16_t pos; |
| 914 | uint8_t buf_sel; | 942 | uint8_t buf_sel; |
| 915 | uint32_t irqflags; // irqflags_t | 943 | uint32_t irqflags; // irqflags_t |
| 916 | 944 | ||
| 917 | //#if UDI_CDC_PORT_NB == 1 // To optimize code | 945 | //#if UDI_CDC_PORT_NB == 1 // To optimize code |
| 918 | port = 0; | 946 | port = 0; |
| @@ -952,12 +980,16 @@ static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void *buf, iram_s | |||
| 952 | return (nb_avail_data); | 980 | return (nb_avail_data); |
| 953 | } | 981 | } |
| 954 | 982 | ||
| 955 | iram_size_t udi_cdc_read_no_polling(void *buf, iram_size_t size) { return udi_cdc_multi_read_no_polling(0, buf, size); } | 983 | iram_size_t udi_cdc_read_no_polling(void *buf, iram_size_t size) { |
| 984 | return udi_cdc_multi_read_no_polling(0, buf, size); | ||
| 985 | } | ||
| 956 | 986 | ||
| 957 | iram_size_t udi_cdc_read_buf(void *buf, iram_size_t size) { return udi_cdc_multi_read_buf(0, buf, size); } | 987 | iram_size_t udi_cdc_read_buf(void *buf, iram_size_t size) { |
| 988 | return udi_cdc_multi_read_buf(0, buf, size); | ||
| 989 | } | ||
| 958 | 990 | ||
| 959 | iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port) { | 991 | iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port) { |
| 960 | uint32_t irqflags; // irqflags_t | 992 | uint32_t irqflags; // irqflags_t |
| 961 | iram_size_t buf_sel_nb, retval; | 993 | iram_size_t buf_sel_nb, retval; |
| 962 | uint8_t buf_sel; | 994 | uint8_t buf_sel; |
| 963 | 995 | ||
| @@ -986,14 +1018,20 @@ iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port) { | |||
| 986 | return retval; | 1018 | return retval; |
| 987 | } | 1019 | } |
| 988 | 1020 | ||
| 989 | iram_size_t udi_cdc_get_free_tx_buffer(void) { return udi_cdc_multi_get_free_tx_buffer(0); } | 1021 | iram_size_t udi_cdc_get_free_tx_buffer(void) { |
| 1022 | return udi_cdc_multi_get_free_tx_buffer(0); | ||
| 1023 | } | ||
| 990 | 1024 | ||
| 991 | bool udi_cdc_multi_is_tx_ready(uint8_t port) { return (udi_cdc_multi_get_free_tx_buffer(port) != 0); } | 1025 | bool udi_cdc_multi_is_tx_ready(uint8_t port) { |
| 1026 | return (udi_cdc_multi_get_free_tx_buffer(port) != 0); | ||
| 1027 | } | ||
| 992 | 1028 | ||
| 993 | bool udi_cdc_is_tx_ready(void) { return udi_cdc_multi_is_tx_ready(0); } | 1029 | bool udi_cdc_is_tx_ready(void) { |
| 1030 | return udi_cdc_multi_is_tx_ready(0); | ||
| 1031 | } | ||
| 994 | 1032 | ||
| 995 | int udi_cdc_multi_putc(uint8_t port, int value) { | 1033 | int udi_cdc_multi_putc(uint8_t port, int value) { |
| 996 | uint32_t irqflags; // irqflags_t | 1034 | uint32_t irqflags; // irqflags_t |
| 997 | bool b_databit_9; | 1035 | bool b_databit_9; |
| 998 | uint8_t buf_sel; | 1036 | uint8_t buf_sel; |
| 999 | 1037 | ||
| @@ -1030,10 +1068,12 @@ udi_cdc_putc_process_one_byte: | |||
| 1030 | return true; | 1068 | return true; |
| 1031 | } | 1069 | } |
| 1032 | 1070 | ||
| 1033 | int udi_cdc_putc(int value) { return udi_cdc_multi_putc(0, value); } | 1071 | int udi_cdc_putc(int value) { |
| 1072 | return udi_cdc_multi_putc(0, value); | ||
| 1073 | } | ||
| 1034 | 1074 | ||
| 1035 | iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void *buf, iram_size_t size) { | 1075 | iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void *buf, iram_size_t size) { |
| 1036 | uint32_t irqflags; // irqflags_t | 1076 | uint32_t irqflags; // irqflags_t |
| 1037 | uint8_t buf_sel; | 1077 | uint8_t buf_sel; |
| 1038 | uint16_t buf_nb; | 1078 | uint16_t buf_nb; |
| 1039 | iram_size_t copy_nb; | 1079 | iram_size_t copy_nb; |
| @@ -1083,7 +1123,9 @@ udi_cdc_write_buf_loop_wait: | |||
| 1083 | return 0; | 1123 | return 0; |
| 1084 | } | 1124 | } |
| 1085 | 1125 | ||
| 1086 | iram_size_t udi_cdc_write_buf(const void *buf, iram_size_t size) { return udi_cdc_multi_write_buf(0, buf, size); } | 1126 | iram_size_t udi_cdc_write_buf(const void *buf, iram_size_t size) { |
| 1127 | return udi_cdc_multi_write_buf(0, buf, size); | ||
| 1128 | } | ||
| 1087 | 1129 | ||
| 1088 | # define MAX_PRINT 256 | 1130 | # define MAX_PRINT 256 |
| 1089 | # define CDC_SEND_INTERVAL 2 | 1131 | # define CDC_SEND_INTERVAL 2 |
| @@ -1121,10 +1163,10 @@ uint32_t CDC_print(char *printbuf) { | |||
| 1121 | char printbuf[CDC_PRINTBUF_SIZE]; | 1163 | char printbuf[CDC_PRINTBUF_SIZE]; |
| 1122 | 1164 | ||
| 1123 | int CDC_printf(const char *_Format, ...) { | 1165 | int CDC_printf(const char *_Format, ...) { |
| 1124 | va_list va; // Variable argument list variable | 1166 | va_list va; // Variable argument list variable |
| 1125 | int result; | 1167 | int result; |
| 1126 | 1168 | ||
| 1127 | va_start(va, _Format); // Initialize the variable argument list | 1169 | va_start(va, _Format); // Initialize the variable argument list |
| 1128 | result = vsnprintf(printbuf, CDC_PRINTBUF_SIZE, _Format, va); | 1170 | result = vsnprintf(printbuf, CDC_PRINTBUF_SIZE, _Format, va); |
| 1129 | va_end(va); | 1171 | va_end(va); |
| 1130 | 1172 | ||
| @@ -1146,18 +1188,18 @@ uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size) { | |||
| 1146 | 1188 | ||
| 1147 | if (RXChar) { | 1189 | if (RXChar) { |
| 1148 | switch (RXChar) { | 1190 | switch (RXChar) { |
| 1149 | case '\t': // tab - repeat last | 1191 | case '\t': // tab - repeat last |
| 1150 | inbuf.count = inbuf.lastcount; | 1192 | inbuf.count = inbuf.lastcount; |
| 1151 | inbuf.buf[inbuf.count + 1] = 0; | 1193 | inbuf.buf[inbuf.count + 1] = 0; |
| 1152 | CDC_print(inbuf.buf); | 1194 | CDC_print(inbuf.buf); |
| 1153 | break; | 1195 | break; |
| 1154 | case '\r': // enter | 1196 | case '\r': // enter |
| 1155 | inbuf.buf[inbuf.count] = 0; | 1197 | inbuf.buf[inbuf.count] = 0; |
| 1156 | inbuf.lastcount = inbuf.count; | 1198 | inbuf.lastcount = inbuf.count; |
| 1157 | inbuf.count = 0; | 1199 | inbuf.count = 0; |
| 1158 | entered = 1; | 1200 | entered = 1; |
| 1159 | break; | 1201 | break; |
| 1160 | case '\b': // backspace | 1202 | case '\b': // backspace |
| 1161 | if (inbuf.count > 0) { | 1203 | if (inbuf.count > 0) { |
| 1162 | inbuf.count -= 1; | 1204 | inbuf.count -= 1; |
| 1163 | CDC_print("\b \b\0"); | 1205 | CDC_print("\b \b\0"); |
| @@ -1181,7 +1223,9 @@ uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size) { | |||
| 1181 | return entered; | 1223 | return entered; |
| 1182 | } | 1224 | } |
| 1183 | 1225 | ||
| 1184 | uint32_t CDC_input() { return CDC_input_buf(inbuf, CDC_INBUF_SIZE); } | 1226 | uint32_t CDC_input() { |
| 1227 | return CDC_input_buf(inbuf, CDC_INBUF_SIZE); | ||
| 1228 | } | ||
| 1185 | 1229 | ||
| 1186 | void CDC_init(void) { | 1230 | void CDC_init(void) { |
| 1187 | inbuf.count = 0; | 1231 | inbuf.count = 0; |
| @@ -1190,19 +1234,27 @@ void CDC_init(void) { | |||
| 1190 | cdc_tx_send_time_next = timer_read64() + CDC_SEND_INTERVAL; | 1234 | cdc_tx_send_time_next = timer_read64() + CDC_SEND_INTERVAL; |
| 1191 | } | 1235 | } |
| 1192 | 1236 | ||
| 1193 | #else // CDC line 62 | 1237 | #else // CDC line 62 |
| 1194 | 1238 | ||
| 1195 | char printbuf[CDC_PRINTBUF_SIZE]; | 1239 | char printbuf[CDC_PRINTBUF_SIZE]; |
| 1196 | 1240 | ||
| 1197 | void CDC_send(void) { return; } | 1241 | void CDC_send(void) { |
| 1242 | return; | ||
| 1243 | } | ||
| 1198 | 1244 | ||
| 1199 | uint32_t CDC_print(char *printbuf) { return 0; } | 1245 | uint32_t CDC_print(char *printbuf) { |
| 1246 | return 0; | ||
| 1247 | } | ||
| 1200 | 1248 | ||
| 1201 | int CDC_printf(const char *_Format, ...) { return 0; } | 1249 | int CDC_printf(const char *_Format, ...) { |
| 1250 | return 0; | ||
| 1251 | } | ||
| 1202 | 1252 | ||
| 1203 | inbuf_t inbuf; | 1253 | inbuf_t inbuf; |
| 1204 | 1254 | ||
| 1205 | uint32_t CDC_input(void) { return 0; } | 1255 | uint32_t CDC_input(void) { |
| 1256 | return 0; | ||
| 1257 | } | ||
| 1206 | 1258 | ||
| 1207 | void CDC_init(void) { | 1259 | void CDC_init(void) { |
| 1208 | inbuf.count = 0; | 1260 | inbuf.count = 0; |
| @@ -1210,6 +1262,6 @@ void CDC_init(void) { | |||
| 1210 | printbuf[0] = 0; | 1262 | printbuf[0] = 0; |
| 1211 | } | 1263 | } |
| 1212 | 1264 | ||
| 1213 | #endif // CDC line 62 | 1265 | #endif // CDC line 62 |
| 1214 | 1266 | ||
| 1215 | //@} | 1267 | //@} |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc.h b/tmk_core/protocol/arm_atsam/usb/udi_cdc.h index 406023980c..ff4f521ce0 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_cdc.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc.h | |||
| @@ -346,7 +346,7 @@ typedef struct { | |||
| 346 | char buf[CDC_INBUF_SIZE]; | 346 | char buf[CDC_INBUF_SIZE]; |
| 347 | } inbuf_t; | 347 | } inbuf_t; |
| 348 | 348 | ||
| 349 | #else // VIRTSER_ENABLE | 349 | #else // VIRTSER_ENABLE |
| 350 | 350 | ||
| 351 | // keep these to accommodate calls if remaining | 351 | // keep these to accommodate calls if remaining |
| 352 | # define CDC_PRINTBUF_SIZE 1 | 352 | # define CDC_PRINTBUF_SIZE 1 |
| @@ -362,7 +362,7 @@ typedef struct { | |||
| 362 | 362 | ||
| 363 | extern inbuf_t inbuf; | 363 | extern inbuf_t inbuf; |
| 364 | 364 | ||
| 365 | #endif // VIRTSER_ENABLE | 365 | #endif // VIRTSER_ENABLE |
| 366 | 366 | ||
| 367 | uint32_t CDC_print(char* printbuf); | 367 | uint32_t CDC_print(char* printbuf); |
| 368 | int CDC_printf(const char* _Format, ...); | 368 | int CDC_printf(const char* _Format, ...); |
| @@ -373,4 +373,4 @@ void CDC_init(void); | |||
| 373 | } | 373 | } |
| 374 | #endif | 374 | #endif |
| 375 | 375 | ||
| 376 | #endif // _UDI_CDC_H_ | 376 | #endif // _UDI_CDC_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h index e079512492..e17ed7bf44 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h | |||
| @@ -59,9 +59,9 @@ | |||
| 59 | extern "C" { | 59 | extern "C" { |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | #define UDI_CDC_DATA_EP_IN_0 ((CDC_TX_ENDPOINT) | (USB_EP_DIR_IN)) // TX | 62 | #define UDI_CDC_DATA_EP_IN_0 ((CDC_TX_ENDPOINT) | (USB_EP_DIR_IN)) // TX |
| 63 | #define UDI_CDC_DATA_EP_OUT_0 ((CDC_RX_ENDPOINT) | (USB_EP_DIR_OUT)) // RX | 63 | #define UDI_CDC_DATA_EP_OUT_0 ((CDC_RX_ENDPOINT) | (USB_EP_DIR_OUT)) // RX |
| 64 | #define UDI_CDC_COMM_EP_0 ((CDC_ACM_ENDPOINT) | (USB_EP_DIR_IN)) // Notify endpoint | 64 | #define UDI_CDC_COMM_EP_0 ((CDC_ACM_ENDPOINT) | (USB_EP_DIR_IN)) // Notify endpoint |
| 65 | 65 | ||
| 66 | #define UDI_CDC_COMM_IFACE_NUMBER_0 (CDC_STATUS_INTERFACE) | 66 | #define UDI_CDC_COMM_IFACE_NUMBER_0 (CDC_STATUS_INTERFACE) |
| 67 | #define UDI_CDC_DATA_IFACE_NUMBER_0 (CDC_DATA_INTERFACE) | 67 | #define UDI_CDC_DATA_IFACE_NUMBER_0 (CDC_DATA_INTERFACE) |
| @@ -69,4 +69,4 @@ extern "C" { | |||
| 69 | #ifdef __cplusplus | 69 | #ifdef __cplusplus |
| 70 | } | 70 | } |
| 71 | #endif | 71 | #endif |
| 72 | #endif // _UDI_CDC_CONF_H_ | 72 | #endif // _UDI_CDC_CONF_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h index 1c0983115c..eeed196275 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h | |||
| @@ -220,7 +220,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 220 | # define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1) | 220 | # define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1) |
| 221 | 221 | ||
| 222 | # define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE | 222 | # define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE |
| 223 | # define CDC_RX_SIZE CDC_EPSIZE // KFSMOD was 64 | 223 | # define CDC_RX_SIZE CDC_EPSIZE // KFSMOD was 64 |
| 224 | # define CDC_TX_SIZE CDC_RX_SIZE | 224 | # define CDC_TX_SIZE CDC_RX_SIZE |
| 225 | # define CDC_ACM_POLLING_INTERVAL 255 | 225 | # define CDC_ACM_POLLING_INTERVAL 255 |
| 226 | # define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL | 226 | # define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL |
| @@ -370,7 +370,7 @@ extern udi_hid_exk_report_t udi_hid_exk_report; | |||
| 370 | 370 | ||
| 371 | COMPILER_PACK_RESET() | 371 | COMPILER_PACK_RESET() |
| 372 | 372 | ||
| 373 | #endif // EXTRAKEY_ENABLE | 373 | #endif // EXTRAKEY_ENABLE |
| 374 | 374 | ||
| 375 | // ********************************************************************** | 375 | // ********************************************************************** |
| 376 | // NKRO Descriptor structure and content | 376 | // NKRO Descriptor structure and content |
| @@ -433,7 +433,7 @@ extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE]; | |||
| 433 | 433 | ||
| 434 | COMPILER_PACK_RESET() | 434 | COMPILER_PACK_RESET() |
| 435 | 435 | ||
| 436 | #endif // NKRO_ENABLE | 436 | #endif // NKRO_ENABLE |
| 437 | 437 | ||
| 438 | // ********************************************************************** | 438 | // ********************************************************************** |
| 439 | // MOU Descriptor structure and content | 439 | // MOU Descriptor structure and content |
| @@ -449,7 +449,7 @@ typedef struct { | |||
| 449 | } udi_hid_mou_desc_t; | 449 | } udi_hid_mou_desc_t; |
| 450 | 450 | ||
| 451 | typedef struct { | 451 | typedef struct { |
| 452 | uint8_t array[77]; // MOU PDS | 452 | uint8_t array[77]; // MOU PDS |
| 453 | } udi_hid_mou_report_desc_t; | 453 | } udi_hid_mou_report_desc_t; |
| 454 | 454 | ||
| 455 | // clang-format off | 455 | // clang-format off |
| @@ -488,12 +488,12 @@ typedef struct { | |||
| 488 | // clang-format on | 488 | // clang-format on |
| 489 | 489 | ||
| 490 | // report buffer | 490 | // report buffer |
| 491 | # define UDI_HID_MOU_REPORT_SIZE 5 // MOU PDS | 491 | # define UDI_HID_MOU_REPORT_SIZE 5 // MOU PDS |
| 492 | extern uint8_t udi_hid_mou_report[UDI_HID_MOU_REPORT_SIZE]; | 492 | extern uint8_t udi_hid_mou_report[UDI_HID_MOU_REPORT_SIZE]; |
| 493 | 493 | ||
| 494 | COMPILER_PACK_RESET() | 494 | COMPILER_PACK_RESET() |
| 495 | 495 | ||
| 496 | #endif // MOUSE_ENABLE | 496 | #endif // MOUSE_ENABLE |
| 497 | 497 | ||
| 498 | // ********************************************************************** | 498 | // ********************************************************************** |
| 499 | // RAW Descriptor structure and content | 499 | // RAW Descriptor structure and content |
| @@ -565,7 +565,7 @@ extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE]; | |||
| 565 | 565 | ||
| 566 | COMPILER_PACK_RESET() | 566 | COMPILER_PACK_RESET() |
| 567 | 567 | ||
| 568 | #endif // RAW_ENABLE | 568 | #endif // RAW_ENABLE |
| 569 | 569 | ||
| 570 | // ********************************************************************** | 570 | // ********************************************************************** |
| 571 | // CON Descriptor structure and content | 571 | // CON Descriptor structure and content |
| @@ -637,7 +637,7 @@ extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE]; | |||
| 637 | 637 | ||
| 638 | COMPILER_PACK_RESET() | 638 | COMPILER_PACK_RESET() |
| 639 | 639 | ||
| 640 | #endif // CONSOLE_ENABLE | 640 | #endif // CONSOLE_ENABLE |
| 641 | 641 | ||
| 642 | // ********************************************************************** | 642 | // ********************************************************************** |
| 643 | // CDC Descriptor structure and content | 643 | // CDC Descriptor structure and content |
| @@ -780,7 +780,7 @@ typedef struct { | |||
| 780 | 780 | ||
| 781 | COMPILER_PACK_RESET() | 781 | COMPILER_PACK_RESET() |
| 782 | 782 | ||
| 783 | #endif // VIRTSER_ENABLE | 783 | #endif // VIRTSER_ENABLE |
| 784 | 784 | ||
| 785 | // ********************************************************************** | 785 | // ********************************************************************** |
| 786 | // CONFIGURATION Descriptor structure and content | 786 | // CONFIGURATION Descriptor structure and content |
| @@ -815,4 +815,4 @@ typedef struct { | |||
| 815 | 815 | ||
| 816 | COMPILER_PACK_RESET() | 816 | COMPILER_PACK_RESET() |
| 817 | 817 | ||
| 818 | #endif //_UDI_DEVICE_CONF_H_ | 818 | #endif //_UDI_DEVICE_CONF_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h index 09de475469..7a9ed31930 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h | |||
| @@ -28,4 +28,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 28 | #define CDC_NOTIFICATION_EPSIZE 8 | 28 | #define CDC_NOTIFICATION_EPSIZE 8 |
| 29 | #define CDC_EPSIZE 16 | 29 | #define CDC_EPSIZE 16 |
| 30 | 30 | ||
| 31 | #endif //_UDI_DEVICE_EPSIZE_H_ | 31 | #endif //_UDI_DEVICE_EPSIZE_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid.c b/tmk_core/protocol/arm_atsam/usb/udi_hid.c index b0bdcc6932..73e384a039 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid.c | |||
| @@ -110,7 +110,7 @@ bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool | |||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | return false; // Request not supported | 113 | return false; // Request not supported |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | //--------------------------------------------- | 116 | //--------------------------------------------- |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid.h b/tmk_core/protocol/arm_atsam/usb/udi_hid.h index 6fd2cabd4c..a08b7db744 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid.h | |||
| @@ -82,4 +82,4 @@ bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool | |||
| 82 | #ifdef __cplusplus | 82 | #ifdef __cplusplus |
| 83 | } | 83 | } |
| 84 | #endif | 84 | #endif |
| 85 | #endif // _UDI_HID_H_ | 85 | #endif // _UDI_HID_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c index 9ea4addcfc..be4f2bb0c9 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | |||
| @@ -94,42 +94,42 @@ static uint8_t udi_hid_kbd_report_trans[UDI_HID_KBD_REPORT_SIZE]; | |||
| 94 | 94 | ||
| 95 | COMPILER_WORD_ALIGNED | 95 | COMPILER_WORD_ALIGNED |
| 96 | UDC_DESC_STORAGE udi_hid_kbd_report_desc_t udi_hid_kbd_report_desc = {{ | 96 | UDC_DESC_STORAGE udi_hid_kbd_report_desc_t udi_hid_kbd_report_desc = {{ |
| 97 | 0x05, 0x01, // Usage Page (Generic Desktop) | 97 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 98 | 0x09, 0x06, // Usage (Keyboard) | 98 | 0x09, 0x06, // Usage (Keyboard) |
| 99 | 0xA1, 0x01, // Collection (Application) | 99 | 0xA1, 0x01, // Collection (Application) |
| 100 | // Modifiers (8 bits) | 100 | // Modifiers (8 bits) |
| 101 | 0x05, 0x07, // Usage Page (Keyboard) | 101 | 0x05, 0x07, // Usage Page (Keyboard) |
| 102 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) | 102 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) |
| 103 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) | 103 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) |
| 104 | 0x15, 0x00, // Logical Minimum (0) | 104 | 0x15, 0x00, // Logical Minimum (0) |
| 105 | 0x25, 0x01, // Logical Maximum (1) | 105 | 0x25, 0x01, // Logical Maximum (1) |
| 106 | 0x95, 0x08, // Report Count (8) | 106 | 0x95, 0x08, // Report Count (8) |
| 107 | 0x75, 0x01, // Report Size (1) | 107 | 0x75, 0x01, // Report Size (1) |
| 108 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 108 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 109 | // Reserved (1 byte) | 109 | // Reserved (1 byte) |
| 110 | 0x81, 0x01, // Input (Constant) | 110 | 0x81, 0x01, // Input (Constant) |
| 111 | // Keycodes (6 bytes) | 111 | // Keycodes (6 bytes) |
| 112 | 0x19, 0x00, // Usage Minimum (0) | 112 | 0x19, 0x00, // Usage Minimum (0) |
| 113 | 0x29, 0xFF, // Usage Maximum (255) | 113 | 0x29, 0xFF, // Usage Maximum (255) |
| 114 | 0x15, 0x00, // Logical Minimum (0) | 114 | 0x15, 0x00, // Logical Minimum (0) |
| 115 | 0x25, 0xFF, // Logical Maximum (255) | 115 | 0x25, 0xFF, // Logical Maximum (255) |
| 116 | 0x95, 0x06, // Report Count (6) | 116 | 0x95, 0x06, // Report Count (6) |
| 117 | 0x75, 0x08, // Report Size (8) | 117 | 0x75, 0x08, // Report Size (8) |
| 118 | 0x81, 0x00, // Input (Data, Array, Absolute) | 118 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| 119 | 119 | ||
| 120 | // Status LEDs (5 bits) | 120 | // Status LEDs (5 bits) |
| 121 | 0x05, 0x08, // Usage Page (LED) | 121 | 0x05, 0x08, // Usage Page (LED) |
| 122 | 0x19, 0x01, // Usage Minimum (Num Lock) | 122 | 0x19, 0x01, // Usage Minimum (Num Lock) |
| 123 | 0x29, 0x05, // Usage Maximum (Kana) | 123 | 0x29, 0x05, // Usage Maximum (Kana) |
| 124 | 0x15, 0x00, // Logical Minimum (0) | 124 | 0x15, 0x00, // Logical Minimum (0) |
| 125 | 0x25, 0x01, // Logical Maximum (1) | 125 | 0x25, 0x01, // Logical Maximum (1) |
| 126 | 0x95, 0x05, // Report Count (5) | 126 | 0x95, 0x05, // Report Count (5) |
| 127 | 0x75, 0x01, // Report Size (1) | 127 | 0x75, 0x01, // Report Size (1) |
| 128 | 0x91, 0x02, // Output (Data, Variable, Absolute) | 128 | 0x91, 0x02, // Output (Data, Variable, Absolute) |
| 129 | // LED padding (3 bits) | 129 | // LED padding (3 bits) |
| 130 | 0x95, 0x03, // Report Count (3) | 130 | 0x95, 0x03, // Report Count (3) |
| 131 | 0x91, 0x01, // Output (Constant) | 131 | 0x91, 0x01, // Output (Constant) |
| 132 | 0xC0 // End Collection | 132 | 0xC0 // End Collection |
| 133 | }}; | 133 | }}; |
| 134 | 134 | ||
| 135 | static bool udi_hid_kbd_setreport(void); | 135 | static bool udi_hid_kbd_setreport(void); |
| @@ -148,11 +148,17 @@ bool udi_hid_kbd_enable(void) { | |||
| 148 | return UDI_HID_KBD_ENABLE_EXT(); | 148 | return UDI_HID_KBD_ENABLE_EXT(); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void udi_hid_kbd_disable(void) { UDI_HID_KBD_DISABLE_EXT(); } | 151 | void udi_hid_kbd_disable(void) { |
| 152 | UDI_HID_KBD_DISABLE_EXT(); | ||
| 153 | } | ||
| 152 | 154 | ||
| 153 | bool udi_hid_kbd_setup(void) { return udi_hid_setup(&udi_hid_kbd_rate, &udi_hid_kbd_protocol, (uint8_t *)&udi_hid_kbd_report_desc, udi_hid_kbd_setreport); } | 155 | bool udi_hid_kbd_setup(void) { |
| 156 | return udi_hid_setup(&udi_hid_kbd_rate, &udi_hid_kbd_protocol, (uint8_t *)&udi_hid_kbd_report_desc, udi_hid_kbd_setreport); | ||
| 157 | } | ||
| 154 | 158 | ||
| 155 | uint8_t udi_hid_kbd_getsetting(void) { return 0; } | 159 | uint8_t udi_hid_kbd_getsetting(void) { |
| 160 | return 0; | ||
| 161 | } | ||
| 156 | 162 | ||
| 157 | static bool udi_hid_kbd_setreport(void) { | 163 | static bool udi_hid_kbd_setreport(void) { |
| 158 | if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { | 164 | if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { |
| @@ -234,41 +240,41 @@ static uint8_t udi_hid_nkro_report_trans[UDI_HID_NKRO_REPORT_SIZE]; | |||
| 234 | 240 | ||
| 235 | COMPILER_WORD_ALIGNED | 241 | COMPILER_WORD_ALIGNED |
| 236 | UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {{ | 242 | UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {{ |
| 237 | 0x05, 0x01, // Usage Page (Generic Desktop) | 243 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 238 | 0x09, 0x06, // Usage (Keyboard) | 244 | 0x09, 0x06, // Usage (Keyboard) |
| 239 | 0xA1, 0x01, // Collection (Application) | 245 | 0xA1, 0x01, // Collection (Application) |
| 240 | 246 | ||
| 241 | // Modifiers (8 bits) | 247 | // Modifiers (8 bits) |
| 242 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) | 248 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) |
| 243 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) | 249 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) |
| 244 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) | 250 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) |
| 245 | 0x15, 0x00, // Logical Minimum (0) | 251 | 0x15, 0x00, // Logical Minimum (0) |
| 246 | 0x25, 0x01, // Logical Maximum (1) | 252 | 0x25, 0x01, // Logical Maximum (1) |
| 247 | 0x95, 0x08, // Report Count (8) | 253 | 0x95, 0x08, // Report Count (8) |
| 248 | 0x75, 0x01, // Report Size (1) | 254 | 0x75, 0x01, // Report Size (1) |
| 249 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 255 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 250 | // Keycodes | 256 | // Keycodes |
| 251 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) | 257 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) |
| 252 | 0x19, 0x00, // Usage Minimum (0) | 258 | 0x19, 0x00, // Usage Minimum (0) |
| 253 | 0x29, 0xF7, // Usage Maximum (247) | 259 | 0x29, 0xF7, // Usage Maximum (247) |
| 254 | 0x15, 0x00, // Logical Minimum (0) | 260 | 0x15, 0x00, // Logical Minimum (0) |
| 255 | 0x25, 0x01, // Logical Maximum (1) | 261 | 0x25, 0x01, // Logical Maximum (1) |
| 256 | 0x95, 0xF8, // Report Count (248) | 262 | 0x95, 0xF8, // Report Count (248) |
| 257 | 0x75, 0x01, // Report Size (1) | 263 | 0x75, 0x01, // Report Size (1) |
| 258 | 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield) | 264 | 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield) |
| 259 | 265 | ||
| 260 | // Status LEDs (5 bits) | 266 | // Status LEDs (5 bits) |
| 261 | 0x05, 0x08, // Usage Page (LED) | 267 | 0x05, 0x08, // Usage Page (LED) |
| 262 | 0x19, 0x01, // Usage Minimum (Num Lock) | 268 | 0x19, 0x01, // Usage Minimum (Num Lock) |
| 263 | 0x29, 0x05, // Usage Maximum (Kana) | 269 | 0x29, 0x05, // Usage Maximum (Kana) |
| 264 | 0x95, 0x05, // Report Count (5) | 270 | 0x95, 0x05, // Report Count (5) |
| 265 | 0x75, 0x01, // Report Size (1) | 271 | 0x75, 0x01, // Report Size (1) |
| 266 | 0x91, 0x02, // Output (Data, Variable, Absolute) | 272 | 0x91, 0x02, // Output (Data, Variable, Absolute) |
| 267 | // LED padding (3 bits) | 273 | // LED padding (3 bits) |
| 268 | 0x95, 0x01, // Report Count (1) | 274 | 0x95, 0x01, // Report Count (1) |
| 269 | 0x75, 0x03, // Report Size (3) | 275 | 0x75, 0x03, // Report Size (3) |
| 270 | 0x91, 0x03, // Output (Constant) | 276 | 0x91, 0x03, // Output (Constant) |
| 271 | 0xC0 // End Collection | 277 | 0xC0 // End Collection |
| 272 | }}; | 278 | }}; |
| 273 | 279 | ||
| 274 | static bool udi_hid_nkro_setreport(void); | 280 | static bool udi_hid_nkro_setreport(void); |
| @@ -285,18 +291,24 @@ bool udi_hid_nkro_enable(void) { | |||
| 285 | return UDI_HID_NKRO_ENABLE_EXT(); | 291 | return UDI_HID_NKRO_ENABLE_EXT(); |
| 286 | } | 292 | } |
| 287 | 293 | ||
| 288 | void udi_hid_nkro_disable(void) { UDI_HID_NKRO_DISABLE_EXT(); } | 294 | void udi_hid_nkro_disable(void) { |
| 295 | UDI_HID_NKRO_DISABLE_EXT(); | ||
| 296 | } | ||
| 289 | 297 | ||
| 290 | bool udi_hid_nkro_setup(void) { return udi_hid_setup(&udi_hid_nkro_rate, &udi_hid_nkro_protocol, (uint8_t *)&udi_hid_nkro_report_desc, udi_hid_nkro_setreport); } | 298 | bool udi_hid_nkro_setup(void) { |
| 299 | return udi_hid_setup(&udi_hid_nkro_rate, &udi_hid_nkro_protocol, (uint8_t *)&udi_hid_nkro_report_desc, udi_hid_nkro_setreport); | ||
| 300 | } | ||
| 291 | 301 | ||
| 292 | uint8_t udi_hid_nkro_getsetting(void) { return 0; } | 302 | uint8_t udi_hid_nkro_getsetting(void) { |
| 303 | return 0; | ||
| 304 | } | ||
| 293 | 305 | ||
| 294 | // keyboard receives LED report here | 306 | // keyboard receives LED report here |
| 295 | static bool udi_hid_nkro_setreport(void) { | 307 | static bool udi_hid_nkro_setreport(void) { |
| 296 | if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { | 308 | if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { |
| 297 | // Report OUT type on report ID 0 from USB Host | 309 | // Report OUT type on report ID 0 from USB Host |
| 298 | udd_g_ctrlreq.payload = &udi_hid_nkro_report_set; | 310 | udd_g_ctrlreq.payload = &udi_hid_nkro_report_set; |
| 299 | udd_g_ctrlreq.callback = udi_hid_nkro_setreport_valid; // must call routine to transform setreport to LED state | 311 | udd_g_ctrlreq.callback = udi_hid_nkro_setreport_valid; // must call routine to transform setreport to LED state |
| 300 | udd_g_ctrlreq.payload_size = 1; | 312 | udd_g_ctrlreq.payload_size = 1; |
| 301 | return true; | 313 | return true; |
| 302 | } | 314 | } |
| @@ -333,7 +345,7 @@ static void udi_hid_nkro_setreport_valid(void) { | |||
| 333 | // UDI_HID_NKRO_CHANGE_LED(udi_hid_nkro_report_set); | 345 | // UDI_HID_NKRO_CHANGE_LED(udi_hid_nkro_report_set); |
| 334 | } | 346 | } |
| 335 | 347 | ||
| 336 | #endif // NKRO_ENABLE | 348 | #endif // NKRO_ENABLE |
| 337 | 349 | ||
| 338 | //******************************************************************************************** | 350 | //******************************************************************************************** |
| 339 | // EXK (extra-keys) SYS-CTRL Keyboard | 351 | // EXK (extra-keys) SYS-CTRL Keyboard |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h index a2d2281628..a330014498 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h | |||
| @@ -71,7 +71,7 @@ extern UDC_DESC_STORAGE udi_api_t udi_api_hid_nkro; | |||
| 71 | extern bool udi_hid_nkro_b_report_valid; | 71 | extern bool udi_hid_nkro_b_report_valid; |
| 72 | extern volatile bool udi_hid_nkro_b_report_trans_ongoing; | 72 | extern volatile bool udi_hid_nkro_b_report_trans_ongoing; |
| 73 | bool udi_hid_nkro_send_report(void); | 73 | bool udi_hid_nkro_send_report(void); |
| 74 | #endif // NKRO_ENABLE | 74 | #endif // NKRO_ENABLE |
| 75 | 75 | ||
| 76 | //******************************************************************************************** | 76 | //******************************************************************************************** |
| 77 | // SYS-CTRL interface | 77 | // SYS-CTRL interface |
| @@ -81,7 +81,7 @@ extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk; | |||
| 81 | extern bool udi_hid_exk_b_report_valid; | 81 | extern bool udi_hid_exk_b_report_valid; |
| 82 | extern uint8_t udi_hid_exk_report_set; | 82 | extern uint8_t udi_hid_exk_report_set; |
| 83 | bool udi_hid_exk_send_report(void); | 83 | bool udi_hid_exk_send_report(void); |
| 84 | #endif // EXTRAKEY_ENABLE | 84 | #endif // EXTRAKEY_ENABLE |
| 85 | 85 | ||
| 86 | //******************************************************************************************** | 86 | //******************************************************************************************** |
| 87 | // CON Console | 87 | // CON Console |
| @@ -92,7 +92,7 @@ extern bool udi_hid_con_b_report_valid; | |||
| 92 | extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE]; | 92 | extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE]; |
| 93 | extern volatile bool udi_hid_con_b_report_trans_ongoing; | 93 | extern volatile bool udi_hid_con_b_report_trans_ongoing; |
| 94 | bool udi_hid_con_send_report(void); | 94 | bool udi_hid_con_send_report(void); |
| 95 | #endif // CONSOLE_ENABLE | 95 | #endif // CONSOLE_ENABLE |
| 96 | 96 | ||
| 97 | //******************************************************************************************** | 97 | //******************************************************************************************** |
| 98 | // MOU Mouse | 98 | // MOU Mouse |
| @@ -101,7 +101,7 @@ bool udi_hid_con_send_report(void); | |||
| 101 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_mou; | 101 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_mou; |
| 102 | extern bool udi_hid_mou_b_report_valid; | 102 | extern bool udi_hid_mou_b_report_valid; |
| 103 | bool udi_hid_mou_send_report(void); | 103 | bool udi_hid_mou_send_report(void); |
| 104 | #endif // MOUSE_ENABLE | 104 | #endif // MOUSE_ENABLE |
| 105 | 105 | ||
| 106 | //******************************************************************************************** | 106 | //******************************************************************************************** |
| 107 | // RAW Raw | 107 | // RAW Raw |
| @@ -110,7 +110,7 @@ bool udi_hid_mou_send_report(void); | |||
| 110 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw; | 110 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw; |
| 111 | bool udi_hid_raw_send_report(void); | 111 | bool udi_hid_raw_send_report(void); |
| 112 | bool udi_hid_raw_receive_report(void); | 112 | bool udi_hid_raw_receive_report(void); |
| 113 | #endif // RAW_ENABLE | 113 | #endif // RAW_ENABLE |
| 114 | 114 | ||
| 115 | //@} | 115 | //@} |
| 116 | 116 | ||
| @@ -118,4 +118,4 @@ bool udi_hid_raw_receive_report(void); | |||
| 118 | } | 118 | } |
| 119 | #endif | 119 | #endif |
| 120 | 120 | ||
| 121 | #endif // _UDC_HID_KBD_H_ | 121 | #endif // _UDC_HID_KBD_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h index ec73252b69..db5db17ed5 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h | |||
| @@ -57,4 +57,4 @@ | |||
| 57 | 57 | ||
| 58 | #include "udi_hid_kbd.h" | 58 | #include "udi_hid_kbd.h" |
| 59 | 59 | ||
| 60 | #endif // _UDI_HID_KBD_CONF_H_ | 60 | #endif // _UDI_HID_KBD_CONF_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c index 3c1c9a7926..2a60868ed2 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c | |||
| @@ -78,17 +78,17 @@ UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {.bLength = sizeof(usb | |||
| 78 | #ifdef USB_DEVICE_MANUFACTURE_NAME | 78 | #ifdef USB_DEVICE_MANUFACTURE_NAME |
| 79 | .iManufacturer = 1, | 79 | .iManufacturer = 1, |
| 80 | #else | 80 | #else |
| 81 | .iManufacturer = 0, // No manufacture string | 81 | .iManufacturer = 0, // No manufacture string |
| 82 | #endif | 82 | #endif |
| 83 | #ifdef USB_DEVICE_PRODUCT_NAME | 83 | #ifdef USB_DEVICE_PRODUCT_NAME |
| 84 | .iProduct = 2, | 84 | .iProduct = 2, |
| 85 | #else | 85 | #else |
| 86 | .iProduct = 0, // No product string | 86 | .iProduct = 0, // No product string |
| 87 | #endif | 87 | #endif |
| 88 | #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER) | 88 | #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER) |
| 89 | .iSerialNumber = 3, | 89 | .iSerialNumber = 3, |
| 90 | #else | 90 | #else |
| 91 | .iSerialNumber = 0, // No serial string | 91 | .iSerialNumber = 0, // No serial string |
| 92 | #endif | 92 | #endif |
| 93 | .bNumConfigurations = 1}; | 93 | .bNumConfigurations = 1}; |
| 94 | 94 | ||
diff --git a/tmk_core/protocol/arm_atsam/usb/ui.c b/tmk_core/protocol/arm_atsam/usb/ui.c index 86c7edc94e..f5263d7289 100644 --- a/tmk_core/protocol/arm_atsam/usb/ui.c +++ b/tmk_core/protocol/arm_atsam/usb/ui.c | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | # define ARM_MATH_CM4 | 48 | # define ARM_MATH_CM4 |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #undef LITTLE_ENDIAN // redefined in samd51j18a.h | 51 | #undef LITTLE_ENDIAN // redefined in samd51j18a.h |
| 52 | #include "samd51j18a.h" | 52 | #include "samd51j18a.h" |
| 53 | #include "ui.h" | 53 | #include "ui.h" |
| 54 | 54 | ||
diff --git a/tmk_core/protocol/arm_atsam/usb/ui.h b/tmk_core/protocol/arm_atsam/usb/ui.h index f7bc652360..d1c767d457 100644 --- a/tmk_core/protocol/arm_atsam/usb/ui.h +++ b/tmk_core/protocol/arm_atsam/usb/ui.h | |||
| @@ -73,4 +73,4 @@ void ui_process(uint16_t framenumber); | |||
| 73 | */ | 73 | */ |
| 74 | void ui_kbd_led(uint8_t value); | 74 | void ui_kbd_led(uint8_t value); |
| 75 | 75 | ||
| 76 | #endif // _UI_H_ | 76 | #endif // _UI_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb.c b/tmk_core/protocol/arm_atsam/usb/usb.c index b7393660b1..1abf0a2f4d 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb.c +++ b/tmk_core/protocol/arm_atsam/usb/usb.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | #include "compiler.h" | 54 | #include "compiler.h" |
| 55 | #undef LITTLE_ENDIAN // redefined in samd51j18a.h | 55 | #undef LITTLE_ENDIAN // redefined in samd51j18a.h |
| 56 | #include "samd51j18a.h" | 56 | #include "samd51j18a.h" |
| 57 | #include <stdbool.h> | 57 | #include <stdbool.h> |
| 58 | #include <string.h> | 58 | #include <string.h> |
| @@ -319,7 +319,7 @@ enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_i | |||
| 319 | module_inst->device_endpoint_enabled_callback_mask[ep_num] |= _usb_endpoint_irq_bits[callback_type]; | 319 | module_inst->device_endpoint_enabled_callback_mask[ep_num] |= _usb_endpoint_irq_bits[callback_type]; |
| 320 | 320 | ||
| 321 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) { | 321 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) { |
| 322 | if (ep_num == 0) { // control endpoint | 322 | if (ep_num == 0) { // control endpoint |
| 323 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT0 | USB_DEVICE_EPINTENSET_TRCPT1; | 323 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT0 | USB_DEVICE_EPINTENSET_TRCPT1; |
| 324 | } else if (ep & USB_EP_DIR_IN) { | 324 | } else if (ep & USB_EP_DIR_IN) { |
| 325 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT1; | 325 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT1; |
| @@ -329,7 +329,7 @@ enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_i | |||
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) { | 331 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) { |
| 332 | if (ep_num == 0) { // control endpoint | 332 | if (ep_num == 0) { // control endpoint |
| 333 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL0 | USB_DEVICE_EPINTENSET_TRFAIL1; | 333 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL0 | USB_DEVICE_EPINTENSET_TRFAIL1; |
| 334 | } else if (ep & USB_EP_DIR_IN) { | 334 | } else if (ep & USB_EP_DIR_IN) { |
| 335 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL1; | 335 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL1; |
| @@ -377,7 +377,7 @@ enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_ | |||
| 377 | module_inst->device_endpoint_enabled_callback_mask[ep_num] &= ~_usb_endpoint_irq_bits[callback_type]; | 377 | module_inst->device_endpoint_enabled_callback_mask[ep_num] &= ~_usb_endpoint_irq_bits[callback_type]; |
| 378 | 378 | ||
| 379 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) { | 379 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) { |
| 380 | if (ep_num == 0) { // control endpoint | 380 | if (ep_num == 0) { // control endpoint |
| 381 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0 | USB_DEVICE_EPINTENCLR_TRCPT1; | 381 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0 | USB_DEVICE_EPINTENCLR_TRCPT1; |
| 382 | } else if (ep & USB_EP_DIR_IN) { | 382 | } else if (ep & USB_EP_DIR_IN) { |
| 383 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT1; | 383 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT1; |
| @@ -387,7 +387,7 @@ enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_ | |||
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) { | 389 | if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) { |
| 390 | if (ep_num == 0) { // control endpoint | 390 | if (ep_num == 0) { // control endpoint |
| 391 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL0 | USB_DEVICE_EPINTENCLR_TRFAIL1; | 391 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL0 | USB_DEVICE_EPINTENCLR_TRFAIL1; |
| 392 | } else if (ep & USB_EP_DIR_IN) { | 392 | } else if (ep & USB_EP_DIR_IN) { |
| 393 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL1; | 393 | module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL1; |
| @@ -903,11 +903,17 @@ void USB_0_Handler(void) { | |||
| 903 | } | 903 | } |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | void USB_1_Handler(void) { _usb_device_interrupt_handler(); } | 906 | void USB_1_Handler(void) { |
| 907 | _usb_device_interrupt_handler(); | ||
| 908 | } | ||
| 907 | 909 | ||
| 908 | void USB_2_Handler(void) { _usb_device_interrupt_handler(); } | 910 | void USB_2_Handler(void) { |
| 911 | _usb_device_interrupt_handler(); | ||
| 912 | } | ||
| 909 | 913 | ||
| 910 | void USB_3_Handler(void) { _usb_device_interrupt_handler(); } | 914 | void USB_3_Handler(void) { |
| 915 | _usb_device_interrupt_handler(); | ||
| 916 | } | ||
| 911 | 917 | ||
| 912 | /** | 918 | /** |
| 913 | * \brief Get the default USB module settings | 919 | * \brief Get the default USB module settings |
| @@ -974,10 +980,10 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct | |||
| 974 | pmclk->APBBMASK.bit.USB_ = 1; | 980 | pmclk->APBBMASK.bit.USB_ = 1; |
| 975 | 981 | ||
| 976 | /* Set up the USB DP/DN pins */ | 982 | /* Set up the USB DP/DN pins */ |
| 977 | pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+ | 983 | pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+ |
| 978 | pport->Group[0].PINCFG[24].bit.PMUXEN = 1; | 984 | pport->Group[0].PINCFG[24].bit.PMUXEN = 1; |
| 979 | pport->Group[0].PINCFG[25].bit.PMUXEN = 1; | 985 | pport->Group[0].PINCFG[25].bit.PMUXEN = 1; |
| 980 | pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output | 986 | pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output |
| 981 | pport->Group[1].PINCFG[22].bit.PMUXEN = 1; | 987 | pport->Group[1].PINCFG[22].bit.PMUXEN = 1; |
| 982 | 988 | ||
| 983 | // configure and enable DFLL for USB clock recovery mode at 48MHz | 989 | // configure and enable DFLL for USB clock recovery mode at 48MHz |
| @@ -996,7 +1002,7 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct | |||
| 996 | while (posc->DFLLSYNC.bit.DFLLCTRLB) | 1002 | while (posc->DFLLSYNC.bit.DFLLCTRLB) |
| 997 | ; | 1003 | ; |
| 998 | posc->DFLLCTRLB.bit.CCDIS = 1; | 1004 | posc->DFLLCTRLB.bit.CCDIS = 1; |
| 999 | posc->DFLLMUL.bit.MUL = 0xbb80; // 4800 x 1KHz | 1005 | posc->DFLLMUL.bit.MUL = 0xbb80; // 4800 x 1KHz |
| 1000 | while (posc->DFLLSYNC.bit.DFLLMUL) | 1006 | while (posc->DFLLSYNC.bit.DFLLMUL) |
| 1001 | ; | 1007 | ; |
| 1002 | posc->DFLLCTRLA.bit.ENABLE = 1; | 1008 | posc->DFLLCTRLA.bit.ENABLE = 1; |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb.h b/tmk_core/protocol/arm_atsam/usb/usb.h index 4c937ecdc9..270143a112 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb.h +++ b/tmk_core/protocol/arm_atsam/usb/usb.h | |||
| @@ -319,14 +319,18 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct | |||
| 319 | * | 319 | * |
| 320 | * \param module_inst Pointer to USB device module instance | 320 | * \param module_inst Pointer to USB device module instance |
| 321 | */ | 321 | */ |
| 322 | static inline void usb_device_attach(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg &= ~USB_DEVICE_CTRLB_DETACH; } | 322 | static inline void usb_device_attach(struct usb_module *module_inst) { |
| 323 | module_inst->hw->DEVICE.CTRLB.reg &= ~USB_DEVICE_CTRLB_DETACH; | ||
| 324 | } | ||
| 323 | 325 | ||
| 324 | /** | 326 | /** |
| 325 | * \brief Detach USB device from the bus | 327 | * \brief Detach USB device from the bus |
| 326 | * | 328 | * |
| 327 | * \param module_inst Pointer to USB device module instance | 329 | * \param module_inst Pointer to USB device module instance |
| 328 | */ | 330 | */ |
| 329 | static inline void usb_device_detach(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_DETACH; } | 331 | static inline void usb_device_detach(struct usb_module *module_inst) { |
| 332 | module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_DETACH; | ||
| 333 | } | ||
| 330 | 334 | ||
| 331 | /** | 335 | /** |
| 332 | * \brief Get the speed mode of USB device | 336 | * \brief Get the speed mode of USB device |
| @@ -348,7 +352,9 @@ static inline enum usb_speed usb_device_get_speed(struct usb_module *module_inst | |||
| 348 | * \param module_inst Pointer to USB device module instance | 352 | * \param module_inst Pointer to USB device module instance |
| 349 | * \return USB device address value. | 353 | * \return USB device address value. |
| 350 | */ | 354 | */ |
| 351 | static inline uint8_t usb_device_get_address(struct usb_module *module_inst) { return ((uint8_t)(module_inst->hw->DEVICE.DADD.bit.DADD)); } | 355 | static inline uint8_t usb_device_get_address(struct usb_module *module_inst) { |
| 356 | return ((uint8_t)(module_inst->hw->DEVICE.DADD.bit.DADD)); | ||
| 357 | } | ||
| 352 | 358 | ||
| 353 | /** | 359 | /** |
| 354 | * \brief Set the speed mode of USB device | 360 | * \brief Set the speed mode of USB device |
| @@ -356,7 +362,9 @@ static inline uint8_t usb_device_get_address(struct usb_module *module_inst) { r | |||
| 356 | * \param module_inst Pointer to USB device module instance | 362 | * \param module_inst Pointer to USB device module instance |
| 357 | * \param address USB device address value | 363 | * \param address USB device address value |
| 358 | */ | 364 | */ |
| 359 | static inline void usb_device_set_address(struct usb_module *module_inst, uint8_t address) { module_inst->hw->DEVICE.DADD.reg = USB_DEVICE_DADD_ADDEN | address; } | 365 | static inline void usb_device_set_address(struct usb_module *module_inst, uint8_t address) { |
| 366 | module_inst->hw->DEVICE.DADD.reg = USB_DEVICE_DADD_ADDEN | address; | ||
| 367 | } | ||
| 360 | 368 | ||
| 361 | /** | 369 | /** |
| 362 | * \brief Get the frame number of USB device | 370 | * \brief Get the frame number of USB device |
| @@ -364,7 +372,9 @@ static inline void usb_device_set_address(struct usb_module *module_inst, uint8_ | |||
| 364 | * \param module_inst Pointer to USB device module instance | 372 | * \param module_inst Pointer to USB device module instance |
| 365 | * \return USB device frame number value. | 373 | * \return USB device frame number value. |
| 366 | */ | 374 | */ |
| 367 | static inline uint16_t usb_device_get_frame_number(struct usb_module *module_inst) { return ((uint16_t)(module_inst->hw->DEVICE.FNUM.bit.FNUM)); } | 375 | static inline uint16_t usb_device_get_frame_number(struct usb_module *module_inst) { |
| 376 | return ((uint16_t)(module_inst->hw->DEVICE.FNUM.bit.FNUM)); | ||
| 377 | } | ||
| 368 | 378 | ||
| 369 | /** | 379 | /** |
| 370 | * \brief Get the micro-frame number of USB device | 380 | * \brief Get the micro-frame number of USB device |
| @@ -372,14 +382,18 @@ static inline uint16_t usb_device_get_frame_number(struct usb_module *module_ins | |||
| 372 | * \param module_inst Pointer to USB device module instance | 382 | * \param module_inst Pointer to USB device module instance |
| 373 | * \return USB device micro-frame number value. | 383 | * \return USB device micro-frame number value. |
| 374 | */ | 384 | */ |
| 375 | static inline uint16_t usb_device_get_micro_frame_number(struct usb_module *module_inst) { return ((uint16_t)(module_inst->hw->DEVICE.FNUM.reg)); } | 385 | static inline uint16_t usb_device_get_micro_frame_number(struct usb_module *module_inst) { |
| 386 | return ((uint16_t)(module_inst->hw->DEVICE.FNUM.reg)); | ||
| 387 | } | ||
| 376 | 388 | ||
| 377 | /** | 389 | /** |
| 378 | * \brief USB device send the resume wakeup | 390 | * \brief USB device send the resume wakeup |
| 379 | * | 391 | * |
| 380 | * \param module_inst Pointer to USB device module instance | 392 | * \param module_inst Pointer to USB device module instance |
| 381 | */ | 393 | */ |
| 382 | static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_UPRSM; } | 394 | static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst) { |
| 395 | module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_UPRSM; | ||
| 396 | } | ||
| 383 | 397 | ||
| 384 | /** | 398 | /** |
| 385 | * \brief USB device set the LPM mode | 399 | * \brief USB device set the LPM mode |
| @@ -387,7 +401,9 @@ static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst | |||
| 387 | * \param module_inst Pointer to USB device module instance | 401 | * \param module_inst Pointer to USB device module instance |
| 388 | * \param lpm_mode LPM mode | 402 | * \param lpm_mode LPM mode |
| 389 | */ | 403 | */ |
| 390 | static inline void usb_device_set_lpm_mode(struct usb_module *module_inst, enum usb_device_lpm_mode lpm_mode) { module_inst->hw->DEVICE.CTRLB.bit.LPMHDSK = lpm_mode; } | 404 | static inline void usb_device_set_lpm_mode(struct usb_module *module_inst, enum usb_device_lpm_mode lpm_mode) { |
| 405 | module_inst->hw->DEVICE.CTRLB.bit.LPMHDSK = lpm_mode; | ||
| 406 | } | ||
| 391 | 407 | ||
| 392 | /** | 408 | /** |
| 393 | * \name USB Device Callback Management | 409 | * \name USB Device Callback Management |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_atmel.h b/tmk_core/protocol/arm_atsam/usb/usb_atmel.h index 1cef703788..82bafdc7d1 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_atmel.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_atmel.h | |||
| @@ -109,7 +109,7 @@ | |||
| 109 | #define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306 | 109 | #define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306 |
| 110 | #define USB_PID_ATMEL_UC3_CDC 0x2307 | 110 | #define USB_PID_ATMEL_UC3_CDC 0x2307 |
| 111 | #define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308 | 111 | #define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308 |
| 112 | #define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx | 112 | #define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx |
| 113 | #define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311 | 113 | #define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311 |
| 114 | #define USB_PID_ATMEL_UC3_CDC_MSC 0x2312 | 114 | #define USB_PID_ATMEL_UC3_CDC_MSC 0x2312 |
| 115 | //! @} | 115 | //! @} |
| @@ -186,4 +186,4 @@ | |||
| 186 | 186 | ||
| 187 | //! @} | 187 | //! @} |
| 188 | 188 | ||
| 189 | #endif // _USB_ATMEL_H_ | 189 | #endif // _USB_ATMEL_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c index f138b42786..e4510e7363 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c +++ b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c | |||
| @@ -127,12 +127,12 @@ uint8_t udd_ctrl_buffer[USB_DEVICE_EP_CTRL_SIZE]; | |||
| 127 | 127 | ||
| 128 | /** Bit definitions about endpoint control state machine for udd_ep_control_state */ | 128 | /** Bit definitions about endpoint control state machine for udd_ep_control_state */ |
| 129 | typedef enum { | 129 | typedef enum { |
| 130 | UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet | 130 | UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet |
| 131 | UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet | 131 | UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet |
| 132 | UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet | 132 | UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet |
| 133 | UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet | 133 | UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet |
| 134 | UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet | 134 | UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet |
| 135 | UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet | 135 | UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet |
| 136 | } udd_ctrl_ep_state_t; | 136 | } udd_ctrl_ep_state_t; |
| 137 | 137 | ||
| 138 | /** Global variable to give and record information of the set up request management */ | 138 | /** Global variable to give and record information of the set up request management */ |
| @@ -363,11 +363,17 @@ void udd_ep_abort(udd_ep_id_t ep) { | |||
| 363 | } | 363 | } |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | bool udd_is_high_speed(void) { return false; } | 366 | bool udd_is_high_speed(void) { |
| 367 | return false; | ||
| 368 | } | ||
| 367 | 369 | ||
| 368 | uint16_t udd_get_frame_number(void) { return usb_device_get_frame_number(&usb_device); } | 370 | uint16_t udd_get_frame_number(void) { |
| 371 | return usb_device_get_frame_number(&usb_device); | ||
| 372 | } | ||
| 369 | 373 | ||
| 370 | uint16_t udd_get_micro_frame_number(void) { return usb_device_get_micro_frame_number(&usb_device); } | 374 | uint16_t udd_get_micro_frame_number(void) { |
| 375 | return usb_device_get_micro_frame_number(&usb_device); | ||
| 376 | } | ||
| 371 | 377 | ||
| 372 | void udd_ep_free(udd_ep_id_t ep) { | 378 | void udd_ep_free(udd_ep_id_t ep) { |
| 373 | struct usb_device_endpoint_config config_ep; | 379 | struct usb_device_endpoint_config config_ep; |
| @@ -436,7 +442,9 @@ bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize | |||
| 436 | return true; | 442 | return true; |
| 437 | } | 443 | } |
| 438 | 444 | ||
| 439 | bool udd_ep_is_halted(udd_ep_id_t ep) { return usb_device_endpoint_is_halted(&usb_device, ep); } | 445 | bool udd_ep_is_halted(udd_ep_id_t ep) { |
| 446 | return usb_device_endpoint_is_halted(&usb_device, ep); | ||
| 447 | } | ||
| 440 | 448 | ||
| 441 | bool udd_ep_set_halt(udd_ep_id_t ep) { | 449 | bool udd_ep_set_halt(udd_ep_id_t ep) { |
| 442 | uint8_t ep_num = ep & USB_EP_ADDR_MASK; | 450 | uint8_t ep_num = ep & USB_EP_ADDR_MASK; |
| @@ -591,9 +599,13 @@ bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t bu | |||
| 591 | } | 599 | } |
| 592 | } | 600 | } |
| 593 | 601 | ||
| 594 | void udd_set_address(uint8_t address) { usb_device_set_address(&usb_device, address); } | 602 | void udd_set_address(uint8_t address) { |
| 603 | usb_device_set_address(&usb_device, address); | ||
| 604 | } | ||
| 595 | 605 | ||
| 596 | uint8_t udd_getaddress(void) { return usb_device_get_address(&usb_device); } | 606 | uint8_t udd_getaddress(void) { |
| 607 | return usb_device_get_address(&usb_device); | ||
| 608 | } | ||
| 597 | 609 | ||
| 598 | void udd_send_remotewakeup(void) { | 610 | void udd_send_remotewakeup(void) { |
| 599 | uint32_t try | 611 | uint32_t try |
| @@ -913,7 +925,7 @@ static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointe | |||
| 913 | usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP); | 925 | usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP); |
| 914 | 926 | ||
| 915 | //#warning Here the sleep mode must be choose to have a DFLL startup time < bmAttribut.HIRD | 927 | //#warning Here the sleep mode must be choose to have a DFLL startup time < bmAttribut.HIRD |
| 916 | udd_sleep_mode(UDD_STATE_SUSPEND_LPM); // Enter in LPM SUSPEND mode | 928 | udd_sleep_mode(UDD_STATE_SUSPEND_LPM); // Enter in LPM SUSPEND mode |
| 917 | if ((*lpm_wakeup_enable)) { | 929 | if ((*lpm_wakeup_enable)) { |
| 918 | UDC_REMOTEWAKEUP_LPM_ENABLE(); | 930 | UDC_REMOTEWAKEUP_LPM_ENABLE(); |
| 919 | } | 931 | } |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_hub.c b/tmk_core/protocol/arm_atsam/usb/usb_hub.c index c5fd284aab..14fba799c7 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_hub.c +++ b/tmk_core/protocol/arm_atsam/usb/usb_hub.c | |||
| @@ -27,7 +27,7 @@ uint8_t usb_extra_state; | |||
| 27 | uint8_t usb_extra_manual; | 27 | uint8_t usb_extra_manual; |
| 28 | uint8_t usb_gcr_auto; | 28 | uint8_t usb_gcr_auto; |
| 29 | 29 | ||
| 30 | #endif // MD_BOOTLOADER | 30 | #endif // MD_BOOTLOADER |
| 31 | 31 | ||
| 32 | uint16_t adc_extra; | 32 | uint16_t adc_extra; |
| 33 | 33 | ||
| @@ -51,10 +51,10 @@ void USB_Hub_init(void) { | |||
| 51 | pmclk->APBBMASK.bit.USB_ = 1; | 51 | pmclk->APBBMASK.bit.USB_ = 1; |
| 52 | 52 | ||
| 53 | // setup port pins for D-, D+, and SOF_1KHZ | 53 | // setup port pins for D-, D+, and SOF_1KHZ |
| 54 | pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+ | 54 | pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+ |
| 55 | pport->Group[0].PINCFG[24].bit.PMUXEN = 1; | 55 | pport->Group[0].PINCFG[24].bit.PMUXEN = 1; |
| 56 | pport->Group[0].PINCFG[25].bit.PMUXEN = 1; | 56 | pport->Group[0].PINCFG[25].bit.PMUXEN = 1; |
| 57 | pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output | 57 | pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output |
| 58 | pport->Group[1].PINCFG[22].bit.PMUXEN = 1; | 58 | pport->Group[1].PINCFG[22].bit.PMUXEN = 1; |
| 59 | 59 | ||
| 60 | // configure and enable DFLL for USB clock recovery mode at 48MHz | 60 | // configure and enable DFLL for USB clock recovery mode at 48MHz |
| @@ -78,7 +78,7 @@ void USB_Hub_init(void) { | |||
| 78 | DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4); | 78 | DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4); |
| 79 | } | 79 | } |
| 80 | posc->DFLLCTRLB.bit.CCDIS = 1; | 80 | posc->DFLLCTRLB.bit.CCDIS = 1; |
| 81 | posc->DFLLMUL.bit.MUL = 0xBB80; // 4800 x 1KHz | 81 | posc->DFLLMUL.bit.MUL = 0xBB80; // 4800 x 1KHz |
| 82 | while (posc->DFLLSYNC.bit.DFLLMUL) { | 82 | while (posc->DFLLSYNC.bit.DFLLMUL) { |
| 83 | DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLMUL); | 83 | DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLMUL); |
| 84 | } | 84 | } |
| @@ -99,7 +99,7 @@ void USB_Hub_init(void) { | |||
| 99 | pusb->DEVICE.PADCAL.bit.TRANSP = (USB_FUSES_TRANSP_ADDR >> USB_FUSES_TRANSP_Pos) & USB_FUSES_TRANSP_Msk; | 99 | pusb->DEVICE.PADCAL.bit.TRANSP = (USB_FUSES_TRANSP_ADDR >> USB_FUSES_TRANSP_Pos) & USB_FUSES_TRANSP_Msk; |
| 100 | pusb->DEVICE.PADCAL.bit.TRIM = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk; | 100 | pusb->DEVICE.PADCAL.bit.TRIM = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk; |
| 101 | // device mode, enabled | 101 | // device mode, enabled |
| 102 | pusb->DEVICE.CTRLB.bit.SPDCONF = 0; // full speed | 102 | pusb->DEVICE.CTRLB.bit.SPDCONF = 0; // full speed |
| 103 | pusb->DEVICE.CTRLA.bit.MODE = 0; | 103 | pusb->DEVICE.CTRLA.bit.MODE = 0; |
| 104 | pusb->DEVICE.CTRLA.bit.ENABLE = 1; | 104 | pusb->DEVICE.CTRLA.bit.ENABLE = 1; |
| 105 | while (pusb->DEVICE.SYNCBUSY.bit.ENABLE) { | 105 | while (pusb->DEVICE.SYNCBUSY.bit.ENABLE) { |
| @@ -111,8 +111,8 @@ void USB_Hub_init(void) { | |||
| 111 | 111 | ||
| 112 | USB2422_init(); | 112 | USB2422_init(); |
| 113 | 113 | ||
| 114 | sr_exp_data.bit.HUB_CONNECT = 1; // connect signal | 114 | sr_exp_data.bit.HUB_CONNECT = 1; // connect signal |
| 115 | sr_exp_data.bit.HUB_RESET_N = 1; // reset high | 115 | sr_exp_data.bit.HUB_RESET_N = 1; // reset high |
| 116 | SR_EXP_WriteData(); | 116 | SR_EXP_WriteData(); |
| 117 | 117 | ||
| 118 | wait_us(100); | 118 | wait_us(100); |
| @@ -122,7 +122,7 @@ void USB_Hub_init(void) { | |||
| 122 | usb_extra_manual = 0; | 122 | usb_extra_manual = 0; |
| 123 | usb_gcr_auto = 1; | 123 | usb_gcr_auto = 1; |
| 124 | 124 | ||
| 125 | #endif // MD_BOOTLOADER | 125 | #endif // MD_BOOTLOADER |
| 126 | 126 | ||
| 127 | DBGC(DC_USB2422_INIT_COMPLETE); | 127 | DBGC(DC_USB2422_INIT_COMPLETE); |
| 128 | } | 128 | } |
| @@ -131,10 +131,10 @@ void USB_reset(void) { | |||
| 131 | DBGC(DC_USB_RESET_BEGIN); | 131 | DBGC(DC_USB_RESET_BEGIN); |
| 132 | 132 | ||
| 133 | // pulse reset for at least 1 usec | 133 | // pulse reset for at least 1 usec |
| 134 | sr_exp_data.bit.HUB_RESET_N = 0; // reset low | 134 | sr_exp_data.bit.HUB_RESET_N = 0; // reset low |
| 135 | SR_EXP_WriteData(); | 135 | SR_EXP_WriteData(); |
| 136 | wait_us(2); | 136 | wait_us(2); |
| 137 | sr_exp_data.bit.HUB_RESET_N = 1; // reset high to run | 137 | sr_exp_data.bit.HUB_RESET_N = 1; // reset high to run |
| 138 | SR_EXP_WriteData(); | 138 | SR_EXP_WriteData(); |
| 139 | 139 | ||
| 140 | DBGC(DC_USB_RESET_COMPLETE); | 140 | DBGC(DC_USB_RESET_COMPLETE); |
| @@ -150,7 +150,9 @@ void USB_configure(void) { | |||
| 150 | DBGC(DC_USB_CONFIGURE_COMPLETE); | 150 | DBGC(DC_USB_CONFIGURE_COMPLETE); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | uint16_t USB_active(void) { return USB2422_active(); } | 153 | uint16_t USB_active(void) { |
| 154 | return USB2422_active(); | ||
| 155 | } | ||
| 154 | 156 | ||
| 155 | void USB_set_host_by_voltage(void) { | 157 | void USB_set_host_by_voltage(void) { |
| 156 | // UP is upstream device (HOST) | 158 | // UP is upstream device (HOST) |
| @@ -162,13 +164,13 @@ void USB_set_host_by_voltage(void) { | |||
| 162 | usb_host_port = USB_HOST_PORT_UNKNOWN; | 164 | usb_host_port = USB_HOST_PORT_UNKNOWN; |
| 163 | #ifndef MD_BOOTLOADER | 165 | #ifndef MD_BOOTLOADER |
| 164 | usb_extra_state = USB_EXTRA_STATE_UNKNOWN; | 166 | usb_extra_state = USB_EXTRA_STATE_UNKNOWN; |
| 165 | #endif // MD_BOOTLOADER | 167 | #endif // MD_BOOTLOADER |
| 166 | sr_exp_data.bit.SRC_1 = 1; // USBC-1 available for test | 168 | sr_exp_data.bit.SRC_1 = 1; // USBC-1 available for test |
| 167 | sr_exp_data.bit.SRC_2 = 1; // USBC-2 available for test | 169 | sr_exp_data.bit.SRC_2 = 1; // USBC-2 available for test |
| 168 | sr_exp_data.bit.E_UP_N = 1; // HOST disable | 170 | sr_exp_data.bit.E_UP_N = 1; // HOST disable |
| 169 | sr_exp_data.bit.E_DN1_N = 1; // EXTRA disable | 171 | sr_exp_data.bit.E_DN1_N = 1; // EXTRA disable |
| 170 | sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O | 172 | sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O |
| 171 | sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O | 173 | sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O |
| 172 | 174 | ||
| 173 | SR_EXP_WriteData(); | 175 | SR_EXP_WriteData(); |
| 174 | 176 | ||
| @@ -185,33 +187,33 @@ void USB_set_host_by_voltage(void) { | |||
| 185 | v_con_2_boot = v_con_2; | 187 | v_con_2_boot = v_con_2; |
| 186 | 188 | ||
| 187 | if (v_con_1 > v_con_2) { | 189 | if (v_con_1 > v_con_2) { |
| 188 | sr_exp_data.bit.S_UP = 0; // HOST to USBC-1 | 190 | sr_exp_data.bit.S_UP = 0; // HOST to USBC-1 |
| 189 | sr_exp_data.bit.S_DN1 = 1; // EXTRA to USBC-2 | 191 | sr_exp_data.bit.S_DN1 = 1; // EXTRA to USBC-2 |
| 190 | sr_exp_data.bit.SRC_1 = 1; // HOST on USBC-1 | 192 | sr_exp_data.bit.SRC_1 = 1; // HOST on USBC-1 |
| 191 | sr_exp_data.bit.SRC_2 = 0; // EXTRA available on USBC-2 | 193 | sr_exp_data.bit.SRC_2 = 0; // EXTRA available on USBC-2 |
| 192 | 194 | ||
| 193 | sr_exp_data.bit.E_VBUS_1 = 1; // USBC-1 enable full power I/O | 195 | sr_exp_data.bit.E_VBUS_1 = 1; // USBC-1 enable full power I/O |
| 194 | sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O | 196 | sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O |
| 195 | 197 | ||
| 196 | SR_EXP_WriteData(); | 198 | SR_EXP_WriteData(); |
| 197 | 199 | ||
| 198 | sr_exp_data.bit.E_UP_N = 0; // HOST enable | 200 | sr_exp_data.bit.E_UP_N = 0; // HOST enable |
| 199 | 201 | ||
| 200 | SR_EXP_WriteData(); | 202 | SR_EXP_WriteData(); |
| 201 | 203 | ||
| 202 | usb_host_port = USB_HOST_PORT_1; | 204 | usb_host_port = USB_HOST_PORT_1; |
| 203 | } else { | 205 | } else { |
| 204 | sr_exp_data.bit.S_UP = 1; // EXTRA to USBC-1 | 206 | sr_exp_data.bit.S_UP = 1; // EXTRA to USBC-1 |
| 205 | sr_exp_data.bit.S_DN1 = 0; // HOST to USBC-2 | 207 | sr_exp_data.bit.S_DN1 = 0; // HOST to USBC-2 |
| 206 | sr_exp_data.bit.SRC_1 = 0; // EXTRA available on USBC-1 | 208 | sr_exp_data.bit.SRC_1 = 0; // EXTRA available on USBC-1 |
| 207 | sr_exp_data.bit.SRC_2 = 1; // HOST on USBC-2 | 209 | sr_exp_data.bit.SRC_2 = 1; // HOST on USBC-2 |
| 208 | 210 | ||
| 209 | sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O | 211 | sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O |
| 210 | sr_exp_data.bit.E_VBUS_2 = 1; // USBC-2 enable full power I/O | 212 | sr_exp_data.bit.E_VBUS_2 = 1; // USBC-2 enable full power I/O |
| 211 | 213 | ||
| 212 | SR_EXP_WriteData(); | 214 | SR_EXP_WriteData(); |
| 213 | 215 | ||
| 214 | sr_exp_data.bit.E_UP_N = 0; // HOST enable | 216 | sr_exp_data.bit.E_UP_N = 0; // HOST enable |
| 215 | 217 | ||
| 216 | SR_EXP_WriteData(); | 218 | SR_EXP_WriteData(); |
| 217 | 219 | ||
| @@ -220,7 +222,7 @@ void USB_set_host_by_voltage(void) { | |||
| 220 | 222 | ||
| 221 | #ifndef MD_BOOTLOADER | 223 | #ifndef MD_BOOTLOADER |
| 222 | usb_extra_state = USB_EXTRA_STATE_DISABLED; | 224 | usb_extra_state = USB_EXTRA_STATE_DISABLED; |
| 223 | #endif // MD_BOOTLOADER | 225 | #endif // MD_BOOTLOADER |
| 224 | 226 | ||
| 225 | USB_reset(); | 227 | USB_reset(); |
| 226 | USB_configure(); | 228 | USB_configure(); |
| @@ -241,7 +243,7 @@ uint8_t USB_Hub_Port_Detect_Init(void) { | |||
| 241 | while (!USB_active()) { | 243 | while (!USB_active()) { |
| 242 | tmod = timer_read64() % PORT_DETECT_RETRY_INTERVAL; | 244 | tmod = timer_read64() % PORT_DETECT_RETRY_INTERVAL; |
| 243 | 245 | ||
| 244 | if (v_con_1 > v_con_2) // Values updated from USB_set_host_by_voltage(); | 246 | if (v_con_1 > v_con_2) // Values updated from USB_set_host_by_voltage(); |
| 245 | { | 247 | { |
| 246 | // 1 flash for port 1 detected | 248 | // 1 flash for port 1 detected |
| 247 | if (tmod > 500 && tmod < 600) { | 249 | if (tmod > 500 && tmod < 600) { |
| @@ -249,7 +251,7 @@ uint8_t USB_Hub_Port_Detect_Init(void) { | |||
| 249 | } else { | 251 | } else { |
| 250 | DBG_LED_OFF; | 252 | DBG_LED_OFF; |
| 251 | } | 253 | } |
| 252 | } else if (v_con_2 > v_con_1) // Values updated from USB_set_host_by_voltage(); | 254 | } else if (v_con_2 > v_con_1) // Values updated from USB_set_host_by_voltage(); |
| 253 | { | 255 | { |
| 254 | // 2 flash for port 2 detected | 256 | // 2 flash for port 2 detected |
| 255 | if (tmod > 500 && tmod < 600) { | 257 | if (tmod > 500 && tmod < 600) { |
| @@ -321,7 +323,7 @@ void USB_HandleExtraDevice(void) { | |||
| 321 | // Detect unplug and reset state to disabled | 323 | // Detect unplug and reset state to disabled |
| 322 | if (adc_extra > USB_EXTRA_ADC_THRESHOLD) usb_extra_state = USB_EXTRA_STATE_DISABLED; | 324 | if (adc_extra > USB_EXTRA_ADC_THRESHOLD) usb_extra_state = USB_EXTRA_STATE_DISABLED; |
| 323 | 325 | ||
| 324 | return; // Return even if unplug detected | 326 | return; // Return even if unplug detected |
| 325 | } | 327 | } |
| 326 | 328 | ||
| 327 | if (usb_extra_manual) { | 329 | if (usb_extra_manual) { |
| @@ -337,4 +339,4 @@ void USB_HandleExtraDevice(void) { | |||
| 337 | USB_ExtraSetState(USB_EXTRA_STATE_DISABLED); | 339 | USB_ExtraSetState(USB_EXTRA_STATE_DISABLED); |
| 338 | } | 340 | } |
| 339 | 341 | ||
| 340 | #endif // MD_BOOTLOADER | 342 | #endif // MD_BOOTLOADER |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_hub.h b/tmk_core/protocol/arm_atsam/usb/usb_hub.h index 76b1e0a326..d7b2e3fab4 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_hub.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_hub.h | |||
| @@ -48,4 +48,4 @@ uint16_t adc_get(uint8_t muxpos); | |||
| 48 | void USB_HandleExtraDevice(void); | 48 | void USB_HandleExtraDevice(void); |
| 49 | void USB_ExtraSetState(uint8_t state); | 49 | void USB_ExtraSetState(uint8_t state); |
| 50 | 50 | ||
| 51 | #endif //_USB2422_H_ | 51 | #endif //_USB2422_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_main.h b/tmk_core/protocol/arm_atsam/usb/usb_main.h index d8461c6c9f..c3b1698c59 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_main.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_main.h | |||
| @@ -71,31 +71,31 @@ void main_kbd_disable(void); | |||
| 71 | extern volatile bool main_b_nkro_enable; | 71 | extern volatile bool main_b_nkro_enable; |
| 72 | bool main_nkro_enable(void); | 72 | bool main_nkro_enable(void); |
| 73 | void main_nkro_disable(void); | 73 | void main_nkro_disable(void); |
| 74 | #endif // NKRO_ENABLE | 74 | #endif // NKRO_ENABLE |
| 75 | 75 | ||
| 76 | #ifdef EXTRAKEY_ENABLE | 76 | #ifdef EXTRAKEY_ENABLE |
| 77 | extern volatile bool main_b_exk_enable; | 77 | extern volatile bool main_b_exk_enable; |
| 78 | bool main_exk_enable(void); | 78 | bool main_exk_enable(void); |
| 79 | void main_exk_disable(void); | 79 | void main_exk_disable(void); |
| 80 | #endif // EXTRAKEY_ENABLE | 80 | #endif // EXTRAKEY_ENABLE |
| 81 | 81 | ||
| 82 | #ifdef CONSOLE_ENABLE | 82 | #ifdef CONSOLE_ENABLE |
| 83 | extern volatile bool main_b_con_enable; | 83 | extern volatile bool main_b_con_enable; |
| 84 | bool main_con_enable(void); | 84 | bool main_con_enable(void); |
| 85 | void main_con_disable(void); | 85 | void main_con_disable(void); |
| 86 | #endif // CONSOLE_ENABLE | 86 | #endif // CONSOLE_ENABLE |
| 87 | 87 | ||
| 88 | #ifdef MOUSE_ENABLE | 88 | #ifdef MOUSE_ENABLE |
| 89 | extern volatile bool main_b_mou_enable; | 89 | extern volatile bool main_b_mou_enable; |
| 90 | bool main_mou_enable(void); | 90 | bool main_mou_enable(void); |
| 91 | void main_mou_disable(void); | 91 | void main_mou_disable(void); |
| 92 | #endif // MOUSE_ENABLE | 92 | #endif // MOUSE_ENABLE |
| 93 | 93 | ||
| 94 | #ifdef RAW_ENABLE | 94 | #ifdef RAW_ENABLE |
| 95 | extern volatile bool main_b_raw_enable; | 95 | extern volatile bool main_b_raw_enable; |
| 96 | bool main_raw_enable(void); | 96 | bool main_raw_enable(void); |
| 97 | void main_raw_disable(void); | 97 | void main_raw_disable(void); |
| 98 | void main_raw_receive(uint8_t *buffer, uint8_t len); | 98 | void main_raw_receive(uint8_t *buffer, uint8_t len); |
| 99 | #endif // RAW_ENABLE | 99 | #endif // RAW_ENABLE |
| 100 | 100 | ||
| 101 | #endif // _MAIN_H_ | 101 | #endif // _MAIN_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol.h index 54d023a6ee..639b80a804 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_protocol.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol.h | |||
| @@ -63,8 +63,8 @@ | |||
| 63 | */ | 63 | */ |
| 64 | 64 | ||
| 65 | //! Value for field bcdUSB | 65 | //! Value for field bcdUSB |
| 66 | #define USB_V2_0 0x0200 //!< USB Specification version 2.00 | 66 | #define USB_V2_0 0x0200 //!< USB Specification version 2.00 |
| 67 | #define USB_V2_1 0x0201 //!< USB Specification version 2.01 | 67 | #define USB_V2_1 0x0201 //!< USB Specification version 2.01 |
| 68 | 68 | ||
| 69 | /*! \name Generic definitions (Class, subclass and protocol) | 69 | /*! \name Generic definitions (Class, subclass and protocol) |
| 70 | */ | 70 | */ |
| @@ -85,26 +85,26 @@ | |||
| 85 | /** | 85 | /** |
| 86 | * \brief USB request data transfer direction (bmRequestType) | 86 | * \brief USB request data transfer direction (bmRequestType) |
| 87 | */ | 87 | */ |
| 88 | #define USB_REQ_DIR_OUT (0 << 7) //!< Host to device | 88 | #define USB_REQ_DIR_OUT (0 << 7) //!< Host to device |
| 89 | #define USB_REQ_DIR_IN (1 << 7) //!< Device to host | 89 | #define USB_REQ_DIR_IN (1 << 7) //!< Device to host |
| 90 | #define USB_REQ_DIR_MASK (1 << 7) //!< Mask | 90 | #define USB_REQ_DIR_MASK (1 << 7) //!< Mask |
| 91 | 91 | ||
| 92 | /** | 92 | /** |
| 93 | * \brief USB request types (bmRequestType) | 93 | * \brief USB request types (bmRequestType) |
| 94 | */ | 94 | */ |
| 95 | #define USB_REQ_TYPE_STANDARD (0 << 5) //!< Standard request | 95 | #define USB_REQ_TYPE_STANDARD (0 << 5) //!< Standard request |
| 96 | #define USB_REQ_TYPE_CLASS (1 << 5) //!< Class-specific request | 96 | #define USB_REQ_TYPE_CLASS (1 << 5) //!< Class-specific request |
| 97 | #define USB_REQ_TYPE_VENDOR (2 << 5) //!< Vendor-specific request | 97 | #define USB_REQ_TYPE_VENDOR (2 << 5) //!< Vendor-specific request |
| 98 | #define USB_REQ_TYPE_MASK (3 << 5) //!< Mask | 98 | #define USB_REQ_TYPE_MASK (3 << 5) //!< Mask |
| 99 | 99 | ||
| 100 | /** | 100 | /** |
| 101 | * \brief USB recipient codes (bmRequestType) | 101 | * \brief USB recipient codes (bmRequestType) |
| 102 | */ | 102 | */ |
| 103 | #define USB_REQ_RECIP_DEVICE (0 << 0) //!< Recipient device | 103 | #define USB_REQ_RECIP_DEVICE (0 << 0) //!< Recipient device |
| 104 | #define USB_REQ_RECIP_INTERFACE (1 << 0) //!< Recipient interface | 104 | #define USB_REQ_RECIP_INTERFACE (1 << 0) //!< Recipient interface |
| 105 | #define USB_REQ_RECIP_ENDPOINT (2 << 0) //!< Recipient endpoint | 105 | #define USB_REQ_RECIP_ENDPOINT (2 << 0) //!< Recipient endpoint |
| 106 | #define USB_REQ_RECIP_OTHER (3 << 0) //!< Recipient other | 106 | #define USB_REQ_RECIP_OTHER (3 << 0) //!< Recipient other |
| 107 | #define USB_REQ_RECIP_MASK (0x1F) //!< Mask | 107 | #define USB_REQ_RECIP_MASK (0x1F) //!< Mask |
| 108 | 108 | ||
| 109 | /** | 109 | /** |
| 110 | * \brief Standard USB requests (bRequest) | 110 | * \brief Standard USB requests (bRequest) |
| @@ -149,8 +149,8 @@ enum usb_endpoint_status { | |||
| 149 | * \note valid for SetFeature request. | 149 | * \note valid for SetFeature request. |
| 150 | */ | 150 | */ |
| 151 | enum usb_device_feature { | 151 | enum usb_device_feature { |
| 152 | USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled | 152 | USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled |
| 153 | USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode | 153 | USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode |
| 154 | USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3, | 154 | USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3, |
| 155 | USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4, | 155 | USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4, |
| 156 | USB_DEV_FEATURE_OTG_A_ALT_HNP_SUPPORT = 5 | 156 | USB_DEV_FEATURE_OTG_A_ALT_HNP_SUPPORT = 5 |
| @@ -261,7 +261,7 @@ enum usb_ep_type { | |||
| 261 | * \brief Standard USB language IDs for string descriptors | 261 | * \brief Standard USB language IDs for string descriptors |
| 262 | */ | 262 | */ |
| 263 | enum usb_langid { | 263 | enum usb_langid { |
| 264 | USB_LANGID_EN_US = 0x0409, //!< English (United States) | 264 | USB_LANGID_EN_US = 0x0409, //!< English (United States) |
| 265 | }; | 265 | }; |
| 266 | 266 | ||
| 267 | /** | 267 | /** |
| @@ -396,14 +396,14 @@ typedef struct { | |||
| 396 | * \brief Standard USB Interface Association Descriptor structure | 396 | * \brief Standard USB Interface Association Descriptor structure |
| 397 | */ | 397 | */ |
| 398 | typedef struct { | 398 | typedef struct { |
| 399 | uint8_t bLength; //!< size of this descriptor in bytes | 399 | uint8_t bLength; //!< size of this descriptor in bytes |
| 400 | uint8_t bDescriptorType; //!< INTERFACE descriptor type | 400 | uint8_t bDescriptorType; //!< INTERFACE descriptor type |
| 401 | uint8_t bFirstInterface; //!< Number of interface | 401 | uint8_t bFirstInterface; //!< Number of interface |
| 402 | uint8_t bInterfaceCount; //!< value to select alternate setting | 402 | uint8_t bInterfaceCount; //!< value to select alternate setting |
| 403 | uint8_t bFunctionClass; //!< Class code assigned by the USB | 403 | uint8_t bFunctionClass; //!< Class code assigned by the USB |
| 404 | uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB | 404 | uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB |
| 405 | uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB | 405 | uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB |
| 406 | uint8_t iFunction; //!< Index of string descriptor | 406 | uint8_t iFunction; //!< Index of string descriptor |
| 407 | } usb_association_desc_t; | 407 | } usb_association_desc_t; |
| 408 | 408 | ||
| 409 | /** | 409 | /** |
| @@ -420,25 +420,25 @@ typedef struct { | |||
| 420 | uint8_t bMaxPower; | 420 | uint8_t bMaxPower; |
| 421 | } usb_conf_desc_t; | 421 | } usb_conf_desc_t; |
| 422 | 422 | ||
| 423 | #define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set | 423 | #define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set |
| 424 | #define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered | 424 | #define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered |
| 425 | #define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered | 425 | #define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered |
| 426 | #define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported | 426 | #define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported |
| 427 | 427 | ||
| 428 | #define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA | 428 | #define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA |
| 429 | 429 | ||
| 430 | /** | 430 | /** |
| 431 | * \brief Standard USB association descriptor structure | 431 | * \brief Standard USB association descriptor structure |
| 432 | */ | 432 | */ |
| 433 | typedef struct { | 433 | typedef struct { |
| 434 | uint8_t bLength; //!< Size of this descriptor in bytes | 434 | uint8_t bLength; //!< Size of this descriptor in bytes |
| 435 | uint8_t bDescriptorType; //!< Interface descriptor type | 435 | uint8_t bDescriptorType; //!< Interface descriptor type |
| 436 | uint8_t bFirstInterface; //!< Number of interface | 436 | uint8_t bFirstInterface; //!< Number of interface |
| 437 | uint8_t bInterfaceCount; //!< value to select alternate setting | 437 | uint8_t bInterfaceCount; //!< value to select alternate setting |
| 438 | uint8_t bFunctionClass; //!< Class code assigned by the USB | 438 | uint8_t bFunctionClass; //!< Class code assigned by the USB |
| 439 | uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB | 439 | uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB |
| 440 | uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB | 440 | uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB |
| 441 | uint8_t iFunction; //!< Index of string descriptor | 441 | uint8_t iFunction; //!< Index of string descriptor |
| 442 | } usb_iad_desc_t; | 442 | } usb_iad_desc_t; |
| 443 | 443 | ||
| 444 | /** | 444 | /** |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h index f35503a3be..1d36d58dbd 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h | |||
| @@ -50,41 +50,41 @@ | |||
| 50 | 50 | ||
| 51 | #ifdef VIRTSER_ENABLE | 51 | #ifdef VIRTSER_ENABLE |
| 52 | 52 | ||
| 53 | # define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class | 53 | # define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class |
| 54 | # define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface | 54 | # define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface |
| 55 | # define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface | 55 | # define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface |
| 56 | 56 | ||
| 57 | # define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model | 57 | # define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model |
| 58 | # define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model | 58 | # define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model |
| 59 | # define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model | 59 | # define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model |
| 60 | # define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model | 60 | # define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model |
| 61 | # define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model | 61 | # define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model |
| 62 | # define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model | 62 | # define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model |
| 63 | # define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model | 63 | # define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model |
| 64 | 64 | ||
| 65 | # define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands | 65 | # define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands |
| 66 | 66 | ||
| 67 | # define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI | 67 | # define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI |
| 68 | # define CDC_PROTOCOL_HDLC 0x31 //!< HDLC | 68 | # define CDC_PROTOCOL_HDLC 0x31 //!< HDLC |
| 69 | # define CDC_PROTOCOL_TRANS 0x32 //!< Transparent | 69 | # define CDC_PROTOCOL_TRANS 0x32 //!< Transparent |
| 70 | # define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol | 70 | # define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol |
| 71 | # define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol | 71 | # define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol |
| 72 | # define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor | 72 | # define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor |
| 73 | # define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures | 73 | # define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures |
| 74 | # define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control | 74 | # define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control |
| 75 | # define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN | 75 | # define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN |
| 76 | # define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands | 76 | # define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands |
| 77 | # define CDC_PROTOCOL_HOST 0xFD //!< Host based driver | 77 | # define CDC_PROTOCOL_HOST 0xFD //!< Host based driver |
| 78 | 78 | ||
| 79 | # define CDC_PROTOCOL_PUFD 0xFE | 79 | # define CDC_PROTOCOL_PUFD 0xFE |
| 80 | 80 | ||
| 81 | # define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor | 81 | # define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor |
| 82 | # define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor | 82 | # define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor |
| 83 | 83 | ||
| 84 | # define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor | 84 | # define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor |
| 85 | # define CDC_SCS_CALL_MGMT 0x01 //!< Call Management | 85 | # define CDC_SCS_CALL_MGMT 0x01 //!< Call Management |
| 86 | # define CDC_SCS_ACM 0x02 //!< Abstract Control Management | 86 | # define CDC_SCS_ACM 0x02 //!< Abstract Control Management |
| 87 | # define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor | 87 | # define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor |
| 88 | 88 | ||
| 89 | # define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00 | 89 | # define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00 |
| 90 | # define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01 | 90 | # define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01 |
| @@ -144,17 +144,17 @@ typedef struct { | |||
| 144 | # pragma pack(pop) | 144 | # pragma pack(pop) |
| 145 | 145 | ||
| 146 | enum cdc_char_format { | 146 | enum cdc_char_format { |
| 147 | CDC_STOP_BITS_1 = 0, //!< 1 stop bit | 147 | CDC_STOP_BITS_1 = 0, //!< 1 stop bit |
| 148 | CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits | 148 | CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits |
| 149 | CDC_STOP_BITS_2 = 2, //!< 2 stop bits | 149 | CDC_STOP_BITS_2 = 2, //!< 2 stop bits |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | enum cdc_parity { | 152 | enum cdc_parity { |
| 153 | CDC_PAR_NONE = 0, //!< No parity | 153 | CDC_PAR_NONE = 0, //!< No parity |
| 154 | CDC_PAR_ODD = 1, //!< Odd parity | 154 | CDC_PAR_ODD = 1, //!< Odd parity |
| 155 | CDC_PAR_EVEN = 2, //!< Even parity | 155 | CDC_PAR_EVEN = 2, //!< Even parity |
| 156 | CDC_PAR_MARK = 3, //!< Parity forced to 0 (space) | 156 | CDC_PAR_MARK = 3, //!< Parity forced to 0 (space) |
| 157 | CDC_PAR_SPACE = 4, //!< Parity forced to 1 (mark) | 157 | CDC_PAR_SPACE = 4, //!< Parity forced to 1 (mark) |
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | typedef struct { | 160 | typedef struct { |
| @@ -187,4 +187,4 @@ typedef struct { | |||
| 187 | 187 | ||
| 188 | #endif | 188 | #endif |
| 189 | 189 | ||
| 190 | #endif // _USB_PROTOCOL_CDC_H_ | 190 | #endif // _USB_PROTOCOL_CDC_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h index fb97f63cef..c984c0762f 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h | |||
| @@ -121,13 +121,13 @@ COMPILER_PACK_SET(1) | |||
| 121 | 121 | ||
| 122 | //! \brief HID Descriptor | 122 | //! \brief HID Descriptor |
| 123 | typedef struct { | 123 | typedef struct { |
| 124 | uint8_t bLength; //!< Size of this descriptor in bytes | 124 | uint8_t bLength; //!< Size of this descriptor in bytes |
| 125 | uint8_t bDescriptorType; //!< HID descriptor type | 125 | uint8_t bDescriptorType; //!< HID descriptor type |
| 126 | le16_t bcdHID; //!< Binary Coded Decimal Spec. release | 126 | le16_t bcdHID; //!< Binary Coded Decimal Spec. release |
| 127 | uint8_t bCountryCode; //!< Hardware target country | 127 | uint8_t bCountryCode; //!< Hardware target country |
| 128 | uint8_t bNumDescriptors; //!< Number of HID class descriptors to follow | 128 | uint8_t bNumDescriptors; //!< Number of HID class descriptors to follow |
| 129 | uint8_t bRDescriptorType; //!< Report descriptor type | 129 | uint8_t bRDescriptorType; //!< Report descriptor type |
| 130 | le16_t wDescriptorLength; //!< Total length of Report descriptor | 130 | le16_t wDescriptorLength; //!< Total length of Report descriptor |
| 131 | } usb_hid_descriptor_t; | 131 | } usb_hid_descriptor_t; |
| 132 | 132 | ||
| 133 | COMPILER_PACK_RESET() | 133 | COMPILER_PACK_RESET() |
| @@ -151,45 +151,45 @@ COMPILER_PACK_RESET() | |||
| 151 | 151 | ||
| 152 | //! \name Country code | 152 | //! \name Country code |
| 153 | //! @{ | 153 | //! @{ |
| 154 | #define USB_HID_NO_COUNTRY_CODE 0 // Not Supported | 154 | #define USB_HID_NO_COUNTRY_CODE 0 // Not Supported |
| 155 | #define USB_HID_COUNTRY_ARABIC 1 // Arabic | 155 | #define USB_HID_COUNTRY_ARABIC 1 // Arabic |
| 156 | #define USB_HID_COUNTRY_BELGIAN 2 // Belgian | 156 | #define USB_HID_COUNTRY_BELGIAN 2 // Belgian |
| 157 | #define USB_HID_COUNTRY_CANADIAN_BILINGUAL 3 // Canadian-Bilingual | 157 | #define USB_HID_COUNTRY_CANADIAN_BILINGUAL 3 // Canadian-Bilingual |
| 158 | #define USB_HID_COUNTRY_CANADIAN_FRENCH 4 // Canadian-French | 158 | #define USB_HID_COUNTRY_CANADIAN_FRENCH 4 // Canadian-French |
| 159 | #define USB_HID_COUNTRY_CZECH_REPUBLIC 5 // Czech Republic | 159 | #define USB_HID_COUNTRY_CZECH_REPUBLIC 5 // Czech Republic |
| 160 | #define USB_HID_COUNTRY_DANISH 6 // Danish | 160 | #define USB_HID_COUNTRY_DANISH 6 // Danish |
| 161 | #define USB_HID_COUNTRY_FINNISH 7 // Finnish | 161 | #define USB_HID_COUNTRY_FINNISH 7 // Finnish |
| 162 | #define USB_HID_COUNTRY_FRENCH 8 // French | 162 | #define USB_HID_COUNTRY_FRENCH 8 // French |
| 163 | #define USB_HID_COUNTRY_GERMAN 9 // German | 163 | #define USB_HID_COUNTRY_GERMAN 9 // German |
| 164 | #define USB_HID_COUNTRY_GREEK 10 // Greek | 164 | #define USB_HID_COUNTRY_GREEK 10 // Greek |
| 165 | #define USB_HID_COUNTRY_HEBREW 11 // Hebrew | 165 | #define USB_HID_COUNTRY_HEBREW 11 // Hebrew |
| 166 | #define USB_HID_COUNTRY_HUNGARY 12 // Hungary | 166 | #define USB_HID_COUNTRY_HUNGARY 12 // Hungary |
| 167 | #define USB_HID_COUNTRY_INTERNATIONAL_ISO 13 // International (ISO) | 167 | #define USB_HID_COUNTRY_INTERNATIONAL_ISO 13 // International (ISO) |
| 168 | #define USB_HID_COUNTRY_ITALIAN 14 // Italian | 168 | #define USB_HID_COUNTRY_ITALIAN 14 // Italian |
| 169 | #define USB_HID_COUNTRY_JAPAN_KATAKANA 15 // Japan (Katakana) | 169 | #define USB_HID_COUNTRY_JAPAN_KATAKANA 15 // Japan (Katakana) |
| 170 | #define USB_HID_COUNTRY_KOREAN 16 // Korean | 170 | #define USB_HID_COUNTRY_KOREAN 16 // Korean |
| 171 | #define USB_HID_COUNTRY_LATIN_AMERICAN 17 // Latin American | 171 | #define USB_HID_COUNTRY_LATIN_AMERICAN 17 // Latin American |
| 172 | #define USB_HID_COUNTRY_NETHERLANDS_DUTCH 18 // Netherlands/Dutch | 172 | #define USB_HID_COUNTRY_NETHERLANDS_DUTCH 18 // Netherlands/Dutch |
| 173 | #define USB_HID_COUNTRY_NORWEGIAN 19 // Norwegian | 173 | #define USB_HID_COUNTRY_NORWEGIAN 19 // Norwegian |
| 174 | #define USB_HID_COUNTRY_PERSIAN_FARSI 20 // Persian (Farsi) | 174 | #define USB_HID_COUNTRY_PERSIAN_FARSI 20 // Persian (Farsi) |
| 175 | #define USB_HID_COUNTRY_POLAND 21 // Poland | 175 | #define USB_HID_COUNTRY_POLAND 21 // Poland |
| 176 | #define USB_HID_COUNTRY_PORTUGUESE 22 // Portuguese | 176 | #define USB_HID_COUNTRY_PORTUGUESE 22 // Portuguese |
| 177 | #define USB_HID_COUNTRY_RUSSIA 23 // Russia | 177 | #define USB_HID_COUNTRY_RUSSIA 23 // Russia |
| 178 | #define USB_HID_COUNTRY_SLOVAKIA 24 // Slovakia | 178 | #define USB_HID_COUNTRY_SLOVAKIA 24 // Slovakia |
| 179 | #define USB_HID_COUNTRY_SPANISH 25 // Spanish | 179 | #define USB_HID_COUNTRY_SPANISH 25 // Spanish |
| 180 | #define USB_HID_COUNTRY_SWEDISH 26 // Swedish | 180 | #define USB_HID_COUNTRY_SWEDISH 26 // Swedish |
| 181 | #define USB_HID_COUNTRY_SWISS_FRENCH 27 // Swiss/French | 181 | #define USB_HID_COUNTRY_SWISS_FRENCH 27 // Swiss/French |
| 182 | #define USB_HID_COUNTRY_SWISS_GERMAN 28 // Swiss/German | 182 | #define USB_HID_COUNTRY_SWISS_GERMAN 28 // Swiss/German |
| 183 | #define USB_HID_COUNTRY_SWITZERLAND 29 // Switzerland | 183 | #define USB_HID_COUNTRY_SWITZERLAND 29 // Switzerland |
| 184 | #define USB_HID_COUNTRY_TAIWAN 30 // Taiwan | 184 | #define USB_HID_COUNTRY_TAIWAN 30 // Taiwan |
| 185 | #define USB_HID_COUNTRY_TURKISH_Q 31 // Turkish-Q | 185 | #define USB_HID_COUNTRY_TURKISH_Q 31 // Turkish-Q |
| 186 | #define USB_HID_COUNTRY_UK 32 // UK | 186 | #define USB_HID_COUNTRY_UK 32 // UK |
| 187 | #define USB_HID_COUNTRY_US 33 // US | 187 | #define USB_HID_COUNTRY_US 33 // US |
| 188 | #define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia | 188 | #define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia |
| 189 | #define USB_HID_COUNTRY_TURKISH_F \ | 189 | #define USB_HID_COUNTRY_TURKISH_F \ |
| 190 | 35 // Turkish-F | 190 | 35 // Turkish-F |
| 191 | //! @} | 191 | //! @} |
| 192 | //! @} | 192 | //! @} |
| 193 | //! @} | 193 | //! @} |
| 194 | 194 | ||
| 195 | //! \name HID KEYS values | 195 | //! \name HID KEYS values |
| @@ -237,12 +237,12 @@ COMPILER_PACK_RESET() | |||
| 237 | #define HID_SPACEBAR 44 | 237 | #define HID_SPACEBAR 44 |
| 238 | #define HID_UNDERSCORE 45 | 238 | #define HID_UNDERSCORE 45 |
| 239 | #define HID_PLUS 46 | 239 | #define HID_PLUS 46 |
| 240 | #define HID_OPEN_BRACKET 47 // { | 240 | #define HID_OPEN_BRACKET 47 // { |
| 241 | #define HID_CLOSE_BRACKET 48 // } | 241 | #define HID_CLOSE_BRACKET 48 // } |
| 242 | #define HID_BACKSLASH 49 | 242 | #define HID_BACKSLASH 49 |
| 243 | #define HID_ASH 50 // # ~ | 243 | #define HID_ASH 50 // # ~ |
| 244 | #define HID_COLON 51 // ; : | 244 | #define HID_COLON 51 // ; : |
| 245 | #define HID_QUOTE 52 // ' " | 245 | #define HID_QUOTE 52 // ' " |
| 246 | #define HID_TILDE 53 | 246 | #define HID_TILDE 53 |
| 247 | #define HID_COMMA 54 | 247 | #define HID_COMMA 54 |
| 248 | #define HID_DOT 55 | 248 | #define HID_DOT 55 |
| @@ -314,4 +314,4 @@ COMPILER_PACK_RESET() | |||
| 314 | #define HID_LED_KANA (1 << 4) | 314 | #define HID_LED_KANA (1 << 4) |
| 315 | //! @} | 315 | //! @} |
| 316 | 316 | ||
| 317 | #endif // _USB_PROTOCOL_HID_H_ | 317 | #endif // _USB_PROTOCOL_HID_H_ |
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_util.c b/tmk_core/protocol/arm_atsam/usb/usb_util.c index a682c00b58..c7555c84c6 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_util.c +++ b/tmk_core/protocol/arm_atsam/usb/usb_util.c | |||
| @@ -11,17 +11,17 @@ char digit(int d, int radix) { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | int UTIL_ltoa_radix(int64_t value, char *dest, int radix) { | 13 | int UTIL_ltoa_radix(int64_t value, char *dest, int radix) { |
| 14 | int64_t original = value; // save original value | 14 | int64_t original = value; // save original value |
| 15 | char buf[25] = ""; | 15 | char buf[25] = ""; |
| 16 | int c = sizeof(buf) - 1; | 16 | int c = sizeof(buf) - 1; |
| 17 | int last = c; | 17 | int last = c; |
| 18 | int d; | 18 | int d; |
| 19 | int size; | 19 | int size; |
| 20 | 20 | ||
| 21 | if (value < 0) // if it's negative, take the absolute value | 21 | if (value < 0) // if it's negative, take the absolute value |
| 22 | value = -value; | 22 | value = -value; |
| 23 | 23 | ||
| 24 | do // write least significant digit of value that's left | 24 | do // write least significant digit of value that's left |
| 25 | { | 25 | { |
| 26 | d = (value % radix); | 26 | d = (value % radix); |
| 27 | buf[--c] = digit(d, radix); | 27 | buf[--c] = digit(d, radix); |
| @@ -30,14 +30,20 @@ int UTIL_ltoa_radix(int64_t value, char *dest, int radix) { | |||
| 30 | 30 | ||
| 31 | if (original < 0) buf[--c] = '-'; | 31 | if (original < 0) buf[--c] = '-'; |
| 32 | 32 | ||
| 33 | size = last - c + 1; // includes null at end | 33 | size = last - c + 1; // includes null at end |
| 34 | memcpy(dest, &buf[c], last - c + 1); | 34 | memcpy(dest, &buf[c], last - c + 1); |
| 35 | 35 | ||
| 36 | return (size - 1); // without null termination | 36 | return (size - 1); // without null termination |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | int UTIL_ltoa(int64_t value, char *dest) { return UTIL_ltoa_radix(value, dest, 10); } | 39 | int UTIL_ltoa(int64_t value, char *dest) { |
| 40 | return UTIL_ltoa_radix(value, dest, 10); | ||
| 41 | } | ||
| 40 | 42 | ||
| 41 | int UTIL_itoa(int value, char *dest) { return UTIL_ltoa_radix((int64_t)value, dest, 10); } | 43 | int UTIL_itoa(int value, char *dest) { |
| 44 | return UTIL_ltoa_radix((int64_t)value, dest, 10); | ||
| 45 | } | ||
| 42 | 46 | ||
| 43 | int UTIL_utoa(uint32_t value, char *dest) { return UTIL_ltoa_radix((int64_t)value, dest, 10); } | 47 | int UTIL_utoa(uint32_t value, char *dest) { |
| 48 | return UTIL_ltoa_radix((int64_t)value, dest, 10); | ||
| 49 | } | ||
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_util.h b/tmk_core/protocol/arm_atsam/usb/usb_util.h index 3bad2c26f2..3e5b4fbb32 100644 --- a/tmk_core/protocol/arm_atsam/usb/usb_util.h +++ b/tmk_core/protocol/arm_atsam/usb/usb_util.h | |||
| @@ -6,4 +6,4 @@ int UTIL_ltoa(int64_t value, char *dest); | |||
| 6 | int UTIL_itoa(int value, char *dest); | 6 | int UTIL_itoa(int value, char *dest); |
| 7 | int UTIL_utoa(uint32_t value, char *dest); | 7 | int UTIL_utoa(uint32_t value, char *dest); |
| 8 | 8 | ||
| 9 | #endif //_USB_UTIL_H_ | 9 | #endif //_USB_UTIL_H_ |
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index b6cff05e9f..c9a480c325 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c | |||
| @@ -107,7 +107,7 @@ __attribute__((weak)) void early_hardware_init_pre(void) { | |||
| 107 | #if EARLY_INIT_PERFORM_BOOTLOADER_JUMP | 107 | #if EARLY_INIT_PERFORM_BOOTLOADER_JUMP |
| 108 | void enter_bootloader_mode_if_requested(void); | 108 | void enter_bootloader_mode_if_requested(void); |
| 109 | enter_bootloader_mode_if_requested(); | 109 | enter_bootloader_mode_if_requested(); |
| 110 | #endif // EARLY_INIT_PERFORM_BOOTLOADER_JUMP | 110 | #endif // EARLY_INIT_PERFORM_BOOTLOADER_JUMP |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | __attribute__((weak)) void early_hardware_init_post(void) {} | 113 | __attribute__((weak)) void early_hardware_init_post(void) {} |
| @@ -176,7 +176,9 @@ void protocol_pre_init(void) { | |||
| 176 | print("USB configured.\n"); | 176 | print("USB configured.\n"); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | void protocol_post_init(void) { host_set_driver(driver); } | 179 | void protocol_post_init(void) { |
| 180 | host_set_driver(driver); | ||
| 181 | } | ||
| 180 | 182 | ||
| 181 | void protocol_pre_task(void) { | 183 | void protocol_pre_task(void) { |
| 182 | usb_event_queue_task(); | 184 | usb_event_queue_task(); |
| @@ -186,7 +188,7 @@ void protocol_pre_task(void) { | |||
| 186 | print("[s]"); | 188 | print("[s]"); |
| 187 | while (USB_DRIVER.state == USB_SUSPENDED) { | 189 | while (USB_DRIVER.state == USB_SUSPENDED) { |
| 188 | /* Do this in the suspended state */ | 190 | /* Do this in the suspended state */ |
| 189 | suspend_power_down(); // on AVR this deep sleeps for 15ms | 191 | suspend_power_down(); // on AVR this deep sleeps for 15ms |
| 190 | /* Remote wakeup */ | 192 | /* Remote wakeup */ |
| 191 | if (suspend_wakeup_condition()) { | 193 | if (suspend_wakeup_condition()) { |
| 192 | usbWakeupHost(&USB_DRIVER); | 194 | usbWakeupHost(&USB_DRIVER); |
diff --git a/tmk_core/protocol/chibios/usb_driver.c b/tmk_core/protocol/chibios/usb_driver.c index cc0ce7600f..4de060f306 100644 --- a/tmk_core/protocol/chibios/usb_driver.c +++ b/tmk_core/protocol/chibios/usb_driver.c | |||
| @@ -80,21 +80,37 @@ static bool qmkusb_start_receive(QMKUSBDriver *qmkusbp) { | |||
| 80 | * Interface implementation. | 80 | * Interface implementation. |
| 81 | */ | 81 | */ |
| 82 | 82 | ||
| 83 | static size_t _write(void *ip, const uint8_t *bp, size_t n) { return obqWriteTimeout(&((QMKUSBDriver *)ip)->obqueue, bp, n, TIME_INFINITE); } | 83 | static size_t _write(void *ip, const uint8_t *bp, size_t n) { |
| 84 | return obqWriteTimeout(&((QMKUSBDriver *)ip)->obqueue, bp, n, TIME_INFINITE); | ||
| 85 | } | ||
| 84 | 86 | ||
| 85 | static size_t _read(void *ip, uint8_t *bp, size_t n) { return ibqReadTimeout(&((QMKUSBDriver *)ip)->ibqueue, bp, n, TIME_INFINITE); } | 87 | static size_t _read(void *ip, uint8_t *bp, size_t n) { |
| 88 | return ibqReadTimeout(&((QMKUSBDriver *)ip)->ibqueue, bp, n, TIME_INFINITE); | ||
| 89 | } | ||
| 86 | 90 | ||
| 87 | static msg_t _put(void *ip, uint8_t b) { return obqPutTimeout(&((QMKUSBDriver *)ip)->obqueue, b, TIME_INFINITE); } | 91 | static msg_t _put(void *ip, uint8_t b) { |
| 92 | return obqPutTimeout(&((QMKUSBDriver *)ip)->obqueue, b, TIME_INFINITE); | ||
| 93 | } | ||
| 88 | 94 | ||
| 89 | static msg_t _get(void *ip) { return ibqGetTimeout(&((QMKUSBDriver *)ip)->ibqueue, TIME_INFINITE); } | 95 | static msg_t _get(void *ip) { |
| 96 | return ibqGetTimeout(&((QMKUSBDriver *)ip)->ibqueue, TIME_INFINITE); | ||
| 97 | } | ||
| 90 | 98 | ||
| 91 | static msg_t _putt(void *ip, uint8_t b, sysinterval_t timeout) { return obqPutTimeout(&((QMKUSBDriver *)ip)->obqueue, b, timeout); } | 99 | static msg_t _putt(void *ip, uint8_t b, sysinterval_t timeout) { |
| 100 | return obqPutTimeout(&((QMKUSBDriver *)ip)->obqueue, b, timeout); | ||
| 101 | } | ||
| 92 | 102 | ||
| 93 | static msg_t _gett(void *ip, sysinterval_t timeout) { return ibqGetTimeout(&((QMKUSBDriver *)ip)->ibqueue, timeout); } | 103 | static msg_t _gett(void *ip, sysinterval_t timeout) { |
| 104 | return ibqGetTimeout(&((QMKUSBDriver *)ip)->ibqueue, timeout); | ||
| 105 | } | ||
| 94 | 106 | ||
| 95 | static size_t _writet(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout) { return obqWriteTimeout(&((QMKUSBDriver *)ip)->obqueue, bp, n, timeout); } | 107 | static size_t _writet(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout) { |
| 108 | return obqWriteTimeout(&((QMKUSBDriver *)ip)->obqueue, bp, n, timeout); | ||
| 109 | } | ||
| 96 | 110 | ||
| 97 | static size_t _readt(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout) { return ibqReadTimeout(&((QMKUSBDriver *)ip)->ibqueue, bp, n, timeout); } | 111 | static size_t _readt(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout) { |
| 112 | return ibqReadTimeout(&((QMKUSBDriver *)ip)->ibqueue, bp, n, timeout); | ||
| 113 | } | ||
| 98 | 114 | ||
| 99 | static const struct QMKUSBDriverVMT vmt = {0, _write, _read, _put, _get, _putt, _gett, _writet, _readt}; | 115 | static const struct QMKUSBDriverVMT vmt = {0, _write, _read, _put, _get, _putt, _gett, _writet, _readt}; |
| 100 | 116 | ||
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 30bfac9f3e..d9aa351ecb 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -775,7 +775,9 @@ void kbd_in_cb(USBDriver *usbp, usbep_t ep) { | |||
| 775 | /* start-of-frame handler | 775 | /* start-of-frame handler |
| 776 | * TODO: i guess it would be better to re-implement using timers, | 776 | * TODO: i guess it would be better to re-implement using timers, |
| 777 | * so that this is not going to have to be checked every 1ms */ | 777 | * so that this is not going to have to be checked every 1ms */ |
| 778 | void kbd_sof_cb(USBDriver *usbp) { (void)usbp; } | 778 | void kbd_sof_cb(USBDriver *usbp) { |
| 779 | (void)usbp; | ||
| 780 | } | ||
| 779 | 781 | ||
| 780 | /* Idle requests timer code | 782 | /* Idle requests timer code |
| 781 | * callback (called from ISR, unlocked state) */ | 783 | * callback (called from ISR, unlocked state) */ |
| @@ -815,7 +817,9 @@ static void keyboard_idle_timer_cb(void *arg) { | |||
| 815 | } | 817 | } |
| 816 | 818 | ||
| 817 | /* LED status */ | 819 | /* LED status */ |
| 818 | uint8_t keyboard_leds(void) { return keyboard_led_state; } | 820 | uint8_t keyboard_leds(void) { |
| 821 | return keyboard_led_state; | ||
| 822 | } | ||
| 819 | 823 | ||
| 820 | /* prepare and start sending a report IN | 824 | /* prepare and start sending a report IN |
| 821 | * not callable from ISR or locked state */ | 825 | * not callable from ISR or locked state */ |
| @@ -915,7 +919,9 @@ void send_mouse(report_mouse_t *report) { | |||
| 915 | } | 919 | } |
| 916 | 920 | ||
| 917 | #else /* MOUSE_ENABLE */ | 921 | #else /* MOUSE_ENABLE */ |
| 918 | void send_mouse(report_mouse_t *report) { (void)report; } | 922 | void send_mouse(report_mouse_t *report) { |
| 923 | (void)report; | ||
| 924 | } | ||
| 919 | #endif /* MOUSE_ENABLE */ | 925 | #endif /* MOUSE_ENABLE */ |
| 920 | 926 | ||
| 921 | /* --------------------------------------------------------- | 927 | /* --------------------------------------------------------- |
| @@ -1107,7 +1113,9 @@ void raw_hid_task(void) { | |||
| 1107 | 1113 | ||
| 1108 | #ifdef MIDI_ENABLE | 1114 | #ifdef MIDI_ENABLE |
| 1109 | 1115 | ||
| 1110 | void send_midi_packet(MIDI_EventPacket_t *event) { chnWrite(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t)); } | 1116 | void send_midi_packet(MIDI_EventPacket_t *event) { |
| 1117 | chnWrite(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t)); | ||
| 1118 | } | ||
| 1111 | 1119 | ||
| 1112 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { | 1120 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { |
| 1113 | size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE); | 1121 | size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE); |
| @@ -1130,7 +1138,9 @@ void midi_ep_task(void) { | |||
| 1130 | 1138 | ||
| 1131 | void virtser_init(void) {} | 1139 | void virtser_init(void) {} |
| 1132 | 1140 | ||
| 1133 | void virtser_send(const uint8_t byte) { chnWrite(&drivers.serial_driver.driver, &byte, 1); } | 1141 | void virtser_send(const uint8_t byte) { |
| 1142 | chnWrite(&drivers.serial_driver.driver, &byte, 1); | ||
| 1143 | } | ||
| 1134 | 1144 | ||
| 1135 | __attribute__((weak)) void virtser_recv(uint8_t c) { | 1145 | __attribute__((weak)) void virtser_recv(uint8_t c) { |
| 1136 | // Ignore by default | 1146 | // Ignore by default |
| @@ -1174,7 +1184,7 @@ void send_joystick_packet(joystick_t *joystick) { | |||
| 1174 | joystick->axes[5], | 1184 | joystick->axes[5], |
| 1175 | # endif | 1185 | # endif |
| 1176 | }, | 1186 | }, |
| 1177 | # endif // JOYSTICK_AXES_COUNT>0 | 1187 | # endif // JOYSTICK_AXES_COUNT>0 |
| 1178 | 1188 | ||
| 1179 | # if JOYSTICK_BUTTON_COUNT > 0 | 1189 | # if JOYSTICK_BUTTON_COUNT > 0 |
| 1180 | .buttons = { | 1190 | .buttons = { |
| @@ -1190,7 +1200,7 @@ void send_joystick_packet(joystick_t *joystick) { | |||
| 1190 | joystick->buttons[3], | 1200 | joystick->buttons[3], |
| 1191 | # endif | 1201 | # endif |
| 1192 | } | 1202 | } |
| 1193 | # endif // JOYSTICK_BUTTON_COUNT>0 | 1203 | # endif // JOYSTICK_BUTTON_COUNT>0 |
| 1194 | }; | 1204 | }; |
| 1195 | 1205 | ||
| 1196 | // chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep)); | 1206 | // chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep)); |
diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c index e32d6ebfa4..c8b435db0c 100644 --- a/tmk_core/protocol/chibios/usb_util.c +++ b/tmk_core/protocol/chibios/usb_util.c | |||
| @@ -16,6 +16,10 @@ | |||
| 16 | #include <hal.h> | 16 | #include <hal.h> |
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | void usb_disconnect(void) { usbStop(&USBD1); } | 19 | void usb_disconnect(void) { |
| 20 | usbStop(&USBD1); | ||
| 21 | } | ||
| 20 | 22 | ||
| 21 | bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } | 23 | bool usb_connected_state(void) { |
| 24 | return usbGetDriverStateI(&USBD1) == USB_ACTIVE; | ||
| 25 | } | ||
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 56d4bb0847..053d2b79e3 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c | |||
| @@ -34,13 +34,19 @@ static uint16_t last_system_report = 0; | |||
| 34 | static uint16_t last_consumer_report = 0; | 34 | static uint16_t last_consumer_report = 0; |
| 35 | static uint32_t last_programmable_button_report = 0; | 35 | static uint32_t last_programmable_button_report = 0; |
| 36 | 36 | ||
| 37 | void host_set_driver(host_driver_t *d) { driver = d; } | 37 | void host_set_driver(host_driver_t *d) { |
| 38 | driver = d; | ||
| 39 | } | ||
| 38 | 40 | ||
| 39 | host_driver_t *host_get_driver(void) { return driver; } | 41 | host_driver_t *host_get_driver(void) { |
| 42 | return driver; | ||
| 43 | } | ||
| 40 | 44 | ||
| 41 | #ifdef SPLIT_KEYBOARD | 45 | #ifdef SPLIT_KEYBOARD |
| 42 | uint8_t split_led_state = 0; | 46 | uint8_t split_led_state = 0; |
| 43 | void set_split_host_keyboard_leds(uint8_t led_state) { split_led_state = led_state; } | 47 | void set_split_host_keyboard_leds(uint8_t led_state) { |
| 48 | split_led_state = led_state; | ||
| 49 | } | ||
| 44 | #endif | 50 | #endif |
| 45 | 51 | ||
| 46 | uint8_t host_keyboard_leds(void) { | 52 | uint8_t host_keyboard_leds(void) { |
| @@ -51,7 +57,9 @@ uint8_t host_keyboard_leds(void) { | |||
| 51 | return (*driver->keyboard_leds)(); | 57 | return (*driver->keyboard_leds)(); |
| 52 | } | 58 | } |
| 53 | 59 | ||
| 54 | led_t host_keyboard_led_state(void) { return (led_t)host_keyboard_leds(); } | 60 | led_t host_keyboard_led_state(void) { |
| 61 | return (led_t)host_keyboard_leds(); | ||
| 62 | } | ||
| 55 | 63 | ||
| 56 | /* send report */ | 64 | /* send report */ |
| 57 | void host_keyboard_send(report_keyboard_t *report) { | 65 | void host_keyboard_send(report_keyboard_t *report) { |
| @@ -131,8 +139,14 @@ void host_programmable_button_send(uint32_t report) { | |||
| 131 | (*driver->send_programmable_button)(report); | 139 | (*driver->send_programmable_button)(report); |
| 132 | } | 140 | } |
| 133 | 141 | ||
| 134 | uint16_t host_last_system_report(void) { return last_system_report; } | 142 | uint16_t host_last_system_report(void) { |
| 143 | return last_system_report; | ||
| 144 | } | ||
| 135 | 145 | ||
| 136 | uint16_t host_last_consumer_report(void) { return last_consumer_report; } | 146 | uint16_t host_last_consumer_report(void) { |
| 147 | return last_consumer_report; | ||
| 148 | } | ||
| 137 | 149 | ||
| 138 | uint32_t host_last_programmable_button_report(void) { return last_programmable_button_report; } | 150 | uint32_t host_last_programmable_button_report(void) { |
| 151 | return last_programmable_button_report; | ||
| 152 | } | ||
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 3943f8c92b..b4b03357a3 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -256,7 +256,8 @@ static void Console_Task(void) { | |||
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | // fill empty bank | 258 | // fill empty bank |
| 259 | while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); | 259 | while (Endpoint_IsReadWriteAllowed()) |
| 260 | Endpoint_Write_8(0); | ||
| 260 | 261 | ||
| 261 | // flush sendchar packet | 262 | // flush sendchar packet |
| 262 | if (Endpoint_IsINReady()) { | 263 | if (Endpoint_IsINReady()) { |
| @@ -296,7 +297,7 @@ void send_joystick_packet(joystick_t *joystick) { | |||
| 296 | joystick->axes[5], | 297 | joystick->axes[5], |
| 297 | # endif | 298 | # endif |
| 298 | }, | 299 | }, |
| 299 | # endif // JOYSTICK_AXES_COUNT>0 | 300 | # endif // JOYSTICK_AXES_COUNT>0 |
| 300 | 301 | ||
| 301 | # if JOYSTICK_BUTTON_COUNT > 0 | 302 | # if JOYSTICK_BUTTON_COUNT > 0 |
| 302 | .buttons = { | 303 | .buttons = { |
| @@ -312,14 +313,15 @@ void send_joystick_packet(joystick_t *joystick) { | |||
| 312 | joystick->buttons[3], | 313 | joystick->buttons[3], |
| 313 | # endif | 314 | # endif |
| 314 | } | 315 | } |
| 315 | # endif // JOYSTICK_BUTTON_COUNT>0 | 316 | # endif // JOYSTICK_BUTTON_COUNT>0 |
| 316 | }; | 317 | }; |
| 317 | 318 | ||
| 318 | /* Select the Joystick Report Endpoint */ | 319 | /* Select the Joystick Report Endpoint */ |
| 319 | Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM); | 320 | Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM); |
| 320 | 321 | ||
| 321 | /* Check if write ready for a polling interval around 10ms */ | 322 | /* Check if write ready for a polling interval around 10ms */ |
| 322 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 323 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 324 | _delay_us(40); | ||
| 323 | if (!Endpoint_IsReadWriteAllowed()) return; | 325 | if (!Endpoint_IsReadWriteAllowed()) return; |
| 324 | 326 | ||
| 325 | /* Write Joystick Report Data */ | 327 | /* Write Joystick Report Data */ |
| @@ -414,9 +416,11 @@ void EVENT_USB_Device_WakeUp() { | |||
| 414 | 416 | ||
| 415 | #ifdef CONSOLE_ENABLE | 417 | #ifdef CONSOLE_ENABLE |
| 416 | static bool console_flush = false; | 418 | static bool console_flush = false; |
| 417 | # define CONSOLE_FLUSH_SET(b) \ | 419 | # define CONSOLE_FLUSH_SET(b) \ |
| 418 | do { \ | 420 | do { \ |
| 419 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { console_flush = b; } \ | 421 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { \ |
| 422 | console_flush = b; \ | ||
| 423 | } \ | ||
| 420 | } while (0) | 424 | } while (0) |
| 421 | 425 | ||
| 422 | /** \brief Event USB Device Start Of Frame | 426 | /** \brief Event USB Device Start Of Frame |
| @@ -634,7 +638,9 @@ void EVENT_USB_Device_ControlRequest(void) { | |||
| 634 | * | 638 | * |
| 635 | * FIXME: Needs doc | 639 | * FIXME: Needs doc |
| 636 | */ | 640 | */ |
| 637 | static uint8_t keyboard_leds(void) { return keyboard_led_state; } | 641 | static uint8_t keyboard_leds(void) { |
| 642 | return keyboard_led_state; | ||
| 643 | } | ||
| 638 | 644 | ||
| 639 | /** \brief Send Keyboard | 645 | /** \brief Send Keyboard |
| 640 | * | 646 | * |
| @@ -665,7 +671,8 @@ static void send_keyboard(report_keyboard_t *report) { | |||
| 665 | #endif | 671 | #endif |
| 666 | Endpoint_SelectEndpoint(ep); | 672 | Endpoint_SelectEndpoint(ep); |
| 667 | /* Check if write ready for a polling interval around 10ms */ | 673 | /* Check if write ready for a polling interval around 10ms */ |
| 668 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 674 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 675 | _delay_us(40); | ||
| 669 | if (!Endpoint_IsReadWriteAllowed()) return; | 676 | if (!Endpoint_IsReadWriteAllowed()) return; |
| 670 | 677 | ||
| 671 | /* If we're in Boot Protocol, don't send any report ID or other funky fields */ | 678 | /* If we're in Boot Protocol, don't send any report ID or other funky fields */ |
| @@ -705,7 +712,8 @@ static void send_mouse(report_mouse_t *report) { | |||
| 705 | Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); | 712 | Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); |
| 706 | 713 | ||
| 707 | /* Check if write ready for a polling interval around 10ms */ | 714 | /* Check if write ready for a polling interval around 10ms */ |
| 708 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 715 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 716 | _delay_us(40); | ||
| 709 | if (!Endpoint_IsReadWriteAllowed()) return; | 717 | if (!Endpoint_IsReadWriteAllowed()) return; |
| 710 | 718 | ||
| 711 | /* Write Mouse Report Data */ | 719 | /* Write Mouse Report Data */ |
| @@ -725,7 +733,8 @@ static void send_report(void *report, size_t size) { | |||
| 725 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); | 733 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); |
| 726 | 734 | ||
| 727 | /* Check if write ready for a polling interval around 10ms */ | 735 | /* Check if write ready for a polling interval around 10ms */ |
| 728 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 736 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 737 | _delay_us(40); | ||
| 729 | if (!Endpoint_IsReadWriteAllowed()) return; | 738 | if (!Endpoint_IsReadWriteAllowed()) return; |
| 730 | 739 | ||
| 731 | Endpoint_Write_Stream_LE(report, size, NULL); | 740 | Endpoint_Write_Stream_LE(report, size, NULL); |
| @@ -876,9 +885,13 @@ USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { | |||
| 876 | 885 | ||
| 877 | // clang-format on | 886 | // clang-format on |
| 878 | 887 | ||
| 879 | void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } | 888 | void send_midi_packet(MIDI_EventPacket_t *event) { |
| 889 | MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); | ||
| 890 | } | ||
| 880 | 891 | ||
| 881 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } | 892 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { |
| 893 | return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); | ||
| 894 | } | ||
| 882 | 895 | ||
| 883 | #endif | 896 | #endif |
| 884 | 897 | ||
| @@ -934,7 +947,8 @@ void virtser_send(const uint8_t byte) { | |||
| 934 | return; | 947 | return; |
| 935 | } | 948 | } |
| 936 | 949 | ||
| 937 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 950 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 951 | _delay_us(40); | ||
| 938 | 952 | ||
| 939 | Endpoint_Write_8(byte); | 953 | Endpoint_Write_8(byte); |
| 940 | CDC_Device_Flush(&cdc_device); | 954 | CDC_Device_Flush(&cdc_device); |
| @@ -957,7 +971,8 @@ void send_digitizer(report_digitizer_t *report) { | |||
| 957 | Endpoint_SelectEndpoint(DIGITIZER_IN_EPNUM); | 971 | Endpoint_SelectEndpoint(DIGITIZER_IN_EPNUM); |
| 958 | 972 | ||
| 959 | /* Check if write ready for a polling interval around 10ms */ | 973 | /* Check if write ready for a polling interval around 10ms */ |
| 960 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | 974 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) |
| 975 | _delay_us(40); | ||
| 961 | if (!Endpoint_IsReadWriteAllowed()) return; | 976 | if (!Endpoint_IsReadWriteAllowed()) return; |
| 962 | 977 | ||
| 963 | Endpoint_Write_Stream_LE(report, sizeof(report_digitizer_t), NULL); | 978 | Endpoint_Write_Stream_LE(report, sizeof(report_digitizer_t), NULL); |
| @@ -1033,7 +1048,9 @@ void protocol_pre_init(void) { | |||
| 1033 | #endif | 1048 | #endif |
| 1034 | } | 1049 | } |
| 1035 | 1050 | ||
| 1036 | void protocol_post_init(void) { host_set_driver(&lufa_driver); } | 1051 | void protocol_post_init(void) { |
| 1052 | host_set_driver(&lufa_driver); | ||
| 1053 | } | ||
| 1037 | 1054 | ||
| 1038 | void protocol_pre_task(void) { | 1055 | void protocol_pre_task(void) { |
| 1039 | #if !defined(NO_USB_STARTUP_CHECK) | 1056 | #if !defined(NO_USB_STARTUP_CHECK) |
| @@ -1084,4 +1101,6 @@ void protocol_post_task(void) { | |||
| 1084 | #endif | 1101 | #endif |
| 1085 | } | 1102 | } |
| 1086 | 1103 | ||
| 1087 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { return get_usb_descriptor(wValue, wIndex, DescriptorAddress); } | 1104 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { |
| 1105 | return get_usb_descriptor(wValue, wIndex, DescriptorAddress); | ||
| 1106 | } | ||
diff --git a/tmk_core/protocol/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c index 9691eff1e4..2e3b86b80e 100644 --- a/tmk_core/protocol/lufa/usb_util.c +++ b/tmk_core/protocol/lufa/usb_util.c | |||
| @@ -22,13 +22,15 @@ void usb_disconnect(void) { | |||
| 22 | USB_DeviceState = DEVICE_STATE_Unattached; | 22 | USB_DeviceState = DEVICE_STATE_Unattached; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | bool usb_connected_state(void) { return USB_Device_IsAddressSet(); } | 25 | bool usb_connected_state(void) { |
| 26 | return USB_Device_IsAddressSet(); | ||
| 27 | } | ||
| 26 | 28 | ||
| 27 | #if defined(OTGPADE) | 29 | #if defined(OTGPADE) |
| 28 | bool usb_vbus_state(void) { | 30 | bool usb_vbus_state(void) { |
| 29 | USB_OTGPAD_On(); // enables VBUS pad | 31 | USB_OTGPAD_On(); // enables VBUS pad |
| 30 | wait_us(5); | 32 | wait_us(5); |
| 31 | 33 | ||
| 32 | return USB_VBUS_GetStatus(); // checks state of VBUS | 34 | return USB_VBUS_GetStatus(); // checks state of VBUS |
| 33 | } | 35 | } |
| 34 | #endif | 36 | #endif |
diff --git a/tmk_core/protocol/midi/bytequeue/bytequeue.c b/tmk_core/protocol/midi/bytequeue/bytequeue.c index e36a9e66b1..0dd18680f0 100644 --- a/tmk_core/protocol/midi/bytequeue/bytequeue.c +++ b/tmk_core/protocol/midi/bytequeue/bytequeue.c | |||
| @@ -52,7 +52,9 @@ byteQueueIndex_t bytequeue_length(byteQueue_t* queue) { | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | // we don't need to avoid interrupts if there is only one reader | 54 | // we don't need to avoid interrupts if there is only one reader |
| 55 | uint8_t bytequeue_get(byteQueue_t* queue, byteQueueIndex_t index) { return queue->data[(queue->start + index) % queue->length]; } | 55 | uint8_t bytequeue_get(byteQueue_t* queue, byteQueueIndex_t index) { |
| 56 | return queue->data[(queue->start + index) % queue->length]; | ||
| 57 | } | ||
| 56 | 58 | ||
| 57 | // we just update the start index to remove elements | 59 | // we just update the start index to remove elements |
| 58 | void bytequeue_remove(byteQueue_t* queue, byteQueueIndex_t numToRemove) { | 60 | void bytequeue_remove(byteQueue_t* queue, byteQueueIndex_t numToRemove) { |
diff --git a/tmk_core/protocol/midi/bytequeue/interrupt_setting.c b/tmk_core/protocol/midi/bytequeue/interrupt_setting.c index 407cc65f49..d9c0035946 100644 --- a/tmk_core/protocol/midi/bytequeue/interrupt_setting.c +++ b/tmk_core/protocol/midi/bytequeue/interrupt_setting.c | |||
| @@ -30,7 +30,9 @@ interrupt_setting_t store_and_clear_interrupt(void) { | |||
| 30 | return sreg; | 30 | return sreg; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void restore_interrupt_setting(interrupt_setting_t setting) { SREG = setting; } | 33 | void restore_interrupt_setting(interrupt_setting_t setting) { |
| 34 | SREG = setting; | ||
| 35 | } | ||
| 34 | #elif defined(__arm__) | 36 | #elif defined(__arm__) |
| 35 | # include <ch.h> | 37 | # include <ch.h> |
| 36 | 38 | ||
| @@ -39,5 +41,7 @@ interrupt_setting_t store_and_clear_interrupt(void) { | |||
| 39 | return 0; | 41 | return 0; |
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | void restore_interrupt_setting(interrupt_setting_t setting) { chSysUnlock(); } | 44 | void restore_interrupt_setting(interrupt_setting_t setting) { |
| 45 | chSysUnlock(); | ||
| 46 | } | ||
| 43 | #endif | 47 | #endif |
diff --git a/tmk_core/protocol/midi/midi.c b/tmk_core/protocol/midi/midi.c index 643c43722d..f3792552f4 100644 --- a/tmk_core/protocol/midi/midi.c +++ b/tmk_core/protocol/midi/midi.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | // along with avr-midi. If not, see <http://www.gnu.org/licenses/>. | 17 | // along with avr-midi. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | ||
| 19 | #include "midi.h" | 19 | #include "midi.h" |
| 20 | #include <string.h> //for memcpy | 20 | #include <string.h> //for memcpy |
| 21 | 21 | ||
| 22 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) | 22 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) |
| 23 | 23 | ||
| @@ -25,9 +25,13 @@ | |||
| 25 | # define NULL 0 | 25 | # define NULL 0 |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | bool midi_is_statusbyte(uint8_t theByte) { return (bool)(theByte & MIDI_STATUSMASK); } | 28 | bool midi_is_statusbyte(uint8_t theByte) { |
| 29 | return (bool)(theByte & MIDI_STATUSMASK); | ||
| 30 | } | ||
| 29 | 31 | ||
| 30 | bool midi_is_realtime(uint8_t theByte) { return (theByte >= MIDI_CLOCK); } | 32 | bool midi_is_realtime(uint8_t theByte) { |
| 33 | return (theByte >= MIDI_CLOCK); | ||
| 34 | } | ||
| 31 | 35 | ||
| 32 | midi_packet_length_t midi_packet_length(uint8_t status) { | 36 | midi_packet_length_t midi_packet_length(uint8_t status) { |
| 33 | switch (status & 0xF0) { | 37 | switch (status & 0xF0) { |
| @@ -83,7 +87,9 @@ void midi_send_noteoff(MidiDevice* device, uint8_t chan, uint8_t num, uint8_t ve | |||
| 83 | device->send_func(device, 3, MIDI_NOTEOFF | (chan & MIDI_CHANMASK), num & 0x7F, vel & 0x7F); | 87 | device->send_func(device, 3, MIDI_NOTEOFF | (chan & MIDI_CHANMASK), num & 0x7F, vel & 0x7F); |
| 84 | } | 88 | } |
| 85 | 89 | ||
| 86 | void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, uint8_t amt) { device->send_func(device, 3, MIDI_AFTERTOUCH | (chan & MIDI_CHANMASK), note_num & 0x7F, amt & 0x7F); } | 90 | void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, uint8_t amt) { |
| 91 | device->send_func(device, 3, MIDI_AFTERTOUCH | (chan & MIDI_CHANMASK), note_num & 0x7F, amt & 0x7F); | ||
| 92 | } | ||
| 87 | 93 | ||
| 88 | // XXX does this work right? | 94 | // XXX does this work right? |
| 89 | // amt in range -0x2000, 0x1fff | 95 | // amt in range -0x2000, 0x1fff |
| @@ -102,34 +108,62 @@ void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt) { | |||
| 102 | device->send_func(device, 3, MIDI_PITCHBEND | (chan & MIDI_CHANMASK), uAmt & 0x7F, (uAmt >> 7) & 0x7F); | 108 | device->send_func(device, 3, MIDI_PITCHBEND | (chan & MIDI_CHANMASK), uAmt & 0x7F, (uAmt >> 7) & 0x7F); |
| 103 | } | 109 | } |
| 104 | 110 | ||
| 105 | void midi_send_programchange(MidiDevice* device, uint8_t chan, uint8_t num) { device->send_func(device, 2, MIDI_PROGCHANGE | (chan & MIDI_CHANMASK), num & 0x7F, 0); } | 111 | void midi_send_programchange(MidiDevice* device, uint8_t chan, uint8_t num) { |
| 112 | device->send_func(device, 2, MIDI_PROGCHANGE | (chan & MIDI_CHANMASK), num & 0x7F, 0); | ||
| 113 | } | ||
| 106 | 114 | ||
| 107 | void midi_send_channelpressure(MidiDevice* device, uint8_t chan, uint8_t amt) { device->send_func(device, 2, MIDI_CHANPRESSURE | (chan & MIDI_CHANMASK), amt & 0x7F, 0); } | 115 | void midi_send_channelpressure(MidiDevice* device, uint8_t chan, uint8_t amt) { |
| 116 | device->send_func(device, 2, MIDI_CHANPRESSURE | (chan & MIDI_CHANMASK), amt & 0x7F, 0); | ||
| 117 | } | ||
| 108 | 118 | ||
| 109 | void midi_send_clock(MidiDevice* device) { device->send_func(device, 1, MIDI_CLOCK, 0, 0); } | 119 | void midi_send_clock(MidiDevice* device) { |
| 120 | device->send_func(device, 1, MIDI_CLOCK, 0, 0); | ||
| 121 | } | ||
| 110 | 122 | ||
| 111 | void midi_send_tick(MidiDevice* device) { device->send_func(device, 1, MIDI_TICK, 0, 0); } | 123 | void midi_send_tick(MidiDevice* device) { |
| 124 | device->send_func(device, 1, MIDI_TICK, 0, 0); | ||
| 125 | } | ||
| 112 | 126 | ||
| 113 | void midi_send_start(MidiDevice* device) { device->send_func(device, 1, MIDI_START, 0, 0); } | 127 | void midi_send_start(MidiDevice* device) { |
| 128 | device->send_func(device, 1, MIDI_START, 0, 0); | ||
| 129 | } | ||
| 114 | 130 | ||
| 115 | void midi_send_continue(MidiDevice* device) { device->send_func(device, 1, MIDI_CONTINUE, 0, 0); } | 131 | void midi_send_continue(MidiDevice* device) { |
| 132 | device->send_func(device, 1, MIDI_CONTINUE, 0, 0); | ||
| 133 | } | ||
| 116 | 134 | ||
| 117 | void midi_send_stop(MidiDevice* device) { device->send_func(device, 1, MIDI_STOP, 0, 0); } | 135 | void midi_send_stop(MidiDevice* device) { |
| 136 | device->send_func(device, 1, MIDI_STOP, 0, 0); | ||
| 137 | } | ||
| 118 | 138 | ||
| 119 | void midi_send_activesense(MidiDevice* device) { device->send_func(device, 1, MIDI_ACTIVESENSE, 0, 0); } | 139 | void midi_send_activesense(MidiDevice* device) { |
| 140 | device->send_func(device, 1, MIDI_ACTIVESENSE, 0, 0); | ||
| 141 | } | ||
| 120 | 142 | ||
| 121 | void midi_send_reset(MidiDevice* device) { device->send_func(device, 1, MIDI_RESET, 0, 0); } | 143 | void midi_send_reset(MidiDevice* device) { |
| 144 | device->send_func(device, 1, MIDI_RESET, 0, 0); | ||
| 145 | } | ||
| 122 | 146 | ||
| 123 | void midi_send_tcquarterframe(MidiDevice* device, uint8_t time) { device->send_func(device, 2, MIDI_TC_QUARTERFRAME, time & 0x7F, 0); } | 147 | void midi_send_tcquarterframe(MidiDevice* device, uint8_t time) { |
| 148 | device->send_func(device, 2, MIDI_TC_QUARTERFRAME, time & 0x7F, 0); | ||
| 149 | } | ||
| 124 | 150 | ||
| 125 | // XXX is this right? | 151 | // XXX is this right? |
| 126 | void midi_send_songposition(MidiDevice* device, uint16_t pos) { device->send_func(device, 3, MIDI_SONGPOSITION, pos & 0x7F, (pos >> 7) & 0x7F); } | 152 | void midi_send_songposition(MidiDevice* device, uint16_t pos) { |
| 153 | device->send_func(device, 3, MIDI_SONGPOSITION, pos & 0x7F, (pos >> 7) & 0x7F); | ||
| 154 | } | ||
| 127 | 155 | ||
| 128 | void midi_send_songselect(MidiDevice* device, uint8_t song) { device->send_func(device, 2, MIDI_SONGSELECT, song & 0x7F, 0); } | 156 | void midi_send_songselect(MidiDevice* device, uint8_t song) { |
| 157 | device->send_func(device, 2, MIDI_SONGSELECT, song & 0x7F, 0); | ||
| 158 | } | ||
| 129 | 159 | ||
| 130 | void midi_send_tunerequest(MidiDevice* device) { device->send_func(device, 1, MIDI_TUNEREQUEST, 0, 0); } | 160 | void midi_send_tunerequest(MidiDevice* device) { |
| 161 | device->send_func(device, 1, MIDI_TUNEREQUEST, 0, 0); | ||
| 162 | } | ||
| 131 | 163 | ||
| 132 | void midi_send_byte(MidiDevice* device, uint8_t b) { device->send_func(device, 1, b, 0, 0); } | 164 | void midi_send_byte(MidiDevice* device, uint8_t b) { |
| 165 | device->send_func(device, 1, b, 0, 0); | ||
| 166 | } | ||
| 133 | 167 | ||
| 134 | void midi_send_data(MidiDevice* device, uint16_t count, uint8_t byte0, uint8_t byte1, uint8_t byte2) { | 168 | void midi_send_data(MidiDevice* device, uint16_t count, uint8_t byte0, uint8_t byte1, uint8_t byte2) { |
| 135 | // ensure that the count passed along is always 3 or lower | 169 | // ensure that the count passed along is always 3 or lower |
| @@ -150,32 +184,62 @@ void midi_send_array(MidiDevice* device, uint16_t count, uint8_t* array) { | |||
| 150 | } | 184 | } |
| 151 | } | 185 | } |
| 152 | 186 | ||
| 153 | void midi_register_cc_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_cc_callback = func; } | 187 | void midi_register_cc_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 188 | device->input_cc_callback = func; | ||
| 189 | } | ||
| 154 | 190 | ||
| 155 | void midi_register_noteon_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_noteon_callback = func; } | 191 | void midi_register_noteon_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 192 | device->input_noteon_callback = func; | ||
| 193 | } | ||
| 156 | 194 | ||
| 157 | void midi_register_noteoff_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_noteoff_callback = func; } | 195 | void midi_register_noteoff_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 196 | device->input_noteoff_callback = func; | ||
| 197 | } | ||
| 158 | 198 | ||
| 159 | void midi_register_aftertouch_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_aftertouch_callback = func; } | 199 | void midi_register_aftertouch_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 200 | device->input_aftertouch_callback = func; | ||
| 201 | } | ||
| 160 | 202 | ||
| 161 | void midi_register_pitchbend_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_pitchbend_callback = func; } | 203 | void midi_register_pitchbend_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 204 | device->input_pitchbend_callback = func; | ||
| 205 | } | ||
| 162 | 206 | ||
| 163 | void midi_register_songposition_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_songposition_callback = func; } | 207 | void midi_register_songposition_callback(MidiDevice* device, midi_three_byte_func_t func) { |
| 208 | device->input_songposition_callback = func; | ||
| 209 | } | ||
| 164 | 210 | ||
| 165 | void midi_register_progchange_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_progchange_callback = func; } | 211 | void midi_register_progchange_callback(MidiDevice* device, midi_two_byte_func_t func) { |
| 212 | device->input_progchange_callback = func; | ||
| 213 | } | ||
| 166 | 214 | ||
| 167 | void midi_register_chanpressure_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_chanpressure_callback = func; } | 215 | void midi_register_chanpressure_callback(MidiDevice* device, midi_two_byte_func_t func) { |
| 216 | device->input_chanpressure_callback = func; | ||
| 217 | } | ||
| 168 | 218 | ||
| 169 | void midi_register_songselect_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_songselect_callback = func; } | 219 | void midi_register_songselect_callback(MidiDevice* device, midi_two_byte_func_t func) { |
| 220 | device->input_songselect_callback = func; | ||
| 221 | } | ||
| 170 | 222 | ||
| 171 | void midi_register_tc_quarterframe_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_tc_quarterframe_callback = func; } | 223 | void midi_register_tc_quarterframe_callback(MidiDevice* device, midi_two_byte_func_t func) { |
| 224 | device->input_tc_quarterframe_callback = func; | ||
| 225 | } | ||
| 172 | 226 | ||
| 173 | void midi_register_realtime_callback(MidiDevice* device, midi_one_byte_func_t func) { device->input_realtime_callback = func; } | 227 | void midi_register_realtime_callback(MidiDevice* device, midi_one_byte_func_t func) { |
| 228 | device->input_realtime_callback = func; | ||
| 229 | } | ||
| 174 | 230 | ||
| 175 | void midi_register_tunerequest_callback(MidiDevice* device, midi_one_byte_func_t func) { device->input_tunerequest_callback = func; } | 231 | void midi_register_tunerequest_callback(MidiDevice* device, midi_one_byte_func_t func) { |
| 232 | device->input_tunerequest_callback = func; | ||
| 233 | } | ||
| 176 | 234 | ||
| 177 | void midi_register_sysex_callback(MidiDevice* device, midi_sysex_func_t func) { device->input_sysex_callback = func; } | 235 | void midi_register_sysex_callback(MidiDevice* device, midi_sysex_func_t func) { |
| 236 | device->input_sysex_callback = func; | ||
| 237 | } | ||
| 178 | 238 | ||
| 179 | void midi_register_fallthrough_callback(MidiDevice* device, midi_var_byte_func_t func) { device->input_fallthrough_callback = func; } | 239 | void midi_register_fallthrough_callback(MidiDevice* device, midi_var_byte_func_t func) { |
| 240 | device->input_fallthrough_callback = func; | ||
| 241 | } | ||
| 180 | 242 | ||
| 181 | void midi_register_catchall_callback(MidiDevice* device, midi_var_byte_func_t func) { device->input_catchall_callback = func; } | 243 | void midi_register_catchall_callback(MidiDevice* device, midi_var_byte_func_t func) { |
| 244 | device->input_catchall_callback = func; | ||
| 245 | } | ||
diff --git a/tmk_core/protocol/midi/midi.h b/tmk_core/protocol/midi/midi.h index 75f3b13b0b..34547077e4 100644 --- a/tmk_core/protocol/midi/midi.h +++ b/tmk_core/protocol/midi/midi.h | |||
| @@ -48,7 +48,7 @@ extern "C" { | |||
| 48 | * | 48 | * |
| 49 | * @param device the device to initialize | 49 | * @param device the device to initialize |
| 50 | */ | 50 | */ |
| 51 | void midi_device_init(MidiDevice* device); // [implementation in midi_device.c] | 51 | void midi_device_init(MidiDevice* device); // [implementation in midi_device.c] |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * @brief Process input data | 54 | * @brief Process input data |
| @@ -58,7 +58,7 @@ void midi_device_init(MidiDevice* device); // [implementation in midi_device.c] | |||
| 58 | * | 58 | * |
| 59 | * @param device the device to process | 59 | * @param device the device to process |
| 60 | */ | 60 | */ |
| 61 | void midi_device_process(MidiDevice* device); // [implementation in midi_device.c] | 61 | void midi_device_process(MidiDevice* device); // [implementation in midi_device.c] |
| 62 | 62 | ||
| 63 | /**@}*/ | 63 | /**@}*/ |
| 64 | 64 | ||
| @@ -115,7 +115,7 @@ void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, ui | |||
| 115 | * @param chan the channel to send on, 0-15 | 115 | * @param chan the channel to send on, 0-15 |
| 116 | * @param amt the bend amount range: -8192..8191, 0 means no bend | 116 | * @param amt the bend amount range: -8192..8191, 0 means no bend |
| 117 | */ | 117 | */ |
| 118 | void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt); // range -8192, 8191 | 118 | void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt); // range -8192, 8191 |
| 119 | 119 | ||
| 120 | /** | 120 | /** |
| 121 | * @brief Send a program change message via the given device. | 121 | * @brief Send a program change message via the given device. |
diff --git a/tmk_core/protocol/midi/midi_device.c b/tmk_core/protocol/midi/midi_device.c index 58fe685e2d..77c010b156 100644 --- a/tmk_core/protocol/midi/midi_device.c +++ b/tmk_core/protocol/midi/midi_device.c | |||
| @@ -60,12 +60,17 @@ void midi_device_init(MidiDevice* device) { | |||
| 60 | 60 | ||
| 61 | void midi_device_input(MidiDevice* device, uint8_t cnt, uint8_t* input) { | 61 | void midi_device_input(MidiDevice* device, uint8_t cnt, uint8_t* input) { |
| 62 | uint8_t i; | 62 | uint8_t i; |
| 63 | for (i = 0; i < cnt; i++) bytequeue_enqueue(&device->input_queue, input[i]); | 63 | for (i = 0; i < cnt; i++) |
| 64 | bytequeue_enqueue(&device->input_queue, input[i]); | ||
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | void midi_device_set_send_func(MidiDevice* device, midi_var_byte_func_t send_func) { device->send_func = send_func; } | 67 | void midi_device_set_send_func(MidiDevice* device, midi_var_byte_func_t send_func) { |
| 68 | device->send_func = send_func; | ||
| 69 | } | ||
| 67 | 70 | ||
| 68 | void midi_device_set_pre_input_process_func(MidiDevice* device, midi_no_byte_func_t pre_process_func) { device->pre_input_process_callback = pre_process_func; } | 71 | void midi_device_set_pre_input_process_func(MidiDevice* device, midi_no_byte_func_t pre_process_func) { |
| 72 | device->pre_input_process_callback = pre_process_func; | ||
| 73 | } | ||
| 69 | 74 | ||
| 70 | void midi_device_process(MidiDevice* device) { | 75 | void midi_device_process(MidiDevice* device) { |
| 71 | // call the pre_input_process_callback if there is one | 76 | // call the pre_input_process_callback if there is one |
diff --git a/tmk_core/protocol/midi/qmk_midi.c b/tmk_core/protocol/midi/qmk_midi.c index 3a454d61ae..f6a5d92281 100644 --- a/tmk_core/protocol/midi/qmk_midi.c +++ b/tmk_core/protocol/midi/qmk_midi.c | |||
| @@ -50,7 +50,7 @@ static void usb_send_func(MidiDevice* device, uint16_t cnt, uint8_t byte0, uint8 | |||
| 50 | event.Event = MIDI_EVENT(cable, SYSEX_START_OR_CONT); | 50 | event.Event = MIDI_EVENT(cable, SYSEX_START_OR_CONT); |
| 51 | break; | 51 | break; |
| 52 | default: | 52 | default: |
| 53 | return; // invalid cnt | 53 | return; // invalid cnt |
| 54 | } | 54 | } |
| 55 | } else { | 55 | } else { |
| 56 | // deal with 'system common' messages | 56 | // deal with 'system common' messages |
diff --git a/tmk_core/protocol/midi/sysex_tools.c b/tmk_core/protocol/midi/sysex_tools.c index 84bca72158..c9a9d03285 100644 --- a/tmk_core/protocol/midi/sysex_tools.c +++ b/tmk_core/protocol/midi/sysex_tools.c | |||
| @@ -35,7 +35,7 @@ uint16_t sysex_decoded_length(uint16_t encoded_length) { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | uint16_t sysex_encode(uint8_t *encoded, const uint8_t *source, const uint16_t length) { | 37 | uint16_t sysex_encode(uint8_t *encoded, const uint8_t *source, const uint16_t length) { |
| 38 | uint16_t encoded_full = length / 7; // number of full 8 byte sections from 7 bytes of input | 38 | uint16_t encoded_full = length / 7; // number of full 8 byte sections from 7 bytes of input |
| 39 | uint16_t i, j; | 39 | uint16_t i, j; |
| 40 | 40 | ||
| 41 | // fill out the fully encoded sections | 41 | // fill out the fully encoded sections |
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 0f0c78f66c..6c3424145c 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h | |||
| @@ -200,7 +200,7 @@ enum usb_interfaces { | |||
| 200 | * Endpoint numbers | 200 | * Endpoint numbers |
| 201 | */ | 201 | */ |
| 202 | enum usb_endpoints { | 202 | enum usb_endpoints { |
| 203 | __unused_epnum__ = NEXT_EPNUM, // Endpoint numbering starts at 1 | 203 | __unused_epnum__ = NEXT_EPNUM, // Endpoint numbering starts at 1 |
| 204 | 204 | ||
| 205 | #ifndef KEYBOARD_SHARED_EP | 205 | #ifndef KEYBOARD_SHARED_EP |
| 206 | KEYBOARD_IN_EPNUM = NEXT_EPNUM, | 206 | KEYBOARD_IN_EPNUM = NEXT_EPNUM, |
diff --git a/tmk_core/protocol/usb_device_state.c b/tmk_core/protocol/usb_device_state.c index 84f01943be..8d56ba4d2f 100644 --- a/tmk_core/protocol/usb_device_state.c +++ b/tmk_core/protocol/usb_device_state.c | |||
| @@ -22,7 +22,9 @@ | |||
| 22 | 22 | ||
| 23 | enum usb_device_state usb_device_state = USB_DEVICE_STATE_NO_INIT; | 23 | enum usb_device_state usb_device_state = USB_DEVICE_STATE_NO_INIT; |
| 24 | 24 | ||
| 25 | __attribute__((weak)) void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state) { notify_usb_device_state_change_user(usb_device_state); } | 25 | __attribute__((weak)) void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state) { |
| 26 | notify_usb_device_state_change_user(usb_device_state); | ||
| 27 | } | ||
| 26 | 28 | ||
| 27 | __attribute__((weak)) void notify_usb_device_state_change_user(enum usb_device_state usb_device_state) {} | 29 | __attribute__((weak)) void notify_usb_device_state_change_user(enum usb_device_state usb_device_state) {} |
| 28 | 30 | ||
diff --git a/tmk_core/protocol/usb_device_state.h b/tmk_core/protocol/usb_device_state.h index c229311d46..3be65ea7e1 100644 --- a/tmk_core/protocol/usb_device_state.h +++ b/tmk_core/protocol/usb_device_state.h | |||
| @@ -27,10 +27,10 @@ void usb_device_state_set_reset(void); | |||
| 27 | void usb_device_state_init(void); | 27 | void usb_device_state_init(void); |
| 28 | 28 | ||
| 29 | enum usb_device_state { | 29 | enum usb_device_state { |
| 30 | USB_DEVICE_STATE_NO_INIT = 0, // We're in this state before calling usb_device_state_init() | 30 | USB_DEVICE_STATE_NO_INIT = 0, // We're in this state before calling usb_device_state_init() |
| 31 | USB_DEVICE_STATE_INIT = 1, // Can consume up to 100mA | 31 | USB_DEVICE_STATE_INIT = 1, // Can consume up to 100mA |
| 32 | USB_DEVICE_STATE_CONFIGURED = 2, // Can consume up to what is specified in configuration descriptor, typically 500mA | 32 | USB_DEVICE_STATE_CONFIGURED = 2, // Can consume up to what is specified in configuration descriptor, typically 500mA |
| 33 | USB_DEVICE_STATE_SUSPEND = 3 // Can consume only suspend current | 33 | USB_DEVICE_STATE_SUSPEND = 3 // Can consume only suspend current |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | extern enum usb_device_state usb_device_state; | 36 | extern enum usb_device_state usb_device_state; |
diff --git a/tmk_core/protocol/usb_util.c b/tmk_core/protocol/usb_util.c index dd1deeaa11..49aadedc2a 100644 --- a/tmk_core/protocol/usb_util.c +++ b/tmk_core/protocol/usb_util.c | |||
| @@ -17,7 +17,9 @@ | |||
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | __attribute__((weak)) void usb_disconnect(void) {} | 19 | __attribute__((weak)) void usb_disconnect(void) {} |
| 20 | __attribute__((weak)) bool usb_connected_state(void) { return true; } | 20 | __attribute__((weak)) bool usb_connected_state(void) { |
| 21 | return true; | ||
| 22 | } | ||
| 21 | __attribute__((weak)) bool usb_vbus_state(void) { | 23 | __attribute__((weak)) bool usb_vbus_state(void) { |
| 22 | #ifdef USB_VBUS_PIN | 24 | #ifdef USB_VBUS_PIN |
| 23 | setPinInput(USB_VBUS_PIN); | 25 | setPinInput(USB_VBUS_PIN); |
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c index 644e77e021..20d0530483 100644 --- a/tmk_core/protocol/vusb/protocol.c +++ b/tmk_core/protocol/vusb/protocol.c | |||
| @@ -97,7 +97,9 @@ static void vusb_wakeup(void) { | |||
| 97 | * | 97 | * |
| 98 | * FIXME: Needs doc | 98 | * FIXME: Needs doc |
| 99 | */ | 99 | */ |
| 100 | static void setup_usb(void) { initForUsbConnectivity(); } | 100 | static void setup_usb(void) { |
| 101 | initForUsbConnectivity(); | ||
| 102 | } | ||
| 101 | 103 | ||
| 102 | uint16_t sof_timer = 0; | 104 | uint16_t sof_timer = 0; |
| 103 | 105 | ||
diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c index 4ee2d3188b..38c4352d55 100644 --- a/tmk_core/protocol/vusb/usb_util.c +++ b/tmk_core/protocol/vusb/usb_util.c | |||
| @@ -16,7 +16,9 @@ | |||
| 16 | #include <usbdrv/usbdrv.h> | 16 | #include <usbdrv/usbdrv.h> |
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | void usb_disconnect(void) { usbDeviceDisconnect(); } | 19 | void usb_disconnect(void) { |
| 20 | usbDeviceDisconnect(); | ||
| 21 | } | ||
| 20 | 22 | ||
| 21 | bool usb_connected_state(void) { | 23 | bool usb_connected_state(void) { |
| 22 | usbPoll(); | 24 | usbPoll(); |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 8bdcccc9c9..ebde955d3b 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -230,9 +230,13 @@ static void send_programmable_button(uint32_t data); | |||
| 230 | 230 | ||
| 231 | static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button}; | 231 | static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button}; |
| 232 | 232 | ||
| 233 | host_driver_t *vusb_driver(void) { return &driver; } | 233 | host_driver_t *vusb_driver(void) { |
| 234 | return &driver; | ||
| 235 | } | ||
| 234 | 236 | ||
| 235 | static uint8_t keyboard_leds(void) { return keyboard_led_state; } | 237 | static uint8_t keyboard_leds(void) { |
| 238 | return keyboard_led_state; | ||
| 239 | } | ||
| 236 | 240 | ||
| 237 | static void send_keyboard(report_keyboard_t *report) { | 241 | static void send_keyboard(report_keyboard_t *report) { |
| 238 | uint8_t next = (kbuf_head + 1) % KBUF_SIZE; | 242 | uint8_t next = (kbuf_head + 1) % KBUF_SIZE; |
| @@ -348,7 +352,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
| 348 | last_req.kind = SET_LED; | 352 | last_req.kind = SET_LED; |
| 349 | last_req.len = rq->wLength.word; | 353 | last_req.len = rq->wLength.word; |
| 350 | } | 354 | } |
| 351 | return USB_NO_MSG; // to get data in usbFunctionWrite | 355 | return USB_NO_MSG; // to get data in usbFunctionWrite |
| 352 | } else { | 356 | } else { |
| 353 | dprint("UNKNOWN:"); | 357 | dprint("UNKNOWN:"); |
| 354 | } | 358 | } |
| @@ -410,47 +414,47 @@ const PROGMEM uchar shared_hid_report[] = { | |||
| 410 | #else | 414 | #else |
| 411 | const PROGMEM uchar keyboard_hid_report[] = { | 415 | const PROGMEM uchar keyboard_hid_report[] = { |
| 412 | #endif | 416 | #endif |
| 413 | 0x05, 0x01, // Usage Page (Generic Desktop) | 417 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 414 | 0x09, 0x06, // Usage (Keyboard) | 418 | 0x09, 0x06, // Usage (Keyboard) |
| 415 | 0xA1, 0x01, // Collection (Application) | 419 | 0xA1, 0x01, // Collection (Application) |
| 416 | #ifdef KEYBOARD_SHARED_EP | 420 | #ifdef KEYBOARD_SHARED_EP |
| 417 | 0x85, REPORT_ID_KEYBOARD, // Report ID | 421 | 0x85, REPORT_ID_KEYBOARD, // Report ID |
| 418 | #endif | 422 | #endif |
| 419 | // Modifiers (8 bits) | 423 | // Modifiers (8 bits) |
| 420 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) | 424 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) |
| 421 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) | 425 | 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) |
| 422 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) | 426 | 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) |
| 423 | 0x15, 0x00, // Logical Minimum (0) | 427 | 0x15, 0x00, // Logical Minimum (0) |
| 424 | 0x25, 0x01, // Logical Maximum (1) | 428 | 0x25, 0x01, // Logical Maximum (1) |
| 425 | 0x95, 0x08, // Report Count (8) | 429 | 0x95, 0x08, // Report Count (8) |
| 426 | 0x75, 0x01, // Report Size (1) | 430 | 0x75, 0x01, // Report Size (1) |
| 427 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 431 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 428 | // Reserved (1 byte) | 432 | // Reserved (1 byte) |
| 429 | 0x95, 0x01, // Report Count (1) | 433 | 0x95, 0x01, // Report Count (1) |
| 430 | 0x75, 0x08, // Report Size (8) | 434 | 0x75, 0x08, // Report Size (8) |
| 431 | 0x81, 0x03, // Input (Constant) | 435 | 0x81, 0x03, // Input (Constant) |
| 432 | // Keycodes (6 bytes) | 436 | // Keycodes (6 bytes) |
| 433 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) | 437 | 0x05, 0x07, // Usage Page (Keyboard/Keypad) |
| 434 | 0x19, 0x00, // Usage Minimum (0) | 438 | 0x19, 0x00, // Usage Minimum (0) |
| 435 | 0x29, 0xFF, // Usage Maximum (255) | 439 | 0x29, 0xFF, // Usage Maximum (255) |
| 436 | 0x15, 0x00, // Logical Minimum (0) | 440 | 0x15, 0x00, // Logical Minimum (0) |
| 437 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | 441 | 0x26, 0xFF, 0x00, // Logical Maximum (255) |
| 438 | 0x95, 0x06, // Report Count (6) | 442 | 0x95, 0x06, // Report Count (6) |
| 439 | 0x75, 0x08, // Report Size (8) | 443 | 0x75, 0x08, // Report Size (8) |
| 440 | 0x81, 0x00, // Input (Data, Array, Absolute) | 444 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| 441 | 445 | ||
| 442 | // Status LEDs (5 bits) | 446 | // Status LEDs (5 bits) |
| 443 | 0x05, 0x08, // Usage Page (LED) | 447 | 0x05, 0x08, // Usage Page (LED) |
| 444 | 0x19, 0x01, // Usage Minimum (Num Lock) | 448 | 0x19, 0x01, // Usage Minimum (Num Lock) |
| 445 | 0x29, 0x05, // Usage Maximum (Kana) | 449 | 0x29, 0x05, // Usage Maximum (Kana) |
| 446 | 0x95, 0x05, // Report Count (5) | 450 | 0x95, 0x05, // Report Count (5) |
| 447 | 0x75, 0x01, // Report Size (1) | 451 | 0x75, 0x01, // Report Size (1) |
| 448 | 0x91, 0x02, // Output (Data, Variable, Absolute) | 452 | 0x91, 0x02, // Output (Data, Variable, Absolute) |
| 449 | // LED padding (3 bits) | 453 | // LED padding (3 bits) |
| 450 | 0x95, 0x01, // Report Count (1) | 454 | 0x95, 0x01, // Report Count (1) |
| 451 | 0x75, 0x03, // Report Size (3) | 455 | 0x75, 0x03, // Report Size (3) |
| 452 | 0x91, 0x03, // Output (Constant) | 456 | 0x91, 0x03, // Output (Constant) |
| 453 | 0xC0, // End Collection | 457 | 0xC0, // End Collection |
| 454 | #ifndef KEYBOARD_SHARED_EP | 458 | #ifndef KEYBOARD_SHARED_EP |
| 455 | }; | 459 | }; |
| 456 | #endif | 460 | #endif |
| @@ -462,135 +466,135 @@ const PROGMEM uchar shared_hid_report[] = { | |||
| 462 | 466 | ||
| 463 | #ifdef MOUSE_ENABLE | 467 | #ifdef MOUSE_ENABLE |
| 464 | // Mouse report descriptor | 468 | // Mouse report descriptor |
| 465 | 0x05, 0x01, // Usage Page (Generic Desktop) | 469 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 466 | 0x09, 0x02, // Usage (Mouse) | 470 | 0x09, 0x02, // Usage (Mouse) |
| 467 | 0xA1, 0x01, // Collection (Application) | 471 | 0xA1, 0x01, // Collection (Application) |
| 468 | 0x85, REPORT_ID_MOUSE, // Report ID | 472 | 0x85, REPORT_ID_MOUSE, // Report ID |
| 469 | 0x09, 0x01, // Usage (Pointer) | 473 | 0x09, 0x01, // Usage (Pointer) |
| 470 | 0xA1, 0x00, // Collection (Physical) | 474 | 0xA1, 0x00, // Collection (Physical) |
| 471 | // Buttons (8 bits) | 475 | // Buttons (8 bits) |
| 472 | 0x05, 0x09, // Usage Page (Button) | 476 | 0x05, 0x09, // Usage Page (Button) |
| 473 | 0x19, 0x01, // Usage Minimum (Button 1) | 477 | 0x19, 0x01, // Usage Minimum (Button 1) |
| 474 | 0x29, 0x08, // Usage Maximum (Button 8) | 478 | 0x29, 0x08, // Usage Maximum (Button 8) |
| 475 | 0x15, 0x00, // Logical Minimum (0) | 479 | 0x15, 0x00, // Logical Minimum (0) |
| 476 | 0x25, 0x01, // Logical Maximum (1) | 480 | 0x25, 0x01, // Logical Maximum (1) |
| 477 | 0x95, 0x08, // Report Count (8) | 481 | 0x95, 0x08, // Report Count (8) |
| 478 | 0x75, 0x01, // Report Size (1) | 482 | 0x75, 0x01, // Report Size (1) |
| 479 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 483 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 480 | 484 | ||
| 481 | // X/Y position (2 bytes) | 485 | // X/Y position (2 bytes) |
| 482 | 0x05, 0x01, // Usage Page (Generic Desktop) | 486 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 483 | 0x09, 0x30, // Usage (X) | 487 | 0x09, 0x30, // Usage (X) |
| 484 | 0x09, 0x31, // Usage (Y) | 488 | 0x09, 0x31, // Usage (Y) |
| 485 | 0x15, 0x81, // Logical Minimum (-127) | 489 | 0x15, 0x81, // Logical Minimum (-127) |
| 486 | 0x25, 0x7F, // Logical Maximum (127) | 490 | 0x25, 0x7F, // Logical Maximum (127) |
| 487 | 0x95, 0x02, // Report Count (2) | 491 | 0x95, 0x02, // Report Count (2) |
| 488 | 0x75, 0x08, // Report Size (8) | 492 | 0x75, 0x08, // Report Size (8) |
| 489 | 0x81, 0x06, // Input (Data, Variable, Relative) | 493 | 0x81, 0x06, // Input (Data, Variable, Relative) |
| 490 | 494 | ||
| 491 | // Vertical wheel (1 byte) | 495 | // Vertical wheel (1 byte) |
| 492 | 0x09, 0x38, // Usage (Wheel) | 496 | 0x09, 0x38, // Usage (Wheel) |
| 493 | 0x15, 0x81, // Logical Minimum (-127) | 497 | 0x15, 0x81, // Logical Minimum (-127) |
| 494 | 0x25, 0x7F, // Logical Maximum (127) | 498 | 0x25, 0x7F, // Logical Maximum (127) |
| 495 | 0x95, 0x01, // Report Count (1) | 499 | 0x95, 0x01, // Report Count (1) |
| 496 | 0x75, 0x08, // Report Size (8) | 500 | 0x75, 0x08, // Report Size (8) |
| 497 | 0x81, 0x06, // Input (Data, Variable, Relative) | 501 | 0x81, 0x06, // Input (Data, Variable, Relative) |
| 498 | // Horizontal wheel (1 byte) | 502 | // Horizontal wheel (1 byte) |
| 499 | 0x05, 0x0C, // Usage Page (Consumer) | 503 | 0x05, 0x0C, // Usage Page (Consumer) |
| 500 | 0x0A, 0x38, 0x02, // Usage (AC Pan) | 504 | 0x0A, 0x38, 0x02, // Usage (AC Pan) |
| 501 | 0x15, 0x81, // Logical Minimum (-127) | 505 | 0x15, 0x81, // Logical Minimum (-127) |
| 502 | 0x25, 0x7F, // Logical Maximum (127) | 506 | 0x25, 0x7F, // Logical Maximum (127) |
| 503 | 0x95, 0x01, // Report Count (1) | 507 | 0x95, 0x01, // Report Count (1) |
| 504 | 0x75, 0x08, // Report Size (8) | 508 | 0x75, 0x08, // Report Size (8) |
| 505 | 0x81, 0x06, // Input (Data, Variable, Relative) | 509 | 0x81, 0x06, // Input (Data, Variable, Relative) |
| 506 | 0xC0, // End Collection | 510 | 0xC0, // End Collection |
| 507 | 0xC0, // End Collection | 511 | 0xC0, // End Collection |
| 508 | #endif | 512 | #endif |
| 509 | 513 | ||
| 510 | #ifdef EXTRAKEY_ENABLE | 514 | #ifdef EXTRAKEY_ENABLE |
| 511 | // Extrakeys report descriptor | 515 | // Extrakeys report descriptor |
| 512 | 0x05, 0x01, // Usage Page (Generic Desktop) | 516 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 513 | 0x09, 0x80, // Usage (System Control) | 517 | 0x09, 0x80, // Usage (System Control) |
| 514 | 0xA1, 0x01, // Collection (Application) | 518 | 0xA1, 0x01, // Collection (Application) |
| 515 | 0x85, REPORT_ID_SYSTEM, // Report ID | 519 | 0x85, REPORT_ID_SYSTEM, // Report ID |
| 516 | 0x19, 0x01, // Usage Minimum (Pointer) | 520 | 0x19, 0x01, // Usage Minimum (Pointer) |
| 517 | 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale) | 521 | 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale) |
| 518 | 0x15, 0x01, // Logical Minimum | 522 | 0x15, 0x01, // Logical Minimum |
| 519 | 0x26, 0xB7, 0x00, // Logical Maximum | 523 | 0x26, 0xB7, 0x00, // Logical Maximum |
| 520 | 0x95, 0x01, // Report Count (1) | 524 | 0x95, 0x01, // Report Count (1) |
| 521 | 0x75, 0x10, // Report Size (16) | 525 | 0x75, 0x10, // Report Size (16) |
| 522 | 0x81, 0x00, // Input (Data, Array, Absolute) | 526 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| 523 | 0xC0, // End Collection | 527 | 0xC0, // End Collection |
| 524 | 528 | ||
| 525 | 0x05, 0x0C, // Usage Page (Consumer) | 529 | 0x05, 0x0C, // Usage Page (Consumer) |
| 526 | 0x09, 0x01, // Usage (Consumer Control) | 530 | 0x09, 0x01, // Usage (Consumer Control) |
| 527 | 0xA1, 0x01, // Collection (Application) | 531 | 0xA1, 0x01, // Collection (Application) |
| 528 | 0x85, REPORT_ID_CONSUMER, // Report ID | 532 | 0x85, REPORT_ID_CONSUMER, // Report ID |
| 529 | 0x19, 0x01, // Usage Minimum (Consumer Control) | 533 | 0x19, 0x01, // Usage Minimum (Consumer Control) |
| 530 | 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications) | 534 | 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications) |
| 531 | 0x15, 0x01, // Logical Minimum | 535 | 0x15, 0x01, // Logical Minimum |
| 532 | 0x26, 0xA0, 0x02, // Logical Maximum | 536 | 0x26, 0xA0, 0x02, // Logical Maximum |
| 533 | 0x95, 0x01, // Report Count (1) | 537 | 0x95, 0x01, // Report Count (1) |
| 534 | 0x75, 0x10, // Report Size (16) | 538 | 0x75, 0x10, // Report Size (16) |
| 535 | 0x81, 0x00, // Input (Data, Array, Absolute) | 539 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| 536 | 0xC0, // End Collection | 540 | 0xC0, // End Collection |
| 537 | #endif | 541 | #endif |
| 538 | 542 | ||
| 539 | #ifdef DIGITIZER_ENABLE | 543 | #ifdef DIGITIZER_ENABLE |
| 540 | // Digitizer report descriptor | 544 | // Digitizer report descriptor |
| 541 | 0x05, 0x0D, // Usage Page (Digitizers) | 545 | 0x05, 0x0D, // Usage Page (Digitizers) |
| 542 | 0x09, 0x01, // Usage (Digitizer) | 546 | 0x09, 0x01, // Usage (Digitizer) |
| 543 | 0xA1, 0x01, // Collection (Application) | 547 | 0xA1, 0x01, // Collection (Application) |
| 544 | 0x85, REPORT_ID_DIGITIZER, // Report ID | 548 | 0x85, REPORT_ID_DIGITIZER, // Report ID |
| 545 | 0x09, 0x22, // Usage (Finger) | 549 | 0x09, 0x22, // Usage (Finger) |
| 546 | 0xA1, 0x00, // Collection (Physical) | 550 | 0xA1, 0x00, // Collection (Physical) |
| 547 | // Tip Switch (1 bit) | 551 | // Tip Switch (1 bit) |
| 548 | 0x09, 0x42, // Usage (Tip Switch) | 552 | 0x09, 0x42, // Usage (Tip Switch) |
| 549 | 0x15, 0x00, // Logical Minimum | 553 | 0x15, 0x00, // Logical Minimum |
| 550 | 0x25, 0x01, // Logical Maximum | 554 | 0x25, 0x01, // Logical Maximum |
| 551 | 0x95, 0x01, // Report Count (1) | 555 | 0x95, 0x01, // Report Count (1) |
| 552 | 0x75, 0x01, // Report Size (16) | 556 | 0x75, 0x01, // Report Size (16) |
| 553 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 557 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 554 | // In Range (1 bit) | 558 | // In Range (1 bit) |
| 555 | 0x09, 0x32, // Usage (In Range) | 559 | 0x09, 0x32, // Usage (In Range) |
| 556 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 560 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 557 | // Padding (6 bits) | 561 | // Padding (6 bits) |
| 558 | 0x95, 0x06, // Report Count (6) | 562 | 0x95, 0x06, // Report Count (6) |
| 559 | 0x81, 0x03, // Input (Constant) | 563 | 0x81, 0x03, // Input (Constant) |
| 560 | 564 | ||
| 561 | // X/Y Position (4 bytes) | 565 | // X/Y Position (4 bytes) |
| 562 | 0x05, 0x01, // Usage Page (Generic Desktop) | 566 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 563 | 0x26, 0xFF, 0x7F, // Logical Maximum (32767) | 567 | 0x26, 0xFF, 0x7F, // Logical Maximum (32767) |
| 564 | 0x95, 0x01, // Report Count (1) | 568 | 0x95, 0x01, // Report Count (1) |
| 565 | 0x75, 0x10, // Report Size (16) | 569 | 0x75, 0x10, // Report Size (16) |
| 566 | 0x65, 0x33, // Unit (Inch, English Linear) | 570 | 0x65, 0x33, // Unit (Inch, English Linear) |
| 567 | 0x55, 0x0E, // Unit Exponent (-2) | 571 | 0x55, 0x0E, // Unit Exponent (-2) |
| 568 | 0x09, 0x30, // Usage (X) | 572 | 0x09, 0x30, // Usage (X) |
| 569 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 573 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 570 | 0x09, 0x31, // Usage (Y) | 574 | 0x09, 0x31, // Usage (Y) |
| 571 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 575 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 572 | 0xC0, // End Collection | 576 | 0xC0, // End Collection |
| 573 | 0xC0, // End Collection | 577 | 0xC0, // End Collection |
| 574 | #endif | 578 | #endif |
| 575 | 579 | ||
| 576 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | 580 | #ifdef PROGRAMMABLE_BUTTON_ENABLE |
| 577 | // Programmable buttons report descriptor | 581 | // Programmable buttons report descriptor |
| 578 | 0x05, 0x0C, // Usage Page (Consumer) | 582 | 0x05, 0x0C, // Usage Page (Consumer) |
| 579 | 0x09, 0x01, // Usage (Consumer Control) | 583 | 0x09, 0x01, // Usage (Consumer Control) |
| 580 | 0xA1, 0x01, // Collection (Application) | 584 | 0xA1, 0x01, // Collection (Application) |
| 581 | 0x85, REPORT_ID_PROGRAMMABLE_BUTTON, // Report ID | 585 | 0x85, REPORT_ID_PROGRAMMABLE_BUTTON, // Report ID |
| 582 | 0x09, 0x03, // Usage (Programmable Buttons) | 586 | 0x09, 0x03, // Usage (Programmable Buttons) |
| 583 | 0xA1, 0x04, // Collection (Named Array) | 587 | 0xA1, 0x04, // Collection (Named Array) |
| 584 | 0x05, 0x09, // Usage Page (Button) | 588 | 0x05, 0x09, // Usage Page (Button) |
| 585 | 0x19, 0x01, // Usage Minimum (Button 1) | 589 | 0x19, 0x01, // Usage Minimum (Button 1) |
| 586 | 0x29, 0x20, // Usage Maximum (Button 32) | 590 | 0x29, 0x20, // Usage Maximum (Button 32) |
| 587 | 0x15, 0x00, // Logical Minimum (0) | 591 | 0x15, 0x00, // Logical Minimum (0) |
| 588 | 0x25, 0x01, // Logical Maximum (1) | 592 | 0x25, 0x01, // Logical Maximum (1) |
| 589 | 0x95, 0x20, // Report Count (32) | 593 | 0x95, 0x20, // Report Count (32) |
| 590 | 0x75, 0x01, // Report Size (1) | 594 | 0x75, 0x01, // Report Size (1) |
| 591 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 595 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 592 | 0xC0, // End Collection | 596 | 0xC0, // End Collection |
| 593 | 0xC0, // End Collection | 597 | 0xC0, // End Collection |
| 594 | #endif | 598 | #endif |
| 595 | 599 | ||
| 596 | #ifdef SHARED_EP_ENABLE | 600 | #ifdef SHARED_EP_ENABLE |
| @@ -599,47 +603,47 @@ const PROGMEM uchar shared_hid_report[] = { | |||
| 599 | 603 | ||
| 600 | #ifdef RAW_ENABLE | 604 | #ifdef RAW_ENABLE |
| 601 | const PROGMEM uchar raw_hid_report[] = { | 605 | const PROGMEM uchar raw_hid_report[] = { |
| 602 | 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) | 606 | 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) |
| 603 | 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) | 607 | 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) |
| 604 | 0xA1, 0x01, // Collection (Application) | 608 | 0xA1, 0x01, // Collection (Application) |
| 605 | // Data to host | 609 | // Data to host |
| 606 | 0x09, 0x62, // Usage (Vendor Defined) | 610 | 0x09, 0x62, // Usage (Vendor Defined) |
| 607 | 0x15, 0x00, // Logical Minimum (0) | 611 | 0x15, 0x00, // Logical Minimum (0) |
| 608 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | 612 | 0x26, 0xFF, 0x00, // Logical Maximum (255) |
| 609 | 0x95, RAW_BUFFER_SIZE, // Report Count | 613 | 0x95, RAW_BUFFER_SIZE, // Report Count |
| 610 | 0x75, 0x08, // Report Size (8) | 614 | 0x75, 0x08, // Report Size (8) |
| 611 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 615 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 612 | // Data from host | 616 | // Data from host |
| 613 | 0x09, 0x63, // Usage (Vendor Defined) | 617 | 0x09, 0x63, // Usage (Vendor Defined) |
| 614 | 0x15, 0x00, // Logical Minimum (0) | 618 | 0x15, 0x00, // Logical Minimum (0) |
| 615 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | 619 | 0x26, 0xFF, 0x00, // Logical Maximum (255) |
| 616 | 0x95, RAW_BUFFER_SIZE, // Report Count | 620 | 0x95, RAW_BUFFER_SIZE, // Report Count |
| 617 | 0x75, 0x08, // Report Size (8) | 621 | 0x75, 0x08, // Report Size (8) |
| 618 | 0x91, 0x02, // Output (Data, Variable, Absolute) | 622 | 0x91, 0x02, // Output (Data, Variable, Absolute) |
| 619 | 0xC0 // End Collection | 623 | 0xC0 // End Collection |
| 620 | }; | 624 | }; |
| 621 | #endif | 625 | #endif |
| 622 | 626 | ||
| 623 | #if defined(CONSOLE_ENABLE) | 627 | #if defined(CONSOLE_ENABLE) |
| 624 | const PROGMEM uchar console_hid_report[] = { | 628 | const PROGMEM uchar console_hid_report[] = { |
| 625 | 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible) | 629 | 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible) |
| 626 | 0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible) | 630 | 0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible) |
| 627 | 0xA1, 0x01, // Collection (Application) | 631 | 0xA1, 0x01, // Collection (Application) |
| 628 | // Data to host | 632 | // Data to host |
| 629 | 0x09, 0x75, // Usage (Vendor Defined) | 633 | 0x09, 0x75, // Usage (Vendor Defined) |
| 630 | 0x15, 0x00, // Logical Minimum (0x00) | 634 | 0x15, 0x00, // Logical Minimum (0x00) |
| 631 | 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) | 635 | 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) |
| 632 | 0x95, CONSOLE_BUFFER_SIZE, // Report Count | 636 | 0x95, CONSOLE_BUFFER_SIZE, // Report Count |
| 633 | 0x75, 0x08, // Report Size (8) | 637 | 0x75, 0x08, // Report Size (8) |
| 634 | 0x81, 0x02, // Input (Data, Variable, Absolute) | 638 | 0x81, 0x02, // Input (Data, Variable, Absolute) |
| 635 | // Data from host | 639 | // Data from host |
| 636 | 0x09, 0x76, // Usage (Vendor Defined) | 640 | 0x09, 0x76, // Usage (Vendor Defined) |
| 637 | 0x15, 0x00, // Logical Minimum (0x00) | 641 | 0x15, 0x00, // Logical Minimum (0x00) |
| 638 | 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) | 642 | 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) |
| 639 | 0x95, CONSOLE_BUFFER_SIZE, // Report Count | 643 | 0x95, CONSOLE_BUFFER_SIZE, // Report Count |
| 640 | 0x75, 0x08, // Report Size (8) | 644 | 0x75, 0x08, // Report Size (8) |
| 641 | 0x91, 0x02, // Output (Data) | 645 | 0x91, 0x02, // Output (Data) |
| 642 | 0xC0 // End Collection | 646 | 0xC0 // End Collection |
| 643 | }; | 647 | }; |
| 644 | #endif | 648 | #endif |
| 645 | 649 | ||
| @@ -939,16 +943,16 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 939 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorZero; | 943 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorZero; |
| 940 | len = usbStringDescriptorZero.header.bLength; | 944 | len = usbStringDescriptorZero.header.bLength; |
| 941 | break; | 945 | break; |
| 942 | case 1: // iManufacturer | 946 | case 1: // iManufacturer |
| 943 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorManufacturer; | 947 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorManufacturer; |
| 944 | len = usbStringDescriptorManufacturer.header.bLength; | 948 | len = usbStringDescriptorManufacturer.header.bLength; |
| 945 | break; | 949 | break; |
| 946 | case 2: // iProduct | 950 | case 2: // iProduct |
| 947 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct; | 951 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct; |
| 948 | len = usbStringDescriptorProduct.header.bLength; | 952 | len = usbStringDescriptorProduct.header.bLength; |
| 949 | break; | 953 | break; |
| 950 | #if defined(SERIAL_NUMBER) | 954 | #if defined(SERIAL_NUMBER) |
| 951 | case 3: // iSerialNumber | 955 | case 3: // iSerialNumber |
| 952 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial; | 956 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial; |
| 953 | len = usbStringDescriptorSerial.header.bLength; | 957 | len = usbStringDescriptorSerial.header.bLength; |
| 954 | break; | 958 | break; |
