Logo
MSP PMBus Library API Guide  v1.00.00.00
pmbus.h
1 #ifndef __PMBUS_H__
2 #define __PMBUS_H__
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 //
23 // Include files
24 //
25 #include <stdlib.h>
26 #include <stdint.h>
27 #include <stdbool.h>
28 #include <smbus.h>
29 
30 // The PMBus commands below are are supported by the PMBus_cmdRead and
31 // PMBus_cmdWrite APIs.
32 //
33 // The PMBus commands which are not listed below are manufacturer-specific, or
34 // have variable data packets.
35 //
36 // Use the appropriate lower level API.(i.e. PM PMBus_cmdSendByte,
37 // PMBus_cmdWriteByte, PMBus_cmdWriteWord, PMBus_cmdBlockWrite
38 // PMBus_cmdReadByte, PMBus_cmdReadWord, PMBus_cmdBlockRead,
39 // PMBus_cmdBlockWriteBlockReadProcessCall for these commands.
40 //
41 // Some information about these commands is in the comment section of pmbus.h.
42 // For more details on exact usage of the manufacture-specific commands, see
43 // the device documentation and the PMBus specification.
44 #define PMB_PAGE 0x00
45 #define PMB_OPERATION 0x01
46 #define PMB_ON_OFF_CONFIG 0x02
47 #define PMB_CLEAR_FAULTS 0x03
48 #define PMB_PHASE 0x04
49 #define PMB_PAGE_PLUS_WRITE 0x05
50 #define PMB_ZONE_ACTIVE 0x08
51 #define PMB_WRITE_PROTECT 0x10
52 #define PMB_STORE_DEFAULT_ALL 0x11
53 #define PMB_RESTORE_DEFAULT_ALL 0x12
54 #define PMB_STORE_DEFAULT_CODE 0x13
55 #define PMB_RESTORE_DEFAULT_CODE 0x14
56 #define PMB_STORE_USER_ALL 0x15
57 #define PMB_RESTORE_USER_ALL 0x16
58 #define PMB_STORE_USER_CODE 0x17
59 #define PMB_RESTORE_USER_CODE 0x18
60 #define PMB_CAPABILITY 0x19
61 #define PMB_VOUT_MODE 0x20
62 #define PMB_VOUT_COMMAND 0x21
63 #define PMB_VOUT_TRIM 0x22
64 #define PMB_VOUT_CAL_OFFSET 0x23
65 #define PMB_VOUT_MAX 0x24
66 #define PMB_VOUT_MARGIN_HIGH 0x25
67 #define PMB_VOUT_MARGIN_LOW 0x26
68 #define PMB_VOUT_TRANSITION_RATE 0x27
69 #define PMB_VOUT_DROOP 0x28
70 #define PMB_VOUT_SCALE_LOOP 0x29
71 #define PMB_VOUT_SCALE_MONITOR 0x2A
72 #define PMB_VOUT_MIN 0x2B
73 #define PMB_POUT_MAX 0x31
74 #define PMB_MAX_DUTY 0x32
75 #define PMB_FREQUENCY_SWITCH 0x33
76 #define PMB_POWER_MODE 0x34
77 #define PMB_VIN_ON 0x35
78 #define PMB_VIN_OFF 0x36
79 #define PMB_INTERLEAVE 0x37
80 #define PMB_IOUT_CAL_GAIN 0x38
81 #define PMB_IOUT_CAL_OFFSET 0x39
82 #define PMB_FAN_CONFIG_1_2 0x3A
83 #define PMB_FAN_COMMAND_1 0x3B
84 #define PMB_FAN_COMMAND_2 0x3C
85 #define PMB_FAN_CONFIG_3_4 0x3D
86 #define PMB_FAN_COMMAND_3 0x3E
87 #define PMB_FAN_COMMAND_4 0x3F
88 #define PMB_VOUT_OV_FAULT_LIMIT 0x40
89 #define PMB_VOUT_OV_FAULT_RESPONSE 0x41
90 #define PMB_VOUT_OV_WARN_LIMIT 0x42
91 #define PMB_VOUT_UV_WARN_LIMIT 0x43
92 #define PMB_VOUT_UV_FAULT_LIMIT 0x44
93 #define PMB_VOUT_UV_FAULT_RESPONSE 0x45
94 #define PMB_IOUT_OC_FAULT_LIMIT 0x46
95 #define PMB_IOUT_OC_FAULT_RESPONSE 0x47
96 #define PMB_IOUT_OC_LV_FAULT_LIMIT 0x48
97 #define PMB_IOUT_OC_LV_FAULT_RESPONSE 0x49
98 #define PMB_IOUT_OC_WARN_LIMIT 0x4A
99 #define PMB_IOUT_UC_FAULT_LIMIT 0x4B
100 #define PMB_IOUT_UC_FAULT_RESPONSE 0x4C
101 #define PMB_OT_FAULT_LIMIT 0x4F
102 #define PMB_OT_FAULT_RESPONSE 0x50
103 #define PMB_OT_WARN_LIMIT 0x51
104 #define PMB_UT_WARN_LIMIT 0x52
105 #define PMB_UT_FAULT_LIMIT 0x53
106 #define PMB_UT_FAULT_RESPONSE 0x54
107 #define PMB_VIN_OV_FAULT_LIMIT 0x55
108 #define PMB_VIN_OV_FAULT_RESPONSE 0x56
109 #define PMB_VIN_OV_WARN_LIMIT 0x57
110 #define PMB_VIN_UV_WARN_LIMIT 0x58
111 #define PMB_VIN_UV_FAULT_LIMIT 0x59
112 #define PMB_VIN_UV_FAULT_RESPONSE 0x5A
113 #define PMB_IIN_OC_FAULT_LIMIT 0x5B
114 #define PMB_IIN_OC_FAULT_RESPONSE 0x5C
115 #define PMB_IIN_OC_WARN_LIMIT 0x5D
116 #define PMB_POWER_GOOD_ON 0x5E
117 #define PMB_POWER_GOOD_OFF 0x5F
118 #define PMB_TON_DELAY 0x60
119 #define PMB_TON_RISE 0x61
120 #define PMB_TON_MAX_FAULT_LIMIT 0x62
121 #define PMB_TON_MAX_FAULT_RESPONSE 0x63
122 #define PMB_TOFF_DELAY 0x64
123 #define PMB_TOFF_FALL 0x65
124 #define PMB_TOFF_MAX_WARN_LIMIT 0x66
125 #define PMB_POUT_OP_FAULT_LIMIT 0x68
126 #define PMB_POUT_OP_FAULT_RESPONSE 0x69
127 #define PMB_POUT_OP_WARN_LIMIT 0x6A
128 #define PMB_PIN_OP_WARN_LIMIT 0x6B
129 #define PMB_STATUS_BYTE 0x78
130 #define PMB_STATUS_WORD 0x79
131 #define PMB_STATUS_VOUT 0x7A
132 #define PMB_STATUS_IOUT 0x7B
133 #define PMB_STATUS_INPUT 0x7C
134 #define PMB_STATUS_TEMPERATURE 0x7D
135 #define PMB_STATUS_CML 0x7E
136 #define PMB_STATUS_OTHER 0x7F
137 #define PMB_STATUS_MFR_SPECIFIC 0x80
138 #define PMB_STATUS_FANS_1_2 0x81
139 #define PMB_STATUS_FANS_3_4 0x82
140 #define PMB_READ_KWH_CONFIG 0x85
141 #define PMB_READ_EIN 0x86
142 #define PMB_READ_EOUT 0x87
143 #define PMB_READ_VIN 0x88
144 #define PMB_READ_IIN 0x89
145 #define PMB_READ_VCAP 0x8A
146 #define PMB_READ_VOUT 0x8B
147 #define PMB_READ_IOUT 0x8C
148 #define PMB_READ_TEMPERATURE_1 0x8D
149 #define PMB_READ_TEMPERATURE_2 0x8E
150 #define PMB_READ_TEMPERATURE_3 0x8F
151 #define PMB_READ_FAN_SPEED_1 0x90
152 #define PMB_READ_FAN_SPEED_2 0x91
153 #define PMB_READ_FAN_SPEED_3 0x92
154 #define PMB_READ_FAN_SPEED_4 0x93
155 #define PMB_READ_DUTY_CYCLE 0x94
156 #define PMB_READ_FREQUENCY 0x95
157 #define PMB_READ_POUT 0x96
158 #define PMB_READ_PIN 0x97
159 #define PMB_PMBUS_REVISION 0x98
160 #define PMB_MFR_ID 0x99
161 #define PMB_MFR_MODEL 0x9A
162 #define PMB_MFR_REVISION 0x9B
163 #define PMB_MFR_LOCATION 0x9C
164 #define PMB_MFR_DATE 0x9D
165 #define PMB_MFR_SERIAL 0x9E
166 #define PMB_APP_PROFILE_SUPPORT 0x9F
167 #define PMB_MFR_VIN_MIN 0xA0
168 #define PMB_MFR_VIN_MAX 0xA1
169 #define PMB_MFR_IIN_MAX 0xA2
170 #define PMB_MFR_PIN_MAX 0xA3
171 #define PMB_MFR_VOUT_MIN 0xA4
172 #define PMB_MFR_VOUT_MAX 0xA5
173 #define PMB_MFR_IOUT_MAX 0xA6
174 #define PMB_MFR_POUT_MAX 0xA7
175 #define PMB_MFR_TAMBIENT_MAX 0xA8
176 #define PMB_MFR_TAMBIENT_MIN 0xA9
177 #define PMB_MFR_EFFICIENCY_LL 0xAA
178 #define PMB_MFR_EFFICIENCY_HL 0xAB
179 #define PMB_MFR_PIN_ACCURACY 0xAC
180 #define PMB_IC_DEVICE_ID 0xAD
181 #define PMB_IC_DEVICE_REV 0xAE
182 #define PMB_USER_DATA_00 0xB0
183 #define PMB_USER_DATA_01 0xB1
184 #define PMB_USER_DATA_02 0xB2
185 #define PMB_USER_DATA_03 0xB3
186 #define PMB_USER_DATA_04 0xB4
187 #define PMB_USER_DATA_05 0xB5
188 #define PMB_USER_DATA_06 0xB6
189 #define PMB_USER_DATA_07 0xB7
190 #define PMB_USER_DATA_08 0xB8
191 #define PMB_USER_DATA_09 0xB9
192 #define PMB_USER_DATA_10 0xBA
193 #define PMB_USER_DATA_11 0xBB
194 #define PMB_USER_DATA_12 0xBC
195 #define PMB_USER_DATA_13 0xBD
196 #define PMB_USER_DATA_14 0xBE
197 #define PMB_USER_DATA_15 0xBF
198 #define PMB_MFR_MAX_TEMP_1 0xC0
199 #define PMB_MFR_MAX_TEMP_2 0xC1
200 #define PMB_MFR_MAX_TEMP_3 0xC2
201 
202 //*****************************************************************************
203 //
205 //
206 //*****************************************************************************
207 #define PMBUS_RET_OK (1)
208 
209 //*****************************************************************************
210 //
212 //
213 //*****************************************************************************
214 #define PMBUS_RET_ERROR (-1)
215 
216 //*****************************************************************************
217 //
219 //
220 //*****************************************************************************
221 #define PMB_MAX_PACKET_SIZE SMB_MAX_PACKET_SIZE
222 
223 //*****************************************************************************
224 //
226 //
227 //*****************************************************************************
228 #define PMBUS_ARA (0x0C)
229 
230 //*****************************************************************************
231 //
233 //
237 //
238 // \return None
239 //
240 //*****************************************************************************
241 extern void PMBus_init(uint16_t i2cAddr,
242  uint32_t busClk);
243 
244 //*****************************************************************************
245 //
247 //
250 //
252 //
253 //*****************************************************************************
254 extern void PMBus_processInt();
255 
256 #ifdef __MSP430_HAS_USCI__
257 //*****************************************************************************
258 //
260 //
263 //
265 //
266 //*****************************************************************************
267 extern void PMBus_processTimeoutInt();
268 #endif
269 
270 #if (SMB_PEC_SUPPORTED == 1)
271 //*****************************************************************************
272 //
274 //
276 //
277 //*****************************************************************************
278 extern void PMBus_enablePEC();
279 
280 //*****************************************************************************
281 //
283 //
285 //
286 //*****************************************************************************
287 extern void PMBus_disablePEC();
288 #endif
289 
290 //*****************************************************************************
291 //
293 //
299 //
301 //
302 //*****************************************************************************
303 extern int8_t PMBus_cmdRead(uint8_t slaveAddress,
304  uint8_t commandId,
305  uint8_t* rxData,
306  uint8_t* rxSize,
307  uint32_t timeout);
308 
309 //*****************************************************************************
310 //
312 //
318 //
320 //
321 //*****************************************************************************
322 extern int8_t PMBus_cmdWrite(uint8_t slaveAddress,
323  uint8_t commandId,
324  uint8_t* txData,
325  uint8_t txSize,
326  uint32_t timeout);
327 
328 //*****************************************************************************
329 //
331 //
335 //
337 //
338 //*****************************************************************************
339 extern int8_t PMBus_cmdSendByte(uint8_t slaveAddress,
340  uint8_t txData,
341  uint32_t timeout);
342 
343 //*****************************************************************************
344 //
346 //
351 //
353 //
354 //*****************************************************************************
355 extern int8_t PMBus_cmdWriteByte(uint8_t slaveAddress,
356  uint8_t commandId,
357  uint8_t* txData,
358  uint32_t timeout);
359 
360 //*****************************************************************************
361 //
363 //
368 //
370 //
371 //*****************************************************************************
372 extern int8_t PMBus_cmdWriteWord(uint8_t slaveAddress,
373  uint8_t commandId,
374  uint8_t* txData,
375  uint32_t timeout);
376 
377 //*****************************************************************************
378 //
380 //
386 //
388 //
389 //*****************************************************************************
390 extern int8_t PMBus_cmdBlockWrite(uint8_t slaveAddress,
391  uint8_t commandId,
392  uint8_t* txData,
393  uint8_t txSize,
394  uint32_t timeout);
395 
396 //*****************************************************************************
397 //
399 //
403 //
405 //
406 //*****************************************************************************
407 extern int8_t PMBus_cmdReceiveByte(uint8_t slaveAddress,
408  uint8_t* rxData,
409  uint32_t timeout);
410 
411 //*****************************************************************************
412 //
414 //
419 //
421 //
422 //*****************************************************************************
423 extern int8_t PMBus_cmdReadByte(uint8_t slaveAddress,
424  uint8_t commandId,
425  uint8_t* rxData,
426  uint32_t timeout);
427 
428 //*****************************************************************************
429 //
431 //
436 //
438 //
439 //*****************************************************************************
440 extern int8_t PMBus_cmdReadWord(uint8_t slaveAddress,
441  uint8_t commandId,
442  uint8_t* rxData,
443  uint32_t timeout);
444 
445 //*****************************************************************************
446 //
448 //
454 //
456 //
457 //*****************************************************************************
458 extern int8_t PMBus_cmdBlockRead(uint8_t slaveAddress,
459  uint8_t commandId,
460  uint8_t* rxData,
461  uint8_t* rxSize,
462  uint32_t timeout);
463 
464 //*****************************************************************************
465 //
467 //
473 //
475 //
476 //*****************************************************************************
477 extern int8_t PMBus_cmdProcessCall(uint8_t slaveAddress,
478  uint8_t commandByte,
479  uint8_t* txData,
480  uint8_t* rxData,
481  uint32_t timeout);
482 
483 //*****************************************************************************
484 //
486 //
494 //
496 //
497 //*****************************************************************************
498 extern int8_t PMBus_cmdBlockWriteBlockReadProcessCall(uint8_t slaveAddress,
499  uint8_t commandId,
500  uint8_t* txData,
501  uint8_t txSize,
502  uint8_t* rxData,
503  uint8_t* rxSize,
504  uint32_t timeout);
505 
506 //*****************************************************************************
507 //
509 //
512 //
514 //
515 //*****************************************************************************
516 extern int8_t PMBus_ReceiveByteARA(uint8_t *rxData,
517  uint32_t timeout);
518 
519 //*****************************************************************************
520 //
521 // Mark the end of the C bindings section for C++ compilers.
522 //
523 //*****************************************************************************
524 #ifdef __cplusplus
525 }
526 #endif
527 
528 //*****************************************************************************
529 //
530 // Close the Doxygen group.
532 //
533 //*****************************************************************************
534 
535 #endif //__PMBUS_H__
int8_t PMBus_cmdWriteWord(uint8_t slaveAddress, uint8_t commandId, uint8_t *txData, uint32_t timeout)
Writes a word to the PMBus slave.
Definition: pmbus.c:414
void PMBus_processInt()
I2C Interrupt Service routine.
Definition: pmbus.c:234
int8_t PMBus_cmdRead(uint8_t slaveAddress, uint8_t commandId, uint8_t *rxData, uint8_t *rxSize, uint32_t timeout)
Perform a PMBus read for the given PMBus command id.
Definition: pmbus.c:261
int8_t PMBus_cmdReceiveByte(uint8_t slaveAddress, uint8_t *rxData, uint32_t timeout)
Receives a data byte from the PMBus slave.
Definition: pmbus.c:463
int8_t PMBus_cmdBlockWriteBlockReadProcessCall(uint8_t slaveAddress, uint8_t commandId, uint8_t *txData, uint8_t txSize, uint8_t *rxData, uint8_t *rxSize, uint32_t timeout)
Sends a Block-Write, Block-Read, Process Call to the PMBus slave.
Definition: pmbus.c:608
int8_t PMBus_cmdSendByte(uint8_t slaveAddress, uint8_t txData, uint32_t timeout)
Sends byte to the PMBus slave.
Definition: pmbus.c:369
int8_t PMBus_cmdWriteByte(uint8_t slaveAddress, uint8_t commandId, uint8_t *txData, uint32_t timeout)
Writes a data byte to the PMBus slave.
Definition: pmbus.c:390
int8_t PMBus_cmdReadByte(uint8_t slaveAddress, uint8_t commandId, uint8_t *rxData, uint32_t timeout)
Reads a data byte from the PMBus slave.
Definition: pmbus.c:490
int8_t PMBus_cmdBlockRead(uint8_t slaveAddress, uint8_t commandId, uint8_t *rxData, uint8_t *rxSize, uint32_t timeout)
Reads a block of data from the PMBus slave.
Definition: pmbus.c:550
void PMBus_init(uint16_t i2cAddr, uint32_t busClk)
Initialize the PMBus Interface.
Definition: pmbus.c:225
int8_t PMBus_cmdBlockWrite(uint8_t slaveAddress, uint8_t commandId, uint8_t *txData, uint8_t txSize, uint32_t timeout)
Writes a data block the PMBus slave.
Definition: pmbus.c:438
int8_t PMBus_cmdReadWord(uint8_t slaveAddress, uint8_t commandId, uint8_t *rxData, uint32_t timeout)
Reads a data word from the PMBus slave.
Definition: pmbus.c:520
int8_t PMBus_ReceiveByteARA(uint8_t *rxData, uint32_t timeout)
Sends a Receive Byte to Alert Response Address to request.
Definition: pmbus.c:639
int8_t PMBus_cmdWrite(uint8_t slaveAddress, uint8_t commandId, uint8_t *txData, uint8_t txSize, uint32_t timeout)
Perform a PMBus write for the given PMBus command id.
Definition: pmbus.c:307
int8_t PMBus_cmdProcessCall(uint8_t slaveAddress, uint8_t commandByte, uint8_t *txData, uint8_t *rxData, uint32_t timeout)
Sends a Process call command to the PMBus slave.
Definition: pmbus.c:577