|
Senzory 1.0
|
#include <avr/io.h>Go to the source code of this file.
Macros | |
Definition of frequencies | |
| #define | F_CPU 16000000 |
| CPU frequency in Hz required TWI_BIT_RATE_REG. | |
| #define | F_SCL 100000 |
| I2C/TWI bit rate. Must be greater than 31000. | |
| #define | TWI_BIT_RATE_REG ((F_CPU/F_SCL - 16) / 2) |
| TWI bit rate register value. | |
Definition of ports and pins | |
| #define | TWI_PORT PORTC |
| Port of TWI unit. | |
| #define | TWI_SDA_PIN 4 |
| SDA pin of TWI unit. | |
| #define | TWI_SCL_PIN 5 |
| SCL pin of TWI unit. | |
Other definitions | |
| #define | TWI_WRITE 0 |
| Mode for writing to I2C/TWI device. | |
| #define | TWI_READ 1 |
| Mode for reading from I2C/TWI device. | |
| #define | TWI_ACK 0 |
| ACK value for writing to I2C/TWI bus. | |
| #define | TWI_NACK 1 |
| NACK value for writing to I2C/TWI bus. | |
| #define | DDR(_x) |
| Address of Data Direction Register of port _x. | |
| #define | PIN(_x) |
| Address of input register of port _x. | |
| void | twi_init (void) |
| Initialize TWI unit, enable internal pull-ups, and set SCL frequency. | |
| void | twi_start (void) |
| Start communication on I2C/TWI bus. | |
| uint8_t | twi_write (uint8_t data) |
| Write one byte to the I2C/TWI bus. | |
| uint8_t | twi_read (uint8_t ack) |
| Read one byte from the I2C/TWI bus and acknowledge it by ACK or NACK. | |
| void | twi_stop (void) |
| Generates Stop condition on I2C/TWI bus. | |
| uint8_t | twi_test_address (uint8_t addr) |
| Test presence of one I2C device on the bus. | |
| void | twi_readfrom_mem_into (uint8_t addr, uint8_t memaddr, volatile uint8_t *buf, uint8_t nbytes) |
| Read into buf from the peripheral, starting from the memory address. | |