i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018-2019 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef __HAL_I2C_ADAPTER_H__
10 #define __HAL_I2C_ADAPTER_H__
11 
17 /*******************************************************************************
18  * Definitions
19  ******************************************************************************/
21 #define HAL_I2C_MASTER_HANDLE_SIZE (80U)
22 
24 #define HAL_I2C_SLAVE_HANDLE_SIZE (88U)
25 
27 typedef enum _hal_i2c_status
28 {
38 
40 typedef struct _hal_i2c_master_config
41 {
42  uint32_t srcClock_Hz;
43  uint32_t baudRate_Bps;
44  bool enableMaster;
45  uint8_t instance;
47 
49 typedef struct _hal_i2c_slave_config
50 {
51  uint32_t srcClock_Hz;
52  uint16_t slaveAddress;
53  bool enableSlave;
54  uint8_t instance;
56 
58 typedef enum _hal_i2c_direction
59 {
63 
66 {
73 
85 {
100 
103 {
104  uint8_t *volatile data;
105  volatile size_t dataSize;
106  uint32_t flags;
107  uint32_t subaddress;
108  uint8_t subaddressSize;
109  uint8_t slaveAddress;
112 
115 {
117  uint8_t *volatile data;
118  volatile size_t dataSize;
124 
127 
130 
146 #define HAL_I2C_MASTER_HANDLE_DEFINE(name) \
147  uint32_t name[(HAL_I2C_MASTER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
148 
164 #define HAL_I2C_SLAVE_HANDLE_DEFINE(name) \
165  uint32_t name[(HAL_I2C_SLAVE_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
166 
178  hal_i2c_status_t completionStatus,
179  void *callbackParam);
180 
192  hal_i2c_slave_transfer_t *transfer,
193  void *callbackParam);
194 
195 /*******************************************************************************
196  * API
197  ******************************************************************************/
198 
199 #if defined(__cplusplus)
200 extern "C" {
201 #endif /*_cplusplus. */
202 
240 
273 
281 
290 
311  const uint8_t *txBuff,
312  size_t txSize,
313  uint32_t flags);
314 
331  uint8_t *rxBuff,
332  size_t rxSize,
333  uint32_t flags);
334 
345 hal_i2c_status_t HAL_I2cSlaveWriteBlocking(hal_i2c_slave_handle_t handle, const uint8_t *txBuff, size_t txSize);
346 
356 hal_i2c_status_t HAL_I2cSlaveReadBlocking(hal_i2c_slave_handle_t handle, uint8_t *rxBuff, size_t rxSize);
357 
373 
395  void *callbackParam);
396 
412 
422 
434 
449  void *callbackParam);
450 
475 
485 
495 
497 #if defined(__cplusplus)
498 }
499 #endif /*_cplusplus. */
500 
502 #endif /* __HAL_I2C_ADAPTER_H__*/
_hal_i2c_slave_transfer::event
hal_i2c_slave_transfer_event_t event
Definition: i2c.h:116
HAL_I2cSlaveInit
hal_i2c_status_t HAL_I2cSlaveInit(hal_i2c_slave_handle_t handle, const hal_i2c_slave_config_t *config)
Initializes the HAL I2C peripheral.
Definition: lpi2c_adapter.c:150
hal_i2c_slave_transfer_event_t
enum _hal_i2c_slave_transfer_event hal_i2c_slave_transfer_event_t
Set of events sent to the callback for nonblocking slave transfers.
_hal_i2c_master_transfer_flag
_hal_i2c_master_transfer_flag
I2C transfer control flag.
Definition: i2c.h:65
_hal_i2c_master_transfer::direction
hal_i2c_direction_t direction
Definition: i2c.h:110
_hal_i2c_master_transfer::slaveAddress
uint8_t slaveAddress
Definition: i2c.h:109
_hal_i2c_master_config::baudRate_Bps
uint32_t baudRate_Bps
Definition: i2c.h:43
kHAL_I2cSlaveTransmitEvent
@ kHAL_I2cSlaveTransmitEvent
Definition: i2c.h:87
HAL_I2cSlaveDeinit
hal_i2c_status_t HAL_I2cSlaveDeinit(hal_i2c_slave_handle_t handle)
De-initializes the HAL I2C slave peripheral. Calling this API gates the HAL I2C clock....
Definition: lpi2c_adapter.c:184
kHAL_I2cTransferNoStopFlag
@ kHAL_I2cTransferNoStopFlag
Definition: i2c.h:71
HAL_I2cMasterTransferGetCount
hal_i2c_status_t HAL_I2cMasterTransferGetCount(hal_i2c_master_handle_t handle, size_t *count)
Gets the master transfer status during a interrupt non-blocking transfer.
Definition: lpi2c_adapter.c:283
_hal_i2c_slave_config
HAL I2C slave user configuration.
Definition: i2c.h:49
hal_i2c_master_transfer_flag_t
enum _hal_i2c_master_transfer_flag hal_i2c_master_transfer_flag_t
I2C transfer control flag.
hal_i2c_slave_transfer_t
struct _hal_i2c_slave_transfer hal_i2c_slave_transfer_t
HAL I2C slave transfer structure.
hal_i2c_direction_t
enum _hal_i2c_direction hal_i2c_direction_t
Direction of master and slave transfers.
hal_i2c_master_transfer_t
struct _hal_i2c_master_transfer hal_i2c_master_transfer_t
HAL I2C master transfer structure.
HAL_I2cSlaveWriteBlocking
hal_i2c_status_t HAL_I2cSlaveWriteBlocking(hal_i2c_slave_handle_t handle, const uint8_t *txBuff, size_t txSize)
Performs a polling send transaction on the HAL I2C bus.
Definition: lpi2c_adapter.c:213
_hal_i2c_slave_config::enableSlave
bool enableSlave
Definition: i2c.h:53
kStatus_HAL_I2cBusy
@ kStatus_HAL_I2cBusy
Definition: i2c.h:31
_hal_i2c_master_transfer::dataSize
volatile size_t dataSize
Definition: i2c.h:105
_hal_i2c_master_transfer::flags
uint32_t flags
Definition: i2c.h:106
_hal_i2c_master_config::enableMaster
bool enableMaster
Definition: i2c.h:44
HAL_I2cSlaveTransferGetCount
hal_i2c_status_t HAL_I2cSlaveTransferGetCount(hal_i2c_slave_handle_t handle, size_t *count)
Gets the slave transfer remaining bytes during a interrupt non-blocking transfer.
Definition: lpi2c_adapter.c:350
_hal_i2c_slave_config::instance
uint8_t instance
Definition: i2c.h:54
_hal_i2c_master_transfer::data
uint8_t *volatile data
Definition: i2c.h:104
_hal_i2c_slave_transfer::transferredCount
size_t transferredCount
Definition: i2c.h:121
kStatus_HAL_I2cSuccess
@ kStatus_HAL_I2cSuccess
Definition: i2c.h:29
kHAL_I2cSlaveTransmitAckEvent
@ kHAL_I2cSlaveTransmitAckEvent
Definition: i2c.h:91
_hal_i2c_slave_transfer
HAL I2C slave transfer structure.
Definition: i2c.h:114
_hal_i2c_master_config
HAL I2C master user configuration.
Definition: i2c.h:40
MAKE_STATUS
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:43
hal_i2c_slave_config_t
struct _hal_i2c_slave_config hal_i2c_slave_config_t
HAL I2C slave user configuration.
_hal_i2c_slave_transfer::dataSize
volatile size_t dataSize
Definition: i2c.h:118
_hal_i2c_direction
_hal_i2c_direction
Direction of master and slave transfers.
Definition: i2c.h:58
kHAL_I2cSlaveAddressMatchEvent
@ kHAL_I2cSlaveAddressMatchEvent
Definition: i2c.h:86
kStatus_HAL_I2cArbitrationLost
@ kStatus_HAL_I2cArbitrationLost
Definition: i2c.h:34
kStatus_HAL_I2cIdle
@ kStatus_HAL_I2cIdle
Definition: i2c.h:32
_hal_i2c_master_config::instance
uint8_t instance
Definition: i2c.h:45
HAL_I2cMasterTransferInstallCallback
hal_i2c_status_t HAL_I2cMasterTransferInstallCallback(hal_i2c_master_handle_t handle, hal_i2c_master_transfer_callback_t callback, void *callbackParam)
Installs a callback and callback parameter.
Definition: lpi2c_adapter.c:244
hal_i2c_master_config_t
struct _hal_i2c_master_config hal_i2c_master_config_t
HAL I2C master user configuration.
kHAL_I2cRead
@ kHAL_I2cRead
Definition: i2c.h:61
hal_i2c_status_t
enum _hal_i2c_status hal_i2c_status_t
HAL I2C status.
HAL_I2cMasterWriteBlocking
hal_i2c_status_t HAL_I2cMasterWriteBlocking(hal_i2c_master_handle_t handle, const uint8_t *txBuff, size_t txSize, uint32_t flags)
Performs a polling send transaction on the HAL I2C bus.
Definition: lpi2c_adapter.c:197
kHAL_I2cSlaveReceiveEvent
@ kHAL_I2cSlaveReceiveEvent
Definition: i2c.h:89
HAL_I2cSlaveTransferNonBlocking
hal_i2c_status_t HAL_I2cSlaveTransferNonBlocking(hal_i2c_slave_handle_t handle, uint32_t eventMask)
Starts accepting slave transfers.
Definition: lpi2c_adapter.c:325
_hal_i2c_status
_hal_i2c_status
HAL I2C status.
Definition: i2c.h:27
HAL_I2cSlaveTransferInstallCallback
hal_i2c_status_t HAL_I2cSlaveTransferInstallCallback(hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_callback_t callback, void *callbackParam)
Installs a callback and callback parameter.
Definition: lpi2c_adapter.c:307
kHAL_I2cSlaveStartEvent
@ kHAL_I2cSlaveStartEvent
Definition: i2c.h:93
kStatus_HAL_I2cNak
@ kStatus_HAL_I2cNak
Definition: i2c.h:33
kHAL_I2cWrite
@ kHAL_I2cWrite
Definition: i2c.h:60
count
size_t count
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/tests/test_common/ma_test_common.c:31
HAL_I2cSlaveReadBlocking
hal_i2c_status_t HAL_I2cSlaveReadBlocking(hal_i2c_slave_handle_t handle, uint8_t *rxBuff, size_t rxSize)
Performs a polling receive transaction on the HAL I2C bus.
Definition: lpi2c_adapter.c:218
HAL_I2cMasterInit
hal_i2c_status_t HAL_I2cMasterInit(hal_i2c_master_handle_t handle, const hal_i2c_master_config_t *config)
Initializes the HAL I2C master peripheral.
Definition: lpi2c_adapter.c:129
hal_i2c_slave_handle_t
void * hal_i2c_slave_handle_t
HAL I2C slave handle.
Definition: i2c.h:129
kStatus_HAL_I2cAddrressNak
@ kStatus_HAL_I2cAddrressNak
Definition: i2c.h:36
HAL_I2cMasterTransferBlocking
hal_i2c_status_t HAL_I2cMasterTransferBlocking(hal_i2c_master_handle_t handle, hal_i2c_master_transfer_t *xfer)
Performs a master polling transfer on the HAL I2C bus.
Definition: lpi2c_adapter.c:223
kHAL_I2cTransferNoStartFlag
@ kHAL_I2cTransferNoStartFlag
Definition: i2c.h:68
_hal_i2c_slave_transfer::data
uint8_t *volatile data
Definition: i2c.h:117
kHAL_I2cTransferRepeatedStartFlag
@ kHAL_I2cTransferRepeatedStartFlag
Definition: i2c.h:70
_hal_i2c_slave_config::slaveAddress
uint16_t slaveAddress
Definition: i2c.h:52
kStatus_HAL_I2cError
@ kStatus_HAL_I2cError
Definition: i2c.h:30
HAL_I2cMasterTransferAbort
hal_i2c_status_t HAL_I2cMasterTransferAbort(hal_i2c_master_handle_t handle)
Aborts an interrupt non-blocking transfer early.
Definition: lpi2c_adapter.c:295
HAL_I2cSlaveTransferAbort
hal_i2c_status_t HAL_I2cSlaveTransferAbort(hal_i2c_slave_handle_t handle)
Aborts the slave transfer.
Definition: lpi2c_adapter.c:337
_hal_i2c_slave_config::srcClock_Hz
uint32_t srcClock_Hz
Definition: i2c.h:51
_hal_i2c_master_transfer::subaddress
uint32_t subaddress
Definition: i2c.h:107
HAL_I2cMasterTransferNonBlocking
hal_i2c_status_t HAL_I2cMasterTransferNonBlocking(hal_i2c_master_handle_t handle, hal_i2c_master_transfer_t *xfer)
Performs a master interrupt non-blocking transfer on the HAL I2C bus.
Definition: lpi2c_adapter.c:262
kHAL_I2cTransferDefaultFlag
@ kHAL_I2cTransferDefaultFlag
Definition: i2c.h:67
HAL_I2cMasterDeinit
hal_i2c_status_t HAL_I2cMasterDeinit(hal_i2c_master_handle_t handle)
De-initializes the HAL I2C master peripheral. Call this API to gate the HAL I2C clock....
Definition: lpi2c_adapter.c:171
_hal_i2c_master_transfer::subaddressSize
uint8_t subaddressSize
Definition: i2c.h:108
config
static sai_transceiver_t config
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:75
kHAL_I2cSlaveCompletionEvent
@ kHAL_I2cSlaveCompletionEvent
Definition: i2c.h:92
_hal_i2c_slave_transfer::completionStatus
hal_i2c_status_t completionStatus
Definition: i2c.h:119
hal_i2c_master_transfer_callback_t
void(* hal_i2c_master_transfer_callback_t)(hal_i2c_master_handle_t handle, hal_i2c_status_t completionStatus, void *callbackParam)
Master completion callback function pointer type.
Definition: i2c.h:177
kStatusGroup_HAL_I2C
@ kStatusGroup_HAL_I2C
Definition: fsl_common.h:150
hal_i2c_master_handle_t
void * hal_i2c_master_handle_t
HAL I2C master handle.
Definition: i2c.h:126
kStatus_HAL_I2cTimeout
@ kStatus_HAL_I2cTimeout
Definition: i2c.h:35
_hal_i2c_slave_transfer_event
_hal_i2c_slave_transfer_event
Set of events sent to the callback for nonblocking slave transfers.
Definition: i2c.h:84
_hal_i2c_master_config::srcClock_Hz
uint32_t srcClock_Hz
Definition: i2c.h:42
_hal_i2c_master_transfer
HAL I2C master transfer structure.
Definition: i2c.h:102
HAL_I2cMasterReadBlocking
hal_i2c_status_t HAL_I2cMasterReadBlocking(hal_i2c_master_handle_t handle, uint8_t *rxBuff, size_t rxSize, uint32_t flags)
Performs a polling receive transaction on the HAL I2C bus.
Definition: lpi2c_adapter.c:205
kStatus_Success
@ kStatus_Success
Definition: fsl_common.h:179
kHAL_I2cSlaveAllEvents
@ kHAL_I2cSlaveAllEvents
Definition: i2c.h:96
hal_i2c_slave_transfer_callback_t
void(* hal_i2c_slave_transfer_callback_t)(hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_t *transfer, void *callbackParam)
Slave event callback function pointer type.
Definition: i2c.h:191
kHAL_I2cSlaveGenaralcallEvent
@ kHAL_I2cSlaveGenaralcallEvent
Definition: i2c.h:94


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56