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 0x08 |
| #define | SMB_STATE_REP_START 0x10 |
| #define | SMB_STATE_MT_SLAVE_ACK 0x18 |
| #define | SMB_STATE_MT_SLAVE_NACK 0x20 |
| #define | SMB_STATE_MT_DATA_ACK 0x28 |
| #define | SMB_STATE_MT_DATA_NACK 0x30 |
| #define | SMB_STATE_MR_SLAVE_ACK 0x40 |
| #define | SMB_STATE_MR_SLAVE_NACK 0x48 |
| #define | SMB_STATE_MR_DATA_ACK 0x50 |
| #define | SMB_STATE_MR_DATA_NACK 0x58 |
Functions | |
| void | SMBus_Init (unsigned char force) |
| void | SMBus_EnableACKPoll (void) |
| void | SMBus_SetSlaveAddr (unsigned char slaveAddr) |
| void | SMBus_SetTXBuffer (const 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 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 0x50 |
| #define SMB_STATE_MR_DATA_NACK 0x58 |
| #define SMB_STATE_MR_SLAVE_ACK 0x40 |
| #define SMB_STATE_MR_SLAVE_NACK 0x48 |
| #define SMB_STATE_MT_DATA_ACK 0x28 |
| #define SMB_STATE_MT_DATA_NACK 0x30 |
| #define SMB_STATE_MT_SLAVE_ACK 0x18 |
| #define SMB_STATE_MT_SLAVE_NACK 0x20 |
| #define SMB_STATE_REP_START 0x10 |
| #define SMB_STATE_START 0x08 |
| #define SMB_WRITE 0x00 |
| 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 | ( | unsigned char | force | ) |
Initializing the SMBus
00107 { 00108 static char init = 0; 00109 00110 if(!init || force) { 00111 init = 1; 00112 00113 // Configuring the Timer3 Registers 00114 SFRPAGE = TMR3_PAGE; 00115 TMR3CN = 0x00; // Turn Clock off 00116 TMR3CF = 0x00; // SYSCLK / 12 00117 00118 RCAP3L = 0x00; /* TIMER 3 CAPTURE/RELOAD LOW BYTE */ 00119 RCAP3H = 0x00; /* TIMER 3 CAPTURE/RELOAD HIGH BYTE */ 00120 00121 TMR3L = 0x00; //Timer3 Low Bytes 00122 TMR3H = 0x00; //Timer3 High Bytes 00123 00124 TMR3CN = 0x04; // Enable Timer3 00125 00126 SFRPAGE = SMB0_PAGE; 00127 SMB0CN = 0x43; 00128 EIP1 |= 0x02; // SMB High priority 00129 EIE1 |= 0x02; // Enable SMBus interrupts 00130 EIE2 |= 0x01; // Enable Timer3 interrupts 00131 EA = 1; // Enable Global interrupts 00132 SMBus_Clear(); 00133 00134 } 00135 }
| void SMBus_SetRXBuffer | ( | unsigned char * | pData, | |
| unsigned char | dataLen | |||
| ) |
| void SMBus_SetSlaveAddr | ( | unsigned char | slaveAddr | ) |
| void SMBus_SetTXBuffer | ( | const unsigned char * | pData, | |
| unsigned char | dataLen | |||
| ) |
00049 { 00050 unsigned char i; 00051 00052 for(i = 0; (i < dataLen) && (i < SMB_MAX_BUFF_SIZE); ++i) { 00053 SMB_DATA_OUT[i] = pData[i]; 00054 } 00055 00056 SMB_DATA_OUT_LEN = i; 00057 }
| 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