int uart_read(char *c, int rsize) { struct uart_token token; token.cur_bytes = 0; token.req_bytes = rsize; token.buf = c; if(ps_cdev_read(&serial_device, token.buf, token.req_bytes, &read_callback, &token) < 0){ printf("Error reading from UART\n"); return -1; } read_sem_wait(); return token.cur_bytes; }
void uart__init(void) { /* Iniitialise the UART */ printf("Initialising UART driver\n"); if(exynos_serial_init(DEV_ID, uart0base, NULL, &uart_dummy_clk, &serial_device)){ printf("Failed to initialise UART\n"); while(1); } ps_cdev_set_flags(&serial_device, serial_device.flags & ~SERIAL_AUTO_CR); serial_configure(&serial_device, BAUD_RATE, 8, PARITY_NONE, 1); /* Prime semaphores */ read_sem_wait(); write_sem_wait(); }
void pre_init(void) { /* Initialise the UART */ printf("Initialising UART driver\n"); if(exynos_serial_init(DEV_ID, (void *) vaddr, NULL, NULL, &serial_device)){ printf("Failed to initialise UART\n"); while(1); } serial_configure(&serial_device, BAUD_RATE, 8, PARITY_NONE, 1); serial_device.flags &= ~SERIAL_AUTO_CR; /* Prime semaphore */ read_sem_wait(); /* Register for IRQs */ interrupt_acknowledge(); }