Skip to content

fix example code in QSPI.h #7991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions drivers/QSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,27 @@ namespace mbed {
*
* #include "mbed.h"
*
* #define CMD_WRITE 0x02
* #define CMD_READ 0x03
* #define ADDRESS 0x1000
*
* // hardware ssel (where applicable)
* QSPI qspi_device(QSPI_PIN_IO0, QSPI_PIN_IO1, QSPI_PIN_IO2, QSPI_PIN_IO3, QSPI_PIN_SCK, QSPI_PIN_CSN); // io0, io1, io2, io3, sclk, ssel
* QSPI qspi_device(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN); // io0, io1, io2, io3, sclk, ssel
*
*
* int main() {
* char tx_buf[] = { 0x11, 0x22, 0x33, 0x44 };
* char rx_buf[4];
* int buf_len = sizeof(tx_buf);
*
* int result = qspi_device.write( 0x12 , 0x100000 , 0 , tx_buf, &buf_len );
* if( !result ) printf("Write failed");
* int result = qspi_device.read( 0x13 , 0x100000 , 0 , rx_buf, &buf_len );
* if( !result ) printf("Read failed");
* qspi_status_t result = qspi_device.write(CMD_WRITE, 0, ADDRESS, tx_buf, &buf_len);
* if (result != QSPI_STATUS_OK) {
* printf("Write failed");
* }
* result = qspi_device.read(CMD_READ, 0, ADDRESS, rx_buf, &buf_len);
* if (result != QSPI_STATUS_OK) {
* printf("Read failed");
* }
*
* }
* @endcode
Expand Down