GPIO_LPC18xx.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* --------------------------------------------------------------------------
  2. * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * $Date: 02. March 2016
  19. * $Revision: V1.0
  20. *
  21. * Project: GPIO Driver Definitions for NXP LPC18xx
  22. * -------------------------------------------------------------------------- */
  23. #ifndef __GPIO_LPC18XX_H
  24. #define __GPIO_LPC18XX_H
  25. #include <stdint.h>
  26. // GPIO identifier
  27. typedef struct _GPIO_ID {
  28. uint8_t port;
  29. uint8_t num;
  30. } GPIO_ID;
  31. // GPIO Direction
  32. #define GPIO_DIR_INPUT (0)
  33. #define GPIO_DIR_OUTPUT (1)
  34. /**
  35. \fn void GPIO_PortClock (uint32_t clock)
  36. \brief Port Clock Control
  37. \param[in] clock Enable or disable clock
  38. */
  39. extern void GPIO_PortClock (uint32_t clock);
  40. /**
  41. \fn void GPIO_SetDir (uint32_t port_num,
  42. uint32_t pin_num,
  43. uint32_t dir)
  44. \brief Configure GPIO pin direction
  45. \param[in] port_num GPIO number (0..7)
  46. \param[in] pin_num Port pin number
  47. \param[in] dir GPIO_DIR_INPUT, GPIO_DIR_OUTPUT
  48. */
  49. extern void GPIO_SetDir (uint32_t port_num, uint32_t pin_num, uint32_t dir);
  50. /**
  51. \fn void GPIO_PinWrite (uint32_t port_num,
  52. uint32_t pin_num,
  53. uint32_t val)
  54. \brief Write port pin
  55. \param[in] port_num GPIO number (0..7)
  56. \param[in] pin_num Port pin number
  57. \param[in] val Port pin value (0 or 1)
  58. */
  59. extern void GPIO_PinWrite (uint32_t port_num,
  60. uint32_t pin_num,
  61. uint32_t val);
  62. /**
  63. \fn uint32_t GPIO_PinRead (uint32_t port_num, uint32_t pin_num)
  64. \brief Read port pin
  65. \param[in] port_num GPIO number (0..7)
  66. \param[in] pin_num Port pin number
  67. \return pin value (0 or 1)
  68. */
  69. extern uint32_t GPIO_PinRead (uint32_t port_num, uint32_t pin_num);
  70. /**
  71. \fn void GPIO_PortWrite (uint32_t port_num,
  72. uint32_t mask,
  73. uint32_t val)
  74. \brief Write port pins
  75. \param[in] port_num GPIO number (0..7)
  76. \param[in] mask Selected pins
  77. \param[in] val Pin values
  78. */
  79. extern void GPIO_PortWrite (uint32_t port_num, uint32_t mask, uint32_t val);
  80. /**
  81. \fn uint32_t GPIO_PortRead (uint32_t port_num)
  82. \brief Read port pins
  83. \param[in] port_num GPIO number (0..7)
  84. \return port pin inputs
  85. */
  86. extern uint32_t GPIO_PortRead (uint32_t port_num);
  87. #endif /* __GPIO_LPC18XX_H */