diff options
| author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-01 15:29:17 +0000 | 
|---|---|---|
| committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-01 15:29:17 +0000 | 
| commit | 307e9891e40e46b08cd15690da8fff1657172915 (patch) | |
| tree | 0b62c8e7972e24320c1091d957f7a2764de829dc /os/hal | |
| parent | f8c40043e469d81f2a9f380d6723b92c79bd30bc (diff) | |
| download | ChibiOS-307e9891e40e46b08cd15690da8fff1657172915.tar.gz ChibiOS-307e9891e40e46b08cd15690da8fff1657172915.tar.bz2 ChibiOS-307e9891e40e46b08cd15690da8fff1657172915.zip | |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1486 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
| -rw-r--r-- | os/hal/platforms/AT91SAM7/serial_lld.c | 2 | ||||
| -rw-r--r-- | os/hal/platforms/AT91SAM7/serial_lld.h | 2 | ||||
| -rw-r--r-- | os/hal/platforms/AVR/serial_lld.c | 39 | ||||
| -rw-r--r-- | os/hal/platforms/AVR/serial_lld.h | 79 | ||||
| -rw-r--r-- | os/hal/platforms/LPC214x/serial_lld.c | 155 | ||||
| -rw-r--r-- | os/hal/platforms/LPC214x/serial_lld.h | 88 | ||||
| -rw-r--r-- | os/hal/platforms/STM32/serial_lld.c | 3 | ||||
| -rw-r--r-- | os/hal/platforms/STM32/serial_lld.h | 6 | 
8 files changed, 197 insertions, 177 deletions
| diff --git a/os/hal/platforms/AT91SAM7/serial_lld.c b/os/hal/platforms/AT91SAM7/serial_lld.c index 8fac96e33..d310153e6 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.c +++ b/os/hal/platforms/AT91SAM7/serial_lld.c @@ -266,7 +266,6 @@ void sd_lld_start(SerialDriver *sdp) {        AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_US0);
        /* Enables associated interrupt vector.*/
        AIC_EnableIT(AT91C_ID_US0);
 -      return;
      }
  #endif
  #if USE_SAM7_USART1
 @@ -275,7 +274,6 @@ void sd_lld_start(SerialDriver *sdp) {        AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_US1);
        /* Enables associated interrupt vector.*/
        AIC_EnableIT(AT91C_ID_US1);
 -      return;
      }
  #endif
    }
 diff --git a/os/hal/platforms/AT91SAM7/serial_lld.h b/os/hal/platforms/AT91SAM7/serial_lld.h index 7b7deba95..b79439c04 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.h +++ b/os/hal/platforms/AT91SAM7/serial_lld.h @@ -78,7 +78,7 @@  /*===========================================================================*/
  /**
 - * Serial Driver condition flags type.
 + * @brief Serial Driver condition flags type.
   */
  typedef uint32_t sdflags_t;
 diff --git a/os/hal/platforms/AVR/serial_lld.c b/os/hal/platforms/AVR/serial_lld.c index 166663c44..0244471a6 100644 --- a/os/hal/platforms/AVR/serial_lld.c +++ b/os/hal/platforms/AVR/serial_lld.c @@ -58,7 +58,7 @@ SerialDriver SD2;  /**
   * @brief Driver default configuration.
   */
 -static const SerialDriverConfig default_config = {
 +static const SerialConfig default_config = {
    UBRR(DEFAULT_USART_BITRATE),
    (1 << UCSZ1) | (1 << UCSZ0)
  };
 @@ -91,13 +91,13 @@ static void notify1(void) {   * @brief USART0 initialization.
   * @param[in] config the architecture-dependent serial driver configuration
   */
 -static void usart0_init(const SerialDriverConfig *config) {
 +static void usart0_init(const SerialConfig *config) {
 -  UBRR0L = config->brr;
 -  UBRR0H = config->brr >> 8;
 +  UBRR0L = config->sc_brr;
 +  UBRR0H = config->sc_brr >> 8;
    UCSR0A = 0;
    UCSR0B = (1 << RXEN) | (1 << TXEN) | (1 << RXCIE);
 -  UCSR0C = config->csrc;
 +  UCSR0C = config->sc_csrc;
  }
  /**
 @@ -121,13 +121,13 @@ static void notify2(void) {   * @brief USART1 initialization.
   * @param[in] config the architecture-dependent serial driver configuration
   */
 -static void usart1_init(const SerialDriverConfig *config) {
 +static void usart1_init(const SerialConfig *config) {
 -  UBRR1L = config->brr;
 -  UBRR1H = config->brr >> 8;
 +  UBRR1L = config->sc_brr;
 +  UBRR1H = config->sc_brr >> 8;
    UCSR1A = 0;
    UCSR1B = (1 << RXEN) | (1 << TXEN) | (1 << RXCIE);
 -  UCSR1C = config->csrc;
 +  UCSR1C = config->sc_csrc;
  }
  /**
 @@ -232,20 +232,19 @@ void sd_lld_init(void) {   * @brief Low level serial driver configuration and (re)start.
   *
   * @param[in] sdp pointer to a @p SerialDriver object
 - * @param[in] config the architecture-dependent serial driver configuration.
 - *                   If this parameter is set to @p NULL then a default
 - *                   configuration is used.
   */
 -void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {
 +void sd_lld_start(SerialDriver *sdp) {
 -  if (config == NULL)
 -    config = &default_config;
 +  if (sdp->sd.config == NULL)
 +    sdp->sd.config = &default_config;
  #if USE_AVR_USART0
 -  usart0_init(config);
 +  if (&SD1 == sdp)
 +    usart0_init(sdp->sd.config);
  #endif
  #if USE_AVR_USART1
 -  usart1_init(config);
 +  if (&SD2 == sdp)
 +    usart1_init(sdp->sd.config);
  #endif
  }
 @@ -259,10 +258,12 @@ void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {  void sd_lld_stop(SerialDriver *sdp) {
  #if USE_AVR_USART0
 -  usart0_deinit();
 +  if (&SD1 == sdp)
 +    usart0_deinit();
  #endif
  #if USE_AVR_USART1
 -  usart1_deinit();
 +  if (&SD2 == sdp)
 +    usart1_deinit();
  #endif
  }
 diff --git a/os/hal/platforms/AVR/serial_lld.h b/os/hal/platforms/AVR/serial_lld.h index ad0ffdd3a..79d070635 100644 --- a/os/hal/platforms/AVR/serial_lld.h +++ b/os/hal/platforms/AVR/serial_lld.h @@ -38,16 +38,6 @@  /*===========================================================================*/
  /**
 - * @brief Serial buffers size.
 - * @details Configuration parameter, you can change the depth of the queue
 - * buffers depending on the requirements of your application.
 - * @note The default is 32 bytes for both the transmission and receive buffers.
 - */
 -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
 -#define SERIAL_BUFFERS_SIZE 32
 -#endif
 -
 -/**
   * @brief Default bit rate.
   * @details Configuration parameter, at startup the UARTs are configured at
   * this speed.
 @@ -86,53 +76,68 @@  /*===========================================================================*/
  /**
 - * Serial Driver condition flags type.
 + * @brief Serial Driver condition flags type.
   */
  typedef uint8_t sdflags_t;
  /**
 + * @brief AVR Serial Driver configuration structure.
 + * @details An instance of this structure must be passed to @p sdStart()
 + *          in order to configure and start a serial driver operations.
 + */
 +typedef struct {
 +  /**
 +   * @brief Initialization value for the BRR register.
 +   */
 +  uint16_t                  sc_brr;
 +  /**
 +   * @brief Initialization value for the CSRC register.
 +   */
 +  uint8_t                   sc_csrc;
 +} SerialConfig;
 +
 +/**
   * @brief @p SerialDriver specific data.
   */
  struct _serial_driver_data {
    /**
 -   * Input queue, incoming data can be read from this input queue by
 -   * using the queues APIs.
 +   * @brief Driver state.
 +   */
 +  sdstate_t                 state;
 +  /**
 +   * @brief Current configuration data.
     */
 -  InputQueue            iqueue;
 +  const SerialConfig        *config;
    /**
 -   * Output queue, outgoing data can be written to this output queue by
 -   * using the queues APIs.
 +   * @brief Input queue, incoming data can be read from this input queue by
 +   *        using the queues APIs.
     */
 -  OutputQueue           oqueue;
 +  InputQueue                iqueue;
    /**
 -   * Status Change @p EventSource. This event is generated when one or more
 -   * condition flags change.
 +   * @brief Output queue, outgoing data can be written to this output queue by
 +   *        using the queues APIs.
     */
 -  EventSource           sevent;
 +  OutputQueue               oqueue;
    /**
 -   * I/O driver status flags.
 +   * @brief Status Change @p EventSource. This event is generated when one or
 +   *        more condition flags change.
     */
 -  sdflags_t             flags;
 +  EventSource               sevent;
    /**
 -   * Input circular buffer. +   * @brief I/O driver status flags.
     */
 -  uint8_t               ib[SERIAL_BUFFERS_SIZE];
 +  sdflags_t                 flags;
    /**
 -   * Output circular buffer. +   * @brief Input circular buffer.
     */
 -  uint8_t               ob[SERIAL_BUFFERS_SIZE];
 +  uint8_t                   ib[SERIAL_BUFFERS_SIZE];
 +  /**
 +   * @brief Output circular buffer.
 +   */
 +  uint8_t                   ob[SERIAL_BUFFERS_SIZE];
 +  /* End of the mandatory fields.*/
  };
 -/**
 - * @brief AVR Serial Driver configuration structure.
 - * @details An instance of this structure must be passed to @p sdStart()
 - *          in order to configure and start a serial driver operations.
 - */
 -typedef struct {
 -  uint16_t              brr;
 -  uint8_t               csrc;
 -} SerialDriverConfig;
 -
  /*===========================================================================*/
  /* Driver macros.                                                            */
  /*===========================================================================*/
 @@ -159,7 +164,7 @@ extern SerialDriver SD2;  extern "C" {
  #endif
    void sd_lld_init(void);
 -  void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config);
 +  void sd_lld_start(SerialDriver *sdp);
    void sd_lld_stop(SerialDriver *sdp);
  #ifdef __cplusplus
  }
 diff --git a/os/hal/platforms/LPC214x/serial_lld.c b/os/hal/platforms/LPC214x/serial_lld.c index 819b2df9a..80d828155 100644 --- a/os/hal/platforms/LPC214x/serial_lld.c +++ b/os/hal/platforms/LPC214x/serial_lld.c @@ -48,7 +48,7 @@ SerialDriver SD2;  /*===========================================================================*/
  /** @brief Driver default configuration.*/
 -static const SerialDriverConfig default_config = {
 +static const SerialConfig default_config = {
    38400,
    LCR_WL8 | LCR_STOP1 | LCR_NOPARITY,
    FCR_TRIGGER0
 @@ -60,17 +60,18 @@ static const SerialDriverConfig default_config = {  /**
   * @brief UART initialization.
 - * @param[in] u pointer to an UART I/O block
 - * @param[in] config the architecture-dependent serial driver configuration
 + *
 + * @param[in] sdp communication channel associated to the UART
   */
 -static void uart_init(UART *u, const SerialDriverConfig *config) {
 +static void uart_init(SerialDriver *sdp) {
 +  UART *u = sdp->sd.uart;
 -  uint32_t div = PCLK / (config->speed << 4);
 -  u->UART_LCR = config->lcr | LCR_DLAB;
 +  uint32_t div = PCLK / (sdp->sd.config->sc_speed << 4);
 +  u->UART_LCR = sdp->sd.config->sc_lcr | LCR_DLAB;
    u->UART_DLL = div;
    u->UART_DLM = div >> 8;
 -  u->UART_LCR = config->lcr;
 -  u->UART_FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | config->fcr;
 +  u->UART_LCR = sdp->sd.config->sc_lcr;
 +  u->UART_FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | sdp->sd.config->sc_fcr;
    u->UART_ACR = 0;
    u->UART_FDR = 0x10;
    u->UART_TER = TER_ENABLE;
 @@ -79,6 +80,7 @@ static void uart_init(UART *u, const SerialDriverConfig *config) {  /**
   * @brief UART de-initialization.
 + *
   * @param[in] u pointer to an UART I/O block
   */
  static void uart_deinit(UART *u) {
 @@ -95,10 +97,11 @@ static void uart_deinit(UART *u) {  /**
   * @brief Error handling routine.
 - * @param[in] err UART LSR register value
 + *
   * @param[in] sdp communication channel associated to the UART
 + * @param[in] err UART LSR register value
   */
 -static void set_error(IOREG32 err, SerialDriver *sdp) {
 +static void set_error(SerialDriver *sdp, IOREG32 err) {
    sdflags_t sts = 0;
    if (err & LSR_OVERRUN)
 @@ -124,55 +127,59 @@ __attribute__((noinline))   * @note Tries hard to clear all the pending interrupt sources, we dont want to
   *       go through the whole ISR and have another interrupt soon after.
   */
 -static void serve_interrupt(UART *u, SerialDriver *sdp) {
 +static void serve_interrupt(SerialDriver *sdp) {
 +  UART *u = sdp->sd.uart;
    while (TRUE) {
 +    int i;
      switch (u->UART_IIR & IIR_SRC_MASK) {
      case IIR_SRC_NONE:
        return;
      case IIR_SRC_ERROR:
 -      set_error(u->UART_LSR, sdp);
 +      set_error(sdp, u->UART_LSR);
        break;
      case IIR_SRC_TIMEOUT:
      case IIR_SRC_RX:
 +      chSysLockFromIsr();
 +      if (chIQIsEmpty(&sdp->sd.iqueue))
 +        chEvtBroadcastI(&sdp->bac.ievent);
 +      chSysUnlockFromIsr();
        while (u->UART_LSR & LSR_RBR_FULL) {
          chSysLockFromIsr();
 -        if (chIQPutI(&sdp->d2.iqueue, u->UART_RBR) < Q_OK)
 +        if (chIQPutI(&sdp->sd.iqueue, u->UART_RBR) < Q_OK)
             sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
          chSysUnlockFromIsr();
        }
 -      chSysLockFromIsr();
 -      chEvtBroadcastI(&sdp->d1.ievent);
 -      chSysUnlockFromIsr();
        break;
      case IIR_SRC_TX:
 -      {
  #if UART_FIFO_PRELOAD > 0
 -        int i = UART_FIFO_PRELOAD;
 -        do {
 -          chSysLockFromIsr();
 -          msg_t b = chOQGetI(&sdp->d2.oqueue);
 -          chSysUnlockFromIsr();
 -          if (b < Q_OK) {
 -            u->UART_IER &= ~IER_THRE;
 -            chSysLockFromIsr();
 -            chEvtBroadcastI(&sdp->d1.oevent);
 -            chSysUnlockFromIsr();
 -            break;
 -          }
 -          u->UART_THR = b;
 -        } while (--i);
 -#else
 +      i = UART_FIFO_PRELOAD;
 +      do {
 +        msg_t b;
 +
          chSysLockFromIsr();
 -        msg_t b = sdRequestDataI(sdp);
 +        b = chOQGetI(&sdp->sd.oqueue);
          chSysUnlockFromIsr();
 -        if (b < Q_OK)
 +        if (b < Q_OK) {
            u->UART_IER &= ~IER_THRE;
 -        else
 -          u->UART_THR = b;
 +          chSysLockFromIsr();
 +          chEvtBroadcastI(&sdp->bac.oevent);
 +          chSysUnlockFromIsr();
 +          break;
 +        }
 +        u->UART_THR = b;
 +      } while (--i);
 +#else
 +      chSysLockFromIsr();
 +      msg_t b = sdRequestDataI(sdp);
 +      chSysUnlockFromIsr();
 +      if (b < Q_OK)
 +        u->UART_IER &= ~IER_THRE;
 +      else
 +        u->UART_THR = b;
  #endif
 -      }
 +      break;
      default:
        (void) u->UART_THR;
        (void) u->UART_RBR;
 @@ -181,17 +188,18 @@ static void serve_interrupt(UART *u, SerialDriver *sdp) {  }
  #if UART_FIFO_PRELOAD > 0
 -static void preload(UART *u, SerialDriver *sdp) {
 +static void preload(SerialDriver *sdp) {
 +  UART *u = sdp->sd.uart;
    if (u->UART_LSR & LSR_THRE) {
      int i = UART_FIFO_PRELOAD;
      do {
        chSysLockFromIsr();
 -      msg_t b = chOQGetI(&sdp->d2.oqueue);
 +      msg_t b = chOQGetI(&sdp->sd.oqueue);
        chSysUnlockFromIsr();
        if (b < Q_OK) {
          chSysLockFromIsr();
 -        chEvtBroadcastI(&sdp->d1.oevent);
 +        chEvtBroadcastI(&sdp->bac.oevent);
          chSysUnlockFromIsr();
          return;
        }
 @@ -206,7 +214,7 @@ static void preload(UART *u, SerialDriver *sdp) {  static void notify1(void) {
  #if UART_FIFO_PRELOAD > 0
 -  preload(U0Base, &SD1);
 +  preload(&SD1);
  #else
    UART *u = U0Base;
 @@ -224,7 +232,7 @@ static void notify1(void) {  static void notify2(void) {
  #if UART_FIFO_PRELOAD > 0
 -  preload(U1Base, &SD2);
 +  preload(&SD2);
  #else
    UART *u = U1Base;
 @@ -244,7 +252,7 @@ CH_IRQ_HANDLER(UART0IrqHandler) {    CH_IRQ_PROLOGUE();
 -  serve_interrupt(U0Base, &SD1);
 +  serve_interrupt(&SD1);
    VICVectAddr = 0;
    CH_IRQ_EPILOGUE();
 @@ -256,7 +264,7 @@ CH_IRQ_HANDLER(UART1IrqHandler) {    CH_IRQ_PROLOGUE();
 -  serve_interrupt(U1Base, &SD2);
 +  serve_interrupt(&SD2);
    VICVectAddr = 0;
    CH_IRQ_EPILOGUE();
 @@ -275,10 +283,12 @@ void sd_lld_init(void) {  #if USE_LPC214x_UART0
    sdObjectInit(&SD1, NULL, notify1);
 +  SD1.sd.uart = U0Base;
    SetVICVector(UART0IrqHandler, LPC214x_UART1_PRIORITY, SOURCE_UART0);
  #endif
  #if USE_LPC214x_UART1
    sdObjectInit(&SD2, NULL, notify2);
 +  SD2.sd.uart = U1Base;
    SetVICVector(UART1IrqHandler, LPC214x_UART2_PRIORITY, SOURCE_UART1);
  #endif
  }
 @@ -287,31 +297,27 @@ void sd_lld_init(void) {   * @brief Low level serial driver configuration and (re)start.
   *
   * @param[in] sdp pointer to a @p SerialDriver object
 - * @param[in] config the architecture-dependent serial driver configuration.
 - *                   If this parameter is set to @p NULL then a default
 - *                   configuration is used.
   */
 -void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {
 +void sd_lld_start(SerialDriver *sdp) {
 -  if (config == NULL)
 -    config = &default_config;
 +  if (sdp->sd.config == NULL)
 +    sdp->sd.config = &default_config;
 +  if (sdp->sd.state == SD_STOP) {
  #if USE_LPC214x_UART1
 -  if (&SD1 == sdp) {
 -    PCONP = (PCONP & PCALL) | PCUART0;
 -    uart_init(U0Base, config);
 -    VICIntEnable = INTMASK(SOURCE_UART0);
 -    return;
 -  }
 +    if (&SD1 == sdp) {
 +      PCONP = (PCONP & PCALL) | PCUART0;
 +      VICIntEnable = INTMASK(SOURCE_UART0);
 +    }
  #endif
  #if USE_LPC214x_UART2
 -  if (&SD2 == sdp) {
 -    PCONP = (PCONP & PCALL) | PCUART1;
 -    uart_init(U1Base, config);
 -    VICIntEnable = INTMASK(SOURCE_UART1);
 -    return;
 -  }
 +    if (&SD2 == sdp) {
 +      PCONP = (PCONP & PCALL) | PCUART1;
 +      VICIntEnable = INTMASK(SOURCE_UART1);
 +    }
  #endif
 +  }
 +  uart_init(sdp);
  }
  /**
 @@ -323,22 +329,23 @@ void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {   */
  void sd_lld_stop(SerialDriver *sdp) {
 +  if (sdp->sd.state == SD_READY) {
 +    uart_deinit(sdp->sd.uart);
  #if USE_LPC214x_UART1
 -  if (&SD1 == sdp) {
 -    uart_deinit(U0Base);
 -    PCONP = (PCONP & PCALL) & ~PCUART0;
 -    VICIntEnClear = INTMASK(SOURCE_UART0);
 -    return;
 -  }
 +    if (&SD1 == sdp) {
 +      PCONP = (PCONP & PCALL) & ~PCUART0;
 +      VICIntEnClear = INTMASK(SOURCE_UART0);
 +      return;
 +    }
  #endif
  #if USE_LPC214x_UART2
 -  if (&SD2 == sdp) {
 -    uart_deinit(U1Base);
 -    PCONP = (PCONP & PCALL) & ~PCUART1;
 -    VICIntEnClear = INTMASK(SOURCE_UART1);
 -    return;
 -  }
 +    if (&SD2 == sdp) {
 +      PCONP = (PCONP & PCALL) & ~PCUART1;
 +      VICIntEnClear = INTMASK(SOURCE_UART1);
 +      return;
 +    }
  #endif
 +  }
  }
  #endif /* CH_HAL_USE_SERIAL */
 diff --git a/os/hal/platforms/LPC214x/serial_lld.h b/os/hal/platforms/LPC214x/serial_lld.h index cea587935..e8371104a 100644 --- a/os/hal/platforms/LPC214x/serial_lld.h +++ b/os/hal/platforms/LPC214x/serial_lld.h @@ -38,16 +38,6 @@  /*===========================================================================*/
  /**
 - * @brief Serial buffers size.
 - * @details Configuration parameter, you can change the depth of the queue
 - * buffers depending on the requirements of your application.
 - * @note The default is 128 bytes for both the transmission and receive buffers.
 - */
 -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
 -#define SERIAL_BUFFERS_SIZE 128
 -#endif
 -
 -/**
   * @brief FIFO preload parameter.
   * @details Configuration parameter, this values defines how many bytes are
   * preloaded in the HW transmit FIFO for each interrupt, the maximum value is
 @@ -104,54 +94,76 @@  /*===========================================================================*/
  /**
 - * Serial Driver condition flags type.
 + * @brief Serial Driver condition flags type.
   */
  typedef uint32_t sdflags_t;
  /**
 + * @brief LPC214x Serial Driver configuration structure.
 + * @details An instance of this structure must be passed to @p sdStart()
 + *          in order to configure and start a serial driver operations.
 + */
 +typedef struct {
 +  /**
 +   * @brief Bit rate.
 +   */
 +  uint32_t                  sc_speed;
 +  /**
 +   * @brief Initialization value for the LCR register.
 +   */
 +  uint32_t                  sc_lcr;
 +  /**
 +   * @brief Initialization value for the FCR register.
 +   */
 +  uint32_t                  sc_fcr;
 +} SerialConfig;
 +
 +/**
   * @brief @p SerialDriver specific data.
   */
  struct _serial_driver_data {
    /**
 -   * Input queue, incoming data can be read from this input queue by
 -   * using the queues APIs.
 +   * @brief Driver state.
 +   */
 +  sdstate_t                 state;
 +  /**
 +   * @brief Current configuration data.
 +   */
 +  const SerialConfig        *config;
 +  /**
 +   * @brief Input queue, incoming data can be read from this input queue by
 +   *        using the queues APIs.
 +   */
 +  InputQueue                iqueue;
 +  /**
 +   * @brief Output queue, outgoing data can be written to this output queue by
 +   *        using the queues APIs.
     */
 -  InputQueue            iqueue;
 +  OutputQueue               oqueue;
    /**
 -   * Output queue, outgoing data can be written to this output queue by
 -   * using the queues APIs.
 +   * @brief Status Change @p EventSource. This event is generated when one or
 +   *        more condition flags change.
     */
 -  OutputQueue           oqueue;
 +  EventSource               sevent;
    /**
 -   * Status Change @p EventSource. This event is generated when one or more
 -   * condition flags change.
 +   * @brief I/O driver status flags.
     */
 -  EventSource           sevent;
 +  sdflags_t                 flags;
    /**
 -   * I/O driver status flags.
 +   * @brief Input circular buffer.
     */
 -  sdflags_t             flags;
 +  uint8_t                   ib[SERIAL_BUFFERS_SIZE];
    /**
 -   * Input circular buffer. +   * @brief Output circular buffer.
     */
 -  uint8_t               ib[SERIAL_BUFFERS_SIZE];
 +  uint8_t                   ob[SERIAL_BUFFERS_SIZE];
 +  /* End of the mandatory fields.*/
    /**
 -   * Output circular buffer. +   * @brief Pointer to the USART registers block.
     */
 -  uint8_t               ob[SERIAL_BUFFERS_SIZE];
 +  UART                      *uart;
  };
 -/**
 - * @brief LPC214x Serial Driver configuration structure.
 - * @details An instance of this structure must be passed to @p sdStart()
 - *          in order to configure and start a serial driver operations.
 - */
 -typedef struct {
 -  uint32_t              speed;
 -  uint32_t              lcr;
 -  uint32_t              fcr;
 -} SerialDriverConfig;
 -
  /*===========================================================================*/
  /* Driver macros.                                                            */
  /*===========================================================================*/
 @@ -172,7 +184,7 @@ extern SerialDriver SD2;  extern "C" {
  #endif
    void sd_lld_init(void);
 -  void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config);
 +  void sd_lld_start(SerialDriver *sdp);
    void sd_lld_stop(SerialDriver *sdp);
  #ifdef __cplusplus
  }
 diff --git a/os/hal/platforms/STM32/serial_lld.c b/os/hal/platforms/STM32/serial_lld.c index 6d28fe71f..6a9f71673 100644 --- a/os/hal/platforms/STM32/serial_lld.c +++ b/os/hal/platforms/STM32/serial_lld.c @@ -264,21 +264,18 @@ void sd_lld_start(SerialDriver *sdp) {      if (&SD1 == sdp) {
        RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
        NVICEnableVector(USART1_IRQn, STM32_USART1_PRIORITY);
 -      return;
      }
  #endif
  #if USE_STM32_USART2
      if (&SD2 == sdp) {
        RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
        NVICEnableVector(USART2_IRQn, STM32_USART2_PRIORITY);
 -      return;
      }
  #endif
  #if USE_STM32_USART3
      if (&SD3 == sdp) {
        RCC->APB1ENR |= RCC_APB1ENR_USART3EN;
        NVICEnableVector(USART3_IRQn, STM32_USART3_PRIORITY);
 -      return;
      }
  #endif
    }
 diff --git a/os/hal/platforms/STM32/serial_lld.h b/os/hal/platforms/STM32/serial_lld.h index 64c74f5f9..97a56a332 100644 --- a/os/hal/platforms/STM32/serial_lld.h +++ b/os/hal/platforms/STM32/serial_lld.h @@ -43,7 +43,7 @@   * @note The default is @p FALSE.
   */
  #if !defined(USE_STM32_USART1) || defined(__DOXYGEN__)
 -#define USE_STM32_USART1            FALSE
 +#define USE_STM32_USART1            TRUE
  #endif
  /**
 @@ -61,7 +61,7 @@   * @note The default is @p FALSE.
   */
  #if !defined(USE_STM32_USART3) || defined(__DOXYGEN__)
 -#define USE_STM32_USART3            FALSE
 +#define USE_STM32_USART3            TRUE
  #endif
  /**
 @@ -97,7 +97,7 @@  /*===========================================================================*/
  /**
 - * Serial Driver condition flags type.
 + * @brief Serial Driver condition flags type.
   */
  typedef uint32_t sdflags_t;
 | 
