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)
122 PINSEL0 &= ~(_BV(14));
126 PWMPR = PWM_PRESCALER - 1;
132 PWMLER = PWMLER_LATCH0 | PWMLER_LATCH2;
133 PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
134 PWMPCR = PWMPCR_ENA2;
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
220 for (
int i=0; i<4; i++){
242 int16_t off =
c2 * 4 + ((
c4 - 512) * dT) / (1 << 12);
244 uint16_t x = (sens * (
d1 - 7168)) / (1 << 14) - off;
269 if (spi_message_received) {
271 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
Common code for AP and FBW telemetry.
Handling of the MS5534a pressure sensor.
Fixedwing Navigation library.
Architecture independent SPI (Serial Peripheral Interface) API.
API to get/set the generic vehicle states.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
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.