diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-08-23 17:08:59 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-08-23 17:12:21 +0200 |
commit | 3061ecca3d0fdfb87dabbf5f63c9e06c2a30f53a (patch) | |
tree | ab49cc16ed0b853452c5c2ed2d3042416d628986 /thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include | |
download | iot-sensors-master.tar.gz iot-sensors-master.tar.bz2 iot-sensors-master.tar.xz iot-sensors-master.zip |
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include')
14 files changed, 1499 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/Datatypes.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/Datatypes.h new file mode 100644 index 0000000..2e056fe --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/Datatypes.h @@ -0,0 +1,122 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file contains the type definitions for the fundamental data types. +* +* +* +*/ + +#ifndef _DATATYPES_H_ +#define _DATATYPES_H_ + +/****************************************************************************** +* required includes +* Setup common include order for the used types and definitions +******************************************************************************/ +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +/****************************************************************************** +* DataTypes.h +******************************************************************************/ + +/****************************************************************************** +* defines +******************************************************************************/ + +/// @cond hidden +#ifndef _OPTIGA_EXPORTS_DLLEXPORT_H_ +#define _OPTIGA_EXPORTS_DLLEXPORT_H_ + +#if defined(WIN32) || defined(_WIN32) + +#ifdef OPTIGA_LIB_EXPORTS +#define LIBRARY_EXPORTS __declspec(dllexport) +#elif defined(OPTIGA_LIB_EXCLUDE_IMPORT) +#define LIBRARY_EXPORTS +#else +#define LIBRARY_EXPORTS __declspec(dllimport) +#endif // OPTIGA_LIB_EXPORTS + +#else +#define LIBRARY_EXPORTS +#endif //WIN32 + +#endif /*_OPTIGA_EXPORTS_DLLEXPORT_H_*/ +/// @endcond + +/// Definition for false +#ifndef FALSE +#define FALSE 0 +#endif + +/// Definition for true +#ifndef TRUE +#define TRUE 1 +#endif + +/****************************************************************************** +* fundamental typedefs +******************************************************************************/ + +/// Typedef for one byte integer +typedef char char_t; + +/// Typedef for native byte pointer +typedef uint8_t* puint8_t; + +/// Typedef for a 4 byte unsigned integer pointer +typedef uint32_t* puint32_t; + +/// Typedef for unsigned word pointer +typedef uint16_t* puint16_t ; + +/// Typedef for a void +typedef void Void; + +/// Typedef for a double word +typedef double double_t; + +/// Typedef for a float +typedef float float_t; + +/// Typedef for a boolean +typedef uint8_t bool_t; + +/// Typedef for Handle +typedef Void* hdl_t; + +/// typedef for host library status +typedef uint16_t host_lib_status_t; + +/** + * \brief Structure to specify a byte stream consisting of length and data + * pointer. + */ +typedef struct sbBlob_d +{ + /// Length of the byte stream + uint16_t wLen; + + /// Pointer to byte array which contains the data stream + uint8_t *prgbStream; +} sbBlob_d; + +/// typedef for application event handler +typedef void (*app_event_handler_t)(void* upper_layer_ctx, host_lib_status_t event); + +#ifndef _STATIC_H +#define _STATIC_H static +#endif +#endif /* __DATATYPES_H__ */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c.h new file mode 100644 index 0000000..0a3b586 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c.h @@ -0,0 +1,90 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file ifx_i2c.h +* +* \brief This file defines the API prototype for IFX I2C protocol v1.65 wrapper. +* +* \addtogroup grIFXI2C +* @{ +*/ + +#ifndef _IFXI2C_H_ +#define _IFXI2C_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************************************************************** + * HEADER FILES + **********************************************************************************************************************/ +#include "Datatypes.h" +#include "ifx_i2c_config.h" +/*********************************************************************************************************************** +* MACROS +***********************************************************************************************************************/ + +/*********************************************************************************************************************** + +* ENUMS +***********************************************************************************************************************/ + +/** @brief IFX I2C Reset types */ +typedef enum ifx_i2c_reset_type +{ + /// Cold reset. Both reset pin and vdd pin are toggled low and then high + IFX_I2C_COLD_RESET = 0U, + /// Soft reset. 0x0000 is written to IFX-I2C Soft reset register + IFX_I2C_SOFT_RESET = 1U, + /// Warm reset. Only reset pin is toggled low and then high + IFX_I2C_WARM_RESET = 2U +} ifx_i2c_reset_type_t; +/*********************************************************************************************************************** +* DATA STRUCTURES +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* API PROTOTYPES +**********************************************************************************************************************/ + +/** + * \brief Initializes the IFX I2C protocol stack for a given context. + */ +host_lib_status_t ifx_i2c_open(ifx_i2c_context_t *p_ctx); + +/** + * \brief Resets the I2C slave. + */ +host_lib_status_t ifx_i2c_reset(ifx_i2c_context_t *p_ctx, ifx_i2c_reset_type_t reset_type); + +/** + * \brief Sends a command and receives a response for the command. + */ +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); + +/** + * \brief Closes the IFX I2C protocol stack for a given context. + */ +host_lib_status_t ifx_i2c_close(ifx_i2c_context_t *p_ctx); + +/** + * \brief Sets the slave address of the target device. + */ +host_lib_status_t ifx_i2c_set_slave_address(ifx_i2c_context_t *p_ctx, uint8_t slave_address, uint8_t persistent); + +#ifdef __cplusplus +} +#endif +#endif /* _IFXI2C_H_ */ +/** + * @} + **/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_config.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_config.h new file mode 100644 index 0000000..bf1fa2f --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_config.h @@ -0,0 +1,296 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file ifx_i2c_config.h +* +* \brief This file defines the structures and macros for the Infineon I2C Protocol. +* +* \addtogroup grIFXI2C +* @{ +*/ + +#ifndef _IFX_I2C_CONFIG_H_ +#define _IFX_I2C_CONFIG_H_ +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************************************************************** +* HEADER FILES +**********************************************************************************************************************/ +// Protocol Stack Includes +#include <stdint.h> +#include "pal_i2c.h" +#include "pal_gpio.h" +#include "pal_os_timer.h" + +/*********************************************************************************************************************** +* MACROS +**********************************************************************************************************************/ + +/** @brief I2C slave address of the Infineon device */ +#define IFX_I2C_BASE_ADDR (0x30) + +/** @brief Physical Layer: polling interval in microseconds */ +#define PL_POLLING_INVERVAL_US (1000) +/** @brief Physical layer: maximal attempts */ +#define PL_POLLING_MAX_CNT (200) +/** @brief Physical Layer: data register polling interval in microseconds */ +#define PL_DATA_POLLING_INVERVAL_US (5000) +/** @brief Physical Layer: guard time interval in microseconds */ +#define PL_GUARD_TIME_INTERVAL_US (50) + +/** @brief Data link layer: maximum frame size */ +#define DL_MAX_FRAME_SIZE (300) +/** @brief Data link layer: header size */ +#define DL_HEADER_SIZE (5) +/** @brief Data link layer: maximum number of retries in case of transmission error */ +#define DL_TRANS_REPEAT (3) +/** @brief Data link layer: Trans timeout in milliseconds*/ +#define PL_TRANS_TIMEOUT_MS (10) + +/** @brief Transport layer: Maximum exit timeout in seconds */ +#define TL_MAX_EXIT_TIMEOUT (6) + +/** @brief Reset low time for GPIO pin toggling */ +#define RESET_LOW_TIME_MSEC (2000) +/** @brief Start up time */ +#define STARTUP_TIME_MSEC (12000) + +/** @brief Protocol Stack: Status codes for success */ +#define IFX_I2C_STACK_SUCCESS (0x00) +/** @brief Protocol Stack: Status codes for error */ +#define IFX_I2C_STACK_ERROR (0x01) +/** @brief Protocol Stack: Status codes busy */ +#define IFX_I2C_STACK_BUSY (0x02) +/** @brief Protocol Stack: Memory insufficient */ +#define IFX_I2C_STACK_MEM_ERROR (0x03) +/** @brief Protocol Stack: Fatal error. Used internal to IFX I2C Stack */ +#define IFX_I2C_FATAL_ERROR (0x04) + +/** @brief Offset of Datalink header in tx_frame_buffer */ +#define IFX_I2C_DL_HEADER_OFFSET (0) +/** @brief Offset of Transport header in tx_frame_buffer */ +#define IFX_I2C_TL_HEADER_OFFSET (IFX_I2C_DL_HEADER_OFFSET+3) + +/** @brief Protocol Stack debug switch for physical layer (set to 0 or 1) */ +#define IFX_I2C_LOG_PL 0 +/** @brief Protocol Stack debug switch for data link layer (set to 0 or 1) */ +#define IFX_I2C_LOG_DL 0 +/** @brief Protocol Stack debug switch for transport layer (set to 0 or 1) */ +#define IFX_I2C_LOG_TL 0 + +/** @brief Log ID number for physical layer */ +#define IFX_I2C_LOG_ID_PL 0x00 +/** @brief Log ID number for data link layer */ +#define IFX_I2C_LOG_ID_DL 0x01 +/** @brief Log ID number for transport layer */ +#define IFX_I2C_LOG_ID_TL 0x02 +/** @brief Log ID number for platform abstraction layer */ +#define IFX_I2C_LOG_ID_PAL 0x04 + +/*********************************************************************************************************************** +* ENUMS +***********************************************************************************************************************/ + + +/*********************************************************************************************************************** +* DATA STRUCTURES +***********************************************************************************************************************/ +typedef struct ifx_i2c_context ifx_i2c_context_t; + +/** @brief Event handler function prototype */ +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); + +/** @brief Physical layer structure */ +typedef struct ifx_i2c_pl +{ + // Physical Layer low level interface variables + + /// Physical layer buffer + uint8_t buffer[DL_MAX_FRAME_SIZE+1]; + /// Tx length + uint16_t buffer_tx_len; + /// Rx length + uint16_t buffer_rx_len; + /// Action on register, read/write + uint8_t register_action; + /// i2c read/i2c write + uint8_t i2c_cmd; + /// Retry counter + uint16_t retry_counter; + + // Physical Layer high level interface variables + + /// Action of frame. Tx/Rx + uint8_t frame_action; + /// Frame state + uint8_t frame_state ; + /// Pointer to data to be sent + uint8_t * p_tx_frame; + /// Length of data to be sent + uint16_t tx_frame_len; + // Upper layer handler + ifx_i2c_event_handler_t upper_layer_event_handler; + + // Physical Layer negotiation/soft reset variables + + /// Negotiation state + uint8_t negotiate_state; + /// Soft reset requested + uint8_t request_soft_reset; +} ifx_i2c_pl_t; + +/** @brief Datalink layer structure */ +typedef struct ifx_i2c_dl +{ + // Data Link layer internal state variables + + /// Datalink layer state + uint8_t state; + /// Tx sequence number + uint8_t tx_seq_nr; + // Rx sequence number + uint8_t rx_seq_nr; + /// Indicate only Rx required + uint8_t action_rx_only; + /// Retransmit counter + uint8_t retransmit_counter; + /// Error occured + uint8_t error; + /// Resynced + uint8_t resynced; + /// Timeout value + uint32_t data_poll_timeout; + /// Transmit buffer size + uint16_t tx_buffer_size; + /// Receive buffer size + uint16_t rx_buffer_size; + /// Pointer to main transmit buffers + uint8_t* p_tx_frame_buffer; + /// Pointer to main receive buffers + uint8_t* p_rx_frame_buffer; + ///Start time of sending frame + uint32_t frame_start_time; + // Upper layer Event handler + ifx_i2c_event_handler_t upper_layer_event_handler; +} ifx_i2c_dl_t; + +/** @brief Transport layer structure */ +typedef struct ifx_i2c_tl +{ + // Transport Layer state and buffer + + /// Transport layer state + uint8_t state; + /// Pointer to packet provided by user + uint8_t* p_actual_packet; + /// Total received data + uint16_t total_recv_length; + /// Actual length of user provided packet + uint16_t actual_packet_length; + /// Offset till which data is sent from p_actual_packet + uint16_t packet_offset; + /// Maximum length of packet at transport layer + uint16_t max_packet_length; + /// Pointer to user provided receive buffer + uint8_t* p_recv_packet_buffer; + /// Length of receive buffer + uint16_t* p_recv_packet_buffer_length; + /// Start time of the transport layer API + uint32_t api_start_time; + ///Chaining error coutn from slave + uint8_t chaining_error_count; + ///Chaining error count for master + uint8_t master_chaining_error_count; + ///State to check last chaining state + uint8_t previous_chaining; + /// transmission done + uint8_t transmission_completed; + /// Error event state + uint8_t error_event; + + /// Upper layer event handler + ifx_i2c_event_handler_t upper_layer_event_handler; +} ifx_i2c_tl_t; + +/** @brief IFX I2C context structure */ +struct ifx_i2c_context +{ + /// I2C Slave address + uint8_t slave_address; + /// Frequency of i2c master + uint16_t frequency; + /// Data link layer frame size + uint16_t frame_size; + /// Pointer to pal gpio context for vdd + pal_gpio_t* p_slave_vdd_pin; + /// Pointer to pal gpio context for reset + pal_gpio_t* p_slave_reset_pin; + /// Pointer to pal i2c context + pal_i2c_t* p_pal_i2c_ctx; + + /// Upper layer event handler + app_event_handler_t upper_layer_event_handler; + /// Upper layer context + void* p_upper_layer_ctx; + /// Pointer to upper layer rx buffer + uint8_t* p_upper_layer_rx_buffer; + /// Pointer to length of upper layer rx buffer + uint16_t* p_upper_layer_rx_buffer_len; + + /// Protocol variables + /// ifx i2c wrapper apis state + uint8_t state; + /// ifx i2c wrapper api status + uint8_t status; + /// reset states + uint8_t reset_state; + /// type of reset + uint8_t reset_type; + /// init pal + uint8_t do_pal_init; + + /// Transport layer context + ifx_i2c_tl_t tl; + /// Datalink layer context + ifx_i2c_dl_t dl; + /// Physical layer context + ifx_i2c_pl_t pl; + + /// IFX I2C tx frame of max length + uint8_t tx_frame_buffer[DL_MAX_FRAME_SIZE]; + /// IFX I2C rx frame of max length + uint8_t rx_frame_buffer[DL_MAX_FRAME_SIZE]; + +}; + +/*********************************************************************************************************************** +* GLOBAL +***********************************************************************************************************************/ + +/** @brief IFX I2C Instance */ +extern ifx_i2c_context_t ifx_i2c_context_0; + +/*********************************************************************************************************************** +* LOCAL ROUTINES +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* API PROTOTYPES +**********************************************************************************************************************/ + +/** + * @} + **/ +#ifdef __cplusplus +} +#endif +#endif /* _IFX_I2C_CONFIG_H_ */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_data_link_layer.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_data_link_layer.h new file mode 100644 index 0000000..ae89ff3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_data_link_layer.h @@ -0,0 +1,103 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file ifx_i2c_data_link_layer.h +* +* \brief This file defines the API prototype for data link layer of the Infineon I2C Protocol Stack library. +* +* \addtogroup grIFXI2C +* @{ +*/ + +#ifndef _IFX_I2C_DATA_LINK_LAYER_H_ +#define _IFX_I2C_DATA_LINK_LAYER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************************************************************** +* HEADER FILES +**********************************************************************************************************************/ +#include "ifx_i2c_config.h" + +/*********************************************************************************************************************** +* MACROS +**********************************************************************************************************************/ +/** @brief Error event propagated to upper layer */ +#define IFX_I2C_DL_EVENT_ERROR (0x01) +/** @brief Transmit success event propagated to upper layer (bit field 1) */ +#define IFX_I2C_DL_EVENT_TX_SUCCESS (0x02) +/** @brief Receive success event propagated to upper layer (bit field 3)*/ +#define IFX_I2C_DL_EVENT_RX_SUCCESS (0x04) + +/*********************************************************************************************************************** +* ENUMS +**********************************************************************************************************************/ +/*********************************************************************************************************************** +* DATA STRUCTURES +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* API PROTOTYPES +**********************************************************************************************************************/ +/** + * @brief 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. + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] handler Function pointer to the event handler of the upper layer. + * + * @retval IFX_I2C_STACK_SUCCESS If initialization was successful. + * @retval IFX_I2C_STACK_ERROR If the module is already initialized. + */ +host_lib_status_t ifx_i2c_dl_init(ifx_i2c_context_t *p_ctx,ifx_i2c_event_handler_t handler); + +/** + * @brief 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 @ref ifx_i2c_dl_init. + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] frame_len Frame length. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If the module is busy. + */ +host_lib_status_t ifx_i2c_dl_send_frame(ifx_i2c_context_t *p_ctx,uint16_t frame_len); + +/** + * @brief 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 @ref ifx_i2c_dl_init. + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If the module is busy. + */ +host_lib_status_t ifx_i2c_dl_receive_frame(ifx_i2c_context_t *p_ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* _IFX_I2C_DATA_LINK_LAYER_H_ */ + + +/** + * @} + **/ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_physical_layer.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_physical_layer.h new file mode 100644 index 0000000..18366f7 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_physical_layer.h @@ -0,0 +1,110 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file ifx_i2c_physical_layer.h +* +* \brief This file defines the API prototype for physical layer of the Infineon I2C Protocol Stack library. +* +* \addtogroup grIFXI2C +* @{ +*/ + +#ifndef _IFX_I2C_PHYSICAL_LAYER_H_ +#define _IFX_I2C_PHYSICAL_LAYER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************************************************************** +* HEADER FILES +**********************************************************************************************************************/ +#include "ifx_i2c_config.h" + +/*********************************************************************************************************************** +* MACROS +**********************************************************************************************************************/ +/*********************************************************************************************************************** +* ENUMS +**********************************************************************************************************************/ +/*********************************************************************************************************************** +* DATA STRUCTURES +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* API PROTOTYPES +**********************************************************************************************************************/ +/** + * @brief 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. + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] handler Function pointer to the event handler of the upper layer. + * + * @retval IFX_I2C_STACK_SUCCESS If initialization was successful. + * @retval IFX_I2C_STACK_ERROR If the module is already initialized. + */ +host_lib_status_t ifx_i2c_pl_init(ifx_i2c_context_t *p_ctx,ifx_i2c_event_handler_t handler); + +/** + * @brief 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 @ref ifx_i2c_pl_init + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] p_frame Buffer containing the frame. + * @param[in] frame_len Frame length. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If 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); + +/** + * @brief 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 @ref ifx_i2c_pl_init + * + * @param[in] p_ctx Pointer to ifx i2c context. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If the module is busy. + */ +host_lib_status_t ifx_i2c_pl_receive_frame(ifx_i2c_context_t *p_ctx); + + +/** + * @brief Function for setting slave address. + * + * Synchronous function to set slave address. + * + * @param[in] p_ctx Pointer to ifx i2c context. + * @param[in] slave_address Holds new slave address[7 Bit] to be set. + * @param[in] storage_type 0 - To set the Slave address until next reset.<br> + * Non-zero - To set the slave address to persistent memory. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If setting slave address fails. + */ +host_lib_status_t ifx_i2c_pl_write_slave_address(ifx_i2c_context_t *p_ctx, uint8_t slave_address, uint8_t storage_type); +/** + * @} + **/ + +#ifdef __cplusplus +} +#endif +#endif /* _IFX_I2C_PHYSICAL_LAYER_H_ */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_transport_layer.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_transport_layer.h new file mode 100644 index 0000000..6b61011 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/ifx_i2c_transport_layer.h @@ -0,0 +1,84 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file ifx_i2c_transport_layer.h +* +* \brief This file defines the API prototype for transport layer of the Infineon I2C Protocol Stack library. +* +* \addtogroup grIFXI2C +* @{ +*/ + +#ifndef _IFX_I2C_TRANSPORT_LAYER_H_ +#define _IFX_I2C_TRANSPORT_LAYER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************************************************************** +* HEADER FILES +**********************************************************************************************************************/ +#include "ifx_i2c_config.h" +#include "pal_os_timer.h" + +/*********************************************************************************************************************** +* MACROS +**********************************************************************************************************************/ +/*********************************************************************************************************************** +* ENUMS +**********************************************************************************************************************/ +/*********************************************************************************************************************** +* DATA STRUCTURES +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* API PROTOTYPES +**********************************************************************************************************************/ +/** + * @brief 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. + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] handler Function pointer to the event handler of the upper layer. + * + * @retval IFX_I2C_STACK_SUCCESS If initialization was successful. + * @retval IFX_I2C_STACK_ERROR If the module is already initialized. + */ +host_lib_status_t ifx_i2c_tl_init(ifx_i2c_context_t *p_ctx,ifx_i2c_event_handler_t handler); + +/** + * @brief 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 @ref ifx_i2c_tl_init + * + * @param[in,out] p_ctx Pointer to ifx i2c context. + * @param[in] p_packet Buffer containing the packet header. + * @param[in] packet_len Packet header length. + * @param[in] p_recv_packet Buffer containing the packet payload. + * @param[in] recv_packet_len Packet payload length. + * + * @retval IFX_I2C_STACK_SUCCESS If function was successful. + * @retval IFX_I2C_STACK_ERROR If the module is busy. + */ +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); + +/** + * @} + **/ +#ifdef __cplusplus +} +#endif +#endif /* IFX_I2C_TRANSPORT_LAYER_H__ */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/optiga_comms.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/optiga_comms.h new file mode 100644 index 0000000..d04cd95 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/optiga_comms.h @@ -0,0 +1,90 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements optiga comms abstraction layer for IFX I2C Protocol. +* +* \addtogroup grOptigaComms +* @{ +*/ + +#ifndef _OPTIGA_COMMS_H_ +#define _OPTIGA_COMMS_H_ +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ +#include "Datatypes.h" + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + +/// Succesfull execution +#define OPTIGA_COMMS_SUCCESS 0x0000 +/// Error in execution +#define OPTIGA_COMMS_ERROR 0x0001 +/// Busy, doing operation +#define OPTIGA_COMMS_BUSY 0x0002 + +/********************************************************************************************************************** + * DATA STRUCTURES + *********************************************************************************************************************/ + +/** @brief optiga comms structure */ +typedef struct optiga_comms +{ + /// Comms structure pointer + void* comms_ctx; + /// Upper layer contect + void* upper_layer_ctx; + /// Upper layer handler + app_event_handler_t upper_layer_handler; + /// Optiga comms state + uint8_t state; +}optiga_comms_t; + +extern optiga_comms_t optiga_comms; + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Opens the communication channel with OPTIGA. + */ +LIBRARY_EXPORTS host_lib_status_t optiga_comms_open(optiga_comms_t *p_ctx); + +/** + * \brief Resets the OPTIGA. + */ +LIBRARY_EXPORTS host_lib_status_t optiga_comms_reset(optiga_comms_t *p_ctx,uint8_t reset_type); + +/** + * \brief Sends and receives the APDU. + */ +LIBRARY_EXPORTS host_lib_status_t optiga_comms_transceive(optiga_comms_t *p_ctx,const uint8_t* p_data, + const uint16_t* p_data_length, + uint8_t* p_buffer, uint16_t* p_buffer_len); + +/** + * \brief Closes the communication channel with OPTIGA. + */ +LIBRARY_EXPORTS host_lib_status_t optiga_comms_close(optiga_comms_t *p_ctx); + +/** +* @} +*/ + +#endif /*_OPTIGA_COMMS_H_*/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal.h new file mode 100644 index 0000000..f66b41a --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal.h @@ -0,0 +1,60 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of platform abstraction layer +* +* \addtogroup grPAL +* @{ +*/ + + +#ifndef _PAL_H_ +#define _PAL_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ +#include <Datatypes.h> + +/********************************************************************************************************************** + * pal.h + *********************************************************************************************************************/ + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + +/// PAL API execution is successful +#define PAL_STATUS_SUCCESS (0x0000) +/// PAL API execution failed +#define PAL_STATUS_FAILURE (0x0001) +/// PAL I2C is busy +#define PAL_STATUS_I2C_BUSY (0x0002) + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ +/** + * \brief PAL return status. + */ +typedef uint16_t pal_status_t; + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ + +#endif /* _PAL_H_ */ + +/** +* @} +*/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_gpio.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_gpio.h new file mode 100644 index 0000000..171811b --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_gpio.h @@ -0,0 +1,84 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of pal gpio +* +* \addtogroup grPAL +* @{ +*/ + +#ifndef _PAL_GPIO_H_ +#define _PAL_GPIO_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ + +#include "pal.h" + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * DATA STRUCTURES + *********************************************************************************************************************/ + +/** + * \brief Structure defines the PAL GPIO configuration. + */ +typedef struct pal_gpio +{ + /// Pointer to gpio platform specific context/structure + void* p_gpio_hw; + +} pal_gpio_t; + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Initializes the GPIO PAL. + */ +void pal_gpio_init(void); + +/** + * \brief Sets the gpio pin to high state. + */ +void pal_gpio_set_high(const pal_gpio_t* p_gpio_context); + +/** + * \brief Sets the gpio pin to Low state. + */ +void pal_gpio_set_low(const pal_gpio_t* p_gpio_context); + +#ifdef __cplusplus +} +#endif + +#endif /* _PAL_GPIO_H_ */ + +/** +* @} +*/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_i2c.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_i2c.h new file mode 100644 index 0000000..fd470d3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_i2c.h @@ -0,0 +1,92 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of pal i2c +* +* \addtogroup grPAL +* @{ +*/ + +#ifndef _PAL_I2C_H_ +#define _PAL_I2C_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ + +#include "pal.h" + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ +/// Event returned when I2C master completes execution +#define PAL_I2C_EVENT_SUCCESS (0x0000) +/// Event returned when I2C master operation fails +#define PAL_I2C_EVENT_ERROR (0x0001) +/// Event returned when lower level I2C bus is busy +#define PAL_I2C_EVENT_BUSY (0x0002) + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + +/********************************************************************************************************************** + * DATA STRUCTURES + *********************************************************************************************************************/ +/** @brief PAL I2C context structure */ +typedef struct pal_i2c +{ + /// Pointer to I2C master platform specific context + void* p_i2c_hw_config; + /// I2C slave address + uint8_t slave_address; + /// Pointer to store the callers context information + void* upper_layer_ctx; + /// Pointer to store the callers handler + void* upper_layer_event_handler; + +} pal_i2c_t; + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ +/** + * @brief Initializes the I2C master. + */ +pal_status_t pal_i2c_init(const pal_i2c_t* p_i2c_context); + +/** + * @brief Sets the I2C Master bitrate + */ +pal_status_t pal_i2c_set_bitrate(const pal_i2c_t* p_i2c_context, uint16_t bitrate); + +/** + * @brief Writes to I2C bus. + */ +pal_status_t pal_i2c_write(pal_i2c_t* p_i2c_context, uint8_t* p_data , uint16_t length); + +/** + * @brief Reads from I2C bus. + */ +pal_status_t pal_i2c_read(pal_i2c_t* p_i2c_context, uint8_t* p_data , uint16_t length); + +/** + * @brief De-initializes the I2C master. + */ +pal_status_t pal_i2c_deinit(const pal_i2c_t* p_i2c_context); + +#endif /* _PAL_I2C_H_ */ + +/** +* @} +*/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_ifx_i2c_config.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_ifx_i2c_config.h new file mode 100644 index 0000000..0df491a --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_ifx_i2c_config.h @@ -0,0 +1,49 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the platform abstraction layer extern declarations for ifx i2c. +* +* \addtogroup grPAL +* @{ +*/ + +#ifndef _PAL_IFX_I2C_CONFIG_H_ +#define _PAL_IFX_I2C_CONFIG_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ +#include "pal.h" +#include "pal_i2c.h" +#include "pal_gpio.h" + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + +/********************************************************************************************************************** + * PAL extern definitions for IFX I2C + *********************************************************************************************************************/ +extern pal_i2c_t optiga_pal_i2c_context_0; +extern pal_gpio_t optiga_vdd_0; +extern pal_gpio_t optiga_reset_0; + +#endif /* _PAL_IFX_I2C_CONFIG_H_ */ + +/** +* @} +*/ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_event.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_event.h new file mode 100644 index 0000000..e4a1315 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_event.h @@ -0,0 +1,61 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of pal os event +* +* \addtogroup grPAL +* @{ +*/ + + +#ifndef _PAL_OS_EVENT_H_ +#define _PAL_OS_EVENT_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ + +#include "Datatypes.h" + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + +/********************************************************************************************************************** + * PAL extern definitions + *********************************************************************************************************************/ + +/** + * @brief typedef for Callback function when timer elapses. + */ +typedef void (*register_callback)(void*); + +/** + * \brief Initializes the OS event PAL. + */ +void pal_os_event_init(void); + +/** + * @brief Callback registration function to trigger once when timer expires. + */ +void pal_os_event_register_callback_oneshot(register_callback callback, void* callback_args, uint32_t time_us); + +#endif //_PAL_OS_EVENT_H_ + +/** +* @} +*/ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_timer.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_timer.h new file mode 100644 index 0000000..796e39e --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_os_timer.h @@ -0,0 +1,76 @@ +/** +* \copyright +* Copyright (c) 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of pal os timer functionalities. +* +* \addtogroup grPAL +* @{ +*/ +#ifndef _PAL_OS_TIMER_H_ +#define _PAL_OS_TIMER_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ + +#include "pal.h" + +/********************************************************************************************************************* + * pal_os_timer.h +*********************************************************************************************************************/ + + +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * DATA STRUCTURES + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Gets tick count value in milliseconds + */ +uint32_t pal_os_timer_get_time_in_milliseconds(void); + +/** + * @brief Waits or delay until the supplied milliseconds + */ +void pal_os_timer_delay_in_milliseconds(uint16_t milliseconds); + + +#ifdef __cplusplus +} +#endif + +#endif /* _PAL_OS_TIMER_H_ */ + +/** +* @} +*/ + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_socket.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_socket.h new file mode 100644 index 0000000..5456bca --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/external/infineon/include/pal_socket.h @@ -0,0 +1,182 @@ +/** +* \copyright +* Copyright© 2018, Infineon Technologies AG +* All rights reserved. +* +* This software is provided with terms and conditions as specified in OPTIGA™ Trust X Evaluation Kit License Agreement. +* \endcopyright +* +* \author Infineon AG +* +* \file +* +* \brief This file implements the prototype declarations of pal socket functionalities +* \ingroup grPAL +* @{ +*/ + + +#ifndef _PAL_SOCKET_H_ +#define _PAL_SOCKET_H_ + +/********************************************************************************************************************** + * HEADER FILES + *********************************************************************************************************************/ + +#ifndef WIN32 + #include "Datatypes.h" + #include "DAVE.h" + #include "udp.h" + #include "inet.h" +#else + #include <winsock2.h> + #include "Datatypes.h" +#endif + +#include "ErrorCodes.h" +#include "UDPErrorCodes.h" + +/// @cond hidden +/********************************************************************************************************************** + * MACROS + *********************************************************************************************************************/ +#ifndef WIN32 + #define IPAddressParse(pzIpAddress, psIPAddress) (inet_aton(pzIpAddress, psIPAddress)) +#else + #define IPAddressParse(pzIpAddress, psIPAddress) (1) +#endif +/// @endcond +/********************************************************************************************************************** + * ENUMS + *********************************************************************************************************************/ + + +/********************************************************************************************************************** + * DATA STRUCTURES + *********************************************************************************************************************/ + +#ifndef WIN32 +/** + * \brief Pointer type definition of pal socket receive event callback + */ +typedef void (*pal_socket_event_listener)(void *arg, struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *addr, u16_t port); +#endif + + + +/** + * \brief This structure contains socket communication data + */ +typedef enum eRecvMode_d +{ + eBlock = 0x10, + + eNonBlock = 0x20 +}eRecvMode_d; + +/** + * \brief This structure contains socket communication data + */ +#ifndef WIN32 + +typedef struct pal_socket +{ + + ///UDP structure Tx + struct udp_pcb *pcbTx; + + ///UDP structure Rx + struct udp_pcb *pcbRx; + + //Received IP address + ip_addr_t sIPAddress; + + ///Function pointer to hold receive callback + pal_socket_event_listener pfListen; + + ///Port for UDP communication + uint16_t wPort; + + ///Transport Layer Timeout + uint16_t wTimeout; + + ///Enumeration to indicate Blocking or Non blocking + uint8_t bMode; + +} pal_socket_t; + +#else + +typedef struct pal_socket +{ + ///Received IP address + char* sIPAddress; + + ///Port for UDP communication + uint16_t wPort; + + ///Pointer to the socket for Receiving + SOCKET SocketHdl; + + ///IPv4 Socket address for Receiving + SOCKADDR_IN sSocketAddrIn; + + ///Transport Layer Timeout + uint16_t wTimeout; + + ///Enumeration to indicate Blocking or Non blocking + uint8_t bMode; + +} pal_socket_t; +#endif + +/********************************************************************************************************************** + * API Prototypes + *********************************************************************************************************************/ + +/** + * \brief Assign IP address + */ +#ifndef WIN32 +int32_t pal_socket_assign_ip_address(const char* p_ip_address,void *p_input_ip_address); +#else +int32_t pal_socket_assign_ip_address(const char_t* p_ip_address,char** p_input_ip_address); +#endif + +/** + * \brief Initializes the socket communication structure + */ +int32_t pal_socket_init(pal_socket_t* p_socket); + +/** + * \brief Creates server port and bind + */ +int32_t pal_socket_open(pal_socket_t* p_socket, + uint16_t port); +/** + * \brief Creates a client port and connect + */ +int32_t pal_socket_connect(pal_socket_t* p_socket, + uint16_t port); +/** + * \brief Receive data from the client + */ +int32_t pal_socket_listen(pal_socket_t* p_socket, uint8_t *p_data, + uint32_t *p_length); +/** + * \brief Sends the data to the the client + */ +int32_t pal_socket_send(const pal_socket_t* p_socket, uint8_t *p_data, + uint32_t length); +/** + * \brief Closes the socket communication and release the udp port + */ +void pal_socket_close(pal_socket_t* p_socket); + +#endif //_PAL_SOCKET_H_ + +/** +* @} +*/ + |