/** * @brief Function for configuring the radio to use a random address and a 254 byte random payload. * The S0 and S1 fields are not used. */ static void generate_modulated_rf_packet(void) { uint8_t i; NRF_RADIO->PREFIX0 = rnd8(); NRF_RADIO->BASE0 = rnd32(); // Packet configuration: // S1 size = 0 bits, S0 size = 0 bytes, payload length size = 8 bits NRF_RADIO->PCNF0 = (0UL << RADIO_PCNF0_S1LEN_Pos) | (0UL << RADIO_PCNF0_S0LEN_Pos) | (8UL << RADIO_PCNF0_LFLEN_Pos); // Packet configuration: // Bit 25: 1 Whitening enabled // Bit 24: 1 Big endian, // 4 byte base address length (5 byte full address length), // 0 byte static length, max 255 byte payload . NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (4UL << RADIO_PCNF1_BALEN_Pos) | (0UL << RADIO_PCNF1_STATLEN_Pos) | (255UL << RADIO_PCNF1_MAXLEN_Pos); NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Disabled << RADIO_CRCCNF_LEN_Pos); packet[0] = 254; // 254 byte payload. // Fill payload with random data. for (i = 0; i < 254; i++) { packet[i+1] = rnd8(); } NRF_RADIO->PACKETPTR = (uint32_t)packet; }
int main() { int i, j; u32 x, y; for (i = 0; i < NUM_SPECIAL_VALUES; i++) { for (j = 0; j < NUM_SPECIAL_VALUES; j++) { test1(special_values[i], special_values[j]); } test1(special_values[i], rnd32()); test1(rnd32(), special_values[i]); } for (i = 0; i < 100; i++) { x = rnd32(); y = rnd32(); test1(x, y); } return 0; }
inline value_type operator ()() const { return(double(rnd32()) * (0.5 / 0x80000000)); }