gpio_define.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (C) 2011-2012, Freescale Semiconductor, Inc. All Rights Reserved
  3. * THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
  4. * BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
  5. * Freescale Semiconductor, Inc.
  6. */
  7. #ifndef _GPIO_DEFINE_H_
  8. #define _GPIO_DEFINE_H_
  9. #if 0
  10. #define GPIO_DR_OFFSET 0x0000
  11. #define GPIO_GDIR_OFFSET 0x0004
  12. #define GPIO_PSR_OFFSET 0x0008
  13. #endif
  14. typedef enum {
  15. GPIO_PORT1 = 0,
  16. GPIO_PORT2 = 1,
  17. GPIO_PORT3 = 2,
  18. GPIO_PORT4 = 3,
  19. GPIO_PORT5 = 4,
  20. GPIO_PORT6 = 5,
  21. GPIO_PORT7 = 6,
  22. } GPIO_PORT;
  23. typedef struct {
  24. unsigned int DR;
  25. unsigned int GDIR;
  26. unsigned int PSR;
  27. unsigned int ICR1;
  28. unsigned int ICR2;
  29. unsigned int IMR;
  30. unsigned int ISR;
  31. unsigned int EDGE_SEL;
  32. } CSP_GPIO_REGS, *PCSP_GPIO_REGS;
  33. #define GPIO_GDIR_INPUT 0 // GPIO pin is input
  34. #define GPIO_GDIR_OUTPUT 1 // GPIO pin is output
  35. #define GPIO_LOW_LEVEL 0 // GPIO pin is low
  36. #define GPIO_HIGH_LEVEL 1 // GPIO pin is high
  37. #define GPIO_ICR_LOW_LEVEL 0 // Interrupt is low-level
  38. #define GPIO_ICR_HIGH_LEVEL 1 // Interrupt is high-level
  39. #define GPIO_ICR_RISE_EDGE 2 // Interrupt is rising edge
  40. #define GPIO_ICR_FALL_EDGE 3 // Interrupt is falling edge
  41. #define GPIO_IMR_MASKED 0 // Interrupt is masked
  42. #define GPIO_IMR_UNMASKED 1 // Interrupt is unmasked
  43. #define GPIO_EDGE_SEL_DISABLE 0 // Edge select is disabled
  44. #define GPIO_EDGE_SEL_ENABLE 1 // Edge select is enabled
  45. #define GPIO_PIN_MASK(pin) (1U << (pin))
  46. #define GPIO_PIN_VAL(val, pin) ((val) << (pin))
  47. #define GPIO_ICR_MASK(pin) (0x3U << ((pin) << 1))
  48. #define GPIO_ICR_VAL(val, pin) ((val) << ((pin) << 1))
  49. //#########################################
  50. //# GPIO peripheral defines
  51. //#########################################
  52. #define GPIO_DR0_OFFSET 0x00 // 32bit gpio pta data direction reg
  53. #define GPIO_GDIR0_OFFSET 0x04 // 32bit gpio pta output config 1 reg
  54. #define GPIO_PSR0_OFFSET 0x08 // 32bit gpio pta output config 2 reg
  55. #define GPIO_ICR1_OFFSET 0x0C // 32bit gpio pta input config A1 reg
  56. #define GPIO_ICR2_OFFSET 0x10 // 32bit gpio pta input config A2 reg
  57. #define GPIO_IMR_OFFSET 0x14 // 32bit gpio pta input config B1 reg
  58. #define GPIO_ISR_OFFSET 0x18 // GPIO Interrupt Status Register
  59. #define GPIO_EDGE_SEL_OFFSET 0x1C // GPIO Edge Detect Register
  60. #define GPIO1_DR GPIO1_BASE_ADDR+0x00
  61. #define GPIO1_GDIR GPIO1_BASE_ADDR+0x04
  62. #define GPIO1_PSR GPIO1_BASE_ADDR+0x08
  63. #define GPIO1_ICR1 GPIO1_BASE_ADDR+0x0C
  64. #define GPIO1_ICR2 GPIO1_BASE_ADDR+0x10
  65. #define GPIO1_IMR GPIO1_BASE_ADDR+0x14
  66. #define GPIO1_ISR GPIO1_BASE_ADDR+0x18
  67. #define GPIO1_EDGE_SEL GPIO1_BASE_ADDR+0x1C
  68. #define GPIO2_DR GPIO2_BASE_ADDR+0x00
  69. #define GPIO2_GDIR GPIO2_BASE_ADDR+0x04
  70. #define GPIO2_PSR GPIO2_BASE_ADDR+0x08
  71. #define GPIO2_ICR1 GPIO2_BASE_ADDR+0x0C
  72. #define GPIO2_ICR2 GPIO2_BASE_ADDR+0x10
  73. #define GPIO2_IMR GPIO2_BASE_ADDR+0x14
  74. #define GPIO2_ISR GPIO2_BASE_ADDR+0x18
  75. #define GPIO2_EDGE_SEL GPIO2_BASE_ADDR+0x1C
  76. #define GPIO3_DR GPIO3_BASE_ADDR+0x00
  77. #define GPIO3_GDIR GPIO3_BASE_ADDR+0x04
  78. #define GPIO3_PSR GPIO3_BASE_ADDR+0x08
  79. #define GPIO3_ICR1 GPIO3_BASE_ADDR+0x0C
  80. #define GPIO3_ICR2 GPIO3_BASE_ADDR+0x10
  81. #define GPIO3_IMR GPIO3_BASE_ADDR+0x14
  82. #define GPIO3_ISR GPIO3_BASE_ADDR+0x18
  83. #define GPIO3_EDGE_SEL GPIO3_BASE_ADDR+0x1C
  84. #define GPIO4_DR GPIO4_BASE_ADDR+0x00
  85. #define GPIO4_GDIR GPIO4_BASE_ADDR+0x04
  86. #define GPIO4_PSR GPIO4_BASE_ADDR+0x08
  87. #define GPIO4_ICR1 GPIO4_BASE_ADDR+0x0C
  88. #define GPIO4_ICR2 GPIO4_BASE_ADDR+0x10
  89. #define GPIO4_IMR GPIO4_BASE_ADDR+0x14
  90. #define GPIO4_ISR GPIO4_BASE_ADDR+0x18
  91. #define GPIO4_EDGE_SEL GPIO4_BASE_ADDR+0x1C
  92. #define GPIO5_DR GPIO5_BASE_ADDR+0x00
  93. #define GPIO5_GDIR GPIO5_BASE_ADDR+0x04
  94. #define GPIO5_PSR GPIO5_BASE_ADDR+0x08
  95. #define GPIO5_ICR1 GPIO5_BASE_ADDR+0x0C
  96. #define GPIO5_ICR2 GPIO5_BASE_ADDR+0x10
  97. #define GPIO5_IMR GPIO5_BASE_ADDR+0x14
  98. #define GPIO5_ISR GPIO5_BASE_ADDR+0x18
  99. #define GPIO5_EDGE_SEL GPIO5_BASE_ADDR+0x1C
  100. #define GPIO6_DR GPIO6_BASE_ADDR+0x00
  101. #define GPIO6_GDIR GPIO6_BASE_ADDR+0x04
  102. #define GPIO6_PSR GPIO6_BASE_ADDR+0x08
  103. #define GPIO6_ICR1 GPIO6_BASE_ADDR+0x0C
  104. #define GPIO6_ICR2 GPIO6_BASE_ADDR+0x10
  105. #define GPIO6_IMR GPIO6_BASE_ADDR+0x14
  106. #define GPIO6_ISR GPIO6_BASE_ADDR+0x18
  107. #define GPIO6_EDGE_SEL GPIO6_BASE_ADDR+0x1C
  108. #define GPIO7_DR GPIO7_BASE_ADDR+0x00
  109. #define GPIO7_GDIR GPIO7_BASE_ADDR+0x04
  110. #define GPIO7_PSR GPIO7_BASE_ADDR+0x08
  111. #define GPIO7_ICR1 GPIO7_BASE_ADDR+0x0C
  112. #define GPIO7_ICR2 GPIO7_BASE_ADDR+0x10
  113. #define GPIO7_IMR GPIO7_BASE_ADDR+0x14
  114. #define GPIO7_ISR GPIO7_BASE_ADDR+0x18
  115. #define GPIO7_EDGE_SEL GPIO7_BASE_ADDR+0x1C
  116. #endif