initial check in based on SVN revision 575
This commit is contained in:
12100
device/LPC54114_cm4.h
Normal file
12100
device/LPC54114_cm4.h
Normal file
File diff suppressed because it is too large
Load Diff
255
device/LPC54114_cm4_features.h
Normal file
255
device/LPC54114_cm4_features.h
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Version: rev. 1.0, 2016-05-09
|
||||
** Build: b190225
|
||||
**
|
||||
** Abstract:
|
||||
** Chip specific module features.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2019 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2016-05-09)
|
||||
** Initial version.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
#ifndef _LPC54114_cm4_FEATURES_H_
|
||||
#define _LPC54114_cm4_FEATURES_H_
|
||||
|
||||
/* SOC module features */
|
||||
|
||||
/* @brief ADC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_ADC_COUNT (1)
|
||||
/* @brief ASYNC_SYSCON availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT (1)
|
||||
/* @brief CRC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CRC_COUNT (1)
|
||||
/* @brief CTIMER availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CTIMER_COUNT (5)
|
||||
/* @brief DMA availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_DMA_COUNT (1)
|
||||
/* @brief DMIC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_DMIC_COUNT (1)
|
||||
/* @brief FLEXCOMM availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_FLEXCOMM_COUNT (8)
|
||||
/* @brief GINT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_GINT_COUNT (2)
|
||||
/* @brief GPIO availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_GPIO_COUNT (1)
|
||||
/* @brief I2C availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_I2C_COUNT (8)
|
||||
/* @brief I2S availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_I2S_COUNT (2)
|
||||
/* @brief INPUTMUX availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_INPUTMUX_COUNT (1)
|
||||
/* @brief IOCON availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_IOCON_COUNT (1)
|
||||
/* @brief MAILBOX availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_MAILBOX_COUNT (1)
|
||||
/* @brief MRT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_MRT_COUNT (1)
|
||||
/* @brief PINT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_PINT_COUNT (1)
|
||||
/* @brief RTC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_RTC_COUNT (1)
|
||||
/* @brief SCT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SCT_COUNT (1)
|
||||
/* @brief SPI availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SPI_COUNT (8)
|
||||
/* @brief SPIFI availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SPIFI_COUNT (1)
|
||||
/* @brief SYSCON availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SYSCON_COUNT (1)
|
||||
/* @brief USART availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USART_COUNT (8)
|
||||
/* @brief USB availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USB_COUNT (1)
|
||||
/* @brief UTICK availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_UTICK_COUNT (1)
|
||||
/* @brief WWDT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_WWDT_COUNT (1)
|
||||
|
||||
/* ADC module features */
|
||||
|
||||
/* @brief Do not has input select (register INSEL). */
|
||||
#define FSL_FEATURE_ADC_HAS_NO_INSEL (0)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE (1)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_RESOL (1)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL (1)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_TSAMP (1)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE (0)
|
||||
/* @brief Has ASYNMODE bitfile in CTRL reigster. */
|
||||
#define FSL_FEATURE_ADC_HAS_CTRL_CALMODE (0)
|
||||
/* @brief Has startup register. */
|
||||
#define FSL_FEATURE_ADC_HAS_STARTUP_REG (1)
|
||||
/* @brief Has ADTrim register */
|
||||
#define FSL_FEATURE_ADC_HAS_TRIM_REG (0)
|
||||
/* @brief Has Calibration register. */
|
||||
#define FSL_FEATURE_ADC_HAS_CALIB_REG (1)
|
||||
|
||||
/* DMA module features */
|
||||
|
||||
/* @brief Number of channels */
|
||||
#define FSL_FEATURE_DMA_NUMBER_OF_CHANNELS (20)
|
||||
/* @brief Align size of DMA descriptor */
|
||||
#define FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE (512)
|
||||
/* @brief DMA head link descriptor table align size */
|
||||
#define FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE (16U)
|
||||
|
||||
/* FLEXCOMM module features */
|
||||
|
||||
/* @brief FLEXCOMM0 USART INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_USART_INDEX (0)
|
||||
/* @brief FLEXCOMM0 SPI INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_SPI_INDEX (0)
|
||||
/* @brief FLEXCOMM0 I2C INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_I2C_INDEX (0)
|
||||
/* @brief FLEXCOMM1 USART INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_USART_INDEX (1)
|
||||
/* @brief FLEXCOMM1 SPI INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_SPI_INDEX (1)
|
||||
/* @brief FLEXCOMM1 I2C INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_I2C_INDEX (1)
|
||||
/* @brief FLEXCOMM2 USART INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_USART_INDEX (2)
|
||||
/* @brief FLEXCOMM2 SPI INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_SPI_INDEX (2)
|
||||
/* @brief FLEXCOMM2 I2C INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_I2C_INDEX (2)
|
||||
/* @brief FLEXCOMM3 USART INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_USART_INDEX (3)
|
||||
/* @brief FLEXCOMM3 SPI INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_SPI_INDEX (3)
|
||||
/* @brief FLEXCOMM3 I2C INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_I2C_INDEX (3)
|
||||
/* @brief FLEXCOMM4 USART INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_USART_INDEX (4)
|
||||
/* @brief FLEXCOMM4 SPI INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_SPI_INDEX (4)
|
||||
/* @brief FLEXCOMM4 I2C INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_I2C_INDEX (4)
|
||||
/* @brief FLEXCOMM5 USART INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_USART_INDEX (5)
|
||||
/* @brief FLEXCOMM5 SPI INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_SPI_INDEX (5)
|
||||
/* @brief FLEXCOMM5 I2C INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_I2C_INDEX (5)
|
||||
/* @brief FLEXCOMM6 USART INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_USART_INDEX (6)
|
||||
/* @brief FLEXCOMM6 SPI INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_SPI_INDEX (6)
|
||||
/* @brief FLEXCOMM6 I2C INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_I2C_INDEX (6)
|
||||
/* @brief FLEXCOMM7 I2S INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_I2S_INDEX (0)
|
||||
/* @brief FLEXCOMM7 USART INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_USART_INDEX (7)
|
||||
/* @brief FLEXCOMM7 SPI INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_SPI_INDEX (7)
|
||||
/* @brief FLEXCOMM7 I2C INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_I2C_INDEX (7)
|
||||
/* @brief FLEXCOMM7 I2S INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_I2S_INDEX (1)
|
||||
/* @brief I2S has DMIC interconnection */
|
||||
#define FSL_FEATURE_FLEXCOMM_INSTANCE_I2S_HAS_DMIC_INTERCONNECTIONn(x) \
|
||||
(((x) == FLEXCOMM0) ? (0) : \
|
||||
(((x) == FLEXCOMM1) ? (0) : \
|
||||
(((x) == FLEXCOMM2) ? (0) : \
|
||||
(((x) == FLEXCOMM3) ? (0) : \
|
||||
(((x) == FLEXCOMM4) ? (0) : \
|
||||
(((x) == FLEXCOMM5) ? (0) : \
|
||||
(((x) == FLEXCOMM6) ? (0) : \
|
||||
(((x) == FLEXCOMM7) ? (1) : (-1)))))))))
|
||||
|
||||
/* I2S module features */
|
||||
|
||||
/* @brief I2S support dual channel transfer */
|
||||
#define FSL_FEATURE_I2S_SUPPORT_SECONDARY_CHANNEL (0)
|
||||
/* @brief I2S has DMIC interconnection */
|
||||
#define FSL_FEATURE_FLEXCOMM_I2S_HAS_DMIC_INTERCONNECTION (1)
|
||||
|
||||
/* MAILBOX module features */
|
||||
|
||||
/* @brief Mailbox side for current core */
|
||||
#define FSL_FEATURE_MAILBOX_SIDE_A (1)
|
||||
/* @brief Mailbox has no reset control */
|
||||
#define FSL_FEATURE_MAILBOX_HAS_NO_RESET (1)
|
||||
|
||||
/* MRT module features */
|
||||
|
||||
/* @brief number of channels. */
|
||||
#define FSL_FEATURE_MRT_NUMBER_OF_CHANNELS (4)
|
||||
|
||||
/* interrupt module features */
|
||||
|
||||
/* @brief Lowest interrupt request number. */
|
||||
#define FSL_FEATURE_INTERRUPT_IRQ_MIN (-14)
|
||||
/* @brief Highest interrupt request number. */
|
||||
#define FSL_FEATURE_INTERRUPT_IRQ_MAX (105)
|
||||
|
||||
/* PINT module features */
|
||||
|
||||
/* @brief Number of connected outputs */
|
||||
#define FSL_FEATURE_PINT_NUMBER_OF_CONNECTED_OUTPUTS (8)
|
||||
|
||||
/* RTC module features */
|
||||
|
||||
/* @brief RTC has no reset control */
|
||||
#define FSL_FEATURE_RTC_HAS_NO_RESET (1)
|
||||
|
||||
/* SCT module features */
|
||||
|
||||
/* @brief Number of events */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_EVENTS (10)
|
||||
/* @brief Number of states */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_STATES (10)
|
||||
/* @brief Number of match capture */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_MATCH_CAPTURE (10)
|
||||
/* @brief Number of outputs */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_OUTPUTS (8)
|
||||
|
||||
/* SYSCON module features */
|
||||
|
||||
/* @brief Pointer to ROM IAP entry functions */
|
||||
#define FSL_FEATURE_SYSCON_IAP_ENTRY_LOCATION (0x03000205)
|
||||
/* @brief Flash page size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES (256)
|
||||
/* @brief Flash sector size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_SECTOR_SIZE_BYTES (32768)
|
||||
/* @brief Flash size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_SIZE_BYTES (262144)
|
||||
/* @brief IAP has Flash read & write function */
|
||||
#define FSL_FEATURE_IAP_HAS_FLASH_FUNCTION (1)
|
||||
/* @brief IAP has read Flash signature function */
|
||||
#define FSL_FEATURE_IAP_HAS_FLASH_SIGNATURE_READ (1)
|
||||
/* @brief IAP has read extended Flash signature function */
|
||||
#define FSL_FEATURE_IAP_HAS_FLASH_EXTENDED_SIGNATURE_READ (0)
|
||||
|
||||
/* SysTick module features */
|
||||
|
||||
/* @brief Systick has external reference clock. */
|
||||
#define FSL_FEATURE_SYSTICK_HAS_EXT_REF (0)
|
||||
/* @brief Systick external reference clock is core clock divided by this value. */
|
||||
#define FSL_FEATURE_SYSTICK_EXT_REF_CORE_DIV (0)
|
||||
|
||||
/* USB module features */
|
||||
|
||||
/* @brief Number of the endpoint in USB FS */
|
||||
#define FSL_FEATURE_USB_EP_NUM (5)
|
||||
|
||||
#endif /* _LPC54114_cm4_FEATURES_H_ */
|
||||
|
||||
43
device/fsl_device_registers.h
Normal file
43
device/fsl_device_registers.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2014-2016 Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FSL_DEVICE_REGISTERS_H__
|
||||
#define __FSL_DEVICE_REGISTERS_H__
|
||||
|
||||
/*
|
||||
* Include the cpu specific register header files.
|
||||
*
|
||||
* The CPU macro should be declared in the project or makefile.
|
||||
*/
|
||||
#if (defined(CPU_LPC54114J256BD64_cm4) || defined(CPU_LPC54114J256UK49_cm4))
|
||||
|
||||
#define LPC54114_cm4_SERIES
|
||||
|
||||
/* CMSIS-style register definitions */
|
||||
#include "LPC54114_cm4.h"
|
||||
/* CPU specific feature definitions */
|
||||
#include "LPC54114_cm4_features.h"
|
||||
|
||||
#elif (defined(CPU_LPC54114J256BD64_cm0plus) || defined(CPU_LPC54114J256UK49_cm0plus))
|
||||
|
||||
#define LPC54114_cm0plus_SERIES
|
||||
|
||||
/* CMSIS-style register definitions */
|
||||
#include "LPC54114_cm0plus.h"
|
||||
/* CPU specific feature definitions */
|
||||
#include "LPC54114_cm0plus_features.h"
|
||||
|
||||
#else
|
||||
#error "No valid CPU defined!"
|
||||
#endif
|
||||
|
||||
#endif /* __FSL_DEVICE_REGISTERS_H__ */
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF
|
||||
******************************************************************************/
|
||||
355
device/system_LPC54114_cm4.c
Normal file
355
device/system_LPC54114_cm4.c
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: LPC54114J256BD64_cm4
|
||||
** LPC54114J256UK49_cm4
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: LPC5411x User manual Rev. 1.1 25 May 2016
|
||||
** Version: rev. 1.0, 2016-04-29
|
||||
** Build: b180802
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2016-04-29)
|
||||
** Initial version.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file LPC54114_cm4
|
||||
* @version 1.0
|
||||
* @date 2016-04-29
|
||||
* @brief Device specific configuration file for LPC54114_cm4 (implementation
|
||||
* file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
#define NVALMAX (0x100U)
|
||||
#define PVALMAX (0x20U)
|
||||
#define MVALMAX (0x8000U)
|
||||
#define PLL_SSCG0_MDEC_VAL_P (0U) /* MDEC is in bits 16 downto 0 */
|
||||
#define PLL_SSCG0_MDEC_VAL_M (0x1FFFFUL << PLL_SSCG0_MDEC_VAL_P) /* NDEC is in bits 9 downto 0 */
|
||||
#define PLL_NDEC_VAL_P (0U) /* NDEC is in bits 9:0 */
|
||||
#define PLL_NDEC_VAL_M (0x3FFUL << PLL_NDEC_VAL_P)
|
||||
#define PLL_PDEC_VAL_P (0U) /* PDEC is in bits 6:0 */
|
||||
#define PLL_PDEC_VAL_M (0x3FFUL << PLL_PDEC_VAL_P)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Core clock
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
||||
|
||||
static const uint8_t wdtFreqLookup[32] = {0, 8, 12, 15, 18, 20, 24, 26, 28, 30, 32, 34, 36, 38, 40, 41,
|
||||
42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58, 59, 60, 61};
|
||||
|
||||
static uint32_t GetWdtOscFreq(void)
|
||||
{
|
||||
uint8_t freq_sel;
|
||||
uint32_t div_sel;
|
||||
div_sel = ((SYSCON->WDTOSCCTRL & SYSCON_WDTOSCCTRL_DIVSEL_MASK) + 1U) << 1U;
|
||||
freq_sel =
|
||||
wdtFreqLookup[((SYSCON->WDTOSCCTRL & SYSCON_WDTOSCCTRL_FREQSEL_MASK) >> SYSCON_WDTOSCCTRL_FREQSEL_SHIFT)];
|
||||
return ((uint32_t)freq_sel * 50000U) / div_sel;
|
||||
}
|
||||
|
||||
/* Find decoded N value for raw NDEC value */
|
||||
static uint32_t pllDecodeN(uint32_t NDEC)
|
||||
{
|
||||
uint32_t n, x, i;
|
||||
|
||||
/* Find NDec */
|
||||
switch (NDEC)
|
||||
{
|
||||
case 0xFFFU:
|
||||
n = 0U;
|
||||
break;
|
||||
case 0x302U:
|
||||
n = 1U;
|
||||
break;
|
||||
case 0x202U:
|
||||
n = 2U;
|
||||
break;
|
||||
default:
|
||||
x = 0x080U;
|
||||
n = 0xFFFFFFFFU;
|
||||
for (i = NVALMAX; i >= 3U; i--)
|
||||
{
|
||||
x = (((x ^ (x >> 2U) ^ (x >> 3U) ^ (x >> 4U)) & 1U) << 7U) | ((x >> 1U) & 0x7FU);
|
||||
if ((x & (PLL_NDEC_VAL_M >> PLL_NDEC_VAL_P)) == NDEC)
|
||||
{
|
||||
/* Decoded value of NDEC */
|
||||
n = i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Find decoded P value for raw PDEC value */
|
||||
static uint32_t pllDecodeP(uint32_t PDEC)
|
||||
{
|
||||
uint32_t p, x, i;
|
||||
/* Find PDec */
|
||||
switch (PDEC)
|
||||
{
|
||||
case 0xFFU:
|
||||
p = 0U;
|
||||
break;
|
||||
case 0x62U:
|
||||
p = 1U;
|
||||
break;
|
||||
case 0x42U:
|
||||
p = 2U;
|
||||
break;
|
||||
default:
|
||||
x = 0x10U;
|
||||
p = 0xFFFFFFFFU;
|
||||
for (i = PVALMAX; i >= 3U; i--)
|
||||
{
|
||||
x = (((x ^ (x >> 2U)) & 1U) << 4U) | ((x >> 1U) & 0xFU);
|
||||
if ((x & (PLL_PDEC_VAL_M >> PLL_PDEC_VAL_P)) == PDEC)
|
||||
{
|
||||
/* Decoded value of PDEC */
|
||||
p = i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Find decoded M value for raw MDEC value */
|
||||
static uint32_t pllDecodeM(uint32_t MDEC)
|
||||
{
|
||||
uint32_t m, i, x;
|
||||
|
||||
/* Find MDec */
|
||||
switch (MDEC)
|
||||
{
|
||||
case 0xFFFFFU:
|
||||
m = 0U;
|
||||
break;
|
||||
case 0x18003U:
|
||||
m = 1U;
|
||||
break;
|
||||
case 0x10003U:
|
||||
m = 2U;
|
||||
break;
|
||||
default:
|
||||
x = 0x04000U;
|
||||
m = 0xFFFFFFFFU;
|
||||
for (i = MVALMAX; i >= 3U; i--)
|
||||
{
|
||||
x = (((x ^ (x >> 1U)) & 1U) << 14U) | ((x >> 1U) & 0x3FFFU);
|
||||
if ((x & (PLL_SSCG0_MDEC_VAL_M >> PLL_SSCG0_MDEC_VAL_P)) == MDEC)
|
||||
{
|
||||
/* Decoded value of MDEC */
|
||||
m = i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* Get predivider (N) from PLL NDEC setting */
|
||||
static uint32_t findPllPreDiv(uint32_t ctrlReg, uint32_t nDecReg)
|
||||
{
|
||||
uint32_t preDiv = 1U;
|
||||
|
||||
/* Direct input is not used? */
|
||||
if ((ctrlReg & SYSCON_SYSPLLCTRL_DIRECTI_MASK) == 0U)
|
||||
{
|
||||
/* Decode NDEC value to get (N) pre divider */
|
||||
preDiv = pllDecodeN(nDecReg & 0x3FFU);
|
||||
if (preDiv == 0U)
|
||||
{
|
||||
preDiv = 1U;
|
||||
}
|
||||
}
|
||||
/* Adjusted by 1, directi is used to bypass */
|
||||
return preDiv;
|
||||
}
|
||||
|
||||
/* Get postdivider (P) from PLL PDEC setting */
|
||||
static uint32_t findPllPostDiv(uint32_t ctrlReg, uint32_t pDecReg)
|
||||
{
|
||||
uint32_t postDiv = 1U;
|
||||
|
||||
/* Direct input is not used? */
|
||||
if ((ctrlReg & SYSCON_SYSPLLCTRL_DIRECTO_MASK) == 0U)
|
||||
{
|
||||
/* Decode PDEC value to get (P) post divider */
|
||||
postDiv = 2U * pllDecodeP(pDecReg & 0x7FU);
|
||||
if (postDiv == 0U)
|
||||
{
|
||||
postDiv = 2U;
|
||||
}
|
||||
}
|
||||
/* Adjusted by 1, directo is used to bypass */
|
||||
return postDiv;
|
||||
}
|
||||
|
||||
/* Get multiplier (M) from PLL MDEC and BYPASS_FBDIV2 settings */
|
||||
static uint32_t findPllMMult(uint32_t ctrlReg, uint32_t mDecReg)
|
||||
{
|
||||
uint32_t mMult = 1U;
|
||||
|
||||
/* Decode MDEC value to get (M) multiplier */
|
||||
mMult = pllDecodeM(mDecReg & 0x1FFFFU);
|
||||
/* Extra multiply by 2 needed? */
|
||||
if ((ctrlReg & SYSCON_SYSPLLCTRL_BYPASSCCODIV2_MASK) == 0U)
|
||||
{
|
||||
mMult = mMult << 1U;
|
||||
}
|
||||
if (mMult == 0U)
|
||||
{
|
||||
mMult = 1U;
|
||||
}
|
||||
return mMult;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) || (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10, CP11 Full Access */
|
||||
#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */
|
||||
extern void *__Vectors;
|
||||
SCB->VTOR = (uint32_t)&__Vectors;
|
||||
/* Optionally enable RAM banks that may be off by default at reset */
|
||||
#if !defined(DONT_ENABLE_DISABLED_RAMBANKS)
|
||||
SYSCON->AHBCLKCTRLSET[0] = SYSCON_AHBCLKCTRL_SRAM2_MASK;
|
||||
#endif
|
||||
|
||||
SystemInitHook();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemCoreClockUpdate()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
uint32_t clkRate = 0U;
|
||||
uint32_t prediv, postdiv;
|
||||
uint32_t bypassccodiv2;
|
||||
uint64_t workRate;
|
||||
|
||||
switch (SYSCON->MAINCLKSELB & SYSCON_MAINCLKSELB_SEL_MASK)
|
||||
{
|
||||
case 0x00U: /* MAINCLKSELA clock (main_clk_a)*/
|
||||
switch (SYSCON->MAINCLKSELA & SYSCON_MAINCLKSELA_SEL_MASK)
|
||||
{
|
||||
case 0x00U: /* FRO 12 MHz (fro_12m) */
|
||||
clkRate = CLK_FRO_12MHZ;
|
||||
break;
|
||||
case 0x01U: /* CLKIN (clk_in) */
|
||||
clkRate = CLK_CLK_IN;
|
||||
break;
|
||||
case 0x02U: /* Watchdog oscillator (wdt_clk) */
|
||||
clkRate = GetWdtOscFreq();
|
||||
break;
|
||||
default: /* = 0x03 = FRO 96 or 48 MHz (fro_hf) */
|
||||
if ((SYSCON->FROCTRL & SYSCON_FROCTRL_SEL_MASK) == SYSCON_FROCTRL_SEL_MASK)
|
||||
{
|
||||
clkRate = CLK_FRO_96MHZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
clkRate = CLK_FRO_48MHZ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x02U: /* System PLL clock (pll_clk)*/
|
||||
switch (SYSCON->SYSPLLCLKSEL & SYSCON_SYSPLLCLKSEL_SEL_MASK)
|
||||
{
|
||||
case 0x00U: /* FRO 12 MHz (fro_12m) */
|
||||
clkRate = CLK_FRO_12MHZ;
|
||||
break;
|
||||
case 0x01U: /* CLKIN (clk_in) */
|
||||
clkRate = CLK_CLK_IN;
|
||||
break;
|
||||
case 0x02U: /* Watchdog oscillator (wdt_clk) */
|
||||
clkRate = GetWdtOscFreq();
|
||||
break;
|
||||
case 0x03U: /* RTC oscillator 32 kHz output (32k_clk) */
|
||||
clkRate = CLK_RTC_32K_CLK;
|
||||
break;
|
||||
default:
|
||||
clkRate = 0U;
|
||||
break;
|
||||
}
|
||||
if ((SYSCON->SYSPLLCTRL & SYSCON_SYSPLLCTRL_BYPASS_MASK) == 0U)
|
||||
{
|
||||
/* PLL is not in bypass mode, get pre-divider, post-divider, and M divider */
|
||||
prediv = findPllPreDiv(SYSCON->SYSPLLCTRL, SYSCON->SYSPLLNDEC);
|
||||
postdiv = findPllPostDiv(SYSCON->SYSPLLCTRL, SYSCON->SYSPLLPDEC);
|
||||
/* Adjust input clock */
|
||||
clkRate = clkRate / prediv;
|
||||
/* If using the SS, use the multiplier */
|
||||
if ((SYSCON->SYSPLLSSCTRL0 & SYSCON_SYSPLLSSCTRL0_SEL_EXT_MASK) == SYSCON_SYSPLLSSCTRL0_SEL_EXT_MASK)
|
||||
{
|
||||
/* MDEC used for rate */
|
||||
workRate = (uint64_t)clkRate * (uint64_t)findPllMMult(SYSCON->SYSPLLCTRL, SYSCON->SYSPLLSSCTRL0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* SS multipler used for rate */
|
||||
workRate = 0UL;
|
||||
/* Adjust by fractional */
|
||||
bypassccodiv2 = (uint32_t)((SYSCON->SYSPLLCTRL & SYSCON_SYSPLLCTRL_BYPASSCCODIV2_MASK) >>
|
||||
SYSCON_SYSPLLCTRL_BYPASSCCODIV2_SHIFT);
|
||||
workRate = (2UL - bypassccodiv2) * (uint64_t)(clkRate) *
|
||||
((SYSCON->SYSPLLSSCTRL1 & 0x7FFFFUL) >> 11UL);
|
||||
}
|
||||
clkRate = (uint32_t)workRate / postdiv;
|
||||
}
|
||||
break;
|
||||
case 0x03U: /* RTC oscillator 32 kHz output (32k_clk) */
|
||||
clkRate = CLK_RTC_32K_CLK;
|
||||
break;
|
||||
default:
|
||||
clkRate = 0U;
|
||||
break;
|
||||
}
|
||||
SystemCoreClock = (uint32_t)(clkRate / ((uint64_t)(SYSCON->AHBCLKDIV & 0xFFUL) + 1UL));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInitHook()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
__attribute__((weak)) void SystemInitHook(void)
|
||||
{
|
||||
/* Void implementation of the weak function. */
|
||||
}
|
||||
109
device/system_LPC54114_cm4.h
Normal file
109
device/system_LPC54114_cm4.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: LPC54114J256BD64_cm4
|
||||
** LPC54114J256UK49_cm4
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: LPC5411x User manual Rev. 1.1 25 May 2016
|
||||
** Version: rev. 1.0, 2016-04-29
|
||||
** Build: b180802
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2016-04-29)
|
||||
** Initial version.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file LPC54114_cm4
|
||||
* @version 1.0
|
||||
* @date 2016-04-29
|
||||
* @brief Device specific configuration file for LPC54114_cm4 (header file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#ifndef _SYSTEM_LPC54114_cm4_H_
|
||||
#define _SYSTEM_LPC54114_cm4_H_ /**< Symbol preventing repeated inclusion */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#define DEFAULT_SYSTEM_CLOCK 12000000u /* Default System clock value */
|
||||
#define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz output (32k_clk */
|
||||
#define CLK_FRO_12MHZ 12000000u /* FRO 12 MHz (fro_12m) */
|
||||
#define CLK_FRO_48MHZ 48000000u /* FRO 48 MHz (fro_48m) */
|
||||
#define CLK_FRO_96MHZ 96000000u /* FRO 96 MHz (fro_96m) */
|
||||
#define CLK_CLK_IN 0u /* Default CLK_IN pin clock */
|
||||
|
||||
|
||||
/**
|
||||
* @brief System clock frequency (core clock)
|
||||
*
|
||||
* The system clock frequency supplied to the SysTick timer and the processor
|
||||
* core clock. This variable can be used by the user application to setup the
|
||||
* SysTick timer or configure other parameters. It may also be used by debugger to
|
||||
* query the frequency of the debug timer or configure the trace clock speed
|
||||
* SystemCoreClock is initialized with a correct predefined value.
|
||||
*/
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
*
|
||||
* Typically this function configures the oscillator (PLL) that is part of the
|
||||
* microcontroller device. For systems with variable clock speed it also updates
|
||||
* the variable SystemCoreClock. SystemInit is called from startup_device file.
|
||||
*/
|
||||
void SystemInit (void);
|
||||
|
||||
/**
|
||||
* @brief Updates the SystemCoreClock variable.
|
||||
*
|
||||
* It must be called whenever the core clock is changed during program
|
||||
* execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
|
||||
* the current core clock.
|
||||
*/
|
||||
void SystemCoreClockUpdate (void);
|
||||
|
||||
/**
|
||||
* @brief SystemInit function hook.
|
||||
*
|
||||
* This weak function allows to call specific initialization code during the
|
||||
* SystemInit() execution.This can be used when an application specific code needs
|
||||
* to be called as close to the reset entry as possible (for example the Multicore
|
||||
* Manager MCMGR_EarlyInit() function call).
|
||||
* NOTE: No global r/w variables can be used in this hook function because the
|
||||
* initialization of these variables happens after this function.
|
||||
*/
|
||||
void SystemInitHook (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYSTEM_LPC54114_cm4_H_ */
|
||||
Reference in New Issue
Block a user