A V / Mbed 2 deprecated pokus_s_UART

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UARTs.c Source File

UARTs.c

00001 #include <LPC17xx.h>
00002 #include "typedefs.h"
00003 #include "UARTs.h"
00004 
00005 void
00006 init_UARTs( UI_8 number_of_UART     /* number of interface 0=UART0, 1=UART1, 2=UART2, 3=UART3 */
00007             ,UI_8 data_bits_count   /* count of data bits  5,6,7,8 */
00008             ,UI_8 stop_bits_count   /* count of stop bits  1=1, 2=2 (if data_bits==5 then stopbits=1and1/2) */
00009             ,UI_8 type_of_parity    /* type of parity      0=fixed "0", 1=fixed "1", 2=odd , 3=even, 4=none (without parity bit) */
00010             ,UI_8 break_control     /* 0=disable 1=enable */
00011 
00012             )
00013 {
00014     LPC_UART_TypeDef *uart;
00015 
00016     switch(number_of_UART)
00017     {
00018         case UART0: uart=(LPC_UART_TypeDef *) LPC_UART0; break;
00019         case UART1: uart=(LPC_UART_TypeDef *) LPC_UART1; break;
00020         case UART2: uart=(LPC_UART_TypeDef *) LPC_UART2; break;
00021         case UART3: uart=(LPC_UART_TypeDef *) LPC_UART3; break;
00022     }
00023     uart->LCR=(data_bits_count-(UI_8) 5)|((stop_bits_count-(UI_8) 1)<<2)|(type_of_parity<<3)|(break_control<<6);
00024     uart->LCR|=MASK_DIVISOR_LATCH_ACCESS_BIT;
00025     uart->DLL=
00026     uart->DLM=
00027     uart->LCR&=~MASK_DIVISOR_LATCH_ACCESS_BIT;
00028 
00029 
00030 //   /* Initialize the serial interface */
00031 //   rbuf.in   = 0;
00032 //   rbuf.out  = 0;
00033 //   tbuf.in   = 0;
00034 //   tbuf.out  = 0;
00035 //   tx_active = __FALSE;
00036 //
00037 //   /* Enable RxD1 and TxD1 pins. */
00038 //   PINSEL0 = 0x00050000;
00039 //   /* 8-bits, no parity, 1 stop bit */
00040 //   U1LCR = 0x83;
00041 //   /* 19200 Baud Rate @ 15MHz VPB Clock */
00042 //   U1DLL = 49;
00043 //   U1DLM = 0;
00044 //   U1LCR = 0x03;
00045 //   /* Enable RDA and THRE interrupts. */
00046 //   U1IER = 0x03;
00047 //   /* Enable UART1 interrupts. */
00048 //   VICVectAddr14  = (U32)handler_UART1;
00049 //   VICVectCntl14  = 0x27;
00050 //   VICIntEnable  |= 1 << 7;
00051 }