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
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by fctom on 2020/2/13.
//
 
#include "comm_test.h"
#include "../driver_test.h"
#include "../defs.h"
 
static bool seatbeltInsert;
static bool engineStart;
 
const int ENGINE_MIN_ROTATE = 200;
 
static uint16_t gpioStore = 0;
static uint16_t engineStore = 0;
 
static void SensorChange(int index, bool value);
 
void CommTestStart(void)
{
    gpioStore = engineStore = 0;
}
 
void UpdateSensor(uint16_t gpio, uint16_t speed, uint16_t engine)
{
    int idx, lvl;
 
    uint16_t chg = gpioStore^gpio;
 
    if (chg == 0)
        return;
 
    for (int i = 0; i < 16; ++i) {
        if (chg & BV(i)) {
            SensorChange(i, (bool)(gpio & BV(i)));
        }
    }
 
    gpioStore = gpio;
 
 
 
    // 安全带
 
    // 挡位
 
    // 启动指示
 
    // 熄火监控
}
 
static void SensorChange(int index, bool value)
{
    int func;
 
    switch (func) {
        case SENSOR_SEATBELT:
            break;
        case SENSOR_TURNRIGHT:
            break;
 
    }
}