summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-08-31 21:01:21 -0500
committerKeith Packard <keithp@keithp.com>2012-08-31 21:01:21 -0500
commitf9af7819de086d9179c3a4d1df7c88ab67a7d7c7 (patch)
tree03588676c8870085ada79d53e39208ade02cac08 /src
parent6d8858ca1899c8b64f107ebb45711efbb7b8d62a (diff)
altos: Add custom panic noise for self-test failures
Make it easier to tell which component is failing self test Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/ao.h5
-rw-r--r--src/core/ao_panic.c10
-rw-r--r--src/drivers/ao_cc1120.c4
-rw-r--r--src/drivers/ao_mpu6000.c2
-rw-r--r--src/drivers/ao_ms5607.c35
5 files changed, 34 insertions, 22 deletions
diff --git a/src/core/ao.h b/src/core/ao.h
index 66c0881f..4f4779ec 100644
--- a/src/core/ao.h
+++ b/src/core/ao.h
@@ -115,7 +115,10 @@ ao_start_scheduler(void);
#define AO_PANIC_BT 11 /* Communications with bluetooth device failed */
#define AO_PANIC_STACK 12 /* Stack overflow */
#define AO_PANIC_SPI 13 /* SPI communication failure */
-#define AO_PANIC_SELF_TEST 14 /* Self test failure */
+#define AO_PANIC_SELF_TEST_CC1120 0x40 | 1 /* Self test failure */
+#define AO_PANIC_SELF_TEST_HMC5883 0x40 | 2 /* Self test failure */
+#define AO_PANIC_SELF_TEST_MPU6000 0x40 | 3 /* Self test failure */
+#define AO_PANIC_SELF_TEST_MS5607 0x40 | 4 /* Self test failure */
/* Stop the operating system, beeping and blinking the reason */
void
diff --git a/src/core/ao_panic.c b/src/core/ao_panic.c
index 25dc145e..52433044 100644
--- a/src/core/ao_panic.c
+++ b/src/core/ao_panic.c
@@ -65,7 +65,15 @@ ao_panic(uint8_t reason)
#ifdef SDCC
#pragma disable_warning 126
#endif
- for (n = 0; n < reason; n++) {
+ if (reason & 0x40) {
+ ao_led_on(AO_LED_RED);
+ ao_beep(AO_BEEP_HIGH);
+ ao_panic_delay(40);
+ ao_led_off(AO_LED_RED);
+ ao_beep(AO_BEEP_OFF);
+ ao_panic_delay(10);
+ }
+ for (n = 0; n < (reason & 0x3f); n++) {
ao_led_on(AO_LED_RED);
ao_beep(AO_BEEP_MID);
ao_panic_delay(10);
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c
index 4df931b5..2f9c296f 100644
--- a/src/drivers/ao_cc1120.c
+++ b/src/drivers/ao_cc1120.c
@@ -1028,12 +1028,12 @@ ao_radio_init(void)
AO_CC1120_SPI_CS_PORT->bsrr = ((uint32_t) (1 << AO_CC1120_SPI_CS_PIN));
for (i = 0; i < 10000; i++) {
- if ((SPI_2_GPIO->idr & (1 << SPI_2_MISO)) == 0)
+ if ((SPI_2_PORT->idr & (1 << SPI_2_MISO_PIN)) == 0)
break;
}
AO_CC1120_SPI_CS_PORT->bsrr = (1 << AO_CC1120_SPI_CS_PIN);
if (i == 10000)
- ao_panic(AO_PANIC_SELF_TEST);
+ ao_panic(AO_PANIC_SELF_TEST_CC1120);
/* Enable the EXTI interrupt for the appropriate pin */
ao_enable_port(AO_CC1120_INT_PORT);
diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c
index e8c80f12..b3e284e0 100644
--- a/src/drivers/ao_mpu6000.c
+++ b/src/drivers/ao_mpu6000.c
@@ -225,7 +225,7 @@ ao_mpu6000_setup(void)
errors += ao_mpu6000_gyro_check(normal_mode.gyro_z, test_mode.gyro_z, "z");
if (errors)
- ao_panic(AO_PANIC_SELF_TEST);
+ ao_panic(AO_PANIC_SELF_TEST_MPU6000);
/* Filter to about 100Hz, which also sets the gyro rate to 1000Hz */
ao_mpu6000_reg_write(MPU6000_CONFIG,
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index ec0d2202..704b4583 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -27,12 +27,12 @@ static uint8_t ms5607_configured;
static void
ao_ms5607_start(void) {
ao_spi_get(AO_MS5607_SPI_INDEX,AO_SPI_SPEED_FAST);
- stm_gpio_set(AO_MS5607_CS_GPIO, AO_MS5607_CS, 0);
+ stm_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 0);
}
static void
ao_ms5607_stop(void) {
- stm_gpio_set(AO_MS5607_CS_GPIO, AO_MS5607_CS, 1);
+ stm_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 1);
ao_spi_put(AO_MS5607_SPI_INDEX);
}
@@ -92,7 +92,7 @@ ao_ms5607_prom_read(struct ao_ms5607_prom *prom)
printf ("MS5607 PROM CRC error (computed %x actual %x)\n",
crc, (((uint8_t *) prom)[15] & 0xf));
flush();
- ao_panic(AO_PANIC_SELF_TEST);
+// ao_panic(AO_PANIC_SELF_TEST_MS5607);
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -120,7 +120,7 @@ static uint8_t ao_ms5607_done;
static void
ao_ms5607_isr(void)
{
- ao_exti_disable(AO_MS5607_MISO_GPIO, AO_MS5607_MISO);
+ ao_exti_disable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN);
ao_ms5607_done = 1;
ao_wakeup(&ao_ms5607_done);
}
@@ -135,7 +135,7 @@ ao_ms5607_get_sample(uint8_t cmd) {
ao_ms5607_start();
ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX);
- ao_exti_enable(AO_MS5607_MISO_GPIO, AO_MS5607_MISO);
+ ao_exti_enable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN);
#if AO_MS5607_PRIVATE_PINS
ao_spi_put(AO_MS5607_SPI_INDEX);
#endif
@@ -144,7 +144,7 @@ ao_ms5607_get_sample(uint8_t cmd) {
ao_sleep(&ao_ms5607_done);
sei();
#if AO_MS5607_PRIVATE_PINS
- stm_gpio_set(AO_MS5607_CS_GPIO, AO_MS5607_CS, 1);
+ stm_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 1);
#else
ao_ms5607_stop();
#endif
@@ -235,13 +235,14 @@ ao_ms5607_info(void)
static void
ao_ms5607_dump(void)
{
- struct ao_data sample;
+ struct ao_ms5607_sample sample;
struct ao_ms5607_value value;
- ao_data_get(&sample);
- ao_ms5607_convert(&sample.ms5607_raw, &value);
- printf ("Pressure: %8u %8d\n", sample.ms5607_raw.pres, value.pres);
- printf ("Temperature: %8u %8d\n", sample.ms5607_raw.temp, value.temp);
+ ao_ms5607_setup();
+ ao_ms5607_sample(&sample);
+ ao_ms5607_convert(&sample, &value);
+ printf ("Pressure: %8u %8d\n", sample.pres, value.pres);
+ printf ("Temperature: %8u %8d\n", sample.temp, value.temp);
printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres));
}
@@ -255,24 +256,24 @@ ao_ms5607_init(void)
{
ms5607_configured = 0;
ao_cmd_register(&ao_ms5607_cmds[0]);
- ao_spi_init_cs(AO_MS5607_CS_GPIO, (1 << AO_MS5607_CS));
+ ao_spi_init_cs(AO_MS5607_CS_PORT, (1 << AO_MS5607_CS_PIN));
- ao_add_task(&ao_ms5607_task, ao_ms5607, "ms5607");
+// ao_add_task(&ao_ms5607_task, ao_ms5607, "ms5607");
/* Configure the MISO pin as an interrupt; when the
* conversion is complete, the MS5607 will raise this
* pin as a signal
*/
- ao_exti_setup(AO_MS5607_MISO_GPIO,
- AO_MS5607_MISO,
+ ao_exti_setup(AO_MS5607_MISO_PORT,
+ AO_MS5607_MISO_PIN,
AO_EXTI_MODE_RISING,
ao_ms5607_isr);
/* Reset the pin from INPUT to ALTERNATE so that SPI works
* This needs an abstraction at some point...
*/
- stm_moder_set(AO_MS5607_MISO_GPIO,
- AO_MS5607_MISO,
+ stm_moder_set(AO_MS5607_MISO_PORT,
+ AO_MS5607_MISO_PIN,
STM_MODER_ALTERNATE);
}