[a91dc98b] | 1 | /* |
---|
| 2 | * Copyright (c) 2013 embedded brains GmbH. All rights reserved. |
---|
| 3 | * |
---|
| 4 | * embedded brains GmbH |
---|
| 5 | * Dornierstr. 4 |
---|
| 6 | * 82178 Puchheim |
---|
| 7 | * Germany |
---|
| 8 | * <info@embedded-brains.de> |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
| 12 | * http://www.rtems.com/license/LICENSE. |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #include <libchip/serial.h> |
---|
| 16 | |
---|
| 17 | #include <bsp.h> |
---|
| 18 | #include <bsp/irq.h> |
---|
| 19 | #include <bsp/arm-pl011.h> |
---|
| 20 | |
---|
| 21 | console_tbl Console_Configuration_Ports[] = { |
---|
| 22 | { |
---|
| 23 | .sDeviceName = "/dev/ttyS0", |
---|
| 24 | .deviceType = SERIAL_CUSTOM, |
---|
| 25 | .pDeviceFns = &arm_pl011_fns, |
---|
| 26 | .deviceProbe = NULL, |
---|
| 27 | .pDeviceFlow = NULL, |
---|
| 28 | .ulMargin = 10, |
---|
| 29 | .ulHysteresis = 0, |
---|
| 30 | .pDeviceParams = (void *) 115200, |
---|
| 31 | .ulCtrlPort1 = 0x10009000, |
---|
| 32 | .ulCtrlPort2 = 0, |
---|
| 33 | .ulDataPort = 0, |
---|
| 34 | .getRegister = NULL, |
---|
| 35 | .setRegister = NULL, |
---|
| 36 | .getData = NULL, |
---|
| 37 | .setData = NULL, |
---|
| 38 | .ulClock = 0, |
---|
| 39 | .ulIntVector = RVPBXA9_IRQ_UART_0 |
---|
| 40 | } |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | unsigned long Console_Configuration_Count = |
---|
| 44 | RTEMS_ARRAY_SIZE(Console_Configuration_Ports); |
---|
| 45 | |
---|
| 46 | static void output_char(char c) |
---|
| 47 | { |
---|
| 48 | int minor = (int) Console_Port_Minor; |
---|
| 49 | const console_tbl *ct = Console_Port_Tbl != NULL ? |
---|
| 50 | Console_Port_Tbl[minor] : &Console_Configuration_Ports[minor]; |
---|
| 51 | const console_fns *cf = ct->pDeviceFns; |
---|
| 52 | |
---|
| 53 | if (c == '\n') { |
---|
| 54 | (*cf->deviceWritePolled)(minor, '\r'); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | (*cf->deviceWritePolled)(minor, c); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | static void output_char_init(char c) |
---|
| 61 | { |
---|
| 62 | if (Console_Port_Tbl == NULL) { |
---|
| 63 | int minor = (int) Console_Port_Minor; |
---|
| 64 | const console_fns *cf = Console_Configuration_Ports[minor].pDeviceFns; |
---|
| 65 | |
---|
| 66 | (*cf->deviceInitialize)(minor); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | BSP_output_char = output_char; |
---|
| 70 | output_char(c); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | BSP_output_char_function_type BSP_output_char = output_char_init; |
---|
| 74 | |
---|
| 75 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|