/************************************************************************** * arch/arm/src/kinetis/kinetis_lowputc.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * **************************************************************************/ /************************************************************************** * Included Files **************************************************************************/ #include #include #include #include #include "up_internal.h" #include "up_arch.h" #include "kinetis_config.h" #include "kinetis_internal.h" #include "kinetis_uart.h" #include "kinetis_pinmux.h" /************************************************************************** * Private Definitions **************************************************************************/ /* Select UART parameters for the selected console */ #if defined(CONFIG_UART0_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART0_BASE # define CONSOLE_BAUD CONFIG_UART0_BAUD # define CONSOLE_BITS CONFIG_UART0_BITS # define CONSOLE_PARITY CONFIG_UART0_PARITY # define CONSOLE_2STOP CONFIG_UART0_2STOP #elif defined(CONFIG_UART1_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART1_BASE # define CONSOLE_BAUD CONFIG_UART1_BAUD # define CONSOLE_BITS CONFIG_UART1_BITS # define CONSOLE_PARITY CONFIG_UART1_PARITY # define CONSOLE_2STOP CONFIG_UART1_2STOP #elif defined(CONFIG_UART2_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART2_BASE # define CONSOLE_BAUD CONFIG_UART2_BAUD # define CONSOLE_BITS CONFIG_UART2_BITS # define CONSOLE_PARITY CONFIG_UART2_PARITY # define CONSOLE_2STOP CONFIG_UART2_2STOP #elif defined(CONFIG_UART3_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART3_BASE # define CONSOLE_BAUD CONFIG_UART3_BAUD # define CONSOLE_BITS CONFIG_UART3_BITS # define CONSOLE_PARITY CONFIG_UART3_PARITY # define CONSOLE_2STOP CONFIG_UART3_2STOP #elif defined(CONFIG_UART4_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART4_BASE # define CONSOLE_BAUD CONFIG_UART4_BAUD # define CONSOLE_BITS CONFIG_UART4_BITS # define CONSOLE_PARITY CONFIG_UART4_PARITY # define CONSOLE_2STOP CONFIG_UART4_2STOP #elif defined(CONFIG_UART5_SERIAL_CONSOLE) # define CONSOLE_BASE KINETIS_UART5_BASE # define CONSOLE_BAUD CONFIG_UART5_BAUD # define CONSOLE_BITS CONFIG_UART5_BITS # define CONSOLE_PARITY CONFIG_UART5_PARITY # define CONSOLE_2STOP CONFIG_UART5_2STOP #elif defined(HAVE_CONSOLE) # error "No CONFIG_UARTn_SERIAL_CONSOLE Setting" #endif /* Get word length setting for the console */ # warning "Missing logic" /* Get parity setting for the console */ # warning "Missing logic" /* Get stop-bit setting for the console and UART0-3 */ # warning "Missing logic" /* Select a divider to produce the UART CLK */ # warning "Missing logic" /************************************************************************** * Private Types **************************************************************************/ /************************************************************************** * Private Function Prototypes **************************************************************************/ /************************************************************************** * Global Variables **************************************************************************/ /************************************************************************** * Private Variables **************************************************************************/ /************************************************************************** * Private Functions **************************************************************************/ /************************************************************************** * Public Functions **************************************************************************/ /************************************************************************** * Name: up_lowputc * * Description: * Output one byte on the serial console * **************************************************************************/ void up_lowputc(char ch) { #if defined HAVE_UART_DEVICE && defined HAVE_CONSOLE # warning "Missing logic" #endif } /************************************************************************** * Name: kinetis_lowsetup * * Description: * This performs basic initialization of the UART used for the serial * console. Its purpose is to get the console output availabe as soon * as possible. * * The UART0/1/2/3 peripherals are configured using the following registers: * 1. Power: In the PCONP register, set bits PCUART0/1/2/3. * On reset, UART0 and UART 1 are enabled (PCUART0 = 1 and PCUART1 = 1) * and UART2/3 are disabled (PCUART1 = 0 and PCUART3 = 0). * 2. Peripheral clock: In the PCLKSEL0 register, select PCLK_UART0 and * PCLK_UART1; in the PCLKSEL1 register, select PCLK_UART2 and PCLK_UART3. * 3. Baud rate: In the LCR register, set bit DLAB = 1. This enables access * to registers DLL and DLM for setting the baud rate. Also, if needed, * set the fractional baud rate in the fractional divider * 4. UART FIFO: Use bit FIFO enable (bit 0) in FCR register to * enable FIFO. * 5. Pins: Select UART pins through the PINSEL registers and pin modes * through the PINMODE registers. UART receive pins should not have * pull-down resistors enabled. * 6. Interrupts: To enable UART interrupts set bit DLAB = 0 in the LCRF * register. This enables access to IER. Interrupts are enabled * in the NVIC using the appropriate Interrupt Set Enable register. * 7. DMA: UART transmit and receive functions can operate with the * GPDMA controller. * **************************************************************************/ void kinetis_lowsetup(void) { #ifdef HAVE_UART_DEVICE /* Step 1: Enable power for all enabled UARTs */ # warning "Missing logic" /* Step 2: Enable peripheral clocking for all enabled UARTs */ # warning "Missing logic" /* Configure UART pins for the all enabled UARTs */ #ifdef CONFIG_KINETIS_UART0 kinetis_configgpio(GPIO_UART0_TX); kinetis_configgpio(GPIO_UART0_RX); #endif #ifdef CONFIG_KINETIS_UART1 kinetis_configgpio(GPIO_UART1_TX); kinetis_configgpio(GPIO_UART1_RX); #endif #ifdef CONFIG_KINETIS_UART2 kinetis_configgpio(GPIO_UART2_TX); kinetis_configgpio(GPIO_UART2_RX); #endif #ifdef CONFIG_KINETIS_UART3 kinetis_configgpio(GPIO_UART3_TX); kinetis_configgpio(GPIO_UART3_RX); #endif #ifdef CONFIG_KINETIS_UART4 kinetis_configgpio(GPIO_UART4_TX); kinetis_configgpio(GPIO_UART4_RX); #endif #ifdef CONFIG_KINETIS_UART5 kinetis_configgpio(GPIO_UART5_TX); kinetis_configgpio(GPIO_UART5_RX); #endif /* Configure the console (only) */ #if defined(HAVE_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG) kinetis_uartconfigure(CONSOLE_BASE, CONSOLE_BAUD, CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP); #endif #endif /* HAVE_UART_DEVICE */ } /****************************************************************************** * Name: kinetis_uartreset * * Description: * Reset a UART. * ******************************************************************************/ #ifdef HAVE_UART_DEVICE void kinetis_uartreset(uintptr_t uart_base) { # warning "Missing logic" } #endif /****************************************************************************** * Name: kinetis_uartconfigure * * Description: * Configure a UART as a RS-232 UART. * ******************************************************************************/ #ifdef HAVE_UART_DEVICE void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baudrate, unsigned int parity, unsigned int nbits, bool stop2) { # warning "Missing logic" } #endif