nRF5 SDK v17.1.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Infineon I2C protocol APIs

Infineon I2C protocol stack library. More...

Data Structures

struct  ifx_i2c_pl
 Physical layer structure. More...
 
struct  ifx_i2c_dl
 Datalink layer structure. More...
 
struct  ifx_i2c_tl
 Transport layer structure. More...
 
struct  ifx_i2c_context
 IFX I2C context structure. More...
 

Macros

#define IFX_I2C_BASE_ADDR   (0x30)
 I2C slave address of the Infineon device.
 
#define PL_POLLING_INVERVAL_US   (1000)
 Physical Layer: polling interval in microseconds.
 
#define PL_POLLING_MAX_CNT   (200)
 Physical layer: maximal attempts.
 
#define PL_DATA_POLLING_INVERVAL_US   (5000)
 Physical Layer: data register polling interval in microseconds.
 
#define PL_GUARD_TIME_INTERVAL_US   (50)
 Physical Layer: guard time interval in microseconds.
 
#define DL_MAX_FRAME_SIZE   (300)
 Data link layer: maximum frame size.
 
#define DL_HEADER_SIZE   (5)
 Data link layer: header size.
 
#define DL_TRANS_REPEAT   (3)
 Data link layer: maximum number of retries in case of transmission error.
 
#define PL_TRANS_TIMEOUT_MS   (10)
 Data link layer: Trans timeout in milliseconds.
 
#define TL_MAX_EXIT_TIMEOUT   (6)
 Transport layer: Maximum exit timeout in seconds.
 
#define RESET_LOW_TIME_MSEC   (2000)
 Reset low time for GPIO pin toggling.
 
#define STARTUP_TIME_MSEC   (12000)
 Start up time.
 
#define IFX_I2C_STACK_SUCCESS   (0x00)
 Protocol Stack: Status codes for success.
 
#define IFX_I2C_STACK_ERROR   (0x01)
 Protocol Stack: Status codes for error.
 
#define IFX_I2C_STACK_BUSY   (0x02)
 Protocol Stack: Status codes busy.
 
#define IFX_I2C_STACK_MEM_ERROR   (0x03)
 Protocol Stack: Memory insufficient.
 
#define IFX_I2C_FATAL_ERROR   (0x04)
 Protocol Stack: Fatal error. Used internal to IFX I2C Stack.
 
#define IFX_I2C_DL_HEADER_OFFSET   (0)
 Offset of Datalink header in tx_frame_buffer.
 
#define IFX_I2C_TL_HEADER_OFFSET   (IFX_I2C_DL_HEADER_OFFSET+3)
 Offset of Transport header in tx_frame_buffer.
 
#define IFX_I2C_LOG_PL   0
 Protocol Stack debug switch for physical layer (set to 0 or 1)
 
#define IFX_I2C_LOG_DL   0
 Protocol Stack debug switch for data link layer (set to 0 or 1)
 
#define IFX_I2C_LOG_TL   0
 Protocol Stack debug switch for transport layer (set to 0 or 1)
 
#define IFX_I2C_LOG_ID_PL   0x00
 Log ID number for physical layer.
 
#define IFX_I2C_LOG_ID_DL   0x01
 Log ID number for data link layer.
 
#define IFX_I2C_LOG_ID_TL   0x02
 Log ID number for transport layer.
 
#define IFX_I2C_LOG_ID_PAL   0x04
 Log ID number for platform abstraction layer.
 
#define IFX_I2C_DL_EVENT_ERROR   (0x01)
 Error event propagated to upper layer.
 
#define IFX_I2C_DL_EVENT_TX_SUCCESS   (0x02)
 Transmit success event propagated to upper layer (bit field 1)
 
#define IFX_I2C_DL_EVENT_RX_SUCCESS   (0x04)
 Receive success event propagated to upper layer (bit field 3)
 

Typedefs

typedef enum ifx_i2c_reset_type ifx_i2c_reset_type_t
 IFX I2C Reset types.
 
typedef void(* ifx_i2c_event_handler_t )(struct ifx_i2c_context *ctx, host_lib_status_t event, const uint8_t *data, uint16_t data_len)
 Event handler function prototype.
 
typedef struct ifx_i2c_pl ifx_i2c_pl_t
 Physical layer structure.
 
typedef struct ifx_i2c_dl ifx_i2c_dl_t
 Datalink layer structure.
 
typedef struct ifx_i2c_tl ifx_i2c_tl_t
 Transport layer structure.
 
typedef struct ifx_i2c_context ifx_i2c_context_t
 IFX I2C context structure.
 

Enumerations

enum  ifx_i2c_reset_type {
  IFX_I2C_COLD_RESET = 0U,
  IFX_I2C_SOFT_RESET = 1U,
  IFX_I2C_WARM_RESET = 2U
}
 IFX I2C Reset types. More...
 

Functions

host_lib_status_t ifx_i2c_open (ifx_i2c_context_t *p_ctx)
 Initializes the IFX I2C protocol stack for a given context.
 
host_lib_status_t ifx_i2c_reset (ifx_i2c_context_t *p_ctx, ifx_i2c_reset_type_t reset_type)
 Resets the I2C slave.
 
host_lib_status_t ifx_i2c_transceive (ifx_i2c_context_t *p_ctx, const uint8_t *p_data, const uint16_t *p_data_length, uint8_t *p_buffer, uint16_t *p_buffer_len)
 Sends a command and receives a response for the command.
 
host_lib_status_t ifx_i2c_close (ifx_i2c_context_t *p_ctx)
 Closes the IFX I2C protocol stack for a given context.
 
host_lib_status_t ifx_i2c_set_slave_address (ifx_i2c_context_t *p_ctx, uint8_t slave_address, uint8_t persistent)
 Sets the slave address of the target device.
 
host_lib_status_t ifx_i2c_dl_init (ifx_i2c_context_t *p_ctx, ifx_i2c_event_handler_t handler)
 Function for initializing the module. More...
 
host_lib_status_t ifx_i2c_dl_send_frame (ifx_i2c_context_t *p_ctx, uint16_t frame_len)
 Function for sending a frame. More...
 
host_lib_status_t ifx_i2c_dl_receive_frame (ifx_i2c_context_t *p_ctx)
 Function for receiving a frame. More...
 
host_lib_status_t ifx_i2c_pl_init (ifx_i2c_context_t *p_ctx, ifx_i2c_event_handler_t handler)
 Function for initializing the module. More...
 
host_lib_status_t ifx_i2c_pl_send_frame (ifx_i2c_context_t *p_ctx, uint8_t *p_frame, uint16_t frame_len)
 Function for sending a frame. More...
 
host_lib_status_t ifx_i2c_pl_receive_frame (ifx_i2c_context_t *p_ctx)
 Function for receiving a frame. More...
 
host_lib_status_t ifx_i2c_pl_write_slave_address (ifx_i2c_context_t *p_ctx, uint8_t slave_address, uint8_t storage_type)
 Function for setting slave address. More...
 
host_lib_status_t ifx_i2c_tl_init (ifx_i2c_context_t *p_ctx, ifx_i2c_event_handler_t handler)
 Function for initializing the module. More...
 
host_lib_status_t ifx_i2c_tl_transceive (ifx_i2c_context_t *p_ctx, uint8_t *p_packet, uint16_t packet_len, uint8_t *p_recv_packet, uint16_t *recv_packet_len)
 Function to transmit and receive a packet. More...
 

Variables

ifx_i2c_context_t ifx_i2c_context_0
 IFX I2C Instance.
 

Detailed Description

Infineon I2C protocol stack library.

Enumeration Type Documentation

IFX I2C Reset types.

Enumerator
IFX_I2C_COLD_RESET 

Cold reset. Both reset pin and vdd pin are toggled low and then high.

IFX_I2C_SOFT_RESET 

Soft reset. 0x0000 is written to IFX-I2C Soft reset register.

IFX_I2C_WARM_RESET 

Warm reset. Only reset pin is toggled low and then high.

Function Documentation

host_lib_status_t ifx_i2c_dl_init ( ifx_i2c_context_t p_ctx,
ifx_i2c_event_handler_t  handler 
)

Function for initializing the module.

Function initializes and enables the module and registers an event handler to receive events from this module.

Attention
This function must be called before using the module.
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]handlerFunction pointer to the event handler of the upper layer.
Return values
IFX_I2C_STACK_SUCCESSIf initialization was successful.
IFX_I2C_STACK_ERRORIf the module is already initialized.
host_lib_status_t ifx_i2c_dl_receive_frame ( ifx_i2c_context_t p_ctx)

Function for receiving a frame.

Asynchronous function to receive a frame. The function returns immediately. One of the following events is propagated to the event handler registered with ifx_i2c_dl_init.

Parameters
[in,out]p_ctxPointer to ifx i2c context.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf the module is busy.
host_lib_status_t ifx_i2c_dl_send_frame ( ifx_i2c_context_t p_ctx,
uint16_t  frame_len 
)

Function for sending a frame.

Asynchronous function to send a frame. The function returns immediately. One of the following events is propagated to the event handler registered with ifx_i2c_dl_init.

Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]frame_lenFrame length.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf the module is busy.
host_lib_status_t ifx_i2c_pl_init ( ifx_i2c_context_t p_ctx,
ifx_i2c_event_handler_t  handler 
)

Function for initializing the module.

Function initializes and enables the module and registers an event handler to receive events from this module.

Attention
This function must be called before using the module.
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]handlerFunction pointer to the event handler of the upper layer.
Return values
IFX_I2C_STACK_SUCCESSIf initialization was successful.
IFX_I2C_STACK_ERRORIf the module is already initialized.
host_lib_status_t ifx_i2c_pl_receive_frame ( ifx_i2c_context_t p_ctx)

Function for receiving a frame.

Asynchronous function to receive a frame. The function returns immediately. One of the following events is propagated to the event handler registered with ifx_i2c_pl_init

Parameters
[in]p_ctxPointer to ifx i2c context.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf the module is busy.
host_lib_status_t ifx_i2c_pl_send_frame ( ifx_i2c_context_t p_ctx,
uint8_t *  p_frame,
uint16_t  frame_len 
)

Function for sending a frame.

Asynchronous function to send a frame. The function returns immediately. One of the following events is propagated to the event handler registered with ifx_i2c_pl_init

Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]p_frameBuffer containing the frame.
[in]frame_lenFrame length.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf the module is busy.
host_lib_status_t ifx_i2c_pl_write_slave_address ( ifx_i2c_context_t p_ctx,
uint8_t  slave_address,
uint8_t  storage_type 
)

Function for setting slave address.

Synchronous function to set slave address.

Parameters
[in]p_ctxPointer to ifx i2c context.
[in]slave_addressHolds new slave address[7 Bit] to be set.
[in]storage_typeStorage type.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf setting slave address fails.
host_lib_status_t ifx_i2c_tl_init ( ifx_i2c_context_t p_ctx,
ifx_i2c_event_handler_t  handler 
)

Function for initializing the module.

Function initializes and enables the module and registers an event handler to receive events from this module.

Attention
This function must be called before using the module.
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]handlerFunction pointer to the event handler of the upper layer.
Return values
IFX_I2C_STACK_SUCCESSIf initialization was successful.
IFX_I2C_STACK_ERRORIf the module is already initialized.
host_lib_status_t ifx_i2c_tl_transceive ( ifx_i2c_context_t p_ctx,
uint8_t *  p_packet,
uint16_t  packet_len,
uint8_t *  p_recv_packet,
uint16_t *  recv_packet_len 
)

Function to transmit and receive a packet.

Asynchronous function to send and receive a packet. The function returns immediately. One of the following events is propagated to the event handler registered with ifx_i2c_tl_init

Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]p_packetBuffer containing the packet header.
[in]packet_lenPacket header length.
[in]p_recv_packetBuffer containing the packet payload.
[in]recv_packet_lenPacket payload length.
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_STACK_ERRORIf the module is busy.

Documentation feedback | Developer Zone | Subscribe | Updated