nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Hardware access layer for the two-wire interface (TWI) peripheral. More...

Enumerations

enum  nrf_twi_tasks_t {
  NRF_TWI_TASKS_STARTRX = offsetof(NRF_TWI_Type, TASKS_STARTRX),
  NRF_TWI_TASKS_STARTTX = offsetof(NRF_TWI_Type, TASKS_STARTTX),
  NRF_TWI_TASKS_STOP = offsetof(NRF_TWI_Type, TASKS_STOP),
  NRF_TWI_TASKS_SUSPEND = offsetof(NRF_TWI_Type, TASKS_SUSPEND),
  NRF_TWI_TASKS_RESUME = offsetof(NRF_TWI_Type, TASKS_RESUME)
}
 TWI tasks. More...
 
enum  nrf_twi_events_t {
  NRF_TWI_EVENTS_STOPPED = offsetof(NRF_TWI_Type, EVENTS_STOPPED),
  NRF_TWI_EVENTS_RXDREADY = offsetof(NRF_TWI_Type, EVENTS_RXDREADY),
  NRF_TWI_EVENTS_TXDSENT = offsetof(NRF_TWI_Type, EVENTS_TXDSENT),
  NRF_TWI_EVENTS_ERROR = offsetof(NRF_TWI_Type, EVENTS_ERROR),
  NRF_TWI_EVENTS_BB = offsetof(NRF_TWI_Type, EVENTS_BB),
  NRF_TWI_EVENTS_SUSPENDED = offsetof(NRF_TWI_Type, EVENTS_SUSPENDED)
}
 TWI events. More...
 
enum  nrf_twi_int_mask_t {
  NRF_TWI_INT_SUSPENDED_MASK = TWI_INTENSET_SUSPENDED_Msk,
  NRF_TWI_INT_BB_MASK = TWI_INTENSET_BB_Msk,
  NRF_TWI_INT_ERROR_MASK = TWI_INTENSET_ERROR_Msk,
  NRF_TWI_INT_TXDSENT_MASK = TWI_INTENSET_TXDSENT_Msk,
  NRF_TWI_INT_RXDREADY_MASK = TWI_INTENSET_RXDREADY_Msk,
  NRF_TWI_INT_STOPPED_MASK = TWI_INTENSET_STOPPED_Msk
}
 TWI interrupts. More...
 
enum  nrf_twi_shorts_mask_t {
  NRF_TWI_SHORTS_BB_SUSPEND_MASK = TWI_SHORTS_BB_SUSPEND_Msk,
  NRF_TWI_SHORTS_BB_STOP_MASK = TWI_SHORTS_BB_STOP_Msk
}
 Types of TWI shortcuts. More...
 
enum  nrf_twi_frequency_t {
  NRF_TWI_FREQ_100K = TWI_FREQUENCY_FREQUENCY_K100,
  NRF_TWI_FREQ_250K = TWI_FREQUENCY_FREQUENCY_K250,
  NRF_TWI_FREQ_400K = TWI_FREQUENCY_FREQUENCY_K400
}
 TWI master clock frequency. More...
 
enum  nrf_twi_error_t {
  NRF_TWI_ERROR_ADDRESS_NACK = TWI_ERRORSRC_ANACK_Msk,
  NRF_TWI_ERROR_OVERRUN_NACK = TWI_ERRORSRC_OVERRUN_Msk,
  NRF_TWI_ERROR_DATA_NACK = TWI_ERRORSRC_DNACK_Msk
}
 TWI error source. More...
 

Functions

__STATIC_INLINE void nrf_twi_task_set (NRF_TWI_Type *p_twi, nrf_twi_tasks_t task)
 Function for activating a specific TWI task. More...
 
__STATIC_INLINE uint32_t * nrf_twi_task_address_get (NRF_TWI_Type *p_twi, nrf_twi_tasks_t task)
 Function for returning the address of a specific TWI task register. More...
 
__STATIC_INLINE void nrf_twi_event_clear (NRF_TWI_Type *p_twi, nrf_twi_events_t event)
 Function for clearing a specific event. More...
 
__STATIC_INLINE bool nrf_twi_event_check (NRF_TWI_Type *p_twi, nrf_twi_events_t event)
 Function for returning the state of a specific event. More...
 
__STATIC_INLINE uint32_t * nrf_twi_event_address_get (NRF_TWI_Type *p_twi, nrf_twi_events_t event)
 Function for returning the address of a specific TWI event register. More...
 
__STATIC_INLINE void nrf_twi_shorts_set (NRF_TWI_Type *p_twi, uint32_t short_mask)
 Function for setting a shortcut. More...
 
__STATIC_INLINE void nrf_twi_shorts_clear (NRF_TWI_Type *p_twi, uint32_t short_mask)
 Function for clearing shortcuts. More...
 
__STATIC_INLINE void nrf_twi_int_enable (NRF_TWI_Type *p_twi, uint32_t int_mask)
 Function for enabling a specific interrupt. More...
 
__STATIC_INLINE bool nrf_twi_int_enable_check (NRF_TWI_Type *p_twi, uint32_t int_mask)
 Function for retrieving the state of a given interrupt. More...
 
__STATIC_INLINE void nrf_twi_int_disable (NRF_TWI_Type *p_twi, uint32_t int_mask)
 Function for disabling a specific interrupt. More...
 
__STATIC_INLINE void nrf_twi_frequency_set (NRF_TWI_Type *p_twi, nrf_twi_frequency_t frequency)
 Function for setting the TWI master clock frequency. More...
 
__STATIC_INLINE nrf_twi_frequency_t nrf_twi_frequency_get (NRF_TWI_Type *p_twi)
 Function for retrieving the TWI frequency. More...
 
__STATIC_INLINE uint32_t nrf_twi_error_source_get (NRF_TWI_Type *p_twi)
 Function for retrieving the TWI error source. More...
 
__STATIC_INLINE void nrf_twi_enable (NRF_TWI_Type *p_twi)
 Function for enabling TWI. More...
 
__STATIC_INLINE void nrf_twi_disable (NRF_TWI_Type *p_twi)
 Function for disabling TWI. More...
 
__STATIC_INLINE void nrf_twi_pins_set (NRF_TWI_Type *p_twi, uint32_t scl, uint32_t sda)
 Function for configuring TWI pins. More...
 
__STATIC_INLINE uint8_t nrf_twi_rxd_get (NRF_TWI_Type *p_twi)
 Function for reading RX data from TWI. More...
 
__STATIC_INLINE void nrf_twi_txd_set (NRF_TWI_Type *p_twi, uint8_t data)
 Function for writing data to TWI. More...
 
__STATIC_INLINE void nrf_twi_address_set (NRF_TWI_Type *p_twi, uint8_t addr)
 Function for setting the slave address. More...
 

Detailed Description

Hardware access layer for the two-wire interface (TWI) peripheral.

Enumeration Type Documentation

TWI error source.

Enumerator
NRF_TWI_ERROR_ADDRESS_NACK 

NACK received after sending the address.

NRF_TWI_ERROR_OVERRUN_NACK 

Byte received in RXD register before read of the last received byte (data loss).

NRF_TWI_ERROR_DATA_NACK 

NACK received after sending a data byte.

TWI events.

Enumerator
NRF_TWI_EVENTS_STOPPED 

Stopped.

NRF_TWI_EVENTS_RXDREADY 

RXD byte received.

NRF_TWI_EVENTS_TXDSENT 

TXD byte sent.

NRF_TWI_EVENTS_ERROR 

Error.

NRF_TWI_EVENTS_BB 

Byte boundary, generated before each byte that is sent or received.

NRF_TWI_EVENTS_SUSPENDED 

Entered the suspended state.

TWI master clock frequency.

Enumerator
NRF_TWI_FREQ_100K 

100 kbps.

NRF_TWI_FREQ_250K 

250 kbps.

NRF_TWI_FREQ_400K 

400 kbps.

TWI interrupts.

Enumerator
NRF_TWI_INT_SUSPENDED_MASK 

TWI interrupt on suspend event.

NRF_TWI_INT_BB_MASK 

TWI interrupt on byte boundary event.

NRF_TWI_INT_ERROR_MASK 

TWI interrupt on error event.

NRF_TWI_INT_TXDSENT_MASK 

TWI interrupt on txdsent event.

NRF_TWI_INT_RXDREADY_MASK 

TWI interrupt on rxdready event.

NRF_TWI_INT_STOPPED_MASK 

TWI interrupt on stopped event.

Types of TWI shortcuts.

Enumerator
NRF_TWI_SHORTS_BB_SUSPEND_MASK 

Shortcut between bb event and suspend task.

NRF_TWI_SHORTS_BB_STOP_MASK 

Shortcut between bb event and stop task.

TWI tasks.

Enumerator
NRF_TWI_TASKS_STARTRX 

Start receive sequence.

NRF_TWI_TASKS_STARTTX 

Start transmit sequence.

NRF_TWI_TASKS_STOP 

Stop transaction.

NRF_TWI_TASKS_SUSPEND 

Suspend transaction.

NRF_TWI_TASKS_RESUME 

Resume transaction.

Function Documentation

__STATIC_INLINE void nrf_twi_address_set ( NRF_TWI_Type *  p_twi,
uint8_t  addr 
)

Function for setting the slave address.

Parameters
[in]p_twiTWI instance.
[in]addrAddress of next transaction.
__STATIC_INLINE void nrf_twi_disable ( NRF_TWI_Type *  p_twi)

Function for disabling TWI.

Parameters
[in]p_twiTWI instance.
__STATIC_INLINE void nrf_twi_enable ( NRF_TWI_Type *  p_twi)

Function for enabling TWI.

Parameters
[in]p_twiTWI instance.
__STATIC_INLINE uint32_t nrf_twi_error_source_get ( NRF_TWI_Type *  p_twi)

Function for retrieving the TWI error source.

Error sources are cleared after read.

Parameters
[in]p_twiTWI instance.
Returns
Error source mask.
__STATIC_INLINE uint32_t* nrf_twi_event_address_get ( NRF_TWI_Type *  p_twi,
nrf_twi_events_t  event 
)

Function for returning the address of a specific TWI event register.

Parameters
[in]p_twiTWI instance.
[in]eventEvent.
Returns
Address.
__STATIC_INLINE bool nrf_twi_event_check ( NRF_TWI_Type *  p_twi,
nrf_twi_events_t  event 
)

Function for returning the state of a specific event.

Parameters
[in]p_twiTWI instance.
[in]eventEvent.
Return values
trueIf the event is set.
falseIf the event is not set.
__STATIC_INLINE void nrf_twi_event_clear ( NRF_TWI_Type *  p_twi,
nrf_twi_events_t  event 
)

Function for clearing a specific event.

Parameters
[in]p_twiTWI instance.
[in]eventEvent.
__STATIC_INLINE nrf_twi_frequency_t nrf_twi_frequency_get ( NRF_TWI_Type *  p_twi)

Function for retrieving the TWI frequency.

Parameters
[in]p_twiTWI instance.
Returns
Frequency.
__STATIC_INLINE void nrf_twi_frequency_set ( NRF_TWI_Type *  p_twi,
nrf_twi_frequency_t  frequency 
)

Function for setting the TWI master clock frequency.

Parameters
[in]p_twiTWI instance.
[in]frequencyTWI frequency value.
__STATIC_INLINE void nrf_twi_int_disable ( NRF_TWI_Type *  p_twi,
uint32_t  int_mask 
)

Function for disabling a specific interrupt.

Parameters
[in]p_twiTWI instance.
[in]int_maskInterrupts mask.
__STATIC_INLINE void nrf_twi_int_enable ( NRF_TWI_Type *  p_twi,
uint32_t  int_mask 
)

Function for enabling a specific interrupt.

Parameters
[in]p_twiTWI instance.
[in]int_maskInterrupts mask.
__STATIC_INLINE bool nrf_twi_int_enable_check ( NRF_TWI_Type *  p_twi,
uint32_t  int_mask 
)

Function for retrieving the state of a given interrupt.

Parameters
[in]p_twiTWI instance.
[in]int_maskInterrupts mask.
Return values
trueIf the interrupts are enabled.
falseIf the interrupts are not enabled.
__STATIC_INLINE void nrf_twi_pins_set ( NRF_TWI_Type *  p_twi,
uint32_t  scl,
uint32_t  sda 
)

Function for configuring TWI pins.

Parameters
[in]p_twiTWI instance.
[in]sclSCL pin number.
[in]sdaSDA pin number.
__STATIC_INLINE uint8_t nrf_twi_rxd_get ( NRF_TWI_Type *  p_twi)

Function for reading RX data from TWI.

Parameters
[in]p_twiTWI instance.
Returns
RX data.
__STATIC_INLINE void nrf_twi_shorts_clear ( NRF_TWI_Type *  p_twi,
uint32_t  short_mask 
)

Function for clearing shortcuts.

Parameters
[in]p_twiTWI instance.
[in]short_maskShortcuts mask.
__STATIC_INLINE void nrf_twi_shorts_set ( NRF_TWI_Type *  p_twi,
uint32_t  short_mask 
)

Function for setting a shortcut.

Parameters
[in]p_twiTWI instance.
[in]short_maskShortcuts mask.
__STATIC_INLINE uint32_t* nrf_twi_task_address_get ( NRF_TWI_Type *  p_twi,
nrf_twi_tasks_t  task 
)

Function for returning the address of a specific TWI task register.

Parameters
[in]p_twiTWI instance.
[in]taskTask.
Returns
Task address.
__STATIC_INLINE void nrf_twi_task_set ( NRF_TWI_Type *  p_twi,
nrf_twi_tasks_t  task 
)

Function for activating a specific TWI task.

Parameters
[in]p_twiTWI instance.
[in]taskTask.
__STATIC_INLINE void nrf_twi_txd_set ( NRF_TWI_Type *  p_twi,
uint8_t  data 
)

Function for writing data to TWI.

Parameters
[in]p_twiTWI instance.
[in]dataData to be transmitted.