iLLD_TC29x  1.0
IfxI2c.h
Go to the documentation of this file.
1 /**
2  * \file IfxI2c.h
3  * \brief I2C basic functionality
4  * \ingroup IfxLld_I2c
5  *
6  * \version iLLD_1_0_0_11_0
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  * \defgroup IfxLld_I2c_Std_enums Enumerations
25  * \ingroup IfxLld_I2c_Std
26  * \defgroup IfxLld_I2c_Std_functions Functions
27  * \ingroup IfxLld_I2c_Std
28  * \defgroup IfxLld_I2c_Std_structures Data Structures
29  * \ingroup IfxLld_I2c_Std
30  */
31 
32 #ifndef IFXI2C_H
33 #define IFXI2C_H 1
34 
35 /******************************************************************************/
36 /*----------------------------------Includes----------------------------------*/
37 /******************************************************************************/
38 
39 #include "_Impl/IfxI2c_cfg.h"
40 #include "Scu/Std/IfxScuWdt.h"
41 #include "Scu/Std/IfxScuCcu.h"
42 #include "IfxI2c_reg.h"
43 #include "IfxI2c_bf.h"
44 #include "_PinMap/IfxI2c_PinMap.h"
45 #include "Src/Std/IfxSrc.h"
46 
47 /******************************************************************************/
48 /*--------------------------------Enumerations--------------------------------*/
49 /******************************************************************************/
50 
51 /** \addtogroup IfxLld_I2c_Std_enums
52  * \{ */
53 typedef enum
54 {
55  IfxI2c_BusStatus_idle = 0, /**< \brief idle */
56  IfxI2c_BusStatus_started = 1, /**< \brief started */
57  IfxI2c_BusStatus_busyMaster = 2, /**< \brief busy Master */
58  IfxI2c_BusStatus_remoteSlave = 3 /**< \brief remote Slave */
60 
61 /** \brief enable error interrupt request source
62  * Definition in Ifx.I2C.ERRIRQSM.U
63  */
64 typedef enum
65 {
66  IfxI2c_ErrorInterruptSource_rxFifoUnderflow = IFX_I2C_ERRIRQSM_RXF_UFL_OFF, /**< \brief receive fifo underflow service request */
67  IfxI2c_ErrorInterruptSource_rxFifoOverflow = IFX_I2C_ERRIRQSM_RXF_OFL_OFF, /**< \brief receive fifo overflow service request */
68  IfxI2c_ErrorInterruptSource_txFifoUnderflow = IFX_I2C_ERRIRQSM_TXF_UFL_OFF, /**< \brief transmit fifo underflow service request */
69  IfxI2c_ErrorInterruptSource_txFifoOverflow = IFX_I2C_ERRIRQSM_TXF_OFL_OFF /**< \brief transmit fifo overflow service request */
71 
72 typedef enum
73 {
83 
84 /** \brief enable protocol interrupt source
85  * Definition in Ifx.I2C.PIRQSM.U
86  */
87 typedef enum
88 {
89  IfxI2c_ProtocolInterruptSource_addressMatch = IFX_I2C_PIRQSM_AM_OFF, /**< \brief address match service request */
90  IfxI2c_ProtocolInterruptSource_generalCall = IFX_I2C_PIRQSM_GC_OFF, /**< \brief general call service request */
91  IfxI2c_ProtocolInterruptSource_masterCode = IFX_I2C_PIRQSM_MC_OFF, /**< \brief master code service request */
92  IfxI2c_ProtocolInterruptSource_arbitrationLost = IFX_I2C_PIRQSM_AL_OFF, /**< \brief arbitration lost service request */
93  IfxI2c_ProtocolInterruptSource_notAcknowledgeReceived = IFX_I2C_PIRQSM_NACK_OFF, /**< \brief not acknowledge received service request */
94  IfxI2c_ProtocolInterruptSource_transmissionEnd = IFX_I2C_PIRQSM_TX_END_OFF, /**< \brief transmission end service request */
95  IfxI2c_ProtocolInterruptSource_receiveMode = IFX_I2C_PIRQSM_RX_OFF /**< \brief receive mode service request */
97 
98 /** \brief Enable/disable the sensitivity of the module to sleep signal\n
99  * Definition in Ifx_I2C.CLC1.B.EDIS
100  */
101 typedef enum
102 {
103  IfxI2c_SleepMode_enable = 0, /**< \brief enables sleep mode */
104  IfxI2c_SleepMode_disable = 1 /**< \brief disables sleep mode */
106 
107 /** \} */
108 
109 /******************************************************************************/
110 /*-----------------------------Data Structures--------------------------------*/
111 /******************************************************************************/
112 
113 /** \addtogroup IfxLld_I2c_Std_structures
114  * \{ */
115 /** \brief Pin Structure
116  */
117 typedef struct
118 {
122 } IfxI2c_Pins;
123 
124 /** \} */
125 
126 /** \addtogroup IfxLld_I2c_Std_functions
127  * \{ */
128 
129 /******************************************************************************/
130 /*-------------------------Inline Function Prototypes-------------------------*/
131 /******************************************************************************/
132 
133 /** \brief Returns if the bus is free
134  */
135 IFX_INLINE boolean IfxI2c_busIsFree(Ifx_I2C *i2c);
136 
137 /** \brief clears all Error Interrupt sources
138  * \param i2c pointer to i2c registers
139  * \return None
140  */
142 
143 /** \brief Clears all Protocol Interrupt sources
144  * \param i2c pointer to i2c registers
145  * \return None
146  */
148 
149 /** \brief clears burst request interrupt source
150  * \param i2c pointer to i2c registers
151  * \return None
152  */
154 
155 /** \brief clears the specified source of error interrupt
156  * \param i2c pointer to i2c registers
157  * \param source error interrupt source
158  * \return None
159  */
161 
162 /** \brief clears last burst request interrupt source
163  * \param i2c pointer to i2c registers
164  * \return None
165  */
167 
168 /** \brief clears last single request interrupt source
169  * \param i2c pointer to i2c registers
170  * \return None
171  */
173 
174 /** \brief clears the specified source of protocol interrupt
175  * \param i2c pointer to i2c registers
176  * \param source protocol interrupt source
177  * \return None
178  */
180 
181 /** \brief clears single request interrupt source
182  * \param i2c pointer to i2c registers
183  * \return None
184  */
186 
187 /** \brief disables burst request interrupt source
188  * \param i2c pointer to i2c registers
189  * \return None
190  */
192 
193 /** \brief disables the error interrupt flag
194  * \param i2c pointer to i2c registers
195  * \return None
196  */
198 
199 /** \brief disables the specified source of error interrupt
200  * \param i2c pointer to i2c registers
201  * \param source error interrupt source
202  * \return None
203  */
205 
206 /** \brief disables last burst request interrupt source
207  * \param i2c pointer to i2c registers
208  * \return None
209  */
211 
212 /** \brief disables last single request interrupt source
213  * \param i2c pointer to i2c registers
214  * \return None
215  */
217 
218 /** \brief disables the Protocol interrupt flag
219  * \param i2c pointer to i2c registers
220  * \return None
221  */
223 
224 /** \brief disables the specified source of protocol interrupt
225  * \param i2c pointer to i2c registers
226  * \param source protocol interrupt source
227  * \return None
228  */
230 
231 /** \brief disables single request interrupt source
232  * \param i2c pointer to i2c registers
233  * \return None
234  */
236 
237 /** \brief enables burst request interrupt source
238  * \param i2c pointer to i2c registers
239  * \return None
240  */
242 
243 /** \brief enables the error interrupt flag
244  * \param i2c pointer to i2c registers
245  * \return None
246  */
248 
249 /** \brief enables the specified source of error interrupt
250  * \param i2c pointer to i2c registers
251  * \param source error interrupt source
252  * \return None
253  */
255 
256 /** \brief enables last burst request interrupt source
257  * \param i2c pointer to i2c registers
258  * \return None
259  */
261 
262 /** \brief enables last single request interrupt source
263  * \param i2c pointer to i2c registers
264  * \return None
265  */
267 
268 /** \brief enables the protocol interrupt flag
269  * \param i2c pointer to I2C registers
270  * \return None
271  */
273 
274 /** \brief enables the specified source of protocol interrupt
275  * \param i2c pointer to I2C registers
276  * \param source protocol interrupt source
277  * \return None
278  */
280 
281 /** \brief enables single request interrupt source
282  * \param i2c pointer to i2c registers
283  * \return None
284  */
286 
287 /** \brief Returns the SRC pointer for I2C burst data transfer request interrupt
288  * \param i2c pointer to i2c registers
289  * \return SRC pointer for I2C burst data transfer Service interrupt
290  */
291 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getBurstDataTransferSrcPointer(Ifx_I2C *i2c);
292 
293 /** \brief returns the status of burst request interrupt source status
294  * \param i2c pointer to i2c registers
295  * \return status
296  */
298 
299 /**
300  * \param i2c pointer to i2c registers
301  * \return BusStatus
302  */
304 
305 /** \brief returns the current status of error interrupt flag
306  * \param i2c pointer to i2c registers
307  * \return status
308  */
309 IFX_INLINE boolean IfxI2c_getErrorInterruptFlagStatus(Ifx_I2C *i2c);
310 
311 /** \brief returns the status of the error interrupt source
312  * \param i2c pointer to i2c registers
313  * \param source error interrupt source
314  * \return status
315  */
317 
318 /** \brief Returns the SRC pointer for I2C Error interrupt
319  * \param i2c pointer to i2c registers
320  * \return SRC pointer for I2C Error Service interrupt
321  */
322 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getErrorSrcPointer(Ifx_I2C *i2c);
323 
324 /** \brief Returns the SRC pointer for I2C last burst data transfer request interrupt
325  * \param i2c pointer to i2c registers
326  * \return SRC pointer for I2C last burst data transfer Service interrupt
327  */
328 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getLastBurstDataTransferSrcPointer(Ifx_I2C *i2c);
329 
330 /** \brief returns the status of last burst request interrupt source status
331  * \param i2c pointer to i2c registers
332  * \return status
333  */
335 
336 /** \brief Returns the SRC pointer for I2C last single data transfer request interrupt
337  * \param i2c pointer to i2c registers
338  * \return SRC pointer for I2C last single data transfer Service interrupt
339  */
340 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getLastSingleDataTransferSrcPointer(Ifx_I2C *i2c);
341 
342 /** \brief returns the status of last single request interrupt source status
343  * \param i2c pointer to i2c registers
344  * \return status
345  */
347 
348 /** \brief returns the current raw status of protocol interrupt
349  * \param i2c pointer to i2c registers
350  * \return status
351  */
353 
354 /** \brief returns the status of specified protocol interrupt source
355  * \param i2c pointer to i2c registers
356  * \param source protocol interrupt source
357  * \return status
358  */
360 
361 /** \brief Returns the SRC pointer for I2C Protocol interrupt
362  * \param i2c pointer to i2c registers
363  * \return SRC pointer for I2C Protocol Service interrupt
364  */
365 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getProtocolSrcPointer(Ifx_I2C *i2c);
366 
367 /** \brief Returns the SRC pointer for I2C single data transfer request interrupt
368  * \param i2c pointer to i2c registers
369  * \return SRC pointer for I2C single data transfer Service interrupt
370  */
371 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getSingleDataTransferSrcPointer(Ifx_I2C *i2c);
372 
373 /** \brief returns the status of single request interrupt source status
374  * \param i2c pointer to i2c registers
375  * \return status
376  */
378 
379 /** \brief Returns if the Fifo is requesting new data
380  */
381 IFX_INLINE boolean IfxI2c_isFifoRequest(Ifx_I2C *i2c);
382 
383 /**
384  * \param i2c pointer to i2c registers
385  * \return None
386  */
387 IFX_INLINE void IfxI2c_run(Ifx_I2C *i2c);
388 
389 /** \brief selects the pin
390  * \param i2c pointer to i2c registers
391  * \param pisel pin to be select
392  * \return None
393  */
394 IFX_INLINE void IfxI2c_setPinSelection(Ifx_I2C *i2c, IfxI2c_PinSelect pisel);
395 
396 /** \brief Sets the number of bytes to be received
397  * \param i2c pointer to i2c registers
398  * \param size number of packets
399  * \return None
400  */
401 IFX_INLINE void IfxI2c_setReceivePacketSize(Ifx_I2C *i2c, Ifx_SizeT size);
402 
403 /**
404  * \param i2c pointer to i2c registers
405  * \param address device address
406  * \return None
407  */
408 IFX_INLINE void IfxI2c_setSlaveDeviceAddress(Ifx_I2C *i2c, uint16 address);
409 
410 /** \brief Sets the sensitivity of the module to sleep signal
411  * \param i2c pointer to i2c registers
412  * \param mode mode selection (enable / disable)
413  * \return None
414  */
415 IFX_INLINE void IfxI2c_setSleepMode(Ifx_I2C *i2c, IfxI2c_SleepMode mode);
416 
417 /** \brief Sets the number of bytes to be tansmitted
418  * \param i2c pointer to i2c registers
419  * \param size number of packets
420  * \return None
421  */
422 IFX_INLINE void IfxI2c_setTransmitPacketSize(Ifx_I2C *i2c, Ifx_SizeT size);
423 
424 /**
425  * \param i2c pointer to i2c registers
426  * \return None
427  */
428 IFX_INLINE void IfxI2c_stop(Ifx_I2C *i2c);
429 
430 /**
431  * \param i2c pointer to i2c registers
432  * \return None
433  */
434 IFX_INLINE void IfxI2c_waitBusFree(Ifx_I2C *i2c);
435 
436 /** \brief Writes a packet (4 bytes) into the Fifo
437  * \param i2c pointer to i2c registers
438  * \param packet specifies the byte to be transfer
439  * \return None
440  */
441 IFX_INLINE void IfxI2c_writeFifo(Ifx_I2C *i2c, uint32 packet);
442 
443 /******************************************************************************/
444 /*-------------------------Global Function Prototypes-------------------------*/
445 /******************************************************************************/
446 
447 /** \brief Configures the Module as Master
448  * \param i2c pointer to i2c registers
449  * \return None
450  */
451 IFX_EXTERN void IfxI2c_configureAsMaster(Ifx_I2C *i2c);
452 
453 /** \brief Disables the I2c Module
454  * \param i2c pointer to i2c registers
455  * \return None
456  */
457 IFX_EXTERN void IfxI2c_disableModule(Ifx_I2C *i2c);
458 
459 /** \brief Enables the Burst data transfer interrupt
460  * \param i2c pointer to i2c registers
461  * \param typeOfService Type of Service (Cpu or DMA)
462  * \param priority priority of the interrupt
463  * \return None
464  */
465 IFX_EXTERN void IfxI2c_enableBurstDataTransferInterrupt(Ifx_I2C *i2c, IfxSrc_Tos typeOfService, uint16 priority);
466 
467 /** \brief Enables the Error interrupt
468  * \param i2c pointer to i2c registers
469  * \param typeOfService Type of Service (Cpu or DMA)
470  * \param priority priority of the interrupt
471  * \return None
472  */
473 IFX_EXTERN void IfxI2c_enableErrorInterrupt(Ifx_I2C *i2c, IfxSrc_Tos typeOfService, uint16 priority);
474 
475 /** \brief enables the last burst data transfer interrupt
476  * \param i2c pointer to i2c registers
477  * \param typeOfService Type of Service (Cpu or DMA)
478  * \param priority priority of the interrupt
479  * \return None
480  */
481 IFX_EXTERN void IfxI2c_enableLastBurstDataTransferInterrupt(Ifx_I2C *i2c, IfxSrc_Tos typeOfService, uint16 priority);
482 
483 /** \brief enables the last single data transfer interrupt
484  * \param i2c pointer to i2c registers
485  * \param typeOfService Type of Service (Cpu or DMA)
486  * \param priority priority of the interrupt
487  * \return None
488  */
489 IFX_EXTERN void IfxI2c_enableLastSingleDataTransferInterrupt(Ifx_I2C *i2c, IfxSrc_Tos typeOfService, uint16 priority);
490 
491 /** \brief Enables the I2c Module
492  * \param i2c pointer to i2c registers
493  * \return None
494  */
495 IFX_EXTERN void IfxI2c_enableModule(Ifx_I2C *i2c);
496 
497 /** \brief Enables the protocol interrupt
498  * \param i2c pointer to i2c registers
499  * \param typeOfService Type of Service (Cpu or DMA)
500  * \param priority Priority of the interrupt
501  * \return None
502  */
503 IFX_EXTERN void IfxI2c_enableProtocolInterrupt(void *i2c, IfxSrc_Tos typeOfService, uint16 priority);
504 
505 /** \brief enables the single data transfer interrupt
506  * \param i2c pointer to i2c registers
507  * \param typeOfService Type of Service (Cpu or DMA)
508  * \param priority priority of the interrupt
509  * \return None
510  */
511 IFX_EXTERN void IfxI2c_enableSingleDataTransferInterrupt(Ifx_I2C *i2c, IfxSrc_Tos typeOfService, uint16 priority);
512 
513 /** \brief Returns the real Baudrate
514  * \return Baudrate
515  */
517 
518 /**
519  * \return None
520  */
522 
523 /** \brief Releases the bus, i.e puts a stop condition on the bus
524  * \return None
525  */
526 IFX_EXTERN void IfxI2c_releaseBus(Ifx_I2C *i2c);
527 
528 /**
529  * \return None
530  */
531 IFX_EXTERN void IfxI2c_resetFifo(Ifx_I2C *i2c);
532 
533 /** \brief resets the I2c kernel
534  * \param i2c pointer to i2c registers
535  * \return None
536  */
537 IFX_EXTERN void IfxI2c_resetModule(Ifx_I2C *i2c);
538 
539 /** \brief Calculates the desired baudrate
540  * \param i2c pointer to i2c registers
541  * \param baudrate specifies the baud rate
542  * \return None
543  */
544 IFX_EXTERN void IfxI2c_setBaudrate(Ifx_I2C *i2c, float32 baudrate);
545 
546 /** \} */
547 
548 /******************************************************************************/
549 /*---------------------Inline Function Implementations------------------------*/
550 /******************************************************************************/
551 
552 IFX_INLINE boolean IfxI2c_busIsFree(Ifx_I2C *i2c)
553 {
554  boolean free = FALSE;
555 
556  if (i2c->BUSSTAT.B.BS == IfxI2c_BusStatus_idle)
557  {
558  free = TRUE;
559  }
560 
561  return free;
562 }
563 
564 
566 {
567  i2c->ERRIRQSC.U = (1 << IFX_I2C_ERRIRQSC_RXF_UFL_OFF) | (1 << IFX_I2C_ERRIRQSC_RXF_OFL_OFF) | (1 << IFX_I2C_ERRIRQSC_TXF_UFL_OFF) | (1 << IFX_I2C_ERRIRQSC_TXF_OFL_OFF);
568 }
569 
570 
572 {
573  i2c->PIRQSC.U = (1 << IFX_I2C_PIRQSC_AM_OFF) | (1 << IFX_I2C_PIRQSC_GC_OFF) | (1 << IFX_I2C_PIRQSC_MC_OFF) | (1 << IFX_I2C_PIRQSC_AL_OFF) | (1 << IFX_I2C_PIRQSC_NACK_OFF) | (1 << IFX_I2C_PIRQSC_TX_END_OFF) | (1 << IFX_I2C_PIRQSC_RX_OFF);
574 }
575 
576 
578 {
579  i2c->ICR.B.BREQ_INT = 1;
580 }
581 
582 
584 {
585  i2c->ERRIRQSC.U = (1 << source);
586 }
587 
588 
590 {
591  i2c->ICR.B.LBREQ_INT = 1;
592 }
593 
594 
596 {
597  i2c->ICR.B.LSREQ_INT = 1;
598 }
599 
600 
602 {
603  i2c->PIRQSC.U = (1 << source);
604 }
605 
606 
608 {
609  i2c->ICR.B.SREQ_INT = 1;
610 }
611 
612 
614 {
615  i2c->IMSC.B.BREQ_INT = 0;
616 }
617 
618 
620 {
621  i2c->IMSC.B.I2C_ERR_INT = 0;
622 }
623 
624 
626 {
627  i2c->ERRIRQSM.U &= ~(1 << source);
628 }
629 
630 
632 {
633  i2c->IMSC.B.LBREQ_INT = 0;
634 }
635 
636 
638 {
639  i2c->IMSC.B.LSREQ_INT = 0;
640 }
641 
642 
644 {
645  i2c->IMSC.B.I2C_P_INT = 0;
646 }
647 
648 
650 {
651  i2c->PIRQSM.U &= ~(1 << source);
652 }
653 
654 
656 {
657  i2c->IMSC.B.SREQ_INT = 0;
658 }
659 
660 
662 {
663  i2c->IMSC.B.BREQ_INT = 1;
664 }
665 
666 
668 {
669  i2c->IMSC.B.I2C_ERR_INT = 1;
670 }
671 
672 
674 {
675  i2c->ERRIRQSM.U |= (1 << source);
676 }
677 
678 
680 {
681  i2c->IMSC.B.LBREQ_INT = 1;
682 }
683 
684 
686 {
687  i2c->IMSC.B.LSREQ_INT = 1;
688 }
689 
690 
692 {
693  i2c->IMSC.B.I2C_P_INT = 1;
694 }
695 
696 
698 {
699  i2c->PIRQSM.U |= (1 << source);
700 }
701 
702 
704 {
705  i2c->IMSC.B.SREQ_INT = 1;
706 }
707 
708 
709 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getBurstDataTransferSrcPointer(Ifx_I2C *i2c)
710 {
711  if (i2c == &MODULE_I2C0)
712  {
713  return &MODULE_SRC.I2C.I2C[0].BREQ;
714  }
715  else
716  {
717  return &MODULE_SRC.I2C.I2C[1].BREQ;
718  }
719 }
720 
721 
723 {
724  return i2c->RIS.B.BREQ_INT;
725 }
726 
727 
729 {
730  return (IfxI2c_BusStatus)i2c->BUSSTAT.B.BS;
731 }
732 
733 
735 {
736  return i2c->RIS.B.I2C_ERR_INT;
737 }
738 
739 
741 {
742  return (i2c->ERRIRQSS.U & (1 << source)) ? TRUE : FALSE;
743 }
744 
745 
746 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getErrorSrcPointer(Ifx_I2C *i2c)
747 {
748  if (i2c == &MODULE_I2C0)
749  {
750  return &MODULE_SRC.I2C.I2C[0].ERR;
751  }
752  else
753  {
754  return &MODULE_SRC.I2C.I2C[1].ERR;
755  }
756 }
757 
758 
759 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getLastBurstDataTransferSrcPointer(Ifx_I2C *i2c)
760 {
761  if (i2c == &MODULE_I2C0)
762  {
763  return &MODULE_SRC.I2C.I2C[0].LBREQ;
764  }
765  else
766  {
767  return &MODULE_SRC.I2C.I2C[1].LBREQ;
768  }
769 }
770 
771 
773 {
774  return i2c->RIS.B.LBREQ_INT;
775 }
776 
777 
778 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getLastSingleDataTransferSrcPointer(Ifx_I2C *i2c)
779 {
780  if (i2c == &MODULE_I2C0)
781  {
782  return &MODULE_SRC.I2C.I2C[0].LSREQ;
783  }
784  else
785  {
786  return &MODULE_SRC.I2C.I2C[1].LSREQ;
787  }
788 }
789 
790 
792 {
793  return i2c->RIS.B.LSREQ_INT;
794 }
795 
796 
798 {
799  return i2c->RIS.B.I2C_P_INT;
800 }
801 
802 
804 {
805  return (i2c->PIRQSS.U & (1 << source)) ? TRUE : FALSE;
806 }
807 
808 
809 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getProtocolSrcPointer(Ifx_I2C *i2c)
810 {
811  if (i2c == &MODULE_I2C0)
812  {
813  return &MODULE_SRC.I2C.I2C[0].P;
814  }
815  else
816  {
817  return &MODULE_SRC.I2C.I2C[1].P;
818  }
819 }
820 
821 
822 IFX_INLINE volatile Ifx_SRC_SRCR *IfxI2c_getSingleDataTransferSrcPointer(Ifx_I2C *i2c)
823 {
824  if (i2c == &MODULE_I2C0)
825  {
826  return &MODULE_SRC.I2C.I2C[0].SREQ;
827  }
828  else
829  {
830  return &MODULE_SRC.I2C.I2C[1].SREQ;
831  }
832 }
833 
834 
836 {
837  return i2c->RIS.B.SREQ_INT;
838 }
839 
840 
841 IFX_INLINE boolean IfxI2c_isFifoRequest(Ifx_I2C *i2c)
842 {
843  return i2c->RIS.U & 0x0F ? TRUE : FALSE;
844 }
845 
846 
847 IFX_INLINE void IfxI2c_run(Ifx_I2C *i2c)
848 {
849  i2c->RUNCTRL.U = 1;
850 }
851 
852 
854 {
855  i2c->GPCTL.B.PISEL = pisel;
856 }
857 
858 
860 {
861  i2c->MRPSCTRL.B.MRPS = size;
862 }
863 
864 
865 IFX_INLINE void IfxI2c_setSlaveDeviceAddress(Ifx_I2C *i2c, uint16 address)
866 {
867  i2c->ADDRCFG.B.ADR = address;
868 }
869 
870 
872 {
873  i2c->CLC1.B.EDIS = mode;
874 }
875 
876 
878 {
879  i2c->TPSCTRL.B.TPS = size;
880 }
881 
882 
883 IFX_INLINE void IfxI2c_stop(Ifx_I2C *i2c)
884 {
885  i2c->RUNCTRL.U = 0;
886 }
887 
888 
889 IFX_INLINE void IfxI2c_waitBusFree(Ifx_I2C *i2c)
890 {
892  {}
893 }
894 
895 
896 IFX_INLINE void IfxI2c_writeFifo(Ifx_I2C *i2c, uint32 packet)
897 {
898  i2c->TXD.U = packet;
899 }
900 
901 
902 #endif /* IFXI2C_H */