I2c pin details and sample program support for BC66

Hi,
i am using bc66 module for my R&D, i did access by AT commands and also i have programmed the chip by using qflash tool, but i need some assist for i2c in BC66 module. as per the datasheet the pin DCD shows under development. can anyone suggest me regarding i2c communication in the same BC66, is that possible for using some other pin as SCL and SDA.

Thanks & regards
hmdra

Hi wizlo,
Thanks for your pin detail. can you please suggest me about how to configure the modem. are you have any sample program or api list to access…

regards
hmdra

yep - but is Adruino source code for BC66

I2C examples - > BC66 SDK folder examples

Hi WizlO,
i have tried your program. i got successful response even the slave address is invalid. can you please suggest me to sort it out as soon as possible. i did connect RI as SCL and DCD as SDA.

here i copied my test program kindly go through it.

#include “custom_feature_def.h”
#include “ql_type.h”
#include “ql_stdlib.h”
#include “ql_uart.h”
#include “ril.h”
#include “ql_error.h”
#include “ql_iic.h”
#include “ql_gpio.h”
#include <stdint.h>
#include <stddef.h>

#define I2C_SlaveAddr 0x55
//#define I2C_WriteSlaveAddr 0xEC//1110 1100
#define I2C_ReadSlaveAddr 0x77//1110 1101
#define I2C_RECVBUF_LENGTH 8
#define I2C_SENDBUF_LENGTH 8
#define READ_BUFFER_LENGTH 1024

u8 I2C_RecvBuf[I2C_RECVBUF_LENGTH];
u8 I2C_SendBuf[I2C_SENDBUF_LENGTH] ={0xF5};
static u8 m_buffer[100];
static u8 m_Read_Buffer[READ_BUFFER_LENGTH];

char DBG_BUFFER[256];
#define DBG_PORT UART_PORT0
#define DBG(FORMAT, …)
{
Ql_memset(DBG_BUFFER, 0, sizeof(DBG_BUFFER));
Ql_sprintf(DBG_BUFFER, FORMAT, ##VA_ARGS);
Ql_UART_Write(DBG_PORT, (u8 *)DBG_BUFFER, Ql_strlen(DBG_BUFFER));
}

void uart_callback(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void *customizedPara)
{
}

void proc_main_task(s32 taskId)
{
s32 ret;
ST_MSG msg;
Ql_UART_Register(DBG_PORT, uart_callback, NULL);
Ql_UART_Open(DBG_PORT, 115200, FC_NONE);
// u8 write_buffer[4]={0x10,0x02,0x50,0x0a};
// u8 read_buffer[6]={0x14,0x22,0x33,0x44,0x55,0x66};
DBG(“BEGIN\n”);
while (1)
{
Ql_OS_GetMessage(&msg);
switch (msg.message)
{
case MSG_ID_RIL_READY:
Ql_RIL_Initialize();
DBG(“Ril Ready\n”);

        u8 write_buffer=0xF5;    
        u8 read_buffer[6]={0x14,0x22,0x33,0x44,0x55,0x66};     
        u8 registerAdrr[2]={0x01,0x45};   

        //IIC Initialization

        ret = Ql_IIC_Init(0,PINNAME_RI,PINNAME_DCD,1);
        if(ret < 0)
        {
            DBG("\r\n<--Failed!! Ql_IIC_Init channel 1 fail ret=%d-->\r\n",ret);
           
        }
         DBG("\r\n<--pins(%d & %d) Ql_IIC_Init channel 1 ret=%d-->\r\n",PINNAME_RI,PINNAME_DCD,ret);
      
        //IIC Config

        ret = Ql_IIC_Config(0,TRUE, I2C_SlaveAddr,I2C_FREQUENCY_400K);
        if(ret < 0)
        {
            DBG("\r\n<--Failed !!Ql_IIC_Config channel 1 fail ret=%d-->\r\n",ret);
            
        }
        DBG("\r\n<--Ql_IIC_Config channel 1 ret=%d-->\r\n",ret);
        while(1){
                ret = Ql_IIC_Write(0,I2C_SlaveAddr,&write_buffer,sizeof(write_buffer));
                if(ret < 0)
                {
                    DBG("\r\n<--Failed !! Ql_IIC_Write Channel 1 fail ret=%d-->\r\n",ret);
                            
                }
                DBG("\r\n<--Channel 1 Ql_IIC_Write ret=%d-->\r\n",ret);
                Ql_Sleep(200);

                ret=Ql_IIC_Read(0,I2C_SlaveAddr,I2C_RecvBuf,2); 
                if(ret > 0){
                        DBG("Read Succeeded:%d\n",ret);
                        for(int i=0;i<2;i++){
                                 DBG("Read : %d\t",I2C_RecvBuf[i]);
                         }
                } 

        }

    //     ret=Ql_IIC_Write(1, I2C_SlaveAddr,write_buffer,2);   
    //     if(ret > 0){
    //         DBG("Write Succeeded :%d\n",ret);
    //     } 
    //    // DBG("Read:%d\n",ret);

    //      ret=Ql_IIC_Read(1, I2C_SlaveAddr, read_buffer, sizeof(read_buffer)); 
    //      if(ret > 0){
    //          DBG("Read Succeeded:%d  %d\n",ret,read_buffer[0],read_buffer[1]);
    //      } 

        // ret=Ql_IIC_Write_Read(1, 0x77, registerAdrr, sizeof(registerAdrr),read_buffer, sizeof(read_buffer)); 
        //  if(ret > 0){
        //     DBG("write & Read Succeeded:%d\n",ret);
        //     for(int i=0;i<sizeof(read_buffer);i++){
        //         DBG("Read : %d\t",read_buffer[i]);
        //     }
        //} 

/*

        //IIC Write

        ret = Ql_IIC_Write(1,I2C_SlaveAddr,(u8*)I2C_SendBuf,2);
        if(ret < 0)
        {
            DBG("\r\n<--Failed !! Ql_IIC_Write channel 0 fail ret=%d-->\r\n",ret);
                       
        }
        DBG("\r\n<--channel 1 Ql_IIC_Write ret=%d-->\r\n",ret);
        

        //IIC read  

        ret = Ql_IIC_Read(1, I2C_ReadSlaveAddr, I2C_RecvBuf, 2);     //read data
        if(ret < 0)
        {
            DBG("\r\n<--Failed !! Ql_IIC_Read channel 1 fail ret=%d-->\r\n",ret);
                        
        }
        DBG("\r\nLength : %d Read_buffer[0]=(%d)  Read_buffer[1]=(%d) Read_buffer[2]=(%d) Read_buffer[3]=(%d) \r\n",ret,I2C_RecvBuf[0],I2C_RecvBuf[1],I2C_RecvBuf[2],I2C_RecvBuf[3]);

        Ql_IIC_Uninit(1);

        ret=Ql_GPIO_GetLevel(PINNAME_RI);
        DBG("RI pin voltage level:%d\n",ret);

        ret=Ql_GPIO_GetLevel(PINNAME_DCD);
        DBG("DCD pin voltage level:%d\n",ret);
       */
        break;
    }
}

}

Thanks
Hmdra

Hi,
The slave address must be 8 bit variant ( Mediatek SoC I2C )
example if device documentation say 7-bits = 0x3C you must shift to 8-bits = 0x78

SSD1306 display;
#define SLAVE_ADDRESS 0x78 /* doc say 0x3C */

hi,
thanks for your response, my slave address after shifting is 0x76 with SDO gnd and 0x77 for SDO to Vcc.
ret = Ql_IIC_Write(0,I2C_SlaveAddr,&write_buffer,sizeof(write_buffer));

when i call the above api it always shows the postive value, i tested it with wrong slave address, stilll it gives the positive value which means successful reading. but it should never happen for wrong slave address. i am not clear about where i missing the things…

please suggest me to solve.

Ql_IIC_Init( i2c_port = 1 , PINNAME_RI, PINNAME_DCD, IIC_TYPE = (i2c_port == 1) );
1 for RI/DCD

Ql_IIC_Init( i2c_port = 1 , PINNAME_RI, PINNAME_DCD, IIC_TYPE = (i2c_port == 1) );

i have tried this, but no change in output.

where i can get the register level datasheet fro bc66.

thanks

here is my lib for Arduino ( tested with OLED SSD1306 )