#ifndef _KICKER_H
#define _KICKER_H

#include "../../stdafx.h"

class Kicker : public IO_Module
{
public:
	Kicker()
	{
		this->enabled = false;
		this->parent = NULL;
		this->moduleId = 0;
		this->portPower = NULL;
		this->portForward = NULL;
		this->portReverse = NULL;
		this->pinPower = 0;
		this->pinForward = 0;
		this->pinReverse = 0;
	}

	Kicker(uint32 kickerId)
	{
		this->enabled = false;
		this->parent = NULL;
		this->moduleId = kickerId;

		switch(kickerId)
		{
			case IO_KICKER_MAIN:
				this->portPower = &PORTG;
				this->portForward = &PORTA;
				this->portReverse = &PORTE;
				this->pinPower = (1 << 3);
				this->pinForward = (1 << 2);
				this->pinReverse = (1 << 6);
				break;
			default:
				this->portPower = NULL;
				this->portForward = NULL;
				this->portReverse = NULL;
				this->pinPower = 0;
				this->pinForward = 0;
				this->pinReverse = 0;
				break;
		}

		*this->portForward |= this->pinForward;
		*this->portReverse &= ~this->pinReverse;
	}

protected:
	bool enabled;

	//Hardware
	volatile uint8* portPower;
	volatile uint8* portForward;
	volatile uint8* portReverse;
	uint8 pinPower;
	uint8 pinForward;
	uint8 pinReverse;

public:
	bool GetEnabled()
	{
		return enabled;
	}

	void SetEnabled(bool newStatus)
	{
		enabled = newStatus;

		if(enabled)
		{
			*portPower |= pinPower;
		}
		else
		{
			*portPower &= ~pinPower;
		}
	}
};

#endif
