Skip to content

Commit 4d01527

Browse files
cvinayakAnas Nashif
authored andcommitted
Bluetooth: controller: Minor refactor radio_tmr_start
Minor refactor of radio_tmr_start to reduced duplicate assignments common in if-then-else control path. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 60b37e4 commit 4d01527

File tree

1 file changed

+11
-30
lines changed
  • subsys/bluetooth/controller/hal/nrf5

1 file changed

+11
-30
lines changed

subsys/bluetooth/controller/hal/nrf5/radio.c

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -680,19 +680,10 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
680680
NRF_PPI->CH[1].TEP = (u32_t)&(NRF_TIMER0->TASKS_START);
681681
NRF_PPI->CHENSET = PPI_CHEN_CH1_Msk;
682682

683-
if (trx) {
684-
NRF_PPI->CH[0].EEP =
685-
(u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
686-
NRF_PPI->CH[0].TEP =
687-
(u32_t)&(NRF_RADIO->TASKS_TXEN);
688-
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
689-
} else {
690-
NRF_PPI->CH[0].EEP =
691-
(u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
692-
NRF_PPI->CH[0].TEP =
693-
(u32_t)&(NRF_RADIO->TASKS_RXEN);
694-
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
695-
}
683+
NRF_PPI->CH[0].EEP = (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
684+
NRF_PPI->CH[0].TEP = (trx) ? (u32_t)&(NRF_RADIO->TASKS_TXEN) :
685+
(u32_t)&(NRF_RADIO->TASKS_RXEN);
686+
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
696687

697688
#if !defined(CONFIG_BT_CTLR_TIFS_HW)
698689
NRF_TIMER1->TASKS_CLEAR = 1;
@@ -704,12 +695,10 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
704695
NRF_PPI->CH[8].EEP = (u32_t)&(NRF_RADIO->EVENTS_END);
705696
NRF_PPI->CH[8].TEP = (u32_t)&(NRF_TIMER1->TASKS_CLEAR);
706697

707-
NRF_PPI->CH[9].EEP = (u32_t)
708-
&(NRF_TIMER1->EVENTS_COMPARE[0]);
698+
NRF_PPI->CH[9].EEP = (u32_t)&(NRF_TIMER1->EVENTS_COMPARE[0]);
709699
NRF_PPI->CH[9].TEP = (u32_t)&(NRF_PPI->TASKS_CHG[0].DIS);
710700

711-
NRF_PPI->CH[10].EEP = (u32_t)
712-
&(NRF_TIMER1->EVENTS_COMPARE[1]);
701+
NRF_PPI->CH[10].EEP = (u32_t)&(NRF_TIMER1->EVENTS_COMPARE[1]);
713702
NRF_PPI->CH[10].TEP = (u32_t)&(NRF_PPI->TASKS_CHG[1].DIS);
714703

715704
NRF_PPI->CHG[0] = PPI_CHG_CH9_Msk | PPI_CHG_CH12_Msk;
@@ -721,21 +710,13 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
721710

722711
void radio_tmr_start_us(u8_t trx, u32_t us)
723712
{
724-
if (trx) {
725-
NRF_PPI->CH[0].EEP =
726-
(u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
727-
NRF_PPI->CH[0].TEP =
728-
(u32_t)&(NRF_RADIO->TASKS_TXEN);
729-
} else {
730-
NRF_PPI->CH[0].EEP =
731-
(u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
732-
NRF_PPI->CH[0].TEP =
733-
(u32_t)&(NRF_RADIO->TASKS_RXEN);
734-
}
735-
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
736-
737713
NRF_TIMER0->CC[0] = us;
738714
NRF_TIMER0->EVENTS_COMPARE[0] = 0;
715+
716+
NRF_PPI->CH[0].EEP = (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
717+
NRF_PPI->CH[0].TEP = (trx) ? (u32_t)&(NRF_RADIO->TASKS_TXEN) :
718+
(u32_t)&(NRF_RADIO->TASKS_RXEN);
719+
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
739720
}
740721

741722
void radio_tmr_stop(void)

0 commit comments

Comments
 (0)