Rename simple UART driver to pipe UART

Original name was too generic and confusing. This patch renames
driver to pipe UART and moves it to console drivers folder. Kconfig
destription is also improved.

Change-Id: I716fdbf7d636bbdc03b0fce27a59fd866f473246
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2015-11-25 08:11:30 +01:00 committed by Anas Nashif
parent 341f81bd81
commit c0baad2262
18 changed files with 67 additions and 83 deletions

View file

@ -126,12 +126,12 @@ extern struct device * const uart_devs[];
#endif /* CONFIG_BLUETOOTH_UART */
/* Simple UART definitions */
#define CONFIG_UART_SIMPLE_INDEX 2
#define CONFIG_UART_SIMPLE_BAUDRATE 115200
#define CONFIG_UART_SIMPLE_IRQ IRQ_UART2
#define CONFIG_UART_SIMPLE_INT_PRI 3
#define CONFIG_UART_SIMPLE_FREQ SYSCLK_DEFAULT_IOSC_HZ
/* Pipe UART definitions */
#define CONFIG_UART_PIPE_INDEX 2
#define CONFIG_UART_PIPE_BAUDRATE 115200
#define CONFIG_UART_PIPE_IRQ IRQ_UART2
#define CONFIG_UART_PIPE_INT_PRI 3
#define CONFIG_UART_PIPE_FREQ SYSCLK_DEFAULT_IOSC_HZ
#define EXC_FROM_IRQ(irq) ((irq) + 16)
#define VECTOR_FROM_IRQ(irq) EXC_FROM_IRQ(irq)

View file

@ -49,11 +49,11 @@ by x86 platforms.
#endif /* CONFIG_IOAPIC */
#endif /* CONFIG_CONSOLE_HANDLER */
#if defined(CONFIG_UART_SIMPLE)
#if defined(CONFIG_UART_PIPE)
#if defined(CONFIG_IOAPIC)
ioapic_mkstub uart_simple uart_simple_isr 0
ioapic_mkstub uart_pipe uart_pipe_isr 0
#endif /* CONFIG_IOAPIC */
#endif /* CONFIG_UART_SIMPLE */
#endif /* CONFIG_UART_PIPE */
/* externs (internal APIs) */

View file

@ -83,12 +83,12 @@
#define CONFIG_UART_PORT_1_IRQ COM2_INT_LVL
#define CONFIG_UART_PORT_1_IRQ_PRIORITY COM2_INT_PRI
/* Simple UART definitions */
#define CONFIG_UART_SIMPLE_INDEX 1
#define CONFIG_UART_SIMPLE_BAUDRATE CONFIG_UART_BAUDRATE
#define CONFIG_UART_SIMPLE_IRQ COM2_INT_LVL
#define CONFIG_UART_SIMPLE_INT_PRI COM2_INT_PRI
#define CONFIG_UART_SIMPLE_FREQ UART_XTAL_FREQ
/* Pipe UART definitions */
#define CONFIG_UART_PIPE_INDEX 1
#define CONFIG_UART_PIPE_BAUDRATE CONFIG_UART_BAUDRATE
#define CONFIG_UART_PIPE_IRQ COM2_INT_LVL
#define CONFIG_UART_PIPE_INT_PRI COM2_INT_PRI
#define CONFIG_UART_PIPE_FREQ UART_XTAL_FREQ
#ifndef _ASMLANGUAGE
extern struct device * const uart_devs[];

View file

@ -19,8 +19,6 @@
menu "Device Drivers"
source "drivers/simple/Kconfig"
source "drivers/bluetooth/Kconfig"
source "drivers/console/Kconfig"

View file

@ -10,7 +10,6 @@ obj-y += interrupt_controller/
obj-$(CONFIG_GROVE) += grove/
obj-$(CONFIG_PCI) += pci/
obj-$(CONFIG_BLUETOOTH) += bluetooth/
obj-$(CONFIG_UART_SIMPLE) += simple/
obj-$(CONFIG_SHARED_IRQ) += shared_irq/
obj-$(CONFIG_SPI) += spi/
obj-$(CONFIG_GPIO) += gpio/

View file

@ -101,4 +101,15 @@ config IPI_CONSOLE_RECEIVER
help
Enable the receiving side of IPI console
config UART_PIPE
bool
prompt "Enable pipe UART driver"
select UART_INTERRUPT_DRIVEN
default n
help
Enable pipe UART driver. This driver allows application to communicate
over UART with custom defined protocol. Driver doesn't inspect received
data (as contrary to console UART driver) and all aspects of received
protocol data are handled by application provided callback.
endif

View file

@ -2,3 +2,4 @@ obj-$(CONFIG_UART_CONSOLE) = uart_console.o
obj-$(CONFIG_RAM_CONSOLE) += ram_console.o
obj-$(CONFIG_IPI_CONSOLE_RECEIVER) += ipi_console_receiver.o
obj-$(CONFIG_IPI_CONSOLE_SENDER) += ipi_console_sender.o
obj-$(CONFIG_UART_PIPE) = uart_pipe.o

View file

@ -1,7 +1,7 @@
/** @file
* @brief Simple UART driver
* @brief Pipe UART driver
*
* A simple UART driver allowing application to handle all aspects of received
* A pipe UART driver allowing application to handle all aspects of received
* protocol data.
*/
@ -26,20 +26,20 @@
#include <board.h>
#include <uart.h>
#include <simple/uart.h>
#include <console/uart_pipe.h>
#include <misc/printk.h>
#if !defined(CONFIG_UART_SIMPLE_INDEX) || !defined(CONFIG_UART_SIMPLE_IRQ)
#if !defined(CONFIG_UART_PIPE_INDEX) || !defined(CONFIG_UART_PIPE_IRQ)
#error One or more required values for this driver are not set.
#else
#define UART (uart_devs[CONFIG_UART_SIMPLE_INDEX])
#define UART (uart_devs[CONFIG_UART_PIPE_INDEX])
static uint8_t *recv_buf;
static size_t recv_buf_len;
static uart_simple_recv_cb app_cb;
static uart_pipe_recv_cb app_cb;
static size_t recv_off;
void uart_simple_isr(void *unused)
void uart_pipe_isr(void *unused)
{
ARG_UNUSED(unused);
@ -56,7 +56,8 @@ void uart_simple_isr(void *unused)
continue;
}
/* Call application callback with received data. Application
/*
* Call application callback with received data. Application
* may provide new buffer or alter data offset.
*/
recv_off += rx;
@ -64,22 +65,22 @@ void uart_simple_isr(void *unused)
}
}
int uart_simple_send(const uint8_t *data, int len)
int uart_pipe_send(const uint8_t *data, int len)
{
return uart_fifo_fill(UART, data, len);
}
IRQ_CONNECT_STATIC(uart_simple, CONFIG_UART_SIMPLE_IRQ,
CONFIG_UART_SIMPLE_INT_PRI, uart_simple_isr, 0,
IRQ_CONNECT_STATIC(uart_pipe, CONFIG_UART_PIPE_IRQ,
CONFIG_UART_PIPE_INT_PRI, uart_pipe_isr, 0,
UART_IRQ_FLAGS);
static void uart_simple_setup(struct device *uart, struct uart_init_info *info)
static void uart_pipe_setup(struct device *uart, struct uart_init_info *info)
{
uart_init(uart, info);
uart_irq_rx_disable(uart);
uart_irq_tx_disable(uart);
IRQ_CONFIG(uart_simple, uart_irq_get(uart), 0);
IRQ_CONFIG(uart_pipe, uart_irq_get(uart), 0);
irq_enable(uart_irq_get(uart));
/* Drain the fifo */
@ -92,19 +93,19 @@ static void uart_simple_setup(struct device *uart, struct uart_init_info *info)
uart_irq_rx_enable(uart);
}
void uart_simple_register(uint8_t *buf, size_t len, uart_simple_recv_cb cb)
void uart_pipe_register(uint8_t *buf, size_t len, uart_pipe_recv_cb cb)
{
struct uart_init_info info = {
.options = 0,
.sys_clk_freq = CONFIG_UART_SIMPLE_FREQ,
.baud_rate = CONFIG_UART_SIMPLE_BAUDRATE,
.irq_pri = CONFIG_UART_SIMPLE_INT_PRI,
.sys_clk_freq = CONFIG_UART_PIPE_FREQ,
.baud_rate = CONFIG_UART_PIPE_BAUDRATE,
.irq_pri = CONFIG_UART_PIPE_INT_PRI,
};
recv_buf = buf;
recv_buf_len = len;
app_cb = cb;
uart_simple_setup(UART, &info);
uart_pipe_setup(UART, &info);
}
#endif

View file

@ -1,25 +0,0 @@
# Kconfig - simple UART driver configuration options
#
# Copyright (c) 2014-2015 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
config UART_SIMPLE
bool
prompt "Simple UART driver"
select UART_INTERRUPT_DRIVEN
default n
help
Enable Simple UART driver.

View file

@ -1 +0,0 @@
obj-y=uart.o

View file

@ -1,7 +1,7 @@
/** @file
* @brief Simple UART driver header file.
* @brief Pipe UART driver header file.
*
* A simple UART driver that allows applications to handle all aspects of
* A pipe UART driver that allows applications to handle all aspects of
* received protocol data.
*/
@ -35,7 +35,7 @@
*
* @return Buffer to be used on next receive.
*/
typedef uint8_t *(*uart_simple_recv_cb)(uint8_t *buf, size_t *off);
typedef uint8_t *(*uart_pipe_recv_cb)(uint8_t *buf, size_t *off);
/** @brief Register UART application.
*
@ -45,7 +45,7 @@ typedef uint8_t *(*uart_simple_recv_cb)(uint8_t *buf, size_t *off);
* @param len Size of buffer.
* @param cb Callback to be called on data reception.
*/
void uart_simple_register(uint8_t *buf, size_t len, uart_simple_recv_cb cb);
void uart_pipe_register(uint8_t *buf, size_t len, uart_pipe_recv_cb cb);
/** @brief Send data over UART.
*
@ -56,7 +56,7 @@ void uart_simple_register(uint8_t *buf, size_t len, uart_simple_recv_cb cb);
*
* @return Number of bytes sent.
*/
int uart_simple_send(const uint8_t *data, int len);
int uart_pipe_send(const uint8_t *data, int len);
/** @brief Simple UART interrupt handler.
*
@ -65,4 +65,4 @@ int uart_simple_send(const uint8_t *data, int len);
*
* @param unused unused
*/
void uart_simple_isr(void *unused);
void uart_pipe_isr(void *unused);

View file

@ -165,7 +165,7 @@ config NETWORKING_NO_WIRED
this option is selected.
config NETWORKING_UART
bool "Network UART/slip driver"
select UART_SIMPLE
select UART_PIPE
help
Enable UART driver for passing IPv6 packets using slip.
config ETHERNET
@ -257,7 +257,7 @@ config NETWORKING_WITH_15_4_LOOPBACK
config NETWORKING_WITH_15_4_LOOPBACK_UART
bool
prompt "Enable 802.15.4 loopback radio uart driver"
select UART_SIMPLE
select UART_PIPE
help
Enable 802.15.4 loopback radio driver that sends
802.15.4 frames out of qemu through uart and receive

View file

@ -18,7 +18,7 @@
#include <stdint.h>
#include <simple/uart.h>
#include <console/uart_pipe.h>
#include "dev/slip.h"
@ -26,7 +26,7 @@ void slip_arch_writeb(unsigned char c)
{
uint8_t buf[1] = { c };
uart_simple_send(&buf[0], 1);
uart_pipe_send(&buf[0], 1);
}
void slip_arch_init(unsigned long ubr)

View file

@ -37,7 +37,7 @@
#include <string.h>
#include <stdint.h>
#include <simple/uart.h>
#include <console/uart_pipe.h>
#include <net/net_core.h>
#include <net/l2_buf.h>
@ -466,7 +466,7 @@ void slip_start(void)
/* Use small temp buffer for receiving data */
static uint8_t buf[32];
uart_simple_register(buf, sizeof(buf), recv_cb);
uart_pipe_register(buf, sizeof(buf), recv_cb);
process_start(&slip_process, NULL);
}

View file

@ -19,7 +19,7 @@
#include "contiki.h"
#include <net/l2_buf.h>
#include <simple/uart.h>
#include <console/uart_pipe.h>
#include "contiki/packetbuf.h"
#include "contiki/netstack.h"
@ -150,7 +150,7 @@ static int uart_send(unsigned char c)
__FUNCTION__, buf[0]);
#endif
return uart_simple_send(&buf[0], 1);
return uart_pipe_send(&buf[0], 1);
}
#endif
@ -162,7 +162,7 @@ init(void)
/* Use small temp buffer for receiving data */
static uint8_t buf[1];
uart_simple_register(buf, sizeof(buf), recv_cb);
uart_pipe_register(buf, sizeof(buf), recv_cb);
/* It seems that some of the start bytes are lost so
* send some null bytes in the start in order to sync

View file

@ -1,4 +1,4 @@
CONFIG_UART_SIMPLE=y
CONFIG_UART_PIPE=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_BLUETOOTH=y

View file

@ -1,4 +1,4 @@
CONFIG_UART_SIMPLE=y
CONFIG_UART_PIPE=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_BLUETOOTH=y

View file

@ -24,7 +24,7 @@
#include <toolchain.h>
#include <misc/printk.h>
#include <misc/byteorder.h>
#include <simple/uart.h>
#include <console/uart_pipe.h>
#include "bttester.h"
@ -192,7 +192,7 @@ void tester_init(void)
task_fiber_start(stack, STACKSIZE, cmd_handler, 0, 0, 7, 0);
uart_simple_register(nano_fifo_get(&avail_queue), BTP_MTU, recv_cb);
uart_pipe_register(nano_fifo_get(&avail_queue), BTP_MTU, recv_cb);
printk("BT tester initialized\n");
}
@ -207,9 +207,9 @@ static void tester_send(uint8_t service, uint8_t opcode, uint8_t index,
msg.index = index;
msg.len = len;
uart_simple_send((uint8_t *)&msg, sizeof(msg));
uart_pipe_send((uint8_t *)&msg, sizeof(msg));
if (data && len) {
uart_simple_send(data, len);
uart_pipe_send(data, len);
}
}