|
ChibiOS/RT
2.6.0 |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio 00003 00004 Licensed under the Apache License, Version 2.0 (the "License"); 00005 you may not use this file except in compliance with the License. 00006 You may obtain a copy of the License at 00007 00008 http://www.apache.org/licenses/LICENSE-2.0 00009 00010 Unless required by applicable law or agreed to in writing, software 00011 distributed under the License is distributed on an "AS IS" BASIS, 00012 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 See the License for the specific language governing permissions and 00014 limitations under the License. 00015 */ 00016 00017 /** 00018 * @file templates/serial_lld.c 00019 * @brief Serial Driver subsystem low level driver source template. 00020 * 00021 * @addtogroup SERIAL 00022 * @{ 00023 */ 00024 00025 #include "ch.h" 00026 #include "hal.h" 00027 00028 #if HAL_USE_SERIAL || defined(__DOXYGEN__) 00029 00030 /*===========================================================================*/ 00031 /* Driver local definitions. */ 00032 /*===========================================================================*/ 00033 00034 /*===========================================================================*/ 00035 /* Driver exported variables. */ 00036 /*===========================================================================*/ 00037 00038 /** 00039 * @brief SD1 driver identifier. 00040 */ 00041 #if PLATFORM_SERIAL_USE_SD1 || defined(__DOXYGEN__) 00042 SerialDriver SD1; 00043 #endif 00044 00045 /*===========================================================================*/ 00046 /* Driver local variables and types. */ 00047 /*===========================================================================*/ 00048 00049 /** 00050 * @brief Driver default configuration. 00051 */ 00052 static const SerialConfig default_config = { 00053 38400 00054 }; 00055 00056 /*===========================================================================*/ 00057 /* Driver local functions. */ 00058 /*===========================================================================*/ 00059 00060 /*===========================================================================*/ 00061 /* Driver interrupt handlers. */ 00062 /*===========================================================================*/ 00063 00064 /*===========================================================================*/ 00065 /* Driver exported functions. */ 00066 /*===========================================================================*/ 00067 00068 /** 00069 * @brief Low level serial driver initialization. 00070 * 00071 * @notapi 00072 */ 00073 void sd_lld_init(void) { 00074 00075 #if PLATFORM_SERIAL_USE_SD1 00076 /* Driver initialization.*/ 00077 sdObjectInit(&SD1); 00078 #endif /* PLATFORM_SERIAL_USE_SD1 */ 00079 } 00080 00081 /** 00082 * @brief Low level serial driver configuration and (re)start. 00083 * 00084 * @param[in] sdp pointer to a @p SerialDriver object 00085 * @param[in] config the architecture-dependent serial driver configuration. 00086 * If this parameter is set to @p NULL then a default 00087 * configuration is used. 00088 * 00089 * @notapi 00090 */ 00091 void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) { 00092 00093 if (config == NULL) 00094 config = &default_config; 00095 00096 if (sdp->state == SD_STOP) { 00097 /* Enables the peripheral.*/ 00098 #if PLATFORM_SERIAL_USE_SD1 00099 if (&SD1 == sdp) { 00100 00101 } 00102 #endif /* PLATFORM_SD_USE_SD1 */ 00103 } 00104 /* Configures the peripheral.*/ 00105 00106 } 00107 00108 /** 00109 * @brief Low level serial driver stop. 00110 * @details De-initializes the USART, stops the associated clock, resets the 00111 * interrupt vector. 00112 * 00113 * @param[in] sdp pointer to a @p SerialDriver object 00114 * 00115 * @notapi 00116 */ 00117 void sd_lld_stop(SerialDriver *sdp) { 00118 00119 if (sdp->state == SD_READY) { 00120 /* Resets the peripheral.*/ 00121 00122 /* Disables the peripheral.*/ 00123 #if PLATFORM_SERIAL_USE_SD1 00124 if (&SD1 == sdp) { 00125 00126 } 00127 #endif /* PLATFORM_SERIAL_USE_SD1 */ 00128 } 00129 } 00130 00131 #endif /* HAL_USE_SERIAL */ 00132 00133 /** @} */