Driver_ETH_MAC.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /**
  2. \defgroup eth_mac_interface_gr Ethernet MAC Interface
  3. \ingroup eth_interface_gr
  4. \brief Driver API for Ethernet MAC Peripheral (%Driver_ETH_MAC.h)
  5. \details
  6. The following section describes the Ethernet MAC Interface as defined in the %Driver_ETH_MAC.h header file.
  7. @{
  8. */
  9. /**
  10. \struct ARM_ETH_MAC_CAPABILITIES
  11. \details
  12. An Ethernet MAC driver can be implemented with different capabilities.
  13. The data fields of this struct encode the capabilities implemented by this driver.
  14. <b>Returned by:</b>
  15. - \ref ARM_ETH_MAC_GetCapabilities
  16. */
  17. /**
  18. \struct ARM_DRIVER_ETH_MAC
  19. \details
  20. The functions of the Ethernet MAC are accessed by function pointers. Refer to \ref DriverFunctions for
  21. overview information.
  22. Each instance of an Ethernet MAC provides such an access struct. The instance is indicated by
  23. a postfix in the symbol name of the access struct, for example:
  24. - \b Driver_ETH_MAC0 is the name of the access struct of the first instance (no. 0).
  25. - \b Driver_ETH_MAC1 is the name of the access struct of the second instance (no. 1).
  26. A configuration setting in the middleware allows connecting the middleware to a specific driver instance <b>Driver_ETH_MAC<i>n</i></b>.
  27. The default is \token{0}, which connects a middleware to the first instance of a driver.
  28. */
  29. /**
  30. \struct ARM_ETH_MAC_TIME
  31. \details
  32. The two members of this struct provide fields to encode time values in the order \token{Nano seconds} and \token{seconds}.
  33. The member \em ns is also used as a correction factor for \ref ARM_ETH_MAC_TIMER_ADJUST_CLOCK.
  34. <b>Used in:</b>
  35. - \ref ARM_ETH_MAC_GetRxFrameTime
  36. - \ref ARM_ETH_MAC_GetTxFrameTime
  37. - \ref ARM_ETH_MAC_ControlTimer
  38. *******************************************************************************************************************/
  39. /**
  40. \typedef ARM_ETH_MAC_SignalEvent_t
  41. \details
  42. Provides the typedef for the callback function \ref ARM_ETH_MAC_SignalEvent.
  43. <b>Parameter for:</b>
  44. - \ref ARM_ETH_MAC_Initialize
  45. *******************************************************************************************************************/
  46. /**
  47. \defgroup ETH_MAC_events Ethernet MAC Events
  48. \ingroup eth_mac_interface_gr
  49. \brief The Ethernet MAC driver generates call back events that are notified via the function \ref ARM_ETH_MAC_SignalEvent.
  50. \details
  51. This section provides the event values for the \ref ARM_ETH_MAC_SignalEvent callback function.
  52. The following call back notification events are generated:
  53. @{
  54. \def ARM_ETH_MAC_EVENT_RX_FRAME
  55. \def ARM_ETH_MAC_EVENT_TX_FRAME
  56. \def ARM_ETH_MAC_EVENT_WAKEUP
  57. \def ARM_ETH_MAC_EVENT_TIMER_ALARM
  58. @}
  59. */
  60. //
  61. // Function documentation
  62. //
  63. ARM_DRIVER_VERSION ARM_ETH_MAC_GetVersion (void) {
  64. ;
  65. }
  66. /**
  67. \fn ARM_DRIVER_VERSION ARM_ETH_MAC_GetVersion (void);
  68. \details
  69. The function \b ARM_ETH_MAC_GetVersion returns version information of the driver implementation in \ref ARM_DRIVER_VERSION
  70. - API version is the version of the CMSIS-Driver specification used to implement this driver.
  71. - Driver version is source code version of the actual driver implementation.
  72. Example:
  73. \code
  74. extern ARM_DRIVER_ETH_MAC Driver_ETH_MAC0;
  75. ARM_DRIVER_ETH_MAC *mac;
  76. void setup_ethernet (void) {
  77. ARM_DRIVER_VERSION version;
  78. mac = &Driver_ETH_MAC0;
  79. version = mac->GetVersion ();
  80. if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
  81. // error handling
  82. return;
  83. }
  84. }
  85. \endcode
  86. *******************************************************************************************************************/
  87. ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities (void) {
  88. ;
  89. }
  90. /**
  91. \fn ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities (void)
  92. \details
  93. The function \b ARM_ETH_MAC_GetCapabilities retrieves information about capabilities in this driver implementation.
  94. The data fields of the struct \ref ARM_ETH_MAC_CAPABILITIES encode various capabilities, for example
  95. if a hardware is capable to create checksums in hardware or signal events using the \ref ARM_ETH_MAC_SignalEvent
  96. callback function.
  97. Example:
  98. \code
  99. extern ARM_DRIVER_ETH_MAC Driver_ETH_MAC0;
  100. ARM_DRIVER_ETH_MAC *mac;
  101. void read_capabilities (void) {
  102. ARM_ETH_MAC_CAPABILITIES mac_capabilities;
  103. mac = &Driver_ETH_MAC0;
  104. mac_capabilities = mac->GetCapabilities ();
  105. // interrogate capabilities
  106. }
  107. \endcode
  108. *******************************************************************************************************************/
  109. int32_t ARM_ETH_MAC_Initialize (ARM_ETH_MAC_SignalEvent_t cb_event) {
  110. }
  111. /**
  112. \fn int32_t ARM_ETH_MAC_Initialize (ARM_ETH_MAC_SignalEvent_t cb_event)
  113. \details
  114. The function \b ARM_ETH_MAC_Initialize initializes the Ethernet MAC interface.
  115. It is called when the middleware component starts operation.
  116. The \ref ARM_ETH_MAC_Initialize function performs the following operations:
  117. - Initializes the resources needed for the Ethernet MAC peripheral.
  118. - Registers the \ref ARM_ETH_MAC_SignalEvent callback function.
  119. The parameter \em cb_event is a pointer to the \ref ARM_ETH_MAC_SignalEvent callback function; use a NULL pointer
  120. when no callback signals are required.
  121. \b Example:
  122. - see \ref eth_interface_gr - Driver Functions
  123. *******************************************************************************************************************/
  124. int32_t ARM_ETH_MAC_Uninitialize (void) {
  125. }
  126. /**
  127. \fn int32_t ARM_ETH_MAC_Uninitialize (void)
  128. \details
  129. The function \b ARM_ETH_MAC_Uninitialize de-initializes the resources of Ethernet MAC interface.
  130. It is called when the middleware component stops operation and releases the software resources
  131. used by the interface.
  132. *******************************************************************************************************************/
  133. int32_t ARM_ETH_MAC_PowerControl (ARM_POWER_STATE state) {
  134. }
  135. /**
  136. \fn int32_t ARM_ETH_MAC_PowerControl (ARM_POWER_STATE state)
  137. \details
  138. The function \b ARM_ETH_MAC_PowerControl allows you to configure the power modes of the Ethernet MAC interface.
  139. The parameter \em state can be:
  140. - ARM_POWER_OFF: Ethernet MAC peripheral is turned off.
  141. - ARM_POWER_FULL: Ethernet MAC peripheral is turned on and fully operational.
  142. If power \em state specifies an unsupported mode, the function returns \ref ARM_DRIVER_ERROR_UNSUPPORTED as status information
  143. and the previous power state of the peripheral is unchanged. Multiple calls with the same \em state generate no
  144. error.
  145. \b Example:
  146. - see \ref eth_interface_gr - Driver Functions
  147. *******************************************************************************************************************/
  148. int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) {
  149. }
  150. /**
  151. \fn int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr)
  152. \details
  153. The function \b ARM_ETH_MAC_GetMacAddress retrieves the Ethernet MAC own address from the driver.
  154. *******************************************************************************************************************/
  155. int32_t ARM_ETH_MAC_SetMacAddress (const ARM_ETH_MAC_ADDR *ptr_addr) {
  156. }
  157. /**
  158. \fn int32_t ARM_ETH_MAC_SetMacAddress (const ARM_ETH_MAC_ADDR *ptr_addr)
  159. \details
  160. The function \b ARM_ETH_MAC_SetMacAddress configures Ethernet MAC own address.
  161. The Ethernet MAC accepts packets <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frames</b></a> which contains
  162. a MAC destination address that matches the address specified with \em ptr_addr.
  163. The Ethernet MAC receiver will accept also packets with addresses configured by \ref ARM_ETH_MAC_SetAddressFilter function.
  164. MAC receiver can be configured to accept also packets with broadcast address, any multicast address or even all packets regardless of address (Promiscuity Mode).
  165. This is configured by function \ref ARM_ETH_MAC_Control with \ref ARM_ETH_MAC_CONFIGURE as control parameter.
  166. *******************************************************************************************************************/
  167. int32_t ARM_ETH_MAC_SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr) {
  168. }
  169. /**
  170. \fn int32_t ARM_ETH_MAC_SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr)
  171. \details
  172. The function \b ARM_ETH_MAC_SetAddressFilter configures Ethernet MAC receiver address filtering.
  173. The Ethernet MAC accepts packets <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frames</b></a> which contains
  174. a MAC destination address of the list supplied with \em ptr_addr. The parameter \em ptr_addr provides and array of Ethernet MAC addresses. The number of addresses
  175. is supplied by \em num_addr. Specifying \em num_adr = 0 disables address filtering previously set with this function.
  176. The Ethernet MAC receiver will accept packets addressed to its own address and packets with addresses configured by this function.
  177. MAC receiver can be configured to accept also packets with broadcast address, any multicast address or even all packets regardless of address (Promiscuity Mode).
  178. This is configured by function \ref ARM_ETH_MAC_Control with \ref ARM_ETH_MAC_CONFIGURE as control parameter.
  179. *******************************************************************************************************************/
  180. int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags) {
  181. }
  182. /**
  183. \fn int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags)
  184. \details
  185. The function \b ARM_ETH_MAC_SendFrame writes an <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frame</b></a> to the Ethernet MAC transmit buffer.
  186. The Ethernet MAC transmit engine must be enabled by using the function \ref ARM_ETH_MAC_Control (ARM_ETH_MAC_CONTROL_TX, 1) before a call to this function.
  187. The frame data addressed by \em buf starts with MAC destination and ends with the last Payload data byte. The frame data is copied into
  188. the transmit buffer of the Ethernet MAC interface. The function does not wait until the transmission over the Ethernet is complete,
  189. however the memory addressed by \em buf is available for the next Ethernet frame after return.
  190. The maximum value for \em len is implied by the size restrictions of the Ethernet frame but is not verified.
  191. Using an invalid value for \em len may generate unpredicted results.
  192. The parameter \em flags specifies additional attributes for the function as shown in the following table. Multiple flags can be combined, for example:
  193. ARM_ETH_MAC_TX_FRAME_EVENT | ARM_ETH_MAC_TX_FRAME_TIMESTAMP.
  194. Flag bit | Description
  195. :--------------------------------------|:-----------------------------------------
  196. \ref ARM_ETH_MAC_TX_FRAME_FRAGMENT | Indicates that it is a fragment of the frame. allows you to collect multiple fragments before the frame is sent.
  197. \ref ARM_ETH_MAC_TX_FRAME_EVENT | \ref ARM_ETH_MAC_SignalEvent with \em event bit \ref ARM_ETH_MAC_EVENT_TX_FRAME set will be called when frame send is complete.
  198. \ref ARM_ETH_MAC_TX_FRAME_TIMESTAMP | Capture the time stamp of the frame. The time stamp can be obtained using the function \ref ARM_ETH_MAC_GetTxFrameTime.
  199. \b Example:
  200. \code
  201. status = mac->SendFrame (&frame->data[0], frame->length, 0);
  202. if (status != ARM_DRIVER_OK) {
  203. // error handling
  204. }
  205. \endcode
  206. *******************************************************************************************************************/
  207. int32_t ARM_ETH_MAC_ReadFrame (uint8_t *frame, uint32_t len) {
  208. }
  209. /**
  210. \fn int32_t ARM_ETH_MAC_ReadFrame (uint8_t *frame, uint32_t len)
  211. \details
  212. The function \b ARM_ETH_MAC_ReadFrame reads an <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frame</b></a> from the Ethernet MAC receive buffer.
  213. The Ethernet MAC receive engine must be enabled using the function \ref ARM_ETH_MAC_Control (ARM_ETH_MAC_CONTROL_RX , 1) before a call to this function.
  214. The \em len of the Ethernet frame can be checked using the function \ref ARM_ETH_MAC_GetRxFrameSize.
  215. The frame data addressed by \em buf starts with MAC destination and ends with the last Payload data byte. The frame data is read from
  216. the receive buffer of the Ethernet MAC interface and the number of bytes written into the memory addressed by \em buf is returned.
  217. A negative return value indicates an error whereby the status code is defined with driver common return codes.
  218. The function \ref ARM_ETH_MAC_ReadFrame may be called with \em buf = NULL and \em len = 0 to discard or release an frame. This is useful when an incorrect frame has been received or
  219. no memory is available to hold the Ethernet frame.
  220. \b Example:
  221. \code
  222. size = mac->GetRxFrameSize ();
  223. if ((size < 14) || (size > 1514)) { // frame excludes CRC
  224. mac->ReadFrame (NULL, 0); // Frame error, release it
  225. }
  226. len = mac->ReadFrame (&frame->data[0], size);
  227. if (len < 0) {
  228. // error handling
  229. }
  230. \endcode
  231. *******************************************************************************************************************/
  232. uint32_t ARM_ETH_MAC_GetRxFrameSize (void) {
  233. }
  234. /**
  235. \fn uint32_t ARM_ETH_MAC_GetRxFrameSize (void)
  236. \details
  237. The function \b ARM_ETH_MAC_GetRxFrameSize returns the size of a received
  238. <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frame</b></a>.
  239. This function is called before \ref ARM_ETH_MAC_ReadFrame and supplies the value \em len.
  240. The frame size includes MAC destination and ends with the last Payload data byte.
  241. Value \em 0 indicates that no Ethernet frame is available in the receive buffer.
  242. Values smaller than minimum size of Ethernet frame or larger than maximum size of Ethernet frame
  243. indicate an invalid frame which needs to be discarded by calling \ref ARM_ETH_MAC_ReadFrame.
  244. \b Example:
  245. - see \ref ARM_ETH_MAC_ReadFrame
  246. *******************************************************************************************************************/
  247. int32_t ARM_ETH_MAC_GetRxFrameTime (ARM_ETH_MAC_TIME *time) {
  248. }
  249. /**
  250. \fn int32_t ARM_ETH_MAC_GetRxFrameTime (ARM_ETH_MAC_TIME *time)
  251. \details
  252. Retrieve time stamp of a received <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frame</b></a>.
  253. This function must be called before the frame is read using \ref ARM_ETH_MAC_ReadFrame.
  254. *******************************************************************************************************************/
  255. int32_t ARM_ETH_MAC_GetTxFrameTime (ARM_ETH_MAC_TIME *time) {
  256. }
  257. /**
  258. \fn int32_t ARM_ETH_MAC_GetTxFrameTime (ARM_ETH_MAC_TIME *time)
  259. \details
  260. The function \b returns the time stamp of a transmitted <a href="http://en.wikipedia.org/wiki/Ethernet_frame" target="_blank"><b>Ethernet frame</b></a>.
  261. *******************************************************************************************************************/
  262. int32_t ARM_ETH_MAC_Control (uint32_t control, uint32_t arg) {
  263. }
  264. /**
  265. \fn int32_t ARM_ETH_MAC_Control (uint32_t control, uint32_t arg)
  266. \details
  267. The function \b ARM_ETH_MAC_Control controls the Ethernet MAC interface and executes various operations.
  268. After initialization, the Ethernet transceiver and receiver are disabled.
  269. The parameter \em control specifies an operation as defined in the table <b>Parameter \em control</b>. \n
  270. The parameter \em arg provides, depending on the operation, additional information or values.
  271. The table lists values for the parameter \em control.
  272. Parameter \em control | Operation
  273. :----------------------------------------------------|:--------------------------------------------
  274. \ref ARM_ETH_MAC_CONFIGURE | Configure the Ethernet MAC interface; For \em arg values, see table <b>Parameter \em arg for CONFIGURE</b>
  275. \ref ARM_ETH_MAC_CONTROL_TX | Enable or disable the transmitter; \em arg : \token{0=disable; 1=enable}
  276. \ref ARM_ETH_MAC_CONTROL_RX | Enable or disable the receiver; \em arg : \token{0=disable; 1=enable}
  277. \ref ARM_ETH_MAC_FLUSH | Flush a buffer; \em arg : see table <b>Parameter \em arg for FLUSH</b>
  278. \ref ARM_ETH_MAC_SLEEP | Exit/Enter Sleep mode; \em arg : \token{0=exit; 1=enter and wait for Magic packet}
  279. \ref ARM_ETH_MAC_VLAN_FILTER | Configure VLAN Filter for received frames; \em arg : See table <b>Parameter \em arg for VLAN Filter</b>
  280. The table <b>Parameter \em arg for CONFIGURE</b> lists the \em arg values for the \em control \b ARM_ETH_MAC_CONFIGURE.
  281. The values can be ORed in the following way:
  282. \code
  283. mac->Control(ARM_ETH_MAC_CONFIGURE, ARM_ETH_MAC_SPEED_100M | ARM_ETH_MAC_DUPLEX_FULL | ARM_ETH_MAC_LOOPBACK);
  284. \endcode
  285. <table class="cmtable" summary="">
  286. <tr><th colspan="4">Parameter \em arg CONFIGURE </th></tr>
  287. <tr><th>Parameter \em arg </th><th> Bit </th><th> Category </th><th>Description </th></tr>
  288. <tr><td>\ref ARM_ETH_MAC_SPEED_10M </td><td rowspan="3"> 0..1 </td><td rowspan="3">Link Speed </td><td>Set the link speed to \token{10 [Mbps]} </td></tr>
  289. <tr><td>\ref ARM_ETH_MAC_SPEED_100M </td> <td>Set the link speed to \token{100 [Mbps]}</td></tr>
  290. <tr><td>\ref ARM_ETH_MAC_SPEED_1G </td> <td>Set the link speed to \token{1 [Gbps]} </td></tr>
  291. <tr><td>\ref ARM_ETH_MAC_DUPLEX_HALF </td><td rowspan="2"> 2 </td><td rowspan="2">Link Mode </td><td>Set the link mode to half duplex </td></tr>
  292. <tr><td>\ref ARM_ETH_MAC_DUPLEX_FULL </td> <td>Set the link mode to full duplex </td></tr>
  293. <tr><td>n.a. </td><td> 3 </td><td> n.a. </td><td>\em reserved </td></tr>
  294. <tr><td>\ref ARM_ETH_MAC_LOOPBACK </td><td> 4 </td><td> Loopback Test Mode </td><td>Set the interface into a Loop-back test mode</td></tr>
  295. <tr><td>\ref ARM_ETH_MAC_CHECKSUM_OFFLOAD_RX</td><td> 5 </td><td>Receiver Checksum offload</td><td>Enable Receiver Checksum offload </td></tr>
  296. <tr><td>\ref ARM_ETH_MAC_CHECKSUM_OFFLOAD_TX</td><td> 6 </td><td>Transmitter Checksum offload</td><td>Enable Transmitter Checksum offload </td></tr>
  297. <tr><td>\ref ARM_ETH_MAC_ADDRESS_BROADCAST </td><td> 7 </td><td>Broadcast Frame address </td><td>Accept frames with Broadcast address </td></tr>
  298. <tr><td>\ref ARM_ETH_MAC_ADDRESS_MULTICAST </td><td> 8 </td><td>Multicast Frame address </td><td>Accept frames with any Multicast address</td></tr>
  299. <tr><td>\ref ARM_ETH_MAC_ADDRESS_ALL </td><td> 9 </td><td>Any Frame address </td><td>Accept frames with any address (Promiscuous Mode)</td></tr>
  300. </table>
  301. The table <b>Parameter \em arg for FLUSH</b> lists the \em arg values for the \em control \b ARM_ETH_MAC_FLUSH.
  302. The \em arg values can be ORed.
  303. <table class="cmtable" summary="">
  304. <tr><th colspan="4">Parameter \em arg for FLUSH </th></tr>
  305. <tr><th>Parameter \em arg </th><th> Bit </th><th> Category </th><th> Description </th></tr>
  306. <tr><td>\ref ARM_ETH_MAC_FLUSH_RX </td><td> 1 </td><td> Receive buffer </td><td> Flush the Receive buffer </td></tr>
  307. <tr><td>\ref ARM_ETH_MAC_FLUSH_TX </td><td> 2 </td><td> Transmit buffer </td><td> Flush the Transmit buffer </td></tr>
  308. </table>
  309. The table <b>Parameter \em arg for VLAN Filter</b> lists the \em arg values for the \em control \b ARM_ETH_MAC_VLAN_FILTER.
  310. The \em arg values can be ORed.
  311. <table class="cmtable" summary="">
  312. <tr><th colspan="4">Parameter \em arg for VLAN Filter</th></tr>
  313. <tr><th>Parameter \em arg </th><th> Bit </th><th> Category </th><th> Description </th></tr>
  314. <tr><td>\em value </td><td> 0..15 </td><td> VLAN Tag </td><td> Set VLAN Tag value </td></tr>
  315. <tr><td>\token{0} </td><td rowspan="2"> 16 </td><td rowspan="2"> Use of VLAN </td><td> Compare the complete 16-bit VLAN Tag value </td></tr>
  316. <tr><td>\ref ARM_ETH_MAC_VLAN_FILTER_ID_ONLY </td> <td>Compare only the 12-bit VLAN Identifier </td></tr>
  317. <tr><td>\token{0} </td><td> 0..16 </td><td> Disable </td><td> Disable the VLAN Filter </td></tr>
  318. </table>
  319. \b Example:
  320. \code
  321. ...
  322. // start transfer
  323. mac->Control(ARM_ETH_MAC_CONFIGURE, ARM_ETH_MAC_SPEED_100M | ARM_ETH_MAC_DUPLEX_FULL | ARM_ETH_MAC_ADDRESS_BROADCAST);
  324. mac->Control(ARM_ETH_MAC_CONTROL_TX, 1);
  325. mac->Control(ARM_ETH_MAC_CONTROL_RX, 1);
  326. ... // stop transfer
  327. mac->Control(ARM_ETH_MAC_FLUSH, ARM_ETH_MAC_FLUSH_TX | ARM_ETH_MAC_FLUSH_RX);
  328. mac->Control(ARM_ETH_MAC_CONTROL_TX, 0);
  329. mac->Control(ARM_ETH_MAC_CONTROL_RX, 0);
  330. }
  331. }
  332. \endcode
  333. For a complete example, refer to \ref eth_interface_gr - Driver Functions.
  334. *******************************************************************************************************************/
  335. int32_t ARM_ETH_MAC_ControlTimer (uint32_t control, ARM_ETH_MAC_TIME *time) {
  336. }
  337. /**
  338. \fn int32_t ARM_ETH_MAC_ControlTimer (uint32_t control, ARM_ETH_MAC_TIME *time)
  339. \details
  340. The function \b ARM_ETH_MAC_ControlTimer controls the timer required for PTP (Precision Time Protocol).
  341. The parameter \em control receives \b ARM_ETH_MAC_TIMER_xxx codes to manage the timer for a PTP enabled Ethernet MAC interface. \n
  342. The parameter \em time is pointer to a structure that holds time information.
  343. Mode Parameters: Timer Controls | Description
  344. :---------------------------------------|:--------------------------------------------
  345. \ref ARM_ETH_MAC_TIMER_GET_TIME | Retrieve the current time and update the content \ref ARM_ETH_MAC_TIME *time.
  346. \ref ARM_ETH_MAC_TIMER_SET_TIME | Set the new time using the values provided with \ref ARM_ETH_MAC_TIME *time.
  347. \ref ARM_ETH_MAC_TIMER_INC_TIME | Increment the current time by using the values provided with \ref ARM_ETH_MAC_TIME *time.
  348. \ref ARM_ETH_MAC_TIMER_DEC_TIME | Decrement the current time by using the values provided with \ref ARM_ETH_MAC_TIME *time.
  349. \ref ARM_ETH_MAC_TIMER_SET_ALARM | Set the alarm time to the values provided with \ref ARM_ETH_MAC_TIME *time.
  350. \ref ARM_ETH_MAC_TIMER_ADJUST_CLOCK | Set the clock frequency; the value in time->ns is the <b>correction factor</b> in fractional format q31.
  351. *******************************************************************************************************************/
  352. int32_t ARM_ETH_MAC_PHY_Read (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data) {
  353. }
  354. /**
  355. \fn int32_t ARM_ETH_MAC_PHY_Read (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
  356. \details
  357. Read Ethernet PHY Register through the Management Interface. The function is passed to \ref ARM_ETH_PHY_Initialize.
  358. The Ethernet PHY driver uses this function to read the value of PHY registers.
  359. \b Example:
  360. - see \ref eth_interface_gr - Driver Functions
  361. *******************************************************************************************************************/
  362. int32_t ARM_ETH_MAC_PHY_Write (uint8_t phy_addr, uint8_t reg_addr, uint16_t data) {
  363. }
  364. /**
  365. \fn int32_t ARM_ETH_MAC_PHY_Write (uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
  366. \details
  367. The function \b ARM_ETH_MAC_PHY_Write writes to a Ethernet PHY register through the Management Interface. The function is passed to \ref ARM_ETH_PHY_Initialize.
  368. The Ethernet PHY driver uses this function to write data to PHY registers.
  369. \b Example:
  370. - see \ref eth_interface_gr - Driver Functions
  371. *******************************************************************************************************************/
  372. void ARM_ETH_MAC_SignalEvent (uint32_t event) {
  373. ;
  374. }
  375. /**
  376. \fn void ARM_ETH_MAC_SignalEvent (uint32_t event)
  377. \details
  378. The function \b ARM_ETH_MAC_SignalEvent is a callback function registered by the function
  379. \ref ARM_ETH_MAC_Initialize. This function is typically called from interrupt service routines (ISR) to indicate that
  380. a frame is processed or a special event occurred.
  381. The parameter \a event indicates one or more events that occurred during driver operation.
  382. Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call.
  383. Not every event is necessarily generated by the driver. This depends on the implemented capabilities stored in the
  384. data fields of the structure \ref ARM_ETH_MAC_CAPABILITIES, which can be retrieved with the function \ref ARM_ETH_MAC_GetCapabilities.
  385. The following events can be generated:
  386. Parameter \em event | Bit | Description
  387. :----------------------------------------|:---:|:----------------------------------------
  388. \ref ARM_ETH_MAC_EVENT_RX_FRAME | 0 | Occurs after a frame is received. Frame can be read by calling \ref ARM_ETH_MAC_ReadFrame.
  389. \ref ARM_ETH_MAC_EVENT_TX_FRAME | 1 | Occurs after call to \ref ARM_ETH_MAC_SendFrame to indicate that the frame is transmitted.
  390. \ref ARM_ETH_MAC_EVENT_WAKEUP | 2 | Indicates that a Magic Packet is received while the driver is in Sleep mode (set by \ref ARM_ETH_MAC_SLEEP using \ref ARM_ETH_MAC_Control).
  391. \ref ARM_ETH_MAC_EVENT_TIMER_ALARM | 3 | Indicates that a Timer Alarm occurred that was set with \ref ARM_ETH_MAC_TIMER_SET_ALARM using ARM_ETH_MAC_ControlTimer.
  392. *******************************************************************************************************************/
  393. /**
  394. \defgroup eth_mac_control Ethernet MAC Control Codes
  395. \ingroup eth_mac_interface_gr
  396. \brief Configure and control the Ethernet MAC using the \ref ARM_ETH_MAC_Control.
  397. \details
  398. @{
  399. Many parameters of the Ethernet MAC driver are configured using the \ref ARM_ETH_MAC_Control function.
  400. The various Ethernet MAC control codes define:
  401. - \ref eth_mac_ctrls configures and controls the Ethernet MAC interface
  402. - \ref eth_mac_configuration_ctrls specifies speed mode, link mode, checksum, and frame filtering modes
  403. - \ref eth_mac_flush_flag_ctrls specify controls to flush a buffer
  404. - \ref eth_mac_vlan_filter_ctrls specifies whether to compare only the VLAN Identifier
  405. Refer to the \ref ARM_ETH_MAC_Control function for further details.
  406. */
  407. /**
  408. \defgroup eth_mac_ctrls Ethernet MAC Controls
  409. \brief Configure and control the Ethernet MAC interface.
  410. \details
  411. @{
  412. \def ARM_ETH_MAC_CONFIGURE
  413. \sa ARM_ETH_MAC_Control
  414. \def ARM_ETH_MAC_CONTROL_TX
  415. \sa ARM_ETH_MAC_Control
  416. \def ARM_ETH_MAC_CONTROL_RX
  417. \sa ARM_ETH_MAC_Control
  418. \def ARM_ETH_MAC_FLUSH
  419. \sa ARM_ETH_MAC_Control
  420. \def ARM_ETH_MAC_SLEEP
  421. \sa ARM_ETH_MAC_Control
  422. \def ARM_ETH_MAC_VLAN_FILTER
  423. \sa ARM_ETH_MAC_Control
  424. @}
  425. */
  426. /**
  427. \defgroup eth_mac_configuration_ctrls Ethernet MAC Configuration
  428. \brief Specifies speed mode, link mode, checksum, and frame filtering modes.
  429. \details
  430. @{
  431. The function \ref ARM_ETH_MAC_Control with \em control = \ref ARM_ETH_MAC_CONFIGURE configures the Ethernet MAC interface
  432. as specified with \em arg listed bellow.
  433. \def ARM_ETH_MAC_SPEED_10M
  434. \def ARM_ETH_MAC_SPEED_100M
  435. \def ARM_ETH_MAC_SPEED_1G
  436. \def ARM_ETH_MAC_DUPLEX_HALF
  437. \def ARM_ETH_MAC_DUPLEX_FULL
  438. \def ARM_ETH_MAC_LOOPBACK
  439. \def ARM_ETH_MAC_CHECKSUM_OFFLOAD_RX
  440. \def ARM_ETH_MAC_CHECKSUM_OFFLOAD_TX
  441. \def ARM_ETH_MAC_ADDRESS_BROADCAST
  442. \def ARM_ETH_MAC_ADDRESS_MULTICAST
  443. \def ARM_ETH_MAC_ADDRESS_ALL
  444. @}
  445. */
  446. /**
  447. \defgroup eth_mac_flush_flag_ctrls Ethernet MAC Flush Flags
  448. \brief Specify controls to flush a buffer
  449. \details
  450. @{
  451. The function \ref ARM_ETH_MAC_Control with \em control = \ref ARM_ETH_MAC_FLUSH flushes the buffer
  452. which is specified with \em arg listed bellow.
  453. \def ARM_ETH_MAC_FLUSH_RX
  454. \def ARM_ETH_MAC_FLUSH_TX
  455. @}
  456. */
  457. /**
  458. \defgroup eth_mac_vlan_filter_ctrls Ethernet MAC VLAN Filter Flag
  459. \brief Specify whether to compare only the VLAN Identifier
  460. \details
  461. @{
  462. The function \ref ARM_ETH_MAC_Control with \em control = \ref ARM_ETH_MAC_VLAN_FILTER configures the VLAN Filter for received frames as specified with \em arg.
  463. By default the complete VLAN Tag (16-bit) is compared. When \ref ARM_ETH_MAC_VLAN_FILTER_ID_ONLY is specified then only the VLAN Identifier (12-bit) is compared.
  464. Specifying \em arg=0 disables the VLAN Filter.
  465. \def ARM_ETH_MAC_VLAN_FILTER_ID_ONLY
  466. @}
  467. */
  468. /**
  469. @} */ // end group eth_mac_control
  470. /**
  471. \defgroup eth_mac_time_control Ethernet MAC Timer Control Codes
  472. \ingroup eth_mac_interface_gr
  473. \brief Control codes for \ref ARM_ETH_MAC_ControlTimer function.
  474. \details
  475. The following timer controls are used as parameter \em control for the \ref ARM_ETH_MAC_ControlTimer function:
  476. @{
  477. \def ARM_ETH_MAC_TIMER_GET_TIME
  478. \sa ARM_ETH_MAC_ControlTimer
  479. \def ARM_ETH_MAC_TIMER_SET_TIME
  480. \sa ARM_ETH_MAC_ControlTimer
  481. \def ARM_ETH_MAC_TIMER_INC_TIME
  482. \sa ARM_ETH_MAC_ControlTimer
  483. \def ARM_ETH_MAC_TIMER_DEC_TIME
  484. \sa ARM_ETH_MAC_ControlTimer
  485. \def ARM_ETH_MAC_TIMER_SET_ALARM
  486. \sa ARM_ETH_MAC_ControlTimer
  487. \def ARM_ETH_MAC_TIMER_ADJUST_CLOCK
  488. \sa ARM_ETH_MAC_ControlTimer
  489. @}
  490. */
  491. /**
  492. \defgroup eth_mac_frame_transmit_ctrls Ethernet MAC Frame Transmit Flags
  493. \brief Specify frame transmit flags
  494. \details
  495. @{
  496. \def ARM_ETH_MAC_TX_FRAME_FRAGMENT
  497. \sa ARM_ETH_MAC_SendFrame
  498. \def ARM_ETH_MAC_TX_FRAME_EVENT
  499. \sa ARM_ETH_MAC_SendFrame
  500. \def ARM_ETH_MAC_TX_FRAME_TIMESTAMP
  501. \sa ARM_ETH_MAC_SendFrame
  502. @}
  503. */
  504. /**
  505. @}
  506. */
  507. // End ETH MAC Interface