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_hal_def.h
jhon309 0:ac8863619623 4 * @author MCD Application Team
jhon309 0:ac8863619623 5 * @version V1.2.0
jhon309 0:ac8863619623 6 * @date 11-December-2014
jhon309 0:ac8863619623 7 * @brief This file contains HAL common defines, enumeration, macros and
jhon309 0:ac8863619623 8 * structures definitions.
jhon309 0:ac8863619623 9 ******************************************************************************
jhon309 0:ac8863619623 10 * @attention
jhon309 0:ac8863619623 11 *
jhon309 0:ac8863619623 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:ac8863619623 13 *
jhon309 0:ac8863619623 14 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:ac8863619623 15 * are permitted provided that the following conditions are met:
jhon309 0:ac8863619623 16 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:ac8863619623 17 * this list of conditions and the following disclaimer.
jhon309 0:ac8863619623 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:ac8863619623 19 * this list of conditions and the following disclaimer in the documentation
jhon309 0:ac8863619623 20 * and/or other materials provided with the distribution.
jhon309 0:ac8863619623 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:ac8863619623 22 * may be used to endorse or promote products derived from this software
jhon309 0:ac8863619623 23 * without specific prior written permission.
jhon309 0:ac8863619623 24 *
jhon309 0:ac8863619623 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:ac8863619623 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:ac8863619623 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:ac8863619623 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:ac8863619623 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:ac8863619623 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:ac8863619623 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:ac8863619623 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:ac8863619623 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:ac8863619623 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:ac8863619623 35 *
jhon309 0:ac8863619623 36 ******************************************************************************
jhon309 0:ac8863619623 37 */
jhon309 0:ac8863619623 38
jhon309 0:ac8863619623 39 /* Define to prevent recursive inclusion -------------------------------------*/
jhon309 0:ac8863619623 40 #ifndef __STM32F0xx_HAL_DEF
jhon309 0:ac8863619623 41 #define __STM32F0xx_HAL_DEF
jhon309 0:ac8863619623 42
jhon309 0:ac8863619623 43 #ifdef __cplusplus
jhon309 0:ac8863619623 44 extern "C" {
jhon309 0:ac8863619623 45 #endif
jhon309 0:ac8863619623 46
jhon309 0:ac8863619623 47 /* Includes ------------------------------------------------------------------*/
jhon309 0:ac8863619623 48 #include "stm32f0xx.h"
jhon309 0:ac8863619623 49
jhon309 0:ac8863619623 50 /* Exported types ------------------------------------------------------------*/
jhon309 0:ac8863619623 51
jhon309 0:ac8863619623 52 /**
jhon309 0:ac8863619623 53 * @brief HAL Status structures definition
jhon309 0:ac8863619623 54 */
jhon309 0:ac8863619623 55 typedef enum
jhon309 0:ac8863619623 56 {
jhon309 0:ac8863619623 57 HAL_OK = 0x00,
jhon309 0:ac8863619623 58 HAL_ERROR = 0x01,
jhon309 0:ac8863619623 59 HAL_BUSY = 0x02,
jhon309 0:ac8863619623 60 HAL_TIMEOUT = 0x03
jhon309 0:ac8863619623 61 } HAL_StatusTypeDef;
jhon309 0:ac8863619623 62
jhon309 0:ac8863619623 63 /**
jhon309 0:ac8863619623 64 * @brief HAL Lock structures definition
jhon309 0:ac8863619623 65 */
jhon309 0:ac8863619623 66 typedef enum
jhon309 0:ac8863619623 67 {
jhon309 0:ac8863619623 68 HAL_UNLOCKED = 0x00,
jhon309 0:ac8863619623 69 HAL_LOCKED = 0x01
jhon309 0:ac8863619623 70 } HAL_LockTypeDef;
jhon309 0:ac8863619623 71
jhon309 0:ac8863619623 72 /* Exported macro ------------------------------------------------------------*/
jhon309 0:ac8863619623 73 #ifndef NULL
jhon309 0:ac8863619623 74 #define NULL 0
jhon309 0:ac8863619623 75 #endif
jhon309 0:ac8863619623 76
jhon309 0:ac8863619623 77 #define HAL_MAX_DELAY 0xFFFFFFFF
jhon309 0:ac8863619623 78
jhon309 0:ac8863619623 79 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
jhon309 0:ac8863619623 80 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
jhon309 0:ac8863619623 81
jhon309 0:ac8863619623 82 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \
jhon309 0:ac8863619623 83 do{ \
jhon309 0:ac8863619623 84 (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \
jhon309 0:ac8863619623 85 (__DMA_HANDLE_).Parent = (__HANDLE__); \
jhon309 0:ac8863619623 86 } while(0)
jhon309 0:ac8863619623 87
jhon309 0:ac8863619623 88 #define UNUSED(x) ((void)(x))
jhon309 0:ac8863619623 89
jhon309 0:ac8863619623 90 /** @brief Reset the Handle's State field.
jhon309 0:ac8863619623 91 * @param __HANDLE__: specifies the Peripheral Handle.
jhon309 0:ac8863619623 92 * @note This macro can be used for the following purpose:
jhon309 0:ac8863619623 93 * - When the Handle is declared as local variable; before passing it as parameter
jhon309 0:ac8863619623 94 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
jhon309 0:ac8863619623 95 * to set to 0 the Handle's "State" field.
jhon309 0:ac8863619623 96 * Otherwise, "State" field may have any random value and the first time the function
jhon309 0:ac8863619623 97 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
jhon309 0:ac8863619623 98 * (i.e. HAL_PPP_MspInit() will not be executed).
jhon309 0:ac8863619623 99 * - When there is a need to reconfigure the low level hardware: instead of calling
jhon309 0:ac8863619623 100 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
jhon309 0:ac8863619623 101 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
jhon309 0:ac8863619623 102 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
jhon309 0:ac8863619623 103 * @retval None
jhon309 0:ac8863619623 104 */
jhon309 0:ac8863619623 105 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
jhon309 0:ac8863619623 106
jhon309 0:ac8863619623 107 #if (USE_RTOS == 1)
jhon309 0:ac8863619623 108 #error " USE_RTOS should be 0 in the current HAL release "
jhon309 0:ac8863619623 109 #else
jhon309 0:ac8863619623 110 #define __HAL_LOCK(__HANDLE__) \
jhon309 0:ac8863619623 111 do{ \
jhon309 0:ac8863619623 112 if((__HANDLE__)->Lock == HAL_LOCKED) \
jhon309 0:ac8863619623 113 { \
jhon309 0:ac8863619623 114 return HAL_BUSY; \
jhon309 0:ac8863619623 115 } \
jhon309 0:ac8863619623 116 else \
jhon309 0:ac8863619623 117 { \
jhon309 0:ac8863619623 118 (__HANDLE__)->Lock = HAL_LOCKED; \
jhon309 0:ac8863619623 119 } \
jhon309 0:ac8863619623 120 }while (0)
jhon309 0:ac8863619623 121
jhon309 0:ac8863619623 122 #define __HAL_UNLOCK(__HANDLE__) \
jhon309 0:ac8863619623 123 do{ \
jhon309 0:ac8863619623 124 (__HANDLE__)->Lock = HAL_UNLOCKED; \
jhon309 0:ac8863619623 125 }while (0)
jhon309 0:ac8863619623 126 #endif /* USE_RTOS */
jhon309 0:ac8863619623 127
jhon309 0:ac8863619623 128 #if defined ( __GNUC__ )
jhon309 0:ac8863619623 129 #ifndef __weak
jhon309 0:ac8863619623 130 #define __weak __attribute__((weak))
jhon309 0:ac8863619623 131 #endif /* __weak */
jhon309 0:ac8863619623 132 #ifndef __packed
jhon309 0:ac8863619623 133 #define __packed __attribute__((__packed__))
jhon309 0:ac8863619623 134 #endif /* __packed */
jhon309 0:ac8863619623 135 #endif /* __GNUC__ */
jhon309 0:ac8863619623 136
jhon309 0:ac8863619623 137
jhon309 0:ac8863619623 138 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
jhon309 0:ac8863619623 139 #if defined (__GNUC__) /* GNU Compiler */
jhon309 0:ac8863619623 140 #ifndef __ALIGN_END
jhon309 0:ac8863619623 141 #define __ALIGN_END __attribute__ ((aligned (4)))
jhon309 0:ac8863619623 142 #endif /* __ALIGN_END */
jhon309 0:ac8863619623 143 #ifndef __ALIGN_BEGIN
jhon309 0:ac8863619623 144 #define __ALIGN_BEGIN
jhon309 0:ac8863619623 145 #endif /* __ALIGN_BEGIN */
jhon309 0:ac8863619623 146 #else
jhon309 0:ac8863619623 147 #ifndef __ALIGN_END
jhon309 0:ac8863619623 148 #define __ALIGN_END
jhon309 0:ac8863619623 149 #endif /* __ALIGN_END */
jhon309 0:ac8863619623 150 #ifndef __ALIGN_BEGIN
jhon309 0:ac8863619623 151 #if defined (__CC_ARM) /* ARM Compiler */
jhon309 0:ac8863619623 152 #define __ALIGN_BEGIN __align(4)
jhon309 0:ac8863619623 153 #elif defined (__ICCARM__) /* IAR Compiler */
jhon309 0:ac8863619623 154 #define __ALIGN_BEGIN
jhon309 0:ac8863619623 155 #endif /* __CC_ARM */
jhon309 0:ac8863619623 156 #endif /* __ALIGN_BEGIN */
jhon309 0:ac8863619623 157 #endif /* __GNUC__ */
jhon309 0:ac8863619623 158
jhon309 0:ac8863619623 159 /**
jhon309 0:ac8863619623 160 * @brief __NOINLINE definition
jhon309 0:ac8863619623 161 */
jhon309 0:ac8863619623 162 #if defined ( __CC_ARM ) || defined ( __GNUC__ )
jhon309 0:ac8863619623 163 /* ARM & GNUCompiler
jhon309 0:ac8863619623 164 ----------------
jhon309 0:ac8863619623 165 */
jhon309 0:ac8863619623 166 #define __NOINLINE __attribute__ ( (noinline) )
jhon309 0:ac8863619623 167
jhon309 0:ac8863619623 168 #elif defined ( __ICCARM__ )
jhon309 0:ac8863619623 169 /* ICCARM Compiler
jhon309 0:ac8863619623 170 ---------------
jhon309 0:ac8863619623 171 */
jhon309 0:ac8863619623 172 #define __NOINLINE _Pragma("optimize = no_inline")
jhon309 0:ac8863619623 173
jhon309 0:ac8863619623 174 #endif
jhon309 0:ac8863619623 175
jhon309 0:ac8863619623 176 #ifdef __cplusplus
jhon309 0:ac8863619623 177 }
jhon309 0:ac8863619623 178 #endif
jhon309 0:ac8863619623 179
jhon309 0:ac8863619623 180 #endif /* ___STM32F0xx_HAL_DEF */
jhon309 0:ac8863619623 181
jhon309 0:ac8863619623 182 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
jhon309 0:ac8863619623 183