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 /platforms | |
| parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
Format code according to conventions (#16322)
Diffstat (limited to 'platforms')
61 files changed, 550 insertions, 346 deletions
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 |
