Skip to content

Commit

Permalink
Merge pull request #182 from aabadie/power_radio_enh
Browse files Browse the repository at this point in the history
nrf53: various improvements
  • Loading branch information
aabadie authored Apr 14, 2023
2 parents 4820618 + 3980b39 commit 92ae62c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion bsp/nrf/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ void db_radio_init(radio_cb_t callback, db_radio_ble_mode_t mode) {
NRF_RADIO->MODE = ((RADIO_MODE_MODE_Ble_1Mbit + mode) << RADIO_MODE_MODE_Pos); // Configure BLE mode
#if defined(NRF5340_XXAA) && defined(NRF_NETWORK)
// From errata v1.6 - 3.15 [117] RADIO: Changing MODE requires additional configuration
*((volatile uint32_t *)0x41008588) = *((volatile uint32_t *)0x01FF0080);
if (mode == DB_RADIO_BLE_2MBit) {
*((volatile uint32_t *)0x41008588) = *((volatile uint32_t *)0x01FF0084);
} else {
*((volatile uint32_t *)0x41008588) = *((volatile uint32_t *)0x01FF0080);
}

#endif

if (mode == DB_RADIO_BLE_1MBit || mode == DB_RADIO_BLE_2MBit) {
Expand Down
6 changes: 4 additions & 2 deletions bsp/nrf/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ static uart_vars_t _uart_vars; ///< variable handling the UART context
void db_uart_init(const gpio_t *rx_pin, const gpio_t *tx_pin, uint32_t baudrate, uart_rx_cb_t callback) {

#if defined(NRF5340_XXAA)
// On nrf53 configure constant latency mode for better performances
NRF_POWER->TASKS_CONSTLAT = 1;
if (baudrate > 460800) {
// On nrf53 configure constant latency mode for better performances with high baudrates
NRF_POWER->TASKS_CONSTLAT = 1;
}
#endif

// configure UART pins (RX as input, TX as output);
Expand Down
6 changes: 6 additions & 0 deletions projects/03app_nrf5340_net/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ void radio_callback(uint8_t *packet, uint8_t length) {
//=========================== main ==============================================

int main(void) {

#if defined(NRF5340_XXAA)
// Configure constant latency mode for better performances
NRF_POWER_NS->TASKS_CONSTLAT = 1;
#endif

NRF_IPC_NS->INTENSET = 1 << DB_IPC_CHAN_REQ;
NRF_IPC_NS->SEND_CNF[DB_IPC_CHAN_ACK] = 1 << DB_IPC_CHAN_ACK;
NRF_IPC_NS->SEND_CNF[DB_IPC_CHAN_RADIO_RX] = 1 << DB_IPC_CHAN_RADIO_RX;
Expand Down

0 comments on commit 92ae62c

Please sign in to comment.