1 Reply Latest reply on May 3, 2017 10:51 PM by amank_21

    GPIO Init issue

      Hello All

       

      I wanted to bring to your attention something I came across and was wondering if this indeed is an innate error and if not what sort of issues could I expect from this.

       

      In the glucose meter profile there is a GPIO pin/flag array named  “BLE_PROFILE_GPIO_CFG glucose_monitor_gpio_config”

       

      I noticed that this array is dimensioned as GPIO_NUM_MAX, which is “16”. But in the initialization of the struct in the code

      Depending on the pre-processor directive chosen it only initializes “15” out of the “16” pin/flag combination. This to me means that if one were to assign GPIO pin 0 with a flag that it might be overwritten by the un-initialized last member of the array to “0”. I don’t know what GPIO pin “0” is used for but it could be getting squashed somehow.

       

      Shouldn’t there be “16” array elements initialized and not “15”? It seems to be an issue below for the #ifdef cases of BLE_P1 and BLE_P2 …

      The default #ifdef case seems OK … please let me know

       

      typedef PACKED struct

      {

          INT8 gpio_pin[GPIO_NUM_MAX];    //pin number of gpio

          UINT16 gpio_flag[GPIO_NUM_MAX]; //flag of gpio

      } BLE_PROFILE_GPIO_CFG;

       

       

       

      #ifdef BLE_P1

      BLE_PROFILE_GPIO_CFG glucose_monitor_gpio_config =

      {

          /*.gpio_pin =*/

          {

              1, 14, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1

          },

          /*.gpio_flag =*/

          {

              GPIO_OUTPUT | GPIO_INIT_LOW  | GPIO_WP,

              GPIO_INPUT  | GPIO_INIT_LOW  | GPIO_BUTTON1 | GPIO_INT,

              GPIO_INPUT  | GPIO_INIT_HIGH | GPIO_BUTTON2 | GPIO_INT,

              GPIO_INPUT  | GPIO_INIT_HIGH | GPIO_BUTTON3 | GPIO_INT,

              GPIO_OUTPUT | GPIO_INIT_LOW,

              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

          },

      };

      #elif defined(BLE_P2)

      BLE_PROFILE_GPIO_CFG glucose_monitor_gpio_config =

      {

          /*.gpio_pin =*/

          {

              1, 0, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1

          },

          /*.gpio_flag =*/

          {

              GPIO_OUTPUT | GPIO_INIT_LOW | GPIO_WP,

              GPIO_INPUT | GPIO_INIT_LOW | GPIO_BUTTON1 | GPIO_INT,

              GPIO_INPUT | GPIO_INIT_HIGH | GPIO_BUTTON2 | GPIO_INT,

              GPIO_INPUT | GPIO_INIT_HIGH | GPIO_BUTTON3 | GPIO_INT,

              GPIO_OUTPUT | GPIO_INIT_LOW,

              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

          },

      };

       

      #else

      BLE_PROFILE_GPIO_CFG glucose_monitor_gpio_config =

      {

          /*.gpio_pin =*/

          {

             31, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1

          },

          /*.gpio_flag =*/

          {

              GPIO_OUTPUT | GPIO_INIT_LOW | GPIO_WP,

              GPIO_INPUT | GPIO_INIT_HIGH | GPIO_BUTTON1 | GPIO_INT,

              GPIO_INPUT | GPIO_INIT_HIGH | GPIO_BUTTON2 | GPIO_INT,

              GPIO_INPUT | GPIO_INIT_HIGH | GPIO_BUTTON3 | GPIO_INT,

              GPIO_OUTPUT | GPIO_INIT_LOW,

              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

          },

      };

      #endif

        • 1. Re: GPIO Init issue

          Hello,

           

          Thanks for pointing out but its not an error.
          as setting GPIO pins to -1 means that we are not using those pins.
          '-1' is an indicator that after this value we are not concerned of GPIO pin values.

           

          so we can us

          BLE_PROFILE_GPIO_CFG glucose_monitor_gpio_config =

          {

              /*.gpio_pin =*/

              {

                 31, 1, 2, 3, 4, -1

              },

          this also.we are mainly concerned of pins before -1 value.

           

          BR,
          Aman