Browse Source

Keep SPI0 pin config in sync with AVR SPI emulation

main
PaulStoffregen 7 years ago
parent
commit
8d59205728
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      SPI.cpp

+ 9
- 0
SPI.cpp View File



void SPIClass::setMOSI(uint8_t pin) void SPIClass::setMOSI(uint8_t pin)
{ {
if (hardware_addr == (uintptr_t)&spi0_hardware) {
SPCR.setMOSI_soft(pin);
}
if (pin != hardware().mosi_pin[mosi_pin_index]) { if (pin != hardware().mosi_pin[mosi_pin_index]) {
for (unsigned int i = 0; i < sizeof(hardware().mosi_pin); i++) { for (unsigned int i = 0; i < sizeof(hardware().mosi_pin); i++) {
if (pin == hardware().mosi_pin[i]) { if (pin == hardware().mosi_pin[i]) {


void SPIClass::setMISO(uint8_t pin) void SPIClass::setMISO(uint8_t pin)
{ {
if (hardware_addr == (uintptr_t)&spi0_hardware) {
SPCR.setMISO_soft(pin);
}
if (pin != hardware().miso_pin[miso_pin_index]) { if (pin != hardware().miso_pin[miso_pin_index]) {
for (unsigned int i = 0; i < sizeof(hardware().miso_pin); i++) { for (unsigned int i = 0; i < sizeof(hardware().miso_pin); i++) {
if (pin == hardware().miso_pin[i]) { if (pin == hardware().miso_pin[i]) {


void SPIClass::setSCK(uint8_t pin) void SPIClass::setSCK(uint8_t pin)
{ {
if (hardware_addr == (uintptr_t)&spi0_hardware) {
SPCR.setSCK_soft(pin);
}
if (pin != hardware().sck_pin[sck_pin_index]) { if (pin != hardware().sck_pin[sck_pin_index]) {
for (unsigned int i = 0; i < sizeof(hardware().sck_pin); i++) { for (unsigned int i = 0; i < sizeof(hardware().sck_pin); i++) {
if (pin == hardware().sck_pin[i]) { if (pin == hardware().sck_pin[i]) {

Loading…
Cancel
Save