STM8S/A Standard Peripherals Firmware Library
|
stm8s_eval_i2c_ee.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8s_eval_i2c_ee.h 00004 * @author MCD Application Team 00005 * @version V1.0.1 00006 * @date 30-September-2014 00007 * @brief This file contains all the functions prototypes for the stm8s_eval_i2c_ee 00008 * firmware driver. 00009 ****************************************************************************** 00010 * 00011 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00012 * You may not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at: 00014 * 00015 * http://www.st.com/software_license_agreement_liberty_v2 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, 00019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 ****************************************************************************** 00024 */ 00025 00026 /* Define to prevent recursive inclusion -------------------------------------*/ 00027 #ifndef __STM8S_EVAL_I2C_EE_H 00028 #define __STM8S_EVAL_I2C_EE_H 00029 00030 /* Includes ------------------------------------------------------------------*/ 00031 #include "stm8s_eval.h" 00032 00033 /** @addtogroup Utilities 00034 * @{ 00035 */ 00036 00037 /** @addtogroup STM8S_EVAL 00038 * @{ 00039 */ 00040 00041 /** @addtogroup Common 00042 * @{ 00043 */ 00044 00045 /** @addtogroup STM8S_EVAL_I2C_EE 00046 * @{ 00047 */ 00048 00049 /* Exported types ------------------------------------------------------------*/ 00050 00051 /** @defgroup STM8S_EVAL_I2C_EE_Exported_Constants 00052 * @{ 00053 */ 00054 /* Uncomment this line to use the default start and end of critical section 00055 callbacks (it disables then enables all interrupts) */ 00056 #define USE_DEFAULT_CRITICAL_CALLBACK 00057 /* Start and End of critical section: these callbacks should be typically used 00058 to disable interrupts when entering a critical section of I2C communication 00059 You may use default callbacks provided into this driver by uncommenting the 00060 define USE_DEFAULT_CRITICAL_CALLBACK. 00061 Or you can comment that line and implement these callbacks into your 00062 application */ 00063 00064 /* Uncomment the following line to use the default sEE_TIMEOUT_UserCallback() 00065 function implemented in stm8s_eval_i2c_ee.c file. 00066 sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 00067 occurs during communication (waiting on an event that doesn't occur, bus 00068 errors, busy devices ...). */ 00069 /* #define USE_DEFAULT_TIMEOUT_CALLBACK */ 00070 00071 #if !defined (sEE_M24C64_32) 00072 /* Use the defines below to choose the EEPROM type */ 00073 #define sEE_M24C64_32 /* Support the devices: M24C32 and M24C64 */ 00074 #endif 00075 00076 #ifdef sEE_M24C64_32 00077 /* For M24C32 and M24C64 devices, E0,E1 and E2 pins are all used for device 00078 address selection (ne need for additional address lines). According to the 00079 Hardware connection on the board (on STM8 EVAL board E0 = E1 = E2 = 0) */ 00080 00081 #define sEE_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */ 00082 #endif /* sEE_M24C64_32 */ 00083 00084 #define I2C_SPEED 200000 00085 #define I2C_SLAVE_ADDRESS7 0xA0 00086 00087 #if defined (sEE_M24C64_32) 00088 #define sEE_PAGESIZE 32 00089 #endif 00090 00091 00092 /* Maximum Timeout values for flags and events waiting loops. These timeouts are 00093 not based on accurate values, they just guarantee that the application will 00094 not remain stuck if the I2C communication is corrupted. 00095 You may modify these timeout values depending on CPU frequency and application 00096 conditions (interrupts routines ...). */ 00097 #define sEE_FLAG_TIMEOUT ((uint32_t)0x1000) 00098 #define sEE_LONG_TIMEOUT ((uint32_t)(10 * sEE_FLAG_TIMEOUT)) 00099 00100 /* Maximum number of trials for sEE_WaitEepromStandbyState() function */ 00101 #define sEE_MAX_TRIALS_NUMBER 150 00102 00103 #define sEE_OK 0 00104 #define sEE_FAIL 1 00105 00106 /** 00107 * @} 00108 */ 00109 00110 /* Exported macro ------------------------------------------------------------*/ 00111 00112 /** @defgroup STM8S_EVAL_I2C_EE_Exported_Functions 00113 * @{ 00114 */ 00115 void sEE_DeInit(void); 00116 void sEE_Init(void); 00117 uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead); 00118 uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); 00119 void sEE_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); 00120 uint32_t sEE_WaitEepromStandbyState(void); 00121 00122 /* USER Callbacks: These are functions for which prototypes only are declared in 00123 EEPROM driver and that should be implemented into user application. */ 00124 /* sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 00125 occurs during communication (waiting on an event that doesn't occur, bus 00126 errors, busy devices ...). 00127 You can use the default timeout callback implementation by uncommenting the 00128 define USE_DEFAULT_TIMEOUT_CALLBACK in stm8s_eval_i2c_ee.h file. 00129 Typically the user implementation of this callback should reset I2C peripheral 00130 and re-initialize communication or in worst case reset all the application. */ 00131 uint32_t sEE_TIMEOUT_UserCallback(void); 00132 00133 /* Start and End of critical section: these callbacks should be typically used 00134 to disable interrupts when entering a critical section of I2C communication 00135 You may use default callbacks provided into this driver by uncommenting the 00136 define USE_DEFAULT_CRITICAL_CALLBACK in stm8s_eval_i2c_ee.h file.. 00137 Or you can comment that line and implement these callbacks into your 00138 application */ 00139 void sEE_EnterCriticalSection_UserCallback(void); 00140 void sEE_ExitCriticalSection_UserCallback(void); 00141 00142 #endif /* __STM8S_EVAL_I2C_EE_H */ 00143 /** 00144 * @} 00145 */ 00146 00147 /** 00148 * @} 00149 */ 00150 00151 /** 00152 * @} 00153 */ 00154 00155 /** 00156 * @} 00157 */ 00158 00159 /** 00160 * @} 00161 */ 00162 00163 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/