-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm24256.h
140 lines (117 loc) · 3.54 KB
/
m24256.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
/**
******************************************************************************
* @file m24256.h
* @author MCD Application Team
* @brief This file is the header of m24256.c
******************************************************************************
* @attention
*
* Copyright (c) 2023 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 M24256_H
#define M24256_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stddef.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup M24256
* @{
*/
/** @defgroup M24256_Exported_Types M24256 Exported Types
* @{
*/
typedef int32_t (*M24256_Init_Func)(void);
typedef int32_t (*M24256_DeInit_Func)(void);
typedef int32_t (*M24256_GetTick_Func)(void);
typedef int32_t (*M24256_Delay_Func)(uint32_t);
typedef int32_t (*M24256_WriteReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*M24256_ReadReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*M24256_IsDeviceReady_Func)(uint16_t, uint32_t);
typedef int32_t (*M24256_Write_Func)(const void *, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*M24256_Read_Func)(const void *, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*M24256_IsReady_Func)(const void *, uint32_t);
typedef struct
{
M24256_Write_Func Write;
M24256_Read_Func Read;
M24256_IsReady_Func IsReady;
void *handle;
} M24256_Ctx_t;
typedef struct
{
M24256_Init_Func Init;
M24256_DeInit_Func DeInit;
uint16_t Address;
M24256_WriteReg_Func Write;
M24256_ReadReg_Func Read;
M24256_IsDeviceReady_Func IsReady;
M24256_GetTick_Func GetTick;
} M24256_IO_t;
typedef struct
{
M24256_IO_t IO;
M24256_Ctx_t Ctx;
uint8_t IsInitialized;
} M24256_Object_t;
typedef struct
{
int32_t (*Init)(M24256_Object_t *);
int32_t (*DeInit)(M24256_Object_t *);
int32_t (*Write)(const M24256_Object_t *, uint16_t, uint8_t *, uint16_t);
int32_t (*Read)(const M24256_Object_t *, uint16_t, uint8_t *, uint16_t);
int32_t (*IsReady)(const M24256_Object_t *, uint32_t);
} M24256_EEPROM_Drv_t;
/**
* @}
*/
/** @defgroup M24256_Exported_Constants M24256 Exported Constants
* @{
*/
#define M24256_OK 0
#define M24256_ERROR -1
/**
* @}
*/
/** @defgroup M24256_Exported_FunctionsPrototypes M24256 Exported FunctionsPrototypes
* @{
*/
/* public function --------------------------------------------------------------------------*/
int32_t M24256_RegisterBusIO(M24256_Object_t *pObj, M24256_IO_t *pIO);
int32_t M24256_Init(M24256_Object_t *pObj);
int32_t M24256_DeInit(M24256_Object_t *pObj);
int32_t M24256_Write(const M24256_Object_t *pObj, uint16_t Addr, uint8_t *pData, uint16_t Length);
int32_t M24256_Read(const M24256_Object_t *pObj, uint16_t Addr, uint8_t *pData, uint16_t Length);
int32_t M24256_IsReady(const M24256_Object_t *pObj, uint32_t Trials);
extern M24256_EEPROM_Drv_t M24256_EEPROM_Driver;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* M24256_H */