#pragma once

#include <cstdint>
#include <GPS_Interface.hpp>
#include <CTD_Interface.hpp>
#include <UART_Interface.hpp>
#include <TimerManager.hpp>
#include <MotorizedValve_Interface.hpp>
#include <system_time.hpp>

using CPFTimerManager_t = TimerManager<10>;

enum class LED : uint8_t
{
	OK = 0,
	ERROR
};

/* Initialize the processor
 *
 * This function initializes the processor as expected by the system. It is
 * expected to be called by main(), or some other early initialization code.
 *
 * This function configures clocks, power states, sets errata, and
 * any other necessary setup steps.
 *
 * @post The processor has been configured to match the system state.
 */
void initializeProcessor();

/* Initialize the board
 *
 * This function initializes all devices on the board. It is expected
 * to be called by main(), or some other early initialization code.
 * @pre The processor has already been initialized.
 * @post The devices installed on the board are ready
 *		for use by the greater application.
 */
void initializeBoard();

/** Set the system time
 *
 * @param [in] inTime The time to set the system to, usually acquired from
 *  a GPS
 * @param [in] input_capture_tickstamp The tickstamp (uptime_in_ms) associated
 * with the inTime capture. This is used to calculate the time offset between the GPS
 * and the current time, resulting in a more accurate time.
 */
void setTime(systime::DateTimeStruct inTime, uint64_t input_capture_tickstamp = 0);

GPS& getGPS1();
CTD& getCTD1();
UART& getUSART1();


CPFTimerManager_t::TimerHandle allocateSoftwareTimer();

/// Turn on the target LED
void enableLED(LED target);
/// Turn off the target LED
void disableLED(LED target);
/// Toggle the status of the target LED
void toggleLED(LED target);

/// Open or close the motorized valve
void setMotorizedValve(MotorizedValve::STATE desired);
/// Get valve state
bool isMotorizedValveOpen();
/// Is valve ready state
bool isMotorizedValveReady();
