#define FOSC 32000000
-#define ao_radio_select() ao_spi_get_mask(AO_CC1120_SPI_CS_PORT,(1 << AO_CC1120_SPI_CS_PIN),AO_CC1120_SPI_BUS)
+#define ao_radio_select() ao_spi_get_mask(AO_CC1120_SPI_CS_PORT,(1 << AO_CC1120_SPI_CS_PIN),AO_CC1120_SPI_BUS,AO_SPI_SPEED_1MHz)
#define ao_radio_deselect() ao_spi_put_mask(AO_CC1120_SPI_CS_PORT,(1 << AO_CC1120_SPI_CS_PIN),AO_CC1120_SPI_BUS)
#define ao_radio_spi_send(d,l) ao_spi_send((d), (l), AO_CC1120_SPI_BUS)
#define ao_radio_spi_send_fixed(d,l) ao_spi_send_fixed((d), (l), AO_CC1120_SPI_BUS)
rx_data[rx_data_cur++] = d;
if (rx_waiting && rx_data_cur - rx_data_consumed >= AO_FEC_DECODE_BLOCK) {
#if AO_PROFILE
- if (rx_data_consumed == 0)
+ if (!rx_packet_tick)
rx_packet_tick = ao_profile_tick();
+ if (rx_data_cur < rx_data_count)
+ return;
#endif
rx_waiting = 0;
ao_wakeup(&ao_radio_wake);
if (ao_radio_abort)
return 0;
rx_data_consumed += AO_FEC_DECODE_BLOCK;
+#if AO_PROFILE
+ return rx_data_cur - rx_data_consumed;
+#endif
return AO_FEC_DECODE_BLOCK;
}
}
#if AO_PROFILE
rx_start_tick = ao_profile_tick();
+ rx_packet_tick = 0;
#endif
len = size + 2; /* CRC bytes */
len += 1 + ~(len & 1); /* 1 or two pad bytes */
ao_radio_put();
- /* Construct final packet */
-
- if (ret && ((uint8_t *) d)[size] == 0 && ((uint8_t *)d)[size+1] == 0)
- ((uint8_t *) d)[size + 1] = 0x80;
- else
- ((uint8_t *) d)[size + 1] = 0x00;
+ /* Store the received RSSI value; the crc-OK byte is already done */
((uint8_t *) d)[size] = (uint8_t) rssi;