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.

71 lines
2.5 KiB

4 years ago
//////////////////////////////////////////////////////////////////////////
/// COPYRIGHT NOTICE
/// Copyright (c) 2018, 传控科技
4 years ago
/// All rights reserved.
///
/// @file iic_sim
/// @brief iic 模拟io 版本, 和cpu无关,唯一需要修改的就是头函数中的管脚定义
/// @info 除了io配置 ,其他地方如无必要请勿修改
///(本文件实现的功能的详述)
4 years ago
///
/// @version 1.1 CCsens technology
/// @author CC
/// @date 20180102
//
//////////////////////////////////////////////////////////////////////////
#ifndef _IIC_SIM_H_
#define _IIC_SIM_H_
#include "../clib/type.h"
#include "../clib/clib.h"
#include "../ctask/tick.h"
///>>>端口位定义,可修改!!!!!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
4 years ago
#include "../cpu/stc_stc8a8k.h"
#include "../cpu/c51_macro.h"
4 years ago
//根据sch的定义
#define L0_IIC_SIM_INIT() BITN_0(P3M1,3);BITN_0(P3M0,3);\
BITN_0(P3M1,2);BITN_0(P3M0,2);
///stc独有10 高阻
#define L0_IIC_SIM_close() BITN_1(P3M1,3);BITN_0(P3M0,3);\
BITN_1(P3M1,2);BITN_0(P3M0,2);
4 years ago
#define L0_SDA_ON() D_P33_ON()
#define L0_SDA_OFF() D_P33_OFF()
#define L0_SDA_AT() D_P33_AT()
#define L0_SCL_ON() D_P32_ON()
#define L0_SCL_OFF() D_P32_OFF()
4 years ago
#if 0
//// for stc 11.0M
#define delay10us() NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();///Lc_delay_us(1) //根据cpu的速率进行相应的调整
4 years ago
#define L0_I2C_delay(x) NOP();NOP();///Lc_delay_us(x)
#else
///#define delay10us() NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();///Lc_delay_us(1) //根据cpu的速率进行相应的调整
4 years ago
///#define L0_I2C_delay(x) NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();///Lc_delay_us(x)
#define delay10us() Lc_delay_us(3000) //根据cpu的速率进行相应的调整
#define L0_I2C_delay(x) Lc_delay_us(10000)
4 years ago
#endif
//<<<<端口位定义,可修改!!!!!!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
4 years ago
extern void L2_I2C_ReadReg(unsigned char sla,unsigned char reg,unsigned char *r,unsigned char n);
extern void L2_I2C_WriteCmd(unsigned char sla,unsigned char reg,unsigned char cmd);
extern void L0_I2C_INIT(unsigned char v);
extern void L2_tws_ReadReg(unsigned char sla,unsigned char reg,
unsigned char *v);
4 years ago
#endif// #ifndef _IIC_H_