cancel
Showing results for 
Search instead for 
Did you mean: 

Want to use Hal I2C calls instead of Wire.H for TE Arduino 5 sensor weather shield on a STM32F746G-Disco board -

William Spencer
Associate
Posted on July 16, 2018 at 00:47

We are evaluating embedded controllers this as a summer intern project and wanted to try the TE Arduino Weather Shield with a STM32F746G-Disco board.  The shield plugs directly into the Arduino V3 pins on the discovery board.  We are using Atollic True Studio with the STM32cube templates for the touch screen and have pasted in the HAL I2C example to see the basic I2C send and receive calls using HAL.

Now to the problems - We have downloaded code from GitHub for the TE Weather Shield sensors but they use the Arduino Wire.H  and Wire.cpp to communicate to each of the 5 sensors on the shield.  I would like to know if anybody has written a translator using HAL calls for the wire.h /  wire.cpp functions that could be used.  Another question is how best to use the HAL GPIO  to set/select the on-shield sensor.  I am finding that it is apparently difficult to find documentation on the HAL function call details but assume there is an easy call to use or a manual that I am missing.  Below is a snippet from the TE Weather Shield software that shows what is needed.  That is we basically need to set pins for Output and a digitalWrite function  to configure the three pins as an address to the sensor. I assume these are on GPIOB like the I2C SCL and SDA lines. Is there an equivalent HAL function call to pinMode(,)  and digitalWrite(,) functions?

void TEWeatherShield::selectSensor(enum TEWeatherShield_Sensor sensor) {

  pinMode(9, OUTPUT);

  pinMode(10, OUTPUT);

  pinMode(11, OUTPUT);

  switch (sensor) {

  case Sensor_HTU21D:

    digitalWrite(9, LOW);

    digitalWrite(10, LOW);

    digitalWrite(11, LOW);

    delay(5);

    break;

  case Sensor_MS5637:

    digitalWrite(9, LOW);

    digitalWrite(10, LOW);

    digitalWrite(11, LOW);

    delay(5);

    break;

  case Sensor_MS8607:

    digitalWrite(9, LOW);

    digitalWrite(10, LOW);

    digitalWrite(11, HIGH);

    delay(5);

    break;

….

0 REPLIES 0