@@ -183,9 +183,7 @@ bool TwoWire::twi_master_init(void)
183183 twi->PSELSCL = SCL_pin_number;
184184 twi->PSELSDA = SDA_pin_number;
185185 twi->FREQUENCY = TWI_FREQUENCY_FREQUENCY_K100 << TWI_FREQUENCY_FREQUENCY_Pos;
186- NRF_PPI->CH [7 ].EEP = (uint32_t )&twi->EVENTS_BB ;
187- NRF_PPI->CH [7 ].TEP = (uint32_t )&twi->TASKS_SUSPEND ;
188- NRF_PPI->CHENCLR = PPI_CHENCLR_CH7_Msk;
186+ rfduino_ppi_channel_unassign (7 );
189187 twi->ENABLE = TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos;
190188
191189 return twi_master_clear_bus ();
@@ -204,13 +202,12 @@ uint8_t TwoWire::twi_master_read(uint8_t *data, uint8_t data_length, uint8_t iss
204202
205203 if ((data_length == 1 ) && (issue_stop_condition == 1 ))
206204 {
207- NRF_PPI-> CH [ 7 ]. TEP = ( uint32_t ) &twi->TASKS_STOP ;
205+ rfduino_ppi_channel_assign ( 7 , &twi->EVENTS_BB , &twi-> TASKS_STOP ) ;
208206 }
209207 else
210208 {
211- NRF_PPI-> CH [ 7 ]. TEP = ( uint32_t ) &twi->TASKS_SUSPEND ;
209+ rfduino_ppi_channel_assign ( 7 , &twi-> EVENTS_BB , &twi->TASKS_SUSPEND ) ;
212210 }
213- NRF_PPI->CHENSET = PPI_CHENSET_CH7_Msk;
214211 twi->TASKS_STARTRX = 1 ;
215212 while (true )
216213 {
@@ -233,7 +230,7 @@ uint8_t TwoWire::twi_master_read(uint8_t *data, uint8_t data_length, uint8_t iss
233230 {
234231 if (issue_stop_condition == 1 )
235232 {
236- NRF_PPI-> CH [ 7 ]. TEP = ( uint32_t ) &twi->TASKS_STOP ;
233+ rfduino_ppi_channel_assign ( 7 , &twi->EVENTS_BB , &twi-> TASKS_STOP ) ;
237234 }
238235 }
239236
@@ -252,7 +249,7 @@ uint8_t TwoWire::twi_master_read(uint8_t *data, uint8_t data_length, uint8_t iss
252249 twi->EVENTS_STOPPED = 0 ;
253250 }
254251
255- NRF_PPI-> CHENCLR = PPI_CHENCLR_CH7_Msk ;
252+ rfduino_ppi_channel_unassign ( 7 ) ;
256253 return bytes_received;
257254}
258255
0 commit comments