162 const uint8_t order[] = {0x80, 0x96, 0x97, 0x89, 0x07, 0x9D, 0x8A,
163 0x86, 0x98, 0x95, 0x8E, 0x8F, 0x8B, 0x8C,
164 0x08, 0x1D, 0x0D, 0x0D, 0x17, 0x8C, 0x82};
165 TEST_ASSERT_EQUAL_UINT(
sizeof order,
chip.n_cmds);
166 for (
unsigned i = 0; i <
sizeof order; ++i) {
167 TEST_ASSERT_EQUAL_HEX8(order[i],
chip.cmds[i][0]);
169 const uint8_t tcxo[] = {0x97, 0x02, 0x00, 0x01, 0x40};
170 TEST_ASSERT_EQUAL_HEX8_ARRAY(tcxo,
chip.cmds[2],
sizeof tcxo);
171 TEST_ASSERT_EQUAL_HEX8(0x7F,
chip.cmds[3][1]);
172 TEST_ASSERT_EQUAL_HEX8(0x01,
chip.cmds[5][1]);
173 const uint8_t freq[] = {0x86, 0x39, 0x30, 0x00, 0x00};
174 TEST_ASSERT_EQUAL_HEX8_ARRAY(freq,
chip.cmds[7],
sizeof freq);
175 const uint8_t image[] = {0x98, 0xE1, 0xE9};
176 TEST_ASSERT_EQUAL_HEX8_ARRAY(image,
chip.cmds[8],
sizeof image);
177 const uint8_t pa[] = {0x95, 0x04, 0x07, 0x00, 0x01};
178 TEST_ASSERT_EQUAL_HEX8_ARRAY(pa,
chip.cmds[9],
sizeof pa);
179 const uint8_t power[] = {0x8E, 0x16, 0x04};
180 TEST_ASSERT_EQUAL_HEX8_ARRAY(power,
chip.cmds[10],
sizeof power);
181 const uint8_t mod[] = {0x8B, 0x09, 0x04, 0x01, 0x00};
182 TEST_ASSERT_EQUAL_HEX8_ARRAY(mod,
chip.cmds[12],
sizeof mod);
183 const uint8_t pkt[] = {0x8C, 0x00, 0x08, 0x00, 0xFF, 0x01, 0x00};
184 TEST_ASSERT_EQUAL_HEX8_ARRAY(pkt,
chip.cmds[13],
sizeof pkt);
185 const uint8_t irq[] = {0x08, 0x02, 0x63, 0x02, 0x63, 0, 0, 0, 0};
186 TEST_ASSERT_EQUAL_HEX8_ARRAY(irq,
chip.cmds[14],
sizeof irq);
187 TEST_ASSERT_EQUAL_HEX8(0xDE,
chip.tx_clamp);
188 TEST_ASSERT_EQUAL_HEX8(0x14,
chip.sync[0]);
189 TEST_ASSERT_EQUAL_HEX8(0x24,
chip.sync[1]);
190 const uint8_t rx[] = {0x82, 0xFF, 0xFF, 0xFF};
191 TEST_ASSERT_EQUAL_HEX8_ARRAY(rx,
chip.cmds[
chip.n_cmds - 1],
sizeof rx);
192 TEST_ASSERT_TRUE(control.rx_switch);
217 const uint8_t
frame[14] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
220 TEST_ASSERT_EQUAL_HEX8(0x05,
chip.tx_modulation);
221 int pp =
chip.find(0x8C);
222 TEST_ASSERT_TRUE(pp >= 0);
223 TEST_ASSERT_EQUAL_HEX8(14,
chip.cmds[pp][4]);
224 int tx =
chip.find(0x83);
225 TEST_ASSERT_TRUE(tx > pp);
227 TEST_ASSERT_EQUAL_HEX8(0x00,
chip.cmds[tx][1]);
228 TEST_ASSERT_EQUAL_HEX8(0x52,
chip.cmds[tx][2]);
229 TEST_ASSERT_EQUAL_HEX8(0x6F,
chip.cmds[tx][3]);
230 TEST_ASSERT_EQUAL_UINT(3, control.delays);
231 TEST_ASSERT_FALSE(control.rx_switch_during_tx);
233 int rx =
chip.find(0x82, tx);
234 TEST_ASSERT_TRUE(rx > tx);
235 TEST_ASSERT_EQUAL_HEX8(0xFF,
chip.cmds[
chip.find(0x8C, tx)][4]);
236 TEST_ASSERT_TRUE(control.rx_switch);
237 TEST_ASSERT_EQUAL_UINT32(1, radio.
tx_ok());
289 int dc =
chip.find(0x94);
290 TEST_ASSERT_TRUE(dc >= 0);
291 TEST_ASSERT_EQUAL_HEX8(0x00,
chip.cmds[dc][1]);
292 TEST_ASSERT_EQUAL_HEX8(0x08,
chip.cmds[dc][2]);
293 TEST_ASSERT_EQUAL_HEX8(0x40,
chip.cmds[dc][3]);
294 TEST_ASSERT_EQUAL_HEX8(0x00,
chip.cmds[dc][4]);
295 TEST_ASSERT_EQUAL_HEX8(0xFA,
chip.cmds[dc][5]);
296 TEST_ASSERT_EQUAL_HEX8(0x00,
chip.cmds[dc][6]);
297 TEST_ASSERT_EQUAL_UINT(7,
chip.lens[dc]);
299 TEST_ASSERT_TRUE(control.rx_switch);
301 int pp =
chip.find(0x8C);
302 TEST_ASSERT_TRUE(pp >= 0 && pp < dc);
303 TEST_ASSERT_EQUAL_HEX8(0xFF,
chip.cmds[pp][4]);
305 TEST_ASSERT_EQUAL_HEX8(0x80,
chip.cmds[0][0]);
307 TEST_ASSERT_EQUAL(-1,
chip.find(0x82, dc));
void transfer(const uint8_t *tx, uint8_t *rx, uint16_t len) override
int find(uint8_t opcode, int from=0) const
static std::vector< uint8_t > frame(uint8_t hi, uint8_t lo, size_t payload_len, uint8_t fill)
One wire packet: len(4, LE) then len bytes of body, where the first 4 body bytes are ty/packet_id(2)/...
static void test_duty_cycle_1ms_is_64_steps(void)
static void test_send_keeps_a_packet_that_just_arrived(void)
static void test_send_waits_for_tx_done_and_returns_to_rx(void)
static void test_send_returns_to_duty_cycle_not_continuous(void)
static void test_rearm_restarts_duty_cycle_after_rxdone(void)
static void test_send_times_out(void)
static void test_configure_names_the_failing_step(void)
static void test_start_continuous_after_duty_cycle(void)
static void test_configure_follows_the_datasheet_order(void)
static void test_duty_cycle_sends_correct_opcode_and_periods(void)
static void test_frequency_word_and_time_on_air(void)
static void test_rearm_is_noop_in_continuous_mode(void)
static void test_send_refuses_bad_input_and_dead_chip(void)