mirror of
https://github.com/EranMorkon/AMTS.git
synced 2023-12-28 16:48:38 +00:00
Comments to source code
This commit is contained in:
parent
d109bae8d7
commit
9a18bd88f0
22 changed files with 286 additions and 122 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue