git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@728 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2009-02-06 20:34:05 +00:00
parent 724de0c330
commit 77df449498
7 changed files with 694 additions and 715 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
/** @} */
/**
* @defgroup AT91SAM7X_SERIAL UART Support
* @defgroup AT91SAM7X_SERIAL USART Support
* @{
* @brief USART peripherals support.
* @details The serial driver supports the AT91SAM7X USART peripherals.

View File

@ -17,19 +17,34 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file ports/ARM7-AT91SAM7X/sam7x_serial.h
* @brief AT91SAM7X Serial driver macros and structures.
* @addtogroup AT91SAM7X_SERIAL
* @{
*/
#include <ch.h>
#include "board.h"
#include "sam7x_serial.h"
#include "at91lib/aic.h"
#if USE_SAM7X_USART0 || defined(__DOXYGEN__)
/** @brief USART0 serial driver identifier.*/
FullDuplexDriver COM1;
static uint8_t ib1[SERIAL_BUFFERS_SIZE];
static uint8_t ob1[SERIAL_BUFFERS_SIZE];
#endif
#if USE_SAM7X_USART1 || defined(__DOXYGEN__)
/** @brief USART1 serial driver identifier.*/
FullDuplexDriver COM2;
static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE];
#endif
static void SetError(AT91_REG csr, FullDuplexDriver *com) {
dflags_t sts = 0;
@ -47,10 +62,14 @@ static void SetError(AT91_REG csr, FullDuplexDriver *com) {
chSysUnlockFromIsr();
}
/*
* Serves the pending sources on the USART.
*/
/** @cond never*/
__attribute__((noinline))
/** @endcond*/
/**
* @brief Common IRQ handler.
* @param[in] u pointer to an USART I/O block
* @param[in] com communication channel associated to the USART
*/
static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
if (u->US_CSR & AT91C_US_RXRDY) {
@ -74,6 +93,7 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
AT91C_BASE_AIC->AIC_EOICR = 0;
}
#if USE_SAM7X_USART0 || defined(__DOXYGEN__)
CH_IRQ_HANDLER(USART0IrqHandler) {
CH_IRQ_PROLOGUE();
@ -83,6 +103,13 @@ CH_IRQ_HANDLER(USART0IrqHandler) {
CH_IRQ_EPILOGUE();
}
static void OutNotify1(void) {
AT91C_BASE_US0->US_IER = AT91C_US_TXRDY;
}
#endif
#if USE_SAM7X_USART1 || defined(__DOXYGEN__)
CH_IRQ_HANDLER(USART1IrqHandler) {
CH_IRQ_PROLOGUE();
@ -92,23 +119,11 @@ CH_IRQ_HANDLER(USART1IrqHandler) {
CH_IRQ_EPILOGUE();
}
/*
* Invoked by the high driver when one or more bytes are inserted in the
* output queue.
*/
static void OutNotify1(void) {
AT91C_BASE_US0->US_IER = AT91C_US_TXRDY;
}
/*
* Invoked by the high driver when one or more bytes are inserted in the
* output queue.
*/
static void OutNotify2(void) {
AT91C_BASE_US1->US_IER = AT91C_US_TXRDY;
}
#endif
/*
* USART setup, must be invoked with interrupts disabled.
@ -180,3 +195,5 @@ void InitSerial(int prio0, int prio1) {
AT91C_US_PAR_NONE |
AT91C_US_NBSTOP_1_BIT);
}
/** @} */

View File

@ -44,26 +44,26 @@
* @note It is possible to use @p SetUART() in order to change the working
* parameters at runtime.
*/
#if !defined(AT91SAM7X_UART_BITRATE) || defined(__DOXYGEN__)
#if !defined(SAM7X_UART_BITRATE) || defined(__DOXYGEN__)
#define SAM7X_UART_BITRATE 38400
#endif
/**
* @brief UART0 driver enable switch.
* @details If set to 1 the support for USART1 is included.
* @note The default is 1.
* @details If set to @p TRUE the support for USART1 is included.
* @note The default is @p TRUE.
*/
#if !defined(USE_LPC214x_UART0) || defined(__DOXYGEN__)
#define USE_SAM7X_USART0 1
#if !defined(USE_SAM7X_USART0) || defined(__DOXYGEN__)
#define USE_SAM7X_USART0 TRUE
#endif
/**
* @brief UART1 driver enable switch.
* @details If set to 1 the support for USART2 is included.
* @note The default is 1.
* @details If set to @p TRUE the support for USART2 is included.
* @note The default is @p TRUE.
*/
#if !defined(USE_LPC214x_UART1) || defined(__DOXYGEN__)
#define USE_SAM7X_USART1 1
#if !defined(USE_SAM7X_USART1) || defined(__DOXYGEN__)
#define USE_SAM7X_USART1 TRUE
#endif
#ifdef __cplusplus

View File

@ -157,9 +157,6 @@ static void preload(UART *u, FullDuplexDriver *com) {
#endif
#if USE_LPC214x_UART0 || defined(__DOXYGEN__)
/**
* @brief UART0 IRQ service routine.
*/
CH_IRQ_HANDLER(UART0IrqHandler) {
CH_IRQ_PROLOGUE();
@ -170,9 +167,6 @@ CH_IRQ_HANDLER(UART0IrqHandler) {
CH_IRQ_EPILOGUE();
}
/**
* @brief Output queue insertion notification from the high driver.
*/
static void OutNotify1(void) {
#if LPC214x_UART_FIFO_PRELOAD > 0
@ -191,9 +185,6 @@ static void OutNotify1(void) {
#endif
#if USE_LPC214x_UART1 || defined(__DOXYGEN__)
/**
* @brief UART1 IRQ service routine.
*/
CH_IRQ_HANDLER(UART1IrqHandler) {
CH_IRQ_PROLOGUE();
@ -204,9 +195,6 @@ CH_IRQ_HANDLER(UART1IrqHandler) {
CH_IRQ_EPILOGUE();
}
/**
* @brief Output queue insertion notification from the high driver.
*/
static void OutNotify2(void) {
#if LPC214x_UART_FIFO_PRELOAD > 0

View File

@ -103,9 +103,6 @@ static void ServeInterrupt(USART_TypeDef *u, FullDuplexDriver *com) {
}
#if USE_STM32_USART1 || defined(__DOXYGEN__)
/**
* @brief USART1 IRQ service routine.
*/
CH_IRQ_HANDLER(VectorD4) {
CH_IRQ_PROLOGUE();
@ -115,9 +112,6 @@ CH_IRQ_HANDLER(VectorD4) {
CH_IRQ_EPILOGUE();
}
/**
* @brief Output queue insertion notification from the high driver.
*/
static void OutNotify1(void) {
USART1->CR1 |= CR1_TXEIE;
@ -125,9 +119,6 @@ static void OutNotify1(void) {
#endif
#if USE_STM32_USART2 || defined(__DOXYGEN__)
/**
* @brief USART2 IRQ service routine.
*/
CH_IRQ_HANDLER(VectorD8) {
CH_IRQ_PROLOGUE();
@ -137,9 +128,6 @@ CH_IRQ_HANDLER(VectorD8) {
CH_IRQ_EPILOGUE();
}
/**
* @brief Output queue insertion notification from the high driver.
*/
static void OutNotify2(void) {
USART2->CR1 |= CR1_TXEIE;
@ -147,9 +135,6 @@ static void OutNotify2(void) {
#endif
#if USE_STM32_USART3 || defined(__DOXYGEN__)
/**
* @brief USART3 IRQ service routine.
*/
CH_IRQ_HANDLER(VectorDC) {
CH_IRQ_PROLOGUE();
@ -159,9 +144,6 @@ CH_IRQ_HANDLER(VectorDC) {
CH_IRQ_EPILOGUE();
}
/**
* @brief Output queue insertion notification from the high driver.
*/
static void OutNotify3(void) {
USART3->CR1 |= CR1_TXEIE;

View File

@ -84,10 +84,6 @@ CH_IRQ_HANDLER(USART0RX_VECTOR) {
CH_IRQ_EPILOGUE();
}
/*
* Invoked by the high driver when one or more bytes are inserted in the
* output queue.
*/
static void OutNotify1(void) {
if (!(U0IE & UTXIE0)) {
@ -163,10 +159,6 @@ CH_IRQ_HANDLER(USART1RX_VECTOR) {
CH_IRQ_EPILOGUE();
}
/*
* Invoked by the high driver when one or more bytes are inserted in the
* output queue.
*/
static void OutNotify2(void) {
if (!(U1IE & UTXIE1)) {