LingYun Studio ISKv1(IoT Starter Kits) board project
guowenxue
2021-06-19 a58d17000e8ade8090c27d170f09f0d321ab83c9
src/ISKv1/Core/Src/main.c
@@ -19,6 +19,7 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "adc.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
@@ -66,7 +67,7 @@
int main(void)
{
  /* USER CODE BEGIN 1 */
  uint32_t         lux, noisy;
  /* USER CODE END 1 */
  /* MCU Configuration--------------------------------------------------------*/
@@ -89,6 +90,7 @@
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  MX_TIM4_Init();
  MX_ADC1_Init();
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */
@@ -100,6 +102,11 @@
  while (1)
  {
     sysled_hearbeat();
     adc_sample_lux_noisy(&lux, &noisy);
     printf("Lux[%lu] Noisy[%lu]\r\n", lux, noisy);
     HAL_Delay(5000);
    /* USER CODE END WHILE */
@@ -116,6 +123,7 @@
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
@@ -144,6 +152,12 @@
  {
    Error_Handler();
  }
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
  PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
}
/* USER CODE BEGIN 4 */