Hi,
I want to use a Sensor with I2C interface along with the beacon. I am working with Beacon reference design as my starting point. Although whenever i try to configure pins for i2c bus the beacon stops advertising for unknown reasons. The only change that i have made in the Beacon Reference design is in the periph_setup.c in the function set_pad where peripheral pins are assigned for beacon reference design. The changes made are:
//Code Snippet start
void set_pad_functions(void) // set gpio port function mode
{
#if(CFG\u HW\u CONFIG==HW\u CONFIG\u SMARTTAG)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, INPUT_PULLDOWN, PID_GPIO, false );
GPIO\ U配置引脚(GPIO\ U端口\ U 0,GPIO\ U引脚\ U 6,输出,PID\ GPIO,false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_GPIO, false);
if (!sys_startup_flag)
GPIO_ConfigurePin(GPIO_PORT_1,GPIO_PIN_5,OUTPUT,PID_GPIO,false);//绿色LED熄灭以降低功耗
GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLUP, PID_GPIO, false);
GPIO\u ConfigurePin(GPIO\u PORT\u 0,GPIO\u PIN\u 3,INPUT\u PULLUP,PID\u GPIO,false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_1, INPUT_PULLUP, PID_GPIO, false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_2, INPUT_PULLUP, PID_GPIO, false);
#elif (CFG_HW_CONFIG == HW_CONFIG_DK)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_1, INPUT_PULLUP, PID_GPIO, false); // PUSH_BUTTON
#elif(CFG\u HW\u CONFIG==HW\u CONFIG\u PVCELL)
GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLDOWN, PID_GPIO, false );
GPIO\u ConfigurePin(GPIO\u PORT\u 0,GPIO\u PIN\u 3,INPUT\u PULLDOWN,PID\u GPIO,false);
#elif (CFG_HW_CONFIG == HW_CONFIG_SMARTTAG2)
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); // BUZZER-
GPIO_ConfigurePin(GPIO_PORT_1,GPIO_PIN_0,OUTPUT,PID_GPIO,false);//蜂鸣器+
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_1, INPUT_PULLDOWN, PID_GPIO, false); // PUSH_BUTTON
GPIO_ConfigurePin(GPIO_PORT_0,GPIO_PIN_2,OUTPUT,PID_GPIO,false);//发光二极管
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CS_PIN, OUTPUT, PID_SPI_EN, true );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false );
GPIO\ U配置引脚(SPI\ U GPIO\ U端口,SPI\ U DI\ U引脚,输入,PID\ U SPI\ U DI,false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_7, OUTPUT, PID_GPIO, false); // SPI_PE
#elif(CFG\u HW\u CONFIG==HW\u CONFIG\u BEACON\u REF)
#ifdef CFG\u SPI\u闪存
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CS_PIN, OUTPUT, PID_SPI_EN, true );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false );
GPIO\ U配置引脚(SPI\ U GPIO\ U端口,SPI\ U DI\ U引脚,输入,PID\ U SPI\ U DI,false);
#endif
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SCL_PIN, INPUT, PID_I2C_SCL, false);/////This are the new lines i have added
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SDA_PIN, INPUT, PID_I2C_SDA,false);/////This are the new lines i have added
#endif
}
//代码段结束
And yes I have defined I2C_GPIO_PORT as Port 0, I2C_SCL_PIN as P0.6 and I2C_SDA_PIN as P0.7, So why does the beacon stop advertising when these two lines are added ? Is there a way to use I2C drivers with Beacon Reference design?
Thanks and Regards,
Hi Krutarth,
Please check the various configurations for the Beacon reference design, maybe there's a confilict somewhere, it depends on your hardware configuration. And have you reserved the GPIO pins before using it? This will give a clue if there is a conflict.
Thanks MT_dialog
谢谢你的建议_Dialog. I tried reserving GPIO pins where i am a bit confused. If you can clarify my confusion that will help a lot. When I write these lines for reserving GPIO
//Code Snippet Start
RESERVE_GPIO( SPI_CLK, I2C_GPIO_PORT, I2C_SCL_PIN, PID_I2C_SCL);
RESERVE_GPIO( SPI_DI, I2C_GPIO_PORT, I2C_SDA_PIN, PID_I2C_SDA);
//代码段结束
The code works fine but if i make these changes as shown below it stops working, I don't know why.
//Code Snippets Start
预留GPIO(I2C\ U SCL、I2C\ U GPIO\端口、I2C\ U SCL\引脚、PID\ I2C\ U SCL);
预留GPIO(I2C\ U SDA、I2C\ U GPIO\端口、I2C\ U SDA\引脚、PID\ U I2C\ U SDA);
//Code Snippet ends
Also i am using I2C bus does using defined constants SPI_CLK and SPI_DI make a difference?Please guide me through this.
Thanks and Regards,
Hi Krutarth,
As far as i know this should not make any difference, the name parameter in the RESERVE_GPIO is just a name and doesn't have any function in the macro RESERVE_GPIO. What you are mentioning sounds very weird.
Thanks MT_dialog
I am sorry there was another part of code that was creating the problem it was
//Code Snippet start
WAIT_UNTIL_I2C_FIFO_IS_EMPTY();
//Code Snippet end
Right now i am using PAN1740 evaluation kit and no I2C device is on the bus. So if this macro is called will it end into a endless waiting loop? Can i use I2C without using this macro?I was planning to have the device connected after i was done with firmware.
Thanks and Regards,
Hi krutarth,
是的,这个宏将以无休止的while循环结束。我们不能确定会发生什么,如果你只是删除它,你应该使用驱动程序,因为是和测试你的固件。
Thanks MT_dialog
Hi Dialog,
I have been trying to use the drivers provided by SDK to read temperature data from the sensor using I2C. The temperature data is of 2 bytes and is stored at a single address 0x00 i have trouble reading the second byte since all the functions in the driver provided by you guys read a single byte after sending address. The temperature sensor sends 2 bytes of data for the single address. Can you please tell me a solution to reading two bytes of data continuously for single address.
Thanks and Regards,
Close this ticket the issue has been solved in another thread.
Thanks and Regards,