summaryrefslogtreecommitdiff
path: root/src/arch/msp430fr5994lp/driver/timed_resistive_load.cc
blob: 09d6a84ed63f79ce89de16d2de70f33159c2b1e1 (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
85
86
87
88
89
90
/*
 * Copyright 2020 Daniel Friesel
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
#include "driver/timed_resistive_load.h"
#include "driver/gpio.h"
#include "arch.h"

#ifndef TIMED_RESISTIVE_LOAD_PIN1
#error TIMED_RESISTIVE_LOAD_PIN1 must be set
#endif

#ifndef TIMED_RESISTIVE_LOAD_PIN2
#error TIMED_RESISTIVE_LOAD_PIN2 must be set
#endif

#ifndef TIMED_RESISTIVE_LOAD_PIN3
#error TIMED_RESISTIVE_LOAD_PIN3 must be set
#endif

#ifndef TIMED_RESISTIVE_LOAD_PIN4
#error TIMED_RESISTIVE_LOAD_PIN4 must be set
#endif

void TimedResistiveLoad::setup()
{
	gpio.output(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.output(TIMED_RESISTIVE_LOAD_PIN2, 0);
	gpio.output(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.output(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

void TimedResistiveLoad::switchToNone()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

void TimedResistiveLoad::switchTo750()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

void TimedResistiveLoad::switchTo1K0()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

void TimedResistiveLoad::switchTo2K4()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 1);
}

void TimedResistiveLoad::switchTo3K3()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

void TimedResistiveLoad::switchTo10K()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 1);
}

void TimedResistiveLoad::switchTo47K()
{
	gpio.write(TIMED_RESISTIVE_LOAD_PIN1, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN2, 0);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN3, 1);
	gpio.write(TIMED_RESISTIVE_LOAD_PIN4, 0);
}

TimedResistiveLoad timedResistiveLoad;