Subversion Repositories Code-Repo

Rev

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

Rev 202 Rev 222
Line 186... Line 186...
186
            case I2C_IDLE:
186
            case I2C_IDLE:
187
                break;
187
                break;
188
            case I2C_SEND_ADDR:
188
            case I2C_SEND_ADDR:
189
                // Send address with write bit set
189
                // Send address with write bit set
190
                data_ptr->operating_state = I2C_CHECK_ACK_RECV;
190
                data_ptr->operating_state = I2C_CHECK_ACK_RECV;
191
                SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x1;
191
                char tmp = (data_ptr->master_dest_addr << 1);
-
 
192
                tmp |= 0x1;
-
 
193
                SSP1BUF = tmp;
192
                break;
194
                break;
193
            case I2C_CHECK_ACK_RECV:
195
            case I2C_CHECK_ACK_RECV:
194
                // Check if ACK is received
196
                // Check if ACK is received
195
                if (!SSP1CON2bits.ACKSTAT) {
197
                if (!SSP1CON2bits.ACKSTAT) {
196
                    // If an ACK is received, set module to receive 1 byte of data
198
                    // If an ACK is received, set module to receive 1 byte of data
Line 237... Line 239...
237
    } else if (data_ptr->master_status == I2C_MASTER_RESTART) {
239
    } else if (data_ptr->master_status == I2C_MASTER_RESTART) {
238
        switch (data_ptr->operating_state) {
240
        switch (data_ptr->operating_state) {
239
            case I2C_IDLE:
241
            case I2C_IDLE:
240
                break;
242
                break;
241
            case I2C_SEND_ADDR:
243
            case I2C_SEND_ADDR:
242
                // Send the address with read bit set
244
                // Send the address with write bit set
243
                data_ptr->operating_state = I2C_CHECK_ACK_SEND;
245
                data_ptr->operating_state = I2C_CHECK_ACK_SEND;
244
                SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x0;
246
                SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x0;
245
                break;
247
                break;
246
            case I2C_CHECK_ACK_SEND:
248
            case I2C_CHECK_ACK_SEND:
247
                // Check if ACK is received or not
249
                // Check if ACK is received or not
Line 270... Line 272...
270
                }
272
                }
271
                break;
273
                break;
272
            case I2C_SEND_ADDR_2:
274
            case I2C_SEND_ADDR_2:
273
                // Send the address with read bit set
275
                // Send the address with read bit set
274
                data_ptr->operating_state = I2C_CHECK_ACK_RECV;
276
                data_ptr->operating_state = I2C_CHECK_ACK_RECV;
275
                SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x1;
277
                char tmp = (data_ptr->master_dest_addr << 1);
-
 
278
                tmp |= 0x1;
-
 
279
                SSP1BUF = tmp;
276
                break;
280
                break;
277
            case I2C_CHECK_ACK_RECV:
281
            case I2C_CHECK_ACK_RECV:
278
                // Check if ACK is received
282
                // Check if ACK is received
279
                if (!SSP1CON2bits.ACKSTAT) {
283
                if (!SSP1CON2bits.ACKSTAT) {
280
                    // If an ACK is received, set module to receive 1 byte of data
284
                    // If an ACK is received, set module to receive 1 byte of data