Skip to content
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

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

rleh
Copy link
Member

@rleh rleh commented Jan 29, 2024

  • Driver
  • Example
  • Tested on real hardware
  • Future: Support for other DW3xxx chips

rleh and others added 2 commits January 29, 2024 22:35
Co-authored-by: Elias H. <46895028+kingelilol@users.noreply.github.com>
Co-authored-by: Elias H. <46895028+kingelilol@users.noreply.github.com>
@rleh rleh added this to the 2024q1 milestone Jan 29, 2024
@salkinium salkinium removed this from the 2024q1 milestone Mar 30, 2024
@rleh rleh added this to the 2024q2 milestone Apr 2, 2024

modm::ResumableResult<bool>
receive(void);
uint8_t receive_rx_data[20];
Copy link
Member Author

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)

Comment on lines +75 to +79
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;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
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;

Comment on lines +61 to +62
uint8_t ping_result_data[4];
std::span<uint8_t> ping_result{ping_result_data};
Copy link
Member Author

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...

Comment on lines +31 to +39
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);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
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();
}

Comment on lines +46 to +47
RF_BEGIN();
RF_END_RETURN_CALL(send<mode>(address, std::span<uint8_t>()));
Copy link
Member Author

Choose a reason for hiding this comment

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

This can be abbreviated:

Suggested change
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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants