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
2543638c3dbafb66df95f4534e42c596a9749e90
joelnb/duckyPad
resources/bdf2c-master/bdf2c.c
[ "MIT" ]
C
EncodingTable
void
void EncodingTable(FILE * out, const char *name, const unsigned *encoding_table, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// character encoding for each index entry\n" "static const unsigned short __%s_index__[] = {\n", name); while (chars--) { fprintf(out, "\t%u,\n", *encoding_table++); } }
/// /// Print encoding table for c file /// /// @param out file stream for output /// @param name font variable name in C source file /// @param encoding_table encoding table read from BDF file /// @param chars number of characters in encoding table ///
Print encoding table for c file
[ "Print", "encoding", "table", "for", "c", "file" ]
void EncodingTable(FILE * out, const char *name, const unsigned *encoding_table, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// character encoding for each index entry\n" "static const unsigned short __%s_index__[] = {\n", name); while (chars--) { fprintf(out, "\t%u,\n", *encoding_table++); } }
[ "void", "EncodingTable", "(", "FILE", "*", "out", ",", "const", "char", "*", "name", ",", "const", "unsigned", "*", "encoding_table", ",", "int", "chars", ")", "{", "fprintf", "(", "out", ",", "\"", "\\n", "\\n", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", "\"", "\\n", "\"", ",", "name", ")", ";", "while", "(", "chars", "--", ")", "{", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "*", "encoding_table", "++", ")", ";", "}", "}" ]
Print encoding table for c file
[ "Print", "encoding", "table", "for", "c", "file" ]
[]
[ { "param": "out", "type": "FILE" }, { "param": "name", "type": "char" }, { "param": "encoding_table", "type": "unsigned" }, { "param": "chars", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": "file stream for output", "docstring_tokens": [ "file", "stream", "for", "output" ], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": "font variable name in C source file", "docstring_tokens": [ "font", "variable", "name", "in", "C", "source", "file" ], "default": null, "is_optional": null }, { "identifier": "encoding_table", "type": "unsigned", "docstring": "encoding table read from BDF file", "docstring_tokens": [ "encoding", "table", "read", "from", "BDF", "file" ], "default": null, "is_optional": null }, { "identifier": "chars", "type": "int", "docstring": "number of characters in encoding table", "docstring_tokens": [ "number", "of", "characters", "in", "encoding", "table" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2543638c3dbafb66df95f4534e42c596a9749e90
joelnb/duckyPad
resources/bdf2c-master/bdf2c.c
[ "MIT" ]
C
Footer
void
void Footer(FILE * out, const char *name, int width, int height, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// bitmap font structure\n" "const struct bitmap_font %s = {\n", name); fprintf(out, "\t.Width = %d, .Height = %d,\n", width, height); fprintf(out, "\t.Chars = %d,\n", chars); if(!SmartMatrix) fprintf(out, "\t.Widths = __%s_widths__,\n", name); else fprintf(out, "\t.Widths = 0,\n"); fprintf(out, "\t.Index = __%s_index__,\n", name); fprintf(out, "\t.Bitmap = __%s_bitmap__,\n", name); fprintf(out, "};\n\n"); }
/// /// Print footer for c file. /// /// @param out file stream for output /// @param name font variable name in C source file /// @param width character width of font /// @param height character height of font /// @param chars number of characters in font ///
Print footer for c file.
[ "Print", "footer", "for", "c", "file", "." ]
void Footer(FILE * out, const char *name, int width, int height, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// bitmap font structure\n" "const struct bitmap_font %s = {\n", name); fprintf(out, "\t.Width = %d, .Height = %d,\n", width, height); fprintf(out, "\t.Chars = %d,\n", chars); if(!SmartMatrix) fprintf(out, "\t.Widths = __%s_widths__,\n", name); else fprintf(out, "\t.Widths = 0,\n"); fprintf(out, "\t.Index = __%s_index__,\n", name); fprintf(out, "\t.Bitmap = __%s_bitmap__,\n", name); fprintf(out, "};\n\n"); }
[ "void", "Footer", "(", "FILE", "*", "out", ",", "const", "char", "*", "name", ",", "int", "width", ",", "int", "height", ",", "int", "chars", ")", "{", "fprintf", "(", "out", ",", "\"", "\\n", "\\n", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", "\"", "\\n", "\"", ",", "name", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "width", ",", "height", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "chars", ")", ";", "if", "(", "!", "SmartMatrix", ")", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "name", ")", ";", "else", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "name", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "name", ")", ";", "fprintf", "(", "out", ",", "\"", "\\n", "\\n", "\"", ")", ";", "}" ]
Print footer for c file.
[ "Print", "footer", "for", "c", "file", "." ]
[]
[ { "param": "out", "type": "FILE" }, { "param": "name", "type": "char" }, { "param": "width", "type": "int" }, { "param": "height", "type": "int" }, { "param": "chars", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": "file stream for output", "docstring_tokens": [ "file", "stream", "for", "output" ], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": "font variable name in C source file", "docstring_tokens": [ "font", "variable", "name", "in", "C", "source", "file" ], "default": null, "is_optional": null }, { "identifier": "width", "type": "int", "docstring": "character width of font", "docstring_tokens": [ "character", "width", "of", "font" ], "default": null, "is_optional": null }, { "identifier": "height", "type": "int", "docstring": "character height of font", "docstring_tokens": [ "character", "height", "of", "font" ], "default": null, "is_optional": null }, { "identifier": "chars", "type": "int", "docstring": "number of characters in font", "docstring_tokens": [ "number", "of", "characters", "in", "font" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2543638c3dbafb66df95f4534e42c596a9749e90
joelnb/duckyPad
resources/bdf2c-master/bdf2c.c
[ "MIT" ]
C
OutlineCharacter
void
void OutlineCharacter(unsigned char *bitmap, int width, int height) { int x; int y; unsigned char *outline; outline = alloca(((width + 7) / 8) * height); memset(outline, 0, ((width + 7) / 8) * height); for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { // Bit not set check surroundings if (~bitmap[y * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { // Upper row bit was set if (y && bitmap[(y - 1) * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); // Previous bit was set } else if (x && bitmap[y * ((width + 7) / 8) + (x - 1) / 8] & (0x80 >> (x - 1) % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); // Next bit was set } else if (x < width - 1 && bitmap[y * ((width + 7) / 8) + (x + 1) / 8] & (0x80 >> (x + 1) % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); // below row was set } else if (y < height - 1 && bitmap[(y + 1) * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); } } } } memcpy(bitmap, outline, ((width + 7) / 8) * height); }
/// /// Outline character. Create an outline font from normal fonts. /// /// @param bitmap input bitmap /// @param width character width /// @param height character height ///
Outline character. Create an outline font from normal fonts.
[ "Outline", "character", ".", "Create", "an", "outline", "font", "from", "normal", "fonts", "." ]
void OutlineCharacter(unsigned char *bitmap, int width, int height) { int x; int y; unsigned char *outline; outline = alloca(((width + 7) / 8) * height); memset(outline, 0, ((width + 7) / 8) * height); for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { if (~bitmap[y * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { if (y && bitmap[(y - 1) * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); } else if (x && bitmap[y * ((width + 7) / 8) + (x - 1) / 8] & (0x80 >> (x - 1) % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); } else if (x < width - 1 && bitmap[y * ((width + 7) / 8) + (x + 1) / 8] & (0x80 >> (x + 1) % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); } else if (y < height - 1 && bitmap[(y + 1) * ((width + 7) / 8) + x / 8] & (0x80 >> x % 8)) { outline[y * ((width + 7) / 8) + x / 8] |= (0x80 >> x % 8); } } } } memcpy(bitmap, outline, ((width + 7) / 8) * height); }
[ "void", "OutlineCharacter", "(", "unsigned", "char", "*", "bitmap", ",", "int", "width", ",", "int", "height", ")", "{", "int", "x", ";", "int", "y", ";", "unsigned", "char", "*", "outline", ";", "outline", "=", "alloca", "(", "(", "(", "width", "+", "7", ")", "/", "8", ")", "*", "height", ")", ";", "memset", "(", "outline", ",", "0", ",", "(", "(", "width", "+", "7", ")", "/", "8", ")", "*", "height", ")", ";", "for", "(", "y", "=", "0", ";", "y", "<", "height", ";", "++", "y", ")", "{", "for", "(", "x", "=", "0", ";", "x", "<", "width", ";", "++", "x", ")", "{", "if", "(", "~", "bitmap", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "&", "(", "0x80", ">>", "x", "%", "8", ")", ")", "{", "if", "(", "y", "&&", "bitmap", "[", "(", "y", "-", "1", ")", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "&", "(", "0x80", ">>", "x", "%", "8", ")", ")", "{", "outline", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "|=", "(", "0x80", ">>", "x", "%", "8", ")", ";", "}", "else", "if", "(", "x", "&&", "bitmap", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "(", "x", "-", "1", ")", "/", "8", "]", "&", "(", "0x80", ">>", "(", "x", "-", "1", ")", "%", "8", ")", ")", "{", "outline", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "|=", "(", "0x80", ">>", "x", "%", "8", ")", ";", "}", "else", "if", "(", "x", "<", "width", "-", "1", "&&", "bitmap", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "(", "x", "+", "1", ")", "/", "8", "]", "&", "(", "0x80", ">>", "(", "x", "+", "1", ")", "%", "8", ")", ")", "{", "outline", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "|=", "(", "0x80", ">>", "x", "%", "8", ")", ";", "}", "else", "if", "(", "y", "<", "height", "-", "1", "&&", "bitmap", "[", "(", "y", "+", "1", ")", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "&", "(", "0x80", ">>", "x", "%", "8", ")", ")", "{", "outline", "[", "y", "*", "(", "(", "width", "+", "7", ")", "/", "8", ")", "+", "x", "/", "8", "]", "|=", "(", "0x80", ">>", "x", "%", "8", ")", ";", "}", "}", "}", "}", "memcpy", "(", "bitmap", ",", "outline", ",", "(", "(", "width", "+", "7", ")", "/", "8", ")", "*", "height", ")", ";", "}" ]
Outline character.
[ "Outline", "character", "." ]
[ "// Bit not set check surroundings", "// Upper row bit was set", "// Previous bit was set", "// Next bit was set", "// below row was set" ]
[ { "param": "bitmap", "type": "unsigned char" }, { "param": "width", "type": "int" }, { "param": "height", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bitmap", "type": "unsigned char", "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "width", "type": "int", "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "height", "type": "int", "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a60f5259ddd79dd9023b6c24f0cfb12f44d54db4
joelnb/duckyPad
firmware/code/Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
[ "MIT" ]
C
xPortStartScheduler
BaseType_t
BaseType_t xPortStartScheduler( void ) { /* Make PendSV, CallSV and SysTick the same priroity as the kernel. */ *(portNVIC_SYSPRI2) |= portNVIC_PENDSV_PRI; *(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI; /* Start the timer that generates the tick ISR. Interrupts are disabled here already. */ vPortSetupTimerInterrupt(); /* Initialise the critical nesting count ready for the first task. */ uxCriticalNesting = 0; /* Start the first task. */ prvPortStartFirstTask(); /* Should not get here! */ return 0; }
/* * See header file for description. */
See header file for description.
[ "See", "header", "file", "for", "description", "." ]
BaseType_t xPortStartScheduler( void ) { *(portNVIC_SYSPRI2) |= portNVIC_PENDSV_PRI; *(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI; vPortSetupTimerInterrupt(); uxCriticalNesting = 0; prvPortStartFirstTask(); return 0; }
[ "BaseType_t", "xPortStartScheduler", "(", "void", ")", "{", "*", "(", "portNVIC_SYSPRI2", ")", "|=", "portNVIC_PENDSV_PRI", ";", "*", "(", "portNVIC_SYSPRI2", ")", "|=", "portNVIC_SYSTICK_PRI", ";", "vPortSetupTimerInterrupt", "(", ")", ";", "uxCriticalNesting", "=", "0", ";", "prvPortStartFirstTask", "(", ")", ";", "return", "0", ";", "}" ]
See header file for description.
[ "See", "header", "file", "for", "description", "." ]
[ "/* Make PendSV, CallSV and SysTick the same priroity as the kernel. */", "/* Start the timer that generates the tick ISR. Interrupts are disabled\n\there already. */", "/* Initialise the critical nesting count ready for the first task. */", "/* Start the first task. */", "/* Should not get here! */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
clust2sect
DWORD
DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ FATFS* fs, /* File system object */ DWORD clst /* Cluster# to be converted */ ) { clst -= 2; if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ return clst * fs->csize + fs->database; }
/*-----------------------------------------------------------------------*/ /* Get sector# from cluster# */ /*-----------------------------------------------------------------------*/ /* Hidden API for hacks and disk tools */
Get sector# from cluster Hidden API for hacks and disk tools
[ "Get", "sector#", "from", "cluster", "Hidden", "API", "for", "hacks", "and", "disk", "tools" ]
DWORD clust2sect ( FATFS* fs, DWORD clst ) { clst -= 2; if (clst >= fs->n_fatent - 2) return 0; return clst * fs->csize + fs->database; }
[ "DWORD", "clust2sect", "(", "FATFS", "*", "fs", ",", "DWORD", "clst", ")", "{", "clst", "-=", "2", ";", "if", "(", "clst", ">=", "fs", "->", "n_fatent", "-", "2", ")", "return", "0", ";", "return", "clst", "*", "fs", "->", "csize", "+", "fs", "->", "database", ";", "}" ]
Get sector# from cluster Hidden API for hacks and disk tools
[ "Get", "sector#", "from", "cluster", "Hidden", "API", "for", "hacks", "and", "disk", "tools" ]
[ "/* !=0: Sector number, 0: Failed - invalid cluster# */", "/* File system object */", "/* Cluster# to be converted */", "/* Invalid cluster# */" ]
[ { "param": "fs", "type": "FATFS" }, { "param": "clst", "type": "DWORD" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fs", "type": "FATFS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "clst", "type": "DWORD", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
dir_sdi
FRESULT
static FRESULT dir_sdi ( DIR* dp, /* Pointer to directory object */ UINT idx /* Index of directory table */ ) { DWORD clst, sect; UINT ic; dp->index = (WORD)idx; /* Current index */ clst = dp->sclust; /* Table start cluster (0:root) */ if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ return FR_INT_ERR; if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ clst = dp->fs->dirbase; if (clst == 0) { /* Static table (root-directory in FAT12/16) */ if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ return FR_INT_ERR; sect = dp->fs->dirbase; } else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ while (idx >= ic) { /* Follow cluster chain */ clst = get_fat(dp->fs, clst); /* Get next cluster */ if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ return FR_INT_ERR; idx -= ic; } sect = clust2sect(dp->fs, clst); } dp->clust = clst; /* Current cluster# */ if (!sect) return FR_INT_ERR; dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ dp->dir = dp->fs->win.d8 + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ return FR_OK; }
/*-----------------------------------------------------------------------*/ /* Directory handling - Set directory index */ /*-----------------------------------------------------------------------*/
Directory handling - Set directory index
[ "Directory", "handling", "-", "Set", "directory", "index" ]
static FRESULT dir_sdi ( DIR* dp, UINT idx ) { DWORD clst, sect; UINT ic; dp->index = (WORD)idx; clst = dp->sclust; if (clst == 1 || clst >= dp->fs->n_fatent) return FR_INT_ERR; if (!clst && dp->fs->fs_type == FS_FAT32) clst = dp->fs->dirbase; if (clst == 0) { if (idx >= dp->fs->n_rootdir) return FR_INT_ERR; sect = dp->fs->dirbase; } else { ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; while (idx >= ic) { clst = get_fat(dp->fs, clst); if (clst == 0xFFFFFFFF) return FR_DISK_ERR; if (clst < 2 || clst >= dp->fs->n_fatent) return FR_INT_ERR; idx -= ic; } sect = clust2sect(dp->fs, clst); } dp->clust = clst; if (!sect) return FR_INT_ERR; dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); dp->dir = dp->fs->win.d8 + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; return FR_OK; }
[ "static", "FRESULT", "dir_sdi", "(", "DIR", "*", "dp", ",", "UINT", "idx", ")", "{", "DWORD", "clst", ",", "sect", ";", "UINT", "ic", ";", "dp", "->", "index", "=", "(", "WORD", ")", "idx", ";", "clst", "=", "dp", "->", "sclust", ";", "if", "(", "clst", "==", "1", "||", "clst", ">=", "dp", "->", "fs", "->", "n_fatent", ")", "return", "FR_INT_ERR", ";", "if", "(", "!", "clst", "&&", "dp", "->", "fs", "->", "fs_type", "==", "FS_FAT32", ")", "clst", "=", "dp", "->", "fs", "->", "dirbase", ";", "if", "(", "clst", "==", "0", ")", "{", "if", "(", "idx", ">=", "dp", "->", "fs", "->", "n_rootdir", ")", "return", "FR_INT_ERR", ";", "sect", "=", "dp", "->", "fs", "->", "dirbase", ";", "}", "else", "{", "ic", "=", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", "*", "dp", "->", "fs", "->", "csize", ";", "while", "(", "idx", ">=", "ic", ")", "{", "clst", "=", "get_fat", "(", "dp", "->", "fs", ",", "clst", ")", ";", "if", "(", "clst", "==", "0xFFFFFFFF", ")", "return", "FR_DISK_ERR", ";", "if", "(", "clst", "<", "2", "||", "clst", ">=", "dp", "->", "fs", "->", "n_fatent", ")", "return", "FR_INT_ERR", ";", "idx", "-=", "ic", ";", "}", "sect", "=", "clust2sect", "(", "dp", "->", "fs", ",", "clst", ")", ";", "}", "dp", "->", "clust", "=", "clst", ";", "if", "(", "!", "sect", ")", "return", "FR_INT_ERR", ";", "dp", "->", "sect", "=", "sect", "+", "idx", "/", "(", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", ")", ";", "dp", "->", "dir", "=", "dp", "->", "fs", "->", "win", ".", "d8", "+", "(", "idx", "%", "(", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", ")", ")", "*", "SZ_DIRE", ";", "return", "FR_OK", ";", "}" ]
Directory handling - Set directory index
[ "Directory", "handling", "-", "Set", "directory", "index" ]
[ "/* Pointer to directory object */", "/* Index of directory table */", "/* Current index */", "/* Table start cluster (0:root) */", "/* Check start cluster range */", "/* Replace cluster# 0 with root cluster# if in FAT32 */", "/* Static table (root-directory in FAT12/16) */", "/* Is index out of range? */", "/* Dynamic table (root-directory in FAT32 or sub-directory) */", "/* Entries per cluster */", "/* Follow cluster chain */", "/* Get next cluster */", "/* Disk error */", "/* Reached to end of table or internal error */", "/* Current cluster# */", "/* Sector# of the directory entry */", "/* Ptr to the entry in the sector */" ]
[ { "param": "dp", "type": "DIR" }, { "param": "idx", "type": "UINT" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "DIR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "idx", "type": "UINT", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
dir_next
FRESULT
static FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ DIR* dp, /* Pointer to the directory object */ int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ ) { DWORD clst; UINT i; #if !_FS_READONLY UINT c; #endif i = dp->index + 1; if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ return FR_NO_FILE; if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ dp->sect++; /* Next sector */ if (!dp->clust) { /* Static table */ if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ return FR_NO_FILE; } else { /* Dynamic table */ if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ if (clst <= 1) return FR_INT_ERR; if (clst == 0xFFFFFFFF) return FR_DISK_ERR; if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ #if !_FS_READONLY if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ if (clst == 0) return FR_DENIED; /* No free cluster */ if (clst == 1) return FR_INT_ERR; if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Clean-up stretched table */ if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ mem_set(dp->fs->win.d8, 0, SS(dp->fs)); /* Clear window buffer */ dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ dp->fs->wflag = 1; if (sync_window(dp->fs)) return FR_DISK_ERR; dp->fs->winsect++; } dp->fs->winsect -= c; /* Rewind window offset */ #else if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ return FR_NO_FILE; /* Report EOT */ #endif } dp->clust = clst; /* Initialize data for new cluster */ dp->sect = clust2sect(dp->fs, clst); } } } dp->index = (WORD)i; /* Current index */ dp->dir = dp->fs->win.d8 + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ return FR_OK; }
/*-----------------------------------------------------------------------*/ /* Directory handling - Move directory table index next */ /*-----------------------------------------------------------------------*/
Directory handling - Move directory table index next
[ "Directory", "handling", "-", "Move", "directory", "table", "index", "next" ]
static FRESULT dir_next ( DIR* dp, int stretch ) { DWORD clst; UINT i; #if !_FS_READONLY UINT c; #endif i = dp->index + 1; if (!(i & 0xFFFF) || !dp->sect) return FR_NO_FILE; if (!(i % (SS(dp->fs) / SZ_DIRE))) { dp->sect++; if (!dp->clust) { if (i >= dp->fs->n_rootdir) return FR_NO_FILE; } else { if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { clst = get_fat(dp->fs, dp->clust); if (clst <= 1) return FR_INT_ERR; if (clst == 0xFFFFFFFF) return FR_DISK_ERR; if (clst >= dp->fs->n_fatent) { #if !_FS_READONLY if (!stretch) return FR_NO_FILE; clst = create_chain(dp->fs, dp->clust); if (clst == 0) return FR_DENIED; if (clst == 1) return FR_INT_ERR; if (clst == 0xFFFFFFFF) return FR_DISK_ERR; if (sync_window(dp->fs)) return FR_DISK_ERR; mem_set(dp->fs->win.d8, 0, SS(dp->fs)); dp->fs->winsect = clust2sect(dp->fs, clst); for (c = 0; c < dp->fs->csize; c++) { dp->fs->wflag = 1; if (sync_window(dp->fs)) return FR_DISK_ERR; dp->fs->winsect++; } dp->fs->winsect -= c; #else if (!stretch) return FR_NO_FILE; return FR_NO_FILE; #endif } dp->clust = clst; dp->sect = clust2sect(dp->fs, clst); } } } dp->index = (WORD)i; dp->dir = dp->fs->win.d8 + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; return FR_OK; }
[ "static", "FRESULT", "dir_next", "(", "DIR", "*", "dp", ",", "int", "stretch", ")", "{", "DWORD", "clst", ";", "UINT", "i", ";", "#if", "!", "_FS_READONLY", "\n", "UINT", "c", ";", "#endif", "i", "=", "dp", "->", "index", "+", "1", ";", "if", "(", "!", "(", "i", "&", "0xFFFF", ")", "||", "!", "dp", "->", "sect", ")", "return", "FR_NO_FILE", ";", "if", "(", "!", "(", "i", "%", "(", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", ")", ")", ")", "{", "dp", "->", "sect", "++", ";", "if", "(", "!", "dp", "->", "clust", ")", "{", "if", "(", "i", ">=", "dp", "->", "fs", "->", "n_rootdir", ")", "return", "FR_NO_FILE", ";", "}", "else", "{", "if", "(", "(", "(", "i", "/", "(", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", ")", ")", "&", "(", "dp", "->", "fs", "->", "csize", "-", "1", ")", ")", "==", "0", ")", "{", "clst", "=", "get_fat", "(", "dp", "->", "fs", ",", "dp", "->", "clust", ")", ";", "if", "(", "clst", "<=", "1", ")", "return", "FR_INT_ERR", ";", "if", "(", "clst", "==", "0xFFFFFFFF", ")", "return", "FR_DISK_ERR", ";", "if", "(", "clst", ">=", "dp", "->", "fs", "->", "n_fatent", ")", "{", "#if", "!", "_FS_READONLY", "\n", "if", "(", "!", "stretch", ")", "return", "FR_NO_FILE", ";", "clst", "=", "create_chain", "(", "dp", "->", "fs", ",", "dp", "->", "clust", ")", ";", "if", "(", "clst", "==", "0", ")", "return", "FR_DENIED", ";", "if", "(", "clst", "==", "1", ")", "return", "FR_INT_ERR", ";", "if", "(", "clst", "==", "0xFFFFFFFF", ")", "return", "FR_DISK_ERR", ";", "if", "(", "sync_window", "(", "dp", "->", "fs", ")", ")", "return", "FR_DISK_ERR", ";", "mem_set", "(", "dp", "->", "fs", "->", "win", ".", "d8", ",", "0", ",", "SS", "(", "dp", "->", "fs", ")", ")", ";", "dp", "->", "fs", "->", "winsect", "=", "clust2sect", "(", "dp", "->", "fs", ",", "clst", ")", ";", "for", "(", "c", "=", "0", ";", "c", "<", "dp", "->", "fs", "->", "csize", ";", "c", "++", ")", "{", "dp", "->", "fs", "->", "wflag", "=", "1", ";", "if", "(", "sync_window", "(", "dp", "->", "fs", ")", ")", "return", "FR_DISK_ERR", ";", "dp", "->", "fs", "->", "winsect", "++", ";", "}", "dp", "->", "fs", "->", "winsect", "-=", "c", ";", "#else", "if", "(", "!", "stretch", ")", "return", "FR_NO_FILE", ";", "return", "FR_NO_FILE", ";", "#endif", "}", "dp", "->", "clust", "=", "clst", ";", "dp", "->", "sect", "=", "clust2sect", "(", "dp", "->", "fs", ",", "clst", ")", ";", "}", "}", "}", "dp", "->", "index", "=", "(", "WORD", ")", "i", ";", "dp", "->", "dir", "=", "dp", "->", "fs", "->", "win", ".", "d8", "+", "(", "i", "%", "(", "SS", "(", "dp", "->", "fs", ")", "/", "SZ_DIRE", ")", ")", "*", "SZ_DIRE", ";", "return", "FR_OK", ";", "}" ]
Directory handling - Move directory table index next
[ "Directory", "handling", "-", "Move", "directory", "table", "index", "next" ]
[ "/* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */", "/* Pointer to the directory object */", "/* 0: Do not stretch table, 1: Stretch table if needed */", "/* Report EOT when index has reached 65535 */", "/* Sector changed? */", "/* Next sector */", "/* Static table */", "/* Report EOT if it reached end of static table */", "/* Dynamic table */", "/* Cluster changed? */", "/* Get next cluster */", "/* If it reached end of dynamic table, */", "/* If do not stretch, report EOT */", "/* Stretch cluster chain */", "/* No free cluster */", "/* Clean-up stretched table */", "/* Flush disk access window */", "/* Clear window buffer */", "/* Cluster start sector */", "/* Fill the new cluster with 0 */", "/* Rewind window offset */", "/* If do not stretch, report EOT (this is to suppress warning) */", "/* Report EOT */", "/* Initialize data for new cluster */", "/* Current index */", "/* Current entry in the window */" ]
[ { "param": "dp", "type": "DIR" }, { "param": "stretch", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "DIR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "stretch", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
ld_clust
DWORD
static DWORD ld_clust ( FATFS* fs, /* Pointer to the fs object */ BYTE* dir /* Pointer to the directory entry */ ) { DWORD cl; cl = LD_WORD(dir + DIR_FstClusLO); if (fs->fs_type == FS_FAT32) cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; return cl; }
/*-----------------------------------------------------------------------*/ /* Directory handling - Load/Store start cluster number */ /*-----------------------------------------------------------------------*/
Directory handling - Load/Store start cluster number
[ "Directory", "handling", "-", "Load", "/", "Store", "start", "cluster", "number" ]
static DWORD ld_clust ( FATFS* fs, BYTE* dir ) { DWORD cl; cl = LD_WORD(dir + DIR_FstClusLO); if (fs->fs_type == FS_FAT32) cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; return cl; }
[ "static", "DWORD", "ld_clust", "(", "FATFS", "*", "fs", ",", "BYTE", "*", "dir", ")", "{", "DWORD", "cl", ";", "cl", "=", "LD_WORD", "(", "dir", "+", "DIR_FstClusLO", ")", ";", "if", "(", "fs", "->", "fs_type", "==", "FS_FAT32", ")", "cl", "|=", "(", "DWORD", ")", "LD_WORD", "(", "dir", "+", "DIR_FstClusHI", ")", "<<", "16", ";", "return", "cl", ";", "}" ]
Directory handling - Load/Store start cluster number
[ "Directory", "handling", "-", "Load", "/", "Store", "start", "cluster", "number" ]
[ "/* Pointer to the fs object */", "/* Pointer to the directory entry */" ]
[ { "param": "fs", "type": "FATFS" }, { "param": "dir", "type": "BYTE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fs", "type": "FATFS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dir", "type": "BYTE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
cmp_lfn
int
static int cmp_lfn ( /* 1:Matched, 0:Not matched */ WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ BYTE* dir /* Pointer to the directory entry containing a part of LFN */ ) { UINT i, s; WCHAR wc, uc; i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ s = 0; wc = 1; do { uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ if (wc) { /* Last character has not been processed */ wc = ff_wtoupper(uc); /* Convert it to upper case */ if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ return 0; /* Not matched */ } else { if (uc != 0xFFFF) return 0; /* Check filler */ } } while (++s < 13); /* Repeat until all characters in the entry are checked */ if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ return 0; return 1; /* The part of LFN matched */ }
/* Offset of LFN characters in the directory entry */
Offset of LFN characters in the directory entry
[ "Offset", "of", "LFN", "characters", "in", "the", "directory", "entry" ]
static int cmp_lfn ( WCHAR* lfnbuf, BYTE* dir ) { UINT i, s; WCHAR wc, uc; i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; s = 0; wc = 1; do { uc = LD_WORD(dir + LfnOfs[s]); if (wc) { wc = ff_wtoupper(uc); if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) return 0; } else { if (uc != 0xFFFF) return 0; } } while (++s < 13); if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) return 0; return 1; }
[ "static", "int", "cmp_lfn", "(", "WCHAR", "*", "lfnbuf", ",", "BYTE", "*", "dir", ")", "{", "UINT", "i", ",", "s", ";", "WCHAR", "wc", ",", "uc", ";", "i", "=", "(", "(", "dir", "[", "LDIR_Ord", "]", "&", "~", "LLEF", ")", "-", "1", ")", "*", "13", ";", "s", "=", "0", ";", "wc", "=", "1", ";", "do", "{", "uc", "=", "LD_WORD", "(", "dir", "+", "LfnOfs", "[", "s", "]", ")", ";", "if", "(", "wc", ")", "{", "wc", "=", "ff_wtoupper", "(", "uc", ")", ";", "if", "(", "i", ">=", "_MAX_LFN", "||", "wc", "!=", "ff_wtoupper", "(", "lfnbuf", "[", "i", "++", "]", ")", ")", "return", "0", ";", "}", "else", "{", "if", "(", "uc", "!=", "0xFFFF", ")", "return", "0", ";", "}", "}", "while", "(", "++", "s", "<", "13", ")", ";", "if", "(", "(", "dir", "[", "LDIR_Ord", "]", "&", "LLEF", ")", "&&", "wc", "&&", "lfnbuf", "[", "i", "]", ")", "return", "0", ";", "return", "1", ";", "}" ]
Offset of LFN characters in the directory entry
[ "Offset", "of", "LFN", "characters", "in", "the", "directory", "entry" ]
[ "/* 1:Matched, 0:Not matched */", "/* Pointer to the LFN to be compared */", "/* Pointer to the directory entry containing a part of LFN */", "/* Get offset in the LFN buffer */", "/* Pick an LFN character from the entry */", "/* Last character has not been processed */", "/* Convert it to upper case */", "/* Compare it */", "/* Not matched */", "/* Check filler */", "/* Repeat until all characters in the entry are checked */", "/* Last segment matched but different length */", "/* The part of LFN matched */" ]
[ { "param": "lfnbuf", "type": "WCHAR" }, { "param": "dir", "type": "BYTE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lfnbuf", "type": "WCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dir", "type": "BYTE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
dir_find
FRESULT
static FRESULT dir_find ( DIR* dp /* Pointer to the directory object linked to the file name */ ) { FRESULT res; BYTE c, *dir; #if _USE_LFN BYTE a, ord, sum; #endif res = dir_sdi(dp, 0); /* Rewind directory object */ if (res != FR_OK) return res; #if _USE_LFN ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ #endif do { res = move_window(dp->fs, dp->sect); if (res != FR_OK) break; dir = dp->dir; /* Ptr to the directory entry of current index */ c = dir[DIR_Name]; if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ #if _USE_LFN /* LFN configuration */ a = dir[DIR_Attr] & AM_MASK; if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ } else { if (a == AM_LFN) { /* An LFN entry is found */ if (dp->lfn) { if (c & LLEF) { /* Is it start of LFN sequence? */ sum = dir[LDIR_Chksum]; c &= ~LLEF; ord = c; /* LFN start order */ dp->lfn_idx = dp->index; /* Start index of LFN */ } /* Check validity of the LFN entry and compare it with given name */ ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; } } else { /* An SFN entry is found */ if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ } } #else /* Non LFN configuration */ if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ break; #endif res = dir_next(dp, 0); /* Next entry */ } while (res == FR_OK); return res; }
/*-----------------------------------------------------------------------*/ /* Directory handling - Find an object in the directory */ /*-----------------------------------------------------------------------*/
Directory handling - Find an object in the directory
[ "Directory", "handling", "-", "Find", "an", "object", "in", "the", "directory" ]
static FRESULT dir_find ( DIR* dp ) { FRESULT res; BYTE c, *dir; #if _USE_LFN BYTE a, ord, sum; #endif res = dir_sdi(dp, 0); if (res != FR_OK) return res; #if _USE_LFN ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; #endif do { res = move_window(dp->fs, dp->sect); if (res != FR_OK) break; dir = dp->dir; c = dir[DIR_Name]; if (c == 0) { res = FR_NO_FILE; break; } #if _USE_LFN a = dir[DIR_Attr] & AM_MASK; if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { ord = 0xFF; dp->lfn_idx = 0xFFFF; } else { if (a == AM_LFN) { if (dp->lfn) { if (c & LLEF) { sum = dir[LDIR_Chksum]; c &= ~LLEF; ord = c; dp->lfn_idx = dp->index; } ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; } } else { if (!ord && sum == sum_sfn(dir)) break; if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; ord = 0xFF; dp->lfn_idx = 0xFFFF; } } #else if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) break; #endif res = dir_next(dp, 0); } while (res == FR_OK); return res; }
[ "static", "FRESULT", "dir_find", "(", "DIR", "*", "dp", ")", "{", "FRESULT", "res", ";", "BYTE", "c", ",", "*", "dir", ";", "#if", "_USE_LFN", "\n", "BYTE", "a", ",", "ord", ",", "sum", ";", "#endif", "res", "=", "dir_sdi", "(", "dp", ",", "0", ")", ";", "if", "(", "res", "!=", "FR_OK", ")", "return", "res", ";", "#if", "_USE_LFN", "\n", "ord", "=", "sum", "=", "0xFF", ";", "dp", "->", "lfn_idx", "=", "0xFFFF", ";", "#endif", "do", "{", "res", "=", "move_window", "(", "dp", "->", "fs", ",", "dp", "->", "sect", ")", ";", "if", "(", "res", "!=", "FR_OK", ")", "break", ";", "dir", "=", "dp", "->", "dir", ";", "c", "=", "dir", "[", "DIR_Name", "]", ";", "if", "(", "c", "==", "0", ")", "{", "res", "=", "FR_NO_FILE", ";", "break", ";", "}", "#if", "_USE_LFN", "\n", "a", "=", "dir", "[", "DIR_Attr", "]", "&", "AM_MASK", ";", "if", "(", "c", "==", "DDEM", "||", "(", "(", "a", "&", "AM_VOL", ")", "&&", "a", "!=", "AM_LFN", ")", ")", "{", "ord", "=", "0xFF", ";", "dp", "->", "lfn_idx", "=", "0xFFFF", ";", "}", "else", "{", "if", "(", "a", "==", "AM_LFN", ")", "{", "if", "(", "dp", "->", "lfn", ")", "{", "if", "(", "c", "&", "LLEF", ")", "{", "sum", "=", "dir", "[", "LDIR_Chksum", "]", ";", "c", "&=", "~", "LLEF", ";", "ord", "=", "c", ";", "dp", "->", "lfn_idx", "=", "dp", "->", "index", ";", "}", "ord", "=", "(", "c", "==", "ord", "&&", "sum", "==", "dir", "[", "LDIR_Chksum", "]", "&&", "cmp_lfn", "(", "dp", "->", "lfn", ",", "dir", ")", ")", "?", "ord", "-", "1", ":", "0xFF", ";", "}", "}", "else", "{", "if", "(", "!", "ord", "&&", "sum", "==", "sum_sfn", "(", "dir", ")", ")", "break", ";", "if", "(", "!", "(", "dp", "->", "fn", "[", "NSFLAG", "]", "&", "NS_LOSS", ")", "&&", "!", "mem_cmp", "(", "dir", ",", "dp", "->", "fn", ",", "11", ")", ")", "break", ";", "ord", "=", "0xFF", ";", "dp", "->", "lfn_idx", "=", "0xFFFF", ";", "}", "}", "#else", "if", "(", "!", "(", "dir", "[", "DIR_Attr", "]", "&", "AM_VOL", ")", "&&", "!", "mem_cmp", "(", "dir", ",", "dp", "->", "fn", ",", "11", ")", ")", "break", ";", "#endif", "res", "=", "dir_next", "(", "dp", ",", "0", ")", ";", "}", "while", "(", "res", "==", "FR_OK", ")", ";", "return", "res", ";", "}" ]
Directory handling - Find an object in the directory
[ "Directory", "handling", "-", "Find", "an", "object", "in", "the", "directory" ]
[ "/* Pointer to the directory object linked to the file name */", "/* Rewind directory object */", "/* Reset LFN sequence */", "/* Ptr to the directory entry of current index */", "/* Reached to end of table */", "/* LFN configuration */", "/* An entry without valid data */", "/* Reset LFN sequence */", "/* An LFN entry is found */", "/* Is it start of LFN sequence? */", "/* LFN start order */", "/* Start index of LFN */", "/* Check validity of the LFN entry and compare it with given name */", "/* An SFN entry is found */", "/* LFN matched? */", "/* SFN matched? */", "/* Reset LFN sequence */", "/* Non LFN configuration */", "/* Is it a valid entry? */", "/* Next entry */" ]
[ { "param": "dp", "type": "DIR" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "DIR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
check_fs
BYTE
static BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ FATFS* fs, /* File system object */ DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ ) { fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ if (move_window(fs, sect) != FR_OK) /* Load boot record */ return 3; if (LD_WORD(&fs->win.d8[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ return 2; if ((LD_DWORD(&fs->win.d8[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ return 0; if ((LD_DWORD(&fs->win.d8[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ return 0; return 1; }
/*-----------------------------------------------------------------------*/ /* Load a sector and check if it is an FAT boot sector */ /*-----------------------------------------------------------------------*/
Load a sector and check if it is an FAT boot sector
[ "Load", "a", "sector", "and", "check", "if", "it", "is", "an", "FAT", "boot", "sector" ]
static BYTE check_fs ( FATFS* fs, DWORD sect ) { fs->wflag = 0; fs->winsect = 0xFFFFFFFF; if (move_window(fs, sect) != FR_OK) return 3; if (LD_WORD(&fs->win.d8[BS_55AA]) != 0xAA55) return 2; if ((LD_DWORD(&fs->win.d8[BS_FilSysType]) & 0xFFFFFF) == 0x544146) return 0; if ((LD_DWORD(&fs->win.d8[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) return 0; return 1; }
[ "static", "BYTE", "check_fs", "(", "FATFS", "*", "fs", ",", "DWORD", "sect", ")", "{", "fs", "->", "wflag", "=", "0", ";", "fs", "->", "winsect", "=", "0xFFFFFFFF", ";", "if", "(", "move_window", "(", "fs", ",", "sect", ")", "!=", "FR_OK", ")", "return", "3", ";", "if", "(", "LD_WORD", "(", "&", "fs", "->", "win", ".", "d8", "[", "BS_55AA", "]", ")", "!=", "0xAA55", ")", "return", "2", ";", "if", "(", "(", "LD_DWORD", "(", "&", "fs", "->", "win", ".", "d8", "[", "BS_FilSysType", "]", ")", "&", "0xFFFFFF", ")", "==", "0x544146", ")", "return", "0", ";", "if", "(", "(", "LD_DWORD", "(", "&", "fs", "->", "win", ".", "d8", "[", "BS_FilSysType32", "]", ")", "&", "0xFFFFFF", ")", "==", "0x544146", ")", "return", "0", ";", "return", "1", ";", "}" ]
Load a sector and check if it is an FAT boot sector
[ "Load", "a", "sector", "and", "check", "if", "it", "is", "an", "FAT", "boot", "sector" ]
[ "/* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */", "/* File system object */", "/* Sector# (lba) to check if it is an FAT boot record or not */", "/* Invaidate window */", "/* Load boot record */", "/* Check boot record signature (always placed at offset 510 even if the sector size is >512) */", "/* Check \"FAT\" string */", "/* Check \"FAT\" string */" ]
[ { "param": "fs", "type": "FATFS" }, { "param": "sect", "type": "DWORD" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fs", "type": "FATFS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sect", "type": "DWORD", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
f_mount
FRESULT
FRESULT f_mount ( FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ const TCHAR* path, /* Logical drive number to be mounted/unmounted */ BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ ) { FATFS *cfs; int vol; FRESULT res; const TCHAR *rp = path; vol = get_ldnumber(&rp); if (vol < 0) return FR_INVALID_DRIVE; cfs = FatFs[vol]; /* Pointer to fs object */ if (cfs) { #if _FS_LOCK clear_lock(cfs); #endif #if _FS_REENTRANT /* Discard sync object of the current volume */ if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; #endif cfs->fs_type = 0; /* Clear old fs object */ } if (fs) { fs->fs_type = 0; /* Clear new fs object */ #if _FS_REENTRANT /* Create sync object for the new volume */ if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; #endif } FatFs[vol] = fs; /* Register new fs object */ if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ res = find_volume(&fs, &path, 0); /* Force mounted the volume */ LEAVE_FF(fs, res); }
/*-----------------------------------------------------------------------*/ /* Mount/Unmount a Logical Drive */ /*-----------------------------------------------------------------------*/
Mount/Unmount a Logical Drive
[ "Mount", "/", "Unmount", "a", "Logical", "Drive" ]
FRESULT f_mount ( FATFS* fs, const TCHAR* path, BYTE opt ) { FATFS *cfs; int vol; FRESULT res; const TCHAR *rp = path; vol = get_ldnumber(&rp); if (vol < 0) return FR_INVALID_DRIVE; cfs = FatFs[vol]; if (cfs) { #if _FS_LOCK clear_lock(cfs); #endif #if _FS_REENTRANT if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; #endif cfs->fs_type = 0; } if (fs) { fs->fs_type = 0; #if _FS_REENTRANT if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; #endif } FatFs[vol] = fs; if (!fs || opt != 1) return FR_OK; res = find_volume(&fs, &path, 0); LEAVE_FF(fs, res); }
[ "FRESULT", "f_mount", "(", "FATFS", "*", "fs", ",", "const", "TCHAR", "*", "path", ",", "BYTE", "opt", ")", "{", "FATFS", "*", "cfs", ";", "int", "vol", ";", "FRESULT", "res", ";", "const", "TCHAR", "*", "rp", "=", "path", ";", "vol", "=", "get_ldnumber", "(", "&", "rp", ")", ";", "if", "(", "vol", "<", "0", ")", "return", "FR_INVALID_DRIVE", ";", "cfs", "=", "FatFs", "[", "vol", "]", ";", "if", "(", "cfs", ")", "{", "#if", "_FS_LOCK", "\n", "clear_lock", "(", "cfs", ")", ";", "#endif", "#if", "_FS_REENTRANT", "\n", "if", "(", "!", "ff_del_syncobj", "(", "cfs", "->", "sobj", ")", ")", "return", "FR_INT_ERR", ";", "#endif", "cfs", "->", "fs_type", "=", "0", ";", "}", "if", "(", "fs", ")", "{", "fs", "->", "fs_type", "=", "0", ";", "#if", "_FS_REENTRANT", "\n", "if", "(", "!", "ff_cre_syncobj", "(", "(", "BYTE", ")", "vol", ",", "&", "fs", "->", "sobj", ")", ")", "return", "FR_INT_ERR", ";", "#endif", "}", "FatFs", "[", "vol", "]", "=", "fs", ";", "if", "(", "!", "fs", "||", "opt", "!=", "1", ")", "return", "FR_OK", ";", "res", "=", "find_volume", "(", "&", "fs", ",", "&", "path", ",", "0", ")", ";", "LEAVE_FF", "(", "fs", ",", "res", ")", ";", "}" ]
Mount/Unmount a Logical Drive
[ "Mount", "/", "Unmount", "a", "Logical", "Drive" ]
[ "/* Pointer to the file system object (NULL:unmount)*/", "/* Logical drive number to be mounted/unmounted */", "/* 0:Do not mount (delayed mount), 1:Mount immediately */", "/* Pointer to fs object */", "/* Discard sync object of the current volume */", "/* Clear old fs object */", "/* Clear new fs object */", "/* Create sync object for the new volume */", "/* Register new fs object */", "/* Do not mount now, it will be mounted later */", "/* Force mounted the volume */" ]
[ { "param": "fs", "type": "FATFS" }, { "param": "path", "type": "TCHAR" }, { "param": "opt", "type": "BYTE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fs", "type": "FATFS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": "TCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opt", "type": "BYTE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
f_fdisk
FRESULT
FRESULT f_fdisk ( BYTE pdrv, /* Physical drive number */ const DWORD szt[], /* Pointer to the size table for each partitions */ void* work /* Pointer to the working buffer */ ) { UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; DSTATUS stat; DWORD sz_disk, sz_part, s_part; stat = disk_initialize(pdrv); if (stat & STA_NOINIT) return FR_NOT_READY; if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; /* Determine CHS in the table regardless of the drive geometry */ for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; if (n == 256) n--; e_hd = n - 1; sz_cyl = 63 * n; tot_cyl = sz_disk / sz_cyl; /* Create partition table */ mem_set(buf, 0, _MAX_SS); p = buf + MBR_Table; b_cyl = 0; for (i = 0; i < 4; i++, p += SZ_PTE) { p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; if (!p_cyl) continue; s_part = (DWORD)sz_cyl * b_cyl; sz_part = (DWORD)sz_cyl * p_cyl; if (i == 0) { /* Exclude first track of cylinder 0 */ s_hd = 1; s_part += 63; sz_part -= 63; } else { s_hd = 0; } e_cyl = b_cyl + p_cyl - 1; if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; /* Set partition table */ p[1] = s_hd; /* Start head */ p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ p[3] = (BYTE)b_cyl; /* Start cylinder */ p[4] = 0x06; /* System type (temporary setting) */ p[5] = e_hd; /* End head */ p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ p[7] = (BYTE)e_cyl; /* End cylinder */ ST_DWORD(p + 8, s_part); /* Start sector in LBA */ ST_DWORD(p + 12, sz_part); /* Partition size */ /* Next partition */ b_cyl += p_cyl; } ST_WORD(p, 0xAA55); /* Write it to the MBR */ return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; }
/*-----------------------------------------------------------------------*/ /* Create partition table on the physical drive */ /*-----------------------------------------------------------------------*/
Create partition table on the physical drive
[ "Create", "partition", "table", "on", "the", "physical", "drive" ]
FRESULT f_fdisk ( BYTE pdrv, const DWORD szt[], void* work ) { UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; DSTATUS stat; DWORD sz_disk, sz_part, s_part; stat = disk_initialize(pdrv); if (stat & STA_NOINIT) return FR_NOT_READY; if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; if (n == 256) n--; e_hd = n - 1; sz_cyl = 63 * n; tot_cyl = sz_disk / sz_cyl; mem_set(buf, 0, _MAX_SS); p = buf + MBR_Table; b_cyl = 0; for (i = 0; i < 4; i++, p += SZ_PTE) { p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; if (!p_cyl) continue; s_part = (DWORD)sz_cyl * b_cyl; sz_part = (DWORD)sz_cyl * p_cyl; if (i == 0) { s_hd = 1; s_part += 63; sz_part -= 63; } else { s_hd = 0; } e_cyl = b_cyl + p_cyl - 1; if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; p[1] = s_hd; p[2] = (BYTE)((b_cyl >> 2) + 1); p[3] = (BYTE)b_cyl; p[4] = 0x06; p[5] = e_hd; p[6] = (BYTE)((e_cyl >> 2) + 63); p[7] = (BYTE)e_cyl; ST_DWORD(p + 8, s_part); ST_DWORD(p + 12, sz_part); b_cyl += p_cyl; } ST_WORD(p, 0xAA55); return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; }
[ "FRESULT", "f_fdisk", "(", "BYTE", "pdrv", ",", "const", "DWORD", "szt", "[", "]", ",", "void", "*", "work", ")", "{", "UINT", "i", ",", "n", ",", "sz_cyl", ",", "tot_cyl", ",", "b_cyl", ",", "e_cyl", ",", "p_cyl", ";", "BYTE", "s_hd", ",", "e_hd", ",", "*", "p", ",", "*", "buf", "=", "(", "BYTE", "*", ")", "work", ";", "DSTATUS", "stat", ";", "DWORD", "sz_disk", ",", "sz_part", ",", "s_part", ";", "stat", "=", "disk_initialize", "(", "pdrv", ")", ";", "if", "(", "stat", "&", "STA_NOINIT", ")", "return", "FR_NOT_READY", ";", "if", "(", "stat", "&", "STA_PROTECT", ")", "return", "FR_WRITE_PROTECTED", ";", "if", "(", "disk_ioctl", "(", "pdrv", ",", "GET_SECTOR_COUNT", ",", "&", "sz_disk", ")", ")", "return", "FR_DISK_ERR", ";", "for", "(", "n", "=", "16", ";", "n", "<", "256", "&&", "sz_disk", "/", "n", "/", "63", ">", "1024", ";", "n", "*=", "2", ")", ";", "if", "(", "n", "==", "256", ")", "n", "--", ";", "e_hd", "=", "n", "-", "1", ";", "sz_cyl", "=", "63", "*", "n", ";", "tot_cyl", "=", "sz_disk", "/", "sz_cyl", ";", "mem_set", "(", "buf", ",", "0", ",", "_MAX_SS", ")", ";", "p", "=", "buf", "+", "MBR_Table", ";", "b_cyl", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ",", "p", "+=", "SZ_PTE", ")", "{", "p_cyl", "=", "(", "szt", "[", "i", "]", "<=", "100U", ")", "?", "(", "DWORD", ")", "tot_cyl", "*", "szt", "[", "i", "]", "/", "100", ":", "szt", "[", "i", "]", "/", "sz_cyl", ";", "if", "(", "!", "p_cyl", ")", "continue", ";", "s_part", "=", "(", "DWORD", ")", "sz_cyl", "*", "b_cyl", ";", "sz_part", "=", "(", "DWORD", ")", "sz_cyl", "*", "p_cyl", ";", "if", "(", "i", "==", "0", ")", "{", "s_hd", "=", "1", ";", "s_part", "+=", "63", ";", "sz_part", "-=", "63", ";", "}", "else", "{", "s_hd", "=", "0", ";", "}", "e_cyl", "=", "b_cyl", "+", "p_cyl", "-", "1", ";", "if", "(", "e_cyl", ">=", "tot_cyl", ")", "return", "FR_INVALID_PARAMETER", ";", "p", "[", "1", "]", "=", "s_hd", ";", "p", "[", "2", "]", "=", "(", "BYTE", ")", "(", "(", "b_cyl", ">>", "2", ")", "+", "1", ")", ";", "p", "[", "3", "]", "=", "(", "BYTE", ")", "b_cyl", ";", "p", "[", "4", "]", "=", "0x06", ";", "p", "[", "5", "]", "=", "e_hd", ";", "p", "[", "6", "]", "=", "(", "BYTE", ")", "(", "(", "e_cyl", ">>", "2", ")", "+", "63", ")", ";", "p", "[", "7", "]", "=", "(", "BYTE", ")", "e_cyl", ";", "ST_DWORD", "(", "p", "+", "8", ",", "s_part", ")", ";", "ST_DWORD", "(", "p", "+", "12", ",", "sz_part", ")", ";", "b_cyl", "+=", "p_cyl", ";", "}", "ST_WORD", "(", "p", ",", "0xAA55", ")", ";", "return", "(", "disk_write", "(", "pdrv", ",", "buf", ",", "0", ",", "1", ")", "!=", "RES_OK", "||", "disk_ioctl", "(", "pdrv", ",", "CTRL_SYNC", ",", "0", ")", "!=", "RES_OK", ")", "?", "FR_DISK_ERR", ":", "FR_OK", ";", "}" ]
Create partition table on the physical drive
[ "Create", "partition", "table", "on", "the", "physical", "drive" ]
[ "/* Physical drive number */", "/* Pointer to the size table for each partitions */", "/* Pointer to the working buffer */", "/* Determine CHS in the table regardless of the drive geometry */", "/* Create partition table */", "/* Exclude first track of cylinder 0 */", "/* Set partition table */", "/* Start head */", "/* Start sector */", "/* Start cylinder */", "/* System type (temporary setting) */", "/* End head */", "/* End sector */", "/* End cylinder */", "/* Start sector in LBA */", "/* Partition size */", "/* Next partition */", "/* Write it to the MBR */" ]
[ { "param": "pdrv", "type": "BYTE" }, { "param": "szt", "type": "DWORD" }, { "param": "work", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pdrv", "type": "BYTE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "szt", "type": "DWORD", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "work", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
f_gets
TCHAR
TCHAR* f_gets ( TCHAR* buff, /* Pointer to the string buffer to read */ int len, /* Size of string buffer (characters) */ FIL* fp /* Pointer to the file object */ ) { int n = 0; TCHAR c, *p = buff; BYTE s[2]; UINT rc; while (n < len - 1) { /* Read characters until buffer gets filled */ #if _USE_LFN && _LFN_UNICODE #if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; if (c >= 0x80) { if (c < 0xC0) continue; /* Skip stray trailer */ if (c < 0xE0) { /* Two-byte sequence */ f_read(fp, s, 1, &rc); if (rc != 1) break; c = (c & 0x1F) << 6 | (s[0] & 0x3F); if (c < 0x80) c = '?'; } else { if (c < 0xF0) { /* Three-byte sequence */ f_read(fp, s, 2, &rc); if (rc != 2) break; c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); if (c < 0x800) c = '?'; } else { /* Reject four-byte sequence */ c = '?'; } } } #elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ f_read(fp, s, 2, &rc); if (rc != 2) break; c = s[1] + (s[0] << 8); #elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ f_read(fp, s, 2, &rc); if (rc != 2) break; c = s[0] + (s[1] << 8); #else /* Read a character in ANSI/OEM */ f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; if (IsDBCS1(c)) { f_read(fp, s, 1, &rc); if (rc != 1) break; c = (c << 8) + s[0]; } c = ff_convert(c, 1); /* OEM -> Unicode */ if (!c) c = '?'; #endif #else /* Read a character without conversion */ f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; #endif if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ *p++ = c; n++; if (c == '\n') break; /* Break on EOL */ } *p = 0; return n ? buff : 0; /* When no data read (eof or error), return with error. */ }
/*-----------------------------------------------------------------------*/ /* Get a string from the file */ /*-----------------------------------------------------------------------*/
Get a string from the file
[ "Get", "a", "string", "from", "the", "file" ]
TCHAR* f_gets ( TCHAR* buff, int len, FIL* fp ) { int n = 0; TCHAR c, *p = buff; BYTE s[2]; UINT rc; while (n < len - 1) { #if _USE_LFN && _LFN_UNICODE #if _STRF_ENCODE == 3 f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; if (c >= 0x80) { if (c < 0xC0) continue; if (c < 0xE0) { f_read(fp, s, 1, &rc); if (rc != 1) break; c = (c & 0x1F) << 6 | (s[0] & 0x3F); if (c < 0x80) c = '?'; } else { if (c < 0xF0) { f_read(fp, s, 2, &rc); if (rc != 2) break; c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); if (c < 0x800) c = '?'; } else { c = '?'; } } } #elif _STRF_ENCODE == 2 f_read(fp, s, 2, &rc); if (rc != 2) break; c = s[1] + (s[0] << 8); #elif _STRF_ENCODE == 1 f_read(fp, s, 2, &rc); if (rc != 2) break; c = s[0] + (s[1] << 8); #else f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; if (IsDBCS1(c)) { f_read(fp, s, 1, &rc); if (rc != 1) break; c = (c << 8) + s[0]; } c = ff_convert(c, 1); if (!c) c = '?'; #endif #else f_read(fp, s, 1, &rc); if (rc != 1) break; c = s[0]; #endif if (_USE_STRFUNC == 2 && c == '\r') continue; *p++ = c; n++; if (c == '\n') break; } *p = 0; return n ? buff : 0; }
[ "TCHAR", "*", "f_gets", "(", "TCHAR", "*", "buff", ",", "int", "len", ",", "FIL", "*", "fp", ")", "{", "int", "n", "=", "0", ";", "TCHAR", "c", ",", "*", "p", "=", "buff", ";", "BYTE", "s", "[", "2", "]", ";", "UINT", "rc", ";", "while", "(", "n", "<", "len", "-", "1", ")", "{", "#if", "_USE_LFN", "&&", "_LFN_UNICODE", "\n", "#if", "_STRF_ENCODE", "==", "3", "\n", "f_read", "(", "fp", ",", "s", ",", "1", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "1", ")", "break", ";", "c", "=", "s", "[", "0", "]", ";", "if", "(", "c", ">=", "0x80", ")", "{", "if", "(", "c", "<", "0xC0", ")", "continue", ";", "if", "(", "c", "<", "0xE0", ")", "{", "f_read", "(", "fp", ",", "s", ",", "1", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "1", ")", "break", ";", "c", "=", "(", "c", "&", "0x1F", ")", "<<", "6", "|", "(", "s", "[", "0", "]", "&", "0x3F", ")", ";", "if", "(", "c", "<", "0x80", ")", "c", "=", "'", "'", ";", "}", "else", "{", "if", "(", "c", "<", "0xF0", ")", "{", "f_read", "(", "fp", ",", "s", ",", "2", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "2", ")", "break", ";", "c", "=", "c", "<<", "12", "|", "(", "s", "[", "0", "]", "&", "0x3F", ")", "<<", "6", "|", "(", "s", "[", "1", "]", "&", "0x3F", ")", ";", "if", "(", "c", "<", "0x800", ")", "c", "=", "'", "'", ";", "}", "else", "{", "c", "=", "'", "'", ";", "}", "}", "}", "#elif", "_STRF_ENCODE", "==", "2", "\n", "f_read", "(", "fp", ",", "s", ",", "2", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "2", ")", "break", ";", "c", "=", "s", "[", "1", "]", "+", "(", "s", "[", "0", "]", "<<", "8", ")", ";", "#elif", "_STRF_ENCODE", "==", "1", "\n", "f_read", "(", "fp", ",", "s", ",", "2", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "2", ")", "break", ";", "c", "=", "s", "[", "0", "]", "+", "(", "s", "[", "1", "]", "<<", "8", ")", ";", "#else", "f_read", "(", "fp", ",", "s", ",", "1", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "1", ")", "break", ";", "c", "=", "s", "[", "0", "]", ";", "if", "(", "IsDBCS1", "(", "c", ")", ")", "{", "f_read", "(", "fp", ",", "s", ",", "1", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "1", ")", "break", ";", "c", "=", "(", "c", "<<", "8", ")", "+", "s", "[", "0", "]", ";", "}", "c", "=", "ff_convert", "(", "c", ",", "1", ")", ";", "if", "(", "!", "c", ")", "c", "=", "'", "'", ";", "#endif", "#else", "f_read", "(", "fp", ",", "s", ",", "1", ",", "&", "rc", ")", ";", "if", "(", "rc", "!=", "1", ")", "break", ";", "c", "=", "s", "[", "0", "]", ";", "#endif", "if", "(", "_USE_STRFUNC", "==", "2", "&&", "c", "==", "'", "\\r", "'", ")", "continue", ";", "*", "p", "++", "=", "c", ";", "n", "++", ";", "if", "(", "c", "==", "'", "\\n", "'", ")", "break", ";", "}", "*", "p", "=", "0", ";", "return", "n", "?", "buff", ":", "0", ";", "}" ]
Get a string from the file
[ "Get", "a", "string", "from", "the", "file" ]
[ "/* Pointer to the string buffer to read */", "/* Size of string buffer (characters) */", "/* Pointer to the file object */", "/* Read characters until buffer gets filled */", "/* Read a character in UTF-8 */", "/* Skip stray trailer */", "/* Two-byte sequence */", "/* Three-byte sequence */", "/* Reject four-byte sequence */", "/* Read a character in UTF-16BE */", "/* Read a character in UTF-16LE */", "/* Read a character in ANSI/OEM */", "/* OEM -> Unicode */", "/* Read a character without conversion */", "/* Strip '\\r' */", "/* Break on EOL */", "/* When no data read (eof or error), return with error. */" ]
[ { "param": "buff", "type": "TCHAR" }, { "param": "len", "type": "int" }, { "param": "fp", "type": "FIL" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buff", "type": "TCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fp", "type": "FIL", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf7219de777525c790c704a89bc772635a67f493
joelnb/duckyPad
resources/old_v1/firmware/Middlewares/Third_Party/FatFs/ff.c
[ "MIT" ]
C
f_puts
int
int f_puts ( const TCHAR* str, /* Pointer to the string to be output */ FIL* fp /* Pointer to the file object */ ) { putbuff pb; UINT nw; pb.fp = fp; /* Initialize output buffer */ pb.nchr = pb.idx = 0; while (*str) /* Put the string */ putc_bfd(&pb, *str++); if ( pb.idx >= 0 /* Flush buffered characters to the file */ && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK && (UINT)pb.idx == nw) return pb.nchr; return EOF; }
/*-----------------------------------------------------------------------*/ /* Put a string to the file */ /*-----------------------------------------------------------------------*/
Put a string to the file
[ "Put", "a", "string", "to", "the", "file" ]
int f_puts ( const TCHAR* str, FIL* fp ) { putbuff pb; UINT nw; pb.fp = fp; pb.nchr = pb.idx = 0; while (*str) putc_bfd(&pb, *str++); if ( pb.idx >= 0 && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK && (UINT)pb.idx == nw) return pb.nchr; return EOF; }
[ "int", "f_puts", "(", "const", "TCHAR", "*", "str", ",", "FIL", "*", "fp", ")", "{", "putbuff", "pb", ";", "UINT", "nw", ";", "pb", ".", "fp", "=", "fp", ";", "pb", ".", "nchr", "=", "pb", ".", "idx", "=", "0", ";", "while", "(", "*", "str", ")", "putc_bfd", "(", "&", "pb", ",", "*", "str", "++", ")", ";", "if", "(", "pb", ".", "idx", ">=", "0", "&&", "f_write", "(", "pb", ".", "fp", ",", "pb", ".", "buf", ",", "(", "UINT", ")", "pb", ".", "idx", ",", "&", "nw", ")", "==", "FR_OK", "&&", "(", "UINT", ")", "pb", ".", "idx", "==", "nw", ")", "return", "pb", ".", "nchr", ";", "return", "EOF", ";", "}" ]
Put a string to the file
[ "Put", "a", "string", "to", "the", "file" ]
[ "/* Pointer to the string to be output */", "/* Pointer to the file object */", "/* Initialize output buffer */", "/* Put the string */", "/* Flush buffered characters to the file */" ]
[ { "param": "str", "type": "TCHAR" }, { "param": "fp", "type": "FIL" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "TCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fp", "type": "FIL", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e8d4efbede71b06b63b44cd040de60191cf7c0c
z80oolong/libandroid-pty
libandroid-pty.c
[ "BSD-2-Clause" ]
C
create_thread_local_string
thread_local_string
static thread_local_string *create_thread_local_string(size_t size) { thread_local_string *result = NULL; pthread_key_t key = 0; int error = 1; result = (thread_local_string *)calloc(1, sizeof(thread_local_string)); if(result == NULL) { return NULL; } error = pthread_key_create(&key, free); if(error != 0) { return NULL; } result->size = size; result->key = key; return result; }
// Function about operation of struct thread_local_string.
Function about operation of struct thread_local_string.
[ "Function", "about", "operation", "of", "struct", "thread_local_string", "." ]
static thread_local_string *create_thread_local_string(size_t size) { thread_local_string *result = NULL; pthread_key_t key = 0; int error = 1; result = (thread_local_string *)calloc(1, sizeof(thread_local_string)); if(result == NULL) { return NULL; } error = pthread_key_create(&key, free); if(error != 0) { return NULL; } result->size = size; result->key = key; return result; }
[ "static", "thread_local_string", "*", "create_thread_local_string", "(", "size_t", "size", ")", "{", "thread_local_string", "*", "result", "=", "NULL", ";", "pthread_key_t", "key", "=", "0", ";", "int", "error", "=", "1", ";", "result", "=", "(", "thread_local_string", "*", ")", "calloc", "(", "1", ",", "sizeof", "(", "thread_local_string", ")", ")", ";", "if", "(", "result", "==", "NULL", ")", "{", "return", "NULL", ";", "}", "error", "=", "pthread_key_create", "(", "&", "key", ",", "free", ")", ";", "if", "(", "error", "!=", "0", ")", "{", "return", "NULL", ";", "}", "result", "->", "size", "=", "size", ";", "result", "->", "key", "=", "key", ";", "return", "result", ";", "}" ]
Function about operation of struct thread_local_string.
[ "Function", "about", "operation", "of", "struct", "thread_local_string", "." ]
[]
[ { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5b3d5c707dc41fffb85ba17fead223dd593455dc
koppi/xv6-freebsd
kern/sysproc.c
[ "BSD-4-Clause-UC" ]
C
sys_uptime
int
int sys_uptime(void) { uint xticks; xticks = ticks; // atomic read return xticks; }
// return how many clock tick interrupts have occurred // since start.
return how many clock tick interrupts have occurred since start.
[ "return", "how", "many", "clock", "tick", "interrupts", "have", "occurred", "since", "start", "." ]
int sys_uptime(void) { uint xticks; xticks = ticks; return xticks; }
[ "int", "sys_uptime", "(", "void", ")", "{", "uint", "xticks", ";", "xticks", "=", "ticks", ";", "return", "xticks", ";", "}" ]
return how many clock tick interrupts have occurred since start.
[ "return", "how", "many", "clock", "tick", "interrupts", "have", "occurred", "since", "start", "." ]
[ "// atomic read" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8acc59f6fe86984262c3d430bfdeded732b0e2eb
koppi/xv6-freebsd
kern/sysfile.c
[ "BSD-4-Clause-UC" ]
C
sys_link
int
int sys_link(void) { char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) return EINVAL; begin_op(); if((ip = namei(old)) == 0){ end_op(); return -1; } ip->iops->ilock(ip); if(ip->type == T_DIR){ iunlockput(ip); end_op(); return ENOENT; } ip->nlink++; ip->iops->iupdate(ip); ip->iops->iunlock(ip); if((dp = nameiparent(new, name)) == 0) goto bad; dp->iops->ilock(dp); if(dp->dev != ip->dev || ip->iops->dirlink(dp, name, ip->inum, ip->type) < 0){ iunlockput(dp); goto bad; } iunlockput(dp); iput(ip); end_op(); return 0; bad: ip->iops->ilock(ip); ip->nlink--; ip->iops->iupdate(ip); iunlockput(ip); end_op(); return EEXIST; }
// Create the path new as a link to the same inode as old.
Create the path new as a link to the same inode as old.
[ "Create", "the", "path", "new", "as", "a", "link", "to", "the", "same", "inode", "as", "old", "." ]
int sys_link(void) { char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) return EINVAL; begin_op(); if((ip = namei(old)) == 0){ end_op(); return -1; } ip->iops->ilock(ip); if(ip->type == T_DIR){ iunlockput(ip); end_op(); return ENOENT; } ip->nlink++; ip->iops->iupdate(ip); ip->iops->iunlock(ip); if((dp = nameiparent(new, name)) == 0) goto bad; dp->iops->ilock(dp); if(dp->dev != ip->dev || ip->iops->dirlink(dp, name, ip->inum, ip->type) < 0){ iunlockput(dp); goto bad; } iunlockput(dp); iput(ip); end_op(); return 0; bad: ip->iops->ilock(ip); ip->nlink--; ip->iops->iupdate(ip); iunlockput(ip); end_op(); return EEXIST; }
[ "int", "sys_link", "(", "void", ")", "{", "char", "name", "[", "DIRSIZ", "]", ",", "*", "new", ",", "*", "old", ";", "struct", "inode", "*", "dp", ",", "*", "ip", ";", "if", "(", "argstr", "(", "0", ",", "&", "old", ")", "<", "0", "||", "argstr", "(", "1", ",", "&", "new", ")", "<", "0", ")", "return", "EINVAL", ";", "begin_op", "(", ")", ";", "if", "(", "(", "ip", "=", "namei", "(", "old", ")", ")", "==", "0", ")", "{", "end_op", "(", ")", ";", "return", "-1", ";", "}", "ip", "->", "iops", "->", "ilock", "(", "ip", ")", ";", "if", "(", "ip", "->", "type", "==", "T_DIR", ")", "{", "iunlockput", "(", "ip", ")", ";", "end_op", "(", ")", ";", "return", "ENOENT", ";", "}", "ip", "->", "nlink", "++", ";", "ip", "->", "iops", "->", "iupdate", "(", "ip", ")", ";", "ip", "->", "iops", "->", "iunlock", "(", "ip", ")", ";", "if", "(", "(", "dp", "=", "nameiparent", "(", "new", ",", "name", ")", ")", "==", "0", ")", "goto", "bad", ";", "dp", "->", "iops", "->", "ilock", "(", "dp", ")", ";", "if", "(", "dp", "->", "dev", "!=", "ip", "->", "dev", "||", "ip", "->", "iops", "->", "dirlink", "(", "dp", ",", "name", ",", "ip", "->", "inum", ",", "ip", "->", "type", ")", "<", "0", ")", "{", "iunlockput", "(", "dp", ")", ";", "goto", "bad", ";", "}", "iunlockput", "(", "dp", ")", ";", "iput", "(", "ip", ")", ";", "end_op", "(", ")", ";", "return", "0", ";", "bad", ":", "ip", "->", "iops", "->", "ilock", "(", "ip", ")", ";", "ip", "->", "nlink", "--", ";", "ip", "->", "iops", "->", "iupdate", "(", "ip", ")", ";", "iunlockput", "(", "ip", ")", ";", "end_op", "(", ")", ";", "return", "EEXIST", ";", "}" ]
Create the path new as a link to the same inode as old.
[ "Create", "the", "path", "new", "as", "a", "link", "to", "the", "same", "inode", "as", "old", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_npw2
uint32_t
static inline uint32_t lfs_npw2(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM)) return 32 - __builtin_clz(a-1); #else uint32_t r = 0; uint32_t s; a -= 1; s = (a > 0xffff) << 4; a >>= s; r |= s; s = (a > 0xff) << 3; a >>= s; r |= s; s = (a > 0xf) << 2; a >>= s; r |= s; s = (a > 0x3) << 1; a >>= s; r |= s; return (r | (a >> 1)) + 1; #endif }
/* Find the smallest power of 2 greater than or equal to a */
Find the smallest power of 2 greater than or equal to a
[ "Find", "the", "smallest", "power", "of", "2", "greater", "than", "or", "equal", "to", "a" ]
static inline uint32_t lfs_npw2(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM)) return 32 - __builtin_clz(a-1); #else uint32_t r = 0; uint32_t s; a -= 1; s = (a > 0xffff) << 4; a >>= s; r |= s; s = (a > 0xff) << 3; a >>= s; r |= s; s = (a > 0xf) << 2; a >>= s; r |= s; s = (a > 0x3) << 1; a >>= s; r |= s; return (r | (a >> 1)) + 1; #endif }
[ "static", "inline", "uint32_t", "lfs_npw2", "(", "uint32_t", "a", ")", "{", "#if", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "defined", "(", "__GNUC__", ")", "||", "defined", "(", "__CC_ARM", ")", ")", "\n", "return", "32", "-", "__builtin_clz", "(", "a", "-", "1", ")", ";", "#else", "uint32_t", "r", "=", "0", ";", "uint32_t", "s", ";", "a", "-=", "1", ";", "s", "=", "(", "a", ">", "0xffff", ")", "<<", "4", ";", "a", ">>=", "s", ";", "r", "|=", "s", ";", "s", "=", "(", "a", ">", "0xff", ")", "<<", "3", ";", "a", ">>=", "s", ";", "r", "|=", "s", ";", "s", "=", "(", "a", ">", "0xf", ")", "<<", "2", ";", "a", ">>=", "s", ";", "r", "|=", "s", ";", "s", "=", "(", "a", ">", "0x3", ")", "<<", "1", ";", "a", ">>=", "s", ";", "r", "|=", "s", ";", "return", "(", "r", "|", "(", "a", ">>", "1", ")", ")", "+", "1", ";", "#endif", "}" ]
Find the smallest power of 2 greater than or equal to a
[ "Find", "the", "smallest", "power", "of", "2", "greater", "than", "or", "equal", "to", "a" ]
[]
[ { "param": "a", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_ctz
uint32_t
static inline uint32_t lfs_ctz(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && defined(__GNUC__) return __builtin_ctz(a); #else return lfs_npw2((a & -a) + 1) - 1; #endif }
/* Count the number of trailing binary zeros in a */ /* lfs_ctz(0) may be undefined */
Count the number of trailing binary zeros in a lfs_ctz(0) may be undefined
[ "Count", "the", "number", "of", "trailing", "binary", "zeros", "in", "a", "lfs_ctz", "(", "0", ")", "may", "be", "undefined" ]
static inline uint32_t lfs_ctz(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && defined(__GNUC__) return __builtin_ctz(a); #else return lfs_npw2((a & -a) + 1) - 1; #endif }
[ "static", "inline", "uint32_t", "lfs_ctz", "(", "uint32_t", "a", ")", "{", "#if", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "defined", "(", "__GNUC__", ")", "\n", "return", "__builtin_ctz", "(", "a", ")", ";", "#else", "return", "lfs_npw2", "(", "(", "a", "&", "-", "a", ")", "+", "1", ")", "-", "1", ";", "#endif", "}" ]
Count the number of trailing binary zeros in a lfs_ctz(0) may be undefined
[ "Count", "the", "number", "of", "trailing", "binary", "zeros", "in", "a", "lfs_ctz", "(", "0", ")", "may", "be", "undefined" ]
[]
[ { "param": "a", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_popc
uint32_t
static inline uint32_t lfs_popc(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM)) return __builtin_popcount(a); #else a = a - ((a >> 1) & 0x55555555); a = (a & 0x33333333) + ((a >> 2) & 0x33333333); return (((a + (a >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; #endif }
/* Count the number of binary ones in a */
Count the number of binary ones in a
[ "Count", "the", "number", "of", "binary", "ones", "in", "a" ]
static inline uint32_t lfs_popc(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM)) return __builtin_popcount(a); #else a = a - ((a >> 1) & 0x55555555); a = (a & 0x33333333) + ((a >> 2) & 0x33333333); return (((a + (a >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; #endif }
[ "static", "inline", "uint32_t", "lfs_popc", "(", "uint32_t", "a", ")", "{", "#if", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "defined", "(", "__GNUC__", ")", "||", "defined", "(", "__CC_ARM", ")", ")", "\n", "return", "__builtin_popcount", "(", "a", ")", ";", "#else", "a", "=", "a", "-", "(", "(", "a", ">>", "1", ")", "&", "0x55555555", ")", ";", "a", "=", "(", "a", "&", "0x33333333", ")", "+", "(", "(", "a", ">>", "2", ")", "&", "0x33333333", ")", ";", "return", "(", "(", "(", "a", "+", "(", "a", ">>", "4", ")", ")", "&", "0xf0f0f0f", ")", "*", "0x1010101", ")", ">>", "24", ";", "#endif", "}" ]
Count the number of binary ones in a
[ "Count", "the", "number", "of", "binary", "ones", "in", "a" ]
[]
[ { "param": "a", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_fromle32
uint32_t
static inline uint32_t lfs_fromle32(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \ BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \ __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) return a; #elif !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \ BYTE_ORDER == ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \ __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) return __builtin_bswap32(a); #else return (((uint8_t *)&a)[0] << 0) | (((uint8_t *)&a)[1] << 8) | (((uint8_t *)&a)[2] << 16) | (((uint8_t *)&a)[3] << 24); #endif }
/* Convert between 32-bit little-endian and native order */
Convert between 32-bit little-endian and native order
[ "Convert", "between", "32", "-", "bit", "little", "-", "endian", "and", "native", "order" ]
static inline uint32_t lfs_fromle32(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \ BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \ __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) return a; #elif !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \ BYTE_ORDER == ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \ __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) return __builtin_bswap32(a); #else return (((uint8_t *)&a)[0] << 0) | (((uint8_t *)&a)[1] << 8) | (((uint8_t *)&a)[2] << 16) | (((uint8_t *)&a)[3] << 24); #endif }
[ "static", "inline", "uint32_t", "lfs_fromle32", "(", "uint32_t", "a", ")", "{", "#if", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "(", "defined", "(", "BYTE_ORDER", ")", "&&", "defined", "(", "ORDER_LITTLE_ENDIAN", ")", "&&", "BYTE_ORDER", "==", "ORDER_LITTLE_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER", ")", "&&", "defined", "(", "__ORDER_LITTLE_ENDIAN", ")", "&&", "__BYTE_ORDER", "==", "__ORDER_LITTLE_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER__", ")", "&&", "defined", "(", "__ORDER_LITTLE_ENDIAN__", ")", "&&", "__BYTE_ORDER__", "==", "__ORDER_LITTLE_ENDIAN__", ")", ")", "\n", "return", "a", ";", "#elif", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "(", "defined", "(", "BYTE_ORDER", ")", "&&", "defined", "(", "ORDER_BIG_ENDIAN", ")", "&&", "BYTE_ORDER", "==", "ORDER_BIG_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER", ")", "&&", "defined", "(", "__ORDER_BIG_ENDIAN", ")", "&&", "__BYTE_ORDER", "==", "__ORDER_BIG_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER__", ")", "&&", "defined", "(", "__ORDER_BIG_ENDIAN__", ")", "&&", "__BYTE_ORDER__", "==", "__ORDER_BIG_ENDIAN__", ")", ")", "\n", "return", "__builtin_bswap32", "(", "a", ")", ";", "#else", "return", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "0", "]", "<<", "0", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "1", "]", "<<", "8", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "2", "]", "<<", "16", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "3", "]", "<<", "24", ")", ";", "#endif", "}" ]
Convert between 32-bit little-endian and native order
[ "Convert", "between", "32", "-", "bit", "little", "-", "endian", "and", "native", "order" ]
[]
[ { "param": "a", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_frombe32
uint32_t
static inline uint32_t lfs_frombe32(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \ BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \ __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) return __builtin_bswap32(a); #elif !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \ BYTE_ORDER == ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \ __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) return a; #else return (((uint8_t *)&a)[0] << 24) | (((uint8_t *)&a)[1] << 16) | (((uint8_t *)&a)[2] << 8) | (((uint8_t *)&a)[3] << 0); #endif }
/* Convert between 32-bit big-endian and native order */
Convert between 32-bit big-endian and native order
[ "Convert", "between", "32", "-", "bit", "big", "-", "endian", "and", "native", "order" ]
static inline uint32_t lfs_frombe32(uint32_t a) { #if !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \ BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \ __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) return __builtin_bswap32(a); #elif !defined(LFS_NO_INTRINSICS) && ( \ (defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \ BYTE_ORDER == ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \ __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) return a; #else return (((uint8_t *)&a)[0] << 24) | (((uint8_t *)&a)[1] << 16) | (((uint8_t *)&a)[2] << 8) | (((uint8_t *)&a)[3] << 0); #endif }
[ "static", "inline", "uint32_t", "lfs_frombe32", "(", "uint32_t", "a", ")", "{", "#if", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "(", "defined", "(", "BYTE_ORDER", ")", "&&", "defined", "(", "ORDER_LITTLE_ENDIAN", ")", "&&", "BYTE_ORDER", "==", "ORDER_LITTLE_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER", ")", "&&", "defined", "(", "__ORDER_LITTLE_ENDIAN", ")", "&&", "__BYTE_ORDER", "==", "__ORDER_LITTLE_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER__", ")", "&&", "defined", "(", "__ORDER_LITTLE_ENDIAN__", ")", "&&", "__BYTE_ORDER__", "==", "__ORDER_LITTLE_ENDIAN__", ")", ")", "\n", "return", "__builtin_bswap32", "(", "a", ")", ";", "#elif", "!", "defined", "(", "LFS_NO_INTRINSICS", ")", "&&", "(", "(", "defined", "(", "BYTE_ORDER", ")", "&&", "defined", "(", "ORDER_BIG_ENDIAN", ")", "&&", "BYTE_ORDER", "==", "ORDER_BIG_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER", ")", "&&", "defined", "(", "__ORDER_BIG_ENDIAN", ")", "&&", "__BYTE_ORDER", "==", "__ORDER_BIG_ENDIAN", ")", "||", "(", "defined", "(", "__BYTE_ORDER__", ")", "&&", "defined", "(", "__ORDER_BIG_ENDIAN__", ")", "&&", "__BYTE_ORDER__", "==", "__ORDER_BIG_ENDIAN__", ")", ")", "\n", "return", "a", ";", "#else", "return", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "0", "]", "<<", "24", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "1", "]", "<<", "16", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "2", "]", "<<", "8", ")", "|", "(", "(", "(", "uint8_t", "*", ")", "&", "a", ")", "[", "3", "]", "<<", "0", ")", ";", "#endif", "}" ]
Convert between 32-bit big-endian and native order
[ "Convert", "between", "32", "-", "bit", "big", "-", "endian", "and", "native", "order" ]
[]
[ { "param": "a", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_malloc
void
static inline void *lfs_malloc(size_t size) { #ifndef LFS_NO_MALLOC return malloc(size); #else (void)size; return NULL; #endif }
/* Allocate memory, only used if buffers are not provided to littlefs */ /* Note, memory must be 64-bit aligned */
Allocate memory, only used if buffers are not provided to littlefs Note, memory must be 64-bit aligned
[ "Allocate", "memory", "only", "used", "if", "buffers", "are", "not", "provided", "to", "littlefs", "Note", "memory", "must", "be", "64", "-", "bit", "aligned" ]
static inline void *lfs_malloc(size_t size) { #ifndef LFS_NO_MALLOC return malloc(size); #else (void)size; return NULL; #endif }
[ "static", "inline", "void", "*", "lfs_malloc", "(", "size_t", "size", ")", "{", "#ifndef", "LFS_NO_MALLOC", "return", "malloc", "(", "size", ")", ";", "#else", "(", "void", ")", "size", ";", "return", "NULL", ";", "#endif", "}" ]
Allocate memory, only used if buffers are not provided to littlefs Note, memory must be 64-bit aligned
[ "Allocate", "memory", "only", "used", "if", "buffers", "are", "not", "provided", "to", "littlefs", "Note", "memory", "must", "be", "64", "-", "bit", "aligned" ]
[]
[ { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af7be9ad93bbf4def8c3d29c55666c3b31bffdb5
ParticleBeamHQ/zephyr
modules/littlefs/zephyr_lfs_config.h
[ "Apache-2.0" ]
C
lfs_free
void
static inline void lfs_free(void *p) { #ifndef LFS_NO_MALLOC free(p); #else (void)p; #endif }
/* Deallocate memory, only used if buffers are not provided to littlefs */
Deallocate memory, only used if buffers are not provided to littlefs
[ "Deallocate", "memory", "only", "used", "if", "buffers", "are", "not", "provided", "to", "littlefs" ]
static inline void lfs_free(void *p) { #ifndef LFS_NO_MALLOC free(p); #else (void)p; #endif }
[ "static", "inline", "void", "lfs_free", "(", "void", "*", "p", ")", "{", "#ifndef", "LFS_NO_MALLOC", "free", "(", "p", ")", ";", "#else", "(", "void", ")", "p", ";", "#endif", "}" ]
Deallocate memory, only used if buffers are not provided to littlefs
[ "Deallocate", "memory", "only", "used", "if", "buffers", "are", "not", "provided", "to", "littlefs" ]
[]
[ { "param": "p", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0eaaab024d3f88803d1f199c3b72655e268234c
ParticleBeamHQ/zephyr
drivers/timer/ite_it8xxx2_timer.c
[ "Apache-2.0" ]
C
timer_5ms_one_shot
void
void timer_5ms_one_shot(void) { struct wdt_it8xxx2_regs *const timer2_reg = WDT_REG; uint32_t hw_cnt; /* Initialize interrupt handler of one shot timer */ IRQ_CONNECT(ONE_SHOT_TIMER_IRQ, 0, timer_5ms_one_shot_isr, NULL, ONE_SHOT_TIMER_FLAG); /* Set rising edge triggered of one shot timer */ ite_intc_irq_polarity_set(ONE_SHOT_TIMER_IRQ, ONE_SHOT_TIMER_FLAG); /* Clear interrupt status of one shot timer */ ite_intc_isr_clear(ONE_SHOT_TIMER_IRQ); /* Set clock source of one shot timer */ timer2_reg->ET2PSR = EXT_PSR_32P768K; /* * Set count of one shot timer, * and after write ET2CNTLLR timer will start */ hw_cnt = MS_TO_COUNT(32768, 5/*ms*/); timer2_reg->ET2CNTLH2R = (uint8_t)((hw_cnt >> 16) & 0xff); timer2_reg->ET2CNTLHR = (uint8_t)((hw_cnt >> 8) & 0xff); timer2_reg->ET2CNTLLR = (uint8_t)(hw_cnt & 0xff); irq_enable(ONE_SHOT_TIMER_IRQ); }
/* * This timer is used to wake up chip from sleep mode to complete * changing PLL sequence. */
This timer is used to wake up chip from sleep mode to complete changing PLL sequence.
[ "This", "timer", "is", "used", "to", "wake", "up", "chip", "from", "sleep", "mode", "to", "complete", "changing", "PLL", "sequence", "." ]
void timer_5ms_one_shot(void) { struct wdt_it8xxx2_regs *const timer2_reg = WDT_REG; uint32_t hw_cnt; IRQ_CONNECT(ONE_SHOT_TIMER_IRQ, 0, timer_5ms_one_shot_isr, NULL, ONE_SHOT_TIMER_FLAG); ite_intc_irq_polarity_set(ONE_SHOT_TIMER_IRQ, ONE_SHOT_TIMER_FLAG); ite_intc_isr_clear(ONE_SHOT_TIMER_IRQ); timer2_reg->ET2PSR = EXT_PSR_32P768K; hw_cnt = MS_TO_COUNT(32768, 5); timer2_reg->ET2CNTLH2R = (uint8_t)((hw_cnt >> 16) & 0xff); timer2_reg->ET2CNTLHR = (uint8_t)((hw_cnt >> 8) & 0xff); timer2_reg->ET2CNTLLR = (uint8_t)(hw_cnt & 0xff); irq_enable(ONE_SHOT_TIMER_IRQ); }
[ "void", "timer_5ms_one_shot", "(", "void", ")", "{", "struct", "wdt_it8xxx2_regs", "*", "const", "timer2_reg", "=", "WDT_REG", ";", "uint32_t", "hw_cnt", ";", "IRQ_CONNECT", "(", "ONE_SHOT_TIMER_IRQ", ",", "0", ",", "timer_5ms_one_shot_isr", ",", "NULL", ",", "ONE_SHOT_TIMER_FLAG", ")", ";", "ite_intc_irq_polarity_set", "(", "ONE_SHOT_TIMER_IRQ", ",", "ONE_SHOT_TIMER_FLAG", ")", ";", "ite_intc_isr_clear", "(", "ONE_SHOT_TIMER_IRQ", ")", ";", "timer2_reg", "->", "ET2PSR", "=", "EXT_PSR_32P768K", ";", "hw_cnt", "=", "MS_TO_COUNT", "(", "32768", ",", "5", ")", ";", "timer2_reg", "->", "ET2CNTLH2R", "=", "(", "uint8_t", ")", "(", "(", "hw_cnt", ">>", "16", ")", "&", "0xff", ")", ";", "timer2_reg", "->", "ET2CNTLHR", "=", "(", "uint8_t", ")", "(", "(", "hw_cnt", ">>", "8", ")", "&", "0xff", ")", ";", "timer2_reg", "->", "ET2CNTLLR", "=", "(", "uint8_t", ")", "(", "hw_cnt", "&", "0xff", ")", ";", "irq_enable", "(", "ONE_SHOT_TIMER_IRQ", ")", ";", "}" ]
This timer is used to wake up chip from sleep mode to complete changing PLL sequence.
[ "This", "timer", "is", "used", "to", "wake", "up", "chip", "from", "sleep", "mode", "to", "complete", "changing", "PLL", "sequence", "." ]
[ "/* Initialize interrupt handler of one shot timer */", "/* Set rising edge triggered of one shot timer */", "/* Clear interrupt status of one shot timer */", "/* Set clock source of one shot timer */", "/*\n\t * Set count of one shot timer,\n\t * and after write ET2CNTLLR timer will start\n\t */", "/*ms*/" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
d264cb361b64d904a867ab5d2ad1b80f1264a8ea
ParticleBeamHQ/zephyr
drivers/gpio/gpio_sx1509b.c
[ "Apache-2.0" ]
C
i2c_reg_write_word_be
int
static inline int i2c_reg_write_word_be(const struct i2c_dt_spec *bus, uint8_t reg_addr, uint16_t value) { uint8_t tx_buf[3] = { reg_addr, value >> 8, value & 0xff }; return i2c_write_dt(bus, tx_buf, 3); }
/** * @brief Write a big-endian word to an internal address of an I2C slave. * * @param dev Pointer to the I2C bus spec. * @param reg_addr Address of the internal register being written. * @param value Value to be written to internal register. * * @retval 0 If successful. * @retval -EIO General input / output error. */
@brief Write a big-endian word to an internal address of an I2C slave. @param dev Pointer to the I2C bus spec. @param reg_addr Address of the internal register being written. @param value Value to be written to internal register. @retval 0 If successful. @retval -EIO General input / output error.
[ "@brief", "Write", "a", "big", "-", "endian", "word", "to", "an", "internal", "address", "of", "an", "I2C", "slave", ".", "@param", "dev", "Pointer", "to", "the", "I2C", "bus", "spec", ".", "@param", "reg_addr", "Address", "of", "the", "internal", "register", "being", "written", ".", "@param", "value", "Value", "to", "be", "written", "to", "internal", "register", ".", "@retval", "0", "If", "successful", ".", "@retval", "-", "EIO", "General", "input", "/", "output", "error", "." ]
static inline int i2c_reg_write_word_be(const struct i2c_dt_spec *bus, uint8_t reg_addr, uint16_t value) { uint8_t tx_buf[3] = { reg_addr, value >> 8, value & 0xff }; return i2c_write_dt(bus, tx_buf, 3); }
[ "static", "inline", "int", "i2c_reg_write_word_be", "(", "const", "struct", "i2c_dt_spec", "*", "bus", ",", "uint8_t", "reg_addr", ",", "uint16_t", "value", ")", "{", "uint8_t", "tx_buf", "[", "3", "]", "=", "{", "reg_addr", ",", "value", ">>", "8", ",", "value", "&", "0xff", "}", ";", "return", "i2c_write_dt", "(", "bus", ",", "tx_buf", ",", "3", ")", ";", "}" ]
@brief Write a big-endian word to an internal address of an I2C slave.
[ "@brief", "Write", "a", "big", "-", "endian", "word", "to", "an", "internal", "address", "of", "an", "I2C", "slave", "." ]
[]
[ { "param": "bus", "type": "struct i2c_dt_spec" }, { "param": "reg_addr", "type": "uint8_t" }, { "param": "value", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bus", "type": "struct i2c_dt_spec", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d264cb361b64d904a867ab5d2ad1b80f1264a8ea
ParticleBeamHQ/zephyr
drivers/gpio/gpio_sx1509b.c
[ "Apache-2.0" ]
C
i2c_reg_write_byte_be
int
static inline int i2c_reg_write_byte_be(const struct i2c_dt_spec *bus, uint8_t reg_addr, uint8_t value) { uint8_t tx_buf[3] = { reg_addr, value }; return i2c_write_dt(bus, tx_buf, 2); }
/** * @brief Write a big-endian byte to an internal address of an I2C slave. * * @param bus Pointer to the I2C bus spec. * @param reg_addr Address of the internal register being written. * @param value Value to be written to internal register. * * @retval 0 If successful. * @retval -EIO General input / output error. */
@brief Write a big-endian byte to an internal address of an I2C slave. @param bus Pointer to the I2C bus spec. @param reg_addr Address of the internal register being written. @param value Value to be written to internal register. @retval 0 If successful. @retval -EIO General input / output error.
[ "@brief", "Write", "a", "big", "-", "endian", "byte", "to", "an", "internal", "address", "of", "an", "I2C", "slave", ".", "@param", "bus", "Pointer", "to", "the", "I2C", "bus", "spec", ".", "@param", "reg_addr", "Address", "of", "the", "internal", "register", "being", "written", ".", "@param", "value", "Value", "to", "be", "written", "to", "internal", "register", ".", "@retval", "0", "If", "successful", ".", "@retval", "-", "EIO", "General", "input", "/", "output", "error", "." ]
static inline int i2c_reg_write_byte_be(const struct i2c_dt_spec *bus, uint8_t reg_addr, uint8_t value) { uint8_t tx_buf[3] = { reg_addr, value }; return i2c_write_dt(bus, tx_buf, 2); }
[ "static", "inline", "int", "i2c_reg_write_byte_be", "(", "const", "struct", "i2c_dt_spec", "*", "bus", ",", "uint8_t", "reg_addr", ",", "uint8_t", "value", ")", "{", "uint8_t", "tx_buf", "[", "3", "]", "=", "{", "reg_addr", ",", "value", "}", ";", "return", "i2c_write_dt", "(", "bus", ",", "tx_buf", ",", "2", ")", ";", "}" ]
@brief Write a big-endian byte to an internal address of an I2C slave.
[ "@brief", "Write", "a", "big", "-", "endian", "byte", "to", "an", "internal", "address", "of", "an", "I2C", "slave", "." ]
[]
[ { "param": "bus", "type": "struct i2c_dt_spec" }, { "param": "reg_addr", "type": "uint8_t" }, { "param": "value", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bus", "type": "struct i2c_dt_spec", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d264cb361b64d904a867ab5d2ad1b80f1264a8ea
ParticleBeamHQ/zephyr
drivers/gpio/gpio_sx1509b.c
[ "Apache-2.0" ]
C
sx1509b_init
int
static int sx1509b_init(const struct device *dev) { const struct sx1509b_config *cfg = dev->config; struct sx1509b_drv_data *drv_data = dev->data; int rc; if (!device_is_ready(cfg->bus.bus)) { LOG_ERR("I2C bus not ready"); rc = -ENODEV; goto out; } #ifdef CONFIG_GPIO_SX1509B_INTERRUPT drv_data->dev = dev; if (!device_is_ready(cfg->nint_gpio.port)) { rc = -ENODEV; goto out; } k_work_init(&drv_data->work, sx1509b_work_handler); gpio_pin_configure_dt(&cfg->nint_gpio, GPIO_INPUT); gpio_pin_interrupt_configure_dt(&cfg->nint_gpio, GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&drv_data->gpio_cb, sx1509_int_cb, BIT(cfg->nint_gpio.pin)); gpio_add_callback(cfg->nint_gpio.port, &drv_data->gpio_cb); drv_data->irq_state = (struct sx1509b_irq_state) { .interrupt_mask = ALL_PINS, }; #endif rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_RESET, SX1509B_REG_RESET_MAGIC0); if (rc != 0) { LOG_ERR("%s: reset m0 failed: %d\n", dev->name, rc); goto out; } rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_RESET, SX1509B_REG_RESET_MAGIC1); if (rc != 0) { goto out; } k_sleep(K_MSEC(RESET_DELAY_MS)); /* Reset state mediated by initial configuration */ drv_data->pin_state = (struct sx1509b_pin_state) { .dir = (ALL_PINS & ~(DT_INST_PROP(0, init_out_low) | DT_INST_PROP(0, init_out_high))), .data = (ALL_PINS & ~DT_INST_PROP(0, init_out_low)), }; drv_data->debounce_state = (struct sx1509b_debounce_state) { .debounce_config = CONFIG_GPIO_SX1509B_DEBOUNCE_TIME, }; rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_CLOCK, SX1509B_REG_CLOCK_FOSC_INT_2MHZ); if (rc == 0) { rc = i2c_reg_write_word_be(&cfg->bus, SX1509B_REG_DATA, drv_data->pin_state.data); } if (rc == 0) { rc = i2c_reg_write_word_be(&cfg->bus, SX1509B_REG_DIR, drv_data->pin_state.dir); } if (rc == 0) { rc = i2c_reg_write_byte_be(&cfg->bus, SX1509B_REG_MISC, SX1509B_REG_MISC_LOG_A | SX1509B_REG_MISC_LOG_B | SX1509B_REG_MISC_FREQ); } out: if (rc != 0) { LOG_ERR("%s init failed: %d", dev->name, rc); } else { LOG_INF("%s init ok", dev->name); } k_sem_give(&drv_data->lock); return rc; }
/** * @brief Initialization function of SX1509B * * @param dev Device struct * @return 0 if successful, failed otherwise. */
@brief Initialization function of SX1509B @param dev Device struct @return 0 if successful, failed otherwise.
[ "@brief", "Initialization", "function", "of", "SX1509B", "@param", "dev", "Device", "struct", "@return", "0", "if", "successful", "failed", "otherwise", "." ]
static int sx1509b_init(const struct device *dev) { const struct sx1509b_config *cfg = dev->config; struct sx1509b_drv_data *drv_data = dev->data; int rc; if (!device_is_ready(cfg->bus.bus)) { LOG_ERR("I2C bus not ready"); rc = -ENODEV; goto out; } #ifdef CONFIG_GPIO_SX1509B_INTERRUPT drv_data->dev = dev; if (!device_is_ready(cfg->nint_gpio.port)) { rc = -ENODEV; goto out; } k_work_init(&drv_data->work, sx1509b_work_handler); gpio_pin_configure_dt(&cfg->nint_gpio, GPIO_INPUT); gpio_pin_interrupt_configure_dt(&cfg->nint_gpio, GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&drv_data->gpio_cb, sx1509_int_cb, BIT(cfg->nint_gpio.pin)); gpio_add_callback(cfg->nint_gpio.port, &drv_data->gpio_cb); drv_data->irq_state = (struct sx1509b_irq_state) { .interrupt_mask = ALL_PINS, }; #endif rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_RESET, SX1509B_REG_RESET_MAGIC0); if (rc != 0) { LOG_ERR("%s: reset m0 failed: %d\n", dev->name, rc); goto out; } rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_RESET, SX1509B_REG_RESET_MAGIC1); if (rc != 0) { goto out; } k_sleep(K_MSEC(RESET_DELAY_MS)); drv_data->pin_state = (struct sx1509b_pin_state) { .dir = (ALL_PINS & ~(DT_INST_PROP(0, init_out_low) | DT_INST_PROP(0, init_out_high))), .data = (ALL_PINS & ~DT_INST_PROP(0, init_out_low)), }; drv_data->debounce_state = (struct sx1509b_debounce_state) { .debounce_config = CONFIG_GPIO_SX1509B_DEBOUNCE_TIME, }; rc = i2c_reg_write_byte_dt(&cfg->bus, SX1509B_REG_CLOCK, SX1509B_REG_CLOCK_FOSC_INT_2MHZ); if (rc == 0) { rc = i2c_reg_write_word_be(&cfg->bus, SX1509B_REG_DATA, drv_data->pin_state.data); } if (rc == 0) { rc = i2c_reg_write_word_be(&cfg->bus, SX1509B_REG_DIR, drv_data->pin_state.dir); } if (rc == 0) { rc = i2c_reg_write_byte_be(&cfg->bus, SX1509B_REG_MISC, SX1509B_REG_MISC_LOG_A | SX1509B_REG_MISC_LOG_B | SX1509B_REG_MISC_FREQ); } out: if (rc != 0) { LOG_ERR("%s init failed: %d", dev->name, rc); } else { LOG_INF("%s init ok", dev->name); } k_sem_give(&drv_data->lock); return rc; }
[ "static", "int", "sx1509b_init", "(", "const", "struct", "device", "*", "dev", ")", "{", "const", "struct", "sx1509b_config", "*", "cfg", "=", "dev", "->", "config", ";", "struct", "sx1509b_drv_data", "*", "drv_data", "=", "dev", "->", "data", ";", "int", "rc", ";", "if", "(", "!", "device_is_ready", "(", "cfg", "->", "bus", ".", "bus", ")", ")", "{", "LOG_ERR", "(", "\"", "\"", ")", ";", "rc", "=", "-", "ENODEV", ";", "goto", "out", ";", "}", "#ifdef", "CONFIG_GPIO_SX1509B_INTERRUPT", "drv_data", "->", "dev", "=", "dev", ";", "if", "(", "!", "device_is_ready", "(", "cfg", "->", "nint_gpio", ".", "port", ")", ")", "{", "rc", "=", "-", "ENODEV", ";", "goto", "out", ";", "}", "k_work_init", "(", "&", "drv_data", "->", "work", ",", "sx1509b_work_handler", ")", ";", "gpio_pin_configure_dt", "(", "&", "cfg", "->", "nint_gpio", ",", "GPIO_INPUT", ")", ";", "gpio_pin_interrupt_configure_dt", "(", "&", "cfg", "->", "nint_gpio", ",", "GPIO_INT_EDGE_TO_ACTIVE", ")", ";", "gpio_init_callback", "(", "&", "drv_data", "->", "gpio_cb", ",", "sx1509_int_cb", ",", "BIT", "(", "cfg", "->", "nint_gpio", ".", "pin", ")", ")", ";", "gpio_add_callback", "(", "cfg", "->", "nint_gpio", ".", "port", ",", "&", "drv_data", "->", "gpio_cb", ")", ";", "drv_data", "->", "irq_state", "=", "(", "struct", "sx1509b_irq_state", ")", "{", ".", "interrupt_mask", "=", "ALL_PINS", ",", "}", ";", "#endif", "rc", "=", "i2c_reg_write_byte_dt", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_RESET", ",", "SX1509B_REG_RESET_MAGIC0", ")", ";", "if", "(", "rc", "!=", "0", ")", "{", "LOG_ERR", "(", "\"", "\\n", "\"", ",", "dev", "->", "name", ",", "rc", ")", ";", "goto", "out", ";", "}", "rc", "=", "i2c_reg_write_byte_dt", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_RESET", ",", "SX1509B_REG_RESET_MAGIC1", ")", ";", "if", "(", "rc", "!=", "0", ")", "{", "goto", "out", ";", "}", "k_sleep", "(", "K_MSEC", "(", "RESET_DELAY_MS", ")", ")", ";", "drv_data", "->", "pin_state", "=", "(", "struct", "sx1509b_pin_state", ")", "{", ".", "dir", "=", "(", "ALL_PINS", "&", "~", "(", "DT_INST_PROP", "(", "0", ",", "init_out_low", ")", "|", "DT_INST_PROP", "(", "0", ",", "init_out_high", ")", ")", ")", ",", ".", "data", "=", "(", "ALL_PINS", "&", "~", "DT_INST_PROP", "(", "0", ",", "init_out_low", ")", ")", ",", "}", ";", "drv_data", "->", "debounce_state", "=", "(", "struct", "sx1509b_debounce_state", ")", "{", ".", "debounce_config", "=", "CONFIG_GPIO_SX1509B_DEBOUNCE_TIME", ",", "}", ";", "rc", "=", "i2c_reg_write_byte_dt", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_CLOCK", ",", "SX1509B_REG_CLOCK_FOSC_INT_2MHZ", ")", ";", "if", "(", "rc", "==", "0", ")", "{", "rc", "=", "i2c_reg_write_word_be", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_DATA", ",", "drv_data", "->", "pin_state", ".", "data", ")", ";", "}", "if", "(", "rc", "==", "0", ")", "{", "rc", "=", "i2c_reg_write_word_be", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_DIR", ",", "drv_data", "->", "pin_state", ".", "dir", ")", ";", "}", "if", "(", "rc", "==", "0", ")", "{", "rc", "=", "i2c_reg_write_byte_be", "(", "&", "cfg", "->", "bus", ",", "SX1509B_REG_MISC", ",", "SX1509B_REG_MISC_LOG_A", "|", "SX1509B_REG_MISC_LOG_B", "|", "SX1509B_REG_MISC_FREQ", ")", ";", "}", "out", ":", "if", "(", "rc", "!=", "0", ")", "{", "LOG_ERR", "(", "\"", "\"", ",", "dev", "->", "name", ",", "rc", ")", ";", "}", "else", "{", "LOG_INF", "(", "\"", "\"", ",", "dev", "->", "name", ")", ";", "}", "k_sem_give", "(", "&", "drv_data", "->", "lock", ")", ";", "return", "rc", ";", "}" ]
@brief Initialization function of SX1509B @param dev Device struct @return 0 if successful, failed otherwise.
[ "@brief", "Initialization", "function", "of", "SX1509B", "@param", "dev", "Device", "struct", "@return", "0", "if", "successful", "failed", "otherwise", "." ]
[ "/* Reset state mediated by initial configuration */" ]
[ { "param": "dev", "type": "struct device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
811a22b7a61ee5fdb8150b1dfe5dc1eefb07c25b
ParticleBeamHQ/zephyr
soc/arm/microchip_mec/mec1501/power.c
[ "Apache-2.0" ]
C
z_power_soc_deep_sleep
void
static void z_power_soc_deep_sleep(void) { /* Mask all exceptions and interrupts except NMI and HardFault */ __set_PRIMASK(1); soc_deep_sleep_periph_save(); soc_deep_sleep_enable(); soc_deep_sleep_wait_clk_idle(); soc_deep_sleep_non_wake_en(); /* * Unmask all interrupts in BASEPRI. PRIMASK is used above to * prevent entering an ISR after unmasking in BASEPRI. */ __set_BASEPRI(0); __DSB(); __WFI(); /* triggers sleep hardware */ __NOP(); __NOP(); soc_deep_sleep_disable(); soc_deep_sleep_non_wake_dis(); /* Wait for PLL to lock */ while ((PCR_REGS->OSC_ID & MCHP_PCR_OSC_ID_PLL_LOCK) == 0) { } soc_deep_sleep_periph_restore(); /* * pm_state_exit_post_ops() is not being called * after exiting deep sleep, so need to unmask exceptions * and interrupts here. */ __set_PRIMASK(0); }
/* * Deep Sleep * Pros: * Lower power dissipation, 48MHz PLL is off * Cons: * Longer wake latency. CPU start running on ring oscillator * between 16 to 25 MHz. Minimum 3ms until PLL reaches lock * frequency of 48MHz. * * Implementation Notes: * We touch the Cortex-M's primary mask and base priority registers * because we do not want to enter an ISR immediately upon wake. * We must restore any hardware state that was modified upon sleep * entry before allowing interrupts to be serviced. Zephyr arch level * does not provide API's to manipulate both primary mask and base priority. * * DEBUG NOTES: * If a JTAG/SWD debug probe is connected driving TRST# high and * possibly polling the DUT then MEC1501 will not shut off its 48MHz * PLL. Firmware should not disable JTAG/SWD in the EC subsystem * while a probe is using the interface. This can leave the JTAG/SWD * TAP controller in a state of requesting clocks preventing the PLL * from being shut off. */
Deep Sleep Pros: Lower power dissipation, 48MHz PLL is off Cons: Longer wake latency. CPU start running on ring oscillator between 16 to 25 MHz. Minimum 3ms until PLL reaches lock frequency of 48MHz. Implementation Notes: We touch the Cortex-M's primary mask and base priority registers because we do not want to enter an ISR immediately upon wake. We must restore any hardware state that was modified upon sleep entry before allowing interrupts to be serviced. Zephyr arch level does not provide API's to manipulate both primary mask and base priority. DEBUG NOTES: If a JTAG/SWD debug probe is connected driving TRST# high and possibly polling the DUT then MEC1501 will not shut off its 48MHz PLL. Firmware should not disable JTAG/SWD in the EC subsystem while a probe is using the interface. This can leave the JTAG/SWD TAP controller in a state of requesting clocks preventing the PLL from being shut off.
[ "Deep", "Sleep", "Pros", ":", "Lower", "power", "dissipation", "48MHz", "PLL", "is", "off", "Cons", ":", "Longer", "wake", "latency", ".", "CPU", "start", "running", "on", "ring", "oscillator", "between", "16", "to", "25", "MHz", ".", "Minimum", "3ms", "until", "PLL", "reaches", "lock", "frequency", "of", "48MHz", ".", "Implementation", "Notes", ":", "We", "touch", "the", "Cortex", "-", "M", "'", "s", "primary", "mask", "and", "base", "priority", "registers", "because", "we", "do", "not", "want", "to", "enter", "an", "ISR", "immediately", "upon", "wake", ".", "We", "must", "restore", "any", "hardware", "state", "that", "was", "modified", "upon", "sleep", "entry", "before", "allowing", "interrupts", "to", "be", "serviced", ".", "Zephyr", "arch", "level", "does", "not", "provide", "API", "'", "s", "to", "manipulate", "both", "primary", "mask", "and", "base", "priority", ".", "DEBUG", "NOTES", ":", "If", "a", "JTAG", "/", "SWD", "debug", "probe", "is", "connected", "driving", "TRST#", "high", "and", "possibly", "polling", "the", "DUT", "then", "MEC1501", "will", "not", "shut", "off", "its", "48MHz", "PLL", ".", "Firmware", "should", "not", "disable", "JTAG", "/", "SWD", "in", "the", "EC", "subsystem", "while", "a", "probe", "is", "using", "the", "interface", ".", "This", "can", "leave", "the", "JTAG", "/", "SWD", "TAP", "controller", "in", "a", "state", "of", "requesting", "clocks", "preventing", "the", "PLL", "from", "being", "shut", "off", "." ]
static void z_power_soc_deep_sleep(void) { __set_PRIMASK(1); soc_deep_sleep_periph_save(); soc_deep_sleep_enable(); soc_deep_sleep_wait_clk_idle(); soc_deep_sleep_non_wake_en(); __set_BASEPRI(0); __DSB(); __WFI(); __NOP(); __NOP(); soc_deep_sleep_disable(); soc_deep_sleep_non_wake_dis(); while ((PCR_REGS->OSC_ID & MCHP_PCR_OSC_ID_PLL_LOCK) == 0) { } soc_deep_sleep_periph_restore(); __set_PRIMASK(0); }
[ "static", "void", "z_power_soc_deep_sleep", "(", "void", ")", "{", "__set_PRIMASK", "(", "1", ")", ";", "soc_deep_sleep_periph_save", "(", ")", ";", "soc_deep_sleep_enable", "(", ")", ";", "soc_deep_sleep_wait_clk_idle", "(", ")", ";", "soc_deep_sleep_non_wake_en", "(", ")", ";", "__set_BASEPRI", "(", "0", ")", ";", "__DSB", "(", ")", ";", "__WFI", "(", ")", ";", "__NOP", "(", ")", ";", "__NOP", "(", ")", ";", "soc_deep_sleep_disable", "(", ")", ";", "soc_deep_sleep_non_wake_dis", "(", ")", ";", "while", "(", "(", "PCR_REGS", "->", "OSC_ID", "&", "MCHP_PCR_OSC_ID_PLL_LOCK", ")", "==", "0", ")", "{", "}", "soc_deep_sleep_periph_restore", "(", ")", ";", "__set_PRIMASK", "(", "0", ")", ";", "}" ]
Deep Sleep Pros: Lower power dissipation, 48MHz PLL is off Cons: Longer wake latency.
[ "Deep", "Sleep", "Pros", ":", "Lower", "power", "dissipation", "48MHz", "PLL", "is", "off", "Cons", ":", "Longer", "wake", "latency", "." ]
[ "/* Mask all exceptions and interrupts except NMI and HardFault */", "/*\n\t * Unmask all interrupts in BASEPRI. PRIMASK is used above to\n\t * prevent entering an ISR after unmasking in BASEPRI.\n\t */", "/* triggers sleep hardware */", "/* Wait for PLL to lock */", "/*\n\t * pm_state_exit_post_ops() is not being called\n\t * after exiting deep sleep, so need to unmask exceptions\n\t * and interrupts here.\n\t */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
8b8ebce08a2536566d73d7bfbd241cf868a6e009
ParticleBeamHQ/zephyr
subsys/pm/pm.c
[ "Apache-2.0" ]
C
pm_state_notify
void
static inline void pm_state_notify(bool entering_state) { struct pm_notifier *notifier; k_spinlock_key_t pm_notifier_key; void (*callback)(enum pm_state state); pm_notifier_key = k_spin_lock(&pm_notifier_lock); SYS_SLIST_FOR_EACH_CONTAINER(&pm_notifiers, notifier, _node) { if (entering_state) { callback = notifier->state_entry; } else { callback = notifier->state_exit; } if (callback) { callback(z_cpus_pm_state[_current_cpu->id].state); } } k_spin_unlock(&pm_notifier_lock, pm_notifier_key); }
/* * Function called to notify when the system is entering / exiting a * power state */
Function called to notify when the system is entering / exiting a power state
[ "Function", "called", "to", "notify", "when", "the", "system", "is", "entering", "/", "exiting", "a", "power", "state" ]
static inline void pm_state_notify(bool entering_state) { struct pm_notifier *notifier; k_spinlock_key_t pm_notifier_key; void (*callback)(enum pm_state state); pm_notifier_key = k_spin_lock(&pm_notifier_lock); SYS_SLIST_FOR_EACH_CONTAINER(&pm_notifiers, notifier, _node) { if (entering_state) { callback = notifier->state_entry; } else { callback = notifier->state_exit; } if (callback) { callback(z_cpus_pm_state[_current_cpu->id].state); } } k_spin_unlock(&pm_notifier_lock, pm_notifier_key); }
[ "static", "inline", "void", "pm_state_notify", "(", "bool", "entering_state", ")", "{", "struct", "pm_notifier", "*", "notifier", ";", "k_spinlock_key_t", "pm_notifier_key", ";", "void", "(", "*", "callback", ")", "(", "enum", "pm_state", "state", ")", ";", "pm_notifier_key", "=", "k_spin_lock", "(", "&", "pm_notifier_lock", ")", ";", "SYS_SLIST_FOR_EACH_CONTAINER", "(", "&", "pm_notifiers", ",", "notifier", ",", "_node", ")", "", "{", "if", "(", "entering_state", ")", "{", "callback", "=", "notifier", "->", "state_entry", ";", "}", "else", "{", "callback", "=", "notifier", "->", "state_exit", ";", "}", "if", "(", "callback", ")", "{", "callback", "(", "z_cpus_pm_state", "[", "_current_cpu", "->", "id", "]", ".", "state", ")", ";", "}", "}", "k_spin_unlock", "(", "&", "pm_notifier_lock", ",", "pm_notifier_key", ")", ";", "}" ]
Function called to notify when the system is entering / exiting a power state
[ "Function", "called", "to", "notify", "when", "the", "system", "is", "entering", "/", "exiting", "a", "power", "state" ]
[]
[ { "param": "entering_state", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "entering_state", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6ba2fa7fb1c062a581c52ebe84ef8f8d026fdf41
ParticleBeamHQ/zephyr
drivers/bluetooth/hci/spi.c
[ "Apache-2.0" ]
C
configure_cs
int
static int configure_cs(void) { /* Configure pin as output and set to active */ return gpio_pin_configure_dt(&bus.config.cs->gpio, GPIO_OUTPUT_ACTIVE); }
/* BlueNRG has a particuliar way to wake up from sleep and be ready. * All is done through its CS line: * If it is in sleep mode, the first transaction will not return ready * status. At this point, it's necessary to release the CS and retry * within 2ms the same transaction. And again when it's required to * know the amount of byte to read. * (See section 5.2 of BlueNRG-MS datasheet) */
BlueNRG has a particuliar way to wake up from sleep and be ready. All is done through its CS line: If it is in sleep mode, the first transaction will not return ready status. At this point, it's necessary to release the CS and retry within 2ms the same transaction. And again when it's required to know the amount of byte to read. (See section 5.2 of BlueNRG-MS datasheet)
[ "BlueNRG", "has", "a", "particuliar", "way", "to", "wake", "up", "from", "sleep", "and", "be", "ready", ".", "All", "is", "done", "through", "its", "CS", "line", ":", "If", "it", "is", "in", "sleep", "mode", "the", "first", "transaction", "will", "not", "return", "ready", "status", ".", "At", "this", "point", "it", "'", "s", "necessary", "to", "release", "the", "CS", "and", "retry", "within", "2ms", "the", "same", "transaction", ".", "And", "again", "when", "it", "'", "s", "required", "to", "know", "the", "amount", "of", "byte", "to", "read", ".", "(", "See", "section", "5", ".", "2", "of", "BlueNRG", "-", "MS", "datasheet", ")" ]
static int configure_cs(void) { return gpio_pin_configure_dt(&bus.config.cs->gpio, GPIO_OUTPUT_ACTIVE); }
[ "static", "int", "configure_cs", "(", "void", ")", "{", "return", "gpio_pin_configure_dt", "(", "&", "bus", ".", "config", ".", "cs", "->", "gpio", ",", "GPIO_OUTPUT_ACTIVE", ")", ";", "}" ]
BlueNRG has a particuliar way to wake up from sleep and be ready.
[ "BlueNRG", "has", "a", "particuliar", "way", "to", "wake", "up", "from", "sleep", "and", "be", "ready", "." ]
[ "/* Configure pin as output and set to active */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f657a7abd22dee165d49b6107ada7935c7ff9638
ParticleBeamHQ/zephyr
samples/boards/stm32/usbc/sink/src/stm32g081b_eval_board.c
[ "Apache-2.0" ]
C
board_vbus_meas
int
int board_vbus_meas(int *mv) { int32_t value; int ret; ret = adc_read(dev_adc, &sequence); if (ret != 0) { printk("ADC reading failed with error %d.\n", ret); return ret; } value = sample_buffer; ret = adc_raw_to_millivolts(ADC_REF_MV, ADC_GAIN, ADC_RESOLUTION, &value); if (ret != 0) { printk("Scaling ADC failed with error %d.\n", ret); return ret; } /* VBUS is scaled down though a voltage divider */ *mv = (value * 1000) / ((output_ohm * 1000) / full_ohm); return 0; }
/** * @brief This function is used to measure the VBUS in millivolts */
@brief This function is used to measure the VBUS in millivolts
[ "@brief", "This", "function", "is", "used", "to", "measure", "the", "VBUS", "in", "millivolts" ]
int board_vbus_meas(int *mv) { int32_t value; int ret; ret = adc_read(dev_adc, &sequence); if (ret != 0) { printk("ADC reading failed with error %d.\n", ret); return ret; } value = sample_buffer; ret = adc_raw_to_millivolts(ADC_REF_MV, ADC_GAIN, ADC_RESOLUTION, &value); if (ret != 0) { printk("Scaling ADC failed with error %d.\n", ret); return ret; } *mv = (value * 1000) / ((output_ohm * 1000) / full_ohm); return 0; }
[ "int", "board_vbus_meas", "(", "int", "*", "mv", ")", "{", "int32_t", "value", ";", "int", "ret", ";", "ret", "=", "adc_read", "(", "dev_adc", ",", "&", "sequence", ")", ";", "if", "(", "ret", "!=", "0", ")", "{", "printk", "(", "\"", "\\n", "\"", ",", "ret", ")", ";", "return", "ret", ";", "}", "value", "=", "sample_buffer", ";", "ret", "=", "adc_raw_to_millivolts", "(", "ADC_REF_MV", ",", "ADC_GAIN", ",", "ADC_RESOLUTION", ",", "&", "value", ")", ";", "if", "(", "ret", "!=", "0", ")", "{", "printk", "(", "\"", "\\n", "\"", ",", "ret", ")", ";", "return", "ret", ";", "}", "*", "mv", "=", "(", "value", "*", "1000", ")", "/", "(", "(", "output_ohm", "*", "1000", ")", "/", "full_ohm", ")", ";", "return", "0", ";", "}" ]
@brief This function is used to measure the VBUS in millivolts
[ "@brief", "This", "function", "is", "used", "to", "measure", "the", "VBUS", "in", "millivolts" ]
[ "/* VBUS is scaled down though a voltage divider */" ]
[ { "param": "mv", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mv", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
904019e759aa5c5bc57e111988122126d3fc01b8
ParticleBeamHQ/zephyr
include/zephyr/arch/xtensa/cache.h
[ "Apache-2.0" ]
C
arch_xtensa_cached_ptr
void
static inline void *arch_xtensa_cached_ptr(void *ptr) { return (void *)z_xtrpoflip((uint32_t) ptr, CONFIG_XTENSA_CACHED_REGION, CONFIG_XTENSA_UNCACHED_REGION); }
/** * @brief Return cached pointer to a RAM address * * The Xtensa coherence architecture maps addressable RAM twice, in * two different 512MB regions whose L1 cache settings can be * controlled independently. So for any given pointer, it is possible * to convert it to and from a cached version. * * This function takes a pointer to any addressable object (either in * cacheable memory or not) and returns a pointer that can be used to * refer to the same memory through the L1 data cache. Data read * through the resulting pointer will reflect locally cached values on * the current CPU if they exist, and writes will go first into the * cache and be written back later. * * @see arch_xtensa_uncached_ptr() * * @param ptr A pointer to a valid C object * @return A pointer to the same object via the L1 dcache */
@brief Return cached pointer to a RAM address The Xtensa coherence architecture maps addressable RAM twice, in two different 512MB regions whose L1 cache settings can be controlled independently. So for any given pointer, it is possible to convert it to and from a cached version. This function takes a pointer to any addressable object (either in cacheable memory or not) and returns a pointer that can be used to refer to the same memory through the L1 data cache. Data read through the resulting pointer will reflect locally cached values on the current CPU if they exist, and writes will go first into the cache and be written back later. @param ptr A pointer to a valid C object @return A pointer to the same object via the L1 dcache
[ "@brief", "Return", "cached", "pointer", "to", "a", "RAM", "address", "The", "Xtensa", "coherence", "architecture", "maps", "addressable", "RAM", "twice", "in", "two", "different", "512MB", "regions", "whose", "L1", "cache", "settings", "can", "be", "controlled", "independently", ".", "So", "for", "any", "given", "pointer", "it", "is", "possible", "to", "convert", "it", "to", "and", "from", "a", "cached", "version", ".", "This", "function", "takes", "a", "pointer", "to", "any", "addressable", "object", "(", "either", "in", "cacheable", "memory", "or", "not", ")", "and", "returns", "a", "pointer", "that", "can", "be", "used", "to", "refer", "to", "the", "same", "memory", "through", "the", "L1", "data", "cache", ".", "Data", "read", "through", "the", "resulting", "pointer", "will", "reflect", "locally", "cached", "values", "on", "the", "current", "CPU", "if", "they", "exist", "and", "writes", "will", "go", "first", "into", "the", "cache", "and", "be", "written", "back", "later", ".", "@param", "ptr", "A", "pointer", "to", "a", "valid", "C", "object", "@return", "A", "pointer", "to", "the", "same", "object", "via", "the", "L1", "dcache" ]
static inline void *arch_xtensa_cached_ptr(void *ptr) { return (void *)z_xtrpoflip((uint32_t) ptr, CONFIG_XTENSA_CACHED_REGION, CONFIG_XTENSA_UNCACHED_REGION); }
[ "static", "inline", "void", "*", "arch_xtensa_cached_ptr", "(", "void", "*", "ptr", ")", "{", "return", "(", "void", "*", ")", "z_xtrpoflip", "(", "(", "uint32_t", ")", "ptr", ",", "CONFIG_XTENSA_CACHED_REGION", ",", "CONFIG_XTENSA_UNCACHED_REGION", ")", ";", "}" ]
@brief Return cached pointer to a RAM address The Xtensa coherence architecture maps addressable RAM twice, in two different 512MB regions whose L1 cache settings can be controlled independently.
[ "@brief", "Return", "cached", "pointer", "to", "a", "RAM", "address", "The", "Xtensa", "coherence", "architecture", "maps", "addressable", "RAM", "twice", "in", "two", "different", "512MB", "regions", "whose", "L1", "cache", "settings", "can", "be", "controlled", "independently", "." ]
[]
[ { "param": "ptr", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
904019e759aa5c5bc57e111988122126d3fc01b8
ParticleBeamHQ/zephyr
include/zephyr/arch/xtensa/cache.h
[ "Apache-2.0" ]
C
arch_xtensa_uncached_ptr
void
static inline void *arch_xtensa_uncached_ptr(void *ptr) { return (void *)z_xtrpoflip((uint32_t) ptr, CONFIG_XTENSA_UNCACHED_REGION, CONFIG_XTENSA_CACHED_REGION); }
/** * @brief Return uncached pointer to a RAM address * * The Xtensa coherence architecture maps addressable RAM twice, in * two different 512MB regions whose L1 cache settings can be * controlled independently. So for any given pointer, it is possible * to convert it to and from a cached version. * * This function takes a pointer to any addressable object (either in * cacheable memory or not) and returns a pointer that can be used to * refer to the same memory while bypassing the L1 data cache. Data * in the L1 cache will not be inspected nor modified by the access. * * @see arch_xtensa_cached_ptr() * * @param ptr A pointer to a valid C object * @return A pointer to the same object bypassing the L1 dcache */
@brief Return uncached pointer to a RAM address The Xtensa coherence architecture maps addressable RAM twice, in two different 512MB regions whose L1 cache settings can be controlled independently. So for any given pointer, it is possible to convert it to and from a cached version. This function takes a pointer to any addressable object (either in cacheable memory or not) and returns a pointer that can be used to refer to the same memory while bypassing the L1 data cache. Data in the L1 cache will not be inspected nor modified by the access. @param ptr A pointer to a valid C object @return A pointer to the same object bypassing the L1 dcache
[ "@brief", "Return", "uncached", "pointer", "to", "a", "RAM", "address", "The", "Xtensa", "coherence", "architecture", "maps", "addressable", "RAM", "twice", "in", "two", "different", "512MB", "regions", "whose", "L1", "cache", "settings", "can", "be", "controlled", "independently", ".", "So", "for", "any", "given", "pointer", "it", "is", "possible", "to", "convert", "it", "to", "and", "from", "a", "cached", "version", ".", "This", "function", "takes", "a", "pointer", "to", "any", "addressable", "object", "(", "either", "in", "cacheable", "memory", "or", "not", ")", "and", "returns", "a", "pointer", "that", "can", "be", "used", "to", "refer", "to", "the", "same", "memory", "while", "bypassing", "the", "L1", "data", "cache", ".", "Data", "in", "the", "L1", "cache", "will", "not", "be", "inspected", "nor", "modified", "by", "the", "access", ".", "@param", "ptr", "A", "pointer", "to", "a", "valid", "C", "object", "@return", "A", "pointer", "to", "the", "same", "object", "bypassing", "the", "L1", "dcache" ]
static inline void *arch_xtensa_uncached_ptr(void *ptr) { return (void *)z_xtrpoflip((uint32_t) ptr, CONFIG_XTENSA_UNCACHED_REGION, CONFIG_XTENSA_CACHED_REGION); }
[ "static", "inline", "void", "*", "arch_xtensa_uncached_ptr", "(", "void", "*", "ptr", ")", "{", "return", "(", "void", "*", ")", "z_xtrpoflip", "(", "(", "uint32_t", ")", "ptr", ",", "CONFIG_XTENSA_UNCACHED_REGION", ",", "CONFIG_XTENSA_CACHED_REGION", ")", ";", "}" ]
@brief Return uncached pointer to a RAM address The Xtensa coherence architecture maps addressable RAM twice, in two different 512MB regions whose L1 cache settings can be controlled independently.
[ "@brief", "Return", "uncached", "pointer", "to", "a", "RAM", "address", "The", "Xtensa", "coherence", "architecture", "maps", "addressable", "RAM", "twice", "in", "two", "different", "512MB", "regions", "whose", "L1", "cache", "settings", "can", "be", "controlled", "independently", "." ]
[]
[ { "param": "ptr", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
535e26b9eaf5d8be12d343840df70951693f1f12
ParticleBeamHQ/zephyr
drivers/adc/adc_ite_it8xxx2.c
[ "Apache-2.0" ]
C
adc_it8xxx2_get_sample
void
static void adc_it8xxx2_get_sample(const struct device *dev) { struct adc_it8xxx2_data *data = dev->data; struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE; if (adc_data_valid(dev)) { if (data->ch <= CHIP_ADC_CH7) { /* Read adc raw data of msb and lsb */ *data->buffer++ = adc_regs->VCH0DATM << 8 | adc_regs->VCH0DATL; } else { /* Read adc channels 13~16 raw data of msb and lsb */ *data->buffer++ = adc_regs->adc_vchs_ctrl[ADC_CHANNEL_OFFSET(data->ch)].VCHDATM << 8 | adc_regs->adc_vchs_ctrl[ADC_CHANNEL_OFFSET(data->ch)].VCHDATL; } } else { LOG_WRN("ADC failed to read (regs=%x, ch=%d)", adc_regs->ADCDVSTS, data->ch); } adc_disable_measurement(data->ch); }
/* Get result for each ADC selected channel. */
Get result for each ADC selected channel.
[ "Get", "result", "for", "each", "ADC", "selected", "channel", "." ]
static void adc_it8xxx2_get_sample(const struct device *dev) { struct adc_it8xxx2_data *data = dev->data; struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE; if (adc_data_valid(dev)) { if (data->ch <= CHIP_ADC_CH7) { *data->buffer++ = adc_regs->VCH0DATM << 8 | adc_regs->VCH0DATL; } else { *data->buffer++ = adc_regs->adc_vchs_ctrl[ADC_CHANNEL_OFFSET(data->ch)].VCHDATM << 8 | adc_regs->adc_vchs_ctrl[ADC_CHANNEL_OFFSET(data->ch)].VCHDATL; } } else { LOG_WRN("ADC failed to read (regs=%x, ch=%d)", adc_regs->ADCDVSTS, data->ch); } adc_disable_measurement(data->ch); }
[ "static", "void", "adc_it8xxx2_get_sample", "(", "const", "struct", "device", "*", "dev", ")", "{", "struct", "adc_it8xxx2_data", "*", "data", "=", "dev", "->", "data", ";", "struct", "adc_it8xxx2_regs", "*", "const", "adc_regs", "=", "ADC_IT8XXX2_REG_BASE", ";", "if", "(", "adc_data_valid", "(", "dev", ")", ")", "{", "if", "(", "data", "->", "ch", "<=", "CHIP_ADC_CH7", ")", "{", "*", "data", "->", "buffer", "++", "=", "adc_regs", "->", "VCH0DATM", "<<", "8", "|", "adc_regs", "->", "VCH0DATL", ";", "}", "else", "{", "*", "data", "->", "buffer", "++", "=", "adc_regs", "->", "adc_vchs_ctrl", "[", "ADC_CHANNEL_OFFSET", "(", "data", "->", "ch", ")", "]", ".", "VCHDATM", "<<", "8", "|", "adc_regs", "->", "adc_vchs_ctrl", "[", "ADC_CHANNEL_OFFSET", "(", "data", "->", "ch", ")", "]", ".", "VCHDATL", ";", "}", "}", "else", "{", "LOG_WRN", "(", "\"", "\"", ",", "adc_regs", "->", "ADCDVSTS", ",", "data", "->", "ch", ")", ";", "}", "adc_disable_measurement", "(", "data", "->", "ch", ")", ";", "}" ]
Get result for each ADC selected channel.
[ "Get", "result", "for", "each", "ADC", "selected", "channel", "." ]
[ "/* Read adc raw data of msb and lsb */", "/* Read adc channels 13~16 raw data of msb and lsb */" ]
[ { "param": "dev", "type": "struct device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
535e26b9eaf5d8be12d343840df70951693f1f12
ParticleBeamHQ/zephyr
drivers/adc/adc_ite_it8xxx2.c
[ "Apache-2.0" ]
C
adc_accuracy_initialization
void
static void adc_accuracy_initialization(void) { struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE; /* Start adc accuracy initialization */ adc_regs->ADCSTS |= IT8XXX2_ADC_AINITB; /* Enable automatic HW calibration. */ adc_regs->KDCTL |= IT8XXX2_ADC_AHCE; /* Stop adc accuracy initialization */ adc_regs->ADCSTS &= ~IT8XXX2_ADC_AINITB; }
/* * ADC analog accuracy initialization (only once after VSTBY power on) * * Write 1 to this bit and write 0 to this bit immediately once and * only once during the firmware initialization and do not write 1 again * after initialization since IT83xx takes much power consumption * if this bit is set as 1 */
ADC analog accuracy initialization (only once after VSTBY power on) Write 1 to this bit and write 0 to this bit immediately once and only once during the firmware initialization and do not write 1 again after initialization since IT83xx takes much power consumption if this bit is set as 1
[ "ADC", "analog", "accuracy", "initialization", "(", "only", "once", "after", "VSTBY", "power", "on", ")", "Write", "1", "to", "this", "bit", "and", "write", "0", "to", "this", "bit", "immediately", "once", "and", "only", "once", "during", "the", "firmware", "initialization", "and", "do", "not", "write", "1", "again", "after", "initialization", "since", "IT83xx", "takes", "much", "power", "consumption", "if", "this", "bit", "is", "set", "as", "1" ]
static void adc_accuracy_initialization(void) { struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE; adc_regs->ADCSTS |= IT8XXX2_ADC_AINITB; adc_regs->KDCTL |= IT8XXX2_ADC_AHCE; adc_regs->ADCSTS &= ~IT8XXX2_ADC_AINITB; }
[ "static", "void", "adc_accuracy_initialization", "(", "void", ")", "{", "struct", "adc_it8xxx2_regs", "*", "const", "adc_regs", "=", "ADC_IT8XXX2_REG_BASE", ";", "adc_regs", "->", "ADCSTS", "|=", "IT8XXX2_ADC_AINITB", ";", "adc_regs", "->", "KDCTL", "|=", "IT8XXX2_ADC_AHCE", ";", "adc_regs", "->", "ADCSTS", "&=", "~", "IT8XXX2_ADC_AINITB", ";", "}" ]
ADC analog accuracy initialization (only once after VSTBY power on) Write 1 to this bit and write 0 to this bit immediately once and only once during the firmware initialization and do not write 1 again after initialization since IT83xx takes much power consumption if this bit is set as 1
[ "ADC", "analog", "accuracy", "initialization", "(", "only", "once", "after", "VSTBY", "power", "on", ")", "Write", "1", "to", "this", "bit", "and", "write", "0", "to", "this", "bit", "immediately", "once", "and", "only", "once", "during", "the", "firmware", "initialization", "and", "do", "not", "write", "1", "again", "after", "initialization", "since", "IT83xx", "takes", "much", "power", "consumption", "if", "this", "bit", "is", "set", "as", "1" ]
[ "/* Start adc accuracy initialization */", "/* Enable automatic HW calibration. */", "/* Stop adc accuracy initialization */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0a80b92876a26663d3f353802fbef8fecf4f19ff
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_init
int
static int gpio_xlnx_ps_init(const struct device *dev) { const struct gpio_xlnx_ps_dev_cfg *dev_conf = dev->config; /* Initialize the device's interrupt */ dev_conf->config_func(dev); return 0; }
/** * @brief Initialize a Xilinx PS GPIO controller parent device * * Initialize a Xilinx PS GPIO controller parent device, whose task it is * to handle the IRQ line of each controller instance, while the configuration, * status and data acquisition of each MIO / EMIO GPIO pin associated with * the parent controller instance is handled via the respective GPIO pin * bank's child device. * * @param dev Pointer to the PS GPIO controller's device. * * @retval Always 0. */
@brief Initialize a Xilinx PS GPIO controller parent device Initialize a Xilinx PS GPIO controller parent device, whose task it is to handle the IRQ line of each controller instance, while the configuration, status and data acquisition of each MIO / EMIO GPIO pin associated with the parent controller instance is handled via the respective GPIO pin bank's child device. @param dev Pointer to the PS GPIO controller's device. @retval Always 0.
[ "@brief", "Initialize", "a", "Xilinx", "PS", "GPIO", "controller", "parent", "device", "Initialize", "a", "Xilinx", "PS", "GPIO", "controller", "parent", "device", "whose", "task", "it", "is", "to", "handle", "the", "IRQ", "line", "of", "each", "controller", "instance", "while", "the", "configuration", "status", "and", "data", "acquisition", "of", "each", "MIO", "/", "EMIO", "GPIO", "pin", "associated", "with", "the", "parent", "controller", "instance", "is", "handled", "via", "the", "respective", "GPIO", "pin", "bank", "'", "s", "child", "device", ".", "@param", "dev", "Pointer", "to", "the", "PS", "GPIO", "controller", "'", "s", "device", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_init(const struct device *dev) { const struct gpio_xlnx_ps_dev_cfg *dev_conf = dev->config; dev_conf->config_func(dev); return 0; }
[ "static", "int", "gpio_xlnx_ps_init", "(", "const", "struct", "device", "*", "dev", ")", "{", "const", "struct", "gpio_xlnx_ps_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "dev_conf", "->", "config_func", "(", "dev", ")", ";", "return", "0", ";", "}" ]
@brief Initialize a Xilinx PS GPIO controller parent device Initialize a Xilinx PS GPIO controller parent device, whose task it is to handle the IRQ line of each controller instance, while the configuration, status and data acquisition of each MIO / EMIO GPIO pin associated with the parent controller instance is handled via the respective GPIO pin bank's child device.
[ "@brief", "Initialize", "a", "Xilinx", "PS", "GPIO", "controller", "parent", "device", "Initialize", "a", "Xilinx", "PS", "GPIO", "controller", "parent", "device", "whose", "task", "it", "is", "to", "handle", "the", "IRQ", "line", "of", "each", "controller", "instance", "while", "the", "configuration", "status", "and", "data", "acquisition", "of", "each", "MIO", "/", "EMIO", "GPIO", "pin", "associated", "with", "the", "parent", "controller", "instance", "is", "handled", "via", "the", "respective", "GPIO", "pin", "bank", "'", "s", "child", "device", "." ]
[ "/* Initialize the device's interrupt */" ]
[ { "param": "dev", "type": "struct device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_pin_configure
int
static int gpio_xlnx_ps_pin_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t pin_mask = BIT(pin); uint32_t bank_data; uint32_t dirm_data; uint32_t oen_data; /* Validity of the specified pin index is checked in drivers/gpio.h */ /* Check for config flags not supported by the controller */ if (flags & (GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_SINGLE_ENDED)) { return -ENOTSUP; } /* Read the data direction & output enable registers */ dirm_data = sys_read32(GPIO_XLNX_PS_BANK_DIRM_REG); oen_data = sys_read32(GPIO_XLNX_PS_BANK_OEN_REG); if (flags & GPIO_OUTPUT) { dirm_data |= pin_mask; oen_data |= pin_mask; /* * Setting of an initial value (see below) requires the * direction register to be written *BEFORE* the data * register, otherwise, the value will not be applied! * The output enable bit can be set after the initial * value has been written. */ sys_write32(dirm_data, GPIO_XLNX_PS_BANK_DIRM_REG); /* * If the current pin is to be configured as an output * pin, it is up to the caller to specify whether the * output's initial value shall be high or low. * -> Write the initial output value into the data register. */ bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); if (flags & GPIO_OUTPUT_INIT_HIGH) { bank_data |= pin_mask; } else if (flags & GPIO_OUTPUT_INIT_LOW) { bank_data &= ~pin_mask; } sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); /* Set the pin's output enable bit */ sys_write32(oen_data, GPIO_XLNX_PS_BANK_OEN_REG); } else { dirm_data &= ~pin_mask; oen_data &= ~pin_mask; /* * Disable the output first in case of an O -> I * transition, then change the pin's direction. */ sys_write32(oen_data, GPIO_XLNX_PS_BANK_OEN_REG); sys_write32(dirm_data, GPIO_XLNX_PS_BANK_DIRM_REG); } return 0; }
/** * @brief GPIO bank pin configuration function * * Configures an individual pin within a MIO / EMIO GPIO pin bank. * The following flags specified by the GPIO subsystem are NOT * supported by the PS GPIO controller: * * - Pull up * - Pull down * - Open drain * - Open source. * * @param dev Pointer to the GPIO bank's device. * @param pin Index of the pin within the bank to be configured * (decimal index of the pin). * @param flags Flags specifying the pin's configuration. * * @retval 0 if the device initialization completed successfully, * -EINVAL if the specified pin index is out of range, * -ENOTSUP if the pin configuration data contains a flag * that is not supported by the controller. */
@brief GPIO bank pin configuration function Configures an individual pin within a MIO / EMIO GPIO pin bank. The following flags specified by the GPIO subsystem are NOT supported by the PS GPIO controller. - Pull up - Pull down - Open drain - Open source. @param dev Pointer to the GPIO bank's device. @param pin Index of the pin within the bank to be configured (decimal index of the pin). @param flags Flags specifying the pin's configuration. @retval 0 if the device initialization completed successfully, -EINVAL if the specified pin index is out of range, -ENOTSUP if the pin configuration data contains a flag that is not supported by the controller.
[ "@brief", "GPIO", "bank", "pin", "configuration", "function", "Configures", "an", "individual", "pin", "within", "a", "MIO", "/", "EMIO", "GPIO", "pin", "bank", ".", "The", "following", "flags", "specified", "by", "the", "GPIO", "subsystem", "are", "NOT", "supported", "by", "the", "PS", "GPIO", "controller", ".", "-", "Pull", "up", "-", "Pull", "down", "-", "Open", "drain", "-", "Open", "source", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "pin", "Index", "of", "the", "pin", "within", "the", "bank", "to", "be", "configured", "(", "decimal", "index", "of", "the", "pin", ")", ".", "@param", "flags", "Flags", "specifying", "the", "pin", "'", "s", "configuration", ".", "@retval", "0", "if", "the", "device", "initialization", "completed", "successfully", "-", "EINVAL", "if", "the", "specified", "pin", "index", "is", "out", "of", "range", "-", "ENOTSUP", "if", "the", "pin", "configuration", "data", "contains", "a", "flag", "that", "is", "not", "supported", "by", "the", "controller", "." ]
static int gpio_xlnx_ps_pin_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t pin_mask = BIT(pin); uint32_t bank_data; uint32_t dirm_data; uint32_t oen_data; if (flags & (GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_SINGLE_ENDED)) { return -ENOTSUP; } dirm_data = sys_read32(GPIO_XLNX_PS_BANK_DIRM_REG); oen_data = sys_read32(GPIO_XLNX_PS_BANK_OEN_REG); if (flags & GPIO_OUTPUT) { dirm_data |= pin_mask; oen_data |= pin_mask; sys_write32(dirm_data, GPIO_XLNX_PS_BANK_DIRM_REG); bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); if (flags & GPIO_OUTPUT_INIT_HIGH) { bank_data |= pin_mask; } else if (flags & GPIO_OUTPUT_INIT_LOW) { bank_data &= ~pin_mask; } sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); sys_write32(oen_data, GPIO_XLNX_PS_BANK_OEN_REG); } else { dirm_data &= ~pin_mask; oen_data &= ~pin_mask; sys_write32(oen_data, GPIO_XLNX_PS_BANK_OEN_REG); sys_write32(dirm_data, GPIO_XLNX_PS_BANK_DIRM_REG); } return 0; }
[ "static", "int", "gpio_xlnx_ps_pin_configure", "(", "const", "struct", "device", "*", "dev", ",", "gpio_pin_t", "pin", ",", "gpio_flags_t", "flags", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "pin_mask", "=", "BIT", "(", "pin", ")", ";", "uint32_t", "bank_data", ";", "uint32_t", "dirm_data", ";", "uint32_t", "oen_data", ";", "if", "(", "flags", "&", "(", "GPIO_PULL_UP", "|", "GPIO_PULL_DOWN", "|", "GPIO_SINGLE_ENDED", ")", ")", "{", "return", "-", "ENOTSUP", ";", "}", "dirm_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DIRM_REG", ")", ";", "oen_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_OEN_REG", ")", ";", "if", "(", "flags", "&", "GPIO_OUTPUT", ")", "{", "dirm_data", "|=", "pin_mask", ";", "oen_data", "|=", "pin_mask", ";", "sys_write32", "(", "dirm_data", ",", "GPIO_XLNX_PS_BANK_DIRM_REG", ")", ";", "bank_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "if", "(", "flags", "&", "GPIO_OUTPUT_INIT_HIGH", ")", "{", "bank_data", "|=", "pin_mask", ";", "}", "else", "if", "(", "flags", "&", "GPIO_OUTPUT_INIT_LOW", ")", "{", "bank_data", "&=", "~", "pin_mask", ";", "}", "sys_write32", "(", "bank_data", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "sys_write32", "(", "oen_data", ",", "GPIO_XLNX_PS_BANK_OEN_REG", ")", ";", "}", "else", "{", "dirm_data", "&=", "~", "pin_mask", ";", "oen_data", "&=", "~", "pin_mask", ";", "sys_write32", "(", "oen_data", ",", "GPIO_XLNX_PS_BANK_OEN_REG", ")", ";", "sys_write32", "(", "dirm_data", ",", "GPIO_XLNX_PS_BANK_DIRM_REG", ")", ";", "}", "return", "0", ";", "}" ]
@brief GPIO bank pin configuration function Configures an individual pin within a MIO / EMIO GPIO pin bank.
[ "@brief", "GPIO", "bank", "pin", "configuration", "function", "Configures", "an", "individual", "pin", "within", "a", "MIO", "/", "EMIO", "GPIO", "pin", "bank", "." ]
[ "/* Validity of the specified pin index is checked in drivers/gpio.h */", "/* Check for config flags not supported by the controller */", "/* Read the data direction & output enable registers */", "/*\n\t\t * Setting of an initial value (see below) requires the\n\t\t * direction register to be written *BEFORE* the data\n\t\t * register, otherwise, the value will not be applied!\n\t\t * The output enable bit can be set after the initial\n\t\t * value has been written.\n\t\t */", "/*\n\t\t * If the current pin is to be configured as an output\n\t\t * pin, it is up to the caller to specify whether the\n\t\t * output's initial value shall be high or low.\n\t\t * -> Write the initial output value into the data register.\n\t\t */", "/* Set the pin's output enable bit */", "/*\n\t\t * Disable the output first in case of an O -> I\n\t\t * transition, then change the pin's direction.\n\t\t */" ]
[ { "param": "dev", "type": "struct device" }, { "param": "pin", "type": "gpio_pin_t" }, { "param": "flags", "type": "gpio_flags_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pin", "type": "gpio_pin_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "gpio_flags_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_get
int
static int gpio_xlnx_ps_bank_get(const struct device *dev, gpio_port_value_t *value) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; *value = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
/** * @brief Reads the current bit mask of the entire GPIO pin bank. * * Reads the current bit mask of the entire bank from the * read-only data register. This includes the current values * of not just all input pins, but both the input and output * pins within the bank. * * @param dev Pointer to the GPIO bank's device. * @param value Pointer to a variable of type gpio_port_value_t * to which the current bit mask read from the bank's * RO data register will be written to. * * @retval 0 if the read operation completed successfully, * -EINVAL if the pointer to the output variable is NULL. */
@brief Reads the current bit mask of the entire GPIO pin bank. Reads the current bit mask of the entire bank from the read-only data register. This includes the current values of not just all input pins, but both the input and output pins within the bank. @param dev Pointer to the GPIO bank's device. @param value Pointer to a variable of type gpio_port_value_t to which the current bit mask read from the bank's RO data register will be written to. @retval 0 if the read operation completed successfully, -EINVAL if the pointer to the output variable is NULL.
[ "@brief", "Reads", "the", "current", "bit", "mask", "of", "the", "entire", "GPIO", "pin", "bank", ".", "Reads", "the", "current", "bit", "mask", "of", "the", "entire", "bank", "from", "the", "read", "-", "only", "data", "register", ".", "This", "includes", "the", "current", "values", "of", "not", "just", "all", "input", "pins", "but", "both", "the", "input", "and", "output", "pins", "within", "the", "bank", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "value", "Pointer", "to", "a", "variable", "of", "type", "gpio_port_value_t", "to", "which", "the", "current", "bit", "mask", "read", "from", "the", "bank", "'", "s", "RO", "data", "register", "will", "be", "written", "to", ".", "@retval", "0", "if", "the", "read", "operation", "completed", "successfully", "-", "EINVAL", "if", "the", "pointer", "to", "the", "output", "variable", "is", "NULL", "." ]
static int gpio_xlnx_ps_bank_get(const struct device *dev, gpio_port_value_t *value) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; *value = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_get", "(", "const", "struct", "device", "*", "dev", ",", "gpio_port_value_t", "*", "value", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "*", "value", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Reads the current bit mask of the entire GPIO pin bank.
[ "@brief", "Reads", "the", "current", "bit", "mask", "of", "the", "entire", "GPIO", "pin", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "value", "type": "gpio_port_value_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "gpio_port_value_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_set_masked
int
static int gpio_xlnx_ps_bank_set_masked(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data = (bank_data & ~mask) | (value & mask); sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
/** * @brief Masked write of a bit mask for the entire GPIO pin bank. * * Performs a masked write operation on the data register of * the current GPIO pin bank. The mask is applied twice: * first, it is applied to the current contents of the bank's * RO data register, clearing any bits that are zeroes in the * mask (will not have any effect on input pins). Second, it * is applied to the data word to be written into the current * bank's data register. The masked data word read from the * RO data register and the masked data word provided by the * caller ar then OR'ed and written to the bank's data register. * * @param dev Pointer to the GPIO bank's device. * @param mask Mask to be applied to both the current contents * of the data register and the data word provided * by the caller. * @param value Value to be written to the current bank's data * register. * * @retval Always 0. */
@brief Masked write of a bit mask for the entire GPIO pin bank. Performs a masked write operation on the data register of the current GPIO pin bank. The mask is applied twice: first, it is applied to the current contents of the bank's RO data register, clearing any bits that are zeroes in the mask (will not have any effect on input pins). Second, it is applied to the data word to be written into the current bank's data register. The masked data word read from the RO data register and the masked data word provided by the caller ar then OR'ed and written to the bank's data register. @param dev Pointer to the GPIO bank's device. @param mask Mask to be applied to both the current contents of the data register and the data word provided by the caller. @param value Value to be written to the current bank's data register. @retval Always 0.
[ "@brief", "Masked", "write", "of", "a", "bit", "mask", "for", "the", "entire", "GPIO", "pin", "bank", ".", "Performs", "a", "masked", "write", "operation", "on", "the", "data", "register", "of", "the", "current", "GPIO", "pin", "bank", ".", "The", "mask", "is", "applied", "twice", ":", "first", "it", "is", "applied", "to", "the", "current", "contents", "of", "the", "bank", "'", "s", "RO", "data", "register", "clearing", "any", "bits", "that", "are", "zeroes", "in", "the", "mask", "(", "will", "not", "have", "any", "effect", "on", "input", "pins", ")", ".", "Second", "it", "is", "applied", "to", "the", "data", "word", "to", "be", "written", "into", "the", "current", "bank", "'", "s", "data", "register", ".", "The", "masked", "data", "word", "read", "from", "the", "RO", "data", "register", "and", "the", "masked", "data", "word", "provided", "by", "the", "caller", "ar", "then", "OR", "'", "ed", "and", "written", "to", "the", "bank", "'", "s", "data", "register", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "mask", "Mask", "to", "be", "applied", "to", "both", "the", "current", "contents", "of", "the", "data", "register", "and", "the", "data", "word", "provided", "by", "the", "caller", ".", "@param", "value", "Value", "to", "be", "written", "to", "the", "current", "bank", "'", "s", "data", "register", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_bank_set_masked(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data = (bank_data & ~mask) | (value & mask); sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_set_masked", "(", "const", "struct", "device", "*", "dev", ",", "gpio_port_pins_t", "mask", ",", "gpio_port_value_t", "value", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "bank_data", ";", "bank_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "bank_data", "=", "(", "bank_data", "&", "~", "mask", ")", "|", "(", "value", "&", "mask", ")", ";", "sys_write32", "(", "bank_data", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Masked write of a bit mask for the entire GPIO pin bank.
[ "@brief", "Masked", "write", "of", "a", "bit", "mask", "for", "the", "entire", "GPIO", "pin", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "mask", "type": "gpio_port_pins_t" }, { "param": "value", "type": "gpio_port_value_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "gpio_port_pins_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "gpio_port_value_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_set_bits
int
static int gpio_xlnx_ps_bank_set_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data |= pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
/** * @brief Sets bits in the data register of the GPIO pin bank. * * Sets bits in the data register of the current GPIO pin bank * as a read-modify-write operation. All bits set in the bit * mask provided by the caller are OR'ed into the current data * word of the bank. This operation has no effect on the values * associated with pins configured as inputs. * * @param dev Pointer to the GPIO bank's device. * @param pins Bit mask specifying which bits shall be set in * the data word of the current GPIO pin bank. * * @retval Always 0. */
@brief Sets bits in the data register of the GPIO pin bank. Sets bits in the data register of the current GPIO pin bank as a read-modify-write operation. All bits set in the bit mask provided by the caller are OR'ed into the current data word of the bank. This operation has no effect on the values associated with pins configured as inputs. @param dev Pointer to the GPIO bank's device. @param pins Bit mask specifying which bits shall be set in the data word of the current GPIO pin bank. @retval Always 0.
[ "@brief", "Sets", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", ".", "Sets", "bits", "in", "the", "data", "register", "of", "the", "current", "GPIO", "pin", "bank", "as", "a", "read", "-", "modify", "-", "write", "operation", ".", "All", "bits", "set", "in", "the", "bit", "mask", "provided", "by", "the", "caller", "are", "OR", "'", "ed", "into", "the", "current", "data", "word", "of", "the", "bank", ".", "This", "operation", "has", "no", "effect", "on", "the", "values", "associated", "with", "pins", "configured", "as", "inputs", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "pins", "Bit", "mask", "specifying", "which", "bits", "shall", "be", "set", "in", "the", "data", "word", "of", "the", "current", "GPIO", "pin", "bank", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_bank_set_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data |= pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_set_bits", "(", "const", "struct", "device", "*", "dev", ",", "gpio_port_pins_t", "pins", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "bank_data", ";", "bank_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "bank_data", "|=", "pins", ";", "sys_write32", "(", "bank_data", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Sets bits in the data register of the GPIO pin bank.
[ "@brief", "Sets", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "pins", "type": "gpio_port_pins_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pins", "type": "gpio_port_pins_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_clear_bits
int
static int gpio_xlnx_ps_bank_clear_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data &= ~pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
/** * @brief Clears bits in the data register of the GPIO pin bank. * * Clears bits in the data register of the current GPIO pin bank * as a read-modify-write operation. All bits set in the bit * mask provided by the caller are NAND'ed into the current data * word of the bank. This operation has no effect on the values * associated with pins configured as inputs. * * @param dev Pointer to the GPIO bank's device. * @param pins Bit mask specifying which bits shall be cleared * in the data word of the current GPIO pin bank. * * @retval Always 0. */
@brief Clears bits in the data register of the GPIO pin bank. Clears bits in the data register of the current GPIO pin bank as a read-modify-write operation. All bits set in the bit mask provided by the caller are NAND'ed into the current data word of the bank. This operation has no effect on the values associated with pins configured as inputs. @param dev Pointer to the GPIO bank's device. @param pins Bit mask specifying which bits shall be cleared in the data word of the current GPIO pin bank. @retval Always 0.
[ "@brief", "Clears", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", ".", "Clears", "bits", "in", "the", "data", "register", "of", "the", "current", "GPIO", "pin", "bank", "as", "a", "read", "-", "modify", "-", "write", "operation", ".", "All", "bits", "set", "in", "the", "bit", "mask", "provided", "by", "the", "caller", "are", "NAND", "'", "ed", "into", "the", "current", "data", "word", "of", "the", "bank", ".", "This", "operation", "has", "no", "effect", "on", "the", "values", "associated", "with", "pins", "configured", "as", "inputs", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "pins", "Bit", "mask", "specifying", "which", "bits", "shall", "be", "cleared", "in", "the", "data", "word", "of", "the", "current", "GPIO", "pin", "bank", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_bank_clear_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data &= ~pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_clear_bits", "(", "const", "struct", "device", "*", "dev", ",", "gpio_port_pins_t", "pins", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "bank_data", ";", "bank_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "bank_data", "&=", "~", "pins", ";", "sys_write32", "(", "bank_data", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Clears bits in the data register of the GPIO pin bank.
[ "@brief", "Clears", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "pins", "type": "gpio_port_pins_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pins", "type": "gpio_port_pins_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_toggle_bits
int
static int gpio_xlnx_ps_bank_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data ^= pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
/** * @brief Toggles bits in the data register of the GPIO pin bank. * * Toggles bits in the data register of the current GPIO pin bank * as a read-modify-write operation. All bits set in the bit * mask provided by the caller are XOR'ed into the current data * word of the bank. This operation has no effect on the values * associated with pins configured as inputs. * * @param dev Pointer to the GPIO bank's device. * @param pins Bit mask specifying which bits shall be toggled * in the data word of the current GPIO pin bank. * * @retval Always 0. */
@brief Toggles bits in the data register of the GPIO pin bank. Toggles bits in the data register of the current GPIO pin bank as a read-modify-write operation. All bits set in the bit mask provided by the caller are XOR'ed into the current data word of the bank. This operation has no effect on the values associated with pins configured as inputs. @param dev Pointer to the GPIO bank's device. @param pins Bit mask specifying which bits shall be toggled in the data word of the current GPIO pin bank. @retval Always 0.
[ "@brief", "Toggles", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", ".", "Toggles", "bits", "in", "the", "data", "register", "of", "the", "current", "GPIO", "pin", "bank", "as", "a", "read", "-", "modify", "-", "write", "operation", ".", "All", "bits", "set", "in", "the", "bit", "mask", "provided", "by", "the", "caller", "are", "XOR", "'", "ed", "into", "the", "current", "data", "word", "of", "the", "bank", ".", "This", "operation", "has", "no", "effect", "on", "the", "values", "associated", "with", "pins", "configured", "as", "inputs", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "pins", "Bit", "mask", "specifying", "which", "bits", "shall", "be", "toggled", "in", "the", "data", "word", "of", "the", "current", "GPIO", "pin", "bank", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_bank_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t bank_data; bank_data = sys_read32(GPIO_XLNX_PS_BANK_DATA_REG); bank_data ^= pins; sys_write32(bank_data, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_toggle_bits", "(", "const", "struct", "device", "*", "dev", ",", "gpio_port_pins_t", "pins", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "bank_data", ";", "bank_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "bank_data", "^=", "pins", ";", "sys_write32", "(", "bank_data", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Toggles bits in the data register of the GPIO pin bank.
[ "@brief", "Toggles", "bits", "in", "the", "data", "register", "of", "the", "GPIO", "pin", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "pins", "type": "gpio_port_pins_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pins", "type": "gpio_port_pins_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_pin_irq_configure
int
static int gpio_xlnx_ps_bank_pin_irq_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t pin_mask = BIT(pin); uint32_t int_type_data; uint32_t int_polarity_data; uint32_t int_any_data; /* Validity of the specified pin index is checked in drivers/gpio.h */ /* Disable the specified pin's interrupt before (re-)configuring it */ sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_DIS_REG); int_type_data = sys_read32(GPIO_XLNX_PS_BANK_INT_TYPE_REG); int_polarity_data = sys_read32(GPIO_XLNX_PS_BANK_INT_POLARITY_REG); int_any_data = sys_read32(GPIO_XLNX_PS_BANK_INT_ANY_REG); if (mode != GPIO_INT_MODE_DISABLED) { if (mode == GPIO_INT_MODE_LEVEL) { int_type_data &= ~pin_mask; } else if (mode == GPIO_INT_MODE_EDGE) { int_type_data |= pin_mask; } else { return -EINVAL; } if (trig == GPIO_INT_TRIG_LOW) { int_any_data &= ~pin_mask; int_polarity_data &= ~pin_mask; } else if (trig == GPIO_INT_TRIG_HIGH) { int_any_data &= ~pin_mask; int_polarity_data |= pin_mask; } else if (trig == GPIO_INT_TRIG_BOTH) { if (mode == GPIO_INT_MODE_LEVEL) { return -EINVAL; } int_any_data |= pin_mask; } } else { /* mode == GPIO_INT_MODE_DISABLED */ int_any_data &= ~pin_mask; int_polarity_data &= ~pin_mask; int_type_data &= ~pin_mask; } sys_write32(int_any_data, GPIO_XLNX_PS_BANK_INT_ANY_REG); sys_write32(int_polarity_data, GPIO_XLNX_PS_BANK_INT_POLARITY_REG); sys_write32(int_type_data, GPIO_XLNX_PS_BANK_INT_TYPE_REG); if (mode != GPIO_INT_MODE_DISABLED) { /* Clear potential stale pending bit before enabling interrupt */ sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_STAT_REG); sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_EN_REG); } return 0; }
/** * @brief Configures the interrupt behaviour of a pin within the * current GPIO bank. * * Configures the interrupt behaviour of a pin within the current * GPIO bank. If a pin is to be configured to trigger an interrupt, * the following modes are supported: * * - edge or level triggered, * - rising edge / high level or falling edge / low level, * - in edge mode only: trigger on both rising and falling edge. * * @param dev Pointer to the GPIO bank's device. * @param pin Index of the pin within the bank to be configured * (decimal index of the pin). * @param mode Mode configuration: edge, level or interrupt disabled. * @param trig Trigger condition configuration: high/low level or * rising/falling/both edge(s). * * @retval 0 if the interrupt configuration completed successfully, * -EINVAL if the specified pin index is out of range, * -ENOTSUP if the interrupt configuration data contains an * invalid combination of configuration flags. */
@brief Configures the interrupt behaviour of a pin within the current GPIO bank. Configures the interrupt behaviour of a pin within the current GPIO bank. If a pin is to be configured to trigger an interrupt, the following modes are supported. - edge or level triggered, - rising edge / high level or falling edge / low level, - in edge mode only: trigger on both rising and falling edge. @param dev Pointer to the GPIO bank's device. @param pin Index of the pin within the bank to be configured (decimal index of the pin). @param mode Mode configuration: edge, level or interrupt disabled. @param trig Trigger condition configuration: high/low level or rising/falling/both edge(s). @retval 0 if the interrupt configuration completed successfully, -EINVAL if the specified pin index is out of range, -ENOTSUP if the interrupt configuration data contains an invalid combination of configuration flags.
[ "@brief", "Configures", "the", "interrupt", "behaviour", "of", "a", "pin", "within", "the", "current", "GPIO", "bank", ".", "Configures", "the", "interrupt", "behaviour", "of", "a", "pin", "within", "the", "current", "GPIO", "bank", ".", "If", "a", "pin", "is", "to", "be", "configured", "to", "trigger", "an", "interrupt", "the", "following", "modes", "are", "supported", ".", "-", "edge", "or", "level", "triggered", "-", "rising", "edge", "/", "high", "level", "or", "falling", "edge", "/", "low", "level", "-", "in", "edge", "mode", "only", ":", "trigger", "on", "both", "rising", "and", "falling", "edge", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "pin", "Index", "of", "the", "pin", "within", "the", "bank", "to", "be", "configured", "(", "decimal", "index", "of", "the", "pin", ")", ".", "@param", "mode", "Mode", "configuration", ":", "edge", "level", "or", "interrupt", "disabled", ".", "@param", "trig", "Trigger", "condition", "configuration", ":", "high", "/", "low", "level", "or", "rising", "/", "falling", "/", "both", "edge", "(", "s", ")", ".", "@retval", "0", "if", "the", "interrupt", "configuration", "completed", "successfully", "-", "EINVAL", "if", "the", "specified", "pin", "index", "is", "out", "of", "range", "-", "ENOTSUP", "if", "the", "interrupt", "configuration", "data", "contains", "an", "invalid", "combination", "of", "configuration", "flags", "." ]
static int gpio_xlnx_ps_bank_pin_irq_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t pin_mask = BIT(pin); uint32_t int_type_data; uint32_t int_polarity_data; uint32_t int_any_data; sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_DIS_REG); int_type_data = sys_read32(GPIO_XLNX_PS_BANK_INT_TYPE_REG); int_polarity_data = sys_read32(GPIO_XLNX_PS_BANK_INT_POLARITY_REG); int_any_data = sys_read32(GPIO_XLNX_PS_BANK_INT_ANY_REG); if (mode != GPIO_INT_MODE_DISABLED) { if (mode == GPIO_INT_MODE_LEVEL) { int_type_data &= ~pin_mask; } else if (mode == GPIO_INT_MODE_EDGE) { int_type_data |= pin_mask; } else { return -EINVAL; } if (trig == GPIO_INT_TRIG_LOW) { int_any_data &= ~pin_mask; int_polarity_data &= ~pin_mask; } else if (trig == GPIO_INT_TRIG_HIGH) { int_any_data &= ~pin_mask; int_polarity_data |= pin_mask; } else if (trig == GPIO_INT_TRIG_BOTH) { if (mode == GPIO_INT_MODE_LEVEL) { return -EINVAL; } int_any_data |= pin_mask; } } else { int_any_data &= ~pin_mask; int_polarity_data &= ~pin_mask; int_type_data &= ~pin_mask; } sys_write32(int_any_data, GPIO_XLNX_PS_BANK_INT_ANY_REG); sys_write32(int_polarity_data, GPIO_XLNX_PS_BANK_INT_POLARITY_REG); sys_write32(int_type_data, GPIO_XLNX_PS_BANK_INT_TYPE_REG); if (mode != GPIO_INT_MODE_DISABLED) { sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_STAT_REG); sys_write32(pin_mask, GPIO_XLNX_PS_BANK_INT_EN_REG); } return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_pin_irq_configure", "(", "const", "struct", "device", "*", "dev", ",", "gpio_pin_t", "pin", ",", "enum", "gpio_int_mode", "mode", ",", "enum", "gpio_int_trig", "trig", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "pin_mask", "=", "BIT", "(", "pin", ")", ";", "uint32_t", "int_type_data", ";", "uint32_t", "int_polarity_data", ";", "uint32_t", "int_any_data", ";", "sys_write32", "(", "pin_mask", ",", "GPIO_XLNX_PS_BANK_INT_DIS_REG", ")", ";", "int_type_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_INT_TYPE_REG", ")", ";", "int_polarity_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_INT_POLARITY_REG", ")", ";", "int_any_data", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_INT_ANY_REG", ")", ";", "if", "(", "mode", "!=", "GPIO_INT_MODE_DISABLED", ")", "{", "if", "(", "mode", "==", "GPIO_INT_MODE_LEVEL", ")", "{", "int_type_data", "&=", "~", "pin_mask", ";", "}", "else", "if", "(", "mode", "==", "GPIO_INT_MODE_EDGE", ")", "{", "int_type_data", "|=", "pin_mask", ";", "}", "else", "{", "return", "-", "EINVAL", ";", "}", "if", "(", "trig", "==", "GPIO_INT_TRIG_LOW", ")", "{", "int_any_data", "&=", "~", "pin_mask", ";", "int_polarity_data", "&=", "~", "pin_mask", ";", "}", "else", "if", "(", "trig", "==", "GPIO_INT_TRIG_HIGH", ")", "{", "int_any_data", "&=", "~", "pin_mask", ";", "int_polarity_data", "|=", "pin_mask", ";", "}", "else", "if", "(", "trig", "==", "GPIO_INT_TRIG_BOTH", ")", "{", "if", "(", "mode", "==", "GPIO_INT_MODE_LEVEL", ")", "{", "return", "-", "EINVAL", ";", "}", "int_any_data", "|=", "pin_mask", ";", "}", "}", "else", "{", "int_any_data", "&=", "~", "pin_mask", ";", "int_polarity_data", "&=", "~", "pin_mask", ";", "int_type_data", "&=", "~", "pin_mask", ";", "}", "sys_write32", "(", "int_any_data", ",", "GPIO_XLNX_PS_BANK_INT_ANY_REG", ")", ";", "sys_write32", "(", "int_polarity_data", ",", "GPIO_XLNX_PS_BANK_INT_POLARITY_REG", ")", ";", "sys_write32", "(", "int_type_data", ",", "GPIO_XLNX_PS_BANK_INT_TYPE_REG", ")", ";", "if", "(", "mode", "!=", "GPIO_INT_MODE_DISABLED", ")", "{", "sys_write32", "(", "pin_mask", ",", "GPIO_XLNX_PS_BANK_INT_STAT_REG", ")", ";", "sys_write32", "(", "pin_mask", ",", "GPIO_XLNX_PS_BANK_INT_EN_REG", ")", ";", "}", "return", "0", ";", "}" ]
@brief Configures the interrupt behaviour of a pin within the current GPIO bank.
[ "@brief", "Configures", "the", "interrupt", "behaviour", "of", "a", "pin", "within", "the", "current", "GPIO", "bank", "." ]
[ "/* Validity of the specified pin index is checked in drivers/gpio.h */", "/* Disable the specified pin's interrupt before (re-)configuring it */", "/* mode == GPIO_INT_MODE_DISABLED */", "/* Clear potential stale pending bit before enabling interrupt */" ]
[ { "param": "dev", "type": "struct device" }, { "param": "pin", "type": "gpio_pin_t" }, { "param": "mode", "type": "enum gpio_int_mode" }, { "param": "trig", "type": "enum gpio_int_trig" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pin", "type": "gpio_pin_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mode", "type": "enum gpio_int_mode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "trig", "type": "enum gpio_int_trig", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_get_int_status
uint32_t
static uint32_t gpio_xlnx_ps_bank_get_int_status(const struct device *dev) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t int_status; int_status = sys_read32(GPIO_XLNX_PS_BANK_INT_STAT_REG); if (int_status != 0) { sys_write32(int_status, GPIO_XLNX_PS_BANK_INT_STAT_REG); } return int_status; }
/** * @brief Returns the interrupt status of the current GPIO bank. * * Returns the interrupt status of the current GPIO bank, in the * form of a bit mask where each pin with a pending interrupt is * indicated. This information can either be used by the PM sub- * system or the parent controller device driver, which manages * the interrupt line of the entire PS GPIO controller, regardless * of how many bank sub-devices exist. As the current status is * read, it is automatically cleared. Callback triggering is handled * by the parent controller device. * * @param dev Pointer to the GPIO bank's device. * * @retval A bit mask indicating for which pins within the bank * an interrupt is pending. */
@brief Returns the interrupt status of the current GPIO bank. Returns the interrupt status of the current GPIO bank, in the form of a bit mask where each pin with a pending interrupt is indicated. This information can either be used by the PM sub system or the parent controller device driver, which manages the interrupt line of the entire PS GPIO controller, regardless of how many bank sub-devices exist. As the current status is read, it is automatically cleared. Callback triggering is handled by the parent controller device. @param dev Pointer to the GPIO bank's device. @retval A bit mask indicating for which pins within the bank an interrupt is pending.
[ "@brief", "Returns", "the", "interrupt", "status", "of", "the", "current", "GPIO", "bank", ".", "Returns", "the", "interrupt", "status", "of", "the", "current", "GPIO", "bank", "in", "the", "form", "of", "a", "bit", "mask", "where", "each", "pin", "with", "a", "pending", "interrupt", "is", "indicated", ".", "This", "information", "can", "either", "be", "used", "by", "the", "PM", "sub", "system", "or", "the", "parent", "controller", "device", "driver", "which", "manages", "the", "interrupt", "line", "of", "the", "entire", "PS", "GPIO", "controller", "regardless", "of", "how", "many", "bank", "sub", "-", "devices", "exist", ".", "As", "the", "current", "status", "is", "read", "it", "is", "automatically", "cleared", ".", "Callback", "triggering", "is", "handled", "by", "the", "parent", "controller", "device", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@retval", "A", "bit", "mask", "indicating", "for", "which", "pins", "within", "the", "bank", "an", "interrupt", "is", "pending", "." ]
static uint32_t gpio_xlnx_ps_bank_get_int_status(const struct device *dev) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; uint32_t int_status; int_status = sys_read32(GPIO_XLNX_PS_BANK_INT_STAT_REG); if (int_status != 0) { sys_write32(int_status, GPIO_XLNX_PS_BANK_INT_STAT_REG); } return int_status; }
[ "static", "uint32_t", "gpio_xlnx_ps_bank_get_int_status", "(", "const", "struct", "device", "*", "dev", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "uint32_t", "int_status", ";", "int_status", "=", "sys_read32", "(", "GPIO_XLNX_PS_BANK_INT_STAT_REG", ")", ";", "if", "(", "int_status", "!=", "0", ")", "{", "sys_write32", "(", "int_status", ",", "GPIO_XLNX_PS_BANK_INT_STAT_REG", ")", ";", "}", "return", "int_status", ";", "}" ]
@brief Returns the interrupt status of the current GPIO bank.
[ "@brief", "Returns", "the", "interrupt", "status", "of", "the", "current", "GPIO", "bank", "." ]
[]
[ { "param": "dev", "type": "struct device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_manage_callback
int
static int gpio_xlnx_ps_bank_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { struct gpio_xlnx_ps_bank_dev_data *dev_data = dev->data; return gpio_manage_callback(&dev_data->callbacks, callback, set); }
/** * @brief Callback management re-direction function. * * Re-directs any callback management calls relating to the current * GPIO bank to the GPIO sub-system. Comp. documentation of the * underlying sub-system's #gpio_manage_callback function. * * @param dev Pointer to the GPIO bank's device. * @param callback Pointer to a GPIO callback struct. * @param set Callback set flag. * * @retval A bit mask indicating for which pins within the bank * an interrupt is pending. */
@brief Callback management re-direction function. Re-directs any callback management calls relating to the current GPIO bank to the GPIO sub-system. Comp. documentation of the underlying sub-system's #gpio_manage_callback function. @param dev Pointer to the GPIO bank's device. @param callback Pointer to a GPIO callback struct. @param set Callback set flag. @retval A bit mask indicating for which pins within the bank an interrupt is pending.
[ "@brief", "Callback", "management", "re", "-", "direction", "function", ".", "Re", "-", "directs", "any", "callback", "management", "calls", "relating", "to", "the", "current", "GPIO", "bank", "to", "the", "GPIO", "sub", "-", "system", ".", "Comp", ".", "documentation", "of", "the", "underlying", "sub", "-", "system", "'", "s", "#gpio_manage_callback", "function", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@param", "callback", "Pointer", "to", "a", "GPIO", "callback", "struct", ".", "@param", "set", "Callback", "set", "flag", ".", "@retval", "A", "bit", "mask", "indicating", "for", "which", "pins", "within", "the", "bank", "an", "interrupt", "is", "pending", "." ]
static int gpio_xlnx_ps_bank_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { struct gpio_xlnx_ps_bank_dev_data *dev_data = dev->data; return gpio_manage_callback(&dev_data->callbacks, callback, set); }
[ "static", "int", "gpio_xlnx_ps_bank_manage_callback", "(", "const", "struct", "device", "*", "dev", ",", "struct", "gpio_callback", "*", "callback", ",", "bool", "set", ")", "{", "struct", "gpio_xlnx_ps_bank_dev_data", "*", "dev_data", "=", "dev", "->", "data", ";", "return", "gpio_manage_callback", "(", "&", "dev_data", "->", "callbacks", ",", "callback", ",", "set", ")", ";", "}" ]
@brief Callback management re-direction function.
[ "@brief", "Callback", "management", "re", "-", "direction", "function", "." ]
[]
[ { "param": "dev", "type": "struct device" }, { "param": "callback", "type": "struct gpio_callback" }, { "param": "set", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "struct gpio_callback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "set", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
baf1d97237f49bce851e0d78de1b69fd9dfcec8c
ParticleBeamHQ/zephyr
drivers/gpio/gpio_xlnx_ps_bank.c
[ "Apache-2.0" ]
C
gpio_xlnx_ps_bank_init
int
static int gpio_xlnx_ps_bank_init(const struct device *dev) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; sys_write32(~0x0, GPIO_XLNX_PS_BANK_INT_DIS_REG); /* Disable all interrupts */ sys_write32(~0x0, GPIO_XLNX_PS_BANK_INT_STAT_REG); /* Clear all interrupts */ sys_write32(0x0, GPIO_XLNX_PS_BANK_OEN_REG); /* All outputs disabled */ sys_write32(0x0, GPIO_XLNX_PS_BANK_DIRM_REG); /* All pins input */ sys_write32(0x0, GPIO_XLNX_PS_BANK_DATA_REG); /* Zero data register */ return 0; }
/** * @brief Initialize a MIO / EMIO GPIO bank sub-device * * Initialize a MIO / EMIO GPIO bank sub-device, which is a child * of the parent Xilinx PS GPIO controller device driver. This ini- * tialization function sets up a defined initial state for each * GPIO bank. * * @param dev Pointer to the GPIO bank's device. * * @retval Always 0. */
@brief Initialize a MIO / EMIO GPIO bank sub-device Initialize a MIO / EMIO GPIO bank sub-device, which is a child of the parent Xilinx PS GPIO controller device driver. This ini tialization function sets up a defined initial state for each GPIO bank. @param dev Pointer to the GPIO bank's device. @retval Always 0.
[ "@brief", "Initialize", "a", "MIO", "/", "EMIO", "GPIO", "bank", "sub", "-", "device", "Initialize", "a", "MIO", "/", "EMIO", "GPIO", "bank", "sub", "-", "device", "which", "is", "a", "child", "of", "the", "parent", "Xilinx", "PS", "GPIO", "controller", "device", "driver", ".", "This", "ini", "tialization", "function", "sets", "up", "a", "defined", "initial", "state", "for", "each", "GPIO", "bank", ".", "@param", "dev", "Pointer", "to", "the", "GPIO", "bank", "'", "s", "device", ".", "@retval", "Always", "0", "." ]
static int gpio_xlnx_ps_bank_init(const struct device *dev) { const struct gpio_xlnx_ps_bank_dev_cfg *dev_conf = dev->config; sys_write32(~0x0, GPIO_XLNX_PS_BANK_INT_DIS_REG); sys_write32(~0x0, GPIO_XLNX_PS_BANK_INT_STAT_REG); sys_write32(0x0, GPIO_XLNX_PS_BANK_OEN_REG); sys_write32(0x0, GPIO_XLNX_PS_BANK_DIRM_REG); sys_write32(0x0, GPIO_XLNX_PS_BANK_DATA_REG); return 0; }
[ "static", "int", "gpio_xlnx_ps_bank_init", "(", "const", "struct", "device", "*", "dev", ")", "{", "const", "struct", "gpio_xlnx_ps_bank_dev_cfg", "*", "dev_conf", "=", "dev", "->", "config", ";", "sys_write32", "(", "~", "0x0", ",", "GPIO_XLNX_PS_BANK_INT_DIS_REG", ")", ";", "sys_write32", "(", "~", "0x0", ",", "GPIO_XLNX_PS_BANK_INT_STAT_REG", ")", ";", "sys_write32", "(", "0x0", ",", "GPIO_XLNX_PS_BANK_OEN_REG", ")", ";", "sys_write32", "(", "0x0", ",", "GPIO_XLNX_PS_BANK_DIRM_REG", ")", ";", "sys_write32", "(", "0x0", ",", "GPIO_XLNX_PS_BANK_DATA_REG", ")", ";", "return", "0", ";", "}" ]
@brief Initialize a MIO / EMIO GPIO bank sub-device Initialize a MIO / EMIO GPIO bank sub-device, which is a child of the parent Xilinx PS GPIO controller device driver.
[ "@brief", "Initialize", "a", "MIO", "/", "EMIO", "GPIO", "bank", "sub", "-", "device", "Initialize", "a", "MIO", "/", "EMIO", "GPIO", "bank", "sub", "-", "device", "which", "is", "a", "child", "of", "the", "parent", "Xilinx", "PS", "GPIO", "controller", "device", "driver", "." ]
[ "/* Disable all interrupts */", "/* Clear all interrupts */", "/* All outputs disabled */", "/* All pins input */", "/* Zero data register */" ]
[ { "param": "dev", "type": "struct device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6a0f0f26a7b9876eb68ed4eb7221aac4e4f9ddbc
ParticleBeamHQ/zephyr
tests/drivers/can/stm32/src/main.c
[ "Apache-2.0" ]
C
assert_frame_equal
void
static inline void assert_frame_equal(const struct zcan_frame *frame1, const struct zcan_frame *frame2) { zassert_equal(frame1->id_type, frame2->id_type, "ID type does not match"); zassert_equal(frame1->rtr, frame2->rtr, "RTR bit does not match"); zassert_equal(frame1->id, frame2->id, "ID does not match"); zassert_equal(frame1->dlc, frame2->dlc, "DLC does not match"); zassert_mem_equal(frame1->data, frame2->data, frame1->dlc, "Received data differ"); }
/** * @brief Assert that two CAN frames are equal. * * @param frame1 First CAN frame. * @param frame2 Second CAN frame. */
@brief Assert that two CAN frames are equal. @param frame1 First CAN frame. @param frame2 Second CAN frame.
[ "@brief", "Assert", "that", "two", "CAN", "frames", "are", "equal", ".", "@param", "frame1", "First", "CAN", "frame", ".", "@param", "frame2", "Second", "CAN", "frame", "." ]
static inline void assert_frame_equal(const struct zcan_frame *frame1, const struct zcan_frame *frame2) { zassert_equal(frame1->id_type, frame2->id_type, "ID type does not match"); zassert_equal(frame1->rtr, frame2->rtr, "RTR bit does not match"); zassert_equal(frame1->id, frame2->id, "ID does not match"); zassert_equal(frame1->dlc, frame2->dlc, "DLC does not match"); zassert_mem_equal(frame1->data, frame2->data, frame1->dlc, "Received data differ"); }
[ "static", "inline", "void", "assert_frame_equal", "(", "const", "struct", "zcan_frame", "*", "frame1", ",", "const", "struct", "zcan_frame", "*", "frame2", ")", "{", "zassert_equal", "(", "frame1", "->", "id_type", ",", "frame2", "->", "id_type", ",", "\"", "\"", ")", ";", "zassert_equal", "(", "frame1", "->", "rtr", ",", "frame2", "->", "rtr", ",", "\"", "\"", ")", ";", "zassert_equal", "(", "frame1", "->", "id", ",", "frame2", "->", "id", ",", "\"", "\"", ")", ";", "zassert_equal", "(", "frame1", "->", "dlc", ",", "frame2", "->", "dlc", ",", "\"", "\"", ")", ";", "zassert_mem_equal", "(", "frame1", "->", "data", ",", "frame2", "->", "data", ",", "frame1", "->", "dlc", ",", "\"", "\"", ")", ";", "}" ]
@brief Assert that two CAN frames are equal.
[ "@brief", "Assert", "that", "two", "CAN", "frames", "are", "equal", "." ]
[]
[ { "param": "frame1", "type": "struct zcan_frame" }, { "param": "frame2", "type": "struct zcan_frame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "frame1", "type": "struct zcan_frame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "frame2", "type": "struct zcan_frame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4efca978e2cd449e2a91511f5eea4493a06af3c2
ParticleBeamHQ/zephyr
drivers/pcie/host/controller.c
[ "Apache-2.0" ]
C
pcie_bdf_bus_next
null
static inline unsigned int pcie_bdf_bus_next(unsigned int bdf, bool skip_next_func) { if (skip_next_func) { if (PCIE_BDF_TO_DEV(bdf) == PCIE_BDF_DEV_MASK) { return PCIE_BDF_NONE; } return PCIE_BDF(PCIE_BDF_TO_BUS(bdf), PCIE_BDF_TO_DEV(bdf) + 1, 0); } if (PCIE_BDF_TO_DEV(bdf) == PCIE_BDF_DEV_MASK && PCIE_BDF_TO_FUNC(bdf) == PCIE_BDF_FUNC_MASK) { return PCIE_BDF_NONE; } return PCIE_BDF(PCIE_BDF_TO_BUS(bdf), (PCIE_BDF_TO_DEV(bdf) + ((PCIE_BDF_TO_FUNC(bdf) + 1) / (PCIE_BDF_FUNC_MASK + 1))), ((PCIE_BDF_TO_FUNC(bdf) + 1) & PCIE_BDF_FUNC_MASK)); }
/* Return the next BDF or PCIE_BDF_NONE without changing bus number */
Return the next BDF or PCIE_BDF_NONE without changing bus number
[ "Return", "the", "next", "BDF", "or", "PCIE_BDF_NONE", "without", "changing", "bus", "number" ]
static inline unsigned int pcie_bdf_bus_next(unsigned int bdf, bool skip_next_func) { if (skip_next_func) { if (PCIE_BDF_TO_DEV(bdf) == PCIE_BDF_DEV_MASK) { return PCIE_BDF_NONE; } return PCIE_BDF(PCIE_BDF_TO_BUS(bdf), PCIE_BDF_TO_DEV(bdf) + 1, 0); } if (PCIE_BDF_TO_DEV(bdf) == PCIE_BDF_DEV_MASK && PCIE_BDF_TO_FUNC(bdf) == PCIE_BDF_FUNC_MASK) { return PCIE_BDF_NONE; } return PCIE_BDF(PCIE_BDF_TO_BUS(bdf), (PCIE_BDF_TO_DEV(bdf) + ((PCIE_BDF_TO_FUNC(bdf) + 1) / (PCIE_BDF_FUNC_MASK + 1))), ((PCIE_BDF_TO_FUNC(bdf) + 1) & PCIE_BDF_FUNC_MASK)); }
[ "static", "inline", "unsigned", "int", "pcie_bdf_bus_next", "(", "unsigned", "int", "bdf", ",", "bool", "skip_next_func", ")", "{", "if", "(", "skip_next_func", ")", "{", "if", "(", "PCIE_BDF_TO_DEV", "(", "bdf", ")", "==", "PCIE_BDF_DEV_MASK", ")", "{", "return", "PCIE_BDF_NONE", ";", "}", "return", "PCIE_BDF", "(", "PCIE_BDF_TO_BUS", "(", "bdf", ")", ",", "PCIE_BDF_TO_DEV", "(", "bdf", ")", "+", "1", ",", "0", ")", ";", "}", "if", "(", "PCIE_BDF_TO_DEV", "(", "bdf", ")", "==", "PCIE_BDF_DEV_MASK", "&&", "PCIE_BDF_TO_FUNC", "(", "bdf", ")", "==", "PCIE_BDF_FUNC_MASK", ")", "{", "return", "PCIE_BDF_NONE", ";", "}", "return", "PCIE_BDF", "(", "PCIE_BDF_TO_BUS", "(", "bdf", ")", ",", "(", "PCIE_BDF_TO_DEV", "(", "bdf", ")", "+", "(", "(", "PCIE_BDF_TO_FUNC", "(", "bdf", ")", "+", "1", ")", "/", "(", "PCIE_BDF_FUNC_MASK", "+", "1", ")", ")", ")", ",", "(", "(", "PCIE_BDF_TO_FUNC", "(", "bdf", ")", "+", "1", ")", "&", "PCIE_BDF_FUNC_MASK", ")", ")", ";", "}" ]
Return the next BDF or PCIE_BDF_NONE without changing bus number
[ "Return", "the", "next", "BDF", "or", "PCIE_BDF_NONE", "without", "changing", "bus", "number" ]
[]
[ { "param": "bdf", "type": "unsigned int" }, { "param": "skip_next_func", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bdf", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "skip_next_func", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4efca978e2cd449e2a91511f5eea4493a06af3c2
ParticleBeamHQ/zephyr
drivers/pcie/host/controller.c
[ "Apache-2.0" ]
C
pcie_generic_ctrl_enumerate
void
void pcie_generic_ctrl_enumerate(const struct device *ctrl_dev, pcie_bdf_t bdf_start) { struct pcie_bus_state stack[MAX_TRAVERSE_STACK], *state; unsigned int bus_number = PCIE_BDF_TO_BUS(bdf_start) + 1; bool skip_next_func = false; bool is_bridge = false; int stack_top = 0; /* Start with first endpoint of immediate Root Controller bus */ stack[stack_top].bus_bdf = PCIE_BDF(PCIE_BDF_TO_BUS(bdf_start), 0, 0); stack[stack_top].bridge_bdf = PCIE_BDF_NONE; stack[stack_top].next_bdf = bdf_start; while (stack_top >= 0) { /* Top of stack contains the current PCIe bus to traverse */ state = &stack[stack_top]; /* Finish current bridge configuration before scanning other endpoints */ if (state->bridge_bdf != PCIE_BDF_NONE) { pcie_generic_ctrl_post_enumerate_type1(ctrl_dev, state->bridge_bdf, bus_number); state->bridge_bdf = PCIE_BDF_NONE; } /* We still have more endpoints to scan */ if (state->next_bdf != PCIE_BDF_NONE) { while (state->next_bdf != PCIE_BDF_NONE) { is_bridge = pcie_generic_ctrl_enumerate_endpoint(ctrl_dev, state->next_bdf, bus_number, &skip_next_func); if (is_bridge) { state->bridge_bdf = state->next_bdf; state->next_bdf = pcie_bdf_bus_next(state->next_bdf, skip_next_func); /* If we can't handle more bridges, don't go further */ if (stack_top == (MAX_TRAVERSE_STACK - 1) || bus_number == PCIE_BDF_BUS_MASK) { break; } /* Push to stack to scan this bus */ stack_top++; stack[stack_top].bus_bdf = PCIE_BDF(bus_number, 0, 0); stack[stack_top].bridge_bdf = PCIE_BDF_NONE; stack[stack_top].next_bdf = PCIE_BDF(bus_number, 0, 0); /* Increase bus number */ bus_number++; break; } state->next_bdf = pcie_bdf_bus_next(state->next_bdf, skip_next_func); } } else { /* We finished scanning this bus, go back and scan next endpoints */ stack_top--; } } }
/* Non-recursive stack based PCIe bus & bridge enumeration */
Non-recursive stack based PCIe bus & bridge enumeration
[ "Non", "-", "recursive", "stack", "based", "PCIe", "bus", "&", "bridge", "enumeration" ]
void pcie_generic_ctrl_enumerate(const struct device *ctrl_dev, pcie_bdf_t bdf_start) { struct pcie_bus_state stack[MAX_TRAVERSE_STACK], *state; unsigned int bus_number = PCIE_BDF_TO_BUS(bdf_start) + 1; bool skip_next_func = false; bool is_bridge = false; int stack_top = 0; stack[stack_top].bus_bdf = PCIE_BDF(PCIE_BDF_TO_BUS(bdf_start), 0, 0); stack[stack_top].bridge_bdf = PCIE_BDF_NONE; stack[stack_top].next_bdf = bdf_start; while (stack_top >= 0) { state = &stack[stack_top]; if (state->bridge_bdf != PCIE_BDF_NONE) { pcie_generic_ctrl_post_enumerate_type1(ctrl_dev, state->bridge_bdf, bus_number); state->bridge_bdf = PCIE_BDF_NONE; } if (state->next_bdf != PCIE_BDF_NONE) { while (state->next_bdf != PCIE_BDF_NONE) { is_bridge = pcie_generic_ctrl_enumerate_endpoint(ctrl_dev, state->next_bdf, bus_number, &skip_next_func); if (is_bridge) { state->bridge_bdf = state->next_bdf; state->next_bdf = pcie_bdf_bus_next(state->next_bdf, skip_next_func); if (stack_top == (MAX_TRAVERSE_STACK - 1) || bus_number == PCIE_BDF_BUS_MASK) { break; } stack_top++; stack[stack_top].bus_bdf = PCIE_BDF(bus_number, 0, 0); stack[stack_top].bridge_bdf = PCIE_BDF_NONE; stack[stack_top].next_bdf = PCIE_BDF(bus_number, 0, 0); bus_number++; break; } state->next_bdf = pcie_bdf_bus_next(state->next_bdf, skip_next_func); } } else { stack_top--; } } }
[ "void", "pcie_generic_ctrl_enumerate", "(", "const", "struct", "device", "*", "ctrl_dev", ",", "pcie_bdf_t", "bdf_start", ")", "{", "struct", "pcie_bus_state", "stack", "[", "MAX_TRAVERSE_STACK", "]", ",", "*", "state", ";", "unsigned", "int", "bus_number", "=", "PCIE_BDF_TO_BUS", "(", "bdf_start", ")", "+", "1", ";", "bool", "skip_next_func", "=", "false", ";", "bool", "is_bridge", "=", "false", ";", "int", "stack_top", "=", "0", ";", "stack", "[", "stack_top", "]", ".", "bus_bdf", "=", "PCIE_BDF", "(", "PCIE_BDF_TO_BUS", "(", "bdf_start", ")", ",", "0", ",", "0", ")", ";", "stack", "[", "stack_top", "]", ".", "bridge_bdf", "=", "PCIE_BDF_NONE", ";", "stack", "[", "stack_top", "]", ".", "next_bdf", "=", "bdf_start", ";", "while", "(", "stack_top", ">=", "0", ")", "{", "state", "=", "&", "stack", "[", "stack_top", "]", ";", "if", "(", "state", "->", "bridge_bdf", "!=", "PCIE_BDF_NONE", ")", "{", "pcie_generic_ctrl_post_enumerate_type1", "(", "ctrl_dev", ",", "state", "->", "bridge_bdf", ",", "bus_number", ")", ";", "state", "->", "bridge_bdf", "=", "PCIE_BDF_NONE", ";", "}", "if", "(", "state", "->", "next_bdf", "!=", "PCIE_BDF_NONE", ")", "{", "while", "(", "state", "->", "next_bdf", "!=", "PCIE_BDF_NONE", ")", "{", "is_bridge", "=", "pcie_generic_ctrl_enumerate_endpoint", "(", "ctrl_dev", ",", "state", "->", "next_bdf", ",", "bus_number", ",", "&", "skip_next_func", ")", ";", "if", "(", "is_bridge", ")", "{", "state", "->", "bridge_bdf", "=", "state", "->", "next_bdf", ";", "state", "->", "next_bdf", "=", "pcie_bdf_bus_next", "(", "state", "->", "next_bdf", ",", "skip_next_func", ")", ";", "if", "(", "stack_top", "==", "(", "MAX_TRAVERSE_STACK", "-", "1", ")", "||", "bus_number", "==", "PCIE_BDF_BUS_MASK", ")", "{", "break", ";", "}", "stack_top", "++", ";", "stack", "[", "stack_top", "]", ".", "bus_bdf", "=", "PCIE_BDF", "(", "bus_number", ",", "0", ",", "0", ")", ";", "stack", "[", "stack_top", "]", ".", "bridge_bdf", "=", "PCIE_BDF_NONE", ";", "stack", "[", "stack_top", "]", ".", "next_bdf", "=", "PCIE_BDF", "(", "bus_number", ",", "0", ",", "0", ")", ";", "bus_number", "++", ";", "break", ";", "}", "state", "->", "next_bdf", "=", "pcie_bdf_bus_next", "(", "state", "->", "next_bdf", ",", "skip_next_func", ")", ";", "}", "}", "else", "{", "stack_top", "--", ";", "}", "}", "}" ]
Non-recursive stack based PCIe bus & bridge enumeration
[ "Non", "-", "recursive", "stack", "based", "PCIe", "bus", "&", "bridge", "enumeration" ]
[ "/* Start with first endpoint of immediate Root Controller bus */", "/* Top of stack contains the current PCIe bus to traverse */", "/* Finish current bridge configuration before scanning other endpoints */", "/* We still have more endpoints to scan */", "/* If we can't handle more bridges, don't go further */", "/* Push to stack to scan this bus */", "/* Increase bus number */", "/* We finished scanning this bus, go back and scan next endpoints */" ]
[ { "param": "ctrl_dev", "type": "struct device" }, { "param": "bdf_start", "type": "pcie_bdf_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctrl_dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bdf_start", "type": "pcie_bdf_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
16553ea68a67b7764b579b4c31ef5b785712d9fe
ParticleBeamHQ/zephyr
arch/arm64/core/prep_c.c
[ "Apache-2.0" ]
C
z_early_memset
void
void z_early_memset(void *dst, int c, size_t n) { uint8_t *d = dst; while (n--) { *d++ = c; } }
/* * These simple memset/memcpy alternatives are necessary as the optimized * ones depend on the MMU to be active (see commit c5b898743a20). */
These simple memset/memcpy alternatives are necessary as the optimized ones depend on the MMU to be active .
[ "These", "simple", "memset", "/", "memcpy", "alternatives", "are", "necessary", "as", "the", "optimized", "ones", "depend", "on", "the", "MMU", "to", "be", "active", "." ]
void z_early_memset(void *dst, int c, size_t n) { uint8_t *d = dst; while (n--) { *d++ = c; } }
[ "void", "z_early_memset", "(", "void", "*", "dst", ",", "int", "c", ",", "size_t", "n", ")", "{", "uint8_t", "*", "d", "=", "dst", ";", "while", "(", "n", "--", ")", "{", "*", "d", "++", "=", "c", ";", "}", "}" ]
These simple memset/memcpy alternatives are necessary as the optimized ones depend on the MMU to be active (see commit c5b898743a20).
[ "These", "simple", "memset", "/", "memcpy", "alternatives", "are", "necessary", "as", "the", "optimized", "ones", "depend", "on", "the", "MMU", "to", "be", "active", "(", "see", "commit", "c5b898743a20", ")", "." ]
[]
[ { "param": "dst", "type": "void" }, { "param": "c", "type": "int" }, { "param": "n", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "c", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
16553ea68a67b7764b579b4c31ef5b785712d9fe
ParticleBeamHQ/zephyr
arch/arm64/core/prep_c.c
[ "Apache-2.0" ]
C
z_arm64_prep_c
void
void z_arm64_prep_c(void) { /* Initialize tpidrro_el0 with our struct _cpu instance address */ write_tpidrro_el0((uintptr_t)&_kernel.cpus[0]); z_bss_zero(); z_data_copy(); z_arm64_mm_init(true); z_arm64_interrupt_init(); z_cstart(); CODE_UNREACHABLE; }
/** * * @brief Prepare to and run C code * * This routine prepares for the execution of and runs C code. * */
@brief Prepare to and run C code This routine prepares for the execution of and runs C code.
[ "@brief", "Prepare", "to", "and", "run", "C", "code", "This", "routine", "prepares", "for", "the", "execution", "of", "and", "runs", "C", "code", "." ]
void z_arm64_prep_c(void) { write_tpidrro_el0((uintptr_t)&_kernel.cpus[0]); z_bss_zero(); z_data_copy(); z_arm64_mm_init(true); z_arm64_interrupt_init(); z_cstart(); CODE_UNREACHABLE; }
[ "void", "z_arm64_prep_c", "(", "void", ")", "{", "write_tpidrro_el0", "(", "(", "uintptr_t", ")", "&", "_kernel", ".", "cpus", "[", "0", "]", ")", ";", "z_bss_zero", "(", ")", ";", "z_data_copy", "(", ")", ";", "z_arm64_mm_init", "(", "true", ")", ";", "z_arm64_interrupt_init", "(", ")", ";", "z_cstart", "(", ")", ";", "CODE_UNREACHABLE", ";", "}" ]
@brief Prepare to and run C code This routine prepares for the execution of and runs C code.
[ "@brief", "Prepare", "to", "and", "run", "C", "code", "This", "routine", "prepares", "for", "the", "execution", "of", "and", "runs", "C", "code", "." ]
[ "/* Initialize tpidrro_el0 with our struct _cpu instance address */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f711738dd597186e799afa389f168a8df2dde079
ParticleBeamHQ/zephyr
subsys/mgmt/mcumgr/smp_bt.c
[ "Apache-2.0" ]
C
conn_param_data_alloc
null
static struct conn_param_data *conn_param_data_alloc(struct bt_conn *conn) { for (size_t i = 0; i < ARRAY_SIZE(conn_data); i++) { if (conn_data[i].conn == NULL) { conn_data[i].conn = conn; return &conn_data[i]; } } /* Conn data must exists. */ __ASSERT_NO_MSG(false); return NULL; }
/* Helper function that allocates conn_param_data for a conn. */
Helper function that allocates conn_param_data for a conn.
[ "Helper", "function", "that", "allocates", "conn_param_data", "for", "a", "conn", "." ]
static struct conn_param_data *conn_param_data_alloc(struct bt_conn *conn) { for (size_t i = 0; i < ARRAY_SIZE(conn_data); i++) { if (conn_data[i].conn == NULL) { conn_data[i].conn = conn; return &conn_data[i]; } } __ASSERT_NO_MSG(false); return NULL; }
[ "static", "struct", "conn_param_data", "*", "conn_param_data_alloc", "(", "struct", "bt_conn", "*", "conn", ")", "{", "for", "(", "size_t", "i", "=", "0", ";", "i", "<", "ARRAY_SIZE", "(", "conn_data", ")", ";", "i", "++", ")", "{", "if", "(", "conn_data", "[", "i", "]", ".", "conn", "==", "NULL", ")", "{", "conn_data", "[", "i", "]", ".", "conn", "=", "conn", ";", "return", "&", "conn_data", "[", "i", "]", ";", "}", "}", "__ASSERT_NO_MSG", "(", "false", ")", ";", "return", "NULL", ";", "}" ]
Helper function that allocates conn_param_data for a conn.
[ "Helper", "function", "that", "allocates", "conn_param_data", "for", "a", "conn", "." ]
[ "/* Conn data must exists. */" ]
[ { "param": "conn", "type": "struct bt_conn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "struct bt_conn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f711738dd597186e799afa389f168a8df2dde079
ParticleBeamHQ/zephyr
subsys/mgmt/mcumgr/smp_bt.c
[ "Apache-2.0" ]
C
conn_param_data_get
null
static struct conn_param_data *conn_param_data_get(const struct bt_conn *conn) { for (size_t i = 0; i < ARRAY_SIZE(conn_data); i++) { if (conn_data[i].conn == conn) { return &conn_data[i]; } } /* Conn data must exists. */ __ASSERT_NO_MSG(false); return NULL; }
/* Helper function that returns conn_param_data associated with a conn. */
Helper function that returns conn_param_data associated with a conn.
[ "Helper", "function", "that", "returns", "conn_param_data", "associated", "with", "a", "conn", "." ]
static struct conn_param_data *conn_param_data_get(const struct bt_conn *conn) { for (size_t i = 0; i < ARRAY_SIZE(conn_data); i++) { if (conn_data[i].conn == conn) { return &conn_data[i]; } } __ASSERT_NO_MSG(false); return NULL; }
[ "static", "struct", "conn_param_data", "*", "conn_param_data_get", "(", "const", "struct", "bt_conn", "*", "conn", ")", "{", "for", "(", "size_t", "i", "=", "0", ";", "i", "<", "ARRAY_SIZE", "(", "conn_data", ")", ";", "i", "++", ")", "{", "if", "(", "conn_data", "[", "i", "]", ".", "conn", "==", "conn", ")", "{", "return", "&", "conn_data", "[", "i", "]", ";", "}", "}", "__ASSERT_NO_MSG", "(", "false", ")", ";", "return", "NULL", ";", "}" ]
Helper function that returns conn_param_data associated with a conn.
[ "Helper", "function", "that", "returns", "conn_param_data", "associated", "with", "a", "conn", "." ]
[ "/* Conn data must exists. */" ]
[ { "param": "conn", "type": "struct bt_conn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "struct bt_conn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f711738dd597186e799afa389f168a8df2dde079
ParticleBeamHQ/zephyr
subsys/mgmt/mcumgr/smp_bt.c
[ "Apache-2.0" ]
C
conn_param_set
void
static void conn_param_set(struct bt_conn *conn, struct bt_le_conn_param *param) { int ret = 0; struct conn_param_data *cpd = conn_param_data_get(conn); ret = bt_conn_le_param_update(conn, param); if (ret && (ret != -EALREADY)) { /* Try again to avoid being stuck with incorrect connection parameters. */ (void)k_work_reschedule(&cpd->ework, K_MSEC(RETRY_TIME)); } else { (void)k_work_cancel_delayable(&cpd->ework); } }
/* Sets connection parameters for a given conn. */
Sets connection parameters for a given conn.
[ "Sets", "connection", "parameters", "for", "a", "given", "conn", "." ]
static void conn_param_set(struct bt_conn *conn, struct bt_le_conn_param *param) { int ret = 0; struct conn_param_data *cpd = conn_param_data_get(conn); ret = bt_conn_le_param_update(conn, param); if (ret && (ret != -EALREADY)) { (void)k_work_reschedule(&cpd->ework, K_MSEC(RETRY_TIME)); } else { (void)k_work_cancel_delayable(&cpd->ework); } }
[ "static", "void", "conn_param_set", "(", "struct", "bt_conn", "*", "conn", ",", "struct", "bt_le_conn_param", "*", "param", ")", "{", "int", "ret", "=", "0", ";", "struct", "conn_param_data", "*", "cpd", "=", "conn_param_data_get", "(", "conn", ")", ";", "ret", "=", "bt_conn_le_param_update", "(", "conn", ",", "param", ")", ";", "if", "(", "ret", "&&", "(", "ret", "!=", "-", "EALREADY", ")", ")", "{", "(", "void", ")", "k_work_reschedule", "(", "&", "cpd", "->", "ework", ",", "K_MSEC", "(", "RETRY_TIME", ")", ")", ";", "}", "else", "{", "(", "void", ")", "k_work_cancel_delayable", "(", "&", "cpd", "->", "ework", ")", ";", "}", "}" ]
Sets connection parameters for a given conn.
[ "Sets", "connection", "parameters", "for", "a", "given", "conn", "." ]
[ "/* Try again to avoid being stuck with incorrect connection parameters. */" ]
[ { "param": "conn", "type": "struct bt_conn" }, { "param": "param", "type": "struct bt_le_conn_param" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "struct bt_conn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "param", "type": "struct bt_le_conn_param", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f711738dd597186e799afa389f168a8df2dde079
ParticleBeamHQ/zephyr
subsys/mgmt/mcumgr/smp_bt.c
[ "Apache-2.0" ]
C
smp_bt_chr_write
ssize_t
static ssize_t smp_bt_chr_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) { #ifdef CONFIG_MCUMGR_SMP_REASSEMBLY_BT int ret; bool started; started = (zephyr_smp_reassembly_expected(&smp_bt_transport) >= 0); LOG_DBG("started = %s, buf len = %d", started ? "true" : "false", len); LOG_HEXDUMP_DBG(buf, len, "buf = "); ret = zephyr_smp_reassembly_collect(&smp_bt_transport, buf, len); LOG_DBG("collect = %d", ret); /* * Collection can fail only due to failing to allocate memory or by receiving * more data than expected. */ if (ret == -ENOMEM) { /* Failed to collect the buffer */ return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } else if (ret < 0) { /* Failed operation on already allocated buffer, drop the packet and report * error. */ struct smp_bt_user_data *ud = (struct smp_bt_user_data *)zephyr_smp_reassembly_get_ud(&smp_bt_transport); if (ud != NULL) { bt_conn_unref(ud->conn); ud->conn = NULL; } zephyr_smp_reassembly_drop(&smp_bt_transport); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } if (!started) { /* * Transport context is attached to the buffer after first fragment * has been collected. */ struct smp_bt_user_data *ud = zephyr_smp_reassembly_get_ud(&smp_bt_transport); if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) { conn_param_smp_enable(conn); } ud->conn = bt_conn_ref(conn); } /* No more bytes are expected for this packet */ if (ret == 0) { zephyr_smp_reassembly_complete(&smp_bt_transport, false); } /* BT expects entire len to be consumed */ return len; #else struct smp_bt_user_data *ud; struct net_buf *nb; nb = mcumgr_buf_alloc(); if (!nb) { LOG_DBG("failed net_buf alloc for SMP packet"); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } if (net_buf_tailroom(nb) < len) { LOG_DBG("SMP packet len (%zu) > net_buf len (%zu)", len, net_buf_tailroom(nb)); mcumgr_buf_free(nb); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } net_buf_add_mem(nb, buf, len); ud = net_buf_user_data(nb); ud->conn = bt_conn_ref(conn); if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) { conn_param_smp_enable(conn); } zephyr_smp_rx_req(&smp_bt_transport, nb); return len; #endif }
/** * Write handler for the SMP characteristic; processes an incoming SMP request. */
Write handler for the SMP characteristic; processes an incoming SMP request.
[ "Write", "handler", "for", "the", "SMP", "characteristic", ";", "processes", "an", "incoming", "SMP", "request", "." ]
static ssize_t smp_bt_chr_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) { #ifdef CONFIG_MCUMGR_SMP_REASSEMBLY_BT int ret; bool started; started = (zephyr_smp_reassembly_expected(&smp_bt_transport) >= 0); LOG_DBG("started = %s, buf len = %d", started ? "true" : "false", len); LOG_HEXDUMP_DBG(buf, len, "buf = "); ret = zephyr_smp_reassembly_collect(&smp_bt_transport, buf, len); LOG_DBG("collect = %d", ret); if (ret == -ENOMEM) { return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } else if (ret < 0) { struct smp_bt_user_data *ud = (struct smp_bt_user_data *)zephyr_smp_reassembly_get_ud(&smp_bt_transport); if (ud != NULL) { bt_conn_unref(ud->conn); ud->conn = NULL; } zephyr_smp_reassembly_drop(&smp_bt_transport); return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } if (!started) { struct smp_bt_user_data *ud = zephyr_smp_reassembly_get_ud(&smp_bt_transport); if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) { conn_param_smp_enable(conn); } ud->conn = bt_conn_ref(conn); } if (ret == 0) { zephyr_smp_reassembly_complete(&smp_bt_transport, false); } return len; #else struct smp_bt_user_data *ud; struct net_buf *nb; nb = mcumgr_buf_alloc(); if (!nb) { LOG_DBG("failed net_buf alloc for SMP packet"); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } if (net_buf_tailroom(nb) < len) { LOG_DBG("SMP packet len (%zu) > net_buf len (%zu)", len, net_buf_tailroom(nb)); mcumgr_buf_free(nb); return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES); } net_buf_add_mem(nb, buf, len); ud = net_buf_user_data(nb); ud->conn = bt_conn_ref(conn); if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) { conn_param_smp_enable(conn); } zephyr_smp_rx_req(&smp_bt_transport, nb); return len; #endif }
[ "static", "ssize_t", "smp_bt_chr_write", "(", "struct", "bt_conn", "*", "conn", ",", "const", "struct", "bt_gatt_attr", "*", "attr", ",", "const", "void", "*", "buf", ",", "uint16_t", "len", ",", "uint16_t", "offset", ",", "uint8_t", "flags", ")", "{", "#ifdef", "CONFIG_MCUMGR_SMP_REASSEMBLY_BT", "int", "ret", ";", "bool", "started", ";", "started", "=", "(", "zephyr_smp_reassembly_expected", "(", "&", "smp_bt_transport", ")", ">=", "0", ")", ";", "LOG_DBG", "(", "\"", "\"", ",", "started", "?", "\"", "\"", ":", "\"", "\"", ",", "len", ")", ";", "LOG_HEXDUMP_DBG", "(", "buf", ",", "len", ",", "\"", "\"", ")", ";", "ret", "=", "zephyr_smp_reassembly_collect", "(", "&", "smp_bt_transport", ",", "buf", ",", "len", ")", ";", "LOG_DBG", "(", "\"", "\"", ",", "ret", ")", ";", "if", "(", "ret", "==", "-", "ENOMEM", ")", "{", "return", "BT_GATT_ERR", "(", "BT_ATT_ERR_INSUFFICIENT_RESOURCES", ")", ";", "}", "else", "if", "(", "ret", "<", "0", ")", "{", "struct", "smp_bt_user_data", "*", "ud", "=", "(", "struct", "smp_bt_user_data", "*", ")", "zephyr_smp_reassembly_get_ud", "(", "&", "smp_bt_transport", ")", ";", "if", "(", "ud", "!=", "NULL", ")", "{", "bt_conn_unref", "(", "ud", "->", "conn", ")", ";", "ud", "->", "conn", "=", "NULL", ";", "}", "zephyr_smp_reassembly_drop", "(", "&", "smp_bt_transport", ")", ";", "return", "BT_GATT_ERR", "(", "BT_ATT_ERR_VALUE_NOT_ALLOWED", ")", ";", "}", "if", "(", "!", "started", ")", "{", "struct", "smp_bt_user_data", "*", "ud", "=", "zephyr_smp_reassembly_get_ud", "(", "&", "smp_bt_transport", ")", ";", "if", "(", "IS_ENABLED", "(", "CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL", ")", ")", "{", "conn_param_smp_enable", "(", "conn", ")", ";", "}", "ud", "->", "conn", "=", "bt_conn_ref", "(", "conn", ")", ";", "}", "if", "(", "ret", "==", "0", ")", "{", "zephyr_smp_reassembly_complete", "(", "&", "smp_bt_transport", ",", "false", ")", ";", "}", "return", "len", ";", "#else", "struct", "smp_bt_user_data", "*", "ud", ";", "struct", "net_buf", "*", "nb", ";", "nb", "=", "mcumgr_buf_alloc", "(", ")", ";", "if", "(", "!", "nb", ")", "{", "LOG_DBG", "(", "\"", "\"", ")", ";", "return", "BT_GATT_ERR", "(", "BT_ATT_ERR_INSUFFICIENT_RESOURCES", ")", ";", "}", "if", "(", "net_buf_tailroom", "(", "nb", ")", "<", "len", ")", "{", "LOG_DBG", "(", "\"", "\"", ",", "len", ",", "net_buf_tailroom", "(", "nb", ")", ")", ";", "mcumgr_buf_free", "(", "nb", ")", ";", "return", "BT_GATT_ERR", "(", "BT_ATT_ERR_INSUFFICIENT_RESOURCES", ")", ";", "}", "net_buf_add_mem", "(", "nb", ",", "buf", ",", "len", ")", ";", "ud", "=", "net_buf_user_data", "(", "nb", ")", ";", "ud", "->", "conn", "=", "bt_conn_ref", "(", "conn", ")", ";", "if", "(", "IS_ENABLED", "(", "CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL", ")", ")", "{", "conn_param_smp_enable", "(", "conn", ")", ";", "}", "zephyr_smp_rx_req", "(", "&", "smp_bt_transport", ",", "nb", ")", ";", "return", "len", ";", "#endif", "}" ]
Write handler for the SMP characteristic; processes an incoming SMP request.
[ "Write", "handler", "for", "the", "SMP", "characteristic", ";", "processes", "an", "incoming", "SMP", "request", "." ]
[ "/*\n\t * Collection can fail only due to failing to allocate memory or by receiving\n\t * more data than expected.\n\t */", "/* Failed to collect the buffer */", "/* Failed operation on already allocated buffer, drop the packet and report\n\t\t * error.\n\t\t */", "/*\n\t\t * Transport context is attached to the buffer after first fragment\n\t\t * has been collected.\n\t\t */", "/* No more bytes are expected for this packet */", "/* BT expects entire len to be consumed */" ]
[ { "param": "conn", "type": "struct bt_conn" }, { "param": "attr", "type": "struct bt_gatt_attr" }, { "param": "buf", "type": "void" }, { "param": "len", "type": "uint16_t" }, { "param": "offset", "type": "uint16_t" }, { "param": "flags", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "struct bt_conn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "attr", "type": "struct bt_gatt_attr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2b3d0b7405b5912e33f7f1ee48ccb60853dd9e7c
ParticleBeamHQ/zephyr
soc/xtensa/intel_adsp/common/include/cavs_hda.h
[ "Apache-2.0" ]
C
cavs_hda_set_buffer
int
static inline int cavs_hda_set_buffer(uint32_t base, uint32_t sid, uint8_t *buf, uint32_t buf_size) { /* While we don't actually care if the pointer is in the cached * region or not, we do need a consistent address space to check * against for our assertion. This is cheap. */ uint32_t addr = (uint32_t)arch_xtensa_cached_ptr(buf); uint32_t aligned_addr = addr & HDA_ALIGN_MASK; uint32_t aligned_size = buf_size & HDA_ALIGN_MASK; __ASSERT(aligned_addr == addr, "Buffer must be 128 byte aligned"); __ASSERT(aligned_addr >= L2_SRAM_BASE && aligned_addr < L2_SRAM_BASE + L2_SRAM_SIZE, "Buffer must be in L2 address space"); __ASSERT(aligned_size == buf_size, "Buffer must be 128 byte aligned in size"); __ASSERT(aligned_addr + aligned_size < L2_SRAM_BASE + L2_SRAM_SIZE, "Buffer must end in L2 address space"); if (*DGCS(base, sid) & DGCS_GEN) { return -EBUSY; } if (*DGCS(base, sid) & DGCS_GBUSY) { return -EBUSY; } *DGBBA(base, sid) = aligned_addr; *DGBS(base, sid) = aligned_size; return 0; }
/** * @brief Set the buffer, size, and element size for an HDA stream * * Sanity checks that the buffer address and size are valid and that the * stream isn't enabled or busy. * * Prior to enabling an HDA stream to/from the host this is the minimum configuration * that is required. It must be set *after* the host has configured its own buffers. * * * @param hda Stream set to work with * @param sid Stream ID * @param buf Buffer address to use for the shared FIFO. Must be in L2 and 128 byte aligned. * @param buf_size Buffer size in bytes Must be 128 byte aligned * * @retval -EBUSY if the HDA stream is already enabled * @retval -EINVAL if the buf is not in L2, buf isn't aligned on 128 byte boundaries * @retval 0 on Success */
@brief Set the buffer, size, and element size for an HDA stream Sanity checks that the buffer address and size are valid and that the stream isn't enabled or busy. Prior to enabling an HDA stream to/from the host this is the minimum configuration that is required. It must be set *after* the host has configured its own buffers. @param hda Stream set to work with @param sid Stream ID @param buf Buffer address to use for the shared FIFO. Must be in L2 and 128 byte aligned. @param buf_size Buffer size in bytes Must be 128 byte aligned @retval -EBUSY if the HDA stream is already enabled @retval -EINVAL if the buf is not in L2, buf isn't aligned on 128 byte boundaries @retval 0 on Success
[ "@brief", "Set", "the", "buffer", "size", "and", "element", "size", "for", "an", "HDA", "stream", "Sanity", "checks", "that", "the", "buffer", "address", "and", "size", "are", "valid", "and", "that", "the", "stream", "isn", "'", "t", "enabled", "or", "busy", ".", "Prior", "to", "enabling", "an", "HDA", "stream", "to", "/", "from", "the", "host", "this", "is", "the", "minimum", "configuration", "that", "is", "required", ".", "It", "must", "be", "set", "*", "after", "*", "the", "host", "has", "configured", "its", "own", "buffers", ".", "@param", "hda", "Stream", "set", "to", "work", "with", "@param", "sid", "Stream", "ID", "@param", "buf", "Buffer", "address", "to", "use", "for", "the", "shared", "FIFO", ".", "Must", "be", "in", "L2", "and", "128", "byte", "aligned", ".", "@param", "buf_size", "Buffer", "size", "in", "bytes", "Must", "be", "128", "byte", "aligned", "@retval", "-", "EBUSY", "if", "the", "HDA", "stream", "is", "already", "enabled", "@retval", "-", "EINVAL", "if", "the", "buf", "is", "not", "in", "L2", "buf", "isn", "'", "t", "aligned", "on", "128", "byte", "boundaries", "@retval", "0", "on", "Success" ]
static inline int cavs_hda_set_buffer(uint32_t base, uint32_t sid, uint8_t *buf, uint32_t buf_size) { uint32_t addr = (uint32_t)arch_xtensa_cached_ptr(buf); uint32_t aligned_addr = addr & HDA_ALIGN_MASK; uint32_t aligned_size = buf_size & HDA_ALIGN_MASK; __ASSERT(aligned_addr == addr, "Buffer must be 128 byte aligned"); __ASSERT(aligned_addr >= L2_SRAM_BASE && aligned_addr < L2_SRAM_BASE + L2_SRAM_SIZE, "Buffer must be in L2 address space"); __ASSERT(aligned_size == buf_size, "Buffer must be 128 byte aligned in size"); __ASSERT(aligned_addr + aligned_size < L2_SRAM_BASE + L2_SRAM_SIZE, "Buffer must end in L2 address space"); if (*DGCS(base, sid) & DGCS_GEN) { return -EBUSY; } if (*DGCS(base, sid) & DGCS_GBUSY) { return -EBUSY; } *DGBBA(base, sid) = aligned_addr; *DGBS(base, sid) = aligned_size; return 0; }
[ "static", "inline", "int", "cavs_hda_set_buffer", "(", "uint32_t", "base", ",", "uint32_t", "sid", ",", "uint8_t", "*", "buf", ",", "uint32_t", "buf_size", ")", "{", "uint32_t", "addr", "=", "(", "uint32_t", ")", "arch_xtensa_cached_ptr", "(", "buf", ")", ";", "uint32_t", "aligned_addr", "=", "addr", "&", "HDA_ALIGN_MASK", ";", "uint32_t", "aligned_size", "=", "buf_size", "&", "HDA_ALIGN_MASK", ";", "__ASSERT", "(", "aligned_addr", "==", "addr", ",", "\"", "\"", ")", ";", "__ASSERT", "(", "aligned_addr", ">=", "L2_SRAM_BASE", "&&", "aligned_addr", "<", "L2_SRAM_BASE", "+", "L2_SRAM_SIZE", ",", "\"", "\"", ")", ";", "__ASSERT", "(", "aligned_size", "==", "buf_size", ",", "\"", "\"", ")", ";", "__ASSERT", "(", "aligned_addr", "+", "aligned_size", "<", "L2_SRAM_BASE", "+", "L2_SRAM_SIZE", ",", "\"", "\"", ")", ";", "if", "(", "*", "DGCS", "(", "base", ",", "sid", ")", "&", "DGCS_GEN", ")", "{", "return", "-", "EBUSY", ";", "}", "if", "(", "*", "DGCS", "(", "base", ",", "sid", ")", "&", "DGCS_GBUSY", ")", "{", "return", "-", "EBUSY", ";", "}", "*", "DGBBA", "(", "base", ",", "sid", ")", "=", "aligned_addr", ";", "*", "DGBS", "(", "base", ",", "sid", ")", "=", "aligned_size", ";", "return", "0", ";", "}" ]
@brief Set the buffer, size, and element size for an HDA stream Sanity checks that the buffer address and size are valid and that the stream isn't enabled or busy.
[ "@brief", "Set", "the", "buffer", "size", "and", "element", "size", "for", "an", "HDA", "stream", "Sanity", "checks", "that", "the", "buffer", "address", "and", "size", "are", "valid", "and", "that", "the", "stream", "isn", "'", "t", "enabled", "or", "busy", "." ]
[ "/* While we don't actually care if the pointer is in the cached\n\t * region or not, we do need a consistent address space to check\n\t * against for our assertion. This is cheap.\n\t */" ]
[ { "param": "base", "type": "uint32_t" }, { "param": "sid", "type": "uint32_t" }, { "param": "buf", "type": "uint8_t" }, { "param": "buf_size", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sid", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf_size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2b3d0b7405b5912e33f7f1ee48ccb60853dd9e7c
ParticleBeamHQ/zephyr
soc/xtensa/intel_adsp/common/include/cavs_hda.h
[ "Apache-2.0" ]
C
cavs_hda_unused
uint32_t
static inline uint32_t cavs_hda_unused(uint32_t base, uint32_t sid) { uint32_t dgcs = *DGCS(base, sid); uint32_t dgbs = *DGBS(base, sid); /* Check if buffer is empty */ if ((dgcs & DGCS_BNE) == 0) { return dgbs; } /* Check if the buffer is full */ if (dgcs & DGCS_BF) { return 0; } int32_t rp = *DGBRP(base, sid); int32_t wp = *DGBWP(base, sid); int32_t size = rp - wp; if (size <= 0) { size += dgbs; } return size; }
/** * @brief Determine the number of unused bytes in the buffer * * This is useful primarily for a host in (dsp -> host) stream. * * @param base Base address of the IP register block * @param sid Stream ID within the register block * * @retval n Number of unused bytes */
@brief Determine the number of unused bytes in the buffer This is useful primarily for a host in (dsp -> host) stream. @param base Base address of the IP register block @param sid Stream ID within the register block @retval n Number of unused bytes
[ "@brief", "Determine", "the", "number", "of", "unused", "bytes", "in", "the", "buffer", "This", "is", "useful", "primarily", "for", "a", "host", "in", "(", "dsp", "-", ">", "host", ")", "stream", ".", "@param", "base", "Base", "address", "of", "the", "IP", "register", "block", "@param", "sid", "Stream", "ID", "within", "the", "register", "block", "@retval", "n", "Number", "of", "unused", "bytes" ]
static inline uint32_t cavs_hda_unused(uint32_t base, uint32_t sid) { uint32_t dgcs = *DGCS(base, sid); uint32_t dgbs = *DGBS(base, sid); if ((dgcs & DGCS_BNE) == 0) { return dgbs; } if (dgcs & DGCS_BF) { return 0; } int32_t rp = *DGBRP(base, sid); int32_t wp = *DGBWP(base, sid); int32_t size = rp - wp; if (size <= 0) { size += dgbs; } return size; }
[ "static", "inline", "uint32_t", "cavs_hda_unused", "(", "uint32_t", "base", ",", "uint32_t", "sid", ")", "{", "uint32_t", "dgcs", "=", "*", "DGCS", "(", "base", ",", "sid", ")", ";", "uint32_t", "dgbs", "=", "*", "DGBS", "(", "base", ",", "sid", ")", ";", "if", "(", "(", "dgcs", "&", "DGCS_BNE", ")", "==", "0", ")", "{", "return", "dgbs", ";", "}", "if", "(", "dgcs", "&", "DGCS_BF", ")", "{", "return", "0", ";", "}", "int32_t", "rp", "=", "*", "DGBRP", "(", "base", ",", "sid", ")", ";", "int32_t", "wp", "=", "*", "DGBWP", "(", "base", ",", "sid", ")", ";", "int32_t", "size", "=", "rp", "-", "wp", ";", "if", "(", "size", "<=", "0", ")", "{", "size", "+=", "dgbs", ";", "}", "return", "size", ";", "}" ]
@brief Determine the number of unused bytes in the buffer This is useful primarily for a host in (dsp -> host) stream.
[ "@brief", "Determine", "the", "number", "of", "unused", "bytes", "in", "the", "buffer", "This", "is", "useful", "primarily", "for", "a", "host", "in", "(", "dsp", "-", ">", "host", ")", "stream", "." ]
[ "/* Check if buffer is empty */", "/* Check if the buffer is full */" ]
[ { "param": "base", "type": "uint32_t" }, { "param": "sid", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sid", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2b3d0b7405b5912e33f7f1ee48ccb60853dd9e7c
ParticleBeamHQ/zephyr
soc/xtensa/intel_adsp/common/include/cavs_hda.h
[ "Apache-2.0" ]
C
cavs_hda_host_commit
void
static inline void cavs_hda_host_commit(uint32_t base, uint32_t sid, uint32_t len) { *DGBFPI(base, sid) = len; *DGLLPI(base, sid) = len; *DGLPIBI(base, sid) = len; }
/** * @brief Commit a number of bytes that have been transferred to/from host * * Writes the length to BFPI. For host transfers LLPI and LPIB are * also written to with the given length. * * This then updates the read or write position depending on the direction. * * LPIBI writes here can be seen on the host side of the transfer in the * matching LPIB register. * * LLPI seems to, from behavior, inform the hardware to actually read/write * from the buffer. Without updating BFPI AND LLPI, the transfer doesn't * happen in testing for host transfers. * * @param base Base address of the IP register block * @param sid Stream ID within the register block * @param len Len to increment postion by */
@brief Commit a number of bytes that have been transferred to/from host Writes the length to BFPI. For host transfers LLPI and LPIB are also written to with the given length. This then updates the read or write position depending on the direction. LPIBI writes here can be seen on the host side of the transfer in the matching LPIB register. LLPI seems to, from behavior, inform the hardware to actually read/write from the buffer. Without updating BFPI AND LLPI, the transfer doesn't happen in testing for host transfers. @param base Base address of the IP register block @param sid Stream ID within the register block @param len Len to increment postion by
[ "@brief", "Commit", "a", "number", "of", "bytes", "that", "have", "been", "transferred", "to", "/", "from", "host", "Writes", "the", "length", "to", "BFPI", ".", "For", "host", "transfers", "LLPI", "and", "LPIB", "are", "also", "written", "to", "with", "the", "given", "length", ".", "This", "then", "updates", "the", "read", "or", "write", "position", "depending", "on", "the", "direction", ".", "LPIBI", "writes", "here", "can", "be", "seen", "on", "the", "host", "side", "of", "the", "transfer", "in", "the", "matching", "LPIB", "register", ".", "LLPI", "seems", "to", "from", "behavior", "inform", "the", "hardware", "to", "actually", "read", "/", "write", "from", "the", "buffer", ".", "Without", "updating", "BFPI", "AND", "LLPI", "the", "transfer", "doesn", "'", "t", "happen", "in", "testing", "for", "host", "transfers", ".", "@param", "base", "Base", "address", "of", "the", "IP", "register", "block", "@param", "sid", "Stream", "ID", "within", "the", "register", "block", "@param", "len", "Len", "to", "increment", "postion", "by" ]
static inline void cavs_hda_host_commit(uint32_t base, uint32_t sid, uint32_t len) { *DGBFPI(base, sid) = len; *DGLLPI(base, sid) = len; *DGLPIBI(base, sid) = len; }
[ "static", "inline", "void", "cavs_hda_host_commit", "(", "uint32_t", "base", ",", "uint32_t", "sid", ",", "uint32_t", "len", ")", "{", "*", "DGBFPI", "(", "base", ",", "sid", ")", "=", "len", ";", "*", "DGLLPI", "(", "base", ",", "sid", ")", "=", "len", ";", "*", "DGLPIBI", "(", "base", ",", "sid", ")", "=", "len", ";", "}" ]
@brief Commit a number of bytes that have been transferred to/from host Writes the length to BFPI.
[ "@brief", "Commit", "a", "number", "of", "bytes", "that", "have", "been", "transferred", "to", "/", "from", "host", "Writes", "the", "length", "to", "BFPI", "." ]
[]
[ { "param": "base", "type": "uint32_t" }, { "param": "sid", "type": "uint32_t" }, { "param": "len", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sid", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b9c43f892f83c918b1812ef541338d7847c92c12
ParticleBeamHQ/zephyr
drivers/clock_control/nrf_clock_calibration.c
[ "Apache-2.0" ]
C
start_hw_cal
void
static void start_hw_cal(void) { nrfx_clock_calibration_start(); calib_skip_cnt = CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP; }
/* Start actual HW calibration assuming that HFCLK XTAL is on. */
Start actual HW calibration assuming that HFCLK XTAL is on.
[ "Start", "actual", "HW", "calibration", "assuming", "that", "HFCLK", "XTAL", "is", "on", "." ]
static void start_hw_cal(void) { nrfx_clock_calibration_start(); calib_skip_cnt = CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP; }
[ "static", "void", "start_hw_cal", "(", "void", ")", "{", "nrfx_clock_calibration_start", "(", ")", ";", "calib_skip_cnt", "=", "CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP", ";", "}" ]
Start actual HW calibration assuming that HFCLK XTAL is on.
[ "Start", "actual", "HW", "calibration", "assuming", "that", "HFCLK", "XTAL", "is", "on", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7885c8973b0e8f6950b6ffd1e02f18956ec5a3b2
ParticleBeamHQ/zephyr
subsys/mgmt/mcumgr/lib/cmd/fs_mgmt/src/fs_mgmt.c
[ "Apache-2.0" ]
C
fs_mgmt_file_rsp
bool
static bool fs_mgmt_file_rsp(zcbor_state_t *zse, int rc, uint64_t off) { bool ok; ok = zcbor_tstr_put_lit(zse, "rc") && zcbor_int32_put(zse, rc) && zcbor_tstr_put_lit(zse, "off") && zcbor_uint64_put(zse, off); return ok; }
/** * Encodes a file upload response. */
Encodes a file upload response.
[ "Encodes", "a", "file", "upload", "response", "." ]
static bool fs_mgmt_file_rsp(zcbor_state_t *zse, int rc, uint64_t off) { bool ok; ok = zcbor_tstr_put_lit(zse, "rc") && zcbor_int32_put(zse, rc) && zcbor_tstr_put_lit(zse, "off") && zcbor_uint64_put(zse, off); return ok; }
[ "static", "bool", "fs_mgmt_file_rsp", "(", "zcbor_state_t", "*", "zse", ",", "int", "rc", ",", "uint64_t", "off", ")", "{", "bool", "ok", ";", "ok", "=", "zcbor_tstr_put_lit", "(", "zse", ",", "\"", "\"", ")", "&&", "zcbor_int32_put", "(", "zse", ",", "rc", ")", "&&", "zcbor_tstr_put_lit", "(", "zse", ",", "\"", "\"", ")", "&&", "zcbor_uint64_put", "(", "zse", ",", "off", ")", ";", "return", "ok", ";", "}" ]
Encodes a file upload response.
[ "Encodes", "a", "file", "upload", "response", "." ]
[]
[ { "param": "zse", "type": "zcbor_state_t" }, { "param": "rc", "type": "int" }, { "param": "off", "type": "uint64_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "zse", "type": "zcbor_state_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "off", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eac47fe66b3e175c010076afab04808e89661221
ParticleBeamHQ/zephyr
soc/arm/microchip_mec/common/soc_i2c.c
[ "Apache-2.0" ]
C
soc_i2c_port_lines_get
int
int soc_i2c_port_lines_get(uint8_t port, uint32_t *lines) { struct gpio_regs *regs = MCHP_XEC_GPIO_REG_BASE; uint32_t idx_scl = 0; uint32_t idx_sda = 0; uint32_t pinval = 0; if (!(BIT(port) & MEC_I2C_PORT_MASK) || !lines) { return -EINVAL; } idx_scl = (uint32_t)mec_i2c_ports[port].scl_pin_no; idx_sda = (uint32_t)mec_i2c_ports[port].sda_pin_no; if ((idx_scl == 0xFF) || (idx_sda == 0xFF)) { return -EINVAL; } if (regs->CTRL[idx_scl] & BIT(MCHP_GPIO_CTRL_INPAD_VAL_POS)) { pinval |= BIT(SOC_I2C_SCL_POS); } if (regs->CTRL[idx_sda] & BIT(MCHP_GPIO_CTRL_INPAD_VAL_POS)) { pinval |= BIT(SOC_I2C_SDA_POS); } *lines = pinval; return 0; }
/* * Read pin states of specified I2C port. * We GPIO control register always active RO pad input bit. * lines b[0]=SCL pin state at pad, b[1]=SDA pin state at pad */
Read pin states of specified I2C port. We GPIO control register always active RO pad input bit. lines b[0]=SCL pin state at pad, b[1]=SDA pin state at pad
[ "Read", "pin", "states", "of", "specified", "I2C", "port", ".", "We", "GPIO", "control", "register", "always", "active", "RO", "pad", "input", "bit", ".", "lines", "b", "[", "0", "]", "=", "SCL", "pin", "state", "at", "pad", "b", "[", "1", "]", "=", "SDA", "pin", "state", "at", "pad" ]
int soc_i2c_port_lines_get(uint8_t port, uint32_t *lines) { struct gpio_regs *regs = MCHP_XEC_GPIO_REG_BASE; uint32_t idx_scl = 0; uint32_t idx_sda = 0; uint32_t pinval = 0; if (!(BIT(port) & MEC_I2C_PORT_MASK) || !lines) { return -EINVAL; } idx_scl = (uint32_t)mec_i2c_ports[port].scl_pin_no; idx_sda = (uint32_t)mec_i2c_ports[port].sda_pin_no; if ((idx_scl == 0xFF) || (idx_sda == 0xFF)) { return -EINVAL; } if (regs->CTRL[idx_scl] & BIT(MCHP_GPIO_CTRL_INPAD_VAL_POS)) { pinval |= BIT(SOC_I2C_SCL_POS); } if (regs->CTRL[idx_sda] & BIT(MCHP_GPIO_CTRL_INPAD_VAL_POS)) { pinval |= BIT(SOC_I2C_SDA_POS); } *lines = pinval; return 0; }
[ "int", "soc_i2c_port_lines_get", "(", "uint8_t", "port", ",", "uint32_t", "*", "lines", ")", "{", "struct", "gpio_regs", "*", "regs", "=", "MCHP_XEC_GPIO_REG_BASE", ";", "uint32_t", "idx_scl", "=", "0", ";", "uint32_t", "idx_sda", "=", "0", ";", "uint32_t", "pinval", "=", "0", ";", "if", "(", "!", "(", "BIT", "(", "port", ")", "&", "MEC_I2C_PORT_MASK", ")", "||", "!", "lines", ")", "{", "return", "-", "EINVAL", ";", "}", "idx_scl", "=", "(", "uint32_t", ")", "mec_i2c_ports", "[", "port", "]", ".", "scl_pin_no", ";", "idx_sda", "=", "(", "uint32_t", ")", "mec_i2c_ports", "[", "port", "]", ".", "sda_pin_no", ";", "if", "(", "(", "idx_scl", "==", "0xFF", ")", "||", "(", "idx_sda", "==", "0xFF", ")", ")", "{", "return", "-", "EINVAL", ";", "}", "if", "(", "regs", "->", "CTRL", "[", "idx_scl", "]", "&", "BIT", "(", "MCHP_GPIO_CTRL_INPAD_VAL_POS", ")", ")", "{", "pinval", "|=", "BIT", "(", "SOC_I2C_SCL_POS", ")", ";", "}", "if", "(", "regs", "->", "CTRL", "[", "idx_sda", "]", "&", "BIT", "(", "MCHP_GPIO_CTRL_INPAD_VAL_POS", ")", ")", "{", "pinval", "|=", "BIT", "(", "SOC_I2C_SDA_POS", ")", ";", "}", "*", "lines", "=", "pinval", ";", "return", "0", ";", "}" ]
Read pin states of specified I2C port.
[ "Read", "pin", "states", "of", "specified", "I2C", "port", "." ]
[]
[ { "param": "port", "type": "uint8_t" }, { "param": "lines", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "port", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lines", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
59601c3323a616a6ac735d86cba25a14d6ed9695
ParticleBeamHQ/zephyr
subsys/bluetooth/host/direction.c
[ "Apache-2.0" ]
C
hci_df_set_conn_cte_tx_param
int
static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn, const struct bt_df_conn_cte_tx_param *params) { struct bt_hci_rp_le_set_conn_cte_tx_params *rp; struct bt_hci_cmd_state_set state; struct net_buf *buf, *rsp; uint8_t num_ant_ids; int err; /* If AoD is not enabled, ant_ids are ignored by controller: * BT Core spec 5.2 Vol 4, Part E sec. 7.8.84. */ if (!valid_conn_cte_tx_params(params)) { return -EINVAL; } num_ant_ids = ((params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) ? params->num_ant_ids : 0); buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, sizeof(struct bt_hci_cp_le_set_conn_cte_tx_params) + num_ant_ids); if (!buf) { return -ENOBUFS; } prepare_conn_cte_tx_params_cmd(buf, conn, params); /* CTE transmission parameters must be set only once for connection lifetime, hence the * flag BT_CONN_CTE_TX_PARAMS_SET is always set to true and never set to false. */ bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_TX_PARAMS_SET, true); err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, buf, &rsp); if (err) { return err; } rp = (void *)rsp->data; if (conn->handle != sys_le16_to_cpu(rp->handle)) { err = -EIO; } net_buf_unref(rsp); return err; }
/** * @brief Function sets CTE parameters for connection object * * @param conn Connection object * @param params CTE transmission parameters. * * @return Zero in case of success, other value in case of failure. */
@brief Function sets CTE parameters for connection object @param conn Connection object @param params CTE transmission parameters. @return Zero in case of success, other value in case of failure.
[ "@brief", "Function", "sets", "CTE", "parameters", "for", "connection", "object", "@param", "conn", "Connection", "object", "@param", "params", "CTE", "transmission", "parameters", ".", "@return", "Zero", "in", "case", "of", "success", "other", "value", "in", "case", "of", "failure", "." ]
static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn, const struct bt_df_conn_cte_tx_param *params) { struct bt_hci_rp_le_set_conn_cte_tx_params *rp; struct bt_hci_cmd_state_set state; struct net_buf *buf, *rsp; uint8_t num_ant_ids; int err; if (!valid_conn_cte_tx_params(params)) { return -EINVAL; } num_ant_ids = ((params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) ? params->num_ant_ids : 0); buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, sizeof(struct bt_hci_cp_le_set_conn_cte_tx_params) + num_ant_ids); if (!buf) { return -ENOBUFS; } prepare_conn_cte_tx_params_cmd(buf, conn, params); bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_TX_PARAMS_SET, true); err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, buf, &rsp); if (err) { return err; } rp = (void *)rsp->data; if (conn->handle != sys_le16_to_cpu(rp->handle)) { err = -EIO; } net_buf_unref(rsp); return err; }
[ "static", "int", "hci_df_set_conn_cte_tx_param", "(", "struct", "bt_conn", "*", "conn", ",", "const", "struct", "bt_df_conn_cte_tx_param", "*", "params", ")", "{", "struct", "bt_hci_rp_le_set_conn_cte_tx_params", "*", "rp", ";", "struct", "bt_hci_cmd_state_set", "state", ";", "struct", "net_buf", "*", "buf", ",", "*", "rsp", ";", "uint8_t", "num_ant_ids", ";", "int", "err", ";", "if", "(", "!", "valid_conn_cte_tx_params", "(", "params", ")", ")", "{", "return", "-", "EINVAL", ";", "}", "num_ant_ids", "=", "(", "(", "params", "->", "cte_types", "&", "(", "BT_DF_CTE_TYPE_AOD_1US", "|", "BT_DF_CTE_TYPE_AOD_2US", ")", ")", "?", "params", "->", "num_ant_ids", ":", "0", ")", ";", "buf", "=", "bt_hci_cmd_create", "(", "BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS", ",", "sizeof", "(", "struct", "bt_hci_cp_le_set_conn_cte_tx_params", ")", "+", "num_ant_ids", ")", ";", "if", "(", "!", "buf", ")", "{", "return", "-", "ENOBUFS", ";", "}", "prepare_conn_cte_tx_params_cmd", "(", "buf", ",", "conn", ",", "params", ")", ";", "bt_hci_cmd_state_set_init", "(", "buf", ",", "&", "state", ",", "conn", "->", "flags", ",", "BT_CONN_CTE_TX_PARAMS_SET", ",", "true", ")", ";", "err", "=", "bt_hci_cmd_send_sync", "(", "BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS", ",", "buf", ",", "&", "rsp", ")", ";", "if", "(", "err", ")", "{", "return", "err", ";", "}", "rp", "=", "(", "void", "*", ")", "rsp", "->", "data", ";", "if", "(", "conn", "->", "handle", "!=", "sys_le16_to_cpu", "(", "rp", "->", "handle", ")", ")", "{", "err", "=", "-", "EIO", ";", "}", "net_buf_unref", "(", "rsp", ")", ";", "return", "err", ";", "}" ]
@brief Function sets CTE parameters for connection object @param conn Connection object @param params CTE transmission parameters.
[ "@brief", "Function", "sets", "CTE", "parameters", "for", "connection", "object", "@param", "conn", "Connection", "object", "@param", "params", "CTE", "transmission", "parameters", "." ]
[ "/* If AoD is not enabled, ant_ids are ignored by controller:\n\t * BT Core spec 5.2 Vol 4, Part E sec. 7.8.84.\n\t */", "/* CTE transmission parameters must be set only once for connection lifetime, hence the\n\t * flag BT_CONN_CTE_TX_PARAMS_SET is always set to true and never set to false.\n\t */" ]
[ { "param": "conn", "type": "struct bt_conn" }, { "param": "params", "type": "struct bt_df_conn_cte_tx_param" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "struct bt_conn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": "struct bt_df_conn_cte_tx_param", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f74764f077a47e9dea67671a985eb8af41232c39
ParticleBeamHQ/zephyr
subsys/testsuite/ztest/src/ztress.c
[ "Apache-2.0" ]
C
adjust_load
void
static void adjust_load(uint8_t ratio) { for (uint32_t i = 0; i < context_cnt; i++) { uint32_t new_ticks = ratio * (uint32_t)backoff[i].ticks / 16; backoff[i].ticks = MAX(4, new_ticks); } }
/* Ratio is 1/16, e.g using ratio 14 reduces all timeouts by multiplying it by 14/16. * 16 fraction is used to avoid dividing which may take more time on certain platforms. */
Ratio is 1/16, e.g using ratio 14 reduces all timeouts by multiplying it by 14/16. 16 fraction is used to avoid dividing which may take more time on certain platforms.
[ "Ratio", "is", "1", "/", "16", "e", ".", "g", "using", "ratio", "14", "reduces", "all", "timeouts", "by", "multiplying", "it", "by", "14", "/", "16", ".", "16", "fraction", "is", "used", "to", "avoid", "dividing", "which", "may", "take", "more", "time", "on", "certain", "platforms", "." ]
static void adjust_load(uint8_t ratio) { for (uint32_t i = 0; i < context_cnt; i++) { uint32_t new_ticks = ratio * (uint32_t)backoff[i].ticks / 16; backoff[i].ticks = MAX(4, new_ticks); } }
[ "static", "void", "adjust_load", "(", "uint8_t", "ratio", ")", "{", "for", "(", "uint32_t", "i", "=", "0", ";", "i", "<", "context_cnt", ";", "i", "++", ")", "{", "uint32_t", "new_ticks", "=", "ratio", "*", "(", "uint32_t", ")", "backoff", "[", "i", "]", ".", "ticks", "/", "16", ";", "backoff", "[", "i", "]", ".", "ticks", "=", "MAX", "(", "4", ",", "new_ticks", ")", ";", "}", "}" ]
Ratio is 1/16, e.g using ratio 14 reduces all timeouts by multiplying it by 14/16.
[ "Ratio", "is", "1", "/", "16", "e", ".", "g", "using", "ratio", "14", "reduces", "all", "timeouts", "by", "multiplying", "it", "by", "14", "/", "16", "." ]
[]
[ { "param": "ratio", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ratio", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
read_excess_bytes
void
static void read_excess_bytes(uint16_t size) { if (size > 0) { uint8_t buffer[size]; edtt_read((uint8_t *)buffer, size, EDTTT_BLOCK); LOG_ERR("command size wrong! (%u extra bytes removed)", size); } }
/** * @brief Clean out excess bytes from the input buffer */
@brief Clean out excess bytes from the input buffer
[ "@brief", "Clean", "out", "excess", "bytes", "from", "the", "input", "buffer" ]
static void read_excess_bytes(uint16_t size) { if (size > 0) { uint8_t buffer[size]; edtt_read((uint8_t *)buffer, size, EDTTT_BLOCK); LOG_ERR("command size wrong! (%u extra bytes removed)", size); } }
[ "static", "void", "read_excess_bytes", "(", "uint16_t", "size", ")", "{", "if", "(", "size", ">", "0", ")", "{", "uint8_t", "buffer", "[", "size", "]", ";", "edtt_read", "(", "(", "uint8_t", "*", ")", "buffer", ",", "size", ",", "EDTTT_BLOCK", ")", ";", "LOG_ERR", "(", "\"", "\"", ",", "size", ")", ";", "}", "}" ]
@brief Clean out excess bytes from the input buffer
[ "@brief", "Clean", "out", "excess", "bytes", "from", "the", "input", "buffer" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
error_response
void
static void error_response(int error) { uint16_t response = sys_cpu_to_le16(waiting_response); int le_error = sys_cpu_to_le32(error); uint16_t size = sys_cpu_to_le16(sizeof(le_error)); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)&le_error, sizeof(le_error), EDTTT_BLOCK); waiting_response = CMD_NOTHING; waiting_opcode = 0; }
/** * @brief Provide an error response when an HCI command send failed */
@brief Provide an error response when an HCI command send failed
[ "@brief", "Provide", "an", "error", "response", "when", "an", "HCI", "command", "send", "failed" ]
static void error_response(int error) { uint16_t response = sys_cpu_to_le16(waiting_response); int le_error = sys_cpu_to_le32(error); uint16_t size = sys_cpu_to_le16(sizeof(le_error)); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)&le_error, sizeof(le_error), EDTTT_BLOCK); waiting_response = CMD_NOTHING; waiting_opcode = 0; }
[ "static", "void", "error_response", "(", "int", "error", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "waiting_response", ")", ";", "int", "le_error", "=", "sys_cpu_to_le32", "(", "error", ")", ";", "uint16_t", "size", "=", "sys_cpu_to_le16", "(", "sizeof", "(", "le_error", ")", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "le_error", ",", "sizeof", "(", "le_error", ")", ",", "EDTTT_BLOCK", ")", ";", "waiting_response", "=", "CMD_NOTHING", ";", "waiting_opcode", "=", "0", ";", "}" ]
@brief Provide an error response when an HCI command send failed
[ "@brief", "Provide", "an", "error", "response", "when", "an", "HCI", "command", "send", "failed" ]
[]
[ { "param": "error", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "error", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
hci_cmd_create
null
static struct net_buf *hci_cmd_create(uint16_t opcode, uint8_t param_len) { struct bt_hci_cmd_hdr *hdr; struct net_buf *buf; buf = bt_buf_get_tx(BT_BUF_CMD, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); hdr->opcode = sys_cpu_to_le16(opcode); hdr->param_len = param_len; return buf; }
/** * @brief Allocate buffer for HCI command and fill in opCode for the command */
@brief Allocate buffer for HCI command and fill in opCode for the command
[ "@brief", "Allocate", "buffer", "for", "HCI", "command", "and", "fill", "in", "opCode", "for", "the", "command" ]
static struct net_buf *hci_cmd_create(uint16_t opcode, uint8_t param_len) { struct bt_hci_cmd_hdr *hdr; struct net_buf *buf; buf = bt_buf_get_tx(BT_BUF_CMD, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); hdr->opcode = sys_cpu_to_le16(opcode); hdr->param_len = param_len; return buf; }
[ "static", "struct", "net_buf", "*", "hci_cmd_create", "(", "uint16_t", "opcode", ",", "uint8_t", "param_len", ")", "{", "struct", "bt_hci_cmd_hdr", "*", "hdr", ";", "struct", "net_buf", "*", "buf", ";", "buf", "=", "bt_buf_get_tx", "(", "BT_BUF_CMD", ",", "K_FOREVER", ",", "NULL", ",", "0", ")", ";", "__ASSERT_NO_MSG", "(", "buf", ")", ";", "hdr", "=", "net_buf_add", "(", "buf", ",", "sizeof", "(", "*", "hdr", ")", ")", ";", "hdr", "->", "opcode", "=", "sys_cpu_to_le16", "(", "opcode", ")", ";", "hdr", "->", "param_len", "=", "param_len", ";", "return", "buf", ";", "}" ]
@brief Allocate buffer for HCI command and fill in opCode for the command
[ "@brief", "Allocate", "buffer", "for", "HCI", "command", "and", "fill", "in", "opCode", "for", "the", "command" ]
[]
[ { "param": "opcode", "type": "uint16_t" }, { "param": "param_len", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "opcode", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "param_len", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
acl_data_create
null
static struct net_buf *acl_data_create(struct bt_hci_acl_hdr *le_hdr) { struct net_buf *buf; struct bt_hci_acl_hdr *hdr; buf = bt_buf_get_tx(BT_BUF_ACL_OUT, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); *hdr = *le_hdr; return buf; }
/** * @brief Allocate buffer for ACL Data Package and fill in Header */
@brief Allocate buffer for ACL Data Package and fill in Header
[ "@brief", "Allocate", "buffer", "for", "ACL", "Data", "Package", "and", "fill", "in", "Header" ]
static struct net_buf *acl_data_create(struct bt_hci_acl_hdr *le_hdr) { struct net_buf *buf; struct bt_hci_acl_hdr *hdr; buf = bt_buf_get_tx(BT_BUF_ACL_OUT, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); *hdr = *le_hdr; return buf; }
[ "static", "struct", "net_buf", "*", "acl_data_create", "(", "struct", "bt_hci_acl_hdr", "*", "le_hdr", ")", "{", "struct", "net_buf", "*", "buf", ";", "struct", "bt_hci_acl_hdr", "*", "hdr", ";", "buf", "=", "bt_buf_get_tx", "(", "BT_BUF_ACL_OUT", ",", "K_FOREVER", ",", "NULL", ",", "0", ")", ";", "__ASSERT_NO_MSG", "(", "buf", ")", ";", "hdr", "=", "net_buf_add", "(", "buf", ",", "sizeof", "(", "*", "hdr", ")", ")", ";", "*", "hdr", "=", "*", "le_hdr", ";", "return", "buf", ";", "}" ]
@brief Allocate buffer for ACL Data Package and fill in Header
[ "@brief", "Allocate", "buffer", "for", "ACL", "Data", "Package", "and", "fill", "in", "Header" ]
[]
[ { "param": "le_hdr", "type": "struct bt_hci_acl_hdr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "le_hdr", "type": "struct bt_hci_acl_hdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
iso_data_create
null
static struct net_buf *iso_data_create(struct bt_hci_iso_hdr *le_hdr) { struct net_buf *buf; struct bt_hci_iso_hdr *hdr; buf = bt_buf_get_tx(BT_BUF_ISO_OUT, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); *hdr = *le_hdr; return buf; }
/** * @brief Allocate buffer for ISO Data Package and fill in Header */
@brief Allocate buffer for ISO Data Package and fill in Header
[ "@brief", "Allocate", "buffer", "for", "ISO", "Data", "Package", "and", "fill", "in", "Header" ]
static struct net_buf *iso_data_create(struct bt_hci_iso_hdr *le_hdr) { struct net_buf *buf; struct bt_hci_iso_hdr *hdr; buf = bt_buf_get_tx(BT_BUF_ISO_OUT, K_FOREVER, NULL, 0); __ASSERT_NO_MSG(buf); hdr = net_buf_add(buf, sizeof(*hdr)); *hdr = *le_hdr; return buf; }
[ "static", "struct", "net_buf", "*", "iso_data_create", "(", "struct", "bt_hci_iso_hdr", "*", "le_hdr", ")", "{", "struct", "net_buf", "*", "buf", ";", "struct", "bt_hci_iso_hdr", "*", "hdr", ";", "buf", "=", "bt_buf_get_tx", "(", "BT_BUF_ISO_OUT", ",", "K_FOREVER", ",", "NULL", ",", "0", ")", ";", "__ASSERT_NO_MSG", "(", "buf", ")", ";", "hdr", "=", "net_buf_add", "(", "buf", ",", "sizeof", "(", "*", "hdr", ")", ")", ";", "*", "hdr", "=", "*", "le_hdr", ";", "return", "buf", ";", "}" ]
@brief Allocate buffer for ISO Data Package and fill in Header
[ "@brief", "Allocate", "buffer", "for", "ISO", "Data", "Package", "and", "fill", "in", "Header" ]
[]
[ { "param": "le_hdr", "type": "struct bt_hci_iso_hdr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "le_hdr", "type": "struct bt_hci_iso_hdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
send_hci_command
int
static int send_hci_command(uint16_t opcode, uint8_t param_len, uint16_t response) { struct net_buf *buf; void *cp; int err = 0; waiting_response = response; buf = hci_cmd_create(waiting_opcode = opcode, param_len); if (buf) { if (param_len) { cp = net_buf_add(buf, param_len); edtt_read((uint8_t *)cp, param_len, EDTTT_BLOCK); } err = bt_send(buf); if (err) { LOG_ERR("Failed to send HCI command %d (err %d)", opcode, err); error_response(err); } } else { LOG_ERR("Failed to create buffer for HCI command 0x%04x", opcode); error_response(-1); } return err; }
/** * @brief Allocate buffer for HCI command, fill in parameters and send the * command... */
@brief Allocate buffer for HCI command, fill in parameters and send the command
[ "@brief", "Allocate", "buffer", "for", "HCI", "command", "fill", "in", "parameters", "and", "send", "the", "command" ]
static int send_hci_command(uint16_t opcode, uint8_t param_len, uint16_t response) { struct net_buf *buf; void *cp; int err = 0; waiting_response = response; buf = hci_cmd_create(waiting_opcode = opcode, param_len); if (buf) { if (param_len) { cp = net_buf_add(buf, param_len); edtt_read((uint8_t *)cp, param_len, EDTTT_BLOCK); } err = bt_send(buf); if (err) { LOG_ERR("Failed to send HCI command %d (err %d)", opcode, err); error_response(err); } } else { LOG_ERR("Failed to create buffer for HCI command 0x%04x", opcode); error_response(-1); } return err; }
[ "static", "int", "send_hci_command", "(", "uint16_t", "opcode", ",", "uint8_t", "param_len", ",", "uint16_t", "response", ")", "{", "struct", "net_buf", "*", "buf", ";", "void", "*", "cp", ";", "int", "err", "=", "0", ";", "waiting_response", "=", "response", ";", "buf", "=", "hci_cmd_create", "(", "waiting_opcode", "=", "opcode", ",", "param_len", ")", ";", "if", "(", "buf", ")", "{", "if", "(", "param_len", ")", "{", "cp", "=", "net_buf_add", "(", "buf", ",", "param_len", ")", ";", "edtt_read", "(", "(", "uint8_t", "*", ")", "cp", ",", "param_len", ",", "EDTTT_BLOCK", ")", ";", "}", "err", "=", "bt_send", "(", "buf", ")", ";", "if", "(", "err", ")", "{", "LOG_ERR", "(", "\"", "\"", ",", "opcode", ",", "err", ")", ";", "error_response", "(", "err", ")", ";", "}", "}", "else", "{", "LOG_ERR", "(", "\"", "\"", ",", "opcode", ")", ";", "error_response", "(", "-1", ")", ";", "}", "return", "err", ";", "}" ]
@brief Allocate buffer for HCI command, fill in parameters and send the command...
[ "@brief", "Allocate", "buffer", "for", "HCI", "command", "fill", "in", "parameters", "and", "send", "the", "command", "..." ]
[]
[ { "param": "opcode", "type": "uint16_t" }, { "param": "param_len", "type": "uint8_t" }, { "param": "response", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "opcode", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "param_len", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "response", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
echo
void
static void echo(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_ECHO_RSP); uint16_t le_size = sys_cpu_to_le16(size); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&le_size, sizeof(le_size), EDTTT_BLOCK); if (size > 0) { uint8_t buff[size]; edtt_read(buff, size, EDTTT_BLOCK); edtt_write(buff, size, EDTTT_BLOCK); } }
/** * @brief Echo function - echo input received... */
@brief Echo function - echo input received
[ "@brief", "Echo", "function", "-", "echo", "input", "received" ]
static void echo(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_ECHO_RSP); uint16_t le_size = sys_cpu_to_le16(size); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&le_size, sizeof(le_size), EDTTT_BLOCK); if (size > 0) { uint8_t buff[size]; edtt_read(buff, size, EDTTT_BLOCK); edtt_write(buff, size, EDTTT_BLOCK); } }
[ "static", "void", "echo", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_ECHO_RSP", ")", ";", "uint16_t", "le_size", "=", "sys_cpu_to_le16", "(", "size", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "le_size", ",", "sizeof", "(", "le_size", ")", ",", "EDTTT_BLOCK", ")", ";", "if", "(", "size", ">", "0", ")", "{", "uint8_t", "buff", "[", "size", "]", ";", "edtt_read", "(", "buff", ",", "size", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "buff", ",", "size", ",", "EDTTT_BLOCK", ")", ";", "}", "}" ]
@brief Echo function - echo input received...
[ "@brief", "Echo", "function", "-", "echo", "input", "received", "..." ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
command_complete
void
static void command_complete(struct net_buf *buf) { struct bt_hci_evt_cmd_complete *evt = (void *)buf->data; uint16_t opcode = sys_le16_to_cpu(evt->opcode); uint16_t response = sys_cpu_to_le16(waiting_response); struct net_buf_simple_state state; uint16_t size; net_buf_simple_save(&buf->b, &state); net_buf_pull(buf, sizeof(*evt)); size = sys_cpu_to_le16(buf->len); if (opcode == waiting_opcode) { LOG_DBG("Command complete for 0x%04x", waiting_opcode); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); waiting_opcode = 0; } else { LOG_WRN("Not waiting for 0x(%04x) command status," " expected 0x(%04x)", opcode, waiting_opcode); } net_buf_simple_restore(&buf->b, &state); }
/** * @brief Handle Command Complete HCI event... */
@brief Handle Command Complete HCI event
[ "@brief", "Handle", "Command", "Complete", "HCI", "event" ]
static void command_complete(struct net_buf *buf) { struct bt_hci_evt_cmd_complete *evt = (void *)buf->data; uint16_t opcode = sys_le16_to_cpu(evt->opcode); uint16_t response = sys_cpu_to_le16(waiting_response); struct net_buf_simple_state state; uint16_t size; net_buf_simple_save(&buf->b, &state); net_buf_pull(buf, sizeof(*evt)); size = sys_cpu_to_le16(buf->len); if (opcode == waiting_opcode) { LOG_DBG("Command complete for 0x%04x", waiting_opcode); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); waiting_opcode = 0; } else { LOG_WRN("Not waiting for 0x(%04x) command status," " expected 0x(%04x)", opcode, waiting_opcode); } net_buf_simple_restore(&buf->b, &state); }
[ "static", "void", "command_complete", "(", "struct", "net_buf", "*", "buf", ")", "{", "struct", "bt_hci_evt_cmd_complete", "*", "evt", "=", "(", "void", "*", ")", "buf", "->", "data", ";", "uint16_t", "opcode", "=", "sys_le16_to_cpu", "(", "evt", "->", "opcode", ")", ";", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "waiting_response", ")", ";", "struct", "net_buf_simple_state", "state", ";", "uint16_t", "size", ";", "net_buf_simple_save", "(", "&", "buf", "->", "b", ",", "&", "state", ")", ";", "net_buf_pull", "(", "buf", ",", "sizeof", "(", "*", "evt", ")", ")", ";", "size", "=", "sys_cpu_to_le16", "(", "buf", "->", "len", ")", ";", "if", "(", "opcode", "==", "waiting_opcode", ")", "{", "LOG_DBG", "(", "\"", "\"", ",", "waiting_opcode", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "buf", "->", "data", ",", "buf", "->", "len", ",", "EDTTT_BLOCK", ")", ";", "waiting_opcode", "=", "0", ";", "}", "else", "{", "LOG_WRN", "(", "\"", "\"", "\"", "\"", ",", "opcode", ",", "waiting_opcode", ")", ";", "}", "net_buf_simple_restore", "(", "&", "buf", "->", "b", ",", "&", "state", ")", ";", "}" ]
@brief Handle Command Complete HCI event...
[ "@brief", "Handle", "Command", "Complete", "HCI", "event", "..." ]
[]
[ { "param": "buf", "type": "struct net_buf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "struct net_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
command_status
void
static void command_status(struct net_buf *buf) { struct bt_hci_evt_cmd_status *evt = (void *)buf->data; uint16_t opcode = sys_le16_to_cpu(evt->opcode); uint16_t response = sys_cpu_to_le16(waiting_response); struct net_buf_simple_state state; uint8_t status = evt->status; uint16_t size; net_buf_simple_save(&buf->b, &state); net_buf_pull(buf, sizeof(*evt)); size = sys_cpu_to_le16(buf->len) + 1; if (opcode == waiting_opcode) { LOG_DBG("Command status for 0x%04x", waiting_opcode); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)&status, sizeof(status), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); waiting_opcode = 0; } else { LOG_WRN("Not waiting for 0x(%04x) command status," " expected 0x(%04x)", opcode, waiting_opcode); } net_buf_simple_restore(&buf->b, &state); }
/** * @brief Handle Command Status HCI event... */
@brief Handle Command Status HCI event
[ "@brief", "Handle", "Command", "Status", "HCI", "event" ]
static void command_status(struct net_buf *buf) { struct bt_hci_evt_cmd_status *evt = (void *)buf->data; uint16_t opcode = sys_le16_to_cpu(evt->opcode); uint16_t response = sys_cpu_to_le16(waiting_response); struct net_buf_simple_state state; uint8_t status = evt->status; uint16_t size; net_buf_simple_save(&buf->b, &state); net_buf_pull(buf, sizeof(*evt)); size = sys_cpu_to_le16(buf->len) + 1; if (opcode == waiting_opcode) { LOG_DBG("Command status for 0x%04x", waiting_opcode); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)&status, sizeof(status), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); waiting_opcode = 0; } else { LOG_WRN("Not waiting for 0x(%04x) command status," " expected 0x(%04x)", opcode, waiting_opcode); } net_buf_simple_restore(&buf->b, &state); }
[ "static", "void", "command_status", "(", "struct", "net_buf", "*", "buf", ")", "{", "struct", "bt_hci_evt_cmd_status", "*", "evt", "=", "(", "void", "*", ")", "buf", "->", "data", ";", "uint16_t", "opcode", "=", "sys_le16_to_cpu", "(", "evt", "->", "opcode", ")", ";", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "waiting_response", ")", ";", "struct", "net_buf_simple_state", "state", ";", "uint8_t", "status", "=", "evt", "->", "status", ";", "uint16_t", "size", ";", "net_buf_simple_save", "(", "&", "buf", "->", "b", ",", "&", "state", ")", ";", "net_buf_pull", "(", "buf", ",", "sizeof", "(", "*", "evt", ")", ")", ";", "size", "=", "sys_cpu_to_le16", "(", "buf", "->", "len", ")", "+", "1", ";", "if", "(", "opcode", "==", "waiting_opcode", ")", "{", "LOG_DBG", "(", "\"", "\"", ",", "waiting_opcode", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "status", ",", "sizeof", "(", "status", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "buf", "->", "data", ",", "buf", "->", "len", ",", "EDTTT_BLOCK", ")", ";", "waiting_opcode", "=", "0", ";", "}", "else", "{", "LOG_WRN", "(", "\"", "\"", "\"", "\"", ",", "opcode", ",", "waiting_opcode", ")", ";", "}", "net_buf_simple_restore", "(", "&", "buf", "->", "b", ",", "&", "state", ")", ";", "}" ]
@brief Handle Command Status HCI event...
[ "@brief", "Handle", "Command", "Status", "HCI", "event", "..." ]
[]
[ { "param": "buf", "type": "struct net_buf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "struct net_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
discard_event
void
static void discard_event(void) { struct net_buf *buf = net_buf_get(&event_queue, K_FOREVER); net_buf_unref(buf); m_events--; }
/** * @brief Remove an event from the event queue */
@brief Remove an event from the event queue
[ "@brief", "Remove", "an", "event", "from", "the", "event", "queue" ]
static void discard_event(void) { struct net_buf *buf = net_buf_get(&event_queue, K_FOREVER); net_buf_unref(buf); m_events--; }
[ "static", "void", "discard_event", "(", "void", ")", "{", "struct", "net_buf", "*", "buf", "=", "net_buf_get", "(", "&", "event_queue", ",", "K_FOREVER", ")", ";", "net_buf_unref", "(", "buf", ")", ";", "m_events", "--", ";", "}" ]
@brief Remove an event from the event queue
[ "@brief", "Remove", "an", "event", "from", "the", "event", "queue" ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
queue_event
null
static struct net_buf *queue_event(struct net_buf *buf) { struct net_buf *evt; evt = net_buf_alloc(&event_pool, K_NO_WAIT); if (evt) { bt_buf_set_type(evt, BT_BUF_EVT); net_buf_add_le32(evt, sys_cpu_to_le32(k_uptime_get())); net_buf_add_mem(evt, buf->data, buf->len); net_buf_put(&event_queue, evt); m_events++; } return evt; }
/** * @brief Allocate and store an event in the event queue */
@brief Allocate and store an event in the event queue
[ "@brief", "Allocate", "and", "store", "an", "event", "in", "the", "event", "queue" ]
static struct net_buf *queue_event(struct net_buf *buf) { struct net_buf *evt; evt = net_buf_alloc(&event_pool, K_NO_WAIT); if (evt) { bt_buf_set_type(evt, BT_BUF_EVT); net_buf_add_le32(evt, sys_cpu_to_le32(k_uptime_get())); net_buf_add_mem(evt, buf->data, buf->len); net_buf_put(&event_queue, evt); m_events++; } return evt; }
[ "static", "struct", "net_buf", "*", "queue_event", "(", "struct", "net_buf", "*", "buf", ")", "{", "struct", "net_buf", "*", "evt", ";", "evt", "=", "net_buf_alloc", "(", "&", "event_pool", ",", "K_NO_WAIT", ")", ";", "if", "(", "evt", ")", "{", "bt_buf_set_type", "(", "evt", ",", "BT_BUF_EVT", ")", ";", "net_buf_add_le32", "(", "evt", ",", "sys_cpu_to_le32", "(", "k_uptime_get", "(", ")", ")", ")", ";", "net_buf_add_mem", "(", "evt", ",", "buf", "->", "data", ",", "buf", "->", "len", ")", ";", "net_buf_put", "(", "&", "event_queue", ",", "evt", ")", ";", "m_events", "++", ";", "}", "return", "evt", ";", "}" ]
@brief Allocate and store an event in the event queue
[ "@brief", "Allocate", "and", "store", "an", "event", "in", "the", "event", "queue" ]
[]
[ { "param": "buf", "type": "struct net_buf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "struct net_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
flush_events
void
static void flush_events(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_FLUSH_EVENTS_RSP); struct net_buf *buf; while ((buf = net_buf_get(&event_queue, K_NO_WAIT))) { net_buf_unref(buf); m_events--; } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
/** * @brief Flush all HCI events from the input-copy queue */
@brief Flush all HCI events from the input-copy queue
[ "@brief", "Flush", "all", "HCI", "events", "from", "the", "input", "-", "copy", "queue" ]
static void flush_events(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_FLUSH_EVENTS_RSP); struct net_buf *buf; while ((buf = net_buf_get(&event_queue, K_NO_WAIT))) { net_buf_unref(buf); m_events--; } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
[ "static", "void", "flush_events", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_FLUSH_EVENTS_RSP", ")", ";", "struct", "net_buf", "*", "buf", ";", "while", "(", "(", "buf", "=", "net_buf_get", "(", "&", "event_queue", ",", "K_NO_WAIT", ")", ")", ")", "{", "net_buf_unref", "(", "buf", ")", ";", "m_events", "--", ";", "}", "read_excess_bytes", "(", "size", ")", ";", "size", "=", "0", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Flush all HCI events from the input-copy queue
[ "@brief", "Flush", "all", "HCI", "events", "from", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
has_event
void
static void has_event(uint16_t size) { struct has_event_resp { uint16_t response; uint16_t size; uint8_t count; } __packed; struct has_event_resp le_response = { .response = sys_cpu_to_le16(CMD_HAS_EVENT_RSP), .size = sys_cpu_to_le16(1), .count = m_events }; if (size > 0) { read_excess_bytes(size); } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
/** * @brief Check whether an HCI event is available in the input-copy queue */
@brief Check whether an HCI event is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "HCI", "event", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
static void has_event(uint16_t size) { struct has_event_resp { uint16_t response; uint16_t size; uint8_t count; } __packed; struct has_event_resp le_response = { .response = sys_cpu_to_le16(CMD_HAS_EVENT_RSP), .size = sys_cpu_to_le16(1), .count = m_events }; if (size > 0) { read_excess_bytes(size); } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
[ "static", "void", "has_event", "(", "uint16_t", "size", ")", "{", "struct", "has_event_resp", "{", "uint16_t", "response", ";", "uint16_t", "size", ";", "uint8_t", "count", ";", "}", "__packed", ";", "struct", "has_event_resp", "le_response", "=", "{", ".", "response", "=", "sys_cpu_to_le16", "(", "CMD_HAS_EVENT_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "1", ")", ",", ".", "count", "=", "m_events", "}", ";", "if", "(", "size", ">", "0", ")", "{", "read_excess_bytes", "(", "size", ")", ";", "}", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "le_response", ",", "sizeof", "(", "le_response", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Check whether an HCI event is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "HCI", "event", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_flush_data
void
static void le_flush_data(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_DATA_RSP); struct net_buf *buf; while ((buf = net_buf_get(&data_queue, K_NO_WAIT))) { net_buf_unref(buf); } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
/** * @brief Flush all ACL Data Packages from the input-copy queue */
@brief Flush all ACL Data Packages from the input-copy queue
[ "@brief", "Flush", "all", "ACL", "Data", "Packages", "from", "the", "input", "-", "copy", "queue" ]
static void le_flush_data(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_DATA_RSP); struct net_buf *buf; while ((buf = net_buf_get(&data_queue, K_NO_WAIT))) { net_buf_unref(buf); } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
[ "static", "void", "le_flush_data", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_FLUSH_DATA_RSP", ")", ";", "struct", "net_buf", "*", "buf", ";", "while", "(", "(", "buf", "=", "net_buf_get", "(", "&", "data_queue", ",", "K_NO_WAIT", ")", ")", ")", "{", "net_buf_unref", "(", "buf", ")", ";", "}", "read_excess_bytes", "(", "size", ")", ";", "size", "=", "0", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Flush all ACL Data Packages from the input-copy queue
[ "@brief", "Flush", "all", "ACL", "Data", "Packages", "from", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_data_ready
void
static void le_data_ready(uint16_t size) { struct has_data_resp { uint16_t response; uint16_t size; uint8_t empty; } __packed; struct has_data_resp le_response = { .response = sys_cpu_to_le16(CMD_LE_DATA_READY_RSP), .size = sys_cpu_to_le16(1), .empty = 0 }; if (size > 0) { read_excess_bytes(size); } if (k_fifo_is_empty(&data_queue)) { le_response.empty = 1; } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
/** * @brief Check whether an ACL Data Package is available in the input-copy queue */
@brief Check whether an ACL Data Package is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "ACL", "Data", "Package", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
static void le_data_ready(uint16_t size) { struct has_data_resp { uint16_t response; uint16_t size; uint8_t empty; } __packed; struct has_data_resp le_response = { .response = sys_cpu_to_le16(CMD_LE_DATA_READY_RSP), .size = sys_cpu_to_le16(1), .empty = 0 }; if (size > 0) { read_excess_bytes(size); } if (k_fifo_is_empty(&data_queue)) { le_response.empty = 1; } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
[ "static", "void", "le_data_ready", "(", "uint16_t", "size", ")", "{", "struct", "has_data_resp", "{", "uint16_t", "response", ";", "uint16_t", "size", ";", "uint8_t", "empty", ";", "}", "__packed", ";", "struct", "has_data_resp", "le_response", "=", "{", ".", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_DATA_READY_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "1", ")", ",", ".", "empty", "=", "0", "}", ";", "if", "(", "size", ">", "0", ")", "{", "read_excess_bytes", "(", "size", ")", ";", "}", "if", "(", "k_fifo_is_empty", "(", "&", "data_queue", ")", ")", "{", "le_response", ".", "empty", "=", "1", ";", "}", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "le_response", ",", "sizeof", "(", "le_response", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Check whether an ACL Data Package is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "ACL", "Data", "Package", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_data_read
void
static void le_data_read(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_DATA_READ_RSP); struct net_buf *buf; read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); buf = net_buf_get(&data_queue, K_FOREVER); if (buf) { size = sys_cpu_to_le16(buf->len); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); net_buf_unref(buf); } else { edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); } }
/** * @brief Get next available HCI Data Package from the input-copy queue */
@brief Get next available HCI Data Package from the input-copy queue
[ "@brief", "Get", "next", "available", "HCI", "Data", "Package", "from", "the", "input", "-", "copy", "queue" ]
static void le_data_read(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_DATA_READ_RSP); struct net_buf *buf; read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); buf = net_buf_get(&data_queue, K_FOREVER); if (buf) { size = sys_cpu_to_le16(buf->len); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); net_buf_unref(buf); } else { edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); } }
[ "static", "void", "le_data_read", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_DATA_READ_RSP", ")", ";", "struct", "net_buf", "*", "buf", ";", "read_excess_bytes", "(", "size", ")", ";", "size", "=", "0", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "buf", "=", "net_buf_get", "(", "&", "data_queue", ",", "K_FOREVER", ")", ";", "if", "(", "buf", ")", "{", "size", "=", "sys_cpu_to_le16", "(", "buf", "->", "len", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "buf", "->", "data", ",", "buf", "->", "len", ",", "EDTTT_BLOCK", ")", ";", "net_buf_unref", "(", "buf", ")", ";", "}", "else", "{", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "}", "}" ]
@brief Get next available HCI Data Package from the input-copy queue
[ "@brief", "Get", "next", "available", "HCI", "Data", "Package", "from", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_data_write
void
static void le_data_write(uint16_t size) { struct data_write_resp { uint16_t code; uint16_t size; uint8_t status; } __packed; struct data_write_resp response = { .code = sys_cpu_to_le16(CMD_LE_DATA_WRITE_RSP), .size = sys_cpu_to_le16(1), .status = 0 }; struct net_buf *buf; struct bt_hci_acl_hdr hdr; int err; if (size >= sizeof(hdr)) { edtt_read((uint8_t *)&hdr, sizeof(hdr), EDTTT_BLOCK); size -= sizeof(hdr); buf = acl_data_create(&hdr); if (buf) { uint16_t hdr_length = sys_le16_to_cpu(hdr.len); uint8_t *pdata = net_buf_add(buf, hdr_length); if (size >= hdr_length) { edtt_read(pdata, hdr_length, EDTTT_BLOCK); size -= hdr_length; } err = bt_send(buf); if (err) { LOG_ERR("Failed to send ACL Data (err %d)", err); } } else { err = -2; /* Failed to allocate data buffer */ LOG_ERR("Failed to create buffer for ACL Data."); } } else { /* Size too small for header (handle and data length) */ err = -3; } read_excess_bytes(size); response.status = sys_cpu_to_le32(err); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); }
/** * @brief Write ACL Data Package to the Controller... */
@brief Write ACL Data Package to the Controller
[ "@brief", "Write", "ACL", "Data", "Package", "to", "the", "Controller" ]
static void le_data_write(uint16_t size) { struct data_write_resp { uint16_t code; uint16_t size; uint8_t status; } __packed; struct data_write_resp response = { .code = sys_cpu_to_le16(CMD_LE_DATA_WRITE_RSP), .size = sys_cpu_to_le16(1), .status = 0 }; struct net_buf *buf; struct bt_hci_acl_hdr hdr; int err; if (size >= sizeof(hdr)) { edtt_read((uint8_t *)&hdr, sizeof(hdr), EDTTT_BLOCK); size -= sizeof(hdr); buf = acl_data_create(&hdr); if (buf) { uint16_t hdr_length = sys_le16_to_cpu(hdr.len); uint8_t *pdata = net_buf_add(buf, hdr_length); if (size >= hdr_length) { edtt_read(pdata, hdr_length, EDTTT_BLOCK); size -= hdr_length; } err = bt_send(buf); if (err) { LOG_ERR("Failed to send ACL Data (err %d)", err); } } else { err = -2; LOG_ERR("Failed to create buffer for ACL Data."); } } else { err = -3; } read_excess_bytes(size); response.status = sys_cpu_to_le32(err); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); }
[ "static", "void", "le_data_write", "(", "uint16_t", "size", ")", "{", "struct", "data_write_resp", "{", "uint16_t", "code", ";", "uint16_t", "size", ";", "uint8_t", "status", ";", "}", "__packed", ";", "struct", "data_write_resp", "response", "=", "{", ".", "code", "=", "sys_cpu_to_le16", "(", "CMD_LE_DATA_WRITE_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "1", ")", ",", ".", "status", "=", "0", "}", ";", "struct", "net_buf", "*", "buf", ";", "struct", "bt_hci_acl_hdr", "hdr", ";", "int", "err", ";", "if", "(", "size", ">=", "sizeof", "(", "hdr", ")", ")", "{", "edtt_read", "(", "(", "uint8_t", "*", ")", "&", "hdr", ",", "sizeof", "(", "hdr", ")", ",", "EDTTT_BLOCK", ")", ";", "size", "-=", "sizeof", "(", "hdr", ")", ";", "buf", "=", "acl_data_create", "(", "&", "hdr", ")", ";", "if", "(", "buf", ")", "{", "uint16_t", "hdr_length", "=", "sys_le16_to_cpu", "(", "hdr", ".", "len", ")", ";", "uint8_t", "*", "pdata", "=", "net_buf_add", "(", "buf", ",", "hdr_length", ")", ";", "if", "(", "size", ">=", "hdr_length", ")", "{", "edtt_read", "(", "pdata", ",", "hdr_length", ",", "EDTTT_BLOCK", ")", ";", "size", "-=", "hdr_length", ";", "}", "err", "=", "bt_send", "(", "buf", ")", ";", "if", "(", "err", ")", "{", "LOG_ERR", "(", "\"", "\"", ",", "err", ")", ";", "}", "}", "else", "{", "err", "=", "-2", ";", "LOG_ERR", "(", "\"", "\"", ")", ";", "}", "}", "else", "{", "err", "=", "-3", ";", "}", "read_excess_bytes", "(", "size", ")", ";", "response", ".", "status", "=", "sys_cpu_to_le32", "(", "err", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Write ACL Data Package to the Controller...
[ "@brief", "Write", "ACL", "Data", "Package", "to", "the", "Controller", "..." ]
[ "/* Failed to allocate data buffer */", "/* Size too small for header (handle and data length) */" ]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_flush_iso_data
void
static void le_flush_iso_data(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_ISO_DATA_RSP); struct net_buf *buf; while ((buf = net_buf_get(&iso_data_queue, K_NO_WAIT))) { net_buf_unref(buf); } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
/** * @brief Flush all ISO Data Packages from the input-copy queue */
@brief Flush all ISO Data Packages from the input-copy queue
[ "@brief", "Flush", "all", "ISO", "Data", "Packages", "from", "the", "input", "-", "copy", "queue" ]
static void le_flush_iso_data(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_ISO_DATA_RSP); struct net_buf *buf; while ((buf = net_buf_get(&iso_data_queue, K_NO_WAIT))) { net_buf_unref(buf); } read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); }
[ "static", "void", "le_flush_iso_data", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_FLUSH_ISO_DATA_RSP", ")", ";", "struct", "net_buf", "*", "buf", ";", "while", "(", "(", "buf", "=", "net_buf_get", "(", "&", "iso_data_queue", ",", "K_NO_WAIT", ")", ")", ")", "{", "net_buf_unref", "(", "buf", ")", ";", "}", "read_excess_bytes", "(", "size", ")", ";", "size", "=", "0", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Flush all ISO Data Packages from the input-copy queue
[ "@brief", "Flush", "all", "ISO", "Data", "Packages", "from", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_iso_data_ready
void
static void le_iso_data_ready(uint16_t size) { struct has_iso_data_resp { uint16_t response; uint16_t size; uint8_t empty; } __packed; struct has_iso_data_resp le_response = { .response = sys_cpu_to_le16(CMD_LE_ISO_DATA_READY_RSP), .size = sys_cpu_to_le16(1), .empty = 0 }; if (size > 0) { read_excess_bytes(size); } if (k_fifo_is_empty(&iso_data_queue)) { le_response.empty = 1; } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
/** * @brief Check whether an ISO Data Package is available in the input-copy queue */
@brief Check whether an ISO Data Package is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "ISO", "Data", "Package", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
static void le_iso_data_ready(uint16_t size) { struct has_iso_data_resp { uint16_t response; uint16_t size; uint8_t empty; } __packed; struct has_iso_data_resp le_response = { .response = sys_cpu_to_le16(CMD_LE_ISO_DATA_READY_RSP), .size = sys_cpu_to_le16(1), .empty = 0 }; if (size > 0) { read_excess_bytes(size); } if (k_fifo_is_empty(&iso_data_queue)) { le_response.empty = 1; } edtt_write((uint8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK); }
[ "static", "void", "le_iso_data_ready", "(", "uint16_t", "size", ")", "{", "struct", "has_iso_data_resp", "{", "uint16_t", "response", ";", "uint16_t", "size", ";", "uint8_t", "empty", ";", "}", "__packed", ";", "struct", "has_iso_data_resp", "le_response", "=", "{", ".", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_ISO_DATA_READY_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "1", ")", ",", ".", "empty", "=", "0", "}", ";", "if", "(", "size", ">", "0", ")", "{", "read_excess_bytes", "(", "size", ")", ";", "}", "if", "(", "k_fifo_is_empty", "(", "&", "iso_data_queue", ")", ")", "{", "le_response", ".", "empty", "=", "1", ";", "}", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "le_response", ",", "sizeof", "(", "le_response", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Check whether an ISO Data Package is available in the input-copy queue
[ "@brief", "Check", "whether", "an", "ISO", "Data", "Package", "is", "available", "in", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_iso_data_read
void
static void le_iso_data_read(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_ISO_DATA_READ_RSP); struct net_buf *buf; read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); buf = net_buf_get(&iso_data_queue, K_FOREVER); if (buf) { size = sys_cpu_to_le16(buf->len); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); net_buf_unref(buf); } else { edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); } }
/** * @brief Get next available ISO Data Package from the input-copy queue */
@brief Get next available ISO Data Package from the input-copy queue
[ "@brief", "Get", "next", "available", "ISO", "Data", "Package", "from", "the", "input", "-", "copy", "queue" ]
static void le_iso_data_read(uint16_t size) { uint16_t response = sys_cpu_to_le16(CMD_LE_ISO_DATA_READ_RSP); struct net_buf *buf; read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); buf = net_buf_get(&iso_data_queue, K_FOREVER); if (buf) { size = sys_cpu_to_le16(buf->len); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); net_buf_unref(buf); } else { edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); } }
[ "static", "void", "le_iso_data_read", "(", "uint16_t", "size", ")", "{", "uint16_t", "response", "=", "sys_cpu_to_le16", "(", "CMD_LE_ISO_DATA_READ_RSP", ")", ";", "struct", "net_buf", "*", "buf", ";", "read_excess_bytes", "(", "size", ")", ";", "size", "=", "0", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "buf", "=", "net_buf_get", "(", "&", "iso_data_queue", ",", "K_FOREVER", ")", ";", "if", "(", "buf", ")", "{", "size", "=", "sys_cpu_to_le16", "(", "buf", "->", "len", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "buf", "->", "data", ",", "buf", "->", "len", ",", "EDTTT_BLOCK", ")", ";", "net_buf_unref", "(", "buf", ")", ";", "}", "else", "{", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "size", ",", "sizeof", "(", "size", ")", ",", "EDTTT_BLOCK", ")", ";", "}", "}" ]
@brief Get next available ISO Data Package from the input-copy queue
[ "@brief", "Get", "next", "available", "ISO", "Data", "Package", "from", "the", "input", "-", "copy", "queue" ]
[]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_iso_data_write
void
static void le_iso_data_write(uint16_t size) { struct iso_data_write_resp { uint16_t code; uint16_t size; uint8_t status; } __packed; struct iso_data_write_resp response = { .code = sys_cpu_to_le16(CMD_LE_ISO_DATA_WRITE_RSP), .size = sys_cpu_to_le16(1), .status = 0 }; struct net_buf *buf; struct bt_hci_iso_hdr hdr; int err; if (size >= sizeof(hdr)) { edtt_read((uint8_t *)&hdr, sizeof(hdr), EDTTT_BLOCK); size -= sizeof(hdr); buf = iso_data_create(&hdr); if (buf) { uint16_t hdr_length = sys_le16_to_cpu(hdr.len); uint8_t *pdata = net_buf_add(buf, hdr_length); if (size >= hdr_length) { edtt_read(pdata, hdr_length, EDTTT_BLOCK); size -= hdr_length; } err = bt_send(buf); if (err) { LOG_ERR("Failed to send ISO Data (err %d)", err); } } else { err = -2; /* Failed to allocate data buffer */ LOG_ERR("Failed to create buffer for ISO Data."); } } else { /* Size too small for header (handle and data length) */ err = -3; } read_excess_bytes(size); response.status = sys_cpu_to_le32(err); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); }
/** * @brief Write ISO Data Package to the Controller... */
@brief Write ISO Data Package to the Controller
[ "@brief", "Write", "ISO", "Data", "Package", "to", "the", "Controller" ]
static void le_iso_data_write(uint16_t size) { struct iso_data_write_resp { uint16_t code; uint16_t size; uint8_t status; } __packed; struct iso_data_write_resp response = { .code = sys_cpu_to_le16(CMD_LE_ISO_DATA_WRITE_RSP), .size = sys_cpu_to_le16(1), .status = 0 }; struct net_buf *buf; struct bt_hci_iso_hdr hdr; int err; if (size >= sizeof(hdr)) { edtt_read((uint8_t *)&hdr, sizeof(hdr), EDTTT_BLOCK); size -= sizeof(hdr); buf = iso_data_create(&hdr); if (buf) { uint16_t hdr_length = sys_le16_to_cpu(hdr.len); uint8_t *pdata = net_buf_add(buf, hdr_length); if (size >= hdr_length) { edtt_read(pdata, hdr_length, EDTTT_BLOCK); size -= hdr_length; } err = bt_send(buf); if (err) { LOG_ERR("Failed to send ISO Data (err %d)", err); } } else { err = -2; LOG_ERR("Failed to create buffer for ISO Data."); } } else { err = -3; } read_excess_bytes(size); response.status = sys_cpu_to_le32(err); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); }
[ "static", "void", "le_iso_data_write", "(", "uint16_t", "size", ")", "{", "struct", "iso_data_write_resp", "{", "uint16_t", "code", ";", "uint16_t", "size", ";", "uint8_t", "status", ";", "}", "__packed", ";", "struct", "iso_data_write_resp", "response", "=", "{", ".", "code", "=", "sys_cpu_to_le16", "(", "CMD_LE_ISO_DATA_WRITE_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "1", ")", ",", ".", "status", "=", "0", "}", ";", "struct", "net_buf", "*", "buf", ";", "struct", "bt_hci_iso_hdr", "hdr", ";", "int", "err", ";", "if", "(", "size", ">=", "sizeof", "(", "hdr", ")", ")", "{", "edtt_read", "(", "(", "uint8_t", "*", ")", "&", "hdr", ",", "sizeof", "(", "hdr", ")", ",", "EDTTT_BLOCK", ")", ";", "size", "-=", "sizeof", "(", "hdr", ")", ";", "buf", "=", "iso_data_create", "(", "&", "hdr", ")", ";", "if", "(", "buf", ")", "{", "uint16_t", "hdr_length", "=", "sys_le16_to_cpu", "(", "hdr", ".", "len", ")", ";", "uint8_t", "*", "pdata", "=", "net_buf_add", "(", "buf", ",", "hdr_length", ")", ";", "if", "(", "size", ">=", "hdr_length", ")", "{", "edtt_read", "(", "pdata", ",", "hdr_length", ",", "EDTTT_BLOCK", ")", ";", "size", "-=", "hdr_length", ";", "}", "err", "=", "bt_send", "(", "buf", ")", ";", "if", "(", "err", ")", "{", "LOG_ERR", "(", "\"", "\"", ",", "err", ")", ";", "}", "}", "else", "{", "err", "=", "-2", ";", "LOG_ERR", "(", "\"", "\"", ")", ";", "}", "}", "else", "{", "err", "=", "-3", ";", "}", "read_excess_bytes", "(", "size", ")", ";", "response", ".", "status", "=", "sys_cpu_to_le32", "(", "err", ")", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "}" ]
@brief Write ISO Data Package to the Controller...
[ "@brief", "Write", "ISO", "Data", "Package", "to", "the", "Controller", "..." ]
[ "/* Failed to allocate data buffer */", "/* Size too small for header (handle and data length) */" ]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2015214b336260364f53c0e3d73747658a978009
ParticleBeamHQ/zephyr
tests/bluetooth/bsim_bt/edtt_ble_test_app/hci_test_app/src/main.c
[ "Apache-2.0" ]
C
le_ixit_value_read
void
static void le_ixit_value_read(uint16_t size) { uint8_t profileId; uint8_t refMajor; uint8_t refMinor; struct EdttIxit *pIxitArray; int ixitArraySize; struct EdttIxit *pIxitElement = NULL; /* * CMD_GET_IXIT_VALUE_REQ payload layout * * ... * [ 4] PROFILE_ID[0] * [ 5] IXIT_Reference_Major * [ 6] IXIT_Reference_Minor */ edtt_read((uint8_t *)&profileId, sizeof(profileId), EDTTT_BLOCK); edtt_read((uint8_t *)&refMajor, sizeof(refMajor), EDTTT_BLOCK); edtt_read((uint8_t *)&refMinor, sizeof(refMinor), EDTTT_BLOCK); switch (profileId) { case PROFILE_ID_LL: pIxitArray = llIxits; ixitArraySize = ARRAY_SIZE(llIxits); break; default: pIxitArray = NULL; ixitArraySize = 0; } for (int i = 0; i < ixitArraySize; i++) { if (pIxitArray[i].refMajor == refMajor && pIxitArray[i].refMinor == refMinor) { pIxitElement = &pIxitArray[i]; break; } } struct ixit_value_get_resp { uint16_t code; uint16_t size; uint8_t data[]; } __packed; struct ixit_value_get_resp response = { .code = sys_cpu_to_le16(CMD_GET_IXIT_VALUE_RSP), .size = sys_cpu_to_le16(pIxitElement ? pIxitElement->len : 0), }; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); if (pIxitElement) { edtt_write(pIxitElement->pVal, pIxitElement->len, EDTTT_BLOCK); } }
/** * @brief Read 'Implementation eXtra Information for Test' value */
@brief Read 'Implementation eXtra Information for Test' value
[ "@brief", "Read", "'", "Implementation", "eXtra", "Information", "for", "Test", "'", "value" ]
static void le_ixit_value_read(uint16_t size) { uint8_t profileId; uint8_t refMajor; uint8_t refMinor; struct EdttIxit *pIxitArray; int ixitArraySize; struct EdttIxit *pIxitElement = NULL; edtt_read((uint8_t *)&profileId, sizeof(profileId), EDTTT_BLOCK); edtt_read((uint8_t *)&refMajor, sizeof(refMajor), EDTTT_BLOCK); edtt_read((uint8_t *)&refMinor, sizeof(refMinor), EDTTT_BLOCK); switch (profileId) { case PROFILE_ID_LL: pIxitArray = llIxits; ixitArraySize = ARRAY_SIZE(llIxits); break; default: pIxitArray = NULL; ixitArraySize = 0; } for (int i = 0; i < ixitArraySize; i++) { if (pIxitArray[i].refMajor == refMajor && pIxitArray[i].refMinor == refMinor) { pIxitElement = &pIxitArray[i]; break; } } struct ixit_value_get_resp { uint16_t code; uint16_t size; uint8_t data[]; } __packed; struct ixit_value_get_resp response = { .code = sys_cpu_to_le16(CMD_GET_IXIT_VALUE_RSP), .size = sys_cpu_to_le16(pIxitElement ? pIxitElement->len : 0), }; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); if (pIxitElement) { edtt_write(pIxitElement->pVal, pIxitElement->len, EDTTT_BLOCK); } }
[ "static", "void", "le_ixit_value_read", "(", "uint16_t", "size", ")", "{", "uint8_t", "profileId", ";", "uint8_t", "refMajor", ";", "uint8_t", "refMinor", ";", "struct", "EdttIxit", "*", "pIxitArray", ";", "int", "ixitArraySize", ";", "struct", "EdttIxit", "*", "pIxitElement", "=", "NULL", ";", "edtt_read", "(", "(", "uint8_t", "*", ")", "&", "profileId", ",", "sizeof", "(", "profileId", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_read", "(", "(", "uint8_t", "*", ")", "&", "refMajor", ",", "sizeof", "(", "refMajor", ")", ",", "EDTTT_BLOCK", ")", ";", "edtt_read", "(", "(", "uint8_t", "*", ")", "&", "refMinor", ",", "sizeof", "(", "refMinor", ")", ",", "EDTTT_BLOCK", ")", ";", "switch", "(", "profileId", ")", "{", "case", "PROFILE_ID_LL", ":", "pIxitArray", "=", "llIxits", ";", "ixitArraySize", "=", "ARRAY_SIZE", "(", "llIxits", ")", ";", "break", ";", "default", ":", "pIxitArray", "=", "NULL", ";", "ixitArraySize", "=", "0", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ixitArraySize", ";", "i", "++", ")", "{", "if", "(", "pIxitArray", "[", "i", "]", ".", "refMajor", "==", "refMajor", "&&", "pIxitArray", "[", "i", "]", ".", "refMinor", "==", "refMinor", ")", "{", "pIxitElement", "=", "&", "pIxitArray", "[", "i", "]", ";", "break", ";", "}", "}", "struct", "ixit_value_get_resp", "{", "uint16_t", "code", ";", "uint16_t", "size", ";", "uint8_t", "data", "[", "]", ";", "}", "__packed", ";", "struct", "ixit_value_get_resp", "response", "=", "{", ".", "code", "=", "sys_cpu_to_le16", "(", "CMD_GET_IXIT_VALUE_RSP", ")", ",", ".", "size", "=", "sys_cpu_to_le16", "(", "pIxitElement", "?", "pIxitElement", "->", "len", ":", "0", ")", ",", "}", ";", "edtt_write", "(", "(", "uint8_t", "*", ")", "&", "response", ",", "sizeof", "(", "response", ")", ",", "EDTTT_BLOCK", ")", ";", "if", "(", "pIxitElement", ")", "{", "edtt_write", "(", "pIxitElement", "->", "pVal", ",", "pIxitElement", "->", "len", ",", "EDTTT_BLOCK", ")", ";", "}", "}" ]
@brief Read 'Implementation eXtra Information for Test' value
[ "@brief", "Read", "'", "Implementation", "eXtra", "Information", "for", "Test", "'", "value" ]
[ "/*\n\t * CMD_GET_IXIT_VALUE_REQ payload layout\n\t *\n\t * ...\n\t * [ 4] PROFILE_ID[0]\n\t * [ 5] IXIT_Reference_Major\n\t * [ 6] IXIT_Reference_Minor\n\t */" ]
[ { "param": "size", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9fe37f722abd463141bc7064d634901fd6fef79
ParticleBeamHQ/zephyr
soc/arm/nordic_nrf/nrf53/sync_rtc.c
[ "Apache-2.0" ]
C
ppi_ipc_to_rtc
void
static void ppi_ipc_to_rtc(union rtc_sync_channels channels, bool setup) { nrf_ipc_event_t ipc_evt = nrf_ipc_receive_event_get(channels.ch.ipc_in); uint32_t task_addr = z_nrf_rtc_timer_capture_task_address_get(channels.ch.rtc); if (setup) { nrfx_gppi_task_endpoint_setup(channels.ch.ppi, task_addr); nrf_ipc_publish_set(NRF_IPC, ipc_evt, channels.ch.ppi); } else { nrfx_gppi_task_endpoint_clear(channels.ch.ppi, task_addr); nrf_ipc_publish_clear(NRF_IPC, ipc_evt); } }
/* Setup or clear connection from IPC_RECEIVE to RTC_CAPTURE * * @param channels Details about channels * @param setup If true connection is setup, else it is cleared. */
Setup or clear connection from IPC_RECEIVE to RTC_CAPTURE @param channels Details about channels @param setup If true connection is setup, else it is cleared.
[ "Setup", "or", "clear", "connection", "from", "IPC_RECEIVE", "to", "RTC_CAPTURE", "@param", "channels", "Details", "about", "channels", "@param", "setup", "If", "true", "connection", "is", "setup", "else", "it", "is", "cleared", "." ]
static void ppi_ipc_to_rtc(union rtc_sync_channels channels, bool setup) { nrf_ipc_event_t ipc_evt = nrf_ipc_receive_event_get(channels.ch.ipc_in); uint32_t task_addr = z_nrf_rtc_timer_capture_task_address_get(channels.ch.rtc); if (setup) { nrfx_gppi_task_endpoint_setup(channels.ch.ppi, task_addr); nrf_ipc_publish_set(NRF_IPC, ipc_evt, channels.ch.ppi); } else { nrfx_gppi_task_endpoint_clear(channels.ch.ppi, task_addr); nrf_ipc_publish_clear(NRF_IPC, ipc_evt); } }
[ "static", "void", "ppi_ipc_to_rtc", "(", "union", "rtc_sync_channels", "channels", ",", "bool", "setup", ")", "{", "nrf_ipc_event_t", "ipc_evt", "=", "nrf_ipc_receive_event_get", "(", "channels", ".", "ch", ".", "ipc_in", ")", ";", "uint32_t", "task_addr", "=", "z_nrf_rtc_timer_capture_task_address_get", "(", "channels", ".", "ch", ".", "rtc", ")", ";", "if", "(", "setup", ")", "{", "nrfx_gppi_task_endpoint_setup", "(", "channels", ".", "ch", ".", "ppi", ",", "task_addr", ")", ";", "nrf_ipc_publish_set", "(", "NRF_IPC", ",", "ipc_evt", ",", "channels", ".", "ch", ".", "ppi", ")", ";", "}", "else", "{", "nrfx_gppi_task_endpoint_clear", "(", "channels", ".", "ch", ".", "ppi", ",", "task_addr", ")", ";", "nrf_ipc_publish_clear", "(", "NRF_IPC", ",", "ipc_evt", ")", ";", "}", "}" ]
Setup or clear connection from IPC_RECEIVE to RTC_CAPTURE @param channels Details about channels @param setup If true connection is setup, else it is cleared.
[ "Setup", "or", "clear", "connection", "from", "IPC_RECEIVE", "to", "RTC_CAPTURE", "@param", "channels", "Details", "about", "channels", "@param", "setup", "If", "true", "connection", "is", "setup", "else", "it", "is", "cleared", "." ]
[]
[ { "param": "channels", "type": "union rtc_sync_channels" }, { "param": "setup", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "channels", "type": "union rtc_sync_channels", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "setup", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9fe37f722abd463141bc7064d634901fd6fef79
ParticleBeamHQ/zephyr
soc/arm/nordic_nrf/nrf53/sync_rtc.c
[ "Apache-2.0" ]
C
ppi_rtc_to_ipc
void
static void ppi_rtc_to_ipc(union rtc_sync_channels channels, bool setup) { uint32_t evt_addr = z_nrf_rtc_timer_compare_evt_address_get(channels.ch.rtc); nrf_ipc_task_t ipc_task = nrf_ipc_send_task_get(channels.ch.ipc_out); if (setup) { nrf_ipc_subscribe_set(NRF_IPC, ipc_task, channels.ch.ppi); nrfx_gppi_event_endpoint_setup(channels.ch.ppi, evt_addr); } else { nrfx_gppi_event_endpoint_clear(channels.ch.ppi, evt_addr); nrf_ipc_subscribe_clear(NRF_IPC, ipc_task); } }
/* Setup or clear connection from RTC_COMPARE to IPC_SEND * * @param channels Details about channels * @param setup If true connection is setup, else it is cleared. */
Setup or clear connection from RTC_COMPARE to IPC_SEND @param channels Details about channels @param setup If true connection is setup, else it is cleared.
[ "Setup", "or", "clear", "connection", "from", "RTC_COMPARE", "to", "IPC_SEND", "@param", "channels", "Details", "about", "channels", "@param", "setup", "If", "true", "connection", "is", "setup", "else", "it", "is", "cleared", "." ]
static void ppi_rtc_to_ipc(union rtc_sync_channels channels, bool setup) { uint32_t evt_addr = z_nrf_rtc_timer_compare_evt_address_get(channels.ch.rtc); nrf_ipc_task_t ipc_task = nrf_ipc_send_task_get(channels.ch.ipc_out); if (setup) { nrf_ipc_subscribe_set(NRF_IPC, ipc_task, channels.ch.ppi); nrfx_gppi_event_endpoint_setup(channels.ch.ppi, evt_addr); } else { nrfx_gppi_event_endpoint_clear(channels.ch.ppi, evt_addr); nrf_ipc_subscribe_clear(NRF_IPC, ipc_task); } }
[ "static", "void", "ppi_rtc_to_ipc", "(", "union", "rtc_sync_channels", "channels", ",", "bool", "setup", ")", "{", "uint32_t", "evt_addr", "=", "z_nrf_rtc_timer_compare_evt_address_get", "(", "channels", ".", "ch", ".", "rtc", ")", ";", "nrf_ipc_task_t", "ipc_task", "=", "nrf_ipc_send_task_get", "(", "channels", ".", "ch", ".", "ipc_out", ")", ";", "if", "(", "setup", ")", "{", "nrf_ipc_subscribe_set", "(", "NRF_IPC", ",", "ipc_task", ",", "channels", ".", "ch", ".", "ppi", ")", ";", "nrfx_gppi_event_endpoint_setup", "(", "channels", ".", "ch", ".", "ppi", ",", "evt_addr", ")", ";", "}", "else", "{", "nrfx_gppi_event_endpoint_clear", "(", "channels", ".", "ch", ".", "ppi", ",", "evt_addr", ")", ";", "nrf_ipc_subscribe_clear", "(", "NRF_IPC", ",", "ipc_task", ")", ";", "}", "}" ]
Setup or clear connection from RTC_COMPARE to IPC_SEND @param channels Details about channels @param setup If true connection is setup, else it is cleared.
[ "Setup", "or", "clear", "connection", "from", "RTC_COMPARE", "to", "IPC_SEND", "@param", "channels", "Details", "about", "channels", "@param", "setup", "If", "true", "connection", "is", "setup", "else", "it", "is", "cleared", "." ]
[]
[ { "param": "channels", "type": "union rtc_sync_channels" }, { "param": "setup", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "channels", "type": "union rtc_sync_channels", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "setup", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f4e420dc12967fb8582738edc0adf31a1b535c23
ParticleBeamHQ/zephyr
subsys/net/lib/lwm2m/lwm2m_rw_link_format.c
[ "Apache-2.0" ]
C
put_corelink_attributes_resource
int
static int put_corelink_attributes_resource(struct lwm2m_output_context *out, const struct lwm2m_obj_path *path, uint8_t *buf, uint16_t buflen) { struct lwm2m_attr *attrs[NR_LWM2M_ATTR] = { 0 }; struct lwm2m_engine_obj *obj = lwm2m_engine_get_obj(path); struct lwm2m_engine_obj_inst *obj_inst = lwm2m_engine_get_obj_inst(path); struct lwm2m_engine_res *res = lwm2m_engine_get_res(path); if (obj == NULL || obj_inst == NULL || res == NULL) { return -ENOENT; } get_attributes(obj, attrs); get_attributes(obj_inst, attrs); get_attributes(res, attrs); return put_attributes(out, attrs, buf, buflen); }
/* Resource-level attribute request - should propagate attributes from Object * and Object Instance. */
Resource-level attribute request - should propagate attributes from Object and Object Instance.
[ "Resource", "-", "level", "attribute", "request", "-", "should", "propagate", "attributes", "from", "Object", "and", "Object", "Instance", "." ]
static int put_corelink_attributes_resource(struct lwm2m_output_context *out, const struct lwm2m_obj_path *path, uint8_t *buf, uint16_t buflen) { struct lwm2m_attr *attrs[NR_LWM2M_ATTR] = { 0 }; struct lwm2m_engine_obj *obj = lwm2m_engine_get_obj(path); struct lwm2m_engine_obj_inst *obj_inst = lwm2m_engine_get_obj_inst(path); struct lwm2m_engine_res *res = lwm2m_engine_get_res(path); if (obj == NULL || obj_inst == NULL || res == NULL) { return -ENOENT; } get_attributes(obj, attrs); get_attributes(obj_inst, attrs); get_attributes(res, attrs); return put_attributes(out, attrs, buf, buflen); }
[ "static", "int", "put_corelink_attributes_resource", "(", "struct", "lwm2m_output_context", "*", "out", ",", "const", "struct", "lwm2m_obj_path", "*", "path", ",", "uint8_t", "*", "buf", ",", "uint16_t", "buflen", ")", "{", "struct", "lwm2m_attr", "*", "attrs", "[", "NR_LWM2M_ATTR", "]", "=", "{", "0", "}", ";", "struct", "lwm2m_engine_obj", "*", "obj", "=", "lwm2m_engine_get_obj", "(", "path", ")", ";", "struct", "lwm2m_engine_obj_inst", "*", "obj_inst", "=", "lwm2m_engine_get_obj_inst", "(", "path", ")", ";", "struct", "lwm2m_engine_res", "*", "res", "=", "lwm2m_engine_get_res", "(", "path", ")", ";", "if", "(", "obj", "==", "NULL", "||", "obj_inst", "==", "NULL", "||", "res", "==", "NULL", ")", "{", "return", "-", "ENOENT", ";", "}", "get_attributes", "(", "obj", ",", "attrs", ")", ";", "get_attributes", "(", "obj_inst", ",", "attrs", ")", ";", "get_attributes", "(", "res", ",", "attrs", ")", ";", "return", "put_attributes", "(", "out", ",", "attrs", ",", "buf", ",", "buflen", ")", ";", "}" ]
Resource-level attribute request - should propagate attributes from Object and Object Instance.
[ "Resource", "-", "level", "attribute", "request", "-", "should", "propagate", "attributes", "from", "Object", "and", "Object", "Instance", "." ]
[]
[ { "param": "out", "type": "struct lwm2m_output_context" }, { "param": "path", "type": "struct lwm2m_obj_path" }, { "param": "buf", "type": "uint8_t" }, { "param": "buflen", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "struct lwm2m_output_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": "struct lwm2m_obj_path", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buflen", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
206d0f519941f596b22de09547719431891fb813
ParticleBeamHQ/zephyr
soc/arm/nxp_imx/rt/lpm_rt1064.c
[ "Apache-2.0" ]
C
clock_set_mux
void
static void clock_set_mux(clock_mux_t mux, uint32_t value) { uint32_t busy_shift; busy_shift = (uint32_t)CCM_TUPLE_BUSY_SHIFT(mux); CCM_TUPLE_REG(CCM, mux) = (CCM_TUPLE_REG(CCM, mux) & (~CCM_TUPLE_MASK(mux))) | (((uint32_t)((value) << CCM_TUPLE_SHIFT(mux))) & CCM_TUPLE_MASK(mux)); /* Clock switch need Handshake? */ if (busy_shift != CCM_NO_BUSY_WAIT) { /* Wait until CCM internal handshake finish. */ while ((CCM->CDHIPR & ((1UL << busy_shift))) != 0UL) { } } }
/* * Duplicate implementation of CLOCK_SetMux() provided by SDK. This function * must be linked to ITCM, as it will be used to change the clocks of the * FLEXSPI and SEMC peripherals. * Any function called from this function must also reside in ITCM */
Duplicate implementation of CLOCK_SetMux() provided by SDK. This function must be linked to ITCM, as it will be used to change the clocks of the FLEXSPI and SEMC peripherals. Any function called from this function must also reside in ITCM
[ "Duplicate", "implementation", "of", "CLOCK_SetMux", "()", "provided", "by", "SDK", ".", "This", "function", "must", "be", "linked", "to", "ITCM", "as", "it", "will", "be", "used", "to", "change", "the", "clocks", "of", "the", "FLEXSPI", "and", "SEMC", "peripherals", ".", "Any", "function", "called", "from", "this", "function", "must", "also", "reside", "in", "ITCM" ]
static void clock_set_mux(clock_mux_t mux, uint32_t value) { uint32_t busy_shift; busy_shift = (uint32_t)CCM_TUPLE_BUSY_SHIFT(mux); CCM_TUPLE_REG(CCM, mux) = (CCM_TUPLE_REG(CCM, mux) & (~CCM_TUPLE_MASK(mux))) | (((uint32_t)((value) << CCM_TUPLE_SHIFT(mux))) & CCM_TUPLE_MASK(mux)); if (busy_shift != CCM_NO_BUSY_WAIT) { while ((CCM->CDHIPR & ((1UL << busy_shift))) != 0UL) { } } }
[ "static", "void", "clock_set_mux", "(", "clock_mux_t", "mux", ",", "uint32_t", "value", ")", "{", "uint32_t", "busy_shift", ";", "busy_shift", "=", "(", "uint32_t", ")", "CCM_TUPLE_BUSY_SHIFT", "(", "mux", ")", ";", "CCM_TUPLE_REG", "(", "CCM", ",", "mux", ")", "=", "(", "CCM_TUPLE_REG", "(", "CCM", ",", "mux", ")", "&", "(", "~", "CCM_TUPLE_MASK", "(", "mux", ")", ")", ")", "|", "(", "(", "(", "uint32_t", ")", "(", "(", "value", ")", "<<", "CCM_TUPLE_SHIFT", "(", "mux", ")", ")", ")", "&", "CCM_TUPLE_MASK", "(", "mux", ")", ")", ";", "if", "(", "busy_shift", "!=", "CCM_NO_BUSY_WAIT", ")", "{", "while", "(", "(", "CCM", "->", "CDHIPR", "&", "(", "(", "1UL", "<<", "busy_shift", ")", ")", ")", "!=", "0UL", ")", "{", "}", "}", "}" ]
Duplicate implementation of CLOCK_SetMux() provided by SDK.
[ "Duplicate", "implementation", "of", "CLOCK_SetMux", "()", "provided", "by", "SDK", "." ]
[ "/* Clock switch need Handshake? */", "/* Wait until CCM internal handshake finish. */" ]
[ { "param": "mux", "type": "clock_mux_t" }, { "param": "value", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mux", "type": "clock_mux_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
206d0f519941f596b22de09547719431891fb813
ParticleBeamHQ/zephyr
soc/arm/nxp_imx/rt/lpm_rt1064.c
[ "Apache-2.0" ]
C
clock_set_div
void
static void clock_set_div(clock_div_t divider, uint32_t value) { uint32_t busy_shift; busy_shift = CCM_TUPLE_BUSY_SHIFT(divider); CCM_TUPLE_REG(CCM, divider) = (CCM_TUPLE_REG(CCM, divider) & (~CCM_TUPLE_MASK(divider))) | (((uint32_t)((value) << CCM_TUPLE_SHIFT(divider))) & CCM_TUPLE_MASK(divider)); /* Clock switch need Handshake? */ if (busy_shift != CCM_NO_BUSY_WAIT) { /* Wait until CCM internal handshake finish. */ while ((CCM->CDHIPR & ((uint32_t)(1UL << busy_shift))) != 0UL) { } } }
/* * Duplicate implementation of CLOCK_SetDiv() provided by SDK. This function * must be linked to ITCM, as it will be used to change the clocks of the * FLEXSPI and SEMC peripherals. * Any function called from this function must also reside in ITCM */
Duplicate implementation of CLOCK_SetDiv() provided by SDK. This function must be linked to ITCM, as it will be used to change the clocks of the FLEXSPI and SEMC peripherals. Any function called from this function must also reside in ITCM
[ "Duplicate", "implementation", "of", "CLOCK_SetDiv", "()", "provided", "by", "SDK", ".", "This", "function", "must", "be", "linked", "to", "ITCM", "as", "it", "will", "be", "used", "to", "change", "the", "clocks", "of", "the", "FLEXSPI", "and", "SEMC", "peripherals", ".", "Any", "function", "called", "from", "this", "function", "must", "also", "reside", "in", "ITCM" ]
static void clock_set_div(clock_div_t divider, uint32_t value) { uint32_t busy_shift; busy_shift = CCM_TUPLE_BUSY_SHIFT(divider); CCM_TUPLE_REG(CCM, divider) = (CCM_TUPLE_REG(CCM, divider) & (~CCM_TUPLE_MASK(divider))) | (((uint32_t)((value) << CCM_TUPLE_SHIFT(divider))) & CCM_TUPLE_MASK(divider)); if (busy_shift != CCM_NO_BUSY_WAIT) { while ((CCM->CDHIPR & ((uint32_t)(1UL << busy_shift))) != 0UL) { } } }
[ "static", "void", "clock_set_div", "(", "clock_div_t", "divider", ",", "uint32_t", "value", ")", "{", "uint32_t", "busy_shift", ";", "busy_shift", "=", "CCM_TUPLE_BUSY_SHIFT", "(", "divider", ")", ";", "CCM_TUPLE_REG", "(", "CCM", ",", "divider", ")", "=", "(", "CCM_TUPLE_REG", "(", "CCM", ",", "divider", ")", "&", "(", "~", "CCM_TUPLE_MASK", "(", "divider", ")", ")", ")", "|", "(", "(", "(", "uint32_t", ")", "(", "(", "value", ")", "<<", "CCM_TUPLE_SHIFT", "(", "divider", ")", ")", ")", "&", "CCM_TUPLE_MASK", "(", "divider", ")", ")", ";", "if", "(", "busy_shift", "!=", "CCM_NO_BUSY_WAIT", ")", "{", "while", "(", "(", "CCM", "->", "CDHIPR", "&", "(", "(", "uint32_t", ")", "(", "1UL", "<<", "busy_shift", ")", ")", ")", "!=", "0UL", ")", "{", "}", "}", "}" ]
Duplicate implementation of CLOCK_SetDiv() provided by SDK.
[ "Duplicate", "implementation", "of", "CLOCK_SetDiv", "()", "provided", "by", "SDK", "." ]
[ "/* Clock switch need Handshake? */", "/* Wait until CCM internal handshake finish. */" ]
[ { "param": "divider", "type": "clock_div_t" }, { "param": "value", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "divider", "type": "clock_div_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
206d0f519941f596b22de09547719431891fb813
ParticleBeamHQ/zephyr
soc/arm/nxp_imx/rt/lpm_rt1064.c
[ "Apache-2.0" ]
C
clock_init_usb1_pll
void
static void clock_init_usb1_pll(const clock_usb_pll_config_t *config) { /* Bypass PLL first */ CCM_ANALOG->PLL_USB1 = (CCM_ANALOG->PLL_USB1 & (~CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC_MASK)) | CCM_ANALOG_PLL_USB1_BYPASS_MASK | CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC(config->src); CCM_ANALOG->PLL_USB1 = (CCM_ANALOG->PLL_USB1 & (~CCM_ANALOG_PLL_USB1_DIV_SELECT_MASK)) | CCM_ANALOG_PLL_USB1_ENABLE_MASK | CCM_ANALOG_PLL_USB1_POWER_MASK | CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK | CCM_ANALOG_PLL_USB1_DIV_SELECT(config->loopDivider); while ((CCM_ANALOG->PLL_USB1 & CCM_ANALOG_PLL_USB1_LOCK_MASK) == 0UL) { ; } /* Disable Bypass */ CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_BYPASS_MASK; }
/* * Duplicate implementation of CLOCK_InitUsb1Pll() provided by SDK. This function * must be linked to ITCM, as it will be used to change the clocks of the * FLEXSPI and SEMC peripherals. * Any function called from this function must also reside in ITCM */
Duplicate implementation of CLOCK_InitUsb1Pll() provided by SDK. This function must be linked to ITCM, as it will be used to change the clocks of the FLEXSPI and SEMC peripherals. Any function called from this function must also reside in ITCM
[ "Duplicate", "implementation", "of", "CLOCK_InitUsb1Pll", "()", "provided", "by", "SDK", ".", "This", "function", "must", "be", "linked", "to", "ITCM", "as", "it", "will", "be", "used", "to", "change", "the", "clocks", "of", "the", "FLEXSPI", "and", "SEMC", "peripherals", ".", "Any", "function", "called", "from", "this", "function", "must", "also", "reside", "in", "ITCM" ]
static void clock_init_usb1_pll(const clock_usb_pll_config_t *config) { CCM_ANALOG->PLL_USB1 = (CCM_ANALOG->PLL_USB1 & (~CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC_MASK)) | CCM_ANALOG_PLL_USB1_BYPASS_MASK | CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC(config->src); CCM_ANALOG->PLL_USB1 = (CCM_ANALOG->PLL_USB1 & (~CCM_ANALOG_PLL_USB1_DIV_SELECT_MASK)) | CCM_ANALOG_PLL_USB1_ENABLE_MASK | CCM_ANALOG_PLL_USB1_POWER_MASK | CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK | CCM_ANALOG_PLL_USB1_DIV_SELECT(config->loopDivider); while ((CCM_ANALOG->PLL_USB1 & CCM_ANALOG_PLL_USB1_LOCK_MASK) == 0UL) { ; } CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_BYPASS_MASK; }
[ "static", "void", "clock_init_usb1_pll", "(", "const", "clock_usb_pll_config_t", "*", "config", ")", "{", "CCM_ANALOG", "->", "PLL_USB1", "=", "(", "CCM_ANALOG", "->", "PLL_USB1", "&", "(", "~", "CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC_MASK", ")", ")", "|", "CCM_ANALOG_PLL_USB1_BYPASS_MASK", "|", "CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC", "(", "config", "->", "src", ")", ";", "CCM_ANALOG", "->", "PLL_USB1", "=", "(", "CCM_ANALOG", "->", "PLL_USB1", "&", "(", "~", "CCM_ANALOG_PLL_USB1_DIV_SELECT_MASK", ")", ")", "|", "CCM_ANALOG_PLL_USB1_ENABLE_MASK", "|", "CCM_ANALOG_PLL_USB1_POWER_MASK", "|", "CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK", "|", "CCM_ANALOG_PLL_USB1_DIV_SELECT", "(", "config", "->", "loopDivider", ")", ";", "while", "(", "(", "CCM_ANALOG", "->", "PLL_USB1", "&", "CCM_ANALOG_PLL_USB1_LOCK_MASK", ")", "==", "0UL", ")", "{", ";", "}", "CCM_ANALOG", "->", "PLL_USB1", "&=", "~", "CCM_ANALOG_PLL_USB1_BYPASS_MASK", ";", "}" ]
Duplicate implementation of CLOCK_InitUsb1Pll() provided by SDK.
[ "Duplicate", "implementation", "of", "CLOCK_InitUsb1Pll", "()", "provided", "by", "SDK", "." ]
[ "/* Bypass PLL first */", "/* Disable Bypass */" ]
[ { "param": "config", "type": "clock_usb_pll_config_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "config", "type": "clock_usb_pll_config_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_data_byte27
uint8_t
static inline uint8_t tlc5971_data_byte27(uint8_t control_data) { return FIELD_PREP(TLC5971_BYTE27_WRITE_CMD_MASK, TLC5971_WRITE_COMMAND) | FIELD_PREP(TLC5971_BYTE27_CTRL_MASK, control_data); }
/** * @brief create data byte 27 from control data * * @param control_data control bits * @return uint8_t the serialized data byte 27 */
@brief create data byte 27 from control data @param control_data control bits @return uint8_t the serialized data byte 27
[ "@brief", "create", "data", "byte", "27", "from", "control", "data", "@param", "control_data", "control", "bits", "@return", "uint8_t", "the", "serialized", "data", "byte", "27" ]
static inline uint8_t tlc5971_data_byte27(uint8_t control_data) { return FIELD_PREP(TLC5971_BYTE27_WRITE_CMD_MASK, TLC5971_WRITE_COMMAND) | FIELD_PREP(TLC5971_BYTE27_CTRL_MASK, control_data); }
[ "static", "inline", "uint8_t", "tlc5971_data_byte27", "(", "uint8_t", "control_data", ")", "{", "return", "FIELD_PREP", "(", "TLC5971_BYTE27_WRITE_CMD_MASK", ",", "TLC5971_WRITE_COMMAND", ")", "|", "FIELD_PREP", "(", "TLC5971_BYTE27_CTRL_MASK", ",", "control_data", ")", ";", "}" ]
@brief create data byte 27 from control data @param control_data control bits @return uint8_t the serialized data byte 27
[ "@brief", "create", "data", "byte", "27", "from", "control", "data", "@param", "control_data", "control", "bits", "@return", "uint8_t", "the", "serialized", "data", "byte", "27" ]
[]
[ { "param": "control_data", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "control_data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_data_byte26
uint8_t
static inline uint8_t tlc5971_data_byte26(uint8_t control_data, uint8_t gbc_color_1) { return FIELD_PREP(TLC5971_BYTE26_CTRL_MASK, control_data) | FIELD_PREP(TLC5971_BYTE26_GBC1_MASK, gbc_color_1 >> 2); }
/** * @brief create data byte 26 from control data and color 1 GBC * * @param control_data control bits * @param gbc_color_1 global brightness control for color 1 LEDs * @return uint8_t the serialized data byte 26 */
@brief create data byte 26 from control data and color 1 GBC @param control_data control bits @param gbc_color_1 global brightness control for color 1 LEDs @return uint8_t the serialized data byte 26
[ "@brief", "create", "data", "byte", "26", "from", "control", "data", "and", "color", "1", "GBC", "@param", "control_data", "control", "bits", "@param", "gbc_color_1", "global", "brightness", "control", "for", "color", "1", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "26" ]
static inline uint8_t tlc5971_data_byte26(uint8_t control_data, uint8_t gbc_color_1) { return FIELD_PREP(TLC5971_BYTE26_CTRL_MASK, control_data) | FIELD_PREP(TLC5971_BYTE26_GBC1_MASK, gbc_color_1 >> 2); }
[ "static", "inline", "uint8_t", "tlc5971_data_byte26", "(", "uint8_t", "control_data", ",", "uint8_t", "gbc_color_1", ")", "{", "return", "FIELD_PREP", "(", "TLC5971_BYTE26_CTRL_MASK", ",", "control_data", ")", "|", "FIELD_PREP", "(", "TLC5971_BYTE26_GBC1_MASK", ",", "gbc_color_1", ">>", "2", ")", ";", "}" ]
@brief create data byte 26 from control data and color 1 GBC @param control_data control bits @param gbc_color_1 global brightness control for color 1 LEDs @return uint8_t the serialized data byte 26
[ "@brief", "create", "data", "byte", "26", "from", "control", "data", "and", "color", "1", "GBC", "@param", "control_data", "control", "bits", "@param", "gbc_color_1", "global", "brightness", "control", "for", "color", "1", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "26" ]
[]
[ { "param": "control_data", "type": "uint8_t" }, { "param": "gbc_color_1", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "control_data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gbc_color_1", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_data_byte25
uint8_t
static inline uint8_t tlc5971_data_byte25(uint8_t gbc_color_1, uint8_t gbc_color_2) { return FIELD_PREP(TLC5971_BYTE25_GBC1_MASK, gbc_color_1 << 6) | FIELD_PREP(TLC5971_BYTE25_GBC2_MASK, gbc_color_2 >> 1); }
/** * @brief create data byte 25 from color 1 and 2 GBC * * @param gbc_color_1 global brightness control for color 1 LEDs * @param gbc_color_2 global brightness control for color 2 LEDs * @return uint8_t the serialized data byte 25 */
@brief create data byte 25 from color 1 and 2 GBC @param gbc_color_1 global brightness control for color 1 LEDs @param gbc_color_2 global brightness control for color 2 LEDs @return uint8_t the serialized data byte 25
[ "@brief", "create", "data", "byte", "25", "from", "color", "1", "and", "2", "GBC", "@param", "gbc_color_1", "global", "brightness", "control", "for", "color", "1", "LEDs", "@param", "gbc_color_2", "global", "brightness", "control", "for", "color", "2", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "25" ]
static inline uint8_t tlc5971_data_byte25(uint8_t gbc_color_1, uint8_t gbc_color_2) { return FIELD_PREP(TLC5971_BYTE25_GBC1_MASK, gbc_color_1 << 6) | FIELD_PREP(TLC5971_BYTE25_GBC2_MASK, gbc_color_2 >> 1); }
[ "static", "inline", "uint8_t", "tlc5971_data_byte25", "(", "uint8_t", "gbc_color_1", ",", "uint8_t", "gbc_color_2", ")", "{", "return", "FIELD_PREP", "(", "TLC5971_BYTE25_GBC1_MASK", ",", "gbc_color_1", "<<", "6", ")", "|", "FIELD_PREP", "(", "TLC5971_BYTE25_GBC2_MASK", ",", "gbc_color_2", ">>", "1", ")", ";", "}" ]
@brief create data byte 25 from color 1 and 2 GBC @param gbc_color_1 global brightness control for color 1 LEDs @param gbc_color_2 global brightness control for color 2 LEDs @return uint8_t the serialized data byte 25
[ "@brief", "create", "data", "byte", "25", "from", "color", "1", "and", "2", "GBC", "@param", "gbc_color_1", "global", "brightness", "control", "for", "color", "1", "LEDs", "@param", "gbc_color_2", "global", "brightness", "control", "for", "color", "2", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "25" ]
[]
[ { "param": "gbc_color_1", "type": "uint8_t" }, { "param": "gbc_color_2", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gbc_color_1", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gbc_color_2", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_data_byte24
uint8_t
static inline uint8_t tlc5971_data_byte24(uint8_t gbc_color_2, uint8_t gbc_color_3) { return FIELD_PREP(TLC5971_BYTE24_GBC2_MASK, gbc_color_2 << 7) | FIELD_PREP(TLC5971_BYTE24_GBC3_MASK, gbc_color_3); }
/** * @brief create data byte 24 from color 2 and 3 GBC * * @param gbc_color_2 global brightness control for color 2 LEDs * @param gbc_color_3 global brightness control for color 3 LEDs * @return uint8_t the serialized data byte 24 */
@brief create data byte 24 from color 2 and 3 GBC @param gbc_color_2 global brightness control for color 2 LEDs @param gbc_color_3 global brightness control for color 3 LEDs @return uint8_t the serialized data byte 24
[ "@brief", "create", "data", "byte", "24", "from", "color", "2", "and", "3", "GBC", "@param", "gbc_color_2", "global", "brightness", "control", "for", "color", "2", "LEDs", "@param", "gbc_color_3", "global", "brightness", "control", "for", "color", "3", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "24" ]
static inline uint8_t tlc5971_data_byte24(uint8_t gbc_color_2, uint8_t gbc_color_3) { return FIELD_PREP(TLC5971_BYTE24_GBC2_MASK, gbc_color_2 << 7) | FIELD_PREP(TLC5971_BYTE24_GBC3_MASK, gbc_color_3); }
[ "static", "inline", "uint8_t", "tlc5971_data_byte24", "(", "uint8_t", "gbc_color_2", ",", "uint8_t", "gbc_color_3", ")", "{", "return", "FIELD_PREP", "(", "TLC5971_BYTE24_GBC2_MASK", ",", "gbc_color_2", "<<", "7", ")", "|", "FIELD_PREP", "(", "TLC5971_BYTE24_GBC3_MASK", ",", "gbc_color_3", ")", ";", "}" ]
@brief create data byte 24 from color 2 and 3 GBC @param gbc_color_2 global brightness control for color 2 LEDs @param gbc_color_3 global brightness control for color 3 LEDs @return uint8_t the serialized data byte 24
[ "@brief", "create", "data", "byte", "24", "from", "color", "2", "and", "3", "GBC", "@param", "gbc_color_2", "global", "brightness", "control", "for", "color", "2", "LEDs", "@param", "gbc_color_3", "global", "brightness", "control", "for", "color", "3", "LEDs", "@return", "uint8_t", "the", "serialized", "data", "byte", "24" ]
[]
[ { "param": "gbc_color_2", "type": "uint8_t" }, { "param": "gbc_color_3", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gbc_color_2", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gbc_color_3", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_map_color
uint8_t
static uint8_t tlc5971_map_color(int color_id, const struct led_rgb *pixel_data) { uint8_t temp = 0; switch (color_id) { case LED_COLOR_ID_RED: temp = pixel_data->r; break; case LED_COLOR_ID_GREEN: temp = pixel_data->g; break; case LED_COLOR_ID_BLUE: temp = pixel_data->b; break; default: temp = 0; break; } return temp; }
/** * @brief map user colors to tlc5971 color order * * @param color_id color id from color mapping * @param pixel_data rgb data to be mapped * @return the mapped color value */
@brief map user colors to tlc5971 color order @param color_id color id from color mapping @param pixel_data rgb data to be mapped @return the mapped color value
[ "@brief", "map", "user", "colors", "to", "tlc5971", "color", "order", "@param", "color_id", "color", "id", "from", "color", "mapping", "@param", "pixel_data", "rgb", "data", "to", "be", "mapped", "@return", "the", "mapped", "color", "value" ]
static uint8_t tlc5971_map_color(int color_id, const struct led_rgb *pixel_data) { uint8_t temp = 0; switch (color_id) { case LED_COLOR_ID_RED: temp = pixel_data->r; break; case LED_COLOR_ID_GREEN: temp = pixel_data->g; break; case LED_COLOR_ID_BLUE: temp = pixel_data->b; break; default: temp = 0; break; } return temp; }
[ "static", "uint8_t", "tlc5971_map_color", "(", "int", "color_id", ",", "const", "struct", "led_rgb", "*", "pixel_data", ")", "{", "uint8_t", "temp", "=", "0", ";", "switch", "(", "color_id", ")", "{", "case", "LED_COLOR_ID_RED", ":", "temp", "=", "pixel_data", "->", "r", ";", "break", ";", "case", "LED_COLOR_ID_GREEN", ":", "temp", "=", "pixel_data", "->", "g", ";", "break", ";", "case", "LED_COLOR_ID_BLUE", ":", "temp", "=", "pixel_data", "->", "b", ";", "break", ";", "default", ":", "temp", "=", "0", ";", "break", ";", "}", "return", "temp", ";", "}" ]
@brief map user colors to tlc5971 color order @param color_id color id from color mapping @param pixel_data rgb data to be mapped @return the mapped color value
[ "@brief", "map", "user", "colors", "to", "tlc5971", "color", "order", "@param", "color_id", "color", "id", "from", "color", "mapping", "@param", "pixel_data", "rgb", "data", "to", "be", "mapped", "@return", "the", "mapped", "color", "value" ]
[]
[ { "param": "color_id", "type": "int" }, { "param": "pixel_data", "type": "struct led_rgb" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "color_id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pixel_data", "type": "struct led_rgb", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8c4980342006791f74b25ff0f794514354c1d9a
ParticleBeamHQ/zephyr
drivers/led_strip/tlc5971.c
[ "Apache-2.0" ]
C
tlc5971_fill_data_buffer
void
static void tlc5971_fill_data_buffer(const struct device *dev, struct led_rgb *pixels, size_t num_pixels) { const struct tlc5971_config *cfg = dev->config; struct tlc5971_data *data = dev->data; uint8_t *data_buffer = data->data_buffer; int count = 0; /* * tlc5971 device order is reversed as the rgb data for the last device in the daisy chain * should be transmitted first. */ for (int device = (num_pixels / TLC5971_PIXELS_PER_DEVICE) - 1; device >= 0; device--) { /* * The SPI frame format expects a BGR color order for the global brightness control * values, but since the led_strip API allows custom color mappings, we simply use * color_x terms to keep things generic. */ data_buffer[count++] = tlc5971_data_byte27(data->control_data); data_buffer[count++] = tlc5971_data_byte26(data->control_data, data->gbc_color_1); data_buffer[count++] = tlc5971_data_byte25(data->gbc_color_1, data->gbc_color_2); data_buffer[count++] = tlc5971_data_byte24(data->gbc_color_2, data->gbc_color_3); for (int pixel = (TLC5971_PIXELS_PER_DEVICE - 1); pixel >= 0; pixel--) { /* data is "reversed" so RGB0 comes last, i.e at byte 0 */ const struct led_rgb *pixel_data = &pixels[(device * TLC5971_PIXELS_PER_DEVICE) + pixel]; /* * Convert pixel data into SPI frames, mapping user colors to tlc5971 * data frame color order (BGR). */ for (int color = 0; color < cfg->num_colors; color++) { uint8_t temp = tlc5971_map_color(cfg->color_mapping[color], pixel_data); /* * The tlc5971 rgb values are 16 bit but zephyr's rgb values are * 8 bit. Simply upscale to 16 bit by using the 8 bit value for both * LSB and MSB of the 16 bit word. */ data_buffer[count++] = temp; data_buffer[count++] = temp; } } } }
/** * @brief serialize control data and pixel data for device daisy chain * * the serializer only supports "full" devices, meaning each device is expected * to be mounted with all 4 LEDs. * * @param dev device pointer * @param pixels pixel RGB data for daisy chain * @param num_pixels number of pixels in daisy chain */
@brief serialize control data and pixel data for device daisy chain the serializer only supports "full" devices, meaning each device is expected to be mounted with all 4 LEDs. @param dev device pointer @param pixels pixel RGB data for daisy chain @param num_pixels number of pixels in daisy chain
[ "@brief", "serialize", "control", "data", "and", "pixel", "data", "for", "device", "daisy", "chain", "the", "serializer", "only", "supports", "\"", "full", "\"", "devices", "meaning", "each", "device", "is", "expected", "to", "be", "mounted", "with", "all", "4", "LEDs", ".", "@param", "dev", "device", "pointer", "@param", "pixels", "pixel", "RGB", "data", "for", "daisy", "chain", "@param", "num_pixels", "number", "of", "pixels", "in", "daisy", "chain" ]
static void tlc5971_fill_data_buffer(const struct device *dev, struct led_rgb *pixels, size_t num_pixels) { const struct tlc5971_config *cfg = dev->config; struct tlc5971_data *data = dev->data; uint8_t *data_buffer = data->data_buffer; int count = 0; for (int device = (num_pixels / TLC5971_PIXELS_PER_DEVICE) - 1; device >= 0; device--) { data_buffer[count++] = tlc5971_data_byte27(data->control_data); data_buffer[count++] = tlc5971_data_byte26(data->control_data, data->gbc_color_1); data_buffer[count++] = tlc5971_data_byte25(data->gbc_color_1, data->gbc_color_2); data_buffer[count++] = tlc5971_data_byte24(data->gbc_color_2, data->gbc_color_3); for (int pixel = (TLC5971_PIXELS_PER_DEVICE - 1); pixel >= 0; pixel--) { const struct led_rgb *pixel_data = &pixels[(device * TLC5971_PIXELS_PER_DEVICE) + pixel]; for (int color = 0; color < cfg->num_colors; color++) { uint8_t temp = tlc5971_map_color(cfg->color_mapping[color], pixel_data); data_buffer[count++] = temp; data_buffer[count++] = temp; } } } }
[ "static", "void", "tlc5971_fill_data_buffer", "(", "const", "struct", "device", "*", "dev", ",", "struct", "led_rgb", "*", "pixels", ",", "size_t", "num_pixels", ")", "{", "const", "struct", "tlc5971_config", "*", "cfg", "=", "dev", "->", "config", ";", "struct", "tlc5971_data", "*", "data", "=", "dev", "->", "data", ";", "uint8_t", "*", "data_buffer", "=", "data", "->", "data_buffer", ";", "int", "count", "=", "0", ";", "for", "(", "int", "device", "=", "(", "num_pixels", "/", "TLC5971_PIXELS_PER_DEVICE", ")", "-", "1", ";", "device", ">=", "0", ";", "device", "--", ")", "{", "data_buffer", "[", "count", "++", "]", "=", "tlc5971_data_byte27", "(", "data", "->", "control_data", ")", ";", "data_buffer", "[", "count", "++", "]", "=", "tlc5971_data_byte26", "(", "data", "->", "control_data", ",", "data", "->", "gbc_color_1", ")", ";", "data_buffer", "[", "count", "++", "]", "=", "tlc5971_data_byte25", "(", "data", "->", "gbc_color_1", ",", "data", "->", "gbc_color_2", ")", ";", "data_buffer", "[", "count", "++", "]", "=", "tlc5971_data_byte24", "(", "data", "->", "gbc_color_2", ",", "data", "->", "gbc_color_3", ")", ";", "for", "(", "int", "pixel", "=", "(", "TLC5971_PIXELS_PER_DEVICE", "-", "1", ")", ";", "pixel", ">=", "0", ";", "pixel", "--", ")", "{", "const", "struct", "led_rgb", "*", "pixel_data", "=", "&", "pixels", "[", "(", "device", "*", "TLC5971_PIXELS_PER_DEVICE", ")", "+", "pixel", "]", ";", "for", "(", "int", "color", "=", "0", ";", "color", "<", "cfg", "->", "num_colors", ";", "color", "++", ")", "{", "uint8_t", "temp", "=", "tlc5971_map_color", "(", "cfg", "->", "color_mapping", "[", "color", "]", ",", "pixel_data", ")", ";", "data_buffer", "[", "count", "++", "]", "=", "temp", ";", "data_buffer", "[", "count", "++", "]", "=", "temp", ";", "}", "}", "}", "}" ]
@brief serialize control data and pixel data for device daisy chain the serializer only supports "full" devices, meaning each device is expected to be mounted with all 4 LEDs.
[ "@brief", "serialize", "control", "data", "and", "pixel", "data", "for", "device", "daisy", "chain", "the", "serializer", "only", "supports", "\"", "full", "\"", "devices", "meaning", "each", "device", "is", "expected", "to", "be", "mounted", "with", "all", "4", "LEDs", "." ]
[ "/*\n\t * tlc5971 device order is reversed as the rgb data for the last device in the daisy chain\n\t * should be transmitted first.\n\t */", "/*\n\t\t * The SPI frame format expects a BGR color order for the global brightness control\n\t\t * values, but since the led_strip API allows custom color mappings, we simply use\n\t\t * color_x terms to keep things generic.\n\t\t */", "/* data is \"reversed\" so RGB0 comes last, i.e at byte 0 */", "/*\n\t\t\t * Convert pixel data into SPI frames, mapping user colors to tlc5971\n\t\t\t * data frame color order (BGR).\n\t\t\t */", "/*\n\t\t\t\t * The tlc5971 rgb values are 16 bit but zephyr's rgb values are\n\t\t\t\t * 8 bit. Simply upscale to 16 bit by using the 8 bit value for both\n\t\t\t\t * LSB and MSB of the 16 bit word.\n\t\t\t\t */" ]
[ { "param": "dev", "type": "struct device" }, { "param": "pixels", "type": "struct led_rgb" }, { "param": "num_pixels", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dev", "type": "struct device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pixels", "type": "struct led_rgb", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_pixels", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
04f6b76c245c7ae18726823c036ec9cb01bb9ad6
ParticleBeamHQ/zephyr
drivers/modem/modem_cmd_handler.c
[ "Apache-2.0" ]
C
process_cmd
int
static int process_cmd(const struct modem_cmd *cmd, size_t match_len, struct modem_cmd_handler_data *data) { int parsed_len = 0, ret = 0; uint8_t *argv[CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT]; uint16_t argc = 0U; /* reset params */ memset(argv, 0, sizeof(argv[0]) * ARRAY_SIZE(argv)); /* do we need to parse arguments? */ if (cmd->arg_count_max > 0U) { /* returns < 0 on error and > 0 for parsed len */ parsed_len = parse_params(data, match_len, cmd, argv, ARRAY_SIZE(argv), &argc); if (parsed_len < 0) { return parsed_len; } } /* skip cmd_len + parsed len */ data->rx_buf = net_buf_skip(data->rx_buf, cmd->cmd_len + parsed_len); /* call handler */ if (cmd->func) { ret = cmd->func(data, match_len - cmd->cmd_len - parsed_len, argv, argc); if (ret == -EAGAIN) { /* wait for more data */ net_buf_push(data->rx_buf, cmd->cmd_len + parsed_len); } } return ret; }
/* process a "matched" command */
process a "matched" command
[ "process", "a", "\"", "matched", "\"", "command" ]
static int process_cmd(const struct modem_cmd *cmd, size_t match_len, struct modem_cmd_handler_data *data) { int parsed_len = 0, ret = 0; uint8_t *argv[CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT]; uint16_t argc = 0U; memset(argv, 0, sizeof(argv[0]) * ARRAY_SIZE(argv)); if (cmd->arg_count_max > 0U) { parsed_len = parse_params(data, match_len, cmd, argv, ARRAY_SIZE(argv), &argc); if (parsed_len < 0) { return parsed_len; } } data->rx_buf = net_buf_skip(data->rx_buf, cmd->cmd_len + parsed_len); if (cmd->func) { ret = cmd->func(data, match_len - cmd->cmd_len - parsed_len, argv, argc); if (ret == -EAGAIN) { net_buf_push(data->rx_buf, cmd->cmd_len + parsed_len); } } return ret; }
[ "static", "int", "process_cmd", "(", "const", "struct", "modem_cmd", "*", "cmd", ",", "size_t", "match_len", ",", "struct", "modem_cmd_handler_data", "*", "data", ")", "{", "int", "parsed_len", "=", "0", ",", "ret", "=", "0", ";", "uint8_t", "*", "argv", "[", "CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT", "]", ";", "uint16_t", "argc", "=", "0U", ";", "memset", "(", "argv", ",", "0", ",", "sizeof", "(", "argv", "[", "0", "]", ")", "*", "ARRAY_SIZE", "(", "argv", ")", ")", ";", "if", "(", "cmd", "->", "arg_count_max", ">", "0U", ")", "{", "parsed_len", "=", "parse_params", "(", "data", ",", "match_len", ",", "cmd", ",", "argv", ",", "ARRAY_SIZE", "(", "argv", ")", ",", "&", "argc", ")", ";", "if", "(", "parsed_len", "<", "0", ")", "{", "return", "parsed_len", ";", "}", "}", "data", "->", "rx_buf", "=", "net_buf_skip", "(", "data", "->", "rx_buf", ",", "cmd", "->", "cmd_len", "+", "parsed_len", ")", ";", "if", "(", "cmd", "->", "func", ")", "{", "ret", "=", "cmd", "->", "func", "(", "data", ",", "match_len", "-", "cmd", "->", "cmd_len", "-", "parsed_len", ",", "argv", ",", "argc", ")", ";", "if", "(", "ret", "==", "-", "EAGAIN", ")", "{", "net_buf_push", "(", "data", "->", "rx_buf", ",", "cmd", "->", "cmd_len", "+", "parsed_len", ")", ";", "}", "}", "return", "ret", ";", "}" ]
process a "matched" command
[ "process", "a", "\"", "matched", "\"", "command" ]
[ "/* reset params */", "/* do we need to parse arguments? */", "/* returns < 0 on error and > 0 for parsed len */", "/* skip cmd_len + parsed len */", "/* call handler */", "/* wait for more data */" ]
[ { "param": "cmd", "type": "struct modem_cmd" }, { "param": "match_len", "type": "size_t" }, { "param": "data", "type": "struct modem_cmd_handler_data" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "struct modem_cmd", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "match_len", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "struct modem_cmd_handler_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }