Move telemetry displayport init and cms device registering
[betaflight.git] / src / test / unit / io_serial_unittest.cc
blob5e53baa373ec265f9972febc54b5974031e3a3fe
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdint.h>
19 #include <stdbool.h>
21 #include <limits.h>
23 extern "C" {
24 #include "platform.h"
26 #include "drivers/serial.h"
27 #include "drivers/serial_softserial.h"
28 #include "drivers/serial_uart.h"
30 #include "io/serial.h"
32 #include "pg/pg.h"
33 #include "pg/pg_ids.h"
34 #include "pg/rx.h"
36 void serialInit(bool softserialEnabled, serialPortIdentifier_e serialPortToDisable);
38 PG_REGISTER(rxConfig_t, rxConfig, PG_RX_CONFIG, 0);
41 #include "unittest_macros.h"
42 #include "gtest/gtest.h"
44 TEST(IoSerialTest, TestFindPortConfig)
46 // given
47 serialInit(false, SERIAL_PORT_NONE);
49 // when
50 const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_MSP);
52 // then
53 EXPECT_EQ(NULL, portConfig);
57 // STUBS
58 extern "C" {
59 void delay(uint32_t) {}
61 bool isSerialTransmitBufferEmpty(const serialPort_t *) { return true; }
63 void systemResetToBootloader(void) {}
65 bool telemetryCheckRxPortShared(const serialPortConfig_t *) { return false; }
67 uint32_t serialRxBytesWaiting(const serialPort_t *) { return 0; }
68 uint8_t serialRead(serialPort_t *) { return 0; }
69 void serialWrite(serialPort_t *, uint8_t) {}
71 serialPort_t *usbVcpOpen(void) { return NULL; }
73 serialPort_t *uartOpen(UARTDevice_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {
74 return NULL;
77 serialPort_t *openSoftSerial(softSerialPortIndex_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {
78 return NULL;
81 void serialSetCtrlLineStateCb(serialPort_t *, void (*)(void *, uint16_t ), void *) {}
82 void serialSetCtrlLineState(serialPort_t *, uint16_t ) {}
83 uint32_t serialTxBytesFree(const serialPort_t *) {return 1;}
85 void serialSetBaudRateCb(serialPort_t *, void (*)(serialPort_t *context, uint32_t baud), serialPort_t *) {}
87 void pinioSet(int, bool) {}