mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
fix reset chip
This commit is contained in:
parent
4cdf6d4ffe
commit
338aa1b825
@ -122,6 +122,8 @@ void TpUartDataLinkLayer::enterRxWaitEOP()
|
|||||||
void TpUartDataLinkLayer::loop()
|
void TpUartDataLinkLayer::loop()
|
||||||
{
|
{
|
||||||
if (!_enabled)
|
if (!_enabled)
|
||||||
|
{
|
||||||
|
if(_waitConfirmStartTime == 0)
|
||||||
{
|
{
|
||||||
if (millis() - _lastResetChipTime > 1000)
|
if (millis() - _lastResetChipTime > 1000)
|
||||||
{
|
{
|
||||||
@ -129,6 +131,9 @@ void TpUartDataLinkLayer::loop()
|
|||||||
_lastResetChipTime = millis();
|
_lastResetChipTime = millis();
|
||||||
_enabled = resetChip();
|
_enabled = resetChip();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_enabled = resetChipTick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_enabled)
|
if (!_enabled)
|
||||||
@ -485,17 +490,30 @@ bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame)
|
|||||||
|
|
||||||
bool TpUartDataLinkLayer::resetChip()
|
bool TpUartDataLinkLayer::resetChip()
|
||||||
{
|
{
|
||||||
|
if(_waitConfirmStartTime > 0) return false;
|
||||||
uint8_t cmd = U_RESET_REQ;
|
uint8_t cmd = U_RESET_REQ;
|
||||||
_platform.writeUart(cmd);
|
_platform.writeUart(cmd);
|
||||||
_waitConfirmStartTime = millis();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int resp = _platform.readUart();
|
int resp = _platform.readUart();
|
||||||
if (resp == U_RESET_IND)
|
if (resp == U_RESET_IND)
|
||||||
return true;
|
return true;
|
||||||
else if (millis() - _waitConfirmStartTime > RESET_TIMEOUT)
|
|
||||||
|
_waitConfirmStartTime = millis();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TpUartDataLinkLayer::resetChipTick()
|
||||||
|
{
|
||||||
|
int resp = _platform.readUart();
|
||||||
|
if (resp == U_RESET_IND)
|
||||||
|
{
|
||||||
|
_waitConfirmStartTime = 0;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (millis() - _waitConfirmStartTime > RESET_TIMEOUT)
|
||||||
|
_waitConfirmStartTime = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TpUartDataLinkLayer::stopChip()
|
void TpUartDataLinkLayer::stopChip()
|
||||||
|
@ -45,7 +45,7 @@ class TpUartDataLinkLayer : public DataLinkLayer
|
|||||||
uint32_t _lastByteRxTime;
|
uint32_t _lastByteRxTime;
|
||||||
uint32_t _lastByteTxTime;
|
uint32_t _lastByteTxTime;
|
||||||
uint32_t _lastLoopTime;
|
uint32_t _lastLoopTime;
|
||||||
uint32_t _waitConfirmStartTime;
|
uint32_t _waitConfirmStartTime = 0;
|
||||||
uint32_t _lastResetChipTime = 0;
|
uint32_t _lastResetChipTime = 0;
|
||||||
|
|
||||||
struct _tx_queue_frame_t
|
struct _tx_queue_frame_t
|
||||||
@ -70,6 +70,7 @@ class TpUartDataLinkLayer : public DataLinkLayer
|
|||||||
void dataConBytesReceived(uint8_t* buffer, uint16_t length, bool success);
|
void dataConBytesReceived(uint8_t* buffer, uint16_t length, bool success);
|
||||||
void enterRxWaitEOP();
|
void enterRxWaitEOP();
|
||||||
bool resetChip();
|
bool resetChip();
|
||||||
|
bool resetChipTick();
|
||||||
void stopChip();
|
void stopChip();
|
||||||
|
|
||||||
ITpUartCallBacks& _cb;
|
ITpUartCallBacks& _cb;
|
||||||
|
Loading…
Reference in New Issue
Block a user