BLE_TYQ_BJQ_CH32V303/bsp/inc/bsp_vin_detection.h

48 lines
1.3 KiB
C
Raw Normal View History

2024-12-04 10:31:57 +08:00
/***
* @Author: mbw
* @Date: 2024-11-30 15:46:21
* @LastEditors: mbw && 1600520629@qq.com
2024-12-04 18:55:59 +08:00
* @LastEditTime: 2024-12-04 17:06:16
2024-12-04 10:31:57 +08:00
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\inc\bsp_vin_detection.h
* @Description:
* @
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
*/
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
* @LastEditTime : 2024-09-24 11:21:59
* @FilePath : \JT-DT-YD4N02A_RTT_MRS\bsp\inc\bsp_vin_detection.h
* @Description :
*
* Copyright (c) 2024 by yzy, All Rights Reserved.
*/
#ifndef __BSP_VIN_DETECTION_H__
#define __BSP_VIN_DETECTION_H__
#include "board.h"
#if 0
#define VIN_THREAD_STACK_SIZE (1024)
#define VIN_THREAD_PRIORITY (1)
#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
2024-12-04 18:55:59 +08:00
// #define VIN_ADC_HIGH_THRESHOLD (uint16_t)3723 // 13V
#define VIN_ADC_HIGH_THRESHOLD (uint16_t)4095 //
2024-12-01 13:49:43 +08:00
// (4.7/19.7) * 10V = 2.39V, 2.39/3.3*4096 = 2966
2024-12-04 18:55:59 +08:00
#define VIN_ADC_LOW_THRESHOLD (uint16_t)2369 // 9V
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__