#include "stm32f4_discovery.h"
#include "stm32f4xx_conf.h" 
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "delay.h"
#include "usart.h"



int main(void)
{
usart2_init(115200);

//hardware init
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB2PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);


print(USART2, "pulses to charge and discharge a capacitor\n"); 

while(1)
        {
/*
	printf("Enter pulse duration in microseconds:"); fflush(stdout);
        unsigned int micros;
	scanf("%d",&micros);
*/
//NOTE: GPIO_SetBits are not inlined - use a macro to make it fast
	GPIO_SetBits(GPIOA, GPIO_Pin_5);
	Delay(28);
	GPIO_ResetBits(GPIOA, GPIO_Pin_5);
	Delay(28);
        }



}


