pal_gpio.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * MIT License
  3. *
  4. * Copyright (c) 2018 Infineon Technologies AG
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE
  23. *
  24. *
  25. * \file
  26. *
  27. * \brief This file implements the platform abstraction layer APIs for gpio.
  28. *
  29. * \addtogroup grPAL
  30. * @{
  31. */
  32. /**********************************************************************************************************************
  33. * HEADER FILES
  34. *********************************************************************************************************************/
  35. #include "optiga/pal/pal_gpio.h"
  36. #include "optiga/pal/pal_ifx_i2c_config.h"
  37. #include "nrf_gpio.h"
  38. #include "boards.h"
  39. /**********************************************************************************************************************
  40. * MACROS
  41. *********************************************************************************************************************/
  42. /**********************************************************************************************************************
  43. * LOCAL DATA
  44. *********************************************************************************************************************/
  45. /**********************************************************************************************************************
  46. * LOCAL ROUTINES
  47. *********************************************************************************************************************/
  48. /**********************************************************************************************************************
  49. * API IMPLEMENTATION
  50. *********************************************************************************************************************/
  51. void pal_gpio_init()
  52. {
  53. // Init power pins
  54. nrf_gpio_cfg_output((uint32_t)optiga_vdd_0.p_gpio_hw);
  55. // Set power pins to enable power
  56. nrf_gpio_pin_set((uint32_t)optiga_vdd_0.p_gpio_hw); // Enable power for onboard OPTIGA
  57. // Init reset pin
  58. nrf_gpio_cfg_output((uint32_t)(optiga_reset_0.p_gpio_hw));
  59. }
  60. void pal_gpio_set_high(const pal_gpio_t* p_gpio_context)
  61. {
  62. if (p_gpio_context != NULL && p_gpio_context->p_gpio_hw != NULL)
  63. {
  64. nrf_gpio_pin_set((uint32_t)(p_gpio_context->p_gpio_hw));
  65. }
  66. }
  67. void pal_gpio_set_low(const pal_gpio_t* p_gpio_context)
  68. {
  69. if (p_gpio_context != NULL && p_gpio_context->p_gpio_hw != NULL)
  70. {
  71. nrf_gpio_pin_clear((uint32_t)(p_gpio_context->p_gpio_hw));
  72. }
  73. }
  74. /**
  75. * @}
  76. */