38 #ifndef _IFX_I2C_CONFIG_H_ 39 #define _IFX_I2C_CONFIG_H_ 45 #ifdef IFX_I2C_CONFIG_EXTERNAL 46 #include "ifx_i2c_config_external.h" 57 #define IFX_I2C_BASE_ADDR (0x30) 60 #define PL_POLLING_INVERVAL_US (1000U) 62 #define PL_POLLING_MAX_CNT (200U) 64 #define PL_DATA_POLLING_INVERVAL_US (5000U) 66 #define PL_GUARD_TIME_INTERVAL_US (50U) 70 #ifdef IFX_I2C_FRAME_SIZE 71 #if (IFX_I2C_FRAME_SIZE > 277) || (IFX_I2C_FRAME_SIZE < 16) 72 #error "unsupported value" 75 #define IFX_I2C_FRAME_SIZE (19U) 79 #define TL_HEADER_SIZE (1U) 81 #define DL_HEADER_SIZE (5U) 83 #define DL_TRANS_REPEAT (3U) 85 #define PL_TRANS_TIMEOUT_MS (10U) 88 #define TL_MAX_EXIT_TIMEOUT (180U) 91 #define RESET_LOW_TIME_MSEC (2000U) 93 #define STARTUP_TIME_MSEC (12000U) 96 #define IFX_I2C_STACK_SUCCESS (0x0000) 98 #define IFX_I2C_STACK_BUSY (0x0001) 100 #define IFX_I2C_STACK_ERROR (0x0102) 102 #define IFX_I2C_STACK_MEM_ERROR (0x0104) 104 #define IFX_I2C_FATAL_ERROR (0x0106) 106 #define IFX_I2C_HANDSHAKE_ERROR (0x0107) 108 #define IFX_I2C_SESSION_ERROR (0x0108) 111 #define IFX_I2C_DL_HEADER_OFFSET (0U) 113 #define IFX_I2C_TL_HEADER_OFFSET (IFX_I2C_DL_HEADER_OFFSET + 3) 115 #define IFX_I2C_LOG_PL (0U) 117 #define IFX_I2C_LOG_DL (0U) 119 #define IFX_I2C_LOG_TL (0U) 121 #define IFX_I2C_LOG_PRL (0U) 124 #define IFX_I2C_LOG_ID_PL (0x00) 126 #define IFX_I2C_LOG_ID_DL (0x01) 128 #define IFX_I2C_LOG_ID_TL (0x02) 130 #define IFX_I2C_LOG_ID_PRL (0x03) 132 #define IFX_I2C_LOG_ID_PAL (0x04) 135 #if defined IFX_I2C_PRESENTATION_LAYER_TRANSPARENT 136 #define IFX_I2C_TL_ENABLE (1U) 138 #define IFX_I2C_PRESENCE_BIT (0x08) 139 #define IFX_I2C_PRL_MAC_SIZE (0x08) 140 #define IFX_I2C_PRL_HEADER_SIZE (0x05) 141 #define IFX_I2C_PRL_OVERHEAD_SIZE (IFX_I2C_PRL_HEADER_SIZE + IFX_I2C_PRL_MAC_SIZE) 143 #define IFX_I2C_DATA_OFFSET (IFX_I2C_PRL_HEADER_SIZE) 145 #define IFX_I2C_PRESENCE_BIT_CHECK (0x08) 148 #if defined OPTIGA_COMMS_SHIELDED_CONNECTION 149 #define IFX_I2C_PRL_ENABLED (1U) 150 #define IFX_I2C_TL_ENABLE (1U) 152 #define IFX_I2C_PRESENCE_BIT (0x08) 153 #define IFX_I2C_PRL_MAC_SIZE (0x08) 154 #define IFX_I2C_PRL_HEADER_SIZE (0x05) 155 #define IFX_I2C_PRL_OVERHEAD_SIZE (IFX_I2C_PRL_HEADER_SIZE + IFX_I2C_PRL_MAC_SIZE) 157 #define IFX_I2C_DATA_OFFSET (IFX_I2C_PRL_HEADER_SIZE) 159 #define IFX_I2C_PRESENCE_BIT_CHECK (0x08) 161 #define IFX_I2C_PRESENCE_BIT (0x00) 162 #define IFX_I2C_PRL_MAC_SIZE (0x00) 163 #define IFX_I2C_PRL_HEADER_SIZE (0x00) 164 #define IFX_I2C_PRL_OVERHEAD_SIZE (IFX_I2C_PRL_HEADER_SIZE + IFX_I2C_PRL_MAC_SIZE) 166 #define IFX_I2C_DATA_OFFSET (IFX_I2C_PRL_HEADER_SIZE) 168 #define IFX_I2C_PRESENCE_BIT_CHECK (0x00) 172 #define PROTOCOL_VERSION_PRE_SHARED_SECRET (0x01) 174 #define IFX_I2C_SESSION_CONTEXT_RESTORE (0x11) 176 #define IFX_I2C_SESSION_CONTEXT_SAVE (0x22) 178 #define IFX_I2C_SESSION_CONTEXT_NONE (0x33) 181 #define NO_PROTECTION (0x00) 183 #define MASTER_PROTECTION (0x01) 185 #define SLAVE_PROTECTION (0x02) 187 #define FULL_PROTECTION (0x03) 189 #define RE_ESTABLISH (0x80) 197 const uint8_t * data,
318 #if defined OPTIGA_COMMS_SHIELDED_CONNECTION 430 #if defined OPTIGA_COMMS_SHIELDED_CONNECTION 456 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION 473 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION 488 #if defined (OPTIGA_LIB_ENABLE_LOGGING) && defined (OPTIGA_LIB_ENABLE_COMMS_LOGGING) 504 #define OPTIGA_COMMS_LOG_MESSAGE(msg) \ 506 optiga_lib_print_message(msg,OPTIGA_COMMUNICATION_LAYER,OPTIGA_COMMUNICATION_LAYER_COLOR);\ 523 #define OPTIGA_COMMS_LOG_STATUS(return_value) \ 525 if (OPTIGA_LIB_SUCCESS != return_value) \ 527 optiga_lib_print_status(OPTIGA_COMMUNICATION_LAYER,OPTIGA_ERROR_COLOR,return_value); \ 531 optiga_lib_print_status(OPTIGA_COMMUNICATION_LAYER,OPTIGA_COMMUNICATION_LAYER_COLOR,return_value); \ 535 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION 554 #define OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA(array,array_len,p_ifx_i2c_ctx) \ 556 if (0 != frame_len) \ 558 if (((((ifx_i2c_context_t * )p_ifx_i2c_ctx)->protection_level & 0x0F) == 0x01) || \ 559 ((((ifx_i2c_context_t * )p_ifx_i2c_ctx)->protection_level & 0x0F) == 0x03)) \ 561 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_PROTECTED_DATA_COLOR); \ 565 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_UNPROTECTED_DATA_COLOR);\ 587 #define OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA(array,array_len,p_ifx_i2c_ctx) \ 589 if (((((ifx_i2c_context_t * )p_ifx_i2c_ctx)->protection_level & 0x0F) == 0x02) || \ 590 ((((ifx_i2c_context_t * )p_ifx_i2c_ctx)->protection_level & 0x0F) == 0x03)) \ 592 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_PROTECTED_DATA_COLOR); \ 596 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_UNPROTECTED_DATA_COLOR); \ 618 #define OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA(array,array_len,p_ifx_i2c_ctx) \ 620 OPTIGA_COMMS_LOG_MESSAGE("");\ 621 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_UNPROTECTED_DATA_COLOR);\ 641 #define OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA(array,array_len,p_ifx_i2c_ctx) \ 643 OPTIGA_COMMS_LOG_MESSAGE("");\ 644 optiga_lib_print_array_hex_format(array,array_len,OPTIGA_UNPROTECTED_DATA_COLOR);\ 651 #define OPTIGA_IFXI2C_LOG_TRANSMIT_HEX_DATA(array,array_len,p_ifx_i2c_ctx) {} 652 #define OPTIGA_IFXI2C_LOG_RECEIVE_HEX_DATA(array,array_len,p_ifx_i2c_ctx) {} 653 #define OPTIGA_COMMS_LOG_MESSAGE(msg) {} 654 #define OPTIGA_COMMS_LOG_STATUS(return_value) {} uint8_t * p_recv_payload_buffer
Pointer to user provided receive buffer.
Definition: ifx_i2c_config.h:375
uint8_t random[32]
Randon data.
Definition: ifx_i2c_config.h:389
This file provides the prototypes for the OPTIGA library logger.
ifx_i2c_prl_t prl
Presentation layer context.
Definition: ifx_i2c_config.h:475
uint8_t resynced
Resynced.
Definition: ifx_i2c_config.h:257
pal_i2c_t * p_pal_i2c_ctx
Pointer to pal i2c context.
Definition: ifx_i2c_config.h:429
ifx_i2c_event_handler_t upper_layer_event_handler
Definition: ifx_i2c_config.h:271
uint8_t associate_data[8]
Associate data buffer.
Definition: ifx_i2c_config.h:395
uint8_t alert_type
Alert type.
Definition: ifx_i2c_config.h:383
uint8_t session_key[40]
Buffer to store session key.
Definition: ifx_i2c_config.h:324
uint16_t frequency
Frequency of i2c master.
Definition: ifx_i2c_config.h:421
ifx_i2c_event_handler_t upper_layer_event_handler
Upper layer event handler.
Definition: ifx_i2c_config.h:315
Data store configuration structure.
Definition: ifx_i2c_config.h:340
uint8_t buffer[IFX_I2C_FRAME_SIZE+1]
Physical layer buffer.
Definition: ifx_i2c_config.h:206
uint8_t * p_recv_packet_buffer
Pointer to user provided receive buffer.
Definition: ifx_i2c_config.h:292
uint8_t protocol_version
Supported presentation layer protocol version.
Definition: ifx_i2c_config.h:463
uint16_t * p_recv_payload_buffer_length
Length of receive buffer.
Definition: ifx_i2c_config.h:377
uint32_t master_sequence_number
Master sequence number.
Definition: ifx_i2c_config.h:334
ifx_i2c_event_handler_t upper_layer_event_handler
Definition: ifx_i2c_config.h:409
uint16_t datastore_shared_secret_id
ID to read and write the shared secret.
Definition: ifx_i2c_config.h:345
uint8_t negotiation_state
Negotiation state.
Definition: ifx_i2c_config.h:330
uint8_t previous_chaining
State to check last chaining state.
Definition: ifx_i2c_config.h:302
uint8_t saved_sctr
Saved SCTR status byte.
Definition: ifx_i2c_config.h:381
struct ifx_i2c_context ifx_i2c_context_t
IFX I2C context structure.
Definition: ifx_i2c_config.h:192
uint16_t rx_buffer_size
Receive buffer size.
Definition: ifx_i2c_config.h:263
ifx_i2c_event_handler_t upper_layer_event_handler
Definition: ifx_i2c_config.h:229
uint8_t state
Transport layer state.
Definition: ifx_i2c_config.h:280
uint8_t * p_rx_frame_buffer
Pointer to main receive buffers.
Definition: ifx_i2c_config.h:267
void * p_upper_layer_ctx
Upper layer context.
Definition: ifx_i2c_config.h:437
uint8_t reset_type
type of reset
Definition: ifx_i2c_config.h:453
uint8_t * p_actual_payload
Pointer to packet provided by user.
Definition: ifx_i2c_config.h:371
optiga_lib_status_t error_event
Error event state.
Definition: ifx_i2c_config.h:306
ifx_i2c_tl_t tl
Transport layer context.
Definition: ifx_i2c_config.h:468
struct ifx_i2c_prl ifx_i2c_prl_t
Presentation layer structure.
ifx_i2c_context_t ifx_i2c_context_0
IFX I2C Instance.
Definition: ifx_i2c_config.c:92
ifx_i2c_prl_manage_context_t prl_saved_ctx
Definition: ifx_i2c_config.h:407
uint8_t master_chaining_error_count
Chaining error count for master.
Definition: ifx_i2c_config.h:300
uint16_t prl_receive_length
Receive buffer length.
Definition: ifx_i2c_config.h:397
uint8_t session_key[40]
Buffer to store prf.
Definition: ifx_i2c_config.h:387
uint32_t api_start_time
Start time of the transport layer API.
Definition: ifx_i2c_config.h:296
uint16_t packet_offset
Offset till which data is sent from p_actual_packet.
Definition: ifx_i2c_config.h:288
uint8_t prl_header_offset
Presentation header offset.
Definition: ifx_i2c_config.h:385
uint16_t tx_frame_len
Length of data to be sent.
Definition: ifx_i2c_config.h:227
uint8_t rx_seq_nr
Definition: ifx_i2c_config.h:249
struct ifx_i2c_prl_manage_context ifx_i2c_prl_manage_context_t
Presentation layer manage context structure.
uint8_t restore_context_flag
Restore context flag.
Definition: ifx_i2c_config.h:405
uint8_t mc_state
Manage context state.
Definition: ifx_i2c_config.h:363
#define IFX_I2C_FRAME_SIZE
Data link layer: frame size (max supported is 277 decimal). Note: This can be configured externally t...
Definition: ifx_i2c_config.h:75
uint8_t state
Definition: ifx_i2c_config.h:357
uint16_t * p_upper_layer_rx_buffer_len
Pointer to length of upper layer rx buffer.
Definition: ifx_i2c_config.h:441
pal_gpio_t * p_slave_vdd_pin
Pointer to pal gpio context for vdd.
Definition: ifx_i2c_config.h:425
uint8_t register_action
Action on register, read/write.
Definition: ifx_i2c_config.h:212
uint8_t manage_context_operation
Variable to indicate manage context operation.
Definition: ifx_i2c_config.h:465
Structure defines the PAL GPIO configuration.
Definition: pal_gpio.h:51
uint8_t rx_frame_buffer[IFX_I2C_FRAME_SIZE+1]
IFX I2C rx frame of max length.
Definition: ifx_i2c_config.h:480
uint32_t frame_start_time
Start time of sending frame.
Definition: ifx_i2c_config.h:269
upper_layer_callback_t upper_layer_event_handler
Upper layer event handler.
Definition: ifx_i2c_config.h:435
Presentation layer structure.
Definition: ifx_i2c_config.h:354
uint8_t negotiate_state
Negotiation state.
Definition: ifx_i2c_config.h:234
PAL I2C context structure.
Definition: pal_i2c.h:56
struct ifx_i2c_dl ifx_i2c_dl_t
Datalink layer structure.
uint16_t frame_size
Data link layer frame size.
Definition: ifx_i2c_config.h:423
uint8_t decryption_failure_counter
Master retransmit counter.
Definition: ifx_i2c_config.h:399
uint8_t frame_state
Frame state.
Definition: ifx_i2c_config.h:223
uint32_t slave_sequence_number
Slave sequence number.
Definition: ifx_i2c_config.h:367
uint8_t chaining_error_count
Chaining error coutn from slave.
Definition: ifx_i2c_config.h:298
struct ifx_i2c_datastore_config ifx_i2c_datastore_config_t
Data store configuration structure.
ifx_i2c_dl_t dl
Datalink layer context.
Definition: ifx_i2c_config.h:470
uint8_t * p_tx_frame_buffer
Pointer to main transmit buffers.
Definition: ifx_i2c_config.h:265
uint8_t tx_payload_offset
Tl tx payload copy offset.
Definition: ifx_i2c_config.h:310
uint8_t prl_txrx_buffer[58]
Receive buffer.
Definition: ifx_i2c_config.h:391
uint16_t buffer_rx_len
Rx length.
Definition: ifx_i2c_config.h:210
uint8_t negotiation_state
Handshake negotiation state.
Definition: ifx_i2c_config.h:361
This file provides the prototype declarations of PAL I2C.
uint8_t slave_address
I2C Slave address.
Definition: ifx_i2c_config.h:419
pal_gpio_t * p_slave_reset_pin
Pointer to pal gpio context for reset.
Definition: ifx_i2c_config.h:427
uint32_t save_slave_sequence_number
Save slave sequence number.
Definition: ifx_i2c_config.h:336
optiga_lib_status_t close_state
Close states.
Definition: ifx_i2c_config.h:451
IFX I2C context structure.
Definition: ifx_i2c_config.h:416
uint16_t buffer_tx_len
Tx length.
Definition: ifx_i2c_config.h:208
uint8_t tx_seq_nr
Tx sequence number.
Definition: ifx_i2c_config.h:247
uint8_t hs_state
Definition: ifx_i2c_config.h:359
uint8_t data_retransmit_counter
Slave retransmit counter.
Definition: ifx_i2c_config.h:401
This file provides API prototypes of platform abstraction layer for datastore operations.
uint8_t decryption_failure_counter
Master retransmit counter.
Definition: ifx_i2c_config.h:326
ifx_i2c_pl_t pl
Physical layer context.
Definition: ifx_i2c_config.h:472
uint16_t retry_counter
Retry counter.
Definition: ifx_i2c_config.h:216
uint8_t trans_repeat_status
Definition: ifx_i2c_config.h:411
uint8_t protection_level
Definition: ifx_i2c_config.h:461
uint8_t frame_action
Action of frame. Tx/Rx.
Definition: ifx_i2c_config.h:221
uint8_t action_rx_only
Indicate only Rx required.
Definition: ifx_i2c_config.h:251
struct ifx_i2c_pl ifx_i2c_pl_t
Physical layer structure.
This file provides the prototype declarations of PAL OS timer functionalities.
uint8_t protocol_version
Protocol version.
Definition: ifx_i2c_config.h:343
optiga_lib_status_t return_status
Return status.
Definition: ifx_i2c_config.h:403
uint8_t status
ifx i2c wrapper api status
Definition: ifx_i2c_config.h:447
uint8_t initialization_state
Initial state check.
Definition: ifx_i2c_config.h:312
uint16_t actual_packet_length
Actual length of user provided packet.
Definition: ifx_i2c_config.h:286
uint16_t shared_secret_length
Length of shared secret.
Definition: ifx_i2c_config.h:349
uint8_t sctr
SCTR status byte.
Definition: ifx_i2c_config.h:379
uint8_t * p_actual_packet
Pointer to packet provided by user.
Definition: ifx_i2c_config.h:282
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.
Definition: ifx_i2c_config.h:195
Transport layer structure.
Definition: ifx_i2c_config.h:275
Datalink layer structure.
Definition: ifx_i2c_config.h:240
uint8_t do_pal_init
init pal
Definition: ifx_i2c_config.h:455
uint16_t total_recv_length
Total received data.
Definition: ifx_i2c_config.h:284
uint8_t * p_tx_frame
Pointer to data to be sent.
Definition: ifx_i2c_config.h:225
uint32_t data_poll_timeout
Timeout value.
Definition: ifx_i2c_config.h:259
void(* upper_layer_callback_t)(void *upper_layer_ctx, optiga_lib_status_t event)
typedef for application event handler
Definition: optiga_lib_types.h:103
uint8_t tx_frame_buffer[IFX_I2C_FRAME_SIZE+1]
IFX I2C tx frame of max length.
Definition: ifx_i2c_config.h:478
uint8_t payload_offset
Tl rx payload copy offset.
Definition: ifx_i2c_config.h:308
uint16_t prl_txrx_receive_length
Receive txrx buffer length.
Definition: ifx_i2c_config.h:393
uint8_t error
Error occured.
Definition: ifx_i2c_config.h:255
uint8_t i2c_cmd
i2c read/i2c write
Definition: ifx_i2c_config.h:214
uint8_t retransmit_counter
Retransmit counter.
Definition: ifx_i2c_config.h:253
uint8_t request_soft_reset
Soft reset requested.
Definition: ifx_i2c_config.h:236
uint32_t save_slave_sequence_number
Save slave sequence number.
Definition: ifx_i2c_config.h:369
This file is defines the compilation switches to build code with required features.
uint16_t max_packet_length
Maximum length of packet at transport layer.
Definition: ifx_i2c_config.h:290
uint16_t optiga_lib_status_t
typedef for OPTIGA host library status
Definition: optiga_lib_types.h:97
uint8_t transmission_completed
transmission done
Definition: ifx_i2c_config.h:304
uint16_t * p_recv_packet_buffer_length
Length of receive buffer.
Definition: ifx_i2c_config.h:294
uint8_t data_retransmit_counter
Slave retransmit counter.
Definition: ifx_i2c_config.h:328
Presentation layer manage context structure.
Definition: ifx_i2c_config.h:321
struct ifx_i2c_tl ifx_i2c_tl_t
Transport layer structure.
Physical layer structure.
Definition: ifx_i2c_config.h:201
This file provides the prototype declarations of PAL GPIO.
ifx_i2c_datastore_config_t * ifx_i2c_datastore_config
Datastore configuration instance for prl.
Definition: ifx_i2c_config.h:432
uint32_t master_sequence_number
Master sequence number.
Definition: ifx_i2c_config.h:365
uint16_t tx_buffer_size
Transmit buffer size.
Definition: ifx_i2c_config.h:261
uint8_t state
Definition: ifx_i2c_config.h:445
uint16_t actual_payload_length
Total received data.
Definition: ifx_i2c_config.h:373
uint8_t reset_state
reset states
Definition: ifx_i2c_config.h:449
uint8_t * p_upper_layer_rx_buffer
Pointer to upper layer rx buffer.
Definition: ifx_i2c_config.h:439
uint16_t datastore_manage_context_id
ID to read and write the shielded connection context data.
Definition: ifx_i2c_config.h:347
uint8_t state
Datalink layer state.
Definition: ifx_i2c_config.h:245
uint8_t stored_context_flag
Stored context flag.
Definition: ifx_i2c_config.h:332
void * pal_os_event_ctx
Definition: ifx_i2c_config.h:481