/*
    ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio

    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.
*/

/**
 * @defgroup SERIAL Serial Driver
 * @brief   Generic Serial Driver.
 * @details This module implements a generic full duplex serial driver. The
 *          driver implements a @p SerialDriver interface and uses I/O Queues
 *          for communication between the upper and the lower driver. Event
 *          flags are used to notify the application about incoming data,
 *          outgoing data and other I/O events.<br>
 *          The  module also contains functions that make the implementation
 *          of the interrupt service routines much easier.
 * @pre     In order to use the SERIAL driver the @p HAL_USE_SERIAL option
 *          must be enabled in @p halconf.h.
 *
 *
 * @section serial_1 Driver State Machine
 * The driver implements a state machine internally, not all the driver
 * functionalities can be used in any moment, any transition not explicitly
 * shown in the following diagram has to be considered an error and shall
 * be captured by an assertion (if enabled).
 * @dot
  digraph example {
    rankdir="LR";
    node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true",
          width="0.9", height="0.9"];
    edge [fontname=Helvetica, fontsize=8];

    uninit [label="SD_UNINIT", style="bold"];
    stop [label="SD_STOP\nLow Power"];
    ready [label="SD_READY\nClock Enabled"];

    uninit -> stop [label=" sdInit()"];
    stop -> stop [label="\nsdStop()"];
    stop -> ready [label="\nsdStart()"];
    ready -> stop [label="\nsdStop()"];
    ready -> ready [label="\nsdStart()"];
    ready -> ready [label="\nAny I/O operation"];
  }
 * @enddot
 *
 * @ingroup HAL_NORMAL_DRIVERS
 */
