Implement Module 0--Line control at speed S8
[sudos/9s12.git] / sources / app / board.h
blob98107bb7082e18854b8ee1f80b02b88ca66cdfda
1 #ifndef BOARD_H
2 #define BOARD_H
4 #include "includes.h"
6 #define PIEX 50 //Set how many piexs in one line
7 #define LINE 60 //Set how many lines in one frame
8 #define FRAME 1 //Set how many frames to acquisition
10 #define POFFSET 100
11 #define LOFFSET 48
12 #define FOFFSET 4
14 #define S0 0 //Speed Switcher
15 #define S1 6553
16 #define S2 30107
17 #define S4 38214
18 #define S6 39321
19 #define S8 52428
20 #define S10 65000
22 #define M 3650 // Direction Switcher
23 #define R1 2200
24 #define L1 3200
25 #define R2 1300
26 #define L2 4200
27 #define WLFT 700
28 #define WRIT -800
30 #define LED1 PORTB_PB4
31 #define LED2 PORTB_PB5
32 #define LED3 PORTB_PB6
33 #define LED4 PORTB_PB7
35 #define KEY1 PORTE_PE6
36 #define KEY2 PORTE_PE5
37 ///#define KEY3 PORTE_PE6
38 //#define KEY4 PORTE_PE7
40 #define D0 PORTA_PA0
41 #define D1 PORTA_PA1
42 #define D2 PORTA_PA2
43 #define D3 PORTA_PA3
44 #define D4 PORTA_PA4
45 #define D5 PORTA_PA5
46 #define D6 PORTA_PA6
47 #define D7 PORTA_PA7
50 /* **************************************************
51 * Board declared global variables .
52 * PAY ATTENTION to define each one at modified file.
53 * **************************************************/
55 extern byte LINECNT; //Count line numbers while IRQ is enable
56 extern byte FRAMECNT; //Count frame numbers while PJINT is enable
57 extern byte LINEACH;
58 extern byte CNTFLAG;
59 extern byte LOFCNT; //Count each LINEACH capture one line
60 extern int DR;
61 extern byte data[LINE][PIEX];
64 extern byte EVNB; // Environment Brightness
65 extern bool KNOCK; // Task communicating
67 struct ctrl_data{
68 int LOR;
69 int WPLUS;
70 int MOTOR;
73 struct mod_data{
74 byte MOD; // Trace Module. LINE:0; 'S'route:1; 'U'route:2;
75 byte STA; // Route stage. Basically 3 Stage will be implemented. 1: head into; 2: in middle; 3: head out
77 int CNT; // Trace central offset in LINE
78 int TOP; // Trace top boundary in LINE
79 byte LFT; // Trace left boundary in PIEX
80 byte RIT; // Trace right boundary in PIEX
83 struct pid_data{
84 int kp;
85 int ki;
86 int kd;
90 void delay(int );
91 void dvrinit(void);
92 void transchar(void);
93 void transchar_n(void);
94 void envb(void);
95 void ctrl_pad(void);
96 void data_proc(void);
97 void ctrl_0(void);
98 void ctrl_1(void);
99 void ctrl_2(void);
100 int feedback(int a, int b, int kp);
101 #endif