Tutorial 3 - Libraries

STM32F4Discovery Tutorial 3 - Libraries

This is the third video on the video tutorial series on stm32f4discovery board. In this tutorial we will learn about libraries. What is a library? What are the benefits to use a library? How to use library. We will understand the line by line program we have written in the previous tutorial. And how we have used the st library.

We will then modify the already written program in the previous tutorial. And understand how our code is interacting with hardware in reality.

#include "stm32f4xx.h"

GPIO_InitTypeDef GPIO_LED;

void Delay(__IO uint32_t nCount)
{       while(nCount--)
        {
        }
}

int main(void)
{
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  GPIO_LED.GPIO_Pin = GPIO_Pin_12;
  GPIO_LED.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_LED.GPIO_OType = GPIO_OType_PP;
  GPIO_LED.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_LED);

  while (1)
  {
          GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);
          Delay(16800000);
          GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);
          Delay(16800000);
  }
}