-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbpd_ucsi.h
920 lines (821 loc) · 27 KB
/
usbpd_ucsi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
/**
******************************************************************************
* @file usbpd_ucsi.h
* @author MCD Application Team
* @brief Header file of UCSI driver
******************************************************************************
* @attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
This software comes from https://github.com/microsoft/Windows-driver-samples.
Original file is under MS-PL License.
A complete copy of this license can be found alongside this file.
--
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
Ucsi.h
Abstract:
UCSI specification structure definitions.
UCSI version 1.0
Environment:
Kernel-mode and user-mode.
--
*/
#ifndef __USBPD_UCSI_H
#define __USBPD_UCSI_H
#ifdef __cplusplus
extern "C" {
#endif
/* GNU Compiler */
#if defined(__GNUC__)
/* ARM Compiler */
#elif defined(__CC_ARM)
#pragma anon_unions
/* IAR Compiler */
#elif defined (__ICCARM__)
#endif /* __GNUC__ */
/* Includes ------------------------------------------------------------------*/
#include "usbpd_def.h"
#include <stdint.h>
#include "cmsis_compiler.h"
/** @addtogroup STM32_USBPD_LIBRARY
* @{
*/
/** @addtogroup USBPD_CORE
* @{
*/
/** @addtogroup USBPD_CORE_UCSI
* @{
*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define UCSI_MAX_DATA_LENGTH 0x10U
#define UCSI_MAX_NUM_ALT_MODE 0x80U
#define UCSI_MIN_TIME_TO_RESPOND_WITH_BUSY 0x0AU
#define UCSI_GET_ERROR_STATUS_DATA_LENGTH 0x10U
#define UCSI_MAX_NUM_PDOS 0x32U /* Table 6-32 Counter parameters PD 3.1 V1.3 */
#define UCSI_MASK_UCSI_COMMAND 0xFFU /* Mask used to pass UCSI command to */
/* Exported typedef ----------------------------------------------------------*/
/** @defgroup USBPD_UCSI_exported_TypeDef USBPD_UCSI exported Typedef
* @{
*/
/**
* @brief List the USBPD UCSI function status.
* list of the returned status value, any negative value is corresponding to an error.
*/
typedef enum
{
USBPD_UCSI_OK = 0U, /*!< Operation terminated successfully. */
USBPD_UCSI_ERROR = 1U /*!< Operation terminated failed. */
} USBPD_UCSI_Status_t;
/**
* @brief Advanced trace driver definition
*/
typedef struct
{
USBPD_UCSI_Status_t (* Init)(void (*ReceiveCommandCb)(uint8_t, uint8_t *)); /*!< Media initialization. */
void (* AlertON)(void); /*!< Media alert ON */
void (* AlertOFF)(void); /*!< Media alert OFF */
} USBPD_UCSI_Driver_t;
typedef enum
{
/* Use for messages between OPM -> PPM*/
UcsiCommandUnkown = 0x00U,
UcsiCommandPpmReset = 0x01U,
UcsiCommandCancel = 0x02U,
UcsiCommandConnectorReset = 0x03U,
UcsiCommandAckCcCi = 0x04U,
UcsiCommandSetNotificationEnable = 0x05U,
UcsiCommandGetCapability = 0x06U,
UcsiCommandGetConnectorCapability = 0x07U,
UcsiCommandSetCCom = 0x08U, /* Optional */
UcsiCommandSetUor = 0x09U,
UcsiCommandSetPdm = 0x0AU, /* Optional - Obsolete from Rev1.2, Jan20 */
UcsiCommandSetPdr = 0x0BU,
UcsiCommandGetAlternateModes = 0x0CU, /* Optional */
UcsiCommandGetCamSupported = 0x0DU, /* Optional */
UcsiCommandGetCurrentCam = 0x0EU, /* Optional */
UcsiCommandSetNewCam = 0x0FU, /* Optional */
UcsiCommandGetPdos = 0x10U, /* Optional */
UcsiCommandGetCableProperty = 0x11U, /* Optional */
UcsiCommandGetConnectorStatus = 0x12U,
UcsiCommandGetErrorStatus = 0x13U,
UcsiCommandSetPowerLevel = 0x14U, /* Optional */
UcsiCommandGetPDMessage = 0x15U, /* Optional */
UcsiCommandMax = (UcsiCommandGetPDMessage + 1U)
} UCSI_COMMAND_t;
typedef enum
{
UcsiRegDataStructureVersion = 0x00U, /* PPM -> OPM */
UcsiRegDataStructureReserved = 0x02U, /* N/A */
UcsiRegDataStructureCci = 0x04U, /* PPM -> OPM */
UcsiRegDataStructureControl = 0x08U, /* OPM -> PPM */
UcsiRegDataStructureMessageIn = 0x10U, /* PPM -> OPM */
UcsiRegDataStructureMessageOut = 0x20U, /* OPM -> PPM */
UcsiRegDataStructureUnkown = (UcsiRegDataStructureMessageOut + 1U)
} UCSI_REG_t;
typedef union
{
uint16_t AsUInt16;
struct
{
uint16_t SubMinorVersion : 4U;
uint16_t MinorVersion : 4U;
uint16_t MajorVersion : 8U;
};
} UCSI_VERSION_t, *PUCSI_VERSION_t;
typedef union
{
uint32_t AsUInt32;
struct
{
uint32_t : 1U;
uint32_t ConnectorChangeIndicator : 7U;
uint32_t DataLength : 8U;
uint32_t : 9U;
uint32_t NotSupportedIndicator : 1U;
uint32_t CancelCompletedIndicator : 1U;
uint32_t ResetCompletedIndicator : 1U;
uint32_t BusyIndicator : 1U;
uint32_t AcknowledgeCommandIndicator : 1U;
uint32_t ErrorIndicator : 1U;
uint32_t CommandCompletedIndicator : 1U;
};
} UCSI_CCI_t, *PUCSI_CCI_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t HardReset : 1U;
uint64_t : 40U;
};
} UCSI_CONNECTOR_RESET_COMMAND_t, *PUCSI_CONNECTOR_RESET_COMMAND_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorChangeAcknowledge : 1U;
uint64_t CommandCompletedAcknowledge : 1U;
uint64_t : 46U;
};
} UCSI_ACK_CC_CI_COMMAND_t, *PUCSI_ACK_CC_CI_COMMAND_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t AckCciStatus : 32U; /* Based on the structure UCSI_CCI_t */
uint64_t : 16U;
};
} UCSI_ACK_CC_CI_STATUS_COMMAND_t, *PUCSI_ACK_CC_CI_STATUS_COMMAND_t;
typedef union
{
uint16_t NotificationEnable;
struct
{
uint16_t CommandComplete : 1U;
uint16_t ExternalSupplyChange : 1U;
uint16_t PowerOperationModeChange : 1U;
uint16_t : 1U;
uint16_t : 1U;
uint16_t SupportedProviderCapabilitiesChange : 1U;
uint16_t NegotiatedPowerLevelChange : 1U;
uint16_t PdResetComplete : 1U;
uint16_t SupportedCamChange : 1U;
uint16_t BatteryChargingStatusChange : 1U;
uint16_t : 1U;
uint16_t ConnectorPartnerChange : 1U;
uint16_t PowerDirectionChange : 1U;
uint16_t : 1U;
uint16_t ConnectChange : 1U;
uint16_t Error : 1U;
};
} UCSI_SET_NOTIFICATION_ENABLE_t, *PUCSI_SET_NOTIFICATION_ENABLE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint8_t Command;
uint8_t DataLength;
UCSI_SET_NOTIFICATION_ENABLE_t Content;
uint32_t : 32U;
};
} UCSI_SET_NOTIFICATION_ENABLE_COMMAND_t, *PUCSI_SET_NOTIFICATION_ENABLE_COMMAND_t;
typedef union
{
uint8_t AsUInt8;
struct
{
uint8_t AcSupply : 1U;
uint8_t : 1U;
uint8_t Other : 1U;
uint8_t : 3U;
uint8_t UsesVBus : 1U;
uint8_t : 1U;
};
} UCSI_BM_POWER_SOURCE_t, *PUCSI_BM_POWER_SOURCE_t;
typedef union
{
uint32_t AsUInt32;
struct
{
uint32_t SetCComSupported : 1U;
uint32_t SetPowerLevelSupported : 1U;
uint32_t AlternateModeDetailsSupported : 1U;
uint32_t AlternateModeOverrideSupported : 1U;
uint32_t PdoDetailsSupported : 1U;
uint32_t CableDetailsSupported : 1U;
uint32_t ExternalSupplyNotificationSupported : 1U;
uint32_t PdResetNotificationSupported : 1U;
uint32_t GetPDMessageSupported : 1U;
uint32_t : 15U;
};
} bmOptionalFeatures_t, *PbmOptionalFeatures_t;
typedef __PACKED_STRUCT
{
__PACKED_UNION
{
uint32_t AsUInt32;
__PACKED_STRUCT
{
uint32_t DisabledStateSupport : 1U;
uint32_t BatteryCharging : 1U;
uint32_t UsbPowerDelivery : 1U;
uint32_t : 3U;
uint32_t UsbTypeCCurrent : 1U;
uint32_t : 1U;
uint32_t bmPowerSource : 8U;
uint32_t : 16U;
};
} bmAttributes;
uint32_t bNumConnectors : 7U;
uint32_t : 1U;
uint32_t OptionalFeatures : 24U;
uint32_t bNumAltModes : 8U;
uint32_t : 8U;
uint32_t bcdBcVersion :16U;
uint32_t bcdPdVersion :16U;
uint32_t bcdUsbTypeCVersion :16U;
} UCSI_GET_CAPABILITY_IN_t, *PUCSI_GET_CAPABILITY_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t : 41U;
};
} UCSI_GET_CONNECTOR_CAPABILITY_COMMAND_t, *PUCSI_GET_CONNECTOR_CAPABILITY_COMMAND_t;
typedef struct
{
union
{
uint8_t AsUInt8;
struct
{
uint8_t RpOnly : 1U;
uint8_t RdOnly : 1U;
uint8_t Drp : 1U;
uint8_t AudioAccessoryMode : 1U;
uint8_t DebugAccessoryMode : 1U;
uint8_t Usb2 : 1U;
uint8_t Usb3 : 1U;
uint8_t AlternateMode : 1U;
};
} OperationMode;
uint8_t Provider : 1U;
uint8_t Consumer : 1U;
uint8_t SwapToDFP : 1U;
uint8_t SwapToUFP : 1U;
uint8_t SwapToSRC : 1U;
uint8_t SwapToSNK : 1U;
uint8_t : 2U;
} UCSI_GET_CONNECTOR_CAPABILITY_IN_t, *PUCSI_GET_CONNECTOR_CAPABILITY_IN_t;
typedef enum
{
UcsiCCOperationModeRpOnly = 0x1U,
UcsiCCOperationModeRdOnly = 0x2U,
UcsiCCOperationModeDrp = 0x4U
} UCSI_CC_OPERATION_MODE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t UsbOperationMode : 3U;
uint64_t : 38U;
};
} UCSI_SET_UOM_COMMAND_t, *PUCSI_SET_UOM_COMMAND_t;
typedef enum
{
UcsiUsbOperationRoleDfp = 0x1U,
UcsiUsbOperationRoleUfp = 0x2U,
UcsiUsbOperationRoleAcceptSwap = 0x4U
} UCSI_USB_OPERATION_ROLE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t UsbOperationRole : 3U;
uint64_t : 38U;
};
} UCSI_SET_UOR_COMMAND_t, *PUCSI_SET_UOR_COMMAND_t;
typedef enum
{
UcsiPowerDirectionModeProvider = 0x1U,
UcsiPowerDirectionModeConsumer = 0x2U,
UcsiPowerDirectionModeEither = 0x4U
} UCSI_POWER_DIRECTION_MODE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t PowerDirectionMode : 3U;
uint64_t : 38U;
};
} UCSI_SET_PDM_COMMAND_t, *PUCSI_SET_PDM_COMMAND_t;
typedef enum
{
UcsiPowerDirectionRoleProvider = 0x1U,
UcsiPowerDirectionRoleConsumer = 0x2U,
UcsiPowerDirectionRoleAcceptSwap = 0x4U
} UCSI_POWER_DIRECTION_ROLE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t PowerDirectionRole : 3U;
uint64_t : 38U;
};
} UCSI_SET_PDR_COMMAND_t, *PUCSI_SET_PDR_COMMAND_t;
typedef enum
{
UcsiGetAlternateModesRecipientConnector = 0U,
UcsiGetAlternateModesRecipientSop = 1U,
UcsiGetAlternateModesRecipientSopP = 2U,
UcsiGetAlternateModesRecipientSopPP = 3U
} UCSI_GET_ALTERNATE_MODES_RECIPIENT_t;
typedef struct
{
uint16_t Recipient : 3U;
uint16_t AlternateModeOffset : 8U;
uint16_t NumberOfAlternateModes : 3U;
uint16_t : 2U;
} UCSI_GET_ALTERNATE_MODES_COMMAND_STRUCT_t, *PUCSI_GET_ALTERNATE_MODES_COMMAND_STRUCT_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t Recipient : 3U;
uint64_t : 5U;
uint64_t ConnectorNumber : 7U;
uint64_t : 1U;
uint64_t AlternateModeOffset : 8U;
uint64_t NumberOfAlternateModes : 2U;
uint64_t : 22U;
};
} UCSI_GET_ALTERNATE_MODES_COMMAND_t, *PUCSI_GET_ALTERNATE_MODES_COMMAND_t;
typedef struct
{
uint16_t Svid;
uint32_t Mode;
} UCSI_ALTERNATE_MODE_t, *PUCSI_ALTERNATE_MODE_t;
typedef struct
{
UCSI_ALTERNATE_MODE_t AlternateModes[2];
} UCSI_GET_ALTERNATE_MODES_IN_t, *PUCSI_GET_ALTERNATE_MODES_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t : 41U;
};
} UCSI_GET_CAM_SUPPORTED_COMMAND_t, *PUCSI_GET_CAM_SUPPORTED_COMMAND_t;
typedef struct
{
uint8_t bmAlternateModeSupported[16];
} UCSI_GET_CAM_SUPPORTED_IN_t, *PUCSI_GET_CAM_SUPPORTED_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t : 41U;
};
} UCSI_GET_CURRENT_CAM_COMMAND_t, *PUCSI_GET_CURRENT_CAM_COMMAND_t;
typedef struct
{
uint8_t CurrentAlternateMode;
} UCSI_GET_CURRENT_CAM_IN_t, *PUCSI_GET_CURRENT_CAM_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t EnterOrExit : 1U;
uint64_t NewCam : 8U;
uint64_t AmSpecific : 32U;
};
} UCSI_SET_NEW_CAM_COMMAND_t, *PUCSI_SET_NEW_CAM_COMMAND_t;
typedef enum
{
UcsiGetPdosTypeSink = 0U,
UcsiGetPdosTypeSource = 1U
} UCSI_GET_PDOS_TYPE_t;
typedef enum
{
UcsiGetPdosCurrentSourceCapabilities = 0U,
UcsiGetPdosAdvertisedSourceCapabilities = 1U,
UcsiGetPdosMaxSourceCapabilities = 2U
} UCSI_GET_PDOS_SOURCE_CAPABILITIES_TYPE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t PartnerPdo : 1U;
uint64_t PdoOffset : 8U;
uint64_t NumberOfPdos : 2U;
UCSI_GET_PDOS_TYPE_t SourceOrSinkPdos : 1U;
UCSI_GET_PDOS_SOURCE_CAPABILITIES_TYPE_t SourceCapabilitiesType : 2U;
uint64_t : 27U;
};
} UCSI_GET_PDOS_COMMAND_t, *PUCSI_GET_PDOS_COMMAND_t;
typedef struct
{
uint32_t Pdos[4];
} UCSI_GET_PDOS_IN_t, *PUCSI_GET_PDOS_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t : 41U;
};
} UCSI_GET_CABLE_PROPERTY_COMMAND_t, *PUCSI_GET_CABLE_PROPERTY_COMMAND_t;
typedef struct
{
union
{
uint16_t AsUInt16;
struct
{
uint16_t SpeedExponent : 2U;
uint16_t Mantissa : 14U;
};
} bmSpeedSupported;
uint8_t bCurrentCapability;
uint16_t VBusInCable : 1U;
uint16_t CableType : 1U;
uint16_t Directionality : 1U;
USBPD_CableToType PlugEndType : 2U;
uint16_t ModeSupport : 1U;
uint16_t : 2U;
USBPD_CableLatency Latency : 4U;
uint16_t : 4U;
} UCSI_GET_CABLE_PROPERTY_IN_t, *PUCSI_GET_CABLE_PROPERTY_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U;
uint64_t : 41U;
};
} UCSI_GET_CONNECTOR_STATUS_COMMAND_t, *PUCSI_GET_CONNECTOR_STATUS_COMMAND_t;
typedef enum
{
UcsiPowerOperationModeNoConsumer = 0U,
UcsiPowerOperationModeDefaultUsb = 1U,
UcsiPowerOperationModeBc = 2U,
UcsiPowerOperationModePd = 3U,
UcsiPowerOperationModeTypeC1500 = 4U,
UcsiPowerOperationModeTypeC3000 = 5U
} UCSI_POWER_OPERATION_MODE_t;
typedef enum
{
UcsiPowerDirectionConsumer = 0U,
UcsiPowerDirectionProvider = 1U
} UCSI_POWER_DIRECTION_t;
typedef enum
{
UcsiConnectorPartnerFlagUsb = 0x1U,
UcsiConnectorPartnerFlagAlternateMode = 0x2U
} UCSI_CONNECTOR_PARTNER_FLAGS_t;
typedef enum
{
UcsiConnectorPartnerUnknown = 0U,
UcsiConnectorPartnerTypeDfp = 1U,
UcsiConnectorPartnerTypeUfp = 2U,
UcsiConnectorPartnerTypePoweredCableNoUfp = 3U,
UcsiConnectorPartnerTypePoweredCableWithUfp = 4U,
UcsiConnectorPartnerTypeDebugAccessory = 5U,
UcsiConnectorPartnerTypeAudioAccessory = 6U
} UCSI_CONNECTOR_PARTNER_TYPE_t;
typedef enum
{
UcsiBatteryChargingNotCharging = 0U,
UcsiBatteryChargingNominal = 1U,
UcsiBatteryChargingSlowCharging = 2U,
UcsiBatteryChargingTrickleCharging = 3U
} UCSI_BATTERY_CHARGING_STATUS_t;
typedef struct
{
union
{
uint16_t AsUInt16;
struct
{
uint16_t : 1U;
uint16_t ExternalSupplyChange : 1U;
uint16_t PowerOperationModeChange : 1U;
uint16_t : 1U;
uint16_t : 1U;
uint16_t SupportedProviderCapabilitiesChange : 1U;
uint16_t NegotiatedPowerLevelChange : 1U;
uint16_t PdResetComplete : 1U;
uint16_t SupportedCamChange : 1U;
uint16_t BatteryChargingStatusChange : 1U;
uint16_t : 1U;
uint16_t ConnectorPartnerChange : 1U;
uint16_t PowerDirectionChange : 1U;
uint16_t : 1U;
uint16_t ConnectChange : 1U;
uint16_t Error : 1U;
};
} ConnectorStatusChange;
UCSI_POWER_OPERATION_MODE_t PowerOperationMode : 3U;
uint16_t ConnectStatus : 1U;
UCSI_POWER_DIRECTION_t PowerDirection : 1U;
uint16_t ConnectorPartnerFlags : 8U;
UCSI_CONNECTOR_PARTNER_TYPE_t ConnectorPartnerType : 3U;
uint32_t RequestDataObject;
union
{
struct
{
UCSI_BATTERY_CHARGING_STATUS_t BatteryChargingStatus : 2U;
uint8_t PowerBudgetLimitedReason : 4U;
uint8_t : 2U;
};
struct
{
uint8_t : 2U;
uint8_t PowerBudgetLowered : 1U;
uint8_t ReachingPowerBudgetLimit : 1U;
uint8_t : 1U;
uint8_t : 1U;
uint8_t : 2U;
} bmPowerBudgetLimitedReason;
};
} UCSI_GET_CONNECTOR_STATUS_IN_t, *PUCSI_GET_CONNECTOR_STATUS_IN_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t : 48U;
};
} UCSI_GET_ERROR_STATUS_COMMAND_t, *PUCSI_GET_ERROR_STATUS_COMMAND_t;
typedef struct
{
union
{
uint16_t AsUInt16;
struct
{
uint16_t UnrecognizedCommandError : 1U;
uint16_t NonExistentConnectorNumberError : 1U;
uint16_t InvalidCommandParametersError : 1U;
uint16_t IncompatibleConnectorPartnerError : 1U;
uint16_t CcCommunicationError : 1U;
uint16_t CommandFailureDueToDeadBattery : 1U;
uint16_t ContractNegotiationFailure : 1U;
uint16_t OverCurrent : 1U;
uint16_t Undefined : 1U;
uint16_t PortPartnerRejectedSwap : 1U;
uint16_t HardReset : 1U;
uint16_t PPM_PolicyConflict : 1U;
uint16_t SwapRejected : 1U;
uint16_t : 3U;
};
} ErrorInformation;
uint8_t VendorDefined[14];
} UCSI_GET_ERROR_STATUS_IN_t, *PUCSI_GET_ERROR_STATUS_IN_t;
/*
* Definition of SET POWER LEVEL COMMAND
*/
typedef enum
{
UcsiTypeCCurrentPPMDefault = 0U, /* PPM Defined default */
UcsiTypeCCurrent3A = 1U, /* 3A */
UcsiTypeCCurrent1P5A = 2U, /* 1.5A */
UcsiTypeCCurrentUSBDefault = 3U /* USB Type-C Default */
} UCSI_TYPEC_CURRENT_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U; /* 0: means max power negotiable by all the connected ports */
uint64_t SourceOrSink : 1U; /* 1: source, 0: Sink */
uint64_t USB_PD_MaxPower : 8U; /* 0.5W unit - 0x00 means max power determined by PPM,
0xFF disable this command */
UCSI_TYPEC_CURRENT_t TypeCCurrent : 2U; /* Maximum current valid if ConnectorNumber != 0 else 0 */
uint64_t : 30U;
};
} UCSI_SET_POWER_LEVEL_COMMAND_t, *PUCSI_SET_POWER_LEVEL_COMMAND_t;
/*
* Definition of GET PD MESSAGE COMMAND
*/
typedef enum
{
UcsiRecipientConnector = 0U, /* Connector */
UcsiRecipientSOP = 1U, /* SOP */
UcsiRecipientSOPPrime = 2U, /* SOP' */
UcsiRecipientSOPSecond = 3U /* SOP'' */
} UCSI_RECIPIENT_t;
typedef enum
{
UcsiRspMsgTypeGetSnkCapaExt = 0U, /* Get Sink Capa extended */
UcsiRspMsgTypeGetSrcCapaExt = 1U, /* Get Source Capa extended */
UcsiRspMsgTypeGetBatteryCapa = 2U, /* Get Battery capa */
UcsiRspMsgTypeGetBatteryStatus = 3U, /* Get Battery Status */
UcsiRspMsgTypeDiscoIdentReq = 4U /* Discovery Identity request */
} UCSI_RSP_MSG_TYPE_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t ConnectorNumber : 7U; /* Set to the connector being queried */
UCSI_RECIPIENT_t Recipient : 3U; /* port partner or cable plus or idenitifed connector */
uint64_t MessageOffset : 8U; /* Starting offset (in bytes) of the message to be returned */
uint64_t NumberOfBytes : 8U; /* Number of bytes to return starting from the offset */
UCSI_RSP_MSG_TYPE_t RspMsgType : 6U; /* Response message Type */
uint16_t : 16U;
};
} UCSI_GET_PD_MESSAGE_COMMAND_t, *PUCSI_GET_PD_MESSAGE_COMMAND_t;
typedef union
{
uint64_t AsUInt64;
struct
{
uint64_t Command : 8U;
uint64_t DataLength : 8U;
uint64_t CommandSpecific : 48U;
};
UCSI_CONNECTOR_RESET_COMMAND_t ConnectorReset;
UCSI_ACK_CC_CI_COMMAND_t AckCcCi;
UCSI_SET_NOTIFICATION_ENABLE_COMMAND_t SetNotificationEnable;
UCSI_GET_CONNECTOR_CAPABILITY_COMMAND_t GetConnectorCapability;
UCSI_SET_UOM_COMMAND_t SetUom;
UCSI_SET_UOR_COMMAND_t SetUor;
UCSI_SET_PDM_COMMAND_t SetPdm;
UCSI_SET_PDR_COMMAND_t SetPdr;
UCSI_GET_ALTERNATE_MODES_COMMAND_t GetAlternateModes;
UCSI_GET_CAM_SUPPORTED_COMMAND_t GetCamSupported;
UCSI_GET_CURRENT_CAM_COMMAND_t GetCurrentCam;
UCSI_SET_NEW_CAM_COMMAND_t SetNewCam;
UCSI_GET_PDOS_COMMAND_t GetPdos;
UCSI_GET_CABLE_PROPERTY_COMMAND_t GetCableProperty;
UCSI_GET_CONNECTOR_STATUS_COMMAND_t GetConnectorStatus;
UCSI_GET_ERROR_STATUS_COMMAND_t GetErrorStatus;
UCSI_ACK_CC_CI_STATUS_COMMAND_t AckCcCiStatus;
UCSI_SET_POWER_LEVEL_COMMAND_t SetPowerLevel;
UCSI_GET_PD_MESSAGE_COMMAND_t GetPDMessage;
} UCSI_CONTROL_t, *PUCSI_CONTROL_t;
typedef union
{
uint8_t AsBuffer[UCSI_MAX_DATA_LENGTH];
UCSI_GET_CAPABILITY_IN_t Capability;
UCSI_GET_CONNECTOR_CAPABILITY_IN_t ConnectorCapability;
UCSI_GET_ALTERNATE_MODES_IN_t AlternateModes;
UCSI_GET_CAM_SUPPORTED_IN_t CamSupported;
UCSI_GET_CURRENT_CAM_IN_t CurrentCam;
UCSI_GET_PDOS_IN_t Pdos;
UCSI_GET_CABLE_PROPERTY_IN_t CableProperty;
UCSI_GET_CONNECTOR_STATUS_IN_t ConnectorStatus;
UCSI_GET_ERROR_STATUS_IN_t ErrorStatus;
} UCSI_MESSAGE_IN_t, *PUCSI_MESSAGE_IN_t;
typedef union
{
uint8_t AsBuffer[UCSI_MAX_DATA_LENGTH];
} UCSI_MESSAGE_OUT_t, *PUCSI_MESSAGE_OUT_t;
typedef struct
{
UCSI_VERSION_t UcsiVersion;
uint16_t : 16U;
UCSI_CCI_t CCI;
UCSI_CONTROL_t Control;
UCSI_GET_CAPABILITY_IN_t Capability;
UCSI_GET_CONNECTOR_CAPABILITY_IN_t ConnectorCapability;
UCSI_GET_ALTERNATE_MODES_IN_t AlternateModes;
UCSI_GET_CAM_SUPPORTED_IN_t CamSupported;
UCSI_GET_CURRENT_CAM_IN_t CurrentCam;
UCSI_GET_PDOS_IN_t Pdos;
UCSI_GET_CABLE_PROPERTY_IN_t CableProperty;
UCSI_GET_CONNECTOR_STATUS_IN_t ConnectorStatus;
UCSI_GET_ERROR_STATUS_IN_t ErrorStatus;
} UCSI_DATA_BLOCK_t, *PUCSI_DATA_BLOCK_t;
/**
* @}
*/
/* External variables --------------------------------------------------------*/
/** @defgroup USBPD_CORE_UCSI_exported_variables USBPD_CORE_UCSI exported variables
*
* @{
*/
/**
* @brief This structure is the linked with the IF layer implementation.
*/
extern const USBPD_UCSI_Driver_t USBPD_UcsiDriver;
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup USBPD_CORE_UCSI_Exported_Functions
* @{
*/
USBPD_StatusTypeDef USBPD_UCSI_Init(void);
void USBPD_UCSI_SendNotification(uint32_t PortNumber);
void USBPD_UCSI_ClearAlert(uint32_t PortNumber);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBPD_UCSI_H */