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

PLEN has to be configured to 16bit when using 2MBit; not doing so res… #136

Merged
merged 1 commit into from
Nov 17, 2023
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
37 changes: 15 additions & 22 deletions bluetoe/bindings/nordic/nrf52/nrf52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ namespace nrf52_details
override_correction< NRF_FICR_Type >( NRF_FICR, nrf_radio );

nrf_radio->MODE = RADIO_MODE_MODE_Ble_1Mbit << RADIO_MODE_MODE_Pos;
nrf_radio->MODECNF0 =
( RADIO_MODECNF0_DTX_Center << RADIO_MODECNF0_DTX_Pos );

nrf_radio->PCNF0 =
( 1 << RADIO_PCNF0_S0LEN_Pos ) |
Expand Down Expand Up @@ -428,11 +430,19 @@ namespace nrf52_details
nrf_radio->INTENCLR = 0xffffffff;
}

static void config_phy( bool transmit_2mbit )
{
nrf_radio->MODE =
( transmit_2mbit ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;

nrf_radio->PCNF0 = ( nrf_radio->PCNF0 & ~RADIO_PCNF0_PLEN_Msk )
| ( ( transmit_2mbit ? RADIO_PCNF0_PLEN_16bit : RADIO_PCNF0_PLEN_8bit ) << RADIO_PCNF0_PLEN_Pos );
}

void radio_hardware_without_crypto_support::configure_transmit_train(
const bluetoe::link_layer::write_buffer& transmit_data )
{
nrf_radio->MODE =
( transmit_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;
config_phy( transmit_2mbit_ );

nrf_radio->SHORTS =
RADIO_SHORTS_READY_START_Msk
Expand All @@ -456,13 +466,6 @@ namespace nrf52_details
{
assert( transmit_data.buffer );

nrf_radio->MODE =
( transmit_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;

nrf_radio->SHORTS =
RADIO_SHORTS_READY_START_Msk
| RADIO_SHORTS_END_DISABLE_Msk;

nrf_ppi->CHENCLR = all_preprogramed_ppi_channels_mask;

nrf_radio->PACKETPTR = reinterpret_cast< std::uint32_t >( transmit_data.buffer );
Expand All @@ -472,8 +475,7 @@ namespace nrf52_details
void radio_hardware_without_crypto_support::configure_receive_train(
const bluetoe::link_layer::read_buffer& receive_buffer )
{
nrf_radio->MODE =
( receive_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;
config_phy( receive_2mbit_ );

nrf_radio->SHORTS =
RADIO_SHORTS_READY_START_Msk
Expand Down Expand Up @@ -867,8 +869,7 @@ namespace nrf52_details
void radio_hardware_with_crypto_support::configure_transmit_train(
const bluetoe::link_layer::write_buffer& transmit_data )
{
nrf_radio->MODE =
( transmit_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;
config_phy( transmit_2mbit_ );

nrf_radio->SHORTS =
RADIO_SHORTS_READY_START_Msk
Expand All @@ -892,15 +893,8 @@ namespace nrf52_details
void radio_hardware_with_crypto_support::configure_final_transmit(
const bluetoe::link_layer::write_buffer& transmit_data )
{
nrf_radio->MODE =
( transmit_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;

nrf_ppi->CHENCLR = all_preprogramed_ppi_channels_mask;

nrf_radio->SHORTS =
RADIO_SHORTS_READY_START_Msk
| RADIO_SHORTS_END_DISABLE_Msk;

// only encrypt none empty PDUs
if ( transmit_encrypted_ && transmit_data.buffer[ 1 ] != 0 )
{
Expand Down Expand Up @@ -938,8 +932,7 @@ namespace nrf52_details
void radio_hardware_with_crypto_support::configure_receive_train(
const bluetoe::link_layer::read_buffer& receive_buffer )
{
nrf_radio->MODE =
( receive_2mbit_ ? RADIO_MODE_MODE_Ble_2Mbit : RADIO_MODE_MODE_Ble_1Mbit ) << RADIO_MODE_MODE_Pos;
config_phy( receive_2mbit_ );

if ( receive_encrypted_ )
{
Expand Down