2008-12-11 11:08:39 RS485 style implementation
Gil Richard (CANADA)
Message: 66633
I am adding RS485 support to the bfin_5xx.c module and am grappling with an implementation issue. The application would make a driver call to toggle between RS232 and RS485 operation, but should that driver call be implemented as an ioctl() call or a termios() call? Or perhaps a third option I haven't thought of?
-Gil
QuoteReplyEditDelete
2008-12-11 11:11:20 Re: RS485 style implementation
Mike Frysinger (UNITED STATES)
Message: 66634
off the top of my head, no termios setting is applicable ... so make it a custom ioctl()
QuoteReplyEditDelete
2008-12-11 11:58:12 Re: RS485 style implementation
Ian Jeffray (UNITED KINGDOM)
Message: 66636
I've also had to add RS422/RS485 handling and switching for a project, along with automatic control of the CTS line when requested via CRTSCTS. There may be a way I can merge these options in to the stock driver. Anyway, for RS485 switching, to bfin_serial_pops I added .ioctl = bfin_serial_ioctl. bfin_serial_ioctl() just responds to cmd == TIOCSERSETRS485 and does the toggle:
if ( cmd == TIOCSERSETRS485 )
{
int is485;
if ( get_user(is485, uarg) )
return -EFAULT;
// Prod your hardware here
TIOCSERSETRS485 is the name used for the toggle on other architectures, so I defined it in asm-blackfin\ioctls.h thus:
#define TIOCSERSETRS485 0x5461
Then you can call it from your userland app: int is485=1; ioctl(fd, TIOCSERSETRS485, &is485);
QuoteReplyEditDelete
2008-12-11 13:15:45 Re: RS485 style implementation
Robin Getz (UNITED STATES)
Message: 66637
Gil/Ian:
Something in /sys might be more acceptable upstream...
-Robin
QuoteReplyEditDelete
2008-12-11 15:08:45 Re: RS485 style implementation
Mike Frysinger (UNITED STATES)
Message: 66640
yeah, using TIOCSERSETRS485 as it looks like it was used elsewhere and it's simple will be a good starting point ...
QuoteReplyEditDelete
2008-12-12 09:43:34 Re: RS485 style implementation
Gil Richard (CANADA)
Message: 66664
That's fantastic, Ian! Did you have an external RS485 controller, or did you re-jig the serial driver?
QuoteReplyEditDelete
2008-12-12 09:48:37 Re: RS485 style implementation
Ian Jeffray (UNITED KINGDOM)
Message: 66665
We've a MAX3072E and MAX3070E connected directly to the Blackfin Uart to give us switchable RS422/RS485.