GPIO initailization simplification
Answer
11/20/15 10:35 AM
Hey :)

when you currently are using one of the GPIO Pins of the extension boards the initialization procedure is as I guess a little bit more complicated as it needs to be. Therefore I would suggest three different points:
  1. Add a GPIO_handleInfo_t for each Pin in the xdk_board.c like it is currently done for gpioRedLed_HandleInfo, gpioButton1_HandleInfo, etc. To extend this it may be useful to define two different handles for each pin that is either configured as an input or output.
  2. In the current version of the GPIO_init you have to declare whether the pin will be an input or output even though this information is already stored in the GPIO_handleInfo struct.
  3. Extend the GPIO_pinStates_t with GPIO_State_Pull_Up and GPIO_State_Pull_Down for the state of the  resistors when the pin is set as an input.
With this simple changes the initalization and use of a random pin later could look like this:

GPIO_handle_tp gpioPA1_Handle = (GPIO_handle_tp)(&gpioPA1_Input_HandleInfo);
GPIO_handle_tp gpioPA2_Handle = (GPIO_handle_tp)(&gpioPA2_Output_HandleInfo);

void func(void)
{
     //Initialize PA1 and PA2
    GPIO_init(gpioPA1_Handle, GPIO_State_Pull_Up);
    GPIO_init(gpioPA2_Handle, GPIO_State_Off);

    //Reading and writing from/to pins is already very simple and can continue to work as always
}

What are you thinking about this idea?

Kind regards,

Kai Liebich
0 (0 Votes)
GPIO initailization simplification
Answer
12/1/15 11:49 AM as a reply to Kai Clemens Liebich.
Hey Kai,

we're currently working hard improving the XDK SDK and continously trying to make the lifes of our devs easier, unfortunately as you might know, that's not always easy when developing a whole SDK ... ;) 

So I definitely see your case here, which is why I forwarded your code sample to the responsible people to be considered to be included in one of the next releases.

- Florian
0 (0 Votes)