Cosmetics
[opentx.git] / radio / src / tests / crossfire.cpp
blob60d88ff86c98472e7bce746a4201cb0b1df6a9e5
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "gtests.h"
23 #if defined(CROSSFIRE)
24 uint8_t createCrossfireChannelsFrame(uint8_t * frame, int16_t * pulses);
25 TEST(Crossfire, createCrossfireChannelsFrame)
27 int16_t pulsesStart[MAX_TRAINER_CHANNELS];
28 uint8_t crossfire[CROSSFIRE_FRAME_MAXLEN];
30 memset(crossfire, 0, sizeof(crossfire));
31 for (int i=0; i<MAX_TRAINER_CHANNELS; i++) {
32 pulsesStart[i] = -1024 + (2048 / MAX_TRAINER_CHANNELS) * i;
35 createCrossfireChannelsFrame(crossfire, pulsesStart);
37 // TODO check
40 TEST(Crossfire, crc8)
42 uint8_t frame[] = { 0x00, 0x0C, 0x14, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x03, 0x00, 0x00, 0x00, 0xF4 };
43 uint8_t crc = crc8(&frame[2], frame[1]-1);
44 ASSERT_EQ(frame[frame[1]+1], crc);
46 #endif