static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) { uint8_t status[2]; uint8_t packetLength = 0; /* Any bytes available in RX FIFO? */ if ((cc110x_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) { // Read length byte (first byte in RX FIFO) cc110x_read_fifo((char*) &packetLength, 1); // Read data from RX FIFO and store in rxBuffer if (packetLength <= length) { // Put length byte at first position in RX Buffer rxBuffer[0] = packetLength; // Read the rest of the packet //cc110x_readburst_reg(CC1100_RXFIFO, (char*)rxBuffer+1, packetLength); cc110x_read_fifo((char*) rxBuffer + 1, packetLength); // Read the 2 appended status bytes (status[0] = RSSI, status[1] = LQI) cc110x_readburst_reg(CC1100_RXFIFO, (char*)status, 2); // Store RSSI value of packet rflags._RSSI = status[I_RSSI]; // MSB of LQI is the CRC_OK bit rflags.CRC = (status[I_LQI] & CRC_OK) >> 7; if (!rflags.CRC) { cc110x_statistic.packets_in_crc_fail++; } // Bit 0-6 of LQI indicates the link quality (LQI) rflags._LQI = status[I_LQI] & LQI_EST; return rflags.CRC; }
static uint8_t receive_packet_variable(uint8_t *rxBuffer, radio_packet_length_t length) { uint8_t status[2]; /* Any bytes available in RX FIFO? */ if ((cc110x_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) { uint8_t packetLength = 0; /* Read length byte (first byte in RX FIFO) */ packetLength = cc110x_read_reg(CC1100_RXFIFO); /* Read data from RX FIFO and store in rxBuffer */ if (packetLength <= length) { uint8_t crc_ok = 0; /* Put length byte at first position in RX Buffer */ rxBuffer[0] = packetLength; /* Read the rest of the packet */ cc110x_readburst_reg(CC1100_RXFIFO, (char *) rxBuffer + 1, packetLength); /* Read the 2 appended status bytes (status[0] = RSSI, status[1] = LQI) */ cc110x_readburst_reg(CC1100_RXFIFO, (char *)status, 2); /* Store RSSI value of packet */ rflags._RSSI = status[I_RSSI]; /* MSB of LQI is the CRC_OK bit */ crc_ok = (status[I_LQI] & CRC_OK) >> 7; if (!crc_ok) { cc110x_statistic.packets_in_crc_fail++; } /* Bit 0-6 of LQI indicates the link quality (LQI) */ rflags._LQI = status[I_LQI] & LQI_EST; return crc_ok; }
static void store_conf(void) { cc110x_readburst_reg(0x0, old_conf, CC1100_CONF_SIZE); // cc110x_read_reg(CC1100_PATABLE, pa_table[pa_table_index]); }