Krolyxon
Commit a51e4c5

Branches

Tags

Refs →

orion-rfa51e4c5

add 2nd cc1101 in device check, remove link

Author
krolyxon
Date
2026-05-06 15:34 +0530
Parent
8f6c64d
Commit
a51e4c5c84622ff80fdf16c16fb6dccda5950213

+24 −59

1 file changed

  1. M firmware/device_check.cpp +24 −59
M firmware/device_check.cpp View
@@ -16,10 +16,10 @@ extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2;
1616
1717 // ===== RESULTS =====
1818 struct DeviceStatus {
19− bool nrf_link = false;
2019 bool nrf1 = false;
2120 bool nrf2 = false;
22− bool cc1101 = false;
21+ bool cc1101_1 = false;
22+ bool cc1101_2 = false;
2323 bool oled = true;
2424 bool buttons = false;
2525 };
@@ -37,7 +37,7 @@ bool checkNRF(RF24 &radio)
3737 }
3838
3939 // ===== CC1101 CHECK =====
40−bool checkCC1101()
40+bool checkCC1101_1()
4141 {
4242 ELECHOUSE_cc1101.setSpiPin(
4343 cc1101_SCK,
@@ -51,6 +51,21 @@ bool checkCC1101()
5151 return ELECHOUSE_cc1101.getCC1101();
5252 }
5353
54+bool checkCC1101_2()
55+{
56+ ELECHOUSE_cc1101.setSpiPin(
57+ cc1101_SCK,
58+ cc1101_MISO,
59+ cc1101_MOSI,
60+ CC1101_2_CS
61+ );
62+
63+ delay(5); // important stabilization
64+
65+ return ELECHOUSE_cc1101.getCC1101();
66+}
67+
68+
5469 // ===== BUTTON CHECK =====
5570 bool checkButtons()
5671 {
@@ -82,8 +97,8 @@ bool checkButtons()
8297 const char* labels[MAX_ITEMS] = {
8398 "NRF1",
8499 "NRF2",
85− "LINK",
86− "CC1101",
100+ "CC1101_1",
101+ "CC1101_2",
87102 "BUTTONS",
88103 "OLED"
89104 };
@@ -97,8 +112,8 @@ void drawStatus(DeviceStatus &s)
97112 {
98113 values[0] = s.nrf1;
99114 values[1] = s.nrf2;
100− values[2] = s.nrf_link;
101− values[3] = s.cc1101;
115+ values[2] = s.cc1101_1;
116+ values[3] = s.cc1101_2;
102117 values[4] = s.buttons;
103118 values[5] = s.oled;
104119
@@ -139,56 +154,6 @@ void drawStatus(DeviceStatus &s)
139154 u8g2.sendBuffer();
140155 }
141156
142−bool testNRFLink()
143−{
144− const byte address[6] = "00001";
145− uint8_t payload = 0xAB;
146− uint8_t received = 0;
147−
148− // --- init radios ---
149− if (!radio1.begin(RADIO_SPI)) return false;
150− if (!radio2.begin(RADIO_SPI)) return false;
151−
152− radio1.setPALevel(RF24_PA_LOW);
153− radio2.setPALevel(RF24_PA_LOW);
154−
155− radio1.setDataRate(RF24_1MBPS);
156− radio2.setDataRate(RF24_1MBPS);
157−
158− radio1.setChannel(100);
159− radio2.setChannel(100);
160−
161− radio1.setAutoAck(false);
162− radio2.setAutoAck(false);
163−
164− // --- configure pipes ---
165− radio1.openWritingPipe(address);
166− radio2.openReadingPipe(0, address);
167−
168− radio2.startListening();
169−
170− delay(50);
171−
172− // --- send ---
173− radio1.stopListening();
174− bool sent = radio1.write(&payload, sizeof(payload));
175−
176− if (!sent) return false;
177−
178− // --- receive ---
179− unsigned long start = millis();
180−
181− while (millis() - start < 200)
182− {
183− if (radio2.available())
184− {
185− radio2.read(&received, sizeof(received));
186− return (received == payload);
187− }
188− }
189−
190− return false;
191−}
192157
193158 // ===== MAIN =====
194159 void device_check_run()
@@ -199,12 +164,12 @@ void device_check_run()
199164
200165 // NRF
201166 // NRF link test
202− status.nrf_link = testNRFLink();
203167 status.nrf1 = checkNRF(radio1);
204168 status.nrf2 = checkNRF(radio2);
205169
206170 // CC1101
207− status.cc1101 = checkCC1101();
171+ status.cc1101_1 = checkCC1101_1();
172+ status.cc1101_2 = checkCC1101_1();
208173
209174 // Buttons
210175 status.buttons = checkButtons();