[NRF5_SDK13] fix:

- bad number of pin from nRF52840 ,
- bad type of mask of gpio for nRF52940
- typo (object.h)
- revert abort func. to spi_master driver
- update twi_master driver to the newest (e8527f65e90eee6a4dd48ca55d3fc051a556320a master SDK nRF5)
pull/3841/head
Andrzej Puzdrowski 2017-02-02 09:55:36 +01:00
parent 4e188af065
commit 113ae4e06b
4 changed files with 55 additions and 13 deletions

View File

@ -20,11 +20,13 @@
#include "nrf_drv_gpiote.h"
#if defined(TARGET_MCU_NRF51822)
#define GPIO_PIN_COUNT 48
#elif defined(TARGET_MCU_NRF51822)
#define GPIO_PIN_COUNT 31
#else
#elif defined(TARGET_MCU_NRF52832)
#define GPIO_PIN_COUNT 32
#elif defined(TARGET_MCU_NRF52840)
#define GPIO_PIN_COUNT 48
#else
#error not recognized gpio count for mcu
#endif
typedef struct {
@ -38,7 +40,7 @@ typedef struct {
} gpio_cfg_t;
#if GPIO_PIN_COUNT > 32
typedef uint32_t gpio_mask_t;
typedef uint64_t gpio_mask_t;
#else
typedef uint32_t gpio_mask_t;
#endif

View File

@ -8,7 +8,7 @@
* 1. Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* 2. Redistributions in// binary form, except as embedded into a Nordic Semiconductor ASA
* 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
* integrated circuit in a product or a software update for such product, must reproduce
* the above copyright notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.

View File

@ -129,6 +129,7 @@ typedef struct
bool tx_done : 1;
bool rx_done : 1;
bool abort : 1;
} spi_control_block_t;
static spi_control_block_t m_cb[ENABLED_SPI_COUNT];
@ -401,6 +402,19 @@ static bool transfer_byte(NRF_SPI_Type * p_spi, spi_control_block_t * p_cb)
// see how the transfer is started in the 'nrf_drv_spi_transfer'
// function.
uint16_t bytes_used = p_cb->bytes_transferred + 1;
if (p_cb->abort)
{
if (bytes_used < p_cb->evt.data.done.tx_length)
{
p_cb->evt.data.done.tx_length = bytes_used;
}
if (bytes_used < p_cb->evt.data.done.rx_length)
{
p_cb->evt.data.done.rx_length = bytes_used;
}
}
if (bytes_used < p_cb->evt.data.done.tx_length)
{
nrf_spi_txd_set(p_spi, p_cb->evt.data.done.p_tx_buffer[bytes_used]);
@ -577,6 +591,7 @@ ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance,
p_cb->evt.data.done = *p_xfer_desc;
p_cb->tx_done = false;
p_cb->rx_done = false;
p_cb->abort = false;
if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED)
{

View File

@ -57,7 +57,7 @@
#define NRF_LOG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR
#define EVT_TO_STR(event) (event == NRF_DRV_TWI_EVT_DONE ? "EVT_DONE" : \
(event == NRF_DRV_TWI_EVT_ADDRESS_NACK ? "EVT_ADDRESS_NACK" : \
(event == NRF_DRV_TWI_EVT_DATA_NACK ? "EVT_DATA_NACK" : "UNKNOWN ERROR"))))))
(event == NRF_DRV_TWI_EVT_DATA_NACK ? "EVT_DATA_NACK" : "UNKNOWN ERROR")))
#define EVT_TO_STR_TWI(event) (event == NRF_TWI_EVENT_STOPPED ? "NRF_TWI_EVENT_STOPPED" : \
(event == NRF_TWI_EVENT_RXDREADY ? "NRF_TWI_EVENT_RXDREADY" : \
(event == NRF_TWI_EVENT_TXDSENT ? "NRF_TWI_EVENT_TXDSENT" : \
@ -129,6 +129,7 @@
| (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos))
#define SDA_PIN_INIT_CONF_CLR SCL_PIN_INIT_CONF_CLR
#define HW_TIMEOUT 10000
// Control block - driver instance local data.
typedef struct
@ -530,7 +531,10 @@ static ret_code_t twi_tx_start_transfer(twi_control_block_t * p_cb,
bool no_stop)
{
ret_code_t ret_code = NRF_SUCCESS;
volatile int32_t hw_timeout;
hw_timeout = HW_TIMEOUT;
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED);
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT);
@ -556,9 +560,11 @@ static ret_code_t twi_tx_start_transfer(twi_control_block_t * p_cb,
}
else
{
while (twi_transfer(p_twi, &p_cb->error, &p_cb->bytes_transferred, (uint8_t *)p_data, length, no_stop))
{}
while ((hw_timeout > 0) && twi_transfer(p_twi, &p_cb->error, &p_cb->bytes_transferred, (uint8_t *)p_data, length, no_stop))
{
hw_timeout--;
}
if (p_cb->error)
{
uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi);
@ -569,6 +575,13 @@ static ret_code_t twi_tx_start_transfer(twi_control_block_t * p_cb,
}
}
if (hw_timeout <= 0)
{
nrf_twi_disable(p_twi);
nrf_twi_enable(p_twi);
ret_code = NRF_ERROR_INTERNAL;
}
}
return ret_code;
}
@ -579,6 +592,9 @@ static ret_code_t twi_rx_start_transfer(twi_control_block_t * p_cb,
uint8_t length)
{
ret_code_t ret_code = NRF_SUCCESS;
volatile int32_t hw_timeout;
hw_timeout = HW_TIMEOUT;
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED);
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
@ -610,9 +626,11 @@ static ret_code_t twi_rx_start_transfer(twi_control_block_t * p_cb,
}
else
{
while (twi_transfer(p_twi, &p_cb->error, &p_cb->bytes_transferred, (uint8_t*)p_data, length, false))
{}
while ((hw_timeout > 0) && twi_transfer(p_twi, &p_cb->error, &p_cb->bytes_transferred, (uint8_t*)p_data, length, false))
{
hw_timeout--;
}
if (p_cb->error)
{
uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi);
@ -622,6 +640,13 @@ static ret_code_t twi_rx_start_transfer(twi_control_block_t * p_cb,
ret_code = twi_process_error(errorsrc);
}
}
if (hw_timeout <= 0)
{
nrf_twi_disable(p_twi);
nrf_twi_enable(p_twi);
ret_code = NRF_ERROR_INTERNAL;
}
}
return ret_code;
}