📄 dprintf.c
字号:
/*----------------------------------------------------------------------------------
*
* COPYRIGHT (c) 2001 by Singing Electrons, Inc. All rights reserved.
*
* Module Name : C:\se\adi\hidclass\source\dprintf.c
*
* Description : Code to allow printfs without the overhead
*
*
* Revision History : At bottom of the file.
*
*---------------------------------------------------------------------------------*/
/** include files **/
#include "dprintf.h"
/** local definitions **/
/* default settings */
/** external functions **/
/** external data **/
/** internal functions **/
/** public data **/
/** private data **/
/** public functions **/
/** private functions **/
#if DPRINTF_SUPPRESS
//Nothing to do!
#else
char gDprintfBuffer[MAX_DPRINTFBUFFER_ENTRIES][MAX_DPRINTFBUFFER_LEN];
int gCurrentDprintfBufferIndex = 0;
/*------------------------------------------------------------
* DumpDprintf
*
* Parameters:
* lastFew - set this to 1 to print all entries, otherwise
* set this to the number of "latest" entries to dump.
*
* Globals Used:
* gCurrentDprintfBufferIndex, gDprintfBuffer
*
* Description:
* Dumps the specified number of entries from the
* buffer using printf (to the console).
*
* Returns:
* Nothing
*
*------------------------------------------------------------*/
void DumpDprintf (int lastFew)
{
int currentEntry = 0, startingEntry, endingEntry;
if (lastFew == 1)
{
startingEntry = (gCurrentDprintfBufferIndex + 1) % MAX_DPRINTFBUFFER_ENTRIES;
endingEntry = gCurrentDprintfBufferIndex;
}
else
{
if (gCurrentDprintfBufferIndex >= lastFew)
{
startingEntry = gCurrentDprintfBufferIndex - lastFew;
endingEntry = gCurrentDprintfBufferIndex;
}
else
{
startingEntry = MAX_DPRINTFBUFFER_ENTRIES - (lastFew - gCurrentDprintfBufferIndex);
endingEntry = gCurrentDprintfBufferIndex;
}
}
for (currentEntry = startingEntry; currentEntry != endingEntry; currentEntry = (currentEntry + 1) % MAX_DPRINTFBUFFER_ENTRIES)
if (strlen (gDprintfBuffer[currentEntry]) > 0)
printf ("%02d: %s\n", currentEntry, gDprintfBuffer[currentEntry]);
}
/*------------------------------------------------------------
* InitDprintf
*
* Parameters:
* None.
*
* Globals Used:
* gCurrentDprintfBufferIndex, gDprintfBuffer
*
* Description:
* This routine clears the buffer, and initializes the
* index.
*
* Returns:
* Nothing
*
*------------------------------------------------------------*/
void InitDprintf (void)
{
memset (gDprintfBuffer, 0, sizeof (gDprintfBuffer));
gCurrentDprintfBufferIndex = 0;
}
#endif
/*----------------------------------------------------------------------------------
* $Log: dprintf.c,v $
* Revision 1.1 2003/01/09 01:16:36 Devendra
* First Rev of AudioClass - have the device enumerated as audio device, and the volume control and mute are functional!
*
* Revision 1.1 2002/10/31 00:30:59 Devendra
* Moved all files in one folder to avoid IDE related problems.
*
* Revision 1.1 2002/10/22 17:23:39 Devendra
* Rearranged file locations.
*
* Revision 1.2 2002/10/09 17:09:32 Devendra
* - Added support for handling IN endpoints.
* - Added HID descriptors (HID and HID Report)
* - Modified the Interface descriptors to comply to HID Class Spec.
* - Added functionality to use the push-buttons on the Eagle-35 as a mouse (for buttons as well as for movement).
* - The device is now a fully functioning USB Mouse!
*
* Revision 1.1 2002/10/08 20:44:35 Devendra
* - Separated the printf logging to a different c module.
*
*
*---------------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -