mbox: xmbox_intr_example.c File Reference

| mbox Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xmbox_intr_example.c File Reference

## Overview

This file contains a design example for using the Mailbox hardware and driver XMbox.

This example attempts to send a known message through the mailbox from the processor identified as 0 (XPAR_CPU_ID=0) to the other processor. The message is received by the receiver and the test passes. Since the application is running on two seperate processors, the initiator declares success when the message is sent and the receiver declares success when the message is received. There is no feedback to the initiator so a terminal is required for each processor to verify that the test passed for both sides.

The example assumes there are two processors availabile in the system that are expected to inter-communicate.

This example has been tested on ML505 Hardware Evaluation board.

Note

These code fragments will illustrate how the XMbox component can be used to:

- Initialize the Mailbox core.
- pass data between two processors.

      MODIFICATION HISTORY:

      Ver   Who  Date        Changes

      2.00a hm              Example that sends and receives and uses interrupts
      3.01a sdm  05/06/10   Cleanup for coding guidelines, removed printfs from all
                            the functions except the main function
      4.1   ms   01/23/17 Modified xil_printf statement in main function to
                          ensure that "Successfully ran" and "Failed" strings
                          are available in all examples. This is a fix for
                          CR-965028.
            ms   04/05/17 Added tabspace for return statements in functions for
                          proper documentation while generating doxygen and
                          modified filename tag to include the file in doxygen
                          examples.
    *

## Functions
int | MailboxExample (XIntc *IntcInstancePtr, u16 MboxDeviceId, u16 MboxIntrId)
| This function sends a message to and receives a message from the other processor. More...
int | MailboxExample_Send (XMbox *MboxInstancePtr, int CPU_Id, int Blocking)
| This function sends the hello message to the other processor. More...
int | MailboxExample_Receive (XMbox *MboxInstancePtr, int CPU_Id, int Blocking)
| This function receives a message from the other processor verifies it's the expected message. More...
int | MailboxExample_Wait (volatile int *Count, char *Name, int Threshold)
| This function waits for a particular variable to exceed the threshold value. More...
int | main (void)
| This function is the main function for the mailbox interrupt example. More...

## Function Documentation

int MailboxExample | ( | XIntc * | IntcInstancePtr,
|  | u16 | MboxDeviceId,
|  | u16 | MboxIntrId
| ) |  |

This function sends a message to and receives a message from the other processor.

It also uses the interrupt to check whether the other processor has started to send or receive.

Parameters

  IntcInstancePtr | is the device instance of the interrupt controller that is being worked on.
  MboxDeviceId | is the Mailbox device ID.
  MboxIntrId | is the Mailbox interrupt ID.

Returns
  - XST_SUCCESS if the test passes
  - XST_FAILURE if the test fails

Note
  None

References XMbox_Config::BaseAddress, XMbox::Config, MailboxExample_Receive(), MailboxExample_Send(), MailboxExample_Wait(), XMbox_Config::UseFSL, and XMbox_CfgInitialize().

Referenced by main().

int MailboxExample_Receive | ( | XMbox * | MboxInstancePtr,
|  | int | CPU_Id,
|  | int | Blocking
| ) |  |

This function receives a message from the other processor verifies it's the expected message.

Parameters

  MboxInstancePtr | is the instance pointer for the XMbox.
  CPU_Id | is the CPU ID for the program that is running on.

Returns
  - XST_SUCCESS if the receive succeeds
  - XST_FAILURE if the receive fails

Note
  None

References XMbox_Read(), and XMbox_ReadBlocking().

Referenced by MailboxExample().

int MailboxExample_Send | ( | XMbox * | MboxInstancePtr,
|  | int | CPU_Id,
|  | int | Blocking
| ) |  |

This function sends the hello message to the other processor.

Parameters

  MboxInstancePtr | is the instance pointer for the XMbox.
  CPU_Id | is the CPU ID for the program that is running on.
  Blocking | is set to 1 for the send to block till the data is sent.

Returns
  - XST_SUCCESS if the send succeeds
  - XST_FAILURE if the send fails

Note
  None

References XMbox_Write(), and XMbox_WriteBlocking().

Referenced by MailboxExample().

int MailboxExample_Wait | ( | volatile int * | Count,
|  | char * | Name,
|  | int | Threshold
| ) |  |

This function waits for a particular variable to exceed the threshold value.

If it waits too long, it will time out and returns XST_FAILURE.

Parameters

  Count | is the pointer to the variable to be examined.
  Name | is the name of the variable.
  Threshold | is the threshold value to be exceeded.

Returns
  - XST_SUCCESS if the examined variable exceeds the threshold value.
  - XST_FAILURE if the wait times out.

Note
  None

Referenced by MailboxExample().

int main | ( | void |  | ) |

This function is the main function for the mailbox interrupt example.

Parameters

  None |

Returns
  XST_SUCCESS if successful, XST_FAILURE if unsuccessful

Note
  None

References MailboxExample().