hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
SysTickHandler
void
void SysTickHandler(void) { // // Update our system timer counter. // g_ulSysTickCount++; // // Call the lwIP timer. // lwIPTimer(1000 / TICKS_PER_SECOND); // // Call the file system tick timer. // fs_tick(1000 / TICKS_PER_SECOND); // // Update the touchscreen information on the display if necessary. // if(g_ulTouchUpdateTicks == 0) { // // Ask the main loop to update the touch count. // g_ulCommandFlags |= COMMAND_TOUCH_UPDATE; // // Reload the tick counter for the next update. // g_ulTouchUpdateTicks = TOUCH_UPDATE_TICKS; } else { // // Decrement the timer we use to determine when to update the touch // info on the display. // g_ulTouchUpdateTicks --; } // // Update the thumbwheel potentiometer sample if necessary // if(g_ulThumbUpdateTicks == 0) { // // Request capture of a new thumbwheel sample. // ThumbwheelTrigger(); } else { g_ulThumbUpdateTicks--; } }
//***************************************************************************** // // This is the handler for this SysTick interrupt. FatFs requires a // timer tick every 10 ms for internal timing purposes. // //*****************************************************************************
This is the handler for this SysTick interrupt. FatFs requires a timer tick every 10 ms for internal timing purposes.
[ "This", "is", "the", "handler", "for", "this", "SysTick", "interrupt", ".", "FatFs", "requires", "a", "timer", "tick", "every", "10", "ms", "for", "internal", "timing", "purposes", "." ]
void SysTickHandler(void) { g_ulSysTickCount++; lwIPTimer(1000 / TICKS_PER_SECOND); fs_tick(1000 / TICKS_PER_SECOND); if(g_ulTouchUpdateTicks == 0) { g_ulCommandFlags |= COMMAND_TOUCH_UPDATE; g_ulTouchUpdateTicks = TOUCH_UPDATE_TICKS; } else { g_ulTouchUpdateTicks --; } if(g_ulThumbUpdateTicks == 0) { ThumbwheelTrigger(); } else { g_ulThumbUpdateTicks--; } }
[ "void", "SysTickHandler", "(", "void", ")", "{", "g_ulSysTickCount", "++", ";", "lwIPTimer", "(", "1000", "/", "TICKS_PER_SECOND", ")", ";", "fs_tick", "(", "1000", "/", "TICKS_PER_SECOND", ")", ";", "if", "(", "g_ulTouchUpdateTicks", "==", "0", ")", "{", "g_ulCommandFlags", "|=", "COMMAND_TOUCH_UPDATE", ";", "g_ulTouchUpdateTicks", "=", "TOUCH_UPDATE_TICKS", ";", "}", "else", "{", "g_ulTouchUpdateTicks", "--", ";", "}", "if", "(", "g_ulThumbUpdateTicks", "==", "0", ")", "{", "ThumbwheelTrigger", "(", ")", ";", "}", "else", "{", "g_ulThumbUpdateTicks", "--", ";", "}", "}" ]
This is the handler for this SysTick interrupt.
[ "This", "is", "the", "handler", "for", "this", "SysTick", "interrupt", "." ]
[ "//\r", "// Update our system timer counter.\r", "//\r", "//\r", "// Call the lwIP timer.\r", "//\r", "//\r", "// Call the file system tick timer.\r", "//\r", "//\r", "// Update the touchscreen information on the display if necessary.\r", "//\r", "//\r", "// Ask the main loop to update the touch count.\r", "//\r", "//\r", "// Reload the tick counter for the next update.\r", "//\r", "//\r", "// Decrement the timer we use to determine when to update the touch\r", "// info on the display.\r", "//\r", "//\r", "// Update the thumbwheel potentiometer sample if necessary\r", "//\r", "//\r", "// Request capture of a new thumbwheel sample.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
ShowEthernetAddresses
void
static void ShowEthernetAddresses(void) { UARTprintf("MAC: %s\n", g_pucMACAddrString); UARTprintf("IP: %s\n", g_pucIPAddrString); }
//***************************************************************************** // // This function prints the current IP and MAC addresses to the UART. // //*****************************************************************************
This function prints the current IP and MAC addresses to the UART.
[ "This", "function", "prints", "the", "current", "IP", "and", "MAC", "addresses", "to", "the", "UART", "." ]
static void ShowEthernetAddresses(void) { UARTprintf("MAC: %s\n", g_pucMACAddrString); UARTprintf("IP: %s\n", g_pucIPAddrString); }
[ "static", "void", "ShowEthernetAddresses", "(", "void", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ",", "g_pucMACAddrString", ")", ";", "UARTprintf", "(", "\"", "\\n", "\"", ",", "g_pucIPAddrString", ")", ";", "}" ]
This function prints the current IP and MAC addresses to the UART.
[ "This", "function", "prints", "the", "current", "IP", "and", "MAC", "addresses", "to", "the", "UART", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
Cmd_addr
int
int Cmd_addr(int argc, char *argv[]) { // // Print the addresses to the UART terminal. // ShowEthernetAddresses(); // // Return success (not that we will ever get here). // return(0); }
//***************************************************************************** // // This function implements the "addr" command. It shows the current IP // and Ethernet MAC addresses. // //*****************************************************************************
This function implements the "addr" command. It shows the current IP and Ethernet MAC addresses.
[ "This", "function", "implements", "the", "\"", "addr", "\"", "command", ".", "It", "shows", "the", "current", "IP", "and", "Ethernet", "MAC", "addresses", "." ]
int Cmd_addr(int argc, char *argv[]) { ShowEthernetAddresses(); return(0); }
[ "int", "Cmd_addr", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "ShowEthernetAddresses", "(", ")", ";", "return", "(", "0", ")", ";", "}" ]
This function implements the "addr" command.
[ "This", "function", "implements", "the", "\"", "addr", "\"", "command", "." ]
[ "//\r", "// Print the addresses to the UART terminal.\r", "//\r", "//\r", "// Return success (not that we will ever get here).\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
CheckoutPointerMessage
null
long CheckoutPointerMessage(unsigned long ulMessage, long lX, long lY) { // // Save the current touch position. // g_lPtrX = lX; g_lPtrY = lY; // // Determine whether the screen has been pressed or released. // g_bPtrPressed = (ulMessage == WIDGET_MSG_PTR_UP) ? false : true; // // Pass the event to the USB mouse subsystem // USBMouseTouchHandler(ulMessage, lX, lY); // // Pass the message on to the widget library. // return(WidgetPointerMessage(ulMessage, lX, lY)); }
//***************************************************************************** // // Intercept messages in flow from the touchscreen driver to the widget manager. // This function allows the application to track the current pointer position // and state before passing this on to the widget manager. // //*****************************************************************************
Intercept messages in flow from the touchscreen driver to the widget manager. This function allows the application to track the current pointer position and state before passing this on to the widget manager.
[ "Intercept", "messages", "in", "flow", "from", "the", "touchscreen", "driver", "to", "the", "widget", "manager", ".", "This", "function", "allows", "the", "application", "to", "track", "the", "current", "pointer", "position", "and", "state", "before", "passing", "this", "on", "to", "the", "widget", "manager", "." ]
long CheckoutPointerMessage(unsigned long ulMessage, long lX, long lY) { g_lPtrX = lX; g_lPtrY = lY; g_bPtrPressed = (ulMessage == WIDGET_MSG_PTR_UP) ? false : true; USBMouseTouchHandler(ulMessage, lX, lY); return(WidgetPointerMessage(ulMessage, lX, lY)); }
[ "long", "CheckoutPointerMessage", "(", "unsigned", "long", "ulMessage", ",", "long", "lX", ",", "long", "lY", ")", "{", "g_lPtrX", "=", "lX", ";", "g_lPtrY", "=", "lY", ";", "g_bPtrPressed", "=", "(", "ulMessage", "==", "WIDGET_MSG_PTR_UP", ")", "?", "false", ":", "true", ";", "USBMouseTouchHandler", "(", "ulMessage", ",", "lX", ",", "lY", ")", ";", "return", "(", "WidgetPointerMessage", "(", "ulMessage", ",", "lX", ",", "lY", ")", ")", ";", "}" ]
Intercept messages in flow from the touchscreen driver to the widget manager.
[ "Intercept", "messages", "in", "flow", "from", "the", "touchscreen", "driver", "to", "the", "widget", "manager", "." ]
[ "//\r", "// Save the current touch position.\r", "//\r", "//\r", "// Determine whether the screen has been pressed or released.\r", "//\r", "//\r", "// Pass the event to the USB mouse subsystem\r", "//\r", "//\r", "// Pass the message on to the widget library.\r", "//\r" ]
[ { "param": "ulMessage", "type": "unsigned long" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulMessage", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
UpdateUSBWidgets
void
static void UpdateUSBWidgets(unsigned long ulFlags) { tBoolean bConnected, bDevice; // // Was a mouse connected or disconnected? // if(ulFlags & MOUSE_FLAG_CONNECTION) { // // The connection state changed. Was this a connection or a // disconnection? // bConnected = USBMouseIsConnected(&bDevice); // // Are we connected to something? // if(bConnected) { // // Update the display with the current mode. // CanvasTextSet(&g_sModeString, g_pcMouseModes[(bDevice ? MOUSE_MODE_STR_DEVICE : MOUSE_MODE_STR_HOST)]); // // Update the mode string if it is visible. // if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sModeString); } // // Yes - are we acting as a USB mouse device or a host? // if(!bDevice) { // // Force ourselves to update the position and button states. // ulFlags |= (MOUSE_FLAG_POSITION | MOUSE_FLAG_BUTTONS); // // Update the status. // PrintfStatus("Mouse connected."); } else { // // We are a device. // PrintfStatus("USB host connected."); } } else { // // Update the status. // PrintfStatus("Mouse disconnected."); // // No mouse is connected. // CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_NONE]); CanvasImageSet(&g_sMouseBtn1, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn2, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn3, g_pucGreyLED14x14Image); // // Disable the mouse position and button indicators. // g_pcMousePos[0] = (char)0; if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); WidgetPaint((tWidget *)&g_sMouseBtn1); WidgetPaint((tWidget *)&g_sMouseBtn2); WidgetPaint((tWidget *)&g_sMouseBtn3); WidgetPaint((tWidget *)&g_sModeString); } // // Return here since we obviously can't have pointer movement or // button presses if there's no mouse connected. // return; } } // // Has the position changed? // if(ulFlags & MOUSE_FLAG_POSITION) { short sX, sY; // // Yes - redraw the position string. // USBMouseHostPositionGet(&sX, &sY); usnprintf(g_pcMousePos, MAX_MOUSE_POS_LEN, "(%d, %d) ", sX, sY); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); } } // // Did the state of any button change? // if(ulFlags & MOUSE_FLAG_BUTTONS) { unsigned long ulButtons; // // Yes - redraw the button state indicators. // ulButtons = USBMouseHostButtonsGet(); // // Set the state of the button 1 indicator. // CanvasImageSet(&g_sMouseBtn1, ((ulButtons & MOUSE_BTN_1) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn1); } // // Set the state of the button 2 indicator. // CanvasImageSet(&g_sMouseBtn2, ((ulButtons & MOUSE_BTN_2) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn2); } // // Set the state of the button 3 indicator. // CanvasImageSet(&g_sMouseBtn3, ((ulButtons & MOUSE_BTN_3) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn3); } } if(ulFlags & MSC_FLAG_CONNECTION) { // // The connection state changed. Was this a connection or a // disconnection? // bConnected = USBMSCIsConnected(); // // Tell the user what happened. // if(bConnected) { // // Update the status. // PrintfStatus("Flash stick connected."); } else { // // We are a device. // PrintfStatus("Device disconnected."); } } }
//***************************************************************************** // // Update the various widgets on the screen which indicate the state of the // USB mouse or MSC flash disk. // //*****************************************************************************
Update the various widgets on the screen which indicate the state of the USB mouse or MSC flash disk.
[ "Update", "the", "various", "widgets", "on", "the", "screen", "which", "indicate", "the", "state", "of", "the", "USB", "mouse", "or", "MSC", "flash", "disk", "." ]
static void UpdateUSBWidgets(unsigned long ulFlags) { tBoolean bConnected, bDevice; if(ulFlags & MOUSE_FLAG_CONNECTION) { bConnected = USBMouseIsConnected(&bDevice); if(bConnected) { CanvasTextSet(&g_sModeString, g_pcMouseModes[(bDevice ? MOUSE_MODE_STR_DEVICE : MOUSE_MODE_STR_HOST)]); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sModeString); } if(!bDevice) { ulFlags |= (MOUSE_FLAG_POSITION | MOUSE_FLAG_BUTTONS); PrintfStatus("Mouse connected."); } else { PrintfStatus("USB host connected."); } } else { PrintfStatus("Mouse disconnected."); CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_NONE]); CanvasImageSet(&g_sMouseBtn1, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn2, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn3, g_pucGreyLED14x14Image); g_pcMousePos[0] = (char)0; if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); WidgetPaint((tWidget *)&g_sMouseBtn1); WidgetPaint((tWidget *)&g_sMouseBtn2); WidgetPaint((tWidget *)&g_sMouseBtn3); WidgetPaint((tWidget *)&g_sModeString); } return; } } if(ulFlags & MOUSE_FLAG_POSITION) { short sX, sY; USBMouseHostPositionGet(&sX, &sY); usnprintf(g_pcMousePos, MAX_MOUSE_POS_LEN, "(%d, %d) ", sX, sY); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); } } if(ulFlags & MOUSE_FLAG_BUTTONS) { unsigned long ulButtons; ulButtons = USBMouseHostButtonsGet(); CanvasImageSet(&g_sMouseBtn1, ((ulButtons & MOUSE_BTN_1) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn1); } CanvasImageSet(&g_sMouseBtn2, ((ulButtons & MOUSE_BTN_2) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn2); } CanvasImageSet(&g_sMouseBtn3, ((ulButtons & MOUSE_BTN_3) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn3); } } if(ulFlags & MSC_FLAG_CONNECTION) { bConnected = USBMSCIsConnected(); if(bConnected) { PrintfStatus("Flash stick connected."); } else { PrintfStatus("Device disconnected."); } } }
[ "static", "void", "UpdateUSBWidgets", "(", "unsigned", "long", "ulFlags", ")", "{", "tBoolean", "bConnected", ",", "bDevice", ";", "if", "(", "ulFlags", "&", "MOUSE_FLAG_CONNECTION", ")", "{", "bConnected", "=", "USBMouseIsConnected", "(", "&", "bDevice", ")", ";", "if", "(", "bConnected", ")", "{", "CanvasTextSet", "(", "&", "g_sModeString", ",", "g_pcMouseModes", "[", "(", "bDevice", "?", "MOUSE_MODE_STR_DEVICE", ":", "MOUSE_MODE_STR_HOST", ")", "]", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sModeString", ")", ";", "}", "if", "(", "!", "bDevice", ")", "{", "ulFlags", "|=", "(", "MOUSE_FLAG_POSITION", "|", "MOUSE_FLAG_BUTTONS", ")", ";", "PrintfStatus", "(", "\"", "\"", ")", ";", "}", "else", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "}", "}", "else", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "CanvasTextSet", "(", "&", "g_sModeString", ",", "g_pcMouseModes", "[", "MOUSE_MODE_STR_NONE", "]", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn1", ",", "g_pucGreyLED14x14Image", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn2", ",", "g_pucGreyLED14x14Image", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn3", ",", "g_pucGreyLED14x14Image", ")", ";", "g_pcMousePos", "[", "0", "]", "=", "(", "char", ")", "0", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMousePos", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn1", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn2", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn3", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sModeString", ")", ";", "}", "return", ";", "}", "}", "if", "(", "ulFlags", "&", "MOUSE_FLAG_POSITION", ")", "{", "short", "sX", ",", "sY", ";", "USBMouseHostPositionGet", "(", "&", "sX", ",", "&", "sY", ")", ";", "usnprintf", "(", "g_pcMousePos", ",", "MAX_MOUSE_POS_LEN", ",", "\"", "\"", ",", "sX", ",", "sY", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMousePos", ")", ";", "}", "}", "if", "(", "ulFlags", "&", "MOUSE_FLAG_BUTTONS", ")", "{", "unsigned", "long", "ulButtons", ";", "ulButtons", "=", "USBMouseHostButtonsGet", "(", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn1", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_1", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn1", ")", ";", "}", "CanvasImageSet", "(", "&", "g_sMouseBtn2", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_2", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn2", ")", ";", "}", "CanvasImageSet", "(", "&", "g_sMouseBtn3", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_3", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn3", ")", ";", "}", "}", "if", "(", "ulFlags", "&", "MSC_FLAG_CONNECTION", ")", "{", "bConnected", "=", "USBMSCIsConnected", "(", ")", ";", "if", "(", "bConnected", ")", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "}", "else", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "}", "}", "}" ]
Update the various widgets on the screen which indicate the state of the USB mouse or MSC flash disk.
[ "Update", "the", "various", "widgets", "on", "the", "screen", "which", "indicate", "the", "state", "of", "the", "USB", "mouse", "or", "MSC", "flash", "disk", "." ]
[ "//\r", "// Was a mouse connected or disconnected?\r", "//\r", "//\r", "// The connection state changed. Was this a connection or a\r", "// disconnection?\r", "//\r", "//\r", "// Are we connected to something?\r", "//\r", "//\r", "// Update the display with the current mode.\r", "//\r", "//\r", "// Update the mode string if it is visible.\r", "//\r", "//\r", "// Yes - are we acting as a USB mouse device or a host?\r", "//\r", "//\r", "// Force ourselves to update the position and button states.\r", "//\r", "//\r", "// Update the status.\r", "//\r", "//\r", "// We are a device.\r", "//\r", "//\r", "// Update the status.\r", "//\r", "//\r", "// No mouse is connected.\r", "//\r", "//\r", "// Disable the mouse position and button indicators.\r", "//\r", "//\r", "// Return here since we obviously can't have pointer movement or\r", "// button presses if there's no mouse connected.\r", "//\r", "//\r", "// Has the position changed?\r", "//\r", "//\r", "// Yes - redraw the position string.\r", "//\r", "//\r", "// Did the state of any button change?\r", "//\r", "//\r", "// Yes - redraw the button state indicators.\r", "//\r", "//\r", "// Set the state of the button 1 indicator.\r", "//\r", "//\r", "// Set the state of the button 2 indicator.\r", "//\r", "//\r", "// Set the state of the button 3 indicator.\r", "//\r", "//\r", "// The connection state changed. Was this a connection or a\r", "// disconnection?\r", "//\r", "//\r", "// Tell the user what happened.\r", "//\r", "//\r", "// Update the status.\r", "//\r", "//\r", "// We are a device.\r", "//\r" ]
[ { "param": "ulFlags", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulFlags", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7012db22b39923ca3094316cfff97de9876d1c8
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/qs-checkout/qs-checkout.c
[ "BSD-3-Clause" ]
C
ProcessMainFunctionCommands
void
void ProcessMainFunctionCommands(void) { if(g_ulCommandFlags & COMMAND_TOUCH_UPDATE) { ProcessCommandTouchUpdate(); g_ulCommandFlags &= ~COMMAND_TOUCH_UPDATE; } if(g_ulCommandFlags & COMMAND_THUMB_UPDATE) { ProcessCommandThumbUpdate(); g_ulCommandFlags &= ~COMMAND_THUMB_UPDATE; } }
//***************************************************************************** // // Process any commands that the main function has been sent from other // functions or interrupts. // //*****************************************************************************
Process any commands that the main function has been sent from other functions or interrupts.
[ "Process", "any", "commands", "that", "the", "main", "function", "has", "been", "sent", "from", "other", "functions", "or", "interrupts", "." ]
void ProcessMainFunctionCommands(void) { if(g_ulCommandFlags & COMMAND_TOUCH_UPDATE) { ProcessCommandTouchUpdate(); g_ulCommandFlags &= ~COMMAND_TOUCH_UPDATE; } if(g_ulCommandFlags & COMMAND_THUMB_UPDATE) { ProcessCommandThumbUpdate(); g_ulCommandFlags &= ~COMMAND_THUMB_UPDATE; } }
[ "void", "ProcessMainFunctionCommands", "(", "void", ")", "{", "if", "(", "g_ulCommandFlags", "&", "COMMAND_TOUCH_UPDATE", ")", "{", "ProcessCommandTouchUpdate", "(", ")", ";", "g_ulCommandFlags", "&=", "~", "COMMAND_TOUCH_UPDATE", ";", "}", "if", "(", "g_ulCommandFlags", "&", "COMMAND_THUMB_UPDATE", ")", "{", "ProcessCommandThumbUpdate", "(", ")", ";", "g_ulCommandFlags", "&=", "~", "COMMAND_THUMB_UPDATE", ";", "}", "}" ]
Process any commands that the main function has been sent from other functions or interrupts.
[ "Process", "any", "commands", "that", "the", "main", "function", "has", "been", "sent", "from", "other", "functions", "or", "interrupts", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
690de3d1e99c2119ee4061b695cf2241b0fae07b
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/usb_stick_update/simple_fs.c
[ "BSD-3-Clause" ]
C
SimpleFsInit
null
unsigned long SimpleFsInit(unsigned char *pucSectorBuf) { tMasterBootRecord *pMBR; tPartitionTable *pPart; tBootSector *pBoot; // // Save the sector buffer pointer. The input parameter is assumed // to be good. // g_pucSectorBuf = pucSectorBuf; // // Get the MBR // if(SimpleFsReadMediaSector(0, pucSectorBuf)) { return(1); } // // Verify MBR signature - bare minimum validation of MBR. // pMBR = (tMasterBootRecord *)pucSectorBuf; if(pMBR->usSig != 0xAA55) { return(1); } // // See if this is a MBR or a boot sector. // pBoot = (tBootSector *)pucSectorBuf; if((strncmp(pBoot->ext.sExt16.cFsType, "FAT", 3) != 0) && (strncmp(pBoot->ext.sExt32.cFsType, "FAT32", 5) != 0)) { // // Get the first partition table // pPart = &(pMBR->sPartTable[0]); // // Could optionally check partition type here ... // // // Get the partition location and size // sPartInfo.ulFirstSector = pPart->ulFirstSector; sPartInfo.ulNumBlocks = pPart->ulNumBlocks; // // Read the boot sector from the partition // if(SimpleFsReadMediaSector(sPartInfo.ulFirstSector, pucSectorBuf)) { return(1); } } else { // // Extract the number of sectors from the boot sector. // sPartInfo.ulFirstSector = 0; if(pBoot->usTotalSectorsSmall == 0) { sPartInfo.ulNumBlocks = pBoot->ulTotalSectorsBig; } else { sPartInfo.ulNumBlocks = pBoot->usTotalSectorsSmall; } } // // Get pointer to the boot sector // if(pBoot->ext.sExt16.usSig != 0xAA55) { return(1); } // // Verify the sector size is 512. We can't deal with anything else // if(pBoot->usBytesPerSector != 512) { return(1); } // // Extract some info from the boot record // sPartInfo.usSectorsPerCluster = pBoot->ucSectorsPerCluster; sPartInfo.usMaxRootEntries = pBoot->usNumRootEntries; // // Decide if we are dealing with FAT16 or FAT32. // If number of root entries is 0, that suggests FAT32 // if(sPartInfo.usMaxRootEntries == 0) { // // Confirm FAT 32 signature in the expected place // if(!strncmp(pBoot->ext.sExt32.cFsType, "FAT32 ", 8)) { sPartInfo.ulType = 32; } else { return(1); } } // // Root entries is non-zero, suggests FAT16 // else { // // Confirm FAT16 signature // if(!strncmp(pBoot->ext.sExt16.cFsType, "FAT16 ", 8)) { sPartInfo.ulType = 16; } else { return(1); } } // // Find the beginning of the FAT, in absolute sectors // sPartInfo.ulFirstFATSector = sPartInfo.ulFirstSector + pBoot->usReservedSectors; // // Find the end of the FAT in absolute sectors. FAT16 and 32 // are handled differently. // sPartInfo.ulSectorsPerFAT = (sPartInfo.ulType == 16) ? pBoot->usSectorsPerFAT : pBoot->ext.sExt32.ulSectorsPerFAT; sPartInfo.ulLastFATSector = sPartInfo.ulFirstFATSector + sPartInfo.ulSectorsPerFAT - 1; // // Find the start of the root directory and the data area. // For FAT16, the root will be stored as an absolute sector number // For FAT32, the root will be stored as the starting cluster of the root // The data area start is the absolute first sector of the data area. // if(sPartInfo.ulType == 16) { sPartInfo.ulStartRootDir = sPartInfo.ulFirstFATSector + (sPartInfo.ulSectorsPerFAT * pBoot->ucNumFATs); sPartInfo.ulFirstDataSector = sPartInfo.ulStartRootDir + (sPartInfo.usMaxRootEntries / 16); } else { sPartInfo.ulStartRootDir = pBoot->ext.sExt32.ulRootCluster; sPartInfo.ulFirstDataSector = sPartInfo.ulFirstFATSector + (sPartInfo.ulSectorsPerFAT * pBoot->ucNumFATs); } // // At this point the file system has been initialized, so return // success to the caller. // return(0); }
//***************************************************************************** // //! Initializes the simple file system //! //! \param pucSectorBuf is a pointer to a caller supplied 512-byte buffer //! that will be used for holding sectors that are loaded from the media //! storage device. //! //! Reads the MBR, partition table, and boot record to find the logical //! structure of the file system. This function stores the file system //! structural data internally so that the remaining functions of the API //! can read the file system. //! //! To read data from the storage device, the function SimpleFsReadMediaSector() //! will be called. This function is not implemented here but must be //! implemented by the user of this simple file system. //! //! This file system support is extremely simple-minded. It will only //! find the first partition of a FAT16 or FAT32 formatted mass storage //! device. Only very minimal error checking is performed in order to save //! code space. //! //! \return Zero if successful, non-zero if there was an error. // //*****************************************************************************
Initializes the simple file system \param pucSectorBuf is a pointer to a caller supplied 512-byte buffer that will be used for holding sectors that are loaded from the media storage device. Reads the MBR, partition table, and boot record to find the logical structure of the file system. This function stores the file system structural data internally so that the remaining functions of the API can read the file system. To read data from the storage device, the function SimpleFsReadMediaSector() will be called. This function is not implemented here but must be implemented by the user of this simple file system. This file system support is extremely simple-minded. It will only find the first partition of a FAT16 or FAT32 formatted mass storage device. Only very minimal error checking is performed in order to save code space. \return Zero if successful, non-zero if there was an error.
[ "Initializes", "the", "simple", "file", "system", "\\", "param", "pucSectorBuf", "is", "a", "pointer", "to", "a", "caller", "supplied", "512", "-", "byte", "buffer", "that", "will", "be", "used", "for", "holding", "sectors", "that", "are", "loaded", "from", "the", "media", "storage", "device", ".", "Reads", "the", "MBR", "partition", "table", "and", "boot", "record", "to", "find", "the", "logical", "structure", "of", "the", "file", "system", ".", "This", "function", "stores", "the", "file", "system", "structural", "data", "internally", "so", "that", "the", "remaining", "functions", "of", "the", "API", "can", "read", "the", "file", "system", ".", "To", "read", "data", "from", "the", "storage", "device", "the", "function", "SimpleFsReadMediaSector", "()", "will", "be", "called", ".", "This", "function", "is", "not", "implemented", "here", "but", "must", "be", "implemented", "by", "the", "user", "of", "this", "simple", "file", "system", ".", "This", "file", "system", "support", "is", "extremely", "simple", "-", "minded", ".", "It", "will", "only", "find", "the", "first", "partition", "of", "a", "FAT16", "or", "FAT32", "formatted", "mass", "storage", "device", ".", "Only", "very", "minimal", "error", "checking", "is", "performed", "in", "order", "to", "save", "code", "space", ".", "\\", "return", "Zero", "if", "successful", "non", "-", "zero", "if", "there", "was", "an", "error", "." ]
unsigned long SimpleFsInit(unsigned char *pucSectorBuf) { tMasterBootRecord *pMBR; tPartitionTable *pPart; tBootSector *pBoot; g_pucSectorBuf = pucSectorBuf; if(SimpleFsReadMediaSector(0, pucSectorBuf)) { return(1); } pMBR = (tMasterBootRecord *)pucSectorBuf; if(pMBR->usSig != 0xAA55) { return(1); } pBoot = (tBootSector *)pucSectorBuf; if((strncmp(pBoot->ext.sExt16.cFsType, "FAT", 3) != 0) && (strncmp(pBoot->ext.sExt32.cFsType, "FAT32", 5) != 0)) { pPart = &(pMBR->sPartTable[0]); sPartInfo.ulFirstSector = pPart->ulFirstSector; sPartInfo.ulNumBlocks = pPart->ulNumBlocks; if(SimpleFsReadMediaSector(sPartInfo.ulFirstSector, pucSectorBuf)) { return(1); } } else { sPartInfo.ulFirstSector = 0; if(pBoot->usTotalSectorsSmall == 0) { sPartInfo.ulNumBlocks = pBoot->ulTotalSectorsBig; } else { sPartInfo.ulNumBlocks = pBoot->usTotalSectorsSmall; } } if(pBoot->ext.sExt16.usSig != 0xAA55) { return(1); } if(pBoot->usBytesPerSector != 512) { return(1); } sPartInfo.usSectorsPerCluster = pBoot->ucSectorsPerCluster; sPartInfo.usMaxRootEntries = pBoot->usNumRootEntries; if(sPartInfo.usMaxRootEntries == 0) { if(!strncmp(pBoot->ext.sExt32.cFsType, "FAT32 ", 8)) { sPartInfo.ulType = 32; } else { return(1); } } else { if(!strncmp(pBoot->ext.sExt16.cFsType, "FAT16 ", 8)) { sPartInfo.ulType = 16; } else { return(1); } } sPartInfo.ulFirstFATSector = sPartInfo.ulFirstSector + pBoot->usReservedSectors; sPartInfo.ulSectorsPerFAT = (sPartInfo.ulType == 16) ? pBoot->usSectorsPerFAT : pBoot->ext.sExt32.ulSectorsPerFAT; sPartInfo.ulLastFATSector = sPartInfo.ulFirstFATSector + sPartInfo.ulSectorsPerFAT - 1; if(sPartInfo.ulType == 16) { sPartInfo.ulStartRootDir = sPartInfo.ulFirstFATSector + (sPartInfo.ulSectorsPerFAT * pBoot->ucNumFATs); sPartInfo.ulFirstDataSector = sPartInfo.ulStartRootDir + (sPartInfo.usMaxRootEntries / 16); } else { sPartInfo.ulStartRootDir = pBoot->ext.sExt32.ulRootCluster; sPartInfo.ulFirstDataSector = sPartInfo.ulFirstFATSector + (sPartInfo.ulSectorsPerFAT * pBoot->ucNumFATs); } return(0); }
[ "unsigned", "long", "SimpleFsInit", "(", "unsigned", "char", "*", "pucSectorBuf", ")", "{", "tMasterBootRecord", "*", "pMBR", ";", "tPartitionTable", "*", "pPart", ";", "tBootSector", "*", "pBoot", ";", "g_pucSectorBuf", "=", "pucSectorBuf", ";", "if", "(", "SimpleFsReadMediaSector", "(", "0", ",", "pucSectorBuf", ")", ")", "{", "return", "(", "1", ")", ";", "}", "pMBR", "=", "(", "tMasterBootRecord", "*", ")", "pucSectorBuf", ";", "if", "(", "pMBR", "->", "usSig", "!=", "0xAA55", ")", "{", "return", "(", "1", ")", ";", "}", "pBoot", "=", "(", "tBootSector", "*", ")", "pucSectorBuf", ";", "if", "(", "(", "strncmp", "(", "pBoot", "->", "ext", ".", "sExt16", ".", "cFsType", ",", "\"", "\"", ",", "3", ")", "!=", "0", ")", "&&", "(", "strncmp", "(", "pBoot", "->", "ext", ".", "sExt32", ".", "cFsType", ",", "\"", "\"", ",", "5", ")", "!=", "0", ")", ")", "{", "pPart", "=", "&", "(", "pMBR", "->", "sPartTable", "[", "0", "]", ")", ";", "sPartInfo", ".", "ulFirstSector", "=", "pPart", "->", "ulFirstSector", ";", "sPartInfo", ".", "ulNumBlocks", "=", "pPart", "->", "ulNumBlocks", ";", "if", "(", "SimpleFsReadMediaSector", "(", "sPartInfo", ".", "ulFirstSector", ",", "pucSectorBuf", ")", ")", "{", "return", "(", "1", ")", ";", "}", "}", "else", "{", "sPartInfo", ".", "ulFirstSector", "=", "0", ";", "if", "(", "pBoot", "->", "usTotalSectorsSmall", "==", "0", ")", "{", "sPartInfo", ".", "ulNumBlocks", "=", "pBoot", "->", "ulTotalSectorsBig", ";", "}", "else", "{", "sPartInfo", ".", "ulNumBlocks", "=", "pBoot", "->", "usTotalSectorsSmall", ";", "}", "}", "if", "(", "pBoot", "->", "ext", ".", "sExt16", ".", "usSig", "!=", "0xAA55", ")", "{", "return", "(", "1", ")", ";", "}", "if", "(", "pBoot", "->", "usBytesPerSector", "!=", "512", ")", "{", "return", "(", "1", ")", ";", "}", "sPartInfo", ".", "usSectorsPerCluster", "=", "pBoot", "->", "ucSectorsPerCluster", ";", "sPartInfo", ".", "usMaxRootEntries", "=", "pBoot", "->", "usNumRootEntries", ";", "if", "(", "sPartInfo", ".", "usMaxRootEntries", "==", "0", ")", "{", "if", "(", "!", "strncmp", "(", "pBoot", "->", "ext", ".", "sExt32", ".", "cFsType", ",", "\"", "\"", ",", "8", ")", ")", "{", "sPartInfo", ".", "ulType", "=", "32", ";", "}", "else", "{", "return", "(", "1", ")", ";", "}", "}", "else", "{", "if", "(", "!", "strncmp", "(", "pBoot", "->", "ext", ".", "sExt16", ".", "cFsType", ",", "\"", "\"", ",", "8", ")", ")", "{", "sPartInfo", ".", "ulType", "=", "16", ";", "}", "else", "{", "return", "(", "1", ")", ";", "}", "}", "sPartInfo", ".", "ulFirstFATSector", "=", "sPartInfo", ".", "ulFirstSector", "+", "pBoot", "->", "usReservedSectors", ";", "sPartInfo", ".", "ulSectorsPerFAT", "=", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "?", "pBoot", "->", "usSectorsPerFAT", ":", "pBoot", "->", "ext", ".", "sExt32", ".", "ulSectorsPerFAT", ";", "sPartInfo", ".", "ulLastFATSector", "=", "sPartInfo", ".", "ulFirstFATSector", "+", "sPartInfo", ".", "ulSectorsPerFAT", "-", "1", ";", "if", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "{", "sPartInfo", ".", "ulStartRootDir", "=", "sPartInfo", ".", "ulFirstFATSector", "+", "(", "sPartInfo", ".", "ulSectorsPerFAT", "*", "pBoot", "->", "ucNumFATs", ")", ";", "sPartInfo", ".", "ulFirstDataSector", "=", "sPartInfo", ".", "ulStartRootDir", "+", "(", "sPartInfo", ".", "usMaxRootEntries", "/", "16", ")", ";", "}", "else", "{", "sPartInfo", ".", "ulStartRootDir", "=", "pBoot", "->", "ext", ".", "sExt32", ".", "ulRootCluster", ";", "sPartInfo", ".", "ulFirstDataSector", "=", "sPartInfo", ".", "ulFirstFATSector", "+", "(", "sPartInfo", ".", "ulSectorsPerFAT", "*", "pBoot", "->", "ucNumFATs", ")", ";", "}", "return", "(", "0", ")", ";", "}" ]
Initializes the simple file system \param pucSectorBuf is a pointer to a caller supplied 512-byte buffer that will be used for holding sectors that are loaded from the media storage device.
[ "Initializes", "the", "simple", "file", "system", "\\", "param", "pucSectorBuf", "is", "a", "pointer", "to", "a", "caller", "supplied", "512", "-", "byte", "buffer", "that", "will", "be", "used", "for", "holding", "sectors", "that", "are", "loaded", "from", "the", "media", "storage", "device", "." ]
[ "//\r", "// Save the sector buffer pointer. The input parameter is assumed\r", "// to be good.\r", "//\r", "//\r", "// Get the MBR\r", "//\r", "//\r", "// Verify MBR signature - bare minimum validation of MBR.\r", "//\r", "//\r", "// See if this is a MBR or a boot sector.\r", "//\r", "//\r", "// Get the first partition table\r", "//\r", "//\r", "// Could optionally check partition type here ...\r", "//\r", "//\r", "// Get the partition location and size\r", "//\r", "//\r", "// Read the boot sector from the partition\r", "//\r", "//\r", "// Extract the number of sectors from the boot sector.\r", "//\r", "//\r", "// Get pointer to the boot sector\r", "//\r", "//\r", "// Verify the sector size is 512. We can't deal with anything else\r", "//\r", "//\r", "// Extract some info from the boot record\r", "//\r", "//\r", "// Decide if we are dealing with FAT16 or FAT32.\r", "// If number of root entries is 0, that suggests FAT32\r", "//\r", "//\r", "// Confirm FAT 32 signature in the expected place\r", "//\r", "//\r", "// Root entries is non-zero, suggests FAT16\r", "//\r", "//\r", "// Confirm FAT16 signature\r", "//\r", "//\r", "// Find the beginning of the FAT, in absolute sectors\r", "//\r", "//\r", "// Find the end of the FAT in absolute sectors. FAT16 and 32\r", "// are handled differently.\r", "//\r", "//\r", "// Find the start of the root directory and the data area.\r", "// For FAT16, the root will be stored as an absolute sector number\r", "// For FAT32, the root will be stored as the starting cluster of the root\r", "// The data area start is the absolute first sector of the data area.\r", "//\r", "//\r", "// At this point the file system has been initialized, so return\r", "// success to the caller.\r", "//\r" ]
[ { "param": "pucSectorBuf", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pucSectorBuf", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
690de3d1e99c2119ee4061b695cf2241b0fae07b
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/usb_stick_update/simple_fs.c
[ "BSD-3-Clause" ]
C
SimpleFsGetNextCluster
null
static unsigned long SimpleFsGetNextCluster(unsigned long ulThisCluster) { static unsigned char ucFATCache[512]; static unsigned long ulCachedFATSector = (unsigned long)-1; unsigned long ulClustersPerFATSector; unsigned long ulClusterIdx; unsigned long ulFATSector; unsigned long ulNextCluster; unsigned long ulMaxCluster; // // Compute the maximum possible reasonable cluster number // ulMaxCluster = sPartInfo.ulNumBlocks / sPartInfo.usSectorsPerCluster; // // Make sure cluster input number is reasonable. If not then return // 0 indicating error. // if((ulThisCluster < 2) || (ulThisCluster > ulMaxCluster)) { return(0); } // // Compute the index of the requested cluster within the sector. // Also compute the sector number within the FAT that contains the // entry for the requested cluster. // ulClustersPerFATSector = (sPartInfo.ulType == 16) ? 256 : 128; ulClusterIdx = ulThisCluster % ulClustersPerFATSector; ulFATSector = ulThisCluster / ulClustersPerFATSector; // // Check to see if the FAT sector we need is already cached // if(ulFATSector != ulCachedFATSector) { // // FAT sector we need is not cached, so read it in // if(SimpleFsReadMediaSector(sPartInfo.ulFirstFATSector + ulFATSector, ucFATCache) != 0) { // // There was an error so mark cache as unavailable and return // an error. // ulCachedFATSector = (unsigned long)-1; return(0); } // // Remember which FAT sector was just loaded into the cache. // ulCachedFATSector = ulFATSector; } // // Now look up the next cluster value from the cached sector, using this // requested cluster as an index. It needs to be indexed as 16 or 32 // bit values depending on whether it is FAT16 or 32 // If the cluster value means last cluster, then return 0 // if(sPartInfo.ulType == 16) { ulNextCluster = ((unsigned short *)ucFATCache)[ulClusterIdx]; if(ulNextCluster >= 0xFFF8) { return(0); } } else { ulNextCluster = ((unsigned long *)ucFATCache)[ulClusterIdx]; if(ulNextCluster >= 0x0FFFFFF8) { return(0); } } // // Check new cluster value to make sure it is reasonable. If not then // return 0 to indicate an error. // if((ulNextCluster >= 2) && (ulNextCluster <= ulMaxCluster)) { return(ulNextCluster); } else { return(0); } }
//***************************************************************************** // //! Find the next cluster in a FAT chain //! //! \param ulThisCluster is the current cluster in the chain //! //! Reads the File Allocation Table (FAT) of the file system to find the //! next cluster in a chain of clusters. The current cluster is passed in //! and the next cluster in the chain will be returned. //! //! This function reads sectors from the storage device as needed in order //! to parse the FAT tables. Error handling is minimal since there is not //! much that can be done if an error is encountered. If any error is //! encountered, or if this is the last cluster in the chain, then 0 is //! returned. This signals the caller to stop traversing the chain (either //! due to error or end of chain). //! //! The function maintains a cache of a single sector from the FAT. It only //! reads in a new FAT sector if the requested cluster is not in the //! currently cached sector. //! //! \return Next cluster number if successful, 0 if this is the last cluster //! or any error is found. // //*****************************************************************************
Find the next cluster in a FAT chain \param ulThisCluster is the current cluster in the chain Reads the File Allocation Table (FAT) of the file system to find the next cluster in a chain of clusters. The current cluster is passed in and the next cluster in the chain will be returned. This function reads sectors from the storage device as needed in order to parse the FAT tables. Error handling is minimal since there is not much that can be done if an error is encountered. If any error is encountered, or if this is the last cluster in the chain, then 0 is returned. This signals the caller to stop traversing the chain (either due to error or end of chain). The function maintains a cache of a single sector from the FAT. It only reads in a new FAT sector if the requested cluster is not in the currently cached sector. \return Next cluster number if successful, 0 if this is the last cluster or any error is found.
[ "Find", "the", "next", "cluster", "in", "a", "FAT", "chain", "\\", "param", "ulThisCluster", "is", "the", "current", "cluster", "in", "the", "chain", "Reads", "the", "File", "Allocation", "Table", "(", "FAT", ")", "of", "the", "file", "system", "to", "find", "the", "next", "cluster", "in", "a", "chain", "of", "clusters", ".", "The", "current", "cluster", "is", "passed", "in", "and", "the", "next", "cluster", "in", "the", "chain", "will", "be", "returned", ".", "This", "function", "reads", "sectors", "from", "the", "storage", "device", "as", "needed", "in", "order", "to", "parse", "the", "FAT", "tables", ".", "Error", "handling", "is", "minimal", "since", "there", "is", "not", "much", "that", "can", "be", "done", "if", "an", "error", "is", "encountered", ".", "If", "any", "error", "is", "encountered", "or", "if", "this", "is", "the", "last", "cluster", "in", "the", "chain", "then", "0", "is", "returned", ".", "This", "signals", "the", "caller", "to", "stop", "traversing", "the", "chain", "(", "either", "due", "to", "error", "or", "end", "of", "chain", ")", ".", "The", "function", "maintains", "a", "cache", "of", "a", "single", "sector", "from", "the", "FAT", ".", "It", "only", "reads", "in", "a", "new", "FAT", "sector", "if", "the", "requested", "cluster", "is", "not", "in", "the", "currently", "cached", "sector", ".", "\\", "return", "Next", "cluster", "number", "if", "successful", "0", "if", "this", "is", "the", "last", "cluster", "or", "any", "error", "is", "found", "." ]
static unsigned long SimpleFsGetNextCluster(unsigned long ulThisCluster) { static unsigned char ucFATCache[512]; static unsigned long ulCachedFATSector = (unsigned long)-1; unsigned long ulClustersPerFATSector; unsigned long ulClusterIdx; unsigned long ulFATSector; unsigned long ulNextCluster; unsigned long ulMaxCluster; ulMaxCluster = sPartInfo.ulNumBlocks / sPartInfo.usSectorsPerCluster; if((ulThisCluster < 2) || (ulThisCluster > ulMaxCluster)) { return(0); } ulClustersPerFATSector = (sPartInfo.ulType == 16) ? 256 : 128; ulClusterIdx = ulThisCluster % ulClustersPerFATSector; ulFATSector = ulThisCluster / ulClustersPerFATSector; if(ulFATSector != ulCachedFATSector) { if(SimpleFsReadMediaSector(sPartInfo.ulFirstFATSector + ulFATSector, ucFATCache) != 0) { ulCachedFATSector = (unsigned long)-1; return(0); } ulCachedFATSector = ulFATSector; } if(sPartInfo.ulType == 16) { ulNextCluster = ((unsigned short *)ucFATCache)[ulClusterIdx]; if(ulNextCluster >= 0xFFF8) { return(0); } } else { ulNextCluster = ((unsigned long *)ucFATCache)[ulClusterIdx]; if(ulNextCluster >= 0x0FFFFFF8) { return(0); } } if((ulNextCluster >= 2) && (ulNextCluster <= ulMaxCluster)) { return(ulNextCluster); } else { return(0); } }
[ "static", "unsigned", "long", "SimpleFsGetNextCluster", "(", "unsigned", "long", "ulThisCluster", ")", "{", "static", "unsigned", "char", "ucFATCache", "[", "512", "]", ";", "static", "unsigned", "long", "ulCachedFATSector", "=", "(", "unsigned", "long", ")", "-1", ";", "unsigned", "long", "ulClustersPerFATSector", ";", "unsigned", "long", "ulClusterIdx", ";", "unsigned", "long", "ulFATSector", ";", "unsigned", "long", "ulNextCluster", ";", "unsigned", "long", "ulMaxCluster", ";", "ulMaxCluster", "=", "sPartInfo", ".", "ulNumBlocks", "/", "sPartInfo", ".", "usSectorsPerCluster", ";", "if", "(", "(", "ulThisCluster", "<", "2", ")", "||", "(", "ulThisCluster", ">", "ulMaxCluster", ")", ")", "{", "return", "(", "0", ")", ";", "}", "ulClustersPerFATSector", "=", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "?", "256", ":", "128", ";", "ulClusterIdx", "=", "ulThisCluster", "%", "ulClustersPerFATSector", ";", "ulFATSector", "=", "ulThisCluster", "/", "ulClustersPerFATSector", ";", "if", "(", "ulFATSector", "!=", "ulCachedFATSector", ")", "{", "if", "(", "SimpleFsReadMediaSector", "(", "sPartInfo", ".", "ulFirstFATSector", "+", "ulFATSector", ",", "ucFATCache", ")", "!=", "0", ")", "{", "ulCachedFATSector", "=", "(", "unsigned", "long", ")", "-1", ";", "return", "(", "0", ")", ";", "}", "ulCachedFATSector", "=", "ulFATSector", ";", "}", "if", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "{", "ulNextCluster", "=", "(", "(", "unsigned", "short", "*", ")", "ucFATCache", ")", "[", "ulClusterIdx", "]", ";", "if", "(", "ulNextCluster", ">=", "0xFFF8", ")", "{", "return", "(", "0", ")", ";", "}", "}", "else", "{", "ulNextCluster", "=", "(", "(", "unsigned", "long", "*", ")", "ucFATCache", ")", "[", "ulClusterIdx", "]", ";", "if", "(", "ulNextCluster", ">=", "0x0FFFFFF8", ")", "{", "return", "(", "0", ")", ";", "}", "}", "if", "(", "(", "ulNextCluster", ">=", "2", ")", "&&", "(", "ulNextCluster", "<=", "ulMaxCluster", ")", ")", "{", "return", "(", "ulNextCluster", ")", ";", "}", "else", "{", "return", "(", "0", ")", ";", "}", "}" ]
Find the next cluster in a FAT chain \param ulThisCluster is the current cluster in the chain
[ "Find", "the", "next", "cluster", "in", "a", "FAT", "chain", "\\", "param", "ulThisCluster", "is", "the", "current", "cluster", "in", "the", "chain" ]
[ "//\r", "// Compute the maximum possible reasonable cluster number\r", "//\r", "//\r", "// Make sure cluster input number is reasonable. If not then return\r", "// 0 indicating error.\r", "//\r", "//\r", "// Compute the index of the requested cluster within the sector.\r", "// Also compute the sector number within the FAT that contains the\r", "// entry for the requested cluster.\r", "//\r", "//\r", "// Check to see if the FAT sector we need is already cached\r", "//\r", "//\r", "// FAT sector we need is not cached, so read it in\r", "//\r", "//\r", "// There was an error so mark cache as unavailable and return\r", "// an error.\r", "//\r", "//\r", "// Remember which FAT sector was just loaded into the cache.\r", "//\r", "//\r", "// Now look up the next cluster value from the cached sector, using this\r", "// requested cluster as an index. It needs to be indexed as 16 or 32\r", "// bit values depending on whether it is FAT16 or 32\r", "// If the cluster value means last cluster, then return 0\r", "//\r", "//\r", "// Check new cluster value to make sure it is reasonable. If not then\r", "// return 0 to indicate an error.\r", "//\r" ]
[ { "param": "ulThisCluster", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulThisCluster", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
690de3d1e99c2119ee4061b695cf2241b0fae07b
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/usb_stick_update/simple_fs.c
[ "BSD-3-Clause" ]
C
SimpleFsGetNextFileSector
null
unsigned long SimpleFsGetNextFileSector(unsigned long ulStartCluster) { static unsigned long ulWorkingCluster = 0; static unsigned long ulWorkingSector; unsigned long ulReadSector; // // If user specified starting cluster, then init the working cluster // and sector values // if(ulStartCluster) { ulWorkingCluster = ulStartCluster; ulWorkingSector = 0; return(0); } // // Otherwise, make sure there is a valid working cluster already // else if(ulWorkingCluster == 0) { return(0); } // // If the current working sector is the same as sectors per cluster, // then that means that the next cluster needs to be loaded. // if(ulWorkingSector == sPartInfo.usSectorsPerCluster) { // // Get the next cluster in the chain for this file. // ulWorkingCluster = SimpleFsGetNextCluster(ulWorkingCluster); // // If the next cluster is valid, then reset the working sector // if(ulWorkingCluster) { ulWorkingSector = 0; } // // Next cluster is not valid, or this was the end of the chain. // Clear the working cluster and return an indication that no new // sector data was loaded. // else { ulWorkingCluster = 0; return(0); } } // // Calculate the sector to read from. It is the sector of the start // of the working cluster, plus the working sector (the sector within // the cluster), plus the offset to the start of the data area. // Note that the cluster needs to be reduced by 2 in order to index // properly into the data area. That is a feature of FAT file system. // ulReadSector = (ulWorkingCluster - 2) * sPartInfo.usSectorsPerCluster; ulReadSector += ulWorkingSector; ulReadSector += sPartInfo.ulFirstDataSector; // // Attempt to read the next sector from the cluster. If not successful, // then clear the working cluster and return a non-success indication. // if(SimpleFsReadMediaSector(ulReadSector, g_pucSectorBuf) != 0) { ulWorkingCluster = 0; return(0); } else { // // Read was successful. Increment to the next sector of the cluster // and return a success indication. // ulWorkingSector++; return(1); } }
//***************************************************************************** // //! Read a single sector from a file into the sector buffer //! //! \param ulStartCluster is the first cluster of the file, used to //! initialize the file read. Use 0 for successive sectors. //! //! Reads sectors in sequence from a file and stores the data in the sector //! buffer that was passed in the initial call to SimpleFsInit(). The function //! is initialized with the file to read by passing the starting cluster of //! the file. The function will initialize some static data and return. It //! does not read any file data when passed a starting cluster (and //! returns 0 - this is normal). //! //! Once the function has been initialized with the file's starting cluster, //! then successive calls should be made, passing a value of 0 for the //! cluster number. This tells the function to read the next sector from the //! file and store it in the sector buffer. The function remembers the last //! sector that was read, and each time it is called with a cluster value of //! 0, it will read the next sector. The function will traverse the FAT //! chain as needed to read all the sectors. When a sector has been //! successfully read from a file, the function will return non-zero. When //! there are no more sectors to read, or any error is encountered, the //! function will return 0. //! //! Note that the function always reads a whole sector, even if the end of //! a file does not fill the last sector. It is the responsibility of the //! caller to track the file size and to deal with a partially full last //! sector. //! //! \return Non-zero if a sector was read into the sector buffer, or //! 0 if there are no more sectors or if any error occurred. // //*****************************************************************************
Read a single sector from a file into the sector buffer \param ulStartCluster is the first cluster of the file, used to initialize the file read. Use 0 for successive sectors. Reads sectors in sequence from a file and stores the data in the sector buffer that was passed in the initial call to SimpleFsInit(). The function is initialized with the file to read by passing the starting cluster of the file. The function will initialize some static data and return. It does not read any file data when passed a starting cluster (and returns 0 - this is normal). Once the function has been initialized with the file's starting cluster, then successive calls should be made, passing a value of 0 for the cluster number. This tells the function to read the next sector from the file and store it in the sector buffer. The function remembers the last sector that was read, and each time it is called with a cluster value of 0, it will read the next sector. The function will traverse the FAT chain as needed to read all the sectors. When a sector has been successfully read from a file, the function will return non-zero. When there are no more sectors to read, or any error is encountered, the function will return 0. Note that the function always reads a whole sector, even if the end of a file does not fill the last sector. It is the responsibility of the caller to track the file size and to deal with a partially full last sector. \return Non-zero if a sector was read into the sector buffer, or 0 if there are no more sectors or if any error occurred.
[ "Read", "a", "single", "sector", "from", "a", "file", "into", "the", "sector", "buffer", "\\", "param", "ulStartCluster", "is", "the", "first", "cluster", "of", "the", "file", "used", "to", "initialize", "the", "file", "read", ".", "Use", "0", "for", "successive", "sectors", ".", "Reads", "sectors", "in", "sequence", "from", "a", "file", "and", "stores", "the", "data", "in", "the", "sector", "buffer", "that", "was", "passed", "in", "the", "initial", "call", "to", "SimpleFsInit", "()", ".", "The", "function", "is", "initialized", "with", "the", "file", "to", "read", "by", "passing", "the", "starting", "cluster", "of", "the", "file", ".", "The", "function", "will", "initialize", "some", "static", "data", "and", "return", ".", "It", "does", "not", "read", "any", "file", "data", "when", "passed", "a", "starting", "cluster", "(", "and", "returns", "0", "-", "this", "is", "normal", ")", ".", "Once", "the", "function", "has", "been", "initialized", "with", "the", "file", "'", "s", "starting", "cluster", "then", "successive", "calls", "should", "be", "made", "passing", "a", "value", "of", "0", "for", "the", "cluster", "number", ".", "This", "tells", "the", "function", "to", "read", "the", "next", "sector", "from", "the", "file", "and", "store", "it", "in", "the", "sector", "buffer", ".", "The", "function", "remembers", "the", "last", "sector", "that", "was", "read", "and", "each", "time", "it", "is", "called", "with", "a", "cluster", "value", "of", "0", "it", "will", "read", "the", "next", "sector", ".", "The", "function", "will", "traverse", "the", "FAT", "chain", "as", "needed", "to", "read", "all", "the", "sectors", ".", "When", "a", "sector", "has", "been", "successfully", "read", "from", "a", "file", "the", "function", "will", "return", "non", "-", "zero", ".", "When", "there", "are", "no", "more", "sectors", "to", "read", "or", "any", "error", "is", "encountered", "the", "function", "will", "return", "0", ".", "Note", "that", "the", "function", "always", "reads", "a", "whole", "sector", "even", "if", "the", "end", "of", "a", "file", "does", "not", "fill", "the", "last", "sector", ".", "It", "is", "the", "responsibility", "of", "the", "caller", "to", "track", "the", "file", "size", "and", "to", "deal", "with", "a", "partially", "full", "last", "sector", ".", "\\", "return", "Non", "-", "zero", "if", "a", "sector", "was", "read", "into", "the", "sector", "buffer", "or", "0", "if", "there", "are", "no", "more", "sectors", "or", "if", "any", "error", "occurred", "." ]
unsigned long SimpleFsGetNextFileSector(unsigned long ulStartCluster) { static unsigned long ulWorkingCluster = 0; static unsigned long ulWorkingSector; unsigned long ulReadSector; if(ulStartCluster) { ulWorkingCluster = ulStartCluster; ulWorkingSector = 0; return(0); } else if(ulWorkingCluster == 0) { return(0); } if(ulWorkingSector == sPartInfo.usSectorsPerCluster) { ulWorkingCluster = SimpleFsGetNextCluster(ulWorkingCluster); if(ulWorkingCluster) { ulWorkingSector = 0; } else { ulWorkingCluster = 0; return(0); } } ulReadSector = (ulWorkingCluster - 2) * sPartInfo.usSectorsPerCluster; ulReadSector += ulWorkingSector; ulReadSector += sPartInfo.ulFirstDataSector; if(SimpleFsReadMediaSector(ulReadSector, g_pucSectorBuf) != 0) { ulWorkingCluster = 0; return(0); } else { ulWorkingSector++; return(1); } }
[ "unsigned", "long", "SimpleFsGetNextFileSector", "(", "unsigned", "long", "ulStartCluster", ")", "{", "static", "unsigned", "long", "ulWorkingCluster", "=", "0", ";", "static", "unsigned", "long", "ulWorkingSector", ";", "unsigned", "long", "ulReadSector", ";", "if", "(", "ulStartCluster", ")", "{", "ulWorkingCluster", "=", "ulStartCluster", ";", "ulWorkingSector", "=", "0", ";", "return", "(", "0", ")", ";", "}", "else", "if", "(", "ulWorkingCluster", "==", "0", ")", "{", "return", "(", "0", ")", ";", "}", "if", "(", "ulWorkingSector", "==", "sPartInfo", ".", "usSectorsPerCluster", ")", "{", "ulWorkingCluster", "=", "SimpleFsGetNextCluster", "(", "ulWorkingCluster", ")", ";", "if", "(", "ulWorkingCluster", ")", "{", "ulWorkingSector", "=", "0", ";", "}", "else", "{", "ulWorkingCluster", "=", "0", ";", "return", "(", "0", ")", ";", "}", "}", "ulReadSector", "=", "(", "ulWorkingCluster", "-", "2", ")", "*", "sPartInfo", ".", "usSectorsPerCluster", ";", "ulReadSector", "+=", "ulWorkingSector", ";", "ulReadSector", "+=", "sPartInfo", ".", "ulFirstDataSector", ";", "if", "(", "SimpleFsReadMediaSector", "(", "ulReadSector", ",", "g_pucSectorBuf", ")", "!=", "0", ")", "{", "ulWorkingCluster", "=", "0", ";", "return", "(", "0", ")", ";", "}", "else", "{", "ulWorkingSector", "++", ";", "return", "(", "1", ")", ";", "}", "}" ]
Read a single sector from a file into the sector buffer \param ulStartCluster is the first cluster of the file, used to initialize the file read.
[ "Read", "a", "single", "sector", "from", "a", "file", "into", "the", "sector", "buffer", "\\", "param", "ulStartCluster", "is", "the", "first", "cluster", "of", "the", "file", "used", "to", "initialize", "the", "file", "read", "." ]
[ "//\r", "// If user specified starting cluster, then init the working cluster\r", "// and sector values\r", "//\r", "//\r", "// Otherwise, make sure there is a valid working cluster already\r", "//\r", "//\r", "// If the current working sector is the same as sectors per cluster,\r", "// then that means that the next cluster needs to be loaded.\r", "//\r", "//\r", "// Get the next cluster in the chain for this file.\r", "//\r", "//\r", "// If the next cluster is valid, then reset the working sector\r", "//\r", "//\r", "// Next cluster is not valid, or this was the end of the chain.\r", "// Clear the working cluster and return an indication that no new\r", "// sector data was loaded.\r", "//\r", "//\r", "// Calculate the sector to read from. It is the sector of the start\r", "// of the working cluster, plus the working sector (the sector within\r", "// the cluster), plus the offset to the start of the data area.\r", "// Note that the cluster needs to be reduced by 2 in order to index\r", "// properly into the data area. That is a feature of FAT file system.\r", "//\r", "//\r", "// Attempt to read the next sector from the cluster. If not successful,\r", "// then clear the working cluster and return a non-success indication.\r", "//\r", "//\r", "// Read was successful. Increment to the next sector of the cluster\r", "// and return a success indication.\r", "//\r" ]
[ { "param": "ulStartCluster", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulStartCluster", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
690de3d1e99c2119ee4061b695cf2241b0fae07b
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/usb_stick_update/simple_fs.c
[ "BSD-3-Clause" ]
C
SimpleFsOpen
null
unsigned long SimpleFsOpen(char *pcName83) { tDirEntry *pDirEntry; unsigned long ulDirSector; unsigned long ulFirstCluster; // // Find starting root dir sector, only used for FAT16 // If FAT32 then this is the first cluster of root dir // ulDirSector = sPartInfo.ulStartRootDir; // // For FAT32, root dir is like a file, so init a file read of the root dir // if(sPartInfo.ulType == 32) { SimpleFsGetNextFileSector(ulDirSector); } // // Search the root directory entry for the firmware file // while(1) { // // Read in a directory block. // if(sPartInfo.ulType == 16) { // // For FAT16, read in a sector of the root directory // if(SimpleFsReadMediaSector(ulDirSector, g_pucSectorBuf)) { return(0); } } else { // // For FAT32, the root directory is treated like a file. // The root directory sector will be loaded into the sector buf // if(SimpleFsGetNextFileSector(0) == 0) { return(0); } } // // Initialize the directory entry pointer to the first entry of // this sector. // pDirEntry = (tDirEntry *)g_pucSectorBuf; // // Iterate through all the directory entries in this sector // while((unsigned char *)pDirEntry < &g_pucSectorBuf[512]) { // // If the 8.3 filename of this entry matches the firmware // file name, then we have a match, so return a pointer to // this entry. // if(!strncmp(pDirEntry->cFileName, pcName83, 11)) { // // Compute the starting cluster of the file // ulFirstCluster = pDirEntry->usCluster; if(sPartInfo.ulType == 32) { // // For FAT32, add in the upper word of the // starting cluster number // ulFirstCluster += pDirEntry->usClusterHi << 16; } // // Initialize the start of the file // SimpleFsGetNextFileSector(ulFirstCluster); return(pDirEntry->ulFileSize); } // // Advance to the next entry in this sector. // pDirEntry++; } // // Need to get the next sector in the directory. Handled // differently depending on if this is FAT16 or 32 // if(sPartInfo.ulType == 16) { // // FAT16: advance sectors as long as there are more possible // entries. // sPartInfo.usMaxRootEntries -= 512 / 32; if(sPartInfo.usMaxRootEntries) { ulDirSector++; } else { // // Ran out of directory entries and didn't find the file, // so return a null. // return(0); } } else { // // FAT32: there is nothing to compute here. The next root // dir sector will be fetched at the top of the loop // } } }
//***************************************************************************** // //! Find a file in the root directory of the file system and open it for //! reading. //! //! \param pcName83 is an 11-character string that represents the 8.3 file //! name of the file to open. //! //! This function traverses the root directory of the file system to find //! the file name specified by the caller. Note that the file name must be //! an 8.3 file name that is 11 characters long. The first 8 characters are //! the base name and the last 3 characters are the extension. If there are //! fewer characters in the base name or extension, the name should be padded //! with spaces. For example "myfile.bn" has fewer than 11 characters, and //! should be passed with padding like this: "myfile bn ". Note the extra //! spaces, and that the dot ('.') is not part of the string that is passed //! to this function. //! //! If the file is found, then it initializes the file for reading, and returns //! the file length. The file can be read by making successive calls to //! SimpleFsReadFileSector(). //! //! The function only searches the root directory and ignores any //! subdirectories. It also ignores any long file name entries, looking only //! at the 8.3 file name for a match. //! //! \return The size of the file if it is found, or 0 if the file could not //! be found. // //*****************************************************************************
Find a file in the root directory of the file system and open it for reading. \param pcName83 is an 11-character string that represents the 8.3 file name of the file to open. This function traverses the root directory of the file system to find the file name specified by the caller. Note that the file name must be an 8.3 file name that is 11 characters long. The first 8 characters are the base name and the last 3 characters are the extension. If there are fewer characters in the base name or extension, the name should be padded with spaces. For example "myfile.bn" has fewer than 11 characters, and should be passed with padding like this: "myfile bn ". Note the extra spaces, and that the dot ('.') is not part of the string that is passed to this function. If the file is found, then it initializes the file for reading, and returns the file length. The file can be read by making successive calls to SimpleFsReadFileSector(). The function only searches the root directory and ignores any subdirectories. It also ignores any long file name entries, looking only at the 8.3 file name for a match. \return The size of the file if it is found, or 0 if the file could not be found.
[ "Find", "a", "file", "in", "the", "root", "directory", "of", "the", "file", "system", "and", "open", "it", "for", "reading", ".", "\\", "param", "pcName83", "is", "an", "11", "-", "character", "string", "that", "represents", "the", "8", ".", "3", "file", "name", "of", "the", "file", "to", "open", ".", "This", "function", "traverses", "the", "root", "directory", "of", "the", "file", "system", "to", "find", "the", "file", "name", "specified", "by", "the", "caller", ".", "Note", "that", "the", "file", "name", "must", "be", "an", "8", ".", "3", "file", "name", "that", "is", "11", "characters", "long", ".", "The", "first", "8", "characters", "are", "the", "base", "name", "and", "the", "last", "3", "characters", "are", "the", "extension", ".", "If", "there", "are", "fewer", "characters", "in", "the", "base", "name", "or", "extension", "the", "name", "should", "be", "padded", "with", "spaces", ".", "For", "example", "\"", "myfile", ".", "bn", "\"", "has", "fewer", "than", "11", "characters", "and", "should", "be", "passed", "with", "padding", "like", "this", ":", "\"", "myfile", "bn", "\"", ".", "Note", "the", "extra", "spaces", "and", "that", "the", "dot", "(", "'", ".", "'", ")", "is", "not", "part", "of", "the", "string", "that", "is", "passed", "to", "this", "function", ".", "If", "the", "file", "is", "found", "then", "it", "initializes", "the", "file", "for", "reading", "and", "returns", "the", "file", "length", ".", "The", "file", "can", "be", "read", "by", "making", "successive", "calls", "to", "SimpleFsReadFileSector", "()", ".", "The", "function", "only", "searches", "the", "root", "directory", "and", "ignores", "any", "subdirectories", ".", "It", "also", "ignores", "any", "long", "file", "name", "entries", "looking", "only", "at", "the", "8", ".", "3", "file", "name", "for", "a", "match", ".", "\\", "return", "The", "size", "of", "the", "file", "if", "it", "is", "found", "or", "0", "if", "the", "file", "could", "not", "be", "found", "." ]
unsigned long SimpleFsOpen(char *pcName83) { tDirEntry *pDirEntry; unsigned long ulDirSector; unsigned long ulFirstCluster; ulDirSector = sPartInfo.ulStartRootDir; if(sPartInfo.ulType == 32) { SimpleFsGetNextFileSector(ulDirSector); } while(1) { if(sPartInfo.ulType == 16) { if(SimpleFsReadMediaSector(ulDirSector, g_pucSectorBuf)) { return(0); } } else { if(SimpleFsGetNextFileSector(0) == 0) { return(0); } } pDirEntry = (tDirEntry *)g_pucSectorBuf; while((unsigned char *)pDirEntry < &g_pucSectorBuf[512]) { if(!strncmp(pDirEntry->cFileName, pcName83, 11)) { ulFirstCluster = pDirEntry->usCluster; if(sPartInfo.ulType == 32) { ulFirstCluster += pDirEntry->usClusterHi << 16; } SimpleFsGetNextFileSector(ulFirstCluster); return(pDirEntry->ulFileSize); } pDirEntry++; } if(sPartInfo.ulType == 16) { sPartInfo.usMaxRootEntries -= 512 / 32; if(sPartInfo.usMaxRootEntries) { ulDirSector++; } else { return(0); } } else { } } }
[ "unsigned", "long", "SimpleFsOpen", "(", "char", "*", "pcName83", ")", "{", "tDirEntry", "*", "pDirEntry", ";", "unsigned", "long", "ulDirSector", ";", "unsigned", "long", "ulFirstCluster", ";", "ulDirSector", "=", "sPartInfo", ".", "ulStartRootDir", ";", "if", "(", "sPartInfo", ".", "ulType", "==", "32", ")", "{", "SimpleFsGetNextFileSector", "(", "ulDirSector", ")", ";", "}", "while", "(", "1", ")", "{", "if", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "{", "if", "(", "SimpleFsReadMediaSector", "(", "ulDirSector", ",", "g_pucSectorBuf", ")", ")", "{", "return", "(", "0", ")", ";", "}", "}", "else", "{", "if", "(", "SimpleFsGetNextFileSector", "(", "0", ")", "==", "0", ")", "{", "return", "(", "0", ")", ";", "}", "}", "pDirEntry", "=", "(", "tDirEntry", "*", ")", "g_pucSectorBuf", ";", "while", "(", "(", "unsigned", "char", "*", ")", "pDirEntry", "<", "&", "g_pucSectorBuf", "[", "512", "]", ")", "{", "if", "(", "!", "strncmp", "(", "pDirEntry", "->", "cFileName", ",", "pcName83", ",", "11", ")", ")", "{", "ulFirstCluster", "=", "pDirEntry", "->", "usCluster", ";", "if", "(", "sPartInfo", ".", "ulType", "==", "32", ")", "{", "ulFirstCluster", "+=", "pDirEntry", "->", "usClusterHi", "<<", "16", ";", "}", "SimpleFsGetNextFileSector", "(", "ulFirstCluster", ")", ";", "return", "(", "pDirEntry", "->", "ulFileSize", ")", ";", "}", "pDirEntry", "++", ";", "}", "if", "(", "sPartInfo", ".", "ulType", "==", "16", ")", "{", "sPartInfo", ".", "usMaxRootEntries", "-=", "512", "/", "32", ";", "if", "(", "sPartInfo", ".", "usMaxRootEntries", ")", "{", "ulDirSector", "++", ";", "}", "else", "{", "return", "(", "0", ")", ";", "}", "}", "else", "{", "}", "}", "}" ]
Find a file in the root directory of the file system and open it for reading.
[ "Find", "a", "file", "in", "the", "root", "directory", "of", "the", "file", "system", "and", "open", "it", "for", "reading", "." ]
[ "//\r", "// Find starting root dir sector, only used for FAT16\r", "// If FAT32 then this is the first cluster of root dir\r", "//\r", "//\r", "// For FAT32, root dir is like a file, so init a file read of the root dir\r", "//\r", "//\r", "// Search the root directory entry for the firmware file\r", "//\r", "//\r", "// Read in a directory block.\r", "//\r", "//\r", "// For FAT16, read in a sector of the root directory\r", "//\r", "//\r", "// For FAT32, the root directory is treated like a file.\r", "// The root directory sector will be loaded into the sector buf\r", "//\r", "//\r", "// Initialize the directory entry pointer to the first entry of\r", "// this sector.\r", "//\r", "//\r", "// Iterate through all the directory entries in this sector\r", "//\r", "//\r", "// If the 8.3 filename of this entry matches the firmware\r", "// file name, then we have a match, so return a pointer to\r", "// this entry.\r", "//\r", "//\r", "// Compute the starting cluster of the file\r", "//\r", "//\r", "// For FAT32, add in the upper word of the\r", "// starting cluster number\r", "//\r", "//\r", "// Initialize the start of the file\r", "//\r", "//\r", "// Advance to the next entry in this sector.\r", "//\r", "//\r", "// Need to get the next sector in the directory. Handled\r", "// differently depending on if this is FAT16 or 32\r", "//\r", "//\r", "// FAT16: advance sectors as long as there are more possible\r", "// entries.\r", "//\r", "//\r", "// Ran out of directory entries and didn't find the file,\r", "// so return a null.\r", "//\r", "//\r", "// FAT32: there is nothing to compute here. The next root\r", "// dir sector will be fetched at the top of the loop\r", "//\r" ]
[ { "param": "pcName83", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pcName83", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
54e90191cec9cbf75aea19ab19194513946b8186
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/udma_demo/udma_demo.c
[ "BSD-3-Clause" ]
C
UART0IntHandler
void
void UART0IntHandler(void) { unsigned long ulStatus; unsigned long ulMode; // // Read the interrupt status of the UART. // ulStatus = ROM_UARTIntStatus(UART0_BASE, 1); // // Clear any pending status, even though there should be none since no UART // interrupts were enabled. If UART error interrupts were enabled, then // those interrupts could occur here and should be handled. Since uDMA is // used for both the RX and TX, then neither of those interrupts should be // enabled. // ROM_UARTIntClear(UART0_BASE, ulStatus); // // Check the DMA control table to see if the ping-pong "A" transfer is // complete. The "A" transfer uses receive buffer "A", and the primary // control structure. // ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT); // // If the primary control structure indicates stop, that means the "A" // receive buffer is done. The uDMA controller should still be receiving // data into the "B" buffer. // if(ulMode == UDMA_MODE_STOP) { // // Increment a counter to indicate data was received into buffer A. In // a real application this would be used to signal the main thread that // data was received so the main thread can process the data. // g_ulRxBufACount++; // // Set up the next transfer for the "A" buffer, using the primary // control structure. When the ongoing receive into the "B" buffer is // done, the uDMA controller will switch back to this one. This // example re-uses buffer A, but a more sophisticated application could // use a rotating set of buffers to increase the amount of time that // the main thread has to process the data in the buffer before it is // reused. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufA, sizeof(g_ucRxBufA)); } // // Check the DMA control table to see if the ping-pong "B" transfer is // complete. The "B" transfer uses receive buffer "B", and the alternate // control structure. // ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT); // // If the alternate control structure indicates stop, that means the "B" // receive buffer is done. The uDMA controller should still be receiving // data into the "A" buffer. // if(ulMode == UDMA_MODE_STOP) { // // Increment a counter to indicate data was received into buffer A. In // a real application this would be used to signal the main thread that // data was received so the main thread can process the data. // g_ulRxBufBCount++; // // Set up the next transfer for the "B" buffer, using the alternate // control structure. When the ongoing receive into the "A" buffer is // done, the uDMA controller will switch back to this one. This // example re-uses buffer B, but a more sophisticated application could // use a rotating set of buffers to increase the amount of time that // the main thread has to process the data in the buffer before it is // reused. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufB, sizeof(g_ucRxBufB)); } // // If the UART0 DMA TX channel is disabled, that means the TX DMA transfer // is done. // if(!ROM_uDMAChannelIsEnabled(UDMA_CHANNEL_UART0TX)) { // // Start another DMA transfer to UART0 TX. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_MODE_BASIC, g_ucTxBuf, (void *)(UART0_BASE + UART_O_DR), sizeof(g_ucTxBuf)); // // The uDMA TX channel must be re-enabled. // ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0TX); } }
//***************************************************************************** // // The interrupt handler for UART0. This interrupt will occur when a DMA // transfer is complete using the UART0 uDMA channel. It will also be // triggered if the peripheral signals an error. This interrupt handler will // switch between receive ping-pong buffers A and B. It will also restart a TX // uDMA transfer if the prior transfer is complete. This will keep the UART // running continuously (looping TX data back to RX). // //*****************************************************************************
The interrupt handler for UART0. This interrupt will occur when a DMA transfer is complete using the UART0 uDMA channel. It will also be triggered if the peripheral signals an error. This interrupt handler will switch between receive ping-pong buffers A and B. It will also restart a TX uDMA transfer if the prior transfer is complete. This will keep the UART running continuously (looping TX data back to RX).
[ "The", "interrupt", "handler", "for", "UART0", ".", "This", "interrupt", "will", "occur", "when", "a", "DMA", "transfer", "is", "complete", "using", "the", "UART0", "uDMA", "channel", ".", "It", "will", "also", "be", "triggered", "if", "the", "peripheral", "signals", "an", "error", ".", "This", "interrupt", "handler", "will", "switch", "between", "receive", "ping", "-", "pong", "buffers", "A", "and", "B", ".", "It", "will", "also", "restart", "a", "TX", "uDMA", "transfer", "if", "the", "prior", "transfer", "is", "complete", ".", "This", "will", "keep", "the", "UART", "running", "continuously", "(", "looping", "TX", "data", "back", "to", "RX", ")", "." ]
void UART0IntHandler(void) { unsigned long ulStatus; unsigned long ulMode; ulStatus = ROM_UARTIntStatus(UART0_BASE, 1); ROM_UARTIntClear(UART0_BASE, ulStatus); ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT); if(ulMode == UDMA_MODE_STOP) { g_ulRxBufACount++; ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufA, sizeof(g_ucRxBufA)); } ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT); if(ulMode == UDMA_MODE_STOP) { g_ulRxBufBCount++; ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufB, sizeof(g_ucRxBufB)); } if(!ROM_uDMAChannelIsEnabled(UDMA_CHANNEL_UART0TX)) { ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_MODE_BASIC, g_ucTxBuf, (void *)(UART0_BASE + UART_O_DR), sizeof(g_ucTxBuf)); ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0TX); } }
[ "void", "UART0IntHandler", "(", "void", ")", "{", "unsigned", "long", "ulStatus", ";", "unsigned", "long", "ulMode", ";", "ulStatus", "=", "ROM_UARTIntStatus", "(", "UART0_BASE", ",", "1", ")", ";", "ROM_UARTIntClear", "(", "UART0_BASE", ",", "ulStatus", ")", ";", "ulMode", "=", "ROM_uDMAChannelModeGet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_PRI_SELECT", ")", ";", "if", "(", "ulMode", "==", "UDMA_MODE_STOP", ")", "{", "g_ulRxBufACount", "++", ";", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_PRI_SELECT", ",", "UDMA_MODE_PINGPONG", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "g_ucRxBufA", ",", "sizeof", "(", "g_ucRxBufA", ")", ")", ";", "}", "ulMode", "=", "ROM_uDMAChannelModeGet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_ALT_SELECT", ")", ";", "if", "(", "ulMode", "==", "UDMA_MODE_STOP", ")", "{", "g_ulRxBufBCount", "++", ";", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_ALT_SELECT", ",", "UDMA_MODE_PINGPONG", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "g_ucRxBufB", ",", "sizeof", "(", "g_ucRxBufB", ")", ")", ";", "}", "if", "(", "!", "ROM_uDMAChannelIsEnabled", "(", "UDMA_CHANNEL_UART0TX", ")", ")", "{", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0TX", "|", "UDMA_PRI_SELECT", ",", "UDMA_MODE_BASIC", ",", "g_ucTxBuf", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "sizeof", "(", "g_ucTxBuf", ")", ")", ";", "ROM_uDMAChannelEnable", "(", "UDMA_CHANNEL_UART0TX", ")", ";", "}", "}" ]
The interrupt handler for UART0.
[ "The", "interrupt", "handler", "for", "UART0", "." ]
[ "//\r", "// Read the interrupt status of the UART.\r", "//\r", "//\r", "// Clear any pending status, even though there should be none since no UART\r", "// interrupts were enabled. If UART error interrupts were enabled, then\r", "// those interrupts could occur here and should be handled. Since uDMA is\r", "// used for both the RX and TX, then neither of those interrupts should be\r", "// enabled.\r", "//\r", "//\r", "// Check the DMA control table to see if the ping-pong \"A\" transfer is\r", "// complete. The \"A\" transfer uses receive buffer \"A\", and the primary\r", "// control structure.\r", "//\r", "//\r", "// If the primary control structure indicates stop, that means the \"A\"\r", "// receive buffer is done. The uDMA controller should still be receiving\r", "// data into the \"B\" buffer.\r", "//\r", "//\r", "// Increment a counter to indicate data was received into buffer A. In\r", "// a real application this would be used to signal the main thread that\r", "// data was received so the main thread can process the data.\r", "//\r", "//\r", "// Set up the next transfer for the \"A\" buffer, using the primary\r", "// control structure. When the ongoing receive into the \"B\" buffer is\r", "// done, the uDMA controller will switch back to this one. This\r", "// example re-uses buffer A, but a more sophisticated application could\r", "// use a rotating set of buffers to increase the amount of time that\r", "// the main thread has to process the data in the buffer before it is\r", "// reused.\r", "//\r", "//\r", "// Check the DMA control table to see if the ping-pong \"B\" transfer is\r", "// complete. The \"B\" transfer uses receive buffer \"B\", and the alternate\r", "// control structure.\r", "//\r", "//\r", "// If the alternate control structure indicates stop, that means the \"B\"\r", "// receive buffer is done. The uDMA controller should still be receiving\r", "// data into the \"A\" buffer.\r", "//\r", "//\r", "// Increment a counter to indicate data was received into buffer A. In\r", "// a real application this would be used to signal the main thread that\r", "// data was received so the main thread can process the data.\r", "//\r", "//\r", "// Set up the next transfer for the \"B\" buffer, using the alternate\r", "// control structure. When the ongoing receive into the \"A\" buffer is\r", "// done, the uDMA controller will switch back to this one. This\r", "// example re-uses buffer B, but a more sophisticated application could\r", "// use a rotating set of buffers to increase the amount of time that\r", "// the main thread has to process the data in the buffer before it is\r", "// reused.\r", "//\r", "//\r", "// If the UART0 DMA TX channel is disabled, that means the TX DMA transfer\r", "// is done.\r", "//\r", "//\r", "// Start another DMA transfer to UART0 TX.\r", "//\r", "//\r", "// The uDMA TX channel must be re-enabled.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
54e90191cec9cbf75aea19ab19194513946b8186
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/udma_demo/udma_demo.c
[ "BSD-3-Clause" ]
C
InitUART0Transfer
void
void InitUART0Transfer(void) { unsigned int uIdx; // // Fill the TX buffer with a simple data pattern. // for(uIdx = 0; uIdx < UART_TXBUF_SIZE; uIdx++) { g_ucTxBuf[uIdx] = uIdx; } // // Enable the UART peripheral, and configure it to operate even if the CPU // is in sleep. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); // // Configure the UART communication parameters. // ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); // // Set both the TX and RX trigger thresholds to 4. This will be used by // the uDMA controller to signal when more data should be transferred. The // uDMA TX and RX channels will be configured so that it can transfer 4 // bytes in a burst when the UART is ready to transfer more data. // ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); // // Enable the UART for operation, and enable the uDMA interface for both TX // and RX channels. // ROM_UARTEnable(UART0_BASE); ROM_UARTDMAEnable(UART0_BASE, UART_DMA_RX | UART_DMA_TX); // // This register write will set the UART to operate in loopback mode. Any // data sent on the TX output will be received on the RX input. // HWREG(UART0_BASE + UART_O_CTL) |= UART_CTL_LBE; // // Enable the UART peripheral interrupts. Note that no UART interrupts // were enabled, but the uDMA controller will cause an interrupt on the // UART interrupt signal when a uDMA transfer is complete. // ROM_IntEnable(INT_UART0); // // Put the attributes in a known state for the uDMA UART0RX channel. These // should already be disabled by default. // ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); // // Configure the control parameters for the primary control structure for // the UART RX channel. The primary contol structure is used for the "A" // part of the ping-pong receive. The transfer data size is 8 bits, the // source address does not increment since it will be reading from a // register. The destination address increment is byte 8-bit bytes. The // arbitration size is set to 4 to match the RX FIFO trigger threshold. // The uDMA controller will use a 4 byte burst transfer if possible. This // will be somewhat more effecient that single byte transfers. // ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); // // Configure the control parameters for the alternate control structure for // the UART RX channel. The alternate contol structure is used for the "B" // part of the ping-pong receive. The configuration is identical to the // primary/A control structure. // ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); // // Set up the transfer parameters for the UART RX primary control // structure. The mode is set to ping-pong, the transfer source is the // UART data register, and the destination is the receive "A" buffer. The // transfer size is set to match the size of the buffer. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufA, sizeof(g_ucRxBufA)); // // Set up the transfer parameters for the UART RX alternate control // structure. The mode is set to ping-pong, the transfer source is the // UART data register, and the destination is the receive "B" buffer. The // transfer size is set to match the size of the buffer. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufB, sizeof(g_ucRxBufB)); // // Put the attributes in a known state for the uDMA UART0TX channel. These // should already be disabled by default. // ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0TX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); // // Set the USEBURST attribute for the uDMA UART TX channel. This will // force the controller to always use a burst when transferring data from // the TX buffer to the UART. This is somewhat more effecient bus usage // than the default which allows single or burst transfers. // ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0TX, UDMA_ATTR_USEBURST); // // Configure the control parameters for the UART TX. The uDMA UART TX // channel is used to transfer a block of data from a buffer to the UART. // The data size is 8 bits. The source address increment is 8-bit bytes // since the data is coming from a buffer. The destination increment is // none since the data is to be written to the UART data register. The // arbitration size is set to 4, which matches the UART TX FIFO trigger // threshold. // ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_4); // // Set up the transfer parameters for the uDMA UART TX channel. This will // configure the transfer source and destination and the transfer size. // Basic mode is used because the peripheral is making the uDMA transfer // request. The source is the TX buffer and the destination is the UART // data register. // ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_MODE_BASIC, g_ucTxBuf, (void *)(UART0_BASE + UART_O_DR), sizeof(g_ucTxBuf)); // // Now both the uDMA UART TX and RX channels are primed to start a // transfer. As soon as the channels are enabled, the peripheral will // issue a transfer request and the data transfers will begin. // ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX); ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0TX); }
//***************************************************************************** // // Initializes the UART0 peripheral and sets up the TX and RX uDMA channels. // The UART is configured for loopback mode so that any data sent on TX will be // received on RX. The uDMA channels are configured so that the TX channel // will copy data from a buffer to the UART TX output. And the uDMA RX channel // will receive any incoming data into a pair of buffers in ping-pong mode. // //*****************************************************************************
Initializes the UART0 peripheral and sets up the TX and RX uDMA channels. The UART is configured for loopback mode so that any data sent on TX will be received on RX. The uDMA channels are configured so that the TX channel will copy data from a buffer to the UART TX output. And the uDMA RX channel will receive any incoming data into a pair of buffers in ping-pong mode.
[ "Initializes", "the", "UART0", "peripheral", "and", "sets", "up", "the", "TX", "and", "RX", "uDMA", "channels", ".", "The", "UART", "is", "configured", "for", "loopback", "mode", "so", "that", "any", "data", "sent", "on", "TX", "will", "be", "received", "on", "RX", ".", "The", "uDMA", "channels", "are", "configured", "so", "that", "the", "TX", "channel", "will", "copy", "data", "from", "a", "buffer", "to", "the", "UART", "TX", "output", ".", "And", "the", "uDMA", "RX", "channel", "will", "receive", "any", "incoming", "data", "into", "a", "pair", "of", "buffers", "in", "ping", "-", "pong", "mode", "." ]
void InitUART0Transfer(void) { unsigned int uIdx; for(uIdx = 0; uIdx < UART_TXBUF_SIZE; uIdx++) { g_ucTxBuf[uIdx] = uIdx; } ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); ROM_UARTEnable(UART0_BASE); ROM_UARTDMAEnable(UART0_BASE, UART_DMA_RX | UART_DMA_TX); HWREG(UART0_BASE + UART_O_CTL) |= UART_CTL_LBE; ROM_IntEnable(INT_UART0); ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufA, sizeof(g_ucRxBufA)); ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_ucRxBufB, sizeof(g_ucRxBufB)); ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0TX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0TX, UDMA_ATTR_USEBURST); ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_4); ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_MODE_BASIC, g_ucTxBuf, (void *)(UART0_BASE + UART_O_DR), sizeof(g_ucTxBuf)); ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX); ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0TX); }
[ "void", "InitUART0Transfer", "(", "void", ")", "{", "unsigned", "int", "uIdx", ";", "for", "(", "uIdx", "=", "0", ";", "uIdx", "<", "UART_TXBUF_SIZE", ";", "uIdx", "++", ")", "{", "g_ucTxBuf", "[", "uIdx", "]", "=", "uIdx", ";", "}", "ROM_SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_UART0", ")", ";", "ROM_SysCtlPeripheralSleepEnable", "(", "SYSCTL_PERIPH_UART0", ")", ";", "ROM_UARTConfigSetExpClk", "(", "UART0_BASE", ",", "ROM_SysCtlClockGet", "(", ")", ",", "115200", ",", "UART_CONFIG_WLEN_8", "|", "UART_CONFIG_STOP_ONE", "|", "UART_CONFIG_PAR_NONE", ")", ";", "ROM_UARTFIFOLevelSet", "(", "UART0_BASE", ",", "UART_FIFO_TX4_8", ",", "UART_FIFO_RX4_8", ")", ";", "ROM_UARTEnable", "(", "UART0_BASE", ")", ";", "ROM_UARTDMAEnable", "(", "UART0_BASE", ",", "UART_DMA_RX", "|", "UART_DMA_TX", ")", ";", "HWREG", "(", "UART0_BASE", "+", "UART_O_CTL", ")", "|=", "UART_CTL_LBE", ";", "ROM_IntEnable", "(", "INT_UART0", ")", ";", "ROM_uDMAChannelAttributeDisable", "(", "UDMA_CHANNEL_UART0RX", ",", "UDMA_ATTR_ALTSELECT", "|", "UDMA_ATTR_USEBURST", "|", "UDMA_ATTR_HIGH_PRIORITY", "|", "UDMA_ATTR_REQMASK", ")", ";", "ROM_uDMAChannelControlSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_PRI_SELECT", ",", "UDMA_SIZE_8", "|", "UDMA_SRC_INC_NONE", "|", "UDMA_DST_INC_8", "|", "UDMA_ARB_4", ")", ";", "ROM_uDMAChannelControlSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_ALT_SELECT", ",", "UDMA_SIZE_8", "|", "UDMA_SRC_INC_NONE", "|", "UDMA_DST_INC_8", "|", "UDMA_ARB_4", ")", ";", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_PRI_SELECT", ",", "UDMA_MODE_PINGPONG", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "g_ucRxBufA", ",", "sizeof", "(", "g_ucRxBufA", ")", ")", ";", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0RX", "|", "UDMA_ALT_SELECT", ",", "UDMA_MODE_PINGPONG", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "g_ucRxBufB", ",", "sizeof", "(", "g_ucRxBufB", ")", ")", ";", "ROM_uDMAChannelAttributeDisable", "(", "UDMA_CHANNEL_UART0TX", ",", "UDMA_ATTR_ALTSELECT", "|", "UDMA_ATTR_HIGH_PRIORITY", "|", "UDMA_ATTR_REQMASK", ")", ";", "ROM_uDMAChannelAttributeEnable", "(", "UDMA_CHANNEL_UART0TX", ",", "UDMA_ATTR_USEBURST", ")", ";", "ROM_uDMAChannelControlSet", "(", "UDMA_CHANNEL_UART0TX", "|", "UDMA_PRI_SELECT", ",", "UDMA_SIZE_8", "|", "UDMA_SRC_INC_8", "|", "UDMA_DST_INC_NONE", "|", "UDMA_ARB_4", ")", ";", "ROM_uDMAChannelTransferSet", "(", "UDMA_CHANNEL_UART0TX", "|", "UDMA_PRI_SELECT", ",", "UDMA_MODE_BASIC", ",", "g_ucTxBuf", ",", "(", "void", "*", ")", "(", "UART0_BASE", "+", "UART_O_DR", ")", ",", "sizeof", "(", "g_ucTxBuf", ")", ")", ";", "ROM_uDMAChannelEnable", "(", "UDMA_CHANNEL_UART0RX", ")", ";", "ROM_uDMAChannelEnable", "(", "UDMA_CHANNEL_UART0TX", ")", ";", "}" ]
Initializes the UART0 peripheral and sets up the TX and RX uDMA channels.
[ "Initializes", "the", "UART0", "peripheral", "and", "sets", "up", "the", "TX", "and", "RX", "uDMA", "channels", "." ]
[ "//\r", "// Fill the TX buffer with a simple data pattern.\r", "//\r", "//\r", "// Enable the UART peripheral, and configure it to operate even if the CPU\r", "// is in sleep.\r", "//\r", "//\r", "// Configure the UART communication parameters.\r", "//\r", "//\r", "// Set both the TX and RX trigger thresholds to 4. This will be used by\r", "// the uDMA controller to signal when more data should be transferred. The\r", "// uDMA TX and RX channels will be configured so that it can transfer 4\r", "// bytes in a burst when the UART is ready to transfer more data.\r", "//\r", "//\r", "// Enable the UART for operation, and enable the uDMA interface for both TX\r", "// and RX channels.\r", "//\r", "//\r", "// This register write will set the UART to operate in loopback mode. Any\r", "// data sent on the TX output will be received on the RX input.\r", "//\r", "//\r", "// Enable the UART peripheral interrupts. Note that no UART interrupts\r", "// were enabled, but the uDMA controller will cause an interrupt on the\r", "// UART interrupt signal when a uDMA transfer is complete.\r", "//\r", "//\r", "// Put the attributes in a known state for the uDMA UART0RX channel. These\r", "// should already be disabled by default.\r", "//\r", "//\r", "// Configure the control parameters for the primary control structure for\r", "// the UART RX channel. The primary contol structure is used for the \"A\"\r", "// part of the ping-pong receive. The transfer data size is 8 bits, the\r", "// source address does not increment since it will be reading from a\r", "// register. The destination address increment is byte 8-bit bytes. The\r", "// arbitration size is set to 4 to match the RX FIFO trigger threshold.\r", "// The uDMA controller will use a 4 byte burst transfer if possible. This\r", "// will be somewhat more effecient that single byte transfers.\r", "//\r", "//\r", "// Configure the control parameters for the alternate control structure for\r", "// the UART RX channel. The alternate contol structure is used for the \"B\"\r", "// part of the ping-pong receive. The configuration is identical to the\r", "// primary/A control structure.\r", "//\r", "//\r", "// Set up the transfer parameters for the UART RX primary control\r", "// structure. The mode is set to ping-pong, the transfer source is the\r", "// UART data register, and the destination is the receive \"A\" buffer. The\r", "// transfer size is set to match the size of the buffer.\r", "//\r", "//\r", "// Set up the transfer parameters for the UART RX alternate control\r", "// structure. The mode is set to ping-pong, the transfer source is the\r", "// UART data register, and the destination is the receive \"B\" buffer. The\r", "// transfer size is set to match the size of the buffer.\r", "//\r", "//\r", "// Put the attributes in a known state for the uDMA UART0TX channel. These\r", "// should already be disabled by default.\r", "//\r", "//\r", "// Set the USEBURST attribute for the uDMA UART TX channel. This will\r", "// force the controller to always use a burst when transferring data from\r", "// the TX buffer to the UART. This is somewhat more effecient bus usage\r", "// than the default which allows single or burst transfers.\r", "//\r", "//\r", "// Configure the control parameters for the UART TX. The uDMA UART TX\r", "// channel is used to transfer a block of data from a buffer to the UART.\r", "// The data size is 8 bits. The source address increment is 8-bit bytes\r", "// since the data is coming from a buffer. The destination increment is\r", "// none since the data is to be written to the UART data register. The\r", "// arbitration size is set to 4, which matches the UART TX FIFO trigger\r", "// threshold.\r", "//\r", "//\r", "// Set up the transfer parameters for the uDMA UART TX channel. This will\r", "// configure the transfer source and destination and the transfer size.\r", "// Basic mode is used because the peripheral is making the uDMA transfer\r", "// request. The source is the TX buffer and the destination is the UART\r", "// data register.\r", "//\r", "//\r", "// Now both the uDMA UART TX and RX channels are primed to start a\r", "// transfer. As soon as the channels are enabled, the peripheral will\r", "// issue a transfer request and the data transfers will begin.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
dequeue_packet
null
static struct pbuf * dequeue_packet(struct pbufq *q) { struct pbuf *pBuf; SYS_ARCH_DECL_PROTECT(lev); /** * This entire function must run within a "critical section" to preserve * the integrity of the transmit pbuf queue. * */ SYS_ARCH_PROTECT(lev); if(PBUF_QUEUE_EMPTY(q)) { /* Return a NULL pointer if the queue is empty. */ pBuf = (struct pbuf *)NULL; } else { /** * The queue is not empty so return the next frame from it * and adjust the read pointer accordingly. * */ pBuf = q->pbuf[q->qread]; q->qread = ((q->qread + 1) % STELLARIS_NUM_PBUF_QUEUE); } /* Return to prior interrupt state and return the pbuf pointer. */ SYS_ARCH_UNPROTECT(lev); return(pBuf); }
/** * Pop a pbuf packet from a pbuf packet queue * * @param q is the packet queue from which to pop the pbuf. * * @return pointer to pbuf packet if available, NULL otherswise. */
Pop a pbuf packet from a pbuf packet queue @param q is the packet queue from which to pop the pbuf. @return pointer to pbuf packet if available, NULL otherswise.
[ "Pop", "a", "pbuf", "packet", "from", "a", "pbuf", "packet", "queue", "@param", "q", "is", "the", "packet", "queue", "from", "which", "to", "pop", "the", "pbuf", ".", "@return", "pointer", "to", "pbuf", "packet", "if", "available", "NULL", "otherswise", "." ]
static struct pbuf * dequeue_packet(struct pbufq *q) { struct pbuf *pBuf; SYS_ARCH_DECL_PROTECT(lev); SYS_ARCH_PROTECT(lev); if(PBUF_QUEUE_EMPTY(q)) { pBuf = (struct pbuf *)NULL; } else { pBuf = q->pbuf[q->qread]; q->qread = ((q->qread + 1) % STELLARIS_NUM_PBUF_QUEUE); } SYS_ARCH_UNPROTECT(lev); return(pBuf); }
[ "static", "struct", "pbuf", "*", "dequeue_packet", "(", "struct", "pbufq", "*", "q", ")", "{", "struct", "pbuf", "*", "pBuf", ";", "SYS_ARCH_DECL_PROTECT", "(", "lev", ")", ";", "SYS_ARCH_PROTECT", "(", "lev", ")", ";", "if", "(", "PBUF_QUEUE_EMPTY", "(", "q", ")", ")", "{", "pBuf", "=", "(", "struct", "pbuf", "*", ")", "NULL", ";", "}", "else", "{", "pBuf", "=", "q", "->", "pbuf", "[", "q", "->", "qread", "]", ";", "q", "->", "qread", "=", "(", "(", "q", "->", "qread", "+", "1", ")", "%", "STELLARIS_NUM_PBUF_QUEUE", ")", ";", "}", "SYS_ARCH_UNPROTECT", "(", "lev", ")", ";", "return", "(", "pBuf", ")", ";", "}" ]
Pop a pbuf packet from a pbuf packet queue
[ "Pop", "a", "pbuf", "packet", "from", "a", "pbuf", "packet", "queue" ]
[ "/**\r\n * This entire function must run within a \"critical section\" to preserve\r\n * the integrity of the transmit pbuf queue.\r\n *\r\n */", "/* Return a NULL pointer if the queue is empty. */", "/**\r\n * The queue is not empty so return the next frame from it\r\n * and adjust the read pointer accordingly.\r\n *\r\n */", "/* Return to prior interrupt state and return the pbuf pointer. */" ]
[ { "param": "q", "type": "struct pbufq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "struct pbufq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
enqueue_packet
int
static int enqueue_packet(struct pbuf *p, struct pbufq *q) { SYS_ARCH_DECL_PROTECT(lev); int ret; /** * This entire function must run within a "critical section" to preserve * the integrity of the transmit pbuf queue. * */ SYS_ARCH_PROTECT(lev); if(!PBUF_QUEUE_FULL(q)) { /** * The queue isn't full so we add the new frame at the current * write position and move the write pointer. * */ q->pbuf[q->qwrite] = p; q->qwrite = ((q->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE); ret = 1; } else { /** * The stack is full so we are throwing away this value. Keep track * of the number of times this happens. * */ q->overflow++; ret = 0; } /* Return to prior interrupt state and return the pbuf pointer. */ SYS_ARCH_UNPROTECT(lev); return(ret); }
/** * Push a pbuf packet onto a pbuf packet queue * * @param p is the pbuf to push onto the packet queue. * @param q is the packet queue. * * @return 1 if successful, 0 if q is full. */
Push a pbuf packet onto a pbuf packet queue @param p is the pbuf to push onto the packet queue. @param q is the packet queue. @return 1 if successful, 0 if q is full.
[ "Push", "a", "pbuf", "packet", "onto", "a", "pbuf", "packet", "queue", "@param", "p", "is", "the", "pbuf", "to", "push", "onto", "the", "packet", "queue", ".", "@param", "q", "is", "the", "packet", "queue", ".", "@return", "1", "if", "successful", "0", "if", "q", "is", "full", "." ]
static int enqueue_packet(struct pbuf *p, struct pbufq *q) { SYS_ARCH_DECL_PROTECT(lev); int ret; SYS_ARCH_PROTECT(lev); if(!PBUF_QUEUE_FULL(q)) { q->pbuf[q->qwrite] = p; q->qwrite = ((q->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE); ret = 1; } else { q->overflow++; ret = 0; } SYS_ARCH_UNPROTECT(lev); return(ret); }
[ "static", "int", "enqueue_packet", "(", "struct", "pbuf", "*", "p", ",", "struct", "pbufq", "*", "q", ")", "{", "SYS_ARCH_DECL_PROTECT", "(", "lev", ")", ";", "int", "ret", ";", "SYS_ARCH_PROTECT", "(", "lev", ")", ";", "if", "(", "!", "PBUF_QUEUE_FULL", "(", "q", ")", ")", "{", "q", "->", "pbuf", "[", "q", "->", "qwrite", "]", "=", "p", ";", "q", "->", "qwrite", "=", "(", "(", "q", "->", "qwrite", "+", "1", ")", "%", "STELLARIS_NUM_PBUF_QUEUE", ")", ";", "ret", "=", "1", ";", "}", "else", "{", "q", "->", "overflow", "++", ";", "ret", "=", "0", ";", "}", "SYS_ARCH_UNPROTECT", "(", "lev", ")", ";", "return", "(", "ret", ")", ";", "}" ]
Push a pbuf packet onto a pbuf packet queue
[ "Push", "a", "pbuf", "packet", "onto", "a", "pbuf", "packet", "queue" ]
[ "/**\r\n * This entire function must run within a \"critical section\" to preserve\r\n * the integrity of the transmit pbuf queue.\r\n *\r\n */", "/**\r\n * The queue isn't full so we add the new frame at the current\r\n * write position and move the write pointer.\r\n *\r\n */", "/**\r\n * The stack is full so we are throwing away this value. Keep track\r\n * of the number of times this happens.\r\n *\r\n */", "/* Return to prior interrupt state and return the pbuf pointer. */" ]
[ { "param": "p", "type": "struct pbuf" }, { "param": "q", "type": "struct pbufq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "struct pbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "q", "type": "struct pbufq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_hwinit
void
static void stellarisif_hwinit(struct netif *netif) { u32_t temp; //struct stellarisif *stellarisif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0])); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* Do whatever else is needed to initialize interface. */ /* Disable all Ethernet Interrupts. */ EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, temp); /* Initialize the Ethernet Controller. */ EthernetInitExpClk(ETH_BASE, SysCtlClockGet()); /* * Configure the Ethernet Controller for normal operation. * - Enable TX Duplex Mode * - Enable TX Padding * - Enable TX CRC Generation * - Enable RX Multicast Reception */ EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); /* Enable the Ethernet Controller transmitter and receiver. */ EthernetEnable(ETH_BASE); /* Enable the Ethernet Interrupt handler. */ IntEnable(INT_ETH); /* Enable Ethernet TX and RX Packet Interrupts. */ EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX); }
/** * In this function, the hardware should be initialized. * Called from stellarisif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */
In this function, the hardware should be initialized. @param netif the already initialized lwip network interface structure for this ethernetif
[ "In", "this", "function", "the", "hardware", "should", "be", "initialized", ".", "@param", "netif", "the", "already", "initialized", "lwip", "network", "interface", "structure", "for", "this", "ethernetif" ]
static void stellarisif_hwinit(struct netif *netif) { u32_t temp; netif->hwaddr_len = ETHARP_HWADDR_LEN; EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0])); netif->mtu = 1500; netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, temp); EthernetInitExpClk(ETH_BASE, SysCtlClockGet()); EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); EthernetEnable(ETH_BASE); IntEnable(INT_ETH); EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX); }
[ "static", "void", "stellarisif_hwinit", "(", "struct", "netif", "*", "netif", ")", "{", "u32_t", "temp", ";", "netif", "->", "hwaddr_len", "=", "ETHARP_HWADDR_LEN", ";", "EthernetMACAddrGet", "(", "ETH_BASE", ",", "&", "(", "netif", "->", "hwaddr", "[", "0", "]", ")", ")", ";", "netif", "->", "mtu", "=", "1500", ";", "netif", "->", "flags", "=", "NETIF_FLAG_BROADCAST", "|", "NETIF_FLAG_ETHARP", "|", "NETIF_FLAG_LINK_UP", ";", "EthernetIntDisable", "(", "ETH_BASE", ",", "(", "ETH_INT_PHY", "|", "ETH_INT_MDIO", "|", "ETH_INT_RXER", "|", "ETH_INT_RXOF", "|", "ETH_INT_TX", "|", "ETH_INT_TXER", "|", "ETH_INT_RX", ")", ")", ";", "temp", "=", "EthernetIntStatus", "(", "ETH_BASE", ",", "false", ")", ";", "EthernetIntClear", "(", "ETH_BASE", ",", "temp", ")", ";", "EthernetInitExpClk", "(", "ETH_BASE", ",", "SysCtlClockGet", "(", ")", ")", ";", "EthernetConfigSet", "(", "ETH_BASE", ",", "(", "ETH_CFG_TX_DPLXEN", "|", "ETH_CFG_TX_CRCEN", "|", "ETH_CFG_TX_PADEN", "|", "ETH_CFG_RX_AMULEN", ")", ")", ";", "EthernetEnable", "(", "ETH_BASE", ")", ";", "IntEnable", "(", "INT_ETH", ")", ";", "EthernetIntEnable", "(", "ETH_BASE", ",", "ETH_INT_RX", "|", "ETH_INT_TX", ")", ";", "}" ]
In this function, the hardware should be initialized.
[ "In", "this", "function", "the", "hardware", "should", "be", "initialized", "." ]
[ "//struct stellarisif *stellarisif = netif->state;\r", "/* set MAC hardware address length */", "/* set MAC hardware address */", "/* maximum transfer unit */", "/* device capabilities */", "/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */", "/* Do whatever else is needed to initialize interface. */", "/* Disable all Ethernet Interrupts. */", "/* Initialize the Ethernet Controller. */", "/*\r\n * Configure the Ethernet Controller for normal operation.\r\n * - Enable TX Duplex Mode\r\n * - Enable TX Padding\r\n * - Enable TX CRC Generation\r\n * - Enable RX Multicast Reception\r\n */", "/* Enable the Ethernet Controller transmitter and receiver. */", "/* Enable the Ethernet Interrupt handler. */", "/* Enable Ethernet TX and RX Packet Interrupts. */" ]
[ { "param": "netif", "type": "struct netif" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_transmit
err_t
static err_t stellarisif_transmit(struct netif *netif, struct pbuf *p) { int iBuf; unsigned char *pucBuf; unsigned long *pulBuf; struct pbuf *q; int iGather; unsigned long ulGather; unsigned char *pucGather; /** * Fill in the first two bytes of the payload data (configured as padding * with ETH_PAD_SIZE = 2) with the total length of the payload data * (minus the Ethernet MAC layer header). * */ *((unsigned short *)(p->payload)) = p->tot_len - 16; /* Initialize the gather register. */ iGather = 0; pucGather = (unsigned char *)&ulGather; ulGather = 0; /* Copy data from the pbuf(s) into the TX Fifo. */ for(q = p; q != NULL; q = q->next) { /* Intialize a char pointer and index to the pbuf payload data. */ pucBuf = (unsigned char *)q->payload; iBuf = 0; /** * If the gather buffer has leftover data from a previous pbuf * in the chain, fill it up and write it to the Tx FIFO. * */ while((iBuf < q->len) && (iGather != 0)) { /* Copy a byte from the pbuf into the gather buffer. */ pucGather[iGather] = pucBuf[iBuf++]; /* Increment the gather buffer index modulo 4. */ iGather = ((iGather + 1) % 4); } /** * If the gather index is 0 and the pbuf index is non-zero, * we have a gather buffer to write into the Tx FIFO. * */ if((iGather == 0) && (iBuf != 0)) { HWREG(ETH_BASE + MAC_O_DATA) = ulGather; ulGather = 0; } /* Initialze a long pointer into the pbuf for 32-bit access. */ pulBuf = (unsigned long *)&pucBuf[iBuf]; /** * Copy words of pbuf data into the Tx FIFO, but don't go past * the end of the pbuf. * */ while((iBuf + 4) <= q->len) { HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++; iBuf += 4; } /** * Check if leftover data in the pbuf and save it in the gather * buffer for the next time. * */ while(iBuf < q->len) { /* Copy a byte from the pbuf into the gather buffer. */ pucGather[iGather] = pucBuf[iBuf++]; /* Increment the gather buffer index modulo 4. */ iGather = ((iGather + 1) % 4); } } /* Send any leftover data to the FIFO. */ HWREG(ETH_BASE + MAC_O_DATA) = ulGather; /* Wakeup the transmitter. */ HWREG(ETH_BASE + MAC_O_TR) = MAC_TR_NEWTX; /* Dereference the pbuf from the queue. */ pbuf_free(p); LINK_STATS_INC(link.xmit); return(ERR_OK); }
/** * This function should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf might be * chained. * * @param netif the lwip network interface structure for this ethernetif * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type) * @return ERR_OK if the packet could be sent * an err_t value if the packet couldn't be sent * @note This function MUST be called with interrupts disabled or with the * Stellaris Ethernet transmit fifo protected. */
This function should do the actual transmission of the packet. The packet is contained in the pbuf that is passed to the function. This pbuf might be chained. @param netif the lwip network interface structure for this ethernetif @param p the MAC packet to send @return ERR_OK if the packet could be sent an err_t value if the packet couldn't be sent @note This function MUST be called with interrupts disabled or with the Stellaris Ethernet transmit fifo protected.
[ "This", "function", "should", "do", "the", "actual", "transmission", "of", "the", "packet", ".", "The", "packet", "is", "contained", "in", "the", "pbuf", "that", "is", "passed", "to", "the", "function", ".", "This", "pbuf", "might", "be", "chained", ".", "@param", "netif", "the", "lwip", "network", "interface", "structure", "for", "this", "ethernetif", "@param", "p", "the", "MAC", "packet", "to", "send", "@return", "ERR_OK", "if", "the", "packet", "could", "be", "sent", "an", "err_t", "value", "if", "the", "packet", "couldn", "'", "t", "be", "sent", "@note", "This", "function", "MUST", "be", "called", "with", "interrupts", "disabled", "or", "with", "the", "Stellaris", "Ethernet", "transmit", "fifo", "protected", "." ]
static err_t stellarisif_transmit(struct netif *netif, struct pbuf *p) { int iBuf; unsigned char *pucBuf; unsigned long *pulBuf; struct pbuf *q; int iGather; unsigned long ulGather; unsigned char *pucGather; *((unsigned short *)(p->payload)) = p->tot_len - 16; iGather = 0; pucGather = (unsigned char *)&ulGather; ulGather = 0; for(q = p; q != NULL; q = q->next) { pucBuf = (unsigned char *)q->payload; iBuf = 0; while((iBuf < q->len) && (iGather != 0)) { pucGather[iGather] = pucBuf[iBuf++]; iGather = ((iGather + 1) % 4); } if((iGather == 0) && (iBuf != 0)) { HWREG(ETH_BASE + MAC_O_DATA) = ulGather; ulGather = 0; } pulBuf = (unsigned long *)&pucBuf[iBuf]; while((iBuf + 4) <= q->len) { HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++; iBuf += 4; } while(iBuf < q->len) { pucGather[iGather] = pucBuf[iBuf++]; iGather = ((iGather + 1) % 4); } } HWREG(ETH_BASE + MAC_O_DATA) = ulGather; HWREG(ETH_BASE + MAC_O_TR) = MAC_TR_NEWTX; pbuf_free(p); LINK_STATS_INC(link.xmit); return(ERR_OK); }
[ "static", "err_t", "stellarisif_transmit", "(", "struct", "netif", "*", "netif", ",", "struct", "pbuf", "*", "p", ")", "{", "int", "iBuf", ";", "unsigned", "char", "*", "pucBuf", ";", "unsigned", "long", "*", "pulBuf", ";", "struct", "pbuf", "*", "q", ";", "int", "iGather", ";", "unsigned", "long", "ulGather", ";", "unsigned", "char", "*", "pucGather", ";", "*", "(", "(", "unsigned", "short", "*", ")", "(", "p", "->", "payload", ")", ")", "=", "p", "->", "tot_len", "-", "16", ";", "iGather", "=", "0", ";", "pucGather", "=", "(", "unsigned", "char", "*", ")", "&", "ulGather", ";", "ulGather", "=", "0", ";", "for", "(", "q", "=", "p", ";", "q", "!=", "NULL", ";", "q", "=", "q", "->", "next", ")", "{", "pucBuf", "=", "(", "unsigned", "char", "*", ")", "q", "->", "payload", ";", "iBuf", "=", "0", ";", "while", "(", "(", "iBuf", "<", "q", "->", "len", ")", "&&", "(", "iGather", "!=", "0", ")", ")", "{", "pucGather", "[", "iGather", "]", "=", "pucBuf", "[", "iBuf", "++", "]", ";", "iGather", "=", "(", "(", "iGather", "+", "1", ")", "%", "4", ")", ";", "}", "if", "(", "(", "iGather", "==", "0", ")", "&&", "(", "iBuf", "!=", "0", ")", ")", "{", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", "=", "ulGather", ";", "ulGather", "=", "0", ";", "}", "pulBuf", "=", "(", "unsigned", "long", "*", ")", "&", "pucBuf", "[", "iBuf", "]", ";", "while", "(", "(", "iBuf", "+", "4", ")", "<=", "q", "->", "len", ")", "{", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", "=", "*", "pulBuf", "++", ";", "iBuf", "+=", "4", ";", "}", "while", "(", "iBuf", "<", "q", "->", "len", ")", "{", "pucGather", "[", "iGather", "]", "=", "pucBuf", "[", "iBuf", "++", "]", ";", "iGather", "=", "(", "(", "iGather", "+", "1", ")", "%", "4", ")", ";", "}", "}", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", "=", "ulGather", ";", "HWREG", "(", "ETH_BASE", "+", "MAC_O_TR", ")", "=", "MAC_TR_NEWTX", ";", "pbuf_free", "(", "p", ")", ";", "LINK_STATS_INC", "(", "link", ".", "xmit", ")", ";", "return", "(", "ERR_OK", ")", ";", "}" ]
This function should do the actual transmission of the packet.
[ "This", "function", "should", "do", "the", "actual", "transmission", "of", "the", "packet", "." ]
[ "/**\r\n * Fill in the first two bytes of the payload data (configured as padding\r\n * with ETH_PAD_SIZE = 2) with the total length of the payload data\r\n * (minus the Ethernet MAC layer header).\r\n *\r\n */", "/* Initialize the gather register. */", "/* Copy data from the pbuf(s) into the TX Fifo. */", "/* Intialize a char pointer and index to the pbuf payload data. */", "/**\r\n * If the gather buffer has leftover data from a previous pbuf\r\n * in the chain, fill it up and write it to the Tx FIFO.\r\n *\r\n */", "/* Copy a byte from the pbuf into the gather buffer. */", "/* Increment the gather buffer index modulo 4. */", "/**\r\n * If the gather index is 0 and the pbuf index is non-zero,\r\n * we have a gather buffer to write into the Tx FIFO.\r\n *\r\n */", "/* Initialze a long pointer into the pbuf for 32-bit access. */", "/**\r\n * Copy words of pbuf data into the Tx FIFO, but don't go past\r\n * the end of the pbuf.\r\n *\r\n */", "/**\r\n * Check if leftover data in the pbuf and save it in the gather\r\n * buffer for the next time.\r\n *\r\n */", "/* Copy a byte from the pbuf into the gather buffer. */", "/* Increment the gather buffer index modulo 4. */", "/* Send any leftover data to the FIFO. */", "/* Wakeup the transmitter. */", "/* Dereference the pbuf from the queue. */" ]
[ { "param": "netif", "type": "struct netif" }, { "param": "p", "type": "struct pbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct pbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_output
err_t
static err_t stellarisif_output(struct netif *netif, struct pbuf *p) { struct stellarisif *stellarisif = netif->state; SYS_ARCH_DECL_PROTECT(lev); /** * This entire function must run within a "critical section" to preserve * the integrity of the transmit pbuf queue. * */ SYS_ARCH_PROTECT(lev); /** * Bump the reference count on the pbuf to prevent it from being * freed till we are done with it. * */ pbuf_ref(p); /** * If the transmitter is idle, and there is nothing on the queue, * send the pbuf now. * */ if(PBUF_QUEUE_EMPTY(&stellarisif->txq) && ((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0)) { stellarisif_transmit(netif, p); } /* Otherwise place the pbuf on the transmit queue. */ else { /* Add to transmit packet queue */ if(!enqueue_packet(p, &(stellarisif->txq))) { /* if no room on the queue, free the pbuf reference and return error. */ pbuf_free(p); SYS_ARCH_UNPROTECT(lev); return (ERR_MEM); } } /* Return to prior interrupt state and return. */ SYS_ARCH_UNPROTECT(lev); return ERR_OK; }
/** * This function with either place the packet into the Stellaris transmit fifo, * or will place the packet in the interface PBUF Queue for subsequent * transmission when the transmitter becomes idle. * * @param netif the lwip network interface structure for this ethernetif * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type) * @return ERR_OK if the packet could be sent * an err_t value if the packet couldn't be sent * */
This function with either place the packet into the Stellaris transmit fifo, or will place the packet in the interface PBUF Queue for subsequent transmission when the transmitter becomes idle. @param netif the lwip network interface structure for this ethernetif @param p the MAC packet to send @return ERR_OK if the packet could be sent an err_t value if the packet couldn't be sent
[ "This", "function", "with", "either", "place", "the", "packet", "into", "the", "Stellaris", "transmit", "fifo", "or", "will", "place", "the", "packet", "in", "the", "interface", "PBUF", "Queue", "for", "subsequent", "transmission", "when", "the", "transmitter", "becomes", "idle", ".", "@param", "netif", "the", "lwip", "network", "interface", "structure", "for", "this", "ethernetif", "@param", "p", "the", "MAC", "packet", "to", "send", "@return", "ERR_OK", "if", "the", "packet", "could", "be", "sent", "an", "err_t", "value", "if", "the", "packet", "couldn", "'", "t", "be", "sent" ]
static err_t stellarisif_output(struct netif *netif, struct pbuf *p) { struct stellarisif *stellarisif = netif->state; SYS_ARCH_DECL_PROTECT(lev); SYS_ARCH_PROTECT(lev); pbuf_ref(p); if(PBUF_QUEUE_EMPTY(&stellarisif->txq) && ((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0)) { stellarisif_transmit(netif, p); } else { if(!enqueue_packet(p, &(stellarisif->txq))) { pbuf_free(p); SYS_ARCH_UNPROTECT(lev); return (ERR_MEM); } } SYS_ARCH_UNPROTECT(lev); return ERR_OK; }
[ "static", "err_t", "stellarisif_output", "(", "struct", "netif", "*", "netif", ",", "struct", "pbuf", "*", "p", ")", "{", "struct", "stellarisif", "*", "stellarisif", "=", "netif", "->", "state", ";", "SYS_ARCH_DECL_PROTECT", "(", "lev", ")", ";", "SYS_ARCH_PROTECT", "(", "lev", ")", ";", "pbuf_ref", "(", "p", ")", ";", "if", "(", "PBUF_QUEUE_EMPTY", "(", "&", "stellarisif", "->", "txq", ")", "&&", "(", "(", "HWREG", "(", "ETH_BASE", "+", "MAC_O_TR", ")", "&", "MAC_TR_NEWTX", ")", "==", "0", ")", ")", "{", "stellarisif_transmit", "(", "netif", ",", "p", ")", ";", "}", "else", "{", "if", "(", "!", "enqueue_packet", "(", "p", ",", "&", "(", "stellarisif", "->", "txq", ")", ")", ")", "{", "pbuf_free", "(", "p", ")", ";", "SYS_ARCH_UNPROTECT", "(", "lev", ")", ";", "return", "(", "ERR_MEM", ")", ";", "}", "}", "SYS_ARCH_UNPROTECT", "(", "lev", ")", ";", "return", "ERR_OK", ";", "}" ]
This function with either place the packet into the Stellaris transmit fifo, or will place the packet in the interface PBUF Queue for subsequent transmission when the transmitter becomes idle.
[ "This", "function", "with", "either", "place", "the", "packet", "into", "the", "Stellaris", "transmit", "fifo", "or", "will", "place", "the", "packet", "in", "the", "interface", "PBUF", "Queue", "for", "subsequent", "transmission", "when", "the", "transmitter", "becomes", "idle", "." ]
[ "/**\r\n * This entire function must run within a \"critical section\" to preserve\r\n * the integrity of the transmit pbuf queue.\r\n *\r\n */", "/**\r\n * Bump the reference count on the pbuf to prevent it from being\r\n * freed till we are done with it.\r\n *\r\n */", "/**\r\n * If the transmitter is idle, and there is nothing on the queue,\r\n * send the pbuf now.\r\n *\r\n */", "/* Otherwise place the pbuf on the transmit queue. */", "/* Add to transmit packet queue */", "/* if no room on the queue, free the pbuf reference and return error. */", "/* Return to prior interrupt state and return. */" ]
[ { "param": "netif", "type": "struct netif" }, { "param": "p", "type": "struct pbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct pbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_receive
null
static struct pbuf * stellarisif_receive(struct netif *netif) { struct pbuf *p, *q; u16_t len; u32_t temp; int i; unsigned long *ptr; #if LWIP_PTPD u32_t time_s, time_ns; /* Get the current timestamp if PTPD is enabled */ lwIPHostGetTime(&time_s, &time_ns); #endif /* Check if a packet is available, if not, return NULL packet. */ if((HWREG(ETH_BASE + MAC_O_NP) & MAC_NP_NPR_M) == 0) { return(NULL); } /** * Obtain the size of the packet and put it into the "len" variable. * Note: The length returned in the FIFO length position includes the * two bytes for the length + the 4 bytes for the FCS. * */ temp = HWREG(ETH_BASE + MAC_O_DATA); len = temp & 0xFFFF; /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); /* If a pbuf was allocated, read the packet into the pbuf. */ if(p != NULL) { /* Place the first word into the first pbuf location. */ *(unsigned long *)p->payload = temp; p->payload = (char *)(p->payload) + 4; p->len -= 4; /* Process all but the last buffer in the pbuf chain. */ q = p; while(q != NULL) { /* Setup a byte pointer into the payload section of the pbuf. */ ptr = q->payload; /** * Read data from FIFO into the current pbuf * (assume pbuf length is modulo 4) * */ for(i = 0; i < q->len; i += 4) { *ptr++ = HWREG(ETH_BASE + MAC_O_DATA); } /* Link in the next pbuf in the chain. */ q = q->next; } /* Restore the first pbuf parameters to their original values. */ p->payload = (char *)(p->payload) - 4; p->len += 4; /* Adjust the link statistics */ LINK_STATS_INC(link.recv); #if LWIP_PTPD /* Place the timestamp in the PBUF */ p->time_s = time_s; p->time_ns = time_ns; #endif } /* If no pbuf available, just drain the RX fifo. */ else { for(i = 4; i < len; i+=4) { temp = HWREG(ETH_BASE + MAC_O_DATA); } /* Adjust the link statistics */ LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.drop); } return(p); }
/** * This function will read a single packet from the Stellaris ethernet * interface, if available, and return a pointer to a pbuf. The timestamp * of the packet will be placed into the pbuf structure. * * @param netif the lwip network interface structure for this ethernetif * @return pointer to pbuf packet if available, NULL otherswise. */
This function will read a single packet from the Stellaris ethernet interface, if available, and return a pointer to a pbuf. The timestamp of the packet will be placed into the pbuf structure. @param netif the lwip network interface structure for this ethernetif @return pointer to pbuf packet if available, NULL otherswise.
[ "This", "function", "will", "read", "a", "single", "packet", "from", "the", "Stellaris", "ethernet", "interface", "if", "available", "and", "return", "a", "pointer", "to", "a", "pbuf", ".", "The", "timestamp", "of", "the", "packet", "will", "be", "placed", "into", "the", "pbuf", "structure", ".", "@param", "netif", "the", "lwip", "network", "interface", "structure", "for", "this", "ethernetif", "@return", "pointer", "to", "pbuf", "packet", "if", "available", "NULL", "otherswise", "." ]
static struct pbuf * stellarisif_receive(struct netif *netif) { struct pbuf *p, *q; u16_t len; u32_t temp; int i; unsigned long *ptr; #if LWIP_PTPD u32_t time_s, time_ns; lwIPHostGetTime(&time_s, &time_ns); #endif if((HWREG(ETH_BASE + MAC_O_NP) & MAC_NP_NPR_M) == 0) { return(NULL); } temp = HWREG(ETH_BASE + MAC_O_DATA); len = temp & 0xFFFF; p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); if(p != NULL) { *(unsigned long *)p->payload = temp; p->payload = (char *)(p->payload) + 4; p->len -= 4; q = p; while(q != NULL) { ptr = q->payload; for(i = 0; i < q->len; i += 4) { *ptr++ = HWREG(ETH_BASE + MAC_O_DATA); } q = q->next; } p->payload = (char *)(p->payload) - 4; p->len += 4; LINK_STATS_INC(link.recv); #if LWIP_PTPD p->time_s = time_s; p->time_ns = time_ns; #endif } else { for(i = 4; i < len; i+=4) { temp = HWREG(ETH_BASE + MAC_O_DATA); } LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.drop); } return(p); }
[ "static", "struct", "pbuf", "*", "stellarisif_receive", "(", "struct", "netif", "*", "netif", ")", "{", "struct", "pbuf", "*", "p", ",", "*", "q", ";", "u16_t", "len", ";", "u32_t", "temp", ";", "int", "i", ";", "unsigned", "long", "*", "ptr", ";", "#if", "LWIP_PTPD", "\n", "u32_t", "time_s", ",", "time_ns", ";", "lwIPHostGetTime", "(", "&", "time_s", ",", "&", "time_ns", ")", ";", "#endif", "if", "(", "(", "HWREG", "(", "ETH_BASE", "+", "MAC_O_NP", ")", "&", "MAC_NP_NPR_M", ")", "==", "0", ")", "{", "return", "(", "NULL", ")", ";", "}", "temp", "=", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", ";", "len", "=", "temp", "&", "0xFFFF", ";", "p", "=", "pbuf_alloc", "(", "PBUF_RAW", ",", "len", ",", "PBUF_POOL", ")", ";", "if", "(", "p", "!=", "NULL", ")", "{", "*", "(", "unsigned", "long", "*", ")", "p", "->", "payload", "=", "temp", ";", "p", "->", "payload", "=", "(", "char", "*", ")", "(", "p", "->", "payload", ")", "+", "4", ";", "p", "->", "len", "-=", "4", ";", "q", "=", "p", ";", "while", "(", "q", "!=", "NULL", ")", "{", "ptr", "=", "q", "->", "payload", ";", "for", "(", "i", "=", "0", ";", "i", "<", "q", "->", "len", ";", "i", "+=", "4", ")", "{", "*", "ptr", "++", "=", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", ";", "}", "q", "=", "q", "->", "next", ";", "}", "p", "->", "payload", "=", "(", "char", "*", ")", "(", "p", "->", "payload", ")", "-", "4", ";", "p", "->", "len", "+=", "4", ";", "LINK_STATS_INC", "(", "link", ".", "recv", ")", ";", "#if", "LWIP_PTPD", "\n", "p", "->", "time_s", "=", "time_s", ";", "p", "->", "time_ns", "=", "time_ns", ";", "#endif", "}", "else", "{", "for", "(", "i", "=", "4", ";", "i", "<", "len", ";", "i", "+=", "4", ")", "{", "temp", "=", "HWREG", "(", "ETH_BASE", "+", "MAC_O_DATA", ")", ";", "}", "LINK_STATS_INC", "(", "link", ".", "memerr", ")", ";", "LINK_STATS_INC", "(", "link", ".", "drop", ")", ";", "}", "return", "(", "p", ")", ";", "}" ]
This function will read a single packet from the Stellaris ethernet interface, if available, and return a pointer to a pbuf.
[ "This", "function", "will", "read", "a", "single", "packet", "from", "the", "Stellaris", "ethernet", "interface", "if", "available", "and", "return", "a", "pointer", "to", "a", "pbuf", "." ]
[ "/* Get the current timestamp if PTPD is enabled */", "/* Check if a packet is available, if not, return NULL packet. */", "/**\r\n * Obtain the size of the packet and put it into the \"len\" variable.\r\n * Note: The length returned in the FIFO length position includes the\r\n * two bytes for the length + the 4 bytes for the FCS.\r\n *\r\n */", "/* We allocate a pbuf chain of pbufs from the pool. */", "/* If a pbuf was allocated, read the packet into the pbuf. */", "/* Place the first word into the first pbuf location. */", "/* Process all but the last buffer in the pbuf chain. */", "/* Setup a byte pointer into the payload section of the pbuf. */", "/**\r\n * Read data from FIFO into the current pbuf\r\n * (assume pbuf length is modulo 4)\r\n *\r\n */", "/* Link in the next pbuf in the chain. */", "/* Restore the first pbuf parameters to their original values. */", "/* Adjust the link statistics */", "/* Place the timestamp in the PBUF */", "/* If no pbuf available, just drain the RX fifo. */", "/* Adjust the link statistics */" ]
[ { "param": "netif", "type": "struct netif" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_init
err_t
err_t stellarisif_init(struct netif *netif) { LWIP_ASSERT("netif != NULL", (netif != NULL)); #if LWIP_NETIF_HOSTNAME /* Initialize interface hostname */ netif->hostname = "lwip"; #endif /* LWIP_NETIF_HOSTNAME */ /* * Initialize the snmp variables and counters inside the struct netif. * The last argument should be replaced with your link speed, in units * of bits per second. */ NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 1000000); netif->state = &stellarisif_data; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; /* We directly use etharp_output() here to save a function call. * You can instead declare your own function an call etharp_output() * from it if you have to do some checks before sending (e.g. if link * is available...) */ netif->output = etharp_output; netif->linkoutput = stellarisif_output; stellarisif_data.ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); stellarisif_data.txq.qread = stellarisif_data.txq.qwrite = 0; stellarisif_data.txq.overflow = 0; /* initialize the hardware */ stellarisif_hwinit(netif); return ERR_OK; }
/** * Should be called at the beginning of the program to set up the * network interface. It calls the function stellarisif_hwinit() to do the * actual setup of the hardware. * * This function should be passed as a parameter to netif_add(). * * @param netif the lwip network interface structure for this ethernetif * @return ERR_OK if the loopif is initialized * ERR_MEM if private data couldn't be allocated * any other err_t on error */
Should be called at the beginning of the program to set up the network interface. It calls the function stellarisif_hwinit() to do the actual setup of the hardware. This function should be passed as a parameter to netif_add(). @param netif the lwip network interface structure for this ethernetif @return ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error
[ "Should", "be", "called", "at", "the", "beginning", "of", "the", "program", "to", "set", "up", "the", "network", "interface", ".", "It", "calls", "the", "function", "stellarisif_hwinit", "()", "to", "do", "the", "actual", "setup", "of", "the", "hardware", ".", "This", "function", "should", "be", "passed", "as", "a", "parameter", "to", "netif_add", "()", ".", "@param", "netif", "the", "lwip", "network", "interface", "structure", "for", "this", "ethernetif", "@return", "ERR_OK", "if", "the", "loopif", "is", "initialized", "ERR_MEM", "if", "private", "data", "couldn", "'", "t", "be", "allocated", "any", "other", "err_t", "on", "error" ]
err_t stellarisif_init(struct netif *netif) { LWIP_ASSERT("netif != NULL", (netif != NULL)); #if LWIP_NETIF_HOSTNAME netif->hostname = "lwip"; #endif NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 1000000); netif->state = &stellarisif_data; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->output = etharp_output; netif->linkoutput = stellarisif_output; stellarisif_data.ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); stellarisif_data.txq.qread = stellarisif_data.txq.qwrite = 0; stellarisif_data.txq.overflow = 0; stellarisif_hwinit(netif); return ERR_OK; }
[ "err_t", "stellarisif_init", "(", "struct", "netif", "*", "netif", ")", "{", "LWIP_ASSERT", "(", "\"", "\"", ",", "(", "netif", "!=", "NULL", ")", ")", ";", "#if", "LWIP_NETIF_HOSTNAME", "\n", "netif", "->", "hostname", "=", "\"", "\"", ";", "#endif", "NETIF_INIT_SNMP", "(", "netif", ",", "snmp_ifType_ethernet_csmacd", ",", "1000000", ")", ";", "netif", "->", "state", "=", "&", "stellarisif_data", ";", "netif", "->", "name", "[", "0", "]", "=", "IFNAME0", ";", "netif", "->", "name", "[", "1", "]", "=", "IFNAME1", ";", "netif", "->", "output", "=", "etharp_output", ";", "netif", "->", "linkoutput", "=", "stellarisif_output", ";", "stellarisif_data", ".", "ethaddr", "=", "(", "struct", "eth_addr", "*", ")", "&", "(", "netif", "->", "hwaddr", "[", "0", "]", ")", ";", "stellarisif_data", ".", "txq", ".", "qread", "=", "stellarisif_data", ".", "txq", ".", "qwrite", "=", "0", ";", "stellarisif_data", ".", "txq", ".", "overflow", "=", "0", ";", "stellarisif_hwinit", "(", "netif", ")", ";", "return", "ERR_OK", ";", "}" ]
Should be called at the beginning of the program to set up the network interface.
[ "Should", "be", "called", "at", "the", "beginning", "of", "the", "program", "to", "set", "up", "the", "network", "interface", "." ]
[ "/* Initialize interface hostname */", "/* LWIP_NETIF_HOSTNAME */", "/*\r\n * Initialize the snmp variables and counters inside the struct netif.\r\n * The last argument should be replaced with your link speed, in units\r\n * of bits per second.\r\n */", "/* We directly use etharp_output() here to save a function call.\r\n * You can instead declare your own function an call etharp_output()\r\n * from it if you have to do some checks before sending (e.g. if link\r\n * is available...) */", "/* initialize the hardware */" ]
[ { "param": "netif", "type": "struct netif" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c6b4053b6db9911bfa9ede7309b046a1ceabae5
junyanl-code/Luminary-Micro-Library
third_party/lwip-1.3.2/ports/stellaris/netif/stellarisif.c
[ "BSD-3-Clause" ]
C
stellarisif_interrupt
void
void stellarisif_interrupt(struct netif *netif) { struct stellarisif *stellarisif; struct pbuf *p; /* setup pointer to the if state data */ stellarisif = netif->state; /** * Process the transmit and receive queues as long as there is receive * data available * */ p = stellarisif_receive(netif); while(p != NULL) { /* process the packet */ #if NO_SYS if(ethernet_input(p, netif)!=ERR_OK) { #else if(tcpip_input(p, netif)!=ERR_OK) { #endif /* drop the packet */ LWIP_DEBUGF(NETIF_DEBUG, ("stellarisif_input: input error\n")); pbuf_free(p); /* Adjust the link statistics */ LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.drop); } /* Check if TX fifo is empty and packet available */ if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) { p = dequeue_packet(&stellarisif->txq); if(p != NULL) { stellarisif_transmit(netif, p); } } /* Read another packet from the RX fifo */ p = stellarisif_receive(netif); } /* One more check of the transmit queue/fifo */ if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) { p = dequeue_packet(&stellarisif->txq); if(p != NULL) { stellarisif_transmit(netif, p); } } }
/** * Process tx and rx packets at the low-level interrupt. * * Should be called from the Stellaris Ethernet Interrupt Handler. This * function will read packets from the Stellaris Ethernet fifo and place them * into a pbuf queue. If the transmitter is idle and there is at least one packet * on the transmit queue, it will place it in the transmit fifo and start the * transmitter. * */
Process tx and rx packets at the low-level interrupt. Should be called from the Stellaris Ethernet Interrupt Handler. This function will read packets from the Stellaris Ethernet fifo and place them into a pbuf queue. If the transmitter is idle and there is at least one packet on the transmit queue, it will place it in the transmit fifo and start the transmitter.
[ "Process", "tx", "and", "rx", "packets", "at", "the", "low", "-", "level", "interrupt", ".", "Should", "be", "called", "from", "the", "Stellaris", "Ethernet", "Interrupt", "Handler", ".", "This", "function", "will", "read", "packets", "from", "the", "Stellaris", "Ethernet", "fifo", "and", "place", "them", "into", "a", "pbuf", "queue", ".", "If", "the", "transmitter", "is", "idle", "and", "there", "is", "at", "least", "one", "packet", "on", "the", "transmit", "queue", "it", "will", "place", "it", "in", "the", "transmit", "fifo", "and", "start", "the", "transmitter", "." ]
void stellarisif_interrupt(struct netif *netif) { struct stellarisif *stellarisif; struct pbuf *p; stellarisif = netif->state; p = stellarisif_receive(netif); while(p != NULL) { #if NO_SYS if(ethernet_input(p, netif)!=ERR_OK) { #else if(tcpip_input(p, netif)!=ERR_OK) { #endif LWIP_DEBUGF(NETIF_DEBUG, ("stellarisif_input: input error\n")); pbuf_free(p); LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.drop); } if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) { p = dequeue_packet(&stellarisif->txq); if(p != NULL) { stellarisif_transmit(netif, p); } } p = stellarisif_receive(netif); } if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) { p = dequeue_packet(&stellarisif->txq); if(p != NULL) { stellarisif_transmit(netif, p); } } }
[ "void", "stellarisif_interrupt", "(", "struct", "netif", "*", "netif", ")", "{", "struct", "stellarisif", "*", "stellarisif", ";", "struct", "pbuf", "*", "p", ";", "stellarisif", "=", "netif", "->", "state", ";", "p", "=", "stellarisif_receive", "(", "netif", ")", ";", "while", "(", "p", "!=", "NULL", ")", "{", "#if", "NO_SYS", "\n", "if", "(", "ethernet_input", "(", "p", ",", "netif", ")", "!=", "ERR_OK", ")", "{", "#else", "\r\n if(tcpip_input(p, netif)!=ERR_OK) {\r", "\n", "#endif", "\r\n LWIP_DEBUGF(NETIF_DEBUG, (\"stellarisif_input: input error\\n\"));\r", "\n", "pbuf_free", "(", "p", ")", ";", "LINK_STATS_INC", "(", "link", ".", "memerr", ")", ";", "LINK_STATS_INC", "(", "link", ".", "drop", ")", ";", "}", "if", "(", "(", "HWREG", "(", "ETH_BASE", "+", "MAC_O_TR", ")", "&", "MAC_TR_NEWTX", ")", "==", "0", ")", "{", "p", "=", "dequeue_packet", "(", "&", "stellarisif", "->", "txq", ")", ";", "if", "(", "p", "!=", "NULL", ")", "{", "stellarisif_transmit", "(", "netif", ",", "p", ")", ";", "}", "}", "p", "=", "stellarisif_receive", "(", "netif", ")", ";", "", "}", "if", "(", "(", "HWREG", "(", "ETH_BASE", "+", "MAC_O_TR", ")", "&", "MAC_TR_NEWTX", ")", "==", "0", ")", "{", "p", "=", "dequeue_packet", "(", "&", "stellarisif", "->", "txq", ")", ";", "if", "(", "p", "!=", "NULL", ")", "{", "stellarisif_transmit", "(", "netif", ",", "p", ")", ";", "}", "}", "}" ]
Process tx and rx packets at the low-level interrupt.
[ "Process", "tx", "and", "rx", "packets", "at", "the", "low", "-", "level", "interrupt", "." ]
[ "/* setup pointer to the if state data */", "/**\r\n * Process the transmit and receive queues as long as there is receive\r\n * data available\r\n *\r\n */", "/* process the packet */", "\r\n /* drop the packet */", "/* Adjust the link statistics */", "/* Check if TX fifo is empty and packet available */", "/* Read another packet from the RX fifo */", "/* One more check of the transmit queue/fifo */" ]
[ { "param": "netif", "type": "struct netif" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55a3c995a1fd2bcc0c5889730374ce001f8c6597
junyanl-code/Luminary-Micro-Library
grlib/line.c
[ "BSD-3-Clause" ]
C
GrLineDrawH
void
void GrLineDrawH(const tContext *pContext, long lX1, long lX2, long lY) { long lTemp; // // Check the arguments. // ASSERT(pContext); // // If the Y coordinate of this line is not in the clipping region, then // there is nothing to be done. // if((lY < pContext->sClipRegion.sYMin) || (lY > pContext->sClipRegion.sYMax)) { return; } // // Swap the X coordinates if the first is larger than the second. // if(lX1 > lX2) { lTemp = lX1; lX1 = lX2; lX2 = lTemp; } // // If the entire line is outside the clipping region, then there is nothing // to be done. // if((lX1 > pContext->sClipRegion.sXMax) || (lX2 < pContext->sClipRegion.sXMin)) { return; } // // Clip the starting coordinate to the left side of the clipping region if // required. // if(lX1 < pContext->sClipRegion.sXMin) { lX1 = pContext->sClipRegion.sXMin; } // // Clip the ending coordinate to the right side of the clipping region if // required. // if(lX2 > pContext->sClipRegion.sXMax) { lX2 = pContext->sClipRegion.sXMax; } // // Call the low level horizontal line drawing routine. // DpyLineDrawH(pContext->pDisplay, lX1, lX2, lY, pContext->ulForeground); }
//***************************************************************************** // //! Draws a horizontal line. //! //! \param pContext is a pointer to the drawing context to use. //! \param lX1 is the X coordinate of one end of the line. //! \param lX2 is the X coordinate of the other end of the line. //! \param lY is the Y coordinate of the line. //! //! This function draws a horizontal line, taking advantage of the fact that //! the line is horizontal to draw it more efficiently. The clipping of the //! horizontal line to the clipping rectangle is performed within this routine; //! the display driver's horizontal line routine is used to perform the actual //! line drawing. //! //! \return None. // //*****************************************************************************
Draws a horizontal line. \param pContext is a pointer to the drawing context to use. \param lX1 is the X coordinate of one end of the line. \param lX2 is the X coordinate of the other end of the line. \param lY is the Y coordinate of the line. This function draws a horizontal line, taking advantage of the fact that the line is horizontal to draw it more efficiently. The clipping of the horizontal line to the clipping rectangle is performed within this routine; the display driver's horizontal line routine is used to perform the actual line drawing. \return None.
[ "Draws", "a", "horizontal", "line", ".", "\\", "param", "pContext", "is", "a", "pointer", "to", "the", "drawing", "context", "to", "use", ".", "\\", "param", "lX1", "is", "the", "X", "coordinate", "of", "one", "end", "of", "the", "line", ".", "\\", "param", "lX2", "is", "the", "X", "coordinate", "of", "the", "other", "end", "of", "the", "line", ".", "\\", "param", "lY", "is", "the", "Y", "coordinate", "of", "the", "line", ".", "This", "function", "draws", "a", "horizontal", "line", "taking", "advantage", "of", "the", "fact", "that", "the", "line", "is", "horizontal", "to", "draw", "it", "more", "efficiently", ".", "The", "clipping", "of", "the", "horizontal", "line", "to", "the", "clipping", "rectangle", "is", "performed", "within", "this", "routine", ";", "the", "display", "driver", "'", "s", "horizontal", "line", "routine", "is", "used", "to", "perform", "the", "actual", "line", "drawing", ".", "\\", "return", "None", "." ]
void GrLineDrawH(const tContext *pContext, long lX1, long lX2, long lY) { long lTemp; ASSERT(pContext); if((lY < pContext->sClipRegion.sYMin) || (lY > pContext->sClipRegion.sYMax)) { return; } if(lX1 > lX2) { lTemp = lX1; lX1 = lX2; lX2 = lTemp; } if((lX1 > pContext->sClipRegion.sXMax) || (lX2 < pContext->sClipRegion.sXMin)) { return; } if(lX1 < pContext->sClipRegion.sXMin) { lX1 = pContext->sClipRegion.sXMin; } if(lX2 > pContext->sClipRegion.sXMax) { lX2 = pContext->sClipRegion.sXMax; } DpyLineDrawH(pContext->pDisplay, lX1, lX2, lY, pContext->ulForeground); }
[ "void", "GrLineDrawH", "(", "const", "tContext", "*", "pContext", ",", "long", "lX1", ",", "long", "lX2", ",", "long", "lY", ")", "{", "long", "lTemp", ";", "ASSERT", "(", "pContext", ")", ";", "if", "(", "(", "lY", "<", "pContext", "->", "sClipRegion", ".", "sYMin", ")", "||", "(", "lY", ">", "pContext", "->", "sClipRegion", ".", "sYMax", ")", ")", "{", "return", ";", "}", "if", "(", "lX1", ">", "lX2", ")", "{", "lTemp", "=", "lX1", ";", "lX1", "=", "lX2", ";", "lX2", "=", "lTemp", ";", "}", "if", "(", "(", "lX1", ">", "pContext", "->", "sClipRegion", ".", "sXMax", ")", "||", "(", "lX2", "<", "pContext", "->", "sClipRegion", ".", "sXMin", ")", ")", "{", "return", ";", "}", "if", "(", "lX1", "<", "pContext", "->", "sClipRegion", ".", "sXMin", ")", "{", "lX1", "=", "pContext", "->", "sClipRegion", ".", "sXMin", ";", "}", "if", "(", "lX2", ">", "pContext", "->", "sClipRegion", ".", "sXMax", ")", "{", "lX2", "=", "pContext", "->", "sClipRegion", ".", "sXMax", ";", "}", "DpyLineDrawH", "(", "pContext", "->", "pDisplay", ",", "lX1", ",", "lX2", ",", "lY", ",", "pContext", "->", "ulForeground", ")", ";", "}" ]
Draws a horizontal line.
[ "Draws", "a", "horizontal", "line", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// If the Y coordinate of this line is not in the clipping region, then\r", "// there is nothing to be done.\r", "//\r", "//\r", "// Swap the X coordinates if the first is larger than the second.\r", "//\r", "//\r", "// If the entire line is outside the clipping region, then there is nothing\r", "// to be done.\r", "//\r", "//\r", "// Clip the starting coordinate to the left side of the clipping region if\r", "// required.\r", "//\r", "//\r", "// Clip the ending coordinate to the right side of the clipping region if\r", "// required.\r", "//\r", "//\r", "// Call the low level horizontal line drawing routine.\r", "//\r" ]
[ { "param": "pContext", "type": "tContext" }, { "param": "lX1", "type": "long" }, { "param": "lX2", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55a3c995a1fd2bcc0c5889730374ce001f8c6597
junyanl-code/Luminary-Micro-Library
grlib/line.c
[ "BSD-3-Clause" ]
C
GrLineDrawV
void
void GrLineDrawV(const tContext *pContext, long lX, long lY1, long lY2) { long lTemp; // // Check the arguments. // ASSERT(pContext); // // If the X coordinate of this line is not within the clipping region, then // there is nothing to be done. // if((lX < pContext->sClipRegion.sXMin) || (lX > pContext->sClipRegion.sXMax)) { return; } // // Swap the Y coordinates if the first is larger than the second. // if(lY1 > lY2) { lTemp = lY1; lY1 = lY2; lY2 = lTemp; } // // If the entire line is out of the clipping region, then there is nothing // to be done. // if((lY1 > pContext->sClipRegion.sYMax) || (lY2 < pContext->sClipRegion.sYMin)) { return; } // // Clip the starting coordinate to the top side of the clipping region if // required. // if(lY1 < pContext->sClipRegion.sYMin) { lY1 = pContext->sClipRegion.sYMin; } // // Clip the ending coordinate to the bottom side of the clipping region if // required. // if(lY2 > pContext->sClipRegion.sYMax) { lY2 = pContext->sClipRegion.sYMax; } // // Call the low level vertical line drawing routine. // DpyLineDrawV(pContext->pDisplay, lX, lY1, lY2, pContext->ulForeground); }
//***************************************************************************** // //! Draws a vertical line. //! //! \param pContext is a pointer to the drawing context to use. //! \param lX is the X coordinate of the line. //! \param lY1 is the Y coordinate of one end of the line. //! \param lY2 is the Y coordinate of the other end of the line. //! //! This function draws a vertical line, taking advantage of the fact that the //! line is vertical to draw it more efficiently. The clipping of the vertical //! line to the clipping rectangle is performed within this routine; the //! display driver's vertical line routine is used to perform the actual line //! drawing. //! //! \return None. // //*****************************************************************************
Draws a vertical line. \param pContext is a pointer to the drawing context to use. \param lX is the X coordinate of the line. \param lY1 is the Y coordinate of one end of the line. \param lY2 is the Y coordinate of the other end of the line. This function draws a vertical line, taking advantage of the fact that the line is vertical to draw it more efficiently. The clipping of the vertical line to the clipping rectangle is performed within this routine; the display driver's vertical line routine is used to perform the actual line drawing. \return None.
[ "Draws", "a", "vertical", "line", ".", "\\", "param", "pContext", "is", "a", "pointer", "to", "the", "drawing", "context", "to", "use", ".", "\\", "param", "lX", "is", "the", "X", "coordinate", "of", "the", "line", ".", "\\", "param", "lY1", "is", "the", "Y", "coordinate", "of", "one", "end", "of", "the", "line", ".", "\\", "param", "lY2", "is", "the", "Y", "coordinate", "of", "the", "other", "end", "of", "the", "line", ".", "This", "function", "draws", "a", "vertical", "line", "taking", "advantage", "of", "the", "fact", "that", "the", "line", "is", "vertical", "to", "draw", "it", "more", "efficiently", ".", "The", "clipping", "of", "the", "vertical", "line", "to", "the", "clipping", "rectangle", "is", "performed", "within", "this", "routine", ";", "the", "display", "driver", "'", "s", "vertical", "line", "routine", "is", "used", "to", "perform", "the", "actual", "line", "drawing", ".", "\\", "return", "None", "." ]
void GrLineDrawV(const tContext *pContext, long lX, long lY1, long lY2) { long lTemp; ASSERT(pContext); if((lX < pContext->sClipRegion.sXMin) || (lX > pContext->sClipRegion.sXMax)) { return; } if(lY1 > lY2) { lTemp = lY1; lY1 = lY2; lY2 = lTemp; } if((lY1 > pContext->sClipRegion.sYMax) || (lY2 < pContext->sClipRegion.sYMin)) { return; } if(lY1 < pContext->sClipRegion.sYMin) { lY1 = pContext->sClipRegion.sYMin; } if(lY2 > pContext->sClipRegion.sYMax) { lY2 = pContext->sClipRegion.sYMax; } DpyLineDrawV(pContext->pDisplay, lX, lY1, lY2, pContext->ulForeground); }
[ "void", "GrLineDrawV", "(", "const", "tContext", "*", "pContext", ",", "long", "lX", ",", "long", "lY1", ",", "long", "lY2", ")", "{", "long", "lTemp", ";", "ASSERT", "(", "pContext", ")", ";", "if", "(", "(", "lX", "<", "pContext", "->", "sClipRegion", ".", "sXMin", ")", "||", "(", "lX", ">", "pContext", "->", "sClipRegion", ".", "sXMax", ")", ")", "{", "return", ";", "}", "if", "(", "lY1", ">", "lY2", ")", "{", "lTemp", "=", "lY1", ";", "lY1", "=", "lY2", ";", "lY2", "=", "lTemp", ";", "}", "if", "(", "(", "lY1", ">", "pContext", "->", "sClipRegion", ".", "sYMax", ")", "||", "(", "lY2", "<", "pContext", "->", "sClipRegion", ".", "sYMin", ")", ")", "{", "return", ";", "}", "if", "(", "lY1", "<", "pContext", "->", "sClipRegion", ".", "sYMin", ")", "{", "lY1", "=", "pContext", "->", "sClipRegion", ".", "sYMin", ";", "}", "if", "(", "lY2", ">", "pContext", "->", "sClipRegion", ".", "sYMax", ")", "{", "lY2", "=", "pContext", "->", "sClipRegion", ".", "sYMax", ";", "}", "DpyLineDrawV", "(", "pContext", "->", "pDisplay", ",", "lX", ",", "lY1", ",", "lY2", ",", "pContext", "->", "ulForeground", ")", ";", "}" ]
Draws a vertical line.
[ "Draws", "a", "vertical", "line", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// If the X coordinate of this line is not within the clipping region, then\r", "// there is nothing to be done.\r", "//\r", "//\r", "// Swap the Y coordinates if the first is larger than the second.\r", "//\r", "//\r", "// If the entire line is out of the clipping region, then there is nothing\r", "// to be done.\r", "//\r", "//\r", "// Clip the starting coordinate to the top side of the clipping region if\r", "// required.\r", "//\r", "//\r", "// Clip the ending coordinate to the bottom side of the clipping region if\r", "// required.\r", "//\r", "//\r", "// Call the low level vertical line drawing routine.\r", "//\r" ]
[ { "param": "pContext", "type": "tContext" }, { "param": "lX", "type": "long" }, { "param": "lY1", "type": "long" }, { "param": "lY2", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55a3c995a1fd2bcc0c5889730374ce001f8c6597
junyanl-code/Luminary-Micro-Library
grlib/line.c
[ "BSD-3-Clause" ]
C
GrClipCodeGet
null
static long GrClipCodeGet(const tContext *pContext, long lX, long lY) { long lCode; // // Initialize the clipping code to zero. // lCode = 0; // // Set bit zero of the clipping code if the Y coordinate is above the // clipping region. // if(lY < pContext->sClipRegion.sYMin) { lCode |= 1; } // // Set bit one of the clipping code if the Y coordinate is below the // clipping region. // if(lY > pContext->sClipRegion.sYMax) { lCode |= 2; } // // Set bit two of the clipping code if the X coordinate is to the left of // the clipping region. // if(lX < pContext->sClipRegion.sXMin) { lCode |= 4; } // // Set bit three of the clipping code if the X coordinate is to the right // of the clipping region. // if(lX > pContext->sClipRegion.sXMax) { lCode |= 8; } // // Return the clipping code. // return(lCode); }
//***************************************************************************** // //! Computes the clipping code used by the Cohen-Sutherland clipping algorithm. //! //! \param pContext is a pointer to the drawing context to use. //! \param lX is the X coordinate of the point. //! \param lY is the Y coordinate of the point. //! //! This function computes the clipping code used by the Cohen-Sutherland //! clipping algorithm. Clipping is performed by classifying the endpoints of //! the line based on their relation to the clipping region; this determines //! those relationships. //! //! \return Returns the clipping code. // //*****************************************************************************
Computes the clipping code used by the Cohen-Sutherland clipping algorithm. \param pContext is a pointer to the drawing context to use. \param lX is the X coordinate of the point. \param lY is the Y coordinate of the point. This function computes the clipping code used by the Cohen-Sutherland clipping algorithm. Clipping is performed by classifying the endpoints of the line based on their relation to the clipping region; this determines those relationships. \return Returns the clipping code.
[ "Computes", "the", "clipping", "code", "used", "by", "the", "Cohen", "-", "Sutherland", "clipping", "algorithm", ".", "\\", "param", "pContext", "is", "a", "pointer", "to", "the", "drawing", "context", "to", "use", ".", "\\", "param", "lX", "is", "the", "X", "coordinate", "of", "the", "point", ".", "\\", "param", "lY", "is", "the", "Y", "coordinate", "of", "the", "point", ".", "This", "function", "computes", "the", "clipping", "code", "used", "by", "the", "Cohen", "-", "Sutherland", "clipping", "algorithm", ".", "Clipping", "is", "performed", "by", "classifying", "the", "endpoints", "of", "the", "line", "based", "on", "their", "relation", "to", "the", "clipping", "region", ";", "this", "determines", "those", "relationships", ".", "\\", "return", "Returns", "the", "clipping", "code", "." ]
static long GrClipCodeGet(const tContext *pContext, long lX, long lY) { long lCode; lCode = 0; if(lY < pContext->sClipRegion.sYMin) { lCode |= 1; } if(lY > pContext->sClipRegion.sYMax) { lCode |= 2; } if(lX < pContext->sClipRegion.sXMin) { lCode |= 4; } if(lX > pContext->sClipRegion.sXMax) { lCode |= 8; } return(lCode); }
[ "static", "long", "GrClipCodeGet", "(", "const", "tContext", "*", "pContext", ",", "long", "lX", ",", "long", "lY", ")", "{", "long", "lCode", ";", "lCode", "=", "0", ";", "if", "(", "lY", "<", "pContext", "->", "sClipRegion", ".", "sYMin", ")", "{", "lCode", "|=", "1", ";", "}", "if", "(", "lY", ">", "pContext", "->", "sClipRegion", ".", "sYMax", ")", "{", "lCode", "|=", "2", ";", "}", "if", "(", "lX", "<", "pContext", "->", "sClipRegion", ".", "sXMin", ")", "{", "lCode", "|=", "4", ";", "}", "if", "(", "lX", ">", "pContext", "->", "sClipRegion", ".", "sXMax", ")", "{", "lCode", "|=", "8", ";", "}", "return", "(", "lCode", ")", ";", "}" ]
Computes the clipping code used by the Cohen-Sutherland clipping algorithm.
[ "Computes", "the", "clipping", "code", "used", "by", "the", "Cohen", "-", "Sutherland", "clipping", "algorithm", "." ]
[ "//\r", "// Initialize the clipping code to zero.\r", "//\r", "//\r", "// Set bit zero of the clipping code if the Y coordinate is above the\r", "// clipping region.\r", "//\r", "//\r", "// Set bit one of the clipping code if the Y coordinate is below the\r", "// clipping region.\r", "//\r", "//\r", "// Set bit two of the clipping code if the X coordinate is to the left of\r", "// the clipping region.\r", "//\r", "//\r", "// Set bit three of the clipping code if the X coordinate is to the right\r", "// of the clipping region.\r", "//\r", "//\r", "// Return the clipping code.\r", "//\r" ]
[ { "param": "pContext", "type": "tContext" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55a3c995a1fd2bcc0c5889730374ce001f8c6597
junyanl-code/Luminary-Micro-Library
grlib/line.c
[ "BSD-3-Clause" ]
C
GrLineClip
null
static long GrLineClip(const tContext *pContext, long *plX1, long *plY1, long *plX2, long *plY2) { long lCode, lCode1, lCode2, lX, lY; // // Compute the clipping codes for the two endpoints of the line. // lCode1 = GrClipCodeGet(pContext, *plX1, *plY1); lCode2 = GrClipCodeGet(pContext, *plX2, *plY2); // // Loop forever. This loop will be explicitly broken out of when the line // is either trivially accepted or trivially rejected. // while(1) { // // If both codes are zero, then both points lie within the extent of // the clipping region. In this case, trivally accept the line. // if((lCode1 == 0) && (lCode2 == 0)) { return(1); } // // If the intersection of the codes is non-zero, then the line lies // entirely off one edge of the clipping region. In this case, // trivally reject the line. // if((lCode1 & lCode2) != 0) { return(0); } // // Determine the end of the line to move. The first end of the line is // moved until it is within the clipping region, and then the second // end of the line is moved until it is also within the clipping // region. // if(lCode1) { lCode = lCode1; } else { lCode = lCode2; } // // See if this end of the line lies above the clipping region. // if(lCode & 1) { // // Move this end of the line to the intersection of the line and // the top of the clipping region. // lX = (*plX1 + (((*plX2 - *plX1) * (pContext->sClipRegion.sYMin - *plY1)) / (*plY2 - *plY1))); lY = pContext->sClipRegion.sYMin; } // // Otherwise, see if this end of the line lies below the clipping // region. // else if(lCode & 2) { // // Move this end of the line to the intersection of the line and // the bottom of the clipping region. // lX = (*plX1 + (((*plX2 - *plX1) * (pContext->sClipRegion.sYMax - *plY1)) / (*plY2 - *plY1))); lY = pContext->sClipRegion.sYMax; } // // Otherwise, see if this end of the line lies to the left of the // clipping region. // else if(lCode & 4) { // // Move this end of the line to the intersection of the line and // the left side of the clipping region. // lX = pContext->sClipRegion.sXMin; lY = (*plY1 + (((*plY2 - *plY1) * (pContext->sClipRegion.sXMin - *plX1)) / (*plX2 - *plX1))); } // // Otherwise, this end of the line lies to the right of the clipping // region. // else { // // Move this end of the line to the intersection of the line and // the right side of the clipping region. // lX = pContext->sClipRegion.sXMax; lY = (*plY1 + (((*plY2 - *plY1) * (pContext->sClipRegion.sXMax - *plX1)) / (*plX2 - *plX1))); } // // See which end of the line just moved. // if(lCode1) { // // Save the new coordinates for the start of the line. // *plX1 = lX; *plY1 = lY; // // Recompute the clipping code for the start of the line. // lCode1 = GrClipCodeGet(pContext, lX, lY); } else { // // Save the new coordinates for the end of the line. // *plX2 = lX; *plY2 = lY; // // Recompute the clipping code for the end of the line. // lCode2 = GrClipCodeGet(pContext, lX, lY); } } }
//***************************************************************************** // //! Clips a line to the clipping region. //! //! \param pContext is a pointer to the drawing context to use. //! \param plX1 is the X coordinate of the start of the line. //! \param plY1 is the Y coordinate of the start of the line. //! \param plX2 is the X coordinate of the end of the line. //! \param plY2 is the Y coordinate of the end of the line. //! //! This function clips a line to the extents of the clipping region using the //! Cohen-Sutherland clipping algorithm. The ends of the line are classified //! based on their relation to the clipping region, and the codes are used to //! either trivially accept a line (both end points within the clipping //! region), trivially reject a line (both end points to one side of the //! clipping region), or to adjust an endpoint one axis at a time to the edge //! of the clipping region until the line can either be trivially accepted or //! trivially rejected. //! //! The provided coordinates are modified such that they reside within the //! extents of the clipping region if the line is not rejected. If it is //! rejected, the coordinates may be modified during the process of attempting //! to clip them. //! //! \return Returns one if the clipped line lies within the extent of the //! clipping region and zero if it does not. // //*****************************************************************************
Clips a line to the clipping region. \param pContext is a pointer to the drawing context to use. \param plX1 is the X coordinate of the start of the line. \param plY1 is the Y coordinate of the start of the line. \param plX2 is the X coordinate of the end of the line. \param plY2 is the Y coordinate of the end of the line. This function clips a line to the extents of the clipping region using the Cohen-Sutherland clipping algorithm. The ends of the line are classified based on their relation to the clipping region, and the codes are used to either trivially accept a line (both end points within the clipping region), trivially reject a line (both end points to one side of the clipping region), or to adjust an endpoint one axis at a time to the edge of the clipping region until the line can either be trivially accepted or trivially rejected. The provided coordinates are modified such that they reside within the extents of the clipping region if the line is not rejected. If it is rejected, the coordinates may be modified during the process of attempting to clip them. \return Returns one if the clipped line lies within the extent of the clipping region and zero if it does not.
[ "Clips", "a", "line", "to", "the", "clipping", "region", ".", "\\", "param", "pContext", "is", "a", "pointer", "to", "the", "drawing", "context", "to", "use", ".", "\\", "param", "plX1", "is", "the", "X", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "plY1", "is", "the", "Y", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "plX2", "is", "the", "X", "coordinate", "of", "the", "end", "of", "the", "line", ".", "\\", "param", "plY2", "is", "the", "Y", "coordinate", "of", "the", "end", "of", "the", "line", ".", "This", "function", "clips", "a", "line", "to", "the", "extents", "of", "the", "clipping", "region", "using", "the", "Cohen", "-", "Sutherland", "clipping", "algorithm", ".", "The", "ends", "of", "the", "line", "are", "classified", "based", "on", "their", "relation", "to", "the", "clipping", "region", "and", "the", "codes", "are", "used", "to", "either", "trivially", "accept", "a", "line", "(", "both", "end", "points", "within", "the", "clipping", "region", ")", "trivially", "reject", "a", "line", "(", "both", "end", "points", "to", "one", "side", "of", "the", "clipping", "region", ")", "or", "to", "adjust", "an", "endpoint", "one", "axis", "at", "a", "time", "to", "the", "edge", "of", "the", "clipping", "region", "until", "the", "line", "can", "either", "be", "trivially", "accepted", "or", "trivially", "rejected", ".", "The", "provided", "coordinates", "are", "modified", "such", "that", "they", "reside", "within", "the", "extents", "of", "the", "clipping", "region", "if", "the", "line", "is", "not", "rejected", ".", "If", "it", "is", "rejected", "the", "coordinates", "may", "be", "modified", "during", "the", "process", "of", "attempting", "to", "clip", "them", ".", "\\", "return", "Returns", "one", "if", "the", "clipped", "line", "lies", "within", "the", "extent", "of", "the", "clipping", "region", "and", "zero", "if", "it", "does", "not", "." ]
static long GrLineClip(const tContext *pContext, long *plX1, long *plY1, long *plX2, long *plY2) { long lCode, lCode1, lCode2, lX, lY; lCode1 = GrClipCodeGet(pContext, *plX1, *plY1); lCode2 = GrClipCodeGet(pContext, *plX2, *plY2); while(1) { if((lCode1 == 0) && (lCode2 == 0)) { return(1); } if((lCode1 & lCode2) != 0) { return(0); } if(lCode1) { lCode = lCode1; } else { lCode = lCode2; } if(lCode & 1) { lX = (*plX1 + (((*plX2 - *plX1) * (pContext->sClipRegion.sYMin - *plY1)) / (*plY2 - *plY1))); lY = pContext->sClipRegion.sYMin; } else if(lCode & 2) { lX = (*plX1 + (((*plX2 - *plX1) * (pContext->sClipRegion.sYMax - *plY1)) / (*plY2 - *plY1))); lY = pContext->sClipRegion.sYMax; } else if(lCode & 4) { lX = pContext->sClipRegion.sXMin; lY = (*plY1 + (((*plY2 - *plY1) * (pContext->sClipRegion.sXMin - *plX1)) / (*plX2 - *plX1))); } else { lX = pContext->sClipRegion.sXMax; lY = (*plY1 + (((*plY2 - *plY1) * (pContext->sClipRegion.sXMax - *plX1)) / (*plX2 - *plX1))); } if(lCode1) { *plX1 = lX; *plY1 = lY; lCode1 = GrClipCodeGet(pContext, lX, lY); } else { *plX2 = lX; *plY2 = lY; lCode2 = GrClipCodeGet(pContext, lX, lY); } } }
[ "static", "long", "GrLineClip", "(", "const", "tContext", "*", "pContext", ",", "long", "*", "plX1", ",", "long", "*", "plY1", ",", "long", "*", "plX2", ",", "long", "*", "plY2", ")", "{", "long", "lCode", ",", "lCode1", ",", "lCode2", ",", "lX", ",", "lY", ";", "lCode1", "=", "GrClipCodeGet", "(", "pContext", ",", "*", "plX1", ",", "*", "plY1", ")", ";", "lCode2", "=", "GrClipCodeGet", "(", "pContext", ",", "*", "plX2", ",", "*", "plY2", ")", ";", "while", "(", "1", ")", "{", "if", "(", "(", "lCode1", "==", "0", ")", "&&", "(", "lCode2", "==", "0", ")", ")", "{", "return", "(", "1", ")", ";", "}", "if", "(", "(", "lCode1", "&", "lCode2", ")", "!=", "0", ")", "{", "return", "(", "0", ")", ";", "}", "if", "(", "lCode1", ")", "{", "lCode", "=", "lCode1", ";", "}", "else", "{", "lCode", "=", "lCode2", ";", "}", "if", "(", "lCode", "&", "1", ")", "{", "lX", "=", "(", "*", "plX1", "+", "(", "(", "(", "*", "plX2", "-", "*", "plX1", ")", "*", "(", "pContext", "->", "sClipRegion", ".", "sYMin", "-", "*", "plY1", ")", ")", "/", "(", "*", "plY2", "-", "*", "plY1", ")", ")", ")", ";", "lY", "=", "pContext", "->", "sClipRegion", ".", "sYMin", ";", "}", "else", "if", "(", "lCode", "&", "2", ")", "{", "lX", "=", "(", "*", "plX1", "+", "(", "(", "(", "*", "plX2", "-", "*", "plX1", ")", "*", "(", "pContext", "->", "sClipRegion", ".", "sYMax", "-", "*", "plY1", ")", ")", "/", "(", "*", "plY2", "-", "*", "plY1", ")", ")", ")", ";", "lY", "=", "pContext", "->", "sClipRegion", ".", "sYMax", ";", "}", "else", "if", "(", "lCode", "&", "4", ")", "{", "lX", "=", "pContext", "->", "sClipRegion", ".", "sXMin", ";", "lY", "=", "(", "*", "plY1", "+", "(", "(", "(", "*", "plY2", "-", "*", "plY1", ")", "*", "(", "pContext", "->", "sClipRegion", ".", "sXMin", "-", "*", "plX1", ")", ")", "/", "(", "*", "plX2", "-", "*", "plX1", ")", ")", ")", ";", "}", "else", "{", "lX", "=", "pContext", "->", "sClipRegion", ".", "sXMax", ";", "lY", "=", "(", "*", "plY1", "+", "(", "(", "(", "*", "plY2", "-", "*", "plY1", ")", "*", "(", "pContext", "->", "sClipRegion", ".", "sXMax", "-", "*", "plX1", ")", ")", "/", "(", "*", "plX2", "-", "*", "plX1", ")", ")", ")", ";", "}", "if", "(", "lCode1", ")", "{", "*", "plX1", "=", "lX", ";", "*", "plY1", "=", "lY", ";", "lCode1", "=", "GrClipCodeGet", "(", "pContext", ",", "lX", ",", "lY", ")", ";", "}", "else", "{", "*", "plX2", "=", "lX", ";", "*", "plY2", "=", "lY", ";", "lCode2", "=", "GrClipCodeGet", "(", "pContext", ",", "lX", ",", "lY", ")", ";", "}", "}", "}" ]
Clips a line to the clipping region.
[ "Clips", "a", "line", "to", "the", "clipping", "region", "." ]
[ "//\r", "// Compute the clipping codes for the two endpoints of the line.\r", "//\r", "//\r", "// Loop forever. This loop will be explicitly broken out of when the line\r", "// is either trivially accepted or trivially rejected.\r", "//\r", "//\r", "// If both codes are zero, then both points lie within the extent of\r", "// the clipping region. In this case, trivally accept the line.\r", "//\r", "//\r", "// If the intersection of the codes is non-zero, then the line lies\r", "// entirely off one edge of the clipping region. In this case,\r", "// trivally reject the line.\r", "//\r", "//\r", "// Determine the end of the line to move. The first end of the line is\r", "// moved until it is within the clipping region, and then the second\r", "// end of the line is moved until it is also within the clipping\r", "// region.\r", "//\r", "//\r", "// See if this end of the line lies above the clipping region.\r", "//\r", "//\r", "// Move this end of the line to the intersection of the line and\r", "// the top of the clipping region.\r", "//\r", "//\r", "// Otherwise, see if this end of the line lies below the clipping\r", "// region.\r", "//\r", "//\r", "// Move this end of the line to the intersection of the line and\r", "// the bottom of the clipping region.\r", "//\r", "//\r", "// Otherwise, see if this end of the line lies to the left of the\r", "// clipping region.\r", "//\r", "//\r", "// Move this end of the line to the intersection of the line and\r", "// the left side of the clipping region.\r", "//\r", "//\r", "// Otherwise, this end of the line lies to the right of the clipping\r", "// region.\r", "//\r", "//\r", "// Move this end of the line to the intersection of the line and\r", "// the right side of the clipping region.\r", "//\r", "//\r", "// See which end of the line just moved.\r", "//\r", "//\r", "// Save the new coordinates for the start of the line.\r", "//\r", "//\r", "// Recompute the clipping code for the start of the line.\r", "//\r", "//\r", "// Save the new coordinates for the end of the line.\r", "//\r", "//\r", "// Recompute the clipping code for the end of the line.\r", "//\r" ]
[ { "param": "pContext", "type": "tContext" }, { "param": "plX1", "type": "long" }, { "param": "plY1", "type": "long" }, { "param": "plX2", "type": "long" }, { "param": "plY2", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plX1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plY1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plX2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plY2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55a3c995a1fd2bcc0c5889730374ce001f8c6597
junyanl-code/Luminary-Micro-Library
grlib/line.c
[ "BSD-3-Clause" ]
C
GrLineDraw
void
void GrLineDraw(const tContext *pContext, long lX1, long lY1, long lX2, long lY2) { long lError, lDeltaX, lDeltaY, lYStep, bSteep; // // Check the arguments. // ASSERT(pContext); // // See if this is a vertical line. // if(lX1 == lX2) { // // It is more efficient to avoid Bresenham's algorithm when drawing a // vertical line, so use the vertical line routine to draw this line. // GrLineDrawV(pContext, lX1, lY1, lY2); // // The line has ben drawn, so return. // return; } // // See if this is a horizontal line. // if(lY1 == lY2) { // // It is more efficient to avoid Bresenham's algorithm when drawing a // horizontal line, so use the horizontal line routien to draw this // line. // GrLineDrawH(pContext, lX1, lX2, lY1); // // The line has ben drawn, so return. // return; } // // Clip this line if necessary, and return without drawing anything if the // line does not cross the clipping region. // if(GrLineClip(pContext, &lX1, &lY1, &lX2, &lY2) == 0) { return; } // // Determine if the line is steep. A steep line has more motion in the Y // direction than the X direction. // if(((lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2)) > ((lX2 > lX1) ? (lX2 - lX1) : (lX1 - lX2))) { bSteep = 1; } else { bSteep = 0; } // // If the line is steep, then swap the X and Y coordinates. // if(bSteep) { lError = lX1; lX1 = lY1; lY1 = lError; lError = lX2; lX2 = lY2; lY2 = lError; } // // If the starting X coordinate is larger than the ending X coordinate, // then swap the start and end coordinates. // if(lX1 > lX2) { lError = lX1; lX1 = lX2; lX2 = lError; lError = lY1; lY1 = lY2; lY2 = lError; } // // Compute the difference between the start and end coordinates in each // axis. // lDeltaX = lX2 - lX1; lDeltaY = (lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2); // // Initialize the error term to negative half the X delta. // lError = -lDeltaX / 2; // // Determine the direction to step in the Y axis when required. // if(lY1 < lY2) { lYStep = 1; } else { lYStep = -1; } // // Loop through all the points along the X axis of the line. // for(; lX1 <= lX2; lX1++) { // // See if this is a steep line. // if(bSteep) { // // Plot this point of the line, swapping the X and Y coordinates. // DpyPixelDraw(pContext->pDisplay, lY1, lX1, pContext->ulForeground); } else { // // Plot this point of the line, using the coordinates as is. // DpyPixelDraw(pContext->pDisplay, lX1, lY1, pContext->ulForeground); } // // Increment the error term by the Y delta. // lError += lDeltaY; // // See if the error term is now greater than zero. // if(lError > 0) { // // Take a step in the Y axis. // lY1 += lYStep; // // Decrement the error term by the X delta. // lError -= lDeltaX; } } }
//***************************************************************************** // //! Draws a line. //! //! \param pContext is a pointer to the drawing context to use. //! \param lX1 is the X coordinate of the start of the line. //! \param lY1 is the Y coordinate of the start of the line. //! \param lX2 is the X coordinate of the end of the line. //! \param lY2 is the Y coordinate of the end of the line. //! //! This function draws a line, utilizing GrLineDrawH() and GrLineDrawV() to //! draw the line as efficiently as possible. The line is clipped to the //! clippping rectangle using the Cohen-Sutherland clipping algorithm, and then //! scan converted using Bresenham's line drawing algorithm. //! //! \return None. // //*****************************************************************************
Draws a line. \param pContext is a pointer to the drawing context to use. \param lX1 is the X coordinate of the start of the line. \param lY1 is the Y coordinate of the start of the line. \param lX2 is the X coordinate of the end of the line. \param lY2 is the Y coordinate of the end of the line. This function draws a line, utilizing GrLineDrawH() and GrLineDrawV() to draw the line as efficiently as possible. The line is clipped to the clippping rectangle using the Cohen-Sutherland clipping algorithm, and then scan converted using Bresenham's line drawing algorithm. \return None.
[ "Draws", "a", "line", ".", "\\", "param", "pContext", "is", "a", "pointer", "to", "the", "drawing", "context", "to", "use", ".", "\\", "param", "lX1", "is", "the", "X", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "lY1", "is", "the", "Y", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "lX2", "is", "the", "X", "coordinate", "of", "the", "end", "of", "the", "line", ".", "\\", "param", "lY2", "is", "the", "Y", "coordinate", "of", "the", "end", "of", "the", "line", ".", "This", "function", "draws", "a", "line", "utilizing", "GrLineDrawH", "()", "and", "GrLineDrawV", "()", "to", "draw", "the", "line", "as", "efficiently", "as", "possible", ".", "The", "line", "is", "clipped", "to", "the", "clippping", "rectangle", "using", "the", "Cohen", "-", "Sutherland", "clipping", "algorithm", "and", "then", "scan", "converted", "using", "Bresenham", "'", "s", "line", "drawing", "algorithm", ".", "\\", "return", "None", "." ]
void GrLineDraw(const tContext *pContext, long lX1, long lY1, long lX2, long lY2) { long lError, lDeltaX, lDeltaY, lYStep, bSteep; ASSERT(pContext); if(lX1 == lX2) { GrLineDrawV(pContext, lX1, lY1, lY2); return; } if(lY1 == lY2) { GrLineDrawH(pContext, lX1, lX2, lY1); return; } if(GrLineClip(pContext, &lX1, &lY1, &lX2, &lY2) == 0) { return; } if(((lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2)) > ((lX2 > lX1) ? (lX2 - lX1) : (lX1 - lX2))) { bSteep = 1; } else { bSteep = 0; } if(bSteep) { lError = lX1; lX1 = lY1; lY1 = lError; lError = lX2; lX2 = lY2; lY2 = lError; } if(lX1 > lX2) { lError = lX1; lX1 = lX2; lX2 = lError; lError = lY1; lY1 = lY2; lY2 = lError; } lDeltaX = lX2 - lX1; lDeltaY = (lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2); lError = -lDeltaX / 2; if(lY1 < lY2) { lYStep = 1; } else { lYStep = -1; } for(; lX1 <= lX2; lX1++) { if(bSteep) { DpyPixelDraw(pContext->pDisplay, lY1, lX1, pContext->ulForeground); } else { DpyPixelDraw(pContext->pDisplay, lX1, lY1, pContext->ulForeground); } lError += lDeltaY; if(lError > 0) { lY1 += lYStep; lError -= lDeltaX; } } }
[ "void", "GrLineDraw", "(", "const", "tContext", "*", "pContext", ",", "long", "lX1", ",", "long", "lY1", ",", "long", "lX2", ",", "long", "lY2", ")", "{", "long", "lError", ",", "lDeltaX", ",", "lDeltaY", ",", "lYStep", ",", "bSteep", ";", "ASSERT", "(", "pContext", ")", ";", "if", "(", "lX1", "==", "lX2", ")", "{", "GrLineDrawV", "(", "pContext", ",", "lX1", ",", "lY1", ",", "lY2", ")", ";", "return", ";", "}", "if", "(", "lY1", "==", "lY2", ")", "{", "GrLineDrawH", "(", "pContext", ",", "lX1", ",", "lX2", ",", "lY1", ")", ";", "return", ";", "}", "if", "(", "GrLineClip", "(", "pContext", ",", "&", "lX1", ",", "&", "lY1", ",", "&", "lX2", ",", "&", "lY2", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "(", "(", "lY2", ">", "lY1", ")", "?", "(", "lY2", "-", "lY1", ")", ":", "(", "lY1", "-", "lY2", ")", ")", ">", "(", "(", "lX2", ">", "lX1", ")", "?", "(", "lX2", "-", "lX1", ")", ":", "(", "lX1", "-", "lX2", ")", ")", ")", "{", "bSteep", "=", "1", ";", "}", "else", "{", "bSteep", "=", "0", ";", "}", "if", "(", "bSteep", ")", "{", "lError", "=", "lX1", ";", "lX1", "=", "lY1", ";", "lY1", "=", "lError", ";", "lError", "=", "lX2", ";", "lX2", "=", "lY2", ";", "lY2", "=", "lError", ";", "}", "if", "(", "lX1", ">", "lX2", ")", "{", "lError", "=", "lX1", ";", "lX1", "=", "lX2", ";", "lX2", "=", "lError", ";", "lError", "=", "lY1", ";", "lY1", "=", "lY2", ";", "lY2", "=", "lError", ";", "}", "lDeltaX", "=", "lX2", "-", "lX1", ";", "lDeltaY", "=", "(", "lY2", ">", "lY1", ")", "?", "(", "lY2", "-", "lY1", ")", ":", "(", "lY1", "-", "lY2", ")", ";", "lError", "=", "-", "lDeltaX", "/", "2", ";", "if", "(", "lY1", "<", "lY2", ")", "{", "lYStep", "=", "1", ";", "}", "else", "{", "lYStep", "=", "-1", ";", "}", "for", "(", ";", "lX1", "<=", "lX2", ";", "lX1", "++", ")", "{", "if", "(", "bSteep", ")", "{", "DpyPixelDraw", "(", "pContext", "->", "pDisplay", ",", "lY1", ",", "lX1", ",", "pContext", "->", "ulForeground", ")", ";", "}", "else", "{", "DpyPixelDraw", "(", "pContext", "->", "pDisplay", ",", "lX1", ",", "lY1", ",", "pContext", "->", "ulForeground", ")", ";", "}", "lError", "+=", "lDeltaY", ";", "if", "(", "lError", ">", "0", ")", "{", "lY1", "+=", "lYStep", ";", "lError", "-=", "lDeltaX", ";", "}", "}", "}" ]
Draws a line.
[ "Draws", "a", "line", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// See if this is a vertical line.\r", "//\r", "//\r", "// It is more efficient to avoid Bresenham's algorithm when drawing a\r", "// vertical line, so use the vertical line routine to draw this line.\r", "//\r", "//\r", "// The line has ben drawn, so return.\r", "//\r", "//\r", "// See if this is a horizontal line.\r", "//\r", "//\r", "// It is more efficient to avoid Bresenham's algorithm when drawing a\r", "// horizontal line, so use the horizontal line routien to draw this\r", "// line.\r", "//\r", "//\r", "// The line has ben drawn, so return.\r", "//\r", "//\r", "// Clip this line if necessary, and return without drawing anything if the\r", "// line does not cross the clipping region.\r", "//\r", "//\r", "// Determine if the line is steep. A steep line has more motion in the Y\r", "// direction than the X direction.\r", "//\r", "//\r", "// If the line is steep, then swap the X and Y coordinates.\r", "//\r", "//\r", "// If the starting X coordinate is larger than the ending X coordinate,\r", "// then swap the start and end coordinates.\r", "//\r", "//\r", "// Compute the difference between the start and end coordinates in each\r", "// axis.\r", "//\r", "//\r", "// Initialize the error term to negative half the X delta.\r", "//\r", "//\r", "// Determine the direction to step in the Y axis when required.\r", "//\r", "//\r", "// Loop through all the points along the X axis of the line.\r", "//\r", "//\r", "// See if this is a steep line.\r", "//\r", "//\r", "// Plot this point of the line, swapping the X and Y coordinates.\r", "//\r", "//\r", "// Plot this point of the line, using the coordinates as is.\r", "//\r", "//\r", "// Increment the error term by the Y delta.\r", "//\r", "//\r", "// See if the error term is now greater than zero.\r", "//\r", "//\r", "// Take a step in the Y axis.\r", "//\r", "//\r", "// Decrement the error term by the X delta.\r", "//\r" ]
[ { "param": "pContext", "type": "tContext" }, { "param": "lX1", "type": "long" }, { "param": "lY1", "type": "long" }, { "param": "lX2", "type": "long" }, { "param": "lY2", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY1", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY2", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4ea1c5d81a61fc7d43f7fa746110c76a620b0c43
junyanl-code/Luminary-Micro-Library
boards/rdk-bdc/bdc-ui/bdc-ui.c
[ "BSD-3-Clause" ]
C
SysTickIntHandler
void
void SysTickIntHandler(void) { unsigned long ulButtons, ulIdx; // // Set the flag that indicates that a timer tick has occurred. // HWREGBITW(&g_ulFlags, FLAG_TICK) = 1; // // Increment the count of ticks. // g_ulTickCount++; // // Call the CAN periodic tick function. // CANTick(); // // Call the push button periodic tick function. // ulButtons = ButtonsTick(); // // Set the appropriate button press flags if the corresponding button was // pressed. // for(ulIdx = 0; ulIdx < (sizeof(g_ppulButtonMap) / sizeof(g_ppulButtonMap[0])); ulIdx++) { if(ulButtons & g_ppulButtonMap[ulIdx][0]) { HWREGBITW(&g_ulFlags, g_ppulButtonMap[ulIdx][1]) = 1; } } }
//***************************************************************************** // // This function is called by SysTick once every millisecond. // //*****************************************************************************
This function is called by SysTick once every millisecond.
[ "This", "function", "is", "called", "by", "SysTick", "once", "every", "millisecond", "." ]
void SysTickIntHandler(void) { unsigned long ulButtons, ulIdx; HWREGBITW(&g_ulFlags, FLAG_TICK) = 1; g_ulTickCount++; CANTick(); ulButtons = ButtonsTick(); for(ulIdx = 0; ulIdx < (sizeof(g_ppulButtonMap) / sizeof(g_ppulButtonMap[0])); ulIdx++) { if(ulButtons & g_ppulButtonMap[ulIdx][0]) { HWREGBITW(&g_ulFlags, g_ppulButtonMap[ulIdx][1]) = 1; } } }
[ "void", "SysTickIntHandler", "(", "void", ")", "{", "unsigned", "long", "ulButtons", ",", "ulIdx", ";", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_TICK", ")", "=", "1", ";", "g_ulTickCount", "++", ";", "CANTick", "(", ")", ";", "ulButtons", "=", "ButtonsTick", "(", ")", ";", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "(", "sizeof", "(", "g_ppulButtonMap", ")", "/", "sizeof", "(", "g_ppulButtonMap", "[", "0", "]", ")", ")", ";", "ulIdx", "++", ")", "{", "if", "(", "ulButtons", "&", "g_ppulButtonMap", "[", "ulIdx", "]", "[", "0", "]", ")", "{", "HWREGBITW", "(", "&", "g_ulFlags", ",", "g_ppulButtonMap", "[", "ulIdx", "]", "[", "1", "]", ")", "=", "1", ";", "}", "}", "}" ]
This function is called by SysTick once every millisecond.
[ "This", "function", "is", "called", "by", "SysTick", "once", "every", "millisecond", "." ]
[ "//\r", "// Set the flag that indicates that a timer tick has occurred.\r", "//\r", "//\r", "// Increment the count of ticks.\r", "//\r", "//\r", "// Call the CAN periodic tick function.\r", "//\r", "//\r", "// Call the push button periodic tick function.\r", "//\r", "//\r", "// Set the appropriate button press flags if the corresponding button was\r", "// pressed.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4ea1c5d81a61fc7d43f7fa746110c76a620b0c43
junyanl-code/Luminary-Micro-Library
boards/rdk-bdc/bdc-ui/bdc-ui.c
[ "BSD-3-Clause" ]
C
DisplaySplash
void
static void DisplaySplash(void) { unsigned long ulIdx; tContext sContext; tRectangle sRect; // // Initialize a drawing context. // GrContextInit(&sContext, &g_sRIT128x96x4Display); // // Clear the screen. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = 127; sRect.sYMax = 95; GrContextForegroundSet(&sContext, ClrBlack); GrRectFill(&sContext, &sRect); // // Draw the splash screen image on the screen. // GrImageDraw(&sContext, g_pucSplashImage, 0, 10); // // Draw some text below the splash screen image. // GrContextForegroundSet(&sContext, ClrWhite); GrContextFontSet(&sContext, g_pFontFixed6x8); GrStringDrawCentered(&sContext, "Brushed DC Motor", -1, 63, 73, 0); GrStringDrawCentered(&sContext, "Reference Design Kit", -1, 63, 81, 0); // // Flush the drawing operations to the screen. // GrFlush(&sContext); // // Delay for 5 seconds while the splash screen is displayed. // for(ulIdx = 0; ulIdx < 5000; ulIdx++) { HWREGBITW(&g_ulFlags, FLAG_TICK) = 0; while(HWREGBITW(&g_ulFlags, FLAG_TICK) == 0) { } } // // Ignore any buttons that were pressed while the splash screen was // displayed. // HWREGBITW(&g_ulFlags, FLAG_UP_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_DOWN_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_LEFT_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_RIGHT_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_SELECT_PRESSED) = 0; }
//***************************************************************************** // // This function displays the splash screen. // //*****************************************************************************
This function displays the splash screen.
[ "This", "function", "displays", "the", "splash", "screen", "." ]
static void DisplaySplash(void) { unsigned long ulIdx; tContext sContext; tRectangle sRect; GrContextInit(&sContext, &g_sRIT128x96x4Display); sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = 127; sRect.sYMax = 95; GrContextForegroundSet(&sContext, ClrBlack); GrRectFill(&sContext, &sRect); GrImageDraw(&sContext, g_pucSplashImage, 0, 10); GrContextForegroundSet(&sContext, ClrWhite); GrContextFontSet(&sContext, g_pFontFixed6x8); GrStringDrawCentered(&sContext, "Brushed DC Motor", -1, 63, 73, 0); GrStringDrawCentered(&sContext, "Reference Design Kit", -1, 63, 81, 0); GrFlush(&sContext); for(ulIdx = 0; ulIdx < 5000; ulIdx++) { HWREGBITW(&g_ulFlags, FLAG_TICK) = 0; while(HWREGBITW(&g_ulFlags, FLAG_TICK) == 0) { } } HWREGBITW(&g_ulFlags, FLAG_UP_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_DOWN_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_LEFT_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_RIGHT_PRESSED) = 0; HWREGBITW(&g_ulFlags, FLAG_SELECT_PRESSED) = 0; }
[ "static", "void", "DisplaySplash", "(", "void", ")", "{", "unsigned", "long", "ulIdx", ";", "tContext", "sContext", ";", "tRectangle", "sRect", ";", "GrContextInit", "(", "&", "sContext", ",", "&", "g_sRIT128x96x4Display", ")", ";", "sRect", ".", "sXMin", "=", "0", ";", "sRect", ".", "sYMin", "=", "0", ";", "sRect", ".", "sXMax", "=", "127", ";", "sRect", ".", "sYMax", "=", "95", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrBlack", ")", ";", "GrRectFill", "(", "&", "sContext", ",", "&", "sRect", ")", ";", "GrImageDraw", "(", "&", "sContext", ",", "g_pucSplashImage", ",", "0", ",", "10", ")", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrWhite", ")", ";", "GrContextFontSet", "(", "&", "sContext", ",", "g_pFontFixed6x8", ")", ";", "GrStringDrawCentered", "(", "&", "sContext", ",", "\"", "\"", ",", "-1", ",", "63", ",", "73", ",", "0", ")", ";", "GrStringDrawCentered", "(", "&", "sContext", ",", "\"", "\"", ",", "-1", ",", "63", ",", "81", ",", "0", ")", ";", "GrFlush", "(", "&", "sContext", ")", ";", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "5000", ";", "ulIdx", "++", ")", "{", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_TICK", ")", "=", "0", ";", "while", "(", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_TICK", ")", "==", "0", ")", "{", "}", "}", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_UP_PRESSED", ")", "=", "0", ";", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_DOWN_PRESSED", ")", "=", "0", ";", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_LEFT_PRESSED", ")", "=", "0", ";", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_RIGHT_PRESSED", ")", "=", "0", ";", "HWREGBITW", "(", "&", "g_ulFlags", ",", "FLAG_SELECT_PRESSED", ")", "=", "0", ";", "}" ]
This function displays the splash screen.
[ "This", "function", "displays", "the", "splash", "screen", "." ]
[ "//\r", "// Initialize a drawing context.\r", "//\r", "//\r", "// Clear the screen.\r", "//\r", "//\r", "// Draw the splash screen image on the screen.\r", "//\r", "//\r", "// Draw some text below the splash screen image.\r", "//\r", "//\r", "// Flush the drawing operations to the screen.\r", "//\r", "//\r", "// Delay for 5 seconds while the splash screen is displayed.\r", "//\r", "//\r", "// Ignore any buttons that were pressed while the splash screen was\r", "// displayed.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4ea1c5d81a61fc7d43f7fa746110c76a620b0c43
junyanl-code/Luminary-Micro-Library
boards/rdk-bdc/bdc-ui/bdc-ui.c
[ "BSD-3-Clause" ]
C
DisplayFlush
void
void DisplayFlush(void) { // // Send a paint message to the entire widget tree. // WidgetPaint(WIDGET_ROOT); // // Process any widget messages in the message queue. // WidgetMessageQueueProcess(); // // Flush the drawing operations to the screen. // DpyFlush(&g_sRIT128x96x4Display); }
//***************************************************************************** // // This function causes the display to be redrawn. // //*****************************************************************************
This function causes the display to be redrawn.
[ "This", "function", "causes", "the", "display", "to", "be", "redrawn", "." ]
void DisplayFlush(void) { WidgetPaint(WIDGET_ROOT); WidgetMessageQueueProcess(); DpyFlush(&g_sRIT128x96x4Display); }
[ "void", "DisplayFlush", "(", "void", ")", "{", "WidgetPaint", "(", "WIDGET_ROOT", ")", ";", "WidgetMessageQueueProcess", "(", ")", ";", "DpyFlush", "(", "&", "g_sRIT128x96x4Display", ")", ";", "}" ]
This function causes the display to be redrawn.
[ "This", "function", "causes", "the", "display", "to", "be", "redrawn", "." ]
[ "//\r", "// Send a paint message to the entire widget tree.\r", "//\r", "//\r", "// Process any widget messages in the message queue.\r", "//\r", "//\r", "// Flush the drawing operations to the screen.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c6316af383e4dc322f967445ce327d74ef1628d7
junyanl-code/Luminary-Micro-Library
boards/rdk-acim/qs-acim/adc_ctrl.c
[ "BSD-3-Clause" ]
C
ADC0IntHandler
void
void ADC0IntHandler(void) { unsigned long ulIdx; unsigned short pusADCData[8]; // // Clear the ADC interrupt. // ADCIntClear(ADC0_BASE, 0); // // Read the samples from the ADC FIFO. // ulIdx = 0; while(!(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) && (ulIdx < 8)) { // // Read the next sample. // pusADCData[ulIdx] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); // // Increment the count of samples read. // ulIdx++; } // // See if five samples were read. // if(ulIdx != 5) { // // Since there were not precisely five samples in the FIFO, it is not // known what analog signal is represented by each sample. Therefore, // return without doing any processing on these samples. // return; } // // Filter the new samples. // for(ulIdx = 0; ulIdx < 5; ulIdx++) { // // Pass the new data sample through a single pole IIR low pass filter // with a coefficient of 0.75. // g_pusFilteredData[ulIdx] = (((g_pusFilteredData[ulIdx] * 3) + pusADCData[ulIdx]) / 4); } // // Convert the ADC DC bus reading to volts. Each volt at the ADC input // corresponds to 150 volts of bus voltage. // g_usBusVoltage = ((unsigned long)g_pusFilteredData[3] * 450) / 1024; // // Convert the ADC junction temperature reading to ambient case temperature // in Celsius. // g_sAmbientTemp = (59960 - (g_pusFilteredData[4] * 100)) / 356; // // See if the motor drive is running. // if(!MainIsRunning()) { // // Since the motor drive is not running, there is no current through // the motor. // g_pusPhaseCurrentRMS[0] = 0; g_pusPhaseCurrentRMS[1] = 0; g_pusPhaseCurrentRMS[2] = 0; g_usMotorCurrent = 0; // // There is nothing further to be done since the motor is not running. // return; } // // See if the drive angle just crossed zero in either direction. // if(((g_ulAngle > 0xf0000000) && (g_ulPrevAngle < 0x10000000)) || ((g_ulAngle < 0x10000000) && (g_ulPrevAngle > 0xf0000000))) { // // Loop through the three phases of the motor drive. // for(ulIdx = 0; ulIdx < 3; ulIdx++) { // // Convert the maximum reading detected during the last cycle into // amperes. The phase current is measured as the voltage dropped // across a 0.04 Ohm resistor, so current is 25 times the voltage. // This is then passed through an op amp that multiplies the value // by 11. The resulting phase current is put into a 8.8 fixed // point representation and must therefore be multiplied by 256. // This is the peak current, which is then divided by 1.4 to get // the RMS current. Since the ADC reading is 0 to 1023 for // voltages between 0 V and 3 V, the final equation is: // // A = R * (25 / 11) * (3 / 1024) * (10 / 14) * 256 // // Reducing the constants results in R * 375 / 308. // g_pusPhaseCurrentRMS[ulIdx] = (((long)g_pusPhaseMax[ulIdx] * 375) / 308); // // Reset the maximum phase current seen to zero to prepare for the // next cycle. // g_pusPhaseMax[ulIdx] = 0; } // // See if this is a single phase or three phase motor. // if(HWREGBITH(&(g_sParameters.usFlags), FLAG_MOTOR_TYPE_BIT) == FLAG_MOTOR_TYPE_1PHASE) { // // Average the RMS current of the two phases to get the RMS motor // current. // pusADCData[0] = g_pusPhaseCurrentRMS[0]; pusADCData[1] = g_pusPhaseCurrentRMS[1]; g_usMotorCurrent = ((pusADCData[0] + pusADCData[1]) / 2); } else { // // Average the RMS current of the three phases to get the RMS motor // current. // pusADCData[0] = g_pusPhaseCurrentRMS[0]; pusADCData[1] = g_pusPhaseCurrentRMS[1]; pusADCData[2] = g_pusPhaseCurrentRMS[2]; g_usMotorCurrent = ((pusADCData[0] + pusADCData[1] + pusADCData[2]) / 3); } } // // Loop through the three phases of the motor drive. // for(ulIdx = 0; ulIdx < 3; ulIdx++) { // // See if this ADC reading is larger than any previous ADC reading. // if(g_pusFilteredData[ulIdx] > g_pusPhaseMax[ulIdx]) { // // Save this ADC reading as the maximum. // g_pusPhaseMax[ulIdx] = g_pusFilteredData[ulIdx]; } } // // Save the current motor drive angle for the next set of samples. // g_ulPrevAngle = g_ulAngle; }
//***************************************************************************** // //! Handles the ADC sample sequence zero interrupt. //! //! This function is called when sample sequence zero asserts an interrupt. It //! handles clearing the interrupt and processing the new ADC data in the FIFO. //! //! \return None. // //*****************************************************************************
Handles the ADC sample sequence zero interrupt. This function is called when sample sequence zero asserts an interrupt. It handles clearing the interrupt and processing the new ADC data in the FIFO. \return None.
[ "Handles", "the", "ADC", "sample", "sequence", "zero", "interrupt", ".", "This", "function", "is", "called", "when", "sample", "sequence", "zero", "asserts", "an", "interrupt", ".", "It", "handles", "clearing", "the", "interrupt", "and", "processing", "the", "new", "ADC", "data", "in", "the", "FIFO", ".", "\\", "return", "None", "." ]
void ADC0IntHandler(void) { unsigned long ulIdx; unsigned short pusADCData[8]; ADCIntClear(ADC0_BASE, 0); ulIdx = 0; while(!(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) && (ulIdx < 8)) { pusADCData[ulIdx] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); ulIdx++; } if(ulIdx != 5) { return; } for(ulIdx = 0; ulIdx < 5; ulIdx++) { g_pusFilteredData[ulIdx] = (((g_pusFilteredData[ulIdx] * 3) + pusADCData[ulIdx]) / 4); } g_usBusVoltage = ((unsigned long)g_pusFilteredData[3] * 450) / 1024; g_sAmbientTemp = (59960 - (g_pusFilteredData[4] * 100)) / 356; if(!MainIsRunning()) { g_pusPhaseCurrentRMS[0] = 0; g_pusPhaseCurrentRMS[1] = 0; g_pusPhaseCurrentRMS[2] = 0; g_usMotorCurrent = 0; return; } if(((g_ulAngle > 0xf0000000) && (g_ulPrevAngle < 0x10000000)) || ((g_ulAngle < 0x10000000) && (g_ulPrevAngle > 0xf0000000))) { for(ulIdx = 0; ulIdx < 3; ulIdx++) { g_pusPhaseCurrentRMS[ulIdx] = (((long)g_pusPhaseMax[ulIdx] * 375) / 308); g_pusPhaseMax[ulIdx] = 0; } if(HWREGBITH(&(g_sParameters.usFlags), FLAG_MOTOR_TYPE_BIT) == FLAG_MOTOR_TYPE_1PHASE) { pusADCData[0] = g_pusPhaseCurrentRMS[0]; pusADCData[1] = g_pusPhaseCurrentRMS[1]; g_usMotorCurrent = ((pusADCData[0] + pusADCData[1]) / 2); } else { pusADCData[0] = g_pusPhaseCurrentRMS[0]; pusADCData[1] = g_pusPhaseCurrentRMS[1]; pusADCData[2] = g_pusPhaseCurrentRMS[2]; g_usMotorCurrent = ((pusADCData[0] + pusADCData[1] + pusADCData[2]) / 3); } } for(ulIdx = 0; ulIdx < 3; ulIdx++) { if(g_pusFilteredData[ulIdx] > g_pusPhaseMax[ulIdx]) { g_pusPhaseMax[ulIdx] = g_pusFilteredData[ulIdx]; } } g_ulPrevAngle = g_ulAngle; }
[ "void", "ADC0IntHandler", "(", "void", ")", "{", "unsigned", "long", "ulIdx", ";", "unsigned", "short", "pusADCData", "[", "8", "]", ";", "ADCIntClear", "(", "ADC0_BASE", ",", "0", ")", ";", "ulIdx", "=", "0", ";", "while", "(", "!", "(", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_SSFSTAT0", ")", "&", "ADC_SSFSTAT0_EMPTY", ")", "&&", "(", "ulIdx", "<", "8", ")", ")", "{", "pusADCData", "[", "ulIdx", "]", "=", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_SSFIFO0", ")", ";", "ulIdx", "++", ";", "}", "if", "(", "ulIdx", "!=", "5", ")", "{", "return", ";", "}", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "5", ";", "ulIdx", "++", ")", "{", "g_pusFilteredData", "[", "ulIdx", "]", "=", "(", "(", "(", "g_pusFilteredData", "[", "ulIdx", "]", "*", "3", ")", "+", "pusADCData", "[", "ulIdx", "]", ")", "/", "4", ")", ";", "}", "g_usBusVoltage", "=", "(", "(", "unsigned", "long", ")", "g_pusFilteredData", "[", "3", "]", "*", "450", ")", "/", "1024", ";", "g_sAmbientTemp", "=", "(", "59960", "-", "(", "g_pusFilteredData", "[", "4", "]", "*", "100", ")", ")", "/", "356", ";", "if", "(", "!", "MainIsRunning", "(", ")", ")", "{", "g_pusPhaseCurrentRMS", "[", "0", "]", "=", "0", ";", "g_pusPhaseCurrentRMS", "[", "1", "]", "=", "0", ";", "g_pusPhaseCurrentRMS", "[", "2", "]", "=", "0", ";", "g_usMotorCurrent", "=", "0", ";", "return", ";", "}", "if", "(", "(", "(", "g_ulAngle", ">", "0xf0000000", ")", "&&", "(", "g_ulPrevAngle", "<", "0x10000000", ")", ")", "||", "(", "(", "g_ulAngle", "<", "0x10000000", ")", "&&", "(", "g_ulPrevAngle", ">", "0xf0000000", ")", ")", ")", "{", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "3", ";", "ulIdx", "++", ")", "{", "g_pusPhaseCurrentRMS", "[", "ulIdx", "]", "=", "(", "(", "(", "long", ")", "g_pusPhaseMax", "[", "ulIdx", "]", "*", "375", ")", "/", "308", ")", ";", "g_pusPhaseMax", "[", "ulIdx", "]", "=", "0", ";", "}", "if", "(", "HWREGBITH", "(", "&", "(", "g_sParameters", ".", "usFlags", ")", ",", "FLAG_MOTOR_TYPE_BIT", ")", "==", "FLAG_MOTOR_TYPE_1PHASE", ")", "{", "pusADCData", "[", "0", "]", "=", "g_pusPhaseCurrentRMS", "[", "0", "]", ";", "pusADCData", "[", "1", "]", "=", "g_pusPhaseCurrentRMS", "[", "1", "]", ";", "g_usMotorCurrent", "=", "(", "(", "pusADCData", "[", "0", "]", "+", "pusADCData", "[", "1", "]", ")", "/", "2", ")", ";", "}", "else", "{", "pusADCData", "[", "0", "]", "=", "g_pusPhaseCurrentRMS", "[", "0", "]", ";", "pusADCData", "[", "1", "]", "=", "g_pusPhaseCurrentRMS", "[", "1", "]", ";", "pusADCData", "[", "2", "]", "=", "g_pusPhaseCurrentRMS", "[", "2", "]", ";", "g_usMotorCurrent", "=", "(", "(", "pusADCData", "[", "0", "]", "+", "pusADCData", "[", "1", "]", "+", "pusADCData", "[", "2", "]", ")", "/", "3", ")", ";", "}", "}", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "3", ";", "ulIdx", "++", ")", "{", "if", "(", "g_pusFilteredData", "[", "ulIdx", "]", ">", "g_pusPhaseMax", "[", "ulIdx", "]", ")", "{", "g_pusPhaseMax", "[", "ulIdx", "]", "=", "g_pusFilteredData", "[", "ulIdx", "]", ";", "}", "}", "g_ulPrevAngle", "=", "g_ulAngle", ";", "}" ]
Handles the ADC sample sequence zero interrupt.
[ "Handles", "the", "ADC", "sample", "sequence", "zero", "interrupt", "." ]
[ "//\r", "// Clear the ADC interrupt.\r", "//\r", "//\r", "// Read the samples from the ADC FIFO.\r", "//\r", "//\r", "// Read the next sample.\r", "//\r", "//\r", "// Increment the count of samples read.\r", "//\r", "//\r", "// See if five samples were read.\r", "//\r", "//\r", "// Since there were not precisely five samples in the FIFO, it is not\r", "// known what analog signal is represented by each sample. Therefore,\r", "// return without doing any processing on these samples.\r", "//\r", "//\r", "// Filter the new samples.\r", "//\r", "//\r", "// Pass the new data sample through a single pole IIR low pass filter\r", "// with a coefficient of 0.75.\r", "//\r", "//\r", "// Convert the ADC DC bus reading to volts. Each volt at the ADC input\r", "// corresponds to 150 volts of bus voltage.\r", "//\r", "//\r", "// Convert the ADC junction temperature reading to ambient case temperature\r", "// in Celsius.\r", "//\r", "//\r", "// See if the motor drive is running.\r", "//\r", "//\r", "// Since the motor drive is not running, there is no current through\r", "// the motor.\r", "//\r", "//\r", "// There is nothing further to be done since the motor is not running.\r", "//\r", "//\r", "// See if the drive angle just crossed zero in either direction.\r", "//\r", "//\r", "// Loop through the three phases of the motor drive.\r", "//\r", "//\r", "// Convert the maximum reading detected during the last cycle into\r", "// amperes. The phase current is measured as the voltage dropped\r", "// across a 0.04 Ohm resistor, so current is 25 times the voltage.\r", "// This is then passed through an op amp that multiplies the value\r", "// by 11. The resulting phase current is put into a 8.8 fixed\r", "// point representation and must therefore be multiplied by 256.\r", "// This is the peak current, which is then divided by 1.4 to get\r", "// the RMS current. Since the ADC reading is 0 to 1023 for\r", "// voltages between 0 V and 3 V, the final equation is:\r", "//\r", "// A = R * (25 / 11) * (3 / 1024) * (10 / 14) * 256\r", "//\r", "// Reducing the constants results in R * 375 / 308.\r", "//\r", "//\r", "// Reset the maximum phase current seen to zero to prepare for the\r", "// next cycle.\r", "//\r", "//\r", "// See if this is a single phase or three phase motor.\r", "//\r", "//\r", "// Average the RMS current of the two phases to get the RMS motor\r", "// current.\r", "//\r", "//\r", "// Average the RMS current of the three phases to get the RMS motor\r", "// current.\r", "//\r", "//\r", "// Loop through the three phases of the motor drive.\r", "//\r", "//\r", "// See if this ADC reading is larger than any previous ADC reading.\r", "//\r", "//\r", "// Save this ADC reading as the maximum.\r", "//\r", "//\r", "// Save the current motor drive angle for the next set of samples.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c6316af383e4dc322f967445ce327d74ef1628d7
junyanl-code/Luminary-Micro-Library
boards/rdk-acim/qs-acim/adc_ctrl.c
[ "BSD-3-Clause" ]
C
ADCInit
void
void ADCInit(void) { // // Set the speed of the ADC to 1 million samples per second. // SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // // Configure sample sequence zero to capture all three motor phase // currents, the DC bus voltage, and the internal junction temperature. // The sample sequence is triggered by the signal from the PWM module. // ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PWM0, 0); ADCSequenceStepConfigure(ADC0_BASE, 0, 0, PIN_I_PHASEU); ADCSequenceStepConfigure(ADC0_BASE, 0, 1, PIN_I_PHASEV); ADCSequenceStepConfigure(ADC0_BASE, 0, 2, PIN_I_PHASEW); ADCSequenceStepConfigure(ADC0_BASE, 0, 3, PIN_VSENSE); ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_END | ADC_CTL_IE | ADC_CTL_TS); // // Enable sample sequence zero and its interrupt. // ADCSequenceEnable(ADC0_BASE,0); ADCIntEnable(ADC0_BASE, 0); IntEnable(INT_ADC0SS0); }
//***************************************************************************** // //! Initializes the ADC control routines. //! //! This function initializes the ADC module and the control routines, //! preparing them to monitor currents and voltages on the motor drive. //! //! \return None. // //*****************************************************************************
Initializes the ADC control routines. This function initializes the ADC module and the control routines, preparing them to monitor currents and voltages on the motor drive. \return None.
[ "Initializes", "the", "ADC", "control", "routines", ".", "This", "function", "initializes", "the", "ADC", "module", "and", "the", "control", "routines", "preparing", "them", "to", "monitor", "currents", "and", "voltages", "on", "the", "motor", "drive", ".", "\\", "return", "None", "." ]
void ADCInit(void) { SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PWM0, 0); ADCSequenceStepConfigure(ADC0_BASE, 0, 0, PIN_I_PHASEU); ADCSequenceStepConfigure(ADC0_BASE, 0, 1, PIN_I_PHASEV); ADCSequenceStepConfigure(ADC0_BASE, 0, 2, PIN_I_PHASEW); ADCSequenceStepConfigure(ADC0_BASE, 0, 3, PIN_VSENSE); ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_END | ADC_CTL_IE | ADC_CTL_TS); ADCSequenceEnable(ADC0_BASE,0); ADCIntEnable(ADC0_BASE, 0); IntEnable(INT_ADC0SS0); }
[ "void", "ADCInit", "(", "void", ")", "{", "SysCtlADCSpeedSet", "(", "SYSCTL_ADCSPEED_1MSPS", ")", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "0", ",", "ADC_TRIGGER_PWM0", ",", "0", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "0", ",", "0", ",", "PIN_I_PHASEU", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "0", ",", "1", ",", "PIN_I_PHASEV", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "0", ",", "2", ",", "PIN_I_PHASEW", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "0", ",", "3", ",", "PIN_VSENSE", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "0", ",", "4", ",", "ADC_CTL_END", "|", "ADC_CTL_IE", "|", "ADC_CTL_TS", ")", ";", "ADCSequenceEnable", "(", "ADC0_BASE", ",", "0", ")", ";", "ADCIntEnable", "(", "ADC0_BASE", ",", "0", ")", ";", "IntEnable", "(", "INT_ADC0SS0", ")", ";", "}" ]
Initializes the ADC control routines.
[ "Initializes", "the", "ADC", "control", "routines", "." ]
[ "//\r", "// Set the speed of the ADC to 1 million samples per second.\r", "//\r", "//\r", "// Configure sample sequence zero to capture all three motor phase\r", "// currents, the DC bus voltage, and the internal junction temperature.\r", "// The sample sequence is triggered by the signal from the PWM module.\r", "//\r", "//\r", "// Enable sample sequence zero and its interrupt.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c610dfdb91946e33091712296f680b0b55eafbb2
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/hello/hello.c
[ "BSD-3-Clause" ]
C
TCPIPStackInit
null
unsigned long TCPIPStackInit(void) { char pcMACAddrString [SIZE_MAC_ADDR_BUFFER]; unsigned long ulUser0, ulUser1; unsigned char pucMACAddr[6]; // // Configure SysTick for a 100Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Enable Interrupts // ROM_IntMasterEnable(); // // Configure the Ethernet LEDs on PF2 and PF3. // LED0 Bit 3 Output // LED1 Bit 2 Output // GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); // // Get the MAC address from the UART0 and UART1 registers in NV ram. // ROM_FlashUserGet(&ulUser0, &ulUser1); // // Convert the 24/24 split MAC address from NV ram into a MAC address // array. // pucMACAddr[0] = ulUser0 & 0xff; pucMACAddr[1] = (ulUser0 >> 8) & 0xff; pucMACAddr[2] = (ulUser0 >> 16) & 0xff; pucMACAddr[3] = ulUser1 & 0xff; pucMACAddr[4] = (ulUser1 >> 8) & 0xff; pucMACAddr[5] = (ulUser1 >> 16) & 0xff; // // Format this address into a string and display it. // usnprintf(pcMACAddrString, SIZE_MAC_ADDR_BUFFER, "MAC: %02X-%02X-%02X-%02X-%02X-%02X", pucMACAddr[0], pucMACAddr[1], pucMACAddr[2], pucMACAddr[3], pucMACAddr[4], pucMACAddr[5]); GrContextFontSet(&g_sContext, g_pFontCm20); GrStringDrawCentered(&g_sContext, pcMACAddrString, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 20, 0); // // Initialize the lwIP TCP/IP stack. // lwIPInit(pucMACAddr, 0, 0, 0, IPADDR_USE_DHCP); // // Setup the device locator service. // LocatorInit(); LocatorMACAddrSet(pucMACAddr); LocatorAppTitleSet("RDK-IDM-SBC hello"); // // Start monitoring for the special packet that tells us a software // download is being requested. // SoftwareUpdateInit(SoftwareUpdateRequestCallback); // // Return our initial IP address. This is 0 for now since we have not // had one assigned yet. // return(0); }
//***************************************************************************** // // Initialize the Ethernet hardware and lwIP TCP/IP stack and set up to listen // for remote firmware update requests. // //*****************************************************************************
Initialize the Ethernet hardware and lwIP TCP/IP stack and set up to listen for remote firmware update requests.
[ "Initialize", "the", "Ethernet", "hardware", "and", "lwIP", "TCP", "/", "IP", "stack", "and", "set", "up", "to", "listen", "for", "remote", "firmware", "update", "requests", "." ]
unsigned long TCPIPStackInit(void) { char pcMACAddrString [SIZE_MAC_ADDR_BUFFER]; unsigned long ulUser0, ulUser1; unsigned char pucMACAddr[6]; ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); ROM_IntMasterEnable(); GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); ROM_FlashUserGet(&ulUser0, &ulUser1); pucMACAddr[0] = ulUser0 & 0xff; pucMACAddr[1] = (ulUser0 >> 8) & 0xff; pucMACAddr[2] = (ulUser0 >> 16) & 0xff; pucMACAddr[3] = ulUser1 & 0xff; pucMACAddr[4] = (ulUser1 >> 8) & 0xff; pucMACAddr[5] = (ulUser1 >> 16) & 0xff; usnprintf(pcMACAddrString, SIZE_MAC_ADDR_BUFFER, "MAC: %02X-%02X-%02X-%02X-%02X-%02X", pucMACAddr[0], pucMACAddr[1], pucMACAddr[2], pucMACAddr[3], pucMACAddr[4], pucMACAddr[5]); GrContextFontSet(&g_sContext, g_pFontCm20); GrStringDrawCentered(&g_sContext, pcMACAddrString, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 20, 0); lwIPInit(pucMACAddr, 0, 0, 0, IPADDR_USE_DHCP); LocatorInit(); LocatorMACAddrSet(pucMACAddr); LocatorAppTitleSet("RDK-IDM-SBC hello"); SoftwareUpdateInit(SoftwareUpdateRequestCallback); return(0); }
[ "unsigned", "long", "TCPIPStackInit", "(", "void", ")", "{", "char", "pcMACAddrString", "[", "SIZE_MAC_ADDR_BUFFER", "]", ";", "unsigned", "long", "ulUser0", ",", "ulUser1", ";", "unsigned", "char", "pucMACAddr", "[", "6", "]", ";", "ROM_SysTickPeriodSet", "(", "ROM_SysCtlClockGet", "(", ")", "/", "TICKS_PER_SECOND", ")", ";", "ROM_SysTickEnable", "(", ")", ";", "ROM_SysTickIntEnable", "(", ")", ";", "ROM_IntMasterEnable", "(", ")", ";", "GPIOPinTypeEthernetLED", "(", "GPIO_PORTF_BASE", ",", "GPIO_PIN_2", "|", "GPIO_PIN_3", ")", ";", "ROM_FlashUserGet", "(", "&", "ulUser0", ",", "&", "ulUser1", ")", ";", "pucMACAddr", "[", "0", "]", "=", "ulUser0", "&", "0xff", ";", "pucMACAddr", "[", "1", "]", "=", "(", "ulUser0", ">>", "8", ")", "&", "0xff", ";", "pucMACAddr", "[", "2", "]", "=", "(", "ulUser0", ">>", "16", ")", "&", "0xff", ";", "pucMACAddr", "[", "3", "]", "=", "ulUser1", "&", "0xff", ";", "pucMACAddr", "[", "4", "]", "=", "(", "ulUser1", ">>", "8", ")", "&", "0xff", ";", "pucMACAddr", "[", "5", "]", "=", "(", "ulUser1", ">>", "16", ")", "&", "0xff", ";", "usnprintf", "(", "pcMACAddrString", ",", "SIZE_MAC_ADDR_BUFFER", ",", "\"", "\"", ",", "pucMACAddr", "[", "0", "]", ",", "pucMACAddr", "[", "1", "]", ",", "pucMACAddr", "[", "2", "]", ",", "pucMACAddr", "[", "3", "]", ",", "pucMACAddr", "[", "4", "]", ",", "pucMACAddr", "[", "5", "]", ")", ";", "GrContextFontSet", "(", "&", "g_sContext", ",", "g_pFontCm20", ")", ";", "GrStringDrawCentered", "(", "&", "g_sContext", ",", "pcMACAddrString", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "/", "2", ",", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "20", ",", "0", ")", ";", "lwIPInit", "(", "pucMACAddr", ",", "0", ",", "0", ",", "0", ",", "IPADDR_USE_DHCP", ")", ";", "LocatorInit", "(", ")", ";", "LocatorMACAddrSet", "(", "pucMACAddr", ")", ";", "LocatorAppTitleSet", "(", "\"", "\"", ")", ";", "SoftwareUpdateInit", "(", "SoftwareUpdateRequestCallback", ")", ";", "return", "(", "0", ")", ";", "}" ]
Initialize the Ethernet hardware and lwIP TCP/IP stack and set up to listen for remote firmware update requests.
[ "Initialize", "the", "Ethernet", "hardware", "and", "lwIP", "TCP", "/", "IP", "stack", "and", "set", "up", "to", "listen", "for", "remote", "firmware", "update", "requests", "." ]
[ "//\r", "// Configure SysTick for a 100Hz interrupt.\r", "//\r", "//\r", "// Enable Interrupts\r", "//\r", "//\r", "// Configure the Ethernet LEDs on PF2 and PF3.\r", "// LED0 Bit 3 Output\r", "// LED1 Bit 2 Output\r", "//\r", "//\r", "// Get the MAC address from the UART0 and UART1 registers in NV ram.\r", "//\r", "//\r", "// Convert the 24/24 split MAC address from NV ram into a MAC address\r", "// array.\r", "//\r", "//\r", "// Format this address into a string and display it.\r", "//\r", "//\r", "// Initialize the lwIP TCP/IP stack.\r", "//\r", "//\r", "// Setup the device locator service.\r", "//\r", "//\r", "// Start monitoring for the special packet that tells us a software\r", "// download is being requested.\r", "//\r", "//\r", "// Return our initial IP address. This is 0 for now since we have not\r", "// had one assigned yet.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c610dfdb91946e33091712296f680b0b55eafbb2
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/hello/hello.c
[ "BSD-3-Clause" ]
C
IPAddressChangeCheck
null
unsigned long IPAddressChangeCheck(unsigned long ulCurrentIP) { unsigned long ulIPAddr; char pcIPAddrString[24]; // // What is our current IP address? // ulIPAddr = lwIPLocalIPAddrGet(); // // Has the IP address changed? // if(ulIPAddr != ulCurrentIP) { // // Yes - the address changed so update the display. // usprintf(pcIPAddrString, "IP: %d.%d.%d.%d", ulIPAddr & 0xff, (ulIPAddr >> 8) & 0xff, (ulIPAddr >> 16) & 0xff, ulIPAddr >> 24); GrContextFontSet(&g_sContext, g_pFontCm20); GrStringDrawCentered(&g_sContext, pcIPAddrString, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 40, 0); } // // Return our current IP address. // return(ulIPAddr); }
//***************************************************************************** // // Check to see if the IP address has changed and, if so, update the // display. // //*****************************************************************************
Check to see if the IP address has changed and, if so, update the display.
[ "Check", "to", "see", "if", "the", "IP", "address", "has", "changed", "and", "if", "so", "update", "the", "display", "." ]
unsigned long IPAddressChangeCheck(unsigned long ulCurrentIP) { unsigned long ulIPAddr; char pcIPAddrString[24]; ulIPAddr = lwIPLocalIPAddrGet(); if(ulIPAddr != ulCurrentIP) { usprintf(pcIPAddrString, "IP: %d.%d.%d.%d", ulIPAddr & 0xff, (ulIPAddr >> 8) & 0xff, (ulIPAddr >> 16) & 0xff, ulIPAddr >> 24); GrContextFontSet(&g_sContext, g_pFontCm20); GrStringDrawCentered(&g_sContext, pcIPAddrString, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 40, 0); } return(ulIPAddr); }
[ "unsigned", "long", "IPAddressChangeCheck", "(", "unsigned", "long", "ulCurrentIP", ")", "{", "unsigned", "long", "ulIPAddr", ";", "char", "pcIPAddrString", "[", "24", "]", ";", "ulIPAddr", "=", "lwIPLocalIPAddrGet", "(", ")", ";", "if", "(", "ulIPAddr", "!=", "ulCurrentIP", ")", "{", "usprintf", "(", "pcIPAddrString", ",", "\"", "\"", ",", "ulIPAddr", "&", "0xff", ",", "(", "ulIPAddr", ">>", "8", ")", "&", "0xff", ",", "(", "ulIPAddr", ">>", "16", ")", "&", "0xff", ",", "ulIPAddr", ">>", "24", ")", ";", "GrContextFontSet", "(", "&", "g_sContext", ",", "g_pFontCm20", ")", ";", "GrStringDrawCentered", "(", "&", "g_sContext", ",", "pcIPAddrString", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "/", "2", ",", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "40", ",", "0", ")", ";", "}", "return", "(", "ulIPAddr", ")", ";", "}" ]
Check to see if the IP address has changed and, if so, update the display.
[ "Check", "to", "see", "if", "the", "IP", "address", "has", "changed", "and", "if", "so", "update", "the", "display", "." ]
[ "//\r", "// What is our current IP address?\r", "//\r", "//\r", "// Has the IP address changed?\r", "//\r", "//\r", "// Yes - the address changed so update the display.\r", "//\r", "//\r", "// Return our current IP address.\r", "//\r" ]
[ { "param": "ulCurrentIP", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulCurrentIP", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7ef2be3f65ae56e8f74a6706d3152a81774655d
junyanl-code/Luminary-Micro-Library
boards/rdk-idm/hello_widget/hello_widget.c
[ "BSD-3-Clause" ]
C
OnButtonPress
void
void OnButtonPress(tWidget *pWidget) { g_bHelloVisible = !g_bHelloVisible; if(g_bHelloVisible) { // // Add the Hello widget to the tree as a child of the push // button. We could add it elsewhere but this seems as good a // place as any. // WidgetAdd((tWidget *)&g_sPushBtn, (tWidget *)&g_sHello); WidgetPaint((tWidget *)&g_sHello); } else { // // Remove the Hello widget from the tree. // WidgetRemove((tWidget *)&g_sHello); // // Repaint the widget tree to remove the Hello widget from the // display. This is rather inefficient but saves having to use // additional widgets to overpaint the area of the Hello text (since // disabling a widget does not automatically erase whatever it // previously displayed on the screen). // WidgetPaint(WIDGET_ROOT); } }
//***************************************************************************** // // This function is called by the graphics library widget manager in the // context of WidgetMessageQueueProcess whenever the user releases the // "Press Me!" button. We use this notification to display or hide the // "Hello!" widget. // // This is actually a rather inefficient way to accomplish this but it's // a good example of how to add and remove widgets dynamically. In // normal circumstances, you would likely leave the g_sHello widget // linked into the tree and merely add or remove the text by changing // its style then repainting. // // If using this dynamic add/remove strategy, another useful optimization // is to use a black canvas widget that covers the same area of the screen // as the widgets that you will be adding and removing. If this is the used // as the point in the tree where the subtree is added to and removed // from, you can repaint just the desired area by repainting the black // canvas rather than repainting the whole tree. // //*****************************************************************************
This function is called by the graphics library widget manager in the context of WidgetMessageQueueProcess whenever the user releases the "Press Me!" button. We use this notification to display or hide the "Hello!" widget. This is actually a rather inefficient way to accomplish this but it's a good example of how to add and remove widgets dynamically. In normal circumstances, you would likely leave the g_sHello widget linked into the tree and merely add or remove the text by changing its style then repainting. If using this dynamic add/remove strategy, another useful optimization is to use a black canvas widget that covers the same area of the screen as the widgets that you will be adding and removing. If this is the used as the point in the tree where the subtree is added to and removed from, you can repaint just the desired area by repainting the black canvas rather than repainting the whole tree.
[ "This", "function", "is", "called", "by", "the", "graphics", "library", "widget", "manager", "in", "the", "context", "of", "WidgetMessageQueueProcess", "whenever", "the", "user", "releases", "the", "\"", "Press", "Me!", "\"", "button", ".", "We", "use", "this", "notification", "to", "display", "or", "hide", "the", "\"", "Hello!", "\"", "widget", ".", "This", "is", "actually", "a", "rather", "inefficient", "way", "to", "accomplish", "this", "but", "it", "'", "s", "a", "good", "example", "of", "how", "to", "add", "and", "remove", "widgets", "dynamically", ".", "In", "normal", "circumstances", "you", "would", "likely", "leave", "the", "g_sHello", "widget", "linked", "into", "the", "tree", "and", "merely", "add", "or", "remove", "the", "text", "by", "changing", "its", "style", "then", "repainting", ".", "If", "using", "this", "dynamic", "add", "/", "remove", "strategy", "another", "useful", "optimization", "is", "to", "use", "a", "black", "canvas", "widget", "that", "covers", "the", "same", "area", "of", "the", "screen", "as", "the", "widgets", "that", "you", "will", "be", "adding", "and", "removing", ".", "If", "this", "is", "the", "used", "as", "the", "point", "in", "the", "tree", "where", "the", "subtree", "is", "added", "to", "and", "removed", "from", "you", "can", "repaint", "just", "the", "desired", "area", "by", "repainting", "the", "black", "canvas", "rather", "than", "repainting", "the", "whole", "tree", "." ]
void OnButtonPress(tWidget *pWidget) { g_bHelloVisible = !g_bHelloVisible; if(g_bHelloVisible) { WidgetAdd((tWidget *)&g_sPushBtn, (tWidget *)&g_sHello); WidgetPaint((tWidget *)&g_sHello); } else { WidgetRemove((tWidget *)&g_sHello); WidgetPaint(WIDGET_ROOT); } }
[ "void", "OnButtonPress", "(", "tWidget", "*", "pWidget", ")", "{", "g_bHelloVisible", "=", "!", "g_bHelloVisible", ";", "if", "(", "g_bHelloVisible", ")", "{", "WidgetAdd", "(", "(", "tWidget", "*", ")", "&", "g_sPushBtn", ",", "(", "tWidget", "*", ")", "&", "g_sHello", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sHello", ")", ";", "}", "else", "{", "WidgetRemove", "(", "(", "tWidget", "*", ")", "&", "g_sHello", ")", ";", "WidgetPaint", "(", "WIDGET_ROOT", ")", ";", "}", "}" ]
This function is called by the graphics library widget manager in the context of WidgetMessageQueueProcess whenever the user releases the "Press Me!"
[ "This", "function", "is", "called", "by", "the", "graphics", "library", "widget", "manager", "in", "the", "context", "of", "WidgetMessageQueueProcess", "whenever", "the", "user", "releases", "the", "\"", "Press", "Me!", "\"" ]
[ "//\r", "// Add the Hello widget to the tree as a child of the push\r", "// button. We could add it elsewhere but this seems as good a\r", "// place as any.\r", "//\r", "//\r", "// Remove the Hello widget from the tree.\r", "//\r", "//\r", "// Repaint the widget tree to remove the Hello widget from the\r", "// display. This is rather inefficient but saves having to use\r", "// additional widgets to overpaint the area of the Hello text (since\r", "// disabling a widget does not automatically erase whatever it\r", "// previously displayed on the screen).\r", "//\r" ]
[ { "param": "pWidget", "type": "tWidget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pWidget", "type": "tWidget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a6c7734ad393015ce44a2ef965fd427da3bc9ffb
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s3748/bitband/bitband.c
[ "BSD-3-Clause" ]
C
PrintValue
void
void PrintValue(unsigned long ulValue) { char pcBuffer[9]; pcBuffer[0] = pcHex[(ulValue >> 28) & 15]; pcBuffer[1] = pcHex[(ulValue >> 24) & 15]; pcBuffer[2] = pcHex[(ulValue >> 20) & 15]; pcBuffer[3] = pcHex[(ulValue >> 16) & 15]; pcBuffer[4] = pcHex[(ulValue >> 12) & 15]; pcBuffer[5] = pcHex[(ulValue >> 8) & 15]; pcBuffer[6] = pcHex[(ulValue >> 4) & 15]; pcBuffer[7] = pcHex[(ulValue >> 0) & 15]; pcBuffer[8] = '\0'; GrStringDrawCentered(&g_sContext, pcBuffer, -1, GrContextDpyWidthGet(&g_sContext) / 2, 30, 1); }
//***************************************************************************** // // Print the given value as a hexadecimal string on the CSTN. // //*****************************************************************************
Print the given value as a hexadecimal string on the CSTN.
[ "Print", "the", "given", "value", "as", "a", "hexadecimal", "string", "on", "the", "CSTN", "." ]
void PrintValue(unsigned long ulValue) { char pcBuffer[9]; pcBuffer[0] = pcHex[(ulValue >> 28) & 15]; pcBuffer[1] = pcHex[(ulValue >> 24) & 15]; pcBuffer[2] = pcHex[(ulValue >> 20) & 15]; pcBuffer[3] = pcHex[(ulValue >> 16) & 15]; pcBuffer[4] = pcHex[(ulValue >> 12) & 15]; pcBuffer[5] = pcHex[(ulValue >> 8) & 15]; pcBuffer[6] = pcHex[(ulValue >> 4) & 15]; pcBuffer[7] = pcHex[(ulValue >> 0) & 15]; pcBuffer[8] = '\0'; GrStringDrawCentered(&g_sContext, pcBuffer, -1, GrContextDpyWidthGet(&g_sContext) / 2, 30, 1); }
[ "void", "PrintValue", "(", "unsigned", "long", "ulValue", ")", "{", "char", "pcBuffer", "[", "9", "]", ";", "pcBuffer", "[", "0", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "28", ")", "&", "15", "]", ";", "pcBuffer", "[", "1", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "24", ")", "&", "15", "]", ";", "pcBuffer", "[", "2", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "20", ")", "&", "15", "]", ";", "pcBuffer", "[", "3", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "16", ")", "&", "15", "]", ";", "pcBuffer", "[", "4", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "12", ")", "&", "15", "]", ";", "pcBuffer", "[", "5", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "8", ")", "&", "15", "]", ";", "pcBuffer", "[", "6", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "4", ")", "&", "15", "]", ";", "pcBuffer", "[", "7", "]", "=", "pcHex", "[", "(", "ulValue", ">>", "0", ")", "&", "15", "]", ";", "pcBuffer", "[", "8", "]", "=", "'", "\\0", "'", ";", "GrStringDrawCentered", "(", "&", "g_sContext", ",", "pcBuffer", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "/", "2", ",", "30", ",", "1", ")", ";", "}" ]
Print the given value as a hexadecimal string on the CSTN.
[ "Print", "the", "given", "value", "as", "a", "hexadecimal", "string", "on", "the", "CSTN", "." ]
[]
[ { "param": "ulValue", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulValue", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
ReadFlash
void
static void ReadFlash(int iLength, unsigned char *pucDest) { #if (SAVED_LINK_KEY_ADDRESS != 0) BTPS_MemCopy(pucDest, (void *)SAVED_LINK_KEY_ADDRESS, iLength); #endif }
//***************************************************************************** // // The following function is used to read a chunk of data from the flash // memory. The function will transfer the data from the location allocated // for link key storage for as many bytes as defined by the iLength parameter. // The second parameter specifies a caller-supplied buffer where the data that // is read from flash will be stored. // //*****************************************************************************
The following function is used to read a chunk of data from the flash memory. The function will transfer the data from the location allocated for link key storage for as many bytes as defined by the iLength parameter. The second parameter specifies a caller-supplied buffer where the data that is read from flash will be stored.
[ "The", "following", "function", "is", "used", "to", "read", "a", "chunk", "of", "data", "from", "the", "flash", "memory", ".", "The", "function", "will", "transfer", "the", "data", "from", "the", "location", "allocated", "for", "link", "key", "storage", "for", "as", "many", "bytes", "as", "defined", "by", "the", "iLength", "parameter", ".", "The", "second", "parameter", "specifies", "a", "caller", "-", "supplied", "buffer", "where", "the", "data", "that", "is", "read", "from", "flash", "will", "be", "stored", "." ]
static void ReadFlash(int iLength, unsigned char *pucDest) { #if (SAVED_LINK_KEY_ADDRESS != 0) BTPS_MemCopy(pucDest, (void *)SAVED_LINK_KEY_ADDRESS, iLength); #endif }
[ "static", "void", "ReadFlash", "(", "int", "iLength", ",", "unsigned", "char", "*", "pucDest", ")", "{", "#if", "(", "SAVED_LINK_KEY_ADDRESS", "!=", "0", ")", "\n", "BTPS_MemCopy", "(", "pucDest", ",", "(", "void", "*", ")", "SAVED_LINK_KEY_ADDRESS", ",", "iLength", ")", ";", "#endif", "}" ]
The following function is used to read a chunk of data from the flash memory.
[ "The", "following", "function", "is", "used", "to", "read", "a", "chunk", "of", "data", "from", "the", "flash", "memory", "." ]
[]
[ { "param": "iLength", "type": "int" }, { "param": "pucDest", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iLength", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucDest", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
WriteFlash
void
static void WriteFlash(int iLength, unsigned char *pucSrc) { #if (SAVED_LINK_KEY_ADDRESS != 0) unsigned long ulErasePages; // // Compute the number of pages that need to be erased. // ulErasePages = (iLength + (FLASH_ERASE_SIZE - 1)) / FLASH_ERASE_SIZE; // // Erase the pages needed to store the new data. // while(ulErasePages--) { FlashErase(SAVED_LINK_KEY_ADDRESS + (ulErasePages * FLASH_ERASE_SIZE)); } // // Make sure iLength is multiple of 4 // iLength = (iLength + 3) & ~0x3;; // // Program the data into the flash // FlashProgram((unsigned long *)pucSrc, SAVED_LINK_KEY_ADDRESS, iLength); #endif }
//***************************************************************************** // // The following function is used to write a chunk of data to the flash memory. // The function will write the data to the location in flash allocated for // link key storage. The first parameter defines the number of bytes to be // written to flash, and the second parameter points to a buffer that holds // the data that is to be written. // //*****************************************************************************
The following function is used to write a chunk of data to the flash memory. The function will write the data to the location in flash allocated for link key storage. The first parameter defines the number of bytes to be written to flash, and the second parameter points to a buffer that holds the data that is to be written.
[ "The", "following", "function", "is", "used", "to", "write", "a", "chunk", "of", "data", "to", "the", "flash", "memory", ".", "The", "function", "will", "write", "the", "data", "to", "the", "location", "in", "flash", "allocated", "for", "link", "key", "storage", ".", "The", "first", "parameter", "defines", "the", "number", "of", "bytes", "to", "be", "written", "to", "flash", "and", "the", "second", "parameter", "points", "to", "a", "buffer", "that", "holds", "the", "data", "that", "is", "to", "be", "written", "." ]
static void WriteFlash(int iLength, unsigned char *pucSrc) { #if (SAVED_LINK_KEY_ADDRESS != 0) unsigned long ulErasePages; ulErasePages = (iLength + (FLASH_ERASE_SIZE - 1)) / FLASH_ERASE_SIZE; while(ulErasePages--) { FlashErase(SAVED_LINK_KEY_ADDRESS + (ulErasePages * FLASH_ERASE_SIZE)); } iLength = (iLength + 3) & ~0x3;; FlashProgram((unsigned long *)pucSrc, SAVED_LINK_KEY_ADDRESS, iLength); #endif }
[ "static", "void", "WriteFlash", "(", "int", "iLength", ",", "unsigned", "char", "*", "pucSrc", ")", "{", "#if", "(", "SAVED_LINK_KEY_ADDRESS", "!=", "0", ")", "\n", "unsigned", "long", "ulErasePages", ";", "ulErasePages", "=", "(", "iLength", "+", "(", "FLASH_ERASE_SIZE", "-", "1", ")", ")", "/", "FLASH_ERASE_SIZE", ";", "while", "(", "ulErasePages", "--", ")", "{", "FlashErase", "(", "SAVED_LINK_KEY_ADDRESS", "+", "(", "ulErasePages", "*", "FLASH_ERASE_SIZE", ")", ")", ";", "}", "iLength", "=", "(", "iLength", "+", "3", ")", "&", "~", "0x3", ";", ";", "FlashProgram", "(", "(", "unsigned", "long", "*", ")", "pucSrc", ",", "SAVED_LINK_KEY_ADDRESS", ",", "iLength", ")", ";", "#endif", "}" ]
The following function is used to write a chunk of data to the flash memory.
[ "The", "following", "function", "is", "used", "to", "write", "a", "chunk", "of", "data", "to", "the", "flash", "memory", "." ]
[ "//\r", "// Compute the number of pages that need to be erased.\r", "//\r", "//\r", "// Erase the pages needed to store the new data.\r", "//\r", "//\r", "// Make sure iLength is multiple of 4\r", "//\r", "//\r", "// Program the data into the flash\r", "//\r" ]
[ { "param": "iLength", "type": "int" }, { "param": "pucSrc", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iLength", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucSrc", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
LocateLinkKey
int
static int LocateLinkKey(BD_ADDR_t sBD_ADDR) { int iIdx; // // Loop through the list for a match for the BD_ADDR. // for(iIdx = 0; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { if((!g_sLinkKeyInfo[iIdx].bEmpty) && (COMPARE_BD_ADDR(g_sLinkKeyInfo[iIdx].sBD_ADDR, sBD_ADDR))) { return(iIdx); } } // // If we fell out of loop above, then no match was found // return(-1); }
//***************************************************************************** // // The following function is used to locate a link key for the supplied // Bluetooth address. If located, the function will return the index of the // link key in the tLinkKeyInfo structure. If a link key was not located the // function returns a negative number. // //*****************************************************************************
The following function is used to locate a link key for the supplied Bluetooth address. If located, the function will return the index of the link key in the tLinkKeyInfo structure. If a link key was not located the function returns a negative number.
[ "The", "following", "function", "is", "used", "to", "locate", "a", "link", "key", "for", "the", "supplied", "Bluetooth", "address", ".", "If", "located", "the", "function", "will", "return", "the", "index", "of", "the", "link", "key", "in", "the", "tLinkKeyInfo", "structure", ".", "If", "a", "link", "key", "was", "not", "located", "the", "function", "returns", "a", "negative", "number", "." ]
static int LocateLinkKey(BD_ADDR_t sBD_ADDR) { int iIdx; for(iIdx = 0; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { if((!g_sLinkKeyInfo[iIdx].bEmpty) && (COMPARE_BD_ADDR(g_sLinkKeyInfo[iIdx].sBD_ADDR, sBD_ADDR))) { return(iIdx); } } return(-1); }
[ "static", "int", "LocateLinkKey", "(", "BD_ADDR_t", "sBD_ADDR", ")", "{", "int", "iIdx", ";", "for", "(", "iIdx", "=", "0", ";", "iIdx", "<", "NUM_SUPPORTED_LINK_KEYS", ";", "iIdx", "++", ")", "{", "if", "(", "(", "!", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "bEmpty", ")", "&&", "(", "COMPARE_BD_ADDR", "(", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "sBD_ADDR", ",", "sBD_ADDR", ")", ")", ")", "{", "return", "(", "iIdx", ")", ";", "}", "}", "return", "(", "-1", ")", ";", "}" ]
The following function is used to locate a link key for the supplied Bluetooth address.
[ "The", "following", "function", "is", "used", "to", "locate", "a", "link", "key", "for", "the", "supplied", "Bluetooth", "address", "." ]
[ "//\r", "// Loop through the list for a match for the BD_ADDR.\r", "//\r", "//\r", "// If we fell out of loop above, then no match was found\r", "//\r" ]
[ { "param": "sBD_ADDR", "type": "BD_ADDR_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sBD_ADDR", "type": "BD_ADDR_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
DeleteLinkKey
int
static int DeleteLinkKey(BD_ADDR_t sBD_ADDR) { int iIdx; // // Find the specified key in the link key storage // iIdx = LocateLinkKey(sBD_ADDR); // // If a valid index is returned, then remove it from the storage by // overwriting it while repacking the remaining keys in the structure. // if(iIdx >= 0) { // // Loop through remaining keys and slide all the remaining keys down // by one slot in the structure. // for(; iIdx < (NUM_SUPPORTED_LINK_KEYS - 1); iIdx++) { g_sLinkKeyInfo[iIdx] = g_sLinkKeyInfo[iIdx + 1]; } // // Flag the last entry as free. // BTPS_MemInitialize(&g_sLinkKeyInfo[NUM_SUPPORTED_LINK_KEYS - 1], 0xFF, sizeof(Link_Key_t)); // // Rewrite the new key info structure to flash. // WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); // // Return a success indication // return(1); } // // Else the key was not found so return an error. // else { return(-1); } }
//***************************************************************************** // // The following function is used to locate a link key for the supplied // Bluetooth address. If located, the function will remove the entry from the // LinkKeyInfo structure and repack the structure. If a link key was not // located the function returns a negative number. // //*****************************************************************************
The following function is used to locate a link key for the supplied Bluetooth address. If located, the function will remove the entry from the LinkKeyInfo structure and repack the structure. If a link key was not located the function returns a negative number.
[ "The", "following", "function", "is", "used", "to", "locate", "a", "link", "key", "for", "the", "supplied", "Bluetooth", "address", ".", "If", "located", "the", "function", "will", "remove", "the", "entry", "from", "the", "LinkKeyInfo", "structure", "and", "repack", "the", "structure", ".", "If", "a", "link", "key", "was", "not", "located", "the", "function", "returns", "a", "negative", "number", "." ]
static int DeleteLinkKey(BD_ADDR_t sBD_ADDR) { int iIdx; iIdx = LocateLinkKey(sBD_ADDR); if(iIdx >= 0) { for(; iIdx < (NUM_SUPPORTED_LINK_KEYS - 1); iIdx++) { g_sLinkKeyInfo[iIdx] = g_sLinkKeyInfo[iIdx + 1]; } BTPS_MemInitialize(&g_sLinkKeyInfo[NUM_SUPPORTED_LINK_KEYS - 1], 0xFF, sizeof(Link_Key_t)); WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); return(1); } else { return(-1); } }
[ "static", "int", "DeleteLinkKey", "(", "BD_ADDR_t", "sBD_ADDR", ")", "{", "int", "iIdx", ";", "iIdx", "=", "LocateLinkKey", "(", "sBD_ADDR", ")", ";", "if", "(", "iIdx", ">=", "0", ")", "{", "for", "(", ";", "iIdx", "<", "(", "NUM_SUPPORTED_LINK_KEYS", "-", "1", ")", ";", "iIdx", "++", ")", "{", "g_sLinkKeyInfo", "[", "iIdx", "]", "=", "g_sLinkKeyInfo", "[", "iIdx", "+", "1", "]", ";", "}", "BTPS_MemInitialize", "(", "&", "g_sLinkKeyInfo", "[", "NUM_SUPPORTED_LINK_KEYS", "-", "1", "]", ",", "0xFF", ",", "sizeof", "(", "Link_Key_t", ")", ")", ";", "WriteFlash", "(", "sizeof", "(", "g_sLinkKeyInfo", ")", ",", "(", "unsigned", "char", "*", ")", "&", "g_sLinkKeyInfo", ")", ";", "return", "(", "1", ")", ";", "}", "else", "{", "return", "(", "-1", ")", ";", "}", "}" ]
The following function is used to locate a link key for the supplied Bluetooth address.
[ "The", "following", "function", "is", "used", "to", "locate", "a", "link", "key", "for", "the", "supplied", "Bluetooth", "address", "." ]
[ "//\r", "// Find the specified key in the link key storage\r", "//\r", "//\r", "// If a valid index is returned, then remove it from the storage by\r", "// overwriting it while repacking the remaining keys in the structure.\r", "//\r", "//\r", "// Loop through remaining keys and slide all the remaining keys down\r", "// by one slot in the structure.\r", "//\r", "//\r", "// Flag the last entry as free.\r", "//\r", "//\r", "// Rewrite the new key info structure to flash.\r", "//\r", "//\r", "// Return a success indication\r", "//\r", "//\r", "// Else the key was not found so return an error.\r", "//\r" ]
[ { "param": "sBD_ADDR", "type": "BD_ADDR_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sBD_ADDR", "type": "BD_ADDR_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
SaveLinkKeyInfo
int
static int SaveLinkKeyInfo(BD_ADDR_t sBD_ADDR, Link_Key_t sLinkKey) { int iIdx; // // Check to see if this remote device address is already present in the // key info structure // iIdx = LocateLinkKey(sBD_ADDR); // // The device address is already in storage // if(iIdx >= 0) { // // Check the stored key for this device address. If it is not the // same then update the entry with the new link key and rewrite // the structure to flash. // if(!COMPARE_LINK_KEY(g_sLinkKeyInfo[iIdx].sLinkKey, sLinkKey)) { g_sLinkKeyInfo[iIdx].sLinkKey = sLinkKey; WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); } } // // The device address is not already in storage // else { // // Loop through the list looking for an empty slot. // for(iIdx = 0; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { if(g_sLinkKeyInfo[iIdx].bEmpty) { // // Empty slot was found so stop looking // break; } } // // Check to see if we found an empty slot. If not, then we will // replace the oldest entry. // if(iIdx == NUM_SUPPORTED_LINK_KEYS) { // // Move all of the link key information down 1 slot. The will // delete the key in the first slot, which is the oldest. // for(iIdx = 1; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { g_sLinkKeyInfo[iIdx - 1] = g_sLinkKeyInfo[iIdx]; } // // Set the index of the free slot to be the last entry, which is // now available. // iIdx = NUM_SUPPORTED_LINK_KEYS - 1; } // // Save the link key information in the available slot (found above) // g_sLinkKeyInfo[iIdx].bEmpty = 0; g_sLinkKeyInfo[iIdx].sBD_ADDR = sBD_ADDR; g_sLinkKeyInfo[iIdx].sLinkKey = sLinkKey; // // Save the updated link key structure to flash // WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); } // // Return index of the saved key // return(iIdx); }
//***************************************************************************** // // The following function is used to save a new link key in the link key // storage structure. If the remote device address is already present in // storage, then its link key will be updated and no new slots are used. // If an empty slot is available then that will be used for the new device // address and link key. Otherwise, if there are no empty slots, then the // oldest address/key pair will be deleted and the new one added in its // place. The function returns the index of the saved key. // //*****************************************************************************
The following function is used to save a new link key in the link key storage structure. If the remote device address is already present in storage, then its link key will be updated and no new slots are used. If an empty slot is available then that will be used for the new device address and link key. Otherwise, if there are no empty slots, then the oldest address/key pair will be deleted and the new one added in its place. The function returns the index of the saved key.
[ "The", "following", "function", "is", "used", "to", "save", "a", "new", "link", "key", "in", "the", "link", "key", "storage", "structure", ".", "If", "the", "remote", "device", "address", "is", "already", "present", "in", "storage", "then", "its", "link", "key", "will", "be", "updated", "and", "no", "new", "slots", "are", "used", ".", "If", "an", "empty", "slot", "is", "available", "then", "that", "will", "be", "used", "for", "the", "new", "device", "address", "and", "link", "key", ".", "Otherwise", "if", "there", "are", "no", "empty", "slots", "then", "the", "oldest", "address", "/", "key", "pair", "will", "be", "deleted", "and", "the", "new", "one", "added", "in", "its", "place", ".", "The", "function", "returns", "the", "index", "of", "the", "saved", "key", "." ]
static int SaveLinkKeyInfo(BD_ADDR_t sBD_ADDR, Link_Key_t sLinkKey) { int iIdx; iIdx = LocateLinkKey(sBD_ADDR); if(iIdx >= 0) { if(!COMPARE_LINK_KEY(g_sLinkKeyInfo[iIdx].sLinkKey, sLinkKey)) { g_sLinkKeyInfo[iIdx].sLinkKey = sLinkKey; WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); } } else { for(iIdx = 0; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { if(g_sLinkKeyInfo[iIdx].bEmpty) { break; } } if(iIdx == NUM_SUPPORTED_LINK_KEYS) { for(iIdx = 1; iIdx < NUM_SUPPORTED_LINK_KEYS; iIdx++) { g_sLinkKeyInfo[iIdx - 1] = g_sLinkKeyInfo[iIdx]; } iIdx = NUM_SUPPORTED_LINK_KEYS - 1; } g_sLinkKeyInfo[iIdx].bEmpty = 0; g_sLinkKeyInfo[iIdx].sBD_ADDR = sBD_ADDR; g_sLinkKeyInfo[iIdx].sLinkKey = sLinkKey; WriteFlash(sizeof(g_sLinkKeyInfo), (unsigned char *)&g_sLinkKeyInfo); } return(iIdx); }
[ "static", "int", "SaveLinkKeyInfo", "(", "BD_ADDR_t", "sBD_ADDR", ",", "Link_Key_t", "sLinkKey", ")", "{", "int", "iIdx", ";", "iIdx", "=", "LocateLinkKey", "(", "sBD_ADDR", ")", ";", "if", "(", "iIdx", ">=", "0", ")", "{", "if", "(", "!", "COMPARE_LINK_KEY", "(", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "sLinkKey", ",", "sLinkKey", ")", ")", "{", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "sLinkKey", "=", "sLinkKey", ";", "WriteFlash", "(", "sizeof", "(", "g_sLinkKeyInfo", ")", ",", "(", "unsigned", "char", "*", ")", "&", "g_sLinkKeyInfo", ")", ";", "}", "}", "else", "{", "for", "(", "iIdx", "=", "0", ";", "iIdx", "<", "NUM_SUPPORTED_LINK_KEYS", ";", "iIdx", "++", ")", "{", "if", "(", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "bEmpty", ")", "{", "break", ";", "}", "}", "if", "(", "iIdx", "==", "NUM_SUPPORTED_LINK_KEYS", ")", "{", "for", "(", "iIdx", "=", "1", ";", "iIdx", "<", "NUM_SUPPORTED_LINK_KEYS", ";", "iIdx", "++", ")", "{", "g_sLinkKeyInfo", "[", "iIdx", "-", "1", "]", "=", "g_sLinkKeyInfo", "[", "iIdx", "]", ";", "}", "iIdx", "=", "NUM_SUPPORTED_LINK_KEYS", "-", "1", ";", "}", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "bEmpty", "=", "0", ";", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "sBD_ADDR", "=", "sBD_ADDR", ";", "g_sLinkKeyInfo", "[", "iIdx", "]", ".", "sLinkKey", "=", "sLinkKey", ";", "WriteFlash", "(", "sizeof", "(", "g_sLinkKeyInfo", ")", ",", "(", "unsigned", "char", "*", ")", "&", "g_sLinkKeyInfo", ")", ";", "}", "return", "(", "iIdx", ")", ";", "}" ]
The following function is used to save a new link key in the link key storage structure.
[ "The", "following", "function", "is", "used", "to", "save", "a", "new", "link", "key", "in", "the", "link", "key", "storage", "structure", "." ]
[ "//\r", "// Check to see if this remote device address is already present in the\r", "// key info structure\r", "//\r", "//\r", "// The device address is already in storage\r", "//\r", "//\r", "// Check the stored key for this device address. If it is not the\r", "// same then update the entry with the new link key and rewrite\r", "// the structure to flash.\r", "//\r", "//\r", "// The device address is not already in storage\r", "//\r", "//\r", "// Loop through the list looking for an empty slot.\r", "//\r", "//\r", "// Empty slot was found so stop looking\r", "//\r", "//\r", "// Check to see if we found an empty slot. If not, then we will\r", "// replace the oldest entry.\r", "//\r", "//\r", "// Move all of the link key information down 1 slot. The will\r", "// delete the key in the first slot, which is the oldest.\r", "//\r", "//\r", "// Set the index of the free slot to be the last entry, which is\r", "// now available.\r", "//\r", "//\r", "// Save the link key information in the available slot (found above)\r", "//\r", "//\r", "// Save the updated link key structure to flash\r", "//\r", "//\r", "// Return index of the saved key\r", "//\r" ]
[ { "param": "sBD_ADDR", "type": "BD_ADDR_t" }, { "param": "sLinkKey", "type": "Link_Key_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sBD_ADDR", "type": "BD_ADDR_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sLinkKey", "type": "Link_Key_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
IssueCallback
void
static void IssueCallback(BD_ADDR_t *psBD_ADDR, tCallbackEvent eEvent) { tCallbackEventData sCallbackEventData; // // Verify that there is a valid callback function. // if(g_pfnCallbackFunction) { // // Load the callback event type // sCallbackEventData.sEvent = eEvent; // // Load the remote device address, if available // if(psBD_ADDR) { BD_ADDR_To_Array(*psBD_ADDR, sCallbackEventData.ucRemoteDevice); } // // Call the user callback function // g_pfnCallbackFunction(&sCallbackEventData, g_pvCallbackParameter); } }
//***************************************************************************** // // The following function is used to issue a callback to the registered // callback function. // //*****************************************************************************
The following function is used to issue a callback to the registered callback function.
[ "The", "following", "function", "is", "used", "to", "issue", "a", "callback", "to", "the", "registered", "callback", "function", "." ]
static void IssueCallback(BD_ADDR_t *psBD_ADDR, tCallbackEvent eEvent) { tCallbackEventData sCallbackEventData; if(g_pfnCallbackFunction) { sCallbackEventData.sEvent = eEvent; if(psBD_ADDR) { BD_ADDR_To_Array(*psBD_ADDR, sCallbackEventData.ucRemoteDevice); } g_pfnCallbackFunction(&sCallbackEventData, g_pvCallbackParameter); } }
[ "static", "void", "IssueCallback", "(", "BD_ADDR_t", "*", "psBD_ADDR", ",", "tCallbackEvent", "eEvent", ")", "{", "tCallbackEventData", "sCallbackEventData", ";", "if", "(", "g_pfnCallbackFunction", ")", "{", "sCallbackEventData", ".", "sEvent", "=", "eEvent", ";", "if", "(", "psBD_ADDR", ")", "{", "BD_ADDR_To_Array", "(", "*", "psBD_ADDR", ",", "sCallbackEventData", ".", "ucRemoteDevice", ")", ";", "}", "g_pfnCallbackFunction", "(", "&", "sCallbackEventData", ",", "g_pvCallbackParameter", ")", ";", "}", "}" ]
The following function is used to issue a callback to the registered callback function.
[ "The", "following", "function", "is", "used", "to", "issue", "a", "callback", "to", "the", "registered", "callback", "function", "." ]
[ "//\r", "// Verify that there is a valid callback function.\r", "//\r", "//\r", "// Load the callback event type\r", "//\r", "//\r", "// Load the remote device address, if available\r", "//\r", "//\r", "// Call the user callback function\r", "//\r" ]
[ { "param": "psBD_ADDR", "type": "BD_ADDR_t" }, { "param": "eEvent", "type": "tCallbackEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "psBD_ADDR", "type": "BD_ADDR_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eEvent", "type": "tCallbackEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
PinCodeResponse
int
int PinCodeResponse(unsigned char *pucBD_ADDR, int iPinCodeLength, char *pcPinCode) { int iRetVal; BD_ADDR_t sRemoteBD_ADDR; // // Verify that the parameters passed in appear valid. // if(pucBD_ADDR && iPinCodeLength && (iPinCodeLength <= SIZE_OF_PIN_CODE) && pcPinCode) { // // Assign the Bluetooth Address information. // ASSIGN_BD_ADDR(sRemoteBD_ADDR, pucBD_ADDR[0], pucBD_ADDR[1], pucBD_ADDR[2], pucBD_ADDR[3], pucBD_ADDR[4], pucBD_ADDR[5]); // // Setup the Authentication Information Response structure. // g_sAuthenticationInfo.GAP_Authentication_Type = atPINCode; g_sAuthenticationInfo.Authentication_Data_Length = iPinCodeLength; BTPS_MemCopy(&(g_sAuthenticationInfo.Authentication_Data.PIN_Code), pcPinCode, iPinCodeLength); // // Submit the Authentication Response. // iRetVal = GAP_Authentication_Response(g_uiBluetoothStackID, sRemoteBD_ADDR, &g_sAuthenticationInfo); // // Check the result of the submitted command. // if(!iRetVal) { Display(("GAP_Authentication_Response() Success.\n")); } else { Display(("GAP_Authentication_Response() Failure: %d.\n", iRetVal)); iRetVal = BTH_ERROR_REQUEST_FAILURE; } } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
//***************************************************************************** // // The following function provides a means to respond to a Pin code request. // The function takes as its parameters a pointer to the Bluetooth address of // the device that requested the Pin code and a pointer to the Pin Code data as // well as the number length of the data pointed to by PinCode. The // function return zero on success and a negative number on failure. // * NOTE * The PinCodeLength must be more than zero and less SIZE_OF_PIN_CODE // Bytes. // //*****************************************************************************
The following function provides a means to respond to a Pin code request. The function takes as its parameters a pointer to the Bluetooth address of the device that requested the Pin code and a pointer to the Pin Code data as well as the number length of the data pointed to by PinCode. The function return zero on success and a negative number on failure. NOTE * The PinCodeLength must be more than zero and less SIZE_OF_PIN_CODE Bytes.
[ "The", "following", "function", "provides", "a", "means", "to", "respond", "to", "a", "Pin", "code", "request", ".", "The", "function", "takes", "as", "its", "parameters", "a", "pointer", "to", "the", "Bluetooth", "address", "of", "the", "device", "that", "requested", "the", "Pin", "code", "and", "a", "pointer", "to", "the", "Pin", "Code", "data", "as", "well", "as", "the", "number", "length", "of", "the", "data", "pointed", "to", "by", "PinCode", ".", "The", "function", "return", "zero", "on", "success", "and", "a", "negative", "number", "on", "failure", ".", "NOTE", "*", "The", "PinCodeLength", "must", "be", "more", "than", "zero", "and", "less", "SIZE_OF_PIN_CODE", "Bytes", "." ]
int PinCodeResponse(unsigned char *pucBD_ADDR, int iPinCodeLength, char *pcPinCode) { int iRetVal; BD_ADDR_t sRemoteBD_ADDR; if(pucBD_ADDR && iPinCodeLength && (iPinCodeLength <= SIZE_OF_PIN_CODE) && pcPinCode) { ASSIGN_BD_ADDR(sRemoteBD_ADDR, pucBD_ADDR[0], pucBD_ADDR[1], pucBD_ADDR[2], pucBD_ADDR[3], pucBD_ADDR[4], pucBD_ADDR[5]); g_sAuthenticationInfo.GAP_Authentication_Type = atPINCode; g_sAuthenticationInfo.Authentication_Data_Length = iPinCodeLength; BTPS_MemCopy(&(g_sAuthenticationInfo.Authentication_Data.PIN_Code), pcPinCode, iPinCodeLength); iRetVal = GAP_Authentication_Response(g_uiBluetoothStackID, sRemoteBD_ADDR, &g_sAuthenticationInfo); if(!iRetVal) { Display(("GAP_Authentication_Response() Success.\n")); } else { Display(("GAP_Authentication_Response() Failure: %d.\n", iRetVal)); iRetVal = BTH_ERROR_REQUEST_FAILURE; } } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
[ "int", "PinCodeResponse", "(", "unsigned", "char", "*", "pucBD_ADDR", ",", "int", "iPinCodeLength", ",", "char", "*", "pcPinCode", ")", "{", "int", "iRetVal", ";", "BD_ADDR_t", "sRemoteBD_ADDR", ";", "if", "(", "pucBD_ADDR", "&&", "iPinCodeLength", "&&", "(", "iPinCodeLength", "<=", "SIZE_OF_PIN_CODE", ")", "&&", "pcPinCode", ")", "{", "ASSIGN_BD_ADDR", "(", "sRemoteBD_ADDR", ",", "pucBD_ADDR", "[", "0", "]", ",", "pucBD_ADDR", "[", "1", "]", ",", "pucBD_ADDR", "[", "2", "]", ",", "pucBD_ADDR", "[", "3", "]", ",", "pucBD_ADDR", "[", "4", "]", ",", "pucBD_ADDR", "[", "5", "]", ")", ";", "g_sAuthenticationInfo", ".", "GAP_Authentication_Type", "=", "atPINCode", ";", "g_sAuthenticationInfo", ".", "Authentication_Data_Length", "=", "iPinCodeLength", ";", "BTPS_MemCopy", "(", "&", "(", "g_sAuthenticationInfo", ".", "Authentication_Data", ".", "PIN_Code", ")", ",", "pcPinCode", ",", "iPinCodeLength", ")", ";", "iRetVal", "=", "GAP_Authentication_Response", "(", "g_uiBluetoothStackID", ",", "sRemoteBD_ADDR", ",", "&", "g_sAuthenticationInfo", ")", ";", "if", "(", "!", "iRetVal", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ",", "iRetVal", ")", ")", ";", "iRetVal", "=", "BTH_ERROR_REQUEST_FAILURE", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_INVALID_PARAMETER", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function provides a means to respond to a Pin code request.
[ "The", "following", "function", "provides", "a", "means", "to", "respond", "to", "a", "Pin", "code", "request", "." ]
[ "//\r", "// Verify that the parameters passed in appear valid.\r", "//\r", "//\r", "// Assign the Bluetooth Address information.\r", "//\r", "//\r", "// Setup the Authentication Information Response structure.\r", "//\r", "//\r", "// Submit the Authentication Response.\r", "//\r", "//\r", "// Check the result of the submitted command.\r", "//\r" ]
[ { "param": "pucBD_ADDR", "type": "unsigned char" }, { "param": "iPinCodeLength", "type": "int" }, { "param": "pcPinCode", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pucBD_ADDR", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iPinCodeLength", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pcPinCode", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
GetLocalDeviceInformation
int
int GetLocalDeviceInformation(tDeviceInfo *psDeviceInfo) { int iRetVal; // // Verify that the parameters passed in appear valid. // if(psDeviceInfo) { // // Copy the local device info to the user. // BTPS_MemCopy(psDeviceInfo, &g_sDeviceInfo, sizeof(tDeviceInfo)); iRetVal = 0; } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
//***************************************************************************** // // The following function is used to retrieve information about the local // Bluetooth device. The function takes as its parameter a pointer to a Device // Info Structure that will be filled in by this function with information // about the local device. If the function fails to return the device // information, the return value will be negative, otherwise the return value // will be zero. // //*****************************************************************************
The following function is used to retrieve information about the local Bluetooth device. The function takes as its parameter a pointer to a Device Info Structure that will be filled in by this function with information about the local device. If the function fails to return the device information, the return value will be negative, otherwise the return value will be zero.
[ "The", "following", "function", "is", "used", "to", "retrieve", "information", "about", "the", "local", "Bluetooth", "device", ".", "The", "function", "takes", "as", "its", "parameter", "a", "pointer", "to", "a", "Device", "Info", "Structure", "that", "will", "be", "filled", "in", "by", "this", "function", "with", "information", "about", "the", "local", "device", ".", "If", "the", "function", "fails", "to", "return", "the", "device", "information", "the", "return", "value", "will", "be", "negative", "otherwise", "the", "return", "value", "will", "be", "zero", "." ]
int GetLocalDeviceInformation(tDeviceInfo *psDeviceInfo) { int iRetVal; if(psDeviceInfo) { BTPS_MemCopy(psDeviceInfo, &g_sDeviceInfo, sizeof(tDeviceInfo)); iRetVal = 0; } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
[ "int", "GetLocalDeviceInformation", "(", "tDeviceInfo", "*", "psDeviceInfo", ")", "{", "int", "iRetVal", ";", "if", "(", "psDeviceInfo", ")", "{", "BTPS_MemCopy", "(", "psDeviceInfo", ",", "&", "g_sDeviceInfo", ",", "sizeof", "(", "tDeviceInfo", ")", ")", ";", "iRetVal", "=", "0", ";", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_INVALID_PARAMETER", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to retrieve information about the local Bluetooth device.
[ "The", "following", "function", "is", "used", "to", "retrieve", "information", "about", "the", "local", "Bluetooth", "device", "." ]
[ "//\r", "// Verify that the parameters passed in appear valid.\r", "//\r", "//\r", "// Copy the local device info to the user.\r", "//\r" ]
[ { "param": "psDeviceInfo", "type": "tDeviceInfo" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "psDeviceInfo", "type": "tDeviceInfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
SetLocalDeviceMode
int
int SetLocalDeviceMode(unsigned short usMode) { int iRetVal; GAP_Pairability_Mode_t sPairableMode; // // Make sure that 2 modes are not being set. // if((usMode & PAIRABLE_MODE_MASK) != PAIRABLE_MODE_MASK) { // // Determine the mode that is being enabled. // sPairableMode = pmNonPairableMode; if(usMode & PAIRABLE_NON_SSP_MODE) { sPairableMode = pmPairableMode; } if(usMode & PAIRABLE_SSP_MODE) { sPairableMode = pmPairableMode_EnableSecureSimplePairing; } // // Attempt to set the mode. // iRetVal = GAP_Set_Pairability_Mode(g_uiBluetoothStackID, sPairableMode); // // If there was no error and pairable mode is being enabled then we // need to register for remote authentication. // if(!iRetVal) { // // If we are in a Pairable mode, then register the authentication // callback. // if(sPairableMode != pmNonPairableMode) { // // Register the authentication callback. // GAP_Register_Remote_Authentication(g_uiBluetoothStackID, GAP_EventCallback, 0); } // // Check the Connectability Mode. // if(usMode & CONNECTABLE_MODE) { GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmConnectableMode); } else { GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmNonConnectableMode); } // // Check the Discoverability Mode. // if(usMode & DISCOVERABLE_MODE) { GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmGeneralDiscoverableMode, 0); } else { GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmNonDiscoverableMode, 0); } // // Save the current Mode settings. // g_sDeviceInfo.sMode = usMode; } // // There was an error setting pairability, set error return code // else { iRetVal = BTH_ERROR_REQUEST_FAILURE; } } // // There was an error in the parameters passed to this function, set // error return code. // else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
//***************************************************************************** // // The following function is used to set the local device mode. The function // takes as its parameter a bit-mask that indicates the state of the various // modes. It should be noted that if the device supports Secured Simple // Pairing, then once it has been enabled then it can't be disabled. // //*****************************************************************************
The following function is used to set the local device mode. The function takes as its parameter a bit-mask that indicates the state of the various modes. It should be noted that if the device supports Secured Simple Pairing, then once it has been enabled then it can't be disabled.
[ "The", "following", "function", "is", "used", "to", "set", "the", "local", "device", "mode", ".", "The", "function", "takes", "as", "its", "parameter", "a", "bit", "-", "mask", "that", "indicates", "the", "state", "of", "the", "various", "modes", ".", "It", "should", "be", "noted", "that", "if", "the", "device", "supports", "Secured", "Simple", "Pairing", "then", "once", "it", "has", "been", "enabled", "then", "it", "can", "'", "t", "be", "disabled", "." ]
int SetLocalDeviceMode(unsigned short usMode) { int iRetVal; GAP_Pairability_Mode_t sPairableMode; if((usMode & PAIRABLE_MODE_MASK) != PAIRABLE_MODE_MASK) { sPairableMode = pmNonPairableMode; if(usMode & PAIRABLE_NON_SSP_MODE) { sPairableMode = pmPairableMode; } if(usMode & PAIRABLE_SSP_MODE) { sPairableMode = pmPairableMode_EnableSecureSimplePairing; } iRetVal = GAP_Set_Pairability_Mode(g_uiBluetoothStackID, sPairableMode); if(!iRetVal) { if(sPairableMode != pmNonPairableMode) { GAP_Register_Remote_Authentication(g_uiBluetoothStackID, GAP_EventCallback, 0); } if(usMode & CONNECTABLE_MODE) { GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmConnectableMode); } else { GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmNonConnectableMode); } if(usMode & DISCOVERABLE_MODE) { GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmGeneralDiscoverableMode, 0); } else { GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmNonDiscoverableMode, 0); } g_sDeviceInfo.sMode = usMode; } else { iRetVal = BTH_ERROR_REQUEST_FAILURE; } } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
[ "int", "SetLocalDeviceMode", "(", "unsigned", "short", "usMode", ")", "{", "int", "iRetVal", ";", "GAP_Pairability_Mode_t", "sPairableMode", ";", "if", "(", "(", "usMode", "&", "PAIRABLE_MODE_MASK", ")", "!=", "PAIRABLE_MODE_MASK", ")", "{", "sPairableMode", "=", "pmNonPairableMode", ";", "if", "(", "usMode", "&", "PAIRABLE_NON_SSP_MODE", ")", "{", "sPairableMode", "=", "pmPairableMode", ";", "}", "if", "(", "usMode", "&", "PAIRABLE_SSP_MODE", ")", "{", "sPairableMode", "=", "pmPairableMode_EnableSecureSimplePairing", ";", "}", "iRetVal", "=", "GAP_Set_Pairability_Mode", "(", "g_uiBluetoothStackID", ",", "sPairableMode", ")", ";", "if", "(", "!", "iRetVal", ")", "{", "if", "(", "sPairableMode", "!=", "pmNonPairableMode", ")", "{", "GAP_Register_Remote_Authentication", "(", "g_uiBluetoothStackID", ",", "GAP_EventCallback", ",", "0", ")", ";", "}", "if", "(", "usMode", "&", "CONNECTABLE_MODE", ")", "{", "GAP_Set_Connectability_Mode", "(", "g_uiBluetoothStackID", ",", "cmConnectableMode", ")", ";", "}", "else", "{", "GAP_Set_Connectability_Mode", "(", "g_uiBluetoothStackID", ",", "cmNonConnectableMode", ")", ";", "}", "if", "(", "usMode", "&", "DISCOVERABLE_MODE", ")", "{", "GAP_Set_Discoverability_Mode", "(", "g_uiBluetoothStackID", ",", "dmGeneralDiscoverableMode", ",", "0", ")", ";", "}", "else", "{", "GAP_Set_Discoverability_Mode", "(", "g_uiBluetoothStackID", ",", "dmNonDiscoverableMode", ",", "0", ")", ";", "}", "g_sDeviceInfo", ".", "sMode", "=", "usMode", ";", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_REQUEST_FAILURE", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_INVALID_PARAMETER", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to set the local device mode.
[ "The", "following", "function", "is", "used", "to", "set", "the", "local", "device", "mode", "." ]
[ "//\r", "// Make sure that 2 modes are not being set.\r", "//\r", "//\r", "// Determine the mode that is being enabled.\r", "//\r", "//\r", "// Attempt to set the mode.\r", "//\r", "//\r", "// If there was no error and pairable mode is being enabled then we\r", "// need to register for remote authentication.\r", "//\r", "//\r", "// If we are in a Pairable mode, then register the authentication\r", "// callback.\r", "//\r", "//\r", "// Register the authentication callback.\r", "//\r", "//\r", "// Check the Connectability Mode.\r", "//\r", "//\r", "// Check the Discoverability Mode.\r", "//\r", "//\r", "// Save the current Mode settings.\r", "//\r", "//\r", "// There was an error setting pairability, set error return code\r", "//\r", "//\r", "// There was an error in the parameters passed to this function, set\r", "// error return code.\r", "//\r" ]
[ { "param": "usMode", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "usMode", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
SetLocalDeviceName
int
int SetLocalDeviceName(char *pcDeviceName) { int iRetVal; // // Verify that the parameters passed in appear valid. // if(pcDeviceName) { // // Check to see that the length of the name is within the limits. // iRetVal = BTPS_StringLength(pcDeviceName); if(iRetVal > MAX_DEVICE_NAME_LENGTH) { // // Truncate the name to the Maximum length. // pcDeviceName[MAX_DEVICE_NAME_LENGTH] = 0; iRetVal = MAX_DEVICE_NAME_LENGTH; } // // Copy the device name plus the terminator. // BTPS_MemCopy(g_sDeviceInfo.cDeviceName, pcDeviceName, iRetVal + 1); // // Set the new device name. // if(GAP_Set_Local_Device_Name(g_uiBluetoothStackID, g_sDeviceInfo.cDeviceName)) { iRetVal = BTH_ERROR_REQUEST_FAILURE; } else { iRetVal = 0; } } // // Function parameter was bad, set error return code // else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
//***************************************************************************** // // The following function is used to set the local device name. The function // takes as its parameter a pointer to the new device name. The function will // truncate the name if the name exceeds MAX_DEVICE_NAME_LENGTH characters. // The function returns zero on success and a negative number on failure. // //*****************************************************************************
The following function is used to set the local device name. The function takes as its parameter a pointer to the new device name. The function will truncate the name if the name exceeds MAX_DEVICE_NAME_LENGTH characters. The function returns zero on success and a negative number on failure.
[ "The", "following", "function", "is", "used", "to", "set", "the", "local", "device", "name", ".", "The", "function", "takes", "as", "its", "parameter", "a", "pointer", "to", "the", "new", "device", "name", ".", "The", "function", "will", "truncate", "the", "name", "if", "the", "name", "exceeds", "MAX_DEVICE_NAME_LENGTH", "characters", ".", "The", "function", "returns", "zero", "on", "success", "and", "a", "negative", "number", "on", "failure", "." ]
int SetLocalDeviceName(char *pcDeviceName) { int iRetVal; if(pcDeviceName) { iRetVal = BTPS_StringLength(pcDeviceName); if(iRetVal > MAX_DEVICE_NAME_LENGTH) { pcDeviceName[MAX_DEVICE_NAME_LENGTH] = 0; iRetVal = MAX_DEVICE_NAME_LENGTH; } BTPS_MemCopy(g_sDeviceInfo.cDeviceName, pcDeviceName, iRetVal + 1); if(GAP_Set_Local_Device_Name(g_uiBluetoothStackID, g_sDeviceInfo.cDeviceName)) { iRetVal = BTH_ERROR_REQUEST_FAILURE; } else { iRetVal = 0; } } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
[ "int", "SetLocalDeviceName", "(", "char", "*", "pcDeviceName", ")", "{", "int", "iRetVal", ";", "if", "(", "pcDeviceName", ")", "{", "iRetVal", "=", "BTPS_StringLength", "(", "pcDeviceName", ")", ";", "if", "(", "iRetVal", ">", "MAX_DEVICE_NAME_LENGTH", ")", "{", "pcDeviceName", "[", "MAX_DEVICE_NAME_LENGTH", "]", "=", "0", ";", "iRetVal", "=", "MAX_DEVICE_NAME_LENGTH", ";", "}", "BTPS_MemCopy", "(", "g_sDeviceInfo", ".", "cDeviceName", ",", "pcDeviceName", ",", "iRetVal", "+", "1", ")", ";", "if", "(", "GAP_Set_Local_Device_Name", "(", "g_uiBluetoothStackID", ",", "g_sDeviceInfo", ".", "cDeviceName", ")", ")", "{", "iRetVal", "=", "BTH_ERROR_REQUEST_FAILURE", ";", "}", "else", "{", "iRetVal", "=", "0", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_INVALID_PARAMETER", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to set the local device name.
[ "The", "following", "function", "is", "used", "to", "set", "the", "local", "device", "name", "." ]
[ "//\r", "// Verify that the parameters passed in appear valid.\r", "//\r", "//\r", "// Check to see that the length of the name is within the limits.\r", "//\r", "//\r", "// Truncate the name to the Maximum length.\r", "//\r", "//\r", "// Copy the device name plus the terminator.\r", "//\r", "//\r", "// Set the new device name.\r", "//\r", "//\r", "// Function parameter was bad, set error return code\r", "//\r" ]
[ { "param": "pcDeviceName", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pcDeviceName", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
DACIntHandler
void
void DACIntHandler(void) { unsigned long ulStatus; // // Get the interrupt status and clear any pending interrupts. // ulStatus = I2SIntStatus(I2S0_BASE, true); I2SIntClear(I2S0_BASE, ulStatus); // // Pack the left and right channel into a single 32 bit value and load it // into the transmit register. Continue this until the transmit FIFO is // full. // while(g_sAudioData.iNumAudioSamples && I2STxDataPutNonBlocking(I2S0_BASE, ((g_sAudioData.usLeftChannel[g_sAudioData.iOutIndex] << 16) | g_sAudioData.usRightChannel[g_sAudioData.iOutIndex]))) { // // Increment the output index and handle any buffer wrap. // g_sAudioData.iOutIndex++; g_sAudioData.iNumAudioSamples--; if(g_sAudioData.iEndIndex && (g_sAudioData.iOutIndex >= g_sAudioData.iEndIndex)) { g_sAudioData.iOutIndex = 0; } } // // If we run out of audio samples, disable the DAC interrupts and set the // state to waiting. We will start playing again when we buffer up enough // audio samples. // if(!g_sAudioData.iNumAudioSamples) { I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); g_sAudioState = asDecoding; } }
//***************************************************************************** // // Interrupt handler for I2S peripheral, which is used for passing data to the // audio DAC. // //*****************************************************************************
Interrupt handler for I2S peripheral, which is used for passing data to the audio DAC.
[ "Interrupt", "handler", "for", "I2S", "peripheral", "which", "is", "used", "for", "passing", "data", "to", "the", "audio", "DAC", "." ]
void DACIntHandler(void) { unsigned long ulStatus; ulStatus = I2SIntStatus(I2S0_BASE, true); I2SIntClear(I2S0_BASE, ulStatus); while(g_sAudioData.iNumAudioSamples && I2STxDataPutNonBlocking(I2S0_BASE, ((g_sAudioData.usLeftChannel[g_sAudioData.iOutIndex] << 16) | g_sAudioData.usRightChannel[g_sAudioData.iOutIndex]))) { g_sAudioData.iOutIndex++; g_sAudioData.iNumAudioSamples--; if(g_sAudioData.iEndIndex && (g_sAudioData.iOutIndex >= g_sAudioData.iEndIndex)) { g_sAudioData.iOutIndex = 0; } } if(!g_sAudioData.iNumAudioSamples) { I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); g_sAudioState = asDecoding; } }
[ "void", "DACIntHandler", "(", "void", ")", "{", "unsigned", "long", "ulStatus", ";", "ulStatus", "=", "I2SIntStatus", "(", "I2S0_BASE", ",", "true", ")", ";", "I2SIntClear", "(", "I2S0_BASE", ",", "ulStatus", ")", ";", "while", "(", "g_sAudioData", ".", "iNumAudioSamples", "&&", "I2STxDataPutNonBlocking", "(", "I2S0_BASE", ",", "(", "(", "g_sAudioData", ".", "usLeftChannel", "[", "g_sAudioData", ".", "iOutIndex", "]", "<<", "16", ")", "|", "g_sAudioData", ".", "usRightChannel", "[", "g_sAudioData", ".", "iOutIndex", "]", ")", ")", ")", "{", "g_sAudioData", ".", "iOutIndex", "++", ";", "g_sAudioData", ".", "iNumAudioSamples", "--", ";", "if", "(", "g_sAudioData", ".", "iEndIndex", "&&", "(", "g_sAudioData", ".", "iOutIndex", ">=", "g_sAudioData", ".", "iEndIndex", ")", ")", "{", "g_sAudioData", ".", "iOutIndex", "=", "0", ";", "}", "}", "if", "(", "!", "g_sAudioData", ".", "iNumAudioSamples", ")", "{", "I2SIntDisable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "g_sAudioState", "=", "asDecoding", ";", "}", "}" ]
Interrupt handler for I2S peripheral, which is used for passing data to the audio DAC.
[ "Interrupt", "handler", "for", "I2S", "peripheral", "which", "is", "used", "for", "passing", "data", "to", "the", "audio", "DAC", "." ]
[ "//\r", "// Get the interrupt status and clear any pending interrupts.\r", "//\r", "//\r", "// Pack the left and right channel into a single 32 bit value and load it\r", "// into the transmit register. Continue this until the transmit FIFO is\r", "// full.\r", "//\r", "//\r", "// Increment the output index and handle any buffer wrap.\r", "//\r", "//\r", "// If we run out of audio samples, disable the DAC interrupts and set the\r", "// state to waiting. We will start playing again when we buffer up enough\r", "// audio samples.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
Decode
int
static int Decode(unsigned int uiDataLength, unsigned char *pucDataPtr) { int iRetVal; unsigned int uiUnusedDataLength; // // Note the amount of unprocessed data. // uiUnusedDataLength = uiDataLength; // // Verify that the parameters passed in appear valid. // if(uiDataLength && pucDataPtr) { // // Process while there is unused data. // while(uiUnusedDataLength) { // // Initialize the decode data structure for this iteration. // g_sDecodedData.LeftChannelDataLength = 0; g_sDecodedData.RightChannelDataLength = 0; g_sDecodedData.LeftChannelDataPtr = &g_sAudioData.usLeftChannel[g_sAudioData.iInIndex]; g_sDecodedData.RightChannelDataPtr = &g_sAudioData.usRightChannel[g_sAudioData.iInIndex]; // // Lock out I2S interrupts while updating buffer info // if(g_sAudioState == asPlaying) { I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); } // // Calculate the amount of space available for audio samples. // if(g_sAudioData.iOutIndex > g_sAudioData.iInIndex) { g_sDecodedData.ChannelDataSize = (unsigned int)(g_sAudioData.iOutIndex - g_sAudioData.iInIndex); } else { g_sDecodedData.ChannelDataSize = (unsigned int)(AUDIO_BUFFER_SIZE - g_sAudioData.iInIndex); } // // Restore I2S processing // if(g_sAudioState == asPlaying) { I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } // // Make sure that there is enough room to contain the samples from // a single SBC frame. // if(g_sDecodedData.ChannelDataSize < NUM_AUDIO_SAMPLES_PER_SBC_FRAME) { break; } // // Pass the SBC data into the decoder. If a complete frame was // decoded then we need to write the decoded data to the output // buffer. // iRetVal = SBC_Decode_Data( g_sDecoderHandle, uiUnusedDataLength, &pucDataPtr[uiDataLength - uiUnusedDataLength], &g_sDecodeConfiguration, &g_sDecodedData, &uiUnusedDataLength); if(iRetVal == SBC_PROCESSING_COMPLETE) { // // If format was changed then recompute buffer limits // if(g_iFormatFlag == 1) { g_iFormatFlag = 0; // // Show configuration on debug console // Display(("Frame Length : %d\r\n", g_sDecodeConfiguration.FrameLength)); Display(("Bit Pool : %d\r\n", g_sDecodeConfiguration.BitPool)); Display(("Bit Rate : %d\r\n", g_sDecodeConfiguration.BitRate)); Display(("Buffer Length : %d\r\n", g_sDecodedData.LeftChannelDataLength)); Display(("Frames/GAVD : %d\r\n", (uiDataLength/g_sDecodeConfiguration.FrameLength))); } // // Adjust the index for the audio samples that were just added. // g_sAudioData.iInIndex += g_sDecodedData.LeftChannelDataLength; // // Check to see if we are waiting to build up samples before we // start playing the audio. // if(g_sAudioState == asPlaying) { // // Protect data structures from int handler corruption // I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); // // Update the number of audio samples that are available to // be played. // g_sAudioData.iNumAudioSamples += g_sDecodedData.LeftChannelDataLength; // // Reenable I2S audio int handler // I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } else { // // Check to see if we are waiting to build up samples // before we start playing the audio. // if(g_sAudioData.sAudioState == asDecoding) { g_sAudioData.iNumAudioSamples += g_sDecodedData.LeftChannelDataLength; // // Check to see if we have enough samples to start. // if(g_sAudioData.iNumAudioSamples >= (AUDIO_BUFFER_SIZE >> 1)) { // // It is time to start the audio, so enable the // audio interrupt. // g_sAudioState = asPlaying; I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } } } // // Check to see if another packet would overflow the buffer. // if((g_sAudioData.iInIndex + g_sDecodedData.LeftChannelDataLength) > AUDIO_BUFFER_SIZE) { // // Set a marker to the last available audio sample and wrap // the index to the beginning of the buffer. // g_sAudioData.iEndIndex = g_sAudioData.iInIndex; g_sAudioData.iInIndex = 0; } } else { Display(("Incomplete %d %d\n", iRetVal, uiUnusedDataLength)); } } } // // Return the number of bytes that were processed. // return(uiDataLength - uiUnusedDataLength); }
//***************************************************************************** // // The following function issued to decode a block of SBC data. When a full // buffer of data is decoded, the data is delivered to the upper layer for // playback. // //*****************************************************************************
The following function issued to decode a block of SBC data. When a full buffer of data is decoded, the data is delivered to the upper layer for playback.
[ "The", "following", "function", "issued", "to", "decode", "a", "block", "of", "SBC", "data", ".", "When", "a", "full", "buffer", "of", "data", "is", "decoded", "the", "data", "is", "delivered", "to", "the", "upper", "layer", "for", "playback", "." ]
static int Decode(unsigned int uiDataLength, unsigned char *pucDataPtr) { int iRetVal; unsigned int uiUnusedDataLength; uiUnusedDataLength = uiDataLength; if(uiDataLength && pucDataPtr) { while(uiUnusedDataLength) { g_sDecodedData.LeftChannelDataLength = 0; g_sDecodedData.RightChannelDataLength = 0; g_sDecodedData.LeftChannelDataPtr = &g_sAudioData.usLeftChannel[g_sAudioData.iInIndex]; g_sDecodedData.RightChannelDataPtr = &g_sAudioData.usRightChannel[g_sAudioData.iInIndex]; if(g_sAudioState == asPlaying) { I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); } if(g_sAudioData.iOutIndex > g_sAudioData.iInIndex) { g_sDecodedData.ChannelDataSize = (unsigned int)(g_sAudioData.iOutIndex - g_sAudioData.iInIndex); } else { g_sDecodedData.ChannelDataSize = (unsigned int)(AUDIO_BUFFER_SIZE - g_sAudioData.iInIndex); } if(g_sAudioState == asPlaying) { I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } if(g_sDecodedData.ChannelDataSize < NUM_AUDIO_SAMPLES_PER_SBC_FRAME) { break; } iRetVal = SBC_Decode_Data( g_sDecoderHandle, uiUnusedDataLength, &pucDataPtr[uiDataLength - uiUnusedDataLength], &g_sDecodeConfiguration, &g_sDecodedData, &uiUnusedDataLength); if(iRetVal == SBC_PROCESSING_COMPLETE) { if(g_iFormatFlag == 1) { g_iFormatFlag = 0; Display(("Frame Length : %d\r\n", g_sDecodeConfiguration.FrameLength)); Display(("Bit Pool : %d\r\n", g_sDecodeConfiguration.BitPool)); Display(("Bit Rate : %d\r\n", g_sDecodeConfiguration.BitRate)); Display(("Buffer Length : %d\r\n", g_sDecodedData.LeftChannelDataLength)); Display(("Frames/GAVD : %d\r\n", (uiDataLength/g_sDecodeConfiguration.FrameLength))); } g_sAudioData.iInIndex += g_sDecodedData.LeftChannelDataLength; if(g_sAudioState == asPlaying) { I2SIntDisable(I2S0_BASE, I2S_INT_TXREQ); g_sAudioData.iNumAudioSamples += g_sDecodedData.LeftChannelDataLength; I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } else { if(g_sAudioData.sAudioState == asDecoding) { g_sAudioData.iNumAudioSamples += g_sDecodedData.LeftChannelDataLength; if(g_sAudioData.iNumAudioSamples >= (AUDIO_BUFFER_SIZE >> 1)) { g_sAudioState = asPlaying; I2SIntEnable(I2S0_BASE, I2S_INT_TXREQ); } } } if((g_sAudioData.iInIndex + g_sDecodedData.LeftChannelDataLength) > AUDIO_BUFFER_SIZE) { g_sAudioData.iEndIndex = g_sAudioData.iInIndex; g_sAudioData.iInIndex = 0; } } else { Display(("Incomplete %d %d\n", iRetVal, uiUnusedDataLength)); } } } return(uiDataLength - uiUnusedDataLength); }
[ "static", "int", "Decode", "(", "unsigned", "int", "uiDataLength", ",", "unsigned", "char", "*", "pucDataPtr", ")", "{", "int", "iRetVal", ";", "unsigned", "int", "uiUnusedDataLength", ";", "uiUnusedDataLength", "=", "uiDataLength", ";", "if", "(", "uiDataLength", "&&", "pucDataPtr", ")", "{", "while", "(", "uiUnusedDataLength", ")", "{", "g_sDecodedData", ".", "LeftChannelDataLength", "=", "0", ";", "g_sDecodedData", ".", "RightChannelDataLength", "=", "0", ";", "g_sDecodedData", ".", "LeftChannelDataPtr", "=", "&", "g_sAudioData", ".", "usLeftChannel", "[", "g_sAudioData", ".", "iInIndex", "]", ";", "g_sDecodedData", ".", "RightChannelDataPtr", "=", "&", "g_sAudioData", ".", "usRightChannel", "[", "g_sAudioData", ".", "iInIndex", "]", ";", "if", "(", "g_sAudioState", "==", "asPlaying", ")", "{", "I2SIntDisable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "}", "if", "(", "g_sAudioData", ".", "iOutIndex", ">", "g_sAudioData", ".", "iInIndex", ")", "{", "g_sDecodedData", ".", "ChannelDataSize", "=", "(", "unsigned", "int", ")", "(", "g_sAudioData", ".", "iOutIndex", "-", "g_sAudioData", ".", "iInIndex", ")", ";", "}", "else", "{", "g_sDecodedData", ".", "ChannelDataSize", "=", "(", "unsigned", "int", ")", "(", "AUDIO_BUFFER_SIZE", "-", "g_sAudioData", ".", "iInIndex", ")", ";", "}", "if", "(", "g_sAudioState", "==", "asPlaying", ")", "{", "I2SIntEnable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "}", "if", "(", "g_sDecodedData", ".", "ChannelDataSize", "<", "NUM_AUDIO_SAMPLES_PER_SBC_FRAME", ")", "{", "break", ";", "}", "iRetVal", "=", "SBC_Decode_Data", "(", "g_sDecoderHandle", ",", "uiUnusedDataLength", ",", "&", "pucDataPtr", "[", "uiDataLength", "-", "uiUnusedDataLength", "]", ",", "&", "g_sDecodeConfiguration", ",", "&", "g_sDecodedData", ",", "&", "uiUnusedDataLength", ")", ";", "if", "(", "iRetVal", "==", "SBC_PROCESSING_COMPLETE", ")", "{", "if", "(", "g_iFormatFlag", "==", "1", ")", "{", "g_iFormatFlag", "=", "0", ";", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "g_sDecodeConfiguration", ".", "FrameLength", ")", ")", ";", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "g_sDecodeConfiguration", ".", "BitPool", ")", ")", ";", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "g_sDecodeConfiguration", ".", "BitRate", ")", ")", ";", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "g_sDecodedData", ".", "LeftChannelDataLength", ")", ")", ";", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "(", "uiDataLength", "/", "g_sDecodeConfiguration", ".", "FrameLength", ")", ")", ")", ";", "}", "g_sAudioData", ".", "iInIndex", "+=", "g_sDecodedData", ".", "LeftChannelDataLength", ";", "if", "(", "g_sAudioState", "==", "asPlaying", ")", "{", "I2SIntDisable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "g_sAudioData", ".", "iNumAudioSamples", "+=", "g_sDecodedData", ".", "LeftChannelDataLength", ";", "I2SIntEnable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "}", "else", "{", "if", "(", "g_sAudioData", ".", "sAudioState", "==", "asDecoding", ")", "{", "g_sAudioData", ".", "iNumAudioSamples", "+=", "g_sDecodedData", ".", "LeftChannelDataLength", ";", "if", "(", "g_sAudioData", ".", "iNumAudioSamples", ">=", "(", "AUDIO_BUFFER_SIZE", ">>", "1", ")", ")", "{", "g_sAudioState", "=", "asPlaying", ";", "I2SIntEnable", "(", "I2S0_BASE", ",", "I2S_INT_TXREQ", ")", ";", "}", "}", "}", "if", "(", "(", "g_sAudioData", ".", "iInIndex", "+", "g_sDecodedData", ".", "LeftChannelDataLength", ")", ">", "AUDIO_BUFFER_SIZE", ")", "{", "g_sAudioData", ".", "iEndIndex", "=", "g_sAudioData", ".", "iInIndex", ";", "g_sAudioData", ".", "iInIndex", "=", "0", ";", "}", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ",", "iRetVal", ",", "uiUnusedDataLength", ")", ")", ";", "}", "}", "}", "return", "(", "uiDataLength", "-", "uiUnusedDataLength", ")", ";", "}" ]
The following function issued to decode a block of SBC data.
[ "The", "following", "function", "issued", "to", "decode", "a", "block", "of", "SBC", "data", "." ]
[ "//\r", "// Note the amount of unprocessed data.\r", "//\r", "//\r", "// Verify that the parameters passed in appear valid.\r", "//\r", "//\r", "// Process while there is unused data.\r", "//\r", "//\r", "// Initialize the decode data structure for this iteration.\r", "//\r", "//\r", "// Lock out I2S interrupts while updating buffer info\r", "//\r", "//\r", "// Calculate the amount of space available for audio samples.\r", "//\r", "//\r", "// Restore I2S processing\r", "//\r", "//\r", "// Make sure that there is enough room to contain the samples from\r", "// a single SBC frame.\r", "//\r", "//\r", "// Pass the SBC data into the decoder. If a complete frame was\r", "// decoded then we need to write the decoded data to the output\r", "// buffer.\r", "//\r", "//\r", "// If format was changed then recompute buffer limits\r", "//\r", "//\r", "// Show configuration on debug console\r", "//\r", "//\r", "// Adjust the index for the audio samples that were just added.\r", "//\r", "//\r", "// Check to see if we are waiting to build up samples before we\r", "// start playing the audio.\r", "//\r", "//\r", "// Protect data structures from int handler corruption\r", "//\r", "//\r", "// Update the number of audio samples that are available to\r", "// be played.\r", "//\r", "//\r", "// Reenable I2S audio int handler\r", "//\r", "//\r", "// Check to see if we are waiting to build up samples\r", "// before we start playing the audio.\r", "//\r", "//\r", "// Check to see if we have enough samples to start.\r", "//\r", "//\r", "// It is time to start the audio, so enable the\r", "// audio interrupt.\r", "//\r", "//\r", "// Check to see if another packet would overflow the buffer.\r", "//\r", "//\r", "// Set a marker to the last available audio sample and wrap\r", "// the index to the beginning of the buffer.\r", "//\r", "//\r", "// Return the number of bytes that were processed.\r", "//\r" ]
[ { "param": "uiDataLength", "type": "unsigned int" }, { "param": "pucDataPtr", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uiDataLength", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucDataPtr", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
GAVD_SetConfiguration
int
static int GAVD_SetConfiguration(unsigned int uiNumberServiceCapabilities, GAVD_Service_Capabilities_Info_t *psCapab) { int iRetVal; unsigned char sValue; unsigned char *sSpecInfoPtr; GAVD_Media_Codec_Info_Element_Data_t *pCodecInfo; // // Initialize the return value. // iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CODEC_TYPE; // // Check for valid parameters passed to this function // while(uiNumberServiceCapabilities && psCapab) { // // We need to make sure that the Code is SBC audio and that we support // the bit rate. // if(psCapab->ServiceCategory == scMediaCodec) { // // Check for expected codec info // pCodecInfo = &psCapab->InfoElement.GAVD_Media_Codec_Info_Element_Data; if((pCodecInfo->MediaType == mtAudio) && (pCodecInfo->MediaCodecType == A2DP_MEDIA_CODEC_TYPE_SBC)) { if(pCodecInfo->MediaCodecSpecificInfoLength == A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE) { // // Get a pointer to the configuration information. // sSpecInfoPtr = pCodecInfo->MediaCodecSpecificInfo; // // Check to see what frequency is being requested. // *MUST* be 44.1 KHz, or 48 KHz. // sValue = A2DP_SBC_READ_SAMPLING_FREQUENCY(sSpecInfoPtr); if((sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) || (sValue == A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE)) { // // Display the sampling frequency and return the // proper Value. // Display(("Sampling Frequency: %s\n", (sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) ? "44.1 KHz" : "48KHz")); iRetVal = (sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) ? 44100 : 48000; } else { // // Unsupported sample rate requested so return error // iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SAMPLING_FREQUENCY; } // // Read the requested channel modes. // Display(("Channel Mode : \f")); sValue = A2DP_SBC_READ_CHANNEL_MODE(sSpecInfoPtr); // // Show the value of the channel mode on the debug console // switch(sValue) { case A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE: { Display(("Joint Stereo\n")); break; } case A2DP_SBC_CHANNEL_MODE_STEREO_VALUE: { Display(("Stereo\n")); break; } case A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE: { Display(("Dual Channel\n")); break; } default: { // // This case should not happen, so return an // error // Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CHANNEL_MODE; break; } } // // Read the block length. // Display(("Block Length : \f")); sValue = A2DP_SBC_READ_BLOCK_LENGTH(sSpecInfoPtr); switch(sValue) { case A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE: { Display(("4\n")); break; } case A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE: { Display(("8\n")); break; } case A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE: { Display(("12\n")); break; } case A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE: { Display(("16\n")); break; } default: { Display(("Invalid\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_BLOCK_LENGTH; break; } } // // Read the number of SBC subbands. // Display(("Number Sub Bands : \f")); sValue = A2DP_SBC_READ_SUBBANDS(sSpecInfoPtr); switch(sValue) { case A2DP_SBC_SUBBANDS_FOUR_VALUE: { Display(("4\n")); break; } case A2DP_SBC_SUBBANDS_EIGHT_VALUE: { Display(("8\n")); break; } default: { Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SUBBANDS; break; } } // // Read the SBC allocation methods. // sValue = A2DP_SBC_READ_ALLOCATION_METHOD(sSpecInfoPtr); Display(("Allocation Method : \f")); switch(sValue) { case A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE: { Display(("SNR\n")); break; } case A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE: { Display(("Loudness\n")); break; } default: { Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_ALLOCATION_METHOD; break; } } // // Assign minimum and maximum supported SBC bit pool // values. // if(A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE(sSpecInfoPtr) < 0x0A) { iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MINIMUM_BIT_POOL_VALUE; } if(A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE(sSpecInfoPtr) > 0x90) { iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MAXIMUM_BIT_POOL_VALUE; } Display(("Min/Max Bit Pool : (%d)/(%d)\n", A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE(sSpecInfoPtr), A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE(sSpecInfoPtr))); } // // MediaCodecSpecificInfoLength is not as expected // else { iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_VERSION; } } } // // Move to the next capability in the list. // uiNumberServiceCapabilities--; psCapab++; } // // Return value to caller. // return(iRetVal); }
//***************************************************************************** // // The following function is used to process the Set Configuration Request. // //*****************************************************************************
The following function is used to process the Set Configuration Request.
[ "The", "following", "function", "is", "used", "to", "process", "the", "Set", "Configuration", "Request", "." ]
static int GAVD_SetConfiguration(unsigned int uiNumberServiceCapabilities, GAVD_Service_Capabilities_Info_t *psCapab) { int iRetVal; unsigned char sValue; unsigned char *sSpecInfoPtr; GAVD_Media_Codec_Info_Element_Data_t *pCodecInfo; iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CODEC_TYPE; while(uiNumberServiceCapabilities && psCapab) { if(psCapab->ServiceCategory == scMediaCodec) { pCodecInfo = &psCapab->InfoElement.GAVD_Media_Codec_Info_Element_Data; if((pCodecInfo->MediaType == mtAudio) && (pCodecInfo->MediaCodecType == A2DP_MEDIA_CODEC_TYPE_SBC)) { if(pCodecInfo->MediaCodecSpecificInfoLength == A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE) { sSpecInfoPtr = pCodecInfo->MediaCodecSpecificInfo; sValue = A2DP_SBC_READ_SAMPLING_FREQUENCY(sSpecInfoPtr); if((sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) || (sValue == A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE)) { Display(("Sampling Frequency: %s\n", (sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) ? "44.1 KHz" : "48KHz")); iRetVal = (sValue == A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE) ? 44100 : 48000; } else { iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SAMPLING_FREQUENCY; } Display(("Channel Mode : \f")); sValue = A2DP_SBC_READ_CHANNEL_MODE(sSpecInfoPtr); switch(sValue) { case A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE: { Display(("Joint Stereo\n")); break; } case A2DP_SBC_CHANNEL_MODE_STEREO_VALUE: { Display(("Stereo\n")); break; } case A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE: { Display(("Dual Channel\n")); break; } default: { Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CHANNEL_MODE; break; } } Display(("Block Length : \f")); sValue = A2DP_SBC_READ_BLOCK_LENGTH(sSpecInfoPtr); switch(sValue) { case A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE: { Display(("4\n")); break; } case A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE: { Display(("8\n")); break; } case A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE: { Display(("12\n")); break; } case A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE: { Display(("16\n")); break; } default: { Display(("Invalid\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_BLOCK_LENGTH; break; } } Display(("Number Sub Bands : \f")); sValue = A2DP_SBC_READ_SUBBANDS(sSpecInfoPtr); switch(sValue) { case A2DP_SBC_SUBBANDS_FOUR_VALUE: { Display(("4\n")); break; } case A2DP_SBC_SUBBANDS_EIGHT_VALUE: { Display(("8\n")); break; } default: { Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SUBBANDS; break; } } sValue = A2DP_SBC_READ_ALLOCATION_METHOD(sSpecInfoPtr); Display(("Allocation Method : \f")); switch(sValue) { case A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE: { Display(("SNR\n")); break; } case A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE: { Display(("Loudness\n")); break; } default: { Display(("Unsupported\n")); iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_ALLOCATION_METHOD; break; } } if(A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE(sSpecInfoPtr) < 0x0A) { iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MINIMUM_BIT_POOL_VALUE; } if(A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE(sSpecInfoPtr) > 0x90) { iRetVal = -A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MAXIMUM_BIT_POOL_VALUE; } Display(("Min/Max Bit Pool : (%d)/(%d)\n", A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE(sSpecInfoPtr), A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE(sSpecInfoPtr))); } else { iRetVal = -A2DP_GAVD_ERROR_CODE_INVALID_VERSION; } } } uiNumberServiceCapabilities--; psCapab++; } return(iRetVal); }
[ "static", "int", "GAVD_SetConfiguration", "(", "unsigned", "int", "uiNumberServiceCapabilities", ",", "GAVD_Service_Capabilities_Info_t", "*", "psCapab", ")", "{", "int", "iRetVal", ";", "unsigned", "char", "sValue", ";", "unsigned", "char", "*", "sSpecInfoPtr", ";", "GAVD_Media_Codec_Info_Element_Data_t", "*", "pCodecInfo", ";", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CODEC_TYPE", ";", "while", "(", "uiNumberServiceCapabilities", "&&", "psCapab", ")", "{", "if", "(", "psCapab", "->", "ServiceCategory", "==", "scMediaCodec", ")", "{", "pCodecInfo", "=", "&", "psCapab", "->", "InfoElement", ".", "GAVD_Media_Codec_Info_Element_Data", ";", "if", "(", "(", "pCodecInfo", "->", "MediaType", "==", "mtAudio", ")", "&&", "(", "pCodecInfo", "->", "MediaCodecType", "==", "A2DP_MEDIA_CODEC_TYPE_SBC", ")", ")", "{", "if", "(", "pCodecInfo", "->", "MediaCodecSpecificInfoLength", "==", "A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE", ")", "{", "sSpecInfoPtr", "=", "pCodecInfo", "->", "MediaCodecSpecificInfo", ";", "sValue", "=", "A2DP_SBC_READ_SAMPLING_FREQUENCY", "(", "sSpecInfoPtr", ")", ";", "if", "(", "(", "sValue", "==", "A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE", ")", "||", "(", "sValue", "==", "A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE", ")", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ",", "(", "sValue", "==", "A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ")", ";", "iRetVal", "=", "(", "sValue", "==", "A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE", ")", "?", "44100", ":", "48000", ";", "}", "else", "{", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SAMPLING_FREQUENCY", ";", "}", "Display", "(", "(", "\"", "\\f", "\"", ")", ")", ";", "sValue", "=", "A2DP_SBC_READ_CHANNEL_MODE", "(", "sSpecInfoPtr", ")", ";", "switch", "(", "sValue", ")", "{", "case", "A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_CHANNEL_MODE_STEREO_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_CHANNEL_MODE", ";", "break", ";", "}", "}", "Display", "(", "(", "\"", "\\f", "\"", ")", ")", ";", "sValue", "=", "A2DP_SBC_READ_BLOCK_LENGTH", "(", "sSpecInfoPtr", ")", ";", "switch", "(", "sValue", ")", "{", "case", "A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_INVALID_BLOCK_LENGTH", ";", "break", ";", "}", "}", "Display", "(", "(", "\"", "\\f", "\"", ")", ")", ";", "sValue", "=", "A2DP_SBC_READ_SUBBANDS", "(", "sSpecInfoPtr", ")", ";", "switch", "(", "sValue", ")", "{", "case", "A2DP_SBC_SUBBANDS_FOUR_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_SUBBANDS_EIGHT_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_SUBBANDS", ";", "break", ";", "}", "}", "sValue", "=", "A2DP_SBC_READ_ALLOCATION_METHOD", "(", "sSpecInfoPtr", ")", ";", "Display", "(", "(", "\"", "\\f", "\"", ")", ")", ";", "switch", "(", "sValue", ")", "{", "case", "A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "case", "A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_INVALID_ALLOCATION_METHOD", ";", "break", ";", "}", "}", "if", "(", "A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE", "(", "sSpecInfoPtr", ")", "<", "0x0A", ")", "{", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MINIMUM_BIT_POOL_VALUE", ";", "}", "if", "(", "A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE", "(", "sSpecInfoPtr", ")", ">", "0x90", ")", "{", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_NOT_SUPPORTED_MAXIMUM_BIT_POOL_VALUE", ";", "}", "Display", "(", "(", "\"", "\\n", "\"", ",", "A2DP_SBC_READ_MINIMUM_BIT_POOL_VALUE", "(", "sSpecInfoPtr", ")", ",", "A2DP_SBC_READ_MAXIMUM_BIT_POOL_VALUE", "(", "sSpecInfoPtr", ")", ")", ")", ";", "}", "else", "{", "iRetVal", "=", "-", "A2DP_GAVD_ERROR_CODE_INVALID_VERSION", ";", "}", "}", "}", "uiNumberServiceCapabilities", "--", ";", "psCapab", "++", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to process the Set Configuration Request.
[ "The", "following", "function", "is", "used", "to", "process", "the", "Set", "Configuration", "Request", "." ]
[ "//\r", "// Initialize the return value.\r", "//\r", "//\r", "// Check for valid parameters passed to this function\r", "//\r", "//\r", "// We need to make sure that the Code is SBC audio and that we support\r", "// the bit rate.\r", "//\r", "//\r", "// Check for expected codec info\r", "//\r", "//\r", "// Get a pointer to the configuration information.\r", "//\r", "//\r", "// Check to see what frequency is being requested.\r", "// *MUST* be 44.1 KHz, or 48 KHz.\r", "//\r", "//\r", "// Display the sampling frequency and return the\r", "// proper Value.\r", "//\r", "//\r", "// Unsupported sample rate requested so return error\r", "//\r", "//\r", "// Read the requested channel modes.\r", "//\r", "//\r", "// Show the value of the channel mode on the debug console\r", "//\r", "//\r", "// This case should not happen, so return an\r", "// error\r", "//\r", "//\r", "// Read the block length.\r", "//\r", "//\r", "// Read the number of SBC subbands.\r", "//\r", "//\r", "// Read the SBC allocation methods.\r", "//\r", "//\r", "// Assign minimum and maximum supported SBC bit pool\r", "// values.\r", "//\r", "//\r", "// MediaCodecSpecificInfoLength is not as expected\r", "//\r", "//\r", "// Move to the next capability in the list.\r", "//\r", "//\r", "// Return value to caller.\r", "//\r" ]
[ { "param": "uiNumberServiceCapabilities", "type": "unsigned int" }, { "param": "psCapab", "type": "GAVD_Service_Capabilities_Info_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uiNumberServiceCapabilities", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "psCapab", "type": "GAVD_Service_Capabilities_Info_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
GAVDRegisterEndPoint
int
static int GAVDRegisterEndPoint(void) { int iRetVal; GAVD_Media_Codec_Info_Element_Data_t *pMediaCodecInfo; // // First check to see if a valid Bluetooth stack ID exists. // if(g_uiBluetoothStackID) { // // Create the capabilities for the end point. // * NOTE * The capabilities that we are creating are for the A2DP // profile. We are hardcoding the media codec information for // demonstration purposes. // g_sCapability[0].ServiceCategory = scMediaTransport; g_sCapability[1].ServiceCategory = scMediaCodec; pMediaCodecInfo = &g_sCapability[1].InfoElement.GAVD_Media_Codec_Info_Element_Data; pMediaCodecInfo->MediaType = mtAudio; pMediaCodecInfo->MediaCodecType = A2DP_MEDIA_CODEC_TYPE_SBC; pMediaCodecInfo->MediaCodecSpecificInfoLength = A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE; pMediaCodecInfo->MediaCodecSpecificInfo = (Byte_t *)&g_sSpecInfo; // // Initialize the SBC codec specific information. // * NOTE * This could also be hardcoded as a simple array of bytes, // but for completeness, it will be shown here. // * NOTE * See A2DP specification for the specific meaning and what // minimum feature set needs to be supported. // * NOTE * See A2DPAPI.h for the definition of these values. // BTPS_MemInitialize(&g_sSpecInfo, 0, A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE); // // Assign supported sampling frequencies - SNK *MUST* support both 44.1 // KHz, and 48 KHz. // A2DP_SBC_ASSIGN_SAMPLING_FREQUENCY(&g_sSpecInfo, (A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE | A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE)); // // Assign supported channel modes. // A2DP_SBC_ASSIGN_CHANNEL_MODE(&g_sSpecInfo, (A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE | A2DP_SBC_CHANNEL_MODE_STEREO_VALUE | A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE)); // // Assign supported SBC block lengths. // A2DP_SBC_ASSIGN_BLOCK_LENGTH(&g_sSpecInfo, (A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE | A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE | A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE | A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE)); // // Assign supported SBC subbands. // A2DP_SBC_ASSIGN_SUBBANDS(&g_sSpecInfo, (A2DP_SBC_SUBBANDS_FOUR_VALUE | A2DP_SBC_SUBBANDS_EIGHT_VALUE)); // // Assign supported SBC allocation methods. // A2DP_SBC_ASSIGN_ALLOCATION_METHOD(&g_sSpecInfo, (A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE | A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE)); // // Assign minimum and maximum supported SBC bit pool values. // A2DP_SBC_ASSIGN_MINIMUM_BIT_POOL_VALUE(&g_sSpecInfo, 0x0A); A2DP_SBC_ASSIGN_MAXIMUM_BIT_POOL_VALUE(&g_sSpecInfo, 0x35); // // Create the end point info structure. // g_sEndPointInfo.NumberCapabilities = 2; g_sEndPointInfo.CapabilitiesInfo = g_sCapability; g_sEndPointInfo.MediaType = mtAudio; g_sEndPointInfo.TSEP = tspSNK; g_sEndPointInfo.MediaInMTU = 1000; // value will fit in a 3-DH5 g_sEndPointInfo.ReportingInMTU = 1000; // value will fit in a 3-DH5 g_sEndPointInfo.RecoveryInMTU = 1000; // value will fit in a 3-DH5 // // Try to register the end point. // iRetVal = GAVD_Register_End_Point(g_uiBluetoothStackID, &g_sEndPointInfo, GAVD_EventCallback, 0); // // Now check to see if the function call was successfully made. // if(iRetVal > 0) { // // Register a SDP service record. // * NOTE * We will simply register an Advanced Audio Distribution // Profile (A2DP) SDP record for demonstration purposes. // First format the service class as an audio sink. // g_sGAVDSDPRecordInfo.NumberServiceClassUUID = 1; g_sGAVDSDPRecordInfo.SDPUUIDEntries = &g_sUUIDEntry; g_sUUIDEntry.SDP_Data_Element_Type = deUUID_16; ASSIGN_UUID_16(g_sUUIDEntry.UUID_Value.UUID_16, 0x11, 0x0B); // // Next flag that there are no additional protocols that need to be // added. // g_sGAVDSDPRecordInfo.ProtocolList = NULL; // // Next add the profile list information to the record. // g_sGAVDSDPRecordInfo.ProfileList = g_psProfileInfo; // // Now we need to actually build the Bluetooth profile descriptor // list which is data element sequence of data element sequences. // g_psProfileInfo[0].SDP_Data_Element_Type = deSequence; g_psProfileInfo[0].SDP_Data_Element_Length = 1; g_psProfileInfo[0].SDP_Data_Element.SDP_Data_Element_Sequence = &(g_psProfileInfo[1]); g_psProfileInfo[1].SDP_Data_Element_Type = deSequence; g_psProfileInfo[1].SDP_Data_Element_Length = 2; g_psProfileInfo[1].SDP_Data_Element.SDP_Data_Element_Sequence = &(g_psProfileInfo[2]); g_psProfileInfo[2].SDP_Data_Element_Type = deUUID_16; g_psProfileInfo[2].SDP_Data_Element_Length = UUID_16_SIZE; ASSIGN_UUID_16(g_psProfileInfo[2].SDP_Data_Element.UUID_16, 0x11, 0x0D); g_psProfileInfo[3].SDP_Data_Element_Type = deUnsignedInteger2Bytes; g_psProfileInfo[3].SDP_Data_Element_Length = WORD_SIZE; g_psProfileInfo[3].SDP_Data_Element.UnsignedInteger2Bytes = 0x0100; // // Now attempt to add the GAVD SDP record to the SDP database. // if(!GAVD_Register_SDP_Record(g_uiBluetoothStackID, &g_sGAVDSDPRecordInfo, "GAVD Audio Sink Sample", &g_ulRecordHandle)) { // // The end point was successfully registered. The return value // of the call is the LSEID and is required for future GAVD // calls to this end point. // Display(("GAVD_Register_End_Point: Function Successful " "(LSEID = 0x%X).\n", iRetVal)); } else { // // Error adding the SDP record to the database, so go ahead // unregister the end point and notify the user. // GAVD_Un_Register_End_Point(g_uiBluetoothStackID, iRetVal); Display(("Unable to register SDP Record. " "Endpoint not registered.\n")); // // Flag an error to the caller. // iRetVal = -1; } } else { // // There was an error attempting to register the end point. // Display(("GAVD_Register_End_Point: Function Failure: %d.\n", iRetVal)); } } else { // // No valid Bluetooth stack ID exists. // Display(("Stack ID Invalid.\n")); iRetVal = -1; } return(iRetVal); }
//***************************************************************************** // // The following function is used to register a GAVD endpoint that can be // connected to by remote devices. // //*****************************************************************************
The following function is used to register a GAVD endpoint that can be connected to by remote devices.
[ "The", "following", "function", "is", "used", "to", "register", "a", "GAVD", "endpoint", "that", "can", "be", "connected", "to", "by", "remote", "devices", "." ]
static int GAVDRegisterEndPoint(void) { int iRetVal; GAVD_Media_Codec_Info_Element_Data_t *pMediaCodecInfo; if(g_uiBluetoothStackID) { g_sCapability[0].ServiceCategory = scMediaTransport; g_sCapability[1].ServiceCategory = scMediaCodec; pMediaCodecInfo = &g_sCapability[1].InfoElement.GAVD_Media_Codec_Info_Element_Data; pMediaCodecInfo->MediaType = mtAudio; pMediaCodecInfo->MediaCodecType = A2DP_MEDIA_CODEC_TYPE_SBC; pMediaCodecInfo->MediaCodecSpecificInfoLength = A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE; pMediaCodecInfo->MediaCodecSpecificInfo = (Byte_t *)&g_sSpecInfo; BTPS_MemInitialize(&g_sSpecInfo, 0, A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE); A2DP_SBC_ASSIGN_SAMPLING_FREQUENCY(&g_sSpecInfo, (A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE | A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE)); A2DP_SBC_ASSIGN_CHANNEL_MODE(&g_sSpecInfo, (A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE | A2DP_SBC_CHANNEL_MODE_STEREO_VALUE | A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE)); A2DP_SBC_ASSIGN_BLOCK_LENGTH(&g_sSpecInfo, (A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE | A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE | A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE | A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE)); A2DP_SBC_ASSIGN_SUBBANDS(&g_sSpecInfo, (A2DP_SBC_SUBBANDS_FOUR_VALUE | A2DP_SBC_SUBBANDS_EIGHT_VALUE)); A2DP_SBC_ASSIGN_ALLOCATION_METHOD(&g_sSpecInfo, (A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE | A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE)); A2DP_SBC_ASSIGN_MINIMUM_BIT_POOL_VALUE(&g_sSpecInfo, 0x0A); A2DP_SBC_ASSIGN_MAXIMUM_BIT_POOL_VALUE(&g_sSpecInfo, 0x35); g_sEndPointInfo.NumberCapabilities = 2; g_sEndPointInfo.CapabilitiesInfo = g_sCapability; g_sEndPointInfo.MediaType = mtAudio; g_sEndPointInfo.TSEP = tspSNK; g_sEndPointInfo.MediaInMTU = 1000; g_sEndPointInfo.ReportingInMTU = 1000; g_sEndPointInfo.RecoveryInMTU = 1000; iRetVal = GAVD_Register_End_Point(g_uiBluetoothStackID, &g_sEndPointInfo, GAVD_EventCallback, 0); if(iRetVal > 0) { g_sGAVDSDPRecordInfo.NumberServiceClassUUID = 1; g_sGAVDSDPRecordInfo.SDPUUIDEntries = &g_sUUIDEntry; g_sUUIDEntry.SDP_Data_Element_Type = deUUID_16; ASSIGN_UUID_16(g_sUUIDEntry.UUID_Value.UUID_16, 0x11, 0x0B); g_sGAVDSDPRecordInfo.ProtocolList = NULL; g_sGAVDSDPRecordInfo.ProfileList = g_psProfileInfo; g_psProfileInfo[0].SDP_Data_Element_Type = deSequence; g_psProfileInfo[0].SDP_Data_Element_Length = 1; g_psProfileInfo[0].SDP_Data_Element.SDP_Data_Element_Sequence = &(g_psProfileInfo[1]); g_psProfileInfo[1].SDP_Data_Element_Type = deSequence; g_psProfileInfo[1].SDP_Data_Element_Length = 2; g_psProfileInfo[1].SDP_Data_Element.SDP_Data_Element_Sequence = &(g_psProfileInfo[2]); g_psProfileInfo[2].SDP_Data_Element_Type = deUUID_16; g_psProfileInfo[2].SDP_Data_Element_Length = UUID_16_SIZE; ASSIGN_UUID_16(g_psProfileInfo[2].SDP_Data_Element.UUID_16, 0x11, 0x0D); g_psProfileInfo[3].SDP_Data_Element_Type = deUnsignedInteger2Bytes; g_psProfileInfo[3].SDP_Data_Element_Length = WORD_SIZE; g_psProfileInfo[3].SDP_Data_Element.UnsignedInteger2Bytes = 0x0100; if(!GAVD_Register_SDP_Record(g_uiBluetoothStackID, &g_sGAVDSDPRecordInfo, "GAVD Audio Sink Sample", &g_ulRecordHandle)) { Display(("GAVD_Register_End_Point: Function Successful " "(LSEID = 0x%X).\n", iRetVal)); } else { GAVD_Un_Register_End_Point(g_uiBluetoothStackID, iRetVal); Display(("Unable to register SDP Record. " "Endpoint not registered.\n")); iRetVal = -1; } } else { Display(("GAVD_Register_End_Point: Function Failure: %d.\n", iRetVal)); } } else { Display(("Stack ID Invalid.\n")); iRetVal = -1; } return(iRetVal); }
[ "static", "int", "GAVDRegisterEndPoint", "(", "void", ")", "{", "int", "iRetVal", ";", "GAVD_Media_Codec_Info_Element_Data_t", "*", "pMediaCodecInfo", ";", "if", "(", "g_uiBluetoothStackID", ")", "{", "g_sCapability", "[", "0", "]", ".", "ServiceCategory", "=", "scMediaTransport", ";", "g_sCapability", "[", "1", "]", ".", "ServiceCategory", "=", "scMediaCodec", ";", "pMediaCodecInfo", "=", "&", "g_sCapability", "[", "1", "]", ".", "InfoElement", ".", "GAVD_Media_Codec_Info_Element_Data", ";", "pMediaCodecInfo", "->", "MediaType", "=", "mtAudio", ";", "pMediaCodecInfo", "->", "MediaCodecType", "=", "A2DP_MEDIA_CODEC_TYPE_SBC", ";", "pMediaCodecInfo", "->", "MediaCodecSpecificInfoLength", "=", "A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE", ";", "pMediaCodecInfo", "->", "MediaCodecSpecificInfo", "=", "(", "Byte_t", "*", ")", "&", "g_sSpecInfo", ";", "BTPS_MemInitialize", "(", "&", "g_sSpecInfo", ",", "0", ",", "A2DP_SBC_CODEC_SPECIFIC_INFORMATION_ELEMENT_SIZE", ")", ";", "A2DP_SBC_ASSIGN_SAMPLING_FREQUENCY", "(", "&", "g_sSpecInfo", ",", "(", "A2DP_SBC_SAMPLING_FREQUENCY_44_1_KHZ_VALUE", "|", "A2DP_SBC_SAMPLING_FREQUENCY_48_KHZ_VALUE", ")", ")", ";", "A2DP_SBC_ASSIGN_CHANNEL_MODE", "(", "&", "g_sSpecInfo", ",", "(", "A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_VALUE", "|", "A2DP_SBC_CHANNEL_MODE_STEREO_VALUE", "|", "A2DP_SBC_CHANNEL_MODE_DUAL_CHANNEL_VALUE", ")", ")", ";", "A2DP_SBC_ASSIGN_BLOCK_LENGTH", "(", "&", "g_sSpecInfo", ",", "(", "A2DP_SBC_BLOCK_LENGTH_FOUR_VALUE", "|", "A2DP_SBC_BLOCK_LENGTH_EIGHT_VALUE", "|", "A2DP_SBC_BLOCK_LENGTH_TWELVE_VALUE", "|", "A2DP_SBC_BLOCK_LENGTH_SIXTEEN_VALUE", ")", ")", ";", "A2DP_SBC_ASSIGN_SUBBANDS", "(", "&", "g_sSpecInfo", ",", "(", "A2DP_SBC_SUBBANDS_FOUR_VALUE", "|", "A2DP_SBC_SUBBANDS_EIGHT_VALUE", ")", ")", ";", "A2DP_SBC_ASSIGN_ALLOCATION_METHOD", "(", "&", "g_sSpecInfo", ",", "(", "A2DP_SBC_ALLOCATION_METHOD_SNR_VALUE", "|", "A2DP_SBC_ALLOCATION_METHOD_LOUDNESS_VALUE", ")", ")", ";", "A2DP_SBC_ASSIGN_MINIMUM_BIT_POOL_VALUE", "(", "&", "g_sSpecInfo", ",", "0x0A", ")", ";", "A2DP_SBC_ASSIGN_MAXIMUM_BIT_POOL_VALUE", "(", "&", "g_sSpecInfo", ",", "0x35", ")", ";", "g_sEndPointInfo", ".", "NumberCapabilities", "=", "2", ";", "g_sEndPointInfo", ".", "CapabilitiesInfo", "=", "g_sCapability", ";", "g_sEndPointInfo", ".", "MediaType", "=", "mtAudio", ";", "g_sEndPointInfo", ".", "TSEP", "=", "tspSNK", ";", "g_sEndPointInfo", ".", "MediaInMTU", "=", "1000", ";", "g_sEndPointInfo", ".", "ReportingInMTU", "=", "1000", ";", "g_sEndPointInfo", ".", "RecoveryInMTU", "=", "1000", ";", "iRetVal", "=", "GAVD_Register_End_Point", "(", "g_uiBluetoothStackID", ",", "&", "g_sEndPointInfo", ",", "GAVD_EventCallback", ",", "0", ")", ";", "if", "(", "iRetVal", ">", "0", ")", "{", "g_sGAVDSDPRecordInfo", ".", "NumberServiceClassUUID", "=", "1", ";", "g_sGAVDSDPRecordInfo", ".", "SDPUUIDEntries", "=", "&", "g_sUUIDEntry", ";", "g_sUUIDEntry", ".", "SDP_Data_Element_Type", "=", "deUUID_16", ";", "ASSIGN_UUID_16", "(", "g_sUUIDEntry", ".", "UUID_Value", ".", "UUID_16", ",", "0x11", ",", "0x0B", ")", ";", "g_sGAVDSDPRecordInfo", ".", "ProtocolList", "=", "NULL", ";", "g_sGAVDSDPRecordInfo", ".", "ProfileList", "=", "g_psProfileInfo", ";", "g_psProfileInfo", "[", "0", "]", ".", "SDP_Data_Element_Type", "=", "deSequence", ";", "g_psProfileInfo", "[", "0", "]", ".", "SDP_Data_Element_Length", "=", "1", ";", "g_psProfileInfo", "[", "0", "]", ".", "SDP_Data_Element", ".", "SDP_Data_Element_Sequence", "=", "&", "(", "g_psProfileInfo", "[", "1", "]", ")", ";", "g_psProfileInfo", "[", "1", "]", ".", "SDP_Data_Element_Type", "=", "deSequence", ";", "g_psProfileInfo", "[", "1", "]", ".", "SDP_Data_Element_Length", "=", "2", ";", "g_psProfileInfo", "[", "1", "]", ".", "SDP_Data_Element", ".", "SDP_Data_Element_Sequence", "=", "&", "(", "g_psProfileInfo", "[", "2", "]", ")", ";", "g_psProfileInfo", "[", "2", "]", ".", "SDP_Data_Element_Type", "=", "deUUID_16", ";", "g_psProfileInfo", "[", "2", "]", ".", "SDP_Data_Element_Length", "=", "UUID_16_SIZE", ";", "ASSIGN_UUID_16", "(", "g_psProfileInfo", "[", "2", "]", ".", "SDP_Data_Element", ".", "UUID_16", ",", "0x11", ",", "0x0D", ")", ";", "g_psProfileInfo", "[", "3", "]", ".", "SDP_Data_Element_Type", "=", "deUnsignedInteger2Bytes", ";", "g_psProfileInfo", "[", "3", "]", ".", "SDP_Data_Element_Length", "=", "WORD_SIZE", ";", "g_psProfileInfo", "[", "3", "]", ".", "SDP_Data_Element", ".", "UnsignedInteger2Bytes", "=", "0x0100", ";", "if", "(", "!", "GAVD_Register_SDP_Record", "(", "g_uiBluetoothStackID", ",", "&", "g_sGAVDSDPRecordInfo", ",", "\"", "\"", ",", "&", "g_ulRecordHandle", ")", ")", "{", "Display", "(", "(", "\"", "\"", "\"", "\\n", "\"", ",", "iRetVal", ")", ")", ";", "}", "else", "{", "GAVD_Un_Register_End_Point", "(", "g_uiBluetoothStackID", ",", "iRetVal", ")", ";", "Display", "(", "(", "\"", "\"", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-1", ";", "}", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ",", "iRetVal", ")", ")", ";", "}", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-1", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to register a GAVD endpoint that can be connected to by remote devices.
[ "The", "following", "function", "is", "used", "to", "register", "a", "GAVD", "endpoint", "that", "can", "be", "connected", "to", "by", "remote", "devices", "." ]
[ "//\r", "// First check to see if a valid Bluetooth stack ID exists.\r", "//\r", "//\r", "// Create the capabilities for the end point.\r", "// * NOTE * The capabilities that we are creating are for the A2DP\r", "// profile. We are hardcoding the media codec information for\r", "// demonstration purposes.\r", "//\r", "//\r", "// Initialize the SBC codec specific information.\r", "// * NOTE * This could also be hardcoded as a simple array of bytes,\r", "// but for completeness, it will be shown here.\r", "// * NOTE * See A2DP specification for the specific meaning and what\r", "// minimum feature set needs to be supported.\r", "// * NOTE * See A2DPAPI.h for the definition of these values.\r", "//\r", "//\r", "// Assign supported sampling frequencies - SNK *MUST* support both 44.1\r", "// KHz, and 48 KHz.\r", "//\r", "//\r", "// Assign supported channel modes.\r", "//\r", "//\r", "// Assign supported SBC block lengths.\r", "//\r", "//\r", "// Assign supported SBC subbands.\r", "//\r", "//\r", "// Assign supported SBC allocation methods.\r", "//\r", "//\r", "// Assign minimum and maximum supported SBC bit pool values.\r", "//\r", "//\r", "// Create the end point info structure.\r", "//\r", "// value will fit in a 3-DH5\r", "// value will fit in a 3-DH5\r", "// value will fit in a 3-DH5\r", "//\r", "// Try to register the end point.\r", "//\r", "//\r", "// Now check to see if the function call was successfully made.\r", "//\r", "//\r", "// Register a SDP service record.\r", "// * NOTE * We will simply register an Advanced Audio Distribution\r", "// Profile (A2DP) SDP record for demonstration purposes.\r", "// First format the service class as an audio sink.\r", "//\r", "//\r", "// Next flag that there are no additional protocols that need to be\r", "// added.\r", "//\r", "//\r", "// Next add the profile list information to the record.\r", "//\r", "//\r", "// Now we need to actually build the Bluetooth profile descriptor\r", "// list which is data element sequence of data element sequences.\r", "//\r", "//\r", "// Now attempt to add the GAVD SDP record to the SDP database.\r", "//\r", "//\r", "// The end point was successfully registered. The return value\r", "// of the call is the LSEID and is required for future GAVD\r", "// calls to this end point.\r", "//\r", "//\r", "// Error adding the SDP record to the database, so go ahead\r", "// unregister the end point and notify the user.\r", "//\r", "//\r", "// Flag an error to the caller.\r", "//\r", "//\r", "// There was an error attempting to register the end point.\r", "//\r", "//\r", "// No valid Bluetooth stack ID exists.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
RegisterAVRCPController
int
static int RegisterAVRCPController(void) { int iRetVal; UUID_16_t ProfileUUID; // // First check to see if a valid Bluetooth stack ID exists. // if(g_uiBluetoothStackID) { // // Attempt to register the Audio/Video Remote Control profile (AVRCP) // with AVCTP. // SDP_ASSIGN_AUDIO_VIDEO_REMOTE_CONTROL_PROFILE_UUID_16(ProfileUUID); iRetVal = AVCTP_Register_Profile(g_uiBluetoothStackID, ProfileUUID, AVCTP_EventCallback, 0); if(iRetVal > 0) { g_uiAVCTPProfileID = (unsigned int)iRetVal; // // Finally, attempt to register an AVRCP controller service // record. // iRetVal = AVRCP_Register_SDP_Record_Version(g_uiBluetoothStackID, TRUE, "AVRCP Controller", "TI/Stonestreet One", (Word_t)SDP_AVRCP_SUPPORTED_FEATURES_CONTROLLER_CATEGORY_1, apvVersion1_0, &g_ulAVCTPRecordHandle); if(!iRetVal) { Display(("AVRCP Controller Registered.\n")); // // Initialize the transaction ID. // g_ucTransactionID = 0; } else { // // Unable to register profile with AVCTP. // Display(("Unable to register AVRCP profile SDP Record.\n")); // // Un-Register the profile that was registered with AVCTP. // AVCTP_UnRegister_Profile(g_uiBluetoothStackID, g_uiAVCTPProfileID); iRetVal = -3; } } else { // // Unable to register profile with AVCTP. // Display(("Unable to register AVRCP profile with AVCTP.\n")); iRetVal = -2; } } else { // // No valid Bluetooth stack ID exists. // Display(("Stack ID Invalid.\n")); iRetVal = -1; } return(iRetVal); }
//***************************************************************************** // // The following function is used to register an AVRCP remote control // controller with AVCTP that can be connected to by remote devices. // //*****************************************************************************
The following function is used to register an AVRCP remote control controller with AVCTP that can be connected to by remote devices.
[ "The", "following", "function", "is", "used", "to", "register", "an", "AVRCP", "remote", "control", "controller", "with", "AVCTP", "that", "can", "be", "connected", "to", "by", "remote", "devices", "." ]
static int RegisterAVRCPController(void) { int iRetVal; UUID_16_t ProfileUUID; if(g_uiBluetoothStackID) { SDP_ASSIGN_AUDIO_VIDEO_REMOTE_CONTROL_PROFILE_UUID_16(ProfileUUID); iRetVal = AVCTP_Register_Profile(g_uiBluetoothStackID, ProfileUUID, AVCTP_EventCallback, 0); if(iRetVal > 0) { g_uiAVCTPProfileID = (unsigned int)iRetVal; iRetVal = AVRCP_Register_SDP_Record_Version(g_uiBluetoothStackID, TRUE, "AVRCP Controller", "TI/Stonestreet One", (Word_t)SDP_AVRCP_SUPPORTED_FEATURES_CONTROLLER_CATEGORY_1, apvVersion1_0, &g_ulAVCTPRecordHandle); if(!iRetVal) { Display(("AVRCP Controller Registered.\n")); g_ucTransactionID = 0; } else { Display(("Unable to register AVRCP profile SDP Record.\n")); AVCTP_UnRegister_Profile(g_uiBluetoothStackID, g_uiAVCTPProfileID); iRetVal = -3; } } else { Display(("Unable to register AVRCP profile with AVCTP.\n")); iRetVal = -2; } } else { Display(("Stack ID Invalid.\n")); iRetVal = -1; } return(iRetVal); }
[ "static", "int", "RegisterAVRCPController", "(", "void", ")", "{", "int", "iRetVal", ";", "UUID_16_t", "ProfileUUID", ";", "if", "(", "g_uiBluetoothStackID", ")", "{", "SDP_ASSIGN_AUDIO_VIDEO_REMOTE_CONTROL_PROFILE_UUID_16", "(", "ProfileUUID", ")", ";", "iRetVal", "=", "AVCTP_Register_Profile", "(", "g_uiBluetoothStackID", ",", "ProfileUUID", ",", "AVCTP_EventCallback", ",", "0", ")", ";", "if", "(", "iRetVal", ">", "0", ")", "{", "g_uiAVCTPProfileID", "=", "(", "unsigned", "int", ")", "iRetVal", ";", "iRetVal", "=", "AVRCP_Register_SDP_Record_Version", "(", "g_uiBluetoothStackID", ",", "TRUE", ",", "\"", "\"", ",", "\"", "\"", ",", "(", "Word_t", ")", "SDP_AVRCP_SUPPORTED_FEATURES_CONTROLLER_CATEGORY_1", ",", "apvVersion1_0", ",", "&", "g_ulAVCTPRecordHandle", ")", ";", "if", "(", "!", "iRetVal", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "g_ucTransactionID", "=", "0", ";", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "AVCTP_UnRegister_Profile", "(", "g_uiBluetoothStackID", ",", "g_uiAVCTPProfileID", ")", ";", "iRetVal", "=", "-3", ";", "}", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-2", ";", "}", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "iRetVal", "=", "-1", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is used to register an AVRCP remote control controller with AVCTP that can be connected to by remote devices.
[ "The", "following", "function", "is", "used", "to", "register", "an", "AVRCP", "remote", "control", "controller", "with", "AVCTP", "that", "can", "be", "connected", "to", "by", "remote", "devices", "." ]
[ "//\r", "// First check to see if a valid Bluetooth stack ID exists.\r", "//\r", "//\r", "// Attempt to register the Audio/Video Remote Control profile (AVRCP)\r", "// with AVCTP.\r", "//\r", "//\r", "// Finally, attempt to register an AVRCP controller service\r", "// record.\r", "//\r", "//\r", "// Initialize the transaction ID.\r", "//\r", "//\r", "// Unable to register profile with AVCTP.\r", "//\r", "//\r", "// Un-Register the profile that was registered with AVCTP.\r", "//\r", "//\r", "// Unable to register profile with AVCTP.\r", "//\r", "//\r", "// No valid Bluetooth stack ID exists.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
SendRemoteControlCommand
int
int SendRemoteControlCommand(tRemoteControlCommand sCommand) { int iRetVal; Byte_t Buffer[16]; AVRCP_Pass_Through_Command_Data_t PassThroughCommandData; // // Verify that the module is initialized correctly. // if(g_uiBluetoothStackID && g_uiAVCTPProfileID) { iRetVal = 0; // // Initialize common members of the pass through command. // * NOTE * State flag of FALSE specifies button down. // PassThroughCommandData.CommandType = AVRCP_CTYPE_CONTROL; PassThroughCommandData.SubunitType = AVRCP_SUBUNIT_TYPE_PANEL; PassThroughCommandData.SubunitID = AVRCP_SUBUNIT_ID_INSTANCE_0; PassThroughCommandData.OperationID = (Byte_t)0; PassThroughCommandData.StateFlag = (Boolean_t)FALSE; PassThroughCommandData.OperationDataLength = 0; PassThroughCommandData.OperationData = NULL; // // Determine the command and go ahead and build it. // switch(sCommand) { case rcPlay: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_PLAY; break; } case rcPause: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_PAUSE; break; } case rcNext: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_FORWARD; break; } case rcBack: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_BACKWARD; break; } case rcVolumeUp: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_VOLUME_UP; break; } case rcVolumeDown: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_VOLUME_DOWN; break; } default: { iRetVal = -2; break; } } // // Proceed only if the AVRCP command is supported. // if(!iRetVal) { // // Everything parsed correct, go ahead and try to build the // command. // iRetVal = AVRCP_Format_Pass_Through_Command(g_uiBluetoothStackID, &PassThroughCommandData, sizeof(Buffer), Buffer); if(iRetVal > 0) { // // Command built, attempt to send it. // iRetVal = AVCTP_Send_Message(g_uiBluetoothStackID, g_uiAVCTPProfileID, g_sConnectedAudioDevice, (Byte_t)((g_ucTransactionID++) & AVCTP_TRANSACTION_ID_MASK), FALSE, iRetVal, Buffer); // // If the command was sent, send the button release. // if(!iRetVal) { PassThroughCommandData.StateFlag = (Boolean_t)TRUE; iRetVal = AVRCP_Format_Pass_Through_Command( g_uiBluetoothStackID, &PassThroughCommandData, sizeof(Buffer), Buffer); if(iRetVal > 0) { // // Command built, attempt to send it. // iRetVal = AVCTP_Send_Message( g_uiBluetoothStackID, g_uiAVCTPProfileID, g_sConnectedAudioDevice, (Byte_t)((g_ucTransactionID++) & AVCTP_TRANSACTION_ID_MASK), FALSE, iRetVal, Buffer); } } } } } else { iRetVal = -1; } return(iRetVal); }
//***************************************************************************** // // The following function provides a means to send the specified remote // control command to the remote device. This function accepts the // remote control command to send. This function will return zero on // success and a negative number on failure. // //*****************************************************************************
The following function provides a means to send the specified remote control command to the remote device. This function accepts the remote control command to send. This function will return zero on success and a negative number on failure.
[ "The", "following", "function", "provides", "a", "means", "to", "send", "the", "specified", "remote", "control", "command", "to", "the", "remote", "device", ".", "This", "function", "accepts", "the", "remote", "control", "command", "to", "send", ".", "This", "function", "will", "return", "zero", "on", "success", "and", "a", "negative", "number", "on", "failure", "." ]
int SendRemoteControlCommand(tRemoteControlCommand sCommand) { int iRetVal; Byte_t Buffer[16]; AVRCP_Pass_Through_Command_Data_t PassThroughCommandData; if(g_uiBluetoothStackID && g_uiAVCTPProfileID) { iRetVal = 0; PassThroughCommandData.CommandType = AVRCP_CTYPE_CONTROL; PassThroughCommandData.SubunitType = AVRCP_SUBUNIT_TYPE_PANEL; PassThroughCommandData.SubunitID = AVRCP_SUBUNIT_ID_INSTANCE_0; PassThroughCommandData.OperationID = (Byte_t)0; PassThroughCommandData.StateFlag = (Boolean_t)FALSE; PassThroughCommandData.OperationDataLength = 0; PassThroughCommandData.OperationData = NULL; switch(sCommand) { case rcPlay: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_PLAY; break; } case rcPause: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_PAUSE; break; } case rcNext: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_FORWARD; break; } case rcBack: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_BACKWARD; break; } case rcVolumeUp: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_VOLUME_UP; break; } case rcVolumeDown: { PassThroughCommandData.OperationID = (Byte_t)AVRCP_PASS_THROUGH_ID_VOLUME_DOWN; break; } default: { iRetVal = -2; break; } } if(!iRetVal) { iRetVal = AVRCP_Format_Pass_Through_Command(g_uiBluetoothStackID, &PassThroughCommandData, sizeof(Buffer), Buffer); if(iRetVal > 0) { iRetVal = AVCTP_Send_Message(g_uiBluetoothStackID, g_uiAVCTPProfileID, g_sConnectedAudioDevice, (Byte_t)((g_ucTransactionID++) & AVCTP_TRANSACTION_ID_MASK), FALSE, iRetVal, Buffer); if(!iRetVal) { PassThroughCommandData.StateFlag = (Boolean_t)TRUE; iRetVal = AVRCP_Format_Pass_Through_Command( g_uiBluetoothStackID, &PassThroughCommandData, sizeof(Buffer), Buffer); if(iRetVal > 0) { iRetVal = AVCTP_Send_Message( g_uiBluetoothStackID, g_uiAVCTPProfileID, g_sConnectedAudioDevice, (Byte_t)((g_ucTransactionID++) & AVCTP_TRANSACTION_ID_MASK), FALSE, iRetVal, Buffer); } } } } } else { iRetVal = -1; } return(iRetVal); }
[ "int", "SendRemoteControlCommand", "(", "tRemoteControlCommand", "sCommand", ")", "{", "int", "iRetVal", ";", "Byte_t", "Buffer", "[", "16", "]", ";", "AVRCP_Pass_Through_Command_Data_t", "PassThroughCommandData", ";", "if", "(", "g_uiBluetoothStackID", "&&", "g_uiAVCTPProfileID", ")", "{", "iRetVal", "=", "0", ";", "PassThroughCommandData", ".", "CommandType", "=", "AVRCP_CTYPE_CONTROL", ";", "PassThroughCommandData", ".", "SubunitType", "=", "AVRCP_SUBUNIT_TYPE_PANEL", ";", "PassThroughCommandData", ".", "SubunitID", "=", "AVRCP_SUBUNIT_ID_INSTANCE_0", ";", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "0", ";", "PassThroughCommandData", ".", "StateFlag", "=", "(", "Boolean_t", ")", "FALSE", ";", "PassThroughCommandData", ".", "OperationDataLength", "=", "0", ";", "PassThroughCommandData", ".", "OperationData", "=", "NULL", ";", "switch", "(", "sCommand", ")", "{", "case", "rcPlay", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_PLAY", ";", "break", ";", "}", "case", "rcPause", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_PAUSE", ";", "break", ";", "}", "case", "rcNext", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_FORWARD", ";", "break", ";", "}", "case", "rcBack", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_BACKWARD", ";", "break", ";", "}", "case", "rcVolumeUp", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_VOLUME_UP", ";", "break", ";", "}", "case", "rcVolumeDown", ":", "{", "PassThroughCommandData", ".", "OperationID", "=", "(", "Byte_t", ")", "AVRCP_PASS_THROUGH_ID_VOLUME_DOWN", ";", "break", ";", "}", "default", ":", "{", "iRetVal", "=", "-2", ";", "break", ";", "}", "}", "if", "(", "!", "iRetVal", ")", "{", "iRetVal", "=", "AVRCP_Format_Pass_Through_Command", "(", "g_uiBluetoothStackID", ",", "&", "PassThroughCommandData", ",", "sizeof", "(", "Buffer", ")", ",", "Buffer", ")", ";", "if", "(", "iRetVal", ">", "0", ")", "{", "iRetVal", "=", "AVCTP_Send_Message", "(", "g_uiBluetoothStackID", ",", "g_uiAVCTPProfileID", ",", "g_sConnectedAudioDevice", ",", "(", "Byte_t", ")", "(", "(", "g_ucTransactionID", "++", ")", "&", "AVCTP_TRANSACTION_ID_MASK", ")", ",", "FALSE", ",", "iRetVal", ",", "Buffer", ")", ";", "if", "(", "!", "iRetVal", ")", "{", "PassThroughCommandData", ".", "StateFlag", "=", "(", "Boolean_t", ")", "TRUE", ";", "iRetVal", "=", "AVRCP_Format_Pass_Through_Command", "(", "g_uiBluetoothStackID", ",", "&", "PassThroughCommandData", ",", "sizeof", "(", "Buffer", ")", ",", "Buffer", ")", ";", "if", "(", "iRetVal", ">", "0", ")", "{", "iRetVal", "=", "AVCTP_Send_Message", "(", "g_uiBluetoothStackID", ",", "g_uiAVCTPProfileID", ",", "g_sConnectedAudioDevice", ",", "(", "Byte_t", ")", "(", "(", "g_ucTransactionID", "++", ")", "&", "AVCTP_TRANSACTION_ID_MASK", ")", ",", "FALSE", ",", "iRetVal", ",", "Buffer", ")", ";", "}", "}", "}", "}", "}", "else", "{", "iRetVal", "=", "-1", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function provides a means to send the specified remote control command to the remote device.
[ "The", "following", "function", "provides", "a", "means", "to", "send", "the", "specified", "remote", "control", "command", "to", "the", "remote", "device", "." ]
[ "//\r", "// Verify that the module is initialized correctly.\r", "//\r", "//\r", "// Initialize common members of the pass through command.\r", "// * NOTE * State flag of FALSE specifies button down.\r", "//\r", "//\r", "// Determine the command and go ahead and build it.\r", "//\r", "//\r", "// Proceed only if the AVRCP command is supported.\r", "//\r", "//\r", "// Everything parsed correct, go ahead and try to build the\r", "// command.\r", "//\r", "//\r", "// Command built, attempt to send it.\r", "//\r", "//\r", "// If the command was sent, send the button release.\r", "//\r", "//\r", "// Command built, attempt to send it.\r", "//\r" ]
[ { "param": "sCommand", "type": "tRemoteControlCommand" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sCommand", "type": "tRemoteControlCommand", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c2341bd3b0541082446fcce19fd1022a1e02791
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bluetooth.c
[ "BSD-3-Clause" ]
C
InitializeBluetooth
int
int InitializeBluetooth(tBluetoothCallbackFn pfnCallbackFunction, void *pvCallbackParameter, BTPS_Initialization_t *pBTPSInitialization) { int iRetVal; int iCount; Byte_t sStatus; BD_ADDR_t sBD_ADDR; HCI_Version_t sHCIVersion; ThreadHandle_t sSBCDecodeThread; HCI_DriverInformation_t sDriverInformation; L2CA_Link_Connect_Params_t sConnectParams; Extended_Inquiry_Response_Data_t *psEIRData; // // Verify that the parameters passed in appear valid. // if(pfnCallbackFunction && pBTPSInitialization) { // // Initialize the OS abstraction layer. // BTPS_Init((void *)pBTPSInitialization); // // Configure the UART parameters and initialize the Bluetooth stack. // HCI_DRIVER_SET_COMM_INFORMATION(&sDriverInformation, 1, 115200, cpUART); // // Set the Bluetooth serial port startup delay. This is the amount of // time in ms to wait before starting to use the serial port after // initialization. // sDriverInformation.DriverInformation.COMMDriverInformation. InitializationDelay = 150; // // Initialize the Bluetooth stack. // iRetVal = BSC_Initialize(&sDriverInformation, 0); Display(("Bluetooth Stack ID %d\n", iRetVal)); if(iRetVal > 0) { // // Save the Bluetooth stack ID. // g_uiBluetoothStackID = (unsigned int)iRetVal; g_pfnCallbackFunction = pfnCallbackFunction; g_pvCallbackParameter = pvCallbackParameter; // // Read and display the Bluetooth version. // HCI_Version_Supported(g_uiBluetoothStackID, &sHCIVersion); g_sDeviceInfo.ucHCIVersion = (unsigned char)sHCIVersion; // // Read the local Bluetooth device address. // GAP_Query_Local_BD_ADDR(g_uiBluetoothStackID, &sBD_ADDR); BD_ADDR_To_Array(sBD_ADDR, g_sDeviceInfo.ucBDAddr); // // Go ahead and allow master/slave role switch. // sConnectParams.L2CA_Link_Connect_Request_Config = cqAllowRoleSwitch; sConnectParams.L2CA_Link_Connect_Response_Config = csMaintainCurrentRole; L2CA_Set_Link_Connection_Configuration(g_uiBluetoothStackID, &sConnectParams); // // Update the default link policy if supported. // if(HCI_Command_Supported(g_uiBluetoothStackID, HCI_SUPPORTED_COMMAND_WRITE_DEFAULT_LINK_POLICY_BIT_NUMBER) > 0) { HCI_Write_Default_Link_Policy_Settings(g_uiBluetoothStackID, HCI_LINK_POLICY_SETTINGS_ENABLE_MASTER_SLAVE_SWITCH, &sStatus); } // // In order to allow bonding we are making all devices: // discoverable, connectable, and [airable. We are also // registering an authentication callback. Pairing is not required // to use this application however some devices require it. // GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmNonConnectableMode); GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmNonDiscoverableMode, 0); GAP_Set_Pairability_Mode(g_uiBluetoothStackID, pmPairableMode); // // Set the current state in the device info structure. // g_sDeviceInfo.sMode = PAIRABLE_NON_SSP_MODE; // // Register callback to handle remote authentication requests. // if(GAP_Register_Remote_Authentication(g_uiBluetoothStackID, GAP_EventCallback, 0)) { Display(("Error Registering Remote Authentication\n")); } // // Set our local name. // BTPS_SprintF(g_sDeviceInfo.cDeviceName, DEFAULT_DEVICE_NAME); GAP_Set_Local_Device_Name(g_uiBluetoothStackID, g_sDeviceInfo.cDeviceName); // // Allocate space to store temporarily the extended response data // psEIRData = (Extended_Inquiry_Response_Data_t *) BTPS_AllocateMemory(sizeof(Extended_Inquiry_Response_Data_t)); if(psEIRData) { // // Zero out the allocated space // BTPS_MemInitialize(psEIRData->Extended_Inquiry_Response_Data, 0, sizeof(Extended_Inquiry_Response_Data_t)); // // Initialize the Extended Inquiry Data with predefined data // BTPS_MemCopy(psEIRData->Extended_Inquiry_Response_Data, g_ucEIR, sizeof(g_ucEIR)); // // Write the Extended Inquiry Data to the controller. This // will be used to respond to an Extended Inquiry request // iRetVal = GAP_Write_Extended_Inquiry_Information( g_uiBluetoothStackID, HCI_EXTENDED_INQUIRY_RESPONSE_FEC_REQUIRED, psEIRData); if(iRetVal) { Display(("Failed to set Extended Inquiry Data: %d", iRetVal)); } // // Free the temporary storage // BTPS_FreeMemory(psEIRData); } // // Set the class of device // ASSIGN_CLASS_OF_DEVICE(g_sClassOfDevice, (Byte_t)0x24, (Byte_t)0x04, (Byte_t)0x04); GAP_Set_Class_Of_Device(g_uiBluetoothStackID, g_sClassOfDevice); if(GAVD_Initialize(g_uiBluetoothStackID)) { Display(("GAVD failed to Initialize\n")); } else { Display(("GAVD Initialized\n")); } // // Register an end point. // GAVDRegisterEndPoint(); // // Initialize the SBC decoder. // g_sDecoderHandle = SBC_Initialize_Decoder(); // // Initialize AVCTP (required for AVRCP). // if(AVCTP_Initialize(g_uiBluetoothStackID)) { Display(("AVCP failed to Initialize\n")); } else { Display(("AVCTP Initialized\n")); } // // Register remote control controller // RegisterAVRCPController(); // // Read the stored link key information from flash. // ReadFlash((NUM_SUPPORTED_LINK_KEYS * sizeof(tLinkKeyInfo)), (unsigned char *)&g_sLinkKeyInfo); // // Count the number of link keys that are stored. // iCount = 0; for(iRetVal = 0; iRetVal < NUM_SUPPORTED_LINK_KEYS; iRetVal++) { if(!g_sLinkKeyInfo[iRetVal].bEmpty) { iCount++; } } Display(("%d Link Keys Stored\r\n", iCount)); DAC32SoundInit(); // // Set the audio state to idle. // g_sAudioState = asIdle; // // First create an event to signal when the task should process // new SBC data. // if((g_sSBCDecodeEvent = BTPS_CreateEvent(FALSE)) != NULL) { // // Add a task that that will manage decoding the SBC data and // supplying the audio data buffer to the DAC. // g_bExit = FALSE; sSBCDecodeThread = BTPS_CreateThread(SBCDecodeThread, SBC_DECODE_STACK_SIZE, NULL); if(sSBCDecodeThread != NULL) { // // Everything initialized, go ahead and flag success // to the caller. // iRetVal = 0; } else { // // Unable to create the SBC decode thread, so go ahead and // free the event that we allocated and flag an error. // BTPS_CloseEvent(g_sSBCDecodeEvent); iRetVal = BTH_ERROR_RESOURCE_FAILURE; } } else { iRetVal = BTH_ERROR_RESOURCE_FAILURE; } } else { iRetVal = BTH_ERROR_REQUEST_FAILURE; } } // // Error initializing Bluetooth stack, set error return code // else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
//***************************************************************************** // // The following function is responsible for initializing the Bluetooth stack // as well as the A2DP server. The function takes as its parameters a pointer // to a callback function that is to called when Bluetooth events occur. The // second parameter is an application defined value that will be passed when // the callback function is called. The final parameter is MANDATORY and // specifies (at a minimum) the function callback that will be called by the // Bluetooth sub-system when the Bluetooth sub-system requires the optional // function that is called by the Bluetooth module whenever there is a // character of debug output data to be output. The function returns zero on // success and a negative value if an error occurs. // //*****************************************************************************
The following function is responsible for initializing the Bluetooth stack as well as the A2DP server. The function takes as its parameters a pointer to a callback function that is to called when Bluetooth events occur. The second parameter is an application defined value that will be passed when the callback function is called. The final parameter is MANDATORY and specifies (at a minimum) the function callback that will be called by the Bluetooth sub-system when the Bluetooth sub-system requires the optional function that is called by the Bluetooth module whenever there is a character of debug output data to be output. The function returns zero on success and a negative value if an error occurs.
[ "The", "following", "function", "is", "responsible", "for", "initializing", "the", "Bluetooth", "stack", "as", "well", "as", "the", "A2DP", "server", ".", "The", "function", "takes", "as", "its", "parameters", "a", "pointer", "to", "a", "callback", "function", "that", "is", "to", "called", "when", "Bluetooth", "events", "occur", ".", "The", "second", "parameter", "is", "an", "application", "defined", "value", "that", "will", "be", "passed", "when", "the", "callback", "function", "is", "called", ".", "The", "final", "parameter", "is", "MANDATORY", "and", "specifies", "(", "at", "a", "minimum", ")", "the", "function", "callback", "that", "will", "be", "called", "by", "the", "Bluetooth", "sub", "-", "system", "when", "the", "Bluetooth", "sub", "-", "system", "requires", "the", "optional", "function", "that", "is", "called", "by", "the", "Bluetooth", "module", "whenever", "there", "is", "a", "character", "of", "debug", "output", "data", "to", "be", "output", ".", "The", "function", "returns", "zero", "on", "success", "and", "a", "negative", "value", "if", "an", "error", "occurs", "." ]
int InitializeBluetooth(tBluetoothCallbackFn pfnCallbackFunction, void *pvCallbackParameter, BTPS_Initialization_t *pBTPSInitialization) { int iRetVal; int iCount; Byte_t sStatus; BD_ADDR_t sBD_ADDR; HCI_Version_t sHCIVersion; ThreadHandle_t sSBCDecodeThread; HCI_DriverInformation_t sDriverInformation; L2CA_Link_Connect_Params_t sConnectParams; Extended_Inquiry_Response_Data_t *psEIRData; if(pfnCallbackFunction && pBTPSInitialization) { BTPS_Init((void *)pBTPSInitialization); HCI_DRIVER_SET_COMM_INFORMATION(&sDriverInformation, 1, 115200, cpUART); sDriverInformation.DriverInformation.COMMDriverInformation. InitializationDelay = 150; iRetVal = BSC_Initialize(&sDriverInformation, 0); Display(("Bluetooth Stack ID %d\n", iRetVal)); if(iRetVal > 0) { g_uiBluetoothStackID = (unsigned int)iRetVal; g_pfnCallbackFunction = pfnCallbackFunction; g_pvCallbackParameter = pvCallbackParameter; HCI_Version_Supported(g_uiBluetoothStackID, &sHCIVersion); g_sDeviceInfo.ucHCIVersion = (unsigned char)sHCIVersion; GAP_Query_Local_BD_ADDR(g_uiBluetoothStackID, &sBD_ADDR); BD_ADDR_To_Array(sBD_ADDR, g_sDeviceInfo.ucBDAddr); sConnectParams.L2CA_Link_Connect_Request_Config = cqAllowRoleSwitch; sConnectParams.L2CA_Link_Connect_Response_Config = csMaintainCurrentRole; L2CA_Set_Link_Connection_Configuration(g_uiBluetoothStackID, &sConnectParams); if(HCI_Command_Supported(g_uiBluetoothStackID, HCI_SUPPORTED_COMMAND_WRITE_DEFAULT_LINK_POLICY_BIT_NUMBER) > 0) { HCI_Write_Default_Link_Policy_Settings(g_uiBluetoothStackID, HCI_LINK_POLICY_SETTINGS_ENABLE_MASTER_SLAVE_SWITCH, &sStatus); } GAP_Set_Connectability_Mode(g_uiBluetoothStackID, cmNonConnectableMode); GAP_Set_Discoverability_Mode(g_uiBluetoothStackID, dmNonDiscoverableMode, 0); GAP_Set_Pairability_Mode(g_uiBluetoothStackID, pmPairableMode); g_sDeviceInfo.sMode = PAIRABLE_NON_SSP_MODE; if(GAP_Register_Remote_Authentication(g_uiBluetoothStackID, GAP_EventCallback, 0)) { Display(("Error Registering Remote Authentication\n")); } BTPS_SprintF(g_sDeviceInfo.cDeviceName, DEFAULT_DEVICE_NAME); GAP_Set_Local_Device_Name(g_uiBluetoothStackID, g_sDeviceInfo.cDeviceName); psEIRData = (Extended_Inquiry_Response_Data_t *) BTPS_AllocateMemory(sizeof(Extended_Inquiry_Response_Data_t)); if(psEIRData) { BTPS_MemInitialize(psEIRData->Extended_Inquiry_Response_Data, 0, sizeof(Extended_Inquiry_Response_Data_t)); BTPS_MemCopy(psEIRData->Extended_Inquiry_Response_Data, g_ucEIR, sizeof(g_ucEIR)); iRetVal = GAP_Write_Extended_Inquiry_Information( g_uiBluetoothStackID, HCI_EXTENDED_INQUIRY_RESPONSE_FEC_REQUIRED, psEIRData); if(iRetVal) { Display(("Failed to set Extended Inquiry Data: %d", iRetVal)); } BTPS_FreeMemory(psEIRData); } ASSIGN_CLASS_OF_DEVICE(g_sClassOfDevice, (Byte_t)0x24, (Byte_t)0x04, (Byte_t)0x04); GAP_Set_Class_Of_Device(g_uiBluetoothStackID, g_sClassOfDevice); if(GAVD_Initialize(g_uiBluetoothStackID)) { Display(("GAVD failed to Initialize\n")); } else { Display(("GAVD Initialized\n")); } GAVDRegisterEndPoint(); g_sDecoderHandle = SBC_Initialize_Decoder(); if(AVCTP_Initialize(g_uiBluetoothStackID)) { Display(("AVCP failed to Initialize\n")); } else { Display(("AVCTP Initialized\n")); } RegisterAVRCPController(); ReadFlash((NUM_SUPPORTED_LINK_KEYS * sizeof(tLinkKeyInfo)), (unsigned char *)&g_sLinkKeyInfo); iCount = 0; for(iRetVal = 0; iRetVal < NUM_SUPPORTED_LINK_KEYS; iRetVal++) { if(!g_sLinkKeyInfo[iRetVal].bEmpty) { iCount++; } } Display(("%d Link Keys Stored\r\n", iCount)); DAC32SoundInit(); g_sAudioState = asIdle; if((g_sSBCDecodeEvent = BTPS_CreateEvent(FALSE)) != NULL) { g_bExit = FALSE; sSBCDecodeThread = BTPS_CreateThread(SBCDecodeThread, SBC_DECODE_STACK_SIZE, NULL); if(sSBCDecodeThread != NULL) { iRetVal = 0; } else { BTPS_CloseEvent(g_sSBCDecodeEvent); iRetVal = BTH_ERROR_RESOURCE_FAILURE; } } else { iRetVal = BTH_ERROR_RESOURCE_FAILURE; } } else { iRetVal = BTH_ERROR_REQUEST_FAILURE; } } else { iRetVal = BTH_ERROR_INVALID_PARAMETER; } return(iRetVal); }
[ "int", "InitializeBluetooth", "(", "tBluetoothCallbackFn", "pfnCallbackFunction", ",", "void", "*", "pvCallbackParameter", ",", "BTPS_Initialization_t", "*", "pBTPSInitialization", ")", "{", "int", "iRetVal", ";", "int", "iCount", ";", "Byte_t", "sStatus", ";", "BD_ADDR_t", "sBD_ADDR", ";", "HCI_Version_t", "sHCIVersion", ";", "ThreadHandle_t", "sSBCDecodeThread", ";", "HCI_DriverInformation_t", "sDriverInformation", ";", "L2CA_Link_Connect_Params_t", "sConnectParams", ";", "Extended_Inquiry_Response_Data_t", "*", "psEIRData", ";", "if", "(", "pfnCallbackFunction", "&&", "pBTPSInitialization", ")", "{", "BTPS_Init", "(", "(", "void", "*", ")", "pBTPSInitialization", ")", ";", "HCI_DRIVER_SET_COMM_INFORMATION", "(", "&", "sDriverInformation", ",", "1", ",", "115200", ",", "cpUART", ")", ";", "sDriverInformation", ".", "DriverInformation", ".", "COMMDriverInformation", ".", "InitializationDelay", "=", "150", ";", "iRetVal", "=", "BSC_Initialize", "(", "&", "sDriverInformation", ",", "0", ")", ";", "Display", "(", "(", "\"", "\\n", "\"", ",", "iRetVal", ")", ")", ";", "if", "(", "iRetVal", ">", "0", ")", "{", "g_uiBluetoothStackID", "=", "(", "unsigned", "int", ")", "iRetVal", ";", "g_pfnCallbackFunction", "=", "pfnCallbackFunction", ";", "g_pvCallbackParameter", "=", "pvCallbackParameter", ";", "HCI_Version_Supported", "(", "g_uiBluetoothStackID", ",", "&", "sHCIVersion", ")", ";", "g_sDeviceInfo", ".", "ucHCIVersion", "=", "(", "unsigned", "char", ")", "sHCIVersion", ";", "GAP_Query_Local_BD_ADDR", "(", "g_uiBluetoothStackID", ",", "&", "sBD_ADDR", ")", ";", "BD_ADDR_To_Array", "(", "sBD_ADDR", ",", "g_sDeviceInfo", ".", "ucBDAddr", ")", ";", "sConnectParams", ".", "L2CA_Link_Connect_Request_Config", "=", "cqAllowRoleSwitch", ";", "sConnectParams", ".", "L2CA_Link_Connect_Response_Config", "=", "csMaintainCurrentRole", ";", "L2CA_Set_Link_Connection_Configuration", "(", "g_uiBluetoothStackID", ",", "&", "sConnectParams", ")", ";", "if", "(", "HCI_Command_Supported", "(", "g_uiBluetoothStackID", ",", "HCI_SUPPORTED_COMMAND_WRITE_DEFAULT_LINK_POLICY_BIT_NUMBER", ")", ">", "0", ")", "{", "HCI_Write_Default_Link_Policy_Settings", "(", "g_uiBluetoothStackID", ",", "HCI_LINK_POLICY_SETTINGS_ENABLE_MASTER_SLAVE_SWITCH", ",", "&", "sStatus", ")", ";", "}", "GAP_Set_Connectability_Mode", "(", "g_uiBluetoothStackID", ",", "cmNonConnectableMode", ")", ";", "GAP_Set_Discoverability_Mode", "(", "g_uiBluetoothStackID", ",", "dmNonDiscoverableMode", ",", "0", ")", ";", "GAP_Set_Pairability_Mode", "(", "g_uiBluetoothStackID", ",", "pmPairableMode", ")", ";", "g_sDeviceInfo", ".", "sMode", "=", "PAIRABLE_NON_SSP_MODE", ";", "if", "(", "GAP_Register_Remote_Authentication", "(", "g_uiBluetoothStackID", ",", "GAP_EventCallback", ",", "0", ")", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "BTPS_SprintF", "(", "g_sDeviceInfo", ".", "cDeviceName", ",", "DEFAULT_DEVICE_NAME", ")", ";", "GAP_Set_Local_Device_Name", "(", "g_uiBluetoothStackID", ",", "g_sDeviceInfo", ".", "cDeviceName", ")", ";", "psEIRData", "=", "(", "Extended_Inquiry_Response_Data_t", "*", ")", "BTPS_AllocateMemory", "(", "sizeof", "(", "Extended_Inquiry_Response_Data_t", ")", ")", ";", "if", "(", "psEIRData", ")", "{", "BTPS_MemInitialize", "(", "psEIRData", "->", "Extended_Inquiry_Response_Data", ",", "0", ",", "sizeof", "(", "Extended_Inquiry_Response_Data_t", ")", ")", ";", "BTPS_MemCopy", "(", "psEIRData", "->", "Extended_Inquiry_Response_Data", ",", "g_ucEIR", ",", "sizeof", "(", "g_ucEIR", ")", ")", ";", "iRetVal", "=", "GAP_Write_Extended_Inquiry_Information", "(", "g_uiBluetoothStackID", ",", "HCI_EXTENDED_INQUIRY_RESPONSE_FEC_REQUIRED", ",", "psEIRData", ")", ";", "if", "(", "iRetVal", ")", "{", "Display", "(", "(", "\"", "\"", ",", "iRetVal", ")", ")", ";", "}", "BTPS_FreeMemory", "(", "psEIRData", ")", ";", "}", "ASSIGN_CLASS_OF_DEVICE", "(", "g_sClassOfDevice", ",", "(", "Byte_t", ")", "0x24", ",", "(", "Byte_t", ")", "0x04", ",", "(", "Byte_t", ")", "0x04", ")", ";", "GAP_Set_Class_Of_Device", "(", "g_uiBluetoothStackID", ",", "g_sClassOfDevice", ")", ";", "if", "(", "GAVD_Initialize", "(", "g_uiBluetoothStackID", ")", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "GAVDRegisterEndPoint", "(", ")", ";", "g_sDecoderHandle", "=", "SBC_Initialize_Decoder", "(", ")", ";", "if", "(", "AVCTP_Initialize", "(", "g_uiBluetoothStackID", ")", ")", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "else", "{", "Display", "(", "(", "\"", "\\n", "\"", ")", ")", ";", "}", "RegisterAVRCPController", "(", ")", ";", "ReadFlash", "(", "(", "NUM_SUPPORTED_LINK_KEYS", "*", "sizeof", "(", "tLinkKeyInfo", ")", ")", ",", "(", "unsigned", "char", "*", ")", "&", "g_sLinkKeyInfo", ")", ";", "iCount", "=", "0", ";", "for", "(", "iRetVal", "=", "0", ";", "iRetVal", "<", "NUM_SUPPORTED_LINK_KEYS", ";", "iRetVal", "++", ")", "{", "if", "(", "!", "g_sLinkKeyInfo", "[", "iRetVal", "]", ".", "bEmpty", ")", "{", "iCount", "++", ";", "}", "}", "Display", "(", "(", "\"", "\\r", "\\n", "\"", ",", "iCount", ")", ")", ";", "DAC32SoundInit", "(", ")", ";", "g_sAudioState", "=", "asIdle", ";", "if", "(", "(", "g_sSBCDecodeEvent", "=", "BTPS_CreateEvent", "(", "FALSE", ")", ")", "!=", "NULL", ")", "{", "g_bExit", "=", "FALSE", ";", "sSBCDecodeThread", "=", "BTPS_CreateThread", "(", "SBCDecodeThread", ",", "SBC_DECODE_STACK_SIZE", ",", "NULL", ")", ";", "if", "(", "sSBCDecodeThread", "!=", "NULL", ")", "{", "iRetVal", "=", "0", ";", "}", "else", "{", "BTPS_CloseEvent", "(", "g_sSBCDecodeEvent", ")", ";", "iRetVal", "=", "BTH_ERROR_RESOURCE_FAILURE", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_RESOURCE_FAILURE", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_REQUEST_FAILURE", ";", "}", "}", "else", "{", "iRetVal", "=", "BTH_ERROR_INVALID_PARAMETER", ";", "}", "return", "(", "iRetVal", ")", ";", "}" ]
The following function is responsible for initializing the Bluetooth stack as well as the A2DP server.
[ "The", "following", "function", "is", "responsible", "for", "initializing", "the", "Bluetooth", "stack", "as", "well", "as", "the", "A2DP", "server", "." ]
[ "//\r", "// Verify that the parameters passed in appear valid.\r", "//\r", "//\r", "// Initialize the OS abstraction layer.\r", "//\r", "//\r", "// Configure the UART parameters and initialize the Bluetooth stack.\r", "//\r", "//\r", "// Set the Bluetooth serial port startup delay. This is the amount of\r", "// time in ms to wait before starting to use the serial port after\r", "// initialization.\r", "//\r", "//\r", "// Initialize the Bluetooth stack.\r", "//\r", "//\r", "// Save the Bluetooth stack ID.\r", "//\r", "//\r", "// Read and display the Bluetooth version.\r", "//\r", "//\r", "// Read the local Bluetooth device address.\r", "//\r", "//\r", "// Go ahead and allow master/slave role switch.\r", "//\r", "//\r", "// Update the default link policy if supported.\r", "//\r", "//\r", "// In order to allow bonding we are making all devices:\r", "// discoverable, connectable, and [airable. We are also\r", "// registering an authentication callback. Pairing is not required\r", "// to use this application however some devices require it.\r", "//\r", "//\r", "// Set the current state in the device info structure.\r", "//\r", "//\r", "// Register callback to handle remote authentication requests.\r", "//\r", "//\r", "// Set our local name.\r", "//\r", "//\r", "// Allocate space to store temporarily the extended response data\r", "//\r", "//\r", "// Zero out the allocated space\r", "//\r", "//\r", "// Initialize the Extended Inquiry Data with predefined data\r", "//\r", "//\r", "// Write the Extended Inquiry Data to the controller. This\r", "// will be used to respond to an Extended Inquiry request\r", "//\r", "//\r", "// Free the temporary storage\r", "//\r", "//\r", "// Set the class of device\r", "//\r", "//\r", "// Register an end point.\r", "//\r", "//\r", "// Initialize the SBC decoder.\r", "//\r", "//\r", "// Initialize AVCTP (required for AVRCP).\r", "//\r", "//\r", "// Register remote control controller\r", "//\r", "//\r", "// Read the stored link key information from flash.\r", "//\r", "//\r", "// Count the number of link keys that are stored.\r", "//\r", "//\r", "// Set the audio state to idle.\r", "//\r", "//\r", "// First create an event to signal when the task should process\r", "// new SBC data.\r", "//\r", "//\r", "// Add a task that that will manage decoding the SBC data and\r", "// supplying the audio data buffer to the DAC.\r", "//\r", "//\r", "// Everything initialized, go ahead and flag success\r", "// to the caller.\r", "//\r", "//\r", "// Unable to create the SBC decode thread, so go ahead and\r", "// free the event that we allocated and flag an error.\r", "//\r", "//\r", "// Error initializing Bluetooth stack, set error return code\r", "//\r" ]
[ { "param": "pfnCallbackFunction", "type": "tBluetoothCallbackFn" }, { "param": "pvCallbackParameter", "type": "void" }, { "param": "pBTPSInitialization", "type": "BTPS_Initialization_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfnCallbackFunction", "type": "tBluetoothCallbackFn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvCallbackParameter", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pBTPSInitialization", "type": "BTPS_Initialization_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
BumpSensorsInit
void
void BumpSensorsInit (void) { // // Enable the GPIO ports used for the bump sensors. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // // Configure the sensor GPIOs as pulled-up inputs. // ROM_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); }
//***************************************************************************** // //! Initializes the board's bump sensors. //! //! This function must be called before any attempt to read the board bump //! sensors. It configures the GPIO ports used by the sensors. //! //! \return None. // //*****************************************************************************
Initializes the board's bump sensors. This function must be called before any attempt to read the board bump sensors. It configures the GPIO ports used by the sensors. \return None.
[ "Initializes", "the", "board", "'", "s", "bump", "sensors", ".", "This", "function", "must", "be", "called", "before", "any", "attempt", "to", "read", "the", "board", "bump", "sensors", ".", "It", "configures", "the", "GPIO", "ports", "used", "by", "the", "sensors", ".", "\\", "return", "None", "." ]
void BumpSensorsInit (void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); }
[ "void", "BumpSensorsInit", "(", "void", ")", "{", "ROM_SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_GPIOE", ")", ";", "ROM_GPIOPinTypeGPIOInput", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ")", ";", "ROM_GPIOPadConfigSet", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ",", "GPIO_STRENGTH_2MA", ",", "GPIO_PIN_TYPE_STD_WPU", ")", ";", "}" ]
Initializes the board's bump sensors.
[ "Initializes", "the", "board", "'", "s", "bump", "sensors", "." ]
[ "//\r", "// Enable the GPIO ports used for the bump sensors.\r", "//\r", "//\r", "// Configure the sensor GPIOs as pulled-up inputs.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
BumpSensorGetStatus
tBoolean
tBoolean BumpSensorGetStatus (tBumper eBumper) { tBoolean status; // // Which sensor are we being asked to read? // switch (eBumper) { // // Return the state of the right sensor. // case BUMP_RIGHT: { status = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0) ? true : false; break; } // // Return the state of the left sensor. // case BUMP_LEFT: { status = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1) ? true : false; break; } // // This case should never be seen since tSide only contains two // possible values. Some people have been known to cast integers // into enums, though, so.... // default: { status = false; break; } } return (status); }
//***************************************************************************** // //! Gets the status of a bump sensors on the board. //! //! \param eBumper identifies the sensor whose state is to be returned. Valid //! values are \e BUMP_RIGHT and \e BUMP_LEFT. //! //! This function may be used to determine the current state of one or other of //! the EVALBOT's front bump sensors. //! //! \return Returns \e true if the sensor is closed or \e false if it is open. //! //*****************************************************************************
Gets the status of a bump sensors on the board. \param eBumper identifies the sensor whose state is to be returned. Valid values are \e BUMP_RIGHT and \e BUMP_LEFT. This function may be used to determine the current state of one or other of the EVALBOT's front bump sensors. \return Returns \e true if the sensor is closed or \e false if it is open.
[ "Gets", "the", "status", "of", "a", "bump", "sensors", "on", "the", "board", ".", "\\", "param", "eBumper", "identifies", "the", "sensor", "whose", "state", "is", "to", "be", "returned", ".", "Valid", "values", "are", "\\", "e", "BUMP_RIGHT", "and", "\\", "e", "BUMP_LEFT", ".", "This", "function", "may", "be", "used", "to", "determine", "the", "current", "state", "of", "one", "or", "other", "of", "the", "EVALBOT", "'", "s", "front", "bump", "sensors", ".", "\\", "return", "Returns", "\\", "e", "true", "if", "the", "sensor", "is", "closed", "or", "\\", "e", "false", "if", "it", "is", "open", "." ]
tBoolean BumpSensorGetStatus (tBumper eBumper) { tBoolean status; switch (eBumper) { case BUMP_RIGHT: { status = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0) ? true : false; break; } case BUMP_LEFT: { status = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1) ? true : false; break; } default: { status = false; break; } } return (status); }
[ "tBoolean", "BumpSensorGetStatus", "(", "tBumper", "eBumper", ")", "{", "tBoolean", "status", ";", "switch", "(", "eBumper", ")", "{", "case", "BUMP_RIGHT", ":", "{", "status", "=", "ROM_GPIOPinRead", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_0", ")", "?", "true", ":", "false", ";", "break", ";", "}", "case", "BUMP_LEFT", ":", "{", "status", "=", "ROM_GPIOPinRead", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_1", ")", "?", "true", ":", "false", ";", "break", ";", "}", "default", ":", "{", "status", "=", "false", ";", "break", ";", "}", "}", "return", "(", "status", ")", ";", "}" ]
Gets the status of a bump sensors on the board.
[ "Gets", "the", "status", "of", "a", "bump", "sensors", "on", "the", "board", "." ]
[ "//\r", "// Which sensor are we being asked to read?\r", "//\r", "//\r", "// Return the state of the right sensor.\r", "//\r", "//\r", "// Return the state of the left sensor.\r", "//\r", "//\r", "// This case should never be seen since tSide only contains two\r", "// possible values. Some people have been known to cast integers\r", "// into enums, though, so....\r", "//\r" ]
[ { "param": "eBumper", "type": "tBumper" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "eBumper", "type": "tBumper", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
BumpSensorDebouncer
void
void BumpSensorDebouncer(void) { static unsigned char ucBumperClockA = 0; static unsigned char ucBumperClockB = 0; unsigned char ucData; unsigned char ucDelta; // // Read the current state of the hardware bump sensors // ucData = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Determine bumpers that are in a different state from the debounced state // ucDelta = ucData ^ g_ucDebouncedBumpers; // // Increment the debounce counter by one // ucBumperClockA ^= ucBumperClockB; ucBumperClockB = ~ucBumperClockB; // // Reset the debounce counter for any bumper that is unchanged // ucBumperClockA &= ucDelta; ucBumperClockB &= ucDelta; // // Determine the new debounced bumper state based on the debounce // counter. // g_ucDebouncedBumpers &= ucBumperClockA | ucBumperClockB; g_ucDebouncedBumpers |= (~(ucBumperClockA | ucBumperClockB)) & ucData; }
//***************************************************************************** // //! Debounces the EVALBOT sensor switches when called periodically. //! //! If bump sensor debouncing is used, this function should be called //! periodically, for example every 10 ms. It will check the bump sensor //! state and save a debounced state that can be read by the application at //! any time. //! //! \return None. // //*****************************************************************************
Debounces the EVALBOT sensor switches when called periodically. If bump sensor debouncing is used, this function should be called periodically, for example every 10 ms. It will check the bump sensor state and save a debounced state that can be read by the application at any time. \return None.
[ "Debounces", "the", "EVALBOT", "sensor", "switches", "when", "called", "periodically", ".", "If", "bump", "sensor", "debouncing", "is", "used", "this", "function", "should", "be", "called", "periodically", "for", "example", "every", "10", "ms", ".", "It", "will", "check", "the", "bump", "sensor", "state", "and", "save", "a", "debounced", "state", "that", "can", "be", "read", "by", "the", "application", "at", "any", "time", ".", "\\", "return", "None", "." ]
void BumpSensorDebouncer(void) { static unsigned char ucBumperClockA = 0; static unsigned char ucBumperClockB = 0; unsigned char ucData; unsigned char ucDelta; ucData = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); ucDelta = ucData ^ g_ucDebouncedBumpers; ucBumperClockA ^= ucBumperClockB; ucBumperClockB = ~ucBumperClockB; ucBumperClockA &= ucDelta; ucBumperClockB &= ucDelta; g_ucDebouncedBumpers &= ucBumperClockA | ucBumperClockB; g_ucDebouncedBumpers |= (~(ucBumperClockA | ucBumperClockB)) & ucData; }
[ "void", "BumpSensorDebouncer", "(", "void", ")", "{", "static", "unsigned", "char", "ucBumperClockA", "=", "0", ";", "static", "unsigned", "char", "ucBumperClockB", "=", "0", ";", "unsigned", "char", "ucData", ";", "unsigned", "char", "ucDelta", ";", "ucData", "=", "ROM_GPIOPinRead", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ")", ";", "ucDelta", "=", "ucData", "^", "g_ucDebouncedBumpers", ";", "ucBumperClockA", "^=", "ucBumperClockB", ";", "ucBumperClockB", "=", "~", "ucBumperClockB", ";", "ucBumperClockA", "&=", "ucDelta", ";", "ucBumperClockB", "&=", "ucDelta", ";", "g_ucDebouncedBumpers", "&=", "ucBumperClockA", "|", "ucBumperClockB", ";", "g_ucDebouncedBumpers", "|=", "(", "~", "(", "ucBumperClockA", "|", "ucBumperClockB", ")", ")", "&", "ucData", ";", "}" ]
Debounces the EVALBOT sensor switches when called periodically.
[ "Debounces", "the", "EVALBOT", "sensor", "switches", "when", "called", "periodically", "." ]
[ "//\r", "// Read the current state of the hardware bump sensors\r", "//\r", "//\r", "// Determine bumpers that are in a different state from the debounced state\r", "//\r", "//\r", "// Increment the debounce counter by one\r", "//\r", "//\r", "// Reset the debounce counter for any bumper that is unchanged\r", "//\r", "//\r", "// Determine the new debounced bumper state based on the debounce\r", "// counter.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
BumpSensorGetDebounced
tBoolean
tBoolean BumpSensorGetDebounced(tBumper eBumper) { tBoolean status; // // Which sensor are we being asked to read? // switch (eBumper) { // // Return the state of the right sensor. // case BUMP_RIGHT: { status = g_ucDebouncedBumpers & GPIO_PIN_0 ? true : false; break; } // // Return the state of the left sensor. // case BUMP_LEFT: { status = g_ucDebouncedBumpers & GPIO_PIN_1 ? true : false; break; } // // This case should never be seen since tSide only contains two // possible values. Some people have been known to cast integers // into enums, though, so.... // default: { status = false; break; } } return (status); }
//***************************************************************************** // //! Gets the debounced state of a bump sensors on the board. //! //! \param eBumper identifies the sensor whose state is to be returned. Valid //! values are \e BUMP_RIGHT and \e BUMP_LEFT. //! //! This function may be used to determine the debounced state of one or other //! of the EVALBOT's front bump sensors. If this function is used, then the //! application must periodically call the function BumpSensorDebouncer(). //! //! \return Returns \e true if the sensor is closed or \e false if it is open. //! //*****************************************************************************
Gets the debounced state of a bump sensors on the board. \param eBumper identifies the sensor whose state is to be returned. Valid values are \e BUMP_RIGHT and \e BUMP_LEFT. This function may be used to determine the debounced state of one or other of the EVALBOT's front bump sensors. If this function is used, then the application must periodically call the function BumpSensorDebouncer(). \return Returns \e true if the sensor is closed or \e false if it is open.
[ "Gets", "the", "debounced", "state", "of", "a", "bump", "sensors", "on", "the", "board", ".", "\\", "param", "eBumper", "identifies", "the", "sensor", "whose", "state", "is", "to", "be", "returned", ".", "Valid", "values", "are", "\\", "e", "BUMP_RIGHT", "and", "\\", "e", "BUMP_LEFT", ".", "This", "function", "may", "be", "used", "to", "determine", "the", "debounced", "state", "of", "one", "or", "other", "of", "the", "EVALBOT", "'", "s", "front", "bump", "sensors", ".", "If", "this", "function", "is", "used", "then", "the", "application", "must", "periodically", "call", "the", "function", "BumpSensorDebouncer", "()", ".", "\\", "return", "Returns", "\\", "e", "true", "if", "the", "sensor", "is", "closed", "or", "\\", "e", "false", "if", "it", "is", "open", "." ]
tBoolean BumpSensorGetDebounced(tBumper eBumper) { tBoolean status; switch (eBumper) { case BUMP_RIGHT: { status = g_ucDebouncedBumpers & GPIO_PIN_0 ? true : false; break; } case BUMP_LEFT: { status = g_ucDebouncedBumpers & GPIO_PIN_1 ? true : false; break; } default: { status = false; break; } } return (status); }
[ "tBoolean", "BumpSensorGetDebounced", "(", "tBumper", "eBumper", ")", "{", "tBoolean", "status", ";", "switch", "(", "eBumper", ")", "{", "case", "BUMP_RIGHT", ":", "{", "status", "=", "g_ucDebouncedBumpers", "&", "GPIO_PIN_0", "?", "true", ":", "false", ";", "break", ";", "}", "case", "BUMP_LEFT", ":", "{", "status", "=", "g_ucDebouncedBumpers", "&", "GPIO_PIN_1", "?", "true", ":", "false", ";", "break", ";", "}", "default", ":", "{", "status", "=", "false", ";", "break", ";", "}", "}", "return", "(", "status", ")", ";", "}" ]
Gets the debounced state of a bump sensors on the board.
[ "Gets", "the", "debounced", "state", "of", "a", "bump", "sensors", "on", "the", "board", "." ]
[ "//\r", "// Which sensor are we being asked to read?\r", "//\r", "//\r", "// Return the state of the right sensor.\r", "//\r", "//\r", "// Return the state of the left sensor.\r", "//\r", "//\r", "// This case should never be seen since tSide only contains two\r", "// possible values. Some people have been known to cast integers\r", "// into enums, though, so....\r", "//\r" ]
[ { "param": "eBumper", "type": "tBumper" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "eBumper", "type": "tBumper", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorsInit
void
void WheelSensorsInit(void (*pfnCallback)(tWheel eWheel)) { // // Remember the application's callback function pointer. // g_pfnWheelCallback = pfnCallback; // // Enable the GPIO ports used for the wheel encoders. // ROM_SysCtlPeripheralEnable(LEFT_RIGHT_IR_LED_PERIPH); ROM_SysCtlPeripheralEnable(LEFT_IR_SENSOR_PERIPH); ROM_SysCtlPeripheralEnable(RIGHT_IR_SENSOR_PERIPH); // // Configure the sensor inputs. // ROM_GPIOPinTypeGPIOInput(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinTypeGPIOInput(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); // // Configure the LED outputs. Initially turn the LEDs off by setting the // pins high. // ROM_GPIOPinTypeGPIOOutput(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN); ROM_GPIOPadConfigSet(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, LEFT_RIGHT_IR_LED_PIN); // // Disable all of the pin interrupts // ROM_GPIOPinIntDisable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinIntDisable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); ROM_GPIOIntTypeSet(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN, GPIO_RISING_EDGE); ROM_GPIOIntTypeSet(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN, GPIO_RISING_EDGE); // // Enable the GPIO port interrupts for the inputs. The interrupts for the // individual pins still need to be enabled by WheelSensorIntEnable(). // ROM_IntEnable(LEFT_IR_SENSOR_INT); ROM_IntEnable(RIGHT_IR_SENSOR_INT); }
//***************************************************************************** // //! Initializes the infrared wheel sensors. //! //! \param pfnCallback is a pointer to the function which will be called on //! each pulse from the wheel sensors. It may be null to disable callbacks. //! //! This function must be called to initialize the infrared sensors used to //! calculate actual EVALBOT speed. If a non-NULL function pointer is provided //! in the \e pfnCallback parameters, this function will be called on each //! pulse from a wheel sensor when they are enabled. Note that this callback //! is made in interrupt context. //! //! \return None. // //*****************************************************************************
Initializes the infrared wheel sensors. \param pfnCallback is a pointer to the function which will be called on each pulse from the wheel sensors. It may be null to disable callbacks. This function must be called to initialize the infrared sensors used to calculate actual EVALBOT speed. If a non-NULL function pointer is provided in the \e pfnCallback parameters, this function will be called on each pulse from a wheel sensor when they are enabled. Note that this callback is made in interrupt context. \return None.
[ "Initializes", "the", "infrared", "wheel", "sensors", ".", "\\", "param", "pfnCallback", "is", "a", "pointer", "to", "the", "function", "which", "will", "be", "called", "on", "each", "pulse", "from", "the", "wheel", "sensors", ".", "It", "may", "be", "null", "to", "disable", "callbacks", ".", "This", "function", "must", "be", "called", "to", "initialize", "the", "infrared", "sensors", "used", "to", "calculate", "actual", "EVALBOT", "speed", ".", "If", "a", "non", "-", "NULL", "function", "pointer", "is", "provided", "in", "the", "\\", "e", "pfnCallback", "parameters", "this", "function", "will", "be", "called", "on", "each", "pulse", "from", "a", "wheel", "sensor", "when", "they", "are", "enabled", ".", "Note", "that", "this", "callback", "is", "made", "in", "interrupt", "context", ".", "\\", "return", "None", "." ]
void WheelSensorsInit(void (*pfnCallback)(tWheel eWheel)) { g_pfnWheelCallback = pfnCallback; ROM_SysCtlPeripheralEnable(LEFT_RIGHT_IR_LED_PERIPH); ROM_SysCtlPeripheralEnable(LEFT_IR_SENSOR_PERIPH); ROM_SysCtlPeripheralEnable(RIGHT_IR_SENSOR_PERIPH); ROM_GPIOPinTypeGPIOInput(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinTypeGPIOInput(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); ROM_GPIOPinTypeGPIOOutput(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN); ROM_GPIOPadConfigSet(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, LEFT_RIGHT_IR_LED_PIN); ROM_GPIOPinIntDisable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinIntDisable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); ROM_GPIOIntTypeSet(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN, GPIO_RISING_EDGE); ROM_GPIOIntTypeSet(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN, GPIO_RISING_EDGE); ROM_IntEnable(LEFT_IR_SENSOR_INT); ROM_IntEnable(RIGHT_IR_SENSOR_INT); }
[ "void", "WheelSensorsInit", "(", "void", "(", "*", "pfnCallback", ")", "(", "tWheel", "eWheel", ")", ")", "{", "g_pfnWheelCallback", "=", "pfnCallback", ";", "ROM_SysCtlPeripheralEnable", "(", "LEFT_RIGHT_IR_LED_PERIPH", ")", ";", "ROM_SysCtlPeripheralEnable", "(", "LEFT_IR_SENSOR_PERIPH", ")", ";", "ROM_SysCtlPeripheralEnable", "(", "RIGHT_IR_SENSOR_PERIPH", ")", ";", "ROM_GPIOPinTypeGPIOInput", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOPinTypeGPIOInput", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOPinTypeGPIOOutput", "(", "LEFT_RIGHT_IR_LED_PORT", ",", "LEFT_RIGHT_IR_LED_PIN", ")", ";", "ROM_GPIOPadConfigSet", "(", "LEFT_RIGHT_IR_LED_PORT", ",", "LEFT_RIGHT_IR_LED_PIN", ",", "GPIO_STRENGTH_8MA", ",", "GPIO_PIN_TYPE_STD", ")", ";", "ROM_GPIOPinWrite", "(", "LEFT_RIGHT_IR_LED_PORT", ",", "LEFT_RIGHT_IR_LED_PIN", ",", "LEFT_RIGHT_IR_LED_PIN", ")", ";", "ROM_GPIOPinIntDisable", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOPinIntDisable", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOIntTypeSet", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ",", "GPIO_RISING_EDGE", ")", ";", "ROM_GPIOIntTypeSet", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ",", "GPIO_RISING_EDGE", ")", ";", "ROM_IntEnable", "(", "LEFT_IR_SENSOR_INT", ")", ";", "ROM_IntEnable", "(", "RIGHT_IR_SENSOR_INT", ")", ";", "}" ]
Initializes the infrared wheel sensors.
[ "Initializes", "the", "infrared", "wheel", "sensors", "." ]
[ "//\r", "// Remember the application's callback function pointer.\r", "//\r", "//\r", "// Enable the GPIO ports used for the wheel encoders.\r", "//\r", "//\r", "// Configure the sensor inputs.\r", "//\r", "//\r", "// Configure the LED outputs. Initially turn the LEDs off by setting the\r", "// pins high.\r", "//\r", "//\r", "// Disable all of the pin interrupts\r", "//\r", "//\r", "// Enable the GPIO port interrupts for the inputs. The interrupts for the\r", "// individual pins still need to be enabled by WheelSensorIntEnable().\r", "//\r" ]
[ { "param": "pfnCallback", "type": "void" }, { "param": "eWheel", "type": "tWheel" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfnCallback", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eWheel", "type": "tWheel", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorEnable
void
void WheelSensorEnable(void) { // // Turn on the LEDs by setting the pin high. // ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, LEFT_RIGHT_IR_LED_PIN); }
//***************************************************************************** //! //! Enables the LEDs for both EVALBOT wheel sensors. //! //! This function enables the LEDs used by both EVALBOT wheel sensors. //! When the sensors are enabled, notification of sensor pulses will be //! made to the \e pfnCallback function passed to WheelSensorsInit() for that //! wheel assuming sensor interrupts for a given wheel have also been enabled //! by a previous call to WheelSensorIntEnable(). The sensors may be //! disabled by calling WheelSensorDisable(). //! //! \return None. // //*****************************************************************************
Enables the LEDs for both EVALBOT wheel sensors. This function enables the LEDs used by both EVALBOT wheel sensors. When the sensors are enabled, notification of sensor pulses will be made to the \e pfnCallback function passed to WheelSensorsInit() for that wheel assuming sensor interrupts for a given wheel have also been enabled by a previous call to WheelSensorIntEnable(). The sensors may be disabled by calling WheelSensorDisable(). \return None.
[ "Enables", "the", "LEDs", "for", "both", "EVALBOT", "wheel", "sensors", ".", "This", "function", "enables", "the", "LEDs", "used", "by", "both", "EVALBOT", "wheel", "sensors", ".", "When", "the", "sensors", "are", "enabled", "notification", "of", "sensor", "pulses", "will", "be", "made", "to", "the", "\\", "e", "pfnCallback", "function", "passed", "to", "WheelSensorsInit", "()", "for", "that", "wheel", "assuming", "sensor", "interrupts", "for", "a", "given", "wheel", "have", "also", "been", "enabled", "by", "a", "previous", "call", "to", "WheelSensorIntEnable", "()", ".", "The", "sensors", "may", "be", "disabled", "by", "calling", "WheelSensorDisable", "()", ".", "\\", "return", "None", "." ]
void WheelSensorEnable(void) { ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, LEFT_RIGHT_IR_LED_PIN); }
[ "void", "WheelSensorEnable", "(", "void", ")", "{", "ROM_GPIOPinWrite", "(", "LEFT_RIGHT_IR_LED_PORT", ",", "LEFT_RIGHT_IR_LED_PIN", ",", "LEFT_RIGHT_IR_LED_PIN", ")", ";", "}" ]
Enables the LEDs for both EVALBOT wheel sensors.
[ "Enables", "the", "LEDs", "for", "both", "EVALBOT", "wheel", "sensors", "." ]
[ "//\r", "// Turn on the LEDs by setting the pin high.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorDisable
void
void WheelSensorDisable(void) { // // Turn off the LEDs by setting the pin low. // ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, 0); }
//***************************************************************************** //! //! Disables the LEDs for both EVALBOT wheel sensors. //! //! This function disables the LEDs used by both EVALBOT wheel sensors. //! When the sensors are disabled, no notification of sensor pulses will be //! made to the \e pfnCallback function passed to WheelSensorsInit() for that //! wheel. The sensors may be reenabled by calling WheelSensorEnable(). //! //! \return None. // //*****************************************************************************
Disables the LEDs for both EVALBOT wheel sensors. This function disables the LEDs used by both EVALBOT wheel sensors. When the sensors are disabled, no notification of sensor pulses will be made to the \e pfnCallback function passed to WheelSensorsInit() for that wheel. The sensors may be reenabled by calling WheelSensorEnable(). \return None.
[ "Disables", "the", "LEDs", "for", "both", "EVALBOT", "wheel", "sensors", ".", "This", "function", "disables", "the", "LEDs", "used", "by", "both", "EVALBOT", "wheel", "sensors", ".", "When", "the", "sensors", "are", "disabled", "no", "notification", "of", "sensor", "pulses", "will", "be", "made", "to", "the", "\\", "e", "pfnCallback", "function", "passed", "to", "WheelSensorsInit", "()", "for", "that", "wheel", ".", "The", "sensors", "may", "be", "reenabled", "by", "calling", "WheelSensorEnable", "()", ".", "\\", "return", "None", "." ]
void WheelSensorDisable(void) { ROM_GPIOPinWrite(LEFT_RIGHT_IR_LED_PORT, LEFT_RIGHT_IR_LED_PIN, 0); }
[ "void", "WheelSensorDisable", "(", "void", ")", "{", "ROM_GPIOPinWrite", "(", "LEFT_RIGHT_IR_LED_PORT", ",", "LEFT_RIGHT_IR_LED_PIN", ",", "0", ")", ";", "}" ]
Disables the LEDs for both EVALBOT wheel sensors.
[ "Disables", "the", "LEDs", "for", "both", "EVALBOT", "wheel", "sensors", "." ]
[ "//\r", "// Turn off the LEDs by setting the pin low.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorIntEnable
void
void WheelSensorIntEnable(tWheel eWheel) { // // Check for a valid parameter value. // ASSERT((eWheel == WHEEL_LEFT) || (eWheel == WHEEL_RIGHT)); // // Enable the interrupt for the specified wheel. // if(eWheel == WHEEL_LEFT) { ROM_GPIOPinIntClear(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinIntEnable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); } else { ROM_GPIOPinIntClear(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); ROM_GPIOPinIntEnable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); } }
//***************************************************************************** //! //! Enables the interrupts from an infrared wheel sensor. //! //! \param eWheel defines which wheel sensor interrupt to enable. Valid values //! are \e WHEEL_LEFT and \e WHEEL_RIGHT. //! //! This function enables the wheel sensor interrupt from one EVALBOT wheel. //! When a sensor interrupt is enabled, callbacks will be made to the \e //! pfnCallback function passed to WheelSensorsInit() for that wheel. //! Interrupts may be disabled by calling WheelSensorIntDisable(). //! //! \return None. // //*****************************************************************************
Enables the interrupts from an infrared wheel sensor. \param eWheel defines which wheel sensor interrupt to enable. Valid values are \e WHEEL_LEFT and \e WHEEL_RIGHT. This function enables the wheel sensor interrupt from one EVALBOT wheel. When a sensor interrupt is enabled, callbacks will be made to the \e pfnCallback function passed to WheelSensorsInit() for that wheel. Interrupts may be disabled by calling WheelSensorIntDisable(). \return None.
[ "Enables", "the", "interrupts", "from", "an", "infrared", "wheel", "sensor", ".", "\\", "param", "eWheel", "defines", "which", "wheel", "sensor", "interrupt", "to", "enable", ".", "Valid", "values", "are", "\\", "e", "WHEEL_LEFT", "and", "\\", "e", "WHEEL_RIGHT", ".", "This", "function", "enables", "the", "wheel", "sensor", "interrupt", "from", "one", "EVALBOT", "wheel", ".", "When", "a", "sensor", "interrupt", "is", "enabled", "callbacks", "will", "be", "made", "to", "the", "\\", "e", "pfnCallback", "function", "passed", "to", "WheelSensorsInit", "()", "for", "that", "wheel", ".", "Interrupts", "may", "be", "disabled", "by", "calling", "WheelSensorIntDisable", "()", ".", "\\", "return", "None", "." ]
void WheelSensorIntEnable(tWheel eWheel) { ASSERT((eWheel == WHEEL_LEFT) || (eWheel == WHEEL_RIGHT)); if(eWheel == WHEEL_LEFT) { ROM_GPIOPinIntClear(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); ROM_GPIOPinIntEnable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); } else { ROM_GPIOPinIntClear(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); ROM_GPIOPinIntEnable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); } }
[ "void", "WheelSensorIntEnable", "(", "tWheel", "eWheel", ")", "{", "ASSERT", "(", "(", "eWheel", "==", "WHEEL_LEFT", ")", "||", "(", "eWheel", "==", "WHEEL_RIGHT", ")", ")", ";", "if", "(", "eWheel", "==", "WHEEL_LEFT", ")", "{", "ROM_GPIOPinIntClear", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOPinIntEnable", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "}", "else", "{", "ROM_GPIOPinIntClear", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "ROM_GPIOPinIntEnable", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "}", "}" ]
Enables the interrupts from an infrared wheel sensor.
[ "Enables", "the", "interrupts", "from", "an", "infrared", "wheel", "sensor", "." ]
[ "//\r", "// Check for a valid parameter value.\r", "//\r", "//\r", "// Enable the interrupt for the specified wheel.\r", "//\r" ]
[ { "param": "eWheel", "type": "tWheel" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "eWheel", "type": "tWheel", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorIntDisable
void
void WheelSensorIntDisable(tWheel eWheel) { // // Check for a valid parameter value. // ASSERT((eWheel == WHEEL_LEFT) || (eWheel == WHEEL_RIGHT)); // // Disable the interrupt for the specified wheel. // if(eWheel == WHEEL_LEFT) { ROM_GPIOPinIntDisable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); } else { ROM_GPIOPinIntDisable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); } }
//***************************************************************************** //! //! Disables the interrupts from an infrared wheel sensor. //! //! \param eWheel defines which wheel sensor interrupt to disable. Valid values //! are \e WHEEL_LEFT and \e WHEEL_RIGHT. //! //! This function disables the wheel sensor interrupt from one EVALBOT wheel. //! When a sensor interrupt is disabled, no further callbacks will be made to //! the \e pfnCallback function passed to WheelSensorsInit() for that wheel. //! Interrupts may be reenabled by calling WheelSensorIntEnable(). //! //! \return None. // //*****************************************************************************
Disables the interrupts from an infrared wheel sensor. \param eWheel defines which wheel sensor interrupt to disable. Valid values are \e WHEEL_LEFT and \e WHEEL_RIGHT. This function disables the wheel sensor interrupt from one EVALBOT wheel. When a sensor interrupt is disabled, no further callbacks will be made to the \e pfnCallback function passed to WheelSensorsInit() for that wheel. Interrupts may be reenabled by calling WheelSensorIntEnable(). \return None.
[ "Disables", "the", "interrupts", "from", "an", "infrared", "wheel", "sensor", ".", "\\", "param", "eWheel", "defines", "which", "wheel", "sensor", "interrupt", "to", "disable", ".", "Valid", "values", "are", "\\", "e", "WHEEL_LEFT", "and", "\\", "e", "WHEEL_RIGHT", ".", "This", "function", "disables", "the", "wheel", "sensor", "interrupt", "from", "one", "EVALBOT", "wheel", ".", "When", "a", "sensor", "interrupt", "is", "disabled", "no", "further", "callbacks", "will", "be", "made", "to", "the", "\\", "e", "pfnCallback", "function", "passed", "to", "WheelSensorsInit", "()", "for", "that", "wheel", ".", "Interrupts", "may", "be", "reenabled", "by", "calling", "WheelSensorIntEnable", "()", ".", "\\", "return", "None", "." ]
void WheelSensorIntDisable(tWheel eWheel) { ASSERT((eWheel == WHEEL_LEFT) || (eWheel == WHEEL_RIGHT)); if(eWheel == WHEEL_LEFT) { ROM_GPIOPinIntDisable(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); } else { ROM_GPIOPinIntDisable(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); } }
[ "void", "WheelSensorIntDisable", "(", "tWheel", "eWheel", ")", "{", "ASSERT", "(", "(", "eWheel", "==", "WHEEL_LEFT", ")", "||", "(", "eWheel", "==", "WHEEL_RIGHT", ")", ")", ";", "if", "(", "eWheel", "==", "WHEEL_LEFT", ")", "{", "ROM_GPIOPinIntDisable", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "}", "else", "{", "ROM_GPIOPinIntDisable", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "}", "}" ]
Disables the interrupts from an infrared wheel sensor.
[ "Disables", "the", "interrupts", "from", "an", "infrared", "wheel", "sensor", "." ]
[ "//\r", "// Check for a valid parameter value.\r", "//\r", "//\r", "// Disable the interrupt for the specified wheel.\r", "//\r" ]
[ { "param": "eWheel", "type": "tWheel" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "eWheel", "type": "tWheel", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
109f792f3eb6de8b2ef51f947653ea95cd7f7dee
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/drivers/sensors.c
[ "BSD-3-Clause" ]
C
WheelSensorIntHandler
void
void WheelSensorIntHandler(void) { unsigned long ulStatus, ulLoop; // // Was this interrupt from the left wheel sensor? // ulStatus = ROM_GPIOPinIntStatus(LEFT_IR_SENSOR_PORT, true); if (ulStatus & LEFT_IR_SENSOR_PIN) { // // Clear the interrupt. // ROM_GPIOPinIntClear(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); // // Add a short polling loop to reject noise. If the sensor input goes // low inside this loop, we assume we've read a noise spike and ignore // it. // for (ulLoop = 0; ulLoop < 100; ulLoop++) { if (!ROM_GPIOPinRead(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN)) { return; } } // // Tell the app that we got a click from the left wheel sensor. // if(g_pfnWheelCallback) { g_pfnWheelCallback(WHEEL_LEFT); } } // // Was this from the right side sensor? // ulStatus = ROM_GPIOPinIntStatus(RIGHT_IR_SENSOR_PORT, true); if (ulStatus & RIGHT_IR_SENSOR_PIN) { // // Clear the interrupt. // ROM_GPIOPinIntClear(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); // // Add a short polling loop to reject noise. If the sensor input goes // low inside this loop, we assume we've read a noise spike and ignore // it. // for (ulLoop = 0; ulLoop < 100; ulLoop++) { if (!ROM_GPIOPinRead(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN)) { return; } } // // Tell the app that we got a click from the right wheel sensor. // if(g_pfnWheelCallback) { g_pfnWheelCallback(WHEEL_RIGHT); } } }
//***************************************************************************** // //! Handles interrupts from each of the IR sensors used to determine speed. //! //! This interrupt function is called by the processor due to an interrupt //! on the rising edge signals from each of the wheel sensors and is used to //! call a callback function to the client application informing it that the //! wheel has moved. The application-supplied callback function will typically //! be used to calculate wheel rotation speed. //! //! Applications using the motor driver must hook this function to the interrupt //! vectors for each GPIO port containing a wheel sensor pin. For the existing //! EVALBOT hardware, this is GPIO port E. //! //! \return None. //! //! \note This function is called by the interrupt system and should not be //! called directly from application code. // //*****************************************************************************
Handles interrupts from each of the IR sensors used to determine speed. This interrupt function is called by the processor due to an interrupt on the rising edge signals from each of the wheel sensors and is used to call a callback function to the client application informing it that the wheel has moved. The application-supplied callback function will typically be used to calculate wheel rotation speed. Applications using the motor driver must hook this function to the interrupt vectors for each GPIO port containing a wheel sensor pin. For the existing EVALBOT hardware, this is GPIO port E. \return None. \note This function is called by the interrupt system and should not be called directly from application code.
[ "Handles", "interrupts", "from", "each", "of", "the", "IR", "sensors", "used", "to", "determine", "speed", ".", "This", "interrupt", "function", "is", "called", "by", "the", "processor", "due", "to", "an", "interrupt", "on", "the", "rising", "edge", "signals", "from", "each", "of", "the", "wheel", "sensors", "and", "is", "used", "to", "call", "a", "callback", "function", "to", "the", "client", "application", "informing", "it", "that", "the", "wheel", "has", "moved", ".", "The", "application", "-", "supplied", "callback", "function", "will", "typically", "be", "used", "to", "calculate", "wheel", "rotation", "speed", ".", "Applications", "using", "the", "motor", "driver", "must", "hook", "this", "function", "to", "the", "interrupt", "vectors", "for", "each", "GPIO", "port", "containing", "a", "wheel", "sensor", "pin", ".", "For", "the", "existing", "EVALBOT", "hardware", "this", "is", "GPIO", "port", "E", ".", "\\", "return", "None", ".", "\\", "note", "This", "function", "is", "called", "by", "the", "interrupt", "system", "and", "should", "not", "be", "called", "directly", "from", "application", "code", "." ]
void WheelSensorIntHandler(void) { unsigned long ulStatus, ulLoop; ulStatus = ROM_GPIOPinIntStatus(LEFT_IR_SENSOR_PORT, true); if (ulStatus & LEFT_IR_SENSOR_PIN) { ROM_GPIOPinIntClear(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN); for (ulLoop = 0; ulLoop < 100; ulLoop++) { if (!ROM_GPIOPinRead(LEFT_IR_SENSOR_PORT, LEFT_IR_SENSOR_PIN)) { return; } } if(g_pfnWheelCallback) { g_pfnWheelCallback(WHEEL_LEFT); } } ulStatus = ROM_GPIOPinIntStatus(RIGHT_IR_SENSOR_PORT, true); if (ulStatus & RIGHT_IR_SENSOR_PIN) { ROM_GPIOPinIntClear(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN); for (ulLoop = 0; ulLoop < 100; ulLoop++) { if (!ROM_GPIOPinRead(RIGHT_IR_SENSOR_PORT, RIGHT_IR_SENSOR_PIN)) { return; } } if(g_pfnWheelCallback) { g_pfnWheelCallback(WHEEL_RIGHT); } } }
[ "void", "WheelSensorIntHandler", "(", "void", ")", "{", "unsigned", "long", "ulStatus", ",", "ulLoop", ";", "ulStatus", "=", "ROM_GPIOPinIntStatus", "(", "LEFT_IR_SENSOR_PORT", ",", "true", ")", ";", "if", "(", "ulStatus", "&", "LEFT_IR_SENSOR_PIN", ")", "{", "ROM_GPIOPinIntClear", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "100", ";", "ulLoop", "++", ")", "{", "if", "(", "!", "ROM_GPIOPinRead", "(", "LEFT_IR_SENSOR_PORT", ",", "LEFT_IR_SENSOR_PIN", ")", ")", "{", "return", ";", "}", "}", "if", "(", "g_pfnWheelCallback", ")", "{", "g_pfnWheelCallback", "(", "WHEEL_LEFT", ")", ";", "}", "}", "ulStatus", "=", "ROM_GPIOPinIntStatus", "(", "RIGHT_IR_SENSOR_PORT", ",", "true", ")", ";", "if", "(", "ulStatus", "&", "RIGHT_IR_SENSOR_PIN", ")", "{", "ROM_GPIOPinIntClear", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "100", ";", "ulLoop", "++", ")", "{", "if", "(", "!", "ROM_GPIOPinRead", "(", "RIGHT_IR_SENSOR_PORT", ",", "RIGHT_IR_SENSOR_PIN", ")", ")", "{", "return", ";", "}", "}", "if", "(", "g_pfnWheelCallback", ")", "{", "g_pfnWheelCallback", "(", "WHEEL_RIGHT", ")", ";", "}", "}", "}" ]
Handles interrupts from each of the IR sensors used to determine speed.
[ "Handles", "interrupts", "from", "each", "of", "the", "IR", "sensors", "used", "to", "determine", "speed", "." ]
[ "//\r", "// Was this interrupt from the left wheel sensor?\r", "//\r", "//\r", "// Clear the interrupt.\r", "//\r", "//\r", "// Add a short polling loop to reject noise. If the sensor input goes\r", "// low inside this loop, we assume we've read a noise spike and ignore\r", "// it.\r", "//\r", "//\r", "// Tell the app that we got a click from the left wheel sensor.\r", "//\r", "//\r", "// Was this from the right side sensor?\r", "//\r", "//\r", "// Clear the interrupt.\r", "//\r", "//\r", "// Add a short polling loop to reject noise. If the sensor input goes\r", "// low inside this loop, we assume we've read a noise spike and ignore\r", "// it.\r", "//\r", "//\r", "// Tell the app that we got a click from the right wheel sensor.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
ModeCallback
void
void ModeCallback(unsigned long ulIndex, tUSBMode eMode) { // // Save the new mode. // g_eCurrentUSBMode = eMode; }
//***************************************************************************** // // USB Mode callback // // \param ulIndex is the zero-based index of the USB controller making the // callback. // \param eMode indicates the new operating mode. // // This function is called by the USB library whenever an OTG mode change // occurs and, if a connection has been made, informs us of whether we are to // operate as a host or device. // // \return None. // //*****************************************************************************
USB Mode callback \param ulIndex is the zero-based index of the USB controller making the callback. \param eMode indicates the new operating mode. This function is called by the USB library whenever an OTG mode change occurs and, if a connection has been made, informs us of whether we are to operate as a host or device. \return None.
[ "USB", "Mode", "callback", "\\", "param", "ulIndex", "is", "the", "zero", "-", "based", "index", "of", "the", "USB", "controller", "making", "the", "callback", ".", "\\", "param", "eMode", "indicates", "the", "new", "operating", "mode", ".", "This", "function", "is", "called", "by", "the", "USB", "library", "whenever", "an", "OTG", "mode", "change", "occurs", "and", "if", "a", "connection", "has", "been", "made", "informs", "us", "of", "whether", "we", "are", "to", "operate", "as", "a", "host", "or", "device", ".", "\\", "return", "None", "." ]
void ModeCallback(unsigned long ulIndex, tUSBMode eMode) { g_eCurrentUSBMode = eMode; }
[ "void", "ModeCallback", "(", "unsigned", "long", "ulIndex", ",", "tUSBMode", "eMode", ")", "{", "g_eCurrentUSBMode", "=", "eMode", ";", "}" ]
USB Mode callback \param ulIndex is the zero-based index of the USB controller making the callback.
[ "USB", "Mode", "callback", "\\", "param", "ulIndex", "is", "the", "zero", "-", "based", "index", "of", "the", "USB", "controller", "making", "the", "callback", "." ]
[ "//\r", "// Save the new mode.\r", "//\r" ]
[ { "param": "ulIndex", "type": "unsigned long" }, { "param": "eMode", "type": "tUSBMode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulIndex", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eMode", "type": "tUSBMode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
Cmd_ls
int
int Cmd_ls(int argc, char *argv[]) { unsigned long ulTotalSize; unsigned long ulFileCount; unsigned long ulDirCount; FRESULT fresult; FATFS *pFatFs; // // Do not attempt to do anything if there is not a drive attached. // if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } // // Open the current directory for access. // fresult = f_opendir(&g_sDirObject, g_cCwdBuf); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { return(fresult); } ulTotalSize = 0; ulFileCount = 0; ulDirCount = 0; // // Enter loop to enumerate through all directory entries. // while(1) { // // Read an entry from the directory. // fresult = f_readdir(&g_sDirObject, &g_sFileInfo); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { return(fresult); } // // If the file name is blank, then this is the end of the listing. // if(!g_sFileInfo.fname[0]) { break; } // // If the attribute is directory, then increment the directory count. // if(g_sFileInfo.fattrib & AM_DIR) { ulDirCount++; } // // Otherwise, it is a file. Increment the file count, and add in the // file size to the total. // else { ulFileCount++; ulTotalSize += g_sFileInfo.fsize; } // // Print the entry information on a single line with formatting to show // the attributes, date, time, size, and name. // UARTprintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9u %s\n", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : '-', (g_sFileInfo.fattrib & AM_RDO) ? 'R' : '-', (g_sFileInfo.fattrib & AM_HID) ? 'H' : '-', (g_sFileInfo.fattrib & AM_SYS) ? 'S' : '-', (g_sFileInfo.fattrib & AM_ARC) ? 'A' : '-', (g_sFileInfo.fdate >> 9) + 1980, (g_sFileInfo.fdate >> 5) & 15, g_sFileInfo.fdate & 31, (g_sFileInfo.ftime >> 11), (g_sFileInfo.ftime >> 5) & 63, g_sFileInfo.fsize, g_sFileInfo.fname); } // // Print summary lines showing the file, dir, and size totals. // UARTprintf("\n%4u File(s),%10u bytes total\n%4u Dir(s)", ulFileCount, ulTotalSize, ulDirCount); // // Get the free space. // fresult = f_getfree("/", &ulTotalSize, &pFatFs); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { return(fresult); } // // Display the amount of free space that was calculated. // UARTprintf(", %10uK bytes free\n", ulTotalSize * pFatFs->sects_clust / 2); // // Made it to here, return with no errors. // return(0); }
//***************************************************************************** // // This function implements the "ls" command. It opens the current directory // and enumerates through the contents, and prints a line for each item it // finds. It shows details such as file attributes, time and date, and the // file size, along with the name. It shows a summary of file sizes at the end // along with free space. // //*****************************************************************************
This function implements the "ls" command. It opens the current directory and enumerates through the contents, and prints a line for each item it finds. It shows details such as file attributes, time and date, and the file size, along with the name. It shows a summary of file sizes at the end along with free space.
[ "This", "function", "implements", "the", "\"", "ls", "\"", "command", ".", "It", "opens", "the", "current", "directory", "and", "enumerates", "through", "the", "contents", "and", "prints", "a", "line", "for", "each", "item", "it", "finds", ".", "It", "shows", "details", "such", "as", "file", "attributes", "time", "and", "date", "and", "the", "file", "size", "along", "with", "the", "name", ".", "It", "shows", "a", "summary", "of", "file", "sizes", "at", "the", "end", "along", "with", "free", "space", "." ]
int Cmd_ls(int argc, char *argv[]) { unsigned long ulTotalSize; unsigned long ulFileCount; unsigned long ulDirCount; FRESULT fresult; FATFS *pFatFs; if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } fresult = f_opendir(&g_sDirObject, g_cCwdBuf); if(fresult != FR_OK) { return(fresult); } ulTotalSize = 0; ulFileCount = 0; ulDirCount = 0; while(1) { fresult = f_readdir(&g_sDirObject, &g_sFileInfo); if(fresult != FR_OK) { return(fresult); } if(!g_sFileInfo.fname[0]) { break; } if(g_sFileInfo.fattrib & AM_DIR) { ulDirCount++; } else { ulFileCount++; ulTotalSize += g_sFileInfo.fsize; } UARTprintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9u %s\n", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : '-', (g_sFileInfo.fattrib & AM_RDO) ? 'R' : '-', (g_sFileInfo.fattrib & AM_HID) ? 'H' : '-', (g_sFileInfo.fattrib & AM_SYS) ? 'S' : '-', (g_sFileInfo.fattrib & AM_ARC) ? 'A' : '-', (g_sFileInfo.fdate >> 9) + 1980, (g_sFileInfo.fdate >> 5) & 15, g_sFileInfo.fdate & 31, (g_sFileInfo.ftime >> 11), (g_sFileInfo.ftime >> 5) & 63, g_sFileInfo.fsize, g_sFileInfo.fname); } UARTprintf("\n%4u File(s),%10u bytes total\n%4u Dir(s)", ulFileCount, ulTotalSize, ulDirCount); fresult = f_getfree("/", &ulTotalSize, &pFatFs); if(fresult != FR_OK) { return(fresult); } UARTprintf(", %10uK bytes free\n", ulTotalSize * pFatFs->sects_clust / 2); return(0); }
[ "int", "Cmd_ls", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "unsigned", "long", "ulTotalSize", ";", "unsigned", "long", "ulFileCount", ";", "unsigned", "long", "ulDirCount", ";", "FRESULT", "fresult", ";", "FATFS", "*", "pFatFs", ";", "if", "(", "g_eState", "!=", "STATE_DEVICE_READY", ")", "{", "return", "(", "FR_NOT_READY", ")", ";", "}", "fresult", "=", "f_opendir", "(", "&", "g_sDirObject", ",", "g_cCwdBuf", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "ulTotalSize", "=", "0", ";", "ulFileCount", "=", "0", ";", "ulDirCount", "=", "0", ";", "while", "(", "1", ")", "{", "fresult", "=", "f_readdir", "(", "&", "g_sDirObject", ",", "&", "g_sFileInfo", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "if", "(", "!", "g_sFileInfo", ".", "fname", "[", "0", "]", ")", "{", "break", ";", "}", "if", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "{", "ulDirCount", "++", ";", "}", "else", "{", "ulFileCount", "++", ";", "ulTotalSize", "+=", "g_sFileInfo", ".", "fsize", ";", "}", "UARTprintf", "(", "\"", "\\n", "\"", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_RDO", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_HID", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_SYS", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_ARC", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fdate", ">>", "9", ")", "+", "1980", ",", "(", "g_sFileInfo", ".", "fdate", ">>", "5", ")", "&", "15", ",", "g_sFileInfo", ".", "fdate", "&", "31", ",", "(", "g_sFileInfo", ".", "ftime", ">>", "11", ")", ",", "(", "g_sFileInfo", ".", "ftime", ">>", "5", ")", "&", "63", ",", "g_sFileInfo", ".", "fsize", ",", "g_sFileInfo", ".", "fname", ")", ";", "}", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ",", "ulFileCount", ",", "ulTotalSize", ",", "ulDirCount", ")", ";", "fresult", "=", "f_getfree", "(", "\"", "\"", ",", "&", "ulTotalSize", ",", "&", "pFatFs", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "UARTprintf", "(", "\"", "\\n", "\"", ",", "ulTotalSize", "*", "pFatFs", "->", "sects_clust", "/", "2", ")", ";", "return", "(", "0", ")", ";", "}" ]
This function implements the "ls" command.
[ "This", "function", "implements", "the", "\"", "ls", "\"", "command", "." ]
[ "//\r", "// Do not attempt to do anything if there is not a drive attached.\r", "//\r", "//\r", "// Open the current directory for access.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// Enter loop to enumerate through all directory entries.\r", "//\r", "//\r", "// Read an entry from the directory.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// If the file name is blank, then this is the end of the listing.\r", "//\r", "//\r", "// If the attribute is directory, then increment the directory count.\r", "//\r", "//\r", "// Otherwise, it is a file. Increment the file count, and add in the\r", "// file size to the total.\r", "//\r", "//\r", "// Print the entry information on a single line with formatting to show\r", "// the attributes, date, time, size, and name.\r", "//\r", "//\r", "// Print summary lines showing the file, dir, and size totals.\r", "//\r", "//\r", "// Get the free space.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// Display the amount of free space that was calculated.\r", "//\r", "//\r", "// Made it to here, return with no errors.\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
Cmd_cd
int
int Cmd_cd(int argc, char *argv[]) { unsigned int uIdx; FRESULT fresult; // // Do not attempt to do anything if there is not a drive attached. // if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } // // Copy the current working path into a temporary buffer so it can be // manipulated. // strcpy(g_cTmpBuf, g_cCwdBuf); // // If the first character is /, then this is a fully specified path, and it // should just be used as-is. // if(argv[1][0] == '/') { // // Make sure the new path is not bigger than the cwd buffer. // if(strlen(argv[1]) + 1 > sizeof(g_cCwdBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } // // If the new path name (in argv[1]) is not too long, then copy it // into the temporary buffer so it can be checked. // else { strncpy(g_cTmpBuf, argv[1], sizeof(g_cTmpBuf)); } } // // If the argument is .. then attempt to remove the lowest level on the // CWD. // else if(!strcmp(argv[1], "..")) { // // Get the index to the last character in the current path. // uIdx = strlen(g_cTmpBuf) - 1; // // Back up from the end of the path name until a separator (/) is // found, or until we bump up to the start of the path. // while((g_cTmpBuf[uIdx] != '/') && (uIdx > 1)) { // // Back up one character. // uIdx--; } // // Now we are either at the lowest level separator in the current path, // or at the beginning of the string (root). So set the new end of // string here, effectively removing that last part of the path. // g_cTmpBuf[uIdx] = 0; } // // Otherwise this is just a normal path name from the current directory, // and it needs to be appended to the current path. // else { // // Test to make sure that when the new additional path is added on to // the current path, there is room in the buffer for the full new path. // It needs to include a new separator, and a trailing null character. // if(strlen(g_cTmpBuf) + strlen(argv[1]) + 1 + 1 > sizeof(g_cCwdBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } // // The new path is okay, so add the separator and then append the new // directory to the path. // else { // // If not already at the root level, then append a / // if(strcmp(g_cTmpBuf, "/")) { strcat(g_cTmpBuf, "/"); } // // Append the new directory to the path. // strcat(g_cTmpBuf, argv[1]); } } // // At this point, a candidate new directory path is in chTmpBuf. Try to // open it to make sure it is valid. // fresult = f_opendir(&g_sDirObject, g_cTmpBuf); // // If it can't be opened, then it is a bad path. Inform user and return. // if(fresult != FR_OK) { UARTprintf("cd: %s\n", g_cTmpBuf); return(fresult); } // // Otherwise, it is a valid new path, so copy it into the CWD. // else { strncpy(g_cCwdBuf, g_cTmpBuf, sizeof(g_cCwdBuf)); } // // Return success. // return(0); }
//***************************************************************************** // // This function implements the "cd" command. It takes an argument that // specifies the directory to make the current working directory. Path // separators must use a forward slash "/". The argument to cd can be one of // the following: // // * root ("/") // * a fully specified path ("/my/path/to/mydir") // * a single directory name that is in the current directory ("mydir") // * parent directory ("..") // // It does not understand relative paths, so don't try something like this: // ("../my/new/path") // // Once the new directory is specified, it attempts to open the directory to // make sure it exists. If the new path is opened successfully, then the // current working directory (cwd) is changed to the new path. // //*****************************************************************************
This function implements the "cd" command. It takes an argument that specifies the directory to make the current working directory. Path separators must use a forward slash "/". The argument to cd can be one of the following. It does not understand relative paths, so don't try something like this: ("../my/new/path") Once the new directory is specified, it attempts to open the directory to make sure it exists. If the new path is opened successfully, then the current working directory (cwd) is changed to the new path.
[ "This", "function", "implements", "the", "\"", "cd", "\"", "command", ".", "It", "takes", "an", "argument", "that", "specifies", "the", "directory", "to", "make", "the", "current", "working", "directory", ".", "Path", "separators", "must", "use", "a", "forward", "slash", "\"", "/", "\"", ".", "The", "argument", "to", "cd", "can", "be", "one", "of", "the", "following", ".", "It", "does", "not", "understand", "relative", "paths", "so", "don", "'", "t", "try", "something", "like", "this", ":", "(", "\"", "..", "/", "my", "/", "new", "/", "path", "\"", ")", "Once", "the", "new", "directory", "is", "specified", "it", "attempts", "to", "open", "the", "directory", "to", "make", "sure", "it", "exists", ".", "If", "the", "new", "path", "is", "opened", "successfully", "then", "the", "current", "working", "directory", "(", "cwd", ")", "is", "changed", "to", "the", "new", "path", "." ]
int Cmd_cd(int argc, char *argv[]) { unsigned int uIdx; FRESULT fresult; if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } strcpy(g_cTmpBuf, g_cCwdBuf); if(argv[1][0] == '/') { if(strlen(argv[1]) + 1 > sizeof(g_cCwdBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } else { strncpy(g_cTmpBuf, argv[1], sizeof(g_cTmpBuf)); } } else if(!strcmp(argv[1], "..")) { uIdx = strlen(g_cTmpBuf) - 1; while((g_cTmpBuf[uIdx] != '/') && (uIdx > 1)) { uIdx--; } g_cTmpBuf[uIdx] = 0; } else { if(strlen(g_cTmpBuf) + strlen(argv[1]) + 1 + 1 > sizeof(g_cCwdBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } else { if(strcmp(g_cTmpBuf, "/")) { strcat(g_cTmpBuf, "/"); } strcat(g_cTmpBuf, argv[1]); } } fresult = f_opendir(&g_sDirObject, g_cTmpBuf); if(fresult != FR_OK) { UARTprintf("cd: %s\n", g_cTmpBuf); return(fresult); } else { strncpy(g_cCwdBuf, g_cTmpBuf, sizeof(g_cCwdBuf)); } return(0); }
[ "int", "Cmd_cd", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "unsigned", "int", "uIdx", ";", "FRESULT", "fresult", ";", "if", "(", "g_eState", "!=", "STATE_DEVICE_READY", ")", "{", "return", "(", "FR_NOT_READY", ")", ";", "}", "strcpy", "(", "g_cTmpBuf", ",", "g_cCwdBuf", ")", ";", "if", "(", "argv", "[", "1", "]", "[", "0", "]", "==", "'", "'", ")", "{", "if", "(", "strlen", "(", "argv", "[", "1", "]", ")", "+", "1", ">", "sizeof", "(", "g_cCwdBuf", ")", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "return", "(", "0", ")", ";", "}", "else", "{", "strncpy", "(", "g_cTmpBuf", ",", "argv", "[", "1", "]", ",", "sizeof", "(", "g_cTmpBuf", ")", ")", ";", "}", "}", "else", "if", "(", "!", "strcmp", "(", "argv", "[", "1", "]", ",", "\"", "\"", ")", ")", "{", "uIdx", "=", "strlen", "(", "g_cTmpBuf", ")", "-", "1", ";", "while", "(", "(", "g_cTmpBuf", "[", "uIdx", "]", "!=", "'", "'", ")", "&&", "(", "uIdx", ">", "1", ")", ")", "{", "uIdx", "--", ";", "}", "g_cTmpBuf", "[", "uIdx", "]", "=", "0", ";", "}", "else", "{", "if", "(", "strlen", "(", "g_cTmpBuf", ")", "+", "strlen", "(", "argv", "[", "1", "]", ")", "+", "1", "+", "1", ">", "sizeof", "(", "g_cCwdBuf", ")", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "return", "(", "0", ")", ";", "}", "else", "{", "if", "(", "strcmp", "(", "g_cTmpBuf", ",", "\"", "\"", ")", ")", "{", "strcat", "(", "g_cTmpBuf", ",", "\"", "\"", ")", ";", "}", "strcat", "(", "g_cTmpBuf", ",", "argv", "[", "1", "]", ")", ";", "}", "}", "fresult", "=", "f_opendir", "(", "&", "g_sDirObject", ",", "g_cTmpBuf", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ",", "g_cTmpBuf", ")", ";", "return", "(", "fresult", ")", ";", "}", "else", "{", "strncpy", "(", "g_cCwdBuf", ",", "g_cTmpBuf", ",", "sizeof", "(", "g_cCwdBuf", ")", ")", ";", "}", "return", "(", "0", ")", ";", "}" ]
This function implements the "cd" command.
[ "This", "function", "implements", "the", "\"", "cd", "\"", "command", "." ]
[ "//\r", "// Do not attempt to do anything if there is not a drive attached.\r", "//\r", "//\r", "// Copy the current working path into a temporary buffer so it can be\r", "// manipulated.\r", "//\r", "//\r", "// If the first character is /, then this is a fully specified path, and it\r", "// should just be used as-is.\r", "//\r", "//\r", "// Make sure the new path is not bigger than the cwd buffer.\r", "//\r", "//\r", "// If the new path name (in argv[1]) is not too long, then copy it\r", "// into the temporary buffer so it can be checked.\r", "//\r", "//\r", "// If the argument is .. then attempt to remove the lowest level on the\r", "// CWD.\r", "//\r", "//\r", "// Get the index to the last character in the current path.\r", "//\r", "//\r", "// Back up from the end of the path name until a separator (/) is\r", "// found, or until we bump up to the start of the path.\r", "//\r", "//\r", "// Back up one character.\r", "//\r", "//\r", "// Now we are either at the lowest level separator in the current path,\r", "// or at the beginning of the string (root). So set the new end of\r", "// string here, effectively removing that last part of the path.\r", "//\r", "//\r", "// Otherwise this is just a normal path name from the current directory,\r", "// and it needs to be appended to the current path.\r", "//\r", "//\r", "// Test to make sure that when the new additional path is added on to\r", "// the current path, there is room in the buffer for the full new path.\r", "// It needs to include a new separator, and a trailing null character.\r", "//\r", "//\r", "// The new path is okay, so add the separator and then append the new\r", "// directory to the path.\r", "//\r", "//\r", "// If not already at the root level, then append a /\r", "//\r", "//\r", "// Append the new directory to the path.\r", "//\r", "//\r", "// At this point, a candidate new directory path is in chTmpBuf. Try to\r", "// open it to make sure it is valid.\r", "//\r", "//\r", "// If it can't be opened, then it is a bad path. Inform user and return.\r", "//\r", "//\r", "// Otherwise, it is a valid new path, so copy it into the CWD.\r", "//\r", "//\r", "// Return success.\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
Cmd_pwd
int
int Cmd_pwd(int argc, char *argv[]) { // // Do not attempt to do anything if there is not a drive attached. // if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } // // Print the CWD to the console. // UARTprintf("%s\n", g_cCwdBuf); // // Return success. // return(0); }
//***************************************************************************** // // This function implements the "pwd" command. It simply prints the current // working directory. // //*****************************************************************************
This function implements the "pwd" command. It simply prints the current working directory.
[ "This", "function", "implements", "the", "\"", "pwd", "\"", "command", ".", "It", "simply", "prints", "the", "current", "working", "directory", "." ]
int Cmd_pwd(int argc, char *argv[]) { if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } UARTprintf("%s\n", g_cCwdBuf); return(0); }
[ "int", "Cmd_pwd", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "if", "(", "g_eState", "!=", "STATE_DEVICE_READY", ")", "{", "return", "(", "FR_NOT_READY", ")", ";", "}", "UARTprintf", "(", "\"", "\\n", "\"", ",", "g_cCwdBuf", ")", ";", "return", "(", "0", ")", ";", "}" ]
This function implements the "pwd" command.
[ "This", "function", "implements", "the", "\"", "pwd", "\"", "command", "." ]
[ "//\r", "// Do not attempt to do anything if there is not a drive attached.\r", "//\r", "//\r", "// Print the CWD to the console.\r", "//\r", "//\r", "// Return success.\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
Cmd_cat
int
int Cmd_cat(int argc, char *argv[]) { FRESULT fresult; unsigned short usBytesRead; // // Do not attempt to do anything if there is not a drive attached. // if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } // // First, check to make sure that the current path (CWD), plus the file // name, plus a separator and trailing null, will all fit in the temporary // buffer that will be used to hold the file name. The file name must be // fully specified, with path, to FatFs. // if(strlen(g_cCwdBuf) + strlen(argv[1]) + 1 + 1 > sizeof(g_cTmpBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } // // Copy the current path to the temporary buffer so it can be manipulated. // strcpy(g_cTmpBuf, g_cCwdBuf); // // If not already at the root level, then append a separator. // if(strcmp("/", g_cCwdBuf)) { strcat(g_cTmpBuf, "/"); } // // Now finally, append the file name to result in a fully specified file. // strcat(g_cTmpBuf, argv[1]); // // Open the file for reading. // fresult = f_open(&g_sFileObject, g_cTmpBuf, FA_READ); // // If there was some problem opening the file, then return an error. // if(fresult != FR_OK) { return(fresult); } // // Enter a loop to repeatedly read data from the file and display it, until // the end of the file is reached. // do { // // Read a block of data from the file. Read as much as can fit in the // temporary buffer, including a space for the trailing null. // fresult = f_read(&g_sFileObject, g_cTmpBuf, sizeof(g_cTmpBuf) - 1, &usBytesRead); // // If there was an error reading, then print a newline and return the // error to the user. // if(fresult != FR_OK) { UARTprintf("\n"); return(fresult); } // // Null terminate the last block that was read to make it a null // terminated string that can be used with printf. // g_cTmpBuf[usBytesRead] = 0; // // Print the last chunk of the file that was received. // UARTprintf("%s", g_cTmpBuf); // // Continue reading until less than the full number of bytes are read. // That means the end of the buffer was reached. // } while(usBytesRead == sizeof(g_cTmpBuf) - 1); // // Return success. // return(0); }
//***************************************************************************** // // This function implements the "cat" command. It reads the contents of a file // and prints it to the console. This should only be used on text files. If // it is used on a binary file, then a bunch of garbage is likely to printed on // the console. // //*****************************************************************************
This function implements the "cat" command. It reads the contents of a file and prints it to the console. This should only be used on text files. If it is used on a binary file, then a bunch of garbage is likely to printed on the console.
[ "This", "function", "implements", "the", "\"", "cat", "\"", "command", ".", "It", "reads", "the", "contents", "of", "a", "file", "and", "prints", "it", "to", "the", "console", ".", "This", "should", "only", "be", "used", "on", "text", "files", ".", "If", "it", "is", "used", "on", "a", "binary", "file", "then", "a", "bunch", "of", "garbage", "is", "likely", "to", "printed", "on", "the", "console", "." ]
int Cmd_cat(int argc, char *argv[]) { FRESULT fresult; unsigned short usBytesRead; if(g_eState != STATE_DEVICE_READY) { return(FR_NOT_READY); } if(strlen(g_cCwdBuf) + strlen(argv[1]) + 1 + 1 > sizeof(g_cTmpBuf)) { UARTprintf("Resulting path name is too long\n"); return(0); } strcpy(g_cTmpBuf, g_cCwdBuf); if(strcmp("/", g_cCwdBuf)) { strcat(g_cTmpBuf, "/"); } strcat(g_cTmpBuf, argv[1]); fresult = f_open(&g_sFileObject, g_cTmpBuf, FA_READ); if(fresult != FR_OK) { return(fresult); } do { fresult = f_read(&g_sFileObject, g_cTmpBuf, sizeof(g_cTmpBuf) - 1, &usBytesRead); if(fresult != FR_OK) { UARTprintf("\n"); return(fresult); } g_cTmpBuf[usBytesRead] = 0; UARTprintf("%s", g_cTmpBuf); } while(usBytesRead == sizeof(g_cTmpBuf) - 1); return(0); }
[ "int", "Cmd_cat", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "FRESULT", "fresult", ";", "unsigned", "short", "usBytesRead", ";", "if", "(", "g_eState", "!=", "STATE_DEVICE_READY", ")", "{", "return", "(", "FR_NOT_READY", ")", ";", "}", "if", "(", "strlen", "(", "g_cCwdBuf", ")", "+", "strlen", "(", "argv", "[", "1", "]", ")", "+", "1", "+", "1", ">", "sizeof", "(", "g_cTmpBuf", ")", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "return", "(", "0", ")", ";", "}", "strcpy", "(", "g_cTmpBuf", ",", "g_cCwdBuf", ")", ";", "if", "(", "strcmp", "(", "\"", "\"", ",", "g_cCwdBuf", ")", ")", "{", "strcat", "(", "g_cTmpBuf", ",", "\"", "\"", ")", ";", "}", "strcat", "(", "g_cTmpBuf", ",", "argv", "[", "1", "]", ")", ";", "fresult", "=", "f_open", "(", "&", "g_sFileObject", ",", "g_cTmpBuf", ",", "FA_READ", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "do", "{", "fresult", "=", "f_read", "(", "&", "g_sFileObject", ",", "g_cTmpBuf", ",", "sizeof", "(", "g_cTmpBuf", ")", "-", "1", ",", "&", "usBytesRead", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "return", "(", "fresult", ")", ";", "}", "g_cTmpBuf", "[", "usBytesRead", "]", "=", "0", ";", "UARTprintf", "(", "\"", "\"", ",", "g_cTmpBuf", ")", ";", "}", "while", "(", "usBytesRead", "==", "sizeof", "(", "g_cTmpBuf", ")", "-", "1", ")", ";", "return", "(", "0", ")", ";", "}" ]
This function implements the "cat" command.
[ "This", "function", "implements", "the", "\"", "cat", "\"", "command", "." ]
[ "//\r", "// Do not attempt to do anything if there is not a drive attached.\r", "//\r", "//\r", "// First, check to make sure that the current path (CWD), plus the file\r", "// name, plus a separator and trailing null, will all fit in the temporary\r", "// buffer that will be used to hold the file name. The file name must be\r", "// fully specified, with path, to FatFs.\r", "//\r", "//\r", "// Copy the current path to the temporary buffer so it can be manipulated.\r", "//\r", "//\r", "// If not already at the root level, then append a separator.\r", "//\r", "//\r", "// Now finally, append the file name to result in a fully specified file.\r", "//\r", "//\r", "// Open the file for reading.\r", "//\r", "//\r", "// If there was some problem opening the file, then return an error.\r", "//\r", "//\r", "// Enter a loop to repeatedly read data from the file and display it, until\r", "// the end of the file is reached.\r", "//\r", "//\r", "// Read a block of data from the file. Read as much as can fit in the\r", "// temporary buffer, including a space for the trailing null.\r", "//\r", "//\r", "// If there was an error reading, then print a newline and return the\r", "// error to the user.\r", "//\r", "//\r", "// Null terminate the last block that was read to make it a null\r", "// terminated string that can be used with printf.\r", "//\r", "//\r", "// Print the last chunk of the file that was received.\r", "//\r", "//\r", "// Continue reading until less than the full number of bytes are read.\r", "// That means the end of the buffer was reached.\r", "//\r", "//\r", "// Return success.\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
MSCCallback
void
void MSCCallback(unsigned long ulInstance, unsigned long ulEvent, void *pvData) { // // Determine the event. // switch(ulEvent) { // // Called when the device driver has successfully enumerated an MSC // device. // case MSC_EVENT_OPEN: { // // Proceed to the enumeration state. // g_eState = STATE_DEVICE_ENUM; break; } // // Called when the device driver has been unloaded due to error or // the device is no longer present. // case MSC_EVENT_CLOSE: { // // Go back to the "no device" state and wait for a new connection. // g_eState = STATE_NO_DEVICE; break; } default: { break; } } }
//***************************************************************************** // // This is the callback from the MSC driver. // // \param ulInstance is the driver instance which is needed when communicating // with the driver. // \param ulEvent is one of the events defined by the driver. // \param pvData is a pointer to data passed into the initial call to register // the callback. // // This function handles callback events from the MSC driver. The only events // currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE. This allows // the main routine to know when an MSC device has been detected and // enumerated and when an MSC device has been removed from the system. // // \return Returns \e true on success or \e false on failure. // //*****************************************************************************
This is the callback from the MSC driver. \param ulInstance is the driver instance which is needed when communicating with the driver. \param ulEvent is one of the events defined by the driver. \param pvData is a pointer to data passed into the initial call to register the callback. This function handles callback events from the MSC driver. The only events currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE. This allows the main routine to know when an MSC device has been detected and enumerated and when an MSC device has been removed from the system. \return Returns \e true on success or \e false on failure.
[ "This", "is", "the", "callback", "from", "the", "MSC", "driver", ".", "\\", "param", "ulInstance", "is", "the", "driver", "instance", "which", "is", "needed", "when", "communicating", "with", "the", "driver", ".", "\\", "param", "ulEvent", "is", "one", "of", "the", "events", "defined", "by", "the", "driver", ".", "\\", "param", "pvData", "is", "a", "pointer", "to", "data", "passed", "into", "the", "initial", "call", "to", "register", "the", "callback", ".", "This", "function", "handles", "callback", "events", "from", "the", "MSC", "driver", ".", "The", "only", "events", "currently", "handled", "are", "the", "MSC_EVENT_OPEN", "and", "MSC_EVENT_CLOSE", ".", "This", "allows", "the", "main", "routine", "to", "know", "when", "an", "MSC", "device", "has", "been", "detected", "and", "enumerated", "and", "when", "an", "MSC", "device", "has", "been", "removed", "from", "the", "system", ".", "\\", "return", "Returns", "\\", "e", "true", "on", "success", "or", "\\", "e", "false", "on", "failure", "." ]
void MSCCallback(unsigned long ulInstance, unsigned long ulEvent, void *pvData) { switch(ulEvent) { case MSC_EVENT_OPEN: { g_eState = STATE_DEVICE_ENUM; break; } case MSC_EVENT_CLOSE: { g_eState = STATE_NO_DEVICE; break; } default: { break; } } }
[ "void", "MSCCallback", "(", "unsigned", "long", "ulInstance", ",", "unsigned", "long", "ulEvent", ",", "void", "*", "pvData", ")", "{", "switch", "(", "ulEvent", ")", "{", "case", "MSC_EVENT_OPEN", ":", "{", "g_eState", "=", "STATE_DEVICE_ENUM", ";", "break", ";", "}", "case", "MSC_EVENT_CLOSE", ":", "{", "g_eState", "=", "STATE_NO_DEVICE", ";", "break", ";", "}", "default", ":", "{", "break", ";", "}", "}", "}" ]
This is the callback from the MSC driver.
[ "This", "is", "the", "callback", "from", "the", "MSC", "driver", "." ]
[ "//\r", "// Determine the event.\r", "//\r", "//\r", "// Called when the device driver has successfully enumerated an MSC\r", "// device.\r", "//\r", "//\r", "// Proceed to the enumeration state.\r", "//\r", "//\r", "// Called when the device driver has been unloaded due to error or\r", "// the device is no longer present.\r", "//\r", "//\r", "// Go back to the \"no device\" state and wait for a new connection.\r", "//\r" ]
[ { "param": "ulInstance", "type": "unsigned long" }, { "param": "ulEvent", "type": "unsigned long" }, { "param": "pvData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulInstance", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulEvent", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
USBHCDEvents
void
void USBHCDEvents(void *pvData) { tEventInfo *pEventInfo; // // Cast this pointer to its actual type. // pEventInfo = (tEventInfo *)pvData; switch(pEventInfo->ulEvent) { // // Unknown device detected. // case USB_EVENT_UNKNOWN_CONNECTED: { // // Save the unknown class. // g_ulUnknownClass = pEventInfo->ulInstance; // // An unknown device was detected. // g_eState = STATE_UNKNOWN_DEVICE; break; } // // Keyboard has been unplugged. // case USB_EVENT_DISCONNECTED: { // // Unknown device has been removed. // g_eState = STATE_NO_DEVICE; break; } case USB_EVENT_POWER_FAULT: { // // No power means no device is present. // g_eState = STATE_POWER_FAULT; break; } default: { break; } } }
//***************************************************************************** // // This is the generic callback from host stack. // // \param pvData is actually a pointer to a tEventInfo structure. // // This function will be called to inform the application when a USB event has // occurred that is outside those related to the mass storage device. At this // point this is used to detect unsupported devices being inserted and removed. // It is also used to inform the application when a power fault has occurred. // This function is required when the g_USBGenericEventDriver is included in // the host controller driver array that is passed in to the // USBHCDRegisterDrivers() function. // // \return None. // //*****************************************************************************
This is the generic callback from host stack. \param pvData is actually a pointer to a tEventInfo structure. This function will be called to inform the application when a USB event has occurred that is outside those related to the mass storage device. At this point this is used to detect unsupported devices being inserted and removed. It is also used to inform the application when a power fault has occurred. This function is required when the g_USBGenericEventDriver is included in the host controller driver array that is passed in to the USBHCDRegisterDrivers() function. \return None.
[ "This", "is", "the", "generic", "callback", "from", "host", "stack", ".", "\\", "param", "pvData", "is", "actually", "a", "pointer", "to", "a", "tEventInfo", "structure", ".", "This", "function", "will", "be", "called", "to", "inform", "the", "application", "when", "a", "USB", "event", "has", "occurred", "that", "is", "outside", "those", "related", "to", "the", "mass", "storage", "device", ".", "At", "this", "point", "this", "is", "used", "to", "detect", "unsupported", "devices", "being", "inserted", "and", "removed", ".", "It", "is", "also", "used", "to", "inform", "the", "application", "when", "a", "power", "fault", "has", "occurred", ".", "This", "function", "is", "required", "when", "the", "g_USBGenericEventDriver", "is", "included", "in", "the", "host", "controller", "driver", "array", "that", "is", "passed", "in", "to", "the", "USBHCDRegisterDrivers", "()", "function", ".", "\\", "return", "None", "." ]
void USBHCDEvents(void *pvData) { tEventInfo *pEventInfo; pEventInfo = (tEventInfo *)pvData; switch(pEventInfo->ulEvent) { case USB_EVENT_UNKNOWN_CONNECTED: { g_ulUnknownClass = pEventInfo->ulInstance; g_eState = STATE_UNKNOWN_DEVICE; break; } case USB_EVENT_DISCONNECTED: { g_eState = STATE_NO_DEVICE; break; } case USB_EVENT_POWER_FAULT: { g_eState = STATE_POWER_FAULT; break; } default: { break; } } }
[ "void", "USBHCDEvents", "(", "void", "*", "pvData", ")", "{", "tEventInfo", "*", "pEventInfo", ";", "pEventInfo", "=", "(", "tEventInfo", "*", ")", "pvData", ";", "switch", "(", "pEventInfo", "->", "ulEvent", ")", "{", "case", "USB_EVENT_UNKNOWN_CONNECTED", ":", "{", "g_ulUnknownClass", "=", "pEventInfo", "->", "ulInstance", ";", "g_eState", "=", "STATE_UNKNOWN_DEVICE", ";", "break", ";", "}", "case", "USB_EVENT_DISCONNECTED", ":", "{", "g_eState", "=", "STATE_NO_DEVICE", ";", "break", ";", "}", "case", "USB_EVENT_POWER_FAULT", ":", "{", "g_eState", "=", "STATE_POWER_FAULT", ";", "break", ";", "}", "default", ":", "{", "break", ";", "}", "}", "}" ]
This is the generic callback from host stack.
[ "This", "is", "the", "generic", "callback", "from", "host", "stack", "." ]
[ "//\r", "// Cast this pointer to its actual type.\r", "//\r", "//\r", "// Unknown device detected.\r", "//\r", "//\r", "// Save the unknown class.\r", "//\r", "//\r", "// An unknown device was detected.\r", "//\r", "//\r", "// Keyboard has been unplugged.\r", "//\r", "//\r", "// Unknown device has been removed.\r", "//\r", "//\r", "// No power means no device is present.\r", "//\r" ]
[ { "param": "pvData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c620687eaeddaad2d63a468fd1a6f8a86e7498e0
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b92/usb_host_msc/usb_host_msc.c
[ "BSD-3-Clause" ]
C
ReadLine
void
void ReadLine(void) { unsigned long ulIdx, ulPrompt; unsigned char ucChar; tState eStateCopy; unsigned long ulDriveTimeout; // // Start reading at the beginning of the command buffer and print a prompt. // g_cCmdBuf[0] = '\0'; ulIdx = 0; ulPrompt = 1; // // Initialize the drive timeout. // ulDriveTimeout = USBMSC_DRIVE_RETRY; // // Loop forever. This loop will be explicitly broken out of when the line // has been fully read. // while(1) { // // See if a mass storage device has been enumerated. // if(g_eState == STATE_DEVICE_ENUM) { // // Take it easy on the Mass storage device if it is slow to // start up after connecting. // if(USBHMSCDriveReady(g_ulMSCInstance) != 0) { // // Wait about 500ms before attempting to check if the // device is ready again. // SysCtlDelay(SysCtlClockGet()/(3*2)); // // Decrement the retry count. // ulDriveTimeout--; // // If the timeout is hit then go to the // STATE_TIMEOUT_DEVICE state. // if(ulDriveTimeout == 0) { g_eState = STATE_TIMEOUT_DEVICE; } break; } // // Reset the working directory to the root. // g_cCwdBuf[0] = '/'; g_cCwdBuf[1] = '\0'; // // Attempt to open the directory. Some drives take longer to // start up than others, and this may fail (even though the USB // device has enumerated) if it is still initializing. // f_mount(0, &g_sFatFs); if(f_opendir(&g_sDirObject, g_cCwdBuf) == FR_OK) { // // The drive is fully ready, so move to that state. // g_eState = STATE_DEVICE_READY; } } // // See if the state has changed. We make a copy of g_eUIState to // prevent a compiler warning about undefined order of volatile // accesses. // eStateCopy = g_eUIState; if(g_eState != eStateCopy) { // // Determine the new state. // switch(g_eState) { // // A previously connected device has been disconnected. // case STATE_NO_DEVICE: { if(g_eUIState == STATE_UNKNOWN_DEVICE) { UARTprintf("\nUnknown device disconnected.\n"); } else { UARTprintf("\nMass storage device disconnected.\n"); } ulPrompt = 1; break; } // // A mass storage device is being enumerated. // case STATE_DEVICE_ENUM: { break; } // // A mass storage device has been enumerated and initialized. // case STATE_DEVICE_READY: { UARTprintf("\nMass storage device connected.\n"); ulPrompt = 1; break; } // // An unknown device has been connected. // case STATE_UNKNOWN_DEVICE: { UARTprintf("Unknown Device Class (0x%02x) Connected.\n", g_ulUnknownClass); ulPrompt = 1; break; } // // The connected mass storage device is not reporting ready. // case STATE_TIMEOUT_DEVICE: { // // If this is the first time in this state then print a // message. // UARTprintf("Device Timeout.\n"); ulPrompt = 1; break; } // // A power fault has occurred. // case STATE_POWER_FAULT: { UARTprintf("\nPower fault.\n"); ulPrompt = 1; break; } } // // Save the current state. // g_eUIState = g_eState; } // // Print a prompt if necessary. // if(ulPrompt) { // // Print the prompt based on the current state. // if(g_eState == STATE_DEVICE_READY) { UARTprintf("%s> %s", g_cCwdBuf, g_cCmdBuf); } else if(g_eState == STATE_UNKNOWN_DEVICE) { UARTprintf("UNKNOWN> %s", g_cCmdBuf); } else { UARTprintf("NODEV> %s", g_cCmdBuf); } // // The prompt no longer needs to be printed. // ulPrompt = 0; } // // Loop while there are characters that have been received from the // UART. // while(ROM_UARTCharsAvail(UART0_BASE)) { // // Read the next character from the UART. // ucChar = UARTgetc(); // // See if this character is a backspace and there is at least one // character in the input line. // if((ucChar == '\b') && (ulIdx != 0)) { // // Erase the lsat character from the input line. // UARTprintf("\b \b"); ulIdx--; g_cCmdBuf[ulIdx] = '\0'; } // // See if this character is a newline. // else if((ucChar == '\r') || (ucChar == '\n')) { // // Return to the caller. // UARTprintf("\n"); return; } // // See if this character is an escape or Ctrl-U. // else if((ucChar == 0x1b) || (ucChar == 0x15)) { // // Erase all characters in the input buffer. // while(ulIdx) { UARTprintf("\b \b"); ulIdx--; } g_cCmdBuf[0] = '\0'; } // // See if this is a printable ASCII character. // else if((ucChar >= ' ') && (ucChar <= '~') && (ulIdx < (sizeof(g_cCmdBuf) - 1))) { // // Add this character to the input buffer. // g_cCmdBuf[ulIdx++] = ucChar; g_cCmdBuf[ulIdx] = '\0'; UARTprintf("%c", ucChar); } } // // Tell the OTG state machine how much time has passed in // milliseconds since the last call. // USBOTGMain(GetTickms()); } }
//***************************************************************************** // // This function reads a line of text from the UART console. The USB host main // function is called throughout this process to keep USB alive and well. // //*****************************************************************************
This function reads a line of text from the UART console. The USB host main function is called throughout this process to keep USB alive and well.
[ "This", "function", "reads", "a", "line", "of", "text", "from", "the", "UART", "console", ".", "The", "USB", "host", "main", "function", "is", "called", "throughout", "this", "process", "to", "keep", "USB", "alive", "and", "well", "." ]
void ReadLine(void) { unsigned long ulIdx, ulPrompt; unsigned char ucChar; tState eStateCopy; unsigned long ulDriveTimeout; g_cCmdBuf[0] = '\0'; ulIdx = 0; ulPrompt = 1; ulDriveTimeout = USBMSC_DRIVE_RETRY; while(1) { if(g_eState == STATE_DEVICE_ENUM) { if(USBHMSCDriveReady(g_ulMSCInstance) != 0) { SysCtlDelay(SysCtlClockGet()/(3*2)); ulDriveTimeout--; if(ulDriveTimeout == 0) { g_eState = STATE_TIMEOUT_DEVICE; } break; } g_cCwdBuf[0] = '/'; g_cCwdBuf[1] = '\0'; f_mount(0, &g_sFatFs); if(f_opendir(&g_sDirObject, g_cCwdBuf) == FR_OK) { g_eState = STATE_DEVICE_READY; } } eStateCopy = g_eUIState; if(g_eState != eStateCopy) { switch(g_eState) { case STATE_NO_DEVICE: { if(g_eUIState == STATE_UNKNOWN_DEVICE) { UARTprintf("\nUnknown device disconnected.\n"); } else { UARTprintf("\nMass storage device disconnected.\n"); } ulPrompt = 1; break; } case STATE_DEVICE_ENUM: { break; } case STATE_DEVICE_READY: { UARTprintf("\nMass storage device connected.\n"); ulPrompt = 1; break; } case STATE_UNKNOWN_DEVICE: { UARTprintf("Unknown Device Class (0x%02x) Connected.\n", g_ulUnknownClass); ulPrompt = 1; break; } case STATE_TIMEOUT_DEVICE: { UARTprintf("Device Timeout.\n"); ulPrompt = 1; break; } case STATE_POWER_FAULT: { UARTprintf("\nPower fault.\n"); ulPrompt = 1; break; } } g_eUIState = g_eState; } if(ulPrompt) { if(g_eState == STATE_DEVICE_READY) { UARTprintf("%s> %s", g_cCwdBuf, g_cCmdBuf); } else if(g_eState == STATE_UNKNOWN_DEVICE) { UARTprintf("UNKNOWN> %s", g_cCmdBuf); } else { UARTprintf("NODEV> %s", g_cCmdBuf); } ulPrompt = 0; } while(ROM_UARTCharsAvail(UART0_BASE)) { ucChar = UARTgetc(); if((ucChar == '\b') && (ulIdx != 0)) { UARTprintf("\b \b"); ulIdx--; g_cCmdBuf[ulIdx] = '\0'; } else if((ucChar == '\r') || (ucChar == '\n')) { UARTprintf("\n"); return; } else if((ucChar == 0x1b) || (ucChar == 0x15)) { while(ulIdx) { UARTprintf("\b \b"); ulIdx--; } g_cCmdBuf[0] = '\0'; } else if((ucChar >= ' ') && (ucChar <= '~') && (ulIdx < (sizeof(g_cCmdBuf) - 1))) { g_cCmdBuf[ulIdx++] = ucChar; g_cCmdBuf[ulIdx] = '\0'; UARTprintf("%c", ucChar); } } USBOTGMain(GetTickms()); } }
[ "void", "ReadLine", "(", "void", ")", "{", "unsigned", "long", "ulIdx", ",", "ulPrompt", ";", "unsigned", "char", "ucChar", ";", "tState", "eStateCopy", ";", "unsigned", "long", "ulDriveTimeout", ";", "g_cCmdBuf", "[", "0", "]", "=", "'", "\\0", "'", ";", "ulIdx", "=", "0", ";", "ulPrompt", "=", "1", ";", "ulDriveTimeout", "=", "USBMSC_DRIVE_RETRY", ";", "while", "(", "1", ")", "{", "if", "(", "g_eState", "==", "STATE_DEVICE_ENUM", ")", "{", "if", "(", "USBHMSCDriveReady", "(", "g_ulMSCInstance", ")", "!=", "0", ")", "{", "SysCtlDelay", "(", "SysCtlClockGet", "(", ")", "/", "(", "3", "*", "2", ")", ")", ";", "ulDriveTimeout", "--", ";", "if", "(", "ulDriveTimeout", "==", "0", ")", "{", "g_eState", "=", "STATE_TIMEOUT_DEVICE", ";", "}", "break", ";", "}", "g_cCwdBuf", "[", "0", "]", "=", "'", "'", ";", "g_cCwdBuf", "[", "1", "]", "=", "'", "\\0", "'", ";", "f_mount", "(", "0", ",", "&", "g_sFatFs", ")", ";", "if", "(", "f_opendir", "(", "&", "g_sDirObject", ",", "g_cCwdBuf", ")", "==", "FR_OK", ")", "{", "g_eState", "=", "STATE_DEVICE_READY", ";", "}", "}", "eStateCopy", "=", "g_eUIState", ";", "if", "(", "g_eState", "!=", "eStateCopy", ")", "{", "switch", "(", "g_eState", ")", "{", "case", "STATE_NO_DEVICE", ":", "{", "if", "(", "g_eUIState", "==", "STATE_UNKNOWN_DEVICE", ")", "{", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "}", "else", "{", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "}", "ulPrompt", "=", "1", ";", "break", ";", "}", "case", "STATE_DEVICE_ENUM", ":", "{", "break", ";", "}", "case", "STATE_DEVICE_READY", ":", "{", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "ulPrompt", "=", "1", ";", "break", ";", "}", "case", "STATE_UNKNOWN_DEVICE", ":", "{", "UARTprintf", "(", "\"", "\\n", "\"", ",", "g_ulUnknownClass", ")", ";", "ulPrompt", "=", "1", ";", "break", ";", "}", "case", "STATE_TIMEOUT_DEVICE", ":", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "ulPrompt", "=", "1", ";", "break", ";", "}", "case", "STATE_POWER_FAULT", ":", "{", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "ulPrompt", "=", "1", ";", "break", ";", "}", "}", "g_eUIState", "=", "g_eState", ";", "}", "if", "(", "ulPrompt", ")", "{", "if", "(", "g_eState", "==", "STATE_DEVICE_READY", ")", "{", "UARTprintf", "(", "\"", "\"", ",", "g_cCwdBuf", ",", "g_cCmdBuf", ")", ";", "}", "else", "if", "(", "g_eState", "==", "STATE_UNKNOWN_DEVICE", ")", "{", "UARTprintf", "(", "\"", "\"", ",", "g_cCmdBuf", ")", ";", "}", "else", "{", "UARTprintf", "(", "\"", "\"", ",", "g_cCmdBuf", ")", ";", "}", "ulPrompt", "=", "0", ";", "}", "while", "(", "ROM_UARTCharsAvail", "(", "UART0_BASE", ")", ")", "{", "ucChar", "=", "UARTgetc", "(", ")", ";", "if", "(", "(", "ucChar", "==", "'", "\\b", "'", ")", "&&", "(", "ulIdx", "!=", "0", ")", ")", "{", "UARTprintf", "(", "\"", "\\b", "\\b", "\"", ")", ";", "ulIdx", "--", ";", "g_cCmdBuf", "[", "ulIdx", "]", "=", "'", "\\0", "'", ";", "}", "else", "if", "(", "(", "ucChar", "==", "'", "\\r", "'", ")", "||", "(", "ucChar", "==", "'", "\\n", "'", ")", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "return", ";", "}", "else", "if", "(", "(", "ucChar", "==", "0x1b", ")", "||", "(", "ucChar", "==", "0x15", ")", ")", "{", "while", "(", "ulIdx", ")", "{", "UARTprintf", "(", "\"", "\\b", "\\b", "\"", ")", ";", "ulIdx", "--", ";", "}", "g_cCmdBuf", "[", "0", "]", "=", "'", "\\0", "'", ";", "}", "else", "if", "(", "(", "ucChar", ">=", "'", "'", ")", "&&", "(", "ucChar", "<=", "'", "'", ")", "&&", "(", "ulIdx", "<", "(", "sizeof", "(", "g_cCmdBuf", ")", "-", "1", ")", ")", ")", "{", "g_cCmdBuf", "[", "ulIdx", "++", "]", "=", "ucChar", ";", "g_cCmdBuf", "[", "ulIdx", "]", "=", "'", "\\0", "'", ";", "UARTprintf", "(", "\"", "\"", ",", "ucChar", ")", ";", "}", "}", "USBOTGMain", "(", "GetTickms", "(", ")", ")", ";", "}", "}" ]
This function reads a line of text from the UART console.
[ "This", "function", "reads", "a", "line", "of", "text", "from", "the", "UART", "console", "." ]
[ "//\r", "// Start reading at the beginning of the command buffer and print a prompt.\r", "//\r", "//\r", "// Initialize the drive timeout.\r", "//\r", "//\r", "// Loop forever. This loop will be explicitly broken out of when the line\r", "// has been fully read.\r", "//\r", "//\r", "// See if a mass storage device has been enumerated.\r", "//\r", "//\r", "// Take it easy on the Mass storage device if it is slow to\r", "// start up after connecting.\r", "//\r", "//\r", "// Wait about 500ms before attempting to check if the\r", "// device is ready again.\r", "//\r", "//\r", "// Decrement the retry count.\r", "//\r", "//\r", "// If the timeout is hit then go to the\r", "// STATE_TIMEOUT_DEVICE state.\r", "//\r", "//\r", "// Reset the working directory to the root.\r", "//\r", "//\r", "// Attempt to open the directory. Some drives take longer to\r", "// start up than others, and this may fail (even though the USB\r", "// device has enumerated) if it is still initializing.\r", "//\r", "//\r", "// The drive is fully ready, so move to that state.\r", "//\r", "//\r", "// See if the state has changed. We make a copy of g_eUIState to\r", "// prevent a compiler warning about undefined order of volatile\r", "// accesses.\r", "//\r", "//\r", "// Determine the new state.\r", "//\r", "//\r", "// A previously connected device has been disconnected.\r", "//\r", "//\r", "// A mass storage device is being enumerated.\r", "//\r", "//\r", "// A mass storage device has been enumerated and initialized.\r", "//\r", "//\r", "// An unknown device has been connected.\r", "//\r", "//\r", "// The connected mass storage device is not reporting ready.\r", "//\r", "//\r", "// If this is the first time in this state then print a\r", "// message.\r", "//\r", "//\r", "// A power fault has occurred.\r", "//\r", "//\r", "// Save the current state.\r", "//\r", "//\r", "// Print a prompt if necessary.\r", "//\r", "//\r", "// Print the prompt based on the current state.\r", "//\r", "//\r", "// The prompt no longer needs to be printed.\r", "//\r", "//\r", "// Loop while there are characters that have been received from the\r", "// UART.\r", "//\r", "//\r", "// Read the next character from the UART.\r", "//\r", "//\r", "// See if this character is a backspace and there is at least one\r", "// character in the input line.\r", "//\r", "//\r", "// Erase the lsat character from the input line.\r", "//\r", "//\r", "// See if this character is a newline.\r", "//\r", "//\r", "// Return to the caller.\r", "//\r", "//\r", "// See if this character is an escape or Ctrl-U.\r", "//\r", "//\r", "// Erase all characters in the input buffer.\r", "//\r", "//\r", "// See if this is a printable ASCII character.\r", "//\r", "//\r", "// Add this character to the input buffer.\r", "//\r", "//\r", "// Tell the OTG state machine how much time has passed in\r", "// milliseconds since the last call.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBInit
void
void RGBInit(unsigned long ulEnable) { // // Enable the GPIO Port and Timer for each LED // SysCtlPeripheralEnable(RED_GPIO_PERIPH); SysCtlPeripheralEnable(RED_TIMER_PERIPH); SysCtlPeripheralEnable(GREEN_GPIO_PERIPH); SysCtlPeripheralEnable(GREEN_TIMER_PERIPH); SysCtlPeripheralEnable(BLUE_GPIO_PERIPH); SysCtlPeripheralEnable(BLUE_TIMER_PERIPH); // // Configure each timer for output mode // HWREG(GREEN_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(GREEN_TIMER_BASE + TIMER_O_TAMR) = 0x0A; HWREG(GREEN_TIMER_BASE + TIMER_O_TAILR) = 0xFFFF; HWREG(BLUE_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(BLUE_TIMER_BASE + TIMER_O_TBMR) = 0x0A; HWREG(BLUE_TIMER_BASE + TIMER_O_TBILR) = 0xFFFF; HWREG(RED_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(RED_TIMER_BASE + TIMER_O_TBMR) = 0x0A; HWREG(RED_TIMER_BASE + TIMER_O_TBILR) = 0xFFFF; // // Invert the output signals. // HWREG(RED_TIMER_BASE + TIMER_O_CTL) |= 0x4000; HWREG(GREEN_TIMER_BASE + TIMER_O_CTL) |= 0x40; HWREG(BLUE_TIMER_BASE + TIMER_O_CTL) |= 0x4000; if(ulEnable) { RGBEnable(); } }
//***************************************************************************** // //! Initializes the Timer and GPIO functionality associated with the RGB LED //! //! \param ulEnable enables RGB immediately if set. //! //! This function must be called during application initialization to //! configure the GPIO pins to which the LEDs are attached. It enables //! the port used by the LEDs and configures each color's Timer. It optionally //! enables the RGB LED by configuring the GPIO pins and starting the timers. //! //! \return None. // //*****************************************************************************
Initializes the Timer and GPIO functionality associated with the RGB LED \param ulEnable enables RGB immediately if set. This function must be called during application initialization to configure the GPIO pins to which the LEDs are attached. It enables the port used by the LEDs and configures each color's Timer. It optionally enables the RGB LED by configuring the GPIO pins and starting the timers. \return None.
[ "Initializes", "the", "Timer", "and", "GPIO", "functionality", "associated", "with", "the", "RGB", "LED", "\\", "param", "ulEnable", "enables", "RGB", "immediately", "if", "set", ".", "This", "function", "must", "be", "called", "during", "application", "initialization", "to", "configure", "the", "GPIO", "pins", "to", "which", "the", "LEDs", "are", "attached", ".", "It", "enables", "the", "port", "used", "by", "the", "LEDs", "and", "configures", "each", "color", "'", "s", "Timer", ".", "It", "optionally", "enables", "the", "RGB", "LED", "by", "configuring", "the", "GPIO", "pins", "and", "starting", "the", "timers", ".", "\\", "return", "None", "." ]
void RGBInit(unsigned long ulEnable) { Enable the GPIO Port and Timer for each LED SysCtlPeripheralEnable(RED_GPIO_PERIPH); SysCtlPeripheralEnable(RED_TIMER_PERIPH); SysCtlPeripheralEnable(GREEN_GPIO_PERIPH); SysCtlPeripheralEnable(GREEN_TIMER_PERIPH); SysCtlPeripheralEnable(BLUE_GPIO_PERIPH); SysCtlPeripheralEnable(BLUE_TIMER_PERIPH); Configure each timer for output mode HWREG(GREEN_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(GREEN_TIMER_BASE + TIMER_O_TAMR) = 0x0A; HWREG(GREEN_TIMER_BASE + TIMER_O_TAILR) = 0xFFFF; HWREG(BLUE_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(BLUE_TIMER_BASE + TIMER_O_TBMR) = 0x0A; HWREG(BLUE_TIMER_BASE + TIMER_O_TBILR) = 0xFFFF; HWREG(RED_TIMER_BASE + TIMER_O_CFG) = 0x04; HWREG(RED_TIMER_BASE + TIMER_O_TBMR) = 0x0A; HWREG(RED_TIMER_BASE + TIMER_O_TBILR) = 0xFFFF; Invert the output signals. HWREG(RED_TIMER_BASE + TIMER_O_CTL) |= 0x4000; HWREG(GREEN_TIMER_BASE + TIMER_O_CTL) |= 0x40; HWREG(BLUE_TIMER_BASE + TIMER_O_CTL) |= 0x4000; if(ulEnable) { RGBEnable(); } }
[ "void", "RGBInit", "(", "unsigned", "long", "ulEnable", ")", "{", "SysCtlPeripheralEnable", "(", "RED_GPIO_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "RED_TIMER_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "GREEN_GPIO_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "GREEN_TIMER_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "BLUE_GPIO_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "BLUE_TIMER_PERIPH", ")", ";", "HWREG", "(", "GREEN_TIMER_BASE", "+", "TIMER_O_CFG", ")", "=", "0x04", ";", "HWREG", "(", "GREEN_TIMER_BASE", "+", "TIMER_O_TAMR", ")", "=", "0x0A", ";", "HWREG", "(", "GREEN_TIMER_BASE", "+", "TIMER_O_TAILR", ")", "=", "0xFFFF", ";", "HWREG", "(", "BLUE_TIMER_BASE", "+", "TIMER_O_CFG", ")", "=", "0x04", ";", "HWREG", "(", "BLUE_TIMER_BASE", "+", "TIMER_O_TBMR", ")", "=", "0x0A", ";", "HWREG", "(", "BLUE_TIMER_BASE", "+", "TIMER_O_TBILR", ")", "=", "0xFFFF", ";", "HWREG", "(", "RED_TIMER_BASE", "+", "TIMER_O_CFG", ")", "=", "0x04", ";", "HWREG", "(", "RED_TIMER_BASE", "+", "TIMER_O_TBMR", ")", "=", "0x0A", ";", "HWREG", "(", "RED_TIMER_BASE", "+", "TIMER_O_TBILR", ")", "=", "0xFFFF", ";", "HWREG", "(", "RED_TIMER_BASE", "+", "TIMER_O_CTL", ")", "|=", "0x4000", ";", "HWREG", "(", "GREEN_TIMER_BASE", "+", "TIMER_O_CTL", ")", "|=", "0x40", ";", "HWREG", "(", "BLUE_TIMER_BASE", "+", "TIMER_O_CTL", ")", "|=", "0x4000", ";", "if", "(", "ulEnable", ")", "{", "RGBEnable", "(", ")", ";", "}", "}" ]
Initializes the Timer and GPIO functionality associated with the RGB LED \param ulEnable enables RGB immediately if set.
[ "Initializes", "the", "Timer", "and", "GPIO", "functionality", "associated", "with", "the", "RGB", "LED", "\\", "param", "ulEnable", "enables", "RGB", "immediately", "if", "set", "." ]
[ "//", "// Enable the GPIO Port and Timer for each LED", "//", "//", "// Configure each timer for output mode", "//", "//", "// Invert the output signals.", "//" ]
[ { "param": "ulEnable", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulEnable", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBEnable
void
void RGBEnable(void) { // // Enable timers to begin counting // TimerEnable(RED_TIMER_BASE, TIMER_BOTH); TimerEnable(GREEN_TIMER_BASE, TIMER_BOTH); TimerEnable(BLUE_TIMER_BASE, TIMER_BOTH); // // Reconfigure each LED's GPIO pad for timer control // GPIOPinConfigure(GREEN_GPIO_PIN_CFG); GPIOPinTypeTimer(GREEN_GPIO_BASE, GREEN_GPIO_PIN); GPIOPadConfigSet(GREEN_GPIO_BASE, GREEN_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); GPIOPinConfigure(BLUE_GPIO_PIN_CFG); GPIOPinTypeTimer(BLUE_GPIO_BASE, BLUE_GPIO_PIN); GPIOPadConfigSet(BLUE_GPIO_BASE, BLUE_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); GPIOPinConfigure(RED_GPIO_PIN_CFG); GPIOPinTypeTimer(RED_GPIO_BASE, RED_GPIO_PIN); GPIOPadConfigSet(RED_GPIO_BASE, RED_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); }
//***************************************************************************** // //! Enable the RGB LED with already configured timer settings //! //! This function or RGBDisable should be called during application //! initialization to configure the GPIO pins to which the LEDs are attached. //! This function enables the timers and configures the GPIO pins as timer //! outputs. //! //! \return None. // //*****************************************************************************
Enable the RGB LED with already configured timer settings This function or RGBDisable should be called during application initialization to configure the GPIO pins to which the LEDs are attached. This function enables the timers and configures the GPIO pins as timer outputs. \return None.
[ "Enable", "the", "RGB", "LED", "with", "already", "configured", "timer", "settings", "This", "function", "or", "RGBDisable", "should", "be", "called", "during", "application", "initialization", "to", "configure", "the", "GPIO", "pins", "to", "which", "the", "LEDs", "are", "attached", ".", "This", "function", "enables", "the", "timers", "and", "configures", "the", "GPIO", "pins", "as", "timer", "outputs", ".", "\\", "return", "None", "." ]
void RGBEnable(void) { Enable timers to begin counting TimerEnable(RED_TIMER_BASE, TIMER_BOTH); TimerEnable(GREEN_TIMER_BASE, TIMER_BOTH); TimerEnable(BLUE_TIMER_BASE, TIMER_BOTH); Reconfigure each LED's GPIO pad for timer control GPIOPinConfigure(GREEN_GPIO_PIN_CFG); GPIOPinTypeTimer(GREEN_GPIO_BASE, GREEN_GPIO_PIN); GPIOPadConfigSet(GREEN_GPIO_BASE, GREEN_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); GPIOPinConfigure(BLUE_GPIO_PIN_CFG); GPIOPinTypeTimer(BLUE_GPIO_BASE, BLUE_GPIO_PIN); GPIOPadConfigSet(BLUE_GPIO_BASE, BLUE_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); GPIOPinConfigure(RED_GPIO_PIN_CFG); GPIOPinTypeTimer(RED_GPIO_BASE, RED_GPIO_PIN); GPIOPadConfigSet(RED_GPIO_BASE, RED_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD); }
[ "void", "RGBEnable", "(", "void", ")", "{", "TimerEnable", "(", "RED_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "TimerEnable", "(", "GREEN_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "TimerEnable", "(", "BLUE_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "GPIOPinConfigure", "(", "GREEN_GPIO_PIN_CFG", ")", ";", "GPIOPinTypeTimer", "(", "GREEN_GPIO_BASE", ",", "GREEN_GPIO_PIN", ")", ";", "GPIOPadConfigSet", "(", "GREEN_GPIO_BASE", ",", "GREEN_GPIO_PIN", ",", "GPIO_STRENGTH_8MA_SC", ",", "GPIO_PIN_TYPE_STD", ")", ";", "GPIOPinConfigure", "(", "BLUE_GPIO_PIN_CFG", ")", ";", "GPIOPinTypeTimer", "(", "BLUE_GPIO_BASE", ",", "BLUE_GPIO_PIN", ")", ";", "GPIOPadConfigSet", "(", "BLUE_GPIO_BASE", ",", "BLUE_GPIO_PIN", ",", "GPIO_STRENGTH_8MA_SC", ",", "GPIO_PIN_TYPE_STD", ")", ";", "GPIOPinConfigure", "(", "RED_GPIO_PIN_CFG", ")", ";", "GPIOPinTypeTimer", "(", "RED_GPIO_BASE", ",", "RED_GPIO_PIN", ")", ";", "GPIOPadConfigSet", "(", "RED_GPIO_BASE", ",", "RED_GPIO_PIN", ",", "GPIO_STRENGTH_8MA_SC", ",", "GPIO_PIN_TYPE_STD", ")", ";", "}" ]
Enable the RGB LED with already configured timer settings This function or RGBDisable should be called during application initialization to configure the GPIO pins to which the LEDs are attached.
[ "Enable", "the", "RGB", "LED", "with", "already", "configured", "timer", "settings", "This", "function", "or", "RGBDisable", "should", "be", "called", "during", "application", "initialization", "to", "configure", "the", "GPIO", "pins", "to", "which", "the", "LEDs", "are", "attached", "." ]
[ "//", "// Enable timers to begin counting", "//", "//", "// Reconfigure each LED's GPIO pad for timer control", "//" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBDisable
void
void RGBDisable(void) { // // Configure the GPIO pads as general purpose inputs. // GPIOPinTypeGPIOInput(RED_GPIO_BASE, RED_GPIO_PIN); GPIOPinTypeGPIOInput(GREEN_GPIO_BASE, GREEN_GPIO_PIN); GPIOPinTypeGPIOInput(BLUE_GPIO_BASE, BLUE_GPIO_PIN); // // Stop the timer counting. // TimerDisable(RED_TIMER_BASE, TIMER_BOTH); TimerDisable(GREEN_TIMER_BASE, TIMER_BOTH); TimerDisable(BLUE_TIMER_BASE, TIMER_BOTH); }
//***************************************************************************** // //! Disable the RGB LED by configuring the GPIO's as inputs. //! //! This function or RGBEnable should be called during application //! initialization to configure the GPIO pins to which the LEDs are attached. //! This function disables the timers and configures the GPIO pins as inputs //! for minimum current draw. //! //! \return None. // //*****************************************************************************
Disable the RGB LED by configuring the GPIO's as inputs. This function or RGBEnable should be called during application initialization to configure the GPIO pins to which the LEDs are attached. This function disables the timers and configures the GPIO pins as inputs for minimum current draw. \return None.
[ "Disable", "the", "RGB", "LED", "by", "configuring", "the", "GPIO", "'", "s", "as", "inputs", ".", "This", "function", "or", "RGBEnable", "should", "be", "called", "during", "application", "initialization", "to", "configure", "the", "GPIO", "pins", "to", "which", "the", "LEDs", "are", "attached", ".", "This", "function", "disables", "the", "timers", "and", "configures", "the", "GPIO", "pins", "as", "inputs", "for", "minimum", "current", "draw", ".", "\\", "return", "None", "." ]
void RGBDisable(void) { Configure the GPIO pads as general purpose inputs. GPIOPinTypeGPIOInput(RED_GPIO_BASE, RED_GPIO_PIN); GPIOPinTypeGPIOInput(GREEN_GPIO_BASE, GREEN_GPIO_PIN); GPIOPinTypeGPIOInput(BLUE_GPIO_BASE, BLUE_GPIO_PIN); Stop the timer counting. TimerDisable(RED_TIMER_BASE, TIMER_BOTH); TimerDisable(GREEN_TIMER_BASE, TIMER_BOTH); TimerDisable(BLUE_TIMER_BASE, TIMER_BOTH); }
[ "void", "RGBDisable", "(", "void", ")", "{", "GPIOPinTypeGPIOInput", "(", "RED_GPIO_BASE", ",", "RED_GPIO_PIN", ")", ";", "GPIOPinTypeGPIOInput", "(", "GREEN_GPIO_BASE", ",", "GREEN_GPIO_PIN", ")", ";", "GPIOPinTypeGPIOInput", "(", "BLUE_GPIO_BASE", ",", "BLUE_GPIO_PIN", ")", ";", "TimerDisable", "(", "RED_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "TimerDisable", "(", "GREEN_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "TimerDisable", "(", "BLUE_TIMER_BASE", ",", "TIMER_BOTH", ")", ";", "}" ]
Disable the RGB LED by configuring the GPIO's as inputs.
[ "Disable", "the", "RGB", "LED", "by", "configuring", "the", "GPIO", "'", "s", "as", "inputs", "." ]
[ "//", "// Configure the GPIO pads as general purpose inputs.", "//", "//", "// Stop the timer counting.", "//" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBSet
void
void RGBSet(volatile unsigned long * pulRGBColor, float fIntensity) { RGBColorSet(pulRGBColor); RGBIntensitySet(fIntensity); }
//***************************************************************************** // //! Set the output color and intensity. //! //! \param pulRGBColor points to a three element array representing the //! relative intensity of each color. Red is element 0, Green is element 1, //! Blue is element 2. 0x0000 is off. 0xFFFF is fully on. //! //! \param fIntensity is used to scale the intensity of all three colors by //! the same amount. fIntensity should be between 0.0 and 1.0. This scale //! factor is applied to all three colors. //! //! This function should be called by the application to set the color and //! intensity of the RGB LED. //! //! \return None. // //*****************************************************************************
Set the output color and intensity. \param pulRGBColor points to a three element array representing the relative intensity of each color. Red is element 0, Green is element 1, Blue is element 2. \param fIntensity is used to scale the intensity of all three colors by the same amount. This function should be called by the application to set the color and intensity of the RGB LED. \return None.
[ "Set", "the", "output", "color", "and", "intensity", ".", "\\", "param", "pulRGBColor", "points", "to", "a", "three", "element", "array", "representing", "the", "relative", "intensity", "of", "each", "color", ".", "Red", "is", "element", "0", "Green", "is", "element", "1", "Blue", "is", "element", "2", ".", "\\", "param", "fIntensity", "is", "used", "to", "scale", "the", "intensity", "of", "all", "three", "colors", "by", "the", "same", "amount", ".", "This", "function", "should", "be", "called", "by", "the", "application", "to", "set", "the", "color", "and", "intensity", "of", "the", "RGB", "LED", ".", "\\", "return", "None", "." ]
void RGBSet(volatile unsigned long * pulRGBColor, float fIntensity) { RGBColorSet(pulRGBColor); RGBIntensitySet(fIntensity); }
[ "void", "RGBSet", "(", "volatile", "unsigned", "long", "*", "pulRGBColor", ",", "float", "fIntensity", ")", "{", "RGBColorSet", "(", "pulRGBColor", ")", ";", "RGBIntensitySet", "(", "fIntensity", ")", ";", "}" ]
Set the output color and intensity.
[ "Set", "the", "output", "color", "and", "intensity", "." ]
[]
[ { "param": "pulRGBColor", "type": "unsigned long" }, { "param": "fIntensity", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pulRGBColor", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fIntensity", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBColorSet
void
void RGBColorSet(volatile unsigned long * pulRGBColor) { unsigned long ulColor[3]; unsigned long ulIndex; for(ulIndex=0; ulIndex < 3; ulIndex++) { g_ulColors[ulIndex] = pulRGBColor[ulIndex]; ulColor[ulIndex] = (unsigned long) (((float) pulRGBColor[ulIndex]) * g_fIntensity + 0.5f); if(ulColor[ulIndex] > 0xFFFF) { ulColor[ulIndex] = 0xFFFF; } } TimerMatchSet(RED_TIMER_BASE, RED_TIMER, ulColor[RED]); TimerMatchSet(GREEN_TIMER_BASE, GREEN_TIMER, ulColor[GREEN]); TimerMatchSet(BLUE_TIMER_BASE, BLUE_TIMER, ulColor[BLUE]); }
//***************************************************************************** // //! Set the output color. //! //! \param pulRGBColor points to a three element array representing the //! relative intensity of each color. Red is element 0, Green is element 1, //! Blue is element 2. 0x0000 is off. 0xFFFF is fully on. //! //! This function should be called by the application to set the color //! of the RGB LED. //! //! \return None. // //*****************************************************************************
Set the output color. \param pulRGBColor points to a three element array representing the relative intensity of each color. Red is element 0, Green is element 1, Blue is element 2. This function should be called by the application to set the color of the RGB LED. \return None.
[ "Set", "the", "output", "color", ".", "\\", "param", "pulRGBColor", "points", "to", "a", "three", "element", "array", "representing", "the", "relative", "intensity", "of", "each", "color", ".", "Red", "is", "element", "0", "Green", "is", "element", "1", "Blue", "is", "element", "2", ".", "This", "function", "should", "be", "called", "by", "the", "application", "to", "set", "the", "color", "of", "the", "RGB", "LED", ".", "\\", "return", "None", "." ]
void RGBColorSet(volatile unsigned long * pulRGBColor) { unsigned long ulColor[3]; unsigned long ulIndex; for(ulIndex=0; ulIndex < 3; ulIndex++) { g_ulColors[ulIndex] = pulRGBColor[ulIndex]; ulColor[ulIndex] = (unsigned long) (((float) pulRGBColor[ulIndex]) * g_fIntensity + 0.5f); if(ulColor[ulIndex] > 0xFFFF) { ulColor[ulIndex] = 0xFFFF; } } TimerMatchSet(RED_TIMER_BASE, RED_TIMER, ulColor[RED]); TimerMatchSet(GREEN_TIMER_BASE, GREEN_TIMER, ulColor[GREEN]); TimerMatchSet(BLUE_TIMER_BASE, BLUE_TIMER, ulColor[BLUE]); }
[ "void", "RGBColorSet", "(", "volatile", "unsigned", "long", "*", "pulRGBColor", ")", "{", "unsigned", "long", "ulColor", "[", "3", "]", ";", "unsigned", "long", "ulIndex", ";", "for", "(", "ulIndex", "=", "0", ";", "ulIndex", "<", "3", ";", "ulIndex", "++", ")", "{", "g_ulColors", "[", "ulIndex", "]", "=", "pulRGBColor", "[", "ulIndex", "]", ";", "ulColor", "[", "ulIndex", "]", "=", "(", "unsigned", "long", ")", "(", "(", "(", "float", ")", "pulRGBColor", "[", "ulIndex", "]", ")", "*", "g_fIntensity", "+", "0.5f", ")", ";", "if", "(", "ulColor", "[", "ulIndex", "]", ">", "0xFFFF", ")", "{", "ulColor", "[", "ulIndex", "]", "=", "0xFFFF", ";", "}", "}", "TimerMatchSet", "(", "RED_TIMER_BASE", ",", "RED_TIMER", ",", "ulColor", "[", "RED", "]", ")", ";", "TimerMatchSet", "(", "GREEN_TIMER_BASE", ",", "GREEN_TIMER", ",", "ulColor", "[", "GREEN", "]", ")", ";", "TimerMatchSet", "(", "BLUE_TIMER_BASE", ",", "BLUE_TIMER", ",", "ulColor", "[", "BLUE", "]", ")", ";", "}" ]
Set the output color.
[ "Set", "the", "output", "color", "." ]
[]
[ { "param": "pulRGBColor", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pulRGBColor", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBIntensitySet
void
void RGBIntensitySet(float fIntensity) { g_fIntensity = fIntensity; RGBColorSet(g_ulColors); }
//***************************************************************************** // //! Set the current output intensity. //! //! \param fIntensity is used to scale the intensity of all three colors by //! the same amount. fIntensity should be between 0.0 and 1.0. This scale //! factor is applied individually to all three colors. //! //! This function should be called by the application to set the intensity //! of the RGB LED. //! //! \return None. // //*****************************************************************************
Set the current output intensity. \param fIntensity is used to scale the intensity of all three colors by the same amount. This function should be called by the application to set the intensity of the RGB LED. \return None.
[ "Set", "the", "current", "output", "intensity", ".", "\\", "param", "fIntensity", "is", "used", "to", "scale", "the", "intensity", "of", "all", "three", "colors", "by", "the", "same", "amount", ".", "This", "function", "should", "be", "called", "by", "the", "application", "to", "set", "the", "intensity", "of", "the", "RGB", "LED", ".", "\\", "return", "None", "." ]
void RGBIntensitySet(float fIntensity) { g_fIntensity = fIntensity; RGBColorSet(g_ulColors); }
[ "void", "RGBIntensitySet", "(", "float", "fIntensity", ")", "{", "g_fIntensity", "=", "fIntensity", ";", "RGBColorSet", "(", "g_ulColors", ")", ";", "}" ]
Set the current output intensity.
[ "Set", "the", "current", "output", "intensity", "." ]
[]
[ { "param": "fIntensity", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fIntensity", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b1305bbcb855eba2284388ab0a9a9af6cb84bf48
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f120xl/drivers/rgb.c
[ "BSD-3-Clause" ]
C
RGBColorGet
void
void RGBColorGet(unsigned long * pulRGBColor) { unsigned long ulIndex; for(ulIndex=0; ulIndex < 3; ulIndex++) { pulRGBColor[ulIndex] = g_ulColors[ulIndex]; } }
//***************************************************************************** // //! Get the output color. //! //! \param pulRGBColor points to a three element array representing the //! relative intensity of each color. Red is element 0, Green is element 1, //! Blue is element 2. 0x0000 is off. 0xFFFF is fully on. Caller must allocate //! and pass a pointer to a three element array of unsigned longs. //! //! This function should be called by the application to get the current color //! of the RGB LED. //! //! \return None. // //*****************************************************************************
Get the output color. \param pulRGBColor points to a three element array representing the relative intensity of each color. Red is element 0, Green is element 1, Blue is element 2. This function should be called by the application to get the current color of the RGB LED. \return None.
[ "Get", "the", "output", "color", ".", "\\", "param", "pulRGBColor", "points", "to", "a", "three", "element", "array", "representing", "the", "relative", "intensity", "of", "each", "color", ".", "Red", "is", "element", "0", "Green", "is", "element", "1", "Blue", "is", "element", "2", ".", "This", "function", "should", "be", "called", "by", "the", "application", "to", "get", "the", "current", "color", "of", "the", "RGB", "LED", ".", "\\", "return", "None", "." ]
void RGBColorGet(unsigned long * pulRGBColor) { unsigned long ulIndex; for(ulIndex=0; ulIndex < 3; ulIndex++) { pulRGBColor[ulIndex] = g_ulColors[ulIndex]; } }
[ "void", "RGBColorGet", "(", "unsigned", "long", "*", "pulRGBColor", ")", "{", "unsigned", "long", "ulIndex", ";", "for", "(", "ulIndex", "=", "0", ";", "ulIndex", "<", "3", ";", "ulIndex", "++", ")", "{", "pulRGBColor", "[", "ulIndex", "]", "=", "g_ulColors", "[", "ulIndex", "]", ";", "}", "}" ]
Get the output color.
[ "Get", "the", "output", "color", "." ]
[]
[ { "param": "pulRGBColor", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pulRGBColor", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8037636d66d93d69a726623e32f01684ce31fcc0
junyanl-code/Luminary-Micro-Library
SimpliciTI-1.1.1/Components/simpliciti/nwk_applications/nwk_link.c
[ "BSD-3-Clause" ]
C
nwk_setLinkToken
void
void nwk_setLinkToken(uint32_t token) { /* only set if the supplied token is non-zero. */ if (token) { sLinkToken = token; } return; }
/****************************************************************************** * @fn nwk_setLinkToken * * @brief Sets the link token received in a Join reply. * * input parameters * @param token - Link token to be used on this network to link to any peer. * * output parameters * * @return void */
@brief Sets the link token received in a Join reply. input parameters @param token - Link token to be used on this network to link to any peer. output parameters @return void
[ "@brief", "Sets", "the", "link", "token", "received", "in", "a", "Join", "reply", ".", "input", "parameters", "@param", "token", "-", "Link", "token", "to", "be", "used", "on", "this", "network", "to", "link", "to", "any", "peer", ".", "output", "parameters", "@return", "void" ]
void nwk_setLinkToken(uint32_t token) { if (token) { sLinkToken = token; } return; }
[ "void", "nwk_setLinkToken", "(", "uint32_t", "token", ")", "{", "if", "(", "token", ")", "{", "sLinkToken", "=", "token", ";", "}", "return", ";", "}" ]
@fn nwk_setLinkToken
[ "@fn", "nwk_setLinkToken" ]
[ "/* only set if the supplied token is non-zero. */" ]
[ { "param": "token", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8037636d66d93d69a726623e32f01684ce31fcc0
junyanl-code/Luminary-Micro-Library
SimpliciTI-1.1.1/Components/simpliciti/nwk_applications/nwk_link.c
[ "BSD-3-Clause" ]
C
nwk_unlink
smplStatus_t
smplStatus_t nwk_unlink(linkID_t lid) { uint8_t msg[UNLINK_FRAME_SIZE]; connInfo_t *pCInfo = nwk_getConnInfo(lid); smplStatus_t rc = SMPL_SUCCESS; addr_t addr; union { ioctlRawSend_t send; ioctlRawReceive_t recv; } ioctl_info; /* is there connection info? */ if (!pCInfo || (lid == SMPL_LINKID_USER_UUD)) { return SMPL_BAD_PARAM; } /* set request byte */ msg[LB_REQ_OS] = LINK_REQ_UNLINK; /* set the transaction ID. this allows target to figure out duplicates */ msg[LB_TID_OS] = sLinkTid; /* remote port to be sent in message to help match connection */ msg[UL_RMT_PORT_OS] = pCInfo->portRx; /* setup for ioctl raw I/O */ memcpy(addr.addr, pCInfo->peerAddr, NET_ADDR_SIZE); ioctl_info.send.addr = &addr; ioctl_info.send.msg = msg; ioctl_info.send.len = sizeof(msg); ioctl_info.send.port = SMPL_PORT_LINK; SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &ioctl_info.send); { uint8_t spin = NWK_RX_RETRY_COUNT; uint8_t radioState = MRFI_GetRadioState(); ioctl_info.recv.port = SMPL_PORT_LINK; ioctl_info.recv.msg = msg; ioctl_info.recv.addr = (addr_t *)0; do { NWK_CHECK_FOR_SETRX(radioState); NWK_REPLY_DELAY(); NWK_CHECK_FOR_RESTORE_STATE(radioState); if (SMPL_SUCCESS == SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, &ioctl_info.recv)) { if ((msg[LB_REQ_OS] & (~NWK_APP_REPLY_BIT)) == LINK_REQ_UNLINK) { rc = (smplStatus_t)msg[ULR_RESULT_OS]; break; } } if (!spin) { rc = SMPL_TIMEOUT; break; } --spin; } while (1); /* it's ok to unconditionally invalidate connection object */ nwk_freeConnection(pCInfo); } return rc; }
/****************************************************************************** * @fn nwk_unlink * * @brief Called from the application level to tear down a link. * * input parameters * * output parameters * @param lid - Link ID assigned for this link * * @return Status of the operation. * SMPL_SUCCESS * SMPL_BAD_PARAM No connection table entry for this Link ID; * SMPL_LINKID_USER_UUD not valid since it is not * connection-based. * SMPL_TIMEOUT No reply from peer. * SMPL_NO_PEER_UNLINK Peer did not have a Connection Table entry for me. */
@brief Called from the application level to tear down a link. input parameters output parameters @param lid - Link ID assigned for this link @return Status of the operation. SMPL_SUCCESS SMPL_BAD_PARAM No connection table entry for this Link ID; SMPL_LINKID_USER_UUD not valid since it is not connection-based. SMPL_TIMEOUT No reply from peer. SMPL_NO_PEER_UNLINK Peer did not have a Connection Table entry for me.
[ "@brief", "Called", "from", "the", "application", "level", "to", "tear", "down", "a", "link", ".", "input", "parameters", "output", "parameters", "@param", "lid", "-", "Link", "ID", "assigned", "for", "this", "link", "@return", "Status", "of", "the", "operation", ".", "SMPL_SUCCESS", "SMPL_BAD_PARAM", "No", "connection", "table", "entry", "for", "this", "Link", "ID", ";", "SMPL_LINKID_USER_UUD", "not", "valid", "since", "it", "is", "not", "connection", "-", "based", ".", "SMPL_TIMEOUT", "No", "reply", "from", "peer", ".", "SMPL_NO_PEER_UNLINK", "Peer", "did", "not", "have", "a", "Connection", "Table", "entry", "for", "me", "." ]
smplStatus_t nwk_unlink(linkID_t lid) { uint8_t msg[UNLINK_FRAME_SIZE]; connInfo_t *pCInfo = nwk_getConnInfo(lid); smplStatus_t rc = SMPL_SUCCESS; addr_t addr; union { ioctlRawSend_t send; ioctlRawReceive_t recv; } ioctl_info; if (!pCInfo || (lid == SMPL_LINKID_USER_UUD)) { return SMPL_BAD_PARAM; } msg[LB_REQ_OS] = LINK_REQ_UNLINK; msg[LB_TID_OS] = sLinkTid; msg[UL_RMT_PORT_OS] = pCInfo->portRx; memcpy(addr.addr, pCInfo->peerAddr, NET_ADDR_SIZE); ioctl_info.send.addr = &addr; ioctl_info.send.msg = msg; ioctl_info.send.len = sizeof(msg); ioctl_info.send.port = SMPL_PORT_LINK; SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &ioctl_info.send); { uint8_t spin = NWK_RX_RETRY_COUNT; uint8_t radioState = MRFI_GetRadioState(); ioctl_info.recv.port = SMPL_PORT_LINK; ioctl_info.recv.msg = msg; ioctl_info.recv.addr = (addr_t *)0; do { NWK_CHECK_FOR_SETRX(radioState); NWK_REPLY_DELAY(); NWK_CHECK_FOR_RESTORE_STATE(radioState); if (SMPL_SUCCESS == SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, &ioctl_info.recv)) { if ((msg[LB_REQ_OS] & (~NWK_APP_REPLY_BIT)) == LINK_REQ_UNLINK) { rc = (smplStatus_t)msg[ULR_RESULT_OS]; break; } } if (!spin) { rc = SMPL_TIMEOUT; break; } --spin; } while (1); nwk_freeConnection(pCInfo); } return rc; }
[ "smplStatus_t", "nwk_unlink", "(", "linkID_t", "lid", ")", "{", "uint8_t", "msg", "[", "UNLINK_FRAME_SIZE", "]", ";", "connInfo_t", "*", "pCInfo", "=", "nwk_getConnInfo", "(", "lid", ")", ";", "smplStatus_t", "rc", "=", "SMPL_SUCCESS", ";", "addr_t", "addr", ";", "union", "{", "ioctlRawSend_t", "send", ";", "ioctlRawReceive_t", "recv", ";", "}", "ioctl_info", ";", "if", "(", "!", "pCInfo", "||", "(", "lid", "==", "SMPL_LINKID_USER_UUD", ")", ")", "{", "return", "SMPL_BAD_PARAM", ";", "}", "msg", "[", "LB_REQ_OS", "]", "=", "LINK_REQ_UNLINK", ";", "msg", "[", "LB_TID_OS", "]", "=", "sLinkTid", ";", "msg", "[", "UL_RMT_PORT_OS", "]", "=", "pCInfo", "->", "portRx", ";", "memcpy", "(", "addr", ".", "addr", ",", "pCInfo", "->", "peerAddr", ",", "NET_ADDR_SIZE", ")", ";", "ioctl_info", ".", "send", ".", "addr", "=", "&", "addr", ";", "ioctl_info", ".", "send", ".", "msg", "=", "msg", ";", "ioctl_info", ".", "send", ".", "len", "=", "sizeof", "(", "msg", ")", ";", "ioctl_info", ".", "send", ".", "port", "=", "SMPL_PORT_LINK", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RAW_IO", ",", "IOCTL_ACT_WRITE", ",", "&", "ioctl_info", ".", "send", ")", ";", "{", "uint8_t", "spin", "=", "NWK_RX_RETRY_COUNT", ";", "uint8_t", "radioState", "=", "MRFI_GetRadioState", "(", ")", ";", "ioctl_info", ".", "recv", ".", "port", "=", "SMPL_PORT_LINK", ";", "ioctl_info", ".", "recv", ".", "msg", "=", "msg", ";", "ioctl_info", ".", "recv", ".", "addr", "=", "(", "addr_t", "*", ")", "0", ";", "do", "{", "NWK_CHECK_FOR_SETRX", "(", "radioState", ")", ";", "NWK_REPLY_DELAY", "(", ")", ";", "NWK_CHECK_FOR_RESTORE_STATE", "(", "radioState", ")", ";", "if", "(", "SMPL_SUCCESS", "==", "SMPL_Ioctl", "(", "IOCTL_OBJ_RAW_IO", ",", "IOCTL_ACT_READ", ",", "&", "ioctl_info", ".", "recv", ")", ")", "{", "if", "(", "(", "msg", "[", "LB_REQ_OS", "]", "&", "(", "~", "NWK_APP_REPLY_BIT", ")", ")", "==", "LINK_REQ_UNLINK", ")", "{", "rc", "=", "(", "smplStatus_t", ")", "msg", "[", "ULR_RESULT_OS", "]", ";", "break", ";", "}", "}", "if", "(", "!", "spin", ")", "{", "rc", "=", "SMPL_TIMEOUT", ";", "break", ";", "}", "--", "spin", ";", "}", "while", "(", "1", ")", ";", "nwk_freeConnection", "(", "pCInfo", ")", ";", "}", "return", "rc", ";", "}" ]
@fn nwk_unlink
[ "@fn", "nwk_unlink" ]
[ "/* is there connection info? */", "/* set request byte */", "/* set the transaction ID. this allows target to figure out duplicates */", "/* remote port to be sent in message to help match connection */", "/* setup for ioctl raw I/O */", "/* it's ok to unconditionally invalidate connection object */" ]
[ { "param": "lid", "type": "linkID_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lid", "type": "linkID_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8037636d66d93d69a726623e32f01684ce31fcc0
junyanl-code/Luminary-Micro-Library
SimpliciTI-1.1.1/Components/simpliciti/nwk_applications/nwk_link.c
[ "BSD-3-Clause" ]
C
nwk_link
smplStatus_t
smplStatus_t nwk_link(linkID_t *lid) { uint8_t msg[LINK_FRAME_SIZE]; connInfo_t *pCInfo = nwk_getNextConnection(); smplStatus_t rc; if (pCInfo) { addr_t addr; union { ioctlRawSend_t send; ioctlRawReceive_t recv; } ioctl_info; if (!nwk_allocateLocalRxPort(LINK_SEND, pCInfo)) { nwk_freeConnection(pCInfo); return SMPL_NOMEM; } memcpy(addr.addr, nwk_getBCastAddress(), NET_ADDR_SIZE); ioctl_info.send.addr = &addr; ioctl_info.send.msg = msg; ioctl_info.send.len = sizeof(msg); ioctl_info.send.port = SMPL_PORT_LINK; /* Put link token in */ nwk_putNumObjectIntoMsg((void *)&sLinkToken, msg+L_LINK_TOKEN_OS, sizeof(sLinkToken)); /* set port to which the remote device should send */ msg[L_RMT_PORT_OS] = pCInfo->portRx; /* set the transaction ID. this allows target to figure out duplicates */ msg[LB_TID_OS] = sLinkTid; /* set my Rx type */ msg[L_MY_RXTYPE_OS] = nwk_getMyRxType(); /* set request byte */ msg[LB_REQ_OS] = LINK_REQ_LINK; /* protocol version number */ msg[L_PROTOCOL_VERSION_OS] = nwk_getProtocolVersion(); #if defined(SMPL_SECURE) pCInfo->connTxCTR = MRFI_RandomByte() | \ ((uint32_t)(MRFI_RandomByte())<<8) | \ ((uint32_t)(MRFI_RandomByte())<<16) | \ ((uint32_t)(MRFI_RandomByte())<<24); nwk_putNumObjectIntoMsg((void *)&pCInfo->connTxCTR, (void *)&msg[L_CTR_OS], 4); #endif if (SMPL_SUCCESS != (rc=SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &ioctl_info.send))) { return rc; } { uint8_t radioState = MRFI_GetRadioState(); ioctl_info.recv.port = SMPL_PORT_LINK; ioctl_info.recv.msg = msg; ioctl_info.recv.addr = (addr_t *)pCInfo->peerAddr; NWK_CHECK_FOR_SETRX(radioState); NWK_REPLY_DELAY(); NWK_CHECK_FOR_RESTORE_STATE(radioState); if (SMPL_SUCCESS == SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, &ioctl_info.recv)) { uint8_t firstByte = msg[LB_REQ_OS] & (~NWK_APP_REPLY_BIT); /* Sanity check for correct reply frame. Older version * has the length instead of the request as the first byte. */ if ((firstByte != LINK_REQ_LINK) && (firstByte != LINK_REPLY_LEGACY_MSG_LENGTH) ) { /* invalidate connection object */ nwk_freeConnection(pCInfo); return SMPL_NO_LINK; } } else { /* no successful receive */ nwk_freeConnection(pCInfo); return SMPL_TIMEOUT; } pCInfo->connState = CONNSTATE_CONNECTED; pCInfo->portTx = msg[LR_RMT_PORT_OS]; /* link reply returns remote port */ *lid = pCInfo->thisLinkID; /* return our local port number */ /* Set hop count. If it's a polling device set the count to the * distance to the AP. Otherwise, set it to the max less the remaining * which will be the path taken for this frame. It will be no worse * then tha max and probably will be better. */ if (F_RX_TYPE_POLLS == msg[LR_MY_RXTYPE_OS]) { pCInfo->hops2target = MAX_HOPS_FROM_AP; } else { /* Can't really use this trick because the device could move. If the * devices are all static this may work unless the initial reception * was marginal. */ #if defined(DEVICE_DOES_NOT_MOVE) pCInfo->hops2target = MAX_HOPS - ioctl_info.recv.hopCount; #else pCInfo->hops2target = MAX_HOPS; #endif } #if defined(SMPL_SECURE) nwk_getNumObjectFromMsg((void *)&msg[LR_CTR_OS], (void *)&pCInfo->connRxCTR, 4); #endif } /* guard against duplicates... */ ++sLinkTid; if (!sLinkTid) { sLinkTid = 1; } return SMPL_SUCCESS; } return SMPL_NOMEM; }
/****************************************************************************** * @fn nwk_link * * @brief Called from the application level to accomplish the link * * input parameters * * output parameters * @param lid - pointer to Link ID (port) assigned for this link * * @return Status of the operation. */
@brief Called from the application level to accomplish the link input parameters output parameters @param lid - pointer to Link ID (port) assigned for this link @return Status of the operation.
[ "@brief", "Called", "from", "the", "application", "level", "to", "accomplish", "the", "link", "input", "parameters", "output", "parameters", "@param", "lid", "-", "pointer", "to", "Link", "ID", "(", "port", ")", "assigned", "for", "this", "link", "@return", "Status", "of", "the", "operation", "." ]
smplStatus_t nwk_link(linkID_t *lid) { uint8_t msg[LINK_FRAME_SIZE]; connInfo_t *pCInfo = nwk_getNextConnection(); smplStatus_t rc; if (pCInfo) { addr_t addr; union { ioctlRawSend_t send; ioctlRawReceive_t recv; } ioctl_info; if (!nwk_allocateLocalRxPort(LINK_SEND, pCInfo)) { nwk_freeConnection(pCInfo); return SMPL_NOMEM; } memcpy(addr.addr, nwk_getBCastAddress(), NET_ADDR_SIZE); ioctl_info.send.addr = &addr; ioctl_info.send.msg = msg; ioctl_info.send.len = sizeof(msg); ioctl_info.send.port = SMPL_PORT_LINK; nwk_putNumObjectIntoMsg((void *)&sLinkToken, msg+L_LINK_TOKEN_OS, sizeof(sLinkToken)); msg[L_RMT_PORT_OS] = pCInfo->portRx; msg[LB_TID_OS] = sLinkTid; msg[L_MY_RXTYPE_OS] = nwk_getMyRxType(); msg[LB_REQ_OS] = LINK_REQ_LINK; msg[L_PROTOCOL_VERSION_OS] = nwk_getProtocolVersion(); #if defined(SMPL_SECURE) pCInfo->connTxCTR = MRFI_RandomByte() | \ ((uint32_t)(MRFI_RandomByte())<<8) | \ ((uint32_t)(MRFI_RandomByte())<<16) | \ ((uint32_t)(MRFI_RandomByte())<<24); nwk_putNumObjectIntoMsg((void *)&pCInfo->connTxCTR, (void *)&msg[L_CTR_OS], 4); #endif if (SMPL_SUCCESS != (rc=SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &ioctl_info.send))) { return rc; } { uint8_t radioState = MRFI_GetRadioState(); ioctl_info.recv.port = SMPL_PORT_LINK; ioctl_info.recv.msg = msg; ioctl_info.recv.addr = (addr_t *)pCInfo->peerAddr; NWK_CHECK_FOR_SETRX(radioState); NWK_REPLY_DELAY(); NWK_CHECK_FOR_RESTORE_STATE(radioState); if (SMPL_SUCCESS == SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, &ioctl_info.recv)) { uint8_t firstByte = msg[LB_REQ_OS] & (~NWK_APP_REPLY_BIT); if ((firstByte != LINK_REQ_LINK) && (firstByte != LINK_REPLY_LEGACY_MSG_LENGTH) ) { nwk_freeConnection(pCInfo); return SMPL_NO_LINK; } } else { nwk_freeConnection(pCInfo); return SMPL_TIMEOUT; } pCInfo->connState = CONNSTATE_CONNECTED; pCInfo->portTx = msg[LR_RMT_PORT_OS]; *lid = pCInfo->thisLinkID; if (F_RX_TYPE_POLLS == msg[LR_MY_RXTYPE_OS]) { pCInfo->hops2target = MAX_HOPS_FROM_AP; } else { #if defined(DEVICE_DOES_NOT_MOVE) pCInfo->hops2target = MAX_HOPS - ioctl_info.recv.hopCount; #else pCInfo->hops2target = MAX_HOPS; #endif } #if defined(SMPL_SECURE) nwk_getNumObjectFromMsg((void *)&msg[LR_CTR_OS], (void *)&pCInfo->connRxCTR, 4); #endif } ++sLinkTid; if (!sLinkTid) { sLinkTid = 1; } return SMPL_SUCCESS; } return SMPL_NOMEM; }
[ "smplStatus_t", "nwk_link", "(", "linkID_t", "*", "lid", ")", "{", "uint8_t", "msg", "[", "LINK_FRAME_SIZE", "]", ";", "connInfo_t", "*", "pCInfo", "=", "nwk_getNextConnection", "(", ")", ";", "smplStatus_t", "rc", ";", "if", "(", "pCInfo", ")", "{", "addr_t", "addr", ";", "union", "{", "ioctlRawSend_t", "send", ";", "ioctlRawReceive_t", "recv", ";", "}", "ioctl_info", ";", "if", "(", "!", "nwk_allocateLocalRxPort", "(", "LINK_SEND", ",", "pCInfo", ")", ")", "{", "nwk_freeConnection", "(", "pCInfo", ")", ";", "return", "SMPL_NOMEM", ";", "}", "memcpy", "(", "addr", ".", "addr", ",", "nwk_getBCastAddress", "(", ")", ",", "NET_ADDR_SIZE", ")", ";", "ioctl_info", ".", "send", ".", "addr", "=", "&", "addr", ";", "ioctl_info", ".", "send", ".", "msg", "=", "msg", ";", "ioctl_info", ".", "send", ".", "len", "=", "sizeof", "(", "msg", ")", ";", "ioctl_info", ".", "send", ".", "port", "=", "SMPL_PORT_LINK", ";", "nwk_putNumObjectIntoMsg", "(", "(", "void", "*", ")", "&", "sLinkToken", ",", "msg", "+", "L_LINK_TOKEN_OS", ",", "sizeof", "(", "sLinkToken", ")", ")", ";", "msg", "[", "L_RMT_PORT_OS", "]", "=", "pCInfo", "->", "portRx", ";", "msg", "[", "LB_TID_OS", "]", "=", "sLinkTid", ";", "msg", "[", "L_MY_RXTYPE_OS", "]", "=", "nwk_getMyRxType", "(", ")", ";", "msg", "[", "LB_REQ_OS", "]", "=", "LINK_REQ_LINK", ";", "msg", "[", "L_PROTOCOL_VERSION_OS", "]", "=", "nwk_getProtocolVersion", "(", ")", ";", "#if", "defined", "(", "SMPL_SECURE", ")", "\n", "pCInfo", "->", "connTxCTR", "=", "MRFI_RandomByte", "(", ")", "|", "(", "(", "uint32_t", ")", "(", "MRFI_RandomByte", "(", ")", ")", "<<", "8", ")", "|", "(", "(", "uint32_t", ")", "(", "MRFI_RandomByte", "(", ")", ")", "<<", "16", ")", "|", "(", "(", "uint32_t", ")", "(", "MRFI_RandomByte", "(", ")", ")", "<<", "24", ")", ";", "nwk_putNumObjectIntoMsg", "(", "(", "void", "*", ")", "&", "pCInfo", "->", "connTxCTR", ",", "(", "void", "*", ")", "&", "msg", "[", "L_CTR_OS", "]", ",", "4", ")", ";", "#endif", "if", "(", "SMPL_SUCCESS", "!=", "(", "rc", "=", "SMPL_Ioctl", "(", "IOCTL_OBJ_RAW_IO", ",", "IOCTL_ACT_WRITE", ",", "&", "ioctl_info", ".", "send", ")", ")", ")", "{", "return", "rc", ";", "}", "{", "uint8_t", "radioState", "=", "MRFI_GetRadioState", "(", ")", ";", "ioctl_info", ".", "recv", ".", "port", "=", "SMPL_PORT_LINK", ";", "ioctl_info", ".", "recv", ".", "msg", "=", "msg", ";", "ioctl_info", ".", "recv", ".", "addr", "=", "(", "addr_t", "*", ")", "pCInfo", "->", "peerAddr", ";", "NWK_CHECK_FOR_SETRX", "(", "radioState", ")", ";", "NWK_REPLY_DELAY", "(", ")", ";", "NWK_CHECK_FOR_RESTORE_STATE", "(", "radioState", ")", ";", "if", "(", "SMPL_SUCCESS", "==", "SMPL_Ioctl", "(", "IOCTL_OBJ_RAW_IO", ",", "IOCTL_ACT_READ", ",", "&", "ioctl_info", ".", "recv", ")", ")", "{", "uint8_t", "firstByte", "=", "msg", "[", "LB_REQ_OS", "]", "&", "(", "~", "NWK_APP_REPLY_BIT", ")", ";", "if", "(", "(", "firstByte", "!=", "LINK_REQ_LINK", ")", "&&", "(", "firstByte", "!=", "LINK_REPLY_LEGACY_MSG_LENGTH", ")", ")", "{", "nwk_freeConnection", "(", "pCInfo", ")", ";", "return", "SMPL_NO_LINK", ";", "}", "}", "else", "{", "nwk_freeConnection", "(", "pCInfo", ")", ";", "return", "SMPL_TIMEOUT", ";", "}", "pCInfo", "->", "connState", "=", "CONNSTATE_CONNECTED", ";", "pCInfo", "->", "portTx", "=", "msg", "[", "LR_RMT_PORT_OS", "]", ";", "*", "lid", "=", "pCInfo", "->", "thisLinkID", ";", "if", "(", "F_RX_TYPE_POLLS", "==", "msg", "[", "LR_MY_RXTYPE_OS", "]", ")", "{", "pCInfo", "->", "hops2target", "=", "MAX_HOPS_FROM_AP", ";", "}", "else", "{", "#if", "defined", "(", "DEVICE_DOES_NOT_MOVE", ")", "\n", "pCInfo", "->", "hops2target", "=", "MAX_HOPS", "-", "ioctl_info", ".", "recv", ".", "hopCount", ";", "#else", "pCInfo", "->", "hops2target", "=", "MAX_HOPS", ";", "#endif", "}", "#if", "defined", "(", "SMPL_SECURE", ")", "\n", "nwk_getNumObjectFromMsg", "(", "(", "void", "*", ")", "&", "msg", "[", "LR_CTR_OS", "]", ",", "(", "void", "*", ")", "&", "pCInfo", "->", "connRxCTR", ",", "4", ")", ";", "#endif", "}", "++", "sLinkTid", ";", "if", "(", "!", "sLinkTid", ")", "{", "sLinkTid", "=", "1", ";", "}", "return", "SMPL_SUCCESS", ";", "}", "return", "SMPL_NOMEM", ";", "}" ]
@fn nwk_link
[ "@fn", "nwk_link" ]
[ "/* Put link token in */", "/* set port to which the remote device should send */", "/* set the transaction ID. this allows target to figure out duplicates */", "/* set my Rx type */", "/* set request byte */", "/* protocol version number */", "/* Sanity check for correct reply frame. Older version\r\n * has the length instead of the request as the first byte.\r\n */", "/* invalidate connection object */", "/* no successful receive */", "/* link reply returns remote port */", "/* return our local port number */", "/* Set hop count. If it's a polling device set the count to the\r\n * distance to the AP. Otherwise, set it to the max less the remaining\r\n * which will be the path taken for this frame. It will be no worse\r\n * then tha max and probably will be better.\r\n */", "/* Can't really use this trick because the device could move. If the\r\n * devices are all static this may work unless the initial reception\r\n * was marginal.\r\n */", "/* guard against duplicates... */" ]
[ { "param": "lid", "type": "linkID_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lid", "type": "linkID_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8037636d66d93d69a726623e32f01684ce31fcc0
junyanl-code/Luminary-Micro-Library
SimpliciTI-1.1.1/Components/simpliciti/nwk_applications/nwk_link.c
[ "BSD-3-Clause" ]
C
smpl_send_unlink_reply
void
static void smpl_send_unlink_reply(mrfiPacket_t *frame) { connInfo_t *pCInfo; frameInfo_t *pOutFrame; uint8_t msg[UNLINK_REPLY_FRAME_SIZE]; smplStatus_t rc = SMPL_NO_PEER_UNLINK; /* match the remote port and source address with a connection table entry */ pCInfo = nwk_findPeer((addr_t *)MRFI_P_SRC_ADDR(frame), *(MRFI_P_PAYLOAD(frame)+F_APP_PAYLOAD_OS+UL_RMT_PORT_OS)); if (pCInfo) { /* Note we unconditionally free the connection resources */ nwk_freeConnection(pCInfo); rc = SMPL_SUCCESS; } /* set reply bit */ msg[LB_REQ_OS] = LINK_REQ_UNLINK | NWK_APP_REPLY_BIT; /* sender's TID */ msg[LB_TID_OS] = *(MRFI_P_PAYLOAD(frame)+F_APP_PAYLOAD_OS+LB_TID_OS); /* result of freeing local connection */ msg[ULR_RESULT_OS] = rc; pOutFrame = nwk_buildFrame(SMPL_PORT_LINK, msg, sizeof(msg), MAX_HOPS); if (pOutFrame) { /* destination address is the source adddress of the received frame. */ memcpy(MRFI_P_DST_ADDR(&pOutFrame->mrfiPkt), MRFI_P_SRC_ADDR(frame), NET_ADDR_SIZE); #if defined(SMPL_SECURE) nwk_setSecureFrame(&pOutFrame->mrfiPkt, sizeof(msg), 0); #endif /* SMPL_SECURE */ nwk_sendFrame(pOutFrame, MRFI_TX_TYPE_FORCED); } }
/****************************************************************************** * @fn smpl_send_unlink_reply * * @brief Send the unlink reply to the device trying to unlink * * input parameters * @param frame - frame received from linker * * output parameters * * @return void */
@brief Send the unlink reply to the device trying to unlink input parameters @param frame - frame received from linker output parameters @return void
[ "@brief", "Send", "the", "unlink", "reply", "to", "the", "device", "trying", "to", "unlink", "input", "parameters", "@param", "frame", "-", "frame", "received", "from", "linker", "output", "parameters", "@return", "void" ]
static void smpl_send_unlink_reply(mrfiPacket_t *frame) { connInfo_t *pCInfo; frameInfo_t *pOutFrame; uint8_t msg[UNLINK_REPLY_FRAME_SIZE]; smplStatus_t rc = SMPL_NO_PEER_UNLINK; pCInfo = nwk_findPeer((addr_t *)MRFI_P_SRC_ADDR(frame), *(MRFI_P_PAYLOAD(frame)+F_APP_PAYLOAD_OS+UL_RMT_PORT_OS)); if (pCInfo) { nwk_freeConnection(pCInfo); rc = SMPL_SUCCESS; } msg[LB_REQ_OS] = LINK_REQ_UNLINK | NWK_APP_REPLY_BIT; msg[LB_TID_OS] = *(MRFI_P_PAYLOAD(frame)+F_APP_PAYLOAD_OS+LB_TID_OS); msg[ULR_RESULT_OS] = rc; pOutFrame = nwk_buildFrame(SMPL_PORT_LINK, msg, sizeof(msg), MAX_HOPS); if (pOutFrame) { memcpy(MRFI_P_DST_ADDR(&pOutFrame->mrfiPkt), MRFI_P_SRC_ADDR(frame), NET_ADDR_SIZE); #if defined(SMPL_SECURE) nwk_setSecureFrame(&pOutFrame->mrfiPkt, sizeof(msg), 0); #endif nwk_sendFrame(pOutFrame, MRFI_TX_TYPE_FORCED); } }
[ "static", "void", "smpl_send_unlink_reply", "(", "mrfiPacket_t", "*", "frame", ")", "{", "connInfo_t", "*", "pCInfo", ";", "frameInfo_t", "*", "pOutFrame", ";", "uint8_t", "msg", "[", "UNLINK_REPLY_FRAME_SIZE", "]", ";", "smplStatus_t", "rc", "=", "SMPL_NO_PEER_UNLINK", ";", "pCInfo", "=", "nwk_findPeer", "(", "(", "addr_t", "*", ")", "MRFI_P_SRC_ADDR", "(", "frame", ")", ",", "*", "(", "MRFI_P_PAYLOAD", "(", "frame", ")", "+", "F_APP_PAYLOAD_OS", "+", "UL_RMT_PORT_OS", ")", ")", ";", "if", "(", "pCInfo", ")", "{", "nwk_freeConnection", "(", "pCInfo", ")", ";", "rc", "=", "SMPL_SUCCESS", ";", "}", "msg", "[", "LB_REQ_OS", "]", "=", "LINK_REQ_UNLINK", "|", "NWK_APP_REPLY_BIT", ";", "msg", "[", "LB_TID_OS", "]", "=", "*", "(", "MRFI_P_PAYLOAD", "(", "frame", ")", "+", "F_APP_PAYLOAD_OS", "+", "LB_TID_OS", ")", ";", "msg", "[", "ULR_RESULT_OS", "]", "=", "rc", ";", "pOutFrame", "=", "nwk_buildFrame", "(", "SMPL_PORT_LINK", ",", "msg", ",", "sizeof", "(", "msg", ")", ",", "MAX_HOPS", ")", ";", "if", "(", "pOutFrame", ")", "{", "memcpy", "(", "MRFI_P_DST_ADDR", "(", "&", "pOutFrame", "->", "mrfiPkt", ")", ",", "MRFI_P_SRC_ADDR", "(", "frame", ")", ",", "NET_ADDR_SIZE", ")", ";", "#if", "defined", "(", "SMPL_SECURE", ")", "\n", "nwk_setSecureFrame", "(", "&", "pOutFrame", "->", "mrfiPkt", ",", "sizeof", "(", "msg", ")", ",", "0", ")", ";", "#endif", "nwk_sendFrame", "(", "pOutFrame", ",", "MRFI_TX_TYPE_FORCED", ")", ";", "}", "}" ]
@fn smpl_send_unlink_reply
[ "@fn", "smpl_send_unlink_reply" ]
[ "/* match the remote port and source address with a connection table entry */", "/* Note we unconditionally free the connection resources */", "/* set reply bit */", "/* sender's TID */", "/* result of freeing local connection */", "/* destination address is the source adddress of the received frame. */", "/* SMPL_SECURE */" ]
[ { "param": "frame", "type": "mrfiPacket_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "frame", "type": "mrfiPacket_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8037636d66d93d69a726623e32f01684ce31fcc0
junyanl-code/Luminary-Micro-Library
SimpliciTI-1.1.1/Components/simpliciti/nwk_applications/nwk_link.c
[ "BSD-3-Clause" ]
C
nwk_getLocalLinkID
linkID_t
linkID_t nwk_getLocalLinkID(void) { linkID_t lid = 0; #if NUM_CONNECTIONS > 0 uint8_t i; bspIState_t intState; BSP_ENTER_CRITICAL_SECTION(intState); if (sNumLinkers) { sNumLinkers--; BSP_EXIT_CRITICAL_SECTION(intState); nwk_setListenContext(LINK_LISTEN_OFF); lid = sServiceLinkID[0]; /* If more than one Link frame has been processed without an intervening * Listen assume that there will be another Link Listen call that will * poll for completion which has already occurred. Age any existing entries. * This code was added to deal with the possibility of mulitple EDs being * activated simultaneously in the AP-as-data-hub example. This opens a * window of opportunity for a "typical" scenario to get hosed. But for * a "typical" scenario to get hosed a number of improbable events have to * occur. These are deemed far less likely than the multiple-ED-activation * scenario in the AP-as-dat-hub case. */ for (i=0; i<sNumLinkers; ++i) { sServiceLinkID[i] = sServiceLinkID[i+1]; } } else { BSP_EXIT_CRITICAL_SECTION(intState); } #endif /* NUM_CONNECTIONS */ return lid; }
/****************************************************************************** * @fn nwk_getLocalLinkID * * @brief This routine checks to see if a service port has been assigned * as a result of a link reply frame being received. It is the means * by which the user thread knows that the waiting is over for the * link listen. the value is set in an interrupt thread. * * input parameters * * output parameters * * @return Local port assigned when the link reply was received. */
@brief This routine checks to see if a service port has been assigned as a result of a link reply frame being received. It is the means by which the user thread knows that the waiting is over for the link listen. the value is set in an interrupt thread. input parameters output parameters @return Local port assigned when the link reply was received.
[ "@brief", "This", "routine", "checks", "to", "see", "if", "a", "service", "port", "has", "been", "assigned", "as", "a", "result", "of", "a", "link", "reply", "frame", "being", "received", ".", "It", "is", "the", "means", "by", "which", "the", "user", "thread", "knows", "that", "the", "waiting", "is", "over", "for", "the", "link", "listen", ".", "the", "value", "is", "set", "in", "an", "interrupt", "thread", ".", "input", "parameters", "output", "parameters", "@return", "Local", "port", "assigned", "when", "the", "link", "reply", "was", "received", "." ]
linkID_t nwk_getLocalLinkID(void) { linkID_t lid = 0; #if NUM_CONNECTIONS > 0 uint8_t i; bspIState_t intState; BSP_ENTER_CRITICAL_SECTION(intState); if (sNumLinkers) { sNumLinkers--; BSP_EXIT_CRITICAL_SECTION(intState); nwk_setListenContext(LINK_LISTEN_OFF); lid = sServiceLinkID[0]; for (i=0; i<sNumLinkers; ++i) { sServiceLinkID[i] = sServiceLinkID[i+1]; } } else { BSP_EXIT_CRITICAL_SECTION(intState); } #endif return lid; }
[ "linkID_t", "nwk_getLocalLinkID", "(", "void", ")", "{", "linkID_t", "lid", "=", "0", ";", "#if", "NUM_CONNECTIONS", ">", "0", "\n", "uint8_t", "i", ";", "bspIState_t", "intState", ";", "BSP_ENTER_CRITICAL_SECTION", "(", "intState", ")", ";", "if", "(", "sNumLinkers", ")", "{", "sNumLinkers", "--", ";", "BSP_EXIT_CRITICAL_SECTION", "(", "intState", ")", ";", "nwk_setListenContext", "(", "LINK_LISTEN_OFF", ")", ";", "lid", "=", "sServiceLinkID", "[", "0", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "sNumLinkers", ";", "++", "i", ")", "{", "sServiceLinkID", "[", "i", "]", "=", "sServiceLinkID", "[", "i", "+", "1", "]", ";", "}", "}", "else", "{", "BSP_EXIT_CRITICAL_SECTION", "(", "intState", ")", ";", "}", "#endif", "return", "lid", ";", "}" ]
@fn nwk_getLocalLinkID
[ "@fn", "nwk_getLocalLinkID" ]
[ "/* If more than one Link frame has been processed without an intervening\r\n * Listen assume that there will be another Link Listen call that will\r\n * poll for completion which has already occurred. Age any existing entries.\r\n * This code was added to deal with the possibility of mulitple EDs being\r\n * activated simultaneously in the AP-as-data-hub example. This opens a\r\n * window of opportunity for a \"typical\" scenario to get hosed. But for\r\n * a \"typical\" scenario to get hosed a number of improbable events have to\r\n * occur. These are deemed far less likely than the multiple-ED-activation\r\n * scenario in the AP-as-dat-hub case.\r\n */", "/* NUM_CONNECTIONS */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c99a0817d081e8d9eb7d1e1cb0065bd0dbf07610
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/softuart_echo/softuart_echo.c
[ "BSD-3-Clause" ]
C
Timer0AIntHandler
void
void Timer0AIntHandler(void) { // // Clear the timer interrupt. // ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // // Call the SoftUART transmit timer tick function. // SoftUARTTxTimerTick(&g_sUART); }
//***************************************************************************** // // The interrupt handler for the SoftUART transmit timer interrupt. // //*****************************************************************************
The interrupt handler for the SoftUART transmit timer interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "transmit", "timer", "interrupt", "." ]
void Timer0AIntHandler(void) { ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); SoftUARTTxTimerTick(&g_sUART); }
[ "void", "Timer0AIntHandler", "(", "void", ")", "{", "ROM_TimerIntClear", "(", "TIMER0_BASE", ",", "TIMER_TIMA_TIMEOUT", ")", ";", "SoftUARTTxTimerTick", "(", "&", "g_sUART", ")", ";", "}" ]
The interrupt handler for the SoftUART transmit timer interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "transmit", "timer", "interrupt", "." ]
[ "//\r", "// Clear the timer interrupt.\r", "//\r", "//\r", "// Call the SoftUART transmit timer tick function.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c99a0817d081e8d9eb7d1e1cb0065bd0dbf07610
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/softuart_echo/softuart_echo.c
[ "BSD-3-Clause" ]
C
Timer0BIntHandler
void
void Timer0BIntHandler(void) { // // Clear the timer interrupt. // ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT); // // Call the SoftUART receive timer tick function, and see if the timer // should be disabled. // if(SoftUARTRxTick(&g_sUART, false) == SOFTUART_RXTIMER_END) { // // Disable the timer interrupt since the SoftUART doesn't need it any // longer. // ROM_TimerDisable(TIMER0_BASE, TIMER_B); } }
//***************************************************************************** // // The interrupt handler for the SoftUART receive timer interrupt. // //*****************************************************************************
The interrupt handler for the SoftUART receive timer interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "receive", "timer", "interrupt", "." ]
void Timer0BIntHandler(void) { ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT); if(SoftUARTRxTick(&g_sUART, false) == SOFTUART_RXTIMER_END) { ROM_TimerDisable(TIMER0_BASE, TIMER_B); } }
[ "void", "Timer0BIntHandler", "(", "void", ")", "{", "ROM_TimerIntClear", "(", "TIMER0_BASE", ",", "TIMER_TIMB_TIMEOUT", ")", ";", "if", "(", "SoftUARTRxTick", "(", "&", "g_sUART", ",", "false", ")", "==", "SOFTUART_RXTIMER_END", ")", "{", "ROM_TimerDisable", "(", "TIMER0_BASE", ",", "TIMER_B", ")", ";", "}", "}" ]
The interrupt handler for the SoftUART receive timer interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "receive", "timer", "interrupt", "." ]
[ "//\r", "// Clear the timer interrupt.\r", "//\r", "//\r", "// Call the SoftUART receive timer tick function, and see if the timer\r", "// should be disabled.\r", "//\r", "//\r", "// Disable the timer interrupt since the SoftUART doesn't need it any\r", "// longer.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c99a0817d081e8d9eb7d1e1cb0065bd0dbf07610
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/softuart_echo/softuart_echo.c
[ "BSD-3-Clause" ]
C
GPIOAIntHandler
void
void GPIOAIntHandler(void) { // // Configure the SoftUART receive timer so that it will sample at the // mid-bit time of this character. // ROM_TimerDisable(TIMER0_BASE, TIMER_B); ROM_TimerLoadSet(TIMER0_BASE, TIMER_B, g_ulBitTime); ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT); ROM_TimerEnable(TIMER0_BASE, TIMER_B); // // Call the SoftUART receive timer tick function. // SoftUARTRxTick(&g_sUART, true); }
//***************************************************************************** // // The interrupt handler for the SoftUART GPIO edge interrupt. // //*****************************************************************************
The interrupt handler for the SoftUART GPIO edge interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "GPIO", "edge", "interrupt", "." ]
void GPIOAIntHandler(void) { ROM_TimerDisable(TIMER0_BASE, TIMER_B); ROM_TimerLoadSet(TIMER0_BASE, TIMER_B, g_ulBitTime); ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT); ROM_TimerEnable(TIMER0_BASE, TIMER_B); SoftUARTRxTick(&g_sUART, true); }
[ "void", "GPIOAIntHandler", "(", "void", ")", "{", "ROM_TimerDisable", "(", "TIMER0_BASE", ",", "TIMER_B", ")", ";", "ROM_TimerLoadSet", "(", "TIMER0_BASE", ",", "TIMER_B", ",", "g_ulBitTime", ")", ";", "ROM_TimerIntClear", "(", "TIMER0_BASE", ",", "TIMER_TIMB_TIMEOUT", ")", ";", "ROM_TimerEnable", "(", "TIMER0_BASE", ",", "TIMER_B", ")", ";", "SoftUARTRxTick", "(", "&", "g_sUART", ",", "true", ")", ";", "}" ]
The interrupt handler for the SoftUART GPIO edge interrupt.
[ "The", "interrupt", "handler", "for", "the", "SoftUART", "GPIO", "edge", "interrupt", "." ]
[ "//\r", "// Configure the SoftUART receive timer so that it will sample at the\r", "// mid-bit time of this character.\r", "//\r", "//\r", "// Call the SoftUART receive timer tick function.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c99a0817d081e8d9eb7d1e1cb0065bd0dbf07610
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9b90/softuart_echo/softuart_echo.c
[ "BSD-3-Clause" ]
C
UARTSend
void
void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { // // Loop while there are more characters to send. // while(ulCount--) { // // Write the next character to the UART. // SoftUARTCharPut(&g_sUART, *pucBuffer++); } }
//***************************************************************************** // // Send a string to the UART. // //*****************************************************************************
Send a string to the UART.
[ "Send", "a", "string", "to", "the", "UART", "." ]
void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { while(ulCount--) { SoftUARTCharPut(&g_sUART, *pucBuffer++); } }
[ "void", "UARTSend", "(", "const", "unsigned", "char", "*", "pucBuffer", ",", "unsigned", "long", "ulCount", ")", "{", "while", "(", "ulCount", "--", ")", "{", "SoftUARTCharPut", "(", "&", "g_sUART", ",", "*", "pucBuffer", "++", ")", ";", "}", "}" ]
Send a string to the UART.
[ "Send", "a", "string", "to", "the", "UART", "." ]
[ "//\r", "// Loop while there are more characters to send.\r", "//\r", "//\r", "// Write the next character to the UART.\r", "//\r" ]
[ { "param": "pucBuffer", "type": "unsigned char" }, { "param": "ulCount", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pucBuffer", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulCount", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f53c7c01bd4d02f5af4528379d176ad6464235e
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/idm-checkout/idm-checkout.c
[ "BSD-3-Clause" ]
C
OnCheckLED
void
void OnCheckLED(tWidget *pWidget, unsigned long bSelected) { // // Set the state of the user LED on the board to follow the checkbox // selection. // ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, bSelected ? 0 : GPIO_PIN_2); // // Play the key click sound. // SoundPlay(g_pusKeyClick, g_ulKeyClickLen); }
//***************************************************************************** // // The LED checkbox widget callback function. // // This function is called whenever someone clicks the "LED" checkbox. // //*****************************************************************************
The LED checkbox widget callback function. This function is called whenever someone clicks the "LED" checkbox.
[ "The", "LED", "checkbox", "widget", "callback", "function", ".", "This", "function", "is", "called", "whenever", "someone", "clicks", "the", "\"", "LED", "\"", "checkbox", "." ]
void OnCheckLED(tWidget *pWidget, unsigned long bSelected) { ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, bSelected ? 0 : GPIO_PIN_2); SoundPlay(g_pusKeyClick, g_ulKeyClickLen); }
[ "void", "OnCheckLED", "(", "tWidget", "*", "pWidget", ",", "unsigned", "long", "bSelected", ")", "{", "ROM_GPIOPinWrite", "(", "GPIO_PORTF_BASE", ",", "GPIO_PIN_2", ",", "bSelected", "?", "0", ":", "GPIO_PIN_2", ")", ";", "SoundPlay", "(", "g_pusKeyClick", ",", "g_ulKeyClickLen", ")", ";", "}" ]
The LED checkbox widget callback function.
[ "The", "LED", "checkbox", "widget", "callback", "function", "." ]
[ "//\r", "// Set the state of the user LED on the board to follow the checkbox\r", "// selection.\r", "//\r", "//\r", "// Play the key click sound.\r", "//\r" ]
[ { "param": "pWidget", "type": "tWidget" }, { "param": "bSelected", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pWidget", "type": "tWidget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bSelected", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f53c7c01bd4d02f5af4528379d176ad6464235e
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/idm-checkout/idm-checkout.c
[ "BSD-3-Clause" ]
C
SysTickHandler
void
void SysTickHandler(void) { // // Update our system timer counter. // g_ulSysTickCount++; // // Call the lwIP timer. // lwIPTimer(1000 / TICKS_PER_SECOND); // // Call the file system tick timer. // fs_tick(1000 / TICKS_PER_SECOND); // // Update the touchscreen information on the display if necessary. // if(g_ulTouchUpdateTicks == 0) { // // Ask the main loop to update the touch count. // g_ulCommandFlags |= COMMAND_TOUCH_UPDATE; // // Reload the tick counter for the next update. // g_ulTouchUpdateTicks = TOUCH_UPDATE_TICKS; } else { // // Decrement the timer we use to determine when to update the touch // info on the display. // g_ulTouchUpdateTicks --; } }
//***************************************************************************** // // This is the handler for this SysTick interrupt. FatFs requires a // timer tick every 10 ms for internal timing purposes. // //*****************************************************************************
This is the handler for this SysTick interrupt. FatFs requires a timer tick every 10 ms for internal timing purposes.
[ "This", "is", "the", "handler", "for", "this", "SysTick", "interrupt", ".", "FatFs", "requires", "a", "timer", "tick", "every", "10", "ms", "for", "internal", "timing", "purposes", "." ]
void SysTickHandler(void) { g_ulSysTickCount++; lwIPTimer(1000 / TICKS_PER_SECOND); fs_tick(1000 / TICKS_PER_SECOND); if(g_ulTouchUpdateTicks == 0) { g_ulCommandFlags |= COMMAND_TOUCH_UPDATE; g_ulTouchUpdateTicks = TOUCH_UPDATE_TICKS; } else { g_ulTouchUpdateTicks --; } }
[ "void", "SysTickHandler", "(", "void", ")", "{", "g_ulSysTickCount", "++", ";", "lwIPTimer", "(", "1000", "/", "TICKS_PER_SECOND", ")", ";", "fs_tick", "(", "1000", "/", "TICKS_PER_SECOND", ")", ";", "if", "(", "g_ulTouchUpdateTicks", "==", "0", ")", "{", "g_ulCommandFlags", "|=", "COMMAND_TOUCH_UPDATE", ";", "g_ulTouchUpdateTicks", "=", "TOUCH_UPDATE_TICKS", ";", "}", "else", "{", "g_ulTouchUpdateTicks", "--", ";", "}", "}" ]
This is the handler for this SysTick interrupt.
[ "This", "is", "the", "handler", "for", "this", "SysTick", "interrupt", "." ]
[ "//\r", "// Update our system timer counter.\r", "//\r", "//\r", "// Call the lwIP timer.\r", "//\r", "//\r", "// Call the file system tick timer.\r", "//\r", "//\r", "// Update the touchscreen information on the display if necessary.\r", "//\r", "//\r", "// Ask the main loop to update the touch count.\r", "//\r", "//\r", "// Reload the tick counter for the next update.\r", "//\r", "//\r", "// Decrement the timer we use to determine when to update the touch\r", "// info on the display.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
9f53c7c01bd4d02f5af4528379d176ad6464235e
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/idm-checkout/idm-checkout.c
[ "BSD-3-Clause" ]
C
CheckoutPointerMessage
null
long CheckoutPointerMessage(unsigned long ulMessage, long lX, long lY) { // // Save the current touch position. // g_lPtrX = lX; g_lPtrY = lY; // // Determine whether the screen has been pressed or released. // g_bPtrPressed = (ulMessage == WIDGET_MSG_PTR_UP) ? false : true; // // Pass the message on to the widget library. // return(WidgetPointerMessage(ulMessage, lX, lY)); }
//***************************************************************************** // // Intercept messages in flow from the touchscreen driver to the widget manager. // This function allows the application to track the current pointer position // and state before passing this on to the widget manager. // //*****************************************************************************
Intercept messages in flow from the touchscreen driver to the widget manager. This function allows the application to track the current pointer position and state before passing this on to the widget manager.
[ "Intercept", "messages", "in", "flow", "from", "the", "touchscreen", "driver", "to", "the", "widget", "manager", ".", "This", "function", "allows", "the", "application", "to", "track", "the", "current", "pointer", "position", "and", "state", "before", "passing", "this", "on", "to", "the", "widget", "manager", "." ]
long CheckoutPointerMessage(unsigned long ulMessage, long lX, long lY) { g_lPtrX = lX; g_lPtrY = lY; g_bPtrPressed = (ulMessage == WIDGET_MSG_PTR_UP) ? false : true; return(WidgetPointerMessage(ulMessage, lX, lY)); }
[ "long", "CheckoutPointerMessage", "(", "unsigned", "long", "ulMessage", ",", "long", "lX", ",", "long", "lY", ")", "{", "g_lPtrX", "=", "lX", ";", "g_lPtrY", "=", "lY", ";", "g_bPtrPressed", "=", "(", "ulMessage", "==", "WIDGET_MSG_PTR_UP", ")", "?", "false", ":", "true", ";", "return", "(", "WidgetPointerMessage", "(", "ulMessage", ",", "lX", ",", "lY", ")", ")", ";", "}" ]
Intercept messages in flow from the touchscreen driver to the widget manager.
[ "Intercept", "messages", "in", "flow", "from", "the", "touchscreen", "driver", "to", "the", "widget", "manager", "." ]
[ "//\r", "// Save the current touch position.\r", "//\r", "//\r", "// Determine whether the screen has been pressed or released.\r", "//\r", "//\r", "// Pass the message on to the widget library.\r", "//\r" ]
[ { "param": "ulMessage", "type": "unsigned long" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulMessage", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f53c7c01bd4d02f5af4528379d176ad6464235e
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/idm-checkout/idm-checkout.c
[ "BSD-3-Clause" ]
C
UpdateMouseWidgets
void
static void UpdateMouseWidgets(unsigned long ulFlags) { tBoolean bConnected; // // Was a mouse connected or disconnected? // if(ulFlags & MOUSE_FLAG_CONNECTION) { // // The connection state changed. Was this a connection or a // disconnection? // bConnected = USBMouseIsConnected(); // // Are we connected to something? // if(bConnected) { // // Update the display with the current mode. // CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_HOST]); // // Update the mode string if it is visible. // if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sModeString); } // // Force ourselves to update the position and button states. // ulFlags |= (MOUSE_FLAG_POSITION | MOUSE_FLAG_BUTTONS); // // Update the status. // PrintfStatus("Mouse connected."); } else { // // Update the status. // PrintfStatus("Mouse disconnected."); // // No mouse is connected. // CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_NONE]); CanvasImageSet(&g_sMouseBtn1, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn2, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn3, g_pucGreyLED14x14Image); // // Disable the mouse position and button indicators. // g_pcMousePos[0] = (char)0; if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); WidgetPaint((tWidget *)&g_sMouseBtn1); WidgetPaint((tWidget *)&g_sMouseBtn2); WidgetPaint((tWidget *)&g_sMouseBtn3); WidgetPaint((tWidget *)&g_sModeString); } // // Return here since we obviously can't have pointer movement or // button presses if there's no mouse connected. // return; } } // // Has the position changed? // if(ulFlags & MOUSE_FLAG_POSITION) { short sX, sY; // // Yes - redraw the position string. // USBMouseHostPositionGet(&sX, &sY); usnprintf(g_pcMousePos, MAX_MOUSE_POS_LEN, "(%d, %d) ", sX, sY); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); } } // // Did the state of any button change? // if(ulFlags & MOUSE_FLAG_BUTTONS) { unsigned long ulButtons; // // Yes - redraw the button state indicators. // ulButtons = USBMouseHostButtonsGet(); // // Set the state of the button 1 indicator. // CanvasImageSet(&g_sMouseBtn1, ((ulButtons & MOUSE_BTN_1) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn1); } // // Set the state of the button 2 indicator. // CanvasImageSet(&g_sMouseBtn2, ((ulButtons & MOUSE_BTN_2) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn2); } // // Set the state of the button 3 indicator. // CanvasImageSet(&g_sMouseBtn3, ((ulButtons & MOUSE_BTN_3) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn3); } } }
//***************************************************************************** // // Update the various widgets on the screen which indicate the state of the // USB mouse. // //*****************************************************************************
Update the various widgets on the screen which indicate the state of the USB mouse.
[ "Update", "the", "various", "widgets", "on", "the", "screen", "which", "indicate", "the", "state", "of", "the", "USB", "mouse", "." ]
static void UpdateMouseWidgets(unsigned long ulFlags) { tBoolean bConnected; if(ulFlags & MOUSE_FLAG_CONNECTION) { bConnected = USBMouseIsConnected(); if(bConnected) { CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_HOST]); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sModeString); } ulFlags |= (MOUSE_FLAG_POSITION | MOUSE_FLAG_BUTTONS); PrintfStatus("Mouse connected."); } else { PrintfStatus("Mouse disconnected."); CanvasTextSet(&g_sModeString, g_pcMouseModes[MOUSE_MODE_STR_NONE]); CanvasImageSet(&g_sMouseBtn1, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn2, g_pucGreyLED14x14Image); CanvasImageSet(&g_sMouseBtn3, g_pucGreyLED14x14Image); g_pcMousePos[0] = (char)0; if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); WidgetPaint((tWidget *)&g_sMouseBtn1); WidgetPaint((tWidget *)&g_sMouseBtn2); WidgetPaint((tWidget *)&g_sMouseBtn3); WidgetPaint((tWidget *)&g_sModeString); } return; } } if(ulFlags & MOUSE_FLAG_POSITION) { short sX, sY; USBMouseHostPositionGet(&sX, &sY); usnprintf(g_pcMousePos, MAX_MOUSE_POS_LEN, "(%d, %d) ", sX, sY); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMousePos); } } if(ulFlags & MOUSE_FLAG_BUTTONS) { unsigned long ulButtons; ulButtons = USBMouseHostButtonsGet(); CanvasImageSet(&g_sMouseBtn1, ((ulButtons & MOUSE_BTN_1) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn1); } CanvasImageSet(&g_sMouseBtn2, ((ulButtons & MOUSE_BTN_2) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn2); } CanvasImageSet(&g_sMouseBtn3, ((ulButtons & MOUSE_BTN_3) ? g_pucGreenLED14x14Image : g_pucRedLED14x14Image)); if(g_ulCurrentScreen == IO_SCREEN) { WidgetPaint((tWidget *)&g_sMouseBtn3); } } }
[ "static", "void", "UpdateMouseWidgets", "(", "unsigned", "long", "ulFlags", ")", "{", "tBoolean", "bConnected", ";", "if", "(", "ulFlags", "&", "MOUSE_FLAG_CONNECTION", ")", "{", "bConnected", "=", "USBMouseIsConnected", "(", ")", ";", "if", "(", "bConnected", ")", "{", "CanvasTextSet", "(", "&", "g_sModeString", ",", "g_pcMouseModes", "[", "MOUSE_MODE_STR_HOST", "]", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sModeString", ")", ";", "}", "ulFlags", "|=", "(", "MOUSE_FLAG_POSITION", "|", "MOUSE_FLAG_BUTTONS", ")", ";", "PrintfStatus", "(", "\"", "\"", ")", ";", "}", "else", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "CanvasTextSet", "(", "&", "g_sModeString", ",", "g_pcMouseModes", "[", "MOUSE_MODE_STR_NONE", "]", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn1", ",", "g_pucGreyLED14x14Image", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn2", ",", "g_pucGreyLED14x14Image", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn3", ",", "g_pucGreyLED14x14Image", ")", ";", "g_pcMousePos", "[", "0", "]", "=", "(", "char", ")", "0", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMousePos", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn1", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn2", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn3", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sModeString", ")", ";", "}", "return", ";", "}", "}", "if", "(", "ulFlags", "&", "MOUSE_FLAG_POSITION", ")", "{", "short", "sX", ",", "sY", ";", "USBMouseHostPositionGet", "(", "&", "sX", ",", "&", "sY", ")", ";", "usnprintf", "(", "g_pcMousePos", ",", "MAX_MOUSE_POS_LEN", ",", "\"", "\"", ",", "sX", ",", "sY", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMousePos", ")", ";", "}", "}", "if", "(", "ulFlags", "&", "MOUSE_FLAG_BUTTONS", ")", "{", "unsigned", "long", "ulButtons", ";", "ulButtons", "=", "USBMouseHostButtonsGet", "(", ")", ";", "CanvasImageSet", "(", "&", "g_sMouseBtn1", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_1", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn1", ")", ";", "}", "CanvasImageSet", "(", "&", "g_sMouseBtn2", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_2", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn2", ")", ";", "}", "CanvasImageSet", "(", "&", "g_sMouseBtn3", ",", "(", "(", "ulButtons", "&", "MOUSE_BTN_3", ")", "?", "g_pucGreenLED14x14Image", ":", "g_pucRedLED14x14Image", ")", ")", ";", "if", "(", "g_ulCurrentScreen", "==", "IO_SCREEN", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sMouseBtn3", ")", ";", "}", "}", "}" ]
Update the various widgets on the screen which indicate the state of the USB mouse.
[ "Update", "the", "various", "widgets", "on", "the", "screen", "which", "indicate", "the", "state", "of", "the", "USB", "mouse", "." ]
[ "//\r", "// Was a mouse connected or disconnected?\r", "//\r", "//\r", "// The connection state changed. Was this a connection or a\r", "// disconnection?\r", "//\r", "//\r", "// Are we connected to something?\r", "//\r", "//\r", "// Update the display with the current mode.\r", "//\r", "//\r", "// Update the mode string if it is visible.\r", "//\r", "//\r", "// Force ourselves to update the position and button states.\r", "//\r", "//\r", "// Update the status.\r", "//\r", "//\r", "// Update the status.\r", "//\r", "//\r", "// No mouse is connected.\r", "//\r", "//\r", "// Disable the mouse position and button indicators.\r", "//\r", "//\r", "// Return here since we obviously can't have pointer movement or\r", "// button presses if there's no mouse connected.\r", "//\r", "//\r", "// Has the position changed?\r", "//\r", "//\r", "// Yes - redraw the position string.\r", "//\r", "//\r", "// Did the state of any button change?\r", "//\r", "//\r", "// Yes - redraw the button state indicators.\r", "//\r", "//\r", "// Set the state of the button 1 indicator.\r", "//\r", "//\r", "// Set the state of the button 2 indicator.\r", "//\r", "//\r", "// Set the state of the button 3 indicator.\r", "//\r" ]
[ { "param": "ulFlags", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulFlags", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f53c7c01bd4d02f5af4528379d176ad6464235e
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/idm-checkout/idm-checkout.c
[ "BSD-3-Clause" ]
C
ProcessMainFunctionCommands
void
void ProcessMainFunctionCommands(void) { if(g_ulCommandFlags & COMMAND_TOUCH_UPDATE) { ProcessCommandTouchUpdate(); g_ulCommandFlags &= ~COMMAND_TOUCH_UPDATE; } }
//***************************************************************************** // // Process any commands that the main function has been sent from other // functions or interrupts. // //*****************************************************************************
Process any commands that the main function has been sent from other functions or interrupts.
[ "Process", "any", "commands", "that", "the", "main", "function", "has", "been", "sent", "from", "other", "functions", "or", "interrupts", "." ]
void ProcessMainFunctionCommands(void) { if(g_ulCommandFlags & COMMAND_TOUCH_UPDATE) { ProcessCommandTouchUpdate(); g_ulCommandFlags &= ~COMMAND_TOUCH_UPDATE; } }
[ "void", "ProcessMainFunctionCommands", "(", "void", ")", "{", "if", "(", "g_ulCommandFlags", "&", "COMMAND_TOUCH_UPDATE", ")", "{", "ProcessCommandTouchUpdate", "(", ")", ";", "g_ulCommandFlags", "&=", "~", "COMMAND_TOUCH_UPDATE", ";", "}", "}" ]
Process any commands that the main function has been sent from other functions or interrupts.
[ "Process", "any", "commands", "that", "the", "main", "function", "has", "been", "sent", "from", "other", "functions", "or", "interrupts", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b10c82e5af8fceb129915b9d192638704a866bb4
junyanl-code/Luminary-Micro-Library
boards/mdl-lm4f211cncd/uart_echo/uart_echo.c
[ "BSD-3-Clause" ]
C
UARTSend
void
void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { // // Loop while there are more characters to send. // while(ulCount--) { // // Write the next character to the UART. // ROM_UARTCharPutNonBlocking(UART1_BASE, *pucBuffer++); } }
//***************************************************************************** // // Send a string to the UART. // //*****************************************************************************
Send a string to the UART.
[ "Send", "a", "string", "to", "the", "UART", "." ]
void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { Loop while there are more characters to send. while(ulCount--) { Write the next character to the UART. ROM_UARTCharPutNonBlocking(UART1_BASE, *pucBuffer++); } }
[ "void", "UARTSend", "(", "const", "unsigned", "char", "*", "pucBuffer", ",", "unsigned", "long", "ulCount", ")", "{", "while", "(", "ulCount", "--", ")", "{", "ROM_UARTCharPutNonBlocking", "(", "UART1_BASE", ",", "*", "pucBuffer", "++", ")", ";", "}", "}" ]
Send a string to the UART.
[ "Send", "a", "string", "to", "the", "UART", "." ]
[ "//", "// Loop while there are more characters to send.", "//", "//", "// Write the next character to the UART.", "//" ]
[ { "param": "pucBuffer", "type": "unsigned char" }, { "param": "ulCount", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pucBuffer", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulCount", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a2647ef71aeab11005929c4f9faa6149eded3f4a
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-l35/sd_card/sd_card.c
[ "BSD-3-Clause" ]
C
OnListBoxChange
void
void OnListBoxChange(tWidget *pWidget, short usSelected) { short sSelected; // // Get the current selection from the list box. // sSelected = ListBoxSelectionGet(&g_sDirList); // // Is there any selection? // if(sSelected == -1) { return; } else { // // Is the selection a directory name? // if(g_pcFilenames[sSelected][1] == 'D') { // // Enable the "CD" button. // WidgetAdd((tWidget *)&g_sCDBackground, (tWidget *)&g_sCDBtn); } else { // // Hide the "CD" button. // WidgetRemove((tWidget *)&g_sCDBtn); } // // Make sure the CD button (or its background) is drawn correctly. // WidgetPaint((tWidget *)&g_sCDBackground); } // // Update the status display to say what we've done. // PrintfStatus("Selected %s %s\n", (g_pcFilenames[sSelected][1] == 'D') ? "dir" : "file", &g_pcFilenames[sSelected][4]); }
//***************************************************************************** // // The listbox widget callback function. // // This function is called whenever someone changes the selected entry in the // listbox containing the files and directories found in the current directory. // //*****************************************************************************
The listbox widget callback function. This function is called whenever someone changes the selected entry in the listbox containing the files and directories found in the current directory.
[ "The", "listbox", "widget", "callback", "function", ".", "This", "function", "is", "called", "whenever", "someone", "changes", "the", "selected", "entry", "in", "the", "listbox", "containing", "the", "files", "and", "directories", "found", "in", "the", "current", "directory", "." ]
void OnListBoxChange(tWidget *pWidget, short usSelected) { short sSelected; sSelected = ListBoxSelectionGet(&g_sDirList); if(sSelected == -1) { return; } else { if(g_pcFilenames[sSelected][1] == 'D') { WidgetAdd((tWidget *)&g_sCDBackground, (tWidget *)&g_sCDBtn); } else { WidgetRemove((tWidget *)&g_sCDBtn); } WidgetPaint((tWidget *)&g_sCDBackground); } PrintfStatus("Selected %s %s\n", (g_pcFilenames[sSelected][1] == 'D') ? "dir" : "file", &g_pcFilenames[sSelected][4]); }
[ "void", "OnListBoxChange", "(", "tWidget", "*", "pWidget", ",", "short", "usSelected", ")", "{", "short", "sSelected", ";", "sSelected", "=", "ListBoxSelectionGet", "(", "&", "g_sDirList", ")", ";", "if", "(", "sSelected", "==", "-1", ")", "{", "return", ";", "}", "else", "{", "if", "(", "g_pcFilenames", "[", "sSelected", "]", "[", "1", "]", "==", "'", "'", ")", "{", "WidgetAdd", "(", "(", "tWidget", "*", ")", "&", "g_sCDBackground", ",", "(", "tWidget", "*", ")", "&", "g_sCDBtn", ")", ";", "}", "else", "{", "WidgetRemove", "(", "(", "tWidget", "*", ")", "&", "g_sCDBtn", ")", ";", "}", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sCDBackground", ")", ";", "}", "PrintfStatus", "(", "\"", "\\n", "\"", ",", "(", "g_pcFilenames", "[", "sSelected", "]", "[", "1", "]", "==", "'", "'", ")", "?", "\"", "\"", ":", "\"", "\"", ",", "&", "g_pcFilenames", "[", "sSelected", "]", "[", "4", "]", ")", ";", "}" ]
The listbox widget callback function.
[ "The", "listbox", "widget", "callback", "function", "." ]
[ "//\r", "// Get the current selection from the list box.\r", "//\r", "//\r", "// Is there any selection?\r", "//\r", "//\r", "// Is the selection a directory name?\r", "//\r", "//\r", "// Enable the \"CD\" button.\r", "//\r", "//\r", "// Hide the \"CD\" button.\r", "//\r", "//\r", "// Make sure the CD button (or its background) is drawn correctly.\r", "//\r", "//\r", "// Update the status display to say what we've done.\r", "//\r" ]
[ { "param": "pWidget", "type": "tWidget" }, { "param": "usSelected", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pWidget", "type": "tWidget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "usSelected", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a2647ef71aeab11005929c4f9faa6149eded3f4a
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-l35/sd_card/sd_card.c
[ "BSD-3-Clause" ]
C
Cmd_ls
int
int Cmd_ls(int argc, char *argv[]) { unsigned long ulTotalSize, ulItemCount, ulFileCount, ulDirCount; FRESULT fresult; FATFS *pFatFs; // // Empty the list box on the display. // ListBoxClear(&g_sDirList); // // Make sure the list box will be redrawn next time the message queue // is processed. // WidgetPaint((tWidget *)&g_sDirList); // // Open the current directory for access. // fresult = f_opendir(&g_sDirObject, g_cCwdBuf); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { // // Ensure that the error is reported. // ListBoxTextAdd(&g_sDirList, "Error from SD Card:"); ListBoxTextAdd(&g_sDirList, (char *)StringFromFresult(fresult)); return(fresult); } ulTotalSize = 0; ulFileCount = 0; ulDirCount = 0; ulItemCount = 0; // // Give an extra blank line before the listing. // UARTprintf("\n"); // // Enter loop to enumerate through all directory entries. // for(;;) { // // Read an entry from the directory. // fresult = f_readdir(&g_sDirObject, &g_sFileInfo); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { return(fresult); } // // If the file name is blank, then this is the end of the // listing. // if(!g_sFileInfo.fname[0]) { break; } // // Print the entry information on a single line with formatting // to show the attributes, date, time, size, and name. // UARTprintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9u %s\n", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : '-', (g_sFileInfo.fattrib & AM_RDO) ? 'R' : '-', (g_sFileInfo.fattrib & AM_HID) ? 'H' : '-', (g_sFileInfo.fattrib & AM_SYS) ? 'S' : '-', (g_sFileInfo.fattrib & AM_ARC) ? 'A' : '-', (g_sFileInfo.fdate >> 9) + 1980, (g_sFileInfo.fdate >> 5) & 15, g_sFileInfo.fdate & 31, (g_sFileInfo.ftime >> 11), (g_sFileInfo.ftime >> 5) & 63, g_sFileInfo.fsize, g_sFileInfo.fname); // // Add the information as a line in the listbox widget. // if(ulItemCount < NUM_LIST_STRINGS) { usprintf(g_pcFilenames[ulItemCount], "(%c) %12s", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : 'F', g_sFileInfo.fname); ListBoxTextAdd(&g_sDirList, g_pcFilenames[ulItemCount]); } // // If the attribute is directory, then increment the directory count. // if(g_sFileInfo.fattrib & AM_DIR) { ulDirCount++; } // // Otherwise, it is a file. Increment the file count, and // add in the file size to the total. // else { ulFileCount++; ulTotalSize += g_sFileInfo.fsize; } // // Move to the next entry in the item array we use to populate the // list box. // ulItemCount++; // // Wait for the UART transmit buffer to empty. // UARTFlushTx(false); } // endfor // // Print summary lines showing the file, dir, and size totals. // UARTprintf("\n%4u File(s),%10u bytes total\n%4u Dir(s)", ulFileCount, ulTotalSize, ulDirCount); // // Get the free space. // fresult = f_getfree("/", &ulTotalSize, &pFatFs); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { return(fresult); } // // Display the amount of free space that was calculated. // UARTprintf(", %10uK bytes free\n", ulTotalSize * pFatFs->sects_clust / 2); // // Wait for the UART transmit buffer to empty. // UARTFlushTx(false); // // Made it to here, return with no errors. // return(0); }
//***************************************************************************** // // This function implements the "ls" command. It opens the current // directory and enumerates through the contents, and prints a line for // each item it finds. It shows details such as file attributes, time and // date, and the file size, along with the name. It shows a summary of // file sizes at the end along with free space. // //*****************************************************************************
This function implements the "ls" command. It opens the current directory and enumerates through the contents, and prints a line for each item it finds. It shows details such as file attributes, time and date, and the file size, along with the name. It shows a summary of file sizes at the end along with free space.
[ "This", "function", "implements", "the", "\"", "ls", "\"", "command", ".", "It", "opens", "the", "current", "directory", "and", "enumerates", "through", "the", "contents", "and", "prints", "a", "line", "for", "each", "item", "it", "finds", ".", "It", "shows", "details", "such", "as", "file", "attributes", "time", "and", "date", "and", "the", "file", "size", "along", "with", "the", "name", ".", "It", "shows", "a", "summary", "of", "file", "sizes", "at", "the", "end", "along", "with", "free", "space", "." ]
int Cmd_ls(int argc, char *argv[]) { unsigned long ulTotalSize, ulItemCount, ulFileCount, ulDirCount; FRESULT fresult; FATFS *pFatFs; ListBoxClear(&g_sDirList); WidgetPaint((tWidget *)&g_sDirList); fresult = f_opendir(&g_sDirObject, g_cCwdBuf); if(fresult != FR_OK) { ListBoxTextAdd(&g_sDirList, "Error from SD Card:"); ListBoxTextAdd(&g_sDirList, (char *)StringFromFresult(fresult)); return(fresult); } ulTotalSize = 0; ulFileCount = 0; ulDirCount = 0; ulItemCount = 0; UARTprintf("\n"); for(;;) { fresult = f_readdir(&g_sDirObject, &g_sFileInfo); if(fresult != FR_OK) { return(fresult); } if(!g_sFileInfo.fname[0]) { break; } UARTprintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9u %s\n", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : '-', (g_sFileInfo.fattrib & AM_RDO) ? 'R' : '-', (g_sFileInfo.fattrib & AM_HID) ? 'H' : '-', (g_sFileInfo.fattrib & AM_SYS) ? 'S' : '-', (g_sFileInfo.fattrib & AM_ARC) ? 'A' : '-', (g_sFileInfo.fdate >> 9) + 1980, (g_sFileInfo.fdate >> 5) & 15, g_sFileInfo.fdate & 31, (g_sFileInfo.ftime >> 11), (g_sFileInfo.ftime >> 5) & 63, g_sFileInfo.fsize, g_sFileInfo.fname); if(ulItemCount < NUM_LIST_STRINGS) { usprintf(g_pcFilenames[ulItemCount], "(%c) %12s", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : 'F', g_sFileInfo.fname); ListBoxTextAdd(&g_sDirList, g_pcFilenames[ulItemCount]); } if(g_sFileInfo.fattrib & AM_DIR) { ulDirCount++; } else { ulFileCount++; ulTotalSize += g_sFileInfo.fsize; } ulItemCount++; UARTFlushTx(false); } UARTprintf("\n%4u File(s),%10u bytes total\n%4u Dir(s)", ulFileCount, ulTotalSize, ulDirCount); fresult = f_getfree("/", &ulTotalSize, &pFatFs); if(fresult != FR_OK) { return(fresult); } UARTprintf(", %10uK bytes free\n", ulTotalSize * pFatFs->sects_clust / 2); UARTFlushTx(false); return(0); }
[ "int", "Cmd_ls", "(", "int", "argc", ",", "char", "*", "argv", "[", "]", ")", "{", "unsigned", "long", "ulTotalSize", ",", "ulItemCount", ",", "ulFileCount", ",", "ulDirCount", ";", "FRESULT", "fresult", ";", "FATFS", "*", "pFatFs", ";", "ListBoxClear", "(", "&", "g_sDirList", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sDirList", ")", ";", "fresult", "=", "f_opendir", "(", "&", "g_sDirObject", ",", "g_cCwdBuf", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "ListBoxTextAdd", "(", "&", "g_sDirList", ",", "\"", "\"", ")", ";", "ListBoxTextAdd", "(", "&", "g_sDirList", ",", "(", "char", "*", ")", "StringFromFresult", "(", "fresult", ")", ")", ";", "return", "(", "fresult", ")", ";", "}", "ulTotalSize", "=", "0", ";", "ulFileCount", "=", "0", ";", "ulDirCount", "=", "0", ";", "ulItemCount", "=", "0", ";", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "for", "(", ";", ";", ")", "{", "fresult", "=", "f_readdir", "(", "&", "g_sDirObject", ",", "&", "g_sFileInfo", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "if", "(", "!", "g_sFileInfo", ".", "fname", "[", "0", "]", ")", "{", "break", ";", "}", "UARTprintf", "(", "\"", "\\n", "\"", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_RDO", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_HID", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_SYS", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_ARC", ")", "?", "'", "'", ":", "'", "'", ",", "(", "g_sFileInfo", ".", "fdate", ">>", "9", ")", "+", "1980", ",", "(", "g_sFileInfo", ".", "fdate", ">>", "5", ")", "&", "15", ",", "g_sFileInfo", ".", "fdate", "&", "31", ",", "(", "g_sFileInfo", ".", "ftime", ">>", "11", ")", ",", "(", "g_sFileInfo", ".", "ftime", ">>", "5", ")", "&", "63", ",", "g_sFileInfo", ".", "fsize", ",", "g_sFileInfo", ".", "fname", ")", ";", "if", "(", "ulItemCount", "<", "NUM_LIST_STRINGS", ")", "{", "usprintf", "(", "g_pcFilenames", "[", "ulItemCount", "]", ",", "\"", "\"", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "?", "'", "'", ":", "'", "'", ",", "g_sFileInfo", ".", "fname", ")", ";", "ListBoxTextAdd", "(", "&", "g_sDirList", ",", "g_pcFilenames", "[", "ulItemCount", "]", ")", ";", "}", "if", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "{", "ulDirCount", "++", ";", "}", "else", "{", "ulFileCount", "++", ";", "ulTotalSize", "+=", "g_sFileInfo", ".", "fsize", ";", "}", "ulItemCount", "++", ";", "UARTFlushTx", "(", "false", ")", ";", "}", "UARTprintf", "(", "\"", "\\n", "\\n", "\"", ",", "ulFileCount", ",", "ulTotalSize", ",", "ulDirCount", ")", ";", "fresult", "=", "f_getfree", "(", "\"", "\"", ",", "&", "ulTotalSize", ",", "&", "pFatFs", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "return", "(", "fresult", ")", ";", "}", "UARTprintf", "(", "\"", "\\n", "\"", ",", "ulTotalSize", "*", "pFatFs", "->", "sects_clust", "/", "2", ")", ";", "UARTFlushTx", "(", "false", ")", ";", "return", "(", "0", ")", ";", "}" ]
This function implements the "ls" command.
[ "This", "function", "implements", "the", "\"", "ls", "\"", "command", "." ]
[ "//\r", "// Empty the list box on the display.\r", "//\r", "//\r", "// Make sure the list box will be redrawn next time the message queue\r", "// is processed.\r", "//\r", "//\r", "// Open the current directory for access.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// Ensure that the error is reported.\r", "//\r", "//\r", "// Give an extra blank line before the listing.\r", "//\r", "//\r", "// Enter loop to enumerate through all directory entries.\r", "//\r", "//\r", "// Read an entry from the directory.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// If the file name is blank, then this is the end of the\r", "// listing.\r", "//\r", "//\r", "// Print the entry information on a single line with formatting\r", "// to show the attributes, date, time, size, and name.\r", "//\r", "//\r", "// Add the information as a line in the listbox widget.\r", "//\r", "//\r", "// If the attribute is directory, then increment the directory count.\r", "//\r", "//\r", "// Otherwise, it is a file. Increment the file count, and\r", "// add in the file size to the total.\r", "//\r", "//\r", "// Move to the next entry in the item array we use to populate the\r", "// list box.\r", "//\r", "//\r", "// Wait for the UART transmit buffer to empty.\r", "//\r", "// endfor\r", "//\r", "// Print summary lines showing the file, dir, and size totals.\r", "//\r", "//\r", "// Get the free space.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// Display the amount of free space that was calculated.\r", "//\r", "//\r", "// Wait for the UART transmit buffer to empty.\r", "//\r", "//\r", "// Made it to here, return with no errors.\r", "//\r" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a2647ef71aeab11005929c4f9faa6149eded3f4a
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-l35/sd_card/sd_card.c
[ "BSD-3-Clause" ]
C
PopulateFileListBox
int
static int PopulateFileListBox(tBoolean bRepaint) { unsigned long ulItemCount; FRESULT fresult; // // Empty the list box on the display. // ListBoxClear(&g_sDirList); // // Make sure the list box will be redrawn next time the message queue // is processed. // if(bRepaint) { WidgetPaint((tWidget *)&g_sDirList); } // // Open the current directory for access. // fresult = f_opendir(&g_sDirObject, g_cCwdBuf); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { // // Ensure that the error is reported. // PrintfStatus("Error from SD Card:"); PrintfStatus((char *)StringFromFresult(fresult)); return(fresult); } ulItemCount = 0; // // Enter loop to enumerate through all directory entries. // for(;;) { // // Read an entry from the directory. // fresult = f_readdir(&g_sDirObject, &g_sFileInfo); // // Check for error and return if there is a problem. // if(fresult != FR_OK) { PrintfStatus("Error from SD Card:"); PrintfStatus((char *)StringFromFresult(fresult)); return(fresult); } // // If the file name is blank, then this is the end of the // listing. // if(!g_sFileInfo.fname[0]) { break; } // // Add the information as a line in the listbox widget. // if(ulItemCount < NUM_LIST_STRINGS) { usnprintf(g_pcFilenames[ulItemCount], MAX_FILENAME_STRING_LEN, "(%c) %s", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : 'F', g_sFileInfo.fname); ListBoxTextAdd(&g_sDirList, g_pcFilenames[ulItemCount]); } // // Move to the next entry in the item array we use to populate the // list box. // ulItemCount++; } // endfor // // Made it to here, return with no errors. // return(0); }
//***************************************************************************** // // This function is called to read the contents of the current directory on // the SD card and fill the listbox containing the names of all files and // directories. // //*****************************************************************************
This function is called to read the contents of the current directory on the SD card and fill the listbox containing the names of all files and directories.
[ "This", "function", "is", "called", "to", "read", "the", "contents", "of", "the", "current", "directory", "on", "the", "SD", "card", "and", "fill", "the", "listbox", "containing", "the", "names", "of", "all", "files", "and", "directories", "." ]
static int PopulateFileListBox(tBoolean bRepaint) { unsigned long ulItemCount; FRESULT fresult; ListBoxClear(&g_sDirList); if(bRepaint) { WidgetPaint((tWidget *)&g_sDirList); } fresult = f_opendir(&g_sDirObject, g_cCwdBuf); if(fresult != FR_OK) { PrintfStatus("Error from SD Card:"); PrintfStatus((char *)StringFromFresult(fresult)); return(fresult); } ulItemCount = 0; for(;;) { fresult = f_readdir(&g_sDirObject, &g_sFileInfo); if(fresult != FR_OK) { PrintfStatus("Error from SD Card:"); PrintfStatus((char *)StringFromFresult(fresult)); return(fresult); } if(!g_sFileInfo.fname[0]) { break; } if(ulItemCount < NUM_LIST_STRINGS) { usnprintf(g_pcFilenames[ulItemCount], MAX_FILENAME_STRING_LEN, "(%c) %s", (g_sFileInfo.fattrib & AM_DIR) ? 'D' : 'F', g_sFileInfo.fname); ListBoxTextAdd(&g_sDirList, g_pcFilenames[ulItemCount]); } ulItemCount++; } return(0); }
[ "static", "int", "PopulateFileListBox", "(", "tBoolean", "bRepaint", ")", "{", "unsigned", "long", "ulItemCount", ";", "FRESULT", "fresult", ";", "ListBoxClear", "(", "&", "g_sDirList", ")", ";", "if", "(", "bRepaint", ")", "{", "WidgetPaint", "(", "(", "tWidget", "*", ")", "&", "g_sDirList", ")", ";", "}", "fresult", "=", "f_opendir", "(", "&", "g_sDirObject", ",", "g_cCwdBuf", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "PrintfStatus", "(", "(", "char", "*", ")", "StringFromFresult", "(", "fresult", ")", ")", ";", "return", "(", "fresult", ")", ";", "}", "ulItemCount", "=", "0", ";", "for", "(", ";", ";", ")", "{", "fresult", "=", "f_readdir", "(", "&", "g_sDirObject", ",", "&", "g_sFileInfo", ")", ";", "if", "(", "fresult", "!=", "FR_OK", ")", "{", "PrintfStatus", "(", "\"", "\"", ")", ";", "PrintfStatus", "(", "(", "char", "*", ")", "StringFromFresult", "(", "fresult", ")", ")", ";", "return", "(", "fresult", ")", ";", "}", "if", "(", "!", "g_sFileInfo", ".", "fname", "[", "0", "]", ")", "{", "break", ";", "}", "if", "(", "ulItemCount", "<", "NUM_LIST_STRINGS", ")", "{", "usnprintf", "(", "g_pcFilenames", "[", "ulItemCount", "]", ",", "MAX_FILENAME_STRING_LEN", ",", "\"", "\"", ",", "(", "g_sFileInfo", ".", "fattrib", "&", "AM_DIR", ")", "?", "'", "'", ":", "'", "'", ",", "g_sFileInfo", ".", "fname", ")", ";", "ListBoxTextAdd", "(", "&", "g_sDirList", ",", "g_pcFilenames", "[", "ulItemCount", "]", ")", ";", "}", "ulItemCount", "++", ";", "}", "return", "(", "0", ")", ";", "}" ]
This function is called to read the contents of the current directory on the SD card and fill the listbox containing the names of all files and directories.
[ "This", "function", "is", "called", "to", "read", "the", "contents", "of", "the", "current", "directory", "on", "the", "SD", "card", "and", "fill", "the", "listbox", "containing", "the", "names", "of", "all", "files", "and", "directories", "." ]
[ "//\r", "// Empty the list box on the display.\r", "//\r", "//\r", "// Make sure the list box will be redrawn next time the message queue\r", "// is processed.\r", "//\r", "//\r", "// Open the current directory for access.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// Ensure that the error is reported.\r", "//\r", "//\r", "// Enter loop to enumerate through all directory entries.\r", "//\r", "//\r", "// Read an entry from the directory.\r", "//\r", "//\r", "// Check for error and return if there is a problem.\r", "//\r", "//\r", "// If the file name is blank, then this is the end of the\r", "// listing.\r", "//\r", "//\r", "// Add the information as a line in the listbox widget.\r", "//\r", "//\r", "// Move to the next entry in the item array we use to populate the\r", "// list box.\r", "//\r", "// endfor\r", "//\r", "// Made it to here, return with no errors.\r", "//\r" ]
[ { "param": "bRepaint", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bRepaint", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a2647ef71aeab11005929c4f9faa6149eded3f4a
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-l35/sd_card/sd_card.c
[ "BSD-3-Clause" ]
C
UpdateFirmware
void
void UpdateFirmware(void) { tContext sContext; // // Initialize the graphics context. // GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119); GrContextForegroundSet(&sContext, ClrWhite); GrContextForegroundSet(&sContext, ClrBlack); GrContextFontSet(&sContext, g_pFontCm20); // // Tell the user what's up // GrContextForegroundSet(&sContext, ClrWhite); GrStringDrawCentered(&sContext, "Updating firmware...", -1, GrContextDpyWidthGet(&sContext) / 2, GrContextDpyHeightGet(&sContext) / 2, true); // // Disable all processor interrupts. Instead of disabling them // one at a time (and possibly missing an interrupt if new sources // are added), a direct write to NVIC is done to disable all // peripheral interrupts. // IntMasterDisable(); SysTickIntDisable(); HWREG(NVIC_DIS0) = 0xffffffff; HWREG(NVIC_DIS1) = 0xffffffff; // // Return control to the boot loader. This is a call to the SVC // handler in the boot loader. // (*((void (*)(void))(*(unsigned long *)0x2c)))(); }
//***************************************************************************** // // Transfer control to the bootloader to wait for an ethernet-based firmware // update to occur. // //*****************************************************************************
Transfer control to the bootloader to wait for an ethernet-based firmware update to occur.
[ "Transfer", "control", "to", "the", "bootloader", "to", "wait", "for", "an", "ethernet", "-", "based", "firmware", "update", "to", "occur", "." ]
void UpdateFirmware(void) { tContext sContext; GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119); GrContextForegroundSet(&sContext, ClrWhite); GrContextForegroundSet(&sContext, ClrBlack); GrContextFontSet(&sContext, g_pFontCm20); GrContextForegroundSet(&sContext, ClrWhite); GrStringDrawCentered(&sContext, "Updating firmware...", -1, GrContextDpyWidthGet(&sContext) / 2, GrContextDpyHeightGet(&sContext) / 2, true); IntMasterDisable(); SysTickIntDisable(); HWREG(NVIC_DIS0) = 0xffffffff; HWREG(NVIC_DIS1) = 0xffffffff; (*((void (*)(void))(*(unsigned long *)0x2c)))(); }
[ "void", "UpdateFirmware", "(", "void", ")", "{", "tContext", "sContext", ";", "GrContextInit", "(", "&", "sContext", ",", "&", "g_sKitronix320x240x16_SSD2119", ")", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrWhite", ")", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrBlack", ")", ";", "GrContextFontSet", "(", "&", "sContext", ",", "g_pFontCm20", ")", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrWhite", ")", ";", "GrStringDrawCentered", "(", "&", "sContext", ",", "\"", "\"", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "sContext", ")", "/", "2", ",", "GrContextDpyHeightGet", "(", "&", "sContext", ")", "/", "2", ",", "true", ")", ";", "IntMasterDisable", "(", ")", ";", "SysTickIntDisable", "(", ")", ";", "HWREG", "(", "NVIC_DIS0", ")", "=", "0xffffffff", ";", "HWREG", "(", "NVIC_DIS1", ")", "=", "0xffffffff", ";", "(", "*", "(", "(", "void", "(", "*", ")", "(", "void", ")", ")", "(", "*", "(", "unsigned", "long", "*", ")", "0x2c", ")", ")", ")", "(", ")", ";", "}" ]
Transfer control to the bootloader to wait for an ethernet-based firmware update to occur.
[ "Transfer", "control", "to", "the", "bootloader", "to", "wait", "for", "an", "ethernet", "-", "based", "firmware", "update", "to", "occur", "." ]
[ "//\r", "// Initialize the graphics context.\r", "//\r", "//\r", "// Tell the user what's up\r", "//\r", "//\r", "// Disable all processor interrupts. Instead of disabling them\r", "// one at a time (and possibly missing an interrupt if new sources\r", "// are added), a direct write to NVIC is done to disable all\r", "// peripheral interrupts.\r", "//\r", "//\r", "// Return control to the boot loader. This is a call to the SVC\r", "// handler in the boot loader.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
47f20dbb537f804cb162e0044c415b9f4a595575
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/qs-autonomous/sound_task.c
[ "BSD-3-Clause" ]
C
SoundTask
void
void SoundTask(void *pvParam) { static unsigned long ulState = SOUND_STATE_IDLE; // // Process the state machine // switch(ulState) { // // IDLE - not playing a sound // case SOUND_STATE_IDLE: { // // If there is a new clip ready to play, then start playing it. // if(pucNextPlaying) { // // Set the current playing clip to match the new clip, and // clear the "next" clip pointer. // pucNowPlaying = pucNextPlaying; pucNextPlaying = 0; // // Open the new clip as a wave file // if(WaveOpen((unsigned long *)pucNowPlaying, &sSoundEffectHeader) == WAVE_OK) { // // If the clip opened okay as a wave file, then start the // clip playing and change our state to PLAYING // ulState = SOUND_STATE_PLAYING; WavePlayStart(&sSoundEffectHeader); } // // Otherwise the clip was not opened successfully in which // case clear the current playing clip and remain in IDLE state // else { pucNowPlaying = 0; } } break; } // // PLAYING - a clip is playing // case SOUND_STATE_PLAYING: { // // Call the function to continue wave playing. This function must // be called periodically, and it will keep the wave driver playing // the audio clip until it is finished. // if(WavePlayContinue(&sSoundEffectHeader)) { // // Clip is done playing, so clear the playing clip pointer and // set the state back to IDLE. // pucNowPlaying = 0; ulState = SOUND_STATE_IDLE; } break; } // // default state is an error. Clear the current and next clip pointers // and set the state back to IDLE // default: { pucNowPlaying = 0; pucNextPlaying = 0; ulState = SOUND_STATE_IDLE; break; } } }
//**************************************************************************** // // This function is the sound "task" that is called periodically by the // scheduler from the app main processing loop. This task plays audio clips // that are queued up bby the SoundTaskPlay() function. // //****************************************************************************
This function is the sound "task" that is called periodically by the scheduler from the app main processing loop. This task plays audio clips that are queued up bby the SoundTaskPlay() function.
[ "This", "function", "is", "the", "sound", "\"", "task", "\"", "that", "is", "called", "periodically", "by", "the", "scheduler", "from", "the", "app", "main", "processing", "loop", ".", "This", "task", "plays", "audio", "clips", "that", "are", "queued", "up", "bby", "the", "SoundTaskPlay", "()", "function", "." ]
void SoundTask(void *pvParam) { static unsigned long ulState = SOUND_STATE_IDLE; switch(ulState) { case SOUND_STATE_IDLE: { if(pucNextPlaying) { pucNowPlaying = pucNextPlaying; pucNextPlaying = 0; if(WaveOpen((unsigned long *)pucNowPlaying, &sSoundEffectHeader) == WAVE_OK) { ulState = SOUND_STATE_PLAYING; WavePlayStart(&sSoundEffectHeader); } else { pucNowPlaying = 0; } } break; } case SOUND_STATE_PLAYING: { if(WavePlayContinue(&sSoundEffectHeader)) { pucNowPlaying = 0; ulState = SOUND_STATE_IDLE; } break; } default: { pucNowPlaying = 0; pucNextPlaying = 0; ulState = SOUND_STATE_IDLE; break; } } }
[ "void", "SoundTask", "(", "void", "*", "pvParam", ")", "{", "static", "unsigned", "long", "ulState", "=", "SOUND_STATE_IDLE", ";", "switch", "(", "ulState", ")", "{", "case", "SOUND_STATE_IDLE", ":", "{", "if", "(", "pucNextPlaying", ")", "{", "pucNowPlaying", "=", "pucNextPlaying", ";", "pucNextPlaying", "=", "0", ";", "if", "(", "WaveOpen", "(", "(", "unsigned", "long", "*", ")", "pucNowPlaying", ",", "&", "sSoundEffectHeader", ")", "==", "WAVE_OK", ")", "{", "ulState", "=", "SOUND_STATE_PLAYING", ";", "WavePlayStart", "(", "&", "sSoundEffectHeader", ")", ";", "}", "else", "{", "pucNowPlaying", "=", "0", ";", "}", "}", "break", ";", "}", "case", "SOUND_STATE_PLAYING", ":", "{", "if", "(", "WavePlayContinue", "(", "&", "sSoundEffectHeader", ")", ")", "{", "pucNowPlaying", "=", "0", ";", "ulState", "=", "SOUND_STATE_IDLE", ";", "}", "break", ";", "}", "default", ":", "{", "pucNowPlaying", "=", "0", ";", "pucNextPlaying", "=", "0", ";", "ulState", "=", "SOUND_STATE_IDLE", ";", "break", ";", "}", "}", "}" ]
This function is the sound "task" that is called periodically by the scheduler from the app main processing loop.
[ "This", "function", "is", "the", "sound", "\"", "task", "\"", "that", "is", "called", "periodically", "by", "the", "scheduler", "from", "the", "app", "main", "processing", "loop", "." ]
[ "//\r", "// Process the state machine\r", "//\r", "//\r", "// IDLE - not playing a sound\r", "//\r", "//\r", "// If there is a new clip ready to play, then start playing it.\r", "//\r", "//\r", "// Set the current playing clip to match the new clip, and\r", "// clear the \"next\" clip pointer.\r", "//\r", "//\r", "// Open the new clip as a wave file\r", "//\r", "//\r", "// If the clip opened okay as a wave file, then start the\r", "// clip playing and change our state to PLAYING\r", "//\r", "//\r", "// Otherwise the clip was not opened successfully in which\r", "// case clear the current playing clip and remain in IDLE state\r", "//\r", "//\r", "// PLAYING - a clip is playing\r", "//\r", "//\r", "// Call the function to continue wave playing. This function must\r", "// be called periodically, and it will keep the wave driver playing\r", "// the audio clip until it is finished.\r", "//\r", "//\r", "// Clip is done playing, so clear the playing clip pointer and\r", "// set the state back to IDLE.\r", "//\r", "//\r", "// default state is an error. Clear the current and next clip pointers\r", "// and set the state back to IDLE\r", "//\r" ]
[ { "param": "pvParam", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvParam", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
47f20dbb537f804cb162e0044c415b9f4a595575
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/qs-autonomous/sound_task.c
[ "BSD-3-Clause" ]
C
SoundTaskInit
void
void SoundTaskInit(void *pvParam) { SoundInit(); }
//**************************************************************************** // // This function perform initializations needed to run the sound task. It // should be called during system initialization. // //****************************************************************************
This function perform initializations needed to run the sound task. It should be called during system initialization.
[ "This", "function", "perform", "initializations", "needed", "to", "run", "the", "sound", "task", ".", "It", "should", "be", "called", "during", "system", "initialization", "." ]
void SoundTaskInit(void *pvParam) { SoundInit(); }
[ "void", "SoundTaskInit", "(", "void", "*", "pvParam", ")", "{", "SoundInit", "(", ")", ";", "}" ]
This function perform initializations needed to run the sound task.
[ "This", "function", "perform", "initializations", "needed", "to", "run", "the", "sound", "task", "." ]
[]
[ { "param": "pvParam", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvParam", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
47f20dbb537f804cb162e0044c415b9f4a595575
junyanl-code/Luminary-Micro-Library
boards/ek-evalbot/qs-autonomous/sound_task.c
[ "BSD-3-Clause" ]
C
SoundTaskPlay
void
void SoundTaskPlay(const unsigned char *pucSound) { // // Set the "next" pointer to point at the requested clip. // pucNextPlaying = pucSound; }
//**************************************************************************** // // This function is used to queue a wave format audio clip for playing. // //****************************************************************************
This function is used to queue a wave format audio clip for playing.
[ "This", "function", "is", "used", "to", "queue", "a", "wave", "format", "audio", "clip", "for", "playing", "." ]
void SoundTaskPlay(const unsigned char *pucSound) { pucNextPlaying = pucSound; }
[ "void", "SoundTaskPlay", "(", "const", "unsigned", "char", "*", "pucSound", ")", "{", "pucNextPlaying", "=", "pucSound", ";", "}" ]
This function is used to queue a wave format audio clip for playing.
[ "This", "function", "is", "used", "to", "queue", "a", "wave", "format", "audio", "clip", "for", "playing", "." ]
[ "//\r", "// Set the \"next\" pointer to point at the requested clip.\r", "//\r" ]
[ { "param": "pucSound", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pucSound", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c75b8d41c44cbf8c5142d217484d019ad056a851
junyanl-code/Luminary-Micro-Library
grlib/offscr8bpp.c
[ "BSD-3-Clause" ]
C
GrOffScreen8BPPColorTranslate
null
static unsigned long GrOffScreen8BPPColorTranslate(void *pvDisplayData, unsigned long ulValue) { unsigned long ulIdx, ulDiff, ulMatchIdx, ulMatchDiff, ulR, ulG, ulB; unsigned char *pucPalette; // // Check the arguments. // ASSERT(pvDisplayData); // // Get a pointer to the palette for the off-screen buffer. // pucPalette = (unsigned char *)pvDisplayData + 6; // // Extract the red, green, and blue component from the input color. // ulR = (ulValue >> ClrRedShift) & 0xff; ulG = (ulValue >> ClrGreenShift) & 0xff; ulB = (ulValue >> ClrBlueShift) & 0xff; // // Set the match such that the first palette entry will be a better match. // ulMatchIdx = 0; ulMatchDiff = 0xffffffff; // // Loop through the colors in the palette. // for(ulIdx = 0; ulIdx < 256; ulIdx++, pucPalette += 3) { // // Compute the Cartesian distance between these two colors. // ulDiff = (((pucPalette[2] - ulR) * (pucPalette[2] - ulR)) + ((pucPalette[1] - ulG) * (pucPalette[1] - ulG)) + ((pucPalette[0] - ulB) * (pucPalette[0] - ulB))); // // See if this color is a closer match than any of the previous colors. // if(ulDiff < ulMatchDiff) { // // Save this color as the new best match. // ulMatchDiff = ulDiff; ulMatchIdx = ulIdx; } // // Stop looking if an exact match was found. // if(ulDiff == 0) { break; } } // // Return the index of the best match. // return(ulMatchIdx); }
//***************************************************************************** // //! Translates a 24-bit RGB color to a display driver-specific color. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! \param ulValue is the 24-bit RGB color. The least-significant byte is the //! blue channel, the next byte is the green channel, and the third byte is the //! red channel. //! //! This function translates a 24-bit RGB color into a value that can be //! written into the display's frame buffer in order to reproduce that color, //! or the closest possible approximation of that color. //! //! \return Returns the display-driver specific color. // //*****************************************************************************
Translates a 24-bit RGB color to a display driver-specific color. \param pvDisplayData is a pointer to the driver-specific data for this display driver. \param ulValue is the 24-bit RGB color. The least-significant byte is the blue channel, the next byte is the green channel, and the third byte is the red channel. This function translates a 24-bit RGB color into a value that can be written into the display's frame buffer in order to reproduce that color, or the closest possible approximation of that color. \return Returns the display-driver specific color.
[ "Translates", "a", "24", "-", "bit", "RGB", "color", "to", "a", "display", "driver", "-", "specific", "color", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "\\", "param", "ulValue", "is", "the", "24", "-", "bit", "RGB", "color", ".", "The", "least", "-", "significant", "byte", "is", "the", "blue", "channel", "the", "next", "byte", "is", "the", "green", "channel", "and", "the", "third", "byte", "is", "the", "red", "channel", ".", "This", "function", "translates", "a", "24", "-", "bit", "RGB", "color", "into", "a", "value", "that", "can", "be", "written", "into", "the", "display", "'", "s", "frame", "buffer", "in", "order", "to", "reproduce", "that", "color", "or", "the", "closest", "possible", "approximation", "of", "that", "color", ".", "\\", "return", "Returns", "the", "display", "-", "driver", "specific", "color", "." ]
static unsigned long GrOffScreen8BPPColorTranslate(void *pvDisplayData, unsigned long ulValue) { unsigned long ulIdx, ulDiff, ulMatchIdx, ulMatchDiff, ulR, ulG, ulB; unsigned char *pucPalette; ASSERT(pvDisplayData); pucPalette = (unsigned char *)pvDisplayData + 6; ulR = (ulValue >> ClrRedShift) & 0xff; ulG = (ulValue >> ClrGreenShift) & 0xff; ulB = (ulValue >> ClrBlueShift) & 0xff; ulMatchIdx = 0; ulMatchDiff = 0xffffffff; for(ulIdx = 0; ulIdx < 256; ulIdx++, pucPalette += 3) { ulDiff = (((pucPalette[2] - ulR) * (pucPalette[2] - ulR)) + ((pucPalette[1] - ulG) * (pucPalette[1] - ulG)) + ((pucPalette[0] - ulB) * (pucPalette[0] - ulB))); if(ulDiff < ulMatchDiff) { ulMatchDiff = ulDiff; ulMatchIdx = ulIdx; } if(ulDiff == 0) { break; } } return(ulMatchIdx); }
[ "static", "unsigned", "long", "GrOffScreen8BPPColorTranslate", "(", "void", "*", "pvDisplayData", ",", "unsigned", "long", "ulValue", ")", "{", "unsigned", "long", "ulIdx", ",", "ulDiff", ",", "ulMatchIdx", ",", "ulMatchDiff", ",", "ulR", ",", "ulG", ",", "ulB", ";", "unsigned", "char", "*", "pucPalette", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "pucPalette", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", "+", "6", ";", "ulR", "=", "(", "ulValue", ">>", "ClrRedShift", ")", "&", "0xff", ";", "ulG", "=", "(", "ulValue", ">>", "ClrGreenShift", ")", "&", "0xff", ";", "ulB", "=", "(", "ulValue", ">>", "ClrBlueShift", ")", "&", "0xff", ";", "ulMatchIdx", "=", "0", ";", "ulMatchDiff", "=", "0xffffffff", ";", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "256", ";", "ulIdx", "++", ",", "pucPalette", "+=", "3", ")", "{", "ulDiff", "=", "(", "(", "(", "pucPalette", "[", "2", "]", "-", "ulR", ")", "*", "(", "pucPalette", "[", "2", "]", "-", "ulR", ")", ")", "+", "(", "(", "pucPalette", "[", "1", "]", "-", "ulG", ")", "*", "(", "pucPalette", "[", "1", "]", "-", "ulG", ")", ")", "+", "(", "(", "pucPalette", "[", "0", "]", "-", "ulB", ")", "*", "(", "pucPalette", "[", "0", "]", "-", "ulB", ")", ")", ")", ";", "if", "(", "ulDiff", "<", "ulMatchDiff", ")", "{", "ulMatchDiff", "=", "ulDiff", ";", "ulMatchIdx", "=", "ulIdx", ";", "}", "if", "(", "ulDiff", "==", "0", ")", "{", "break", ";", "}", "}", "return", "(", "ulMatchIdx", ")", ";", "}" ]
Translates a 24-bit RGB color to a display driver-specific color.
[ "Translates", "a", "24", "-", "bit", "RGB", "color", "to", "a", "display", "driver", "-", "specific", "color", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// Get a pointer to the palette for the off-screen buffer.\r", "//\r", "//\r", "// Extract the red, green, and blue component from the input color.\r", "//\r", "//\r", "// Set the match such that the first palette entry will be a better match.\r", "//\r", "//\r", "// Loop through the colors in the palette.\r", "//\r", "//\r", "// Compute the Cartesian distance between these two colors.\r", "//\r", "//\r", "// See if this color is a closer match than any of the previous colors.\r", "//\r", "//\r", "// Save this color as the new best match.\r", "//\r", "//\r", "// Stop looking if an exact match was found.\r", "//\r", "//\r", "// Return the index of the best match.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "ulValue", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvDisplayData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulValue", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c75b8d41c44cbf8c5142d217484d019ad056a851
junyanl-code/Luminary-Micro-Library
grlib/offscr8bpp.c
[ "BSD-3-Clause" ]
C
GrOffScreen8BPPPixelDraw
void
static void GrOffScreen8BPPPixelDraw(void *pvDisplayData, long lX, long lY, unsigned long ulValue) { unsigned char *pucData; // // Check the arguments. // ASSERT(pvDisplayData); // // Create a character pointer for the display-specific data (which points // to the image buffer). // pucData = (unsigned char *)pvDisplayData; // // Get the offset to the byte of the image buffer that contains the pixel // in question. // pucData += (*(unsigned short *)(pucData + 1) * lY) + lX + 6 + (256 * 3); // // Write this pixel into the image buffer. // *pucData = ulValue; }
//***************************************************************************** // //! Draws a pixel on the screen. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! \param lX is the X coordinate of the pixel. //! \param lY is the Y coordinate of the pixel. //! \param ulValue is the color of the pixel. //! //! This function sets the given pixel to a particular color. The coordinates //! of the pixel are assumed to be within the extents of the display. //! //! \return None. // //*****************************************************************************
Draws a pixel on the screen. \param pvDisplayData is a pointer to the driver-specific data for this display driver. \param lX is the X coordinate of the pixel. \param lY is the Y coordinate of the pixel. \param ulValue is the color of the pixel. This function sets the given pixel to a particular color. The coordinates of the pixel are assumed to be within the extents of the display. \return None.
[ "Draws", "a", "pixel", "on", "the", "screen", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "\\", "param", "lX", "is", "the", "X", "coordinate", "of", "the", "pixel", ".", "\\", "param", "lY", "is", "the", "Y", "coordinate", "of", "the", "pixel", ".", "\\", "param", "ulValue", "is", "the", "color", "of", "the", "pixel", ".", "This", "function", "sets", "the", "given", "pixel", "to", "a", "particular", "color", ".", "The", "coordinates", "of", "the", "pixel", "are", "assumed", "to", "be", "within", "the", "extents", "of", "the", "display", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPPixelDraw(void *pvDisplayData, long lX, long lY, unsigned long ulValue) { unsigned char *pucData; ASSERT(pvDisplayData); pucData = (unsigned char *)pvDisplayData; pucData += (*(unsigned short *)(pucData + 1) * lY) + lX + 6 + (256 * 3); *pucData = ulValue; }
[ "static", "void", "GrOffScreen8BPPPixelDraw", "(", "void", "*", "pvDisplayData", ",", "long", "lX", ",", "long", "lY", ",", "unsigned", "long", "ulValue", ")", "{", "unsigned", "char", "*", "pucData", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "pucData", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", ";", "pucData", "+=", "(", "*", "(", "unsigned", "short", "*", ")", "(", "pucData", "+", "1", ")", "*", "lY", ")", "+", "lX", "+", "6", "+", "(", "256", "*", "3", ")", ";", "*", "pucData", "=", "ulValue", ";", "}" ]
Draws a pixel on the screen.
[ "Draws", "a", "pixel", "on", "the", "screen", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// Create a character pointer for the display-specific data (which points\r", "// to the image buffer).\r", "//\r", "//\r", "// Get the offset to the byte of the image buffer that contains the pixel\r", "// in question.\r", "//\r", "//\r", "// Write this pixel into the image buffer.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" }, { "param": "ulValue", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvDisplayData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lX", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lY", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulValue", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }