ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file templates/mac_lld.h 00029 * @brief MAC Driver subsystem low level driver header template. 00030 * 00031 * @addtogroup MAC_LLD 00032 * @{ 00033 */ 00034 00035 #ifndef _MAC_LLD_H_ 00036 #define _MAC_LLD_H_ 00037 00038 #if CH_HAL_USE_MAC || defined(__DOXYGEN__) 00039 00040 /*===========================================================================*/ 00041 /* Driver constants. */ 00042 /*===========================================================================*/ 00043 00044 /*===========================================================================*/ 00045 /* Driver pre-compile time settings. */ 00046 /*===========================================================================*/ 00047 00048 /** 00049 * @brief Number of available transmit buffers. 00050 */ 00051 #if !defined(MAC_TRANSMIT_BUFFERS) || defined(__DOXYGEN__) 00052 #define MAC_TRANSMIT_BUFFERS 2 00053 #endif 00054 00055 /** 00056 * @brief Number of available receive buffers. 00057 */ 00058 #if !defined(MAC_RECEIVE_BUFFERS) || defined(__DOXYGEN__) 00059 #define MAC_RECEIVE_BUFFERS 2 00060 #endif 00061 00062 /** 00063 * @brief Maximum supported frame size. 00064 */ 00065 #if !defined(MAC_BUFFERS_SIZE) || defined(__DOXYGEN__) 00066 #define MAC_BUFFERS_SIZE 1518 00067 #endif 00068 00069 /*===========================================================================*/ 00070 /* Derived constants and error checks. */ 00071 /*===========================================================================*/ 00072 00073 /*===========================================================================*/ 00074 /* Driver data structures and types. */ 00075 /*===========================================================================*/ 00076 00077 /** 00078 * @brief Structure representing a MAC driver. 00079 */ 00080 typedef struct { 00081 Semaphore md_tdsem; /**< Transmit semaphore. */ 00082 Semaphore md_rdsem; /**< Receive semaphore. */ 00083 #if CH_USE_EVENTS 00084 EventSource md_rdevent; /**< Receive event source. */ 00085 #endif 00086 /* End of the mandatory fields.*/ 00087 } MACDriver; 00088 00089 /** 00090 * @brief Structure representing a transmit descriptor. 00091 */ 00092 typedef struct { 00093 size_t td_offset; /**< Current write offset. */ 00094 size_t td_size; /**< Available space size. */ 00095 /* End of the mandatory fields.*/ 00096 } MACTransmitDescriptor; 00097 00098 /** 00099 * @brief Structure representing a receive descriptor. 00100 */ 00101 typedef struct { 00102 size_t rd_offset; /**< Current read offset. */ 00103 size_t rd_size; /**< Available data size. */ 00104 /* End of the mandatory fields.*/ 00105 } MACReceiveDescriptor; 00106 00107 /*===========================================================================*/ 00108 /* Driver macros. */ 00109 /*===========================================================================*/ 00110 00111 /*===========================================================================*/ 00112 /* External declarations. */ 00113 /*===========================================================================*/ 00114 00115 #ifdef __cplusplus 00116 extern "C" { 00117 #endif 00118 void mac_lld_init(void); 00119 void mac_lld_set_address(MACDriver *macp, const uint8_t *p); 00120 msg_t max_lld_get_transmit_descriptor(MACDriver *macp, 00121 MACTransmitDescriptor *tdp); 00122 size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp, 00123 uint8_t *buf, 00124 size_t size); 00125 void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp); 00126 msg_t max_lld_get_receive_descriptor(MACDriver *macp, 00127 MACReceiveDescriptor *rdp); 00128 size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp, 00129 uint8_t *buf, 00130 size_t size); 00131 void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp); 00132 bool_t mac_lld_poll_link_status(MACDriver *macp); 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif /* CH_HAL_USE_MAC */ 00138 00139 #endif /* _MAC_LLD_H_ */ 00140 00141 /** @} */