STM32F0 CPAL I2C bibliotheek  1.0
ST Microelectronics CPALv2 bibliotheek documentatie
 All Data Structures Files Functions Variables Enumerations Enumerator Macros
stm32f0xx_i2c_cpal_conf_template.h
1 
28 /* Define to prevent recursive inclusion -------------------------------------*/
29 #ifndef __STM32F0XX_I2C_CPAL_CONF_H
30 #define __STM32F0XX_I2C_CPAL_CONF_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------*/
37 /* Exported types ------------------------------------------------------------*/
38 /* Exported constants --------------------------------------------------------*/
39 
40 /*=======================================================================================================================================
41  User NOTES
42 =========================================================================================================================================
43 
44 -------------------------------
45 1. How To use the CPAL Library:
46 -------------------------------
47 
48 ------- Refer to the user manual of the library and (eventually) the example to check if
49  this firmware is appropriate for your hardware (device and (eventually) evaluation board)
50 
51  - Section 1 : Select the Device instances to be used and the total number of devices
52 
53  - Section 2 : Configure Transfer Options
54 
55  - Section 3 : Select and configure transfer and error user Callbacks
56 
57  - Section 4 : Configure Timeout mechanism and TimeoutCallback
58 
59  - Section 5 : Configure Interrupt Priority Offset
60 
61  - Section 6 : Configure CPAL_LOG Macro
62 
63 ------ After configuring CPAL firmware functionality , You should proceed by configuring hardware used with CPAL
64  (please refer to stm32f0xx_i2c_cpal_hal.h file).
65 
66 ------ After configuring CPAL Firmware Library, you should follow these steps to use the Firmware correctly :
67 
68  -1- STRUCTURE INITIALIZATION
69  Start by initializing the Device. To perform this action, the global variable PPPx_DevStructure declared
70  in CPAL Firmware as CPAL_InitTypeDef (I2C1_DevStructure for I2C1, I2C2_DevStructure for I2C2 ...) must be used.
71  There are two ways to proceed :
72 
73  ** Call the function CPAL_PPP_StructInit() using as parameter PPPx_DevStructure (where PPP = device type (ie. I2C...)
74  and where x could be 1 for PPP1, 2 for PPP2 ...). This function sets the default values for all fields of this structure.
75 
76  Default values for I2C devices are :
77  I2Cx_DevStructure.CPAL_Direction = CPAL_DIRECTION_TXRX
78  I2Cx_DevStructure.CPAL_Mode = CPAL_MODE_MASTER
79  I2Cx_DevStructure.CPAL_ProgModel = CPAL_PROGMODEL_DMA
80  I2Cx_DevStructure.pCPAL_TransferTx = pNULL
81  I2Cx_DevStructure.pCPAL_TransferRx = pNULL
82  I2Cx_DevStructure.CPAL_State = CPAL_STATE_DISABLED
83  I2Cx_DevStructure.wCPAL_DevError = CPAL_I2C_ERR_NONE
84  I2Cx_DevStructure.wCPAL_Options = 0 (all options disabled)
85  I2Cx_DevStructure.wCPAL_Timeout = CPAL_TIMEOUT_DEFAULT
86  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_Mode = I2C_Mode_I2C
87  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_AnalogFilter = I2C_AnalogFilter_Enable
88  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_DigitalFilter = 0x00
89  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_OwnAddress1 = 0
90  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_Ack = I2C_Ack_Enable
91  I2Cx_DevStructure.pCPAL_I2C_Struct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit
92 
93 
94  pCPAL_TransferTx and pCPAL_TransferRx fields have to be updated in order to point to valid structures
95  (these structures should be local/global variables in the user application).
96 
97  ** Another way of configuration is without calling CPAL_PPP_StructInit() function.
98  Declare the following structures:
99  - A PPP_InitTypeDef structure for the device configuration (ie. I2C_InitTypeDef structure)
100  - One or two CPAL_TransferTypeDef variables (one for Tx and one for Rx).
101  - Use the extern structure provided by the CPAL library: PPPx_InitStructure (ie. I2C1_DevStructure).
102  Fill in all the fields for these structures (one by one).
103  Use the pointers to these structures to fill in the fields pCPAL_PPP_Struct and pCPAL_TransferTx and/or
104  pCPAL_TransferRx of the PPPx_DevStructure.
105  After that CPAL_State must be set to CPAL_STATE_DISABLED.
106  Finally, call the CPAL_PPP_Init() with pointer to the PPPx_DevStructure as argument.
107 
108  Example:
109  // Declare local structures
110  I2C_InitTypeDef I2C1_InitStructure;
111  CPAL_TransferTypeDef TX_Transfer, RX_Transfer;
112  // Fill in all the fields of to these structures
113  I2Cx_InitStructure.I2C_Timing = 0X50321312;
114  I2Cx_InitStructure.I2C_Mode = I2C_Mode_I2C;
115  I2Cx_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Disable;
116  .....
117  TX_Transfer.pbBuffer = 0;
118  TX_Transfer.wNumData = 0;
119  .....
120  RX_Transfer.pbBuffer = 0;
121  RX_Transfer.wNumData = 0;
122  .....
123  // Use these structures and fill all fields of I2C1_DevStructure.
124  I2C1_DevStructure.CPAL_Dev = CPAL_I2C1;
125  I2C1_DevStructure.CPAL_Direction = CPAL_DIRECTION_TXRX;
126  I2C1_DevStructure.CPAL_Mode = CPAL_MODE_SLAVE;
127  I2C1_DevStructure.wCPAL_Options = CPAL_OPT_DMATX_TCIT | CPAL_OPT_DMATX_HTIT ;
128  .....
129  I2C1_DevStructure.pCPAL_TransferTx = &TX_Transfer;
130  I2C1_DevStructure.pCPAL_TransferRx = &RX_Transfer;
131  I2C1_DevStructure.pCPAL_I2C_Struct = &I2C1_InitStructure;
132  ...
133  I2C1_DevStructure.wCPAL_State = CPAL_STATE_DISABLED;
134  ....
135  CPAL_I2C_Init(&I2C1_DevStructure);
136 
137  -2- DEVICE CONFIGURATION
138  Call the function CPAL_PPP_Init() to configure the selected device with the selected configuration by calling
139  CPAL_PPP_Init(). This function also enables device clock and initialize all related peripherals ( GPIO, DMA , IT and NVIC ).
140  This function tests on CPAL_State, if it is equal to CPAL_STATE_BUSY it exit, otherwise device initialization is
141  performed and CPAL_State is set to CPAL_STATE_READY.
142  This function returns CPAL_PASS state when the operation is correctly performed, or CPAL_FAIL when the current state of the
143  device doesn't allow configuration (ie. state different from READY, DISABLED or ERROR).
144  After calling this function, you may check on the new state of device, when it is equal to CPAL_STATE_READY, Transfer operations
145  can be started, otherwise you can call CPAL_PPP_DeInit() to deinitialize device and call CPAL_PPP_Init() once again.
146 
147  -3- READ / WRITE OPERATIONS
148  Call the function CPAL_PPP_Write() or CPAL_PPP_Read() to perform transfer operations.
149  These functions handle communication events using device event interrupts (independently of programming model used: DMA,
150  Interrupt). These functions start preparing communication (send start condition, send salve address in case of
151  master mode ...) if connection is established between devices CPAL_State is set CPAL_STATE_BUSY_XX and data transfer starts.
152  By default, Error interrupts are enabled to manage device errors (Error interrupts can be disabled by affecting
153  CPAL_OPT_I2C_ERRIT_DISABLE to wCPAL_Options). When transfer is completed successfully, CPAL_State is set to CPAL_STATE_READY
154  and another operation can be started.
155  These functions return CPAL_PASS if the current state of the device allows starting a new operation and the operation is correctly
156  started (but not finished). It returns CPAL_FAIL when the state of the device doesn't allow starting a new communication (ie.
157  BUSY, DISABLED, ERROR) or when an error occurs during operation start.
158  Once operation is started, user application may perform other tasks while CPAL is sending/receiving data on device through interrupt
159  or DMA.
160 
161  -4- DEVICE DEINITIALIZATION
162  When transfer operations are finished, you may call CPAL_PPP_DeInit() to disable PPPx device and related resources
163  ( GPIO, DMA , IT and NVIC). CPAL_State is then set to CPAL_STATE_DISABLED by this function.
164 
165 
166 
167 ------ Callbacks are routines that let you insert your own code in different stages of communication and for handling
168  device errors. Their prototypes are declared by the CPAL library (if the relative define in this stm32f0xx_i2c_cpal_conf.h is enabled)
169  but their body is not implemented by CPAL library. It may be done by user when needed.
170  There are three types of Callbacks: Transfer User Callbacks, Error User Callbacks and Timeout User Callbacks:
171 
172  -a- Transfer User Callbacks :
173 
174  ** CPAL_I2C_TX_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
175  This function is called before sending data when Interrupt Programming Model is selected.
176 
177  ** CPAL_I2C_RX_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
178  This function is called after receiving data when Interrupt Programming Model is selected.
179 
180  ** CPAL_I2C_TXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
181  ** CPAL_I2C_RXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
182  These functions are called when a transfer is complete when using Interrupt programming model or DMA
183  programming model.
184 
185  ** CPAL_I2C_DMATXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
186  ** CPAL_I2C_DMATXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
187  These functions are called when Transfer complete Interrupt occurred in transmission/reception operation
188  if DMA Programming Model is selected
189 
190  ** CPAL_I2C_DMATXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
191  ** CPAL_I2C_DMARXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
192  These functions are called when Half transfer Interrupt occurred in transmission/reception operation
193  if DMA Programming Model is selected.
194 
195  ** CPAL_I2C_DMATXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
196  ** CPAL_I2C_DMARXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
197  These functions are called when a transfer error Interrupt occurred in transmission/reception operation
198  if DMA Programming Model is selected.
199 
200  ** CPAL_I2C_GENCALL_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
201  This function is called when an Address Event interrupt occurred and General Call Address Flag is set
202  (available in Slave mode only and when the option CPAL_OPT_I2C_GENCALL is enabled).
203 
204  ** CPAL_I2C_DUALF_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
205  This function is called when an Address Event interrupt occurred and Dual Address Flag is set
206  (available in Slave mode only and when the option CPAL_OPT_I2C_DUALADDR is enabled).
207 
208 
209  -b- Error User Callbacks :
210 
211  ** CPAL_I2C_ERR_UserCallback(CPAL_DevTypeDef pDevInstance, uint32_t Device_Error)
212  This function is called either when an Error Interrupt occurred (If Error Interrupts enabled) or after
213  a read or write operations to handle device errors (If Error Interrupts disabled). This callback
214  can be used to handle all device errors. It is available only when the define USE_SINGLE_ERROR_CALLBACK
215  is enabled (Section 5).
216 
217  ** CPAL_I2C_BERR_UserCallback(CPAL_DevTypeDef pDevInstance)
218  This function is called either when a Bus Error Interrupt occurred (If Error Interrupts enabled) or
219  after a read or write operations to handle this error (If Error Interrupts disabled). This callback is
220  available only when USE_MULTIPLE_ERROR_CALLBACK is enabled (Section 5).
221 
222  ** CPAL_I2C_ARLO_UserCallback(CPAL_DevTypeDef pDevInstance)
223  This function is called either when an Arbitration Lost Interrupt occurred (If Error Interrupts
224  enabled) or after a read or write operations to handle this error (If Error Interrupts disabled).
225 
226  ** CPAL_I2C_OVR_UserCallback(CPAL_DevTypeDef pDevInstance)
227  This function is called either when an Overrun Interrupt occurred (If Error Interrupts enabled) or
228  after a read or write operations to handle this error (If Error Interrupts disabled). This callback is
229  available only when USE_MULTIPLE_ERROR_CALLBACK is enabled (Section 5).
230 
231  ** CPAL_I2C_AF_UserCallback(CPAL_DevTypeDef pDevInstance)
232  This function is called either when an Acknowledge Failure Interrupt occurred (If Error Interrupts
233  enabled) or after a read or write operations to handle this error (If Error Interrupts disabled).
234  This callback is available only when USE_MULTIPLE_ERROR_CALLBACK is enabled (Section 5).
235 
236 
237  -c- Timeout User Callbacks :
238  ** CPAL_TIMEOUT_UserCallback(void)
239  This function is called when a Timeout occurred in communication.
240 
241  ** CPAL_TIMEOUT_INIT()
242  This function allows to configure and enable the counting peripheral/function (ie. SysTick Timer)
243  It is called into all CPAL_PPP_Init() functions.
244 
245  ** CPAL_TIMEOUT_DEINIT()
246  This function allow to free the resources of counting peripheral/function and stop the count.
247  (ie. disable the SysTick timer and its interrupt).
248 
249  ** CPAL_PPP_TIMEOUT_Manager()
250  WARNING: DO NOT IMPLEMENT THIS FUNCTION (already implemented in CPAL drivers)
251  This function is already implemented in the CPAL drivers (stm32f0xx_i2c_cpal.c file). It should be called periodically
252  (using the count mechanism interrupt for example). This function checks all PPP devices and
253  manages timeout conditions. In case of timeout occurring, this function calls the
254  CPAL_TIMEOUT_UserCallback() function that may be implemented by user to manage the cases of
255  timeout errors (ie. reset the device/microcontroller...).
256  In order to facilitate implementation, this function (instead to be called periodically by user
257  application), may be mapped directly to a periodic event/interrupt:
258  Example:
259  #define CPAL_I2C_TIMEOUT_Manager SysTick_Handler
260 
261  ** Note ** : when mapping CPAL_I2C_TIMEOUT_Manager to a periodic event/interrupt, the prototype
262  of this event/interrupt should be added. Here below an example when SysTick_Handler
263  is used to handle timeout mechanism :
264  #ifndef CPAL_I2C_TIMEOUT_Manager
265  void CPAL_I2C_TIMEOUT_Manager(void);
266  #else
267  void SysTick_Handler(void);
268  #endif
269 
270  To implement Transfer and Error Callbacks, you should comment relative defines in Section 4 and implement Callback function (body) into
271  your application (their prototypes are declared in stm32f0xx_i2c_cpal.h file).
272 
273  Example: How to implement CPAL_I2C_TX_UserCallback() callback:
274 
275  -1- Comment the relative define in this file :
276  //#define CPAL_I2C_TX_UserCallback (void)
277 
278  -2- Add CPAL_I2C_TX_UserCallback code source in application file ( example : main.c )
279  void CPAL_I2C_TX_UserCallback (CPAL_InitTypeDef* pDevInitStruct)
280  {
281  //
282  // user code
283  //
284  }
285 
286  There are two types of Error Callbacks :
287  -1- Single Error Callback : Only one Callback is used to manage all device errors.
288  -2- Multiple Error Callback : Each device error is managed by its own separate Callback.
289 
290  Example of using CPAL_I2C_BERR_UserCallback :
291 
292  -1- Select Multiple Error Callback type :
293  //#define USE_SINGLE_ERROR_CALLBACK
294  #define USE_MULTIPLE_ERROR_CALLBACK
295 
296  -2- Comment define relative to CPAL_I2C_BERR_UserCallback in stm32f0xx_i2c_cpal_conf.h.h file:
297  //#define CPAL_I2C_BERR_UserCallback (void)
298 
299  -3- Add CPAL_I2C_BERR_UserCallback code source in application file ( example: main.c )
300  void CPAL_I2C_BERR_UserCallback (CPAL_DevTypeDef pDevInstance)
301  {
302  //
303  // user code
304  //
305  }
306 
307 ------ The driver API functions Prototypes are in stm32f0xx_i2c_cpal.h file.
308 
309 *********END OF User Notes***************************************************************************************************************/
310 
311 
312 
313 
314 /*=======================================================================================================================================
315  CPAL Firmware Functionality Configuration
316 =========================================================================================================================================*/
317 
318 /*-----------------------------------------------------------------------------------------------------------------------*/
319 /*-----------------------------------------------------------------------------------------------------------------------*/
320 
321 /* -- Section 1 : **** I2Cx Device Selection ****
322 
323  Description: This section provide an easy way to select I2Cx devices in user application.
324  Choosing device allows to save memory resources.
325  If you need I2C1 device, uncomment relative define: #define CPAL_USE_I2C1.
326  All available I2Cx device can be used at the same time.
327  At least one I2C device should be selected.*/
328 
329 #define CPAL_USE_I2C1 /*<! Uncomment to use I2C1 device */
330 #define CPAL_USE_I2C2 /*<! Uncomment to use I2C2 device */
331 
332 /*-----------------------------------------------------------------------------------------------------------------------*/
333 /*-----------------------------------------------------------------------------------------------------------------------*/
334 
335 /* -- Section 2 : **** Transfer Options Configuration ****
336 
337  Description: This section allows user to enable/disable some Transfer Options. The benefits of these
338  defines is to minimize the size of the source code */
339 
340 /* Enable the use of Master Mode */
341 #define CPAL_I2C_MASTER_MODE
342 
343 
344 /* Enable the use of Slave Mode */
345 #define CPAL_I2C_SLAVE_MODE
346 
347 
348 /* Enable the use of DMA Programming Model */
349 #define CPAL_I2C_DMA_PROGMODEL
350 
351 
352 /* Enable the use of IT Programming Model */
353 #define CPAL_I2C_IT_PROGMODEL
354 
355 
356 /* !!!! These following defines are available only when CPAL_I2C_MASTER_MODE is enabled !!!! */
357 
358 /* Enable the use of 10Bit Addressing Mode */
359 #define CPAL_I2C_10BIT_ADDR_MODE
360 
361 /* Enable the use of Memory Addressing Mode */
362 #define CPAL_I2C_MEM_ADDR
363 
364 /* Enable the use of 16Bit Address memory register option */
365 #define CPAL_16BIT_REG_OPTION
366 
367 
368 /*------------------------------------------------------------------------------------------------------------------------------*/
369 /*------------------------------------------------------------------------------------------------------------------------------*/
370 
371 /* -- Section 3 : **** UserCallbacks Selection and Configuration ****
372 
373  Description: This section provides an easy way to enable UserCallbacks and select type of Error UserCallbacks.
374  By default, All UserCallbacks are disabled (UserCallbacks are defined as void functions).
375  To implement a UserCallbacks in your application, comment the relative define and
376  implement the callback body in your application file.*/
377 
378 
379 /* Error UserCallbacks Type : Uncomment to select UserCallbacks type. One type must be selected */
380 /* Note : if Error UserCallbacks are not used the two following defines must be commented
381 
382  WARNING: These two defines are EXCLUSIVE, only one define should be uncommented !
383  */
384 //#define USE_SINGLE_ERROR_CALLBACK /*<! select single UserCallbacks type */
385 //#define USE_MULTIPLE_ERROR_CALLBACK /*<! select multiple UserCallbacks type */
386 
387 /* Error UserCallbacks : To use an Error UserCallback comment the relative define */
388 
389 /* Single Error Callback */
390 #define CPAL_I2C_ERR_UserCallback (void)
391 
392 /* Multiple Error Callback */
393 #define CPAL_I2C_BERR_UserCallback (void)
394 #define CPAL_I2C_ARLO_UserCallback (void)
395 #define CPAL_I2C_OVR_UserCallback (void)
396 #define CPAL_I2C_AF_UserCallback (void)
397 
398 /* Transfer UserCallbacks : To use a Transfer callback comment the relative define */
399 #define CPAL_I2C_TX_UserCallback (void)
400 #define CPAL_I2C_RX_UserCallback (void)
401 #define CPAL_I2C_TXTC_UserCallback (void)
402 #define CPAL_I2C_RXTC_UserCallback (void)
403 
404 /* DMA Transfer UserCallbacks : To use a DMA Transfer UserCallbacks comment the relative define */
405 #define CPAL_I2C_DMATXTC_UserCallback (void)
406 #define CPAL_I2C_DMATXHT_UserCallback (void)
407 #define CPAL_I2C_DMATXTE_UserCallback (void)
408 #define CPAL_I2C_DMARXTC_UserCallback (void)
409 #define CPAL_I2C_DMARXHT_UserCallback (void)
410 #define CPAL_I2C_DMARXTE_UserCallback (void)
411 
412 /* Address Mode UserCallbacks : To use an Address Mode UserCallbacks comment the relative define */
413 #define CPAL_I2C_GENCALL_UserCallback (void)
414 #define CPAL_I2C_DUALF_UserCallback (void)
415 
416 /* CriticalSectionCallback : Call User callback for critical section (should typically disable interrupts) */
417 #define CPAL_EnterCriticalSection_UserCallback __disable_irq
418 #define CPAL_ExitCriticalSection_UserCallback __enable_irq
419 
420 /*------------------------------------------------------------------------------------------------------------------------------------------------*/
421 /*------------------------------------------------------------------------------------------------------------------------------------------------*/
422 
423 /* -- Section 4 : **** Configure Timeout method, TimeoutCallback ****
424 
425  Description: This section allows you to implement your own Timeout Procedure.
426  By default Timeout procedure is implemented with Systick timer and
427  CPAL_I2C_TIMEOUT_Manager is defined as SysTick_Handler.
428  */
429 
430 
431 #define _CPAL_TIMEOUT_INIT() SysTick_Config((SystemCoreClock / 1000));\
432  NVIC_SetPriority (SysTick_IRQn, 0)
433  /*<! Configure and enable the systick timer
434  to generate an interrupt when counter value
435  reaches 0. In the Systick interrupt handler
436  the Timeout Error function is called. Time base is 1 ms */
437 
438 #define _CPAL_TIMEOUT_DEINIT() SysTick->CTRL = 0 /*<! Disable the systick timer */
439 
440 
441 #define CPAL_I2C_TIMEOUT_Manager SysTick_Handler /*<! This callback is used to handle Timeout error.
442  When a timeout occurs CPAL_TIMEOUT_UserCallback
443  is called to handle this error */
444 #ifndef CPAL_I2C_TIMEOUT_Manager
445  void CPAL_I2C_TIMEOUT_Manager(void);
446 #else
447  void SysTick_Handler(void);
448 #endif /* CPAL_I2C_TIMEOUT_Manager */
449 
450 /*#define CPAL_TIMEOUT_UserCallback (void) */ /*<! Comment this line and implement the callback body in your
451  application in order to use the Timeout Callback.
452  It is strongly advised to implement this callback, since it
453  is the only way to manage timeout errors.*/
454 
455 /* Maximum Timeout values for each communication operation (preferably, Time base should be 1 Millisecond).
456  The exact maximum value is the sum of event timeout value and the CPAL_I2C_TIMEOUT_MIN value defined below */
457 #define CPAL_I2C_TIMEOUT_TC 5
458 #define CPAL_I2C_TIMEOUT_TCR 5
459 #define CPAL_I2C_TIMEOUT_TXIS 2
460 #define CPAL_I2C_TIMEOUT_BUSY 2
461 
462 /* DO NOT MODIFY THESE VALUES ---------------------------------------------------------*/
463 #define CPAL_I2C_TIMEOUT_DEFAULT ((uint32_t)0xFFFFFFFF)
464 #define CPAL_I2C_TIMEOUT_MIN ((uint32_t)0x00000001)
465 #define CPAL_I2C_TIMEOUT_DETECTED ((uint32_t)0x00000000)
466 
467 /*-----------------------------------------------------------------------------------------------------------------------*/
468 /*-----------------------------------------------------------------------------------------------------------------------*/
469 
470 /* -- Section 5 : **** Configure Interrupt Priority Offset ****
471 
472  Description: This section allows user to configure Interrupt Priority Offset.
473  By default Priority Offset of I2Cx device (ERR, EVT, DMA) are set to 0 */
474 
475 /*-----------Interrupt Priority Offset-------------*/
476 
477 /* This defines can be used to decrease the Level of Interrupt Priority for I2Cx Device (ERR, EVT, DMA_TX, DMA_RX).
478  The value of I2Cx_IT_OFFSET_SUBPRIO is added to I2Cx_IT_XXX_SUBPRIO and the value of I2Cx_IT_OFFSET_PREPRIO
479  is added to I2Cx_IT_XXX_PREPRIO (XXX: ERR, EVT, DMATX, DMARX).
480  I2Cx Interrupt Priority are defined in stm32f0xx_i2c_cpal_hal.h file in Section 3 */
481 
482 #define I2C1_IT_OFFSET_SUBPRIO 0 /* I2C1 SUB-PRIORITY Offset */
483 #define I2C1_IT_OFFSET_PREPRIO 0 /* I2C1 PREEMPTION PRIORITY Offset */
484 
485 #define I2C2_IT_OFFSET_SUBPRIO 0 /* I2C2 SUB-PRIORITY Offset */
486 #define I2C2_IT_OFFSET_PREPRIO 0 /* I2C2 PREEMPTION PRIORITY Offset */
487 
488 /*-----------------------------------------------------------------------------------------------------------------------*/
489 /*-----------------------------------------------------------------------------------------------------------------------*/
490 
491 /* -- Section 6 : **** CPAL DEBUG Configuration ****
492 
493  Description: This section allow user to enable or disable CPAL Debug option. Enabling this option provide
494  to user an easy way to debug the application code. This option use CPAL_LOG Macro that integrate
495  printf function. User can retarget printf function to USART ( use hyperterminal), LCD Screen
496  on ST Eval Board or development toolchain debugger.
497  In this example, the log is managed through printf function routed to USART peripheral and allowing
498  to display messages on Hyperterminal-like terminals. This is performed through redefining the
499  function PUTCHAR_PROTOTYPE (depending on the compiler) as follows:
500 
501  #ifdef __GNUC__
502  // With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
503  // set to 'Yes') calls __io_putchar()
504  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
505  #else
506  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
507  #endif
508 
509  WARNING Be aware that enabling this feature may slow down the communication process, increase the code size
510  significantly, and may in some cases cause communication errors (when print/display mechanism is too slow)*/
511 
512 
513 /* To Enable CPAL_DEBUG Option Uncomment the define below */
514 //#define CPAL_DEBUG
515 
516 #ifdef CPAL_DEBUG
517 #define CPAL_LOG(Str) printf(Str)
518 #include <stdio.h> /* This header file must be included when using CPAL_DEBUG option */
519 #else
520 #define CPAL_LOG(Str) ((void)0)
521 #endif /* CPAL_DEBUG */
522 
523 
524 /*-----------------------------------------------------------------------------------------------------------------------*/
525 /*-----------------------------------------------------------------------------------------------------------------------*/
526 
527 /*********END OF CPAL Firmware Functionality Configuration****************************************************************/
528 
529 /* Exported macro ------------------------------------------------------------*/
530 /* Exported functions ------------------------------------------------------- */
531 
532 #ifdef __cplusplus
533 }
534 #endif
535 
536 #endif /* __STM32F0XX_I2C_CPAL_CONF_H */
537 
538 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/