chip.h 7.8 KB

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