baud zero divide

This commit is contained in:
Kizarm 2024-10-18 19:45:45 +02:00
parent 47dd58d040
commit 4ec412bf43

View file

@ -69,6 +69,7 @@ uint32_t Usart::Down(const char * data, const uint32_t len) {
return n; return n;
} }
void Usart::SetBaud (const uint32_t _baud) const { void Usart::SetBaud (const uint32_t _baud) const {
if (_baud == 0u) return; // ! zero divide
const ONE_BIT b = USART1.CTLR1.B.UE; const ONE_BIT b = USART1.CTLR1.B.UE;
if (b == SET) USART1.CTLR1.B.UE = RESET; if (b == SET) USART1.CTLR1.B.UE = RESET;
const uint32_t HCLK = SystemCoreClock; // hodiny pro USART zde nejsou děleny const uint32_t HCLK = SystemCoreClock; // hodiny pro USART zde nejsou děleny