MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / uart_init

Function uart_init

bsp/raspberry-pi/raspi3-64/applications/test/uart.c:45–68  ·  view source on GitHub ↗

* Set baud rate and characteristics (115200 8N1) and map to GPIO */

Source from the content-addressed store, hash-verified

43 * Set baud rate and characteristics (115200 8N1) and map to GPIO
44 */
45void uart_init()
46{
47 register unsigned int r;
48
49 /* initialize UART */
50 *AUX_ENABLE |=1; // enable UART1, AUX mini uart
51 *AUX_MU_CNTL = 0;
52 *AUX_MU_LCR = 3; // 8 bits
53 *AUX_MU_MCR = 0;
54 *AUX_MU_IER = 0;
55 *AUX_MU_IIR = 0xc6; // disable interrupts
56 *AUX_MU_BAUD = 270; // 115200 baud
57 /* map UART1 to GPIO pins */
58 r=*GPFSEL1;
59 r&=~((7<<12)|(7<<15)); // gpio14, gpio15
60 r|=(2<<12)|(2<<15); // alt5
61 *GPFSEL1 = r;
62 *GPPUD = 0; // enable pins 14 and 15
63 r=150; while(r--) { asm volatile("nop"); }
64 *GPPUDCLK0 = (1<<14)|(1<<15);
65 r=150; while(r--) { asm volatile("nop"); }
66 *GPPUDCLK0 = 0; // flush GPIO setup
67 *AUX_MU_CNTL = 3; // enable Tx, Rx
68}
69
70/**
71 * Send a character

Callers 1

pico_uart_configureFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected