Hardware Abstraction Layer (HAL)
All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
M2M DMA (Memory-to-Memory Direct Memory Access)

General Description

High level interface for interacting with the memory-to-memory direct memory access (DMA).

This driver allows transferring data to/from the radio RAM from/to the main application RAM. For general-purpose DMA transfers, use the DMA driver.

Typedefs

typedef void(* cyhal_m2m_event_callback_t) (void *callback_arg, cyhal_m2m_event_t event)
 Event handler for M2M interrupts.
 

Enumerations

enum  cyhal_m2m_rx_status_t {
  CYHAL_M2M_RX_DISABLED = 0x0 ,
  CYHAL_M2M_RX_ACTIVE = 0x1 ,
  CYHAL_M2M_RX_IDLE_WAIT = 0x2 ,
  CYHAL_M2M_RX_STOPPED = 0x3
}
 Enum of M2M RX channel activity status. More...
 
enum  cyhal_m2m_event_t {
  CYHAL_M2M_NO_INTR = 0 ,
  CYHAL_M2M_DESCRIPTOR_READ_ERROR = (1 << 0) ,
  CYHAL_M2M_DATA_TRANSFER_ERROR = (1 << 1) ,
  CYHAL_M2M_DESCRIPTOR_PROGRAM_ERROR = (1 << 2) ,
  CYHAL_M2M_NO_DESCRIPTOR_ERROR = (1 << 3) ,
  CYHAL_M2M_RX_CHANNEL_INTERRUPT = (1 << 4) ,
  CYHAL_M2M_TX_CHANNEL_INTERRUPT = (1 << 5)
}
 Flags enum of M2M events. More...
 

Functions

cy_rslt_t cyhal_m2m_init (cyhal_m2m_t *obj, uint32_t rx_buffer_size)
 Initialize the M2M peripheral. More...
 
void cyhal_m2m_free (cyhal_m2m_t *obj)
 Free the M2M object. More...
 
bool cyhal_m2m_is_busy (cyhal_m2m_t *obj)
 Checks if the transfer has been triggered, but not yet complete (eg: is pending, blocked or running) More...
 
void cyhal_m2m_register_callback (cyhal_m2m_t *obj, cyhal_m2m_event_callback_t callback, void *callback_arg)
 Register an M2M callback handler. More...
 
void cyhal_m2m_enable_event (cyhal_m2m_t *obj, cyhal_m2m_event_t event, uint8_t intr_priority, bool enable)
 Configure M2M event enablement. More...
 
cy_rslt_t cyhal_m2m_tx_send (cyhal_m2m_t *obj, void *buffer)
 Send M2M TX data packet. More...
 
void cyhal_m2m_tx_release (cyhal_m2m_t *obj)
 Release next completed M2M TX data packet. More...
 
void cyhal_m2m_rx_receive (cyhal_m2m_t *obj, void **rxd_handle, uint16_t **hwtag)
 Receive and read M2M RX data packet. More...
 
bool cyhal_m2m_rx_prepare (cyhal_m2m_t *obj)
 Prepare M2M RX ring buffer. More...
 
cyhal_m2m_rx_status_t cyhal_m2m_rx_status (cyhal_m2m_t *obj)
 M2M RX activity status. More...
 
cyhal_m2m_event_t cyhal_m2m_intr_status (cyhal_m2m_t *obj, bool *signal_txdone)
 Read M2M TX and RX interrupt status. More...
 

Enumeration Type Documentation

◆ cyhal_m2m_rx_status_t

Enum of M2M RX channel activity status.

Enumerator
CYHAL_M2M_RX_DISABLED 

Channel is disabled.

CYHAL_M2M_RX_ACTIVE 

Channel is either waiting for data to transfer or is transferring data.

CYHAL_M2M_RX_IDLE_WAIT 

Channel is waiting for a descriptor to be posted or is suspended.

CYHAL_M2M_RX_STOPPED 

Channel is stopped because an error was detected.

◆ cyhal_m2m_event_t

Flags enum of M2M events.

Multiple events can be enabled via cyhal_m2m_enable_event and the callback from cyhal_m2m_register_callback will be run to notify.

Enumerator
CYHAL_M2M_NO_INTR 

No interrupt.

CYHAL_M2M_DESCRIPTOR_READ_ERROR 

Descriptor read error.

CYHAL_M2M_DATA_TRANSFER_ERROR 

Errors while transferring data to or from memory.

CYHAL_M2M_DESCRIPTOR_PROGRAM_ERROR 

descriptor programming errors

CYHAL_M2M_NO_DESCRIPTOR_ERROR 

Channel cannot process an incoming frame because no descriptors are available.

CYHAL_M2M_RX_CHANNEL_INTERRUPT 

Interrupt from the RX channel.

CYHAL_M2M_TX_CHANNEL_INTERRUPT 

Interrupt from the TX channel.

Function Documentation

◆ cyhal_m2m_init()

cy_rslt_t cyhal_m2m_init ( cyhal_m2m_t obj,
uint32_t  rx_buffer_size 
)

Initialize the M2M peripheral.

Parameters
[out]objPointer to an M2M object. The caller must allocate the memory for this object but the init function will initialize its contents.
[in]rx_buffer_sizeSize of the RX buffer.
Returns
The status of the init request

◆ cyhal_m2m_free()

void cyhal_m2m_free ( cyhal_m2m_t obj)

Free the M2M object.

Freeing a M2M object while a transfer is in progress (cyhal_m2m_is_busy) is invalid.

Parameters
[in,out]objThe M2M object

◆ cyhal_m2m_is_busy()

bool cyhal_m2m_is_busy ( cyhal_m2m_t obj)

Checks if the transfer has been triggered, but not yet complete (eg: is pending, blocked or running)

Parameters
[in]objThe M2M object
Returns
True if M2M channel is busy

◆ cyhal_m2m_register_callback()

void cyhal_m2m_register_callback ( cyhal_m2m_t obj,
cyhal_m2m_event_callback_t  callback,
void *  callback_arg 
)

Register an M2M callback handler.

This function will be called when one of the events enabled by cyhal_m2m_enable_event occurs.

Parameters
[in]objThe M2M object
[in]callbackThe callback handler which will be invoked when an event triggers
[in]callback_argGeneric argument that will be provided to the callback when called

◆ cyhal_m2m_enable_event()

void cyhal_m2m_enable_event ( cyhal_m2m_t obj,
cyhal_m2m_event_t  event,
uint8_t  intr_priority,
bool  enable 
)

Configure M2M event enablement.

When an enabled event occurs, the function specified by cyhal_m2m_register_callback will be called.

Parameters
[in]objThe M2M object
[in]eventThe M2M event type
[in]intr_priorityThe priority for NVIC interrupt events. The priority from the most recent call will take precedence, i.e all events will have the same priority.
[in]enableTrue to turn on interrupts, False to turn off

◆ cyhal_m2m_tx_send()

cy_rslt_t cyhal_m2m_tx_send ( cyhal_m2m_t obj,
void *  buffer 
)

Send M2M TX data packet.

This function sends a TX data packet. WHD is expected to set the packet size and send the "data" with whd_buffer_t type. The buffer type is dependent on the network stack. For example for LWIP, it is structured as follows: p->payload = payload; //packet data p->len = len; //packet size

Parameters
[in]objThe M2M object
[in]bufferData buffer to use in the packet transaction
Returns
The status of the tx operation

◆ cyhal_m2m_tx_release()

void cyhal_m2m_tx_release ( cyhal_m2m_t obj)

Release next completed M2M TX data packet.

This function is used to free the TX data packet if TX error occurs.

Parameters
[in]objThe M2M object

◆ cyhal_m2m_rx_receive()

void cyhal_m2m_rx_receive ( cyhal_m2m_t obj,
void **  rxd_handle,
uint16_t **  hwtag 
)

Receive and read M2M RX data packet.

This function reads the next available RX packet.

Parameters
[in]objThe M2M object
[out]rxd_handleRX packet handle
[out]hwtagHardware tag used to read the frame header

◆ cyhal_m2m_rx_prepare()

bool cyhal_m2m_rx_prepare ( cyhal_m2m_t obj)

Prepare M2M RX ring buffer.

Prepares the internal M2M RX buffer (allocated during initialization) for receiving RX data packets.

Parameters
[in]objThe M2M object
Returns
Success (true) or Failed (false)

◆ cyhal_m2m_rx_status()

cyhal_m2m_rx_status_t cyhal_m2m_rx_status ( cyhal_m2m_t obj)

M2M RX activity status.

Parameters
[in]objThe M2M object
Returns
RX activity status

◆ cyhal_m2m_intr_status()

cyhal_m2m_event_t cyhal_m2m_intr_status ( cyhal_m2m_t obj,
bool *  signal_txdone 
)

Read M2M TX and RX interrupt status.

Reads the interrupt status for TX and RX channels.

Parameters
[in]objThe M2M object
[out]signal_txdoneTX done state as signaled by the RX interrupt
Returns
Interrupt event status