Skip to content

Commit d101bf5

Browse files
committed
[sam] 2 bugfix to SPI library.
- begin() after end() now works. - unconnected SPI pin is selected as CS when old (non extended) API is used.
1 parent 8b0b0a7 commit d101bf5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

build/shared/revisions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ARDUINO 1.5.3 BETA
2020

2121
[libraries]
2222
* sam: Added CAN library (still in early stage of development) (Palliser)
23+
* sam: Bugfix SPI library: begin() after end() now works (stimmer)
24+
* sam: Bugfix SPI library: incorrent pin configuration in non-extended mode.
2325

2426
[firmwares]
2527
* Arduino Due: fixed USB2Serial garbage at startup (https://github.com/arduino/Arduino/pull/1267)

hardware/arduino/sam/libraries/SPI/SPI.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
SPIClass::SPIClass(Spi *_spi, uint32_t _id, void(*_initCb)(void)) :
1414
spi(_spi), id(_id), initCb(_initCb)
1515
{
16-
initCb();
16+
// Empty
17+
}
1718

19+
void SPIClass::begin() {
20+
initCb();
1821
SPI_Configure(spi, id, SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS);
1922
SPI_Enable(spi);
20-
}
2123

22-
void SPIClass::begin() {
2324
// NPCS control is left to the user
2425

2526
// Default speed set to 4Mhz

hardware/arduino/sam/variants/arduino_due_x/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extern "C"{
8484
#define BOARD_SPI_SS1 (4u)
8585
#define BOARD_SPI_SS2 (52u)
8686
#define BOARD_SPI_SS3 PIN_SPI_SS3
87-
#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS2
87+
#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3
8888

8989
#define BOARD_PIN_TO_SPI_PIN(x) \
9090
(x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \

0 commit comments

Comments
 (0)