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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c8877f0e0cee518bc23d56a6809d95dd088e64ce | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/LSM6DS3_TiltDetection/Src/main.c | [
"MIT"
] | C | Error_Handler | void | void Error_Handler( void )
{
while (1)
{}
} | /**
* @brief This function is executed in case of error occurrence
* @param None
* @retval None
*/ | @brief This function is executed in case of error occurrence
@param None
@retval None | [
"@brief",
"This",
"function",
"is",
"executed",
"in",
"case",
"of",
"error",
"occurrence",
"@param",
"None",
"@retval",
"None"
] | void Error_Handler( void )
{
while (1)
{}
} | [
"void",
"Error_Handler",
"(",
"void",
")",
"{",
"while",
"(",
"1",
")",
"{",
"}",
"}"
] | @brief This function is executed in case of error occurrence
@param None
@retval None | [
"@brief",
"This",
"function",
"is",
"executed",
"in",
"case",
"of",
"error",
"occurrence",
"@param",
"None",
"@retval",
"None"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c8877f0e0cee518bc23d56a6809d95dd088e64ce | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/LSM6DS3_TiltDetection/Src/main.c | [
"MIT"
] | C | assert_failed | void | void assert_failed( uint8_t* file, uint32_t line )
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{}
} | /**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/ | @brief Reports the name of the source file and the source line number
where the assert_param error has occurred
@param file: pointer to the source file name
@param line: assert_param error line source number
@retval None | [
"@brief",
"Reports",
"the",
"name",
"of",
"the",
"source",
"file",
"and",
"the",
"source",
"line",
"number",
"where",
"the",
"assert_param",
"error",
"has",
"occurred",
"@param",
"file",
":",
"pointer",
"to",
"the",
"source",
"file",
"name",
"@param",
"line",
":",
"assert_param",
"error",
"line",
"source",
"number",
"@retval",
"None"
] | void assert_failed( uint8_t* file, uint32_t line )
{
while (1)
{}
} | [
"void",
"assert_failed",
"(",
"uint8_t",
"*",
"file",
",",
"uint32_t",
"line",
")",
"{",
"while",
"(",
"1",
")",
"{",
"}",
"}"
] | @brief Reports the name of the source file and the source line number
where the assert_param error has occurred
@param file: pointer to the source file name
@param line: assert_param error line source number
@retval None | [
"@brief",
"Reports",
"the",
"name",
"of",
"the",
"source",
"file",
"and",
"the",
"source",
"line",
"number",
"where",
"the",
"assert_param",
"error",
"has",
"occurred",
"@param",
"file",
":",
"pointer",
"to",
"the",
"source",
"file",
"name",
"@param",
"line",
":",
"assert_param",
"error",
"line",
"source",
"number",
"@retval",
"None"
] | [
"/* User can add his own implementation to report the file name and line number,\r\n ex: printf(\"Wrong parameters value: file %s on line %d\\r\\n\", file, line) */",
"/* Infinite loop */"
] | [
{
"param": "file",
"type": "uint8_t"
},
{
"param": "line",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5a190cdea9c299515418dba0c1aa3a6c593cfa73 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/DemoDatalog.c | [
"MIT"
] | C | SaveCalibrationToMemory | void | void SaveCalibrationToMemory(uint16_t dataSize, uint32_t *data)
{
uint32_t Address = MOTION_TL_FLASH_ADD;
/* Reset Before The data in Memory */
ResetCalibrationInMemory();
/* Unlock the Flash to enable the flash control register access */
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
uint32_t word;
for (int nword = 0; nword < dataSize; nword++)
{
word = *(data + nword);
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address, word) == HAL_OK)
{
Address += 4;
}
else
{
Error_Handler();
}
}
#elif (defined (USE_STM32L4XX_NUCLEO))
uint64_t lword, hword;
for (int nword = 0; nword < dataSize; nword += 2)
{
lword = *(data + nword);
if ((nword + 1) < dataSize)
{
hword = (uint64_t)(*(data + nword + 1)) << 32;
}
else
{
hword = 0;
}
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, hword | lword) == HAL_OK)
{
Address += 8;
}
else
{
Error_Handler();
}
}
#else
#error Not supported platform
#endif
HAL_FLASH_Lock();
} | /**
* @brief Save the calibration values to memory
* @param None
* @retval None
*/ | @brief Save the calibration values to memory
@param None
@retval None | [
"@brief",
"Save",
"the",
"calibration",
"values",
"to",
"memory",
"@param",
"None",
"@retval",
"None"
] | void SaveCalibrationToMemory(uint16_t dataSize, uint32_t *data)
{
uint32_t Address = MOTION_TL_FLASH_ADD;
ResetCalibrationInMemory();
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
uint32_t word;
for (int nword = 0; nword < dataSize; nword++)
{
word = *(data + nword);
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address, word) == HAL_OK)
{
Address += 4;
}
else
{
Error_Handler();
}
}
#elif (defined (USE_STM32L4XX_NUCLEO))
uint64_t lword, hword;
for (int nword = 0; nword < dataSize; nword += 2)
{
lword = *(data + nword);
if ((nword + 1) < dataSize)
{
hword = (uint64_t)(*(data + nword + 1)) << 32;
}
else
{
hword = 0;
}
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, hword | lword) == HAL_OK)
{
Address += 8;
}
else
{
Error_Handler();
}
}
#else
#error Not supported platform
#endif
HAL_FLASH_Lock();
} | [
"void",
"SaveCalibrationToMemory",
"(",
"uint16_t",
"dataSize",
",",
"uint32_t",
"*",
"data",
")",
"{",
"uint32_t",
"Address",
"=",
"MOTION_TL_FLASH_ADD",
";",
"ResetCalibrationInMemory",
"(",
")",
";",
"HAL_FLASH_Unlock",
"(",
")",
";",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"uint32_t",
"word",
";",
"for",
"(",
"int",
"nword",
"=",
"0",
";",
"nword",
"<",
"dataSize",
";",
"nword",
"++",
")",
"{",
"word",
"=",
"*",
"(",
"data",
"+",
"nword",
")",
";",
"if",
"(",
"HAL_FLASH_Program",
"(",
"TYPEPROGRAM_WORD",
",",
"Address",
",",
"word",
")",
"==",
"HAL_OK",
")",
"{",
"Address",
"+=",
"4",
";",
"}",
"else",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"uint64_t",
"lword",
",",
"hword",
";",
"for",
"(",
"int",
"nword",
"=",
"0",
";",
"nword",
"<",
"dataSize",
";",
"nword",
"+=",
"2",
")",
"{",
"lword",
"=",
"*",
"(",
"data",
"+",
"nword",
")",
";",
"if",
"(",
"(",
"nword",
"+",
"1",
")",
"<",
"dataSize",
")",
"{",
"hword",
"=",
"(",
"uint64_t",
")",
"(",
"*",
"(",
"data",
"+",
"nword",
"+",
"1",
")",
")",
"<<",
"32",
";",
"}",
"else",
"{",
"hword",
"=",
"0",
";",
"}",
"if",
"(",
"HAL_FLASH_Program",
"(",
"FLASH_TYPEPROGRAM_DOUBLEWORD",
",",
"Address",
",",
"hword",
"|",
"lword",
")",
"==",
"HAL_OK",
")",
"{",
"Address",
"+=",
"8",
";",
"}",
"else",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"HAL_FLASH_Lock",
"(",
")",
";",
"}"
] | @brief Save the calibration values to memory
@param None
@retval None | [
"@brief",
"Save",
"the",
"calibration",
"values",
"to",
"memory",
"@param",
"None",
"@retval",
"None"
] | [
"/* Reset Before The data in Memory */",
"/* Unlock the Flash to enable the flash control register access */"
] | [
{
"param": "dataSize",
"type": "uint16_t"
},
{
"param": "data",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dataSize",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5a190cdea9c299515418dba0c1aa3a6c593cfa73 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/DemoDatalog.c | [
"MIT"
] | C | ResetCalibrationInMemory | void | void ResetCalibrationInMemory(void)
{
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t SectorError = 0;
#if (defined (USE_STM32F4XX_NUCLEO))
EraseInitStruct.TypeErase = TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3;
EraseInitStruct.Sector = MOTION_TL_FLASH_SECTOR;
EraseInitStruct.NbSectors = 1;
#elif (defined (USE_STM32L4XX_NUCLEO))
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = GetBank(MOTION_TL_FLASH_ADD);
EraseInitStruct.Page = GetPage(MOTION_TL_FLASH_ADD);
EraseInitStruct.NbPages = 1;
#else
#error Not supported platform
#endif
/* Unlock the Flash to enable the flash control register access */
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
/* Clear pending flags (if any) */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
#elif (defined (USE_STM32L4XX_NUCLEO))
/* Clear pending flags (if any) */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
#else
#error Not supported platform
#endif
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK)
{
Error_Handler();
}
/* Lock the Flash to disable the flash control register access */
HAL_FLASH_Lock();
} | /**
* @brief Reset the calibration values in memory
* @param None
* @retval None
*/ | @brief Reset the calibration values in memory
@param None
@retval None | [
"@brief",
"Reset",
"the",
"calibration",
"values",
"in",
"memory",
"@param",
"None",
"@retval",
"None"
] | void ResetCalibrationInMemory(void)
{
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t SectorError = 0;
#if (defined (USE_STM32F4XX_NUCLEO))
EraseInitStruct.TypeErase = TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3;
EraseInitStruct.Sector = MOTION_TL_FLASH_SECTOR;
EraseInitStruct.NbSectors = 1;
#elif (defined (USE_STM32L4XX_NUCLEO))
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = GetBank(MOTION_TL_FLASH_ADD);
EraseInitStruct.Page = GetPage(MOTION_TL_FLASH_ADD);
EraseInitStruct.NbPages = 1;
#else
#error Not supported platform
#endif
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
#elif (defined (USE_STM32L4XX_NUCLEO))
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
#else
#error Not supported platform
#endif
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK)
{
Error_Handler();
}
HAL_FLASH_Lock();
} | [
"void",
"ResetCalibrationInMemory",
"(",
"void",
")",
"{",
"FLASH_EraseInitTypeDef",
"EraseInitStruct",
";",
"uint32_t",
"SectorError",
"=",
"0",
";",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"EraseInitStruct",
".",
"TypeErase",
"=",
"TYPEERASE_SECTORS",
";",
"EraseInitStruct",
".",
"VoltageRange",
"=",
"VOLTAGE_RANGE_3",
";",
"EraseInitStruct",
".",
"Sector",
"=",
"MOTION_TL_FLASH_SECTOR",
";",
"EraseInitStruct",
".",
"NbSectors",
"=",
"1",
";",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"EraseInitStruct",
".",
"TypeErase",
"=",
"FLASH_TYPEERASE_PAGES",
";",
"EraseInitStruct",
".",
"Banks",
"=",
"GetBank",
"(",
"MOTION_TL_FLASH_ADD",
")",
";",
"EraseInitStruct",
".",
"Page",
"=",
"GetPage",
"(",
"MOTION_TL_FLASH_ADD",
")",
";",
"EraseInitStruct",
".",
"NbPages",
"=",
"1",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"HAL_FLASH_Unlock",
"(",
")",
";",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"__HAL_FLASH_CLEAR_FLAG",
"(",
"FLASH_FLAG_EOP",
"|",
"FLASH_FLAG_OPERR",
"|",
"FLASH_FLAG_WRPERR",
"|",
"FLASH_FLAG_PGAERR",
"|",
"FLASH_FLAG_PGPERR",
"|",
"FLASH_FLAG_PGSERR",
")",
";",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"__HAL_FLASH_CLEAR_FLAG",
"(",
"FLASH_FLAG_ALL_ERRORS",
")",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"if",
"(",
"HAL_FLASHEx_Erase",
"(",
"&",
"EraseInitStruct",
",",
"&",
"SectorError",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"HAL_FLASH_Lock",
"(",
")",
";",
"}"
] | @brief Reset the calibration values in memory
@param None
@retval None | [
"@brief",
"Reset",
"the",
"calibration",
"values",
"in",
"memory",
"@param",
"None",
"@retval",
"None"
] | [
"/* Unlock the Flash to enable the flash control register access */",
"/* Clear pending flags (if any) */",
"/* Clear pending flags (if any) */",
"/* Lock the Flash to disable the flash control register access */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2b49482c5dc867c3389df0c49081b05027deeaaa | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/DataLogExtended/Src/sensor_commands.c | [
"MIT"
] | C | Handle_Sensor_command | int | int Handle_Sensor_command(TMsg *Msg)
{
/* Commands */
switch (Msg->Data[3])
{
case SC_GET_SENSOR_NAME:
return SC_Get_Sensor_Name(Msg);
case SC_READ_REGISTER:
return SC_Read_Register(Msg);
case SC_WRITE_REGISTER:
return SC_Write_Register(Msg);
case SC_GET_FULL_SCALE_LIST:
return SC_Get_Full_Scale_List(Msg);
case SC_SET_FULL_SCALE:
return SC_Set_Full_Scale(Msg);
case SC_GET_ODR_LIST:
return SC_Get_ODR_List(Msg);
case SC_SET_ODR:
return SC_Set_ODR(Msg);
default:
return 0;
}
} | /**
* @brief Handle Sensors command
* @param Msg the pointer to the message to be handled
* @retval 1 if the message is correctly handled, 0 otherwise
*/ | @brief Handle Sensors command
@param Msg the pointer to the message to be handled
@retval 1 if the message is correctly handled, 0 otherwise | [
"@brief",
"Handle",
"Sensors",
"command",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"handled",
"@retval",
"1",
"if",
"the",
"message",
"is",
"correctly",
"handled",
"0",
"otherwise"
] | int Handle_Sensor_command(TMsg *Msg)
{
switch (Msg->Data[3])
{
case SC_GET_SENSOR_NAME:
return SC_Get_Sensor_Name(Msg);
case SC_READ_REGISTER:
return SC_Read_Register(Msg);
case SC_WRITE_REGISTER:
return SC_Write_Register(Msg);
case SC_GET_FULL_SCALE_LIST:
return SC_Get_Full_Scale_List(Msg);
case SC_SET_FULL_SCALE:
return SC_Set_Full_Scale(Msg);
case SC_GET_ODR_LIST:
return SC_Get_ODR_List(Msg);
case SC_SET_ODR:
return SC_Set_ODR(Msg);
default:
return 0;
}
} | [
"int",
"Handle_Sensor_command",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"switch",
"(",
"Msg",
"->",
"Data",
"[",
"3",
"]",
")",
"{",
"case",
"SC_GET_SENSOR_NAME",
":",
"return",
"SC_Get_Sensor_Name",
"(",
"Msg",
")",
";",
"case",
"SC_READ_REGISTER",
":",
"return",
"SC_Read_Register",
"(",
"Msg",
")",
";",
"case",
"SC_WRITE_REGISTER",
":",
"return",
"SC_Write_Register",
"(",
"Msg",
")",
";",
"case",
"SC_GET_FULL_SCALE_LIST",
":",
"return",
"SC_Get_Full_Scale_List",
"(",
"Msg",
")",
";",
"case",
"SC_SET_FULL_SCALE",
":",
"return",
"SC_Set_Full_Scale",
"(",
"Msg",
")",
";",
"case",
"SC_GET_ODR_LIST",
":",
"return",
"SC_Get_ODR_List",
"(",
"Msg",
")",
";",
"case",
"SC_SET_ODR",
":",
"return",
"SC_Set_ODR",
"(",
"Msg",
")",
";",
"default",
":",
"return",
"0",
";",
"}",
"}"
] | @brief Handle Sensors command
@param Msg the pointer to the message to be handled
@retval 1 if the message is correctly handled, 0 otherwise | [
"@brief",
"Handle",
"Sensors",
"command",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"handled",
"@retval",
"1",
"if",
"the",
"message",
"is",
"correctly",
"handled",
"0",
"otherwise"
] | [
"/* Commands */"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9de0ef95e870a5dacae000c6741237b7e6f39ac4 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/LSM6DS3_SelfTest/Src/cube_hal_l0.c | [
"MIT"
] | C | SystemClock_Config | void | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 0x10;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
__SYSCFG_CLK_ENABLE();
} | /**
* @brief System Clock Configuration
* @param None
* @retval None
*/ | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 0x10;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
__SYSCFG_CLK_ENABLE();
} | [
"void",
"SystemClock_Config",
"(",
"void",
")",
"{",
"RCC_ClkInitTypeDef",
"RCC_ClkInitStruct",
";",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
";",
"__PWR_CLK_ENABLE",
"(",
")",
";",
"__HAL_PWR_VOLTAGESCALING_CONFIG",
"(",
"PWR_REGULATOR_VOLTAGE_SCALE1",
")",
";",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_HSI",
";",
"RCC_OscInitStruct",
".",
"HSIState",
"=",
"RCC_HSI_ON",
";",
"RCC_OscInitStruct",
".",
"HSICalibrationValue",
"=",
"0x10",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_ON",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLSource",
"=",
"RCC_PLLSOURCE_HSI",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLMUL",
"=",
"RCC_PLLMUL_4",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLDIV",
"=",
"RCC_PLLDIV_2",
";",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
";",
"RCC_ClkInitStruct",
".",
"ClockType",
"=",
"(",
"RCC_CLOCKTYPE_SYSCLK",
"|",
"RCC_CLOCKTYPE_HCLK",
"|",
"RCC_CLOCKTYPE_PCLK1",
"|",
"RCC_CLOCKTYPE_PCLK2",
")",
";",
"RCC_ClkInitStruct",
".",
"SYSCLKSource",
"=",
"RCC_SYSCLKSOURCE_PLLCLK",
";",
"RCC_ClkInitStruct",
".",
"AHBCLKDivider",
"=",
"RCC_SYSCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB1CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB2CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"HAL_RCC_ClockConfig",
"(",
"&",
"RCC_ClkInitStruct",
",",
"FLASH_LATENCY_1",
")",
";",
"__SYSCFG_CLK_ENABLE",
"(",
")",
";",
"}"
] | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5967e9e2f309c199eff6910fa53f2d71b22537b9 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/MotionAC_Manager.c | [
"MIT"
] | C | MotionAC_manager_compensate | void | void MotionAC_manager_compensate(SensorAxes_t* DataIn, SensorAxes_t* DataOut)
{
MAC_output_t acc_calib;
MotionAC_GetCalParams(&acc_calib);
DataOut->AXIS_X = (int32_t) ((DataIn->AXIS_X - acc_bias_to_mg(acc_calib.AccBias[0])) * acc_calib.SF_Matrix[0][0]);
DataOut->AXIS_Y = (int32_t) ((DataIn->AXIS_Y - acc_bias_to_mg(acc_calib.AccBias[1])) * acc_calib.SF_Matrix[1][1]);
DataOut->AXIS_Z = (int32_t) ((DataIn->AXIS_Z - acc_bias_to_mg(acc_calib.AccBias[2])) * acc_calib.SF_Matrix[2][2]);
} | /**
* @brief Do offset & scale factor calibration
* @param dataIn raw accelerometer data
* @param dataOut calibrated data
* @retval none
*/ | @brief Do offset & scale factor calibration
@param dataIn raw accelerometer data
@param dataOut calibrated data
@retval none | [
"@brief",
"Do",
"offset",
"&",
"scale",
"factor",
"calibration",
"@param",
"dataIn",
"raw",
"accelerometer",
"data",
"@param",
"dataOut",
"calibrated",
"data",
"@retval",
"none"
] | void MotionAC_manager_compensate(SensorAxes_t* DataIn, SensorAxes_t* DataOut)
{
MAC_output_t acc_calib;
MotionAC_GetCalParams(&acc_calib);
DataOut->AXIS_X = (int32_t) ((DataIn->AXIS_X - acc_bias_to_mg(acc_calib.AccBias[0])) * acc_calib.SF_Matrix[0][0]);
DataOut->AXIS_Y = (int32_t) ((DataIn->AXIS_Y - acc_bias_to_mg(acc_calib.AccBias[1])) * acc_calib.SF_Matrix[1][1]);
DataOut->AXIS_Z = (int32_t) ((DataIn->AXIS_Z - acc_bias_to_mg(acc_calib.AccBias[2])) * acc_calib.SF_Matrix[2][2]);
} | [
"void",
"MotionAC_manager_compensate",
"(",
"SensorAxes_t",
"*",
"DataIn",
",",
"SensorAxes_t",
"*",
"DataOut",
")",
"{",
"MAC_output_t",
"acc_calib",
";",
"MotionAC_GetCalParams",
"(",
"&",
"acc_calib",
")",
";",
"DataOut",
"->",
"AXIS_X",
"=",
"(",
"int32_t",
")",
"(",
"(",
"DataIn",
"->",
"AXIS_X",
"-",
"acc_bias_to_mg",
"(",
"acc_calib",
".",
"AccBias",
"[",
"0",
"]",
")",
")",
"*",
"acc_calib",
".",
"SF_Matrix",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"DataOut",
"->",
"AXIS_Y",
"=",
"(",
"int32_t",
")",
"(",
"(",
"DataIn",
"->",
"AXIS_Y",
"-",
"acc_bias_to_mg",
"(",
"acc_calib",
".",
"AccBias",
"[",
"1",
"]",
")",
")",
"*",
"acc_calib",
".",
"SF_Matrix",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"DataOut",
"->",
"AXIS_Z",
"=",
"(",
"int32_t",
")",
"(",
"(",
"DataIn",
"->",
"AXIS_Z",
"-",
"acc_bias_to_mg",
"(",
"acc_calib",
".",
"AccBias",
"[",
"2",
"]",
")",
")",
"*",
"acc_calib",
".",
"SF_Matrix",
"[",
"2",
"]",
"[",
"2",
"]",
")",
";",
"}"
] | @brief Do offset & scale factor calibration
@param dataIn raw accelerometer data
@param dataOut calibrated data
@retval none | [
"@brief",
"Do",
"offset",
"&",
"scale",
"factor",
"calibration",
"@param",
"dataIn",
"raw",
"accelerometer",
"data",
"@param",
"dataOut",
"calibrated",
"data",
"@retval",
"none"
] | [] | [
{
"param": "DataIn",
"type": "SensorAxes_t"
},
{
"param": "DataOut",
"type": "SensorAxes_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DataIn",
"type": "SensorAxes_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "DataOut",
"type": "SensorAxes_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | MX_TIM_GC_Init | void | static void MX_TIM_GC_Init(void)
{
#define PERIOD_50HZ ((uint8_t)39)
#if (defined (USE_STM32F4XX_NUCLEO)) /* 84 MHZ CPU clock */
#define PRESCALER_50HZ ((uint16_t)41999)
#elif (defined (USE_STM32L4XX_NUCLEO)) /* 80 MHZ CPU clock */
#define PRESCALER_50HZ ((uint16_t)39999)
#else
#error Not supported platform
#endif
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
TIM_OC_InitTypeDef sConfigOC;
GCTimHandle.Instance = TIM_GC;
GCTimHandle.Init.Prescaler = PRESCALER_50HZ;
GCTimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
GCTimHandle.Init.Period = PERIOD_50HZ;
GCTimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&GCTimHandle);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&GCTimHandle, &sClockSourceConfig);
HAL_TIM_OC_Init(&GCTimHandle);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&GCTimHandle, &sMasterConfig);
sConfigOC.OCMode = TIM_OCMODE_TIMING;
sConfigOC.Pulse = 2;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
HAL_TIM_OC_ConfigChannel(&GCTimHandle, &sConfigOC, TIM_CHANNEL_1);
HAL_TIM_Base_Start_IT(&GCTimHandle);
} | /**
* @brief TIM_GC init function.
* @param None
* @retval None
* @details This function intialize the Timer used to syncronize the AC algorithm.
*/ | @brief TIM_GC init function.
@param None
@retval None
@details This function intialize the Timer used to syncronize the AC algorithm. | [
"@brief",
"TIM_GC",
"init",
"function",
".",
"@param",
"None",
"@retval",
"None",
"@details",
"This",
"function",
"intialize",
"the",
"Timer",
"used",
"to",
"syncronize",
"the",
"AC",
"algorithm",
"."
] | static void MX_TIM_GC_Init(void)
{
#define PERIOD_50HZ ((uint8_t)39)
#if (defined (USE_STM32F4XX_NUCLEO))
#define PRESCALER_50HZ ((uint16_t)41999)
#elif (defined (USE_STM32L4XX_NUCLEO))
#define PRESCALER_50HZ ((uint16_t)39999)
#else
#error Not supported platform
#endif
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
TIM_OC_InitTypeDef sConfigOC;
GCTimHandle.Instance = TIM_GC;
GCTimHandle.Init.Prescaler = PRESCALER_50HZ;
GCTimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
GCTimHandle.Init.Period = PERIOD_50HZ;
GCTimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&GCTimHandle);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&GCTimHandle, &sClockSourceConfig);
HAL_TIM_OC_Init(&GCTimHandle);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&GCTimHandle, &sMasterConfig);
sConfigOC.OCMode = TIM_OCMODE_TIMING;
sConfigOC.Pulse = 2;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
HAL_TIM_OC_ConfigChannel(&GCTimHandle, &sConfigOC, TIM_CHANNEL_1);
HAL_TIM_Base_Start_IT(&GCTimHandle);
} | [
"static",
"void",
"MX_TIM_GC_Init",
"(",
"void",
")",
"{",
"#define",
"PERIOD_50HZ",
" ((uint8_t)39)\r",
"\n",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"#define",
"PRESCALER_50HZ",
" ((uint16_t)41999)\r",
"\n",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"#define",
"PRESCALER_50HZ",
" ((uint16_t)39999)\r",
"\n",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"TIM_ClockConfigTypeDef",
"sClockSourceConfig",
";",
"TIM_MasterConfigTypeDef",
"sMasterConfig",
";",
"TIM_OC_InitTypeDef",
"sConfigOC",
";",
"GCTimHandle",
".",
"Instance",
"=",
"TIM_GC",
";",
"GCTimHandle",
".",
"Init",
".",
"Prescaler",
"=",
"PRESCALER_50HZ",
";",
"GCTimHandle",
".",
"Init",
".",
"CounterMode",
"=",
"TIM_COUNTERMODE_UP",
";",
"GCTimHandle",
".",
"Init",
".",
"Period",
"=",
"PERIOD_50HZ",
";",
"GCTimHandle",
".",
"Init",
".",
"ClockDivision",
"=",
"TIM_CLOCKDIVISION_DIV1",
";",
"HAL_TIM_Base_Init",
"(",
"&",
"GCTimHandle",
")",
";",
"sClockSourceConfig",
".",
"ClockSource",
"=",
"TIM_CLOCKSOURCE_INTERNAL",
";",
"HAL_TIM_ConfigClockSource",
"(",
"&",
"GCTimHandle",
",",
"&",
"sClockSourceConfig",
")",
";",
"HAL_TIM_OC_Init",
"(",
"&",
"GCTimHandle",
")",
";",
"sMasterConfig",
".",
"MasterOutputTrigger",
"=",
"TIM_TRGO_RESET",
";",
"sMasterConfig",
".",
"MasterSlaveMode",
"=",
"TIM_MASTERSLAVEMODE_DISABLE",
";",
"HAL_TIMEx_MasterConfigSynchronization",
"(",
"&",
"GCTimHandle",
",",
"&",
"sMasterConfig",
")",
";",
"sConfigOC",
".",
"OCMode",
"=",
"TIM_OCMODE_TIMING",
";",
"sConfigOC",
".",
"Pulse",
"=",
"2",
";",
"sConfigOC",
".",
"OCPolarity",
"=",
"TIM_OCPOLARITY_HIGH",
";",
"sConfigOC",
".",
"OCFastMode",
"=",
"TIM_OCFAST_DISABLE",
";",
"HAL_TIM_OC_ConfigChannel",
"(",
"&",
"GCTimHandle",
",",
"&",
"sConfigOC",
",",
"TIM_CHANNEL_1",
")",
";",
"HAL_TIM_Base_Start_IT",
"(",
"&",
"GCTimHandle",
")",
";",
"}"
] | @brief TIM_GC init function. | [
"@brief",
"TIM_GC",
"init",
"function",
"."
] | [
"/* 84 MHZ CPU clock */",
"/* 80 MHZ CPU clock */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Accelero_Sensor_Handler | void | static void Accelero_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
if(Sensors_Enabled & ACCELEROMETER_SENSOR)
{
if(BSP_ACCELERO_IsInitialized(ACCELERO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_ACCELERO_Get_Axes(ACCELERO_handle, &ACC_Value);
Serialize_s32(&Msg->Data[19], (int32_t)ACC_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[23], (int32_t)ACC_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[27], (int32_t)ACC_Value.AXIS_Z, 4);
}
}
} | /**
* @brief Handles the ACC axes data getting/sending
* @param Msg - ACC part of the stream
* @retval None
*/ | @brief Handles the ACC axes data getting/sending
@param Msg - ACC part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"ACC",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"ACC",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Accelero_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
if(Sensors_Enabled & ACCELEROMETER_SENSOR)
{
if(BSP_ACCELERO_IsInitialized(ACCELERO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_ACCELERO_Get_Axes(ACCELERO_handle, &ACC_Value);
Serialize_s32(&Msg->Data[19], (int32_t)ACC_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[23], (int32_t)ACC_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[27], (int32_t)ACC_Value.AXIS_Z, 4);
}
}
} | [
"static",
"void",
"Accelero_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"ACCELEROMETER_SENSOR",
")",
"{",
"if",
"(",
"BSP_ACCELERO_IsInitialized",
"(",
"ACCELERO_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_ACCELERO_Get_Axes",
"(",
"ACCELERO_handle",
",",
"&",
"ACC_Value",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"19",
"]",
",",
"(",
"int32_t",
")",
"ACC_Value",
".",
"AXIS_X",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"23",
"]",
",",
"(",
"int32_t",
")",
"ACC_Value",
".",
"AXIS_Y",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"27",
"]",
",",
"(",
"int32_t",
")",
"ACC_Value",
".",
"AXIS_Z",
",",
"4",
")",
";",
"}",
"}",
"}"
] | @brief Handles the ACC axes data getting/sending
@param Msg - ACC part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"ACC",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"ACC",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Gyro_Sensor_Handler | void | static void Gyro_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
if(Sensors_Enabled & GYROSCOPE_SENSOR)
{
if(BSP_GYRO_IsInitialized(GYRO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_GYRO_Get_Axes(GYRO_handle, &GYR_Value);
Serialize_s32(&Msg->Data[31], GYR_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[35], GYR_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[39], GYR_Value.AXIS_Z, 4);
}
}
} | /**
* @brief Handles the GYR axes data getting/sending
* @param Msg - GYR part of the stream
* @retval None
*/ | @brief Handles the GYR axes data getting/sending
@param Msg - GYR part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"GYR",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"GYR",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Gyro_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
if(Sensors_Enabled & GYROSCOPE_SENSOR)
{
if(BSP_GYRO_IsInitialized(GYRO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_GYRO_Get_Axes(GYRO_handle, &GYR_Value);
Serialize_s32(&Msg->Data[31], GYR_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[35], GYR_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[39], GYR_Value.AXIS_Z, 4);
}
}
} | [
"static",
"void",
"Gyro_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"GYROSCOPE_SENSOR",
")",
"{",
"if",
"(",
"BSP_GYRO_IsInitialized",
"(",
"GYRO_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_GYRO_Get_Axes",
"(",
"GYRO_handle",
",",
"&",
"GYR_Value",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"31",
"]",
",",
"GYR_Value",
".",
"AXIS_X",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"35",
"]",
",",
"GYR_Value",
".",
"AXIS_Y",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"39",
"]",
",",
"GYR_Value",
".",
"AXIS_Z",
",",
"4",
")",
";",
"}",
"}",
"}"
] | @brief Handles the GYR axes data getting/sending
@param Msg - GYR part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"GYR",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"GYR",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | GC_Data_Handler | void | static void GC_Data_Handler(TMsg *Msg)
{
MGC_input_t data_in;
MGC_output_t data_out;
int bias_update = 0;
SensorAxes_t GYR_Comp;
data_in.Acc[0] = ACC_Value.AXIS_X / 1000.0f;
data_in.Acc[1] = ACC_Value.AXIS_Y / 1000.0f;
data_in.Acc[2] = ACC_Value.AXIS_Z / 1000.0f;
data_in.Gyro[0] = GYR_Value.AXIS_X / 1000.0f;
data_in.Gyro[1] = GYR_Value.AXIS_Y / 1000.0f;
data_in.Gyro[2] = GYR_Value.AXIS_Z / 1000.0f;
/* Run Gyroscope calibration algorithm */
MotionGC_manager_update(&data_in, &data_out, &bias_update);
/* Do offset & scale factor calibration */
MotionGC_manager_compensate(&GYR_Value, &GYR_Comp);
/* Offset coeficients */
Serialize_s32(&Msg->Data[55], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasX), 4);
Serialize_s32(&Msg->Data[59], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasY), 4);
Serialize_s32(&Msg->Data[63], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasZ), 4);
/* Calibrated data */
Serialize_s32(&Msg->Data[67], (int32_t) GYR_Comp.AXIS_X, 4);
Serialize_s32(&Msg->Data[71], (int32_t) GYR_Comp.AXIS_Y, 4);
Serialize_s32(&Msg->Data[75], (int32_t) GYR_Comp.AXIS_Z, 4);
/* Calibration quality */
Serialize_s32(&Msg->Data[79], (int32_t) bias_update, 4);
} | /**
* @brief Gyroscope calibration data sending
* @param Msg - Gyroscope calibration part of the data stream
* @retval None
*/ | @brief Gyroscope calibration data sending
@param Msg - Gyroscope calibration part of the data stream
@retval None | [
"@brief",
"Gyroscope",
"calibration",
"data",
"sending",
"@param",
"Msg",
"-",
"Gyroscope",
"calibration",
"part",
"of",
"the",
"data",
"stream",
"@retval",
"None"
] | static void GC_Data_Handler(TMsg *Msg)
{
MGC_input_t data_in;
MGC_output_t data_out;
int bias_update = 0;
SensorAxes_t GYR_Comp;
data_in.Acc[0] = ACC_Value.AXIS_X / 1000.0f;
data_in.Acc[1] = ACC_Value.AXIS_Y / 1000.0f;
data_in.Acc[2] = ACC_Value.AXIS_Z / 1000.0f;
data_in.Gyro[0] = GYR_Value.AXIS_X / 1000.0f;
data_in.Gyro[1] = GYR_Value.AXIS_Y / 1000.0f;
data_in.Gyro[2] = GYR_Value.AXIS_Z / 1000.0f;
MotionGC_manager_update(&data_in, &data_out, &bias_update);
MotionGC_manager_compensate(&GYR_Value, &GYR_Comp);
Serialize_s32(&Msg->Data[55], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasX), 4);
Serialize_s32(&Msg->Data[59], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasY), 4);
Serialize_s32(&Msg->Data[63], (int32_t) gyro_bias_to_mdps(data_out.GyroBiasZ), 4);
Serialize_s32(&Msg->Data[67], (int32_t) GYR_Comp.AXIS_X, 4);
Serialize_s32(&Msg->Data[71], (int32_t) GYR_Comp.AXIS_Y, 4);
Serialize_s32(&Msg->Data[75], (int32_t) GYR_Comp.AXIS_Z, 4);
Serialize_s32(&Msg->Data[79], (int32_t) bias_update, 4);
} | [
"static",
"void",
"GC_Data_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"MGC_input_t",
"data_in",
";",
"MGC_output_t",
"data_out",
";",
"int",
"bias_update",
"=",
"0",
";",
"SensorAxes_t",
"GYR_Comp",
";",
"data_in",
".",
"Acc",
"[",
"0",
"]",
"=",
"ACC_Value",
".",
"AXIS_X",
"/",
"1000.0f",
";",
"data_in",
".",
"Acc",
"[",
"1",
"]",
"=",
"ACC_Value",
".",
"AXIS_Y",
"/",
"1000.0f",
";",
"data_in",
".",
"Acc",
"[",
"2",
"]",
"=",
"ACC_Value",
".",
"AXIS_Z",
"/",
"1000.0f",
";",
"data_in",
".",
"Gyro",
"[",
"0",
"]",
"=",
"GYR_Value",
".",
"AXIS_X",
"/",
"1000.0f",
";",
"data_in",
".",
"Gyro",
"[",
"1",
"]",
"=",
"GYR_Value",
".",
"AXIS_Y",
"/",
"1000.0f",
";",
"data_in",
".",
"Gyro",
"[",
"2",
"]",
"=",
"GYR_Value",
".",
"AXIS_Z",
"/",
"1000.0f",
";",
"MotionGC_manager_update",
"(",
"&",
"data_in",
",",
"&",
"data_out",
",",
"&",
"bias_update",
")",
";",
"MotionGC_manager_compensate",
"(",
"&",
"GYR_Value",
",",
"&",
"GYR_Comp",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"55",
"]",
",",
"(",
"int32_t",
")",
"gyro_bias_to_mdps",
"(",
"data_out",
".",
"GyroBiasX",
")",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"59",
"]",
",",
"(",
"int32_t",
")",
"gyro_bias_to_mdps",
"(",
"data_out",
".",
"GyroBiasY",
")",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"63",
"]",
",",
"(",
"int32_t",
")",
"gyro_bias_to_mdps",
"(",
"data_out",
".",
"GyroBiasZ",
")",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"67",
"]",
",",
"(",
"int32_t",
")",
"GYR_Comp",
".",
"AXIS_X",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"71",
"]",
",",
"(",
"int32_t",
")",
"GYR_Comp",
".",
"AXIS_Y",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"75",
"]",
",",
"(",
"int32_t",
")",
"GYR_Comp",
".",
"AXIS_Z",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"79",
"]",
",",
"(",
"int32_t",
")",
"bias_update",
",",
"4",
")",
";",
"}"
] | @brief Gyroscope calibration data sending
@param Msg - Gyroscope calibration part of the data stream
@retval None | [
"@brief",
"Gyroscope",
"calibration",
"data",
"sending",
"@param",
"Msg",
"-",
"Gyroscope",
"calibration",
"part",
"of",
"the",
"data",
"stream",
"@retval",
"None"
] | [
"/* Run Gyroscope calibration algorithm */",
"/* Do offset & scale factor calibration */",
"/* Offset coeficients */",
"/* Calibrated data */",
"/* Calibration quality */"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Magneto_Sensor_Handler | void | static void Magneto_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
SensorAxes_t MAG_Value;
if(Sensors_Enabled & MAGNETIC_SENSOR)
{
if(BSP_MAGNETO_IsInitialized(MAGNETO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_MAGNETO_Get_Axes(MAGNETO_handle, &MAG_Value);
Serialize_s32(&Msg->Data[43], MAG_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[47], MAG_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[51], MAG_Value.AXIS_Z, 4);
}
}
} | /**
* @brief Handles the MAG axes data getting/sending
* @param Msg - MAG part of the stream
* @retval None
*/ | @brief Handles the MAG axes data getting/sending
@param Msg - MAG part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"MAG",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"MAG",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Magneto_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
SensorAxes_t MAG_Value;
if(Sensors_Enabled & MAGNETIC_SENSOR)
{
if(BSP_MAGNETO_IsInitialized(MAGNETO_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_MAGNETO_Get_Axes(MAGNETO_handle, &MAG_Value);
Serialize_s32(&Msg->Data[43], MAG_Value.AXIS_X, 4);
Serialize_s32(&Msg->Data[47], MAG_Value.AXIS_Y, 4);
Serialize_s32(&Msg->Data[51], MAG_Value.AXIS_Z, 4);
}
}
} | [
"static",
"void",
"Magneto_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"SensorAxes_t",
"MAG_Value",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"MAGNETIC_SENSOR",
")",
"{",
"if",
"(",
"BSP_MAGNETO_IsInitialized",
"(",
"MAGNETO_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_MAGNETO_Get_Axes",
"(",
"MAGNETO_handle",
",",
"&",
"MAG_Value",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"43",
"]",
",",
"MAG_Value",
".",
"AXIS_X",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"47",
"]",
",",
"MAG_Value",
".",
"AXIS_Y",
",",
"4",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"51",
"]",
",",
"MAG_Value",
".",
"AXIS_Z",
",",
"4",
")",
";",
"}",
"}",
"}"
] | @brief Handles the MAG axes data getting/sending
@param Msg - MAG part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"MAG",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"MAG",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Pressure_Sensor_Handler | void | static void Pressure_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float PRESSURE_Value;
if(Sensors_Enabled & PRESSURE_SENSOR)
{
if(BSP_PRESSURE_IsInitialized(PRESSURE_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_PRESSURE_Get_Press(PRESSURE_handle, &PRESSURE_Value);
memcpy(&Msg->Data[7], (void *)&PRESSURE_Value, sizeof(float));
}
}
} | /**
* @brief Handles the PRESS sensor data getting/sending.
* @param Msg - PRESS part of the stream
* @retval None
*/ | @brief Handles the PRESS sensor data getting/sending.
@param Msg - PRESS part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"PRESS",
"sensor",
"data",
"getting",
"/",
"sending",
".",
"@param",
"Msg",
"-",
"PRESS",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Pressure_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float PRESSURE_Value;
if(Sensors_Enabled & PRESSURE_SENSOR)
{
if(BSP_PRESSURE_IsInitialized(PRESSURE_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_PRESSURE_Get_Press(PRESSURE_handle, &PRESSURE_Value);
memcpy(&Msg->Data[7], (void *)&PRESSURE_Value, sizeof(float));
}
}
} | [
"static",
"void",
"Pressure_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"float",
"PRESSURE_Value",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"PRESSURE_SENSOR",
")",
"{",
"if",
"(",
"BSP_PRESSURE_IsInitialized",
"(",
"PRESSURE_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_PRESSURE_Get_Press",
"(",
"PRESSURE_handle",
",",
"&",
"PRESSURE_Value",
")",
";",
"memcpy",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"7",
"]",
",",
"(",
"void",
"*",
")",
"&",
"PRESSURE_Value",
",",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"}",
"}"
] | @brief Handles the PRESS sensor data getting/sending. | [
"@brief",
"Handles",
"the",
"PRESS",
"sensor",
"data",
"getting",
"/",
"sending",
"."
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Temperature_Sensor_Handler | void | static void Temperature_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float TEMPERATURE_Value;
if(Sensors_Enabled & TEMPERATURE_SENSOR)
{
if(BSP_TEMPERATURE_IsInitialized(TEMPERATURE_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_TEMPERATURE_Get_Temp(TEMPERATURE_handle, &TEMPERATURE_Value);
memcpy(&Msg->Data[11], (void *)&TEMPERATURE_Value, sizeof(float));
}
}
} | /**
* @brief Handles the TEMP axes data getting/sending
* @param Msg - TEMP part of the stream
* @retval None
*/ | @brief Handles the TEMP axes data getting/sending
@param Msg - TEMP part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"TEMP",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"TEMP",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Temperature_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float TEMPERATURE_Value;
if(Sensors_Enabled & TEMPERATURE_SENSOR)
{
if(BSP_TEMPERATURE_IsInitialized(TEMPERATURE_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_TEMPERATURE_Get_Temp(TEMPERATURE_handle, &TEMPERATURE_Value);
memcpy(&Msg->Data[11], (void *)&TEMPERATURE_Value, sizeof(float));
}
}
} | [
"static",
"void",
"Temperature_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"float",
"TEMPERATURE_Value",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"TEMPERATURE_SENSOR",
")",
"{",
"if",
"(",
"BSP_TEMPERATURE_IsInitialized",
"(",
"TEMPERATURE_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_TEMPERATURE_Get_Temp",
"(",
"TEMPERATURE_handle",
",",
"&",
"TEMPERATURE_Value",
")",
";",
"memcpy",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"11",
"]",
",",
"(",
"void",
"*",
")",
"&",
"TEMPERATURE_Value",
",",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"}",
"}"
] | @brief Handles the TEMP axes data getting/sending
@param Msg - TEMP part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"TEMP",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"TEMP",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | Humidity_Sensor_Handler | void | static void Humidity_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float HUMIDITY_Value;
if(Sensors_Enabled & HUMIDITY_SENSOR)
{
if(BSP_HUMIDITY_IsInitialized(HUMIDITY_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_HUMIDITY_Get_Hum(HUMIDITY_handle, &HUMIDITY_Value);
memcpy(&Msg->Data[15], (void *)&HUMIDITY_Value, sizeof(float));
}
}
} | /**
* @brief Handles the HUM axes data getting/sending
* @param Msg - HUM part of the stream
* @retval None
*/ | @brief Handles the HUM axes data getting/sending
@param Msg - HUM part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"HUM",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"HUM",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Humidity_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float HUMIDITY_Value;
if(Sensors_Enabled & HUMIDITY_SENSOR)
{
if(BSP_HUMIDITY_IsInitialized(HUMIDITY_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_HUMIDITY_Get_Hum(HUMIDITY_handle, &HUMIDITY_Value);
memcpy(&Msg->Data[15], (void *)&HUMIDITY_Value, sizeof(float));
}
}
} | [
"static",
"void",
"Humidity_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"float",
"HUMIDITY_Value",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"HUMIDITY_SENSOR",
")",
"{",
"if",
"(",
"BSP_HUMIDITY_IsInitialized",
"(",
"HUMIDITY_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_HUMIDITY_Get_Hum",
"(",
"HUMIDITY_handle",
",",
"&",
"HUMIDITY_Value",
")",
";",
"memcpy",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"15",
"]",
",",
"(",
"void",
"*",
")",
"&",
"HUMIDITY_Value",
",",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"}",
"}"
] | @brief Handles the HUM axes data getting/sending
@param Msg - HUM part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"HUM",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"HUM",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | RTC_TimeStampConfig | void | static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/* Configure the Date */
/* Set Date: Monday March 21st 2016 */
sdatestructure.Year = 0x16;
sdatestructure.Month = RTC_MONTH_MARCH;
sdatestructure.Date = 0x21;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if(HAL_RTC_SetDate(&RtcHandle, &sdatestructure, FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Configure the Time */
/* Set Time: 08:10:00 */
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle, &stimestructure, FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
} | /**
* @brief Configures the current time and date
* @param None
* @retval None
*/ | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
sdatestructure.Year = 0x16;
sdatestructure.Month = RTC_MONTH_MARCH;
sdatestructure.Date = 0x21;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if(HAL_RTC_SetDate(&RtcHandle, &sdatestructure, FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle, &stimestructure, FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
} | [
"static",
"void",
"RTC_TimeStampConfig",
"(",
"void",
")",
"{",
"RTC_DateTypeDef",
"sdatestructure",
";",
"RTC_TimeTypeDef",
"stimestructure",
";",
"sdatestructure",
".",
"Year",
"=",
"0x16",
";",
"sdatestructure",
".",
"Month",
"=",
"RTC_MONTH_MARCH",
";",
"sdatestructure",
".",
"Date",
"=",
"0x21",
";",
"sdatestructure",
".",
"WeekDay",
"=",
"RTC_WEEKDAY_MONDAY",
";",
"if",
"(",
"HAL_RTC_SetDate",
"(",
"&",
"RtcHandle",
",",
"&",
"sdatestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"stimestructure",
".",
"Hours",
"=",
"0x08",
";",
"stimestructure",
".",
"Minutes",
"=",
"0x10",
";",
"stimestructure",
".",
"Seconds",
"=",
"0x00",
";",
"stimestructure",
".",
"TimeFormat",
"=",
"RTC_HOURFORMAT12_AM",
";",
"stimestructure",
".",
"DayLightSaving",
"=",
"RTC_DAYLIGHTSAVING_NONE",
";",
"stimestructure",
".",
"StoreOperation",
"=",
"RTC_STOREOPERATION_RESET",
";",
"if",
"(",
"HAL_RTC_SetTime",
"(",
"&",
"RtcHandle",
",",
"&",
"stimestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}"
] | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | [
"/* Configure the Date */",
"/* Set Date: Monday March 21st 2016 */",
"/* Initialization Error */",
"/* Configure the Time */",
"/* Set Time: 08:10:00 */",
"/* Initialization Error */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0faaa1f522febe980064212164f07bd28d5a058d | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GyroscopeCalibration/Src/main.c | [
"MIT"
] | C | HAL_TIM_PeriodElapsedCallback | void | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance == TIM_GC)
{
sensor_read_request = 1;
}
} | /**
* @brief Period elapsed callback
* @param htim: pointer to a TIM_HandleTypeDef structure that contains
* the configuration information for TIM module.
* @retval None
*/ | @brief Period elapsed callback
@param htim: pointer to a TIM_HandleTypeDef structure that contains
the configuration information for TIM module.
@retval None | [
"@brief",
"Period",
"elapsed",
"callback",
"@param",
"htim",
":",
"pointer",
"to",
"a",
"TIM_HandleTypeDef",
"structure",
"that",
"contains",
"the",
"configuration",
"information",
"for",
"TIM",
"module",
".",
"@retval",
"None"
] | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance == TIM_GC)
{
sensor_read_request = 1;
}
} | [
"void",
"HAL_TIM_PeriodElapsedCallback",
"(",
"TIM_HandleTypeDef",
"*",
"htim",
")",
"{",
"if",
"(",
"htim",
"->",
"Instance",
"==",
"TIM_GC",
")",
"{",
"sensor_read_request",
"=",
"1",
";",
"}",
"}"
] | @brief Period elapsed callback
@param htim: pointer to a TIM_HandleTypeDef structure that contains
the configuration information for TIM module. | [
"@brief",
"Period",
"elapsed",
"callback",
"@param",
"htim",
":",
"pointer",
"to",
"a",
"TIM_HandleTypeDef",
"structure",
"that",
"contains",
"the",
"configuration",
"information",
"for",
"TIM",
"module",
"."
] | [] | [
{
"param": "htim",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
607f273addf3ace8e095de67039f288fa0e53e14 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/stm32l4xx_hal_msp.c | [
"MIT"
] | C | HAL_RTC_MspInit | void | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*##-1- Enables the PWR Clock and Enables access to the backup domain ###################################*/
/* To change the source clock of the RTC feature (LSE, LSI), You have to:
- Enable the power clock using __HAL_RCC_PWR_CLK_ENABLE()
- Enable write access using HAL_PWR_EnableBkUpAccess() function before to
configure the RTC clock source (to be done once after reset).
- Reset the Back up Domain using __HAL_RCC_BACKUPRESET_FORCE() and
__HAL_RCC_BACKUPRESET_RELEASE().
- Configure the needed RTC clock source */
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
/*##-2- Configue LSE/LSI as RTC clock soucre ###############################*/
if(use_LSI == 0)
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
else
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
/*##-2- Enable RTC peripheral Clocks #######################################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
/*##-4- Configure the NVIC for RTC Alarm ###################################*/
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
} | /**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example
* @param hrtc: RTC handle pointer
*
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
* the RTC clock source; in this case the Backup domain will be reset in
* order to modify the RTC Clock source, as consequence RTC registers (including
* the backup registers) and RCC_BDCR register are set to their reset values.
*
* @retval None
*/ | @brief RTC MSP Initialization
This function configures the hardware resources used in this example
@param hrtc: RTC handle pointer
@note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
the RTC clock source; in this case the Backup domain will be reset in
order to modify the RTC Clock source, as consequence RTC registers (including
the backup registers) and RCC_BDCR register are set to their reset values.
@retval None | [
"@brief",
"RTC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer",
"@note",
"Care",
"must",
"be",
"taken",
"when",
"HAL_RCCEx_PeriphCLKConfig",
"()",
"is",
"used",
"to",
"select",
"the",
"RTC",
"clock",
"source",
";",
"in",
"this",
"case",
"the",
"Backup",
"domain",
"will",
"be",
"reset",
"in",
"order",
"to",
"modify",
"the",
"RTC",
"Clock",
"source",
"as",
"consequence",
"RTC",
"registers",
"(",
"including",
"the",
"backup",
"registers",
")",
"and",
"RCC_BDCR",
"register",
"are",
"set",
"to",
"their",
"reset",
"values",
".",
"@retval",
"None"
] | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
if(use_LSI == 0)
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
else
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
__HAL_RCC_RTC_ENABLE();
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
} | [
"void",
"HAL_RTC_MspInit",
"(",
"RTC_HandleTypeDef",
"*",
"hrtc",
")",
"{",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
";",
"RCC_PeriphCLKInitTypeDef",
"PeriphClkInitStruct",
";",
"__HAL_RCC_PWR_CLK_ENABLE",
"(",
")",
";",
"HAL_PWR_EnableBkUpAccess",
"(",
")",
";",
"if",
"(",
"use_LSI",
"==",
"0",
")",
"{",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_LSI",
"|",
"RCC_OSCILLATORTYPE_LSE",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_NONE",
";",
"RCC_OscInitStruct",
".",
"LSEState",
"=",
"RCC_LSE_ON",
";",
"RCC_OscInitStruct",
".",
"LSIState",
"=",
"RCC_LSI_OFF",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"PeriphClkInitStruct",
".",
"PeriphClockSelection",
"=",
"RCC_PERIPHCLK_RTC",
";",
"PeriphClkInitStruct",
".",
"RTCClockSelection",
"=",
"RCC_RTCCLKSOURCE_LSE",
";",
"if",
"(",
"HAL_RCCEx_PeriphCLKConfig",
"(",
"&",
"PeriphClkInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"else",
"{",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_LSI",
"|",
"RCC_OSCILLATORTYPE_LSE",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_NONE",
";",
"RCC_OscInitStruct",
".",
"LSIState",
"=",
"RCC_LSI_ON",
";",
"RCC_OscInitStruct",
".",
"LSEState",
"=",
"RCC_LSE_OFF",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"PeriphClkInitStruct",
".",
"PeriphClockSelection",
"=",
"RCC_PERIPHCLK_RTC",
";",
"PeriphClkInitStruct",
".",
"RTCClockSelection",
"=",
"RCC_RTCCLKSOURCE_LSI",
";",
"if",
"(",
"HAL_RCCEx_PeriphCLKConfig",
"(",
"&",
"PeriphClkInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"__HAL_RCC_RTC_ENABLE",
"(",
")",
";",
"HAL_NVIC_SetPriority",
"(",
"RTC_Alarm_IRQn",
",",
"0x0F",
",",
"0",
")",
";",
"HAL_NVIC_EnableIRQ",
"(",
"RTC_Alarm_IRQn",
")",
";",
"}"
] | @brief RTC MSP Initialization
This function configures the hardware resources used in this example
@param hrtc: RTC handle pointer | [
"@brief",
"RTC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer"
] | [
"/*##-1- Enables the PWR Clock and Enables access to the backup domain ###################################*/",
"/* To change the source clock of the RTC feature (LSE, LSI), You have to:\r\n - Enable the power clock using __HAL_RCC_PWR_CLK_ENABLE()\r\n - Enable write access using HAL_PWR_EnableBkUpAccess() function before to\r\n configure the RTC clock source (to be done once after reset).\r\n - Reset the Back up Domain using __HAL_RCC_BACKUPRESET_FORCE() and\r\n __HAL_RCC_BACKUPRESET_RELEASE().\r\n - Configure the needed RTC clock source */",
"/*##-2- Configue LSE/LSI as RTC clock soucre ###############################*/",
"/*##-2- Enable RTC peripheral Clocks #######################################*/",
"/* Enable RTC Clock */",
"/*##-4- Configure the NVIC for RTC Alarm ###################################*/"
] | [
{
"param": "hrtc",
"type": "RTC_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hrtc",
"type": "RTC_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
607f273addf3ace8e095de67039f288fa0e53e14 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/stm32l4xx_hal_msp.c | [
"MIT"
] | C | HAL_TIM_Base_MspInit | void | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_AC)
{
/* Peripheral clock enable */
TIM_AC_CLK_ENABLE();
/* System interrupt init*/
HAL_NVIC_SetPriority(TIM_AC_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TIM_AC_IRQn);
}
} | /**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/ | @brief TIM MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_AC)
{
TIM_AC_CLK_ENABLE();
HAL_NVIC_SetPriority(TIM_AC_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TIM_AC_IRQn);
}
} | [
"void",
"HAL_TIM_Base_MspInit",
"(",
"TIM_HandleTypeDef",
"*",
"htim_base",
")",
"{",
"if",
"(",
"htim_base",
"->",
"Instance",
"==",
"TIM_AC",
")",
"{",
"TIM_AC_CLK_ENABLE",
"(",
")",
";",
"HAL_NVIC_SetPriority",
"(",
"TIM_AC_IRQn",
",",
"0x0F",
",",
"0",
")",
";",
"HAL_NVIC_EnableIRQ",
"(",
"TIM_AC_IRQn",
")",
";",
"}",
"}"
] | @brief TIM MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock enable */",
"/* System interrupt init*/"
] | [
{
"param": "htim_base",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim_base",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
607f273addf3ace8e095de67039f288fa0e53e14 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/stm32l4xx_hal_msp.c | [
"MIT"
] | C | HAL_TIM_Base_MspDeInit | void | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_AC)
{
/* Peripheral clock disable */
TIM_AC_CLK_DISABLE();
/* Peripheral interrupt DeInit*/
HAL_NVIC_DisableIRQ(TIM_AC_IRQn);
}
} | /**
* @brief TIM MSP DeInitialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/ | @brief TIM MSP DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_AC)
{
TIM_AC_CLK_DISABLE();
HAL_NVIC_DisableIRQ(TIM_AC_IRQn);
}
} | [
"void",
"HAL_TIM_Base_MspDeInit",
"(",
"TIM_HandleTypeDef",
"*",
"htim_base",
")",
"{",
"if",
"(",
"htim_base",
"->",
"Instance",
"==",
"TIM_AC",
")",
"{",
"TIM_AC_CLK_DISABLE",
"(",
")",
";",
"HAL_NVIC_DisableIRQ",
"(",
"TIM_AC_IRQn",
")",
";",
"}",
"}"
] | @brief TIM MSP DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock disable */",
"/* Peripheral interrupt DeInit*/"
] | [
{
"param": "htim_base",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim_base",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
607f273addf3ace8e095de67039f288fa0e53e14 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/stm32l4xx_hal_msp.c | [
"MIT"
] | C | HAL_CRC_MspInit | void | void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
/* Peripheral clock enable */
__HAL_RCC_CRC_CLK_ENABLE();
}
} | /**
* @brief CRC MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param hcrc: CRC handle pointer
* @retval None
*/ | @brief CRC MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
@param hcrc: CRC handle pointer
@retval None | [
"@brief",
"CRC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"@param",
"hcrc",
":",
"CRC",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
__HAL_RCC_CRC_CLK_ENABLE();
}
} | [
"void",
"HAL_CRC_MspInit",
"(",
"CRC_HandleTypeDef",
"*",
"hcrc",
")",
"{",
"if",
"(",
"hcrc",
"->",
"Instance",
"==",
"CRC",
")",
"{",
"__HAL_RCC_CRC_CLK_ENABLE",
"(",
")",
";",
"}",
"}"
] | @brief CRC MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
@param hcrc: CRC handle pointer
@retval None | [
"@brief",
"CRC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"@param",
"hcrc",
":",
"CRC",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock enable */"
] | [
{
"param": "hcrc",
"type": "CRC_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hcrc",
"type": "CRC_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
607f273addf3ace8e095de67039f288fa0e53e14 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/AccelerometerCalibration/Src/stm32l4xx_hal_msp.c | [
"MIT"
] | C | HAL_CRC_MspDeInit | void | void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
/* Peripheral clock disable */
__HAL_RCC_CRC_CLK_DISABLE();
}
} | /**
* @brief TIM CRC DeInitialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock disable
* @param hcrc: CRC handle pointer
* @retval None
*/ | @brief TIM CRC DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock disable
@param hcrc: CRC handle pointer
@retval None | [
"@brief",
"TIM",
"CRC",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"disable",
"@param",
"hcrc",
":",
"CRC",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
__HAL_RCC_CRC_CLK_DISABLE();
}
} | [
"void",
"HAL_CRC_MspDeInit",
"(",
"CRC_HandleTypeDef",
"*",
"hcrc",
")",
"{",
"if",
"(",
"hcrc",
"->",
"Instance",
"==",
"CRC",
")",
"{",
"__HAL_RCC_CRC_CLK_DISABLE",
"(",
")",
";",
"}",
"}"
] | @brief TIM CRC DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock disable
@param hcrc: CRC handle pointer
@retval None | [
"@brief",
"TIM",
"CRC",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"disable",
"@param",
"hcrc",
":",
"CRC",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock disable */"
] | [
{
"param": "hcrc",
"type": "CRC_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hcrc",
"type": "CRC_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f46165365fe1ff87a45ab3f9b36d077ad2072000 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/MotionTL_Manager.c | [
"MIT"
] | C | MotionTL_manager_init | uint8_t | uint8_t MotionTL_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MTL_AccCal_t accCal;
MotionTL_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return 0;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return 0;
#else
#error Not supported platform
#endif
}
MotionTL_SetOrientation_Acc(acc_orientation);
// Get calibration values from flash memory and set them in library if valid
MotionTL_manager_LoadCalValuesFromNVM(&accCal);
MotionTL_SetCalValues(&accCal);
return 1;
} | /**
* @brief Initialize the MotionTL engine
* @param None
* @retval 1 in case of success,
* @retval 0 otherwise
*/ | @brief Initialize the MotionTL engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionTL",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | uint8_t MotionTL_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MTL_AccCal_t accCal;
MotionTL_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return 0;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return 0;
#else
#error Not supported platform
#endif
}
MotionTL_SetOrientation_Acc(acc_orientation);
MotionTL_manager_LoadCalValuesFromNVM(&accCal);
MotionTL_SetCalValues(&accCal);
return 1;
} | [
"uint8_t",
"MotionTL_manager_init",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"instance",
";",
"char",
"acc_orientation",
"[",
"3",
"]",
";",
"MTL_AccCal_t",
"accCal",
";",
"MotionTL_Initialize",
"(",
")",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_IKS01A1",
")",
")",
"\n",
"case",
"LSM6DS0_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM6DS3_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
"0",
";",
"#elif",
"(",
"defined",
"(",
"USE_IKS01A2",
")",
")",
"\n",
"case",
"LSM6DSL_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM303AGR_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
"0",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"}",
"MotionTL_SetOrientation_Acc",
"(",
"acc_orientation",
")",
";",
"MotionTL_manager_LoadCalValuesFromNVM",
"(",
"&",
"accCal",
")",
";",
"MotionTL_SetCalValues",
"(",
"&",
"accCal",
")",
";",
"return",
"1",
";",
"}"
] | @brief Initialize the MotionTL engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionTL",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | [
"// Get calibration values from flash memory and set them in library if valid\r"
] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f46165365fe1ff87a45ab3f9b36d077ad2072000 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/MotionTL_Manager.c | [
"MIT"
] | C | MotionTL_manager_calibratePosition | void | void MotionTL_manager_calibratePosition(MTL_CalPosition_t calPosition)
{
float calData[CAL_DATA_NUM_RECORDS][3];
if (CollectData(calData, CAL_DATA_NUM_RECORDS) == 0)
{
MotionTL_CalibratePosition(calData, CAL_DATA_NUM_RECORDS, calPosition);
}
} | /**
* @brief Calibrate accelerometer in specific position - collect data and pass them to library
* @param calPosition Calibration position the data belong to
* @retval None
*/ | @brief Calibrate accelerometer in specific position - collect data and pass them to library
@param calPosition Calibration position the data belong to
@retval None | [
"@brief",
"Calibrate",
"accelerometer",
"in",
"specific",
"position",
"-",
"collect",
"data",
"and",
"pass",
"them",
"to",
"library",
"@param",
"calPosition",
"Calibration",
"position",
"the",
"data",
"belong",
"to",
"@retval",
"None"
] | void MotionTL_manager_calibratePosition(MTL_CalPosition_t calPosition)
{
float calData[CAL_DATA_NUM_RECORDS][3];
if (CollectData(calData, CAL_DATA_NUM_RECORDS) == 0)
{
MotionTL_CalibratePosition(calData, CAL_DATA_NUM_RECORDS, calPosition);
}
} | [
"void",
"MotionTL_manager_calibratePosition",
"(",
"MTL_CalPosition_t",
"calPosition",
")",
"{",
"float",
"calData",
"[",
"CAL_DATA_NUM_RECORDS",
"]",
"[",
"3",
"]",
";",
"if",
"(",
"CollectData",
"(",
"calData",
",",
"CAL_DATA_NUM_RECORDS",
")",
"==",
"0",
")",
"{",
"MotionTL_CalibratePosition",
"(",
"calData",
",",
"CAL_DATA_NUM_RECORDS",
",",
"calPosition",
")",
";",
"}",
"}"
] | @brief Calibrate accelerometer in specific position - collect data and pass them to library
@param calPosition Calibration position the data belong to
@retval None | [
"@brief",
"Calibrate",
"accelerometer",
"in",
"specific",
"position",
"-",
"collect",
"data",
"and",
"pass",
"them",
"to",
"library",
"@param",
"calPosition",
"Calibration",
"position",
"the",
"data",
"belong",
"to",
"@retval",
"None"
] | [] | [
{
"param": "calPosition",
"type": "MTL_CalPosition_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "calPosition",
"type": "MTL_CalPosition_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f46165365fe1ff87a45ab3f9b36d077ad2072000 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/MotionTL_Manager.c | [
"MIT"
] | C | MotionTL_manager_LoadCalValuesFromNVM | uint8_t | uint8_t MotionTL_manager_LoadCalValuesFromNVM(MTL_AccCal_t *accCal)
{
#if (defined (MOTION_TL_STORE_CALIB_FLASH))
float data[6] = {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
RecallCalibrationFromMemory(6, (uint32_t *)data);
for (int i = 0; i < 3; i++)
{
accCal->offset[i] = data[i];
accCal->gain[i] = data[i + 3];
}
return 0;
#else
return 1;
#endif
} | /**
* @brief Load calibration values from memory
* @param accCal Pointer to structure with offset and gain values
* @retval (1) fail, (0) success
*/ | @brief Load calibration values from memory
@param accCal Pointer to structure with offset and gain values
@retval (1) fail, (0) success | [
"@brief",
"Load",
"calibration",
"values",
"from",
"memory",
"@param",
"accCal",
"Pointer",
"to",
"structure",
"with",
"offset",
"and",
"gain",
"values",
"@retval",
"(",
"1",
")",
"fail",
"(",
"0",
")",
"success"
] | uint8_t MotionTL_manager_LoadCalValuesFromNVM(MTL_AccCal_t *accCal)
{
#if (defined (MOTION_TL_STORE_CALIB_FLASH))
float data[6] = {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
RecallCalibrationFromMemory(6, (uint32_t *)data);
for (int i = 0; i < 3; i++)
{
accCal->offset[i] = data[i];
accCal->gain[i] = data[i + 3];
}
return 0;
#else
return 1;
#endif
} | [
"uint8_t",
"MotionTL_manager_LoadCalValuesFromNVM",
"(",
"MTL_AccCal_t",
"*",
"accCal",
")",
"{",
"#if",
"(",
"defined",
"(",
"MOTION_TL_STORE_CALIB_FLASH",
")",
")",
"\n",
"float",
"data",
"[",
"6",
"]",
"=",
"{",
"0.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"1.0f",
",",
"1.0f",
"}",
";",
"RecallCalibrationFromMemory",
"(",
"6",
",",
"(",
"uint32_t",
"*",
")",
"data",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"accCal",
"->",
"offset",
"[",
"i",
"]",
"=",
"data",
"[",
"i",
"]",
";",
"accCal",
"->",
"gain",
"[",
"i",
"]",
"=",
"data",
"[",
"i",
"+",
"3",
"]",
";",
"}",
"return",
"0",
";",
"#else",
"return",
"1",
";",
"#endif",
"}"
] | @brief Load calibration values from memory
@param accCal Pointer to structure with offset and gain values
@retval (1) fail, (0) success | [
"@brief",
"Load",
"calibration",
"values",
"from",
"memory",
"@param",
"accCal",
"Pointer",
"to",
"structure",
"with",
"offset",
"and",
"gain",
"values",
"@retval",
"(",
"1",
")",
"fail",
"(",
"0",
")",
"success"
] | [] | [
{
"param": "accCal",
"type": "MTL_AccCal_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "accCal",
"type": "MTL_AccCal_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f46165365fe1ff87a45ab3f9b36d077ad2072000 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/MotionTL_Manager.c | [
"MIT"
] | C | MotionTL_manager_SaveCalValuesInNVM | uint8_t | uint8_t MotionTL_manager_SaveCalValuesInNVM(MTL_AccCal_t *accCal)
{
#if (defined (MOTION_TL_STORE_CALIB_FLASH))
float data[6] = {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
for (int i = 0; i < 3; i++)
{
data[i] = accCal->offset[i];
data[i + 3] = accCal->gain[i];
}
SaveCalibrationToMemory(6, (uint32_t *)data);
return 0;
#else
return 1;
#endif
} | /**
* @brief Save calibration values to memory
* @param accCal Pointer to calibration values structure
* @retval (1) fail, (0) success
*/ | @brief Save calibration values to memory
@param accCal Pointer to calibration values structure
@retval (1) fail, (0) success | [
"@brief",
"Save",
"calibration",
"values",
"to",
"memory",
"@param",
"accCal",
"Pointer",
"to",
"calibration",
"values",
"structure",
"@retval",
"(",
"1",
")",
"fail",
"(",
"0",
")",
"success"
] | uint8_t MotionTL_manager_SaveCalValuesInNVM(MTL_AccCal_t *accCal)
{
#if (defined (MOTION_TL_STORE_CALIB_FLASH))
float data[6] = {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
for (int i = 0; i < 3; i++)
{
data[i] = accCal->offset[i];
data[i + 3] = accCal->gain[i];
}
SaveCalibrationToMemory(6, (uint32_t *)data);
return 0;
#else
return 1;
#endif
} | [
"uint8_t",
"MotionTL_manager_SaveCalValuesInNVM",
"(",
"MTL_AccCal_t",
"*",
"accCal",
")",
"{",
"#if",
"(",
"defined",
"(",
"MOTION_TL_STORE_CALIB_FLASH",
")",
")",
"\n",
"float",
"data",
"[",
"6",
"]",
"=",
"{",
"0.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"1.0f",
",",
"1.0f",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"data",
"[",
"i",
"]",
"=",
"accCal",
"->",
"offset",
"[",
"i",
"]",
";",
"data",
"[",
"i",
"+",
"3",
"]",
"=",
"accCal",
"->",
"gain",
"[",
"i",
"]",
";",
"}",
"SaveCalibrationToMemory",
"(",
"6",
",",
"(",
"uint32_t",
"*",
")",
"data",
")",
";",
"return",
"0",
";",
"#else",
"return",
"1",
";",
"#endif",
"}"
] | @brief Save calibration values to memory
@param accCal Pointer to calibration values structure
@retval (1) fail, (0) success | [
"@brief",
"Save",
"calibration",
"values",
"to",
"memory",
"@param",
"accCal",
"Pointer",
"to",
"calibration",
"values",
"structure",
"@retval",
"(",
"1",
")",
"fail",
"(",
"0",
")",
"success"
] | [] | [
{
"param": "accCal",
"type": "MTL_AccCal_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "accCal",
"type": "MTL_AccCal_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601297176ab66da26c77b82f8ba083bc6d2e034f | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/DataLog/Src/DemoSerial.c | [
"MIT"
] | C | INIT_STREAMING_MSG | void | void INIT_STREAMING_MSG(TMsg *Msg)
{
uint8_t i;
Msg->Data[0] = DataStreamingDest;
Msg->Data[1] = DEV_ADDR;
Msg->Data[2] = CMD_Start_Data_Streaming;
for(i = 3; i < STREAMING_MSG_LENGTH + 3; i++)
{
Msg->Data[i] = 0;
}
Msg->Len = 3;
} | /**
* @brief Initialize the streaming message
* @param Msg the pointer to the message to be initialized
* @retval None
*/ | @brief Initialize the streaming message
@param Msg the pointer to the message to be initialized
@retval None | [
"@brief",
"Initialize",
"the",
"streaming",
"message",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"initialized",
"@retval",
"None"
] | void INIT_STREAMING_MSG(TMsg *Msg)
{
uint8_t i;
Msg->Data[0] = DataStreamingDest;
Msg->Data[1] = DEV_ADDR;
Msg->Data[2] = CMD_Start_Data_Streaming;
for(i = 3; i < STREAMING_MSG_LENGTH + 3; i++)
{
Msg->Data[i] = 0;
}
Msg->Len = 3;
} | [
"void",
"INIT_STREAMING_MSG",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"i",
";",
"Msg",
"->",
"Data",
"[",
"0",
"]",
"=",
"DataStreamingDest",
";",
"Msg",
"->",
"Data",
"[",
"1",
"]",
"=",
"DEV_ADDR",
";",
"Msg",
"->",
"Data",
"[",
"2",
"]",
"=",
"CMD_Start_Data_Streaming",
";",
"for",
"(",
"i",
"=",
"3",
";",
"i",
"<",
"STREAMING_MSG_LENGTH",
"+",
"3",
";",
"i",
"++",
")",
"{",
"Msg",
"->",
"Data",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"Msg",
"->",
"Len",
"=",
"3",
";",
"}"
] | @brief Initialize the streaming message
@param Msg the pointer to the message to be initialized
@retval None | [
"@brief",
"Initialize",
"the",
"streaming",
"message",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"initialized",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601297176ab66da26c77b82f8ba083bc6d2e034f | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/DataLog/Src/DemoSerial.c | [
"MIT"
] | C | HandleMSG | int | int HandleMSG(TMsg *Msg)
// DestAddr | SouceAddr | CMD | PAYLOAD
// 1 1 1 N
{
uint32_t i;
uint8_t instance;
if (Msg->Len < 2) return 0;
if (Msg->Data[0] != DEV_ADDR) return 0;
switch (Msg->Data[2]) // CMD
{
case CMD_Ping:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
UART_SendMsg(Msg);
return 1;
case CMD_Enter_DFU_Mode:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
return 1;
case CMD_Read_PresString:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
i = 0; //
while (i < (sizeof(PresentationString) - 1))
{
Msg->Data[3 + i] = PresentationString[i];
i++;
}
Msg->Len = 3 + i;
UART_SendMsg(Msg);
return 1;
case CMD_CheckModeSupport:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER(Msg);
Serialize_s32(&Msg->Data[3], DATALOG_MODE, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_PRESSURE_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
BSP_PRESSURE_Get_Instance( PRESSURE_handle, &instance );
switch (instance)
{
case LPS25HB_P_0:
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
break;
case LPS25HB_P_1:
Serialize_s32(&Msg->Data[3], 2, 4);
Msg->Len = 3 + 4;
break;
case LPS22HB_P_0:
Serialize_s32(&Msg->Data[3], 3, 4);
Msg->Len = 3 + 4;
break;
default:
break;
}
UART_SendMsg(Msg);
return 1;
case CMD_HUMIDITY_TEMPERATURE_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_ACCELERO_GYRO_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
/* We can check one between accelerometer instance and gyroscope instance */
BSP_GYRO_Get_Instance( GYRO_handle, &instance );
switch (instance)
{
case LSM6DS0_G_0:
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
break;
case LSM6DS3_G_0:
Serialize_s32(&Msg->Data[3], 2, 4);
Msg->Len = 3 + 4;
break;
default:
break;
}
UART_SendMsg(Msg);
return 1;
case CMD_MAGNETO_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_Start_Data_Streaming:
if (Msg->Len < 3) return 0;
Sensors_Enabled = Deserialize(&Msg->Data[3], 4);
DataTxPeriod = Deserialize(&Msg->Data[7], 4);
DataLoggerActive = 1;
DataStreamingDest = Msg->Data[1];
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
UART_SendMsg(Msg);
return 1;
case CMD_Stop_Data_Streaming:
if (Msg->Len < 3) return 0;
Sensors_Enabled = 0;
DataLoggerActive = 0;
BUILD_REPLY_HEADER(Msg);
UART_SendMsg(Msg);
return 1;
case CMD_Set_DateTime:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
RTC_TimeRegulate(Msg->Data[3], Msg->Data[4], Msg->Data[5]);
UART_SendMsg(Msg);
return 1;
default:
return 0;
}
} | /**
* @brief Handle a message
* @param Msg the pointer to the message to be handled
* @retval 1 if the message is correctly handled, 0 otherwise
*/ | @brief Handle a message
@param Msg the pointer to the message to be handled
@retval 1 if the message is correctly handled, 0 otherwise | [
"@brief",
"Handle",
"a",
"message",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"handled",
"@retval",
"1",
"if",
"the",
"message",
"is",
"correctly",
"handled",
"0",
"otherwise"
] | int HandleMSG(TMsg *Msg)
{
uint32_t i;
uint8_t instance;
if (Msg->Len < 2) return 0;
if (Msg->Data[0] != DEV_ADDR) return 0;
switch (Msg->Data[2])
{
case CMD_Ping:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
UART_SendMsg(Msg);
return 1;
case CMD_Enter_DFU_Mode:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
return 1;
case CMD_Read_PresString:
if (Msg->Len != 3) return 0;
BUILD_REPLY_HEADER(Msg);
i = 0;
while (i < (sizeof(PresentationString) - 1))
{
Msg->Data[3 + i] = PresentationString[i];
i++;
}
Msg->Len = 3 + i;
UART_SendMsg(Msg);
return 1;
case CMD_CheckModeSupport:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER(Msg);
Serialize_s32(&Msg->Data[3], DATALOG_MODE, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_PRESSURE_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
BSP_PRESSURE_Get_Instance( PRESSURE_handle, &instance );
switch (instance)
{
case LPS25HB_P_0:
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
break;
case LPS25HB_P_1:
Serialize_s32(&Msg->Data[3], 2, 4);
Msg->Len = 3 + 4;
break;
case LPS22HB_P_0:
Serialize_s32(&Msg->Data[3], 3, 4);
Msg->Len = 3 + 4;
break;
default:
break;
}
UART_SendMsg(Msg);
return 1;
case CMD_HUMIDITY_TEMPERATURE_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_ACCELERO_GYRO_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
BSP_GYRO_Get_Instance( GYRO_handle, &instance );
switch (instance)
{
case LSM6DS0_G_0:
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
break;
case LSM6DS3_G_0:
Serialize_s32(&Msg->Data[3], 2, 4);
Msg->Len = 3 + 4;
break;
default:
break;
}
UART_SendMsg(Msg);
return 1;
case CMD_MAGNETO_Init:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER( Msg );
Serialize_s32(&Msg->Data[3], 1, 4);
Msg->Len = 3 + 4;
UART_SendMsg(Msg);
return 1;
case CMD_Start_Data_Streaming:
if (Msg->Len < 3) return 0;
Sensors_Enabled = Deserialize(&Msg->Data[3], 4);
DataTxPeriod = Deserialize(&Msg->Data[7], 4);
DataLoggerActive = 1;
DataStreamingDest = Msg->Data[1];
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
UART_SendMsg(Msg);
return 1;
case CMD_Stop_Data_Streaming:
if (Msg->Len < 3) return 0;
Sensors_Enabled = 0;
DataLoggerActive = 0;
BUILD_REPLY_HEADER(Msg);
UART_SendMsg(Msg);
return 1;
case CMD_Set_DateTime:
if (Msg->Len < 3) return 0;
BUILD_REPLY_HEADER(Msg);
Msg->Len = 3;
RTC_TimeRegulate(Msg->Data[3], Msg->Data[4], Msg->Data[5]);
UART_SendMsg(Msg);
return 1;
default:
return 0;
}
} | [
"int",
"HandleMSG",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint32_t",
"i",
";",
"uint8_t",
"instance",
";",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"2",
")",
"return",
"0",
";",
"if",
"(",
"Msg",
"->",
"Data",
"[",
"0",
"]",
"!=",
"DEV_ADDR",
")",
"return",
"0",
";",
"switch",
"(",
"Msg",
"->",
"Data",
"[",
"2",
"]",
")",
"{",
"case",
"CMD_Ping",
":",
"if",
"(",
"Msg",
"->",
"Len",
"!=",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_Enter_DFU_Mode",
":",
"if",
"(",
"Msg",
"->",
"Len",
"!=",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
";",
"return",
"1",
";",
"case",
"CMD_Read_PresString",
":",
"if",
"(",
"Msg",
"->",
"Len",
"!=",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"(",
"sizeof",
"(",
"PresentationString",
")",
"-",
"1",
")",
")",
"{",
"Msg",
"->",
"Data",
"[",
"3",
"+",
"i",
"]",
"=",
"PresentationString",
"[",
"i",
"]",
";",
"i",
"++",
";",
"}",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"i",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_CheckModeSupport",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"DATALOG_MODE",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_PRESSURE_Init",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"BSP_PRESSURE_Get_Instance",
"(",
"PRESSURE_handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"case",
"LPS25HB_P_0",
":",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"1",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"break",
";",
"case",
"LPS25HB_P_1",
":",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"2",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"break",
";",
"case",
"LPS22HB_P_0",
":",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"3",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_HUMIDITY_TEMPERATURE_Init",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"1",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_ACCELERO_GYRO_Init",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"BSP_GYRO_Get_Instance",
"(",
"GYRO_handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"case",
"LSM6DS0_G_0",
":",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"1",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"break",
";",
"case",
"LSM6DS3_G_0",
":",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"2",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_MAGNETO_Init",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"1",
",",
"4",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
"+",
"4",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_Start_Data_Streaming",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"Sensors_Enabled",
"=",
"Deserialize",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"4",
")",
";",
"DataTxPeriod",
"=",
"Deserialize",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"7",
"]",
",",
"4",
")",
";",
"DataLoggerActive",
"=",
"1",
";",
"DataStreamingDest",
"=",
"Msg",
"->",
"Data",
"[",
"1",
"]",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_Stop_Data_Streaming",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"Sensors_Enabled",
"=",
"0",
";",
"DataLoggerActive",
"=",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"case",
"CMD_Set_DateTime",
":",
"if",
"(",
"Msg",
"->",
"Len",
"<",
"3",
")",
"return",
"0",
";",
"BUILD_REPLY_HEADER",
"(",
"Msg",
")",
";",
"Msg",
"->",
"Len",
"=",
"3",
";",
"RTC_TimeRegulate",
"(",
"Msg",
"->",
"Data",
"[",
"3",
"]",
",",
"Msg",
"->",
"Data",
"[",
"4",
"]",
",",
"Msg",
"->",
"Data",
"[",
"5",
"]",
")",
";",
"UART_SendMsg",
"(",
"Msg",
")",
";",
"return",
"1",
";",
"default",
":",
"return",
"0",
";",
"}",
"}"
] | @brief Handle a message
@param Msg the pointer to the message to be handled
@retval 1 if the message is correctly handled, 0 otherwise | [
"@brief",
"Handle",
"a",
"message",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"handled",
"@retval",
"1",
"if",
"the",
"message",
"is",
"correctly",
"handled",
"0",
"otherwise"
] | [
"// DestAddr | SouceAddr | CMD | PAYLOAD\r",
"// 1 1 1 N\r",
"// CMD\r",
"//\r",
"/* We can check one between accelerometer instance and gyroscope instance */"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
591910aec6e612d4547199a99a4c46ba196e8be3 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_6DOrientation/Src/main.c | [
"MIT"
] | C | sendOrientation | void | static void sendOrientation( void )
{
uint8_t xl = 0;
uint8_t xh = 0;
uint8_t yl = 0;
uint8_t yh = 0;
uint8_t zl = 0;
uint8_t zh = 0;
uint8_t instance;
BSP_ACCELERO_Get_Instance( LSM6DSL_X_0_handle, &instance );
if ( BSP_ACCELERO_Get_6D_Orientation_XL_Ext( LSM6DSL_X_0_handle, &xl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_XH_Ext( LSM6DSL_X_0_handle, &xh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_YL_Ext( LSM6DSL_X_0_handle, &yl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_YH_Ext( LSM6DSL_X_0_handle, &yh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_ZL_Ext( LSM6DSL_X_0_handle, &zl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_ZH_Ext( LSM6DSL_X_0_handle, &zh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n __*_____________ " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n |________________| " \
"\r\n * \r\n" );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "None of the 6D orientation axes is set in LSM6DSL - accelerometer[%d].\r\n", instance );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
} | /**
* @brief Send actual 6D orientation to UART
* @param None
* @retval None
*/ | @brief Send actual 6D orientation to UART
@param None
@retval None | [
"@brief",
"Send",
"actual",
"6D",
"orientation",
"to",
"UART",
"@param",
"None",
"@retval",
"None"
] | static void sendOrientation( void )
{
uint8_t xl = 0;
uint8_t xh = 0;
uint8_t yl = 0;
uint8_t yh = 0;
uint8_t zl = 0;
uint8_t zh = 0;
uint8_t instance;
BSP_ACCELERO_Get_Instance( LSM6DSL_X_0_handle, &instance );
if ( BSP_ACCELERO_Get_6D_Orientation_XL_Ext( LSM6DSL_X_0_handle, &xl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_XH_Ext( LSM6DSL_X_0_handle, &xh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_YL_Ext( LSM6DSL_X_0_handle, &yl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_YH_Ext( LSM6DSL_X_0_handle, &yh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_ZL_Ext( LSM6DSL_X_0_handle, &zl ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZL axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( BSP_ACCELERO_Get_6D_Orientation_ZH_Ext( LSM6DSL_X_0_handle, &zh ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZH axis from LSM6DSL - accelerometer[%d].\r\n", instance );
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
return;
}
if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n __*_____________ " \
"\r\n |________________| \r\n" );
}
else if ( xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0 )
{
snprintf( dataOut, MAX_BUF_SIZE, "\r\n ________________ " \
"\r\n |________________| " \
"\r\n * \r\n" );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "None of the 6D orientation axes is set in LSM6DSL - accelerometer[%d].\r\n", instance );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
} | [
"static",
"void",
"sendOrientation",
"(",
"void",
")",
"{",
"uint8_t",
"xl",
"=",
"0",
";",
"uint8_t",
"xh",
"=",
"0",
";",
"uint8_t",
"yl",
"=",
"0",
";",
"uint8_t",
"yh",
"=",
"0",
";",
"uint8_t",
"zl",
"=",
"0",
";",
"uint8_t",
"zh",
"=",
"0",
";",
"uint8_t",
"instance",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"instance",
")",
";",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_XL_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"xl",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_XH_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"xh",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_YL_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"yl",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_YH_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"yh",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_ZL_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"zl",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"BSP_ACCELERO_Get_6D_Orientation_ZH_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"zh",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"return",
";",
"}",
"if",
"(",
"xl",
"==",
"0",
"&&",
"yl",
"==",
"0",
"&&",
"zl",
"==",
"0",
"&&",
"xh",
"==",
"0",
"&&",
"yh",
"==",
"1",
"&&",
"zh",
"==",
"0",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"xl",
"==",
"1",
"&&",
"yl",
"==",
"0",
"&&",
"zl",
"==",
"0",
"&&",
"xh",
"==",
"0",
"&&",
"yh",
"==",
"0",
"&&",
"zh",
"==",
"0",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"xl",
"==",
"0",
"&&",
"yl",
"==",
"0",
"&&",
"zl",
"==",
"0",
"&&",
"xh",
"==",
"1",
"&&",
"yh",
"==",
"0",
"&&",
"zh",
"==",
"0",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"xl",
"==",
"0",
"&&",
"yl",
"==",
"1",
"&&",
"zl",
"==",
"0",
"&&",
"xh",
"==",
"0",
"&&",
"yh",
"==",
"0",
"&&",
"zh",
"==",
"0",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"xl",
"==",
"0",
"&&",
"yl",
"==",
"0",
"&&",
"zl",
"==",
"0",
"&&",
"xh",
"==",
"0",
"&&",
"yh",
"==",
"0",
"&&",
"zh",
"==",
"1",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"xl",
"==",
"0",
"&&",
"yl",
"==",
"0",
"&&",
"zl",
"==",
"1",
"&&",
"xh",
"==",
"0",
"&&",
"yh",
"==",
"0",
"&&",
"zh",
"==",
"0",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\"",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}"
] | @brief Send actual 6D orientation to UART
@param None
@retval None | [
"@brief",
"Send",
"actual",
"6D",
"orientation",
"to",
"UART",
"@param",
"None",
"@retval",
"None"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
591910aec6e612d4547199a99a4c46ba196e8be3 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_6DOrientation/Src/main.c | [
"MIT"
] | C | HAL_GPIO_EXTI_Callback | void | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
/* User button. */
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
/* Request to send actual 6D orientation to UART (available only for LSM6DSL sensor). */
send_orientation_request = 1;
}
}
/* 6D orientation (available only for LSM6DSL sensor). */
else if ( GPIO_Pin == LSM6DSL_INT1_O_PIN )
{
mems_event_detected = 1;
}
} | /**
* @brief EXTI line detection callbacks
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/ | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
send_orientation_request = 1;
}
}
else if ( GPIO_Pin == LSM6DSL_INT1_O_PIN )
{
mems_event_detected = 1;
}
} | [
"void",
"HAL_GPIO_EXTI_Callback",
"(",
"uint16_t",
"GPIO_Pin",
")",
"{",
"if",
"(",
"GPIO_Pin",
"==",
"KEY_BUTTON_PIN",
")",
"{",
"if",
"(",
"BSP_PB_GetState",
"(",
"BUTTON_KEY",
")",
"==",
"GPIO_PIN_RESET",
")",
"{",
"send_orientation_request",
"=",
"1",
";",
"}",
"}",
"else",
"if",
"(",
"GPIO_Pin",
"==",
"LSM6DSL_INT1_O_PIN",
")",
"{",
"mems_event_detected",
"=",
"1",
";",
"}",
"}"
] | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | [
"/* User button. */",
"/* Request to send actual 6D orientation to UART (available only for LSM6DSL sensor). */",
"/* 6D orientation (available only for LSM6DSL sensor). */"
] | [
{
"param": "GPIO_Pin",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GPIO_Pin",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
591910aec6e612d4547199a99a4c46ba196e8be3 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_6DOrientation/Src/main.c | [
"MIT"
] | C | assert_failed | void | void assert_failed( uint8_t *file, uint32_t line )
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\r\n", file, line) */
/* Infinite loop */
while (1)
{}
} | /**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred
* @param file pointer to the source file name
* @param line assert_param error line source number
* @retval None
*/ | @brief Reports the name of the source file and the source line number
where the assert_param error has occurred
@param file pointer to the source file name
@param line assert_param error line source number
@retval None | [
"@brief",
"Reports",
"the",
"name",
"of",
"the",
"source",
"file",
"and",
"the",
"source",
"line",
"number",
"where",
"the",
"assert_param",
"error",
"has",
"occurred",
"@param",
"file",
"pointer",
"to",
"the",
"source",
"file",
"name",
"@param",
"line",
"assert_param",
"error",
"line",
"source",
"number",
"@retval",
"None"
] | void assert_failed( uint8_t *file, uint32_t line )
{
while (1)
{}
} | [
"void",
"assert_failed",
"(",
"uint8_t",
"*",
"file",
",",
"uint32_t",
"line",
")",
"{",
"while",
"(",
"1",
")",
"{",
"}",
"}"
] | @brief Reports the name of the source file and the source line number
where the assert_param error has occurred
@param file pointer to the source file name
@param line assert_param error line source number
@retval None | [
"@brief",
"Reports",
"the",
"name",
"of",
"the",
"source",
"file",
"and",
"the",
"source",
"line",
"number",
"where",
"the",
"assert_param",
"error",
"has",
"occurred",
"@param",
"file",
"pointer",
"to",
"the",
"source",
"file",
"name",
"@param",
"line",
"assert_param",
"error",
"line",
"source",
"number",
"@retval",
"None"
] | [
"/* User can add his own implementation to report the file name and line number,\r\n ex: printf(\"Wrong parameters value: file %s on line %d\\r\\r\\n\", file, line) */",
"/* Infinite loop */"
] | [
{
"param": "file",
"type": "uint8_t"
},
{
"param": "line",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1dd1972a9f2fae6252e20fbe5442e8bcfd2fa9be | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/StandingSittingDesk/Src/MotionSD_Manager.c | [
"MIT"
] | C | MotionSD_manager_init | void | void MotionSD_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionSD_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return;
#else
#error Not supported platform
#endif
}
MotionSD_SetOrientation_Acc(acc_orientation);
} | /**
* @brief Initialises MotionSD algorithm
* @param handle handle to accelerometer sensor
* @retval none
*/ | @brief Initialises MotionSD algorithm
@param handle handle to accelerometer sensor
@retval none | [
"@brief",
"Initialises",
"MotionSD",
"algorithm",
"@param",
"handle",
"handle",
"to",
"accelerometer",
"sensor",
"@retval",
"none"
] | void MotionSD_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionSD_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return;
#else
#error Not supported platform
#endif
}
MotionSD_SetOrientation_Acc(acc_orientation);
} | [
"void",
"MotionSD_manager_init",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"instance",
";",
"char",
"acc_orientation",
"[",
"3",
"]",
";",
"MotionSD_Initialize",
"(",
")",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_IKS01A1",
")",
")",
"\n",
"case",
"LSM6DS0_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM6DS3_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
";",
"#elif",
"(",
"defined",
"(",
"USE_IKS01A2",
")",
")",
"\n",
"case",
"LSM6DSL_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM303AGR_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"}",
"MotionSD_SetOrientation_Acc",
"(",
"acc_orientation",
")",
";",
"}"
] | @brief Initialises MotionSD algorithm
@param handle handle to accelerometer sensor
@retval none | [
"@brief",
"Initialises",
"MotionSD",
"algorithm",
"@param",
"handle",
"handle",
"to",
"accelerometer",
"sensor",
"@retval",
"none"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
790d1f28b790e6d82c3b75ed4ccbf36867988d43 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/cube_hal_f4.c | [
"MIT"
] | C | SystemClock_Config | void | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable Power Control clock */
__PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
/* Enable HSE Oscillator and activate PLL with HSI as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
} | /**
* @brief System Clock Configuration
* @param None
* @retval None
*/ | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
} | [
"void",
"SystemClock_Config",
"(",
"void",
")",
"{",
"RCC_ClkInitTypeDef",
"RCC_ClkInitStruct",
";",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
";",
"__PWR_CLK_ENABLE",
"(",
")",
";",
"__HAL_PWR_VOLTAGESCALING_CONFIG",
"(",
"PWR_REGULATOR_VOLTAGE_SCALE2",
")",
";",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_HSI",
";",
"RCC_OscInitStruct",
".",
"HSIState",
"=",
"RCC_HSI_ON",
";",
"RCC_OscInitStruct",
".",
"HSICalibrationValue",
"=",
"16",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_ON",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLSource",
"=",
"RCC_PLLSOURCE_HSI",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLM",
"=",
"16",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLN",
"=",
"336",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLP",
"=",
"RCC_PLLP_DIV4",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLQ",
"=",
"7",
";",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
";",
"RCC_ClkInitStruct",
".",
"ClockType",
"=",
"(",
"RCC_CLOCKTYPE_SYSCLK",
"|",
"RCC_CLOCKTYPE_HCLK",
"|",
"RCC_CLOCKTYPE_PCLK1",
"|",
"RCC_CLOCKTYPE_PCLK2",
")",
";",
"RCC_ClkInitStruct",
".",
"SYSCLKSource",
"=",
"RCC_SYSCLKSOURCE_PLLCLK",
";",
"RCC_ClkInitStruct",
".",
"AHBCLKDivider",
"=",
"RCC_SYSCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB1CLKDivider",
"=",
"RCC_HCLK_DIV2",
";",
"RCC_ClkInitStruct",
".",
"APB2CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"HAL_RCC_ClockConfig",
"(",
"&",
"RCC_ClkInitStruct",
",",
"FLASH_LATENCY_2",
")",
";",
"}"
] | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | [
"/* Enable Power Control clock */",
"/* The voltage scaling allows optimizing the power consumption when the device is\r\n clocked below the maximum system frequency, to update the voltage scaling value\r\n regarding system frequency refer to product datasheet. */",
"/* Enable HSE Oscillator and activate PLL with HSI as source */",
"/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2\r\n clocks dividers */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
790d1f28b790e6d82c3b75ed4ccbf36867988d43 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/TiltSensing/Src/cube_hal_f4.c | [
"MIT"
] | C | Config_DMA_Handler | void | void Config_DMA_Handler(DMA_HandleTypeDef *handle_dma)
{
handle_dma->Instance = DMA1_Stream5;
handle_dma->Init.Channel = DMA_CHANNEL_4;
handle_dma->Init.Direction = DMA_PERIPH_TO_MEMORY;
handle_dma->Init.PeriphInc = DMA_PINC_DISABLE;
handle_dma->Init.MemInc = DMA_MINC_ENABLE;
handle_dma->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
handle_dma->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
handle_dma->Init.Mode = DMA_CIRCULAR;//DMA_CIRCULAR;
handle_dma->Init.Priority = DMA_PRIORITY_MEDIUM;
handle_dma->Init.FIFOMode = DMA_FIFOMODE_DISABLE;
handle_dma->Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
handle_dma->Init.MemBurst = DMA_MBURST_INC4;
handle_dma->Init.PeriphBurst = DMA_MBURST_INC4;
} | /**
* @brief Configure the DMA handler for transmission process
* @param handle_dma DMA handle
* @retval None
*/ | @brief Configure the DMA handler for transmission process
@param handle_dma DMA handle
@retval None | [
"@brief",
"Configure",
"the",
"DMA",
"handler",
"for",
"transmission",
"process",
"@param",
"handle_dma",
"DMA",
"handle",
"@retval",
"None"
] | void Config_DMA_Handler(DMA_HandleTypeDef *handle_dma)
{
handle_dma->Instance = DMA1_Stream5;
handle_dma->Init.Channel = DMA_CHANNEL_4;
handle_dma->Init.Direction = DMA_PERIPH_TO_MEMORY;
handle_dma->Init.PeriphInc = DMA_PINC_DISABLE;
handle_dma->Init.MemInc = DMA_MINC_ENABLE;
handle_dma->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
handle_dma->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
handle_dma->Init.Mode = DMA_CIRCULAR;
handle_dma->Init.Priority = DMA_PRIORITY_MEDIUM;
handle_dma->Init.FIFOMode = DMA_FIFOMODE_DISABLE;
handle_dma->Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
handle_dma->Init.MemBurst = DMA_MBURST_INC4;
handle_dma->Init.PeriphBurst = DMA_MBURST_INC4;
} | [
"void",
"Config_DMA_Handler",
"(",
"DMA_HandleTypeDef",
"*",
"handle_dma",
")",
"{",
"handle_dma",
"->",
"Instance",
"=",
"DMA1_Stream5",
";",
"handle_dma",
"->",
"Init",
".",
"Channel",
"=",
"DMA_CHANNEL_4",
";",
"handle_dma",
"->",
"Init",
".",
"Direction",
"=",
"DMA_PERIPH_TO_MEMORY",
";",
"handle_dma",
"->",
"Init",
".",
"PeriphInc",
"=",
"DMA_PINC_DISABLE",
";",
"handle_dma",
"->",
"Init",
".",
"MemInc",
"=",
"DMA_MINC_ENABLE",
";",
"handle_dma",
"->",
"Init",
".",
"PeriphDataAlignment",
"=",
"DMA_PDATAALIGN_BYTE",
";",
"handle_dma",
"->",
"Init",
".",
"MemDataAlignment",
"=",
"DMA_MDATAALIGN_BYTE",
";",
"handle_dma",
"->",
"Init",
".",
"Mode",
"=",
"DMA_CIRCULAR",
";",
"handle_dma",
"->",
"Init",
".",
"Priority",
"=",
"DMA_PRIORITY_MEDIUM",
";",
"handle_dma",
"->",
"Init",
".",
"FIFOMode",
"=",
"DMA_FIFOMODE_DISABLE",
";",
"handle_dma",
"->",
"Init",
".",
"FIFOThreshold",
"=",
"DMA_FIFO_THRESHOLD_FULL",
";",
"handle_dma",
"->",
"Init",
".",
"MemBurst",
"=",
"DMA_MBURST_INC4",
";",
"handle_dma",
"->",
"Init",
".",
"PeriphBurst",
"=",
"DMA_MBURST_INC4",
";",
"}"
] | @brief Configure the DMA handler for transmission process
@param handle_dma DMA handle
@retval None | [
"@brief",
"Configure",
"the",
"DMA",
"handler",
"for",
"transmission",
"process",
"@param",
"handle_dma",
"DMA",
"handle",
"@retval",
"None"
] | [
"//DMA_CIRCULAR;\r"
] | [
{
"param": "handle_dma",
"type": "DMA_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle_dma",
"type": "DMA_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c4183b554f72413fd243336e0d2d7021cbe2b27 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/GestureRecognition/Src/MotionGR_Manager.c | [
"MIT"
] | C | MotionGR_manager_init | uint8_t | uint8_t MotionGR_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionGR_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0: // TODO: Check real orientation on PCB
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return 0;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return 0;
#else
#error Not supported platform
#endif
}
MotionGR_SetOrientation_Acc(acc_orientation);
return 1;
} | /**
* @brief Initialize the MotionGR engine
* @param None
* @retval 1 in case of success,
* @retval 0 otherwise
*/ | @brief Initialize the MotionGR engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionGR",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | uint8_t MotionGR_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionGR_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return 0;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return 0;
#else
#error Not supported platform
#endif
}
MotionGR_SetOrientation_Acc(acc_orientation);
return 1;
} | [
"uint8_t",
"MotionGR_manager_init",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"instance",
";",
"char",
"acc_orientation",
"[",
"3",
"]",
";",
"MotionGR_Initialize",
"(",
")",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_IKS01A1",
")",
")",
"\n",
"case",
"LSM6DS0_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM6DS3_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
"0",
";",
"#elif",
"(",
"defined",
"(",
"USE_IKS01A2",
")",
")",
"\n",
"case",
"LSM6DSL_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM303AGR_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
"0",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"}",
"MotionGR_SetOrientation_Acc",
"(",
"acc_orientation",
")",
";",
"return",
"1",
";",
"}"
] | @brief Initialize the MotionGR engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionGR",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | [
"// TODO: Check real orientation on PCB\r"
] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2469847434dc2fcf1a155fb79bc29b724abb03e | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/ECompass/Src/MotionEC_Manager.c | [
"MIT"
] | C | MotionEC_manager_init | void | void MotionEC_manager_init(float freq)
{
MotionEC_Initialize(freq);
MotionEC_SetOrientationEnable(MEC_ENABLE);
MotionEC_SetVirtualGyroEnable(MEC_ENABLE);
MotionEC_SetGravityEnable(MEC_ENABLE);
MotionEC_SetLinearAccEnable(MEC_ENABLE);
} | /**
* @brief Initialize and reset the MotionEC engine
* @param freq Sensors sampling frequency [Hz]
* @retval none
*/ | @brief Initialize and reset the MotionEC engine
@param freq Sensors sampling frequency [Hz]
@retval none | [
"@brief",
"Initialize",
"and",
"reset",
"the",
"MotionEC",
"engine",
"@param",
"freq",
"Sensors",
"sampling",
"frequency",
"[",
"Hz",
"]",
"@retval",
"none"
] | void MotionEC_manager_init(float freq)
{
MotionEC_Initialize(freq);
MotionEC_SetOrientationEnable(MEC_ENABLE);
MotionEC_SetVirtualGyroEnable(MEC_ENABLE);
MotionEC_SetGravityEnable(MEC_ENABLE);
MotionEC_SetLinearAccEnable(MEC_ENABLE);
} | [
"void",
"MotionEC_manager_init",
"(",
"float",
"freq",
")",
"{",
"MotionEC_Initialize",
"(",
"freq",
")",
";",
"MotionEC_SetOrientationEnable",
"(",
"MEC_ENABLE",
")",
";",
"MotionEC_SetVirtualGyroEnable",
"(",
"MEC_ENABLE",
")",
";",
"MotionEC_SetGravityEnable",
"(",
"MEC_ENABLE",
")",
";",
"MotionEC_SetLinearAccEnable",
"(",
"MEC_ENABLE",
")",
";",
"}"
] | @brief Initialize and reset the MotionEC engine
@param freq Sensors sampling frequency [Hz]
@retval none | [
"@brief",
"Initialize",
"and",
"reset",
"the",
"MotionEC",
"engine",
"@param",
"freq",
"Sensors",
"sampling",
"frequency",
"[",
"Hz",
"]",
"@retval",
"none"
] | [] | [
{
"param": "freq",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "freq",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2469847434dc2fcf1a155fb79bc29b724abb03e | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/ECompass/Src/MotionEC_Manager.c | [
"MIT"
] | C | MotionEC_manager_run | void | void MotionEC_manager_run(TMsg *Msg)
{
MEC_input_t data_in;
MEC_output_t data_out;
/* Do sensor orientation transformation */
#if (defined (USE_IKS01A1))
transform_xyz_to_enu(&ACC_Value, data_in.Acc, LSM6DS0_0_Matrix);
transform_xyz_to_enu(&MAG_ValueComp, data_in.Mag, LIS3MDL_0_Matrix);
#elif (defined (USE_IKS01A2))
transform_xyz_to_enu(&ACC_Value, data_in.Acc, LSM303AGR_0_Matrix);
transform_xyz_to_enu(&MAG_ValueComp, data_in.Mag, LSM303AGR_0_Matrix);
#else
#error "ERROR: Unknown MEMS shield!"
#endif
/* Raw accelerometer data [g] */
data_in.Acc[0] = data_in.Acc[0] / 1000.0f; /* East */
data_in.Acc[1] = data_in.Acc[1] / 1000.0f; /* North */
data_in.Acc[2] = data_in.Acc[2] / 1000.0f; /* Up */
/* Compensated magnetometer data [uT / 50], [mGauss / 5] */
data_in.Mag[0] = data_in.Mag[0] / 5.0f; /* East */
data_in.Mag[1] = data_in.Mag[1] / 5.0f; /* North */
data_in.Mag[2] = data_in.Mag[2] / 5.0f; /* Up */
/* Delta time [s] */
data_in.DTime = REPORT_INTERVAL / 1000.0f;
/* Do calculation */
MotionEC_Run(&data_in, &data_out);
/* Write data to output stream */
FloatToArray(&Msg->Data[55], data_out.Quaternion[0]);
FloatToArray(&Msg->Data[59], data_out.Quaternion[1]);
FloatToArray(&Msg->Data[63], data_out.Quaternion[2]);
FloatToArray(&Msg->Data[67], data_out.Quaternion[3]);
FloatToArray(&Msg->Data[71], data_out.Euler[0]);
FloatToArray(&Msg->Data[75], data_out.Euler[1]);
FloatToArray(&Msg->Data[79], data_out.Euler[2]);
FloatToArray(&Msg->Data[83], data_out.IGyro[0]);
FloatToArray(&Msg->Data[87], data_out.IGyro[1]);
FloatToArray(&Msg->Data[91], data_out.IGyro[2]);
FloatToArray(&Msg->Data[95], data_out.Gravity[0]);
FloatToArray(&Msg->Data[99], data_out.Gravity[1]);
FloatToArray(&Msg->Data[103], data_out.Gravity[2]);
FloatToArray(&Msg->Data[107], data_out.Linear[0]);
FloatToArray(&Msg->Data[111], data_out.Linear[1]);
FloatToArray(&Msg->Data[115], data_out.Linear[2]);
float v_base[3] = {0.0, 1.0, 0.0};
float v_head[3];
float heading;
int heading_valid = 0;
v_rotate(v_head, data_out.Quaternion, v_base);
heading_valid = calc_heading(&heading, v_head);
FloatToArray(&Msg->Data[119], heading);
Msg->Data[123] = (uint8_t)heading_valid;
} | /**
* @brief Run E-Compass algorithm (accelerometer and magnetometer data fusion)
* @param Msg Data stream
* @retval none
*/ | @brief Run E-Compass algorithm (accelerometer and magnetometer data fusion)
@param Msg Data stream
@retval none | [
"@brief",
"Run",
"E",
"-",
"Compass",
"algorithm",
"(",
"accelerometer",
"and",
"magnetometer",
"data",
"fusion",
")",
"@param",
"Msg",
"Data",
"stream",
"@retval",
"none"
] | void MotionEC_manager_run(TMsg *Msg)
{
MEC_input_t data_in;
MEC_output_t data_out;
#if (defined (USE_IKS01A1))
transform_xyz_to_enu(&ACC_Value, data_in.Acc, LSM6DS0_0_Matrix);
transform_xyz_to_enu(&MAG_ValueComp, data_in.Mag, LIS3MDL_0_Matrix);
#elif (defined (USE_IKS01A2))
transform_xyz_to_enu(&ACC_Value, data_in.Acc, LSM303AGR_0_Matrix);
transform_xyz_to_enu(&MAG_ValueComp, data_in.Mag, LSM303AGR_0_Matrix);
#else
#error "ERROR: Unknown MEMS shield!"
#endif
data_in.Acc[0] = data_in.Acc[0] / 1000.0f;
data_in.Acc[1] = data_in.Acc[1] / 1000.0f;
data_in.Acc[2] = data_in.Acc[2] / 1000.0f;
data_in.Mag[0] = data_in.Mag[0] / 5.0f;
data_in.Mag[1] = data_in.Mag[1] / 5.0f;
data_in.Mag[2] = data_in.Mag[2] / 5.0f;
data_in.DTime = REPORT_INTERVAL / 1000.0f;
MotionEC_Run(&data_in, &data_out);
FloatToArray(&Msg->Data[55], data_out.Quaternion[0]);
FloatToArray(&Msg->Data[59], data_out.Quaternion[1]);
FloatToArray(&Msg->Data[63], data_out.Quaternion[2]);
FloatToArray(&Msg->Data[67], data_out.Quaternion[3]);
FloatToArray(&Msg->Data[71], data_out.Euler[0]);
FloatToArray(&Msg->Data[75], data_out.Euler[1]);
FloatToArray(&Msg->Data[79], data_out.Euler[2]);
FloatToArray(&Msg->Data[83], data_out.IGyro[0]);
FloatToArray(&Msg->Data[87], data_out.IGyro[1]);
FloatToArray(&Msg->Data[91], data_out.IGyro[2]);
FloatToArray(&Msg->Data[95], data_out.Gravity[0]);
FloatToArray(&Msg->Data[99], data_out.Gravity[1]);
FloatToArray(&Msg->Data[103], data_out.Gravity[2]);
FloatToArray(&Msg->Data[107], data_out.Linear[0]);
FloatToArray(&Msg->Data[111], data_out.Linear[1]);
FloatToArray(&Msg->Data[115], data_out.Linear[2]);
float v_base[3] = {0.0, 1.0, 0.0};
float v_head[3];
float heading;
int heading_valid = 0;
v_rotate(v_head, data_out.Quaternion, v_base);
heading_valid = calc_heading(&heading, v_head);
FloatToArray(&Msg->Data[119], heading);
Msg->Data[123] = (uint8_t)heading_valid;
} | [
"void",
"MotionEC_manager_run",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"MEC_input_t",
"data_in",
";",
"MEC_output_t",
"data_out",
";",
"#if",
"(",
"defined",
"(",
"USE_IKS01A1",
")",
")",
"\n",
"transform_xyz_to_enu",
"(",
"&",
"ACC_Value",
",",
"data_in",
".",
"Acc",
",",
"LSM6DS0_0_Matrix",
")",
";",
"transform_xyz_to_enu",
"(",
"&",
"MAG_ValueComp",
",",
"data_in",
".",
"Mag",
",",
"LIS3MDL_0_Matrix",
")",
";",
"#elif",
"(",
"defined",
"(",
"USE_IKS01A2",
")",
")",
"\n",
"transform_xyz_to_enu",
"(",
"&",
"ACC_Value",
",",
"data_in",
".",
"Acc",
",",
"LSM303AGR_0_Matrix",
")",
";",
"transform_xyz_to_enu",
"(",
"&",
"MAG_ValueComp",
",",
"data_in",
".",
"Mag",
",",
"LSM303AGR_0_Matrix",
")",
";",
"#else",
"#error",
" \"ERROR: Unknown MEMS shield!\"\r",
"\n",
"#endif",
"data_in",
".",
"Acc",
"[",
"0",
"]",
"=",
"data_in",
".",
"Acc",
"[",
"0",
"]",
"/",
"1000.0f",
";",
"data_in",
".",
"Acc",
"[",
"1",
"]",
"=",
"data_in",
".",
"Acc",
"[",
"1",
"]",
"/",
"1000.0f",
";",
"data_in",
".",
"Acc",
"[",
"2",
"]",
"=",
"data_in",
".",
"Acc",
"[",
"2",
"]",
"/",
"1000.0f",
";",
"data_in",
".",
"Mag",
"[",
"0",
"]",
"=",
"data_in",
".",
"Mag",
"[",
"0",
"]",
"/",
"5.0f",
";",
"data_in",
".",
"Mag",
"[",
"1",
"]",
"=",
"data_in",
".",
"Mag",
"[",
"1",
"]",
"/",
"5.0f",
";",
"data_in",
".",
"Mag",
"[",
"2",
"]",
"=",
"data_in",
".",
"Mag",
"[",
"2",
"]",
"/",
"5.0f",
";",
"data_in",
".",
"DTime",
"=",
"REPORT_INTERVAL",
"/",
"1000.0f",
";",
"MotionEC_Run",
"(",
"&",
"data_in",
",",
"&",
"data_out",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"55",
"]",
",",
"data_out",
".",
"Quaternion",
"[",
"0",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"59",
"]",
",",
"data_out",
".",
"Quaternion",
"[",
"1",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"63",
"]",
",",
"data_out",
".",
"Quaternion",
"[",
"2",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"67",
"]",
",",
"data_out",
".",
"Quaternion",
"[",
"3",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"71",
"]",
",",
"data_out",
".",
"Euler",
"[",
"0",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"75",
"]",
",",
"data_out",
".",
"Euler",
"[",
"1",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"79",
"]",
",",
"data_out",
".",
"Euler",
"[",
"2",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"83",
"]",
",",
"data_out",
".",
"IGyro",
"[",
"0",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"87",
"]",
",",
"data_out",
".",
"IGyro",
"[",
"1",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"91",
"]",
",",
"data_out",
".",
"IGyro",
"[",
"2",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"95",
"]",
",",
"data_out",
".",
"Gravity",
"[",
"0",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"99",
"]",
",",
"data_out",
".",
"Gravity",
"[",
"1",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"103",
"]",
",",
"data_out",
".",
"Gravity",
"[",
"2",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"107",
"]",
",",
"data_out",
".",
"Linear",
"[",
"0",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"111",
"]",
",",
"data_out",
".",
"Linear",
"[",
"1",
"]",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"115",
"]",
",",
"data_out",
".",
"Linear",
"[",
"2",
"]",
")",
";",
"float",
"v_base",
"[",
"3",
"]",
"=",
"{",
"0.0",
",",
"1.0",
",",
"0.0",
"}",
";",
"float",
"v_head",
"[",
"3",
"]",
";",
"float",
"heading",
";",
"int",
"heading_valid",
"=",
"0",
";",
"v_rotate",
"(",
"v_head",
",",
"data_out",
".",
"Quaternion",
",",
"v_base",
")",
";",
"heading_valid",
"=",
"calc_heading",
"(",
"&",
"heading",
",",
"v_head",
")",
";",
"FloatToArray",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"119",
"]",
",",
"heading",
")",
";",
"Msg",
"->",
"Data",
"[",
"123",
"]",
"=",
"(",
"uint8_t",
")",
"heading_valid",
";",
"}"
] | @brief Run E-Compass algorithm (accelerometer and magnetometer data fusion)
@param Msg Data stream
@retval none | [
"@brief",
"Run",
"E",
"-",
"Compass",
"algorithm",
"(",
"accelerometer",
"and",
"magnetometer",
"data",
"fusion",
")",
"@param",
"Msg",
"Data",
"stream",
"@retval",
"none"
] | [
"/* Do sensor orientation transformation */",
"/* Raw accelerometer data [g] */",
"/* East */",
"/* North */",
"/* Up */",
"/* Compensated magnetometer data [uT / 50], [mGauss / 5] */",
"/* East */",
"/* North */",
"/* Up */",
"/* Delta time [s] */",
"/* Do calculation */",
"/* Write data to output stream */"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2469847434dc2fcf1a155fb79bc29b724abb03e | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/ECompass/Src/MotionEC_Manager.c | [
"MIT"
] | C | calc_heading | int | static int calc_heading(float *heading, float v_head[])
{
const float tol_deg = 5.0; /* Tolerance [deg] */
float tolerance = sin(tol_deg * M_PI / 180.0f);
if ( v_head[0] > (-1) * tolerance && v_head[0] < tolerance
&& v_head[1] > (-1) * tolerance && v_head[1] < tolerance)
{
*heading = 0.0;
return 0; /* Device is pointing up or down - it is impossible to evaluate heading */
}
else
{
*heading = atan2(v_head[0], v_head[1]) * 180.0f / M_PI;
*heading = floor(*heading * 100.0f + 0.5f) / 100.0f; /* Rounds number to two decimal digits */
*heading = (*heading < 0.0f) ? (*heading + 360.0f) : *heading; /* Change negative value to be in range <0,360) */
return 1;
}
} | /**
* @brief Calculate heading.
* @param heading Device heading in range <0, 360) degrees
* @param v_head Device orientation vector for heading
* @retval 1 in case of success, 0 otherwise
*/ | @brief Calculate heading.
@param heading Device heading in range <0, 360) degrees
@param v_head Device orientation vector for heading
@retval 1 in case of success, 0 otherwise | [
"@brief",
"Calculate",
"heading",
".",
"@param",
"heading",
"Device",
"heading",
"in",
"range",
"<0",
"360",
")",
"degrees",
"@param",
"v_head",
"Device",
"orientation",
"vector",
"for",
"heading",
"@retval",
"1",
"in",
"case",
"of",
"success",
"0",
"otherwise"
] | static int calc_heading(float *heading, float v_head[])
{
const float tol_deg = 5.0;
float tolerance = sin(tol_deg * M_PI / 180.0f);
if ( v_head[0] > (-1) * tolerance && v_head[0] < tolerance
&& v_head[1] > (-1) * tolerance && v_head[1] < tolerance)
{
*heading = 0.0;
return 0;
}
else
{
*heading = atan2(v_head[0], v_head[1]) * 180.0f / M_PI;
*heading = floor(*heading * 100.0f + 0.5f) / 100.0f;
*heading = (*heading < 0.0f) ? (*heading + 360.0f) : *heading;
return 1;
}
} | [
"static",
"int",
"calc_heading",
"(",
"float",
"*",
"heading",
",",
"float",
"v_head",
"[",
"]",
")",
"{",
"const",
"float",
"tol_deg",
"=",
"5.0",
";",
"float",
"tolerance",
"=",
"sin",
"(",
"tol_deg",
"*",
"M_PI",
"/",
"180.0f",
")",
";",
"if",
"(",
"v_head",
"[",
"0",
"]",
">",
"(",
"-1",
")",
"*",
"tolerance",
"&&",
"v_head",
"[",
"0",
"]",
"<",
"tolerance",
"&&",
"v_head",
"[",
"1",
"]",
">",
"(",
"-1",
")",
"*",
"tolerance",
"&&",
"v_head",
"[",
"1",
"]",
"<",
"tolerance",
")",
"{",
"*",
"heading",
"=",
"0.0",
";",
"return",
"0",
";",
"}",
"else",
"{",
"*",
"heading",
"=",
"atan2",
"(",
"v_head",
"[",
"0",
"]",
",",
"v_head",
"[",
"1",
"]",
")",
"*",
"180.0f",
"/",
"M_PI",
";",
"*",
"heading",
"=",
"floor",
"(",
"*",
"heading",
"*",
"100.0f",
"+",
"0.5f",
")",
"/",
"100.0f",
";",
"*",
"heading",
"=",
"(",
"*",
"heading",
"<",
"0.0f",
")",
"?",
"(",
"*",
"heading",
"+",
"360.0f",
")",
":",
"*",
"heading",
";",
"return",
"1",
";",
"}",
"}"
] | @brief Calculate heading. | [
"@brief",
"Calculate",
"heading",
"."
] | [
"/* Tolerance [deg] */",
"/* Device is pointing up or down - it is impossible to evaluate heading */",
"/* Rounds number to two decimal digits */",
"/* Change negative value to be in range <0,360) */"
] | [
{
"param": "heading",
"type": "float"
},
{
"param": "v_head",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "heading",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v_head",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2469847434dc2fcf1a155fb79bc29b724abb03e | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/ECompass/Src/MotionEC_Manager.c | [
"MIT"
] | C | q_conjug | void | static void q_conjug(float q_conj[], float q_src[])
{
q_conj[0] = (-1) * q_src[0];
q_conj[1] = (-1) * q_src[1];
q_conj[2] = (-1) * q_src[2];
q_conj[3] = q_src[3];
return;
} | /**
* @brief Create conjugated quaternion.
* @param q_conj Conjugated quaternion
* @param q_src Source quaternion
* @retval None
*/ | @brief Create conjugated quaternion.
@param q_conj Conjugated quaternion
@param q_src Source quaternion
@retval None | [
"@brief",
"Create",
"conjugated",
"quaternion",
".",
"@param",
"q_conj",
"Conjugated",
"quaternion",
"@param",
"q_src",
"Source",
"quaternion",
"@retval",
"None"
] | static void q_conjug(float q_conj[], float q_src[])
{
q_conj[0] = (-1) * q_src[0];
q_conj[1] = (-1) * q_src[1];
q_conj[2] = (-1) * q_src[2];
q_conj[3] = q_src[3];
return;
} | [
"static",
"void",
"q_conjug",
"(",
"float",
"q_conj",
"[",
"]",
",",
"float",
"q_src",
"[",
"]",
")",
"{",
"q_conj",
"[",
"0",
"]",
"=",
"(",
"-1",
")",
"*",
"q_src",
"[",
"0",
"]",
";",
"q_conj",
"[",
"1",
"]",
"=",
"(",
"-1",
")",
"*",
"q_src",
"[",
"1",
"]",
";",
"q_conj",
"[",
"2",
"]",
"=",
"(",
"-1",
")",
"*",
"q_src",
"[",
"2",
"]",
";",
"q_conj",
"[",
"3",
"]",
"=",
"q_src",
"[",
"3",
"]",
";",
"return",
";",
"}"
] | @brief Create conjugated quaternion. | [
"@brief",
"Create",
"conjugated",
"quaternion",
"."
] | [] | [
{
"param": "q_conj",
"type": "float"
},
{
"param": "q_src",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "q_conj",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q_src",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
550015228169fb96b21864592475e8cb8b05af3b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/MotionCP_Manager.c | [
"MIT"
] | C | MotionCP_manager_init | void | void MotionCP_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionCP_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return;
#else
#error Not supported platform
#endif
}
MotionCP_SetOrientation_Acc(acc_orientation);
} | /**
* @brief Initialises MotionCP algorithm
* @param handle handle to accelerometer sensor
* @retval none
*/ | @brief Initialises MotionCP algorithm
@param handle handle to accelerometer sensor
@retval none | [
"@brief",
"Initialises",
"MotionCP",
"algorithm",
"@param",
"handle",
"handle",
"to",
"accelerometer",
"sensor",
"@retval",
"none"
] | void MotionCP_manager_init(void *handle)
{
uint8_t instance;
char acc_orientation[3];
MotionCP_Initialize();
BSP_ACCELERO_Get_Instance(handle, &instance);
switch (instance)
{
#if (defined (USE_IKS01A1))
case LSM6DS0_X_0:
acc_orientation[0] ='e';
acc_orientation[1] ='n';
acc_orientation[2] ='u';
break;
case LSM6DS3_X_0:
acc_orientation[0] ='n';
acc_orientation[1] ='w';
acc_orientation[2] ='u';
break;
default:
return;
#elif (defined (USE_IKS01A2))
case LSM6DSL_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'w';
acc_orientation[2] = 'u';
break;
case LSM303AGR_X_0:
acc_orientation[0] = 'n';
acc_orientation[1] = 'e';
acc_orientation[2] = 'u';
break;
default:
return;
#else
#error Not supported platform
#endif
}
MotionCP_SetOrientation_Acc(acc_orientation);
} | [
"void",
"MotionCP_manager_init",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"instance",
";",
"char",
"acc_orientation",
"[",
"3",
"]",
";",
"MotionCP_Initialize",
"(",
")",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"handle",
",",
"&",
"instance",
")",
";",
"switch",
"(",
"instance",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_IKS01A1",
")",
")",
"\n",
"case",
"LSM6DS0_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM6DS3_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
";",
"#elif",
"(",
"defined",
"(",
"USE_IKS01A2",
")",
")",
"\n",
"case",
"LSM6DSL_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"LSM303AGR_X_0",
":",
"acc_orientation",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"1",
"]",
"=",
"'",
"'",
";",
"acc_orientation",
"[",
"2",
"]",
"=",
"'",
"'",
";",
"break",
";",
"default",
":",
"return",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"}",
"MotionCP_SetOrientation_Acc",
"(",
"acc_orientation",
")",
";",
"}"
] | @brief Initialises MotionCP algorithm
@param handle handle to accelerometer sensor
@retval none | [
"@brief",
"Initialises",
"MotionCP",
"algorithm",
"@param",
"handle",
"handle",
"to",
"accelerometer",
"sensor",
"@retval",
"none"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c9b2ebfa3ad82a98201903f87c4db6f8c6f1c2da | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/main.c | [
"MIT"
] | C | MX_TIM_CP_Init | void | static void MX_TIM_CP_Init(void)
{
#define PERIOD_50HZ ((uint8_t)39)
#if (defined (USE_STM32F4XX_NUCLEO)) /* 84 MHZ CPU clock */
#define PRESCALER_50HZ ((uint16_t)41999)
#elif (defined (USE_STM32L4XX_NUCLEO)) /* 80 MHZ CPU clock */
#define PRESCALER_50HZ ((uint16_t)39999)
#else
#error Not supported platform
#endif
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
CP_TimHandle.Instance = TIM_CP;
CP_TimHandle.Init.Prescaler = PRESCALER_50HZ;
CP_TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
CP_TimHandle.Init.Period = PERIOD_50HZ;
CP_TimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&CP_TimHandle);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&CP_TimHandle, &sClockSourceConfig);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&CP_TimHandle, &sMasterConfig);
} | /**
* @brief TIM_CP init function.
* @param None
* @retval None
* @details This function intialize the Timer used to syncronize the AW algorithm.
*/ | @brief TIM_CP init function.
@param None
@retval None
@details This function intialize the Timer used to syncronize the AW algorithm. | [
"@brief",
"TIM_CP",
"init",
"function",
".",
"@param",
"None",
"@retval",
"None",
"@details",
"This",
"function",
"intialize",
"the",
"Timer",
"used",
"to",
"syncronize",
"the",
"AW",
"algorithm",
"."
] | static void MX_TIM_CP_Init(void)
{
#define PERIOD_50HZ ((uint8_t)39)
#if (defined (USE_STM32F4XX_NUCLEO))
#define PRESCALER_50HZ ((uint16_t)41999)
#elif (defined (USE_STM32L4XX_NUCLEO))
#define PRESCALER_50HZ ((uint16_t)39999)
#else
#error Not supported platform
#endif
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
CP_TimHandle.Instance = TIM_CP;
CP_TimHandle.Init.Prescaler = PRESCALER_50HZ;
CP_TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
CP_TimHandle.Init.Period = PERIOD_50HZ;
CP_TimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&CP_TimHandle);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&CP_TimHandle, &sClockSourceConfig);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&CP_TimHandle, &sMasterConfig);
} | [
"static",
"void",
"MX_TIM_CP_Init",
"(",
"void",
")",
"{",
"#define",
"PERIOD_50HZ",
" ((uint8_t)39)\r",
"\n",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"#define",
"PRESCALER_50HZ",
" ((uint16_t)41999)\r",
"\n",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"#define",
"PRESCALER_50HZ",
" ((uint16_t)39999)\r",
"\n",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"TIM_ClockConfigTypeDef",
"sClockSourceConfig",
";",
"TIM_MasterConfigTypeDef",
"sMasterConfig",
";",
"CP_TimHandle",
".",
"Instance",
"=",
"TIM_CP",
";",
"CP_TimHandle",
".",
"Init",
".",
"Prescaler",
"=",
"PRESCALER_50HZ",
";",
"CP_TimHandle",
".",
"Init",
".",
"CounterMode",
"=",
"TIM_COUNTERMODE_UP",
";",
"CP_TimHandle",
".",
"Init",
".",
"Period",
"=",
"PERIOD_50HZ",
";",
"CP_TimHandle",
".",
"Init",
".",
"ClockDivision",
"=",
"TIM_CLOCKDIVISION_DIV1",
";",
"HAL_TIM_Base_Init",
"(",
"&",
"CP_TimHandle",
")",
";",
"sClockSourceConfig",
".",
"ClockSource",
"=",
"TIM_CLOCKSOURCE_INTERNAL",
";",
"HAL_TIM_ConfigClockSource",
"(",
"&",
"CP_TimHandle",
",",
"&",
"sClockSourceConfig",
")",
";",
"sMasterConfig",
".",
"MasterOutputTrigger",
"=",
"TIM_TRGO_RESET",
";",
"sMasterConfig",
".",
"MasterSlaveMode",
"=",
"TIM_MASTERSLAVEMODE_DISABLE",
";",
"HAL_TIMEx_MasterConfigSynchronization",
"(",
"&",
"CP_TimHandle",
",",
"&",
"sMasterConfig",
")",
";",
"}"
] | @brief TIM_CP init function. | [
"@brief",
"TIM_CP",
"init",
"function",
"."
] | [
"/* 84 MHZ CPU clock */",
"/* 80 MHZ CPU clock */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c9b2ebfa3ad82a98201903f87c4db6f8c6f1c2da | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/main.c | [
"MIT"
] | C | Humidity_Sensor_Handler | void | static void Humidity_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float HUMIDITY_Value;
if (Sensors_Enabled & HUMIDITY_SENSOR)
{
if (BSP_HUMIDITY_IsInitialized(HUMIDITY_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_HUMIDITY_Get_Hum(HUMIDITY_handle, &HUMIDITY_Value);
memcpy(&Msg->Data[15], (void *)&HUMIDITY_Value, sizeof(float));
}
}
} | /**
* @brief Handles the HUM axes data getting/sending
* @param Msg - HUM part of the stream
* @retval None
*/ | @brief Handles the HUM axes data getting/sending
@param Msg - HUM part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"HUM",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"HUM",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void Humidity_Sensor_Handler(TMsg *Msg)
{
uint8_t status = 0;
float HUMIDITY_Value;
if (Sensors_Enabled & HUMIDITY_SENSOR)
{
if (BSP_HUMIDITY_IsInitialized(HUMIDITY_handle, &status) == COMPONENT_OK && status == 1)
{
BSP_HUMIDITY_Get_Hum(HUMIDITY_handle, &HUMIDITY_Value);
memcpy(&Msg->Data[15], (void *)&HUMIDITY_Value, sizeof(float));
}
}
} | [
"static",
"void",
"Humidity_Sensor_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint8_t",
"status",
"=",
"0",
";",
"float",
"HUMIDITY_Value",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"HUMIDITY_SENSOR",
")",
"{",
"if",
"(",
"BSP_HUMIDITY_IsInitialized",
"(",
"HUMIDITY_handle",
",",
"&",
"status",
")",
"==",
"COMPONENT_OK",
"&&",
"status",
"==",
"1",
")",
"{",
"BSP_HUMIDITY_Get_Hum",
"(",
"HUMIDITY_handle",
",",
"&",
"HUMIDITY_Value",
")",
";",
"memcpy",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"15",
"]",
",",
"(",
"void",
"*",
")",
"&",
"HUMIDITY_Value",
",",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"}",
"}"
] | @brief Handles the HUM axes data getting/sending
@param Msg - HUM part of the stream
@retval None | [
"@brief",
"Handles",
"the",
"HUM",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"Msg",
"-",
"HUM",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c9b2ebfa3ad82a98201903f87c4db6f8c6f1c2da | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/main.c | [
"MIT"
] | C | CP_Data_Handler | void | static void CP_Data_Handler(TMsg *Msg)
{
MCP_input_t data_in;
static MCP_output_t carry_position_prev = MCP_UNKNOWN;
static MCP_output_t carry_position;
static uint32_t SessionCounter = 0;
if (Sensors_Enabled & ACCELEROMETER_SENSOR)
{
/* Convert acceleration from [mg] to [g] */
data_in.AccX = (float)ACC_Value.AXIS_X / 1000.0f;
data_in.AccY = (float)ACC_Value.AXIS_Y / 1000.0f;
data_in.AccZ = (float)ACC_Value.AXIS_Z / 1000.0f;
/* Run Carry Position algorithm */
if (ProgramState == STANDALONE_MODE) BSP_LED_On(LED2);
MotionCP_manager_run(&data_in, &carry_position);
if (ProgramState == STANDALONE_MODE) BSP_LED_Off(LED2);
if (ProgramState == GUI_MODE)
{
Serialize_s32(&Msg->Data[55], (int32_t)carry_position, 4);
}
else if (ProgramState == STANDALONE_MODE)
{
/* New session */
if (SessionNew == 1)
{
SessionNew = 0;
SessionCounter = 0;
CP_Data_index = 0;
/* Create new session record with only date and time */
RTC_Handler_CPStamp(&DataByte_CP[CP_Data_index].DateTime);
DataByte_CP[CP_Data_index].DataValid = 0;
DataByte_CP[CP_Data_index].CPosition = MCP_UNKNOWN;
CP_Data_index++;
carry_position_prev = MCP_UNKNOWN;
return;
}
/* Buffer full */
if (CP_Data_index >= DATABYTE_CP_LEN)
{
/* Carry Position data are stored in FLASH */
if (Datalog_SaveCP2Mem(CP_Data_index) == 0)
gui_mode_request = 1;
CP_Data_index = 0;
}
/* Position changed */
if (carry_position != carry_position_prev)
{
/* Store new pose in buffer */
RTC_Handler_CPStamp(&DataByte_CP[CP_Data_index].DateTime);
DataByte_CP[CP_Data_index].DataValid = 1;
DataByte_CP[CP_Data_index].CPosition = carry_position;
CP_Data_index++;
carry_position_prev = carry_position;
}
/* Periodic Carry Position data save */
if (SessionCounter >= SESSION_COUNTER_MAX)
{
/* Carry Position data are stored in FLASH */
Datalog_SaveCP2Mem(CP_Data_index);
SessionCounter = 0;
CP_Data_index = 0;
}
else
{
SessionCounter++;
}
}
else
{
Error_Handler();
}
}
} | /**
* @brief Carry Position data handler
* @param Msg - Carry Position data part of the stream
* @retval None
*/ | @brief Carry Position data handler
@param Msg - Carry Position data part of the stream
@retval None | [
"@brief",
"Carry",
"Position",
"data",
"handler",
"@param",
"Msg",
"-",
"Carry",
"Position",
"data",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | static void CP_Data_Handler(TMsg *Msg)
{
MCP_input_t data_in;
static MCP_output_t carry_position_prev = MCP_UNKNOWN;
static MCP_output_t carry_position;
static uint32_t SessionCounter = 0;
if (Sensors_Enabled & ACCELEROMETER_SENSOR)
{
data_in.AccX = (float)ACC_Value.AXIS_X / 1000.0f;
data_in.AccY = (float)ACC_Value.AXIS_Y / 1000.0f;
data_in.AccZ = (float)ACC_Value.AXIS_Z / 1000.0f;
if (ProgramState == STANDALONE_MODE) BSP_LED_On(LED2);
MotionCP_manager_run(&data_in, &carry_position);
if (ProgramState == STANDALONE_MODE) BSP_LED_Off(LED2);
if (ProgramState == GUI_MODE)
{
Serialize_s32(&Msg->Data[55], (int32_t)carry_position, 4);
}
else if (ProgramState == STANDALONE_MODE)
{
if (SessionNew == 1)
{
SessionNew = 0;
SessionCounter = 0;
CP_Data_index = 0;
RTC_Handler_CPStamp(&DataByte_CP[CP_Data_index].DateTime);
DataByte_CP[CP_Data_index].DataValid = 0;
DataByte_CP[CP_Data_index].CPosition = MCP_UNKNOWN;
CP_Data_index++;
carry_position_prev = MCP_UNKNOWN;
return;
}
if (CP_Data_index >= DATABYTE_CP_LEN)
{
if (Datalog_SaveCP2Mem(CP_Data_index) == 0)
gui_mode_request = 1;
CP_Data_index = 0;
}
if (carry_position != carry_position_prev)
{
RTC_Handler_CPStamp(&DataByte_CP[CP_Data_index].DateTime);
DataByte_CP[CP_Data_index].DataValid = 1;
DataByte_CP[CP_Data_index].CPosition = carry_position;
CP_Data_index++;
carry_position_prev = carry_position;
}
if (SessionCounter >= SESSION_COUNTER_MAX)
{
Datalog_SaveCP2Mem(CP_Data_index);
SessionCounter = 0;
CP_Data_index = 0;
}
else
{
SessionCounter++;
}
}
else
{
Error_Handler();
}
}
} | [
"static",
"void",
"CP_Data_Handler",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"MCP_input_t",
"data_in",
";",
"static",
"MCP_output_t",
"carry_position_prev",
"=",
"MCP_UNKNOWN",
";",
"static",
"MCP_output_t",
"carry_position",
";",
"static",
"uint32_t",
"SessionCounter",
"=",
"0",
";",
"if",
"(",
"Sensors_Enabled",
"&",
"ACCELEROMETER_SENSOR",
")",
"{",
"data_in",
".",
"AccX",
"=",
"(",
"float",
")",
"ACC_Value",
".",
"AXIS_X",
"/",
"1000.0f",
";",
"data_in",
".",
"AccY",
"=",
"(",
"float",
")",
"ACC_Value",
".",
"AXIS_Y",
"/",
"1000.0f",
";",
"data_in",
".",
"AccZ",
"=",
"(",
"float",
")",
"ACC_Value",
".",
"AXIS_Z",
"/",
"1000.0f",
";",
"if",
"(",
"ProgramState",
"==",
"STANDALONE_MODE",
")",
"BSP_LED_On",
"(",
"LED2",
")",
";",
"MotionCP_manager_run",
"(",
"&",
"data_in",
",",
"&",
"carry_position",
")",
";",
"if",
"(",
"ProgramState",
"==",
"STANDALONE_MODE",
")",
"BSP_LED_Off",
"(",
"LED2",
")",
";",
"if",
"(",
"ProgramState",
"==",
"GUI_MODE",
")",
"{",
"Serialize_s32",
"(",
"&",
"Msg",
"->",
"Data",
"[",
"55",
"]",
",",
"(",
"int32_t",
")",
"carry_position",
",",
"4",
")",
";",
"}",
"else",
"if",
"(",
"ProgramState",
"==",
"STANDALONE_MODE",
")",
"{",
"if",
"(",
"SessionNew",
"==",
"1",
")",
"{",
"SessionNew",
"=",
"0",
";",
"SessionCounter",
"=",
"0",
";",
"CP_Data_index",
"=",
"0",
";",
"RTC_Handler_CPStamp",
"(",
"&",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"DateTime",
")",
";",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"DataValid",
"=",
"0",
";",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"CPosition",
"=",
"MCP_UNKNOWN",
";",
"CP_Data_index",
"++",
";",
"carry_position_prev",
"=",
"MCP_UNKNOWN",
";",
"return",
";",
"}",
"if",
"(",
"CP_Data_index",
">=",
"DATABYTE_CP_LEN",
")",
"{",
"if",
"(",
"Datalog_SaveCP2Mem",
"(",
"CP_Data_index",
")",
"==",
"0",
")",
"gui_mode_request",
"=",
"1",
";",
"CP_Data_index",
"=",
"0",
";",
"}",
"if",
"(",
"carry_position",
"!=",
"carry_position_prev",
")",
"{",
"RTC_Handler_CPStamp",
"(",
"&",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"DateTime",
")",
";",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"DataValid",
"=",
"1",
";",
"DataByte_CP",
"[",
"CP_Data_index",
"]",
".",
"CPosition",
"=",
"carry_position",
";",
"CP_Data_index",
"++",
";",
"carry_position_prev",
"=",
"carry_position",
";",
"}",
"if",
"(",
"SessionCounter",
">=",
"SESSION_COUNTER_MAX",
")",
"{",
"Datalog_SaveCP2Mem",
"(",
"CP_Data_index",
")",
";",
"SessionCounter",
"=",
"0",
";",
"CP_Data_index",
"=",
"0",
";",
"}",
"else",
"{",
"SessionCounter",
"++",
";",
"}",
"}",
"else",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"}"
] | @brief Carry Position data handler
@param Msg - Carry Position data part of the stream
@retval None | [
"@brief",
"Carry",
"Position",
"data",
"handler",
"@param",
"Msg",
"-",
"Carry",
"Position",
"data",
"part",
"of",
"the",
"stream",
"@retval",
"None"
] | [
"/* Convert acceleration from [mg] to [g] */",
"/* Run Carry Position algorithm */",
"/* New session */",
"/* Create new session record with only date and time */",
"/* Buffer full */",
"/* Carry Position data are stored in FLASH */",
"/* Position changed */",
"/* Store new pose in buffer */",
"/* Periodic Carry Position data save */",
"/* Carry Position data are stored in FLASH */"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c9b2ebfa3ad82a98201903f87c4db6f8c6f1c2da | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/main.c | [
"MIT"
] | C | RTC_TimeStampConfig | void | static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/* Configure the Date */
/* Set Date: Monday March 21st 2016 */
sdatestructure.Year = 0x16;
sdatestructure.Month = RTC_MONTH_MARCH;
sdatestructure.Date = 0x21;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if (HAL_RTC_SetDate(&RtcHandle, &sdatestructure, FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Configure the Time */
/* Set Time: 08:10:00 */
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&RtcHandle, &stimestructure, FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
} | /**
* @brief Configures the current time and date
* @param None
* @retval None
*/ | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
sdatestructure.Year = 0x16;
sdatestructure.Month = RTC_MONTH_MARCH;
sdatestructure.Date = 0x21;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if (HAL_RTC_SetDate(&RtcHandle, &sdatestructure, FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&RtcHandle, &stimestructure, FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
} | [
"static",
"void",
"RTC_TimeStampConfig",
"(",
"void",
")",
"{",
"RTC_DateTypeDef",
"sdatestructure",
";",
"RTC_TimeTypeDef",
"stimestructure",
";",
"sdatestructure",
".",
"Year",
"=",
"0x16",
";",
"sdatestructure",
".",
"Month",
"=",
"RTC_MONTH_MARCH",
";",
"sdatestructure",
".",
"Date",
"=",
"0x21",
";",
"sdatestructure",
".",
"WeekDay",
"=",
"RTC_WEEKDAY_MONDAY",
";",
"if",
"(",
"HAL_RTC_SetDate",
"(",
"&",
"RtcHandle",
",",
"&",
"sdatestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"stimestructure",
".",
"Hours",
"=",
"0x08",
";",
"stimestructure",
".",
"Minutes",
"=",
"0x10",
";",
"stimestructure",
".",
"Seconds",
"=",
"0x00",
";",
"stimestructure",
".",
"TimeFormat",
"=",
"RTC_HOURFORMAT12_AM",
";",
"stimestructure",
".",
"DayLightSaving",
"=",
"RTC_DAYLIGHTSAVING_NONE",
";",
"stimestructure",
".",
"StoreOperation",
"=",
"RTC_STOREOPERATION_RESET",
";",
"if",
"(",
"HAL_RTC_SetTime",
"(",
"&",
"RtcHandle",
",",
"&",
"stimestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}"
] | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | [
"/* Configure the Date */",
"/* Set Date: Monday March 21st 2016 */",
"/* Initialization Error */",
"/* Configure the Time */",
"/* Set Time: 08:10:00 */",
"/* Initialization Error */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c9b2ebfa3ad82a98201903f87c4db6f8c6f1c2da | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/CarryPosition/Src/main.c | [
"MIT"
] | C | HAL_TIM_PeriodElapsedCallback | void | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIM_CP)
{
sensor_read_request = 1;
}
} | /**
* @brief Period elapsed callback
* @param htim pointer to a TIM_HandleTypeDef structure that contains
* the configuration information for TIM module.
* @retval None
*/ | @brief Period elapsed callback
@param htim pointer to a TIM_HandleTypeDef structure that contains
the configuration information for TIM module.
@retval None | [
"@brief",
"Period",
"elapsed",
"callback",
"@param",
"htim",
"pointer",
"to",
"a",
"TIM_HandleTypeDef",
"structure",
"that",
"contains",
"the",
"configuration",
"information",
"for",
"TIM",
"module",
".",
"@retval",
"None"
] | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIM_CP)
{
sensor_read_request = 1;
}
} | [
"void",
"HAL_TIM_PeriodElapsedCallback",
"(",
"TIM_HandleTypeDef",
"*",
"htim",
")",
"{",
"if",
"(",
"htim",
"->",
"Instance",
"==",
"TIM_CP",
")",
"{",
"sensor_read_request",
"=",
"1",
";",
"}",
"}"
] | @brief Period elapsed callback
@param htim pointer to a TIM_HandleTypeDef structure that contains
the configuration information for TIM module. | [
"@brief",
"Period",
"elapsed",
"callback",
"@param",
"htim",
"pointer",
"to",
"a",
"TIM_HandleTypeDef",
"structure",
"that",
"contains",
"the",
"configuration",
"information",
"for",
"TIM",
"module",
"."
] | [] | [
{
"param": "htim",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80f624c641c7071f50fa36e76ec3490f6ba3c615 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogExtended/Src/com.c | [
"MIT"
] | C | UART_ReceivedMSG | int | int UART_ReceivedMSG(TMsg *Msg)
{
uint16_t i, j, k, j2;
uint16_t DmaCounter, length;
uint8_t Data;
uint16_t source = 0;
uint8_t inc = 0;
if(Get_DMA_Flag_Status(&hdma_rx) == RESET)
{
DmaCounter = UART_RxBufferSize - Get_DMA_Counter(&hdma_rx);
if (DmaCounter >= Uart_Engine.StartOfMsg)
{
length = DmaCounter - Uart_Engine.StartOfMsg;
}
else
{
length = UART_RxBufferSize + DmaCounter - Uart_Engine.StartOfMsg;
}
j = Uart_Engine.StartOfMsg;
for (k = 0; k < length; k++)
{
Data = UART_RxBuffer[j];
j++;
if (j >= UART_RxBufferSize)
{
j = 0;
}
if (Data == TMsg_EOF)
{
j = Uart_Engine.StartOfMsg;
for (i = 0; i < k; i += inc)
{
uint8_t Source0;
uint8_t Source1;
uint8_t* Dest;
j2 = (j + 1) % UART_RxBufferSize;
Source0 = UART_RxBuffer[j];
Source1 = UART_RxBuffer[j2];
Dest = &Msg->Data[source];
inc = ReverseByteStuffCopyByte2( Source0, Source1, Dest );
if (inc == 0)
{
Uart_Engine.StartOfMsg = j2;
return 0;
}
j = (j + inc) % UART_RxBufferSize;
source++;
}
Msg->Len = source;
j = (j + 1) % UART_RxBufferSize; // skip TMsg_EOF
Uart_Engine.StartOfMsg = j;
if (CHK_CheckAndRemove(Msg)) // check message integrity
{
return 1;
}
}
}
if (length > Uart_Msg_Max_Size)
{
Uart_Engine.StartOfMsg = DmaCounter;
}
}
return 0;
} | /**
* @brief Check if a message is received via UART
* @param Msg the pointer to the message to be received
* @retval 1 if a complete message is found, 0 otherwise
*/ | @brief Check if a message is received via UART
@param Msg the pointer to the message to be received
@retval 1 if a complete message is found, 0 otherwise | [
"@brief",
"Check",
"if",
"a",
"message",
"is",
"received",
"via",
"UART",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"received",
"@retval",
"1",
"if",
"a",
"complete",
"message",
"is",
"found",
"0",
"otherwise"
] | int UART_ReceivedMSG(TMsg *Msg)
{
uint16_t i, j, k, j2;
uint16_t DmaCounter, length;
uint8_t Data;
uint16_t source = 0;
uint8_t inc = 0;
if(Get_DMA_Flag_Status(&hdma_rx) == RESET)
{
DmaCounter = UART_RxBufferSize - Get_DMA_Counter(&hdma_rx);
if (DmaCounter >= Uart_Engine.StartOfMsg)
{
length = DmaCounter - Uart_Engine.StartOfMsg;
}
else
{
length = UART_RxBufferSize + DmaCounter - Uart_Engine.StartOfMsg;
}
j = Uart_Engine.StartOfMsg;
for (k = 0; k < length; k++)
{
Data = UART_RxBuffer[j];
j++;
if (j >= UART_RxBufferSize)
{
j = 0;
}
if (Data == TMsg_EOF)
{
j = Uart_Engine.StartOfMsg;
for (i = 0; i < k; i += inc)
{
uint8_t Source0;
uint8_t Source1;
uint8_t* Dest;
j2 = (j + 1) % UART_RxBufferSize;
Source0 = UART_RxBuffer[j];
Source1 = UART_RxBuffer[j2];
Dest = &Msg->Data[source];
inc = ReverseByteStuffCopyByte2( Source0, Source1, Dest );
if (inc == 0)
{
Uart_Engine.StartOfMsg = j2;
return 0;
}
j = (j + inc) % UART_RxBufferSize;
source++;
}
Msg->Len = source;
j = (j + 1) % UART_RxBufferSize;
Uart_Engine.StartOfMsg = j;
if (CHK_CheckAndRemove(Msg))
{
return 1;
}
}
}
if (length > Uart_Msg_Max_Size)
{
Uart_Engine.StartOfMsg = DmaCounter;
}
}
return 0;
} | [
"int",
"UART_ReceivedMSG",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint16_t",
"i",
",",
"j",
",",
"k",
",",
"j2",
";",
"uint16_t",
"DmaCounter",
",",
"length",
";",
"uint8_t",
"Data",
";",
"uint16_t",
"source",
"=",
"0",
";",
"uint8_t",
"inc",
"=",
"0",
";",
"if",
"(",
"Get_DMA_Flag_Status",
"(",
"&",
"hdma_rx",
")",
"==",
"RESET",
")",
"{",
"DmaCounter",
"=",
"UART_RxBufferSize",
"-",
"Get_DMA_Counter",
"(",
"&",
"hdma_rx",
")",
";",
"if",
"(",
"DmaCounter",
">=",
"Uart_Engine",
".",
"StartOfMsg",
")",
"{",
"length",
"=",
"DmaCounter",
"-",
"Uart_Engine",
".",
"StartOfMsg",
";",
"}",
"else",
"{",
"length",
"=",
"UART_RxBufferSize",
"+",
"DmaCounter",
"-",
"Uart_Engine",
".",
"StartOfMsg",
";",
"}",
"j",
"=",
"Uart_Engine",
".",
"StartOfMsg",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"length",
";",
"k",
"++",
")",
"{",
"Data",
"=",
"UART_RxBuffer",
"[",
"j",
"]",
";",
"j",
"++",
";",
"if",
"(",
"j",
">=",
"UART_RxBufferSize",
")",
"{",
"j",
"=",
"0",
";",
"}",
"if",
"(",
"Data",
"==",
"TMsg_EOF",
")",
"{",
"j",
"=",
"Uart_Engine",
".",
"StartOfMsg",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"k",
";",
"i",
"+=",
"inc",
")",
"{",
"uint8_t",
"Source0",
";",
"uint8_t",
"Source1",
";",
"uint8_t",
"*",
"Dest",
";",
"j2",
"=",
"(",
"j",
"+",
"1",
")",
"%",
"UART_RxBufferSize",
";",
"Source0",
"=",
"UART_RxBuffer",
"[",
"j",
"]",
";",
"Source1",
"=",
"UART_RxBuffer",
"[",
"j2",
"]",
";",
"Dest",
"=",
"&",
"Msg",
"->",
"Data",
"[",
"source",
"]",
";",
"inc",
"=",
"ReverseByteStuffCopyByte2",
"(",
"Source0",
",",
"Source1",
",",
"Dest",
")",
";",
"if",
"(",
"inc",
"==",
"0",
")",
"{",
"Uart_Engine",
".",
"StartOfMsg",
"=",
"j2",
";",
"return",
"0",
";",
"}",
"j",
"=",
"(",
"j",
"+",
"inc",
")",
"%",
"UART_RxBufferSize",
";",
"source",
"++",
";",
"}",
"Msg",
"->",
"Len",
"=",
"source",
";",
"j",
"=",
"(",
"j",
"+",
"1",
")",
"%",
"UART_RxBufferSize",
";",
"Uart_Engine",
".",
"StartOfMsg",
"=",
"j",
";",
"if",
"(",
"CHK_CheckAndRemove",
"(",
"Msg",
")",
")",
"{",
"return",
"1",
";",
"}",
"}",
"}",
"if",
"(",
"length",
">",
"Uart_Msg_Max_Size",
")",
"{",
"Uart_Engine",
".",
"StartOfMsg",
"=",
"DmaCounter",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | @brief Check if a message is received via UART
@param Msg the pointer to the message to be received
@retval 1 if a complete message is found, 0 otherwise | [
"@brief",
"Check",
"if",
"a",
"message",
"is",
"received",
"via",
"UART",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"received",
"@retval",
"1",
"if",
"a",
"complete",
"message",
"is",
"found",
"0",
"otherwise"
] | [
"// skip TMsg_EOF\r",
"// check message integrity\r"
] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80f624c641c7071f50fa36e76ec3490f6ba3c615 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogExtended/Src/com.c | [
"MIT"
] | C | UART_SendMsg | void | void UART_SendMsg(TMsg *Msg)
{
uint16_t CountOut;
CHK_ComputeAndAdd(Msg);
CountOut = ByteStuffCopy((uint8_t*) UART_TxBuffer, Msg);
HAL_UART_Transmit(&UartHandle, (uint8_t*)UART_TxBuffer, CountOut, 5000);
} | /**
* @brief Send a message via UART
* @param Msg the pointer to the message to be sent
* @retval None
*/ | @brief Send a message via UART
@param Msg the pointer to the message to be sent
@retval None | [
"@brief",
"Send",
"a",
"message",
"via",
"UART",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"sent",
"@retval",
"None"
] | void UART_SendMsg(TMsg *Msg)
{
uint16_t CountOut;
CHK_ComputeAndAdd(Msg);
CountOut = ByteStuffCopy((uint8_t*) UART_TxBuffer, Msg);
HAL_UART_Transmit(&UartHandle, (uint8_t*)UART_TxBuffer, CountOut, 5000);
} | [
"void",
"UART_SendMsg",
"(",
"TMsg",
"*",
"Msg",
")",
"{",
"uint16_t",
"CountOut",
";",
"CHK_ComputeAndAdd",
"(",
"Msg",
")",
";",
"CountOut",
"=",
"ByteStuffCopy",
"(",
"(",
"uint8_t",
"*",
")",
"UART_TxBuffer",
",",
"Msg",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"UART_TxBuffer",
",",
"CountOut",
",",
"5000",
")",
";",
"}"
] | @brief Send a message via UART
@param Msg the pointer to the message to be sent
@retval None | [
"@brief",
"Send",
"a",
"message",
"via",
"UART",
"@param",
"Msg",
"the",
"pointer",
"to",
"the",
"message",
"to",
"be",
"sent",
"@retval",
"None"
] | [] | [
{
"param": "Msg",
"type": "TMsg"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Msg",
"type": "TMsg",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80f624c641c7071f50fa36e76ec3490f6ba3c615 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogExtended/Src/com.c | [
"MIT"
] | C | USART_DMA_Configuration | void | void USART_DMA_Configuration(void)
{
Config_DMA_Handler(&hdma_rx);
HAL_DMA_Init(&hdma_rx);
/* Associate the initialized DMA handle to the the UART handle */
__HAL_LINKDMA(&UartHandle, hdmarx, hdma_rx);
} | /**
* @brief Configure DMA for the reception via USART
* @param None
* @retval None
*/ | @brief Configure DMA for the reception via USART
@param None
@retval None | [
"@brief",
"Configure",
"DMA",
"for",
"the",
"reception",
"via",
"USART",
"@param",
"None",
"@retval",
"None"
] | void USART_DMA_Configuration(void)
{
Config_DMA_Handler(&hdma_rx);
HAL_DMA_Init(&hdma_rx);
__HAL_LINKDMA(&UartHandle, hdmarx, hdma_rx);
} | [
"void",
"USART_DMA_Configuration",
"(",
"void",
")",
"{",
"Config_DMA_Handler",
"(",
"&",
"hdma_rx",
")",
";",
"HAL_DMA_Init",
"(",
"&",
"hdma_rx",
")",
";",
"__HAL_LINKDMA",
"(",
"&",
"UartHandle",
",",
"hdmarx",
",",
"hdma_rx",
")",
";",
"}"
] | @brief Configure DMA for the reception via USART
@param None
@retval None | [
"@brief",
"Configure",
"DMA",
"for",
"the",
"reception",
"via",
"USART",
"@param",
"None",
"@retval",
"None"
] | [
"/* Associate the initialized DMA handle to the the UART handle */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7e045c73be4e29403325209b5d70e99cbaeed73f | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogExtended/Src/cube_hal_l1.c | [
"MIT"
] | C | SystemClock_Config | void | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
/* Enable HSE Oscillator and Activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Set Voltage scale1 as MCU will run at 32MHz */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
/* Select PLL as system clock source and configure the HCLK,
PCLK1 and PCLK2 clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
} | /**
* @brief System Clock Configuration
* @param None
* @retval None
*/ | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
} | [
"void",
"SystemClock_Config",
"(",
"void",
")",
"{",
"RCC_ClkInitTypeDef",
"RCC_ClkInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_HSI",
";",
"RCC_OscInitStruct",
".",
"HSIState",
"=",
"RCC_HSI_ON",
";",
"RCC_OscInitStruct",
".",
"HSICalibrationValue",
"=",
"RCC_HSICALIBRATION_DEFAULT",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_ON",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLSource",
"=",
"RCC_PLLSOURCE_HSI",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLMUL",
"=",
"RCC_PLL_MUL6",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLDIV",
"=",
"RCC_PLL_DIV3",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"__HAL_RCC_PWR_CLK_ENABLE",
"(",
")",
";",
"__HAL_PWR_VOLTAGESCALING_CONFIG",
"(",
"PWR_REGULATOR_VOLTAGE_SCALE1",
")",
";",
"while",
"(",
"__HAL_PWR_GET_FLAG",
"(",
"PWR_FLAG_VOS",
")",
"!=",
"RESET",
")",
"{",
"}",
";",
"RCC_ClkInitStruct",
".",
"ClockType",
"=",
"(",
"RCC_CLOCKTYPE_SYSCLK",
"|",
"RCC_CLOCKTYPE_HCLK",
"|",
"RCC_CLOCKTYPE_PCLK1",
"|",
"RCC_CLOCKTYPE_PCLK2",
")",
";",
"RCC_ClkInitStruct",
".",
"SYSCLKSource",
"=",
"RCC_SYSCLKSOURCE_PLLCLK",
";",
"RCC_ClkInitStruct",
".",
"AHBCLKDivider",
"=",
"RCC_SYSCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB1CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB2CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"if",
"(",
"HAL_RCC_ClockConfig",
"(",
"&",
"RCC_ClkInitStruct",
",",
"FLASH_LATENCY_1",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}"
] | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | [
"/* Enable HSE Oscillator and Activate PLL with HSE as source */",
"/* Set Voltage scale1 as MCU will run at 32MHz */",
"/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */",
"/* Select PLL as system clock source and configure the HCLK,\r\n PCLK1 and PCLK2 clocks dividers */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7e045c73be4e29403325209b5d70e99cbaeed73f | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogExtended/Src/cube_hal_l1.c | [
"MIT"
] | C | Config_DMA_Handler | void | void Config_DMA_Handler(DMA_HandleTypeDef *handle_dma)
{
handle_dma->Instance = DMA1_Channel6;
handle_dma->Init.Direction = DMA_PERIPH_TO_MEMORY;
handle_dma->Init.PeriphInc = DMA_PINC_DISABLE;
handle_dma->Init.MemInc = DMA_MINC_ENABLE;
handle_dma->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
handle_dma->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
handle_dma->Init.Mode = DMA_CIRCULAR;
handle_dma->Init.Priority = DMA_PRIORITY_MEDIUM;
} | /**
* @brief Configure the DMA handler for transmission process
* @param handle_dma DMA handle
* @retval None
*/ | @brief Configure the DMA handler for transmission process
@param handle_dma DMA handle
@retval None | [
"@brief",
"Configure",
"the",
"DMA",
"handler",
"for",
"transmission",
"process",
"@param",
"handle_dma",
"DMA",
"handle",
"@retval",
"None"
] | void Config_DMA_Handler(DMA_HandleTypeDef *handle_dma)
{
handle_dma->Instance = DMA1_Channel6;
handle_dma->Init.Direction = DMA_PERIPH_TO_MEMORY;
handle_dma->Init.PeriphInc = DMA_PINC_DISABLE;
handle_dma->Init.MemInc = DMA_MINC_ENABLE;
handle_dma->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
handle_dma->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
handle_dma->Init.Mode = DMA_CIRCULAR;
handle_dma->Init.Priority = DMA_PRIORITY_MEDIUM;
} | [
"void",
"Config_DMA_Handler",
"(",
"DMA_HandleTypeDef",
"*",
"handle_dma",
")",
"{",
"handle_dma",
"->",
"Instance",
"=",
"DMA1_Channel6",
";",
"handle_dma",
"->",
"Init",
".",
"Direction",
"=",
"DMA_PERIPH_TO_MEMORY",
";",
"handle_dma",
"->",
"Init",
".",
"PeriphInc",
"=",
"DMA_PINC_DISABLE",
";",
"handle_dma",
"->",
"Init",
".",
"MemInc",
"=",
"DMA_MINC_ENABLE",
";",
"handle_dma",
"->",
"Init",
".",
"PeriphDataAlignment",
"=",
"DMA_PDATAALIGN_BYTE",
";",
"handle_dma",
"->",
"Init",
".",
"MemDataAlignment",
"=",
"DMA_MDATAALIGN_BYTE",
";",
"handle_dma",
"->",
"Init",
".",
"Mode",
"=",
"DMA_CIRCULAR",
";",
"handle_dma",
"->",
"Init",
".",
"Priority",
"=",
"DMA_PRIORITY_MEDIUM",
";",
"}"
] | @brief Configure the DMA handler for transmission process
@param handle_dma DMA handle
@retval None | [
"@brief",
"Configure",
"the",
"DMA",
"handler",
"for",
"transmission",
"process",
"@param",
"handle_dma",
"DMA",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle_dma",
"type": "DMA_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle_dma",
"type": "DMA_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | floatToInt | void | static void floatToInt(float in, displayFloatToInt_t *out_value, int32_t dec_prec)
{
if(in >= 0.0f)
{
out_value->sign = 0;
}else
{
out_value->sign = 1;
in = -in;
}
out_value->out_int = (int32_t)in;
in = in - (float)(out_value->out_int);
out_value->out_dec = (int32_t)trunc(in * pow(10, dec_prec));
} | /**
* @brief Splits a float into two integer values.
* @param in the float value as input
* @param out_value the pointer to the output integer structure
* @param dec_prec the decimal precision to be used
* @retval None
*/ | @brief Splits a float into two integer values.
@param in the float value as input
@param out_value the pointer to the output integer structure
@param dec_prec the decimal precision to be used
@retval None | [
"@brief",
"Splits",
"a",
"float",
"into",
"two",
"integer",
"values",
".",
"@param",
"in",
"the",
"float",
"value",
"as",
"input",
"@param",
"out_value",
"the",
"pointer",
"to",
"the",
"output",
"integer",
"structure",
"@param",
"dec_prec",
"the",
"decimal",
"precision",
"to",
"be",
"used",
"@retval",
"None"
] | static void floatToInt(float in, displayFloatToInt_t *out_value, int32_t dec_prec)
{
if(in >= 0.0f)
{
out_value->sign = 0;
}else
{
out_value->sign = 1;
in = -in;
}
out_value->out_int = (int32_t)in;
in = in - (float)(out_value->out_int);
out_value->out_dec = (int32_t)trunc(in * pow(10, dec_prec));
} | [
"static",
"void",
"floatToInt",
"(",
"float",
"in",
",",
"displayFloatToInt_t",
"*",
"out_value",
",",
"int32_t",
"dec_prec",
")",
"{",
"if",
"(",
"in",
">=",
"0.0f",
")",
"{",
"out_value",
"->",
"sign",
"=",
"0",
";",
"}",
"else",
"{",
"out_value",
"->",
"sign",
"=",
"1",
";",
"in",
"=",
"-",
"in",
";",
"}",
"out_value",
"->",
"out_int",
"=",
"(",
"int32_t",
")",
"in",
";",
"in",
"=",
"in",
"-",
"(",
"float",
")",
"(",
"out_value",
"->",
"out_int",
")",
";",
"out_value",
"->",
"out_dec",
"=",
"(",
"int32_t",
")",
"trunc",
"(",
"in",
"*",
"pow",
"(",
"10",
",",
"dec_prec",
")",
")",
";",
"}"
] | @brief Splits a float into two integer values. | [
"@brief",
"Splits",
"a",
"float",
"into",
"two",
"integer",
"values",
"."
] | [] | [
{
"param": "in",
"type": "float"
},
{
"param": "out_value",
"type": "displayFloatToInt_t"
},
{
"param": "dec_prec",
"type": "int32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "in",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "out_value",
"type": "displayFloatToInt_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dec_prec",
"type": "int32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Accelero_Sensor_Handler | void | static void Accelero_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t acceleration;
uint8_t status;
displayFloatToInt_t out_value;
BSP_ACCELERO_Get_Instance( handle, &id );
BSP_ACCELERO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_ACCELERO_Get_Axes( handle, &acceleration ) == COMPONENT_ERROR )
{
acceleration.AXIS_X = 0;
acceleration.AXIS_Y = 0;
acceleration.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nACC_X[%d]: %d, ACC_Y[%d]: %d, ACC_Z[%d]: %d\r\n", (int)id, (int)acceleration.AXIS_X, (int)id,
(int)acceleration.AXIS_Y, (int)id, (int)acceleration.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_ACCELERO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_ACCELERO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_ACCELERO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d g\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the accelerometer axes data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the accelerometer axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"accelerometer",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Accelero_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t acceleration;
uint8_t status;
displayFloatToInt_t out_value;
BSP_ACCELERO_Get_Instance( handle, &id );
BSP_ACCELERO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_ACCELERO_Get_Axes( handle, &acceleration ) == COMPONENT_ERROR )
{
acceleration.AXIS_X = 0;
acceleration.AXIS_Y = 0;
acceleration.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nACC_X[%d]: %d, ACC_Y[%d]: %d, ACC_Z[%d]: %d\r\n", (int)id, (int)acceleration.AXIS_X, (int)id,
(int)acceleration.AXIS_Y, (int)id, (int)acceleration.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_ACCELERO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_ACCELERO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_ACCELERO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d g\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Accelero_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"float",
"fullScale",
";",
"uint8_t",
"id",
";",
"SensorAxes_t",
"acceleration",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_ACCELERO_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_ACCELERO_Get_Axes",
"(",
"handle",
",",
"&",
"acceleration",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"acceleration",
".",
"AXIS_X",
"=",
"0",
";",
"acceleration",
".",
"AXIS_Y",
"=",
"0",
";",
"acceleration",
".",
"AXIS_Z",
"=",
"0",
";",
"}",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"acceleration",
".",
"AXIS_X",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"acceleration",
".",
"AXIS_Y",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"acceleration",
".",
"AXIS_Z",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_ACCELERO_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_ACCELERO_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_ACCELERO_Get_FS",
"(",
"handle",
",",
"&",
"fullScale",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"fullScale",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the accelerometer axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"accelerometer",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Gyro_Sensor_Handler | void | static void Gyro_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t angular_velocity;
uint8_t status;
displayFloatToInt_t out_value;
BSP_GYRO_Get_Instance( handle, &id );
BSP_GYRO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_GYRO_Get_Axes( handle, &angular_velocity ) == COMPONENT_ERROR )
{
angular_velocity.AXIS_X = 0;
angular_velocity.AXIS_Y = 0;
angular_velocity.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nGYR_X[%d]: %d, GYR_Y[%d]: %d, GYR_Z[%d]: %d\r\n", (int)id, (int)angular_velocity.AXIS_X, (int)id,
(int)angular_velocity.AXIS_Y, (int)id, (int)angular_velocity.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_GYRO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_GYRO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_GYRO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d dps\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the gyroscope axes data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the gyroscope axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"gyroscope",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Gyro_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t angular_velocity;
uint8_t status;
displayFloatToInt_t out_value;
BSP_GYRO_Get_Instance( handle, &id );
BSP_GYRO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_GYRO_Get_Axes( handle, &angular_velocity ) == COMPONENT_ERROR )
{
angular_velocity.AXIS_X = 0;
angular_velocity.AXIS_Y = 0;
angular_velocity.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nGYR_X[%d]: %d, GYR_Y[%d]: %d, GYR_Z[%d]: %d\r\n", (int)id, (int)angular_velocity.AXIS_X, (int)id,
(int)angular_velocity.AXIS_Y, (int)id, (int)angular_velocity.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_GYRO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_GYRO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_GYRO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d dps\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Gyro_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"float",
"fullScale",
";",
"uint8_t",
"id",
";",
"SensorAxes_t",
"angular_velocity",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_GYRO_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_GYRO_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_GYRO_Get_Axes",
"(",
"handle",
",",
"&",
"angular_velocity",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"angular_velocity",
".",
"AXIS_X",
"=",
"0",
";",
"angular_velocity",
".",
"AXIS_Y",
"=",
"0",
";",
"angular_velocity",
".",
"AXIS_Z",
"=",
"0",
";",
"}",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"angular_velocity",
".",
"AXIS_X",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"angular_velocity",
".",
"AXIS_Y",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"angular_velocity",
".",
"AXIS_Z",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_GYRO_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_GYRO_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_GYRO_Get_FS",
"(",
"handle",
",",
"&",
"fullScale",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"fullScale",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the gyroscope axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"gyroscope",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Magneto_Sensor_Handler | void | static void Magneto_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t magnetic_field;
uint8_t status;
displayFloatToInt_t out_value;
BSP_MAGNETO_Get_Instance( handle, &id );
BSP_MAGNETO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_MAGNETO_Get_Axes( handle, &magnetic_field ) == COMPONENT_ERROR )
{
magnetic_field.AXIS_X = 0;
magnetic_field.AXIS_Y = 0;
magnetic_field.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nMAG_X[%d]: %d, MAG_Y[%d]: %d, MAG_Z[%d]: %d\r\n", (int)id, (int)magnetic_field.AXIS_X, (int)id,
(int)magnetic_field.AXIS_Y, (int)id, (int)magnetic_field.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_MAGNETO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_MAGNETO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_MAGNETO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d Gauss\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the magneto axes data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the magneto axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"magneto",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Magneto_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
float fullScale;
uint8_t id;
SensorAxes_t magnetic_field;
uint8_t status;
displayFloatToInt_t out_value;
BSP_MAGNETO_Get_Instance( handle, &id );
BSP_MAGNETO_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_MAGNETO_Get_Axes( handle, &magnetic_field ) == COMPONENT_ERROR )
{
magnetic_field.AXIS_X = 0;
magnetic_field.AXIS_Y = 0;
magnetic_field.AXIS_Z = 0;
}
snprintf( dataOut, MAX_BUF_SIZE, "\r\nMAG_X[%d]: %d, MAG_Y[%d]: %d, MAG_Z[%d]: %d\r\n", (int)id, (int)magnetic_field.AXIS_X, (int)id,
(int)magnetic_field.AXIS_Y, (int)id, (int)magnetic_field.AXIS_Z );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_MAGNETO_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_MAGNETO_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_MAGNETO_Get_FS( handle, &fullScale ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: ERROR\r\n", id );
}
else
{
floatToInt( fullScale, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "FS[%d]: %d.%03d Gauss\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Magneto_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"float",
"fullScale",
";",
"uint8_t",
"id",
";",
"SensorAxes_t",
"magnetic_field",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_MAGNETO_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_MAGNETO_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_MAGNETO_Get_Axes",
"(",
"handle",
",",
"&",
"magnetic_field",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"magnetic_field",
".",
"AXIS_X",
"=",
"0",
";",
"magnetic_field",
".",
"AXIS_Y",
"=",
"0",
";",
"magnetic_field",
".",
"AXIS_Z",
"=",
"0",
";",
"}",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"magnetic_field",
".",
"AXIS_X",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"magnetic_field",
".",
"AXIS_Y",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"magnetic_field",
".",
"AXIS_Z",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_MAGNETO_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_MAGNETO_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_MAGNETO_Get_FS",
"(",
"handle",
",",
"&",
"fullScale",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"fullScale",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the magneto axes data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"magneto",
"axes",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Humidity_Sensor_Handler | void | static void Humidity_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float humidity;
uint8_t status;
displayFloatToInt_t out_value;
BSP_HUMIDITY_Get_Instance( handle, &id );
BSP_HUMIDITY_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_HUMIDITY_Get_Hum( handle, &humidity ) == COMPONENT_ERROR )
{
humidity = 0.0f;
}
floatToInt( humidity, &out_value, 2 );
snprintf( dataOut, MAX_BUF_SIZE, "\r\nHUM[%d]: %d.%02d\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_HUMIDITY_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_HUMIDITY_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the humidity data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the humidity data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"humidity",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Humidity_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float humidity;
uint8_t status;
displayFloatToInt_t out_value;
BSP_HUMIDITY_Get_Instance( handle, &id );
BSP_HUMIDITY_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_HUMIDITY_Get_Hum( handle, &humidity ) == COMPONENT_ERROR )
{
humidity = 0.0f;
}
floatToInt( humidity, &out_value, 2 );
snprintf( dataOut, MAX_BUF_SIZE, "\r\nHUM[%d]: %d.%02d\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_HUMIDITY_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_HUMIDITY_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Humidity_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"uint8_t",
"id",
";",
"float",
"humidity",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_HUMIDITY_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_HUMIDITY_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_HUMIDITY_Get_Hum",
"(",
"handle",
",",
"&",
"humidity",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"humidity",
"=",
"0.0f",
";",
"}",
"floatToInt",
"(",
"humidity",
",",
"&",
"out_value",
",",
"2",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_HUMIDITY_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_HUMIDITY_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the humidity data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"humidity",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Temperature_Sensor_Handler | void | static void Temperature_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float temperature;
uint8_t status;
displayFloatToInt_t out_value;
BSP_TEMPERATURE_Get_Instance( handle, &id );
BSP_TEMPERATURE_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_TEMPERATURE_Get_Temp( handle, &temperature ) == COMPONENT_ERROR )
{
temperature = 0.0f;
}
floatToInt( temperature, &out_value, 2 );
snprintf( dataOut, MAX_BUF_SIZE, "\r\nTEMP[%d]: %c%d.%02d\r\n", (int)id, ((out_value.sign) ? '-' : '+'), (int)out_value.out_int, (int)out_value.out_dec );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_TEMPERATURE_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_TEMPERATURE_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the temperature data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the temperature data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"temperature",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Temperature_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float temperature;
uint8_t status;
displayFloatToInt_t out_value;
BSP_TEMPERATURE_Get_Instance( handle, &id );
BSP_TEMPERATURE_IsInitialized( handle, &status );
if ( status == 1 )
{
if ( BSP_TEMPERATURE_Get_Temp( handle, &temperature ) == COMPONENT_ERROR )
{
temperature = 0.0f;
}
floatToInt( temperature, &out_value, 2 );
snprintf( dataOut, MAX_BUF_SIZE, "\r\nTEMP[%d]: %c%d.%02d\r\n", (int)id, ((out_value.sign) ? '-' : '+'), (int)out_value.out_int, (int)out_value.out_dec );
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_TEMPERATURE_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_TEMPERATURE_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Temperature_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"uint8_t",
"id",
";",
"float",
"temperature",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_TEMPERATURE_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_TEMPERATURE_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_TEMPERATURE_Get_Temp",
"(",
"handle",
",",
"&",
"temperature",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"temperature",
"=",
"0.0f",
";",
"}",
"floatToInt",
"(",
"temperature",
",",
"&",
"out_value",
",",
"2",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"(",
"out_value",
".",
"sign",
")",
"?",
"'",
"'",
":",
"'",
"'",
")",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_TEMPERATURE_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_TEMPERATURE_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the temperature data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"temperature",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | Pressure_Sensor_Handler | void | static void Pressure_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float pressure;
uint8_t status;
displayFloatToInt_t out_value;
BSP_PRESSURE_Get_Instance( handle, &id );
BSP_PRESSURE_IsInitialized( handle, &status );
if( status == 1 )
{
if ( BSP_PRESSURE_Get_Press( handle, &pressure ) == COMPONENT_ERROR )
{
pressure = 0.0f;
}
floatToInt( pressure, &out_value, 2 );
snprintf(dataOut, MAX_BUF_SIZE, "\r\nPRESS[%d]: %d.%02d\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec);
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_PRESSURE_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_PRESSURE_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | /**
* @brief Handles the pressure sensor data getting/sending
* @param handle the device handle
* @retval None
*/ | @brief Handles the pressure sensor data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"pressure",
"sensor",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | static void Pressure_Sensor_Handler( void *handle )
{
uint8_t who_am_i;
float odr;
uint8_t id;
float pressure;
uint8_t status;
displayFloatToInt_t out_value;
BSP_PRESSURE_Get_Instance( handle, &id );
BSP_PRESSURE_IsInitialized( handle, &status );
if( status == 1 )
{
if ( BSP_PRESSURE_Get_Press( handle, &pressure ) == COMPONENT_ERROR )
{
pressure = 0.0f;
}
floatToInt( pressure, &out_value, 2 );
snprintf(dataOut, MAX_BUF_SIZE, "\r\nPRESS[%d]: %d.%02d\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec);
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( verbose == 1 )
{
if ( BSP_PRESSURE_Get_WhoAmI( handle, &who_am_i ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: ERROR\r\n", id );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "WHO AM I address[%d]: 0x%02X\r\n", id, who_am_i );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
if ( BSP_PRESSURE_Get_ODR( handle, &odr ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: ERROR\r\n", id );
}
else
{
floatToInt( odr, &out_value, 3 );
snprintf( dataOut, MAX_BUF_SIZE, "ODR[%d]: %d.%03d Hz\r\n", (int)id, (int)out_value.out_int, (int)out_value.out_dec );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 5000 );
}
}
} | [
"static",
"void",
"Pressure_Sensor_Handler",
"(",
"void",
"*",
"handle",
")",
"{",
"uint8_t",
"who_am_i",
";",
"float",
"odr",
";",
"uint8_t",
"id",
";",
"float",
"pressure",
";",
"uint8_t",
"status",
";",
"displayFloatToInt_t",
"out_value",
";",
"BSP_PRESSURE_Get_Instance",
"(",
"handle",
",",
"&",
"id",
")",
";",
"BSP_PRESSURE_IsInitialized",
"(",
"handle",
",",
"&",
"status",
")",
";",
"if",
"(",
"status",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_PRESSURE_Get_Press",
"(",
"handle",
",",
"&",
"pressure",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"pressure",
"=",
"0.0f",
";",
"}",
"floatToInt",
"(",
"pressure",
",",
"&",
"out_value",
",",
"2",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"verbose",
"==",
"1",
")",
"{",
"if",
"(",
"BSP_PRESSURE_Get_WhoAmI",
"(",
"handle",
",",
"&",
"who_am_i",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
",",
"who_am_i",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"if",
"(",
"BSP_PRESSURE_Get_ODR",
"(",
"handle",
",",
"&",
"odr",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"floatToInt",
"(",
"odr",
",",
"&",
"out_value",
",",
"3",
")",
";",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"int",
")",
"id",
",",
"(",
"int",
")",
"out_value",
".",
"out_int",
",",
"(",
"int",
")",
"out_value",
".",
"out_dec",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}",
"}",
"}"
] | @brief Handles the pressure sensor data getting/sending
@param handle the device handle
@retval None | [
"@brief",
"Handles",
"the",
"pressure",
"sensor",
"data",
"getting",
"/",
"sending",
"@param",
"handle",
"the",
"device",
"handle",
"@retval",
"None"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | RTC_TimeStampConfig | void | static void RTC_TimeStampConfig( void )
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/*##-3- Configure the Date using BCD format ################################*/
/* Set Date: Monday January 1st 2000 */
sdatestructure.Year = 0x00;
sdatestructure.Month = RTC_MONTH_JANUARY;
sdatestructure.Date = 0x01;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if ( HAL_RTC_SetDate( &RtcHandle, &sdatestructure, FORMAT_BCD ) != HAL_OK )
{
/* Initialization Error */
Error_Handler();
}
/*##-4- Configure the Time using BCD format#################################*/
/* Set Time: 00:00:00 */
stimestructure.Hours = 0x00;
stimestructure.Minutes = 0x00;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if ( HAL_RTC_SetTime( &RtcHandle, &stimestructure, FORMAT_BCD ) != HAL_OK )
{
/* Initialization Error */
Error_Handler();
}
} | /**
* @brief Configures the current time and date
* @param None
* @retval None
*/ | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | static void RTC_TimeStampConfig( void )
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
sdatestructure.Year = 0x00;
sdatestructure.Month = RTC_MONTH_JANUARY;
sdatestructure.Date = 0x01;
sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
if ( HAL_RTC_SetDate( &RtcHandle, &sdatestructure, FORMAT_BCD ) != HAL_OK )
{
Error_Handler();
}
stimestructure.Hours = 0x00;
stimestructure.Minutes = 0x00;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if ( HAL_RTC_SetTime( &RtcHandle, &stimestructure, FORMAT_BCD ) != HAL_OK )
{
Error_Handler();
}
} | [
"static",
"void",
"RTC_TimeStampConfig",
"(",
"void",
")",
"{",
"RTC_DateTypeDef",
"sdatestructure",
";",
"RTC_TimeTypeDef",
"stimestructure",
";",
"sdatestructure",
".",
"Year",
"=",
"0x00",
";",
"sdatestructure",
".",
"Month",
"=",
"RTC_MONTH_JANUARY",
";",
"sdatestructure",
".",
"Date",
"=",
"0x01",
";",
"sdatestructure",
".",
"WeekDay",
"=",
"RTC_WEEKDAY_MONDAY",
";",
"if",
"(",
"HAL_RTC_SetDate",
"(",
"&",
"RtcHandle",
",",
"&",
"sdatestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"stimestructure",
".",
"Hours",
"=",
"0x00",
";",
"stimestructure",
".",
"Minutes",
"=",
"0x00",
";",
"stimestructure",
".",
"Seconds",
"=",
"0x00",
";",
"stimestructure",
".",
"TimeFormat",
"=",
"RTC_HOURFORMAT12_AM",
";",
"stimestructure",
".",
"DayLightSaving",
"=",
"RTC_DAYLIGHTSAVING_NONE",
";",
"stimestructure",
".",
"StoreOperation",
"=",
"RTC_STOREOPERATION_RESET",
";",
"if",
"(",
"HAL_RTC_SetTime",
"(",
"&",
"RtcHandle",
",",
"&",
"stimestructure",
",",
"FORMAT_BCD",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}"
] | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | [
"/*##-3- Configure the Date using BCD format ################################*/",
"/* Set Date: Monday January 1st 2000 */",
"/* Initialization Error */",
"/*##-4- Configure the Time using BCD format#################################*/",
"/* Set Time: 00:00:00 */",
"/* Initialization Error */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8f9412bfac3507187d7bd8f5f688d2ef90813f8b | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/DataLogTerminal/Src/main.c | [
"MIT"
] | C | HAL_GPIO_EXTI_Callback | void | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
/* User button. */
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
if ( acquire_data_enabled == 0 )
{
acquire_data_enable_request = 1;
}
else
{
acquire_data_disable_request = 1;
}
}
}
} | /**
* @brief EXTI line detection callbacks
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/ | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
if ( acquire_data_enabled == 0 )
{
acquire_data_enable_request = 1;
}
else
{
acquire_data_disable_request = 1;
}
}
}
} | [
"void",
"HAL_GPIO_EXTI_Callback",
"(",
"uint16_t",
"GPIO_Pin",
")",
"{",
"if",
"(",
"GPIO_Pin",
"==",
"KEY_BUTTON_PIN",
")",
"{",
"if",
"(",
"BSP_PB_GetState",
"(",
"BUTTON_KEY",
")",
"==",
"GPIO_PIN_RESET",
")",
"{",
"if",
"(",
"acquire_data_enabled",
"==",
"0",
")",
"{",
"acquire_data_enable_request",
"=",
"1",
";",
"}",
"else",
"{",
"acquire_data_disable_request",
"=",
"1",
";",
"}",
"}",
"}",
"}"
] | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | [
"/* User button. */"
] | [
{
"param": "GPIO_Pin",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GPIO_Pin",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8fd0e1f47661fdb3221b861e7ab5a35e0bfa2779 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A1/LSM6DS3_FIFOMode/Src/cube_hal_l1.c | [
"MIT"
] | C | SystemClock_Config | void | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
/* Enable HSE Oscillator and Activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(__func__);
}
/* Set Voltage scale1 as MCU will run at 32MHz */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
/* Select PLL as system clock source and configure the HCLK,
PCLK1 and PCLK2 clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler(__func__);
}
} | /**
* @brief System Clock Configuration
* @param None
* @retval None
*/ | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(__func__);
}
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler(__func__);
}
} | [
"void",
"SystemClock_Config",
"(",
"void",
")",
"{",
"RCC_ClkInitTypeDef",
"RCC_ClkInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_HSI",
";",
"RCC_OscInitStruct",
".",
"HSIState",
"=",
"RCC_HSI_ON",
";",
"RCC_OscInitStruct",
".",
"HSICalibrationValue",
"=",
"RCC_HSICALIBRATION_DEFAULT",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_ON",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLSource",
"=",
"RCC_PLLSOURCE_HSI",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLMUL",
"=",
"RCC_PLL_MUL6",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLDIV",
"=",
"RCC_PLL_DIV3",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
"__func__",
")",
";",
"}",
"__HAL_RCC_PWR_CLK_ENABLE",
"(",
")",
";",
"__HAL_PWR_VOLTAGESCALING_CONFIG",
"(",
"PWR_REGULATOR_VOLTAGE_SCALE1",
")",
";",
"while",
"(",
"__HAL_PWR_GET_FLAG",
"(",
"PWR_FLAG_VOS",
")",
"!=",
"RESET",
")",
"{",
"}",
";",
"RCC_ClkInitStruct",
".",
"ClockType",
"=",
"(",
"RCC_CLOCKTYPE_SYSCLK",
"|",
"RCC_CLOCKTYPE_HCLK",
"|",
"RCC_CLOCKTYPE_PCLK1",
"|",
"RCC_CLOCKTYPE_PCLK2",
")",
";",
"RCC_ClkInitStruct",
".",
"SYSCLKSource",
"=",
"RCC_SYSCLKSOURCE_PLLCLK",
";",
"RCC_ClkInitStruct",
".",
"AHBCLKDivider",
"=",
"RCC_SYSCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB1CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB2CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"if",
"(",
"HAL_RCC_ClockConfig",
"(",
"&",
"RCC_ClkInitStruct",
",",
"FLASH_LATENCY_1",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
"__func__",
")",
";",
"}",
"}"
] | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | [
"/* Enable HSE Oscillator and Activate PLL with HSE as source */",
"/* Set Voltage scale1 as MCU will run at 32MHz */",
"/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */",
"/* Select PLL as system clock source and configure the HCLK,\r\n PCLK1 and PCLK2 clocks dividers */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ecdeac240f42743db248bc15cab2049ec385d3f3 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LPS22HB_FIFOMode/Src/cube_hal_l4.c | [
"MIT"
] | C | SystemClock_Config | void | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
/* MSI is enabled after System reset, activate PLL with MSI as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 40;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLP = 7;
RCC_OscInitStruct.PLL.PLLQ = 4;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler(__func__);
}
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
/* Initialization Error */
Error_Handler(__func__);
}
} | /**
* @brief System Clock Configuration
* @param None
* @retval None
*/ | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 40;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLP = 7;
RCC_OscInitStruct.PLL.PLLQ = 4;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(__func__);
}
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler(__func__);
}
} | [
"void",
"SystemClock_Config",
"(",
"void",
")",
"{",
"RCC_ClkInitTypeDef",
"RCC_ClkInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
"=",
"{",
"0",
"}",
";",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_MSI",
";",
"RCC_OscInitStruct",
".",
"MSIState",
"=",
"RCC_MSI_ON",
";",
"RCC_OscInitStruct",
".",
"MSIClockRange",
"=",
"RCC_MSIRANGE_6",
";",
"RCC_OscInitStruct",
".",
"MSICalibrationValue",
"=",
"RCC_MSICALIBRATION_DEFAULT",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_ON",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLSource",
"=",
"RCC_PLLSOURCE_MSI",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLM",
"=",
"1",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLN",
"=",
"40",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLR",
"=",
"2",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLP",
"=",
"7",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLQ",
"=",
"4",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
"__func__",
")",
";",
"}",
"RCC_ClkInitStruct",
".",
"ClockType",
"=",
"(",
"RCC_CLOCKTYPE_SYSCLK",
"|",
"RCC_CLOCKTYPE_HCLK",
"|",
"RCC_CLOCKTYPE_PCLK1",
"|",
"RCC_CLOCKTYPE_PCLK2",
")",
";",
"RCC_ClkInitStruct",
".",
"SYSCLKSource",
"=",
"RCC_SYSCLKSOURCE_PLLCLK",
";",
"RCC_ClkInitStruct",
".",
"AHBCLKDivider",
"=",
"RCC_SYSCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB1CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"RCC_ClkInitStruct",
".",
"APB2CLKDivider",
"=",
"RCC_HCLK_DIV1",
";",
"if",
"(",
"HAL_RCC_ClockConfig",
"(",
"&",
"RCC_ClkInitStruct",
",",
"FLASH_LATENCY_4",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
"__func__",
")",
";",
"}",
"}"
] | @brief System Clock Configuration
@param None
@retval None | [
"@brief",
"System",
"Clock",
"Configuration",
"@param",
"None",
"@retval",
"None"
] | [
"/* MSI is enabled after System reset, activate PLL with MSI as source */",
"/* Initialization Error */",
"/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2\r\n clocks dividers */",
"/* Initialization Error */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ececd0cc8d0034d5d59497aede9fb6f0162814f1 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/Pedometer/Src/MotionPM_Manager.c | [
"MIT"
] | C | MotionPM_manager_init | uint8_t | uint8_t MotionPM_manager_init(void *handle)
{
MotionPM_Initialize();
return 1;
} | /**
* @brief Initialize the MotionPM engine
* @param None
* @retval 1 in case of success,
* @retval 0 otherwise
*/ | @brief Initialize the MotionPM engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionPM",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | uint8_t MotionPM_manager_init(void *handle)
{
MotionPM_Initialize();
return 1;
} | [
"uint8_t",
"MotionPM_manager_init",
"(",
"void",
"*",
"handle",
")",
"{",
"MotionPM_Initialize",
"(",
")",
";",
"return",
"1",
";",
"}"
] | @brief Initialize the MotionPM engine
@param None
@retval 1 in case of success,
@retval 0 otherwise | [
"@brief",
"Initialize",
"the",
"MotionPM",
"engine",
"@param",
"None",
"@retval",
"1",
"in",
"case",
"of",
"success",
"@retval",
"0",
"otherwise"
] | [] | [
{
"param": "handle",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e691835fc10677959928dd01aa396d497b2a54b0 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/StandingSittingDesk/Src/stm32f4xx_hal_msp.c | [
"MIT"
] | C | HAL_RTC_MspInit | void | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*##-1- Configue LSE as RTC clock soucre ###################################*/
if(use_LSI == 0)
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
else
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
/*##-2- Enable RTC peripheral Clocks #######################################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
/*##-3- Configure the NVIC for RTC TimeStamp ###################################*/
HAL_NVIC_SetPriority(TAMP_STAMP_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TAMP_STAMP_IRQn);
} | /**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example
* @param hrtc: RTC handle pointer
*
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
* the RTC clock source; in this case the Backup domain will be reset in
* order to modify the RTC Clock source, as consequence RTC registers (including
* the backup registers) and RCC_BDCR register are set to their reset values.
*
* @retval None
*/ | @brief RTC MSP Initialization
This function configures the hardware resources used in this example
@param hrtc: RTC handle pointer
@note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
the RTC clock source; in this case the Backup domain will be reset in
order to modify the RTC Clock source, as consequence RTC registers (including
the backup registers) and RCC_BDCR register are set to their reset values.
@retval None | [
"@brief",
"RTC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer",
"@note",
"Care",
"must",
"be",
"taken",
"when",
"HAL_RCCEx_PeriphCLKConfig",
"()",
"is",
"used",
"to",
"select",
"the",
"RTC",
"clock",
"source",
";",
"in",
"this",
"case",
"the",
"Backup",
"domain",
"will",
"be",
"reset",
"in",
"order",
"to",
"modify",
"the",
"RTC",
"Clock",
"source",
"as",
"consequence",
"RTC",
"registers",
"(",
"including",
"the",
"backup",
"registers",
")",
"and",
"RCC_BDCR",
"register",
"are",
"set",
"to",
"their",
"reset",
"values",
".",
"@retval",
"None"
] | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
if(use_LSI == 0)
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
else
{
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
__HAL_RCC_RTC_ENABLE();
HAL_NVIC_SetPriority(TAMP_STAMP_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TAMP_STAMP_IRQn);
} | [
"void",
"HAL_RTC_MspInit",
"(",
"RTC_HandleTypeDef",
"*",
"hrtc",
")",
"{",
"RCC_OscInitTypeDef",
"RCC_OscInitStruct",
";",
"RCC_PeriphCLKInitTypeDef",
"PeriphClkInitStruct",
";",
"if",
"(",
"use_LSI",
"==",
"0",
")",
"{",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_LSI",
"|",
"RCC_OSCILLATORTYPE_LSE",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_NONE",
";",
"RCC_OscInitStruct",
".",
"LSEState",
"=",
"RCC_LSE_ON",
";",
"RCC_OscInitStruct",
".",
"LSIState",
"=",
"RCC_LSI_OFF",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"PeriphClkInitStruct",
".",
"PeriphClockSelection",
"=",
"RCC_PERIPHCLK_RTC",
";",
"PeriphClkInitStruct",
".",
"RTCClockSelection",
"=",
"RCC_RTCCLKSOURCE_LSE",
";",
"if",
"(",
"HAL_RCCEx_PeriphCLKConfig",
"(",
"&",
"PeriphClkInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"else",
"{",
"RCC_OscInitStruct",
".",
"OscillatorType",
"=",
"RCC_OSCILLATORTYPE_LSI",
"|",
"RCC_OSCILLATORTYPE_LSE",
";",
"RCC_OscInitStruct",
".",
"PLL",
".",
"PLLState",
"=",
"RCC_PLL_NONE",
";",
"RCC_OscInitStruct",
".",
"LSIState",
"=",
"RCC_LSI_ON",
";",
"RCC_OscInitStruct",
".",
"LSEState",
"=",
"RCC_LSE_OFF",
";",
"if",
"(",
"HAL_RCC_OscConfig",
"(",
"&",
"RCC_OscInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"PeriphClkInitStruct",
".",
"PeriphClockSelection",
"=",
"RCC_PERIPHCLK_RTC",
";",
"PeriphClkInitStruct",
".",
"RTCClockSelection",
"=",
"RCC_RTCCLKSOURCE_LSI",
";",
"if",
"(",
"HAL_RCCEx_PeriphCLKConfig",
"(",
"&",
"PeriphClkInitStruct",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"__HAL_RCC_RTC_ENABLE",
"(",
")",
";",
"HAL_NVIC_SetPriority",
"(",
"TAMP_STAMP_IRQn",
",",
"0x0F",
",",
"0",
")",
";",
"HAL_NVIC_EnableIRQ",
"(",
"TAMP_STAMP_IRQn",
")",
";",
"}"
] | @brief RTC MSP Initialization
This function configures the hardware resources used in this example
@param hrtc: RTC handle pointer | [
"@brief",
"RTC",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer"
] | [
"/*##-1- Configue LSE as RTC clock soucre ###################################*/",
"/* Initialization Error */",
"/* Initialization Error */",
"/* Initialization Error */",
"/* Initialization Error */",
"/*##-2- Enable RTC peripheral Clocks #######################################*/",
"/* Enable RTC Clock */",
"/*##-3- Configure the NVIC for RTC TimeStamp ###################################*/"
] | [
{
"param": "hrtc",
"type": "RTC_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hrtc",
"type": "RTC_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e691835fc10677959928dd01aa396d497b2a54b0 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/StandingSittingDesk/Src/stm32f4xx_hal_msp.c | [
"MIT"
] | C | HAL_RTC_MspDeInit | void | void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
{
/*##-1- Reset peripherals ##################################################*/
__HAL_RCC_RTC_DISABLE();
/*##-2- Disable the NVIC for TimeStamp #####################################*/
HAL_NVIC_DisableIRQ(TAMP_STAMP_IRQn);
} | /**
* @brief RTC MSP De-Initialization
* This function frees the hardware resources used in this example:
* - Disable the Peripheral's clock
* @param hrtc: RTC handle pointer
* @retval None
*/ | @brief RTC MSP De-Initialization
This function frees the hardware resources used in this example:
- Disable the Peripheral's clock
@param hrtc: RTC handle pointer
@retval None | [
"@brief",
"RTC",
"MSP",
"De",
"-",
"Initialization",
"This",
"function",
"frees",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Disable",
"the",
"Peripheral",
"'",
"s",
"clock",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
{
__HAL_RCC_RTC_DISABLE();
HAL_NVIC_DisableIRQ(TAMP_STAMP_IRQn);
} | [
"void",
"HAL_RTC_MspDeInit",
"(",
"RTC_HandleTypeDef",
"*",
"hrtc",
")",
"{",
"__HAL_RCC_RTC_DISABLE",
"(",
")",
";",
"HAL_NVIC_DisableIRQ",
"(",
"TAMP_STAMP_IRQn",
")",
";",
"}"
] | @brief RTC MSP De-Initialization
This function frees the hardware resources used in this example:
- Disable the Peripheral's clock
@param hrtc: RTC handle pointer
@retval None | [
"@brief",
"RTC",
"MSP",
"De",
"-",
"Initialization",
"This",
"function",
"frees",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Disable",
"the",
"Peripheral",
"'",
"s",
"clock",
"@param",
"hrtc",
":",
"RTC",
"handle",
"pointer",
"@retval",
"None"
] | [
"/*##-1- Reset peripherals ##################################################*/",
"/*##-2- Disable the NVIC for TimeStamp #####################################*/"
] | [
{
"param": "hrtc",
"type": "RTC_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hrtc",
"type": "RTC_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e691835fc10677959928dd01aa396d497b2a54b0 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/StandingSittingDesk/Src/stm32f4xx_hal_msp.c | [
"MIT"
] | C | HAL_TIM_Base_MspInit | void | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_SD)
{
/* Peripheral clock enable */
TIM_SD_CLK_ENABLE();
/* System interrupt init*/
HAL_NVIC_SetPriority(TIM_SD_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TIM_SD_IRQn);
}
} | /**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/ | @brief TIM MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_SD)
{
TIM_SD_CLK_ENABLE();
HAL_NVIC_SetPriority(TIM_SD_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(TIM_SD_IRQn);
}
} | [
"void",
"HAL_TIM_Base_MspInit",
"(",
"TIM_HandleTypeDef",
"*",
"htim_base",
")",
"{",
"if",
"(",
"htim_base",
"->",
"Instance",
"==",
"TIM_SD",
")",
"{",
"TIM_SD_CLK_ENABLE",
"(",
")",
";",
"HAL_NVIC_SetPriority",
"(",
"TIM_SD_IRQn",
",",
"0x0F",
",",
"0",
")",
";",
"HAL_NVIC_EnableIRQ",
"(",
"TIM_SD_IRQn",
")",
";",
"}",
"}"
] | @brief TIM MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"Initialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock enable */",
"/* System interrupt init*/"
] | [
{
"param": "htim_base",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim_base",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e691835fc10677959928dd01aa396d497b2a54b0 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/StandingSittingDesk/Src/stm32f4xx_hal_msp.c | [
"MIT"
] | C | HAL_TIM_Base_MspDeInit | void | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_SD)
{
/* Peripheral clock disable */
TIM_SD_CLK_DISABLE();
/* Peripheral interrupt DeInit*/
HAL_NVIC_DisableIRQ(TIM_SD_IRQn);
}
} | /**
* @brief TIM MSP DeInitialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/ | @brief TIM MSP DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance == TIM_SD)
{
TIM_SD_CLK_DISABLE();
HAL_NVIC_DisableIRQ(TIM_SD_IRQn);
}
} | [
"void",
"HAL_TIM_Base_MspDeInit",
"(",
"TIM_HandleTypeDef",
"*",
"htim_base",
")",
"{",
"if",
"(",
"htim_base",
"->",
"Instance",
"==",
"TIM_SD",
")",
"{",
"TIM_SD_CLK_DISABLE",
"(",
")",
";",
"HAL_NVIC_DisableIRQ",
"(",
"TIM_SD_IRQn",
")",
";",
"}",
"}"
] | @brief TIM MSP DeInitialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param htim: TIM handle pointer
@retval None | [
"@brief",
"TIM",
"MSP",
"DeInitialization",
"This",
"function",
"configures",
"the",
"hardware",
"resources",
"used",
"in",
"this",
"example",
":",
"-",
"Peripheral",
"'",
"s",
"clock",
"enable",
"-",
"Peripheral",
"'",
"s",
"GPIO",
"Configuration",
"@param",
"htim",
":",
"TIM",
"handle",
"pointer",
"@retval",
"None"
] | [
"/* Peripheral clock disable */",
"/* Peripheral interrupt DeInit*/"
] | [
{
"param": "htim_base",
"type": "TIM_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "htim_base",
"type": "TIM_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
82310732b876de15e09d00e7d9947a5a4a4641c5 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_MultiEvent/Src/main.c | [
"MIT"
] | C | Send_Step_Count | void | static void Send_Step_Count( void )
{
uint8_t instance;
RTC_Handler();
BSP_ACCELERO_Get_Instance( LSM6DSL_X_0_handle, &instance );
if ( BSP_ACCELERO_Get_Step_Count_Ext( LSM6DSL_X_0_handle, &step_count ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting step count from LSM6DSL - accelerometer[%d].\r\n", instance );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "Step count: %d\r\n", step_count );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
} | /**
* @brief Send time stamp and step count to UART
* @param None
* @retval None
*/ | @brief Send time stamp and step count to UART
@param None
@retval None | [
"@brief",
"Send",
"time",
"stamp",
"and",
"step",
"count",
"to",
"UART",
"@param",
"None",
"@retval",
"None"
] | static void Send_Step_Count( void )
{
uint8_t instance;
RTC_Handler();
BSP_ACCELERO_Get_Instance( LSM6DSL_X_0_handle, &instance );
if ( BSP_ACCELERO_Get_Step_Count_Ext( LSM6DSL_X_0_handle, &step_count ) == COMPONENT_ERROR )
{
snprintf( dataOut, MAX_BUF_SIZE, "Error getting step count from LSM6DSL - accelerometer[%d].\r\n", instance );
}
else
{
snprintf( dataOut, MAX_BUF_SIZE, "Step count: %d\r\n", step_count );
}
HAL_UART_Transmit( &UartHandle, ( uint8_t* )dataOut, strlen( dataOut ), 5000 );
} | [
"static",
"void",
"Send_Step_Count",
"(",
"void",
")",
"{",
"uint8_t",
"instance",
";",
"RTC_Handler",
"(",
")",
";",
"BSP_ACCELERO_Get_Instance",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"instance",
")",
";",
"if",
"(",
"BSP_ACCELERO_Get_Step_Count_Ext",
"(",
"LSM6DSL_X_0_handle",
",",
"&",
"step_count",
")",
"==",
"COMPONENT_ERROR",
")",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"instance",
")",
";",
"}",
"else",
"{",
"snprintf",
"(",
"dataOut",
",",
"MAX_BUF_SIZE",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"step_count",
")",
";",
"}",
"HAL_UART_Transmit",
"(",
"&",
"UartHandle",
",",
"(",
"uint8_t",
"*",
")",
"dataOut",
",",
"strlen",
"(",
"dataOut",
")",
",",
"5000",
")",
";",
"}"
] | @brief Send time stamp and step count to UART
@param None
@retval None | [
"@brief",
"Send",
"time",
"stamp",
"and",
"step",
"count",
"to",
"UART",
"@param",
"None",
"@retval",
"None"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
82310732b876de15e09d00e7d9947a5a4a4641c5 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_MultiEvent/Src/main.c | [
"MIT"
] | C | RTC_TimeRegulate | void | void RTC_TimeRegulate( uint8_t hh, uint8_t mm, uint8_t ss )
{
RTC_TimeTypeDef stimestructure;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.Hours = hh;
stimestructure.Minutes = mm;
stimestructure.Seconds = ss;
stimestructure.SubSeconds = 0;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if ( HAL_RTC_SetTime( &RtcHandle, &stimestructure, FORMAT_BIN ) != HAL_OK )
{
/* Initialization Error */
Error_Handler();
}
} | /**
* @brief Configures the current time and date
* @param None
* @retval None
*/ | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | void RTC_TimeRegulate( uint8_t hh, uint8_t mm, uint8_t ss )
{
RTC_TimeTypeDef stimestructure;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.Hours = hh;
stimestructure.Minutes = mm;
stimestructure.Seconds = ss;
stimestructure.SubSeconds = 0;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if ( HAL_RTC_SetTime( &RtcHandle, &stimestructure, FORMAT_BIN ) != HAL_OK )
{
Error_Handler();
}
} | [
"void",
"RTC_TimeRegulate",
"(",
"uint8_t",
"hh",
",",
"uint8_t",
"mm",
",",
"uint8_t",
"ss",
")",
"{",
"RTC_TimeTypeDef",
"stimestructure",
";",
"stimestructure",
".",
"TimeFormat",
"=",
"RTC_HOURFORMAT12_AM",
";",
"stimestructure",
".",
"Hours",
"=",
"hh",
";",
"stimestructure",
".",
"Minutes",
"=",
"mm",
";",
"stimestructure",
".",
"Seconds",
"=",
"ss",
";",
"stimestructure",
".",
"SubSeconds",
"=",
"0",
";",
"stimestructure",
".",
"DayLightSaving",
"=",
"RTC_DAYLIGHTSAVING_NONE",
";",
"stimestructure",
".",
"StoreOperation",
"=",
"RTC_STOREOPERATION_RESET",
";",
"if",
"(",
"HAL_RTC_SetTime",
"(",
"&",
"RtcHandle",
",",
"&",
"stimestructure",
",",
"FORMAT_BIN",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}"
] | @brief Configures the current time and date
@param None
@retval None | [
"@brief",
"Configures",
"the",
"current",
"time",
"and",
"date",
"@param",
"None",
"@retval",
"None"
] | [
"/* Initialization Error */"
] | [
{
"param": "hh",
"type": "uint8_t"
},
{
"param": "mm",
"type": "uint8_t"
},
{
"param": "ss",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hh",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mm",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ss",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
82310732b876de15e09d00e7d9947a5a4a4641c5 | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Examples/IKS01A2/LSM6DSL_MultiEvent/Src/main.c | [
"MIT"
] | C | HAL_GPIO_EXTI_Callback | void | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
/* User button. */
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
// Toggle enable/disable HW events (available only for LSM6DSL sensor).
if ( HW_event_enabled != 0 )
{
HW_event_disable_request = 1;
}
else
{
HW_event_enable_request = 1;
}
}
}
/* Hardware event (available only for LSM6DSL sensor). */
else if ( GPIO_Pin == LSM6DSL_INT1_O_PIN || GPIO_Pin == LSM6DSL_INT2_O_PIN )
{
mems_event_detected = 1;
}
} | /**
* @brief EXTI line detection callbacks
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/ | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
if ( BSP_PB_GetState( BUTTON_KEY ) == GPIO_PIN_RESET )
{
if ( HW_event_enabled != 0 )
{
HW_event_disable_request = 1;
}
else
{
HW_event_enable_request = 1;
}
}
}
else if ( GPIO_Pin == LSM6DSL_INT1_O_PIN || GPIO_Pin == LSM6DSL_INT2_O_PIN )
{
mems_event_detected = 1;
}
} | [
"void",
"HAL_GPIO_EXTI_Callback",
"(",
"uint16_t",
"GPIO_Pin",
")",
"{",
"if",
"(",
"GPIO_Pin",
"==",
"KEY_BUTTON_PIN",
")",
"{",
"if",
"(",
"BSP_PB_GetState",
"(",
"BUTTON_KEY",
")",
"==",
"GPIO_PIN_RESET",
")",
"{",
"if",
"(",
"HW_event_enabled",
"!=",
"0",
")",
"{",
"HW_event_disable_request",
"=",
"1",
";",
"}",
"else",
"{",
"HW_event_enable_request",
"=",
"1",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"GPIO_Pin",
"==",
"LSM6DSL_INT1_O_PIN",
"||",
"GPIO_Pin",
"==",
"LSM6DSL_INT2_O_PIN",
")",
"{",
"mems_event_detected",
"=",
"1",
";",
"}",
"}"
] | @brief EXTI line detection callbacks
@param GPIO_Pin: Specifies the pins connected EXTI line
@retval None | [
"@brief",
"EXTI",
"line",
"detection",
"callbacks",
"@param",
"GPIO_Pin",
":",
"Specifies",
"the",
"pins",
"connected",
"EXTI",
"line",
"@retval",
"None"
] | [
"/* User button. */",
"// Toggle enable/disable HW events (available only for LSM6DSL sensor).\r",
"/* Hardware event (available only for LSM6DSL sensor). */"
] | [
{
"param": "GPIO_Pin",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GPIO_Pin",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f53410b52c6c4380f774296e38d44a7def44029a | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/Pedometer/Src/DemoDatalog.c | [
"MIT"
] | C | Datalog_SetAddress | flash_state_t | flash_state_t Datalog_SetAddress(void)
{
uint32_t flash_sector = MOTION_PM_FLASH_ADD;
Address_PM2F += Datalog_SearchNextFreeMemoryIndex(&flash_sector);
if (Address_PM2F > MOTION_PM_FLASH_LESSTHAN2HH)
{
return FLASH_FULL;
}
else
{
return FLASH_READY;
}
} | /**
* @brief Set current data storage address to the first free address in flash memory
* @param None
* @retval Flash memory state (FLASH_FULL/FLASH_READY)
*/ | @brief Set current data storage address to the first free address in flash memory
@param None
@retval Flash memory state (FLASH_FULL/FLASH_READY) | [
"@brief",
"Set",
"current",
"data",
"storage",
"address",
"to",
"the",
"first",
"free",
"address",
"in",
"flash",
"memory",
"@param",
"None",
"@retval",
"Flash",
"memory",
"state",
"(",
"FLASH_FULL",
"/",
"FLASH_READY",
")"
] | flash_state_t Datalog_SetAddress(void)
{
uint32_t flash_sector = MOTION_PM_FLASH_ADD;
Address_PM2F += Datalog_SearchNextFreeMemoryIndex(&flash_sector);
if (Address_PM2F > MOTION_PM_FLASH_LESSTHAN2HH)
{
return FLASH_FULL;
}
else
{
return FLASH_READY;
}
} | [
"flash_state_t",
"Datalog_SetAddress",
"(",
"void",
")",
"{",
"uint32_t",
"flash_sector",
"=",
"MOTION_PM_FLASH_ADD",
";",
"Address_PM2F",
"+=",
"Datalog_SearchNextFreeMemoryIndex",
"(",
"&",
"flash_sector",
")",
";",
"if",
"(",
"Address_PM2F",
">",
"MOTION_PM_FLASH_LESSTHAN2HH",
")",
"{",
"return",
"FLASH_FULL",
";",
"}",
"else",
"{",
"return",
"FLASH_READY",
";",
"}",
"}"
] | @brief Set current data storage address to the first free address in flash memory
@param None
@retval Flash memory state (FLASH_FULL/FLASH_READY) | [
"@brief",
"Set",
"current",
"data",
"storage",
"address",
"to",
"the",
"first",
"free",
"address",
"in",
"flash",
"memory",
"@param",
"None",
"@retval",
"Flash",
"memory",
"state",
"(",
"FLASH_FULL",
"/",
"FLASH_READY",
")"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f53410b52c6c4380f774296e38d44a7def44029a | PPA-Kerhoas-BLE/MeteoStation | STM32CubeExpansion_MEMS1_V4.1.0/Projects/Multi/Applications/Pedometer/Src/DemoDatalog.c | [
"MIT"
] | C | Datalog_SaveData2Mem | null | unsigned char Datalog_SaveData2Mem(uint8_t index_max)
{
#if (defined (USE_STM32F4XX_NUCLEO))
#define SECTOR7_ADD 0x8060000
uint32_t Address = SECTOR7_ADD;
#elif (defined (USE_STM32L4XX_NUCLEO))
uint32_t Address = 0x80FF800;
#else
#error Not supported platform
#endif
unsigned char Success=1;
uint8_t idx;
uint8_t nword;
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
uint32_t* lpdata = 0;
/* Clear pending flags (if any) */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
#elif (defined (USE_STM32L4XX_NUCLEO))
uint64_t* lpdata = 0;
/* Clear pending flags (if any) */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
#else
#error Not supported platform
#endif
for(idx=0; idx < index_max; idx++)
{
#if (defined (USE_STM32F4XX_NUCLEO))
lpdata = (uint32_t*)&DataByte_PM[idx];
#elif (defined (USE_STM32L4XX_NUCLEO))
lpdata = (uint64_t*)&DataByte_PM[idx];
#else
#error Not supported platform
#endif
if (Address_PM2F < (uint32_t)(Address - index_max * sizeof(DataByte_PM_t)))
{
#if (defined (USE_STM32F4XX_NUCLEO))
for (nword = 0; nword < (sizeof(DataByte_PM_t)/4); nword ++)
{
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address_PM2F, *(lpdata + nword)) == HAL_OK)
Address_PM2F += 4;
else
{
/* Error occurred while writing data in Flash memory */
Error_Handler();
}
}
#elif (defined (USE_STM32L4XX_NUCLEO))
for (nword = 0; nword < (sizeof(DataByte_PM_t)/8); nword ++)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address_PM2F, *(lpdata + nword)) == HAL_OK)
Address_PM2F += 8;
else
{
/* Error occurred while writing data in Flash memory */
Error_Handler();
}
}
#else
#error Not supported platform
#endif
}
else
{
Success = 0;
}
}
HAL_FLASH_Lock();
return Success;
} | /**
* @brief Save the data to memory
* @param index_max Index to last data record in buffer
* @retval 1 in case of success, 0 otherwise
*/ | @brief Save the data to memory
@param index_max Index to last data record in buffer
@retval 1 in case of success, 0 otherwise | [
"@brief",
"Save",
"the",
"data",
"to",
"memory",
"@param",
"index_max",
"Index",
"to",
"last",
"data",
"record",
"in",
"buffer",
"@retval",
"1",
"in",
"case",
"of",
"success",
"0",
"otherwise"
] | unsigned char Datalog_SaveData2Mem(uint8_t index_max)
{
#if (defined (USE_STM32F4XX_NUCLEO))
#define SECTOR7_ADD 0x8060000
uint32_t Address = SECTOR7_ADD;
#elif (defined (USE_STM32L4XX_NUCLEO))
uint32_t Address = 0x80FF800;
#else
#error Not supported platform
#endif
unsigned char Success=1;
uint8_t idx;
uint8_t nword;
HAL_FLASH_Unlock();
#if (defined (USE_STM32F4XX_NUCLEO))
uint32_t* lpdata = 0;
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
#elif (defined (USE_STM32L4XX_NUCLEO))
uint64_t* lpdata = 0;
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
#else
#error Not supported platform
#endif
for(idx=0; idx < index_max; idx++)
{
#if (defined (USE_STM32F4XX_NUCLEO))
lpdata = (uint32_t*)&DataByte_PM[idx];
#elif (defined (USE_STM32L4XX_NUCLEO))
lpdata = (uint64_t*)&DataByte_PM[idx];
#else
#error Not supported platform
#endif
if (Address_PM2F < (uint32_t)(Address - index_max * sizeof(DataByte_PM_t)))
{
#if (defined (USE_STM32F4XX_NUCLEO))
for (nword = 0; nword < (sizeof(DataByte_PM_t)/4); nword ++)
{
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address_PM2F, *(lpdata + nword)) == HAL_OK)
Address_PM2F += 4;
else
{
Error_Handler();
}
}
#elif (defined (USE_STM32L4XX_NUCLEO))
for (nword = 0; nword < (sizeof(DataByte_PM_t)/8); nword ++)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address_PM2F, *(lpdata + nword)) == HAL_OK)
Address_PM2F += 8;
else
{
Error_Handler();
}
}
#else
#error Not supported platform
#endif
}
else
{
Success = 0;
}
}
HAL_FLASH_Lock();
return Success;
} | [
"unsigned",
"char",
"Datalog_SaveData2Mem",
"(",
"uint8_t",
"index_max",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"#define",
"SECTOR7_ADD",
" 0x8060000\r",
"\n",
"uint32_t",
"Address",
"=",
"SECTOR7_ADD",
";",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"uint32_t",
"Address",
"=",
"0x80FF800",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"unsigned",
"char",
"Success",
"=",
"1",
";",
"uint8_t",
"idx",
";",
"uint8_t",
"nword",
";",
"HAL_FLASH_Unlock",
"(",
")",
";",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"uint32_t",
"*",
"lpdata",
"=",
"0",
";",
"__HAL_FLASH_CLEAR_FLAG",
"(",
"FLASH_FLAG_EOP",
"|",
"FLASH_FLAG_OPERR",
"|",
"FLASH_FLAG_WRPERR",
"|",
"FLASH_FLAG_PGAERR",
"|",
"FLASH_FLAG_PGPERR",
"|",
"FLASH_FLAG_PGSERR",
")",
";",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"uint64_t",
"*",
"lpdata",
"=",
"0",
";",
"__HAL_FLASH_CLEAR_FLAG",
"(",
"FLASH_FLAG_ALL_ERRORS",
")",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"index_max",
";",
"idx",
"++",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"lpdata",
"=",
"(",
"uint32_t",
"*",
")",
"&",
"DataByte_PM",
"[",
"idx",
"]",
";",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"lpdata",
"=",
"(",
"uint64_t",
"*",
")",
"&",
"DataByte_PM",
"[",
"idx",
"]",
";",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"if",
"(",
"Address_PM2F",
"<",
"(",
"uint32_t",
")",
"(",
"Address",
"-",
"index_max",
"*",
"sizeof",
"(",
"DataByte_PM_t",
")",
")",
")",
"{",
"#if",
"(",
"defined",
"(",
"USE_STM32F4XX_NUCLEO",
")",
")",
"\n",
"for",
"(",
"nword",
"=",
"0",
";",
"nword",
"<",
"(",
"sizeof",
"(",
"DataByte_PM_t",
")",
"/",
"4",
")",
";",
"nword",
"++",
")",
"{",
"if",
"(",
"HAL_FLASH_Program",
"(",
"TYPEPROGRAM_WORD",
",",
"Address_PM2F",
",",
"*",
"(",
"lpdata",
"+",
"nword",
")",
")",
"==",
"HAL_OK",
")",
"Address_PM2F",
"+=",
"4",
";",
"else",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"#elif",
"(",
"defined",
"(",
"USE_STM32L4XX_NUCLEO",
")",
")",
"\n",
"for",
"(",
"nword",
"=",
"0",
";",
"nword",
"<",
"(",
"sizeof",
"(",
"DataByte_PM_t",
")",
"/",
"8",
")",
";",
"nword",
"++",
")",
"{",
"if",
"(",
"HAL_FLASH_Program",
"(",
"FLASH_TYPEPROGRAM_DOUBLEWORD",
",",
"Address_PM2F",
",",
"*",
"(",
"lpdata",
"+",
"nword",
")",
")",
"==",
"HAL_OK",
")",
"Address_PM2F",
"+=",
"8",
";",
"else",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"}",
"#else",
"#error",
" Not supported platform\r",
"\n",
"#endif",
"}",
"else",
"{",
"Success",
"=",
"0",
";",
"}",
"}",
"HAL_FLASH_Lock",
"(",
")",
";",
"return",
"Success",
";",
"}"
] | @brief Save the data to memory
@param index_max Index to last data record in buffer
@retval 1 in case of success, 0 otherwise | [
"@brief",
"Save",
"the",
"data",
"to",
"memory",
"@param",
"index_max",
"Index",
"to",
"last",
"data",
"record",
"in",
"buffer",
"@retval",
"1",
"in",
"case",
"of",
"success",
"0",
"otherwise"
] | [
"/* Clear pending flags (if any) */",
"/* Clear pending flags (if any) */",
"/* Error occurred while writing data in Flash memory */",
"/* Error occurred while writing data in Flash memory */"
] | [
{
"param": "index_max",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "index_max",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24795a2ce7bbd673e5fc28d53538fba28b4f4355 | aeshirey/h3rs | src/testapps/testH3ToLocalIjExhaustive.c | [
"Apache-2.0"
] | C | h3ToLocalIj_neighbors_assertions | void | void h3ToLocalIj_neighbors_assertions(H3Index h3) {
CoordIJ origin = {0};
t_assert(H3_EXPORT(experimentalH3ToLocalIj)(h3, h3, &origin) == 0,
"got ij for origin");
CoordIJK originIjk;
ijToIjk(&origin, &originIjk);
for (Direction d = K_AXES_DIGIT; d < INVALID_DIGIT; d++) {
if (d == K_AXES_DIGIT && H3_EXPORT(h3IsPentagon)(h3)) {
continue;
}
int rotations = 0;
H3Index offset = h3NeighborRotations(h3, d, &rotations);
CoordIJ ij = {0};
t_assert(H3_EXPORT(experimentalH3ToLocalIj)(h3, offset, &ij) == 0,
"got ij for destination");
CoordIJK ijk;
ijToIjk(&ij, &ijk);
CoordIJK invertedIjk = {0};
_neighbor(&invertedIjk, d);
for (int i = 0; i < 3; i++) {
_ijkRotate60ccw(&invertedIjk);
}
_ijkAdd(&invertedIjk, &ijk, &ijk);
_ijkNormalize(&ijk);
t_assert(_ijkMatches(&ijk, &originIjk), "back to origin");
}
} | /**
* Test the the immediate neighbors of an index are at the expected locations in
* the local IJ coordinate space.
*/ | Test the the immediate neighbors of an index are at the expected locations in
the local IJ coordinate space. | [
"Test",
"the",
"the",
"immediate",
"neighbors",
"of",
"an",
"index",
"are",
"at",
"the",
"expected",
"locations",
"in",
"the",
"local",
"IJ",
"coordinate",
"space",
"."
] | void h3ToLocalIj_neighbors_assertions(H3Index h3) {
CoordIJ origin = {0};
t_assert(H3_EXPORT(experimentalH3ToLocalIj)(h3, h3, &origin) == 0,
"got ij for origin");
CoordIJK originIjk;
ijToIjk(&origin, &originIjk);
for (Direction d = K_AXES_DIGIT; d < INVALID_DIGIT; d++) {
if (d == K_AXES_DIGIT && H3_EXPORT(h3IsPentagon)(h3)) {
continue;
}
int rotations = 0;
H3Index offset = h3NeighborRotations(h3, d, &rotations);
CoordIJ ij = {0};
t_assert(H3_EXPORT(experimentalH3ToLocalIj)(h3, offset, &ij) == 0,
"got ij for destination");
CoordIJK ijk;
ijToIjk(&ij, &ijk);
CoordIJK invertedIjk = {0};
_neighbor(&invertedIjk, d);
for (int i = 0; i < 3; i++) {
_ijkRotate60ccw(&invertedIjk);
}
_ijkAdd(&invertedIjk, &ijk, &ijk);
_ijkNormalize(&ijk);
t_assert(_ijkMatches(&ijk, &originIjk), "back to origin");
}
} | [
"void",
"h3ToLocalIj_neighbors_assertions",
"(",
"H3Index",
"h3",
")",
"{",
"CoordIJ",
"origin",
"=",
"{",
"0",
"}",
";",
"t_assert",
"(",
"H3_EXPORT",
"(",
"experimentalH3ToLocalIj",
")",
"(",
"h3",
",",
"h3",
",",
"&",
"origin",
")",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"CoordIJK",
"originIjk",
";",
"ijToIjk",
"(",
"&",
"origin",
",",
"&",
"originIjk",
")",
";",
"for",
"(",
"Direction",
"d",
"=",
"K_AXES_DIGIT",
";",
"d",
"<",
"INVALID_DIGIT",
";",
"d",
"++",
")",
"{",
"if",
"(",
"d",
"==",
"K_AXES_DIGIT",
"&&",
"H3_EXPORT",
"(",
"h3IsPentagon",
")",
"(",
"h3",
")",
")",
"{",
"continue",
";",
"}",
"int",
"rotations",
"=",
"0",
";",
"H3Index",
"offset",
"=",
"h3NeighborRotations",
"(",
"h3",
",",
"d",
",",
"&",
"rotations",
")",
";",
"CoordIJ",
"ij",
"=",
"{",
"0",
"}",
";",
"t_assert",
"(",
"H3_EXPORT",
"(",
"experimentalH3ToLocalIj",
")",
"(",
"h3",
",",
"offset",
",",
"&",
"ij",
")",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"CoordIJK",
"ijk",
";",
"ijToIjk",
"(",
"&",
"ij",
",",
"&",
"ijk",
")",
";",
"CoordIJK",
"invertedIjk",
"=",
"{",
"0",
"}",
";",
"_neighbor",
"(",
"&",
"invertedIjk",
",",
"d",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"_ijkRotate60ccw",
"(",
"&",
"invertedIjk",
")",
";",
"}",
"_ijkAdd",
"(",
"&",
"invertedIjk",
",",
"&",
"ijk",
",",
"&",
"ijk",
")",
";",
"_ijkNormalize",
"(",
"&",
"ijk",
")",
";",
"t_assert",
"(",
"_ijkMatches",
"(",
"&",
"ijk",
",",
"&",
"originIjk",
")",
",",
"\"",
"\"",
")",
";",
"}",
"}"
] | Test the the immediate neighbors of an index are at the expected locations in
the local IJ coordinate space. | [
"Test",
"the",
"the",
"immediate",
"neighbors",
"of",
"an",
"index",
"are",
"at",
"the",
"expected",
"locations",
"in",
"the",
"local",
"IJ",
"coordinate",
"space",
"."
] | [] | [
{
"param": "h3",
"type": "H3Index"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h3",
"type": "H3Index",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24795a2ce7bbd673e5fc28d53538fba28b4f4355 | aeshirey/h3rs | src/testapps/testH3ToLocalIjExhaustive.c | [
"Apache-2.0"
] | C | localIjToH3_kRing_assertions | void | void localIjToH3_kRing_assertions(H3Index h3) {
int r = H3_GET_RESOLUTION(h3);
t_assert(r <= 5, "resolution supported by test function (kRing)");
int maxK = MAX_DISTANCES[r];
int sz = H3_EXPORT(maxKringSize)(maxK);
H3Index *neighbors = calloc(sz, sizeof(H3Index));
int *distances = calloc(sz, sizeof(int));
H3_EXPORT(kRingDistances)(h3, maxK, neighbors, distances);
for (int i = 0; i < sz; i++) {
if (neighbors[i] == 0) {
continue;
}
CoordIJ ij;
// Don't consider indexes which we can't unfold in the first place
if (H3_EXPORT(experimentalH3ToLocalIj)(h3, neighbors[i], &ij) == 0) {
H3Index retrieved;
t_assert(
H3_EXPORT(experimentalLocalIjToH3)(h3, &ij, &retrieved) == 0,
"retrieved index for unfolded coordinates");
t_assert(retrieved == neighbors[i],
"round trip neighboring index matches expected");
}
}
free(distances);
free(neighbors);
} | /**
* Test that the neighbors (k-ring), if they can be found in the local IJ
* coordinate space, can be converted back to indexes.
*/ | Test that the neighbors (k-ring), if they can be found in the local IJ
coordinate space, can be converted back to indexes. | [
"Test",
"that",
"the",
"neighbors",
"(",
"k",
"-",
"ring",
")",
"if",
"they",
"can",
"be",
"found",
"in",
"the",
"local",
"IJ",
"coordinate",
"space",
"can",
"be",
"converted",
"back",
"to",
"indexes",
"."
] | void localIjToH3_kRing_assertions(H3Index h3) {
int r = H3_GET_RESOLUTION(h3);
t_assert(r <= 5, "resolution supported by test function (kRing)");
int maxK = MAX_DISTANCES[r];
int sz = H3_EXPORT(maxKringSize)(maxK);
H3Index *neighbors = calloc(sz, sizeof(H3Index));
int *distances = calloc(sz, sizeof(int));
H3_EXPORT(kRingDistances)(h3, maxK, neighbors, distances);
for (int i = 0; i < sz; i++) {
if (neighbors[i] == 0) {
continue;
}
CoordIJ ij;
if (H3_EXPORT(experimentalH3ToLocalIj)(h3, neighbors[i], &ij) == 0) {
H3Index retrieved;
t_assert(
H3_EXPORT(experimentalLocalIjToH3)(h3, &ij, &retrieved) == 0,
"retrieved index for unfolded coordinates");
t_assert(retrieved == neighbors[i],
"round trip neighboring index matches expected");
}
}
free(distances);
free(neighbors);
} | [
"void",
"localIjToH3_kRing_assertions",
"(",
"H3Index",
"h3",
")",
"{",
"int",
"r",
"=",
"H3_GET_RESOLUTION",
"(",
"h3",
")",
";",
"t_assert",
"(",
"r",
"<=",
"5",
",",
"\"",
"\"",
")",
";",
"int",
"maxK",
"=",
"MAX_DISTANCES",
"[",
"r",
"]",
";",
"int",
"sz",
"=",
"H3_EXPORT",
"(",
"maxKringSize",
")",
"(",
"maxK",
")",
";",
"H3Index",
"*",
"neighbors",
"=",
"calloc",
"(",
"sz",
",",
"sizeof",
"(",
"H3Index",
")",
")",
";",
"int",
"*",
"distances",
"=",
"calloc",
"(",
"sz",
",",
"sizeof",
"(",
"int",
")",
")",
";",
"H3_EXPORT",
"(",
"kRingDistances",
")",
"(",
"h3",
",",
"maxK",
",",
"neighbors",
",",
"distances",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sz",
";",
"i",
"++",
")",
"{",
"if",
"(",
"neighbors",
"[",
"i",
"]",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"CoordIJ",
"ij",
";",
"if",
"(",
"H3_EXPORT",
"(",
"experimentalH3ToLocalIj",
")",
"(",
"h3",
",",
"neighbors",
"[",
"i",
"]",
",",
"&",
"ij",
")",
"==",
"0",
")",
"{",
"H3Index",
"retrieved",
";",
"t_assert",
"(",
"H3_EXPORT",
"(",
"experimentalLocalIjToH3",
")",
"(",
"h3",
",",
"&",
"ij",
",",
"&",
"retrieved",
")",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"t_assert",
"(",
"retrieved",
"==",
"neighbors",
"[",
"i",
"]",
",",
"\"",
"\"",
")",
";",
"}",
"}",
"free",
"(",
"distances",
")",
";",
"free",
"(",
"neighbors",
")",
";",
"}"
] | Test that the neighbors (k-ring), if they can be found in the local IJ
coordinate space, can be converted back to indexes. | [
"Test",
"that",
"the",
"neighbors",
"(",
"k",
"-",
"ring",
")",
"if",
"they",
"can",
"be",
"found",
"in",
"the",
"local",
"IJ",
"coordinate",
"space",
"can",
"be",
"converted",
"back",
"to",
"indexes",
"."
] | [
"// Don't consider indexes which we can't unfold in the first place"
] | [
{
"param": "h3",
"type": "H3Index"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h3",
"type": "H3Index",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9483bda597e4aa05ef09fd9c9b86a6d88160a5d9 | panchyo0/database-sqlite3-C-Python | translate_RDF_into_sqlite3_database_and _/q7pang.c | [
"MIT"
] | C | insert | char | char* insert(char source[],char destination[],int length)
{
char temp[max_length];
char buf[max_length];
unsigned long ln;
int temp2;
char *first_part;
memset(final,0,max_length*sizeof(char));
memset(buf,0,max_length*sizeof(char));
temp2=length;
ln=strlen(source)-length;
for(int i=0;i<=ln;i++){
temp[i]=source[length+1];
length++;
}
for (int i=0; i<=temp2; i++) {
buf[i]=source[i];
}
first_part=strcat(buf,destination);
strcpy(final,strcat(first_part,temp));
return final;
} | //insert destination into source string at position | insert destination into source string at position | [
"insert",
"destination",
"into",
"source",
"string",
"at",
"position"
] | char* insert(char source[],char destination[],int length)
{
char temp[max_length];
char buf[max_length];
unsigned long ln;
int temp2;
char *first_part;
memset(final,0,max_length*sizeof(char));
memset(buf,0,max_length*sizeof(char));
temp2=length;
ln=strlen(source)-length;
for(int i=0;i<=ln;i++){
temp[i]=source[length+1];
length++;
}
for (int i=0; i<=temp2; i++) {
buf[i]=source[i];
}
first_part=strcat(buf,destination);
strcpy(final,strcat(first_part,temp));
return final;
} | [
"char",
"*",
"insert",
"(",
"char",
"source",
"[",
"]",
",",
"char",
"destination",
"[",
"]",
",",
"int",
"length",
")",
"{",
"char",
"temp",
"[",
"max_length",
"]",
";",
"char",
"buf",
"[",
"max_length",
"]",
";",
"unsigned",
"long",
"ln",
";",
"int",
"temp2",
";",
"char",
"*",
"first_part",
";",
"memset",
"(",
"final",
",",
"0",
",",
"max_length",
"*",
"sizeof",
"(",
"char",
")",
")",
";",
"memset",
"(",
"buf",
",",
"0",
",",
"max_length",
"*",
"sizeof",
"(",
"char",
")",
")",
";",
"temp2",
"=",
"length",
";",
"ln",
"=",
"strlen",
"(",
"source",
")",
"-",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"ln",
";",
"i",
"++",
")",
"{",
"temp",
"[",
"i",
"]",
"=",
"source",
"[",
"length",
"+",
"1",
"]",
";",
"length",
"++",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"temp2",
";",
"i",
"++",
")",
"{",
"buf",
"[",
"i",
"]",
"=",
"source",
"[",
"i",
"]",
";",
"}",
"first_part",
"=",
"strcat",
"(",
"buf",
",",
"destination",
")",
";",
"strcpy",
"(",
"final",
",",
"strcat",
"(",
"first_part",
",",
"temp",
")",
")",
";",
"return",
"final",
";",
"}"
] | insert destination into source string at position | [
"insert",
"destination",
"into",
"source",
"string",
"at",
"position"
] | [] | [
{
"param": "source",
"type": "char"
},
{
"param": "destination",
"type": "char"
},
{
"param": "length",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "destination",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9483bda597e4aa05ef09fd9c9b86a6d88160a5d9 | panchyo0/database-sqlite3-C-Python | translate_RDF_into_sqlite3_database_and _/q7pang.c | [
"MIT"
] | C | StringFind | int | int StringFind(const char *pSrc, const char *pDst)
{
int i, j;
for (i=0; pSrc[i]!='\0'; i++)
{
if(pSrc[i]!=pDst[0])
continue;
j = 0;
while(pDst[j]!='\0' && pSrc[i+j]!='\0')
{
j++;
if(pDst[j]!=pSrc[i+j])
break;
}
if(pDst[j]=='\0')
return i;
}
return -1;
} | //find string in string, return the first start location or -1 if can not find | find string in string, return the first start location or -1 if can not find | [
"find",
"string",
"in",
"string",
"return",
"the",
"first",
"start",
"location",
"or",
"-",
"1",
"if",
"can",
"not",
"find"
] | int StringFind(const char *pSrc, const char *pDst)
{
int i, j;
for (i=0; pSrc[i]!='\0'; i++)
{
if(pSrc[i]!=pDst[0])
continue;
j = 0;
while(pDst[j]!='\0' && pSrc[i+j]!='\0')
{
j++;
if(pDst[j]!=pSrc[i+j])
break;
}
if(pDst[j]=='\0')
return i;
}
return -1;
} | [
"int",
"StringFind",
"(",
"const",
"char",
"*",
"pSrc",
",",
"const",
"char",
"*",
"pDst",
")",
"{",
"int",
"i",
",",
"j",
";",
"for",
"(",
"i",
"=",
"0",
";",
"pSrc",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pSrc",
"[",
"i",
"]",
"!=",
"pDst",
"[",
"0",
"]",
")",
"continue",
";",
"j",
"=",
"0",
";",
"while",
"(",
"pDst",
"[",
"j",
"]",
"!=",
"'",
"\\0",
"'",
"&&",
"pSrc",
"[",
"i",
"+",
"j",
"]",
"!=",
"'",
"\\0",
"'",
")",
"{",
"j",
"++",
";",
"if",
"(",
"pDst",
"[",
"j",
"]",
"!=",
"pSrc",
"[",
"i",
"+",
"j",
"]",
")",
"break",
";",
"}",
"if",
"(",
"pDst",
"[",
"j",
"]",
"==",
"'",
"\\0",
"'",
")",
"return",
"i",
";",
"}",
"return",
"-1",
";",
"}"
] | find string in string, return the first start location or -1 if can not find | [
"find",
"string",
"in",
"string",
"return",
"the",
"first",
"start",
"location",
"or",
"-",
"1",
"if",
"can",
"not",
"find"
] | [] | [
{
"param": "pSrc",
"type": "char"
},
{
"param": "pDst",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pSrc",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pDst",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
88da45e10f8aba49d4bda9487049af8eaed82718 | HideoYamauchi/corosync | exec/logsys.c | [
"BSD-3-Clause"
] | C | logsys_config_file_set_unlocked | int | static int logsys_config_file_set_unlocked (
int subsysid,
const char **error_string,
const char *file)
{
static char error_string_response[512];
int i;
char file_format[128];
if (logsys_loggers[subsysid].target_id > 0) {
int32_t f;
for (f = 0; f < logsys_loggers[subsysid].file_idx; f++) {
qb_log_filter_ctl(logsys_loggers[subsysid].target_id,
QB_LOG_FILTER_REMOVE,
QB_LOG_FILTER_FILE,
logsys_loggers[subsysid].files[f],
LOG_TRACE);
}
}
logsys_loggers[subsysid].dirty = QB_TRUE;
if (file == NULL) {
return (0);
}
if (logsys_loggers[subsysid].target_id > 0 &&
logsys_loggers[subsysid].logfile != NULL &&
strcmp(file, logsys_loggers[subsysid].logfile) == 0) {
return (0);
}
if (strlen(file) >= PATH_MAX) {
snprintf (error_string_response,
sizeof(error_string_response),
"%s: logfile name exceed maximum system filename length",
logsys_loggers[subsysid].subsys);
*error_string = error_string_response;
return (-1);
}
if (logsys_loggers[subsysid].logfile != NULL) {
free(logsys_loggers[subsysid].logfile);
logsys_loggers[subsysid].logfile = NULL;
}
logsys_loggers[subsysid].logfile = strdup(file);
if (logsys_loggers[subsysid].logfile == NULL) {
snprintf (error_string_response,
sizeof(error_string_response),
"Unable to allocate memory for logfile '%s'",
file);
*error_string = error_string_response;
return (-1);
}
for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
if ((logsys_loggers[i].logfile != NULL) &&
(strcmp (logsys_loggers[i].logfile, file) == 0) &&
(i != subsysid)) {
/* we have found another subsys with this config file
* so add a filter
*/
logsys_loggers[subsysid].target_id = logsys_loggers[i].target_id;
return (0);
}
}
if (logsys_loggers[subsysid].target_id > 0) {
int num_using_current = 0;
for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
if (logsys_loggers[subsysid].target_id ==
logsys_loggers[i].target_id) {
num_using_current++;
}
}
if (num_using_current == 1) {
/* no one else is using this close it */
qb_log_file_close(logsys_loggers[subsysid].target_id);
}
}
logsys_loggers[subsysid].target_id = qb_log_file_open(file);
if (logsys_loggers[subsysid].target_id < 0) {
int err = -logsys_loggers[subsysid].target_id;
char error_str[LOGSYS_MAX_PERROR_MSG_LEN];
const char *error_ptr;
error_ptr = qb_strerror_r(err, error_str, sizeof(error_str));
free(logsys_loggers[subsysid].logfile);
logsys_loggers[subsysid].logfile = NULL;
snprintf (error_string_response,
sizeof(error_string_response),
"Can't open logfile '%s' for reason: %s (%d)",
file, error_ptr, err);
*error_string = error_string_response;
return (-1);
}
logsys_file_format_get(file_format, 128);
qb_log_format_set(logsys_loggers[subsysid].target_id, file_format);
qb_log_ctl(logsys_loggers[subsysid].target_id,
QB_LOG_CONF_ENABLED,
(logsys_loggers[subsysid].mode & LOGSYS_MODE_OUTPUT_FILE));
if (logsys_thread_started) {
qb_log_ctl(logsys_loggers[subsysid].target_id, QB_LOG_CONF_THREADED, QB_TRUE);
}
return (0);
} | /*
* we need a version that can work when somebody else is already
* holding a config mutex lock or we will never get out of here
*/ | we need a version that can work when somebody else is already
holding a config mutex lock or we will never get out of here | [
"we",
"need",
"a",
"version",
"that",
"can",
"work",
"when",
"somebody",
"else",
"is",
"already",
"holding",
"a",
"config",
"mutex",
"lock",
"or",
"we",
"will",
"never",
"get",
"out",
"of",
"here"
] | static int logsys_config_file_set_unlocked (
int subsysid,
const char **error_string,
const char *file)
{
static char error_string_response[512];
int i;
char file_format[128];
if (logsys_loggers[subsysid].target_id > 0) {
int32_t f;
for (f = 0; f < logsys_loggers[subsysid].file_idx; f++) {
qb_log_filter_ctl(logsys_loggers[subsysid].target_id,
QB_LOG_FILTER_REMOVE,
QB_LOG_FILTER_FILE,
logsys_loggers[subsysid].files[f],
LOG_TRACE);
}
}
logsys_loggers[subsysid].dirty = QB_TRUE;
if (file == NULL) {
return (0);
}
if (logsys_loggers[subsysid].target_id > 0 &&
logsys_loggers[subsysid].logfile != NULL &&
strcmp(file, logsys_loggers[subsysid].logfile) == 0) {
return (0);
}
if (strlen(file) >= PATH_MAX) {
snprintf (error_string_response,
sizeof(error_string_response),
"%s: logfile name exceed maximum system filename length",
logsys_loggers[subsysid].subsys);
*error_string = error_string_response;
return (-1);
}
if (logsys_loggers[subsysid].logfile != NULL) {
free(logsys_loggers[subsysid].logfile);
logsys_loggers[subsysid].logfile = NULL;
}
logsys_loggers[subsysid].logfile = strdup(file);
if (logsys_loggers[subsysid].logfile == NULL) {
snprintf (error_string_response,
sizeof(error_string_response),
"Unable to allocate memory for logfile '%s'",
file);
*error_string = error_string_response;
return (-1);
}
for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
if ((logsys_loggers[i].logfile != NULL) &&
(strcmp (logsys_loggers[i].logfile, file) == 0) &&
(i != subsysid)) {
logsys_loggers[subsysid].target_id = logsys_loggers[i].target_id;
return (0);
}
}
if (logsys_loggers[subsysid].target_id > 0) {
int num_using_current = 0;
for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
if (logsys_loggers[subsysid].target_id ==
logsys_loggers[i].target_id) {
num_using_current++;
}
}
if (num_using_current == 1) {
qb_log_file_close(logsys_loggers[subsysid].target_id);
}
}
logsys_loggers[subsysid].target_id = qb_log_file_open(file);
if (logsys_loggers[subsysid].target_id < 0) {
int err = -logsys_loggers[subsysid].target_id;
char error_str[LOGSYS_MAX_PERROR_MSG_LEN];
const char *error_ptr;
error_ptr = qb_strerror_r(err, error_str, sizeof(error_str));
free(logsys_loggers[subsysid].logfile);
logsys_loggers[subsysid].logfile = NULL;
snprintf (error_string_response,
sizeof(error_string_response),
"Can't open logfile '%s' for reason: %s (%d)",
file, error_ptr, err);
*error_string = error_string_response;
return (-1);
}
logsys_file_format_get(file_format, 128);
qb_log_format_set(logsys_loggers[subsysid].target_id, file_format);
qb_log_ctl(logsys_loggers[subsysid].target_id,
QB_LOG_CONF_ENABLED,
(logsys_loggers[subsysid].mode & LOGSYS_MODE_OUTPUT_FILE));
if (logsys_thread_started) {
qb_log_ctl(logsys_loggers[subsysid].target_id, QB_LOG_CONF_THREADED, QB_TRUE);
}
return (0);
} | [
"static",
"int",
"logsys_config_file_set_unlocked",
"(",
"int",
"subsysid",
",",
"const",
"char",
"*",
"*",
"error_string",
",",
"const",
"char",
"*",
"file",
")",
"{",
"static",
"char",
"error_string_response",
"[",
"512",
"]",
";",
"int",
"i",
";",
"char",
"file_format",
"[",
"128",
"]",
";",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
">",
"0",
")",
"{",
"int32_t",
"f",
";",
"for",
"(",
"f",
"=",
"0",
";",
"f",
"<",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"file_idx",
";",
"f",
"++",
")",
"{",
"qb_log_filter_ctl",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
",",
"QB_LOG_FILTER_REMOVE",
",",
"QB_LOG_FILTER_FILE",
",",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"files",
"[",
"f",
"]",
",",
"LOG_TRACE",
")",
";",
"}",
"}",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"dirty",
"=",
"QB_TRUE",
";",
"if",
"(",
"file",
"==",
"NULL",
")",
"{",
"return",
"(",
"0",
")",
";",
"}",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
">",
"0",
"&&",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"!=",
"NULL",
"&&",
"strcmp",
"(",
"file",
",",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
")",
"==",
"0",
")",
"{",
"return",
"(",
"0",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"file",
")",
">=",
"PATH_MAX",
")",
"{",
"snprintf",
"(",
"error_string_response",
",",
"sizeof",
"(",
"error_string_response",
")",
",",
"\"",
"\"",
",",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"subsys",
")",
";",
"*",
"error_string",
"=",
"error_string_response",
";",
"return",
"(",
"-1",
")",
";",
"}",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"!=",
"NULL",
")",
"{",
"free",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
")",
";",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"=",
"NULL",
";",
"}",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"=",
"strdup",
"(",
"file",
")",
";",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"==",
"NULL",
")",
"{",
"snprintf",
"(",
"error_string_response",
",",
"sizeof",
"(",
"error_string_response",
")",
",",
"\"",
"\"",
",",
"file",
")",
";",
"*",
"error_string",
"=",
"error_string_response",
";",
"return",
"(",
"-1",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<=",
"LOGSYS_MAX_SUBSYS_COUNT",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"logsys_loggers",
"[",
"i",
"]",
".",
"logfile",
"!=",
"NULL",
")",
"&&",
"(",
"strcmp",
"(",
"logsys_loggers",
"[",
"i",
"]",
".",
"logfile",
",",
"file",
")",
"==",
"0",
")",
"&&",
"(",
"i",
"!=",
"subsysid",
")",
")",
"{",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
"=",
"logsys_loggers",
"[",
"i",
"]",
".",
"target_id",
";",
"return",
"(",
"0",
")",
";",
"}",
"}",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
">",
"0",
")",
"{",
"int",
"num_using_current",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<=",
"LOGSYS_MAX_SUBSYS_COUNT",
";",
"i",
"++",
")",
"{",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
"==",
"logsys_loggers",
"[",
"i",
"]",
".",
"target_id",
")",
"{",
"num_using_current",
"++",
";",
"}",
"}",
"if",
"(",
"num_using_current",
"==",
"1",
")",
"{",
"qb_log_file_close",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
")",
";",
"}",
"}",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
"=",
"qb_log_file_open",
"(",
"file",
")",
";",
"if",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
"<",
"0",
")",
"{",
"int",
"err",
"=",
"-",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
";",
"char",
"error_str",
"[",
"LOGSYS_MAX_PERROR_MSG_LEN",
"]",
";",
"const",
"char",
"*",
"error_ptr",
";",
"error_ptr",
"=",
"qb_strerror_r",
"(",
"err",
",",
"error_str",
",",
"sizeof",
"(",
"error_str",
")",
")",
";",
"free",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
")",
";",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"logfile",
"=",
"NULL",
";",
"snprintf",
"(",
"error_string_response",
",",
"sizeof",
"(",
"error_string_response",
")",
",",
"\"",
"\"",
",",
"file",
",",
"error_ptr",
",",
"err",
")",
";",
"*",
"error_string",
"=",
"error_string_response",
";",
"return",
"(",
"-1",
")",
";",
"}",
"logsys_file_format_get",
"(",
"file_format",
",",
"128",
")",
";",
"qb_log_format_set",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
",",
"file_format",
")",
";",
"qb_log_ctl",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
",",
"QB_LOG_CONF_ENABLED",
",",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"mode",
"&",
"LOGSYS_MODE_OUTPUT_FILE",
")",
")",
";",
"if",
"(",
"logsys_thread_started",
")",
"{",
"qb_log_ctl",
"(",
"logsys_loggers",
"[",
"subsysid",
"]",
".",
"target_id",
",",
"QB_LOG_CONF_THREADED",
",",
"QB_TRUE",
")",
";",
"}",
"return",
"(",
"0",
")",
";",
"}"
] | we need a version that can work when somebody else is already
holding a config mutex lock or we will never get out of here | [
"we",
"need",
"a",
"version",
"that",
"can",
"work",
"when",
"somebody",
"else",
"is",
"already",
"holding",
"a",
"config",
"mutex",
"lock",
"or",
"we",
"will",
"never",
"get",
"out",
"of",
"here"
] | [
"/* we have found another subsys with this config file\n\t\t\t * so add a filter\n\t\t\t */",
"/* no one else is using this close it */"
] | [
{
"param": "subsysid",
"type": "int"
},
{
"param": "error_string",
"type": "char"
},
{
"param": "file",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "subsysid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "error_string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
88da45e10f8aba49d4bda9487049af8eaed82718 | HideoYamauchi/corosync | exec/logsys.c | [
"BSD-3-Clause"
] | C | logsys_blackbox_prefork | void | void logsys_blackbox_prefork(void)
{
(void)qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE);
} | /*
* To set correct pid to qb blackbox filename after tty dettach (fork) we have to
* close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function).
*/ | To set correct pid to qb blackbox filename after tty dettach (fork) we have to
close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function). | [
"To",
"set",
"correct",
"pid",
"to",
"qb",
"blackbox",
"filename",
"after",
"tty",
"dettach",
"(",
"fork",
")",
"we",
"have",
"to",
"close",
"(",
"this",
"function",
")",
"and",
"(",
"if",
"needed",
")",
"reopen",
"blackbox",
"(",
"logsys_blackbox_postfork",
"function",
")",
"."
] | void logsys_blackbox_prefork(void)
{
(void)qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE);
} | [
"void",
"logsys_blackbox_prefork",
"(",
"void",
")",
"{",
"(",
"void",
")",
"qb_log_ctl",
"(",
"QB_LOG_BLACKBOX",
",",
"QB_LOG_CONF_ENABLED",
",",
"QB_FALSE",
")",
";",
"}"
] | To set correct pid to qb blackbox filename after tty dettach (fork) we have to
close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function). | [
"To",
"set",
"correct",
"pid",
"to",
"qb",
"blackbox",
"filename",
"after",
"tty",
"dettach",
"(",
"fork",
")",
"we",
"have",
"to",
"close",
"(",
"this",
"function",
")",
"and",
"(",
"if",
"needed",
")",
"reopen",
"blackbox",
"(",
"logsys_blackbox_postfork",
"function",
")",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a24843238b53d76f783dcf3e5acb3f7fac72bcaf | HideoYamauchi/corosync | exec/totempg.c | [
"BSD-3-Clause"
] | C | totempg_initialize | int | int totempg_initialize (
qb_loop_t *poll_handle,
struct totem_config *totem_config)
{
int res;
totempg_totem_config = totem_config;
totempg_log_level_security = totem_config->totem_logging_configuration.log_level_security;
totempg_log_level_error = totem_config->totem_logging_configuration.log_level_error;
totempg_log_level_warning = totem_config->totem_logging_configuration.log_level_warning;
totempg_log_level_notice = totem_config->totem_logging_configuration.log_level_notice;
totempg_log_level_debug = totem_config->totem_logging_configuration.log_level_debug;
totempg_log_printf = totem_config->totem_logging_configuration.log_printf;
totempg_subsys_id = totem_config->totem_logging_configuration.log_subsys_id;
fragmentation_data = malloc (TOTEMPG_PACKET_SIZE);
if (fragmentation_data == 0) {
return (-1);
}
totemsrp_net_mtu_adjust (totem_config);
res = totemsrp_initialize (
poll_handle,
&totemsrp_context,
totem_config,
&totempg_stats,
totempg_deliver_fn,
totempg_confchg_fn,
totempg_waiting_trans_ack_cb);
if (res == -1) {
goto error_exit;
}
totemsrp_callback_token_create (
totemsrp_context,
&callback_token_received_handle,
TOTEM_CALLBACK_TOKEN_RECEIVED,
0,
callback_token_received_fn,
0);
totempg_size_limit = (totemsrp_avail(totemsrp_context) - 1) *
(totempg_totem_config->net_mtu -
sizeof (struct totempg_mcast) - 16);
qb_list_init (&totempg_groups_list);
error_exit:
return (res);
} | /*
* Initialize the totem process group abstraction
*/ | Initialize the totem process group abstraction | [
"Initialize",
"the",
"totem",
"process",
"group",
"abstraction"
] | int totempg_initialize (
qb_loop_t *poll_handle,
struct totem_config *totem_config)
{
int res;
totempg_totem_config = totem_config;
totempg_log_level_security = totem_config->totem_logging_configuration.log_level_security;
totempg_log_level_error = totem_config->totem_logging_configuration.log_level_error;
totempg_log_level_warning = totem_config->totem_logging_configuration.log_level_warning;
totempg_log_level_notice = totem_config->totem_logging_configuration.log_level_notice;
totempg_log_level_debug = totem_config->totem_logging_configuration.log_level_debug;
totempg_log_printf = totem_config->totem_logging_configuration.log_printf;
totempg_subsys_id = totem_config->totem_logging_configuration.log_subsys_id;
fragmentation_data = malloc (TOTEMPG_PACKET_SIZE);
if (fragmentation_data == 0) {
return (-1);
}
totemsrp_net_mtu_adjust (totem_config);
res = totemsrp_initialize (
poll_handle,
&totemsrp_context,
totem_config,
&totempg_stats,
totempg_deliver_fn,
totempg_confchg_fn,
totempg_waiting_trans_ack_cb);
if (res == -1) {
goto error_exit;
}
totemsrp_callback_token_create (
totemsrp_context,
&callback_token_received_handle,
TOTEM_CALLBACK_TOKEN_RECEIVED,
0,
callback_token_received_fn,
0);
totempg_size_limit = (totemsrp_avail(totemsrp_context) - 1) *
(totempg_totem_config->net_mtu -
sizeof (struct totempg_mcast) - 16);
qb_list_init (&totempg_groups_list);
error_exit:
return (res);
} | [
"int",
"totempg_initialize",
"(",
"qb_loop_t",
"*",
"poll_handle",
",",
"struct",
"totem_config",
"*",
"totem_config",
")",
"{",
"int",
"res",
";",
"totempg_totem_config",
"=",
"totem_config",
";",
"totempg_log_level_security",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_level_security",
";",
"totempg_log_level_error",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_level_error",
";",
"totempg_log_level_warning",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_level_warning",
";",
"totempg_log_level_notice",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_level_notice",
";",
"totempg_log_level_debug",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_level_debug",
";",
"totempg_log_printf",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_printf",
";",
"totempg_subsys_id",
"=",
"totem_config",
"->",
"totem_logging_configuration",
".",
"log_subsys_id",
";",
"fragmentation_data",
"=",
"malloc",
"(",
"TOTEMPG_PACKET_SIZE",
")",
";",
"if",
"(",
"fragmentation_data",
"==",
"0",
")",
"{",
"return",
"(",
"-1",
")",
";",
"}",
"totemsrp_net_mtu_adjust",
"(",
"totem_config",
")",
";",
"res",
"=",
"totemsrp_initialize",
"(",
"poll_handle",
",",
"&",
"totemsrp_context",
",",
"totem_config",
",",
"&",
"totempg_stats",
",",
"totempg_deliver_fn",
",",
"totempg_confchg_fn",
",",
"totempg_waiting_trans_ack_cb",
")",
";",
"if",
"(",
"res",
"==",
"-1",
")",
"{",
"goto",
"error_exit",
";",
"}",
"totemsrp_callback_token_create",
"(",
"totemsrp_context",
",",
"&",
"callback_token_received_handle",
",",
"TOTEM_CALLBACK_TOKEN_RECEIVED",
",",
"0",
",",
"callback_token_received_fn",
",",
"0",
")",
";",
"totempg_size_limit",
"=",
"(",
"totemsrp_avail",
"(",
"totemsrp_context",
")",
"-",
"1",
")",
"*",
"(",
"totempg_totem_config",
"->",
"net_mtu",
"-",
"sizeof",
"(",
"struct",
"totempg_mcast",
")",
"-",
"16",
")",
";",
"qb_list_init",
"(",
"&",
"totempg_groups_list",
")",
";",
"error_exit",
":",
"return",
"(",
"res",
")",
";",
"}"
] | Initialize the totem process group abstraction | [
"Initialize",
"the",
"totem",
"process",
"group",
"abstraction"
] | [] | [
{
"param": "poll_handle",
"type": "qb_loop_t"
},
{
"param": "totem_config",
"type": "struct totem_config"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "poll_handle",
"type": "qb_loop_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totem_config",
"type": "struct totem_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a24843238b53d76f783dcf3e5acb3f7fac72bcaf | HideoYamauchi/corosync | exec/totempg.c | [
"BSD-3-Clause"
] | C | msg_count_send_ok | int | static int msg_count_send_ok (
int msg_count)
{
int avail = 0;
avail = totemsrp_avail (totemsrp_context);
totempg_stats.msg_queue_avail = avail;
return ((avail - totempg_reserved) > msg_count);
} | /*
* Determine if a message of msg_size could be queued
*/ | Determine if a message of msg_size could be queued | [
"Determine",
"if",
"a",
"message",
"of",
"msg_size",
"could",
"be",
"queued"
] | static int msg_count_send_ok (
int msg_count)
{
int avail = 0;
avail = totemsrp_avail (totemsrp_context);
totempg_stats.msg_queue_avail = avail;
return ((avail - totempg_reserved) > msg_count);
} | [
"static",
"int",
"msg_count_send_ok",
"(",
"int",
"msg_count",
")",
"{",
"int",
"avail",
"=",
"0",
";",
"avail",
"=",
"totemsrp_avail",
"(",
"totemsrp_context",
")",
";",
"totempg_stats",
".",
"msg_queue_avail",
"=",
"avail",
";",
"return",
"(",
"(",
"avail",
"-",
"totempg_reserved",
")",
">",
"msg_count",
")",
";",
"}"
] | Determine if a message of msg_size could be queued | [
"Determine",
"if",
"a",
"message",
"of",
"msg_size",
"could",
"be",
"queued"
] | [] | [
{
"param": "msg_count",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "msg_count",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a24843238b53d76f783dcf3e5acb3f7fac72bcaf | HideoYamauchi/corosync | exec/totempg.c | [
"BSD-3-Clause"
] | C | totempg_groups_send_ok_groups | int | int totempg_groups_send_ok_groups (
void *totempg_groups_instance,
const struct totempg_group *groups,
size_t groups_cnt,
const struct iovec *iovec,
unsigned int iov_len)
{
unsigned int size = 0;
unsigned int i;
unsigned int res;
if (totempg_threaded_mode == 1) {
pthread_mutex_lock (&totempg_mutex);
}
for (i = 0; i < groups_cnt; i++) {
size += groups[i].group_len;
}
for (i = 0; i < iov_len; i++) {
size += iovec[i].iov_len;
}
res = msg_count_send_ok (size);
if (totempg_threaded_mode == 1) {
pthread_mutex_unlock (&totempg_mutex);
}
return (res);
} | /*
* Returns -1 if error, 0 if can't send, 1 if can send the message
*/ | 1 if error, 0 if can't send, 1 if can send the message | [
"1",
"if",
"error",
"0",
"if",
"can",
"'",
"t",
"send",
"1",
"if",
"can",
"send",
"the",
"message"
] | int totempg_groups_send_ok_groups (
void *totempg_groups_instance,
const struct totempg_group *groups,
size_t groups_cnt,
const struct iovec *iovec,
unsigned int iov_len)
{
unsigned int size = 0;
unsigned int i;
unsigned int res;
if (totempg_threaded_mode == 1) {
pthread_mutex_lock (&totempg_mutex);
}
for (i = 0; i < groups_cnt; i++) {
size += groups[i].group_len;
}
for (i = 0; i < iov_len; i++) {
size += iovec[i].iov_len;
}
res = msg_count_send_ok (size);
if (totempg_threaded_mode == 1) {
pthread_mutex_unlock (&totempg_mutex);
}
return (res);
} | [
"int",
"totempg_groups_send_ok_groups",
"(",
"void",
"*",
"totempg_groups_instance",
",",
"const",
"struct",
"totempg_group",
"*",
"groups",
",",
"size_t",
"groups_cnt",
",",
"const",
"struct",
"iovec",
"*",
"iovec",
",",
"unsigned",
"int",
"iov_len",
")",
"{",
"unsigned",
"int",
"size",
"=",
"0",
";",
"unsigned",
"int",
"i",
";",
"unsigned",
"int",
"res",
";",
"if",
"(",
"totempg_threaded_mode",
"==",
"1",
")",
"{",
"pthread_mutex_lock",
"(",
"&",
"totempg_mutex",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"groups_cnt",
";",
"i",
"++",
")",
"{",
"size",
"+=",
"groups",
"[",
"i",
"]",
".",
"group_len",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"iov_len",
";",
"i",
"++",
")",
"{",
"size",
"+=",
"iovec",
"[",
"i",
"]",
".",
"iov_len",
";",
"}",
"res",
"=",
"msg_count_send_ok",
"(",
"size",
")",
";",
"if",
"(",
"totempg_threaded_mode",
"==",
"1",
")",
"{",
"pthread_mutex_unlock",
"(",
"&",
"totempg_mutex",
")",
";",
"}",
"return",
"(",
"res",
")",
";",
"}"
] | Returns -1 if error, 0 if can't send, 1 if can send the message | [
"Returns",
"-",
"1",
"if",
"error",
"0",
"if",
"can",
"'",
"t",
"send",
"1",
"if",
"can",
"send",
"the",
"message"
] | [] | [
{
"param": "totempg_groups_instance",
"type": "void"
},
{
"param": "groups",
"type": "struct totempg_group"
},
{
"param": "groups_cnt",
"type": "size_t"
},
{
"param": "iovec",
"type": "struct iovec"
},
{
"param": "iov_len",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "totempg_groups_instance",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "groups",
"type": "struct totempg_group",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "groups_cnt",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iovec",
"type": "struct iovec",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iov_len",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0782c01868bb4ca40ba3e015db7d126d924d54fe | HideoYamauchi/corosync | exec/totemknet.c | [
"BSD-3-Clause"
] | C | run_nozzle_script | void | static void run_nozzle_script(struct totemknet_instance *instance, int type, const char *typename)
{
int res;
char *exec_string;
res = nozzle_run_updown(instance->nozzle_handle, type, &exec_string);
if (res == -1 && errno != ENOENT) {
knet_log_printf (LOGSYS_LEVEL_INFO, "exec nozzle %s script failed: %s", typename, strerror(errno));
} else if (res == -2) {
knet_log_printf (LOGSYS_LEVEL_INFO, "nozzle %s script failed", typename);
knet_log_printf (LOGSYS_LEVEL_INFO, "%s", exec_string);
}
} | /*
* Deliberately doesn't return the status as caller doesn't care.
* The result will be logged though
*/ | Deliberately doesn't return the status as caller doesn't care.
The result will be logged though | [
"Deliberately",
"doesn",
"'",
"t",
"return",
"the",
"status",
"as",
"caller",
"doesn",
"'",
"t",
"care",
".",
"The",
"result",
"will",
"be",
"logged",
"though"
] | static void run_nozzle_script(struct totemknet_instance *instance, int type, const char *typename)
{
int res;
char *exec_string;
res = nozzle_run_updown(instance->nozzle_handle, type, &exec_string);
if (res == -1 && errno != ENOENT) {
knet_log_printf (LOGSYS_LEVEL_INFO, "exec nozzle %s script failed: %s", typename, strerror(errno));
} else if (res == -2) {
knet_log_printf (LOGSYS_LEVEL_INFO, "nozzle %s script failed", typename);
knet_log_printf (LOGSYS_LEVEL_INFO, "%s", exec_string);
}
} | [
"static",
"void",
"run_nozzle_script",
"(",
"struct",
"totemknet_instance",
"*",
"instance",
",",
"int",
"type",
",",
"const",
"char",
"*",
"typename",
")",
"{",
"int",
"res",
";",
"char",
"*",
"exec_string",
";",
"res",
"=",
"nozzle_run_updown",
"(",
"instance",
"->",
"nozzle_handle",
",",
"type",
",",
"&",
"exec_string",
")",
";",
"if",
"(",
"res",
"==",
"-1",
"&&",
"errno",
"!=",
"ENOENT",
")",
"{",
"knet_log_printf",
"(",
"LOGSYS_LEVEL_INFO",
",",
"\"",
"\"",
",",
"typename",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"}",
"else",
"if",
"(",
"res",
"==",
"-2",
")",
"{",
"knet_log_printf",
"(",
"LOGSYS_LEVEL_INFO",
",",
"\"",
"\"",
",",
"typename",
")",
";",
"knet_log_printf",
"(",
"LOGSYS_LEVEL_INFO",
",",
"\"",
"\"",
",",
"exec_string",
")",
";",
"}",
"}"
] | Deliberately doesn't return the status as caller doesn't care. | [
"Deliberately",
"doesn",
"'",
"t",
"return",
"the",
"status",
"as",
"caller",
"doesn",
"'",
"t",
"care",
"."
] | [] | [
{
"param": "instance",
"type": "struct totemknet_instance"
},
{
"param": "type",
"type": "int"
},
{
"param": "typename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "instance",
"type": "struct totemknet_instance",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "type",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "typename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0782c01868bb4ca40ba3e015db7d126d924d54fe | HideoYamauchi/corosync | exec/totemknet.c | [
"BSD-3-Clause"
] | C | reparse_nozzle_ip_address | int | static int reparse_nozzle_ip_address(struct totemknet_instance *instance,
const char *input_addr,
const char *prefix, int nodeid,
char *output_addr, size_t output_len)
{
char *coloncolon;
int bits;
int max_prefix = 64;
uint32_t nodeid_mask;
uint32_t addr_mask;
uint32_t masked_nodeid;
struct in_addr *addr;
struct totem_ip_address totemip;
coloncolon = strstr(input_addr, "::");
if (!coloncolon) {
max_prefix = 30;
}
bits = atoi(prefix);
if (bits < 8 || bits > max_prefix) {
knet_log_printf(LOGSYS_LEVEL_ERROR, "nozzle IP address prefix must be >= 8 and <= %d (got %d)", max_prefix, bits);
return -1;
}
/* IPv6 is easy */
if (coloncolon) {
memcpy(output_addr, input_addr, coloncolon-input_addr);
sprintf(output_addr + (coloncolon-input_addr), "::%x", nodeid);
return 0;
}
/* For IPv4 we need to parse the address into binary, mask off the required bits,
* add in the masked_nodeid and 'print' it out again
*/
nodeid_mask = UINT32_MAX & ((1<<(32 - bits)) - 1);
addr_mask = UINT32_MAX ^ nodeid_mask;
masked_nodeid = nodeid & nodeid_mask;
if (totemip_parse(&totemip, input_addr, AF_INET)) {
knet_log_printf(LOGSYS_LEVEL_ERROR, "Failed to parse IPv4 nozzle IP address");
return -1;
}
addr = (struct in_addr *)&totemip.addr;
addr->s_addr &= htonl(addr_mask);
addr->s_addr |= htonl(masked_nodeid);
inet_ntop(AF_INET, addr, output_addr, output_len);
return 0;
} | /*
* Reparse IP address to add in our node ID
* IPv6 addresses must end in '::'
* IPv4 addresses must just be valid
* '/xx' lengths are optional for IPv6, mandatory for IPv4
*
* Returns the modified IP address as a string to pass into libnozzle
*/ | Reparse IP address to add in our node ID
IPv6 addresses must end in '::'
IPv4 addresses must just be valid
'/xx' lengths are optional for IPv6, mandatory for IPv4
Returns the modified IP address as a string to pass into libnozzle | [
"Reparse",
"IP",
"address",
"to",
"add",
"in",
"our",
"node",
"ID",
"IPv6",
"addresses",
"must",
"end",
"in",
"'",
"::",
"'",
"IPv4",
"addresses",
"must",
"just",
"be",
"valid",
"'",
"/",
"xx",
"'",
"lengths",
"are",
"optional",
"for",
"IPv6",
"mandatory",
"for",
"IPv4",
"Returns",
"the",
"modified",
"IP",
"address",
"as",
"a",
"string",
"to",
"pass",
"into",
"libnozzle"
] | static int reparse_nozzle_ip_address(struct totemknet_instance *instance,
const char *input_addr,
const char *prefix, int nodeid,
char *output_addr, size_t output_len)
{
char *coloncolon;
int bits;
int max_prefix = 64;
uint32_t nodeid_mask;
uint32_t addr_mask;
uint32_t masked_nodeid;
struct in_addr *addr;
struct totem_ip_address totemip;
coloncolon = strstr(input_addr, "::");
if (!coloncolon) {
max_prefix = 30;
}
bits = atoi(prefix);
if (bits < 8 || bits > max_prefix) {
knet_log_printf(LOGSYS_LEVEL_ERROR, "nozzle IP address prefix must be >= 8 and <= %d (got %d)", max_prefix, bits);
return -1;
}
if (coloncolon) {
memcpy(output_addr, input_addr, coloncolon-input_addr);
sprintf(output_addr + (coloncolon-input_addr), "::%x", nodeid);
return 0;
}
nodeid_mask = UINT32_MAX & ((1<<(32 - bits)) - 1);
addr_mask = UINT32_MAX ^ nodeid_mask;
masked_nodeid = nodeid & nodeid_mask;
if (totemip_parse(&totemip, input_addr, AF_INET)) {
knet_log_printf(LOGSYS_LEVEL_ERROR, "Failed to parse IPv4 nozzle IP address");
return -1;
}
addr = (struct in_addr *)&totemip.addr;
addr->s_addr &= htonl(addr_mask);
addr->s_addr |= htonl(masked_nodeid);
inet_ntop(AF_INET, addr, output_addr, output_len);
return 0;
} | [
"static",
"int",
"reparse_nozzle_ip_address",
"(",
"struct",
"totemknet_instance",
"*",
"instance",
",",
"const",
"char",
"*",
"input_addr",
",",
"const",
"char",
"*",
"prefix",
",",
"int",
"nodeid",
",",
"char",
"*",
"output_addr",
",",
"size_t",
"output_len",
")",
"{",
"char",
"*",
"coloncolon",
";",
"int",
"bits",
";",
"int",
"max_prefix",
"=",
"64",
";",
"uint32_t",
"nodeid_mask",
";",
"uint32_t",
"addr_mask",
";",
"uint32_t",
"masked_nodeid",
";",
"struct",
"in_addr",
"*",
"addr",
";",
"struct",
"totem_ip_address",
"totemip",
";",
"coloncolon",
"=",
"strstr",
"(",
"input_addr",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"coloncolon",
")",
"{",
"max_prefix",
"=",
"30",
";",
"}",
"bits",
"=",
"atoi",
"(",
"prefix",
")",
";",
"if",
"(",
"bits",
"<",
"8",
"||",
"bits",
">",
"max_prefix",
")",
"{",
"knet_log_printf",
"(",
"LOGSYS_LEVEL_ERROR",
",",
"\"",
"\"",
",",
"max_prefix",
",",
"bits",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"coloncolon",
")",
"{",
"memcpy",
"(",
"output_addr",
",",
"input_addr",
",",
"coloncolon",
"-",
"input_addr",
")",
";",
"sprintf",
"(",
"output_addr",
"+",
"(",
"coloncolon",
"-",
"input_addr",
")",
",",
"\"",
"\"",
",",
"nodeid",
")",
";",
"return",
"0",
";",
"}",
"nodeid_mask",
"=",
"UINT32_MAX",
"&",
"(",
"(",
"1",
"<<",
"(",
"32",
"-",
"bits",
")",
")",
"-",
"1",
")",
";",
"addr_mask",
"=",
"UINT32_MAX",
"^",
"nodeid_mask",
";",
"masked_nodeid",
"=",
"nodeid",
"&",
"nodeid_mask",
";",
"if",
"(",
"totemip_parse",
"(",
"&",
"totemip",
",",
"input_addr",
",",
"AF_INET",
")",
")",
"{",
"knet_log_printf",
"(",
"LOGSYS_LEVEL_ERROR",
",",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"addr",
"=",
"(",
"struct",
"in_addr",
"*",
")",
"&",
"totemip",
".",
"addr",
";",
"addr",
"->",
"s_addr",
"&=",
"htonl",
"(",
"addr_mask",
")",
";",
"addr",
"->",
"s_addr",
"|=",
"htonl",
"(",
"masked_nodeid",
")",
";",
"inet_ntop",
"(",
"AF_INET",
",",
"addr",
",",
"output_addr",
",",
"output_len",
")",
";",
"return",
"0",
";",
"}"
] | Reparse IP address to add in our node ID
IPv6 addresses must end in '::'
IPv4 addresses must just be valid
'/xx' lengths are optional for IPv6, mandatory for IPv4 | [
"Reparse",
"IP",
"address",
"to",
"add",
"in",
"our",
"node",
"ID",
"IPv6",
"addresses",
"must",
"end",
"in",
"'",
"::",
"'",
"IPv4",
"addresses",
"must",
"just",
"be",
"valid",
"'",
"/",
"xx",
"'",
"lengths",
"are",
"optional",
"for",
"IPv6",
"mandatory",
"for",
"IPv4"
] | [
"/* IPv6 is easy */",
"/* For IPv4 we need to parse the address into binary, mask off the required bits,\n\t * add in the masked_nodeid and 'print' it out again\n\t */"
] | [
{
"param": "instance",
"type": "struct totemknet_instance"
},
{
"param": "input_addr",
"type": "char"
},
{
"param": "prefix",
"type": "char"
},
{
"param": "nodeid",
"type": "int"
},
{
"param": "output_addr",
"type": "char"
},
{
"param": "output_len",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "instance",
"type": "struct totemknet_instance",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_addr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prefix",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nodeid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_addr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_len",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | totem_volatile_config_set_uint32_value | void | static void totem_volatile_config_set_uint32_value (struct totem_config *totem_config, icmap_map_t map,
const char *key_name, const char *deleted_key, unsigned int default_value,
int allow_zero_value)
{
char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
if (icmap_get_uint32_r(map, key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
(deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
(!allow_zero_value && *(uint32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
*(uint32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
}
/*
* Store totem_config value to cmap runtime section
*/
if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
/*
* This shouldn't happen
*/
return ;
}
strcpy(runtime_key_name, "runtime.config.");
strcat(runtime_key_name, key_name);
icmap_set_uint32_r(map, runtime_key_name, *(uint32_t *)totem_get_param_by_name(totem_config, key_name));
} | /*
* Read key_name from icmap. If key is not found or key_name == delete_key or if allow_zero is false
* and readed value is zero, default value is used and stored into totem_config.
*/ | Read key_name from icmap. If key is not found or key_name == delete_key or if allow_zero is false
and readed value is zero, default value is used and stored into totem_config. | [
"Read",
"key_name",
"from",
"icmap",
".",
"If",
"key",
"is",
"not",
"found",
"or",
"key_name",
"==",
"delete_key",
"or",
"if",
"allow_zero",
"is",
"false",
"and",
"readed",
"value",
"is",
"zero",
"default",
"value",
"is",
"used",
"and",
"stored",
"into",
"totem_config",
"."
] | static void totem_volatile_config_set_uint32_value (struct totem_config *totem_config, icmap_map_t map,
const char *key_name, const char *deleted_key, unsigned int default_value,
int allow_zero_value)
{
char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
if (icmap_get_uint32_r(map, key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
(deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
(!allow_zero_value && *(uint32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
*(uint32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
}
if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
return ;
}
strcpy(runtime_key_name, "runtime.config.");
strcat(runtime_key_name, key_name);
icmap_set_uint32_r(map, runtime_key_name, *(uint32_t *)totem_get_param_by_name(totem_config, key_name));
} | [
"static",
"void",
"totem_volatile_config_set_uint32_value",
"(",
"struct",
"totem_config",
"*",
"totem_config",
",",
"icmap_map_t",
"map",
",",
"const",
"char",
"*",
"key_name",
",",
"const",
"char",
"*",
"deleted_key",
",",
"unsigned",
"int",
"default_value",
",",
"int",
"allow_zero_value",
")",
"{",
"char",
"runtime_key_name",
"[",
"ICMAP_KEYNAME_MAXLEN",
"]",
";",
"if",
"(",
"icmap_get_uint32_r",
"(",
"map",
",",
"key_name",
",",
"totem_get_param_by_name",
"(",
"totem_config",
",",
"key_name",
")",
")",
"!=",
"CS_OK",
"||",
"(",
"deleted_key",
"!=",
"NULL",
"&&",
"strcmp",
"(",
"deleted_key",
",",
"key_name",
")",
"==",
"0",
")",
"||",
"(",
"!",
"allow_zero_value",
"&&",
"*",
"(",
"uint32_t",
"*",
")",
"totem_get_param_by_name",
"(",
"totem_config",
",",
"key_name",
")",
"==",
"0",
")",
")",
"{",
"*",
"(",
"uint32_t",
"*",
")",
"totem_get_param_by_name",
"(",
"totem_config",
",",
"key_name",
")",
"=",
"default_value",
";",
"}",
"if",
"(",
"strlen",
"(",
"\"",
"\"",
")",
"+",
"strlen",
"(",
"key_name",
")",
">=",
"ICMAP_KEYNAME_MAXLEN",
")",
"{",
"return",
";",
"}",
"strcpy",
"(",
"runtime_key_name",
",",
"\"",
"\"",
")",
";",
"strcat",
"(",
"runtime_key_name",
",",
"key_name",
")",
";",
"icmap_set_uint32_r",
"(",
"map",
",",
"runtime_key_name",
",",
"*",
"(",
"uint32_t",
"*",
")",
"totem_get_param_by_name",
"(",
"totem_config",
",",
"key_name",
")",
")",
";",
"}"
] | Read key_name from icmap. | [
"Read",
"key_name",
"from",
"icmap",
"."
] | [
"/*\n\t * Store totem_config value to cmap runtime section\n\t */",
"/*\n\t\t * This shouldn't happen\n\t\t */"
] | [
{
"param": "totem_config",
"type": "struct totem_config"
},
{
"param": "map",
"type": "icmap_map_t"
},
{
"param": "key_name",
"type": "char"
},
{
"param": "deleted_key",
"type": "char"
},
{
"param": "default_value",
"type": "unsigned int"
},
{
"param": "allow_zero_value",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "totem_config",
"type": "struct totem_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "map",
"type": "icmap_map_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "deleted_key",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "default_value",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "allow_zero_value",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | totem_volatile_config_read | void | void totem_volatile_config_read (struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
{
uint32_t u32;
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmits_before_loss_const", deleted_key,
TOKEN_RETRANSMITS_BEFORE_LOSS_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token", deleted_key, TOKEN_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_warning", deleted_key, TOKEN_WARNING, 1);
if (totem_config->interfaces[0].member_count > 2) {
u32 = TOKEN_COEFFICIENT;
icmap_get_uint32_r(temp_map, "totem.token_coefficient", &u32);
totem_config->token_timeout += (totem_config->interfaces[0].member_count - 2) * u32;
/*
* Store totem_config value to cmap runtime section
*/
icmap_set_uint32_r(temp_map, "runtime.config.totem.token", totem_config->token_timeout);
}
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_network_delay", deleted_key, MAX_NETWORK_DELAY, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.window_size", deleted_key, WINDOW_SIZE, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_messages", deleted_key, MAX_MESSAGES, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.miss_count_const", deleted_key, MISS_COUNT_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_pmtud_interval", deleted_key, KNET_PMTUD_INTERVAL, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmit", deleted_key,
(int)(totem_config->token_timeout / (totem_config->token_retransmits_before_loss_const + 0.2)), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.hold", deleted_key,
(int)(totem_config->token_retransmit_timeout * 0.8 - (1000/HZ)), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.join", deleted_key, JOIN_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.consensus", deleted_key,
(int)(float)(1.2 * totem_config->token_timeout), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.merge", deleted_key, MERGE_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.downcheck", deleted_key, DOWNCHECK_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.fail_recv_const", deleted_key, FAIL_TO_RECV_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.seqno_unchanged_const", deleted_key,
SEQNO_UNCHANGED_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.send_join", deleted_key, 0, 1);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.heartbeat_failures_allowed", deleted_key, 0, 1);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_compression_threshold", deleted_key, 0, 1);
totem_volatile_config_set_int32_value(totem_config, temp_map, "totem.knet_compression_level", deleted_key, 0, 1);
totem_volatile_config_set_string_value(totem_config, temp_map, "totem.knet_compression_model", deleted_key, "none");
totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.block_unlisted_ips", deleted_key,
BLOCK_UNLISTED_IPS);
totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.cancel_token_hold_on_retransmit",
deleted_key, CANCEL_TOKEN_HOLD_ON_RETRANSMIT);
} | /*
* Read and validate config values from cmap and store them into totem_config. If key doesn't exists,
* default value is stored. deleted_key is name of key beeing processed by delete operation
* from cmap. It is considered as non existing even if it can be read. Can be NULL.
*/ | Read and validate config values from cmap and store them into totem_config. If key doesn't exists,
default value is stored. deleted_key is name of key beeing processed by delete operation
from cmap. It is considered as non existing even if it can be read. Can be NULL. | [
"Read",
"and",
"validate",
"config",
"values",
"from",
"cmap",
"and",
"store",
"them",
"into",
"totem_config",
".",
"If",
"key",
"doesn",
"'",
"t",
"exists",
"default",
"value",
"is",
"stored",
".",
"deleted_key",
"is",
"name",
"of",
"key",
"beeing",
"processed",
"by",
"delete",
"operation",
"from",
"cmap",
".",
"It",
"is",
"considered",
"as",
"non",
"existing",
"even",
"if",
"it",
"can",
"be",
"read",
".",
"Can",
"be",
"NULL",
"."
] | void totem_volatile_config_read (struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
{
uint32_t u32;
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmits_before_loss_const", deleted_key,
TOKEN_RETRANSMITS_BEFORE_LOSS_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token", deleted_key, TOKEN_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_warning", deleted_key, TOKEN_WARNING, 1);
if (totem_config->interfaces[0].member_count > 2) {
u32 = TOKEN_COEFFICIENT;
icmap_get_uint32_r(temp_map, "totem.token_coefficient", &u32);
totem_config->token_timeout += (totem_config->interfaces[0].member_count - 2) * u32;
icmap_set_uint32_r(temp_map, "runtime.config.totem.token", totem_config->token_timeout);
}
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_network_delay", deleted_key, MAX_NETWORK_DELAY, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.window_size", deleted_key, WINDOW_SIZE, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_messages", deleted_key, MAX_MESSAGES, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.miss_count_const", deleted_key, MISS_COUNT_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_pmtud_interval", deleted_key, KNET_PMTUD_INTERVAL, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmit", deleted_key,
(int)(totem_config->token_timeout / (totem_config->token_retransmits_before_loss_const + 0.2)), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.hold", deleted_key,
(int)(totem_config->token_retransmit_timeout * 0.8 - (1000/HZ)), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.join", deleted_key, JOIN_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.consensus", deleted_key,
(int)(float)(1.2 * totem_config->token_timeout), 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.merge", deleted_key, MERGE_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.downcheck", deleted_key, DOWNCHECK_TIMEOUT, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.fail_recv_const", deleted_key, FAIL_TO_RECV_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.seqno_unchanged_const", deleted_key,
SEQNO_UNCHANGED_CONST, 0);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.send_join", deleted_key, 0, 1);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.heartbeat_failures_allowed", deleted_key, 0, 1);
totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_compression_threshold", deleted_key, 0, 1);
totem_volatile_config_set_int32_value(totem_config, temp_map, "totem.knet_compression_level", deleted_key, 0, 1);
totem_volatile_config_set_string_value(totem_config, temp_map, "totem.knet_compression_model", deleted_key, "none");
totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.block_unlisted_ips", deleted_key,
BLOCK_UNLISTED_IPS);
totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.cancel_token_hold_on_retransmit",
deleted_key, CANCEL_TOKEN_HOLD_ON_RETRANSMIT);
} | [
"void",
"totem_volatile_config_read",
"(",
"struct",
"totem_config",
"*",
"totem_config",
",",
"icmap_map_t",
"temp_map",
",",
"const",
"char",
"*",
"deleted_key",
")",
"{",
"uint32_t",
"u32",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"TOKEN_RETRANSMITS_BEFORE_LOSS_CONST",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"TOKEN_TIMEOUT",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"TOKEN_WARNING",
",",
"1",
")",
";",
"if",
"(",
"totem_config",
"->",
"interfaces",
"[",
"0",
"]",
".",
"member_count",
">",
"2",
")",
"{",
"u32",
"=",
"TOKEN_COEFFICIENT",
";",
"icmap_get_uint32_r",
"(",
"temp_map",
",",
"\"",
"\"",
",",
"&",
"u32",
")",
";",
"totem_config",
"->",
"token_timeout",
"+=",
"(",
"totem_config",
"->",
"interfaces",
"[",
"0",
"]",
".",
"member_count",
"-",
"2",
")",
"*",
"u32",
";",
"icmap_set_uint32_r",
"(",
"temp_map",
",",
"\"",
"\"",
",",
"totem_config",
"->",
"token_timeout",
")",
";",
"}",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"MAX_NETWORK_DELAY",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"WINDOW_SIZE",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"MAX_MESSAGES",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"MISS_COUNT_CONST",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"KNET_PMTUD_INTERVAL",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"(",
"int",
")",
"(",
"totem_config",
"->",
"token_timeout",
"/",
"(",
"totem_config",
"->",
"token_retransmits_before_loss_const",
"+",
"0.2",
")",
")",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"(",
"int",
")",
"(",
"totem_config",
"->",
"token_retransmit_timeout",
"*",
"0.8",
"-",
"(",
"1000",
"/",
"HZ",
")",
")",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"JOIN_TIMEOUT",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"(",
"int",
")",
"(",
"float",
")",
"(",
"1.2",
"*",
"totem_config",
"->",
"token_timeout",
")",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"MERGE_TIMEOUT",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"DOWNCHECK_TIMEOUT",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"FAIL_TO_RECV_CONST",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"SEQNO_UNCHANGED_CONST",
",",
"0",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"0",
",",
"1",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"0",
",",
"1",
")",
";",
"totem_volatile_config_set_uint32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"0",
",",
"1",
")",
";",
"totem_volatile_config_set_int32_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"0",
",",
"1",
")",
";",
"totem_volatile_config_set_string_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"\"",
"\"",
")",
";",
"totem_volatile_config_set_boolean_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"BLOCK_UNLISTED_IPS",
")",
";",
"totem_volatile_config_set_boolean_value",
"(",
"totem_config",
",",
"temp_map",
",",
"\"",
"\"",
",",
"deleted_key",
",",
"CANCEL_TOKEN_HOLD_ON_RETRANSMIT",
")",
";",
"}"
] | Read and validate config values from cmap and store them into totem_config. | [
"Read",
"and",
"validate",
"config",
"values",
"from",
"cmap",
"and",
"store",
"them",
"into",
"totem_config",
"."
] | [
"/*\n\t\t * Store totem_config value to cmap runtime section\n\t\t */"
] | [
{
"param": "totem_config",
"type": "struct totem_config"
},
{
"param": "temp_map",
"type": "icmap_map_t"
},
{
"param": "deleted_key",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "totem_config",
"type": "struct totem_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "temp_map",
"type": "icmap_map_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "deleted_key",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | ipaddr_equal | int | static int ipaddr_equal(const struct sockaddr *addr1, const struct sockaddr *addr2)
{
int addrlen = 0;
const void *addr1p, *addr2p;
if (addr1->sa_family != addr2->sa_family)
return 0;
switch (addr1->sa_family) {
case AF_INET:
addrlen = sizeof(struct in_addr);
addr1p = &((struct sockaddr_in *)addr1)->sin_addr;
addr2p = &((struct sockaddr_in *)addr2)->sin_addr;
break;
case AF_INET6:
addrlen = sizeof(struct in6_addr);
addr1p = &((struct sockaddr_in6 *)addr1)->sin6_addr;
addr2p = &((struct sockaddr_in6 *)addr2)->sin6_addr;
break;
default:
assert(0);
}
return (memcmp(addr1p, addr2p, addrlen) == 0);
} | /* Compare two addresses - only address part (sin_addr/sin6_addr) is checked */ | Compare two addresses - only address part (sin_addr/sin6_addr) is checked | [
"Compare",
"two",
"addresses",
"-",
"only",
"address",
"part",
"(",
"sin_addr",
"/",
"sin6_addr",
")",
"is",
"checked"
] | static int ipaddr_equal(const struct sockaddr *addr1, const struct sockaddr *addr2)
{
int addrlen = 0;
const void *addr1p, *addr2p;
if (addr1->sa_family != addr2->sa_family)
return 0;
switch (addr1->sa_family) {
case AF_INET:
addrlen = sizeof(struct in_addr);
addr1p = &((struct sockaddr_in *)addr1)->sin_addr;
addr2p = &((struct sockaddr_in *)addr2)->sin_addr;
break;
case AF_INET6:
addrlen = sizeof(struct in6_addr);
addr1p = &((struct sockaddr_in6 *)addr1)->sin6_addr;
addr2p = &((struct sockaddr_in6 *)addr2)->sin6_addr;
break;
default:
assert(0);
}
return (memcmp(addr1p, addr2p, addrlen) == 0);
} | [
"static",
"int",
"ipaddr_equal",
"(",
"const",
"struct",
"sockaddr",
"*",
"addr1",
",",
"const",
"struct",
"sockaddr",
"*",
"addr2",
")",
"{",
"int",
"addrlen",
"=",
"0",
";",
"const",
"void",
"*",
"addr1p",
",",
"*",
"addr2p",
";",
"if",
"(",
"addr1",
"->",
"sa_family",
"!=",
"addr2",
"->",
"sa_family",
")",
"return",
"0",
";",
"switch",
"(",
"addr1",
"->",
"sa_family",
")",
"{",
"case",
"AF_INET",
":",
"addrlen",
"=",
"sizeof",
"(",
"struct",
"in_addr",
")",
";",
"addr1p",
"=",
"&",
"(",
"(",
"struct",
"sockaddr_in",
"*",
")",
"addr1",
")",
"->",
"sin_addr",
";",
"addr2p",
"=",
"&",
"(",
"(",
"struct",
"sockaddr_in",
"*",
")",
"addr2",
")",
"->",
"sin_addr",
";",
"break",
";",
"case",
"AF_INET6",
":",
"addrlen",
"=",
"sizeof",
"(",
"struct",
"in6_addr",
")",
";",
"addr1p",
"=",
"&",
"(",
"(",
"struct",
"sockaddr_in6",
"*",
")",
"addr1",
")",
"->",
"sin6_addr",
";",
"addr2p",
"=",
"&",
"(",
"(",
"struct",
"sockaddr_in6",
"*",
")",
"addr2",
")",
"->",
"sin6_addr",
";",
"break",
";",
"default",
":",
"assert",
"(",
"0",
")",
";",
"}",
"return",
"(",
"memcmp",
"(",
"addr1p",
",",
"addr2p",
",",
"addrlen",
")",
"==",
"0",
")",
";",
"}"
] | Compare two addresses - only address part (sin_addr/sin6_addr) is checked | [
"Compare",
"two",
"addresses",
"-",
"only",
"address",
"part",
"(",
"sin_addr",
"/",
"sin6_addr",
")",
"is",
"checked"
] | [] | [
{
"param": "addr1",
"type": "struct sockaddr"
},
{
"param": "addr2",
"type": "struct sockaddr"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "addr1",
"type": "struct sockaddr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr2",
"type": "struct sockaddr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | find_local_node | int | static int find_local_node(icmap_map_t map, int use_cache)
{
char nodename2[PATH_MAX];
char name_str[ICMAP_KEYNAME_MAXLEN];
icmap_iter_t iter;
const char *iter_key;
unsigned int cached_pos;
char *dot = NULL;
const char *node;
struct ifaddrs *ifa, *ifa_list;
struct sockaddr *sa;
int found = 0;
int node_pos = -1;
int res;
struct utsname utsname;
/* Check for cached value first */
if (use_cache) {
if (icmap_get_uint32("nodelist.local_node_pos", &cached_pos) == CS_OK) {
return cached_pos;
}
}
res = uname(&utsname);
if (res) {
return -1;
}
node = utsname.nodename;
/* 1. Exact match */
node_pos = nodelist_byname(map, node, 0);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
/* 2. Try to match with increasingly more
* specific versions of it
*/
strcpy(nodename2, node);
dot = strrchr(nodename2, '.');
while (dot) {
*dot = '\0';
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
dot = strrchr(nodename2, '.');
}
node_pos = nodelist_byname(map, nodename2, 1);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
/*
* The corosync.conf name may not be related to uname at all,
* they may match a hostname on some network interface.
*/
if (getifaddrs(&ifa_list))
return -1;
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
socklen_t salen = 0;
/* Restore this */
strcpy(nodename2, node);
sa = ifa->ifa_addr;
if (!sa) {
continue;
}
if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
continue;
}
if (sa->sa_family == AF_INET) {
salen = sizeof(struct sockaddr_in);
}
if (sa->sa_family == AF_INET6) {
salen = sizeof(struct sockaddr_in6);
}
if (getnameinfo(sa, salen,
nodename2, sizeof(nodename2),
NULL, 0, 0) == 0) {
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
/* Truncate this name and try again */
dot = strchr(nodename2, '.');
if (dot) {
*dot = '\0';
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
}
}
/* See if it's the IP address that's in corosync.conf */
if (getnameinfo(sa, sizeof(*sa),
nodename2, sizeof(nodename2),
NULL, 0, NI_NUMERICHOST))
continue;
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
}
out:
if (found) {
freeifaddrs(ifa_list);
goto ret_found;
}
/*
* This section covers the usecase where the nodename specified in cluster.conf
* is an alias specified in /etc/hosts. For example:
* <ipaddr> hostname alias1 alias2
* and <clusternode name="alias2">
* the above calls use uname and getnameinfo does not return aliases.
* here we take the name specified in cluster.conf, resolve it to an address
* and then compare against all known local ip addresses.
* if we have a match, we found our nodename. In theory this chunk of code
* could replace all the checks above, but let's avoid any possible regressions
* and use it as last.
*/
iter = icmap_iter_init_r(map, "nodelist.node.");
while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
char *dbnodename = NULL;
struct addrinfo hints;
struct addrinfo *result = NULL, *rp = NULL;
res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
if (res != 2) {
continue;
}
/* 'ring0_addr' is allowed as a fallback, but 'name' will be found first
* because the names are in alpha order.
*/
if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
continue;
}
if (icmap_get_string_r(map, iter_key, &dbnodename) != CS_OK) {
continue;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = 0;
hints.ai_protocol = IPPROTO_UDP;
if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
continue;
}
for (rp = result; rp != NULL; rp = rp->ai_next) {
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr &&
ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
freeaddrinfo(result);
found = 1;
goto out2;
}
}
}
freeaddrinfo(result);
}
out2:
icmap_iter_finalize(iter);
freeifaddrs(ifa_list);
ret_found:
if (found) {
res = icmap_set_uint32_r(map, "nodelist.local_node_pos", node_pos);
}
return node_pos;
} | /* Finds the local node and returns its position in the nodelist.
* Uses nodelist.local_node_pos as a cache to save effort
*/ | Finds the local node and returns its position in the nodelist.
Uses nodelist.local_node_pos as a cache to save effort | [
"Finds",
"the",
"local",
"node",
"and",
"returns",
"its",
"position",
"in",
"the",
"nodelist",
".",
"Uses",
"nodelist",
".",
"local_node_pos",
"as",
"a",
"cache",
"to",
"save",
"effort"
] | static int find_local_node(icmap_map_t map, int use_cache)
{
char nodename2[PATH_MAX];
char name_str[ICMAP_KEYNAME_MAXLEN];
icmap_iter_t iter;
const char *iter_key;
unsigned int cached_pos;
char *dot = NULL;
const char *node;
struct ifaddrs *ifa, *ifa_list;
struct sockaddr *sa;
int found = 0;
int node_pos = -1;
int res;
struct utsname utsname;
if (use_cache) {
if (icmap_get_uint32("nodelist.local_node_pos", &cached_pos) == CS_OK) {
return cached_pos;
}
}
res = uname(&utsname);
if (res) {
return -1;
}
node = utsname.nodename;
node_pos = nodelist_byname(map, node, 0);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
strcpy(nodename2, node);
dot = strrchr(nodename2, '.');
while (dot) {
*dot = '\0';
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
dot = strrchr(nodename2, '.');
}
node_pos = nodelist_byname(map, nodename2, 1);
if (node_pos > -1) {
found = 1;
goto ret_found;
}
if (getifaddrs(&ifa_list))
return -1;
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
socklen_t salen = 0;
strcpy(nodename2, node);
sa = ifa->ifa_addr;
if (!sa) {
continue;
}
if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
continue;
}
if (sa->sa_family == AF_INET) {
salen = sizeof(struct sockaddr_in);
}
if (sa->sa_family == AF_INET6) {
salen = sizeof(struct sockaddr_in6);
}
if (getnameinfo(sa, salen,
nodename2, sizeof(nodename2),
NULL, 0, 0) == 0) {
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
dot = strchr(nodename2, '.');
if (dot) {
*dot = '\0';
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
}
}
if (getnameinfo(sa, sizeof(*sa),
nodename2, sizeof(nodename2),
NULL, 0, NI_NUMERICHOST))
continue;
node_pos = nodelist_byname(map, nodename2, 0);
if (node_pos > -1) {
found = 1;
goto out;
}
}
out:
if (found) {
freeifaddrs(ifa_list);
goto ret_found;
}
iter = icmap_iter_init_r(map, "nodelist.node.");
while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
char *dbnodename = NULL;
struct addrinfo hints;
struct addrinfo *result = NULL, *rp = NULL;
res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
if (res != 2) {
continue;
}
if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
continue;
}
if (icmap_get_string_r(map, iter_key, &dbnodename) != CS_OK) {
continue;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = 0;
hints.ai_protocol = IPPROTO_UDP;
if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
continue;
}
for (rp = result; rp != NULL; rp = rp->ai_next) {
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr &&
ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
freeaddrinfo(result);
found = 1;
goto out2;
}
}
}
freeaddrinfo(result);
}
out2:
icmap_iter_finalize(iter);
freeifaddrs(ifa_list);
ret_found:
if (found) {
res = icmap_set_uint32_r(map, "nodelist.local_node_pos", node_pos);
}
return node_pos;
} | [
"static",
"int",
"find_local_node",
"(",
"icmap_map_t",
"map",
",",
"int",
"use_cache",
")",
"{",
"char",
"nodename2",
"[",
"PATH_MAX",
"]",
";",
"char",
"name_str",
"[",
"ICMAP_KEYNAME_MAXLEN",
"]",
";",
"icmap_iter_t",
"iter",
";",
"const",
"char",
"*",
"iter_key",
";",
"unsigned",
"int",
"cached_pos",
";",
"char",
"*",
"dot",
"=",
"NULL",
";",
"const",
"char",
"*",
"node",
";",
"struct",
"ifaddrs",
"*",
"ifa",
",",
"*",
"ifa_list",
";",
"struct",
"sockaddr",
"*",
"sa",
";",
"int",
"found",
"=",
"0",
";",
"int",
"node_pos",
"=",
"-1",
";",
"int",
"res",
";",
"struct",
"utsname",
"utsname",
";",
"if",
"(",
"use_cache",
")",
"{",
"if",
"(",
"icmap_get_uint32",
"(",
"\"",
"\"",
",",
"&",
"cached_pos",
")",
"==",
"CS_OK",
")",
"{",
"return",
"cached_pos",
";",
"}",
"}",
"res",
"=",
"uname",
"(",
"&",
"utsname",
")",
";",
"if",
"(",
"res",
")",
"{",
"return",
"-1",
";",
"}",
"node",
"=",
"utsname",
".",
"nodename",
";",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"node",
",",
"0",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"ret_found",
";",
"}",
"strcpy",
"(",
"nodename2",
",",
"node",
")",
";",
"dot",
"=",
"strrchr",
"(",
"nodename2",
",",
"'",
"'",
")",
";",
"while",
"(",
"dot",
")",
"{",
"*",
"dot",
"=",
"'",
"\\0",
"'",
";",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"nodename2",
",",
"0",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"ret_found",
";",
"}",
"dot",
"=",
"strrchr",
"(",
"nodename2",
",",
"'",
"'",
")",
";",
"}",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"nodename2",
",",
"1",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"ret_found",
";",
"}",
"if",
"(",
"getifaddrs",
"(",
"&",
"ifa_list",
")",
")",
"return",
"-1",
";",
"for",
"(",
"ifa",
"=",
"ifa_list",
";",
"ifa",
";",
"ifa",
"=",
"ifa",
"->",
"ifa_next",
")",
"{",
"socklen_t",
"salen",
"=",
"0",
";",
"strcpy",
"(",
"nodename2",
",",
"node",
")",
";",
"sa",
"=",
"ifa",
"->",
"ifa_addr",
";",
"if",
"(",
"!",
"sa",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"sa",
"->",
"sa_family",
"!=",
"AF_INET",
"&&",
"sa",
"->",
"sa_family",
"!=",
"AF_INET6",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"sa",
"->",
"sa_family",
"==",
"AF_INET",
")",
"{",
"salen",
"=",
"sizeof",
"(",
"struct",
"sockaddr_in",
")",
";",
"}",
"if",
"(",
"sa",
"->",
"sa_family",
"==",
"AF_INET6",
")",
"{",
"salen",
"=",
"sizeof",
"(",
"struct",
"sockaddr_in6",
")",
";",
"}",
"if",
"(",
"getnameinfo",
"(",
"sa",
",",
"salen",
",",
"nodename2",
",",
"sizeof",
"(",
"nodename2",
")",
",",
"NULL",
",",
"0",
",",
"0",
")",
"==",
"0",
")",
"{",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"nodename2",
",",
"0",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"out",
";",
"}",
"dot",
"=",
"strchr",
"(",
"nodename2",
",",
"'",
"'",
")",
";",
"if",
"(",
"dot",
")",
"{",
"*",
"dot",
"=",
"'",
"\\0",
"'",
";",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"nodename2",
",",
"0",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"out",
";",
"}",
"}",
"}",
"if",
"(",
"getnameinfo",
"(",
"sa",
",",
"sizeof",
"(",
"*",
"sa",
")",
",",
"nodename2",
",",
"sizeof",
"(",
"nodename2",
")",
",",
"NULL",
",",
"0",
",",
"NI_NUMERICHOST",
")",
")",
"continue",
";",
"node_pos",
"=",
"nodelist_byname",
"(",
"map",
",",
"nodename2",
",",
"0",
")",
";",
"if",
"(",
"node_pos",
">",
"-1",
")",
"{",
"found",
"=",
"1",
";",
"goto",
"out",
";",
"}",
"}",
"out",
":",
"if",
"(",
"found",
")",
"{",
"freeifaddrs",
"(",
"ifa_list",
")",
";",
"goto",
"ret_found",
";",
"}",
"iter",
"=",
"icmap_iter_init_r",
"(",
"map",
",",
"\"",
"\"",
")",
";",
"while",
"(",
"(",
"iter_key",
"=",
"icmap_iter_next",
"(",
"iter",
",",
"NULL",
",",
"NULL",
")",
")",
"!=",
"NULL",
")",
"{",
"char",
"*",
"dbnodename",
"=",
"NULL",
";",
"struct",
"addrinfo",
"hints",
";",
"struct",
"addrinfo",
"*",
"result",
"=",
"NULL",
",",
"*",
"rp",
"=",
"NULL",
";",
"res",
"=",
"sscanf",
"(",
"iter_key",
",",
"\"",
"\"",
",",
"&",
"node_pos",
",",
"name_str",
")",
";",
"if",
"(",
"res",
"!=",
"2",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"strcmp",
"(",
"name_str",
",",
"\"",
"\"",
")",
"&&",
"strcmp",
"(",
"name_str",
",",
"\"",
"\"",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"icmap_get_string_r",
"(",
"map",
",",
"iter_key",
",",
"&",
"dbnodename",
")",
"!=",
"CS_OK",
")",
"{",
"continue",
";",
"}",
"memset",
"(",
"&",
"hints",
",",
"0",
",",
"sizeof",
"(",
"struct",
"addrinfo",
")",
")",
";",
"hints",
".",
"ai_family",
"=",
"AF_UNSPEC",
";",
"hints",
".",
"ai_socktype",
"=",
"SOCK_DGRAM",
";",
"hints",
".",
"ai_flags",
"=",
"0",
";",
"hints",
".",
"ai_protocol",
"=",
"IPPROTO_UDP",
";",
"if",
"(",
"getaddrinfo",
"(",
"dbnodename",
",",
"NULL",
",",
"&",
"hints",
",",
"&",
"result",
")",
")",
"{",
"continue",
";",
"}",
"for",
"(",
"rp",
"=",
"result",
";",
"rp",
"!=",
"NULL",
";",
"rp",
"=",
"rp",
"->",
"ai_next",
")",
"{",
"for",
"(",
"ifa",
"=",
"ifa_list",
";",
"ifa",
";",
"ifa",
"=",
"ifa",
"->",
"ifa_next",
")",
"{",
"if",
"(",
"ifa",
"->",
"ifa_addr",
"&&",
"ipaddr_equal",
"(",
"rp",
"->",
"ai_addr",
",",
"ifa",
"->",
"ifa_addr",
")",
")",
"{",
"freeaddrinfo",
"(",
"result",
")",
";",
"found",
"=",
"1",
";",
"goto",
"out2",
";",
"}",
"}",
"}",
"freeaddrinfo",
"(",
"result",
")",
";",
"}",
"out2",
":",
"icmap_iter_finalize",
"(",
"iter",
")",
";",
"freeifaddrs",
"(",
"ifa_list",
")",
";",
"ret_found",
":",
"if",
"(",
"found",
")",
"{",
"res",
"=",
"icmap_set_uint32_r",
"(",
"map",
",",
"\"",
"\"",
",",
"node_pos",
")",
";",
"}",
"return",
"node_pos",
";",
"}"
] | Finds the local node and returns its position in the nodelist. | [
"Finds",
"the",
"local",
"node",
"and",
"returns",
"its",
"position",
"in",
"the",
"nodelist",
"."
] | [
"/* Check for cached value first */",
"/* 1. Exact match */",
"/* 2. Try to match with increasingly more\n\t * specific versions of it\n\t */",
"/*\n\t * The corosync.conf name may not be related to uname at all,\n\t * they may match a hostname on some network interface.\n\t */",
"/* Restore this */",
"/* Truncate this name and try again */",
"/* See if it's the IP address that's in corosync.conf */",
"/*\n\t * This section covers the usecase where the nodename specified in cluster.conf\n\t * is an alias specified in /etc/hosts. For example:\n\t * <ipaddr> hostname alias1 alias2\n\t * and <clusternode name=\"alias2\">\n\t * the above calls use uname and getnameinfo does not return aliases.\n\t * here we take the name specified in cluster.conf, resolve it to an address\n\t * and then compare against all known local ip addresses.\n\t * if we have a match, we found our nodename. In theory this chunk of code\n\t * could replace all the checks above, but let's avoid any possible regressions\n\t * and use it as last.\n\t */",
"/* 'ring0_addr' is allowed as a fallback, but 'name' will be found first\n\t\t * because the names are in alpha order.\n\t\t */"
] | [
{
"param": "map",
"type": "icmap_map_t"
},
{
"param": "use_cache",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "map",
"type": "icmap_map_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_cache",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | calc_knet_ping_timers | void | static void calc_knet_ping_timers(struct totem_config *totem_config)
{
char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
int interface;
for (interface = 0; interface < INTERFACE_MAX; interface++) {
if (totem_config->interfaces[interface].configured) {
if (!totem_config->interfaces[interface].knet_pong_count) {
totem_config->interfaces[interface].knet_pong_count = KNET_PONG_COUNT;
}
if (!totem_config->interfaces[interface].knet_ping_timeout) {
totem_config->interfaces[interface].knet_ping_timeout =
totem_config->token_timeout / totem_config->interfaces[interface].knet_pong_count;
}
snprintf(runtime_key_name, sizeof(runtime_key_name),
"runtime.config.totem.interface.%d.knet_ping_timeout", interface);
icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_timeout);
if (!totem_config->interfaces[interface].knet_ping_interval) {
totem_config->interfaces[interface].knet_ping_interval =
totem_config->token_timeout / (totem_config->interfaces[interface].knet_pong_count * 2);
}
snprintf(runtime_key_name, sizeof(runtime_key_name),
"runtime.config.totem.interface.%d.knet_ping_interval", interface);
icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_interval);
}
}
} | /*
* This needs to be done last of all. It would be nice to do it when reading the
* interface params, but the totem params need to have them to be read first. We
* need both, so this is a way round that circular dependancy.
*/ | This needs to be done last of all. It would be nice to do it when reading the
interface params, but the totem params need to have them to be read first. We
need both, so this is a way round that circular dependancy. | [
"This",
"needs",
"to",
"be",
"done",
"last",
"of",
"all",
".",
"It",
"would",
"be",
"nice",
"to",
"do",
"it",
"when",
"reading",
"the",
"interface",
"params",
"but",
"the",
"totem",
"params",
"need",
"to",
"have",
"them",
"to",
"be",
"read",
"first",
".",
"We",
"need",
"both",
"so",
"this",
"is",
"a",
"way",
"round",
"that",
"circular",
"dependancy",
"."
] | static void calc_knet_ping_timers(struct totem_config *totem_config)
{
char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
int interface;
for (interface = 0; interface < INTERFACE_MAX; interface++) {
if (totem_config->interfaces[interface].configured) {
if (!totem_config->interfaces[interface].knet_pong_count) {
totem_config->interfaces[interface].knet_pong_count = KNET_PONG_COUNT;
}
if (!totem_config->interfaces[interface].knet_ping_timeout) {
totem_config->interfaces[interface].knet_ping_timeout =
totem_config->token_timeout / totem_config->interfaces[interface].knet_pong_count;
}
snprintf(runtime_key_name, sizeof(runtime_key_name),
"runtime.config.totem.interface.%d.knet_ping_timeout", interface);
icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_timeout);
if (!totem_config->interfaces[interface].knet_ping_interval) {
totem_config->interfaces[interface].knet_ping_interval =
totem_config->token_timeout / (totem_config->interfaces[interface].knet_pong_count * 2);
}
snprintf(runtime_key_name, sizeof(runtime_key_name),
"runtime.config.totem.interface.%d.knet_ping_interval", interface);
icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_interval);
}
}
} | [
"static",
"void",
"calc_knet_ping_timers",
"(",
"struct",
"totem_config",
"*",
"totem_config",
")",
"{",
"char",
"runtime_key_name",
"[",
"ICMAP_KEYNAME_MAXLEN",
"]",
";",
"int",
"interface",
";",
"for",
"(",
"interface",
"=",
"0",
";",
"interface",
"<",
"INTERFACE_MAX",
";",
"interface",
"++",
")",
"{",
"if",
"(",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"configured",
")",
"{",
"if",
"(",
"!",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_pong_count",
")",
"{",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_pong_count",
"=",
"KNET_PONG_COUNT",
";",
"}",
"if",
"(",
"!",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_timeout",
")",
"{",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_timeout",
"=",
"totem_config",
"->",
"token_timeout",
"/",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_pong_count",
";",
"}",
"snprintf",
"(",
"runtime_key_name",
",",
"sizeof",
"(",
"runtime_key_name",
")",
",",
"\"",
"\"",
",",
"interface",
")",
";",
"icmap_set_uint32",
"(",
"runtime_key_name",
",",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_timeout",
")",
";",
"if",
"(",
"!",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_interval",
")",
"{",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_interval",
"=",
"totem_config",
"->",
"token_timeout",
"/",
"(",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_pong_count",
"*",
"2",
")",
";",
"}",
"snprintf",
"(",
"runtime_key_name",
",",
"sizeof",
"(",
"runtime_key_name",
")",
",",
"\"",
"\"",
",",
"interface",
")",
";",
"icmap_set_uint32",
"(",
"runtime_key_name",
",",
"totem_config",
"->",
"interfaces",
"[",
"interface",
"]",
".",
"knet_ping_interval",
")",
";",
"}",
"}",
"}"
] | This needs to be done last of all. | [
"This",
"needs",
"to",
"be",
"done",
"last",
"of",
"all",
"."
] | [] | [
{
"param": "totem_config",
"type": "struct totem_config"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "totem_config",
"type": "struct totem_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | compute_and_set_totempg_interfaces | void | static void compute_and_set_totempg_interfaces(struct totem_interface *set1,
struct totem_interface *set2)
{
int ring_no, set1_pos, set2_pos;
struct totem_ip_address empty_ip_address;
memset(&empty_ip_address, 0, sizeof(empty_ip_address));
for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
if (!set1[ring_no].configured && !set2[ring_no].configured) {
continue;
}
for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
/*
* For current ring_no remove all set1 items existing
* in set2
*/
if (memcmp(&set1[ring_no].member_list[set1_pos],
&set2[ring_no].member_list[set2_pos],
sizeof(struct totem_ip_address)) == 0) {
memset(&set1[ring_no].member_list[set1_pos], 0,
sizeof(struct totem_ip_address));
memset(&set2[ring_no].member_list[set2_pos], 0,
sizeof(struct totem_ip_address));
}
}
}
}
for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
/*
* All items which remain in set1 and don't exist in set2 any more
* have to be removed.
*/
if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
log_printf(LOGSYS_LEVEL_DEBUG,
"removing dynamic member %s for ring %u",
totemip_print(&set1[ring_no].member_list[set1_pos]),
ring_no);
totempg_member_remove(&set1[ring_no].member_list[set1_pos], ring_no);
}
}
if (!set2[ring_no].configured) {
continue;
}
for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
/*
* All items which remain in set2 and don't exist in set1 are new nodes
* and have to be added.
*/
if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
log_printf(LOGSYS_LEVEL_DEBUG,
"adding dynamic member %s for ring %u",
totemip_print(&set2[ring_no].member_list[set2_pos]),
ring_no);
totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no);
}
}
}
} | /*
* Compute difference between two set of totem interface arrays and commit it.
* set1 and set2
* are changed so for same ring, ip existing in both set1 and set2 are cleared
* (set to 0), and ips which are only in set1 or set2 remains untouched.
* totempg_node_add/remove is called.
*/ | Compute difference between two set of totem interface arrays and commit it.
set1 and set2
are changed so for same ring, ip existing in both set1 and set2 are cleared
(set to 0), and ips which are only in set1 or set2 remains untouched. | [
"Compute",
"difference",
"between",
"two",
"set",
"of",
"totem",
"interface",
"arrays",
"and",
"commit",
"it",
".",
"set1",
"and",
"set2",
"are",
"changed",
"so",
"for",
"same",
"ring",
"ip",
"existing",
"in",
"both",
"set1",
"and",
"set2",
"are",
"cleared",
"(",
"set",
"to",
"0",
")",
"and",
"ips",
"which",
"are",
"only",
"in",
"set1",
"or",
"set2",
"remains",
"untouched",
"."
] | static void compute_and_set_totempg_interfaces(struct totem_interface *set1,
struct totem_interface *set2)
{
int ring_no, set1_pos, set2_pos;
struct totem_ip_address empty_ip_address;
memset(&empty_ip_address, 0, sizeof(empty_ip_address));
for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
if (!set1[ring_no].configured && !set2[ring_no].configured) {
continue;
}
for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
if (memcmp(&set1[ring_no].member_list[set1_pos],
&set2[ring_no].member_list[set2_pos],
sizeof(struct totem_ip_address)) == 0) {
memset(&set1[ring_no].member_list[set1_pos], 0,
sizeof(struct totem_ip_address));
memset(&set2[ring_no].member_list[set2_pos], 0,
sizeof(struct totem_ip_address));
}
}
}
}
for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
log_printf(LOGSYS_LEVEL_DEBUG,
"removing dynamic member %s for ring %u",
totemip_print(&set1[ring_no].member_list[set1_pos]),
ring_no);
totempg_member_remove(&set1[ring_no].member_list[set1_pos], ring_no);
}
}
if (!set2[ring_no].configured) {
continue;
}
for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
log_printf(LOGSYS_LEVEL_DEBUG,
"adding dynamic member %s for ring %u",
totemip_print(&set2[ring_no].member_list[set2_pos]),
ring_no);
totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no);
}
}
}
} | [
"static",
"void",
"compute_and_set_totempg_interfaces",
"(",
"struct",
"totem_interface",
"*",
"set1",
",",
"struct",
"totem_interface",
"*",
"set2",
")",
"{",
"int",
"ring_no",
",",
"set1_pos",
",",
"set2_pos",
";",
"struct",
"totem_ip_address",
"empty_ip_address",
";",
"memset",
"(",
"&",
"empty_ip_address",
",",
"0",
",",
"sizeof",
"(",
"empty_ip_address",
")",
")",
";",
"for",
"(",
"ring_no",
"=",
"0",
";",
"ring_no",
"<",
"INTERFACE_MAX",
";",
"ring_no",
"++",
")",
"{",
"if",
"(",
"!",
"set1",
"[",
"ring_no",
"]",
".",
"configured",
"&&",
"!",
"set2",
"[",
"ring_no",
"]",
".",
"configured",
")",
"{",
"continue",
";",
"}",
"for",
"(",
"set1_pos",
"=",
"0",
";",
"set1_pos",
"<",
"set1",
"[",
"ring_no",
"]",
".",
"member_count",
";",
"set1_pos",
"++",
")",
"{",
"for",
"(",
"set2_pos",
"=",
"0",
";",
"set2_pos",
"<",
"set2",
"[",
"ring_no",
"]",
".",
"member_count",
";",
"set2_pos",
"++",
")",
"{",
"if",
"(",
"memcmp",
"(",
"&",
"set1",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set1_pos",
"]",
",",
"&",
"set2",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set2_pos",
"]",
",",
"sizeof",
"(",
"struct",
"totem_ip_address",
")",
")",
"==",
"0",
")",
"{",
"memset",
"(",
"&",
"set1",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set1_pos",
"]",
",",
"0",
",",
"sizeof",
"(",
"struct",
"totem_ip_address",
")",
")",
";",
"memset",
"(",
"&",
"set2",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set2_pos",
"]",
",",
"0",
",",
"sizeof",
"(",
"struct",
"totem_ip_address",
")",
")",
";",
"}",
"}",
"}",
"}",
"for",
"(",
"ring_no",
"=",
"0",
";",
"ring_no",
"<",
"INTERFACE_MAX",
";",
"ring_no",
"++",
")",
"{",
"for",
"(",
"set1_pos",
"=",
"0",
";",
"set1_pos",
"<",
"set1",
"[",
"ring_no",
"]",
".",
"member_count",
";",
"set1_pos",
"++",
")",
"{",
"if",
"(",
"memcmp",
"(",
"&",
"set1",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set1_pos",
"]",
",",
"&",
"empty_ip_address",
",",
"sizeof",
"(",
"empty_ip_address",
")",
")",
"!=",
"0",
")",
"{",
"log_printf",
"(",
"LOGSYS_LEVEL_DEBUG",
",",
"\"",
"\"",
",",
"totemip_print",
"(",
"&",
"set1",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set1_pos",
"]",
")",
",",
"ring_no",
")",
";",
"totempg_member_remove",
"(",
"&",
"set1",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set1_pos",
"]",
",",
"ring_no",
")",
";",
"}",
"}",
"if",
"(",
"!",
"set2",
"[",
"ring_no",
"]",
".",
"configured",
")",
"{",
"continue",
";",
"}",
"for",
"(",
"set2_pos",
"=",
"0",
";",
"set2_pos",
"<",
"set2",
"[",
"ring_no",
"]",
".",
"member_count",
";",
"set2_pos",
"++",
")",
"{",
"if",
"(",
"memcmp",
"(",
"&",
"set2",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set2_pos",
"]",
",",
"&",
"empty_ip_address",
",",
"sizeof",
"(",
"empty_ip_address",
")",
")",
"!=",
"0",
")",
"{",
"log_printf",
"(",
"LOGSYS_LEVEL_DEBUG",
",",
"\"",
"\"",
",",
"totemip_print",
"(",
"&",
"set2",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set2_pos",
"]",
")",
",",
"ring_no",
")",
";",
"totempg_member_add",
"(",
"&",
"set2",
"[",
"ring_no",
"]",
".",
"member_list",
"[",
"set2_pos",
"]",
",",
"ring_no",
")",
";",
"}",
"}",
"}",
"}"
] | Compute difference between two set of totem interface arrays and commit it. | [
"Compute",
"difference",
"between",
"two",
"set",
"of",
"totem",
"interface",
"arrays",
"and",
"commit",
"it",
"."
] | [
"/*\n\t\t\t\t * For current ring_no remove all set1 items existing\n\t\t\t\t * in set2\n\t\t\t\t */",
"/*\n\t\t\t * All items which remain in set1 and don't exist in set2 any more\n\t\t\t * have to be removed.\n\t\t\t */",
"/*\n\t\t\t * All items which remain in set2 and don't exist in set1 are new nodes\n\t\t\t * and have to be added.\n\t\t\t */"
] | [
{
"param": "set1",
"type": "struct totem_interface"
},
{
"param": "set2",
"type": "struct totem_interface"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "set1",
"type": "struct totem_interface",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "set2",
"type": "struct totem_interface",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46e099528e3047483d8a602ce942f13b32d627a3 | HideoYamauchi/corosync | exec/totemconfig.c | [
"BSD-3-Clause"
] | C | check_things_have_not_changed | int | static int check_things_have_not_changed(struct totem_config *totem_config, const char **error_string)
{
int i,j,k;
const char *ip_str;
char addr_buf[INET6_ADDRSTRLEN];
int changed = 0;
for (i = 0; i<INTERFACE_MAX; i++) {
if (totem_config->interfaces[i].configured &&
totem_config->orig_interfaces[i].configured) {
if (totem_config->interfaces[i].knet_transport !=
totem_config->orig_interfaces[i].knet_transport) {
log_printf(LOGSYS_LEVEL_ERROR,
"New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
changed = 1;
}
/* Check each nodeid in the new configuration and make sure its IP address on this link has not changed */
for (j=0; j < totem_config->interfaces[i].member_count; j++) {
for (k=0; k < totem_config->orig_interfaces[i].member_count; k++) {
if (totem_config->interfaces[i].member_list[j].nodeid ==
totem_config->orig_interfaces[i].member_list[k].nodeid) {
/* Found our nodeid - check the IP address */
if (memcmp(&totem_config->interfaces[i].member_list[j],
&totem_config->orig_interfaces[i].member_list[k],
sizeof(struct totem_ip_address))) {
ip_str = totemip_print(&totem_config->orig_interfaces[i].member_list[k]);
/* if ip_str is NULL then the old address was invalid and is allowed to change */
if (ip_str) {
strncpy(addr_buf, ip_str, sizeof(addr_buf));
addr_buf[sizeof(addr_buf) - 1] = '\0';
log_printf(LOGSYS_LEVEL_ERROR,
"new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
i, addr_buf, totemip_print(&totem_config->interfaces[i].member_list[j]));
changed = 1;
}
}
}
}
}
}
}
if (changed) {
snprintf (error_string_response, sizeof(error_string_response),
"To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
*error_string = error_string_response;
return -1;
}
return 0;
} | /* Check for differences in config that can't be done on-the-fly and print an error */ | Check for differences in config that can't be done on-the-fly and print an error | [
"Check",
"for",
"differences",
"in",
"config",
"that",
"can",
"'",
"t",
"be",
"done",
"on",
"-",
"the",
"-",
"fly",
"and",
"print",
"an",
"error"
] | static int check_things_have_not_changed(struct totem_config *totem_config, const char **error_string)
{
int i,j,k;
const char *ip_str;
char addr_buf[INET6_ADDRSTRLEN];
int changed = 0;
for (i = 0; i<INTERFACE_MAX; i++) {
if (totem_config->interfaces[i].configured &&
totem_config->orig_interfaces[i].configured) {
if (totem_config->interfaces[i].knet_transport !=
totem_config->orig_interfaces[i].knet_transport) {
log_printf(LOGSYS_LEVEL_ERROR,
"New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
changed = 1;
}
for (j=0; j < totem_config->interfaces[i].member_count; j++) {
for (k=0; k < totem_config->orig_interfaces[i].member_count; k++) {
if (totem_config->interfaces[i].member_list[j].nodeid ==
totem_config->orig_interfaces[i].member_list[k].nodeid) {
if (memcmp(&totem_config->interfaces[i].member_list[j],
&totem_config->orig_interfaces[i].member_list[k],
sizeof(struct totem_ip_address))) {
ip_str = totemip_print(&totem_config->orig_interfaces[i].member_list[k]);
if (ip_str) {
strncpy(addr_buf, ip_str, sizeof(addr_buf));
addr_buf[sizeof(addr_buf) - 1] = '\0';
log_printf(LOGSYS_LEVEL_ERROR,
"new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
i, addr_buf, totemip_print(&totem_config->interfaces[i].member_list[j]));
changed = 1;
}
}
}
}
}
}
}
if (changed) {
snprintf (error_string_response, sizeof(error_string_response),
"To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
*error_string = error_string_response;
return -1;
}
return 0;
} | [
"static",
"int",
"check_things_have_not_changed",
"(",
"struct",
"totem_config",
"*",
"totem_config",
",",
"const",
"char",
"*",
"*",
"error_string",
")",
"{",
"int",
"i",
",",
"j",
",",
"k",
";",
"const",
"char",
"*",
"ip_str",
";",
"char",
"addr_buf",
"[",
"INET6_ADDRSTRLEN",
"]",
";",
"int",
"changed",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"INTERFACE_MAX",
";",
"i",
"++",
")",
"{",
"if",
"(",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"configured",
"&&",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"configured",
")",
"{",
"if",
"(",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"knet_transport",
"!=",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"knet_transport",
")",
"{",
"log_printf",
"(",
"LOGSYS_LEVEL_ERROR",
",",
"\"",
"\\n",
"\"",
",",
"i",
")",
";",
"changed",
"=",
"1",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"member_count",
";",
"j",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"member_count",
";",
"k",
"++",
")",
"{",
"if",
"(",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"j",
"]",
".",
"nodeid",
"==",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"k",
"]",
".",
"nodeid",
")",
"{",
"if",
"(",
"memcmp",
"(",
"&",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"j",
"]",
",",
"&",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"k",
"]",
",",
"sizeof",
"(",
"struct",
"totem_ip_address",
")",
")",
")",
"{",
"ip_str",
"=",
"totemip_print",
"(",
"&",
"totem_config",
"->",
"orig_interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"k",
"]",
")",
";",
"if",
"(",
"ip_str",
")",
"{",
"strncpy",
"(",
"addr_buf",
",",
"ip_str",
",",
"sizeof",
"(",
"addr_buf",
")",
")",
";",
"addr_buf",
"[",
"sizeof",
"(",
"addr_buf",
")",
"-",
"1",
"]",
"=",
"'",
"\\0",
"'",
";",
"log_printf",
"(",
"LOGSYS_LEVEL_ERROR",
",",
"\"",
"\\n",
"\"",
",",
"i",
",",
"addr_buf",
",",
"totemip_print",
"(",
"&",
"totem_config",
"->",
"interfaces",
"[",
"i",
"]",
".",
"member_list",
"[",
"j",
"]",
")",
")",
";",
"changed",
"=",
"1",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"changed",
")",
"{",
"snprintf",
"(",
"error_string_response",
",",
"sizeof",
"(",
"error_string_response",
")",
",",
"\"",
"\"",
")",
";",
"*",
"error_string",
"=",
"error_string_response",
";",
"return",
"-1",
";",
"}",
"return",
"0",
";",
"}"
] | Check for differences in config that can't be done on-the-fly and print an error | [
"Check",
"for",
"differences",
"in",
"config",
"that",
"can",
"'",
"t",
"be",
"done",
"on",
"-",
"the",
"-",
"fly",
"and",
"print",
"an",
"error"
] | [
"/* Check each nodeid in the new configuration and make sure its IP address on this link has not changed */",
"/* Found our nodeid - check the IP address */",
"/* if ip_str is NULL then the old address was invalid and is allowed to change */"
] | [
{
"param": "totem_config",
"type": "struct totem_config"
},
{
"param": "error_string",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "totem_config",
"type": "struct totem_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "error_string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a85bbc833ba6e76bc100146727cd0b4f685f30d2 | justin-harper/cs223 | HW5/hw6_234tree.h | [
"MIT"
] | C | FindMin | Node | Node* FindMin(Node* root)
{
if (root->IsLeaf())
{
return root;
}
Node* n = root->L;
while (n->L) { n = n->L; }
return n;
} | // Finds and returns the node containing the minimum value in the subtree. | Finds and returns the node containing the minimum value in the subtree. | [
"Finds",
"and",
"returns",
"the",
"node",
"containing",
"the",
"minimum",
"value",
"in",
"the",
"subtree",
"."
] | Node* FindMin(Node* root)
{
if (root->IsLeaf())
{
return root;
}
Node* n = root->L;
while (n->L) { n = n->L; }
return n;
} | [
"Node",
"*",
"FindMin",
"(",
"Node",
"*",
"root",
")",
"{",
"if",
"(",
"root",
"->",
"IsLeaf",
"(",
")",
")",
"{",
"return",
"root",
";",
"}",
"Node",
"*",
"n",
"=",
"root",
"->",
"L",
";",
"while",
"(",
"n",
"->",
"L",
")",
"{",
"n",
"=",
"n",
"->",
"L",
";",
"}",
"return",
"n",
";",
"}"
] | Finds and returns the node containing the minimum value in the subtree. | [
"Finds",
"and",
"returns",
"the",
"node",
"containing",
"the",
"minimum",
"value",
"in",
"the",
"subtree",
"."
] | [] | [
{
"param": "root",
"type": "Node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "root",
"type": "Node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
538be52b3418fd1b08516d28bae6fabc2aee677a | justin-harper/cs223 | HW7/PQ_Heap.h | [
"MIT"
] | C | maxChild | int | int maxChild(int parentIndex)
{
int index = -1;
T max = *m_heap[parentIndex];
//child nodes are located at kn+1 ..kn+2 ..kn+k
for (int i = 1; i <= m_k; i++)
{
//make sure (m_k*parentIndex) + i is within bounds of m_heap
if ((m_k*parentIndex) + i > m_lastUsedIndex)
{
//(m_k*parentIndex) + i > LastIndexUsed is outside the bounds
//there are no more children ... no need to continue checking
return index;
}
if (max < *m_heap[(m_k*parentIndex) + i])
{
max =*m_heap[(m_k*parentIndex) + i];
index = (m_k*parentIndex) + i;
}
}
//all k children exist return index of greatest
return index;
} | //returns index of child with max value | returns index of child with max value | [
"returns",
"index",
"of",
"child",
"with",
"max",
"value"
] | int maxChild(int parentIndex)
{
int index = -1;
T max = *m_heap[parentIndex];
for (int i = 1; i <= m_k; i++)
{
if ((m_k*parentIndex) + i > m_lastUsedIndex)
{
return index;
}
if (max < *m_heap[(m_k*parentIndex) + i])
{
max =*m_heap[(m_k*parentIndex) + i];
index = (m_k*parentIndex) + i;
}
}
return index;
} | [
"int",
"maxChild",
"(",
"int",
"parentIndex",
")",
"{",
"int",
"index",
"=",
"-1",
";",
"T",
"max",
"=",
"*",
"m_heap",
"[",
"parentIndex",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"m_k",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"m_k",
"*",
"parentIndex",
")",
"+",
"i",
">",
"m_lastUsedIndex",
")",
"{",
"return",
"index",
";",
"}",
"if",
"(",
"max",
"<",
"*",
"m_heap",
"[",
"(",
"m_k",
"*",
"parentIndex",
")",
"+",
"i",
"]",
")",
"{",
"max",
"=",
"*",
"m_heap",
"[",
"(",
"m_k",
"*",
"parentIndex",
")",
"+",
"i",
"]",
";",
"index",
"=",
"(",
"m_k",
"*",
"parentIndex",
")",
"+",
"i",
";",
"}",
"}",
"return",
"index",
";",
"}"
] | returns index of child with max value | [
"returns",
"index",
"of",
"child",
"with",
"max",
"value"
] | [
"//child nodes are located at kn+1 ..kn+2 ..kn+k",
"//make sure (m_k*parentIndex) + i is within bounds of m_heap",
"//(m_k*parentIndex) + i > LastIndexUsed is outside the bounds",
"//there are no more children ... no need to continue checking",
"//all k children exist return index of greatest"
] | [
{
"param": "parentIndex",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "parentIndex",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5384305b0337e7a7a53028796f51fa4f687defc8 | y11en/BranchMonitoringProject | BranchMonitor.Multi-page/src/BTS/BTS.c | [
"MIT"
] | C | FILL_DS_WITH_BUFFER | void | void FILL_DS_WITH_BUFFER(PTDS_BASE DS_BASE,PTBTS_BUFFER BTS_BUFFER)
{
debug("Filling DS with bts addresses");
/* BTS BUFFER BASE */
DS_BASE->BUFFER_BASE=BTS_BUFFER;
/* BTS INDEX */
DS_BASE->BTS_INDEX=BTS_BUFFER;
/* BTS MAX */
DS_BASE->MAXIMUM=(PTBTS_BUFFER)(((UINT_PTR)BTS_BUFFER)+(SIZE_BTS_BUFFER*sizeof(TBTS_BUFFER)));
/* BTS Threshold */
DS_BASE->THRESHOLD=(PTBTS_BUFFER)(((UINT_PTR)BTS_BUFFER)+(THRESHOLD_BTS_BUFFER*sizeof(TBTS_BUFFER)));
} | /* Configure offsets and threshold on DS_AREA */ | Configure offsets and threshold on DS_AREA | [
"Configure",
"offsets",
"and",
"threshold",
"on",
"DS_AREA"
] | void FILL_DS_WITH_BUFFER(PTDS_BASE DS_BASE,PTBTS_BUFFER BTS_BUFFER)
{
debug("Filling DS with bts addresses");
DS_BASE->BUFFER_BASE=BTS_BUFFER;
DS_BASE->BTS_INDEX=BTS_BUFFER;
DS_BASE->MAXIMUM=(PTBTS_BUFFER)(((UINT_PTR)BTS_BUFFER)+(SIZE_BTS_BUFFER*sizeof(TBTS_BUFFER)));
DS_BASE->THRESHOLD=(PTBTS_BUFFER)(((UINT_PTR)BTS_BUFFER)+(THRESHOLD_BTS_BUFFER*sizeof(TBTS_BUFFER)));
} | [
"void",
"FILL_DS_WITH_BUFFER",
"(",
"PTDS_BASE",
"DS_BASE",
",",
"PTBTS_BUFFER",
"BTS_BUFFER",
")",
"{",
"debug",
"(",
"\"",
"\"",
")",
";",
"DS_BASE",
"->",
"BUFFER_BASE",
"=",
"BTS_BUFFER",
";",
"DS_BASE",
"->",
"BTS_INDEX",
"=",
"BTS_BUFFER",
";",
"DS_BASE",
"->",
"MAXIMUM",
"=",
"(",
"PTBTS_BUFFER",
")",
"(",
"(",
"(",
"UINT_PTR",
")",
"BTS_BUFFER",
")",
"+",
"(",
"SIZE_BTS_BUFFER",
"*",
"sizeof",
"(",
"TBTS_BUFFER",
")",
")",
")",
";",
"DS_BASE",
"->",
"THRESHOLD",
"=",
"(",
"PTBTS_BUFFER",
")",
"(",
"(",
"(",
"UINT_PTR",
")",
"BTS_BUFFER",
")",
"+",
"(",
"THRESHOLD_BTS_BUFFER",
"*",
"sizeof",
"(",
"TBTS_BUFFER",
")",
")",
")",
";",
"}"
] | Configure offsets and threshold on DS_AREA | [
"Configure",
"offsets",
"and",
"threshold",
"on",
"DS_AREA"
] | [
"/* BTS BUFFER BASE */",
"/* BTS INDEX */",
"/* BTS MAX */",
"/* BTS Threshold */"
] | [
{
"param": "DS_BASE",
"type": "PTDS_BASE"
},
{
"param": "BTS_BUFFER",
"type": "PTBTS_BUFFER"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DS_BASE",
"type": "PTDS_BASE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "BTS_BUFFER",
"type": "PTBTS_BUFFER",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
17e4ba582a3d7e0e15756a21c4fcd19f4e0bf19e | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/IO/IO.c | [
"MIT"
] | C | Read | NTSTATUS | NTSTATUS Read(PDEVICE_OBJECT DeviceObject,PIRP Irp)
{
TBTS_BUFFER bdata;
PVOID userbuffer;
PIO_STACK_LOCATION PIO_STACK_IRP;
UINT32 datasize,sizerequired;
NTSTATUS NtStatus=STATUS_SUCCESS;
UNREFERENCED_PARAMETER(DeviceObject);
NtStatus=STATUS_SUCCESS;
/* remove an item from list */
if(Remove_List(&bdata)==TRUE)
{
/* if data is available, copy to userland */
userbuffer=Irp->AssociatedIrp.SystemBuffer;
PIO_STACK_IRP=IoGetCurrentIrpStackLocation(Irp);
if(PIO_STACK_IRP && userbuffer)
{
datasize=PIO_STACK_IRP->Parameters.Read.Length;
sizerequired=sizeof(TBTS_BUFFER);
if(datasize>=sizerequired){
memcpy(userbuffer,&bdata,sizerequired);
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = sizerequired;
}else{
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
}else{
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
}else{
/* if not available, no data is written */
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return NtStatus;
} | /* Write data from driver to the userland stack */ | Write data from driver to the userland stack | [
"Write",
"data",
"from",
"driver",
"to",
"the",
"userland",
"stack"
] | NTSTATUS Read(PDEVICE_OBJECT DeviceObject,PIRP Irp)
{
TBTS_BUFFER bdata;
PVOID userbuffer;
PIO_STACK_LOCATION PIO_STACK_IRP;
UINT32 datasize,sizerequired;
NTSTATUS NtStatus=STATUS_SUCCESS;
UNREFERENCED_PARAMETER(DeviceObject);
NtStatus=STATUS_SUCCESS;
if(Remove_List(&bdata)==TRUE)
{
userbuffer=Irp->AssociatedIrp.SystemBuffer;
PIO_STACK_IRP=IoGetCurrentIrpStackLocation(Irp);
if(PIO_STACK_IRP && userbuffer)
{
datasize=PIO_STACK_IRP->Parameters.Read.Length;
sizerequired=sizeof(TBTS_BUFFER);
if(datasize>=sizerequired){
memcpy(userbuffer,&bdata,sizerequired);
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = sizerequired;
}else{
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
}else{
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
}else{
Irp->IoStatus.Status = NtStatus;
Irp->IoStatus.Information = 0;
}
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return NtStatus;
} | [
"NTSTATUS",
"Read",
"(",
"PDEVICE_OBJECT",
"DeviceObject",
",",
"PIRP",
"Irp",
")",
"{",
"TBTS_BUFFER",
"bdata",
";",
"PVOID",
"userbuffer",
";",
"PIO_STACK_LOCATION",
"PIO_STACK_IRP",
";",
"UINT32",
"datasize",
",",
"sizerequired",
";",
"NTSTATUS",
"NtStatus",
"=",
"STATUS_SUCCESS",
";",
"UNREFERENCED_PARAMETER",
"(",
"DeviceObject",
")",
";",
"NtStatus",
"=",
"STATUS_SUCCESS",
";",
"if",
"(",
"Remove_List",
"(",
"&",
"bdata",
")",
"==",
"TRUE",
")",
"{",
"userbuffer",
"=",
"Irp",
"->",
"AssociatedIrp",
".",
"SystemBuffer",
";",
"PIO_STACK_IRP",
"=",
"IoGetCurrentIrpStackLocation",
"(",
"Irp",
")",
";",
"if",
"(",
"PIO_STACK_IRP",
"&&",
"userbuffer",
")",
"{",
"datasize",
"=",
"PIO_STACK_IRP",
"->",
"Parameters",
".",
"Read",
".",
"Length",
";",
"sizerequired",
"=",
"sizeof",
"(",
"TBTS_BUFFER",
")",
";",
"if",
"(",
"datasize",
">=",
"sizerequired",
")",
"{",
"memcpy",
"(",
"userbuffer",
",",
"&",
"bdata",
",",
"sizerequired",
")",
";",
"Irp",
"->",
"IoStatus",
".",
"Status",
"=",
"NtStatus",
";",
"Irp",
"->",
"IoStatus",
".",
"Information",
"=",
"sizerequired",
";",
"}",
"else",
"{",
"Irp",
"->",
"IoStatus",
".",
"Status",
"=",
"NtStatus",
";",
"Irp",
"->",
"IoStatus",
".",
"Information",
"=",
"0",
";",
"}",
"}",
"else",
"{",
"Irp",
"->",
"IoStatus",
".",
"Status",
"=",
"NtStatus",
";",
"Irp",
"->",
"IoStatus",
".",
"Information",
"=",
"0",
";",
"}",
"}",
"else",
"{",
"Irp",
"->",
"IoStatus",
".",
"Status",
"=",
"NtStatus",
";",
"Irp",
"->",
"IoStatus",
".",
"Information",
"=",
"0",
";",
"}",
"IoCompleteRequest",
"(",
"Irp",
",",
"IO_NO_INCREMENT",
")",
";",
"return",
"NtStatus",
";",
"}"
] | Write data from driver to the userland stack | [
"Write",
"data",
"from",
"driver",
"to",
"the",
"userland",
"stack"
] | [
"/* remove an item from list */",
"/* if data is available, copy to userland */",
"/* if not available, no data is written */"
] | [
{
"param": "DeviceObject",
"type": "PDEVICE_OBJECT"
},
{
"param": "Irp",
"type": "PIRP"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DeviceObject",
"type": "PDEVICE_OBJECT",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Irp",
"type": "PIRP",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
17e4ba582a3d7e0e15756a21c4fcd19f4e0bf19e | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/IO/IO.c | [
"MIT"
] | C | NotSupported | NTSTATUS | NTSTATUS NotSupported(PDEVICE_OBJECT DeviceObject,PIRP Irp)
{
NTSTATUS status;
UNREFERENCED_PARAMETER(DeviceObject);
debug("Not Supported I/O operation");
Irp->IoStatus.Status=STATUS_NOT_SUPPORTED;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
status = STATUS_NOT_SUPPORTED;
return status;
} | /* generic routine to support non-implemented I/O */ | generic routine to support non-implemented I/O | [
"generic",
"routine",
"to",
"support",
"non",
"-",
"implemented",
"I",
"/",
"O"
] | NTSTATUS NotSupported(PDEVICE_OBJECT DeviceObject,PIRP Irp)
{
NTSTATUS status;
UNREFERENCED_PARAMETER(DeviceObject);
debug("Not Supported I/O operation");
Irp->IoStatus.Status=STATUS_NOT_SUPPORTED;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
status = STATUS_NOT_SUPPORTED;
return status;
} | [
"NTSTATUS",
"NotSupported",
"(",
"PDEVICE_OBJECT",
"DeviceObject",
",",
"PIRP",
"Irp",
")",
"{",
"NTSTATUS",
"status",
";",
"UNREFERENCED_PARAMETER",
"(",
"DeviceObject",
")",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"Irp",
"->",
"IoStatus",
".",
"Status",
"=",
"STATUS_NOT_SUPPORTED",
";",
"IoCompleteRequest",
"(",
"Irp",
",",
"IO_NO_INCREMENT",
")",
";",
"status",
"=",
"STATUS_NOT_SUPPORTED",
";",
"return",
"status",
";",
"}"
] | generic routine to support non-implemented I/O | [
"generic",
"routine",
"to",
"support",
"non",
"-",
"implemented",
"I",
"/",
"O"
] | [] | [
{
"param": "DeviceObject",
"type": "PDEVICE_OBJECT"
},
{
"param": "Irp",
"type": "PIRP"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DeviceObject",
"type": "PDEVICE_OBJECT",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Irp",
"type": "PIRP",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f798da2176ba8074f2968162a5ef972e1a8e9b63 | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/device/device.c | [
"MIT"
] | C | CreateDevice | NTSTATUS | NTSTATUS CreateDevice(PDRIVER_OBJECT DriverObject)
{
int i;
NTSTATUS status;
PDEVICE_OBJECT dev;
UNICODE_STRING namestring,linkstring;
debug("Creating Device");
RtlInitUnicodeString(&namestring,DRIVERNAME);
status=IoCreateDevice(DriverObject,0,&namestring,FILE_DEVICE_DISK_FILE_SYSTEM,FILE_DEVICE_SECURE_OPEN,FALSE,&dev);
if(!NT_SUCCESS(status))
{
debug("Error Creating Device");
return status; /* In Case of failing */
}
DriverObject->DeviceObject=dev;
RtlInitUnicodeString(&linkstring,DOSDRIVERNAME);
status=IoCreateSymbolicLink(&linkstring,&namestring); /* Linking the name */
if(!NT_SUCCESS(status))
{
debug("Error Creating Link");
IoDeleteDevice(dev); /* Error, remove and unload */
return status;
}
/* registering generic I/O routines */
for(i=0;i<IRP_MJ_MAXIMUM_FUNCTION;i++)
{
DriverObject->MajorFunction[i]=NotSupported;
}
/* registering specific I/O routines */
DriverObject->MajorFunction[IRP_MJ_CREATE]=Create;
DriverObject->MajorFunction[IRP_MJ_READ]=Read;
DriverObject->MajorFunction[IRP_MJ_CLOSE]=Close;
dev->Flags|=DO_BUFFERED_IO;
return STATUS_SUCCESS;
} | /* Create Device Routine
* THis driver will work as a FS resource
* You can open a handle to this driver
*/ | Create Device Routine
THis driver will work as a FS resource
You can open a handle to this driver | [
"Create",
"Device",
"Routine",
"THis",
"driver",
"will",
"work",
"as",
"a",
"FS",
"resource",
"You",
"can",
"open",
"a",
"handle",
"to",
"this",
"driver"
] | NTSTATUS CreateDevice(PDRIVER_OBJECT DriverObject)
{
int i;
NTSTATUS status;
PDEVICE_OBJECT dev;
UNICODE_STRING namestring,linkstring;
debug("Creating Device");
RtlInitUnicodeString(&namestring,DRIVERNAME);
status=IoCreateDevice(DriverObject,0,&namestring,FILE_DEVICE_DISK_FILE_SYSTEM,FILE_DEVICE_SECURE_OPEN,FALSE,&dev);
if(!NT_SUCCESS(status))
{
debug("Error Creating Device");
return status;
}
DriverObject->DeviceObject=dev;
RtlInitUnicodeString(&linkstring,DOSDRIVERNAME);
status=IoCreateSymbolicLink(&linkstring,&namestring);
if(!NT_SUCCESS(status))
{
debug("Error Creating Link");
IoDeleteDevice(dev);
return status;
}
for(i=0;i<IRP_MJ_MAXIMUM_FUNCTION;i++)
{
DriverObject->MajorFunction[i]=NotSupported;
}
DriverObject->MajorFunction[IRP_MJ_CREATE]=Create;
DriverObject->MajorFunction[IRP_MJ_READ]=Read;
DriverObject->MajorFunction[IRP_MJ_CLOSE]=Close;
dev->Flags|=DO_BUFFERED_IO;
return STATUS_SUCCESS;
} | [
"NTSTATUS",
"CreateDevice",
"(",
"PDRIVER_OBJECT",
"DriverObject",
")",
"{",
"int",
"i",
";",
"NTSTATUS",
"status",
";",
"PDEVICE_OBJECT",
"dev",
";",
"UNICODE_STRING",
"namestring",
",",
"linkstring",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"RtlInitUnicodeString",
"(",
"&",
"namestring",
",",
"DRIVERNAME",
")",
";",
"status",
"=",
"IoCreateDevice",
"(",
"DriverObject",
",",
"0",
",",
"&",
"namestring",
",",
"FILE_DEVICE_DISK_FILE_SYSTEM",
",",
"FILE_DEVICE_SECURE_OPEN",
",",
"FALSE",
",",
"&",
"dev",
")",
";",
"if",
"(",
"!",
"NT_SUCCESS",
"(",
"status",
")",
")",
"{",
"debug",
"(",
"\"",
"\"",
")",
";",
"return",
"status",
";",
"}",
"DriverObject",
"->",
"DeviceObject",
"=",
"dev",
";",
"RtlInitUnicodeString",
"(",
"&",
"linkstring",
",",
"DOSDRIVERNAME",
")",
";",
"status",
"=",
"IoCreateSymbolicLink",
"(",
"&",
"linkstring",
",",
"&",
"namestring",
")",
";",
"if",
"(",
"!",
"NT_SUCCESS",
"(",
"status",
")",
")",
"{",
"debug",
"(",
"\"",
"\"",
")",
";",
"IoDeleteDevice",
"(",
"dev",
")",
";",
"return",
"status",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"IRP_MJ_MAXIMUM_FUNCTION",
";",
"i",
"++",
")",
"{",
"DriverObject",
"->",
"MajorFunction",
"[",
"i",
"]",
"=",
"NotSupported",
";",
"}",
"DriverObject",
"->",
"MajorFunction",
"[",
"IRP_MJ_CREATE",
"]",
"=",
"Create",
";",
"DriverObject",
"->",
"MajorFunction",
"[",
"IRP_MJ_READ",
"]",
"=",
"Read",
";",
"DriverObject",
"->",
"MajorFunction",
"[",
"IRP_MJ_CLOSE",
"]",
"=",
"Close",
";",
"dev",
"->",
"Flags",
"|=",
"DO_BUFFERED_IO",
";",
"return",
"STATUS_SUCCESS",
";",
"}"
] | Create Device Routine
THis driver will work as a FS resource
You can open a handle to this driver | [
"Create",
"Device",
"Routine",
"THis",
"driver",
"will",
"work",
"as",
"a",
"FS",
"resource",
"You",
"can",
"open",
"a",
"handle",
"to",
"this",
"driver"
] | [
"/* In Case of failing */",
"/* Linking the name */",
"/* Error, remove and unload */",
"/* registering generic I/O routines */",
"/* registering specific I/O routines */"
] | [
{
"param": "DriverObject",
"type": "PDRIVER_OBJECT"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DriverObject",
"type": "PDRIVER_OBJECT",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f94a87881bc0d44bb78d36952d59bbfe53d1e3 | y11en/BranchMonitoringProject | Debugger/Driver/VoiDbg/src/Driver.c | [
"MIT"
] | C | thread_attach_to_core | void | void thread_attach_to_core(unsigned id)
{
KAFFINITY mask;
#pragma warning( disable : 4305 )
#pragma warning( disable : 4334 )
mask=1<<id;
KeSetSystemAffinityThread(mask);
} | /* attach thread to a given core */ | attach thread to a given core | [
"attach",
"thread",
"to",
"a",
"given",
"core"
] | void thread_attach_to_core(unsigned id)
{
KAFFINITY mask;
#pragma warning( disable : 4305 )
#pragma warning( disable : 4334 )
mask=1<<id;
KeSetSystemAffinityThread(mask);
} | [
"void",
"thread_attach_to_core",
"(",
"unsigned",
"id",
")",
"{",
"KAFFINITY",
"mask",
";",
"#pragma",
" warning( disable : 4305 )\r",
"\n",
"#pragma",
" warning( disable : 4334 )\r",
"\n",
"mask",
"=",
"1",
"<<",
"id",
";",
"KeSetSystemAffinityThread",
"(",
"mask",
")",
";",
"}"
] | attach thread to a given core | [
"attach",
"thread",
"to",
"a",
"given",
"core"
] | [] | [
{
"param": "id",
"type": "unsigned"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f94a87881bc0d44bb78d36952d59bbfe53d1e3 | y11en/BranchMonitoringProject | Debugger/Driver/VoiDbg/src/Driver.c | [
"MIT"
] | C | InvertedNotify | VOID | VOID InvertedNotify(PINVERTED_DEVICE_CONTEXT DevContext)
{
NTSTATUS status;
ULONG_PTR info;
WDFREQUEST notifyRequest;
PULONG bufferPointer;
LONG valueToReturn;
/* Get cached I/O Request */
status = WdfIoQueueRetrieveNextRequest(DevContext->NotificationQueue,¬ifyRequest);
/* Case no request available */
if(!NT_SUCCESS(status)) {
dbg_print(NO_CACHED_IO);
return;
}
/* get the output buffer */
status = WdfRequestRetrieveOutputBuffer(notifyRequest,sizeof(LONG),(PVOID*)&bufferPointer,NULL);
/* case cannot get buffer */
if(!NT_SUCCESS(status)) {
dbg_print(GET_OUT_BUFFER_ERROR);
status = STATUS_SUCCESS;
/* No Data Returned */
info = NO_DATA_RETURNED;
} else {
/* Data to Return */
/* We are returning the number of BTS entries */
valueToReturn = InterlockedExchangeAdd(&DevContext->Sequence,THRESHOLD_BTS_BUFFER);
*bufferPointer = valueToReturn;
status = STATUS_SUCCESS;
/* return data size */
info = sizeof(THRESHOLD_BTS_BUFFER);
}
/* Complete I/O */
WdfRequestCompleteWithInformation(notifyRequest, status, info);
} | /* Inverted I/O Implementation
* This function implements the interrupt notification
*/ | Inverted I/O Implementation
This function implements the interrupt notification | [
"Inverted",
"I",
"/",
"O",
"Implementation",
"This",
"function",
"implements",
"the",
"interrupt",
"notification"
] | VOID InvertedNotify(PINVERTED_DEVICE_CONTEXT DevContext)
{
NTSTATUS status;
ULONG_PTR info;
WDFREQUEST notifyRequest;
PULONG bufferPointer;
LONG valueToReturn;
status = WdfIoQueueRetrieveNextRequest(DevContext->NotificationQueue,¬ifyRequest);
if(!NT_SUCCESS(status)) {
dbg_print(NO_CACHED_IO);
return;
}
status = WdfRequestRetrieveOutputBuffer(notifyRequest,sizeof(LONG),(PVOID*)&bufferPointer,NULL);
if(!NT_SUCCESS(status)) {
dbg_print(GET_OUT_BUFFER_ERROR);
status = STATUS_SUCCESS;
info = NO_DATA_RETURNED;
} else {
valueToReturn = InterlockedExchangeAdd(&DevContext->Sequence,THRESHOLD_BTS_BUFFER);
*bufferPointer = valueToReturn;
status = STATUS_SUCCESS;
info = sizeof(THRESHOLD_BTS_BUFFER);
}
WdfRequestCompleteWithInformation(notifyRequest, status, info);
} | [
"VOID",
"InvertedNotify",
"(",
"PINVERTED_DEVICE_CONTEXT",
"DevContext",
")",
"{",
"NTSTATUS",
"status",
";",
"ULONG_PTR",
"info",
";",
"WDFREQUEST",
"notifyRequest",
";",
"PULONG",
"bufferPointer",
";",
"LONG",
"valueToReturn",
";",
"status",
"=",
"WdfIoQueueRetrieveNextRequest",
"(",
"DevContext",
"->",
"NotificationQueue",
",",
"&",
"notifyRequest",
")",
";",
"if",
"(",
"!",
"NT_SUCCESS",
"(",
"status",
")",
")",
"{",
"dbg_print",
"(",
"NO_CACHED_IO",
")",
";",
"return",
";",
"}",
"status",
"=",
"WdfRequestRetrieveOutputBuffer",
"(",
"notifyRequest",
",",
"sizeof",
"(",
"LONG",
")",
",",
"(",
"PVOID",
"*",
")",
"&",
"bufferPointer",
",",
"NULL",
")",
";",
"if",
"(",
"!",
"NT_SUCCESS",
"(",
"status",
")",
")",
"{",
"dbg_print",
"(",
"GET_OUT_BUFFER_ERROR",
")",
";",
"status",
"=",
"STATUS_SUCCESS",
";",
"info",
"=",
"NO_DATA_RETURNED",
";",
"}",
"else",
"{",
"valueToReturn",
"=",
"InterlockedExchangeAdd",
"(",
"&",
"DevContext",
"->",
"Sequence",
",",
"THRESHOLD_BTS_BUFFER",
")",
";",
"*",
"bufferPointer",
"=",
"valueToReturn",
";",
"status",
"=",
"STATUS_SUCCESS",
";",
"info",
"=",
"sizeof",
"(",
"THRESHOLD_BTS_BUFFER",
")",
";",
"}",
"WdfRequestCompleteWithInformation",
"(",
"notifyRequest",
",",
"status",
",",
"info",
")",
";",
"}"
] | Inverted I/O Implementation
This function implements the interrupt notification | [
"Inverted",
"I",
"/",
"O",
"Implementation",
"This",
"function",
"implements",
"the",
"interrupt",
"notification"
] | [
"/* Get cached I/O Request */",
"/* Case no request available */",
"/* get the output buffer */",
"/* case cannot get buffer */",
"/* No Data Returned */",
"/* Data to Return */",
"/* We are returning the number of BTS entries */",
"/* return data size */",
"/* Complete I/O */"
] | [
{
"param": "DevContext",
"type": "PINVERTED_DEVICE_CONTEXT"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DevContext",
"type": "PINVERTED_DEVICE_CONTEXT",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
554dfd383bb7c1f6039ee1817a4be1239aa48284 | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/checks/apic/apic.c | [
"MIT"
] | C | check_apic | int | int check_apic()
{
UINT64 apic_base;
debug("Checking APIC");
/* read APIC MSR */
apic_base=(__readmsr(MSR_APIC_BASE) & (APIC_MASK));
/* check the default value */
if((apic_base>>APIC_MASK_OFFSET)!=APIC_BASE_VALUE)
{
return APIC_WAS_REMAPPED;
/* TODO: support apic remap
* Save apic_base value for further usage
* APIC value is located at the +0x340 offset
*/
}
return NO_ERROR;
} | /* Perform APIC check
* This driver works when APIC is not relocated
* In case it was relocated, an error is raised
*/ | Perform APIC check
This driver works when APIC is not relocated
In case it was relocated, an error is raised | [
"Perform",
"APIC",
"check",
"This",
"driver",
"works",
"when",
"APIC",
"is",
"not",
"relocated",
"In",
"case",
"it",
"was",
"relocated",
"an",
"error",
"is",
"raised"
] | int check_apic()
{
UINT64 apic_base;
debug("Checking APIC");
apic_base=(__readmsr(MSR_APIC_BASE) & (APIC_MASK));
if((apic_base>>APIC_MASK_OFFSET)!=APIC_BASE_VALUE)
{
return APIC_WAS_REMAPPED;
}
return NO_ERROR;
} | [
"int",
"check_apic",
"(",
")",
"{",
"UINT64",
"apic_base",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"apic_base",
"=",
"(",
"__readmsr",
"(",
"MSR_APIC_BASE",
")",
"&",
"(",
"APIC_MASK",
")",
")",
";",
"if",
"(",
"(",
"apic_base",
">>",
"APIC_MASK_OFFSET",
")",
"!=",
"APIC_BASE_VALUE",
")",
"{",
"return",
"APIC_WAS_REMAPPED",
";",
"}",
"return",
"NO_ERROR",
";",
"}"
] | Perform APIC check
This driver works when APIC is not relocated
In case it was relocated, an error is raised | [
"Perform",
"APIC",
"check",
"This",
"driver",
"works",
"when",
"APIC",
"is",
"not",
"relocated",
"In",
"case",
"it",
"was",
"relocated",
"an",
"error",
"is",
"raised"
] | [
"/* read APIC MSR */",
"/* check the default value */",
"/* TODO: support apic remap\r\n\t\t * Save apic_base value for further usage\r\n\t\t * APIC value is located at the +0x340 offset\r\n\t\t */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ba3cd0022fa5e8cb25a230cbbf1980eb0dd362f | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/checks/cpu/cpuid.c | [
"MIT"
] | C | check_is_64 | int | int check_is_64()
{
int regs[CPUID_NUM_REGS];
debug("Checking x64 CPU");
/* cpuid processor features - eax = 1 */
__cpuid(regs,CPUID_PROC_FEATURES);
/* 64 bits DS = ECX[2]=1 */
if(CHECK_BIT(regs[REG_ECX],x64_BITS_OFFSET)==BIT_ENABLED)
{
return NO_ERROR;
}
return CPU_IS_NOT_64;
} | /* check if DS structure is 64 bits */ | check if DS structure is 64 bits | [
"check",
"if",
"DS",
"structure",
"is",
"64",
"bits"
] | int check_is_64()
{
int regs[CPUID_NUM_REGS];
debug("Checking x64 CPU");
__cpuid(regs,CPUID_PROC_FEATURES);
if(CHECK_BIT(regs[REG_ECX],x64_BITS_OFFSET)==BIT_ENABLED)
{
return NO_ERROR;
}
return CPU_IS_NOT_64;
} | [
"int",
"check_is_64",
"(",
")",
"{",
"int",
"regs",
"[",
"CPUID_NUM_REGS",
"]",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"__cpuid",
"(",
"regs",
",",
"CPUID_PROC_FEATURES",
")",
";",
"if",
"(",
"CHECK_BIT",
"(",
"regs",
"[",
"REG_ECX",
"]",
",",
"x64_BITS_OFFSET",
")",
"==",
"BIT_ENABLED",
")",
"{",
"return",
"NO_ERROR",
";",
"}",
"return",
"CPU_IS_NOT_64",
";",
"}"
] | check if DS structure is 64 bits | [
"check",
"if",
"DS",
"structure",
"is",
"64",
"bits"
] | [
"/* cpuid processor features - eax = 1 */",
"/* 64 bits DS = ECX[2]=1 */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ba3cd0022fa5e8cb25a230cbbf1980eb0dd362f | y11en/BranchMonitoringProject | BranchMonitor.PMI/src/checks/cpu/cpuid.c | [
"MIT"
] | C | check_has_ds | int | int check_has_ds()
{
int regs[CPUID_NUM_REGS];
debug("Check DS support");
__cpuid(regs,CPUID_PROC_FEATURES);
/* EDX[21]=1 */
if(CHECK_BIT(regs[REG_EDX],DS_BIT_OFFSET)==BIT_ENABLED)
{
return NO_ERROR;
}
return CPU_HAS_NO_DS;
} | /* Check if debug store capabilitie is present */ | Check if debug store capabilitie is present | [
"Check",
"if",
"debug",
"store",
"capabilitie",
"is",
"present"
] | int check_has_ds()
{
int regs[CPUID_NUM_REGS];
debug("Check DS support");
__cpuid(regs,CPUID_PROC_FEATURES);
if(CHECK_BIT(regs[REG_EDX],DS_BIT_OFFSET)==BIT_ENABLED)
{
return NO_ERROR;
}
return CPU_HAS_NO_DS;
} | [
"int",
"check_has_ds",
"(",
")",
"{",
"int",
"regs",
"[",
"CPUID_NUM_REGS",
"]",
";",
"debug",
"(",
"\"",
"\"",
")",
";",
"__cpuid",
"(",
"regs",
",",
"CPUID_PROC_FEATURES",
")",
";",
"if",
"(",
"CHECK_BIT",
"(",
"regs",
"[",
"REG_EDX",
"]",
",",
"DS_BIT_OFFSET",
")",
"==",
"BIT_ENABLED",
")",
"{",
"return",
"NO_ERROR",
";",
"}",
"return",
"CPU_HAS_NO_DS",
";",
"}"
] | Check if debug store capabilitie is present | [
"Check",
"if",
"debug",
"store",
"capabilitie",
"is",
"present"
] | [
"/* EDX[21]=1 */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.