File tree Expand file tree Collapse file tree 3 files changed +36
-9
lines changed
targets/TARGET_NXP/TARGET_MCUXpresso_MCUS
TARGET_LPC54114/TARGET_LPCXpresso
TARGET_LPC54608/TARGET_LPCXpresso Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
#include "gpio_api.h"
17
17
#include "clock_config.h"
18
+ #include "fsl_power.h"
18
19
19
20
// called before main
20
21
void mbed_sdk_init ()
@@ -31,6 +32,19 @@ void NMI_Handler(void)
31
32
//gpio_init_in(&gpio, PTA4);
32
33
}
33
34
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
+
34
48
// Enable the RTC oscillator if available on the board
35
49
void rtc_setup_oscillator (void )
36
50
{
Original file line number Diff line number Diff line change 16
16
#include "gpio_api.h"
17
17
#include "clock_config.h"
18
18
#include "fsl_emc.h"
19
+ #include "fsl_power.h"
19
20
20
21
/*******************************************************************************
21
22
* Definitions
@@ -58,6 +59,25 @@ void rtc_setup_oscillator(void)
58
59
SYSCON -> RTCOSCCTRL |= SYSCON_RTCOSCCTRL_EN_MASK ;
59
60
}
60
61
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
+
61
81
/* Initialize the external memory. */
62
82
void BOARD_InitSDRAM (void )
63
83
{
Original file line number Diff line number Diff line change 27
27
28
28
/* Array of ADC peripheral base address. */
29
29
static ADC_Type * const adc_addrs [] = ADC_BASE_PTRS ;
30
+ extern void ADC_ClockPower_Configuration (void );
30
31
31
32
#define MAX_FADC 6000000
32
33
@@ -38,15 +39,7 @@ void analogin_init(analogin_t *obj, PinName pin)
38
39
uint32_t instance = obj -> adc >> ADC_INSTANCE_SHIFT ;
39
40
adc_config_t adc_config ;
40
41
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 ();
50
43
51
44
/* Calibration after power up. */
52
45
if (!(ADC_DoSelfCalibration (adc_addrs [instance ]))) {
You can’t perform that action at this time.
0 commit comments