eBoard ①⑧⑨
Written for SIA 2017/2018
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
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
71  #endif
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)
89  #if EBOARD_DEBUG_MODE > 0x0
90  Serial.println("Initializing main driving motor (3s)");
91  #endif
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
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
Servo steerMotor
Definition: eBoard.h:651
void setPin(optVAL_t idx, optVAL_t mode=OUTPUT)
[COPY&PASTE] set a pin to a certain mode => checkPin() will return true then
void write(int value)
sets angle or pulse width of the Servo
#define PIN_MOTOR_SPE
Definition: eBoard.h:576
#define EBOARD_BLUETOOTH_SPEED
Definition: eBoard.h:456
#define PIN_SHIFT_CLK
Definition: eBoard.h:587
#define EBOARD_DRIVE_ZERO
Definition: eBoard.h:344
void begin()
begin the communication and setup SPI
#define PIN_BLUETOOTH_RX
Definition: eBoard.h:544
void eagle_setup(void)
this is a guard
#define EBOARD_HELPCAR_MAIN
Definition: eBoard.h:337
SoftwareSerial _serial
this is the recomenned-to-use _serial object for bluetooth communcation :D
Definition: eBoard.h:625
static bool STOP
Definition: eBoard.h:123
#define PIN_SHIFT_LAT
Definition: eBoard.h:599
void setup(void)
[COPY&PASTE] As we have an Arduino we need a setup function ;)
#define PIN_MOTOR_DIR
Definition: eBoard.h:569
#define PIN_BLUETOOTH_TX
Definition: eBoard.h:555
TwoWire Wire
this is the well-known Arduino Wire Interface, just a little bit &#39;modified&#39; ;P
void shiftAll(void)
[SHIFT] Changes bits according to store_bits
uint8_t attach(int pin)
this will tell the Servo-instance which pin the data cable is connected to
ServoCds55 _servoHandler
this is the "to_use" instance of ServoCds55
#define EBOARD_HELPCAR_STEER
Definition: eBoard.h:330
#define PIN_BLUETOOTH_STATE
Definition: eBoard.h:533
int eVirtual_main()
[COPY&PASTE] Assures the existence of the "qfix-code-main-method"
Servo mainMotor
Definition: eBoard.h:651
#define PIN_SHIFT_DAT
Definition: eBoard.h:593
#define EBOARD_DEBUG_SPEED
Definition: eBoard.h:303