Release 0.1
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
#include "DS_I2CScanner.h"
|
||||
|
||||
void DS_I2CScan(I2C_HandleTypeDef *I2C)
|
||||
void DS_I2CScan(I2C_HandleTypeDef *I2C, uint8_t *Result, uint8_t maxNumResults)
|
||||
{
|
||||
|
||||
HAL_StatusTypeDef HAL_result = HAL_ERROR;
|
||||
uint8_t NumOfResult = 0;
|
||||
|
||||
for (uint8_t i = 0; i < maxNumResults - 1; i++)
|
||||
{
|
||||
Result[i] = 0;
|
||||
}
|
||||
|
||||
for (uint8_t addr = 0; addr < 0xFF; ++addr)
|
||||
{
|
||||
HAL_result = HAL_I2C_IsDeviceReady(I2C, addr, 3, 1000);
|
||||
if (HAL_result == HAL_OK)
|
||||
{
|
||||
Result[NumOfResult] = addr;
|
||||
if (NumOfResult < maxNumResults - 1)
|
||||
{
|
||||
NumOfResult++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user