mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-09 23:08:12 +00:00
Adds SX1276_DetectChip() function (#373)
* Adds SX1276_DetectChip() function works by testing for 0x12 match in version reg 0x42 * fix build err
This commit is contained in:
parent
79b525ee71
commit
908634474b
@ -42,6 +42,39 @@ uint8_t SX1276_Reset()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SX1276_DetectChip() //to be called after reset, verfies the chip has been detected
|
||||||
|
{
|
||||||
|
#define MaxAttempts 5
|
||||||
|
uint8_t i = 0;
|
||||||
|
bool chipFound = false;
|
||||||
|
while ((i < MaxAttempts) && !chipFound)
|
||||||
|
{
|
||||||
|
uint8_t ChipVersion = SX1276_ReadReg(0x42);
|
||||||
|
if (ChipVersion == 0x12)
|
||||||
|
{
|
||||||
|
debugln("SX1276 reg version=%d", ChipVersion);
|
||||||
|
chipFound = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("SX1276 not found! attempts: %d", i);
|
||||||
|
debug(" of ");
|
||||||
|
debugln("%d SX1276 reg version=%d", MaxAttempts, ChipVersion);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!chipFound)
|
||||||
|
{
|
||||||
|
debugln("SX1276 not detected!!!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debugln("Found SX1276 Device!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SX1276_SetTxRxMode(uint8_t mode)
|
void SX1276_SetTxRxMode(uint8_t mode)
|
||||||
{
|
{
|
||||||
#ifdef SX1276_TXEN_pin
|
#ifdef SX1276_TXEN_pin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user