Page 1 of 1

STM32F0 and others: Hardware Modbus support

Posted: Tue Jun 21, 2016 8:15 pm
by Ilfirin
Greetings,

I was implementing hardware modbus support on STM32F072 because somehow I messed Virtual Timers (for idle detection) beyond point of return.

I succeded, but run into some obstackles:

1) No API for setting RTOR register, workarounded by

Code: Select all

UARTD2.usart->RTOR |= MODBUS_15SPACE_BITS;

2) No IRQ handling in uart_lld. Workarounded by adding it into errors (couldn't found better place)

Code: Select all

#define UART_REC_IDLE_DETECTED  128 /**< @brief Reciever timeout detected.  */

static uartflags_t translate_errors(uint32_t isr) {
  uartflags_t sts = 0;

  if (isr & USART_ISR_ORE)
    sts |= UART_OVERRUN_ERROR;
  if (isr & USART_ISR_PE)
    sts |= UART_PARITY_ERROR;
  if (isr & USART_ISR_FE)
    sts |= UART_FRAMING_ERROR;
  if (isr & USART_ISR_NE)
    sts |= UART_NOISE_ERROR;
  if (isr & USART_ISR_LBDF)
    sts |= UART_BREAK_DETECTED;
  if (isr & USART_ISR_RTOF)
    sts |= UART_REC_IDLE_DETECTED;
  return sts;
}
and added to static void serve_usart_irq(UARTDriver *uartp) as an error

Just wanted to ask, if is planned better support in future, or is better way to do it?

Thank you

Re: STM32F0 and others: Hardware Modbus support

Posted: Tue Jun 21, 2016 10:00 pm
by Giovanni
Hi,

The driver would need a small update in order to support that, the ISR and one more field in the configuration structure.

Giovanni

Re: STM32F0 and others: Hardware Modbus support

Posted: Thu Aug 04, 2016 6:25 pm
by cipher
Hi Giovanni
Any plans to add this functionality in the near future?

Re: STM32F0 and others: Hardware Modbus support

Posted: Thu Aug 04, 2016 6:59 pm
by Giovanni
Hi,

It has already been implemented in the trunk code (by barthess), it is not handled as an error, there is a specific callback for timeout handling.

Giovanni

Re: STM32F0 and others: Hardware Modbus support

Posted: Thu Aug 04, 2016 7:00 pm
by cipher
Ohh this is great
Thank you for the info, i will get the code from the TRUNK