Add Polled Mode Serial Output for Panic Messages

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
genosensor
Posts: 65
Joined: Thu Oct 03, 2013 1:06 am
Location: Santa Cruz, California
Has thanked: 1 time
Been thanked: 1 time

Add Polled Mode Serial Output for Panic Messages

Postby genosensor » Sun Mar 26, 2017 7:28 pm

I propose adding a polled output mode so panic messages can be output on a serial port with interrupts disabled.
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;
}
- brent

Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 7 guests