SimAVR
AVR Simulator
avr_usb.h
Go to the documentation of this file.
1 // vim: set sts=4:sw=4:ts=4:noexpandtab
2 
3 /*
4  * avr_usb.h
5  *
6  * Copyright 2012 Torbjorn Tyridal <ttyridal@gmail.com>
7  *
8  * This file is part of simavr.
9  *
10  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
11  * General Public License as published by the Free Software Foundation, either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with simavr. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
27 #ifndef __AVR_USB_H__
28 #define __AVR_USB_H__
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 #include "sim_avr.h"
36 
37  enum
38  {
41  };
42 
44 #define AVR_IOCTL_USB_WRITE AVR_IOCTL_DEF('u','s','b','w')
45 #define AVR_IOCTL_USB_READ AVR_IOCTL_DEF('u','s','b','r')
46 #define AVR_IOCTL_USB_SETUP AVR_IOCTL_DEF('u','s','b','s')
47 #define AVR_IOCTL_USB_RESET AVR_IOCTL_DEF('u','s','b','R')
48 #define AVR_IOCTL_USB_VBUS AVR_IOCTL_DEF('u','s','b','V')
49 #define AVR_IOCTL_USB_GETIRQ() AVR_IOCTL_DEF('u','s','b',' ')
50 
51  struct avr_io_usb
52  {
53  uint8_t pipe;
54  uint32_t sz;
55  uint8_t *buf;
56  };
57 #define AVR_IOCTL_USB_NAK -2
58 #define AVR_IOCTL_USB_STALL -3
59 #define AVR_IOCTL_USB_OK 0
60 
61  typedef struct avr_usb_t
62  {
64  char name;
69 
70  uint8_t usb_com_vect;
71  uint8_t usb_gen_vect;
72 
74  } avr_usb_t;
75 
76  void avr_usb_init (avr_t * avr, avr_usb_t * port);
77 
78 #ifdef __cplusplus
79 };
80 #endif
81 
82 #endif /*__AVR_USB_H__*/
83 
Definition: avr_usb.h:39
Definition: avr_usb.h:61
Definition: avr_usb.h:51
uint16_t avr_io_addr_t
Definition: sim_avr_types.h:37
avr_io_addr_t r_pllcsr
Definition: avr_usb.h:68
uint8_t usb_gen_vect
Definition: avr_usb.h:71
avr_regbit_t usbrf
bit in the MCUSR
Definition: avr_usb.h:66
avr_t * avr
Definition: run_avr.c:54
Definition: avr_usb.c:165
uint8_t pipe
[in]
Definition: avr_usb.h:53
This 'structure' is a packed representation of an IO register 'bit' (or consecutive bits)...
Definition: sim_avr_types.h:47
struct usb_internal_state * state
Definition: avr_usb.h:73
avr_regbit_t disabled
bit in the PRR
Definition: avr_usb.h:65
avr_io_addr_t r_usbcon
every usb reg is an offset of this.
Definition: avr_usb.h:67
uint8_t usb_com_vect
Definition: avr_usb.h:70
void avr_usb_init(avr_t *avr, avr_usb_t *port)
Definition: avr_usb.c:752
avr_io_t io
Definition: avr_usb.h:63
uint8_t * buf
[in/out]
Definition: avr_usb.h:55
char name
Definition: avr_usb.h:64
Definition: avr_usb.h:40
uint32_t sz
[in/out]
Definition: avr_usb.h:54
Main AVR instance.
Definition: sim_avr.h:142
IO module base struct Modules uses that as their first member in their own struct.
Definition: sim_io.h:42
struct avr_usb_t avr_usb_t