/* This short example shows how to set a serial line to RS485 on a device * handled by the atmel_serial driver. */ #include #include #include #include #include #include /* From arch/arm/include/asm/ioctls.h: */ #define TIOCGRS485 0x542E #define TIOCSRS485 0x542F /* From include/linux/serial.h: */ struct serial_rs485 { __u32 flags; /* RS485 feature flags */ #define SER_RS485_ENABLED (1 << 0) #define SER_RS485_RTS_ON_SEND (1 << 1) #define SER_RS485_RTS_AFTER_SEND (1 << 2) __u32 delay_rts_before_send; /* Milliseconds */ __u32 padding[6]; /* Memory is cheap, new structs are a royal PITA .. */ }; int main (void) { /* Open device: */ int fd = open ("/dev/mydevice", O_RDWR); struct serial_rs485 rs485conf; /* Set RS485 mode: */ rs485conf.flags |= SER_RS485_ENABLED; /* Set delay: */ rs485conf.delay_rts_before_send = 0x00000004; ioctl (fd, TIOCSRS485, &rs485conf); close (fd); return 0; }