Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4c8e24

Browse files
committed
refactor(spi): simplify constructor
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent021d321 commite4c8e24

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

‎libraries/SPI/src/SPI.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,18 @@
1414
SPIClass SPI;
1515

1616
/**
17-
* @brief Default constructor. Uses pin configuration of variant.h.
18-
*/
19-
SPIClass::SPIClass()
20-
{
21-
_spi.pin_miso =digitalPinToPinName(MISO);
22-
_spi.pin_mosi =digitalPinToPinName(MOSI);
23-
_spi.pin_sclk =digitalPinToPinName(SCK);
24-
_spi.pin_ssel = NC;
25-
}
26-
27-
/**
28-
* @brief Constructor to create another SPI instance attached to another SPI
29-
* peripheral different of the default SPI. All pins must be attached to
30-
* the same SPI peripheral. See datasheet of the microcontroller.
17+
* @brief Default Constructor. Uses pin configuration of default SPI
18+
* defined in the varian*t.h.
19+
* To create another SPI instance attached to another SPI
20+
* peripheral gave the pins as parameters to the constructor.
21+
* @note All pins must be attached to the same SPI peripheral.
22+
* See datasheet of the microcontroller.
3123
* @param mosi: SPI mosi pin. Accepted format: number or Arduino format (Dx)
32-
* or ST format (Pxy).
24+
* or ST format (Pxy). Default is MOSI pin of the default SPI peripheral.
3325
* @param miso: SPI miso pin. Accepted format: number or Arduino format (Dx)
34-
* or ST format (Pxy).
26+
* or ST format (Pxy). Default is MISO pin of the default SPI peripheral.
3527
* @param sclk: SPI clock pin. Accepted format: number or Arduino format (Dx)
36-
* or ST format (Pxy).
28+
* or ST format (Pxy). Default is SCK pin of the default SPI peripheral.
3729
* @param ssel: SPI ssel pin (optional). Accepted format: number or
3830
* Arduino format (Dx) or ST format (Pxy). By default is set to NC.
3931
* This pin must correspond to a hardware CS pin which can be managed

‎libraries/SPI/src/SPI.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class SPISettings {
8484

8585
classSPIClass {
8686
public:
87-
SPIClass();
88-
SPIClass(uint32_t mosi,uint32_t miso,uint32_t sclk,uint32_t ssel = PNUM_NOT_DEFINED);
87+
SPIClass(uint32_t mosi = MISO,uint32_t miso = MOSI,uint32_t sclk = SCK,uint32_t ssel = PNUM_NOT_DEFINED);
8988

9089
// setMISO/MOSI/SCLK/SSEL have to be called before begin()
9190
voidsetMISO(uint32_t miso)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp