# I2C - 10-bit

Source: [https://docs.qualcomm.com/doc/80-58740-4/topic/i2c-10-bit.html](https://docs.qualcomm.com/doc/80-58740-4/topic/i2c-10-bit.html)

This demo mainly introduces I2C 10-bit slave mode data transmission.

## Hardware connection

The GPIO used in this demo refers to `board_i2c0_gpio_init`. Connect
                the USB to I2C module to the development board. The specific pin connection method
                is as follows (taking QCC743 as an example):

| Signal | USB to I2C module |
| --- | --- |
| SCL(GPIO14) | SCL |
| SDA(GPIO15) | SDA |

## Software implementation

For more detailed code, refer to
                    examples/peripherals/i2c/i2c\_10\_bit.

    board_init();Copy to clipboard

- `board_init` turns on the I2C IP clock and select the I2C clock
                    source and frequency division.

    board_i2c0_gpio_init();Copy to clipboard

- Configure related pins as `I2C` function

    i2c0 = qcc74x_device_get_by_name("i2c0");
    
    qcc74x_i2c_init(i2c0, 400000);Copy to clipboard

- Get the `i2c0` handle and initialize the i2c0 frequency to
                        400K

    struct qcc74x_i2c_msg_s msgs[2];
    uint8_t subaddr[2] = { 0x00, 0x04};
    uint8_t write_data[I2C_10BIT_TRANSFER_LENGTH];
    
    /* Write buffer init */
    write_data[0] = 0x55;
    write_data[1] = 0x11;
    write_data[2] = 0x22;
    for (size_t i = 3; i < I2C_10BIT_TRANSFER_LENGTH; i++) {
        write_data[i] = i;
    }
    
    /* Write data */
    msgs[0].addr = I2C_10BIT_SLAVE_ADDR;
    msgs[0].flags = I2C_M_NOSTOP | I2C_M_TEN;
    msgs[0].buffer = subaddr;
    msgs[0].length = 2;
    
    msgs[1].addr = I2C_10BIT_SLAVE_ADDR;
    msgs[1].flags = 0;
    msgs[1].buffer = write_data;
    msgs[1].length = I2C_10BIT_TRANSFER_LENGTH;
    
    qcc74x_i2c_transfer(i2c0, msgs, 2);Copy to clipboard

- Initialize sending data (write\_data) and configure slave device information
                        (msgs)
- `qcc74x_i2c_transfer(i2c0, msgs, 2)` enables I2C transfer

## Experimental phenomena

Send the `04 00 06 01 03 55` command to the USB to I2C module through
                the serial port (baud rate is greater than 115200) to set the I2C slave 10-bit mode
                data transmission. Press the RST button on the development board, and the serial
                port prints the write\_data data sent by the development board.

**Parent Topic:** [I2C](https://docs.qualcomm.com/doc/80-58740-4/topic/i2c.html)

Last Published: Feb 10, 2025

[Previous Topic
I2C](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/i2c.md) [Next Topic
I2C - eeprom](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/i2c-eeprom.md)