2 * Copyright Droids Corporation (2009)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: main.h,v 1.4 2009-05-27 20:04:07 zer0 Exp $
22 #define LED_TOGGLE(port, bit) do { \
23 if (port & _BV(bit)) \
29 #define LED1_ON() sbi(PORTJ, 2)
30 #define LED1_OFF() cbi(PORTJ, 2)
31 #define LED1_TOGGLE() LED_TOGGLE(PORTJ, 2)
33 #define LED2_ON() sbi(PORTL, 7)
34 #define LED2_OFF() cbi(PORTL, 7)
35 #define LED2_TOGGLE() LED_TOGGLE(PORTL, 7)
37 #define LED3_ON() sbi(PORTJ, 3)
38 #define LED3_OFF() cbi(PORTJ, 3)
39 #define LED3_TOGGLE() LED_TOGGLE(PORTJ, 3)
41 #define LED4_ON() sbi(PORTL, 6)
42 #define LED4_OFF() cbi(PORTL, 6)
43 #define LED4_TOGGLE() LED_TOGGLE(PORTL, 6)
45 #define BRAKE_DDR() do { DDRJ |= 0xF0; } while(0)
46 #define BRAKE_ON() do { PORTJ |= 0xF0; } while(0)
47 #define BRAKE_OFF() do { PORTJ &= 0x0F; } while(0)
49 #define ROLLER_ENCODER ((void *)0)
50 #define FORKTRANS_ENCODER ((void *)1)
51 #define FORKROT_ENCODER ((void *)2)
53 #define ROLLER_PWM ((void *)&gen.pwm1_4A)
54 #define FORKTRANS_PWM ((void *)&gen.pwm2_4B)
55 #define FORKROT_PWM ((void *)&gen.pwm3_1A)
56 #define XXX_PWM ((void *)&gen.pwm4_1B)
58 #define BALL_PRESENT_SENSOR 2 /* XXX dummy example */
61 #define E_USER_I2C_PROTO 195
62 #define E_USER_SENSOR 196
63 #define E_USER_BEACON 197
64 #define E_USER_SCANNER 198
65 #define E_USER_IMGPROCESS 199
71 #define I2C_POLL_PRIO 20
73 #define CS_PERIOD 5000L
77 /* generic to all boards */
79 /* command line interface */
81 char prompt[RDLINE_PROMPT_SIZE];
84 struct pwm_ng pwm1_4A;
85 struct pwm_ng pwm2_4B;
86 struct pwm_ng pwm3_1A;
87 struct pwm_ng pwm4_1B;
99 uint8_t logs[NB_LOGS+1];
107 struct pid_filter pid;
108 struct quadramp_filter qr;
109 struct blocking_detection bd;
112 /* ballboard specific */
114 #define DO_ENCODERS 1
118 uint8_t flags; /* misc flags */
120 /* control systems */
121 struct cs_block roller;
122 struct cs_block forktrans;
123 struct cs_block forkrot;
129 extern struct genboard gen;
130 extern struct ballboard ballboard;
132 /* start the bootloader */
133 void bootloader(void);
135 #define wait_cond_or_timeout(cond, timeout) \
137 microseconds __us = time_get_us2(); \
140 if (time_get_us2() - __us > (timeout)*1000L) {\