/** * @brief Function for main application entry. */ int main(void) { LEDS_CONFIGURE(BSP_LED_0_MASK); LEDS_OFF(BSP_LED_0_MASK); adc_config(); UNUSED_RETURN_VALUE(NRF_LOG_INIT()); NRF_LOG_PRINTF("ADC example\r\n"); while (true) { APP_ERROR_CHECK(nrf_drv_adc_buffer_convert(adc_buffer,ADC_BUFFER_SIZE)); uint32_t i; for (i = 0; i < ADC_BUFFER_SIZE; i++) { // manually trigger ADC conversion nrf_drv_adc_sample(); // enter into sleep mode __SEV(); __WFE(); __WFE(); nrf_delay_ms(100); LEDS_INVERT(BSP_LED_0_MASK); } } }
static void nrfx_rng_handler(uint8_t rng_val) { NRF_DRV_RNG_LOCK(); if (!NRF_DRV_RNG_SD_IS_ENABLED()) { UNUSED_RETURN_VALUE(nrf_queue_push(&m_rand_pool, &rng_val)); if (nrf_queue_is_full(&m_rand_pool)) { nrfx_rng_stop(); } NRF_LOG_DEBUG("Event: NRF_RNG_EVENT_VALRDY."); } NRF_DRV_RNG_RELEASE(); }
/** * @brief This function calls the user's observer (@ref m_observer) after it is done handling the event. */ static void dfu_observer(nrf_dfu_evt_type_t event) { switch (event) { case NRF_DFU_EVT_DFU_COMPLETED: { #ifndef NRF_DFU_NO_TRANSPORT UNUSED_RETURN_VALUE(nrf_dfu_transports_close(NULL)); #endif break; } default: break; } /* Call user's observer if present. */ if (m_user_observer) { m_user_observer(event); } }
ret_code_t nfc_ndef_msg_encode(nfc_ndef_msg_desc_t const * p_ndef_msg_desc, uint8_t * p_msg_buffer, uint32_t * const p_msg_len) { nfc_ndef_record_location_t record_location; uint32_t temp_len; uint32_t i; uint32_t err_code; uint32_t sum_of_len = 0; if ((p_ndef_msg_desc == NULL) || p_msg_len == NULL) { return NRF_ERROR_NULL; } nfc_ndef_record_desc_t * * pp_record_rec_desc = p_ndef_msg_desc->pp_record; if (p_ndef_msg_desc->pp_record == NULL) { return NRF_ERROR_NULL; } #if NFC_NDEF_MSG_TAG_TYPE == TYPE_4_TAG uint8_t * p_root_msg_buffer = p_msg_buffer; if (p_msg_buffer != NULL) { if (*p_msg_len < NLEN_FIELD_SIZE) { return NRF_ERROR_NO_MEM; } p_msg_buffer += NLEN_FIELD_SIZE; } sum_of_len += NLEN_FIELD_SIZE; #endif for (i = 0; i < p_ndef_msg_desc->record_count; i++) { record_location = record_location_get(i, p_ndef_msg_desc->record_count); temp_len = *p_msg_len - sum_of_len; err_code = nfc_ndef_record_encode(*pp_record_rec_desc, record_location, p_msg_buffer, &temp_len); if (err_code != NRF_SUCCESS) { return err_code; } sum_of_len += temp_len; if (p_msg_buffer != NULL) { p_msg_buffer += temp_len; } /* next record */ pp_record_rec_desc++; } #if NFC_NDEF_MSG_TAG_TYPE == TYPE_4_TAG if (p_msg_buffer != NULL) { if (sum_of_len - NLEN_FIELD_SIZE > UINT16_MAX) { return NRF_ERROR_NOT_SUPPORTED; } UNUSED_RETURN_VALUE(uint16_big_encode(sum_of_len - NLEN_FIELD_SIZE, p_root_msg_buffer)); } #endif *p_msg_len = sum_of_len; return NRF_SUCCESS; }