pal_pin_config.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * \copyright
  3. * MIT License
  4. *
  5. * Copyright (c) 2019 Infineon Technologies AG
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE
  24. *
  25. * \endcopyright
  26. *
  27. * \author Infineon Technologies AG
  28. *
  29. * \file pal_pin_config.h
  30. *
  31. * \brief This file defines the pins the OPTIGA is connected to.
  32. *
  33. * \addtogroup grPAL
  34. *
  35. * @{
  36. */
  37. #ifndef _OPTIGA_PIN_CONFIG_H_
  38. #define _OPTIGA_PIN_CONFIG_H_
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. #include "boards.h"
  43. #include <stdint.h>
  44. // To select a pin configuration set its define to '1' and all others to '0'
  45. // Trust X Shield
  46. // OPTIGA as 2Go board on the TrustX shield, e.g. TrustX2Go and TrustM2Go
  47. #define OPTIGA_PIN_CONFIG_2GO 0
  48. // OPTIGA soldered on the TrustX shield
  49. #define OPTIGA_PIN_CONFIG_TRUSTX_SHIELD 0
  50. // MY IOT ADAPTER
  51. // Product Link: https://www.infineon.com/cms/en/product/evaluation-boards/my-iot-adapter/
  52. // OPTIGA as 2Go board on MY IOT ADAPTER Slot 1
  53. #define OPTIGA_PIN_CONFIG_MYIOT_SLOT1 0
  54. // OPTIGA as 2Go board on MY IOT ADAPTER Slot 2 or 3
  55. #define OPTIGA_PIN_CONFIG_MYIOT_SLOT2_3 1
  56. /*
  57. * The following defines pack additional information into the highest bits of
  58. * a void*. This is safe, because on nrf52 the pin description uses less than 8 bit
  59. * and a void* has 32 bits on this platform.
  60. */
  61. /** @brief set a pin to this value to mark it as unused and it will not be initialised */
  62. #define OPTIGA_PIN_UNUSED UINT32_C(0xFFFFFFFF)
  63. #define OPTIGA_PIN_INITIAL_VAL_MASK (UINT32_C(1) << 31)
  64. /** @brief defines the initial state of the pin */
  65. #define OPTIGA_PIN_INITIAL_VAL_HIGH OPTIGA_PIN_INITIAL_VAL_MASK
  66. #define OPTIGA_PIN_INITIAL_VAL_LOW 0
  67. #define OPTIGA_PIN_ONE_TIME_INIT_MASK (UINT32_C(1) << 30)
  68. /** @brief If this flag is set, the pin will be initialised with the specified value, but not used */
  69. #define OPTIGA_PIN_ONE_TIME_INIT OPTIGA_PIN_ONE_TIME_INIT_MASK
  70. #define OPTIGA_PIN_ALL_MASKS (OPTIGA_PIN_INITIAL_VAL_MASK | OPTIGA_PIN_ONE_TIME_INIT_MASK)
  71. #if OPTIGA_PIN_CONFIG_2GO == 1
  72. #define OPTIGA_PIN_VDD (ARDUINO_9_PIN | OPTIGA_PIN_INITIAL_VAL_LOW | OPTIGA_PIN_ONE_TIME_INIT)
  73. #define OPTIGA_PIN_RST (ARDUINO_7_PIN | OPTIGA_PIN_INITIAL_VAL_LOW)
  74. #elif OPTIGA_PIN_CONFIG_TRUSTX_SHIELD == 1
  75. #define OPTIGA_PIN_VDD (ARDUINO_9_PIN | OPTIGA_PIN_INITIAL_VAL_HIGH)
  76. #define OPTIGA_PIN_RST (ARDUINO_7_PIN | OPTIGA_PIN_INITIAL_VAL_LOW)
  77. #elif OPTIGA_PIN_CONFIG_MYIOT_SLOT1 == 1
  78. #define OPTIGA_PIN_RST (ARDUINO_10_PIN | OPTIGA_PIN_INITIAL_VAL_LOW)
  79. #define OPTIGA_PIN_VDD OPTIGA_PIN_UNUSED
  80. #elif OPTIGA_PIN_CONFIG_MYIOT_SLOT2_3 == 1
  81. #define OPTIGA_PIN_RST (ARDUINO_5_PIN | OPTIGA_PIN_INITIAL_VAL_LOW)
  82. #define OPTIGA_PIN_VDD OPTIGA_PIN_UNUSED
  83. #else
  84. #error "No pin configuration selected"
  85. #endif
  86. /** @brief PIN for I2C SCL to Infineon OPTIGA Trust X device */
  87. #define OPTIGA_PIN_I2C_SCL (ARDUINO_SCL_PIN)
  88. /** @brief PIN for I2C SDA to Infineon OPTIGA Trust X device */
  89. #define OPTIGA_PIN_I2C_SDA (ARDUINO_SDA_PIN)
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93. #endif /*_OPTIGA_PIN_CONFIG_H_*/
  94. /**
  95. * @}
  96. */