14
14
SPIClass SPI;
15
15
16
16
/* *
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 variant*.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.
31
23
* @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.
33
25
* @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.
35
27
* @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.
37
29
* @param ssel: SPI ssel pin (optional). Accepted format: number or
38
30
* Arduino format (Dx) or ST format (Pxy). By default is set to NC.
39
31
* This pin must correspond to a hardware CS pin which can be managed
@@ -45,6 +37,7 @@ SPIClass::SPIClass()
45
37
*/
46
38
SPIClass::SPIClass (uint32_t mosi, uint32_t miso, uint32_t sclk, uint32_t ssel)
47
39
{
40
+ memset ((void *)&_spi, 0 , sizeof (_spi));
48
41
_spi.pin_miso = digitalPinToPinName (miso);
49
42
_spi.pin_mosi = digitalPinToPinName (mosi);
50
43
_spi.pin_sclk = digitalPinToPinName (sclk);
0 commit comments