lpc_pinsel.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /**********************************************************************
  2. * $Id$ lpc_pinsel.h 2011-06-02
  3. *//**
  4. * @file lpc_pinsel.h
  5. * @brief Contains all macro definitions and function prototypes
  6. * support for Pin-connection block firmware library on LPC
  7. * @version 1.0
  8. * @date 02. June. 2011
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2011, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. * Permission to use, copy, modify, and distribute this software and its
  26. * documentation is hereby granted, under NXP Semiconductors'
  27. * relevant copyright in the software, without fee, provided that it
  28. * is used in conjunction with NXP Semiconductors microcontrollers. This
  29. * copyright, permission, and disclaimer notice must appear in all copies of
  30. * this code.
  31. **********************************************************************/
  32. /* Peripheral group ----------------------------------------------------------- */
  33. /** @defgroup PINSEL PINSEL (Pin Selection)
  34. * @ingroup LPC_CMSIS_FwLib_Drivers
  35. * @{
  36. */
  37. #ifndef __LPC_PINSEL_H
  38. #define __LPC_PINSEL_H
  39. /* Includes ------------------------------------------------------------------- */
  40. #include "LPC407x_8x_177x_8x.h"
  41. #include "lpc_types.h"
  42. /* Public Macros -------------------------------------------------------------- */
  43. /** @defgroup PINSEL_Public_Macros PINSEL Public Macros
  44. * @{
  45. */
  46. /* Macros define IOCON bits*/
  47. /** Selects pin functions */
  48. #define IOCON_FUNC_POS (0)
  49. #define IOCON_FUNC_MASK (0x07<<IOCON_FUNC_POS)
  50. /** Selects output function mode (on-chip pull-up/pull-down resistor control */
  51. #define IOCON_MODE_POS (3)
  52. #define IOCON_MODE_MASK (0x03<<IOCON_MODE_POS)
  53. #define IOCON_MODE_PLAIN ((0<<IOCON_MODE_POS))
  54. #define IOCON_MODE_PULLDOWN ((1<<IOCON_MODE_POS))
  55. #define IOCON_MODE_PULLUP ((2<<IOCON_MODE_POS))
  56. #define IOCON_MODE_REPEATER ((3<<IOCON_MODE_POS))
  57. /** Hysteresis */
  58. #define IOCON_HYS_POS (5)
  59. #define IOCON_HYS_MASK (0x01<<IOCON_HYS_POS)
  60. #define IOCON_HYS_ENABLE ((1<<IOCON_HYS_POS))
  61. /** Input polarity */
  62. #define IOCON_INVERT_POS (6)
  63. #define IOCON_INVERT_MASK (0x01<<IOCON_INVERT_POS)
  64. #define IOCON_INVERT_INPUT (1<<IOCON_INVERT_POS)
  65. /** Selects Analog/Digital mode */
  66. #define IOCON_ADMODE_POS (7)
  67. #define IOCON_ADMODE_MASK (0x01<<IOCON_ADMODE_POS)
  68. #define IOCON_ANALOG_MODE (0<<IOCON_ADMODE_POS)
  69. #define IOCON_DIGITIAL_MODE (1<<IOCON_ADMODE_POS)
  70. /* Controls Glitch Filter */
  71. #define IOCON_FILTER_POS (8)
  72. #define IOCON_FILTER_MASK (0x01<<IOCON_FILTER_POS)
  73. #define IOCON_10ns_FILTER_ENABLE (0<<IOCON_FILTER_POS)
  74. #define IOCON_10ns_FILTER_DISABLE (1<<IOCON_FILTER_POS)
  75. /** I2C 50ns glitch filter and slew rate control */
  76. #define IOCON_HS_POS (8)
  77. #define IOCON_HS_MASK (0x01<<IOCON_HS_POS)
  78. #define IOCON_I2C_FILTER_ENABLE (0<<IOCON_HS_POS)
  79. #define IOCON_I2C_FILTER_DISABLE (1<<IOCON_HS_POS)
  80. /** Driver Output Slew Rate Control*/
  81. #define IOCON_SLEW_POS (9)
  82. #define IOCON_SLEW_MASK (0x01<<IOCON_SLEW_POS)
  83. #define IOCON_SLEW_ENABLE ((1<<IOCON_SLEW_POS))
  84. /** Controls sink current capability of the pin*/
  85. #define IOCON_HIDRIVE_POS (9)
  86. #define IOCON_HIDRIVE_MASK (0x01<<IOCON_HIDRIVE_POS)
  87. #define IOCON_I2CMODE_FASTPLUS (1<<IOCON_HIDRIVE_POS)
  88. /** Controls open-drain mode */
  89. #define IOCON_OD_POS (10)
  90. #define IOCON_OD_MASK (0x01<<IOCON_OD_POS)
  91. #define IOCON_OPENDRAIN_MODE (1<<IOCON_OD_POS)
  92. /** DAC enable control */
  93. #define IOCON_DACEN_POS (16)
  94. #define IOCON_DACEN_MASK (0x01<<IOCON_DACEN_POS)
  95. #define IOCON_DAC_ENABLE (1<<IOCON_DACEN_POS)
  96. /* Macros define for Return Code */
  97. typedef int32_t PINSEL_RET_CODE;
  98. #define PINSEL_RET_OK (0)
  99. #define PINSEL_RET_INVALID_PIN (0x10000001)
  100. #define PINSEL_RET_NOT_SUPPORT (0x10000002)
  101. #define PINSEL_RET_ERR (-1)
  102. /**
  103. * @}
  104. */
  105. /** @defgroup PINSEL_Public_Types PINSEL Public Types
  106. * @{
  107. */
  108. typedef enum
  109. {
  110. PINSEL_BASICMODE_PLAINOUT = 0, /**< Plain output */
  111. PINSEL_BASICMODE_PULLDOWN, /**< Pull-down enabled */
  112. PINSEL_BASICMODE_PULLUP, /**< Pull-up enabled (default) */
  113. PINSEL_BASICMODE_REPEATER /**< Repeater mode */
  114. }PinSel_BasicMode;
  115. typedef enum
  116. {
  117. /** Fast mode (400 kHz clock rate) and standard (100 kHz clock rate) */
  118. PINSEL_I2CMODE_FAST_STANDARD = 0,
  119. /** Open drain I/O (not I2C). No glitch filter, 3 mA typical output drive */
  120. PINSEL_I2CMODE_OPENDRAINIO,
  121. /** Fast Mode Plus I2C. This includes a filter for <50 ns glitches */
  122. PINSEL_I2CMODE_FASTMODEPLUS,
  123. }PinSel_I2cMode;
  124. typedef enum
  125. {
  126. /** Type D IOCON registers */
  127. PINSEL_PIN_TYPE_D,
  128. /** Type A IOCON registers */
  129. PINSEL_PIN_TYPE_A,
  130. /** Type U IOCON registers */
  131. PINSEL_PIN_TYPE_U,
  132. /** Type I IOCON registers */
  133. PINSEL_PIN_TYPE_I,
  134. /** Type W IOCON registers */
  135. PINSEL_PIN_TYPE_W,
  136. /** Unknown type */
  137. PINSEL_PIN_TYPE_UNKNOWN,
  138. }PinSel_PinType;
  139. /**
  140. * @}
  141. */
  142. /* Public Functions ----------------------------------------------------------- */
  143. /** @defgroup PINSEL_Public_Functions PINSEL Public Functions
  144. * @{
  145. */
  146. PinSel_PinType PINSEL_GetPinType(uint8_t portnum, uint8_t pinnum);
  147. PINSEL_RET_CODE PINSEL_ConfigPin(uint8_t portnum, uint8_t pinnum, uint8_t funcnum);
  148. PINSEL_RET_CODE PINSEL_SetPinMode(uint8_t portnum, uint8_t pinnum, PinSel_BasicMode modenum);
  149. PINSEL_RET_CODE PINSEL_SetHysMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  150. PINSEL_RET_CODE PINSEL_SetInvertInput(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  151. PINSEL_RET_CODE PINSEL_SetSlewMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  152. PINSEL_RET_CODE PINSEL_SetI2CMode(uint8_t portnum, uint8_t pinnum, PinSel_I2cMode I2CMode);
  153. PINSEL_RET_CODE PINSEL_SetOpenDrainMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  154. PINSEL_RET_CODE PINSEL_SetAnalogPinMode (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  155. PINSEL_RET_CODE PINSEL_DacEnable (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  156. PINSEL_RET_CODE PINSEL_SetFilter (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  157. PINSEL_RET_CODE PINSEL_SetI2CFilter (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  158. /**
  159. * @}
  160. */
  161. #endif /* LPC_PINSEL_H */
  162. /**
  163. * @}
  164. */
  165. /* --------------------------------- End Of File ------------------------------ */