#include "twi_basics.h"#include <util/twi.h>Go to the source code of this file.
Defines | |
| #define | TW_CONF_MASK ((1<<TWWC) | (1<<TWEN) | (1<<TWIE) | (1<<1) ) |
| #define | TW_SEND_CMD(cmd) TWCR = (TWCR & TW_CONF_MASK ) | (cmd) |
| sends command leaving CONF bits unchanged | |
Functions | |
| void | wait () |
| twi_status | twi_start () |
| twi_status | twi_send (uint8_t data) |
| twi_status | twi_receive (uint8_t *where, uint8_t ack) |
| void | twi_stop () |
Definition in file twi_basics.c.
| #define TW_CONF_MASK ((1<<TWWC) | (1<<TWEN) | (1<<TWIE) | (1<<1) ) |
those bits should be unchanged while writing commands to TWCR, so we will simple write (TCWR & TW_CONF_MASK) | Command
Definition at line 12 of file twi_basics.c.
| twi_status twi_receive | ( | uint8_t * | where, | |
| uint8_t | ack | |||
| ) |
Receive one byte over TWI interface
| where | Pointer to location where received data we'll be stored | |
| ack | Set to nonzero to send ACK after receiving. Usually it continues transfer. |
Definition at line 54 of file twi_basics.c.
References TW_SEND_CMD, and wait().
Referenced by ds1338_readBufferFromNVRAM(), and ds1338_readByteFromNVRAM().
| twi_status twi_send | ( | uint8_t | data | ) |
Sends one byte over TWI interface
| data | Data to be send |
Definition at line 40 of file twi_basics.c.
References TW_SEND_CMD, and wait().
Referenced by ds1338_writeBufferToNVRAM(), and ds1338_writeByteToNVRAM().
| twi_status twi_start | ( | ) |
Sends start condition
Definition at line 28 of file twi_basics.c.
References TW_SEND_CMD, and wait().
| void twi_stop | ( | ) |
Sends STOP condition. Take a look at unusual busy-wait loop (Stop doesn't affect TWINT)
Definition at line 68 of file twi_basics.c.
References TW_SEND_CMD.
Referenced by ds1338_readBufferFromNVRAM(), ds1338_readByteFromNVRAM(), ds1338_writeBufferToNVRAM(), and ds1338_writeByteToNVRAM().
| void wait | ( | ) |
Waits until last TWI operation is completed
Definition at line 19 of file twi_basics.c.
Referenced by twi_receive(), twi_send(), and twi_start().
1.6.1