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
c75b8d41c44cbf8c5142d217484d019ad056a851
junyanl-code/Luminary-Micro-Library
grlib/offscr8bpp.c
[ "BSD-3-Clause" ]
C
GrOffScreen8BPPPixelDrawMultiple
void
static void GrOffScreen8BPPPixelDrawMultiple(void *pvDisplayData, long lX, long lY, long lX0, long lCount, long lBPP, const unsigned char *pucData, const unsigned char *pucPalette) { unsigned char *pucPtr; unsigned long ulByte; // // Check the arguments. // ASSERT(pvDisplayData); ASSERT(pucData); ASSERT(pucPalette); // // Create a character pointer for the display-specific data (which points // to the image buffer). // pucPtr = (unsigned char *)pvDisplayData; // // Get the offset to the byte of the image buffer that contains the // starting pixel. // pucPtr += (*(unsigned short *)(pucPtr + 1) * lY) + lX + 6 + (256 * 3); // // Determine how to interpret the pixel data based on the number of bits // per pixel. // switch(lBPP) { // // The pixel data is in 1 bit per pixel format. // case 1: { // // Loop while there are more pixels to draw. // while(lCount) { // // Get the next byte of image data. // ulByte = *pucData++; // // Loop through the pixels in this byte of image data. // for(; (lX0 < 8) && lCount; lX0++, lCount--) { // // Draw this pixel in the appropriate color. // *pucPtr++ = (((unsigned long *)pucPalette)[(ulByte >> (7 - lX0)) & 1]); } // // Start at the beginning of the next byte of image data. // lX0 = 0; } // // The image data has been drawn. // break; } // // The pixel data is in 4 bit per pixel format. // case 4: { // // Loop while there are more pixels to draw. "Duff's device" is // used to jump into the middle of the loop if the first nibble of // the pixel data should not be used. Duff's device makes use of // the fact that a case statement is legal anywhere within a // sub-block of a switch statement. See // http://en.wikipedia.org/wiki/Duff's_device for detailed // information about Duff's device. // switch(lX0 & 1) { case 0: while(lCount) { // // Get the upper nibble of the next byte of pixel data // and extract the corresponding entry from the // palette. // ulByte = (*pucData >> 4) * 3; ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff); // // Translate this palette entry and write it to the // screen. // *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); // // Decrement the count of pixels to draw. // lCount--; // // See if there is another pixel to draw. // if(lCount) { case 1: // // Get the lower nibble of the next byte of pixel // data and extract the corresponding entry from // the palette. // ulByte = (*pucData++ & 15) * 3; ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff); // // Translate this palette entry and write it to the // screen. // *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); // // Decrement the count of pixels to draw. // lCount--; } } } // // The image data has been drawn. // break; } // // The pixel data is in 8 bit per pixel format. // case 8: { // // Loop while there are more pixels to draw. // while(lCount--) { // // Get the next byte of pixel data and extract the // corresponding entry from the palette. // ulByte = *pucData++ * 3; ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff; // // Translate this palette entry and write it to the screen. // *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); } // // The image data has been drawn. // break; } } }
//***************************************************************************** // //! Draws a horizontal sequence of pixels 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 first pixel. //! \param lY is the Y coordinate of the first pixel. //! \param lX0 is sub-pixel offset within the pixel data, which is valid for 1 //! or 4 bit per pixel formats. //! \param lCount is the number of pixels to draw. //! \param lBPP is the number of bits per pixel; must be 1, 4, or 8. //! \param pucData is a pointer to the pixel data. For 1 and 4 bit per pixel //! formats, the most significant bit(s) represent the left-most pixel. //! \param pucPalette is a pointer to the palette used to draw the pixels. //! //! This function draws a horizontal sequence of pixels on the screen, using //! the supplied palette. For 1 bit per pixel format, the palette contains //! pre-translated colors; for 4 and 8 bit per pixel formats, the palette //! contains 24-bit RGB values that must be translated before being written to //! the display. //! //! \return None. // //*****************************************************************************
Draws a horizontal sequence of pixels 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 first pixel. \param lY is the Y coordinate of the first pixel. \param lX0 is sub-pixel offset within the pixel data, which is valid for 1 or 4 bit per pixel formats. \param lCount is the number of pixels to draw. \param lBPP is the number of bits per pixel; must be 1, 4, or 8. \param pucData is a pointer to the pixel data. For 1 and 4 bit per pixel formats, the most significant bit(s) represent the left-most pixel. \param pucPalette is a pointer to the palette used to draw the pixels. This function draws a horizontal sequence of pixels on the screen, using the supplied palette. For 1 bit per pixel format, the palette contains pre-translated colors; for 4 and 8 bit per pixel formats, the palette contains 24-bit RGB values that must be translated before being written to the display. \return None.
[ "Draws", "a", "horizontal", "sequence", "of", "pixels", "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", "first", "pixel", ".", "\\", "param", "lY", "is", "the", "Y", "coordinate", "of", "the", "first", "pixel", ".", "\\", "param", "lX0", "is", "sub", "-", "pixel", "offset", "within", "the", "pixel", "data", "which", "is", "valid", "for", "1", "or", "4", "bit", "per", "pixel", "formats", ".", "\\", "param", "lCount", "is", "the", "number", "of", "pixels", "to", "draw", ".", "\\", "param", "lBPP", "is", "the", "number", "of", "bits", "per", "pixel", ";", "must", "be", "1", "4", "or", "8", ".", "\\", "param", "pucData", "is", "a", "pointer", "to", "the", "pixel", "data", ".", "For", "1", "and", "4", "bit", "per", "pixel", "formats", "the", "most", "significant", "bit", "(", "s", ")", "represent", "the", "left", "-", "most", "pixel", ".", "\\", "param", "pucPalette", "is", "a", "pointer", "to", "the", "palette", "used", "to", "draw", "the", "pixels", ".", "This", "function", "draws", "a", "horizontal", "sequence", "of", "pixels", "on", "the", "screen", "using", "the", "supplied", "palette", ".", "For", "1", "bit", "per", "pixel", "format", "the", "palette", "contains", "pre", "-", "translated", "colors", ";", "for", "4", "and", "8", "bit", "per", "pixel", "formats", "the", "palette", "contains", "24", "-", "bit", "RGB", "values", "that", "must", "be", "translated", "before", "being", "written", "to", "the", "display", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPPixelDrawMultiple(void *pvDisplayData, long lX, long lY, long lX0, long lCount, long lBPP, const unsigned char *pucData, const unsigned char *pucPalette) { unsigned char *pucPtr; unsigned long ulByte; ASSERT(pvDisplayData); ASSERT(pucData); ASSERT(pucPalette); pucPtr = (unsigned char *)pvDisplayData; pucPtr += (*(unsigned short *)(pucPtr + 1) * lY) + lX + 6 + (256 * 3); switch(lBPP) { case 1: { while(lCount) { ulByte = *pucData++; for(; (lX0 < 8) && lCount; lX0++, lCount--) { *pucPtr++ = (((unsigned long *)pucPalette)[(ulByte >> (7 - lX0)) & 1]); } lX0 = 0; } break; } case 4: { switch(lX0 & 1) { case 0: while(lCount) { ulByte = (*pucData >> 4) * 3; ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff); *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); lCount--; if(lCount) { case 1: ulByte = (*pucData++ & 15) * 3; ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff); *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); lCount--; } } } break; } case 8: { while(lCount--) { ulByte = *pucData++ * 3; ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff; *pucPtr++ = GrOffScreen8BPPColorTranslate(pvDisplayData, ulByte); } break; } } }
[ "static", "void", "GrOffScreen8BPPPixelDrawMultiple", "(", "void", "*", "pvDisplayData", ",", "long", "lX", ",", "long", "lY", ",", "long", "lX0", ",", "long", "lCount", ",", "long", "lBPP", ",", "const", "unsigned", "char", "*", "pucData", ",", "const", "unsigned", "char", "*", "pucPalette", ")", "{", "unsigned", "char", "*", "pucPtr", ";", "unsigned", "long", "ulByte", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "ASSERT", "(", "pucData", ")", ";", "ASSERT", "(", "pucPalette", ")", ";", "pucPtr", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", ";", "pucPtr", "+=", "(", "*", "(", "unsigned", "short", "*", ")", "(", "pucPtr", "+", "1", ")", "*", "lY", ")", "+", "lX", "+", "6", "+", "(", "256", "*", "3", ")", ";", "switch", "(", "lBPP", ")", "{", "case", "1", ":", "{", "while", "(", "lCount", ")", "{", "ulByte", "=", "*", "pucData", "++", ";", "for", "(", ";", "(", "lX0", "<", "8", ")", "&&", "lCount", ";", "lX0", "++", ",", "lCount", "--", ")", "{", "*", "pucPtr", "++", "=", "(", "(", "(", "unsigned", "long", "*", ")", "pucPalette", ")", "[", "(", "ulByte", ">>", "(", "7", "-", "lX0", ")", ")", "&", "1", "]", ")", ";", "}", "lX0", "=", "0", ";", "}", "break", ";", "}", "case", "4", ":", "{", "switch", "(", "lX0", "&", "1", ")", "{", "case", "0", ":", "while", "(", "lCount", ")", "{", "ulByte", "=", "(", "*", "pucData", ">>", "4", ")", "*", "3", ";", "ulByte", "=", "(", "*", "(", "unsigned", "long", "*", ")", "(", "pucPalette", "+", "ulByte", ")", "&", "0x00ffffff", ")", ";", "*", "pucPtr", "++", "=", "GrOffScreen8BPPColorTranslate", "(", "pvDisplayData", ",", "ulByte", ")", ";", "lCount", "--", ";", "if", "(", "lCount", ")", "{", "case", "1", ":", "ulByte", "=", "(", "*", "pucData", "++", "&", "15", ")", "*", "3", ";", "ulByte", "=", "(", "*", "(", "unsigned", "long", "*", ")", "(", "pucPalette", "+", "ulByte", ")", "&", "0x00ffffff", ")", ";", "*", "pucPtr", "++", "=", "GrOffScreen8BPPColorTranslate", "(", "pvDisplayData", ",", "ulByte", ")", ";", "lCount", "--", ";", "}", "}", "}", "break", ";", "}", "case", "8", ":", "{", "while", "(", "lCount", "--", ")", "{", "ulByte", "=", "*", "pucData", "++", "*", "3", ";", "ulByte", "=", "*", "(", "unsigned", "long", "*", ")", "(", "pucPalette", "+", "ulByte", ")", "&", "0x00ffffff", ";", "*", "pucPtr", "++", "=", "GrOffScreen8BPPColorTranslate", "(", "pvDisplayData", ",", "ulByte", ")", ";", "}", "break", ";", "}", "}", "}" ]
Draws a horizontal sequence of pixels on the screen.
[ "Draws", "a", "horizontal", "sequence", "of", "pixels", "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\r", "// starting pixel.\r", "//\r", "//\r", "// Determine how to interpret the pixel data based on the number of bits\r", "// per pixel.\r", "//\r", "//\r", "// The pixel data is in 1 bit per pixel format.\r", "//\r", "//\r", "// Loop while there are more pixels to draw.\r", "//\r", "//\r", "// Get the next byte of image data.\r", "//\r", "//\r", "// Loop through the pixels in this byte of image data.\r", "//\r", "//\r", "// Draw this pixel in the appropriate color.\r", "//\r", "//\r", "// Start at the beginning of the next byte of image data.\r", "//\r", "//\r", "// The image data has been drawn.\r", "//\r", "//\r", "// The pixel data is in 4 bit per pixel format.\r", "//\r", "//\r", "// Loop while there are more pixels to draw. \"Duff's device\" is\r", "// used to jump into the middle of the loop if the first nibble of\r", "// the pixel data should not be used. Duff's device makes use of\r", "// the fact that a case statement is legal anywhere within a\r", "// sub-block of a switch statement. See\r", "// http://en.wikipedia.org/wiki/Duff's_device for detailed\r", "// information about Duff's device.\r", "//\r", "//\r", "// Get the upper nibble of the next byte of pixel data\r", "// and extract the corresponding entry from the\r", "// palette.\r", "//\r", "//\r", "// Translate this palette entry and write it to the\r", "// screen.\r", "//\r", "//\r", "// Decrement the count of pixels to draw.\r", "//\r", "//\r", "// See if there is another pixel to draw.\r", "//\r", "//\r", "// Get the lower nibble of the next byte of pixel\r", "// data and extract the corresponding entry from\r", "// the palette.\r", "//\r", "//\r", "// Translate this palette entry and write it to the\r", "// screen.\r", "//\r", "//\r", "// Decrement the count of pixels to draw.\r", "//\r", "//\r", "// The image data has been drawn.\r", "//\r", "//\r", "// The pixel data is in 8 bit per pixel format.\r", "//\r", "//\r", "// Loop while there are more pixels to draw.\r", "//\r", "//\r", "// Get the next byte of pixel data and extract the\r", "// corresponding entry from the palette.\r", "//\r", "//\r", "// Translate this palette entry and write it to the screen.\r", "//\r", "//\r", "// The image data has been drawn.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" }, { "param": "lX0", "type": "long" }, { "param": "lCount", "type": "long" }, { "param": "lBPP", "type": "long" }, { "param": "pucData", "type": "unsigned char" }, { "param": "pucPalette", "type": "unsigned char" } ]
{ "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": "lX0", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lCount", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lBPP", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucData", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucPalette", "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
GrOffScreen8BPPLineDrawH
void
static void GrOffScreen8BPPLineDrawH(void *pvDisplayData, long lX1, long lX2, 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 // starting pixel. // pucData += (*(unsigned short *)(pucData + 1) * lY) + lX1 + 6 + (256 * 3); // // Copy the pixel value into all 4 pixels of the unsigned long. This will // be used later to write multiple pixels into memory (as opposed to one at // a time). // ulValue = (ulValue << 24) | (ulValue << 16) | (ulValue << 8) | ulValue; // // See if the buffer pointer is not half-word aligned. // if(((unsigned long)pucData) & 1) { // // Draw one pixel to half-word align the buffer pointer. // *pucData++ = ulValue & 0xff; lX1++; } // // See if the buffer pointer is not word aligned and there are at least two // pixels left to draw. // if(((unsigned long)pucData & 2) && ((lX2 - lX1) > 0)) { // // Draw two pixels to word align the buffer pointer. // *(unsigned short *)pucData = ulValue & 0xffff; pucData += 2; lX1 += 2; } // // Loop while there are at least four pixels left to draw. // while((lX1 + 3) <= lX2) { // // Draw four pixels. // *(unsigned long *)pucData = ulValue; pucData += 4; lX1 += 4; } // // See if there are at least two pixels left to draw. // if((lX1 + 1) <= lX2) { // // Draw two pixels, leaving the buffer pointer half-word aligned. // *(unsigned short *)pucData = ulValue & 0xffff; pucData += 2; lX1 += 2; } // // See if there is one pixel left to draw. // if(lX1 == lX2) { // // Draw the final pixel. // *pucData = ulValue & 0xff; } }
//***************************************************************************** // //! Draws a horizontal line. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! \param lX1 is the X coordinate of the start of the line. //! \param lX2 is the X coordinate of the end of the line. //! \param lY is the Y coordinate of the line. //! \param ulValue is the color of the line. //! //! This function draws a horizontal line on the display. The coordinates of //! the line are assumed to be within the extents of the display. //! //! \return None. // //*****************************************************************************
Draws a horizontal line. \param pvDisplayData is a pointer to the driver-specific data for this display driver. \param lX1 is the X coordinate of the start of the line. \param lX2 is the X coordinate of the end of the line. \param lY is the Y coordinate of the line. \param ulValue is the color of the line. This function draws a horizontal line on the display. The coordinates of the line are assumed to be within the extents of the display. \return None.
[ "Draws", "a", "horizontal", "line", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "\\", "param", "lX1", "is", "the", "X", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "lX2", "is", "the", "X", "coordinate", "of", "the", "end", "of", "the", "line", ".", "\\", "param", "lY", "is", "the", "Y", "coordinate", "of", "the", "line", ".", "\\", "param", "ulValue", "is", "the", "color", "of", "the", "line", ".", "This", "function", "draws", "a", "horizontal", "line", "on", "the", "display", ".", "The", "coordinates", "of", "the", "line", "are", "assumed", "to", "be", "within", "the", "extents", "of", "the", "display", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPLineDrawH(void *pvDisplayData, long lX1, long lX2, long lY, unsigned long ulValue) { unsigned char *pucData; ASSERT(pvDisplayData); pucData = (unsigned char *)pvDisplayData; pucData += (*(unsigned short *)(pucData + 1) * lY) + lX1 + 6 + (256 * 3); ulValue = (ulValue << 24) | (ulValue << 16) | (ulValue << 8) | ulValue; if(((unsigned long)pucData) & 1) { *pucData++ = ulValue & 0xff; lX1++; } if(((unsigned long)pucData & 2) && ((lX2 - lX1) > 0)) { *(unsigned short *)pucData = ulValue & 0xffff; pucData += 2; lX1 += 2; } while((lX1 + 3) <= lX2) { *(unsigned long *)pucData = ulValue; pucData += 4; lX1 += 4; } if((lX1 + 1) <= lX2) { *(unsigned short *)pucData = ulValue & 0xffff; pucData += 2; lX1 += 2; } if(lX1 == lX2) { *pucData = ulValue & 0xff; } }
[ "static", "void", "GrOffScreen8BPPLineDrawH", "(", "void", "*", "pvDisplayData", ",", "long", "lX1", ",", "long", "lX2", ",", "long", "lY", ",", "unsigned", "long", "ulValue", ")", "{", "unsigned", "char", "*", "pucData", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "pucData", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", ";", "pucData", "+=", "(", "*", "(", "unsigned", "short", "*", ")", "(", "pucData", "+", "1", ")", "*", "lY", ")", "+", "lX1", "+", "6", "+", "(", "256", "*", "3", ")", ";", "ulValue", "=", "(", "ulValue", "<<", "24", ")", "|", "(", "ulValue", "<<", "16", ")", "|", "(", "ulValue", "<<", "8", ")", "|", "ulValue", ";", "if", "(", "(", "(", "unsigned", "long", ")", "pucData", ")", "&", "1", ")", "{", "*", "pucData", "++", "=", "ulValue", "&", "0xff", ";", "lX1", "++", ";", "}", "if", "(", "(", "(", "unsigned", "long", ")", "pucData", "&", "2", ")", "&&", "(", "(", "lX2", "-", "lX1", ")", ">", "0", ")", ")", "{", "*", "(", "unsigned", "short", "*", ")", "pucData", "=", "ulValue", "&", "0xffff", ";", "pucData", "+=", "2", ";", "lX1", "+=", "2", ";", "}", "while", "(", "(", "lX1", "+", "3", ")", "<=", "lX2", ")", "{", "*", "(", "unsigned", "long", "*", ")", "pucData", "=", "ulValue", ";", "pucData", "+=", "4", ";", "lX1", "+=", "4", ";", "}", "if", "(", "(", "lX1", "+", "1", ")", "<=", "lX2", ")", "{", "*", "(", "unsigned", "short", "*", ")", "pucData", "=", "ulValue", "&", "0xffff", ";", "pucData", "+=", "2", ";", "lX1", "+=", "2", ";", "}", "if", "(", "lX1", "==", "lX2", ")", "{", "*", "pucData", "=", "ulValue", "&", "0xff", ";", "}", "}" ]
Draws a horizontal line.
[ "Draws", "a", "horizontal", "line", "." ]
[ "//\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\r", "// starting pixel.\r", "//\r", "//\r", "// Copy the pixel value into all 4 pixels of the unsigned long. This will\r", "// be used later to write multiple pixels into memory (as opposed to one at\r", "// a time).\r", "//\r", "//\r", "// See if the buffer pointer is not half-word aligned.\r", "//\r", "//\r", "// Draw one pixel to half-word align the buffer pointer.\r", "//\r", "//\r", "// See if the buffer pointer is not word aligned and there are at least two\r", "// pixels left to draw.\r", "//\r", "//\r", "// Draw two pixels to word align the buffer pointer.\r", "//\r", "//\r", "// Loop while there are at least four pixels left to draw.\r", "//\r", "//\r", "// Draw four pixels.\r", "//\r", "//\r", "// See if there are at least two pixels left to draw.\r", "//\r", "//\r", "// Draw two pixels, leaving the buffer pointer half-word aligned.\r", "//\r", "//\r", "// See if there is one pixel left to draw.\r", "//\r", "//\r", "// Draw the final pixel.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "lX1", "type": "long" }, { "param": "lX2", "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": "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 }, { "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
GrOffScreen8BPPLineDrawV
void
static void GrOffScreen8BPPLineDrawV(void *pvDisplayData, long lX, long lY1, long lY2, unsigned long ulValue) { unsigned char *pucData; long lBytesPerRow; // // Check the arguments. // ASSERT(pvDisplayData); // // Create a character pointer for the display-specific data (which points // to the image buffer). // pucData = (unsigned char *)pvDisplayData; // // Compute the number of bytes per row in the image buffer. // lBytesPerRow = *(unsigned short *)(pucData + 1); // // Get the offset to the byte of the image buffer that contains the // starting pixel. // pucData += (lBytesPerRow * lY1) + lX + 6 + (256 * 3); // // Loop over the rows of the line. // for(; lY1 <= lY2; lY1++) { *pucData = ulValue; pucData += lBytesPerRow; } }
//***************************************************************************** // //! Draws a vertical line. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! \param lX is the X coordinate of the line. //! \param lY1 is the Y coordinate of the start of the line. //! \param lY2 is the Y coordinate of the end of the line. //! \param ulValue is the color of the line. //! //! This function draws a vertical line on the display. The coordinates of the //! line are assumed to be within the extents of the display. //! //! \return None. // //*****************************************************************************
Draws a vertical line. \param pvDisplayData is a pointer to the driver-specific data for this display driver. \param lX is the X coordinate of the line. \param lY1 is the Y coordinate of the start of the line. \param lY2 is the Y coordinate of the end of the line. \param ulValue is the color of the line. This function draws a vertical line on the display. The coordinates of the line are assumed to be within the extents of the display. \return None.
[ "Draws", "a", "vertical", "line", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "\\", "param", "lX", "is", "the", "X", "coordinate", "of", "the", "line", ".", "\\", "param", "lY1", "is", "the", "Y", "coordinate", "of", "the", "start", "of", "the", "line", ".", "\\", "param", "lY2", "is", "the", "Y", "coordinate", "of", "the", "end", "of", "the", "line", ".", "\\", "param", "ulValue", "is", "the", "color", "of", "the", "line", ".", "This", "function", "draws", "a", "vertical", "line", "on", "the", "display", ".", "The", "coordinates", "of", "the", "line", "are", "assumed", "to", "be", "within", "the", "extents", "of", "the", "display", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPLineDrawV(void *pvDisplayData, long lX, long lY1, long lY2, unsigned long ulValue) { unsigned char *pucData; long lBytesPerRow; ASSERT(pvDisplayData); pucData = (unsigned char *)pvDisplayData; lBytesPerRow = *(unsigned short *)(pucData + 1); pucData += (lBytesPerRow * lY1) + lX + 6 + (256 * 3); for(; lY1 <= lY2; lY1++) { *pucData = ulValue; pucData += lBytesPerRow; } }
[ "static", "void", "GrOffScreen8BPPLineDrawV", "(", "void", "*", "pvDisplayData", ",", "long", "lX", ",", "long", "lY1", ",", "long", "lY2", ",", "unsigned", "long", "ulValue", ")", "{", "unsigned", "char", "*", "pucData", ";", "long", "lBytesPerRow", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "pucData", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", ";", "lBytesPerRow", "=", "*", "(", "unsigned", "short", "*", ")", "(", "pucData", "+", "1", ")", ";", "pucData", "+=", "(", "lBytesPerRow", "*", "lY1", ")", "+", "lX", "+", "6", "+", "(", "256", "*", "3", ")", ";", "for", "(", ";", "lY1", "<=", "lY2", ";", "lY1", "++", ")", "{", "*", "pucData", "=", "ulValue", ";", "pucData", "+=", "lBytesPerRow", ";", "}", "}" ]
Draws a vertical line.
[ "Draws", "a", "vertical", "line", "." ]
[ "//\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", "// Compute the number of bytes per row in the image buffer.\r", "//\r", "//\r", "// Get the offset to the byte of the image buffer that contains the\r", "// starting pixel.\r", "//\r", "//\r", "// Loop over the rows of the line.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "lX", "type": "long" }, { "param": "lY1", "type": "long" }, { "param": "lY2", "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": "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 }, { "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
GrOffScreen8BPPRectFill
void
static void GrOffScreen8BPPRectFill(void *pvDisplayData, const tRectangle *pRect, unsigned long ulValue) { unsigned char *pucData, *pucPtr; long lBytesPerRow, lX, lY; // // Check the arguments. // ASSERT(pvDisplayData); ASSERT(pRect); // // Create a character pointer for the display-specific data (which points // to the image buffer). // pucData = (unsigned char *)pvDisplayData; // // Compute the number of bytes per row in the image buffer. // lBytesPerRow = *(unsigned short *)(pucData + 1); // // Get the offset to the byte of the image buffer that contains the // starting pixel. // pucData += (lBytesPerRow * pRect->sYMin) + pRect->sXMin + 6 + (256 * 3); // // Copy the pixel value into all 4 pixels of the unsigned long. This will // be used later to write multiple pixels into memory (as opposed to one at // a time). // ulValue = (ulValue << 24) | (ulValue << 16) | (ulValue << 8) | ulValue; // // Get the starting X coordinate. // lX = pRect->sXMin; // // See if the buffer pointer is not half-word aligned. // if(((unsigned long)pucData) & 1) { // // Draw one pixel column to half-word align the buffer pointer. // for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *pucPtr = ulValue & 0xff; } pucData++; lX++; } // // See if the buffer pointer is not word aligned and there are at least two // pixel columns left to draw. // if(((unsigned long)pucData & 2) && ((pRect->sXMax - lX) > 0)) { // // Draw two pixel columns to word align the buffer pointer. // for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned short *)pucPtr = ulValue & 0xffff; } pucData += 2; lX += 2; } // // Loop while there are at least four pixel columns left to draw. // while((lX + 3) <= pRect->sXMax) { // // Draw four pixel columns. // for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned long *)pucPtr = ulValue; } pucData += 4; lX += 4; } // // See if ther are at least two pixel columns left to draw. // if((lX + 1) <= pRect->sXMax) { // // Draw two pixel columns, leaving the buffer pointer half-word // aligned. // ulValue &= 0xffff; for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned short *)pucPtr = ulValue; } pucData += 2; lX += 2; } // // See if there is one pixel column left to draw. // if(lX == pRect->sXMax) { // // Draw the final pixel column. // ulValue &= 0xff; for(lY = pRect->sYMin; lY <= pRect->sYMax; lY++, pucData += lBytesPerRow) { *pucData = ulValue; } } }
//***************************************************************************** // //! Fills a rectangle. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! \param pRect is a pointer to the structure describing the rectangle. //! \param ulValue is the color of the rectangle. //! //! This function fills a rectangle on the display. The coordinates of the //! rectangle are assumed to be within the extents of the display, and the //! rectangle specification is fully inclusive (in other words, both sXMin and //! sXMax are drawn, along with sYMin and sYMax). //! //! \return None. // //*****************************************************************************
Fills a rectangle. \param pvDisplayData is a pointer to the driver-specific data for this display driver. \param pRect is a pointer to the structure describing the rectangle. \param ulValue is the color of the rectangle. This function fills a rectangle on the display. The coordinates of the rectangle are assumed to be within the extents of the display, and the rectangle specification is fully inclusive (in other words, both sXMin and sXMax are drawn, along with sYMin and sYMax). \return None.
[ "Fills", "a", "rectangle", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "\\", "param", "pRect", "is", "a", "pointer", "to", "the", "structure", "describing", "the", "rectangle", ".", "\\", "param", "ulValue", "is", "the", "color", "of", "the", "rectangle", ".", "This", "function", "fills", "a", "rectangle", "on", "the", "display", ".", "The", "coordinates", "of", "the", "rectangle", "are", "assumed", "to", "be", "within", "the", "extents", "of", "the", "display", "and", "the", "rectangle", "specification", "is", "fully", "inclusive", "(", "in", "other", "words", "both", "sXMin", "and", "sXMax", "are", "drawn", "along", "with", "sYMin", "and", "sYMax", ")", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPRectFill(void *pvDisplayData, const tRectangle *pRect, unsigned long ulValue) { unsigned char *pucData, *pucPtr; long lBytesPerRow, lX, lY; ASSERT(pvDisplayData); ASSERT(pRect); pucData = (unsigned char *)pvDisplayData; lBytesPerRow = *(unsigned short *)(pucData + 1); pucData += (lBytesPerRow * pRect->sYMin) + pRect->sXMin + 6 + (256 * 3); ulValue = (ulValue << 24) | (ulValue << 16) | (ulValue << 8) | ulValue; lX = pRect->sXMin; if(((unsigned long)pucData) & 1) { for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *pucPtr = ulValue & 0xff; } pucData++; lX++; } if(((unsigned long)pucData & 2) && ((pRect->sXMax - lX) > 0)) { for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned short *)pucPtr = ulValue & 0xffff; } pucData += 2; lX += 2; } while((lX + 3) <= pRect->sXMax) { for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned long *)pucPtr = ulValue; } pucData += 4; lX += 4; } if((lX + 1) <= pRect->sXMax) { ulValue &= 0xffff; for(lY = pRect->sYMin, pucPtr = pucData; lY <= pRect->sYMax; lY++, pucPtr += lBytesPerRow) { *(unsigned short *)pucPtr = ulValue; } pucData += 2; lX += 2; } if(lX == pRect->sXMax) { ulValue &= 0xff; for(lY = pRect->sYMin; lY <= pRect->sYMax; lY++, pucData += lBytesPerRow) { *pucData = ulValue; } } }
[ "static", "void", "GrOffScreen8BPPRectFill", "(", "void", "*", "pvDisplayData", ",", "const", "tRectangle", "*", "pRect", ",", "unsigned", "long", "ulValue", ")", "{", "unsigned", "char", "*", "pucData", ",", "*", "pucPtr", ";", "long", "lBytesPerRow", ",", "lX", ",", "lY", ";", "ASSERT", "(", "pvDisplayData", ")", ";", "ASSERT", "(", "pRect", ")", ";", "pucData", "=", "(", "unsigned", "char", "*", ")", "pvDisplayData", ";", "lBytesPerRow", "=", "*", "(", "unsigned", "short", "*", ")", "(", "pucData", "+", "1", ")", ";", "pucData", "+=", "(", "lBytesPerRow", "*", "pRect", "->", "sYMin", ")", "+", "pRect", "->", "sXMin", "+", "6", "+", "(", "256", "*", "3", ")", ";", "ulValue", "=", "(", "ulValue", "<<", "24", ")", "|", "(", "ulValue", "<<", "16", ")", "|", "(", "ulValue", "<<", "8", ")", "|", "ulValue", ";", "lX", "=", "pRect", "->", "sXMin", ";", "if", "(", "(", "(", "unsigned", "long", ")", "pucData", ")", "&", "1", ")", "{", "for", "(", "lY", "=", "pRect", "->", "sYMin", ",", "pucPtr", "=", "pucData", ";", "lY", "<=", "pRect", "->", "sYMax", ";", "lY", "++", ",", "pucPtr", "+=", "lBytesPerRow", ")", "{", "*", "pucPtr", "=", "ulValue", "&", "0xff", ";", "}", "pucData", "++", ";", "lX", "++", ";", "}", "if", "(", "(", "(", "unsigned", "long", ")", "pucData", "&", "2", ")", "&&", "(", "(", "pRect", "->", "sXMax", "-", "lX", ")", ">", "0", ")", ")", "{", "for", "(", "lY", "=", "pRect", "->", "sYMin", ",", "pucPtr", "=", "pucData", ";", "lY", "<=", "pRect", "->", "sYMax", ";", "lY", "++", ",", "pucPtr", "+=", "lBytesPerRow", ")", "{", "*", "(", "unsigned", "short", "*", ")", "pucPtr", "=", "ulValue", "&", "0xffff", ";", "}", "pucData", "+=", "2", ";", "lX", "+=", "2", ";", "}", "while", "(", "(", "lX", "+", "3", ")", "<=", "pRect", "->", "sXMax", ")", "{", "for", "(", "lY", "=", "pRect", "->", "sYMin", ",", "pucPtr", "=", "pucData", ";", "lY", "<=", "pRect", "->", "sYMax", ";", "lY", "++", ",", "pucPtr", "+=", "lBytesPerRow", ")", "{", "*", "(", "unsigned", "long", "*", ")", "pucPtr", "=", "ulValue", ";", "}", "pucData", "+=", "4", ";", "lX", "+=", "4", ";", "}", "if", "(", "(", "lX", "+", "1", ")", "<=", "pRect", "->", "sXMax", ")", "{", "ulValue", "&=", "0xffff", ";", "for", "(", "lY", "=", "pRect", "->", "sYMin", ",", "pucPtr", "=", "pucData", ";", "lY", "<=", "pRect", "->", "sYMax", ";", "lY", "++", ",", "pucPtr", "+=", "lBytesPerRow", ")", "{", "*", "(", "unsigned", "short", "*", ")", "pucPtr", "=", "ulValue", ";", "}", "pucData", "+=", "2", ";", "lX", "+=", "2", ";", "}", "if", "(", "lX", "==", "pRect", "->", "sXMax", ")", "{", "ulValue", "&=", "0xff", ";", "for", "(", "lY", "=", "pRect", "->", "sYMin", ";", "lY", "<=", "pRect", "->", "sYMax", ";", "lY", "++", ",", "pucData", "+=", "lBytesPerRow", ")", "{", "*", "pucData", "=", "ulValue", ";", "}", "}", "}" ]
Fills a rectangle.
[ "Fills", "a", "rectangle", "." ]
[ "//\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", "// Compute the number of bytes per row in the image buffer.\r", "//\r", "//\r", "// Get the offset to the byte of the image buffer that contains the\r", "// starting pixel.\r", "//\r", "//\r", "// Copy the pixel value into all 4 pixels of the unsigned long. This will\r", "// be used later to write multiple pixels into memory (as opposed to one at\r", "// a time).\r", "//\r", "//\r", "// Get the starting X coordinate.\r", "//\r", "//\r", "// See if the buffer pointer is not half-word aligned.\r", "//\r", "//\r", "// Draw one pixel column to half-word align the buffer pointer.\r", "//\r", "//\r", "// See if the buffer pointer is not word aligned and there are at least two\r", "// pixel columns left to draw.\r", "//\r", "//\r", "// Draw two pixel columns to word align the buffer pointer.\r", "//\r", "//\r", "// Loop while there are at least four pixel columns left to draw.\r", "//\r", "//\r", "// Draw four pixel columns.\r", "//\r", "//\r", "// See if ther are at least two pixel columns left to draw.\r", "//\r", "//\r", "// Draw two pixel columns, leaving the buffer pointer half-word\r", "// aligned.\r", "//\r", "//\r", "// See if there is one pixel column left to draw.\r", "//\r", "//\r", "// Draw the final pixel column.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" }, { "param": "pRect", "type": "tRectangle" }, { "param": "ulValue", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvDisplayData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pRect", "type": "tRectangle", "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
GrOffScreen8BPPFlush
void
static void GrOffScreen8BPPFlush(void *pvDisplayData) { // // Check the arguments. // ASSERT(pvDisplayData); }
//***************************************************************************** // //! Flushes any cached drawing operations. //! //! \param pvDisplayData is a pointer to the driver-specific data for this //! display driver. //! //! This functions flushes any cached drawing operations to the display. This //! is useful when a local frame buffer is used for drawing operations, and the //! flush would copy the local frame buffer to the display. For the off-screen //! display buffer driver, the flush is a no operation. //! //! \return None. // //*****************************************************************************
Flushes any cached drawing operations. \param pvDisplayData is a pointer to the driver-specific data for this display driver. This functions flushes any cached drawing operations to the display. This is useful when a local frame buffer is used for drawing operations, and the flush would copy the local frame buffer to the display. For the off-screen display buffer driver, the flush is a no operation. \return None.
[ "Flushes", "any", "cached", "drawing", "operations", ".", "\\", "param", "pvDisplayData", "is", "a", "pointer", "to", "the", "driver", "-", "specific", "data", "for", "this", "display", "driver", ".", "This", "functions", "flushes", "any", "cached", "drawing", "operations", "to", "the", "display", ".", "This", "is", "useful", "when", "a", "local", "frame", "buffer", "is", "used", "for", "drawing", "operations", "and", "the", "flush", "would", "copy", "the", "local", "frame", "buffer", "to", "the", "display", ".", "For", "the", "off", "-", "screen", "display", "buffer", "driver", "the", "flush", "is", "a", "no", "operation", ".", "\\", "return", "None", "." ]
static void GrOffScreen8BPPFlush(void *pvDisplayData) { ASSERT(pvDisplayData); }
[ "static", "void", "GrOffScreen8BPPFlush", "(", "void", "*", "pvDisplayData", ")", "{", "ASSERT", "(", "pvDisplayData", ")", ";", "}" ]
Flushes any cached drawing operations.
[ "Flushes", "any", "cached", "drawing", "operations", "." ]
[ "//\r", "// Check the arguments.\r", "//\r" ]
[ { "param": "pvDisplayData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvDisplayData", "type": "void", "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
GrOffScreen8BPPInit
void
void GrOffScreen8BPPInit(tDisplay *pDisplay, unsigned char *pucImage, long lWidth, long lHeight) { // // Check the arguments. // ASSERT(pDisplay); ASSERT(pucImage); // // Initialize the display structure. // pDisplay->lSize = sizeof(tDisplay); pDisplay->pvDisplayData = pucImage; pDisplay->usWidth = lWidth; pDisplay->usHeight = lHeight; pDisplay->pfnPixelDraw = GrOffScreen8BPPPixelDraw; pDisplay->pfnPixelDrawMultiple = GrOffScreen8BPPPixelDrawMultiple; pDisplay->pfnLineDrawH = GrOffScreen8BPPLineDrawH; pDisplay->pfnLineDrawV = GrOffScreen8BPPLineDrawV; pDisplay->pfnRectFill = GrOffScreen8BPPRectFill; pDisplay->pfnColorTranslate = GrOffScreen8BPPColorTranslate; pDisplay->pfnFlush = GrOffScreen8BPPFlush; // // Initialize the image buffer. // pucImage[0] = IMAGE_FMT_8BPP_UNCOMP; *(unsigned short *)(pucImage + 1) = lWidth; *(unsigned short *)(pucImage + 3) = lHeight; pucImage[5] = 255; }
//***************************************************************************** // //! Initializes an 8 BPP off-screen buffer. //! //! \param pDisplay is a pointer to the display structure to be configured for //! the 4 BPP off-screen buffer. //! \param pucImage is a pointer to the image buffer to be used for the //! off-screen buffer. //! \param lWidth is the width of the image buffer in pixels. //! \param lHeight is the height of the image buffer in pixels. //! //! This function initializes a display structure, preparing it to draw into //! the supplied image buffer. The image buffer is assumed to be large enough //! to hold an image of the specified geometry. //! //! \return None. // //*****************************************************************************
Initializes an 8 BPP off-screen buffer. \param pDisplay is a pointer to the display structure to be configured for the 4 BPP off-screen buffer. \param pucImage is a pointer to the image buffer to be used for the off-screen buffer. \param lWidth is the width of the image buffer in pixels. \param lHeight is the height of the image buffer in pixels. This function initializes a display structure, preparing it to draw into the supplied image buffer. The image buffer is assumed to be large enough to hold an image of the specified geometry. \return None.
[ "Initializes", "an", "8", "BPP", "off", "-", "screen", "buffer", ".", "\\", "param", "pDisplay", "is", "a", "pointer", "to", "the", "display", "structure", "to", "be", "configured", "for", "the", "4", "BPP", "off", "-", "screen", "buffer", ".", "\\", "param", "pucImage", "is", "a", "pointer", "to", "the", "image", "buffer", "to", "be", "used", "for", "the", "off", "-", "screen", "buffer", ".", "\\", "param", "lWidth", "is", "the", "width", "of", "the", "image", "buffer", "in", "pixels", ".", "\\", "param", "lHeight", "is", "the", "height", "of", "the", "image", "buffer", "in", "pixels", ".", "This", "function", "initializes", "a", "display", "structure", "preparing", "it", "to", "draw", "into", "the", "supplied", "image", "buffer", ".", "The", "image", "buffer", "is", "assumed", "to", "be", "large", "enough", "to", "hold", "an", "image", "of", "the", "specified", "geometry", ".", "\\", "return", "None", "." ]
void GrOffScreen8BPPInit(tDisplay *pDisplay, unsigned char *pucImage, long lWidth, long lHeight) { ASSERT(pDisplay); ASSERT(pucImage); pDisplay->lSize = sizeof(tDisplay); pDisplay->pvDisplayData = pucImage; pDisplay->usWidth = lWidth; pDisplay->usHeight = lHeight; pDisplay->pfnPixelDraw = GrOffScreen8BPPPixelDraw; pDisplay->pfnPixelDrawMultiple = GrOffScreen8BPPPixelDrawMultiple; pDisplay->pfnLineDrawH = GrOffScreen8BPPLineDrawH; pDisplay->pfnLineDrawV = GrOffScreen8BPPLineDrawV; pDisplay->pfnRectFill = GrOffScreen8BPPRectFill; pDisplay->pfnColorTranslate = GrOffScreen8BPPColorTranslate; pDisplay->pfnFlush = GrOffScreen8BPPFlush; pucImage[0] = IMAGE_FMT_8BPP_UNCOMP; *(unsigned short *)(pucImage + 1) = lWidth; *(unsigned short *)(pucImage + 3) = lHeight; pucImage[5] = 255; }
[ "void", "GrOffScreen8BPPInit", "(", "tDisplay", "*", "pDisplay", ",", "unsigned", "char", "*", "pucImage", ",", "long", "lWidth", ",", "long", "lHeight", ")", "{", "ASSERT", "(", "pDisplay", ")", ";", "ASSERT", "(", "pucImage", ")", ";", "pDisplay", "->", "lSize", "=", "sizeof", "(", "tDisplay", ")", ";", "pDisplay", "->", "pvDisplayData", "=", "pucImage", ";", "pDisplay", "->", "usWidth", "=", "lWidth", ";", "pDisplay", "->", "usHeight", "=", "lHeight", ";", "pDisplay", "->", "pfnPixelDraw", "=", "GrOffScreen8BPPPixelDraw", ";", "pDisplay", "->", "pfnPixelDrawMultiple", "=", "GrOffScreen8BPPPixelDrawMultiple", ";", "pDisplay", "->", "pfnLineDrawH", "=", "GrOffScreen8BPPLineDrawH", ";", "pDisplay", "->", "pfnLineDrawV", "=", "GrOffScreen8BPPLineDrawV", ";", "pDisplay", "->", "pfnRectFill", "=", "GrOffScreen8BPPRectFill", ";", "pDisplay", "->", "pfnColorTranslate", "=", "GrOffScreen8BPPColorTranslate", ";", "pDisplay", "->", "pfnFlush", "=", "GrOffScreen8BPPFlush", ";", "pucImage", "[", "0", "]", "=", "IMAGE_FMT_8BPP_UNCOMP", ";", "*", "(", "unsigned", "short", "*", ")", "(", "pucImage", "+", "1", ")", "=", "lWidth", ";", "*", "(", "unsigned", "short", "*", ")", "(", "pucImage", "+", "3", ")", "=", "lHeight", ";", "pucImage", "[", "5", "]", "=", "255", ";", "}" ]
Initializes an 8 BPP off-screen buffer.
[ "Initializes", "an", "8", "BPP", "off", "-", "screen", "buffer", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// Initialize the display structure.\r", "//\r", "//\r", "// Initialize the image buffer.\r", "//\r" ]
[ { "param": "pDisplay", "type": "tDisplay" }, { "param": "pucImage", "type": "unsigned char" }, { "param": "lWidth", "type": "long" }, { "param": "lHeight", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pDisplay", "type": "tDisplay", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pucImage", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lWidth", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lHeight", "type": "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
GrOffScreen8BPPPaletteSet
void
void GrOffScreen8BPPPaletteSet(tDisplay *pDisplay, unsigned long *pulPalette, unsigned long ulOffset, unsigned long ulCount) { unsigned char *pucData; // // Check the arguments. // ASSERT(pDisplay); ASSERT(pulPalette); ASSERT(ulOffset < 256); ASSERT((ulOffset + ulCount) <= 256); // // Get a pointer to the start of the image buffer's palette. // pucData = (unsigned char *)pDisplay->pvDisplayData + 6; // // Skip to the specified offset in the palette. // pucData += ulOffset * 3; // // Loop while there are more palette entries to add. // while(ulCount--) { // // Copy this palette entry to the image buffer's palette. // *pucData++ = (*pulPalette >> ClrBlueShift) & 0xff; *pucData++ = (*pulPalette >> ClrGreenShift) & 0xff; *pucData++ = (*pulPalette++ >> ClrRedShift) & 0xff; } }
//***************************************************************************** // //! Sets the palette of an 8 BPP off-screen buffer. //! //! \param pDisplay is a pointer to the display structure for the 4 BPP //! off-screen buffer. //! \param pulPalette is a pointer to the array of 24-bit RGB values to be //! placed into the palette. //! \param ulOffset is the starting offset into the image palette. //! \param ulCount is the number of palette entries to set. //! //! This function sets the entries of the palette used by the 8 BPP off-screen //! buffer. The palette is used to select colors for drawing via //! GrOffScreen4BPPColorTranslate(), and for the final rendering of the image //! to a real display via GrImageDraw(). //! //! \return None. // //*****************************************************************************
Sets the palette of an 8 BPP off-screen buffer. \param pDisplay is a pointer to the display structure for the 4 BPP off-screen buffer. \param pulPalette is a pointer to the array of 24-bit RGB values to be placed into the palette. \param ulOffset is the starting offset into the image palette. \param ulCount is the number of palette entries to set. This function sets the entries of the palette used by the 8 BPP off-screen buffer. The palette is used to select colors for drawing via GrOffScreen4BPPColorTranslate(), and for the final rendering of the image to a real display via GrImageDraw(). \return None.
[ "Sets", "the", "palette", "of", "an", "8", "BPP", "off", "-", "screen", "buffer", ".", "\\", "param", "pDisplay", "is", "a", "pointer", "to", "the", "display", "structure", "for", "the", "4", "BPP", "off", "-", "screen", "buffer", ".", "\\", "param", "pulPalette", "is", "a", "pointer", "to", "the", "array", "of", "24", "-", "bit", "RGB", "values", "to", "be", "placed", "into", "the", "palette", ".", "\\", "param", "ulOffset", "is", "the", "starting", "offset", "into", "the", "image", "palette", ".", "\\", "param", "ulCount", "is", "the", "number", "of", "palette", "entries", "to", "set", ".", "This", "function", "sets", "the", "entries", "of", "the", "palette", "used", "by", "the", "8", "BPP", "off", "-", "screen", "buffer", ".", "The", "palette", "is", "used", "to", "select", "colors", "for", "drawing", "via", "GrOffScreen4BPPColorTranslate", "()", "and", "for", "the", "final", "rendering", "of", "the", "image", "to", "a", "real", "display", "via", "GrImageDraw", "()", ".", "\\", "return", "None", "." ]
void GrOffScreen8BPPPaletteSet(tDisplay *pDisplay, unsigned long *pulPalette, unsigned long ulOffset, unsigned long ulCount) { unsigned char *pucData; ASSERT(pDisplay); ASSERT(pulPalette); ASSERT(ulOffset < 256); ASSERT((ulOffset + ulCount) <= 256); pucData = (unsigned char *)pDisplay->pvDisplayData + 6; pucData += ulOffset * 3; while(ulCount--) { *pucData++ = (*pulPalette >> ClrBlueShift) & 0xff; *pucData++ = (*pulPalette >> ClrGreenShift) & 0xff; *pucData++ = (*pulPalette++ >> ClrRedShift) & 0xff; } }
[ "void", "GrOffScreen8BPPPaletteSet", "(", "tDisplay", "*", "pDisplay", ",", "unsigned", "long", "*", "pulPalette", ",", "unsigned", "long", "ulOffset", ",", "unsigned", "long", "ulCount", ")", "{", "unsigned", "char", "*", "pucData", ";", "ASSERT", "(", "pDisplay", ")", ";", "ASSERT", "(", "pulPalette", ")", ";", "ASSERT", "(", "ulOffset", "<", "256", ")", ";", "ASSERT", "(", "(", "ulOffset", "+", "ulCount", ")", "<=", "256", ")", ";", "pucData", "=", "(", "unsigned", "char", "*", ")", "pDisplay", "->", "pvDisplayData", "+", "6", ";", "pucData", "+=", "ulOffset", "*", "3", ";", "while", "(", "ulCount", "--", ")", "{", "*", "pucData", "++", "=", "(", "*", "pulPalette", ">>", "ClrBlueShift", ")", "&", "0xff", ";", "*", "pucData", "++", "=", "(", "*", "pulPalette", ">>", "ClrGreenShift", ")", "&", "0xff", ";", "*", "pucData", "++", "=", "(", "*", "pulPalette", "++", ">>", "ClrRedShift", ")", "&", "0xff", ";", "}", "}" ]
Sets the palette of an 8 BPP off-screen buffer.
[ "Sets", "the", "palette", "of", "an", "8", "BPP", "off", "-", "screen", "buffer", "." ]
[ "//\r", "// Check the arguments.\r", "//\r", "//\r", "// Get a pointer to the start of the image buffer's palette.\r", "//\r", "//\r", "// Skip to the specified offset in the palette.\r", "//\r", "//\r", "// Loop while there are more palette entries to add.\r", "//\r", "//\r", "// Copy this palette entry to the image buffer's palette.\r", "//\r" ]
[ { "param": "pDisplay", "type": "tDisplay" }, { "param": "pulPalette", "type": "unsigned long" }, { "param": "ulOffset", "type": "unsigned long" }, { "param": "ulCount", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pDisplay", "type": "tDisplay", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pulPalette", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulOffset", "type": "unsigned long", "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": [] }
ac1387086641b05a4174a3932e218e1aaa72a2f5
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s3748/audio/audio.c
[ "BSD-3-Clause" ]
C
SysTickIntHandler
void
void SysTickIntHandler(void) { unsigned char ucButtons, ucDelta, ucRepeat; // // Get the debounced button states. // ucButtons = ButtonsPoll(&ucDelta, &ucRepeat); // // See if the up button was just pressed. // if(BUTTON_PRESSED(UP_BUTTON, ucButtons, ucDelta) || BUTTON_REPEAT(UP_BUTTON, ucRepeat)) { // // Increase the volume of the playback. // ClassDVolumeUp(16); } // // See if the down button was just pressed. // if(BUTTON_PRESSED(DOWN_BUTTON, ucButtons, ucDelta) || BUTTON_REPEAT(DOWN_BUTTON, ucRepeat)) { // // Decrease the volume of the playback. // ClassDVolumeDown(16); } // // See if the left button was just pressed. // if(BUTTON_PRESSED(LEFT_BUTTON, ucButtons, ucDelta)) { // // Start playback of the PCM stream. // ClassDPlayPCM(g_pucPCMData, sizeof(g_pucPCMData)); } // // See if the right button was just pressed. // if(BUTTON_PRESSED(RIGHT_BUTTON, ucButtons, ucDelta)) { // // Start playback of the ADPCM stream. // ClassDPlayADPCM(g_pucADPCMData, sizeof(g_pucADPCMData)); } // // See if the select button was just pressed. // if(BUTTON_PRESSED(SELECT_BUTTON, ucButtons, ucDelta)) { // // Stop playback. // ClassDStop(); } }
//***************************************************************************** // // Handles the SysTick timeout interrupt. // //*****************************************************************************
Handles the SysTick timeout interrupt.
[ "Handles", "the", "SysTick", "timeout", "interrupt", "." ]
void SysTickIntHandler(void) { unsigned char ucButtons, ucDelta, ucRepeat; ucButtons = ButtonsPoll(&ucDelta, &ucRepeat); if(BUTTON_PRESSED(UP_BUTTON, ucButtons, ucDelta) || BUTTON_REPEAT(UP_BUTTON, ucRepeat)) { ClassDVolumeUp(16); } if(BUTTON_PRESSED(DOWN_BUTTON, ucButtons, ucDelta) || BUTTON_REPEAT(DOWN_BUTTON, ucRepeat)) { ClassDVolumeDown(16); } if(BUTTON_PRESSED(LEFT_BUTTON, ucButtons, ucDelta)) { ClassDPlayPCM(g_pucPCMData, sizeof(g_pucPCMData)); } if(BUTTON_PRESSED(RIGHT_BUTTON, ucButtons, ucDelta)) { ClassDPlayADPCM(g_pucADPCMData, sizeof(g_pucADPCMData)); } if(BUTTON_PRESSED(SELECT_BUTTON, ucButtons, ucDelta)) { ClassDStop(); } }
[ "void", "SysTickIntHandler", "(", "void", ")", "{", "unsigned", "char", "ucButtons", ",", "ucDelta", ",", "ucRepeat", ";", "ucButtons", "=", "ButtonsPoll", "(", "&", "ucDelta", ",", "&", "ucRepeat", ")", ";", "if", "(", "BUTTON_PRESSED", "(", "UP_BUTTON", ",", "ucButtons", ",", "ucDelta", ")", "||", "BUTTON_REPEAT", "(", "UP_BUTTON", ",", "ucRepeat", ")", ")", "{", "ClassDVolumeUp", "(", "16", ")", ";", "}", "if", "(", "BUTTON_PRESSED", "(", "DOWN_BUTTON", ",", "ucButtons", ",", "ucDelta", ")", "||", "BUTTON_REPEAT", "(", "DOWN_BUTTON", ",", "ucRepeat", ")", ")", "{", "ClassDVolumeDown", "(", "16", ")", ";", "}", "if", "(", "BUTTON_PRESSED", "(", "LEFT_BUTTON", ",", "ucButtons", ",", "ucDelta", ")", ")", "{", "ClassDPlayPCM", "(", "g_pucPCMData", ",", "sizeof", "(", "g_pucPCMData", ")", ")", ";", "}", "if", "(", "BUTTON_PRESSED", "(", "RIGHT_BUTTON", ",", "ucButtons", ",", "ucDelta", ")", ")", "{", "ClassDPlayADPCM", "(", "g_pucADPCMData", ",", "sizeof", "(", "g_pucADPCMData", ")", ")", ";", "}", "if", "(", "BUTTON_PRESSED", "(", "SELECT_BUTTON", ",", "ucButtons", ",", "ucDelta", ")", ")", "{", "ClassDStop", "(", ")", ";", "}", "}" ]
Handles the SysTick timeout interrupt.
[ "Handles", "the", "SysTick", "timeout", "interrupt", "." ]
[ "//\r", "// Get the debounced button states.\r", "//\r", "//\r", "// See if the up button was just pressed.\r", "//\r", "//\r", "// Increase the volume of the playback.\r", "//\r", "//\r", "// See if the down button was just pressed.\r", "//\r", "//\r", "// Decrease the volume of the playback.\r", "//\r", "//\r", "// See if the left button was just pressed.\r", "//\r", "//\r", "// Start playback of the PCM stream.\r", "//\r", "//\r", "// See if the right button was just pressed.\r", "//\r", "//\r", "// Start playback of the ADPCM stream.\r", "//\r", "//\r", "// See if the select button was just pressed.\r", "//\r", "//\r", "// Stop playback.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fc820008b4192ed41fe6639cf3c6bbaab8428736
junyanl-code/Luminary-Micro-Library
third_party/FreeRTOS/Demo/Common/Full/death.c
[ "BSD-3-Clause" ]
C
vCreateTasks
void
static void vCreateTasks( void *pvParameters ) { const portTickType xDelay = ( portTickType ) 1000 / portTICK_RATE_MS; unsigned portBASE_TYPE uxPriority; const char * const pcTaskStartMsg = "Create task started.\r\n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); uxPriority = *( unsigned portBASE_TYPE * ) pvParameters; vPortFree( pvParameters ); for( ;; ) { /* Just loop round, delaying then creating the four suicidal tasks. */ vTaskDelay( xDelay ); xTaskCreate( vSuicidalTask, "SUICIDE1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask1 ); xTaskCreate( vSuicidalTask, "SUICIDE2", deathSTACK_SIZE, &xCreatedTask1, uxPriority, NULL ); xTaskCreate( vSuicidalTask, "SUICIDE1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask2 ); xTaskCreate( vSuicidalTask, "SUICIDE2", deathSTACK_SIZE, &xCreatedTask2, uxPriority, NULL ); ++sCreationCount; } }
/*lint !e818 !e550 Function prototype must be as per standard for task functions. */ /*-----------------------------------------------------------*/
lint !e818 !e550 Function prototype must be as per standard for task functions.
[ "lint", "!e818", "!e550", "Function", "prototype", "must", "be", "as", "per", "standard", "for", "task", "functions", "." ]
static void vCreateTasks( void *pvParameters ) { const portTickType xDelay = ( portTickType ) 1000 / portTICK_RATE_MS; unsigned portBASE_TYPE uxPriority; const char * const pcTaskStartMsg = "Create task started.\r\n"; vPrintDisplayMessage( &pcTaskStartMsg ); uxPriority = *( unsigned portBASE_TYPE * ) pvParameters; vPortFree( pvParameters ); for( ;; ) { vTaskDelay( xDelay ); xTaskCreate( vSuicidalTask, "SUICIDE1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask1 ); xTaskCreate( vSuicidalTask, "SUICIDE2", deathSTACK_SIZE, &xCreatedTask1, uxPriority, NULL ); xTaskCreate( vSuicidalTask, "SUICIDE1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask2 ); xTaskCreate( vSuicidalTask, "SUICIDE2", deathSTACK_SIZE, &xCreatedTask2, uxPriority, NULL ); ++sCreationCount; } }
[ "static", "void", "vCreateTasks", "(", "void", "*", "pvParameters", ")", "{", "const", "portTickType", "xDelay", "=", "(", "portTickType", ")", "1000", "/", "portTICK_RATE_MS", ";", "unsigned", "portBASE_TYPE", "uxPriority", ";", "const", "char", "*", "const", "pcTaskStartMsg", "=", "\"", "\\r", "\\n", "\"", ";", "vPrintDisplayMessage", "(", "&", "pcTaskStartMsg", ")", ";", "uxPriority", "=", "*", "(", "unsigned", "portBASE_TYPE", "*", ")", "pvParameters", ";", "vPortFree", "(", "pvParameters", ")", ";", "for", "(", ";", ";", ")", "{", "vTaskDelay", "(", "xDelay", ")", ";", "xTaskCreate", "(", "vSuicidalTask", ",", "\"", "\"", ",", "deathSTACK_SIZE", ",", "NULL", ",", "uxPriority", ",", "&", "xCreatedTask1", ")", ";", "xTaskCreate", "(", "vSuicidalTask", ",", "\"", "\"", ",", "deathSTACK_SIZE", ",", "&", "xCreatedTask1", ",", "uxPriority", ",", "NULL", ")", ";", "xTaskCreate", "(", "vSuicidalTask", ",", "\"", "\"", ",", "deathSTACK_SIZE", ",", "NULL", ",", "uxPriority", ",", "&", "xCreatedTask2", ")", ";", "xTaskCreate", "(", "vSuicidalTask", ",", "\"", "\"", ",", "deathSTACK_SIZE", ",", "&", "xCreatedTask2", ",", "uxPriority", ",", "NULL", ")", ";", "++", "sCreationCount", ";", "}", "}" ]
lint !e818 !e550 Function prototype must be as per standard for task functions.
[ "lint", "!e818", "!e550", "Function", "prototype", "must", "be", "as", "per", "standard", "for", "task", "functions", "." ]
[ "/* Queue a message for printing to say the task has started. */", "/* Just loop round, delaying then creating the four suicidal tasks. */" ]
[ { "param": "pvParameters", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvParameters", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc820008b4192ed41fe6639cf3c6bbaab8428736
junyanl-code/Luminary-Micro-Library
third_party/FreeRTOS/Demo/Common/Full/death.c
[ "BSD-3-Clause" ]
C
xIsCreateTaskStillRunning
portBASE_TYPE
portBASE_TYPE xIsCreateTaskStillRunning( void ) { static short sLastCreationCount = 0; short sReturn = pdTRUE; unsigned portBASE_TYPE uxTasksRunningNow; if( sLastCreationCount == sCreationCount ) { sReturn = pdFALSE; } uxTasksRunningNow = uxTaskGetNumberOfTasks(); if( uxTasksRunningNow < uxTasksRunningAtStart ) { sReturn = pdFALSE; } else if( ( uxTasksRunningNow - uxTasksRunningAtStart ) > uxMaxNumberOfExtraTasksRunning ) { sReturn = pdFALSE; } else { /* Everything is okay. */ } return sReturn; }
/* This is called to check that the creator task is still running and that there are not any more than four extra tasks. */
This is called to check that the creator task is still running and that there are not any more than four extra tasks.
[ "This", "is", "called", "to", "check", "that", "the", "creator", "task", "is", "still", "running", "and", "that", "there", "are", "not", "any", "more", "than", "four", "extra", "tasks", "." ]
portBASE_TYPE xIsCreateTaskStillRunning( void ) { static short sLastCreationCount = 0; short sReturn = pdTRUE; unsigned portBASE_TYPE uxTasksRunningNow; if( sLastCreationCount == sCreationCount ) { sReturn = pdFALSE; } uxTasksRunningNow = uxTaskGetNumberOfTasks(); if( uxTasksRunningNow < uxTasksRunningAtStart ) { sReturn = pdFALSE; } else if( ( uxTasksRunningNow - uxTasksRunningAtStart ) > uxMaxNumberOfExtraTasksRunning ) { sReturn = pdFALSE; } else { } return sReturn; }
[ "portBASE_TYPE", "xIsCreateTaskStillRunning", "(", "void", ")", "{", "static", "short", "sLastCreationCount", "=", "0", ";", "short", "sReturn", "=", "pdTRUE", ";", "unsigned", "portBASE_TYPE", "uxTasksRunningNow", ";", "if", "(", "sLastCreationCount", "==", "sCreationCount", ")", "{", "sReturn", "=", "pdFALSE", ";", "}", "uxTasksRunningNow", "=", "uxTaskGetNumberOfTasks", "(", ")", ";", "if", "(", "uxTasksRunningNow", "<", "uxTasksRunningAtStart", ")", "{", "sReturn", "=", "pdFALSE", ";", "}", "else", "if", "(", "(", "uxTasksRunningNow", "-", "uxTasksRunningAtStart", ")", ">", "uxMaxNumberOfExtraTasksRunning", ")", "{", "sReturn", "=", "pdFALSE", ";", "}", "else", "{", "}", "return", "sReturn", ";", "}" ]
This is called to check that the creator task is still running and that there are not any more than four extra tasks.
[ "This", "is", "called", "to", "check", "that", "the", "creator", "task", "is", "still", "running", "and", "that", "there", "are", "not", "any", "more", "than", "four", "extra", "tasks", "." ]
[ "/* Everything is okay. */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreSave
int
int FlashStoreSave(void) { unsigned long ulAddr; unsigned long ulOldestRecord = FLASH_STORE_START_ADDR; unsigned long ulOldestSeconds = 0xFFFFFFFF; tLogRecord *pRecord; // // Show a message to the user. // SetStatusText("SAVE", "SCANNING", "FLASH", 0); // // Start at beginning of flash storage area // ulAddr = FLASH_STORE_START_ADDR; // // Search all of flash area checking every stored record. // while(ulAddr < FLASH_STORE_END_ADDR) { // // If a record signature is found, check for oldest record, then // increment to the next record // if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { // // Get a pointer to the data record (account for flash header word) // pRecord = (tLogRecord *)(ulAddr + 4); // // If the seconds in this record are older than any found so far // then save the seconds value, and the address of this record // if(pRecord->ulSeconds < ulOldestSeconds) { ulOldestSeconds = pRecord->ulSeconds; ulOldestRecord = ulAddr; } // // Advance the address to the next record. // ulAddr += HWREG(ulAddr) & 0xFF; } // // Otherwise a record was not found so just advance to the next // location in flash // else { ulAddr += 4; } } // // If no "oldest" seconds was found, then there is no valid data stored // if(ulOldestSeconds == 0xFFFFFFFF) { SetStatusText("SAVE", "NO RECORDS", "FOUND", "PRESS <"); return(1); } // // Open the output file on the USB stick. It will return NULL if there // was any problem. // if(!USBStickOpenLogFile(0)) { SetStatusText("SAVE", 0, "USB ERROR", "PRESS <"); return(1); } // // Notify user we are saving data to USB // SetStatusText("SAVE", "SAVING", "TO USB", 0); // // Start reading records from flash, start at the address of the oldest // record, as found above. We scan through records, assuming the flash // store is not corrupted. Continue scanning until a blank space is // found which should indicate the end of recorded data, or until we // have read all the records. // ulAddr = ulOldestRecord; while(HWREG(ulAddr) != 0xFFFFFFFF) { unsigned long ulCount; unsigned long ulPartialCount; // // If a record signature is found (which it should be), extract the // record data and send it to USB stick. // if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { // // Get byte count for this record // ulCount = HWREG(ulAddr) & 0xFF; // // Adjust the count and the address to remove the flash header // ulCount -= 4; ulAddr += 4; // // Adjust for memory wrap // if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; } // // If the contents of this record go past the end of the memory // storage area, then perform a partial copy first. // ulPartialCount = 0; if((ulAddr + ulCount) >= FLASH_STORE_END_ADDR) { // // Find how many bytes are left on this page // ulPartialCount = FLASH_STORE_END_ADDR - ulAddr; // // Copy the portion until the end of memory store, adjust // remaining count and address // memcpy(g_ulRecordBuf, (void *)ulAddr, ulPartialCount); ulCount -= ulPartialCount; ulAddr = FLASH_STORE_START_ADDR; } // // Copy entire record (or remaining part of record if memory wrap) // into record buffer // memcpy(&g_ulRecordBuf[ulPartialCount / 4], (void *)ulAddr, ulCount); // // Update address pointer to next record // ulAddr += ulCount; // // Now we have an entire data logger record copied from flash // storage into a local (contiguous) memory buffer. Pass it // to the USB file writing function to write the record to the // USB stick. // USBStickWriteRecord((tLogRecord *)g_ulRecordBuf); } // // This should not happen, but it means we ended up in a non-blank // location that is not the start of a record. In this case just // advance through memory until either a blank location or another // record is found. // else { // // Increment to next word in flash, adjust for memory wrap. // ulAddr += 4; if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; } } } // // Close the USB stick file so that any buffers will be flushed. // USBStickCloseFile(); // // Inform user that save is complete. // SetStatusText("SAVE", "USB SAVE", "COMPLETE", "PRESS <"); // // Return success // return(0); }
//***************************************************************************** // // Saves data records that are stored in the flash to an externally connected // USB memory storage device (USB stick). // The flash memory is scanned for the presence of store data records. When // records are found they are written in CSV format to the USB stick. This // function assumes a non-corrupted storage area, and that any records, once // found, are contiguous with all stored records. It will find the oldest // record and start with that when storing. // //*****************************************************************************
Saves data records that are stored in the flash to an externally connected USB memory storage device (USB stick). The flash memory is scanned for the presence of store data records. When records are found they are written in CSV format to the USB stick. This function assumes a non-corrupted storage area, and that any records, once found, are contiguous with all stored records. It will find the oldest record and start with that when storing.
[ "Saves", "data", "records", "that", "are", "stored", "in", "the", "flash", "to", "an", "externally", "connected", "USB", "memory", "storage", "device", "(", "USB", "stick", ")", ".", "The", "flash", "memory", "is", "scanned", "for", "the", "presence", "of", "store", "data", "records", ".", "When", "records", "are", "found", "they", "are", "written", "in", "CSV", "format", "to", "the", "USB", "stick", ".", "This", "function", "assumes", "a", "non", "-", "corrupted", "storage", "area", "and", "that", "any", "records", "once", "found", "are", "contiguous", "with", "all", "stored", "records", ".", "It", "will", "find", "the", "oldest", "record", "and", "start", "with", "that", "when", "storing", "." ]
int FlashStoreSave(void) { unsigned long ulAddr; unsigned long ulOldestRecord = FLASH_STORE_START_ADDR; unsigned long ulOldestSeconds = 0xFFFFFFFF; tLogRecord *pRecord; SetStatusText("SAVE", "SCANNING", "FLASH", 0); ulAddr = FLASH_STORE_START_ADDR; while(ulAddr < FLASH_STORE_END_ADDR) { if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { pRecord = (tLogRecord *)(ulAddr + 4); if(pRecord->ulSeconds < ulOldestSeconds) { ulOldestSeconds = pRecord->ulSeconds; ulOldestRecord = ulAddr; } ulAddr += HWREG(ulAddr) & 0xFF; } else { ulAddr += 4; } } if(ulOldestSeconds == 0xFFFFFFFF) { SetStatusText("SAVE", "NO RECORDS", "FOUND", "PRESS <"); return(1); } if(!USBStickOpenLogFile(0)) { SetStatusText("SAVE", 0, "USB ERROR", "PRESS <"); return(1); } SetStatusText("SAVE", "SAVING", "TO USB", 0); ulAddr = ulOldestRecord; while(HWREG(ulAddr) != 0xFFFFFFFF) { unsigned long ulCount; unsigned long ulPartialCount; if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { ulCount = HWREG(ulAddr) & 0xFF; ulCount -= 4; ulAddr += 4; if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; } ulPartialCount = 0; if((ulAddr + ulCount) >= FLASH_STORE_END_ADDR) { ulPartialCount = FLASH_STORE_END_ADDR - ulAddr; memcpy(g_ulRecordBuf, (void *)ulAddr, ulPartialCount); ulCount -= ulPartialCount; ulAddr = FLASH_STORE_START_ADDR; } memcpy(&g_ulRecordBuf[ulPartialCount / 4], (void *)ulAddr, ulCount); ulAddr += ulCount; USBStickWriteRecord((tLogRecord *)g_ulRecordBuf); } else { ulAddr += 4; if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; } } } USBStickCloseFile(); SetStatusText("SAVE", "USB SAVE", "COMPLETE", "PRESS <"); return(0); }
[ "int", "FlashStoreSave", "(", "void", ")", "{", "unsigned", "long", "ulAddr", ";", "unsigned", "long", "ulOldestRecord", "=", "FLASH_STORE_START_ADDR", ";", "unsigned", "long", "ulOldestSeconds", "=", "0xFFFFFFFF", ";", "tLogRecord", "*", "pRecord", ";", "SetStatusText", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "0", ")", ";", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "while", "(", "ulAddr", "<", "FLASH_STORE_END_ADDR", ")", "{", "if", "(", "(", "HWREG", "(", "ulAddr", ")", "&", "0xFFFFFF00", ")", "==", "0x53554100", ")", "{", "pRecord", "=", "(", "tLogRecord", "*", ")", "(", "ulAddr", "+", "4", ")", ";", "if", "(", "pRecord", "->", "ulSeconds", "<", "ulOldestSeconds", ")", "{", "ulOldestSeconds", "=", "pRecord", "->", "ulSeconds", ";", "ulOldestRecord", "=", "ulAddr", ";", "}", "ulAddr", "+=", "HWREG", "(", "ulAddr", ")", "&", "0xFF", ";", "}", "else", "{", "ulAddr", "+=", "4", ";", "}", "}", "if", "(", "ulOldestSeconds", "==", "0xFFFFFFFF", ")", "{", "SetStatusText", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "return", "(", "1", ")", ";", "}", "if", "(", "!", "USBStickOpenLogFile", "(", "0", ")", ")", "{", "SetStatusText", "(", "\"", "\"", ",", "0", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "return", "(", "1", ")", ";", "}", "SetStatusText", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "0", ")", ";", "ulAddr", "=", "ulOldestRecord", ";", "while", "(", "HWREG", "(", "ulAddr", ")", "!=", "0xFFFFFFFF", ")", "{", "unsigned", "long", "ulCount", ";", "unsigned", "long", "ulPartialCount", ";", "if", "(", "(", "HWREG", "(", "ulAddr", ")", "&", "0xFFFFFF00", ")", "==", "0x53554100", ")", "{", "ulCount", "=", "HWREG", "(", "ulAddr", ")", "&", "0xFF", ";", "ulCount", "-=", "4", ";", "ulAddr", "+=", "4", ";", "if", "(", "ulAddr", ">=", "FLASH_STORE_END_ADDR", ")", "{", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "}", "ulPartialCount", "=", "0", ";", "if", "(", "(", "ulAddr", "+", "ulCount", ")", ">=", "FLASH_STORE_END_ADDR", ")", "{", "ulPartialCount", "=", "FLASH_STORE_END_ADDR", "-", "ulAddr", ";", "memcpy", "(", "g_ulRecordBuf", ",", "(", "void", "*", ")", "ulAddr", ",", "ulPartialCount", ")", ";", "ulCount", "-=", "ulPartialCount", ";", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "}", "memcpy", "(", "&", "g_ulRecordBuf", "[", "ulPartialCount", "/", "4", "]", ",", "(", "void", "*", ")", "ulAddr", ",", "ulCount", ")", ";", "ulAddr", "+=", "ulCount", ";", "USBStickWriteRecord", "(", "(", "tLogRecord", "*", ")", "g_ulRecordBuf", ")", ";", "}", "else", "{", "ulAddr", "+=", "4", ";", "if", "(", "ulAddr", ">=", "FLASH_STORE_END_ADDR", ")", "{", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "}", "}", "}", "USBStickCloseFile", "(", ")", ";", "SetStatusText", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "return", "(", "0", ")", ";", "}" ]
Saves data records that are stored in the flash to an externally connected USB memory storage device (USB stick).
[ "Saves", "data", "records", "that", "are", "stored", "in", "the", "flash", "to", "an", "externally", "connected", "USB", "memory", "storage", "device", "(", "USB", "stick", ")", "." ]
[ "//\r", "// Show a message to the user.\r", "//\r", "//\r", "// Start at beginning of flash storage area\r", "//\r", "//\r", "// Search all of flash area checking every stored record.\r", "//\r", "//\r", "// If a record signature is found, check for oldest record, then\r", "// increment to the next record\r", "//\r", "//\r", "// Get a pointer to the data record (account for flash header word)\r", "//\r", "//\r", "// If the seconds in this record are older than any found so far\r", "// then save the seconds value, and the address of this record\r", "//\r", "//\r", "// Advance the address to the next record.\r", "//\r", "//\r", "// Otherwise a record was not found so just advance to the next\r", "// location in flash\r", "//\r", "//\r", "// If no \"oldest\" seconds was found, then there is no valid data stored\r", "//\r", "//\r", "// Open the output file on the USB stick. It will return NULL if there\r", "// was any problem.\r", "//\r", "//\r", "// Notify user we are saving data to USB\r", "//\r", "//\r", "// Start reading records from flash, start at the address of the oldest\r", "// record, as found above. We scan through records, assuming the flash\r", "// store is not corrupted. Continue scanning until a blank space is\r", "// found which should indicate the end of recorded data, or until we\r", "// have read all the records.\r", "//\r", "//\r", "// If a record signature is found (which it should be), extract the\r", "// record data and send it to USB stick.\r", "//\r", "//\r", "// Get byte count for this record\r", "//\r", "//\r", "// Adjust the count and the address to remove the flash header\r", "//\r", "//\r", "// Adjust for memory wrap\r", "//\r", "//\r", "// If the contents of this record go past the end of the memory\r", "// storage area, then perform a partial copy first.\r", "//\r", "//\r", "// Find how many bytes are left on this page\r", "//\r", "//\r", "// Copy the portion until the end of memory store, adjust\r", "// remaining count and address\r", "//\r", "//\r", "// Copy entire record (or remaining part of record if memory wrap)\r", "// into record buffer\r", "//\r", "//\r", "// Update address pointer to next record\r", "//\r", "//\r", "// Now we have an entire data logger record copied from flash\r", "// storage into a local (contiguous) memory buffer. Pass it\r", "// to the USB file writing function to write the record to the\r", "// USB stick.\r", "//\r", "//\r", "// This should not happen, but it means we ended up in a non-blank\r", "// location that is not the start of a record. In this case just\r", "// advance through memory until either a blank location or another\r", "// record is found.\r", "//\r", "//\r", "// Increment to next word in flash, adjust for memory wrap.\r", "//\r", "//\r", "// Close the USB stick file so that any buffers will be flushed.\r", "//\r", "//\r", "// Inform user that save is complete.\r", "//\r", "//\r", "// Return success\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreOpenLogFile
int
int FlashStoreOpenLogFile(unsigned long ulStartAddr) { unsigned long ulAddr; // // If a valid starting address is specified, then just use that and skip // the search below. // if((ulStartAddr >= FLASH_STORE_START_ADDR) && (ulStartAddr < FLASH_STORE_END_ADDR)) { g_ulStoreAddr = ulStartAddr; return(0); } // // Start at beginning of flash storage area // ulAddr = FLASH_STORE_START_ADDR; // // Search until a blank is found or the end of flash storage area // while((HWREG(ulAddr) != 0xFFFFFFFF) && (ulAddr < FLASH_STORE_END_ADDR)) { // // If a record signature is found, then increment to the next record // if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { ulAddr += HWREG(ulAddr) & 0xFF; } // // Otherwise just advance to the next location in flash // else { ulAddr += 4; } } // // If we are at the end of flash that means no blank area was found. // So reset to the beginning and erase the first page. // if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; FlashErase(ulAddr); } // // When we reach here we either found a blank location, or made a new // blank location by erasing the first page. // To keep things simple we are making an assumption that the flash store // is not corrupted and that the first blank location implies the start // of a blank area suitable for storing data records. // g_ulStoreAddr = ulAddr; // // Return success indication to caller // return(0); }
//***************************************************************************** // // This is called at the start of logging to prepare space in flash for // storage of logged data. It searches for the first blank area in the // flash storage to be used for storing records. // // If a starting address is specified then the search is skipped and it goes // directly to the new address. If the starting address is 0, then it performs // the search. // //*****************************************************************************
This is called at the start of logging to prepare space in flash for storage of logged data. It searches for the first blank area in the flash storage to be used for storing records. If a starting address is specified then the search is skipped and it goes directly to the new address. If the starting address is 0, then it performs the search.
[ "This", "is", "called", "at", "the", "start", "of", "logging", "to", "prepare", "space", "in", "flash", "for", "storage", "of", "logged", "data", ".", "It", "searches", "for", "the", "first", "blank", "area", "in", "the", "flash", "storage", "to", "be", "used", "for", "storing", "records", ".", "If", "a", "starting", "address", "is", "specified", "then", "the", "search", "is", "skipped", "and", "it", "goes", "directly", "to", "the", "new", "address", ".", "If", "the", "starting", "address", "is", "0", "then", "it", "performs", "the", "search", "." ]
int FlashStoreOpenLogFile(unsigned long ulStartAddr) { unsigned long ulAddr; if((ulStartAddr >= FLASH_STORE_START_ADDR) && (ulStartAddr < FLASH_STORE_END_ADDR)) { g_ulStoreAddr = ulStartAddr; return(0); } ulAddr = FLASH_STORE_START_ADDR; while((HWREG(ulAddr) != 0xFFFFFFFF) && (ulAddr < FLASH_STORE_END_ADDR)) { if((HWREG(ulAddr) & 0xFFFFFF00) == 0x53554100) { ulAddr += HWREG(ulAddr) & 0xFF; } else { ulAddr += 4; } } if(ulAddr >= FLASH_STORE_END_ADDR) { ulAddr = FLASH_STORE_START_ADDR; FlashErase(ulAddr); } g_ulStoreAddr = ulAddr; return(0); }
[ "int", "FlashStoreOpenLogFile", "(", "unsigned", "long", "ulStartAddr", ")", "{", "unsigned", "long", "ulAddr", ";", "if", "(", "(", "ulStartAddr", ">=", "FLASH_STORE_START_ADDR", ")", "&&", "(", "ulStartAddr", "<", "FLASH_STORE_END_ADDR", ")", ")", "{", "g_ulStoreAddr", "=", "ulStartAddr", ";", "return", "(", "0", ")", ";", "}", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "while", "(", "(", "HWREG", "(", "ulAddr", ")", "!=", "0xFFFFFFFF", ")", "&&", "(", "ulAddr", "<", "FLASH_STORE_END_ADDR", ")", ")", "{", "if", "(", "(", "HWREG", "(", "ulAddr", ")", "&", "0xFFFFFF00", ")", "==", "0x53554100", ")", "{", "ulAddr", "+=", "HWREG", "(", "ulAddr", ")", "&", "0xFF", ";", "}", "else", "{", "ulAddr", "+=", "4", ";", "}", "}", "if", "(", "ulAddr", ">=", "FLASH_STORE_END_ADDR", ")", "{", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "FlashErase", "(", "ulAddr", ")", ";", "}", "g_ulStoreAddr", "=", "ulAddr", ";", "return", "(", "0", ")", ";", "}" ]
This is called at the start of logging to prepare space in flash for storage of logged data.
[ "This", "is", "called", "at", "the", "start", "of", "logging", "to", "prepare", "space", "in", "flash", "for", "storage", "of", "logged", "data", "." ]
[ "//\r", "// If a valid starting address is specified, then just use that and skip\r", "// the search below.\r", "//\r", "//\r", "// Start at beginning of flash storage area\r", "//\r", "//\r", "// Search until a blank is found or the end of flash storage area\r", "//\r", "//\r", "// If a record signature is found, then increment to the next record\r", "//\r", "//\r", "// Otherwise just advance to the next location in flash\r", "//\r", "//\r", "// If we are at the end of flash that means no blank area was found.\r", "// So reset to the beginning and erase the first page.\r", "//\r", "//\r", "// When we reach here we either found a blank location, or made a new\r", "// blank location by erasing the first page.\r", "// To keep things simple we are making an assumption that the flash store\r", "// is not corrupted and that the first blank location implies the start\r", "// of a blank area suitable for storing data records.\r", "//\r", "//\r", "// Return success indication to caller\r", "//\r" ]
[ { "param": "ulStartAddr", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulStartAddr", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreWriteRecord
int
int FlashStoreWriteRecord(tLogRecord *pRecord) { unsigned long ulIdx; unsigned long ulItemCount; unsigned long *pulRecord; // // Check the arguments // ASSERT(pRecord); if(!pRecord) { return(1); } // // Determine how many channels are to be logged // ulIdx = pRecord->usItemMask; ulItemCount = 0; while(ulIdx) { if(ulIdx & 1) { ulItemCount++; } ulIdx >>= 1; } // // Add 16-bit count equivalent of record header, time stamp, and // selected items mask. This is the total number of 16 bit words // of the record. // ulItemCount += 6; // // Convert the count to bytes, be sure to pad to 32-bit alignment. // ulItemCount = ((ulItemCount * 2) + 3) & ~3; // // Create the flash record header, which is a 3-byte signature and a // one byte count of bytes in the record. Save it at the beginning // of the write buffer. // ulIdx = 0x53554100 | (ulItemCount & 0xFF); g_ulRecordBuf[0] = ulIdx; // // Copy the rest of the record to the buffer, and get a pointer to // the buffer. // memcpy(&g_ulRecordBuf[1], pRecord, ulItemCount - 4); pulRecord = g_ulRecordBuf; // // Check to see if the record is going to cross a page boundary. // if(((g_ulStoreAddr & 0x3FF) + ulItemCount) > 0x3FF) { // // Find number of bytes remaining on this page // ulIdx = 0x400 - (g_ulStoreAddr & 0x3FF); // // Program part of the record on the space remaining on the current // page // FlashProgram(pulRecord, g_ulStoreAddr, ulIdx); // // Increment the store address by the amount just written, which // should make the new store address be at the beginning of the next // flash page. // g_ulStoreAddr += ulIdx; // // Adjust the remaining bytes to program, and the pointer to the // remainder of the record data. // ulItemCount -= ulIdx; pulRecord = &g_ulRecordBuf[ulIdx / 4]; // // Check to see if the new page is past the end of store and adjust // if(g_ulStoreAddr >= FLASH_STORE_END_ADDR) { g_ulStoreAddr = FLASH_STORE_START_ADDR; } // // If new page is not blank, then erase it // if(HWREG(g_ulStoreAddr) != 0xFFFFFFFF) { FlashErase(g_ulStoreAddr); } } // // Now program the remaining part of the record (if we crossed a page // boundary above) or the full record to the current location in flash // FlashProgram(pulRecord, g_ulStoreAddr, ulItemCount); // // Increment the storage address to the next location. // g_ulStoreAddr += ulItemCount; // // Return success indication to caller. // return(0); }
//***************************************************************************** // // This is called each time there is a new data record to log to the flash // storage area. A simple algorithm is used which rotates programming // data log records through an area of flash. It is assumed that the current // page is blank. Records are stored on the current page until a page // boundary is crossed. If the page boundary is crossed and the new page // is not blank (testing only the first location), then the new page is // erased. Finally the entire record is programmed into flash and the // storage pointers are updated. // // While storing and when crossing to a new page, if the flash page is not // blank it is erased. So this algorithm overwrites old data. // // The data is stored in flash as a record, with a flash header prepended, // and with the record length padded to be a multiple of 4 bytes. The flash // header is a 3-byte magic number and one byte of record length. // //*****************************************************************************
This is called each time there is a new data record to log to the flash storage area. A simple algorithm is used which rotates programming data log records through an area of flash. It is assumed that the current page is blank. Records are stored on the current page until a page boundary is crossed. If the page boundary is crossed and the new page is not blank (testing only the first location), then the new page is erased. Finally the entire record is programmed into flash and the storage pointers are updated. While storing and when crossing to a new page, if the flash page is not blank it is erased. So this algorithm overwrites old data. The data is stored in flash as a record, with a flash header prepended, and with the record length padded to be a multiple of 4 bytes. The flash header is a 3-byte magic number and one byte of record length.
[ "This", "is", "called", "each", "time", "there", "is", "a", "new", "data", "record", "to", "log", "to", "the", "flash", "storage", "area", ".", "A", "simple", "algorithm", "is", "used", "which", "rotates", "programming", "data", "log", "records", "through", "an", "area", "of", "flash", ".", "It", "is", "assumed", "that", "the", "current", "page", "is", "blank", ".", "Records", "are", "stored", "on", "the", "current", "page", "until", "a", "page", "boundary", "is", "crossed", ".", "If", "the", "page", "boundary", "is", "crossed", "and", "the", "new", "page", "is", "not", "blank", "(", "testing", "only", "the", "first", "location", ")", "then", "the", "new", "page", "is", "erased", ".", "Finally", "the", "entire", "record", "is", "programmed", "into", "flash", "and", "the", "storage", "pointers", "are", "updated", ".", "While", "storing", "and", "when", "crossing", "to", "a", "new", "page", "if", "the", "flash", "page", "is", "not", "blank", "it", "is", "erased", ".", "So", "this", "algorithm", "overwrites", "old", "data", ".", "The", "data", "is", "stored", "in", "flash", "as", "a", "record", "with", "a", "flash", "header", "prepended", "and", "with", "the", "record", "length", "padded", "to", "be", "a", "multiple", "of", "4", "bytes", ".", "The", "flash", "header", "is", "a", "3", "-", "byte", "magic", "number", "and", "one", "byte", "of", "record", "length", "." ]
int FlashStoreWriteRecord(tLogRecord *pRecord) { unsigned long ulIdx; unsigned long ulItemCount; unsigned long *pulRecord; ASSERT(pRecord); if(!pRecord) { return(1); } ulIdx = pRecord->usItemMask; ulItemCount = 0; while(ulIdx) { if(ulIdx & 1) { ulItemCount++; } ulIdx >>= 1; } ulItemCount += 6; ulItemCount = ((ulItemCount * 2) + 3) & ~3; ulIdx = 0x53554100 | (ulItemCount & 0xFF); g_ulRecordBuf[0] = ulIdx; memcpy(&g_ulRecordBuf[1], pRecord, ulItemCount - 4); pulRecord = g_ulRecordBuf; if(((g_ulStoreAddr & 0x3FF) + ulItemCount) > 0x3FF) { ulIdx = 0x400 - (g_ulStoreAddr & 0x3FF); FlashProgram(pulRecord, g_ulStoreAddr, ulIdx); g_ulStoreAddr += ulIdx; ulItemCount -= ulIdx; pulRecord = &g_ulRecordBuf[ulIdx / 4]; if(g_ulStoreAddr >= FLASH_STORE_END_ADDR) { g_ulStoreAddr = FLASH_STORE_START_ADDR; } if(HWREG(g_ulStoreAddr) != 0xFFFFFFFF) { FlashErase(g_ulStoreAddr); } } FlashProgram(pulRecord, g_ulStoreAddr, ulItemCount); g_ulStoreAddr += ulItemCount; return(0); }
[ "int", "FlashStoreWriteRecord", "(", "tLogRecord", "*", "pRecord", ")", "{", "unsigned", "long", "ulIdx", ";", "unsigned", "long", "ulItemCount", ";", "unsigned", "long", "*", "pulRecord", ";", "ASSERT", "(", "pRecord", ")", ";", "if", "(", "!", "pRecord", ")", "{", "return", "(", "1", ")", ";", "}", "ulIdx", "=", "pRecord", "->", "usItemMask", ";", "ulItemCount", "=", "0", ";", "while", "(", "ulIdx", ")", "{", "if", "(", "ulIdx", "&", "1", ")", "{", "ulItemCount", "++", ";", "}", "ulIdx", ">>=", "1", ";", "}", "ulItemCount", "+=", "6", ";", "ulItemCount", "=", "(", "(", "ulItemCount", "*", "2", ")", "+", "3", ")", "&", "~", "3", ";", "ulIdx", "=", "0x53554100", "|", "(", "ulItemCount", "&", "0xFF", ")", ";", "g_ulRecordBuf", "[", "0", "]", "=", "ulIdx", ";", "memcpy", "(", "&", "g_ulRecordBuf", "[", "1", "]", ",", "pRecord", ",", "ulItemCount", "-", "4", ")", ";", "pulRecord", "=", "g_ulRecordBuf", ";", "if", "(", "(", "(", "g_ulStoreAddr", "&", "0x3FF", ")", "+", "ulItemCount", ")", ">", "0x3FF", ")", "{", "ulIdx", "=", "0x400", "-", "(", "g_ulStoreAddr", "&", "0x3FF", ")", ";", "FlashProgram", "(", "pulRecord", ",", "g_ulStoreAddr", ",", "ulIdx", ")", ";", "g_ulStoreAddr", "+=", "ulIdx", ";", "ulItemCount", "-=", "ulIdx", ";", "pulRecord", "=", "&", "g_ulRecordBuf", "[", "ulIdx", "/", "4", "]", ";", "if", "(", "g_ulStoreAddr", ">=", "FLASH_STORE_END_ADDR", ")", "{", "g_ulStoreAddr", "=", "FLASH_STORE_START_ADDR", ";", "}", "if", "(", "HWREG", "(", "g_ulStoreAddr", ")", "!=", "0xFFFFFFFF", ")", "{", "FlashErase", "(", "g_ulStoreAddr", ")", ";", "}", "}", "FlashProgram", "(", "pulRecord", ",", "g_ulStoreAddr", ",", "ulItemCount", ")", ";", "g_ulStoreAddr", "+=", "ulItemCount", ";", "return", "(", "0", ")", ";", "}" ]
This is called each time there is a new data record to log to the flash storage area.
[ "This", "is", "called", "each", "time", "there", "is", "a", "new", "data", "record", "to", "log", "to", "the", "flash", "storage", "area", "." ]
[ "//\r", "// Check the arguments\r", "//\r", "//\r", "// Determine how many channels are to be logged\r", "//\r", "//\r", "// Add 16-bit count equivalent of record header, time stamp, and\r", "// selected items mask. This is the total number of 16 bit words\r", "// of the record.\r", "//\r", "//\r", "// Convert the count to bytes, be sure to pad to 32-bit alignment.\r", "//\r", "//\r", "// Create the flash record header, which is a 3-byte signature and a\r", "// one byte count of bytes in the record. Save it at the beginning\r", "// of the write buffer.\r", "//\r", "//\r", "// Copy the rest of the record to the buffer, and get a pointer to\r", "// the buffer.\r", "//\r", "//\r", "// Check to see if the record is going to cross a page boundary.\r", "//\r", "//\r", "// Find number of bytes remaining on this page\r", "//\r", "//\r", "// Program part of the record on the space remaining on the current\r", "// page\r", "//\r", "//\r", "// Increment the store address by the amount just written, which\r", "// should make the new store address be at the beginning of the next\r", "// flash page.\r", "//\r", "//\r", "// Adjust the remaining bytes to program, and the pointer to the\r", "// remainder of the record data.\r", "//\r", "//\r", "// Check to see if the new page is past the end of store and adjust\r", "//\r", "//\r", "// If new page is not blank, then erase it\r", "//\r", "//\r", "// Now program the remaining part of the record (if we crossed a page\r", "// boundary above) or the full record to the current location in flash\r", "//\r", "//\r", "// Increment the storage address to the next location.\r", "//\r", "//\r", "// Return success indication to caller.\r", "//\r" ]
[ { "param": "pRecord", "type": "tLogRecord" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pRecord", "type": "tLogRecord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreGetAddr
null
unsigned long FlashStoreGetAddr(void) { return(g_ulStoreAddr); }
//***************************************************************************** // // Return the current address being used for storing records. // //*****************************************************************************
Return the current address being used for storing records.
[ "Return", "the", "current", "address", "being", "used", "for", "storing", "records", "." ]
unsigned long FlashStoreGetAddr(void) { return(g_ulStoreAddr); }
[ "unsigned", "long", "FlashStoreGetAddr", "(", "void", ")", "{", "return", "(", "g_ulStoreAddr", ")", ";", "}" ]
Return the current address being used for storing records.
[ "Return", "the", "current", "address", "being", "used", "for", "storing", "records", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreErase
void
void FlashStoreErase(void) { unsigned long ulAddr; // // Inform user we are erasing // SetStatusText("ERASE", 0, "ERASING", 0); // // Loop through entire storage area and erase each page. // for(ulAddr = FLASH_STORE_START_ADDR; ulAddr < FLASH_STORE_END_ADDR; ulAddr += 0x400) { FlashErase(ulAddr); } // // Inform user the erase is done. // SetStatusText("SAVE", "ERASE", "COMPLETE", "PRESS <"); }
//***************************************************************************** // // Erase the data storage area of flash. // //*****************************************************************************
Erase the data storage area of flash.
[ "Erase", "the", "data", "storage", "area", "of", "flash", "." ]
void FlashStoreErase(void) { unsigned long ulAddr; SetStatusText("ERASE", 0, "ERASING", 0); for(ulAddr = FLASH_STORE_START_ADDR; ulAddr < FLASH_STORE_END_ADDR; ulAddr += 0x400) { FlashErase(ulAddr); } SetStatusText("SAVE", "ERASE", "COMPLETE", "PRESS <"); }
[ "void", "FlashStoreErase", "(", "void", ")", "{", "unsigned", "long", "ulAddr", ";", "SetStatusText", "(", "\"", "\"", ",", "0", ",", "\"", "\"", ",", "0", ")", ";", "for", "(", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "ulAddr", "<", "FLASH_STORE_END_ADDR", ";", "ulAddr", "+=", "0x400", ")", "{", "FlashErase", "(", "ulAddr", ")", ";", "}", "SetStatusText", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "}" ]
Erase the data storage area of flash.
[ "Erase", "the", "data", "storage", "area", "of", "flash", "." ]
[ "//\r", "// Inform user we are erasing\r", "//\r", "//\r", "// Loop through entire storage area and erase each page.\r", "//\r", "//\r", "// Inform user the erase is done.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
IsBlockFree
int
static int IsBlockFree(unsigned long ulBaseAddr) { unsigned long ulAddr; // // Make sure we start at the beginning of a 1K block // ulBaseAddr &= ~0x3FF; // // Loop through every address in this block and test if it is blank. // for(ulAddr = 0; ulAddr < 0x400; ulAddr += 4) { if(HWREG(ulBaseAddr + ulAddr) != 0xFFFFFFFF) { // // Found a non-blank location, so return indication that block // is not free. // return(0); } } // // If we made it to here then every location in this block is erased, // so return indication that the block is free. // return(1); }
//***************************************************************************** // // Determine if the flash block that contains the address is blank. // //*****************************************************************************
Determine if the flash block that contains the address is blank.
[ "Determine", "if", "the", "flash", "block", "that", "contains", "the", "address", "is", "blank", "." ]
static int IsBlockFree(unsigned long ulBaseAddr) { unsigned long ulAddr; ulBaseAddr &= ~0x3FF; for(ulAddr = 0; ulAddr < 0x400; ulAddr += 4) { if(HWREG(ulBaseAddr + ulAddr) != 0xFFFFFFFF) { return(0); } } return(1); }
[ "static", "int", "IsBlockFree", "(", "unsigned", "long", "ulBaseAddr", ")", "{", "unsigned", "long", "ulAddr", ";", "ulBaseAddr", "&=", "~", "0x3FF", ";", "for", "(", "ulAddr", "=", "0", ";", "ulAddr", "<", "0x400", ";", "ulAddr", "+=", "4", ")", "{", "if", "(", "HWREG", "(", "ulBaseAddr", "+", "ulAddr", ")", "!=", "0xFFFFFFFF", ")", "{", "return", "(", "0", ")", ";", "}", "}", "return", "(", "1", ")", ";", "}" ]
Determine if the flash block that contains the address is blank.
[ "Determine", "if", "the", "flash", "block", "that", "contains", "the", "address", "is", "blank", "." ]
[ "//\r", "// Make sure we start at the beginning of a 1K block\r", "//\r", "//\r", "// Loop through every address in this block and test if it is blank.\r", "//\r", "//\r", "// Found a non-blank location, so return indication that block\r", "// is not free.\r", "//\r", "//\r", "// If we made it to here then every location in this block is erased,\r", "// so return indication that the block is free.\r", "//\r" ]
[ { "param": "ulBaseAddr", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulBaseAddr", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fb520680cb8660d26e993dff83a2350f8cc5f56c
junyanl-code/Luminary-Micro-Library
boards/ek-lm4f232/qs-logger/flashstore.c
[ "BSD-3-Clause" ]
C
FlashStoreReport
void
void FlashStoreReport(void) { unsigned long ulAddr; unsigned long ulFreeBlocks = 0; unsigned long ulUsedBlocks = 0; static char cBufFree[16]; static char cBufUsed[16]; // // Loop through each block of the storage area and count how many blocks // are free and non-free. // for(ulAddr = FLASH_STORE_START_ADDR; ulAddr < FLASH_STORE_END_ADDR; ulAddr += 0x400) { if(IsBlockFree(ulAddr)) { ulFreeBlocks++; } else { ulUsedBlocks++; } } // // Report the result to the user via a status display screen. // usnprintf(cBufFree, sizeof(cBufFree), "FREE: %3uK", ulFreeBlocks); usnprintf(cBufUsed, sizeof(cBufUsed), "USED: %3uK", ulUsedBlocks); SetStatusText("FREE FLASH", cBufFree, cBufUsed, "PRESS <"); }
//***************************************************************************** // // Report to the user the amount of free space and used space in the data // storage area. // //*****************************************************************************
Report to the user the amount of free space and used space in the data storage area.
[ "Report", "to", "the", "user", "the", "amount", "of", "free", "space", "and", "used", "space", "in", "the", "data", "storage", "area", "." ]
void FlashStoreReport(void) { unsigned long ulAddr; unsigned long ulFreeBlocks = 0; unsigned long ulUsedBlocks = 0; static char cBufFree[16]; static char cBufUsed[16]; for(ulAddr = FLASH_STORE_START_ADDR; ulAddr < FLASH_STORE_END_ADDR; ulAddr += 0x400) { if(IsBlockFree(ulAddr)) { ulFreeBlocks++; } else { ulUsedBlocks++; } } usnprintf(cBufFree, sizeof(cBufFree), "FREE: %3uK", ulFreeBlocks); usnprintf(cBufUsed, sizeof(cBufUsed), "USED: %3uK", ulUsedBlocks); SetStatusText("FREE FLASH", cBufFree, cBufUsed, "PRESS <"); }
[ "void", "FlashStoreReport", "(", "void", ")", "{", "unsigned", "long", "ulAddr", ";", "unsigned", "long", "ulFreeBlocks", "=", "0", ";", "unsigned", "long", "ulUsedBlocks", "=", "0", ";", "static", "char", "cBufFree", "[", "16", "]", ";", "static", "char", "cBufUsed", "[", "16", "]", ";", "for", "(", "ulAddr", "=", "FLASH_STORE_START_ADDR", ";", "ulAddr", "<", "FLASH_STORE_END_ADDR", ";", "ulAddr", "+=", "0x400", ")", "{", "if", "(", "IsBlockFree", "(", "ulAddr", ")", ")", "{", "ulFreeBlocks", "++", ";", "}", "else", "{", "ulUsedBlocks", "++", ";", "}", "}", "usnprintf", "(", "cBufFree", ",", "sizeof", "(", "cBufFree", ")", ",", "\"", "\"", ",", "ulFreeBlocks", ")", ";", "usnprintf", "(", "cBufUsed", ",", "sizeof", "(", "cBufUsed", ")", ",", "\"", "\"", ",", "ulUsedBlocks", ")", ";", "SetStatusText", "(", "\"", "\"", ",", "cBufFree", ",", "cBufUsed", ",", "\"", "\"", ")", ";", "}" ]
Report to the user the amount of free space and used space in the data storage area.
[ "Report", "to", "the", "user", "the", "amount", "of", "free", "space", "and", "used", "space", "in", "the", "data", "storage", "area", "." ]
[ "//\r", "// Loop through each block of the storage area and count how many blocks\r", "// are free and non-free.\r", "//\r", "//\r", "// Report the result to the user via a status display screen.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraFPGAIntHandler
void
void CameraFPGAIntHandler(void) { long lStatus; unsigned long ulInts; // // Get the interrupt status and clear the GPIO interrupt. // lStatus = ROM_GPIOPinIntStatus(CAMERA_INT_BASE, true); ROM_GPIOPinIntClear(CAMERA_INT_BASE, (unsigned char)(lStatus & 0xFF)); // // Get the interrupt status from the FPGA and clear all pending interrupts. // ulInts = (unsigned long)HWREGH(FPGA_IRQSTAT_REG); HWREGH(FPGA_IRQSTAT_REG) = ulInts; // // Clear the bits in the signal variable corresponding to the interrupts // we are processing. // g_ulCameraSignals &= ~ulInts; // // If this interrupt relates to an event that the client has asked to see // and if a callback function has been provided, call it. // if((g_ulCameraEvents & ulInts) && g_pfnCameraCallback) { // // Pass the event notification to the client's callback function. // g_pfnCameraCallback(g_ulCameraEvents & ulInts); } }
//***************************************************************************** // // The handler for interrupts from the FPGA (via EPI30. These inform us of various // asynchronous events related to video capture and display. // //*****************************************************************************
The handler for interrupts from the FPGA (via EPI30. These inform us of various asynchronous events related to video capture and display.
[ "The", "handler", "for", "interrupts", "from", "the", "FPGA", "(", "via", "EPI30", ".", "These", "inform", "us", "of", "various", "asynchronous", "events", "related", "to", "video", "capture", "and", "display", "." ]
void CameraFPGAIntHandler(void) { long lStatus; unsigned long ulInts; lStatus = ROM_GPIOPinIntStatus(CAMERA_INT_BASE, true); ROM_GPIOPinIntClear(CAMERA_INT_BASE, (unsigned char)(lStatus & 0xFF)); ulInts = (unsigned long)HWREGH(FPGA_IRQSTAT_REG); HWREGH(FPGA_IRQSTAT_REG) = ulInts; g_ulCameraSignals &= ~ulInts; if((g_ulCameraEvents & ulInts) && g_pfnCameraCallback) { g_pfnCameraCallback(g_ulCameraEvents & ulInts); } }
[ "void", "CameraFPGAIntHandler", "(", "void", ")", "{", "long", "lStatus", ";", "unsigned", "long", "ulInts", ";", "lStatus", "=", "ROM_GPIOPinIntStatus", "(", "CAMERA_INT_BASE", ",", "true", ")", ";", "ROM_GPIOPinIntClear", "(", "CAMERA_INT_BASE", ",", "(", "unsigned", "char", ")", "(", "lStatus", "&", "0xFF", ")", ")", ";", "ulInts", "=", "(", "unsigned", "long", ")", "HWREGH", "(", "FPGA_IRQSTAT_REG", ")", ";", "HWREGH", "(", "FPGA_IRQSTAT_REG", ")", "=", "ulInts", ";", "g_ulCameraSignals", "&=", "~", "ulInts", ";", "if", "(", "(", "g_ulCameraEvents", "&", "ulInts", ")", "&&", "g_pfnCameraCallback", ")", "{", "g_pfnCameraCallback", "(", "g_ulCameraEvents", "&", "ulInts", ")", ";", "}", "}" ]
The handler for interrupts from the FPGA (via EPI30.
[ "The", "handler", "for", "interrupts", "from", "the", "FPGA", "(", "via", "EPI30", "." ]
[ "//\r", "// Get the interrupt status and clear the GPIO interrupt.\r", "//\r", "//\r", "// Get the interrupt status from the FPGA and clear all pending interrupts.\r", "//\r", "//\r", "// Clear the bits in the signal variable corresponding to the interrupts\r", "// we are processing.\r", "//\r", "//\r", "// If this interrupt relates to an event that the client has asked to see\r", "// and if a callback function has been provided, call it.\r", "//\r", "//\r", "// Pass the event notification to the client's callback function.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
WaitForFrameEnd
void
static void WaitForFrameEnd(tBoolean bCapture) { unsigned long ulIntToCheck; // // Determine which interrupt to use depending upon whether we are to wait // for the end of the capture or display. // ulIntToCheck = bCapture ? FPGA_ISR_VCFEI : FPGA_ISR_LTEI; // // Temporarily disable the FPGA interrupt while we are setting the signal // flag. // ROM_IntDisable(CAMERA_INT); // // Set the global flag indicating that we are waiting for this // interrupt. // g_ulCameraSignals |= ulIntToCheck; // // Ensure that the interrupt we need to look at is turned on. // HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents | ulIntToCheck; // // Enable the FPGA interrupt once again now that everything is set up. // ROM_IntEnable(CAMERA_INT); // // Now wait for the interrupt to fire. Note that this will hang if the // client is silly enough to ask us to wait when capture or display is // not actually running. Hopefully this comment will suffice to help // people realize that they have done this. // while(g_ulCameraSignals & ulIntToCheck) { // // Wait for another interrupt. // CPUwfi(); } // // Reinstate the original interrupt state. // HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents; }
//***************************************************************************** // // Waits for the relevant signal from the FPGA to indicate that all previous // register value changes have been latched and the new values are now in use. // Register writes take effect at the end of each frame. The bCapture // parameter allows the caller to specify whether to wait until the end of the // current video frame capture or the end of the frame being displayed. // //*****************************************************************************
Waits for the relevant signal from the FPGA to indicate that all previous register value changes have been latched and the new values are now in use. Register writes take effect at the end of each frame. The bCapture parameter allows the caller to specify whether to wait until the end of the current video frame capture or the end of the frame being displayed.
[ "Waits", "for", "the", "relevant", "signal", "from", "the", "FPGA", "to", "indicate", "that", "all", "previous", "register", "value", "changes", "have", "been", "latched", "and", "the", "new", "values", "are", "now", "in", "use", ".", "Register", "writes", "take", "effect", "at", "the", "end", "of", "each", "frame", ".", "The", "bCapture", "parameter", "allows", "the", "caller", "to", "specify", "whether", "to", "wait", "until", "the", "end", "of", "the", "current", "video", "frame", "capture", "or", "the", "end", "of", "the", "frame", "being", "displayed", "." ]
static void WaitForFrameEnd(tBoolean bCapture) { unsigned long ulIntToCheck; ulIntToCheck = bCapture ? FPGA_ISR_VCFEI : FPGA_ISR_LTEI; ROM_IntDisable(CAMERA_INT); g_ulCameraSignals |= ulIntToCheck; HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents | ulIntToCheck; ROM_IntEnable(CAMERA_INT); while(g_ulCameraSignals & ulIntToCheck) { CPUwfi(); } HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents; }
[ "static", "void", "WaitForFrameEnd", "(", "tBoolean", "bCapture", ")", "{", "unsigned", "long", "ulIntToCheck", ";", "ulIntToCheck", "=", "bCapture", "?", "FPGA_ISR_VCFEI", ":", "FPGA_ISR_LTEI", ";", "ROM_IntDisable", "(", "CAMERA_INT", ")", ";", "g_ulCameraSignals", "|=", "ulIntToCheck", ";", "HWREGH", "(", "FPGA_IRQEN_REG", ")", "=", "g_ulCameraEvents", "|", "ulIntToCheck", ";", "ROM_IntEnable", "(", "CAMERA_INT", ")", ";", "while", "(", "g_ulCameraSignals", "&", "ulIntToCheck", ")", "{", "CPUwfi", "(", ")", ";", "}", "HWREGH", "(", "FPGA_IRQEN_REG", ")", "=", "g_ulCameraEvents", ";", "}" ]
Waits for the relevant signal from the FPGA to indicate that all previous register value changes have been latched and the new values are now in use.
[ "Waits", "for", "the", "relevant", "signal", "from", "the", "FPGA", "to", "indicate", "that", "all", "previous", "register", "value", "changes", "have", "been", "latched", "and", "the", "new", "values", "are", "now", "in", "use", "." ]
[ "//\r", "// Determine which interrupt to use depending upon whether we are to wait\r", "// for the end of the capture or display.\r", "//\r", "//\r", "// Temporarily disable the FPGA interrupt while we are setting the signal\r", "// flag.\r", "//\r", "//\r", "// Set the global flag indicating that we are waiting for this\r", "// interrupt.\r", "//\r", "//\r", "// Ensure that the interrupt we need to look at is turned on.\r", "//\r", "//\r", "// Enable the FPGA interrupt once again now that everything is set up.\r", "//\r", "//\r", "// Now wait for the interrupt to fire. Note that this will hang if the\r", "// client is silly enough to ask us to wait when capture or display is\r", "// not actually running. Hopefully this comment will suffice to help\r", "// people realize that they have done this.\r", "//\r", "//\r", "// Wait for another interrupt.\r", "//\r", "//\r", "// Reinstate the original interrupt state.\r", "//\r" ]
[ { "param": "bCapture", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bCapture", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraRegWrite
tBoolean
tBoolean CameraRegWrite(unsigned char ucReg, unsigned char ucVal) { // // Set the slave address. // ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, false); // // Write the next byte to the controller. // ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucReg); // // Continue the transfer. // ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START); // // Wait until the current byte has been transferred. // while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } // // Clear the interrupt status. Note that we DO NOT check for ACK here // since the SCCB protocol declares the bit we would normally associate // with ACK to be a "don't care." // ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); // // Write the next byte to the controller. // ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucVal); // // End the transfer. // ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); // // Wait until the current byte has been transferred. // while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } // // Clear the interrupt status. Once again, don't check for ACK. // ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); SysCtlDelay(ROM_SysCtlClockGet() / 1000); return(true); }
//***************************************************************************** // // Write a value to a particular camera control register. // //*****************************************************************************
Write a value to a particular camera control register.
[ "Write", "a", "value", "to", "a", "particular", "camera", "control", "register", "." ]
tBoolean CameraRegWrite(unsigned char ucReg, unsigned char ucVal) { ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, false); ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucReg); ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START); while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucVal); ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); SysCtlDelay(ROM_SysCtlClockGet() / 1000); return(true); }
[ "tBoolean", "CameraRegWrite", "(", "unsigned", "char", "ucReg", ",", "unsigned", "char", "ucVal", ")", "{", "ROM_I2CMasterSlaveAddrSet", "(", "CAMERA_I2C_MASTER_BASE", ",", "CAMERA_I2C_ADDR", ",", "false", ")", ";", "ROM_I2CMasterDataPut", "(", "CAMERA_I2C_MASTER_BASE", ",", "ucReg", ")", ";", "ROM_I2CMasterControl", "(", "CAMERA_I2C_MASTER_BASE", ",", "I2C_MASTER_CMD_BURST_SEND_START", ")", ";", "while", "(", "ROM_I2CMasterIntStatus", "(", "CAMERA_I2C_MASTER_BASE", ",", "false", ")", "==", "0", ")", "{", "}", "ROM_I2CMasterIntClear", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "ROM_I2CMasterDataPut", "(", "CAMERA_I2C_MASTER_BASE", ",", "ucVal", ")", ";", "ROM_I2CMasterControl", "(", "CAMERA_I2C_MASTER_BASE", ",", "I2C_MASTER_CMD_BURST_SEND_FINISH", ")", ";", "while", "(", "ROM_I2CMasterIntStatus", "(", "CAMERA_I2C_MASTER_BASE", ",", "false", ")", "==", "0", ")", "{", "}", "ROM_I2CMasterIntClear", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "SysCtlDelay", "(", "ROM_SysCtlClockGet", "(", ")", "/", "1000", ")", ";", "return", "(", "true", ")", ";", "}" ]
Write a value to a particular camera control register.
[ "Write", "a", "value", "to", "a", "particular", "camera", "control", "register", "." ]
[ "//\r", "// Set the slave address.\r", "//\r", "//\r", "// Write the next byte to the controller.\r", "//\r", "//\r", "// Continue the transfer.\r", "//\r", "//\r", "// Wait until the current byte has been transferred.\r", "//\r", "//\r", "// Clear the interrupt status. Note that we DO NOT check for ACK here\r", "// since the SCCB protocol declares the bit we would normally associate\r", "// with ACK to be a \"don't care.\"\r", "//\r", "//\r", "// Write the next byte to the controller.\r", "//\r", "//\r", "// End the transfer.\r", "//\r", "//\r", "// Wait until the current byte has been transferred.\r", "//\r", "//\r", "// Clear the interrupt status. Once again, don't check for ACK.\r", "//\r" ]
[ { "param": "ucReg", "type": "unsigned char" }, { "param": "ucVal", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucReg", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ucVal", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraRegSequenceWrite
tBoolean
static tBoolean CameraRegSequenceWrite(tRegValue *psRegs, unsigned long ulCount) { unsigned long ulLoop; tBoolean bRetcode; // // Initialize our return code. // bRetcode = true; // // Loop through each of the register/value entries supplied. // for(ulLoop = 0; ulLoop < ulCount; ulLoop++) { // // Write the register with the given value. // bRetcode = CameraRegWrite(psRegs[ulLoop].ucReg, psRegs[ulLoop].ucVal); // // Was the write successful? // if(!bRetcode) { // // No - drop out and return the error. // break; } } // // Tell the caller how we got on. // return(bRetcode); }
//***************************************************************************** // // Write a list of camera registers with particular values. // //*****************************************************************************
Write a list of camera registers with particular values.
[ "Write", "a", "list", "of", "camera", "registers", "with", "particular", "values", "." ]
static tBoolean CameraRegSequenceWrite(tRegValue *psRegs, unsigned long ulCount) { unsigned long ulLoop; tBoolean bRetcode; bRetcode = true; for(ulLoop = 0; ulLoop < ulCount; ulLoop++) { bRetcode = CameraRegWrite(psRegs[ulLoop].ucReg, psRegs[ulLoop].ucVal); if(!bRetcode) { break; } } return(bRetcode); }
[ "static", "tBoolean", "CameraRegSequenceWrite", "(", "tRegValue", "*", "psRegs", ",", "unsigned", "long", "ulCount", ")", "{", "unsigned", "long", "ulLoop", ";", "tBoolean", "bRetcode", ";", "bRetcode", "=", "true", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "ulCount", ";", "ulLoop", "++", ")", "{", "bRetcode", "=", "CameraRegWrite", "(", "psRegs", "[", "ulLoop", "]", ".", "ucReg", ",", "psRegs", "[", "ulLoop", "]", ".", "ucVal", ")", ";", "if", "(", "!", "bRetcode", ")", "{", "break", ";", "}", "}", "return", "(", "bRetcode", ")", ";", "}" ]
Write a list of camera registers with particular values.
[ "Write", "a", "list", "of", "camera", "registers", "with", "particular", "values", "." ]
[ "//\r", "// Initialize our return code.\r", "//\r", "//\r", "// Loop through each of the register/value entries supplied.\r", "//\r", "//\r", "// Write the register with the given value.\r", "//\r", "//\r", "// Was the write successful?\r", "//\r", "//\r", "// No - drop out and return the error.\r", "//\r", "//\r", "// Tell the caller how we got on.\r", "//\r" ]
[ { "param": "psRegs", "type": "tRegValue" }, { "param": "ulCount", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "psRegs", "type": "tRegValue", "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": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraRegRead
null
unsigned char CameraRegRead(unsigned char ucReg) { unsigned char ucVal; // // Clear any previously signalled interrupts. // ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); // // Start with a dummy write to get the address set in the EEPROM. // ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, false); // // Place the register to be read in the data register. // ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucReg); // // Perform a single send, writing the register address as the only byte. // ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND); // // Wait until the current byte has been transferred. // while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } // // Clear the interrupt status. Note that we DO NOT check for ACK here // since the SCCB protocol declares the bit we would normally associate // with ACK to be a "don't care." // ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); // // Put the I2C master into receive mode. // ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, true); // // Start the receive. // ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); // // Wait until the current byte has been read. // while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } // // Read the received character. // ucVal = ROM_I2CMasterDataGet(CAMERA_I2C_MASTER_BASE); // // Clear pending interrupt notifications. // ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); // // Tell the caller we read the required data. // return(ucVal); }
//***************************************************************************** // // Read the value from a particular camera control register. // //*****************************************************************************
Read the value from a particular camera control register.
[ "Read", "the", "value", "from", "a", "particular", "camera", "control", "register", "." ]
unsigned char CameraRegRead(unsigned char ucReg) { unsigned char ucVal; ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, false); ROM_I2CMasterDataPut(CAMERA_I2C_MASTER_BASE, ucReg); ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND); while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); ROM_I2CMasterSlaveAddrSet(CAMERA_I2C_MASTER_BASE, CAMERA_I2C_ADDR, true); ROM_I2CMasterControl(CAMERA_I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); while(ROM_I2CMasterIntStatus(CAMERA_I2C_MASTER_BASE, false) == 0) { } ucVal = ROM_I2CMasterDataGet(CAMERA_I2C_MASTER_BASE); ROM_I2CMasterIntClear(CAMERA_I2C_MASTER_BASE); return(ucVal); }
[ "unsigned", "char", "CameraRegRead", "(", "unsigned", "char", "ucReg", ")", "{", "unsigned", "char", "ucVal", ";", "ROM_I2CMasterIntClear", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "ROM_I2CMasterSlaveAddrSet", "(", "CAMERA_I2C_MASTER_BASE", ",", "CAMERA_I2C_ADDR", ",", "false", ")", ";", "ROM_I2CMasterDataPut", "(", "CAMERA_I2C_MASTER_BASE", ",", "ucReg", ")", ";", "ROM_I2CMasterControl", "(", "CAMERA_I2C_MASTER_BASE", ",", "I2C_MASTER_CMD_SINGLE_SEND", ")", ";", "while", "(", "ROM_I2CMasterIntStatus", "(", "CAMERA_I2C_MASTER_BASE", ",", "false", ")", "==", "0", ")", "{", "}", "ROM_I2CMasterIntClear", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "ROM_I2CMasterSlaveAddrSet", "(", "CAMERA_I2C_MASTER_BASE", ",", "CAMERA_I2C_ADDR", ",", "true", ")", ";", "ROM_I2CMasterControl", "(", "CAMERA_I2C_MASTER_BASE", ",", "I2C_MASTER_CMD_SINGLE_RECEIVE", ")", ";", "while", "(", "ROM_I2CMasterIntStatus", "(", "CAMERA_I2C_MASTER_BASE", ",", "false", ")", "==", "0", ")", "{", "}", "ucVal", "=", "ROM_I2CMasterDataGet", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "ROM_I2CMasterIntClear", "(", "CAMERA_I2C_MASTER_BASE", ")", ";", "return", "(", "ucVal", ")", ";", "}" ]
Read the value from a particular camera control register.
[ "Read", "the", "value", "from", "a", "particular", "camera", "control", "register", "." ]
[ "//\r", "// Clear any previously signalled interrupts.\r", "//\r", "//\r", "// Start with a dummy write to get the address set in the EEPROM.\r", "//\r", "//\r", "// Place the register to be read in the data register.\r", "//\r", "//\r", "// Perform a single send, writing the register address as the only byte.\r", "//\r", "//\r", "// Wait until the current byte has been transferred.\r", "//\r", "//\r", "// Clear the interrupt status. Note that we DO NOT check for ACK here\r", "// since the SCCB protocol declares the bit we would normally associate\r", "// with ACK to be a \"don't care.\"\r", "//\r", "//\r", "// Put the I2C master into receive mode.\r", "//\r", "//\r", "// Start the receive.\r", "//\r", "//\r", "// Wait until the current byte has been read.\r", "//\r", "//\r", "// Read the received character.\r", "//\r", "//\r", "// Clear pending interrupt notifications.\r", "//\r", "//\r", "// Tell the caller we read the required data.\r", "//\r" ]
[ { "param": "ucReg", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucReg", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraInit
tBoolean
tBoolean CameraInit(unsigned long ulFlags, unsigned long ulCaptureAddr, tCameraCallback pfnCallback) { tBoolean bRetcode; // // Make sure that the FPGA/camera daughter board is present. This will // have been detected during a previous call to PinoutSet(). // if(g_eDaughterType != DAUGHTER_FPGA) { return(false); } // // Enable the I2C controller used to interface to the camera controller. // ROM_SysCtlPeripheralEnable(CAMERA_I2C_PERIPH); // // Configure the I2C SCL and SDA pins for I2C operation. // ROM_GPIOPinTypeI2C(CAMERA_I2CSCL_GPIO_PORT, CAMERA_I2CSCL_PIN | CAMERA_I2CSDA_PIN); // // Initialize the I2C master. // ROM_I2CMasterInitExpClk(CAMERA_I2C_MASTER_BASE, SysCtlClockGet(), 0); // // Initialize the camera. // bRetcode = CameraRegSequenceWrite(g_psCameraRegInit, NUM_INIT_REGISTERS); if(!bRetcode) { // // There was an error during camera initialization! // return(bRetcode); } // // Remember the callback function. // g_pfnCameraCallback = pfnCallback; // // Set the initial capture format and size. // CameraCaptureTypeSet(ulFlags); // // Set the initial buffer address and assume that the buffer dimensions // match the video size requested. If this is not the case, the application // can call CameraCaptureBufferSet() to set different dimensions later. // CameraCaptureBufferSet(ulCaptureAddr, ((ulFlags & CAMERA_SIZE_VGA) ? (640 * 2) : (320 * 2)), true); // // Configure the interrupt pin from the FPGA but disable all interrupt // sources for now. // HWREGH(FPGA_IRQEN_REG) = 0; ROM_GPIODirModeSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_DIR_MODE_IN); ROM_GPIOPadConfigSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); ROM_GPIOIntTypeSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_LOW_LEVEL); ROM_GPIOPinIntEnable(CAMERA_INT_BASE, CAMERA_INT_PIN); ROM_IntEnable(CAMERA_INT); // // If we get here, all is well so tell the caller everything is fine. // return(true); }
//***************************************************************************** // //! Initializes the camera and prepares for motion video capture. //! //! \param ulFlags defines the initial video size and pixel format. //! \param ulCaptureAddr is the address of the video capture buffer in //! daughter board SRAM where 0 indicates the bottom of the memory. //! \param pfnCallback is a pointer to a function that will be called to //! inform the application of any requested asynchronous events related to //! video capture and display. If no callbacks are required, this parameter //! may be set to 0 to disable all notifications. //! //! This function must be called after PinoutSet() and before any other camera //! API to initialize the camera and set the initial capture buffer location. //! On exit, the camera is ready to start capturing motion video but capture has //! not been enabled. //! //! Parameter \e ulFlags is comprised of ORed flags indicating the desired //! initial video capture size and pixel format. It must contain two flags, //! one each from the following groups: //! //! Video dimensions: \b CAMERA_SIZE_VGA for 640x480 capture or \b //! CAMERA_SIZE_QVGA for 320x240 capture. //! //! Pixel format: \b CAMERA_FORMAT_RGB565 to capture 16bpp RGB data with the //! red component in the most significant 5 bits of the half word pixel, \b //! CAMERA_FORMAT_BGR565 to capture RGB data with the blue component in the //! most significant 5 bits of the pixel, \b CAMERA_FORMAT_YUYV to capture //! video data in YUV422 format with YUYV component ordering or \b //! CAMERA_FORMAT_YVYU to capture YUV422 data with YVYU component ordering. //! Note that direct display of the video data is only possible when using //! \b CAMERA_FORMAT_RGB565. //! //! The \e ulCaptureAddr parameter defines the start of the video capture buffer //! relative to the start of the daughter board SRAM. It is assumed that the //! buffer is sized to hold a single frame of video at the size requested in //! \e ulFlags. The caller is responsible for managing the SRAM on the daughter //! board and ensuring that this buffer is large enough to hold the captured //! video and that it does not overlap with the graphics display buffer, if //! used. //! //! \return Returns \b true if the camera was initialized successfully or //! \b false if the required hardware was not present or some other error //! occured during initialization. // //*****************************************************************************
Initializes the camera and prepares for motion video capture. \param ulFlags defines the initial video size and pixel format. \param ulCaptureAddr is the address of the video capture buffer in daughter board SRAM where 0 indicates the bottom of the memory. \param pfnCallback is a pointer to a function that will be called to inform the application of any requested asynchronous events related to video capture and display. If no callbacks are required, this parameter may be set to 0 to disable all notifications. This function must be called after PinoutSet() and before any other camera API to initialize the camera and set the initial capture buffer location. On exit, the camera is ready to start capturing motion video but capture has not been enabled. Parameter \e ulFlags is comprised of ORed flags indicating the desired initial video capture size and pixel format. It must contain two flags, one each from the following groups. Video dimensions: \b CAMERA_SIZE_VGA for 640x480 capture or \b CAMERA_SIZE_QVGA for 320x240 capture. Pixel format: \b CAMERA_FORMAT_RGB565 to capture 16bpp RGB data with the red component in the most significant 5 bits of the half word pixel, \b CAMERA_FORMAT_BGR565 to capture RGB data with the blue component in the most significant 5 bits of the pixel, \b CAMERA_FORMAT_YUYV to capture video data in YUV422 format with YUYV component ordering or \b CAMERA_FORMAT_YVYU to capture YUV422 data with YVYU component ordering. Note that direct display of the video data is only possible when using \b CAMERA_FORMAT_RGB565. The \e ulCaptureAddr parameter defines the start of the video capture buffer relative to the start of the daughter board SRAM. It is assumed that the buffer is sized to hold a single frame of video at the size requested in \e ulFlags. The caller is responsible for managing the SRAM on the daughter board and ensuring that this buffer is large enough to hold the captured video and that it does not overlap with the graphics display buffer, if used. \return Returns \b true if the camera was initialized successfully or \b false if the required hardware was not present or some other error occured during initialization.
[ "Initializes", "the", "camera", "and", "prepares", "for", "motion", "video", "capture", ".", "\\", "param", "ulFlags", "defines", "the", "initial", "video", "size", "and", "pixel", "format", ".", "\\", "param", "ulCaptureAddr", "is", "the", "address", "of", "the", "video", "capture", "buffer", "in", "daughter", "board", "SRAM", "where", "0", "indicates", "the", "bottom", "of", "the", "memory", ".", "\\", "param", "pfnCallback", "is", "a", "pointer", "to", "a", "function", "that", "will", "be", "called", "to", "inform", "the", "application", "of", "any", "requested", "asynchronous", "events", "related", "to", "video", "capture", "and", "display", ".", "If", "no", "callbacks", "are", "required", "this", "parameter", "may", "be", "set", "to", "0", "to", "disable", "all", "notifications", ".", "This", "function", "must", "be", "called", "after", "PinoutSet", "()", "and", "before", "any", "other", "camera", "API", "to", "initialize", "the", "camera", "and", "set", "the", "initial", "capture", "buffer", "location", ".", "On", "exit", "the", "camera", "is", "ready", "to", "start", "capturing", "motion", "video", "but", "capture", "has", "not", "been", "enabled", ".", "Parameter", "\\", "e", "ulFlags", "is", "comprised", "of", "ORed", "flags", "indicating", "the", "desired", "initial", "video", "capture", "size", "and", "pixel", "format", ".", "It", "must", "contain", "two", "flags", "one", "each", "from", "the", "following", "groups", ".", "Video", "dimensions", ":", "\\", "b", "CAMERA_SIZE_VGA", "for", "640x480", "capture", "or", "\\", "b", "CAMERA_SIZE_QVGA", "for", "320x240", "capture", ".", "Pixel", "format", ":", "\\", "b", "CAMERA_FORMAT_RGB565", "to", "capture", "16bpp", "RGB", "data", "with", "the", "red", "component", "in", "the", "most", "significant", "5", "bits", "of", "the", "half", "word", "pixel", "\\", "b", "CAMERA_FORMAT_BGR565", "to", "capture", "RGB", "data", "with", "the", "blue", "component", "in", "the", "most", "significant", "5", "bits", "of", "the", "pixel", "\\", "b", "CAMERA_FORMAT_YUYV", "to", "capture", "video", "data", "in", "YUV422", "format", "with", "YUYV", "component", "ordering", "or", "\\", "b", "CAMERA_FORMAT_YVYU", "to", "capture", "YUV422", "data", "with", "YVYU", "component", "ordering", ".", "Note", "that", "direct", "display", "of", "the", "video", "data", "is", "only", "possible", "when", "using", "\\", "b", "CAMERA_FORMAT_RGB565", ".", "The", "\\", "e", "ulCaptureAddr", "parameter", "defines", "the", "start", "of", "the", "video", "capture", "buffer", "relative", "to", "the", "start", "of", "the", "daughter", "board", "SRAM", ".", "It", "is", "assumed", "that", "the", "buffer", "is", "sized", "to", "hold", "a", "single", "frame", "of", "video", "at", "the", "size", "requested", "in", "\\", "e", "ulFlags", ".", "The", "caller", "is", "responsible", "for", "managing", "the", "SRAM", "on", "the", "daughter", "board", "and", "ensuring", "that", "this", "buffer", "is", "large", "enough", "to", "hold", "the", "captured", "video", "and", "that", "it", "does", "not", "overlap", "with", "the", "graphics", "display", "buffer", "if", "used", ".", "\\", "return", "Returns", "\\", "b", "true", "if", "the", "camera", "was", "initialized", "successfully", "or", "\\", "b", "false", "if", "the", "required", "hardware", "was", "not", "present", "or", "some", "other", "error", "occured", "during", "initialization", "." ]
tBoolean CameraInit(unsigned long ulFlags, unsigned long ulCaptureAddr, tCameraCallback pfnCallback) { tBoolean bRetcode; if(g_eDaughterType != DAUGHTER_FPGA) { return(false); } ROM_SysCtlPeripheralEnable(CAMERA_I2C_PERIPH); ROM_GPIOPinTypeI2C(CAMERA_I2CSCL_GPIO_PORT, CAMERA_I2CSCL_PIN | CAMERA_I2CSDA_PIN); ROM_I2CMasterInitExpClk(CAMERA_I2C_MASTER_BASE, SysCtlClockGet(), 0); bRetcode = CameraRegSequenceWrite(g_psCameraRegInit, NUM_INIT_REGISTERS); if(!bRetcode) { return(bRetcode); } g_pfnCameraCallback = pfnCallback; CameraCaptureTypeSet(ulFlags); CameraCaptureBufferSet(ulCaptureAddr, ((ulFlags & CAMERA_SIZE_VGA) ? (640 * 2) : (320 * 2)), true); HWREGH(FPGA_IRQEN_REG) = 0; ROM_GPIODirModeSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_DIR_MODE_IN); ROM_GPIOPadConfigSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); ROM_GPIOIntTypeSet(CAMERA_INT_BASE, CAMERA_INT_PIN, GPIO_LOW_LEVEL); ROM_GPIOPinIntEnable(CAMERA_INT_BASE, CAMERA_INT_PIN); ROM_IntEnable(CAMERA_INT); return(true); }
[ "tBoolean", "CameraInit", "(", "unsigned", "long", "ulFlags", ",", "unsigned", "long", "ulCaptureAddr", ",", "tCameraCallback", "pfnCallback", ")", "{", "tBoolean", "bRetcode", ";", "if", "(", "g_eDaughterType", "!=", "DAUGHTER_FPGA", ")", "{", "return", "(", "false", ")", ";", "}", "ROM_SysCtlPeripheralEnable", "(", "CAMERA_I2C_PERIPH", ")", ";", "ROM_GPIOPinTypeI2C", "(", "CAMERA_I2CSCL_GPIO_PORT", ",", "CAMERA_I2CSCL_PIN", "|", "CAMERA_I2CSDA_PIN", ")", ";", "ROM_I2CMasterInitExpClk", "(", "CAMERA_I2C_MASTER_BASE", ",", "SysCtlClockGet", "(", ")", ",", "0", ")", ";", "bRetcode", "=", "CameraRegSequenceWrite", "(", "g_psCameraRegInit", ",", "NUM_INIT_REGISTERS", ")", ";", "if", "(", "!", "bRetcode", ")", "{", "return", "(", "bRetcode", ")", ";", "}", "g_pfnCameraCallback", "=", "pfnCallback", ";", "CameraCaptureTypeSet", "(", "ulFlags", ")", ";", "CameraCaptureBufferSet", "(", "ulCaptureAddr", ",", "(", "(", "ulFlags", "&", "CAMERA_SIZE_VGA", ")", "?", "(", "640", "*", "2", ")", ":", "(", "320", "*", "2", ")", ")", ",", "true", ")", ";", "HWREGH", "(", "FPGA_IRQEN_REG", ")", "=", "0", ";", "ROM_GPIODirModeSet", "(", "CAMERA_INT_BASE", ",", "CAMERA_INT_PIN", ",", "GPIO_DIR_MODE_IN", ")", ";", "ROM_GPIOPadConfigSet", "(", "CAMERA_INT_BASE", ",", "CAMERA_INT_PIN", ",", "GPIO_STRENGTH_2MA", ",", "GPIO_PIN_TYPE_STD_WPU", ")", ";", "ROM_GPIOIntTypeSet", "(", "CAMERA_INT_BASE", ",", "CAMERA_INT_PIN", ",", "GPIO_LOW_LEVEL", ")", ";", "ROM_GPIOPinIntEnable", "(", "CAMERA_INT_BASE", ",", "CAMERA_INT_PIN", ")", ";", "ROM_IntEnable", "(", "CAMERA_INT", ")", ";", "return", "(", "true", ")", ";", "}" ]
Initializes the camera and prepares for motion video capture.
[ "Initializes", "the", "camera", "and", "prepares", "for", "motion", "video", "capture", "." ]
[ "//\r", "// Make sure that the FPGA/camera daughter board is present. This will\r", "// have been detected during a previous call to PinoutSet().\r", "//\r", "//\r", "// Enable the I2C controller used to interface to the camera controller.\r", "//\r", "//\r", "// Configure the I2C SCL and SDA pins for I2C operation.\r", "//\r", "//\r", "// Initialize the I2C master.\r", "//\r", "//\r", "// Initialize the camera.\r", "//\r", "//\r", "// There was an error during camera initialization!\r", "//\r", "//\r", "// Remember the callback function.\r", "//\r", "//\r", "// Set the initial capture format and size.\r", "//\r", "//\r", "// Set the initial buffer address and assume that the buffer dimensions\r", "// match the video size requested. If this is not the case, the application\r", "// can call CameraCaptureBufferSet() to set different dimensions later.\r", "//\r", "//\r", "// Configure the interrupt pin from the FPGA but disable all interrupt\r", "// sources for now.\r", "//\r", "//\r", "// If we get here, all is well so tell the caller everything is fine.\r", "//\r" ]
[ { "param": "ulFlags", "type": "unsigned long" }, { "param": "ulCaptureAddr", "type": "unsigned long" }, { "param": "pfnCallback", "type": "tCameraCallback" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulFlags", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulCaptureAddr", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pfnCallback", "type": "tCameraCallback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraEventsSet
void
void CameraEventsSet(unsigned long ulEvents, unsigned long ulEventMask) { // // Update the global event notification set based on the client's request. // g_ulCameraEvents = (g_ulCameraEvents & ~ulEventMask) | ulEvents; // // Enable the FPGA interrupts required to produce the desired event // notifications. We write to the status register here to clear any // unhandled interrupts of the type we are interested in before we enable // the interrupt. This prevents the event from firing immediately based on // some stale, past occurrence. // HWREGH(FPGA_IRQSTAT_REG) |= g_ulCameraEvents; HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents; }
//***************************************************************************** // //! Sets or clears notification of various video events. //! //! \param ulEvents defines whether notification is enabled for a given event. //! Valid values are logical OR combinations of \b CAMERA_EVENT_CAPTURE_START, //! \b CAMERA_EVENT_CAPTURE_END, \b CAMERA_EVENT_CAPTURE_MATCH, \b //! CAMERA_EVENT_DISPLAY_START, \b CAMERA_EVENT_DISPLAY_END and \b //! CAMERA_EVENT_DISPLAY_MATCH. //! \param ulEventMask defines which events are to be affected by this call. //! Valid values are as for \e ulEvents. A 1 in a given position in this //! parameter causes the respective event's notification state to be taken //! from \e ulEvents. A zero causes the associated bit in \e ulEvents to be //! ignored. //! //! This function enables or disables client notification for one or more //! asynchronous video events. The use of a mask parameter, \e ulEventMask, //! allows notifications for groups of events to be configured without affecting //! the current states of other events. //! //! When event notification is enabled, the callback function supplied on //! CameraInit() will be called whenever that video event occurs. //! //! \return None. // //*****************************************************************************
Sets or clears notification of various video events. \param ulEvents defines whether notification is enabled for a given event. This function enables or disables client notification for one or more asynchronous video events. The use of a mask parameter, \e ulEventMask, allows notifications for groups of events to be configured without affecting the current states of other events. When event notification is enabled, the callback function supplied on CameraInit() will be called whenever that video event occurs. \return None.
[ "Sets", "or", "clears", "notification", "of", "various", "video", "events", ".", "\\", "param", "ulEvents", "defines", "whether", "notification", "is", "enabled", "for", "a", "given", "event", ".", "This", "function", "enables", "or", "disables", "client", "notification", "for", "one", "or", "more", "asynchronous", "video", "events", ".", "The", "use", "of", "a", "mask", "parameter", "\\", "e", "ulEventMask", "allows", "notifications", "for", "groups", "of", "events", "to", "be", "configured", "without", "affecting", "the", "current", "states", "of", "other", "events", ".", "When", "event", "notification", "is", "enabled", "the", "callback", "function", "supplied", "on", "CameraInit", "()", "will", "be", "called", "whenever", "that", "video", "event", "occurs", ".", "\\", "return", "None", "." ]
void CameraEventsSet(unsigned long ulEvents, unsigned long ulEventMask) { g_ulCameraEvents = (g_ulCameraEvents & ~ulEventMask) | ulEvents; HWREGH(FPGA_IRQSTAT_REG) |= g_ulCameraEvents; HWREGH(FPGA_IRQEN_REG) = g_ulCameraEvents; }
[ "void", "CameraEventsSet", "(", "unsigned", "long", "ulEvents", ",", "unsigned", "long", "ulEventMask", ")", "{", "g_ulCameraEvents", "=", "(", "g_ulCameraEvents", "&", "~", "ulEventMask", ")", "|", "ulEvents", ";", "HWREGH", "(", "FPGA_IRQSTAT_REG", ")", "|=", "g_ulCameraEvents", ";", "HWREGH", "(", "FPGA_IRQEN_REG", ")", "=", "g_ulCameraEvents", ";", "}" ]
Sets or clears notification of various video events.
[ "Sets", "or", "clears", "notification", "of", "various", "video", "events", "." ]
[ "//\r", "// Update the global event notification set based on the client's request.\r", "//\r", "//\r", "// Enable the FPGA interrupts required to produce the desired event\r", "// notifications. We write to the status register here to clear any\r", "// unhandled interrupts of the type we are interested in before we enable\r", "// the interrupt. This prevents the event from firing immediately based on\r", "// some stale, past occurrence.\r", "//\r" ]
[ { "param": "ulEvents", "type": "unsigned long" }, { "param": "ulEventMask", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulEvents", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulEventMask", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraCaptureTypeSet
void
void CameraCaptureTypeSet(unsigned long ulFlags) { unsigned char ucValue; // // First set the capture resolution. // if(ulFlags & CAMERA_SIZE_VGA) { // // Set up for VGA (640x480) resolution capture. // HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_QVGA; CameraRegSequenceWrite(g_psCameraSizeVGA, NUM_VGA_REGISTERS); } else { // // Set up for QVGA (320x240) resolution capture. // CameraRegSequenceWrite(g_psCameraSizeQVGA, NUM_QVGA_REGISTERS); HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_QVGA; } // // Now set the appropriate pixel format. The size setting code sets things // up correctly for RGB565 so we don't need to do anything if asked for this // format. // if(ulFlags & CAMERA_FORMAT_BGR565) { // // Swap the R and B component positions in the pixel. // ucValue = CameraRegRead(0x0C); CameraRegWrite(0x0C, ucValue | 0x20); } else if(ulFlags & CAMERA_FORMAT_YUYV) { // // Set YUV output format. // ucValue = CameraRegRead(0x12); CameraRegWrite(0x12, ucValue & 0xF0); } else if(ulFlags & CAMERA_FORMAT_YVYU) { // // Set YUV output format. // ucValue = CameraRegRead(0x12); CameraRegWrite(0x12, ucValue & 0xF0); // // Swap the YU/YV order. // ucValue = CameraRegRead(0x0C); CameraRegWrite(0x0C, ucValue | 0x10); } }
//***************************************************************************** // //! Sets the video capture size and pixel format. //! //! \param ulFlags defines the video size and pixel format. //! //! This function sets the size of video captured from the camera and the //! pixel format that is stored in the video buffer. //! //! Parameter \e ulFlags is comprised of ORed flags indicating the desired //! video capture size and pixel format. It must contain two flags, one each //! from the following groups: //! //! Video dimensions: \b CAMERA_SIZE_VGA for 640x480 capture or \b //! CAMERA_SIZE_QVGA for 320x240 capture. //! //! Pixel format: \b CAMERA_FORMAT_RGB565 to capture 16bpp RGB data with the //! red component in the most significant 5 bits of the half word pixel, \b //! CAMERA_FORMAT_BGR565 to capture RGB data with the blue component in the //! most significant 5 bits of the pixel, \b CAMERA_FORMAT_YUYV to capture //! video data in YUV422 format with YUYV component ordering or \b //! CAMERA_FORMAT_YVYU to capture YUV422 data with YVYU component ordering. //! Note that direct display of the video data is only possible when using //! \b CAMERA_FORMAT_RGB565. //! //! The caller is responsible for ensuring that the currently-defined video //! capture buffer is large enough to hold the video frame size defined here. //! //! \return None. // //*****************************************************************************
Sets the video capture size and pixel format. \param ulFlags defines the video size and pixel format. This function sets the size of video captured from the camera and the pixel format that is stored in the video buffer. Parameter \e ulFlags is comprised of ORed flags indicating the desired video capture size and pixel format. It must contain two flags, one each from the following groups. Video dimensions: \b CAMERA_SIZE_VGA for 640x480 capture or \b CAMERA_SIZE_QVGA for 320x240 capture. Pixel format: \b CAMERA_FORMAT_RGB565 to capture 16bpp RGB data with the red component in the most significant 5 bits of the half word pixel, \b CAMERA_FORMAT_BGR565 to capture RGB data with the blue component in the most significant 5 bits of the pixel, \b CAMERA_FORMAT_YUYV to capture video data in YUV422 format with YUYV component ordering or \b CAMERA_FORMAT_YVYU to capture YUV422 data with YVYU component ordering. Note that direct display of the video data is only possible when using \b CAMERA_FORMAT_RGB565. The caller is responsible for ensuring that the currently-defined video capture buffer is large enough to hold the video frame size defined here. \return None.
[ "Sets", "the", "video", "capture", "size", "and", "pixel", "format", ".", "\\", "param", "ulFlags", "defines", "the", "video", "size", "and", "pixel", "format", ".", "This", "function", "sets", "the", "size", "of", "video", "captured", "from", "the", "camera", "and", "the", "pixel", "format", "that", "is", "stored", "in", "the", "video", "buffer", ".", "Parameter", "\\", "e", "ulFlags", "is", "comprised", "of", "ORed", "flags", "indicating", "the", "desired", "video", "capture", "size", "and", "pixel", "format", ".", "It", "must", "contain", "two", "flags", "one", "each", "from", "the", "following", "groups", ".", "Video", "dimensions", ":", "\\", "b", "CAMERA_SIZE_VGA", "for", "640x480", "capture", "or", "\\", "b", "CAMERA_SIZE_QVGA", "for", "320x240", "capture", ".", "Pixel", "format", ":", "\\", "b", "CAMERA_FORMAT_RGB565", "to", "capture", "16bpp", "RGB", "data", "with", "the", "red", "component", "in", "the", "most", "significant", "5", "bits", "of", "the", "half", "word", "pixel", "\\", "b", "CAMERA_FORMAT_BGR565", "to", "capture", "RGB", "data", "with", "the", "blue", "component", "in", "the", "most", "significant", "5", "bits", "of", "the", "pixel", "\\", "b", "CAMERA_FORMAT_YUYV", "to", "capture", "video", "data", "in", "YUV422", "format", "with", "YUYV", "component", "ordering", "or", "\\", "b", "CAMERA_FORMAT_YVYU", "to", "capture", "YUV422", "data", "with", "YVYU", "component", "ordering", ".", "Note", "that", "direct", "display", "of", "the", "video", "data", "is", "only", "possible", "when", "using", "\\", "b", "CAMERA_FORMAT_RGB565", ".", "The", "caller", "is", "responsible", "for", "ensuring", "that", "the", "currently", "-", "defined", "video", "capture", "buffer", "is", "large", "enough", "to", "hold", "the", "video", "frame", "size", "defined", "here", ".", "\\", "return", "None", "." ]
void CameraCaptureTypeSet(unsigned long ulFlags) { unsigned char ucValue; if(ulFlags & CAMERA_SIZE_VGA) { HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_QVGA; CameraRegSequenceWrite(g_psCameraSizeVGA, NUM_VGA_REGISTERS); } else { CameraRegSequenceWrite(g_psCameraSizeQVGA, NUM_QVGA_REGISTERS); HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_QVGA; } if(ulFlags & CAMERA_FORMAT_BGR565) { ucValue = CameraRegRead(0x0C); CameraRegWrite(0x0C, ucValue | 0x20); } else if(ulFlags & CAMERA_FORMAT_YUYV) { ucValue = CameraRegRead(0x12); CameraRegWrite(0x12, ucValue & 0xF0); } else if(ulFlags & CAMERA_FORMAT_YVYU) { ucValue = CameraRegRead(0x12); CameraRegWrite(0x12, ucValue & 0xF0); ucValue = CameraRegRead(0x0C); CameraRegWrite(0x0C, ucValue | 0x10); } }
[ "void", "CameraCaptureTypeSet", "(", "unsigned", "long", "ulFlags", ")", "{", "unsigned", "char", "ucValue", ";", "if", "(", "ulFlags", "&", "CAMERA_SIZE_VGA", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&=", "~", "FPGA_SYSCTRL_QVGA", ";", "CameraRegSequenceWrite", "(", "g_psCameraSizeVGA", ",", "NUM_VGA_REGISTERS", ")", ";", "}", "else", "{", "CameraRegSequenceWrite", "(", "g_psCameraSizeQVGA", ",", "NUM_QVGA_REGISTERS", ")", ";", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "|=", "FPGA_SYSCTRL_QVGA", ";", "}", "if", "(", "ulFlags", "&", "CAMERA_FORMAT_BGR565", ")", "{", "ucValue", "=", "CameraRegRead", "(", "0x0C", ")", ";", "CameraRegWrite", "(", "0x0C", ",", "ucValue", "|", "0x20", ")", ";", "}", "else", "if", "(", "ulFlags", "&", "CAMERA_FORMAT_YUYV", ")", "{", "ucValue", "=", "CameraRegRead", "(", "0x12", ")", ";", "CameraRegWrite", "(", "0x12", ",", "ucValue", "&", "0xF0", ")", ";", "}", "else", "if", "(", "ulFlags", "&", "CAMERA_FORMAT_YVYU", ")", "{", "ucValue", "=", "CameraRegRead", "(", "0x12", ")", ";", "CameraRegWrite", "(", "0x12", ",", "ucValue", "&", "0xF0", ")", ";", "ucValue", "=", "CameraRegRead", "(", "0x0C", ")", ";", "CameraRegWrite", "(", "0x0C", ",", "ucValue", "|", "0x10", ")", ";", "}", "}" ]
Sets the video capture size and pixel format.
[ "Sets", "the", "video", "capture", "size", "and", "pixel", "format", "." ]
[ "//\r", "// First set the capture resolution.\r", "//\r", "//\r", "// Set up for VGA (640x480) resolution capture.\r", "//\r", "//\r", "// Set up for QVGA (320x240) resolution capture.\r", "//\r", "//\r", "// Now set the appropriate pixel format. The size setting code sets things\r", "// up correctly for RGB565 so we don't need to do anything if asked for this\r", "// format.\r", "//\r", "//\r", "// Swap the R and B component positions in the pixel.\r", "//\r", "//\r", "// Set YUV output format.\r", "//\r", "//\r", "// Set YUV output format.\r", "//\r", "//\r", "// Swap the YU/YV order.\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": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraCaptureBufferSet
void
void CameraCaptureBufferSet(unsigned long ulAddr, unsigned short usStride, tBoolean bAsync) { ASSERT(ulAddr < 0x100000); ASSERT((usStride & 1) == 0); // // Write the buffer address. We use a single 32bit write to write both // the VML and VMH registers since this will be broken into 2 half word // writes for us by the hardware. // HWREG(FPGA_VML_REG) = ulAddr; // // Write the buffer stride // HWREGH(FPGA_VMS_REG) = usStride; // // The current FPGA implementation doesn't have a register for the // buffer height so we merely ignore the parameter for now. The parameter // is left in the API, however, since it may be useful later. // // // Were we asked to perform this change synchronously? // if(!bAsync) { // // The caller wants us to wait for the change to take effect. // WaitForFrameEnd(true); } }
//***************************************************************************** // //! Sets the video capture buffer. //! //! \param ulAddr is the address of the video capture buffer in the FPGA SRAM. //! This address must be between 0x0 and (0x100000 - video frame size). //! \param usStride is the width of the video capture buffer in bytes. This //! must be at least as wide as a single line of the configured video capture //! frame size (640 * 2 for VGA or 320 * 2 for QVGA) and must be even. //! \param bAsync indicates whether to wait for the capture change to take //! effect before returning or not. If \b true, the call will return //! immediately. If \b false, the call will block until the new capture //! buffer parameters have been read and applied. //! //! This function may be called to move or resize the video capture buffer. //! The initial buffer is configured during a call to CaptureInit() with stride //! 1280 for VGA resolution or 640 for QVGA at the location provided in the //! \b ulCaptureAddr parameter to that function. //! //! The caller is responsible for ensuring that the video capture buffer is //! large enough to hold the currently configured video frame size and that the //! buffer does not overlap with any other buffer in FPGA SRAM (specifically //! the graphics buffer). //! //! \return None. // //*****************************************************************************
Sets the video capture buffer. \param ulAddr is the address of the video capture buffer in the FPGA SRAM. This address must be between 0x0 and (0x100000 - video frame size). \param usStride is the width of the video capture buffer in bytes. This must be at least as wide as a single line of the configured video capture frame size (640 * 2 for VGA or 320 * 2 for QVGA) and must be even. \param bAsync indicates whether to wait for the capture change to take effect before returning or not. If \b true, the call will return immediately. If \b false, the call will block until the new capture buffer parameters have been read and applied. This function may be called to move or resize the video capture buffer. The initial buffer is configured during a call to CaptureInit() with stride 1280 for VGA resolution or 640 for QVGA at the location provided in the \b ulCaptureAddr parameter to that function. The caller is responsible for ensuring that the video capture buffer is large enough to hold the currently configured video frame size and that the buffer does not overlap with any other buffer in FPGA SRAM (specifically the graphics buffer). \return None.
[ "Sets", "the", "video", "capture", "buffer", ".", "\\", "param", "ulAddr", "is", "the", "address", "of", "the", "video", "capture", "buffer", "in", "the", "FPGA", "SRAM", ".", "This", "address", "must", "be", "between", "0x0", "and", "(", "0x100000", "-", "video", "frame", "size", ")", ".", "\\", "param", "usStride", "is", "the", "width", "of", "the", "video", "capture", "buffer", "in", "bytes", ".", "This", "must", "be", "at", "least", "as", "wide", "as", "a", "single", "line", "of", "the", "configured", "video", "capture", "frame", "size", "(", "640", "*", "2", "for", "VGA", "or", "320", "*", "2", "for", "QVGA", ")", "and", "must", "be", "even", ".", "\\", "param", "bAsync", "indicates", "whether", "to", "wait", "for", "the", "capture", "change", "to", "take", "effect", "before", "returning", "or", "not", ".", "If", "\\", "b", "true", "the", "call", "will", "return", "immediately", ".", "If", "\\", "b", "false", "the", "call", "will", "block", "until", "the", "new", "capture", "buffer", "parameters", "have", "been", "read", "and", "applied", ".", "This", "function", "may", "be", "called", "to", "move", "or", "resize", "the", "video", "capture", "buffer", ".", "The", "initial", "buffer", "is", "configured", "during", "a", "call", "to", "CaptureInit", "()", "with", "stride", "1280", "for", "VGA", "resolution", "or", "640", "for", "QVGA", "at", "the", "location", "provided", "in", "the", "\\", "b", "ulCaptureAddr", "parameter", "to", "that", "function", ".", "The", "caller", "is", "responsible", "for", "ensuring", "that", "the", "video", "capture", "buffer", "is", "large", "enough", "to", "hold", "the", "currently", "configured", "video", "frame", "size", "and", "that", "the", "buffer", "does", "not", "overlap", "with", "any", "other", "buffer", "in", "FPGA", "SRAM", "(", "specifically", "the", "graphics", "buffer", ")", ".", "\\", "return", "None", "." ]
void CameraCaptureBufferSet(unsigned long ulAddr, unsigned short usStride, tBoolean bAsync) { ASSERT(ulAddr < 0x100000); ASSERT((usStride & 1) == 0); HWREG(FPGA_VML_REG) = ulAddr; HWREGH(FPGA_VMS_REG) = usStride; if(!bAsync) { WaitForFrameEnd(true); } }
[ "void", "CameraCaptureBufferSet", "(", "unsigned", "long", "ulAddr", ",", "unsigned", "short", "usStride", ",", "tBoolean", "bAsync", ")", "{", "ASSERT", "(", "ulAddr", "<", "0x100000", ")", ";", "ASSERT", "(", "(", "usStride", "&", "1", ")", "==", "0", ")", ";", "HWREG", "(", "FPGA_VML_REG", ")", "=", "ulAddr", ";", "HWREGH", "(", "FPGA_VMS_REG", ")", "=", "usStride", ";", "if", "(", "!", "bAsync", ")", "{", "WaitForFrameEnd", "(", "true", ")", ";", "}", "}" ]
Sets the video capture buffer.
[ "Sets", "the", "video", "capture", "buffer", "." ]
[ "//\r", "// Write the buffer address. We use a single 32bit write to write both\r", "// the VML and VMH registers since this will be broken into 2 half word\r", "// writes for us by the hardware.\r", "//\r", "//\r", "// Write the buffer stride\r", "//\r", "//\r", "// The current FPGA implementation doesn't have a register for the\r", "// buffer height so we merely ignore the parameter for now. The parameter\r", "// is left in the API, however, since it may be useful later.\r", "//\r", "//\r", "// Were we asked to perform this change synchronously?\r", "//\r", "//\r", "// The caller wants us to wait for the change to take effect.\r", "//\r" ]
[ { "param": "ulAddr", "type": "unsigned long" }, { "param": "usStride", "type": "unsigned short" }, { "param": "bAsync", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulAddr", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "usStride", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bAsync", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraColorBarsEnable
void
void CameraColorBarsEnable(tBoolean bEnable, tBoolean bMix) { unsigned char ucVal; // // Have we been asked to control the opaque or mixed color bars? // if(bMix) { // // Enable or disable the color bars which are mixed with the camera // output. // ucVal = CameraRegRead(0x0C); ucVal = bEnable ? (ucVal | 0x01) : (ucVal & ~0x01); CameraRegWrite(0x0C, ucVal); } else { // // Enable or disable opaque color bars. // ucVal = CameraRegRead(0x82); ucVal = bEnable ? (ucVal | 0x0C) : (ucVal & ~0x0C); CameraRegWrite(0x82, ucVal); } }
//***************************************************************************** // //! Enables or disables color bar output from the camera. //! //! \param bEnable is set to \b true to enable color bar output from the camera //! or \b false to disable it and return to normal video capture. //! \param bMix is set to \b true to mix the color bars with the image captured //! by the camera or \b false to replace the camera image completely with the //! color bars. //! //! This function may be used to enable or disable color bars in the output //! from the camera. When \e bMix is \b false, the output from the camera is //! replaced with a standard pattern of vertical color bars. When \e bMix is //! \b true, the normal video output is mixed with the color bar image. //! //! \return None. // //*****************************************************************************
Enables or disables color bar output from the camera. \param bEnable is set to \b true to enable color bar output from the camera or \b false to disable it and return to normal video capture. \param bMix is set to \b true to mix the color bars with the image captured by the camera or \b false to replace the camera image completely with the color bars. This function may be used to enable or disable color bars in the output from the camera. When \e bMix is \b false, the output from the camera is replaced with a standard pattern of vertical color bars. When \e bMix is \b true, the normal video output is mixed with the color bar image. \return None.
[ "Enables", "or", "disables", "color", "bar", "output", "from", "the", "camera", ".", "\\", "param", "bEnable", "is", "set", "to", "\\", "b", "true", "to", "enable", "color", "bar", "output", "from", "the", "camera", "or", "\\", "b", "false", "to", "disable", "it", "and", "return", "to", "normal", "video", "capture", ".", "\\", "param", "bMix", "is", "set", "to", "\\", "b", "true", "to", "mix", "the", "color", "bars", "with", "the", "image", "captured", "by", "the", "camera", "or", "\\", "b", "false", "to", "replace", "the", "camera", "image", "completely", "with", "the", "color", "bars", ".", "This", "function", "may", "be", "used", "to", "enable", "or", "disable", "color", "bars", "in", "the", "output", "from", "the", "camera", ".", "When", "\\", "e", "bMix", "is", "\\", "b", "false", "the", "output", "from", "the", "camera", "is", "replaced", "with", "a", "standard", "pattern", "of", "vertical", "color", "bars", ".", "When", "\\", "e", "bMix", "is", "\\", "b", "true", "the", "normal", "video", "output", "is", "mixed", "with", "the", "color", "bar", "image", ".", "\\", "return", "None", "." ]
void CameraColorBarsEnable(tBoolean bEnable, tBoolean bMix) { unsigned char ucVal; if(bMix) { ucVal = CameraRegRead(0x0C); ucVal = bEnable ? (ucVal | 0x01) : (ucVal & ~0x01); CameraRegWrite(0x0C, ucVal); } else { ucVal = CameraRegRead(0x82); ucVal = bEnable ? (ucVal | 0x0C) : (ucVal & ~0x0C); CameraRegWrite(0x82, ucVal); } }
[ "void", "CameraColorBarsEnable", "(", "tBoolean", "bEnable", ",", "tBoolean", "bMix", ")", "{", "unsigned", "char", "ucVal", ";", "if", "(", "bMix", ")", "{", "ucVal", "=", "CameraRegRead", "(", "0x0C", ")", ";", "ucVal", "=", "bEnable", "?", "(", "ucVal", "|", "0x01", ")", ":", "(", "ucVal", "&", "~", "0x01", ")", ";", "CameraRegWrite", "(", "0x0C", ",", "ucVal", ")", ";", "}", "else", "{", "ucVal", "=", "CameraRegRead", "(", "0x82", ")", ";", "ucVal", "=", "bEnable", "?", "(", "ucVal", "|", "0x0C", ")", ":", "(", "ucVal", "&", "~", "0x0C", ")", ";", "CameraRegWrite", "(", "0x82", ",", "ucVal", ")", ";", "}", "}" ]
Enables or disables color bar output from the camera.
[ "Enables", "or", "disables", "color", "bar", "output", "from", "the", "camera", "." ]
[ "//\r", "// Have we been asked to control the opaque or mixed color bars?\r", "//\r", "//\r", "// Enable or disable the color bars which are mixed with the camera\r", "// output.\r", "//\r", "//\r", "// Enable or disable opaque color bars.\r", "//\r" ]
[ { "param": "bEnable", "type": "tBoolean" }, { "param": "bMix", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bEnable", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bMix", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraCaptureStart
void
void CameraCaptureStart(void) { // // Set the control bit telling the FPGA to start capturing video. // HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VCEN; }
//***************************************************************************** // //! Starts video capture. //! //! This call starts the process of capturing video frames. Frames from the //! camera are written to the buffer configured by a call to the CameraInit() //! or CameraCaptureBufferSet() functions. Following this call, events \b //! CAMERA_EVENT_CAPTURE_START and \b CAMERA_EVENT_CAPTURE_END will be notified //! to the application callback if they have been enabled via a call to the //! CameraEventsSet() function. //! //! \return None. // //*****************************************************************************
Starts video capture. This call starts the process of capturing video frames. Frames from the camera are written to the buffer configured by a call to the CameraInit() or CameraCaptureBufferSet() functions. Following this call, events \b CAMERA_EVENT_CAPTURE_START and \b CAMERA_EVENT_CAPTURE_END will be notified to the application callback if they have been enabled via a call to the CameraEventsSet() function. \return None.
[ "Starts", "video", "capture", ".", "This", "call", "starts", "the", "process", "of", "capturing", "video", "frames", ".", "Frames", "from", "the", "camera", "are", "written", "to", "the", "buffer", "configured", "by", "a", "call", "to", "the", "CameraInit", "()", "or", "CameraCaptureBufferSet", "()", "functions", ".", "Following", "this", "call", "events", "\\", "b", "CAMERA_EVENT_CAPTURE_START", "and", "\\", "b", "CAMERA_EVENT_CAPTURE_END", "will", "be", "notified", "to", "the", "application", "callback", "if", "they", "have", "been", "enabled", "via", "a", "call", "to", "the", "CameraEventsSet", "()", "function", ".", "\\", "return", "None", "." ]
void CameraCaptureStart(void) { HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VCEN; }
[ "void", "CameraCaptureStart", "(", "void", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "|=", "FPGA_SYSCTRL_VCEN", ";", "}" ]
Starts video capture.
[ "Starts", "video", "capture", "." ]
[ "//\r", "// Set the control bit telling the FPGA to start capturing video.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraCaptureStop
void
void CameraCaptureStop(tBoolean bAsync) { // // Were we asked to perform this change synchronously? // if(!bAsync) { // // The caller wants us to wait for the change to take effect. We wait // for the end of the current frame then stop in this case. // WaitForFrameEnd(true); } // // Clear the control bit telling the FPGA to stop capturing video. // HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VCEN; }
//***************************************************************************** // //! Stops video capture. //! //! \param bAsync indicates whether the function call should return immediately //! (\b true) or wait until the current frame capture has completed (\b false) //! before returning. //! //! This call stops the capture of video frames from the camera. Capture will //! stop at the end of the frame which is currently being read and the caller //! may choose to return immediately or wait until the end of the frame by //! setting the \e bAsync parameter appropriately. In cases where \e bAsync is //! set to \b true, capture will end following the next \b //! CAMERA_EVENT_CAPTURE_END event. //! //! \return None. // //*****************************************************************************
Stops video capture. \param bAsync indicates whether the function call should return immediately (\b true) or wait until the current frame capture has completed (\b false) before returning. This call stops the capture of video frames from the camera. Capture will stop at the end of the frame which is currently being read and the caller may choose to return immediately or wait until the end of the frame by setting the \e bAsync parameter appropriately. In cases where \e bAsync is set to \b true, capture will end following the next \b CAMERA_EVENT_CAPTURE_END event. \return None.
[ "Stops", "video", "capture", ".", "\\", "param", "bAsync", "indicates", "whether", "the", "function", "call", "should", "return", "immediately", "(", "\\", "b", "true", ")", "or", "wait", "until", "the", "current", "frame", "capture", "has", "completed", "(", "\\", "b", "false", ")", "before", "returning", ".", "This", "call", "stops", "the", "capture", "of", "video", "frames", "from", "the", "camera", ".", "Capture", "will", "stop", "at", "the", "end", "of", "the", "frame", "which", "is", "currently", "being", "read", "and", "the", "caller", "may", "choose", "to", "return", "immediately", "or", "wait", "until", "the", "end", "of", "the", "frame", "by", "setting", "the", "\\", "e", "bAsync", "parameter", "appropriately", ".", "In", "cases", "where", "\\", "e", "bAsync", "is", "set", "to", "\\", "b", "true", "capture", "will", "end", "following", "the", "next", "\\", "b", "CAMERA_EVENT_CAPTURE_END", "event", ".", "\\", "return", "None", "." ]
void CameraCaptureStop(tBoolean bAsync) { if(!bAsync) { WaitForFrameEnd(true); } HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VCEN; }
[ "void", "CameraCaptureStop", "(", "tBoolean", "bAsync", ")", "{", "if", "(", "!", "bAsync", ")", "{", "WaitForFrameEnd", "(", "true", ")", ";", "}", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&=", "~", "FPGA_SYSCTRL_VCEN", ";", "}" ]
Stops video capture.
[ "Stops", "video", "capture", "." ]
[ "//\r", "// Were we asked to perform this change synchronously?\r", "//\r", "//\r", "// The caller wants us to wait for the change to take effect. We wait\r", "// for the end of the current frame then stop in this case.\r", "//\r", "//\r", "// Clear the control bit telling the FPGA to stop capturing video.\r", "//\r" ]
[ { "param": "bAsync", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bAsync", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraCaptureMatchSet
void
void CameraCaptureMatchSet(unsigned short usLine) { // // Set the capture match register with the line number provided. // HWREGH(FPGA_VCRM_REG) = usLine; }
//***************************************************************************** // //! Sets the capture line on which \b CAMERA_EVENT_CAPTURE_MATCH is generated. //! //! \param usLine is the video line number at which \b //! CAMERA_EVENT_CAPTURE_MATCH will be generated. Valid values are 0 to 479 if //! VGA resolution is being captured or 0 to 239 if QVGA is being captured. //! //! This call sets the video line at which the \b CAMERA_EVENT_CAPTURE_MATCH //! event will be generated assuming this event has previously been enabled //! using a call to CameraEventsSet(). //! //! \return None. // //*****************************************************************************
Sets the capture line on which \b CAMERA_EVENT_CAPTURE_MATCH is generated. \param usLine is the video line number at which \b CAMERA_EVENT_CAPTURE_MATCH will be generated. Valid values are 0 to 479 if VGA resolution is being captured or 0 to 239 if QVGA is being captured. This call sets the video line at which the \b CAMERA_EVENT_CAPTURE_MATCH event will be generated assuming this event has previously been enabled using a call to CameraEventsSet(). \return None.
[ "Sets", "the", "capture", "line", "on", "which", "\\", "b", "CAMERA_EVENT_CAPTURE_MATCH", "is", "generated", ".", "\\", "param", "usLine", "is", "the", "video", "line", "number", "at", "which", "\\", "b", "CAMERA_EVENT_CAPTURE_MATCH", "will", "be", "generated", ".", "Valid", "values", "are", "0", "to", "479", "if", "VGA", "resolution", "is", "being", "captured", "or", "0", "to", "239", "if", "QVGA", "is", "being", "captured", ".", "This", "call", "sets", "the", "video", "line", "at", "which", "the", "\\", "b", "CAMERA_EVENT_CAPTURE_MATCH", "event", "will", "be", "generated", "assuming", "this", "event", "has", "previously", "been", "enabled", "using", "a", "call", "to", "CameraEventsSet", "()", ".", "\\", "return", "None", "." ]
void CameraCaptureMatchSet(unsigned short usLine) { HWREGH(FPGA_VCRM_REG) = usLine; }
[ "void", "CameraCaptureMatchSet", "(", "unsigned", "short", "usLine", ")", "{", "HWREGH", "(", "FPGA_VCRM_REG", ")", "=", "usLine", ";", "}" ]
Sets the capture line on which \b CAMERA_EVENT_CAPTURE_MATCH is generated.
[ "Sets", "the", "capture", "line", "on", "which", "\\", "b", "CAMERA_EVENT_CAPTURE_MATCH", "is", "generated", "." ]
[ "//\r", "// Set the capture match register with the line number provided.\r", "//\r" ]
[ { "param": "usLine", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "usLine", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayBufferSet
void
void CameraDisplayBufferSet(unsigned long ulAddr, unsigned short usStride, tBoolean bAsync) { ASSERT(ulAddr < 0x100000); ASSERT((usStride & 1) == 0); // // Write the buffer address. We use a single 32bit write to write both // the LVML and LVMH registers since this will be broken into 2 half word // writes for us by the hardware. // HWREG(FPGA_LVML_REG) = ulAddr; // // Write the buffer stride. // HWREGH(FPGA_LVMS_REG) = usStride; // // Were we asked to perform this change synchronously? // if(!bAsync) { // // The caller wants us to wait for the change to take effect. // WaitForFrameEnd(false); } }
//***************************************************************************** // //! Sets the address and size of the video display buffer. //! //! \param ulAddr is the address of the video display buffer in the FPGA SRAM. //! This address must be between 0x0 and (0x100000 - video frame size). //! \param usStride is the stride of the video display buffer in bytes. The //! stride is defined as the number of bytes between vertically adjacent pixels. //! \param bAsync indicates whether the function call should return immediately //! (\b true) or wait until the new buffer parameters have taken effect (/b //! false) before returning. //! //! This call sets the address and stride of the buffer from which video should //! be displayed. It is assumed that the image contained in this buffer is the //! size of the video currently being captured, VGA or QVGA. //! //! When displaying live video, the buffer set here will generally be the same //! buffer as was passed to CameraCaptureBufferSet() or CameraInit(). //! Decoupling the capture and display buffers, however, offers applications //! the option of capturing into one buffer while displaying from a different //! region of memory. //! //! \return None. // //*****************************************************************************
Sets the address and size of the video display buffer. \param ulAddr is the address of the video display buffer in the FPGA SRAM. This address must be between 0x0 and (0x100000 - video frame size). \param usStride is the stride of the video display buffer in bytes. The stride is defined as the number of bytes between vertically adjacent pixels. \param bAsync indicates whether the function call should return immediately (\b true) or wait until the new buffer parameters have taken effect (/b false) before returning. This call sets the address and stride of the buffer from which video should be displayed. It is assumed that the image contained in this buffer is the size of the video currently being captured, VGA or QVGA. When displaying live video, the buffer set here will generally be the same buffer as was passed to CameraCaptureBufferSet() or CameraInit(). Decoupling the capture and display buffers, however, offers applications the option of capturing into one buffer while displaying from a different region of memory. \return None.
[ "Sets", "the", "address", "and", "size", "of", "the", "video", "display", "buffer", ".", "\\", "param", "ulAddr", "is", "the", "address", "of", "the", "video", "display", "buffer", "in", "the", "FPGA", "SRAM", ".", "This", "address", "must", "be", "between", "0x0", "and", "(", "0x100000", "-", "video", "frame", "size", ")", ".", "\\", "param", "usStride", "is", "the", "stride", "of", "the", "video", "display", "buffer", "in", "bytes", ".", "The", "stride", "is", "defined", "as", "the", "number", "of", "bytes", "between", "vertically", "adjacent", "pixels", ".", "\\", "param", "bAsync", "indicates", "whether", "the", "function", "call", "should", "return", "immediately", "(", "\\", "b", "true", ")", "or", "wait", "until", "the", "new", "buffer", "parameters", "have", "taken", "effect", "(", "/", "b", "false", ")", "before", "returning", ".", "This", "call", "sets", "the", "address", "and", "stride", "of", "the", "buffer", "from", "which", "video", "should", "be", "displayed", ".", "It", "is", "assumed", "that", "the", "image", "contained", "in", "this", "buffer", "is", "the", "size", "of", "the", "video", "currently", "being", "captured", "VGA", "or", "QVGA", ".", "When", "displaying", "live", "video", "the", "buffer", "set", "here", "will", "generally", "be", "the", "same", "buffer", "as", "was", "passed", "to", "CameraCaptureBufferSet", "()", "or", "CameraInit", "()", ".", "Decoupling", "the", "capture", "and", "display", "buffers", "however", "offers", "applications", "the", "option", "of", "capturing", "into", "one", "buffer", "while", "displaying", "from", "a", "different", "region", "of", "memory", ".", "\\", "return", "None", "." ]
void CameraDisplayBufferSet(unsigned long ulAddr, unsigned short usStride, tBoolean bAsync) { ASSERT(ulAddr < 0x100000); ASSERT((usStride & 1) == 0); HWREG(FPGA_LVML_REG) = ulAddr; HWREGH(FPGA_LVMS_REG) = usStride; if(!bAsync) { WaitForFrameEnd(false); } }
[ "void", "CameraDisplayBufferSet", "(", "unsigned", "long", "ulAddr", ",", "unsigned", "short", "usStride", ",", "tBoolean", "bAsync", ")", "{", "ASSERT", "(", "ulAddr", "<", "0x100000", ")", ";", "ASSERT", "(", "(", "usStride", "&", "1", ")", "==", "0", ")", ";", "HWREG", "(", "FPGA_LVML_REG", ")", "=", "ulAddr", ";", "HWREGH", "(", "FPGA_LVMS_REG", ")", "=", "usStride", ";", "if", "(", "!", "bAsync", ")", "{", "WaitForFrameEnd", "(", "false", ")", ";", "}", "}" ]
Sets the address and size of the video display buffer.
[ "Sets", "the", "address", "and", "size", "of", "the", "video", "display", "buffer", "." ]
[ "//\r", "// Write the buffer address. We use a single 32bit write to write both\r", "// the LVML and LVMH registers since this will be broken into 2 half word\r", "// writes for us by the hardware.\r", "//\r", "//\r", "// Write the buffer stride.\r", "//\r", "//\r", "// Were we asked to perform this change synchronously?\r", "//\r", "//\r", "// The caller wants us to wait for the change to take effect.\r", "//\r" ]
[ { "param": "ulAddr", "type": "unsigned long" }, { "param": "usStride", "type": "unsigned short" }, { "param": "bAsync", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulAddr", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "usStride", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bAsync", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayChromaKeySet
void
void CameraDisplayChromaKeySet(unsigned long ulRGB) { // // Set the chromakey color. // HWREGH(FPGA_CHRMKEY_REG) = Kitronix320x240x16_FPGAColorMap(ulRGB); }
//***************************************************************************** // //! Sets the chromakey color controlling graphics transparency. //! //! \param ulRGB is the RGB888 color to use as the graphics chromakey. //! //! This call sets the color which will be considered the chromakey. If this //! color appears in the graphics buffer and both graphics and video planes are //! enabled, the video pixel will be shown instead of the graphics pixel at //! this position. //! //! Chromakeying offers an easy way to allow graphics to be displayed on top //! of the video with the video "shining through" the graphics in selected //! areas. To achieve this, paint areas of the graphics plane at which the //! video is to be visible using the chromakey color. Areas in which the //! graphics are to be seen should use colors other than the chromakey. //! //! Note that only a simple compare is provided to select between graphics and //! video using the key - the video pixel is shown if the graphics color is //! exactly equal to the chromakey color. If you are preparing graphics which //! contain areas of chromakey, make sure that you do not anti-alias the edges //! between the visible portion of your graphic and the chromakey areas since //! these areas containing a blend of the chromakey and graphics colors will //! show as graphics pixels and result in a chromakey-colored fringe around //! your graphic. //! //! \return None. // //*****************************************************************************
Sets the chromakey color controlling graphics transparency. \param ulRGB is the RGB888 color to use as the graphics chromakey. This call sets the color which will be considered the chromakey. If this color appears in the graphics buffer and both graphics and video planes are enabled, the video pixel will be shown instead of the graphics pixel at this position. Chromakeying offers an easy way to allow graphics to be displayed on top of the video with the video "shining through" the graphics in selected areas. To achieve this, paint areas of the graphics plane at which the video is to be visible using the chromakey color. Areas in which the graphics are to be seen should use colors other than the chromakey. Note that only a simple compare is provided to select between graphics and video using the key - the video pixel is shown if the graphics color is exactly equal to the chromakey color. If you are preparing graphics which contain areas of chromakey, make sure that you do not anti-alias the edges between the visible portion of your graphic and the chromakey areas since these areas containing a blend of the chromakey and graphics colors will show as graphics pixels and result in a chromakey-colored fringe around your graphic. \return None.
[ "Sets", "the", "chromakey", "color", "controlling", "graphics", "transparency", ".", "\\", "param", "ulRGB", "is", "the", "RGB888", "color", "to", "use", "as", "the", "graphics", "chromakey", ".", "This", "call", "sets", "the", "color", "which", "will", "be", "considered", "the", "chromakey", ".", "If", "this", "color", "appears", "in", "the", "graphics", "buffer", "and", "both", "graphics", "and", "video", "planes", "are", "enabled", "the", "video", "pixel", "will", "be", "shown", "instead", "of", "the", "graphics", "pixel", "at", "this", "position", ".", "Chromakeying", "offers", "an", "easy", "way", "to", "allow", "graphics", "to", "be", "displayed", "on", "top", "of", "the", "video", "with", "the", "video", "\"", "shining", "through", "\"", "the", "graphics", "in", "selected", "areas", ".", "To", "achieve", "this", "paint", "areas", "of", "the", "graphics", "plane", "at", "which", "the", "video", "is", "to", "be", "visible", "using", "the", "chromakey", "color", ".", "Areas", "in", "which", "the", "graphics", "are", "to", "be", "seen", "should", "use", "colors", "other", "than", "the", "chromakey", ".", "Note", "that", "only", "a", "simple", "compare", "is", "provided", "to", "select", "between", "graphics", "and", "video", "using", "the", "key", "-", "the", "video", "pixel", "is", "shown", "if", "the", "graphics", "color", "is", "exactly", "equal", "to", "the", "chromakey", "color", ".", "If", "you", "are", "preparing", "graphics", "which", "contain", "areas", "of", "chromakey", "make", "sure", "that", "you", "do", "not", "anti", "-", "alias", "the", "edges", "between", "the", "visible", "portion", "of", "your", "graphic", "and", "the", "chromakey", "areas", "since", "these", "areas", "containing", "a", "blend", "of", "the", "chromakey", "and", "graphics", "colors", "will", "show", "as", "graphics", "pixels", "and", "result", "in", "a", "chromakey", "-", "colored", "fringe", "around", "your", "graphic", ".", "\\", "return", "None", "." ]
void CameraDisplayChromaKeySet(unsigned long ulRGB) { HWREGH(FPGA_CHRMKEY_REG) = Kitronix320x240x16_FPGAColorMap(ulRGB); }
[ "void", "CameraDisplayChromaKeySet", "(", "unsigned", "long", "ulRGB", ")", "{", "HWREGH", "(", "FPGA_CHRMKEY_REG", ")", "=", "Kitronix320x240x16_FPGAColorMap", "(", "ulRGB", ")", ";", "}" ]
Sets the chromakey color controlling graphics transparency.
[ "Sets", "the", "chromakey", "color", "controlling", "graphics", "transparency", "." ]
[ "//\r", "// Set the chromakey color.\r", "//\r" ]
[ { "param": "ulRGB", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulRGB", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayChromaKeyEnable
void
void CameraDisplayChromaKeyEnable(tBoolean bEnable) { // // Enable or disable chromakeying. // if(bEnable) { // // Enable chromakey. // HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_CMKEN; } else { // // Disable chromakey. // HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_CMKEN; } }
//***************************************************************************** // //! Enables or disables chromakey mixing of graphics and video. //! //! \param bEnable is \b true to enable graphics/video chromakeying and \b //! false to disable it. //! //! This call enables or disables chromakeying. When disabled, the graphics //! plane will be displayed in preference to video whenever it is enabled //! by a call to CameraDisplayStart(), regardless of whether the video plane //! is also enabled. //! //! With chromakey enabled and both graphics and video planes enabled, the //! graphics and video will be mixed on the display. At each pixel location, //! if the graphics plane contains the current chromakey color (as set using a //! call to CameraDisplayChromakeySet()), the corresponding video pixel will be //! shown instead of the graphics pixel. //! //! Another way to think of this is that graphics plane sits above the video //! plane with the chromakey color transparent, allowing the video to ``shine //! through'' the graphics in areas where it exists. //! //! \return None. // //*****************************************************************************
Enables or disables chromakey mixing of graphics and video. \param bEnable is \b true to enable graphics/video chromakeying and \b false to disable it. This call enables or disables chromakeying. When disabled, the graphics plane will be displayed in preference to video whenever it is enabled by a call to CameraDisplayStart(), regardless of whether the video plane is also enabled. With chromakey enabled and both graphics and video planes enabled, the graphics and video will be mixed on the display. At each pixel location, if the graphics plane contains the current chromakey color (as set using a call to CameraDisplayChromakeySet()), the corresponding video pixel will be shown instead of the graphics pixel. Another way to think of this is that graphics plane sits above the video plane with the chromakey color transparent, allowing the video to ``shine through'' the graphics in areas where it exists. \return None.
[ "Enables", "or", "disables", "chromakey", "mixing", "of", "graphics", "and", "video", ".", "\\", "param", "bEnable", "is", "\\", "b", "true", "to", "enable", "graphics", "/", "video", "chromakeying", "and", "\\", "b", "false", "to", "disable", "it", ".", "This", "call", "enables", "or", "disables", "chromakeying", ".", "When", "disabled", "the", "graphics", "plane", "will", "be", "displayed", "in", "preference", "to", "video", "whenever", "it", "is", "enabled", "by", "a", "call", "to", "CameraDisplayStart", "()", "regardless", "of", "whether", "the", "video", "plane", "is", "also", "enabled", ".", "With", "chromakey", "enabled", "and", "both", "graphics", "and", "video", "planes", "enabled", "the", "graphics", "and", "video", "will", "be", "mixed", "on", "the", "display", ".", "At", "each", "pixel", "location", "if", "the", "graphics", "plane", "contains", "the", "current", "chromakey", "color", "(", "as", "set", "using", "a", "call", "to", "CameraDisplayChromakeySet", "()", ")", "the", "corresponding", "video", "pixel", "will", "be", "shown", "instead", "of", "the", "graphics", "pixel", ".", "Another", "way", "to", "think", "of", "this", "is", "that", "graphics", "plane", "sits", "above", "the", "video", "plane", "with", "the", "chromakey", "color", "transparent", "allowing", "the", "video", "to", "`", "`", "shine", "through", "'", "'", "the", "graphics", "in", "areas", "where", "it", "exists", ".", "\\", "return", "None", "." ]
void CameraDisplayChromaKeyEnable(tBoolean bEnable) { if(bEnable) { HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_CMKEN; } else { HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_CMKEN; } }
[ "void", "CameraDisplayChromaKeyEnable", "(", "tBoolean", "bEnable", ")", "{", "if", "(", "bEnable", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "|=", "FPGA_SYSCTRL_CMKEN", ";", "}", "else", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&=", "~", "FPGA_SYSCTRL_CMKEN", ";", "}", "}" ]
Enables or disables chromakey mixing of graphics and video.
[ "Enables", "or", "disables", "chromakey", "mixing", "of", "graphics", "and", "video", "." ]
[ "//\r", "// Enable or disable chromakeying.\r", "//\r", "//\r", "// Enable chromakey.\r", "//\r", "//\r", "// Disable chromakey.\r", "//\r" ]
[ { "param": "bEnable", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bEnable", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayDownscaleSet
void
void CameraDisplayDownscaleSet(tBoolean bDownscale) { // // Enable or disable video downscaling. // if(bDownscale) { // // Enable downscaling. // HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VSCALE; } else { // // Disable downscaling. // HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VSCALE; } }
//***************************************************************************** // //! Enables or disables video display downscaling. //! //! \param bDownscale is \b true if the display should show half size video or //! \b false if full size video is to be displayed. //! //! This call allows a client to display video either at the size it was //! captured or at quarter the capture size (skipping every other pixel and //! line). This may be used to show full screen video on the 320x240 display //! while capturing 640x480 VGA images into the video capture buffer. //! //! Note that the downscaling uses a simple pixel skipping approach so video //! display quality will likely be somewhat lower when using this downscale //! option than would be achieved by capturing at the required resolution and //! displaying the native size without downscaling on display. //! //! \return None. // //*****************************************************************************
Enables or disables video display downscaling. \param bDownscale is \b true if the display should show half size video or \b false if full size video is to be displayed. This call allows a client to display video either at the size it was captured or at quarter the capture size (skipping every other pixel and line). This may be used to show full screen video on the 320x240 display while capturing 640x480 VGA images into the video capture buffer. Note that the downscaling uses a simple pixel skipping approach so video display quality will likely be somewhat lower when using this downscale option than would be achieved by capturing at the required resolution and displaying the native size without downscaling on display. \return None.
[ "Enables", "or", "disables", "video", "display", "downscaling", ".", "\\", "param", "bDownscale", "is", "\\", "b", "true", "if", "the", "display", "should", "show", "half", "size", "video", "or", "\\", "b", "false", "if", "full", "size", "video", "is", "to", "be", "displayed", ".", "This", "call", "allows", "a", "client", "to", "display", "video", "either", "at", "the", "size", "it", "was", "captured", "or", "at", "quarter", "the", "capture", "size", "(", "skipping", "every", "other", "pixel", "and", "line", ")", ".", "This", "may", "be", "used", "to", "show", "full", "screen", "video", "on", "the", "320x240", "display", "while", "capturing", "640x480", "VGA", "images", "into", "the", "video", "capture", "buffer", ".", "Note", "that", "the", "downscaling", "uses", "a", "simple", "pixel", "skipping", "approach", "so", "video", "display", "quality", "will", "likely", "be", "somewhat", "lower", "when", "using", "this", "downscale", "option", "than", "would", "be", "achieved", "by", "capturing", "at", "the", "required", "resolution", "and", "displaying", "the", "native", "size", "without", "downscaling", "on", "display", ".", "\\", "return", "None", "." ]
void CameraDisplayDownscaleSet(tBoolean bDownscale) { if(bDownscale) { HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VSCALE; } else { HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VSCALE; } }
[ "void", "CameraDisplayDownscaleSet", "(", "tBoolean", "bDownscale", ")", "{", "if", "(", "bDownscale", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "|=", "FPGA_SYSCTRL_VSCALE", ";", "}", "else", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&=", "~", "FPGA_SYSCTRL_VSCALE", ";", "}", "}" ]
Enables or disables video display downscaling.
[ "Enables", "or", "disables", "video", "display", "downscaling", "." ]
[ "//\r", "// Enable or disable video downscaling.\r", "//\r", "//\r", "// Enable downscaling.\r", "//\r", "//\r", "// Disable downscaling.\r", "//\r" ]
[ { "param": "bDownscale", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bDownscale", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayStart
void
void CameraDisplayStart(void) { // // Enable/disable the video display plane. // HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VDEN; }
//***************************************************************************** // //! Enables the video display plane. //! //! This call instructs the FPGA to enable the video display plane using the //! current size, position and buffer pointer settings. //! //! \return None. // //*****************************************************************************
Enables the video display plane. This call instructs the FPGA to enable the video display plane using the current size, position and buffer pointer settings. \return None.
[ "Enables", "the", "video", "display", "plane", ".", "This", "call", "instructs", "the", "FPGA", "to", "enable", "the", "video", "display", "plane", "using", "the", "current", "size", "position", "and", "buffer", "pointer", "settings", ".", "\\", "return", "None", "." ]
void CameraDisplayStart(void) { HWREGH(FPGA_SYSCTRL_REG) |= FPGA_SYSCTRL_VDEN; }
[ "void", "CameraDisplayStart", "(", "void", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "|=", "FPGA_SYSCTRL_VDEN", ";", "}" ]
Enables the video display plane.
[ "Enables", "the", "video", "display", "plane", "." ]
[ "//\r", "// Enable/disable the video display plane.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayStop
void
void CameraDisplayStop(tBoolean bAsync) { // // Stop automatic display processing // HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VDEN; // // Were we asked to perform this change synchronously? // if(!bAsync) { // // The caller wants us to wait for the change to take effect. // WaitForFrameEnd(false); } }
//***************************************************************************** // //! Disables the video display plane. //! //! \param bAsync indicates whether the function call should return immediately //! (\b true) or wait until the current display frame has completed (/b false) //! before returning. //! //! This call disables the video display plane on the LCD. The caller may //! choose to return immediately or wait until the end of the frame by setting //! the \e bAsync parameter appropriately. In cases where \e bAsync is set to //! \b true, display processing will end following the next //! \b CAMERA_EVENT_DISPLAY_END event. //! //! \return None. // //*****************************************************************************
Disables the video display plane. \param bAsync indicates whether the function call should return immediately (\b true) or wait until the current display frame has completed (/b false) before returning. This call disables the video display plane on the LCD. The caller may choose to return immediately or wait until the end of the frame by setting the \e bAsync parameter appropriately. In cases where \e bAsync is set to \b true, display processing will end following the next \b CAMERA_EVENT_DISPLAY_END event. \return None.
[ "Disables", "the", "video", "display", "plane", ".", "\\", "param", "bAsync", "indicates", "whether", "the", "function", "call", "should", "return", "immediately", "(", "\\", "b", "true", ")", "or", "wait", "until", "the", "current", "display", "frame", "has", "completed", "(", "/", "b", "false", ")", "before", "returning", ".", "This", "call", "disables", "the", "video", "display", "plane", "on", "the", "LCD", ".", "The", "caller", "may", "choose", "to", "return", "immediately", "or", "wait", "until", "the", "end", "of", "the", "frame", "by", "setting", "the", "\\", "e", "bAsync", "parameter", "appropriately", ".", "In", "cases", "where", "\\", "e", "bAsync", "is", "set", "to", "\\", "b", "true", "display", "processing", "will", "end", "following", "the", "next", "\\", "b", "CAMERA_EVENT_DISPLAY_END", "event", ".", "\\", "return", "None", "." ]
void CameraDisplayStop(tBoolean bAsync) { HWREGH(FPGA_SYSCTRL_REG) &= ~FPGA_SYSCTRL_VDEN; if(!bAsync) { WaitForFrameEnd(false); } }
[ "void", "CameraDisplayStop", "(", "tBoolean", "bAsync", ")", "{", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&=", "~", "FPGA_SYSCTRL_VDEN", ";", "if", "(", "!", "bAsync", ")", "{", "WaitForFrameEnd", "(", "false", ")", ";", "}", "}" ]
Disables the video display plane.
[ "Disables", "the", "video", "display", "plane", "." ]
[ "//\r", "// Stop automatic display processing\r", "//\r", "//\r", "// Were we asked to perform this change synchronously?\r", "//\r", "//\r", "// The caller wants us to wait for the change to take effect.\r", "//\r" ]
[ { "param": "bAsync", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bAsync", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraDisplayMatchSet
void
void CameraDisplayMatchSet(unsigned short usLine) { // // Set the LCD row match register with the line number provided. // HWREGH(FPGA_LRM_REG) = usLine; }
//***************************************************************************** // //! Sets the display line on which \b CAMERA_EVENT_DISPLAY_MATCH is generated. //! //! \param usLine is the display line number at which \b //! CAMERA_EVENT_DISPLAY_MATCH will be generated. Valid values are 0 to 239. //! //! This call sets the display line at which the \b CAMERA_EVENT_DISPLAY_MATCH //! event will be generated assuming this event has previously been enabled //! using a call to CameraEventsSet(). The event is generated as the FPGA //! scans out the data for the requested display row. Note, however, that the //! FPGA is merely writing data into the display controller's frame buffer so //! this event cannot be used to synchronize display updates to prevent //! ``tearing.'' //! //! \return None. // //*****************************************************************************
Sets the display line on which \b CAMERA_EVENT_DISPLAY_MATCH is generated. \param usLine is the display line number at which \b CAMERA_EVENT_DISPLAY_MATCH will be generated. Valid values are 0 to 239. This call sets the display line at which the \b CAMERA_EVENT_DISPLAY_MATCH event will be generated assuming this event has previously been enabled using a call to CameraEventsSet(). The event is generated as the FPGA scans out the data for the requested display row. Note, however, that the FPGA is merely writing data into the display controller's frame buffer so this event cannot be used to synchronize display updates to prevent ``tearing.'' \return None.
[ "Sets", "the", "display", "line", "on", "which", "\\", "b", "CAMERA_EVENT_DISPLAY_MATCH", "is", "generated", ".", "\\", "param", "usLine", "is", "the", "display", "line", "number", "at", "which", "\\", "b", "CAMERA_EVENT_DISPLAY_MATCH", "will", "be", "generated", ".", "Valid", "values", "are", "0", "to", "239", ".", "This", "call", "sets", "the", "display", "line", "at", "which", "the", "\\", "b", "CAMERA_EVENT_DISPLAY_MATCH", "event", "will", "be", "generated", "assuming", "this", "event", "has", "previously", "been", "enabled", "using", "a", "call", "to", "CameraEventsSet", "()", ".", "The", "event", "is", "generated", "as", "the", "FPGA", "scans", "out", "the", "data", "for", "the", "requested", "display", "row", ".", "Note", "however", "that", "the", "FPGA", "is", "merely", "writing", "data", "into", "the", "display", "controller", "'", "s", "frame", "buffer", "so", "this", "event", "cannot", "be", "used", "to", "synchronize", "display", "updates", "to", "prevent", "`", "`", "tearing", ".", "'", "'", "\\", "return", "None", "." ]
void CameraDisplayMatchSet(unsigned short usLine) { HWREGH(FPGA_LRM_REG) = usLine; }
[ "void", "CameraDisplayMatchSet", "(", "unsigned", "short", "usLine", ")", "{", "HWREGH", "(", "FPGA_LRM_REG", ")", "=", "usLine", ";", "}" ]
Sets the display line on which \b CAMERA_EVENT_DISPLAY_MATCH is generated.
[ "Sets", "the", "display", "line", "on", "which", "\\", "b", "CAMERA_EVENT_DISPLAY_MATCH", "is", "generated", "." ]
[ "//\r", "// Set the LCD row match register with the line number provided.\r", "//\r" ]
[ { "param": "usLine", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "usLine", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraBrightnessSet
void
void CameraBrightnessSet(unsigned char ucBrightness) { unsigned long ulLoop; // // Loop through the available brightness settings. // for(ulLoop = 0; ulLoop < NUM_BRIGHTNESS_SETTINGS; ulLoop++) { // // Does the supplied brightness fall into the current band? // if(ucBrightness <= g_psBrightness[ulLoop].ucThreshold) { // // Yes - write the registers to set the appropriate brightness // level. // CameraRegWrite(0x24, g_psBrightness[ulLoop].ucReg24Val); CameraRegWrite(0x25, g_psBrightness[ulLoop].ucReg25Val); CameraRegWrite(0x26, g_psBrightness[ulLoop].ucReg26Val); return; } } }
//***************************************************************************** // //! Sets the brightness of the video image. //! //! \param ucBrightness is an unsigned value representing the required //! brightness for the video image. Values in the range [0, 255] are scaled to //! represent exposure values between -4EV and +4EV with \b BRIGHTNESS_NORMAL //! (128) representing ``normal'' brightness or 0EV adjustment. //! //! This function sets the brightness (exposure) of the captured video image. //! Values of \e ucBrightness above \b BRIGHTNESS_NORMAL cause the image to be //! brighter while values below this darken the image. //! //! \return None. // //*****************************************************************************
Sets the brightness of the video image. \param ucBrightness is an unsigned value representing the required brightness for the video image. Values in the range [0, 255] are scaled to represent exposure values between -4EV and +4EV with \b BRIGHTNESS_NORMAL (128) representing ``normal'' brightness or 0EV adjustment. This function sets the brightness (exposure) of the captured video image. Values of \e ucBrightness above \b BRIGHTNESS_NORMAL cause the image to be brighter while values below this darken the image. \return None.
[ "Sets", "the", "brightness", "of", "the", "video", "image", ".", "\\", "param", "ucBrightness", "is", "an", "unsigned", "value", "representing", "the", "required", "brightness", "for", "the", "video", "image", ".", "Values", "in", "the", "range", "[", "0", "255", "]", "are", "scaled", "to", "represent", "exposure", "values", "between", "-", "4EV", "and", "+", "4EV", "with", "\\", "b", "BRIGHTNESS_NORMAL", "(", "128", ")", "representing", "`", "`", "normal", "'", "'", "brightness", "or", "0EV", "adjustment", ".", "This", "function", "sets", "the", "brightness", "(", "exposure", ")", "of", "the", "captured", "video", "image", ".", "Values", "of", "\\", "e", "ucBrightness", "above", "\\", "b", "BRIGHTNESS_NORMAL", "cause", "the", "image", "to", "be", "brighter", "while", "values", "below", "this", "darken", "the", "image", ".", "\\", "return", "None", "." ]
void CameraBrightnessSet(unsigned char ucBrightness) { unsigned long ulLoop; for(ulLoop = 0; ulLoop < NUM_BRIGHTNESS_SETTINGS; ulLoop++) { if(ucBrightness <= g_psBrightness[ulLoop].ucThreshold) { CameraRegWrite(0x24, g_psBrightness[ulLoop].ucReg24Val); CameraRegWrite(0x25, g_psBrightness[ulLoop].ucReg25Val); CameraRegWrite(0x26, g_psBrightness[ulLoop].ucReg26Val); return; } } }
[ "void", "CameraBrightnessSet", "(", "unsigned", "char", "ucBrightness", ")", "{", "unsigned", "long", "ulLoop", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "NUM_BRIGHTNESS_SETTINGS", ";", "ulLoop", "++", ")", "{", "if", "(", "ucBrightness", "<=", "g_psBrightness", "[", "ulLoop", "]", ".", "ucThreshold", ")", "{", "CameraRegWrite", "(", "0x24", ",", "g_psBrightness", "[", "ulLoop", "]", ".", "ucReg24Val", ")", ";", "CameraRegWrite", "(", "0x25", ",", "g_psBrightness", "[", "ulLoop", "]", ".", "ucReg25Val", ")", ";", "CameraRegWrite", "(", "0x26", ",", "g_psBrightness", "[", "ulLoop", "]", ".", "ucReg26Val", ")", ";", "return", ";", "}", "}", "}" ]
Sets the brightness of the video image.
[ "Sets", "the", "brightness", "of", "the", "video", "image", "." ]
[ "//\r", "// Loop through the available brightness settings.\r", "//\r", "//\r", "// Does the supplied brightness fall into the current band?\r", "//\r", "//\r", "// Yes - write the registers to set the appropriate brightness\r", "// level.\r", "//\r" ]
[ { "param": "ucBrightness", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucBrightness", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraSaturationSet
void
void CameraSaturationSet(unsigned char ucSaturation) { unsigned char ucVal; // // Enable color adjustments. // ucVal = CameraRegRead(0x81); ucVal |= 0x33; CameraRegWrite(0x81, ucVal); // // Write the new saturation value. // CameraRegWrite(0xD8, ucSaturation >> 1); CameraRegWrite(0xD9, ucSaturation >> 1); // // Enable saturation adjustment. // ucVal = CameraRegRead(0xD2); ucVal |= 0x02; CameraRegWrite(0xD2, ucVal); }
//***************************************************************************** // //! Sets the color saturation of the video image. //! //! \param ucSaturation is a value representing the required saturation //! for the video image. Normal saturation is represented by value \b //! SATURATION_NORMAL (128) with values above this increasing saturation and //! values below decreasing it. //! //! This function sets the color saturation of the captured video image. Higher //! values result in more vivid images and lower values produce a muted or even //! monochrome effect. //! //! \return None. // //*****************************************************************************
Sets the color saturation of the video image. \param ucSaturation is a value representing the required saturation for the video image. Normal saturation is represented by value \b SATURATION_NORMAL (128) with values above this increasing saturation and values below decreasing it. This function sets the color saturation of the captured video image. Higher values result in more vivid images and lower values produce a muted or even monochrome effect. \return None.
[ "Sets", "the", "color", "saturation", "of", "the", "video", "image", ".", "\\", "param", "ucSaturation", "is", "a", "value", "representing", "the", "required", "saturation", "for", "the", "video", "image", ".", "Normal", "saturation", "is", "represented", "by", "value", "\\", "b", "SATURATION_NORMAL", "(", "128", ")", "with", "values", "above", "this", "increasing", "saturation", "and", "values", "below", "decreasing", "it", ".", "This", "function", "sets", "the", "color", "saturation", "of", "the", "captured", "video", "image", ".", "Higher", "values", "result", "in", "more", "vivid", "images", "and", "lower", "values", "produce", "a", "muted", "or", "even", "monochrome", "effect", ".", "\\", "return", "None", "." ]
void CameraSaturationSet(unsigned char ucSaturation) { unsigned char ucVal; ucVal = CameraRegRead(0x81); ucVal |= 0x33; CameraRegWrite(0x81, ucVal); CameraRegWrite(0xD8, ucSaturation >> 1); CameraRegWrite(0xD9, ucSaturation >> 1); ucVal = CameraRegRead(0xD2); ucVal |= 0x02; CameraRegWrite(0xD2, ucVal); }
[ "void", "CameraSaturationSet", "(", "unsigned", "char", "ucSaturation", ")", "{", "unsigned", "char", "ucVal", ";", "ucVal", "=", "CameraRegRead", "(", "0x81", ")", ";", "ucVal", "|=", "0x33", ";", "CameraRegWrite", "(", "0x81", ",", "ucVal", ")", ";", "CameraRegWrite", "(", "0xD8", ",", "ucSaturation", ">>", "1", ")", ";", "CameraRegWrite", "(", "0xD9", ",", "ucSaturation", ">>", "1", ")", ";", "ucVal", "=", "CameraRegRead", "(", "0xD2", ")", ";", "ucVal", "|=", "0x02", ";", "CameraRegWrite", "(", "0xD2", ",", "ucVal", ")", ";", "}" ]
Sets the color saturation of the video image.
[ "Sets", "the", "color", "saturation", "of", "the", "video", "image", "." ]
[ "//\r", "// Enable color adjustments.\r", "//\r", "//\r", "// Write the new saturation value.\r", "//\r", "//\r", "// Enable saturation adjustment.\r", "//\r" ]
[ { "param": "ucSaturation", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucSaturation", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraContrastSet
void
void CameraContrastSet(unsigned char ucContrast) { unsigned char ucVal; unsigned long ulLoop; // // Enable color adjustments. // ucVal = CameraRegRead(0x81); ucVal |= 0x33; CameraRegWrite(0x81, ucVal); // // Write the new contrast value. Register values for 0xD5 and 0xD2 are // the same for each setting but 0xD4 and 0xD3 vary. // CameraRegWrite(0xD5, 0x20); // // Loop through the available contrast settings. // for(ulLoop = 0; ulLoop < NUM_CONTRAST_SETTINGS; ulLoop++) { // // Does the supplied contrast fall into the current band? // if(ucContrast <= g_psContrast[ulLoop].ucThreshold) { // // Yes - write the registers to set the appropriate contrast. // CameraRegWrite(0xD4, g_psContrast[ulLoop].ucRegD4Val); CameraRegWrite(0xD3, g_psContrast[ulLoop].ucRegD3Val); break; } } // // Enable contrast adjustments. // ucVal = CameraRegRead(0xD2); ucVal |= 0x04; CameraRegWrite(0xD2, ucVal); // // Set the sense of the contrast adjustment, increase or decrease. // ucVal = CameraRegRead(0xDC); if(ucContrast < CONTRAST_NORMAL) { ucVal |= 0x04; } else { ucVal &= ~0x04; } CameraRegWrite(0xDC, ucVal); }
//***************************************************************************** // //! Sets the contrast of the video image. //! //! \param ucContrast is a value representing the required contrast for the //! video image. Normal contrast is represented by value \b CONTRAST_NORMAL //! (128) with values above this increasing contrast and values below //! decreasing it. //! //! This function sets the contrast of the captured video image. Higher //! values result in higher contrast images and lower values result in lower //! contrast images. //! //! \return None. // //*****************************************************************************
Sets the contrast of the video image. \param ucContrast is a value representing the required contrast for the video image. Normal contrast is represented by value \b CONTRAST_NORMAL (128) with values above this increasing contrast and values below decreasing it. This function sets the contrast of the captured video image. Higher values result in higher contrast images and lower values result in lower contrast images. \return None.
[ "Sets", "the", "contrast", "of", "the", "video", "image", ".", "\\", "param", "ucContrast", "is", "a", "value", "representing", "the", "required", "contrast", "for", "the", "video", "image", ".", "Normal", "contrast", "is", "represented", "by", "value", "\\", "b", "CONTRAST_NORMAL", "(", "128", ")", "with", "values", "above", "this", "increasing", "contrast", "and", "values", "below", "decreasing", "it", ".", "This", "function", "sets", "the", "contrast", "of", "the", "captured", "video", "image", ".", "Higher", "values", "result", "in", "higher", "contrast", "images", "and", "lower", "values", "result", "in", "lower", "contrast", "images", ".", "\\", "return", "None", "." ]
void CameraContrastSet(unsigned char ucContrast) { unsigned char ucVal; unsigned long ulLoop; ucVal = CameraRegRead(0x81); ucVal |= 0x33; CameraRegWrite(0x81, ucVal); CameraRegWrite(0xD5, 0x20); for(ulLoop = 0; ulLoop < NUM_CONTRAST_SETTINGS; ulLoop++) { if(ucContrast <= g_psContrast[ulLoop].ucThreshold) { CameraRegWrite(0xD4, g_psContrast[ulLoop].ucRegD4Val); CameraRegWrite(0xD3, g_psContrast[ulLoop].ucRegD3Val); break; } } ucVal = CameraRegRead(0xD2); ucVal |= 0x04; CameraRegWrite(0xD2, ucVal); ucVal = CameraRegRead(0xDC); if(ucContrast < CONTRAST_NORMAL) { ucVal |= 0x04; } else { ucVal &= ~0x04; } CameraRegWrite(0xDC, ucVal); }
[ "void", "CameraContrastSet", "(", "unsigned", "char", "ucContrast", ")", "{", "unsigned", "char", "ucVal", ";", "unsigned", "long", "ulLoop", ";", "ucVal", "=", "CameraRegRead", "(", "0x81", ")", ";", "ucVal", "|=", "0x33", ";", "CameraRegWrite", "(", "0x81", ",", "ucVal", ")", ";", "CameraRegWrite", "(", "0xD5", ",", "0x20", ")", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "NUM_CONTRAST_SETTINGS", ";", "ulLoop", "++", ")", "{", "if", "(", "ucContrast", "<=", "g_psContrast", "[", "ulLoop", "]", ".", "ucThreshold", ")", "{", "CameraRegWrite", "(", "0xD4", ",", "g_psContrast", "[", "ulLoop", "]", ".", "ucRegD4Val", ")", ";", "CameraRegWrite", "(", "0xD3", ",", "g_psContrast", "[", "ulLoop", "]", ".", "ucRegD3Val", ")", ";", "break", ";", "}", "}", "ucVal", "=", "CameraRegRead", "(", "0xD2", ")", ";", "ucVal", "|=", "0x04", ";", "CameraRegWrite", "(", "0xD2", ",", "ucVal", ")", ";", "ucVal", "=", "CameraRegRead", "(", "0xDC", ")", ";", "if", "(", "ucContrast", "<", "CONTRAST_NORMAL", ")", "{", "ucVal", "|=", "0x04", ";", "}", "else", "{", "ucVal", "&=", "~", "0x04", ";", "}", "CameraRegWrite", "(", "0xDC", ",", "ucVal", ")", ";", "}" ]
Sets the contrast of the video image.
[ "Sets", "the", "contrast", "of", "the", "video", "image", "." ]
[ "//\r", "// Enable color adjustments.\r", "//\r", "//\r", "// Write the new contrast value. Register values for 0xD5 and 0xD2 are\r", "// the same for each setting but 0xD4 and 0xD3 vary.\r", "//\r", "//\r", "// Loop through the available contrast settings.\r", "//\r", "//\r", "// Does the supplied contrast fall into the current band?\r", "//\r", "//\r", "// Yes - write the registers to set the appropriate contrast.\r", "//\r", "//\r", "// Enable contrast adjustments.\r", "//\r", "//\r", "// Set the sense of the contrast adjustment, increase or decrease.\r", "//\r" ]
[ { "param": "ucContrast", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucContrast", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraFlipSet
void
void CameraFlipSet(tBoolean bFlip) { unsigned char ucVal; // // Get the existing register value, mask in the appropriately set flip // bit and write it back. // ucVal = CameraRegRead(0x0C); ucVal = bFlip ? (ucVal | 0x80) : (ucVal & ~0x80); CameraRegWrite(0x0C, ucVal); }
//***************************************************************************** // //! Sets the flip (vertical reflection) state of the video. //! //! \param bFlip is \b true if the incoming motion video is to be flipped in //! the vertical direction or \b false to leave the image oriented normally. //! //! \return None. // //*****************************************************************************
Sets the flip (vertical reflection) state of the video. \param bFlip is \b true if the incoming motion video is to be flipped in the vertical direction or \b false to leave the image oriented normally. \return None.
[ "Sets", "the", "flip", "(", "vertical", "reflection", ")", "state", "of", "the", "video", ".", "\\", "param", "bFlip", "is", "\\", "b", "true", "if", "the", "incoming", "motion", "video", "is", "to", "be", "flipped", "in", "the", "vertical", "direction", "or", "\\", "b", "false", "to", "leave", "the", "image", "oriented", "normally", ".", "\\", "return", "None", "." ]
void CameraFlipSet(tBoolean bFlip) { unsigned char ucVal; ucVal = CameraRegRead(0x0C); ucVal = bFlip ? (ucVal | 0x80) : (ucVal & ~0x80); CameraRegWrite(0x0C, ucVal); }
[ "void", "CameraFlipSet", "(", "tBoolean", "bFlip", ")", "{", "unsigned", "char", "ucVal", ";", "ucVal", "=", "CameraRegRead", "(", "0x0C", ")", ";", "ucVal", "=", "bFlip", "?", "(", "ucVal", "|", "0x80", ")", ":", "(", "ucVal", "&", "~", "0x80", ")", ";", "CameraRegWrite", "(", "0x0C", ",", "ucVal", ")", ";", "}" ]
Sets the flip (vertical reflection) state of the video.
[ "Sets", "the", "flip", "(", "vertical", "reflection", ")", "state", "of", "the", "video", "." ]
[ "//\r", "// Get the existing register value, mask in the appropriately set flip\r", "// bit and write it back.\r", "//\r" ]
[ { "param": "bFlip", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bFlip", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraMirrorSet
void
void CameraMirrorSet(tBoolean bMirror) { unsigned char ucVal; // // Get the existing register value, mask in the appropriately set mirror // bit and write it back. // ucVal = CameraRegRead(0x0C); ucVal = bMirror ? (ucVal | 0x40) : (ucVal & ~0x40); CameraRegWrite(0x0C, ucVal); }
//***************************************************************************** // //! Sets the mirror (horizontal reflection) state of the video. //! //! \param bMirror is \b true if the incoming motion video is to be mirrored in //! the horizontal direction or \b false to leave the image oriented normally. //! //! This function would typically be used for applications where a user is //! viewing their own video. Since people are more used to seeing a mirror //! image of themselves, this is often more comfortable than viewing the non- //! inverted image. //! //! \return None. // //*****************************************************************************
Sets the mirror (horizontal reflection) state of the video. \param bMirror is \b true if the incoming motion video is to be mirrored in the horizontal direction or \b false to leave the image oriented normally. This function would typically be used for applications where a user is viewing their own video. Since people are more used to seeing a mirror image of themselves, this is often more comfortable than viewing the non inverted image. \return None.
[ "Sets", "the", "mirror", "(", "horizontal", "reflection", ")", "state", "of", "the", "video", ".", "\\", "param", "bMirror", "is", "\\", "b", "true", "if", "the", "incoming", "motion", "video", "is", "to", "be", "mirrored", "in", "the", "horizontal", "direction", "or", "\\", "b", "false", "to", "leave", "the", "image", "oriented", "normally", ".", "This", "function", "would", "typically", "be", "used", "for", "applications", "where", "a", "user", "is", "viewing", "their", "own", "video", ".", "Since", "people", "are", "more", "used", "to", "seeing", "a", "mirror", "image", "of", "themselves", "this", "is", "often", "more", "comfortable", "than", "viewing", "the", "non", "inverted", "image", ".", "\\", "return", "None", "." ]
void CameraMirrorSet(tBoolean bMirror) { unsigned char ucVal; ucVal = CameraRegRead(0x0C); ucVal = bMirror ? (ucVal | 0x40) : (ucVal & ~0x40); CameraRegWrite(0x0C, ucVal); }
[ "void", "CameraMirrorSet", "(", "tBoolean", "bMirror", ")", "{", "unsigned", "char", "ucVal", ";", "ucVal", "=", "CameraRegRead", "(", "0x0C", ")", ";", "ucVal", "=", "bMirror", "?", "(", "ucVal", "|", "0x40", ")", ":", "(", "ucVal", "&", "~", "0x40", ")", ";", "CameraRegWrite", "(", "0x0C", ",", "ucVal", ")", ";", "}" ]
Sets the mirror (horizontal reflection) state of the video.
[ "Sets", "the", "mirror", "(", "horizontal", "reflection", ")", "state", "of", "the", "video", "." ]
[ "//\r", "// Get the existing register value, mask in the appropriately set mirror\r", "// bit and write it back.\r", "//\r" ]
[ { "param": "bMirror", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bMirror", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c339fb36c5758cbaf299d8e298c78c7e68eecd1e
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/drivers/camera.c
[ "BSD-3-Clause" ]
C
CameraImageDataGet
void
void CameraImageDataGet(tBoolean bCapBuffer, unsigned short usX, unsigned short usY, unsigned long ulNumPixels, tBoolean b24bit, unsigned short *pusBuffer) { unsigned long ulBase, ulWidth, ulStride; unsigned short usPixel; unsigned char *pucBuffer; // // Get the width of the video in the buffer. We assume the capture and // display images are the same dimensions. // ulWidth = (HWREGH(FPGA_SYSCTRL_REG) & FPGA_SYSCTRL_QVGA) ? 320 : 640; // // Which buffer are we to read from? // if(bCapBuffer) { // // Reading from the capture buffer. Retrieve the pointer and // dimensions from the capture registers. // ulBase = HWREG(FPGA_VML_REG); ulStride = (unsigned long)HWREGH(FPGA_VMS_REG); } else { // // Reading from the display buffer. Retrieve the pointer and // dimensions from the display registers. // ulBase = HWREG(FPGA_LVML_REG); ulStride = (unsigned long)HWREGH(FPGA_LVMS_REG); } // // Set up for the copy loops. // ulBase += (usY * ulStride); pucBuffer = (unsigned char *)pusBuffer; // // Read the required number of pixels. // while(ulNumPixels) { // // Get a pixel. // FPGAREADH((ulBase + (usX * 2)), usPixel); // // Write the pixel to the output. // if(b24bit) { *(unsigned char *)pucBuffer++ = BLUEFROM565(usPixel); *(unsigned char *)pucBuffer++ = GREENFROM565(usPixel); *(unsigned char *)pucBuffer++ = REDFROM565(usPixel); } else { *pusBuffer++ = usPixel; } // // Move to the next pixel // usX++; if(usX >= ulWidth) { usX = 0; ulBase += ulStride; } // // Decrement our pixel count. // ulNumPixels--; } }
//***************************************************************************** // //! Reads pixel data from a given position in the video image. //! //! \param bCapBuffer is \b true to read data from the image described by //! the current video capture buffer settings or \b false to read from the //! current video display buffer. //! \param usX is the X coordinate of the start of the data to be read. //! \param usY is the Y coordinate of the start of the data to be read. //! \param ulNumPixels is the number of pixels to be read. Pixels are read //! starting at \e usX, \e usY and progressing to the right then downwards. //! \param b24bit indicates whether to return raw (RGB565) data or extracted //! colors in RGB24 format. //! \param pusBuffer points to the buffer into which the pixel data should be //! copied. //! //! This function allows an application to read back a section of a captured //! image into a buffer in Stellaris internal SRAM. The data may be returned //! either in the native 16bpp format supported by the camera and LCD or in //! 24bpp RGB format. The 24bpp format returned places the blue component in //! the lowest memory location followed by the green component then the red //! component. //! //! \return None. // //*****************************************************************************
Reads pixel data from a given position in the video image. \param bCapBuffer is \b true to read data from the image described by the current video capture buffer settings or \b false to read from the current video display buffer. \param usX is the X coordinate of the start of the data to be read. \param usY is the Y coordinate of the start of the data to be read. \param ulNumPixels is the number of pixels to be read. Pixels are read starting at \e usX, \e usY and progressing to the right then downwards. \param b24bit indicates whether to return raw (RGB565) data or extracted colors in RGB24 format. \param pusBuffer points to the buffer into which the pixel data should be copied. This function allows an application to read back a section of a captured image into a buffer in Stellaris internal SRAM. The data may be returned either in the native 16bpp format supported by the camera and LCD or in 24bpp RGB format. The 24bpp format returned places the blue component in the lowest memory location followed by the green component then the red component. \return None.
[ "Reads", "pixel", "data", "from", "a", "given", "position", "in", "the", "video", "image", ".", "\\", "param", "bCapBuffer", "is", "\\", "b", "true", "to", "read", "data", "from", "the", "image", "described", "by", "the", "current", "video", "capture", "buffer", "settings", "or", "\\", "b", "false", "to", "read", "from", "the", "current", "video", "display", "buffer", ".", "\\", "param", "usX", "is", "the", "X", "coordinate", "of", "the", "start", "of", "the", "data", "to", "be", "read", ".", "\\", "param", "usY", "is", "the", "Y", "coordinate", "of", "the", "start", "of", "the", "data", "to", "be", "read", ".", "\\", "param", "ulNumPixels", "is", "the", "number", "of", "pixels", "to", "be", "read", ".", "Pixels", "are", "read", "starting", "at", "\\", "e", "usX", "\\", "e", "usY", "and", "progressing", "to", "the", "right", "then", "downwards", ".", "\\", "param", "b24bit", "indicates", "whether", "to", "return", "raw", "(", "RGB565", ")", "data", "or", "extracted", "colors", "in", "RGB24", "format", ".", "\\", "param", "pusBuffer", "points", "to", "the", "buffer", "into", "which", "the", "pixel", "data", "should", "be", "copied", ".", "This", "function", "allows", "an", "application", "to", "read", "back", "a", "section", "of", "a", "captured", "image", "into", "a", "buffer", "in", "Stellaris", "internal", "SRAM", ".", "The", "data", "may", "be", "returned", "either", "in", "the", "native", "16bpp", "format", "supported", "by", "the", "camera", "and", "LCD", "or", "in", "24bpp", "RGB", "format", ".", "The", "24bpp", "format", "returned", "places", "the", "blue", "component", "in", "the", "lowest", "memory", "location", "followed", "by", "the", "green", "component", "then", "the", "red", "component", ".", "\\", "return", "None", "." ]
void CameraImageDataGet(tBoolean bCapBuffer, unsigned short usX, unsigned short usY, unsigned long ulNumPixels, tBoolean b24bit, unsigned short *pusBuffer) { unsigned long ulBase, ulWidth, ulStride; unsigned short usPixel; unsigned char *pucBuffer; ulWidth = (HWREGH(FPGA_SYSCTRL_REG) & FPGA_SYSCTRL_QVGA) ? 320 : 640; if(bCapBuffer) { ulBase = HWREG(FPGA_VML_REG); ulStride = (unsigned long)HWREGH(FPGA_VMS_REG); } else { ulBase = HWREG(FPGA_LVML_REG); ulStride = (unsigned long)HWREGH(FPGA_LVMS_REG); } ulBase += (usY * ulStride); pucBuffer = (unsigned char *)pusBuffer; while(ulNumPixels) { FPGAREADH((ulBase + (usX * 2)), usPixel); if(b24bit) { *(unsigned char *)pucBuffer++ = BLUEFROM565(usPixel); *(unsigned char *)pucBuffer++ = GREENFROM565(usPixel); *(unsigned char *)pucBuffer++ = REDFROM565(usPixel); } else { *pusBuffer++ = usPixel; } usX++; if(usX >= ulWidth) { usX = 0; ulBase += ulStride; } ulNumPixels--; } }
[ "void", "CameraImageDataGet", "(", "tBoolean", "bCapBuffer", ",", "unsigned", "short", "usX", ",", "unsigned", "short", "usY", ",", "unsigned", "long", "ulNumPixels", ",", "tBoolean", "b24bit", ",", "unsigned", "short", "*", "pusBuffer", ")", "{", "unsigned", "long", "ulBase", ",", "ulWidth", ",", "ulStride", ";", "unsigned", "short", "usPixel", ";", "unsigned", "char", "*", "pucBuffer", ";", "ulWidth", "=", "(", "HWREGH", "(", "FPGA_SYSCTRL_REG", ")", "&", "FPGA_SYSCTRL_QVGA", ")", "?", "320", ":", "640", ";", "if", "(", "bCapBuffer", ")", "{", "ulBase", "=", "HWREG", "(", "FPGA_VML_REG", ")", ";", "ulStride", "=", "(", "unsigned", "long", ")", "HWREGH", "(", "FPGA_VMS_REG", ")", ";", "}", "else", "{", "ulBase", "=", "HWREG", "(", "FPGA_LVML_REG", ")", ";", "ulStride", "=", "(", "unsigned", "long", ")", "HWREGH", "(", "FPGA_LVMS_REG", ")", ";", "}", "ulBase", "+=", "(", "usY", "*", "ulStride", ")", ";", "pucBuffer", "=", "(", "unsigned", "char", "*", ")", "pusBuffer", ";", "while", "(", "ulNumPixels", ")", "{", "FPGAREADH", "(", "(", "ulBase", "+", "(", "usX", "*", "2", ")", ")", ",", "usPixel", ")", ";", "if", "(", "b24bit", ")", "{", "*", "(", "unsigned", "char", "*", ")", "pucBuffer", "++", "=", "BLUEFROM565", "(", "usPixel", ")", ";", "*", "(", "unsigned", "char", "*", ")", "pucBuffer", "++", "=", "GREENFROM565", "(", "usPixel", ")", ";", "*", "(", "unsigned", "char", "*", ")", "pucBuffer", "++", "=", "REDFROM565", "(", "usPixel", ")", ";", "}", "else", "{", "*", "pusBuffer", "++", "=", "usPixel", ";", "}", "usX", "++", ";", "if", "(", "usX", ">=", "ulWidth", ")", "{", "usX", "=", "0", ";", "ulBase", "+=", "ulStride", ";", "}", "ulNumPixels", "--", ";", "}", "}" ]
Reads pixel data from a given position in the video image.
[ "Reads", "pixel", "data", "from", "a", "given", "position", "in", "the", "video", "image", "." ]
[ "//\r", "// Get the width of the video in the buffer. We assume the capture and\r", "// display images are the same dimensions.\r", "//\r", "//\r", "// Which buffer are we to read from?\r", "//\r", "//\r", "// Reading from the capture buffer. Retrieve the pointer and\r", "// dimensions from the capture registers.\r", "//\r", "//\r", "// Reading from the display buffer. Retrieve the pointer and\r", "// dimensions from the display registers.\r", "//\r", "//\r", "// Set up for the copy loops.\r", "//\r", "//\r", "// Read the required number of pixels.\r", "//\r", "//\r", "// Get a pixel.\r", "//\r", "//\r", "// Write the pixel to the output.\r", "//\r", "//\r", "// Move to the next pixel\r", "//\r", "//\r", "// Decrement our pixel count.\r", "//\r" ]
[ { "param": "bCapBuffer", "type": "tBoolean" }, { "param": "usX", "type": "unsigned short" }, { "param": "usY", "type": "unsigned short" }, { "param": "ulNumPixels", "type": "unsigned long" }, { "param": "b24bit", "type": "tBoolean" }, { "param": "pusBuffer", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bCapBuffer", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "usX", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "usY", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulNumPixels", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b24bit", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pusBuffer", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.c
[ "BSD-3-Clause" ]
C
TCPIPStackInit
null
unsigned long TCPIPStackInit(void) { unsigned long ulUser0, ulUser1; unsigned char pucMACAddr[6]; // // 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 for later display. // usnprintf(g_pcMACAddrString, SIZE_MAC_ADDR_BUFFER, "%02X-%02X-%02X-%02X-%02X-%02X", pucMACAddr[0], pucMACAddr[1], pucMACAddr[2], pucMACAddr[3], pucMACAddr[4], pucMACAddr[5]); // // 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 usb-host-keyboard"); // // 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) { unsigned long ulUser0, ulUser1; unsigned char pucMACAddr[6]; 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(g_pcMACAddrString, SIZE_MAC_ADDR_BUFFER, "%02X-%02X-%02X-%02X-%02X-%02X", pucMACAddr[0], pucMACAddr[1], pucMACAddr[2], pucMACAddr[3], pucMACAddr[4], pucMACAddr[5]); lwIPInit(pucMACAddr, 0, 0, 0, IPADDR_USE_DHCP); LocatorInit(); LocatorMACAddrSet(pucMACAddr); LocatorAppTitleSet("RDK-IDM-SBC usb-host-keyboard"); SoftwareUpdateInit(SoftwareUpdateRequestCallback); return(0); }
[ "unsigned", "long", "TCPIPStackInit", "(", "void", ")", "{", "unsigned", "long", "ulUser0", ",", "ulUser1", ";", "unsigned", "char", "pucMACAddr", "[", "6", "]", ";", "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", "(", "g_pcMACAddrString", ",", "SIZE_MAC_ADDR_BUFFER", ",", "\"", "\"", ",", "pucMACAddr", "[", "0", "]", ",", "pucMACAddr", "[", "1", "]", ",", "pucMACAddr", "[", "2", "]", ",", "pucMACAddr", "[", "3", "]", ",", "pucMACAddr", "[", "4", "]", ",", "pucMACAddr", "[", "5", "]", ")", ";", "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 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 for later display.\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": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.c
[ "BSD-3-Clause" ]
C
PrintChar
void
void PrintChar(const char ucChar) { tRectangle sRect; // // If both the line and column have gone to zero then clear the screen. // if((g_ulLine == 0) && (g_ulColumn == 0)) { // // Form the rectangle that makes up the text box. // sRect.sXMin = 0; sRect.sYMin = DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - DISPLAY_TEXT_BORDER; sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - DISPLAY_BANNER_HEIGHT - DISPLAY_TEXT_BORDER; // // Change the foreground color to black and draw black rectangle to // clear the screen. // GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_BG); GrRectFill(&g_sContext, &sRect); // // Reset the foreground color to the text color. // GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_FG); } // // Send the character to the UART. // UARTprintf("%c", ucChar); // // Allow new lines to cause the column to go back to zero. // if(ucChar != '\n') { // // Did we get a backspace character? // if(ucChar != ASCII_BACKSPACE) { // // This is not a backspace so print the character to the screen. // GrStringDraw(&g_sContext, &ucChar, 1, GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), 0); } else { // // We got a backspace. If we are at the top left of the screen, // return since we don't need to do anything. // if(g_ulColumn || g_ulLine) { // // Adjust the cursor position to erase the last character. // if(g_ulColumn) { g_ulColumn--; } else { g_ulColumn = g_ulCharsPerLine; g_ulLine--; } // // Print a space at this position then return without fixing up // the cursor again. // GrStringDraw(&g_sContext, " ", 1, GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), true); } return; } } else { // // This will allow the code below to properly handle the new line. // g_ulColumn = g_ulCharsPerLine; } // // Update the text row and column that the next character will use. // if(g_ulColumn < g_ulCharsPerLine) { // // No line wrap yet so move one column over. // g_ulColumn++; } else { // // Line wrapped so go back to the first column and update the line. // g_ulColumn = 0; g_ulLine++; // // The line has gone past the end so go back to the first line. // if(g_ulLine >= g_ulLinesPerScreen) { g_ulLine = 0; } } }
//***************************************************************************** // // This function prints the character out the UART and into the text area of // the screen. // // \param ucChar is the character to print out. // // This function handles all of the detail of printing a character to both the // UART and to the text area of the screen on the evaluation board. The text // area of the screen will be cleared any time the text goes beyond the end // of the text area. // // \return None. // //*****************************************************************************
This function prints the character out the UART and into the text area of the screen. \param ucChar is the character to print out. This function handles all of the detail of printing a character to both the UART and to the text area of the screen on the evaluation board. The text area of the screen will be cleared any time the text goes beyond the end of the text area. \return None.
[ "This", "function", "prints", "the", "character", "out", "the", "UART", "and", "into", "the", "text", "area", "of", "the", "screen", ".", "\\", "param", "ucChar", "is", "the", "character", "to", "print", "out", ".", "This", "function", "handles", "all", "of", "the", "detail", "of", "printing", "a", "character", "to", "both", "the", "UART", "and", "to", "the", "text", "area", "of", "the", "screen", "on", "the", "evaluation", "board", ".", "The", "text", "area", "of", "the", "screen", "will", "be", "cleared", "any", "time", "the", "text", "goes", "beyond", "the", "end", "of", "the", "text", "area", ".", "\\", "return", "None", "." ]
void PrintChar(const char ucChar) { tRectangle sRect; if((g_ulLine == 0) && (g_ulColumn == 0)) { sRect.sXMin = 0; sRect.sYMin = DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - DISPLAY_TEXT_BORDER; sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - DISPLAY_BANNER_HEIGHT - DISPLAY_TEXT_BORDER; GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_BG); GrRectFill(&g_sContext, &sRect); GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_FG); } UARTprintf("%c", ucChar); if(ucChar != '\n') { if(ucChar != ASCII_BACKSPACE) { GrStringDraw(&g_sContext, &ucChar, 1, GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), 0); } else { if(g_ulColumn || g_ulLine) { if(g_ulColumn) { g_ulColumn--; } else { g_ulColumn = g_ulCharsPerLine; g_ulLine--; } GrStringDraw(&g_sContext, " ", 1, GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), true); } return; } } else { g_ulColumn = g_ulCharsPerLine; } if(g_ulColumn < g_ulCharsPerLine) { g_ulColumn++; } else { g_ulColumn = 0; g_ulLine++; if(g_ulLine >= g_ulLinesPerScreen) { g_ulLine = 0; } } }
[ "void", "PrintChar", "(", "const", "char", "ucChar", ")", "{", "tRectangle", "sRect", ";", "if", "(", "(", "g_ulLine", "==", "0", ")", "&&", "(", "g_ulColumn", "==", "0", ")", ")", "{", "sRect", ".", "sXMin", "=", "0", ";", "sRect", ".", "sYMin", "=", "DISPLAY_BANNER_HEIGHT", "+", "DISPLAY_TEXT_BORDER", ";", "sRect", ".", "sXMax", "=", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "-", "DISPLAY_TEXT_BORDER", ";", "sRect", ".", "sYMax", "=", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "DISPLAY_BANNER_HEIGHT", "-", "DISPLAY_TEXT_BORDER", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "DISPLAY_TEXT_BG", ")", ";", "GrRectFill", "(", "&", "g_sContext", ",", "&", "sRect", ")", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "DISPLAY_TEXT_FG", ")", ";", "}", "UARTprintf", "(", "\"", "\"", ",", "ucChar", ")", ";", "if", "(", "ucChar", "!=", "'", "\\n", "'", ")", "{", "if", "(", "ucChar", "!=", "ASCII_BACKSPACE", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "&", "ucChar", ",", "1", ",", "GrFontMaxWidthGet", "(", "g_pFontFixed6x8", ")", "*", "g_ulColumn", ",", "DISPLAY_BANNER_HEIGHT", "+", "DISPLAY_TEXT_BORDER", "+", "(", "g_ulLine", "*", "GrFontHeightGet", "(", "g_pFontFixed6x8", ")", ")", ",", "0", ")", ";", "}", "else", "{", "if", "(", "g_ulColumn", "||", "g_ulLine", ")", "{", "if", "(", "g_ulColumn", ")", "{", "g_ulColumn", "--", ";", "}", "else", "{", "g_ulColumn", "=", "g_ulCharsPerLine", ";", "g_ulLine", "--", ";", "}", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "1", ",", "GrFontMaxWidthGet", "(", "g_pFontFixed6x8", ")", "*", "g_ulColumn", ",", "DISPLAY_BANNER_HEIGHT", "+", "DISPLAY_TEXT_BORDER", "+", "(", "g_ulLine", "*", "GrFontHeightGet", "(", "g_pFontFixed6x8", ")", ")", ",", "true", ")", ";", "}", "return", ";", "}", "}", "else", "{", "g_ulColumn", "=", "g_ulCharsPerLine", ";", "}", "if", "(", "g_ulColumn", "<", "g_ulCharsPerLine", ")", "{", "g_ulColumn", "++", ";", "}", "else", "{", "g_ulColumn", "=", "0", ";", "g_ulLine", "++", ";", "if", "(", "g_ulLine", ">=", "g_ulLinesPerScreen", ")", "{", "g_ulLine", "=", "0", ";", "}", "}", "}" ]
This function prints the character out the UART and into the text area of the screen.
[ "This", "function", "prints", "the", "character", "out", "the", "UART", "and", "into", "the", "text", "area", "of", "the", "screen", "." ]
[ "//\r", "// If both the line and column have gone to zero then clear the screen.\r", "//\r", "//\r", "// Form the rectangle that makes up the text box.\r", "//\r", "//\r", "// Change the foreground color to black and draw black rectangle to\r", "// clear the screen.\r", "//\r", "//\r", "// Reset the foreground color to the text color.\r", "//\r", "//\r", "// Send the character to the UART.\r", "//\r", "//\r", "// Allow new lines to cause the column to go back to zero.\r", "//\r", "//\r", "// Did we get a backspace character?\r", "//\r", "//\r", "// This is not a backspace so print the character to the screen.\r", "//\r", "//\r", "// We got a backspace. If we are at the top left of the screen,\r", "// return since we don't need to do anything.\r", "//\r", "//\r", "// Adjust the cursor position to erase the last character.\r", "//\r", "//\r", "// Print a space at this position then return without fixing up\r", "// the cursor again.\r", "//\r", "//\r", "// This will allow the code below to properly handle the new line.\r", "//\r", "//\r", "// Update the text row and column that the next character will use.\r", "//\r", "//\r", "// No line wrap yet so move one column over.\r", "//\r", "//\r", "// Line wrapped so go back to the first column and update the line.\r", "//\r", "//\r", "// The line has gone past the end so go back to the first line.\r", "//\r" ]
[ { "param": "ucChar", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucChar", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.c
[ "BSD-3-Clause" ]
C
UpdateStatus
void
void UpdateStatus(void) { tRectangle sRect; // // Fill the bottom rows of the screen with blue to create the status area. // sRect.sXMin = 0; sRect.sYMin = GrContextDpyHeightGet(&g_sContext) - DISPLAY_BANNER_HEIGHT - 1; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = sRect.sYMin + DISPLAY_BANNER_HEIGHT; GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_pFontFixed6x8); // // Update the status on the screen. // if(g_eUSBState == STATE_NO_DEVICE) { // // Keyboard is currently disconnected. // GrStringDraw(&g_sContext, "no device", -1, 4, sRect.sYMin + 8, 0); } else if(g_eUSBState == STATE_UNKNOWN_DEVICE) { // // Unknown device is currently connected. // GrStringDraw(&g_sContext, "unknown dev.", -1, 4, sRect.sYMin + 8, 0); } else if(g_eUSBState == STATE_POWER_FAULT) { // // Something caused a power fault. // GrStringDraw(&g_sContext, "power fault", -1, 4, sRect.sYMin + 8, 0); } else if((g_eUSBState == STATE_KEYBOARD_CONNECTED) || (g_eUSBState == STATE_KEYBOARD_UPDATE)) { // // Keyboard is connected. // GrStringDraw(&g_sContext, "connected", -1, 4, sRect.sYMin + 8, 0); // // Update the CAPS Lock status. // if(g_ulModifiers & HID_KEYB_CAPS_LOCK) { GrStringDraw(&g_sContext, "CAPS", 4, sRect.sXMax - 28, sRect.sYMin + 8, 0); } } // // Display the MAC and IP addresses. // GrStringDraw(&g_sContext, g_pcMACAddrString, -1, sRect.sXMin + 80, sRect.sYMin + 8, 0); GrStringDraw(&g_sContext, g_pcIPAddrString, -1, sRect.sXMin + 190, sRect.sYMin + 8, 0); }
//***************************************************************************** // // This function updates the status area of the screen. It uses the current // state of the application to print the status bar. // //*****************************************************************************
This function updates the status area of the screen. It uses the current state of the application to print the status bar.
[ "This", "function", "updates", "the", "status", "area", "of", "the", "screen", ".", "It", "uses", "the", "current", "state", "of", "the", "application", "to", "print", "the", "status", "bar", "." ]
void UpdateStatus(void) { tRectangle sRect; sRect.sXMin = 0; sRect.sYMin = GrContextDpyHeightGet(&g_sContext) - DISPLAY_BANNER_HEIGHT - 1; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = sRect.sYMin + DISPLAY_BANNER_HEIGHT; GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG); GrRectFill(&g_sContext, &sRect); GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); GrContextFontSet(&g_sContext, g_pFontFixed6x8); if(g_eUSBState == STATE_NO_DEVICE) { GrStringDraw(&g_sContext, "no device", -1, 4, sRect.sYMin + 8, 0); } else if(g_eUSBState == STATE_UNKNOWN_DEVICE) { GrStringDraw(&g_sContext, "unknown dev.", -1, 4, sRect.sYMin + 8, 0); } else if(g_eUSBState == STATE_POWER_FAULT) { GrStringDraw(&g_sContext, "power fault", -1, 4, sRect.sYMin + 8, 0); } else if((g_eUSBState == STATE_KEYBOARD_CONNECTED) || (g_eUSBState == STATE_KEYBOARD_UPDATE)) { GrStringDraw(&g_sContext, "connected", -1, 4, sRect.sYMin + 8, 0); if(g_ulModifiers & HID_KEYB_CAPS_LOCK) { GrStringDraw(&g_sContext, "CAPS", 4, sRect.sXMax - 28, sRect.sYMin + 8, 0); } } GrStringDraw(&g_sContext, g_pcMACAddrString, -1, sRect.sXMin + 80, sRect.sYMin + 8, 0); GrStringDraw(&g_sContext, g_pcIPAddrString, -1, sRect.sXMin + 190, sRect.sYMin + 8, 0); }
[ "void", "UpdateStatus", "(", "void", ")", "{", "tRectangle", "sRect", ";", "sRect", ".", "sXMin", "=", "0", ";", "sRect", ".", "sYMin", "=", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "DISPLAY_BANNER_HEIGHT", "-", "1", ";", "sRect", ".", "sXMax", "=", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "-", "1", ";", "sRect", ".", "sYMax", "=", "sRect", ".", "sYMin", "+", "DISPLAY_BANNER_HEIGHT", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "DISPLAY_BANNER_BG", ")", ";", "GrRectFill", "(", "&", "g_sContext", ",", "&", "sRect", ")", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "ClrWhite", ")", ";", "GrRectDraw", "(", "&", "g_sContext", ",", "&", "sRect", ")", ";", "GrContextFontSet", "(", "&", "g_sContext", ",", "g_pFontFixed6x8", ")", ";", "if", "(", "g_eUSBState", "==", "STATE_NO_DEVICE", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "-1", ",", "4", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "}", "else", "if", "(", "g_eUSBState", "==", "STATE_UNKNOWN_DEVICE", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "-1", ",", "4", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "}", "else", "if", "(", "g_eUSBState", "==", "STATE_POWER_FAULT", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "-1", ",", "4", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "}", "else", "if", "(", "(", "g_eUSBState", "==", "STATE_KEYBOARD_CONNECTED", ")", "||", "(", "g_eUSBState", "==", "STATE_KEYBOARD_UPDATE", ")", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "-1", ",", "4", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "if", "(", "g_ulModifiers", "&", "HID_KEYB_CAPS_LOCK", ")", "{", "GrStringDraw", "(", "&", "g_sContext", ",", "\"", "\"", ",", "4", ",", "sRect", ".", "sXMax", "-", "28", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "}", "}", "GrStringDraw", "(", "&", "g_sContext", ",", "g_pcMACAddrString", ",", "-1", ",", "sRect", ".", "sXMin", "+", "80", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "GrStringDraw", "(", "&", "g_sContext", ",", "g_pcIPAddrString", ",", "-1", ",", "sRect", ".", "sXMin", "+", "190", ",", "sRect", ".", "sYMin", "+", "8", ",", "0", ")", ";", "}" ]
This function updates the status area of the screen.
[ "This", "function", "updates", "the", "status", "area", "of", "the", "screen", "." ]
[ "//\r", "// Fill the bottom rows of the screen with blue to create the status area.\r", "//\r", "//\r", "// Put a white box around the banner.\r", "//\r", "//\r", "// Put the application name in the middle of the banner.\r", "//\r", "//\r", "// Update the status on the screen.\r", "//\r", "//\r", "// Keyboard is currently disconnected.\r", "//\r", "//\r", "// Unknown device is currently connected.\r", "//\r", "//\r", "// Something caused a power fault.\r", "//\r", "//\r", "// Keyboard is connected.\r", "//\r", "//\r", "// Update the CAPS Lock status.\r", "//\r", "//\r", "// Display the MAC and IP addresses.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.c
[ "BSD-3-Clause" ]
C
IPAddressChangeCheck
null
unsigned long IPAddressChangeCheck(unsigned long ulCurrentIP) { unsigned long ulIPAddr; // // 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(g_pcIPAddrString, "%d.%d.%d.%d", ulIPAddr & 0xff, (ulIPAddr >> 8) & 0xff, (ulIPAddr >> 16) & 0xff, ulIPAddr >> 24); UpdateStatus(); } // // 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; ulIPAddr = lwIPLocalIPAddrGet(); if(ulIPAddr != ulCurrentIP) { usprintf(g_pcIPAddrString, "%d.%d.%d.%d", ulIPAddr & 0xff, (ulIPAddr >> 8) & 0xff, (ulIPAddr >> 16) & 0xff, ulIPAddr >> 24); UpdateStatus(); } return(ulIPAddr); }
[ "unsigned", "long", "IPAddressChangeCheck", "(", "unsigned", "long", "ulCurrentIP", ")", "{", "unsigned", "long", "ulIPAddr", ";", "ulIPAddr", "=", "lwIPLocalIPAddrGet", "(", ")", ";", "if", "(", "ulIPAddr", "!=", "ulCurrentIP", ")", "{", "usprintf", "(", "g_pcIPAddrString", ",", "\"", "\"", ",", "ulIPAddr", "&", "0xff", ",", "(", "ulIPAddr", ">>", "8", ")", "&", "0xff", ",", "(", "ulIPAddr", ">>", "16", ")", "&", "0xff", ",", "ulIPAddr", ">>", "24", ")", ";", "UpdateStatus", "(", ")", ";", "}", "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": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.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) { // // New keyboard detected. // case USB_EVENT_CONNECTED: { // // See if this is a HID Keyboard. // if((USBHCDDevClass(pEventInfo->ulInstance, 0) == USB_CLASS_HID) && (USBHCDDevProtocol(pEventInfo->ulInstance, 0) == USB_HID_PROTOCOL_KEYB)) { // // Indicate that the keyboard has been detected. // UARTprintf("Keyboard Connected\n"); // // Proceed to the STATE_KEYBOARD_INIT state so that the main // loop can finish initialized the mouse since // USBHKeyboardInit() cannot be called from within a callback. // g_eUSBState = STATE_KEYBOARD_INIT; } break; } // // Unsupported device detected. // case USB_EVENT_UNKNOWN_CONNECTED: { UARTprintf("Unsupported Device Connected\n"); // // An unknown device was detected. // g_eUSBState = STATE_UNKNOWN_DEVICE; UpdateStatus(); break; } // // Keyboard has been unplugged. // case USB_EVENT_DISCONNECTED: { UARTprintf("Device Disconnected\n"); // // Unknown device has been removed. // g_eUSBState = STATE_NO_DEVICE; UpdateStatus(); break; } // // Power Fault has occurred. // case USB_EVENT_POWER_FAULT: { UARTprintf("Power Fault\n"); // // No power means no device is present. // g_eUSBState = STATE_POWER_FAULT; UpdateStatus(); 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 keyboard 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 keyboard 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", "keyboard", "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_CONNECTED: { if((USBHCDDevClass(pEventInfo->ulInstance, 0) == USB_CLASS_HID) && (USBHCDDevProtocol(pEventInfo->ulInstance, 0) == USB_HID_PROTOCOL_KEYB)) { UARTprintf("Keyboard Connected\n"); g_eUSBState = STATE_KEYBOARD_INIT; } break; } case USB_EVENT_UNKNOWN_CONNECTED: { UARTprintf("Unsupported Device Connected\n"); g_eUSBState = STATE_UNKNOWN_DEVICE; UpdateStatus(); break; } case USB_EVENT_DISCONNECTED: { UARTprintf("Device Disconnected\n"); g_eUSBState = STATE_NO_DEVICE; UpdateStatus(); break; } case USB_EVENT_POWER_FAULT: { UARTprintf("Power Fault\n"); g_eUSBState = STATE_POWER_FAULT; UpdateStatus(); break; } default: { break; } } }
[ "void", "USBHCDEvents", "(", "void", "*", "pvData", ")", "{", "tEventInfo", "*", "pEventInfo", ";", "pEventInfo", "=", "(", "tEventInfo", "*", ")", "pvData", ";", "switch", "(", "pEventInfo", "->", "ulEvent", ")", "{", "case", "USB_EVENT_CONNECTED", ":", "{", "if", "(", "(", "USBHCDDevClass", "(", "pEventInfo", "->", "ulInstance", ",", "0", ")", "==", "USB_CLASS_HID", ")", "&&", "(", "USBHCDDevProtocol", "(", "pEventInfo", "->", "ulInstance", ",", "0", ")", "==", "USB_HID_PROTOCOL_KEYB", ")", ")", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "g_eUSBState", "=", "STATE_KEYBOARD_INIT", ";", "}", "break", ";", "}", "case", "USB_EVENT_UNKNOWN_CONNECTED", ":", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "g_eUSBState", "=", "STATE_UNKNOWN_DEVICE", ";", "UpdateStatus", "(", ")", ";", "break", ";", "}", "case", "USB_EVENT_DISCONNECTED", ":", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "g_eUSBState", "=", "STATE_NO_DEVICE", ";", "UpdateStatus", "(", ")", ";", "break", ";", "}", "case", "USB_EVENT_POWER_FAULT", ":", "{", "UARTprintf", "(", "\"", "\\n", "\"", ")", ";", "g_eUSBState", "=", "STATE_POWER_FAULT", ";", "UpdateStatus", "(", ")", ";", "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", "// New keyboard detected.\r", "//\r", "//\r", "// See if this is a HID Keyboard.\r", "//\r", "//\r", "// Indicate that the keyboard has been detected.\r", "//\r", "//\r", "// Proceed to the STATE_KEYBOARD_INIT state so that the main\r", "// loop can finish initialized the mouse since\r", "// USBHKeyboardInit() cannot be called from within a callback.\r", "//\r", "//\r", "// Unsupported device detected.\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", "// Power Fault has occurred.\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": [] }
71d6f72f02cad654ab4e80cc65b4071695bc08d0
junyanl-code/Luminary-Micro-Library
boards/rdk-idm-sbc/usb_host_keyboard/usb_host_keyboard.c
[ "BSD-3-Clause" ]
C
KeyboardCallback
null
unsigned long KeyboardCallback(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam, void *pvMsgData) { unsigned char ucChar; switch(ulEvent) { // // New Key press detected. // case USBH_EVENT_HID_KB_PRESS: { // // If this was a Caps Lock key then update the Caps Lock state. // if(ulMsgParam == HID_KEYB_USAGE_CAPSLOCK) { // // The main loop needs to update the keyboard's Caps Lock // state. // g_eUSBState = STATE_KEYBOARD_UPDATE; // // Toggle the current Caps Lock state. // g_ulModifiers ^= HID_KEYB_CAPS_LOCK; // // Update the screen based on the Caps Lock status. // UpdateStatus(); } else if(ulMsgParam == HID_KEYB_USAGE_SCROLLOCK) { // // The main loop needs to update the keyboard's Scroll Lock // state. // g_eUSBState = STATE_KEYBOARD_UPDATE; // // Toggle the current Scroll Lock state. // g_ulModifiers ^= HID_KEYB_SCROLL_LOCK; } else if(ulMsgParam == HID_KEYB_USAGE_NUMLOCK) { // // The main loop needs to update the keyboard's Scroll Lock // state. // g_eUSBState = STATE_KEYBOARD_UPDATE; // // Toggle the current Num Lock state. // g_ulModifiers ^= HID_KEYB_NUM_LOCK; } else { // // Was this the backspace key? // if((unsigned char)ulMsgParam == HID_KEYB_USAGE_BACKSPACE) { // // Yes - set the ASCII code for a backspace key. This is // not returned by USBHKeyboardUsageToChar since this only // returns printable characters. // ucChar = ASCII_BACKSPACE; } else { // // This is not backspace so try to map the usage code to a // printable ASCII character. // ucChar = (unsigned char) USBHKeyboardUsageToChar(g_ulKeyboardInstance, &g_sUSKeyboardMap, (unsigned char)ulMsgParam); } // // A zero value indicates there was no textual mapping of this // usage code. // if(ucChar != 0) { PrintChar(ucChar); } } break; } case USBH_EVENT_HID_KB_MOD: { // // This application ignores the state of the shift or control // and other special keys. // break; } case USBH_EVENT_HID_KB_REL: { // // This applications ignores the release of keys as well. // break; } } return(0); }
//***************************************************************************** // // This is the callback from the USB HID keyboard handler. // // \param pvCBData is ignored by this function. // \param ulEvent is one of the valid events for a keyboard device. // \param ulMsgParam is defined by the event that occurs. // \param pvMsgData is a pointer to data that is defined by the event that // occurs. // // This function will be called to inform the application when a keyboard has // been plugged in or removed and any time a key is pressed or released. // // \return This function will return 0. // //*****************************************************************************
This is the callback from the USB HID keyboard handler. \param pvCBData is ignored by this function. \param ulEvent is one of the valid events for a keyboard device. \param ulMsgParam is defined by the event that occurs. \param pvMsgData is a pointer to data that is defined by the event that occurs. This function will be called to inform the application when a keyboard has been plugged in or removed and any time a key is pressed or released. \return This function will return 0.
[ "This", "is", "the", "callback", "from", "the", "USB", "HID", "keyboard", "handler", ".", "\\", "param", "pvCBData", "is", "ignored", "by", "this", "function", ".", "\\", "param", "ulEvent", "is", "one", "of", "the", "valid", "events", "for", "a", "keyboard", "device", ".", "\\", "param", "ulMsgParam", "is", "defined", "by", "the", "event", "that", "occurs", ".", "\\", "param", "pvMsgData", "is", "a", "pointer", "to", "data", "that", "is", "defined", "by", "the", "event", "that", "occurs", ".", "This", "function", "will", "be", "called", "to", "inform", "the", "application", "when", "a", "keyboard", "has", "been", "plugged", "in", "or", "removed", "and", "any", "time", "a", "key", "is", "pressed", "or", "released", ".", "\\", "return", "This", "function", "will", "return", "0", "." ]
unsigned long KeyboardCallback(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam, void *pvMsgData) { unsigned char ucChar; switch(ulEvent) { case USBH_EVENT_HID_KB_PRESS: { if(ulMsgParam == HID_KEYB_USAGE_CAPSLOCK) { g_eUSBState = STATE_KEYBOARD_UPDATE; g_ulModifiers ^= HID_KEYB_CAPS_LOCK; UpdateStatus(); } else if(ulMsgParam == HID_KEYB_USAGE_SCROLLOCK) { g_eUSBState = STATE_KEYBOARD_UPDATE; g_ulModifiers ^= HID_KEYB_SCROLL_LOCK; } else if(ulMsgParam == HID_KEYB_USAGE_NUMLOCK) { g_eUSBState = STATE_KEYBOARD_UPDATE; g_ulModifiers ^= HID_KEYB_NUM_LOCK; } else { if((unsigned char)ulMsgParam == HID_KEYB_USAGE_BACKSPACE) { ucChar = ASCII_BACKSPACE; } else { ucChar = (unsigned char) USBHKeyboardUsageToChar(g_ulKeyboardInstance, &g_sUSKeyboardMap, (unsigned char)ulMsgParam); } if(ucChar != 0) { PrintChar(ucChar); } } break; } case USBH_EVENT_HID_KB_MOD: { break; } case USBH_EVENT_HID_KB_REL: { break; } } return(0); }
[ "unsigned", "long", "KeyboardCallback", "(", "void", "*", "pvCBData", ",", "unsigned", "long", "ulEvent", ",", "unsigned", "long", "ulMsgParam", ",", "void", "*", "pvMsgData", ")", "{", "unsigned", "char", "ucChar", ";", "switch", "(", "ulEvent", ")", "{", "case", "USBH_EVENT_HID_KB_PRESS", ":", "{", "if", "(", "ulMsgParam", "==", "HID_KEYB_USAGE_CAPSLOCK", ")", "{", "g_eUSBState", "=", "STATE_KEYBOARD_UPDATE", ";", "g_ulModifiers", "^=", "HID_KEYB_CAPS_LOCK", ";", "UpdateStatus", "(", ")", ";", "}", "else", "if", "(", "ulMsgParam", "==", "HID_KEYB_USAGE_SCROLLOCK", ")", "{", "g_eUSBState", "=", "STATE_KEYBOARD_UPDATE", ";", "g_ulModifiers", "^=", "HID_KEYB_SCROLL_LOCK", ";", "}", "else", "if", "(", "ulMsgParam", "==", "HID_KEYB_USAGE_NUMLOCK", ")", "{", "g_eUSBState", "=", "STATE_KEYBOARD_UPDATE", ";", "g_ulModifiers", "^=", "HID_KEYB_NUM_LOCK", ";", "}", "else", "{", "if", "(", "(", "unsigned", "char", ")", "ulMsgParam", "==", "HID_KEYB_USAGE_BACKSPACE", ")", "{", "ucChar", "=", "ASCII_BACKSPACE", ";", "}", "else", "{", "ucChar", "=", "(", "unsigned", "char", ")", "USBHKeyboardUsageToChar", "(", "g_ulKeyboardInstance", ",", "&", "g_sUSKeyboardMap", ",", "(", "unsigned", "char", ")", "ulMsgParam", ")", ";", "}", "if", "(", "ucChar", "!=", "0", ")", "{", "PrintChar", "(", "ucChar", ")", ";", "}", "}", "break", ";", "}", "case", "USBH_EVENT_HID_KB_MOD", ":", "{", "break", ";", "}", "case", "USBH_EVENT_HID_KB_REL", ":", "{", "break", ";", "}", "}", "return", "(", "0", ")", ";", "}" ]
This is the callback from the USB HID keyboard handler.
[ "This", "is", "the", "callback", "from", "the", "USB", "HID", "keyboard", "handler", "." ]
[ "//\r", "// New Key press detected.\r", "//\r", "//\r", "// If this was a Caps Lock key then update the Caps Lock state.\r", "//\r", "//\r", "// The main loop needs to update the keyboard's Caps Lock\r", "// state.\r", "//\r", "//\r", "// Toggle the current Caps Lock state.\r", "//\r", "//\r", "// Update the screen based on the Caps Lock status.\r", "//\r", "//\r", "// The main loop needs to update the keyboard's Scroll Lock\r", "// state.\r", "//\r", "//\r", "// Toggle the current Scroll Lock state.\r", "//\r", "//\r", "// The main loop needs to update the keyboard's Scroll Lock\r", "// state.\r", "//\r", "//\r", "// Toggle the current Num Lock state.\r", "//\r", "//\r", "// Was this the backspace key?\r", "//\r", "//\r", "// Yes - set the ASCII code for a backspace key. This is\r", "// not returned by USBHKeyboardUsageToChar since this only\r", "// returns printable characters.\r", "//\r", "//\r", "// This is not backspace so try to map the usage code to a\r", "// printable ASCII character.\r", "//\r", "//\r", "// A zero value indicates there was no textual mapping of this\r", "// usage code.\r", "//\r", "//\r", "// This application ignores the state of the shift or control\r", "// and other special keys.\r", "//\r", "//\r", "// This applications ignores the release of keys as well.\r", "//\r" ]
[ { "param": "pvCBData", "type": "void" }, { "param": "ulEvent", "type": "unsigned long" }, { "param": "ulMsgParam", "type": "unsigned long" }, { "param": "pvMsgData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvCBData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulEvent", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulMsgParam", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvMsgData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c7d6236e7116de440076e7e15742c02b923d2305
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/safertos_demo.c
[ "BSD-3-Clause" ]
C
SafeRTOSErrorHook
void
static void SafeRTOSErrorHook(xTaskHandle xHandleOfTaskWithError, signed portCHAR *pcNameOfTaskWithError, portBASE_TYPE xErrorCode) { tContext sContext; // // A fatal SafeRTOS error was detected, so display an error message. // GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119); GrContextForegroundSet(&sContext, ClrRed); GrContextBackgroundSet(&sContext, ClrBlack); GrContextFontSet(&sContext, g_pFontCm20); GrStringDrawCentered(&sContext, "Fatal SafeRTOS error!", -1, GrContextDpyWidthGet(&sContext) / 2, (((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24), 1); // // This function can not return, so loop forever. Interrupts are disabled // on entry to this function, so no processor interrupts will interrupt // this loop. // while(1) { } }
//***************************************************************************** // // This hook is called by SafeRTOS when an error is detected. // //*****************************************************************************
This hook is called by SafeRTOS when an error is detected.
[ "This", "hook", "is", "called", "by", "SafeRTOS", "when", "an", "error", "is", "detected", "." ]
static void SafeRTOSErrorHook(xTaskHandle xHandleOfTaskWithError, signed portCHAR *pcNameOfTaskWithError, portBASE_TYPE xErrorCode) { tContext sContext; GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119); GrContextForegroundSet(&sContext, ClrRed); GrContextBackgroundSet(&sContext, ClrBlack); GrContextFontSet(&sContext, g_pFontCm20); GrStringDrawCentered(&sContext, "Fatal SafeRTOS error!", -1, GrContextDpyWidthGet(&sContext) / 2, (((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24), 1); while(1) { } }
[ "static", "void", "SafeRTOSErrorHook", "(", "xTaskHandle", "xHandleOfTaskWithError", ",", "signed", "portCHAR", "*", "pcNameOfTaskWithError", ",", "portBASE_TYPE", "xErrorCode", ")", "{", "tContext", "sContext", ";", "GrContextInit", "(", "&", "sContext", ",", "&", "g_sKitronix320x240x16_SSD2119", ")", ";", "GrContextForegroundSet", "(", "&", "sContext", ",", "ClrRed", ")", ";", "GrContextBackgroundSet", "(", "&", "sContext", ",", "ClrBlack", ")", ";", "GrContextFontSet", "(", "&", "sContext", ",", "g_pFontCm20", ")", ";", "GrStringDrawCentered", "(", "&", "sContext", ",", "\"", "\"", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "sContext", ")", "/", "2", ",", "(", "(", "(", "GrContextDpyHeightGet", "(", "&", "sContext", ")", "-", "24", ")", "/", "2", ")", "+", "24", ")", ",", "1", ")", ";", "while", "(", "1", ")", "{", "}", "}" ]
This hook is called by SafeRTOS when an error is detected.
[ "This", "hook", "is", "called", "by", "SafeRTOS", "when", "an", "error", "is", "detected", "." ]
[ "//\r", "// A fatal SafeRTOS error was detected, so display an error message.\r", "//\r", "//\r", "// This function can not return, so loop forever. Interrupts are disabled\r", "// on entry to this function, so no processor interrupts will interrupt\r", "// this loop.\r", "//\r" ]
[ { "param": "xHandleOfTaskWithError", "type": "xTaskHandle" }, { "param": "pcNameOfTaskWithError", "type": "signed portCHAR" }, { "param": "xErrorCode", "type": "portBASE_TYPE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "xHandleOfTaskWithError", "type": "xTaskHandle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pcNameOfTaskWithError", "type": "signed portCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xErrorCode", "type": "portBASE_TYPE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
UIButtonPress
void
void UIButtonPress(void) { // // See if the motor drive is running. // if(MainIsRunning()) { // // Stop the motor drive. // MainStop(); } else { // // Start the motor drive. // MainRun(); } }
//***************************************************************************** // // Handles button presses. // // This function is called when a press of the on-board push button has been // detected. If the motor drive is running, it will be stopped. If it is // stopped, the direction will be reversed and the motor drive will be // started. // // \return None. // //*****************************************************************************
Handles button presses. This function is called when a press of the on-board push button has been detected. If the motor drive is running, it will be stopped. If it is stopped, the direction will be reversed and the motor drive will be started. \return None.
[ "Handles", "button", "presses", ".", "This", "function", "is", "called", "when", "a", "press", "of", "the", "on", "-", "board", "push", "button", "has", "been", "detected", ".", "If", "the", "motor", "drive", "is", "running", "it", "will", "be", "stopped", ".", "If", "it", "is", "stopped", "the", "direction", "will", "be", "reversed", "and", "the", "motor", "drive", "will", "be", "started", ".", "\\", "return", "None", "." ]
void UIButtonPress(void) { if(MainIsRunning()) { MainStop(); } else { MainRun(); } }
[ "void", "UIButtonPress", "(", "void", ")", "{", "if", "(", "MainIsRunning", "(", ")", ")", "{", "MainStop", "(", ")", ";", "}", "else", "{", "MainRun", "(", ")", ";", "}", "}" ]
Handles button presses.
[ "Handles", "button", "presses", "." ]
[ "//\r", "// See if the motor drive is running.\r", "//\r", "//\r", "// Stop the motor drive.\r", "//\r", "//\r", "// Start the motor drive.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
UIButtonHold
void
static void UIButtonHold(void) { // // Toggle the modulation type. UIModulationType() will take care of // forcing sine wave modulation for single phase motors. // //g_ucModulation ^= 1; //UIModulationType(); }
//***************************************************************************** // // Handles button holds. // // This function is called when a hold of the on-board push button has been // detected. The modulation type of the motor will be toggled between sine // wave and space vector modulation, but only if a three phase motor is in // use. // // \return None. // //*****************************************************************************
Handles button holds. This function is called when a hold of the on-board push button has been detected. The modulation type of the motor will be toggled between sine wave and space vector modulation, but only if a three phase motor is in use. \return None.
[ "Handles", "button", "holds", ".", "This", "function", "is", "called", "when", "a", "hold", "of", "the", "on", "-", "board", "push", "button", "has", "been", "detected", ".", "The", "modulation", "type", "of", "the", "motor", "will", "be", "toggled", "between", "sine", "wave", "and", "space", "vector", "modulation", "but", "only", "if", "a", "three", "phase", "motor", "is", "in", "use", ".", "\\", "return", "None", "." ]
static void UIButtonHold(void) { }
[ "static", "void", "UIButtonHold", "(", "void", ")", "{", "}" ]
Handles button holds.
[ "Handles", "button", "holds", "." ]
[ "//\r", "// Toggle the modulation type. UIModulationType() will take care of\r", "// forcing sine wave modulation for single phase motors.\r", "//\r", "//g_ucModulation ^= 1;\r", "//UIModulationType();\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
UIGetTicks
null
unsigned long UIGetTicks(void) { unsigned long ulTime1; unsigned long ulTime2; unsigned long ulTicks; // // We read the SysTick value twice, sandwiching taking the snapshot of // the tick count value. If the second SysTick read gives us a higher // number than the first read, we know that it wrapped somewhere between // the two reads so our tick count value is suspect. If this occurs, // we go round again. Note that it is not sufficient merely to read the // values with interrupts disabled since the SysTick counter keeps // counting regardless of whether or not the wrap interrupt has been // serviced. // do { ulTime1 = TimerValueGet(TIMER1_BASE, TIMER_A); ulTicks = g_ulUITickCount; ulTime2 = TimerValueGet(TIMER1_BASE, TIMER_A); } while(ulTime2 > ulTime1); // // Calculate the number of ticks // ulTime1 = ulTicks + (SYSTEM_CLOCK / TIMER1A_INT_RATE) - ulTime2; // // Return the value. // return(ulTime1); }
//***************************************************************************** // // This function returns the current number of system ticks. // // \return The number of system timer ticks. // //*****************************************************************************
This function returns the current number of system ticks. \return The number of system timer ticks.
[ "This", "function", "returns", "the", "current", "number", "of", "system", "ticks", ".", "\\", "return", "The", "number", "of", "system", "timer", "ticks", "." ]
unsigned long UIGetTicks(void) { unsigned long ulTime1; unsigned long ulTime2; unsigned long ulTicks; do { ulTime1 = TimerValueGet(TIMER1_BASE, TIMER_A); ulTicks = g_ulUITickCount; ulTime2 = TimerValueGet(TIMER1_BASE, TIMER_A); } while(ulTime2 > ulTime1); ulTime1 = ulTicks + (SYSTEM_CLOCK / TIMER1A_INT_RATE) - ulTime2; return(ulTime1); }
[ "unsigned", "long", "UIGetTicks", "(", "void", ")", "{", "unsigned", "long", "ulTime1", ";", "unsigned", "long", "ulTime2", ";", "unsigned", "long", "ulTicks", ";", "do", "{", "ulTime1", "=", "TimerValueGet", "(", "TIMER1_BASE", ",", "TIMER_A", ")", ";", "ulTicks", "=", "g_ulUITickCount", ";", "ulTime2", "=", "TimerValueGet", "(", "TIMER1_BASE", ",", "TIMER_A", ")", ";", "}", "while", "(", "ulTime2", ">", "ulTime1", ")", ";", "ulTime1", "=", "ulTicks", "+", "(", "SYSTEM_CLOCK", "/", "TIMER1A_INT_RATE", ")", "-", "ulTime2", ";", "return", "(", "ulTime1", ")", ";", "}" ]
This function returns the current number of system ticks.
[ "This", "function", "returns", "the", "current", "number", "of", "system", "ticks", "." ]
[ "//\r", "// We read the SysTick value twice, sandwiching taking the snapshot of\r", "// the tick count value. If the second SysTick read gives us a higher\r", "// number than the first read, we know that it wrapped somewhere between\r", "// the two reads so our tick count value is suspect. If this occurs,\r", "// we go round again. Note that it is not sufficient merely to read the\r", "// values with interrupts disabled since the SysTick counter keeps\r", "// counting regardless of whether or not the wrap interrupt has been\r", "// serviced.\r", "//\r", "//\r", "// Calculate the number of ticks\r", "//\r", "//\r", "// Return the value.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
Timer1AIntHandler
void
void Timer1AIntHandler(void) { // // Clear the Timer interrupt. // TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); // // Increment the running count of timer ticks, based on the Timer1A Tick // interrupt rate. // g_ulUITickCount += (SYSTEM_CLOCK / TIMER1A_INT_RATE); }
//***************************************************************************** // // Handles the Timer1A interrupt. // // This function is called when Timer1A asserts its interrupt. It is // responsible for keeping track of system time. This should be the highest // priority interrupt. // // \return None. // //*****************************************************************************
Handles the Timer1A interrupt. This function is called when Timer1A asserts its interrupt. It is responsible for keeping track of system time. This should be the highest priority interrupt. \return None.
[ "Handles", "the", "Timer1A", "interrupt", ".", "This", "function", "is", "called", "when", "Timer1A", "asserts", "its", "interrupt", ".", "It", "is", "responsible", "for", "keeping", "track", "of", "system", "time", ".", "This", "should", "be", "the", "highest", "priority", "interrupt", ".", "\\", "return", "None", "." ]
void Timer1AIntHandler(void) { TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); g_ulUITickCount += (SYSTEM_CLOCK / TIMER1A_INT_RATE); }
[ "void", "Timer1AIntHandler", "(", "void", ")", "{", "TimerIntClear", "(", "TIMER1_BASE", ",", "TIMER_TIMA_TIMEOUT", ")", ";", "g_ulUITickCount", "+=", "(", "SYSTEM_CLOCK", "/", "TIMER1A_INT_RATE", ")", ";", "}" ]
Handles the Timer1A interrupt.
[ "Handles", "the", "Timer1A", "interrupt", "." ]
[ "//\r", "// Clear the Timer interrupt.\r", "//\r", "//\r", "// Increment the running count of timer ticks, based on the Timer1A Tick\r", "// interrupt rate.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
SysTickIntHandler
void
void SysTickIntHandler(void) { unsigned long ulIdx, ulCount; // // Run the Hall module tick handler. // HallTickHandler(); // // Run the ADC module tick handler. // ADCTickHandler(); // // Convert the ADC Analog Input reading to milli-volts. Each volt at the // ADC input corresponds to ~1.714 volts at the Analog Input. // ulCount = ADCReadAnalog(); g_usAnalogInputVoltage = (((g_usAnalogInputVoltage * 3) + (((ulCount * 3000 * 240) / 140) / 1024)) / 4); // // Read the on-board switch and pass its current value to the switch // debouncer, only if the onboard user interface is enabled. // UIOnboardSwitchDebouncer(GPIOPinRead(PIN_SWITCH_PORT, PIN_SWITCH_PIN)); // // Increment the blink counter. // g_ulBlinkCount++; // // Loop through the two LEDs. // for(ulIdx = 0; ulIdx < 2; ulIdx++) { // // See if this LED is enabled for blinking. // if(g_pusBlinkRate[ulIdx] != 0) { // // Get the count in terms of the clock for this LED. // ulCount = g_ulBlinkCount % g_pusBlinkRate[ulIdx]; // // The LED should be turned on when the count is zero. // if(ulCount == 0) { GPIOPinWrite(g_pulLEDBase[ulIdx], g_pucLEDPin[ulIdx], (ulIdx == 0) ? 0 : g_pucLEDPin[ulIdx]); } // // The LED should be turned off when the count equals the period. // if(ulCount == g_pusBlinkPeriod[ulIdx]) { GPIOPinWrite(g_pulLEDBase[ulIdx], g_pucLEDPin[ulIdx], (ulIdx == 0) ? g_pucLEDPin[0] : 0); } } } }
//***************************************************************************** // // Handles the SysTick interrupt. // // This function is called when SysTick asserts its interrupt. It is // responsible for handling the on-board user interface elements (push button // and potentiometer) if enabled, and the processor usage computation. // // \return None. // //*****************************************************************************
Handles the SysTick interrupt. This function is called when SysTick asserts its interrupt. It is responsible for handling the on-board user interface elements (push button and potentiometer) if enabled, and the processor usage computation. \return None.
[ "Handles", "the", "SysTick", "interrupt", ".", "This", "function", "is", "called", "when", "SysTick", "asserts", "its", "interrupt", ".", "It", "is", "responsible", "for", "handling", "the", "on", "-", "board", "user", "interface", "elements", "(", "push", "button", "and", "potentiometer", ")", "if", "enabled", "and", "the", "processor", "usage", "computation", ".", "\\", "return", "None", "." ]
void SysTickIntHandler(void) { unsigned long ulIdx, ulCount; HallTickHandler(); ADCTickHandler(); ulCount = ADCReadAnalog(); g_usAnalogInputVoltage = (((g_usAnalogInputVoltage * 3) + (((ulCount * 3000 * 240) / 140) / 1024)) / 4); UIOnboardSwitchDebouncer(GPIOPinRead(PIN_SWITCH_PORT, PIN_SWITCH_PIN)); g_ulBlinkCount++; for(ulIdx = 0; ulIdx < 2; ulIdx++) { if(g_pusBlinkRate[ulIdx] != 0) { ulCount = g_ulBlinkCount % g_pusBlinkRate[ulIdx]; if(ulCount == 0) { GPIOPinWrite(g_pulLEDBase[ulIdx], g_pucLEDPin[ulIdx], (ulIdx == 0) ? 0 : g_pucLEDPin[ulIdx]); } if(ulCount == g_pusBlinkPeriod[ulIdx]) { GPIOPinWrite(g_pulLEDBase[ulIdx], g_pucLEDPin[ulIdx], (ulIdx == 0) ? g_pucLEDPin[0] : 0); } } } }
[ "void", "SysTickIntHandler", "(", "void", ")", "{", "unsigned", "long", "ulIdx", ",", "ulCount", ";", "HallTickHandler", "(", ")", ";", "ADCTickHandler", "(", ")", ";", "ulCount", "=", "ADCReadAnalog", "(", ")", ";", "g_usAnalogInputVoltage", "=", "(", "(", "(", "g_usAnalogInputVoltage", "*", "3", ")", "+", "(", "(", "(", "ulCount", "*", "3000", "*", "240", ")", "/", "140", ")", "/", "1024", ")", ")", "/", "4", ")", ";", "UIOnboardSwitchDebouncer", "(", "GPIOPinRead", "(", "PIN_SWITCH_PORT", ",", "PIN_SWITCH_PIN", ")", ")", ";", "g_ulBlinkCount", "++", ";", "for", "(", "ulIdx", "=", "0", ";", "ulIdx", "<", "2", ";", "ulIdx", "++", ")", "{", "if", "(", "g_pusBlinkRate", "[", "ulIdx", "]", "!=", "0", ")", "{", "ulCount", "=", "g_ulBlinkCount", "%", "g_pusBlinkRate", "[", "ulIdx", "]", ";", "if", "(", "ulCount", "==", "0", ")", "{", "GPIOPinWrite", "(", "g_pulLEDBase", "[", "ulIdx", "]", ",", "g_pucLEDPin", "[", "ulIdx", "]", ",", "(", "ulIdx", "==", "0", ")", "?", "0", ":", "g_pucLEDPin", "[", "ulIdx", "]", ")", ";", "}", "if", "(", "ulCount", "==", "g_pusBlinkPeriod", "[", "ulIdx", "]", ")", "{", "GPIOPinWrite", "(", "g_pulLEDBase", "[", "ulIdx", "]", ",", "g_pucLEDPin", "[", "ulIdx", "]", ",", "(", "ulIdx", "==", "0", ")", "?", "g_pucLEDPin", "[", "0", "]", ":", "0", ")", ";", "}", "}", "}", "}" ]
Handles the SysTick interrupt.
[ "Handles", "the", "SysTick", "interrupt", "." ]
[ "//\r", "// Run the Hall module tick handler.\r", "//\r", "//\r", "// Run the ADC module tick handler.\r", "//\r", "//\r", "// Convert the ADC Analog Input reading to milli-volts. Each volt at the\r", "// ADC input corresponds to ~1.714 volts at the Analog Input.\r", "//\r", "//\r", "// Read the on-board switch and pass its current value to the switch\r", "// debouncer, only if the onboard user interface is enabled.\r", "//\r", "//\r", "// Increment the blink counter.\r", "//\r", "//\r", "// Loop through the two LEDs.\r", "//\r", "//\r", "// See if this LED is enabled for blinking.\r", "//\r", "//\r", "// Get the count in terms of the clock for this LED.\r", "//\r", "//\r", "// The LED should be turned on when the count is zero.\r", "//\r", "//\r", "// The LED should be turned off when the count equals the period.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2241e12530fd7682cd098e88ff98c0b6a990f2e7
junyanl-code/Luminary-Micro-Library
boards/rdk-bldc/basic-bldc/ui.c
[ "BSD-3-Clause" ]
C
UIInit
void
void UIInit(void) { volatile int iLoop; // // // Make the push button pin be a GPIO input. // GPIOPinTypeGPIOInput(PIN_SWITCH_PORT, PIN_SWITCH_PIN); GPIOPadConfigSet(PIN_SWITCH_PORT, PIN_SWITCH_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Make the LEDs be GPIO outputs and turn them off. // GPIOPinTypeGPIOOutput(PIN_LEDRUN_PORT, PIN_LEDRUN_PIN); GPIOPinTypeGPIOOutput(PIN_LEDFAULT_PORT, PIN_LEDFAULT_PIN); GPIOPinWrite(PIN_LEDRUN_PORT, PIN_LEDRUN_PIN, 0); GPIOPinWrite(PIN_LEDFAULT_PORT, PIN_LEDFAULT_PIN, 0); // // Configure and read the configuration switches and store the values // for future reference. // GPIOPinTypeGPIOInput(PIN_CFG0_PORT, (PIN_CFG0_PIN | PIN_CFG1_PIN | PIN_CFG2_PIN)); GPIOPadConfigSet(PIN_CFG0_PORT, (PIN_CFG0_PIN | PIN_CFG1_PIN | PIN_CFG2_PIN), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); for(iLoop = 0; iLoop < 10000; iLoop++) { } g_ulConfigSwitch = ((GPIOPinRead(PIN_CFG0_PORT, (PIN_CFG1_PIN | PIN_CFG0_PIN)) >> 2) & 0x03); // // Initialize the on-board user interface. // UIOnboardInit(GPIOPinRead(PIN_SWITCH_PORT, PIN_SWITCH_PIN), 0); // // Configure SysTick to provide a periodic user interface interrupt. // SysTickPeriodSet(SYSTEM_CLOCK / UI_INT_RATE); SysTickIntEnable(); SysTickEnable(); // // Configure and enable a timer to provide a periodic interrupt. // TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER1_BASE, TIMER_A, (SYSTEM_CLOCK / TIMER1A_INT_RATE)); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); IntEnable(INT_TIMER1A); TimerEnable(TIMER1_BASE, TIMER_A); // // Configure the Hall sensor support routines. // HallConfigure(); // // Configure the ADC support routines. // ADCConfigure(); // // Configure the PWM generators. // MainSetPWMFrequency(); PWMSetDeadBand(); PWMSetMinPulseWidth(); // // Update the Speed/Power PI controller. // MainUpdateFAdjI(UI_PARAM_SPEED_I); MainUpdatePAdjI(UI_PARAM_SPEED_I); // // Set the main speed/power target. // MainSetSpeed(); MainSetPower(); // // Clear any fault conditions that might exist. // MainClearFaults(); }
//***************************************************************************** // // Initializes the user interface. // // This function initializes the user interface modules (on-board and serial), // preparing them to operate and control the motor drive. // // \return None. // //*****************************************************************************
Initializes the user interface. This function initializes the user interface modules (on-board and serial), preparing them to operate and control the motor drive. \return None.
[ "Initializes", "the", "user", "interface", ".", "This", "function", "initializes", "the", "user", "interface", "modules", "(", "on", "-", "board", "and", "serial", ")", "preparing", "them", "to", "operate", "and", "control", "the", "motor", "drive", ".", "\\", "return", "None", "." ]
void UIInit(void) { volatile int iLoop; GPIOPinTypeGPIOInput(PIN_SWITCH_PORT, PIN_SWITCH_PIN); GPIOPadConfigSet(PIN_SWITCH_PORT, PIN_SWITCH_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOOutput(PIN_LEDRUN_PORT, PIN_LEDRUN_PIN); GPIOPinTypeGPIOOutput(PIN_LEDFAULT_PORT, PIN_LEDFAULT_PIN); GPIOPinWrite(PIN_LEDRUN_PORT, PIN_LEDRUN_PIN, 0); GPIOPinWrite(PIN_LEDFAULT_PORT, PIN_LEDFAULT_PIN, 0); GPIOPinTypeGPIOInput(PIN_CFG0_PORT, (PIN_CFG0_PIN | PIN_CFG1_PIN | PIN_CFG2_PIN)); GPIOPadConfigSet(PIN_CFG0_PORT, (PIN_CFG0_PIN | PIN_CFG1_PIN | PIN_CFG2_PIN), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); for(iLoop = 0; iLoop < 10000; iLoop++) { } g_ulConfigSwitch = ((GPIOPinRead(PIN_CFG0_PORT, (PIN_CFG1_PIN | PIN_CFG0_PIN)) >> 2) & 0x03); UIOnboardInit(GPIOPinRead(PIN_SWITCH_PORT, PIN_SWITCH_PIN), 0); SysTickPeriodSet(SYSTEM_CLOCK / UI_INT_RATE); SysTickIntEnable(); SysTickEnable(); TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER1_BASE, TIMER_A, (SYSTEM_CLOCK / TIMER1A_INT_RATE)); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); IntEnable(INT_TIMER1A); TimerEnable(TIMER1_BASE, TIMER_A); HallConfigure(); ADCConfigure(); MainSetPWMFrequency(); PWMSetDeadBand(); PWMSetMinPulseWidth(); MainUpdateFAdjI(UI_PARAM_SPEED_I); MainUpdatePAdjI(UI_PARAM_SPEED_I); MainSetSpeed(); MainSetPower(); MainClearFaults(); }
[ "void", "UIInit", "(", "void", ")", "{", "volatile", "int", "iLoop", ";", "GPIOPinTypeGPIOInput", "(", "PIN_SWITCH_PORT", ",", "PIN_SWITCH_PIN", ")", ";", "GPIOPadConfigSet", "(", "PIN_SWITCH_PORT", ",", "PIN_SWITCH_PIN", ",", "GPIO_STRENGTH_2MA", ",", "GPIO_PIN_TYPE_STD_WPU", ")", ";", "GPIOPinTypeGPIOOutput", "(", "PIN_LEDRUN_PORT", ",", "PIN_LEDRUN_PIN", ")", ";", "GPIOPinTypeGPIOOutput", "(", "PIN_LEDFAULT_PORT", ",", "PIN_LEDFAULT_PIN", ")", ";", "GPIOPinWrite", "(", "PIN_LEDRUN_PORT", ",", "PIN_LEDRUN_PIN", ",", "0", ")", ";", "GPIOPinWrite", "(", "PIN_LEDFAULT_PORT", ",", "PIN_LEDFAULT_PIN", ",", "0", ")", ";", "GPIOPinTypeGPIOInput", "(", "PIN_CFG0_PORT", ",", "(", "PIN_CFG0_PIN", "|", "PIN_CFG1_PIN", "|", "PIN_CFG2_PIN", ")", ")", ";", "GPIOPadConfigSet", "(", "PIN_CFG0_PORT", ",", "(", "PIN_CFG0_PIN", "|", "PIN_CFG1_PIN", "|", "PIN_CFG2_PIN", ")", ",", "GPIO_STRENGTH_2MA", ",", "GPIO_PIN_TYPE_STD_WPU", ")", ";", "for", "(", "iLoop", "=", "0", ";", "iLoop", "<", "10000", ";", "iLoop", "++", ")", "{", "}", "g_ulConfigSwitch", "=", "(", "(", "GPIOPinRead", "(", "PIN_CFG0_PORT", ",", "(", "PIN_CFG1_PIN", "|", "PIN_CFG0_PIN", ")", ")", ">>", "2", ")", "&", "0x03", ")", ";", "UIOnboardInit", "(", "GPIOPinRead", "(", "PIN_SWITCH_PORT", ",", "PIN_SWITCH_PIN", ")", ",", "0", ")", ";", "SysTickPeriodSet", "(", "SYSTEM_CLOCK", "/", "UI_INT_RATE", ")", ";", "SysTickIntEnable", "(", ")", ";", "SysTickEnable", "(", ")", ";", "TimerConfigure", "(", "TIMER1_BASE", ",", "TIMER_CFG_PERIODIC", ")", ";", "TimerLoadSet", "(", "TIMER1_BASE", ",", "TIMER_A", ",", "(", "SYSTEM_CLOCK", "/", "TIMER1A_INT_RATE", ")", ")", ";", "TimerIntEnable", "(", "TIMER1_BASE", ",", "TIMER_TIMA_TIMEOUT", ")", ";", "IntEnable", "(", "INT_TIMER1A", ")", ";", "TimerEnable", "(", "TIMER1_BASE", ",", "TIMER_A", ")", ";", "HallConfigure", "(", ")", ";", "ADCConfigure", "(", ")", ";", "MainSetPWMFrequency", "(", ")", ";", "PWMSetDeadBand", "(", ")", ";", "PWMSetMinPulseWidth", "(", ")", ";", "MainUpdateFAdjI", "(", "UI_PARAM_SPEED_I", ")", ";", "MainUpdatePAdjI", "(", "UI_PARAM_SPEED_I", ")", ";", "MainSetSpeed", "(", ")", ";", "MainSetPower", "(", ")", ";", "MainClearFaults", "(", ")", ";", "}" ]
Initializes the user interface.
[ "Initializes", "the", "user", "interface", "." ]
[ "//\r", "//\r", "// Make the push button pin be a GPIO input.\r", "//\r", "//\r", "// Make the LEDs be GPIO outputs and turn them off.\r", "//\r", "//\r", "// Configure and read the configuration switches and store the values\r", "// for future reference.\r", "// \r", "//\r", "// Initialize the on-board user interface.\r", "//\r", "//\r", "// Configure SysTick to provide a periodic user interface interrupt.\r", "//\r", "//\r", "// Configure and enable a timer to provide a periodic interrupt.\r", "//\r", "//\r", "// Configure the Hall sensor support routines.\r", "//\r", "//\r", "// Configure the ADC support routines.\r", "//\r", "//\r", "// Configure the PWM generators.\r", "//\r", "//\r", "// Update the Speed/Power PI controller.\r", "//\r", "//\r", "// Set the main speed/power target.\r", "//\r", "//\r", "// Clear any fault conditions that might exist.\r", "// \r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
SpiderCollide
null
static long SpiderCollide(long lSpider, long lX, long lY) { long lIdx, lDX, lDY; // // Loop through all the spiders. // for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { // // Skip this spider if it is not alive or is the spider that should be // ignored. // if((HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) || (lIdx == lSpider)) { continue; } // // Compute the horizontal and vertical difference between this spider's // position and the point in question. // lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); // // Return this spider index if the point in question collides with it. // if((lDX < SPIDER_WIDTH) && (lDY < SPIDER_HEIGHT)) { return(lIdx); } } // // No collision was detected. // return(-1); }
//***************************************************************************** // // Determines if a given point collides with one of the spiders. The spider // specified is ignored when doing collision detection in order to prevent a // false collision with itself (when checking to see if it is safe to move the // spider). // //*****************************************************************************
Determines if a given point collides with one of the spiders. The spider specified is ignored when doing collision detection in order to prevent a false collision with itself (when checking to see if it is safe to move the spider).
[ "Determines", "if", "a", "given", "point", "collides", "with", "one", "of", "the", "spiders", ".", "The", "spider", "specified", "is", "ignored", "when", "doing", "collision", "detection", "in", "order", "to", "prevent", "a", "false", "collision", "with", "itself", "(", "when", "checking", "to", "see", "if", "it", "is", "safe", "to", "move", "the", "spider", ")", "." ]
static long SpiderCollide(long lSpider, long lX, long lY) { long lIdx, lDX, lDY; for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { if((HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) || (lIdx == lSpider)) { continue; } lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); if((lDX < SPIDER_WIDTH) && (lDY < SPIDER_HEIGHT)) { return(lIdx); } } return(-1); }
[ "static", "long", "SpiderCollide", "(", "long", "lSpider", ",", "long", "lX", ",", "long", "lY", ")", "{", "long", "lIdx", ",", "lDX", ",", "lDY", ";", "for", "(", "lIdx", "=", "0", ";", "lIdx", "<", "MAX_SPIDERS", ";", "lIdx", "++", ")", "{", "if", "(", "(", "HWREGBITW", "(", "&", "g_ulSpiderAlive", ",", "lIdx", ")", "==", "0", ")", "||", "(", "lIdx", "==", "lSpider", ")", ")", "{", "continue", ";", "}", "lDX", "=", "(", "(", "g_plSpiderX", "[", "lIdx", "]", ">", "lX", ")", "?", "(", "g_plSpiderX", "[", "lIdx", "]", "-", "lX", ")", ":", "(", "lX", "-", "g_plSpiderX", "[", "lIdx", "]", ")", ")", ";", "lDY", "=", "(", "(", "g_plSpiderY", "[", "lIdx", "]", ">", "lY", ")", "?", "(", "g_plSpiderY", "[", "lIdx", "]", "-", "lY", ")", ":", "(", "lY", "-", "g_plSpiderY", "[", "lIdx", "]", ")", ")", ";", "if", "(", "(", "lDX", "<", "SPIDER_WIDTH", ")", "&&", "(", "lDY", "<", "SPIDER_HEIGHT", ")", ")", "{", "return", "(", "lIdx", ")", ";", "}", "}", "return", "(", "-1", ")", ";", "}" ]
Determines if a given point collides with one of the spiders.
[ "Determines", "if", "a", "given", "point", "collides", "with", "one", "of", "the", "spiders", "." ]
[ "//\r", "// Loop through all the spiders.\r", "//\r", "//\r", "// Skip this spider if it is not alive or is the spider that should be\r", "// ignored.\r", "//\r", "//\r", "// Compute the horizontal and vertical difference between this spider's\r", "// position and the point in question.\r", "//\r", "//\r", "// Return this spider index if the point in question collides with it.\r", "//\r", "//\r", "// No collision was detected.\r", "//\r" ]
[ { "param": "lSpider", "type": "long" }, { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lSpider", "type": "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": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
SpiderTask
void
static void SpiderTask(void *pvParameters) { unsigned long ulDir, ulImage, ulTemp; long lX, lY, lSpider; // // Get the spider number from the parameter. // lSpider = (long)pvParameters; // // Add the current tick count to the random entropy pool. // RandomAddEntropy(xTaskGetTickCount()); // // Reseed the random number generator. // RandomSeed(); // // Indicate that this spider is alive. // HWREGBITW(&g_ulSpiderAlive, lSpider) = 1; // // Indicate that this spider is not dead yet. // HWREGBITW(&g_ulSpiderDead, lSpider) = 0; // // Get a local copy of the spider's starting position. // lX = g_plSpiderX[lSpider]; lY = g_plSpiderY[lSpider]; // // Choose a random starting direction for the spider. // ulDir = RandomNumber() >> 29; // // Start by displaying the first of the two spider animation images. // ulImage = 0; // // Loop forever. // while(1) { // // See if this spider has been killed. // if(HWREGBITW(&g_ulSpiderDead, lSpider) == 1) { // // Wait for 2 seconds. // xTaskDelay((1000 / portTICK_RATE_MS) * 2); // // Clear the spider from the display. // DisplayImage(lX - (SPIDER_WIDTH / 2), lY - (SPIDER_HEIGHT / 2), g_pucSpiderBlankImage); // // Indicate that this spider is not alive. // HWREGBITW(&g_ulSpiderAlive, lSpider) = 0; // // Delete the current task. This should never return. // xTaskDelete(NULL); // // In case it does return, loop forever. // while(1) { } } // // Enter a critical section while the next move for the spider is // determined. Having more than one spider trying to move at a time // (via preemption) would make the collision detection check fail. // taskENTER_CRITICAL(); // // Move the spider. // lX += g_plSpiderStepX[ulDir]; lY += g_plSpiderStepY[ulDir]; // // See if the spider has cross the boundary of its area, if it has // collided with another spider, or if random chance says that the // spider should turn despite not having collided with anything. // if((lX < SPIDER_MIN_X) || (lX > SPIDER_MAX_X) || (lY < SPIDER_MIN_Y) || (lY > SPIDER_MAX_Y) || (SpiderCollide(lSpider, lX, lY) != -1) || (RandomNumber() < 0x08000000)) { // // Undo the previous movement of the spider. // lX -= g_plSpiderStepX[ulDir]; lY -= g_plSpiderStepY[ulDir]; // // Get a random number to determine the turn to be made. // ulTemp = RandomNumber(); // // Determine how to turn the spider based on the random number. // Half the time the spider turns to the left and half the time it // turns to the right. Of each half, it turns a quarter of a turn // 12.5% of the time and an eighth of a turn 87.5% of the time. // if(ulTemp < 0x10000000) { ulDir = (ulDir + 2) & 7; } else if(ulTemp < 0x80000000) { ulDir = (ulDir + 1) & 7; } else if(ulTemp < 0xf0000000) { ulDir = (ulDir - 1) & 7; } else { ulDir = (ulDir - 2) & 7; } } // // Update the position of the spider. // g_plSpiderX[lSpider] = lX; g_plSpiderY[lSpider] = lY; // // Exit the critical section now that the spider has been moved. // taskEXIT_CRITICAL(); // // Have the display task draw the spider at the new position. Since // there is a one pixel empty border around all the images, and the // position of the spider is incremented by only one pixel, this also // erases any traces of the spider in its previous position. // DisplayImage(lX - (SPIDER_WIDTH / 2), lY - (SPIDER_HEIGHT / 2), g_ppucSpiderImage[(ulDir * 2) + ulImage]); // // Toggle the spider animation index. // ulImage ^= 1; // // Delay this task for an amount of time based on the direction the // spider is moving. // xTaskDelay(g_pulSpiderDelay[ulDir & 1]); // // Add the new tick count to the random entropy pool. // RandomAddEntropy(xTaskGetTickCount()); // // Reseed the random number generator. // RandomSeed(); } }
//***************************************************************************** // // This task manages the scurring about of a spider. // //*****************************************************************************
This task manages the scurring about of a spider.
[ "This", "task", "manages", "the", "scurring", "about", "of", "a", "spider", "." ]
static void SpiderTask(void *pvParameters) { unsigned long ulDir, ulImage, ulTemp; long lX, lY, lSpider; lSpider = (long)pvParameters; RandomAddEntropy(xTaskGetTickCount()); RandomSeed(); HWREGBITW(&g_ulSpiderAlive, lSpider) = 1; HWREGBITW(&g_ulSpiderDead, lSpider) = 0; lX = g_plSpiderX[lSpider]; lY = g_plSpiderY[lSpider]; ulDir = RandomNumber() >> 29; ulImage = 0; while(1) { if(HWREGBITW(&g_ulSpiderDead, lSpider) == 1) { xTaskDelay((1000 / portTICK_RATE_MS) * 2); DisplayImage(lX - (SPIDER_WIDTH / 2), lY - (SPIDER_HEIGHT / 2), g_pucSpiderBlankImage); HWREGBITW(&g_ulSpiderAlive, lSpider) = 0; xTaskDelete(NULL); while(1) { } } taskENTER_CRITICAL(); lX += g_plSpiderStepX[ulDir]; lY += g_plSpiderStepY[ulDir]; if((lX < SPIDER_MIN_X) || (lX > SPIDER_MAX_X) || (lY < SPIDER_MIN_Y) || (lY > SPIDER_MAX_Y) || (SpiderCollide(lSpider, lX, lY) != -1) || (RandomNumber() < 0x08000000)) { lX -= g_plSpiderStepX[ulDir]; lY -= g_plSpiderStepY[ulDir]; ulTemp = RandomNumber(); if(ulTemp < 0x10000000) { ulDir = (ulDir + 2) & 7; } else if(ulTemp < 0x80000000) { ulDir = (ulDir + 1) & 7; } else if(ulTemp < 0xf0000000) { ulDir = (ulDir - 1) & 7; } else { ulDir = (ulDir - 2) & 7; } } g_plSpiderX[lSpider] = lX; g_plSpiderY[lSpider] = lY; taskEXIT_CRITICAL(); DisplayImage(lX - (SPIDER_WIDTH / 2), lY - (SPIDER_HEIGHT / 2), g_ppucSpiderImage[(ulDir * 2) + ulImage]); ulImage ^= 1; xTaskDelay(g_pulSpiderDelay[ulDir & 1]); RandomAddEntropy(xTaskGetTickCount()); RandomSeed(); } }
[ "static", "void", "SpiderTask", "(", "void", "*", "pvParameters", ")", "{", "unsigned", "long", "ulDir", ",", "ulImage", ",", "ulTemp", ";", "long", "lX", ",", "lY", ",", "lSpider", ";", "lSpider", "=", "(", "long", ")", "pvParameters", ";", "RandomAddEntropy", "(", "xTaskGetTickCount", "(", ")", ")", ";", "RandomSeed", "(", ")", ";", "HWREGBITW", "(", "&", "g_ulSpiderAlive", ",", "lSpider", ")", "=", "1", ";", "HWREGBITW", "(", "&", "g_ulSpiderDead", ",", "lSpider", ")", "=", "0", ";", "lX", "=", "g_plSpiderX", "[", "lSpider", "]", ";", "lY", "=", "g_plSpiderY", "[", "lSpider", "]", ";", "ulDir", "=", "RandomNumber", "(", ")", ">>", "29", ";", "ulImage", "=", "0", ";", "while", "(", "1", ")", "{", "if", "(", "HWREGBITW", "(", "&", "g_ulSpiderDead", ",", "lSpider", ")", "==", "1", ")", "{", "xTaskDelay", "(", "(", "1000", "/", "portTICK_RATE_MS", ")", "*", "2", ")", ";", "DisplayImage", "(", "lX", "-", "(", "SPIDER_WIDTH", "/", "2", ")", ",", "lY", "-", "(", "SPIDER_HEIGHT", "/", "2", ")", ",", "g_pucSpiderBlankImage", ")", ";", "HWREGBITW", "(", "&", "g_ulSpiderAlive", ",", "lSpider", ")", "=", "0", ";", "xTaskDelete", "(", "NULL", ")", ";", "while", "(", "1", ")", "{", "}", "}", "taskENTER_CRITICAL", "(", ")", ";", "lX", "+=", "g_plSpiderStepX", "[", "ulDir", "]", ";", "lY", "+=", "g_plSpiderStepY", "[", "ulDir", "]", ";", "if", "(", "(", "lX", "<", "SPIDER_MIN_X", ")", "||", "(", "lX", ">", "SPIDER_MAX_X", ")", "||", "(", "lY", "<", "SPIDER_MIN_Y", ")", "||", "(", "lY", ">", "SPIDER_MAX_Y", ")", "||", "(", "SpiderCollide", "(", "lSpider", ",", "lX", ",", "lY", ")", "!=", "-1", ")", "||", "(", "RandomNumber", "(", ")", "<", "0x08000000", ")", ")", "{", "lX", "-=", "g_plSpiderStepX", "[", "ulDir", "]", ";", "lY", "-=", "g_plSpiderStepY", "[", "ulDir", "]", ";", "ulTemp", "=", "RandomNumber", "(", ")", ";", "if", "(", "ulTemp", "<", "0x10000000", ")", "{", "ulDir", "=", "(", "ulDir", "+", "2", ")", "&", "7", ";", "}", "else", "if", "(", "ulTemp", "<", "0x80000000", ")", "{", "ulDir", "=", "(", "ulDir", "+", "1", ")", "&", "7", ";", "}", "else", "if", "(", "ulTemp", "<", "0xf0000000", ")", "{", "ulDir", "=", "(", "ulDir", "-", "1", ")", "&", "7", ";", "}", "else", "{", "ulDir", "=", "(", "ulDir", "-", "2", ")", "&", "7", ";", "}", "}", "g_plSpiderX", "[", "lSpider", "]", "=", "lX", ";", "g_plSpiderY", "[", "lSpider", "]", "=", "lY", ";", "taskEXIT_CRITICAL", "(", ")", ";", "DisplayImage", "(", "lX", "-", "(", "SPIDER_WIDTH", "/", "2", ")", ",", "lY", "-", "(", "SPIDER_HEIGHT", "/", "2", ")", ",", "g_ppucSpiderImage", "[", "(", "ulDir", "*", "2", ")", "+", "ulImage", "]", ")", ";", "ulImage", "^=", "1", ";", "xTaskDelay", "(", "g_pulSpiderDelay", "[", "ulDir", "&", "1", "]", ")", ";", "RandomAddEntropy", "(", "xTaskGetTickCount", "(", ")", ")", ";", "RandomSeed", "(", ")", ";", "}", "}" ]
This task manages the scurring about of a spider.
[ "This", "task", "manages", "the", "scurring", "about", "of", "a", "spider", "." ]
[ "//\r", "// Get the spider number from the parameter.\r", "//\r", "//\r", "// Add the current tick count to the random entropy pool.\r", "//\r", "//\r", "// Reseed the random number generator.\r", "//\r", "//\r", "// Indicate that this spider is alive.\r", "//\r", "//\r", "// Indicate that this spider is not dead yet.\r", "//\r", "//\r", "// Get a local copy of the spider's starting position.\r", "//\r", "//\r", "// Choose a random starting direction for the spider.\r", "//\r", "//\r", "// Start by displaying the first of the two spider animation images.\r", "//\r", "//\r", "// Loop forever.\r", "//\r", "//\r", "// See if this spider has been killed.\r", "//\r", "//\r", "// Wait for 2 seconds.\r", "//\r", "//\r", "// Clear the spider from the display.\r", "//\r", "//\r", "// Indicate that this spider is not alive.\r", "//\r", "//\r", "// Delete the current task. This should never return.\r", "//\r", "//\r", "// In case it does return, loop forever.\r", "//\r", "//\r", "// Enter a critical section while the next move for the spider is\r", "// determined. Having more than one spider trying to move at a time\r", "// (via preemption) would make the collision detection check fail.\r", "//\r", "//\r", "// Move the spider.\r", "//\r", "//\r", "// See if the spider has cross the boundary of its area, if it has\r", "// collided with another spider, or if random chance says that the\r", "// spider should turn despite not having collided with anything.\r", "//\r", "//\r", "// Undo the previous movement of the spider.\r", "//\r", "//\r", "// Get a random number to determine the turn to be made.\r", "//\r", "//\r", "// Determine how to turn the spider based on the random number.\r", "// Half the time the spider turns to the left and half the time it\r", "// turns to the right. Of each half, it turns a quarter of a turn\r", "// 12.5% of the time and an eighth of a turn 87.5% of the time.\r", "//\r", "//\r", "// Update the position of the spider.\r", "//\r", "//\r", "// Exit the critical section now that the spider has been moved.\r", "//\r", "//\r", "// Have the display task draw the spider at the new position. Since\r", "// there is a one pixel empty border around all the images, and the\r", "// position of the spider is incremented by only one pixel, this also\r", "// erases any traces of the spider in its previous position.\r", "//\r", "//\r", "// Toggle the spider animation index.\r", "//\r", "//\r", "// Delay this task for an amount of time based on the direction the\r", "// spider is moving.\r", "//\r", "//\r", "// Add the new tick count to the random entropy pool.\r", "//\r", "//\r", "// Reseed the random number generator.\r", "//\r" ]
[ { "param": "pvParameters", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvParameters", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
ControlTouchCallback
null
static long ControlTouchCallback(unsigned long ulMessage, long lX, long lY) { portBASE_TYPE bTaskWaken; // // Ignore all messages other than pointer down messages. // if(ulMessage != WIDGET_MSG_PTR_DOWN) { return(0); } // // Pack the position into a message to send to the spider control task. // ulMessage = ((lX & 65535) << 16) | (lY & 65535); // // Send the position message to the spider control task. // xQueueSendFromISR(g_pControlQueue, &ulMessage, &bTaskWaken); // // Perform a task yield if necessary. // taskYIELD_FROM_ISR(bTaskWaken); // // This message has been handled. // return(0); }
//***************************************************************************** // // The callback function for messages from the touch screen driver. // //*****************************************************************************
The callback function for messages from the touch screen driver.
[ "The", "callback", "function", "for", "messages", "from", "the", "touch", "screen", "driver", "." ]
static long ControlTouchCallback(unsigned long ulMessage, long lX, long lY) { portBASE_TYPE bTaskWaken; if(ulMessage != WIDGET_MSG_PTR_DOWN) { return(0); } ulMessage = ((lX & 65535) << 16) | (lY & 65535); xQueueSendFromISR(g_pControlQueue, &ulMessage, &bTaskWaken); taskYIELD_FROM_ISR(bTaskWaken); return(0); }
[ "static", "long", "ControlTouchCallback", "(", "unsigned", "long", "ulMessage", ",", "long", "lX", ",", "long", "lY", ")", "{", "portBASE_TYPE", "bTaskWaken", ";", "if", "(", "ulMessage", "!=", "WIDGET_MSG_PTR_DOWN", ")", "{", "return", "(", "0", ")", ";", "}", "ulMessage", "=", "(", "(", "lX", "&", "65535", ")", "<<", "16", ")", "|", "(", "lY", "&", "65535", ")", ";", "xQueueSendFromISR", "(", "g_pControlQueue", ",", "&", "ulMessage", ",", "&", "bTaskWaken", ")", ";", "taskYIELD_FROM_ISR", "(", "bTaskWaken", ")", ";", "return", "(", "0", ")", ";", "}" ]
The callback function for messages from the touch screen driver.
[ "The", "callback", "function", "for", "messages", "from", "the", "touch", "screen", "driver", "." ]
[ "//\r", "// Ignore all messages other than pointer down messages.\r", "//\r", "//\r", "// Pack the position into a message to send to the spider control task.\r", "//\r", "//\r", "// Send the position message to the spider control task.\r", "//\r", "//\r", "// Perform a task yield if necessary.\r", "//\r", "//\r", "// This message has been handled.\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": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
SpiderTouchCollide
null
static long SpiderTouchCollide(long lX, long lY) { long lIdx, lDX, lDY, lBest, lDist; // // Until a collision is found, there is no best spider choice. // lBest = -1; lDist = 1000000; // // Loop through all the spiders. // for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { // // Skip this spider if it is not alive. // if((HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) || (HWREGBITW(&g_ulSpiderDead, lIdx) == 1)) { continue; } // // Compute the horizontal and vertical difference between this spider's // position and the point in question. // lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); // // See if the point in question collides with this spider. // if((lDX < (SPIDER_WIDTH + 4)) && (lDY < (SPIDER_HEIGHT + 4))) { // // Compute distance (squared) between this point and the spider. // lDX = (lDX * lDX) + (lDY * lDY); // // See if this spider is closer to the point in question than any // other spider encountered. // if(lDX < lDist) { // // Save this spider as the new best choice. // lBest = lIdx; lDist = lDX; } } } // // Return the best choice, if one was found. // if(lBest != -1) { return(lBest); } // // Loop through all the spiders. This time, the spiders that are dead but // not cleared from the screen are not ignored. // for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { // // Skip this spider if it is not alive. // if(HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) { continue; } // // Compute the horizontal and vertical difference between this spider's // position and the point in question. // lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); // // See if the point in question collides with this spider. // if((lDX < (SPIDER_WIDTH + 4)) && (lDY < (SPIDER_HEIGHT + 4))) { // // Compute distance (squared) between this point and the spider. // lDX = (lDX * lDX) + (lDY * lDY); // // See if this spider is closer to the point in question than any // other spider encountered. // if(lDX < lDist) { // // Save this spider as the new best choice. // lBest = lIdx; lDist = lDX; } } } // // Return the best choice, if one was found. // return(lBest); }
//***************************************************************************** // // Determines if a given touch screen point collides with one of the spiders. // //*****************************************************************************
Determines if a given touch screen point collides with one of the spiders.
[ "Determines", "if", "a", "given", "touch", "screen", "point", "collides", "with", "one", "of", "the", "spiders", "." ]
static long SpiderTouchCollide(long lX, long lY) { long lIdx, lDX, lDY, lBest, lDist; lBest = -1; lDist = 1000000; for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { if((HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) || (HWREGBITW(&g_ulSpiderDead, lIdx) == 1)) { continue; } lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); if((lDX < (SPIDER_WIDTH + 4)) && (lDY < (SPIDER_HEIGHT + 4))) { lDX = (lDX * lDX) + (lDY * lDY); if(lDX < lDist) { lBest = lIdx; lDist = lDX; } } } if(lBest != -1) { return(lBest); } for(lIdx = 0; lIdx < MAX_SPIDERS; lIdx++) { if(HWREGBITW(&g_ulSpiderAlive, lIdx) == 0) { continue; } lDX = ((g_plSpiderX[lIdx] > lX) ? (g_plSpiderX[lIdx] - lX) : (lX - g_plSpiderX[lIdx])); lDY = ((g_plSpiderY[lIdx] > lY) ? (g_plSpiderY[lIdx] - lY) : (lY - g_plSpiderY[lIdx])); if((lDX < (SPIDER_WIDTH + 4)) && (lDY < (SPIDER_HEIGHT + 4))) { lDX = (lDX * lDX) + (lDY * lDY); if(lDX < lDist) { lBest = lIdx; lDist = lDX; } } } return(lBest); }
[ "static", "long", "SpiderTouchCollide", "(", "long", "lX", ",", "long", "lY", ")", "{", "long", "lIdx", ",", "lDX", ",", "lDY", ",", "lBest", ",", "lDist", ";", "lBest", "=", "-1", ";", "lDist", "=", "1000000", ";", "for", "(", "lIdx", "=", "0", ";", "lIdx", "<", "MAX_SPIDERS", ";", "lIdx", "++", ")", "{", "if", "(", "(", "HWREGBITW", "(", "&", "g_ulSpiderAlive", ",", "lIdx", ")", "==", "0", ")", "||", "(", "HWREGBITW", "(", "&", "g_ulSpiderDead", ",", "lIdx", ")", "==", "1", ")", ")", "{", "continue", ";", "}", "lDX", "=", "(", "(", "g_plSpiderX", "[", "lIdx", "]", ">", "lX", ")", "?", "(", "g_plSpiderX", "[", "lIdx", "]", "-", "lX", ")", ":", "(", "lX", "-", "g_plSpiderX", "[", "lIdx", "]", ")", ")", ";", "lDY", "=", "(", "(", "g_plSpiderY", "[", "lIdx", "]", ">", "lY", ")", "?", "(", "g_plSpiderY", "[", "lIdx", "]", "-", "lY", ")", ":", "(", "lY", "-", "g_plSpiderY", "[", "lIdx", "]", ")", ")", ";", "if", "(", "(", "lDX", "<", "(", "SPIDER_WIDTH", "+", "4", ")", ")", "&&", "(", "lDY", "<", "(", "SPIDER_HEIGHT", "+", "4", ")", ")", ")", "{", "lDX", "=", "(", "lDX", "*", "lDX", ")", "+", "(", "lDY", "*", "lDY", ")", ";", "if", "(", "lDX", "<", "lDist", ")", "{", "lBest", "=", "lIdx", ";", "lDist", "=", "lDX", ";", "}", "}", "}", "if", "(", "lBest", "!=", "-1", ")", "{", "return", "(", "lBest", ")", ";", "}", "for", "(", "lIdx", "=", "0", ";", "lIdx", "<", "MAX_SPIDERS", ";", "lIdx", "++", ")", "{", "if", "(", "HWREGBITW", "(", "&", "g_ulSpiderAlive", ",", "lIdx", ")", "==", "0", ")", "{", "continue", ";", "}", "lDX", "=", "(", "(", "g_plSpiderX", "[", "lIdx", "]", ">", "lX", ")", "?", "(", "g_plSpiderX", "[", "lIdx", "]", "-", "lX", ")", ":", "(", "lX", "-", "g_plSpiderX", "[", "lIdx", "]", ")", ")", ";", "lDY", "=", "(", "(", "g_plSpiderY", "[", "lIdx", "]", ">", "lY", ")", "?", "(", "g_plSpiderY", "[", "lIdx", "]", "-", "lY", ")", ":", "(", "lY", "-", "g_plSpiderY", "[", "lIdx", "]", ")", ")", ";", "if", "(", "(", "lDX", "<", "(", "SPIDER_WIDTH", "+", "4", ")", ")", "&&", "(", "lDY", "<", "(", "SPIDER_HEIGHT", "+", "4", ")", ")", ")", "{", "lDX", "=", "(", "lDX", "*", "lDX", ")", "+", "(", "lDY", "*", "lDY", ")", ";", "if", "(", "lDX", "<", "lDist", ")", "{", "lBest", "=", "lIdx", ";", "lDist", "=", "lDX", ";", "}", "}", "}", "return", "(", "lBest", ")", ";", "}" ]
Determines if a given touch screen point collides with one of the spiders.
[ "Determines", "if", "a", "given", "touch", "screen", "point", "collides", "with", "one", "of", "the", "spiders", "." ]
[ "//\r", "// Until a collision is found, there is no best spider choice.\r", "//\r", "//\r", "// Loop through all the spiders.\r", "//\r", "//\r", "// Skip this spider if it is not alive.\r", "//\r", "//\r", "// Compute the horizontal and vertical difference between this spider's\r", "// position and the point in question.\r", "//\r", "//\r", "// See if the point in question collides with this spider.\r", "//\r", "//\r", "// Compute distance (squared) between this point and the spider.\r", "//\r", "//\r", "// See if this spider is closer to the point in question than any\r", "// other spider encountered.\r", "//\r", "//\r", "// Save this spider as the new best choice.\r", "//\r", "//\r", "// Return the best choice, if one was found.\r", "//\r", "//\r", "// Loop through all the spiders. This time, the spiders that are dead but\r", "// not cleared from the screen are not ignored.\r", "//\r", "//\r", "// Skip this spider if it is not alive.\r", "//\r", "//\r", "// Compute the horizontal and vertical difference between this spider's\r", "// position and the point in question.\r", "//\r", "//\r", "// See if the point in question collides with this spider.\r", "//\r", "//\r", "// Compute distance (squared) between this point and the spider.\r", "//\r", "//\r", "// See if this spider is closer to the point in question than any\r", "// other spider encountered.\r", "//\r", "//\r", "// Save this spider as the new best choice.\r", "//\r", "//\r", "// Return the best choice, if one was found.\r", "//\r" ]
[ { "param": "lX", "type": "long" }, { "param": "lY", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "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": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
ControlTask
void
static void ControlTask(void *pvParameters) { unsigned long ulMessage; long lX, lY, lSpider; // // Initialize the touch screen driver and register a callback function. // TouchScreenInit(); TouchScreenCallbackSet(ControlTouchCallback); // // Lower the priority of the touch screen interrupt handler. This is // required so that the interrupt handler can safely call the interrupt- // safe SafeRTOS functions (specifically to send messages to the queue). // IntPrioritySet(INT_ADC0SS3, 0xc0); // // Loop forever. // while(1) { // // Read the next message from the queue. // if(xQueueReceive(g_pControlQueue, &ulMessage, portMAX_DELAY) == pdPASS) { // // Extract the position of the screen touch from the message. // lX = ulMessage >> 16; lY = ulMessage & 65535; // // Ignore this screen touch if it is not inside the spider area. // if((lX >= AREA_X) && (lX < (AREA_X + AREA_WIDTH)) && (lY >= AREA_Y) && (lY < (AREA_Y + AREA_HEIGHT))) { // // See if this position collides with any of the spiders. // lSpider = SpiderTouchCollide(lX, lY); if(lSpider == -1) { // // There is no collision, so create a new spider (if // possible) at this position. // CreateSpider(lX, lY); } else { // // There is a collision, so kill this spider. // HWREGBITW(&g_ulSpiderDead, lSpider) = 1; } } } } }
//***************************************************************************** // // This task provides overall control of the spiders, spawning and killing them // in response to presses on the touch screen. // //*****************************************************************************
This task provides overall control of the spiders, spawning and killing them in response to presses on the touch screen.
[ "This", "task", "provides", "overall", "control", "of", "the", "spiders", "spawning", "and", "killing", "them", "in", "response", "to", "presses", "on", "the", "touch", "screen", "." ]
static void ControlTask(void *pvParameters) { unsigned long ulMessage; long lX, lY, lSpider; TouchScreenInit(); TouchScreenCallbackSet(ControlTouchCallback); IntPrioritySet(INT_ADC0SS3, 0xc0); while(1) { if(xQueueReceive(g_pControlQueue, &ulMessage, portMAX_DELAY) == pdPASS) { lX = ulMessage >> 16; lY = ulMessage & 65535; if((lX >= AREA_X) && (lX < (AREA_X + AREA_WIDTH)) && (lY >= AREA_Y) && (lY < (AREA_Y + AREA_HEIGHT))) { lSpider = SpiderTouchCollide(lX, lY); if(lSpider == -1) { CreateSpider(lX, lY); } else { HWREGBITW(&g_ulSpiderDead, lSpider) = 1; } } } } }
[ "static", "void", "ControlTask", "(", "void", "*", "pvParameters", ")", "{", "unsigned", "long", "ulMessage", ";", "long", "lX", ",", "lY", ",", "lSpider", ";", "TouchScreenInit", "(", ")", ";", "TouchScreenCallbackSet", "(", "ControlTouchCallback", ")", ";", "IntPrioritySet", "(", "INT_ADC0SS3", ",", "0xc0", ")", ";", "while", "(", "1", ")", "{", "if", "(", "xQueueReceive", "(", "g_pControlQueue", ",", "&", "ulMessage", ",", "portMAX_DELAY", ")", "==", "pdPASS", ")", "{", "lX", "=", "ulMessage", ">>", "16", ";", "lY", "=", "ulMessage", "&", "65535", ";", "if", "(", "(", "lX", ">=", "AREA_X", ")", "&&", "(", "lX", "<", "(", "AREA_X", "+", "AREA_WIDTH", ")", ")", "&&", "(", "lY", ">=", "AREA_Y", ")", "&&", "(", "lY", "<", "(", "AREA_Y", "+", "AREA_HEIGHT", ")", ")", ")", "{", "lSpider", "=", "SpiderTouchCollide", "(", "lX", ",", "lY", ")", ";", "if", "(", "lSpider", "==", "-1", ")", "{", "CreateSpider", "(", "lX", ",", "lY", ")", ";", "}", "else", "{", "HWREGBITW", "(", "&", "g_ulSpiderDead", ",", "lSpider", ")", "=", "1", ";", "}", "}", "}", "}", "}" ]
This task provides overall control of the spiders, spawning and killing them in response to presses on the touch screen.
[ "This", "task", "provides", "overall", "control", "of", "the", "spiders", "spawning", "and", "killing", "them", "in", "response", "to", "presses", "on", "the", "touch", "screen", "." ]
[ "//\r", "// Initialize the touch screen driver and register a callback function.\r", "//\r", "//\r", "// Lower the priority of the touch screen interrupt handler. This is\r", "// required so that the interrupt handler can safely call the interrupt-\r", "// safe SafeRTOS functions (specifically to send messages to the queue).\r", "//\r", "//\r", "// Loop forever.\r", "//\r", "//\r", "// Read the next message from the queue.\r", "//\r", "//\r", "// Extract the position of the screen touch from the message.\r", "//\r", "//\r", "// Ignore this screen touch if it is not inside the spider area.\r", "//\r", "//\r", "// See if this position collides with any of the spiders.\r", "//\r", "//\r", "// There is no collision, so create a new spider (if\r", "// possible) at this position.\r", "//\r", "//\r", "// There is a collision, so kill this spider.\r", "//\r" ]
[ { "param": "pvParameters", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvParameters", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1329dee9cae4480821c493a468c9e40b90a4fb0a
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/safertos_demo/spider_task.c
[ "BSD-3-Clause" ]
C
SpiderSpeedSet
void
void SpiderSpeedSet(unsigned long ulSpeed) { // // Convert the update rate from milliseconds to ticks. The second entry // of the array is 1.4 times the first so that updates when moving along // the diagonal, which are longer steps, are done less frequently by a // proportional amount. // g_pulSpiderDelay[0] = (ulSpeed * (1000 / portTICK_RATE_MS)) / 1000; g_pulSpiderDelay[1] = (ulSpeed * 14 * (1000 / portTICK_RATE_MS)) / 10000; }
//***************************************************************************** // // Sets the speed of the spiders by specifying the number of milliseconds // between updates to the spider's position. // //*****************************************************************************
Sets the speed of the spiders by specifying the number of milliseconds between updates to the spider's position.
[ "Sets", "the", "speed", "of", "the", "spiders", "by", "specifying", "the", "number", "of", "milliseconds", "between", "updates", "to", "the", "spider", "'", "s", "position", "." ]
void SpiderSpeedSet(unsigned long ulSpeed) { g_pulSpiderDelay[0] = (ulSpeed * (1000 / portTICK_RATE_MS)) / 1000; g_pulSpiderDelay[1] = (ulSpeed * 14 * (1000 / portTICK_RATE_MS)) / 10000; }
[ "void", "SpiderSpeedSet", "(", "unsigned", "long", "ulSpeed", ")", "{", "g_pulSpiderDelay", "[", "0", "]", "=", "(", "ulSpeed", "*", "(", "1000", "/", "portTICK_RATE_MS", ")", ")", "/", "1000", ";", "g_pulSpiderDelay", "[", "1", "]", "=", "(", "ulSpeed", "*", "14", "*", "(", "1000", "/", "portTICK_RATE_MS", ")", ")", "/", "10000", ";", "}" ]
Sets the speed of the spiders by specifying the number of milliseconds between updates to the spider's position.
[ "Sets", "the", "speed", "of", "the", "spiders", "by", "specifying", "the", "number", "of", "milliseconds", "between", "updates", "to", "the", "spider", "'", "s", "position", "." ]
[ "//\r", "// Convert the update rate from milliseconds to ticks. The second entry\r", "// of the array is 1.4 times the first so that updates when moving along\r", "// the diagonal, which are longer steps, are done less frequently by a\r", "// proportional amount.\r", "//\r" ]
[ { "param": "ulSpeed", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulSpeed", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e36d4b6d1216c132a1bc481b7ab93962e1b29d0
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/boot_demo_usb/boot_demo_usb.c
[ "BSD-3-Clause" ]
C
MouseTouchHandler
null
static long MouseTouchHandler(unsigned long ulMessage, long lX, long lY) { unsigned long ulLoop; switch(ulMessage) { // // The touchscreen has been pressed. Remember where we are so that // we can determine how far the pointer moves later. // case WIDGET_MSG_PTR_DOWN: g_lScreenStartX = lX; g_lScreenStartY = lY; g_lScreenX = lX; g_lScreenY = lY; g_bScreenPressed = true; // // Is the press within the button area? If so, determine which // button has been pressed. // if(lY >= (GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT)) { // // Run through the list of buttons to determine which one was // pressed. // for(ulLoop = 0; ulLoop < NUM_MOUSE_BUTTONS; ulLoop++) { if((lX >= g_sMouseButtons[ulLoop].usX) && (lX < (g_sMouseButtons[ulLoop].usX + g_sMouseButtons[ulLoop].usWidth))) { g_ucButtons |= g_sMouseButtons[ulLoop].ucReportFlag; break; } } } break; // // The touchscreen is no longer being pressed. // case WIDGET_MSG_PTR_UP: g_bScreenPressed = false; // // Ensure that all buttons are unpressed. // g_ucButtons = 0; break; // // The user is dragging his/her finger/stylus over the touchscreen. // case WIDGET_MSG_PTR_MOVE: g_lScreenX = lX; g_lScreenY = lY; break; } return(0); }
//***************************************************************************** // // This function is called by the touchscreen driver whenever there is a // change in press state or position. // //*****************************************************************************
This function is called by the touchscreen driver whenever there is a change in press state or position.
[ "This", "function", "is", "called", "by", "the", "touchscreen", "driver", "whenever", "there", "is", "a", "change", "in", "press", "state", "or", "position", "." ]
static long MouseTouchHandler(unsigned long ulMessage, long lX, long lY) { unsigned long ulLoop; switch(ulMessage) { case WIDGET_MSG_PTR_DOWN: g_lScreenStartX = lX; g_lScreenStartY = lY; g_lScreenX = lX; g_lScreenY = lY; g_bScreenPressed = true; if(lY >= (GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT)) { for(ulLoop = 0; ulLoop < NUM_MOUSE_BUTTONS; ulLoop++) { if((lX >= g_sMouseButtons[ulLoop].usX) && (lX < (g_sMouseButtons[ulLoop].usX + g_sMouseButtons[ulLoop].usWidth))) { g_ucButtons |= g_sMouseButtons[ulLoop].ucReportFlag; break; } } } break; case WIDGET_MSG_PTR_UP: g_bScreenPressed = false; g_ucButtons = 0; break; case WIDGET_MSG_PTR_MOVE: g_lScreenX = lX; g_lScreenY = lY; break; } return(0); }
[ "static", "long", "MouseTouchHandler", "(", "unsigned", "long", "ulMessage", ",", "long", "lX", ",", "long", "lY", ")", "{", "unsigned", "long", "ulLoop", ";", "switch", "(", "ulMessage", ")", "{", "case", "WIDGET_MSG_PTR_DOWN", ":", "g_lScreenStartX", "=", "lX", ";", "g_lScreenStartY", "=", "lY", ";", "g_lScreenX", "=", "lX", ";", "g_lScreenY", "=", "lY", ";", "g_bScreenPressed", "=", "true", ";", "if", "(", "lY", ">=", "(", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "BUTTON_HEIGHT", ")", ")", "{", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "NUM_MOUSE_BUTTONS", ";", "ulLoop", "++", ")", "{", "if", "(", "(", "lX", ">=", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usX", ")", "&&", "(", "lX", "<", "(", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usX", "+", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usWidth", ")", ")", ")", "{", "g_ucButtons", "|=", "g_sMouseButtons", "[", "ulLoop", "]", ".", "ucReportFlag", ";", "break", ";", "}", "}", "}", "break", ";", "case", "WIDGET_MSG_PTR_UP", ":", "g_bScreenPressed", "=", "false", ";", "g_ucButtons", "=", "0", ";", "break", ";", "case", "WIDGET_MSG_PTR_MOVE", ":", "g_lScreenX", "=", "lX", ";", "g_lScreenY", "=", "lY", ";", "break", ";", "}", "return", "(", "0", ")", ";", "}" ]
This function is called by the touchscreen driver whenever there is a change in press state or position.
[ "This", "function", "is", "called", "by", "the", "touchscreen", "driver", "whenever", "there", "is", "a", "change", "in", "press", "state", "or", "position", "." ]
[ "//\r", "// The touchscreen has been pressed. Remember where we are so that\r", "// we can determine how far the pointer moves later.\r", "//\r", "//\r", "// Is the press within the button area? If so, determine which\r", "// button has been pressed.\r", "//\r", "//\r", "// Run through the list of buttons to determine which one was\r", "// pressed.\r", "//\r", "//\r", "// The touchscreen is no longer being pressed.\r", "//\r", "//\r", "// Ensure that all buttons are unpressed.\r", "//\r", "//\r", "// The user is dragging his/her finger/stylus over the touchscreen.\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": [] }
7e36d4b6d1216c132a1bc481b7ab93962e1b29d0
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/boot_demo_usb/boot_demo_usb.c
[ "BSD-3-Clause" ]
C
UpdateDisplay
void
void UpdateDisplay(unsigned char ucButtons, tBoolean bRedraw) { unsigned long ulLoop; tRectangle sRect, sRectOutline; static unsigned char ucLastButtons; // // Initialize the Y coordinates of the button rectangle. // sRectOutline.sYMin = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT; sRectOutline.sYMax = GrContextDpyHeightGet(&g_sContext) - 1; sRect.sYMin = sRectOutline.sYMin + 1; sRect.sYMax = sRectOutline.sYMax - 1; // // Set the font we use for the button text. // GrContextFontSet(&g_sContext, g_pFontCmss18); // // Loop through each of the mouse buttons, drawing each in turn. // for(ulLoop = 0; ulLoop < NUM_MOUSE_BUTTONS; ulLoop++) { // // Draw the outline if we are redrawing the whole button area. // if(bRedraw) { GrContextForegroundSet(&g_sContext, ClrWhite); sRectOutline.sXMin = g_sMouseButtons[ulLoop].usX; sRectOutline.sXMax = (sRectOutline.sXMin + g_sMouseButtons[ulLoop].usWidth) - 1; GrRectDraw(&g_sContext, &sRectOutline); } // // Has the button state changed since we last drew it or are we // drawing the buttons unconditionally? // if(((g_ucButtons & g_sMouseButtons[ulLoop].ucReportFlag) != (ucLastButtons & g_sMouseButtons[ulLoop].ucReportFlag)) || bRedraw) { // // Set the appropriate button color depending upon whether the // button is pressed or not. // GrContextForegroundSet(&g_sContext, ((g_ucButtons & g_sMouseButtons[ulLoop].ucReportFlag) ? ClrRed : ClrGreen)); sRect.sXMin = g_sMouseButtons[ulLoop].usX + 1; sRect.sXMax = (sRect.sXMin + g_sMouseButtons[ulLoop].usWidth) - 3; GrRectFill(&g_sContext, &sRect); // // Draw the button text. // GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(&g_sContext, g_sMouseButtons[ulLoop].pszLabel, -1, (sRect.sXMin + sRect.sXMax) / 2, (sRect.sYMin + sRect.sYMax) / 2, 0); } } // // Remember the button state we just drew. // ucLastButtons = ucButtons; }
//***************************************************************************** // // This function updates the color STN display to show button state. // // This function is called from ButtonHandler to update the display showing // the state of each of the buttons. // // Returns None. // //*****************************************************************************
This function updates the color STN display to show button state. This function is called from ButtonHandler to update the display showing the state of each of the buttons. Returns None.
[ "This", "function", "updates", "the", "color", "STN", "display", "to", "show", "button", "state", ".", "This", "function", "is", "called", "from", "ButtonHandler", "to", "update", "the", "display", "showing", "the", "state", "of", "each", "of", "the", "buttons", ".", "Returns", "None", "." ]
void UpdateDisplay(unsigned char ucButtons, tBoolean bRedraw) { unsigned long ulLoop; tRectangle sRect, sRectOutline; static unsigned char ucLastButtons; sRectOutline.sYMin = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT; sRectOutline.sYMax = GrContextDpyHeightGet(&g_sContext) - 1; sRect.sYMin = sRectOutline.sYMin + 1; sRect.sYMax = sRectOutline.sYMax - 1; GrContextFontSet(&g_sContext, g_pFontCmss18); for(ulLoop = 0; ulLoop < NUM_MOUSE_BUTTONS; ulLoop++) { if(bRedraw) { GrContextForegroundSet(&g_sContext, ClrWhite); sRectOutline.sXMin = g_sMouseButtons[ulLoop].usX; sRectOutline.sXMax = (sRectOutline.sXMin + g_sMouseButtons[ulLoop].usWidth) - 1; GrRectDraw(&g_sContext, &sRectOutline); } if(((g_ucButtons & g_sMouseButtons[ulLoop].ucReportFlag) != (ucLastButtons & g_sMouseButtons[ulLoop].ucReportFlag)) || bRedraw) { GrContextForegroundSet(&g_sContext, ((g_ucButtons & g_sMouseButtons[ulLoop].ucReportFlag) ? ClrRed : ClrGreen)); sRect.sXMin = g_sMouseButtons[ulLoop].usX + 1; sRect.sXMax = (sRect.sXMin + g_sMouseButtons[ulLoop].usWidth) - 3; GrRectFill(&g_sContext, &sRect); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(&g_sContext, g_sMouseButtons[ulLoop].pszLabel, -1, (sRect.sXMin + sRect.sXMax) / 2, (sRect.sYMin + sRect.sYMax) / 2, 0); } } ucLastButtons = ucButtons; }
[ "void", "UpdateDisplay", "(", "unsigned", "char", "ucButtons", ",", "tBoolean", "bRedraw", ")", "{", "unsigned", "long", "ulLoop", ";", "tRectangle", "sRect", ",", "sRectOutline", ";", "static", "unsigned", "char", "ucLastButtons", ";", "sRectOutline", ".", "sYMin", "=", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "BUTTON_HEIGHT", ";", "sRectOutline", ".", "sYMax", "=", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "1", ";", "sRect", ".", "sYMin", "=", "sRectOutline", ".", "sYMin", "+", "1", ";", "sRect", ".", "sYMax", "=", "sRectOutline", ".", "sYMax", "-", "1", ";", "GrContextFontSet", "(", "&", "g_sContext", ",", "g_pFontCmss18", ")", ";", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "NUM_MOUSE_BUTTONS", ";", "ulLoop", "++", ")", "{", "if", "(", "bRedraw", ")", "{", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "ClrWhite", ")", ";", "sRectOutline", ".", "sXMin", "=", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usX", ";", "sRectOutline", ".", "sXMax", "=", "(", "sRectOutline", ".", "sXMin", "+", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usWidth", ")", "-", "1", ";", "GrRectDraw", "(", "&", "g_sContext", ",", "&", "sRectOutline", ")", ";", "}", "if", "(", "(", "(", "g_ucButtons", "&", "g_sMouseButtons", "[", "ulLoop", "]", ".", "ucReportFlag", ")", "!=", "(", "ucLastButtons", "&", "g_sMouseButtons", "[", "ulLoop", "]", ".", "ucReportFlag", ")", ")", "||", "bRedraw", ")", "{", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "(", "(", "g_ucButtons", "&", "g_sMouseButtons", "[", "ulLoop", "]", ".", "ucReportFlag", ")", "?", "ClrRed", ":", "ClrGreen", ")", ")", ";", "sRect", ".", "sXMin", "=", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usX", "+", "1", ";", "sRect", ".", "sXMax", "=", "(", "sRect", ".", "sXMin", "+", "g_sMouseButtons", "[", "ulLoop", "]", ".", "usWidth", ")", "-", "3", ";", "GrRectFill", "(", "&", "g_sContext", ",", "&", "sRect", ")", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "ClrWhite", ")", ";", "GrStringDrawCentered", "(", "&", "g_sContext", ",", "g_sMouseButtons", "[", "ulLoop", "]", ".", "pszLabel", ",", "-1", ",", "(", "sRect", ".", "sXMin", "+", "sRect", ".", "sXMax", ")", "/", "2", ",", "(", "sRect", ".", "sYMin", "+", "sRect", ".", "sYMax", ")", "/", "2", ",", "0", ")", ";", "}", "}", "ucLastButtons", "=", "ucButtons", ";", "}" ]
This function updates the color STN display to show button state.
[ "This", "function", "updates", "the", "color", "STN", "display", "to", "show", "button", "state", "." ]
[ "//\r", "// Initialize the Y coordinates of the button rectangle.\r", "//\r", "//\r", "// Set the font we use for the button text.\r", "//\r", "//\r", "// Loop through each of the mouse buttons, drawing each in turn.\r", "//\r", "//\r", "// Draw the outline if we are redrawing the whole button area.\r", "//\r", "//\r", "// Has the button state changed since we last drew it or are we\r", "// drawing the buttons unconditionally?\r", "//\r", "//\r", "// Set the appropriate button color depending upon whether the\r", "// button is pressed or not.\r", "//\r", "//\r", "// Draw the button text.\r", "//\r", "//\r", "// Remember the button state we just drew.\r", "//\r" ]
[ { "param": "ucButtons", "type": "unsigned char" }, { "param": "bRedraw", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ucButtons", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bRedraw", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e36d4b6d1216c132a1bc481b7ab93962e1b29d0
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/boot_demo_usb/boot_demo_usb.c
[ "BSD-3-Clause" ]
C
TouchHandler
void
static void TouchHandler(void) { long lDeltaX, lDeltaY; static unsigned char ucButtons = 0; // // Is someone pressing the screen or has the button changed state? If so, // we determine how far they have dragged their finger/stylus and use this // to calculate mouse position changes to send to the host. // if(g_bScreenPressed || (ucButtons != g_ucButtons)) { // // Calculate how far we moved since the last time we checked. This // rather odd layout prevents a compiler warning about undefined order // of volatile accesses. // lDeltaX = g_lScreenX; lDeltaX -= g_lScreenStartX; lDeltaY = g_lScreenY; lDeltaY -= g_lScreenStartY; // // Reset our start position. // g_lScreenStartX = g_lScreenX; g_lScreenStartY = g_lScreenY; // // Was there any movement or change in button state? // if(lDeltaX || lDeltaY || (ucButtons != g_ucButtons)) { // // Yes - send a report back to the host after clipping the deltas // to the maximum we can support. // lDeltaX = (lDeltaX > 127) ? 127 : lDeltaX; lDeltaX = (lDeltaX < -128) ? -128 : lDeltaX; lDeltaY = (lDeltaY > 127) ? 127 : lDeltaY; lDeltaY = (lDeltaY < -128) ? -128 : lDeltaY; // // Remember the current button state. // ucButtons = g_ucButtons; // // Send the report back to the host. // USBDHIDMouseStateChange((void *)&g_sMouseDevice, (char)lDeltaX, (char)lDeltaY, ucButtons); } // // Update the button portion of the display. // UpdateDisplay(ucButtons, false); } }
//***************************************************************************** // // This function handles updates due to touchscreen input. // // This function is called periodically from the main loop to check the // touchscreen state and, if necessary, send a HID report back to the host // system. // // Returns Returns \b true on success or \b false if an error is detected. // //*****************************************************************************
This function handles updates due to touchscreen input. This function is called periodically from the main loop to check the touchscreen state and, if necessary, send a HID report back to the host system. Returns Returns \b true on success or \b false if an error is detected.
[ "This", "function", "handles", "updates", "due", "to", "touchscreen", "input", ".", "This", "function", "is", "called", "periodically", "from", "the", "main", "loop", "to", "check", "the", "touchscreen", "state", "and", "if", "necessary", "send", "a", "HID", "report", "back", "to", "the", "host", "system", ".", "Returns", "Returns", "\\", "b", "true", "on", "success", "or", "\\", "b", "false", "if", "an", "error", "is", "detected", "." ]
static void TouchHandler(void) { long lDeltaX, lDeltaY; static unsigned char ucButtons = 0; if(g_bScreenPressed || (ucButtons != g_ucButtons)) { lDeltaX = g_lScreenX; lDeltaX -= g_lScreenStartX; lDeltaY = g_lScreenY; lDeltaY -= g_lScreenStartY; g_lScreenStartX = g_lScreenX; g_lScreenStartY = g_lScreenY; if(lDeltaX || lDeltaY || (ucButtons != g_ucButtons)) { lDeltaX = (lDeltaX > 127) ? 127 : lDeltaX; lDeltaX = (lDeltaX < -128) ? -128 : lDeltaX; lDeltaY = (lDeltaY > 127) ? 127 : lDeltaY; lDeltaY = (lDeltaY < -128) ? -128 : lDeltaY; ucButtons = g_ucButtons; USBDHIDMouseStateChange((void *)&g_sMouseDevice, (char)lDeltaX, (char)lDeltaY, ucButtons); } UpdateDisplay(ucButtons, false); } }
[ "static", "void", "TouchHandler", "(", "void", ")", "{", "long", "lDeltaX", ",", "lDeltaY", ";", "static", "unsigned", "char", "ucButtons", "=", "0", ";", "if", "(", "g_bScreenPressed", "||", "(", "ucButtons", "!=", "g_ucButtons", ")", ")", "{", "lDeltaX", "=", "g_lScreenX", ";", "lDeltaX", "-=", "g_lScreenStartX", ";", "lDeltaY", "=", "g_lScreenY", ";", "lDeltaY", "-=", "g_lScreenStartY", ";", "g_lScreenStartX", "=", "g_lScreenX", ";", "g_lScreenStartY", "=", "g_lScreenY", ";", "if", "(", "lDeltaX", "||", "lDeltaY", "||", "(", "ucButtons", "!=", "g_ucButtons", ")", ")", "{", "lDeltaX", "=", "(", "lDeltaX", ">", "127", ")", "?", "127", ":", "lDeltaX", ";", "lDeltaX", "=", "(", "lDeltaX", "<", "-128", ")", "?", "-128", ":", "lDeltaX", ";", "lDeltaY", "=", "(", "lDeltaY", ">", "127", ")", "?", "127", ":", "lDeltaY", ";", "lDeltaY", "=", "(", "lDeltaY", "<", "-128", ")", "?", "-128", ":", "lDeltaY", ";", "ucButtons", "=", "g_ucButtons", ";", "USBDHIDMouseStateChange", "(", "(", "void", "*", ")", "&", "g_sMouseDevice", ",", "(", "char", ")", "lDeltaX", ",", "(", "char", ")", "lDeltaY", ",", "ucButtons", ")", ";", "}", "UpdateDisplay", "(", "ucButtons", ",", "false", ")", ";", "}", "}" ]
This function handles updates due to touchscreen input.
[ "This", "function", "handles", "updates", "due", "to", "touchscreen", "input", "." ]
[ "//\r", "// Is someone pressing the screen or has the button changed state? If so,\r", "// we determine how far they have dragged their finger/stylus and use this\r", "// to calculate mouse position changes to send to the host.\r", "//\r", "//\r", "// Calculate how far we moved since the last time we checked. This\r", "// rather odd layout prevents a compiler warning about undefined order\r", "// of volatile accesses.\r", "//\r", "//\r", "// Reset our start position.\r", "//\r", "//\r", "// Was there any movement or change in button state?\r", "//\r", "//\r", "// Yes - send a report back to the host after clipping the deltas\r", "// to the maximum we can support.\r", "//\r", "//\r", "// Remember the current button state.\r", "//\r", "//\r", "// Send the report back to the host.\r", "//\r", "//\r", "// Update the button portion of the display.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7e36d4b6d1216c132a1bc481b7ab93962e1b29d0
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96/boot_demo_usb/boot_demo_usb.c
[ "BSD-3-Clause" ]
C
SysTickHandler
void
void SysTickHandler(void) { g_ulSysTickCount++; g_ulCommands |= TOUCH_TICK_EVENT; }
//***************************************************************************** // // This is the interrupt handler for the SysTick interrupt. It is called // periodically and updates a global tick counter then sets a flag to tell the // main loop to check the button state. // //*****************************************************************************
This is the interrupt handler for the SysTick interrupt. It is called periodically and updates a global tick counter then sets a flag to tell the main loop to check the button state.
[ "This", "is", "the", "interrupt", "handler", "for", "the", "SysTick", "interrupt", ".", "It", "is", "called", "periodically", "and", "updates", "a", "global", "tick", "counter", "then", "sets", "a", "flag", "to", "tell", "the", "main", "loop", "to", "check", "the", "button", "state", "." ]
void SysTickHandler(void) { g_ulSysTickCount++; g_ulCommands |= TOUCH_TICK_EVENT; }
[ "void", "SysTickHandler", "(", "void", ")", "{", "g_ulSysTickCount", "++", ";", "g_ulCommands", "|=", "TOUCH_TICK_EVENT", ";", "}" ]
This is the interrupt handler for the SysTick interrupt.
[ "This", "is", "the", "interrupt", "handler", "for", "the", "SysTick", "interrupt", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
5b9eda080452aaab39e2e106980f463e8b5c3bca
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/usb_dev_bulk/usb_dev_bulk.c
[ "BSD-3-Clause" ]
C
EchoNewDataToHost
null
static unsigned long EchoNewDataToHost(tUSBDBulkDevice *psDevice, unsigned char *pcData, unsigned long ulNumBytes) { unsigned long ulLoop, ulSpace, ulCount; unsigned long ulReadIndex; unsigned long ulWriteIndex; tUSBRingBufObject sTxRing; // // Get the current buffer information to allow us to write directly to // the transmit buffer (we already have enough information from the // parameters to access the receive buffer directly). // USBBufferInfoGet(&g_sTxBuffer, &sTxRing); // // How much space is there in the transmit buffer? // ulSpace = USBBufferSpaceAvailable(&g_sTxBuffer); // // How many characters can we process this time round? // ulLoop = (ulSpace < ulNumBytes) ? ulSpace : ulNumBytes; ulCount = ulLoop; // // Update our receive counter. // g_ulRxCount += ulNumBytes; // // Dump a debug message. // DEBUG_PRINT("Received %d bytes\n", ulNumBytes); // // Set up to process the characters by directly accessing the USB buffers. // ulReadIndex = (unsigned long)(pcData - g_pucUSBRxBuffer); ulWriteIndex = sTxRing.ulWriteIndex; while(ulLoop) { // // Copy from the receive buffer to the transmit buffer converting // character case on the way. // // // Is this a lower case character? // if((g_pucUSBRxBuffer[ulReadIndex] >= 'a') && (g_pucUSBRxBuffer[ulReadIndex] <= 'z')) { // // Convert to upper case and write to the transmit buffer. // g_pucUSBTxBuffer[ulWriteIndex] = (g_pucUSBRxBuffer[ulReadIndex] - 'a') + 'A'; } else { // // Is this an upper case character? // if((g_pucUSBRxBuffer[ulReadIndex] >= 'A') && (g_pucUSBRxBuffer[ulReadIndex] <= 'Z')) { // // Convert to lower case and write to the transmit buffer. // g_pucUSBTxBuffer[ulWriteIndex] = (g_pucUSBRxBuffer[ulReadIndex] - 'Z') + 'z'; } else { // // Copy the received character to the transmit buffer. // g_pucUSBTxBuffer[ulWriteIndex] = g_pucUSBRxBuffer[ulReadIndex]; } } // // Move to the next character taking care to adjust the pointer for // the buffer wrap if necessary. // ulWriteIndex++; ulWriteIndex = (ulWriteIndex == BULK_BUFFER_SIZE) ? 0 : ulWriteIndex; ulReadIndex++; ulReadIndex = (ulReadIndex == BULK_BUFFER_SIZE) ? 0 : ulReadIndex; ulLoop--; } // // We've processed the data in place so now send the processed data // back to the host. // USBBufferDataWritten(&g_sTxBuffer, ulCount); DEBUG_PRINT("Wrote %d bytes\n", ulCount); // // We processed as much data as we can directly from the receive buffer so // we need to return the number of bytes to allow the lower layer to // update its read pointer appropriately. // return(ulCount); }
//***************************************************************************** // // Receive new data and echo it back to the host. // // \param psDevice points to the instance data for the device whose data is to // be processed. // \param pcData points to the newly received data in the USB receive buffer. // \param ulNumBytes is the number of bytes of data available to be processed. // // This function is called whenever we receive a notification that data is // available from the host. We read the data, byte-by-byte and swap the case // of any alphabetical characters found then write it back out to be // transmitted back to the host. // // \return Returns the number of bytes of data processed. // //*****************************************************************************
Receive new data and echo it back to the host. \param psDevice points to the instance data for the device whose data is to be processed. \param pcData points to the newly received data in the USB receive buffer. \param ulNumBytes is the number of bytes of data available to be processed. This function is called whenever we receive a notification that data is available from the host. We read the data, byte-by-byte and swap the case of any alphabetical characters found then write it back out to be transmitted back to the host. \return Returns the number of bytes of data processed.
[ "Receive", "new", "data", "and", "echo", "it", "back", "to", "the", "host", ".", "\\", "param", "psDevice", "points", "to", "the", "instance", "data", "for", "the", "device", "whose", "data", "is", "to", "be", "processed", ".", "\\", "param", "pcData", "points", "to", "the", "newly", "received", "data", "in", "the", "USB", "receive", "buffer", ".", "\\", "param", "ulNumBytes", "is", "the", "number", "of", "bytes", "of", "data", "available", "to", "be", "processed", ".", "This", "function", "is", "called", "whenever", "we", "receive", "a", "notification", "that", "data", "is", "available", "from", "the", "host", ".", "We", "read", "the", "data", "byte", "-", "by", "-", "byte", "and", "swap", "the", "case", "of", "any", "alphabetical", "characters", "found", "then", "write", "it", "back", "out", "to", "be", "transmitted", "back", "to", "the", "host", ".", "\\", "return", "Returns", "the", "number", "of", "bytes", "of", "data", "processed", "." ]
static unsigned long EchoNewDataToHost(tUSBDBulkDevice *psDevice, unsigned char *pcData, unsigned long ulNumBytes) { unsigned long ulLoop, ulSpace, ulCount; unsigned long ulReadIndex; unsigned long ulWriteIndex; tUSBRingBufObject sTxRing; USBBufferInfoGet(&g_sTxBuffer, &sTxRing); ulSpace = USBBufferSpaceAvailable(&g_sTxBuffer); ulLoop = (ulSpace < ulNumBytes) ? ulSpace : ulNumBytes; ulCount = ulLoop; g_ulRxCount += ulNumBytes; DEBUG_PRINT("Received %d bytes\n", ulNumBytes); ulReadIndex = (unsigned long)(pcData - g_pucUSBRxBuffer); ulWriteIndex = sTxRing.ulWriteIndex; while(ulLoop) { if((g_pucUSBRxBuffer[ulReadIndex] >= 'a') && (g_pucUSBRxBuffer[ulReadIndex] <= 'z')) { g_pucUSBTxBuffer[ulWriteIndex] = (g_pucUSBRxBuffer[ulReadIndex] - 'a') + 'A'; } else { if((g_pucUSBRxBuffer[ulReadIndex] >= 'A') && (g_pucUSBRxBuffer[ulReadIndex] <= 'Z')) { g_pucUSBTxBuffer[ulWriteIndex] = (g_pucUSBRxBuffer[ulReadIndex] - 'Z') + 'z'; } else { g_pucUSBTxBuffer[ulWriteIndex] = g_pucUSBRxBuffer[ulReadIndex]; } } ulWriteIndex++; ulWriteIndex = (ulWriteIndex == BULK_BUFFER_SIZE) ? 0 : ulWriteIndex; ulReadIndex++; ulReadIndex = (ulReadIndex == BULK_BUFFER_SIZE) ? 0 : ulReadIndex; ulLoop--; } USBBufferDataWritten(&g_sTxBuffer, ulCount); DEBUG_PRINT("Wrote %d bytes\n", ulCount); return(ulCount); }
[ "static", "unsigned", "long", "EchoNewDataToHost", "(", "tUSBDBulkDevice", "*", "psDevice", ",", "unsigned", "char", "*", "pcData", ",", "unsigned", "long", "ulNumBytes", ")", "{", "unsigned", "long", "ulLoop", ",", "ulSpace", ",", "ulCount", ";", "unsigned", "long", "ulReadIndex", ";", "unsigned", "long", "ulWriteIndex", ";", "tUSBRingBufObject", "sTxRing", ";", "USBBufferInfoGet", "(", "&", "g_sTxBuffer", ",", "&", "sTxRing", ")", ";", "ulSpace", "=", "USBBufferSpaceAvailable", "(", "&", "g_sTxBuffer", ")", ";", "ulLoop", "=", "(", "ulSpace", "<", "ulNumBytes", ")", "?", "ulSpace", ":", "ulNumBytes", ";", "ulCount", "=", "ulLoop", ";", "g_ulRxCount", "+=", "ulNumBytes", ";", "DEBUG_PRINT", "(", "\"", "\\n", "\"", ",", "ulNumBytes", ")", ";", "ulReadIndex", "=", "(", "unsigned", "long", ")", "(", "pcData", "-", "g_pucUSBRxBuffer", ")", ";", "ulWriteIndex", "=", "sTxRing", ".", "ulWriteIndex", ";", "while", "(", "ulLoop", ")", "{", "if", "(", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", ">=", "'", "'", ")", "&&", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", "<=", "'", "'", ")", ")", "{", "g_pucUSBTxBuffer", "[", "ulWriteIndex", "]", "=", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", "-", "'", "'", ")", "+", "'", "'", ";", "}", "else", "{", "if", "(", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", ">=", "'", "'", ")", "&&", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", "<=", "'", "'", ")", ")", "{", "g_pucUSBTxBuffer", "[", "ulWriteIndex", "]", "=", "(", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", "-", "'", "'", ")", "+", "'", "'", ";", "}", "else", "{", "g_pucUSBTxBuffer", "[", "ulWriteIndex", "]", "=", "g_pucUSBRxBuffer", "[", "ulReadIndex", "]", ";", "}", "}", "ulWriteIndex", "++", ";", "ulWriteIndex", "=", "(", "ulWriteIndex", "==", "BULK_BUFFER_SIZE", ")", "?", "0", ":", "ulWriteIndex", ";", "ulReadIndex", "++", ";", "ulReadIndex", "=", "(", "ulReadIndex", "==", "BULK_BUFFER_SIZE", ")", "?", "0", ":", "ulReadIndex", ";", "ulLoop", "--", ";", "}", "USBBufferDataWritten", "(", "&", "g_sTxBuffer", ",", "ulCount", ")", ";", "DEBUG_PRINT", "(", "\"", "\\n", "\"", ",", "ulCount", ")", ";", "return", "(", "ulCount", ")", ";", "}" ]
Receive new data and echo it back to the host.
[ "Receive", "new", "data", "and", "echo", "it", "back", "to", "the", "host", "." ]
[ "//\r", "// Get the current buffer information to allow us to write directly to\r", "// the transmit buffer (we already have enough information from the\r", "// parameters to access the receive buffer directly).\r", "//\r", "//\r", "// How much space is there in the transmit buffer?\r", "//\r", "//\r", "// How many characters can we process this time round?\r", "//\r", "//\r", "// Update our receive counter.\r", "//\r", "//\r", "// Dump a debug message.\r", "//\r", "//\r", "// Set up to process the characters by directly accessing the USB buffers.\r", "//\r", "//\r", "// Copy from the receive buffer to the transmit buffer converting\r", "// character case on the way.\r", "//\r", "//\r", "// Is this a lower case character?\r", "//\r", "//\r", "// Convert to upper case and write to the transmit buffer.\r", "//\r", "//\r", "// Is this an upper case character?\r", "//\r", "//\r", "// Convert to lower case and write to the transmit buffer.\r", "//\r", "//\r", "// Copy the received character to the transmit buffer.\r", "//\r", "//\r", "// Move to the next character taking care to adjust the pointer for\r", "// the buffer wrap if necessary.\r", "//\r", "//\r", "// We've processed the data in place so now send the processed data\r", "// back to the host.\r", "//\r", "//\r", "// We processed as much data as we can directly from the receive buffer so\r", "// we need to return the number of bytes to allow the lower layer to\r", "// update its read pointer appropriately.\r", "//\r" ]
[ { "param": "psDevice", "type": "tUSBDBulkDevice" }, { "param": "pcData", "type": "unsigned char" }, { "param": "ulNumBytes", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "psDevice", "type": "tUSBDBulkDevice", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pcData", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulNumBytes", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5b9eda080452aaab39e2e106980f463e8b5c3bca
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/usb_dev_bulk/usb_dev_bulk.c
[ "BSD-3-Clause" ]
C
DisplayStatus
void
void DisplayStatus(tContext *psContext, char *pcStatus) { tRectangle rectLine; long lY; // // Calculate the Y coordinate of the top left of the character cell // for our line of text. // lY = (GrContextDpyHeightGet(psContext) / 4) - (GrFontHeightGet(TEXT_FONT) / 2); // // Determine the bounding rectangle for this line of text. We add 4 pixels // to the height just to ensure that we clear a couple of pixels above and // below the line of text. // rectLine.sXMin = 0; rectLine.sXMax = GrContextDpyWidthGet(psContext) - 1; rectLine.sYMin = lY; rectLine.sYMax = lY + GrFontHeightGet(TEXT_FONT) + 3; // // Clear the line with black. // GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(psContext, &rectLine); // // Draw the new status string // DEBUG_PRINT("%s\n", pcStatus); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(psContext, pcStatus, -1, GrContextDpyWidthGet(psContext) / 2, GrContextDpyHeightGet(psContext) / 4 , false); }
//***************************************************************************** // // Shows the status string on the color STN display. // // \param psContext is a pointer to the graphics context representing the // display. // \param pcStatus is a pointer to the string to be shown. // //*****************************************************************************
Shows the status string on the color STN display. \param psContext is a pointer to the graphics context representing the display. \param pcStatus is a pointer to the string to be shown.
[ "Shows", "the", "status", "string", "on", "the", "color", "STN", "display", ".", "\\", "param", "psContext", "is", "a", "pointer", "to", "the", "graphics", "context", "representing", "the", "display", ".", "\\", "param", "pcStatus", "is", "a", "pointer", "to", "the", "string", "to", "be", "shown", "." ]
void DisplayStatus(tContext *psContext, char *pcStatus) { tRectangle rectLine; long lY; lY = (GrContextDpyHeightGet(psContext) / 4) - (GrFontHeightGet(TEXT_FONT) / 2); rectLine.sXMin = 0; rectLine.sXMax = GrContextDpyWidthGet(psContext) - 1; rectLine.sYMin = lY; rectLine.sYMax = lY + GrFontHeightGet(TEXT_FONT) + 3; GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(psContext, &rectLine); DEBUG_PRINT("%s\n", pcStatus); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(psContext, pcStatus, -1, GrContextDpyWidthGet(psContext) / 2, GrContextDpyHeightGet(psContext) / 4 , false); }
[ "void", "DisplayStatus", "(", "tContext", "*", "psContext", ",", "char", "*", "pcStatus", ")", "{", "tRectangle", "rectLine", ";", "long", "lY", ";", "lY", "=", "(", "GrContextDpyHeightGet", "(", "psContext", ")", "/", "4", ")", "-", "(", "GrFontHeightGet", "(", "TEXT_FONT", ")", "/", "2", ")", ";", "rectLine", ".", "sXMin", "=", "0", ";", "rectLine", ".", "sXMax", "=", "GrContextDpyWidthGet", "(", "psContext", ")", "-", "1", ";", "rectLine", ".", "sYMin", "=", "lY", ";", "rectLine", ".", "sYMax", "=", "lY", "+", "GrFontHeightGet", "(", "TEXT_FONT", ")", "+", "3", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "ClrBlack", ")", ";", "GrRectFill", "(", "psContext", ",", "&", "rectLine", ")", ";", "DEBUG_PRINT", "(", "\"", "\\n", "\"", ",", "pcStatus", ")", ";", "GrContextForegroundSet", "(", "&", "g_sContext", ",", "ClrWhite", ")", ";", "GrStringDrawCentered", "(", "psContext", ",", "pcStatus", ",", "-1", ",", "GrContextDpyWidthGet", "(", "psContext", ")", "/", "2", ",", "GrContextDpyHeightGet", "(", "psContext", ")", "/", "4", ",", "false", ")", ";", "}" ]
Shows the status string on the color STN display.
[ "Shows", "the", "status", "string", "on", "the", "color", "STN", "display", "." ]
[ "//\r", "// Calculate the Y coordinate of the top left of the character cell\r", "// for our line of text.\r", "//\r", "//\r", "// Determine the bounding rectangle for this line of text. We add 4 pixels\r", "// to the height just to ensure that we clear a couple of pixels above and\r", "// below the line of text.\r", "//\r", "//\r", "// Clear the line with black.\r", "//\r", "//\r", "// Draw the new status string\r", "//\r" ]
[ { "param": "psContext", "type": "tContext" }, { "param": "pcStatus", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "psContext", "type": "tContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pcStatus", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5b9eda080452aaab39e2e106980f463e8b5c3bca
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/usb_dev_bulk/usb_dev_bulk.c
[ "BSD-3-Clause" ]
C
TxHandler
null
unsigned long TxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { // // We are not required to do anything in response to any transmit event // in this example. All we do is update our transmit counter. // if(ulEvent == USB_EVENT_TX_COMPLETE) { g_ulTxCount += ulMsgValue; } // // Dump a debug message. // DEBUG_PRINT("TX complete %d\n", ulMsgValue); return(0); }
//***************************************************************************** // // Handles bulk driver notifications related to the transmit channel (data to // the USB host). // // \param pvCBData is the client-supplied callback pointer for this channel. // \param ulEvent identifies the event we are being notified about. // \param ulMsgValue is an event-specific value. // \param pvMsgData is an event-specific pointer. // // This function is called by the bulk driver to notify us of any events // related to operation of the transmit data channel (the IN channel carrying // data to the USB host). // // \return The return value is event-specific. // //*****************************************************************************
Handles bulk driver notifications related to the transmit channel (data to the USB host). \param pvCBData is the client-supplied callback pointer for this channel. \param ulEvent identifies the event we are being notified about. \param ulMsgValue is an event-specific value. \param pvMsgData is an event-specific pointer. This function is called by the bulk driver to notify us of any events related to operation of the transmit data channel (the IN channel carrying data to the USB host). \return The return value is event-specific.
[ "Handles", "bulk", "driver", "notifications", "related", "to", "the", "transmit", "channel", "(", "data", "to", "the", "USB", "host", ")", ".", "\\", "param", "pvCBData", "is", "the", "client", "-", "supplied", "callback", "pointer", "for", "this", "channel", ".", "\\", "param", "ulEvent", "identifies", "the", "event", "we", "are", "being", "notified", "about", ".", "\\", "param", "ulMsgValue", "is", "an", "event", "-", "specific", "value", ".", "\\", "param", "pvMsgData", "is", "an", "event", "-", "specific", "pointer", ".", "This", "function", "is", "called", "by", "the", "bulk", "driver", "to", "notify", "us", "of", "any", "events", "related", "to", "operation", "of", "the", "transmit", "data", "channel", "(", "the", "IN", "channel", "carrying", "data", "to", "the", "USB", "host", ")", ".", "\\", "return", "The", "return", "value", "is", "event", "-", "specific", "." ]
unsigned long TxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { if(ulEvent == USB_EVENT_TX_COMPLETE) { g_ulTxCount += ulMsgValue; } DEBUG_PRINT("TX complete %d\n", ulMsgValue); return(0); }
[ "unsigned", "long", "TxHandler", "(", "void", "*", "pvCBData", ",", "unsigned", "long", "ulEvent", ",", "unsigned", "long", "ulMsgValue", ",", "void", "*", "pvMsgData", ")", "{", "if", "(", "ulEvent", "==", "USB_EVENT_TX_COMPLETE", ")", "{", "g_ulTxCount", "+=", "ulMsgValue", ";", "}", "DEBUG_PRINT", "(", "\"", "\\n", "\"", ",", "ulMsgValue", ")", ";", "return", "(", "0", ")", ";", "}" ]
Handles bulk driver notifications related to the transmit channel (data to the USB host).
[ "Handles", "bulk", "driver", "notifications", "related", "to", "the", "transmit", "channel", "(", "data", "to", "the", "USB", "host", ")", "." ]
[ "//\r", "// We are not required to do anything in response to any transmit event\r", "// in this example. All we do is update our transmit counter.\r", "//\r", "//\r", "// Dump a debug message.\r", "//\r" ]
[ { "param": "pvCBData", "type": "void" }, { "param": "ulEvent", "type": "unsigned long" }, { "param": "ulMsgValue", "type": "unsigned long" }, { "param": "pvMsgData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvCBData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulEvent", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulMsgValue", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvMsgData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5b9eda080452aaab39e2e106980f463e8b5c3bca
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/usb_dev_bulk/usb_dev_bulk.c
[ "BSD-3-Clause" ]
C
RxHandler
null
unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { // // Which event are we being sent? // switch(ulEvent) { // // We are connected to a host and communication is now possible. // case USB_EVENT_CONNECTED: { g_bUSBConfigured = true; g_pcStatus = "Host connected."; g_ulFlags |= COMMAND_STATUS_UPDATE; // // Flush our buffers. // USBBufferFlush(&g_sTxBuffer); USBBufferFlush(&g_sRxBuffer); break; } // // The host has disconnected. // case USB_EVENT_DISCONNECTED: { g_bUSBConfigured = false; g_pcStatus = "Host disconnected."; g_ulFlags |= COMMAND_STATUS_UPDATE; break; } // // A new packet has been received. // case USB_EVENT_RX_AVAILABLE: { tUSBDBulkDevice *psDevice; // // Get a pointer to our instance data from the callback data // parameter. // psDevice = (tUSBDBulkDevice *)pvCBData; // // Read the new packet and echo it back to the host. // return(EchoNewDataToHost(psDevice, pvMsgData, ulMsgValue)); } // // Ignore SUSPEND and RESUME for now. // case USB_EVENT_SUSPEND: case USB_EVENT_RESUME: break; // // Ignore all other events and return 0. // default: break; } return(0); }
//***************************************************************************** // // Handles bulk driver notifications related to the receive channel (data from // the USB host). // // \param pvCBData is the client-supplied callback pointer for this channel. // \param ulEvent identifies the event we are being notified about. // \param ulMsgValue is an event-specific value. // \param pvMsgData is an event-specific pointer. // // This function is called by the bulk driver to notify us of any events // related to operation of the receive data channel (the OUT channel carrying // data from the USB host). // // \return The return value is event-specific. // //*****************************************************************************
Handles bulk driver notifications related to the receive channel (data from the USB host). \param pvCBData is the client-supplied callback pointer for this channel. \param ulEvent identifies the event we are being notified about. \param ulMsgValue is an event-specific value. \param pvMsgData is an event-specific pointer. This function is called by the bulk driver to notify us of any events related to operation of the receive data channel (the OUT channel carrying data from the USB host). \return The return value is event-specific.
[ "Handles", "bulk", "driver", "notifications", "related", "to", "the", "receive", "channel", "(", "data", "from", "the", "USB", "host", ")", ".", "\\", "param", "pvCBData", "is", "the", "client", "-", "supplied", "callback", "pointer", "for", "this", "channel", ".", "\\", "param", "ulEvent", "identifies", "the", "event", "we", "are", "being", "notified", "about", ".", "\\", "param", "ulMsgValue", "is", "an", "event", "-", "specific", "value", ".", "\\", "param", "pvMsgData", "is", "an", "event", "-", "specific", "pointer", ".", "This", "function", "is", "called", "by", "the", "bulk", "driver", "to", "notify", "us", "of", "any", "events", "related", "to", "operation", "of", "the", "receive", "data", "channel", "(", "the", "OUT", "channel", "carrying", "data", "from", "the", "USB", "host", ")", ".", "\\", "return", "The", "return", "value", "is", "event", "-", "specific", "." ]
unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { switch(ulEvent) { case USB_EVENT_CONNECTED: { g_bUSBConfigured = true; g_pcStatus = "Host connected."; g_ulFlags |= COMMAND_STATUS_UPDATE; USBBufferFlush(&g_sTxBuffer); USBBufferFlush(&g_sRxBuffer); break; } case USB_EVENT_DISCONNECTED: { g_bUSBConfigured = false; g_pcStatus = "Host disconnected."; g_ulFlags |= COMMAND_STATUS_UPDATE; break; } case USB_EVENT_RX_AVAILABLE: { tUSBDBulkDevice *psDevice; psDevice = (tUSBDBulkDevice *)pvCBData; return(EchoNewDataToHost(psDevice, pvMsgData, ulMsgValue)); } case USB_EVENT_SUSPEND: case USB_EVENT_RESUME: break; default: break; } return(0); }
[ "unsigned", "long", "RxHandler", "(", "void", "*", "pvCBData", ",", "unsigned", "long", "ulEvent", ",", "unsigned", "long", "ulMsgValue", ",", "void", "*", "pvMsgData", ")", "{", "switch", "(", "ulEvent", ")", "{", "case", "USB_EVENT_CONNECTED", ":", "{", "g_bUSBConfigured", "=", "true", ";", "g_pcStatus", "=", "\"", "\"", ";", "g_ulFlags", "|=", "COMMAND_STATUS_UPDATE", ";", "USBBufferFlush", "(", "&", "g_sTxBuffer", ")", ";", "USBBufferFlush", "(", "&", "g_sRxBuffer", ")", ";", "break", ";", "}", "case", "USB_EVENT_DISCONNECTED", ":", "{", "g_bUSBConfigured", "=", "false", ";", "g_pcStatus", "=", "\"", "\"", ";", "g_ulFlags", "|=", "COMMAND_STATUS_UPDATE", ";", "break", ";", "}", "case", "USB_EVENT_RX_AVAILABLE", ":", "{", "tUSBDBulkDevice", "*", "psDevice", ";", "psDevice", "=", "(", "tUSBDBulkDevice", "*", ")", "pvCBData", ";", "return", "(", "EchoNewDataToHost", "(", "psDevice", ",", "pvMsgData", ",", "ulMsgValue", ")", ")", ";", "}", "case", "USB_EVENT_SUSPEND", ":", "case", "USB_EVENT_RESUME", ":", "break", ";", "default", ":", "break", ";", "}", "return", "(", "0", ")", ";", "}" ]
Handles bulk driver notifications related to the receive channel (data from the USB host).
[ "Handles", "bulk", "driver", "notifications", "related", "to", "the", "receive", "channel", "(", "data", "from", "the", "USB", "host", ")", "." ]
[ "//\r", "// Which event are we being sent?\r", "//\r", "//\r", "// We are connected to a host and communication is now possible.\r", "//\r", "//\r", "// Flush our buffers.\r", "//\r", "//\r", "// The host has disconnected.\r", "//\r", "//\r", "// A new packet has been received.\r", "//\r", "//\r", "// Get a pointer to our instance data from the callback data\r", "// parameter.\r", "//\r", "//\r", "// Read the new packet and echo it back to the host.\r", "//\r", "//\r", "// Ignore SUSPEND and RESUME for now.\r", "//\r", "//\r", "// Ignore all other events and return 0.\r", "//\r" ]
[ { "param": "pvCBData", "type": "void" }, { "param": "ulEvent", "type": "unsigned long" }, { "param": "ulMsgValue", "type": "unsigned long" }, { "param": "pvMsgData", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pvCBData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulEvent", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ulMsgValue", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvMsgData", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
read_page
void
void read_page(int page, void *buffer) { memcpy(buffer, g_pulAdventure + (page * (PAGE_SIZE / 4)), PAGE_SIZE); }
//***************************************************************************** // // This function reads a page from the story file. // //*****************************************************************************
This function reads a page from the story file.
[ "This", "function", "reads", "a", "page", "from", "the", "story", "file", "." ]
void read_page(int page, void *buffer) { memcpy(buffer, g_pulAdventure + (page * (PAGE_SIZE / 4)), PAGE_SIZE); }
[ "void", "read_page", "(", "int", "page", ",", "void", "*", "buffer", ")", "{", "memcpy", "(", "buffer", ",", "g_pulAdventure", "+", "(", "page", "*", "(", "PAGE_SIZE", "/", "4", ")", ")", ",", "PAGE_SIZE", ")", ";", "}" ]
This function reads a page from the story file.
[ "This", "function", "reads", "a", "page", "from", "the", "story", "file", "." ]
[]
[ { "param": "page", "type": "int" }, { "param": "buffer", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "page", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
save
int
int save(void) { store_operand(0); return(1); }
//***************************************************************************** // // This function saves the current game state. This is a NOP since saving is // not supported. // //*****************************************************************************
This function saves the current game state. This is a NOP since saving is not supported.
[ "This", "function", "saves", "the", "current", "game", "state", ".", "This", "is", "a", "NOP", "since", "saving", "is", "not", "supported", "." ]
int save(void) { store_operand(0); return(1); }
[ "int", "save", "(", "void", ")", "{", "store_operand", "(", "0", ")", ";", "return", "(", "1", ")", ";", "}" ]
This function saves the current game state.
[ "This", "function", "saves", "the", "current", "game", "state", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
restore
int
int restore(void) { store_operand(0); return(1); }
//***************************************************************************** // // This function restores the game state. // //*****************************************************************************
This function restores the game state.
[ "This", "function", "restores", "the", "game", "state", "." ]
int restore(void) { store_operand(0); return(1); }
[ "int", "restore", "(", "void", ")", "{", "store_operand", "(", "0", ")", ";", "return", "(", "1", ")", ";", "}" ]
This function restores the game state.
[ "This", "function", "restores", "the", "game", "state", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
undo_save
void
void undo_save(void) { store_operand((zword_t)-1); }
//***************************************************************************** // // This function undoes a save operation. // //*****************************************************************************
This function undoes a save operation.
[ "This", "function", "undoes", "a", "save", "operation", "." ]
void undo_save(void) { store_operand((zword_t)-1); }
[ "void", "undo_save", "(", "void", ")", "{", "store_operand", "(", "(", "zword_t", ")", "-", "1", ")", ";", "}" ]
This function undoes a save operation.
[ "This", "function", "undoes", "a", "save", "operation", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
undo_restore
void
void undo_restore(void) { store_operand((zword_t)-1); }
//***************************************************************************** // // This function undoes a restore operation. // //*****************************************************************************
This function undoes a restore operation.
[ "This", "function", "undoes", "a", "restore", "operation", "." ]
void undo_restore(void) { store_operand((zword_t)-1); }
[ "void", "undo_restore", "(", "void", ")", "{", "store_operand", "(", "(", "zword_t", ")", "-", "1", ")", ";", "}" ]
This function undoes a restore operation.
[ "This", "function", "undoes", "a", "restore", "operation", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8fd092069aefd88ef24bb209300c84f43d032982
junyanl-code/Luminary-Micro-Library
boards/ek-lm3s9d92/qs-adventure/fileio.c
[ "BSD-3-Clause" ]
C
playback_line
int
int playback_line(int buflen, char *buffer, int *read_size) { return(-1); }
//***************************************************************************** // // This function reads a line from the record file. // //*****************************************************************************
This function reads a line from the record file.
[ "This", "function", "reads", "a", "line", "from", "the", "record", "file", "." ]
int playback_line(int buflen, char *buffer, int *read_size) { return(-1); }
[ "int", "playback_line", "(", "int", "buflen", ",", "char", "*", "buffer", ",", "int", "*", "read_size", ")", "{", "return", "(", "-1", ")", ";", "}" ]
This function reads a line from the record file.
[ "This", "function", "reads", "a", "line", "from", "the", "record", "file", "." ]
[]
[ { "param": "buflen", "type": "int" }, { "param": "buffer", "type": "char" }, { "param": "read_size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buflen", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "read_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8fdd15be6d81b490940a0ee57bb9c50e8f7d2abd
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96-em2-cc2500-simpliciti/simpliciti_hub_dev/simpliciti_hub_dev.c
[ "BSD-3-Clause" ]
C
UpdateLEDWidget
void
void UpdateLEDWidget(unsigned long ulLED, tBoolean bOn) { tPushButtonWidget *pButton; // // Which widget are we dealing with? // pButton = (ulLED == 1) ? &g_sLED1 : &g_sLED2; // // Turn the LED on or off by setting the background fill color // appropriately. // PushButtonFillColorSet(pButton, g_ulLEDColors[ulLED - 1][bOn]); PushButtonFillColorPressedSet(pButton, g_ulLEDColors[ulLED - 1][bOn]); // // Ensure that the LED is repainted. This will occur on the next call to // WidgetMessageQueueProcess(). // WidgetPaint((tWidget *)pButton); // // Process the messages in the widget message queue. // WidgetMessageQueueProcess(); }
//***************************************************************************** // // Draw one of the LED widgets in a particular state. // //*****************************************************************************
Draw one of the LED widgets in a particular state.
[ "Draw", "one", "of", "the", "LED", "widgets", "in", "a", "particular", "state", "." ]
void UpdateLEDWidget(unsigned long ulLED, tBoolean bOn) { tPushButtonWidget *pButton; pButton = (ulLED == 1) ? &g_sLED1 : &g_sLED2; PushButtonFillColorSet(pButton, g_ulLEDColors[ulLED - 1][bOn]); PushButtonFillColorPressedSet(pButton, g_ulLEDColors[ulLED - 1][bOn]); WidgetPaint((tWidget *)pButton); WidgetMessageQueueProcess(); }
[ "void", "UpdateLEDWidget", "(", "unsigned", "long", "ulLED", ",", "tBoolean", "bOn", ")", "{", "tPushButtonWidget", "*", "pButton", ";", "pButton", "=", "(", "ulLED", "==", "1", ")", "?", "&", "g_sLED1", ":", "&", "g_sLED2", ";", "PushButtonFillColorSet", "(", "pButton", ",", "g_ulLEDColors", "[", "ulLED", "-", "1", "]", "[", "bOn", "]", ")", ";", "PushButtonFillColorPressedSet", "(", "pButton", ",", "g_ulLEDColors", "[", "ulLED", "-", "1", "]", "[", "bOn", "]", ")", ";", "WidgetPaint", "(", "(", "tWidget", "*", ")", "pButton", ")", ";", "WidgetMessageQueueProcess", "(", ")", ";", "}" ]
Draw one of the LED widgets in a particular state.
[ "Draw", "one", "of", "the", "LED", "widgets", "in", "a", "particular", "state", "." ]
[ "//\r", "// Which widget are we dealing with?\r", "//\r", "//\r", "// Turn the LED on or off by setting the background fill color\r", "// appropriately.\r", "//\r", "//\r", "// Ensure that the LED is repainted. This will occur on the next call to\r", "// WidgetMessageQueueProcess().\r", "//\r", "//\r", "// Process the messages in the widget message queue.\r", "//\r" ]
[ { "param": "ulLED", "type": "unsigned long" }, { "param": "bOn", "type": "tBoolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulLED", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bOn", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8fdd15be6d81b490940a0ee57bb9c50e8f7d2abd
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96-em2-cc2500-simpliciti/simpliciti_hub_dev/simpliciti_hub_dev.c
[ "BSD-3-Clause" ]
C
SetSimpliciTIAddress
tBoolean
tBoolean SetSimpliciTIAddress(void) { unsigned long ulUser0, ulUser1; addr_t sAddr; // // Make sure we are using 4 byte addressing. // ASSERT(NET_ADDR_SIZE == 4); // // Get the MAC address from the non-volatile user registers. // ROM_FlashUserGet(&ulUser0, &ulUser1); // // Has the MAC address been programmed? // if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff)) { // // No - we don't have an address so return a failure. // UpdateStatus(false, "Flash user registers are clear"); UpdateStatus(true, "Error - address not set!"); return(false); } else { // // The MAC address is stored with 3 bytes in each of the 2 flash user // registers. Extract the least significant 4 MAC bytes for use as the // SimpliciTI device address. // sAddr.addr[0] = ((ulUser1 >> 16) & 0xff); sAddr.addr[1] = ((ulUser1 >> 8) & 0xff); sAddr.addr[2] = ((ulUser1 >> 0) & 0xff); sAddr.addr[3] = ((ulUser0 >> 16) & 0xff); // // SimpliciTI requires that the first byte of the device address is // never either 0x00 or 0xFF so we check for these cases and invert the // first bit if either is detected. This does result in the // possibility of two devices having the same address but, for example // purposes, is likely to be fine. // if((sAddr.addr[0] == 0x00) || (sAddr.addr[0] == 0xFF)) { sAddr.addr[0] ^= 0x80; } // // Tell the SimpliciTI stack which device address we want to use. // SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &sAddr); } // // If we get here, all is well. // return(true); }
//***************************************************************************** // // Set the SimpliciTI device address as the least significant 4 digits of the // device Ethernet MAC address. This ensures that the address is unique across // Stellaris devices. If the MAC address has not been set, we return false to // indicate failure. // //*****************************************************************************
Set the SimpliciTI device address as the least significant 4 digits of the device Ethernet MAC address. This ensures that the address is unique across Stellaris devices. If the MAC address has not been set, we return false to indicate failure.
[ "Set", "the", "SimpliciTI", "device", "address", "as", "the", "least", "significant", "4", "digits", "of", "the", "device", "Ethernet", "MAC", "address", ".", "This", "ensures", "that", "the", "address", "is", "unique", "across", "Stellaris", "devices", ".", "If", "the", "MAC", "address", "has", "not", "been", "set", "we", "return", "false", "to", "indicate", "failure", "." ]
tBoolean SetSimpliciTIAddress(void) { unsigned long ulUser0, ulUser1; addr_t sAddr; ASSERT(NET_ADDR_SIZE == 4); ROM_FlashUserGet(&ulUser0, &ulUser1); if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff)) { UpdateStatus(false, "Flash user registers are clear"); UpdateStatus(true, "Error - address not set!"); return(false); } else { sAddr.addr[0] = ((ulUser1 >> 16) & 0xff); sAddr.addr[1] = ((ulUser1 >> 8) & 0xff); sAddr.addr[2] = ((ulUser1 >> 0) & 0xff); sAddr.addr[3] = ((ulUser0 >> 16) & 0xff); if((sAddr.addr[0] == 0x00) || (sAddr.addr[0] == 0xFF)) { sAddr.addr[0] ^= 0x80; } SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &sAddr); } return(true); }
[ "tBoolean", "SetSimpliciTIAddress", "(", "void", ")", "{", "unsigned", "long", "ulUser0", ",", "ulUser1", ";", "addr_t", "sAddr", ";", "ASSERT", "(", "NET_ADDR_SIZE", "==", "4", ")", ";", "ROM_FlashUserGet", "(", "&", "ulUser0", ",", "&", "ulUser1", ")", ";", "if", "(", "(", "ulUser0", "==", "0xffffffff", ")", "||", "(", "ulUser1", "==", "0xffffffff", ")", ")", "{", "UpdateStatus", "(", "false", ",", "\"", "\"", ")", ";", "UpdateStatus", "(", "true", ",", "\"", "\"", ")", ";", "return", "(", "false", ")", ";", "}", "else", "{", "sAddr", ".", "addr", "[", "0", "]", "=", "(", "(", "ulUser1", ">>", "16", ")", "&", "0xff", ")", ";", "sAddr", ".", "addr", "[", "1", "]", "=", "(", "(", "ulUser1", ">>", "8", ")", "&", "0xff", ")", ";", "sAddr", ".", "addr", "[", "2", "]", "=", "(", "(", "ulUser1", ">>", "0", ")", "&", "0xff", ")", ";", "sAddr", ".", "addr", "[", "3", "]", "=", "(", "(", "ulUser0", ">>", "16", ")", "&", "0xff", ")", ";", "if", "(", "(", "sAddr", ".", "addr", "[", "0", "]", "==", "0x00", ")", "||", "(", "sAddr", ".", "addr", "[", "0", "]", "==", "0xFF", ")", ")", "{", "sAddr", ".", "addr", "[", "0", "]", "^=", "0x80", ";", "}", "SMPL_Ioctl", "(", "IOCTL_OBJ_ADDR", ",", "IOCTL_ACT_SET", ",", "&", "sAddr", ")", ";", "}", "return", "(", "true", ")", ";", "}" ]
Set the SimpliciTI device address as the least significant 4 digits of the device Ethernet MAC address.
[ "Set", "the", "SimpliciTI", "device", "address", "as", "the", "least", "significant", "4", "digits", "of", "the", "device", "Ethernet", "MAC", "address", "." ]
[ "//\r", "// Make sure we are using 4 byte addressing.\r", "//\r", "//\r", "// Get the MAC address from the non-volatile user registers.\r", "//\r", "//\r", "// Has the MAC address been programmed?\r", "//\r", "//\r", "// No - we don't have an address so return a failure.\r", "//\r", "//\r", "// The MAC address is stored with 3 bytes in each of the 2 flash user\r", "// registers. Extract the least significant 4 MAC bytes for use as the\r", "// SimpliciTI device address.\r", "//\r", "//\r", "// SimpliciTI requires that the first byte of the device address is\r", "// never either 0x00 or 0xFF so we check for these cases and invert the\r", "// first bit if either is detected. This does result in the\r", "// possibility of two devices having the same address but, for example\r", "// purposes, is likely to be fine.\r", "//\r", "//\r", "// Tell the SimpliciTI stack which device address we want to use.\r", "//\r", "//\r", "// If we get here, all is well.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8fdd15be6d81b490940a0ee57bb9c50e8f7d2abd
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96-em2-cc2500-simpliciti/simpliciti_hub_dev/simpliciti_hub_dev.c
[ "BSD-3-Clause" ]
C
LinkTo
void
static void LinkTo(void) { uint8_t pucMsg[2]; uint8_t ucMisses, ucDone; uint8_t ucNoAck; smplStatus_t eRetcode; unsigned long ulButton; UpdateStatus(false, "Linking to Access Point"); // // Keep trying to link. Flash our "LEDs" while these attempts continue. // while (SMPL_SUCCESS != SMPL_Link(&g_sLinkID)) { ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // // Turn off both LEDs now that we are linked. // SetLED(1, false); SetLED(2, false); // // Tell the user all is well. // UpdateStatus(false, "Link successful"); // // Put the radio to sleep until a button is pressed. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); // // Start of the main button processing loop. // while (1) { // // Grab the button press flag and clear it. We do this since the flag // could be changed during the loop whenever function // WidgetMessageQueueProcess() is called and we don't want to miss any // button presses. // ulButton = g_ulButtonPressed; // // Has either button been pressed? // if (ulButton) { // // Clear the main button press flag. // g_ulButtonPressed = 0; // // Wake the radio up since we are about to need it. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); /* Set TID and designate which LED to toggle */ pucMsg[1] = ++g_ucTid; pucMsg[0] = (ulButton == 1) ? 1 : 2; ucDone = 0; while (!ucDone) { // // Remember that we have yet to receive an ack from the AP. // ucNoAck = 0; // // Try sending the message MISSES_IN_A_ROW times looking for an // ack after each transmission. // for (ucMisses = 0; ucMisses < MISSES_IN_A_ROW; ucMisses++) { // // Send the message and request acknowledgement. // eRetcode=SMPL_SendOpt(g_sLinkID, pucMsg, sizeof(pucMsg), SMPL_TXOPTION_ACKREQ); // // Did we get the ack? // if (eRetcode == SMPL_SUCCESS) { // // Yes - Message acked. We're done. Toggle LED 1 to // indicate ack received. */ ToggleLED(1); break; } // // Did we send the message but fail to get an ack back? // if (SMPL_NO_ACK == eRetcode) { // // Count ack failures. Could also fail because of CCA // and we don't want to scan in this case. // ucNoAck++; } } // // Did we fail to get an ack after every transmission? // if (MISSES_IN_A_ROW == ucNoAck) { // // Tell the user what happened. // UpdateStatus(false, "Channel changed?"); // // Message not acked. Toggle LED 2. // ToggleLED(2); #ifdef FREQUENCY_AGILITY // // At this point, we assume we're on the wrong channel so // look for the correct channel by using Ping to initiate a // scan when it gets no reply. With a successful ping try // sending the message again. Otherwise, for any error we // get we will wait until the next button press to try // again. // if (SMPL_SUCCESS != SMPL_Ping(g_sLinkID)) { ucDone = 1; } #else ucDone = 1; #endif /* FREQUENCY_AGILITY */ } else { // // We got the ack so drop out of the transmit loop. // ucDone = 1; UpdateStatus(false, "Toggled AP LED %d", ulButton); } } // // Now that we are finished with it, put the radio back to sleep. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); } // // Process the widget message queue. // WidgetMessageQueueProcess(); } }
//***************************************************************************** // // Link to the access point and continue processing local button requests // forever. This function is called following initialization in main() and // does not return. // //*****************************************************************************
Link to the access point and continue processing local button requests forever. This function is called following initialization in main() and does not return.
[ "Link", "to", "the", "access", "point", "and", "continue", "processing", "local", "button", "requests", "forever", ".", "This", "function", "is", "called", "following", "initialization", "in", "main", "()", "and", "does", "not", "return", "." ]
static void LinkTo(void) { uint8_t pucMsg[2]; uint8_t ucMisses, ucDone; uint8_t ucNoAck; smplStatus_t eRetcode; unsigned long ulButton; UpdateStatus(false, "Linking to Access Point"); while (SMPL_SUCCESS != SMPL_Link(&g_sLinkID)) { ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } SetLED(1, false); SetLED(2, false); UpdateStatus(false, "Link successful"); SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); while (1) { ulButton = g_ulButtonPressed; if (ulButton) { g_ulButtonPressed = 0; SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); pucMsg[1] = ++g_ucTid; pucMsg[0] = (ulButton == 1) ? 1 : 2; ucDone = 0; while (!ucDone) { ucNoAck = 0; for (ucMisses = 0; ucMisses < MISSES_IN_A_ROW; ucMisses++) { eRetcode=SMPL_SendOpt(g_sLinkID, pucMsg, sizeof(pucMsg), SMPL_TXOPTION_ACKREQ); if (eRetcode == SMPL_SUCCESS) { ToggleLED(1); break; } if (SMPL_NO_ACK == eRetcode) { ucNoAck++; } } if (MISSES_IN_A_ROW == ucNoAck) { UpdateStatus(false, "Channel changed?"); ToggleLED(2); #ifdef FREQUENCY_AGILITY if (SMPL_SUCCESS != SMPL_Ping(g_sLinkID)) { ucDone = 1; } #else ucDone = 1; #endif } else { ucDone = 1; UpdateStatus(false, "Toggled AP LED %d", ulButton); } } SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); } WidgetMessageQueueProcess(); } }
[ "static", "void", "LinkTo", "(", "void", ")", "{", "uint8_t", "pucMsg", "[", "2", "]", ";", "uint8_t", "ucMisses", ",", "ucDone", ";", "uint8_t", "ucNoAck", ";", "smplStatus_t", "eRetcode", ";", "unsigned", "long", "ulButton", ";", "UpdateStatus", "(", "false", ",", "\"", "\"", ")", ";", "while", "(", "SMPL_SUCCESS", "!=", "SMPL_Link", "(", "&", "g_sLinkID", ")", ")", "{", "ToggleLED", "(", "1", ")", ";", "ToggleLED", "(", "2", ")", ";", "SPIN_ABOUT_A_SECOND", ";", "}", "SetLED", "(", "1", ",", "false", ")", ";", "SetLED", "(", "2", ",", "false", ")", ";", "UpdateStatus", "(", "false", ",", "\"", "\"", ")", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_SLEEP", ",", "0", ")", ";", "while", "(", "1", ")", "{", "ulButton", "=", "g_ulButtonPressed", ";", "if", "(", "ulButton", ")", "{", "g_ulButtonPressed", "=", "0", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_AWAKE", ",", "0", ")", ";", "pucMsg", "[", "1", "]", "=", "++", "g_ucTid", ";", "pucMsg", "[", "0", "]", "=", "(", "ulButton", "==", "1", ")", "?", "1", ":", "2", ";", "ucDone", "=", "0", ";", "while", "(", "!", "ucDone", ")", "{", "ucNoAck", "=", "0", ";", "for", "(", "ucMisses", "=", "0", ";", "ucMisses", "<", "MISSES_IN_A_ROW", ";", "ucMisses", "++", ")", "{", "eRetcode", "=", "SMPL_SendOpt", "(", "g_sLinkID", ",", "pucMsg", ",", "sizeof", "(", "pucMsg", ")", ",", "SMPL_TXOPTION_ACKREQ", ")", ";", "if", "(", "eRetcode", "==", "SMPL_SUCCESS", ")", "{", "ToggleLED", "(", "1", ")", ";", "break", ";", "}", "if", "(", "SMPL_NO_ACK", "==", "eRetcode", ")", "{", "ucNoAck", "++", ";", "}", "}", "if", "(", "MISSES_IN_A_ROW", "==", "ucNoAck", ")", "{", "UpdateStatus", "(", "false", ",", "\"", "\"", ")", ";", "ToggleLED", "(", "2", ")", ";", "#ifdef", "FREQUENCY_AGILITY", "if", "(", "SMPL_SUCCESS", "!=", "SMPL_Ping", "(", "g_sLinkID", ")", ")", "{", "ucDone", "=", "1", ";", "}", "#else", "ucDone", "=", "1", ";", "#endif", "}", "else", "{", "ucDone", "=", "1", ";", "UpdateStatus", "(", "false", ",", "\"", "\"", ",", "ulButton", ")", ";", "}", "}", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_SLEEP", ",", "0", ")", ";", "}", "WidgetMessageQueueProcess", "(", ")", ";", "}", "}" ]
Link to the access point and continue processing local button requests forever.
[ "Link", "to", "the", "access", "point", "and", "continue", "processing", "local", "button", "requests", "forever", "." ]
[ "//\r", "// Keep trying to link. Flash our \"LEDs\" while these attempts continue.\r", "//\r", "//\r", "// Turn off both LEDs now that we are linked.\r", "//\r", "//\r", "// Tell the user all is well.\r", "//\r", "//\r", "// Put the radio to sleep until a button is pressed.\r", "//\r", "//\r", "// Start of the main button processing loop.\r", "//\r", "//\r", "// Grab the button press flag and clear it. We do this since the flag\r", "// could be changed during the loop whenever function\r", "// WidgetMessageQueueProcess() is called and we don't want to miss any\r", "// button presses.\r", "//\r", "//\r", "// Has either button been pressed?\r", "//\r", "//\r", "// Clear the main button press flag.\r", "//\r", "//\r", "// Wake the radio up since we are about to need it.\r", "//\r", "/* Set TID and designate which LED to toggle */", "//\r", "// Remember that we have yet to receive an ack from the AP.\r", "//\r", "//\r", "// Try sending the message MISSES_IN_A_ROW times looking for an\r", "// ack after each transmission.\r", "//\r", "//\r", "// Send the message and request acknowledgement.\r", "//\r", "//\r", "// Did we get the ack?\r", "//\r", "//\r", "// Yes - Message acked. We're done. Toggle LED 1 to\r", "// indicate ack received. */\r", "//\r", "// Did we send the message but fail to get an ack back?\r", "//\r", "//\r", "// Count ack failures. Could also fail because of CCA\r", "// and we don't want to scan in this case.\r", "//\r", "//\r", "// Did we fail to get an ack after every transmission?\r", "//\r", "//\r", "// Tell the user what happened.\r", "//\r", "//\r", "// Message not acked. Toggle LED 2.\r", "//\r", "//\r", "// At this point, we assume we're on the wrong channel so\r", "// look for the correct channel by using Ping to initiate a\r", "// scan when it gets no reply. With a successful ping try\r", "// sending the message again. Otherwise, for any error we\r", "// get we will wait until the next button press to try\r", "// again.\r", "//\r", "/* FREQUENCY_AGILITY */", "//\r", "// We got the ack so drop out of the transmit loop.\r", "//\r", "//\r", "// Now that we are finished with it, put the radio back to sleep.\r", "//\r", "//\r", "// Process the widget message queue.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
ecef1d1d1118d63e062255871e649c1f84379967
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc1101_433-simpliciti/simpliciti_cascade/simpliciti_cascade.c
[ "BSD-3-Clause" ]
C
UpdateStatus
void
void UpdateStatus(tBoolean bMainStatus, const char *pcString, ...) { va_list vaArgP; // // Start the varargs processing. // va_start(vaArgP, pcString); // // Call vsnprintf to format the text into the status string buffer. // uvsnprintf(g_pcStatus[bMainStatus ? 0 : 1], MAX_STATUS_STRING_LEN, pcString, vaArgP); // // End the varargs processing. // va_end(vaArgP); // // Update the status string on the display. // WidgetPaint(bMainStatus ? (tWidget *)&g_sMainStatus : (tWidget *)&g_sAlarmStatus); }
//***************************************************************************** // // Update one or other of the the status strings on the display. // //*****************************************************************************
Update one or other of the the status strings on the display.
[ "Update", "one", "or", "other", "of", "the", "the", "status", "strings", "on", "the", "display", "." ]
void UpdateStatus(tBoolean bMainStatus, const char *pcString, ...) { va_list vaArgP; va_start(vaArgP, pcString); uvsnprintf(g_pcStatus[bMainStatus ? 0 : 1], MAX_STATUS_STRING_LEN, pcString, vaArgP); va_end(vaArgP); WidgetPaint(bMainStatus ? (tWidget *)&g_sMainStatus : (tWidget *)&g_sAlarmStatus); }
[ "void", "UpdateStatus", "(", "tBoolean", "bMainStatus", ",", "const", "char", "*", "pcString", ",", "...", ")", "{", "va_list", "vaArgP", ";", "va_start", "(", "vaArgP", ",", "pcString", ")", ";", "uvsnprintf", "(", "g_pcStatus", "[", "bMainStatus", "?", "0", ":", "1", "]", ",", "MAX_STATUS_STRING_LEN", ",", "pcString", ",", "vaArgP", ")", ";", "va_end", "(", "vaArgP", ")", ";", "WidgetPaint", "(", "bMainStatus", "?", "(", "tWidget", "*", ")", "&", "g_sMainStatus", ":", "(", "tWidget", "*", ")", "&", "g_sAlarmStatus", ")", ";", "}" ]
Update one or other of the the status strings on the display.
[ "Update", "one", "or", "other", "of", "the", "the", "status", "strings", "on", "the", "display", "." ]
[ "//\r", "// Start the varargs processing.\r", "//\r", "//\r", "// Call vsnprintf to format the text into the status string buffer.\r", "//\r", "//\r", "// End the varargs processing.\r", "//\r", "//\r", "// Update the status string on the display.\r", "//\r" ]
[ { "param": "bMainStatus", "type": "tBoolean" }, { "param": "pcString", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bMainStatus", "type": "tBoolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pcString", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ecef1d1d1118d63e062255871e649c1f84379967
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc1101_433-simpliciti/simpliciti_cascade/simpliciti_cascade.c
[ "BSD-3-Clause" ]
C
OnAlarmButtonPress
void
void OnAlarmButtonPress(tWidget *pWidget) { // // Tell the user we're switching into "LinkTo" mode. // UpdateStatus(true, "Alarm raised!"); // // Set the button background to red and change the text. // PushButtonFillColorSet((tPushButtonWidget *)pWidget, BRIGHT_RED); PushButtonTextSet((tPushButtonWidget *)pWidget, "ALARM!"); WidgetPaint(pWidget); // // Set a flag indicating that the alarm has been raised. // g_bAlarmRaised = true; }
//***************************************************************************** // // Handler for the "Sound Alarm" button. // //*****************************************************************************
Handler for the "Sound Alarm" button.
[ "Handler", "for", "the", "\"", "Sound", "Alarm", "\"", "button", "." ]
void OnAlarmButtonPress(tWidget *pWidget) { UpdateStatus(true, "Alarm raised!"); PushButtonFillColorSet((tPushButtonWidget *)pWidget, BRIGHT_RED); PushButtonTextSet((tPushButtonWidget *)pWidget, "ALARM!"); WidgetPaint(pWidget); g_bAlarmRaised = true; }
[ "void", "OnAlarmButtonPress", "(", "tWidget", "*", "pWidget", ")", "{", "UpdateStatus", "(", "true", ",", "\"", "\"", ")", ";", "PushButtonFillColorSet", "(", "(", "tPushButtonWidget", "*", ")", "pWidget", ",", "BRIGHT_RED", ")", ";", "PushButtonTextSet", "(", "(", "tPushButtonWidget", "*", ")", "pWidget", ",", "\"", "\"", ")", ";", "WidgetPaint", "(", "pWidget", ")", ";", "g_bAlarmRaised", "=", "true", ";", "}" ]
Handler for the "Sound Alarm" button.
[ "Handler", "for", "the", "\"", "Sound", "Alarm", "\"", "button", "." ]
[ "//\r", "// Tell the user we're switching into \"LinkTo\" mode.\r", "//\r", "//\r", "// Set the button background to red and change the text.\r", "//\r", "//\r", "// Set a flag indicating that the alarm has been raised.\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": [] }
ecef1d1d1118d63e062255871e649c1f84379967
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc1101_433-simpliciti/simpliciti_cascade/simpliciti_cascade.c
[ "BSD-3-Clause" ]
C
Start2Babble
void
void Start2Babble() { uint8_t pucMsg[1]; // // Tell the user what we are doing. // UpdateStatus(false, "Retransmitting alert"); /* wake up radio. */ SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); // // Send the bad news message. In a real application, to prevent confusion // with different "networks" such as neighboring smoke alarm arrays send a // token controlled by a DIP switch, for example, and filter in this token. // pucMsg[0] = BAD_NEWS; // // Keep sending the alert forever. In "real life" you would provide a method // to stop sending the alert when the sensor was reset or the alert condition // cleared. // while (1) { // // Wait 100mS or so. // ApplicationDelay(100); // // Babble... // SMPL_Send(SMPL_LINKID_USER_UUD, pucMsg, sizeof(pucMsg)); ToggleLED(2); } }
//***************************************************************************** // // This function is called whenever an alert is received from another device. // It retransmits the alert every 100mS and toggles an LED to indicate that // the alarm has been sounded. // // This function does not return. // //*****************************************************************************
This function is called whenever an alert is received from another device. It retransmits the alert every 100mS and toggles an LED to indicate that the alarm has been sounded. This function does not return.
[ "This", "function", "is", "called", "whenever", "an", "alert", "is", "received", "from", "another", "device", ".", "It", "retransmits", "the", "alert", "every", "100mS", "and", "toggles", "an", "LED", "to", "indicate", "that", "the", "alarm", "has", "been", "sounded", ".", "This", "function", "does", "not", "return", "." ]
void Start2Babble() { uint8_t pucMsg[1]; UpdateStatus(false, "Retransmitting alert"); SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); pucMsg[0] = BAD_NEWS; while (1) { ApplicationDelay(100); SMPL_Send(SMPL_LINKID_USER_UUD, pucMsg, sizeof(pucMsg)); ToggleLED(2); } }
[ "void", "Start2Babble", "(", ")", "{", "uint8_t", "pucMsg", "[", "1", "]", ";", "UpdateStatus", "(", "false", ",", "\"", "\"", ")", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_AWAKE", ",", "0", ")", ";", "pucMsg", "[", "0", "]", "=", "BAD_NEWS", ";", "while", "(", "1", ")", "{", "ApplicationDelay", "(", "100", ")", ";", "SMPL_Send", "(", "SMPL_LINKID_USER_UUD", ",", "pucMsg", ",", "sizeof", "(", "pucMsg", ")", ")", ";", "ToggleLED", "(", "2", ")", ";", "}", "}" ]
This function is called whenever an alert is received from another device.
[ "This", "function", "is", "called", "whenever", "an", "alert", "is", "received", "from", "another", "device", "." ]
[ "//\r", "// Tell the user what we are doing.\r", "//\r", "/* wake up radio. */", "//\r", "// Send the bad news message. In a real application, to prevent confusion\r", "// with different \"networks\" such as neighboring smoke alarm arrays send a\r", "// token controlled by a DIP switch, for example, and filter in this token.\r", "//\r", "//\r", "// Keep sending the alert forever. In \"real life\" you would provide a method\r", "// to stop sending the alert when the sensor was reset or the alert condition\r", "// cleared.\r", "//\r", "//\r", "// Wait 100mS or so.\r", "//\r", "//\r", "// Babble...\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
ecef1d1d1118d63e062255871e649c1f84379967
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9b96-em2-cc1101_433-simpliciti/simpliciti_cascade/simpliciti_cascade.c
[ "BSD-3-Clause" ]
C
MonitorForBadNews
void
void MonitorForBadNews(void) { uint8_t pucMsg[1], ucLen; unsigned long ulLoop; // // Turn off LEDs. Check for bad news will toggle one LED. The other LED will // toggle when bad news message is sent. // SetLED(2, false); SetLED(1, false); // // Start with radio sleeping. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); while (1) { // // Spoof MCU sleeping... // for (ulLoop = 0; ulLoop < CHECK_RATE; ulLoop++) { SPIN_ABOUT_A_SECOND; } ToggleLED(1); // // Check the "sensor" to see if we need to send an alert. // if (g_bAlarmRaised) { // // The sensor has been activated. Start babbling. This function // will not return. // Start2Babble(); } // // Wake up the radio and receiver so that we can listen for others // babbling. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0); // // Stay on "long enough" to see if someone else is babbling // SPIN_ABOUT_A_QUARTER_SECOND; // // We're done with the radio so shut it down. // SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); // // Did we receive a message while the radio was on? // if (SMPL_SUCCESS == SMPL_Receive(SMPL_LINKID_USER_UUD, pucMsg, &ucLen)) { // // Did we receive something and, if so, is it bad news? // if (ucLen && (pucMsg[0] == BAD_NEWS)) { // // Bad news has been received so start babbling to pass the // alert on to the other devices in the network. // UpdateStatus(true, "Alarm received!"); Start2Babble(); } } } }
//***************************************************************************** // // This is the main monitoring function for the applicaiton. It "sleeps" for // 5 seconds or so then checks to see if there are any alerts being broadcast. // If not, it toggles a LED and goes back to "sleep". If an alert is received // it switches into "babbling" mode where it retransmits the alert every 100mS // to propagate the alert through the network. // // This function does not return. // //*****************************************************************************
This is the main monitoring function for the applicaiton. It "sleeps" for 5 seconds or so then checks to see if there are any alerts being broadcast. If not, it toggles a LED and goes back to "sleep". If an alert is received it switches into "babbling" mode where it retransmits the alert every 100mS to propagate the alert through the network. This function does not return.
[ "This", "is", "the", "main", "monitoring", "function", "for", "the", "applicaiton", ".", "It", "\"", "sleeps", "\"", "for", "5", "seconds", "or", "so", "then", "checks", "to", "see", "if", "there", "are", "any", "alerts", "being", "broadcast", ".", "If", "not", "it", "toggles", "a", "LED", "and", "goes", "back", "to", "\"", "sleep", "\"", ".", "If", "an", "alert", "is", "received", "it", "switches", "into", "\"", "babbling", "\"", "mode", "where", "it", "retransmits", "the", "alert", "every", "100mS", "to", "propagate", "the", "alert", "through", "the", "network", ".", "This", "function", "does", "not", "return", "." ]
void MonitorForBadNews(void) { uint8_t pucMsg[1], ucLen; unsigned long ulLoop; SetLED(2, false); SetLED(1, false); SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); while (1) { for (ulLoop = 0; ulLoop < CHECK_RATE; ulLoop++) { SPIN_ABOUT_A_SECOND; } ToggleLED(1); if (g_bAlarmRaised) { Start2Babble(); } SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0); SPIN_ABOUT_A_QUARTER_SECOND; SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); if (SMPL_SUCCESS == SMPL_Receive(SMPL_LINKID_USER_UUD, pucMsg, &ucLen)) { if (ucLen && (pucMsg[0] == BAD_NEWS)) { UpdateStatus(true, "Alarm received!"); Start2Babble(); } } } }
[ "void", "MonitorForBadNews", "(", "void", ")", "{", "uint8_t", "pucMsg", "[", "1", "]", ",", "ucLen", ";", "unsigned", "long", "ulLoop", ";", "SetLED", "(", "2", ",", "false", ")", ";", "SetLED", "(", "1", ",", "false", ")", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_SLEEP", ",", "0", ")", ";", "while", "(", "1", ")", "{", "for", "(", "ulLoop", "=", "0", ";", "ulLoop", "<", "CHECK_RATE", ";", "ulLoop", "++", ")", "{", "SPIN_ABOUT_A_SECOND", ";", "}", "ToggleLED", "(", "1", ")", ";", "if", "(", "g_bAlarmRaised", ")", "{", "Start2Babble", "(", ")", ";", "}", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_AWAKE", ",", "0", ")", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_RXON", ",", "0", ")", ";", "SPIN_ABOUT_A_QUARTER_SECOND", ";", "SMPL_Ioctl", "(", "IOCTL_OBJ_RADIO", ",", "IOCTL_ACT_RADIO_SLEEP", ",", "0", ")", ";", "if", "(", "SMPL_SUCCESS", "==", "SMPL_Receive", "(", "SMPL_LINKID_USER_UUD", ",", "pucMsg", ",", "&", "ucLen", ")", ")", "{", "if", "(", "ucLen", "&&", "(", "pucMsg", "[", "0", "]", "==", "BAD_NEWS", ")", ")", "{", "UpdateStatus", "(", "true", ",", "\"", "\"", ")", ";", "Start2Babble", "(", ")", ";", "}", "}", "}", "}" ]
This is the main monitoring function for the applicaiton.
[ "This", "is", "the", "main", "monitoring", "function", "for", "the", "applicaiton", "." ]
[ "//\r", "// Turn off LEDs. Check for bad news will toggle one LED. The other LED will\r", "// toggle when bad news message is sent.\r", "//\r", "//\r", "// Start with radio sleeping.\r", "//\r", "//\r", "// Spoof MCU sleeping...\r", "//\r", "//\r", "// Check the \"sensor\" to see if we need to send an alert.\r", "//\r", "//\r", "// The sensor has been activated. Start babbling. This function\r", "// will not return.\r", "//\r", "//\r", "// Wake up the radio and receiver so that we can listen for others\r", "// babbling.\r", "//\r", "//\r", "// Stay on \"long enough\" to see if someone else is babbling\r", "//\r", "//\r", "// We're done with the radio so shut it down.\r", "//\r", "//\r", "// Did we receive a message while the radio was on?\r", "//\r", "//\r", "// Did we receive something and, if so, is it bad news?\r", "//\r", "//\r", "// Bad news has been received so start babbling to pass the\r", "// alert on to the other devices in the network.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlTimerHandler
void
static void StepCtrlTimerHandler(unsigned long ulWinding) { unsigned long ulPwmComp; tWinding *pWinding; // // Get a pointer to the winding data. // pWinding = &sWinding[ulWinding]; // // Make sure that there is a register assigned to control the pin. // if(pWinding->ulPwmGenCtlReg) { switch(pWinding->ucTimerState) { // // This state is used in PWM mode. The control signal has // been turned on and left on until this timer times out. // When this happens, the pin is changed to start PWM // at the appropriate duty cycle for the target current. // case TIMER_STATE_FIXED_ON: { // // The PWM cycle needs to be restarted at the end of // the fixed on time. This is done by short cycling the PWM // generator with the control set to turn off the pin for // all triggers. This will cause the pin to turn off. The // generator is reset - this will cause it to restart at 0. // Then the PWM generator is programmed to generate normal // PWM. This should cause the pin to start normal PWM cycle. // // Program the PWM generator to turn off the pin for all // conditions. // HWREG(pWinding->ulPwmGenCtlReg) = CTRL_PIN_OFF_VAL; // // Read the PWM load register value and save it aside. Then // load the PWM gen with a very short period. // Equivalent DriverLib call: // ulPwmComp = PWMGenPeriodGet(PWM0_BASE, [PWM_GEN_X]); // PWMGenPeriodSet(PWM0_BASE, [PWM_GEN_X], 3); // ulPwmComp = HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD); HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD) = 3; // // Reset the PWM generator time base at the end of the // fixed on time so that it starts at the beginning of a cycle. // Equivalent DriverLib call: // PWMSyncTimeBase(PWM0_BASE, pWinding->ulPwmGenBit); // HWREG(PWM0_BASE + PWM_O_SYNC) = pWinding->ulPwmGenBit; // // Switch the winding control pin to a new value. In PWM // mode, then pin will have been on at this point, // and the line below will switch it to using PWM. // The values in .ulTmrPwmReg and .ulTmrPwmVal were preset // when the fixed timing mode was started, and are used to // control one of the winding positive, negative, or // enable signals. // HWREG(pWinding->ulPwmGenCtlReg) = pWinding->ulPwmGenCtlVal; // // Restore the PWM generator period, so that it starts to // cycle normally, from 0. // Equivalent DriverLib call: // PWMGenPeriodSet(PWM0_BASE, [PWM_GEN_X], ulPwmComp); // HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD) = ulPwmComp; break; } // // This state is used in chopper mode. The control signal has // been turned off for the "off blanking" time to allow the // current to decay, and now the pin will be turned on again. // The timer will be started again to provide a short delay // before ADC sampling occurs. // case TIMER_STATE_BLANK_OFF: { // // Switch the winding control pin to a new value. In chopper // mode, then pin will have been off at this point, // and the line below will switch it on. // The values in .ulTmrPwmReg and .ulTmrPwmVal were preset // when the fixed timing mode was started, and are used to // control one of the winding positive, negative, or // enable signals. // HWREG(pWinding->ulPwmGenCtlReg) = pWinding->ulPwmGenCtlVal; // // Load the timer with the ADC delay. This is the time // until the ADC acquisition should be started. This is // used to allow the current sense signal to rise before // starting to sample with ADC. // Equivalent DriverLib call: // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, // ADC_DELAY); // HWREG(pWinding->ulTmrLoadAddr) = ADC_DELAY; // // Start the fixed timer running. When the timer expires // it will start up the ADC acquisition. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the next state to start the ADC. // pWinding->ucTimerState = TIMER_STATE_ADC_DELAY; break; } // // This state is used in chopper mode. The control signal // has been turned on, but the ADC not started yet. So now // the ADC acquisition will be started to measure the winding // current. // case TIMER_STATE_ADC_DELAY: { // // Enable the ADC sequencer // Equivalent DriverLib call: // ADCSequenceEnable(ADC0_BASE, pWinding->ucAdcSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; // // Trigger ADC to take a sample for chopper comparison. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucAdcSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; // // Set the next state to idle. // pWinding->ucTimerState = TIMER_STATE_IDLE; break; } // // If this state is entered, then do nothing, just exit. // case TIMER_STATE_IDLE: default: { break; } } } }
//***************************************************************************** // //! The interrupt handler for fixed timing. //! //! \param ulWinding specifies which winding is being processed. It can //! be one of WINDING_ID_A or WINDING_ID_B. //! //! This handler is called from the specific interrupt handler for the timer //! used for winding A or winding B. There are two timers, one for each //! winding, each with an interrupt handler. This handler is used for the //! common processing for both. The timers are used to generate a timeout //! either for the fixed on time if open-loop PWM mode is used, or the off //! blanking time if chopper mode is used. //! //! If open-loop PWM mode is used, then when this timer times out, it switches //! the control output to PWM (which was previously on). If chopper mode is //! used, then when this timer times out, it turns the control signal back //! on (which was previously off), and starts an ADC conversion. //! //! On entry here, the interrupt has already been acknowledged by the //! specific timer interrupt handler that called here. //! //! \return None. // //*****************************************************************************
The interrupt handler for fixed timing. \param ulWinding specifies which winding is being processed. It can be one of WINDING_ID_A or WINDING_ID_B. This handler is called from the specific interrupt handler for the timer used for winding A or winding B. There are two timers, one for each winding, each with an interrupt handler. This handler is used for the common processing for both. The timers are used to generate a timeout either for the fixed on time if open-loop PWM mode is used, or the off blanking time if chopper mode is used. If open-loop PWM mode is used, then when this timer times out, it switches the control output to PWM (which was previously on). If chopper mode is used, then when this timer times out, it turns the control signal back on (which was previously off), and starts an ADC conversion. On entry here, the interrupt has already been acknowledged by the specific timer interrupt handler that called here. \return None.
[ "The", "interrupt", "handler", "for", "fixed", "timing", ".", "\\", "param", "ulWinding", "specifies", "which", "winding", "is", "being", "processed", ".", "It", "can", "be", "one", "of", "WINDING_ID_A", "or", "WINDING_ID_B", ".", "This", "handler", "is", "called", "from", "the", "specific", "interrupt", "handler", "for", "the", "timer", "used", "for", "winding", "A", "or", "winding", "B", ".", "There", "are", "two", "timers", "one", "for", "each", "winding", "each", "with", "an", "interrupt", "handler", ".", "This", "handler", "is", "used", "for", "the", "common", "processing", "for", "both", ".", "The", "timers", "are", "used", "to", "generate", "a", "timeout", "either", "for", "the", "fixed", "on", "time", "if", "open", "-", "loop", "PWM", "mode", "is", "used", "or", "the", "off", "blanking", "time", "if", "chopper", "mode", "is", "used", ".", "If", "open", "-", "loop", "PWM", "mode", "is", "used", "then", "when", "this", "timer", "times", "out", "it", "switches", "the", "control", "output", "to", "PWM", "(", "which", "was", "previously", "on", ")", ".", "If", "chopper", "mode", "is", "used", "then", "when", "this", "timer", "times", "out", "it", "turns", "the", "control", "signal", "back", "on", "(", "which", "was", "previously", "off", ")", "and", "starts", "an", "ADC", "conversion", ".", "On", "entry", "here", "the", "interrupt", "has", "already", "been", "acknowledged", "by", "the", "specific", "timer", "interrupt", "handler", "that", "called", "here", ".", "\\", "return", "None", "." ]
static void StepCtrlTimerHandler(unsigned long ulWinding) { unsigned long ulPwmComp; tWinding *pWinding; pWinding = &sWinding[ulWinding]; if(pWinding->ulPwmGenCtlReg) { switch(pWinding->ucTimerState) { case TIMER_STATE_FIXED_ON: { HWREG(pWinding->ulPwmGenCtlReg) = CTRL_PIN_OFF_VAL; ulPwmComp = HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD); HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD) = 3; HWREG(PWM0_BASE + PWM_O_SYNC) = pWinding->ulPwmGenBit; HWREG(pWinding->ulPwmGenCtlReg) = pWinding->ulPwmGenCtlVal; HWREG(pWinding->ulPwmGenBase + PWM_O_X_LOAD) = ulPwmComp; break; } case TIMER_STATE_BLANK_OFF: { HWREG(pWinding->ulPwmGenCtlReg) = pWinding->ulPwmGenCtlVal; HWREG(pWinding->ulTmrLoadAddr) = ADC_DELAY; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_ADC_DELAY; break; } case TIMER_STATE_ADC_DELAY: { HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; pWinding->ucTimerState = TIMER_STATE_IDLE; break; } case TIMER_STATE_IDLE: default: { break; } } } }
[ "static", "void", "StepCtrlTimerHandler", "(", "unsigned", "long", "ulWinding", ")", "{", "unsigned", "long", "ulPwmComp", ";", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "if", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "{", "switch", "(", "pWinding", "->", "ucTimerState", ")", "{", "case", "TIMER_STATE_FIXED_ON", ":", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "=", "CTRL_PIN_OFF_VAL", ";", "ulPwmComp", "=", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_LOAD", ")", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_LOAD", ")", "=", "3", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_O_SYNC", ")", "=", "pWinding", "->", "ulPwmGenBit", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "=", "pWinding", "->", "ulPwmGenCtlVal", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_LOAD", ")", "=", "ulPwmComp", ";", "break", ";", "}", "case", "TIMER_STATE_BLANK_OFF", ":", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "=", "pWinding", "->", "ulPwmGenCtlVal", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "ADC_DELAY", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_ADC_DELAY", ";", "break", ";", "}", "case", "TIMER_STATE_ADC_DELAY", ":", "{", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "|=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_IDLE", ";", "break", ";", "}", "case", "TIMER_STATE_IDLE", ":", "default", ":", "{", "break", ";", "}", "}", "}", "}" ]
The interrupt handler for fixed timing.
[ "The", "interrupt", "handler", "for", "fixed", "timing", "." ]
[ "//\r", "// Get a pointer to the winding data.\r", "//\r", "//\r", "// Make sure that there is a register assigned to control the pin.\r", "//\r", "//\r", "// This state is used in PWM mode. The control signal has\r", "// been turned on and left on until this timer times out.\r", "// When this happens, the pin is changed to start PWM\r", "// at the appropriate duty cycle for the target current.\r", "//\r", "//\r", "// The PWM cycle needs to be restarted at the end of\r", "// the fixed on time. This is done by short cycling the PWM\r", "// generator with the control set to turn off the pin for\r", "// all triggers. This will cause the pin to turn off. The\r", "// generator is reset - this will cause it to restart at 0.\r", "// Then the PWM generator is programmed to generate normal\r", "// PWM. This should cause the pin to start normal PWM cycle.\r", "//\r", "// Program the PWM generator to turn off the pin for all\r", "// conditions.\r", "//\r", "//\r", "// Read the PWM load register value and save it aside. Then\r", "// load the PWM gen with a very short period.\r", "// Equivalent DriverLib call:\r", "// ulPwmComp = PWMGenPeriodGet(PWM0_BASE, [PWM_GEN_X]);\r", "// PWMGenPeriodSet(PWM0_BASE, [PWM_GEN_X], 3);\r", "//\r", "//\r", "// Reset the PWM generator time base at the end of the\r", "// fixed on time so that it starts at the beginning of a cycle.\r", "// Equivalent DriverLib call:\r", "// PWMSyncTimeBase(PWM0_BASE, pWinding->ulPwmGenBit);\r", "//\r", "//\r", "// Switch the winding control pin to a new value. In PWM\r", "// mode, then pin will have been on at this point,\r", "// and the line below will switch it to using PWM.\r", "// The values in .ulTmrPwmReg and .ulTmrPwmVal were preset\r", "// when the fixed timing mode was started, and are used to\r", "// control one of the winding positive, negative, or\r", "// enable signals.\r", "//\r", "//\r", "// Restore the PWM generator period, so that it starts to\r", "// cycle normally, from 0.\r", "// Equivalent DriverLib call:\r", "// PWMGenPeriodSet(PWM0_BASE, [PWM_GEN_X], ulPwmComp);\r", "//\r", "//\r", "// This state is used in chopper mode. The control signal has\r", "// been turned off for the \"off blanking\" time to allow the\r", "// current to decay, and now the pin will be turned on again.\r", "// The timer will be started again to provide a short delay\r", "// before ADC sampling occurs.\r", "//\r", "//\r", "// Switch the winding control pin to a new value. In chopper\r", "// mode, then pin will have been off at this point,\r", "// and the line below will switch it on.\r", "// The values in .ulTmrPwmReg and .ulTmrPwmVal were preset\r", "// when the fixed timing mode was started, and are used to\r", "// control one of the winding positive, negative, or\r", "// enable signals.\r", "//\r", "//\r", "// Load the timer with the ADC delay. This is the time\r", "// until the ADC acquisition should be started. This is\r", "// used to allow the current sense signal to rise before\r", "// starting to sample with ADC.\r", "// Equivalent DriverLib call:\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>,\r", "// ADC_DELAY);\r", "//\r", "//\r", "// Start the fixed timer running. When the timer expires\r", "// it will start up the ADC acquisition.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the next state to start the ADC.\r", "//\r", "//\r", "// This state is used in chopper mode. The control signal\r", "// has been turned on, but the ADC not started yet. So now\r", "// the ADC acquisition will be started to measure the winding\r", "// current.\r", "//\r", "//\r", "// Enable the ADC sequencer\r", "// Equivalent DriverLib call:\r", "// ADCSequenceEnable(ADC0_BASE, pWinding->ucAdcSeq);\r", "//\r", "//\r", "// Trigger ADC to take a sample for chopper comparison.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucAdcSeq);\r", "//\r", "//\r", "// Set the next state to idle.\r", "//\r", "//\r", "// If this state is entered, then do nothing, just exit.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlTimerAIntHandler
void
void StepCtrlTimerAIntHandler(void) { // // Clear the timer interrupt // Equivalent DriverLib call: // TimerIntClear(FIXED_TMR_BASE, TIMER_TIMA_TIMEOUT); // HWREG(FIXED_TMR_BASE + TIMER_O_ICR) = TIMER_TIMA_TIMEOUT; // // Call the common timer interrupt handler. // StepCtrlTimerHandler(WINDING_ID_A); }
//***************************************************************************** // //! The interrupt handler for the timer used for winding A fixed timing. //! //! This handler is called when the timer for winding A times out. This //! timer is used to generate a timeout either for the fixed on time if //! PWM mode is used, or the off blanking time if chopper mode is used. //! //! This interrupt handler calls a common timer handler for both //! A and B windings. //! //! \return None. // //*****************************************************************************
The interrupt handler for the timer used for winding A fixed timing. This handler is called when the timer for winding A times out. This timer is used to generate a timeout either for the fixed on time if PWM mode is used, or the off blanking time if chopper mode is used. This interrupt handler calls a common timer handler for both A and B windings. \return None.
[ "The", "interrupt", "handler", "for", "the", "timer", "used", "for", "winding", "A", "fixed", "timing", ".", "This", "handler", "is", "called", "when", "the", "timer", "for", "winding", "A", "times", "out", ".", "This", "timer", "is", "used", "to", "generate", "a", "timeout", "either", "for", "the", "fixed", "on", "time", "if", "PWM", "mode", "is", "used", "or", "the", "off", "blanking", "time", "if", "chopper", "mode", "is", "used", ".", "This", "interrupt", "handler", "calls", "a", "common", "timer", "handler", "for", "both", "A", "and", "B", "windings", ".", "\\", "return", "None", "." ]
void StepCtrlTimerAIntHandler(void) { HWREG(FIXED_TMR_BASE + TIMER_O_ICR) = TIMER_TIMA_TIMEOUT; StepCtrlTimerHandler(WINDING_ID_A); }
[ "void", "StepCtrlTimerAIntHandler", "(", "void", ")", "{", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_ICR", ")", "=", "TIMER_TIMA_TIMEOUT", ";", "StepCtrlTimerHandler", "(", "WINDING_ID_A", ")", ";", "}" ]
The interrupt handler for the timer used for winding A fixed timing.
[ "The", "interrupt", "handler", "for", "the", "timer", "used", "for", "winding", "A", "fixed", "timing", "." ]
[ "//\r", "// Clear the timer interrupt\r", "// Equivalent DriverLib call:\r", "// TimerIntClear(FIXED_TMR_BASE, TIMER_TIMA_TIMEOUT);\r", "//\r", "//\r", "// Call the common timer interrupt handler.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlTimerBIntHandler
void
void StepCtrlTimerBIntHandler(void) { // // Clear the timer interrupt // Equivalent DriverLib call: // TimerIntClear(FIXED_TMR_BASE, TIMER_TIMB_TIMEOUT); // HWREG(FIXED_TMR_BASE + TIMER_O_ICR) = TIMER_TIMB_TIMEOUT; // // Call the common timer interrupt handler. // StepCtrlTimerHandler(WINDING_ID_B); }
//***************************************************************************** // //! The interrupt handler for the timer used for winding B fixed timing. //! //! This handler is called when the timer for winding B times out. This //! timer is used to generate a timeout either for the fixed on time if //! PWM mode is used, or the off blanking time if chopper mode is used. //! //! This interrupt handler calls a common timer handler for both //! A and B windings. //! //! \return None. // //*****************************************************************************
The interrupt handler for the timer used for winding B fixed timing. This handler is called when the timer for winding B times out. This timer is used to generate a timeout either for the fixed on time if PWM mode is used, or the off blanking time if chopper mode is used. This interrupt handler calls a common timer handler for both A and B windings. \return None.
[ "The", "interrupt", "handler", "for", "the", "timer", "used", "for", "winding", "B", "fixed", "timing", ".", "This", "handler", "is", "called", "when", "the", "timer", "for", "winding", "B", "times", "out", ".", "This", "timer", "is", "used", "to", "generate", "a", "timeout", "either", "for", "the", "fixed", "on", "time", "if", "PWM", "mode", "is", "used", "or", "the", "off", "blanking", "time", "if", "chopper", "mode", "is", "used", ".", "This", "interrupt", "handler", "calls", "a", "common", "timer", "handler", "for", "both", "A", "and", "B", "windings", ".", "\\", "return", "None", "." ]
void StepCtrlTimerBIntHandler(void) { HWREG(FIXED_TMR_BASE + TIMER_O_ICR) = TIMER_TIMB_TIMEOUT; StepCtrlTimerHandler(WINDING_ID_B); }
[ "void", "StepCtrlTimerBIntHandler", "(", "void", ")", "{", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_ICR", ")", "=", "TIMER_TIMB_TIMEOUT", ";", "StepCtrlTimerHandler", "(", "WINDING_ID_B", ")", ";", "}" ]
The interrupt handler for the timer used for winding B fixed timing.
[ "The", "interrupt", "handler", "for", "the", "timer", "used", "for", "winding", "B", "fixed", "timing", "." ]
[ "//\r", "// Clear the timer interrupt\r", "// Equivalent DriverLib call:\r", "// TimerIntClear(FIXED_TMR_BASE, TIMER_TIMB_TIMEOUT);\r", "//\r", "//\r", "// Call the common timer interrupt handler.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlADCHandler
void
static void StepCtrlADCHandler(unsigned long ulWinding) { static unsigned int bDynamicExtend = 1; long lSampleCount; unsigned long ulDelta; unsigned long ulDuty; tWinding *pWinding; // // Get a pointer to the winding data. // pWinding = &sWinding[ulWinding]; // // Read the winding current data from the ADC sequencer, and // store it. // lSampleCount = ADCSequenceDataGet(ADC0_BASE, pWinding->ucADCSeq, &g_ulCurrentRaw[ulWinding][0]); // // Make sure that there is a register assigned to control the pin, // the handler is in an active state, and that the expected number of // ADC samples were retrieved. // if(pWinding->ulPwmGenCtlReg && pWinding->ucADCState) { // // If the sample count is not correct, then just start a new // acquisition and return. // if(lSampleCount != 1) { // // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; return; } // // Save the peak measured value for current. // This could be removed if the current reporting was not needed. // if((g_ulCurrentRaw[ulWinding][0] > g_ulPeakCurrentRaw[ulWinding])) { g_ulPeakCurrentRaw[ulWinding] = g_ulCurrentRaw[ulWinding][0]; } // // Process the current control method for operating in chopper mode. // if(pWinding->ucADCState == ADC_STATE_CHOP) { // // Compare the measured winding current to see if it is above the // threshold. If this condition is true, then turn off the winding // control pin, and start the off blanking timer. // if((g_ulCurrentRaw[ulWinding][0] >= pWinding->ulChopperCurrent)) { // // Turn the control pin off. // HWREG(pWinding->ulPwmGenCtlReg) = CTRL_PIN_OFF_VAL; // // Disable the ADC sequencer. // Equivalent DriverLib call: // ADCSequenceDisable(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) &= ~(1 << pWinding->ucADCSeq); // // Load the fixed timer with the blanking time. The blanking // time is multiplied by an extension factor. Each time the // code passes through here with the current above the // threshold, the extension factor is increased. The effect is // to lengthen the time that the voltage remains off if the // current in the winding is not dropping. // Equivalent DriverLib call: // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, // g_usBlankOffTime * bDynamicExtend); // HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime * bDynamicExtend; bDynamicExtend++; // // Start the fixed interval timer running. When the timer // expires it will turn the signal back on and trigger another // ADC sample. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the state of the fixed time to indicate blanking time. // pWinding->ucTimerState = TIMER_STATE_BLANK_OFF; } // // Else, if the measured current was below the threshold, then // leave the control pin on, and start another ADC acquisition. // else { // // Any passes through here means that the current was below // the threshold, so reset the dynamic extension factor. // bDynamicExtend = 1; // // Start next ADC acquisition. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } } // end of ADC_STATE_CHOP processing // // Process the current control method for closed-loop PWM mode. // else if(pWinding->ucADCState == ADC_STATE_CLOSEDPWM) { // // Compare the measured winding current to see if it is above the // threshold. If this condition is true, then set the PWM output // to the minimum pulse width. The minimum pulse width must be // some non-zero value in order to allow the current measurement // to be made. Current can only be measured when the output is on. // if((g_ulCurrentRaw[ulWinding][0] >= pWinding->ulChopperCurrent)) { ulDuty = MIN_PWM_COUNTS; } // // Else, the measured current is below the threshold, so // compute the duty cycle based on the difference between the // threshold and the actual measured current. // else { // // Compute the difference from the desired current. // ulDelta = pWinding->ulChopperCurrent - g_ulCurrentRaw[ulWinding][0]; // // If the difference is too large (the current is too low // by a large amount), then set the output to nearly 100%. // if(ulDelta >= MAX_CURRENT_DELTA) { ulDuty = g_ulPwmPeriod - 4; } // // else, the difference is not too large, so compute // the duty cycle based on the difference. // else { // // Compute the duty cycle based on a simple linear // equation as follows: // ulDelta == 0 --> ulDuty = 0% // ulDelta == MAX --> ulDuty = 100% // ulDuty = g_ulPwmPeriod * ulDelta / MAX_CURRENT_DELTA; // // If the computed duty cycle works out to be 100%, // then make is slightly shorter to ensure a switch // in the output. This will avoid the situation where // the turn-on and turn-off values are the same in the // PWM comparator. // if(ulDuty == g_ulPwmPeriod) { ulDuty = g_ulPwmPeriod - 4; } // // If the computed duty cycle is 0, then make sure it is // at least the minimum value. // if(ulDuty < MIN_PWM_COUNTS) { ulDuty = MIN_PWM_COUNTS; } } } // // Load the newly computed duty cycle into the comparator. // Equivalent DriverLib call: // PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, ulDuty); // HWREG(pWinding->ulPwmGenCtlReg) = (g_ulPwmPeriod - ulDuty) / 2; } // end of ADC_STATE_CLOSEDPWM processing } }
//***************************************************************************** // //! The interrupt handler for the ADC winding current sample. //! //! \param ulWinding specifies which winding is being processed. It can //! be one of WINDING_ID_A or WINDING_ID_B. //! //! This handler is called from the interrupt handler for the ADC sequencer //! for winding A or B. The ADC is used for closed-loop PWM and Chopper modes. //! If chopper mode is used then the sample acquisition was started either //! from this function, or from the winding fixed timer interrupt handler. If //! closed-loop PWM mode is used, then the ADC sample acquisition is triggered //! from the PWM generator at a certain point in the PWM cycle (when the //! output is turned on). //! //! <b>Chopper operation:</b> //! //! This interrupt handler compares the current sampled from the ADC //! with the chopping threshold. If the measured current is below the //! threshold, then a new acquisition is started and the control pin is left //! in the on state. If the measured current is above the threshold, then //! the control pin is turned off, and the winding timer is used to start //! the off blanking time interval. //! //! <b>Closed-loop PWM operation:</b> //! //! The interrupt handler compares the current samples from the ADC with //! the chopping threshold. If the measured current is above the threshold, //! then the PWM output is set to the minimum width. If the measured current //! is below the threshold, then the PWM duty cycle is adjusted so that //! the duty cycle is related to the difference between the actual current //! and the desired current. The larger the difference, the higher the duty //! cycle. //! //! On entry here, the interrupt has already been acknowledged by the //! specific ADC interrupt handler that called here. //! //! \return None. // //*****************************************************************************
The interrupt handler for the ADC winding current sample. \param ulWinding specifies which winding is being processed. It can be one of WINDING_ID_A or WINDING_ID_B. This handler is called from the interrupt handler for the ADC sequencer for winding A or B. The ADC is used for closed-loop PWM and Chopper modes. If chopper mode is used then the sample acquisition was started either from this function, or from the winding fixed timer interrupt handler. If closed-loop PWM mode is used, then the ADC sample acquisition is triggered from the PWM generator at a certain point in the PWM cycle (when the output is turned on). Chopper operation: This interrupt handler compares the current sampled from the ADC with the chopping threshold. If the measured current is below the threshold, then a new acquisition is started and the control pin is left in the on state. If the measured current is above the threshold, then the control pin is turned off, and the winding timer is used to start the off blanking time interval. Closed-loop PWM operation: The interrupt handler compares the current samples from the ADC with the chopping threshold. If the measured current is above the threshold, then the PWM output is set to the minimum width. If the measured current is below the threshold, then the PWM duty cycle is adjusted so that the duty cycle is related to the difference between the actual current and the desired current. The larger the difference, the higher the duty cycle. On entry here, the interrupt has already been acknowledged by the specific ADC interrupt handler that called here. \return None.
[ "The", "interrupt", "handler", "for", "the", "ADC", "winding", "current", "sample", ".", "\\", "param", "ulWinding", "specifies", "which", "winding", "is", "being", "processed", ".", "It", "can", "be", "one", "of", "WINDING_ID_A", "or", "WINDING_ID_B", ".", "This", "handler", "is", "called", "from", "the", "interrupt", "handler", "for", "the", "ADC", "sequencer", "for", "winding", "A", "or", "B", ".", "The", "ADC", "is", "used", "for", "closed", "-", "loop", "PWM", "and", "Chopper", "modes", ".", "If", "chopper", "mode", "is", "used", "then", "the", "sample", "acquisition", "was", "started", "either", "from", "this", "function", "or", "from", "the", "winding", "fixed", "timer", "interrupt", "handler", ".", "If", "closed", "-", "loop", "PWM", "mode", "is", "used", "then", "the", "ADC", "sample", "acquisition", "is", "triggered", "from", "the", "PWM", "generator", "at", "a", "certain", "point", "in", "the", "PWM", "cycle", "(", "when", "the", "output", "is", "turned", "on", ")", ".", "Chopper", "operation", ":", "This", "interrupt", "handler", "compares", "the", "current", "sampled", "from", "the", "ADC", "with", "the", "chopping", "threshold", ".", "If", "the", "measured", "current", "is", "below", "the", "threshold", "then", "a", "new", "acquisition", "is", "started", "and", "the", "control", "pin", "is", "left", "in", "the", "on", "state", ".", "If", "the", "measured", "current", "is", "above", "the", "threshold", "then", "the", "control", "pin", "is", "turned", "off", "and", "the", "winding", "timer", "is", "used", "to", "start", "the", "off", "blanking", "time", "interval", ".", "Closed", "-", "loop", "PWM", "operation", ":", "The", "interrupt", "handler", "compares", "the", "current", "samples", "from", "the", "ADC", "with", "the", "chopping", "threshold", ".", "If", "the", "measured", "current", "is", "above", "the", "threshold", "then", "the", "PWM", "output", "is", "set", "to", "the", "minimum", "width", ".", "If", "the", "measured", "current", "is", "below", "the", "threshold", "then", "the", "PWM", "duty", "cycle", "is", "adjusted", "so", "that", "the", "duty", "cycle", "is", "related", "to", "the", "difference", "between", "the", "actual", "current", "and", "the", "desired", "current", ".", "The", "larger", "the", "difference", "the", "higher", "the", "duty", "cycle", ".", "On", "entry", "here", "the", "interrupt", "has", "already", "been", "acknowledged", "by", "the", "specific", "ADC", "interrupt", "handler", "that", "called", "here", ".", "\\", "return", "None", "." ]
static void StepCtrlADCHandler(unsigned long ulWinding) { static unsigned int bDynamicExtend = 1; long lSampleCount; unsigned long ulDelta; unsigned long ulDuty; tWinding *pWinding; pWinding = &sWinding[ulWinding]; lSampleCount = ADCSequenceDataGet(ADC0_BASE, pWinding->ucADCSeq, &g_ulCurrentRaw[ulWinding][0]); if(pWinding->ulPwmGenCtlReg && pWinding->ucADCState) { if(lSampleCount != 1) { HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; return; } if((g_ulCurrentRaw[ulWinding][0] > g_ulPeakCurrentRaw[ulWinding])) { g_ulPeakCurrentRaw[ulWinding] = g_ulCurrentRaw[ulWinding][0]; } if(pWinding->ucADCState == ADC_STATE_CHOP) { if((g_ulCurrentRaw[ulWinding][0] >= pWinding->ulChopperCurrent)) { HWREG(pWinding->ulPwmGenCtlReg) = CTRL_PIN_OFF_VAL; HWREG(ADC0_BASE + ADC_O_ACTSS) &= ~(1 << pWinding->ucADCSeq); HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime * bDynamicExtend; bDynamicExtend++; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_BLANK_OFF; } else { bDynamicExtend = 1; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } } else if(pWinding->ucADCState == ADC_STATE_CLOSEDPWM) { if((g_ulCurrentRaw[ulWinding][0] >= pWinding->ulChopperCurrent)) { ulDuty = MIN_PWM_COUNTS; } else { ulDelta = pWinding->ulChopperCurrent - g_ulCurrentRaw[ulWinding][0]; if(ulDelta >= MAX_CURRENT_DELTA) { ulDuty = g_ulPwmPeriod - 4; } else { ulDuty = g_ulPwmPeriod * ulDelta / MAX_CURRENT_DELTA; if(ulDuty == g_ulPwmPeriod) { ulDuty = g_ulPwmPeriod - 4; } if(ulDuty < MIN_PWM_COUNTS) { ulDuty = MIN_PWM_COUNTS; } } } HWREG(pWinding->ulPwmGenCtlReg) = (g_ulPwmPeriod - ulDuty) / 2; } } }
[ "static", "void", "StepCtrlADCHandler", "(", "unsigned", "long", "ulWinding", ")", "{", "static", "unsigned", "int", "bDynamicExtend", "=", "1", ";", "long", "lSampleCount", ";", "unsigned", "long", "ulDelta", ";", "unsigned", "long", "ulDuty", ";", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "lSampleCount", "=", "ADCSequenceDataGet", "(", "ADC0_BASE", ",", "pWinding", "->", "ucADCSeq", ",", "&", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ")", ";", "if", "(", "pWinding", "->", "ulPwmGenCtlReg", "&&", "pWinding", "->", "ucADCState", ")", "{", "if", "(", "lSampleCount", "!=", "1", ")", "{", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "return", ";", "}", "if", "(", "(", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ">", "g_ulPeakCurrentRaw", "[", "ulWinding", "]", ")", ")", "{", "g_ulPeakCurrentRaw", "[", "ulWinding", "]", "=", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ";", "}", "if", "(", "pWinding", "->", "ucADCState", "==", "ADC_STATE_CHOP", ")", "{", "if", "(", "(", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ">=", "pWinding", "->", "ulChopperCurrent", ")", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "&=", "~", "(", "1", "<<", "pWinding", "->", "ucADCSeq", ")", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "g_usBlankOffTime", "*", "bDynamicExtend", ";", "bDynamicExtend", "++", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_BLANK_OFF", ";", "}", "else", "{", "bDynamicExtend", "=", "1", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "}", "}", "else", "if", "(", "pWinding", "->", "ucADCState", "==", "ADC_STATE_CLOSEDPWM", ")", "{", "if", "(", "(", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ">=", "pWinding", "->", "ulChopperCurrent", ")", ")", "{", "ulDuty", "=", "MIN_PWM_COUNTS", ";", "}", "else", "{", "ulDelta", "=", "pWinding", "->", "ulChopperCurrent", "-", "g_ulCurrentRaw", "[", "ulWinding", "]", "[", "0", "]", ";", "if", "(", "ulDelta", ">=", "MAX_CURRENT_DELTA", ")", "{", "ulDuty", "=", "g_ulPwmPeriod", "-", "4", ";", "}", "else", "{", "ulDuty", "=", "g_ulPwmPeriod", "*", "ulDelta", "/", "MAX_CURRENT_DELTA", ";", "if", "(", "ulDuty", "==", "g_ulPwmPeriod", ")", "{", "ulDuty", "=", "g_ulPwmPeriod", "-", "4", ";", "}", "if", "(", "ulDuty", "<", "MIN_PWM_COUNTS", ")", "{", "ulDuty", "=", "MIN_PWM_COUNTS", ";", "}", "}", "}", "HWREG", "(", "pWinding", "->", "ulPwmGenCtlReg", ")", "=", "(", "g_ulPwmPeriod", "-", "ulDuty", ")", "/", "2", ";", "}", "}", "}" ]
The interrupt handler for the ADC winding current sample.
[ "The", "interrupt", "handler", "for", "the", "ADC", "winding", "current", "sample", "." ]
[ "//\r", "// Get a pointer to the winding data.\r", "//\r", "//\r", "// Read the winding current data from the ADC sequencer, and\r", "// store it.\r", "//\r", "//\r", "// Make sure that there is a register assigned to control the pin,\r", "// the handler is in an active state, and that the expected number of\r", "// ADC samples were retrieved.\r", "//\r", "//\r", "// If the sample count is not correct, then just start a new\r", "// acquisition and return.\r", "//\r", "//\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Save the peak measured value for current.\r", "// This could be removed if the current reporting was not needed.\r", "//\r", "//\r", "// Process the current control method for operating in chopper mode.\r", "//\r", "//\r", "// Compare the measured winding current to see if it is above the\r", "// threshold. If this condition is true, then turn off the winding\r", "// control pin, and start the off blanking timer.\r", "//\r", "//\r", "// Turn the control pin off.\r", "//\r", "//\r", "// Disable the ADC sequencer.\r", "// Equivalent DriverLib call:\r", "// ADCSequenceDisable(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Load the fixed timer with the blanking time. The blanking\r", "// time is multiplied by an extension factor. Each time the\r", "// code passes through here with the current above the\r", "// threshold, the extension factor is increased. The effect is\r", "// to lengthen the time that the voltage remains off if the\r", "// current in the winding is not dropping.\r", "// Equivalent DriverLib call:\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>,\r", "// g_usBlankOffTime * bDynamicExtend);\r", "//\r", "//\r", "// Start the fixed interval timer running. When the timer\r", "// expires it will turn the signal back on and trigger another\r", "// ADC sample.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the state of the fixed time to indicate blanking time.\r", "//\r", "//\r", "// Else, if the measured current was below the threshold, then\r", "// leave the control pin on, and start another ADC acquisition.\r", "//\r", "//\r", "// Any passes through here means that the current was below\r", "// the threshold, so reset the dynamic extension factor.\r", "//\r", "//\r", "// Start next ADC acquisition.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "// end of ADC_STATE_CHOP processing\r", "//\r", "// Process the current control method for closed-loop PWM mode.\r", "//\r", "//\r", "// Compare the measured winding current to see if it is above the\r", "// threshold. If this condition is true, then set the PWM output\r", "// to the minimum pulse width. The minimum pulse width must be\r", "// some non-zero value in order to allow the current measurement\r", "// to be made. Current can only be measured when the output is on.\r", "//\r", "//\r", "// Else, the measured current is below the threshold, so\r", "// compute the duty cycle based on the difference between the\r", "// threshold and the actual measured current.\r", "//\r", "//\r", "// Compute the difference from the desired current.\r", "//\r", "//\r", "// If the difference is too large (the current is too low\r", "// by a large amount), then set the output to nearly 100%.\r", "//\r", "//\r", "// else, the difference is not too large, so compute\r", "// the duty cycle based on the difference.\r", "//\r", "//\r", "// Compute the duty cycle based on a simple linear\r", "// equation as follows:\r", "// ulDelta == 0 --> ulDuty = 0%\r", "// ulDelta == MAX --> ulDuty = 100%\r", "//\r", "//\r", "// If the computed duty cycle works out to be 100%,\r", "// then make is slightly shorter to ensure a switch\r", "// in the output. This will avoid the situation where\r", "// the turn-on and turn-off values are the same in the\r", "// PWM comparator.\r", "//\r", "//\r", "// If the computed duty cycle is 0, then make sure it is\r", "// at least the minimum value.\r", "//\r", "//\r", "// Load the newly computed duty cycle into the comparator.\r", "// Equivalent DriverLib call:\r", "// PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, ulDuty);\r", "//\r", "// end of ADC_STATE_CLOSEDPWM processing\r" ]
[ { "param": "ulWinding", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlADCAIntHandler
void
void StepCtrlADCAIntHandler(void) { // // Clear the ADC interrupt for this sequencer. // Equivalent DriverLib call: // ADCIntClear(ADC0_BASE, WINDING_A_ADC_SEQUENCER); // HWREG(ADC0_BASE + ADC_O_ISC) = 1 << WINDING_A_ADC_SEQUENCER; // // Call the common ADC interrupt handler. // StepCtrlADCHandler(WINDING_ID_A); }
//***************************************************************************** // //! The interrupt handler for the ADC sequencer used for winding A. //! //! This handler is called when the ADC sequencer used for winding A //! finishes taking samples. //! //! This interrupt handler calls a common handler for the ADC interrupts //! for winding A and B. //! //! \return None. // //*****************************************************************************
The interrupt handler for the ADC sequencer used for winding A. This handler is called when the ADC sequencer used for winding A finishes taking samples. This interrupt handler calls a common handler for the ADC interrupts for winding A and B. \return None.
[ "The", "interrupt", "handler", "for", "the", "ADC", "sequencer", "used", "for", "winding", "A", ".", "This", "handler", "is", "called", "when", "the", "ADC", "sequencer", "used", "for", "winding", "A", "finishes", "taking", "samples", ".", "This", "interrupt", "handler", "calls", "a", "common", "handler", "for", "the", "ADC", "interrupts", "for", "winding", "A", "and", "B", ".", "\\", "return", "None", "." ]
void StepCtrlADCAIntHandler(void) { HWREG(ADC0_BASE + ADC_O_ISC) = 1 << WINDING_A_ADC_SEQUENCER; StepCtrlADCHandler(WINDING_ID_A); }
[ "void", "StepCtrlADCAIntHandler", "(", "void", ")", "{", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ISC", ")", "=", "1", "<<", "WINDING_A_ADC_SEQUENCER", ";", "StepCtrlADCHandler", "(", "WINDING_ID_A", ")", ";", "}" ]
The interrupt handler for the ADC sequencer used for winding A.
[ "The", "interrupt", "handler", "for", "the", "ADC", "sequencer", "used", "for", "winding", "A", "." ]
[ "//\r", "// Clear the ADC interrupt for this sequencer.\r", "// Equivalent DriverLib call:\r", "// ADCIntClear(ADC0_BASE, WINDING_A_ADC_SEQUENCER);\r", "//\r", "//\r", "// Call the common ADC interrupt handler.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlADCBIntHandler
void
void StepCtrlADCBIntHandler(void) { // // Clear the ADC interrupt for this sequencer. // Equivalent DriverLib call: // ADCIntClear(ADC0_BASE, WINDING_B_ADC_SEQUENCER); // HWREG(ADC0_BASE + ADC_O_ISC) = 1 << WINDING_B_ADC_SEQUENCER; // // Call the common ADC interrupt handler. // StepCtrlADCHandler(WINDING_ID_B); }
//***************************************************************************** // //! The interrupt handler for the ADC sequencer used for winding B. //! //! This handler is called when the ADC sequencer used for winding B //! completes taking samples. //! //! This interrupt handler calls a common handler for the ADC interrupts //! for winding A and B. //! //! \return None. // //*****************************************************************************
The interrupt handler for the ADC sequencer used for winding B. This handler is called when the ADC sequencer used for winding B completes taking samples. This interrupt handler calls a common handler for the ADC interrupts for winding A and B. \return None.
[ "The", "interrupt", "handler", "for", "the", "ADC", "sequencer", "used", "for", "winding", "B", ".", "This", "handler", "is", "called", "when", "the", "ADC", "sequencer", "used", "for", "winding", "B", "completes", "taking", "samples", ".", "This", "interrupt", "handler", "calls", "a", "common", "handler", "for", "the", "ADC", "interrupts", "for", "winding", "A", "and", "B", ".", "\\", "return", "None", "." ]
void StepCtrlADCBIntHandler(void) { HWREG(ADC0_BASE + ADC_O_ISC) = 1 << WINDING_B_ADC_SEQUENCER; StepCtrlADCHandler(WINDING_ID_B); }
[ "void", "StepCtrlADCBIntHandler", "(", "void", ")", "{", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ISC", ")", "=", "1", "<<", "WINDING_B_ADC_SEQUENCER", ";", "StepCtrlADCHandler", "(", "WINDING_ID_B", ")", ";", "}" ]
The interrupt handler for the ADC sequencer used for winding B.
[ "The", "interrupt", "handler", "for", "the", "ADC", "sequencer", "used", "for", "winding", "B", "." ]
[ "//\r", "// Clear the ADC interrupt for this sequencer.\r", "// Equivalent DriverLib call:\r", "// ADCIntClear(ADC0_BASE, WINDING_B_ADC_SEQUENCER);\r", "//\r", "//\r", "// Call the common ADC interrupt handler.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlChopMode
void
void StepCtrlChopMode(void) { // // Set the PWM control register to 0. This will cause timer and ADC // ISRs to do nothing in case they fire again. Also, force all output // pins off. // sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; // // Turn on the enable pins now, this will prevent a current surge // when the motor is first moved. // HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Set the ADC sequencers to use a processor trigger. // ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); // // Set the PWM period for all generators. Since, for chopper mode, // the PWM generator outputs are used just to switch the outputs // on or off, and not generate PWM, the PWM period is set very // short so that any changes will take effect right away. // PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 4); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 4); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 4); // // Reset the peak winding current measurements. // g_ulPeakCurrentRaw[WINDING_ID_A] = 0; g_ulPeakCurrentRaw[WINDING_ID_B] = 0; // // Set the ADC processing state to chop mode. // sWinding[WINDING_ID_A].ucADCState = ADC_STATE_CHOP; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_CHOP; }
//***************************************************************************** // //! Configures the winding control signals for chopper mode. //! //! This function should be called prior to using chopper mode as the //! control method. It configures the control signals and the PWM //! generators to be used in chopper mode. //! //! \return None. // //*****************************************************************************
Configures the winding control signals for chopper mode. This function should be called prior to using chopper mode as the control method. It configures the control signals and the PWM generators to be used in chopper mode. \return None.
[ "Configures", "the", "winding", "control", "signals", "for", "chopper", "mode", ".", "This", "function", "should", "be", "called", "prior", "to", "using", "chopper", "mode", "as", "the", "control", "method", ".", "It", "configures", "the", "control", "signals", "and", "the", "PWM", "generators", "to", "be", "used", "in", "chopper", "mode", ".", "\\", "return", "None", "." ]
void StepCtrlChopMode(void) { sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 4); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 4); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 4); g_ulPeakCurrentRaw[WINDING_ID_A] = 0; g_ulPeakCurrentRaw[WINDING_ID_B] = 0; sWinding[WINDING_ID_A].ucADCState = ADC_STATE_CHOP; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_CHOP; }
[ "void", "StepCtrlChopMode", "(", "void", ")", "{", "sWinding", "[", "WINDING_ID_A", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_1_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_1_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_2_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_2_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_A_ADC_PRIORITY", ")", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_B_ADC_PRIORITY", ")", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_0", ",", "4", ")", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_1", ",", "4", ")", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_2", ",", "4", ")", ";", "g_ulPeakCurrentRaw", "[", "WINDING_ID_A", "]", "=", "0", ";", "g_ulPeakCurrentRaw", "[", "WINDING_ID_B", "]", "=", "0", ";", "sWinding", "[", "WINDING_ID_A", "]", ".", "ucADCState", "=", "ADC_STATE_CHOP", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ucADCState", "=", "ADC_STATE_CHOP", ";", "}" ]
Configures the winding control signals for chopper mode.
[ "Configures", "the", "winding", "control", "signals", "for", "chopper", "mode", "." ]
[ "//\r", "// Set the PWM control register to 0. This will cause timer and ADC\r", "// ISRs to do nothing in case they fire again. Also, force all output\r", "// pins off.\r", "//\r", "//\r", "// Turn on the enable pins now, this will prevent a current surge\r", "// when the motor is first moved.\r", "//\r", "//\r", "// Set the ADC sequencers to use a processor trigger.\r", "//\r", "//\r", "// Set the PWM period for all generators. Since, for chopper mode,\r", "// the PWM generator outputs are used just to switch the outputs\r", "// on or off, and not generate PWM, the PWM period is set very\r", "// short so that any changes will take effect right away.\r", "//\r", "//\r", "// Reset the peak winding current measurements.\r", "//\r", "//\r", "// Set the ADC processing state to chop mode.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlOpenPWMMode
void
void StepCtrlOpenPWMMode(unsigned long ulPeriod) { // // Save the value passed in, it is needed later. // g_ulPwmPeriod = ulPeriod; // // Set the PWM control register to 0. This will cause timer and ADC // ISRs to do nothing in case they fire again. Also, force all output // pins off. // sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; // // Turn on the enable pins now, this will prevent a current surge // when the motor is first moved. // HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Set the PWM period for all generators. // PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, ulPeriod); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, ulPeriod); // // Reset the peak winding current measurements. // g_ulPeakCurrentRaw[WINDING_ID_A] = 0; g_ulPeakCurrentRaw[WINDING_ID_B] = 0; // // Set the ADC processing state to idle (not used for PWM). // sWinding[WINDING_ID_A].ucADCState = ADC_STATE_IDLE; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_IDLE; // // Set the ADC sequencers to use a processor trigger. This will // prevent them from being triggered by the PWM generators. // ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); }
//***************************************************************************** // //! Configures the winding control signals for Open-loop PWM mode. //! //! \param ulPeriod is the PWM period in system clock ticks //! //! This function should be called prior to using open-loop PWM mode //! as the control method. It configures the control signals and the //! PWM generators to be used in open-loop PWM mode. //! //! \return None. // //*****************************************************************************
Configures the winding control signals for Open-loop PWM mode. \param ulPeriod is the PWM period in system clock ticks This function should be called prior to using open-loop PWM mode as the control method. It configures the control signals and the PWM generators to be used in open-loop PWM mode. \return None.
[ "Configures", "the", "winding", "control", "signals", "for", "Open", "-", "loop", "PWM", "mode", ".", "\\", "param", "ulPeriod", "is", "the", "PWM", "period", "in", "system", "clock", "ticks", "This", "function", "should", "be", "called", "prior", "to", "using", "open", "-", "loop", "PWM", "mode", "as", "the", "control", "method", ".", "It", "configures", "the", "control", "signals", "and", "the", "PWM", "generators", "to", "be", "used", "in", "open", "-", "loop", "PWM", "mode", ".", "\\", "return", "None", "." ]
void StepCtrlOpenPWMMode(unsigned long ulPeriod) { g_ulPwmPeriod = ulPeriod; sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(PWM0_BASE + PWM_GEN_2_OFFSET + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, ulPeriod); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, ulPeriod); g_ulPeakCurrentRaw[WINDING_ID_A] = 0; g_ulPeakCurrentRaw[WINDING_ID_B] = 0; sWinding[WINDING_ID_A].ucADCState = ADC_STATE_IDLE; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_IDLE; ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); }
[ "void", "StepCtrlOpenPWMMode", "(", "unsigned", "long", "ulPeriod", ")", "{", "g_ulPwmPeriod", "=", "ulPeriod", ";", "sWinding", "[", "WINDING_ID_A", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_1_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_1_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_2_OFFSET", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_2_OFFSET", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_0", ",", "ulPeriod", ")", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_1", ",", "ulPeriod", ")", ";", "PWMGenPeriodSet", "(", "PWM0_BASE", ",", "PWM_GEN_2", ",", "ulPeriod", ")", ";", "g_ulPeakCurrentRaw", "[", "WINDING_ID_A", "]", "=", "0", ";", "g_ulPeakCurrentRaw", "[", "WINDING_ID_B", "]", "=", "0", ";", "sWinding", "[", "WINDING_ID_A", "]", ".", "ucADCState", "=", "ADC_STATE_IDLE", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ucADCState", "=", "ADC_STATE_IDLE", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_A_ADC_PRIORITY", ")", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_B_ADC_PRIORITY", ")", ";", "}" ]
Configures the winding control signals for Open-loop PWM mode.
[ "Configures", "the", "winding", "control", "signals", "for", "Open", "-", "loop", "PWM", "mode", "." ]
[ "//\r", "// Save the value passed in, it is needed later.\r", "//\r", "//\r", "// Set the PWM control register to 0. This will cause timer and ADC\r", "// ISRs to do nothing in case they fire again. Also, force all output\r", "// pins off.\r", "//\r", "//\r", "// Turn on the enable pins now, this will prevent a current surge\r", "// when the motor is first moved.\r", "//\r", "//\r", "// Set the PWM period for all generators.\r", "//\r", "//\r", "// Reset the peak winding current measurements.\r", "//\r", "//\r", "// Set the ADC processing state to idle (not used for PWM).\r", "//\r", "//\r", "// Set the ADC sequencers to use a processor trigger. This will\r", "// prevent them from being triggered by the PWM generators.\r", "//\r" ]
[ { "param": "ulPeriod", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulPeriod", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlClosedPWMMode
void
void StepCtrlClosedPWMMode(unsigned long ulPeriod) { // // Set up for PWM generation. // StepCtrlOpenPWMMode(ulPeriod); // // The following lines of code are used to set the 3 PWM generators // out of phase with each other. This is done so that the ADC data // collection, which is triggered at certain points in the PWM cycle // occurs at different times for each generator. This ensures that // all of the generators will not trigger an ADC acquisition at the // same time, and thus causing possible delays in acquisition. When // an acquisition is triggered, we want to acquire the current sample // as soon as possible. // // Force generator 0 to reset at 0. // PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT); // // Now wait for gen 0 to get halfway to it's max value (from 0). // Max value is at half of period, so divisor is 4. // while(HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_COUNT) < ulPeriod / 4) { } // // Force generator 1 to reset to 0. // PWMSyncTimeBase(PWM0_BASE, PWM_GEN_1_BIT); // // Now wait for gen 0 to get halfway back to 0 (from max). // while(HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_COUNT) > ulPeriod / 4) { } // // Force generator 2 to reset to 0. // PWMSyncTimeBase(PWM0_BASE, PWM_GEN_2_BIT); // // Set pulse width to minimum for all outputs. // PWMPulseWidthSet(PWM0_BASE, PWM_GEN_0, MIN_PWM_COUNTS); PWMPulseWidthSet(PWM0_BASE, PWM_GEN_1, MIN_PWM_COUNTS); PWMPulseWidthSet(PWM0_BASE, PWM_GEN_2, MIN_PWM_COUNTS); // // For generators 0 and 1, set comparator B to have its falling edge // a specified amount of time after the middle of the PWM period. // This will be used to trigger ADC acquisitions and allows for // adjusting the setup and hold times for an ADC acquisition. // HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_CMPB) = (ulPeriod / 2) - ACQ_DELAY_COUNTS; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_CMPB) = (ulPeriod / 2) - ACQ_DELAY_COUNTS; // // For PWM generators 0 and 1, which are used to control the polarity // signal of the H-bridge (one for each winding), set the ADC trigger to // be the falling edge of the B comparator. For generator 2, which is // used to control the enable signals for both windings, set the ADC // trigger to the "load" event, which is the middle of the PWM pulse. // PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_TR_CNT_BD); PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_1, PWM_TR_CNT_BD); PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_2, PWM_TR_CNT_LOAD); // // Set the ADC processing state to closed-loop PWM mode. // sWinding[WINDING_ID_A].ucADCState = ADC_STATE_CLOSEDPWM; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_CLOSEDPWM; // // Set the control reg to NULL so that the ADC handler will not try // to do anything with it yet. // sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; // // Enable the ADC sequencers for windings A and B. This will start // the ADC acquisitions running, triggered at specific points in the PWM // cycle. The ADC handler will do nothing at the moment because no current // control has been set up. That will be handled when // StepCtrlClosedPWMSlow() or StepCtrlClosedPWMFast() is called. // ADCSequenceEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); ADCSequenceEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); }
//***************************************************************************** // //! Configures the winding control signals for Closed-Loop PWM mode. //! //! \param ulPeriod is the PWM period in system clock ticks //! //! This function should be called prior to using Closed-loop PWM mode //! as the control method. It configures the control signals and the //! PWM generators to be used in PWM mode, and sets up the trigger //! points for ADC acqusition for current measurement. //! //! \return None. // //*****************************************************************************
Configures the winding control signals for Closed-Loop PWM mode. \param ulPeriod is the PWM period in system clock ticks This function should be called prior to using Closed-loop PWM mode as the control method. It configures the control signals and the PWM generators to be used in PWM mode, and sets up the trigger points for ADC acqusition for current measurement. \return None.
[ "Configures", "the", "winding", "control", "signals", "for", "Closed", "-", "Loop", "PWM", "mode", ".", "\\", "param", "ulPeriod", "is", "the", "PWM", "period", "in", "system", "clock", "ticks", "This", "function", "should", "be", "called", "prior", "to", "using", "Closed", "-", "loop", "PWM", "mode", "as", "the", "control", "method", ".", "It", "configures", "the", "control", "signals", "and", "the", "PWM", "generators", "to", "be", "used", "in", "PWM", "mode", "and", "sets", "up", "the", "trigger", "points", "for", "ADC", "acqusition", "for", "current", "measurement", ".", "\\", "return", "None", "." ]
void StepCtrlClosedPWMMode(unsigned long ulPeriod) { StepCtrlOpenPWMMode(ulPeriod); PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT); while(HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_COUNT) < ulPeriod / 4) { } PWMSyncTimeBase(PWM0_BASE, PWM_GEN_1_BIT); while(HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_COUNT) > ulPeriod / 4) { } PWMSyncTimeBase(PWM0_BASE, PWM_GEN_2_BIT); PWMPulseWidthSet(PWM0_BASE, PWM_GEN_0, MIN_PWM_COUNTS); PWMPulseWidthSet(PWM0_BASE, PWM_GEN_1, MIN_PWM_COUNTS); PWMPulseWidthSet(PWM0_BASE, PWM_GEN_2, MIN_PWM_COUNTS); HWREG(PWM0_BASE + PWM_GEN_0_OFFSET + PWM_O_X_CMPB) = (ulPeriod / 2) - ACQ_DELAY_COUNTS; HWREG(PWM0_BASE + PWM_GEN_1_OFFSET + PWM_O_X_CMPB) = (ulPeriod / 2) - ACQ_DELAY_COUNTS; PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_TR_CNT_BD); PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_1, PWM_TR_CNT_BD); PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_2, PWM_TR_CNT_LOAD); sWinding[WINDING_ID_A].ucADCState = ADC_STATE_CLOSEDPWM; sWinding[WINDING_ID_B].ucADCState = ADC_STATE_CLOSEDPWM; sWinding[WINDING_ID_A].ulPwmGenCtlReg = 0; sWinding[WINDING_ID_B].ulPwmGenCtlReg = 0; ADCSequenceEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); ADCSequenceEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); }
[ "void", "StepCtrlClosedPWMMode", "(", "unsigned", "long", "ulPeriod", ")", "{", "StepCtrlOpenPWMMode", "(", "ulPeriod", ")", ";", "PWMSyncTimeBase", "(", "PWM0_BASE", ",", "PWM_GEN_0_BIT", ")", ";", "while", "(", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_COUNT", ")", "<", "ulPeriod", "/", "4", ")", "{", "}", "PWMSyncTimeBase", "(", "PWM0_BASE", ",", "PWM_GEN_1_BIT", ")", ";", "while", "(", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_COUNT", ")", ">", "ulPeriod", "/", "4", ")", "{", "}", "PWMSyncTimeBase", "(", "PWM0_BASE", ",", "PWM_GEN_2_BIT", ")", ";", "PWMPulseWidthSet", "(", "PWM0_BASE", ",", "PWM_GEN_0", ",", "MIN_PWM_COUNTS", ")", ";", "PWMPulseWidthSet", "(", "PWM0_BASE", ",", "PWM_GEN_1", ",", "MIN_PWM_COUNTS", ")", ";", "PWMPulseWidthSet", "(", "PWM0_BASE", ",", "PWM_GEN_2", ",", "MIN_PWM_COUNTS", ")", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_0_OFFSET", "+", "PWM_O_X_CMPB", ")", "=", "(", "ulPeriod", "/", "2", ")", "-", "ACQ_DELAY_COUNTS", ";", "HWREG", "(", "PWM0_BASE", "+", "PWM_GEN_1_OFFSET", "+", "PWM_O_X_CMPB", ")", "=", "(", "ulPeriod", "/", "2", ")", "-", "ACQ_DELAY_COUNTS", ";", "PWMGenIntTrigEnable", "(", "PWM0_BASE", ",", "PWM_GEN_0", ",", "PWM_TR_CNT_BD", ")", ";", "PWMGenIntTrigEnable", "(", "PWM0_BASE", ",", "PWM_GEN_1", ",", "PWM_TR_CNT_BD", ")", ";", "PWMGenIntTrigEnable", "(", "PWM0_BASE", ",", "PWM_GEN_2", ",", "PWM_TR_CNT_LOAD", ")", ";", "sWinding", "[", "WINDING_ID_A", "]", ".", "ucADCState", "=", "ADC_STATE_CLOSEDPWM", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ucADCState", "=", "ADC_STATE_CLOSEDPWM", ";", "sWinding", "[", "WINDING_ID_A", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "sWinding", "[", "WINDING_ID_B", "]", ".", "ulPwmGenCtlReg", "=", "0", ";", "ADCSequenceEnable", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ")", ";", "ADCSequenceEnable", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ")", ";", "}" ]
Configures the winding control signals for Closed-Loop PWM mode.
[ "Configures", "the", "winding", "control", "signals", "for", "Closed", "-", "Loop", "PWM", "mode", "." ]
[ "//\r", "// Set up for PWM generation.\r", "//\r", "//\r", "// The following lines of code are used to set the 3 PWM generators\r", "// out of phase with each other. This is done so that the ADC data\r", "// collection, which is triggered at certain points in the PWM cycle\r", "// occurs at different times for each generator. This ensures that\r", "// all of the generators will not trigger an ADC acquisition at the\r", "// same time, and thus causing possible delays in acquisition. When\r", "// an acquisition is triggered, we want to acquire the current sample\r", "// as soon as possible.\r", "//\r", "// Force generator 0 to reset at 0.\r", "//\r", "//\r", "// Now wait for gen 0 to get halfway to it's max value (from 0).\r", "// Max value is at half of period, so divisor is 4.\r", "//\r", "//\r", "// Force generator 1 to reset to 0.\r", "//\r", "//\r", "// Now wait for gen 0 to get halfway back to 0 (from max).\r", "//\r", "//\r", "// Force generator 2 to reset to 0.\r", "//\r", "//\r", "// Set pulse width to minimum for all outputs.\r", "//\r", "//\r", "// For generators 0 and 1, set comparator B to have its falling edge\r", "// a specified amount of time after the middle of the PWM period.\r", "// This will be used to trigger ADC acquisitions and allows for\r", "// adjusting the setup and hold times for an ADC acquisition.\r", "//\r", "//\r", "// For PWM generators 0 and 1, which are used to control the polarity\r", "// signal of the H-bridge (one for each winding), set the ADC trigger to\r", "// be the falling edge of the B comparator. For generator 2, which is\r", "// used to control the enable signals for both windings, set the ADC\r", "// trigger to the \"load\" event, which is the middle of the PWM pulse.\r", "//\r", "//\r", "// Set the ADC processing state to closed-loop PWM mode.\r", "//\r", "//\r", "// Set the control reg to NULL so that the ADC handler will not try\r", "// to do anything with it yet.\r", "//\r", "//\r", "// Enable the ADC sequencers for windings A and B. This will start\r", "// the ADC acquisitions running, triggered at specific points in the PWM\r", "// cycle. The ADC handler will do nothing at the moment because no current\r", "// control has been set up. That will be handled when\r", "// StepCtrlClosedPWMSlow() or StepCtrlClosedPWMFast() is called.\r", "//\r" ]
[ { "param": "ulPeriod", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulPeriod", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlChopSlow
void
void StepCtrlChopSlow(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Disable the fixed interval timer so it can be updated. // Set the load register to the off blanking time. // Equivalent DriverLib call: // TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usBlankOffTime); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime; // // Winding current is positive, set the negative side low, // and start chopping the positive side. // if(lSetting > 0) { // // Save the chopping current threshold. // pWinding->ulChopperCurrent = lSetting; // // Save the PWM register address and value that will be used by the // ADC and timer ISRs to control the signal on the control pin. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENA; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; // // Set positive side high and negative side low, so the // winding is turned on, in the positive direction. // This will apply voltage and start the current flowing. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; // // Enable the ADC sequencer // Equivalent DriverLib call: // ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; // // Trigger ADC to take a sample for chopper comparison. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } // // Winding current is negative, set the positive side low, // and start chopping the negative side. // else if(lSetting < 0) { // // Save the chopping current threshold. Account for sign. // pWinding->ulChopperCurrent = -lSetting; // // Save the PWM register address and value that will be used by the // ADC and timer ISRs to control the signal on the control pin. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENB; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; // // Set negative side high and positive side low, so the // winding is turned on, in the negative direction. // This will apply voltage and start the current flowing. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Enable the ADC sequencer // Equivalent DriverLib call: // ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; // // Trigger ADC to take a sample for chopper comparison. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } // // Winding current is 0, set both sides low. // else { // // Set the chopping current threshold to 0. // pWinding->ulChopperCurrent = 0; // // Set both positive and negative side low, so that there is // no voltage applied to the winding. // pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } // // Turn on the enable signal for the winding. ulPwmAB is used to // select the correct half (A or B) of the PWM generator for the // winding enable signals. For slow decay, the enable signal is // always left on. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; }
//***************************************************************************** // //! Sets up a step using chopper mode and slow decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the chopping current (signed), in raw ADC counts //! //! This function will configure the chopper to control the pins needed //! for slow current decay. It drives the winding positive or negative //! (or off), according to the value and sign of the lSetting parameter. //! Once the control signals are set to apply voltage to the winding, //! an ADC acquisition is started. This will start the chopper running //! for this winding. //! //! For slow current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate drivers are always enabled. To control //! current, the "high" side of the H-bridge is switched between high and //! low. When it is high, the bus voltage is applied to the winding and //! current flows. When it is low, then both sides of the H-bridge will be //! low, and bus voltage is removed, but current continues to circulate in //! the winding as it decays slowly. //! //! \return None. // //*****************************************************************************
Sets up a step using chopper mode and slow decay. \param ulWinding is the winding ID (A or B) \param lSetting is the chopping current (signed), in raw ADC counts This function will configure the chopper to control the pins needed for slow current decay. It drives the winding positive or negative (or off), according to the value and sign of the lSetting parameter. Once the control signals are set to apply voltage to the winding, an ADC acquisition is started. This will start the chopper running for this winding. For slow current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate drivers are always enabled. To control current, the "high" side of the H-bridge is switched between high and low. When it is high, the bus voltage is applied to the winding and current flows. When it is low, then both sides of the H-bridge will be low, and bus voltage is removed, but current continues to circulate in the winding as it decays slowly. \return None.
[ "Sets", "up", "a", "step", "using", "chopper", "mode", "and", "slow", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "chopping", "current", "(", "signed", ")", "in", "raw", "ADC", "counts", "This", "function", "will", "configure", "the", "chopper", "to", "control", "the", "pins", "needed", "for", "slow", "current", "decay", ".", "It", "drives", "the", "winding", "positive", "or", "negative", "(", "or", "off", ")", "according", "to", "the", "value", "and", "sign", "of", "the", "lSetting", "parameter", ".", "Once", "the", "control", "signals", "are", "set", "to", "apply", "voltage", "to", "the", "winding", "an", "ADC", "acquisition", "is", "started", ".", "This", "will", "start", "the", "chopper", "running", "for", "this", "winding", ".", "For", "slow", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "drivers", "are", "always", "enabled", ".", "To", "control", "current", "the", "\"", "high", "\"", "side", "of", "the", "H", "-", "bridge", "is", "switched", "between", "high", "and", "low", ".", "When", "it", "is", "high", "the", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "it", "is", "low", "then", "both", "sides", "of", "the", "H", "-", "bridge", "will", "be", "low", "and", "bus", "voltage", "is", "removed", "but", "current", "continues", "to", "circulate", "in", "the", "winding", "as", "it", "decays", "slowly", ".", "\\", "return", "None", "." ]
void StepCtrlChopSlow(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime; if(lSetting > 0) { pWinding->ulChopperCurrent = lSetting; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENA; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } else if(lSetting < 0) { pWinding->ulChopperCurrent = -lSetting; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENB; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } else { pWinding->ulChopperCurrent = 0; pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; }
[ "void", "StepCtrlChopSlow", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "&=", "~", "pWinding", "->", "ulTmrEnaVal", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "g_usBlankOffTime", ";", "if", "(", "lSetting", ">", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "lSetting", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "|=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "-", "lSetting", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "|=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "}", "else", "{", "pWinding", "->", "ulChopperCurrent", "=", "0", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "}" ]
Sets up a step using chopper mode and slow decay.
[ "Sets", "up", "a", "step", "using", "chopper", "mode", "and", "slow", "decay", "." ]
[ "//\r", "// Disable the fixed interval timer so it can be updated.\r", "// Set the load register to the off blanking time.\r", "// Equivalent DriverLib call:\r", "// TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usBlankOffTime);\r", "//\r", "//\r", "// Winding current is positive, set the negative side low,\r", "// and start chopping the positive side.\r", "//\r", "//\r", "// Save the chopping current threshold.\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// ADC and timer ISRs to control the signal on the control pin.\r", "//\r", "//\r", "// Set positive side high and negative side low, so the\r", "// winding is turned on, in the positive direction.\r", "// This will apply voltage and start the current flowing.\r", "//\r", "//\r", "// Enable the ADC sequencer\r", "// Equivalent DriverLib call:\r", "// ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Trigger ADC to take a sample for chopper comparison.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Winding current is negative, set the positive side low,\r", "// and start chopping the negative side.\r", "//\r", "//\r", "// Save the chopping current threshold. Account for sign.\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// ADC and timer ISRs to control the signal on the control pin.\r", "//\r", "//\r", "// Set negative side high and positive side low, so the\r", "// winding is turned on, in the negative direction.\r", "// This will apply voltage and start the current flowing.\r", "//\r", "//\r", "// Enable the ADC sequencer\r", "// Equivalent DriverLib call:\r", "// ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Trigger ADC to take a sample for chopper comparison.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Winding current is 0, set both sides low.\r", "//\r", "//\r", "// Set the chopping current threshold to 0.\r", "//\r", "//\r", "// Set both positive and negative side low, so that there is\r", "// no voltage applied to the winding.\r", "//\r", "//\r", "// Turn on the enable signal for the winding. ulPwmAB is used to\r", "// select the correct half (A or B) of the PWM generator for the\r", "// winding enable signals. For slow decay, the enable signal is\r", "// always left on.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlChopFast
void
void StepCtrlChopFast(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Disable the fixed interval timer so it can be updated. // Set the load register to the off blanking time. // Equivalent DriverLib call: // TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usBlankOffTime); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime; // // Save the PWM register address and value that will be used by the // ADC and timer ISRs to control the signal on the control pin. // pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; // // Winding current is positive, set the negative side low, and the // positive side high, and start chopping the enable signal. // if(lSetting > 0) { // // Save the chopping current threshold. // pWinding->ulChopperCurrent = lSetting; // // Set positive side high and negative side low, so the // winding is turned on, in the positive direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; // // Turn on the enable pin so that the H-bridge is enabled and // current will begin to flow in the winding. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; // // Enable the ADC sequencer // Equivalent DriverLib call: // ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; // // Trigger ADC to take a sample for chopper comparison. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } // // Winding current is negative, set the positive side low, and the // negative side high, and start chopping the enable signal. // else if(lSetting < 0) { // // Save the chopping current threshold. Account for sign. // pWinding->ulChopperCurrent = -lSetting; // // Set negative side high and positive side low, so the // winding is turned on, in the negative direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Turn on the enable pin so that the H-bridge is enabled and // current will begin to flow in the winding. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; // // Enable the ADC sequencer // Equivalent DriverLib call: // ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; // // Trigger ADC to take a sample for chopper comparison. // Equivalent DriverLib call: // ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq); // HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } // // Winding current is 0. Set both sides low, and stop chopping on // the enable signal, leaving the enable signal off. // else { // // Set the chopping current threshold to 0. // pWinding->ulChopperCurrent = 0; // // Set both positive and negative sides low, so that no // voltage is applied to the winding, and turn off the // winding enable pin. This will have the effect of opening // all the switches. // pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } }
//***************************************************************************** // //! Sets up a step using chopper mode and fast decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the chopping current (signed), in raw ADC counts //! //! This function will configure the chopper to control the pins needed //! for fast current decay. It drives the winding positive or negative //! (or off), according to the value and sign of the lSetting parameter. //! Once the control signals are set to apply voltage to the winding, //! an ADC acquisition is started. This will start the chopper running //! for this winding. //! //! For fast current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate driver enable signal is then turned on //! or off to control the current. When the enable signal is on, bus voltage //! is applied to the winding and current flows. When the enable signal is //! off, all the H-bridge switches are open and the current in the winding //! decays rapidly. //! //! \return None. // //*****************************************************************************
Sets up a step using chopper mode and fast decay. \param ulWinding is the winding ID (A or B) \param lSetting is the chopping current (signed), in raw ADC counts This function will configure the chopper to control the pins needed for fast current decay. It drives the winding positive or negative (or off), according to the value and sign of the lSetting parameter. Once the control signals are set to apply voltage to the winding, an ADC acquisition is started. This will start the chopper running for this winding. For fast current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate driver enable signal is then turned on or off to control the current. When the enable signal is on, bus voltage is applied to the winding and current flows. When the enable signal is off, all the H-bridge switches are open and the current in the winding decays rapidly. \return None.
[ "Sets", "up", "a", "step", "using", "chopper", "mode", "and", "fast", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "chopping", "current", "(", "signed", ")", "in", "raw", "ADC", "counts", "This", "function", "will", "configure", "the", "chopper", "to", "control", "the", "pins", "needed", "for", "fast", "current", "decay", ".", "It", "drives", "the", "winding", "positive", "or", "negative", "(", "or", "off", ")", "according", "to", "the", "value", "and", "sign", "of", "the", "lSetting", "parameter", ".", "Once", "the", "control", "signals", "are", "set", "to", "apply", "voltage", "to", "the", "winding", "an", "ADC", "acquisition", "is", "started", ".", "This", "will", "start", "the", "chopper", "running", "for", "this", "winding", ".", "For", "fast", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "driver", "enable", "signal", "is", "then", "turned", "on", "or", "off", "to", "control", "the", "current", ".", "When", "the", "enable", "signal", "is", "on", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "the", "enable", "signal", "is", "off", "all", "the", "H", "-", "bridge", "switches", "are", "open", "and", "the", "current", "in", "the", "winding", "decays", "rapidly", ".", "\\", "return", "None", "." ]
void StepCtrlChopFast(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usBlankOffTime; pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = CTRL_PIN_ON_VAL; if(lSetting > 0) { pWinding->ulChopperCurrent = lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } else if(lSetting < 0) { pWinding->ulChopperCurrent = -lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; HWREG(ADC0_BASE + ADC_O_ACTSS) |= 1 << pWinding->ucADCSeq; HWREG(ADC0_BASE + ADC_O_PSSI) = 1 << pWinding->ucADCSeq; } else { pWinding->ulChopperCurrent = 0; pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } }
[ "void", "StepCtrlChopFast", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "&=", "~", "pWinding", "->", "ulTmrEnaVal", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "g_usBlankOffTime", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "CTRL_PIN_ON_VAL", ";", "if", "(", "lSetting", ">", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "|=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "-", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_ACTSS", ")", "|=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_PSSI", ")", "=", "1", "<<", "pWinding", "->", "ucADCSeq", ";", "}", "else", "{", "pWinding", "->", "ulChopperCurrent", "=", "0", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "}" ]
Sets up a step using chopper mode and fast decay.
[ "Sets", "up", "a", "step", "using", "chopper", "mode", "and", "fast", "decay", "." ]
[ "//\r", "// Disable the fixed interval timer so it can be updated.\r", "// Set the load register to the off blanking time.\r", "// Equivalent DriverLib call:\r", "// TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usBlankOffTime);\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// ADC and timer ISRs to control the signal on the control pin.\r", "//\r", "//\r", "// Winding current is positive, set the negative side low, and the\r", "// positive side high, and start chopping the enable signal.\r", "//\r", "//\r", "// Save the chopping current threshold.\r", "//\r", "//\r", "// Set positive side high and negative side low, so the\r", "// winding is turned on, in the positive direction.\r", "//\r", "//\r", "// Turn on the enable pin so that the H-bridge is enabled and\r", "// current will begin to flow in the winding.\r", "//\r", "//\r", "// Enable the ADC sequencer\r", "// Equivalent DriverLib call:\r", "// ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Trigger ADC to take a sample for chopper comparison.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Winding current is negative, set the positive side low, and the\r", "// negative side high, and start chopping the enable signal.\r", "//\r", "//\r", "// Save the chopping current threshold. Account for sign.\r", "//\r", "//\r", "// Set negative side high and positive side low, so the\r", "// winding is turned on, in the negative direction.\r", "//\r", "//\r", "// Turn on the enable pin so that the H-bridge is enabled and\r", "// current will begin to flow in the winding.\r", "//\r", "//\r", "// Enable the ADC sequencer\r", "// Equivalent DriverLib call:\r", "// ADCSequenceEnable(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Trigger ADC to take a sample for chopper comparison.\r", "// Equivalent DriverLib call:\r", "// ADCProcessorTrigger(ADC0_BASE, pWinding->ucADCSeq);\r", "//\r", "//\r", "// Winding current is 0. Set both sides low, and stop chopping on\r", "// the enable signal, leaving the enable signal off.\r", "//\r", "//\r", "// Set the chopping current threshold to 0.\r", "//\r", "//\r", "// Set both positive and negative sides low, so that no\r", "// voltage is applied to the winding, and turn off the\r", "// winding enable pin. This will have the effect of opening\r", "// all the switches.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlOpenPwmSlow
void
void StepCtrlOpenPwmSlow(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Disable the fixed interval timer so it can be updated. // Set the load register to the fixed on time. // Equivalent DriverLib call: // TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usFixedOnTime); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usFixedOnTime; // // Winding current is positive // if(lSetting > 0) { // // Load the PWM comparator register to set the PWM pulse width // (duty cycle) according to the lSetting parameter. This sets // up the PWM, but the pin is not being switched yet. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod - lSetting) / 2; // // Set the negative side low. The positive side will be turned // on (below) so that current flows in the winding in the positive // direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; // // If the fixed on time is 0, then just set the positive side pin // directly to start PWM, and dont bother to start the fixed timer. // This will start PWMming on the winding. // if(g_usFixedOnTime == 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_PWMA_VAL; } // // If the fixed on time is set to a non-zero value, then the pin // is turned on for a fixed amount of time. The fixed timer is set // to time out after the fixed on time. The timer handler will // start PWM on the pin. // else { // // Turn the pin on. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; // // Save the PWM register address and value that will be used by the // timer ISR to turn the PWM on when the fixed time expires. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENA; pWinding->ulPwmGenCtlVal = CTRL_PIN_PWMA_VAL; // // Start the fixed interval timer running. When the timer expires // it will start PWMming on the high side signal. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the timer state to indicate fixed on timing. // pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } // // Winding current is negative. // else if(lSetting < 0) { // // Load the PWM comparator register to set the PWM pulse width // (duty cycle) according to the lSetting parameter. This sets // up the PWM, but the pin is not being switched yet. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod + lSetting) / 2; // // Set the positive side low. The negative side will be turned // on (below) so that current flows in the winding in the negative // direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; // // If the fixed on time is 0, then just set the negative side pin // directly to start PWM, and dont bother to start the fixed timer. // This will start PWMming on the winding. // if(g_usFixedOnTime == 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_PWMA_VAL; } // // If the fixed on time is set to a non-zero value, then the pin // is turned on for a fixed amount of time. The fixed timer is set // to time out after the fixed on time. The timer handler will // start PWM on the pin. // else { // // Turn the pin on. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Save the PWM register address and value that will be used by the // timer ISR to turn the PWM on when the fixed time expires. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENB; pWinding->ulPwmGenCtlVal = CTRL_PIN_PWMA_VAL; // // Start the fixed interval timer running. When the timer expires // it will start PWMming on the low side signal. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the timer state to indicate fixed on timing. // pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } // // Winding is off // else { // // Set both positive and negative side low, so that there is // no voltage applied to the winding. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } // // Turn on the enable signal for the winding. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; }
//***************************************************************************** // //! Sets up a step using Open-loop PWM mode and slow decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the duration that the signal is on, in system //! clock ticks (signed to indicate polarity) //! //! This function will configure the PWM to control the pins needed //! for slow current decay. It drives the winding positive or negative //! (or off), according to the value and sign of the lSetting parameter. //! Once the control signals are set to apply voltage to the winding, //! the fixed timer is started with a timeout value for the fixed rise //! time. When the fixed timer times out, it will set the PWM generator //! to start using PWM for the control signal. There is no feedback from //! the measured current, which is why this is called open-loop PWM. //! //! The lSetting parameter is the duration in system clock ticks, that //! the PWM output will be on. This will be a fraction of the PWM period, //! resulting in the PWM duty cycle. It is a signed value, to indicate //! the direction the current should flow. //! //! For slow current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate drivers are always enabled. To control //! current, the "high" side of the H-bridge is switched between high and //! low. When it is high, the bus voltage is applied to the winding and //! current flows. When it is low, then both sides of the H-bridge will be //! low, and bus voltage is removed, but current continues to circulate in //! the winding as it decays slowly. //! //! \return None. // //*****************************************************************************
Sets up a step using Open-loop PWM mode and slow decay. \param ulWinding is the winding ID (A or B) \param lSetting is the duration that the signal is on, in system clock ticks (signed to indicate polarity) This function will configure the PWM to control the pins needed for slow current decay. It drives the winding positive or negative (or off), according to the value and sign of the lSetting parameter. Once the control signals are set to apply voltage to the winding, the fixed timer is started with a timeout value for the fixed rise time. When the fixed timer times out, it will set the PWM generator to start using PWM for the control signal. There is no feedback from the measured current, which is why this is called open-loop PWM. The lSetting parameter is the duration in system clock ticks, that the PWM output will be on. This will be a fraction of the PWM period, resulting in the PWM duty cycle. It is a signed value, to indicate the direction the current should flow. For slow current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate drivers are always enabled. To control current, the "high" side of the H-bridge is switched between high and low. When it is high, the bus voltage is applied to the winding and current flows. When it is low, then both sides of the H-bridge will be low, and bus voltage is removed, but current continues to circulate in the winding as it decays slowly. \return None.
[ "Sets", "up", "a", "step", "using", "Open", "-", "loop", "PWM", "mode", "and", "slow", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "duration", "that", "the", "signal", "is", "on", "in", "system", "clock", "ticks", "(", "signed", "to", "indicate", "polarity", ")", "This", "function", "will", "configure", "the", "PWM", "to", "control", "the", "pins", "needed", "for", "slow", "current", "decay", ".", "It", "drives", "the", "winding", "positive", "or", "negative", "(", "or", "off", ")", "according", "to", "the", "value", "and", "sign", "of", "the", "lSetting", "parameter", ".", "Once", "the", "control", "signals", "are", "set", "to", "apply", "voltage", "to", "the", "winding", "the", "fixed", "timer", "is", "started", "with", "a", "timeout", "value", "for", "the", "fixed", "rise", "time", ".", "When", "the", "fixed", "timer", "times", "out", "it", "will", "set", "the", "PWM", "generator", "to", "start", "using", "PWM", "for", "the", "control", "signal", ".", "There", "is", "no", "feedback", "from", "the", "measured", "current", "which", "is", "why", "this", "is", "called", "open", "-", "loop", "PWM", ".", "The", "lSetting", "parameter", "is", "the", "duration", "in", "system", "clock", "ticks", "that", "the", "PWM", "output", "will", "be", "on", ".", "This", "will", "be", "a", "fraction", "of", "the", "PWM", "period", "resulting", "in", "the", "PWM", "duty", "cycle", ".", "It", "is", "a", "signed", "value", "to", "indicate", "the", "direction", "the", "current", "should", "flow", ".", "For", "slow", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "drivers", "are", "always", "enabled", ".", "To", "control", "current", "the", "\"", "high", "\"", "side", "of", "the", "H", "-", "bridge", "is", "switched", "between", "high", "and", "low", ".", "When", "it", "is", "high", "the", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "it", "is", "low", "then", "both", "sides", "of", "the", "H", "-", "bridge", "will", "be", "low", "and", "bus", "voltage", "is", "removed", "but", "current", "continues", "to", "circulate", "in", "the", "winding", "as", "it", "decays", "slowly", ".", "\\", "return", "None", "." ]
void StepCtrlOpenPwmSlow(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usFixedOnTime; if(lSetting > 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod - lSetting) / 2; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; if(g_usFixedOnTime == 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_PWMA_VAL; } else { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENA; pWinding->ulPwmGenCtlVal = CTRL_PIN_PWMA_VAL; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } else if(lSetting < 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod + lSetting) / 2; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; if(g_usFixedOnTime == 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_PWMA_VAL; } else { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_GENB; pWinding->ulPwmGenCtlVal = CTRL_PIN_PWMA_VAL; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } else { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; }
[ "void", "StepCtrlOpenPwmSlow", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "&=", "~", "pWinding", "->", "ulTmrEnaVal", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "g_usFixedOnTime", ";", "if", "(", "lSetting", ">", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_CMPA", ")", "=", "(", "g_ulPwmPeriod", "-", "lSetting", ")", "/", "2", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "if", "(", "g_usFixedOnTime", "==", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_PWMA_VAL", ";", "}", "else", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "CTRL_PIN_PWMA_VAL", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_FIXED_ON", ";", "}", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_CMPA", ")", "=", "(", "g_ulPwmPeriod", "+", "lSetting", ")", "/", "2", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "if", "(", "g_usFixedOnTime", "==", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_PWMA_VAL", ";", "}", "else", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "CTRL_PIN_PWMA_VAL", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_FIXED_ON", ";", "}", "}", "else", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "}" ]
Sets up a step using Open-loop PWM mode and slow decay.
[ "Sets", "up", "a", "step", "using", "Open", "-", "loop", "PWM", "mode", "and", "slow", "decay", "." ]
[ "//\r", "// Disable the fixed interval timer so it can be updated.\r", "// Set the load register to the fixed on time.\r", "// Equivalent DriverLib call:\r", "// TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usFixedOnTime);\r", "//\r", "//\r", "// Winding current is positive\r", "//\r", "//\r", "// Load the PWM comparator register to set the PWM pulse width\r", "// (duty cycle) according to the lSetting parameter. This sets\r", "// up the PWM, but the pin is not being switched yet.\r", "//\r", "//\r", "// Set the negative side low. The positive side will be turned\r", "// on (below) so that current flows in the winding in the positive\r", "// direction.\r", "//\r", "//\r", "// If the fixed on time is 0, then just set the positive side pin\r", "// directly to start PWM, and dont bother to start the fixed timer.\r", "// This will start PWMming on the winding.\r", "//\r", "//\r", "// If the fixed on time is set to a non-zero value, then the pin\r", "// is turned on for a fixed amount of time. The fixed timer is set\r", "// to time out after the fixed on time. The timer handler will\r", "// start PWM on the pin.\r", "//\r", "//\r", "// Turn the pin on.\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// timer ISR to turn the PWM on when the fixed time expires.\r", "//\r", "//\r", "// Start the fixed interval timer running. When the timer expires\r", "// it will start PWMming on the high side signal.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the timer state to indicate fixed on timing.\r", "//\r", "//\r", "// Winding current is negative.\r", "//\r", "//\r", "// Load the PWM comparator register to set the PWM pulse width\r", "// (duty cycle) according to the lSetting parameter. This sets\r", "// up the PWM, but the pin is not being switched yet.\r", "//\r", "//\r", "// Set the positive side low. The negative side will be turned\r", "// on (below) so that current flows in the winding in the negative\r", "// direction.\r", "//\r", "//\r", "// If the fixed on time is 0, then just set the negative side pin\r", "// directly to start PWM, and dont bother to start the fixed timer.\r", "// This will start PWMming on the winding.\r", "//\r", "//\r", "// If the fixed on time is set to a non-zero value, then the pin\r", "// is turned on for a fixed amount of time. The fixed timer is set\r", "// to time out after the fixed on time. The timer handler will\r", "// start PWM on the pin.\r", "//\r", "//\r", "// Turn the pin on.\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// timer ISR to turn the PWM on when the fixed time expires.\r", "//\r", "//\r", "// Start the fixed interval timer running. When the timer expires\r", "// it will start PWMming on the low side signal.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the timer state to indicate fixed on timing.\r", "//\r", "//\r", "// Winding is off\r", "//\r", "//\r", "// Set both positive and negative side low, so that there is\r", "// no voltage applied to the winding.\r", "//\r", "//\r", "// Turn on the enable signal for the winding.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlOpenPwmFast
void
void StepCtrlOpenPwmFast(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Disable the fixed interval timer so it can be updated. // Set the load register to the fixed on time. // Equivalent DriverLib call: // TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usFixedOnTime); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usFixedOnTime; // // Winding current is positive // if(lSetting > 0) { // // Set positive side high and negative side low, so the // winding is turned on, in the positive direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; // // Set the PWM pulse width for the winding enable signal, but // dont start PWM yet. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod - lSetting) / 2; // // If the fixed on time is 0, then just set the enable pin for // the winding directly to start PWM, and don't bother to start // the fixed timer. This will start PWMming on the winding // enable signal. // if(g_usFixedOnTime == 0) { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; } // // If the fixed on time is set to a non-zero value, then the // winding enable pin is turned on for a fixed amount of time. // The fixed timer is set to time out after the fixed on time. // The timer handler will start PWM on the enable pin. // else { // // Turn the enable pin on. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; // // Save the PWM register address and value that will be used by the // timer ISR to turn the PWM on when the fixed time expires. // pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; // // Start the fixed interval timer running. When the timer expires // it will start PWMming the enable signal. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the timer state to indicate fixed on timing. // pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } // // Winding current is negative. // else if(lSetting < 0) { // // Set negative side high and positive side low, so the // winding is turned on, in the negative direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Set the PWM pulse width for the winding enable signal, but // dont start PWM yet. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod + lSetting) / 2; // // If the fixed on time is 0, then just set the enable pin for // the winding directly to start PWM, and don't bother to start // the fixed timer. This will start PWMming on the winding // enable signal. // if(g_usFixedOnTime == 0) { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; } // // If the fixed on time is set to a non-zero value, then the // winding enable pin is turned on for a fixed amount of time. // The fixed timer is set to time out after the fixed on time. // The timer handler will start PWM on the enable pin. // else { // // Turn the enable pin on. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; // // Save the timer register address and value that will be used by the // timer ISR to turn the PWM on when the fixed time expires. // pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; // // Start the fixed interval timer running. // Equivalent DriverLib call: // TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>); // HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; // // Set the timer state to indicate fixed on timing. // pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } // // Winding is off // else { // // Set both positive and negative sides low, so that no // voltage is applied to the winding, and turn off the // winding enable pin. This will have the effect of opening // all the switches. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } }
//***************************************************************************** // //! Sets up a step using Open-loop PWM mode and fast decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the duration that the signal is on, in system //! clock ticks (signed to indicate polarity) //! //! This function will configure the PWM to control the pins needed //! for fast current decay. It drives the winding positive or negative //! (or off), according to the value and sign of the lSetting parameter. //! Once the control signals are set to apply voltage to the winding, //! the fixed timer is started with a timeout value for the fixed rise //! time. When the fixed timer times out, it will set the PWM generator //! to start using PWM for the control signal. There is no feedback from //! the measured current in the winding, which is why this is called //! open-loop PWM. //! //! The lSetting parameter is the duration in system clock ticks, that //! the PWM output will be on. This will be a fraction of the PWM period, //! resulting in the PWM duty cycle. It is a signed value, to indicate the //! direction the current should flow. //! //! For fast current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate driver enable signal is then turned on //! or off to control the current. When the enable signal is on, bus voltage //! is applied to the winding and current flows. When the enable signal is //! off, all the H-bridge switches are open and the current in the winding //! decays rapidly. //! //! \return None. // //*****************************************************************************
Sets up a step using Open-loop PWM mode and fast decay. \param ulWinding is the winding ID (A or B) \param lSetting is the duration that the signal is on, in system clock ticks (signed to indicate polarity) This function will configure the PWM to control the pins needed for fast current decay. It drives the winding positive or negative (or off), according to the value and sign of the lSetting parameter. Once the control signals are set to apply voltage to the winding, the fixed timer is started with a timeout value for the fixed rise time. When the fixed timer times out, it will set the PWM generator to start using PWM for the control signal. There is no feedback from the measured current in the winding, which is why this is called open-loop PWM. The lSetting parameter is the duration in system clock ticks, that the PWM output will be on. This will be a fraction of the PWM period, resulting in the PWM duty cycle. It is a signed value, to indicate the direction the current should flow. For fast current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate driver enable signal is then turned on or off to control the current. When the enable signal is on, bus voltage is applied to the winding and current flows. When the enable signal is off, all the H-bridge switches are open and the current in the winding decays rapidly. \return None.
[ "Sets", "up", "a", "step", "using", "Open", "-", "loop", "PWM", "mode", "and", "fast", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "duration", "that", "the", "signal", "is", "on", "in", "system", "clock", "ticks", "(", "signed", "to", "indicate", "polarity", ")", "This", "function", "will", "configure", "the", "PWM", "to", "control", "the", "pins", "needed", "for", "fast", "current", "decay", ".", "It", "drives", "the", "winding", "positive", "or", "negative", "(", "or", "off", ")", "according", "to", "the", "value", "and", "sign", "of", "the", "lSetting", "parameter", ".", "Once", "the", "control", "signals", "are", "set", "to", "apply", "voltage", "to", "the", "winding", "the", "fixed", "timer", "is", "started", "with", "a", "timeout", "value", "for", "the", "fixed", "rise", "time", ".", "When", "the", "fixed", "timer", "times", "out", "it", "will", "set", "the", "PWM", "generator", "to", "start", "using", "PWM", "for", "the", "control", "signal", ".", "There", "is", "no", "feedback", "from", "the", "measured", "current", "in", "the", "winding", "which", "is", "why", "this", "is", "called", "open", "-", "loop", "PWM", ".", "The", "lSetting", "parameter", "is", "the", "duration", "in", "system", "clock", "ticks", "that", "the", "PWM", "output", "will", "be", "on", ".", "This", "will", "be", "a", "fraction", "of", "the", "PWM", "period", "resulting", "in", "the", "PWM", "duty", "cycle", ".", "It", "is", "a", "signed", "value", "to", "indicate", "the", "direction", "the", "current", "should", "flow", ".", "For", "fast", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "driver", "enable", "signal", "is", "then", "turned", "on", "or", "off", "to", "control", "the", "current", ".", "When", "the", "enable", "signal", "is", "on", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "the", "enable", "signal", "is", "off", "all", "the", "H", "-", "bridge", "switches", "are", "open", "and", "the", "current", "in", "the", "winding", "decays", "rapidly", ".", "\\", "return", "None", "." ]
void StepCtrlOpenPwmFast(unsigned long ulWinding, long lSetting) { tWinding *pWinding; pWinding = &sWinding[ulWinding]; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) &= ~pWinding->ulTmrEnaVal; HWREG(pWinding->ulTmrLoadAddr) = g_usFixedOnTime; if(lSetting > 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod - lSetting) / 2; if(g_usFixedOnTime == 0) { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; } else { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } else if(lSetting < 0) { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod + lSetting) / 2; if(g_usFixedOnTime == 0) { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; } else { HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB; pWinding->ulPwmGenCtlVal = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; HWREG(FIXED_TMR_BASE + TIMER_O_CTL) |= pWinding->ulTmrEnaVal; pWinding->ucTimerState = TIMER_STATE_FIXED_ON; } } else { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } }
[ "void", "StepCtrlOpenPwmFast", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "&=", "~", "pWinding", "->", "ulTmrEnaVal", ";", "HWREG", "(", "pWinding", "->", "ulTmrLoadAddr", ")", "=", "g_usFixedOnTime", ";", "if", "(", "lSetting", ">", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_CMPA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "g_ulPwmPeriod", "-", "lSetting", ")", "/", "2", ";", "if", "(", "g_usFixedOnTime", "==", "0", ")", "{", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "}", "else", "{", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_FIXED_ON", ";", "}", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_CMPA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "g_ulPwmPeriod", "+", "lSetting", ")", "/", "2", ";", "if", "(", "g_usFixedOnTime", "==", "0", ")", "{", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "}", "else", "{", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ";", "pWinding", "->", "ulPwmGenCtlVal", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "HWREG", "(", "FIXED_TMR_BASE", "+", "TIMER_O_CTL", ")", "|=", "pWinding", "->", "ulTmrEnaVal", ";", "pWinding", "->", "ucTimerState", "=", "TIMER_STATE_FIXED_ON", ";", "}", "}", "else", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "}" ]
Sets up a step using Open-loop PWM mode and fast decay.
[ "Sets", "up", "a", "step", "using", "Open", "-", "loop", "PWM", "mode", "and", "fast", "decay", "." ]
[ "//\r", "// Disable the fixed interval timer so it can be updated.\r", "// Set the load register to the fixed on time.\r", "// Equivalent DriverLib call:\r", "// TimerDisable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "// TimerLoadSet(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>, g_usFixedOnTime);\r", "//\r", "//\r", "// Winding current is positive\r", "//\r", "//\r", "// Set positive side high and negative side low, so the\r", "// winding is turned on, in the positive direction.\r", "//\r", "//\r", "// Set the PWM pulse width for the winding enable signal, but\r", "// dont start PWM yet.\r", "//\r", "//\r", "// If the fixed on time is 0, then just set the enable pin for\r", "// the winding directly to start PWM, and don't bother to start\r", "// the fixed timer. This will start PWMming on the winding\r", "// enable signal.\r", "//\r", "//\r", "// If the fixed on time is set to a non-zero value, then the\r", "// winding enable pin is turned on for a fixed amount of time.\r", "// The fixed timer is set to time out after the fixed on time.\r", "// The timer handler will start PWM on the enable pin.\r", "//\r", "//\r", "// Turn the enable pin on.\r", "//\r", "//\r", "// Save the PWM register address and value that will be used by the\r", "// timer ISR to turn the PWM on when the fixed time expires.\r", "//\r", "//\r", "// Start the fixed interval timer running. When the timer expires\r", "// it will start PWMming the enable signal.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the timer state to indicate fixed on timing.\r", "//\r", "//\r", "// Winding current is negative.\r", "//\r", "//\r", "// Set negative side high and positive side low, so the\r", "// winding is turned on, in the negative direction.\r", "//\r", "//\r", "// Set the PWM pulse width for the winding enable signal, but\r", "// dont start PWM yet.\r", "//\r", "//\r", "// If the fixed on time is 0, then just set the enable pin for\r", "// the winding directly to start PWM, and don't bother to start\r", "// the fixed timer. This will start PWMming on the winding\r", "// enable signal.\r", "//\r", "//\r", "// If the fixed on time is set to a non-zero value, then the\r", "// winding enable pin is turned on for a fixed amount of time.\r", "// The fixed timer is set to time out after the fixed on time.\r", "// The timer handler will start PWM on the enable pin.\r", "//\r", "//\r", "// Turn the enable pin on.\r", "//\r", "//\r", "// Save the timer register address and value that will be used by the\r", "// timer ISR to turn the PWM on when the fixed time expires.\r", "//\r", "//\r", "// Start the fixed interval timer running.\r", "// Equivalent DriverLib call:\r", "// TimerEnable(FIXED_TMR_BASE, <TIMER_A OR TIMER_B>);\r", "//\r", "//\r", "// Set the timer state to indicate fixed on timing.\r", "//\r", "//\r", "// Winding is off\r", "//\r", "//\r", "// Set both positive and negative sides low, so that no\r", "// voltage is applied to the winding, and turn off the\r", "// winding enable pin. This will have the effect of opening\r", "// all the switches.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlClosedPwmSlow
void
void StepCtrlClosedPwmSlow(unsigned long ulWinding, long lSetting) { unsigned long ulSeqTrigger; tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Stop ADC handler from doing anything while the current is being // reconfigured. // pWinding->ulPwmGenCtlReg = 0; // // Initialize the pulse width to minimum, prevents an initial overcurrent. // Equivalent DriverLib call: // PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, MIN_PWM_COUNTS); // HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod - MIN_PWM_COUNTS) / 2; // // Winding current is positive, set the negative side low, // and PWM on the positive side. // if(lSetting > 0) { // // Save the target current threshold. // pWinding->ulChopperCurrent = lSetting; // // Set positive side to PWM using comparator A, and the negative // side low, so the winding is turned on in the positive direction. // This will apply positive, PWM'd voltage. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_PWMA_VAL; // // Save the address of the PWM comparator used to adjust the pulse // width. This will be used by the ADC handler to adjust the // duty cycle according to the measured current. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_CMPA; } // // Winding current is negative, set the positive side low, // and PWm on the negative side. // else if(lSetting < 0) { // // Save the target current threshold. // pWinding->ulChopperCurrent = -lSetting; // // Set negative side to PWM using comparator A, and the positive // side low, so the winding is turned on in the negative direction. // This will apply negative, PWM'd voltage. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_PWMA_VAL; // // Save the address of the PWM comparator used to adjust the pulse // width. This will be used by the ADC handler to adjust the // duty cycle according to the measured current. // pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_CMPA; } // // Winding current is 0, set both sides low. // else { // // Set the target current threshold to 0. // pWinding->ulChopperCurrent = 0; // // Set both positive and negative side low, so that there is // no voltage applied to the winding. // pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } // // Turn on the enable signal for the winding. ulPwmAB is used to // select the correct half (A or B) of the PWM generator for the // winding enable signals. For slow decay, the enable signal is // always left on. // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; // // Set the ADC sequencer for this winding to trigger on the PWM // generator. This will cause the ADC to trigger acquisitions based // on the falling edge of comparator B. // // Get the current register value for sequencer triggers. // ulSeqTrigger = HWREG(ADC0_BASE + ADC_O_EMUX) & ~(0x0f << (pWinding->ucADCSeq * 4)); // // Figure out which PWM trigger to use. // if(ulWinding == WINDING_ID_A) { ulSeqTrigger |= ADC_TRIGGER_PWM0 << (pWinding->ucADCSeq * 4); } else { ulSeqTrigger |= ADC_TRIGGER_PWM1 << (pWinding->ucADCSeq * 4); } // // Save the new trigger value. // HWREG(ADC0_BASE + ADC_O_EMUX) = ulSeqTrigger; }
//***************************************************************************** // //! Sets up a step using Closed-loop PWM mode and slow decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the target winding current (signed), in raw ADC counts //! //! This function will configure the PWM to control the pins needed for //! slow current decay. It sets the winding for positive or negative //! current, depending on the value of the lSetting parameter. The high //! side will be set to switch on and off according to a PWM generator. //! The pulse width will be controlled by the ADC handler which will measure //! the actual current and adjust the PWM pulse width accordingly. //! //! For slow current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate drivers are always enabled. To control //! current, the "high" side of the H-bridge is switched between high and //! low. When it is high, the bus voltage is applied to the winding and //! current flows. When it is low, then both sides of the H-bridge will be //! low, and bus voltage is removed, but current continues to circulate in //! the winding as it decays slowly. //! //! \return None. // //*****************************************************************************
Sets up a step using Closed-loop PWM mode and slow decay. \param ulWinding is the winding ID (A or B) \param lSetting is the target winding current (signed), in raw ADC counts This function will configure the PWM to control the pins needed for slow current decay. It sets the winding for positive or negative current, depending on the value of the lSetting parameter. The high side will be set to switch on and off according to a PWM generator. The pulse width will be controlled by the ADC handler which will measure the actual current and adjust the PWM pulse width accordingly. For slow current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate drivers are always enabled. To control current, the "high" side of the H-bridge is switched between high and low. When it is high, the bus voltage is applied to the winding and current flows. When it is low, then both sides of the H-bridge will be low, and bus voltage is removed, but current continues to circulate in the winding as it decays slowly. \return None.
[ "Sets", "up", "a", "step", "using", "Closed", "-", "loop", "PWM", "mode", "and", "slow", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "target", "winding", "current", "(", "signed", ")", "in", "raw", "ADC", "counts", "This", "function", "will", "configure", "the", "PWM", "to", "control", "the", "pins", "needed", "for", "slow", "current", "decay", ".", "It", "sets", "the", "winding", "for", "positive", "or", "negative", "current", "depending", "on", "the", "value", "of", "the", "lSetting", "parameter", ".", "The", "high", "side", "will", "be", "set", "to", "switch", "on", "and", "off", "according", "to", "a", "PWM", "generator", ".", "The", "pulse", "width", "will", "be", "controlled", "by", "the", "ADC", "handler", "which", "will", "measure", "the", "actual", "current", "and", "adjust", "the", "PWM", "pulse", "width", "accordingly", ".", "For", "slow", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "drivers", "are", "always", "enabled", ".", "To", "control", "current", "the", "\"", "high", "\"", "side", "of", "the", "H", "-", "bridge", "is", "switched", "between", "high", "and", "low", ".", "When", "it", "is", "high", "the", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "it", "is", "low", "then", "both", "sides", "of", "the", "H", "-", "bridge", "will", "be", "low", "and", "bus", "voltage", "is", "removed", "but", "current", "continues", "to", "circulate", "in", "the", "winding", "as", "it", "decays", "slowly", ".", "\\", "return", "None", "." ]
void StepCtrlClosedPwmSlow(unsigned long ulWinding, long lSetting) { unsigned long ulSeqTrigger; tWinding *pWinding; pWinding = &sWinding[ulWinding]; pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_CMPA) = (g_ulPwmPeriod - MIN_PWM_COUNTS) / 2; if(lSetting > 0) { pWinding->ulChopperCurrent = lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_PWMA_VAL; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_CMPA; } else if(lSetting < 0) { pWinding->ulChopperCurrent = -lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_PWMA_VAL; pWinding->ulPwmGenCtlReg = pWinding->ulPwmGenBase + PWM_O_X_CMPA; } else { pWinding->ulChopperCurrent = 0; pWinding->ulPwmGenCtlReg = 0; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; } HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_ON_VAL; ulSeqTrigger = HWREG(ADC0_BASE + ADC_O_EMUX) & ~(0x0f << (pWinding->ucADCSeq * 4)); if(ulWinding == WINDING_ID_A) { ulSeqTrigger |= ADC_TRIGGER_PWM0 << (pWinding->ucADCSeq * 4); } else { ulSeqTrigger |= ADC_TRIGGER_PWM1 << (pWinding->ucADCSeq * 4); } HWREG(ADC0_BASE + ADC_O_EMUX) = ulSeqTrigger; }
[ "void", "StepCtrlClosedPwmSlow", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "unsigned", "long", "ulSeqTrigger", ";", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_CMPA", ")", "=", "(", "g_ulPwmPeriod", "-", "MIN_PWM_COUNTS", ")", "/", "2", ";", "if", "(", "lSetting", ">", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_PWMA_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_CMPA", ";", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "-", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_PWMA_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_CMPA", ";", "}", "else", "{", "pWinding", "->", "ulChopperCurrent", "=", "0", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_ON_VAL", ";", "ulSeqTrigger", "=", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_EMUX", ")", "&", "~", "(", "0x0f", "<<", "(", "pWinding", "->", "ucADCSeq", "*", "4", ")", ")", ";", "if", "(", "ulWinding", "==", "WINDING_ID_A", ")", "{", "ulSeqTrigger", "|=", "ADC_TRIGGER_PWM0", "<<", "(", "pWinding", "->", "ucADCSeq", "*", "4", ")", ";", "}", "else", "{", "ulSeqTrigger", "|=", "ADC_TRIGGER_PWM1", "<<", "(", "pWinding", "->", "ucADCSeq", "*", "4", ")", ";", "}", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_EMUX", ")", "=", "ulSeqTrigger", ";", "}" ]
Sets up a step using Closed-loop PWM mode and slow decay.
[ "Sets", "up", "a", "step", "using", "Closed", "-", "loop", "PWM", "mode", "and", "slow", "decay", "." ]
[ "//\r", "// Stop ADC handler from doing anything while the current is being\r", "// reconfigured.\r", "//\r", "//\r", "// Initialize the pulse width to minimum, prevents an initial overcurrent.\r", "// Equivalent DriverLib call:\r", "// PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, MIN_PWM_COUNTS);\r", "//\r", "//\r", "// Winding current is positive, set the negative side low,\r", "// and PWM on the positive side.\r", "//\r", "//\r", "// Save the target current threshold.\r", "//\r", "//\r", "// Set positive side to PWM using comparator A, and the negative\r", "// side low, so the winding is turned on in the positive direction.\r", "// This will apply positive, PWM'd voltage.\r", "//\r", "//\r", "// Save the address of the PWM comparator used to adjust the pulse\r", "// width. This will be used by the ADC handler to adjust the\r", "// duty cycle according to the measured current.\r", "//\r", "//\r", "// Winding current is negative, set the positive side low,\r", "// and PWm on the negative side.\r", "//\r", "//\r", "// Save the target current threshold.\r", "//\r", "//\r", "// Set negative side to PWM using comparator A, and the positive\r", "// side low, so the winding is turned on in the negative direction.\r", "// This will apply negative, PWM'd voltage.\r", "//\r", "//\r", "// Save the address of the PWM comparator used to adjust the pulse\r", "// width. This will be used by the ADC handler to adjust the\r", "// duty cycle according to the measured current.\r", "//\r", "//\r", "// Winding current is 0, set both sides low.\r", "//\r", "//\r", "// Set the target current threshold to 0.\r", "//\r", "//\r", "// Set both positive and negative side low, so that there is\r", "// no voltage applied to the winding.\r", "//\r", "//\r", "// Turn on the enable signal for the winding. ulPwmAB is used to\r", "// select the correct half (A or B) of the PWM generator for the\r", "// winding enable signals. For slow decay, the enable signal is\r", "// always left on.\r", "//\r", "//\r", "// Set the ADC sequencer for this winding to trigger on the PWM\r", "// generator. This will cause the ADC to trigger acquisitions based\r", "// on the falling edge of comparator B.\r", "//\r", "// Get the current register value for sequencer triggers.\r", "//\r", "//\r", "// Figure out which PWM trigger to use.\r", "//\r", "//\r", "// Save the new trigger value.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlClosedPwmFast
void
void StepCtrlClosedPwmFast(unsigned long ulWinding, long lSetting) { unsigned long ulSeqTrigger; tWinding *pWinding; pWinding = &sWinding[ulWinding]; // // Stop ADC handler from doing anything while the current is being // reconfigured. // pWinding->ulPwmGenCtlReg = 0; // // Initialize the pulse width to minimum, prevents an initial overcurrent. // Equivalent DriverLib call: // PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, MIN_PWM_COUNTS); // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod - MIN_PWM_COUNTS) / 2; // // Winding current is positive // if(lSetting > 0) { // // Save the target current threshold. // pWinding->ulChopperCurrent = lSetting; // // Set positive side high and negative side low, so the // winding is turned on, in the positive direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; // // Set the enable pin to PWM, based on comparator A or B (for // winding A or B). // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; // // Save the address of the PWM comparator used to adjust the pulse // width. This will be used by the ADC handler to adjust the // duty cycle according to the measured current. // pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB; } // // Winding current is negative. // else if(lSetting < 0) { // // Save the target current threshold. // pWinding->ulChopperCurrent = -lSetting; // // Set negative side high and positive side low, so the // winding is turned on, in the negative direction. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; // // Set the enable pin to PWM, based on comparator A or B (for // winding A or B). // HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; // // Save the address of the PWM comparator used to adjust the pulse // width. This will be used by the ADC handler to adjust the // duty cycle according to the measured current. // pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB; } // // Winding is off // else { // // Set both positive and negative sides low, so that no // voltage is applied to the winding, and turn off the // winding enable pin. This will have the effect of opening // all the switches. // HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } // // Set the ADC sequencer for this winding to trigger on the PWM // generator. This will cause the ADC to trigger acquisitions based // on the center of the PWM pulse on the enable line (because PWM_GEN_2 // was configured for trigger on load). // // Get the current register value for sequencer triggers. // ulSeqTrigger = HWREG(ADC0_BASE + ADC_O_EMUX) & ~(0x0f << (pWinding->ucADCSeq * 4)); // // Set to trigger on PWM 2 (the PWM generator used for the enable // signals). // ulSeqTrigger |= ADC_TRIGGER_PWM2 << (pWinding->ucADCSeq * 4); // // Save the new trigger value. // HWREG(ADC0_BASE + ADC_O_EMUX) = ulSeqTrigger; }
//***************************************************************************** // //! Sets up a step using Closed-loop PWM mode and fast decay. //! //! \param ulWinding is the winding ID (A or B) //! \param lSetting is the target winding current (signed), in raw ADC counts //! //! This function will configure the PWM to control the pins needed for //! fast current decay. Its sets the winding gate drivers for positive or //! negative current depending on the lSetting parameter. Then the enable //! signal for the winding is set to be switched on and off by a PWM //! generator. The pulse width will be controlled by the ADC handler which //! will measure the actual current and adjust the PWM pulse width accordingly. //! //! For fast current decay, one side of the H-bridge is set high, and the //! other side is set low, to cause current to flow in the positive or //! negative direction. The gate driver enable signal is then turned on //! or off to control the current. When the enable signal is on, bus voltage //! is applied to the winding and current flows. When the enable signal is //! off, all the H-bridge switches are open and the current in the winding //! decays rapidly. //! //! \return None. // //*****************************************************************************
Sets up a step using Closed-loop PWM mode and fast decay. \param ulWinding is the winding ID (A or B) \param lSetting is the target winding current (signed), in raw ADC counts This function will configure the PWM to control the pins needed for fast current decay. Its sets the winding gate drivers for positive or negative current depending on the lSetting parameter. Then the enable signal for the winding is set to be switched on and off by a PWM generator. The pulse width will be controlled by the ADC handler which will measure the actual current and adjust the PWM pulse width accordingly. For fast current decay, one side of the H-bridge is set high, and the other side is set low, to cause current to flow in the positive or negative direction. The gate driver enable signal is then turned on or off to control the current. When the enable signal is on, bus voltage is applied to the winding and current flows. When the enable signal is off, all the H-bridge switches are open and the current in the winding decays rapidly. \return None.
[ "Sets", "up", "a", "step", "using", "Closed", "-", "loop", "PWM", "mode", "and", "fast", "decay", ".", "\\", "param", "ulWinding", "is", "the", "winding", "ID", "(", "A", "or", "B", ")", "\\", "param", "lSetting", "is", "the", "target", "winding", "current", "(", "signed", ")", "in", "raw", "ADC", "counts", "This", "function", "will", "configure", "the", "PWM", "to", "control", "the", "pins", "needed", "for", "fast", "current", "decay", ".", "Its", "sets", "the", "winding", "gate", "drivers", "for", "positive", "or", "negative", "current", "depending", "on", "the", "lSetting", "parameter", ".", "Then", "the", "enable", "signal", "for", "the", "winding", "is", "set", "to", "be", "switched", "on", "and", "off", "by", "a", "PWM", "generator", ".", "The", "pulse", "width", "will", "be", "controlled", "by", "the", "ADC", "handler", "which", "will", "measure", "the", "actual", "current", "and", "adjust", "the", "PWM", "pulse", "width", "accordingly", ".", "For", "fast", "current", "decay", "one", "side", "of", "the", "H", "-", "bridge", "is", "set", "high", "and", "the", "other", "side", "is", "set", "low", "to", "cause", "current", "to", "flow", "in", "the", "positive", "or", "negative", "direction", ".", "The", "gate", "driver", "enable", "signal", "is", "then", "turned", "on", "or", "off", "to", "control", "the", "current", ".", "When", "the", "enable", "signal", "is", "on", "bus", "voltage", "is", "applied", "to", "the", "winding", "and", "current", "flows", ".", "When", "the", "enable", "signal", "is", "off", "all", "the", "H", "-", "bridge", "switches", "are", "open", "and", "the", "current", "in", "the", "winding", "decays", "rapidly", ".", "\\", "return", "None", "." ]
void StepCtrlClosedPwmFast(unsigned long ulWinding, long lSetting) { unsigned long ulSeqTrigger; tWinding *pWinding; pWinding = &sWinding[ulWinding]; pWinding->ulPwmGenCtlReg = 0; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB) = (g_ulPwmPeriod - MIN_PWM_COUNTS) / 2; if(lSetting > 0) { pWinding->ulChopperCurrent = lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB; } else if(lSetting < 0) { pWinding->ulChopperCurrent = -lSetting; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_ON_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = (ulWinding == WINDING_ID_A) ? CTRL_PIN_PWMA_VAL : CTRL_PIN_PWMB_VAL; pWinding->ulPwmGenCtlReg = WINDING_EN_GEN_BASE + PWM_O_X_CMPA + pWinding->ulPwmAB; } else { HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENA) = CTRL_PIN_OFF_VAL; HWREG(pWinding->ulPwmGenBase + PWM_O_X_GENB) = CTRL_PIN_OFF_VAL; HWREG(WINDING_EN_GEN_BASE + PWM_O_X_GENA + pWinding->ulPwmAB) = CTRL_PIN_OFF_VAL; } ulSeqTrigger = HWREG(ADC0_BASE + ADC_O_EMUX) & ~(0x0f << (pWinding->ucADCSeq * 4)); ulSeqTrigger |= ADC_TRIGGER_PWM2 << (pWinding->ucADCSeq * 4); HWREG(ADC0_BASE + ADC_O_EMUX) = ulSeqTrigger; }
[ "void", "StepCtrlClosedPwmFast", "(", "unsigned", "long", "ulWinding", ",", "long", "lSetting", ")", "{", "unsigned", "long", "ulSeqTrigger", ";", "tWinding", "*", "pWinding", ";", "pWinding", "=", "&", "sWinding", "[", "ulWinding", "]", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "0", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_CMPA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "g_ulPwmPeriod", "-", "MIN_PWM_COUNTS", ")", "/", "2", ";", "if", "(", "lSetting", ">", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_CMPA", "+", "pWinding", "->", "ulPwmAB", ";", "}", "else", "if", "(", "lSetting", "<", "0", ")", "{", "pWinding", "->", "ulChopperCurrent", "=", "-", "lSetting", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_ON_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "(", "ulWinding", "==", "WINDING_ID_A", ")", "?", "CTRL_PIN_PWMA_VAL", ":", "CTRL_PIN_PWMB_VAL", ";", "pWinding", "->", "ulPwmGenCtlReg", "=", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_CMPA", "+", "pWinding", "->", "ulPwmAB", ";", "}", "else", "{", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENA", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "pWinding", "->", "ulPwmGenBase", "+", "PWM_O_X_GENB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "HWREG", "(", "WINDING_EN_GEN_BASE", "+", "PWM_O_X_GENA", "+", "pWinding", "->", "ulPwmAB", ")", "=", "CTRL_PIN_OFF_VAL", ";", "}", "ulSeqTrigger", "=", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_EMUX", ")", "&", "~", "(", "0x0f", "<<", "(", "pWinding", "->", "ucADCSeq", "*", "4", ")", ")", ";", "ulSeqTrigger", "|=", "ADC_TRIGGER_PWM2", "<<", "(", "pWinding", "->", "ucADCSeq", "*", "4", ")", ";", "HWREG", "(", "ADC0_BASE", "+", "ADC_O_EMUX", ")", "=", "ulSeqTrigger", ";", "}" ]
Sets up a step using Closed-loop PWM mode and fast decay.
[ "Sets", "up", "a", "step", "using", "Closed", "-", "loop", "PWM", "mode", "and", "fast", "decay", "." ]
[ "//\r", "// Stop ADC handler from doing anything while the current is being\r", "// reconfigured.\r", "//\r", "//\r", "// Initialize the pulse width to minimum, prevents an initial overcurrent.\r", "// Equivalent DriverLib call:\r", "// PWMPulseWidthSet(PWM0_BASE, PWM_OUT_n, MIN_PWM_COUNTS);\r", "//\r", "//\r", "// Winding current is positive\r", "//\r", "//\r", "// Save the target current threshold.\r", "//\r", "//\r", "// Set positive side high and negative side low, so the\r", "// winding is turned on, in the positive direction.\r", "//\r", "//\r", "// Set the enable pin to PWM, based on comparator A or B (for\r", "// winding A or B).\r", "//\r", "//\r", "// Save the address of the PWM comparator used to adjust the pulse\r", "// width. This will be used by the ADC handler to adjust the\r", "// duty cycle according to the measured current.\r", "//\r", "//\r", "// Winding current is negative.\r", "//\r", "//\r", "// Save the target current threshold.\r", "//\r", "//\r", "// Set negative side high and positive side low, so the\r", "// winding is turned on, in the negative direction.\r", "//\r", "//\r", "// Set the enable pin to PWM, based on comparator A or B (for\r", "// winding A or B).\r", "//\r", "//\r", "// Save the address of the PWM comparator used to adjust the pulse\r", "// width. This will be used by the ADC handler to adjust the\r", "// duty cycle according to the measured current.\r", "//\r", "//\r", "// Winding is off\r", "//\r", "//\r", "// Set both positive and negative sides low, so that no\r", "// voltage is applied to the winding, and turn off the\r", "// winding enable pin. This will have the effect of opening\r", "// all the switches.\r", "//\r", "//\r", "// Set the ADC sequencer for this winding to trigger on the PWM\r", "// generator. This will cause the ADC to trigger acquisitions based\r", "// on the center of the PWM pulse on the enable line (because PWM_GEN_2\r", "// was configured for trigger on load).\r", "//\r", "// Get the current register value for sequencer triggers.\r", "//\r", "//\r", "// Set to trigger on PWM 2 (the PWM generator used for the enable\r", "// signals).\r", "//\r", "//\r", "// Save the new trigger value.\r", "//\r" ]
[ { "param": "ulWinding", "type": "unsigned long" }, { "param": "lSetting", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ulWinding", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lSetting", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f999b5e508478788628791d9b12edd32f910210
junyanl-code/Luminary-Micro-Library
boards/rdk-stepper/qs-stepper/stepctrl.c
[ "BSD-3-Clause" ]
C
StepCtrlInit
void
void StepCtrlInit(void) { // // Enable the PWM peripheral block, and the GPIO ports associated // with the PWM pins. // SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(FIXED_TMR_PERIPH); // // Enable the ADC peripheral, needed for winding current. // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // // Set the ADC to run at the maximum rate of 500 ksamples. // SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); // // Enable the peripherals that should continue to run when the processor // is sleeping. // SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralSleepEnable(FIXED_TMR_PERIPH); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0); // // Set up the timer used for the fixed interval timer. // TimerConfigure(FIXED_TMR_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_ONE_SHOT | TIMER_CFG_B_ONE_SHOT); TimerControlStall(FIXED_TMR_BASE, TIMER_BOTH, 1); TimerPrescaleSet(FIXED_TMR_BASE, TIMER_BOTH, 50); TimerIntEnable(FIXED_TMR_BASE, TIMER_TIMA_TIMEOUT | TIMER_TIMB_TIMEOUT); IntEnable(FIXED_TMR_INT_A); IntEnable(FIXED_TMR_INT_B); IntPrioritySet(FIXED_TMR_INT_A, FIXED_TMR_INT_PRI); IntPrioritySet(FIXED_TMR_INT_B, FIXED_TMR_INT_PRI); // // Initialize the ADC sequencers for windings A and B. // There is one sequencer for each winding. Configure each to take // two samples and generate an interrupt. // Two samples are used for each, because the first sample taken by // the ADC after the winding is first turned on, occurs too fast // for an accurate measurement to be made. By using two samples at // each acquisition, it is guaranteed that the second sample will be // an accurate measurement of the current. // ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceStepConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, 0, WINDING_A_ADC_CHANNEL | ADC_CTL_END | ADC_CTL_IE); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); ADCSequenceStepConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, 0, WINDING_B_ADC_CHANNEL | ADC_CTL_END | ADC_CTL_IE); // // Enable the ADC sequencers, and enable the interrupts. // ADCSequenceEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); ADCIntEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); IntEnable(WINDING_A_ADC_INT); IntPrioritySet(WINDING_A_ADC_INT, ADC_INT_PRI); ADCSequenceEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); ADCIntEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); IntEnable(WINDING_B_ADC_INT); IntPrioritySet(WINDING_B_ADC_INT, ADC_INT_PRI); // // Initialize all of the PWM generators. // PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); // // PWM 4 and 5 pins are connected to the gate driver enable pins, // which are active low, so set them to invert. // PWMOutputInvert(PWM0_BASE, PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); // // Enable all the PWM generators. // PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMGenEnable(PWM0_BASE, PWM_GEN_1); PWMGenEnable(PWM0_BASE, PWM_GEN_2); // // Configure the PWM pins to be controlled by the PWM generators. // GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Start off in chopper mode, by default // StepCtrlChopMode(); // // Configure PWM outputs to safe on fault. // Enable the PWM outputs. // PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); PWMOutputFault(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); }
//***************************************************************************** // //! Initializes the step control module. //! //! This function initializes all the peripherals used by this module //! for controlling the stepper motor. //! //! \return None. // //*****************************************************************************
Initializes the step control module. This function initializes all the peripherals used by this module for controlling the stepper motor. \return None.
[ "Initializes", "the", "step", "control", "module", ".", "This", "function", "initializes", "all", "the", "peripherals", "used", "by", "this", "module", "for", "controlling", "the", "stepper", "motor", ".", "\\", "return", "None", "." ]
void StepCtrlInit(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(FIXED_TMR_PERIPH); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralSleepEnable(FIXED_TMR_PERIPH); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0); TimerConfigure(FIXED_TMR_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_ONE_SHOT | TIMER_CFG_B_ONE_SHOT); TimerControlStall(FIXED_TMR_BASE, TIMER_BOTH, 1); TimerPrescaleSet(FIXED_TMR_BASE, TIMER_BOTH, 50); TimerIntEnable(FIXED_TMR_BASE, TIMER_TIMA_TIMEOUT | TIMER_TIMB_TIMEOUT); IntEnable(FIXED_TMR_INT_A); IntEnable(FIXED_TMR_INT_B); IntPrioritySet(FIXED_TMR_INT_A, FIXED_TMR_INT_PRI); IntPrioritySet(FIXED_TMR_INT_B, FIXED_TMR_INT_PRI); ADCSequenceConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_A_ADC_PRIORITY); ADCSequenceStepConfigure(ADC0_BASE, WINDING_A_ADC_SEQUENCER, 0, WINDING_A_ADC_CHANNEL | ADC_CTL_END | ADC_CTL_IE); ADCSequenceConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, WINDING_B_ADC_PRIORITY); ADCSequenceStepConfigure(ADC0_BASE, WINDING_B_ADC_SEQUENCER, 0, WINDING_B_ADC_CHANNEL | ADC_CTL_END | ADC_CTL_IE); ADCSequenceEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); ADCIntEnable(ADC0_BASE, WINDING_A_ADC_SEQUENCER); IntEnable(WINDING_A_ADC_INT); IntPrioritySet(WINDING_A_ADC_INT, ADC_INT_PRI); ADCSequenceEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); ADCIntEnable(ADC0_BASE, WINDING_B_ADC_SEQUENCER); IntEnable(WINDING_B_ADC_INT); IntPrioritySet(WINDING_B_ADC_INT, ADC_INT_PRI); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP); PWMOutputInvert(PWM0_BASE, PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMGenEnable(PWM0_BASE, PWM_GEN_1); PWMGenEnable(PWM0_BASE, PWM_GEN_2); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1); StepCtrlChopMode(); PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); PWMOutputFault(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, 1); }
[ "void", "StepCtrlInit", "(", "void", ")", "{", "SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_PWM0", ")", ";", "SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_GPIOB", ")", ";", "SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_GPIOD", ")", ";", "SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_GPIOE", ")", ";", "SysCtlPeripheralEnable", "(", "FIXED_TMR_PERIPH", ")", ";", "SysCtlPeripheralEnable", "(", "SYSCTL_PERIPH_ADC0", ")", ";", "SysCtlADCSpeedSet", "(", "SYSCTL_ADCSPEED_500KSPS", ")", ";", "SysCtlPeripheralSleepEnable", "(", "SYSCTL_PERIPH_PWM0", ")", ";", "SysCtlPeripheralSleepEnable", "(", "FIXED_TMR_PERIPH", ")", ";", "SysCtlPeripheralSleepEnable", "(", "SYSCTL_PERIPH_ADC0", ")", ";", "TimerConfigure", "(", "FIXED_TMR_BASE", ",", "TIMER_CFG_SPLIT_PAIR", "|", "TIMER_CFG_A_ONE_SHOT", "|", "TIMER_CFG_B_ONE_SHOT", ")", ";", "TimerControlStall", "(", "FIXED_TMR_BASE", ",", "TIMER_BOTH", ",", "1", ")", ";", "TimerPrescaleSet", "(", "FIXED_TMR_BASE", ",", "TIMER_BOTH", ",", "50", ")", ";", "TimerIntEnable", "(", "FIXED_TMR_BASE", ",", "TIMER_TIMA_TIMEOUT", "|", "TIMER_TIMB_TIMEOUT", ")", ";", "IntEnable", "(", "FIXED_TMR_INT_A", ")", ";", "IntEnable", "(", "FIXED_TMR_INT_B", ")", ";", "IntPrioritySet", "(", "FIXED_TMR_INT_A", ",", "FIXED_TMR_INT_PRI", ")", ";", "IntPrioritySet", "(", "FIXED_TMR_INT_B", ",", "FIXED_TMR_INT_PRI", ")", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_A_ADC_PRIORITY", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ",", "0", ",", "WINDING_A_ADC_CHANNEL", "|", "ADC_CTL_END", "|", "ADC_CTL_IE", ")", ";", "ADCSequenceConfigure", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ",", "ADC_TRIGGER_PROCESSOR", ",", "WINDING_B_ADC_PRIORITY", ")", ";", "ADCSequenceStepConfigure", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ",", "0", ",", "WINDING_B_ADC_CHANNEL", "|", "ADC_CTL_END", "|", "ADC_CTL_IE", ")", ";", "ADCSequenceEnable", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ")", ";", "ADCIntEnable", "(", "ADC0_BASE", ",", "WINDING_A_ADC_SEQUENCER", ")", ";", "IntEnable", "(", "WINDING_A_ADC_INT", ")", ";", "IntPrioritySet", "(", "WINDING_A_ADC_INT", ",", "ADC_INT_PRI", ")", ";", "ADCSequenceEnable", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ")", ";", "ADCIntEnable", "(", "ADC0_BASE", ",", "WINDING_B_ADC_SEQUENCER", ")", ";", "IntEnable", "(", "WINDING_B_ADC_INT", ")", ";", "IntPrioritySet", "(", "WINDING_B_ADC_INT", ",", "ADC_INT_PRI", ")", ";", "PWMGenConfigure", "(", "PWM0_BASE", ",", "PWM_GEN_0", ",", "PWM_GEN_MODE_UP_DOWN", "|", "PWM_GEN_MODE_NO_SYNC", "|", "PWM_GEN_MODE_DBG_STOP", ")", ";", "PWMGenConfigure", "(", "PWM0_BASE", ",", "PWM_GEN_1", ",", "PWM_GEN_MODE_UP_DOWN", "|", "PWM_GEN_MODE_NO_SYNC", "|", "PWM_GEN_MODE_DBG_STOP", ")", ";", "PWMGenConfigure", "(", "PWM0_BASE", ",", "PWM_GEN_2", ",", "PWM_GEN_MODE_UP_DOWN", "|", "PWM_GEN_MODE_NO_SYNC", "|", "PWM_GEN_MODE_DBG_STOP", ")", ";", "PWMOutputInvert", "(", "PWM0_BASE", ",", "PWM_OUT_4_BIT", "|", "PWM_OUT_5_BIT", ",", "1", ")", ";", "PWMGenEnable", "(", "PWM0_BASE", ",", "PWM_GEN_0", ")", ";", "PWMGenEnable", "(", "PWM0_BASE", ",", "PWM_GEN_1", ")", ";", "PWMGenEnable", "(", "PWM0_BASE", ",", "PWM_GEN_2", ")", ";", "GPIOPinTypePWM", "(", "GPIO_PORTB_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ")", ";", "GPIOPinTypePWM", "(", "GPIO_PORTD_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ")", ";", "GPIOPinTypePWM", "(", "GPIO_PORTE_BASE", ",", "GPIO_PIN_0", "|", "GPIO_PIN_1", ")", ";", "StepCtrlChopMode", "(", ")", ";", "PWMOutputState", "(", "PWM0_BASE", ",", "PWM_OUT_0_BIT", "|", "PWM_OUT_1_BIT", "|", "PWM_OUT_2_BIT", "|", "PWM_OUT_3_BIT", "|", "PWM_OUT_4_BIT", "|", "PWM_OUT_5_BIT", ",", "1", ")", ";", "PWMOutputFault", "(", "PWM0_BASE", ",", "PWM_OUT_0_BIT", "|", "PWM_OUT_1_BIT", "|", "PWM_OUT_2_BIT", "|", "PWM_OUT_3_BIT", "|", "PWM_OUT_4_BIT", "|", "PWM_OUT_5_BIT", ",", "1", ")", ";", "}" ]
Initializes the step control module.
[ "Initializes", "the", "step", "control", "module", "." ]
[ "//\r", "// Enable the PWM peripheral block, and the GPIO ports associated\r", "// with the PWM pins.\r", "//\r", "//\r", "// Enable the ADC peripheral, needed for winding current.\r", "//\r", "//\r", "// Set the ADC to run at the maximum rate of 500 ksamples.\r", "//\r", "//\r", "// Enable the peripherals that should continue to run when the processor\r", "// is sleeping.\r", "//\r", "//\r", "// Set up the timer used for the fixed interval timer.\r", "//\r", "//\r", "// Initialize the ADC sequencers for windings A and B.\r", "// There is one sequencer for each winding. Configure each to take\r", "// two samples and generate an interrupt.\r", "// Two samples are used for each, because the first sample taken by\r", "// the ADC after the winding is first turned on, occurs too fast\r", "// for an accurate measurement to be made. By using two samples at\r", "// each acquisition, it is guaranteed that the second sample will be\r", "// an accurate measurement of the current.\r", "//\r", "//\r", "// Enable the ADC sequencers, and enable the interrupts.\r", "//\r", "//\r", "// Initialize all of the PWM generators.\r", "//\r", "//\r", "// PWM 4 and 5 pins are connected to the gate driver enable pins,\r", "// which are active low, so set them to invert.\r", "//\r", "//\r", "// Enable all the PWM generators.\r", "//\r", "//\r", "// Configure the PWM pins to be controlled by the PWM generators.\r", "//\r", "//\r", "// Start off in chopper mode, by default\r", "//\r", "//\r", "// Configure PWM outputs to safe on fault.\r", "// Enable the PWM outputs.\r", "//\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7af7a4c032adeb546fa2416f9c9d5f933f4602a1
junyanl-code/Luminary-Micro-Library
boards/dk-lm3s9d96/enet_uip/enet_uip.c
[ "BSD-3-Clause" ]
C
ShowIPAddress
void
void ShowIPAddress(const uip_ipaddr_t sIPAddr) { char pcBuffer[24]; usprintf(pcBuffer, "IP: %d.%d.%d.%d", sIPAddr[0] & 0xff, sIPAddr[0] >> 8, sIPAddr[1] & 0xff, sIPAddr[1] >> 8); UARTprintf("%s\n", pcBuffer); GrContextFontSet(&g_sContext, g_pFontCmss18b); GrStringDrawCentered(&g_sContext, pcBuffer, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 20, true); }
//***************************************************************************** // // Display the current IP address on the screen and transmit it via the UART. // //*****************************************************************************
Display the current IP address on the screen and transmit it via the UART.
[ "Display", "the", "current", "IP", "address", "on", "the", "screen", "and", "transmit", "it", "via", "the", "UART", "." ]
void ShowIPAddress(const uip_ipaddr_t sIPAddr) { char pcBuffer[24]; usprintf(pcBuffer, "IP: %d.%d.%d.%d", sIPAddr[0] & 0xff, sIPAddr[0] >> 8, sIPAddr[1] & 0xff, sIPAddr[1] >> 8); UARTprintf("%s\n", pcBuffer); GrContextFontSet(&g_sContext, g_pFontCmss18b); GrStringDrawCentered(&g_sContext, pcBuffer, -1, GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) - 20, true); }
[ "void", "ShowIPAddress", "(", "const", "uip_ipaddr_t", "sIPAddr", ")", "{", "char", "pcBuffer", "[", "24", "]", ";", "usprintf", "(", "pcBuffer", ",", "\"", "\"", ",", "sIPAddr", "[", "0", "]", "&", "0xff", ",", "sIPAddr", "[", "0", "]", ">>", "8", ",", "sIPAddr", "[", "1", "]", "&", "0xff", ",", "sIPAddr", "[", "1", "]", ">>", "8", ")", ";", "UARTprintf", "(", "\"", "\\n", "\"", ",", "pcBuffer", ")", ";", "GrContextFontSet", "(", "&", "g_sContext", ",", "g_pFontCmss18b", ")", ";", "GrStringDrawCentered", "(", "&", "g_sContext", ",", "pcBuffer", ",", "-1", ",", "GrContextDpyWidthGet", "(", "&", "g_sContext", ")", "/", "2", ",", "GrContextDpyHeightGet", "(", "&", "g_sContext", ")", "-", "20", ",", "true", ")", ";", "}" ]
Display the current IP address on the screen and transmit it via the UART.
[ "Display", "the", "current", "IP", "address", "on", "the", "screen", "and", "transmit", "it", "via", "the", "UART", "." ]
[]
[ { "param": "sIPAddr", "type": "uip_ipaddr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sIPAddr", "type": "uip_ipaddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }