<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span id="yiv1036972606ygrps-yiv-936312836misspell-0" class="">Hello</span> all. I have been trying to setup a LEON3 system with <span id="yiv1036972606ygrps-yiv-936312836misspell-0" class="">RTEMS</span> 4.10 with two (2) <span id="yiv1036972606ygrps-yiv-936312836misspell-1" class="">APBUARTs</span> in it. My intention is to use one as system console and the other one for serial <span id="yiv1036972606ygrps-yiv-936312836misspell-2" class=""><span>transmission</span></span>/reception with Interrupt driven interface. After some reading I <span id="yiv1036972606ygrps-yiv-936312836misspell-2" class=""><span>realise</span></span> that <span id="yiv1036972606ygrps-yiv-936312836misspell-3" class="">APBUART</span> RAW Driver is deprecated and that only way is the Console/<span
id="yiv1036972606ygrps-yiv-936312836misspell-4" class="">Termios</span> driver. </div><div><br></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
Grande', sans-serif;background-color:transparent;font-style:normal;">So far I am capable of writing and reading from both <span id="yiv1036972606ygrps-yiv-936312836misspell-5" class="">APBUARTs</span> either using <span id="yiv1036972606ygrps-yiv-936312836misspell-6" class="">IP</span> Core Registers directly, or playing with which port is the system console. I had use the <span id="yiv1036972606ygrps-yiv-936312836misspell-7" class="">rtems</span>_hello_multiple.c example to either choose <span id="yiv1036972606ygrps-yiv-936312836misspell-8" class="">APBUART</span>0 or <span id="yiv1036972606ygrps-yiv-936312836misspell-9" class="">APBUART</span>1 as system console, and both options work fine. However a can't configure the other <span id="yiv1036972606ygrps-yiv-936312836misspell-10" class="">APBUART</span> as an interrupt driven raw <span id="yiv1036972606ygrps-yiv-936312836misspell-11" class="">UART</span>. I <span
id="yiv1036972606ygrps-yiv-936312836misspell-12" class=""><span>copied</span></span> some c code from someone that said that this configuration
will <span id="yiv1036972606ygrps-yiv-936312836misspell-13" class="">Termios</span> <span id="yiv1036972606ygrps-yiv-936312836misspell-14" class="">UART</span> act as raw,
and it does, but my code only reads one by one byte and I am sure is in <span id="yiv1036972606ygrps-yiv-936312836misspell-15" class=""><span>polled</span></span> mode because it is only capable to "not lose" the same number of characters as the <span id="yiv1036972606ygrps-yiv-936312836misspell-16" class="">HW</span> FIFO has.</div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class=""><br></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class="">I am looking for someones code which uses <span id="yiv1036972606ygrps-yiv-936312836misspell-17" class="">APBUART</span> with <span id="yiv1036972606ygrps-yiv-936312836misspell-18" class="">Termios</span> and Interrupt driven
interface. Here is a snippet of my
code using <span id="yiv1036972606ygrps-yiv-936312836misspell-19" class="">APBUART</span>0 as system console and trying to use <span id="yiv1036972606ygrps-yiv-936312836misspell-20" class=""><span>erroneously</span></span> <span id="yiv1036972606ygrps-yiv-936312836misspell-21" class="">APBUART</span>1 as raw interrupt driven serial interface:</div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class="">< ... ></div><div style="background-color:transparent;" class=""> #include <<span id="yiv1036972606ygrps-yiv-936312836misspell-22" class="">drvmgr</span>/<span id="yiv1036972606ygrps-yiv-936312836misspell-23" class="">ambapp</span>_bus.h></div><div style="background-color:transparent;" class=""> /* <span id="yiv1036972606ygrps-yiv-936312836misspell-24" class="">APBUART</span>0
*/</div><div style="background-color:transparent;" class=""> <span id="yiv1036972606ygrps-yiv-936312836misspell-25" class="">struct</span> <span id="yiv1036972606ygrps-yiv-936312836misspell-26" class="">drvmgr</span>_key <span id="yiv1036972606ygrps-yiv-936312836misspell-27" class="">grlib</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-28" class="">drv</span>_res_<span id="yiv1036972606ygrps-yiv-936312836misspell-29" class="">apbuart</span>0[] =</div><div style="background-color:transparent;" class=""> {</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>{"mode", KEY_TYPE_INT, {(unsigned int)1}},</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>{"<span id="yiv1036972606ygrps-yiv-936312836misspell-30" class="">syscon</span>", KEY_TYPE_INT, {(unsigned int)1}},</div><div
style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>KEY_EMPTY</div><div style="background-color:transparent;" class=""> };</div><div style="background-color:transparent;" class=""> /* <span id="yiv1036972606ygrps-yiv-936312836misspell-31" class="">APBUART</span>1 */</div><div style="background-color:transparent;" class=""> <span id="yiv1036972606ygrps-yiv-936312836misspell-32" class="">struct</span> <span id="yiv1036972606ygrps-yiv-936312836misspell-33" class="">drvmgr</span>_key <span id="yiv1036972606ygrps-yiv-936312836misspell-34" class="">grlib</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-35" class="">drv</span>_res_<span id="yiv1036972606ygrps-yiv-936312836misspell-36" class="">apbuart</span>1[] =</div><div style="background-color:transparent;" class=""> {</div><div style="background-color:transparent;" class=""> <span class=""
style="white-space:pre;"> </span>{"mode", KEY_TYPE_INT, {(unsigned int)1}},</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>{"<span id="yiv1036972606ygrps-yiv-936312836misspell-37" class="">syscon</span>", KEY_TYPE_INT, {(unsigned int)0}},</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>KEY_EMPTY</div><div style="background-color:transparent;" class=""> };</div><div style="background-color:transparent;" class=""> /* LEON3 System with driver configuration for 2 <span id="yiv1036972606ygrps-yiv-936312836misspell-38" class="">APBUARTs</span>, the</div><div style="background-color:transparent;" class=""> * the rest of the <span id="yiv1036972606ygrps-yiv-936312836misspell-39" class="">AMBA</span> device drivers use their defaults.</div><div style="background-color:transparent;" class="">
*/</div><div style="background-color:transparent;" class=""> <span id="yiv1036972606ygrps-yiv-936312836misspell-40" class="">struct</span> <span id="yiv1036972606ygrps-yiv-936312836misspell-41" class="">drvmgr</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-42" class="">drv</span>_res <span id="yiv1036972606ygrps-yiv-936312836misspell-43" class="">grlib</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-44" class="">drv</span>_resources[] =</div><div style="background-color:transparent;" class=""> {</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>/* DRIVER_ID, DEVICE_INSTANCE, CONFIGURATION_ARRAY
*/</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>{DRIVER_<span id="yiv1036972606ygrps-yiv-936312836misspell-45" class="">AMBAPP</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-46" class="">GAISLER</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-47" class="">APBUART</span>_ID, 0, &<span id="yiv1036972606ygrps-yiv-936312836misspell-48" class="">grlib</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-49" class="">drv</span>_res_<span id="yiv1036972606ygrps-yiv-936312836misspell-50" class="">apbuart</span>0[0]},</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>{DRIVER_<span id="yiv1036972606ygrps-yiv-936312836misspell-51" class="">AMBAPP</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-52" class="">GAISLER</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-53"
class="">APBUART</span>_ID, 1, &<span id="yiv1036972606ygrps-yiv-936312836misspell-54" class="">grlib</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-55" class="">drv</span>_res_<span id="yiv1036972606ygrps-yiv-936312836misspell-56" class="">apbuart</span>1[0]},</div><div style="background-color:transparent;" class=""> <span class="" style="white-space:pre;"> </span>RES_EMPTY</div><div style="background-color:transparent;" class=""> };</div><div style="background-color:transparent;" class=""><br></div><div style="background-color:transparent;" class=""><span style="background-color:transparent;font-size:12pt;"> int debug_<span id="yiv1036972606ygrps-yiv-936312836misspell-57" class="">uart</span>_index = 1; /* second <span id="yiv1036972606ygrps-yiv-936312836misspell-58" class="">UART</span> -- <span id="yiv1036972606ygrps-yiv-936312836misspell-59" class="">APBUART</span>[1] */</span><br></div><div
style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class=""><br></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class=""><...><br></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;background-color:transparent;font-style:normal;" class=""><br></div><div style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-60" class="">sys</span>/types.h></div><div style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-61" class="">sys</span>/stat.h></div><div
style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-62" class="">fcntl</span>.h></div><div style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-63" class="">termios</span>.h></div><div style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-64" class="">unistd</span>.h></div><div style="background-color:transparent;" class="">#include <<span id="yiv1036972606ygrps-yiv-936312836misspell-65" class="">errno</span>.h></div><div style="background-color:transparent;" class=""><br></div><div style="background-color:transparent;" class=""><br></div><div style="background-color:transparent;" class=""><br></div><div style="background-color:transparent;" class=""><span id="yiv1036972606ygrps-yiv-936312836misspell-66" class="">rtems</span>_task <span
id="yiv1036972606ygrps-yiv-936312836misspell-67" class="">Init</span> (<span id="yiv1036972606ygrps-yiv-936312836misspell-68" class="">rtems</span>_task_argument ignored)</div><div style="background-color:transparent;" class="">{</div><div> <...></div><div> /* Opening Communication devices (/<span id="yiv1036972606ygrps-yiv-936312836misspell-69" class="">dev</span>/console_b) */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-70" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-71" class="">fd</span> = open("/<span id="yiv1036972606ygrps-yiv-936312836misspell-72" class="">dev</span>/console_b", O_<span id="yiv1036972606ygrps-yiv-936312836misspell-73" class="">RDWR</span>);</div><div><span class="" style="white-space:pre;"> </span>if (<span id="yiv1036972606ygrps-yiv-936312836misspell-74" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-75" class="">fd</span> !=
0)</div><div><span class="" style="white-space:pre;"> </span>{</div><div><span class="" style="white-space:pre;"> </span><span id="yiv1036972606ygrps-yiv-936312836misspell-76" class="">printf</span>("Failed to open /<span id="yiv1036972606ygrps-yiv-936312836misspell-77" class="">dev</span>/console_b.\<span id="yiv1036972606ygrps-yiv-936312836misspell-78" class="">nCause</span> open failed, <span id="yiv1036972606ygrps-yiv-936312836misspell-79" class="">ERRNO</span>: %d = %s\n",<span id="yiv1036972606ygrps-yiv-936312836misspell-80" class="">errno</span>,<span id="yiv1036972606ygrps-yiv-936312836misspell-81" class="">strerror</span>(<span id="yiv1036972606ygrps-yiv-936312836misspell-82" class="">errno</span>));</div><div><span class="" style="white-space:pre;"> </span>}</div><div><br></div><div> /* Get current configuration */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-83" class="">tcgetattr</span>(<span
id="yiv1036972606ygrps-yiv-936312836misspell-84" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-85" class="">fd</span>, &<span id="yiv1036972606ygrps-yiv-936312836misspell-86" class="">newTerm</span>);</div><div><br></div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-87" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-88" class="">lflag</span> &= ~(<span id="yiv1036972606ygrps-yiv-936312836misspell-89" class="">ICANON</span>|ECHO|<span id="yiv1036972606ygrps-yiv-936312836misspell-90" class="">ECHOE</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-91" class="">ECHOK</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-92" class="">ECHONL</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-93" class="">ECHOPRT</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-94" class="">ECHOCTL</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-95"
class="">ECHOKE</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-96" class="">IEXTEN</span>|<span id="yiv1036972606ygrps-yiv-936312836misspell-97" class="">ISIG</span>);</div><div><br></div><div> /* Local mode and receiver enabled */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-98" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-99" class="">cflag</span> |= (<span id="yiv1036972606ygrps-yiv-936312836misspell-100" class="">CLOCAL</span> | <span id="yiv1036972606ygrps-yiv-936312836misspell-101" class="">CREAD</span>);</div><div><br></div><div> /* 8 bits, enable receiver */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-102" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-103" class="">cflag</span> |= CS8;</div><div><br></div><div> /* Raw output */</div><div> <span
id="yiv1036972606ygrps-yiv-936312836misspell-104" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-105" class="">oflag</span> &= ~<span id="yiv1036972606ygrps-yiv-936312836misspell-106" class="">OPOST</span>;</div><div><br></div><div> /* Ignore breaks. */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-107" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-108" class="">iflag</span> = <span id="yiv1036972606ygrps-yiv-936312836misspell-109" class="">IGNBRK</span>;</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-110" class="">newTerm</span>.c_<span id="yiv1036972606ygrps-yiv-936312836misspell-111" class="">iflag</span> &= ~<span id="yiv1036972606ygrps-yiv-936312836misspell-112" class="">INLCR</span>; /*input
modes*/</div><div><br></div><div> /* Set <span id="yiv1036972606ygrps-yiv-936312836misspell-113" class="">UART</span> Speed at 230400 bps */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-114" class="">cfsetospeed</span> (&<span id="yiv1036972606ygrps-yiv-936312836misspell-115" class="">newTerm</span>, B230400);</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-116" class="">cfsetispeed</span> (&<span id="yiv1036972606ygrps-yiv-936312836misspell-117" class="">newTerm</span>, B230400);</div><div><br></div><div> /* Update driver's settings */</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-118" class="">ret</span> = <span id="yiv1036972606ygrps-yiv-936312836misspell-119" class="">tcsetattr</span>(<span id="yiv1036972606ygrps-yiv-936312836misspell-120" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-121" class="">fd</span>, <span
id="yiv1036972606ygrps-yiv-936312836misspell-122" class="">TCSANOW</span>, &<span id="yiv1036972606ygrps-yiv-936312836misspell-123" class="">newTerm</span>);</div><div> <span id="yiv1036972606ygrps-yiv-936312836misspell-124" class="">tcflush</span>(<span id="yiv1036972606ygrps-yiv-936312836misspell-125" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-126" class="">fd</span>, <span id="yiv1036972606ygrps-yiv-936312836misspell-127" class="">TCIOFLUSH</span>);</div><div><br></div><div> // While loop to test if interrupt is enabled in console b,</div><div> // and also to test the length
of the RX buffer</div><div> while (1)</div><div> {</div><div><span class="" style="white-space:pre;"> </span> <span id="yiv1036972606ygrps-yiv-936312836misspell-128" class="">printf</span>("Send as many bytes by console b as needed\n");</div><div><span class="" style="white-space:pre;"> </span> <span id="yiv1036972606ygrps-yiv-936312836misspell-129" class="">scanf</span> ("%d", &<span id="yiv1036972606ygrps-yiv-936312836misspell-130" class="">ret</span>);</div><div><br></div><div><span class="" style="white-space:pre;"> </span> <span id="yiv1036972606ygrps-yiv-936312836misspell-131" class="">ret</span> = read (<span id="yiv1036972606ygrps-yiv-936312836misspell-132" class="">dev</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-133" class="">fd</span>, <span id="yiv1036972606ygrps-yiv-936312836misspell-134" class="">buf</span>, 10);</div><div><span class="" style="white-space:pre;"> </span>
<span id="yiv1036972606ygrps-yiv-936312836misspell-135" class="">printf</span>("\<span id="yiv1036972606ygrps-yiv-936312836misspell-136" class="">nBytes</span> read: %d. 0x%02X 0x%02X 0x%02X ...\n",
<span id="yiv1036972606ygrps-yiv-936312836misspell-137" class="">ret</span>, <span id="yiv1036972606ygrps-yiv-936312836misspell-138" class="">buf</span>[0], <span id="yiv1036972606ygrps-yiv-936312836misspell-139" class="">buf</span>[1], <span id="yiv1036972606ygrps-yiv-936312836misspell-140" class="">buf</span>[2]);</div><div><span class="" style="white-space:pre;"> </span> <span id="yiv1036972606ygrps-yiv-936312836misspell-141" class="">memset</span> (<span id="yiv1036972606ygrps-yiv-936312836misspell-142" class="">buf</span>, 0, 1000);</div><div><br></div><div> }</div><div><br></div><div><span class="" style="white-space:pre;"> </span><span id="yiv1036972606ygrps-yiv-936312836misspell-143" class="">printf</span> ("Finish <span id="yiv1036972606ygrps-yiv-936312836misspell-144" class="">prueba</span>_<span id="yiv1036972606ygrps-yiv-936312836misspell-145" class="">uart</span>_raw Application!\n");</div><div><br></div><div><span
class="" style="white-space:pre;"> </span>exit( 0 );</div><div><...></div><div><br></div><div>My problem is that
"read" <span id="yiv1036972606ygrps-yiv-936312836misspell-146" class=""><span>function</span></span> always returns '1' (when bytes
have been received <span id="yiv1036972606ygrps-yiv-936312836misspell-147" class=""><span>of course</span></span>) instead of the number of bytes received. It is also not Interrupt driven.</div><div><br></div><div>May anyone give me some clue of what am I doing wrong?</div><div>Thank you!<br><br>pafbat.<br></div><div><br class=""></div></div></body></html>