![]() |
ChibiOS/RT Architecture - Reference Manual - Guides |
Generic MAC driver. More...
|
Generic MAC driver.
This module implements a generic interface for MAC (Media Access Control) drivers, as example Ethernet controllers.
Modules | |
| MAC Low Level Driver | |
MAC Driver low level driver template. | |
Defines | |
| #define | macGetReceiveEventSource(macp) (&(macp)->md_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. | |
Functions | |
| void | macInit (void) |
| MAC Driver initialization. | |
| void | macObjectInit (MACDriver *macp) |
Initialize the standard part of a MACDriver structure. | |
| void | macSetAddress (MACDriver *macp, const uint8_t *p) |
| MAC address setup. | |
| 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. | |
| #define macGetReceiveEventSource | ( | macp | ) | (&(macp)->md_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. | void macInit | ( | void | ) |
MAC Driver initialization.
Definition at line 63 of file mac.c.
References mac_lld_init().
Referenced by halInit().

| void macObjectInit | ( | MACDriver * | macp | ) |
Initialize the standard part of a MACDriver structure.
| [in] | macp | pointer to the MACDriver object |
Definition at line 73 of file mac.c.
References chEvtInit, chSemInit(), MACDriver::md_rdevent, MACDriver::md_rdsem, and MACDriver::md_tdsem.

MAC address setup.
| [in] | macp | pointer to the MACDriver object |
| [in] | p | pointer to a six bytes buffer containing the MAC address. If this parameter is set to NULL then MAC a system default is used. |
Definition at line 93 of file mac.c.
References mac_lld_set_address().

| msg_t macWaitTransmitDescriptor | ( | MACDriver * | macp, | |
| MACTransmitDescriptor * | tdp, | |||
| systime_t | time | |||
| ) |
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 115 of file mac.c.
References chSemWaitTimeoutS(), chSysLock, chSysUnlock, chTimeNow, max_lld_get_transmit_descriptor(), MACDriver::md_tdsem, 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 139 of file mac.c.
References mac_lld_release_transmit_descriptor().

| msg_t macWaitReceiveDescriptor | ( | MACDriver * | macp, | |
| MACReceiveDescriptor * | rdp, | |||
| systime_t | time | |||
| ) |
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 161 of file mac.c.
References chSemWaitTimeoutS(), chSysLock, chSysUnlock, chTimeNow, max_lld_get_receive_descriptor(), MACDriver::md_rdsem, 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 186 of file mac.c.
References mac_lld_release_receive_descriptor().

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 199 of file mac.c.
References mac_lld_poll_link_status().

1.6.3