board_keys.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /***********************************************************************************************************************
  2. * Copyright [2020] Renesas Electronics Corporation and/or its licensors. All Rights Reserved.
  3. *
  4. * This file is part of Renesas RA Flexible Software Package (FSP)
  5. *
  6. * The contents of this file (the "contents") are proprietary and confidential to Renesas Electronics Corporation
  7. * and/or its licensors ("Renesas") and subject to statutory and contractual protections.
  8. *
  9. * This file is subject to a Renesas FSP license agreement. Unless otherwise agreed in an FSP license agreement with
  10. * Renesas: 1) you may not use, copy, modify, distribute, display, or perform the contents; 2) you may not use any name
  11. * or mark of Renesas for advertising or publicity purposes or in connection with your use of the contents; 3) RENESAS
  12. * MAKES NO WARRANTY OR REPRESENTATIONS ABOUT THE SUITABILITY OF THE CONTENTS FOR ANY PURPOSE; THE CONTENTS ARE PROVIDED
  13. * "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  14. * PARTICULAR PURPOSE, AND NON-INFRINGEMENT; AND 4) RENESAS SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, OR
  15. * CONSEQUENTIAL DAMAGES, INCLUDING DAMAGES RESULTING FROM LOSS OF USE, DATA, OR PROJECTS, WHETHER IN AN ACTION OF
  16. * CONTRACT OR TORT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE CONTENTS. Third-party contents
  17. * included in this file may be subject to different terms.
  18. **********************************************************************************************************************/
  19. /***********************************************************************************************************************
  20. * File Name : board_keys.c
  21. * Description : This module has information about the keys on this board.
  22. **********************************************************************************************************************/
  23. /*******************************************************************************************************************//**
  24. * @addtogroup BSP_RA6M4_IOT_KEYS
  25. *
  26. * @{
  27. **********************************************************************************************************************/
  28. /***********************************************************************************************************************
  29. * Includes
  30. **********************************************************************************************************************/
  31. #include "bsp_api.h"
  32. #if defined(BOARD_RA6M4_IOT)
  33. /***********************************************************************************************************************
  34. * Macro definitions
  35. **********************************************************************************************************************/
  36. /***********************************************************************************************************************
  37. * Typedef definitions
  38. **********************************************************************************************************************/
  39. /***********************************************************************************************************************
  40. * Private global variables and functions
  41. **********************************************************************************************************************/
  42. /** Array of KEY IOPORT pins. */
  43. static const uint16_t g_bsp_prv_keys[] =
  44. {
  45. (uint16_t) BSP_IO_PORT_00_PIN_01, ///< USER KEY1
  46. (uint16_t) BSP_IO_PORT_00_PIN_02, ///< USER KEY2
  47. };
  48. /***********************************************************************************************************************
  49. * Exported global variables (to be accessed by other files)
  50. **********************************************************************************************************************/
  51. /** Structure with KEY information for this board. */
  52. const bsp_keys_t g_bsp_keys =
  53. {
  54. .key_count = (uint16_t) ((sizeof(g_bsp_prv_keys) / sizeof(g_bsp_prv_keys[0]))),
  55. .p_keys = &g_bsp_prv_keys[0]
  56. };
  57. extern bsp_leds_t g_bsp_leds;
  58. void key_sample (void)
  59. {
  60. #if BSP_TZ_SECURE_BUILD
  61. /* Enter non-secure code */
  62. R_BSP_NonSecureEnter();
  63. #endif
  64. bsp_leds_t leds = g_bsp_leds;
  65. bsp_keys_t keys = g_bsp_keys;
  66. uint32_t key1_pin=keys.p_keys[BSP_KEY_KEY1];
  67. uint32_t key2_pin=keys.p_keys[BSP_KEY_KEY2];
  68. uint32_t led_pin =leds.p_leds[BSP_LED_LED1];
  69. while (1)
  70. {
  71. R_BSP_PinAccessEnable();
  72. if ( R_BSP_PinRead((bsp_io_port_pin_t)key1_pin)==BSP_IO_LEVEL_LOW)
  73. {
  74. R_BSP_PinWrite((bsp_io_port_pin_t) led_pin,BSP_IO_LEVEL_LOW);
  75. }
  76. if ( R_BSP_PinRead((bsp_io_port_pin_t)key2_pin)==BSP_IO_LEVEL_LOW)
  77. {
  78. R_BSP_PinWrite((bsp_io_port_pin_t) led_pin, BSP_IO_LEVEL_HIGH);
  79. }
  80. R_BSP_PinAccessDisable();
  81. }
  82. }
  83. /***********************************************************************************************************************
  84. * Exported global variables (to be accessed by other files)
  85. **********************************************************************************************************************/
  86. #endif
  87. /** @} (end addtogroup BOARD_RA6M4_RENESAS_IOT_KEYS) */