/*
 * Author: username
 * Date: 2025
 * filename: blink.c
 * description: module_purpose
 */

#include "blink.h"
// #include <ch32fun.h>

// Define the function pointer (initialized to NULL)
DelayFunction delay_ms = 0;

// Returns without caling if function pointer wasn't defined.
void blink_led(unsigned int times)
{
    if (!delay_ms)
    {
        return;
    }

    for (int i = 0; i < times; i++)
    {
        // Sets the gpio pin(high).
        *GPIO_PORT_BSHR |= (1 << 0);

        delay_ms(500);

        // Resets the gpio pin(low).
        *GPIO_PORT_BSHR |= (1 << (0 + 16));

        delay_ms(500);
    }
}
