BLE_TYQ_BJQ_CH32V303/bsp/inc/bsp_vin_detection.h

37 lines
980 B
C
Raw Normal View History

2024-12-01 13:49:43 +08:00
/*
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-09-13 13:11:09
* @LastEditors : stark1898y 1658608470@qq.com
2025-02-21 15:33:29 +08:00
* @LastEditTime : 2025-01-23 16:17:44
* @FilePath : \JT-DT-YD4N02A_4G_RTT_MRS\bsp\inc\bsp_vin_detection.h
2024-12-01 13:49:43 +08:00
* @Description :
*
* Copyright (c) 2024 by yzy, All Rights Reserved.
*/
#ifndef __BSP_VIN_DETECTION_H__
#define __BSP_VIN_DETECTION_H__
#include "board.h"
2025-02-21 15:33:29 +08:00
#if 1
2024-12-01 13:49:43 +08:00
#define VIN_THREAD_STACK_SIZE (1024)
2025-02-21 15:33:29 +08:00
#define VIN_THREAD_PRIORITY (5)
2024-12-01 13:49:43 +08:00
#define VIN_THREAD_TIMESLICE (5)
#endif
#define VIN_VOLTAGE_RATIO (4.19148936F)
// 不含输入二极管的压降
// (4.7/19.7) * 13V = 3.1V, 3.1/3.3*4096 = 3723
2025-02-21 15:33:29 +08:00
#define VIN_ADC_HIGH_THRESHOLD (uint16_t)3847 // 13V
2024-12-01 13:49:43 +08:00
// (4.7/19.7) * 10V = 2.39V, 2.39/3.3*4096 = 2966
2025-02-21 15:33:29 +08:00
#define VIN_ADC_LOW_THRESHOLD (uint16_t)2966 // 10V
2024-12-01 13:49:43 +08:00
float Get_VIN_Voltage(void);
uint16_t Get_VIN_VoltageInt1000x(void);
int BSP_VIN_Detection_Init(void);
#endif // !__BSP_VIN_DETECTION_H__