summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c')
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c
new file mode 100644
index 0000000000..c03ba9bc24
--- /dev/null
+++ b/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c
@@ -0,0 +1,87 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Cástor Muñoz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdio.h>
22#include <stdlib.h>
23#include <stdarg.h>
24
25#include "config.h"
26#include "cpu.h"
27#include "system.h"
28#include "kernel.h"
29
30#include "serial.h"
31#include "s5l8702.h"
32#include "uc8702.h"
33#include "uart-s5l8702.h"
34
35/* Define LOGF_ENABLE to enable logf output in this file */
36#define LOGF_ENABLE
37#include "logf.h"
38
39
40/* shall include serial HW configuracion for specific target */
41#define IPOD6G_UART_CLK_HZ 12000000 /* external OSC0 ??? */
42
43extern struct uartc s5l8702_uart;
44
45struct uartc_port ser_port IDATA_ATTR = {
46 /* location */
47 .uartc = &s5l8702_uart,
48 .id = 0,
49
50 /* configuration */
51 .rx_trg = UFCON_RX_FIFO_TRG_4,
52 .tx_trg = UFCON_TX_FIFO_TRG_EMPTY,
53 .clksel = UCON_CLKSEL_ECLK,
54 .clkhz = IPOD6G_UART_CLK_HZ,
55
56 /* interrupt callbacks */
57 .rx_cb = NULL,
58 .tx_cb = NULL, /* polling */
59};
60
61/*
62 * serial driver API
63 */
64void serial_setup(void)
65{
66 uart_port_init(&ser_port);
67
68 /* set a default configuration, Tx and Rx modes are
69 disabled when the port is initialized */
70 uartc_port_config(&ser_port, 115200, ULCON_DATA_BITS_8,
71 ULCON_PARITY_NONE, ULCON_STOP_BITS_1);
72
73 /* enable Tx interrupt request or POLLING mode */
74 uartc_port_set_tx_mode(&ser_port, UCON_MODE_INTREQ);
75
76 logf("[%lu] serial_setup(): port %d ready!", USEC_TIMER, ser_port.id);
77}
78
79int tx_rdy(void)
80{
81 return uartc_port_tx_ready(&ser_port) ? 1 : 0;
82}
83
84void tx_writec(unsigned char c)
85{
86 uartc_port_tx_byte(&ser_port, c);
87}