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_hw_config == hw_config_smarttag)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, INPUT_PULLDOWN, PID_GPIO, false );
gpio_configurepin(gpio_port_0,gpio_pin_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,输出,pid_gpio,false);//绿色LED关闭以降低功耗
GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLUP, PID_GPIO, false);
gpio_configurepin(gpio_port_0,gpio_pin_3,input_pullup,pid_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_hw_config == hw_config_pvcell)
GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLDOWN, PID_GPIO, false );
gpio_configurepin(gpio_port_0,gpio_pin_3,input_pulldown,pid_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,输出,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,输出,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_configurepin(spi_gpio_port,spi_di_pin,输入,pid_spi_di,false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_7, OUTPUT, PID_GPIO, false); // SPI_PE
#elif(cfg_hw_config == hw_config_beacon_ref)
#ifdef cfg_spi_flash.
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_configurepin(spi_gpio_port,spi_di_pin,输入,pid_spi_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,
请检查灯架参考设计的各种配置,也许在某处有一个有关的内容,这取决于您的硬件配置。并在使用之前保留了GPIO引脚吗?如果存在冲突,这将给出线索。
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_scl,i2c_gpio_port,i2c_scl_pin,pid_i2c_scl);
保留_gpio(i2c_sda,i2c_gpio_port,i2c_sda_pin,pid_i2c_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,
是的,这个宏将在循环中以无限的循环结束。如果您删除它,我们无法判断会发生什么,您应该使用驱动程序,并测试您的固件。
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,