adc.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. ******************************************************************************
  3. * @file VAPC-meter/lib/adc.h
  4. * @author "Vladimir N. Shilov" <shilow@ukr.net>
  5. * @version V1
  6. * @date 24-March-2016
  7. * @brief This file contains the headers of the ADC functions.
  8. ******************************************************************************
  9. */
  10. /* Define to prevent recursive inclusion -------------------------------------*/
  11. #pragma once
  12. #ifndef __ADC_H
  13. #define __ADC_H
  14. /* Includes ------------------------------------------------------------------*/
  15. #include "stm8l15x.h"
  16. /* Exported types ------------------------------------------------------------*/
  17. /* Exported defines ----------------------------------------------------------*/
  18. #define VOLTAGE_CHANNEL ADC_Channel_17
  19. #define CURRENT_CHANNEL ADC_Channel_18
  20. #define ADC1_DR_ADDRESS ((uint16_t)0x5344)
  21. #define ADC_BUFFER_SIZE ((uint8_t) 3)
  22. #define ADC_BUFFER_ADDRESS ((uint16_t)(&ADC_Buffer))
  23. #define FAST_BUFFER_SIZE ((uint8_t) 16)
  24. /* ADC_RATIO = (( 3.3 * 1000 * 1000 ) + 2048 ) / 4095 */
  25. #define ADC_RATIO 806UL
  26. #define ADC_VOLT_RATIO 8864UL
  27. // (×àñòîòà ÌÊ (16 ÌHz) / Ïðåääåëèòåëü òàéìåðà (32) * Íóæíîå âðåìÿ â ñåêóíäàõ (0.00125)) - 1
  28. #define TIM_PERIOD ((uint16_t)624)
  29. #define TIM_PRESCALER TIM2_Prescaler_32
  30. /* Exported constants --------------------------------------------------------*/
  31. /* Exported macro ------------------------------------------------------------*/
  32. /* Exported functions ------------------------------------------------------- */
  33. void Init_ADC(void);
  34. #endif /* __ADC_H */
  35. /************************ (C) Vladimir N. Shilov *****END OF FILE****/