#include "C8051F020.h" #include "I2C_Communication.h" #include "Std_Types.h" //defines #define TRUE 1 #define FALSE 0 #define ONE 0x06 #define TWO 0x5B #define THREE 0x4F #define FOUR 0x66 #define FIVE 0x6D #define SIX 0x7D #define SEVEN 0x07 #define EIGHT 0x7F #define NINE 0x5F #define ZERO 0x3F #define DADD 0xD0 #define RADD 0x00 #define NUMOFBYTES 7 #define STARTBYTE 0 //declaration of global variables ----------------------------------- //Functions --------------------------------------------------------- void main(void) { uint8 ucDataArrayT[8] = {10, 10, 10, 7, 10, 10, 10, 0x80}; uint8 ucDataArrayR[8]; uint8 CheckSend = 0; uint8 CheckRecieve = 0; WDTCN = 0xDE; //Watchdog disable (enables debugging) WDTCN = 0xAD; P2MDOUT = 0xFF; //Port2 defined as output P3MDOUT = 0x00; //Port3 defined as input P74OUT = 0xC0; //Port 7 enable XBR2 = 0x40; //Crossbar enable XBR0 = 0x05; //SMBus(P0.2 & P0.3) and Uart(P0.0 & P0.1) enable OSCICN |= 0x03; //set internal oscillator to 16MHz SMB0CR = -80; //SMBus clock set to 62.5kHz EIE1 |= 2; //SMBus interrupt enable EA = 1; //Global interrupt enable while(1){ while(CheckSend == 0){ CheckSend = SendData(DADD, RADD, NUMOFBYTES, STARTBYTE, ucDataArrayT); } while(CheckRecieve == 0){ CheckRecieve = ReadData(DADD, NUMOFBYTES, STARTBYTE, ucDataArrayR); } } }