comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Utilities/STM32_EVAL/STM32L152_EVAL/stm32l152_eval_i2c_ee.h @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /**
2 ******************************************************************************
3 * @file stm32l152_eval_i2c_ee.h
4 * @author MCD Application Team
5 * @version V4.5.0
6 * @date 07-March-2011
7 * @brief This file contains all the functions prototypes for the stm32l152_eval_i2c_ee
8 * firmware driver.
9 ******************************************************************************
10 * @attention
11 *
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 *
19 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
20 ******************************************************************************
21 */
22
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef __STM32L152_EVAL_I2C_EE_H
25 #define __STM32L152_EVAL_I2C_EE_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Includes ------------------------------------------------------------------*/
32 #include "stm32_eval.h"
33
34 /** @addtogroup Utilities
35 * @{
36 */
37
38 /** @addtogroup STM32_EVAL
39 * @{
40 */
41
42 /** @addtogroup STM32L152_EVAL
43 * @{
44 */
45
46 /** @addtogroup STM32L152_EVAL_I2C_EE
47 * @{
48 */
49
50 /** @defgroup STM32L152_EVAL_I2C_EE_Exported_Types
51 * @{
52 */
53
54 /**
55 * @}
56 */
57
58 /** @defgroup STM32L152_EVAL_I2C_EE_Exported_Constants
59 * @{
60 */
61
62 /* Uncomment the following line to use the default sEE_TIMEOUT_UserCallback()
63 function implemented in stm32_evel_i2c_ee.c file.
64 sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition
65 occure during communication (waiting on an event that doesn't occur, bus
66 errors, busy devices ...). */
67 /* #define USE_DEFAULT_TIMEOUT_CALLBACK */
68
69 #if !defined (sEE_M24C08) && !defined (sEE_M24C64_32)
70 /* Use the defines below the choose the EEPROM type */
71 /* #define sEE_M24C08*/ /* Support the device: M24C08. */
72 /* note: Could support: M24C01, M24C02, M24C04 and M24C16 if the blocks and
73 HW address are correctly defined*/
74 #define sEE_M24C64_32 /* Support the devices: M24C32 and M24C64 */
75 #endif
76
77 #ifdef sEE_M24C64_32
78 /* For M24C32 and M24C64 devices, E0,E1 and E2 pins are all used for device
79 address selection (ne need for additional address lines). According to the
80 Harware connection on the board (on STM3210C-EVAL board E0 = E1 = E2 = 0) */
81
82 #define sEE_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */
83
84 #elif defined (sEE_M24C08)
85 /* The M24C08W contains 4 blocks (128byte each) with the adresses below: E2 = 0
86 EEPROM Addresses defines */
87 #define sEE_Block0_ADDRESS 0xA0 /* E2 = 0 */
88 /*#define sEE_Block1_ADDRESS 0xA2*/ /* E2 = 0 */
89 /*#define sEE_Block2_ADDRESS 0xA4*/ /* E2 = 0 */
90 /*#define sEE_Block3_ADDRESS 0xA6*/ /* E2 = 0 */
91
92 #endif /* sEE_M24C64_32 */
93
94 #define I2C_SPEED 200000
95 #define I2C_SLAVE_ADDRESS7 0xA0
96
97 #if defined (sEE_M24C08)
98 #define sEE_PAGESIZE 16
99 #elif defined (sEE_M24C64_32)
100 #define sEE_PAGESIZE 32
101 #endif
102
103 /* Maximum Timeout values for flags and events waiting loops. These timeouts are
104 not based on accurate values, they just guarantee that the application will
105 not remain stuck if the I2C communication is corrupted.
106 You may modify these timeout values depending on CPU frequency and application
107 conditions (interrupts routines ...). */
108 #define sEE_FLAG_TIMEOUT ((uint32_t)0x1000)
109 #define sEE_LONG_TIMEOUT ((uint32_t)(10 * sEE_FLAG_TIMEOUT))
110
111 /* Maximum number of trials for sEE_WaitEepromStandbyState() function */
112 #define sEE_MAX_TRIALS_NUMBER 300
113
114 /* Defintions for the state of the DMA transfer */
115 #define sEE_STATE_READY 0
116 #define sEE_STATE_BUSY 1
117 #define sEE_STATE_ERROR 2
118
119 #define sEE_OK 0
120 #define sEE_FAIL 1
121
122 /**
123 * @}
124 */
125
126 /** @defgroup STM32L152_EVAL_I2C_EE_Exported_Macros
127 * @{
128 */
129 /**
130 * @}
131 */
132
133 /** @defgroup STM32L152_EVAL_I2C_EE_Exported_Functions
134 * @{
135 */
136 void sEE_DeInit(void);
137 void sEE_Init(void);
138 uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead);
139 uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite);
140 void sEE_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
141 uint32_t sEE_WaitEepromStandbyState(void);
142
143 /* USER Callbacks: These are functions for which prototypes only are declared in
144 EEPROM driver and that should be implemented into user applicaiton. */
145 /* sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition
146 occure during communication (waiting on an event that doesn't occur, bus
147 errors, busy devices ...).
148 You can use the default timeout callback implementation by uncommenting the
149 define USE_DEFAULT_TIMEOUT_CALLBACK in stm32_evel_i2c_ee.h file.
150 Typically the user implementation of this callback should reset I2C peripheral
151 and re-initialize communication or in worst case reset all the application. */
152 uint32_t sEE_TIMEOUT_UserCallback(void);
153
154 #ifdef __cplusplus
155 }
156 #endif
157
158 #endif /* __STM32L152_EVAL_I2C_EE_H */
159 /**
160 * @}
161 */
162
163 /**
164 * @}
165 */
166
167 /**
168 * @}
169 */
170
171 /**
172 * @}
173 */
174
175 /**
176 * @}
177 */
178
179 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
180
181