-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrp2040_split.h
83 lines (64 loc) · 1.74 KB
/
rp2040_split.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//---------------------------------------------------------------------------
#pragma once
#include "javelin/split/split.h"
#include <hardware/pio.h>
//---------------------------------------------------------------------------
#if JAVELIN_SPLIT
class Rp2040Split : public Split {
public:
static void Initialize() { instance.Initialize(); }
static void Update() { instance.Update(); }
static void PrintInfo() { instance.PrintInfo(); }
static bool IsPairConnected() { return instance.isConnected; }
private:
struct SplitData {
enum class State : uint8_t {
READY_TO_SEND,
SENDING,
RECEIVING,
};
SplitData();
State state;
bool updateSendData = true;
bool isConnected = false;
uint8_t retryCount;
uint16_t txId;
uint16_t lastRxId;
uint32_t programOffset;
uint32_t receiveStartTime;
uint64_t rxPacketCount;
uint64_t txIrqCount;
uint64_t rxWords;
uint64_t txWords;
size_t metrics[SplitMetricId::COUNT];
TxBuffer txBuffer;
RxBuffer rxBuffer;
#if JAVELIN_SPLIT_TX_PIN == JAVELIN_SPLIT_RX_PIN
pio_sm_config config;
#endif
void Initialize();
void StartTx();
void StartRx();
void SendData();
void SendTxBuffer();
void Update();
void ResetRxDma();
void OnReceiveFailed();
void OnReceiveTimeout();
void OnReceiveSucceeded();
bool ProcessReceive();
static void TxIrqHandler();
void PrintInfo();
};
static SplitData instance;
};
#else
class Rp2040Split : public Split {
public:
static void Initialize() {}
static void Update() {}
static void PrintInfo() {}
static bool IsPairConnected() { return false; }
};
#endif // JAVELIN_SPLIT
//---------------------------------------------------------------------------