chip.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * @brief LPC8xx basic chip inclusion file
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2013
  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_M0PLUS
  40. #error CORE_M0PLUS is not defined for the LPC8xx architecture
  41. #error CORE_M0PLUS should be defined as part of your compiler define list
  42. #endif
  43. #ifndef CHIP_LPC8XX
  44. #error The LPC8XX Chip include path is used for this build, but
  45. #error CHIP_LPC8XX is not defined!
  46. #endif
  47. /** @defgroup PERIPH_8XX_BASE CHIP: LPC8xx Peripheral addresses and register set declarations
  48. * @ingroup CHIP_8XX_Drivers
  49. * @{
  50. */
  51. /* Base addresses */
  52. #define LPC_FLASH_BASE (0x00000000UL)
  53. #define LPC_RAM_BASE (0x10000000UL)
  54. #define LPC_ROM_BASE (0x1FFF0000UL)
  55. #define LPC_APB0_BASE (0x40000000UL)
  56. #define LPC_AHB_BASE (0x50000000UL)
  57. /* APB0 peripherals */
  58. #define LPC_WWDT_BASE (0x40000000UL)
  59. #define LPC_MRT_BASE (0x40004000UL)
  60. #define LPC_WKT_BASE (0x40008000UL)
  61. #define LPC_SWM_BASE (0x4000C000UL)
  62. #define LPC_ADC_BASE (0x4001C000UL) /* Available only on LPC82x */
  63. #define LPC_PMU_BASE (0x40020000UL)
  64. #define LPC_CMP_BASE (0x40024000UL)
  65. #define LPC_DMATIRGMUX_BASE (0x40028000UL) /* Available only on LPC82x */
  66. #define LPC_INMUX_BASE (0x4002C000UL) /* Available only on LPC82x */
  67. #define LPC_FMC_BASE (0x40040000UL)
  68. #define LPC_IOCON_BASE (0x40044000UL)
  69. #define LPC_SYSCTL_BASE (0x40048000UL)
  70. #define LPC_I2C0_BASE (0x40050000UL)
  71. #define LPC_I2C1_BASE (0x40054000UL) /* Available only on LPC82x */
  72. #define LPC_SPI0_BASE (0x40058000UL)
  73. #define LPC_SPI1_BASE (0x4005C000UL)
  74. #define LPC_USART0_BASE (0x40064000UL)
  75. #define LPC_USART1_BASE (0x40068000UL)
  76. #define LPC_USART2_BASE (0x4006C000UL)
  77. #define LPC_I2C2_BASE (0x40070000UL) /* Available only on LPC82x */
  78. #define LPC_I2C3_BASE (0x40074000UL) /* Available only on LPC82x */
  79. /* AHB peripherals */
  80. #define LPC_CRC_BASE (0x50000000UL)
  81. #define LPC_SCT_BASE (0x50004000UL)
  82. #define LPC_DMA_BASE (0x50008000UL) /* Available only on LPC82x */
  83. #define LPC_GPIO_PORT_BASE (0xA0000000UL)
  84. #define LPC_PIN_INT_BASE (0xA0004000UL)
  85. #define LPC_WWDT ((LPC_WWDT_T *) LPC_WWDT_BASE)
  86. #define LPC_SPI0 ((LPC_SPI_T *) LPC_SPI0_BASE)
  87. #define LPC_SPI1 ((LPC_SPI_T *) LPC_SPI1_BASE)
  88. #define LPC_USART0 ((LPC_USART_T *) LPC_USART0_BASE)
  89. #define LPC_USART1 ((LPC_USART_T *) LPC_USART1_BASE)
  90. #define LPC_USART2 ((LPC_USART_T *) LPC_USART2_BASE)
  91. #define LPC_WKT ((LPC_WKT_T *) LPC_WKT_BASE)
  92. #define LPC_PMU ((LPC_PMU_T *) LPC_PMU_BASE)
  93. #define LPC_CRC ((LPC_CRC_T *) LPC_CRC_BASE)
  94. #define LPC_SCT ((LPC_SCT_T *) LPC_SCT_BASE)
  95. #define LPC_GPIO_PORT ((LPC_GPIO_T *) LPC_GPIO_PORT_BASE)
  96. #define LPC_PININT ((LPC_PIN_INT_T *) LPC_PIN_INT_BASE)
  97. #define LPC_IOCON ((LPC_IOCON_T *) LPC_IOCON_BASE)
  98. #define LPC_SWM ((LPC_SWM_T *) LPC_SWM_BASE)
  99. #define LPC_SYSCTL ((LPC_SYSCTL_T *) LPC_SYSCTL_BASE)
  100. #define LPC_CMP ((LPC_CMP_T *) LPC_CMP_BASE)
  101. #define LPC_FMC ((LPC_FMC_T *) LPC_FMC_BASE)
  102. #define LPC_MRT ((LPC_MRT_T *) LPC_MRT_BASE)
  103. #define LPC_I2C0 ((LPC_I2C_T *) LPC_I2C0_BASE)
  104. #ifdef CHIP_LPC82X
  105. /* Peripherals available only on LPC82x */
  106. #define LPC_ADC ((LPC_ADC_T *) LPC_ADC_BASE)
  107. #define LPC_I2C1 ((LPC_I2C_T *) LPC_I2C1_BASE)
  108. #define LPC_I2C2 ((LPC_I2C_T *) LPC_I2C2_BASE)
  109. #define LPC_I2C3 ((LPC_I2C_T *) LPC_I2C3_BASE)
  110. #define LPC_DMA ((LPC_DMA_T *) LPC_DMA_BASE)
  111. #define LPC_DMATRIGMUX ((LPC_DMATRIGMUX_T *) LPC_DMATIRGMUX_BASE)
  112. #define LPC_INMUX ((LPC_INMUX_T *) LPC_INMUX_BASE)
  113. #endif
  114. /* Base address Alias list */
  115. #define LPC_I2C_BASE LPC_I2C0_BASE
  116. #define LPC_I2C LPC_I2C0
  117. #define LPC_SYSCON LPC_SYSCTL
  118. /* IRQ Handler alias list */
  119. #ifdef CHIP_LPC82X
  120. #define I2C_IRQHandler I2C0_IRQHandler
  121. #define PININT0_IRQHandler PIN_INT0_IRQHandler
  122. #define PININT1_IRQHandler PIN_INT1_IRQHandler
  123. #define PININT2_IRQHandler PIN_INT2_IRQHandler
  124. #define PININT3_IRQHandler PIN_INT3_IRQHandler
  125. #define PININT4_IRQHandler PIN_INT4_IRQHandler
  126. #define PININT5_IRQHandler PIN_INT5_IRQHandler
  127. #define PININT6_IRQHandler PIN_INT6_IRQHandler
  128. #define PININT7_IRQHandler PIN_INT7_IRQHandler
  129. #endif
  130. /**
  131. * @}
  132. */
  133. /** @ingroup CHIP_8XX_DRIVER_OPTIONS
  134. * @{
  135. */
  136. /**
  137. * @brief System oscillator rate
  138. * This value is defined externally to the chip layer and contains
  139. * the value in Hz for the external oscillator for the board. If using the
  140. * internal oscillator, this rate can be 0.
  141. */
  142. extern const uint32_t OscRateIn;
  143. /**
  144. * @brief Clock rate on the CLKIN pin
  145. * This value is defined externally to the chip layer and contains
  146. * the value in Hz for the CLKIN pin for the board. If this pin isn't used,
  147. * this rate can be 0.
  148. */
  149. extern const uint32_t ExtRateIn;
  150. /**
  151. * @}
  152. */
  153. /* Include order is important! */
  154. #include "romapi_8xx.h"
  155. #include "syscon_8xx.h"
  156. #include "clock_8xx.h"
  157. #include "iocon_8xx.h"
  158. #include "swm_8xx.h"
  159. #include "fmc_8xx.h"
  160. #include "pinint_8xx.h"
  161. #include "pmu_8xx.h"
  162. #include "acmp_8xx.h"
  163. #include "crc_8xx.h"
  164. #include "gpio_8xx.h"
  165. #include "mrt_8xx.h"
  166. #include "uart_8xx.h"
  167. #include "wkt_8xx.h"
  168. #include "wwdt_8xx.h"
  169. #include "sct_8xx.h"
  170. #include "sct_pwm_8xx.h"
  171. #include "spi_8xx.h"
  172. #include "i2cm_8xx.h"
  173. #include "i2cs_8xx.h"
  174. #include "spim_8xx.h"
  175. #include "spis_8xx.h"
  176. #ifdef CHIP_LPC82X
  177. #include "adc_8xx.h"
  178. #include "dma_8xx.h"
  179. #include "inmux_8xx.h"
  180. #endif
  181. /** @defgroup SUPPORT_8XX_FUNC CHIP: LPC8xx support functions
  182. * @ingroup CHIP_8XX_Drivers
  183. * @{
  184. */
  185. /**
  186. * @brief Current system clock rate, mainly used for sysTick
  187. */
  188. extern uint32_t SystemCoreClock;
  189. /**
  190. * @brief Update system core clock rate, should be called if the
  191. * system has a clock rate change
  192. * @return None
  193. */
  194. void SystemCoreClockUpdate(void);
  195. /**
  196. * @brief Set up and initialize hardware prior to call to main()
  197. * @return None
  198. * @note Chip_SystemInit() is called prior to the application and sets up
  199. * system clocking prior to the application starting.
  200. */
  201. void Chip_SystemInit(void);
  202. /**
  203. * @brief Clock and PLL initialization based on the external oscillator
  204. * @return None
  205. * @note This function assumes an external crystal oscillator
  206. * frequency of 12MHz.
  207. */
  208. void Chip_SetupXtalClocking(void);
  209. /**
  210. * @brief Clock and PLL initialization based on the internal oscillator
  211. * @return None
  212. */
  213. void Chip_SetupIrcClocking(void);
  214. /**
  215. * @}
  216. */
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #endif /* __CHIP_H_ */