mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
PICO: Implement debug pin (#14526)
This commit is contained in:
parent
1719e72eb4
commit
67d9ca8181
7 changed files with 99 additions and 6 deletions
86
src/platform/PICO/debug_pin.c
Normal file
86
src/platform/PICO/debug_pin.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* This file is part of Betaflight.
|
||||
*
|
||||
* Betaflight is free software. You can redistribute this software
|
||||
* and/or modify this software under the terms of the GNU General
|
||||
* Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Betaflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this software.
|
||||
*
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build/debug_pin.h"
|
||||
|
||||
#ifdef USE_DEBUG_PIN
|
||||
|
||||
#ifndef DEBUG_PIN_COUNT
|
||||
#define DEBUG_PIN_COUNT 0
|
||||
#endif
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/io_impl.h"
|
||||
|
||||
dbgPin_t dbgPins[DEBUG_PIN_COUNT] = {
|
||||
#ifdef DEBUG_PIN1
|
||||
{ .tag = IO_TAG(DEBUG_PIN1) },
|
||||
#endif
|
||||
#ifdef DEBUG_PIN2
|
||||
{ .tag = IO_TAG(DEBUG_PIN2) },
|
||||
#endif
|
||||
};
|
||||
IO_t dbgPinIOs[DEBUG_PIN_COUNT] = { 0 };
|
||||
#endif
|
||||
|
||||
void dbgPinInit(void)
|
||||
{
|
||||
#ifdef USE_DEBUG_PIN
|
||||
for (unsigned i = 0; i < ARRAYLEN(dbgPins); i++) {
|
||||
const dbgPin_t *dbgPin = &dbgPins[i];
|
||||
IO_t io = IOGetByTag(dbgPin->tag);
|
||||
if (!io) {
|
||||
continue;
|
||||
}
|
||||
IOInit(io, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(io, IOCFG_OUT_PP);
|
||||
dbgPinIOs[i] = io;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbgPinHi(int index)
|
||||
{
|
||||
#ifdef USE_DEBUG_PIN
|
||||
if ((unsigned)index >= ARRAYLEN(dbgPinIOs) || !dbgPinIOs[index]) {
|
||||
return;
|
||||
}
|
||||
|
||||
IOHi(dbgPinIOs[index]);
|
||||
#else
|
||||
UNUSED(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbgPinLo(int index)
|
||||
{
|
||||
#ifdef USE_DEBUG_PIN
|
||||
if ((unsigned)index >= ARRAYLEN(dbgPinIOs) || !dbgPinIOs[index]) {
|
||||
return;
|
||||
}
|
||||
|
||||
IOLo(dbgPinIOs[index]);
|
||||
#else
|
||||
UNUSED(index);
|
||||
#endif
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue