Skip to content

File main.cpp

File List > BootloaderBlink > main.cpp

Go to the documentation of this file

Source Code

#include "daisy_seed.h"

using namespace daisy;

DaisySeed hardware;
Switch bootloader_switch;

int main()
{
    hardware.Init();
    bool blinkState = false;

    bootloader_switch.Init(seed::D27);

    uint32_t blink_rate = 50; 
    uint32_t now, blink_time;
    now = blink_time = System::GetNow();

    while (true)
    {
        now = System::GetNow();

        if (now - blink_time > blink_rate)
        {
            hardware.SetLed(blinkState);
            blinkState = !blinkState;
            blink_time = now;
        }

        bootloader_switch.Debounce();
        if (bootloader_switch.FallingEdge())
        {
            System::ResetToBootloader(System::DAISY_INFINITE_TIMEOUT);
        }

        System::Delay(1);
    }
}