Defines | |
| #define | SMB_WRITE 0x00 |
| #define | SMB_READ 0x01 |
| #define | SMB_ENABLE_ACKPOLL 0x01 |
| #define | SMB_DISABLE_ACKPOLL 0x00 |
| #define | SMB_MAX_BUFF_SIZE 8 |
| #define | SMB_MTSTA 0xE0 |
| #define | SMB_MTDB 0xC0 |
| #define | SMB_MRDB 0x80 |
| #define | SMB_STATE_START 0xE0 |
| #define | SMB_STATE_MT_ACK 0xC2 |
| #define | SMB_STATE_MT_NACK 0xC0 |
| #define | SMB_STATE_MR_DATA_ACK 0x88 |
| #define | SMB_STATE_SR_ADDR_ACK 0x2C |
| #define | SMB_STATE_ST_DATA_NACK 0x40 |
| #define | MASTER_LOST_ARBIT 0x2C |
| #define | REP_START_LOST_ARBIT 0x24 |
| #define | STOP_LOST_ARBIT 0x14 |
| #define | MT_LOST_ARBIT 0x0C |
Functions | |
| void | SMBus_Init (void) |
| void | SMBus_EnableACKPoll (void) |
| void | SMBus_SetSlaveAddr (unsigned char slaveAddr) |
| void | SMBus_SetTXBuffer (unsigned char *pData, unsigned char dataLen) |
| void | SMBus_SetRXBuffer (unsigned char *pData, unsigned char dataLen) |
| void | SMBus_Wait (void) |
| void | SMBus_Start (void) |
| void | SMBus_Clear (void) |
| #define MASTER_LOST_ARBIT 0x2C |
| #define MT_LOST_ARBIT 0x0C |
| #define REP_START_LOST_ARBIT 0x24 |
| #define SMB_DISABLE_ACKPOLL 0x00 |
| #define SMB_ENABLE_ACKPOLL 0x01 |
| #define SMB_MAX_BUFF_SIZE 8 |
| #define SMB_MRDB 0x80 |
| #define SMB_MTDB 0xC0 |
| #define SMB_MTSTA 0xE0 |
| #define SMB_READ 0x01 |
| #define SMB_STATE_MR_DATA_ACK 0x88 |
| #define SMB_STATE_MT_ACK 0xC2 |
| #define SMB_STATE_MT_NACK 0xC0 |
| #define SMB_STATE_SR_ADDR_ACK 0x2C |
| #define SMB_STATE_ST_DATA_NACK 0x40 |
| #define SMB_STATE_START 0xE0 |
| #define SMB_WRITE 0x00 |
| #define STOP_LOST_ARBIT 0x14 |
| void SMBus_Clear | ( | void | ) |
00066 { 00067 pSMB_DATA_IN = 0; 00068 SMB_DATA_IN_LEN = 0; 00069 SMB_DATA_OUT_LEN = 0; 00070 SMB_BUSY = 0; 00071 SMB_ACKPOLL = SMB_DISABLE_ACKPOLL; 00072 }
| void SMBus_EnableACKPoll | ( | void | ) |
| void SMBus_Init | ( | void | ) |
Initializing the SMBus
00097 { 00098 static char init = 0; 00099 00100 if(!init) { 00101 init = 1; 00102 00103 // Configuring the Timer3 Registers 00104 TMR3CN = 0x00; // Turn Clock off and SYSCLK / 12 00105 00106 TMR3RLL = 0x00; /* TIMER 3 RELOAD LOW BYTE */ 00107 TMR3RLH = 0x00; /* TIMER 3 RELOAD HIGH BYTE */ 00108 TMR3L = 0x00; //Timer3 Low Bytes 00109 TMR3H = 0x00; //Timer3 High Bytes 00110 TMR3CN = 0x04; // Enable Timer3 00111 00112 SMB0CF = 0x5D; // SMbus Setup Hold Extension/Timeout Detection/Free Timeout Detection Enable 00113 // Timer1 Overflow is set as the clock source 00114 SMB0CF |= 0x80; // Enable SMBus after all setting done. 00115 00116 00117 EIE1 |= 0x81; // Enable SMBus interrupts/Enable Timer3 interrupts 00118 EA = 1; // Enable Global interrupts 00119 00120 SMBus_Clear(); 00121 } 00122 }
| void SMBus_SetRXBuffer | ( | unsigned char * | pData, | |
| unsigned char | dataLen | |||
| ) |
| void SMBus_SetSlaveAddr | ( | unsigned char | slaveAddr | ) |
| void SMBus_SetTXBuffer | ( | unsigned char * | pData, | |
| unsigned char | dataLen | |||
| ) |
00041 { 00042 unsigned char i; 00043 00044 for(i = 0; (i < dataLen) && (i < SMB_MAX_BUFF_SIZE); ++i) { 00045 SMB_DATA_OUT[i] = pData[i]; 00046 } 00047 00048 SMB_DATA_OUT_LEN = i; 00049 }
| void SMBus_Start | ( | void | ) |
00076 { 00077 if(SMB_DATA_OUT_LEN > 0) { 00078 SMB_RW = SMB_WRITE; 00079 } else if(SMB_DATA_IN_LEN > 0) { 00080 SMB_RW = SMB_READ; 00081 } else { 00082 return; 00083 } 00084 00085 SMB_BUSY = 1; 00086 STA = 1; 00087 00088 SMBus_Wait(); 00089 SMBus_Clear(); 00090 }
| void SMBus_Wait | ( | void | ) |
1.4.7