-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbpd-tcpp0203_bus.h
128 lines (107 loc) · 3.13 KB
/
usbpd-tcpp0203_bus.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
/**
******************************************************************************
* @file usbpd-tcpp0203_bus.h
* @author MCD Application Team
* @brief This file contains definitions for BUS hardware resources.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef USBPD_TCPP0203_BUS_H
#define USBPD_TCPP0203_BUS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbpd-tcpp0203_conf.h"
#if defined(USE_STM32G4XX_NUCLEO)
#include "stm32g4xx_nucleo_conf.h"
#include "stm32g4xx_nucleo_errno.h"
#elif defined(USE_STM32G0XX_NUCLEO)
/* STM32G0 series using BSP V1 framework, no conf template file, no error definitions, ... */
#include "stm32g0xx_nucleo.h"
#include "usbpd-tcpp0203_errno.h"
#else
#warning "Please select include files according to HW setup"
#endif /* USE_STM32G4XX_NUCLEO */
/** @addtogroup BSP
* @{
*/
/** @addtogroup USBPD-TCPP0203
* @{
*/
/** @addtogroup USBPD-TCPP0203_BUS
* @{
*/
/** @defgroup USBPD-TCPP0203_BUS_Exported_Constants Exported Constants
* @{
*/
/* Additional error codes */
/* BSP BUS error codes */
#define BSP_ERROR_BUS_TRANSACTION_FAILURE -100
#define BSP_ERROR_BUS_ARBITRATION_LOSS -101
#define BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE -102
#define BSP_ERROR_BUS_PROTOCOL_FAILURE -103
/**
* @}
*/
/** @defgroup USBPD-TCPP0203_BUS_Private_Types Private Types
* @{
*/
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
typedef struct
{
pI2C_CallbackTypeDef pMspInitCb;
pI2C_CallbackTypeDef pMspDeInitCb;
} BSP_I2C_Cb_t;
#endif /* (USE_HAL_I2C_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @addtogroup USBPD-TCPP0203_BUS_Exported_Variables
* @{
*/
/**
* @}
*/
/** @defgroup USBPD-TCPP0203_BUS_Exported_Functions Exported Functions
* @{
*/
HAL_StatusTypeDef MX_I2C_Init(void);
int32_t BSP_I2C_Init(void);
int32_t BSP_I2C_DeInit(void);
int32_t BSP_I2C_WriteReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
int32_t BSP_I2C_ReadReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
int32_t BSP_I2C_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
int32_t BSP_I2C_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
int32_t BSP_I2C_IsReady(uint16_t DevAddr, uint32_t Trials);
int32_t BSP_GetTick(void);
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
int32_t BSP_I2C_RegisterDefaultMspCallbacks(void);
int32_t BSP_I2C_RegisterMspCallbacks(BSP_I2C_Cb_t *Callback);
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* USBPD_TCPP0203_BUS_H */