| 1 | /* USER CODE BEGIN Header */ |
|---|
| 2 | /** |
|---|
| 3 | ****************************************************************************** |
|---|
| 4 | * @file adc.h |
|---|
| 5 | * @brief This file contains all the function prototypes for |
|---|
| 6 | * the adc.c file |
|---|
| 7 | ****************************************************************************** |
|---|
| 8 | * @attention |
|---|
| 9 | * |
|---|
| 10 | * Copyright (c) 2025 STMicroelectronics. |
|---|
| 11 | * All rights reserved. |
|---|
| 12 | * |
|---|
| 13 | * This software is licensed under terms that can be found in the LICENSE file |
|---|
| 14 | * in the root directory of this software component. |
|---|
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS. |
|---|
| 16 | * |
|---|
| 17 | ****************************************************************************** |
|---|
| 18 | */ |
|---|
| 19 | /* USER CODE END Header */ |
|---|
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|---|
| 21 | #ifndef __ADC_H__ |
|---|
| 22 | #define __ADC_H__ |
|---|
| 23 | |
|---|
| 24 | #ifdef __cplusplus |
|---|
| 25 | extern "C" { |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | /* Includes ------------------------------------------------------------------*/ |
|---|
| 29 | #include "main.h" |
|---|
| 30 | |
|---|
| 31 | /* USER CODE BEGIN Includes */ |
|---|
| 32 | |
|---|
| 33 | #include <stdio.h> |
|---|
| 34 | |
|---|
| 35 | /* USER CODE END Includes */ |
|---|
| 36 | |
|---|
| 37 | extern ADC_HandleTypeDef hadc2; |
|---|
| 38 | |
|---|
| 39 | extern ADC_HandleTypeDef hadc3; |
|---|
| 40 | |
|---|
| 41 | /* USER CODE BEGIN Private defines */ |
|---|
| 42 | |
|---|
| 43 | #define ADC2_CHANNELS_NUM (3U) |
|---|
| 44 | #define ADC3_CHANNELS_NUM (4U) |
|---|
| 45 | #define VREF (3000U) |
|---|
| 46 | |
|---|
| 47 | typedef union ADC2_data_t |
|---|
| 48 | { |
|---|
| 49 | uint16_t Raw[ADC2_CHANNELS_NUM]; |
|---|
| 50 | struct |
|---|
| 51 | { |
|---|
| 52 | int16_t charge_strom; |
|---|
| 53 | int16_t eload_strom; |
|---|
| 54 | int16_t u_bat; |
|---|
| 55 | } Name; |
|---|
| 56 | } __attribute__((packed, aligned(32))) ADC2_data_t; |
|---|
| 57 | |
|---|
| 58 | typedef union ADC3_data_t |
|---|
| 59 | { |
|---|
| 60 | uint16_t Raw[ADC3_CHANNELS_NUM]; |
|---|
| 61 | struct |
|---|
| 62 | { |
|---|
| 63 | uint16_t UBat; |
|---|
| 64 | uint16_t Vbat; |
|---|
| 65 | uint16_t Temp; |
|---|
| 66 | uint16_t Vref; |
|---|
| 67 | } Name; |
|---|
| 68 | } __attribute__((packed, aligned(32))) ADC3_data_t; |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | /* USER CODE END Private defines */ |
|---|
| 72 | |
|---|
| 73 | void MX_ADC2_Init(void); |
|---|
| 74 | void MX_ADC3_Init(void); |
|---|
| 75 | |
|---|
| 76 | /* USER CODE BEGIN Prototypes */ |
|---|
| 77 | |
|---|
| 78 | extern volatile ADC2_data_t ADC2Data; |
|---|
| 79 | extern volatile ADC3_data_t ADC3Data; |
|---|
| 80 | |
|---|
| 81 | /* USER CODE END Prototypes */ |
|---|
| 82 | |
|---|
| 83 | #ifdef __cplusplus |
|---|
| 84 | } |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | #endif /* __ADC_H__ */ |
|---|
| 88 | |
|---|