This commit is contained in:
qiyongshuang
2026-01-07 10:43:29 +08:00
parent 6209b6e7f9
commit d161f84c90
551 changed files with 23169 additions and 1518 deletions
@@ -1,9 +1,9 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : CH223.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/08/15
* Description : CH223оƬ²Ù×÷Ïà¹ØÎļþ
* Version : V1.0.1
* Date : 2025/10/27
* Description : This file provides all the CH223 functions
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -36,7 +36,6 @@ void IIC_Init(u32 bound, u16 address)
I2C_InitTypeDef I2C_InitTSturcture={0};
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE );
// GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_I2C2, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
@@ -59,6 +58,7 @@ void IIC_Init(u32 bound, u16 address)
I2C_Cmd( I2C2, ENABLE );
}
/*********************************************************************
* @fn CH223_Init
*
@@ -192,6 +192,7 @@ void CH223_Read(u16 ReadAddr, u32 *pBuffer, u16 NumToRead)
NumToRead--;
}
}
/*********************************************************************
* @fn CH223_Write
*
@@ -214,7 +215,6 @@ void CH223_Write(u16 WriteAddr, u8 *pBuffer, u16 NumToWrite)
}
}
/*********************************************************************
* @fn Buffer_Change
*
@@ -255,6 +255,7 @@ void Buffer_Change(u32 buffer[], int n)
}
}
}
/*********************************************************************
* @fn Current_VI
*
@@ -275,8 +276,9 @@ void Current_VI(u8 ndo_select)
tempI = BufferI[ndo_select] % 10;
current[1] = BufferI[ndo_select] / 10;
printf("The current regulating voltage is£º%d.%dV,%d.%dA\t\r\n", current[0], tempV, current[1], tempI);
printf("The current regulating voltage is: %d.%dV,%d.%dA\t\r\n", current[0], tempV, current[1], tempI);
}
/*********************************************************************
* @fn User_Set_VI
*
@@ -287,7 +289,6 @@ void Current_VI(u8 ndo_select)
*
* @return none
*/
void User_Set_VI(u8 TargetData)
{
u8 ndo_select = 0, state_flag = 0;
@@ -19,10 +19,10 @@ CH223 chip application routine
#include "debug.h"
#include"CH223.h"
u8 ndo = 0;//Number of NDOs in SrcCap
u8 IT_flag = 0;
u8 rst_IT = 0, cc_IT = 0, srccap_IT = 0, ps_IT = 0;//Interrupt flag
s16 Calibrattion_Val = 0;
vu8 ndo = 0;//Number of NDOs in SrcCap
vu8 IT_flag = 0;
vu8 rst_IT = 0, cc_IT = 0, srccap_IT = 0, ps_IT = 0;//Interrupt flag
vs16 Calibrattion_Val = 0;
u16 TxBuf[1024];
/*********************************************************************
@@ -150,7 +150,7 @@ void DMA_Tx_Init(DMA_Channel_TypeDef *DMA_CHx, u32 ppadr, u32 memadr, u16 bufsiz
*/
u16 Get_ConversionVal(s16 val)
{
if((val + Calibrattion_Val) < 0)
if((val + Calibrattion_Val) < 0 || val==0)
return 0;
if((Calibrattion_Val + val) > 4095||val==4095)
return 4095;
@@ -242,12 +242,12 @@ int main(void)
CH223_Init();
ADC_Function_Init();
EXTI0_INT_INIT();
printf("PD_CH223 Demo£¡\r\n");
printf("PD_CH223 Demo!!\r\n");
printf("\r\n");
IT_flag = CH223_ReadOneByte(0xB4);
if (IT_flag==0x0c)
{
printf("power-on reset£¡£¡£¡\r\n");
printf("power-on reset!!!!\r\n");
printf("\r\n");
Delay_Ms(10);
printf("CC Connecting...\r\n");
@@ -258,14 +258,14 @@ int main(void)
Delay_Ms(1);
while(ps_IT) //PS_RDY -->The power supply reaches the required working state
{
CH223_WriteOneByte(0xB6, 0x19); //The initial voltage is set to 9V£º0x2D
CH223_WriteOneByte(0xB6, 0x19); //The initial voltage is set to 9V:0x2D
res = CH223_ReadOneByte(0xB6);
printf("The initial voltage is set to£º%dV\r\n",res*200/1000);
printf("The initial voltage is set to:%dV\r\n",res*200/1000);
printf("\r\n");
Delay_Ms(300);
if (rst_IT == 1)
{
printf("power-on reset£¡£¡£¡\r\n");
printf("power-on reset!!!!\r\n");
printf("\r\n");
}
if (cc_IT == 1)
@@ -281,7 +281,7 @@ int main(void)
Buffer_Change(Buffer, ndo);
if (srccap_IT == 1) //Display SRCCAP message
{
printf("Received SrcCap,NDO data is£º\n");
printf("Received SrcCap,NDO data is:\n");
printf("\r\n");
for(n = 0; n < ndo; n++)
{
@@ -4,7 +4,7 @@
* Version : V1.0.0
* Date : 2021/06/06
* Description : CH32V20x Device Peripheral Access Layer System Source File.
* For HSE = 32Mhz (CH32V208x/CH32V203RBT6)
* For HSE = 32Mhz (CH32V208x/CH32V203RBT)
* For HSE = 8Mhz (other CH32V203x)
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.