STM32F0 and others: Hardware Modbus support

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Ilfirin
Posts: 6
Joined: Mon Jun 20, 2016 1:41 pm
Has thanked: 2 times

STM32F0 and others: Hardware Modbus support

Postby Ilfirin » Tue Jun 21, 2016 8:15 pm

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

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F0 and others: Hardware Modbus support

Postby Giovanni » Tue Jun 21, 2016 10:00 pm

Hi,

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

Giovanni

cipher
Posts: 24
Joined: Tue May 31, 2016 10:05 pm
Has thanked: 2 times
Been thanked: 2 times

Re: STM32F0 and others: Hardware Modbus support

Postby cipher » Thu Aug 04, 2016 6:25 pm

Hi Giovanni
Any plans to add this functionality in the near future?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F0 and others: Hardware Modbus support

Postby Giovanni » Thu Aug 04, 2016 6:59 pm

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

cipher
Posts: 24
Joined: Tue May 31, 2016 10:05 pm
Has thanked: 2 times
Been thanked: 2 times

Re: STM32F0 and others: Hardware Modbus support

Postby cipher » Thu Aug 04, 2016 7:00 pm

Ohh this is great
Thank you for the info, i will get the code from the TRUNK


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 16 guests