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(
EBOARD_BLUETOOTH_SPEED
);
68
#else
69
_serial
.configure(
PIN_BLUETOOTH_RX
,
PIN_BLUETOOTH_TX
);
70
_serial
.begin(
EBOARD_BLUETOOTH_SPEED
);
71
#endif
72
if
(
PIN_BLUETOOTH_STATE
!=
PIN_BLUETOOTH_RX
)
setPin
(
PIN_BLUETOOTH_STATE
,INPUT);
73
#endif
74
#if EBOARD_I2C > 0x0
75
Wire
.begin();
76
#endif
77
#if EBOARD_SHIFT_REGISTER > 0x0
78
pinMode(
PIN_SHIFT_CLK
,OUTPUT);
79
pinMode(
PIN_SHIFT_DAT
,OUTPUT);
80
pinMode(
PIN_SHIFT_LAT
,OUTPUT);
81
shiftAll
();
//set all to 0
82
#endif
83
#if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0)
84
_servoHandler
.
begin
();
//Setup SPI
85
#endif
86
#if defined(EBOARD_HELPCAR)
87
mainMotor
.
attach
(
EBOARD_HELPCAR_MAIN
);
88
steerMotor
.
attach
(
EBOARD_HELPCAR_STEER
);
89
#if EBOARD_DEBUG_MODE > 0x0
90
Serial.println(
"Initializing main driving motor (3s)"
);
91
#endif
92
mainMotor
.
write
(
EBOARD_DRIVE_ZERO
);
93
steerMotor
.
write
(45);
94
delay(3005);
95
#if EBOARD_DEBUG_MODE > 0x0
96
Serial.println(
"Initializing of main driving motor completed"
);
97
#endif
98
#endif
99
#if EBOARD_DEBUG_MODE > 0x0
100
Serial.print((
char
)
eVirtual_main
());
101
Serial.println(
"fin"
);
102
#else
103
eVirtual_main
();
104
#endif
105
if
(
STOP
) {}
//prevent unused error
106
delay(200);
107
#if defined(EBOARD_HELPCAR)
108
mainMotor
.
write
(90);
109
#endif
110
cli();
//disable timers after running the program :D
111
#if EBOARD_USE_SPI > 0x0
112
writePWM
(0);analogWrite(
PIN_MOTOR_SPE
,0);
113
#endif
114
}
115
116
void
setup
(
void
) {
117
eagle_setup
();
118
}
120
121
#endif
writePWM
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
steerMotor
Servo steerMotor
Definition:
eBoard.h:651
setPin
void setPin(optVAL_t idx, optVAL_t mode=OUTPUT)
[COPY&PASTE] set a pin to a certain mode => checkPin() will return true then
Servo::write
void write(int value)
sets angle or pulse width of the Servo
PIN_MOTOR_SPE
#define PIN_MOTOR_SPE
Definition:
eBoard.h:576
EBOARD_BLUETOOTH_SPEED
#define EBOARD_BLUETOOTH_SPEED
Definition:
eBoard.h:456
PIN_SHIFT_CLK
#define PIN_SHIFT_CLK
Definition:
eBoard.h:587
EBOARD_DRIVE_ZERO
#define EBOARD_DRIVE_ZERO
Definition:
eBoard.h:344
ServoCds55::begin
void begin()
begin the communication and setup SPI
PIN_BLUETOOTH_RX
#define PIN_BLUETOOTH_RX
Definition:
eBoard.h:544
eagle_setup
void eagle_setup(void)
this is a guard
EBOARD_HELPCAR_MAIN
#define EBOARD_HELPCAR_MAIN
Definition:
eBoard.h:337
_serial
SoftwareSerial _serial
this is the recomenned-to-use _serial object for bluetooth communcation :D
Definition:
eBoard.h:625
STOP
static bool STOP
Definition:
eBoard.h:123
PIN_SHIFT_LAT
#define PIN_SHIFT_LAT
Definition:
eBoard.h:599
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:569
PIN_BLUETOOTH_TX
#define PIN_BLUETOOTH_TX
Definition:
eBoard.h:555
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:330
PIN_BLUETOOTH_STATE
#define PIN_BLUETOOTH_STATE
Definition:
eBoard.h:533
eVirtual_main
int eVirtual_main()
[COPY&PASTE] Assures the existence of the "qfix-code-main-method"
mainMotor
Servo mainMotor
Definition:
eBoard.h:651
PIN_SHIFT_DAT
#define PIN_SHIFT_DAT
Definition:
eBoard.h:593
EBOARD_DEBUG_SPEED
#define EBOARD_DEBUG_SPEED
Definition:
eBoard.h:303
eBoard
source
eagle_Setup.h
[WIP-510]
EagleoutIce
22.06.2018 00:28:45