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/>.
26 #ifdef USE_TRANSPONDER
28 #include "drivers/transponder_ir.h"
29 #include "drivers/transponder_ir_ilap.h"
31 #if defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4) || defined(UNIT_TEST)
33 static uint16_t dmaBufferOffset
;
34 extern const struct transponderVTable ilapTansponderVTable
;
36 void transponderIrInitIlap(transponder_t
*transponder
){
37 // from drivers/transponder_ir.h
38 transponder
->gap_toggles
= TRANSPONDER_GAP_TOGGLES_ILAP
;
39 transponder
->dma_buffer_size
= TRANSPONDER_DMA_BUFFER_SIZE_ILAP
;
40 transponder
->vTable
= &ilapTansponderVTable
;
41 transponder
->timer_hz
= TRANSPONDER_TIMER_MHZ_ILAP
;
42 transponder
->timer_carrier_hz
= TRANSPONDER_CARRIER_HZ_ILAP
;
43 memset(&(transponder
->transponderIrDMABuffer
.ilap
), 0, sizeof(transponder
->transponderIrDMABuffer
.ilap
));
47 void updateTransponderDMABufferIlap(transponder_t
*transponder
, const uint8_t* transponderData
)
52 for (byteIndex
= 0; byteIndex
< TRANSPONDER_DATA_LENGTH_ILAP
; byteIndex
++) {
53 uint8_t byteToSend
= *transponderData
;
55 for (bitIndex
= 0; bitIndex
< TRANSPONDER_BITS_PER_BYTE_ILAP
; bitIndex
++)
57 bool doToggles
= false;
61 else if (bitIndex
== TRANSPONDER_BITS_PER_BYTE_ILAP
- 1) {
65 doToggles
= byteToSend
& (1 << (bitIndex
- 1));
67 for (toggleIndex
= 0; toggleIndex
< TRANSPONDER_TOGGLES_PER_BIT_ILAP
; toggleIndex
++)
70 transponder
->transponderIrDMABuffer
.ilap
[dmaBufferOffset
] = transponder
->bitToggleOne
;
73 transponder
->transponderIrDMABuffer
.ilap
[dmaBufferOffset
] = 0;
77 transponder
->transponderIrDMABuffer
.ilap
[dmaBufferOffset
] = 0;
84 const struct transponderVTable ilapTansponderVTable
= {
85 updateTransponderDMABufferIlap
,