| | |
| | | /* USER CODE END Header */ |
| | | /* Includes ------------------------------------------------------------------*/ |
| | | #include "main.h" |
| | | #include "adc.h" |
| | | #include "tim.h" |
| | | #include "usart.h" |
| | | #include "gpio.h" |
| | |
| | | int main(void) |
| | | { |
| | | /* USER CODE BEGIN 1 */ |
| | | |
| | | uint32_t lux, noisy; |
| | | /* USER CODE END 1 */ |
| | | |
| | | /* MCU Configuration--------------------------------------------------------*/ |
| | |
| | | MX_GPIO_Init(); |
| | | MX_USART1_UART_Init(); |
| | | MX_TIM4_Init(); |
| | | MX_ADC1_Init(); |
| | | /* USER CODE BEGIN 2 */ |
| | | |
| | | /* USER CODE END 2 */ |
| | |
| | | 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 */ |
| | | |
| | |
| | | { |
| | | 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. |
| | |
| | | { |
| | | 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 */ |