Comments to source code

This commit is contained in:
Andreas Mieke 2018-04-03 17:18:28 +02:00
parent d109bae8d7
commit 9a18bd88f0
22 changed files with 286 additions and 122 deletions

View file

@ -5,11 +5,14 @@ uint8_t old_state;
void init_ne555(volatile uint32_t *SysTickCnt)
{
// Enable GPIOb clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
// Create gpio struct and fill it with default values
GPIO_InitTypeDef gpio;
GPIO_StructInit(&gpio);
// Set PB0 to input floating
gpio.GPIO_Mode = GPIO_Mode_IN_FLOATING;
gpio.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOB, &gpio);
@ -23,15 +26,18 @@ void run_ne555(float *freq)
uint8_t state;
*freq = 0.0f;
NE555STickCur = *NE555STick;
// Run for one second
while((*NE555STick - NE555STickCur) <= 1000)
{
state = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0);
// If the state changes low -> high or high -> low increment freq and save state
if (state != old_state)
{
(*freq)++;
old_state = state;
}
}
// Divide freq by two to get the frequency
*freq /= 2;
return;
}