2014-11-01 17:02:44 +00:00
|
|
|
/*
|
2016-03-18 10:29:35 +00:00
|
|
|
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
|
2014-11-01 17:02:44 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2016-04-02 07:59:24 +00:00
|
|
|
* @file hal_serial_lld.h
|
2014-11-02 16:38:13 +00:00
|
|
|
* @brief PLATFORM serial subsystem low level driver header.
|
2014-11-01 17:02:44 +00:00
|
|
|
*
|
|
|
|
* @addtogroup SERIAL
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-04-02 07:59:24 +00:00
|
|
|
#ifndef HAL_SERIAL_LLD_H
|
|
|
|
#define HAL_SERIAL_LLD_H
|
2014-11-01 17:02:44 +00:00
|
|
|
|
2015-03-09 10:48:08 +00:00
|
|
|
#if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
|
2014-11-01 17:02:44 +00:00
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver constants. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver pre-compile time settings. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
2014-12-11 14:45:16 +00:00
|
|
|
* @name PLATFORM configuration options
|
2014-11-01 17:02:44 +00:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/**
|
2014-11-02 10:41:41 +00:00
|
|
|
* @brief USART1 driver enable switch.
|
|
|
|
* @details If set to @p TRUE the support for USART1 is included.
|
2015-03-09 10:48:08 +00:00
|
|
|
* @note The default is @p FALSE.
|
2014-11-01 17:02:44 +00:00
|
|
|
*/
|
2014-11-02 10:41:41 +00:00
|
|
|
#if !defined(PLATFORM_SERIAL_USE_USART1) || defined(__DOXYGEN__)
|
|
|
|
#define PLATFORM_SERIAL_USE_USART1 FALSE
|
2014-11-01 17:02:44 +00:00
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Derived constants and error checks. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver data structures and types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
2014-11-02 10:41:41 +00:00
|
|
|
* @brief PLATFORM Serial Driver configuration structure.
|
2014-11-01 17:02:44 +00:00
|
|
|
* @details An instance of this structure must be passed to @p sdStart()
|
|
|
|
* in order to configure and start a serial driver operations.
|
2014-11-02 10:41:41 +00:00
|
|
|
* @note This structure content is architecture dependent, each driver
|
|
|
|
* implementation defines its own version and the custom static
|
|
|
|
* initializers.
|
2014-11-01 17:02:44 +00:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
/**
|
|
|
|
* @brief Bit rate.
|
|
|
|
*/
|
2014-11-02 10:41:41 +00:00
|
|
|
uint32_t speed;
|
2014-11-01 17:02:44 +00:00
|
|
|
/* End of the mandatory fields.*/
|
|
|
|
} SerialConfig;
|
|
|
|
|
|
|
|
/**
|
2014-11-02 10:41:41 +00:00
|
|
|
* @brief @p SerialDriver specific data.
|
2014-11-01 17:02:44 +00:00
|
|
|
*/
|
|
|
|
#define _serial_driver_data \
|
|
|
|
_base_asynchronous_channel_data \
|
|
|
|
/* Driver state.*/ \
|
|
|
|
sdstate_t state; \
|
|
|
|
/* Input queue.*/ \
|
2014-11-02 10:41:41 +00:00
|
|
|
input_queue_t iqueue; \
|
2014-11-01 17:02:44 +00:00
|
|
|
/* Output queue.*/ \
|
2014-11-02 10:41:41 +00:00
|
|
|
output_queue_t oqueue; \
|
2014-11-01 17:02:44 +00:00
|
|
|
/* Input circular buffer.*/ \
|
|
|
|
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
|
|
|
|
/* Output circular buffer.*/ \
|
|
|
|
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
|
|
|
/* End of the mandatory fields.*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver macros. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2015-03-09 10:48:08 +00:00
|
|
|
#if (PLATFORM_SERIAL_USE_USART1 == TRUE) && !defined(__DOXYGEN__)
|
2014-11-01 17:02:44 +00:00
|
|
|
extern SerialDriver SD1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void sd_lld_init(void);
|
|
|
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
|
|
|
|
void sd_lld_stop(SerialDriver *sdp);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-09 10:48:08 +00:00
|
|
|
#endif /* HAL_USE_SERIAL == TRUE */
|
2014-11-01 17:02:44 +00:00
|
|
|
|
2016-04-02 07:59:24 +00:00
|
|
|
#endif /* HAL_SERIAL_LLD_H */
|
2014-11-01 17:02:44 +00:00
|
|
|
|
|
|
|
/** @} */
|