Merge pull request #9742 from mikeller/fix_spi_transaction_support
[betaflight.git] / src / main / drivers / light_led.h
blob30d7e307cf16c2fc2e91d5f7d16cbc0f438f6408
1 /*
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)
8 * any later version.
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/>.
21 #pragma once
23 #include "pg/pg.h"
24 #include "drivers/io_types.h"
25 #include "common/utils.h"
27 #define STATUS_LED_NUMBER 3
29 typedef struct statusLedConfig_s {
30 ioTag_t ioTags[STATUS_LED_NUMBER];
31 uint8_t inversion;
32 } statusLedConfig_t;
34 PG_DECLARE(statusLedConfig_t, statusLedConfig);
36 // Helpful macros
37 #if defined(UNIT_TEST) || defined(USE_FAKE_LED)
39 #define LED0_TOGGLE NOOP
40 #define LED0_OFF NOOP
41 #define LED0_ON NOOP
43 #define LED1_TOGGLE NOOP
44 #define LED1_OFF NOOP
45 #define LED1_ON NOOP
47 #define LED2_TOGGLE NOOP
48 #define LED2_OFF NOOP
49 #define LED2_ON NOOP
51 #else
53 #define LED0_TOGGLE ledToggle(0)
54 #define LED0_OFF ledSet(0, false)
55 #define LED0_ON ledSet(0, true)
57 #define LED1_TOGGLE ledToggle(1)
58 #define LED1_OFF ledSet(1, false)
59 #define LED1_ON ledSet(1, true)
61 #define LED2_TOGGLE ledToggle(2)
62 #define LED2_OFF ledSet(2, false)
63 #define LED2_ON ledSet(2, true)
65 void ledInit(const statusLedConfig_t *statusLedConfig);
66 void ledToggle(int led);
67 void ledSet(int led, bool state);
69 #endif