| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /*
- * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de)
- *
- * All rights reserved.
- *
- * 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 of the copyright holders nor the names of
- * 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.
- *
- * For additional information see http://www.ethernut.de/
- */
- /*
- * \verbatim
- * $Id: $
- * \endverbatim
- */
- #include <cfg/arch.h>
- #include <cfg/uart.h>
- #include <dev/debug.h>
- #include <sys/timer.h>
- #include <sys/file.h>
- #include <sys/device.h>
- #if defined(MCU_LPC177x_8x)
- #include <arch/cm3/nxp/lpc177x_8x.h>
- #include <arch/cm3/nxp/lpc177x_8x_clk.h>
- #elif defined(MCU_LPC407x_8x)
- #include <arch/cm3/nxp/lpc407x_8x.h>
- #include <arch/cm3/nxp/lpc407x_8x_clk.h>
- #else
- #warning "Unknown LPC familiy"
- #endif
- #include <arch/cm3/nxp/lpc17xx_usart.h>
- /*!
- * \addtogroup xgNutArchCm3Lpc177x_8xDebug
- */
- /*@{*/
- static NUTFILE *Lpc17xxDevDebugOpen(NUTDEVICE * dev, const char *name, int mode, int acc);
- static int Lpc17xxDevDebugClose(NUTFILE * fp);
- static int Lpc17xxDevDebugWrite(NUTFILE * fp, const void *buffer, int len);
- #ifdef NUT_DEV_DEBUG_READ
- static int Lpc17xxDevDebugRead(NUTFILE * fp, void *buffer, int size);
- static long Lpc17xxDevDebugSize(NUTFILE *fp);
- #endif
- static int Lpc17xxDevDebugIOCtl(NUTDEVICE * dev, int req, void *conf);
- static int Lpc17xxDevDebugInit(NUTDEVICE * dev);
- /*!
- * \name LPC17xx USART1 Device
- */
- /*@{*/
- static NUTFILE dbg1file;
- /*!
- * \brief Debug UART 1 device information structure.
- *
- * An application must pass a pointer to this structure to
- * NutRegisterDevice() before using the serial communication
- * driver of the LPC17xx's on-chip USART1.
- *
- * The device is named usart1.
- *
- * \showinitializer
- */
- NUTDEVICE devDebug1 = {
- NULL, /*!< Pointer to next device, dev_next. */
- {'u', 'a', 'r', 't', '1', 0, 0, 0, 0}
- , /*!< Unique device name, dev_name. */
- 0, /*!< Type of device, dev_type. */
- LPC_UART1_BASE, /*!< Base address, dev_base. */
- 0, /*!< First interrupt number, dev_irq. */
- NULL, /*!< Interface control block, dev_icb. */
- &dbg1file, /*!< Driver control block, dev_dcb. */
- Lpc17xxDevDebugInit, /*!< Driver initialization routine, dev_init. */
- Lpc17xxDevDebugIOCtl, /*!< Driver specific control function, dev_ioctl. */
- #ifdef NUT_DEV_DEBUG_READ
- Lpc17xxDevDebugRead, /*!< dev_read. */
- #else
- NULL, /*!< dev_read. */
- #endif
- Lpc17xxDevDebugWrite, /*!< dev_write. */
- Lpc17xxDevDebugOpen, /*!< dev_open. */
- Lpc17xxDevDebugClose, /*!< dev_close. */
- #ifdef NUT_DEV_DEBUG_READ
- Lpc17xxDevDebugSize, /*!< dev_size. */
- #else
- NULL, /*!< dev_size. */
- #endif
- NULL, /*!< Select function, optional, not yet implemented */
- };
- /*@}*/
- /*!
- * \brief USART1 GPIO configuartion and assignment.
- */
- #define TX_GPIO_PORT NUTGPIO_PORT0
- #define TX_GPIO_PIN 15
- #define TX_GPIO_PIN_CFG GPIO_CFG_OUTPUT | GPIO_CFG_PERIPHERAL1
- #define RX_GPIO_PORT NUTGPIO_PORT0
- #define RX_GPIO_PIN 16
- #define RX_GPIO_PIN_CFG GPIO_CFG_INPUT | GPIO_CFG_PERIPHERAL1
- /*!
- * \brief Debug UART1 base configuration.
- */
- #define USARTn LPC_UART1
- #define USARTnBase LPC_UART1_BASE
- /*@}*/
- #include "lpc17xx_debug.c"
|