XCORE SDK
XCORE Software Development Kit
Macros | Enumerations
Device_control_shared

Macros

#define CONTROL_VERSION   0x10
 
#define IS_CONTROL_CMD_READ(c)   ((c) & 0x80)
 
#define CONTROL_CMD_SET_READ(c)   ((c) | 0x80)
 
#define CONTROL_CMD_SET_WRITE(c)   ((c) & ~0x80)
 
#define CONTROL_SPECIAL_RESID   0
 
#define CONTROL_MAX_RESOURCE_ID   255
 
#define CONTROL_GET_VERSION   CONTROL_CMD_SET_READ(0)
 
#define CONTROL_GET_LAST_COMMAND_STATUS   CONTROL_CMD_SET_READ(1)
 
#define DEVICE_CONTROL_HOST_MODE   0
 
#define DEVICE_CONTROL_CLIENT_MODE   1
 
#define DEVICE_CONTROL_CALLBACK_ATTR   __attribute__((fptrgroup("device_control_cb_fptr_grp")))
 

Enumerations

enum  control_ret_t {
  CONTROL_SUCCESS = 0 , CONTROL_REGISTRATION_FAILED , CONTROL_BAD_COMMAND , CONTROL_DATA_LENGTH_ERROR ,
  CONTROL_OTHER_TRANSPORT_ERROR , CONTROL_ERROR
}
 
enum  control_direction_t { CONTROL_HOST_TO_DEVICE , CONTROL_DEVICE_TO_HOST }
 
typedef uint8_t control_resid_t
 
typedef uint8_t control_cmd_t
 
typedef uint8_t control_version_t
 
typedef uint8_t control_status_t
 

Detailed Description

The shared API for using the device control library on the device and host

Macro Definition Documentation

◆ CONTROL_CMD_SET_READ

#define CONTROL_CMD_SET_READ (   c)    ((c) | 0x80)

Sets the read bit on a command code

Parameters
[in,out]cThe command code to set the read bit on.

◆ CONTROL_CMD_SET_WRITE

#define CONTROL_CMD_SET_WRITE (   c)    ((c) & ~0x80)

Clears the read bit on a command code

Parameters
[in,out]cThe command code to clear the read bit on.

◆ CONTROL_GET_LAST_COMMAND_STATUS

#define CONTROL_GET_LAST_COMMAND_STATUS   CONTROL_CMD_SET_READ(1)

The command to read the return status of the last command. It must be sent to resource ID CONTROL_SPECIAL_RESID.

◆ CONTROL_GET_VERSION

#define CONTROL_GET_VERSION   CONTROL_CMD_SET_READ(0)

The command to read the version of the control protocol. It must be sent to resource ID CONTROL_SPECIAL_RESID.

◆ CONTROL_MAX_RESOURCE_ID

#define CONTROL_MAX_RESOURCE_ID   255

The maximum resource ID. IDs greater than this cannot be registered.

◆ CONTROL_SPECIAL_RESID

#define CONTROL_SPECIAL_RESID   0

This is the special resource ID owned by the control library. It can be used to check the version of the control protocol. Servicers may not register this resource ID.

◆ CONTROL_VERSION

#define CONTROL_VERSION   0x10

This is the version of control protocol. Used to check compatibility

◆ DEVICE_CONTROL_CALLBACK_ATTR

#define DEVICE_CONTROL_CALLBACK_ATTR   __attribute__((fptrgroup("device_control_cb_fptr_grp")))

This attribute must be specified on all device control command handler callback functions provided by the application.

◆ DEVICE_CONTROL_CLIENT_MODE

#define DEVICE_CONTROL_CLIENT_MODE   1

The mode value to use when initializing a device control instance that is not on the same tile as its associated transport layer. These must be connected to a device control instance on another tile that has been initialized with DEVICE_CONTROL_HOST_MODE.

◆ DEVICE_CONTROL_HOST_MODE

#define DEVICE_CONTROL_HOST_MODE   0

The mode value to use when initializing a device control instance that is on the same tile as its associated transport layer. These may be connected to device control instances on other tiles that have been initialized with DEVICE_CONTROL_CLIENT_MODE.

◆ IS_CONTROL_CMD_READ

#define IS_CONTROL_CMD_READ (   c)    ((c) & 0x80)

Checks if the read bit is set in a command code.

Parameters
[in]cThe command code to check
Returns
true if the read bit in the command is set
false if the read bit is not set

Typedef Documentation

◆ control_resid_t

typedef uint8_t control_resid_t

These types are used in control functions to identify the resource id, command, version, and status.

Enumeration Type Documentation

◆ control_direction_t

This type is used to inform the control library the direction of a control transfer from the transport layer.

◆ control_ret_t

This type enumerates the possible outcomes from a control transaction.