CC35xxDriverLibrary
i2c.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Filename: i2c.h
3  *
4  * Description: Prototypes and defines for the I2C API.
5  *
6  * Copyright (c) 2023-2024 Texas Instruments Incorporated
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1) Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2) Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3) Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
36 #ifndef __I2C_H__
37 #define __I2C_H__
38 
39 //*****************************************************************************
40 //
45 //
46 //*****************************************************************************
47 
48 //*****************************************************************************
49 //
50 // If building with a C++ compiler, make all of the definitions in this header
51 // have a C binding.
52 //
53 //*****************************************************************************
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 #include "../inc/hw_types.h"
61 #include "../inc/hw_ints.h"
62 #include "../inc/hw_memmap.h"
63 #include "../inc/hw_i2c.h"
64 #include "debug.h"
65 #include "interrupt.h"
66 #include "cpu.h"
67 
68 //*****************************************************************************
69 //
74 //
75 //*****************************************************************************
76 #define I2C_CONTROLLER_CMD_SINGLE_SEND (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP)
77 #define I2C_CONTROLLER_CMD_SINGLE_RECEIVE (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP)
78 #define I2C_CONTROLLER_CMD_BURST_SEND_START (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START)
79 #define I2C_CONTROLLER_CMD_BURST_SEND_CONT (I2C_CCTR_BURSTRUN_EN)
80 #define I2C_CONTROLLER_CMD_BURST_SEND_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
81 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_START \
82  (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN)
83 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_CONT (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN)
84 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
85 #define I2C_CONTROLLER_CMD_BURST_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
86 
88 //*****************************************************************************
89 //
94 //
95 //*****************************************************************************
97 #define I2C_CONTROLLER_TRANSACTION_LENGTH_MAX 0xFFF
98 #define I2C_CONTROLLER_TRANSACTION_LENGTH_SINGLE 0x001
100 #define I2C_CONTROLLER_TRANSACTION_LENGTH_NONE 0x000
103 
105 //*****************************************************************************
106 //
109 //
110 //*****************************************************************************
112 #define I2C_CONTROLLER_CONFIG_DEFAULT 0
113 #define I2C_CONTROLLER_CONFIG_CLOCK_STRETCHING_DETECTION I2C_CCR_CLKSTRETCH_EN
115 #define I2C_CONTROLLER_CONFIG_MULTI_CONTROLLER_MODE I2C_CCR_MCST_EN
117 #define I2C_CONTROLLER_CONFIG_LOOPBACK I2C_CCR_LPBK_EN
119 
121 //*****************************************************************************
122 //
125 //
126 //*****************************************************************************
128 #define I2C_CONTROLLER_DIR_RECEIVE I2C_CSA_DIR_RECEIVE
129 #define I2C_CONTROLLER_DIR_TRANSMIT I2C_CSA_DIR_TRANSMIT
131 
133 //*****************************************************************************
134 //
137 //
138 //*****************************************************************************
140 #define I2C_CONTROLLER_ERR_NONE 0
141 #define I2C_CONTROLLER_ERR_ADDR_ACK I2C_CSR_ADRACK_SET
143 #define I2C_CONTROLLER_ERR_DATA_ACK I2C_CSR_DATACK_SET
145 #define I2C_CONTROLLER_ERR_ARB_LOST I2C_CSR_ARBLST_SET
147 
149 //*****************************************************************************
150 //
153 //
154 //*****************************************************************************
159 #define I2C_INT_ALL 0xFFFFFFFF
160 
162 //*****************************************************************************
163 //
166 //
167 //*****************************************************************************
168 #define I2C_CONTROLLER_INT_RX_DONE I2C_EVENT0_IMASK_CRXDONE
169 #define I2C_CONTROLLER_INT_TX_DONE I2C_EVENT0_IMASK_CTXDONE
170 #define I2C_CONTROLLER_INT_RX_FIFO_TRIGGER I2C_EVENT0_IMASK_RXFIFOTRGC
171 #define I2C_CONTROLLER_INT_TX_FIFO_TRIGGER I2C_EVENT0_IMASK_TXFIFOTRGC
172 #define I2C_CONTROLLER_INT_RX_FIFO_FULL I2C_EVENT0_IMASK_RXFIFOFULLC
173 #define I2C_CONTROLLER_INT_TX_FIFO_FULL I2C_EVENT0_IMASK_TXFIFOFULLC
174 #define I2C_CONTROLLER_INT_TX_FIFO_EMPTY I2C_EVENT0_IMASK_TXEMPTYC
175 #define I2C_CONTROLLER_INT_NACK I2C_EVENT0_IMASK_CNACK
176 #define I2C_CONTROLLER_INT_START I2C_EVENT0_IMASK_CSTART
177 #define I2C_CONTROLLER_INT_STOP I2C_EVENT0_IMASK_CSTOP
178 #define I2C_CONTROLLER_INT_ARB_LOST I2C_EVENT0_IMASK_CARBLOST
179 
181 //*****************************************************************************
182 //
185 //
186 //*****************************************************************************
187 #define I2C_TARGET_INT_RX_DONE I2C_EVENT0_IMASK_TRXDONE
188 #define I2C_TARGET_INT_TX_DONE I2C_EVENT0_IMASK_TTXDONE
189 #define I2C_TARGET_INT_RX_FIFO_TRIGGER I2C_EVENT0_IMASK_RXFIFOTRGT
190 #define I2C_TARGET_INT_TX_FIFO_TRIGGER I2C_EVENT0_IMASK_TXFIFOTRGT
191 #define I2C_TARGET_INT_RX_FIFO_FULL I2C_EVENT0_IMASK_RXFIFOFULLT
192 #define I2C_TARGET_INT_TX_FIFO_FULL I2C_EVENT0_IMASK_TXFIFOFULLT
193 #define I2C_TARGET_INT_TX_FIFO_EMPTY I2C_EVENT0_IMASK_TXEMPTYT
194 #define I2C_TARGET_INT_START I2C_EVENT0_IMASK_TSTART
195 #define I2C_TARGET_INT_STOP I2C_EVENT0_IMASK_TSTOP
196 #define I2C_TARGET_INT_GEN_CALL I2C_EVENT0_IMASK_TGENCALL
197 #define I2C_TARGET_INT_TX_FIFO_UNDERFLOW I2C_EVENT0_IMASK_TX_UNFL_T
198 #define I2C_TARGET_INT_ARB_LOST I2C_EVENT0_IMASK_CARBLOST
199 
201 //*****************************************************************************
202 //
205 //
206 //*****************************************************************************
208 #define I2C_MODE_STANDARD 0
209 #define I2C_MODE_FAST 1
211 #define I2C_MODE_FAST_PLUS 2
213 
215 //*****************************************************************************
216 //
219 //
220 //*****************************************************************************
222 #define I2C_CONTROLLER_ADDR_MODE_7_BIT I2C_CSA_CMODE_SEVEN_BIT
223 #define I2C_CONTROLLER_ADDR_MODE_10_BIT I2C_CSA_CMODE_TEN_BIT
225 
227 //*****************************************************************************
228 //
231 //
232 //*****************************************************************************
234 #define I2C_TARGET_ADDR_MODE_7_BIT I2C_TOAR_MODE_SEVEN_BIT
235 #define I2C_TARGET_ADDR_MODE_10_BIT I2C_TOAR_MODE_TEN_BIT
237 
239 //*****************************************************************************
240 //
243 //
244 //*****************************************************************************
245 #define I2C_RX_FIFO_SIZE (I2C_FIFOSR_RXFIFOCNT_MAXIMUM >> I2C_FIFOSR_RXFIFOCNT_S)
246 #define I2C_TX_FIFO_SIZE (I2C_FIFOSR_TXFIFOCNT_MAXIMUM >> I2C_FIFOSR_TXFIFOCNT_S)
247 
249 //*****************************************************************************
250 //
251 // API Functions and prototypes
252 //
253 //*****************************************************************************
254 
255 #ifdef DRIVERLIB_DEBUG
256 //*****************************************************************************
257 //
268 //
269 //*****************************************************************************
270 static bool I2CIsBaseValid(uint32_t base)
271 {
272  return (base == I2C0_BASE || base == I2C1_BASE);
273 }
274 #endif
275 
276 //*****************************************************************************
277 //
301 //
302 //*****************************************************************************
303 extern void I2CControllerInit(uint32_t base, uint32_t config, uint32_t mode);
304 
305 //*****************************************************************************
306 //
391 //
392 //*****************************************************************************
393 __STATIC_INLINE void I2CControllerSetCommand(uint32_t base, uint32_t cmd, uint16_t transactionLength)
394 {
395  // Check the arguments.
396  ASSERT(I2CIsBaseValid(base));
398  // (cmd == I2C_CONTROLLER_CMD_SINGLE_RECEIVE) || -> Equal to SINGLE_SEND
402  // (cmd == I2C_CONTROLLER_CMD_BURST_RECEIVE_FINISH) || -> Equal to I2C_CONTROLLER_CMD_BURST_SEND_FINISH
403  // (cmd == I2C_CONTROLLER_CMD_BURST_FINISH) || -> Equal to I2C_CONTROLLER_CMD_BURST_SEND_FINISH
404  );
405  ASSERT(transactionLength <= 0xFFF);
406 
407  // Set the command.
408  HWREG(base + I2C_O_CCTR) = cmd | ((transactionLength << I2C_CCTR_MBLEN_S) & I2C_CCTR_MBLEN_M);
409 }
410 
411 //*****************************************************************************
412 //
427 //
428 //*****************************************************************************
430  uint32_t addressMode,
431  uint16_t targetAddr,
432  uint32_t direction)
433 {
434  // Check the arguments.
435  ASSERT(I2CIsBaseValid(base));
436  ASSERT((addressMode == I2C_CONTROLLER_ADDR_MODE_7_BIT) || (addressMode == I2C_CONTROLLER_ADDR_MODE_10_BIT));
437  ASSERT(!(targetAddr & 0xFF80) || (addressMode == I2C_CONTROLLER_ADDR_MODE_10_BIT));
438  ASSERT(!(targetAddr & 0xFC00));
439  ASSERT((direction == I2C_CONTROLLER_DIR_RECEIVE) || (direction == I2C_CONTROLLER_DIR_TRANSMIT));
440 
441  // Set the address mode and the address of the target with which the
442  // controller will communicate, and set the direction.
443  // Note: The possible values for addressMode and direction are defined in
444  // in terms of the enums for their corresponding fields in MSA, so they can
445  // be added directly without any modification.
446  HWREG(base + I2C_O_CSA) = (targetAddr << I2C_CSA_TADDR_S) | addressMode | direction;
447 }
448 
449 //*****************************************************************************
450 //
461 //
462 //*****************************************************************************
464 {
465  // Check the arguments.
466  ASSERT(I2CIsBaseValid(base));
467 
468  // Write to MCR register
469  HWREG(base + I2C_O_CCR) |= I2C_CCR_ACTIVE_EN;
470 }
471 
472 //*****************************************************************************
473 //
481 //
482 //*****************************************************************************
484 {
485  // Check the arguments.
486  ASSERT(I2CIsBaseValid(base));
487 
488  // Disable the clock for the controller.
489  HWREG(base + I2C_O_CCR) &= ~I2C_CCR_ACTIVE_EN;
490 }
491 
492 //*****************************************************************************
493 //
504 //
505 //*****************************************************************************
507 {
508  // Check the arguments.
509  ASSERT(I2CIsBaseValid(base));
510 
511  // Return the busy status.
512  if ((HWREG(base + I2C_O_CSR) & I2C_CSR_BUSY_M) == I2C_CSR_BUSY_SET)
513  {
514  return (true);
515  }
516  else
517  {
518  return (false);
519  }
520 }
521 
522 //*****************************************************************************
523 //
535 //
536 //*****************************************************************************
538 {
539  // Check the arguments.
540  ASSERT(I2CIsBaseValid(base));
541 
542  // Return the bus busy status.
544  {
545  return (true);
546  }
547  else
548  {
549  return (false);
550  }
551 }
552 
553 //*****************************************************************************
554 //
567 //
568 //*****************************************************************************
569 extern uint32_t I2CControllerGetError(uint32_t base);
570 
571 //*****************************************************************************
572 //
578 //
579 //*****************************************************************************
580 __STATIC_INLINE uint32_t I2CGetTxFifoCount(uint32_t base)
581 {
582  // Check the arguments.
583  ASSERT(I2CIsBaseValid(base));
584 
585  // TXFIFOCNT contains the number of bytes that can be written to the TX
586  // FIFO. This function needs to return the number of byte already in the TX
587  // FIFO.
590 }
591 
592 //*****************************************************************************
593 //
599 //
600 //*****************************************************************************
601 __STATIC_INLINE uint32_t I2CGetRxFifoCount(uint32_t base)
602 {
603  // Check the arguments.
604  ASSERT(I2CIsBaseValid(base));
605 
606  // RXFIFOCNT contains the number of bytes that can be read from the RX FIFO
607  // I.e. the number of bytes in the RX FIFO
609 }
610 
611 //*****************************************************************************
612 //
618 //
619 //*****************************************************************************
621 {
622  // Check the arguments.
623  ASSERT(I2CIsBaseValid(base));
624 
625  // If the maximum number of bytes can be put into the TX FIFO, then it is
626  // empty
628 }
629 
630 //*****************************************************************************
631 //
637 //
638 //*****************************************************************************
640 {
641  // Check the arguments.
642  ASSERT(I2CIsBaseValid(base));
643 
644  // If the no bytes can be read from the RX FIFO, then it is empty
646 }
647 
648 //*****************************************************************************
649 //
655 //
656 //*****************************************************************************
657 __STATIC_INLINE bool I2CIsTxFifoFull(uint32_t base)
658 {
659  // Check the arguments.
660  ASSERT(I2CIsBaseValid(base));
661 
662  // If no bytes can be put into the TX FIFO, then it is full
664 }
665 
666 //*****************************************************************************
667 //
673 //
674 //*****************************************************************************
675 __STATIC_INLINE bool I2CIsRxFifoFull(uint32_t base)
676 {
677  // Check the arguments.
678  ASSERT(I2CIsBaseValid(base));
679 
680  // If the maximum number of bytes can be read from the RX FIFO,
681  // then it is full
683 }
684 
685 //*****************************************************************************
686 //
694 //
695 //*****************************************************************************
696 __STATIC_INLINE void I2CSetTxFifoTrigger(uint32_t base, uint8_t level)
697 {
698  // Check the arguments.
699  ASSERT(I2CIsBaseValid(base));
700  ASSERT(level <= 7);
701 
702  // Read FIFOCTL register
703  uint32_t fifoCtlTmp = HWREG(base + I2C_O_FIFOCTL);
704 
705  // Clear bits in TXTRIG field
706  fifoCtlTmp &= ~I2C_FIFOCTL_TXTRIG_M;
707 
708  // Set TXTRIG field to the specified trigger level
709  fifoCtlTmp |= (level << I2C_FIFOCTL_TXTRIG_S) & I2C_FIFOCTL_TXTRIG_M;
710 
711  // Write back to FIFOCTL register
712  HWREG(base + I2C_O_FIFOCTL) = fifoCtlTmp;
713 }
714 
715 //*****************************************************************************
716 //
724 //
725 //*****************************************************************************
726 __STATIC_INLINE void I2CSetRxFifoTrigger(uint32_t base, uint8_t level)
727 {
728  // Check the arguments.
729  ASSERT(I2CIsBaseValid(base));
730  ASSERT(1 <= level && level <= 8);
731 
732  // Read FIFOCTL register
733  uint32_t fifoCtlTmp = HWREG(base + I2C_O_FIFOCTL);
734 
735  // Clear bits in RXTRIG field
736  fifoCtlTmp &= ~I2C_FIFOCTL_RXTRIG_M;
737 
738  // Set RXTRIG field to the specified trigger level
739  fifoCtlTmp |= ((level - 1) << I2C_FIFOCTL_RXTRIG_S) & I2C_FIFOCTL_RXTRIG_M;
740 
741  // Write back to FIFOCTL register
742  HWREG(base + I2C_O_FIFOCTL) = fifoCtlTmp;
743 }
744 
745 //*****************************************************************************
746 //
767 //
768 //*****************************************************************************
769 __STATIC_INLINE void I2CFlushTxFifo(uint32_t base)
770 {
771  // Check the arguments.
772  ASSERT(I2CIsBaseValid(base));
773 
774  // Flush TX FIFO
776 
777  // Wait until TX FIFO is empty
778  while (I2CIsTxFifoEmpty(base) != true) {}
779 
780  // Disable TX FIFO flushing
782 }
783 
784 //*****************************************************************************
785 //
810 //
811 //*****************************************************************************
812 __STATIC_INLINE void I2CFlushRxFifo(uint32_t base)
813 {
814  // Check the arguments.
815  ASSERT(I2CIsBaseValid(base));
816 
817  // Flush RX FIFO
819 
820  // Wait until RX FIFO is empty
821  while (I2CIsRxFifoEmpty(base) != true) {}
822 
823  // Disable RX FIFO flushing
825 }
826 
827 //*****************************************************************************
828 //
855 //
856 //*****************************************************************************
857 __STATIC_INLINE void I2CFlushFifos(uint32_t base)
858 {
859  // Check the arguments.
860  ASSERT(I2CIsBaseValid(base));
861 
862  // Flush TX and RX FIFOs
864 
865  // Wait until both FIFOs are empty.
868  {}
869 
870  // Disable TX and RX FIFO flushing
872 }
873 
874 //*****************************************************************************
875 //
888 //
889 //*****************************************************************************
890 __STATIC_INLINE void I2CGetData(uint32_t base, uint8_t *data)
891 {
892  // Check the arguments.
893  ASSERT(I2CIsBaseValid(base));
894 
895  // Wait until there is data to be read.
896  while (I2CIsRxFifoEmpty(base)) {}
897 
898  // Read a byte from I2C RX FIFO.
899  *data = HWREGB(base + I2C_O_RXDATA);
900 }
901 
902 //*****************************************************************************
903 //
915 //
916 //*****************************************************************************
917 __STATIC_INLINE uint32_t I2CGetDataNonBlocking(uint32_t base, uint8_t *data)
918 {
919  // Check the arguments.
920  ASSERT(I2CIsBaseValid(base));
921 
922  // Check if there is data to be read
923  if (I2CIsRxFifoEmpty(base))
924  {
925  return 0;
926  }
927  else
928  {
929  // Read a byte from I2C RX FIFO.
930  *data = HWREGB(base + I2C_O_RXDATA);
931  return 1;
932  }
933 }
934 
935 //*****************************************************************************
936 //
947 //
948 //*****************************************************************************
949 __STATIC_INLINE void I2CPutData(uint32_t base, uint8_t data)
950 {
951  // Check the arguments.
952  ASSERT(I2CIsBaseValid(base));
953 
954  // Wait until space is available.
955  while (I2CIsTxFifoFull(base)) {}
956 
957  // Write the byte.
958  HWREGB(base + I2C_O_TXDATA) = data;
959 }
960 
961 //*****************************************************************************
962 //
973 //
974 //*****************************************************************************
975 __STATIC_INLINE uint32_t I2CPutDataNonBlocking(uint32_t base, uint8_t data)
976 {
977  // Check the arguments.
978  ASSERT(I2CIsBaseValid(base));
979 
980  // Check if there is space available.
981  if (I2CIsTxFifoFull(base))
982  {
983  return 0;
984  }
985  else
986  {
987  // Write the byte.
988  HWREGB(base + I2C_O_TXDATA) = data;
989  return 1;
990  }
991 }
992 
993 //*****************************************************************************
994 //
1029 //
1030 //*****************************************************************************
1031 __STATIC_INLINE void I2CEnableInt(uint32_t base, uint32_t intFlags)
1032 {
1033  // Check the arguments.
1034  ASSERT(I2CIsBaseValid(base));
1035 
1036  // Enable the specified interrupts.
1037  HWREG(base + I2C_O_EVENT0_IMEN) = intFlags;
1038 }
1039 
1040 //*****************************************************************************
1041 //
1077 //
1078 //*****************************************************************************
1079 __STATIC_INLINE void I2CDisableInt(uint32_t base, uint32_t intFlags)
1080 {
1081  // Check the arguments.
1082  ASSERT(I2CIsBaseValid(base));
1083 
1084  // Disable the specified interrupts.
1085  HWREG(base + I2C_O_EVENT0_IMDIS) = intFlags;
1086 }
1087 
1088 //*****************************************************************************
1089 //
1142 //
1143 //*****************************************************************************
1144 __STATIC_INLINE void I2CClearInt(uint32_t base, uint32_t intFlags)
1145 {
1146  // Check the arguments.
1147  ASSERT(I2CIsBaseValid(base));
1148 
1149  // Clear the specified I2C interrupt sources.
1150  HWREG(base + I2C_O_EVENT0_IDIS) = intFlags;
1151 }
1152 
1153 //*****************************************************************************
1154 //
1190 //
1191 //*****************************************************************************
1192 __STATIC_INLINE uint32_t I2CIntStatus(uint32_t base, bool masked)
1193 {
1194  // Check the arguments.
1195  ASSERT(I2CIsBaseValid(base));
1196 
1197  // Return either the masked interrupt status or the raw interrupt status as
1198  // requested.
1199  if (masked)
1200  {
1201  return (HWREG(base + I2C_O_EVENT0_MIS));
1202  }
1203  else
1204  {
1205  return (HWREG(base + I2C_O_EVENT0_RIS));
1206  }
1207 }
1208 
1209 //*****************************************************************************
1210 //
1211 // Mark the end of the C bindings section for C++ compilers.
1212 //
1213 //*****************************************************************************
1214 #ifdef __cplusplus
1215 }
1216 #endif
1217 
1218 //*****************************************************************************
1219 //
1223 //
1224 //*****************************************************************************
1225 
1226 #endif // __I2C_H__
#define I2C_CSA_TADDR_S
Definition: hw_i2c.h:221
#define I2C_FIFOSR_RXFIFOCNT_S
Definition: hw_i2c.h:1354
#define I2C_FIFOCTL_TXTRIG_M
Definition: hw_i2c.h:1252
#define I2C_O_CSR
Definition: hw_i2c.h:54
#define I2C_FIFOSR_RXFIFOCNT_MAXIMUM
Definition: hw_i2c.h:1356
__STATIC_INLINE void I2CPutData(uint32_t base, uint8_t data)
Puts a data element into the I2C TX FIFO.
Definition: i2c.h:949
#define I2C_FIFOSR_TXFIFOCNT_MAXIMUM
Definition: hw_i2c.h:1391
#define I2C_CSR_BUSY_M
Definition: hw_i2c.h:391
#define I2C_CONTROLLER_DIR_RECEIVE
I2C Controller is initiating a read from the target.
Definition: i2c.h:128
__STATIC_INLINE bool I2CIsRxFifoFull(uint32_t base)
Check if RX FIFO is full.
Definition: i2c.h:675
#define I2C_CONTROLLER_CMD_BURST_SEND_CONT
Definition: i2c.h:79
#define HWREG(x)
Definition: hw_types.h:78
#define I2C_CONTROLLER_CMD_BURST_SEND_FINISH
Definition: i2c.h:80
#define __STATIC_INLINE
Definition: hw_types.h:57
__STATIC_INLINE uint32_t I2CGetRxFifoCount(uint32_t base)
Get the number of bytes in the RX FIFO.
Definition: i2c.h:601
__STATIC_INLINE uint32_t I2CIntStatus(uint32_t base, bool masked)
Gets the current I2C interrupt status.
Definition: i2c.h:1192
#define I2C_CONTROLLER_DIR_TRANSMIT
I2C Controller is initiating a write to the target.
Definition: i2c.h:130
#define I2C_FIFOSR_RXFIFOCNT_MINIMUM
Definition: hw_i2c.h:1355
#define I2C_O_CCR
Definition: hw_i2c.h:60
#define I2C_FIFOSR_RXFIFOCNT_M
Definition: hw_i2c.h:1353
__STATIC_INLINE void I2CFlushTxFifo(uint32_t base)
Flush the I2C TX FIFO.
Definition: i2c.h:769
void I2CControllerInit(uint32_t base, uint32_t config, uint32_t mode)
Initializes the I2C Controller module.
Definition: i2c.c:43
#define I2C_O_EVENT0_RIS
Definition: hw_i2c.h:102
#define I2C_O_CSA
Definition: hw_i2c.h:48
__STATIC_INLINE void I2CSetRxFifoTrigger(uint32_t base, uint8_t level)
Set RX FIFO trigger level.
Definition: i2c.h:726
#define I2C_FIFOSR_TXFIFOCNT_MINIMUM
Definition: hw_i2c.h:1390
__STATIC_INLINE void I2CControllerSetCommand(uint32_t base, uint32_t cmd, uint16_t transactionLength)
Controls the state of the I2C Controller module.
Definition: i2c.h:393
#define I2C_CSR_BUSBSY_M
Definition: hw_i2c.h:498
#define I2C_CCTR_MBLEN_M
Definition: hw_i2c.h:365
#define I2C_FIFOCTL_RXTRIG_M
Definition: hw_i2c.h:1303
__STATIC_INLINE bool I2CIsTxFifoEmpty(uint32_t base)
Check if TX FIFO is empty.
Definition: i2c.h:620
#define I2C_O_CCTR
Definition: hw_i2c.h:51
__STATIC_INLINE void I2CDisableInt(uint32_t base, uint32_t intFlags)
Disables individual I2C interrupt sources.
Definition: i2c.h:1079
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_START
Definition: i2c.h:81
#define I2C1_BASE
Definition: hw_memmap.h:89
#define I2C_FIFOSR_TXFIFOCNT_M
Definition: hw_i2c.h:1388
__STATIC_INLINE bool I2CControllerIsBusBusy(uint32_t base)
Indicates whether or not the I2C bus is busy.
Definition: i2c.h:537
#define I2C_O_EVENT0_IMEN
Definition: hw_i2c.h:114
#define I2C_FIFOCTL_RXFLUSH_EN
Definition: hw_i2c.h:1331
__STATIC_INLINE void I2CControllerDisable(uint32_t base)
Disables the I2C controller module.
Definition: i2c.h:483
__STATIC_INLINE void I2CSetTxFifoTrigger(uint32_t base, uint8_t level)
Set TX FIFO trigger level.
Definition: i2c.h:696
__STATIC_INLINE bool I2CIsRxFifoEmpty(uint32_t base)
Check if RX FIFO is empty.
Definition: i2c.h:639
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:87
#define I2C_O_FIFOSR
Definition: hw_i2c.h:90
#define I2C_CONTROLLER_CMD_BURST_SEND_START
Definition: i2c.h:78
#define I2C_CSR_BUSY_SET
Definition: hw_i2c.h:394
#define I2C_FIFOCTL_TXFLUSH_EN
Definition: hw_i2c.h:1280
__STATIC_INLINE bool I2CIsTxFifoFull(uint32_t base)
Check if TX FIFO is full.
Definition: i2c.h:657
__STATIC_INLINE void I2CControllerSetTargetAddr(uint32_t base, uint32_t addressMode, uint16_t targetAddr, uint32_t direction)
Sets the address that the I2C Controller will place on the bus.
Definition: i2c.h:429
#define ASSERT(expr)
Definition: debug.h:81
#define I2C_O_TXDATA
Definition: hw_i2c.h:81
#define I2C_CCR_ACTIVE_EN
Definition: hw_i2c.h:584
#define I2C_O_EVENT0_IDIS
Definition: hw_i2c.h:111
__STATIC_INLINE void I2CFlushRxFifo(uint32_t base)
Flush the I2C RX FIFO.
Definition: i2c.h:812
__STATIC_INLINE void I2CControllerEnable(uint32_t base)
Enable the I2C Controller module.
Definition: i2c.h:463
__STATIC_INLINE void I2CFlushFifos(uint32_t base)
Flush the I2C TX and RX FIFOs.
Definition: i2c.h:857
#define I2C_FIFOCTL_RXTRIG_S
Definition: hw_i2c.h:1304
#define I2C_O_EVENT0_IMDIS
Definition: hw_i2c.h:117
#define I2C_O_EVENT0_MIS
Definition: hw_i2c.h:105
__STATIC_INLINE void I2CClearInt(uint32_t base, uint32_t intFlags)
Clears I2C interrupt sources.
Definition: i2c.h:1144
__STATIC_INLINE uint32_t I2CGetDataNonBlocking(uint32_t base, uint8_t *data)
Gets a data element from the I2C RX FIFO (non-blocking).
Definition: i2c.h:917
#define I2C0_BASE
Definition: hw_memmap.h:88
#define I2C_CCTR_MBLEN_S
Definition: hw_i2c.h:366
#define I2C_FIFOSR_TXFIFOCNT_S
Definition: hw_i2c.h:1389
uint32_t I2CControllerGetError(uint32_t base)
Gets the error status of the I2C Controller module.
Definition: i2c.c:109
#define I2C_FIFOCTL_TXTRIG_S
Definition: hw_i2c.h:1253
#define I2C_CONTROLLER_ADDR_MODE_7_BIT
7-bit addressing
Definition: i2c.h:222
__STATIC_INLINE uint32_t I2CGetTxFifoCount(uint32_t base)
Get the number of bytes in the TX FIFO.
Definition: i2c.h:580
__STATIC_INLINE void I2CEnableInt(uint32_t base, uint32_t intFlags)
Enables individual I2C interrupt sources.
Definition: i2c.h:1031
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_CONT
Definition: i2c.h:83
__STATIC_INLINE uint32_t I2CPutDataNonBlocking(uint32_t base, uint8_t data)
Puts a data element into the I2C TX FIFO (non-blocking).
Definition: i2c.h:975
#define I2C_CONTROLLER_ADDR_MODE_10_BIT
10-bit addressing
Definition: i2c.h:224
#define I2C_O_RXDATA
Definition: hw_i2c.h:78
#define HWREGB(x)
Definition: hw_types.h:90
#define I2C_CONTROLLER_CMD_SINGLE_SEND
Definition: i2c.h:76
__STATIC_INLINE bool I2CControllerIsBusy(uint32_t base)
Indicates whether or not the I2C Controller is busy.
Definition: i2c.h:506
#define I2C_CSR_BUSBSY_SET
Definition: hw_i2c.h:501
__STATIC_INLINE void I2CGetData(uint32_t base, uint8_t *data)
Gets a data element from the I2C RX FIFO.
Definition: i2c.h:890