-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update Spi component to return a status on device access #4452
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
base: devel
Are you sure you want to change the base?
Changes from all commits
3791afa
467b59d
1436082
6820dfc
76c3412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,13 +34,26 @@ | |
| // Handler implementations for user-defined typed input ports | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| // @ DEPRECATED: Use SpiWriteRead port instead (same operation with a return value) | ||
| void LinuxSpiDriverComponentImpl::SpiReadWrite_handler(const FwIndexType portNum, | ||
| Fw::Buffer& writeBuffer, | ||
| Fw::Buffer& readBuffer) { | ||
| FW_ASSERT(portNum >= 0, static_cast<FwAssertArgType>(portNum)); | ||
| FW_ASSERT(writeBuffer.isValid()); | ||
| FW_ASSERT(readBuffer.isValid()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this should be ok; but also Googling around seems to suggest there might be use cases for unidirectional SPI, so I wonder if we really should assert here? I'd like to get someone else's eyes on this to confirm, since we weren't asserting before. |
||
| (void)SpiWriteRead_handler(portNum, writeBuffer, readBuffer); | ||
|
||
| } | ||
|
|
||
| SpiStatus LinuxSpiDriverComponentImpl::SpiWriteRead_handler(const FwIndexType portNum, | ||
Check noticeCode scanning / CodeQL Long function without assertion Note
All functions of more than 10 lines should have at least one assertion.
|
||
| Fw::Buffer& writeBuffer, | ||
| Fw::Buffer& readBuffer) { | ||
| FW_ASSERT(portNum >= 0, static_cast<FwAssertArgType>(portNum)); | ||
| FW_ASSERT(writeBuffer.isValid()); | ||
| FW_ASSERT(readBuffer.isValid()); | ||
| FW_ASSERT(writeBuffer.getSize() == readBuffer.getSize()); | ||
|
|
||
| if (this->m_fd == -1) { | ||
| return; | ||
| return SpiStatus::SPI_OPEN_ERR; | ||
| } | ||
|
|
||
| spi_ioc_transfer tr; | ||
|
|
@@ -64,9 +77,12 @@ | |
|
|
||
| if (stat < 1) { | ||
| this->log_WARNING_HI_SPI_WriteError(this->m_device, this->m_select, stat); | ||
| return SpiStatus::SPI_OTHER_ERR; | ||
| } | ||
| this->m_bytes += readBuffer.getSize(); | ||
| this->tlmWrite_SPI_Bytes(this->m_bytes); | ||
|
|
||
| return SpiStatus::SPI_OK; | ||
| } | ||
|
|
||
| bool LinuxSpiDriverComponentImpl::open(FwIndexType device, FwIndexType select, SpiFrequency clock, SpiMode spiMode) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,28 @@ | ||
| module Drv { | ||
|
|
||
| port SpiWriteRead( | ||
| ref writeBuffer: Fw.Buffer | ||
| ref readBuffer: Fw.Buffer | ||
| ) -> Drv.SpiStatus | ||
|
|
||
| @ DEPRECATED: Use SpiWriteRead port instead (same operation with a return value) | ||
| port SpiReadWrite( | ||
| ref writeBuffer: Fw.Buffer | ||
| ref readBuffer: Fw.Buffer | ||
| ref readBuffer: Fw.Buffer | ||
| ) | ||
|
|
||
| } | ||
|
|
||
| module Drv { | ||
|
|
||
| enum SpiStatus : U8 { | ||
| SPI_OK = 0 @< Transaction okay | ||
| SPI_OPEN_ERR = 1 @< SPI driver failed to open device | ||
| SPI_CONFIG_ERR = 2 @< SPI read failed | ||
| SPI_MISMATCH_ERR = 3 @< SPI read failed | ||
| SPI_WRITE_ERR = 4 @< SPI write failed | ||
| SPI_OTHER_ERR = 5 @< Other errors that do not fit | ||
| } | ||
|
|
||
| } | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.