/********************************************************************************************************
*
* File : ws_iic_port.h
* Hardware Environment:
* Build Environment : Silicon LABs 3.42.00 / uVision3 V3.80 20100913
* Version :
* By : Su Wei Feng
*
* (c) Copyright 2005-2010, WaveShare
* https://www.waveshare.net
* All Rights Reserved
*
*********************************************************************************************************/
#ifndef _WS_IIC_PORT_H_
#define _WS_IIC_PORT_H_
#define SMB_FREQUENCY 100000 // Target SCL clock rate
// This example supports in 100kHz
void SMBus_Init(void);
void Check_SDA(void);
void SMBus_Write(uint wrDAdr,uchar Data1,uchar Data2,uchar Num);
void SMBus_Read(uint wrDAdr,uchar *Data,uchar Num);
/*Hardware Environment:DVK501 && F320+ EX*/
#if defined(_DVK501_F320_EX_)
void Timer1_Init(void);
void Timer3_Init(void);
void Enb_Interrupt(void);
void SMBus_ISR(void);
void Timer3_ISR(void);
// 16-bit SFR declarations
sfr16 TMR3RL = 0x92; // Timer3 reload registers
sfr16 TMR3 = 0x94; // Timer3 counter registers
sbit SDA = P1^0; // SMBus on P1.0
sbit SCL = P1^1; // and P1.1
void SMBus_Init(void)
{
XBR0 |= 0x07; // Enable SMBus pins
P1MDOUT = 0x00; // All P1 pins open-drain output
P1 = 0xFF;
SMB0CF = 0x5D; // Use Timer1 overflows as SMBus clock source;
// Disable slave mode;
// Enable setup & hold time extensions;
// Enable SMBus Free timeout detect;
// Enable SCL low timeout detect;
SMB0CF |= 0x80; // Enable SMBus
Timer1_Init();
Timer3_Init();
}
void Timer1_Init(void)
{
// Make sure the Timer can produce the appropriate frequency i