port_api.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2006-2013 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://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,
  14. * WITHOUT 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. #ifndef MBED_PORTMAP_H
  19. #define MBED_PORTMAP_H
  20. #include "device.h"
  21. #if DEVICE_PORTIN || DEVICE_PORTOUT
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /** Port HAL structure. port_s is declared in the target's HAL
  26. */
  27. typedef struct port_s port_t;
  28. /**
  29. * \defgroup hal_port Port HAL functions
  30. * @{
  31. */
  32. /** Get the pin name from the port's pin number
  33. *
  34. * @param port The port name
  35. * @param pin_n The pin number within the specified port
  36. * @return The pin name for the port's pin number
  37. */
  38. PinName port_pin(PortName port, int pin_n);
  39. /** Initilize the port
  40. *
  41. * @param obj The port object to initialize
  42. * @param port The port name
  43. * @param mask The bitmask to identify which bits in the port should be included (0 - ignore)
  44. * @param dir The port direction
  45. */
  46. void port_init(port_t *obj, PortName port, int mask, PinDirection dir);
  47. /** Set the input port mode
  48. *
  49. * @param obj The port object
  50. * @param mode THe port mode to be set
  51. */
  52. void port_mode(port_t *obj, PinMode mode);
  53. /** Set port direction (in/out)
  54. *
  55. * @param obj The port object
  56. * @param dir The port direction to be set
  57. */
  58. void port_dir(port_t *obj, PinDirection dir);
  59. /** Write value to the port
  60. *
  61. * @param obj The port object
  62. * @param value The value to be set
  63. */
  64. void port_write(port_t *obj, int value);
  65. /** Read the current value on the port
  66. *
  67. * @param obj The port object
  68. * @return An integer with each bit corresponding to an associated port pin setting
  69. */
  70. int port_read(port_t *obj);
  71. /**@}*/
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif
  76. #endif
  77. /** @}*/