High level interface for interacting with the Cypress Quad-SPI interface.
The QSPI block supports sending commands to and receiving commands from an another device (often an external memory) via single, dual, quad, or octal SPI.
|
| cy_rslt_t | cyhal_qspi_init (cyhal_qspi_t *obj, cyhal_gpio_t io0, cyhal_gpio_t io1, cyhal_gpio_t io2, cyhal_gpio_t io3, cyhal_gpio_t io4, cyhal_gpio_t io5, cyhal_gpio_t io6, cyhal_gpio_t io7, cyhal_gpio_t sclk, cyhal_gpio_t ssel, uint32_t hz, uint8_t mode) |
| |
| void | cyhal_qspi_free (cyhal_qspi_t *obj) |
| |
| cy_rslt_t | cyhal_qspi_set_frequency (cyhal_qspi_t *obj, uint32_t hz) |
| |
| cy_rslt_t | cyhal_qspi_read (cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, void *data, size_t *length) |
| |
| cy_rslt_t | cyhal_qspi_read_async (cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, void *data, size_t *length) |
| |
| cy_rslt_t | cyhal_qspi_write (cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, const void *data, size_t *length) |
| |
| cy_rslt_t | cyhal_qspi_write_async (cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, const void *data, size_t *length) |
| |
| cy_rslt_t | cyhal_qspi_transfer (cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, const void *tx_data, size_t tx_size, void *rx_data, size_t rx_size) |
| |
| void | cyhal_qspi_register_callback (cyhal_qspi_t *obj, cyhal_qspi_event_callback_t callback, void *callback_arg) |
| |
| void | cyhal_qspi_enable_event (cyhal_qspi_t *obj, cyhal_qspi_event_t event, uint8_t intrPriority, bool enable) |
| |
◆ cyhal_qspi_command_t
| struct cyhal_qspi_command_t |
◆ cyhal_qspi_command_t.instruction
| struct cyhal_qspi_command_t.instruction |
| Data Fields |
|
cyhal_qspi_bus_width_t |
bus_width |
Bus width for the instruction >
|
|
uint8_t |
value |
Instruction value >
|
|
bool |
disabled |
Instruction phase skipped if disabled is set to true >
|
◆ cyhal_qspi_command_t.address
| struct cyhal_qspi_command_t.address |
| Data Fields |
|
cyhal_qspi_bus_width_t |
bus_width |
Bus width for the address >
|
|
cyhal_qspi_size_t |
size |
Address size >
|
|
uint32_t |
value |
Address value >
|
|
bool |
disabled |
Address phase skipped if disabled is set to true >
|
◆ cyhal_qspi_command_t.mode_bits
| struct cyhal_qspi_command_t.mode_bits |
| Data Fields |
|
cyhal_qspi_bus_width_t |
bus_width |
Bus width for mode bits >
|
|
cyhal_qspi_size_t |
size |
Mode bits size >
|
|
uint32_t |
value |
Mode bits value >
|
|
bool |
disabled |
Mode bits phase skipped if disabled is set to true >
|
◆ cyhal_qspi_command_t.data
| struct cyhal_qspi_command_t.data |
◆ CYHAL_QSPI_RSLT_ERR_BUS_WIDTH
◆ CYHAL_QSPI_RSLT_ERR_PIN
◆ CYHAL_QSPI_RSLT_ERR_DATA_SEL
◆ CYHAL_QSPI_RSLT_ERR_INSTANCE
QSPI instance related Error. >
◆ cyhal_qspi_event_callback_t
| typedef void(* cyhal_qspi_event_callback_t) (void *callback_arg, cyhal_qspi_event_t event) |
Handler for QSPI callbacks
◆ cyhal_qspi_bus_width_t
QSPI Bus width
Some parts of commands provide variable bus width
◆ cyhal_qspi_size_t
◆ cyhal_qspi_event_t
QSPI interrupt triggers
| Enumerator |
|---|
| CYHAL_QSPI_EVENT_NONE | No event >
|
| CYHAL_QSPI_IRQ_TRANSMIT_DONE | Async transmit done. >
|
| CYHAL_QSPI_IRQ_RECEIVE_DONE | Async receive done. >
|
◆ cyhal_qspi_init()
| cy_rslt_t cyhal_qspi_init |
( |
cyhal_qspi_t * |
obj, |
|
|
cyhal_gpio_t |
io0, |
|
|
cyhal_gpio_t |
io1, |
|
|
cyhal_gpio_t |
io2, |
|
|
cyhal_gpio_t |
io3, |
|
|
cyhal_gpio_t |
io4, |
|
|
cyhal_gpio_t |
io5, |
|
|
cyhal_gpio_t |
io6, |
|
|
cyhal_gpio_t |
io7, |
|
|
cyhal_gpio_t |
sclk, |
|
|
cyhal_gpio_t |
ssel, |
|
|
uint32_t |
hz, |
|
|
uint8_t |
mode |
|
) |
| |
Initialize QSPI peripheral.
It should initialize QSPI pins (io0-io7, sclk and ssel), set frequency, clock polarity and phase mode. The clock for the peripheral should be enabled
- Parameters
-
| [out] | obj | QSPI object |
| [in] | io0 | Data pin 0 |
| [in] | io1 | Data pin 1 |
| [in] | io2 | Data pin 2 |
| [in] | io3 | Data pin 3 |
| [in] | io4 | Data pin 4 |
| [in] | io5 | Data pin 5 |
| [in] | io6 | Data pin 6 |
| [in] | io7 | Data pin 7 |
| [in] | sclk | The clock pin |
| [in] | ssel | The chip select pin |
| [in] | hz | The bus frequency |
| [in] | mode | Clock polarity and phase mode (0 - 3) |
- Returns
- The status of the init request
◆ cyhal_qspi_free()
Deinitilize QSPI peripheral
It should release pins that are associated with the QSPI object, and disable clocks for QSPI peripheral module that was associated with the object
- Parameters
-
◆ cyhal_qspi_set_frequency()
Set the QSPI baud rate
Actual frequency may differ from the desired frequency due to available dividers and the bus clock Configures the QSPI peripheral's baud rate
- Parameters
-
| [in] | obj | The QSPI object to configure |
| [in] | hz | The baud rate in Hz |
- Returns
- The status of the set_frequency request
◆ cyhal_qspi_read()
Receive a command and block of data, synchronously.
- Parameters
-
| [in] | obj | QSPI object |
| [in] | command | QSPI command |
| [out] | data | RX buffer |
| [in,out] | length | in - RX buffer length in bytes, out - number of bytes read |
- Returns
- The status of the read request
◆ cyhal_qspi_read_async()
Receive a command and block of data in asynchronous mode. This requires __enable_irq() to have been called in order to work. To receive a notification when the read is complete, enable and register a callback using cyhal_qspi_irq_enable and cyhal_qspi_register_irq.
- Parameters
-
| [in] | obj | QSPI object |
| [in] | command | QSPI command |
| [out] | data | RX buffer |
| [in,out] | length | in - RX buffer length in bytes, out - number of bytes read |
- Returns
- The status of the read request
◆ cyhal_qspi_write()
Send a command and block of data, synchronously.
- Parameters
-
| [in] | obj | QSPI object |
| [in] | command | QSPI command |
| [in] | data | TX buffer |
| [in,out] | length | in - TX buffer length in bytes, out - number of bytes written |
- Returns
- The status of the write request
◆ cyhal_qspi_write_async()
Send a command and block of data in asynchronous mode. This requires __enable_irq() to have been called in order to work. To receive a notification when the read is complete, enable and register a callback using cyhal_qspi_irq_enable and cyhal_qspi_register_irq.
- Parameters
-
| [in] | obj | QSPI object |
| [in] | command | QSPI command |
| [in] | data | TX buffer |
| [in,out] | length | in - TX buffer length in bytes, out - number of bytes written |
- Returns
- The status of the write request
◆ cyhal_qspi_transfer()
Send a command (and optionally data) and get the response. Can be used to send/receive device specific commands
- Parameters
-
| [in] | obj | QSPI object |
| [in] | command | QSPI command |
| [in] | tx_data | TX buffer |
| [in,out] | tx_size | in - TX buffer length in bytes, out - bytes actually written |
| [out] | rx_data | RX buffer |
| [in,out] | rx_size | in - RX buffer length in bytes, out - bytes actually read |
- Returns
- The status of the transfer request
◆ cyhal_qspi_register_callback()
The QSPI event handler registration
- Parameters
-
| [in] | obj | The QSPI object |
| [in] | callback | The callback handler which will be invoked when the interrupt fires |
| [in] | callback_arg | Generic argument that will be provided to the handler when called |
◆ cyhal_qspi_enable_event()
Configure QSPI interrupt enablement.
- Parameters
-
| [in] | obj | The QSPI object |
| [in] | event | The QSPI event type |
| [in] | intrPriority | The priority for NVIC interrupt events |
| [in] | enable | True to turn on interrupts, False to turn off |