|
ChibiOS/RT
2.5.1 |
|
Generic MAC driver.
This module implements a generic MAC (Media Access Control) driver for Ethernet controllers.
HAL_USE_MAC option must be enabled in halconf.h. Functions | |
| void | macInit (void) |
| MAC Driver initialization. | |
| void | macObjectInit (MACDriver *macp) |
Initialize the standard part of a MACDriver structure. | |
| void | macStart (MACDriver *macp, const MACConfig *config) |
| Configures and activates the MAC peripheral. | |
| void | macStop (MACDriver *macp) |
| Deactivates the MAC peripheral. | |
| msg_t | macWaitTransmitDescriptor (MACDriver *macp, MACTransmitDescriptor *tdp, systime_t time) |
| Allocates a transmission descriptor. | |
| void | macReleaseTransmitDescriptor (MACTransmitDescriptor *tdp) |
| Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame. | |
| msg_t | macWaitReceiveDescriptor (MACDriver *macp, MACReceiveDescriptor *rdp, systime_t time) |
| Waits for a received frame. | |
| void | macReleaseReceiveDescriptor (MACReceiveDescriptor *rdp) |
| Releases a receive descriptor. | |
| bool_t | macPollLinkStatus (MACDriver *macp) |
| Updates and returns the link status. | |
MAC configuration options | |
| #define | MAC_USE_EVENTS TRUE |
| Enables an event sources for incoming packets. | |
Macro Functions | |
| #define | macGetReceiveEventSource(macp) (&(macp)->rdevent) |
| Returns the received frames event source. | |
| #define | macWriteTransmitDescriptor(tdp, buf, size) mac_lld_write_transmit_descriptor(tdp, buf, size) |
| Writes to a transmit descriptor's stream. | |
| #define | macReadReceiveDescriptor(rdp, buf, size) mac_lld_read_receive_descriptor(rdp, buf, size) |
| Reads from a receive descriptor's stream. | |
Typedefs | |
| typedef struct MACDriver | MACDriver |
| Type of a structure representing a MAC driver. | |
Enumerations | |
| enum | macstate_t { MAC_UNINIT = 0, MAC_STOP = 1, MAC_ACTIVE = 2 } |
| Driver state machine possible states. More... | |
| void macInit | ( | void | ) |
MAC Driver initialization.
halInit(), there is no need to explicitly initialize the driver.Definition at line 65 of file mac.c.
Referenced by halInit().
| void macObjectInit | ( | MACDriver * | macp | ) |
Initialize the standard part of a MACDriver structure.
| [out] | macp | pointer to the MACDriver object |
Definition at line 77 of file mac.c.
References chEvtInit, chSemInit(), and MAC_STOP.

| void macStart | ( | MACDriver * | macp, |
| const MACConfig * | config | ||
| ) |
Configures and activates the MAC peripheral.
| [in] | macp | pointer to the MACDriver object |
| [in] | config | pointer to the MACConfig object |
Definition at line 96 of file mac.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, MAC_ACTIVE, and MAC_STOP.
| void macStop | ( | MACDriver * | macp | ) |
Deactivates the MAC peripheral.
| [in] | macp | pointer to the MACDriver object |
Definition at line 116 of file mac.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, MAC_ACTIVE, and MAC_STOP.
Allocates a transmission descriptor.
One of the available transmission descriptors is locked and returned. If a descriptor is not currently available then the invoking thread is queued until one is freed.
| [in] | macp | pointer to the MACDriver object |
| [out] | tdp | pointer to a MACTransmitDescriptor structure |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| RDY_OK | the descriptor was obtained. |
| RDY_TIMEOUT | the operation timed out, descriptor not initialized. |
Definition at line 147 of file mac.c.
References chDbgAssert, chDbgCheck, chSemWaitTimeoutS(), chSysLock, chSysUnlock, chTimeNow, MAC_ACTIVE, RDY_OK, RDY_TIMEOUT, and TIME_INFINITE.

| void macReleaseTransmitDescriptor | ( | MACTransmitDescriptor * | tdp | ) |
Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.
| [in] | tdp | the pointer to the MACTransmitDescriptor structure |
Definition at line 180 of file mac.c.
References chDbgCheck.
Waits for a received frame.
Stops until a frame is received and buffered. If a frame is not immediately available then the invoking thread is queued until one is received.
| [in] | macp | pointer to the MACDriver object |
| [out] | rdp | pointer to a MACReceiveDescriptor structure |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| RDY_OK | the descriptor was obtained. |
| RDY_TIMEOUT | the operation timed out, descriptor not initialized. |
Definition at line 206 of file mac.c.
References chDbgAssert, chDbgCheck, chSemWaitTimeoutS(), chSysLock, chSysUnlock, chTimeNow, MAC_ACTIVE, RDY_OK, RDY_TIMEOUT, and TIME_INFINITE.

| void macReleaseReceiveDescriptor | ( | MACReceiveDescriptor * | rdp | ) |
Releases a receive descriptor.
The descriptor and its buffer are made available for more incoming frames.
| [in] | rdp | the pointer to the MACReceiveDescriptor structure |
Definition at line 240 of file mac.c.
References chDbgCheck.
Updates and returns the link status.
| [in] | macp | pointer to the MACDriver object |
| TRUE | if the link is active. |
| FALSE | if the link is down. |
Definition at line 257 of file mac.c.
References chDbgAssert, chDbgCheck, and MAC_ACTIVE.
| #define MAC_USE_EVENTS TRUE |
| #define macGetReceiveEventSource | ( | macp | ) | (&(macp)->rdevent) |
Returns the received frames event source.
| [in] | macp | pointer to the MACDriver object |
EventSource structure.| #define macWriteTransmitDescriptor | ( | tdp, | |
| buf, | |||
| size | |||
| ) | mac_lld_write_transmit_descriptor(tdp, buf, size) |
Writes to a transmit descriptor's stream.
| [in] | tdp | pointer to a MACTransmitDescriptor structure |
| [in] | buf | pointer to the buffer containing the data to be written |
| [in] | size | number of bytes to be written |
size if the maximum frame size is reached.| #define macReadReceiveDescriptor | ( | rdp, | |
| buf, | |||
| size | |||
| ) | mac_lld_read_receive_descriptor(rdp, buf, size) |
Reads from a receive descriptor's stream.
| [in] | rdp | pointer to a MACReceiveDescriptor structure |
| [in] | buf | pointer to the buffer that will receive the read data |
| [in] | size | number of bytes to be read |
size if there are no more bytes to read.| enum macstate_t |