pal_gpio.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 platform abstraction layer APIs for gpio.
  14. *
  15. * \addtogroup grPAL
  16. * @{
  17. */
  18. /**********************************************************************************************************************
  19. * HEADER FILES
  20. *********************************************************************************************************************/
  21. #include "pal_gpio.h"
  22. #include "nrf_gpio.h"
  23. #include "pal_ifx_i2c_config.h"
  24. /**********************************************************************************************************************
  25. * MACROS
  26. *********************************************************************************************************************/
  27. /**********************************************************************************************************************
  28. * LOCAL DATA
  29. *********************************************************************************************************************/
  30. /**********************************************************************************************************************
  31. * LOCAL ROUTINES
  32. *********************************************************************************************************************/
  33. /**********************************************************************************************************************
  34. * API IMPLEMENTATION
  35. *********************************************************************************************************************/
  36. void pal_gpio_init()
  37. {
  38. // Init power pins
  39. nrf_gpio_cfg_output(19);
  40. nrf_gpio_cfg_output(20);
  41. // Set power pins to enable power
  42. nrf_gpio_pin_clear(19); // Enable power for the *on-board* Trust X device
  43. nrf_gpio_pin_set(20); // Disable power for *external* Trust X device inside the 2GO slot
  44. // Init reset pin
  45. nrf_gpio_cfg_output((uint32_t)(optiga_reset_0.p_gpio_hw));
  46. }
  47. /**
  48. * Sets the GPIO pin to high state
  49. *
  50. * <b>API Details:</b>
  51. * The API sets the pin high, only if the pin is assigned to a valid gpio context.<br>
  52. * Otherwise the API returns without any failure status.<br>
  53. *
  54. *\param[in] p_gpio_context Pointer to pal layer gpio context
  55. *
  56. *
  57. */
  58. void pal_gpio_set_high(const pal_gpio_t* p_gpio_context)
  59. {
  60. if (p_gpio_context != NULL && p_gpio_context->p_gpio_hw != NULL)
  61. {
  62. nrf_gpio_pin_set((uint32_t)(p_gpio_context->p_gpio_hw));
  63. }
  64. }
  65. /**
  66. * Sets the gpio pin to low state
  67. *
  68. * <b>API Details:</b>
  69. * The API set the pin low, only if the pin is assigned to a valid gpio context.<br>
  70. * Otherwise the API returns without any failure status.<br>
  71. *
  72. *\param[in] p_gpio_context Pointer to pal layer gpio context
  73. *
  74. */
  75. void pal_gpio_set_low(const pal_gpio_t* p_gpio_context)
  76. {
  77. if (p_gpio_context != NULL && p_gpio_context->p_gpio_hw != NULL)
  78. {
  79. nrf_gpio_pin_clear((uint32_t)(p_gpio_context->p_gpio_hw));
  80. }
  81. }
  82. /**
  83. * @}
  84. */