20 #include "platform/platform.h"    22 #if DEVICE_SPI || defined(DOXYGEN_ONLY)    24 #include "platform/PlatformMutex.h"    25 #include "hal/spi_api.h"    26 #include "drivers/DigitalOut.h"    27 #include "platform/SingletonPtr.h"    28 #include "platform/NonCopyable.h"    30 #if defined MBED_CONF_DRIVERS_SPI_COUNT_MAX && DEVICE_SPI_COUNT > MBED_CONF_DRIVERS_SPI_COUNT_MAX    31 #define SPI_PERIPHERALS_USED MBED_CONF_DRIVERS_SPI_COUNT_MAX    32 #elif defined DEVICE_SPI_COUNT    33 #define SPI_PERIPHERALS_USED DEVICE_SPI_COUNT    36 #define SPI_PERIPHERALS_USED 1    40 #include "platform/CThunk.h"    41 #include "hal/dma_api.h"    42 #include "platform/CircularBuffer.h"    43 #include "platform/Callback.h"    44 #include "platform/Transaction.h"   116     SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC);
   150     void format(
int bits, 
int mode = 0);
   156     void frequency(
int hz = 1000000);
   164     virtual int write(
int value);
   180     virtual int write(
const char *tx_buffer, 
int tx_length, 
char *rx_buffer, 
int rx_length);
   184     virtual void lock(
void);
   188     virtual void unlock(
void);
   208     void set_default_write_value(
char data);
   210 #if DEVICE_SPI_ASYNCH   229     template<
typename Type>
   233             return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, 
sizeof(Type) * 8, callback, event);
   235         start_transfer(tx_buffer, tx_length, rx_buffer, rx_length, 
sizeof(Type) * 8, callback, event);
   241     void abort_transfer();
   245     void clear_transfer_buffer();
   249     void abort_all_transfers();
   259     int set_dma_usage(DMAUsage usage);
   261 #if !defined(DOXYGEN_ONLY)   266     void irq_handler_asynch(
void);
   284     int transfer(
const void *tx_buffer, 
int tx_length, 
void *rx_buffer, 
int rx_length, 
unsigned char bit_width, 
const event_callback_t &
callback, 
int event);
   302     int queue_transfer(
const void *tx_buffer, 
int tx_length, 
void *rx_buffer, 
int rx_length, 
unsigned char bit_width, 
const event_callback_t &callback, 
int event);
   316     void start_transfer(
const void *tx_buffer, 
int tx_length, 
void *rx_buffer, 
int rx_length, 
unsigned char bit_width, 
const event_callback_t &callback, 
int event);
   320     void lock_deep_sleep();
   323     void unlock_deep_sleep();
   326 #if TRANSACTION_QUEUE_SIZE_SPI   335     void dequeue_transaction();
   337 #endif // TRANSACTION_QUEUE_SIZE_SPI   338 #endif // !defined(DOXYGEN_ONLY)   339 #endif // DEVICE_SPI_ASYNCH   341 #if !defined(DOXYGEN_ONLY)   343 #ifdef DEVICE_SPI_COUNT   345     typedef ::SPIName SPIName;
   348     enum SPIName { GlobalSPI };
   357     struct spi_peripheral_s {
   359         SPIName name = SPIName(0);
   365         SPI *owner = 
nullptr;
   366 #if DEVICE_SPI_ASYNCH && TRANSACTION_QUEUE_SIZE_SPI   375     static spi_peripheral_s _peripherals[SPI_PERIPHERALS_USED];
   376     static int _peripherals_used;
   379     spi_peripheral_s *_peripheral;
   381 #if DEVICE_SPI_ASYNCH   389     bool _deep_sleep_locked;
   390 #endif // DEVICE_SPI_ASYNCH   410     int8_t _select_count;
   413     void _do_construct();
   423     static spi_peripheral_s *_lookup(SPIName name);
   426     static spi_peripheral_s *_alloc();
   435 #endif // DEVICE_SPI || DOXYGEN_ONLY uint8_t spi_active(spi_t *obj)
Attempts to determine if the SPI peripheral is already in use. 
Prevents generation of copy constructor and copy assignment operator in derived classes. 
int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t &callback, int event=SPI_EVENT_COMPLETE)
Start non-blocking SPI transfer using 8bit buffers. 
A digital output, used for setting the state of a pin. 
A SPI Master, used for communicating with SPI slave devices. 
Class for created a pointer with data bound to it. 
Asynch SPI HAL structure.