summaryrefslogtreecommitdiff
path: root/drivers/avr
diff options
context:
space:
mode:
authorJames Young <18669334+noroadsleft@users.noreply.github.com>2020-11-28 12:02:18 -0800
committerGitHub <noreply@github.com>2020-11-28 12:02:18 -0800
commitc66df1664497546f32662409778731143e45a552 (patch)
treeda73a2d532a27685a31d932b3a44a707d4a3af81 /drivers/avr
parent15385d4113414d42bd062c60c9de5df797d3157f (diff)
2020 November 28 Breaking Changes Update (#11053)
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
Diffstat (limited to 'drivers/avr')
-rw-r--r--drivers/avr/serial.c139
1 files changed, 97 insertions, 42 deletions
diff --git a/drivers/avr/serial.c b/drivers/avr/serial.c
index c27cbfdd0a..526a0946b2 100644
--- a/drivers/avr/serial.c
+++ b/drivers/avr/serial.c
@@ -20,50 +20,111 @@
#ifdef SOFT_SERIAL_PIN
-# ifdef __AVR_ATmega32U4__
-// if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
-# ifdef USE_AVR_I2C
-# if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
-# error Using ATmega32U4 I2C, so can not use PD0, PD1
-# endif
+# if !(defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+# error serial.c is not supported for the currently selected MCU
+# endif
+// if using ATmega32U4/2, AT90USBxxx I2C, can not use PD0 and PD1 in soft serial.
+# if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+# if defined(USE_AVR_I2C) && (SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1)
+# error Using I2C, so can not use PD0, PD1
# endif
+# endif
+// PD0..PD3, common config
+# if SOFT_SERIAL_PIN == D0
+# define EIMSK_BIT _BV(INT0)
+# define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
+# define SERIAL_PIN_INTERRUPT INT0_vect
+# define EICRx EICRA
+# elif SOFT_SERIAL_PIN == D1
+# define EIMSK_BIT _BV(INT1)
+# define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
+# define SERIAL_PIN_INTERRUPT INT1_vect
+# define EICRx EICRA
+# elif SOFT_SERIAL_PIN == D2
+# define EIMSK_BIT _BV(INT2)
+# define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
+# define SERIAL_PIN_INTERRUPT INT2_vect
+# define EICRx EICRA
+# elif SOFT_SERIAL_PIN == D3
+# define EIMSK_BIT _BV(INT3)
+# define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
+# define SERIAL_PIN_INTERRUPT INT3_vect
+# define EICRx EICRA
+# endif
-# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
-# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
-# define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
-# define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
-# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
-
-# if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
-# if SOFT_SERIAL_PIN == D0
-# define EIMSK_BIT _BV(INT0)
-# define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
-# define SERIAL_PIN_INTERRUPT INT0_vect
-# elif SOFT_SERIAL_PIN == D1
-# define EIMSK_BIT _BV(INT1)
-# define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
-# define SERIAL_PIN_INTERRUPT INT1_vect
-# elif SOFT_SERIAL_PIN == D2
-# define EIMSK_BIT _BV(INT2)
-# define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
-# define SERIAL_PIN_INTERRUPT INT2_vect
-# elif SOFT_SERIAL_PIN == D3
-# define EIMSK_BIT _BV(INT3)
-# define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
-# define SERIAL_PIN_INTERRUPT INT3_vect
-# endif
+// ATmegaxxU2 specific config
+# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)
+// PD4(INT5), PD6(INT6), PD7(INT7), PC7(INT4)
+# if SOFT_SERIAL_PIN == D4
+# define EIMSK_BIT _BV(INT5)
+# define EICRx_BIT (~(_BV(ISC50) | _BV(ISC51)))
+# define SERIAL_PIN_INTERRUPT INT5_vect
+# define EICRx EICRB
+# elif SOFT_SERIAL_PIN == D6
+# define EIMSK_BIT _BV(INT6)
+# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
+# define SERIAL_PIN_INTERRUPT INT6_vect
+# define EICRx EICRB
+# elif SOFT_SERIAL_PIN == D7
+# define EIMSK_BIT _BV(INT7)
+# define EICRx_BIT (~(_BV(ISC70) | _BV(ISC71)))
+# define SERIAL_PIN_INTERRUPT INT7_vect
+# define EICRx EICRB
+# elif SOFT_SERIAL_PIN == C7
+# define EIMSK_BIT _BV(INT4)
+# define EICRx_BIT (~(_BV(ISC40) | _BV(ISC41)))
+# define SERIAL_PIN_INTERRUPT INT4_vect
+# define EICRx EICRB
+# endif
+# endif
+
+// ATmegaxxU4 specific config
+# if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
+// PE6(INT6)
+# if SOFT_SERIAL_PIN == E6
+# define EIMSK_BIT _BV(INT6)
+# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
+# define SERIAL_PIN_INTERRUPT INT6_vect
+# define EICRx EICRB
+# endif
+# endif
+
+// AT90USBxxx specific config
+# if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+// PE4..PE7(INT4..INT7)
+# if SOFT_SERIAL_PIN == E4
+# define EIMSK_BIT _BV(INT4)
+# define EICRx_BIT (~(_BV(ISC40) | _BV(ISC41)))
+# define SERIAL_PIN_INTERRUPT INT4_vect
+# define EICRx EICRB
+# elif SOFT_SERIAL_PIN == E5
+# define EIMSK_BIT _BV(INT5)
+# define EICRx_BIT (~(_BV(ISC50) | _BV(ISC51)))
+# define SERIAL_PIN_INTERRUPT INT5_vect
+# define EICRx EICRB
# elif SOFT_SERIAL_PIN == E6
# define EIMSK_BIT _BV(INT6)
# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
# define SERIAL_PIN_INTERRUPT INT6_vect
-# else
-# error invalid SOFT_SERIAL_PIN value
+# define EICRx EICRB
+# elif SOFT_SERIAL_PIN == E7
+# define EIMSK_BIT _BV(INT7)
+# define EICRx_BIT (~(_BV(ISC70) | _BV(ISC71)))
+# define SERIAL_PIN_INTERRUPT INT7_vect
+# define EICRx EICRB
# endif
+# endif
-# else
-# error serial.c now support ATmega32U4 only
+# ifndef SERIAL_PIN_INTERRUPT
+# error invalid SOFT_SERIAL_PIN value
# endif
+# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
+# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
+
# define ALWAYS_INLINE __attribute__((always_inline))
# define NO_INLINE __attribute__((noinline))
# define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
@@ -210,15 +271,9 @@ void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) {
Transaction_table_size = (uint8_t)sstd_table_size;
serial_input_with_pullup();
- // Enable INT0-INT3,INT6
+ // Enable INT0-INT7
EIMSK |= EIMSK_BIT;
-# if SOFT_SERIAL_PIN == E6
- // Trigger on falling edge of INT6
- EICRB &= EICRx_BIT;
-# else
- // Trigger on falling edge of INT0-INT3
- EICRA &= EICRx_BIT;
-# endif
+ EICRx &= EICRx_BIT;
}
// Used by the sender to synchronize timing with the reciver.