Silicon Labs Host Libraries
CP2114_Common.h
1 //-----------------------------------------------------------------------------
2 // CP2114_Common.h
3 //-----------------------------------------------------------------------------
4 // Copyright 2012 Silicon Laboratories, Inc.
5 // http://www.silabs.com
6 //
7 // Program Description:
8 //
9 // Header file shared by both CP2114 firmware and the Configurator.
10 //
11 //
12 // How To Test: See Readme.txt
13 //
14 //
15 // Target: C8051F381/T627
16 // Tool chain: Keil C51
17 // Silicon Laboratories IDE
18 // Command Line: See Readme.txt
19 // Project Name: CP2114
20 //
21 //-----------------------------------------------------------------------------
22 #ifndef _CP2114_DATA_COMMON_H_
23 #define _CP2114_DATA_COMMON_H_
24 
25 //-----------------------------------------------------------------------------
26 // PART NUMBER AND VERSION INFO
27 //-----------------------------------------------------------------------------
28 #define PART_NUMBER 0x0E // 0x0E = 14, i.e. CP2114
29 
30 // Versioning for CP-2114 Firmware, Device API and Configuration Block format.
31 // These elements are used to verify compatibility between the device and the
32 // Configurator. If API change is significant enough to require the Configurator
33 // to change, the firmware API version and the Configurator API version (the integer
34 // part) must be changed at the same time. Otherwise, Configurator won't connect to
35 // the device.
36 //
37 // Device FIRMWARE_VERSION DEV_API_VERSION CFG_FMT_VERSION
38 // ----------------------------------------------------------------------------
39 // CP2114-B01-GM 0x07 0x05 0x01
40 // CP2114-B02-GM 0x08 0x06 0x02
41 
42 #define FIRMWARE_VERSION 0x08 // CP2114-B01: 0x07, CP2114-B02: 0x08
43 #define DEV_API_VERSION 0x06 // CP2114-B01: 0x05, CP2114-B02: 0x06
44 #define CFG_FMT_VERSION 0x02 // CP2114-B01: 0x01, CP2114-B02: 0x02
45 //
46 // END OF VERSION INFO
47 //
48 
49 //--------------------------
50 // Locations
51 //--------------------------
52 // Locations must match settings of 'Project -> Toolchain -> Linker cmd line args'
53 #define DEFAULTDATA_ADDRESS 0x6600
54 #define USERDATA_ADDRESS 0x6800
55 
56 #define CUSTOM_DATA_SIZE (6*1024)
57 
58 // Global errors & status
59 // NOTE:Any changes to the following definitions must also be made in the firmware 'CP2114_Common.h' file.
60 
61 // Config errors
62 #define kInvalidConfigNumber 0x20 // Requested config number >= MAX_CONFIGS
63 #define kBootIndicesDepleted 0x21 // All Dev boot indexes have been used
64 #define kRequestedConfigNotPresent 0x22 // Pointer to requested Dev config is 0xFFFF
65 #define kRequestedConfigInvalid 0x23 // Config is invalid or not supported
66 #define kConfigPointersDepleted 0x24 // All Config pointer slots have been used
67 #define kConfigSpaceDepleted 0x25 // Not enough space to save the new config
68 #define kBootIndexUnchanged 0x26 // The user-specified boot index is already the current boot index
69 #define kConfigUnchanged 0x27 // The Config is already as the user requested
70 #define kConfigInvalidConfigIdentifier 0x28 // Identifier was not INBAND_IDENTIFIER_INIT/SUSPEND/ACTIVE
71 #define kConfigSettingsInvalid 0x29 // Configuration contains invalid setting(s)
72 #define kUnsupportedConfigFormat 0x2A // The config format version is not supported by library/firmware
73 
74 // 'Set Parameters for Next Get' errors
75 #define kInvalidNumberOfCachedParams 0x40 // Specified tSetParamsForNextGet.params > MAX_CACHED_PARAMS
76 #define kUnexpectedCacheData 0x41 // Something in tSetParamsForNextGet was not as expected
77 
78 // I2C errors
79 #define kI2cBusy 0x50 // Busy error code
80 #define kI2cTimeout 0x51 // Time out error code
81 #define kI2cInvalidToken 0x52 // Invalid token error code
82 #define kI2cInvalidWriteLength 0x53 // Invalid write length error code
83 #define kI2cInvalidConfigLength 0x54 // Invalid config length error code
84 #define kI2cSclStuckLow 0x55 // SCL stuck low error code
85 #define kI2cSdaStuckLow 0x56 // SDA stuck low error code
86 
87 //-------------------------------------------------------
90 //-------------------------------------------------------
91 typedef struct
92 {
99 
100 #define SIZE_DEVICE_CAPS (sizeof(tDeviceCaps)) // Size device Capabilities
101 
103 #define CP2114_CONFIG_VERSION_B01 1 // CP2114 config version B01
104 #define CP2114_CONFIG_VERSION_B02 2// CP2114 config version B02
105 
106 // NOTE: The firmware and this library code assumes that RAMConfig fits in
107 // one packet. Since byte[0] is the report ID, the maximum RAMConfig size
108 // (not including the 2-byte length) is 61 bytes.
109 #define MAX_RAM_CONFIG_SIZE (2 + 61)
110 #define RAM_CONFIG_SIZE_B01 30
111 #define RAM_CONFIG_SIZE_B02 50
112 
113 struct _RAM_CONFIG_STRUCT
116 {
118  U8 configData[MAX_RAM_CONFIG_SIZE];
119 };
120 
121 // Configuration Report ID's
122 
123 #define RESET_DEVICE 0x40 // Reset Device
124 #define GETSET_UART_ENABLE 0x41 // Get Set Receive Status
125 #define GET_UART_STATUS 0x42 // Get UART Status
126 #define PURGE_FIFOS 0x43 // Purge FIFOs
127 #define GET_GPIO_VALUES 0x44 // Get GPIO Values
128 #define SET_GPIO_VALUES 0x45 // Set GPIO Values
129 #define GET_VER_INFO 0x46 // Get Version Information
130 #define GETSET_LOCK_BYTE 0x47 // Get Set Lock Byte
131 
132 #define GETSET_UART_CONFIG 0x50 // Get Set UART Config
133 #define TRANS_LINE_BREAK 0x51 // Transmit Line Break
134 #define STOP_LINE_BREAK 0x52 // Stop Line Break
135 
136 #define GETSET_USB_CONFIG 0x60 // All customizable data that's not strings
137 #define GETSET_MANU1 0x61 // Get Set Manufacturing String 1
138 #define GETSET_MANU2 0x62 // Get Set Manufacturing String 2
139 #define GETSET_PROD1 0x63 // Get Set Product String 1
140 #define GETSET_PROD2 0x64 // Get Set Product String 2
141 #define GETSET_SERSTR 0x65 // Get Set Serial String
142 #define GETSET_PIN_CONFIG 0x66 // GPIO configuration
143 
144 // 2114 Specific commands Parameter Description
145 #define GET_DEVICE_STATUS 0x70 // none 1 byte sticky status, cleared in firmware on a read
146 #define GET_DEVICE_CAPS 0x71 // none Gets CP2114 capabilities
147 #define GET_RAM_CONFIG 0x72 // none Get current CP2114 Config from RAM
148 #define SET_RAM_CONFIG 0x73 // config till DAC pairs Set CP2114 Configuration to RAM
149 #define SET_DAC_REGISTERS 0x74 // register values Set DAC Config
150 #define GET_DAC_REGISTERS 0x75 // register addr/count Get DAC registers
151 #define GET_OTP_CONFIG 0x76 // index Return CP2114 OTP Config based on the current index
152 #define GET_DEVICE_VERSIONS 0x77 // none Return API version and firmware version
153 #define CREATE_OTP_CONFIG 0x78 // config block Create New Configuration Block for CP2114
154 #define SET_BOOT_CONFIG 0x79 // index Set CP2114 Boot Configuration
155 #define SET_PARAMS_FOR_NEXT_GET 0x7A // Parameters to be used for subsequent Get
156 #define GET_OTP_ALLCONFIG 0x7B // Get OTP all configuration
157 #define SET_OTP_ALLCONFIG 0x7C // Set OTP all configuration
158 #define I2C_WRITE_DATA 0x7D // SLA,nWrite,data I2C Write operation
159 #define I2C_READ_DATA 0x7E // (Sent in Params block) I2C Read operation
160 
161 #define BUTTON_EVENT 0x80 // Report button status
162 
163 enum
164 {
165  INBAND_IDENTIFIER_INIT = 0xF9, // Inband identifier init
166  INBAND_IDENTIFIER_SUSPEND = 0xFA, // Inband identifier suspend
167  INBAND_IDENTIFIER_ACTIVE = 0xFB, // Inband identifier active
168  INBAND_COMMAND_START = 0xFC, // Inband command start
169  INBAND_COMMAND_REENUMERATE = INBAND_COMMAND_START, // inband command reenumerate
170  INBAND_COMMAND_DELAY_US = 0xFD, // Inband command delay us
171  INBAND_COMMAND_SET_GPIO = 0xFE, // Inband command set gpio
172  INBAND_COMMAND_DELAY_MS = 0xFF, // Inband command delay ms
173 };
174 
175 #endif // _CP2114_COMMON_H_
176 
177 //-----------------------------------------------------------------------------
178 // End Of File
179 //-----------------------------------------------------------------------------
tbd
Definition: CP2114_Common.h:115
U16 Length
Length.
Definition: CP2114_Common.h:117
U8 availableOtpConfigSpace_LSB
Available otp config space LSB.
Definition: CP2114_Common.h:96
U8 availableBootIndices
Available boot indices.
Definition: CP2114_Common.h:93
U8 currentBootConfig
Current boot config.
Definition: CP2114_Common.h:95
U8 configData[(2+61)]
Config data.
Definition: CP2114_Common.h:118
unsigned char U8
unsigned uint 8
Definition: SLABHIDtoUART.h:348
U8 availableOtpConfigSpace_MSB
Available otp config space MSB.
Definition: CP2114_Common.h:97
unsigned short U16
unsigned uint 16
Definition: SLABHIDtoUART.h:351
U8 availableOtpConfigs
Available OTP config.
Definition: CP2114_Common.h:94
CP2114 Capabilities.
Definition: CP2114_Common.h:91