stm32_eval_i2c_ee.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32_eval_i2c_ee.h
00004   * @author  MCD Application Team
00005   * @version V4.3.0
00006   * @date    10/15/2010
00007   * @brief   This file contains all the functions prototypes for the stm32_eval_i2c_ee
00008   *          firmware driver.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00020   */ 
00021 
00022 /* Define to prevent recursive inclusion -------------------------------------*/
00023 #ifndef __STM32_EVAL_I2C_EE_H
00024 #define __STM32_EVAL_I2C_EE_H
00025 
00026 #ifdef __cplusplus
00027  extern "C" {
00028 #endif
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32_eval.h"
00032 
00033 /** @addtogroup Utilities
00034   * @{
00035   */
00036   
00037 /** @addtogroup STM32_EVAL
00038   * @{
00039   */ 
00040 
00041 /** @addtogroup Common
00042   * @{
00043   */
00044   
00045 /** @addtogroup STM32_EVAL_I2C_EE
00046   * @{
00047   */  
00048 
00049 /** @defgroup STM32_EVAL_I2C_EE_Exported_Types
00050   * @{
00051   */ 
00052 
00053 /**
00054   * @}
00055   */
00056   
00057 /** @defgroup STM32_EVAL_I2C_EE_Exported_Constants
00058   * @{
00059   */
00060   
00061 /* Uncomment this line to use the default start and end of critical section 
00062    callbacks (it disables then enabled all interrupts) */
00063 #define USE_DEFAULT_CRITICAL_CALLBACK 
00064 /* Start and End of critical section: these callbacks should be typically used
00065    to disable interrupts when entering a critical section of I2C communication
00066    You may use default callbacks provided into this driver by uncommenting the 
00067    define USE_DEFAULT_CRITICAL_CALLBACK.
00068    Or you can comment that line and implement these callbacks into your 
00069    application */
00070 
00071 /* Uncomment the following line to use the default sEE_TIMEOUT_UserCallback() 
00072    function implemented in stm32_evel_i2c_ee.c file.
00073    sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 
00074    occure during communication (waiting on an event that doesn't occur, bus 
00075    errors, busy devices ...). */   
00076 /* #define USE_DEFAULT_TIMEOUT_CALLBACK */
00077    
00078 #if !defined (sEE_M24C08) && !defined (sEE_M24C64_32)
00079 /* Use the defines below the choose the EEPROM type */
00080 /* #define sEE_M24C08*/  /* Support the device: M24C08. */
00081 /* note: Could support: M24C01, M24C02, M24C04 and M24C16 if the blocks and 
00082    HW address are correctly defined*/
00083 #define sEE_M24C64_32  /* Support the devices: M24C32 and M24C64 */
00084 #endif
00085 
00086 #ifdef sEE_M24C64_32
00087 /* For M24C32 and M24C64 devices, E0,E1 and E2 pins are all used for device 
00088   address selection (ne need for additional address lines). According to the 
00089   Harware connection on the board (on STM3210C-EVAL board E0 = E1 = E2 = 0) */
00090 
00091  #define sEE_HW_ADDRESS         0xA0   /* E0 = E1 = E2 = 0 */ 
00092 
00093 #elif defined (sEE_M24C08)
00094 /* The M24C08W contains 4 blocks (128byte each) with the adresses below: E2 = 0 
00095    EEPROM Addresses defines */
00096  #define sEE_Block0_ADDRESS     0xA0   /* E2 = 0 */ 
00097  /*#define sEE_Block1_ADDRESS     0xA2*/ /* E2 = 0 */  
00098  /*#define sEE_Block2_ADDRESS     0xA4*/ /* E2 = 0 */
00099  /*#define sEE_Block3_ADDRESS     0xA6*/ /* E2 = 0 */
00100 
00101 #endif /* sEE_M24C64_32 */
00102 
00103 #define I2C_SPEED               300000
00104 #define I2C_SLAVE_ADDRESS7      0xA0
00105 
00106 #if defined (sEE_M24C08)
00107  #define sEE_PAGESIZE           16
00108 #elif defined (sEE_M24C64_32)
00109  #define sEE_PAGESIZE           32
00110 #endif
00111    
00112 /* Maximum Timeout values for flags and events waiting loops. These timeouts are
00113    not based on accurate values, they just guarantee that the application will 
00114    not remain stuck if the I2C communication is corrupted.
00115    You may modify these timeout values depending on CPU frequency and application
00116    conditions (interrupts routines ...). */   
00117 #define sEE_FLAG_TIMEOUT         ((uint32_t)0x1000)
00118 #define sEE_LONG_TIMEOUT         ((uint32_t)(10 * sEE_FLAG_TIMEOUT))
00119 
00120 /* Maximum number of trials for sEE_WaitEepromStandbyState() function */
00121 #define sEE_MAX_TRIALS_NUMBER     150
00122    
00123 /* Defintions for the state of the DMA transfer */   
00124 #define sEE_STATE_READY           0
00125 #define sEE_STATE_BUSY            1
00126 #define sEE_STATE_ERROR           2
00127    
00128 #define sEE_OK                    0
00129 #define sEE_FAIL                  1   
00130 
00131 /**
00132   * @}
00133   */ 
00134   
00135 /** @defgroup STM32_EVAL_I2C_EE_Exported_Macros
00136   * @{
00137   */    
00138 /**
00139   * @}
00140   */ 
00141 
00142 /** @defgroup STM32_EVAL_I2C_EE_Exported_Functions
00143   * @{
00144   */ 
00145 void     sEE_DeInit(void);
00146 void     sEE_Init(void);
00147 uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead);
00148 uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite);
00149 void     sEE_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
00150 uint32_t sEE_WaitEepromStandbyState(void);
00151 
00152 /* USER Callbacks: These are functions for which prototypes only are declared in
00153    EEPROM driver and that should be implemented into user applicaiton. */  
00154 /* sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 
00155    occure during communication (waiting on an event that doesn't occur, bus 
00156    errors, busy devices ...).
00157    You can use the default timeout callback implementation by uncommenting the 
00158    define USE_DEFAULT_TIMEOUT_CALLBACK in stm32_evel_i2c_ee.h file.
00159    Typically the user implementation of this callback should reset I2C peripheral
00160    and re-initialize communication or in worst case reset all the application. */
00161 uint32_t sEE_TIMEOUT_UserCallback(void);
00162 
00163 /* Start and End of critical section: these callbacks should be typically used
00164    to disable interrupts when entering a critical section of I2C communication
00165    You may use default callbacks provided into this driver by uncommenting the 
00166    define USE_DEFAULT_CRITICAL_CALLBACK in stm32_evel_i2c_ee.h file..
00167    Or you can comment that line and implement these callbacks into your 
00168    application */
00169 void sEE_EnterCriticalSection_UserCallback(void);
00170 void sEE_ExitCriticalSection_UserCallback(void);
00171 
00172 
00173 #ifdef __cplusplus
00174 }
00175 #endif
00176 
00177 #endif /* __STM32_EVAL_I2C_EE_H */
00178 /**
00179   * @}
00180   */
00181 
00182 /**
00183   * @}
00184   */
00185 
00186 /**
00187   * @}
00188   */
00189 
00190 /**
00191   * @}
00192   */ 
00193 
00194 /**
00195   * @}
00196   */
00197 
00198 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
00199 
00200 
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32