Skip to content

Commit 603ff02

Browse files
mbrossardmathias-arm
authored andcommitted
nrf52820_hic: update to nrfx v2.5.0 (3/3)
nrf(x)_twis and configuration changes
1 parent d650147 commit 603ff02

File tree

5 files changed

+398
-246
lines changed

5 files changed

+398
-246
lines changed

source/hic_hal/nordic/nrf52820/nrfx/drivers/nrfx_twis.c

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
1-
/**
2-
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
3-
*
1+
/*
2+
* Copyright (c) 2015 - 2021, Nordic Semiconductor ASA
43
* All rights reserved.
54
*
6-
* Redistribution and use in source and binary forms, with or without modification,
7-
* are permitted provided that the following conditions are met:
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
89
*
910
* 1. Redistributions of source code must retain the above copyright notice, this
1011
* list of conditions and the following disclaimer.
1112
*
12-
* 2. Redistributions in binary form, except as embedded into a Nordic
13-
* Semiconductor ASA integrated circuit in a product or a software update for
14-
* such product, must reproduce the above copyright notice, this list of
15-
* conditions and the following disclaimer in the documentation and/or other
16-
* materials provided with the distribution.
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
1716
*
18-
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17+
* 3. Neither the name of the copyright holder nor the names of its
1918
* contributors may be used to endorse or promote products derived from this
2019
* software without specific prior written permission.
2120
*
22-
* 4. This software, with or without modification, must only be used with a
23-
* Nordic Semiconductor ASA integrated circuit.
24-
*
25-
* 5. Any software provided in binary form under this license must not be reverse
26-
* engineered, decompiled, modified and/or disassembled.
27-
*
28-
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
29-
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30-
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
31-
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
3225
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34-
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37-
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38-
*
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
3932
*/
4033

4134
#include <nrfx.h>
@@ -515,7 +508,7 @@ nrfx_err_t nrfx_twis_init(nrfx_twis_t const * p_instance,
515508
nrfx_twis_config_pin(p_config->scl, p_config->scl_pull);
516509
nrfx_twis_config_pin(p_config->sda, p_config->sda_pull);
517510

518-
nrf_twis_config_addr_mask_t addr_mask = (nrf_twis_config_addr_mask_t)0;
511+
uint32_t addr_mask = 0;
519512
if (0 == (p_config->addr[0] | p_config->addr[1]))
520513
{
521514
addr_mask = NRF_TWIS_CONFIG_ADDRESS0_MASK;
@@ -543,7 +536,7 @@ nrfx_err_t nrfx_twis_init(nrfx_twis_t const * p_instance,
543536
nrf_twis_pins_set (p_reg, p_config->scl, p_config->sda);
544537
nrf_twis_address_set (p_reg, 0, p_config->addr[0]);
545538
nrf_twis_address_set (p_reg, 1, p_config->addr[1]);
546-
nrf_twis_config_address_set(p_reg, addr_mask);
539+
nrf_twis_config_address_set(p_reg, (nrf_twis_config_addr_mask_t)addr_mask);
547540

548541
/* Clear semaphore */
549542
if (!NRFX_TWIS_NO_SYNC_MODE)
@@ -566,19 +559,13 @@ void nrfx_twis_uninit(nrfx_twis_t const * p_instance)
566559
twis_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
567560
NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED);
568561

569-
TWIS_PSEL_Type psel = p_reg->PSEL;
562+
uint32_t scl_pin = nrf_twis_scl_pin_get(p_reg);
563+
uint32_t sda_pin = nrf_twis_sda_pin_get(p_reg);
570564

571565
nrfx_twis_swreset(p_reg);
572566

573-
/* Clear pins state if */
574-
if (!(TWIS_PSEL_SCL_CONNECT_Msk & psel.SCL))
575-
{
576-
nrf_gpio_cfg_default(psel.SCL);
577-
}
578-
if (!(TWIS_PSEL_SDA_CONNECT_Msk & psel.SDA))
579-
{
580-
nrf_gpio_cfg_default(psel.SDA);
581-
}
567+
nrf_gpio_cfg_default(scl_pin);
568+
nrf_gpio_cfg_default(sda_pin);
582569

583570
#if NRFX_CHECK(NRFX_PRS_ENABLED)
584571
nrfx_prs_release(p_reg);
@@ -631,7 +618,6 @@ void nrfx_twis_disable(nrfx_twis_t const * p_instance)
631618
*
632619
* This is the reason for the function below to be implemented in assembly.
633620
*/
634-
//lint -save -e578
635621
#if defined (__CC_ARM )
636622
static __ASM uint32_t nrfx_twis_error_get_and_clear_internal(uint32_t volatile * perror)
637623
{
@@ -690,7 +676,6 @@ static uint32_t nrfx_twis_error_get_and_clear_internal(uint32_t volatile * perro
690676
#else
691677
#error Unknown compiler
692678
#endif
693-
//lint -restore
694679

695680
uint32_t nrfx_twis_error_get_and_clear(nrfx_twis_t const * p_instance)
696681
{

source/hic_hal/nordic/nrf52820/nrfx/drivers/nrfx_twis.h

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
1-
/**
2-
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
3-
*
1+
/*
2+
* Copyright (c) 2015 - 2021, Nordic Semiconductor ASA
43
* All rights reserved.
54
*
6-
* Redistribution and use in source and binary forms, with or without modification,
7-
* are permitted provided that the following conditions are met:
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
89
*
910
* 1. Redistributions of source code must retain the above copyright notice, this
1011
* list of conditions and the following disclaimer.
1112
*
12-
* 2. Redistributions in binary form, except as embedded into a Nordic
13-
* Semiconductor ASA integrated circuit in a product or a software update for
14-
* such product, must reproduce the above copyright notice, this list of
15-
* conditions and the following disclaimer in the documentation and/or other
16-
* materials provided with the distribution.
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
1716
*
18-
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17+
* 3. Neither the name of the copyright holder nor the names of its
1918
* contributors may be used to endorse or promote products derived from this
2019
* software without specific prior written permission.
2120
*
22-
* 4. This software, with or without modification, must only be used with a
23-
* Nordic Semiconductor ASA integrated circuit.
24-
*
25-
* 5. Any software provided in binary form under this license must not be reverse
26-
* engineered, decompiled, modified and/or disassembled.
27-
*
28-
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
29-
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30-
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
31-
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
3225
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34-
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37-
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38-
*
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
3932
*/
4033

4134
#ifndef NRFX_TWIS_H__
@@ -154,16 +147,26 @@ typedef struct
154147
uint8_t interrupt_priority; //!< The priority of interrupt for the module to be set.
155148
} nrfx_twis_config_t;
156149

157-
/** @brief Generate the default configuration for the TWIS driver instance. */
158-
#define NRFX_TWIS_DEFAULT_CONFIG \
159-
{ \
160-
.addr = { NRFX_TWIS_DEFAULT_CONFIG_ADDR0, \
161-
NRFX_TWIS_DEFAULT_CONFIG_ADDR1 }, \
162-
.scl = 31, \
163-
.sda = 31, \
164-
.scl_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL, \
165-
.sda_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL, \
166-
.interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
150+
/**
151+
* @brief TWIS driver default configuration.
152+
*
153+
* This configuration sets up TWIS with the following options:
154+
* - second slave address disabled
155+
* - SCL pull-up disabled
156+
* - SDA pull-up disabled
157+
*
158+
* @param[in] _pin_scl SCL pin.
159+
* @param[in] _pin_sda SDA pin.
160+
* @param[in] _addr Slave address on TWI bus.
161+
*/
162+
#define NRFX_TWIS_DEFAULT_CONFIG(_pin_scl, _pin_sda, _addr) \
163+
{ \
164+
.addr = { _addr, 0x00 }, \
165+
.scl = _pin_scl, \
166+
.sda = _pin_sda, \
167+
.scl_pull = NRF_GPIO_PIN_NOPULL, \
168+
.sda_pull = NRF_GPIO_PIN_NOPULL, \
169+
.interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
167170
}
168171

169172
/**
@@ -276,7 +279,7 @@ nrfx_err_t nrfx_twis_tx_prepare(nrfx_twis_t const * p_instance,
276279
*
277280
* @return Number of bytes sent.
278281
*/
279-
__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
282+
NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
280283

281284
/**
282285
* @brief Function for preparing the data for receiving.
@@ -310,7 +313,7 @@ nrfx_err_t nrfx_twis_rx_prepare(nrfx_twis_t const * p_instance,
310313
*
311314
* @return Number of bytes received.
312315
*/
313-
__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
316+
NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
314317

315318
/**
316319
* @brief Function for checking if the driver is busy right now.
@@ -375,17 +378,17 @@ bool nrfx_twis_is_pending_tx(nrfx_twis_t const * p_instance);
375378
*/
376379
bool nrfx_twis_is_pending_rx(nrfx_twis_t const * p_instance);
377380

378-
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
379-
__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
381+
#ifndef NRFX_DECLARE_ONLY
382+
NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
380383
{
381384
return nrf_twis_tx_amount_get(p_instance->p_reg);
382385
}
383386

384-
__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
387+
NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
385388
{
386389
return nrf_twis_rx_amount_get(p_instance->p_reg);
387390
}
388-
#endif // SUPPRESS_INLINE_IMPLEMENTATION
391+
#endif // NRFX_DECLARE_ONLY
389392

390393
/** @} */
391394

0 commit comments

Comments
 (0)