-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
spi_master for AVR #8299
spi_master for AVR #8299
Conversation
Need to test the Ploopy with this, but otherwise, I think it looks good, and travis doesn't object. |
I think we should mirror the i2c driver, and add spi_start/spi_stop. |
Speed
Polarity/phase: Suggested API:
|
LUFA's implementation of I2C has equivalents for |
Yep, that's fine, but in the context of whether we want to start and stop communicating with a device, the slave select pin needs to be toggled. I'm also thinking from the Arm side of things -- ChibiOS's SPI driver does indeed need start/stop, so if we "train" people to use the start/transmit/receive/stop methodology then anyone who wants to swap from an AVR-based design to an Arm-based design won't require extra messing about trying to understand why it works for one and not the other. |
Got it. How's this for a start: static pin_t currentSlavePin = NO_PIN;
void spi_start(pin_t slavePin) {
if (currentSlavePin == NO_PIN && slavePin != NO_PIN) {
currentSlavePin = slavePin;
writePinLow(currentSlavePin);
}
}
void spi_stop(void) {
if (currentSlavePin != NO_PIN) {
writePinHigh(currentSlavePin);
currentSlavePin = NO_PIN;
}
} |
With this last commit I've added Debug console just keeps printing this:
and the board will occasionally spam |
Okay, strange. A sprinkling of dprintf in |
Figured it out. The |
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.
Docs look good.
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.
Brief test on my 34u2 bluefruit - seems happy enough.
@yanfali any chance you could test your fruity60?
@yanfali confirmed fruity60 working. |
* 'master' of https://github.com/qmk/qmk_firmware: (53 commits) Set the correct RGB LED count on YD60MQ (qmk#8629) [Keymap] Updates to personal keymaps (qmk#8665) Fix compile issues related to NO_ACTION_MACRO/FUNCTION and LTO_ENABLE (qmk#8663) [Keymap] Userspace update Rgb layers code (qmk#8659) Add Choconum (qmk#8709) Add Via keymap for BM16-A (qmk#8681) Fix edge-case with config Don't hide for devs... Apply @skullydazed's suggestions, move 'import milc' Make dedicated sections for user/dev commands in docs Rebase on master, hide some other subcommands Use milc for config check, requirements fixes CLI: Add development mode support Update info.json (qmk#8723) format code according to conventions [skip ci] spi_master for AVR (qmk#8299) DennyTom's buttery_engine (qmk#8138) add via support for kira80 (qmk#8677) [Keyboard] Wheatfield Split75 (qmk#8511) Correctly handle json keymaps with ANY() ...
* master: (3035 commits) [Keymap] Update personal userspace and keymaps (qmk#8747) Add PS2_MOUSE_ROTATE to compensate for device orientation (qmk#8650) Add RGB support in via to launchpad (qmk#8621) VIA support for the KBDFans KBD6x (qmk#8680) Set the correct RGB LED count on YD60MQ (qmk#8629) [Keymap] Updates to personal keymaps (qmk#8665) Fix compile issues related to NO_ACTION_MACRO/FUNCTION and LTO_ENABLE (qmk#8663) [Keymap] Userspace update Rgb layers code (qmk#8659) Add Choconum (qmk#8709) Add Via keymap for BM16-A (qmk#8681) Fix edge-case with config Don't hide for devs... Apply @skullydazed's suggestions, move 'import milc' Make dedicated sections for user/dev commands in docs Rebase on master, hide some other subcommands Use milc for config check, requirements fixes CLI: Add development mode support Update info.json (qmk#8723) format code according to conventions [skip ci] spi_master for AVR (qmk#8299) ... # Conflicts: # layouts/community/ortho_4x12/grahampheath/keymap.c # lib/lufa
* master: (208 commits) [Keymap] Update personal userspace and keymaps (qmk#8747) Add PS2_MOUSE_ROTATE to compensate for device orientation (qmk#8650) Add RGB support in via to launchpad (qmk#8621) VIA support for the KBDFans KBD6x (qmk#8680) Set the correct RGB LED count on YD60MQ (qmk#8629) [Keymap] Updates to personal keymaps (qmk#8665) Fix compile issues related to NO_ACTION_MACRO/FUNCTION and LTO_ENABLE (qmk#8663) [Keymap] Userspace update Rgb layers code (qmk#8659) Add Choconum (qmk#8709) Add Via keymap for BM16-A (qmk#8681) Fix edge-case with config Don't hide for devs... Apply @skullydazed's suggestions, move 'import milc' Make dedicated sections for user/dev commands in docs Rebase on master, hide some other subcommands Use milc for config check, requirements fixes CLI: Add development mode support Update info.json (qmk#8723) format code according to conventions [skip ci] spi_master for AVR (qmk#8299) ...
* master: (208 commits) [Keymap] Update personal userspace and keymaps (qmk#8747) Add PS2_MOUSE_ROTATE to compensate for device orientation (qmk#8650) Add RGB support in via to launchpad (qmk#8621) VIA support for the KBDFans KBD6x (qmk#8680) Set the correct RGB LED count on YD60MQ (qmk#8629) [Keymap] Updates to personal keymaps (qmk#8665) Fix compile issues related to NO_ACTION_MACRO/FUNCTION and LTO_ENABLE (qmk#8663) [Keymap] Userspace update Rgb layers code (qmk#8659) Add Choconum (qmk#8709) Add Via keymap for BM16-A (qmk#8681) Fix edge-case with config Don't hide for devs... Apply @skullydazed's suggestions, move 'import milc' Make dedicated sections for user/dev commands in docs Rebase on master, hide some other subcommands Use milc for config check, requirements fixes CLI: Add development mode support Update info.json (qmk#8723) format code according to conventions [skip ci] spi_master for AVR (qmk#8299) ...
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
* Change _delay_ms/us() to wait_ms/us() * Switch to platform-agnostic GPIO macros * Add AVR spi_master and migrate Adafruit BLE code * Set verbose back to false * Add clock divisor, bit order and SPI mode configuration for init * Add start and stop functions * Move configuration of mode, endianness and speed to `spi_start()` * Some breaks here would be good * Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4) * Remove mode and divisor enums * Add some docs * No hr at EOF * Add links in sidebar
Description
Pulling the SPI code up out of the BLE stuff so we can reuse it. Also replaced as much of the AVR-specific code as I could see, to facilitate Arm support by simply dropping in an appropriate spi_master.
Feel free to point out any dumb mistakes.
Types of Changes
Issues Fixed or Closed by This PR
Checklist