-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaltitude.h
46 lines (32 loc) · 1.04 KB
/
altitude.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef ALTITUDE_H_
#define ALTITUDE_H_
/*
* altitude.h
*
* Author: Coppy Nawaphanarat (44035285), Grant Wong, Will Archer
*/
#include <stdint.h>
/**
* Constant variables
*/
#define BUF_SIZE 8
#define ADC_TRIGGER_FREQ 200
// 12-bit ADC hence the maximum value is 4095 (i.e. at 3.3V)
//
// We have a 0.8V difference so 4095 * 0.8V / 3.3V is roughly 993
#define ALTITUDE_DELTA 1241
// Initiates an ADC conversion.
void ADCTrigger(void);
// The handler for the ADC conversion complete interrupt. Writes to the circular buffer.
void ADCIntHandler(void);
// Initialise functions for the clock (incl. SysTick), ADC, display
void initClock(void);
// Initialise the ADC peripheral and configuration
void initADC(void);
// Function to display the mean ADc value (10-bit value, note) and sample count.
void displayMeanVal(int16_t meanval, int32_t altirudePercentage, uint8_t state);
// Function to retrieves the mean value of the buffer contents
uint32_t getMeanVal(void);
// Initialise altitude module
void initAltitude(void);
#endif /* ALTITUDE_H_ */