@@ -68,16 +68,31 @@ void radio_phy_set(u8_t phy, u8_t flags)
68
68
case BIT (0 ):
69
69
default :
70
70
mode = RADIO_MODE_MODE_Ble_1Mbit ;
71
+
72
+ #if defined(CONFIG_SOC_NRF52840 )
73
+ /* Workaround: nRF52840 Engineering A Errata ID 164 */
74
+ * (volatile u32_t * )0x4000173c &= ~0x80000000 ;
75
+ #endif /* CONFIG_SOC_NRF52840 */
71
76
break ;
72
77
73
78
#if defined(CONFIG_SOC_SERIES_NRF51X )
74
79
case BIT (1 ):
75
80
mode = RADIO_MODE_MODE_Nrf_2Mbit ;
81
+
82
+ #if defined(CONFIG_SOC_NRF52840 )
83
+ /* Workaround: nRF52840 Engineering A Errata ID 164 */
84
+ * (volatile u32_t * )0x4000173c &= ~0x80000000 ;
85
+ #endif /* CONFIG_SOC_NRF52840 */
76
86
break ;
77
87
78
88
#elif defined(CONFIG_SOC_SERIES_NRF52X )
79
89
case BIT (1 ):
80
90
mode = RADIO_MODE_MODE_Ble_2Mbit ;
91
+
92
+ #if defined(CONFIG_SOC_NRF52840 )
93
+ /* Workaround: nRF52840 Engineering A Errata ID 164 */
94
+ * (volatile u32_t * )0x4000173c &= ~0x80000000 ;
95
+ #endif /* CONFIG_SOC_NRF52840 */
81
96
break ;
82
97
83
98
#if defined(CONFIG_SOC_NRF52840 )
@@ -87,6 +102,12 @@ void radio_phy_set(u8_t phy, u8_t flags)
87
102
} else {
88
103
mode = RADIO_MODE_MODE_Ble_LR500Kbit ;
89
104
}
105
+
106
+ /* Workaround: nRF52840 Engineering A Errata ID 164 */
107
+ * (volatile u32_t * )0x4000173c |= 0x80000000 ;
108
+ * (volatile u32_t * )0x4000173c =
109
+ ((* (volatile u32_t * )0x4000173c ) & 0xFFFFFF00 ) |
110
+ 0x5C ;
90
111
break ;
91
112
#endif /* CONFIG_SOC_NRF52840 */
92
113
#endif /* CONFIG_SOC_SERIES_NRF52X */
@@ -115,6 +136,10 @@ void radio_freq_chan_set(u32_t chan)
115
136
void radio_whiten_iv_set (u32_t iv )
116
137
{
117
138
NRF_RADIO -> DATAWHITEIV = iv ;
139
+
140
+ NRF_RADIO -> PCNF1 &= ~RADIO_PCNF1_WHITEEN_Msk ;
141
+ NRF_RADIO -> PCNF1 |= ((1UL ) << RADIO_PCNF1_WHITEEN_Pos ) &
142
+ RADIO_PCNF1_WHITEEN_Msk ;
118
143
}
119
144
120
145
void radio_aa_set (u8_t * aa )
@@ -187,17 +212,17 @@ void radio_pkt_configure(u8_t bits_len, u8_t max_len, u8_t flags)
187
212
RADIO_PCNF0_S1LEN_Msk ) |
188
213
extra ;
189
214
190
- NRF_RADIO -> PCNF1 = (((((u32_t )max_len ) << RADIO_PCNF1_MAXLEN_Pos ) &
215
+ NRF_RADIO -> PCNF1 &= ~(RADIO_PCNF1_MAXLEN_Msk | RADIO_PCNF1_STATLEN_Msk |
216
+ RADIO_PCNF1_BALEN_Msk | RADIO_PCNF1_ENDIAN_Msk );
217
+ NRF_RADIO -> PCNF1 |= ((((u32_t )max_len ) << RADIO_PCNF1_MAXLEN_Pos ) &
191
218
RADIO_PCNF1_MAXLEN_Msk ) |
192
- (((0UL ) << RADIO_PCNF1_STATLEN_Pos ) &
193
- RADIO_PCNF1_STATLEN_Msk ) |
194
- (((3UL ) << RADIO_PCNF1_BALEN_Pos ) &
195
- RADIO_PCNF1_BALEN_Msk ) |
196
- (((RADIO_PCNF1_ENDIAN_Little ) <<
197
- RADIO_PCNF1_ENDIAN_Pos ) &
198
- RADIO_PCNF1_ENDIAN_Msk ) |
199
- (((1UL ) << RADIO_PCNF1_WHITEEN_Pos ) &
200
- RADIO_PCNF1_WHITEEN_Msk ));
219
+ (((0UL ) << RADIO_PCNF1_STATLEN_Pos ) &
220
+ RADIO_PCNF1_STATLEN_Msk ) |
221
+ (((3UL ) << RADIO_PCNF1_BALEN_Pos ) &
222
+ RADIO_PCNF1_BALEN_Msk ) |
223
+ (((RADIO_PCNF1_ENDIAN_Little ) <<
224
+ RADIO_PCNF1_ENDIAN_Pos ) &
225
+ RADIO_PCNF1_ENDIAN_Msk );
201
226
}
202
227
203
228
void radio_pkt_rx_set (void * rx_packet )
@@ -657,6 +682,25 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
657
682
return remainder ;
658
683
}
659
684
685
+ void radio_tmr_start_us (u8_t trx , u32_t us )
686
+ {
687
+ if (trx ) {
688
+ NRF_PPI -> CH [0 ].EEP =
689
+ (u32_t )& (NRF_TIMER0 -> EVENTS_COMPARE [0 ]);
690
+ NRF_PPI -> CH [0 ].TEP =
691
+ (u32_t )& (NRF_RADIO -> TASKS_TXEN );
692
+ } else {
693
+ NRF_PPI -> CH [0 ].EEP =
694
+ (u32_t )& (NRF_TIMER0 -> EVENTS_COMPARE [0 ]);
695
+ NRF_PPI -> CH [0 ].TEP =
696
+ (u32_t )& (NRF_RADIO -> TASKS_RXEN );
697
+ }
698
+ NRF_PPI -> CHENSET = PPI_CHEN_CH0_Msk ;
699
+
700
+ NRF_TIMER0 -> CC [0 ] = us ;
701
+ NRF_TIMER0 -> EVENTS_COMPARE [0 ] = 0 ;
702
+ }
703
+
660
704
void radio_tmr_stop (void )
661
705
{
662
706
NRF_TIMER0 -> TASKS_STOP = 1 ;
@@ -689,6 +733,11 @@ void radio_tmr_aa_capture(void)
689
733
NRF_PPI -> CHENSET = (PPI_CHEN_CH2_Msk | PPI_CHEN_CH3_Msk );
690
734
}
691
735
736
+ u32_t radio_tmr_ready_get (void )
737
+ {
738
+ return NRF_TIMER0 -> CC [0 ];
739
+ }
740
+
692
741
u32_t radio_tmr_aa_get (void )
693
742
{
694
743
return (NRF_TIMER0 -> CC [1 ] - NRF_TIMER0 -> CC [0 ]);
0 commit comments