4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
31 //#include "sim_twi.h"
41 TWI_COND_START = (1 << 0),
42 TWI_COND_STOP = (1 << 1),
43 TWI_COND_ADDR = (1 << 2),
44 TWI_COND_ACK = (1 << 3),
45 TWI_COND_WRITE = (1 << 4),
46 TWI_COND_READ = (1 << 5),
49 typedef struct avr_twi_msg_t {
56 typedef struct avr_twi_msg_irq_t {
63 // add port number to get the real IRQ
64 #define AVR_IOCTL_TWI_GETIRQ(_name) AVR_IOCTL_DEF('t','w','i',(_name))
66 typedef struct avr_twi_t {
70 avr_regbit_t disabled; // bit in the PRR
72 avr_io_addr_t r_twbr; // bit rate register
73 avr_io_addr_t r_twcr; // control register
74 avr_io_addr_t r_twsr; // status register
75 avr_io_addr_t r_twar; // address register (slave)
76 avr_io_addr_t r_twamr; // address mask register
77 avr_io_addr_t r_twdr; // data register
79 avr_regbit_t twen; // twi enable bit
80 avr_regbit_t twea; // enable acknowledge bit
81 avr_regbit_t twsta; // start condition
82 avr_regbit_t twsto; // stop condition
83 avr_regbit_t twwc; // write collision
85 avr_regbit_t twsr; // status registers, (5 bits)
86 avr_regbit_t twps; // prescaler bits (2 bits)
88 avr_int_vector_t twi; // twi interrupt
101 * Create a message value for twi including the 'msg' bitfield,
102 * 'addr' and data. This value is what is sent as the IRQ value
114 #endif /*__AVR_TWI_H__*/