You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
5.8 KiB
192 lines
5.8 KiB
4 years ago
|
////////////////////////////////////////////////////////////////////////////
|
||
|
///@copyright Copyright (c) 2017, ���ؿƼ� All rights reserved.
|
||
|
///-------------------------------------------------------------------------
|
||
|
/// @file cw63xx.c
|
||
|
/// @brief cw630x driver app
|
||
|
///-------------------------------------------------------------------------
|
||
|
/// @version 1.0
|
||
|
/// @author CC
|
||
|
/// @date 20170122
|
||
|
/// @note cc_AS_stc01
|
||
|
|
||
|
/// @version 1.1
|
||
|
/// @author CC
|
||
|
/// @date 20170619
|
||
|
/// @note for
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
#include "cw63xx.h"
|
||
|
//#include "../debug/debug_drv.h"
|
||
|
#include "../msp/iic_sim.h"
|
||
|
#include "../msp/uart0.h"
|
||
|
//#include "msa300.h"
|
||
|
|
||
|
///-------------------------------------------------------------------------
|
||
|
/// @breif L1_cw63xx_init
|
||
|
/// @param a s_task_PWON
|
||
|
/// @param s "L1_cw63xx_init"
|
||
|
/// @return none
|
||
|
/// @see Test() ���������ο����������صĺ�����������һ�����ӣ�
|
||
|
/// @note (note������Ҫע��������)
|
||
|
///-------------------------------------------------------------------------
|
||
|
#define D_lowPower_warnning 0x02
|
||
|
#define D_lowPower_BAT_FULL 0x08
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/*****************************
|
||
|
|
||
|
if(BITN_G(I2CTXD,BITN1))
|
||
|
|
||
|
CHG_IN������ DCIN �� 5V ��Դ���룬��������粢�����жϣ��Ĵ��� 0x03[5]�� 0 ���� 1��
|
||
|
BAT_FULL���������س����磬������Ϊ 0�����жϣ��Ĵ��� 0x03[4]�� 0 ���� 1��
|
||
|
BAT_OT�����������¶ȹ��ߣ�Ĭ��ֵ 60�����ң������жϲ�ֹͣ���磬�Ĵ��� 0x03[3]�� 0 ����1��
|
||
|
BAT_UT�����������¶ȹ��ͣ�Ĭ��ֵ 0�����ң������жϲ�ֹͣ���磬�Ĵ��� 0x03[2]�� 0 ����1��
|
||
|
LOW_BAT���������ص�ѹ���ڸ澯ֵʱ��Ĭ��Ϊ 3.4V�������жϣ��Ĵ��� 0x03[1]�� 0 ���� 1��
|
||
|
BUTTON���������£��ᴥ��һ���жϣ��Ĵ��� 0x03[0]�� 0 ���� 1
|
||
|
|
||
|
ʵ���У�ȥ�����غ��������� BAT_FULL�жϡ�
|
||
|
|
||
|
***************************/
|
||
|
void L1_cw63xx_sta(void)
|
||
|
{
|
||
|
U8 d;
|
||
|
L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Interrupt,&d,1);
|
||
|
if(BITN_G(d, BITN1))///�յ��͵�ѹ����
|
||
|
{
|
||
|
I2CTXD = 1;
|
||
|
}
|
||
|
|
||
|
if(BITN_G(d, BITN4))///ֻ�г��������ŵ�ѹ��־������
|
||
|
{
|
||
|
I2CTXD = 0;
|
||
|
}
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Interrupt,0);
|
||
|
}
|
||
|
#if 0
|
||
|
void L1_cw63xx_init(void)
|
||
|
{
|
||
|
U8 val = 0;
|
||
|
// LDO1 LDO2 LDO3 LDO4
|
||
|
#if 0
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO1,D_CW63XX_ON|D_CW63XX_3V2); // ����normal ģʽ
|
||
|
Lc_delay_ms(100);// 2000--7s
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO2,D_CW63XX_ON|D_CW63XX_3V2); // ���� LDO1 ������Ϊ1.8v
|
||
|
Lc_delay_ms(100);
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO3,D_CW63XX_ON|D_CW63XX_3V2); // ����normal ģʽ
|
||
|
Lc_delay_ms(100);// 2000--7s
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO4,D_CW63XX_ON|D_CW63XX_3V2); // ���� LDO1 ������Ϊ1.8v
|
||
|
//#else
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC,D_CW63XX_ON|D_CW63XX_2V5); // mcu gsensor
|
||
|
Lc_delay_ms(10);// 2000--7s
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC1,D_CW63XX_ON|D_CW63XX_3V); // uart4 sed ch430 mcu_program
|
||
|
Lc_delay_ms(10);
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_2V5); //uart 4 receive
|
||
|
Lc_delay_ms(10);// 2000--7s
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC3,D_CW63XX_ON|D_CW63XX_2V5); // ���� AS cpu ����2.5v
|
||
|
|
||
|
//L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_1V8); // ���� AS cpu ����2.5v
|
||
|
//Lc_delay_ms(600);
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC3,D_CW63XX_ON|D_CW63XX_2V8); // ���� AS cpu ����2.5v
|
||
|
Lc_delay_ms(10);
|
||
|
|
||
|
#endif
|
||
|
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,0x3F);///150mA CHARGE
|
||
|
///L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,&val,1);
|
||
|
// L0_uart0_uchex(val);
|
||
|
// Lc_delay_ms(10);
|
||
|
//// Lc_delay_ms(10);
|
||
|
//// L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,&val,1);
|
||
|
//// L0_uart0_uc(val);
|
||
|
//// Lc_delay_ms(10);
|
||
|
/******************
|
||
|
while(9)
|
||
|
{
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_2V8); L0_uart0_uc('e');
|
||
|
Lc_delay_ms(30);
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_OFF|D_CW63XX_2V8);
|
||
|
Lc_delay_ms(30);
|
||
|
|
||
|
}
|
||
|
*****************/
|
||
|
|
||
|
///--------------------------------------------------------------------
|
||
|
// L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_LDO1,s_as1.d,4);// press
|
||
|
// L0_uart0_uchex(s_as1.d[0]); L0_uart0_uchex(s_as1.d[1]); L0_uart0_uchex(s_as1.d[2]); L0_uart0_uchex(s_as1.d[3]);
|
||
|
|
||
|
}
|
||
|
|
||
|
void L3_cw63xx_fun(U8 *pPara)
|
||
|
{
|
||
|
*pPara=0;
|
||
|
}
|
||
|
|
||
|
///#else
|
||
|
|
||
|
//// FX CMD R2 R3 4
|
||
|
void L3_cw63xx_fun(U8 *pPara)
|
||
|
{
|
||
|
U8 val = 0;
|
||
|
TS_P_debug *p = pPara;
|
||
|
switch(p->cmd)
|
||
|
{
|
||
|
/**********
|
||
|
case 0:
|
||
|
L1_cw63xx_init();
|
||
|
L0_uart0_uc('C');
|
||
|
L0_uart0_uc(p->R1);
|
||
|
L0_uart0_uc(p->R2);
|
||
|
L0_uart0_uc(p->R3);
|
||
|
break;
|
||
|
***********/
|
||
|
case 1: ////
|
||
|
//// AX CMDR2 R3 R4
|
||
|
/// AD 01 01 03 04 ��ȡreg 01����ֵ
|
||
|
//void L2_I2C_ReadReg(unsigned char sla,unsigned char reg,
|
||
|
// unsigned char *r,unsigned char n)
|
||
|
L2_I2C_ReadReg(D_i2c_addr_cw63xx,p->R2,&val,1);
|
||
|
L0_uart0_uc(val);
|
||
|
break;
|
||
|
|
||
|
|
||
|
case 2: //FD 02 03 04 00
|
||
|
///aD 02 0A 38 00 //vcc1 off
|
||
|
///aD 02 0A B8 00 //vcc1 ON
|
||
|
///FD 02 0B 04 00 B0011_1000
|
||
|
///FD 02 0C 04 00
|
||
|
///FD 02 01 3a 00 100mA����
|
||
|
|
||
|
L0_uart0_uc('W');
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,p->R2,p->R3);
|
||
|
//L0_uart0_uc(pPara[2]);
|
||
|
|
||
|
L0_uart0_uc(p->R2);
|
||
|
L0_uart0_uc(p->R3);
|
||
|
break;
|
||
|
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
L2_I2C_ReadReg(D_i2c_addr_cw63xx,0,s_as.d,4);
|
||
|
L0_uart0_sendArray(s_as.d,4);
|
||
|
L2_I2C_WriteCmd(D_i2c_addr_cw63xx,0x03,0);////�����жϺ���Ҫд�����������ж�
|
||
|
CHG_IN������ DCIN �� 5V ��Դ���룬��������粢�����жϣ��Ĵ��� 0x03[5]�� 0 ���� 1��
|
||
|
BAT_FULL���������س����磬������Ϊ 0�����жϣ��Ĵ��� 0x03[4]�� 0 ���� 1��
|
||
|
BAT_OT�����������¶ȹ��ߣ�Ĭ��ֵ 60�����ң������жϲ�ֹͣ���磬�Ĵ��� 0x03[3]�� 0 ����1��
|
||
|
BAT_UT�����������¶ȹ��ͣ�Ĭ��ֵ 0�����ң������жϲ�ֹͣ���磬�Ĵ��� 0x03[2]�� 0 ����1��
|
||
|
LOW_BAT���������ص�ѹ���ڸ澯ֵʱ��Ĭ��Ϊ 3.4V�������жϣ��Ĵ��� 0x03[1]�� 0 ���� 1��
|
||
|
BUTTON���������£��ᴥ��һ���жϣ��Ĵ��� 0x03[0]�� 0 ���� 1
|
||
|
|
||
|
ʵ���У�ȥ�����غ��������� BAT_FULL�жϡ�
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|