SimAVR
AVR Simulator
avr_usb.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "avr_usb.h"
Include dependency graph for avr_usb.c:

Data Structures

union  _ueintx
 
struct  _epstate
 
struct  usb_internal_state
 

Enumerations

enum  usb_regs {
  usbcon = 0, udcon = 8, udint = 9, udien = 10,
  udaddr = 11, udfnuml = 12, udfnumh = 13, udmfn = 14,
  ueintx = 16, uenum = 17, uerst = 18, ueconx = 19,
  uecfg0x = 20, uecfg1x = 21, uesta0x = 22, uesta1x = 23,
  ueienx = 24, uedatx = 25, uebclx = 26, ueint = 28,
  otgtcon = 29
}
 
enum  epints {
  txini = 0, stalledi = 1, rxouti = 2, rxstpi = 3,
  nakouti = 4, nakini = 6, overfi = 10, underfi = 11
}
 
enum  usbints {
  suspi = 0, sofi = 2, eorsti = 3, wakeupi = 4,
  eorsmi = 5, uprsmi = 6
}
 

Functions

static uint8_t current_ep_to_cpu (avr_usb_t *p)
 
static struct _epstateget_epstate (avr_usb_t *p, uint8_t ep)
 
static void raise_ep_interrupt (struct avr_t *avr, avr_usb_t *p, uint8_t ep, enum epints irq)
 
static void raise_usb_interrupt (avr_usb_t *p, enum usbints irq)
 
static void reset_endpoints (struct avr_t *avr, avr_usb_t *p)
 
static int ep_fifo_empty (struct _epstate *epstate)
 
static int ep_fifo_full (struct _epstate *epstate)
 
static uint8_t ep_fifo_size (struct _epstate *epstate)
 
static uint8_t ep_fifo_count (struct _epstate *epstate)
 
static int ep_fifo_cpu_readbyte (struct _epstate *epstate)
 
static int ep_fifo_cpu_writebyte (struct _epstate *epstate, uint8_t v)
 
static int ep_fifo_usb_read (struct _epstate *epstate, uint8_t *buf)
 
static int ep_fifo_usb_write (struct _epstate *epstate, uint8_t *buf, uint8_t len)
 
static uint8_t avr_usb_ep_read_bytecount (struct avr_t *avr, avr_io_addr_t addr, void *param)
 
static void avr_usb_udaddr_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_usb_udcon_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_usb_uenum_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static uint8_t avr_usb_ep_read_ueintx (struct avr_t *avr, avr_io_addr_t addr, void *param)
 
static void avr_usb_ep_write_ueintx (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static uint8_t avr_usb_ep_read (struct avr_t *avr, avr_io_addr_t addr, void *param)
 
static void avr_usb_ep_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static uint8_t avr_usb_ep_read_data (struct avr_t *avr, avr_io_addr_t addr, void *param)
 
static void avr_usb_ep_write_data (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_usb_pll_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
avr_cycle_count_t sof_generator (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static int avr_usb_ioctl (struct avr_io_t *io, uint32_t ctl, void *io_param)
 
void avr_usb_reset (struct avr_io_t *io)
 
static void avr_usb_dealloc (struct avr_io_t *port)
 
static void register_io_ep_readwrite (avr_t *avr, avr_usb_t *p, uint8_t laddr)
 
static void register_vectors (avr_t *avr, avr_usb_t *p)
 
void avr_usb_init (avr_t *avr, avr_usb_t *p)
 

Variables

const uint8_t num_endpoints = 5
 
static const char * irq_names [USB_IRQ_COUNT]
 
static avr_io_t _io
 

Enumeration Type Documentation

enum epints
Enumerator
txini 
stalledi 
rxouti 
rxstpi 
nakouti 
nakini 
overfi 
underfi 
enum usb_regs
Enumerator
usbcon 
udcon 
udint 
udien 
udaddr 
udfnuml 
udfnumh 
udmfn 
ueintx 
uenum 
uerst 
ueconx 
uecfg0x 
uecfg1x 
uesta0x 
uesta1x 
ueienx 
uedatx 
uebclx 
ueint 
otgtcon 
enum usbints
Enumerator
suspi 
sofi 
eorsti 
wakeupi 
eorsmi 
uprsmi 

Function Documentation

static void avr_usb_dealloc ( struct avr_io_t port)
static
static uint8_t avr_usb_ep_read ( struct avr_t avr,
avr_io_addr_t  addr,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_usb_ep_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_usb_ep_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_usb_ep_write_ueintx ( 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 int avr_usb_ioctl ( struct avr_io_t io,
uint32_t  ctl,
void *  io_param 
)
static

Here is the call graph for this function:

static void avr_usb_pll_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:

void avr_usb_reset ( struct avr_io_t io)
static void avr_usb_udaddr_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_usb_udcon_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_usb_uenum_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 uint8_t current_ep_to_cpu ( avr_usb_t p)
static

Here is the caller graph for this function:

static uint8_t ep_fifo_count ( struct _epstate epstate)
static

Here is the caller graph for this function:

static int ep_fifo_cpu_readbyte ( struct _epstate epstate)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int ep_fifo_cpu_writebyte ( struct _epstate epstate,
uint8_t  v 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int ep_fifo_empty ( struct _epstate epstate)
static

Here is the caller graph for this function:

static int ep_fifo_full ( struct _epstate epstate)
static

Here is the caller graph for this function:

static uint8_t ep_fifo_size ( struct _epstate epstate)
static

Here is the caller graph for this function:

static int ep_fifo_usb_read ( struct _epstate epstate,
uint8_t *  buf 
)
static

Here is the caller graph for this function:

static int ep_fifo_usb_write ( struct _epstate epstate,
uint8_t *  buf,
uint8_t  len 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static struct _epstate* get_epstate ( avr_usb_t p,
uint8_t  ep 
)
static

Here is the caller graph for this function:

static void raise_ep_interrupt ( struct avr_t avr,
avr_usb_t p,
uint8_t  ep,
enum epints  irq 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void raise_usb_interrupt ( avr_usb_t p,
enum usbints  irq 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void register_io_ep_readwrite ( avr_t avr,
avr_usb_t p,
uint8_t  laddr 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void register_vectors ( avr_t avr,
avr_usb_t p 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void reset_endpoints ( struct avr_t avr,
avr_usb_t p 
)
static

Here is the caller graph for this function:

avr_cycle_count_t sof_generator ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)

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 = "usb",
.reset = avr_usb_reset,
.irq_names = irq_names,
.ioctl = avr_usb_ioctl,
.dealloc = avr_usb_dealloc,
}
static int avr_usb_ioctl(struct avr_io_t *io, uint32_t ctl, void *io_param)
Definition: avr_usb.c:598
static const char * irq_names[USB_IRQ_COUNT]
Definition: avr_usb.c:704
void avr_usb_reset(struct avr_io_t *io)
Definition: avr_usb.c:688
static void avr_usb_dealloc(struct avr_io_t *port)
Definition: avr_usb.c:709
const char* irq_names[USB_IRQ_COUNT]
static
Initial value:
= {
[USB_IRQ_ATTACH] = ">attach",
}
Definition: avr_usb.h:39
const uint8_t num_endpoints = 5