summaryrefslogtreecommitdiff
path: root/n/es-2006/src
diff options
context:
space:
mode:
authordufourj2006-05-17 23:35:25 +0000
committerdufourj2006-05-17 23:35:25 +0000
commit03b39369582d6f4335f4a04f10b7ca8d5ff2b132 (patch)
treece10410fa9097ea4e689415e8ee2f29ae3857fa5 /n/es-2006/src
parent1b6e49045708b69ecb19bc80083c8197187b8b1e (diff)
ES (RVB) :
- correction de l'interruption lente (penser à lire les commentaires des .h) ; - diminution du nombre d'IC ignorés avant la véritable acquisition.
Diffstat (limited to 'n/es-2006/src')
-rw-r--r--n/es-2006/src/main.c5
-rw-r--r--n/es-2006/src/sensor_rvb.c18
-rw-r--r--n/es-2006/src/sensor_rvb.h4
3 files changed, 12 insertions, 15 deletions
diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c
index 68fffa8..22e7d3d 100644
--- a/n/es-2006/src/main.c
+++ b/n/es-2006/src/main.c
@@ -63,8 +63,9 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
/*** RVB ***/
/* RVB sensors configuration */
- case c ('p', 4):
- sensor_rvb_config (args[0], args[1], args[2]);
+ case c ('p', 3):
+ temp_16b = v8_to_v16 (args[1], args[2]);
+ sensor_rvb_config (args[0], temp_16b);
break;
/* RVB sniff configuration */
case c ('x', 1):
diff --git a/n/es-2006/src/sensor_rvb.c b/n/es-2006/src/sensor_rvb.c
index f53c324..5a4de2a 100644
--- a/n/es-2006/src/sensor_rvb.c
+++ b/n/es-2006/src/sensor_rvb.c
@@ -39,9 +39,10 @@
#define S0RVB 6
/** Max input capture before considering we can start the real capture.
* (default value) */
-#define RVB_MAX_FALSE_IC 9
+#define RVB_MAX_FALSE_IC 3
/** Max overflow of the timer 1 before thinking the sensor is HS. */
/* TODO Find a way to compute this value */
+/* FIXME with the new sensor config, we can lowdown this value, I hope */
#define RVB_MAX_OVERFLOW 253
/** Wait time between IO change in ns. */
#define RVB_SENSOR_DELAY_IO 125
@@ -61,9 +62,8 @@
/** Max input capture before considering we can start the real capture. */
uint8_t sensor_rvb_conf_max_false_ic_;
/** Max overflow of the timer 1 before thinking the sensor is HS. */
+/* XXX, 8 bits ? */
uint16_t sensor_rvb_conf_max_ov_;
-/** Wait time between IO change in ns. */
-uint8_t sensor_rvb_conf_delay_;
/** RVB sensor state flag. */
volatile uint8_t sensor_rvb_state_;
/** Internal computed result for one color. */
@@ -77,7 +77,6 @@ volatile uint8_t sensor_rvb_overflow_count_;
/** Results table for 9 RVB sensors (RVCB) */
volatile uint16_t sensor_rvb_values[RVB_MAX_SENSOR][4];
/** Count the number of IC before starting a good capture. */
-
uint8_t sensor_rvb_ic_count_;
/** Update everything for you. */
@@ -100,7 +99,7 @@ sensor_rvb_color_select (uint8_t sensor_rvb_color)
/* Select the color */
PORTF = (PORTF & ~0xC0) | (sensor_rvb_color << 6);
/* Wait a little */
- utils_delay_ns (sensor_rvb_conf_delay_);
+ utils_delay_ns (RVB_SENSOR_DELAY_IO);
/* Color exists */
return 1;
default:
@@ -135,11 +134,11 @@ sensor_rvb_sensor_select (uint8_t sensor_rvb_num)
PORTC = 0xff;
PORTD |= _BV(6);
/* Wait a little */
- utils_delay_ns (sensor_rvb_conf_delay_);
+ utils_delay_ns (RVB_SENSOR_DELAY_IO);
return 0;
}
/* Wait a little */
- utils_delay_ns (sensor_rvb_conf_delay_);
+ utils_delay_ns (RVB_SENSOR_DELAY_IO);
return 1;
}
@@ -150,7 +149,6 @@ sensor_rvb_init (void)
/* Init config */
sensor_rvb_conf_max_false_ic_ = RVB_MAX_FALSE_IC;
sensor_rvb_conf_max_ov_ = RVB_MAX_OVERFLOW;
- sensor_rvb_conf_delay_ = RVB_SENSOR_DELAY_IO;
/* No sensor selected */
sensor_rvb_sensor_select (0);
/* Put ENA* pins in output */
@@ -166,11 +164,10 @@ sensor_rvb_init (void)
/** Configure some internal variables. */
void
-sensor_rvb_config (uint8_t false_ic, uint16_t max_ov, uint8_t latency)
+sensor_rvb_config (uint8_t false_ic, uint16_t max_ov)
{
sensor_rvb_conf_max_false_ic_ = false_ic;
sensor_rvb_conf_max_ov_ = max_ov;
- sensor_rvb_conf_delay_ = latency;
}
/** Start updating RVBC values for sensors. */
@@ -192,6 +189,7 @@ sensor_rvb_start_capture (void)
}
/** Update everything for you. */
+// TODO, common part, clean TIFR, remove inline ?
inline void
sensor_rvb_update (void)
{
diff --git a/n/es-2006/src/sensor_rvb.h b/n/es-2006/src/sensor_rvb.h
index 787dc98..c863aeb 100644
--- a/n/es-2006/src/sensor_rvb.h
+++ b/n/es-2006/src/sensor_rvb.h
@@ -74,10 +74,8 @@ void sensor_rvb_start_capture (void);
* capture.
* - max_ov : maximum overflow of the timer/counter 1 before setting the
* sensor dead. uint8_t !
- * - latency : delay between change for sensor. Must be more than 100ns. This
- * setting is in ns.
*/
-void sensor_rvb_config (uint8_t false_ic, uint16_t max_ov, uint8_t latency);
+void sensor_rvb_config (uint8_t false_ic, uint16_t max_ov);
/** Update pins connected to the asserv AVR with the colors seen by the
* sensors. */