add more files

This commit is contained in:
wmano
2025-08-30 23:48:55 +08:00
parent e26e47548f
commit 050eb19fc8
33 changed files with 820 additions and 479 deletions
+16
View File
@@ -0,0 +1,16 @@
from building import *
import os
cwd = GetCurrentDir()
src = Glob('*.c')
path = [cwd]
group = DefineGroup('Applications/utils', src, depend = [''], CPPPATH = path)
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))
Return('group')
@@ -0,0 +1,4 @@
#include "chrg_pcf8574.h"
@@ -0,0 +1,7 @@
#ifndef __CHRG_PCF8574_H__
#define __CHRG_PCF8574_H__
#endif
+4
View File
@@ -0,0 +1,4 @@
#include "chrg_sink.h"
+37
View File
@@ -0,0 +1,37 @@
#ifndef __CHRG_SINK_H__
#define __CHRG_SINK_H__
#include <rtthread.h>
#define SINK_ID 0x01
#define SINK_REG_GET_VOLTAGE 0x20 // 读取变电压板电压
#define SINK_REG_GET_PD 0x13 // 读取源端的PD协议数据
#define SINK_REG_SET_CC 0x17 // 设置CC线
#define SINK_REG_SET_LEVEL 0x16 // 设置CC线电平
// 设置快充协议
#define SINK_REG_SET_QC2 0xF8 // QC2.0
#define SINK_REG_SET_QC3 0xF6 // QC3.0
#define SINK_REG_SET_FCP 0xF2 // FCP
#define SINK_REG_SET_AFC 0xF9 // AFC
#define SINK_REG_SET_SCP 0xF3 // SCP
#define SINK_REG_SET_VIVO 0xFD // VIVO
#define SINK_REG_SET_TFC 0xF7 // TFC 传音
#define SINK_REG_SET_PD0 0xFB // PD0 手动/自动
#define SINK_REG_SET_PPS 0xFC // PPS 手动/自动
#define SINK_REG_SET_PD3P1 0xE1 // PD3.1
#define SINK_REG_SET_UFCS 0xE0 // UFCS
#define SINK_REG_SET_VOOC 0xE2 // VOOC
#define SINK_REG_SET_AVS 0xE3 // AVS
struct chrg_sink_t {
rt_uint8_t type;
};
#endif
@@ -0,0 +1,4 @@
#include "chrg_source.h"
@@ -0,0 +1,7 @@
#ifndef __CHRG_SOURCE_H__
#define __CHRG_SOURCE_H__
#endif
+43
View File
@@ -0,0 +1,43 @@
#include <rtthread.h>
#include "chrg_utils.h"
rt_uint8_t _crc8 (rt_uint8_t res, rt_uint8_t data)
{
rt_uint8_t i = 0, t = 0;
for (i = 0; i < 8; i++) {
t = data^res;
if ((t & 0x01) == 0x01) {
res = res^0x18;
res >>= 1;
res |= 0x80;
} else {
res >>= 1;
}
data >>= 1;
}
return res;
}
rt_uint8_t calc_crc8 (rt_uint8_t *data, rt_uint8_t length)
{
rt_uint8_t i = 0, res = 0x55;
for (i = 0; i < length; i++) {
res = _crc8(res, data[i]);
}
return res;
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef __CHRG_UTILS_H__
#define __CHRG_UTILS_H__
#include <rtthread.h>
extern rt_uint8_t calc_crc8 (rt_uint8_t *data, rt_uint8_t length);
#endif