U08usb.c, Source code files – Motorola USB08 User Manual

Page 104

Advertising
background image

Designer Reference Manual

USB08 Evaluation Board

104

Source Code Files

MOTOROLA

Source Code Files

U08USB.C

//============================================================================

// File: U08USB.C

// Func: USB Implementation Module for USB08 Demo Application

// Ver.: 1.00

// Auth: (C)2000,2001 by Oliver Thamm, MCT Elektronikladen GbR

// http://hc08web.de/usb08

// Rem.: View/Edit this File with TAB-Size=4

//============================================================================

//----------------------------------------------------------------------------

#include "u08usb.h"

// Definitions for USB Data Types & Constants

#include "u08desc.c"

// const USB Descriptor Data

//----------------------------------------------------------------------------

// Source Code Option - set as required by Hardware!

//

#define USB_IPUE1

// Internal Pull-up Enable

// 1=Enable(use build-in Pull-up Resistor)

// 0=Disable (external Pull-up required)

//-- Variables ---------------------------------------------------------------

volatile uchar USB_State;

#define MAX_TXBUF_SIZE 16

// must be 2^x!

volatile uchar TxBuffer[MAX_TXBUF_SIZE];

volatile uchar TxBuf_RdIdx;

volatile uchar TxBuf_WrIdx;

#define MAX_RXBUF_SIZE 16

// must be 2^x!

volatile uchar RxBuffer[MAX_RXBUF_SIZE];

volatile uchar RxBuf_RdIdx;

volatile uchar RxBuf_WrIdx;

volatile uchar SuspendCounter;

setup_buffer SetupBuffer;

uchar SetupSize;

uchar * SetupDataPtr;

uchar R0Sequence;

// DATA0/1 Flag for EP0 Rx

uchar R2Sequence;

// DATA0/1 Flag for EP2 Rx

//----------------------------------------------------------------------------

// Force STALL Condition for EP0 (both IN and OUT)

// as a Response to an invalid SETUP Request

// Flags will be auto-cleared by the next SETUP Token

//

void forceSTALL() {

UCR3 |= BM_OSTALL0 + BM_ISTALL0;

}

Advertising