LPC: Move platform specific code out of the analog api file

Signed-off-by: Mahadevan Mahesh <Mahesh.Mahadevan@nxp.com>
pull/4824/head
Mahadevan Mahesh 2017-05-12 08:30:28 -05:00 committed by Martin Kojtal
parent fb97d8bf42
commit 5b85962c95
3 changed files with 36 additions and 9 deletions

View File

@ -15,6 +15,7 @@
*/ */
#include "gpio_api.h" #include "gpio_api.h"
#include "clock_config.h" #include "clock_config.h"
#include "fsl_power.h"
// called before main // called before main
void mbed_sdk_init() void mbed_sdk_init()
@ -31,6 +32,19 @@ void NMI_Handler(void)
//gpio_init_in(&gpio, PTA4); //gpio_init_in(&gpio, PTA4);
} }
void ADC_ClockPower_Configuration(void)
{
/* SYSCON power. */
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
POWER_DisablePD(kPDRUNCFG_PD_VD7_ENA); /* Power on the analog power supply. */
POWER_DisablePD(kPDRUNCFG_PD_VREFP_SW); /* Power on the reference voltage source. */
POWER_DisablePD(kPDRUNCFG_PD_TEMPS); /* Power on the temperature sensor. */
/* Enable the clock. */
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
CLOCK_EnableClock(kCLOCK_Adc0);
}
// Enable the RTC oscillator if available on the board // Enable the RTC oscillator if available on the board
void rtc_setup_oscillator(void) void rtc_setup_oscillator(void)
{ {

View File

@ -16,6 +16,7 @@
#include "gpio_api.h" #include "gpio_api.h"
#include "clock_config.h" #include "clock_config.h"
#include "fsl_emc.h" #include "fsl_emc.h"
#include "fsl_power.h"
/******************************************************************************* /*******************************************************************************
* Definitions * Definitions
@ -58,6 +59,25 @@ void rtc_setup_oscillator(void)
SYSCON->RTCOSCCTRL |= SYSCON_RTCOSCCTRL_EN_MASK; SYSCON->RTCOSCCTRL |= SYSCON_RTCOSCCTRL_EN_MASK;
} }
void ADC_ClockPower_Configuration(void)
{
/* SYSCON power. */
POWER_DisablePD(kPDRUNCFG_PD_VDDA); /* Power on VDDA. */
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
POWER_DisablePD(kPDRUNCFG_PD_VD2_ANA); /* Power on the analog power supply. */
POWER_DisablePD(kPDRUNCFG_PD_VREFP); /* Power on the reference voltage source. */
POWER_DisablePD(kPDRUNCFG_PD_TS); /* Power on the temperature sensor. */
/* Enable the clock. */
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
/* CLOCK_AttachClk(kMAIN_CLK_to_ADC_CLK); */
/* Sync clock source is not used. Using sync clock source and would be divided by 2.
* The divider would be set when configuring the converter.
*/
CLOCK_EnableClock(kCLOCK_Adc0); /* SYSCON->AHBCLKCTRL[0] |= SYSCON_AHBCLKCTRL_ADC0_MASK; */
}
/* Initialize the external memory. */ /* Initialize the external memory. */
void BOARD_InitSDRAM(void) void BOARD_InitSDRAM(void)
{ {

View File

@ -27,6 +27,7 @@
/* Array of ADC peripheral base address. */ /* Array of ADC peripheral base address. */
static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS; static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS;
extern void ADC_ClockPower_Configuration(void);
#define MAX_FADC 6000000 #define MAX_FADC 6000000
@ -38,15 +39,7 @@ void analogin_init(analogin_t *obj, PinName pin)
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT; uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
adc_config_t adc_config; adc_config_t adc_config;
/* SYSCON power. */ ADC_ClockPower_Configuration();
POWER_DisablePD(kPDRUNCFG_PD_ADC0); /* Power on the ADC converter. */
POWER_DisablePD(kPDRUNCFG_PD_VD7_ENA); /* Power on the analog power supply. */
POWER_DisablePD(kPDRUNCFG_PD_VREFP_SW); /* Power on the reference voltage source. */
POWER_DisablePD(kPDRUNCFG_PD_TEMPS); /* Power on the temperature sensor. */
/* Enable the clock. */
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK);
CLOCK_EnableClock(kCLOCK_Adc0);
/* Calibration after power up. */ /* Calibration after power up. */
if (!(ADC_DoSelfCalibration(adc_addrs[instance]))) { if (!(ADC_DoSelfCalibration(adc_addrs[instance]))) {