/** * main function * @return 0. int return type required by ANSI/ISO standard. */ int main(void) { // Configure pins 8-15 (port1) for LEDs as outputs nrf_gpio_range_cfg_output(8, 15); nrf_gpio_port_set(NRF_GPIO_PORT_SELECT_PORT1, 0XFF); NRF_RNG->TASKS_START = 1; // start RNG while (true) { // Clear the VALRDY EVENT and clear gpio8 - 15 (port1) NRF_RNG->EVENTS_VALRDY = 0; // Wait until the value ready event is generated while ( NRF_RNG->EVENTS_VALRDY == 0){} // Set output according to the random value nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, (uint8_t)NRF_RNG->VALUE); nrf_delay_ms(100); } }
/** @brief Function for main application entry. */ int main(void) { // Configure pins 8-15 (port 1) for LEDs as outputs. nrf_gpio_range_cfg_output(LED_START, LED_STOP); nrf_gpio_port_set(NRF_GPIO_PORT_SELECT_PORT1, 0XFF); NRF_RNG->TASKS_START = 1; // start the RNG peripheral. while (true) { // Clear the VALRDY EVENT. NRF_RNG->EVENTS_VALRDY = 0; // Wait until the value ready event is generated. while (NRF_RNG->EVENTS_VALRDY == 0) { // Do nothing. } // Set output according to the random value. nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, (uint8_t)NRF_RNG->VALUE); nrf_delay_ms(100); } }