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
[driver] DW3110 UWB radio #1124
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: Elias H. <46895028+kingelilol@users.noreply.github.com>
Co-authored-by: Elias H. <46895028+kingelilol@users.noreply.github.com>
|
||
modm::ResumableResult<bool> | ||
receive(void); | ||
uint8_t receive_rx_data[20]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not std::array
? (And in a lot of other places too)
template<modm::Dw3110Register::SpiMode mode> | ||
modm::ResumableResult<void> | ||
send(uint16_t address, std::span<uint8_t> data); | ||
uint16_t send_tx_header = 0; | ||
uint32_t send_size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template<modm::Dw3110Register::SpiMode mode> | |
modm::ResumableResult<void> | |
send(uint16_t address, std::span<uint8_t> data); | |
uint16_t send_tx_header = 0; | |
uint32_t send_size = 0; | |
template<modm::Dw3110Register::SpiMode mode> | |
modm::ResumableResult<void> | |
send(uint16_t address, std::span<uint8_t> data); | |
uint16_t send_tx_header = 0; | |
uint32_t send_size = 0; |
uint8_t ping_result_data[4]; | ||
std::span<uint8_t> ping_result{ping_result_data}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a C array and std::span
?
I think you want to use std::array
...
template<typename SpiMaster, typename Cs, uint32_t buffer_size> | ||
modm::ResumableResult<bool> | ||
modm::Dw3110Phy<SpiMaster, Cs, buffer_size>::ping() | ||
{ | ||
RF_BEGIN(); | ||
RF_CALL_BLOCKING(send<modm::Dw3110Register::SpiMode::FULL_READ>( | ||
modm::Dw3110Register::DwRegister::DEV_ID, ping_result)); | ||
RF_END_RETURN((*((uint32_t *)ping_result.data()) & ~(0b1111)) == 0xDECA0300); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template<typename SpiMaster, typename Cs, uint32_t buffer_size> | |
modm::ResumableResult<bool> | |
modm::Dw3110Phy<SpiMaster, Cs, buffer_size>::ping() | |
{ | |
RF_BEGIN(); | |
RF_CALL_BLOCKING(send<modm::Dw3110Register::SpiMode::FULL_READ>( | |
modm::Dw3110Register::DwRegister::DEV_ID, ping_result)); | |
RF_END_RETURN((*((uint32_t *)ping_result.data()) & ~(0b1111)) == 0xDECA0300); | |
} | |
// private in class: `uint32_t tmp_u32;` | |
template<typename SpiMaster, typename Cs, uint32_t buffer_size> | |
modm::ResumableResult<bool> | |
modm::Dw3110Phy<SpiMaster, Cs, buffer_size>::ping() | |
{ | |
RF_BEGIN(); | |
RF_CALL(send<modm::Dw3110Register::SpiMode::FULL_READ>(modm::Dw3110Register::DwRegister::DEV_ID, tmp_u32)); | |
tmp_u32 =& ~0b1111; | |
RF_RETURN(tmp_u32 == 0xDECA0300); | |
RF_END(); | |
} |
RF_BEGIN(); | ||
RF_END_RETURN_CALL(send<mode>(address, std::span<uint8_t>())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be abbreviated:
RF_BEGIN(); | |
RF_END_RETURN_CALL(send<mode>(address, std::span<uint8_t>())); | |
return send<mode>(address, std::span<uint8_t>()); |
(But I don't understand what the inplace created std::span
is meant to do.)
Support for other DW3xxx chips