mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-14 12:41:56 +00:00
The peripherals utilizing UART were required to register their own ISR rountines. This means that all those peripherals drivers need to know which IRQ line is attached to a UART controller, and all the other config values required to register a ISR. This causes scalibility issue as every board and peripherals have to define those values. Another reason for this patch is to support virtual serial ports. Virtual serial ports do not have physical interrupt lines to attach, and thus would not work. This patch adds a simple callback mechanism, which calls a function when UART interrupts are triggered. The low level plumbing still needs to be done by the peripheral drivers, as these drivers may need to access low level capability of UART to function correctly. This simply moves the interrupt setup into the UART drivers themselves. By doing this, the peripheral drivers do not need to know all the config values to properly setup the interrupts and attaching the ISR. One drawback is that this adds to the interrupt latency. Note that this patch breaks backward compatibility in terms of setting up interrupt for UART controller. How to use UART is still the same. This also addresses the following issues: () UART driver for Atmel SAM3 currently does not support interrupts. So remove the code from vector table. This will be updated when there is interrupt support for the driver. () Corrected some config options for Stellaris UART driver. This was tested with samples/shell on Arduino 101, and on QEMU (Cortex-M3 and x86). Origin: original code Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec Signed-off-by: Daniel Leung <daniel.leung@intel.com>
54 lines
1.5 KiB
C
54 lines
1.5 KiB
C
/* uart_console.h - uart console driver */
|
|
|
|
/*
|
|
* Copyright (c) 2011, 2014 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.
|
|
*/
|
|
|
|
#ifndef _UART_CONSOLE__H_
|
|
#define _UART_CONSOLE__H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <nanokernel.h>
|
|
|
|
#define MAX_LINE_LEN 256
|
|
struct uart_console_input {
|
|
int _unused;
|
|
char line[MAX_LINE_LEN];
|
|
};
|
|
|
|
/** @brief Register uart input processing
|
|
*
|
|
* Input processing is started when string is typed in the console.
|
|
* Carriage return is translated to NULL making string always NULL
|
|
* terminated. Application before calling register function need to
|
|
* initialize two fifo queues mentioned below.
|
|
*
|
|
* @param avail nano_fifo queue keeping available input slots
|
|
* @param lines nano_fifo queue of entered lines which to be processed
|
|
* in the application code.
|
|
*
|
|
* @return N/A
|
|
*/
|
|
void uart_register_input(struct nano_fifo *avail, struct nano_fifo *lines);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _UART_CONSOLE__H_ */
|