git.droids-corp.org
/
aversive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lots of work in opponent avoidance and strats
[aversive.git]
/
projects
/
microb2010
/
mainboard
/
main.c
diff --git
a/projects/microb2010/mainboard/main.c
b/projects/microb2010/mainboard/main.c
index
88d4f97
..
d7ac3d4
100755
(executable)
--- a/
projects/microb2010/mainboard/main.c
+++ b/
projects/microb2010/mainboard/main.c
@@
-67,7
+67,11
@@
#include "actuator.h"
#include "cs.h"
#include "strat_base.h"
#include "actuator.h"
#include "cs.h"
#include "strat_base.h"
+#include "strat_db.h"
+#include "strat_avoid.h"
#include "i2c_protocol.h"
#include "i2c_protocol.h"
+#include "beacon.h"
+
/* 0 means "programmed"
* ---- with 16 Mhz quartz
/* 0 means "programmed"
* ---- with 16 Mhz quartz
@@
-83,8
+87,9
@@
struct genboard gen;
struct mainboard mainboard;
struct genboard gen;
struct mainboard mainboard;
-struct cobboard cobboard;
-struct ballboard ballboard;
+volatile struct cobboard cobboard;
+volatile struct ballboard ballboard;
+volatile struct beaconboard beaconboard;
#ifndef HOST_VERSION
/***********************/
#ifndef HOST_VERSION
/***********************/
@@
-133,9
+138,21
@@
void do_time_monitor(void *dummy)
void do_led_blink(void *dummy)
{
void do_led_blink(void *dummy)
{
-#if 1 /* simple blink */
- LED1_TOGGLE();
-#endif
+ static uint8_t a = 0;
+
+ if (mainboard.flags & DO_ERRBLOCKING) {
+ if (a & 1)
+ LED1_ON();
+ else
+ LED1_OFF();
+ }
+ else {
+ if (a & 4)
+ LED1_ON();
+ else
+ LED1_OFF();
+ }
+ a++;
}
static void main_timer_interrupt(void)
}
static void main_timer_interrupt(void)
@@
-171,7
+188,11
@@
int main(void)
memset(&gen, 0, sizeof(gen));
memset(&mainboard, 0, sizeof(mainboard));
mainboard.flags = DO_ENCODERS | DO_CS | DO_RS |
memset(&gen, 0, sizeof(gen));
memset(&mainboard, 0, sizeof(mainboard));
mainboard.flags = DO_ENCODERS | DO_CS | DO_RS |
- DO_POS | DO_POWER | DO_BD;
+ DO_POS | DO_POWER | DO_BD | DO_ERRBLOCKING;
+ ballboard.lcob = I2C_COB_NONE;
+ ballboard.rcob = I2C_COB_NONE;
+
+ beaconboard.oppx = I2C_OPPONENT_NOT_THERE;
/* UART */
uart_init();
/* UART */
uart_init();
@@
-183,13
+204,17
@@
int main(void)
fdevopen(uart1_dev_send, uart1_dev_recv);
#endif
fdevopen(uart1_dev_send, uart1_dev_recv);
#endif
- //eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_MAINBOARD);
/* check eeprom to avoid to run the bad program */
if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) !=
EEPROM_MAGIC_MAINBOARD) {
/* check eeprom to avoid to run the bad program */
if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) !=
EEPROM_MAGIC_MAINBOARD) {
+ int c;
sei();
sei();
- printf_P(PSTR("Bad eeprom value\r\n"));
- while(1);
+ printf_P(PSTR("Bad eeprom value ('f' to force)\r\n"));
+ c = uart_recv(CMDLINE_UART);
+ if (c == 'f')
+ eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_MAINBOARD);
+ wait_ms(100);
+ bootloader();
}
#endif /* ! HOST_VERSION */
}
#endif /* ! HOST_VERSION */
@@
-262,13
+287,16
@@
int main(void)
/* all cs management */
microb_cs_init();
/* all cs management */
microb_cs_init();
-#ifndef HOST_VERSION
+ /* TIME */
+ time_init(TIME_PRIO);
+
/* sensors, will also init hardware adc */
sensor_init();
/* sensors, will also init hardware adc */
sensor_init();
- /*
TIME
*/
-
time_init(TIME_PRIO
);
+ /*
beacon
*/
+
beacon_init(
);
+#ifndef HOST_VERSION
/* start i2c slave polling */
scheduler_add_periodical_event_priority(i2c_poll_slaves, NULL,
8000L / SCHEDULER_UNIT, I2C_POLL_PRIO);
/* start i2c slave polling */
scheduler_add_periodical_event_priority(i2c_poll_slaves, NULL,
8000L / SCHEDULER_UNIT, I2C_POLL_PRIO);
@@
-277,7
+305,6
@@
int main(void)
/* strat */
gen.logs[0] = E_USER_STRAT;
gen.log_level = 5;
/* strat */
gen.logs[0] = E_USER_STRAT;
gen.log_level = 5;
- strat_reset_infos();
/* strat-related event */
scheduler_add_periodical_event_priority(strat_event, NULL,
/* strat-related event */
scheduler_add_periodical_event_priority(strat_event, NULL,
@@
-293,6
+320,9
@@
int main(void)
sei();
sei();
+ strat_db_init();
+ test_strat_avoid();
+
printf_P(PSTR("\r\n"));
printf_P(PSTR("Respect et robustesse.\r\n"));
#ifndef HOST_VERSION
printf_P(PSTR("\r\n"));
printf_P(PSTR("Respect et robustesse.\r\n"));
#ifndef HOST_VERSION