33 #ifndef BARO_NO_DOWNLINK
52 #define STATUS_INIT1 0
53 #define STATUS_INIT2 1
54 #define STATUS_INIT3 2
55 #define STATUS_INIT4 3
56 #define STATUS_MEASURE_PRESSURE 4
57 #define STATUS_MEASURE_TEMPERATURE 5
58 #define STATUS_RESET 6
64 #define InitStatus() (status <= STATUS_INIT4)
66 #define NextStatus() { \
67 if (status_read_data) { \
68 status++; if (status > STATUS_MEASURE_TEMPERATURE) status = STATUS_MEASURE_PRESSURE; \
70 status_read_data = !status_read_data; \
74 #define CMD_MEASUREMENT 0x0F
80 #define CMD_PRESSURE 0x40
81 #define CMD_TEMPERATURE 0x20
90 #define Uint16(buf_input) (buf_input[0] << 8 | buf_input[1])
94 #if (PCLK == 15000000)
95 #define PWM_PRESCALER 1
98 #if (PCLK == 30000000)
99 #define PWM_PRESCALER 2
102 #if (PCLK == 60000000)
103 #define PWM_PRESCALER 4
106 #error unknown PCLK frequency
111 #define MS5534A_MCLK 32768
112 #define PWM_PERIOD ((PCLK / PWM_PRESCALER) / MS5534A_MCLK)
113 #define PWM_DUTY (PWM_PERIOD / 2)
126 PWMPR = PWM_PRESCALER - 1;
136 #ifdef BARO_MS5534A_W1
137 words[0] = BARO_MS5534A_W1;
138 words[1] = BARO_MS5534A_W2;
139 words[2] = BARO_MS5534A_W3;
140 words[3] = BARO_MS5534A_W4;
171 if (!SpiCheckAvailable()) {
178 for (i = 0; i < 3; i++) {
181 spi_buffer_length = 3;
189 spi_buffer_length = 2;
216 ut1 = (c5 << 3) + 20224;
218 #ifndef BARO_NO_DOWNLINK
238 int16_t off =
c2 * 4 + ((
c4 - 512) * dT) / (1 << 12);
240 uint16_t x = (sens * (
d1 - 7168)) / (1 << 14) - off;
265 if (spi_message_received) {
267 spi_message_received =
false;
Handling of the MS5534a pressure sensor.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static uint8_t buf_output[3]
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
static void SpiStart(struct spi_periph *p, struct spi_transaction *t)
static void SpiSetCPHA(struct spi_periph *p)
Main include for ABI (AirBorneInterface).
bool baro_MS5534A_do_reset
void baro_MS5534A_event(void)
#define Uint16(buf_input)
#define STATUS_MEASURE_TEMPERATURE
static void calibration(void)
#define PWMTCR_COUNTER_ENABLE
Architecture independent SPI (Serial Peripheral Interface) API.
uint32_t pressure
pressure in 1/4 Pascal
static uint8_t buf_input[3]
void baro_MS5534A_send(void)
#define STATUS_MEASURE_PRESSURE
#define BARO_MS5534A_SENDER_ID
float baro_MS5534A_sigma2
uint32_t baro_MS5534A_ground_pressure
#define PWMTCR_PWM_ENABLE
API to get/set the generic vehicle states.
bool baro_MS5534A_available
static bool status_read_data
void baro_MS5534A_event_task(void)
Common code for AP and FBW telemetry.
void baro_MS5534A_reset(void)
Fixedwing Navigation library.
uint16_t baro_MS5534A_temp
void baro_MS5534A_init(void)
uint32_t baro_MS5534A_pressure