-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostRTOS.cpp
More file actions
50 lines (47 loc) · 1.19 KB
/
Copy pathpostRTOS.cpp
File metadata and controls
50 lines (47 loc) · 1.19 KB
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
47
48
49
50
#include "BSP.h"
#include "FreeRTOS.h"
#include "I2C_Wrapper.hpp"
#include "Pins.h"
#include "QC3.h"
#include "Settings.h"
#include "ble.h"
#include "cmsis_os.h"
#include "main.hpp"
#include "power.hpp"
#include "stdlib.h"
#include "task.h"
#ifdef HALL_SI7210
#include "Si7210.h"
#endif
bool hall_effect_present = false;
void postRToSInit() {
// Any after RTos setup
#ifdef HALL_SI7210
if (Si7210::detect()) {
hall_effect_present = Si7210::init();
}
#endif
#ifdef HALL_DIGITAL
// A simple digital hall switch has no I2C identity to probe for, so configure its
// input pin and assume it is fitted.
gpio_set_mode(HALL_DIGITAL_Pin, HALL_DIGITAL_INPUT_MODE);
hall_effect_present = true;
#endif
if (getSettingValue(SettingsOptions::BluetoothLE)) {
ble_stack_start();
}
}
int16_t getRawHallEffect() {
if (!hall_effect_present) {
return 0;
}
#ifdef HALL_DIGITAL
// Map the on/off switch onto the field-strength scale the rest of the firmware expects.
return (gpio_read(HALL_DIGITAL_Pin) == HALL_DIGITAL_ACTIVE_LEVEL) ? HALL_DIGITAL_ACTIVE_VALUE : 0;
#elif defined(HALL_SI7210)
return Si7210::read();
#else
return 0;
#endif
}
bool getHallSensorFitted() { return hall_effect_present; }