This gives some feedback as to the cause of a crash in situations where no debugging probe is installed.
Here's a hacked up example for the STM32v1 serial drivers:
Code: Select all
/**
* @brief Switch to polling mode (disable interrupts)
*
* @param[in] sdp communication channel associated to the USART
*/
void sd_lld_pollMode(SerialDriver *sdp) {
USART_TypeDef *u = sdp->usart;
u->CR1 &=
~(USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | USART_CR1_PEIE);
u->CR2 &= ~USART_CR2_LBDIE;
u->CR3 &= ~USART_CR3_EIE;
}
/**
* @brief Output byte in polling mode
*
* @param[in] sdp communication channel associated to the USART
*/
void sd_lld_xmitByte(SerialDriver *sdp, uint8_t b) {
USART_TypeDef *u = sdp->usart;
while (!(u->SR & USART_SR_TXE)) ;
u->DR = b;
}