From: Darren G. <ts...@ya...> - 2007-02-27 17:03:53
|
FYI, here's a script to enable the HWUART: #!/bin/sh modprobe proc_gpio echo AF1 out > /proc/gpio/GPIO48 echo AF1 in > /proc/gpio/GPIO49 echo AF1 in > /proc/gpio/GPIO50 echo AF1 out > /proc/gpio/GPIO51 for i in 42 43 44 45;do echo GPIO in > /proc/gpio/GPIO$i;done To use the HWUART I've also had to hack the PXA serial driver to turn off HW flow control. Here's a script to setup the port for MIDI. I don't know why you need two stty commands, but it seems you do. #!/bin/sh setserial /dev/ttyS0 divisor 29 spd_cust stty -F /dev/ttyS0 speed 38400 stty -F /dev/ttyS0 speed 38400 With recent builds I've been getting the message that using a custom divisor is deprecated. I suppose if this mechanism goes away, we could use pxaregs to jam the correct divisor into the serial port. And here's what I did from my program to set up the port... I was amazed at how long it took to find the correct incantation from reading various web pages and cutting and pasting various snippets of example code: int initMIDI( void ) { int ret, modem; midi_fd = open(MIDI_DEVICENAME, O_RDWR | O_NONBLOCK /*| O_NOCTTY | O_NDELAY */); printf("open (%s) returned %d\n", MIDI_DEVICENAME, midi_fd); // get current termios structure (sys/termios.h) tcgetattr(midi_fd, &theTermios); printf("Current termios: iFlag %x oFlag %x cFlag %x lFlag %x speed %d\n", theTermios.c_iflag, theTermios.c_oflag, theTermios.c_cflag, theTermios.c_lflag, theTermios.c_ispeed); //memset(&theTermios, 0, sizeof(struct termios)); // we want char by char processing cfmakeraw(&theTermios); // cfsetspeed(&theTermios, B57600); theTermios.c_cflag |= CREAD | CLOCAL; // turn on READ and ignore modem control lines // 81N theTermios.c_cflag &= ~PARENB; theTermios.c_cflag &= ~CSTOPB; theTermios.c_cflag &= ~CSIZE; theTermios.c_cflag |= CS8; printf("SETting termios: iFlag %x oFlag %x cFlag %x lFlag %x speed %d\n", theTermios.c_iflag, theTermios.c_oflag, theTermios.c_cflag, theTermios.c_lflag, theTermios.c_ispeed); // ret = ioctl(fd, TCSETA, &theTermios); ret = tcsetattr(midi_fd, TCSANOW, &theTermios); if (ret) printf("ioctl - TIOCSETA returned %d (errno %d)\n", ret, errno); // why bother with this when we've set to ignore modem control? // ioctl(fd, TIOCMGET, &modem); // modem |= TIOCM_DTR; // modem |= TIOCM_RTS; // modem |= TIOCM_CTS; // ioctl(fd, TIOCMSET, &modem); return 0; } On Feb 25, 2007, at 1:45 PM, Daniel O'Shea wrote: > Darren Gibbs wrote: >> Yes, you have to use set serial and use the "custom" baud mechanism >> to set the clock divider manually. I'll dig up the code and send it >> if you like. I can't remember the exact rate I got, but I remember >> 31250 wasn't possible. What I did get was within 5% and works fine >> with all the MIDI devices I've tested against. > > If it isn't too much trouble for you to send the code, that'd be great > thanks! > |