I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:ac8863619623 1 /**
jhon309 0:ac8863619623 2 ******************************************************************************
jhon309 0:ac8863619623 3 * @file stm32f0xx.h
jhon309 0:ac8863619623 4 * @author MCD Application Team
jhon309 0:ac8863619623 5 * @version V2.2.0
jhon309 0:ac8863619623 6 * @date 05-December-2014
jhon309 0:ac8863619623 7 * @brief CMSIS STM32F0xx Device Peripheral Access Layer Header File.
jhon309 0:ac8863619623 8 *
jhon309 0:ac8863619623 9 * The file is the unique include file that the application programmer
jhon309 0:ac8863619623 10 * is using in the C source code, usually in main.c. This file contains:
jhon309 0:ac8863619623 11 * - Configuration section that allows to select:
jhon309 0:ac8863619623 12 * - The STM32F0xx device used in the target application
jhon309 0:ac8863619623 13 * - To use or not the peripheral’s drivers in application code(i.e.
jhon309 0:ac8863619623 14 * code will be based on direct access to peripheral’s registers
jhon309 0:ac8863619623 15 * rather than drivers API), this option is controlled by
jhon309 0:ac8863619623 16 * "#define USE_HAL_DRIVER"
jhon309 0:ac8863619623 17 *
jhon309 0:ac8863619623 18 ******************************************************************************
jhon309 0:ac8863619623 19 * @attention
jhon309 0:ac8863619623 20 *
jhon309 0:ac8863619623 21 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:ac8863619623 22 *
jhon309 0:ac8863619623 23 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:ac8863619623 24 * are permitted provided that the following conditions are met:
jhon309 0:ac8863619623 25 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:ac8863619623 26 * this list of conditions and the following disclaimer.
jhon309 0:ac8863619623 27 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:ac8863619623 28 * this list of conditions and the following disclaimer in the documentation
jhon309 0:ac8863619623 29 * and/or other materials provided with the distribution.
jhon309 0:ac8863619623 30 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:ac8863619623 31 * may be used to endorse or promote products derived from this software
jhon309 0:ac8863619623 32 * without specific prior written permission.
jhon309 0:ac8863619623 33 *
jhon309 0:ac8863619623 34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:ac8863619623 35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:ac8863619623 36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:ac8863619623 37 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:ac8863619623 38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:ac8863619623 39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:ac8863619623 40 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:ac8863619623 41 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:ac8863619623 42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:ac8863619623 43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:ac8863619623 44 *
jhon309 0:ac8863619623 45 ******************************************************************************
jhon309 0:ac8863619623 46 */
jhon309 0:ac8863619623 47
jhon309 0:ac8863619623 48 /** @addtogroup CMSIS
jhon309 0:ac8863619623 49 * @{
jhon309 0:ac8863619623 50 */
jhon309 0:ac8863619623 51
jhon309 0:ac8863619623 52 /** @addtogroup stm32f0xx
jhon309 0:ac8863619623 53 * @{
jhon309 0:ac8863619623 54 */
jhon309 0:ac8863619623 55
jhon309 0:ac8863619623 56 #ifndef __STM32F0xx_H
jhon309 0:ac8863619623 57 #define __STM32F0xx_H
jhon309 0:ac8863619623 58
jhon309 0:ac8863619623 59 #ifdef __cplusplus
jhon309 0:ac8863619623 60 extern "C" {
jhon309 0:ac8863619623 61 #endif /* __cplusplus */
jhon309 0:ac8863619623 62
jhon309 0:ac8863619623 63 /** @addtogroup Library_configuration_section
jhon309 0:ac8863619623 64 * @{
jhon309 0:ac8863619623 65 */
jhon309 0:ac8863619623 66
jhon309 0:ac8863619623 67 /* Uncomment the line below according to the target STM32 device used in your
jhon309 0:ac8863619623 68 application
jhon309 0:ac8863619623 69 */
jhon309 0:ac8863619623 70
jhon309 0:ac8863619623 71 #if !defined (STM32F030x6) && !defined (STM32F030x8) && \
jhon309 0:ac8863619623 72 !defined (STM32F031x6) && !defined (STM32F038xx) && \
jhon309 0:ac8863619623 73 !defined (STM32F042x6) && !defined (STM32F048xx) && !defined (STM32F070x6) && \
jhon309 0:ac8863619623 74 !defined (STM32F051x8) && !defined (STM32F058xx) && \
jhon309 0:ac8863619623 75 !defined (STM32F071xB) && !defined (STM32F072xB) && !defined (STM32F078xx) && !defined (STM32F070xB) && \
jhon309 0:ac8863619623 76 !defined (STM32F091xC) && !defined (STM32F098xx) && !defined (STM32F030xC)
jhon309 0:ac8863619623 77 /* #define STM32F030x6 */ /*!< STM32F030x4, STM32F030x6 Devices (STM32F030xx microcontrollers where the Flash memory ranges between 16 and 32 Kbytes) */
jhon309 0:ac8863619623 78 /* #define STM32F030x8 */ /*!< STM32F030x8 Devices (STM32F030xx microcontrollers where the Flash memory is 64 Kbytes) */
jhon309 0:ac8863619623 79 /* #define STM32F031x6 */ /*!< STM32F031x4, STM32F031x6 Devices (STM32F031xx microcontrollers where the Flash memory ranges between 16 and 32 Kbytes) */
jhon309 0:ac8863619623 80 /* #define STM32F038xx */ /*!< STM32F038xx Devices (STM32F038xx microcontrollers where the Flash memory is 32 Kbytes) */
jhon309 0:ac8863619623 81 /* #define STM32F042x6 */ /*!< STM32F042x4, STM32F042x6 Devices (STM32F042xx microcontrollers where the Flash memory ranges between 16 and 32 Kbytes) */
jhon309 0:ac8863619623 82 /* #define STM32F048x6 */ /*!< STM32F048xx Devices (STM32F042xx microcontrollers where the Flash memory is 32 Kbytes) */
jhon309 0:ac8863619623 83 /* #define STM32F051x8 */ /*!< STM32F051x4, STM32F051x6, STM32F051x8 Devices (STM32F051xx microcontrollers where the Flash memory ranges between 16 and 64 Kbytes) */
jhon309 0:ac8863619623 84 /* #define STM32F058xx */ /*!< STM32F058xx Devices (STM32F058xx microcontrollers where the Flash memory is 64 Kbytes) */
jhon309 0:ac8863619623 85 /* #define STM32F070x6 */ /*!< STM32F070x6 Devices (STM32F070x6 microcontrollers where the Flash memory ranges between 16 and 32 Kbytes) */
jhon309 0:ac8863619623 86 /* #define STM32F070xB */ /*!< STM32F070xB Devices (STM32F070xB microcontrollers where the Flash memory ranges between 64 and 128 Kbytes) */
jhon309 0:ac8863619623 87 /* #define STM32F071xB */ /*!< STM32F071x8, STM32F071xB Devices (STM32F071xx microcontrollers where the Flash memory ranges between 64 and 128 Kbytes) */
jhon309 0:ac8863619623 88 #define STM32F072xB /*!< STM32F072x8, STM32F072xB Devices (STM32F072xx microcontrollers where the Flash memory ranges between 64 and 128 Kbytes) */
jhon309 0:ac8863619623 89 /* #define STM32F078xx */ /*!< STM32F078xx Devices (STM32F078xx microcontrollers where the Flash memory is 128 Kbytes) */
jhon309 0:ac8863619623 90 /* #define STM32F030xC */ /*!< STM32F030xC Devices (STM32F030xC microcontrollers where the Flash memory is 256 Kbytes) */
jhon309 0:ac8863619623 91 /* #define STM32F091xC */ /*!< STM32F091xC Devices (STM32F091xx microcontrollers where the Flash memory is 256 Kbytes) */
jhon309 0:ac8863619623 92 /* #define STM32F098xx */ /*!< STM32F098xx Devices (STM32F098xx microcontrollers where the Flash memory is 256 Kbytes) */
jhon309 0:ac8863619623 93 #endif
jhon309 0:ac8863619623 94
jhon309 0:ac8863619623 95 /* Tip: To avoid modifying this file each time you need to switch between these
jhon309 0:ac8863619623 96 devices, you can define the device in your toolchain compiler preprocessor.
jhon309 0:ac8863619623 97 */
jhon309 0:ac8863619623 98 #if !defined (USE_HAL_DRIVER)
jhon309 0:ac8863619623 99 /**
jhon309 0:ac8863619623 100 * @brief Comment the line below if you will not use the peripherals drivers.
jhon309 0:ac8863619623 101 In this case, these drivers will not be included and the application code will
jhon309 0:ac8863619623 102 be based on direct access to peripherals registers
jhon309 0:ac8863619623 103 */
jhon309 0:ac8863619623 104 #define USE_HAL_DRIVER
jhon309 0:ac8863619623 105 #endif /* USE_HAL_DRIVER */
jhon309 0:ac8863619623 106
jhon309 0:ac8863619623 107 /**
jhon309 0:ac8863619623 108 * @brief CMSIS Device version number V2.2.0
jhon309 0:ac8863619623 109 */
jhon309 0:ac8863619623 110 #define __STM32F0xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */
jhon309 0:ac8863619623 111 #define __STM32F0xx_CMSIS_DEVICE_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */
jhon309 0:ac8863619623 112 #define __STM32F0xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
jhon309 0:ac8863619623 113 #define __STM32F0xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
jhon309 0:ac8863619623 114 #define __STM32F0xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\
jhon309 0:ac8863619623 115 |(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
jhon309 0:ac8863619623 116 |(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
jhon309 0:ac8863619623 117 |(__CMSIS_DEVICE_HAL_VERSION_RC))
jhon309 0:ac8863619623 118
jhon309 0:ac8863619623 119 /**
jhon309 0:ac8863619623 120 * @}
jhon309 0:ac8863619623 121 */
jhon309 0:ac8863619623 122
jhon309 0:ac8863619623 123 /** @addtogroup Device_Included
jhon309 0:ac8863619623 124 * @{
jhon309 0:ac8863619623 125 */
jhon309 0:ac8863619623 126
jhon309 0:ac8863619623 127 #if defined(STM32F030x6)
jhon309 0:ac8863619623 128 #include "stm32f030x6.h"
jhon309 0:ac8863619623 129 #elif defined(STM32F030x8)
jhon309 0:ac8863619623 130 #include "stm32f030x8.h"
jhon309 0:ac8863619623 131 #elif defined(STM32F031x6)
jhon309 0:ac8863619623 132 #include "stm32f031x6.h"
jhon309 0:ac8863619623 133 #elif defined(STM32F038xx)
jhon309 0:ac8863619623 134 #include "stm32f038xx.h"
jhon309 0:ac8863619623 135 #elif defined(STM32F042x6)
jhon309 0:ac8863619623 136 #include "stm32f042x6.h"
jhon309 0:ac8863619623 137 #elif defined(STM32F048xx)
jhon309 0:ac8863619623 138 #include "stm32f048xx.h"
jhon309 0:ac8863619623 139 #elif defined(STM32F051x8)
jhon309 0:ac8863619623 140 #include "stm32f051x8.h"
jhon309 0:ac8863619623 141 #elif defined(STM32F058xx)
jhon309 0:ac8863619623 142 #include "stm32f058xx.h"
jhon309 0:ac8863619623 143 #elif defined(STM32F070x6)
jhon309 0:ac8863619623 144 #include "stm32f070x6.h"
jhon309 0:ac8863619623 145 #elif defined(STM32F070xB)
jhon309 0:ac8863619623 146 #include "stm32f070xb.h"
jhon309 0:ac8863619623 147 #elif defined(STM32F071xB)
jhon309 0:ac8863619623 148 #include "stm32f071xb.h"
jhon309 0:ac8863619623 149 #elif defined(STM32F072xB)
jhon309 0:ac8863619623 150 #include "stm32f072xb.h"
jhon309 0:ac8863619623 151 #elif defined(STM32F078xx)
jhon309 0:ac8863619623 152 #include "stm32f078xx.h"
jhon309 0:ac8863619623 153 #elif defined(STM32F091xC)
jhon309 0:ac8863619623 154 #include "stm32f091xc.h"
jhon309 0:ac8863619623 155 #elif defined(STM32F098xx)
jhon309 0:ac8863619623 156 #include "stm32f098xx.h"
jhon309 0:ac8863619623 157 #elif defined(STM32F030xC)
jhon309 0:ac8863619623 158 #include "stm32f030xc.h"
jhon309 0:ac8863619623 159 #else
jhon309 0:ac8863619623 160 #error "Please select first the target STM32F0xx device used in your application (in stm32f0xx.h file)"
jhon309 0:ac8863619623 161 #endif
jhon309 0:ac8863619623 162
jhon309 0:ac8863619623 163 /**
jhon309 0:ac8863619623 164 * @}
jhon309 0:ac8863619623 165 */
jhon309 0:ac8863619623 166
jhon309 0:ac8863619623 167 /** @addtogroup Exported_types
jhon309 0:ac8863619623 168 * @{
jhon309 0:ac8863619623 169 */
jhon309 0:ac8863619623 170 typedef enum
jhon309 0:ac8863619623 171 {
jhon309 0:ac8863619623 172 RESET = 0,
jhon309 0:ac8863619623 173 SET = !RESET
jhon309 0:ac8863619623 174 } FlagStatus, ITStatus;
jhon309 0:ac8863619623 175
jhon309 0:ac8863619623 176 typedef enum
jhon309 0:ac8863619623 177 {
jhon309 0:ac8863619623 178 DISABLE = 0,
jhon309 0:ac8863619623 179 ENABLE = !DISABLE
jhon309 0:ac8863619623 180 } FunctionalState;
jhon309 0:ac8863619623 181 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
jhon309 0:ac8863619623 182
jhon309 0:ac8863619623 183 typedef enum
jhon309 0:ac8863619623 184 {
jhon309 0:ac8863619623 185 ERROR = 0,
jhon309 0:ac8863619623 186 SUCCESS = !ERROR
jhon309 0:ac8863619623 187 } ErrorStatus;
jhon309 0:ac8863619623 188
jhon309 0:ac8863619623 189 /**
jhon309 0:ac8863619623 190 * @}
jhon309 0:ac8863619623 191 */
jhon309 0:ac8863619623 192
jhon309 0:ac8863619623 193
jhon309 0:ac8863619623 194 /** @addtogroup Exported_macros
jhon309 0:ac8863619623 195 * @{
jhon309 0:ac8863619623 196 */
jhon309 0:ac8863619623 197 #define SET_BIT(REG, BIT) ((REG) |= (BIT))
jhon309 0:ac8863619623 198
jhon309 0:ac8863619623 199 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
jhon309 0:ac8863619623 200
jhon309 0:ac8863619623 201 #define READ_BIT(REG, BIT) ((REG) & (BIT))
jhon309 0:ac8863619623 202
jhon309 0:ac8863619623 203 #define CLEAR_REG(REG) ((REG) = (0x0))
jhon309 0:ac8863619623 204
jhon309 0:ac8863619623 205 #define WRITE_REG(REG, VAL) ((REG) = (VAL))
jhon309 0:ac8863619623 206
jhon309 0:ac8863619623 207 #define READ_REG(REG) ((REG))
jhon309 0:ac8863619623 208
jhon309 0:ac8863619623 209 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
jhon309 0:ac8863619623 210
jhon309 0:ac8863619623 211
jhon309 0:ac8863619623 212 /**
jhon309 0:ac8863619623 213 * @}
jhon309 0:ac8863619623 214 */
jhon309 0:ac8863619623 215
jhon309 0:ac8863619623 216 #if defined (USE_HAL_DRIVER)
jhon309 0:ac8863619623 217 #include "stm32f0xx_hal.h"
jhon309 0:ac8863619623 218 #endif /* USE_HAL_DRIVER */
jhon309 0:ac8863619623 219
jhon309 0:ac8863619623 220
jhon309 0:ac8863619623 221 #ifdef __cplusplus
jhon309 0:ac8863619623 222 }
jhon309 0:ac8863619623 223 #endif /* __cplusplus */
jhon309 0:ac8863619623 224
jhon309 0:ac8863619623 225 #endif /* __STM32F0xx_H */
jhon309 0:ac8863619623 226 /**
jhon309 0:ac8863619623 227 * @}
jhon309 0:ac8863619623 228 */
jhon309 0:ac8863619623 229
jhon309 0:ac8863619623 230 /**
jhon309 0:ac8863619623 231 * @}
jhon309 0:ac8863619623 232 */
jhon309 0:ac8863619623 233
jhon309 0:ac8863619623 234
jhon309 0:ac8863619623 235
jhon309 0:ac8863619623 236
jhon309 0:ac8863619623 237 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/