SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Functions

Functions

 SVCALL (SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t *p_mutex))
 Initialize a mutex.
 SVCALL (SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t *p_mutex))
 Attempt to acquire a mutex.
 SVCALL (SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t *p_mutex))
 Release a mutex.
 SVCALL (SD_NVIC_ENABLEIRQ, uint32_t, sd_nvic_EnableIRQ(IRQn_Type IRQn))
 Enable External Interrupt.
 SVCALL (SD_NVIC_DISABLEIRQ, uint32_t, sd_nvic_DisableIRQ(IRQn_Type IRQn))
 Disable External Interrupt.
 SVCALL (SD_NVIC_GETPENDINGIRQ, uint32_t, sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t *p_pending_irq))
 Get Pending Interrupt.
 SVCALL (SD_NVIC_SETPENDINGIRQ, uint32_t, sd_nvic_SetPendingIRQ(IRQn_Type IRQn))
 Set Pending Interrupt.
 SVCALL (SD_NVIC_CLEARPENDINGIRQ, uint32_t, sd_nvic_ClearPendingIRQ(IRQn_Type IRQn))
 Clear Pending Interrupt.
 SVCALL (SD_NVIC_SETPRIORITY, uint32_t, sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority))
 Set Interrupt Priority.
 SVCALL (SD_NVIC_GETPRIORITY, uint32_t, sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t *p_priority))
 Get Interrupt Priority.
 SVCALL (SD_NVIC_SYSTEMRESET, uint32_t, sd_nvic_SystemReset(void))
 System Reset.
 SVCALL (SD_NVIC_CRITICAL_REGION_ENTER, uint32_t, sd_nvic_critical_region_enter(uint8_t *p_is_nested_critical_region))
 Enters critical region.
 SVCALL (SD_NVIC_CRITICAL_REGION_EXIT, uint32_t, sd_nvic_critical_region_exit(uint8_t is_nested_critical_region))
 Exit critical region.
 SVCALL (SD_RAND_APPLICATION_POOL_CAPACITY, uint32_t, sd_rand_application_pool_capacity_get(uint8_t *p_pool_capacity))
 Query the capacity of the application random pool.
 SVCALL (SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t *p_bytes_available))
 Get number of random bytes available to the application.
 SVCALL (SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t *p_buff, uint8_t length))
 Get random bytes from the application pool.
 SVCALL (SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t *p_reset_reason))
 Gets the reset reason register.
 SVCALL (SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk))
 Clears the bits of the reset reason register.
 SVCALL (SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(nrf_power_mode_t power_mode))
 Sets the power mode when in CPU sleep.
 SVCALL (SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void))
 Puts the chip in System OFF mode.
 SVCALL (SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable))
 Enables or disables the power-fail comparator.
 SVCALL (SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold))
 Sets the power-fail threshold value.
 SVCALL (SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon))
 Sets bits in the NRF_POWER->RAMON register.
 SVCALL (SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon))
 Clears bits in the NRF_POWER->RAMON register.
 SVCALL (SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t *p_ramon))
 Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
 SVCALL (SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk))
 Set bits in the NRF_POWER->GPREGRET register.
 SVCALL (SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk))
 Clear bits in the NRF_POWER->GPREGRET register.
 SVCALL (SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret))
 Get contents of the NRF_POWER->GPREGRET register.
 SVCALL (SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode))
 Sets the DCDC mode.
 SVCALL (SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void))
 Request the high frequency crystal oscillator.
 SVCALL (SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void))
 Releases the high frequency crystal oscillator.
 SVCALL (SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t *p_is_running))
 Checks if the high frequency crystal oscillator is running.
 SVCALL (SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void))
 Waits for an application event.
 SVCALL (SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t *p_channel_enable))
 Get PPI channel enable register contents.
 SVCALL (SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk))
 Set PPI channel enable register.
 SVCALL (SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk))
 Clear PPI channel enable register.
 SVCALL (SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void *evt_endpoint, const volatile void *task_endpoint))
 Assign endpoints to a PPI channel.
 SVCALL (SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num))
 Task to enable a channel group.
 SVCALL (SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num))
 Task to disable a channel group.
 SVCALL (SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk))
 Assign PPI channels to a channel group.
 SVCALL (SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t *p_channel_msk))
 Gets the PPI channels of a channel group.
 SVCALL (SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(nrf_radio_notification_type_t type, nrf_radio_notification_distance_t distance))
 Configures the Radio Notification signal.
 SVCALL (SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t *p_ecb_data))
 Encrypts a block according to the specified parameters.
 SVCALL (SD_EVT_GET, uint32_t, sd_evt_get(uint32_t *p_evt_id))
 Gets any pending events generated by the SoC API.
 SVCALL (SD_TEMP_GET, uint32_t, sd_temp_get(int32_t *p_temp))
 Get the temperature measured on the chip.
 SVCALL (SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t *const p_dst, uint32_t const *const p_src, uint32_t size))
 Flash Write.
 SVCALL (SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number))
 Flash Erase page.
 SVCALL (SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1))
 Flash Protection set.
 SVCALL (SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback))
 Opens a session for radio requests.
 SVCALL (SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void))
 Closes a session for radio requests.
 SVCALL (SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t *p_request))
 Requests a radio timeslot.

Function Documentation

SVCALL ( SD_MUTEX_NEW  ,
uint32_t  ,
sd_mutex_new(nrf_mutex_t *p_mutex)   
)

Initialize a mutex.

Parameters:
[in]p_mutexPointer to the mutex to initialize.
Return values:
NRF_SUCCESS
SVCALL ( SD_RADIO_REQUEST  ,
uint32_t  ,
sd_radio_request(nrf_radio_request_t *p_request)   
)

Requests a radio timeslot.

Note:
The timing of the radio timeslot is specified by p_request->distance_us. For the first request in a session, p_request->distance_us is required to be 0 by convention, and the timeslot is scheduled at the first possible opportunity. All following radio timeslots are requested with a distance of p_request->distance_us measured from the start of the previous radio timeslot.
A too small p_request->distance_us will lead to a NRF_EVT_RADIO_BLOCKED event.
Timeslots scheduled too close will lead to a NRF_EVT_RADIO_BLOCKED event.
See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
If an opportunity for the first radio timeslot is not found before 100ms after the call to this function, it is not scheduled, and instead a NRF_EVT_RADIO_BLOCKED event is sent. The application may then try to schedule the first radio timeslot again.
Successful requests will result in nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START). Unsuccessful requests will result in a NRF_EVT_RADIO_BLOCKED event, see NRF_SOC_EVTS.
The jitter in the start time of the radio timeslots is +/- NRF_RADIO_START_JITTER_US us.
The nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the specified radio timeslot start, but this does not affect the actual start time of the timeslot.
NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is guaranteed to be clocked from the external crystal.
The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral during the radio timeslot.
Parameters:
[in]p_requestPointer to the request parameters.
Return values:
NRF_ERROR_FORBIDDENIf session not opened or the session is not IDLE.
NRF_ERROR_INVALID_ADDRIf the p_request pointer is invalid.
NRF_ERROR_INVALID_PARAMIf the parameters of p_request are not valid.
NRF_SUCCESSOtherwise.
SVCALL ( SD_RADIO_SESSION_CLOSE  ,
uint32_t  ,
sd_radio_session_close(void)   
)

Closes a session for radio requests.

Note:
Any current radio timeslot will be finished before the session is closed.
If a radio timeslot is scheduled when the session is closed, it will be canceled.
The application cannot consider the session closed until the NRF_EVT_RADIO_SESSION_CLOSED event is received.
Return values:
NRF_ERROR_FORBIDDENIf session not opened.
NRF_ERROR_BUSYIf session is currently being closed.
NRF_SUCCESSOtherwise.
SVCALL ( SD_RADIO_SESSION_OPEN  ,
uint32_t  ,
sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback)   
)

Opens a session for radio requests.

Note:
Only one session can be open at a time.
p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed by the application.
p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0 interrupt occurs.
p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO interrupt occurs.
p_radio_signal_callback() will be called at ARM interrupt priority level 0. This implies that none of the sd_* API calls can be used from p_radio_signal_callback().
Parameters:
[in]p_radio_signal_callbackThe signal callback.
Return values:
NRF_ERROR_INVALID_ADDRp_radio_signal_callback is an invalid function pointer.
NRF_ERROR_BUSYIf session cannot be opened.
NRF_ERROR_INTERNALIf a new session could not be opened due to an internal error.
NRF_SUCCESSOtherwise.
SVCALL ( SD_FLASH_PROTECT  ,
uint32_t  ,
sd_flash_protect(uint32_t protenset0, uint32_t protenset1)   
)

Flash Protection set.

Commands to set the flash protection registers PROTENSETx

Note:
To read the values in PROTENSETx you can read them directly. They are only write-protected.
Parameters:
[in]protenset0Value to be written to PROTENSET0
[in]protenset1Value to be written to PROTENSET1
Return values:
NRF_ERROR_FORBIDDENTried to protect the SoftDevice
NRF_SUCCESSValues successfully written to PROTENSETx
SVCALL ( SD_FLASH_PAGE_ERASE  ,
uint32_t  ,
sd_flash_page_erase(uint32_t page_number)   
)

Flash Erase page.

Commands to erase a flash page

This call initiates the flash access command, and its completion will be communicated to the application with exactly one of the following events:

  • NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
  • NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
Note:
  • This call takes control over the radio and the CPU during flash erase and write to make sure that they will not interfere with the flash access. This means that all interrupts will be blocked for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual and the command parameters).
Parameters:
[in]page_numberPagenumber of the page to erase
Return values:
NRF_ERROR_INTERNALIf a new session could not be opened due to an internal error.
NRF_ERROR_INVALID_ADDRTried to erase to a non existing flash page.
NRF_ERROR_BUSYThe previous command has not yet completed.
NRF_ERROR_FORBIDDENTried to erase a protected page.
NRF_SUCCESSThe command was accepted.
SVCALL ( SD_FLASH_WRITE  ,
uint32_t  ,
sd_flash_write(uint32_t *const p_dst, uint32_t const *const p_src, uint32_t size)   
)

Flash Write.

Commands to write a buffer to flash

This call initiates the flash access command, and its completion will be communicated to the application with exactly one of the following events:

  • NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
  • NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
Note:
  • This call takes control over the radio and the CPU during flash erase and write to make sure that they will not interfere with the flash access. This means that all interrupts will be blocked for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual and the command parameters).
Parameters:
[in]p_dstPointer to start of flash location to be written.
[in]p_srcPointer to buffer with data to be written
[in]sizeNumber of 32-bit words to write. Maximum size is 256 32bit words.
Return values:
NRF_ERROR_INVALID_ADDRTried to write to a non existing flash address, or p_dst or p_src was unaligned.
NRF_ERROR_BUSYThe previous command has not yet completed.
NRF_ERROR_INVALID_LENGTHSize was 0, or more than 256 words.
NRF_ERROR_FORBIDDENTried to write to or read from protected location.
NRF_SUCCESSThe command was accepted.
SVCALL ( SD_TEMP_GET  ,
uint32_t  ,
sd_temp_get(int32_t *p_temp)   
)

Get the temperature measured on the chip.

This function will block until the temperature measurement is done. It takes around 50us from call to return.

Note:
Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function.
Parameters:
[out]p_tempResult of temperature measurement. Die temperature in 0.25 degrees celsius.
Return values:
NRF_SUCCESSA temperature measurement was done, and the temperature was written to temp
SVCALL ( SD_EVT_GET  ,
uint32_t  ,
sd_evt_get(uint32_t *p_evt_id)   
)

Gets any pending events generated by the SoC API.

The application should keep calling this function to get events, until NRF_ERROR_NOT_FOUND is returned.

Parameters:
[out]p_evt_idSet to one of the values in NRF_SOC_EVTS, if any events are pending.
Return values:
NRF_SUCCESSAn event was pending. The event id is written in the p_evt_id parameter.
NRF_ERROR_NOT_FOUNDNo pending events.
SVCALL ( SD_ECB_BLOCK_ENCRYPT  ,
uint32_t  ,
sd_ecb_block_encrypt(nrf_ecb_hal_data_t *p_ecb_data)   
)

Encrypts a block according to the specified parameters.

128-bit AES encryption.

Parameters:
[in,out]p_ecb_dataPointer to the ECB parameters' struct (two input parameters and one output parameter).
Return values:
NRF_SUCCESS
SVCALL ( SD_RADIO_NOTIFICATION_CFG_SET  ,
uint32_t  ,
sd_radio_notification_cfg_set(nrf_radio_notification_type_t type, nrf_radio_notification_distance_t distance)   
)

Configures the Radio Notification signal.

Note:
  • The notification signal latency depends on the interrupt priority settings of SWI used for notification signal.
  • In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice will interrupt the application to do Radio Event preparation.
  • Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have to shorten the connection events to have time for the Radio Notification signals.
Parameters:
[in]typeType of notification signal. NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio notification. Using NRF_RADIO_NOTIFICATION_DISTANCE_NONE is recommended (but not required) to be used with NRF_RADIO_NOTIFICATION_TYPE_NONE.
[in]distanceDistance between the notification signal and start of radio activity. This parameter is ignored when NRF_RADIO_NOTIFICATION_TYPE_NONE or NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
Return values:
NRF_ERROR_INVALID_PARAMThe group number is invalid.
NRF_SUCCESS
SVCALL ( SD_PPI_GROUP_GET  ,
uint32_t  ,
sd_ppi_group_get(uint8_t group_num, uint32_t *p_channel_msk)   
)

Gets the PPI channels of a channel group.

Parameters:
[in]group_numNumber of the channel group.
[out]p_channel_mskMask of the channels assigned to the group.
Return values:
NRF_ERROR_SOC_PPI_INVALID_GROUPThe group number is invalid.
NRF_SUCCESS
SVCALL ( SD_PPI_GROUP_ASSIGN  ,
uint32_t  ,
sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk)   
)

Assign PPI channels to a channel group.

Parameters:
[in]group_numNumber of the channel group.
[in]channel_mskMask of the channels to assign to the group.
Return values:
NRF_ERROR_SOC_PPI_INVALID_GROUPThe group number is invalid.
NRF_SUCCESS
SVCALL ( SD_PPI_GROUP_TASK_DISABLE  ,
uint32_t  ,
sd_ppi_group_task_disable(uint8_t group_num)   
)

Task to disable a channel group.

Parameters:
[in]group_numNumber of the PPI group.
Return values:
NRF_ERROR_SOC_PPI_INVALID_GROUPThe group number is invalid.
NRF_SUCCESS
SVCALL ( SD_PPI_GROUP_TASK_ENABLE  ,
uint32_t  ,
sd_ppi_group_task_enable(uint8_t group_num)   
)

Task to enable a channel group.

Parameters:
[in]group_numNumber of the channel group.
Return values:
NRF_ERROR_SOC_PPI_INVALID_GROUPThe group number is invalid
NRF_SUCCESS
SVCALL ( SD_PPI_CHANNEL_ASSIGN  ,
uint32_t  ,
sd_ppi_channel_assign(uint8_t channel_num, const volatile void *evt_endpoint, const volatile void *task_endpoint)   
)

Assign endpoints to a PPI channel.

Parameters:
[in]channel_numNumber of the PPI channel to assign.
[in]evt_endpointEvent endpoint of the PPI channel.
[in]task_endpointTask endpoint of the PPI channel.
Return values:
NRF_ERROR_SOC_PPI_INVALID_CHANNELThe channel number is invalid.
NRF_SUCCESS
SVCALL ( SD_PPI_CHANNEL_ENABLE_CLR  ,
uint32_t  ,
sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk)   
)

Clear PPI channel enable register.

Parameters:
[in]channel_enable_clr_mskMask containing the bits to clear in the PPI CHEN register.
Return values:
NRF_SUCCESS
SVCALL ( SD_PPI_CHANNEL_ENABLE_SET  ,
uint32_t  ,
sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)   
)

Set PPI channel enable register.

Parameters:
[in]channel_enable_set_mskMask containing the bits to set in the PPI CHEN register.
Return values:
NRF_SUCCESS
SVCALL ( SD_PPI_CHANNEL_ENABLE_GET  ,
uint32_t  ,
sd_ppi_channel_enable_get(uint32_t *p_channel_enable)   
)

Get PPI channel enable register contents.

Parameters:
[out]p_channel_enableThe contents of the PPI CHEN register.
Return values:
NRF_SUCCESS
SVCALL ( SD_APP_EVT_WAIT  ,
uint32_t  ,
sd_app_evt_wait(void)   
)

Waits for an application event.

An application event is either an application interrupt or a pended interrupt when the interrupt is disabled. When the interrupt is enabled it will be taken immediately since this function will wait in thread mode, then the execution will return in the application's main thread. When an interrupt is disabled and gets pended it will return to the application's thread main. The application must ensure that the pended flag is cleared using sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for disabled interrupts, as the interrupt handler will clear the pending flag automatically for enabled interrupts.

In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0 System Control Register (SCR).

See also:
CMSIS_SCB
Note:
If an application interrupt has happened since the last time sd_app_evt_wait was called this function will return immediately and not go to sleep. This is to avoid race conditions that can occur when a flag is updated in the interrupt handler and processed in the main loop.
Postcondition:
An application interrupt has happened or a interrupt pending flag is set.
Return values:
NRF_SUCCESS
SVCALL ( SD_CLOCK_HFCLK_IS_RUNNING  ,
uint32_t  ,
sd_clock_hfclk_is_running(uint32_t *p_is_running)   
)

Checks if the high frequency crystal oscillator is running.

See also:
sd_clock_hfclk_request
sd_clock_hfclk_release
Parameters:
[out]p_is_running1 if the external crystal oscillator is running, 0 if not.
Return values:
NRF_SUCCESS
SVCALL ( SD_CLOCK_HFCLK_RELEASE  ,
uint32_t  ,
sd_clock_hfclk_release(void)   
)

Releases the high frequency crystal oscillator.

Will stop the high frequency crystal oscillator, this happens immediately.

See also:
sd_clock_hfclk_is_running
sd_clock_hfclk_request
Return values:
NRF_SUCCESS
SVCALL ( SD_CLOCK_HFCLK_REQUEST  ,
uint32_t  ,
sd_clock_hfclk_request(void)   
)

Request the high frequency crystal oscillator.

Will start the high frequency crystal oscillator, the startup time of the crystal varies and the sd_clock_hfclk_is_running function can be polled to check if it has started.

See also:
sd_clock_hfclk_is_running
sd_clock_hfclk_release
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_DCDC_MODE_SET  ,
uint32_t  ,
sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode)   
)

Sets the DCDC mode.

Depending on the internal state of the SoftDevice, the mode change may not happen immediately. The DCDC mode switch will be blocked when occurring in close proximity to radio transmissions. When the radio transmission is done, the last mode will be used.

Parameters:
[in]dcdc_modeThe mode of the DCDC.
Return values:
NRF_SUCCESS
NRF_ERROR_INVALID_PARAMThe DCDC mode is invalid.
SVCALL ( SD_POWER_GPREGRET_GET  ,
uint32_t  ,
sd_power_gpregret_get(uint32_t *p_gpregret)   
)

Get contents of the NRF_POWER->GPREGRET register.

Parameters:
[out]p_gpregretContents of the GPREGRET register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_GPREGRET_CLR  ,
uint32_t  ,
sd_power_gpregret_clr(uint32_t gpregret_msk)   
)

Clear bits in the NRF_POWER->GPREGRET register.

Parameters:
[in]gpregret_mskBits to be clear in the GPREGRET register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_GPREGRET_SET  ,
uint32_t  ,
sd_power_gpregret_set(uint32_t gpregret_msk)   
)

Set bits in the NRF_POWER->GPREGRET register.

Parameters:
[in]gpregret_mskBits to be set in the GPREGRET register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_RAMON_GET  ,
uint32_t  ,
sd_power_ramon_get(uint32_t *p_ramon)   
)

Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.

Parameters:
[out]p_ramonContent of NRF_POWER->RAMON register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_RAMON_CLR  ,
uint32_t  ,
sd_power_ramon_clr(uint32_t ramon)   
)

Clears bits in the NRF_POWER->RAMON register.

Parameters:
ramonContains the bits needed to be cleared in the NRF_POWER->RAMON register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_RAMON_SET  ,
uint32_t  ,
sd_power_ramon_set(uint32_t ramon)   
)

Sets bits in the NRF_POWER->RAMON register.

Parameters:
[in]ramonContains the bits needed to be set in the NRF_POWER->RAMON register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_POF_THRESHOLD_SET  ,
uint32_t  ,
sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold)   
)

Sets the power-fail threshold value.

Parameters:
[in]thresholdThe power-fail threshold value to use.
Return values:
NRF_SUCCESSThe power failure threshold was set.
NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWNThe power failure threshold is unknown.
SVCALL ( SD_POWER_POF_ENABLE  ,
uint32_t  ,
sd_power_pof_enable(uint8_t pof_enable)   
)

Enables or disables the power-fail comparator.

Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs. The event can be retrieved with sd_evt_get();

Parameters:
[in]pof_enableTrue if the power-fail comparator should be enabled, false if it should be disabled.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_SYSTEM_OFF  ,
uint32_t  ,
sd_power_system_off(void)   
)

Puts the chip in System OFF mode.

Return values:
NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
SVCALL ( SD_POWER_MODE_SET  ,
uint32_t  ,
sd_power_mode_set(nrf_power_mode_t power_mode)   
)

Sets the power mode when in CPU sleep.

Parameters:
[in]power_modeThe power mode to use when in CPU sleep.
See also:
sd_app_evt_wait
Return values:
NRF_SUCCESSThe power mode was set.
NRF_ERROR_SOC_POWER_MODE_UNKNOWNThe power mode was unknown.
SVCALL ( SD_POWER_RESET_REASON_CLR  ,
uint32_t  ,
sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk)   
)

Clears the bits of the reset reason register.

Parameters:
[in]reset_reason_clr_mskContains the bits to clear from the reset reason register.
Return values:
NRF_SUCCESS
SVCALL ( SD_POWER_RESET_REASON_GET  ,
uint32_t  ,
sd_power_reset_reason_get(uint32_t *p_reset_reason)   
)

Gets the reset reason register.

Parameters:
[out]p_reset_reasonContents of the NRF_POWER->RESETREAS register.
Return values:
NRF_SUCCESS
SVCALL ( SD_RAND_APPLICATION_GET_VECTOR  ,
uint32_t  ,
sd_rand_application_vector_get(uint8_t *p_buff, uint8_t length)   
)

Get random bytes from the application pool.

Parameters:
[out]p_buffPointer to unit8_t buffer for storing the bytes.
[in]lengthNumber of bytes to take from pool and place in p_buff.
Return values:
NRF_SUCCESSThe requested bytes were written to p_buff.
NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUESNo bytes were written to the buffer, because there were not enough bytes available.
SVCALL ( SD_RAND_APPLICATION_BYTES_AVAILABLE  ,
uint32_t  ,
sd_rand_application_bytes_available_get(uint8_t *p_bytes_available)   
)

Get number of random bytes available to the application.

Parameters:
[out]p_bytes_availableThe number of bytes currently available in the pool.
Return values:
NRF_SUCCESS
SVCALL ( SD_RAND_APPLICATION_POOL_CAPACITY  ,
uint32_t  ,
sd_rand_application_pool_capacity_get(uint8_t *p_pool_capacity)   
)

Query the capacity of the application random pool.

Parameters:
[out]p_pool_capacityThe capacity of the pool.
Return values:
NRF_SUCCESS
SVCALL ( SD_NVIC_CRITICAL_REGION_EXIT  ,
uint32_t  ,
sd_nvic_critical_region_exit(uint8_t is_nested_critical_region)   
)

Exit critical region.

Precondition:
Application has entered a critical region using sd_nvic_critical_region_enter.
Postcondition:
If not in a nested critical region, the application interrupts will restored to the state before sd_nvic_critical_region_enter was called.
Parameters:
[in]is_nested_critical_regionIf this is set to 1, the critical region won't be exited.
See also:
sd_nvic_critical_region_enter.
Return values:
NRF_SUCCESS
SVCALL ( SD_NVIC_CRITICAL_REGION_ENTER  ,
uint32_t  ,
sd_nvic_critical_region_enter(uint8_t *p_is_nested_critical_region)   
)

Enters critical region.

Postcondition:
Application interrupts will be disabled.
See also:
sd_nvic_critical_region_exit
Parameters:
[out]p_is_nested_critical_region1: If in a nested critical region. 0: Otherwise.
Return values:
NRF_SUCCESS
SVCALL ( SD_NVIC_SYSTEMRESET  ,
uint32_t  ,
sd_nvic_SystemReset(void)   
)

System Reset.

Note:
Corresponds to NVIC_SystemReset in CMSIS.
Return values:
NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
SVCALL ( SD_NVIC_GETPRIORITY  ,
uint32_t  ,
sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t *p_priority)   
)

Get Interrupt Priority.

Note:
Corresponds to NVIC_GetPriority in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_GetPriority documentation in CMSIS.
[out]p_priorityReturn value from NVIC_GetPriority.
Return values:
NRF_SUCCESSThe interrupt priority is returned in p_priority.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE- IRQn is not available for the application.
SVCALL ( SD_NVIC_SETPRIORITY  ,
uint32_t  ,
sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority)   
)

Set Interrupt Priority.

Note:
Corresponds to NVIC_SetPriority in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
{priority is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_SetPriority documentation in CMSIS.
[in]priorityA valid IRQ priority for use by the application.
Return values:
NRF_SUCCESSThe interrupt and priority level is available for the application.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEIRQn is not available for the application.
NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWEDThe interrupt priority is not available for the application.
SVCALL ( SD_NVIC_CLEARPENDINGIRQ  ,
uint32_t  ,
sd_nvic_ClearPendingIRQ(IRQn_Type IRQn)   
)

Clear Pending Interrupt.

Note:
Corresponds to NVIC_ClearPendingIRQ in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_ClearPendingIRQ documentation in CMSIS.
Return values:
NRF_SUCCESSThe interrupt pending flag is cleared.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEIRQn is not available for the application.
SVCALL ( SD_NVIC_SETPENDINGIRQ  ,
uint32_t  ,
sd_nvic_SetPendingIRQ(IRQn_Type IRQn)   
)

Set Pending Interrupt.

Note:
Corresponds to NVIC_SetPendingIRQ in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_SetPendingIRQ documentation in CMSIS.
Return values:
NRF_SUCCESSThe interrupt is set pending.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEIRQn is not available for the application.
SVCALL ( SD_NVIC_GETPENDINGIRQ  ,
uint32_t  ,
sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t *p_pending_irq)   
)

Get Pending Interrupt.

Note:
Corresponds to NVIC_GetPendingIRQ in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_GetPendingIRQ documentation in CMSIS.
[out]p_pending_irqReturn value from NVIC_GetPendingIRQ.
Return values:
NRF_SUCCESSThe interrupt is available for the application.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEIRQn is not available for the application.
SVCALL ( SD_NVIC_DISABLEIRQ  ,
uint32_t  ,
sd_nvic_DisableIRQ(IRQn_Type IRQn)   
)

Disable External Interrupt.

Note:
Corresponds to NVIC_DisableIRQ in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_DisableIRQ documentation in CMSIS
Return values:
NRF_SUCCESSThe interrupt was disabled.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEThe interrupt is not available for the application.
SVCALL ( SD_NVIC_ENABLEIRQ  ,
uint32_t  ,
sd_nvic_EnableIRQ(IRQn_Type IRQn)   
)

Enable External Interrupt.

Note:
Corresponds to NVIC_EnableIRQ in CMSIS.
Precondition:
{IRQn is valid and not reserved by the stack}
Parameters:
[in]IRQnSee the NVIC_EnableIRQ documentation in CMSIS.
Return values:
NRF_SUCCESSThe interrupt was enabled.
NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLEThe interrupt is not available for the application.
NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWEDThe interrupt has a priority not available for the application.
SVCALL ( SD_MUTEX_RELEASE  ,
uint32_t  ,
sd_mutex_release(nrf_mutex_t *p_mutex)   
)

Release a mutex.

Parameters:
[in]p_mutexPointer to the mutex to release.
Return values:
NRF_SUCCESS
SVCALL ( SD_MUTEX_ACQUIRE  ,
uint32_t  ,
sd_mutex_acquire(nrf_mutex_t *p_mutex)   
)

Attempt to acquire a mutex.

Parameters:
[in]p_mutexPointer to the mutex to acquire.
Return values:
NRF_SUCCESSThe mutex was successfully acquired.
NRF_ERROR_SOC_MUTEX_ALREADY_TAKENThe mutex could not be acquired.