#include "stc12c5a60s2.h" #include "ch375hf5.h"
typedef unsigned char u8; typedef unsigned int u16;
#define UINT8 u8 #define UINT16 u16
void Delay_ms(u16 z) // { u16 x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); }
void Uart1_Init(void) // { AUXR = 0x11; SCON = 0X50; BRT = 0XFD; PCON &= 0X7F; ES = 0; EA = 0; }
void Uart2_Init(void) // { S2CON = 0XD0; BRT = 0XFD; IE2&=0xFE; EA = 0; }
void Send_Byte(u8 cmd) // { SBUF=cmd; while(!TI); TI=0; }
void Send_String(u8 *pbuf) { while(*pbuf !='\0') { Send_Byte(*pbuf++); } }
void xWriteCH375Cmd( UINT8 mCmd ) // { S2CON |=0x08; S2BUF = mCmd; while (( S2CON&0x02) == 0 ); S2CON &=0xFD; }
void xWriteCH375Data( UINT8 mData )// { S2CON &=0xF7; S2BUF = mData; while (( S2CON&0x02) == 0 ); S2CON &=0xFD; }
UINT8 xReadCH375Data( void ) // { while ( (S2CON&0x01) == 0); S2CON&=0xFE; return( S2BUF ); }
void main(void) { u8 i=1; Uart1_Init(); Uart2_Init(); Delay_ms(100); Send_String("准备初始化"); i=CH375LibInit(); if(i == 0) Send_String("初始化成功"); else Send_String("初始化失败"); for(;;) { ; } } 一直卡在初始化那里,CH375Hf5.h和CH375Hf5.lib都添加了 疑问,库函数怎么知道我使用的是串行方式