#include "usb_desc_bootloader.h"
Go to the source code of this file.
Defines | |
#define | USB_EP0_HSNAK() do {ep0cs = 0x02; } while(0) |
#define | USB_EP0_STALL() do {ep0cs = 0x11; } while(0) |
#define | INT_SUDAV 0x00 |
#define | INT_SOF 0x04 |
#define | INT_SUTOK 0x08 |
#define | INT_SUSPEND 0x0C |
#define | INT_USBRESET 0x10 |
#define | INT_EP0IN 0x18 |
#define | INT_EP0OUT 0x1C |
#define | INT_EP1IN 0x20 |
#define | INT_EP1OUT 0x24 |
#define | USB_BM_STATE_CONFIGURED 0x01 |
#define | USB_BM_STATE_ALLOW_REMOTE_WAKEUP 0x02 |
Enumerations | |
enum | usb_state_t { ATTACHED, POWERED, DEFAULT, ADDRESSED, CONFIGURED, SUSPENDED } |
Functions | |
void | usb_init (void) |
void | usb_irq (void) |
This file contain structures and constants defined in Chapter 9 of the USB 2.0 standard
Definition in file usb.h.
enum usb_state_t |
An enum describing the USB state
The states described in this enum are found in Chapter 9 of the USB 2.0 specification
Definition at line 45 of file usb.h.
{ ATTACHED, POWERED, DEFAULT, ADDRESSED, CONFIGURED, SUSPENDED } usb_state_t;
void usb_init | ( | void | ) |
Definition at line 98 of file usb.c.
{ // Setup state information usb_state = DEFAULT; usb_bm_state = 0; // Setconfig configuration information usb_current_config = 0; usb_current_alt_interface = 0; // Disconnect from USB-bus since we are in this routine from a power on and not a soft reset: usbcs |= 0x08; delay_ms(50); usbcs &= ~0x08; usbien = 0x1d; in_ien = 0x01; in_irq = 0x1f; out_ien = 0x01; out_irq = 0x1f; // Setup the USB RAM with some OK default values: bout1addr = MAX_PACKET_SIZE_EP0/2; bout2addr = MAX_PACKET_SIZE_EP0/2 + USB_EP1_SIZE/2; bout3addr = MAX_PACKET_SIZE_EP0/2 + 2*USB_EP1_SIZE/2; bout4addr = MAX_PACKET_SIZE_EP0/2 + 3*USB_EP1_SIZE/2; bout5addr = MAX_PACKET_SIZE_EP0/2 + 4*USB_EP1_SIZE/2; binstaddr = 0xc0; bin1addr = MAX_PACKET_SIZE_EP0/2; bin2addr = MAX_PACKET_SIZE_EP0/2 + USB_EP1_SIZE/2; bin3addr = MAX_PACKET_SIZE_EP0/2 + 2*USB_EP1_SIZE/2; bin4addr = MAX_PACKET_SIZE_EP0/2 + 3*USB_EP1_SIZE/2; bin5addr = MAX_PACKET_SIZE_EP0/2 + 4*USB_EP1_SIZE/2; // Set all endpoints to not valid (except EP0IN and EP0OUT) inbulkval = 0x01; outbulkval = 0x01; inisoval = 0x00; outisoval = 0x00; in_ien |= 0x02;; inbulkval |= 0x02; out_ien |= 0x02; outbulkval |= 0x02; out1bc = 0xff; }
void usb_irq | ( | void | ) |
Definition at line 369 of file usb.c.
{ // // Split case into an if and a switch to force Keil into not using a library function: if (ivec == INT_USBRESET) { usbirq = 0x10; usb_state = DEFAULT; usb_current_config = 0; usb_current_alt_interface = 0; usb_bm_state = 0; } else { switch(ivec) { case INT_SUDAV: usbirq = 0x01; isr_sudav(); break; case INT_SOF: usbirq = 0x02; break; case INT_SUTOK: usbirq = 0x04; packetizer_data_ptr = NULL; packetizer_data_size = 0; packetizer_pkt_size = 0; break; case INT_SUSPEND: usbirq = 0x08; break; case INT_EP0IN: in_irq = 0x01; packetizer_isr_ep0_in(); break; case INT_EP0OUT: out_irq = 0x01; packetizer_data_size = 0; // req.misc_data = out0buf; USB_EP0_HSNAK(); break; case INT_EP1IN: // Clear interrupt in_irq = 0x02; in1cs = 0x02; break; case INT_EP1OUT: // Clear interrupt out_irq = 0x02; packet_received = true; out1bc = 0xff; break; default: break; } } }