From c7162720c19aa460bfee7162f3676a7ae90afef6 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Thu, 2 Feb 2017 22:55:25 +0100 Subject: [PATCH] nrf5/hal: Updating hal_twi.c with tx function. Gets multiple startup bytes for each clocked byte. --- nrf5/hal/hal_twi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nrf5/hal/hal_twi.c b/nrf5/hal/hal_twi.c index 42e5ca92e1..4e38b96c8e 100644 --- a/nrf5/hal/hal_twi.c +++ b/nrf5/hal/hal_twi.c @@ -50,7 +50,7 @@ void hal_twi_master_init(NRF_TWI_Type * p_instance, hal_twi_init_t const * p_twi p_instance->FREQUENCY = hal_twi_frequency_lookup[p_twi_init->freq]; p_instance->ENABLE = (TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos); } - +#include void hal_twi_master_tx(NRF_TWI_Type * p_instance, uint8_t addr, uint16_t transfer_size, @@ -62,16 +62,26 @@ void hal_twi_master_tx(NRF_TWI_Type * p_instance, p_instance->ADDRESS = addr; while (number_of_txd_bytes < transfer_size) { - p_instance->TXD = (uint32_t)(tx_data[number_of_txd_bytes]); p_instance->EVENTS_TXDSENT = 0; + p_instance->TXD = tx_data[number_of_txd_bytes]; p_instance->TASKS_STARTTX = 1; // wait for the transaction complete while (p_instance->EVENTS_TXDSENT == 0) { ; } + number_of_txd_bytes++; } + + if (stop) { + p_instance->EVENTS_STOPPED = 0; + p_instance->TASKS_STOP = 1; + + while (p_instance->EVENTS_STOPPED == 0) { + ; + } + } } void hal_twi_master_rx(NRF_TWI_Type * p_instance,