eBoard ๐
โ โงโจ
Written for SIA 2017/2018
Main Page
Pages
Tutorials
Namespaces
Classes
Files
File List
File Members
eagle_Setup.h
Go to the documentation of this file.
1
#ifndef EAGLE_EBOARD_HELPLIB_SETUP
2
#define EAGLE_EBOARD_HELPLIB_SETUP
3
12
//=====================================================================================================================================================
13
// Setup
14
//=====================================================================================================================================================
15
16
//-------------------------------------------------------------------------------------------------------------------------------------------------
17
// cheat :D
18
//-------------------------------------------------------------------------------------------------------------------------------------------------
19
21
extern
int
eVirtual_main
();
23
24
//-------------------------------------------------------------------------------------------------------------------------------------------------
25
// setup
26
//-------------------------------------------------------------------------------------------------------------------------------------------------
27
28
void
eagle_setup
(
void
);
29
31
void
setup
(
void
);
32
33
35
36
//-------------------------------------------------------------------------------------------------------------------------------------------------
37
// definitions
38
//-------------------------------------------------------------------------------------------------------------------------------------------------
39
40
void
eagle_setup
(
void
) {
41
//setup of RX and TX should be handled manually - in everyCase ^^
42
#if EBOARD_NANO == 0x0
43
setPin(
PIN_MOTOR_DIR
);
44
setPin(
PIN_MOTOR_SPE
);
45
#endif
46
#if EBOARD_DEBUG_MODE > 0x0
47
Serial.begin(
EBOARD_DEBUG_SPEED
);
48
#endif
49
//this will initialize the interrupt handling!
50
#if (EBOARD_NANO == 0x0) || defined(REPT_TASK)
51
cli();
52
TIMSK2 &= ~(1<<TOIE2);
53
TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
54
TCCR2B &= ~(1<<WGM22);
55
ASSR &= ~(1<<AS2);
56
TIMSK2 &= ~(1<<OCIE2A);
57
TCCR2B |= (1<<CS22);
58
TCCR2B &= ~((1<<CS21) | (1<<CS20));
59
TCNT2 = 256 - (int)((
float
)F_CPU * 0.001 / 64);
60
TIMSK2 |= (1<<TOIE2);
61
sei();
62
#endif
63
#if EBOARD_BLUETOOTH > 0x0
64
#if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
67
Serial1.begin(38400);
68
#else
69
_serial
.begin(38400);
70
#endif
71
if
(
PIN_BLUETOOTH_STATE
!=
PIN_BLUETOOTH_RX
) setPin(
PIN_BLUETOOTH_STATE
,INPUT);
72
#endif
73
#if EBOARD_I2C > 0x0
74
Wire
.begin();
75
#endif
76
#if EBOARD_SHIFT_REGISTER > 0x0
77
pinMode(
PIN_SHIFT_CLK
,OUTPUT);
78
pinMode(
PIN_SHIFT_DAT
,OUTPUT);
79
pinMode(
PIN_SHIFT_LAT
,OUTPUT);
80
shiftAll
();
//set all to 0
81
#endif
82
#if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0)
83
_servoHandler
.
begin
();
//Setup SPI
84
#endif
85
#if defined(EBOARD_HELPCAR)
86
mainMotor
.
attach
(
EBOARD_HELPCAR_MAIN
);
87
steerMotor
.
attach
(
EBOARD_HELPCAR_STEER
);
88
#if EBOARD_DEBUG_MODE > 0x0
89
Serial.println(
"Initializing main driving motor (3s)"
);
90
#endif
91
mainMotor
.
write
(90);
92
delay(3005);
93
#if EBOARD_DEBUG_MODE > 0x0
94
Serial.println(
"Initializing of main driving motor completed"
);
95
#endif
96
#endif
97
#if EBOARD_DEBUG_MODE > 0x0
98
Serial.print((
char
)
eVirtual_main
());
99
Serial.println(
"fin"
);
100
#else
101
eVirtual_main
();
102
#endif
103
if
(
STOP
) {}
//prevent unused error
104
delay(200);
105
#if defined(EBOARD_HELPCAR)
106
mainMotor
.
write
(90);
107
#endif
108
cli();
//disable timers after running the program :D
109
#if EBOARD_USE_SPI > 0x0
110
writePWM
(0);analogWrite(
PIN_MOTOR_SPE
,0);
111
#endif
112
}
113
114
void
setup
(
void
) {
115
eagle_setup
();
116
}
118
119
#endif
writePWM
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
steerMotor
Servo steerMotor
Definition:
eBoard.h:627
Servo::write
void write(int value)
sets angle or pulse width of the Servo
_serial
SoftwareSerial _serial(0x13, 0x12)
this is the recomenned-to-use _serial object for bluetooth communcation :D
PIN_MOTOR_SPE
#define PIN_MOTOR_SPE
Definition:
eBoard.h:554
PIN_SHIFT_CLK
#define PIN_SHIFT_CLK
Definition:
eBoard.h:565
ServoCds55::begin
void begin()
begin the communication and setup SPI
PIN_BLUETOOTH_RX
#define PIN_BLUETOOTH_RX
Definition:
eBoard.h:522
eagle_setup
void eagle_setup(void)
this is a guard
EBOARD_HELPCAR_MAIN
#define EBOARD_HELPCAR_MAIN
Definition:
eBoard.h:323
STOP
static bool STOP
Definition:
eBoard.h:118
PIN_SHIFT_LAT
#define PIN_SHIFT_LAT
Definition:
eBoard.h:577
setup
void setup(void)
[COPY&PASTE] As we have an Arduino we need a setup function ;)
PIN_MOTOR_DIR
#define PIN_MOTOR_DIR
Definition:
eBoard.h:547
Wire
TwoWire Wire
this is the well-known Arduino Wire Interface, just a little bit 'modified' ;P
Definition:
eagle_TwoWire.h:401
shiftAll
void shiftAll(void)
[SHIFT] Changes bits according to store_bits
Servo::attach
uint8_t attach(int pin)
this will tell the Servo-instance which pin the data cable is connected to
_servoHandler
ServoCds55 _servoHandler
this is the "to_use" instance of ServoCds55
Definition:
eagle_ServoCds55.h:220
EBOARD_HELPCAR_STEER
#define EBOARD_HELPCAR_STEER
Definition:
eBoard.h:316
PIN_BLUETOOTH_STATE
#define PIN_BLUETOOTH_STATE
Definition:
eBoard.h:511
eVirtual_main
int eVirtual_main()
[COPY&PASTE] Assures the existence of the "qfix-code-main-method"
mainMotor
Servo mainMotor
Definition:
eBoard.h:627
PIN_SHIFT_DAT
#define PIN_SHIFT_DAT
Definition:
eBoard.h:571
EBOARD_DEBUG_SPEED
#define EBOARD_DEBUG_SPEED
Definition:
eBoard.h:289
eBoard
source
eagle_Setup.h
[WIP-BUILD]
EagleoutIce
03.05.2018 22:22:29