pal_i2c.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 the prototype declarations of pal i2c
  14. *
  15. * \addtogroup grPAL
  16. * @{
  17. */
  18. #ifndef _PAL_I2C_H_
  19. #define _PAL_I2C_H_
  20. /**********************************************************************************************************************
  21. * HEADER FILES
  22. *********************************************************************************************************************/
  23. #include "pal.h"
  24. /**********************************************************************************************************************
  25. * MACROS
  26. *********************************************************************************************************************/
  27. /// Event returned when I2C master completes execution
  28. #define PAL_I2C_EVENT_SUCCESS (0x0000)
  29. /// Event returned when I2C master operation fails
  30. #define PAL_I2C_EVENT_ERROR (0x0001)
  31. /// Event returned when lower level I2C bus is busy
  32. #define PAL_I2C_EVENT_BUSY (0x0002)
  33. /**********************************************************************************************************************
  34. * ENUMS
  35. *********************************************************************************************************************/
  36. /**********************************************************************************************************************
  37. * DATA STRUCTURES
  38. *********************************************************************************************************************/
  39. /** @brief PAL I2C context structure */
  40. typedef struct pal_i2c
  41. {
  42. /// Pointer to I2C master platform specific context
  43. void* p_i2c_hw_config;
  44. /// I2C slave address
  45. uint8_t slave_address;
  46. /// Pointer to store the callers context information
  47. void* upper_layer_ctx;
  48. /// Pointer to store the callers handler
  49. void* upper_layer_event_handler;
  50. } pal_i2c_t;
  51. /**********************************************************************************************************************
  52. * API Prototypes
  53. *********************************************************************************************************************/
  54. /**
  55. * @brief Initializes the I2C master.
  56. */
  57. pal_status_t pal_i2c_init(const pal_i2c_t* p_i2c_context);
  58. /**
  59. * @brief Sets the I2C Master bitrate
  60. */
  61. pal_status_t pal_i2c_set_bitrate(const pal_i2c_t* p_i2c_context, uint16_t bitrate);
  62. /**
  63. * @brief Writes to I2C bus.
  64. */
  65. pal_status_t pal_i2c_write(pal_i2c_t* p_i2c_context, uint8_t* p_data , uint16_t length);
  66. /**
  67. * @brief Reads from I2C bus.
  68. */
  69. pal_status_t pal_i2c_read(pal_i2c_t* p_i2c_context, uint8_t* p_data , uint16_t length);
  70. /**
  71. * @brief De-initializes the I2C master.
  72. */
  73. pal_status_t pal_i2c_deinit(const pal_i2c_t* p_i2c_context);
  74. #endif /* _PAL_I2C_H_ */
  75. /**
  76. * @}
  77. */