ChibiOS/HAL 9.0.0
MAC Driver

Generic MAC Driver. More...

Detailed Description

Generic MAC Driver.

This module implements a generic MAC (Media Access Control) driver for Ethernet controllers.

Precondition
In order to use the MAC driver the HAL_USE_MAC option must be enabled in halconf.h.
Collaboration diagram for MAC Driver:

MAC event flags

#define MAC_FLAGS_TX   (1U << 0)
#define MAC_FLAGS_RX   (1U << 1)

MAC configuration options

#define MAC_USE_ZERO_COPY   FALSE
 Enables an event sources for incoming packets.
#define MAC_USE_EVENTS   TRUE
 Enables an event sources for incoming packets.

Low level driver helper macros

#define __mac_callback(macp)
 MAC callback.
#define __mac_tx_wakeup(macp)
 MAC TX wakeup and event.
#define __mac_rx_wakeup(macp)
 MAC RX wakeup and event.

Macro Functions

#define macSetCallbackX(macp, f)
 Associates a callback to the MAC instance.
#define macGetEventSource(macp)
 Returns the driver events source.
#define macGetTransmitDescriptorX(macp, tdp)
 Returns a transmission descriptor.
#define macReleaseTransmitDescriptorX(tdp)
 Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.
#define macGetReceiveDescriptorX(macp, rdp)
 Returns a receive descriptor.
#define macReleaseReceiveDescriptorX(rdp)
 Releases a receive descriptor.
#define macWriteTransmitDescriptor(tdp, buf, size)
 Writes to a transmit descriptor's stream.
#define macReadReceiveDescriptor(rdp, buf, size)
 Reads from a receive descriptor's stream.
#define macGetNextTransmitBuffer(tdp, size, sizep)
 Returns a pointer to the next transmit buffer in the descriptor chain.
#define macGetNextReceiveBuffer(rdp, sizep)
 Returns a pointer to the next receive buffer in the descriptor chain.

PLATFORM configuration options

#define PLATFORM_MAC_USE_MAC1   FALSE
 MAC driver enable switch.

Data Structures

struct  hal_mac_config
 Driver configuration structure. More...
struct  hal_mac_driver
 Structure representing a MAC driver. More...
struct  hal_mac_transmit_descriptor
 Structure representing a MAC transmit descriptor. More...
struct  hal_mac_receive_descriptor
 Structure representing a MAC receive descriptor. More...

Macros

#define MAC_SUPPORTS_ZERO_COPY   TRUE
 This implementation supports the zero-copy mode API.
#define mac_lld_driver_fields
 Low level fields of the MAC driver structure.
#define mac_lld_config_fields
 Low level fields of the MAC configuration structure.
#define mac_lld_transmit_descriptor_fields
 Low level fields of the MAC transmit descriptor structure.
#define mac_lld_receive_descriptor_fields
 Low level fields of the MAC receive descriptor structure.

Typedefs

typedef struct hal_mac_driver MACDriver
 Type of a structure representing a MAC driver.
typedef struct hal_mac_config MACConfig
 Type of structure representing a MAC configuration.
typedef struct hal_mac_transmit_descriptor MACTransmitDescriptor
 Type of structure representing a MAC transmit descriptor.
typedef struct hal_mac_receive_descriptor MACReceiveDescriptor
 Type of structure representing a MAC receive descriptor.
typedef void(* maccb_t) (MACDriver *macp)
 Generic ETH notification callback type.

Enumerations

enum  macstate_t { MAC_UNINIT = 0 , MAC_STOP = 1 , MAC_ACTIVE = 2 }
 Driver state machine possible states. More...

Functions

void macInit (void)
 MAC Driver initialization.
void macObjectInit (MACDriver *macp)
 Initialize the standard part of a MACDriver structure.
msg_t macStart (MACDriver *macp, const MACConfig *config)
 Configures and activates the MAC peripheral.
void macStop (MACDriver *macp)
 Deactivates the MAC peripheral.
eventflags_t macGetAndClearEventsI (MACDriver *macp)
 Get and clears MAC event flags.
msg_t macWaitTransmitDescriptor (MACDriver *macp, MACTransmitDescriptor *tdp, sysinterval_t timeout)
 Allocates a transmission descriptor.
msg_t macWaitReceiveDescriptor (MACDriver *macp, MACReceiveDescriptor *rdp, sysinterval_t timeout)
 Waits for a received frame.
bool macPollLinkStatus (MACDriver *macp)
 Updates and returns the link status.
void macReleaseTransmitDescriptor (MACTransmitDescriptor *tdp)
void macReleaseReceiveDescriptor (MACReceiveDescriptor *rdp)
void mac_lld_init (void)
 Low level MAC initialization.
void mac_lld_start (MACDriver *macp)
 Configures and activates the MAC peripheral.
void mac_lld_stop (MACDriver *macp)
 Deactivates the MAC peripheral.
msg_t mac_lld_get_transmit_descriptor (MACDriver *macp, MACTransmitDescriptor *tdp)
 Returns a transmission descriptor.
void mac_lld_release_transmit_descriptor (MACTransmitDescriptor *tdp)
 Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.
msg_t mac_lld_get_receive_descriptor (MACDriver *macp, MACReceiveDescriptor *rdp)
 Returns a receive descriptor.
void mac_lld_release_receive_descriptor (MACReceiveDescriptor *rdp)
 Releases a receive descriptor.
bool mac_lld_poll_link_status (MACDriver *macp)
 Updates and returns the link status.
size_t mac_lld_write_transmit_descriptor (MACTransmitDescriptor *tdp, uint8_t *buf, size_t size)
 Writes to a transmit descriptor's stream.
size_t mac_lld_read_receive_descriptor (MACReceiveDescriptor *rdp, uint8_t *buf, size_t size)
 Reads from a receive descriptor's stream.
uint8_t * mac_lld_get_next_transmit_buffer (MACTransmitDescriptor *tdp, size_t size, size_t *sizep)
 Returns a pointer to the next transmit buffer in the descriptor chain.
const uint8_t * mac_lld_get_next_receive_buffer (MACReceiveDescriptor *rdp, size_t *sizep)
 Returns a pointer to the next receive buffer in the descriptor chain.

Variables

MACDriver ETHD1
 MAC1 driver identifier.

Macro Definition Documentation

◆ MAC_FLAGS_TX

#define MAC_FLAGS_TX   (1U << 0)

Definition at line 37 of file hal_mac.h.

◆ MAC_FLAGS_RX

#define MAC_FLAGS_RX   (1U << 1)

Definition at line 38 of file hal_mac.h.

◆ MAC_USE_ZERO_COPY

#define MAC_USE_ZERO_COPY   FALSE

Enables an event sources for incoming packets.

Definition at line 53 of file hal_mac.h.

◆ MAC_USE_EVENTS

#define MAC_USE_EVENTS   TRUE

Enables an event sources for incoming packets.

Definition at line 60 of file hal_mac.h.

◆ __mac_callback

#define __mac_callback ( macp)
Value:
do { \
if ((macp)->cb != NULL) { \
(macp)->cb(macp); \
} \
} while (false)

MAC callback.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 218 of file hal_mac.h.

◆ __mac_tx_wakeup

#define __mac_tx_wakeup ( macp)
Value:
do { \
osalSysLockFromISR(); \
osalThreadDequeueAllI(&(macp)->tdqueue, MSG_OK); \
(macp)->flags |= MAC_FLAGS_TX; \
osalEventBroadcastFlagsI(&(macp)->es, MAC_FLAGS_TX); \
osalSysUnlockFromISR(); \
} while (false)
#define MAC_FLAGS_TX
Definition hal_mac.h:37
#define MSG_OK
Definition osal.h:56

MAC TX wakeup and event.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 232 of file hal_mac.h.

◆ __mac_rx_wakeup

#define __mac_rx_wakeup ( macp)
Value:
do { \
osalSysLockFromISR(); \
osalThreadDequeueAllI(&(macp)->rdqueue, MSG_OK); \
(macp)->flags |= MAC_FLAGS_RX; \
osalEventBroadcastFlagsI(&(macp)->es, MAC_FLAGS_RX); \
osalSysUnlockFromISR(); \
} while (false)
#define MAC_FLAGS_RX
Definition hal_mac.h:38

MAC RX wakeup and event.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 256 of file hal_mac.h.

◆ macSetCallbackX

#define macSetCallbackX ( macp,
f )
Value:
(siop)->cb = (f)

Associates a callback to the MAC instance.

Parameters
[in]macppointer to the MACDriver object
[in]fcallback to be associated

Definition at line 283 of file hal_mac.h.

◆ macGetEventSource

#define macGetEventSource ( macp)
Value:
(&(macp)->es)

Returns the driver events source.

Parameters
[in]macppointer to the MACDriver object
Returns
The pointer to the EventSource structure.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 294 of file hal_mac.h.

◆ macGetTransmitDescriptorX

#define macGetTransmitDescriptorX ( macp,
tdp )
Value:
msg_t mac_lld_get_transmit_descriptor(MACDriver *macp, MACTransmitDescriptor *tdp)
Returns a transmission descriptor.

Returns a transmission descriptor.

One of the available transmission descriptors is locked and returned.

Parameters
[in]macppointer to the MACDriver object
[out]tdppointer to a MACTransmitDescriptor structure
Returns
The operation status.
Return values
MSG_OKthe descriptor has been obtained.
MSG_TIMEOUTdescriptor not available.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 310 of file hal_mac.h.

Referenced by macWaitTransmitDescriptor().

◆ macReleaseTransmitDescriptorX

#define macReleaseTransmitDescriptorX ( tdp)
Value:
void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp)
Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.

Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.

Parameters
[in]tdpthe pointer to the MACTransmitDescriptor structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 321 of file hal_mac.h.

◆ macGetReceiveDescriptorX

#define macGetReceiveDescriptorX ( macp,
rdp )
Value:
msg_t mac_lld_get_receive_descriptor(MACDriver *macp, MACReceiveDescriptor *rdp)
Returns a receive descriptor.

Returns a receive descriptor.

Parameters
[in]macppointer to the MACDriver object
[out]rdppointer to a MACReceiveDescriptor structure
Returns
The operation status.
Return values
MSG_OKthe descriptor has been obtained.
MSG_TIMEOUTdescriptor not available.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 335 of file hal_mac.h.

Referenced by macWaitReceiveDescriptor().

◆ macReleaseReceiveDescriptorX

#define macReleaseReceiveDescriptorX ( rdp)
Value:
void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp)
Releases a receive descriptor.

Releases a receive descriptor.

The descriptor and its buffer are made available for more incoming frames.

Parameters
[in]rdpthe pointer to the MACReceiveDescriptor structure
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 347 of file hal_mac.h.

◆ macWriteTransmitDescriptor

#define macWriteTransmitDescriptor ( tdp,
buf,
size )
Value:
size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp, uint8_t *buf, size_t size)
Writes to a transmit descriptor's stream.

Writes to a transmit descriptor's stream.

Parameters
[in]tdppointer to a MACTransmitDescriptor structure
[in]bufpointer to the buffer containing the data to be written
[in]sizenumber of bytes to be written
Returns
The number of bytes written into the descriptor's stream, this value can be less than the amount specified in the parameter size if the maximum frame size is reached.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 363 of file hal_mac.h.

◆ macReadReceiveDescriptor

#define macReadReceiveDescriptor ( rdp,
buf,
size )
Value:
size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp, uint8_t *buf, size_t size)
Reads from a receive descriptor's stream.

Reads from a receive descriptor's stream.

Parameters
[in]rdppointer to a MACReceiveDescriptor structure
[in]bufpointer to the buffer that will receive the read data
[in]sizenumber of bytes to be read
Returns
The number of bytes read from the descriptor's stream, this value can be less than the amount specified in the parameter size if there are no more bytes to read.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 378 of file hal_mac.h.

◆ macGetNextTransmitBuffer

#define macGetNextTransmitBuffer ( tdp,
size,
sizep )
Value:
uint8_t * mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp, size_t size, size_t *sizep)
Returns a pointer to the next transmit buffer in the descriptor chain.

Returns a pointer to the next transmit buffer in the descriptor chain.

Note
The API guarantees that enough buffers can be requested to fill a whole frame.
Parameters
[in]tdppointer to a MACTransmitDescriptor structure
[in]sizesize of the requested buffer. Specify the frame size on the first call then scale the value down subtracting the amount of data already copied into the previous buffers.
[out]sizeppointer to variable receiving the real buffer size. The returned value can be less than the amount requested, this means that more buffers must be requested in order to fill the frame data entirely.
Returns
Pointer to the returned buffer.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 401 of file hal_mac.h.

◆ macGetNextReceiveBuffer

#define macGetNextReceiveBuffer ( rdp,
sizep )
Value:
const uint8_t * mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp, size_t *sizep)
Returns a pointer to the next receive buffer in the descriptor chain.

Returns a pointer to the next receive buffer in the descriptor chain.

Note
The API guarantees that the descriptor chain contains a whole frame.
Parameters
[in]rdppointer to a MACReceiveDescriptor structure
[out]sizeppointer to variable receiving the buffer size, it is zero when the last buffer has already been returned.
Returns
Pointer to the returned buffer.
Return values
NULLif the buffer chain has been entirely scanned.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 418 of file hal_mac.h.

◆ MAC_SUPPORTS_ZERO_COPY

#define MAC_SUPPORTS_ZERO_COPY   TRUE

This implementation supports the zero-copy mode API.

Definition at line 37 of file hal_mac_lld.h.

◆ PLATFORM_MAC_USE_MAC1

#define PLATFORM_MAC_USE_MAC1   FALSE

MAC driver enable switch.

If set to TRUE the support for MAC1 is included.

Note
The default is FALSE.

Definition at line 53 of file hal_mac_lld.h.

◆ mac_lld_driver_fields

#define mac_lld_driver_fields

Low level fields of the MAC driver structure.

Definition at line 72 of file hal_mac_lld.h.

◆ mac_lld_config_fields

#define mac_lld_config_fields

Low level fields of the MAC configuration structure.

Definition at line 77 of file hal_mac_lld.h.

◆ mac_lld_transmit_descriptor_fields

#define mac_lld_transmit_descriptor_fields

Low level fields of the MAC transmit descriptor structure.

Definition at line 82 of file hal_mac_lld.h.

◆ mac_lld_receive_descriptor_fields

#define mac_lld_receive_descriptor_fields

Low level fields of the MAC receive descriptor structure.

Definition at line 87 of file hal_mac_lld.h.

Typedef Documentation

◆ MACDriver

typedef struct hal_mac_driver MACDriver

Type of a structure representing a MAC driver.

Definition at line 75 of file hal_mac.h.

◆ MACConfig

typedef struct hal_mac_config MACConfig

Type of structure representing a MAC configuration.

Definition at line 80 of file hal_mac.h.

◆ MACTransmitDescriptor

Type of structure representing a MAC transmit descriptor.

Definition at line 85 of file hal_mac.h.

◆ MACReceiveDescriptor

Type of structure representing a MAC receive descriptor.

Definition at line 90 of file hal_mac.h.

◆ maccb_t

typedef void(* maccb_t) (MACDriver *macp)

Generic ETH notification callback type.

Parameters
[in]macppointer to the MACDriver object

Definition at line 97 of file hal_mac.h.

Enumeration Type Documentation

◆ macstate_t

enum macstate_t

Driver state machine possible states.

Enumerator
MAC_UNINIT 

Not initialized.

MAC_STOP 

Stopped.

MAC_ACTIVE 

Active.

Definition at line 102 of file hal_mac.h.

Function Documentation

◆ macInit()

void macInit ( void )

MAC Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:
Object or module nitializer function.

Definition at line 64 of file hal_mac.c.

References mac_lld_init().

Referenced by halInit().

Here is the call graph for this function:

◆ macObjectInit()

void macObjectInit ( MACDriver * macp)

Initialize the standard part of a MACDriver structure.

Parameters
[out]macppointer to the MACDriver object
Function Class:
Object or module nitializer function.

Definition at line 76 of file hal_mac.c.

References hal_mac_driver::arg, hal_mac_driver::cb, hal_mac_driver::config, hal_mac_driver::es, hal_mac_driver::flags, MAC_STOP, osalEventObjectInit(), osalThreadQueueObjectInit(), hal_mac_driver::rdqueue, hal_mac_driver::state, and hal_mac_driver::tdqueue.

Referenced by mac_lld_init().

Here is the call graph for this function:

◆ macStart()

msg_t macStart ( MACDriver * macp,
const MACConfig * config )

Configures and activates the MAC peripheral.

Parameters
[in]macppointer to the MACDriver object
[in]configpointer to the MACConfig object
Returns
The operation status.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 99 of file hal_mac.c.

References hal_mac_driver::config, HAL_RET_SUCCESS, MAC_ACTIVE, mac_lld_start(), MAC_STOP, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and hal_mac_driver::state.

Here is the call graph for this function:

◆ macStop()

void macStop ( MACDriver * macp)

Deactivates the MAC peripheral.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 136 of file hal_mac.c.

References hal_mac_driver::config, MAC_ACTIVE, mac_lld_stop(), MAC_STOP, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and hal_mac_driver::state.

Here is the call graph for this function:

◆ macGetAndClearEventsI()

eventflags_t macGetAndClearEventsI ( MACDriver * macp)

Get and clears MAC event flags.

Parameters
[in]macppointer to the MACDriver object
Returns
The pending event flags.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 160 of file hal_mac.c.

References hal_mac_driver::flags.

◆ macWaitTransmitDescriptor()

msg_t macWaitTransmitDescriptor ( MACDriver * macp,
MACTransmitDescriptor * tdp,
sysinterval_t timeout )

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.

Parameters
[in]macppointer to the MACDriver object
[out]tdppointer to a MACTransmitDescriptor structure
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The operation status.
Return values
MSG_OKthe descriptor was obtained.
MSG_TIMEOUTthe operation timed out, descriptor not initialized.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 187 of file hal_mac.c.

References MAC_ACTIVE, macGetTransmitDescriptorX, MSG_OK, MSG_TIMEOUT, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), hal_mac_driver::state, and hal_mac_driver::tdqueue.

Here is the call graph for this function:

◆ macWaitReceiveDescriptor()

msg_t macWaitReceiveDescriptor ( MACDriver * macp,
MACReceiveDescriptor * rdp,
sysinterval_t timeout )

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.

Parameters
[in]macppointer to the MACDriver object
[out]rdppointer to a MACReceiveDescriptor structure
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The operation status.
Return values
MSG_OKthe descriptor was obtained.
MSG_TIMEOUTthe operation timed out, descriptor not initialized.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 227 of file hal_mac.c.

References MAC_ACTIVE, macGetReceiveDescriptorX, MSG_OK, MSG_TIMEOUT, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), hal_mac_driver::rdqueue, and hal_mac_driver::state.

Here is the call graph for this function:

◆ macPollLinkStatus()

bool macPollLinkStatus ( MACDriver * macp)

Updates and returns the link status.

Parameters
[in]macppointer to the MACDriver object
Returns
The link status.
Return values
trueif the link is active.
falseif the link is down.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 259 of file hal_mac.c.

References MAC_ACTIVE, mac_lld_poll_link_status(), osalDbgAssert, osalDbgCheck, and hal_mac_driver::state.

Here is the call graph for this function:

◆ macReleaseTransmitDescriptor()

void macReleaseTransmitDescriptor ( MACTransmitDescriptor * tdp)

◆ macReleaseReceiveDescriptor()

void macReleaseReceiveDescriptor ( MACReceiveDescriptor * rdp)

◆ mac_lld_init()

void mac_lld_init ( void )

Low level MAC initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 69 of file hal_mac_lld.c.

References macObjectInit().

Referenced by macInit().

Here is the call graph for this function:

◆ mac_lld_start()

void mac_lld_start ( MACDriver * macp)

Configures and activates the MAC peripheral.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 84 of file hal_mac_lld.c.

References MAC_STOP, and hal_mac_driver::state.

Referenced by macStart().

◆ mac_lld_stop()

void mac_lld_stop ( MACDriver * macp)

Deactivates the MAC peripheral.

Parameters
[in]macppointer to the MACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 105 of file hal_mac_lld.c.

References MAC_STOP, and hal_mac_driver::state.

Referenced by macStop().

◆ mac_lld_get_transmit_descriptor()

msg_t mac_lld_get_transmit_descriptor ( MACDriver * macp,
MACTransmitDescriptor * tdp )

Returns a transmission descriptor.

One of the available transmission descriptors is locked and returned.

Parameters
[in]macppointer to the MACDriver object
[out]tdppointer to a MACTransmitDescriptor structure
Returns
The operation status.
Return values
MSG_OKthe descriptor has been obtained.
MSG_TIMEOUTdescriptor not available.
Function Class:
Not an API, this function is for internal use only.

Definition at line 132 of file hal_mac_lld.c.

References MSG_OK.

◆ mac_lld_release_transmit_descriptor()

void mac_lld_release_transmit_descriptor ( MACTransmitDescriptor * tdp)

Releases a transmit descriptor and starts the transmission of the enqueued data as a single frame.

Parameters
[in]tdpthe pointer to the MACTransmitDescriptor structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 149 of file hal_mac_lld.c.

◆ mac_lld_get_receive_descriptor()

msg_t mac_lld_get_receive_descriptor ( MACDriver * macp,
MACReceiveDescriptor * rdp )

Returns a receive descriptor.

Parameters
[in]macppointer to the MACDriver object
[out]rdppointer to a MACReceiveDescriptor structure
Returns
The operation status.
Return values
MSG_OKthe descriptor has been obtained.
MSG_TIMEOUTdescriptor not available.
Function Class:
Not an API, this function is for internal use only.

Definition at line 166 of file hal_mac_lld.c.

References MSG_OK.

◆ mac_lld_release_receive_descriptor()

void mac_lld_release_receive_descriptor ( MACReceiveDescriptor * rdp)

Releases a receive descriptor.

The descriptor and its buffer are made available for more incoming frames.

Parameters
[in]rdpthe pointer to the MACReceiveDescriptor structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 184 of file hal_mac_lld.c.

◆ mac_lld_poll_link_status()

bool mac_lld_poll_link_status ( MACDriver * macp)

Updates and returns the link status.

Parameters
[in]macppointer to the MACDriver object
Returns
The link status.
Return values
trueif the link is active.
falseif the link is down.
Function Class:
Not an API, this function is for internal use only.

Definition at line 200 of file hal_mac_lld.c.

Referenced by macPollLinkStatus().

◆ mac_lld_write_transmit_descriptor()

size_t mac_lld_write_transmit_descriptor ( MACTransmitDescriptor * tdp,
uint8_t * buf,
size_t size )

Writes to a transmit descriptor's stream.

Parameters
[in]tdppointer to a MACTransmitDescriptor structure
[in]bufpointer to the buffer containing the data to be written
[in]sizenumber of bytes to be written
Returns
The number of bytes written into the descriptor's stream, this value can be less than the amount specified in the parameter size if the maximum frame size is reached.
Function Class:
Not an API, this function is for internal use only.

Definition at line 221 of file hal_mac_lld.c.

◆ mac_lld_read_receive_descriptor()

size_t mac_lld_read_receive_descriptor ( MACReceiveDescriptor * rdp,
uint8_t * buf,
size_t size )

Reads from a receive descriptor's stream.

Parameters
[in]rdppointer to a MACReceiveDescriptor structure
[in]bufpointer to the buffer that will receive the read data
[in]sizenumber of bytes to be read
Returns
The number of bytes read from the descriptor's stream, this value can be less than the amount specified in the parameter size if there are no more bytes to read.
Function Class:
Not an API, this function is for internal use only.

Definition at line 244 of file hal_mac_lld.c.

◆ mac_lld_get_next_transmit_buffer()

uint8_t * mac_lld_get_next_transmit_buffer ( MACTransmitDescriptor * tdp,
size_t size,
size_t * sizep )

Returns a pointer to the next transmit buffer in the descriptor chain.

Note
The API guarantees that enough buffers can be requested to fill a whole frame.
Parameters
[in]tdppointer to a MACTransmitDescriptor structure
[in]sizesize of the requested buffer. Specify the frame size on the first call then scale the value down subtracting the amount of data already copied into the previous buffers.
[out]sizeppointer to variable receiving the buffer size, it is zero when the last buffer has already been returned. Note that a returned size lower than the amount requested means that more buffers must be requested in order to fill the frame data entirely.
Returns
Pointer to the returned buffer.
Return values
NULLif the buffer chain has been entirely scanned.
Function Class:
Not an API, this function is for internal use only.

Definition at line 276 of file hal_mac_lld.c.

◆ mac_lld_get_next_receive_buffer()

const uint8_t * mac_lld_get_next_receive_buffer ( MACReceiveDescriptor * rdp,
size_t * sizep )

Returns a pointer to the next receive buffer in the descriptor chain.

Note
The API guarantees that the descriptor chain contains a whole frame.
Parameters
[in]rdppointer to a MACReceiveDescriptor structure
[out]sizeppointer to variable receiving the buffer size, it is zero when the last buffer has already been returned.
Returns
Pointer to the returned buffer.
Return values
NULLif the buffer chain has been entirely scanned.
Function Class:
Not an API, this function is for internal use only.

Definition at line 301 of file hal_mac_lld.c.

Variable Documentation

◆ ETHD1

MACDriver ETHD1

MAC1 driver identifier.

Definition at line 45 of file hal_mac_lld.c.