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  extern int eVirtual_main();
6 
7  void eagle_setup(void);
8 
10  void setup(void) {
11  eagle_setup();
12  }
13 
15  void eagle_setup(void) {
16  //setup of RX and TX should be handled manually - in everyCase ^^
17  #if EBOARD_NANO == 0x0
18  setPin(PIN_MOTOR_DIR);
19  setPin(PIN_MOTOR_SPE);
20  #endif
21  #if EBOARD_DEBUG_MODE > 0x0
22  Serial.begin(EBOARD_DEBUG_SPEED);
23  #endif
24  //this will initialize the interrupt handling!
25  #if (EBOARD_NANO == 0x0) || defined(REPT_TASK)
26  cli();
27  TIMSK2 &= ~(1<<TOIE2);
28  TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
29  TCCR2B &= ~(1<<WGM22);
30  ASSR &= ~(1<<AS2);
31  TIMSK2 &= ~(1<<OCIE2A);
32  TCCR2B |= (1<<CS22);
33  TCCR2B &= ~((1<<CS21) | (1<<CS20));
34  TCNT2 = 256 - (int)((float)F_CPU * 0.001 / 64);
35  TIMSK2 |= (1<<TOIE2);
36  sei();
37  #endif
38  #if EBOARD_BLUETOOTH > 0x0
39  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
42  Serial1.begin(38400);
43  #else
44  _serial.begin(38400);
45  #endif
47  #endif
48  #if EBOARD_I2C > 0x0
49  Wire.begin();
50  #endif
51  #if EBOARD_SHIFT_REGISTER > 0x0
52  pinMode(PIN_SHIFT_CLK,OUTPUT);
53  pinMode(PIN_SHIFT_DAT,OUTPUT);
54  pinMode(PIN_SHIFT_LAT,OUTPUT);
55  shiftAll(); //set all to 0
56  #endif
57  #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0)
58  _servoHandler.begin(); //Setup SPI
59  #endif
60  #if EBOARD_NANO > 0x0
61  mainMotor.attach(EBOARD_NANO_MAIN);
62  steerMotor.attach(EBOARD_NANO_STEER);
63  #if EBOARD_DEBUG_MODE > 0x0
64  Serial.println("Initializing main driving motor (3s)");
65  #endif
66  mainMotor.write(90);
67  delay(3005);
68  #if EBOARD_DEBUG_MODE > 0x0
69  Serial.println("Initializing of main driving motor completed");
70  #endif
71  #endif
72  #if EBOARD_DEBUG_MODE > 0x0
73  Serial.print((char) eVirtual_main());
74  Serial.println("fin");
75  #else
76  eVirtual_main();
77  #endif
78  if (STOP) {} //prevent unused error
79  delay(200);
80  #if EBOARD_NANO > 0x0
81  mainMotor.write(90);
82  #endif
83  cli(); //disable timers after running the program :D
84  #if EBOARD_NANO == 0x0
85  writePWM(0);analogWrite(PIN_MOTOR_SPE,0);
86  #endif
87  }
89 #endif
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
SoftwareSerial _serial(0x13, 0x12)
this is the recomenned-to-use _serial object for bluetooth communcation :D
#define PIN_MOTOR_SPE
Definition: eBoard.h:427
#define PIN_SHIFT_CLK
Definition: eBoard.h:434
#define EBOARD_NANO_STEER
Definition: eBoard.h:223
#define EBOARD_NANO_MAIN
Definition: eBoard.h:229
#define PIN_BLUETOOTH_RX
Definition: eBoard.h:399
void eagle_setup(void)
this is a guard
static bool STOP
Definition: eBoard.h:186
#define PIN_SHIFT_LAT
Definition: eBoard.h:446
void setup(void)
[COPY&PASTE] As we have an Arduino we need a setup function ;)
Definition: eagle_Setup.h:10
#define PIN_MOTOR_DIR
Definition: eBoard.h:420
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
#define PIN_BLUETOOTH_STATE
Definition: eBoard.h:388
int eVirtual_main()
[COPY&PASTE] Assures the existence of the "qfix-code-main-method"
#define PIN_SHIFT_DAT
Definition: eBoard.h:440
#define EBOARD_DEBUG_SPEED
Definition: eBoard.h:283