generated from hulk/gd32e23x_template_cmake_vscode
delete unuse file
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief 传感器周期上报使能标志 */
|
||||
extern volatile bool g_sensor_report_enabled;
|
||||
|
||||
/**
|
||||
* @section Command_Protocol 协议格式
|
||||
* 接收命令帧格式:
|
||||
|
101
Inc/ldc1612.h
101
Inc/ldc1612.h
@@ -1,101 +0,0 @@
|
||||
//
|
||||
// Created by dell on 24-12-3.
|
||||
//
|
||||
|
||||
#ifndef LDC1612_H
|
||||
#define LDC1612_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "board_config.h"
|
||||
#include "soft_i2c.h"
|
||||
#include "i2c.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define LDC1612_ADDR 0x2B
|
||||
|
||||
/*Register Rddr*/
|
||||
/***************************************************************************/
|
||||
|
||||
#define CONVERTION_RESULT_REG_START 0X00
|
||||
#define SET_CONVERSION_TIME_REG_START 0X08
|
||||
#define SET_CONVERSION_OFFSET_REG_START 0X0C
|
||||
#define SET_LC_STABILIZE_REG_START 0X10
|
||||
#define SET_FREQ_REG_START 0X14
|
||||
|
||||
#define SENSOR_STATUS_REG 0X18
|
||||
#define ERROR_CONFIG_REG 0X19
|
||||
#define SENSOR_CONFIG_REG 0X1A
|
||||
#define MUL_CONFIG_REG 0X1B
|
||||
#define SENSOR_RESET_REG 0X1C
|
||||
#define SET_DRIVER_CURRENT_REG 0X1E
|
||||
|
||||
#define READ_MANUFACTURER_ID 0X7E
|
||||
#define READ_DEVICE_ID 0X7F
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define CHANNEL_0 0
|
||||
#define CHANNEL_1 1
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define LDC1612_CONVERSION_TIME_CH0 0x0546 //0536
|
||||
#define LDC1612_DRIVE_CURRENT 0x9000 //A000
|
||||
#define LDC1612_MUX_CONFIG 0x020C // no auto scan and filter bandwidth 3.3MHz
|
||||
#define LDC1612_SENSOR_CONFIG 0x1601
|
||||
#define LDC1612_SLEEP_MODE 0x2801
|
||||
#define LDC1612_ERROR_CONFIG 0x0000
|
||||
#define LC_STABILIZE_TIME_CH0 0x001E //30
|
||||
#define LDC1612_RESET_DEV 0x8000 //[15:0] 0b1000 0000 0000 0000
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define COIL_RP_KOM 7.2
|
||||
#define COIL_L_UH 33
|
||||
#define COIL_C_PF 150
|
||||
#define COIL_Q_FACTOR 35.97
|
||||
#define COIL_FREQ_HZ 2262000
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void ldc1612_set_conversion_time(uint8_t channel, uint16_t result);
|
||||
|
||||
void ldc1612_set_conversion_offset(uint8_t channel, uint16_t result);
|
||||
|
||||
void ldc1612_set_LC_stabilize_time(uint8_t channel, uint16_t result);
|
||||
|
||||
void ldc1612_set_freq_divide(uint8_t channel);
|
||||
|
||||
void ldc1612_set_error_config(uint16_t value);
|
||||
|
||||
void ldc1612_set_mux_config(uint16_t value);
|
||||
|
||||
void ldc1612_reset_sensor(void);
|
||||
|
||||
void ldc1612_set_drive_current(uint8_t channel, uint16_t value);
|
||||
|
||||
void ldc1612_set_sensor_config(uint16_t value);
|
||||
|
||||
void ldc1612_single_ch0_config(void);
|
||||
|
||||
void ldc1612_iic_get_sensor_infomation(void);
|
||||
|
||||
uint16_t ldc1612_get_manufacturer_id(void);
|
||||
|
||||
uint16_t ldc1612_get_deveice_id(void);
|
||||
|
||||
uint32_t ldc1612_get_raw_channel_result(uint8_t channel);
|
||||
|
||||
uint32_t ldc1612_parse_raw_result(uint32_t raw_result);
|
||||
|
||||
void ldc1612_drvie_current_detect(uint8_t channel);
|
||||
|
||||
#endif //LDC1612_H
|
155
Inc/tmp112.h
155
Inc/tmp112.h
@@ -1,155 +0,0 @@
|
||||
//
|
||||
// Created by dell on 24-12-20.
|
||||
// TMP112A Temperature Sensor Driver Header
|
||||
//
|
||||
|
||||
#ifndef TMP112_H
|
||||
#define TMP112_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "board_config.h"
|
||||
#include "i2c.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* TMP112A I2C Address */
|
||||
#define TMP112A_ADDR (0x48) // 7-bit address (ADD0=GND)
|
||||
|
||||
/* Register Addresses */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_TEMP_REG 0x00 // 温度寄存器
|
||||
#define TMP112A_CONFIG_REG 0x01 // 配置寄存器
|
||||
#define TMP112A_TLOW_REG 0x02 // 低温阈值寄存器
|
||||
#define TMP112A_THIGH_REG 0x03 // 高温阈值寄存器
|
||||
|
||||
/* Configuration Register Bits */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_CONFIG_OS (1 << 15) // One-shot
|
||||
#define TMP112A_CONFIG_R1 (1 << 14) // Converter resolution bit 1
|
||||
#define TMP112A_CONFIG_R0 (1 << 13) // Converter resolution bit 0
|
||||
#define TMP112A_CONFIG_F1 (1 << 12) // Fault queue bit 1
|
||||
#define TMP112A_CONFIG_F0 (1 << 11) // Fault queue bit 0
|
||||
#define TMP112A_CONFIG_POL (1 << 10) // Polarity
|
||||
#define TMP112A_CONFIG_TM (1 << 9) // Thermostat mode
|
||||
#define TMP112A_CONFIG_SD (1 << 8) // Shutdown
|
||||
#define TMP112A_CONFIG_CR1 (1 << 7) // Conversion rate bit 1
|
||||
#define TMP112A_CONFIG_CR0 (1 << 6) // Conversion rate bit 0
|
||||
#define TMP112A_CONFIG_AL (1 << 5) // Alert
|
||||
#define TMP112A_CONFIG_EM (1 << 4) // Extended mode
|
||||
|
||||
/* Resolution Settings */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_RESOLUTION_9BIT 0x0000 // 9-bit (0.5°C)
|
||||
#define TMP112A_RESOLUTION_10BIT 0x2000 // 10-bit (0.25°C)
|
||||
#define TMP112A_RESOLUTION_11BIT 0x4000 // 11-bit (0.125°C)
|
||||
#define TMP112A_RESOLUTION_12BIT 0x6000 // 12-bit (0.0625°C)
|
||||
|
||||
/* Conversion Rate Settings */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_RATE_0_25HZ 0x0000 // 0.25 Hz (4s)
|
||||
#define TMP112A_RATE_1HZ 0x0040 // 1 Hz (1s)
|
||||
#define TMP112A_RATE_4HZ 0x0080 // 4 Hz (250ms)
|
||||
#define TMP112A_RATE_8HZ 0x00C0 // 8 Hz (125ms)
|
||||
|
||||
/* Default Configuration */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_CONFIG_DEFAULT (TMP112A_RESOLUTION_12BIT | TMP112A_RATE_4HZ)
|
||||
|
||||
/* Temperature Conversion Constants */
|
||||
/******************************************************************************/
|
||||
#define TMP112A_TEMP_RESOLUTION 0.0625f // 12-bit resolution (°C/LSB)
|
||||
#define TMP112A_TEMP_MIN -55.0f // 最低温度 (°C)
|
||||
#define TMP112A_TEMP_MAX 125.0f // 最高温度 (°C)
|
||||
|
||||
/* Status Definitions */
|
||||
/******************************************************************************/
|
||||
typedef enum {
|
||||
TMP112A_STATUS_SUCCESS = 0,
|
||||
TMP112A_STATUS_ERROR,
|
||||
TMP112A_STATUS_TIMEOUT,
|
||||
TMP112A_STATUS_INVALID_PARAM,
|
||||
TMP112A_STATUS_OUT_OF_RANGE
|
||||
} tmp112a_status_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t raw_data;
|
||||
float temperature_c;
|
||||
float temperature_f;
|
||||
bool alert_flag;
|
||||
} tmp112a_result_t;
|
||||
|
||||
/******************************************************************************/
|
||||
/* Function Declarations */
|
||||
|
||||
/*!
|
||||
\brief 初始化TMP112A传感器
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_init(void);
|
||||
|
||||
/*!
|
||||
\brief 配置TMP112A传感器
|
||||
\param[in] config: 配置值
|
||||
\param[out] none
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_config(uint16_t config);
|
||||
|
||||
/*!
|
||||
\brief 读取温度
|
||||
\param[in] none
|
||||
\param[out] result: 结果结构体指针
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_read_temperature(tmp112a_result_t *result);
|
||||
|
||||
/*!
|
||||
\brief 设置温度阈值
|
||||
\param[in] low_temp: 低温阈值 (°C)
|
||||
\param[in] high_temp: 高温阈值 (°C)
|
||||
\param[out] none
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_set_thresholds(float low_temp, float high_temp);
|
||||
|
||||
/*!
|
||||
\brief 进入关机模式
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_shutdown(void);
|
||||
|
||||
/*!
|
||||
\brief 退出关机模式
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_wakeup(void);
|
||||
|
||||
/*!
|
||||
\brief 单次转换
|
||||
\param[in] none
|
||||
\param[out] result: 结果结构体指针
|
||||
\retval tmp112a_status_t
|
||||
*/
|
||||
tmp112a_status_t tmp112a_one_shot(tmp112a_result_t *result);
|
||||
|
||||
/*!
|
||||
\brief 获取状态字符串
|
||||
\param[in] status: 状态码
|
||||
\param[out] none
|
||||
\retval const char* 状态字符串
|
||||
*/
|
||||
const char* tmp112a_get_status_string(tmp112a_status_t status);
|
||||
|
||||
#endif //TMP112_H
|
Reference in New Issue
Block a user