From cd096f604e305c2118cd65c6735234ea714cca38 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Thu, 2 Feb 2017 23:45:44 +0100 Subject: [PATCH] nrf5/hal: Updating hal_twi.c tx implementation to a working state. STARTTX only issued once, before looping bytes. --- nrf5/hal/hal_twi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nrf5/hal/hal_twi.c b/nrf5/hal/hal_twi.c index 4e38b96c8e..9da0cd6d0a 100644 --- a/nrf5/hal/hal_twi.c +++ b/nrf5/hal/hal_twi.c @@ -61,19 +61,25 @@ void hal_twi_master_tx(NRF_TWI_Type * p_instance, p_instance->ADDRESS = addr; - while (number_of_txd_bytes < transfer_size) { - p_instance->EVENTS_TXDSENT = 0; - p_instance->TXD = tx_data[number_of_txd_bytes]; - p_instance->TASKS_STARTTX = 1; + p_instance->EVENTS_TXDSENT = 0; + p_instance->TXD = tx_data[number_of_txd_bytes]; + p_instance->TASKS_STARTTX = 1; + + while (number_of_txd_bytes < transfer_size) { // wait for the transaction complete while (p_instance->EVENTS_TXDSENT == 0) { ; } number_of_txd_bytes++; + + // TODO: This could go one byte out of bound. + p_instance->TXD = tx_data[number_of_txd_bytes]; + p_instance->EVENTS_TXDSENT = 0; } + if (stop) { p_instance->EVENTS_STOPPED = 0; p_instance->TASKS_STOP = 1;