summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/output/kicker.h
blob: 080666af3dc534e4b730fd95e529513aacceab46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#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