This is the chip specific include file for T32CZ20 I2C Driver. note that there is a common include file for this HAL module that contains the APIs (such as the init function) that should be used by the application. More...
Go to the source code of this file.
Data Structures | |
| struct | I2C_REGISTERS_T |
| struct | tr_hal_i2c_settings_t |
| struct | tr_hal_i2c_int_count_t |
Typedefs | |
| typedef void(* | tr_hal_i2c_receive_callback_t) (uint8_t received_byte) |
| typedef void(* | tr_hal_i2c_event_callback_t) (tr_hal_i2c_id_t i2c_id, uint32_t event_bitmask) |
Enumerations | |
| enum | tr_hal_i2c_id_t { I2C_CTRL_0_ID = 0 , I2C_CTRL_1_ID = 1 } |
| On the T32CZ20 there are 2 I2C available to act as a Controller. More... | |
| enum | tr_hal_i2c_clock_rate_t { I2C_CLOCK_1_MHZ = 31 , I2C_CLOCK_400_KHZ = 79 , I2C_CLOCK_200_KHZ = 159 , I2C_CLOCK_100_KHZ = 319 , I2C_CLOCK_50_KHZ = 639 , I2C_CLOCK_10_KHZ = 3199 } |
Functions | |
| I2C_REGISTERS_T * | tr_hal_i2c_get_controller_register_address (tr_hal_i2c_id_t i2c_id) |
This is the chip specific include file for T32CZ20 I2C Driver. note that there is a common include file for this HAL module that contains the APIs (such as the init function) that should be used by the application.
Trident HAL I2C Controller Driver:
I2C (Inter-Integrated Circuit) also known as IIC, is a 2-wire synchronous, multi-device serial communication protocol. it is simple and low cost but not the fastest (2 wires).
the 2 wires for I2C are: SDA == serial data SCL == serial clock
NXP (who created I2C as Philips in 1982 have changed the terminology of I2C and now substitude "Controller" for "Master" and "Target" for "Slave".
the CZ20 chip has 2 I2C Controllers and 1 I2C Target. Controllers and Target use a different register mapping.
SPDX-License-Identifier: LicenseRef-TridentMSLA SPDX-FileCopyrightText: 2025 Trident IoT, LLC https://www.tridentiot.com
| #define CHIP_MEMORY_MAP_I2C_CONTROLLER0_BASE (0x4002B000UL) |
section 2.2 of the data sheet explains the Memory map this gives the base address for how to write the I2C registers the chip registers are how the software interacts with the I2C chip peripheral. We create a struct below that addresses the individual registers. This makes it so we can use this base address and a struct field to read or write a chip register
| #define CHIP_MEMORY_MAP_I2C_CONTROLLER1_BASE (0x4002C000UL) |
| #define DEFAULT_I2C_SCL0_PIN 22 |
| #define DEFAULT_I2C_SCL1_PIN 20 |
| #define DEFAULT_I2C_SDA0_PIN 23 |
| #define DEFAULT_I2C_SDA1_PIN 21 |
| #define I2C0_CHIP_REGISTERS ((I2C_REGISTERS_T *) CHIP_MEMORY_MAP_I2C_CONTROLLER0_BASE) |
| #define I2C1_CHIP_REGISTERS ((I2C_REGISTERS_T *) CHIP_MEMORY_MAP_I2C_CONTROLLER1_BASE) |
| #define I2C_BUFFER_SET_FOR_READ 0x100 |
| #define I2C_BUFFER_SET_FOR_WRITE 0x000 |
| #define I2C_CONFIG_CONTROLLER0 |
initializer macros for default I2C CONTROLLER setting
| #define I2C_CONFIG_CONTROLLER1 |
| #define I2C_CONTROL_BUS_CLEAR 0x08 |
| #define I2C_CONTROL_DISABLE_CONTROLLER 0x00 |
| #define I2C_CONTROL_ENABLE_CONTROLLER 0x01 |
| #define I2C_CONTROL_ENABLE_RESTART 0x02 |
| #define I2C_CONTROL_FIFO_CLEAR 0x10 |
| #define I2C_CONTROL_STOP_TRANSACTION 0x04 |
| #define I2C_EVENT_ABORT_A_NACK 0x40 |
| #define I2C_EVENT_ABORT_LOST_ARB 0x100 |
| #define I2C_EVENT_ABORT_W_NACK 0x80 |
| #define I2C_EVENT_RX_FINISH 0x08 |
| #define I2C_EVENT_RX_FULL 0x04 |
| #define I2C_EVENT_RX_OVER 0x02 |
| #define I2C_EVENT_RX_UNDER 0x01 |
I2C events
| #define I2C_EVENT_TX_EMPTY 0x20 |
| #define I2C_EVENT_TX_OVER 0x10 |
| #define I2C_INTERRUPT_ABORT_A_NACK 0x40 |
| #define I2C_INTERRUPT_ABORT_LOST_ARB 0x100 |
| #define I2C_INTERRUPT_ABORT_W_NACK 0x80 |
| #define I2C_INTERRUPT_ALL 0x1FF |
| #define I2C_INTERRUPT_IDLE_STATE 0x200 |
| #define I2C_INTERRUPT_RX_FINISH 0x08 |
| #define I2C_INTERRUPT_RX_FULL 0x04 |
| #define I2C_INTERRUPT_RX_OVER 0x02 |
| #define I2C_INTERRUPT_RX_UNDER 0x01 |
| #define I2C_INTERRUPT_TX_EMPTY 0x20 |
| #define I2C_INTERRUPT_TX_OVER 0x10 |
| #define I2C_RX_FIFO_BYTES 16 |
| #define I2C_TX_FIFO_BYTES 18 |
| #define NUM_I2C_CONTROLLER 2 |
| #define TR_HAL_MAX_I2C_CONTROLLER_ID 1 |
| typedef void(* tr_hal_i2c_event_callback_t) (tr_hal_i2c_id_t i2c_id, uint32_t event_bitmask) |
| typedef void(* tr_hal_i2c_receive_callback_t) (uint8_t received_byte) |
| enum tr_hal_i2c_id_t |
| I2C_REGISTERS_T * tr_hal_i2c_get_controller_register_address | ( | tr_hal_i2c_id_t | i2c_id | ) |
if the app wants to directly interface with the chip registers, this is a convenience function for getting the address/struct of a particular I2C Controller so the chip registers can be accessed.