mirror of https://github.com/ARMmbed/mbed-os.git
i2c_api.c: fix style
parent
e18a800e7c
commit
32311b7ca5
|
@ -232,7 +232,7 @@ const PinMap *i2c_slave_scl_pinmap()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* Global array for easy register selection for each instance. */
|
/* Global array for easy register selection for each instance. */
|
||||||
static NRF_TWI_Type * nordic_nrf5_twi_register[2] = { NRF_TWI0, NRF_TWI1 };
|
static NRF_TWI_Type *nordic_nrf5_twi_register[2] = { NRF_TWI0, NRF_TWI1 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reconfigure TWI register.
|
* @brief Reconfigure TWI register.
|
||||||
|
@ -255,12 +255,12 @@ void i2c_configure_twi_instance(i2c_t *obj)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static nrfx_irq_handler_t const irq_handlers[NRFX_TWI_ENABLED_COUNT] = {
|
static nrfx_irq_handler_t const irq_handlers[NRFX_TWI_ENABLED_COUNT] = {
|
||||||
#if NRFX_CHECK(NRFX_TWI0_ENABLED)
|
#if NRFX_CHECK(NRFX_TWI0_ENABLED)
|
||||||
nrfx_twi_0_irq_handler,
|
nrfx_twi_0_irq_handler,
|
||||||
#endif
|
#endif
|
||||||
#if NRFX_CHECK(NRFX_TWI1_ENABLED)
|
#if NRFX_CHECK(NRFX_TWI1_ENABLED)
|
||||||
nrfx_twi_1_irq_handler,
|
nrfx_twi_1_irq_handler,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int instance = config->instance;
|
int instance = config->instance;
|
||||||
|
@ -287,7 +287,7 @@ void i2c_configure_twi_instance(i2c_t *obj)
|
||||||
/* Force resource release. This is necessary because mbed drivers don't
|
/* Force resource release. This is necessary because mbed drivers don't
|
||||||
* deinitialize on object destruction.
|
* deinitialize on object destruction.
|
||||||
*/
|
*/
|
||||||
NRFX_IRQ_DISABLE((nrfx_get_irq_number((void const*)nordic_nrf5_twi_register[instance])));
|
NRFX_IRQ_DISABLE((nrfx_get_irq_number((void const *)nordic_nrf5_twi_register[instance])));
|
||||||
/* Release and re-initialize the irq handlers.
|
/* Release and re-initialize the irq handlers.
|
||||||
* observation: based on call flow, this is called only during i2c_reset and i2c_byte_write
|
* observation: based on call flow, this is called only during i2c_reset and i2c_byte_write
|
||||||
* The nrfx_prs_acquire is normally called in nrfx_twi_init which is part of the i2c_configure_driver_instance,
|
* The nrfx_prs_acquire is normally called in nrfx_twi_init which is part of the i2c_configure_driver_instance,
|
||||||
|
@ -297,8 +297,7 @@ void i2c_configure_twi_instance(i2c_t *obj)
|
||||||
|
|
||||||
nrfx_prs_release(nordic_nrf5_twi_register[instance]);
|
nrfx_prs_release(nordic_nrf5_twi_register[instance]);
|
||||||
if (nrfx_prs_acquire(nordic_nrf5_twi_register[instance],
|
if (nrfx_prs_acquire(nordic_nrf5_twi_register[instance],
|
||||||
irq_handlers[instance]) != NRFX_SUCCESS)
|
irq_handlers[instance]) != NRFX_SUCCESS) {
|
||||||
{
|
|
||||||
DEBUG_PRINTF("Function: %s, nrfx_prs_acquire error code: %s.",
|
DEBUG_PRINTF("Function: %s, nrfx_prs_acquire error code: %s.",
|
||||||
__func__,
|
__func__,
|
||||||
err_code);
|
err_code);
|
||||||
|
@ -640,7 +639,7 @@ static void i2c_configure_driver_instance(i2c_t *obj)
|
||||||
/* Force resource release. This is necessary because mbed drivers don't
|
/* Force resource release. This is necessary because mbed drivers don't
|
||||||
* deinitialize on object destruction.
|
* deinitialize on object destruction.
|
||||||
*/
|
*/
|
||||||
NRFX_IRQ_DISABLE((nrfx_get_irq_number((void const*)nordic_nrf5_twi_register[instance])));
|
NRFX_IRQ_DISABLE((nrfx_get_irq_number((void const *)nordic_nrf5_twi_register[instance])));
|
||||||
|
|
||||||
/* Configure driver with new settings. */
|
/* Configure driver with new settings. */
|
||||||
nrfx_twi_config_t twi_config = {
|
nrfx_twi_config_t twi_config = {
|
||||||
|
@ -792,8 +791,7 @@ static void nordic_nrf5_twi_event_handler(nrfx_twi_evt_t const *p_event, void *p
|
||||||
struct i2c_s *config = &obj->i2c;
|
struct i2c_s *config = &obj->i2c;
|
||||||
|
|
||||||
/* Translate event type from NRF driver values to mbed HAL values. */
|
/* Translate event type from NRF driver values to mbed HAL values. */
|
||||||
switch (p_event->type)
|
switch (p_event->type) {
|
||||||
{
|
|
||||||
/* Transfer completed event. */
|
/* Transfer completed event. */
|
||||||
case NRFX_TWI_EVT_DONE:
|
case NRFX_TWI_EVT_DONE:
|
||||||
config->event = I2C_EVENT_TRANSFER_COMPLETE;
|
config->event = I2C_EVENT_TRANSFER_COMPLETE;
|
||||||
|
@ -874,7 +872,7 @@ void i2c_transfer_asynch(i2c_t *obj,
|
||||||
|
|
||||||
/* Configure TWI transfer. */
|
/* Configure TWI transfer. */
|
||||||
const nrfx_twi_xfer_desc_t twi_config = NRFX_TWI_XFER_DESC_TXRX(address >> 1,
|
const nrfx_twi_xfer_desc_t twi_config = NRFX_TWI_XFER_DESC_TXRX(address >> 1,
|
||||||
(uint8_t*) tx,
|
(uint8_t *) tx,
|
||||||
tx_length,
|
tx_length,
|
||||||
rx,
|
rx,
|
||||||
rx_length);
|
rx_length);
|
||||||
|
|
Loading…
Reference in New Issue