20 #include "platform/platform.h" 22 #if DEVICE_OSPI || defined(DOXYGEN_ONLY) 24 #include "hal/ospi_api.h" 25 #include "platform/PlatformMutex.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);
235 ospi_bus_width_t _inst_width;
236 ospi_inst_size_t _inst_size;
237 ospi_bus_width_t _address_width;
238 ospi_address_size_t _address_size;
239 ospi_bus_width_t _alt_width;
240 ospi_alt_size_t _alt_size;
241 ospi_bus_width_t _data_width;
242 ospi_command_t _ospi_command;
243 unsigned int _num_dummy_cycles;
247 PinName _ospi_io0, _ospi_io1, _ospi_io2, _ospi_io3, _ospi_io4, _ospi_io5, _ospi_io6, _ospi_io7, _ospi_clk, _ospi_cs, _ospi_dqs;
248 const ospi_pinmap_t *_static_pinmap;
249 bool (
OSPI::* _init_func)(void);
257 bool _initialize_direct();
262 inline void _build_ospi_command(ospi_inst_t instruction,
int address,
int alt);
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 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...
A OSPI Driver, used for communicating with OSPI slave devices.
Prevents generation of copy constructor and copy assignment operator in derived classes.
ospi_status_t set_frequency(int hz=1000000)
Set the ospi bus clock frequency.
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 write(int address, const char *tx_buffer, size_t *tx_length)
Write to OSPI peripheral using custom write instruction.
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.