📄 hubinterface.h
字号:
//--------------------------------------------------------------------------
//
// Filename: HubInterface.h
//
// Description:
//
//--------------------------------------------------------------------------
// $Archive: /WirelessUSB/WUSB Kits/CY3635 N-to-1 DVK/DocSrc/CD_Root/Software/Nto1/common/HubInterface/HubInterface.h $
// $Modtime: 10/06/04 6:19p $
// $Revision: 1 $
//--------------------------------------------------------------------------
//
// Copyright 2004, Cypress Semiconductor Corporation.
//
// This software is owned by Cypress Semiconductor Corporation (Cypress)
// and is protected by and subject to worldwide patent protection (United
// States and foreign), United States copyright laws and international
// treaty provisions. Cypress hereby grants to licensee a personal,
// non-exclusive, non-transferable license to copy, use, modify, create
// derivative works of, and compile the Cypress Source Code and derivative
// works for the sole purpose of creating custom software in support of
// licensee product to be used only in conjunction with a Cypress integrated
// circuit as specified in the applicable agreement. Any reproduction,
// modification, translation, compilation, or representation of this
// software except as specified above is prohibited without the express
// written permission of Cypress.
//
// Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// Cypress reserves the right to make changes without further notice to the
// materials described herein. Cypress does not assume any liability arising
// out of the application or use of any product or circuit described herein.
// Cypress does not authorize its products for use as critical components in
// life-support systems where a malfunction or failure may reasonably be
// expected to result in significant injury to the user. The inclusion of
// Cypress' product in a life-support systems application implies that the
// manufacturer assumes all risk of such use and in doing so indemnifies
// Cypress against all charges.
//
// Use may be limited by and subject to the applicable Cypress software
// license agreement.
//
//--------------------------------------------------------------------------
#ifndef __hubinterface_h
#define __hubinterface_h
// Macros used to switch between endian ints
#define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
#define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
// Ensure data is byte packed
#pragma pack (1)
#define HUB_RESPONSE_STATUS_SUCCESS 0x00
#define HUB_RESPONSE_STATUS_UNKNOWN_COMMAND 0x01
#define HUB_RESPONSE_STATUS_UNKNOWN_DEVICEID 0x02
#define HUB_RESPONSE_STATUS_SEND_BUFFER_TOO_LARGE 0x03
#define HUB_RESPONSE_STATUS_PRIOR_SEND_PAYLOAD_LOST 0x04
#define HUB_RESPONSE_STATUS_PN_CODE_TOO_BIG 0x05
#define HUB_RESPONSE_STATUS_CHANNEL_ERROR 0x06
#define HUB_RESPONSE_STATUS_SEND_BUFFER_PENDING 0x07
#define HUB_RESPONSE_STATUS_INVALID_CHANNEL 0x08
// HostToHub Command Packets
typedef enum
{
EHostToHubGetHubInfo = 0x01, // Get Hub Information
EHostToHubBind = 0x02, // Bind
EHostToHubDeleteNode = 0x04, // Delete Node
EHostToHubSendMsg = 0x05, // Send Message
EHostToHubEnumDevices = 0x07, // Enumerate Devices
EHostToHubNetworkCfg = 0x08, // Network Configuration
EHostToHubNetworkSts = 0x09, // Network Status
EHostToHubReset = 0x0A, // Reset
EHostToHubChangeChannel = 0x0B, // Change Channel
}
ENUM_HOST_TO_HUB;
// Bind Command Structure
typedef struct
{
BYTE Command;
union
{
struct
{
BYTE Opt_Res0:1;
BYTE Opt_Bind:1;
BYTE Opt_SeededBind:1;
BYTE Opt_Res3:1;
BYTE Opt_Res4:1;
BYTE Opt_Res5:1;
BYTE Opt_Res6:1;
BYTE Opt_Res7:1;
};
BYTE Options;
};
} BIND_COMMAND, *PBIND_COMMAND;
// Delete Node Command Structure
typedef struct
{
BYTE Command;
WORD DeviceID;
} DELETE_NODE_COMMAND, *PDELETE_NODE_COMMAND;
// Send Message Command Structure
typedef struct
{
BYTE Command;
WORD DeviceID;
union
{
struct
{
BYTE TransAttempts:5;
BYTE res0:1;
BYTE res1:1;
BYTE InhibitNotify:1;
};
BYTE Options;
};
BYTE Payload;
} SEND_MESSAGE_COMMAND, *PSEND_MESSAGE_COMMAND;
// Send Message Payload Structure
typedef struct
{
WORD Interval;
union
{
struct
{
BYTE res5 :1;
BYTE LED_Y:1;
BYTE LED_R:1;
BYTE res0:1;
BYTE res1:1;
BYTE res2:1;
BYTE res3:1;
BYTE res4:1;
};
BYTE LEDS;
};
BYTE reserved0;
BYTE Data;
} SEND_MESSAGE_PAYLOAD, *PSEND_MESSAGE_PAYLOAD;
#define MAX_PAYLOAD_DATA_SIZE 5
// Network Configuration Command Structure
typedef struct
{
BYTE Command;
union
{
BYTE PNCodeID;
BYTE PNCodeIndex;
};
BYTE Channel;
ULONG HubMID;
} NETWORK_CONFIG_COMMAND, *PNETWORK_CONFIG_COMMAND;
// Change Channel Command Structure
typedef struct
{
BYTE Command;
BYTE Channel;
} CHANGE_CHANNEL_COMMAND, *PCHANGE_CHANNEL_COMMAND;
// HostToHub Command Structure
typedef struct
{
union
{
// Command byte
BYTE Command;
// Bind Command Structure
BIND_COMMAND Bind;
// Delete Node Command Structure
DELETE_NODE_COMMAND DeleteNode;
// Send Message Command Structure
SEND_MESSAGE_COMMAND SendMessage;
// Network Configuration Command Structure
NETWORK_CONFIG_COMMAND NetworkConfig;
// Change Channel Command Structure
CHANGE_CHANNEL_COMMAND ChangeChannel;
};
} HOST_TO_HUB, *PHOST_TO_HUB;
// HubToHost Response Packets
typedef enum
{
EHubToHostHubInfo = 0x81, // Hub Inforomation Response
EHubToHostBind = 0x82, // Bind Response
EHubToHostBindInfo = 0x83, // Bind Information Response
EHubToHostDeleteNode = 0x84, // Delete Node Response
EHubToHostSendMsg = 0x85, // Send Message Response
EHubToHostIncomingMsg = 0x86, // Incoming Message Response
EHubToHostEnumDevices = 0x87, // Enumerate Devices Response
EHubToHostConfigSts = 0x88, // Configure Status Response
EHubToHostNetworkSts = 0x89, // Network Status Response
EHubToHostReset = 0x8A, // Reset Response
EHubToHostChangeChannel = 0x8B, // Change Channel Response
}
ENUM_HUB_TO_HOST;
// Hub Info Response Structure
typedef struct
{
BYTE Response;
BYTE FirmwareMajorVersion;
BYTE FirmwareMinorVersion;
BYTE FirmwareBuild;
LONG HubMID;
WORD MaxDeviceIDs;
BYTE RadioVersion;
} HUB_INFO_RESPONSE, *PHUB_INFO_RESPONSE;
// Bind Response Structure
typedef struct
{
BYTE Response;
BYTE Status;
} BIND_RESPONSE, *PBIND_RESPONSE;
// Bind Information Response Structure
typedef struct
{
BYTE Response;
WORD DeviceID;
LONG SensorMID;
} BIND_INFO_RESPONSE, *PBIND_INFO_RESPONSE;
// Delete Node Response Structure
typedef struct
{
BYTE Response;
WORD DeviceID;
BYTE Status;
} DELETE_NODE_RESPONSE, *PDELETE_NODE_RESPONSE;
// Send Message Response Structure
typedef struct
{
BYTE Response;
WORD DeviceID;
BYTE Status;
} SEND_MESSAGE_RESPONSE, *PSEND_MESSAGE_RESPONSE;
// Incoming Message Response Structure
typedef struct
{
BYTE Response;
WORD DeviceID;
BYTE Payload;
} INCOMING_MESSAGE_RESPONSE, *PINCOMING_MESSAGE_RESPONSE;
// Incoming Message Payload Structure
typedef struct
{
BYTE BattVolt;
#if defined(THREE_THERMISTORS_DEMO) && defined(THERM_11_BIT)
WORD TempVoltA;
#else
BYTE PotVolt;
BYTE TempVolt;
#endif
union
{
struct
{
BYTE DIP_1:1;
BYTE DIP_2:1;
BYTE DIP_3:1;
BYTE DIP_4:1;
BYTE Button1:1;
BYTE Button2:1;
BYTE Y_LED:1;
BYTE R_LED:1;
};
BYTE Switch;
};
#if defined(THREE_THERMISTORS_DEMO) && defined(THERM_11_BIT)
WORD TempVoltB;
WORD TempVoltC;
#endif
BYTE Data;
} INCOMING_MESSAGE_PAYLOAD, *PINCOMING_MESSAGE_PAYLOAD;
// Enumerate Devices Response Structure
typedef struct
{
BYTE Response;
BYTE Status;
WORD NumDevicesEnumerated;
} ENUMERATE_DEVICES_RESPONSE, *PENUMERATE_DEVICES_RESPONSE;
// Configure Status Response
typedef struct
{
BYTE Response;
BYTE Status;
} CONFIGURE_STATUS_RESPONSE, *PCONFIGURE_STATUS_RESPONSE;
// Network Status Response Structure
typedef struct
{
BYTE Response;
BYTE CurrentChannel;
union
{
BYTE CurrentPNCodeID;
BYTE CurrentPNCodeIndex;
};
BYTE CurrentDataRate;
BYTE CurrentBindState;
} NETWORK_INFO_RESPONSE, *PNETWORK_INFO_RESPONSE;
#define BIND_ENABLE 0x02
// Change Channel Response Structure
typedef struct
{
BYTE Response;
BYTE Status;
BYTE NewChannel;
} CHANGECHANNEL_RESPONSE, *PCHANGECHANNEL_RESPONSE;
// Reset Response Structure
typedef struct
{
BYTE Response;
BYTE Status;
} RESET_RESPONSE, *PRESET_RESPONSE;
// HubToHost Response Packet Structure
typedef struct
{
union
{
// Response byte
BYTE Response;
// Hub Info Response Structure
HUB_INFO_RESPONSE HubInfo;
// Bind Response Structure
BIND_RESPONSE Bind;
// Bind Information Response Structure
BIND_INFO_RESPONSE BindInfo;
// Delete Node Response Structure
DELETE_NODE_RESPONSE DeleteNode;
// Send Message Response Structure
SEND_MESSAGE_RESPONSE SendMessage;
// Incoming Message Response Structure
INCOMING_MESSAGE_RESPONSE IncomingMessage;
// Enumerate Devices Response Structure
ENUMERATE_DEVICES_RESPONSE EnumerateDevices;
// Configure Status Response
CONFIGURE_STATUS_RESPONSE ConfigureStatus;
// Network Status Response Structure
NETWORK_INFO_RESPONSE NetworkInfo;
// Reset Response Structure
RESET_RESPONSE Reset;
// Change Channel Response Structure
CHANGECHANNEL_RESPONSE ChangeChannel;
};
} HUB_TO_HOST, *PHUB_TO_HOST;
// HubToHost Status Codes
typedef enum
{
EHubToHostSuccess = 0x00, // Succes
EHubToHostUnknownCommand = 0x01, // Unknown Command
EHubToHostUnknownDeviceID = 0x02, // Unknown Device ID
EHubToHostSendBufferTooLarge = 0x03, // Send Buffer Too Large
EHubToHostPriorSendPayloadLost = 0x04, // Prior Send Payload Lost
EHubToHostPNCodeTooBig = 0x05, // PN Code Too Big
EHubToHostChannelError = 0x06, // Channel Error
}
ENUM_HUB_TO_HOST_ERRORS;
#pragma pack ()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -