From ee6cf1331610635886be1fe55257ad8b7d77af22 Mon Sep 17 00:00:00 2001 From: jiamin <51077771+hbcz2019@users.noreply.github.com> Date: Tue, 28 May 2019 21:29:27 +0800 Subject: [PATCH] Code comment Code comment --- .../Arduino_1.0.x/libraries/SPI/SPI.cpp | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/ArduinoAddons/Arduino_1.0.x/libraries/SPI/SPI.cpp b/ArduinoAddons/Arduino_1.0.x/libraries/SPI/SPI.cpp index 5e48073..54cb36a 100644 --- a/ArduinoAddons/Arduino_1.0.x/libraries/SPI/SPI.cpp +++ b/ArduinoAddons/Arduino_1.0.x/libraries/SPI/SPI.cpp @@ -15,40 +15,44 @@ SPIClass SPI; void SPIClass::begin() { - // Set SS to high so a connected chip will be "deselected" by default + /* Set SS to high so a connected chip will be "deselected" by default*/ digitalWrite(SS, HIGH); - // When the SS pin is set as OUTPUT, it can be used as - // a general purpose output port (it doesn't influence - // SPI operations). + /* When the SS pin is set as OUTPUT, it can be used as + a general purpose output port (it doesn't influence + SPI operations).*/ pinMode(SS, OUTPUT); - // Warning: if the SS pin ever becomes a LOW INPUT then SPI - // automatically switches to Slave, so the data direction of - // the SS pin MUST be kept as OUTPUT. + /* Warning: if the SS pin ever becomes a LOW INPUT then SPI + automatically switches to Slave, so the data direction of + the SS pin MUST be kept as OUTPUT.*/ SPCR |= _BV(MSTR); SPCR |= _BV(SPE); - // Set direction register for SCK and MOSI pin. - // MISO pin automatically overrides to INPUT. - // By doing this AFTER enabling SPI, we avoid accidentally - // clocking in a single bit since the lines go directly - // from "input" to SPI control. - // http://code.google.com/p/arduino/issues/detail?id=888 + /* Set direction register for SCK and MOSI pin. + MISO pin automatically overrides to INPUT. + By doing this AFTER enabling SPI, we avoid accidentally + clocking in a single bit since the lines go directly + from "input" to SPI control. + http://code.google.com/p/arduino/issues/detail?id=888*/ pinMode(SCK, OUTPUT); pinMode(MOSI, OUTPUT); } -void SPIClass::end() { +void SPIClass::end() +{ SPCR &= ~_BV(SPE); } void SPIClass::setBitOrder(uint8_t bitOrder) { - if(bitOrder == LSBFIRST) { + if(bitOrder == LSBFIRST) + { SPCR |= _BV(DORD); - } else { + } + else + { SPCR &= ~(_BV(DORD)); } }