Skip to content

Commit 316b859

Browse files
committed
LPC: Move platform specific code out of the analog api file
Signed-off-by: Mahadevan Mahesh <[email protected]>
1 parent 7d8b6d7 commit 316b859

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC54114/TARGET_LPCXpresso/mbed_overrides.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include "gpio_api.h"
1717
#include "clock_config.h"
18+
#include "fsl_power.h"
1819

1920
// called before main
2021
void mbed_sdk_init()
@@ -31,6 +32,19 @@ void NMI_Handler(void)
3132
//gpio_init_in(&gpio, PTA4);
3233
}
3334

35+
void ADC_ClockPower_Configuration(void)
36+
{
37+
/* SYSCON power. */
38+
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
39+
POWER_DisablePD(kPDRUNCFG_PD_VD7_ENA); /* Power on the analog power supply. */
40+
POWER_DisablePD(kPDRUNCFG_PD_VREFP_SW); /* Power on the reference voltage source. */
41+
POWER_DisablePD(kPDRUNCFG_PD_TEMPS); /* Power on the temperature sensor. */
42+
43+
/* Enable the clock. */
44+
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
45+
CLOCK_EnableClock(kCLOCK_Adc0);
46+
}
47+
3448
// Enable the RTC oscillator if available on the board
3549
void rtc_setup_oscillator(void)
3650
{

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC54608/TARGET_LPCXpresso/mbed_overrides.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "gpio_api.h"
1717
#include "clock_config.h"
1818
#include "fsl_emc.h"
19+
#include "fsl_power.h"
1920

2021
/*******************************************************************************
2122
* Definitions
@@ -58,6 +59,25 @@ void rtc_setup_oscillator(void)
5859
SYSCON->RTCOSCCTRL |= SYSCON_RTCOSCCTRL_EN_MASK;
5960
}
6061

62+
void ADC_ClockPower_Configuration(void)
63+
{
64+
/* SYSCON power. */
65+
POWER_DisablePD(kPDRUNCFG_PD_VDDA); /* Power on VDDA. */
66+
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
67+
POWER_DisablePD(kPDRUNCFG_PD_VD2_ANA); /* Power on the analog power supply. */
68+
POWER_DisablePD(kPDRUNCFG_PD_VREFP); /* Power on the reference voltage source. */
69+
POWER_DisablePD(kPDRUNCFG_PD_TS); /* Power on the temperature sensor. */
70+
71+
/* Enable the clock. */
72+
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
73+
74+
/* CLOCK_AttachClk(kMAIN_CLK_to_ADC_CLK); */
75+
/* Sync clock source is not used. Using sync clock source and would be divided by 2.
76+
* The divider would be set when configuring the converter.
77+
*/
78+
CLOCK_EnableClock(kCLOCK_Adc0); /* SYSCON->AHBCLKCTRL[0] |= SYSCON_AHBCLKCTRL_ADC0_MASK; */
79+
}
80+
6181
/* Initialize the external memory. */
6282
void BOARD_InitSDRAM(void)
6383
{

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/api/analogin_api.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
/* Array of ADC peripheral base address. */
2929
static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS;
30+
extern void ADC_ClockPower_Configuration(void);
3031

3132
#define MAX_FADC 6000000
3233

@@ -38,15 +39,7 @@ void analogin_init(analogin_t *obj, PinName pin)
3839
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
3940
adc_config_t adc_config;
4041

41-
/* SYSCON power. */
42-
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
43-
POWER_DisablePD(kPDRUNCFG_PD_VD7_ENA); /* Power on the analog power supply. */
44-
POWER_DisablePD(kPDRUNCFG_PD_VREFP_SW); /* Power on the reference voltage source. */
45-
POWER_DisablePD(kPDRUNCFG_PD_TEMPS); /* Power on the temperature sensor. */
46-
47-
/* Enable the clock. */
48-
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
49-
CLOCK_EnableClock(kCLOCK_Adc0);
42+
ADC_ClockPower_Configuration();
5043

5144
/* Calibration after power up. */
5245
if (!(ADC_DoSelfCalibration(adc_addrs[instance]))) {

0 commit comments

Comments
 (0)