STM32F0 CPAL I2C bibliotheek  1.0
ST Microelectronics CPALv2 bibliotheek documentatie
 All Data Structures Files Functions Variables Enumerations Enumerator Macros
stm32f0xx_i2c_cpal.c File Reference

This file provides all the CPAL firmware functions for I2C peripheral. More...

Macros

#define __CPAL_I2C_TIMEOUT_DETECT
 
#define __CPAL_I2C_TIMEOUT(cmd, timeout)
 

Functions

uint32_t CPAL_I2C_Init (CPAL_InitTypeDef *pDevInitStruct)
 Initialize the peripheral and all related clocks, GPIOs, DMA and Interrupts according to the specified parameters in the CPAL_InitTypeDef structure. More...
 
uint32_t CPAL_I2C_DeInit (CPAL_InitTypeDef *pDevInitStruct)
 Deinitialize the peripheral and all related clocks, GPIOs, DMA and NVIC to their reset values. More...
 
uint32_t CPAL_I2C_StructInit (CPAL_InitTypeDef *pDevInitStruct)
 Initialize the peripheral structure with default values according to the specified parameters in the CPAL_I2CDevTypeDef structure. More...
 
uint32_t CPAL_I2C_Write (CPAL_InitTypeDef *pDevInitStruct)
 Allows to send a data or a buffer of data through the peripheral to a selected device in a selected location address. More...
 
uint32_t CPAL_I2C_Read (CPAL_InitTypeDef *pDevInitStruct)
 Allows to receive a data or a buffer of data through the peripheral from a selected device in a selected location address. More...
 
uint32_t CPAL_I2C_IsDeviceReady (CPAL_InitTypeDef *pDevInitStruct)
 Wait until target device is ready for communication (This function is used with Memory devices). More...
 
uint32_t CPAL_I2C_EV_IRQHandler (CPAL_InitTypeDef *pDevInitStruct)
 This function handles I2C interrupt request for preparing communication and for transfer phase in case of using Interrupt Programming Model. More...
 
uint32_t CPAL_I2C_ER_IRQHandler (CPAL_InitTypeDef *pDevInitStruct)
 Allows to handle errors occurred during initialization or communication in order to recover the correct communication status or call specific user functions. More...
 
void CPAL_I2C_TIMEOUT_Manager (void)
 This function Manages I2C Timeouts when waiting for specific events. More...
 

Variables

I2C_TypeDef * CPAL_I2C_DEVICE []
 
I2C_InitTypeDef I2C_InitStructure
 
__IO uint32_t Num_Data = 0
 
uint32_t CR2_tmp = 0
 

Detailed Description

This file provides all the CPAL firmware functions for I2C peripheral.

Author
MCD Application Team
Version
V1.0.0
Date
20-April-2012
Attention

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

   http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Macro Definition Documentation

#define __CPAL_I2C_TIMEOUT (   cmd,
  timeout 
)
Value:
pDevInitStruct->wCPAL_Timeout = CPAL_I2C_TIMEOUT_MIN + (timeout);\
while (((cmd) == 0) && (!__CPAL_I2C_TIMEOUT_DETECT))\
if (__CPAL_I2C_TIMEOUT_DETECT)\
{\
return CPAL_I2C_Timeout (pDevInitStruct); \
}\
pDevInitStruct->wCPAL_Timeout = CPAL_I2C_TIMEOUT_DEFAULT
#define __CPAL_I2C_TIMEOUT_DETECT
Value:
((pDevInitStruct->wCPAL_Timeout == CPAL_I2C_TIMEOUT_MIN) ||\
(pDevInitStruct->wCPAL_Timeout == CPAL_I2C_TIMEOUT_DEFAULT))

Function Documentation

uint32_t CPAL_I2C_DeInit ( CPAL_InitTypeDef pDevInitStruct)

Deinitialize the peripheral and all related clocks, GPIOs, DMA and NVIC to their reset values.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL
Note
The Peripheral clock is disabled but the GPIO Ports clocks remains enabled after this deinitialization.
uint32_t CPAL_I2C_ER_IRQHandler ( CPAL_InitTypeDef pDevInitStruct)

Allows to handle errors occurred during initialization or communication in order to recover the correct communication status or call specific user functions.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASS.
uint32_t CPAL_I2C_EV_IRQHandler ( CPAL_InitTypeDef pDevInitStruct)

This function handles I2C interrupt request for preparing communication and for transfer phase in case of using Interrupt Programming Model.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASS.
uint32_t CPAL_I2C_Init ( CPAL_InitTypeDef pDevInitStruct)

Initialize the peripheral and all related clocks, GPIOs, DMA and Interrupts according to the specified parameters in the CPAL_InitTypeDef structure.

Parameters
pDevInitStruct: Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL
uint32_t CPAL_I2C_IsDeviceReady ( CPAL_InitTypeDef pDevInitStruct)

Wait until target device is ready for communication (This function is used with Memory devices).

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL.
uint32_t CPAL_I2C_Read ( CPAL_InitTypeDef pDevInitStruct)

Allows to receive a data or a buffer of data through the peripheral from a selected device in a selected location address.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL.
uint32_t CPAL_I2C_StructInit ( CPAL_InitTypeDef pDevInitStruct)

Initialize the peripheral structure with default values according to the specified parameters in the CPAL_I2CDevTypeDef structure.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL.
void CPAL_I2C_TIMEOUT_Manager ( void  )

This function Manages I2C Timeouts when waiting for specific events.

Parameters
None
Return values
CPAL_PASSor CPAL_FAIL.
uint32_t CPAL_I2C_Write ( CPAL_InitTypeDef pDevInitStruct)

Allows to send a data or a buffer of data through the peripheral to a selected device in a selected location address.

Parameters
pDevInitStruct,:Pointer to the peripheral configuration structure.
Return values
CPAL_PASSor CPAL_FAIL.