my fork
Fork of mbed by
Diff: TARGET_NUCLEO_F072RB/stm32f0xx_hal_i2c.h
- Revision:
- 92:4fc01daae5a5
- Parent:
- 85:024bf7f99721
- Child:
- 93:e188a91d3eaa
diff -r 031413cf7a89 -r 4fc01daae5a5 TARGET_NUCLEO_F072RB/stm32f0xx_hal_i2c.h --- a/TARGET_NUCLEO_F072RB/stm32f0xx_hal_i2c.h Wed Oct 29 11:02:04 2014 +0000 +++ b/TARGET_NUCLEO_F072RB/stm32f0xx_hal_i2c.h Thu Nov 27 13:33:22 2014 +0000 @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f0xx_hal_i2c.h * @author MCD Application Team - * @version V1.0.0 - * @date 28-May-2014 + * @version V1.1.0 + * @date 03-Oct-2014 * @brief Header file of I2C HAL module. ****************************************************************************** * @attention @@ -55,9 +55,13 @@ */ /* Exported types ------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Types I2C Exported Types + * @{ + */ -/** - * @brief I2C Configuration Structure definition +/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition + * @brief I2C Configuration Structure definition + * @{ */ typedef struct { @@ -88,9 +92,15 @@ }I2C_InitTypeDef; -/** - * @brief HAL State structures definition - */ +/** + * @} + */ + +/** @defgroup HAL_state_structure_definition HAL state structure definition + * @brief HAL State structure definition + * @{ + */ + typedef enum { HAL_I2C_STATE_RESET = 0x00, /*!< I2C not yet initialized or disabled */ @@ -107,9 +117,15 @@ }HAL_I2C_StateTypeDef; -/** - * @brief HAL I2C Error Code structure definition - */ +/** + * @} + */ + +/** @defgroup I2C_Error_Code_structure_definition I2C Error Code structure definition + * @brief I2C Error Code structure definition + * @{ + */ + typedef enum { HAL_I2C_ERROR_NONE = 0x00, /*!< No error */ @@ -122,9 +138,15 @@ HAL_I2C_ERROR_SIZE = 0x40 /*!< Size Management error */ }HAL_I2C_ErrorTypeDef; -/** - * @brief I2C handle Structure definition +/** + * @} */ + +/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition + * @brief I2C handle Structure definition + * @{ + */ + typedef struct { I2C_TypeDef *Instance; /*!< I2C registers base address */ @@ -148,14 +170,20 @@ __IO HAL_I2C_ErrorTypeDef ErrorCode; /* I2C Error code */ }I2C_HandleTypeDef; +/** + * @} + */ +/** + * @} + */ /* Exported constants --------------------------------------------------------*/ -/** @defgroup I2C_Exported_Constants +/** @defgroup I2C_Exported_Constants I2C Exported Constants * @{ */ -/** @defgroup I2C_addressing_mode +/** @defgroup I2C_addressing_mode I2C addressing mode * @{ */ #define I2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00000001) @@ -167,7 +195,7 @@ * @} */ -/** @defgroup I2C_dual_addressing_mode +/** @defgroup I2C_dual_addressing_mode I2C dual addressing mode * @{ */ @@ -180,7 +208,7 @@ * @} */ -/** @defgroup I2C_own_address2_masks +/** @defgroup I2C_own_address2_masks I2C own address2 masks * @{ */ @@ -205,7 +233,7 @@ * @} */ -/** @defgroup I2C_general_call_addressing_mode +/** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode * @{ */ #define I2C_GENERALCALL_DISABLED ((uint32_t)0x00000000) @@ -217,7 +245,7 @@ * @} */ -/** @defgroup I2C_nostretch_mode +/** @defgroup I2C_nostretch_mode I2C nostretch mode * @{ */ #define I2C_NOSTRETCH_DISABLED ((uint32_t)0x00000000) @@ -229,7 +257,7 @@ * @} */ -/** @defgroup I2C_Memory_Address_Size +/** @defgroup I2C_Memory_Address_Size I2C Memory Address Size * @{ */ #define I2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001) @@ -241,7 +269,7 @@ * @} */ -/** @defgroup I2C_ReloadEndMode_definition +/** @defgroup I2C_ReloadEndMode_definition I2C ReloadEndMode definition * @{ */ @@ -256,7 +284,7 @@ * @} */ -/** @defgroup I2C_StartStopMode_definition +/** @defgroup I2C_StartStopMode_definition I2C StartStopMode definition * @{ */ @@ -274,7 +302,7 @@ * @} */ -/** @defgroup I2C_Interrupt_configuration_definition +/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition * @brief I2C Interrupt definition * Elements values convention: 0xXXXXXXXX * - XXXXXXXX : Interrupt control mask @@ -293,7 +321,7 @@ */ -/** @defgroup I2C_Flag_definition +/** @defgroup I2C_Flag_definition I2C Flag definition * @{ */ @@ -323,6 +351,10 @@ /* Exported macros -----------------------------------------------------------*/ +/** @defgroup I2C_Exported_Macros I2C Exported Macros + * @{ + */ + /** @brief Reset I2C handle state * @param __HANDLE__: I2C handle. * @retval None @@ -331,7 +363,7 @@ /** @brief Enables or disables the specified I2C interrupts. * @param __HANDLE__: specifies the I2C Handle. - * This parameter can be I2C where x: 1 or 2 to select the I2C peripheral. + * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. * @param __INTERRUPT__: specifies the interrupt source to enable or disable. * This parameter can be one of the following values: * @arg I2C_IT_ERRI: Errors interrupt enable @@ -350,7 +382,7 @@ /** @brief Checks if the specified I2C interrupt source is enabled or disabled. * @param __HANDLE__: specifies the I2C Handle. - * This parameter can be I2C where x: 1 or 2 to select the I2C peripheral. + * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. * @param __INTERRUPT__: specifies the I2C interrupt source to check. * This parameter can be one of the following values: * @arg I2C_IT_ERRI: Errors interrupt enable @@ -367,7 +399,7 @@ /** @brief Checks whether the specified I2C flag is set or not. * @param __HANDLE__: specifies the I2C Handle. - * This parameter can be I2C where x: 1 or 2 to select the I2C peripheral. + * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: * @arg I2C_FLAG_TXE: Transmit data register empty @@ -389,12 +421,11 @@ * * @retval The new state of __FLAG__ (TRUE or FALSE). */ -#define I2C_FLAG_MASK ((uint32_t)0x0001FFFF) -#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK))) +#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__)) /** @brief Clears the I2C pending flags which are cleared by writing 1 in a specific bit. * @param __HANDLE__: specifies the I2C Handle. - * This parameter can be I2C where x: 1 or 2 to select the I2C peripheral. + * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. * @param __FLAG__: specifies the flag to clear. * This parameter can be any combination of the following values: * @arg I2C_FLAG_ADDR: Address matched (slave mode) @@ -409,7 +440,7 @@ * * @retval None */ -#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR |= ((__FLAG__) & I2C_FLAG_MASK)) +#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) #define __HAL_I2C_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= I2C_CR1_PE) @@ -417,26 +448,46 @@ #define __HAL_I2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN))) -#define __HAL_I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)(((__ADDRESS__) & 0xFF00) >> 8)) -#define __HAL_I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((__ADDRESS__) & 0x00FF)) +#define __HAL_I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8))) +#define __HAL_I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF)))) #define __HAL_I2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \ (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN))) #define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= (uint32_t)0x000003FF) #define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF) - -/* Include I2C HAL Extension module */ +/** + * @} + */ + +/* Include I2C HAL Extended module */ #include "stm32f0xx_hal_i2c_ex.h" /* Exported functions --------------------------------------------------------*/ +/** @addtogroup I2C_Exported_Functions + * @{ + */ + +/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions + * @{ + */ + /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c); HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c); void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); +/** + * @} + */ + +/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions + * @{ + */ + /* IO operation functions *****************************************************/ + /******* Blocking mode: Polling */ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); @@ -473,7 +524,15 @@ void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); -/* Peripheral State functions **************************************/ +/** + * @} + */ + +/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State and Errors functions + * @{ + */ + +/* Peripheral State and Errors functions **************************************/ HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c); uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c); @@ -484,6 +543,14 @@ /** * @} */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } @@ -493,3 +560,4 @@ #endif /* __STM32F0xx_HAL_I2C_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +