20#include "platform/platform.h"
22#if DEVICE_OSPI || defined(DOXYGEN_ONLY)
24#include "hal/ospi_api.h"
25#include "rtos/Mutex.h"
26#include "platform/SingletonPtr.h"
27#include "platform/NonCopyable.h"
29#define ONE_MHZ 1000000
31#define OSPI_NO_INST (-1)
110 OSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName io4, PinName io5, PinName io6, PinName io7,
111 PinName sclk, PinName ssel = NC, PinName dqs = NC,
int mode = 0);
122 OSPI(
const ospi_pinmap_t &pinmap,
int mode = 0);
123 OSPI(
const ospi_pinmap_t &&,
int = 0) =
delete;
142 ospi_inst_size_t inst_size,
143 ospi_bus_width_t address_width,
144 ospi_address_size_t address_size,
145 ospi_bus_width_t alt_width,
146 ospi_alt_size_t alt_size,
147 ospi_bus_width_t data_width,
167 ospi_status_t
read(
int address,
char *rx_buffer,
size_t *rx_length);
178 ospi_status_t
write(
int address,
const char *tx_buffer,
size_t *tx_length);
191 ospi_status_t
read(
ospi_inst_t instruction,
int alt,
int address,
char *rx_buffer,
size_t *rx_length);
204 ospi_status_t
write(
ospi_inst_t instruction,
int alt,
int address,
const char *tx_buffer,
size_t *tx_length);
218 ospi_status_t
command_transfer(
ospi_inst_t instruction,
int address,
const char *tx_buffer,
size_t tx_length,
const char *rx_buffer,
size_t rx_length);
220#if !defined(DOXYGEN_ONLY)
224 virtual void lock(
void);
228 virtual void unlock(
void);
233 ospi_bus_width_t _inst_width;
234 ospi_inst_size_t _inst_size;
235 ospi_bus_width_t _address_width;
236 ospi_address_size_t _address_size;
237 ospi_bus_width_t _alt_width;
238 ospi_alt_size_t _alt_size;
239 ospi_bus_width_t _data_width;
240 ospi_command_t _ospi_command;
241 unsigned int _num_dummy_cycles;
245 PinName _ospi_io0, _ospi_io1, _ospi_io2, _ospi_io3, _ospi_io4, _ospi_io5, _ospi_io6, _ospi_io7, _ospi_clk, _ospi_cs, _ospi_dqs;
246 const ospi_pinmap_t *_static_pinmap;
247 bool (
OSPI::* _init_func)(void);
251 bool _initialize_direct();
256 inline void _build_ospi_command(
ospi_inst_t instruction,
int address,
int alt);
Prevents generation of copy constructor and copy assignment operator in derived classes.
A OSPI Driver, used for communicating with OSPI slave devices.
ospi_status_t read(int address, char *rx_buffer, size_t *rx_length)
Read from OSPI peripheral with the preset read_instruction and alt_value.
ospi_status_t read(ospi_inst_t instruction, int alt, int address, char *rx_buffer, size_t *rx_length)
Read from OSPI peripheral using custom read instruction, alt values.
ospi_status_t configure_format(ospi_bus_width_t inst_width, ospi_inst_size_t inst_size, ospi_bus_width_t address_width, ospi_address_size_t address_size, ospi_bus_width_t alt_width, ospi_alt_size_t alt_size, ospi_bus_width_t data_width, int dummy_cycles)
Configure the data transmission format.
ospi_status_t write(int address, const char *tx_buffer, size_t *tx_length)
Write to OSPI peripheral using custom write instruction.
OSPI(const ospi_pinmap_t &pinmap, int mode=0)
Create a OSPI master connected to the specified pins.
ospi_status_t command_transfer(ospi_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.
ospi_status_t set_frequency(int hz=1000000)
Set the ospi bus clock frequency.
ospi_status_t write(ospi_inst_t instruction, int alt, int address, const char *tx_buffer, size_t *tx_length)
Write to OSPI peripheral using custom write instruction, alt values.
OSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName io4, PinName io5, PinName io6, PinName io7, PinName sclk, PinName ssel=NC, PinName dqs=NC, int mode=0)
Create a OSPI master connected to the specified pins.
int ospi_inst_t
Type representing a OSPI instruction.
Utility class for creating and using a singleton.