NetBurner 3.5.6
PDF Version
SB800EX/include/bsp_devboard.h
1
#ifndef __NB_BSP_H
2
#define __NB_BSP_H
3
/*NB_REVISION*/
4
5
/*NB_COPYRIGHT*/
6
12
#include <pins.h>
13
14
#define PinGpioOutputFn PIN_GPIO
15
#define PinGpioInputFn PIN_GPIO
16
17
// Note:
18
// The SB800EX has two bidirectional/dual color indicator LEDs.
19
// For the sake of usage simplicity, this header treats each direction of the
20
// LED as a separate LED.
21
// The mapping from Software to Hardware is:
22
// LED1 => LED1, Red
23
// LED2 => LED2, Red
24
// LED3 => LED1, Green
25
// LED4 => LED2, Green
26
#define LED_COUNT 4
27
28
#define PIN_LED1 7
29
#define PIN_LED2 5
30
#define PIN_LED3 4
31
#define PIN_LED4 0
32
33
#define LED1 BiDirLED(PortI[PIN_LED1], PortI[PIN_LED2])
34
#define LED2 BiDirLED(PortI[PIN_LED3], PortH[PIN_LED4])
35
#define LED3 BiDirLED(PortI[PIN_LED2], PortI[PIN_LED1])
36
#define LED4 BiDirLED(PortH[PIN_LED4], PortI[PIN_LED3])
37
38
class
BiDirLED
39
{
40
CPU_PINS::PinIO A;
41
CPU_PINS::PinIO K;
42
43
public
:
44
BiDirLED(
const
CPU_PINS::PinIO &anode,
const
CPU_PINS::PinIO &cathode) : A(anode), K(cathode) {}
45
BiDirLED() : A(), K() {}
46
47
void
set(BOOL val = TRUE)
48
{
49
A.set(val);
50
K.clr();
51
}
// Set output high
52
BOOL toggle()
53
{
54
K.clr();
55
return
A.toggle();
56
}
// Toggle the pin state
57
void
clr()
58
{
59
A.clr();
60
K.clr();
61
}
// Set output low
62
BOOL read() {
return
A.read(); }
// Read pin hi/low state
63
void
hiz() { read(); }
// Set output to tristate
64
void
drive() { A.drive(); }
// Turn output on (opposite of tristate)
65
66
void
function(
int
ft)
67
{
68
A.function(ft);
69
K.function(ft);
70
}
// Set pin to special function
71
int
getFunction() {
return
A.getFunction(); }
// Get the special function the pin is set to
72
73
BiDirLED &operator=(BOOL b)
74
{
75
A.set(b);
76
K.clr();
77
return
*
this
;
78
}
79
BiDirLED &operator=(
int
i)
80
{
81
if
(i > 0)
82
{
83
A.set(1);
84
K.set(0);
85
}
86
else
if
(i < 0)
87
{
88
A.set(0);
89
K.set(1);
90
}
91
else
92
{
93
A.set(0);
94
K.set(0);
95
}
96
return
*
this
;
97
};
98
99
operator
int() {
return
read(); };
// Read and return int value
100
operator
BOOL() {
return
read(); };
// Read and return BOOL value
101
operator
bool() {
return
(read() != 0); };
// Read and return boolean value
102
};
103
104
class
LEDArray
105
{
106
public
:
107
BiDirLED operator[](
int
n)
108
{
109
switch
(n)
110
{
111
case
1:
return
LED1;
112
case
2:
return
LED2;
113
case
3:
return
LED3;
114
case
4:
return
LED4;
115
default
:
return
LED1;
116
}
117
}
118
};
119
120
static
LEDArray LEDs;
121
122
#endif