SDK4.0
This document shows Ameba SDK 4.0 APIs
|
spi functions More...
AmebaZ Only | |
enum | MBED_SPI_IDX { MBED_SPI0 = 0xF0, MBED_SPI1 = 0xF1 } |
Ameba Common | |
typedef struct spi_s | spi_t |
void | spi_init (spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
Initializes the SPI device, include clock/function/interrupt/SPI registers. More... | |
void | spi_free (spi_t *obj) |
Deinitializes the SPI device, include interrupt/DMA/DISABLE SPI. More... | |
void | spi_format (spi_t *obj, int bits, int mode, int slave) |
Set SPI format,include DFS/Phase/Polarity. More... | |
void | spi_frequency (spi_t *obj, int hz) |
Set SPI baudrate. More... | |
int | spi_master_write (spi_t *obj, int value) |
Master send one frame use SPI. More... | |
int | spi_slave_receive (spi_t *obj) |
Get slave readable && busy state. More... | |
int | spi_slave_read (spi_t *obj) |
Slave receive one frame use SPI. More... | |
void | spi_slave_write (spi_t *obj, int value) |
Slave send one frame use SPI. More... | |
int | spi_busy (spi_t *obj) |
Get SPI busy state. More... | |
void | spi_flush_rx_fifo (spi_t *obj) |
SPI device to flush rx fifo. More... | |
void | spi_enable (spi_t *obj) |
Open SPI device clock. More... | |
void | spi_disable (spi_t *obj) |
Close SPI device clock. More... | |
spi functions
enum MBED_SPI_IDX |
int spi_busy | ( | spi_t * | obj | ) |
Get SPI busy state.
obj | spi object define in application software. |
current busy state |
void spi_disable | ( | spi_t * | obj | ) |
Close SPI device clock.
obj | spi object define in application software. |
none |
void spi_enable | ( | spi_t * | obj | ) |
Open SPI device clock.
obj | spi object define in application software. |
none |
void spi_flush_rx_fifo | ( | spi_t * | obj | ) |
SPI device to flush rx fifo.
obj | spi object define in application software. |
none |
void spi_format | ( | spi_t * | obj, |
int | bits, | ||
int | mode, | ||
int | slave | ||
) |
Set SPI format,include DFS/Phase/Polarity.
obj | spi object define in application software. |
bits | data frame size, 4-16 supported. |
mode | this parameter can be one of the following values:
|
slave | this parameter can be one of the following values:
|
none |
void spi_free | ( | spi_t * | obj | ) |
Deinitializes the SPI device, include interrupt/DMA/DISABLE SPI.
obj | spi object define in application software. |
none |
void spi_frequency | ( | spi_t * | obj, |
int | hz | ||
) |
Set SPI baudrate.
obj | spi master object define in application software. |
hz | baudrate for SPI bus |
none |
void spi_init | ( | spi_t * | obj, |
PinName | mosi, | ||
PinName | miso, | ||
PinName | sclk, | ||
PinName | ssel | ||
) |
Initializes the SPI device, include clock/function/interrupt/SPI registers.
obj | spi object define in application software. |
mosi | MOSI PinName according to pinmux spec. |
miso | MISO PinName according to pinmux spec. |
sclk | SCLK PinName according to pinmux spec. |
ssel | CS PinName according to pinmux spec. |
none |
int spi_master_write | ( | spi_t * | obj, |
int | value | ||
) |
Master send one frame use SPI.
obj | spi master object define in application software. |
value | the data to transmit. |
data received from slave |
int spi_slave_read | ( | spi_t * | obj | ) |
Slave receive one frame use SPI.
obj | spi slave object define in application software. |
data received from master |
int spi_slave_receive | ( | spi_t * | obj | ) |
Get slave readable && busy state.
obj | spi slave object define in application software. |
slave Readable && Busy State |
void spi_slave_write | ( | spi_t * | obj, |
int | value | ||
) |
Slave send one frame use SPI.
obj | spi slave object define in application software. |
value | the data to transmit. |
none |