SimAVR
AVR Simulator
avr_twi.c File Reference
#include <stdio.h>
#include "avr_twi.h"
Include dependency graph for avr_twi.c:

Macros

#define TWI_START   0x08
 
#define TWI_REP_START   0x10
 
#define TWI_ARB_LOST   0x38
 
#define TWI_MTX_ADR_ACK   0x18
 
#define TWI_MTX_ADR_NACK   0x20
 
#define TWI_MTX_DATA_ACK   0x28
 
#define TWI_MTX_DATA_NACK   0x30
 
#define TWI_MRX_ADR_ACK   0x40
 
#define TWI_MRX_ADR_NACK   0x48
 
#define TWI_MRX_DATA_ACK   0x50
 
#define TWI_MRX_DATA_NACK   0x58
 
#define TWI_STX_ADR_ACK   0xA8
 
#define TWI_STX_ADR_ACK_M_ARB_LOST   0xB0
 
#define TWI_STX_DATA_ACK   0xB8
 
#define TWI_STX_DATA_NACK   0xC0
 
#define TWI_STX_DATA_ACK_LAST_BYTE   0xC8
 
#define TWI_SRX_ADR_ACK   0x60
 
#define TWI_SRX_ADR_ACK_M_ARB_LOST   0x68
 
#define TWI_SRX_GEN_ACK   0x70
 
#define TWI_SRX_GEN_ACK_M_ARB_LOST   0x78
 
#define TWI_SRX_ADR_DATA_ACK   0x80
 
#define TWI_SRX_ADR_DATA_NACK   0x88
 
#define TWI_SRX_GEN_DATA_ACK   0x90
 
#define TWI_SRX_GEN_DATA_NACK   0x98
 
#define TWI_SRX_STOP_RESTART   0xA0
 
#define TWI_NO_STATE   0xF8
 
#define TWI_BUS_ERROR   0x00
 
#define AVR_TWI_DEBUG   1
 

Functions

static void _avr_twi_status_set (avr_twi_t *p, uint8_t v, int interrupt)
 
static __attribute__ ((unused))
 
static avr_cycle_count_t avr_twi_set_state_timer (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static void _avr_twi_delay_state (avr_twi_t *p, int twi_cycles, uint8_t state)
 
static void avr_twi_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_twi_write_data (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static uint8_t avr_twi_read_data (struct avr_t *avr, avr_io_addr_t addr, void *param)
 
static void avr_twi_write_status (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_twi_irq_input (struct avr_irq_t *irq, uint32_t value, void *param)
 
void avr_twi_reset (struct avr_io_t *io)
 
void avr_twi_init (avr_t *avr, avr_twi_t *p)
 
uint32_t avr_twi_irq_msg (uint8_t msg, uint8_t addr, uint8_t data)
 Create a message value for twi including the 'msg' bitfield, 'addr' and data. More...
 

Variables

static const char * irq_names [TWI_IRQ_COUNT]
 
static avr_io_t _io
 

Macro Definition Documentation

#define AVR_TWI_DEBUG   1
#define TWI_ARB_LOST   0x38
#define TWI_BUS_ERROR   0x00
#define TWI_MRX_ADR_ACK   0x40
#define TWI_MRX_ADR_NACK   0x48
#define TWI_MRX_DATA_ACK   0x50
#define TWI_MRX_DATA_NACK   0x58
#define TWI_MTX_ADR_ACK   0x18
#define TWI_MTX_ADR_NACK   0x20
#define TWI_MTX_DATA_ACK   0x28
#define TWI_MTX_DATA_NACK   0x30
#define TWI_NO_STATE   0xF8
#define TWI_REP_START   0x10
#define TWI_SRX_ADR_ACK   0x60
#define TWI_SRX_ADR_ACK_M_ARB_LOST   0x68
#define TWI_SRX_ADR_DATA_ACK   0x80
#define TWI_SRX_ADR_DATA_NACK   0x88
#define TWI_SRX_GEN_ACK   0x70
#define TWI_SRX_GEN_ACK_M_ARB_LOST   0x78
#define TWI_SRX_GEN_DATA_ACK   0x90
#define TWI_SRX_GEN_DATA_NACK   0x98
#define TWI_SRX_STOP_RESTART   0xA0
#define TWI_START   0x08
#define TWI_STX_ADR_ACK   0xA8
#define TWI_STX_ADR_ACK_M_ARB_LOST   0xB0
#define TWI_STX_DATA_ACK   0xB8
#define TWI_STX_DATA_ACK_LAST_BYTE   0xC8
#define TWI_STX_DATA_NACK   0xC0

Function Documentation

static __attribute__ ( (unused)  )
static

Here is the call graph for this function:

static void _avr_twi_delay_state ( avr_twi_t p,
int  twi_cycles,
uint8_t  state 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void _avr_twi_status_set ( avr_twi_t p,
uint8_t  v,
int  interrupt 
)
inlinestatic

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_twi_irq_input ( struct avr_irq_t irq,
uint32_t  value,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static uint8_t avr_twi_read_data ( struct avr_t avr,
avr_io_addr_t  addr,
void *  param 
)
static

Here is the caller graph for this function:

void avr_twi_reset ( struct avr_io_t io)

Here is the call graph for this function:

static avr_cycle_count_t avr_twi_set_state_timer ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_twi_write ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_twi_write_data ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_twi_write_status ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

avr_io_t _io
static
Initial value:
= {
.kind = "twi",
.reset = avr_twi_reset,
.irq_names = irq_names,
}
void avr_twi_reset(struct avr_io_t *io)
Definition: avr_twi.c:438
static const char * irq_names[TWI_IRQ_COUNT]
Definition: avr_twi.c:445
const char* irq_names[TWI_IRQ_COUNT]
static
Initial value:
= {
[TWI_IRQ_INPUT] = "8<input",
[TWI_IRQ_OUTPUT] = "32>output",
[TWI_IRQ_STATUS] = "8>status",
}
Definition: avr_twi.h:39
Definition: avr_twi.h:41
Definition: avr_twi.h:40