]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/i2c/fsl_i2c_hal.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_KPSDK_CODE / hal / i2c / fsl_i2c_hal.h
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  *   of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  *   list of conditions and the following disclaimer in the documentation and/or
13  *   other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  *   contributors may be used to endorse or promote products derived from this
17  *   software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(__FSL_I2C_HAL_H__)
31 #define __FSL_I2C_HAL_H__
32
33 #include <assert.h>
34 #include <stdbool.h>
35 #include "fsl_i2c_features.h"
36 #include "fsl_device_registers.h"
37
38 /*!
39  * @addtogroup i2c_hal
40  * @{
41  */
42
43 /*******************************************************************************
44  * Definitions
45  ******************************************************************************/
46 /*! @brief I2C status return codes.*/
47 typedef enum _i2c_status {
48     kStatus_I2C_Success            = 0x0U,
49     kStatus_I2C_OutOfRange         = 0x1U,
50     kStatus_I2C_Fail               = 0x2U,
51     kStatus_I2C_Busy               = 0x3U, /*!< The master is already performing a transfer.*/
52     kStatus_I2C_Timeout            = 0x4U, /*!< The transfer timed out.*/
53     kStatus_I2C_ReceivedNak        = 0x5U, /*!< The slave device sent a NAK in response to a byte.*/
54     kStatus_I2C_SlaveTxUnderrun    = 0x6U, /*!< I2C Slave TX Underrun error.*/
55     kStatus_I2C_SlaveRxOverrun     = 0x7U, /*!< I2C Slave RX Overrun error.*/
56     kStatus_I2C_AribtrationLost    = 0x8U, /*!< I2C Arbitration Lost error.*/
57 } i2c_status_t;
58
59 /*! @brief I2C status flags. */
60 typedef enum _i2c_status_flag {
61     kI2CTransferComplete = BP_I2C_S_TCF,
62     kI2CAddressAsSlave   = BP_I2C_S_IAAS,
63     kI2CBusBusy          = BP_I2C_S_BUSY,
64     kI2CArbitrationLost  = BP_I2C_S_ARBL,
65     kI2CAddressMatch     = BP_I2C_S_RAM,
66     kI2CSlaveTransmit    = BP_I2C_S_SRW,
67     kI2CInterruptPending = BP_I2C_S_IICIF,
68     kI2CReceivedNak      = BP_I2C_S_RXAK 
69 } i2c_status_flag_t;
70
71 /*! @brief Direction of master and slave transfers.*/
72 typedef enum _i2c_direction {
73     kI2CReceive = 0U,   /*!< Master and slave receive.*/
74     kI2CSend    = 1U    /*!< Master and slave transmit.*/
75 } i2c_direction_t;
76
77 /*******************************************************************************
78  * API
79  ******************************************************************************/
80
81 #if defined(__cplusplus)
82 extern "C" {
83 #endif
84
85 /*!
86  * @name Module controls
87  * @{
88  */
89
90 /*!
91  * @brief Restores the I2C peripheral to reset state.
92  *
93  * @param baseAddr The I2C peripheral base address
94  */
95 void I2C_HAL_Init(uint32_t baseAddr);
96
97 /*!
98  * @brief Enables the I2C module operation.
99  *
100  * @param baseAddr The I2C peripheral base address
101  */
102 static inline void I2C_HAL_Enable(uint32_t baseAddr)
103 {
104     BW_I2C_C1_IICEN(baseAddr, 0x1U);
105 }
106
107 /*!
108  * @brief Disables the I2C module operation.
109  *
110  * @param baseAddr The I2C peripheral base address
111  */
112 static inline void I2C_HAL_Disable(uint32_t baseAddr)
113 {
114     BW_I2C_C1_IICEN(baseAddr, 0x0U);
115 }
116
117 /*@}*/
118
119 /*!
120  * @name DMA
121  * @{
122  */
123
124 /*!
125  * @brief Enables or disables the DMA support.
126  *
127  * @param baseAddr The I2C peripheral base address
128  * @param enable Pass true to enable DMA transfer signalling
129  */
130 static inline void I2C_HAL_SetDmaCmd(uint32_t baseAddr, bool enable)
131 {
132     BW_I2C_C1_DMAEN(baseAddr, (uint8_t)enable);
133 }
134
135 /*!
136  * @brief Returns whether I2C DMA support is enabled.
137  *
138  * @param baseAddr The I2C peripheral base address.
139  * @retval true I2C DMA is enabled.
140  * @retval false I2C DMA is disabled.
141  */
142 static inline bool I2C_HAL_GetDmaCmd(uint32_t baseAddr)
143 {
144     return BR_I2C_C1_DMAEN(baseAddr);
145 }
146
147 /*@}*/
148
149 /*!
150  * @name Pin functions
151  * @{
152  */
153
154 /*!
155  * @brief Controls the drive capability of the I2C pads.
156  *
157  * @param baseAddr The I2C peripheral base address
158  * @param enable Passing true will enable high drive mode of the I2C pads. False sets normal
159  *     drive mode.
160  */
161 static inline void I2C_HAL_SetHighDriveCmd(uint32_t baseAddr, bool enable)
162 {
163     BW_I2C_C2_HDRS(baseAddr, (uint8_t)enable);
164 }
165
166 /*!
167  * @brief Controls the width of the programmable glitch filter.
168  *
169  * Controls the width of the glitch, in terms of bus clock cycles, that the filter must absorb.
170  * The filter does not allow any glitch whose size is less than or equal to this width setting, 
171  * to pass.
172  *
173  * @param baseAddr The I2C peripheral base address
174  * @param glitchWidth Maximum width in bus clock cycles of the glitches that is filtered.
175  *     Pass zero to disable the glitch filter.
176  */
177 static inline void I2C_HAL_SetGlitchWidth(uint32_t baseAddr, uint8_t glitchWidth)
178 {
179     BW_I2C_FLT_FLT(baseAddr, glitchWidth);
180 }
181
182 /*@}*/
183
184 /*!
185  * @name Low power
186  * @{
187  */
188
189 /*!
190  * @brief Controls the I2C wakeup enable.
191  *
192  * The I2C module can wake the MCU from low power mode with no peripheral bus running when
193  * slave address matching occurs. 
194  *
195  * @param baseAddr The I2C peripheral base address.
196  * @param enable true - Enables the wakeup function in low power mode.<br>
197  *     false - Normal operation. No interrupt is  generated when address matching in
198  *     low power mode.
199  */
200 static inline void I2C_HAL_SetWakeupCmd(uint32_t baseAddr, bool enable)
201 {
202     BW_I2C_C1_WUEN(baseAddr, (uint8_t)enable);
203 }
204
205 #if FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF
206 /*!
207  * @brief Controls the stop mode hold off.
208  *
209  * This function lets you enable the hold off entry to low power stop mode when any data transmission
210  * or reception is occurring.
211  *
212  * @param baseAddr The I2C peripheral base address
213  * @param enable false - Stop hold off is disabled. The MCU's entry to stop mode is not gated.<br>
214  *     true - Stop hold off is enabled.
215  */
216
217 static inline void I2C_HAL_SetStopHoldoffCmd(uint32_t baseAddr, bool enable)
218 {
219     BW_I2C_FLT_SHEN(baseAddr, (uint8_t)enable);
220 }
221 #endif /* FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF*/
222
223 /*@}*/
224
225 /*!
226  * @name Baud rate
227  * @{
228  */
229
230 /*!
231  * @brief Sets the I2C bus frequency for master transactions.
232  *
233  * @param baseAddr The I2C peripheral base address
234  * @param sourceClockInHz I2C source input clock in Hertz
235  * @param kbps Requested bus frequency in kilohertz. Common values are either 100 or 400.
236  * @param absoluteError_Hz If this parameter is not NULL, it is filled in with the
237  *     difference in Hertz between the requested bus frequency and the closest frequency
238  *     possible given available divider values.
239  *
240  * @retval kStatus_Success The baud rate was changed successfully. However, there is no
241  *      guarantee on the minimum error. If you want to ensure that the baud was set to within
242  *      a certain error, then use the @a absoluteError_Hz parameter.
243  * @retval kStatus_OutOfRange The requested baud rate was not within the range of rates
244  *      supported by the peripheral.
245  */
246 i2c_status_t I2C_HAL_SetBaudRate(uint32_t baseAddr, uint32_t sourceClockInHz, uint32_t kbps,
247                                   uint32_t * absoluteError_Hz);
248
249 /*!
250  * @brief Sets the I2C baud rate multiplier and table entry.
251  *
252  * Use this function to set the I2C bus frequency register values directly, if they are
253  * known in advance.
254  *
255  * @param baseAddr The I2C peripheral base address
256  * @param mult Value of the MULT bitfield, ranging from 0-2. 
257  * @param icr The ICR bitfield value, which is the index into an internal table in the I2C
258  *     hardware that selects the baud rate divisor and SCL hold time.
259  */
260 static inline void I2C_HAL_SetFreqDiv(uint32_t baseAddr, uint8_t mult, uint8_t icr)
261 {
262     HW_I2C_F_WR(baseAddr, BF_I2C_F_MULT(mult) | BF_I2C_F_ICR(icr));
263 }
264
265 /*!
266  * @brief Slave baud rate control
267  *
268  * Enables an independent slave mode baud rate at the maximum frequency. This forces clock stretching
269  * on the SCL in very fast I2C modes.
270  *
271  * @param baseAddr The I2C peripheral base address
272  * @param enable true - Slave baud rate is independent of the master baud rate;<br>
273  *     false - The slave baud rate follows the master baud rate and clock stretching may occur.
274  */
275 static inline void I2C_HAL_SetSlaveBaudCtrlCmd(uint32_t baseAddr, bool enable)
276 {
277     BW_I2C_C2_SBRC(baseAddr, (uint8_t)enable);
278 }
279
280 /*@}*/
281
282 /*!
283  * @name Bus operations
284  * @{
285  */
286
287 /*!
288  * @brief Sends a START or a Repeated START signal on the I2C bus.
289  *
290  * This function is used to initiate a new master mode transfer by sending the START signal. It
291  * is also used to send a Repeated START signal when a transfer is already in progress.
292  *
293  * @param baseAddr The I2C peripheral base address
294  */
295 void I2C_HAL_SendStart(uint32_t baseAddr);
296
297 /*!
298  * @brief Sends a STOP signal on the I2C bus.
299  *
300  * This function changes the direction to receive.
301  *
302  * @param baseAddr The I2C peripheral base address
303  */
304 static inline void I2C_HAL_SendStop(uint32_t baseAddr)
305 {
306     assert(BR_I2C_C1_MST(baseAddr) == 1);
307     HW_I2C_C1_CLR(baseAddr, BM_I2C_C1_MST | BM_I2C_C1_TX);
308 }
309
310 /*!
311  * @brief Causes an ACK to be sent on the bus.
312  *
313  * This function specifies that an ACK signal is sent in response to the next received byte.
314  *
315  * Note that the behavior of this function is changed when the I2C peripheral is placed in
316  * Fast ACK mode. In this case, this function causes an ACK signal to be sent in
317  * response to the current byte, rather than the next received byte.
318  *
319  * @param baseAddr The I2C peripheral base address
320  */
321 static inline void I2C_HAL_SendAck(uint32_t baseAddr)
322 {
323     BW_I2C_C1_TXAK(baseAddr, 0x0U);
324 }
325
326 /*!
327  * @brief Causes a NAK to be sent on the bus.
328  *
329  * This function specifies that a NAK signal is sent in response to the next received byte.
330  *
331  * Note that the behavior of this function is changed when the I2C peripheral is placed in the
332  * Fast ACK mode. In this case, this function causes an NAK signal to be sent in
333  * response to the current byte, rather than the next received byte.
334  *
335  * @param baseAddr The I2C peripheral base address
336  */
337 static inline void I2C_HAL_SendNak(uint32_t baseAddr)
338 {
339     BW_I2C_C1_TXAK(baseAddr, 0x1U);
340 }
341
342 /*!
343  * @brief Selects either transmit or receive mode.
344  *
345  * @param baseAddr The I2C peripheral base address.
346  * @param direction Specifies either transmit mode or receive mode. The valid values are:
347  *     - #kI2CTransmit
348  *     - #kI2CReceive
349  */
350 static inline void I2C_HAL_SetDirMode(uint32_t baseAddr, i2c_direction_t direction)
351 {
352     BW_I2C_C1_TX(baseAddr, (uint8_t)direction);
353 }
354
355 /*!
356  * @brief Returns the currently selected transmit or receive mode.
357  *
358  * @param baseAddr The I2C peripheral base address.
359  * @retval #kI2CTransmit I2C is configured for master or slave transmit mode.
360  * @retval #kI2CReceive I2C is configured for master or slave receive mode.
361  */
362 static inline i2c_direction_t I2C_HAL_GetDirMode(uint32_t baseAddr)
363 {
364     return (i2c_direction_t)BR_I2C_C1_TX(baseAddr);
365 }
366
367 /*@}*/
368
369 /*!
370  * @name Data transfer
371  * @{
372  */
373
374 /*!
375  * @brief Returns the last byte of data read from the bus and initiate another read.
376  *
377  * In a master receive mode, calling this function initiates receiving  the next byte of data.
378  *
379  * @param baseAddr The I2C peripheral base address
380  * @return This function returns the last byte received while the I2C module is configured in master
381  *     receive or slave receive mode.
382  */
383 static inline uint8_t I2C_HAL_ReadByte(uint32_t baseAddr)
384 {
385     return HW_I2C_D_RD(baseAddr);
386 }
387
388 /*!
389  * @brief Writes one byte of data to the I2C bus.
390  *
391  * When this function is called in the master transmit mode, a data transfer is initiated. In slave
392  * mode, the same function is available after an address match occurs.
393  *
394  * In a master transmit mode, the first byte of data written following the start bit or repeated
395  * start bit is used for the address transfer and must consist of the slave address (in bits 7-1)
396  * concatenated with the required R/\#W bit (in position bit 0).
397  *
398  * @param baseAddr The I2C peripheral base address.
399  * @param byte The byte of data to transmit.
400  */
401 static inline void I2C_HAL_WriteByte(uint32_t baseAddr, uint8_t byte)
402 {
403     HW_I2C_D_WR(baseAddr, byte);
404 }
405
406 /*@}*/
407
408 /*!
409  * @name Slave address
410  * @{
411  */
412
413 /*!
414  * @brief Sets the primary 7-bit slave address.
415  *
416  * @param baseAddr The I2C peripheral base address
417  * @param address The slave address in the upper 7 bits. Bit 0 of this value must be 0.
418  */
419 void I2C_HAL_SetAddress7bit(uint32_t baseAddr, uint8_t address);
420
421 /*!
422  * @brief Sets the primary slave address and enables 10-bit address mode.
423  *
424  * @param baseAddr The I2C peripheral base address
425  * @param address The 10-bit slave address, in bits [10:1] of the value. Bit 0 must be 0.
426  */
427 void I2C_HAL_SetAddress10bit(uint32_t baseAddr, uint16_t address);
428
429 /*!
430  * @brief Enables or disables the extension address (10-bit).
431  *
432  * @param baseAddr The I2C peripheral base address
433  * @param enable true: 10-bit address is enabled.
434  *               false: 10-bit address is not enabled.
435  */
436 static inline void I2C_HAL_SetExtensionAddrCmd(uint32_t baseAddr, bool enable)
437 {
438     BW_I2C_C2_ADEXT(baseAddr, (uint8_t)enable);
439 }
440
441 /*!
442  * @brief Returns whether the extension address is enabled or not.
443  *
444  * @param baseAddr The I2C peripheral base address
445  * @return true: 10-bit address is enabled.
446  *         false: 10-bit address is not enabled.
447  */
448 static inline bool I2C_HAL_GetExtensionAddrCmd(uint32_t baseAddr)
449 {
450     return BR_I2C_C2_ADEXT(baseAddr);
451 }
452
453 /*!
454  * @brief Controls whether the general call address is recognized.
455  *
456  * @param baseAddr The I2C peripheral base address
457  * @param enable Whether to enable the general call address.
458  */
459 static inline void I2C_HAL_SetGeneralCallCmd(uint32_t baseAddr, bool enable)
460 {
461     BW_I2C_C2_GCAEN(baseAddr, (uint8_t)enable);
462 }
463
464 /*!
465  * @brief Enables or disables the slave address range matching.
466  *
467  * @param baseAddr The I2C peripheral base address.
468  * @param enable Pass true to enable range address matching. You must also call
469  *     I2C_HAL_SetUpperAddress7bit() to set the upper address.
470  */
471 static inline void I2C_HAL_SetRangeMatchCmd(uint32_t baseAddr, bool enable)
472 {
473     BW_I2C_C2_RMEN(baseAddr, (uint8_t)enable);
474 }
475
476 /*!
477  * @brief Sets the upper slave address.
478  *
479  * This slave address is used as a secondary slave address. If range address
480  * matching is enabled, this slave address acts as the upper bound on the slave address
481  * range.
482  *
483  * This function sets only a 7-bit slave address. If 10-bit addressing was enabled by calling
484  * I2C_HAL_SetAddress10bit(), then the top 3 bits set with that function are also used
485  * with the address set with this function to form a 10-bit address.
486  *
487  * Passing 0 for the @a address parameter  disables  matching the upper slave address.
488  *
489  * @param baseAddr The I2C peripheral base address
490  * @param address The upper slave address in the upper 7 bits. Bit 0 of this value must be 0.
491  *     In addition, this address must be greater than the primary slave address that is set by
492  *     calling I2C_HAL_SetAddress7bit().
493  */
494 static inline void I2C_HAL_SetUpperAddress7bit(uint32_t baseAddr, uint8_t address)
495 {
496     assert((address & 1) == 0);
497     assert((address == 0) || (address > HW_I2C_A1_RD(baseAddr)));
498     HW_I2C_RA_WR(baseAddr, address);
499 }
500
501 /*@}*/
502
503 /*!
504  * @name Status
505  * @{
506  */
507
508 /*!
509  * @brief Gets the I2C status flag state.
510  *
511  * @param baseAddr The I2C peripheral base address.
512  * @param statusFlag The status flag, defined in type i2c_status_flag_t.
513  * @return State of the status flag: asserted (true) or not-asserted (false).
514  *         - true: related status flag is being set.
515  *         - false: related status flag is not set.
516  */
517 static inline bool I2C_HAL_GetStatusFlag(uint32_t baseAddr, i2c_status_flag_t statusFlag)
518 {
519     return (bool)((HW_I2C_S_RD(baseAddr) >> statusFlag) & 0x1U);
520 }
521
522 /*!
523  * @brief Returns whether the I2C module is in master mode.
524  *
525  * @param baseAddr The I2C peripheral base address.
526  * @retval true The module is in master mode, which implies it is also performing a transfer.
527  * @retval false The module is in slave mode.
528  */
529 static inline bool I2C_HAL_IsMaster(uint32_t baseAddr)
530 {
531     return (bool)BR_I2C_C1_MST(baseAddr);
532 }
533
534 /*!
535  * @brief Clears the arbitration lost flag.
536  *
537  * @param baseAddr The I2C peripheral base address
538  */
539 static inline void I2C_HAL_ClearArbitrationLost(uint32_t baseAddr)
540 {
541     BW_I2C_S_ARBL(baseAddr, 0x1U);
542 }
543
544 /*@}*/
545
546 /*!
547  * @name Interrupt
548  * @{
549  */
550
551 /*!
552  * @brief Enables or disables I2C interrupt requests.
553  *
554  * @param baseAddr The I2C peripheral base address
555  * @param enable   Pass true to enable interrupt, flase to disable.
556  */
557 static inline void I2C_HAL_SetIntCmd(uint32_t baseAddr, bool enable)
558 {
559     BW_I2C_C1_IICIE(baseAddr, (uint8_t)enable);
560 }
561
562 /*!
563  * @brief Returns whether the I2C interrupts are enabled.
564  *
565  * @param baseAddr The I2C peripheral base address
566  * @retval true I2C interrupts are enabled.
567  * @retval false I2C interrupts are disabled.
568  */
569 static inline bool I2C_HAL_GetIntCmd(uint32_t baseAddr)
570 {
571     return (bool)BR_I2C_C1_IICIE(baseAddr);
572 }
573
574 /*!
575  * @brief Returns the current I2C interrupt flag.
576  *
577  * @param baseAddr The I2C peripheral base address
578  * @retval true An interrupt is pending.
579  * @retval false No interrupt is pending.
580  */
581 static inline bool I2C_HAL_IsIntPending(uint32_t baseAddr)
582 {
583     return (bool)BR_I2C_S_IICIF(baseAddr);
584 }
585
586 /*!
587  * @brief Clears the I2C interrupt if set.
588  *
589  * @param baseAddr The I2C peripheral base address
590  */
591 static inline void I2C_HAL_ClearInt(uint32_t baseAddr)
592 {
593     BW_I2C_S_IICIF(baseAddr, 0x1U);
594 }
595
596 /*@}*/
597
598 #if FSL_FEATURE_I2C_HAS_STOP_DETECT
599
600 /*!
601  * @name Bus stop detection status
602  * @{
603  */
604
605 /*!
606  * @brief Gets the flag indicating a STOP signal was detected on the I2C bus.
607  *
608  * @param baseAddr The I2C peripheral base address
609  * @retval true STOP signal detected on bus.
610  * @retval false No STOP signal was detected on the bus.
611  */
612 static inline bool I2C_HAL_GetStopFlag(uint32_t baseAddr)
613 {
614     return (bool)BR_I2C_FLT_STOPF(baseAddr);
615 }
616
617 /*!
618  * @brief Clears the bus STOP signal detected flag.
619  *
620  * @param baseAddr The I2C peripheral base address
621  */
622 static inline void I2C_HAL_ClearStopFlag(uint32_t baseAddr)
623 {
624     BW_I2C_FLT_STOPF(baseAddr, 0x1U);
625 }
626
627 /*@}*/
628
629 #if FSL_FEATURE_I2C_HAS_START_DETECT
630
631 /*!
632  * @name Bus stop detection interrupt
633  * @{
634  */
635
636 /*!
637  * @brief Enables the I2C bus stop detection interrupt.
638  *
639  * @param baseAddr The I2C peripheral base address
640  * @param enable   Pass true to enable interrupt, flase to disable.
641  */
642 static inline void I2C_HAL_SetStopIntCmd(uint32_t baseAddr, bool enable)
643 {
644     BW_I2C_FLT_SSIE(baseAddr, enable);
645 }
646
647 /*!
648  * @brief Returns whether  the I2C bus stop detection interrupts are enabled.
649  *
650  * @param baseAddr The I2C peripheral base address
651  * @retval true Stop detect interrupts are enabled.
652  * @retval false Stop detect interrupts are disabled.
653  */
654 static inline bool I2C_HAL_GetStopIntCmd(uint32_t baseAddr)
655 {
656     return (bool)BR_I2C_FLT_SSIE(baseAddr);
657 }
658
659 #else
660
661 /*! @name Bus stop detection interrupt*/
662 /*@{*/
663
664 /*!
665  * @brief Enables the I2C bus stop detection interrupt.
666  *
667  * @param baseAddr The I2C peripheral base address
668  */
669 static inline void I2C_HAL_SetStopIntCmd(uint32_t baseAddr, bool enable)
670 {
671     BW_I2C_FLT_STOPIE(baseAddr, enable);
672 }
673
674 /*!
675  * @brief Returns whether the I2C bus stop detection interrupts are enabled.
676  *
677  * @param baseAddr The I2C peripheral base address
678  * @retval true Stop detect interrupts are enabled.
679  * @retval false Stop detect interrupts are disabled.
680  */
681 static inline bool I2C_HAL_GetStopIntCmd(uint32_t baseAddr)
682 {
683     return (bool)BR_I2C_FLT_STOPIE(baseAddr);
684 }
685
686 #endif  /* FSL_FEATURE_I2C_HAS_START_DETECT*/
687
688 /*@}*/
689 #endif /* FSL_FEATURE_I2C_HAS_STOP_DETECT*/
690
691 #if defined(__cplusplus)
692 }
693 #endif
694
695 /*! @} */
696
697 #endif /* __FSL_I2C_HAL_H__*/
698 /*******************************************************************************
699  * EOF
700  ******************************************************************************/
701
702