optiga_comms.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * \copyright
  3. * Copyright (c) 2018, Infineon Technologies AG
  4. * All rights reserved.
  5. *
  6. * This software is provided with terms and conditions as specified in OPTIGA(TM) Trust X Evaluation Kit License Agreement.
  7. * \endcopyright
  8. *
  9. * \author Infineon AG
  10. *
  11. * \file
  12. *
  13. * \brief This file implements optiga comms abstraction layer for IFX I2C Protocol.
  14. *
  15. * \addtogroup grOptigaComms
  16. * @{
  17. */
  18. #ifndef _OPTIGA_COMMS_H_
  19. #define _OPTIGA_COMMS_H_
  20. /**********************************************************************************************************************
  21. * HEADER FILES
  22. *********************************************************************************************************************/
  23. #include "Datatypes.h"
  24. /**********************************************************************************************************************
  25. * MACROS
  26. *********************************************************************************************************************/
  27. /// Succesfull execution
  28. #define OPTIGA_COMMS_SUCCESS 0x0000
  29. /// Error in execution
  30. #define OPTIGA_COMMS_ERROR 0x0001
  31. /// Busy, doing operation
  32. #define OPTIGA_COMMS_BUSY 0x0002
  33. /**********************************************************************************************************************
  34. * DATA STRUCTURES
  35. *********************************************************************************************************************/
  36. /** @brief optiga comms structure */
  37. typedef struct optiga_comms
  38. {
  39. /// Comms structure pointer
  40. void* comms_ctx;
  41. /// Upper layer contect
  42. void* upper_layer_ctx;
  43. /// Upper layer handler
  44. app_event_handler_t upper_layer_handler;
  45. /// Optiga comms state
  46. uint8_t state;
  47. }optiga_comms_t;
  48. extern optiga_comms_t optiga_comms;
  49. /**********************************************************************************************************************
  50. * API Prototypes
  51. *********************************************************************************************************************/
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**
  56. * \brief Opens the communication channel with OPTIGA.
  57. */
  58. LIBRARY_EXPORTS host_lib_status_t optiga_comms_open(optiga_comms_t *p_ctx);
  59. /**
  60. * \brief Resets the OPTIGA.
  61. */
  62. LIBRARY_EXPORTS host_lib_status_t optiga_comms_reset(optiga_comms_t *p_ctx,uint8_t reset_type);
  63. /**
  64. * \brief Sends and receives the APDU.
  65. */
  66. LIBRARY_EXPORTS host_lib_status_t optiga_comms_transceive(optiga_comms_t *p_ctx,const uint8_t* p_data,
  67. const uint16_t* p_data_length,
  68. uint8_t* p_buffer, uint16_t* p_buffer_len);
  69. /**
  70. * \brief Closes the communication channel with OPTIGA.
  71. */
  72. LIBRARY_EXPORTS host_lib_status_t optiga_comms_close(optiga_comms_t *p_ctx);
  73. /**
  74. * @}
  75. */
  76. #endif /*_OPTIGA_COMMS_H_*/