Skip to content

QSPI: add contributing guide #454

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 6 commits into from
Apr 30, 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
45 changes: 38 additions & 7 deletions docs/reference/contributing/target/QuadSPI.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
<h2 id="quadspi-port">QuadSPI</h2>

[Include a brief description here.]
Implementing QSPI enables Mbed OS to communicate with external memories much faster than via SPI. Because the communication can be up to four lines between the host and a device.

The most common use case is an external memory to use as additional data storage.

<span class="warnings">**Warning:** We are changing the QSPI HAL API in an upcoming release of Mbed OS. You can find details on how it may affect you in the [Implementing the QSPI API](#implementing-the-qspi-api) section.

### Assumptions

#### Defined behavior

[Include any defined behavior in bullet format here.]
- A target implementaion covers most of the QSPI frame format (some targets might not provide the flexibility for setting all frame parameters).
- Command transfer - A target might provide additional functions for sending device-specific commands. If it does not, you can implement it using read and write functions. (This is target or driver dependent.)

#### Undefined behavior

[Include any undefined behavior in bullet format here.]
- Calling any function other than `qspi_init` before the initialization of the QSPI.

#### Potential bugs
#### Dependency

[Include any potential bugs in bullet format here.]
QSPI peripheral

### Implementing QuadSPI

[Include implementation information here.]
To make sure your platform is ready for the upcoming changes, you need to implement the future API and submit it in a separate pull request. You can find the API and specification for the new QuadSPI API in the following header file:

[![View code](https://www.mbed.com/embed/?type=library)](https://os-doc-builder.test.mbed.com/docs/development/feature-hal-spec-qspi-doxy/classmbed_1_1_q_s_p_i.html)

The target needs to define the `qspi_s` structure - target specific QSPI object.

Functions to implement:

```
qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName ssel, uint32_t hz, uint8_t mode);
qspi_status_t qspi_free(qspi_t *obj);
qspi_status_t qspi_frequency(qspi_t *obj, int hz);
qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void *data, size_t *length);
qspi_status_t qspi_command_transfer(qspi_t *obj, const qspi_command_t *command, const void *tx_data, size_t tx_size, void *rx_data, size_t rx_size);
qspi_status_t qspi_read(qspi_t *obj, const qspi_command_t *command, void *data, size_t *length);

```

Use `qspi_write` and `qspi_read` for data transfers. For communicating with a device, use `qspi_command_transfer`.

To enable the QSPI HAL, define `QSPI` in the targets.json file inside `device_has`:

```
"TARGET_NAME": {
"device_has": ["QSPI"]
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Is this on master? If so, please link to its Doxy on master. Then link to its Doxy on the feature branch. If not, please link only to the Doxy on the feature branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on master, only on feature branch. how to link (an example) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. If it's not on master, then the link toward the top of this section is the correct one. I'm assuming any testing pages will be on the same branch, too: https://os-doc-builder.test.mbed.com/docs/development/feature-hal-spec-qspi-doxy/annotated.html?

We generate the feature-branch Doxy from the .json. You can find the page by replacing the "mbed-os-api-doxy" of the usual Doxy URL with the slug from the .json. (You probably don't need to know how to do that. I'm just telling you in case you're curious.)

### Testing

[Include testing information here.]
To be implemented
Copy link
Contributor

@SenRamakri SenRamakri Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xc0170 Are we planning to expand on this "Testing" section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be added once the tests in the codebase (currently not implemented therefore this is empty)