-
-
Notifications
You must be signed in to change notification settings - Fork 39.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AT90USB support for serial.c #10706
Conversation
I reexamined the datasheets. It seems that serial.c cannot support ATmega32A because the control registers are different. datasheet summary
|
Thanks for the clarification. I'm a bit lost at reading the datasheets, so the review and feedback is very appreciated! I'm also wondering if it's worth abstracting the interrupt vectors for the pins, as there are other places that they would be helpful at. |
0c0fd0a
to
91d441a
Compare
The following parts also need to be fixed. @@ -258,13 +275,11 @@ 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
+# if EIMSK_BIT >= _BV(INT4)
EICRB &= EICRx_BIT;
# else
- // Trigger on falling edge of INT0-INT3
EICRA &= EICRx_BIT;
# endif
} |
I was actually wondering about that, but hadn't had a chance to look into it yet! |
As you can see from the table above, the interrupt conditions for INT0, INT1, INT2, and INT3 are set in EICRA, and the interrupt conditions for INT4, INT5, INT6, and INT7 are set in EICRB. |
Yup, I did see that, and verified that it was the case, just to make sure. Though, it may be worth having it configurable/defined if not all AVR chips support that schema. But ... for now, I think this should be fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a reference, I tryed make a patch again. mtei@10fe308 in https://github.com/mtei/qmk_firmware/commits/PR_10706_suggestion_patch2 It has been confirmed that the build binary does not change. |
1f1f24f
to
947faca
Compare
Finally got my keyboard assembled, and can verify that this works on teensy++ 2.0s (at90usb1286). |
@mtei for the same of ... simplicity, any issues with just doing this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtei for the same of ... simplicity, any issues with just doing this?
4426ab7
(#10706)
I have confirmed that the build results for ATmega32u4 have not changed. That change is fine.
However, for me, I like the following compactness. :-) --- a/drivers/avr/serial.c
+++ b/drivers/avr/serial.c
@@ -29,52 +29,43 @@
# error Using I2C, so can not use PD0, PD1
# endif
# endif
+
+# define _GET_PARAM_1(a, b, c, d) a
+# define GET_PARAM_1(param4) _GET_PARAM_1(param4)
+# define _GET_PARAM_2(a, b, c, d) b
+# define GET_PARAM_2(param4) _GET_PARAM_2(param4)
+# define _GET_PARAM_3(a, b, c, d) c
+# define GET_PARAM_3(param4) _GET_PARAM_3(param4)
+# define _GET_PARAM_4(a, b, c, d) d
+# define GET_PARAM_4(param4) _GET_PARAM_4(param4)
+
+# define SERIAL_PIN_INTERRUPT GET_PARAM_1(REG_INFOS)
+# define EIMSK_BIT GET_PARAM_2(REG_INFOS)
+# define EICRx_BIT GET_PARAM_3(REG_INFOS)
+# define EICRx GET_PARAM_4(REG_INFOS)
+
// 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
+# define REG_INFOS INT0_vect, _BV(INT0), (~(_BV(ISC00) | _BV(ISC01))), 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
+# define REG_INFOS INT1_vect, _BV(INT1), (~(_BV(ISC10) | _BV(ISC11))), 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
+# define REG_INFOS INT2_vect, _BV(INT2), (~(_BV(ISC20) | _BV(ISC21))), EICRA
<<<<Omitted on the way>>>> and -# ifndef SERIAL_PIN_INTERRUPT
+# ifndef REG_INFOS
# error invalid SOFT_SERIAL_PIN value
# endif |
4426ab7
to
26a37d9
Compare
Awesome. I feel more comfortable with "my way". It's less complex, and easier for me to read. |
I've just tested this PR on my ATmega32U2 split keyboard and it seems to work fine. |
d37890d
to
57a3616
Compare
* 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
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (qmk#10183) * Add support for soft serial to ATmega32U2 (qmk#10204) * Change MIDI velocity implementation to allow direct control of velocity value (qmk#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (qmk#10417) * Joystick 16-bit support (qmk#10439) * Per-encoder resolutions (qmk#10259) * Share button state from mousekey to pointing_device (qmk#10179) * Add hotfix for chibios keyboards not wake (qmk#10088) * Add advanced/efficient RGB Matrix Indicators (qmk#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (qmk#10206) * Add milc as a dependency and remove the installed milc (qmk#10563) * ChibiOS upgrade: early init conversions (qmk#10214) * ChibiOS upgrade: configuration file migrator (qmk#9952) * Haptic and solenoid cleanup (qmk#9700) * XD75 cleanup (qmk#10524) * OLED display update interval support (qmk#10388) * Add definition based on currently-selected serial driver. (qmk#10716) * New feature: Retro Tapping per key (qmk#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (qmk#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (qmk#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (qmk#8669) * Minor change to behavior allowing display updates to continue between task ticks (qmk#10750) * Some GPIO manipulations in matrix.c change to atomic. (qmk#10491) * qmk cformat (qmk#10767) * [Keyboard] Update the Speedo firmware for v3.0 (qmk#10657) * Maartenwut/Maarten namechange to evyd13/Evy (qmk#10274) * [quantum] combine repeated lines of code (qmk#10837) * Add step sequencer feature (qmk#9703) * aeboards/ext65 refactor (qmk#10820) * Refactor xelus/dawn60 for Rev2 later (qmk#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549) * update chibios os usb for the otg driver (qmk#8893) * Remove HD44780 References, Part 4 (qmk#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (qmk#10512) * Fix cursor position bug in oled_write_raw functions (qmk#10800) * Fixup version.h writing when using SKIP_VERSION=yes (qmk#10972) * Allow for certain code in the codebase assuming length of string. (qmk#10974) * Add AT90USB support for serial.c (qmk#10706) * Auto shift: support repeats and early registration (qmk#9826) * Rename ledmatrix.h to match .c file (qmk#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10840) * Merge point for 2020 Nov 28 Breaking Change
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (qmk#10183) * Add support for soft serial to ATmega32U2 (qmk#10204) * Change MIDI velocity implementation to allow direct control of velocity value (qmk#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (qmk#10417) * Joystick 16-bit support (qmk#10439) * Per-encoder resolutions (qmk#10259) * Share button state from mousekey to pointing_device (qmk#10179) * Add hotfix for chibios keyboards not wake (qmk#10088) * Add advanced/efficient RGB Matrix Indicators (qmk#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (qmk#10206) * Add milc as a dependency and remove the installed milc (qmk#10563) * ChibiOS upgrade: early init conversions (qmk#10214) * ChibiOS upgrade: configuration file migrator (qmk#9952) * Haptic and solenoid cleanup (qmk#9700) * XD75 cleanup (qmk#10524) * OLED display update interval support (qmk#10388) * Add definition based on currently-selected serial driver. (qmk#10716) * New feature: Retro Tapping per key (qmk#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (qmk#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (qmk#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (qmk#8669) * Minor change to behavior allowing display updates to continue between task ticks (qmk#10750) * Some GPIO manipulations in matrix.c change to atomic. (qmk#10491) * qmk cformat (qmk#10767) * [Keyboard] Update the Speedo firmware for v3.0 (qmk#10657) * Maartenwut/Maarten namechange to evyd13/Evy (qmk#10274) * [quantum] combine repeated lines of code (qmk#10837) * Add step sequencer feature (qmk#9703) * aeboards/ext65 refactor (qmk#10820) * Refactor xelus/dawn60 for Rev2 later (qmk#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549) * update chibios os usb for the otg driver (qmk#8893) * Remove HD44780 References, Part 4 (qmk#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (qmk#10512) * Fix cursor position bug in oled_write_raw functions (qmk#10800) * Fixup version.h writing when using SKIP_VERSION=yes (qmk#10972) * Allow for certain code in the codebase assuming length of string. (qmk#10974) * Add AT90USB support for serial.c (qmk#10706) * Auto shift: support repeats and early registration (qmk#9826) * Rename ledmatrix.h to match .c file (qmk#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10840) * Merge point for 2020 Nov 28 Breaking Change
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (qmk#10183) * Add support for soft serial to ATmega32U2 (qmk#10204) * Change MIDI velocity implementation to allow direct control of velocity value (qmk#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (qmk#10417) * Joystick 16-bit support (qmk#10439) * Per-encoder resolutions (qmk#10259) * Share button state from mousekey to pointing_device (qmk#10179) * Add hotfix for chibios keyboards not wake (qmk#10088) * Add advanced/efficient RGB Matrix Indicators (qmk#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (qmk#10206) * Add milc as a dependency and remove the installed milc (qmk#10563) * ChibiOS upgrade: early init conversions (qmk#10214) * ChibiOS upgrade: configuration file migrator (qmk#9952) * Haptic and solenoid cleanup (qmk#9700) * XD75 cleanup (qmk#10524) * OLED display update interval support (qmk#10388) * Add definition based on currently-selected serial driver. (qmk#10716) * New feature: Retro Tapping per key (qmk#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (qmk#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (qmk#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (qmk#8669) * Minor change to behavior allowing display updates to continue between task ticks (qmk#10750) * Some GPIO manipulations in matrix.c change to atomic. (qmk#10491) * qmk cformat (qmk#10767) * [Keyboard] Update the Speedo firmware for v3.0 (qmk#10657) * Maartenwut/Maarten namechange to evyd13/Evy (qmk#10274) * [quantum] combine repeated lines of code (qmk#10837) * Add step sequencer feature (qmk#9703) * aeboards/ext65 refactor (qmk#10820) * Refactor xelus/dawn60 for Rev2 later (qmk#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549) * update chibios os usb for the otg driver (qmk#8893) * Remove HD44780 References, Part 4 (qmk#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (qmk#10512) * Fix cursor position bug in oled_write_raw functions (qmk#10800) * Fixup version.h writing when using SKIP_VERSION=yes (qmk#10972) * Allow for certain code in the codebase assuming length of string. (qmk#10974) * Add AT90USB support for serial.c (qmk#10706) * Auto shift: support repeats and early registration (qmk#9826) * Rename ledmatrix.h to match .c file (qmk#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10840) * Merge point for 2020 Nov 28 Breaking Change
* Expand list of supported controllers for serial.c * Fix pin defines based on mtei's feedback * Fix EICRx checks in soft_serial_target_init * Fix copy-paste typo * Add defines for EICRx
Description
Adds support for the AT90USB chips in the serial driver for AVR.
Types of Changes
Checklist