chip.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * @brief LPC5410x basic chip inclusion file
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2014
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __CHIP_H_
  32. #define __CHIP_H_
  33. #include "lpc_types.h"
  34. #include "sys_config.h"
  35. #include "cmsis.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #ifndef CORE_M4
  40. #ifndef CORE_M0PLUS
  41. #error "CORE_M4 or CORE_M0PLUS is not defined for the LPC5410x architecture"
  42. #error "CORE_M4 or CORE_M0PLUS should be defined as part of your compiler define list"
  43. #endif
  44. #endif
  45. #ifndef CHIP_LPC5410X
  46. #error "The LPC5410X Chip include path is used for this build, but"
  47. #error "CHIP_LPC5410X is not defined!"
  48. #endif
  49. /** @defgroup PERIPH_5410X_BASE CHIP: LPC5410x Peripheral addresses and register set declarations
  50. * @ingroup CHIP_5410X_DRIVERS
  51. * @{
  52. */
  53. /* Main memory addresses */
  54. #define LPC_FLASHMEM_BASE 0x00000000UL
  55. #define LPC_SRAM0_BASE 0x02000000UL
  56. #define LPC_SRAM1_BASE 0x02010000UL
  57. #define LPC_ROM_BASE 0x03000000UL
  58. #define LPC_SRAM2_BASE 0x03400000UL
  59. #define LPC_GPIO_PORT_BASE 0x1C000000UL
  60. #define LPC_DMA_BASE 0x1C004000UL
  61. #define LPC_CRC_BASE 0x1C010000UL
  62. #define LPC_SCT_BASE 0x1C018000UL
  63. #define LPC_MBOX_BASE 0x1C02C000UL
  64. #define LPC_ADC_BASE 0x1C034000UL
  65. #define LPC_FIFO_BASE 0x1C038000UL
  66. /* APB0 peripheral group addresses */
  67. #define LPC_SYSCON_BASE 0x40000000UL
  68. #define LPC_TIMER2_BASE 0x40004000UL
  69. #define LPC_TIMER3_BASE 0x40008000UL
  70. #define LPC_TIMER4_BASE 0x4000C000UL
  71. #define LPC_GPIO_GROUPINT0_BASE 0x40010000UL
  72. #define LPC_GPIO_GROUPINT1_BASE 0x40014000UL
  73. #define LPC_PIN_INT_BASE 0x40018000UL
  74. #define LPC_IOCON_BASE 0x4001C000UL
  75. #define LPC_UTICK_BASE 0x40020000UL
  76. #define LPC_FMC_BASE 0x40024000UL
  77. #define LPC_PMU_BASE 0x4002C000UL
  78. #define LPC_WWDT_BASE 0x40038000UL
  79. #define LPC_RTC_BASE 0x4003C000UL
  80. /* APB1 peripheral group addresses */
  81. #define LPC_ASYNC_SYSCON_BASE 0x40080000UL
  82. #define LPC_USART0_BASE 0x40084000UL
  83. #define LPC_USART1_BASE 0x40088000UL
  84. #define LPC_USART2_BASE 0x4008C000UL
  85. #define LPC_USART3_BASE 0x40090000UL
  86. #define LPC_I2C0_BASE 0x40094000UL
  87. #define LPC_I2C1_BASE 0x40098000UL
  88. #define LPC_I2C2_BASE 0x4009C000UL
  89. #define LPC_SPI0_BASE 0x400A4000UL
  90. #define LPC_SPI1_BASE 0x400A8000UL
  91. #define LPC_TIMER0_BASE 0x400B4000UL
  92. #define LPC_TIMER1_BASE 0x400B8000UL
  93. #define LPC_INMUX_BASE 0x40050000UL
  94. #define LPC_RITIMER_BASE 0x40070000UL
  95. #define LPC_MRT_BASE 0x40074000UL
  96. /* Main memory register access */
  97. #define LPC_GPIO ((LPC_GPIO_T *) LPC_GPIO_PORT_BASE)
  98. #define LPC_DMA ((LPC_DMA_T *) LPC_DMA_BASE)
  99. #define LPC_CRC ((LPC_CRC_T *) LPC_CRC_BASE)
  100. #define LPC_SCT ((LPC_SCT_T *) LPC_SCT_BASE)
  101. #define LPC_MBOX ((LPC_MBOX_T *) LPC_MBOX_BASE)
  102. #define LPC_ADC ((LPC_ADC_T *) LPC_ADC_BASE)
  103. #define LPC_FIFO ((LPC_FIFO_T *) LPC_FIFO_BASE)
  104. /* APB0 peripheral group register access */
  105. #define LPC_SYSCON ((LPC_SYSCON_T *) LPC_SYSCON_BASE)
  106. #define LPC_TIMER2 ((LPC_TIMER_T *) LPC_TIMER2_BASE)
  107. #define LPC_TIMER3 ((LPC_TIMER_T *) LPC_TIMER3_BASE)
  108. #define LPC_TIMER4 ((LPC_TIMER_T *) LPC_TIMER4_BASE)
  109. #define LPC_GINT ((LPC_GPIOGROUPINT_T *) LPC_GPIO_GROUPINT0_BASE)
  110. #define LPC_PININT ((LPC_PIN_INT_T *) LPC_PIN_INT_BASE)
  111. #define LPC_IOCON ((LPC_IOCON_T *) LPC_IOCON_BASE)
  112. #define LPC_UTICK ((LPC_UTICK_T *) LPC_UTICK_BASE)
  113. #define LPC_WWDT ((LPC_WWDT_T *) LPC_WWDT_BASE)
  114. #define LPC_RTC ((LPC_RTC_T *) LPC_RTC_BASE)
  115. /* APB1 peripheral group register access */
  116. #define LPC_ASYNC_SYSCON ((LPC_ASYNC_SYSCON_T *) LPC_ASYNC_SYSCON_BASE)
  117. #define LPC_USART0 ((LPC_USART_T *) LPC_USART0_BASE)
  118. #define LPC_USART1 ((LPC_USART_T *) LPC_USART1_BASE)
  119. #define LPC_USART2 ((LPC_USART_T *) LPC_USART2_BASE)
  120. #define LPC_USART3 ((LPC_USART_T *) LPC_USART3_BASE)
  121. #define LPC_I2C0 ((LPC_I2C_T *) LPC_I2C0_BASE)
  122. #define LPC_I2C1 ((LPC_I2C_T *) LPC_I2C1_BASE)
  123. #define LPC_I2C2 ((LPC_I2C_T *) LPC_I2C2_BASE)
  124. #define LPC_SCT0 LPC_SCT
  125. #define LPC_SPI0 ((LPC_SPI_T *) LPC_SPI0_BASE)
  126. #define LPC_SPI1 ((LPC_SPI_T *) LPC_SPI1_BASE)
  127. #define LPC_TIMER0 ((LPC_TIMER_T *) LPC_TIMER0_BASE)
  128. #define LPC_TIMER1 ((LPC_TIMER_T *) LPC_TIMER1_BASE)
  129. #define LPC_INMUX ((LPC_INMUX_T *) LPC_INMUX_BASE)
  130. #define LPC_RITIMER ((LPC_RITIMER_T *) LPC_RITIMER_BASE)
  131. #define LPC_MRT ((LPC_MRT_T *) LPC_MRT_BASE)
  132. #define LPC_PMU ((LPC_PMU_T *) LPC_PMU_BASE)
  133. /**
  134. * @}
  135. */
  136. /** @ingroup CHIP_5410X_DRIVER_OPTIONS
  137. * @{
  138. */
  139. /**
  140. * @brief Clock rate on the CLKIN pin
  141. * This value is defined externally to the chip layer and contains
  142. * the value in Hz for the CLKIN pin for the board. If this pin isn't used,
  143. * this rate can be 0.
  144. */
  145. extern const uint32_t ExtClockIn;
  146. /**
  147. * @}
  148. */
  149. /* 如果不用莫个文件,去掉相应的文件,可以 */
  150. /* Include order is important! */
  151. #include "romapi_5410x.h"
  152. #include "syscon_5410x.h"
  153. #include "cpuctrl_5410x.h"
  154. #include "clock_5410x.h"
  155. #include "pmu_5410x.h"
  156. #include "iocon_5410x.h"
  157. #include "pinint_5410x.h"
  158. #include "inmux_5410x.h"
  159. #include "crc_5410x.h"
  160. #include "gpio_5410x.h"
  161. #include "fifo_5410x.h"
  162. #include "mrt_5410x.h"
  163. #include "wwdt_5410x.h"
  164. #include "sct_5410x.h"
  165. #include "sct_pwm_5410x.h"
  166. #include "rtc_5410x.h"
  167. #include "timer_5410x.h"
  168. #include "ritimer_5410x.h"
  169. #include "utick_5410x.h"
  170. #include "gpiogroup_5410x.h"
  171. #include "mailbox_5410x.h"
  172. #include "fpu_init.h"
  173. #include "power_lib_5410x.h"
  174. /** @defgroup SUPPORT_5410X_FUNC CHIP: LPC5410x support functions
  175. * @ingroup CHIP_5410X_DRIVERS
  176. * @{
  177. */
  178. /**
  179. * @brief Current system clock rate, mainly used for peripherals in SYSCON
  180. */
  181. extern uint32_t SystemCoreClock;
  182. /**
  183. * @brief Update system core and ASYNC syscon clock rate, should be called if the
  184. * system has a clock rate change
  185. * @return None
  186. */
  187. void SystemCoreClockUpdate(void);
  188. /**
  189. * @brief Set up and initialize hardware prior to call to main()
  190. * @return None
  191. * @note Chip_SystemInit() is called prior to the application and sets up
  192. * system clocking prior to the application starting.
  193. */
  194. void Chip_SystemInit(void);
  195. /**
  196. * @brief Clock and PLL initialization based on the internal oscillator
  197. * @param iFreq : Rate (in Hz) to set the main system clock to
  198. * @return None
  199. */
  200. void Chip_SetupIrcClocking(uint32_t iFreq);
  201. /**
  202. * @brief Clock and PLL initialization based on the external clock input
  203. * @param iFreq : Rate (in Hz) to set the main system clock to
  204. * @return None
  205. */
  206. void Chip_SetupExtInClocking(uint32_t iFreq);
  207. /**
  208. * @}
  209. */
  210. #ifdef __cplusplus
  211. }
  212. #endif
  213. #endif /* __CHIP_H_ */