Skip to main content

Posts

Showing posts from December, 2016

Stm32 Peripheral Drivers from Scartch : GPIO Programming Part 3

In this part of the series we begin to write the functions that will make use of all the defines in our header file.

The first function we will need to implement is one to configure the pin and it looks something like this:

static void config_pin(GPIO_TypeDef *gpio, uint32_t pinNumber , uint32_t mode_type)
The first parameter in the function is going to be one of GPIO_TypeDef. I am not pulling this typedef out of thin air, it is defined the header file for the microcontroller stm32f10x.h. The parameter The next parameter is of an integer type which tells the function the pin number we will be configuring. The last parameter tells the function what is the mode type, for example if its an output mode do we want it to be a general purpose output or an open drain output  or an alternate function output.  An acceptable function call will use the definitions we made in our header file and it will look something like this:

config_pin(PORTA, 13 , OUTPUT_GEN_PURPOSE); Now lets think about what…