Fix WS2812 led definition
[inav.git] / src / main / io / smartport_master.h
blob3ea39e4cd4d2b15f05280a15c1c436d0842e3cb0
1 /*
2 * This file is part of INAV
4 * INAV free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * INAV is distributed in the hope that it
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdbool.h>
24 #include <stdint.h>
26 #include <common/time.h>
28 #include "config/parameter_group.h"
30 #include <telemetry/smartport.h>
32 #if defined(USE_SMARTPORT_MASTER)
34 typedef struct {
35 bool halfDuplex;
36 bool inverted;
37 } smartportMasterConfig_t;
39 PG_DECLARE(smartportMasterConfig_t, smartportMasterConfig);
41 typedef struct {
42 int8_t count;
43 int16_t voltage[6];
44 } cellsData_t;
46 typedef enum {
47 VS600_BAND_A,
48 VS600_BAND_B,
49 VS600_BAND_C,
50 VS600_BAND_D,
51 VS600_BAND_E,
52 VS600_BAND_F,
53 } vs600Band_e;
55 typedef enum {
56 VS600_POWER_PIT,
57 VS600_POWER_25MW,
58 VS600_POWER_200MW,
59 VS600_POWER_600MW,
60 } vs600Power_e;
62 typedef struct {
63 vs600Band_e band;
64 uint8_t channel;
65 vs600Power_e power;
66 } vs600Data_t;
69 bool smartportMasterInit(void);
70 void smartportMasterHandle(timeUs_t currentTimeUs);
72 bool smartportMasterPhyIDIsActive(uint8_t phyID);
73 int8_t smartportMasterStripPhyIDCheckBits(uint8_t phyID);
75 // Returns latest received SmartPort payload for phyID
76 bool smartportMasterGetSensorPayload(uint8_t phyID, smartPortPayload_t *payload);
78 // Forwarding
79 bool smartportMasterForward(uint8_t phyID, smartPortPayload_t *payload);
80 bool smartportMasterHasForwardResponse(uint8_t phyID);
81 bool smartportMasterNextForwardResponse(uint8_t phyID, smartPortPayload_t *payload);
83 // Returns latest Cells data or NULL if the data is too old
84 cellsData_t *smartportMasterGetCellsData(void);
85 vs600Data_t *smartportMasterGetVS600Data(void);
87 #endif /* USE_SMARTPORT_MASTER */