mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Added Spektrum SPI driver.
This commit is contained in:
parent
96d5b5dcac
commit
1c05c7ead6
15 changed files with 46 additions and 32 deletions
|
@ -23,6 +23,8 @@
|
|||
extern "C" {
|
||||
#include "platform.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/rx_spi.h"
|
||||
|
@ -127,6 +129,10 @@ extern "C" {
|
|||
pkt[i * 2 + 1] = (value >> 0) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
static const rxSpiConfig_t injectedConfig = {
|
||||
.extiIoTag = IO_TAG(PA0),
|
||||
};
|
||||
}
|
||||
|
||||
#include "unittest_macros.h"
|
||||
|
@ -136,7 +142,7 @@ extern "C" {
|
|||
TEST(RxSpiSpektrumUnitTest, TestInitUnbound)
|
||||
{
|
||||
dsmReceiver = empty;
|
||||
spektrumSpiInit(nullptr, &config);
|
||||
spektrumSpiInit(&injectedConfig, &config);
|
||||
EXPECT_FALSE(dsmReceiver.bound);
|
||||
EXPECT_EQ(DSM_RECEIVER_BIND, dsmReceiver.status);
|
||||
EXPECT_EQ(DSM_INITIAL_BIND_CHANNEL, dsmReceiver.rfChannel);
|
||||
|
@ -154,7 +160,7 @@ TEST(RxSpiSpektrumUnitTest, TestInitBound)
|
|||
|
||||
spektrumConfigMutable()->protocol = DSMX_11;
|
||||
|
||||
bool result = spektrumSpiInit(nullptr, &config);
|
||||
bool result = spektrumSpiInit(&injectedConfig, &config);
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_TRUE(dsmReceiver.bound);
|
||||
|
@ -174,7 +180,7 @@ TEST(RxSpiSpektrumUnitTest, TestInitBound)
|
|||
dsmReceiver = empty;
|
||||
spektrumConfigMutable()->protocol = DSM2_11;
|
||||
|
||||
spektrumSpiInit(nullptr, &config);
|
||||
spektrumSpiInit(&injectedConfig, &config);
|
||||
|
||||
EXPECT_TRUE(dsmReceiver.bound);
|
||||
EXPECT_EQ(DSM2_11, dsmReceiver.protocol);
|
||||
|
@ -340,15 +346,13 @@ extern "C" {
|
|||
uint32_t micros(void) { return 0; }
|
||||
uint32_t millis(void) { return 0; }
|
||||
|
||||
void IOConfigGPIO(void) {}
|
||||
bool IORead(IO_t ) { return true; }
|
||||
void IOInit(void) {}
|
||||
IO_t IOGetByTag(ioTag_t ) { return IO_NONE; }
|
||||
IO_t IOGetByTag(ioTag_t ) { return (IO_t)1; }
|
||||
void IOHi(IO_t ) {}
|
||||
void IOLo(IO_t ) {}
|
||||
void writeEEPROM(void) {}
|
||||
|
||||
bool cyrf6936Init(void) { return true; }
|
||||
bool cyrf6936Init(IO_t ) { return true; }
|
||||
bool cyrf6936RxFinished (uint32_t *timestamp)
|
||||
{
|
||||
*timestamp = 0;
|
||||
|
@ -388,4 +392,4 @@ extern "C" {
|
|||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue