Subversion Repositories Code-Repo

Rev

Rev 222 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 222 Rev 223
Line 53... Line 53...
53
    SSP1CON3bits.SCIE = 1;  // Start condition interrupt enable
53
    SSP1CON3bits.SCIE = 1;  // Start condition interrupt enable
54
    SSP1CON1bits.SSPEN = 1; // Enable MSSP Module
54
    SSP1CON1bits.SSPEN = 1; // Enable MSSP Module
55
}
55
}
56
 
56
 
57
// Sends length number of bytes in msg to specified address (no R/W bit)
57
// Sends length number of bytes in msg to specified address (no R/W bit)
58
void I2C_Master_Send(char address, char length, char *msg) {
58
void I2C_Master_Send(char address, char *msg, char length) {
59
    char i;
59
    char i;
60
    if (length == 0)
60
    if (length == 0)
61
        return;
61
        return;
62
 
62
 
63
    // Copy message to send into buffer and save length/address
63
    // Copy message to send into buffer and save length/address
Line 99... Line 99...
99
// Writes msg to address then reads length number of bytes from address
99
// Writes msg to address then reads length number of bytes from address
100
void I2C_Master_Restart(char address, char msg, char length) {
100
void I2C_Master_Restart(char address, char msg, char length) {
101
    char c;
101
    char c;
102
    if (length == 0) {
102
    if (length == 0) {
103
        c = msg;
103
        c = msg;
104
        I2C_Master_Send(address, 1, &c);
104
        I2C_Master_Send(address, &c, 1);
105
        return;
105
        return;
106
    }
106
    }
107
 
107
 
108
    // Save length and address to get data from
108
    // Save length and address to get data from
109
    data_ptr->buffer_in[0] = msg;
109
    data_ptr->buffer_in[0] = msg;