File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -93,8 +93,37 @@ void hal_twi_master_tx(NRF_TWI_Type * p_instance,
93
93
void hal_twi_master_rx (NRF_TWI_Type * p_instance ,
94
94
uint8_t addr ,
95
95
uint16_t transfer_size ,
96
- const uint8_t * rx_data ) {
96
+ uint8_t * rx_data ,
97
+ bool stop ) {
98
+
99
+ uint16_t number_of_rxd_bytes = 0 ;
100
+
101
+ p_instance -> ADDRESS = addr ;
102
+
103
+ p_instance -> EVENTS_RXDREADY = 0 ;
104
+
105
+ p_instance -> TASKS_STARTRX = 1 ;
106
+
107
+ while (number_of_rxd_bytes < transfer_size ) {
108
+ // wait for the transaction complete
109
+ while (p_instance -> EVENTS_RXDREADY == 0 ) {
110
+ ;
111
+ }
112
+
113
+ rx_data [number_of_rxd_bytes ] = p_instance -> RXD ;
114
+ p_instance -> EVENTS_RXDREADY = 0 ;
97
115
116
+ number_of_rxd_bytes ++ ;
117
+ }
118
+
119
+ if (stop ) {
120
+ p_instance -> EVENTS_STOPPED = 0 ;
121
+ p_instance -> TASKS_STOP = 1 ;
122
+
123
+ while (p_instance -> EVENTS_STOPPED == 0 ) {
124
+ ;
125
+ }
126
+ }
98
127
}
99
128
100
129
void hal_twi_slave_init (NRF_TWI_Type * p_instance , hal_twi_init_t const * p_twi_init ) {
Original file line number Diff line number Diff line change @@ -108,7 +108,8 @@ void hal_twi_master_tx(NRF_TWI_Type * p_instance,
108
108
void hal_twi_master_rx (NRF_TWI_Type * p_instance ,
109
109
uint8_t addr ,
110
110
uint16_t transfer_size ,
111
- const uint8_t * rx_data );
111
+ uint8_t * rx_data ,
112
+ bool stop );
112
113
113
114
114
115
void hal_twi_slave_init (NRF_TWI_Type * p_instance , hal_twi_init_t const * p_twi_init );
You can’t perform that action at this time.
0 commit comments