projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos]
/
src
/
drivers
/
ao_ms5607.c
diff --git
a/src/drivers/ao_ms5607.c
b/src/drivers/ao_ms5607.c
index 162141115c01c5f7e7f2abbab541bc9b5622b486..f73b095622cd5a4eccf9f1d0b7e28a7ade50caf7 100644
(file)
--- a/
src/drivers/ao_ms5607.c
+++ b/
src/drivers/ao_ms5607.c
@@
-25,9
+25,7
@@
struct ao_ms5607_prom ao_ms5607_prom;
static uint8_t ms5607_configured;
struct ao_ms5607_prom ao_ms5607_prom;
static uint8_t ms5607_configured;
-#ifndef AO_MS5607_SPI_SPEED
-#define AO_MS5607_SPI_SPEED AO_SPI_SPEED_FAST
-#endif
+#define AO_MS5607_SPI_SPEED ao_spi_speed(20000000)
static void
ao_ms5607_start(void) {
static void
ao_ms5607_start(void) {
@@
-61,17
+59,17
@@
ao_ms5607_crc(uint8_t *prom)
prom[15] = 0;
for (cnt = 0; cnt < 16; cnt++) {
prom[15] = 0;
for (cnt = 0; cnt < 16; cnt++) {
- n_rem ^= *p++;
+ n_rem ^=
(uint16_t)
*p++;
for (n_bit = 8; n_bit > 0; n_bit--) {
if (n_rem & 0x8000)
for (n_bit = 8; n_bit > 0; n_bit--) {
if (n_rem & 0x8000)
- n_rem = (
n_rem << 1) ^ 0x3000
;
+ n_rem = (
uint16_t) ((n_rem << 1) ^ 0x3000U)
;
else
n_rem = (n_rem << 1);
}
}
n_rem = (n_rem >> 12) & 0xf;
prom[15] = crc_byte;
else
n_rem = (n_rem << 1);
}
}
n_rem = (n_rem >> 12) & 0xf;
prom[15] = crc_byte;
- return n_rem;
+ return
(uint8_t)
n_rem;
}
static bool
}
static bool
@@
-112,8
+110,14
@@
ao_ms5607_prom_read(struct ao_ms5607_prom *prom)
r++;
}
r++;
}
- if (!ao_ms5607_prom_valid((uint8_t *) prom))
+
+ if (!ao_ms5607_prom_valid((uint8_t *) prom)) {
+#if HAS_SENSOR_ERRORS
+ AO_SENSOR_ERROR(AO_DATA_MS5607);
+#else
ao_panic(AO_PANIC_SELF_TEST_MS5607);
ao_panic(AO_PANIC_SELF_TEST_MS5607);
+#endif
+ }
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* Byte swap */
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* Byte swap */
@@
-259,7
+263,6
@@
ao_ms5607_dump(void)
struct ao_ms5607_value value;
#if !HAS_MS5607_TASK
struct ao_ms5607_value value;
#if !HAS_MS5607_TASK
- ao_ms5607_info();
ao_ms5607_sample(&ao_ms5607_current);
#endif
ao_ms5607_convert(&ao_ms5607_current, &value);
ao_ms5607_sample(&ao_ms5607_current);
#endif
ao_ms5607_convert(&ao_ms5607_current, &value);