boards/arm: stm32l496g_disco: Enabling adc support
This commit enables ADC support for stm32l496g_disco platform in device tree. VREF is configured to use internal. Current VREF is 2.5V. Signed-off-by: Affrin Pinhero <affrin.pinhero@hcl.com>
This commit is contained in:
parent
5e92d42749
commit
cd887d0f93
5 changed files with 43 additions and 0 deletions
4
boards/arm/stm32l496g_disco/CMakeLists.txt
Normal file
4
boards/arm/stm32l496g_disco/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) 2021 STMicroelectronics
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_ADC board_adc_vref.c)
|
31
boards/arm/stm32l496g_disco/board_adc_vref.c
Normal file
31
boards/arm/stm32l496g_disco/board_adc_vref.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2021 STMicroelectronics
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <init.h>
|
||||
#include <stm32_ll_adc.h>
|
||||
#include <devicetree.h>
|
||||
|
||||
static int enable_adc_reference(const struct device *dev)
|
||||
{
|
||||
uint8_t init_status;
|
||||
/* VREF+ is not connected to VDDA by default */
|
||||
/* Use 2.5V as reference (instead of 3.3V) for internal channels
|
||||
* calculation
|
||||
*/
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
|
||||
/* VREF_OUT2 = 2.5 V */
|
||||
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1);
|
||||
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(
|
||||
SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
|
||||
|
||||
init_status = HAL_SYSCFG_EnableVREFBUF();
|
||||
__ASSERT(init_status == HAL_OK, "ADC Conversion value may be incorrect");
|
||||
|
||||
return init_status;
|
||||
}
|
||||
|
||||
SYS_INIT(enable_adc_reference, POST_KERNEL, 0);
|
|
@ -146,6 +146,8 @@ The Zephyr stm32l496g_disco board configuration supports the following hardware
|
|||
+-----------+------------+-------------------------------------+
|
||||
| PWM | on-chip | pwm |
|
||||
+-----------+------------+-------------------------------------+
|
||||
| ADC | on-chip | adc |
|
||||
+-----------+------------+-------------------------------------+
|
||||
|
||||
Other hardware features are not yet supported on this Zephyr port.
|
||||
|
||||
|
|
|
@ -134,3 +134,8 @@
|
|||
&sdmmc1_ck_pc12 &sdmmc1_cmd_pd2>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&adc1 {
|
||||
pinctrl-0 = < &adc1_in2_pc1>;
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -16,3 +16,4 @@ supported:
|
|||
- gpio
|
||||
- counter
|
||||
- sdhc
|
||||
- adc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue