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
|
@ -4,11 +4,14 @@ volatile uint32_t *PiezoSTick, PiezoSTickCur, Freq;
|
|||
|
||||
void init_piezo(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 output push pull
|
||||
gpio.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
gpio.GPIO_Pin = GPIO_Pin_0;
|
||||
GPIO_Init(GPIOB, &gpio);
|
||||
|
@ -21,10 +24,13 @@ void run_piezo()
|
|||
{
|
||||
uint8_t pstate = 0x0;
|
||||
PiezoSTickCur = *PiezoSTick;
|
||||
// Run for one second
|
||||
while((*PiezoSTick - PiezoSTickCur) <= 1000)
|
||||
{
|
||||
Freq = *PiezoSTick;
|
||||
// Wait for 1 millisecond
|
||||
while((*PiezoSTick - Freq) <= 1);
|
||||
// Toggle output
|
||||
if (pstate) {
|
||||
pstate = ~pstate;
|
||||
GPIO_WriteBit(GPIOB, GPIO_Pin_0, Bit_SET);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue