mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Cherry-pick CF/9f7f2f2
This commit is contained in:
parent
5bc79368be
commit
a4ee4102d7
12 changed files with 446 additions and 90 deletions
66
src/main/drivers/transponder_ir_arcitimer.c
Normal file
66
src/main/drivers/transponder_ir_arcitimer.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it 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.
|
||||
*
|
||||
* Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <platform.h>
|
||||
#include "drivers/transponder_ir.h"
|
||||
#include "drivers/transponder_ir_arcitimer.h"
|
||||
|
||||
#if defined(STM32F3) || defined(STM32F4) || defined(UNIT_TEST)
|
||||
|
||||
extern const struct transponderVTable arcitimerTansponderVTable;
|
||||
static uint16_t dmaBufferOffset;
|
||||
|
||||
void transponderIrInitArcitimer(transponder_t *transponder){
|
||||
// from drivers/transponder_ir.h
|
||||
transponder->gap_toggles = TRANSPONDER_GAP_TOGGLES_ARCITIMER;
|
||||
transponder->dma_buffer_size = TRANSPONDER_DMA_BUFFER_SIZE_ARCITIMER;
|
||||
transponder->vTable = &arcitimerTansponderVTable;
|
||||
transponder->timer_hz = TRANSPONDER_TIMER_MHZ_ARCITIMER;
|
||||
transponder->timer_carrier_hz = TRANSPONDER_CARRIER_HZ_ARCITIMER;
|
||||
memset(&(transponder->transponderIrDMABuffer.arcitimer), 0, TRANSPONDER_DMA_BUFFER_SIZE_ARCITIMER);
|
||||
}
|
||||
|
||||
void updateTransponderDMABufferArcitimer(transponder_t *transponder, const uint8_t* transponderData)
|
||||
{
|
||||
uint8_t byteIndex;
|
||||
uint8_t bitIndex;
|
||||
uint8_t hightStateIndex;
|
||||
for (byteIndex = 0; byteIndex < TRANSPONDER_DATA_LENGTH_ARCITIMER; byteIndex++) {
|
||||
uint8_t byteToSend = *transponderData;
|
||||
transponderData++;
|
||||
for (bitIndex = 0; bitIndex < TRANSPONDER_BITS_PER_BYTE_ARCITIMER; bitIndex++)
|
||||
{
|
||||
bool isHightState = byteToSend & (1 << (bitIndex));
|
||||
for (hightStateIndex = 0; hightStateIndex < TRANSPONDER_TOGGLES_PER_BIT_ARCITIMER; hightStateIndex++)
|
||||
{
|
||||
transponder->transponderIrDMABuffer.arcitimer[dmaBufferOffset] = isHightState ? transponder->bitToggleOne : 0;
|
||||
dmaBufferOffset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dmaBufferOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct transponderVTable arcitimerTansponderVTable = {
|
||||
updateTransponderDMABufferArcitimer,
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue