49 void jesd216_start(BUSDriver *busp,
const BUSConfig *config) {
51 #if JESD216_BUS_MODE == JESD216_BUS_MODE_SPI 58 void jesd216_stop(BUSDriver *busp) {
60 #if JESD216_BUS_MODE == JESD216_BUS_MODE_SPI 67 void jesd216_cmd(BUSDriver *busp, uint32_t cmd) {
68 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 71 mode.cfg = QSPI_CFG_CMD(cmd) |
72 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 73 QSPI_CFG_CMD_MODE_ONE_LINE;
74 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 75 QSPI_CFG_CMD_MODE_TWO_LINES;
77 QSPI_CFG_CMD_MODE_FOUR_LINES;
92 void jesd216_cmd_receive(BUSDriver *busp,
96 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 99 mode.cfg = QSPI_CFG_CMD(cmd) |
100 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 101 QSPI_CFG_CMD_MODE_ONE_LINE |
102 QSPI_CFG_DATA_MODE_ONE_LINE;
103 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 104 QSPI_CFG_CMD_MODE_TWO_LINES |
105 QSPI_CFG_DATA_MODE_TWO_LINES;
107 QSPI_CFG_CMD_MODE_FOUR_LINES |
108 QSPI_CFG_DATA_MODE_FOUR_LINES;
125 void jesd216_cmd_send(BUSDriver *busp,
129 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 132 mode.cfg = QSPI_CFG_CMD(cmd) |
133 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 134 QSPI_CFG_CMD_MODE_ONE_LINE |
135 QSPI_CFG_DATA_MODE_ONE_LINE;
136 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 137 QSPI_CFG_CMD_MODE_TWO_LINES |
138 QSPI_CFG_DATA_MODE_TWO_LINES;
140 QSPI_CFG_CMD_MODE_FOUR_LINES |
141 QSPI_CFG_DATA_MODE_FOUR_LINES;
158 void jesd216_cmd_addr(BUSDriver *busp,
161 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 164 mode.cfg = QSPI_CFG_CMD(cmd) |
165 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 166 QSPI_CFG_CMD_MODE_ONE_LINE |
167 QSPI_CFG_ADDR_MODE_ONE_LINE |
168 QSPI_CFG_ADDR_SIZE_24;
169 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 170 QSPI_CFG_CMD_MODE_TWO_LINES |
171 QSPI_CFG_ADDR_MODE_TWO_LINES |
172 QSPI_CFG_ADDR_SIZE_24;
174 QSPI_CFG_CMD_MODE_FOUR_LINES |
175 QSPI_CFG_ADDR_MODE_FOUR_LINES |
176 QSPI_CFG_ADDR_SIZE_24;
187 buf[1] = (uint8_t)(offset >> 16);
188 buf[2] = (uint8_t)(offset >> 8);
189 buf[3] = (uint8_t)(offset >> 0);
195 void jesd216_cmd_addr_send(BUSDriver *busp,
200 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 203 mode.cfg = QSPI_CFG_CMD(cmd & 0xFFU) |
204 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 205 QSPI_CFG_CMD_MODE_ONE_LINE |
206 QSPI_CFG_ADDR_MODE_ONE_LINE |
207 QSPI_CFG_DATA_MODE_ONE_LINE;
208 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 209 QSPI_CFG_CMD_MODE_TWO_LINES |
210 QSPI_CFG_ADDR_MODE_TWO_LINES |
211 QSPI_CFG_DATA_MODE_TWO_LINES;
213 QSPI_CFG_CMD_MODE_FOUR_LINES |
214 QSPI_CFG_ADDR_MODE_FOUR_LINES |
215 QSPI_CFG_DATA_MODE_FOUR_LINES;
219 if ((cmd & JESD216_CMD_EXTENDED_ADDRESSING) == 0) {
220 mode .cfg |= QSPI_CFG_ADDR_SIZE_24;
223 mode .cfg |= QSPI_CFG_ADDR_SIZE_32;
234 buf[1] = (uint8_t)(offset >> 16);
235 buf[2] = (uint8_t)(offset >> 8);
236 buf[3] = (uint8_t)(offset >> 0);
243 void jesd216_cmd_addr_receive(BUSDriver *busp,
248 #if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI 251 mode.cfg = QSPI_CFG_CMD(cmd & 0xFFU) |
252 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 253 QSPI_CFG_CMD_MODE_ONE_LINE |
254 QSPI_CFG_ADDR_MODE_ONE_LINE |
255 QSPI_CFG_DATA_MODE_ONE_LINE;
256 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 257 QSPI_CFG_CMD_MODE_TWO_LINES |
258 QSPI_CFG_ADDR_MODE_TWO_LINES |
259 QSPI_CFG_ADDR_SIZE_24 |
260 QSPI_CFG_DATA_MODE_TWO_LINES;
262 QSPI_CFG_CMD_MODE_FOUR_LINES |
263 QSPI_CFG_ADDR_MODE_FOUR_LINES |
264 QSPI_CFG_DATA_MODE_FOUR_LINES;
268 if ((cmd & JESD216_CMD_EXTENDED_ADDRESSING) == 0) {
269 mode .cfg |= QSPI_CFG_ADDR_SIZE_24;
272 mode .cfg |= QSPI_CFG_ADDR_SIZE_32;
283 buf[1] = (uint8_t)(offset >> 16);
284 buf[2] = (uint8_t)(offset >> 8);
285 buf[3] = (uint8_t)(offset >> 0);
292 #if (JESD216_BUS_MODE != JESD216_BUS_MODE_SPI) || defined(__DOXYGEN__) 293 void jesd216_cmd_addr_dummy_receive(BUSDriver *busp,
301 mode.cfg = QSPI_CFG_CMD(cmd & 0xFFU) |
302 #if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L 303 QSPI_CFG_CMD_MODE_ONE_LINE |
304 QSPI_CFG_ADDR_MODE_ONE_LINE |
305 QSPI_CFG_DUMMY_CYCLES(dummy) |
306 QSPI_CFG_DATA_MODE_ONE_LINE;
307 #elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L 308 QSPI_CFG_CMD_MODE_TWO_LINES |
309 QSPI_CFG_ADDR_MODE_TWO_LINES |
310 QSPI_CFG_DUMMY_CYCLES(dummy) |
311 QSPI_CFG_DATA_MODE_TWO_LINES;
313 QSPI_CFG_CMD_MODE_FOUR_LINES |
314 QSPI_CFG_ADDR_MODE_FOUR_LINES |
315 QSPI_CFG_DUMMY_CYCLES(dummy) |
316 QSPI_CFG_DATA_MODE_FOUR_LINES;
320 if ((cmd & JESD216_CMD_EXTENDED_ADDRESSING) == 0) {
321 mode .cfg |= QSPI_CFG_ADDR_SIZE_24;
324 mode .cfg |= QSPI_CFG_ADDR_SIZE_32;
333 #if ((JESD216_BUS_MODE != JESD216_BUS_MODE_SPI) && \ 334 (JESD216_SHARED_BUS == TRUE)) || defined(__DOXYGEN__) 335 void jesd216_bus_acquire(BUSDriver *busp,
const BUSConfig *config) {
340 if (busp->config != config) {
345 void jesd216_bus_release(BUSDriver *busp) {
349 #elif (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) && \ 350 (JESD216_SHARED_BUS == TRUE) 351 void jesd216_bus_acquire(BUSDriver *busp,
const BUSConfig *config) {
354 if (busp->config != config) {
359 void jesd216_bus_release(BUSDriver *busp) {
364 #define jesd216_bus_acquire(busp) 365 #define jesd216_bus_release(busp) void spiUnselect(SPIDriver *spip)
Deasserts the slave select signal.
void spiSelect(SPIDriver *spip)
Asserts the slave select signal and prepares for transfers.
void spiReceive(SPIDriver *spip, size_t n, void *rxbuf)
Receives data from the SPI bus.
void spiStart(SPIDriver *spip, const SPIConfig *config)
Configures and activates the SPI peripheral.
void qspiReleaseBus(QSPIDriver *qspip)
Releases exclusive access to the QSPI bus.
void spiReleaseBus(SPIDriver *spip)
Releases exclusive access to the SPI bus.
JESD216 compliant flash driver class header.
void spiAcquireBus(SPIDriver *spip)
Gains exclusive access to the SPI bus.
void qspiStart(QSPIDriver *qspip, const QSPIConfig *config)
Configures and activates the QSPI peripheral.
void qspiReceive(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the QSPI bus.
void qspiSend(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the QSPI bus.
uint32_t flash_offset_t
Type of a flash offset.
void qspiAcquireBus(QSPIDriver *qspip)
Gains exclusive access to the QSPI bus.
void qspiCommand(QSPIDriver *qspip, const qspi_command_t *cmdp)
Sends a command without data phase.
void spiSend(SPIDriver *spip, size_t n, const void *txbuf)
Sends data over the SPI bus.
void qspiStop(QSPIDriver *qspip)
Deactivates the QSPI peripheral.
void spiStop(SPIDriver *spip)
Deactivates the SPI peripheral.
Type of a QSPI command descriptor.