User manual

6 OnRISC Hardware API
50 i f ( r e t < 0)
51 {
52 p er r o r ( " is p ee d " ) ;
53 return 1;
54 }
55 r e t = c f s e t o s p e e d (&s e r_ te rm io s , B38400 ) ;
56 i f ( r e t < 0)
57 {
58 p er r o r ( " ospee d " ) ;
59 return 1;
60 }
61 r e t = t c s e t a t t r ( fd , TCSANOW, &s er_ te r mi os ) ;
62 i f ( r e t < 0)
63 {
64 p er r o r ( " g e t a t t r " ) ;
65 return 1;
66 }
67 . . .
68 c l o s e ( fd ) ;
69 return 0 ;
70 }
Every time the baud rate will be changed a special baud rate generation function will be invoked in
the serial driver (drivers/char/serial.c) namely serial16C950_get_divisors(). This routine
calculates appropriate values for the clock prescaler register (CPR), times clock register (TCR) and
16-bit divisor supported by 16C950 UART. If the routine couldn’t find the appropriate values the
baud rate 9600bit/s will be set. To disable this functionality comment the following definition in
drivers/char/serial.c:
#d e f i n e ENABLE_16C950_BAUD_GENERATION_FEATURES
May 2014 OnRISC User Manual 44