せとうちオープン用のメインプログラム
Dependencies: mbed AQM1602 HMC6352 PID
setting/main.h@0:b910276f9da2, 2016-05-01 (annotated)
- Committer:
- lilac0112_1
- Date:
- Sun May 01 06:30:37 2016 +0000
- Revision:
- 0:b910276f9da2
from 2v10
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lilac0112_1 | 0:b910276f9da2 | 1 | #ifndef _MAIN_H_ |
lilac0112_1 | 0:b910276f9da2 | 2 | #define _MAIN_H_ |
lilac0112_1 | 0:b910276f9da2 | 3 | |
lilac0112_1 | 0:b910276f9da2 | 4 | #include "def.h" |
lilac0112_1 | 0:b910276f9da2 | 5 | |
lilac0112_1 | 0:b910276f9da2 | 6 | //pc(Computer) |
lilac0112_1 | 0:b910276f9da2 | 7 | RawSerial pc(monitor_tx, monitor_rx); |
lilac0112_1 | 0:b910276f9da2 | 8 | //led(main) |
lilac0112_1 | 0:b910276f9da2 | 9 | //DigitalOut LED[4]={led1, led2, led3, led4}; |
lilac0112_1 | 0:b910276f9da2 | 10 | BusOut LED(led1, led2, led3, led4); |
lilac0112_1 | 0:b910276f9da2 | 11 | //line(bottom) |
lilac0112_1 | 0:b910276f9da2 | 12 | BusOut LineKeeper(lineInA, lineInB, lineInC); |
lilac0112_1 | 0:b910276f9da2 | 13 | BusIn LineRaw(lineA2, lineB2, lineC2); |
lilac0112_1 | 0:b910276f9da2 | 14 | BusIn LineHold(lineA1, lineB1, lineC1); |
lilac0112_1 | 0:b910276f9da2 | 15 | InterruptIn Line[3]={lineA2, lineB2, lineC2}; |
lilac0112_1 | 0:b910276f9da2 | 16 | InterruptIn LineHolding[3]={lineA1, lineB1, lineC1}; |
lilac0112_1 | 0:b910276f9da2 | 17 | //ballcheck(bottom) |
lilac0112_1 | 0:b910276f9da2 | 18 | InterruptIn BallChecker(ballcheck); |
lilac0112_1 | 0:b910276f9da2 | 19 | AnalogIn BallCheckerA(ballcheck); |
lilac0112_1 | 0:b910276f9da2 | 20 | //debug_switch(debug_board) |
lilac0112_1 | 0:b910276f9da2 | 21 | DigitalIn Sw[4] = {selectsw1, selectsw2, debugsw1, debugsw2}; |
lilac0112_1 | 0:b910276f9da2 | 22 | //motor(main) |
lilac0112_1 | 0:b910276f9da2 | 23 | Serial motor(motor_tx, motor_rx); |
lilac0112_1 | 0:b910276f9da2 | 24 | //spi(main) |
lilac0112_1 | 0:b910276f9da2 | 25 | SPI spi(SPI_mosi, SPI_miso, SPI_slck); |
lilac0112_1 | 0:b910276f9da2 | 26 | DigitalOut spi_ss[4]={SPI_ss_sd, SPI_ss_sonic, SPI_ss_color, SPI_ss_ir}; |
lilac0112_1 | 0:b910276f9da2 | 27 | //bluetooth(debug_board) |
lilac0112_1 | 0:b910276f9da2 | 28 | RawSerial RN42(blue_rxd, blue_txd); |
lilac0112_1 | 0:b910276f9da2 | 29 | DigitalOut hmc_reset(blue_reset); |
lilac0112_1 | 0:b910276f9da2 | 30 | //lcd(debug_board) |
lilac0112_1 | 0:b910276f9da2 | 31 | AQM1602 Lcd(lcd_sda, lcd_scl); |
lilac0112_1 | 0:b910276f9da2 | 32 | //cmps(debug_board) |
lilac0112_1 | 0:b910276f9da2 | 33 | HMC6352 hmc(sens_sda, sens_scl); |
lilac0112_1 | 0:b910276f9da2 | 34 | //mouse(bottom) |
lilac0112_1 | 0:b910276f9da2 | 35 | adns_9800 mouse_sensor(mouse_mosi, mouse_miso, mouse_slck, mouse_ss); |
lilac0112_1 | 0:b910276f9da2 | 36 | //solenoid(bottom) |
lilac0112_1 | 0:b910276f9da2 | 37 | DigitalOut kicker(solenoid); |
lilac0112_1 | 0:b910276f9da2 | 38 | |
lilac0112_1 | 0:b910276f9da2 | 39 | //Serial for motors |
lilac0112_1 | 0:b910276f9da2 | 40 | int speed[4]={0}; |
lilac0112_1 | 0:b910276f9da2 | 41 | string StringFIN; |
lilac0112_1 | 0:b910276f9da2 | 42 | //PID |
lilac0112_1 | 0:b910276f9da2 | 43 | PID pid(P_GAIN,I_GAIN,D_GAIN, RATE); |
lilac0112_1 | 0:b910276f9da2 | 44 | //Ticker pidupdate; |
lilac0112_1 | 0:b910276f9da2 | 45 | //for Serial |
lilac0112_1 | 0:b910276f9da2 | 46 | volatile uint8_t INdata[DATA_NUM]={0}, EXdata[DATA_NUM]={0}; |
lilac0112_1 | 0:b910276f9da2 | 47 | //for DataSet |
lilac0112_1 | 0:b910276f9da2 | 48 | //Record data; |
lilac0112_1 | 0:b910276f9da2 | 49 | //NewStruct |
lilac0112_1 | 0:b910276f9da2 | 50 | CompassVal cmps_set; |
lilac0112_1 | 0:b910276f9da2 | 51 | SensorVal data; |
lilac0112_1 | 0:b910276f9da2 | 52 | SystemVal sys; |
lilac0112_1 | 0:b910276f9da2 | 53 | //for transition |
lilac0112_1 | 0:b910276f9da2 | 54 | Ticker Sw_ticker; |
lilac0112_1 | 0:b910276f9da2 | 55 | Timeout button; |
lilac0112_1 | 0:b910276f9da2 | 56 | bool state[4]={0,0,0,0}; |
lilac0112_1 | 0:b910276f9da2 | 57 | uint8_t statesum=0, last_statesum=0; |
lilac0112_1 | 0:b910276f9da2 | 58 | // for Time |
lilac0112_1 | 0:b910276f9da2 | 59 | Ticker Motor_ticker; |
lilac0112_1 | 0:b910276f9da2 | 60 | //Ticker Line_ticker; |
lilac0112_1 | 0:b910276f9da2 | 61 | Ticker Info_ticker; |
lilac0112_1 | 0:b910276f9da2 | 62 | //Ticker Hmc_ticker; |
lilac0112_1 | 0:b910276f9da2 | 63 | |
lilac0112_1 | 0:b910276f9da2 | 64 | //Timeout Line_timeout[3]; |
lilac0112_1 | 0:b910276f9da2 | 65 | Timeout Line_reset; |
lilac0112_1 | 0:b910276f9da2 | 66 | |
lilac0112_1 | 0:b910276f9da2 | 67 | Timeout Solenoid_timeout; |
lilac0112_1 | 0:b910276f9da2 | 68 | Timeout Kick_stop; |
lilac0112_1 | 0:b910276f9da2 | 69 | |
lilac0112_1 | 0:b910276f9da2 | 70 | Timeout Turn_timeout; |
lilac0112_1 | 0:b910276f9da2 | 71 | Timeout Turn_stop; |
lilac0112_1 | 0:b910276f9da2 | 72 | |
lilac0112_1 | 0:b910276f9da2 | 73 | Timeout Ball_judge; |
lilac0112_1 | 0:b910276f9da2 | 74 | |
lilac0112_1 | 0:b910276f9da2 | 75 | //Timeout Kick_now; |
lilac0112_1 | 0:b910276f9da2 | 76 | //Timeout Front_now; |
lilac0112_1 | 0:b910276f9da2 | 77 | //Timeout Line_home; |
lilac0112_1 | 0:b910276f9da2 | 78 | |
lilac0112_1 | 0:b910276f9da2 | 79 | Ticker Duty[DUTY_NUM]; |
lilac0112_1 | 0:b910276f9da2 | 80 | Timeout Stp; |
lilac0112_1 | 0:b910276f9da2 | 81 | double dutycycle[DUTY_NUM] ={//[s] |
lilac0112_1 | 0:b910276f9da2 | 82 | 0.2 |
lilac0112_1 | 0:b910276f9da2 | 83 | }; |
lilac0112_1 | 0:b910276f9da2 | 84 | |
lilac0112_1 | 0:b910276f9da2 | 85 | #endif /*_MAIN_H_*/ |