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 #ifdef USE_TRANSPONDER
29 #include "drivers/transponder_ir.h"
30 #include "drivers/transponder_ir_arcitimer.h"
32 #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4) || defined(UNIT_TEST)
34 extern const struct transponderVTable arcitimerTansponderVTable
;
35 static uint16_t dmaBufferOffset
;
37 void transponderIrInitArcitimer(transponder_t
*transponder
)
39 // from drivers/transponder_ir.h
40 transponder
->gap_toggles
= TRANSPONDER_GAP_TOGGLES_ARCITIMER
;
41 transponder
->dma_buffer_size
= TRANSPONDER_DMA_BUFFER_SIZE_ARCITIMER
;
42 transponder
->vTable
= &arcitimerTansponderVTable
;
43 transponder
->timer_hz
= TRANSPONDER_TIMER_MHZ_ARCITIMER
;
44 transponder
->timer_carrier_hz
= TRANSPONDER_CARRIER_HZ_ARCITIMER
;
45 memset(&(transponder
->transponderIrDMABuffer
.arcitimer
), 0, sizeof(transponder
->transponderIrDMABuffer
.arcitimer
));
48 void updateTransponderDMABufferArcitimer(transponder_t
*transponder
, const uint8_t* transponderData
)
52 uint8_t hightStateIndex
;
53 for (byteIndex
= 0; byteIndex
< TRANSPONDER_DATA_LENGTH_ARCITIMER
; byteIndex
++) {
54 uint8_t byteToSend
= *transponderData
;
56 for (bitIndex
= 0; bitIndex
< TRANSPONDER_BITS_PER_BYTE_ARCITIMER
; bitIndex
++)
58 bool isHightState
= byteToSend
& (1 << (bitIndex
));
59 for (hightStateIndex
= 0; hightStateIndex
< TRANSPONDER_TOGGLES_PER_BIT_ARCITIMER
; hightStateIndex
++)
61 transponder
->transponderIrDMABuffer
.arcitimer
[dmaBufferOffset
] = isHightState
? transponder
->bitToggleOne
: 0;
71 const struct transponderVTable arcitimerTansponderVTable
= {
72 updateTransponderDMABufferArcitimer
,