2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are 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)
10 * Cleanflight and Betaflight are distributed in the hope that they
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/>.
27 #include "build/debug.h"
29 #include "common/time.h"
30 #include "common/utils.h"
32 #include "msp/msp_box.h"
35 #include "pg/piniobox.h"
37 #include "scheduler/scheduler.h"
41 typedef struct pinioBoxRuntimeConfig_s
{
42 uint8_t boxId
[PINIO_COUNT
];
43 } pinioBoxRuntimeConfig_t
;
45 static pinioBoxRuntimeConfig_t pinioBoxRuntimeConfig
;
47 void pinioBoxInit(const pinioBoxConfig_t
*pinioBoxConfig
)
49 // Convert permanentId to boxId_e
51 for (int i
= 0; i
< PINIO_COUNT
; i
++) {
52 const box_t
*box
= findBoxByPermanentId(pinioBoxConfig
->permanentId
[i
]);
54 pinioBoxRuntimeConfig
.boxId
[i
] = box
? box
->boxId
: BOXID_NONE
;
58 void pinioBoxUpdate(timeUs_t currentTimeUs
)
60 UNUSED(currentTimeUs
);
62 for (int i
= 0; i
< PINIO_COUNT
; i
++) {
63 if (pinioBoxRuntimeConfig
.boxId
[i
] != BOXID_NONE
) {
64 pinioSet(i
, getBoxIdState(pinioBoxRuntimeConfig
.boxId
[i
]));
69 void pinioBoxTaskControl(void)
71 bool enableTask
= false;
72 for (int i
= 0; i
< PINIO_COUNT
; i
++) {
73 if (pinioBoxRuntimeConfig
.boxId
[i
] != BOXID_NONE
&& isModeActivationConditionPresent(pinioBoxRuntimeConfig
.boxId
[i
])) {
78 setTaskEnabled(TASK_PINIOBOX
, enableTask
);