/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (C) Copyright Intel Corp., 1996 File: service.c Universal Serial Bus 930 Test firmware Revision History --------------------------------------------- 0.1 05-27-96 Abdul Rahman Ismail ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include <82930.h> #include "defs.h" #include "service.h" // external functions. extern void FillEP1Fifo( void ); extern void FillEP2Fifo( void ); // external variables extern BYTE gbEP1Running; extern BYTE gbEP2Running; // function prototypes reentrant void ServiceEndPoints( void ); reentrant void CheckEPRunning( void ); reentrant void CheckEPOverflow( void ); /*------------------------------------------------------------------- Function name : ServiceEndPoints Brief Description : Called whenever a new SOF is recd. Updates the : TX fifos on all endpoints running. -------------------------------------------------------------------*/ reentrant void ServiceEndPoints( void ) { if (gbEP1Running == TRUE) FillEP1Fifo(); if (gbEP2Running == TRUE) FillEP2Fifo(); } /*------------------------------------------------------------------- Function name : CheckEPRunning Brief Description : Checks whether an endpoint has started sending data to the host. If so then sets the gbEP1Running to true. --------------------------------------------------------------------*/ reentrant void CheckEPRunning( void ) { if (gbEP1Running == FALSE) { if ((TXFLG1 & GET_FIFO_BITS) != FIFO_FULL) gbEP1Running = TRUE; } if (gbEP2Running == FALSE) { if ((TXFLG2 & GET_FIFO_BITS) != FIFO_FULL) gbEP2Running = TRUE; } } /*------------------------------------------------------------------- Function name : CheckEPOverflow Brief Description : Continuously called to check whether an overflow has occured on any endpoint. If it has then the endpoint is reset, and new data primed into the fifos. --------------------------------------------------------------------*/ reentrant void CheckEPOverflow( void ) { if (T_OVF1 == TRUE) { gbEP1Running = FALSE; // Assume that the ep has stopped running T_CLR1 = TRUE; // Clear the fifo. /* Fill the fifo with a known pattern */ asm( "mov R8, #00h" ); FillEP1Fifo(); asm( "mov R8, #01h" ); FillEP1Fifo(); } if (T_OVF2 == TRUE ) { gbEP2Running = FALSE; T_CLR2 = TRUE; asm( "mov R8, #00h" ); FillEP2Fifo(); asm( "mov R8, #01h" ); FillEP2Fifo(); } }