53#define STATUS_MEASURE_PRESSURE 4
54#define STATUS_MEASURE_TEMPERATURE 5
61#define InitStatus() (status <= STATUS_INIT4)
63#define NextStatus() { \
64 if (status_read_data) { \
65 status++; if (status > STATUS_MEASURE_TEMPERATURE) status = STATUS_MEASURE_PRESSURE; \
67 status_read_data = !status_read_data; \
71#define CMD_MEASUREMENT 0x0F
77#define CMD_PRESSURE 0x40
78#define CMD_TEMPERATURE 0x20
87#define Uint16(buf_input) (buf_input[0] << 8 | buf_input[1])
92#define PWM_PRESCALER 1
96#define PWM_PRESCALER 2
100#define PWM_PRESCALER 4
103#error unknown PCLK frequency
108#define MS5534A_MCLK 32768
109#define PWM_PERIOD ((PCLK / PWM_PRESCALER) / MS5534A_MCLK)
110#define PWM_DUTY (PWM_PERIOD / 2)
119 PINSEL0 &= ~(_BV(14));
123 PWMPR = PWM_PRESCALER - 1;
129 PWMLER = PWMLER_LATCH0 | PWMLER_LATCH2;
130 PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
131 PWMPCR = PWMPCR_ENA2;
133#ifdef BARO_MS5534A_W1
134 words[0] = BARO_MS5534A_W1;
135 words[1] = BARO_MS5534A_W2;
136 words[2] = BARO_MS5534A_W3;
137 words[3] = BARO_MS5534A_W4;
168 if (!SpiCheckAvailable()) {
175 for (i = 0; i < 3; i++) {
178 spi_buffer_length = 3;
186 spi_buffer_length = 2;
213 ut1 = (c5 << 3) + 20224;
231 int16_t off =
c2 * 4 + ((
c4 - 512) * dT) / (1 << 12);
233 uint16_t x = (sens * (
d1 - 7168)) / (1 << 14) - off;
258 if (spi_message_received) {
260 spi_message_received =
false;
Main include for ABI (AirBorneInterface).
#define BARO_MS5534A_SENDER_ID
void baro_MS5534A_event_task(void)
void baro_MS5534A_event(void)
uint16_t baro_MS5534A_temp
void baro_MS5534A_send(void)
static uint8_t buf_input[3]
void baro_MS5534A_init(void)
float baro_MS5534A_sigma2
#define STATUS_MEASURE_TEMPERATURE
bool baro_MS5534A_do_reset
uint32_t baro_MS5534A_pressure
#define Uint16(buf_input)
void baro_MS5534A_reset(void)
static void calibration(void)
bool baro_MS5534A_available
static bool status_read_data
static uint8_t buf_output[3]
#define STATUS_MEASURE_PRESSURE
uint32_t baro_MS5534A_ground_pressure
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Handling of the MS5534a pressure sensor.
Fixedwing Navigation library.
Architecture independent SPI (Serial Peripheral Interface) API.
API to get/set the generic vehicle states.
Architecture independent timing functions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.