File tree Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change 23
23
24
24
#if DEVICE_SPI
25
25
26
- /* Backwards compatibility with HALs that don't provide this */
27
- MBED_WEAK SPIName spi_get_peripheral_name (PinName /* mosi*/ , PinName /* miso*/ , PinName /* mclk*/ )
28
- {
29
- return (SPIName)1 ;
30
- }
31
-
32
26
namespace mbed {
33
27
34
28
SPI::spi_peripheral_s SPI::_peripherals[SPI_PERIPHERALS_USED];
@@ -73,7 +67,12 @@ void SPI::_do_construct()
73
67
_hz = 1000000 ;
74
68
_write_fill = SPI_FILL_CHAR;
75
69
70
+ // Need backwards compatibility with HALs not providing API
71
+ #ifdef SPI_COUNT
76
72
SPIName name = spi_get_peripheral_name (_mosi, _miso, _sclk);
73
+ #else
74
+ SPIName name = GlobalSPI;
75
+ #endif
77
76
78
77
core_util_critical_section_enter ();
79
78
// lookup in a critical section if we already have it else initialize it
@@ -98,7 +97,7 @@ SPI::~SPI()
98
97
unlock ();
99
98
}
100
99
101
- SPI::spi_peripheral_s *SPI::_lookup (SPIName name)
100
+ SPI::spi_peripheral_s *SPI::_lookup (SPI:: SPIName name)
102
101
{
103
102
SPI::spi_peripheral_s *result = NULL ;
104
103
core_util_critical_section_enter ();
Original file line number Diff line number Diff line change 27
27
#include " platform/SingletonPtr.h"
28
28
#include " platform/NonCopyable.h"
29
29
30
- /* Backwards compatibility with HALs not providing this */
31
- #ifndef SPI_COUNT
32
- #define SPI_COUNT 1
33
- #endif
34
-
35
30
#if defined MBED_CONF_DRIVERS_SPI_COUNT_MAX && SPI_COUNT > MBED_CONF_DRIVERS_SPI_COUNT_MAX
36
31
#define SPI_PERIPHERALS_USED MBED_CONF_DRIVERS_SPI_COUNT_MAX
37
- #else
32
+ #elif defined SPI_COUNT
38
33
#define SPI_PERIPHERALS_USED SPI_COUNT
34
+ #else
35
+ /* Backwards compatibility with HALs not providing SPI_COUNT */
36
+ #define SPI_PERIPHERALS_USED 1
39
37
#endif
40
38
41
39
#if DEVICE_SPI_ASYNCH
@@ -259,6 +257,7 @@ class SPI : private NonCopyable<SPI> {
259
257
260
258
#if !defined(DOXYGEN_ONLY)
261
259
protected:
260
+
262
261
/* * SPI interrupt handler.
263
262
*/
264
263
void irq_handler_asynch (void );
@@ -338,6 +337,14 @@ class SPI : private NonCopyable<SPI> {
338
337
339
338
#if !defined(DOXYGEN_ONLY)
340
339
protected:
340
+ #ifdef SPI_COUNT
341
+ // HAL must have defined this as a global enum
342
+ typedef ::SPIName SPIName;
343
+ #else
344
+ // HAL may or may not have defined it - use a local definition
345
+ enum SPIName { GlobalSPI };
346
+ #endif
347
+
341
348
struct spi_peripheral_s {
342
349
/* Internal SPI name identifying the resources. */
343
350
SPIName name;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ extern "C" {
62
62
* @{
63
63
*/
64
64
65
+ #ifdef SPI_COUNT
65
66
/**
66
67
* Returns a variant of the SPIName enum uniquely identifying a SPI peripheral of the device.
67
68
* @param[in] mosi The pin to use for MOSI
@@ -70,6 +71,7 @@ extern "C" {
70
71
* @return An SPI peripheral identifier
71
72
*/
72
73
SPIName spi_get_peripheral_name (PinName mosi , PinName miso , PinName mclk );
74
+ #endif
73
75
74
76
/** Initialize the SPI peripheral
75
77
*
You can’t perform that action at this time.
0 commit comments