Mbed OS Reference
|
A QSPI Driver, used for communicating with QSPI slave devices. More...
#include <QSPI.h>
Public Member Functions | |
QSPI (PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName ssel=NC, int mode=0) | |
Create a QSPI master connected to the specified pins. More... | |
QSPI (const qspi_pinmap_t &pinmap, int mode=0) | |
Create a QSPI master connected to the specified pins. More... | |
qspi_status_t | configure_format (qspi_bus_width_t inst_width, qspi_bus_width_t address_width, qspi_address_size_t address_size, qspi_bus_width_t alt_width, qspi_alt_size_t alt_size, qspi_bus_width_t data_width, int dummy_cycles) |
Configure the data transmission format. More... | |
qspi_status_t | set_frequency (int hz=1000000) |
Set the qspi bus clock frequency. More... | |
qspi_status_t | read (int address, char *rx_buffer, size_t *rx_length) |
Read from QSPI peripheral with the preset read_instruction and alt_value. More... | |
qspi_status_t | write (int address, const char *tx_buffer, size_t *tx_length) |
Write to QSPI peripheral using custom write instruction. More... | |
qspi_status_t | read (qspi_inst_t instruction, int alt, int address, char *rx_buffer, size_t *rx_length) |
Read from QSPI peripheral using custom read instruction, alt values. More... | |
qspi_status_t | write (qspi_inst_t instruction, int alt, int address, const char *tx_buffer, size_t *tx_length) |
Write to QSPI peripheral using custom write instruction, alt values. More... | |
qspi_status_t | command_transfer (qspi_inst_t instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length) |
Perform a transaction to write to an address(a control register) and get the status results. More... | |
A QSPI Driver, used for communicating with QSPI slave devices.
The default format is set to Quad-SPI(1-1-1), and a clock frequency of 1MHz Most QSPI devices will also require Chip Select which is indicated by ssel.
Example:
QSPI | ( | PinName | io0, |
PinName | io1, | ||
PinName | io2, | ||
PinName | io3, | ||
PinName | sclk, | ||
PinName | ssel = NC , |
||
int | mode = 0 |
||
) |
Create a QSPI master connected to the specified pins.
io0-io3 is used to specify the Pins used for Quad SPI mode
io0 | 1st IO pin used for sending/receiving data during data phase of a transaction |
io1 | 2nd IO pin used for sending/receiving data during data phase of a transaction |
io2 | 3rd IO pin used for sending/receiving data during data phase of a transaction |
io3 | 4th IO pin used for sending/receiving data during data phase of a transaction |
sclk | QSPI Clock pin |
ssel | QSPI chip select pin |
mode | Clock polarity and phase mode (0 - 3) of SPI (Default: Mode=0 uses CPOL=0, CPHA=0, Mode=1 uses CPOL=1, CPHA=1) |
QSPI | ( | const qspi_pinmap_t & | pinmap, |
int | mode = 0 |
||
) |
qspi_status_t configure_format | ( | qspi_bus_width_t | inst_width, |
qspi_bus_width_t | address_width, | ||
qspi_address_size_t | address_size, | ||
qspi_bus_width_t | alt_width, | ||
qspi_alt_size_t | alt_size, | ||
qspi_bus_width_t | data_width, | ||
int | dummy_cycles | ||
) |
Configure the data transmission format.
inst_width | Bus width used by instruction phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) |
address_width | Bus width used by address phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) |
address_size | Size in bits used by address phase(Valid values are QSPI_CFG_ADDR_SIZE_8, QSPI_CFG_ADDR_SIZE_16, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_ADDR_SIZE_32) |
alt_width | Bus width used by alt phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) |
alt_size | Size in bits used by alt phase (must be a multiple of the number of bus lines indicated in alt_width) |
data_width | Bus width used by data phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) |
dummy_cycles | Number of dummy clock cycles to be used after alt phase |
qspi_status_t set_frequency | ( | int | hz = 1000000 | ) |
Set the qspi bus clock frequency.
hz | SCLK frequency in hz (default = 1MHz) |
qspi_status_t read | ( | int | address, |
char * | rx_buffer, | ||
size_t * | rx_length | ||
) |
Read from QSPI peripheral with the preset read_instruction and alt_value.
address | Address to be accessed in QSPI peripheral |
rx_buffer | Buffer for data to be read from the peripheral |
rx_length | Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read |
qspi_status_t write | ( | int | address, |
const char * | tx_buffer, | ||
size_t * | tx_length | ||
) |
Write to QSPI peripheral using custom write instruction.
address | Address to be accessed in QSPI peripheral |
tx_buffer | Buffer containing data to be sent to peripheral |
tx_length | Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written |
qspi_status_t read | ( | qspi_inst_t | instruction, |
int | alt, | ||
int | address, | ||
char * | rx_buffer, | ||
size_t * | rx_length | ||
) |
Read from QSPI peripheral using custom read instruction, alt values.
instruction | Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase |
alt | Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase |
address | Address to be accessed in QSPI peripheral |
rx_buffer | Buffer for data to be read from the peripheral |
rx_length | Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read |
qspi_status_t write | ( | qspi_inst_t | instruction, |
int | alt, | ||
int | address, | ||
const char * | tx_buffer, | ||
size_t * | tx_length | ||
) |
Write to QSPI peripheral using custom write instruction, alt values.
instruction | Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase |
alt | Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase |
address | Address to be accessed in QSPI peripheral |
tx_buffer | Buffer containing data to be sent to peripheral |
tx_length | Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written |
qspi_status_t command_transfer | ( | qspi_inst_t | instruction, |
int | address, | ||
const char * | tx_buffer, | ||
size_t | tx_length, | ||
const char * | rx_buffer, | ||
size_t | rx_length | ||
) |
Perform a transaction to write to an address(a control register) and get the status results.
instruction | Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase |
address | Some instruction might require address. Use -1 if no address |
tx_buffer | Buffer containing data to be sent to peripheral |
tx_length | Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written |
rx_buffer | Buffer for data to be read from the peripheral |
rx_length | Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read |