summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/robospierre
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io-hub/src/robospierre')
-rw-r--r--digital/io-hub/src/robospierre/Makefile1
-rw-r--r--digital/io-hub/src/robospierre/contact_defs.h37
-rw-r--r--digital/io-hub/src/robospierre/main.c15
-rw-r--r--digital/io-hub/src/robospierre/simu.host.c3
-rw-r--r--digital/io-hub/src/robospierre/simu.host.h2
5 files changed, 58 insertions, 0 deletions
diff --git a/digital/io-hub/src/robospierre/Makefile b/digital/io-hub/src/robospierre/Makefile
index 9d0035fe..a95d7586 100644
--- a/digital/io-hub/src/robospierre/Makefile
+++ b/digital/io-hub/src/robospierre/Makefile
@@ -5,6 +5,7 @@ PROGS = io_hub
# Sources to compile.
io_hub_SOURCES = main.c \
pwm.avr.c pwm.host.c \
+ contact.avr.c contact.host.c \
twi_master.c asserv.c mimot.c \
chrono.c timer.avr.c simu.host.c
# Modules needed for IO.
diff --git a/digital/io-hub/src/robospierre/contact_defs.h b/digital/io-hub/src/robospierre/contact_defs.h
new file mode 100644
index 00000000..55b34354
--- /dev/null
+++ b/digital/io-hub/src/robospierre/contact_defs.h
@@ -0,0 +1,37 @@
+#ifndef contact_defs_h
+#define contact_defs_h
+/* contact_defs.h */
+/* robospierre - Eurobot 2011 AI. {{{
+ *
+ * Copyright (C) 2011 Nicolas Schodet
+ *
+ * APBTeam:
+ * Web: http://apbteam.org/
+ * Email: team AT apbteam DOT org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+
+#define CONTACT_COLOR A, 7
+#define CONTACT_JACK F, 7
+#define CONTACT_EX1 E, 0
+#define CONTACT_EX2 E, 1
+
+#define CONTACT_LIST \
+ CONTACT (CONTACT_EX1) \
+ CONTACT (CONTACT_EX2)
+
+#endif /* contact_defs_h */
diff --git a/digital/io-hub/src/robospierre/main.c b/digital/io-hub/src/robospierre/main.c
index 12a35054..bbc9bdb9 100644
--- a/digital/io-hub/src/robospierre/main.c
+++ b/digital/io-hub/src/robospierre/main.c
@@ -37,6 +37,7 @@
#include "twi_master.h"
#include "pwm.h"
+#include "contact.h"
#include "io.h"
@@ -46,6 +47,9 @@ enum team_color_e team_color;
/** Asserv stats counters. */
static uint8_t main_stats_asserv_, main_stats_asserv_cpt_;
+/** Contact stats counters. */
+static uint8_t main_stats_contact_, main_stats_contact_cpt_;
+
/** Main initialisation. */
static void
main_init (void)
@@ -62,6 +66,7 @@ main_init (void)
twi_master_init ();
/* IO modules. */
pwm_init ();
+ contact_init ();
/* Initialization done. */
proto_send0 ('z');
}
@@ -94,6 +99,7 @@ main_loop (void)
proto_accept (uart0_getc ());
/* Update IO modules. */
pwm_update ();
+ contact_update ();
/* Only manage events if slaves are synchronised. */
if (twi_master_sync ())
main_event_to_fsm ();
@@ -108,6 +114,11 @@ main_loop (void)
/* Reset stats counter */
main_stats_asserv_cpt_ = main_stats_asserv_;
}
+ if (main_stats_contact_ && !--main_stats_contact_cpt_)
+ {
+ proto_send1d ('P', contact_all ());
+ main_stats_contact_cpt_ = main_stats_contact_;
+ }
}
}
@@ -144,6 +155,10 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
/* Position stats. */
main_stats_asserv_ = main_stats_asserv_cpt_ = args[0];
break;
+ case c ('P', 1):
+ /* Contact stats. */
+ main_stats_contact_ = main_stats_contact_cpt_ = args[0];
+ break;
default:
/* Unknown commands */
proto_send0 ('?');
diff --git a/digital/io-hub/src/robospierre/simu.host.c b/digital/io-hub/src/robospierre/simu.host.c
index 76e48edd..8f4019aa 100644
--- a/digital/io-hub/src/robospierre/simu.host.c
+++ b/digital/io-hub/src/robospierre/simu.host.c
@@ -30,6 +30,9 @@
#include "modules/host/mex.h"
#include "io.h"
+/** AVR registers. */
+uint8_t PINE;
+
/** Initialise simulation. */
void
simu_init (void)
diff --git a/digital/io-hub/src/robospierre/simu.host.h b/digital/io-hub/src/robospierre/simu.host.h
index 76326a31..4b461e86 100644
--- a/digital/io-hub/src/robospierre/simu.host.h
+++ b/digital/io-hub/src/robospierre/simu.host.h
@@ -27,6 +27,8 @@
#ifdef HOST
+extern uint8_t PINE;
+
#else /* !defined (HOST) */
#endif /* !defined (HOST) */