Skip to content

Instantly share code, notes, and snippets.

@dheeptuck
Created May 1, 2020 20:28
Show Gist options
  • Save dheeptuck/61c88ec3d1edddf3af927f2bf58926e8 to your computer and use it in GitHub Desktop.
Save dheeptuck/61c88ec3d1edddf3af927f2bf58926e8 to your computer and use it in GitHub Desktop.
void portable_delay_cycles(unsigned long n)
{
while (n--)
{
asm volatile ("");
}
}
volatile void Task0()
{
while(1)
{
/// Toggle @ 50 ms
portable_delay_cycles(100000);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);
}
}
volatile void Task1()
{
while(1)
{
/// Toggle @ 100 ms
portable_delay_cycles(200000);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment