OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
ifx_i2c_config.h File Reference

This file defines the structures and macros for the Infineon I2C Protocol. More...

#include "pal_i2c.h"
#include "pal_gpio.h"
#include "pal_os_timer.h"
#include "pal_os_datastore.h"
#include "optiga_lib_config.h"
#include "optiga_lib_logger.h"
Include dependency graph for ifx_i2c_config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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_prl_manage_context
 Presentation layer manage context structure. More...
 
struct  ifx_i2c_datastore_config
 Data store configuration structure. More...
 
struct  ifx_i2c_prl
 Presentation layer structure. More...
 
struct  ifx_i2c_context
 IFX I2C context structure. More...
 
#define IFX_I2C_BASE_ADDR   (0x30)
 I2C slave address of the Infineon device. More...
 
#define PL_POLLING_INVERVAL_US   (1000U)
 Physical Layer: polling interval in microseconds. More...
 
#define PL_POLLING_MAX_CNT   (200U)
 Physical layer: maximal attempts. More...
 
#define PL_DATA_POLLING_INVERVAL_US   (5000U)
 Physical Layer: data register polling interval in microseconds. More...
 
#define PL_GUARD_TIME_INTERVAL_US   (50U)
 Physical Layer: guard time interval in microseconds. More...
 
#define IFX_I2C_FRAME_SIZE   (19U)
 Data link layer: frame size (max supported is 277 decimal). Note: This can be configured externally to a lesser value due to platform restrictions. More...
 
#define TL_HEADER_SIZE   (1U)
 Transport Layer: header size. More...
 
#define DL_HEADER_SIZE   (5U)
 Data link layer: header size. More...
 
#define DL_TRANS_REPEAT   (3U)
 Data link layer: maximum number of retries in case of transmission error. More...
 
#define PL_TRANS_TIMEOUT_MS   (10U)
 Data link layer: Trans timeout in milliseconds. More...
 
#define TL_MAX_EXIT_TIMEOUT   (180U)
 Transport layer: Maximum exit timeout in seconds. More...
 
#define RESET_LOW_TIME_MSEC   (2000U)
 Reset low time for GPIO pin toggling. More...
 
#define STARTUP_TIME_MSEC   (12000U)
 Start up time. More...
 
#define IFX_I2C_STACK_SUCCESS   (0x0000)
 Protocol Stack: Status codes for success. More...
 
#define IFX_I2C_STACK_BUSY   (0x0001)
 Protocol Stack: Status codes busy. More...
 
#define IFX_I2C_STACK_ERROR   (0x0102)
 Protocol Stack: Status codes for error. More...
 
#define IFX_I2C_STACK_MEM_ERROR   (0x0104)
 Protocol Stack: Memory insufficient. More...
 
#define IFX_I2C_FATAL_ERROR   (0x0106)
 Protocol Stack: Fatal error. Used internal to IFX I2C Stack. More...
 
#define IFX_I2C_HANDSHAKE_ERROR   (0x0107)
 Protocol Stack: handshake error. More...
 
#define IFX_I2C_SESSION_ERROR   (0x0108)
 Protocol Stack: session error. More...
 
#define IFX_I2C_DL_HEADER_OFFSET   (0U)
 Offset of Datalink header in tx_frame_buffer. More...
 
#define IFX_I2C_TL_HEADER_OFFSET   (IFX_I2C_DL_HEADER_OFFSET + 3)
 Offset of Transport header in tx_frame_buffer. More...
 
#define IFX_I2C_LOG_PL   (0U)
 Protocol Stack debug switch for physical layer (set to 0 or 1) More...
 
#define IFX_I2C_LOG_DL   (0U)
 Protocol Stack debug switch for data link layer (set to 0 or 1) More...
 
#define IFX_I2C_LOG_TL   (0U)
 Protocol Stack debug switch for transport layer (set to 0 or 1) More...
 
#define IFX_I2C_LOG_PRL   (0U)
 Protocol Stack debug switch for presentation layer (set to 0 or 1) More...
 
#define IFX_I2C_LOG_ID_PL   (0x00)
 Log ID number for physical layer. More...
 
#define IFX_I2C_LOG_ID_DL   (0x01)
 Log ID number for data link layer. More...
 
#define IFX_I2C_LOG_ID_TL   (0x02)
 Log ID number for transport layer. More...
 
#define IFX_I2C_LOG_ID_PRL   (0x03)
 Log ID number for presentation layer. More...
 
#define IFX_I2C_LOG_ID_PAL   (0x04)
 Log ID number for platform abstraction layer. More...
 
#define IFX_I2C_PRL_ENABLED   (1U)
 
#define IFX_I2C_TL_ENABLE   (1U)
 
#define IFX_I2C_PRESENCE_BIT   (0x08)
 
#define IFX_I2C_PRL_MAC_SIZE   (0x08)
 
#define IFX_I2C_PRL_HEADER_SIZE   (0x05)
 
#define IFX_I2C_PRL_OVERHEAD_SIZE   (IFX_I2C_PRL_HEADER_SIZE + IFX_I2C_PRL_MAC_SIZE)
 Overhead buffer size for user buffer. More...
 
#define IFX_I2C_DATA_OFFSET   (IFX_I2C_PRL_HEADER_SIZE)
 Offset for data. More...
 
#define IFX_I2C_PRESENCE_BIT_CHECK   (0x08)
 
#define PROTOCOL_VERSION_PRE_SHARED_SECRET   (0x01)
 Pre shared secret protocol version. More...
 
#define IFX_I2C_SESSION_CONTEXT_RESTORE   (0x11)
 To restore saved secure session. More...
 
#define IFX_I2C_SESSION_CONTEXT_SAVE   (0x22)
 To store active secure session. More...
 
#define IFX_I2C_SESSION_CONTEXT_NONE   (0x33)
 For no manage context operation. More...
 
#define NO_PROTECTION   (0x00)
 When data from master and slave is unprotected. More...
 
#define MASTER_PROTECTION   (0x01)
 When data from master is protected and data from slave is unprotected. More...
 
#define SLAVE_PROTECTION   (0x02)
 When data from master is unprotected and data from is slave protected. More...
 
#define FULL_PROTECTION   (0x03)
 When data from master and slave protected. More...
 
#define RE_ESTABLISH   (0x80)
 To re-establish secure channel. More...
 
#define OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA(array, array_len, p_ifx_i2c_ctx)   {}
 
#define OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA(array, array_len, p_ifx_i2c_ctx)   {}
 
#define OPTIGA_COMMS_LOG_MESSAGE(msg)   {}
 
#define OPTIGA_COMMS_LOG_STATUS(return_value)   {}
 
typedef struct ifx_i2c_context ifx_i2c_context_t
 IFX I2C context structure. More...
 
typedef void(* ifx_i2c_event_handler_t) (struct ifx_i2c_context *p_ctx, optiga_lib_status_t event, const uint8_t *data, uint16_t data_len)
 Event handler function prototype. More...
 
typedef struct ifx_i2c_pl ifx_i2c_pl_t
 Physical layer structure. More...
 
typedef struct ifx_i2c_dl ifx_i2c_dl_t
 Datalink layer structure. More...
 
typedef struct ifx_i2c_tl ifx_i2c_tl_t
 Transport layer structure. More...
 
typedef struct ifx_i2c_prl_manage_context ifx_i2c_prl_manage_context_t
 Presentation layer manage context structure. More...
 
typedef struct ifx_i2c_datastore_config ifx_i2c_datastore_config_t
 Data store configuration structure. More...
 
typedef struct ifx_i2c_prl ifx_i2c_prl_t
 Presentation layer structure. More...
 
ifx_i2c_context_t ifx_i2c_context_0
 IFX I2C Instance. More...
 

Detailed Description

This file defines the structures and macros for the Infineon I2C Protocol.

Copyright (c) 2019 Infineon Technologies AG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

\endcopyright

Author
Infineon Technologies AG

Macro Definition Documentation

◆ DL_HEADER_SIZE

#define DL_HEADER_SIZE   (5U)

Data link layer: header size.

◆ DL_TRANS_REPEAT

#define DL_TRANS_REPEAT   (3U)

Data link layer: maximum number of retries in case of transmission error.

◆ FULL_PROTECTION

#define FULL_PROTECTION   (0x03)

When data from master and slave protected.

◆ IFX_I2C_BASE_ADDR

#define IFX_I2C_BASE_ADDR   (0x30)

I2C slave address of the Infineon device.

◆ IFX_I2C_DATA_OFFSET

#define IFX_I2C_DATA_OFFSET   (IFX_I2C_PRL_HEADER_SIZE)

Offset for data.

◆ IFX_I2C_DL_HEADER_OFFSET

#define IFX_I2C_DL_HEADER_OFFSET   (0U)

Offset of Datalink header in tx_frame_buffer.

◆ IFX_I2C_FATAL_ERROR

#define IFX_I2C_FATAL_ERROR   (0x0106)

Protocol Stack: Fatal error. Used internal to IFX I2C Stack.

◆ IFX_I2C_FRAME_SIZE

#define IFX_I2C_FRAME_SIZE   (19U)

Data link layer: frame size (max supported is 277 decimal). Note: This can be configured externally to a lesser value due to platform restrictions.

◆ IFX_I2C_HANDSHAKE_ERROR

#define IFX_I2C_HANDSHAKE_ERROR   (0x0107)

Protocol Stack: handshake error.

◆ IFX_I2C_LOG_DL

#define IFX_I2C_LOG_DL   (0U)

Protocol Stack debug switch for data link layer (set to 0 or 1)

◆ IFX_I2C_LOG_ID_DL

#define IFX_I2C_LOG_ID_DL   (0x01)

Log ID number for data link layer.

◆ IFX_I2C_LOG_ID_PAL

#define IFX_I2C_LOG_ID_PAL   (0x04)

Log ID number for platform abstraction layer.

◆ IFX_I2C_LOG_ID_PL

#define IFX_I2C_LOG_ID_PL   (0x00)

Log ID number for physical layer.

◆ IFX_I2C_LOG_ID_PRL

#define IFX_I2C_LOG_ID_PRL   (0x03)

Log ID number for presentation layer.

◆ IFX_I2C_LOG_ID_TL

#define IFX_I2C_LOG_ID_TL   (0x02)

Log ID number for transport layer.

◆ IFX_I2C_LOG_PL

#define IFX_I2C_LOG_PL   (0U)

Protocol Stack debug switch for physical layer (set to 0 or 1)

◆ IFX_I2C_LOG_PRL

#define IFX_I2C_LOG_PRL   (0U)

Protocol Stack debug switch for presentation layer (set to 0 or 1)

◆ IFX_I2C_LOG_TL

#define IFX_I2C_LOG_TL   (0U)

Protocol Stack debug switch for transport layer (set to 0 or 1)

◆ IFX_I2C_PRESENCE_BIT

#define IFX_I2C_PRESENCE_BIT   (0x08)

◆ IFX_I2C_PRESENCE_BIT_CHECK

#define IFX_I2C_PRESENCE_BIT_CHECK   (0x08)

◆ IFX_I2C_PRL_ENABLED

#define IFX_I2C_PRL_ENABLED   (1U)

◆ IFX_I2C_PRL_HEADER_SIZE

#define IFX_I2C_PRL_HEADER_SIZE   (0x05)

◆ IFX_I2C_PRL_MAC_SIZE

#define IFX_I2C_PRL_MAC_SIZE   (0x08)

◆ IFX_I2C_PRL_OVERHEAD_SIZE

#define IFX_I2C_PRL_OVERHEAD_SIZE   (IFX_I2C_PRL_HEADER_SIZE + IFX_I2C_PRL_MAC_SIZE)

Overhead buffer size for user buffer.

◆ IFX_I2C_SESSION_CONTEXT_NONE

#define IFX_I2C_SESSION_CONTEXT_NONE   (0x33)

For no manage context operation.

◆ IFX_I2C_SESSION_CONTEXT_RESTORE

#define IFX_I2C_SESSION_CONTEXT_RESTORE   (0x11)

To restore saved secure session.

◆ IFX_I2C_SESSION_CONTEXT_SAVE

#define IFX_I2C_SESSION_CONTEXT_SAVE   (0x22)

To store active secure session.

◆ IFX_I2C_SESSION_ERROR

#define IFX_I2C_SESSION_ERROR   (0x0108)

Protocol Stack: session error.

◆ IFX_I2C_STACK_BUSY

#define IFX_I2C_STACK_BUSY   (0x0001)

Protocol Stack: Status codes busy.

◆ IFX_I2C_STACK_ERROR

#define IFX_I2C_STACK_ERROR   (0x0102)

Protocol Stack: Status codes for error.

◆ IFX_I2C_STACK_MEM_ERROR

#define IFX_I2C_STACK_MEM_ERROR   (0x0104)

Protocol Stack: Memory insufficient.

◆ IFX_I2C_STACK_SUCCESS

#define IFX_I2C_STACK_SUCCESS   (0x0000)

Protocol Stack: Status codes for success.

◆ IFX_I2C_TL_ENABLE

#define IFX_I2C_TL_ENABLE   (1U)

◆ IFX_I2C_TL_HEADER_OFFSET

#define IFX_I2C_TL_HEADER_OFFSET   (IFX_I2C_DL_HEADER_OFFSET + 3)

Offset of Transport header in tx_frame_buffer.

◆ MASTER_PROTECTION

#define MASTER_PROTECTION   (0x01)

When data from master is protected and data from slave is unprotected.

◆ NO_PROTECTION

#define NO_PROTECTION   (0x00)

When data from master and slave is unprotected.

◆ OPTIGA_COMMS_LOG_MESSAGE

#define OPTIGA_COMMS_LOG_MESSAGE (   msg)    {}

◆ OPTIGA_COMMS_LOG_STATUS

#define OPTIGA_COMMS_LOG_STATUS (   return_value)    {}

◆ OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA

#define OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA (   array,
  array_len,
  p_ifx_i2c_ctx 
)    {}

◆ OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA

#define OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA (   array,
  array_len,
  p_ifx_i2c_ctx 
)    {}

◆ PL_DATA_POLLING_INVERVAL_US

#define PL_DATA_POLLING_INVERVAL_US   (5000U)

Physical Layer: data register polling interval in microseconds.

◆ PL_GUARD_TIME_INTERVAL_US

#define PL_GUARD_TIME_INTERVAL_US   (50U)

Physical Layer: guard time interval in microseconds.

◆ PL_POLLING_INVERVAL_US

#define PL_POLLING_INVERVAL_US   (1000U)

Physical Layer: polling interval in microseconds.

◆ PL_POLLING_MAX_CNT

#define PL_POLLING_MAX_CNT   (200U)

Physical layer: maximal attempts.

◆ PL_TRANS_TIMEOUT_MS

#define PL_TRANS_TIMEOUT_MS   (10U)

Data link layer: Trans timeout in milliseconds.

◆ PROTOCOL_VERSION_PRE_SHARED_SECRET

#define PROTOCOL_VERSION_PRE_SHARED_SECRET   (0x01)

Pre shared secret protocol version.

◆ RE_ESTABLISH

#define RE_ESTABLISH   (0x80)

To re-establish secure channel.

◆ RESET_LOW_TIME_MSEC

#define RESET_LOW_TIME_MSEC   (2000U)

Reset low time for GPIO pin toggling.

◆ SLAVE_PROTECTION

#define SLAVE_PROTECTION   (0x02)

When data from master is unprotected and data from is slave protected.

◆ STARTUP_TIME_MSEC

#define STARTUP_TIME_MSEC   (12000U)

Start up time.

◆ TL_HEADER_SIZE

#define TL_HEADER_SIZE   (1U)

Transport Layer: header size.

◆ TL_MAX_EXIT_TIMEOUT

#define TL_MAX_EXIT_TIMEOUT   (180U)

Transport layer: Maximum exit timeout in seconds.

Typedef Documentation

◆ ifx_i2c_context_t

IFX I2C context structure.

◆ ifx_i2c_datastore_config_t

Data store configuration structure.

◆ ifx_i2c_dl_t

typedef struct ifx_i2c_dl ifx_i2c_dl_t

Datalink layer structure.

◆ ifx_i2c_event_handler_t

typedef void( * ifx_i2c_event_handler_t) (struct ifx_i2c_context *p_ctx, optiga_lib_status_t event, const uint8_t *data, uint16_t data_len)

Event handler function prototype.

◆ ifx_i2c_pl_t

typedef struct ifx_i2c_pl ifx_i2c_pl_t

Physical layer structure.

◆ ifx_i2c_prl_manage_context_t

Presentation layer manage context structure.

◆ ifx_i2c_prl_t

typedef struct ifx_i2c_prl ifx_i2c_prl_t

Presentation layer structure.

◆ ifx_i2c_tl_t

typedef struct ifx_i2c_tl ifx_i2c_tl_t

Transport layer structure.

Variable Documentation

◆ ifx_i2c_context_0

ifx_i2c_context_t ifx_i2c_context_0

IFX I2C Instance.

IFX I2C Instance.

  • The following parameters in ifx_i2c_context_t must be initialized with appropriate values
    • slave address : Address of I2C slave
    • frame_size : Frame size in bytes. Minimum supported value is 16 bytes.
      • It is recommended not to use a value greater than the slave's frame size.
      • The user specified frame size is written to I2C slave's frame size register. The frame size register is read back from I2C slave. This frame value is used by the ifx-i2c protocol even if it is not equal to the user specified value.
    • frequency : Frequency/speed of I2C master in KHz.
      • This must be lowest of the maximum frequency supported by the devices (master/slave) connected on the bus.
      • Initial negotiation starts with a frequency of 100KHz.
      • If the user specified frequency is more than 400 KHz, the I2C slave is configured to operate in "Fm+" mode, otherwise the I2C slave is configured for "SM & Fm" mode.
      • If the user specified frequency negotiation fails, the I2C master frequency remains at 100KHz
    • upper_layer_event_handler : Upper layer event handler. This is invoked when ifx_i2c_open() is asynchronously completed.
    • upper_layer_ctx : Context of upper layer.
    • p_slave_vdd_pin : GPIO pin for VDD. If not set, cold reset is not done.
    • p_slave_reset_pin : GPIO pin for Reset. If not set, warm reset is not done.
    • ifx_i2c_datastore_config : Data store configuration instance
  • The other fields must be initialized by the user of the structure.