Page 421 - Programming Microcontrollers in C
P. 421

406    Chapter 8  MCORE, A RISC Machine

                       U1PCR.PC3=ON;  /* connect all i/o pins to the uart */
                       U1PCR.PC2=ON;
                       U1PCR.PC1=ON;
                       U1PCR.PC0=ON;
                       U1DDR.PDC1=ON; /* make output pin for the uart */
                   }                     /* probably not needed */


                   /* send a character out the serial port when it is ready */
                   static void put(BYTE x)
                   {
                       while((U1SRint & TRDYint)==0)
                          ;  /* wait until character is ready */
                       U1TX.DATA =x; /* send the data out */
                   }


                   /* read in and echo a character through the serial port */
                   BYTE getchar(void)
                   {
                       BYTE a;

                       while((U1RXint & CHARRDYint)==0)
                          ;  /* wait till character is ready */
                       a=U1RX.DATA;
                       putchar(a);
                       return a;
                   }


                   /* read in a character with no echo */
                   BYTE getch(void)
                   {
                       BYTE a;

                       while((U1RXint & CHARRDYint)==0)
                          ;  /* wait till character is ready */
                       a=U1RX.DATA;
                       return a;
                   }

                   /* read in a character from the serial port. Do not
                   check for the character ready. This routine should be used
                   with kbhit(). */
                   BYTE getce(void)
                   {
                       return U1RX.DATA;
                   }
   416   417   418   419   420   421   422   423   424   425   426