update nrfx to v2.1.0
this is required for latest tinyusb
This commit is contained in:
1 parent
eefeba8d64
commit
ad3ed9b2ab
154 files changed
+60002
-6899
No files matched your search
@@ -1,6 +1,93 @@
|
||||
# Changelog
|
||||
All notable changes to this project are documented in this file.
|
||||
|
||||
## [2.1.0] - 2020-01-24
|
||||
### Added
|
||||
- Added HALs for DCNF, OSCILLATORS, USBREG, and VREQCTRL.
|
||||
- Added support for 1-MHz clock frequency in TWIM.
|
||||
- Introduced the NRFX_I2S_STATUS_TRANSFER_STOPPED flag in the I2S driver.
|
||||
- Introduced the nrfx_power_compat layer that allows use of the nrfx_power API with new SoC.
|
||||
- Added encryption support in the QSPI driver.
|
||||
- Added support for USBD in nRF5340.
|
||||
- Expanded HALs to cover new functions in nRF5340: GPIO, I2S, PDM, POWER, QSPI, and REGULATORS.
|
||||
- Introduced new clock management system in the CLOCK driver.
|
||||
- Introduced new audio clock configuration settings in the I2S and PDM drivers for nRF5340.
|
||||
- Implemented workaround for nRF5340 anomaly 4 in the CLOCK driver.
|
||||
- Implemented workaround for nRF5340 anomaly 10 in the CCM HAL.
|
||||
- Implemented workaround for nRF9160 anomaly 21 and nRF5340 anomaly 6 in the NVMC HAL.
|
||||
- Implemented workaround for nRF9160 anomaly 23 and nRF5340 anomaly 44 in the UARTE driver.
|
||||
- Introduced the NRFX_TWIM_NO_SPURIOUS_STOP_CHECK flag in the TWIM driver.
|
||||
- Added functions for getting shortcut configuration in the TWIM HAL.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.30.2.
|
||||
- Reorganized templates of nrfx_config header files for different SoCs. Now they are included through one common file according to the selected SoC.
|
||||
- Improved the UARTE driver to consume less current after the driver uninitialization. Now all clocks are disabled properly after uninitialization.
|
||||
- Improved the GPIOTE driver robustness by setting the LATCH functionality to be used by default.
|
||||
- Changed names of the frequency divider symbols in the QSPI HAL to reflect the new frequencies in nRF5340. Old API names were preserved and are still supported.
|
||||
- Improved spurious STOP condition handling in the TWIM driver.
|
||||
- Improved sampling procedure in the advanced blocking mode in the SAADC driver.
|
||||
- Improved calibration procedure in the SAADC driver for nRF5340 and nRF9160.
|
||||
|
||||
### Fixed
|
||||
- Fixed address assertions in NVMC driver for the nRF5340 network core.
|
||||
- Fixed an issue in the TWI driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred.
|
||||
- Fixed the stopping procedure in the PWM driver. Previously in very specific circumstances the PWM output might be not stopped at all or might be immediately restarted.
|
||||
|
||||
## [2.0.0] - 2019-11-06
|
||||
### Added
|
||||
- Added support for nRF5340.
|
||||
- Added HALs for: CACHE, FPU, MUTEX, and RESET.
|
||||
- Added driver and HAL for IPC.
|
||||
- Added possibility to configure in UART and UARTE the number of stop bits and the type of parity, when a given SoC allows it.
|
||||
- Added function in the GPIO HAL for selecting the MCU to control the specified pin.
|
||||
- Added support for ONESHOT register in the TIMER HAL.
|
||||
- Added support for LIST feature in HALs for SPIS and TWIS.
|
||||
- Added possibility to choose TIMER instance used for workarounds in the NFCT driver.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.29.0.
|
||||
- Enhanced PWM driver API: added the "p_context" parameter to the event handler.
|
||||
- Updated address and task getters in all HALs to return values as uint32_t type.
|
||||
- Updated all HAL functions to take the pointer to the structure of registers of the peripheral as their first argument.
|
||||
- Changed __STATIC_INLINE symbol to NRF_STATIC_INLINE for HALs and NRFX_STATIC_INLINE for drivers.
|
||||
- Refactored the SAADC driver and HAL.
|
||||
- Refactored the WDT driver and HAL to support multiple instances.
|
||||
- Changed nrfx_gpiote_init() function to take the interrupt priority as its parameter. Previously this priority was an nrfx_config option.
|
||||
- Changed nrf_usbd_ep_all_disable() function to disable really all endpoints. Use nrf_usbd_ep_default_config() to restore the default endpoint configuration.
|
||||
- Updated nrfx_gpiote_out_init() and nrfx_gpiote_in_init() return codes. Now NRFX_ERROR_INVALID_STATE is changed to NRFX_ERROR_BUSY.
|
||||
- Replaced the SWI/EGU driver with one for EGU only.
|
||||
- Aligned symbol names for default IRQ priority in nrfx_config. These symbols are now adhering to the following standard: NRFX_xxx_DEFAULT_CONFIG_IRQ_PRIORITY.
|
||||
- Changed the way of configuring the MISO pin pull setting in SPI and SPIM drivers. Now it can be set separately for each instance.
|
||||
|
||||
### Removed
|
||||
- Removed deprecated functions from drivers: TWI and TWIM. See migration guide for details.
|
||||
- Removed deprecated functions from HALs: ECB, NVMC, and TEMP. See migration guide for details.
|
||||
- Removed redundant bariers in the nrfx_usbd driver.
|
||||
- Removed the default configuration values for drivers from the nrfx_config header files.
|
||||
|
||||
## [1.8.1] - 2019-10-21
|
||||
### Added
|
||||
- Added functions in the GPIOTE driver for getting task or event for the specified GPIO pin.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to version 8.27.1.
|
||||
- Moved the nrfx_gppi helper from helpers/nrfx_gppi/ to helpers/.
|
||||
- Changed the interrupt initialization in the GPIOTE driver, so that mapping of the GPIOTEx_IRQn enumeration values is no longer needed for nRF9160.
|
||||
|
||||
## [1.8.0] - 2019-08-27
|
||||
### Added
|
||||
- Added support for nRF52833.
|
||||
- Added bus recovery feature in the TWI and TWIM drivers.
|
||||
- Added the nrfx_gppi helper layer to facilitate developing generic code that can utilize PPI or DPPI, depending on which interface is available in a given SoC.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to version 8.27.0.
|
||||
|
||||
### Fixed
|
||||
- Fixed an issue in the TWIM driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred.
|
||||
- Fixed a frame timing bug in the NFCT driver. Previously, the timing of the SENS_RES response could be violated after the NFCT peripheral was put to the Sleep state with the SLP_REQ command.
|
||||
|
||||
## [1.7.2] - 2019-07-25
|
||||
### Added
|
||||
- Added functions in the DPPI, GPIOTE, PPI, RTC, and TIMER HALs for getting tasks and events specified by index.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -16,7 +16,9 @@ SoCs, as well as startup and initialization files for them.
|
||||
* nRF52810
|
||||
* nRF52811
|
||||
* nRF52832
|
||||
* nRF52833
|
||||
* nRF52840
|
||||
* nRF5340
|
||||
* nRF9160
|
||||
|
||||
## Directories
|
||||
@@ -24,12 +26,13 @@ SoCs, as well as startup and initialization files for them.
|
||||
```
|
||||
.
|
||||
├── doc # Project documentation files
|
||||
├── drivers # nrfx drivers files
|
||||
│ └── include # nrfx drivers headers
|
||||
│ └── src # nrfx drivers sources
|
||||
├── drivers # nrfx driver files
|
||||
│ └── include # nrfx driver headers
|
||||
│ └── src # nrfx driver sources
|
||||
├── hal # Hardware Access Layer files
|
||||
├── mdk # Nordic MDK files
|
||||
├── soc # Nordic SoC related files
|
||||
├── helpers # nrfx driver helper files
|
||||
├── mdk # nRF MDK files
|
||||
├── soc # SoC specific files
|
||||
└── templates # Templates of nrfx integration files
|
||||
```
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,21 +57,22 @@ extern "C" {
|
||||
* @param[in] bit Bit index.
|
||||
* @param[in] p_mask Pointer to mask with bit fields.
|
||||
*
|
||||
* @return 0 if bit is not set, positive value otherwise.
|
||||
* @retval true If the specified bit is set.
|
||||
* @retval false If the specified bit is cleared.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
|
||||
__STATIC_INLINE bool nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
|
||||
{
|
||||
uint8_t const * p_mask8 = (uint8_t const *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
return (1 << bit) & p_mask8[byte_idx];
|
||||
return ((1U << bit) & p_mask8[byte_idx]) != 0U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for setting a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param[in] bit Bit index.
|
||||
* @param[in] p_mask Pointer to mask with bit fields.
|
||||
* @param[in] bit Bit index.
|
||||
* @param[in,out] p_mask Pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
|
||||
{
|
||||
@@ -84,8 +85,8 @@ __STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
|
||||
/**
|
||||
* @brief Function for clearing a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param[in] bit Bit index.
|
||||
* @param[in] p_mask Pointer to mask with bit fields.
|
||||
* @param[in] bit Bit index.
|
||||
* @param[in,out] p_mask Pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
|
||||
{
|
||||
@@ -98,21 +99,20 @@ __STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
|
||||
/**
|
||||
* @brief Function for performing bitwise OR operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param[in] p_mask1 Pointer to the first bit mask.
|
||||
* @param[in] p_mask2 Pointer to the second bit mask.
|
||||
* @param[in] p_out_mask Pointer to the output bit mask.
|
||||
* @param[in] length Length of output mask in bytes.
|
||||
* @param[in] p_mask1 Pointer to the first bit mask.
|
||||
* @param[in] p_mask2 Pointer to the second bit mask.
|
||||
* @param[out] p_out_mask Pointer to the output bit mask.
|
||||
* @param[in] length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
size_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] | p_mask8_2[i];
|
||||
}
|
||||
@@ -121,21 +121,20 @@ __STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
|
||||
/**
|
||||
* @brief Function for performing bitwise AND operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param[in] p_mask1 Pointer to the first bit mask.
|
||||
* @param[in] p_mask2 Pointer to the second bit mask.
|
||||
* @param[in] p_out_mask Pointer to the output bit mask.
|
||||
* @param[in] length Length of output mask in bytes.
|
||||
* @param[in] p_mask1 Pointer to the first bit mask.
|
||||
* @param[in] p_mask2 Pointer to the second bit mask.
|
||||
* @param[out] p_out_mask Pointer to the output bit mask.
|
||||
* @param[in] length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
size_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] & p_mask8_2[i];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -77,18 +77,28 @@ typedef struct
|
||||
} data; ///< Union to store event data.
|
||||
} nrfx_adc_evt_t;
|
||||
|
||||
/** @brief Macro for initializing the ADC channel with the default configuration. */
|
||||
/**
|
||||
* @brief ADC channel default configuration.
|
||||
*
|
||||
* This configuration sets up ADC channel with the following options:
|
||||
* - 10 bits resolution
|
||||
* - full scale input
|
||||
* - reference voltage: 1.2 V
|
||||
* - external reference input disabled
|
||||
*
|
||||
* @param[in] analog_input Analog input.
|
||||
*/
|
||||
#define NRFX_ADC_DEFAULT_CHANNEL(analog_input) \
|
||||
{ \
|
||||
NULL, \
|
||||
{ \
|
||||
{ \
|
||||
NULL, \
|
||||
{ \
|
||||
.resolution = NRF_ADC_CONFIG_RES_10BIT, \
|
||||
.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
|
||||
.reference = NRF_ADC_CONFIG_REF_VBG, \
|
||||
.input = (analog_input), \
|
||||
.input = (nrf_adc_config_input_t)analog_input, \
|
||||
.extref = NRF_ADC_CONFIG_EXTREFSEL_NONE \
|
||||
} \
|
||||
}
|
||||
} \
|
||||
}
|
||||
|
||||
/** @brief Forward declaration of the nrfx_adc_channel_t type. */
|
||||
typedef struct nrfx_adc_channel_s nrfx_adc_channel_t;
|
||||
@@ -112,9 +122,9 @@ typedef struct
|
||||
} nrfx_adc_config_t;
|
||||
|
||||
/** @brief ADC default configuration. */
|
||||
#define NRFX_ADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.interrupt_priority = NRFX_ADC_CONFIG_IRQ_PRIORITY \
|
||||
#define NRFX_ADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.interrupt_priority = NRFX_ADC_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,8 +216,8 @@ void nrfx_adc_sample(void);
|
||||
* @retval NRFX_SUCCESS Conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY The ADC driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
|
||||
nrf_adc_value_t * p_value);
|
||||
nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * p_channel,
|
||||
nrf_adc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for converting data to the buffer.
|
||||
@@ -256,16 +266,14 @@ bool nrfx_adc_is_busy(void);
|
||||
*
|
||||
* @return Start task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
|
||||
{
|
||||
return nrf_adc_task_address_get(NRF_ADC_TASK_START);
|
||||
return nrf_adc_task_address_get(NRF_ADC, NRF_ADC_TASK_START);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -50,10 +50,12 @@ extern "C" {
|
||||
/** @brief Clock events. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
|
||||
NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
|
||||
NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
|
||||
NRFX_CLOCK_EVT_CAL_DONE ///< Calibration has been done.
|
||||
NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
|
||||
NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
|
||||
NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
|
||||
NRFX_CLOCK_EVT_CAL_DONE, ///< Calibration has been done.
|
||||
NRFX_CLOCK_EVT_HFCLKAUDIO_STARTED, ///< HFCLKAUDIO has been started.
|
||||
NRFX_CLOCK_EVT_HFCLK192M_STARTED, ///< HFCLK192M has been started.
|
||||
} nrfx_clock_evt_type_t;
|
||||
|
||||
/**
|
||||
@@ -85,33 +87,136 @@ void nrfx_clock_disable(void);
|
||||
/** @brief Function for uninitializing the clock module. */
|
||||
void nrfx_clock_uninit(void);
|
||||
|
||||
/** @brief Function for starting the LFCLK. */
|
||||
void nrfx_clock_lfclk_start(void);
|
||||
/**
|
||||
* @brief Function for starting the specified clock domain.
|
||||
*
|
||||
* @param[in] domain Clock domain.
|
||||
*/
|
||||
void nrfx_clock_start(nrf_clock_domain_t domain);
|
||||
|
||||
/** @brief Function for stopping the LFCLK. */
|
||||
void nrfx_clock_lfclk_stop(void);
|
||||
/**
|
||||
* @brief Function for stopping the specified clock domain.
|
||||
*
|
||||
* @param[in] domain Clock domain.
|
||||
*/
|
||||
void nrfx_clock_stop(nrf_clock_domain_t domain);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the specified clock domain state.
|
||||
*
|
||||
* XTAL source is assumed for domains with multiple sources.
|
||||
*
|
||||
* @param[in] domain Clock domain.
|
||||
* @param[out] clk_src Clock source that is running. Set to NULL if not needed.
|
||||
* Ignored for HFCLKAUDIO domain. Typecast it to @ref nrf_clock_lfclk_t for
|
||||
* LFCLK and @ref nrf_clock_hfclk_t for HFCLK and HFCLK192M.
|
||||
*
|
||||
* @retval true The clock domain is running.
|
||||
* @retval false The clock domain is not running.
|
||||
*/
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_is_running(nrf_clock_domain_t domain, void * clk_src);
|
||||
|
||||
#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
|
||||
/**
|
||||
* @brief Function for setting the specified clock domain divider.
|
||||
*
|
||||
* @param[in] domain Clock domain.
|
||||
* @param[in] div New divider for the clock domain.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Divider successfully set.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED Domain does not support setting the divider.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Divider not supported by the specified domain.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_divider_set(nrf_clock_domain_t domain,
|
||||
nrf_clock_hfclk_div_t div);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified clock domain divider.
|
||||
*
|
||||
* @param[in] domain Clock domain.
|
||||
*
|
||||
* @return Current divider for the specified clock domain.
|
||||
*/
|
||||
|
||||
NRFX_STATIC_INLINE nrf_clock_hfclk_div_t nrfx_clock_divider_get(nrf_clock_domain_t domain);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for starting the LFCLK.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_start instead.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_clock_lfclk_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for stopping the LFCLK.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_stop instead.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_clock_lfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the LFCLK state.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_is_running instead.
|
||||
*
|
||||
* @retval true The LFCLK is running.
|
||||
* @retval false The LFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
|
||||
|
||||
/** @brief Function for starting the high-accuracy source HFCLK. */
|
||||
void nrfx_clock_hfclk_start(void);
|
||||
/**
|
||||
* @brief Function for starting the high-accuracy source HFCLK.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_start instead.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclk_start(void);
|
||||
|
||||
/** @brief Function for stopping the external high-accuracy source HFCLK. */
|
||||
void nrfx_clock_hfclk_stop(void);
|
||||
/**
|
||||
* @brief Function for stopping the external high-accuracy source HFCLK.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_stop instead.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the HFCLK state.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_clock_is_running instead.
|
||||
*
|
||||
* @retval true The HFCLK is running (XTAL source).
|
||||
* @retval false The HFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
|
||||
|
||||
|
||||
#if NRF_CLOCK_HAS_HFCLKAUDIO
|
||||
/**
|
||||
* @brief Function for setting the HFCLKAUDIO configuration.
|
||||
*
|
||||
* The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
|
||||
* To calculate @p freq_value corresponding to the chosen frequency, use the following equation:
|
||||
* FREQ_VALUE = 2^16 * ((12 * f_out / 32M) - 4)
|
||||
*
|
||||
* @warning Chosen frequency must fit in 11.176 MHz - 11.402 MHz or 12.165 MHz - 12.411 MHz
|
||||
* frequency bands.
|
||||
*
|
||||
* @param[in] freq_value New FREQ_VALUE for HFCLKAUDIO.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclkaudio_config_set(uint16_t freq_value);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the HFCLKAUDIO configuration.
|
||||
*
|
||||
* The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
|
||||
* To calculate frequency corresponding to the returned FREQ_VALUE, use the following equation:
|
||||
* f_out = 32M * (4 + FREQ_VALUE * 2^(-16))/12
|
||||
*
|
||||
* @return Current value of FREQ_VALUE for HFCLKAUDIO.
|
||||
*/
|
||||
NRFX_STATIC_INLINE uint16_t nrfx_clock_hfclkaudio_config_get(void);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for starting the calibration of internal LFCLK.
|
||||
@@ -151,7 +256,7 @@ void nrfx_clock_calibration_timer_stop(void);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
|
||||
|
||||
/**@brief Function for returning a requested event address for the clock driver module.
|
||||
*
|
||||
@@ -159,30 +264,92 @@ __STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
|
||||
#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
|
||||
NRFX_STATIC_INLINE nrf_clock_hfclk_div_t nrfx_clock_divider_get(nrf_clock_domain_t domain)
|
||||
{
|
||||
return nrf_clock_task_address_get(task);
|
||||
switch (domain)
|
||||
{
|
||||
#if NRF_CLOCK_HAS_HFCLK_DIV
|
||||
case NRF_CLOCK_DOMAIN_HFCLK:
|
||||
return nrf_clock_hfclk_div_get(NRF_CLOCK);
|
||||
#endif
|
||||
#if NRF_CLOCK_HAS_HFCLK192M
|
||||
case NRF_CLOCK_DOMAIN_HFCLK192M:
|
||||
return nrf_clock_hfclk192m_div_get(NRF_CLOCK);
|
||||
#endif
|
||||
default:
|
||||
NRFX_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_clock_lfclk_start(void)
|
||||
{
|
||||
nrfx_clock_start(NRF_CLOCK_DOMAIN_LFCLK);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
|
||||
NRFX_STATIC_INLINE void nrfx_clock_lfclk_stop(void)
|
||||
{
|
||||
return nrf_clock_event_address_get(event);
|
||||
nrfx_clock_stop(NRF_CLOCK_DOMAIN_LFCLK);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclk_start(void)
|
||||
{
|
||||
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
||||
nrfx_clock_start(NRF_CLOCK_DOMAIN_HFCLK);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclk_stop(void)
|
||||
{
|
||||
return nrf_clock_lf_is_running();
|
||||
nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLK);
|
||||
}
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
|
||||
{
|
||||
return nrf_clock_task_address_get(NRF_CLOCK, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
|
||||
{
|
||||
return nrf_clock_event_address_get(NRF_CLOCK, event);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_is_running(nrf_clock_domain_t domain, void * clk_src)
|
||||
{
|
||||
return nrf_clock_is_running(NRF_CLOCK, domain, clk_src);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
|
||||
{
|
||||
nrf_clock_hfclk_t clk_src;
|
||||
bool ret = nrfx_clock_is_running(NRF_CLOCK_DOMAIN_HFCLK, &clk_src);
|
||||
return (ret && (clk_src == NRF_CLOCK_HFCLK_HIGH_ACCURACY));
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
|
||||
{
|
||||
return nrfx_clock_is_running(NRF_CLOCK_DOMAIN_LFCLK, NULL);
|
||||
}
|
||||
|
||||
#if NRF_CLOCK_HAS_HFCLKAUDIO
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_clock_hfclkaudio_config_set(uint16_t freq_value)
|
||||
{
|
||||
nrf_clock_hfclkaudio_config_set(NRF_CLOCK, freq_value);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint16_t nrfx_clock_hfclkaudio_config_get(void)
|
||||
{
|
||||
return nrf_clock_hfclkaudio_config_get(NRF_CLOCK);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -104,31 +104,42 @@ typedef struct
|
||||
.th_up = NRFX_VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \
|
||||
}
|
||||
|
||||
/** @brief COMP driver default configuration including the COMP HAL configuration. */
|
||||
/**
|
||||
* @brief COMP driver default configuration.
|
||||
*
|
||||
* This configuration sets up COMP with the following options:
|
||||
* - single-ended mode
|
||||
* - reference voltage: internal 1.8 V
|
||||
* - lower threshold: 0.5 V
|
||||
* - upper threshold: 1.5 V
|
||||
* - high speed mode
|
||||
* - hysteresis disabled
|
||||
* - current source disabled
|
||||
*
|
||||
* @param[in] _input Analog input.
|
||||
*/
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.ext_ref = NRF_COMP_EXT_REF_0, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.isource = (nrf_isource_t)NRFX_COMP_CONFIG_ISOURCE, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = NRF_COMP_REF_Int1V8, \
|
||||
.main_mode = NRF_COMP_MAIN_MODE_SE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = NRF_COMP_SP_MODE_High, \
|
||||
.hyst = NRF_COMP_HYST_NoHyst, \
|
||||
.isource = NRF_COMP_ISOURCE_Off, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.ext_ref = NRF_COMP_EXT_REF_0, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = NRF_COMP_REF_Int1V8, \
|
||||
.main_mode = NRF_COMP_MAIN_MODE_SE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = NRF_COMP_SP_MODE_High, \
|
||||
.hyst = NRF_COMP_HYST_NoHyst, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -209,10 +220,7 @@ uint32_t nrfx_comp_sample(void);
|
||||
*
|
||||
* @return Address of the given COMP task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_comp_task_address_get(task);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a COMP event.
|
||||
@@ -221,11 +229,20 @@ __STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
|
||||
*
|
||||
* @return Address of the given COMP event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_comp_event_address_get(event);
|
||||
return nrf_comp_task_address_get(NRF_COMP, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
|
||||
{
|
||||
return nrf_comp_event_address_get(NRF_COMP, event);
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_EGU_H__
|
||||
#define NRFX_EGU_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_egu.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_egu EGU driver
|
||||
* @{
|
||||
* @ingroup nrf_egu
|
||||
*
|
||||
* @brief Event Generator Unit (EGU) peripheral driver.
|
||||
*/
|
||||
|
||||
/** @brief Structure for the EGU driver instance. */
|
||||
typedef struct
|
||||
{
|
||||
NRF_EGU_Type * p_reg; ///< Pointer to a structure with EGU registers.
|
||||
uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
|
||||
} nrfx_egu_t;
|
||||
|
||||
#ifndef __NRFX_DOXYGEN__
|
||||
enum {
|
||||
#if NRFX_CHECK(NRFX_EGU0_ENABLED)
|
||||
NRFX_EGU0_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_EGU1_ENABLED)
|
||||
NRFX_EGU1_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_EGU2_ENABLED)
|
||||
NRFX_EGU2_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_EGU3_ENABLED)
|
||||
NRFX_EGU3_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_EGU4_ENABLED)
|
||||
NRFX_EGU4_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_EGU5_ENABLED)
|
||||
NRFX_EGU5_INST_IDX,
|
||||
#endif
|
||||
NRFX_EGU_ENABLED_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
/** @brief Macro for creating an EGU driver instance. */
|
||||
#define NRFX_EGU_INSTANCE(id) \
|
||||
{ \
|
||||
.p_reg = NRFX_CONCAT_2(NRF_EGU, id), \
|
||||
.drv_inst_idx = NRFX_CONCAT_3(NRFX_EGU, id, _INST_IDX), \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief EGU driver event handler.
|
||||
*
|
||||
* @param[in] event_idx Index of the event that generated the interrupt.
|
||||
* @param[in] p_context Context passed to the event handler. Set on initialization.
|
||||
*/
|
||||
typedef void (*nrfx_egu_event_handler_t)(uint8_t event_idx, void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the EGU driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] interrupt_priority Interrupt priority.
|
||||
* @param[in] event_handler Event handler provided by the user. In case of providing NULL,
|
||||
* event notifications are not done and EGU interrupts are disabled.
|
||||
* @param[in] p_context Context passed to the event handler.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Driver is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_egu_init(nrfx_egu_t const * p_instance,
|
||||
uint8_t interrupt_priority,
|
||||
nrfx_egu_event_handler_t event_handler,
|
||||
void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts on specified events of a given EGU driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] mask Mask of events with interrupts to be enabled.
|
||||
*/
|
||||
void nrfx_egu_int_enable(nrfx_egu_t const * p_instance, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts on specified events of a given EGU driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] mask Mask of events with interrupts to be disabled.
|
||||
*/
|
||||
void nrfx_egu_int_disable(nrfx_egu_t const * p_instance, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering an event specified by @c event_idx of a given EGU driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] event_idx Index of the event to be triggered.
|
||||
*/
|
||||
void nrfx_egu_trigger(nrfx_egu_t const * p_instance, uint8_t event_idx);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the EGU driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_egu_uninit(nrfx_egu_t const * p_instance);
|
||||
|
||||
/** @} */
|
||||
|
||||
void nrfx_egu_0_irq_handler(void);
|
||||
void nrfx_egu_1_irq_handler(void);
|
||||
void nrfx_egu_2_irq_handler(void);
|
||||
void nrfx_egu_3_irq_handler(void);
|
||||
void nrfx_egu_4_irq_handler(void);
|
||||
void nrfx_egu_5_irq_handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_EGU_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -205,10 +205,12 @@ typedef void (*nrfx_gpiote_evt_handler_t)(nrfx_gpiote_pin_t pin, nrf_gpiote_pola
|
||||
* @details Only static configuration is supported to prevent the shared
|
||||
* resource being customized by the initiator.
|
||||
*
|
||||
* @param[in] interrupt_priority Interrupt priority.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_init(void);
|
||||
nrfx_err_t nrfx_gpiote_init(uint8_t interrupt_priority);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the GPIOTE module is initialized.
|
||||
@@ -234,9 +236,9 @@ void nrfx_gpiote_uninit(void);
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] p_config Initial configuration.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_BUSY The pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_out_config_t const * p_config);
|
||||
@@ -285,7 +287,19 @@ void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin);
|
||||
void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
* @brief Function for getting the OUT task for the specified output pin.
|
||||
*
|
||||
* @details The returned task identifier can be used within @ref nrf_gpiote_hal,
|
||||
* for example, to configure a DPPI channel.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return OUT task associated with the specified output pin.
|
||||
*/
|
||||
nrf_gpiote_task_t nrfx_gpiote_out_task_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the OUT task for the specified output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
@@ -295,7 +309,19 @@ uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
* @brief Function for getting the SET task for the specified output pin.
|
||||
*
|
||||
* @details The returned task identifier can be used within @ref nrf_gpiote_hal,
|
||||
* for example, to configure a DPPI channel.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return SET task associated with the specified output pin.
|
||||
*/
|
||||
nrf_gpiote_task_t nrfx_gpiote_set_task_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the SET task for the specified output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
@@ -306,7 +332,19 @@ uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
* @brief Function for getting the CLR task for the specified output pin.
|
||||
*
|
||||
* @details The returned task identifier can be used within @ref nrf_gpiote_hal,
|
||||
* for example, to configure a DPPI channel.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return CLR task associated with the specified output pin.
|
||||
*/
|
||||
nrf_gpiote_task_t nrfx_gpiote_clr_task_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the SET task for the specified output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
@@ -334,9 +372,9 @@ uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
* @param[in] p_config Initial configuration.
|
||||
* @param[in] evt_handler User function to be called when the configured transition occurs.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_BUSY The pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_in_config_t const * p_config,
|
||||
@@ -379,6 +417,20 @@ void nrfx_gpiote_in_event_disable(nrfx_gpiote_pin_t pin);
|
||||
*/
|
||||
bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the GPIOTE event for the specified input pin.
|
||||
*
|
||||
* @details The returned event identifier can be used within @ref nrf_gpiote_hal,
|
||||
* for example, to configure a DPPI channel.
|
||||
* If the pin is configured to use low-accuracy mode, the PORT event
|
||||
* is returned.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Event associated with the specified input pin.
|
||||
*/
|
||||
nrf_gpiote_event_t nrfx_gpiote_in_event_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a GPIOTE input pin event.
|
||||
* @details If the pin is configured to use low-accuracy mode, the address of the PORT event is returned.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,7 +46,6 @@ extern "C" {
|
||||
* @brief Inter-IC Sound (I2S) peripheral driver.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief This value can be provided instead of a pin number for the signals
|
||||
* SDOUT, SDIN, and MCK to specify that a given signal is not used
|
||||
@@ -70,13 +69,17 @@ typedef struct
|
||||
* if this signal is not needed. */
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
|
||||
nrf_i2s_mode_t mode; ///< Mode of operation.
|
||||
nrf_i2s_format_t format; ///< Frame format.
|
||||
nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
|
||||
nrf_i2s_swidth_t sample_width; ///< Sample width.
|
||||
nrf_i2s_channels_t channels; ///< Enabled channels.
|
||||
nrf_i2s_mck_t mck_setup; ///< Master clock setup.
|
||||
nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
|
||||
nrf_i2s_mode_t mode; ///< Mode of operation.
|
||||
nrf_i2s_format_t format; ///< Frame format.
|
||||
nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
|
||||
nrf_i2s_swidth_t sample_width; ///< Sample width.
|
||||
nrf_i2s_channels_t channels; ///< Enabled channels.
|
||||
nrf_i2s_mck_t mck_setup; ///< Master clock setup.
|
||||
nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
|
||||
#if NRF_I2S_HAS_CLKCONFIG
|
||||
nrf_i2s_clksrc_t clksrc; ///< Clock source selection.
|
||||
bool enable_bypass; ///< Bypass clock generator. MCK will be equal to source input.
|
||||
#endif
|
||||
} nrfx_i2s_config_t;
|
||||
|
||||
/** @brief I2S driver buffers structure. */
|
||||
@@ -86,32 +89,61 @@ typedef struct
|
||||
uint32_t const * p_tx_buffer; ///< Pointer to the buffer with data to be sent.
|
||||
} nrfx_i2s_buffers_t;
|
||||
|
||||
/** @brief I2S driver default configuration. */
|
||||
#define NRFX_I2S_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.sck_pin = NRFX_I2S_CONFIG_SCK_PIN, \
|
||||
.lrck_pin = NRFX_I2S_CONFIG_LRCK_PIN, \
|
||||
.mck_pin = NRFX_I2S_CONFIG_MCK_PIN, \
|
||||
.sdout_pin = NRFX_I2S_CONFIG_SDOUT_PIN, \
|
||||
.sdin_pin = NRFX_I2S_CONFIG_SDIN_PIN, \
|
||||
.irq_priority = NRFX_I2S_CONFIG_IRQ_PRIORITY, \
|
||||
.mode = (nrf_i2s_mode_t)NRFX_I2S_CONFIG_MASTER, \
|
||||
.format = (nrf_i2s_format_t)NRFX_I2S_CONFIG_FORMAT, \
|
||||
.alignment = (nrf_i2s_align_t)NRFX_I2S_CONFIG_ALIGN, \
|
||||
.sample_width = (nrf_i2s_swidth_t)NRFX_I2S_CONFIG_SWIDTH, \
|
||||
.channels = (nrf_i2s_channels_t)NRFX_I2S_CONFIG_CHANNELS, \
|
||||
.mck_setup = (nrf_i2s_mck_t)NRFX_I2S_CONFIG_MCK_SETUP, \
|
||||
.ratio = (nrf_i2s_ratio_t)NRFX_I2S_CONFIG_RATIO, \
|
||||
#if NRF_I2S_HAS_CLKCONFIG || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief I2S additional clock source configuration. */
|
||||
#define NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG \
|
||||
.clksrc = NRF_I2S_CLKSRC_PCLK32M, \
|
||||
.enable_bypass = false,
|
||||
#else
|
||||
#define NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG
|
||||
#endif
|
||||
/**
|
||||
* @brief I2S driver default configuration.
|
||||
*
|
||||
* This configuration sets up I2S with the following options:
|
||||
* - master mode
|
||||
* - i2s data format
|
||||
* - left alignment
|
||||
* - sample width 16 bit
|
||||
* - left channel enabled
|
||||
* - MCK frequency 4 MHz
|
||||
* - LRCK frequency 125 kHz
|
||||
*
|
||||
* @param[in] _pin_sck SCK pin number.
|
||||
* @param[in] _pin_lrck LRCK pin number.
|
||||
* @param[in] _pin_mck MCK pin number.
|
||||
* @param[in] _pin_sdout SDOUT pin number.
|
||||
* @param[in] _pin_sdin SDIN pin number.
|
||||
*/
|
||||
#define NRFX_I2S_DEFAULT_CONFIG(_pin_sck, _pin_lrck, _pin_mck, _pin_sdout, _pin_sdin) \
|
||||
{ \
|
||||
.sck_pin = _pin_sck, \
|
||||
.lrck_pin = _pin_lrck, \
|
||||
.mck_pin = _pin_mck, \
|
||||
.sdout_pin = _pin_sdout, \
|
||||
.sdin_pin = _pin_sdin, \
|
||||
.irq_priority = NRFX_I2S_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.mode = NRF_I2S_MODE_MASTER, \
|
||||
.format = NRF_I2S_FORMAT_I2S, \
|
||||
.alignment = NRF_I2S_ALIGN_LEFT, \
|
||||
.sample_width = NRF_I2S_SWIDTH_16BIT, \
|
||||
.channels = NRF_I2S_CHANNELS_LEFT, \
|
||||
.mck_setup = NRF_I2S_MCK_32MDIV8, \
|
||||
.ratio = NRF_I2S_RATIO_32X, \
|
||||
NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG \
|
||||
}
|
||||
|
||||
|
||||
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
|
||||
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
|
||||
/**< The application must provide buffers that are to be used in the next
|
||||
* part of the transfer. A call to @ref nrfx_i2s_next_buffers_set must
|
||||
* be done before the currently used buffers are completely processed
|
||||
* (that is, the time remaining for supplying the next buffers depends on
|
||||
* the used size of the buffers). */
|
||||
|
||||
#define NRFX_I2S_STATUS_TRANSFER_STOPPED (1UL << 1)
|
||||
/**< The I2S peripheral has been stopped and all buffers that were passed
|
||||
* to the driver have been released. */
|
||||
|
||||
/**
|
||||
* @brief I2S driver data handler type.
|
||||
*
|
||||
@@ -140,19 +172,26 @@ typedef struct
|
||||
* Both pointers in this structure are NULL when the
|
||||
* handler is called for the first time after a transfer
|
||||
* is started, because no data has been transferred yet
|
||||
* at this point. In all successive calls the pointers
|
||||
* at this point. In all successive calls, the pointers
|
||||
* specify what has been sent (TX) and what has been
|
||||
* received (RX) in the part of transfer that has just
|
||||
* been completed (provided that a given direction is
|
||||
* enabled, see @ref nrfx_i2s_start).
|
||||
* received (RX) in the part of the transfer that has
|
||||
* just been completed (provided that a given direction
|
||||
* is enabled, see @ref nrfx_i2s_start).
|
||||
* @note Since the peripheral is stopped asynchronously,
|
||||
* buffers that are released after the call to
|
||||
* @ref nrfx_i2s_stop are not used entirely.
|
||||
* In this case, only a part (if any) of the TX
|
||||
* buffer has been actually transmitted and only
|
||||
* a part (if any) of the RX buffer is filled with
|
||||
* received data.
|
||||
* @param[in] status Bit field describing the current status of the transfer.
|
||||
* It can be 0 or a combination of the following flags:
|
||||
* - @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED
|
||||
* - @ref NRFX_I2S_STATUS_TRANSFER_STOPPED
|
||||
*/
|
||||
typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
|
||||
uint32_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the I2S driver.
|
||||
*
|
||||
@@ -184,7 +223,7 @@ void nrfx_i2s_uninit(void);
|
||||
* word can either contain four 8-bit samples, two 16-bit samples, or one
|
||||
* right-aligned 24-bit sample sign-extended to a 32-bit value.
|
||||
* For a detailed memory mapping for different supported configurations,
|
||||
* see the @linkProductSpecification52.
|
||||
* see the Product Specification.
|
||||
*
|
||||
* @note Peripherals using EasyDMA (including I2S) require the transfer buffers
|
||||
* to be placed in the Data RAM region. If this condition is not met,
|
||||
@@ -219,11 +258,14 @@ nrfx_err_t nrfx_i2s_start(nrfx_i2s_buffers_t const * p_initial_buffers,
|
||||
* but it has to be done before the I2S peripheral finishes processing the
|
||||
* buffers supplied previously. Otherwise, data corruption will occur.
|
||||
*
|
||||
* @sa nrfx_i2s_data_handler_t
|
||||
* @param[in] p_buffers Pointer to a structure specifying the buffers
|
||||
* to be used in the upcoming part of the transfer.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the operation was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the buffers were already supplied or
|
||||
* the peripheral is currently being stopped.
|
||||
*
|
||||
* @sa nrfx_i2s_data_handler_t
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_next_buffers_set(nrfx_i2s_buffers_t const * p_buffers);
|
||||
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef NRFX_IPC_H__
|
||||
#define NRFX_IPC_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_ipc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_ipc IPC driver
|
||||
* @{
|
||||
* @ingroup nrf_ipc
|
||||
* @brief Interprocessor Communication (IPC) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief IPC driver handler type.
|
||||
*
|
||||
* @param[in] event_mask Bitmask with events that triggered the interrupt.
|
||||
* @param[in] p_context Context passed to the interrupt handler, set on initialization.
|
||||
*/
|
||||
typedef void (*nrfx_ipc_handler_t)(uint32_t event_mask, void * p_context);
|
||||
|
||||
/** @brief IPC configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t send_task_config[IPC_CONF_NUM]; ///< Configuration of the connection between signals and IPC channels.
|
||||
uint32_t receive_event_config[IPC_CONF_NUM]; ///< Configuration of the connection between events and IPC channels.
|
||||
uint32_t receive_events_enabled; ///< Bitmask with events to be enabled to generate interrupt.
|
||||
} nrfx_ipc_config_t;
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the IPC driver.
|
||||
*
|
||||
* @param irq_priority Interrupt priority.
|
||||
* @param handler Event handler provided by the user. Cannot be NULL.
|
||||
* @param p_context Context passed to event handler.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Driver is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_ipc_init(uint8_t irq_priority, nrfx_ipc_handler_t handler, void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for loading configuration directly into IPC peripheral.
|
||||
*
|
||||
* @param p_config Pointer to the structure with the initial configuration.
|
||||
*/
|
||||
void nrfx_ipc_config_load(nrfx_ipc_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for convey signal on configured channels.
|
||||
*
|
||||
* Events connected to the IPC channels configured within this signal will
|
||||
* be set and can generate interrupts when configured.
|
||||
*
|
||||
* @param send_index Index of the SEND task to trigger.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_signal(uint8_t send_index);
|
||||
|
||||
/**
|
||||
* @brief Function for storing data in GPMEM register in the IPC peripheral.
|
||||
*
|
||||
* @param mem_index Index of the memory cell.
|
||||
* @param data Data to be saved.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_gpmem_set(uint8_t mem_index, uint32_t data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting data from the GPMEM register in the IPC peripheral.
|
||||
*
|
||||
* @param mem_index Index of the memory cell.
|
||||
*
|
||||
* @return Saved data.
|
||||
*/
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ipc_mem_get(uint8_t mem_index);
|
||||
|
||||
/** @brief Function for uninitializing the IPC module. */
|
||||
void nrfx_ipc_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling events to generate interrupt.
|
||||
*
|
||||
* @param event_index Index of event to be enabled.
|
||||
*/
|
||||
void nrfx_ipc_receive_event_enable(uint8_t event_index);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling events from generate interrupt.
|
||||
*
|
||||
* @param event_index Index of event to be disabled.
|
||||
*/
|
||||
void nrfx_ipc_receive_event_disable(uint8_t event_index);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling set of events to generate interrupt.
|
||||
*
|
||||
* @param event_bitmask Bitmask with events to be enabled.
|
||||
*/
|
||||
void nrfx_ipc_receive_event_group_enable(uint32_t event_bitmask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling set of events from generate interrupt.
|
||||
*
|
||||
* @param event_bitmask Bitmask with events to be disabled.
|
||||
*/
|
||||
void nrfx_ipc_receive_event_group_disable(uint32_t event_bitmask);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning event to the IPC channel.
|
||||
*
|
||||
* @param event_index Index of the event to be configured.
|
||||
* @param channel_index Index of the channel to which event will be connected.
|
||||
*/
|
||||
void nrfx_ipc_receive_event_channel_assign(uint8_t event_index, uint8_t channel_index);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning signal to the IPC channel.
|
||||
*
|
||||
* @param send_index Index of the signal to be configured.
|
||||
* @param channel_index Index of the instance of channel.
|
||||
*/
|
||||
void nrfx_ipc_send_task_channel_assign(uint8_t send_index, uint8_t channel_index);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning event to the IPC channels.
|
||||
*
|
||||
* @param event_index Index of the event to be configured.
|
||||
* @param channel_bitmask Bitmask with channels to which event will be connected.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_receive_config_set(uint8_t event_index, uint32_t channel_bitmask);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning signal to the IPC channels.
|
||||
*
|
||||
* @param send_index Index of the signal to be configured.
|
||||
* @param channel_bitmask Bitmask with channels to which signal will be connected.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_send_config_set(uint8_t send_index, uint32_t channel_bitmask);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_gpmem_set(uint8_t mem_index, uint32_t data)
|
||||
{
|
||||
NRFX_ASSERT(mem_index < NRFX_ARRAY_SIZE(NRF_IPC->GPMEM));
|
||||
nrf_ipc_gpmem_set(NRF_IPC, mem_index, data);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ipc_mem_get(uint8_t mem_index)
|
||||
{
|
||||
NRFX_ASSERT(mem_index < NRFX_ARRAY_SIZE(NRF_IPC->GPMEM));
|
||||
return nrf_ipc_gpmem_get(NRF_IPC, mem_index);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_signal(uint8_t send_index)
|
||||
{
|
||||
NRFX_ASSERT(send_index < IPC_CONF_NUM);
|
||||
nrf_ipc_task_trigger(NRF_IPC, nrf_ipc_send_task_get(send_index));
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_receive_config_set(uint8_t event_index, uint32_t channel_bitmask)
|
||||
{
|
||||
NRFX_ASSERT(event_index < IPC_CONF_NUM);
|
||||
nrf_ipc_receive_config_set(NRF_IPC, event_index, channel_bitmask);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_ipc_send_config_set(uint8_t send_index, uint32_t channel_bitmask)
|
||||
{
|
||||
NRFX_ASSERT(send_index < IPC_CONF_NUM);
|
||||
nrf_ipc_send_config_set(NRF_IPC, send_index, channel_bitmask);
|
||||
}
|
||||
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
|
||||
void nrfx_ipc_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_IPC_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -60,23 +60,32 @@ typedef struct
|
||||
uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */
|
||||
} nrfx_lpcomp_config_t;
|
||||
|
||||
/** @brief LPCOMP driver default configuration, including the LPCOMP HAL configuration. */
|
||||
#ifdef NRF52_SERIES
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION, \
|
||||
(nrf_lpcomp_hysteresis_t)NRFX_LPCOMP_CONFIG_HYST }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
/**
|
||||
* @brief LPCOMP driver default configuration.
|
||||
*
|
||||
* This configuration sets up LPCOMP with the following options:
|
||||
* - reference voltage: 4/8 of supply voltage
|
||||
* - detection of both up and down crossings
|
||||
* - hysteresis disabled
|
||||
*
|
||||
* @param[in] _input Comparator input pin.
|
||||
*/
|
||||
#if defined(LPCOMP_FEATURE_HYST_PRESENT)
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.hal = { NRF_LPCOMP_REF_SUPPLY_4_8, \
|
||||
NRF_LPCOMP_DETECT_CROSS, \
|
||||
NRF_LPCOMP_HYST_NOHYST }, \
|
||||
.input = _input, \
|
||||
.interrupt_priority = NRFX_LPCOMP_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.hal = { NRF_LPCOMP_REF_SUPPLY_4_8, \
|
||||
NRF_LPCOMP_DETECT_CROSS }, \
|
||||
.input = _input, \
|
||||
.interrupt_priority = NRFX_LPCOMP_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -116,9 +116,9 @@ typedef struct
|
||||
nrfx_nfct_param_id_t id; ///< Type of parameter.
|
||||
union
|
||||
{
|
||||
uint32_t fdt; ///< NFC-A Frame Delay Time. Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_FDT.
|
||||
uint8_t sel_res_protocol; ///< NFC-A value of the 'Protocol' field in the SEL_RES frame. Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_SEL_RES.
|
||||
nrfx_nfct_nfcid1_t nfcid1; ///< NFC-A NFCID1 value (tag identifier). Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_NFCID1.
|
||||
uint32_t fdt; ///< NFC-A Frame Delay Time. Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_FDT.
|
||||
uint8_t sel_res_protocol; ///< NFC-A value of the 'Protocol' field in the SEL_RES frame. Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_SEL_RES.
|
||||
nrfx_nfct_nfcid1_t nfcid1; ///< NFC-A NFCID1 value (tag identifier). Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_NFCID1.
|
||||
} data; ///< Union to store parameter data.
|
||||
} nrfx_nfct_param_t;
|
||||
|
||||
@@ -154,9 +154,9 @@ typedef struct
|
||||
nrfx_nfct_evt_id_t evt_id; ///< Type of event.
|
||||
union
|
||||
{
|
||||
nrfx_nfct_evt_rx_frameend_t rx_frameend; ///< End of the RX frame data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_RX_FRAMEEND.
|
||||
nrfx_nfct_evt_tx_framestart_t tx_framestart; ///< Start of the TX frame data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_TX_FRAMESTART.
|
||||
nrfx_nfct_evt_error_t error; ///< Error data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_ERROR.
|
||||
nrfx_nfct_evt_rx_frameend_t rx_frameend; ///< End of the RX frame data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_RX_FRAMEEND.
|
||||
nrfx_nfct_evt_tx_framestart_t tx_framestart; ///< Start of the TX frame data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_TX_FRAMESTART.
|
||||
nrfx_nfct_evt_error_t error; ///< Error data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_ERROR.
|
||||
} params; ///< Union to store event data.
|
||||
} nrfx_nfct_evt_t;
|
||||
|
||||
@@ -320,22 +320,13 @@ void nrfx_nfct_irq_handler(void);
|
||||
* To implement the second workaround, power reset is used to release the clock acquired by NFCT
|
||||
* after the field is turned off. Note that the NFCT register configuration is restored to defaults.
|
||||
*
|
||||
* If you are using the nRF52840 chip, rev. Engineering A, the workarounds for the following anomalies
|
||||
* are applied:
|
||||
* - 98. NFCT: The NFCT is not able to communicate with the peer.
|
||||
* - 116. NFCT does not release HFCLK when switching from ACTIVATED to SENSE mode.
|
||||
* - 144. NFCT: Not optimal NFC performance
|
||||
*
|
||||
* If you are using the nRF52840 chip, rev. 1, or rev. Engineering B or C, the workarounds for the following
|
||||
* If you are using the nRF52833, nRF52840 or nRF5340 chips, the workarounds for the following
|
||||
* anomalies are applied:
|
||||
* - 190. NFCT: Event FIELDDETECTED can be generated too early.
|
||||
* To implement this workaround, an instance of NRF_TIMER is used. After the NFC field is detected,
|
||||
* the timing module measures the necessary waiting period after which NFCT can be activated.
|
||||
* This debouncing technique is used to filter possible field instabilities.
|
||||
*
|
||||
* The application of the implemented workarounds for the nRF52840 chip is determined at runtime and depends
|
||||
* on the chip variant.
|
||||
*
|
||||
* The current code contains a patch for the anomaly 25 (NFCT: Reset value of
|
||||
* SENSRES register is incorrect), so that the module now works on Windows Phone.
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_NVMC_H__
|
||||
#define NRFX_NVMC_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_nvmc.h>
|
||||
#include <hal/nrf_ficr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_nvmc NVMC driver
|
||||
* @{
|
||||
* @ingroup nrf_nvmc
|
||||
* @brief Non-Volatile Memory Controller (NVMC) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function for erasing a page in flash.
|
||||
*
|
||||
* This function blocks until the erase operation finishes.
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @param address Address of the first word in the page to erase.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Page erase complete.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR Address is not aligned to the size of the page.
|
||||
*/
|
||||
nrfx_err_t nrfx_nvmc_page_erase(uint32_t address);
|
||||
|
||||
/**
|
||||
* @brief Function for erasing the user information configuration register (UICR).
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @retval NRFX_SUCCESS UICR has been successfully erased.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED UICR erase is not supported.
|
||||
*/
|
||||
nrfx_err_t nrfx_nvmc_uicr_erase(void);
|
||||
|
||||
/**
|
||||
* @brief Function for erasing the whole flash memory.
|
||||
*
|
||||
* @note All user code and UICR will be erased.
|
||||
*/
|
||||
void nrfx_nvmc_all_erase(void);
|
||||
|
||||
#if defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
/**
|
||||
* @brief Function for initiating a complete page erase split into parts (also known as partial erase).
|
||||
*
|
||||
* This function initiates a partial erase with the specified duration.
|
||||
* To execute each part of the partial erase, use @ref nrfx_nvmc_page_partial_erase_continue.
|
||||
*
|
||||
* @param address Address of the first word in the page to erase.
|
||||
* @param duration_ms Time in milliseconds that each partial erase will take.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Partial erase started.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR Address is not aligned to the size of the page.
|
||||
*
|
||||
* @sa nrfx_nvmc_page_partial_erase_continue()
|
||||
*/
|
||||
nrfx_err_t nrfx_nvmc_page_partial_erase_init(uint32_t address, uint32_t duration_ms);
|
||||
|
||||
/**
|
||||
* @brief Function for performing a part of the complete page erase (also known as partial erase).
|
||||
*
|
||||
* This function must be called several times to erase the whole page, once for each erase part.
|
||||
*
|
||||
* @note The actual time needed to perform each part of the page erase is longer than the partial
|
||||
* erase duration specified in the call to @ref nrfx_nvmc_page_partial_erase_init,
|
||||
* since the NVMC peripheral needs certain additional amount of time to handle the process.
|
||||
* For details regarding this additional time, see the "Electrical specification" section
|
||||
* for the NVMC peripheral in the Product Specification.
|
||||
*
|
||||
* @note Using a page that was not completely erased leads to undefined behavior.
|
||||
* Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @retval true Partial erase finished.
|
||||
* @retval false Partial erase not finished.
|
||||
* Call the function again to process the next part.
|
||||
*/
|
||||
bool nrfx_nvmc_page_partial_erase_continue(void);
|
||||
|
||||
#endif // defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
|
||||
/**
|
||||
* @brief Function for checking whether a byte is writable at the specified address.
|
||||
*
|
||||
* The NVMC is only able to write '0' to bits in the flash that are erased (set to '1').
|
||||
* It cannot rewrite a bit back to '1'. This function checks if the value currently
|
||||
* residing at the specified address can be transformed to the desired value
|
||||
* without any '0' to '1' transitions.
|
||||
*
|
||||
* @param address Address to be checked.
|
||||
* @param value Value to be checked.
|
||||
*
|
||||
* @retval true Byte can be written at the specified address.
|
||||
* @retval false Byte cannot be written at the specified address.
|
||||
* Erase the page or change the address.
|
||||
*/
|
||||
bool nrfx_nvmc_byte_writable_check(uint32_t address, uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for writing a single byte to flash.
|
||||
*
|
||||
* To determine if the flash write has been completed, use @ref nrfx_nvmc_write_done_check().
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param value Value to write.
|
||||
*/
|
||||
void nrfx_nvmc_byte_write(uint32_t address, uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for checking whether a word is writable at the specified address.
|
||||
*
|
||||
* The NVMC is only able to write '0' to bits in the Flash that are erased (set to '1').
|
||||
* It cannot rewrite a bit back to '1'. This function checks if the value currently
|
||||
* residing at the specified address can be transformed to the desired value
|
||||
* without any '0' to '1' transitions.
|
||||
*
|
||||
* @param address Address to be checked. Must be word-aligned.
|
||||
* @param value Value to be checked.
|
||||
*
|
||||
* @retval true Word can be written at the specified address.
|
||||
* @retval false Word cannot be written at the specified address.
|
||||
* Erase page or change address.
|
||||
*/
|
||||
bool nrfx_nvmc_word_writable_check(uint32_t address, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for writing a 32-bit word to flash.
|
||||
*
|
||||
* To determine if the flash write has been completed, use @ref nrfx_nvmc_write_done_check().
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @param address Address to write to. Must be word-aligned.
|
||||
* @param value Value to write.
|
||||
*/
|
||||
void nrfx_nvmc_word_write(uint32_t address, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for writing consecutive bytes to flash.
|
||||
*
|
||||
* To determine if the last flash write has been completed, use @ref nrfx_nvmc_write_done_check().
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param src Pointer to the data to copy from.
|
||||
* @param num_bytes Number of bytes to write.
|
||||
*/
|
||||
void nrfx_nvmc_bytes_write(uint32_t address, void const * src, uint32_t num_bytes);
|
||||
|
||||
/**
|
||||
* @brief Function for writing consecutive words to flash.
|
||||
*
|
||||
* To determine if the last flash write has been completed, use @ref nrfx_nvmc_write_done_check().
|
||||
*
|
||||
* @note Depending on the source of the code being executed,
|
||||
* the CPU may be halted during the operation.
|
||||
* Refer to the Product Specification for more information.
|
||||
*
|
||||
* @param address Address to write to. Must be word-aligned.
|
||||
* @param src Pointer to data to copy from. Must be word-aligned.
|
||||
* @param num_words Number of words to write.
|
||||
*/
|
||||
void nrfx_nvmc_words_write(uint32_t address, void const * src, uint32_t num_words);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the total flash size in bytes.
|
||||
*
|
||||
* @return Flash total size in bytes.
|
||||
*/
|
||||
uint32_t nrfx_nvmc_flash_size_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the flash page size in bytes.
|
||||
*
|
||||
* @return Flash page size in bytes.
|
||||
*/
|
||||
uint32_t nrfx_nvmc_flash_page_size_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the flash page count.
|
||||
*
|
||||
* @return Flash page count.
|
||||
*/
|
||||
uint32_t nrfx_nvmc_flash_page_count_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the last flash write has been completed.
|
||||
*
|
||||
* @retval true Last write completed successfully.
|
||||
* @retval false Last write is still in progress.
|
||||
*/
|
||||
NRFX_STATIC_INLINE bool nrfx_nvmc_write_done_check(void);
|
||||
|
||||
#if defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
/**
|
||||
* @brief Function for enabling the Instruction Cache (ICache).
|
||||
*
|
||||
* Enabling ICache reduces the amount of accesses to flash memory,
|
||||
* which can boost performance and lower power consumption.
|
||||
*/
|
||||
NRFX_STATIC_INLINE void nrfx_nvmc_icache_enable(void);
|
||||
|
||||
/** @brief Function for disabling ICache. */
|
||||
NRFX_STATIC_INLINE void nrfx_nvmc_icache_disable(void);
|
||||
|
||||
#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE bool nrfx_nvmc_write_done_check(void)
|
||||
{
|
||||
return nrf_nvmc_ready_check(NRF_NVMC);
|
||||
}
|
||||
|
||||
#if defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
NRFX_STATIC_INLINE void nrfx_nvmc_icache_enable(void)
|
||||
{
|
||||
nrf_nvmc_icache_config_set(NRF_NVMC, NRF_NVMC_ICACHE_ENABLE_WITH_PROFILING);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE void nrfx_nvmc_icache_disable(void)
|
||||
{
|
||||
nrf_nvmc_icache_config_set(NRF_NVMC, NRF_NVMC_ICACHE_DISABLE);
|
||||
}
|
||||
#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_NVMC_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -67,33 +67,63 @@ typedef struct
|
||||
/** @brief PDM interface driver configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_pdm_mode_t mode; ///< Interface operation mode.
|
||||
nrf_pdm_edge_t edge; ///< Sampling mode.
|
||||
uint8_t pin_clk; ///< CLK pin.
|
||||
uint8_t pin_din; ///< DIN pin.
|
||||
nrf_pdm_freq_t clock_freq; ///< Clock frequency.
|
||||
nrf_pdm_gain_t gain_l; ///< Left channel gain.
|
||||
nrf_pdm_gain_t gain_r; ///< Right channel gain.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
nrf_pdm_mode_t mode; ///< Interface operation mode.
|
||||
nrf_pdm_edge_t edge; ///< Sampling mode.
|
||||
uint8_t pin_clk; ///< CLK pin.
|
||||
uint8_t pin_din; ///< DIN pin.
|
||||
nrf_pdm_freq_t clock_freq; ///< Clock frequency.
|
||||
nrf_pdm_gain_t gain_l; ///< Left channel gain.
|
||||
nrf_pdm_gain_t gain_r; ///< Right channel gain.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
#if NRF_PDM_HAS_RATIO_CONFIG
|
||||
nrf_pdm_ratio_t ratio; ///< Ratio between PDM_CLK and output sample rate.
|
||||
#endif
|
||||
#if NRF_PDM_HAS_MCLKCONFIG
|
||||
nrf_pdm_mclksrc_t mclksrc; ///< Master clock source selection.
|
||||
#endif
|
||||
} nrfx_pdm_config_t;
|
||||
|
||||
|
||||
#if NRF_PDM_HAS_RATIO_CONFIG || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief PDM additional ratio configuration. */
|
||||
#define NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG \
|
||||
.ratio = NRF_PDM_RATIO_64X,
|
||||
#else
|
||||
#define NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG
|
||||
#endif
|
||||
|
||||
#if NRF_PDM_HAS_MCLKCONFIG || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief PDM additional master clock source configuration. */
|
||||
#define NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG \
|
||||
.mclksrc = NRF_PDM_MCLKSRC_PCLK32M,
|
||||
#else
|
||||
#define NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrfx_pdm_config_t to default settings
|
||||
* in the single-ended mode.
|
||||
* @brief PDM driver default configuration.
|
||||
*
|
||||
* @param _pin_clk CLK output pin.
|
||||
* @param _pin_din DIN input pin.
|
||||
* This configuration sets up PDM with the following options:
|
||||
* - mono mode
|
||||
* - data sampled on the clock falling edge
|
||||
* - frequency: 1.032 MHz
|
||||
* - standard gain
|
||||
*
|
||||
* @param[in] _pin_clk CLK output pin.
|
||||
* @param[in] _pin_din DIN input pin.
|
||||
*/
|
||||
#define NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din) \
|
||||
{ \
|
||||
.mode = (nrf_pdm_mode_t)NRFX_PDM_CONFIG_MODE, \
|
||||
.edge = (nrf_pdm_edge_t)NRFX_PDM_CONFIG_EDGE, \
|
||||
.pin_clk = _pin_clk, \
|
||||
.pin_din = _pin_din, \
|
||||
.clock_freq = (nrf_pdm_freq_t)NRFX_PDM_CONFIG_CLOCK_FREQ, \
|
||||
.gain_l = NRF_PDM_GAIN_DEFAULT, \
|
||||
.gain_r = NRF_PDM_GAIN_DEFAULT, \
|
||||
.interrupt_priority = NRFX_PDM_CONFIG_IRQ_PRIORITY \
|
||||
#define NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din) \
|
||||
{ \
|
||||
.mode = NRF_PDM_MODE_MONO, \
|
||||
.edge = NRF_PDM_EDGE_LEFTFALLING, \
|
||||
.pin_clk = _pin_clk, \
|
||||
.pin_din = _pin_din, \
|
||||
.clock_freq = NRF_PDM_FREQ_1032K, \
|
||||
.gain_l = NRF_PDM_GAIN_DEFAULT, \
|
||||
.gain_r = NRF_PDM_GAIN_DEFAULT, \
|
||||
.interrupt_priority = NRFX_PDM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG \
|
||||
NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +134,7 @@ typedef struct
|
||||
*
|
||||
* @param[in] p_evt Pointer to the PDM event structure.
|
||||
*/
|
||||
typedef void (*nrfx_pdm_event_handler_t)(nrfx_pdm_evt_t const * const p_evt);
|
||||
typedef void (*nrfx_pdm_event_handler_t)(nrfx_pdm_evt_t const * p_evt);
|
||||
|
||||
|
||||
/**
|
||||
@@ -134,10 +164,7 @@ void nrfx_pdm_uninit(void);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
|
||||
{
|
||||
return nrf_pdm_task_address_get(task);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the PDM interface.
|
||||
@@ -145,10 +172,7 @@ __STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
|
||||
* @retval true The PDM interface is enabled.
|
||||
* @retval false The PDM interface is disabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_pdm_enable_check(void)
|
||||
{
|
||||
return nrf_pdm_enable_check();
|
||||
}
|
||||
NRFX_STATIC_INLINE bool nrfx_pdm_enable_check(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the PDM sampling.
|
||||
@@ -185,6 +209,18 @@ nrfx_err_t nrfx_pdm_stop(void);
|
||||
*/
|
||||
nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
|
||||
{
|
||||
return nrf_pdm_task_address_get(NRF_PDM0, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE bool nrfx_pdm_enable_check(void)
|
||||
{
|
||||
return nrf_pdm_enable_check(NRF_PDM0);
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_power.h>
|
||||
#include <nrfx_power_clock.h>
|
||||
#include "nrfx_power_compat.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -47,6 +48,29 @@ extern "C" {
|
||||
* @brief POWER peripheral driver.
|
||||
*/
|
||||
|
||||
#if NRF_POWER_HAS_POFCON || NRFX_CHECK(NRF_REGULATORS_HAS_POFCON) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether the power failure comparator is supported. */
|
||||
#define NRFX_POWER_SUPPORTS_POFCON 1
|
||||
#else
|
||||
#define NRFX_POWER_SUPPORTS_POFCON 0
|
||||
#endif
|
||||
|
||||
#if NRF_POWER_HAS_POFCON_VDDH || NRFX_CHECK(NRF_REGULATORS_HAS_POFCON_VDDH) || \
|
||||
defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether the power failure comparator for VDDH is supported. */
|
||||
#define NRFX_POWER_SUPPORTS_POFCON_VDDH 1
|
||||
#else
|
||||
#define NRFX_POWER_SUPPORTS_POFCON_VDDH 0
|
||||
#endif
|
||||
|
||||
#if NRF_POWER_HAS_DCDCEN_VDDH || NRFX_CHECK(NRF_REGULATORS_HAS_DCDCEN_VDDH) || \
|
||||
defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether the VDDH regulator is supported. */
|
||||
#define NRFX_POWER_SUPPORTS_DCDCEN_VDDH 1
|
||||
#else
|
||||
#define NRFX_POWER_SUPPORTS_DCDCEN_VDDH 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Power mode possible configurations
|
||||
*/
|
||||
@@ -96,7 +120,7 @@ typedef enum
|
||||
NRFX_POWER_USB_STATE_CONNECTED, /**< The USB power is detected, but USB power regulator is not ready. */
|
||||
NRFX_POWER_USB_STATE_READY /**< From the power viewpoint, USB is ready for working. */
|
||||
}nrfx_power_usb_state_t;
|
||||
#endif /* NRF_POWER_HAS_USBREG */
|
||||
#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @name Callback types
|
||||
@@ -145,7 +169,7 @@ typedef struct
|
||||
*/
|
||||
bool dcdcen:1;
|
||||
|
||||
#if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
|
||||
#if NRFX_POWER_SUPPORTS_DCDCEN_VDDH
|
||||
/**
|
||||
* @brief Enable HV DCDC regulator.
|
||||
*
|
||||
@@ -166,10 +190,10 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
nrfx_power_pofwarn_event_handler_t handler; //!< Event handler.
|
||||
#if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
|
||||
#if NRFX_POWER_SUPPORTS_POFCON
|
||||
nrf_power_pof_thr_t thr; //!< Threshold for power failure detection
|
||||
#endif
|
||||
#if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
|
||||
#if NRFX_POWER_SUPPORTS_POFCON_VDDH
|
||||
nrf_power_pof_thrvddh_t thrvddh; //!< Threshold for power failure detection on the VDDH pin.
|
||||
#endif
|
||||
}nrfx_power_pofwarn_config_t;
|
||||
@@ -198,7 +222,7 @@ typedef struct
|
||||
{
|
||||
nrfx_power_usb_event_handler_t handler; //!< Event processing.
|
||||
}nrfx_power_usbevt_config_t;
|
||||
#endif /* NRF_POWER_HAS_USBREG */
|
||||
#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for getting the handler of the power failure comparator.
|
||||
@@ -212,7 +236,7 @@ nrfx_power_pofwarn_event_handler_t nrfx_power_pof_handler_get(void);
|
||||
* @return Handler of the USB power.
|
||||
*/
|
||||
nrfx_power_usb_event_handler_t nrfx_power_usb_handler_get(void);
|
||||
#endif
|
||||
#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the power module driver.
|
||||
@@ -235,7 +259,7 @@ nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config);
|
||||
*/
|
||||
void nrfx_power_uninit(void);
|
||||
|
||||
#if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
|
||||
#if NRFX_POWER_SUPPORTS_POFCON
|
||||
/**
|
||||
* @brief Function for initializing the power failure comparator.
|
||||
*
|
||||
@@ -271,7 +295,7 @@ void nrfx_power_pof_disable(void);
|
||||
* Clears the settings of the power failure comparator.
|
||||
*/
|
||||
void nrfx_power_pof_uninit(void);
|
||||
#endif // NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
|
||||
#endif // NRFX_POWER_SUPPORTS_POFCON
|
||||
|
||||
#if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -334,16 +358,15 @@ void nrfx_power_usbevt_uninit(void);
|
||||
*
|
||||
* @return Current USB power status.
|
||||
*/
|
||||
__STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
|
||||
NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
|
||||
|
||||
#endif /* NRF_POWER_HAS_USBREG */
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
#if NRF_POWER_HAS_USBREG
|
||||
__STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
|
||||
NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
|
||||
{
|
||||
uint32_t status = nrf_power_usbregstatus_get();
|
||||
uint32_t status = nrf_power_usbregstatus_get(NRF_POWER);
|
||||
if(0 == (status & NRF_POWER_USBREGSTATUS_VBUSDETECT_MASK))
|
||||
{
|
||||
return NRFX_POWER_USB_STATE_DISCONNECTED;
|
||||
@@ -354,9 +377,8 @@ __STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
|
||||
}
|
||||
return NRFX_POWER_USB_STATE_READY;
|
||||
}
|
||||
#endif /* NRF_POWER_HAS_USBREG */
|
||||
|
||||
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
|
||||
#endif // NRF_POWER_HAS_USBREG
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -39,21 +39,18 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
__STATIC_INLINE void nrfx_power_clock_irq_init(void);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE void nrfx_power_clock_irq_init(void)
|
||||
{
|
||||
uint8_t priority;
|
||||
#if NRFX_CHECK(NRFX_POWER_ENABLED) && NRFX_CHECK(NRFX_CLOCK_ENABLED)
|
||||
#if NRFX_POWER_CONFIG_IRQ_PRIORITY != NRFX_CLOCK_CONFIG_IRQ_PRIORITY
|
||||
#if NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY != NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
|
||||
#error "IRQ priorities for POWER and CLOCK must be the same. Check <nrfx_config.h>."
|
||||
#endif
|
||||
priority = NRFX_POWER_CONFIG_IRQ_PRIORITY;
|
||||
priority = NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY;
|
||||
#elif NRFX_CHECK(NRFX_POWER_ENABLED)
|
||||
priority = NRFX_POWER_CONFIG_IRQ_PRIORITY;
|
||||
priority = NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY;
|
||||
#elif NRFX_CHECK(NRFX_CLOCK_ENABLED)
|
||||
priority = NRFX_CLOCK_CONFIG_IRQ_PRIORITY;
|
||||
priority = NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY;
|
||||
#else
|
||||
#error "This code is not supposed to be compiled when neither POWER nor CLOCK is enabled."
|
||||
#endif
|
||||
@@ -64,8 +61,6 @@ __STATIC_INLINE void nrfx_power_clock_irq_init(void)
|
||||
NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_CLOCK));
|
||||
}
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
|
||||
#if NRFX_CHECK(NRFX_POWER_ENABLED) && NRFX_CHECK(NRFX_CLOCK_ENABLED)
|
||||
void nrfx_power_clock_irq_handler(void);
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_POWER_COMPAT_H__
|
||||
#define NRFX_POWER_COMPAT_H__
|
||||
|
||||
/**
|
||||
* POWER compatibility layer.
|
||||
*
|
||||
* The following definitions allow using of common code involving the POWER peripheral
|
||||
* driver for different SoCs, regardless of whether certain regulator registers
|
||||
* are located in the POWER peripheral or in separate peripherals like USBREG and REGULATORS.
|
||||
*/
|
||||
|
||||
#if defined(REGULATORS_PRESENT)
|
||||
#include <hal/nrf_regulators.h>
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON
|
||||
|
||||
typedef nrf_regulators_pof_thr_t nrf_power_pof_thr_t;
|
||||
#define NRF_POWER_POFTHR_V19 NRF_REGULATORS_POFTHR_V19
|
||||
#define NRF_POWER_POFTHR_V20 NRF_REGULATORS_POFTHR_V20
|
||||
#define NRF_POWER_POFTHR_V21 NRF_REGULATORS_POFTHR_V21
|
||||
#define NRF_POWER_POFTHR_V22 NRF_REGULATORS_POFTHR_V22
|
||||
#define NRF_POWER_POFTHR_V23 NRF_REGULATORS_POFTHR_V23
|
||||
#define NRF_POWER_POFTHR_V24 NRF_REGULATORS_POFTHR_V24
|
||||
#define NRF_POWER_POFTHR_V25 NRF_REGULATORS_POFTHR_V25
|
||||
#define NRF_POWER_POFTHR_V26 NRF_REGULATORS_POFTHR_V26
|
||||
#define NRF_POWER_POFTHR_V27 NRF_REGULATORS_POFTHR_V27
|
||||
#define NRF_POWER_POFTHR_V28 NRF_REGULATORS_POFTHR_V28
|
||||
|
||||
typedef nrf_regulators_pof_thrvddh_t nrf_power_pof_thrvddh_t;
|
||||
#define NRF_POWER_POFTHRVDDH_V27 NRF_REGULATORS_POFTHRVDDH_V27
|
||||
#define NRF_POWER_POFTHRVDDH_V28 NRF_REGULATORS_POFTHRVDDH_V28
|
||||
#define NRF_POWER_POFTHRVDDH_V29 NRF_REGULATORS_POFTHRVDDH_V29
|
||||
#define NRF_POWER_POFTHRVDDH_V30 NRF_REGULATORS_POFTHRVDDH_V30
|
||||
#define NRF_POWER_POFTHRVDDH_V31 NRF_REGULATORS_POFTHRVDDH_V31
|
||||
#define NRF_POWER_POFTHRVDDH_V32 NRF_REGULATORS_POFTHRVDDH_V32
|
||||
#define NRF_POWER_POFTHRVDDH_V33 NRF_REGULATORS_POFTHRVDDH_V33
|
||||
#define NRF_POWER_POFTHRVDDH_V34 NRF_REGULATORS_POFTHRVDDH_V34
|
||||
#define NRF_POWER_POFTHRVDDH_V35 NRF_REGULATORS_POFTHRVDDH_V35
|
||||
#define NRF_POWER_POFTHRVDDH_V36 NRF_REGULATORS_POFTHRVDDH_V36
|
||||
#define NRF_POWER_POFTHRVDDH_V37 NRF_REGULATORS_POFTHRVDDH_V37
|
||||
#define NRF_POWER_POFTHRVDDH_V38 NRF_REGULATORS_POFTHRVDDH_V38
|
||||
#define NRF_POWER_POFTHRVDDH_V39 NRF_REGULATORS_POFTHRVDDH_V39
|
||||
#define NRF_POWER_POFTHRVDDH_V40 NRF_REGULATORS_POFTHRVDDH_V40
|
||||
#define NRF_POWER_POFTHRVDDH_V41 NRF_REGULATORS_POFTHRVDDH_V41
|
||||
#define NRF_POWER_POFTHRVDDH_V42 NRF_REGULATORS_POFTHRVDDH_V42
|
||||
|
||||
#endif // NRF_REGULATORS_HAS_POFCON
|
||||
|
||||
#if defined(USBREG_PRESENT)
|
||||
#include "nrfx_usbreg.h"
|
||||
|
||||
typedef nrfx_usbreg_event_handler_t nrfx_power_usb_event_handler_t;
|
||||
typedef nrfx_usbreg_config_t nrfx_power_usbevt_config_t;
|
||||
|
||||
typedef nrfx_usbreg_evt_t nrfx_power_usb_evt_t;
|
||||
#define NRFX_POWER_USB_EVT_DETECTED NRFX_USBREG_EVT_DETECTED
|
||||
#define NRFX_POWER_USB_EVT_REMOVED NRFX_USBREG_EVT_REMOVED
|
||||
#define NRFX_POWER_USB_EVT_READY NRFX_USBREG_EVT_READY
|
||||
|
||||
typedef nrfx_usbreg_state_t nrfx_power_usb_state_t;
|
||||
#define NRFX_POWER_USB_STATE_DISCONNECTED NRFX_USBREG_STATE_DISCONNECTED
|
||||
#define NRFX_POWER_USB_STATE_CONNECTED NRFX_USBREG_STATE_CONNECTED
|
||||
#define NRFX_POWER_USB_STATE_READY NRFX_USBREG_STATE_READY
|
||||
|
||||
#define nrfx_power_usb_handler_get nrfx_usbreg_handler_get
|
||||
#define nrfx_power_usbevt_init nrfx_usbreg_init
|
||||
#define nrfx_power_usbevt_enable nrfx_usbreg_enable
|
||||
#define nrfx_power_usbevt_disable nrfx_usbreg_disable
|
||||
#define nrfx_power_usbevt_uninit nrfx_usbreg_uninit
|
||||
#define nrfx_power_usbstatus_get nrfx_usbreg_usbstatus_get
|
||||
|
||||
#endif // defined(USBREG_PRESENT)
|
||||
|
||||
#endif // NRFX_POWER_COMPAT_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -174,10 +174,7 @@ nrfx_err_t nrfx_ppi_group_free(nrf_ppi_channel_group_t group);
|
||||
*
|
||||
* @return Channel mask.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel)
|
||||
{
|
||||
return (1uL << (uint32_t) channel);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for including multiple PPI channels in a channel group.
|
||||
@@ -204,11 +201,8 @@ nrfx_err_t nrfx_ppi_channels_include_in_group(uint32_t channel_ma
|
||||
* application channel.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
|
||||
*/
|
||||
__STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_include_in_group(nrfx_ppi_channel_to_mask(channel), group);
|
||||
}
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing multiple PPI channels from a channel group.
|
||||
@@ -235,11 +229,8 @@ nrfx_err_t nrfx_ppi_channels_remove_from_group(uint32_t channel_m
|
||||
* application channel.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
|
||||
*/
|
||||
__STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_remove_from_group(nrfx_ppi_channel_to_mask(channel), group);
|
||||
}
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a PPI channel group.
|
||||
@@ -250,10 +241,7 @@ __STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Group is not an application group.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
|
||||
*/
|
||||
__STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_remove_from_group(NRFX_PPI_ALL_APP_CHANNELS_MASK, group);
|
||||
}
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a PPI channel group.
|
||||
@@ -284,10 +272,7 @@ nrfx_err_t nrfx_ppi_group_disable(nrf_ppi_channel_group_t group);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
|
||||
{
|
||||
return (uint32_t) nrf_ppi_task_address_get(task);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the enable task of a PPI group.
|
||||
@@ -296,10 +281,7 @@ __STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return (uint32_t) nrf_ppi_task_group_enable_address_get(group);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the enable task of a PPI group.
|
||||
@@ -308,11 +290,47 @@ __STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_gro
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel)
|
||||
{
|
||||
return (uint32_t) nrf_ppi_task_group_disable_address_get(group);
|
||||
return (1uL << (uint32_t) channel);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_include_in_group(nrfx_ppi_channel_to_mask(channel), group);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_remove_from_group(nrfx_ppi_channel_to_mask(channel), group);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrfx_ppi_channels_remove_from_group(NRFX_PPI_ALL_APP_CHANNELS_MASK, group);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
|
||||
{
|
||||
return nrf_ppi_task_address_get(NRF_PPI, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrf_ppi_task_group_enable_address_get(NRF_PPI, group);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return nrf_ppi_task_group_disable_address_get(NRF_PPI, group);
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -100,24 +100,44 @@ typedef struct
|
||||
uint16_t top_value; ///< Value up to which the pulse generator counter counts.
|
||||
nrf_pwm_dec_load_t load_mode; ///< Mode of loading sequence data from RAM.
|
||||
nrf_pwm_dec_step_t step_mode; ///< Mode of advancing the active sequence.
|
||||
bool skip_gpio_cfg; ///< Skip the GPIO configuration
|
||||
/**< When this flag is set, the user is responsible for
|
||||
* providing the proper configuration of the output pins,
|
||||
* as the driver does not touch it at all. */
|
||||
} nrfx_pwm_config_t;
|
||||
|
||||
/** @brief PWM driver default configuration. */
|
||||
#define NRFX_PWM_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.output_pins = { NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN, \
|
||||
NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN, \
|
||||
NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN, \
|
||||
NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN }, \
|
||||
.irq_priority = NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.base_clock = (nrf_pwm_clk_t)NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK, \
|
||||
.count_mode = (nrf_pwm_mode_t)NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE, \
|
||||
.top_value = NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE, \
|
||||
.load_mode = (nrf_pwm_dec_load_t)NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE, \
|
||||
.step_mode = (nrf_pwm_dec_step_t)NRFX_PWM_DEFAULT_CONFIG_STEP_MODE, \
|
||||
/**
|
||||
* @brief PWM driver default configuration.
|
||||
*
|
||||
* This configuration sets up PWM with the following options:
|
||||
* - clock frequency: 1 MHz
|
||||
* - count up
|
||||
* - top value: 1000 clock ticks
|
||||
* - load mode: common
|
||||
* - step mode: auto
|
||||
*
|
||||
* @param[in] _out_0 PWM output 0 pin.
|
||||
* @param[in] _out_1 PWM output 1 pin.
|
||||
* @param[in] _out_2 PWM output 2 pin.
|
||||
* @param[in] _out_3 PWM output 3 pin.
|
||||
*/
|
||||
#define NRFX_PWM_DEFAULT_CONFIG(_out_0, _out_1, _out_2, _out_3) \
|
||||
{ \
|
||||
.output_pins = { _out_0, \
|
||||
_out_1, \
|
||||
_out_2, \
|
||||
_out_3 \
|
||||
}, \
|
||||
.irq_priority = NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.base_clock = NRF_PWM_CLK_1MHz, \
|
||||
.count_mode = NRF_PWM_MODE_UP, \
|
||||
.top_value = 1000, \
|
||||
.load_mode = NRF_PWM_LOAD_COMMON, \
|
||||
.step_mode = NRF_PWM_STEP_AUTO, \
|
||||
.skip_gpio_cfg = false \
|
||||
}
|
||||
|
||||
/** @brief PWM flags that provide additional playback options. */
|
||||
/** @brief PWM flags providing additional playback options. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_PWM_FLAG_STOP = 0x01, /**< When the requested playback is finished,
|
||||
@@ -175,7 +195,7 @@ typedef enum
|
||||
} nrfx_pwm_evt_type_t;
|
||||
|
||||
/** @brief PWM driver event handler type. */
|
||||
typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type);
|
||||
typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type, void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the PWM driver.
|
||||
@@ -185,13 +205,15 @@ typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type);
|
||||
* @param[in] handler Event handler provided by the user. If NULL is passed
|
||||
* instead, event notifications are not done and PWM
|
||||
* interrupts are disabled.
|
||||
* @param[in] p_context Context passed to the event handler.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
|
||||
nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * p_instance,
|
||||
nrfx_pwm_config_t const * p_config,
|
||||
nrfx_pwm_handler_t handler);
|
||||
nrfx_pwm_handler_t handler,
|
||||
void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the PWM driver.
|
||||
@@ -200,7 +222,7 @@ nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance);
|
||||
void nrfx_pwm_uninit(nrfx_pwm_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a single sequence playback.
|
||||
@@ -234,7 +256,7 @@ void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance);
|
||||
* @return Address of the task to be triggered to start the playback if the @ref
|
||||
* NRFX_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise.
|
||||
*/
|
||||
uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
|
||||
uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence,
|
||||
uint16_t playback_count,
|
||||
uint32_t flags);
|
||||
@@ -262,7 +284,7 @@ uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
|
||||
* @return Address of the task to be triggered to start the playback if the @ref
|
||||
* NRFX_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise.
|
||||
*/
|
||||
uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
|
||||
uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence_0,
|
||||
nrf_pwm_sequence_t const * p_sequence_1,
|
||||
uint16_t playback_count,
|
||||
@@ -275,7 +297,7 @@ uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for stopping the sequence playback.
|
||||
@@ -300,7 +322,7 @@ __STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance);
|
||||
* @retval true The PWM peripheral is stopped.
|
||||
* @retval false The PWM peripheral is not stopped.
|
||||
*/
|
||||
bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance, bool wait_until_stopped);
|
||||
bool nrfx_pwm_stop(nrfx_pwm_t const * p_instance, bool wait_until_stopped);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the status of the PWM peripheral.
|
||||
@@ -310,7 +332,7 @@ bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance, bool wait_until_stopped)
|
||||
* @retval true The PWM peripheral is stopped.
|
||||
* @retval false The PWM peripheral is not stopped.
|
||||
*/
|
||||
bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance);
|
||||
bool nrfx_pwm_is_stopped(nrfx_pwm_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the sequence data during playback.
|
||||
@@ -319,9 +341,9 @@ bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance);
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] p_sequence Pointer to the new sequence definition.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the pointer to the duty cycle values
|
||||
@@ -331,9 +353,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_insta
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] values New pointer to the duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the number of duty cycle values
|
||||
@@ -343,9 +365,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] length New number of the duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the number of repeats for duty cycle values
|
||||
@@ -355,9 +377,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] repeats New number of repeats.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the additional delay after the specified
|
||||
@@ -367,9 +389,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] end_delay New end delay value (in PWM periods).
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay);
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a specified PWM task that can
|
||||
@@ -380,8 +402,8 @@ __STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_instance,
|
||||
nrf_pwm_task_t task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a specified PWM event that can
|
||||
@@ -392,64 +414,62 @@ __STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_in
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * const p_instance,
|
||||
nrf_pwm_event_t event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_event_t event);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * p_instance)
|
||||
{
|
||||
nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_NEXTSTEP);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence)
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence)
|
||||
{
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, seq_id, p_sequence);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values)
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values)
|
||||
{
|
||||
nrf_pwm_seq_ptr_set(p_instance->p_registers, seq_id, values.p_raw);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length)
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length)
|
||||
{
|
||||
nrf_pwm_seq_cnt_set(p_instance->p_registers, seq_id, length);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats)
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats)
|
||||
{
|
||||
nrf_pwm_seq_refresh_set(p_instance->p_registers, seq_id, repeats);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay)
|
||||
NRFX_STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay)
|
||||
{
|
||||
nrf_pwm_seq_end_delay_set(p_instance->p_registers, seq_id, end_delay);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_instance,
|
||||
nrf_pwm_task_t task)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_task_t task)
|
||||
{
|
||||
return nrf_pwm_task_address_get(p_instance->p_registers, task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * const p_instance,
|
||||
nrf_pwm_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * p_instance,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
return nrf_pwm_event_address_get(p_instance->p_registers, event);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -61,20 +61,34 @@ typedef struct
|
||||
uint8_t interrupt_priority; /**< QDEC interrupt priority. */
|
||||
} nrfx_qdec_config_t;
|
||||
|
||||
/**@brief QDEC default configuration. */
|
||||
#define NRFX_QDEC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.reportper = (nrf_qdec_reportper_t)NRFX_QDEC_CONFIG_REPORTPER, \
|
||||
.sampleper = (nrf_qdec_sampleper_t)NRFX_QDEC_CONFIG_SAMPLEPER, \
|
||||
.psela = NRFX_QDEC_CONFIG_PIO_A, \
|
||||
.pselb = NRFX_QDEC_CONFIG_PIO_B, \
|
||||
.pselled = NRFX_QDEC_CONFIG_PIO_LED, \
|
||||
.ledpre = NRFX_QDEC_CONFIG_LEDPRE, \
|
||||
.ledpol = (nrf_qdec_ledpol_t)NRFX_QDEC_CONFIG_LEDPOL, \
|
||||
.dbfen = NRFX_QDEC_CONFIG_DBFEN, \
|
||||
.sample_inten = NRFX_QDEC_CONFIG_SAMPLE_INTEN, \
|
||||
.interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY, \
|
||||
}
|
||||
/**
|
||||
* @brief QDEC driver default configuration.
|
||||
*
|
||||
* This configuration sets up QDEC with the following options:
|
||||
* - report period: 10 samples
|
||||
* - sampling period: 16384 us
|
||||
* - LED enabled for 500 us before sampling
|
||||
* - LED polarity: active high
|
||||
* - debouncing filter disabled
|
||||
* - sample ready interrupt disabled
|
||||
*
|
||||
* @param[in] _pin_a Pin for A encoder channel input.
|
||||
* @param[in] _pin_b Pin for B encoder channel input.
|
||||
* @param[in] _pin_led Pin for LED output.
|
||||
*/
|
||||
#define NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led) \
|
||||
{ \
|
||||
.reportper = NRF_QDEC_REPORTPER_10, \
|
||||
.sampleper = NRF_QDEC_SAMPLEPER_16384us, \
|
||||
.psela = _pin_a, \
|
||||
.pselb = _pin_b, \
|
||||
.pselled = _pin_led, \
|
||||
.ledpre = 500, \
|
||||
.ledpol = NRF_QDEC_LEPOL_ACTIVE_HIGH, \
|
||||
.dbfen = NRF_QDEC_DBFEN_DISABLE, \
|
||||
.sample_inten = false, \
|
||||
.interrupt_priority = NRFX_QDEC_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/** @brief QDEC sample event data. */
|
||||
typedef struct
|
||||
@@ -159,10 +173,7 @@ void nrfx_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_qdec_task_address_get(task);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified QDEC event.
|
||||
@@ -171,11 +182,20 @@ __STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_qdec_event_address_get(event);
|
||||
return nrf_qdec_task_address_get(NRF_QDEC, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
|
||||
{
|
||||
return nrf_qdec_event_address_get(NRF_QDEC, event);
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -56,31 +56,52 @@ typedef struct
|
||||
uint8_t irq_priority; /**< Interrupt priority. */
|
||||
} nrfx_qspi_config_t;
|
||||
|
||||
/** @brief QSPI instance default configuration. */
|
||||
#define NRFX_QSPI_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.xip_offset = NRFX_QSPI_CONFIG_XIP_OFFSET, \
|
||||
.pins = { \
|
||||
.sck_pin = NRFX_QSPI_PIN_SCK, \
|
||||
.csn_pin = NRFX_QSPI_PIN_CSN, \
|
||||
.io0_pin = NRFX_QSPI_PIN_IO0, \
|
||||
.io1_pin = NRFX_QSPI_PIN_IO1, \
|
||||
.io2_pin = NRFX_QSPI_PIN_IO2, \
|
||||
.io3_pin = NRFX_QSPI_PIN_IO3, \
|
||||
}, \
|
||||
.prot_if = { \
|
||||
.readoc = (nrf_qspi_readoc_t)NRFX_QSPI_CONFIG_READOC, \
|
||||
.writeoc = (nrf_qspi_writeoc_t)NRFX_QSPI_CONFIG_WRITEOC, \
|
||||
.addrmode = (nrf_qspi_addrmode_t)NRFX_QSPI_CONFIG_ADDRMODE, \
|
||||
.dpmconfig = false, \
|
||||
}, \
|
||||
.phy_if = { \
|
||||
.sck_delay = (uint8_t)NRFX_QSPI_CONFIG_SCK_DELAY, \
|
||||
.dpmen = false, \
|
||||
.spi_mode = (nrf_qspi_spi_mode_t)NRFX_QSPI_CONFIG_MODE, \
|
||||
.sck_freq = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY, \
|
||||
}, \
|
||||
.irq_priority = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY, \
|
||||
/**
|
||||
* @brief QSPI instance default configuration.
|
||||
*
|
||||
* This configuration sets up QSPI with the following options:
|
||||
* - no offset for address in the external memory for Execute in Place operation
|
||||
* - single data line
|
||||
* - FAST_READ opcode for reading
|
||||
* - PP opcode for writing
|
||||
* - 24 bit addressing mode
|
||||
* - Deep Power-down disabled
|
||||
* - clock frequency: 2 MHz for nRF52 Series, 6 MHz for nRF53 Series
|
||||
* - SCK delay 5 clock ticks
|
||||
* - mode 0 (data captured on the clock rising edge and transmitted on a falling edge. Clock base level is '0')
|
||||
*
|
||||
* @param[in] _pin_sck Pin for clock signal.
|
||||
* @param[in] _pin_csn Pin for chip select signal.
|
||||
* @param[in] _pin_io0 Pin 0 for I/O data.
|
||||
* @param[in] _pin_io1 Pin 1 for I/O data.
|
||||
* @param[in] _pin_io2 Pin 2 for I/O data.
|
||||
* @param[in] _pin_io3 Pin 3 for I/O data.
|
||||
*/
|
||||
#define NRFX_QSPI_DEFAULT_CONFIG(_pin_sck, _pin_csn, _pin_io0, \
|
||||
_pin_io1, _pin_io2, _pin_io3) \
|
||||
{ \
|
||||
.xip_offset = 0, \
|
||||
.pins = { \
|
||||
.sck_pin = _pin_sck, \
|
||||
.csn_pin = _pin_csn, \
|
||||
.io0_pin = _pin_io0, \
|
||||
.io1_pin = _pin_io1, \
|
||||
.io2_pin = _pin_io2, \
|
||||
.io3_pin = _pin_io3 \
|
||||
}, \
|
||||
.prot_if = { \
|
||||
.readoc = NRF_QSPI_READOC_FASTREAD, \
|
||||
.writeoc = NRF_QSPI_WRITEOC_PP, \
|
||||
.addrmode = NRF_QSPI_ADDRMODE_24BIT, \
|
||||
.dpmconfig = false, \
|
||||
}, \
|
||||
.phy_if = { \
|
||||
.sck_delay = 0x05, \
|
||||
.dpmen = false, \
|
||||
.spi_mode = NRF_QSPI_MODE_0, \
|
||||
.sck_freq = NRF_QSPI_FREQ_DIV16, \
|
||||
}, \
|
||||
.irq_priority = (uint8_t)NRFX_QSPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
}
|
||||
|
||||
/** @brief QSPI custom instruction helper with the default configuration. */
|
||||
@@ -308,6 +329,32 @@ nrfx_err_t nrfx_qspi_lfm_xfer(void const * p_tx_buffer,
|
||||
size_t transfer_length,
|
||||
bool finalize);
|
||||
|
||||
#if NRF_QSPI_HAS_XIP_ENC
|
||||
/**
|
||||
* @brief Function for setting the XIP encryption.
|
||||
*
|
||||
* @param[in] p_config XIP encryption configuration structure.
|
||||
* To disable encryption, pass NULL pointer as argument.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Operation was successful.
|
||||
* @retval NRFX_ERROR_BUSY Driver currently handles other operation.
|
||||
*/
|
||||
nrfx_err_t nrfx_qspi_xip_encrypt(nrf_qspi_encryption_t const * p_config);
|
||||
#endif
|
||||
|
||||
#if NRF_QSPI_HAS_DMA_ENC
|
||||
/**
|
||||
* @brief Function for setting the EasyDMA encryption.
|
||||
*
|
||||
* @param[in] p_config DMA encryption configuration structure.
|
||||
* To disable encryption, pass NULL pointer as argument.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Operation was successful.
|
||||
* @retval NRFX_ERROR_BUSY Driver currently handles other operation.
|
||||
*/
|
||||
nrfx_err_t nrfx_qspi_dma_encrypt(nrf_qspi_encryption_t const * p_config);
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -60,11 +60,14 @@ typedef struct
|
||||
* if (nrfx_rng_init(&config, handler)
|
||||
* { ...
|
||||
* @endcode
|
||||
*
|
||||
* This configuration sets up randon number generator with the following options:
|
||||
* - error correction enabled
|
||||
*/
|
||||
#define NRFX_RNG_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.error_correction = NRFX_RNG_CONFIG_ERROR_CORRECTION, \
|
||||
.interrupt_priority = NRFX_RNG_CONFIG_IRQ_PRIORITY, \
|
||||
#define NRFX_RNG_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.error_correction = true, \
|
||||
.interrupt_priority = NRFX_RNG_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
}
|
||||
|
||||
/** @brief RNG driver event handler type. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -102,14 +102,20 @@ typedef struct
|
||||
bool reliable; /**< Reliable mode flag. */
|
||||
} nrfx_rtc_config_t;
|
||||
|
||||
/** @brief RTC instance default configuration. */
|
||||
#define NRFX_RTC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.prescaler = RTC_FREQ_TO_PRESCALER(NRFX_RTC_DEFAULT_CONFIG_FREQUENCY), \
|
||||
.interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.tick_latency = NRFX_RTC_US_TO_TICKS(NRFX_RTC_MAXIMUM_LATENCY_US, \
|
||||
NRFX_RTC_DEFAULT_CONFIG_FREQUENCY), \
|
||||
.reliable = NRFX_RTC_DEFAULT_CONFIG_RELIABLE, \
|
||||
/**
|
||||
* @brief RTC driver default configuration.
|
||||
*
|
||||
* This configuration sets up RTC with the following options:
|
||||
* - frequency 32.768 kHz
|
||||
* - maximum latency 2000 us
|
||||
* - reliability checks disabled
|
||||
*/
|
||||
#define NRFX_RTC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.prescaler = RTC_FREQ_TO_PRESCALER(32768), \
|
||||
.interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.tick_latency = NRFX_RTC_US_TO_TICKS(2000, 32768), \
|
||||
.reliable = false, \
|
||||
}
|
||||
|
||||
/** @brief RTC driver instance handler type. */
|
||||
@@ -128,7 +134,7 @@ typedef void (*nrfx_rtc_handler_t)(nrfx_rtc_int_type_t int_type);
|
||||
* @retval NRFX_SUCCESS Successfully initialized.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The instance is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
|
||||
nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * p_instance,
|
||||
nrfx_rtc_config_t const * p_config,
|
||||
nrfx_rtc_handler_t handler);
|
||||
|
||||
@@ -140,21 +146,21 @@ nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_rtc_uninit(nrfx_rtc_t const * const p_instance);
|
||||
void nrfx_rtc_uninit(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the RTC driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_rtc_enable(nrfx_rtc_t const * const p_instance);
|
||||
void nrfx_rtc_enable(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the RTC driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance);
|
||||
void nrfx_rtc_disable(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a compare channel.
|
||||
@@ -182,10 +188,10 @@ void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance);
|
||||
* current counter value. This error can only be reported
|
||||
* if the reliable mode is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
|
||||
uint32_t channel,
|
||||
uint32_t val,
|
||||
bool enable_irq);
|
||||
nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * p_instance,
|
||||
uint32_t channel,
|
||||
uint32_t val,
|
||||
bool enable_irq);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a channel.
|
||||
@@ -198,7 +204,7 @@ nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_TIMEOUT Interrupt is pending on the requested channel.
|
||||
*/
|
||||
nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t channel);
|
||||
nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * p_instance, uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the TICK event.
|
||||
@@ -208,7 +214,7 @@ nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t cha
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] enable_irq True to enable the interrupt. False to disable the interrupt.
|
||||
*/
|
||||
void nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
|
||||
void nrfx_rtc_tick_enable(nrfx_rtc_t const * p_instance, bool enable_irq);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TICK event.
|
||||
@@ -217,7 +223,7 @@ void nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance);
|
||||
void nrfx_rtc_tick_disable(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling overflow.
|
||||
@@ -227,7 +233,7 @@ void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance);
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] enable_irq True to enable the interrupt. False to disable the interrupt.
|
||||
*/
|
||||
void nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
|
||||
void nrfx_rtc_overflow_enable(nrfx_rtc_t const * p_instance, bool enable_irq);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling overflow.
|
||||
@@ -236,7 +242,7 @@ void nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_i
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_rtc_overflow_disable(nrfx_rtc_t const * const p_instance);
|
||||
void nrfx_rtc_overflow_disable(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the maximum relative tick value that can be set in the compare channel.
|
||||
@@ -251,7 +257,7 @@ void nrfx_rtc_overflow_disable(nrfx_rtc_t const * const p_instance);
|
||||
*
|
||||
* @return Maximum ticks value.
|
||||
*/
|
||||
uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * const p_instance);
|
||||
uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling all instance interrupts.
|
||||
@@ -259,8 +265,8 @@ uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * const p_instance);
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_mask Pointer to the location where the mask is filled.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
|
||||
uint32_t * p_mask);
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * p_instance,
|
||||
uint32_t * p_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling instance interrupts.
|
||||
@@ -268,7 +274,7 @@ __STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] mask Mask of interrupts to enable.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, uint32_t mask);
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * p_instance, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the current counter value.
|
||||
@@ -277,14 +283,14 @@ __STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, ui
|
||||
*
|
||||
* @return Counter value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * const p_instance);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the counter value.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance);
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a requested task address for the RTC driver instance.
|
||||
@@ -296,8 +302,8 @@ __STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance)
|
||||
*
|
||||
* @return Address of task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_instance,
|
||||
nrf_rtc_task_t task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * p_instance,
|
||||
nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a requested event address for the RTC driver instance.
|
||||
@@ -309,15 +315,14 @@ __STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_in
|
||||
*
|
||||
* @return Address of event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * const p_instance,
|
||||
nrf_rtc_event_t event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * p_instance,
|
||||
nrf_rtc_event_t event);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
|
||||
uint32_t * p_mask)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * p_instance,
|
||||
uint32_t * p_mask)
|
||||
{
|
||||
*p_mask = nrf_rtc_int_get(p_instance->p_reg);
|
||||
*p_mask = nrf_rtc_int_enable_check(p_instance->p_reg, ~0uL);
|
||||
nrf_rtc_int_disable(p_instance->p_reg, NRF_RTC_INT_TICK_MASK |
|
||||
NRF_RTC_INT_OVERFLOW_MASK |
|
||||
NRF_RTC_INT_COMPARE0_MASK |
|
||||
@@ -326,33 +331,33 @@ __STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
|
||||
NRF_RTC_INT_COMPARE3_MASK);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, uint32_t mask)
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * p_instance, uint32_t mask)
|
||||
{
|
||||
nrf_rtc_int_enable(p_instance->p_reg, mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * const p_instance)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * p_instance)
|
||||
{
|
||||
return nrf_rtc_counter_get(p_instance->p_reg);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance)
|
||||
NRFX_STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * p_instance)
|
||||
{
|
||||
nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_CLEAR);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_instance,
|
||||
nrf_rtc_task_t task)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * p_instance,
|
||||
nrf_rtc_task_t task)
|
||||
{
|
||||
return nrf_rtc_task_address_get(p_instance->p_reg, task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * const p_instance,
|
||||
nrf_rtc_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * p_instance,
|
||||
nrf_rtc_event_t event)
|
||||
{
|
||||
return nrf_rtc_event_address_get(p_instance->p_reg, event);
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,80 +46,128 @@ extern "C" {
|
||||
* @brief Successive Approximation Analog-to-Digital Converter (SAADC) peripheral driver.
|
||||
*/
|
||||
|
||||
/** @brief Value to be set as high limit to disable limit detection. */
|
||||
#define NRFX_SAADC_LIMITH_DISABLED (2047)
|
||||
/** @brief Value to be set as low limit to disable limit detection. */
|
||||
#define NRFX_SAADC_LIMITL_DISABLED (-2048)
|
||||
|
||||
/** @brief Macro for setting @ref nrfx_saadc_config_t to default settings. */
|
||||
#define NRFX_SAADC_DEFAULT_CONFIG \
|
||||
/**
|
||||
* @brief SAADC channel default configuration for the single-ended mode.
|
||||
*
|
||||
* This configuration sets up single-ended SAADC channel with the following options:
|
||||
* - resistor ladder disabled
|
||||
* - gain: 1/6
|
||||
* - reference voltage: internal 0.6 V
|
||||
* - sample acquisition time: 10 us
|
||||
* - burst disabled
|
||||
*
|
||||
* @param[in] _pin_p Positive input analog pin.
|
||||
* @param[in] _index Channel index.
|
||||
*
|
||||
* @sa nrfx_saadc_channel_t
|
||||
*/
|
||||
#define NRFX_SAADC_DEFAULT_CHANNEL_SE(_pin_p, _index) \
|
||||
{ \
|
||||
.channel_config = \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_SINGLE_ENDED, \
|
||||
.burst = NRF_SAADC_BURST_DISABLED, \
|
||||
}, \
|
||||
.pin_p = (nrf_saadc_input_t)_pin_p, \
|
||||
.pin_n = NRF_SAADC_INPUT_DISABLED, \
|
||||
.channel_index = _index, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SAADC channel default configuration for the differential mode.
|
||||
*
|
||||
* This configuration sets up differential SAADC channel with the following options:
|
||||
* - resistor ladder disabled
|
||||
* - gain: 1/6
|
||||
* - reference voltage: internal 0.6 V
|
||||
* - sample acquisition time: 10 us
|
||||
* - burst disabled
|
||||
*
|
||||
* @param[in] _pin_p Positive input analog pin.
|
||||
* @param[in] _pin_n Negative input analog pin.
|
||||
* @param[in] _index Channel index.
|
||||
*
|
||||
* @sa nrfx_saadc_channel_t
|
||||
*/
|
||||
#define NRFX_SAADC_DEFAULT_CHANNEL_DIFFERENTIAL(_pin_p, _pin_n, _index) \
|
||||
{ \
|
||||
.channel_config = \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_DIFFERENTIAL, \
|
||||
.burst = NRF_SAADC_BURST_DISABLED, \
|
||||
}, \
|
||||
.pin_p = (nrf_saadc_input_t)_pin_p, \
|
||||
.pin_n = (nrf_saadc_input_t)_pin_n, \
|
||||
.channel_index = _index, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SAADC driver advanced mode default configuration.
|
||||
*
|
||||
* This configuration sets up advanced mode of the SAADC driver with the following options:
|
||||
* - oversampling disabled
|
||||
* - burst disabled
|
||||
* - internal sampling timer disabled
|
||||
* - triggering of the START task on the END event disabled
|
||||
*
|
||||
* @param[in] _pin_p Positive input analog pin.
|
||||
* @param[in] _pin_n Negative input analog pin.
|
||||
* @param[in] _index Channel index.
|
||||
*
|
||||
* @sa nrfx_saadc_adv_config_t
|
||||
*/
|
||||
#define NRFX_SAADC_DEFAULT_ADV_CONFIG \
|
||||
{ \
|
||||
.resolution = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION, \
|
||||
.oversample = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE, \
|
||||
.interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY, \
|
||||
.low_power_mode = NRFX_SAADC_CONFIG_LP_MODE \
|
||||
.oversampling = NRF_SAADC_OVERSAMPLE_DISABLED, \
|
||||
.burst = NRF_SAADC_BURST_DISABLED, \
|
||||
.internal_timer_cc = 0, \
|
||||
.start_on_end = false, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
|
||||
* in single-ended mode.
|
||||
*
|
||||
* @param PIN_P Analog input.
|
||||
*/
|
||||
#define NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_SINGLE_ENDED, \
|
||||
.burst = NRF_SAADC_BURST_DISABLED, \
|
||||
.pin_p = (nrf_saadc_input_t)(PIN_P), \
|
||||
.pin_n = NRF_SAADC_INPUT_DISABLED \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
|
||||
* in differential mode.
|
||||
*
|
||||
* @param PIN_P Positive analog input.
|
||||
* @param PIN_N Negative analog input.
|
||||
*/
|
||||
#define NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(PIN_P, PIN_N) \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_DIFFERENTIAL, \
|
||||
.burst = NRF_SAADC_BURST_DISABLED, \
|
||||
.pin_p = (nrf_saadc_input_t)(PIN_P), \
|
||||
.pin_n = (nrf_saadc_input_t)(PIN_N) \
|
||||
}
|
||||
|
||||
/** @brief SAADC driver configuration structure. */
|
||||
/** @brief SAADC channel configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_resolution_t resolution; ///< Resolution configuration.
|
||||
nrf_saadc_oversample_t oversample; ///< Oversampling configuration.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
bool low_power_mode; ///< Indicates if low power mode is active.
|
||||
} nrfx_saadc_config_t;
|
||||
nrf_saadc_channel_config_t channel_config; ///< Channel hardware configuration.
|
||||
nrf_saadc_input_t pin_p; ///< Input positive pin selection.
|
||||
nrf_saadc_input_t pin_n; ///< Input negative pin selection.
|
||||
uint8_t channel_index; ///< Channel index.
|
||||
} nrfx_saadc_channel_t;
|
||||
|
||||
/** @brief SAADC driver advanced mode configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_oversample_t oversampling; ///< Oversampling configuration.
|
||||
nrf_saadc_burst_t burst; ///< Burst configuration.
|
||||
uint16_t internal_timer_cc; ///< Internal timer capture and compare value.
|
||||
bool start_on_end; ///< Flag indicating if the START task is to be triggered on the END event.
|
||||
} nrfx_saadc_adv_config_t;
|
||||
|
||||
/** @brief SAADC driver event types. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRFX_SAADC_EVT_LIMIT, ///< Event generated after one of the limits is reached.
|
||||
NRFX_SAADC_EVT_CALIBRATEDONE ///< Event generated when the calibration is complete.
|
||||
NRFX_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRFX_SAADC_EVT_LIMIT, ///< Event generated when one of the limits is reached.
|
||||
NRFX_SAADC_EVT_CALIBRATEDONE, ///< Event generated when the calibration is complete.
|
||||
NRFX_SAADC_EVT_BUF_REQ, ///< Event generated when the next buffer for continuous conversion is requested.
|
||||
NRFX_SAADC_EVT_READY, ///< Event generated when the first buffer is acquired by the peripheral and sampling can be started.
|
||||
NRFX_SAADC_EVT_FINISHED, ///< Event generated when all supplied buffers are filled with results.
|
||||
} nrfx_saadc_evt_type_t;
|
||||
|
||||
/** @brief SAADC driver done event data. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_value_t * p_buffer; ///< Pointer to buffer with converted samples.
|
||||
nrf_saadc_value_t * p_buffer; ///< Pointer to the buffer with converted samples.
|
||||
uint16_t size; ///< Number of samples in the buffer.
|
||||
} nrfx_saadc_done_evt_t;
|
||||
|
||||
@@ -144,129 +192,137 @@ typedef struct
|
||||
/**
|
||||
* @brief SAADC driver event handler.
|
||||
*
|
||||
* When operating in the advanced mode:
|
||||
* - when the sampling is performed by the external timer, the external timer can be safely started
|
||||
* on @ref NRFX_SAADC_EVT_READY and stopped on @ref NRFX_SAADC_EVT_FINISHED.
|
||||
* - call the @ref nrfx_saadc_buffer_set() on @ref NRFX_SAADC_EVT_BUF_REQ to achieve the continuous conversion.
|
||||
*
|
||||
* @param[in] p_event Pointer to an SAADC driver event. The event structure is allocated on
|
||||
* the stack, so it is valid only within the context of the event handler.
|
||||
*/
|
||||
typedef void (* nrfx_saadc_event_handler_t)(nrfx_saadc_evt_t const * p_event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the SAADC.
|
||||
* @brief Function for initializing the SAADC driver.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
* @param[in] interrupt_priority Interrupt priority.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_init(nrfx_saadc_config_t const * p_config,
|
||||
nrfx_saadc_event_handler_t event_handler);
|
||||
nrfx_err_t nrfx_saadc_init(uint8_t interrupt_priority);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the SAADC.
|
||||
* @brief Function for uninitializing the SAADC driver.
|
||||
*
|
||||
* This function stops all ongoing conversions and disables all channels.
|
||||
*/
|
||||
void nrfx_saadc_uninit(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a SAMPLE SAADC task.
|
||||
* @brief Function for configuring the SAADC channels.
|
||||
*
|
||||
* @return Task address.
|
||||
* @note The values of the @ref nrf_saadc_channel_config_t.burst fields in channel configurations
|
||||
* are ignored. They will be overridden with the value suitable for the selected driver
|
||||
* operation mode.
|
||||
* @note The desired mode (simple or advanced) must be set after the channels are configured.
|
||||
*
|
||||
* @param[in] p_channels Pointer to the array of channel configuration structures.
|
||||
* @param[in] channel_count Number of channels to be configured.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Configuration was successful.
|
||||
* @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Attempt to configure the same channel more than once.
|
||||
*/
|
||||
uint32_t nrfx_saadc_sample_task_get(void);
|
||||
nrfx_err_t nrfx_saadc_channels_config(nrfx_saadc_channel_t const * p_channels,
|
||||
uint32_t channel_count);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing an SAADC channel.
|
||||
* @brief Function for setting the SAADC driver in the simple mode.
|
||||
*
|
||||
* This function configures and enables the channel.
|
||||
* The simple mode allows obtaining a single sample from each requested channel.
|
||||
* The conversion can be done in a blocking or non-blocking manner.
|
||||
* Sampling is initiated by calling @ref nrfx_saadc_mode_trigger() once.
|
||||
*
|
||||
* @param[in] channel Channel index.
|
||||
* @param[in] p_config Pointer to the structure with the initial configuration.
|
||||
* @param[in] channel_mask Bitmask of channels to be used in the simple mode.
|
||||
* @param[in] resolution Resolution configuration.
|
||||
* @param[in] oversampling Oversampling configuration.
|
||||
* @param[in] event_handler Event handler provided by the user. In case of providing NULL,
|
||||
* the conversion will be performed in the blocking manner.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The SAADC was not initialized.
|
||||
* @retval NRFX_ERROR_NO_MEM The specified channel was already allocated.
|
||||
* @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Attempt to activate channel that is not configured.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_channel_init(uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * const p_config);
|
||||
nrfx_err_t nrfx_saadc_simple_mode_set(uint32_t channel_mask,
|
||||
nrf_saadc_resolution_t resolution,
|
||||
nrf_saadc_oversample_t oversampling,
|
||||
nrfx_saadc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing an SAADC channel.
|
||||
* @brief Function for setting the SAADC driver in the advanced mode.
|
||||
*
|
||||
* @param[in] channel Channel index.
|
||||
* The advanced mode allows performing double-buffered conversions of arbitrary length.
|
||||
* The conversions can be done in a blocking or non-blocking manner. When performing conversions
|
||||
* in the non-blocking manner and @ref nrfx_saadc_adv_config_t.internal_timer_cc is set to 0,
|
||||
* sampling needs to be done by triggering @ref NRF_SAADC_TASK_SAMPLE externally
|
||||
* (for example by using the TIMER and/or the PPI/DPPI).
|
||||
* When performing conversions in the non-blocking manner and @ref nrfx_saadc_adv_config_t.start_on_end
|
||||
* is false, the @ref NRF_SAADC_TASK_START needs to be triggered on @ref NRF_SAADC_EVENT_END
|
||||
* externally (for example by using the PPI/DPPI).
|
||||
* Sampling is initiated by calling @ref nrfx_saadc_mode_trigger(). In case of performing
|
||||
* conversions in the blocking manner, @ref nrfx_saadc_mode_trigger() may need to be called several
|
||||
* times as each call sample each requested channel once.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Uninitialization was successful.
|
||||
* @retval NRFX_ERROR_BUSY The SAADC is busy.
|
||||
* @note The internal timer can only be used when a single input channel is enabled.
|
||||
* @note The internal timer can only be used in the non-blocking mode.
|
||||
*
|
||||
* @param[in] channel_mask Bitmask of channels to be used in the advanced mode.
|
||||
* @param[in] resolution Resolution configuration.
|
||||
* @param[in] p_config Pointer to the structure with the advanced mode configuration.
|
||||
* @param[in] event_handler Event handler provided by the user. In case of providing NULL,
|
||||
* the conversion will be performed in the blocking manner.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Attempt to activate channel that is not configured.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED Attempt to activate internal timer or oversampling without burst
|
||||
* with multiple channels enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_channel_uninit(uint8_t channel);
|
||||
nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t channel_mask,
|
||||
nrf_saadc_resolution_t resolution,
|
||||
nrfx_saadc_adv_config_t const * p_config,
|
||||
nrfx_saadc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the SAADC sampling.
|
||||
* @brief Function for supplying the buffer to be used in the next part of
|
||||
* the conversion.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The SAADC sampling was triggered.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The SAADC is in idle state.
|
||||
* @param[in] p_buffer Pointer to the buffer to be filled with conversion results.
|
||||
* @param[in] size Number of @ref nrf_saadc_value_t samples in buffer.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Buffer was supplied successfully.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not in the Data RAM region.
|
||||
* @retval NRFX_ERROR_INVALID_LENGTH The provided buffer is not aligned to the number of activated channels
|
||||
* or is too long for the EasyDMA to handle.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver is in the idle mode.
|
||||
* @retval NRFX_ERROR_ALREADY_INITIALIZED Both buffers for double-buffered conversions are already set.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_sample(void);
|
||||
nrfx_err_t nrfx_saadc_buffer_set(nrf_saadc_value_t * p_buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Blocking function for executing a single SAADC conversion.
|
||||
* @brief Function for triggering the conversion in the configured mode.
|
||||
*
|
||||
* This function selects the desired input, starts a single conversion,
|
||||
* waits for it to finish, and returns the result.
|
||||
*
|
||||
* The function fails if the SAADC is busy.
|
||||
*
|
||||
* @param[in] channel Channel.
|
||||
* @param[out] p_value Pointer to the location where the result is to be placed.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY The SAADC driver is busy.
|
||||
* @retval NRFX_SUCCESS Operation finished successfully in the blocking manner or started
|
||||
* successfully in the non-blocking manner.
|
||||
* @retval NRFX_ERROR_BUSY The driver is performing the conversion in the advanced blocking mode.
|
||||
* Call the function again to continue the conversion.
|
||||
* @retval NRFX_ERROR_NO_MEM There is no buffer provided.
|
||||
* Supply the buffer using @ref nrfx_saadc_buffer_set() and try again.
|
||||
* @retval NRFX_ERROR_INVALID_STATE There is an ongoing conversion being performed in the non-blocking manner
|
||||
* or the driver is in the idle mode.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for issuing conversion of data to the buffer.
|
||||
*
|
||||
* This function is non-blocking. The application is notified about filling the buffer by the event
|
||||
* handler. Conversion will be done on all enabled channels. If the SAADC is in idle state, the
|
||||
* function will set up EasyDMA for the conversion. The SAADC will be ready for sampling and wait
|
||||
* for the SAMPLE task. It can be triggered manually by the @ref nrfx_saadc_sample function
|
||||
* or by PPI using the @ref NRF_SAADC_TASK_SAMPLE task. If one buffer is already set and the
|
||||
* conversion is ongoing, calling this function will result in queuing the given buffer.
|
||||
* The driver will start filling the issued buffer when the first one is completed.
|
||||
* If the function is called again before the first buffer is filled or calibration
|
||||
* is in progress, it will return with error.
|
||||
*
|
||||
* @param[in] buffer Result buffer.
|
||||
* @param[in] size Buffer size in words.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver already has two buffers set or the calibration is in progress.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_buffer_convert(nrf_saadc_value_t * buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the SAADC offset calibration.
|
||||
*
|
||||
* This function is non-blocking. The application is notified about completion by the event handler.
|
||||
* Calibration will also trigger DONE and RESULTDONE events.
|
||||
*
|
||||
* The function will fail if the SAADC is busy or calibration is already in progress.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The calibration was started successfully.
|
||||
* @retval NRFX_ERROR_BUSY The SAADC driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_calibrate_offset(void);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SAADC state.
|
||||
*
|
||||
* @retval true The SAADC is busy.
|
||||
* @retval false The SAADC is ready.
|
||||
*/
|
||||
bool nrfx_saadc_is_busy(void);
|
||||
nrfx_err_t nrfx_saadc_mode_trigger(void);
|
||||
|
||||
/**
|
||||
* @brief Function for aborting the ongoing and buffered conversions.
|
||||
@@ -278,27 +334,47 @@ void nrfx_saadc_abort(void);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SAADC channel limits.
|
||||
* When limits are enabled and the result exceeds the defined bounds, the limit handler
|
||||
* function is called.
|
||||
*
|
||||
* @param[in] channel SAADC channel number.
|
||||
* @param[in] limit_low Lower limit (valid values from @ref NRFX_SAADC_LIMITL_DISABLED to
|
||||
* @ref NRFX_SAADC_LIMITH_DISABLED). Conversion results below this value will
|
||||
* trigger the handler function. Set to @ref NRFX_SAADC_LIMITL_DISABLED
|
||||
* to disable this limit.
|
||||
* @param[in] limit_high Upper limit (valid values from @ref NRFX_SAADC_LIMITL_DISABLED to
|
||||
* @ref NRFX_SAADC_LIMITH_DISABLED). Conversion results above this value will
|
||||
* trigger the handler function. Set to @ref NRFX_SAADC_LIMITH_DISABLED
|
||||
* to disable this limit.
|
||||
* When limits are enabled and the conversion result exceeds the defined bounds,
|
||||
* the handler function is called with the corresponding event as parameter.
|
||||
*
|
||||
* @note Before the limits are set, the driver operation mode (simple or advanced) has
|
||||
* to be configured. Only non-blocking conversions can be monitored.
|
||||
*
|
||||
* @note Changing of the driver operation mode disables all configured limits.
|
||||
*
|
||||
* @param[in] channel Channel index.
|
||||
* @param[in] limit_low Limit low value to generate interrupt. Use @c INT16_MIN
|
||||
* to disable interrupt generation.
|
||||
* @param[in] limit_high Limit high value to generate interrupt. Use @c INT16_MAX
|
||||
* to disable interrupt generation.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Requested channel limits were set.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM Attempt to activate the limits on disabled channel.
|
||||
* @retval NRFX_ERROR_FORBIDDEN Attempt to activate the limits for blocking conversions.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Attempt to activate the limits without configured mode.
|
||||
*/
|
||||
void nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);
|
||||
nrfx_err_t nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the SAADC offset calibration.
|
||||
*
|
||||
* @note This function cancels the currently selected driver operation mode, if any.
|
||||
* The desired mode (simple or advanced) must be set after the calibration process completes.
|
||||
*
|
||||
* @param[in] event_handler Event handler provided by the user. In case of providing NULL,
|
||||
* the calibration will be performed in the blocking manner.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Calibration finished successfully in the blocking manner
|
||||
* or started successfully in the non-blocking manner.
|
||||
* @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
|
||||
*/
|
||||
nrfx_err_t nrfx_saadc_offset_calibrate(nrfx_saadc_event_handler_t event_handler);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
void nrfx_saadc_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_spi.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -53,6 +54,7 @@ typedef struct
|
||||
uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
|
||||
} nrfx_spi_t;
|
||||
|
||||
#ifndef __NRFX_DOXYGEN__
|
||||
enum {
|
||||
#if NRFX_CHECK(NRFX_SPI0_ENABLED)
|
||||
NRFX_SPI0_INST_IDX,
|
||||
@@ -65,6 +67,7 @@ enum {
|
||||
#endif
|
||||
NRFX_SPI_ENABLED_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
/** @brief Macro for creating an instance of the SPI master driver. */
|
||||
#define NRFX_SPI_INSTANCE(id) \
|
||||
@@ -103,20 +106,35 @@ typedef struct
|
||||
nrf_spi_frequency_t frequency; ///< SPI frequency.
|
||||
nrf_spi_mode_t mode; ///< SPI mode.
|
||||
nrf_spi_bit_order_t bit_order; ///< SPI bit order.
|
||||
nrf_gpio_pin_pull_t miso_pull; ///< MISO pull up configuration.
|
||||
} nrfx_spi_config_t;
|
||||
|
||||
/** @brief SPI master instance default configuration. */
|
||||
#define NRFX_SPI_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.sck_pin = NRFX_SPI_PIN_NOT_USED, \
|
||||
.mosi_pin = NRFX_SPI_PIN_NOT_USED, \
|
||||
.miso_pin = NRFX_SPI_PIN_NOT_USED, \
|
||||
.ss_pin = NRFX_SPI_PIN_NOT_USED, \
|
||||
.irq_priority = NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.orc = 0xFF, \
|
||||
.frequency = NRF_SPI_FREQ_4M, \
|
||||
.mode = NRF_SPI_MODE_0, \
|
||||
.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
|
||||
/**
|
||||
* @brief SPI master instance default configuration.
|
||||
* This configuration sets up SPI with the following options:
|
||||
* - over-run character set to 0xFF
|
||||
* - clock frequency 4 MHz
|
||||
* - mode 0 enabled (SCK active high, sample on leading edge of clock)
|
||||
* - MSB shifted out first
|
||||
* - MISO pull-up disabled
|
||||
*
|
||||
* @param[in] _pin_sck SCK pin.
|
||||
* @param[in] _pin_mosi MOSI pin.
|
||||
* @param[in] _pin_miso MISO pin.
|
||||
* @param[in] _pin_ss SS pin.
|
||||
*/
|
||||
#define NRFX_SPI_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_ss) \
|
||||
{ \
|
||||
.sck_pin = _pin_sck, \
|
||||
.mosi_pin = _pin_mosi, \
|
||||
.miso_pin = _pin_miso, \
|
||||
.ss_pin = _pin_ss, \
|
||||
.irq_priority = NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.orc = 0xFF, \
|
||||
.frequency = NRF_SPI_FREQ_4M, \
|
||||
.mode = NRF_SPI_MODE_0, \
|
||||
.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
|
||||
.miso_pull = NRF_GPIO_PIN_NOPULL, \
|
||||
}
|
||||
|
||||
/** @brief Single transfer descriptor structure. */
|
||||
@@ -191,7 +209,7 @@ typedef void (* nrfx_spi_evt_handler_t)(nrfx_spi_evt_t const * p_event,
|
||||
* possible only if @ref nrfx_prs module
|
||||
* is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_spi_init(nrfx_spi_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spi_init(nrfx_spi_t const * p_instance,
|
||||
nrfx_spi_config_t const * p_config,
|
||||
nrfx_spi_evt_handler_t handler,
|
||||
void * p_context);
|
||||
@@ -201,7 +219,7 @@ nrfx_err_t nrfx_spi_init(nrfx_spi_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_spi_uninit(nrfx_spi_t const * const p_instance);
|
||||
void nrfx_spi_uninit(nrfx_spi_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the SPI data transfer.
|
||||
@@ -220,7 +238,7 @@ void nrfx_spi_uninit(nrfx_spi_t const * const p_instance);
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
|
||||
*/
|
||||
nrfx_err_t nrfx_spi_xfer(nrfx_spi_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spi_xfer(nrfx_spi_t const * p_instance,
|
||||
nrfx_spi_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_spim.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -66,6 +67,9 @@ enum {
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)
|
||||
NRFX_SPIM3_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
|
||||
NRFX_SPIM4_INST_IDX,
|
||||
#endif
|
||||
NRFX_SPIM_ENABLED_COUNT
|
||||
};
|
||||
@@ -88,67 +92,90 @@ enum {
|
||||
/** @brief Configuration structure of the SPIM driver instance. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sck_pin; ///< SCK pin number.
|
||||
uint8_t mosi_pin; ///< MOSI pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t miso_pin; ///< MISO pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t ss_pin; ///< Slave Select pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
bool ss_active_high; ///< Polarity of the Slave Select pin during transmission.
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
uint8_t orc; ///< Overrun character.
|
||||
/**< This character is used when all bytes from the TX buffer are sent,
|
||||
but the transfer continues due to RX. */
|
||||
nrf_spim_frequency_t frequency; ///< SPIM frequency.
|
||||
nrf_spim_mode_t mode; ///< SPIM mode.
|
||||
nrf_spim_bit_order_t bit_order; ///< SPIM bit order.
|
||||
uint8_t sck_pin; ///< SCK pin number.
|
||||
uint8_t mosi_pin; ///< MOSI pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t miso_pin; ///< MISO pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t ss_pin; ///< Slave Select pin number (optional).
|
||||
/**< Set to @ref NRFX_SPIM_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
bool ss_active_high; ///< Polarity of the Slave Select pin during transmission.
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
uint8_t orc; ///< Overrun character.
|
||||
/**< This character is used when all bytes from the TX buffer are sent,
|
||||
but the transfer continues due to RX. */
|
||||
nrf_spim_frequency_t frequency; ///< SPIM frequency.
|
||||
nrf_spim_mode_t mode; ///< SPIM mode.
|
||||
nrf_spim_bit_order_t bit_order; ///< SPIM bit order.
|
||||
nrf_gpio_pin_pull_t miso_pull; ///< MISO pull up configuration.
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__)
|
||||
uint8_t dcx_pin; ///< D/CX pin number (optional).
|
||||
uint8_t rx_delay; ///< Sample delay for input serial data on MISO.
|
||||
/**< The value specifies the delay, in number of 64 MHz clock cycles
|
||||
* (15.625 ns), from the the sampling edge of SCK (leading edge for
|
||||
* CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until
|
||||
* the input serial data is sampled. */
|
||||
bool use_hw_ss; ///< Indication to use software or hardware controlled Slave Select pin.
|
||||
uint8_t ss_duration; ///< Slave Select duration before and after transmission.
|
||||
/**< Minimum duration between the edge of CSN and the edge of SCK and minimum
|
||||
* duration of CSN must stay inactive between transactions.
|
||||
* The value is specified in number of 64 MHz clock cycles (15.625 ns).
|
||||
* Supported only for hardware-controlled Slave Select. */
|
||||
uint8_t dcx_pin; ///< D/CX pin number (optional).
|
||||
uint8_t rx_delay; ///< Sample delay for input serial data on MISO.
|
||||
/**< The value specifies the delay, in number of 64 MHz clock cycles
|
||||
* (15.625 ns), from the the sampling edge of SCK (leading edge for
|
||||
* CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until
|
||||
* the input serial data is sampled. */
|
||||
bool use_hw_ss; ///< Indication to use software or hardware controlled Slave Select pin.
|
||||
uint8_t ss_duration; ///< Slave Select duration before and after transmission.
|
||||
/**< Minimum duration between the edge of CSN and the edge of SCK.
|
||||
* Also, minimum duration of CSN inactivity between transactions.
|
||||
* The value is specified in number of 64 MHz clock cycles (15.625 ns).
|
||||
* Supported only for hardware-controlled Slave Select. */
|
||||
#endif
|
||||
} nrfx_spim_config_t;
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Extended default configuration of the SPIM instance.
|
||||
* @brief SPIM driver extended default configuration.
|
||||
*
|
||||
* This configuration sets up SPIM additional options with the following values:
|
||||
* - DCX pin disabled
|
||||
* - RX sampling delay: 2 clock cycles
|
||||
* - hardware SS disabled
|
||||
* - hardware SS duration before and after transmission: 2 clock cycles
|
||||
*/
|
||||
#define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
|
||||
.dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.rx_delay = 0x02, \
|
||||
.use_hw_ss = false, \
|
||||
.ss_duration = 0x02,
|
||||
#define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
|
||||
.dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.rx_delay = 0x02, \
|
||||
.use_hw_ss = false, \
|
||||
.ss_duration = 0x02,
|
||||
#else
|
||||
#define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG
|
||||
#endif
|
||||
|
||||
/** @brief The default configuration of the SPIM master instance. */
|
||||
#define NRFX_SPIM_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.sck_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.mosi_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.miso_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.ss_pin = NRFX_SPIM_PIN_NOT_USED, \
|
||||
.ss_active_high = false, \
|
||||
.irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.orc = 0xFF, \
|
||||
.frequency = NRF_SPIM_FREQ_4M, \
|
||||
.mode = NRF_SPIM_MODE_0, \
|
||||
.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
|
||||
NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
|
||||
/**
|
||||
* @brief SPIM driver default configuration.
|
||||
*
|
||||
* This configuration sets up SPIM with the following options:
|
||||
* - SS pin active low
|
||||
* - over-run character set to 0xFF
|
||||
* - clock frequency: 4 MHz
|
||||
* - mode: 0 (SCK active high, sample on leading edge of the clock signa;)
|
||||
* - MSB shifted out first
|
||||
* - MISO pull-up disabled
|
||||
*
|
||||
* @param[in] _pin_sck SCK pin.
|
||||
* @param[in] _pin_mosi MOSI pin.
|
||||
* @param[in] _pin_miso MISO pin.
|
||||
* @param[in] _pin_ss SS pin.
|
||||
*/
|
||||
#define NRFX_SPIM_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_ss) \
|
||||
{ \
|
||||
.sck_pin = _pin_sck, \
|
||||
.mosi_pin = _pin_mosi, \
|
||||
.miso_pin = _pin_miso, \
|
||||
.ss_pin = _pin_ss, \
|
||||
.ss_active_high = false, \
|
||||
.irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.orc = 0xFF, \
|
||||
.frequency = NRF_SPIM_FREQ_4M, \
|
||||
.mode = NRF_SPIM_MODE_0, \
|
||||
.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
|
||||
.miso_pull = NRF_GPIO_PIN_NOPULL, \
|
||||
NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
|
||||
}
|
||||
|
||||
/** @brief Flag indicating that TX buffer address will be incremented after transfer. */
|
||||
@@ -236,7 +263,7 @@ typedef void (* nrfx_spim_evt_handler_t)(nrfx_spim_evt_t const * p_event,
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED Requested configuration is not supported
|
||||
* by the SPIM instance.
|
||||
*/
|
||||
nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_init(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_config_t const * p_config,
|
||||
nrfx_spim_evt_handler_t handler,
|
||||
void * p_context);
|
||||
@@ -246,7 +273,7 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_spim_uninit(nrfx_spim_t const * const p_instance);
|
||||
void nrfx_spim_uninit(nrfx_spim_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the SPIM data transfer.
|
||||
@@ -290,7 +317,7 @@ void nrfx_spim_uninit(nrfx_spim_t const * const p_instance);
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data
|
||||
* RAM region.
|
||||
*/
|
||||
nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags);
|
||||
|
||||
@@ -323,7 +350,7 @@ nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance,
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data
|
||||
* RAM region.
|
||||
*/
|
||||
nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags,
|
||||
uint8_t cmd_length);
|
||||
@@ -367,6 +394,7 @@ void nrfx_spim_0_irq_handler(void);
|
||||
void nrfx_spim_1_irq_handler(void);
|
||||
void nrfx_spim_2_irq_handler(void);
|
||||
void nrfx_spim_3_irq_handler(void);
|
||||
void nrfx_spim_4_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -86,11 +86,6 @@ enum {
|
||||
*/
|
||||
#define NRFX_SPIS_PIN_NOT_USED 0xFF
|
||||
|
||||
/** @brief Default pull-up configuration of the SPI CS. */
|
||||
#define NRFX_SPIS_DEFAULT_CSN_PULLUP NRF_GPIO_PIN_NOPULL
|
||||
/** @brief Default drive configuration of the SPI MISO. */
|
||||
#define NRFX_SPIS_DEFAULT_MISO_DRIVE NRF_GPIO_PIN_S0S1
|
||||
|
||||
/** @brief SPI slave driver event types. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -107,20 +102,35 @@ typedef struct
|
||||
size_t tx_amount; //!< Number of bytes transmitted in the last transaction. This parameter is only valid for @ref NRFX_SPIS_XFER_DONE events.
|
||||
} nrfx_spis_evt_t;
|
||||
|
||||
/** @brief The default configuration of the SPI slave instance. */
|
||||
#define NRFX_SPIS_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.miso_pin = NRFX_SPIS_PIN_NOT_USED, \
|
||||
.mosi_pin = NRFX_SPIS_PIN_NOT_USED, \
|
||||
.sck_pin = NRFX_SPIS_PIN_NOT_USED, \
|
||||
.csn_pin = NRFX_SPIS_PIN_NOT_USED, \
|
||||
.mode = NRF_SPIS_MODE_0, \
|
||||
.bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
|
||||
.csn_pullup = NRFX_SPIS_DEFAULT_CSN_PULLUP, \
|
||||
.miso_drive = NRFX_SPIS_DEFAULT_MISO_DRIVE, \
|
||||
.def = NRFX_SPIS_DEFAULT_DEF, \
|
||||
.orc = NRFX_SPIS_DEFAULT_ORC, \
|
||||
.irq_priority = NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
/**
|
||||
* @brief SPIS driver default configuration.
|
||||
*
|
||||
* This configuration sets up SPIS with the following options:
|
||||
* - mode: 0 (SCK active high, sample on leading edge of the clock signal)
|
||||
* - MSB shifted out first
|
||||
* - CSN pull-up disabled
|
||||
* - MISO pin drive set to standard '0' and standard '1'
|
||||
* - default character set to 0xFF
|
||||
* - over-read character set to 0xFE
|
||||
*
|
||||
* @param[in] _pin_sck SCK pin.
|
||||
* @param[in] _pin_mosi MOSI pin.
|
||||
* @param[in] _pin_miso MISO pin.
|
||||
* @param[in] _pin_csn CSN pin.
|
||||
*/
|
||||
#define NRFX_SPIS_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_csn) \
|
||||
{ \
|
||||
.miso_pin = _pin_miso, \
|
||||
.mosi_pin = _pin_mosi, \
|
||||
.sck_pin = _pin_sck, \
|
||||
.csn_pin = _pin_csn, \
|
||||
.mode = NRF_SPIS_MODE_0, \
|
||||
.bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
|
||||
.csn_pullup = NRF_GPIO_PIN_NOPULL, \
|
||||
.miso_drive = NRF_GPIO_PIN_S0S1, \
|
||||
.def = 0xFF, \
|
||||
.orc = 0xFE, \
|
||||
.irq_priority = NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
}
|
||||
|
||||
/** @brief SPI peripheral device configuration data. */
|
||||
@@ -179,7 +189,7 @@ typedef void (*nrfx_spis_event_handler_t)(nrfx_spis_evt_t const * p_event,
|
||||
* on CSN pin cannot be initialized. Possible
|
||||
* only when using nRF52 Anomaly 109 workaround.
|
||||
*/
|
||||
nrfx_err_t nrfx_spis_init(nrfx_spis_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spis_init(nrfx_spis_t const * p_instance,
|
||||
nrfx_spis_config_t const * p_config,
|
||||
nrfx_spis_event_handler_t event_handler,
|
||||
void * p_context);
|
||||
@@ -189,7 +199,7 @@ nrfx_err_t nrfx_spis_init(nrfx_spis_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_spis_uninit(nrfx_spis_t const * const p_instance);
|
||||
void nrfx_spis_uninit(nrfx_spis_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for preparing the SPI slave instance for a single SPI transaction.
|
||||
@@ -224,11 +234,11 @@ void nrfx_spis_uninit(nrfx_spis_t const * const p_instance);
|
||||
* @retval NRFX_ERROR_INVALID_LENGTH Provided lengths exceed the EasyDMA limits for the peripheral.
|
||||
* @retval NRFX_ERROR_INTERNAL The operation failed because of an internal error.
|
||||
*/
|
||||
nrfx_err_t nrfx_spis_buffers_set(nrfx_spis_t const * const p_instance,
|
||||
uint8_t const * p_tx_buffer,
|
||||
size_t tx_buffer_length,
|
||||
uint8_t * p_rx_buffer,
|
||||
size_t rx_buffer_length);
|
||||
nrfx_err_t nrfx_spis_buffers_set(nrfx_spis_t const * p_instance,
|
||||
uint8_t const * p_tx_buffer,
|
||||
size_t tx_buffer_length,
|
||||
uint8_t * p_rx_buffer,
|
||||
size_t rx_buffer_length);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_SWI_H__
|
||||
#define NRFX_SWI_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#if NRFX_CHECK(NRFX_EGU_ENABLED)
|
||||
#include <hal/nrf_egu.h>
|
||||
#endif
|
||||
|
||||
#ifndef SWI_COUNT
|
||||
#define SWI_COUNT EGU_COUNT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_swi SWI driver
|
||||
* @{
|
||||
* @ingroup nrf_swi_egu
|
||||
*
|
||||
* @brief Driver for managing software interrupts (SWI).
|
||||
*/
|
||||
|
||||
/** @brief SWI instance. */
|
||||
typedef uint8_t nrfx_swi_t;
|
||||
|
||||
/**
|
||||
* @brief SWI user flags.
|
||||
*
|
||||
* User flags are set during the SWI trigger and passed to the callback function as an argument.
|
||||
*/
|
||||
typedef uint16_t nrfx_swi_flags_t;
|
||||
|
||||
/** @brief Unallocated instance value. */
|
||||
#define NRFX_SWI_UNALLOCATED ((nrfx_swi_t)0xFFuL)
|
||||
|
||||
/** @brief Default SWI priority. */
|
||||
#define NRFX_SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
/**
|
||||
* @brief SWI handler function.
|
||||
*
|
||||
* @param swi SWI instance.
|
||||
* @param flags User flags.
|
||||
*/
|
||||
typedef void (*nrfx_swi_handler_t)(nrfx_swi_t swi, nrfx_swi_flags_t flags);
|
||||
|
||||
/**
|
||||
* @brief Function for allocating the first unused SWI instance and setting a handler.
|
||||
*
|
||||
* If provided handler is not NULL, an allocated SWI has its interrupt enabled by default.
|
||||
* The interrupt can be disabled by @ref nrfx_swi_int_disable.
|
||||
*
|
||||
* @param[out] p_swi Points to a place where the allocated SWI instance
|
||||
* number is to be stored.
|
||||
* @param[in] event_handler Event handler function.
|
||||
* If NULL, no interrupt will be enabled.
|
||||
* It can be NULL only if the EGU driver is enabled.
|
||||
* For classic SWI, it must be a valid handler pointer.
|
||||
* @param[in] irq_priority Interrupt priority.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The SWI was successfully allocated.
|
||||
* @retval NRFX_ERROR_NO_MEM There is no available SWI to be used.
|
||||
*/
|
||||
nrfx_err_t nrfx_swi_alloc(nrfx_swi_t * p_swi,
|
||||
nrfx_swi_handler_t event_handler,
|
||||
uint32_t irq_priority);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an allocated SWI interrupt.
|
||||
*
|
||||
* Use @ref nrfx_swi_int_enable to re-enable the interrupt.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
*/
|
||||
void nrfx_swi_int_disable(nrfx_swi_t swi);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling an allocated SWI interrupt.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
*/
|
||||
void nrfx_swi_int_enable(nrfx_swi_t swi);
|
||||
|
||||
/**
|
||||
* @brief Function for freeing a previously allocated SWI.
|
||||
*
|
||||
* @param[in,out] p_swi SWI instance to free. The value is changed to
|
||||
* @ref NRFX_SWI_UNALLOCATED on success.
|
||||
*/
|
||||
void nrfx_swi_free(nrfx_swi_t * p_swi);
|
||||
|
||||
/** @brief Function for freeing all allocated SWIs. */
|
||||
void nrfx_swi_all_free(void);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the SWI.
|
||||
*
|
||||
* @param[in] swi SWI to trigger.
|
||||
* @param[in] flag_number Number of user flag to trigger.
|
||||
*/
|
||||
void nrfx_swi_trigger(nrfx_swi_t swi,
|
||||
uint8_t flag_number);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified SWI is currently allocated.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
*
|
||||
* @retval true The SWI instance is allocated.
|
||||
* @retval false The SWI instance is not allocated.
|
||||
*/
|
||||
bool nrfx_swi_is_allocated(nrfx_swi_t swi);
|
||||
|
||||
#if NRFX_CHECK(NRFX_EGU_ENABLED) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for returning the base address of the EGU peripheral
|
||||
* associated with the specified SWI instance.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
*
|
||||
* @return EGU base address or NULL if the specified SWI instance number
|
||||
* is too high.
|
||||
*/
|
||||
__STATIC_INLINE NRF_EGU_Type * nrfx_swi_egu_instance_get(nrfx_swi_t swi)
|
||||
{
|
||||
#if (EGU_COUNT < SWI_COUNT)
|
||||
if (swi >= EGU_COUNT)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
uint32_t offset = ((uint32_t)swi) * ((uint32_t)NRF_EGU1 - (uint32_t)NRF_EGU0);
|
||||
return (NRF_EGU_Type *)((uint32_t)NRF_EGU0 + offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for returning the EGU trigger task address.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
* @param[in] channel Number of the EGU channel.
|
||||
*
|
||||
* @return Address of the EGU trigger task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_swi_task_trigger_address_get(nrfx_swi_t swi,
|
||||
uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(nrfx_swi_is_allocated(swi));
|
||||
|
||||
NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
|
||||
#if (EGU_COUNT < SWI_COUNT)
|
||||
if (p_egu == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (uint32_t)nrf_egu_task_trigger_address_get(p_egu, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for returning the EGU-triggered event address.
|
||||
*
|
||||
* @param[in] swi SWI instance.
|
||||
* @param[in] channel Number of the EGU channel.
|
||||
*
|
||||
* @return Address of the EGU-triggered event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_swi_event_triggered_address_get(nrfx_swi_t swi,
|
||||
uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(nrfx_swi_is_allocated(swi));
|
||||
|
||||
NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
|
||||
#if (EGU_COUNT < SWI_COUNT)
|
||||
if (p_egu == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (uint32_t)nrf_egu_event_triggered_address_get(p_egu, channel);
|
||||
}
|
||||
|
||||
#endif // NRFX_CHECK(NRFX_EGU_ENABLED) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
void nrfx_swi_0_irq_handler(void);
|
||||
void nrfx_swi_1_irq_handler(void);
|
||||
void nrfx_swi_2_irq_handler(void);
|
||||
void nrfx_swi_3_irq_handler(void);
|
||||
void nrfx_swi_4_irq_handler(void);
|
||||
void nrfx_swi_5_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_SWI_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -94,7 +94,7 @@ void nrfx_temp_uninit(void);
|
||||
* @return Temperature measurement result in a 2's complement signed value
|
||||
* representation.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrfx_temp_result_get(void);
|
||||
NRFX_STATIC_INLINE int32_t nrfx_temp_result_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for calculating the temperature value in Celsius scale from raw data.
|
||||
@@ -133,14 +133,12 @@ int32_t nrfx_temp_calculate(int32_t raw_measurement);
|
||||
*/
|
||||
nrfx_err_t nrfx_temp_measure(void);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE int32_t nrfx_temp_result_get(void)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE int32_t nrfx_temp_result_get(void)
|
||||
{
|
||||
return nrf_temp_result_get(NRF_TEMP);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -95,14 +95,21 @@ typedef struct
|
||||
void * p_context; ///< Context passed to interrupt handler.
|
||||
} nrfx_timer_config_t;
|
||||
|
||||
/** @brief Timer driver instance default configuration. */
|
||||
#define NRFX_TIMER_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.frequency = (nrf_timer_frequency_t)NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY,\
|
||||
.mode = (nrf_timer_mode_t)NRFX_TIMER_DEFAULT_CONFIG_MODE, \
|
||||
.bit_width = (nrf_timer_bit_width_t)NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH,\
|
||||
.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.p_context = NULL \
|
||||
/**
|
||||
* @brief TIMER driver default configuration.
|
||||
*
|
||||
* This configuration sets up TIMER with the following options:
|
||||
* - frequency: 16 MHz
|
||||
* - works as timer
|
||||
* - width: 16 bit
|
||||
*/
|
||||
#define NRFX_TIMER_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.frequency = NRF_TIMER_FREQ_16MHz, \
|
||||
.mode = NRF_TIMER_MODE_TIMER, \
|
||||
.bit_width = NRF_TIMER_BIT_WIDTH_16, \
|
||||
.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.p_context = NULL \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +135,7 @@ typedef void (* nrfx_timer_event_handler_t)(nrf_timer_event_t event_type,
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The instance is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_timer_init(nrfx_timer_t const * const p_instance,
|
||||
nrfx_err_t nrfx_timer_init(nrfx_timer_t const * p_instance,
|
||||
nrfx_timer_config_t const * p_config,
|
||||
nrfx_timer_event_handler_t timer_event_handler);
|
||||
|
||||
@@ -137,14 +144,14 @@ nrfx_err_t nrfx_timer_init(nrfx_timer_t const * const p_instance,
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_uninit(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_uninit(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for turning on the timer.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_enable(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_enable(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for turning off the timer.
|
||||
@@ -154,7 +161,7 @@ void nrfx_timer_enable(nrfx_timer_t const * const p_instance);
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_disable(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_disable(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the timer state.
|
||||
@@ -164,35 +171,35 @@ void nrfx_timer_disable(nrfx_timer_t const * const p_instance);
|
||||
* @retval true Timer is enabled.
|
||||
* @retval false Timer is not enabled.
|
||||
*/
|
||||
bool nrfx_timer_is_enabled(nrfx_timer_t const * const p_instance);
|
||||
bool nrfx_timer_is_enabled(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for pausing the timer.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_pause(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_pause(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for resuming the timer.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_resume(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_resume(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the timer.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_clear(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_clear(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for incrementing the timer.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_timer_increment(nrfx_timer_t const * const p_instance);
|
||||
void nrfx_timer_increment(nrfx_timer_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified timer task.
|
||||
@@ -202,8 +209,8 @@ void nrfx_timer_increment(nrfx_timer_t const * const p_instance);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_task_t timer_task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_task_t timer_task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified timer capture task.
|
||||
@@ -213,8 +220,8 @@ __STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified timer event.
|
||||
@@ -224,8 +231,8 @@ __STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_event_t timer_event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_event_t timer_event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified timer compare event.
|
||||
@@ -235,8 +242,8 @@ __STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for capturing the timer value.
|
||||
@@ -246,8 +253,8 @@ __STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const
|
||||
*
|
||||
* @return Captured value.
|
||||
*/
|
||||
uint32_t nrfx_timer_capture(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
uint32_t nrfx_timer_capture(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the capture value from the specified channel.
|
||||
@@ -259,8 +266,8 @@ uint32_t nrfx_timer_capture(nrfx_timer_t const * const p_instance,
|
||||
*
|
||||
* @return Captured value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer channel in compare mode.
|
||||
@@ -270,10 +277,10 @@ __STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_ins
|
||||
* @param[in] cc_value Compare value.
|
||||
* @param[in] enable_int Enable or disable the interrupt for the compare channel.
|
||||
*/
|
||||
void nrfx_timer_compare(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value,
|
||||
bool enable_int);
|
||||
void nrfx_timer_compare(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value,
|
||||
bool enable_int);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer channel in the extended compare mode.
|
||||
@@ -285,11 +292,11 @@ void nrfx_timer_compare(nrfx_timer_t const * const p_instance,
|
||||
* and the timer task (STOP or CLEAR).
|
||||
* @param[in] enable_int Enable or disable the interrupt for the compare channel.
|
||||
*/
|
||||
void nrfx_timer_extended_compare(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value,
|
||||
nrf_timer_short_mask_t timer_short_mask,
|
||||
bool enable_int);
|
||||
void nrfx_timer_extended_compare(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value,
|
||||
nrf_timer_short_mask_t timer_short_mask,
|
||||
bool enable_int);
|
||||
|
||||
/**
|
||||
* @brief Function for converting time in microseconds to timer ticks.
|
||||
@@ -299,8 +306,8 @@ void nrfx_timer_extended_compare(nrfx_timer_t const * const p_instance,
|
||||
*
|
||||
* @return Number of ticks.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_instance,
|
||||
uint32_t time_us);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * p_instance,
|
||||
uint32_t time_us);
|
||||
|
||||
/**
|
||||
* @brief Function for converting time in milliseconds to timer ticks.
|
||||
@@ -310,8 +317,8 @@ __STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_ins
|
||||
*
|
||||
* @return Number of ticks.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_instance,
|
||||
uint32_t time_ms);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * p_instance,
|
||||
uint32_t time_ms);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling timer compare interrupt.
|
||||
@@ -319,8 +326,8 @@ __STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_ins
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] channel Compare channel.
|
||||
*/
|
||||
void nrfx_timer_compare_int_enable(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel);
|
||||
void nrfx_timer_compare_int_enable(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling timer compare interrupt.
|
||||
@@ -328,59 +335,54 @@ void nrfx_timer_compare_int_enable(nrfx_timer_t const * const p_instance,
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] channel Compare channel.
|
||||
*/
|
||||
void nrfx_timer_compare_int_disable(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel);
|
||||
void nrfx_timer_compare_int_disable(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_task_t timer_task)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_task_t timer_task)
|
||||
{
|
||||
return (uint32_t)nrf_timer_task_address_get(p_instance->p_reg, timer_task);
|
||||
return nrf_timer_task_address_get(p_instance->p_reg, timer_task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel)
|
||||
{
|
||||
NRFX_ASSERT(channel < p_instance->cc_channel_count);
|
||||
return (uint32_t)nrf_timer_task_address_get(p_instance->p_reg,
|
||||
nrf_timer_capture_task_get(channel));
|
||||
return nrf_timer_task_address_get(p_instance->p_reg, nrf_timer_capture_task_get(channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_event_t timer_event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_event_t timer_event)
|
||||
{
|
||||
return (uint32_t)nrf_timer_event_address_get(p_instance->p_reg, timer_event);
|
||||
return nrf_timer_event_address_get(p_instance->p_reg, timer_event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * const p_instance,
|
||||
uint32_t channel)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * p_instance,
|
||||
uint32_t channel)
|
||||
{
|
||||
NRFX_ASSERT(channel < p_instance->cc_channel_count);
|
||||
return (uint32_t)nrf_timer_event_address_get(p_instance->p_reg,
|
||||
nrf_timer_compare_event_get(channel));
|
||||
return nrf_timer_event_address_get(p_instance->p_reg, nrf_timer_compare_event_get(channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * p_instance,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
{
|
||||
return nrf_timer_cc_read(p_instance->p_reg, cc_channel);
|
||||
return nrf_timer_cc_get(p_instance->p_reg, cc_channel);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_instance,
|
||||
uint32_t timer_us)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * p_instance,
|
||||
uint32_t timer_us)
|
||||
{
|
||||
return nrf_timer_us_to_ticks(timer_us, nrf_timer_frequency_get(p_instance->p_reg));
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_instance,
|
||||
uint32_t timer_ms)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * p_instance,
|
||||
uint32_t timer_ms)
|
||||
{
|
||||
return nrf_timer_ms_to_ticks(timer_ms, nrf_timer_frequency_get(p_instance->p_reg));
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
#define NRFX_TWI_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <nrfx_twi_twim.h>
|
||||
#include <hal/nrf_twi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -84,14 +85,23 @@ typedef struct
|
||||
bool hold_bus_uninit; ///< Hold pull up state on GPIO pins after uninit.
|
||||
} nrfx_twi_config_t;
|
||||
|
||||
/** @brief The default configuration of the TWI master driver instance. */
|
||||
#define NRFX_TWI_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.frequency = (nrf_twi_frequency_t)NRFX_TWI_DEFAULT_CONFIG_FREQUENCY, \
|
||||
.scl = 31, \
|
||||
.sda = 31, \
|
||||
.interrupt_priority = NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hold_bus_uninit = NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \
|
||||
/**
|
||||
* @brief TWI master driver instance default configuration.
|
||||
*
|
||||
* This configuration sets up TWI with the following options:
|
||||
* - clock frequency: 100 kHz
|
||||
* - disable bus holding after uninit
|
||||
*
|
||||
* @param[in] _pin_scl SCL pin.
|
||||
* @param[in] _pin_sda SDA pin.
|
||||
*/
|
||||
#define NRFX_TWI_DEFAULT_CONFIG(_pin_scl, _pin_sda) \
|
||||
{ \
|
||||
.scl = _pin_scl, \
|
||||
.sda = _pin_sda, \
|
||||
.frequency = NRF_TWI_FREQ_100K, \
|
||||
.interrupt_priority = NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hold_bus_uninit = false, \
|
||||
}
|
||||
|
||||
/** @brief Flag indicating that the interrupt after each transfer will be suppressed, and the event handler will not be called. */
|
||||
@@ -106,7 +116,9 @@ typedef enum
|
||||
{
|
||||
NRFX_TWI_EVT_DONE, ///< Transfer completed event.
|
||||
NRFX_TWI_EVT_ADDRESS_NACK, ///< Error event: NACK received after sending the address.
|
||||
NRFX_TWI_EVT_DATA_NACK ///< Error event: NACK received after sending a data byte.
|
||||
NRFX_TWI_EVT_DATA_NACK, ///< Error event: NACK received after sending a data byte.
|
||||
NRFX_TWI_EVT_OVERRUN, ///< Error event: The unread data is replaced by new data.
|
||||
NRFX_TWI_EVT_BUS_ERROR ///< Error event: An unexpected transition occurred on the bus.
|
||||
} nrfx_twi_evt_type_t;
|
||||
|
||||
/** @brief TWI master driver transfer types. */
|
||||
@@ -226,70 +238,10 @@ void nrfx_twi_enable(nrfx_twi_t const * p_instance);
|
||||
*/
|
||||
void nrfx_twi_disable(nrfx_twi_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for sending data to a TWI slave.
|
||||
*
|
||||
* The transmission will be stopped when an error occurs. If a transfer is ongoing,
|
||||
* the function returns the error code @ref NRFX_ERROR_BUSY.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_twi_xfer instead.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] address Address of a specific slave device (only 7 LSB).
|
||||
* @param[in] p_data Pointer to a transmit buffer.
|
||||
* @param[in] length Number of bytes to send.
|
||||
* @param[in] no_stop If set, the stop condition is not generated on the bus
|
||||
* after the transfer has completed successfully (allowing
|
||||
* for a repeated start in the next transfer).
|
||||
*
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
|
||||
* @retval NRFX_ERROR_INVALID_STATE RX transaction is suspended on bus.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK Negative acknowledgement (NACK) is received after sending
|
||||
* the address in polling mode.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK Negative acknowledgement (NACK) is received after sending
|
||||
* a data byte in polling mode.
|
||||
*/
|
||||
nrfx_err_t nrfx_twi_tx(nrfx_twi_t const * p_instance,
|
||||
uint8_t address,
|
||||
uint8_t const * p_data,
|
||||
size_t length,
|
||||
bool no_stop);
|
||||
|
||||
/**
|
||||
* @brief Function for reading data from a TWI slave.
|
||||
*
|
||||
* The transmission will be stopped when an error occurs. If a transfer is ongoing,
|
||||
* the function returns the error code @ref NRFX_ERROR_BUSY.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_twi_xfer instead.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] address Address of a specific slave device (only 7 LSB).
|
||||
* @param[in] p_data Pointer to a receive buffer.
|
||||
* @param[in] length Number of bytes to be received.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
|
||||
* @retval NRFX_ERROR_INVALID_STATE TX transaction is suspended on bus.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK Negative acknowledgement (NACK) is received after sending
|
||||
* the address in polling mode.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK Negative acknowledgement (NACK) is received after sending
|
||||
* a data byte in polling mode.
|
||||
*/
|
||||
nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
|
||||
uint8_t address,
|
||||
uint8_t * p_data,
|
||||
size_t length);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for performing a TWI transfer.
|
||||
*
|
||||
* The following transfer types can be configured (@ref nrfx_twi_xfer_desc_t::type):
|
||||
* The following transfer types can be configured (@ref nrfx_twi_xfer_desc_t.type):
|
||||
* - @ref NRFX_TWI_XFER_TXRX - Write operation followed by a read operation (without STOP condition in between).
|
||||
* - @ref NRFX_TWI_XFER_TXTX - Write operation followed by a write operation (without STOP condition in between).
|
||||
* - @ref NRFX_TWI_XFER_TX - Write operation (with or without STOP condition).
|
||||
@@ -305,7 +257,7 @@ nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
|
||||
*
|
||||
* @note
|
||||
* Some flag combinations are invalid:
|
||||
* - @ref NRFX_TWI_FLAG_TX_NO_STOP with @ref nrfx_twi_xfer_desc_t::type different than @ref NRFX_TWI_XFER_TX
|
||||
* - @ref NRFX_TWI_FLAG_TX_NO_STOP with @ref nrfx_twi_xfer_desc_t.type different than @ref NRFX_TWI_XFER_TX
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_xfer_desc Pointer to the transfer descriptor.
|
||||
@@ -314,7 +266,7 @@ nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
|
||||
* @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
|
||||
* @retval NRFX_ERROR_INTERNAL An unexpected transition occurred on the bus.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Other direction of transaction is suspended on the bus.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data (TXRX and RX)
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK Negative acknowledgement (NACK) is received after sending
|
||||
@@ -343,7 +295,7 @@ bool nrfx_twi_is_busy(nrfx_twi_t const * p_instance);
|
||||
*
|
||||
* @return Data count.
|
||||
*/
|
||||
size_t nrfx_twi_data_count_get(nrfx_twi_t const * const p_instance);
|
||||
size_t nrfx_twi_data_count_get(nrfx_twi_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a STOPPED TWI event.
|
||||
@@ -357,6 +309,30 @@ size_t nrfx_twi_data_count_get(nrfx_twi_t const * const p_instance);
|
||||
*/
|
||||
uint32_t nrfx_twi_stopped_event_get(nrfx_twi_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for recovering the bus.
|
||||
*
|
||||
* This function checks if the bus is not stuck because of a slave holding the SDA line in the low state,
|
||||
* and if needed it performs required number of pulses on the SCL line to make the slave release the SDA line.
|
||||
* Finally, the function generates a STOP condition on the bus to put it into a known state.
|
||||
*
|
||||
* @note This function can be used only if the TWI driver is uninitialized.
|
||||
*
|
||||
* @param[in] scl_pin SCL pin number.
|
||||
* @param[in] sda_pin SDA pin number.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Bus recovery was successful.
|
||||
* @retval NRFX_ERROR_INTERNAL Bus recovery failed.
|
||||
*/
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_twi_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_twi_bus_recover(uint32_t scl_pin, uint32_t sda_pin)
|
||||
{
|
||||
return nrfx_twi_twim_bus_recover(scl_pin, sda_pin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
+11
-46
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -29,54 +29,19 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_TWI_TWIM_H
|
||||
#define NRFX_TWI_TWIM_H
|
||||
|
||||
#include <nrfx.h>
|
||||
#include "nrf_ecb.h"
|
||||
#include <string.h>
|
||||
|
||||
static uint8_t ecb_data[48]; ///< ECB data structure for RNG peripheral to access.
|
||||
static uint8_t* ecb_key; ///< Key: Starts at ecb_data
|
||||
static uint8_t* ecb_cleartext; ///< Cleartext: Starts at ecb_data + 16 bytes.
|
||||
static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes.
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool nrf_ecb_init(void)
|
||||
{
|
||||
ecb_key = ecb_data;
|
||||
ecb_cleartext = ecb_data + 16;
|
||||
ecb_ciphertext = ecb_data + 32;
|
||||
nrfx_err_t nrfx_twi_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
|
||||
|
||||
NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data;
|
||||
return true;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf)
|
||||
{
|
||||
uint32_t counter = 0x1000000;
|
||||
if (src_buf != ecb_cleartext)
|
||||
{
|
||||
memcpy(ecb_cleartext,src_buf,16);
|
||||
}
|
||||
NRF_ECB->EVENTS_ENDECB = 0;
|
||||
NRF_ECB->TASKS_STARTECB = 1;
|
||||
while (NRF_ECB->EVENTS_ENDECB == 0)
|
||||
{
|
||||
counter--;
|
||||
if (counter == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NRF_ECB->EVENTS_ENDECB = 0;
|
||||
if (dest_buf != ecb_ciphertext)
|
||||
{
|
||||
memcpy(dest_buf,ecb_ciphertext,16);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void nrf_ecb_set_key(const uint8_t * key)
|
||||
{
|
||||
memcpy(ecb_key,key,16);
|
||||
}
|
||||
|
||||
|
||||
#endif // NRFX_TWI_TWIM_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
#define NRFX_TWIM_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <nrfx_twi_twim.h>
|
||||
#include <hal/nrf_twim.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -88,35 +89,48 @@ typedef struct
|
||||
bool hold_bus_uninit; ///< Hold pull up state on GPIO pins after uninit.
|
||||
} nrfx_twim_config_t;
|
||||
|
||||
/** @brief TWI master driver instance default configuration. */
|
||||
#define NRFX_TWIM_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.scl = 31, \
|
||||
.sda = 31, \
|
||||
.frequency = (nrf_twim_frequency_t)NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY, \
|
||||
.interrupt_priority = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hold_bus_uninit = NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \
|
||||
/**
|
||||
* @brief TWIM driver default configuration.
|
||||
*
|
||||
* This configuration sets up TWIM with the following options:
|
||||
* - clock frequency: 100 kHz
|
||||
* - disable bus holding after uninit
|
||||
*
|
||||
* @param[in] _pin_scl SCL pin.
|
||||
* @param[in] _pin_sda SDA pin.
|
||||
*/
|
||||
#define NRFX_TWIM_DEFAULT_CONFIG(_pin_scl, _pin_sda) \
|
||||
{ \
|
||||
.scl = _pin_scl, \
|
||||
.sda = _pin_sda, \
|
||||
.frequency = NRF_TWIM_FREQ_100K, \
|
||||
.interrupt_priority = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hold_bus_uninit = false, \
|
||||
}
|
||||
|
||||
/** @brief Flag indicating that TX buffer address will be incremented after the transfer. */
|
||||
#define NRFX_TWIM_FLAG_TX_POSTINC (1UL << 0)
|
||||
#define NRFX_TWIM_FLAG_TX_POSTINC (1UL << 0)
|
||||
/** @brief Flag indicating that RX buffer address will be incremented after the transfer. */
|
||||
#define NRFX_TWIM_FLAG_RX_POSTINC (1UL << 1)
|
||||
#define NRFX_TWIM_FLAG_RX_POSTINC (1UL << 1)
|
||||
/** @brief Flag indicating that the interrupt after each transfer will be suppressed, and the event handler will not be called. */
|
||||
#define NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER (1UL << 2)
|
||||
#define NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER (1UL << 2)
|
||||
/** @brief Flag indicating that the transfer will be set up, but not started. */
|
||||
#define NRFX_TWIM_FLAG_HOLD_XFER (1UL << 3)
|
||||
#define NRFX_TWIM_FLAG_HOLD_XFER (1UL << 3)
|
||||
/** @brief Flag indicating that the transfer will be executed multiple times. */
|
||||
#define NRFX_TWIM_FLAG_REPEATED_XFER (1UL << 4)
|
||||
#define NRFX_TWIM_FLAG_REPEATED_XFER (1UL << 4)
|
||||
/** @brief Flag indicating that the TX transfer will not end with a stop condition. */
|
||||
#define NRFX_TWIM_FLAG_TX_NO_STOP (1UL << 5)
|
||||
#define NRFX_TWIM_FLAG_TX_NO_STOP (1UL << 5)
|
||||
/** @brief Flag indicating that checks for spurious STOP condition will not be performed. */
|
||||
#define NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK (1UL << 6)
|
||||
|
||||
/** @brief TWI master driver event types. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_TWIM_EVT_DONE, ///< Transfer completed event.
|
||||
NRFX_TWIM_EVT_ADDRESS_NACK, ///< Error event: NACK received after sending the address.
|
||||
NRFX_TWIM_EVT_DATA_NACK ///< Error event: NACK received after sending a data byte.
|
||||
NRFX_TWIM_EVT_DATA_NACK, ///< Error event: NACK received after sending a data byte.
|
||||
NRFX_TWIM_EVT_OVERRUN, ///< Error event: The unread data is replaced by new data.
|
||||
NRFX_TWIM_EVT_BUS_ERROR ///< Error event: An unexpected transition occurred on the bus.
|
||||
} nrfx_twim_evt_type_t;
|
||||
|
||||
/** @brief TWI master driver transfer types. */
|
||||
@@ -236,73 +250,10 @@ void nrfx_twim_enable(nrfx_twim_t const * p_instance);
|
||||
*/
|
||||
void nrfx_twim_disable(nrfx_twim_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for sending data to a TWI slave.
|
||||
*
|
||||
* The transmission will be stopped when an error occurs. If a transfer is ongoing,
|
||||
* the function returns the error code @ref NRFX_ERROR_BUSY.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_twim_xfer instead.
|
||||
*
|
||||
* @note Peripherals using EasyDMA (including TWIM) require the transfer buffers
|
||||
* to be placed in the Data RAM region. If this condition is not met,
|
||||
* this function fails with the error code NRFX_ERROR_INVALID_ADDR.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] address Address of a specific slave device (only 7 LSB).
|
||||
* @param[in] p_data Pointer to a transmit buffer.
|
||||
* @param[in] length Number of bytes to send. Maximum possible length is
|
||||
* dependent on the used SoC (see the MAXCNT register
|
||||
* description in the Product Specification). The driver
|
||||
* checks it with assertion.
|
||||
* @param[in] no_stop If set, the stop condition is not generated on the bus
|
||||
* after the transfer has completed successfully (allowing
|
||||
* for a repeated start in the next transfer).
|
||||
*
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
|
||||
*/
|
||||
nrfx_err_t nrfx_twim_tx(nrfx_twim_t const * p_instance,
|
||||
uint8_t address,
|
||||
uint8_t const * p_data,
|
||||
size_t length,
|
||||
bool no_stop);
|
||||
|
||||
/**
|
||||
* @brief Function for reading data from a TWI slave.
|
||||
*
|
||||
* The transmission will be stopped when an error occurs. If a transfer is ongoing,
|
||||
* the function returns the error code @ref NRFX_ERROR_BUSY.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrfx_twim_xfer instead.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] address Address of a specific slave device (only 7 LSB).
|
||||
* @param[in] p_data Pointer to a receive buffer.
|
||||
* @param[in] length Number of bytes to be received. Maximum possible length
|
||||
* is dependent on the used SoC (see the MAXCNT register
|
||||
* description in the Product Specification). The driver
|
||||
* checks it with assertion.
|
||||
*
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
|
||||
*/
|
||||
nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
|
||||
uint8_t address,
|
||||
uint8_t * p_data,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for performing a TWI transfer.
|
||||
*
|
||||
* The following transfer types can be configured (@ref nrfx_twim_xfer_desc_t::type):
|
||||
* The following transfer types can be configured (@ref nrfx_twim_xfer_desc_t.type):
|
||||
* - @ref NRFX_TWIM_XFER_TXRX - Write operation followed by a read operation (without STOP condition in between).
|
||||
* - @ref NRFX_TWIM_XFER_TXTX - Write operation followed by a write operation (without STOP condition in between).
|
||||
* - @ref NRFX_TWIM_XFER_TX - Write operation (with or without STOP condition).
|
||||
@@ -323,13 +274,17 @@ nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
|
||||
* the driver does not set the driver instance into busy state, so you must ensure that the next transfers are set up
|
||||
* when TWIM is not active.
|
||||
* - @ref NRFX_TWIM_FLAG_TX_NO_STOP - No stop condition after the TX transfer.
|
||||
* - @ref NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK - Checks for spurious STOP conditions are disabled.
|
||||
* Used together with @ref NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER can result in lower power consumption
|
||||
* when transfers are triggered externally and CPU is sleeping.
|
||||
* Use only with I2C standard-compliant slave devices.
|
||||
*
|
||||
* @note
|
||||
* Some flag combinations are invalid:
|
||||
* - @ref NRFX_TWIM_FLAG_TX_NO_STOP with @ref nrfx_twim_xfer_desc_t::type different than @ref NRFX_TWIM_XFER_TX
|
||||
* - @ref NRFX_TWIM_FLAG_REPEATED_XFER with @ref nrfx_twim_xfer_desc_t::type set to @ref NRFX_TWIM_XFER_TXTX
|
||||
* - @ref NRFX_TWIM_FLAG_TX_NO_STOP with @ref nrfx_twim_xfer_desc_t.type different than @ref NRFX_TWIM_XFER_TX
|
||||
* - @ref NRFX_TWIM_FLAG_REPEATED_XFER with @ref nrfx_twim_xfer_desc_t.type set to @ref NRFX_TWIM_XFER_TXTX
|
||||
*
|
||||
* If @ref nrfx_twim_xfer_desc_t::type is set to @ref NRFX_TWIM_XFER_TX and the @ref NRFX_TWIM_FLAG_TX_NO_STOP and @ref NRFX_TWIM_FLAG_REPEATED_XFER
|
||||
* If @ref nrfx_twim_xfer_desc_t.type is set to @ref NRFX_TWIM_XFER_TX and the @ref NRFX_TWIM_FLAG_TX_NO_STOP and @ref NRFX_TWIM_FLAG_REPEATED_XFER
|
||||
* flags are set, two tasks must be used to trigger a transfer: TASKS_RESUME followed by TASKS_STARTTX. If no stop condition is generated,
|
||||
* TWIM is in SUSPENDED state. Therefore, it must be resumed before the transfer can be started.
|
||||
*
|
||||
@@ -341,13 +296,14 @@ nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
|
||||
* @param[in] p_xfer_desc Pointer to the transfer descriptor.
|
||||
* @param[in] flags Transfer options (0 for default settings).
|
||||
*
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
|
||||
* @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data RAM region.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte.
|
||||
* @retval NRFX_SUCCESS The procedure is successful.
|
||||
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
|
||||
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
|
||||
* @retval NRFX_ERROR_INTERNAL An unexpected transition occurred on the bus.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data RAM region.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address.
|
||||
* @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte.
|
||||
*/
|
||||
nrfx_err_t nrfx_twim_xfer(nrfx_twim_t const * p_instance,
|
||||
nrfx_twim_xfer_desc_t const * p_xfer_desc,
|
||||
@@ -389,6 +345,30 @@ uint32_t nrfx_twim_start_task_get(nrfx_twim_t const * p_instance, nrfx_twim_xfer
|
||||
*/
|
||||
uint32_t nrfx_twim_stopped_event_get(nrfx_twim_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for recovering the bus.
|
||||
*
|
||||
* This function checks if the bus is not stuck because of a slave holding the SDA line in the low state,
|
||||
* and if needed it performs required number of pulses on the SCL line to make the slave release the SDA line.
|
||||
* Finally, the function generates a STOP condition on the bus to put it into a known state.
|
||||
*
|
||||
* @note This function can be used only if the TWIM driver is uninitialized.
|
||||
*
|
||||
* @param[in] scl_pin SCL pin number.
|
||||
* @param[in] sda_pin SDA pin number.
|
||||
*
|
||||
* @retval NRFX_SUCCESS Bus recovery was successful.
|
||||
* @retval NRFX_ERROR_INTERNAL Bus recovery failed.
|
||||
*/
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE nrfx_err_t nrfx_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin)
|
||||
{
|
||||
return nrfx_twi_twim_bus_recover(scl_pin, sda_pin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
void nrfx_twim_0_irq_handler(void);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -145,16 +145,26 @@ typedef struct
|
||||
uint8_t interrupt_priority; //!< The priority of interrupt for the module to be set.
|
||||
} nrfx_twis_config_t;
|
||||
|
||||
/** @brief Generate the default configuration for the TWIS driver instance. */
|
||||
#define NRFX_TWIS_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.addr = { NRFX_TWIS_DEFAULT_CONFIG_ADDR0, \
|
||||
NRFX_TWIS_DEFAULT_CONFIG_ADDR1 }, \
|
||||
.scl = 31, \
|
||||
.sda = 31, \
|
||||
.scl_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL, \
|
||||
.sda_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL, \
|
||||
.interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
/**
|
||||
* @brief TWIS driver default configuration.
|
||||
*
|
||||
* This configuration sets up TWIS with the following options:
|
||||
* - second slave address disabled
|
||||
* - SCL pull-up disabled
|
||||
* - SDA pull-up disabled
|
||||
*
|
||||
* @param[in] _pin_scl SCL pin.
|
||||
* @param[in] _pin_sda SDA pin.
|
||||
* @param[in] _addr Slave address on TWI bus.
|
||||
*/
|
||||
#define NRFX_TWIS_DEFAULT_CONFIG(_pin_scl, _pin_sda, _addr) \
|
||||
{ \
|
||||
.addr = { _addr, 0x00 }, \
|
||||
.scl = _pin_scl, \
|
||||
.scl_pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sda = _pin_sda, \
|
||||
.sda_pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +277,7 @@ nrfx_err_t nrfx_twis_tx_prepare(nrfx_twis_t const * p_instance,
|
||||
*
|
||||
* @return Number of bytes sent.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
|
||||
NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for preparing the data for receiving.
|
||||
@@ -301,7 +311,7 @@ nrfx_err_t nrfx_twis_rx_prepare(nrfx_twis_t const * p_instance,
|
||||
*
|
||||
* @return Number of bytes received.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
|
||||
NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the driver is busy right now.
|
||||
@@ -366,17 +376,17 @@ bool nrfx_twis_is_pending_tx(nrfx_twis_t const * p_instance);
|
||||
*/
|
||||
bool nrfx_twis_is_pending_rx(nrfx_twis_t const * p_instance);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
|
||||
{
|
||||
return nrf_twis_tx_amount_get(p_instance->p_reg);
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
|
||||
NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
|
||||
{
|
||||
return nrf_twis_rx_amount_get(p_instance->p_reg);
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -85,24 +85,54 @@ typedef struct
|
||||
uint32_t pselcts; ///< CTS pin number.
|
||||
uint32_t pselrts; ///< RTS pin number.
|
||||
void * p_context; ///< Context passed to interrupt handler.
|
||||
nrf_uart_hwfc_t hwfc; ///< Flow control configuration.
|
||||
nrf_uart_parity_t parity; ///< Parity configuration.
|
||||
nrf_uart_baudrate_t baudrate; ///< Baud rate.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
nrf_uart_config_t hal_cfg; ///< Parity, flow control and stop bits settings.
|
||||
} nrfx_uart_config_t;
|
||||
|
||||
/** @brief UART default configuration. */
|
||||
#define NRFX_UART_DEFAULT_CONFIG \
|
||||
#if defined(UART_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief UART additional stop bits configuration. */
|
||||
#define NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG \
|
||||
.stop = NRF_UART_STOP_ONE,
|
||||
#else
|
||||
#define NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG
|
||||
#endif
|
||||
|
||||
#if defined(UART_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief UART additional parity type configuration. */
|
||||
#define NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
|
||||
.paritytype = NRF_UART_PARITYTYPE_EVEN,
|
||||
#else
|
||||
#define NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief UART driver default configuration.
|
||||
*
|
||||
* This configuration sets up UART with the following options:
|
||||
* - hardware flow control disabled
|
||||
* - no parity bit
|
||||
* - one stop bit
|
||||
* - baudrate: 115200
|
||||
*
|
||||
* @param[in] _pin_tx TX pin.
|
||||
* @param[in] _pin_rx RX pin.
|
||||
*/
|
||||
#define NRFX_UART_DEFAULT_CONFIG(_pin_tx, _pin_rx) \
|
||||
{ \
|
||||
.pseltxd = NRF_UART_PSEL_DISCONNECTED, \
|
||||
.pselrxd = NRF_UART_PSEL_DISCONNECTED, \
|
||||
.pseltxd = _pin_tx, \
|
||||
.pselrxd = _pin_rx, \
|
||||
.pselcts = NRF_UART_PSEL_DISCONNECTED, \
|
||||
.pselrts = NRF_UART_PSEL_DISCONNECTED, \
|
||||
.p_context = NULL, \
|
||||
.hwfc = (nrf_uart_hwfc_t)NRFX_UART_DEFAULT_CONFIG_HWFC, \
|
||||
.parity = (nrf_uart_parity_t)NRFX_UART_DEFAULT_CONFIG_PARITY, \
|
||||
.baudrate = (nrf_uart_baudrate_t)NRFX_UART_DEFAULT_CONFIG_BAUDRATE, \
|
||||
.baudrate = NRF_UART_BAUDRATE_115200, \
|
||||
.interrupt_priority = NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hal_cfg = { \
|
||||
.hwfc = NRF_UART_HWFC_DISABLED, \
|
||||
.parity = NRF_UART_PARITY_EXCLUDED, \
|
||||
NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG \
|
||||
NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
|
||||
} \
|
||||
}
|
||||
|
||||
/** @brief Structure for the UART transfer completion event. */
|
||||
@@ -176,8 +206,8 @@ void nrfx_uart_uninit(nrfx_uart_t const * p_instance);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_task_t task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified UART event.
|
||||
@@ -187,8 +217,8 @@ __STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instan
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_event_t event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for sending data over UART.
|
||||
@@ -324,19 +354,19 @@ void nrfx_uart_rx_abort(nrfx_uart_t const * p_instance);
|
||||
uint32_t nrfx_uart_errorsrc_get(nrfx_uart_t const * p_instance);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_task_t task)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_task_t task)
|
||||
{
|
||||
return nrf_uart_task_address_get(p_instance->p_reg, task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
|
||||
nrf_uart_event_t event)
|
||||
{
|
||||
return nrf_uart_event_address_get(p_instance->p_reg, event);
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -94,24 +94,54 @@ typedef struct
|
||||
uint32_t pselcts; ///< CTS pin number.
|
||||
uint32_t pselrts; ///< RTS pin number.
|
||||
void * p_context; ///< Context passed to interrupt handler.
|
||||
nrf_uarte_hwfc_t hwfc; ///< Flow control configuration.
|
||||
nrf_uarte_parity_t parity; ///< Parity configuration.
|
||||
nrf_uarte_baudrate_t baudrate; ///< Baud rate.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
nrf_uarte_config_t hal_cfg; ///< Parity, flow control and stop bits settings.
|
||||
} nrfx_uarte_config_t;
|
||||
|
||||
/** @brief UARTE default configuration. */
|
||||
#define NRFX_UARTE_DEFAULT_CONFIG \
|
||||
#if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief UARTE additional stop bits configuration. */
|
||||
#define NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG \
|
||||
.stop = (nrf_uarte_stop_t)NRF_UARTE_STOP_ONE,
|
||||
#else
|
||||
#define NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG
|
||||
#endif
|
||||
|
||||
#if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief UARTE additional parity type configuration. */
|
||||
#define NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
|
||||
.paritytype = NRF_UARTE_PARITYTYPE_EVEN,
|
||||
#else
|
||||
#define NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief UARTE driver default configuration.
|
||||
*
|
||||
* This configuration sets up UARTE with the following options:
|
||||
* - hardware flow control disabled
|
||||
* - no parity bit
|
||||
* - one stop bit
|
||||
* - baudrate: 115200
|
||||
*
|
||||
* @param[in] _pin_tx TX pin.
|
||||
* @param[in] _pin_rx RX pin.
|
||||
*/
|
||||
#define NRFX_UARTE_DEFAULT_CONFIG(_pin_tx, _pin_rx) \
|
||||
{ \
|
||||
.pseltxd = NRF_UARTE_PSEL_DISCONNECTED, \
|
||||
.pselrxd = NRF_UARTE_PSEL_DISCONNECTED, \
|
||||
.pseltxd = _pin_tx, \
|
||||
.pselrxd = _pin_rx, \
|
||||
.pselcts = NRF_UARTE_PSEL_DISCONNECTED, \
|
||||
.pselrts = NRF_UARTE_PSEL_DISCONNECTED, \
|
||||
.p_context = NULL, \
|
||||
.hwfc = (nrf_uarte_hwfc_t)NRFX_UARTE_DEFAULT_CONFIG_HWFC, \
|
||||
.parity = (nrf_uarte_parity_t)NRFX_UARTE_DEFAULT_CONFIG_PARITY, \
|
||||
.baudrate = (nrf_uarte_baudrate_t)NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE, \
|
||||
.baudrate = NRF_UARTE_BAUDRATE_115200, \
|
||||
.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \
|
||||
.hal_cfg = { \
|
||||
.hwfc = NRF_UARTE_HWFC_DISABLED, \
|
||||
.parity = NRF_UARTE_PARITY_EXCLUDED, \
|
||||
NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG \
|
||||
NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
|
||||
} \
|
||||
}
|
||||
|
||||
/** @brief Structure for the UARTE transfer completion event. */
|
||||
@@ -185,8 +215,8 @@ void nrfx_uarte_uninit(nrfx_uarte_t const * p_instance);
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_task_t task);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified UARTE event.
|
||||
@@ -196,8 +226,8 @@ __STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_inst
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_event_t event);
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for sending data over UARTE.
|
||||
@@ -320,19 +350,19 @@ void nrfx_uarte_rx_abort(nrfx_uarte_t const * p_instance);
|
||||
uint32_t nrfx_uarte_errorsrc_get(nrfx_uarte_t const * p_instance);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_task_t task)
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_task_t task)
|
||||
{
|
||||
return nrf_uarte_task_address_get(p_instance->p_reg, task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
|
||||
nrf_uarte_event_t event)
|
||||
{
|
||||
return nrf_uarte_event_address_get(p_instance->p_reg, event);
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -187,11 +187,11 @@ typedef struct
|
||||
} sof; /**< Data available for @ref NRFX_USBD_EVT_SOF. */
|
||||
struct {
|
||||
nrfx_usbd_ep_t ep; /**< Endpoint number. */
|
||||
} isocrc;
|
||||
} isocrc; /**< Isochronouns channel endpoint number. */
|
||||
struct {
|
||||
nrfx_usbd_ep_t ep; /**< Endpoint number. */
|
||||
nrfx_usbd_ep_status_t status; /**< Status for the endpoint. */
|
||||
} eptransfer;
|
||||
} eptransfer; /**< Endpoint transfer status. */
|
||||
} data; /**< Union to store event data. */
|
||||
} nrfx_usbd_evt_t;
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_USBREG_H__
|
||||
#define NRFX_USBREG_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_usbreg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_usbreg USBREG driver
|
||||
* @{
|
||||
* @ingroup nrf_usbd
|
||||
* @ingroup nrf_power
|
||||
* @brief USB regulators (USBREG) peripheral driver.
|
||||
*/
|
||||
|
||||
/** @brief Events from USB power system */
|
||||
typedef enum {
|
||||
NRFX_USBREG_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */
|
||||
NRFX_USBREG_EVT_REMOVED, /**< USB power removed from the connector. */
|
||||
NRFX_USBREG_EVT_READY /**< USB power regulator ready. */
|
||||
} nrfx_usbreg_evt_t;
|
||||
|
||||
/**
|
||||
* @brief USB power state
|
||||
*
|
||||
* The single enumerator that holds all data about current state of USB
|
||||
* related POWER.
|
||||
*
|
||||
* Organized this way that higher power state has higher numeric value
|
||||
*/
|
||||
typedef enum {
|
||||
NRFX_USBREG_STATE_DISCONNECTED, /**< No power on USB lines detected. */
|
||||
NRFX_USBREG_STATE_CONNECTED, /**< The USB power is detected, but USB power regulator is not ready. */
|
||||
NRFX_USBREG_STATE_READY /**< From the power viewpoint, USB is ready for working. */
|
||||
} nrfx_usbreg_state_t;
|
||||
|
||||
/**
|
||||
* @brief Event handler for the USB-related power events.
|
||||
*
|
||||
* @param event Event type
|
||||
*/
|
||||
typedef void (*nrfx_usbreg_event_handler_t)(nrfx_usbreg_evt_t event);
|
||||
|
||||
/**
|
||||
* @brief The configuration of the USB-related power events.
|
||||
*
|
||||
* Configuration used to enable and configure USB power event handling.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrfx_usbreg_event_handler_t handler; //!< Event processing.
|
||||
uint8_t irq_priority; //!< Priority of the USBREG interrupt.
|
||||
} nrfx_usbreg_config_t;
|
||||
|
||||
/**
|
||||
* @brief Function for getting the USBREG handler.
|
||||
*
|
||||
* @return Handler of the USB power.
|
||||
*/
|
||||
nrfx_usbreg_event_handler_t nrfx_usbreg_handler_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the processing of USBREG events.
|
||||
*
|
||||
* Configures and sets up the USB power event processing.
|
||||
*
|
||||
* @param[in] p_config Configuration structure. Must not be NULL.
|
||||
*
|
||||
* @sa nrfx_usbreg_uninit
|
||||
*/
|
||||
void nrfx_usbreg_init(nrfx_usbreg_config_t const *p_config);
|
||||
|
||||
/** @brief Function for enabling the processing of USBREG events. */
|
||||
void nrfx_usbreg_enable(void);
|
||||
|
||||
/** @brief Function for disabling the processing of USBREG events. */
|
||||
void nrfx_usbreg_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitalizing the processing of USBREG events.
|
||||
*
|
||||
* @sa nrfx_usbreg_init
|
||||
*/
|
||||
void nrfx_usbreg_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the status of USBREG.
|
||||
*
|
||||
* @return Current USB power status.
|
||||
*/
|
||||
NRFX_STATIC_INLINE nrfx_usbreg_state_t nrfx_usbreg_usbstatus_get(void);
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE nrfx_usbreg_state_t nrfx_usbreg_usbstatus_get(void)
|
||||
{
|
||||
uint32_t status = nrf_usbreg_status_get(NRF_USBREGULATOR);
|
||||
if (0 == (status & NRF_USBREG_STATUS_VBUSDETECT_MASK))
|
||||
{
|
||||
return NRFX_USBREG_STATE_DISCONNECTED;
|
||||
}
|
||||
if (0 == (status & NRF_USBREG_STATUS_OUTPUTRDY_MASK))
|
||||
{
|
||||
return NRFX_USBREG_STATE_CONNECTED;
|
||||
}
|
||||
return NRFX_USBREG_STATE_READY;
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
void nrfx_usbreg_irq_handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_USBREG_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -48,11 +48,43 @@ extern "C" {
|
||||
|
||||
#if !NRFX_CHECK(NRFX_WDT_CONFIG_NO_IRQ) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief WDT instance interrupt priority configuration. */
|
||||
#define NRFX_WDT_IRQ_CONFIG .interrupt_priority = NRFX_WDT_CONFIG_IRQ_PRIORITY
|
||||
#define NRFX_WDT_IRQ_CONFIG .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY
|
||||
#else
|
||||
#define NRFX_WDT_IRQ_CONFIG
|
||||
#endif
|
||||
|
||||
/** @brief WDT event handler function type. */
|
||||
typedef void (*nrfx_wdt_event_handler_t)(void);
|
||||
|
||||
/** @brief WDT channel ID type. */
|
||||
typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id;
|
||||
|
||||
/** @brief Data structure of the Watchdog (WDT) driver instance. */
|
||||
typedef struct
|
||||
{
|
||||
NRF_WDT_Type * p_reg; ///< Pointer to a structure with WDT registers.
|
||||
uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
|
||||
} nrfx_wdt_t;
|
||||
|
||||
#ifndef __NRFX_DOXYGEN__
|
||||
enum {
|
||||
#if NRFX_CHECK(NRFX_WDT0_ENABLED)
|
||||
NRFX_WDT0_INST_IDX,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_WDT1_ENABLED)
|
||||
NRFX_WDT1_INST_IDX,
|
||||
#endif
|
||||
NRFX_WDT_ENABLED_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
/** @brief Macro for creating an instance of the WDT driver. */
|
||||
#define NRFX_WDT_INSTANCE(id) \
|
||||
{ \
|
||||
.p_reg = NRF_WDT##id, \
|
||||
.drv_inst_idx = NRFX_CONCAT_3(NRFX_WDT, id, _INST_IDX), \
|
||||
}
|
||||
|
||||
/**@brief Struct for WDT initialization. */
|
||||
typedef struct
|
||||
{
|
||||
@@ -63,92 +95,119 @@ typedef struct
|
||||
#endif
|
||||
} nrfx_wdt_config_t;
|
||||
|
||||
/** @brief WDT event handler function type. */
|
||||
typedef void (*nrfx_wdt_event_handler_t)(void);
|
||||
|
||||
/** @brief WDT channel ID type. */
|
||||
typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id;
|
||||
|
||||
/** @brief WDT driver default configuration. */
|
||||
#define NRFX_WDT_DEAFULT_CONFIG \
|
||||
{ \
|
||||
.behaviour = (nrf_wdt_behaviour_t)NRFX_WDT_CONFIG_BEHAVIOUR, \
|
||||
.reload_value = NRFX_WDT_CONFIG_RELOAD_VALUE, \
|
||||
NRFX_WDT_IRQ_CONFIG \
|
||||
}
|
||||
/**
|
||||
* @brief This function initializes the watchdog.
|
||||
* @brief WDT driver default configuration.
|
||||
*
|
||||
* This configuration sets up WDT with the following options:
|
||||
* - run when CPU is in SLEEP mode, pause when in HALT mode
|
||||
* - reload value: 2000 ms
|
||||
*/
|
||||
#define NRFX_WDT_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP, \
|
||||
.reload_value = 2000, \
|
||||
NRFX_WDT_IRQ_CONFIG \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the WDT driver instance.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_config Pointer to the structure with the initial configuration.
|
||||
* @param[in] wdt_event_handler Event handler provided by the user. Ignored when
|
||||
* @ref NRFX_WDT_CONFIG_NO_IRQ option is enabled.
|
||||
*
|
||||
* @return NRFX_SUCCESS on success, otherwise an error code.
|
||||
* @retval NRFX_SUCCESS Initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_wdt_init(nrfx_wdt_config_t const * p_config,
|
||||
nrfx_err_t nrfx_wdt_init(nrfx_wdt_t const * p_instance,
|
||||
nrfx_wdt_config_t const * p_config,
|
||||
nrfx_wdt_event_handler_t wdt_event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for allocating a watchdog channel.
|
||||
*
|
||||
* @note This function can not be called after nrfx_wdt_start(void).
|
||||
* @note This function can not be called after nrfx_wdt_start().
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[out] p_channel_id ID of granted channel.
|
||||
*
|
||||
* @return NRFX_SUCCESS on success, otherwise an error code.
|
||||
* @retval NRFX_SUCCESS The channel was successfully allocated.
|
||||
* @retval NRFX_ERROR_NO_MEM There is no available channel to be used.
|
||||
*/
|
||||
nrfx_err_t nrfx_wdt_channel_alloc(nrfx_wdt_channel_id * p_channel_id);
|
||||
nrfx_err_t nrfx_wdt_channel_alloc(nrfx_wdt_t const * p_instance,
|
||||
nrfx_wdt_channel_id * p_channel_id);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the watchdog.
|
||||
*
|
||||
* @note After calling this function the watchdog is started, so the user needs to feed all allocated
|
||||
* watchdog channels to avoid reset. At least one watchdog channel must be allocated.
|
||||
* @note After calling this function the watchdog is started, so the user needs to feed
|
||||
* all allocated watchdog channels to avoid reset. At least one watchdog channel
|
||||
* must be allocated.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_wdt_enable(void);
|
||||
void nrfx_wdt_enable(nrfx_wdt_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for feeding the watchdog.
|
||||
*
|
||||
* @details Function feeds all allocated watchdog channels.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrfx_wdt_feed(void);
|
||||
void nrfx_wdt_feed(nrfx_wdt_t const * p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for feeding an invidual watchdog channel.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] channel_id ID of watchdog channel.
|
||||
*/
|
||||
void nrfx_wdt_channel_feed(nrfx_wdt_channel_id channel_id);
|
||||
void nrfx_wdt_channel_feed(nrfx_wdt_t const * p_instance, nrfx_wdt_channel_id channel_id);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a requested task address for the WDT driver module.
|
||||
*
|
||||
* @param[in] task One of the peripheral tasks.
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] task One of the WDT tasks.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_wdt_ppi_task_addr(nrf_wdt_task_t task)
|
||||
{
|
||||
return nrf_wdt_task_address_get(task);
|
||||
}
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_wdt_task_address_get(nrfx_wdt_t const * p_instance,
|
||||
nrf_wdt_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a requested event address for the wdt driver module.
|
||||
* @brief Function for returning a requested event address for the WDT driver module.
|
||||
*
|
||||
* @param[in] event One of the peripheral events.
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] event One of the WDT events.
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_wdt_ppi_event_addr(nrf_wdt_event_t event)
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_wdt_event_address_get(nrfx_wdt_t const * p_instance,
|
||||
nrf_wdt_event_t event);
|
||||
|
||||
|
||||
#ifndef NRFX_DECLARE_ONLY
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_wdt_task_address_get(nrfx_wdt_t const * p_instance,
|
||||
nrf_wdt_task_t task)
|
||||
{
|
||||
return nrf_wdt_event_address_get(event);
|
||||
return nrf_wdt_task_address_get(p_instance->p_reg, task);
|
||||
}
|
||||
|
||||
NRFX_STATIC_INLINE uint32_t nrfx_wdt_event_address_get(nrfx_wdt_t const * p_instance,
|
||||
nrf_wdt_event_t event)
|
||||
{
|
||||
return nrf_wdt_event_address_get(p_instance->p_reg, event);
|
||||
}
|
||||
#endif // NRFX_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
void nrfx_wdt_irq_handler(void);
|
||||
void nrfx_wdt_0_irq_handler(void);
|
||||
void nrfx_wdt_1_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -156,4 +215,3 @@ void nrfx_wdt_irq_handler(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -43,6 +43,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NRFX_STATIC_INLINE
|
||||
#ifdef NRFX_DECLARE_ONLY
|
||||
#define NRFX_STATIC_INLINE
|
||||
#else
|
||||
#define NRFX_STATIC_INLINE __STATIC_INLINE
|
||||
#endif
|
||||
#endif // NRFX_STATIC_INLINE
|
||||
|
||||
#ifndef NRF_STATIC_INLINE
|
||||
#ifdef NRF_DECLARE_ONLY
|
||||
#define NRF_STATIC_INLINE
|
||||
#else
|
||||
#define NRF_STATIC_INLINE __STATIC_INLINE
|
||||
#endif
|
||||
#endif // NRF_STATIC_INLINE
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_common Common module
|
||||
* @{
|
||||
@@ -235,7 +251,7 @@ typedef enum
|
||||
* @retval true The pointed object is located in the Data RAM region.
|
||||
* @retval false The pointed object is not located in the Data RAM region.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
|
||||
NRF_STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if an object is aligned to a 32-bit word
|
||||
@@ -249,7 +265,7 @@ __STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
|
||||
* @retval true The pointed object is aligned to a 32-bit word.
|
||||
* @retval false The pointed object is not aligned to a 32-bit word.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
|
||||
NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the interrupt number for the specified peripheral.
|
||||
@@ -258,7 +274,7 @@ __STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
|
||||
*
|
||||
* @return Interrupt number associated with the pointed peripheral.
|
||||
*/
|
||||
__STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
|
||||
NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for converting an INTEN register bit position to the
|
||||
@@ -274,7 +290,7 @@ __STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
|
||||
*
|
||||
* @sa nrfx_event_to_bitpos
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
|
||||
NRF_STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
|
||||
|
||||
/**
|
||||
* @brief Function for converting an event identifier to the corresponding
|
||||
@@ -290,39 +306,39 @@ __STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
|
||||
*
|
||||
* @sa nrfx_bitpos_to_event
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE bool nrfx_is_in_ram(void const * p_object)
|
||||
NRF_STATIC_INLINE bool nrfx_is_in_ram(void const * p_object)
|
||||
{
|
||||
return ((((uint32_t)p_object) & 0xE0000000u) == 0x20000000u);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
|
||||
NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
|
||||
{
|
||||
return ((((uint32_t)p_object) & 0x3u) == 0u);
|
||||
}
|
||||
|
||||
__STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
|
||||
NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
|
||||
{
|
||||
return (IRQn_Type)NRFX_IRQ_NUMBER_GET(p_reg);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit)
|
||||
NRF_STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit)
|
||||
{
|
||||
static const uint32_t event_reg_offset = 0x100u;
|
||||
return event_reg_offset + (bit * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event)
|
||||
{
|
||||
static const uint32_t event_reg_offset = 0x100u;
|
||||
return (event - event_reg_offset) / sizeof(uint32_t);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,9 +34,6 @@
|
||||
#if NRFX_CHECK(NRFX_POWER_ENABLED)
|
||||
|
||||
#include <nrfx_power.h>
|
||||
#if defined(REGULATORS_PRESENT)
|
||||
#include <hal/nrf_regulators.h>
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_CLOCK_ENABLED)
|
||||
extern bool nrfx_clock_irq_enabled;
|
||||
@@ -106,12 +103,15 @@ nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config)
|
||||
return NRFX_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
#if NRF_POWER_HAS_VDDH
|
||||
nrf_power_dcdcen_vddh_set(p_config->dcdcenhv);
|
||||
#if NRF_POWER_HAS_DCDCEN_VDDH
|
||||
nrf_power_dcdcen_vddh_set(NRF_POWER, p_config->dcdcenhv);
|
||||
#elif NRF_REGULATORS_HAS_DCDCEN_VDDH
|
||||
nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS, p_config->dcdcenhv);
|
||||
#endif
|
||||
|
||||
#if NRF_POWER_HAS_DCDCEN
|
||||
nrf_power_dcdcen_set(p_config->dcdcen);
|
||||
#else
|
||||
nrf_power_dcdcen_set(NRF_POWER, p_config->dcdcen);
|
||||
#elif defined(REGULATORS_PRESENT)
|
||||
nrf_regulators_dcdcen_set(NRF_REGULATORS, p_config->dcdcen);
|
||||
#endif
|
||||
|
||||
@@ -132,19 +132,19 @@ void nrfx_power_uninit(void)
|
||||
{
|
||||
NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_POWER));
|
||||
}
|
||||
#if NRF_POWER_HAS_POFCON
|
||||
#if NRFX_POWER_SUPPORTS_POFCON
|
||||
nrfx_power_pof_uninit();
|
||||
#endif
|
||||
#if NRF_POWER_HAS_SLEEPEVT
|
||||
nrfx_power_sleepevt_uninit();
|
||||
#endif
|
||||
#if NRF_POWER_HAS_USBREG
|
||||
#if NRF_POWER_HAS_USBREG || defined(USBREG_PRESENT)
|
||||
nrfx_power_usbevt_uninit();
|
||||
#endif
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
#if NRF_POWER_HAS_POFCON
|
||||
#if NRFX_POWER_SUPPORTS_POFCON
|
||||
void nrfx_power_pof_init(nrfx_power_pofwarn_config_t const * p_config)
|
||||
{
|
||||
NRFX_ASSERT(p_config != NULL);
|
||||
@@ -159,27 +159,39 @@ void nrfx_power_pof_init(nrfx_power_pofwarn_config_t const * p_config)
|
||||
|
||||
void nrfx_power_pof_enable(nrfx_power_pofwarn_config_t const * p_config)
|
||||
{
|
||||
nrf_power_pofcon_set(true, p_config->thr);
|
||||
#if NRF_POWER_HAS_VDDH
|
||||
nrf_power_pofcon_vddh_set(p_config->thrvddh);
|
||||
#if NRF_POWER_HAS_POFCON
|
||||
nrf_power_pofcon_set(NRF_POWER, true, p_config->thr);
|
||||
#elif NRF_REGULATORS_HAS_POFCON
|
||||
nrf_regulators_pofcon_set(NRF_REGULATORS, true, p_config->thr);
|
||||
#endif
|
||||
|
||||
#if NRF_POWER_HAS_POFCON_VDDH
|
||||
nrf_power_pofcon_vddh_set(NRF_POWER, p_config->thrvddh);
|
||||
#elif NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
nrf_regulators_pofcon_vddh_set(NRF_REGULATORS, p_config->thrvddh);
|
||||
#endif
|
||||
|
||||
if (m_pofwarn_handler != NULL)
|
||||
{
|
||||
nrf_power_int_enable(NRF_POWER_INT_POFWARN_MASK);
|
||||
nrf_power_int_enable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
void nrfx_power_pof_disable(void)
|
||||
{
|
||||
nrf_power_pofcon_set(false, NRF_POWER_POFTHR_V27);
|
||||
nrf_power_int_disable(NRF_POWER_INT_POFWARN_MASK);
|
||||
#if NRF_POWER_HAS_POFCON
|
||||
nrf_power_pofcon_set(NRF_POWER, false, NRF_POWER_POFTHR_V27);
|
||||
#elif NRF_REGULATORS_HAS_POFCON
|
||||
nrf_regulators_pofcon_set(NRF_REGULATORS, false, NRF_REGULATORS_POFTHR_V27);
|
||||
#endif
|
||||
nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
|
||||
}
|
||||
|
||||
void nrfx_power_pof_uninit(void)
|
||||
{
|
||||
m_pofwarn_handler = NULL;
|
||||
}
|
||||
#endif // NRF_POWER_HAS_POFCON
|
||||
#endif // NRFX_POWER_SUPPORTS_POFCON
|
||||
|
||||
#if NRF_POWER_HAS_SLEEPEVT
|
||||
void nrfx_power_sleepevt_init(nrfx_power_sleepevt_config_t const * p_config)
|
||||
@@ -199,21 +211,20 @@ void nrfx_power_sleepevt_enable(nrfx_power_sleepevt_config_t const * p_config)
|
||||
if (p_config->en_enter)
|
||||
{
|
||||
enmask |= NRF_POWER_INT_SLEEPENTER_MASK;
|
||||
nrf_power_event_clear(NRF_POWER_EVENT_SLEEPENTER);
|
||||
nrf_power_event_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPENTER);
|
||||
}
|
||||
if (p_config->en_exit)
|
||||
{
|
||||
enmask |= NRF_POWER_INT_SLEEPEXIT_MASK;
|
||||
nrf_power_event_clear(NRF_POWER_EVENT_SLEEPEXIT);
|
||||
nrf_power_event_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPEXIT);
|
||||
}
|
||||
nrf_power_int_enable(enmask);
|
||||
nrf_power_int_enable(NRF_POWER, enmask);
|
||||
}
|
||||
|
||||
void nrfx_power_sleepevt_disable(void)
|
||||
{
|
||||
nrf_power_int_disable(
|
||||
NRF_POWER_INT_SLEEPENTER_MASK |
|
||||
NRF_POWER_INT_SLEEPEXIT_MASK);
|
||||
nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_SLEEPENTER_MASK |
|
||||
NRF_POWER_INT_SLEEPEXIT_MASK);
|
||||
}
|
||||
|
||||
void nrfx_power_sleepevt_uninit(void)
|
||||
@@ -236,34 +247,35 @@ void nrfx_power_usbevt_init(nrfx_power_usbevt_config_t const * p_config)
|
||||
|
||||
void nrfx_power_usbevt_enable(void)
|
||||
{
|
||||
nrf_power_int_enable(
|
||||
NRF_POWER_INT_USBDETECTED_MASK |
|
||||
NRF_POWER_INT_USBREMOVED_MASK |
|
||||
NRF_POWER_INT_USBPWRRDY_MASK);
|
||||
nrf_power_int_enable(NRF_POWER, NRF_POWER_INT_USBDETECTED_MASK |
|
||||
NRF_POWER_INT_USBREMOVED_MASK |
|
||||
NRF_POWER_INT_USBPWRRDY_MASK);
|
||||
}
|
||||
|
||||
void nrfx_power_usbevt_disable(void)
|
||||
{
|
||||
nrf_power_int_disable(
|
||||
NRF_POWER_INT_USBDETECTED_MASK |
|
||||
NRF_POWER_INT_USBREMOVED_MASK |
|
||||
NRF_POWER_INT_USBPWRRDY_MASK);
|
||||
nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_USBDETECTED_MASK |
|
||||
NRF_POWER_INT_USBREMOVED_MASK |
|
||||
NRF_POWER_INT_USBPWRRDY_MASK);
|
||||
}
|
||||
|
||||
void nrfx_power_usbevt_uninit(void)
|
||||
{
|
||||
nrfx_power_usbevt_disable();
|
||||
m_usbevt_handler = NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif /* NRF_POWER_HAS_USBREG */
|
||||
|
||||
|
||||
void nrfx_power_irq_handler(void)
|
||||
{
|
||||
uint32_t enabled = nrf_power_int_enable_get();
|
||||
uint32_t enabled = nrf_power_int_enable_get(NRF_POWER);
|
||||
|
||||
#if NRF_POWER_HAS_POFCON
|
||||
#if NRFX_POWER_SUPPORTS_POFCON
|
||||
if ((0 != (enabled & NRF_POWER_INT_POFWARN_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_POFWARN))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_POFWARN))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_pofwarn_handler != NULL);
|
||||
@@ -272,14 +284,14 @@ void nrfx_power_irq_handler(void)
|
||||
#endif
|
||||
#if NRF_POWER_HAS_SLEEPEVT
|
||||
if ((0 != (enabled & NRF_POWER_INT_SLEEPENTER_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPENTER))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPENTER))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_sleepevt_handler != NULL);
|
||||
m_sleepevt_handler(NRFX_POWER_SLEEP_EVT_ENTER);
|
||||
}
|
||||
if ((0 != (enabled & NRF_POWER_INT_SLEEPEXIT_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPEXIT))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPEXIT))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_sleepevt_handler != NULL);
|
||||
@@ -288,21 +300,21 @@ void nrfx_power_irq_handler(void)
|
||||
#endif
|
||||
#if NRF_POWER_HAS_USBREG
|
||||
if ((0 != (enabled & NRF_POWER_INT_USBDETECTED_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBDETECTED))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBDETECTED))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_usbevt_handler != NULL);
|
||||
m_usbevt_handler(NRFX_POWER_USB_EVT_DETECTED);
|
||||
}
|
||||
if ((0 != (enabled & NRF_POWER_INT_USBREMOVED_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBREMOVED))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBREMOVED))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_usbevt_handler != NULL);
|
||||
m_usbevt_handler(NRFX_POWER_USB_EVT_REMOVED);
|
||||
}
|
||||
if ((0 != (enabled & NRF_POWER_INT_USBPWRRDY_MASK)) &&
|
||||
nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBPWRRDY))
|
||||
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBPWRRDY))
|
||||
{
|
||||
/* Cannot be null if event is enabled */
|
||||
NRFX_ASSERT(m_usbevt_handler != NULL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -394,6 +394,50 @@ nrfx_err_t nrfx_qspi_chip_erase(void)
|
||||
return nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_ALL, 0);
|
||||
}
|
||||
|
||||
#if NRF_QSPI_HAS_XIP_ENC
|
||||
nrfx_err_t nrfx_qspi_xip_encrypt(nrf_qspi_encryption_t const * p_config)
|
||||
{
|
||||
if (m_cb.is_busy)
|
||||
{
|
||||
return NRFX_ERROR_BUSY;
|
||||
}
|
||||
|
||||
if (p_config)
|
||||
{
|
||||
nrf_qspi_xip_encryption_configure(NRF_QSPI, p_config);
|
||||
nrf_qspi_xip_encryption_set(NRF_QSPI, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_qspi_xip_encryption_set(NRF_QSPI, false);
|
||||
}
|
||||
|
||||
return NRFX_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_QSPI_HAS_DMA_ENC
|
||||
nrfx_err_t nrfx_qspi_dma_encrypt(nrf_qspi_encryption_t const * p_config)
|
||||
{
|
||||
if (m_cb.is_busy)
|
||||
{
|
||||
return NRFX_ERROR_BUSY;
|
||||
}
|
||||
|
||||
if (p_config)
|
||||
{
|
||||
nrf_qspi_dma_encryption_configure(NRF_QSPI, p_config);
|
||||
nrf_qspi_dma_encryption_set(NRF_QSPI, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_qspi_dma_encryption_set(NRF_QSPI, false);
|
||||
}
|
||||
|
||||
return NRFX_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void nrfx_qspi_irq_handler(void)
|
||||
{
|
||||
// Catch Event ready interrupts
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,13 +34,11 @@
|
||||
#if NRFX_CHECK(NRFX_SPIM_ENABLED)
|
||||
|
||||
#if !(NRFX_CHECK(NRFX_SPIM0_ENABLED) || NRFX_CHECK(NRFX_SPIM1_ENABLED) || \
|
||||
NRFX_CHECK(NRFX_SPIM2_ENABLED) || NRFX_CHECK(NRFX_SPIM3_ENABLED))
|
||||
NRFX_CHECK(NRFX_SPIM2_ENABLED) || NRFX_CHECK(NRFX_SPIM3_ENABLED) || \
|
||||
NRFX_CHECK(NRFX_SPIM4_ENABLED))
|
||||
#error "No enabled SPIM instances. Check <nrfx_config.h>."
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) && !NRFX_CHECK(NRFX_SPIM3_ENABLED)
|
||||
#error "Extended options are available only in SPIM3 on the nRF52840 SoC."
|
||||
#endif
|
||||
|
||||
#include <nrfx_spim.h>
|
||||
#include "prs/nrfx_prs.h"
|
||||
@@ -49,45 +47,127 @@
|
||||
#define NRFX_LOG_MODULE SPIM
|
||||
#include <nrfx_log.h>
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) && \
|
||||
((!NRF_SPIM_HW_CSN_PRESENT) || !(NRF_SPIM_DCX_PRESENT) || !(NRF_SPIM_RXDELAY_PRESENT))
|
||||
#error "Extended options are not available in the SoC currently in use."
|
||||
#endif
|
||||
|
||||
#define SPIMX_LENGTH_VALIDATE(peripheral, drv_inst_idx, rx_len, tx_len) \
|
||||
(((drv_inst_idx) == NRFX_CONCAT_3(NRFX_, peripheral, _INST_IDX)) && \
|
||||
NRFX_EASYDMA_LENGTH_VALIDATE(peripheral, rx_len, tx_len))
|
||||
|
||||
#define SPIMX_HW_CSN_PRESENT_VALIDATE(peripheral, drv_inst_idx) \
|
||||
(((drv_inst_idx) == NRFX_CONCAT_3(NRFX_, peripheral, _INST_IDX)) && \
|
||||
NRFX_CONCAT_2(peripheral, _FEATURE_HARDWARE_CSN_PRESENT))
|
||||
|
||||
#define SPIMX_DCX_PRESENT_VALIDATE(peripheral, drv_inst_idx) \
|
||||
(((drv_inst_idx) == NRFX_CONCAT_3(NRFX_, peripheral, _INST_IDX)) && \
|
||||
NRFX_CONCAT_2(peripheral, _FEATURE_DCX_PRESENT))
|
||||
|
||||
#define SPIMX_SUPPORTED_FREQ_VALIDATE(peripheral, drv_inst_idx, freq) \
|
||||
( \
|
||||
((drv_inst_idx) == NRFX_CONCAT_3(NRFX_, peripheral, _INST_IDX)) && \
|
||||
( \
|
||||
(((freq) != NRF_SPIM_FREQ_16M) && ((freq) != NRF_SPIM_FREQ_32M)) || \
|
||||
(((freq) == NRF_SPIM_FREQ_16M) && ((NRFX_CONCAT_2(peripheral, _MAX_DATARATE) >= 16))) || \
|
||||
(((freq) == NRF_SPIM_FREQ_32M) && ((NRFX_CONCAT_2(peripheral, _MAX_DATARATE) >= 32))) \
|
||||
) \
|
||||
)
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM0_ENABLED)
|
||||
#define SPIM0_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM0, __VA_ARGS__)
|
||||
#define SPIM0_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM0, __VA_ARGS__)
|
||||
#define SPIM0_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM0, __VA_ARGS__)
|
||||
#define SPIM0_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM0, __VA_ARGS__)
|
||||
#define SPIM0_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM0, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIM0_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM0_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM0_HW_CSN_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM0_DCX_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM0_SUPPORTED_FREQ_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM1_ENABLED)
|
||||
#define SPIM1_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM1, __VA_ARGS__)
|
||||
#define SPIM1_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM1, __VA_ARGS__)
|
||||
#define SPIM1_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM1, __VA_ARGS__)
|
||||
#define SPIM1_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM1, __VA_ARGS__)
|
||||
#define SPIM1_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM1, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIM1_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM1_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM1_HW_CSN_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM1_DCX_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM1_SUPPORTED_FREQ_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM2_ENABLED)
|
||||
#define SPIM2_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM2, __VA_ARGS__)
|
||||
#define SPIM2_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM2, __VA_ARGS__)
|
||||
#define SPIM2_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM2, __VA_ARGS__)
|
||||
#define SPIM2_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM2, __VA_ARGS__)
|
||||
#define SPIM2_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM2, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIM2_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM2_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM2_HW_CSN_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM2_DCX_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM2_SUPPORTED_FREQ_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)
|
||||
#define SPIM3_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM3, __VA_ARGS__)
|
||||
#define SPIM3_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM3, __VA_ARGS__)
|
||||
#define SPIM3_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM3, __VA_ARGS__)
|
||||
#define SPIM3_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM3, __VA_ARGS__)
|
||||
#define SPIM3_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM3, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIM3_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM3_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM3_HW_CSN_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM3_DCX_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM3_SUPPORTED_FREQ_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
|
||||
#define SPIM4_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM4, __VA_ARGS__)
|
||||
#define SPIM4_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM4, __VA_ARGS__)
|
||||
#define SPIM4_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM4, __VA_ARGS__)
|
||||
#define SPIM4_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM4, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIM4_LENGTH_VALIDATE(...) 0
|
||||
#define SPIM4_HW_CSN_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM4_DCX_PRESENT_VALIDATE(...) 0
|
||||
#define SPIM4_SUPPORTED_FREQ_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#define SPIM_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) \
|
||||
(SPIM0_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIM1_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIM2_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIM3_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len))
|
||||
SPIM3_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIM4_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len))
|
||||
|
||||
#define SPIM_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) \
|
||||
(SPIM0_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM1_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM2_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM3_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM4_HW_CSN_PRESENT_VALIDATE(drv_inst_idx))
|
||||
|
||||
#define SPIM_DCX_PRESENT_VALIDATE(drv_inst_idx) \
|
||||
(SPIM0_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM1_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM2_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM3_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
|
||||
SPIM4_DCX_PRESENT_VALIDATE(drv_inst_idx))
|
||||
|
||||
#define SPIM_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) \
|
||||
(SPIM0_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
|
||||
SPIM1_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
|
||||
SPIM2_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
|
||||
SPIM3_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
|
||||
SPIM4_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq))
|
||||
|
||||
#if defined(NRF52840_XXAA) && (NRFX_CHECK(NRFX_SPIM3_ENABLED))
|
||||
// Enable workaround for nRF52840 anomaly 195 (SPIM3 continues to draw current after disable).
|
||||
#define USE_WORKAROUND_FOR_ANOMALY_195
|
||||
#endif
|
||||
|
||||
|
||||
// Control block - driver instance local data.
|
||||
typedef struct
|
||||
{
|
||||
@@ -156,10 +236,10 @@ static void anomaly_198_disable(void)
|
||||
}
|
||||
#endif // NRFX_CHECK(NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED)
|
||||
|
||||
nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_init(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_config_t const * p_config,
|
||||
nrfx_spim_evt_handler_t handler,
|
||||
void * p_context)
|
||||
void * p_context)
|
||||
{
|
||||
NRFX_ASSERT(p_config);
|
||||
spim_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
@@ -175,13 +255,14 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
}
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED)
|
||||
// Currently, only SPIM3 in nRF52840 supports the extended features.
|
||||
// Other instances must be checked.
|
||||
if ((p_instance->drv_inst_idx != NRFX_SPIM3_INST_IDX) &&
|
||||
((p_config->dcx_pin != NRFX_SPIM_PIN_NOT_USED) ||
|
||||
(p_config->frequency == NRF_SPIM_FREQ_16M) ||
|
||||
(p_config->frequency == NRF_SPIM_FREQ_32M) ||
|
||||
(p_config->use_hw_ss)))
|
||||
// Check if SPIM instance supports the extended features.
|
||||
if (
|
||||
(!SPIM_SUPPORTED_FREQ_VALIDATE(p_instance->drv_inst_idx, p_config->frequency)) ||
|
||||
((p_config->use_hw_ss) &&
|
||||
!SPIM_HW_CSN_PRESENT_VALIDATE(p_instance->drv_inst_idx)) ||
|
||||
((p_config->dcx_pin != NRFX_SPIM_PIN_NOT_USED) &&
|
||||
!SPIM_DCX_PRESENT_VALIDATE(p_instance->drv_inst_idx))
|
||||
)
|
||||
{
|
||||
err_code = NRFX_ERROR_NOT_SUPPORTED;
|
||||
NRFX_LOG_WARNING("Function: %s, error code: %s.",
|
||||
@@ -207,6 +288,9 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)
|
||||
nrfx_spim_3_irq_handler,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
|
||||
nrfx_spim_4_irq_handler,
|
||||
#endif
|
||||
};
|
||||
if (nrfx_prs_acquire(p_instance->p_reg,
|
||||
irq_handlers[p_instance->drv_inst_idx]) != NRFX_SUCCESS)
|
||||
@@ -258,7 +342,7 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
if (p_config->miso_pin != NRFX_SPIM_PIN_NOT_USED)
|
||||
{
|
||||
miso_pin = p_config->miso_pin;
|
||||
nrf_gpio_cfg_input(miso_pin, (nrf_gpio_pin_pull_t)NRFX_SPIM_MISO_PULL_CFG);
|
||||
nrf_gpio_cfg_input(miso_pin, p_config->miso_pull);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -338,7 +422,7 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
|
||||
return err_code;
|
||||
}
|
||||
|
||||
void nrfx_spim_uninit(nrfx_spim_t const * const p_instance)
|
||||
void nrfx_spim_uninit(nrfx_spim_t const * p_instance)
|
||||
{
|
||||
spim_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED);
|
||||
@@ -383,7 +467,7 @@ void nrfx_spim_uninit(nrfx_spim_t const * const p_instance)
|
||||
}
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED)
|
||||
nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags,
|
||||
uint8_t cmd_length)
|
||||
@@ -422,7 +506,7 @@ static void finish_transfer(spim_control_block_t * p_cb)
|
||||
p_cb->handler(&p_cb->evt, p_cb->p_context);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void spim_int_enable(NRF_SPIM_Type * p_spim, bool enable)
|
||||
static void spim_int_enable(NRF_SPIM_Type * p_spim, bool enable)
|
||||
{
|
||||
if (!enable)
|
||||
{
|
||||
@@ -434,7 +518,7 @@ __STATIC_INLINE void spim_int_enable(NRF_SPIM_Type * p_spim, bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void spim_list_enable_handle(NRF_SPIM_Type * p_spim, uint32_t flags)
|
||||
static void spim_list_enable_handle(NRF_SPIM_Type * p_spim, uint32_t flags)
|
||||
{
|
||||
if (NRFX_SPIM_FLAG_TX_POSTINC & flags)
|
||||
{
|
||||
@@ -545,7 +629,7 @@ static nrfx_err_t spim_xfer(NRF_SPIM_Type * p_spim,
|
||||
return err_code;
|
||||
}
|
||||
|
||||
nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance,
|
||||
nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * p_instance,
|
||||
nrfx_spim_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags)
|
||||
{
|
||||
@@ -690,4 +774,11 @@ void nrfx_spim_3_irq_handler(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
|
||||
void nrfx_spim_4_irq_handler(void)
|
||||
{
|
||||
irq_handler(NRF_SPIM4, &m_cb[NRFX_SPIM4_INST_IDX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_CHECK(NRFX_SPIM_ENABLED)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,8 @@
|
||||
#define NRFX_USBD_ERRATA_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <nrfx.h>
|
||||
#include <nrf_erratas.h>
|
||||
|
||||
#ifndef NRFX_USBD_ERRATA_ENABLE
|
||||
/**
|
||||
@@ -43,71 +45,46 @@
|
||||
#define NRFX_USBD_ERRATA_ENABLE 1
|
||||
#endif
|
||||
|
||||
static inline bool nrfx_usbd_errata_type_52840(void)
|
||||
{
|
||||
return (*(uint32_t *)0x10000130UL == 0x8UL);
|
||||
}
|
||||
|
||||
static inline bool nrfx_usbd_errata_type_52840_eng_a(void)
|
||||
{
|
||||
return nrfx_usbd_errata_type_52840();
|
||||
}
|
||||
|
||||
static inline bool nrfx_usbd_errata_type_52840_eng_b(void)
|
||||
{
|
||||
return (nrfx_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL >= 0x1UL));
|
||||
}
|
||||
|
||||
static inline bool nrfx_usbd_errata_type_52840_eng_c(void)
|
||||
{
|
||||
return (nrfx_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL >= 0x2UL));
|
||||
}
|
||||
|
||||
static inline bool nrfx_usbd_errata_type_52840_eng_d(void)
|
||||
{
|
||||
return (nrfx_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL >= 0x3UL));
|
||||
}
|
||||
|
||||
/* Errata: USBD: EPDATA event is not always generated. */
|
||||
/* Errata: USBD: EPDATA event is not always generated. **/
|
||||
static inline bool nrfx_usbd_errata_104(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && (!nrfx_usbd_errata_type_52840_eng_b()));
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_104();
|
||||
}
|
||||
|
||||
/* Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. */
|
||||
/* Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. **/
|
||||
static inline bool nrfx_usbd_errata_154(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && (!nrfx_usbd_errata_type_52840_eng_b()));
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_154();
|
||||
}
|
||||
|
||||
/* Errata: ISO double buffering not functional. */
|
||||
/* Errata: ISO double buffering not functional. **/
|
||||
static inline bool nrfx_usbd_errata_166(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && true);
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_166();
|
||||
}
|
||||
|
||||
/* Errata: USBD might not reach its active state. */
|
||||
/* Errata: USBD might not reach its active state. **/
|
||||
static inline bool nrfx_usbd_errata_171(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && true);
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_171();
|
||||
}
|
||||
|
||||
/* Errata: USB cannot be enabled. */
|
||||
/* Errata: USB cannot be enabled. **/
|
||||
static inline bool nrfx_usbd_errata_187(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && nrfx_usbd_errata_type_52840_eng_b());
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_187();
|
||||
}
|
||||
|
||||
/* Errata: USBD cannot receive tasks during DMA. */
|
||||
/* Errata: USBD cannot receive tasks during DMA. **/
|
||||
static inline bool nrfx_usbd_errata_199(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && true);
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_199();
|
||||
}
|
||||
|
||||
/* Errata: SIZE.EPOUT not writable. */
|
||||
/* Errata: SIZE.EPOUT not writable. **/
|
||||
static inline bool nrfx_usbd_errata_200(void)
|
||||
{
|
||||
return (NRFX_USBD_ERRATA_ENABLE && (!nrfx_usbd_errata_type_52840_eng_b()));
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_200();
|
||||
}
|
||||
|
||||
#endif // NRFX_USBD_ERRATA_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -65,7 +65,8 @@ extern "C" {
|
||||
#define NRFX_PRS_BOX_1_ADDR NRF_SPIM0
|
||||
// UART0, UARTE0
|
||||
#define NRFX_PRS_BOX_2_ADDR NRF_UART0
|
||||
#elif defined(NRF52832_XXAA) || defined (NRF52832_XXAB)
|
||||
#elif defined(NRF52832_XXAA) || defined(NRF52832_XXAB) || \
|
||||
defined(NRF52833_XXAA) || defined(NRF52840_XXAA)
|
||||
// SPIM0, SPIS0, TWIM0, TWIS0, SPI0, TWI0
|
||||
#define NRFX_PRS_BOX_0_ADDR NRF_SPIM0
|
||||
// SPIM1, SPIS1, TWIM1, TWIS1, SPI1, TWI1
|
||||
@@ -76,17 +77,20 @@ extern "C" {
|
||||
#define NRFX_PRS_BOX_3_ADDR NRF_COMP
|
||||
// UARTE0, UART0
|
||||
#define NRFX_PRS_BOX_4_ADDR NRF_UARTE0
|
||||
#elif defined(NRF52840_XXAA)
|
||||
// SPIM0, SPIS0, TWIM0, TWIS0, SPI0, TWI0
|
||||
#define NRFX_PRS_BOX_0_ADDR NRF_SPIM0
|
||||
// SPIM1, SPIS1, TWIM1, TWIS1, SPI1, TWI1
|
||||
#define NRFX_PRS_BOX_1_ADDR NRF_SPIM1
|
||||
// SPIM2, SPIS2, SPI2
|
||||
#define NRFX_PRS_BOX_2_ADDR NRF_SPIM2
|
||||
#elif defined(NRF5340_XXAA_APPLICATION)
|
||||
// SPIM0, SPIS0, TWIM0, TWIS0, UARTE0
|
||||
#define NRFX_PRS_BOX_0_ADDR NRF_UARTE0
|
||||
// SPIM1, SPIS1, TWIM1, TWIS1, UARTE1
|
||||
#define NRFX_PRS_BOX_1_ADDR NRF_UARTE1
|
||||
// SPIM2, SPIS2, TWIM2, TWIS2, UARTE2
|
||||
#define NRFX_PRS_BOX_2_ADDR NRF_UARTE2
|
||||
// SPIM3, SPIS3, TWIM3, TWIS3, UARTE3
|
||||
#define NRFX_PRS_BOX_3_ADDR NRF_UARTE3
|
||||
// COMP, LPCOMP
|
||||
#define NRFX_PRS_BOX_3_ADDR NRF_COMP
|
||||
// UARTE0, UART0
|
||||
#define NRFX_PRS_BOX_4_ADDR NRF_UARTE0
|
||||
#define NRFX_PRS_BOX_4_ADDR NRF_COMP
|
||||
#elif defined(NRF5340_XXAA_NETWORK)
|
||||
// SPIM0, SPIS0, TWIM0, TWIS0, UARTE0
|
||||
#define NRFX_PRS_BOX_0_ADDR NRF_UARTE0
|
||||
#elif defined(NRF9160_XXAA)
|
||||
// UARTE0, SPIM0, SPIS0, TWIM0, TWIS0
|
||||
#define NRFX_PRS_BOX_0_ADDR NRF_UARTE0
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_AAR_H__
|
||||
#define NRF_AAR_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_aar_hal AAR HAL
|
||||
* @{
|
||||
* @ingroup nrf_aar
|
||||
* @brief Hardware access layer for managing the Accelerated Address Resolver (AAR) peripheral.
|
||||
*/
|
||||
|
||||
/** @brief AAR events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_AAR_EVENT_END = offsetof(NRF_AAR_Type, EVENTS_END), ///< Address resolution procedure complete.
|
||||
NRF_AAR_EVENT_RESOLVED = offsetof(NRF_AAR_Type, EVENTS_RESOLVED), ///< Address resolved.
|
||||
NRF_AAR_EVENT_NOTRESOLVED = offsetof(NRF_AAR_Type, EVENTS_NOTRESOLVED), ///< Address not resolved.
|
||||
} nrf_aar_event_t;
|
||||
|
||||
/** @brief AAR interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_AAR_INT_END_MASK = AAR_INTENSET_END_Msk, ///< Interrupt on END event.
|
||||
NRF_AAR_INT_RESOLVED_MASK = AAR_INTENSET_RESOLVED_Msk, ///< Interrupt on RESOLVED event.
|
||||
NRF_AAR_INT_NOTRESOLVED_MASK = AAR_INTENSET_NOTRESOLVED_Msk, ///< Interrupt on NOTRESOLVED event.
|
||||
} nrf_aar_int_mask_t;
|
||||
|
||||
/** @brief AAR tasks. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_AAR_TASK_START = offsetof(NRF_AAR_Type, TASKS_START), ///< Start address resolution procedure.
|
||||
NRF_AAR_TASK_STOP = offsetof(NRF_AAR_Type, TASKS_STOP), ///< Stop address resolution procedure.
|
||||
} nrf_aar_task_t;
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the AAR event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true Event is set.
|
||||
* @retval false Event is not set.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified AAR event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
|
||||
nrf_aar_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified AAR event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to get the address of.
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_event_address_get(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_int_enable_check(NRF_AAR_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_int_disable(NRF_AAR_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for starting an AAR task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific AAR task register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Requested AAR task.
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_task_address_get(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling AAR.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling AAR.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the Identity Resolving Keys (IRK) data structure.
|
||||
*
|
||||
* The size of the provided data structure must correspond to the number of keys available.
|
||||
* Each key occupies 16 bytes.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] irk_ptr Pointer to the IRK data structure. Must point to the Data RAM region.
|
||||
*
|
||||
* @sa nrf_aar_irk_number_set
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the Identity Resolving Keys
|
||||
* data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to the IRK data structure.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t const * nrf_aar_irk_pointer_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the number of keys available in the Identity Resolving Keys
|
||||
* data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] irk_num Number of keys available in the IRK data structure. Maximum is 16.
|
||||
* Must correspond to the size of the provided IRK data structure.
|
||||
*
|
||||
* @sa nrf_aar_irk_pointer_set
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of keys available in the Identity Resolving Keys
|
||||
* data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Number of keys in the IRK data structure.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_irk_number_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the resolvable address.
|
||||
*
|
||||
* The resolvable address must consist of 6 bytes.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] addr_ptr Pointer to the address to resolve using the available IRK keys.
|
||||
* Must point to the Data RAM region.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the resolvable address.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to the address to resolve.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t const * nrf_aar_addr_pointer_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the scratch data area.
|
||||
*
|
||||
* The scratch data area is used for temporary storage during the address resolution procedure.
|
||||
* A space of minimum 3 bytes must be reserved for the scratch data area.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] scratch_ptr Pointer to the scratch data area. Must point to the Data RAM region.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the scratch data area.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to the scratch data area.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t * nrf_aar_scratch_pointer_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the index of the Identity Resolving Key that was used
|
||||
* the last time an address was resolved.
|
||||
*
|
||||
* This function can be used to get the IRK index that matched the resolvable address,
|
||||
* provided that @ref NRF_AAR_EVENT_RESOLVED occured. Otherwise, it will return
|
||||
* the index of the last IRK stored in the IRK data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The index of the IRK that was used the last time an address was resolved.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
NRF_STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t aar_event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
|
||||
nrf_aar_event_t aar_event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_event_address_get(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t aar_event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)aar_event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_int_enable_check(NRF_AAR_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_int_disable(NRF_AAR_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task)
|
||||
{
|
||||
*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task) = 1;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_aar_task_address_get(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = AAR_ENABLE_ENABLE_Enabled << AAR_ENABLE_ENABLE_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = AAR_ENABLE_ENABLE_Disabled << AAR_ENABLE_ENABLE_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr)
|
||||
{
|
||||
p_reg->IRKPTR = (uint32_t)irk_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t const * nrf_aar_irk_pointer_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t const *)(p_reg->IRKPTR);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num)
|
||||
{
|
||||
p_reg->NIRK = irk_num;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_irk_number_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(p_reg->NIRK);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr)
|
||||
{
|
||||
p_reg->ADDRPTR = (uint32_t)addr_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t const * nrf_aar_addr_pointer_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t const *)(p_reg->ADDRPTR);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr)
|
||||
{
|
||||
p_reg->SCRATCHPTR = (uint32_t)scratch_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t * nrf_aar_scratch_pointer_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t *)(p_reg->SCRATCHPTR);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(p_reg->STATUS);
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_AAR_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -66,11 +66,11 @@ typedef enum
|
||||
* @param[in] size Size of region to protect in bytes.
|
||||
* @param[in] perm Permissions to set for region to protect.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
uint32_t region_id,
|
||||
uint32_t address,
|
||||
size_t size,
|
||||
nrf_acl_perm_t perm);
|
||||
NRF_STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
uint32_t region_id,
|
||||
uint32_t address,
|
||||
size_t size,
|
||||
nrf_acl_perm_t perm);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configured region address of a specific ACL region.
|
||||
@@ -80,7 +80,8 @@ __STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
*
|
||||
* @return Configured region address of given ACL region.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_acl_region_address_get(NRF_ACL_Type * p_reg, uint32_t region_id);
|
||||
NRF_STATIC_INLINE uint32_t nrf_acl_region_address_get(NRF_ACL_Type const * p_reg,
|
||||
uint32_t region_id);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configured region size of a specific ACL region.
|
||||
@@ -90,7 +91,7 @@ __STATIC_INLINE uint32_t nrf_acl_region_address_get(NRF_ACL_Type * p_reg, uint32
|
||||
*
|
||||
* @return Configured region size of given ACL region.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_acl_region_size_get(NRF_ACL_Type * p_reg, uint32_t region_id);
|
||||
NRF_STATIC_INLINE size_t nrf_acl_region_size_get(NRF_ACL_Type const * p_reg, uint32_t region_id);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configured region permissions of a specific ACL region.
|
||||
@@ -100,15 +101,16 @@ __STATIC_INLINE size_t nrf_acl_region_size_get(NRF_ACL_Type * p_reg, uint32_t re
|
||||
*
|
||||
* @return Configured region permissions of given ACL region.
|
||||
*/
|
||||
__STATIC_INLINE nrf_acl_perm_t nrf_acl_region_perm_get(NRF_ACL_Type * p_reg, uint32_t region_id);
|
||||
NRF_STATIC_INLINE nrf_acl_perm_t nrf_acl_region_perm_get(NRF_ACL_Type const * p_reg,
|
||||
uint32_t region_id);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
uint32_t region_id,
|
||||
uint32_t address,
|
||||
size_t size,
|
||||
nrf_acl_perm_t perm)
|
||||
NRF_STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
uint32_t region_id,
|
||||
uint32_t address,
|
||||
size_t size,
|
||||
nrf_acl_perm_t perm)
|
||||
{
|
||||
NRFX_ASSERT(region_id < ACL_REGIONS_COUNT);
|
||||
NRFX_ASSERT(address % NRF_FICR->CODEPAGESIZE == 0);
|
||||
@@ -120,22 +122,24 @@ __STATIC_INLINE void nrf_acl_region_set(NRF_ACL_Type * p_reg,
|
||||
p_reg->ACL[region_id].PERM = perm;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_acl_region_address_get(NRF_ACL_Type * p_reg, uint32_t region_id)
|
||||
NRF_STATIC_INLINE uint32_t nrf_acl_region_address_get(NRF_ACL_Type const * p_reg,
|
||||
uint32_t region_id)
|
||||
{
|
||||
return (uint32_t)p_reg->ACL[region_id].ADDR;
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_acl_region_size_get(NRF_ACL_Type * p_reg, uint32_t region_id)
|
||||
NRF_STATIC_INLINE size_t nrf_acl_region_size_get(NRF_ACL_Type const * p_reg, uint32_t region_id)
|
||||
{
|
||||
return (size_t)p_reg->ACL[region_id].SIZE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_acl_perm_t nrf_acl_region_perm_get(NRF_ACL_Type * p_reg, uint32_t region_id)
|
||||
NRF_STATIC_INLINE nrf_acl_perm_t nrf_acl_region_perm_get(NRF_ACL_Type const * p_reg,
|
||||
uint32_t region_id)
|
||||
{
|
||||
return (nrf_acl_perm_t)p_reg->ACL[region_id].PERM;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -133,101 +133,124 @@ typedef uint16_t nrf_adc_value_t;
|
||||
/**
|
||||
* @brief Function for activating the specified ADC task.
|
||||
*
|
||||
* @param[in] task Task to be activated.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_adc_task_trigger(nrf_adc_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_adc_task_trigger(NRF_ADC_Type * p_reg, nrf_adc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of an ADC task register.
|
||||
*
|
||||
* @param[in] task ADC task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task ADC task.
|
||||
*
|
||||
* @return Address of the specified ADC task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_adc_task_address_get(nrf_adc_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_task_address_get(NRF_ADC_Type const * p_reg,
|
||||
nrf_adc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of an ADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_adc_event_check(nrf_adc_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_adc_event_check(NRF_ADC_Type const * p_reg, nrf_adc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing an ADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_adc_event_clear(nrf_adc_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_adc_event_clear(NRF_ADC_Type * p_reg, nrf_adc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified ADC event register.
|
||||
*
|
||||
* @param[in] adc_event ADC event.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event ADC event.
|
||||
*
|
||||
* @return Address of the specified ADC event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_adc_event_address_get(nrf_adc_event_t adc_event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_event_address_get(NRF_ADC_Type const * p_reg,
|
||||
nrf_adc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_adc_int_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_adc_int_enable(NRF_ADC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_adc_int_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_adc_int_disable(NRF_ADC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the specified ADC interrupts.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true All specified interrupts are enabled.
|
||||
* @retval false At least one of the given interrupts is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_adc_int_enable_check(uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_int_enable_check(NRF_ADC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking whether the ADC is busy.
|
||||
*
|
||||
* This function checks whether the ADC converter is busy with a conversion.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The ADC is busy.
|
||||
* @retval false The ADC is not busy.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_adc_busy_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_adc_busy_check(NRF_ADC_Type const * p_reg);
|
||||
|
||||
/** @brief Function for enabling the ADC. */
|
||||
__STATIC_INLINE void nrf_adc_enable(void);
|
||||
/**
|
||||
* @brief Function for enabling the ADC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_adc_enable(NRF_ADC_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling the ADC. */
|
||||
__STATIC_INLINE void nrf_adc_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling the ADC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_adc_disable(NRF_ADC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the ADC is enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The ADC is enabled.
|
||||
* @retval false The ADC is not enabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_adc_enable_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_adc_enable_check(NRF_ADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the ADC conversion result.
|
||||
*
|
||||
* This function retrieves and returns the last analog-to-digital conversion result.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Last conversion result.
|
||||
*/
|
||||
__STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(void);
|
||||
NRF_STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(NRF_ADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the ADC.
|
||||
@@ -235,81 +258,84 @@ __STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(void);
|
||||
* This function writes data to ADC's CONFIG register. After the configuration,
|
||||
* the ADC is in DISABLE state and must be enabled before using it.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_config Configuration parameters.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_adc_init(nrf_adc_config_t const * p_config);
|
||||
NRF_STATIC_INLINE void nrf_adc_init(NRF_ADC_Type * p_reg, nrf_adc_config_t const * p_config);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_adc_task_trigger(nrf_adc_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_adc_task_trigger(NRF_ADC_Type * p_reg, nrf_adc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_ADC + (uint32_t)task)) = 0x1UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_adc_task_address_get(nrf_adc_task_t adc_task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_task_address_get(NRF_ADC_Type const * p_reg,
|
||||
nrf_adc_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)NRF_ADC + (uint32_t)adc_task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_adc_event_check(nrf_adc_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_adc_event_check(NRF_ADC_Type const * p_reg, nrf_adc_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)NRF_ADC + (uint32_t)event);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_event_clear(nrf_adc_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_adc_event_clear(NRF_ADC_Type * p_reg, nrf_adc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_ADC + (uint32_t)event)) = 0x0UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_adc_event_address_get(nrf_adc_event_t adc_event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_event_address_get(NRF_ADC_Type const * p_reg,
|
||||
nrf_adc_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)NRF_ADC + (uint32_t)adc_event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_int_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_adc_int_enable(NRF_ADC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_ADC->INTENSET = mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_int_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_adc_int_disable(NRF_ADC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_ADC->INTENCLR = mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_adc_int_enable_check(uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_adc_int_enable_check(NRF_ADC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(NRF_ADC->INTENSET & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_adc_busy_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_adc_busy_check(NRF_ADC_Type const * p_reg)
|
||||
{
|
||||
return ((NRF_ADC->BUSY & ADC_BUSY_BUSY_Msk) == (ADC_BUSY_BUSY_Busy << ADC_BUSY_BUSY_Pos));
|
||||
return ((p_reg->BUSY & ADC_BUSY_BUSY_Msk) == (ADC_BUSY_BUSY_Busy << ADC_BUSY_BUSY_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_adc_enable(NRF_ADC_Type * p_reg)
|
||||
{
|
||||
NRF_ADC->ENABLE = (ADC_ENABLE_ENABLE_Enabled << ADC_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (ADC_ENABLE_ENABLE_Enabled << ADC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_adc_disable(NRF_ADC_Type * p_reg)
|
||||
{
|
||||
NRF_ADC->ENABLE = (ADC_ENABLE_ENABLE_Disabled << ADC_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (ADC_ENABLE_ENABLE_Disabled << ADC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_adc_enable_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_adc_enable_check(NRF_ADC_Type const * p_reg)
|
||||
{
|
||||
return (NRF_ADC->ENABLE == (ADC_ENABLE_ENABLE_Enabled << ADC_ENABLE_ENABLE_Pos));
|
||||
return (p_reg->ENABLE == (ADC_ENABLE_ENABLE_Enabled << ADC_ENABLE_ENABLE_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(void)
|
||||
NRF_STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(NRF_ADC_Type const * p_reg)
|
||||
{
|
||||
return (nrf_adc_value_t)NRF_ADC->RESULT;
|
||||
return (nrf_adc_value_t)p_reg->RESULT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_adc_init(nrf_adc_config_t const * p_config)
|
||||
NRF_STATIC_INLINE void nrf_adc_init(NRF_ADC_Type * p_reg, nrf_adc_config_t const * p_config)
|
||||
{
|
||||
NRF_ADC->CONFIG =
|
||||
p_reg->CONFIG =
|
||||
((p_config->resolution << ADC_CONFIG_RES_Pos) & ADC_CONFIG_RES_Msk)
|
||||
|((p_config->scaling << ADC_CONFIG_INPSEL_Pos) & ADC_CONFIG_INPSEL_Msk)
|
||||
|((p_config->reference << ADC_CONFIG_REFSEL_Pos) & ADC_CONFIG_REFSEL_Msk)
|
||||
@@ -317,7 +343,8 @@ __STATIC_INLINE void nrf_adc_init(nrf_adc_config_t const * p_config)
|
||||
|((p_config->extref << ADC_CONFIG_EXTREFSEL_Pos) & ADC_CONFIG_EXTREFSEL_Msk);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,9 +57,9 @@ extern "C" {
|
||||
* @param[in] block_mask Non-volatile memory blocks to protect. Each bit in bitmask represents
|
||||
* one memory block in the specified group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask);
|
||||
NRF_STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the non-volatile memory (NVM) protection during debug.
|
||||
@@ -67,17 +67,16 @@ __STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_r
|
||||
* NVM protection is disabled by default while debugging.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if NVM protection during debug is to be enabled.
|
||||
* False if otherwise.
|
||||
* @param[in] enable True if NVM protection during debug is to be enabled, false otherwise.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bprot_nvm_protection_in_debug_set(NRF_BPROT_Type * p_reg,
|
||||
bool enable);
|
||||
NRF_STATIC_INLINE void nrf_bprot_nvm_protection_in_debug_set(NRF_BPROT_Type * p_reg,
|
||||
bool enable);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask)
|
||||
NRF_STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask)
|
||||
{
|
||||
switch (group_idx)
|
||||
{
|
||||
@@ -107,14 +106,14 @@ __STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p_r
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_bprot_nvm_protection_in_debug_set(NRF_BPROT_Type * p_reg,
|
||||
bool enable)
|
||||
NRF_STATIC_INLINE void nrf_bprot_nvm_protection_in_debug_set(NRF_BPROT_Type * p_reg,
|
||||
bool enable)
|
||||
{
|
||||
p_reg->DISABLEINDEBUG =
|
||||
(enable ? 0 : BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Msk);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_CACHE_H__
|
||||
#define NRF_CACHE_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_cache_hal CACHE HAL
|
||||
* @{
|
||||
* @ingroup nrf_cache
|
||||
* @brief The hardware access layer for managing the CACHE peripheral.
|
||||
*/
|
||||
|
||||
/** @brief Cache regions. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CACHE_REGION_FLASH = 0, ///< Cache region related to Flash access.
|
||||
NRF_CACHE_REGION_XIP = 1, ///< Cache region related to XIP access.
|
||||
} nrf_cache_region_t;
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the CACHE peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_enable(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the CACHE peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_disable(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for invalidating the cache content.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_invalidate(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for erasing the cache content.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_erase(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the status of @ref nrf_cache_erase().
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true Erase is finished.
|
||||
* @retval false Erase is not complete or has not started.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_cache_erase_status_check(NRF_CACHE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the status of the cache erase.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_erase_status_clear(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the cache profiling.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if cache profiling is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_profiling_set(NRF_CACHE_Type * p_reg, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the cache profiling counters.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_profiling_counters_clear(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of cache hits for instruction fetch from the specified
|
||||
* cache region.
|
||||
*
|
||||
* @note Separate counters are used for flash region and XIP region.
|
||||
* @note Cache profiling must be enabled first. See @ref nrf_cache_profiling_set.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] region Cache region.
|
||||
*
|
||||
* @return Number of instruction fetch cache hits.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_instruction_hit_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of cache misses for instruction fetch from the specified
|
||||
* cache region.
|
||||
*
|
||||
* @note Separate counters are used for flash region and XIP region.
|
||||
* @note Cache profiling must be enabled first. See @ref nrf_cache_profiling_set.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] region Cache region.
|
||||
*
|
||||
* @return Number of instruction fetch cache misses.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_instruction_miss_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of cache hits for data fetch from the specified
|
||||
* cache region.
|
||||
*
|
||||
* @note Separate counters are used for flash region and XIP region.
|
||||
* @note Cache profiling must be enabled first. See @ref nrf_cache_profiling_set.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] region Cache region.
|
||||
*
|
||||
* @return Number of data fetch cache hits.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_hit_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of cache misses for data fetch from the specified
|
||||
* cache region.
|
||||
*
|
||||
* @note Separate counters are used for flash region and XIP region.
|
||||
* @note Cache profiling must be enabled first. See @ref nrf_cache_profiling_set.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] region Cache region.
|
||||
*
|
||||
* @return Number of data fetch cache misses.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_miss_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the cache RAM mode.
|
||||
*
|
||||
* When configured in the RAM mode, the accesses to internal or external flash will not be cached.
|
||||
* In this mode, the cache data contents can be used as the read/write RAM.
|
||||
* Only the data content of the cache is available as RAM.
|
||||
*
|
||||
* @note -Enabling the RAM mode causes the RAM to be cleared.
|
||||
* @note -Disabling the RAM mode causes the cache to be invalidated.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if the cache RAM mode is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_ram_mode_set(NRF_CACHE_Type * p_reg, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Function for blocking the cache content access.
|
||||
*
|
||||
* To unlock the cache content access, a reset has to be performed.
|
||||
*
|
||||
* @note Blocking is ignored in the RAM mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_read_lock_enable(NRF_CACHE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for blocking the cache content updates.
|
||||
*
|
||||
* Blocking of updates prevents updating of cache content on cache misses,
|
||||
* but the peripheral will continue to check for instruction/data fetches
|
||||
* in the content already present in the cache.
|
||||
*
|
||||
* @note Blocking is ignored in the RAM mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if cache content update lock is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_cache_update_lock_set(NRF_CACHE_Type * p_reg, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the cache data word.
|
||||
*
|
||||
* @note When operating in the RAM mode, the cache data is accessible as a general purpose RAM.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] set Set that contains the data to get.
|
||||
* @param[in] way Way that contains the data to get.
|
||||
* @param[in] word Data word index to get.
|
||||
*
|
||||
* @return 32-bit data word.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_get(NRF_CACHEDATA_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way,
|
||||
uint8_t word);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the tag associated with the specified set and way.
|
||||
*
|
||||
* The tag is used to check if an entry in the cache matches the address that is being fetched.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] set Set that contains the tag to get.
|
||||
* @param[in] way Way that contains the tag to get.
|
||||
*
|
||||
* @return Tag value.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_tag_get(NRF_CACHEINFO_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the validity of a cache line associated with the specified set and way.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] set Set that contains the cache line to check.
|
||||
* @param[in] way Way that contains the cache line to check.
|
||||
*
|
||||
* @retval true Cache line is valid.
|
||||
* @retval false Cache line is invalid.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_cache_line_validity_check(NRF_CACHEINFO_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the most recently used way in the specified set.
|
||||
*
|
||||
* The most recently used way is updated on each fetch from the cache and is used for the cache replacement policy.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] set Specified set.
|
||||
*
|
||||
* @return The most recently used way in the specified set.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_cache_mru_get(NRF_CACHEINFO_Type const * p_reg, uint32_t set);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_enable(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = CACHE_ENABLE_ENABLE_Enabled;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_disable(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = CACHE_ENABLE_ENABLE_Disabled;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_invalidate(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->INVALIDATE = CACHE_INVALIDATE_INVALIDATE_Invalidate;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_erase(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->ERASE = CACHE_ERASE_ERASE_Erase;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_cache_erase_status_check(NRF_CACHE_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->ERASESTATUS & CACHE_ERASESTATUS_ERASESTATUS_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_erase_status_clear(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->ERASESTATUS = 0;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_profiling_set(NRF_CACHE_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->PROFILINGENABLE =
|
||||
(enable ? CACHE_PROFILINGENABLE_ENABLE_Enable : CACHE_PROFILINGENABLE_ENABLE_Disable);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_profiling_counters_clear(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->PROFILINGCLEAR = (CACHE_PROFILINGCLEAR_CLEAR_Clear << CACHE_PROFILINGCLEAR_CLEAR_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_instruction_hit_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region)
|
||||
{
|
||||
return p_reg->PROFILING[region].IHIT;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_instruction_miss_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region)
|
||||
{
|
||||
return p_reg->PROFILING[region].IMISS;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_hit_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region)
|
||||
{
|
||||
return p_reg->PROFILING[region].DHIT;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_miss_counter_get(NRF_CACHE_Type const * p_reg,
|
||||
nrf_cache_region_t region)
|
||||
{
|
||||
return p_reg->PROFILING[region].DMISS;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_ram_mode_set(NRF_CACHE_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->MODE = (enable ? CACHE_MODE_MODE_Ram : CACHE_MODE_MODE_Cache);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_read_lock_enable(NRF_CACHE_Type * p_reg)
|
||||
{
|
||||
p_reg->DEBUGLOCK = CACHE_DEBUGLOCK_DEBUGLOCK_Locked;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_cache_update_lock_set(NRF_CACHE_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->WRITELOCK =
|
||||
(enable ? CACHE_WRITELOCK_WRITELOCK_Locked : CACHE_WRITELOCK_WRITELOCK_Unlocked);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_data_get(NRF_CACHEDATA_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way,
|
||||
uint8_t word)
|
||||
{
|
||||
volatile CACHEDATA_SET_WAY_Type const * reg = &p_reg->SET[set].WAY[way];
|
||||
switch (word)
|
||||
{
|
||||
case 0: return reg->DATA0;
|
||||
case 1: return reg->DATA1;
|
||||
case 2: return reg->DATA2;
|
||||
case 3: return reg->DATA3;
|
||||
default:
|
||||
NRFX_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_cache_tag_get(NRF_CACHEINFO_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way)
|
||||
{
|
||||
return (p_reg->SET[set].WAY[way] & CACHEINFO_SET_WAY_TAG_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_cache_line_validity_check(NRF_CACHEINFO_Type const * p_reg,
|
||||
uint32_t set,
|
||||
uint8_t way)
|
||||
{
|
||||
return (bool)(p_reg->SET[set].WAY[way] & CACHEINFO_SET_WAY_V_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_cache_mru_get(NRF_CACHEINFO_Type const * p_reg, uint32_t set)
|
||||
{
|
||||
return ((p_reg->SET[set].WAY[0] & CACHEINFO_SET_WAY_MRU_Msk) >> CACHEINFO_SET_WAY_MRU_Pos);
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_CACHE_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -120,8 +120,8 @@ typedef struct {
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific CCM task register.
|
||||
@@ -131,8 +131,8 @@ __STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a specific CCM event.
|
||||
@@ -140,8 +140,8 @@ __STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a specific CCM event.
|
||||
@@ -152,8 +152,8 @@ __STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific CCM event register.
|
||||
@@ -163,8 +163,8 @@ __STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
@@ -172,7 +172,7 @@ __STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -180,33 +180,31 @@ __STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ccm_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_int_mask_t ccm_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the CCM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the CCM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the CCM peripheral configuration.
|
||||
@@ -214,8 +212,8 @@ __STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_config Pointer to the structure with configuration to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config);
|
||||
NRF_STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config);
|
||||
|
||||
#if defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -225,8 +223,8 @@ __STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] size Maximum length of the key-stream.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
uint8_t size);
|
||||
NRF_STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
uint8_t size);
|
||||
#endif // defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -237,7 +235,7 @@ __STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
* @retval true The MIC check passed.
|
||||
* @retval false The MIC check failed.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the data structure
|
||||
@@ -246,8 +244,8 @@ __STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Pointer to the data structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the data structure
|
||||
@@ -257,7 +255,7 @@ __STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
*
|
||||
* @return Pointer to the data structure.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the input data pointer.
|
||||
@@ -265,8 +263,8 @@ __STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Input data pointer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the input data pointer.
|
||||
@@ -275,7 +273,7 @@ __STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
*
|
||||
* @return Input data pointer.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the output data pointer.
|
||||
@@ -283,8 +281,8 @@ __STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Output data pointer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the output data pointer.
|
||||
@@ -293,7 +291,7 @@ __STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
*
|
||||
* @return Output data pointer.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the scratch area used for
|
||||
@@ -302,8 +300,8 @@ __STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_area Pointer to the scratch area.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area);
|
||||
NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the scratch area.
|
||||
@@ -312,7 +310,7 @@ __STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
*
|
||||
* @return Pointer to the scratch area.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -322,26 +320,26 @@ __STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg);
|
||||
* @param[in] datarate Override value to be applied when the RATEOVERRIDE task
|
||||
* is triggered.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_datarate_t datarate);
|
||||
NRF_STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_datarate_t datarate);
|
||||
#endif // defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -350,46 +348,45 @@ __STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_int_mask_t ccm_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & ccm_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (CCM_ENABLE_ENABLE_Enabled << CCM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (CCM_ENABLE_ENABLE_Disabled << CCM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config)
|
||||
NRF_STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config)
|
||||
{
|
||||
p_reg->MODE = (((uint32_t)p_config->mode << CCM_MODE_MODE_Pos) |
|
||||
#if defined(CCM_MODE_DATARATE_Pos)
|
||||
@@ -402,8 +399,8 @@ __STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
}
|
||||
|
||||
#if defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos)
|
||||
__STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
uint8_t size)
|
||||
NRF_STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
uint8_t size)
|
||||
{
|
||||
NRFX_ASSERT((size >= 0x1B) && (size <= 0xFB));
|
||||
|
||||
@@ -411,64 +408,84 @@ __STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
|
||||
}
|
||||
#endif // defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos)
|
||||
|
||||
__STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->MICSTATUS);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->CNFPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
#if defined(NRF5340_XXAA_NETWORK)
|
||||
// Apply workaround for anomaly 10.
|
||||
return (uint32_t *)(p_reg->CNFPTR | 0x01000000);
|
||||
#else
|
||||
return (uint32_t *)(p_reg->CNFPTR);
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->INPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
#if defined(NRF5340_XXAA_NETWORK)
|
||||
// Apply workaround for anomaly 10.
|
||||
return (uint32_t *)(p_reg->INPTR | 0x01000000);
|
||||
#else
|
||||
return (uint32_t *)(p_reg->INPTR);
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->OUTPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
#if defined(NRF5340_XXAA_NETWORK)
|
||||
// Apply workaround for anomaly 10.
|
||||
return (uint32_t *)(p_reg->OUTPTR | 0x01000000);
|
||||
#else
|
||||
return (uint32_t *)(p_reg->OUTPTR);
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area)
|
||||
NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area)
|
||||
{
|
||||
p_reg->SCRATCHPTR = (uint32_t)p_area;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
#if defined(NRF5340_XXAA_NETWORK)
|
||||
// Apply workaround for anomaly 10.
|
||||
return (uint32_t *)(p_reg->SCRATCHPTR | 0x01000000);
|
||||
#else
|
||||
return (uint32_t *)(p_reg->SCRATCHPTR);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos)
|
||||
__STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_datarate_t datarate)
|
||||
NRF_STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_datarate_t datarate)
|
||||
{
|
||||
p_reg->RATEOVERRIDE = ((uint32_t)datarate << CCM_RATEOVERRIDE_RATEOVERRIDE_Pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -77,7 +77,13 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
NRF_COMP_EXT_REF_0 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference0, /*!< Use AIN0 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_1 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference1 /*!< Use AIN1 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_1 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference1, /*!< Use AIN1 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_2 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference2, /*!< Use AIN2 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_3 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference3, /*!< Use AIN3 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_4 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference4, /*!< Use AIN4 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_5 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference5, /*!< Use AIN5 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_6 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference6, /*!< Use AIN6 as external analog reference. */
|
||||
NRF_COMP_EXT_REF_7 = COMP_EXTREFSEL_EXTREFSEL_AnalogReference7 /*!< Use AIN7 as external analog reference. */
|
||||
} nrf_comp_ext_ref_t;
|
||||
|
||||
/** @brief COMP THDOWN and THUP values that are used to calculate the threshold voltages VDOWN and VUP. */
|
||||
@@ -145,293 +151,330 @@ typedef struct
|
||||
} nrf_comp_ref_conf_t;
|
||||
|
||||
|
||||
/** @brief Function for enabling the COMP peripheral. */
|
||||
__STATIC_INLINE void nrf_comp_enable(void);
|
||||
/**
|
||||
* @brief Function for enabling the COMP peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_comp_enable(NRF_COMP_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling the COMP peripheral. */
|
||||
__STATIC_INLINE void nrf_comp_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling the COMP peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_comp_disable(NRF_COMP_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the COMP peripheral is enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The COMP peripheral is enabled.
|
||||
* @retval false The COMP peripheral is not enabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_comp_enable_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_comp_enable_check(NRF_COMP_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the reference source.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] reference COMP reference selection.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_ref_set(nrf_comp_ref_t reference);
|
||||
NRF_STATIC_INLINE void nrf_comp_ref_set(NRF_COMP_Type * p_reg, nrf_comp_ref_t reference);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the external analog reference source.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ext_ref COMP external analog reference selection.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_ext_ref_set(nrf_comp_ext_ref_t ext_ref);
|
||||
NRF_STATIC_INLINE void nrf_comp_ext_ref_set(NRF_COMP_Type * p_reg, nrf_comp_ext_ref_t ext_ref);
|
||||
|
||||
/**
|
||||
* @brief Function for setting threshold voltages.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] threshold COMP VDOWN and VUP thresholds.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_th_set(nrf_comp_th_t threshold);
|
||||
NRF_STATIC_INLINE void nrf_comp_th_set(NRF_COMP_Type * p_reg, nrf_comp_th_t threshold);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the main mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] main_mode COMP main operation mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_main_mode_set(nrf_comp_main_mode_t main_mode);
|
||||
NRF_STATIC_INLINE void nrf_comp_main_mode_set(NRF_COMP_Type * p_reg,
|
||||
nrf_comp_main_mode_t main_mode);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the speed mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] speed_mode COMP speed and power mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_speed_mode_set(nrf_comp_sp_mode_t speed_mode);
|
||||
NRF_STATIC_INLINE void nrf_comp_speed_mode_set(NRF_COMP_Type * p_reg,
|
||||
nrf_comp_sp_mode_t speed_mode);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the hysteresis.
|
||||
*
|
||||
* @param[in] hyst COMP comparator hysteresis.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] hyst COMP comparator hysteresis.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_hysteresis_set(nrf_comp_hyst_t hyst);
|
||||
NRF_STATIC_INLINE void nrf_comp_hysteresis_set(NRF_COMP_Type * p_reg, nrf_comp_hyst_t hyst);
|
||||
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for setting the current source on the analog input.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] isource COMP current source selection on analog input.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_isource_set(nrf_isource_t isource);
|
||||
NRF_STATIC_INLINE void nrf_comp_isource_set(NRF_COMP_Type * p_reg, nrf_isource_t isource);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for selecting the active input of the COMP.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] input Input to be selected.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_input_select(nrf_comp_input_t input);
|
||||
NRF_STATIC_INLINE void nrf_comp_input_select(NRF_COMP_Type * p_reg, nrf_comp_input_t input);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the last COMP compare result.
|
||||
*
|
||||
* @note If VIN+ == VIN-, the return value depends on the previous result.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The last compare result. If 0, then VIN+ < VIN-. If 1, then VIN+ > VIN-.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_comp_result_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_result_get(NRF_COMP_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts from COMP.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*
|
||||
* @sa nrf_comp_int_enable_check
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_int_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_comp_int_enable(NRF_COMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts from COMP.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*
|
||||
* @sa nrf_comp_int_enable_check
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_int_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_comp_int_disable(NRF_COMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the enabled interrupts of COMP.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true At least one interrupt from the specified mask is enabled.
|
||||
* @retval false No interrupt provided by the specified mask are enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_comp_int_enable_check(uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_int_enable_check(NRF_COMP_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified COMP task register.
|
||||
*
|
||||
* @param[in] task COMP task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task COMP task.
|
||||
*
|
||||
* @return Address of the specified COMP task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_comp_task_address_get(nrf_comp_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_task_address_get(NRF_COMP_Type const * p_reg,
|
||||
nrf_comp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified COMP event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event COMP event.
|
||||
*
|
||||
* @return Address of the specified COMP event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_comp_event_address_get(nrf_comp_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_event_address_get(NRF_COMP_Type const * p_reg,
|
||||
nrf_comp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting COMP shortcuts.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_shorts_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_comp_shorts_enable(NRF_COMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing COMP shortcuts by mask.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_shorts_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_comp_shorts_disable(NRF_COMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified COMP task.
|
||||
*
|
||||
* @param[in] task Task to be activated.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_task_trigger(nrf_comp_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_comp_task_trigger(NRF_COMP_Type * p_reg, nrf_comp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified COMP event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event COMP event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_comp_event_clear(nrf_comp_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_comp_event_clear(NRF_COMP_Type * p_reg, nrf_comp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the UARTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_comp_event_check(nrf_comp_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_comp_event_check(NRF_COMP_Type const * p_reg, nrf_comp_event_t event);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_comp_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_comp_enable(NRF_COMP_Type * p_reg)
|
||||
{
|
||||
NRF_COMP->ENABLE = (COMP_ENABLE_ENABLE_Enabled << COMP_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (COMP_ENABLE_ENABLE_Enabled << COMP_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_comp_disable(NRF_COMP_Type * p_reg)
|
||||
{
|
||||
NRF_COMP->ENABLE = (COMP_ENABLE_ENABLE_Disabled << COMP_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (COMP_ENABLE_ENABLE_Disabled << COMP_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_comp_enable_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_comp_enable_check(NRF_COMP_Type const * p_reg)
|
||||
{
|
||||
return ((NRF_COMP->ENABLE) & COMP_ENABLE_ENABLE_Enabled);
|
||||
return ((p_reg->ENABLE) & COMP_ENABLE_ENABLE_Enabled);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_ref_set(nrf_comp_ref_t reference)
|
||||
NRF_STATIC_INLINE void nrf_comp_ref_set(NRF_COMP_Type * p_reg, nrf_comp_ref_t reference)
|
||||
{
|
||||
NRF_COMP->REFSEL = (reference << COMP_REFSEL_REFSEL_Pos);
|
||||
p_reg->REFSEL = (reference << COMP_REFSEL_REFSEL_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_ext_ref_set(nrf_comp_ext_ref_t ext_ref)
|
||||
NRF_STATIC_INLINE void nrf_comp_ext_ref_set(NRF_COMP_Type * p_reg, nrf_comp_ext_ref_t ext_ref)
|
||||
{
|
||||
NRF_COMP->EXTREFSEL = (ext_ref << COMP_EXTREFSEL_EXTREFSEL_Pos);
|
||||
p_reg->EXTREFSEL = (ext_ref << COMP_EXTREFSEL_EXTREFSEL_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_th_set(nrf_comp_th_t threshold)
|
||||
NRF_STATIC_INLINE void nrf_comp_th_set(NRF_COMP_Type * p_reg, nrf_comp_th_t threshold)
|
||||
{
|
||||
NRF_COMP->TH =
|
||||
p_reg->TH =
|
||||
(((uint32_t)threshold.th_down << COMP_TH_THDOWN_Pos) & COMP_TH_THDOWN_Msk) |
|
||||
(((uint32_t)threshold.th_up << COMP_TH_THUP_Pos) & COMP_TH_THUP_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_main_mode_set(nrf_comp_main_mode_t main_mode)
|
||||
NRF_STATIC_INLINE void nrf_comp_main_mode_set(NRF_COMP_Type * p_reg,
|
||||
nrf_comp_main_mode_t main_mode)
|
||||
{
|
||||
NRF_COMP->MODE |= (main_mode << COMP_MODE_MAIN_Pos);
|
||||
p_reg->MODE |= (main_mode << COMP_MODE_MAIN_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_speed_mode_set(nrf_comp_sp_mode_t speed_mode)
|
||||
NRF_STATIC_INLINE void nrf_comp_speed_mode_set(NRF_COMP_Type * p_reg,
|
||||
nrf_comp_sp_mode_t speed_mode)
|
||||
{
|
||||
NRF_COMP->MODE |= (speed_mode << COMP_MODE_SP_Pos);
|
||||
p_reg->MODE |= (speed_mode << COMP_MODE_SP_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_hysteresis_set(nrf_comp_hyst_t hyst)
|
||||
NRF_STATIC_INLINE void nrf_comp_hysteresis_set(NRF_COMP_Type * p_reg, nrf_comp_hyst_t hyst)
|
||||
{
|
||||
NRF_COMP->HYST = (hyst << COMP_HYST_HYST_Pos) & COMP_HYST_HYST_Msk;
|
||||
p_reg->HYST = (hyst << COMP_HYST_HYST_Pos) & COMP_HYST_HYST_Msk;
|
||||
}
|
||||
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk)
|
||||
__STATIC_INLINE void nrf_comp_isource_set(nrf_isource_t isource)
|
||||
NRF_STATIC_INLINE void nrf_comp_isource_set(NRF_COMP_Type * p_reg, nrf_isource_t isource)
|
||||
{
|
||||
NRF_COMP->ISOURCE = (isource << COMP_ISOURCE_ISOURCE_Pos) & COMP_ISOURCE_ISOURCE_Msk;
|
||||
p_reg->ISOURCE = (isource << COMP_ISOURCE_ISOURCE_Pos) & COMP_ISOURCE_ISOURCE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_comp_input_select(nrf_comp_input_t input)
|
||||
NRF_STATIC_INLINE void nrf_comp_input_select(NRF_COMP_Type * p_reg, nrf_comp_input_t input)
|
||||
{
|
||||
NRF_COMP->PSEL = ((uint32_t)input << COMP_PSEL_PSEL_Pos);
|
||||
p_reg->PSEL = ((uint32_t)input << COMP_PSEL_PSEL_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_comp_result_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_result_get(NRF_COMP_Type const * p_reg)
|
||||
{
|
||||
return (uint32_t)NRF_COMP->RESULT;
|
||||
return (uint32_t)p_reg->RESULT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_int_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_comp_int_enable(NRF_COMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_COMP->INTENSET = mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_int_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_comp_int_disable(NRF_COMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_COMP->INTENCLR = mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_comp_int_enable_check(uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_int_enable_check(NRF_COMP_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (NRF_COMP->INTENSET & mask); // When read, this register returns the value of INTEN.
|
||||
return p_reg->INTENSET & mask; // When read, this register returns the value of INTEN.
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_comp_task_address_get(nrf_comp_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_task_address_get(NRF_COMP_Type const * p_reg,
|
||||
nrf_comp_task_t task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_comp_event_address_get(nrf_comp_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_comp_event_address_get(NRF_COMP_Type const * p_reg,
|
||||
nrf_comp_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_shorts_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_comp_shorts_enable(NRF_COMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_COMP->SHORTS |= mask;
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_shorts_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_comp_shorts_disable(NRF_COMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_COMP->SHORTS &= ~mask;
|
||||
p_reg->SHORTS &= ~mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_task_trigger(nrf_comp_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_comp_task_trigger(NRF_COMP_Type * p_reg, nrf_comp_task_t task)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_COMP + (uint32_t)task) ) = 1;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)task) ) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_comp_event_clear(nrf_comp_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_comp_event_clear(NRF_COMP_Type * p_reg, nrf_comp_event_t event)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_COMP + (uint32_t)event) ) = 0;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event) ) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_comp_event_check(nrf_comp_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_comp_event_check(NRF_COMP_Type const * p_reg, nrf_comp_event_t event)
|
||||
{
|
||||
return (bool) (*(volatile uint32_t *)( (uint8_t *)NRF_COMP + (uint32_t)event));
|
||||
return (bool) (*(volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event));
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_DCNF_H__
|
||||
#define NRF_DCNF_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_dcnf_hal DCNF HAL
|
||||
* @{
|
||||
* @ingroup nrf_dcnf
|
||||
* @brief Hardware access layer for managing the Domain Configuration (DCNF) module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function for getting the value of the CPU ID.
|
||||
*
|
||||
* CPU ID can be used to identify the specific CPU in the multi-core environment.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return CPU ID.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg);
|
||||
|
||||
#if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
|
||||
/**
|
||||
* @brief Function for configuring the control access to local peripheral memory regions.
|
||||
* Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
* @param[in] mask Mask of the AHB slaves to be protected from being accessed
|
||||
* by external AHB masters.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configuration of control access to local peripheral
|
||||
* memory regions. Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
*
|
||||
* @return Mask of the AHB slaves that are currently protected.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx);
|
||||
#endif // defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
|
||||
|
||||
#if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
|
||||
/**
|
||||
* @brief Function for configuring the control access to local RAM memory regions.
|
||||
* Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
* @param[in] mask Mask of the AHB slaves to be protected from being accessed
|
||||
* by external AHB masters.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configuration of control access to local RAM
|
||||
* memory regions. Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
*
|
||||
* @return Mask of the AHB slaves that are currently protected.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx);
|
||||
#endif // defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
|
||||
|
||||
#if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
|
||||
/**
|
||||
* @brief Function for configuring the control access to local code memory regions.
|
||||
* Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
* @param[in] mask Mask of the AHB slaves to be protected from being accessed
|
||||
* by external AHB masters.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configuration of control access to local code
|
||||
* memory regions. Intended for external master connected to specified AMLI master port.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] port_idx Index of the master port to configure.
|
||||
*
|
||||
* @return Mask of the AHB slaves that are currently protected.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx);
|
||||
#endif // defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg)
|
||||
{
|
||||
return p_reg->CPUID;
|
||||
}
|
||||
|
||||
#if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
|
||||
NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->EXTPERI[port_idx].PROTECT = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx)
|
||||
{
|
||||
return p_reg->EXTPERI[port_idx].PROTECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
|
||||
NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->EXTRAM[port_idx].PROTECT = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx)
|
||||
{
|
||||
return p_reg->EXTRAM[port_idx].PROTECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
|
||||
NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
|
||||
uint8_t port_idx,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->EXTCODE[port_idx].PROTECT = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
|
||||
uint8_t port_idx)
|
||||
{
|
||||
return p_reg->EXTCODE[port_idx].PROTECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DCNF_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -80,7 +80,7 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] dppi_task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task);
|
||||
NRF_STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified DPPI task register.
|
||||
@@ -90,8 +90,8 @@ __STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
|
||||
nrf_dppi_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
|
||||
nrf_dppi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the state of a specific DPPI channel.
|
||||
@@ -102,7 +102,7 @@ __STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
|
||||
* @retval true The channel is enabled.
|
||||
* @retval false The channel is not enabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel);
|
||||
NRF_STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling multiple DPPI channels.
|
||||
@@ -113,7 +113,7 @@ __STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Channel mask.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling multiple DPPI channels.
|
||||
@@ -124,14 +124,14 @@ __STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t m
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Channel mask.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling all DPPI channels.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the subscribe configuration for a given
|
||||
@@ -141,9 +141,9 @@ __STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg);
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -152,7 +152,7 @@ __STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for including multiple DPPI channels in a channel group.
|
||||
@@ -165,9 +165,9 @@ __STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_t
|
||||
* @param[in] channel_mask Channels to be included in the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing multiple DPPI channels from a channel group.
|
||||
@@ -180,9 +180,9 @@ __STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type *
|
||||
* @param[in] channel_mask Channels to be removed from the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing all DPPI channels from a channel group.
|
||||
@@ -190,8 +190,8 @@ __STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type *
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a channel group.
|
||||
@@ -199,8 +199,8 @@ __STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a channel group.
|
||||
@@ -208,8 +208,8 @@ __STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the ENABLE task associated with the specified channel group.
|
||||
@@ -218,7 +218,7 @@ __STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
|
||||
*
|
||||
* @return Requested ENABLE task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the DISABLE task associated with the specified channel group.
|
||||
@@ -227,101 +227,102 @@ __STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index);
|
||||
*
|
||||
* @return Requested DISABLE task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task)
|
||||
NRF_STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) dppi_task)) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
|
||||
nrf_dppi_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
|
||||
nrf_dppi_task_t task)
|
||||
{
|
||||
return (uint32_t) ((uint8_t *) p_reg + (uint32_t ) task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel)
|
||||
NRF_STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(channel < DPPI_CH_NUM);
|
||||
return ((p_reg->CHEN & (DPPIC_CHEN_CH0_Enabled << (DPPIC_CHEN_CH0_Pos + channel))) != 0);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg)
|
||||
{
|
||||
p_reg->CHENCLR = 0xFFFFFFFFuL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->CHENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->CHENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(channel < DPPI_CH_NUM);
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group)
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group)
|
||||
{
|
||||
p_reg->CHG[(uint32_t) channel_group] =
|
||||
p_reg->CHG[(uint32_t) channel_group] | (channel_mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group)
|
||||
NRF_STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_dppi_channel_group_t channel_group)
|
||||
{
|
||||
p_reg->CHG[(uint32_t) channel_group] =
|
||||
p_reg->CHG[(uint32_t) channel_group] & ~(channel_mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group)
|
||||
{
|
||||
p_reg->CHG[(uint32_t) group] = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg, nrf_dppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg, nrf_dppi_channel_group_t group)
|
||||
{
|
||||
p_reg->TASKS_CHG[(uint32_t) group].EN = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
|
||||
nrf_dppi_channel_group_t group)
|
||||
{
|
||||
p_reg->TASKS_CHG[(uint32_t) group].DIS = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_DPPIC->TASKS_CHG));
|
||||
NRFX_ASSERT(index < DPPI_GROUP_NUM);
|
||||
return (nrf_dppi_task_t)NRFX_OFFSETOF(NRF_DPPIC_Type, TASKS_CHG[index].EN);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_DPPIC->TASKS_CHG));
|
||||
NRFX_ASSERT(index < DPPI_GROUP_NUM);
|
||||
return (nrf_dppi_task_t)NRFX_OFFSETOF(NRF_DPPIC_Type, TASKS_CHG[index].DIS);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,49 +38,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ecb_drv AES ECB encryption driver
|
||||
* @{
|
||||
* @ingroup nrf_ecb
|
||||
* @brief Driver for the Advanced Encryption Standard (AES) Electronic Code Book (ECB) peripheral.
|
||||
*
|
||||
* To encrypt data, the peripheral must first be powered on
|
||||
* using @ref nrf_ecb_init. Next, the key must be set using @ref nrf_ecb_set_key.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function for initializing and powering on the ECB peripheral.
|
||||
*
|
||||
* This function allocates memory for the ECBDATAPTR.
|
||||
*
|
||||
* @retval true The initialization was successful.
|
||||
* @retval false The power-on failed.
|
||||
*/
|
||||
bool nrf_ecb_init(void);
|
||||
|
||||
/**
|
||||
* @brief Function for encrypting 16-byte data using current key.
|
||||
*
|
||||
* This function avoids unnecessary copying of data if the parameters point to the
|
||||
* correct locations in the ECB data structure.
|
||||
*
|
||||
* @param dst Result of encryption, 16 bytes will be written.
|
||||
* @param src Source with 16-byte data to be encrypted.
|
||||
*
|
||||
* @retval true The encryption operation completed.
|
||||
* @retval false The encryption operation did not complete.
|
||||
*/
|
||||
bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the key to be used for encryption.
|
||||
*
|
||||
* @param key Pointer to the key. 16 bytes will be read.
|
||||
*/
|
||||
void nrf_ecb_set_key(const uint8_t * key);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ecb_hal AES ECB encryption HAL
|
||||
* @{
|
||||
@@ -116,7 +73,7 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified ECB task register.
|
||||
@@ -126,8 +83,8 @@ __STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t t
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified ECB event.
|
||||
@@ -135,7 +92,7 @@ __STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the ECB event.
|
||||
@@ -146,7 +103,7 @@ __STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t e
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified ECB event register.
|
||||
@@ -156,8 +113,8 @@ __STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_eve
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -165,7 +122,7 @@ __STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] mask Interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -173,19 +130,17 @@ __STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] mask Interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] ecb_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_int_mask_t ecb_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the ECB data buffer.
|
||||
@@ -196,7 +151,7 @@ __STATIC_INLINE bool nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] p_buffer Pointer to the ECB data buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer);
|
||||
NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the ECB data buffer.
|
||||
@@ -205,22 +160,22 @@ __STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const *
|
||||
*
|
||||
* @return Pointer to the ECB data buffer.
|
||||
*/
|
||||
__STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg);
|
||||
NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -229,44 +184,43 @@ __STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t e
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg,
|
||||
nrf_ecb_int_mask_t ecb_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & ecb_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer)
|
||||
NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer)
|
||||
{
|
||||
p_reg->ECBDATAPTR = (uint32_t)p_buffer;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg)
|
||||
NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg)
|
||||
{
|
||||
return (void *)(p_reg->ECBDATAPTR);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -113,142 +113,113 @@ typedef enum
|
||||
/**
|
||||
* @brief Function for getting the maximum channel number of the given EGU.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Number of available channels.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx);
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the specified EGU task.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param egu_task EGU task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] egu_task EGU task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task);
|
||||
NRF_STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * p_reg, nrf_egu_task_t egu_task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified EGU task register.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param egu_task EGU task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] egu_task EGU task.
|
||||
*
|
||||
* @return Address of the specified EGU task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_task_t egu_task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified EGU TRIGGER task register.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param channel Channel number.
|
||||
*
|
||||
* @return Address of the specified EGU TRIGGER task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_task_address_get(NRF_EGU_Type const * p_reg,
|
||||
nrf_egu_task_t egu_task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the specified EGU TRIGGER task.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param channel Channel number.
|
||||
* @param[in] channel Channel number.
|
||||
*
|
||||
* @return The specified EGU TRIGGER task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
|
||||
NRF_STATIC_INLINE nrf_egu_task_t nrf_egu_trigger_task_get(uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the UARTE event.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param egu_event EGU event to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] egu_event EGU event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event);
|
||||
NRF_STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type const * p_reg, nrf_egu_event_t egu_event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified EGU event.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param egu_event EGU event to clear.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] egu_event EGU event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event);
|
||||
NRF_STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * p_reg, nrf_egu_event_t egu_event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified EGU event register.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param egu_event EGU event.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] egu_event EGU event.
|
||||
*
|
||||
* @return Address of the specified EGU event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning address of the specified EGU TRIGGERED event register.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param channel Channel number.
|
||||
*
|
||||
* @return Address of the specified EGU TRIGGERED event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_event_address_get(NRF_EGU_Type const * p_reg,
|
||||
nrf_egu_event_t egu_event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the specified EGU TRIGGERED event.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param channel Channel number.
|
||||
* @param[in] channel Channel number.
|
||||
*
|
||||
* @return The specified EGU TRIGGERED event.
|
||||
*/
|
||||
__STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE nrf_egu_event_t nrf_egu_triggered_event_get(uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling one or more of the EGU interrupts.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of one or more of the EGU interrupts.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true All of the specified interrupts are enabled.
|
||||
* @retval false At least one of the specified interrupts is disabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_int_enable_check(NRF_EGU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling one or more of the EGU interrupts.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving one or more of the EGU interrupts.
|
||||
* @brief Function for retrieving the state of interrupt of the specified EGU channel.
|
||||
*
|
||||
* @param NRF_EGUx EGU instance.
|
||||
* @param channel Channel number.
|
||||
* @param[in] channel Channel number.
|
||||
*
|
||||
* @return EGU interrupt mask.
|
||||
*/
|
||||
__STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
|
||||
NRF_STATIC_INLINE nrf_egu_int_mask_t nrf_egu_channel_int_get(uint8_t channel);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -259,9 +230,9 @@ __STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -270,8 +241,8 @@ __STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -281,9 +252,9 @@ __STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -292,162 +263,139 @@ __STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx)
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type const * p_reg)
|
||||
{
|
||||
if (NRF_EGUx == NRF_EGU0){
|
||||
if (p_reg == NRF_EGU0){
|
||||
return EGU0_CH_NUM;
|
||||
}
|
||||
if (NRF_EGUx == NRF_EGU1){
|
||||
#if EGU_COUNT > 1
|
||||
if (p_reg == NRF_EGU1){
|
||||
return EGU1_CH_NUM;
|
||||
}
|
||||
#endif
|
||||
#if EGU_COUNT > 2
|
||||
if (NRF_EGUx == NRF_EGU2){
|
||||
if (p_reg == NRF_EGU2){
|
||||
return EGU2_CH_NUM;
|
||||
}
|
||||
if (NRF_EGUx == NRF_EGU3){
|
||||
if (p_reg == NRF_EGU3){
|
||||
return EGU3_CH_NUM;
|
||||
}
|
||||
if (NRF_EGUx == NRF_EGU4){
|
||||
if (p_reg == NRF_EGU4){
|
||||
return EGU4_CH_NUM;
|
||||
}
|
||||
if (NRF_EGUx == NRF_EGU5){
|
||||
if (p_reg == NRF_EGU5){
|
||||
return EGU5_CH_NUM;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task)
|
||||
NRF_STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * p_reg, nrf_egu_task_t egu_task)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task)) = 0x1UL;
|
||||
NRFX_ASSERT(p_reg);
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)egu_task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_task_t egu_task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_task_address_get(NRF_EGU_Type const * p_reg,
|
||||
nrf_egu_task_t egu_task)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task);
|
||||
NRFX_ASSERT(p_reg);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)egu_task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE nrf_egu_task_t nrf_egu_trigger_task_get(uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
|
||||
return (uint32_t*)&NRF_EGUx->TASKS_TRIGGER[channel];
|
||||
return (nrf_egu_task_t)NRFX_OFFSETOF(NRF_EGU_Type, TASKS_TRIGGER[channel]);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
|
||||
NRF_STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type const * p_reg, nrf_egu_event_t egu_event)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
|
||||
return (nrf_egu_task_t)((uint32_t) NRF_EGU_TASK_TRIGGER0 + (channel * sizeof(uint32_t)));
|
||||
NRFX_ASSERT(p_reg);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)egu_event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event)
|
||||
NRF_STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * p_reg, nrf_egu_event_t egu_event)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event)) = 0x0UL;
|
||||
NRFX_ASSERT(p_reg);
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)egu_event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)egu_event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
nrf_egu_event_t egu_event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_event_address_get(NRF_EGU_Type const * p_reg,
|
||||
nrf_egu_event_t egu_event)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
|
||||
NRFX_ASSERT(p_reg);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)egu_event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE nrf_egu_event_t nrf_egu_triggered_event_get(uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
|
||||
return (uint32_t*)&NRF_EGUx->EVENTS_TRIGGERED[channel];
|
||||
return (nrf_egu_event_t)NRFX_OFFSETOF(NRF_EGU_Type, EVENTS_TRIGGERED[channel]);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
|
||||
return (nrf_egu_event_t)((uint32_t) NRF_EGU_EVENT_TRIGGERED0 + (channel * sizeof(uint32_t)));
|
||||
NRFX_ASSERT(p_reg);
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_egu_int_enable_check(NRF_EGU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRF_EGUx->INTENSET = mask;
|
||||
NRFX_ASSERT(p_reg);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
return (bool)(NRF_EGUx->INTENSET & mask);
|
||||
NRFX_ASSERT(p_reg);
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
|
||||
NRF_STATIC_INLINE nrf_egu_int_mask_t nrf_egu_channel_int_get(uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRF_EGUx->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
|
||||
{
|
||||
NRFX_ASSERT(NRF_EGUx);
|
||||
NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
|
||||
return (nrf_egu_int_mask_t)((uint32_t) (EGU_INTENSET_TRIGGERED0_Msk << channel));
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | EGU_SUBSCRIBE_TRIGGER_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | EGU_PUBLISH_TRIGGERED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
|
||||
nrf_egu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_FICR_H__
|
||||
#define NRF_FICR_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ficr_hal FICR HAL
|
||||
* @{
|
||||
* @ingroup nrf_ficr
|
||||
* @brief Hardware access layer (HAL) for getting data from
|
||||
* the Factory Information Configuration Registers (FICR).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function for getting the size of the code memory page.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Code memory page size in bytes.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_codepagesize_get(NRF_FICR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the size of the code memory rendered as number of pages.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Code memory size rendered as number of pages.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_codesize_get(NRF_FICR_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the unique device identifier.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] reg_id Register index.
|
||||
*
|
||||
* @return Unique device identifier.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_deviceid_get(NRF_FICR_Type const * p_reg, uint32_t reg_id);
|
||||
|
||||
#if defined(FICR_NFC_TAGHEADER0_MFGID_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the default header values for the NFC tag.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] tagheader_id Tag header index.
|
||||
*
|
||||
* @return The default header value of the NFC tag for the specified header index.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_nfc_tagheader_get(NRF_FICR_Type const * p_reg,
|
||||
uint32_t tagheader_id);
|
||||
#endif // defined(FICR_NFC_TAGHEADER0_MFGID_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_codepagesize_get(NRF_FICR_Type const * p_reg)
|
||||
{
|
||||
#if defined(FICR_INFO_CODEPAGESIZE_CODEPAGESIZE_Msk)
|
||||
return p_reg->INFO.CODEPAGESIZE;
|
||||
#else
|
||||
return p_reg->CODEPAGESIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_codesize_get(NRF_FICR_Type const * p_reg)
|
||||
{
|
||||
#if defined(FICR_INFO_CODESIZE_CODESIZE_Msk)
|
||||
return p_reg->INFO.CODESIZE;
|
||||
#else
|
||||
return p_reg->CODESIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_deviceid_get(NRF_FICR_Type const * p_reg, uint32_t reg_id)
|
||||
{
|
||||
#if defined(FICR_INFO_DEVICEID_DEVICEID_Msk)
|
||||
return p_reg->INFO.DEVICEID[reg_id];
|
||||
#else
|
||||
return p_reg->DEVICEID[reg_id];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FICR_NFC_TAGHEADER0_MFGID_Msk)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ficr_nfc_tagheader_get(NRF_FICR_Type const * p_reg,
|
||||
uint32_t tagheader_id)
|
||||
{
|
||||
switch(tagheader_id) {
|
||||
case 0:
|
||||
return p_reg->NFC.TAGHEADER0;
|
||||
case 1:
|
||||
return p_reg->NFC.TAGHEADER1;
|
||||
case 2:
|
||||
return p_reg->NFC.TAGHEADER2;
|
||||
case 3:
|
||||
return p_reg->NFC.TAGHEADER3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // defined(FICR_NFC_TAGHEADER0_MFGID_Msk)
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_FICR_H__
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_FPU_H__
|
||||
#define NRF_FPU_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_fpu_hal FPU HAL
|
||||
* @{
|
||||
* @ingroup nrf_fpu
|
||||
* @brief Hardware access layer (HAL) for managing the Floating Point Unit configuration.
|
||||
*/
|
||||
|
||||
/** @brief FPU events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_FPU_EVENT_INVALIDOPERATION = offsetof(NRF_FPU_Type, EVENTS_INVALIDOPERATION), /**< An FPUIOC exception triggered by an invalid operation has occurred in the FPU. */
|
||||
NRF_FPU_EVENT_DIVIDEBYZERO = offsetof(NRF_FPU_Type, EVENTS_DIVIDEBYZERO), /**< An FPUDZC exception triggered by a floating-point divide-by-zero operation has occurred in the FPU. */
|
||||
NRF_FPU_EVENT_OVERFLOW = offsetof(NRF_FPU_Type, EVENTS_OVERFLOW), /**< An FPUOFC exception triggered by a floating-point overflow has occurred in the FPU. */
|
||||
NRF_FPU_EVENT_UNDERFLOW = offsetof(NRF_FPU_Type, EVENTS_UNDERFLOW), /**< An FPUUFC exception triggered by a floating-point underflow has occurred in the FPU. */
|
||||
NRF_FPU_EVENT_INEXACT = offsetof(NRF_FPU_Type, EVENTS_INEXACT), /**< An FPUIXC exception triggered by an inexact floating-point operation has occurred in the FPU. */
|
||||
NRF_FPU_EVENT_DENORMALINPUT = offsetof(NRF_FPU_Type, EVENTS_DENORMALINPUT), /**< An FPUIDC exception triggered by a denormal floating-point input has occurred in the FPU. */
|
||||
} nrf_fpu_event_t;
|
||||
|
||||
|
||||
|
||||
/** @brief FPU interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_FPU_INT_INVALIDOPERATION = FPU_INTEN_INVALIDOPERATION_Msk, /**< Interrupt on event INVALIDOPERATION. */
|
||||
NRF_FPU_INT_DIVIDEBYZERO = FPU_INTEN_DIVIDEBYZERO_Msk, /**< Interrupt on event DIVIDEBYZERO. */
|
||||
NRF_FPU_INT_OVERFLOW = FPU_INTEN_OVERFLOW_Msk, /**< Interrupt on event OVERFLOW. */
|
||||
NRF_FPU_INT_UNDERFLOW = FPU_INTEN_UNDERFLOW_Msk, /**< Interrupt on event UNDERFLOW. */
|
||||
NRF_FPU_INT_INEXACT = FPU_INTEN_INEXACT_Msk, /**< Interrupt on event INEXACT. */
|
||||
NRF_FPU_INT_DENORMALINPUT = FPU_INTEN_DENORMALINPUT_Msk, /**< Interrupt on event DENORMALINPUT. */
|
||||
} nrf_fpu_int_mask_t;
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified FPU event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_fpu_event_clear(NRF_FPU_Type * p_reg,
|
||||
nrf_fpu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the FPU event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_fpu_event_check(NRF_FPU_Type const * p_reg,
|
||||
nrf_fpu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_fpu_int_enable(NRF_FPU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_fpu_int_disable(NRF_FPU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_fpu_int_enable_check(NRF_FPU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_fpu_event_clear(NRF_FPU_Type * p_reg,
|
||||
nrf_fpu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_fpu_event_check(NRF_FPU_Type const * p_reg,
|
||||
nrf_fpu_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_fpu_int_enable(NRF_FPU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_fpu_int_disable(NRF_FPU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_fpu_int_enable_check(NRF_FPU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_FPU_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -59,6 +59,11 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the GPIO peripheral.
|
||||
*/
|
||||
|
||||
#if defined(GPIO_LATCH_PIN0_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether the functionality of latching GPIO state change is present. */
|
||||
#define NRF_GPIO_LATCH_PRESENT
|
||||
#endif
|
||||
|
||||
/** @brief Macro for mapping port and pin numbers to values understandable for nrf_gpio functions. */
|
||||
#define NRF_GPIO_PIN_MAP(port, pin) (((port) << 5) | ((pin) & 0x1F))
|
||||
|
||||
@@ -91,14 +96,35 @@ typedef enum
|
||||
/** @brief Enumerator used for selecting output drive mode. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1, ///< !< Standard '0', standard '1'.
|
||||
NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1, ///< !< High-drive '0', standard '1'.
|
||||
NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1, ///< !< Standard '0', high-drive '1'.
|
||||
NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1, ///< !< High drive '0', high-drive '1'.
|
||||
NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1, ///< !< Disconnect '0' standard '1'.
|
||||
NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1, ///< !< Disconnect '0', high-drive '1'.
|
||||
NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1, ///< !< Standard '0', disconnect '1'.
|
||||
NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1, ///< !< High-drive '0', disconnect '1'.
|
||||
NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1, ///< Standard '0', standard '1'.
|
||||
NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1, ///< High drive '0', standard '1'.
|
||||
NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1, ///< Standard '0', high drive '1'.
|
||||
NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1, ///< High drive '0', high drive '1'.
|
||||
NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1, ///< Disconnect '0' standard '1'.
|
||||
NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1, ///< Disconnect '0', high drive '1'.
|
||||
NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1, ///< Standard '0', disconnect '1'.
|
||||
NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1, ///< High drive '0', disconnect '1'.
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_E0S1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_E0S1 = GPIO_PIN_CNF_DRIVE_E0S1, ///< Extra high drive '0', standard '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_S0E1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_S0E1 = GPIO_PIN_CNF_DRIVE_S0E1, ///< Standard '0', extra high drive '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_E0E1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_E0E1 = GPIO_PIN_CNF_DRIVE_E0E1, ///< Extra high drive '0', extra high drive '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_E0H1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_E0H1 = GPIO_PIN_CNF_DRIVE_E0H1, ///< Extra high drive '0', high drive '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_H0E1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_H0E1 = GPIO_PIN_CNF_DRIVE_H0E1, ///< High drive '0', extra high drive '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_D0E1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_D0E1 = GPIO_PIN_CNF_DRIVE_D0E1, ///< Disconnect '0', extra high drive '1'.
|
||||
#endif
|
||||
#if defined(GPIO_PIN_CNF_DRIVE_E0D1) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIO_PIN_E0D1 = GPIO_PIN_CNF_DRIVE_E0D1, ///< Extra high drive '0', disconnect '1'.
|
||||
#endif
|
||||
} nrf_gpio_pin_drive_t;
|
||||
|
||||
/** @brief Enumerator used for selecting the pin to sense high or low level on the pin input. */
|
||||
@@ -109,6 +135,15 @@ typedef enum
|
||||
NRF_GPIO_PIN_SENSE_HIGH = GPIO_PIN_CNF_SENSE_High, ///< Pin sense high level.
|
||||
} nrf_gpio_pin_sense_t;
|
||||
|
||||
#if defined(GPIO_PIN_CNF_MCUSEL_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Enumerator used for selecting the MCU/Subsystem to control the specified pin. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_GPIO_PIN_MCUSEL_APP = GPIO_PIN_CNF_MCUSEL_AppMCU, ///< Pin controlled by Application MCU.
|
||||
NRF_GPIO_PIN_MCUSEL_NETWORK = GPIO_PIN_CNF_MCUSEL_NetworkMCU, ///< Pin controlled by Network MCU.
|
||||
NRF_GPIO_PIN_MCUSEL_TND = GPIO_PIN_CNF_MCUSEL_TND, ///< Pin controlled by Trace and Debug Subsystem.
|
||||
} nrf_gpio_pin_mcusel_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the GPIO pin range as output pins with normal drive strength.
|
||||
@@ -120,7 +155,7 @@ typedef enum
|
||||
* @param pin_range_start Specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
|
||||
* @param pin_range_end Specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end);
|
||||
NRF_STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the GPIO pin range as input pins with given initial value set, hiding inner details.
|
||||
@@ -133,9 +168,9 @@ __STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_
|
||||
* @param pin_range_end Specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
|
||||
* @param pull_config State of the pin range pull resistor (no pull, pulled down, or pulled high).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start,
|
||||
uint32_t pin_range_end,
|
||||
nrf_gpio_pin_pull_t pull_config);
|
||||
NRF_STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start,
|
||||
uint32_t pin_range_end,
|
||||
nrf_gpio_pin_pull_t pull_config);
|
||||
|
||||
/**
|
||||
* @brief Pin configuration function.
|
||||
@@ -150,7 +185,7 @@ __STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_star
|
||||
* @param drive Drive configuration.
|
||||
* @param sense Pin sensing mechanism.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg(
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg(
|
||||
uint32_t pin_number,
|
||||
nrf_gpio_pin_dir_t dir,
|
||||
nrf_gpio_pin_input_t input,
|
||||
@@ -166,7 +201,7 @@ __STATIC_INLINE void nrf_gpio_cfg(
|
||||
*
|
||||
* @param pin_number Specifies the pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the given GPIO pin number as input, hiding inner details.
|
||||
@@ -177,14 +212,14 @@ __STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number);
|
||||
* @param pin_number Specifies the pin number.
|
||||
* @param pull_config State of the pin range pull resistor (no pull, pulled down, or pulled high).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config);
|
||||
|
||||
/**
|
||||
* @brief Function for resetting pin configuration to its default state.
|
||||
*
|
||||
* @param pin_number Specifies the pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the given GPIO pin number as a watcher. Only input is connected.
|
||||
@@ -192,14 +227,14 @@ __STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number);
|
||||
* @param pin_number Specifies the pin number.
|
||||
*
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for disconnecting input for the given GPIO.
|
||||
*
|
||||
* @param pin_number Specifies the pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the given GPIO pin number as input, hiding inner details.
|
||||
@@ -210,9 +245,9 @@ __STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number);
|
||||
* @param pull_config State of the pin pull resistor (no pull, pulled down, or pulled high).
|
||||
* @param sense_config Sense level of the pin (no sense, sense low, or sense high).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
nrf_gpio_pin_pull_t pull_config,
|
||||
nrf_gpio_pin_sense_t sense_config);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
nrf_gpio_pin_pull_t pull_config,
|
||||
nrf_gpio_pin_sense_t sense_config);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring sense level for the given GPIO.
|
||||
@@ -220,7 +255,8 @@ __STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
* @param pin_number Specifies the pin number.
|
||||
* @param sense_config Sense configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number, nrf_gpio_pin_sense_t sense_config);
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number,
|
||||
nrf_gpio_pin_sense_t sense_config);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the direction for a GPIO pin.
|
||||
@@ -228,7 +264,7 @@ __STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number, nrf_gpio_pin_se
|
||||
* @param pin_number Specifies the pin number for which to set the direction.
|
||||
* @param direction Specifies the direction.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a GPIO pin.
|
||||
@@ -237,7 +273,7 @@ __STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_
|
||||
*
|
||||
* @param pin_number Specifies the pin number to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a GPIO pin.
|
||||
@@ -246,7 +282,7 @@ __STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number);
|
||||
*
|
||||
* @param pin_number Specifies the pin number to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for toggling a GPIO pin.
|
||||
@@ -255,7 +291,7 @@ __STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number);
|
||||
*
|
||||
* @param pin_number Specifies the pin number to toggle.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for writing a value to a GPIO pin.
|
||||
@@ -267,7 +303,7 @@ __STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number);
|
||||
* @arg 0 Clears the pin.
|
||||
* @arg >=1 Sets the pin.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the input level of a GPIO pin.
|
||||
@@ -278,7 +314,7 @@ __STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value);
|
||||
*
|
||||
* @return 0 if the pin input level is low. Positive value if the pin is high.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the output level of a GPIO pin.
|
||||
@@ -287,7 +323,7 @@ __STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number);
|
||||
*
|
||||
* @return 0 if the pin output level is low. Positive value if pin output is high.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the sense configuration of a GPIO pin.
|
||||
@@ -296,7 +332,7 @@ __STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number);
|
||||
*
|
||||
* @return Sense configuration.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the direction configuration of a GPIO pin.
|
||||
@@ -305,7 +341,7 @@ __STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
|
||||
*
|
||||
* @return Direction configuration.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the status of GPIO pin input buffer.
|
||||
@@ -314,7 +350,7 @@ __STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number);
|
||||
*
|
||||
* @retval Input buffer configuration.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the pull configuration of a GPIO pin.
|
||||
@@ -323,7 +359,7 @@ __STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number)
|
||||
*
|
||||
* @retval Pull configuration.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for setting output direction on the selected pins on the given port.
|
||||
@@ -331,7 +367,7 @@ __STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number);
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param out_mask Mask specifying the pins to set as output.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_t out_mask);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_t out_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting input direction on selected pins on a given port.
|
||||
@@ -339,7 +375,7 @@ __STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param in_mask Mask that specifies the pins to be set as input.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_input_set(NRF_GPIO_Type * p_reg, uint32_t in_mask);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_input_set(NRF_GPIO_Type * p_reg, uint32_t in_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for writing the direction configuration of the GPIO pins in the given port.
|
||||
@@ -347,7 +383,7 @@ __STATIC_INLINE void nrf_gpio_port_dir_input_set(NRF_GPIO_Type * p_reg, uint32_t
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param dir_mask Mask that specifies the direction of pins. Bit set means that the given pin is configured as output.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_write(NRF_GPIO_Type * p_reg, uint32_t dir_mask);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_write(NRF_GPIO_Type * p_reg, uint32_t dir_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the direction configuration of a GPIO port.
|
||||
@@ -356,7 +392,7 @@ __STATIC_INLINE void nrf_gpio_port_dir_write(NRF_GPIO_Type * p_reg, uint32_t dir
|
||||
*
|
||||
* @return Pin configuration of the current direction settings. Bit set means that the given pin is configured as output.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_dir_read(NRF_GPIO_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_dir_read(NRF_GPIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the input signals of the GPIO pins on the given port.
|
||||
@@ -365,7 +401,7 @@ __STATIC_INLINE uint32_t nrf_gpio_port_dir_read(NRF_GPIO_Type const * p_reg);
|
||||
*
|
||||
* @return Port input values.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_in_read(NRF_GPIO_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_in_read(NRF_GPIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the output signals of the GPIO pins on the given port.
|
||||
@@ -374,7 +410,7 @@ __STATIC_INLINE uint32_t nrf_gpio_port_in_read(NRF_GPIO_Type const * p_reg);
|
||||
*
|
||||
* @return Port output values.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_out_read(NRF_GPIO_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_out_read(NRF_GPIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for writing the GPIO pins output on a given port.
|
||||
@@ -382,7 +418,7 @@ __STATIC_INLINE uint32_t nrf_gpio_port_out_read(NRF_GPIO_Type const * p_reg);
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param value Output port mask.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_out_write(NRF_GPIO_Type * p_reg, uint32_t value);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_write(NRF_GPIO_Type * p_reg, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Function for setting high level on selected the GPIO pins on the given port.
|
||||
@@ -390,7 +426,7 @@ __STATIC_INLINE void nrf_gpio_port_out_write(NRF_GPIO_Type * p_reg, uint32_t val
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param set_mask Mask with pins to be set as logical high level.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_out_set(NRF_GPIO_Type * p_reg, uint32_t set_mask);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_set(NRF_GPIO_Type * p_reg, uint32_t set_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting low level on selected the GPIO pins on the given port.
|
||||
@@ -398,7 +434,7 @@ __STATIC_INLINE void nrf_gpio_port_out_set(NRF_GPIO_Type * p_reg, uint32_t set_m
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param clr_mask Mask with pins to be set as logical low level.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_port_out_clear(NRF_GPIO_Type * p_reg, uint32_t clr_mask);
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_clear(NRF_GPIO_Type * p_reg, uint32_t clr_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for reading pin state of multiple consecutive ports.
|
||||
@@ -407,9 +443,11 @@ __STATIC_INLINE void nrf_gpio_port_out_clear(NRF_GPIO_Type * p_reg, uint32_t clr
|
||||
* @param length Number of ports to read.
|
||||
* @param p_masks Pointer to output array where port states will be stored.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port, uint32_t length, uint32_t * p_masks);
|
||||
NRF_STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks);
|
||||
|
||||
#if defined(GPIO_DETECTMODE_DETECTMODE_LDETECT) || defined(__NRF_DOXYGEN__)
|
||||
#if defined(NRF_GPIO_LATCH_PRESENT)
|
||||
/**
|
||||
* @brief Function for reading latch state of multiple consecutive ports.
|
||||
*
|
||||
@@ -417,8 +455,20 @@ __STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port, uint32_t length, u
|
||||
* @param length Number of ports to read.
|
||||
* @param p_masks Pointer to output array where latch states will be stored.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port, uint32_t length,
|
||||
uint32_t * p_masks);
|
||||
NRF_STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks);
|
||||
|
||||
/**
|
||||
* @brief Function for reading and immediate clearing latch state of multiple consecutive ports.
|
||||
*
|
||||
* @param start_port Index of the first port to read and clear.
|
||||
* @param length Number of ports to read and clear.
|
||||
* @param p_masks Pointer to output array where latch states will be stored.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks);
|
||||
|
||||
/**
|
||||
* @brief Function for reading latch state of single pin.
|
||||
@@ -427,18 +477,27 @@ __STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port, uint32_t length,
|
||||
*
|
||||
* @return 0 if latch is not set. Positive value otherwise.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing latch state of a single pin.
|
||||
*
|
||||
* @param pin_number Pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number);
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number);
|
||||
#endif // defined(NRF_GPIO_LATCH_PRESENT)
|
||||
|
||||
#if defined(GPIO_PIN_CNF_MCUSEL_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for selecting the MCU to control a GPIO pin.
|
||||
*
|
||||
* @param pin_number Pin_number.
|
||||
* @param mcu MCU to control the pin.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_mcu_select(uint32_t pin_number, nrf_gpio_pin_mcusel_t mcu);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
/**
|
||||
* @brief Function for extracting port and the relative pin number from the absolute pin number.
|
||||
@@ -447,7 +506,7 @@ __STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number);
|
||||
*
|
||||
* @return Pointer to port register set.
|
||||
*/
|
||||
__STATIC_INLINE NRF_GPIO_Type * nrf_gpio_pin_port_decode(uint32_t * p_pin)
|
||||
NRF_STATIC_INLINE NRF_GPIO_Type * nrf_gpio_pin_port_decode(uint32_t * p_pin)
|
||||
{
|
||||
NRFX_ASSERT(*p_pin < NUMBER_OF_PINS);
|
||||
#if (GPIO_COUNT == 1)
|
||||
@@ -466,7 +525,7 @@ __STATIC_INLINE NRF_GPIO_Type * nrf_gpio_pin_port_decode(uint32_t * p_pin)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end)
|
||||
NRF_STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end)
|
||||
{
|
||||
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
|
||||
for (; pin_range_start <= pin_range_end; pin_range_start++)
|
||||
@@ -476,9 +535,9 @@ __STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start,
|
||||
uint32_t pin_range_end,
|
||||
nrf_gpio_pin_pull_t pull_config)
|
||||
NRF_STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start,
|
||||
uint32_t pin_range_end,
|
||||
nrf_gpio_pin_pull_t pull_config)
|
||||
{
|
||||
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
|
||||
for (; pin_range_start <= pin_range_end; pin_range_start++)
|
||||
@@ -488,7 +547,7 @@ __STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_star
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg(
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg(
|
||||
uint32_t pin_number,
|
||||
nrf_gpio_pin_dir_t dir,
|
||||
nrf_gpio_pin_input_t input,
|
||||
@@ -506,7 +565,7 @@ __STATIC_INLINE void nrf_gpio_cfg(
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
|
||||
{
|
||||
nrf_gpio_cfg(
|
||||
pin_number,
|
||||
@@ -518,7 +577,7 @@ __STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config)
|
||||
{
|
||||
nrf_gpio_cfg(
|
||||
pin_number,
|
||||
@@ -530,7 +589,7 @@ __STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
|
||||
{
|
||||
nrf_gpio_cfg(
|
||||
pin_number,
|
||||
@@ -542,7 +601,7 @@ __STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
|
||||
@@ -552,7 +611,7 @@ __STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
|
||||
@@ -562,9 +621,9 @@ __STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
nrf_gpio_pin_pull_t pull_config,
|
||||
nrf_gpio_pin_sense_t sense_config)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
nrf_gpio_pin_pull_t pull_config,
|
||||
nrf_gpio_pin_sense_t sense_config)
|
||||
{
|
||||
nrf_gpio_cfg(
|
||||
pin_number,
|
||||
@@ -576,17 +635,18 @@ __STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number,
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number, nrf_gpio_pin_sense_t sense_config)
|
||||
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number,
|
||||
nrf_gpio_pin_sense_t sense_config)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
|
||||
reg->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_SENSE_Msk;
|
||||
reg->PIN_CNF[pin_number] |= (sense_config << GPIO_PIN_CNF_SENSE_Pos);
|
||||
uint32_t cnf = reg->PIN_CNF[pin_number] & ~GPIO_PIN_CNF_SENSE_Msk;
|
||||
|
||||
reg->PIN_CNF[pin_number] = cnf | (sense_config << GPIO_PIN_CNF_SENSE_Pos);
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction)
|
||||
{
|
||||
if (direction == NRF_GPIO_PIN_DIR_INPUT)
|
||||
{
|
||||
@@ -606,7 +666,7 @@ __STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -614,7 +674,7 @@ __STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -622,7 +682,7 @@ __STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
uint32_t pins_state = reg->OUT;
|
||||
@@ -632,7 +692,7 @@ __STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
@@ -645,7 +705,7 @@ __STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -653,7 +713,7 @@ __STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -661,7 +721,7 @@ __STATIC_INLINE uint32_t nrf_gpio_pin_out_read(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -670,7 +730,7 @@ __STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -678,7 +738,7 @@ __STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get(uint32_t pin_number)
|
||||
GPIO_PIN_CNF_DIR_Msk) >> GPIO_PIN_CNF_DIR_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -686,7 +746,7 @@ __STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get(uint32_t pin_number)
|
||||
GPIO_PIN_CNF_INPUT_Msk) >> GPIO_PIN_CNF_INPUT_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -695,61 +755,63 @@ __STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_t out_mask)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_output_set(NRF_GPIO_Type * p_reg, uint32_t out_mask)
|
||||
{
|
||||
p_reg->DIRSET = out_mask;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_input_set(NRF_GPIO_Type * p_reg, uint32_t in_mask)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_input_set(NRF_GPIO_Type * p_reg, uint32_t in_mask)
|
||||
{
|
||||
p_reg->DIRCLR = in_mask;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_dir_write(NRF_GPIO_Type * p_reg, uint32_t value)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_dir_write(NRF_GPIO_Type * p_reg, uint32_t value)
|
||||
{
|
||||
p_reg->DIR = value;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_dir_read(NRF_GPIO_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_dir_read(NRF_GPIO_Type const * p_reg)
|
||||
{
|
||||
return p_reg->DIR;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_in_read(NRF_GPIO_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_in_read(NRF_GPIO_Type const * p_reg)
|
||||
{
|
||||
return p_reg->IN;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_port_out_read(NRF_GPIO_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_port_out_read(NRF_GPIO_Type const * p_reg)
|
||||
{
|
||||
return p_reg->OUT;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_out_write(NRF_GPIO_Type * p_reg, uint32_t value)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_write(NRF_GPIO_Type * p_reg, uint32_t value)
|
||||
{
|
||||
p_reg->OUT = value;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_out_set(NRF_GPIO_Type * p_reg, uint32_t set_mask)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_set(NRF_GPIO_Type * p_reg, uint32_t set_mask)
|
||||
{
|
||||
p_reg->OUTSET = set_mask;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_port_out_clear(NRF_GPIO_Type * p_reg, uint32_t clr_mask)
|
||||
NRF_STATIC_INLINE void nrf_gpio_port_out_clear(NRF_GPIO_Type * p_reg, uint32_t clr_mask)
|
||||
{
|
||||
p_reg->OUTCLR = clr_mask;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port, uint32_t length, uint32_t * p_masks)
|
||||
NRF_STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks)
|
||||
{
|
||||
NRF_GPIO_Type * gpio_regs[GPIO_COUNT] = GPIO_REG_LIST;
|
||||
|
||||
@@ -764,8 +826,10 @@ __STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port, uint32_t length, u
|
||||
}
|
||||
|
||||
|
||||
#ifdef GPIO_DETECTMODE_DETECTMODE_LDETECT
|
||||
__STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port, uint32_t length, uint32_t * p_masks)
|
||||
#if defined(NRF_GPIO_LATCH_PRESENT)
|
||||
NRF_STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks)
|
||||
{
|
||||
NRF_GPIO_Type * gpio_regs[GPIO_COUNT] = GPIO_REG_LIST;
|
||||
uint32_t i;
|
||||
@@ -777,8 +841,25 @@ __STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port, uint32_t length,
|
||||
}
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear(uint32_t start_port,
|
||||
uint32_t length,
|
||||
uint32_t * p_masks)
|
||||
{
|
||||
NRF_GPIO_Type * gpio_regs[GPIO_COUNT] = GPIO_REG_LIST;
|
||||
uint32_t i;
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number)
|
||||
for (i = start_port; i < (start_port + length); i++)
|
||||
{
|
||||
*p_masks = gpio_regs[i]->LATCH;
|
||||
|
||||
// The LATCH register is cleared by writing a '1' to the bit that shall be cleared.
|
||||
gpio_regs[i]->LATCH = *p_masks;
|
||||
|
||||
p_masks++;
|
||||
}
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
@@ -786,16 +867,24 @@ __STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number)
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
|
||||
reg->LATCH = (1 << pin_number);
|
||||
}
|
||||
#endif // defined(NRF_GPIO_LATCH_PRESENT)
|
||||
|
||||
|
||||
#if defined(GPIO_PIN_CNF_MCUSEL_Msk)
|
||||
NRF_STATIC_INLINE void nrf_gpio_pin_mcu_select(uint32_t pin_number, nrf_gpio_pin_mcusel_t mcu)
|
||||
{
|
||||
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
|
||||
uint32_t cnf = reg->PIN_CNF[pin_number] & ~GPIO_PIN_CNF_MCUSEL_Msk;
|
||||
reg->PIN_CNF[pin_number] = cnf | (mcu << GPIO_PIN_CNF_MCUSEL_Pos);
|
||||
}
|
||||
#endif
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -71,53 +71,53 @@ typedef enum
|
||||
/** @brief GPIOTE tasks. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_GPIOTE_TASKS_OUT_0 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[0]), /**< Out task 0. */
|
||||
NRF_GPIOTE_TASKS_OUT_1 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[1]), /**< Out task 1. */
|
||||
NRF_GPIOTE_TASKS_OUT_2 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[2]), /**< Out task 2. */
|
||||
NRF_GPIOTE_TASKS_OUT_3 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[3]), /**< Out task 3. */
|
||||
NRF_GPIOTE_TASK_OUT_0 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[0]), /**< Out task 0. */
|
||||
NRF_GPIOTE_TASK_OUT_1 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[1]), /**< Out task 1. */
|
||||
NRF_GPIOTE_TASK_OUT_2 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[2]), /**< Out task 2. */
|
||||
NRF_GPIOTE_TASK_OUT_3 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[3]), /**< Out task 3. */
|
||||
#if (GPIOTE_CH_NUM > 4) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIOTE_TASKS_OUT_4 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[4]), /**< Out task 4. */
|
||||
NRF_GPIOTE_TASKS_OUT_5 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[5]), /**< Out task 5. */
|
||||
NRF_GPIOTE_TASKS_OUT_6 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[6]), /**< Out task 6. */
|
||||
NRF_GPIOTE_TASKS_OUT_7 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[7]), /**< Out task 7. */
|
||||
NRF_GPIOTE_TASK_OUT_4 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[4]), /**< Out task 4. */
|
||||
NRF_GPIOTE_TASK_OUT_5 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[5]), /**< Out task 5. */
|
||||
NRF_GPIOTE_TASK_OUT_6 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[6]), /**< Out task 6. */
|
||||
NRF_GPIOTE_TASK_OUT_7 = offsetof(NRF_GPIOTE_Type, TASKS_OUT[7]), /**< Out task 7. */
|
||||
#endif
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIOTE_TASKS_SET_0 = offsetof(NRF_GPIOTE_Type, TASKS_SET[0]), /**< Set task 0. */
|
||||
NRF_GPIOTE_TASKS_SET_1 = offsetof(NRF_GPIOTE_Type, TASKS_SET[1]), /**< Set task 1. */
|
||||
NRF_GPIOTE_TASKS_SET_2 = offsetof(NRF_GPIOTE_Type, TASKS_SET[2]), /**< Set task 2. */
|
||||
NRF_GPIOTE_TASKS_SET_3 = offsetof(NRF_GPIOTE_Type, TASKS_SET[3]), /**< Set task 3. */
|
||||
NRF_GPIOTE_TASKS_SET_4 = offsetof(NRF_GPIOTE_Type, TASKS_SET[4]), /**< Set task 4. */
|
||||
NRF_GPIOTE_TASKS_SET_5 = offsetof(NRF_GPIOTE_Type, TASKS_SET[5]), /**< Set task 5. */
|
||||
NRF_GPIOTE_TASKS_SET_6 = offsetof(NRF_GPIOTE_Type, TASKS_SET[6]), /**< Set task 6. */
|
||||
NRF_GPIOTE_TASKS_SET_7 = offsetof(NRF_GPIOTE_Type, TASKS_SET[7]), /**< Set task 7. */
|
||||
NRF_GPIOTE_TASK_SET_0 = offsetof(NRF_GPIOTE_Type, TASKS_SET[0]), /**< Set task 0. */
|
||||
NRF_GPIOTE_TASK_SET_1 = offsetof(NRF_GPIOTE_Type, TASKS_SET[1]), /**< Set task 1. */
|
||||
NRF_GPIOTE_TASK_SET_2 = offsetof(NRF_GPIOTE_Type, TASKS_SET[2]), /**< Set task 2. */
|
||||
NRF_GPIOTE_TASK_SET_3 = offsetof(NRF_GPIOTE_Type, TASKS_SET[3]), /**< Set task 3. */
|
||||
NRF_GPIOTE_TASK_SET_4 = offsetof(NRF_GPIOTE_Type, TASKS_SET[4]), /**< Set task 4. */
|
||||
NRF_GPIOTE_TASK_SET_5 = offsetof(NRF_GPIOTE_Type, TASKS_SET[5]), /**< Set task 5. */
|
||||
NRF_GPIOTE_TASK_SET_6 = offsetof(NRF_GPIOTE_Type, TASKS_SET[6]), /**< Set task 6. */
|
||||
NRF_GPIOTE_TASK_SET_7 = offsetof(NRF_GPIOTE_Type, TASKS_SET[7]), /**< Set task 7. */
|
||||
#endif
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIOTE_TASKS_CLR_0 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[0]), /**< Clear task 0. */
|
||||
NRF_GPIOTE_TASKS_CLR_1 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[1]), /**< Clear task 1. */
|
||||
NRF_GPIOTE_TASKS_CLR_2 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[2]), /**< Clear task 2. */
|
||||
NRF_GPIOTE_TASKS_CLR_3 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[3]), /**< Clear task 3. */
|
||||
NRF_GPIOTE_TASKS_CLR_4 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[4]), /**< Clear task 4. */
|
||||
NRF_GPIOTE_TASKS_CLR_5 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[5]), /**< Clear task 5. */
|
||||
NRF_GPIOTE_TASKS_CLR_6 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[6]), /**< Clear task 6. */
|
||||
NRF_GPIOTE_TASKS_CLR_7 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[7]), /**< Clear task 7. */
|
||||
NRF_GPIOTE_TASK_CLR_0 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[0]), /**< Clear task 0. */
|
||||
NRF_GPIOTE_TASK_CLR_1 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[1]), /**< Clear task 1. */
|
||||
NRF_GPIOTE_TASK_CLR_2 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[2]), /**< Clear task 2. */
|
||||
NRF_GPIOTE_TASK_CLR_3 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[3]), /**< Clear task 3. */
|
||||
NRF_GPIOTE_TASK_CLR_4 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[4]), /**< Clear task 4. */
|
||||
NRF_GPIOTE_TASK_CLR_5 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[5]), /**< Clear task 5. */
|
||||
NRF_GPIOTE_TASK_CLR_6 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[6]), /**< Clear task 6. */
|
||||
NRF_GPIOTE_TASK_CLR_7 = offsetof(NRF_GPIOTE_Type, TASKS_CLR[7]), /**< Clear task 7. */
|
||||
#endif
|
||||
} nrf_gpiote_tasks_t;
|
||||
} nrf_gpiote_task_t;
|
||||
|
||||
/** @brief GPIOTE events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_GPIOTE_EVENTS_IN_0 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[0]), /**< In event 0. */
|
||||
NRF_GPIOTE_EVENTS_IN_1 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[1]), /**< In event 1. */
|
||||
NRF_GPIOTE_EVENTS_IN_2 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[2]), /**< In event 2. */
|
||||
NRF_GPIOTE_EVENTS_IN_3 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[3]), /**< In event 3. */
|
||||
NRF_GPIOTE_EVENT_IN_0 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[0]), /**< In event 0. */
|
||||
NRF_GPIOTE_EVENT_IN_1 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[1]), /**< In event 1. */
|
||||
NRF_GPIOTE_EVENT_IN_2 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[2]), /**< In event 2. */
|
||||
NRF_GPIOTE_EVENT_IN_3 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[3]), /**< In event 3. */
|
||||
#if (GPIOTE_CH_NUM > 4) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_GPIOTE_EVENTS_IN_4 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[4]), /**< In event 4. */
|
||||
NRF_GPIOTE_EVENTS_IN_5 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[5]), /**< In event 5. */
|
||||
NRF_GPIOTE_EVENTS_IN_6 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[6]), /**< In event 6. */
|
||||
NRF_GPIOTE_EVENTS_IN_7 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[7]), /**< In event 7. */
|
||||
NRF_GPIOTE_EVENT_IN_4 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[4]), /**< In event 4. */
|
||||
NRF_GPIOTE_EVENT_IN_5 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[5]), /**< In event 5. */
|
||||
NRF_GPIOTE_EVENT_IN_6 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[6]), /**< In event 6. */
|
||||
NRF_GPIOTE_EVENT_IN_7 = offsetof(NRF_GPIOTE_Type, EVENTS_IN[7]), /**< In event 7. */
|
||||
#endif
|
||||
NRF_GPIOTE_EVENTS_PORT = offsetof(NRF_GPIOTE_Type, EVENTS_PORT), /**< Port event. */
|
||||
} nrf_gpiote_events_t;
|
||||
NRF_GPIOTE_EVENT_PORT = offsetof(NRF_GPIOTE_Type, EVENTS_PORT), /**< Port event. */
|
||||
} nrf_gpiote_event_t;
|
||||
|
||||
/** @brief GPIOTE interrupts. */
|
||||
typedef enum
|
||||
@@ -149,201 +149,235 @@ typedef enum
|
||||
/**
|
||||
* @brief Function for activating the specified GPIOTE task.
|
||||
*
|
||||
* @param[in] task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_task_set(nrf_gpiote_tasks_t task);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_trigger(NRF_GPIOTE_Type * p_reg, nrf_gpiote_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified GPIOTE task.
|
||||
*
|
||||
* @param[in] task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*
|
||||
* @return Address of the specified task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_task_addr_get(nrf_gpiote_tasks_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_task_address_get(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the specified GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event.
|
||||
*
|
||||
* @retval true The event is set.
|
||||
* @retval false The event is not set.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_gpiote_event_is_set(nrf_gpiote_events_t event);
|
||||
NRF_STATIC_INLINE bool nrf_gpiote_event_check(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_event_clear(nrf_gpiote_events_t event);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event.
|
||||
*
|
||||
* @return Address of the specified event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_event_addr_get(nrf_gpiote_events_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_event_address_get(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_int_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_int_enable(NRF_GPIOTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_int_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_int_disable(NRF_GPIOTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if interrupts are enabled.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask with enabled interrupts.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_int_is_enabled(uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_int_enable_check(NRF_GPIOTE_Type const * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for setting the subscribe configuration for a given
|
||||
* GPIOTE task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_subscribe_set(nrf_gpiote_tasks_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_subscribe_set(NRF_GPIOTE_Type * p_reg,
|
||||
nrf_gpiote_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
* GPIOTE task.
|
||||
*
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_subscribe_clear(nrf_gpiote_tasks_t task);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_subscribe_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
* GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_publish_set(nrf_gpiote_events_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_publish_set(NRF_GPIOTE_Type * p_reg,
|
||||
nrf_gpiote_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
* GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_publish_clear(nrf_gpiote_events_t event);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_publish_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a GPIOTE event.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_event_enable(uint32_t idx);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_enable(NRF_GPIOTE_Type * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE event.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_event_disable(uint32_t idx);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_disable(NRF_GPIOTE_Type * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring a GPIOTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] pin Pin associated with event.
|
||||
* @param[in] polarity Transition that should generate an event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_event_configure(uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_configure(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pin associated with a GPIOTE event.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*
|
||||
* @return Pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_event_pin_get(uint32_t idx);
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_event_pin_get(NRF_GPIOTE_Type const * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the polarity associated with a GPIOTE event.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*
|
||||
* @return Polarity.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpiote_polarity_t nrf_gpiote_event_polarity_get(uint32_t idx);
|
||||
NRF_STATIC_INLINE nrf_gpiote_polarity_t nrf_gpiote_event_polarity_get(NRF_GPIOTE_Type const * p_reg,
|
||||
uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a GPIOTE task.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_task_enable(uint32_t idx);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_enable(NRF_GPIOTE_Type * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE task.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_task_disable(uint32_t idx);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_disable(NRF_GPIOTE_Type * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring a GPIOTE task.
|
||||
*
|
||||
* @note Function is not configuring mode field so task is disabled after this function is called.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] pin Pin associated with event.
|
||||
* @param[in] polarity Transition that should generate an event.
|
||||
* @param[in] init_val Initial value of the pin.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_task_configure(uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity,
|
||||
nrf_gpiote_outinit_t init_val);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_configure(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity,
|
||||
nrf_gpiote_outinit_t init_val);
|
||||
|
||||
/**
|
||||
* @brief Function for forcing the specified state on the pin connected to GPIOTE.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] init_val Pin state.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_task_force(uint32_t idx, nrf_gpiote_outinit_t init_val);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_force(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
nrf_gpiote_outinit_t init_val);
|
||||
|
||||
/**
|
||||
* @brief Function for resetting a GPIOTE task event configuration to the default state.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_gpiote_te_default(uint32_t idx);
|
||||
NRF_STATIC_INLINE void nrf_gpiote_te_default(NRF_GPIOTE_Type * p_reg, uint32_t idx);
|
||||
|
||||
/**@brief Function for checking if particular Task-Event is enabled.
|
||||
*
|
||||
* @param[in] idx Task-Event index.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] idx Task-Event index.
|
||||
*
|
||||
* @retval true The Task-Event mode is set to Task or Event.
|
||||
* @retval false The Task-Event mode is set to Disabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_gpiote_te_is_enabled(uint32_t idx);
|
||||
NRF_STATIC_INLINE bool nrf_gpiote_te_is_enabled(NRF_GPIOTE_Type const * p_reg, uint32_t idx);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the OUT task associated with the specified GPIOTE channel.
|
||||
@@ -352,7 +386,7 @@ __STATIC_INLINE bool nrf_gpiote_te_is_enabled(uint32_t idx);
|
||||
*
|
||||
* @return Requested OUT task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_out_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_out_task_get(uint8_t index);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -362,7 +396,7 @@ __STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_out_task_get(uint8_t index);
|
||||
*
|
||||
* @return Requested SET task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_set_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_set_task_get(uint8_t index);
|
||||
#endif
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
@@ -373,7 +407,7 @@ __STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_set_task_get(uint8_t index);
|
||||
*
|
||||
* @return Requested CLR task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_clr_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_clr_task_get(uint8_t index);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -383,186 +417,202 @@ __STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_clr_task_get(uint8_t index);
|
||||
*
|
||||
* @return Requested IN event.
|
||||
*/
|
||||
__STATIC_INLINE nrf_gpiote_events_t nrf_gpiote_in_event_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_gpiote_event_t nrf_gpiote_in_event_get(uint8_t index);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_task_set(nrf_gpiote_tasks_t task)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_trigger(NRF_GPIOTE_Type * p_reg, nrf_gpiote_task_t task)
|
||||
{
|
||||
*(__IO uint32_t *)((uint32_t)NRF_GPIOTE + task) = 0x1UL;
|
||||
*(volatile uint32_t *)((uint32_t)p_reg + task) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_task_addr_get(nrf_gpiote_tasks_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_task_address_get(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_task_t task)
|
||||
{
|
||||
return ((uint32_t)NRF_GPIOTE + task);
|
||||
return ((uint32_t)p_reg + task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_gpiote_event_is_set(nrf_gpiote_events_t event)
|
||||
NRF_STATIC_INLINE bool nrf_gpiote_event_check(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_event_t event)
|
||||
{
|
||||
return (*(uint32_t *)nrf_gpiote_event_addr_get(event) == 0x1UL) ? true : false;
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_event_clear(nrf_gpiote_events_t event)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_event_t event)
|
||||
{
|
||||
*(uint32_t *)nrf_gpiote_event_addr_get(event) = 0;
|
||||
*((volatile uint32_t *)nrf_gpiote_event_address_get(p_reg, event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)nrf_gpiote_event_addr_get(event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)nrf_gpiote_event_address_get(p_reg, event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_event_addr_get(nrf_gpiote_events_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_event_address_get(NRF_GPIOTE_Type const * p_reg,
|
||||
nrf_gpiote_event_t event)
|
||||
{
|
||||
return ((uint32_t)NRF_GPIOTE + event);
|
||||
return ((uint32_t)p_reg + event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_int_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_int_enable(NRF_GPIOTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_GPIOTE->INTENSET = mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_int_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_int_disable(NRF_GPIOTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_GPIOTE->INTENCLR = mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_int_is_enabled(uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_int_enable_check(NRF_GPIOTE_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (NRF_GPIOTE->INTENSET & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_gpiote_subscribe_set(nrf_gpiote_tasks_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_subscribe_set(NRF_GPIOTE_Type * p_reg,
|
||||
nrf_gpiote_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_GPIOTE + (uint32_t) task + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | GPIOTE_SUBSCRIBE_OUT_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_subscribe_clear(nrf_gpiote_tasks_t task)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_subscribe_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_GPIOTE + (uint32_t) task + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_publish_set(nrf_gpiote_events_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_publish_set(NRF_GPIOTE_Type * p_reg,
|
||||
nrf_gpiote_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_GPIOTE + (uint32_t) event + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | GPIOTE_PUBLISH_IN_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_publish_clear(nrf_gpiote_events_t event)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_publish_clear(NRF_GPIOTE_Type * p_reg, nrf_gpiote_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_GPIOTE + (uint32_t) event + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_event_enable(uint32_t idx)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_enable(NRF_GPIOTE_Type * p_reg, uint32_t idx)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] |= GPIOTE_CONFIG_MODE_Event;
|
||||
p_reg->CONFIG[idx] |= GPIOTE_CONFIG_MODE_Event;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_event_disable(uint32_t idx)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_disable(NRF_GPIOTE_Type * p_reg, uint32_t idx)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] &= ~GPIOTE_CONFIG_MODE_Event;
|
||||
p_reg->CONFIG[idx] &= ~GPIOTE_CONFIG_MODE_Event;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_event_configure(uint32_t idx, uint32_t pin, nrf_gpiote_polarity_t polarity)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_event_configure(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk);
|
||||
NRF_GPIOTE->CONFIG[idx] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
|
||||
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk);
|
||||
p_reg->CONFIG[idx] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk);
|
||||
p_reg->CONFIG[idx] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
|
||||
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_gpiote_event_pin_get(uint32_t idx)
|
||||
NRF_STATIC_INLINE uint32_t nrf_gpiote_event_pin_get(NRF_GPIOTE_Type const * p_reg, uint32_t idx)
|
||||
{
|
||||
return ((NRF_GPIOTE->CONFIG[idx] & GPIOTE_CONFIG_PORT_PIN_Msk) >> GPIOTE_CONFIG_PSEL_Pos);
|
||||
return ((p_reg->CONFIG[idx] & GPIOTE_CONFIG_PORT_PIN_Msk) >> GPIOTE_CONFIG_PSEL_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_gpiote_polarity_t nrf_gpiote_event_polarity_get(uint32_t idx)
|
||||
NRF_STATIC_INLINE nrf_gpiote_polarity_t nrf_gpiote_event_polarity_get(NRF_GPIOTE_Type const * p_reg,
|
||||
uint32_t idx)
|
||||
{
|
||||
return (nrf_gpiote_polarity_t)((NRF_GPIOTE->CONFIG[idx] & GPIOTE_CONFIG_POLARITY_Msk) >> GPIOTE_CONFIG_POLARITY_Pos);
|
||||
return (nrf_gpiote_polarity_t)((p_reg->CONFIG[idx] & GPIOTE_CONFIG_POLARITY_Msk) >>
|
||||
GPIOTE_CONFIG_POLARITY_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_task_enable(uint32_t idx)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_enable(NRF_GPIOTE_Type * p_reg, uint32_t idx)
|
||||
{
|
||||
uint32_t final_config = NRF_GPIOTE->CONFIG[idx] | GPIOTE_CONFIG_MODE_Task;
|
||||
uint32_t final_config = p_reg->CONFIG[idx] | GPIOTE_CONFIG_MODE_Task;
|
||||
#ifdef NRF51
|
||||
/* Workaround for the OUTINIT PAN. When nrf_gpiote_task_config() is called a glitch happens
|
||||
on the GPIO if the GPIO in question is already assigned to GPIOTE and the pin is in the
|
||||
correct state in GPIOTE, but not in the OUT register. */
|
||||
/* Configure channel to not existing, not connected to the pin, and configure as a tasks that will set it to proper level */
|
||||
NRF_GPIOTE->CONFIG[idx] = final_config | (((31) << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk);
|
||||
correct state in GPIOTE, but not in the OUT register.
|
||||
Configure channel to not existing, not connected to the pin,
|
||||
and configure as a tasks that will set it to proper level */
|
||||
p_reg->CONFIG[idx] = final_config |
|
||||
(((31) << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk);
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
#endif
|
||||
NRF_GPIOTE->CONFIG[idx] = final_config;
|
||||
p_reg->CONFIG[idx] = final_config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_task_disable(uint32_t idx)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_disable(NRF_GPIOTE_Type * p_reg, uint32_t idx)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] &= ~GPIOTE_CONFIG_MODE_Task;
|
||||
p_reg->CONFIG[idx] &= ~GPIOTE_CONFIG_MODE_Task;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_task_configure(uint32_t idx, uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity,
|
||||
nrf_gpiote_outinit_t init_val)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_configure(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
uint32_t pin,
|
||||
nrf_gpiote_polarity_t polarity,
|
||||
nrf_gpiote_outinit_t init_val)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk |
|
||||
GPIOTE_CONFIG_POLARITY_Msk |
|
||||
GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
p_reg->CONFIG[idx] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk |
|
||||
GPIOTE_CONFIG_POLARITY_Msk |
|
||||
GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
|
||||
NRF_GPIOTE->CONFIG[idx] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
|
||||
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) |
|
||||
((init_val << GPIOTE_CONFIG_OUTINIT_Pos) & GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
p_reg->CONFIG[idx] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
|
||||
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) |
|
||||
((init_val << GPIOTE_CONFIG_OUTINIT_Pos) & GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_task_force(uint32_t idx, nrf_gpiote_outinit_t init_val)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_task_force(NRF_GPIOTE_Type * p_reg,
|
||||
uint32_t idx,
|
||||
nrf_gpiote_outinit_t init_val)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] = (NRF_GPIOTE->CONFIG[idx] & ~GPIOTE_CONFIG_OUTINIT_Msk)
|
||||
| ((init_val << GPIOTE_CONFIG_OUTINIT_Pos) & GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
p_reg->CONFIG[idx] = (p_reg->CONFIG[idx] & ~GPIOTE_CONFIG_OUTINIT_Msk) |
|
||||
((init_val << GPIOTE_CONFIG_OUTINIT_Pos) & GPIOTE_CONFIG_OUTINIT_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_gpiote_te_default(uint32_t idx)
|
||||
NRF_STATIC_INLINE void nrf_gpiote_te_default(NRF_GPIOTE_Type * p_reg, uint32_t idx)
|
||||
{
|
||||
NRF_GPIOTE->CONFIG[idx] = 0;
|
||||
p_reg->CONFIG[idx] = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_gpiote_te_is_enabled(uint32_t idx)
|
||||
NRF_STATIC_INLINE bool nrf_gpiote_te_is_enabled(NRF_GPIOTE_Type const * p_reg, uint32_t idx)
|
||||
{
|
||||
return (NRF_GPIOTE->CONFIG[idx] & GPIOTE_CONFIG_MODE_Msk) != GPIOTE_CONFIG_MODE_Disabled;
|
||||
return (p_reg->CONFIG[idx] & GPIOTE_CONFIG_MODE_Msk) != GPIOTE_CONFIG_MODE_Disabled;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_out_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_out_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_GPIOTE->TASKS_OUT));
|
||||
return (nrf_gpiote_tasks_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_OUT[index]);
|
||||
NRFX_ASSERT(index < GPIOTE_CH_NUM);
|
||||
return (nrf_gpiote_task_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_OUT[index]);
|
||||
}
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT)
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_set_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_set_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_GPIOTE->TASKS_SET));
|
||||
return (nrf_gpiote_tasks_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_SET[index]);
|
||||
NRFX_ASSERT(index < GPIOTE_CH_NUM);
|
||||
return (nrf_gpiote_task_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_SET[index]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT)
|
||||
__STATIC_INLINE nrf_gpiote_tasks_t nrf_gpiote_clr_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_gpiote_task_t nrf_gpiote_clr_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_GPIOTE->TASKS_CLR));
|
||||
return (nrf_gpiote_tasks_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_CLR[index]);
|
||||
NRFX_ASSERT(index < GPIOTE_CH_NUM);
|
||||
return (nrf_gpiote_task_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, TASKS_CLR[index]);
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE nrf_gpiote_events_t nrf_gpiote_in_event_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_gpiote_event_t nrf_gpiote_in_event_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_GPIOTE->EVENTS_IN));
|
||||
return (nrf_gpiote_events_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, EVENTS_IN[index]);
|
||||
NRFX_ASSERT(index < GPIOTE_CH_NUM);
|
||||
return (nrf_gpiote_event_t)NRFX_OFFSETOF(NRF_GPIOTE_Type, EVENTS_IN[index]);
|
||||
}
|
||||
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,6 +45,13 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the Inter-IC Sound (I2S) peripheral.
|
||||
*/
|
||||
|
||||
#if defined(I2S_CONFIG_CLKCONFIG_CLKSRC_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether clock source configuration is available. */
|
||||
#define NRF_I2S_HAS_CLKCONFIG 1
|
||||
#else
|
||||
#define NRF_I2S_HAS_CLKCONFIG 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This value can be provided as a parameter for the @ref nrf_i2s_pins_set
|
||||
* function call to specify that the given I2S signal (SDOUT, SDIN, or MCK)
|
||||
@@ -63,17 +70,23 @@ typedef enum
|
||||
/** @brief I2S events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_I2S_EVENT_RXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_RXPTRUPD), ///< The RXD.PTR register has been copied to internal double buffers.
|
||||
NRF_I2S_EVENT_TXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_TXPTRUPD), ///< The TXD.PTR register has been copied to internal double buffers.
|
||||
NRF_I2S_EVENT_STOPPED = offsetof(NRF_I2S_Type, EVENTS_STOPPED) ///< I2S transfer stopped.
|
||||
NRF_I2S_EVENT_RXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_RXPTRUPD), ///< The RXD.PTR register has been copied to internal double buffers.
|
||||
NRF_I2S_EVENT_TXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_TXPTRUPD), ///< The TXD.PTR register has been copied to internal double buffers.
|
||||
NRF_I2S_EVENT_STOPPED = offsetof(NRF_I2S_Type, EVENTS_STOPPED), ///< I2S transfer stopped.
|
||||
#if defined(I2S_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN_)
|
||||
NRF_I2S_EVENT_FRAMESTART = offsetof(NRF_I2S_Type, EVENTS_FRAMESTART) ///< Frame start event, generated on the active edge of LRCK.
|
||||
#endif
|
||||
} nrf_i2s_event_t;
|
||||
|
||||
/** @brief I2S interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_I2S_INT_RXPTRUPD_MASK = I2S_INTENSET_RXPTRUPD_Msk, ///< Interrupt on RXPTRUPD event.
|
||||
NRF_I2S_INT_TXPTRUPD_MASK = I2S_INTENSET_TXPTRUPD_Msk, ///< Interrupt on TXPTRUPD event.
|
||||
NRF_I2S_INT_STOPPED_MASK = I2S_INTENSET_STOPPED_Msk ///< Interrupt on STOPPED event.
|
||||
NRF_I2S_INT_RXPTRUPD_MASK = I2S_INTENSET_RXPTRUPD_Msk, ///< Interrupt on RXPTRUPD event.
|
||||
NRF_I2S_INT_TXPTRUPD_MASK = I2S_INTENSET_TXPTRUPD_Msk, ///< Interrupt on TXPTRUPD event.
|
||||
NRF_I2S_INT_STOPPED_MASK = I2S_INTENSET_STOPPED_Msk, ///< Interrupt on STOPPED event.
|
||||
#if defined(I2S_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN_)
|
||||
NRF_I2S_INT_FRAMESTART_MASK = I2S_INTENCLR_FRAMESTART_Msk ///< Interrupt on FRAMESTART event.
|
||||
#endif
|
||||
} nrf_i2s_int_mask_t;
|
||||
|
||||
/** @brief I2S modes of operation. */
|
||||
@@ -111,7 +124,9 @@ typedef enum
|
||||
NRF_I2S_MCK_32MDIV16 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV16, ///< 32 MHz / 16 = 2.0 MHz.
|
||||
NRF_I2S_MCK_32MDIV21 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV21, ///< 32 MHz / 21 = 1.5238095 MHz.
|
||||
NRF_I2S_MCK_32MDIV23 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV23, ///< 32 MHz / 23 = 1.3913043 MHz.
|
||||
NRF_I2S_MCK_32MDIV30 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV30, ///< 32 MHz / 30 = 1.0666667 MHz.
|
||||
NRF_I2S_MCK_32MDIV31 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV31, ///< 32 MHz / 31 = 1.0322581 MHz.
|
||||
NRF_I2S_MCK_32MDIV32 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV32, ///< 32 MHz / 32 = 1.0 MHz.
|
||||
NRF_I2S_MCK_32MDIV42 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV42, ///< 32 MHz / 42 = 0.7619048 MHz.
|
||||
NRF_I2S_MCK_32MDIV63 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV63, ///< 32 MHz / 63 = 0.5079365 MHz.
|
||||
NRF_I2S_MCK_32MDIV125 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV125 ///< 32 MHz / 125 = 0.256 MHz.
|
||||
@@ -134,9 +149,24 @@ typedef enum
|
||||
/** @brief I2S sample widths. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_I2S_SWIDTH_8BIT = I2S_CONFIG_SWIDTH_SWIDTH_8Bit, ///< 8 bit.
|
||||
NRF_I2S_SWIDTH_16BIT = I2S_CONFIG_SWIDTH_SWIDTH_16Bit, ///< 16 bit.
|
||||
NRF_I2S_SWIDTH_24BIT = I2S_CONFIG_SWIDTH_SWIDTH_24Bit ///< 24 bit.
|
||||
NRF_I2S_SWIDTH_8BIT = I2S_CONFIG_SWIDTH_SWIDTH_8Bit, ///< 8 bit.
|
||||
NRF_I2S_SWIDTH_16BIT = I2S_CONFIG_SWIDTH_SWIDTH_16Bit, ///< 16 bit.
|
||||
NRF_I2S_SWIDTH_24BIT = I2S_CONFIG_SWIDTH_SWIDTH_24Bit, ///< 24 bit.
|
||||
#if defined(I2S_CONFIG_SWIDTH_SWIDTH_32Bit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_I2S_SWIDTH_32BIT = I2S_CONFIG_SWIDTH_SWIDTH_32Bit, ///< 32 bit.
|
||||
#endif
|
||||
#if defined(I2S_CONFIG_SWIDTH_SWIDTH_8BitIn16) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_I2S_SWIDTH_8BIT_IN16BIT = I2S_CONFIG_SWIDTH_SWIDTH_8BitIn16, ///< 8 bit sample in a 16-bit half-frame.
|
||||
#endif
|
||||
#if defined(I2S_CONFIG_SWIDTH_SWIDTH_8BitIn32) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_I2S_SWIDTH_8BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_8BitIn32, ///< 8 bit sample in a 32-bit half-frame.
|
||||
#endif
|
||||
#if defined(I2S_CONFIG_SWIDTH_SWIDTH_16BitIn32) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_I2S_SWIDTH_16BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_16BitIn32, ///< 16 bit sample in a 32-bit half-frame.
|
||||
#endif
|
||||
#if defined(I2S_CONFIG_SWIDTH_SWIDTH_24BitIn32) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_I2S_SWIDTH_24BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_24BitIn32, ///< 24 bit sample in a 32-bit half-frame.
|
||||
#endif
|
||||
} nrf_i2s_swidth_t;
|
||||
|
||||
/** @brief I2S alignments of sample within a frame. */
|
||||
@@ -161,6 +191,14 @@ typedef enum
|
||||
NRF_I2S_CHANNELS_RIGHT = I2S_CONFIG_CHANNELS_CHANNELS_Right ///< Right only.
|
||||
} nrf_i2s_channels_t;
|
||||
|
||||
#if NRF_I2S_HAS_CLKCONFIG
|
||||
/** @brief I2S Clock source selection. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_I2S_CLKSRC_PCLK32M = I2S_CONFIG_CLKCONFIG_CLKSRC_PCLK32M, ///< 32MHz peripheral clock.
|
||||
NRF_I2S_CLKSRC_ACLK = I2S_CONFIG_CLKCONFIG_CLKSRC_ACLK ///< Audio PLL clock.
|
||||
} nrf_i2s_clksrc_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for activating the specified I2S task.
|
||||
@@ -168,8 +206,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified I2S task register.
|
||||
@@ -179,8 +217,8 @@ __STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_i2s_task_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_task_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified I2S event.
|
||||
@@ -188,8 +226,8 @@ __STATIC_INLINE uint32_t nrf_i2s_task_address_get(NRF_I2S_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the I2S event.
|
||||
@@ -200,8 +238,8 @@ __STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_i2s_event_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_i2s_event_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified I2S event register.
|
||||
@@ -211,8 +249,8 @@ __STATIC_INLINE bool nrf_i2s_event_check(NRF_I2S_Type const * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_i2s_event_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_event_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
@@ -220,7 +258,7 @@ __STATIC_INLINE uint32_t nrf_i2s_event_address_get(NRF_I2S_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_int_enable(NRF_I2S_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_i2s_int_enable(NRF_I2S_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -228,33 +266,31 @@ __STATIC_INLINE void nrf_i2s_int_enable(NRF_I2S_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_int_disable(NRF_I2S_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_i2s_int_disable(NRF_I2S_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] i2s_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_i2s_int_enable_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_int_mask_t i2s_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_int_enable_check(NRF_I2S_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the I2S peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_enable(NRF_I2S_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_i2s_enable(NRF_I2S_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the I2S peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_disable(NRF_I2S_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_i2s_disable(NRF_I2S_Type * p_reg);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -265,9 +301,9 @@ __STATIC_INLINE void nrf_i2s_disable(NRF_I2S_Type * p_reg);
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_subscribe_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_i2s_subscribe_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -276,8 +312,8 @@ __STATIC_INLINE void nrf_i2s_subscribe_set(NRF_I2S_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_subscribe_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_i2s_subscribe_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -287,9 +323,9 @@ __STATIC_INLINE void nrf_i2s_subscribe_clear(NRF_I2S_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_publish_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_i2s_publish_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -298,8 +334,8 @@ __STATIC_INLINE void nrf_i2s_publish_set(NRF_I2S_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_publish_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_i2s_publish_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -316,12 +352,12 @@ __STATIC_INLINE void nrf_i2s_publish_clear(NRF_I2S_Type * p_reg,
|
||||
* @param[in] sdout_pin SDOUT pin number.
|
||||
* @param[in] sdin_pin SDIN pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t lrck_pin,
|
||||
uint32_t mck_pin,
|
||||
uint32_t sdout_pin,
|
||||
uint32_t sdin_pin);
|
||||
NRF_STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t lrck_pin,
|
||||
uint32_t mck_pin,
|
||||
uint32_t sdout_pin,
|
||||
uint32_t sdin_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the I2S peripheral configuration.
|
||||
@@ -338,14 +374,14 @@ __STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
* @retval true The configuration has been set successfully.
|
||||
* @retval false The specified configuration is not allowed.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_mode_t mode,
|
||||
nrf_i2s_format_t format,
|
||||
nrf_i2s_align_t alignment,
|
||||
nrf_i2s_swidth_t sample_width,
|
||||
nrf_i2s_channels_t channels,
|
||||
nrf_i2s_mck_t mck_setup,
|
||||
nrf_i2s_ratio_t ratio);
|
||||
NRF_STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_mode_t mode,
|
||||
nrf_i2s_format_t format,
|
||||
nrf_i2s_align_t alignment,
|
||||
nrf_i2s_swidth_t sample_width,
|
||||
nrf_i2s_channels_t channels,
|
||||
nrf_i2s_mck_t mck_setup,
|
||||
nrf_i2s_ratio_t ratio);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up the I2S transfer.
|
||||
@@ -361,10 +397,10 @@ __STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
* @param[in] p_tx_buffer Pointer to the transmit buffer.
|
||||
* Pass NULL to disable transmission.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
uint16_t size,
|
||||
uint32_t * p_rx_buffer,
|
||||
uint32_t const * p_tx_buffer);
|
||||
NRF_STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
uint16_t size,
|
||||
uint32_t * p_rx_buffer,
|
||||
uint32_t const * p_tx_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the receive buffer.
|
||||
@@ -375,8 +411,8 @@ __STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the receive buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_rx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t * p_buffer);
|
||||
NRF_STATIC_INLINE void nrf_i2s_rx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t * p_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the receive buffer.
|
||||
@@ -385,7 +421,7 @@ __STATIC_INLINE void nrf_i2s_rx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
*
|
||||
* @return Pointer to the receive buffer.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_i2s_rx_buffer_get(NRF_I2S_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_i2s_rx_buffer_get(NRF_I2S_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the transmit buffer.
|
||||
@@ -396,8 +432,8 @@ __STATIC_INLINE uint32_t * nrf_i2s_rx_buffer_get(NRF_I2S_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the transmit buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t const * p_buffer);
|
||||
NRF_STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t const * p_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the transmit buffer.
|
||||
@@ -406,25 +442,38 @@ __STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
*
|
||||
* @return Pointer to the transmit buffer.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg);
|
||||
|
||||
#if NRF_I2S_HAS_CLKCONFIG
|
||||
/**
|
||||
* @brief Function for configuring I2S Clock.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] clksrc I2S Clock source selection.
|
||||
* @param[in] enable_bypass Bypass clock generator. MCK will be equal to source input.
|
||||
* If bypass is enabled the MCKFREQ setting has no effect.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_i2s_clk_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_clksrc_t clksrc,
|
||||
bool enable_bypass);
|
||||
#endif
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_i2s_task_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_task_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -433,80 +482,79 @@ __STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_i2s_event_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_i2s_event_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_i2s_event_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_event_address_get(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_int_enable(NRF_I2S_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_i2s_int_enable(NRF_I2S_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_int_disable(NRF_I2S_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_i2s_int_disable(NRF_I2S_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_i2s_int_enable_check(NRF_I2S_Type const * p_reg,
|
||||
nrf_i2s_int_mask_t i2s_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_i2s_int_enable_check(NRF_I2S_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & i2s_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_enable(NRF_I2S_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_i2s_enable(NRF_I2S_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (I2S_ENABLE_ENABLE_Enabled << I2S_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_disable(NRF_I2S_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_i2s_disable(NRF_I2S_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (I2S_ENABLE_ENABLE_Disabled << I2S_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_i2s_subscribe_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_i2s_subscribe_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | I2S_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_subscribe_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_i2s_subscribe_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_publish_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_i2s_publish_set(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | I2S_PUBLISH_STOPPED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_publish_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_i2s_publish_clear(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t lrck_pin,
|
||||
uint32_t mck_pin,
|
||||
uint32_t sdout_pin,
|
||||
uint32_t sdin_pin)
|
||||
NRF_STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t lrck_pin,
|
||||
uint32_t mck_pin,
|
||||
uint32_t sdout_pin,
|
||||
uint32_t sdin_pin)
|
||||
{
|
||||
p_reg->PSEL.SCK = sck_pin;
|
||||
p_reg->PSEL.LRCK = lrck_pin;
|
||||
@@ -515,14 +563,14 @@ __STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
|
||||
p_reg->PSEL.SDIN = sdin_pin;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_mode_t mode,
|
||||
nrf_i2s_format_t format,
|
||||
nrf_i2s_align_t alignment,
|
||||
nrf_i2s_swidth_t sample_width,
|
||||
nrf_i2s_channels_t channels,
|
||||
nrf_i2s_mck_t mck_setup,
|
||||
nrf_i2s_ratio_t ratio)
|
||||
NRF_STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_mode_t mode,
|
||||
nrf_i2s_format_t format,
|
||||
nrf_i2s_align_t alignment,
|
||||
nrf_i2s_swidth_t sample_width,
|
||||
nrf_i2s_channels_t channels,
|
||||
nrf_i2s_mck_t mck_setup,
|
||||
nrf_i2s_ratio_t ratio)
|
||||
{
|
||||
if (mode == NRF_I2S_MODE_MASTER)
|
||||
{
|
||||
@@ -563,10 +611,10 @@ __STATIC_INLINE bool nrf_i2s_configure(NRF_I2S_Type * p_reg,
|
||||
return true;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
uint16_t size,
|
||||
uint32_t * p_buffer_rx,
|
||||
uint32_t const * p_buffer_tx)
|
||||
NRF_STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
uint16_t size,
|
||||
uint32_t * p_buffer_rx,
|
||||
uint32_t const * p_buffer_tx)
|
||||
{
|
||||
p_reg->RXTXD.MAXCNT = size;
|
||||
|
||||
@@ -577,29 +625,39 @@ __STATIC_INLINE void nrf_i2s_transfer_set(NRF_I2S_Type * p_reg,
|
||||
p_reg->CONFIG.TXEN = (p_buffer_tx != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_rx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t * p_buffer)
|
||||
NRF_STATIC_INLINE void nrf_i2s_rx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t * p_buffer)
|
||||
{
|
||||
p_reg->RXD.PTR = (uint32_t)p_buffer;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_i2s_rx_buffer_get(NRF_I2S_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_i2s_rx_buffer_get(NRF_I2S_Type const * p_reg)
|
||||
{
|
||||
return (uint32_t *)(p_reg->RXD.PTR);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t const * p_buffer)
|
||||
NRF_STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
|
||||
uint32_t const * p_buffer)
|
||||
{
|
||||
p_reg->TXD.PTR = (uint32_t)p_buffer;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg)
|
||||
{
|
||||
return (uint32_t *)(p_reg->TXD.PTR);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_I2S_HAS_CLKCONFIG
|
||||
NRF_STATIC_INLINE void nrf_i2s_clk_configure(NRF_I2S_Type * p_reg,
|
||||
nrf_i2s_clksrc_t clksrc,
|
||||
bool enable_bypass)
|
||||
{
|
||||
p_reg->CONFIG.CLKCONFIG = ((uint32_t) clksrc << I2S_CONFIG_CLKCONFIG_CLKSRC_Pos) |
|
||||
((uint32_t) enable_bypass << I2S_CONFIG_CLKCONFIG_BYPASS_Pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,497 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_IPC_H__
|
||||
#define NRF_IPC_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ipc_hal IPC HAL
|
||||
* @{
|
||||
* @ingroup nrf_ipc
|
||||
* @brief Hardware access layer for managing the Interprocessor Communication (IPC) peripheral.
|
||||
*/
|
||||
|
||||
/** @brief IPC tasks. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_IPC_TASK_SEND_0 = offsetof(NRF_IPC_Type, TASKS_SEND[0]), ///< Trigger events on channels enabled in SEND_CNF[0].
|
||||
NRF_IPC_TASK_SEND_1 = offsetof(NRF_IPC_Type, TASKS_SEND[1]), ///< Trigger events on channels enabled in SEND_CNF[1].
|
||||
NRF_IPC_TASK_SEND_2 = offsetof(NRF_IPC_Type, TASKS_SEND[2]), ///< Trigger events on channels enabled in SEND_CNF[2].
|
||||
NRF_IPC_TASK_SEND_3 = offsetof(NRF_IPC_Type, TASKS_SEND[3]), ///< Trigger events on channels enabled in SEND_CNF[3].
|
||||
NRF_IPC_TASK_SEND_4 = offsetof(NRF_IPC_Type, TASKS_SEND[4]), ///< Trigger events on channels enabled in SEND_CNF[4].
|
||||
NRF_IPC_TASK_SEND_5 = offsetof(NRF_IPC_Type, TASKS_SEND[5]), ///< Trigger events on channels enabled in SEND_CNF[5].
|
||||
NRF_IPC_TASK_SEND_6 = offsetof(NRF_IPC_Type, TASKS_SEND[6]), ///< Trigger events on channels enabled in SEND_CNF[6].
|
||||
NRF_IPC_TASK_SEND_7 = offsetof(NRF_IPC_Type, TASKS_SEND[7]), ///< Trigger events on channels enabled in SEND_CNF[7].
|
||||
#if (IPC_TASKS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_IPC_TASK_SEND_8 = offsetof(NRF_IPC_Type, TASKS_SEND[8]), ///< Trigger events on channels enabled in SEND_CNF[8].
|
||||
NRF_IPC_TASK_SEND_9 = offsetof(NRF_IPC_Type, TASKS_SEND[9]), ///< Trigger events on channels enabled in SEND_CNF[9].
|
||||
NRF_IPC_TASK_SEND_10 = offsetof(NRF_IPC_Type, TASKS_SEND[10]), ///< Trigger events on channels enabled in SEND_CNF[10].
|
||||
NRF_IPC_TASK_SEND_11 = offsetof(NRF_IPC_Type, TASKS_SEND[11]), ///< Trigger events on channels enabled in SEND_CNF[11].
|
||||
NRF_IPC_TASK_SEND_12 = offsetof(NRF_IPC_Type, TASKS_SEND[12]), ///< Trigger events on channels enabled in SEND_CNF[12].
|
||||
NRF_IPC_TASK_SEND_13 = offsetof(NRF_IPC_Type, TASKS_SEND[13]), ///< Trigger events on channels enabled in SEND_CNF[13].
|
||||
NRF_IPC_TASK_SEND_14 = offsetof(NRF_IPC_Type, TASKS_SEND[14]), ///< Trigger events on channels enabled in SEND_CNF[14].
|
||||
NRF_IPC_TASK_SEND_15 = offsetof(NRF_IPC_Type, TASKS_SEND[15]), ///< Trigger events on channels enabled in SEND_CNF[15].
|
||||
#endif // (IPC_TASKS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
} nrf_ipc_task_t;
|
||||
|
||||
/** @brief IPC events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_IPC_EVENT_RECEIVE_0 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[0]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[0] register.
|
||||
NRF_IPC_EVENT_RECEIVE_1 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[1]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[1] register.
|
||||
NRF_IPC_EVENT_RECEIVE_2 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[2]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[2] register.
|
||||
NRF_IPC_EVENT_RECEIVE_3 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[3]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[3] register.
|
||||
NRF_IPC_EVENT_RECEIVE_4 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[4]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[4] register.
|
||||
NRF_IPC_EVENT_RECEIVE_5 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[5]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[5] register.
|
||||
NRF_IPC_EVENT_RECEIVE_6 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[6]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[6] register.
|
||||
NRF_IPC_EVENT_RECEIVE_7 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[7]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[7] register.
|
||||
#if (IPC_EVENTS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_IPC_EVENT_RECEIVE_8 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[8]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[8] register.
|
||||
NRF_IPC_EVENT_RECEIVE_9 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[9]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[9] register.
|
||||
NRF_IPC_EVENT_RECEIVE_10 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[10]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[10] register.
|
||||
NRF_IPC_EVENT_RECEIVE_11 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[11]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[11] register.
|
||||
NRF_IPC_EVENT_RECEIVE_12 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[12]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[12] register.
|
||||
NRF_IPC_EVENT_RECEIVE_13 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[13]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[13] register.
|
||||
NRF_IPC_EVENT_RECEIVE_14 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[14]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[14] register.
|
||||
NRF_IPC_EVENT_RECEIVE_15 = offsetof(NRF_IPC_Type, EVENTS_RECEIVE[15]), ///< Event received on the IPC channels enabled in RECEIVE_CNF[15] register.
|
||||
#endif // (IPC_EVENTS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
} nrf_ipc_event_t;
|
||||
|
||||
/** @brief IPC channel positions. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_IPC_CHANNEL_0 = IPC_RECEIVE_CNF_CHEN0_Msk, ///< Bitmask position for IPC channel 0.
|
||||
NRF_IPC_CHANNEL_1 = IPC_RECEIVE_CNF_CHEN1_Msk, ///< Bitmask position for IPC channel 1.
|
||||
NRF_IPC_CHANNEL_2 = IPC_RECEIVE_CNF_CHEN2_Msk, ///< Bitmask position for IPC channel 2.
|
||||
NRF_IPC_CHANNEL_3 = IPC_RECEIVE_CNF_CHEN3_Msk, ///< Bitmask position for IPC channel 3.
|
||||
NRF_IPC_CHANNEL_4 = IPC_RECEIVE_CNF_CHEN4_Msk, ///< Bitmask position for IPC channel 4.
|
||||
NRF_IPC_CHANNEL_5 = IPC_RECEIVE_CNF_CHEN5_Msk, ///< Bitmask position for IPC channel 5.
|
||||
NRF_IPC_CHANNEL_6 = IPC_RECEIVE_CNF_CHEN6_Msk, ///< Bitmask position for IPC channel 6.
|
||||
NRF_IPC_CHANNEL_7 = IPC_RECEIVE_CNF_CHEN7_Msk, ///< Bitmask position for IPC channel 7.
|
||||
#if (IPC_CH_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_IPC_CHANNEL_8 = IPC_RECEIVE_CNF_CHEN8_Msk, ///< Bitmask position for IPC channel 8.
|
||||
NRF_IPC_CHANNEL_9 = IPC_RECEIVE_CNF_CHEN9_Msk, ///< Bitmask position for IPC channel 9.
|
||||
NRF_IPC_CHANNEL_10 = IPC_RECEIVE_CNF_CHEN10_Msk, ///< Bitmask position for IPC channel 10.
|
||||
NRF_IPC_CHANNEL_11 = IPC_RECEIVE_CNF_CHEN11_Msk, ///< Bitmask position for IPC channel 11.
|
||||
NRF_IPC_CHANNEL_12 = IPC_RECEIVE_CNF_CHEN12_Msk, ///< Bitmask position for IPC channel 12.
|
||||
NRF_IPC_CHANNEL_13 = IPC_RECEIVE_CNF_CHEN13_Msk, ///< Bitmask position for IPC channel 13.
|
||||
NRF_IPC_CHANNEL_14 = IPC_RECEIVE_CNF_CHEN14_Msk, ///< Bitmask position for IPC channel 14.
|
||||
NRF_IPC_CHANNEL_15 = IPC_RECEIVE_CNF_CHEN15_Msk, ///< Bitmask position for IPC channel 15.
|
||||
#endif // (IPC_CH_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
} nrf_ipc_channel_t;
|
||||
|
||||
/** @brief IPC interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_IPC_INT_RECEIVE_0 = IPC_INTEN_RECEIVE0_Msk, ///< Interrupt on receive event 0.
|
||||
NRF_IPC_INT_RECEIVE_1 = IPC_INTEN_RECEIVE1_Msk, ///< Interrupt on receive event 1.
|
||||
NRF_IPC_INT_RECEIVE_2 = IPC_INTEN_RECEIVE2_Msk, ///< Interrupt on receive event 2.
|
||||
NRF_IPC_INT_RECEIVE_3 = IPC_INTEN_RECEIVE3_Msk, ///< Interrupt on receive event 3.
|
||||
NRF_IPC_INT_RECEIVE_4 = IPC_INTEN_RECEIVE4_Msk, ///< Interrupt on receive event 4.
|
||||
NRF_IPC_INT_RECEIVE_5 = IPC_INTEN_RECEIVE5_Msk, ///< Interrupt on receive event 5.
|
||||
NRF_IPC_INT_RECEIVE_6 = IPC_INTEN_RECEIVE6_Msk, ///< Interrupt on receive event 6.
|
||||
NRF_IPC_INT_RECEIVE_7 = IPC_INTEN_RECEIVE7_Msk, ///< Interrupt on receive event 7.
|
||||
#if (IPC_EVENTS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_IPC_INT_RECEIVE_8 = IPC_INTEN_RECEIVE8_Msk, ///< Interrupt on receive event 8.
|
||||
NRF_IPC_INT_RECEIVE_9 = IPC_INTEN_RECEIVE9_Msk, ///< Interrupt on receive event 9.
|
||||
NRF_IPC_INT_RECEIVE_10 = IPC_INTEN_RECEIVE10_Msk, ///< Interrupt on receive event 10.
|
||||
NRF_IPC_INT_RECEIVE_11 = IPC_INTEN_RECEIVE11_Msk, ///< Interrupt on receive event 11.
|
||||
NRF_IPC_INT_RECEIVE_12 = IPC_INTEN_RECEIVE12_Msk, ///< Interrupt on receive event 12.
|
||||
NRF_IPC_INT_RECEIVE_13 = IPC_INTEN_RECEIVE13_Msk, ///< Interrupt on receive event 13.
|
||||
NRF_IPC_INT_RECEIVE_14 = IPC_INTEN_RECEIVE14_Msk, ///< Interrupt on receive event 14.
|
||||
NRF_IPC_INT_RECEIVE_15 = IPC_INTEN_RECEIVE15_Msk, ///< Interrupt on receive event 15.
|
||||
#endif // (IPC_EVENTS_NUM > 8) || defined(__NRFX_DOXYGEN__)
|
||||
} nrf_ipc_int_mask_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the specified IPC task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be triggered.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_task_trigger(NRF_IPC_Type * p_reg, nrf_ipc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified IPC task register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Specified task.
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_task_address_get(NRF_IPC_Type const * p_reg,
|
||||
nrf_ipc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified IPC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_event_clear(NRF_IPC_Type * p_reg, nrf_ipc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the IPC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_ipc_event_check(NRF_IPC_Type const * p_reg, nrf_ipc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified IPC event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Specified event.
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_event_address_get(NRF_IPC_Type const * p_reg,
|
||||
nrf_ipc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_int_enable(NRF_IPC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_int_disable(NRF_IPC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_int_enable_check(NRF_IPC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of pending interrupts of the receive event.
|
||||
*
|
||||
* States of pending interrupt are saved as a bitmask. First position corresponds with
|
||||
* EVENTS_RECEIVE[0] event, second one with EVENTS_RECEIVE[1] etc.
|
||||
* One set at particular position means that interrupt for event is pending.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Bitmask with information about pending interrupts of EVENTS_RECEIVE[n] events.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_int_pending_get(NRF_IPC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the DPPI subscribe configuration for a given
|
||||
* IPC task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel DPPI channel through which to subscribe events.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_subscribe_set(NRF_IPC_Type * p_reg,
|
||||
nrf_ipc_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the DPPI subscribe configuration for a given
|
||||
* IPC task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_subscribe_clear(NRF_IPC_Type * p_reg, nrf_ipc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the DPPI publish configuration for a given
|
||||
* IPC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel DPPI channel through which to publish the event.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_publish_set(NRF_IPC_Type * p_reg,
|
||||
nrf_ipc_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the DPPI publish configuration for a given
|
||||
* IPC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_publish_clear(NRF_IPC_Type * p_reg, nrf_ipc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the configuration of the specified send task.
|
||||
*
|
||||
* @p channels_mask bitmask must be created with @ref nrf_ipc_channel_t values:
|
||||
* NRF_IPC_CHANNEL_0 | NRF_IPC_CHANNEL_1 | ... | NRF_IPC_CHANNEL_n
|
||||
*
|
||||
* @note This function overrides current configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the send task.
|
||||
* @param[in] channels_mask Bitmask specifying channels that are to be enabled for this task.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_send_config_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t channels_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the configuration of the specified send task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the send event configuration.
|
||||
*
|
||||
* @retval Bitmask of channels enabled for this task.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_send_config_get(NRF_IPC_Type * const p_reg, uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning receive event to the IPC channels.
|
||||
*
|
||||
* @p channels_mask bitmask must be created with @ref nrf_ipc_channel_t values:
|
||||
* NRF_IPC_CHANNEL_0 | NRF_IPC_CHANNEL_1 | ... | NRF_IPC_CHANNEL_n
|
||||
*
|
||||
* @note This function overrides current configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the receive event configuration.
|
||||
* @param[in] channels_mask Bitmask with IPC channels from which the receive event
|
||||
* will generate interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_receive_config_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t channels_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting receive event configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the receive event configuration.
|
||||
*
|
||||
* @return Mask of channels connected with receive event.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_receive_config_get(NRF_IPC_Type * const p_reg, uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for storing data in general purpose memory cell.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the general purpose memory cell.
|
||||
* @param[in] data Data to be stored.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ipc_gpmem_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting value of the general purpose memory cell.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Index of the general purpose memory cell.
|
||||
*
|
||||
* @return Stored data.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_gpmem_get(NRF_IPC_Type const * p_reg, uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for getting SEND task by its index.
|
||||
*
|
||||
* @param[in] index Index of the SEND task.
|
||||
*
|
||||
* @return SEND task.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_ipc_task_t nrf_ipc_send_task_get(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RECEIVE event by its index.
|
||||
*
|
||||
* @param[in] index Index of the RECEIVE event.
|
||||
*
|
||||
* @return RECEIVE event.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_ipc_event_t nrf_ipc_receive_event_get(uint8_t index);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_task_trigger(NRF_IPC_Type * p_reg, nrf_ipc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_task_address_get(NRF_IPC_Type const * p_reg,
|
||||
nrf_ipc_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_event_clear(NRF_IPC_Type * p_reg, nrf_ipc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_ipc_event_check(NRF_IPC_Type const * p_reg, nrf_ipc_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_event_address_get(NRF_IPC_Type const * p_reg,
|
||||
nrf_ipc_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_int_enable(NRF_IPC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_int_disable(NRF_IPC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_int_enable_check(NRF_IPC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_int_pending_get(NRF_IPC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->INTPEND;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_subscribe_set(NRF_IPC_Type * p_reg,
|
||||
nrf_ipc_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | IPC_SUBSCRIBE_SEND_EN_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_subscribe_clear(NRF_IPC_Type * p_reg, nrf_ipc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_publish_set(NRF_IPC_Type * p_reg,
|
||||
nrf_ipc_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | IPC_PUBLISH_RECEIVE_EN_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_publish_clear(NRF_IPC_Type * p_reg, nrf_ipc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_send_config_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t channels_mask)
|
||||
{
|
||||
p_reg->SEND_CNF[index] = channels_mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_send_config_get(NRF_IPC_Type * const p_reg, uint8_t index)
|
||||
{
|
||||
return p_reg->SEND_CNF[index];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_receive_config_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t channels_mask)
|
||||
{
|
||||
p_reg->RECEIVE_CNF[index] = channels_mask;
|
||||
}
|
||||
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_receive_config_get(NRF_IPC_Type * const p_reg, uint8_t index)
|
||||
{
|
||||
return p_reg->RECEIVE_CNF[index];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ipc_gpmem_set(NRF_IPC_Type * p_reg,
|
||||
uint8_t index,
|
||||
uint32_t data)
|
||||
{
|
||||
NRFX_ASSERT(index < IPC_GPMEM_NUM);
|
||||
p_reg->GPMEM[index] = data;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ipc_gpmem_get(NRF_IPC_Type const * p_reg, uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < IPC_GPMEM_NUM);
|
||||
return p_reg->GPMEM[index];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_ipc_task_t nrf_ipc_send_task_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < IPC_CH_NUM);
|
||||
return (nrf_ipc_task_t)(NRFX_OFFSETOF(NRF_IPC_Type, TASKS_SEND[index]));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_ipc_event_t nrf_ipc_receive_event_get(uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < IPC_CH_NUM);
|
||||
return (nrf_ipc_event_t)(NRFX_OFFSETOF(NRF_IPC_Type, EVENTS_RECEIVE[index]));
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_IPC_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -81,7 +81,7 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_kmu_task_trigger(NRF_KMU_Type * p_reg, nrf_kmu_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_kmu_task_trigger(NRF_KMU_Type * p_reg, nrf_kmu_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific KMU task register.
|
||||
@@ -91,7 +91,8 @@ __STATIC_INLINE void nrf_kmu_task_trigger(NRF_KMU_Type * p_reg, nrf_kmu_task_t t
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_kmu_task_address_get(NRF_KMU_Type const * p_reg, nrf_kmu_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_task_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a specific KMU event.
|
||||
@@ -99,7 +100,7 @@ __STATIC_INLINE uint32_t nrf_kmu_task_address_get(NRF_KMU_Type const * p_reg, nr
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_kmu_event_clear(NRF_KMU_Type * p_reg, nrf_kmu_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_kmu_event_clear(NRF_KMU_Type * p_reg, nrf_kmu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the KMU event.
|
||||
@@ -110,7 +111,7 @@ __STATIC_INLINE void nrf_kmu_event_clear(NRF_KMU_Type * p_reg, nrf_kmu_event_t e
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_kmu_event_check(NRF_KMU_Type const * p_reg, nrf_kmu_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_kmu_event_check(NRF_KMU_Type const * p_reg, nrf_kmu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific KMU event register.
|
||||
@@ -120,8 +121,8 @@ __STATIC_INLINE bool nrf_kmu_event_check(NRF_KMU_Type const * p_reg, nrf_kmu_eve
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_kmu_event_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_event_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
@@ -129,7 +130,7 @@ __STATIC_INLINE uint32_t nrf_kmu_event_address_get(NRF_KMU_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_kmu_int_enable(NRF_KMU_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_kmu_int_enable(NRF_KMU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -137,19 +138,17 @@ __STATIC_INLINE void nrf_kmu_int_enable(NRF_KMU_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_kmu_int_disable(NRF_KMU_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_kmu_int_disable(NRF_KMU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] kmu_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_kmu_int_enable_check(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_int_mask_t kmu_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_int_enable_check(NRF_KMU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of interrupts.
|
||||
@@ -160,7 +159,7 @@ __STATIC_INLINE bool nrf_kmu_int_enable_check(NRF_KMU_Type const * p_reg,
|
||||
*
|
||||
* @return Bitmask with pending interrupts bits.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_kmu_intpend_get(NRF_KMU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_intpend_get(NRF_KMU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting status bits of the KMU operation.
|
||||
@@ -171,7 +170,7 @@ __STATIC_INLINE uint32_t nrf_kmu_intpend_get(NRF_KMU_Type const * p_reg);
|
||||
*
|
||||
* @return Bitmask with operation status bits.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_kmu_status_get(NRF_KMU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_status_get(NRF_KMU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for selecting the key slot ID.
|
||||
@@ -180,7 +179,7 @@ __STATIC_INLINE uint32_t nrf_kmu_status_get(NRF_KMU_Type const * p_reg);
|
||||
* @param[in] keyslot_id Key slot ID to be read over AHB or pushed over
|
||||
* secure APB when TASKS_PUSH_KEYSLOT is started.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_kmu_keyslot_set(NRF_KMU_Type * p_reg, uint8_t keyslot_id);
|
||||
NRF_STATIC_INLINE void nrf_kmu_keyslot_set(NRF_KMU_Type * p_reg, uint8_t keyslot_id);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the key slot ID.
|
||||
@@ -189,76 +188,76 @@ __STATIC_INLINE void nrf_kmu_keyslot_set(NRF_KMU_Type * p_reg, uint8_t keyslot_i
|
||||
*
|
||||
* @return Key slot ID.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_kmu_keyslot_get(NRF_KMU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_kmu_keyslot_get(NRF_KMU_Type const * p_reg);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_kmu_task_trigger(NRF_KMU_Type * p_reg, nrf_kmu_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_kmu_task_trigger(NRF_KMU_Type * p_reg, nrf_kmu_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_kmu_task_address_get(NRF_KMU_Type const * p_reg, nrf_kmu_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_task_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_kmu_event_clear(NRF_KMU_Type * p_reg, nrf_kmu_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_kmu_event_clear(NRF_KMU_Type * p_reg, nrf_kmu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_kmu_event_check(NRF_KMU_Type const * p_reg, nrf_kmu_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_kmu_event_check(NRF_KMU_Type const * p_reg, nrf_kmu_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_kmu_event_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_event_address_get(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_kmu_int_enable(NRF_KMU_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_kmu_int_enable(NRF_KMU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_kmu_int_disable(NRF_KMU_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_kmu_int_disable(NRF_KMU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_kmu_int_enable_check(NRF_KMU_Type const * p_reg,
|
||||
nrf_kmu_int_mask_t kmu_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_int_enable_check(NRF_KMU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & kmu_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_kmu_intpend_get(NRF_KMU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_intpend_get(NRF_KMU_Type const * p_reg)
|
||||
{
|
||||
return p_reg->INTPEND;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_kmu_status_get(NRF_KMU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_kmu_status_get(NRF_KMU_Type const * p_reg)
|
||||
{
|
||||
return p_reg->STATUS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_kmu_keyslot_set(NRF_KMU_Type * p_reg, uint8_t keyslot_id)
|
||||
NRF_STATIC_INLINE void nrf_kmu_keyslot_set(NRF_KMU_Type * p_reg, uint8_t keyslot_id)
|
||||
{
|
||||
p_reg->SELECTKEYSLOT = (uint32_t) keyslot_id;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_kmu_keyslot_get(NRF_KMU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_kmu_keyslot_get(NRF_KMU_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t) p_reg->SELECTKEYSLOT;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -73,10 +73,10 @@ typedef enum
|
||||
NRF_LPCOMP_REF_SUPPLY_13_16 = LPCOMP_REFSEL_REFSEL_Ref13_16Vdd, /**< Use supply with a 13/16 prescaler as reference. */
|
||||
NRF_LPCOMP_REF_SUPPLY_15_16 = LPCOMP_REFSEL_REFSEL_Ref15_16Vdd, /**< Use supply with a 15/16 prescaler as reference. */
|
||||
#endif
|
||||
NRF_LPCOMP_REF_EXT_REF0 = LPCOMP_REFSEL_REFSEL_ARef |
|
||||
(LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference0 << 16), /**< External reference 0. */
|
||||
NRF_LPCOMP_CONFIG_REF_EXT_REF1 = LPCOMP_REFSEL_REFSEL_ARef |
|
||||
(LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference1 << 16), /**< External reference 1. */
|
||||
NRF_LPCOMP_REF_EXT_REF0 = LPCOMP_REFSEL_REFSEL_ARef |
|
||||
(LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference0 << 16), /**< External reference 0. */
|
||||
NRF_LPCOMP_REF_EXT_REF1 = LPCOMP_REFSEL_REFSEL_ARef |
|
||||
(LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference1 << 16), /**< External reference 1. */
|
||||
} nrf_lpcomp_ref_t;
|
||||
|
||||
/** @brief LPCOMP input selection. */
|
||||
@@ -128,270 +128,297 @@ typedef enum
|
||||
NRF_LPCOMP_SHORT_READY_SAMPLE_MASK = LPCOMP_SHORTS_READY_SAMPLE_Msk /*!< Shortcut between READY event and SAMPLE task. */
|
||||
} nrf_lpcomp_short_mask_t;
|
||||
|
||||
#ifdef LPCOMP_FEATURE_HYST_PRESENT
|
||||
#if defined(LPCOMP_FEATURE_HYST_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief LPCOMP hysteresis. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_LPCOMP_HYST_NOHYST = LPCOMP_HYST_HYST_NoHyst, /**< Comparator hysteresis disabled. */
|
||||
NRF_LPCOMP_HYST_50mV = LPCOMP_HYST_HYST_Hyst50mV /**< Comparator hysteresis enabled (typically 50 mV). */
|
||||
#ifdef LPCOMP_HYST_HYST_NoHyst
|
||||
NRF_LPCOMP_HYST_NOHYST = LPCOMP_HYST_HYST_NoHyst, /**< Comparator hysteresis disabled. */
|
||||
#else
|
||||
NRF_LPCOMP_HYST_NOHYST = LPCOMP_HYST_HYST_Disabled, /**< Comparator hysteresis disabled. */
|
||||
#endif
|
||||
#ifdef LPCOMP_HYST_HYST_Hyst50mV
|
||||
NRF_LPCOMP_HYST_ENABLED = LPCOMP_HYST_HYST_Hyst50mV /**< Comparator hysteresis enabled (typically 50 mV). */
|
||||
#else
|
||||
NRF_LPCOMP_HYST_ENABLED = LPCOMP_HYST_HYST_Enabled /**< Comparator hysteresis enabled (typically 50 mV). */
|
||||
#endif
|
||||
}nrf_lpcomp_hysteresis_t;
|
||||
#endif // LPCOMP_FEATURE_HYST_PRESENT
|
||||
|
||||
/** @brief LPCOMP configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_lpcomp_ref_t reference; /**< LPCOMP reference. */
|
||||
nrf_lpcomp_detect_t detection; /**< LPCOMP detection type. */
|
||||
#ifdef LPCOMP_FEATURE_HYST_PRESENT
|
||||
nrf_lpcomp_hysteresis_t hyst; /**< LPCOMP hysteresis. */
|
||||
nrf_lpcomp_ref_t reference; /**< LPCOMP reference. */
|
||||
nrf_lpcomp_detect_t detection; /**< LPCOMP detection type. */
|
||||
#if defined(LPCOMP_FEATURE_HYST_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_lpcomp_hysteresis_t hyst; /**< LPCOMP hysteresis. */
|
||||
#endif // LPCOMP_FEATURE_HYST_PRESENT
|
||||
} nrf_lpcomp_config_t;
|
||||
|
||||
|
||||
/** Default LPCOMP configuration. */
|
||||
#define NRF_LPCOMP_CONFIG_DEFAULT { NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT, NRF_LPCOMP_DETECT_DOWN }
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for configuring LPCOMP.
|
||||
*
|
||||
* This function powers on LPCOMP and configures it. LPCOMP is in DISABLE state after configuration,
|
||||
* so it must be enabled before using it. All shorts are inactive, events are cleared, and LPCOMP is stopped.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_config Configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_configure(const nrf_lpcomp_config_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_configure(NRF_LPCOMP_Type * p_reg,
|
||||
nrf_lpcomp_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for selecting the LPCOMP input.
|
||||
*
|
||||
* This function selects the active input of LPCOMP.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] input Input to be selected.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_input_select(nrf_lpcomp_input_t input);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_input_select(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_input_t input);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the Low Power Comparator.
|
||||
*
|
||||
* This function enables LPCOMP.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_enable(void);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_enable(NRF_LPCOMP_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the Low Power Comparator.
|
||||
*
|
||||
* This function disables LPCOMP.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_disable(void);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_disable(NRF_LPCOMP_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the last LPCOMP compare result.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The last compare result. If 0 then VIN+ < VIN-, if 1 then the opposite.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_lpcomp_result_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_result_get(NRF_LPCOMP_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts from LPCOMP.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*
|
||||
* @sa nrf_lpcomp_int_disable
|
||||
* @sa nrf_lpcomp_int_enable_check
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_int_enable(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_int_enable(NRF_LPCOMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts from LPCOMP.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*
|
||||
* @sa nrf_lpcomp_int_enable
|
||||
* @sa nrf_lpcomp_int_enable_check
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_int_disable(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_int_disable(NRF_LPCOMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the enabled interrupts of LPCOMP.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true Any of interrupts of the specified mask are enabled.
|
||||
* @retval false None interrupt specified by the mask are enabled.
|
||||
*
|
||||
* @sa nrf_lpcomp_int_enable
|
||||
* @sa nrf_lpcomp_int_disable
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_lpcomp_int_enable_check(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_int_enable_check(NRF_LPCOMP_Type const * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified LPCOMP task register.
|
||||
*
|
||||
* @param[in] task LPCOMP task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task LPCOMP task.
|
||||
*
|
||||
* @return The address of the specified LPCOMP task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_lpcomp_task_address_get(nrf_lpcomp_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_task_address_get(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified LPCOMP event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event LPCOMP event.
|
||||
*
|
||||
* @return The address of the specified LPCOMP event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_lpcomp_event_address_get(nrf_lpcomp_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_event_address_get(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting LPCOMP shorts.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_shorts_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_shorts_enable(NRF_LPCOMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing LPCOMP shorts by mask.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_shorts_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_shorts_disable(NRF_LPCOMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified LPCOMP task.
|
||||
*
|
||||
* @param[in] task LPCOMP task to be set.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task LPCOMP task to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_task_trigger(nrf_lpcomp_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_task_trigger(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified LPCOMP event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event LPCOMP event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_lpcomp_event_clear(nrf_lpcomp_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_event_clear(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the LPCOMP event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_lpcomp_event_check(nrf_lpcomp_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_lpcomp_event_check(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_event_t event);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_configure(const nrf_lpcomp_config_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_configure(NRF_LPCOMP_Type * p_reg,
|
||||
nrf_lpcomp_config_t const * p_config)
|
||||
{
|
||||
NRF_LPCOMP->TASKS_STOP = 1;
|
||||
NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
NRF_LPCOMP->REFSEL =
|
||||
p_reg->TASKS_STOP = 1;
|
||||
p_reg->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
p_reg->REFSEL =
|
||||
(p_config->reference << LPCOMP_REFSEL_REFSEL_Pos) & LPCOMP_REFSEL_REFSEL_Msk;
|
||||
|
||||
//If external source is choosen extract analog reference index.
|
||||
if ((p_config->reference & LPCOMP_REFSEL_REFSEL_ARef)==LPCOMP_REFSEL_REFSEL_ARef)
|
||||
{
|
||||
uint32_t extref = p_config->reference >> 16;
|
||||
NRF_LPCOMP->EXTREFSEL = (extref << LPCOMP_EXTREFSEL_EXTREFSEL_Pos) &
|
||||
LPCOMP_EXTREFSEL_EXTREFSEL_Msk;
|
||||
uint32_t extref = p_config->reference >> 16;
|
||||
p_reg->EXTREFSEL = (extref << LPCOMP_EXTREFSEL_EXTREFSEL_Pos) &
|
||||
LPCOMP_EXTREFSEL_EXTREFSEL_Msk;
|
||||
}
|
||||
|
||||
NRF_LPCOMP->ANADETECT =
|
||||
(p_config->detection << LPCOMP_ANADETECT_ANADETECT_Pos) & LPCOMP_ANADETECT_ANADETECT_Msk;
|
||||
p_reg->ANADETECT = (p_config->detection << LPCOMP_ANADETECT_ANADETECT_Pos) &
|
||||
LPCOMP_ANADETECT_ANADETECT_Msk;
|
||||
#ifdef LPCOMP_FEATURE_HYST_PRESENT
|
||||
NRF_LPCOMP->HYST = ((p_config->hyst) << LPCOMP_HYST_HYST_Pos) & LPCOMP_HYST_HYST_Msk;
|
||||
p_reg->HYST = ((p_config->hyst) << LPCOMP_HYST_HYST_Pos) & LPCOMP_HYST_HYST_Msk;
|
||||
#endif //LPCOMP_FEATURE_HYST_PRESENT
|
||||
NRF_LPCOMP->SHORTS = 0;
|
||||
NRF_LPCOMP->INTENCLR = LPCOMP_INTENCLR_CROSS_Msk | LPCOMP_INTENCLR_UP_Msk |
|
||||
LPCOMP_INTENCLR_DOWN_Msk | LPCOMP_INTENCLR_READY_Msk;
|
||||
p_reg->SHORTS = 0;
|
||||
p_reg->INTENCLR = LPCOMP_INTENCLR_CROSS_Msk | LPCOMP_INTENCLR_UP_Msk |
|
||||
LPCOMP_INTENCLR_DOWN_Msk | LPCOMP_INTENCLR_READY_Msk;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_input_select(nrf_lpcomp_input_t input)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_input_select(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_input_t input)
|
||||
{
|
||||
uint32_t lpcomp_enable_state = NRF_LPCOMP->ENABLE;
|
||||
uint32_t lpcomp_enable_state = p_reg->ENABLE;
|
||||
|
||||
NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
NRF_LPCOMP->PSEL =
|
||||
((uint32_t)input << LPCOMP_PSEL_PSEL_Pos) | (NRF_LPCOMP->PSEL & ~LPCOMP_PSEL_PSEL_Msk);
|
||||
NRF_LPCOMP->ENABLE = lpcomp_enable_state;
|
||||
p_reg->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
p_reg->PSEL = ((uint32_t)input << LPCOMP_PSEL_PSEL_Pos) |
|
||||
(p_reg->PSEL & ~LPCOMP_PSEL_PSEL_Msk);
|
||||
p_reg->ENABLE = lpcomp_enable_state;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_enable(NRF_LPCOMP_Type * p_reg)
|
||||
{
|
||||
NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
NRF_LPCOMP->EVENTS_READY = 0;
|
||||
NRF_LPCOMP->EVENTS_DOWN = 0;
|
||||
NRF_LPCOMP->EVENTS_UP = 0;
|
||||
NRF_LPCOMP->EVENTS_CROSS = 0;
|
||||
p_reg->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
p_reg->EVENTS_READY = 0;
|
||||
p_reg->EVENTS_DOWN = 0;
|
||||
p_reg->EVENTS_UP = 0;
|
||||
p_reg->EVENTS_CROSS = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_disable(NRF_LPCOMP_Type * p_reg)
|
||||
{
|
||||
NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
p_reg->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_lpcomp_result_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_result_get(NRF_LPCOMP_Type const * p_reg)
|
||||
{
|
||||
return (uint32_t)NRF_LPCOMP->RESULT;
|
||||
return (uint32_t)p_reg->RESULT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_int_enable(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_int_enable(NRF_LPCOMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_LPCOMP->INTENSET = int_mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_int_disable(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_int_disable(NRF_LPCOMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_LPCOMP->INTENCLR = int_mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_lpcomp_int_enable_check(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_int_enable_check(NRF_LPCOMP_Type const * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
return (NRF_LPCOMP->INTENSET & int_mask); // when read this register will return the value of INTEN.
|
||||
return p_reg->INTENSET & mask; // when read this register will return the value of INTEN.
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_lpcomp_task_address_get(nrf_lpcomp_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_task_address_get(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_task_t task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_LPCOMP + task);
|
||||
return (uint32_t)((uint8_t *)p_reg + task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_lpcomp_event_address_get(nrf_lpcomp_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_lpcomp_event_address_get(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_LPCOMP + event);
|
||||
return (uint32_t)((uint8_t *)p_reg + event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_shorts_enable(uint32_t short_mask)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_shorts_enable(NRF_LPCOMP_Type * p_reg, uint32_t short_mask)
|
||||
{
|
||||
NRF_LPCOMP->SHORTS |= short_mask;
|
||||
p_reg->SHORTS |= short_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_shorts_disable(uint32_t short_mask)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_shorts_disable(NRF_LPCOMP_Type * p_reg, uint32_t short_mask)
|
||||
{
|
||||
NRF_LPCOMP->SHORTS &= ~short_mask;
|
||||
p_reg->SHORTS &= ~short_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_task_trigger(nrf_lpcomp_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_task_trigger(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_task_t task)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + (uint32_t)task) ) = 1;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)task) ) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_lpcomp_event_clear(nrf_lpcomp_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_lpcomp_event_clear(NRF_LPCOMP_Type * p_reg, nrf_lpcomp_event_t event)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + (uint32_t)event) ) = 0;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event) ) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_LPCOMP + (uint32_t)event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_lpcomp_event_check(nrf_lpcomp_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_lpcomp_event_check(NRF_LPCOMP_Type const * p_reg,
|
||||
nrf_lpcomp_event_t event)
|
||||
{
|
||||
return (bool) (*(volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + (uint32_t)event));
|
||||
return (bool) (*(volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event));
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -64,7 +64,7 @@ extern "C" {
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] size Size of the RAM region 0, in bytes. Must be word-aligned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size);
|
||||
NRF_STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring specified peripherals in the memory region 0.
|
||||
@@ -79,8 +79,8 @@ __STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t
|
||||
* @param[in] peripheral_mask Mask that specifies peripherals to be configured in the memory region 0.
|
||||
* Compose this mask using @ref NRF_MPU_PERIPHERAL_MASK_GET macro.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
|
||||
uint32_t peripheral_mask);
|
||||
NRF_STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
|
||||
uint32_t peripheral_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the bitmask that specifies peripherals configured in the memory region 0.
|
||||
@@ -89,7 +89,7 @@ __STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
|
||||
*
|
||||
* @return Bitmask representing peripherals configured in region 0.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling protection for specified non-volatile memory blocks.
|
||||
@@ -103,9 +103,9 @@ __STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_
|
||||
* @param[in] block_mask Non-volatile memory blocks to protect. Each bit in bitmask represents
|
||||
* one memory block in the specified group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask);
|
||||
NRF_STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the non-volatile memory (NVM) protection during debug.
|
||||
@@ -113,34 +113,33 @@ __STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
* NVM protection during debug is disabled by default.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if NVM protection during debug is to be enabled.
|
||||
* False if otherwise.
|
||||
* @param[in] enable True if NVM protection during debug is to be enabled, false otherwise.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
|
||||
bool enable);
|
||||
NRF_STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
|
||||
bool enable);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size)
|
||||
NRF_STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size)
|
||||
{
|
||||
NRFX_ASSERT(nrfx_is_word_aligned((const void *)size));
|
||||
p_reg->RLENR0 = size;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
|
||||
uint32_t peripheral_mask)
|
||||
NRF_STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
|
||||
uint32_t peripheral_mask)
|
||||
{
|
||||
p_reg->PERR0 = peripheral_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PERR0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask)
|
||||
NRF_STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
uint8_t group_idx,
|
||||
uint32_t block_mask)
|
||||
{
|
||||
switch (group_idx)
|
||||
{
|
||||
@@ -158,14 +157,14 @@ __STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
|
||||
bool enable)
|
||||
NRF_STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
|
||||
bool enable)
|
||||
{
|
||||
p_reg->DISABLEINDEBUG =
|
||||
(enable ? 0 : MPU_DISABLEINDEBUG_DISABLEINDEBUG_Msk);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_MUTEX_H__
|
||||
#define NRF_MUTEX_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_mutex_hal MUTEX HAL
|
||||
* @{
|
||||
* @ingroup nrf_mutex
|
||||
* @brief Hardware access layer for managing the MUTEX peripheral.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function for locking the specified mutex.
|
||||
*
|
||||
* If the specified mutex is already locked, its state remains unchanged.
|
||||
*
|
||||
* @note Faults are not managed by the MUTEX peripheral.
|
||||
* One consequence is that if a mutex is locked and a fault happens,
|
||||
* it is the responsibility of the fault handler to release the mutex.
|
||||
* If a fault handler is not managing the mutex release, the mutex will remain locked.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mutex Index of the mutex to be locked.
|
||||
*
|
||||
* @retval true Mutex is successfully locked.
|
||||
* @retval false Mutex was already locked.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_mutex_lock(NRF_MUTEX_Type * p_reg, uint8_t mutex);
|
||||
|
||||
/**
|
||||
* @brief Function for unlocking the specified mutex.
|
||||
*
|
||||
* If the specified mutex is already unlocked, its state remains unchanged.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mutex Index of the mutex to be locked.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_mutex_unlock(NRF_MUTEX_Type * p_reg, uint8_t mutex);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_mutex_lock(NRF_MUTEX_Type * p_reg, uint8_t mutex)
|
||||
{
|
||||
return (p_reg->MUTEX[mutex] == MUTEX_MUTEX_MUTEX_Unlocked);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_mutex_unlock(NRF_MUTEX_Type * p_reg, uint8_t mutex)
|
||||
{
|
||||
p_reg->MUTEX[mutex] = MUTEX_MUTEX_MUTEX_Unlocked;
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_MUTEX_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -105,8 +105,8 @@ typedef enum
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_mwu_event_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_mwu_event_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a specific MWU event.
|
||||
@@ -114,8 +114,8 @@ __STATIC_INLINE bool nrf_mwu_event_check(NRF_MWU_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a specific MWU event register.
|
||||
@@ -125,64 +125,60 @@ __STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_mwu_event_address_get(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_event_address_get(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] int_mask Interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_int_enable(NRF_MWU_Type * p_reg, uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_int_enable(NRF_MWU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a specific interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mwu_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_mwu_int_enable_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_int_mask_t mwu_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_int_enable_check(NRF_MWU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] int_mask Interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_int_disable(NRF_MWU_Type * p_reg, uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_int_disable(NRF_MWU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified non-maskable interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] int_mask Interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_nmi_enable(NRF_MWU_Type * p_reg, uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_nmi_enable(NRF_MWU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a specific non-maskable interrupt.
|
||||
* @brief Function for checking if the specified non-maskable interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mwu_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_mwu_nmi_enable_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_int_mask_t mwu_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_nmi_enable_check(NRF_MWU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified non-maskable interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] int_mask Interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_nmi_disable(NRF_MWU_Type * p_reg, uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_nmi_disable(NRF_MWU_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting address range of the specified user region.
|
||||
@@ -192,10 +188,10 @@ __STATIC_INLINE void nrf_mwu_nmi_disable(NRF_MWU_Type * p_reg, uint32_t int_mask
|
||||
* @param[in] start_addr Memory address defining the beginning of the region.
|
||||
* @param[in] end_addr Memory address defining the end of the region.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_user_region_range_set(NRF_MWU_Type * p_reg,
|
||||
uint8_t region_idx,
|
||||
uint32_t start_addr,
|
||||
uint32_t end_addr);
|
||||
NRF_STATIC_INLINE void nrf_mwu_user_region_range_set(NRF_MWU_Type * p_reg,
|
||||
uint8_t region_idx,
|
||||
uint32_t start_addr,
|
||||
uint32_t end_addr);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling memory access watch mechanism.
|
||||
@@ -204,7 +200,7 @@ __STATIC_INLINE void nrf_mwu_user_region_range_set(NRF_MWU_Type * p_reg,
|
||||
* @param[in] reg_watch_mask Mask that defines regions and access types to watch.
|
||||
* Compose this mask from @ref nrf_mwu_region_watch_t values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_region_watch_enable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_region_watch_enable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling memory access watch mechanism.
|
||||
@@ -213,7 +209,7 @@ __STATIC_INLINE void nrf_mwu_region_watch_enable(NRF_MWU_Type * p_reg, uint32_t
|
||||
* @param[in] reg_watch_mask Mask that defines regions and access types to stop watching.
|
||||
* Compose this mask from @ref nrf_mwu_region_watch_t values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_region_watch_disable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_region_watch_disable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting memory access watch configuration mask.
|
||||
@@ -222,7 +218,7 @@ __STATIC_INLINE void nrf_mwu_region_watch_disable(NRF_MWU_Type * p_reg, uint32_t
|
||||
*
|
||||
* @return Mask that defines regions and access types being watched.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_mwu_region_watch_get(NRF_MWU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_region_watch_get(NRF_MWU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring peripheral subregions for watching.
|
||||
@@ -231,9 +227,9 @@ __STATIC_INLINE uint32_t nrf_mwu_region_watch_get(NRF_MWU_Type const * p_reg);
|
||||
* @param[in] per_reg_idx Peripheral region containing specified subregions.
|
||||
* @param[in] subregion_mask Mask that defines subregions to include into the specified peripheral region.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_subregions_configure(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_configure(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the mask of the write access flags of peripheral subregions
|
||||
@@ -243,8 +239,8 @@ __STATIC_INLINE void nrf_mwu_subregions_configure(NRF_MWU_Type * p_reg,
|
||||
*
|
||||
* @return Mask specifying subregions that were write accessed.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_mwu_subregions_write_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_subregions_write_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing write access flags of peripheral subregions.
|
||||
@@ -253,9 +249,9 @@ __STATIC_INLINE uint32_t nrf_mwu_subregions_write_accesses_get(NRF_MWU_Type cons
|
||||
* @param[in] per_reg_idx Peripheral region containing subregion accesses to clear.
|
||||
* @param[in] subregion_mask Mask that defines subregion write accesses to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_subregions_write_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_write_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the mask of the read access flags of peripheral subregions
|
||||
@@ -265,8 +261,8 @@ __STATIC_INLINE void nrf_mwu_subregions_write_accesses_clear(NRF_MWU_Type * p_re
|
||||
*
|
||||
* @return Mask specifying subregions that were read accessed.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_mwu_subregions_read_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx);
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_subregions_read_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing read access flags of peripheral subregions.
|
||||
@@ -275,20 +271,20 @@ __STATIC_INLINE uint32_t nrf_mwu_subregions_read_accesses_get(NRF_MWU_Type const
|
||||
* @param[in] per_reg_idx Peripheral region containing subregion accesses to clear.
|
||||
* @param[in] subregion_mask Mask that defines subregion read accesses to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_mwu_subregions_read_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_read_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE bool nrf_mwu_event_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_mwu_event_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -297,115 +293,102 @@ __STATIC_INLINE void nrf_mwu_event_clear(NRF_MWU_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_mwu_event_address_get(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_event_address_get(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_int_enable(NRF_MWU_Type * p_reg, uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_int_enable(NRF_MWU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = int_mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_mwu_int_enable_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_int_mask_t mwu_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_int_enable_check(NRF_MWU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & mwu_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_int_disable(NRF_MWU_Type * p_reg, uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_int_disable(NRF_MWU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = int_mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_nmi_enable(NRF_MWU_Type * p_reg, uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_nmi_enable(NRF_MWU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->NMIENSET = int_mask;
|
||||
p_reg->NMIENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_mwu_nmi_enable_check(NRF_MWU_Type const * p_reg,
|
||||
nrf_mwu_int_mask_t mwu_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_nmi_enable_check(NRF_MWU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->NMIENSET & mwu_int);
|
||||
return p_reg->NMIENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_nmi_disable(NRF_MWU_Type * p_reg, uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_nmi_disable(NRF_MWU_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->NMIENCLR = int_mask;
|
||||
p_reg->NMIENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_user_region_range_set(NRF_MWU_Type * p_reg,
|
||||
uint8_t region_idx,
|
||||
uint32_t start_addr,
|
||||
uint32_t end_addr)
|
||||
NRF_STATIC_INLINE void nrf_mwu_user_region_range_set(NRF_MWU_Type * p_reg,
|
||||
uint8_t region_idx,
|
||||
uint32_t start_addr,
|
||||
uint32_t end_addr)
|
||||
{
|
||||
NRFX_ASSERT(region_idx < NRFX_ARRAY_SIZE(NRF_MWU->REGION));
|
||||
NRFX_ASSERT(end_addr >= start_addr);
|
||||
|
||||
p_reg->REGION[region_idx].START = start_addr;
|
||||
p_reg->REGION[region_idx].END = end_addr;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_region_watch_enable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_region_watch_enable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask)
|
||||
{
|
||||
p_reg->REGIONENSET = reg_watch_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_region_watch_disable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_region_watch_disable(NRF_MWU_Type * p_reg, uint32_t reg_watch_mask)
|
||||
{
|
||||
p_reg->REGIONENCLR = reg_watch_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_mwu_region_watch_get(NRF_MWU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_region_watch_get(NRF_MWU_Type const * p_reg)
|
||||
{
|
||||
return p_reg->REGIONENSET;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_subregions_configure(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_configure(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
{
|
||||
NRFX_ASSERT(per_reg_idx < NRFX_ARRAY_SIZE(NRF_MWU->PREGION));
|
||||
|
||||
p_reg->PREGION[per_reg_idx].SUBS = subregion_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_mwu_subregions_write_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_subregions_write_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx)
|
||||
{
|
||||
NRFX_ASSERT(per_reg_idx < NRFX_ARRAY_SIZE(NRF_MWU->PREGION));
|
||||
|
||||
return p_reg->PERREGION[per_reg_idx].SUBSTATWA;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_subregions_write_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_write_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
{
|
||||
NRFX_ASSERT(per_reg_idx < NRFX_ARRAY_SIZE(NRF_MWU->PREGION));
|
||||
|
||||
p_reg->PERREGION[per_reg_idx].SUBSTATWA = subregion_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_mwu_subregions_read_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx)
|
||||
NRF_STATIC_INLINE uint32_t nrf_mwu_subregions_read_accesses_get(NRF_MWU_Type const * p_reg,
|
||||
uint8_t per_reg_idx)
|
||||
{
|
||||
NRFX_ASSERT(per_reg_idx < NRFX_ARRAY_SIZE(NRF_MWU->PREGION));
|
||||
|
||||
return p_reg->PERREGION[per_reg_idx].SUBSTATRA;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_mwu_subregions_read_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
NRF_STATIC_INLINE void nrf_mwu_subregions_read_accesses_clear(NRF_MWU_Type * p_reg,
|
||||
uint8_t per_reg_idx,
|
||||
uint32_t subregion_mask)
|
||||
{
|
||||
NRFX_ASSERT(per_reg_idx < NRFX_ARRAY_SIZE(NRF_MWU->PREGION));
|
||||
|
||||
p_reg->PERREGION[per_reg_idx].SUBSTATRA = subregion_mask;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
*@file
|
||||
*@brief NMVC driver implementation
|
||||
*/
|
||||
|
||||
#include <nrfx.h>
|
||||
#include "nrf_nvmc.h"
|
||||
|
||||
static inline void wait_for_flash_ready(void)
|
||||
{
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {;}
|
||||
}
|
||||
|
||||
void nrf_nvmc_page_erase(uint32_t address)
|
||||
{
|
||||
// Enable erase.
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een;
|
||||
__ISB();
|
||||
__DSB();
|
||||
|
||||
// Erase the page
|
||||
NRF_NVMC->ERASEPAGE = address;
|
||||
wait_for_flash_ready();
|
||||
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
|
||||
__ISB();
|
||||
__DSB();
|
||||
}
|
||||
|
||||
|
||||
void nrf_nvmc_write_byte(uint32_t address, uint8_t value)
|
||||
{
|
||||
uint32_t byte_shift = address & (uint32_t)0x03;
|
||||
uint32_t address32 = address & ~byte_shift; // Address to the word this byte is in.
|
||||
uint32_t value32 = (*(uint32_t*)address32 & ~((uint32_t)0xFF << (byte_shift << (uint32_t)3)));
|
||||
value32 = value32 + ((uint32_t)value << (byte_shift << 3));
|
||||
|
||||
// Enable write.
|
||||
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
|
||||
__ISB();
|
||||
__DSB();
|
||||
|
||||
*(uint32_t*)address32 = value32;
|
||||
wait_for_flash_ready();
|
||||
|
||||
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
|
||||
__ISB();
|
||||
__DSB();
|
||||
}
|
||||
|
||||
void nrf_nvmc_write_word(uint32_t address, uint32_t value)
|
||||
{
|
||||
// Enable write.
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
|
||||
__ISB();
|
||||
__DSB();
|
||||
|
||||
*(uint32_t*)address = value;
|
||||
wait_for_flash_ready();
|
||||
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
|
||||
__ISB();
|
||||
__DSB();
|
||||
}
|
||||
|
||||
void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < num_bytes; i++)
|
||||
{
|
||||
nrf_nvmc_write_byte(address + i,src[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
// Enable write.
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
|
||||
__ISB();
|
||||
__DSB();
|
||||
|
||||
for (i = 0; i < num_words; i++)
|
||||
{
|
||||
((uint32_t*)address)[i] = src[i];
|
||||
wait_for_flash_ready();
|
||||
}
|
||||
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
|
||||
__ISB();
|
||||
__DSB();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,62 +38,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_nvmc_hal_deprecated NVMC HAL (deprecated)
|
||||
* @{
|
||||
* @ingroup nrf_nvmc
|
||||
* @brief Hardware access layer (HAL) for managing the Non-Volatile Memory Controller (NVMC) peripheral.
|
||||
*
|
||||
* This driver allows writing to the non-volatile memory (NVM) regions
|
||||
* of the chip. To write to NVM, the controller must be powered
|
||||
* on and the relevant page must be erased.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Erase a page in flash. This is required before writing to any address in the page.
|
||||
*
|
||||
* @param address Start address of the page.
|
||||
*/
|
||||
void nrf_nvmc_page_erase(uint32_t address);
|
||||
|
||||
/**
|
||||
* @brief Write a single byte to flash.
|
||||
*
|
||||
* The function reads the word containing the byte, and then rewrites the entire word.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param value Value to write.
|
||||
*/
|
||||
void nrf_nvmc_write_byte(uint32_t address , uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Write a 32-bit word to flash.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param value Value to write.
|
||||
*/
|
||||
void nrf_nvmc_write_word(uint32_t address, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Write consecutive bytes to flash.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param src Pointer to data to copy from.
|
||||
* @param num_bytes Number of bytes in src to write.
|
||||
*/
|
||||
void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes);
|
||||
|
||||
/**
|
||||
* @brief Write consecutive words to flash.
|
||||
*
|
||||
* @param address Address to write to.
|
||||
* @param src Pointer to data to copy from.
|
||||
* @param num_words Number of words in src to write.
|
||||
*/
|
||||
void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup nrf_nvmc_hal NVMC HAL
|
||||
* @{
|
||||
@@ -101,11 +45,6 @@ void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_w
|
||||
* @brief Hardware access layer (HAL) for managing the Non-Volatile Memory Controller (NVMC) peripheral.
|
||||
*/
|
||||
|
||||
#if defined(NVMC_ICACHECNF_CACHEEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether Instruction Cache (ICache) is present. */
|
||||
#define NRF_NVMC_ICACHE_PRESENT
|
||||
#endif
|
||||
|
||||
#if defined(NVMC_ERASEPAGEPARTIALCFG_DURATION_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether the option of page partial erase is present. */
|
||||
#define NRF_NVMC_PARTIAL_ERASE_PRESENT
|
||||
@@ -132,7 +71,7 @@ typedef enum
|
||||
} nrf_nvmc_ns_mode_t;
|
||||
#endif
|
||||
|
||||
#if defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
#if defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
/** @brief NVMC ICache configuration. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -141,7 +80,7 @@ typedef enum
|
||||
NRF_NVMC_ICACHE_ENABLE_WITH_PROFILING = NVMC_ICACHECNF_CACHEEN_Enabled | ///< Instruction Cache with cache profiling enabled.
|
||||
NVMC_ICACHECNF_CACHEPROFEN_Msk
|
||||
} nrf_nvmc_icache_config_t;
|
||||
#endif // defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
|
||||
/**
|
||||
* @brief Function for checking if NVMC is ready to perform write or erase operation.
|
||||
@@ -151,7 +90,7 @@ typedef enum
|
||||
* @retval true NVMC can perform write or erase.
|
||||
* @retval false NVMC is busy and cannot perform next operation yet.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
#if defined(NVMC_READYNEXT_READYNEXT_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -165,7 +104,7 @@ __STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
* into account as soon as the ongoing write operation is completed.
|
||||
* @retval false NVMC is busy and cannot accept the next write yet.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
#endif // defined(NVMC_READYNEXT_READYNEXT_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -178,8 +117,8 @@ __STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mode Desired operating mode for NVMC.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_mode_t mode);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_mode_t mode);
|
||||
|
||||
#if defined(NVMC_CONFIGNS_WEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -188,8 +127,8 @@ __STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mode Desired operating mode for NVMC.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_ns_mode_t mode);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_ns_mode_t mode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -201,8 +140,8 @@ __STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] page_addr Address of the first word of the page to erase.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr);
|
||||
|
||||
#if defined(NVMC_ERASEUICR_ERASEUICR_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -210,7 +149,7 @@ __STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type * p_reg);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -220,7 +159,7 @@ __STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type * p_reg);
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type * p_reg);
|
||||
|
||||
#if defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
/**
|
||||
@@ -229,8 +168,8 @@ __STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] duration_ms Page partial erase duration in milliseconds.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type * p_reg,
|
||||
uint32_t duration_ms);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type * p_reg,
|
||||
uint32_t duration_ms);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the current setting for the page partial erase duration.
|
||||
@@ -239,7 +178,7 @@ __STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type * p_reg,
|
||||
*
|
||||
* @retval Interval duration setting in milliseconds.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a partial erase operation.
|
||||
@@ -249,11 +188,11 @@ __STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] page_addr Address of the first word of the page to erase.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr);
|
||||
#endif // defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
|
||||
#if defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
#if defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
/**
|
||||
* @brief Function for applying the Instruction Cache (ICache) configuration.
|
||||
*
|
||||
@@ -264,8 +203,8 @@ __STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] config ICache configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_icache_config_t config);
|
||||
NRF_STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_icache_config_t config);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if ICache is enabled.
|
||||
@@ -275,7 +214,7 @@ __STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
|
||||
* @retval true ICache enabled.
|
||||
* @retval false ICache disabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the ICache profiling option is enabled.
|
||||
@@ -285,7 +224,7 @@ __STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg);
|
||||
* @retval true ICache profiling enabled.
|
||||
* @retval false ICache profiling disabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_nvmc_icache_profiling_enable_check(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_icache_profiling_enable_check(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of ICache hits.
|
||||
@@ -294,7 +233,7 @@ __STATIC_INLINE bool nrf_nvmc_icache_profiling_enable_check(NRF_NVMC_Type const
|
||||
*
|
||||
* @retval Number of the ICache hits.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_icache_hit_get(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_icache_hit_get(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of ICache misses.
|
||||
@@ -303,46 +242,46 @@ __STATIC_INLINE uint32_t nrf_nvmc_icache_hit_get(NRF_NVMC_Type const * p_reg);
|
||||
*
|
||||
* @retval Number of the ICache misses.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_icache_miss_get(NRF_NVMC_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_icache_miss_get(NRF_NVMC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for resetting the ICache hit and miss counters.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_nvmc_icache_hit_miss_reset(NRF_NVMC_Type * p_reg);
|
||||
#endif // defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_icache_hit_miss_reset(NRF_NVMC_Type * p_reg);
|
||||
#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->READY & NVMC_READY_READY_Msk);
|
||||
}
|
||||
|
||||
#if defined(NVMC_READYNEXT_READYNEXT_Msk)
|
||||
__STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->READYNEXT & NVMC_READYNEXT_READYNEXT_Msk);
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_mode_t mode)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_mode_t mode)
|
||||
{
|
||||
p_reg->CONFIG = (uint32_t)mode;
|
||||
}
|
||||
|
||||
#if defined(NVMC_CONFIGNS_WEN_Msk)
|
||||
__STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_ns_mode_t mode)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_ns_mode_t mode)
|
||||
{
|
||||
p_reg->CONFIGNS = (uint32_t)mode;
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr)
|
||||
{
|
||||
#if defined(NRF51)
|
||||
/* On nRF51, the code area can be divided into two regions: CR0 and CR1.
|
||||
@@ -361,7 +300,7 @@ __STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
}
|
||||
#elif defined(NRF52_SERIES)
|
||||
p_reg->ERASEPAGE = page_addr;
|
||||
#elif defined(NRF9160_XXAA)
|
||||
#elif defined(NRF9160_XXAA) || defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK)
|
||||
*(volatile uint32_t *)page_addr = 0xFFFFFFFF;
|
||||
(void)p_reg;
|
||||
#else
|
||||
@@ -370,35 +309,35 @@ __STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type * p_reg,
|
||||
}
|
||||
|
||||
#if defined(NVMC_ERASEUICR_ERASEUICR_Msk)
|
||||
__STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type * p_reg)
|
||||
{
|
||||
p_reg->ERASEUICR = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type * p_reg)
|
||||
{
|
||||
p_reg->ERASEALL = 1;
|
||||
}
|
||||
|
||||
#if defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
__STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type * p_reg,
|
||||
uint32_t duration_ms)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type * p_reg,
|
||||
uint32_t duration_ms)
|
||||
{
|
||||
p_reg->ERASEPAGEPARTIALCFG = duration_ms;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->ERASEPAGEPARTIALCFG;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
uint32_t page_addr)
|
||||
{
|
||||
#if defined(NVMC_ERASEPAGEPARTIAL_ERASEPAGEPARTIAL_Msk)
|
||||
p_reg->ERASEPAGEPARTIAL = page_addr;
|
||||
#elif defined(NRF9160_XXAA)
|
||||
#elif defined(NRF9160_XXAA) || defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK)
|
||||
nrf_nvmc_page_erase_start(p_reg, page_addr);
|
||||
#else
|
||||
#error "Unknown device."
|
||||
@@ -406,41 +345,57 @@ __STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
|
||||
}
|
||||
#endif // defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
|
||||
|
||||
#if defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
__STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_icache_config_t config)
|
||||
#if defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
|
||||
nrf_nvmc_icache_config_t config)
|
||||
{
|
||||
p_reg->ICACHECNF = (uint32_t)config;
|
||||
#if defined(NRF5340_XXAA_NETWORK) || defined(NRF9160_XXAA)
|
||||
// Apply workaround for the anomalies:
|
||||
// - 6 for the nRF5340.
|
||||
// - 21 for the nRF9160.
|
||||
if (config == NRF_NVMC_ICACHE_DISABLE)
|
||||
{
|
||||
NRFX_CRITICAL_SECTION_ENTER();
|
||||
__ISB();
|
||||
p_reg->ICACHECNF = (uint32_t)NRF_NVMC_ICACHE_DISABLE;
|
||||
__ISB();
|
||||
NRFX_CRITICAL_SECTION_EXIT();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
p_reg->ICACHECNF = (uint32_t)config;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->ICACHECNF & NVMC_ICACHECNF_CACHEEN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_nvmc_icache_profiling_enable_check(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_nvmc_icache_profiling_enable_check(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->ICACHECNF & NVMC_ICACHECNF_CACHEPROFEN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_icache_hit_get(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_icache_hit_get(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->IHIT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_nvmc_icache_miss_get(NRF_NVMC_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_nvmc_icache_miss_get(NRF_NVMC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->IMISS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_nvmc_icache_hit_miss_reset(NRF_NVMC_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_nvmc_icache_hit_miss_reset(NRF_NVMC_Type * p_reg)
|
||||
{
|
||||
p_reg->IHIT = 0;
|
||||
p_reg->IMISS = 0;
|
||||
}
|
||||
#endif // defined(NRF_NVMC_ICACHE_PRESENT)
|
||||
#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_OSCILLATORS_H__
|
||||
#define NRF_OSCILLATORS_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_oscillators_hal OSCILLATORS HAL
|
||||
* @{
|
||||
* @ingroup nrf_clock
|
||||
* @brief Hardware access layer for managing the OSCILLATORS peripheral.
|
||||
*/
|
||||
|
||||
/** @brief Capacitors configuration for LFXO. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_OSCILLATORS_LFXO_CAP_EXTERNAL = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_External, ///< Use external capacitors.
|
||||
NRF_OSCILLATORS_LFXO_CAP_6PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C6PF, ///< Use 6 pF internal capacitors.
|
||||
NRF_OSCILLATORS_LFXO_CAP_7PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C7PF, ///< Use 7 pF internal capacitors.
|
||||
NRF_OSCILLATORS_LFXO_CAP_11PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C11PF, ///< Use 11 pF internal capacitors.
|
||||
} nrf_oscillators_lfxo_cap_t;
|
||||
|
||||
/**
|
||||
* @brief Function for enabling or disabling the bypass of LFXO with external clock source.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if bypass is to be enabled (use with rail-to-rail external source).
|
||||
* False if bypass is to be disabled (use with xtal or low-swing external source).
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_oscillators_lfxo_bypass_set(NRF_OSCILLATORS_Type * p_reg, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the internal capacitors of LFXO.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cap Capacitors configuration.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
|
||||
nrf_oscillators_lfxo_cap_t cap);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the internal capacitors of HXFO.
|
||||
*
|
||||
* The capacitance of internal capacitors ranges from 7 pF to 20 pF in 0.5 pF steps.
|
||||
* To calculate the correct @p cap_value, use the following equation:
|
||||
* CAPVALUE = (1+FICR->XOSC32MTRIM.SLOPE/16) * (CAPACITANCE*2-14) + FICR->XOSC32MTRIM.OFFSET
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if internal capacitors are to be enabled, false otherwise.
|
||||
* @param[in] cap_value Value representing capacitance, calculated using provided equation.
|
||||
* Ignored when internal capacitors are disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
|
||||
bool enable,
|
||||
uint32_t cap_value);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
NRF_STATIC_INLINE void nrf_oscillators_lfxo_bypass_set(NRF_OSCILLATORS_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->XOSC32KI.BYPASS = (enable ? OSCILLATORS_XOSC32KI_BYPASS_BYPASS_Enabled :
|
||||
OSCILLATORS_XOSC32KI_BYPASS_BYPASS_Disabled);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
|
||||
nrf_oscillators_lfxo_cap_t cap)
|
||||
{
|
||||
p_reg->XOSC32KI.INTCAP = (uint32_t)cap;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
|
||||
bool enable,
|
||||
uint32_t cap_value)
|
||||
{
|
||||
p_reg->XOSC32MCAPS =
|
||||
(enable ? ((OSCILLATORS_XOSC32MCAPS_ENABLE_Enabled << OSCILLATORS_XOSC32MCAPS_ENABLE_Pos) |
|
||||
(cap_value << OSCILLATORS_XOSC32MCAPS_CAPVALUE_Pos))
|
||||
: (OSCILLATORS_XOSC32MCAPS_ENABLE_Disabled << OSCILLATORS_XOSC32MCAPS_ENABLE_Pos));
|
||||
}
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_OSCILLATORS_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,6 +37,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NRF_PDM0
|
||||
#define NRF_PDM0 NRF_PDM
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_pdm_hal PDM HAL
|
||||
* @{
|
||||
@@ -44,6 +48,20 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the Pulse Density Modulation (PDM) peripheral.
|
||||
*/
|
||||
|
||||
#if defined(PDM_MCLKCONFIG_SRC_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether master clock source configuration is available. */
|
||||
#define NRF_PDM_HAS_MCLKCONFIG 1
|
||||
#else
|
||||
#define NRF_PDM_HAS_MCLKCONFIG 0
|
||||
#endif
|
||||
|
||||
#if defined(PDM_RATIO_RATIO_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether ratio configuration is available. */
|
||||
#define NRF_PDM_HAS_RATIO_CONFIG 1
|
||||
#else
|
||||
#define NRF_PDM_HAS_RATIO_CONFIG 0
|
||||
#endif
|
||||
|
||||
/** @brief Minimum value of PDM gain. */
|
||||
#define NRF_PDM_GAIN_MINIMUM 0x00
|
||||
/** @brief Default value of PDM gain. */
|
||||
@@ -83,9 +101,28 @@ typedef enum
|
||||
{
|
||||
NRF_PDM_FREQ_1000K = PDM_PDMCLKCTRL_FREQ_1000K, ///< PDM_CLK = 1.000 MHz.
|
||||
NRF_PDM_FREQ_1032K = PDM_PDMCLKCTRL_FREQ_Default, ///< PDM_CLK = 1.032 MHz.
|
||||
NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K ///< PDM_CLK = 1.067 MHz.
|
||||
NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K, ///< PDM_CLK = 1.067 MHz.
|
||||
#if defined(PDM_PDMCLKCTRL_FREQ_1231K) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_PDM_FREQ_1231K = PDM_PDMCLKCTRL_FREQ_1231K, ///< PDM_CLK = 1.231 MHz.
|
||||
#endif
|
||||
#if defined(PDM_PDMCLKCTRL_FREQ_1280K) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_PDM_FREQ_1280K = PDM_PDMCLKCTRL_FREQ_1280K, ///< PDM_CLK = 1.280 MHz.
|
||||
#endif
|
||||
#if defined(PDM_PDMCLKCTRL_FREQ_1333K) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_PDM_FREQ_1333K = PDM_PDMCLKCTRL_FREQ_1333K ///< PDM_CLK = 1.333 MHz.
|
||||
#endif
|
||||
} nrf_pdm_freq_t;
|
||||
|
||||
|
||||
#if NRF_PDM_HAS_RATIO_CONFIG
|
||||
/** @brief PDM ratio between PDM_CLK and output sample rate. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_PDM_RATIO_64X = PDM_RATIO_RATIO_Ratio64, ///< Ratio of 64.
|
||||
NRF_PDM_RATIO_80X = PDM_RATIO_RATIO_Ratio80 ///< Ratio of 80.
|
||||
} nrf_pdm_ratio_t;
|
||||
#endif
|
||||
|
||||
/** @brief PDM operation mode. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -100,185 +137,238 @@ typedef enum
|
||||
NRF_PDM_EDGE_LEFTRISING = PDM_MODE_EDGE_LeftRising ///< Left (or mono) is sampled on rising edge of PDM_CLK.
|
||||
} nrf_pdm_edge_t;
|
||||
|
||||
#if NRF_PDM_HAS_MCLKCONFIG
|
||||
/** @brief PDM master clock source selection. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_PDM_MCLKSRC_PCLK32M = PDM_MCLKCONFIG_SRC_PCLK32M, ///< 32MHz peripheral clock.
|
||||
NRF_PDM_MCLKSRC_ACLK = PDM_MCLKCONFIG_SRC_ACLK ///< Audio PLL clock.
|
||||
} nrf_pdm_mclksrc_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for triggering a PDM task.
|
||||
*
|
||||
* @param[in] task PDM task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task PDM task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_task_trigger(nrf_pdm_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_pdm_task_trigger(NRF_PDM_Type * p_reg, nrf_pdm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a PDM task register.
|
||||
*
|
||||
* @param[in] task PDM task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task PDM task.
|
||||
*
|
||||
* @return Address of the specified PDM task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_pdm_task_address_get(nrf_pdm_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_task_address_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the PDM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_pdm_event_check(nrf_pdm_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_pdm_event_check(NRF_PDM_Type const * p_reg, nrf_pdm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a PDM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event PDM event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_event_clear(nrf_pdm_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_pdm_event_clear(NRF_PDM_Type * p_reg, nrf_pdm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a PDM event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event PDM event.
|
||||
*
|
||||
* @return Address of the specified PDM event.
|
||||
*/
|
||||
__STATIC_INLINE volatile uint32_t * nrf_pdm_event_address_get(nrf_pdm_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_event_address_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling PDM interrupts.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_int_enable(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_pdm_int_enable(NRF_PDM_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of PDM interrupts.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true All specified interrupts are enabled.
|
||||
* @retval false At least one of the given interrupts is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_pdm_int_enable_check(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_int_enable_check(NRF_PDM_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
*
|
||||
* @param[in] int_mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_int_disable(uint32_t int_mask);
|
||||
NRF_STATIC_INLINE void nrf_pdm_int_disable(NRF_PDM_Type * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for setting the subscribe configuration for a given
|
||||
* PDM task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_subscribe_set(nrf_pdm_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_pdm_subscribe_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
* PDM task.
|
||||
*
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_subscribe_clear(nrf_pdm_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_pdm_subscribe_clear(NRF_PDM_Type * p_reg, nrf_pdm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
* PDM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_publish_set(nrf_pdm_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_pdm_publish_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
* PDM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_publish_clear(nrf_pdm_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_pdm_publish_clear(NRF_PDM_Type * p_reg, nrf_pdm_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the PDM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* The PDM peripheral must be enabled before use.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_enable(void);
|
||||
NRF_STATIC_INLINE void nrf_pdm_enable(NRF_PDM_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling the PDM peripheral. */
|
||||
__STATIC_INLINE void nrf_pdm_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling the PDM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_pdm_disable(NRF_PDM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the PDM peripheral is enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The PDM peripheral is enabled.
|
||||
* @retval false The PDM peripheral is not enabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_pdm_enable_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_pdm_enable_check(NRF_PDM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the PDM operation mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pdm_mode PDM operation mode.
|
||||
* @param[in] pdm_edge PDM sampling mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_mode_set(nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge);
|
||||
NRF_STATIC_INLINE void nrf_pdm_mode_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_mode_t pdm_mode,
|
||||
nrf_pdm_edge_t pdm_edge);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the PDM operation mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[out] p_pdm_mode PDM operation mode.
|
||||
* @param[out] p_pdm_edge PDM sampling mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_mode_get(nrf_pdm_mode_t * p_pdm_mode, nrf_pdm_edge_t * p_pdm_edge);
|
||||
NRF_STATIC_INLINE void nrf_pdm_mode_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_mode_t * p_pdm_mode,
|
||||
nrf_pdm_edge_t * p_pdm_edge);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the PDM clock frequency.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pdm_freq PDM clock frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_clock_set(nrf_pdm_freq_t pdm_freq);
|
||||
NRF_STATIC_INLINE void nrf_pdm_clock_set(NRF_PDM_Type * p_reg, nrf_pdm_freq_t pdm_freq);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the PDM clock frequency.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return PDM clock frequency.
|
||||
*/
|
||||
__STATIC_INLINE nrf_pdm_freq_t nrf_pdm_clock_get(void);
|
||||
NRF_STATIC_INLINE nrf_pdm_freq_t nrf_pdm_clock_get(NRF_PDM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up the PDM pins.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] psel_clk CLK pin number.
|
||||
* @param[in] psel_din DIN pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_psel_connect(uint32_t psel_clk, uint32_t psel_din);
|
||||
NRF_STATIC_INLINE void nrf_pdm_psel_connect(NRF_PDM_Type * p_reg,
|
||||
uint32_t psel_clk,
|
||||
uint32_t psel_din);
|
||||
|
||||
/** @brief Function for disconnecting the PDM pins. */
|
||||
__STATIC_INLINE void nrf_pdm_psel_disconnect(void);
|
||||
/**
|
||||
* @brief Function for disconnecting the PDM pins.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_pdm_psel_disconnect(NRF_PDM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the PDM gain.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] gain_l Left channel gain.
|
||||
* @param[in] gain_r Right channel gain.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_gain_set(nrf_pdm_gain_t gain_l, nrf_pdm_gain_t gain_r);
|
||||
NRF_STATIC_INLINE void nrf_pdm_gain_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_gain_t gain_l,
|
||||
nrf_pdm_gain_t gain_r);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the PDM gain.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[out] p_gain_l Left channel gain.
|
||||
* @param[out] p_gain_r Right channel gain.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_gain_get(nrf_pdm_gain_t * p_gain_l, nrf_pdm_gain_t * p_gain_r);
|
||||
NRF_STATIC_INLINE void nrf_pdm_gain_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_gain_t * p_gain_l,
|
||||
nrf_pdm_gain_t * p_gain_r);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the PDM sample buffer.
|
||||
@@ -287,165 +377,216 @@ __STATIC_INLINE void nrf_pdm_gain_get(nrf_pdm_gain_t * p_gain_l, nrf_pdm_gain_t
|
||||
* - For stereo mode: N 32-bit words.
|
||||
* - For mono mode: Ceil(N/2) 32-bit words.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the RAM address where samples are to be written with EasyDMA.
|
||||
* @param[in] num Number of samples to allocate memory for in EasyDMA mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pdm_buffer_set(uint32_t * p_buffer, uint32_t num);
|
||||
NRF_STATIC_INLINE void nrf_pdm_buffer_set(NRF_PDM_Type * p_reg, uint32_t * p_buffer, uint32_t num);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the current PDM sample buffer address.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to the current sample buffer.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_pdm_buffer_get(void);
|
||||
NRF_STATIC_INLINE uint32_t * nrf_pdm_buffer_get(NRF_PDM_Type const * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE void nrf_pdm_task_trigger(nrf_pdm_task_t task)
|
||||
#if NRF_PDM_HAS_RATIO_CONFIG
|
||||
/**
|
||||
* @brief Function for setting ratio between PDM_CLK and output sample rate.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ratio Ratio between PDM_CLK and output sample rate.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_pdm_ratio_set(NRF_PDM_Type * p_reg, nrf_pdm_ratio_t ratio);
|
||||
#endif
|
||||
|
||||
#if NRF_PDM_HAS_MCLKCONFIG
|
||||
/**
|
||||
* @brief Function for configuring PDM master clock source.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mclksrc Master Clock source selection.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_pdm_mclksrc_configure(NRF_PDM_Type * p_reg, nrf_pdm_mclksrc_t mclksrc);
|
||||
#endif
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
NRF_STATIC_INLINE void nrf_pdm_task_trigger(NRF_PDM_Type * p_reg, nrf_pdm_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)task)) = 0x1UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_pdm_task_address_get(nrf_pdm_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_task_address_get(NRF_PDM_Type const * p_reg, nrf_pdm_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)NRF_PDM + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_pdm_event_check(nrf_pdm_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_pdm_event_check(NRF_PDM_Type const * p_reg, nrf_pdm_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)event);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_event_clear(nrf_pdm_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_pdm_event_clear(NRF_PDM_Type * p_reg, nrf_pdm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)event)) = 0x0UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE volatile uint32_t * nrf_pdm_event_address_get(nrf_pdm_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_event_address_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_event_t event)
|
||||
{
|
||||
return (volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_int_enable(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_pdm_int_enable(NRF_PDM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_PDM->INTENSET = int_mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_pdm_int_enable_check(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pdm_int_enable_check(NRF_PDM_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(NRF_PDM->INTENSET & int_mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_int_disable(uint32_t int_mask)
|
||||
NRF_STATIC_INLINE void nrf_pdm_int_disable(NRF_PDM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_PDM->INTENCLR = int_mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_pdm_subscribe_set(nrf_pdm_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_pdm_subscribe_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_PDM + (uint32_t) task + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | PDM_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_subscribe_clear(nrf_pdm_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_pdm_subscribe_clear(NRF_PDM_Type * p_reg, nrf_pdm_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_PDM + (uint32_t) task + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_publish_set(nrf_pdm_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_pdm_publish_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_PDM + (uint32_t) event + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | PDM_PUBLISH_STARTED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_publish_clear(nrf_pdm_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_pdm_publish_clear(NRF_PDM_Type * p_reg, nrf_pdm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_PDM + (uint32_t) event + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_pdm_enable(NRF_PDM_Type * p_reg)
|
||||
{
|
||||
NRF_PDM->ENABLE = (PDM_ENABLE_ENABLE_Enabled << PDM_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (PDM_ENABLE_ENABLE_Enabled << PDM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_pdm_disable(NRF_PDM_Type * p_reg)
|
||||
{
|
||||
NRF_PDM->ENABLE = (PDM_ENABLE_ENABLE_Disabled << PDM_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (PDM_ENABLE_ENABLE_Disabled << PDM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_pdm_enable_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_pdm_enable_check(NRF_PDM_Type const * p_reg)
|
||||
{
|
||||
return (NRF_PDM->ENABLE == (PDM_ENABLE_ENABLE_Enabled << PDM_ENABLE_ENABLE_Pos));
|
||||
return (p_reg->ENABLE == (PDM_ENABLE_ENABLE_Enabled << PDM_ENABLE_ENABLE_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_mode_set(nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge)
|
||||
NRF_STATIC_INLINE void nrf_pdm_mode_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_mode_t pdm_mode,
|
||||
nrf_pdm_edge_t pdm_edge)
|
||||
{
|
||||
NRF_PDM->MODE = ((pdm_mode << PDM_MODE_OPERATION_Pos) & PDM_MODE_OPERATION_Msk)
|
||||
p_reg->MODE = ((pdm_mode << PDM_MODE_OPERATION_Pos) & PDM_MODE_OPERATION_Msk)
|
||||
| ((pdm_edge << PDM_MODE_EDGE_Pos) & PDM_MODE_EDGE_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_mode_get(nrf_pdm_mode_t * p_pdm_mode, nrf_pdm_edge_t * p_pdm_edge)
|
||||
NRF_STATIC_INLINE void nrf_pdm_mode_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_mode_t * p_pdm_mode,
|
||||
nrf_pdm_edge_t * p_pdm_edge)
|
||||
{
|
||||
uint32_t mode = NRF_PDM->MODE;
|
||||
uint32_t mode = p_reg->MODE;
|
||||
*p_pdm_mode = (nrf_pdm_mode_t)((mode & PDM_MODE_OPERATION_Msk ) >> PDM_MODE_OPERATION_Pos);
|
||||
*p_pdm_edge = (nrf_pdm_edge_t)((mode & PDM_MODE_EDGE_Msk ) >> PDM_MODE_EDGE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_clock_set(nrf_pdm_freq_t pdm_freq)
|
||||
NRF_STATIC_INLINE void nrf_pdm_clock_set(NRF_PDM_Type * p_reg, nrf_pdm_freq_t pdm_freq)
|
||||
{
|
||||
NRF_PDM->PDMCLKCTRL = ((pdm_freq << PDM_PDMCLKCTRL_FREQ_Pos) & PDM_PDMCLKCTRL_FREQ_Msk);
|
||||
p_reg->PDMCLKCTRL = ((pdm_freq << PDM_PDMCLKCTRL_FREQ_Pos) & PDM_PDMCLKCTRL_FREQ_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_pdm_freq_t nrf_pdm_clock_get(void)
|
||||
NRF_STATIC_INLINE nrf_pdm_freq_t nrf_pdm_clock_get(NRF_PDM_Type const * p_reg)
|
||||
{
|
||||
return (nrf_pdm_freq_t) ((NRF_PDM->PDMCLKCTRL << PDM_PDMCLKCTRL_FREQ_Pos) & PDM_PDMCLKCTRL_FREQ_Msk);
|
||||
return (nrf_pdm_freq_t) ((p_reg->PDMCLKCTRL << PDM_PDMCLKCTRL_FREQ_Pos) &
|
||||
PDM_PDMCLKCTRL_FREQ_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_psel_connect(uint32_t psel_clk, uint32_t psel_din)
|
||||
NRF_STATIC_INLINE void nrf_pdm_psel_connect(NRF_PDM_Type * p_reg,
|
||||
uint32_t psel_clk,
|
||||
uint32_t psel_din)
|
||||
{
|
||||
NRF_PDM->PSEL.CLK = psel_clk;
|
||||
NRF_PDM->PSEL.DIN = psel_din;
|
||||
p_reg->PSEL.CLK = psel_clk;
|
||||
p_reg->PSEL.DIN = psel_din;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_psel_disconnect(void)
|
||||
NRF_STATIC_INLINE void nrf_pdm_psel_disconnect(NRF_PDM_Type * p_reg)
|
||||
{
|
||||
NRF_PDM->PSEL.CLK = ((PDM_PSEL_CLK_CONNECT_Disconnected << PDM_PSEL_CLK_CONNECT_Pos)
|
||||
p_reg->PSEL.CLK = ((PDM_PSEL_CLK_CONNECT_Disconnected << PDM_PSEL_CLK_CONNECT_Pos)
|
||||
& PDM_PSEL_CLK_CONNECT_Msk);
|
||||
NRF_PDM->PSEL.DIN = ((PDM_PSEL_DIN_CONNECT_Disconnected << PDM_PSEL_DIN_CONNECT_Pos)
|
||||
p_reg->PSEL.DIN = ((PDM_PSEL_DIN_CONNECT_Disconnected << PDM_PSEL_DIN_CONNECT_Pos)
|
||||
& PDM_PSEL_DIN_CONNECT_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_gain_set(nrf_pdm_gain_t gain_l, nrf_pdm_gain_t gain_r)
|
||||
NRF_STATIC_INLINE void nrf_pdm_gain_set(NRF_PDM_Type * p_reg,
|
||||
nrf_pdm_gain_t gain_l,
|
||||
nrf_pdm_gain_t gain_r)
|
||||
{
|
||||
NRF_PDM->GAINL = gain_l;
|
||||
NRF_PDM->GAINR = gain_r;
|
||||
p_reg->GAINL = gain_l;
|
||||
p_reg->GAINR = gain_r;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_gain_get(nrf_pdm_gain_t * p_gain_l, nrf_pdm_gain_t * p_gain_r)
|
||||
NRF_STATIC_INLINE void nrf_pdm_gain_get(NRF_PDM_Type const * p_reg,
|
||||
nrf_pdm_gain_t * p_gain_l,
|
||||
nrf_pdm_gain_t * p_gain_r)
|
||||
{
|
||||
*p_gain_l = NRF_PDM->GAINL;
|
||||
*p_gain_r = NRF_PDM->GAINR;
|
||||
*p_gain_l = p_reg->GAINL;
|
||||
*p_gain_r = p_reg->GAINR;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pdm_buffer_set(uint32_t * p_buffer, uint32_t num)
|
||||
NRF_STATIC_INLINE void nrf_pdm_buffer_set(NRF_PDM_Type * p_reg, uint32_t * p_buffer, uint32_t num)
|
||||
{
|
||||
NRF_PDM->SAMPLE.PTR = (uint32_t)p_buffer;
|
||||
NRF_PDM->SAMPLE.MAXCNT = num;
|
||||
p_reg->SAMPLE.PTR = (uint32_t)p_buffer;
|
||||
p_reg->SAMPLE.MAXCNT = num;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_pdm_buffer_get(void)
|
||||
NRF_STATIC_INLINE uint32_t * nrf_pdm_buffer_get(NRF_PDM_Type const * p_reg)
|
||||
{
|
||||
return (uint32_t *)NRF_PDM->SAMPLE.PTR;
|
||||
return (uint32_t *)p_reg->SAMPLE.PTR;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_PDM_HAS_RATIO_CONFIG
|
||||
NRF_STATIC_INLINE void nrf_pdm_ratio_set(NRF_PDM_Type * p_reg, nrf_pdm_ratio_t ratio)
|
||||
{
|
||||
p_reg->RATIO = ratio;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_PDM_HAS_MCLKCONFIG
|
||||
NRF_STATIC_INLINE void nrf_pdm_mclksrc_configure(NRF_PDM_Type * p_reg, nrf_pdm_mclksrc_t mclksrc)
|
||||
{
|
||||
p_reg->MCLKCONFIG = mclksrc;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -137,101 +137,121 @@ typedef enum
|
||||
*
|
||||
* @details This function enables only one channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_enable(nrf_ppi_channel_t channel);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_enable(NRF_PPI_Type * p_reg, nrf_ppi_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a given PPI channel.
|
||||
*
|
||||
* @details This function disables only one channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_disable(nrf_ppi_channel_t channel);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_disable(NRF_PPI_Type * p_reg, nrf_ppi_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if a given PPI channel is enabled.
|
||||
*
|
||||
* @details This function checks only one channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel to be checked.
|
||||
*
|
||||
* @retval NRF_PPI_CHANNEL_ENABLED The channel is enabled.
|
||||
* @retval NRF_PPI_CHANNEL_DISABLED The channel is not enabled.
|
||||
*
|
||||
*/
|
||||
__STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_channel_t channel);
|
||||
NRF_STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_t channel);
|
||||
|
||||
/** @brief Function for disabling all PPI channels. */
|
||||
__STATIC_INLINE void nrf_ppi_channel_disable_all(void);
|
||||
/**
|
||||
* @brief Function for disabling all PPI channels.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_disable_all(NRF_PPI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling multiple PPI channels.
|
||||
*
|
||||
* @param[in] mask Channel mask.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Channel mask.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channels_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_enable(NRF_PPI_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling multiple PPI channels.
|
||||
*
|
||||
* @param[in] mask Channel mask.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Channel mask.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channels_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_disable(NRF_PPI_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up event and task endpoints for a given PPI channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] eep Event register address.
|
||||
* @param[in] tep Task register address.
|
||||
* @param[in] channel Channel to which the given endpoints are assigned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up the event endpoint for a given PPI channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] eep Event register address.
|
||||
* @param[in] channel Channel to which the given endpoint is assigned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_event_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep);
|
||||
NRF_STATIC_INLINE void nrf_ppi_event_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up the task endpoint for a given PPI channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] tep Task register address.
|
||||
* @param[in] channel Channel to which the given endpoint is assigned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_task_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t tep);
|
||||
NRF_STATIC_INLINE void nrf_ppi_task_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t tep);
|
||||
|
||||
|
||||
#if defined(PPI_FEATURE_FORKS_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for setting up task endpoint for a given PPI fork.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] fork_tep Task register address.
|
||||
* @param[in] channel Channel to which the given fork endpoint is assigned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_fork_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t fork_tep);
|
||||
NRF_STATIC_INLINE void nrf_ppi_fork_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t fork_tep);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up event and task endpoints for a given PPI channel and fork.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] eep Event register address.
|
||||
* @param[in] tep Task register address.
|
||||
* @param[in] fork_tep Fork task register address (register value).
|
||||
* @param[in] channel Channel to which the given endpoints are assigned.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep,
|
||||
uint32_t fork_tep);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep,
|
||||
uint32_t fork_tep);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -239,134 +259,157 @@ __STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t c
|
||||
*
|
||||
* @details This function adds only one channel to the group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel to be included in the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_include_in_group(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for including multiple PPI channels in a channel group.
|
||||
*
|
||||
* @details This function adds all specified channels to the group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel_mask Channels to be included in the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channels_include_in_group(uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_include_in_group(NRF_PPI_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing a PPI channel from a channel group.
|
||||
*
|
||||
* @details This function removes only one channel from the group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel to be removed from the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_remove_from_group(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing multiple PPI channels from a channel group.
|
||||
*
|
||||
* @details This function removes all specified channels from the group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel_mask Channels to be removed from the group.
|
||||
* @param[in] channel_group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channels_remove_from_group(uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_remove_from_group(NRF_PPI_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group);
|
||||
|
||||
/**
|
||||
* @brief Function for removing all PPI channels from a channel group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_channel_group_clear(nrf_ppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_clear(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a channel group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_group_enable(nrf_ppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_enable(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a channel group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group Channel group.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_group_disable(nrf_ppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_disable(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a PPI task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ppi_task PPI task to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_ppi_task_trigger(nrf_ppi_task_t ppi_task);
|
||||
NRF_STATIC_INLINE void nrf_ppi_task_trigger(NRF_PPI_Type * p_reg, nrf_ppi_task_t ppi_task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified PPI task register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ppi_task PPI task.
|
||||
*
|
||||
* @return Address of the requested PPI task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_address_get(nrf_ppi_task_t ppi_task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_task_t ppi_task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the PPI enable task address of the specified group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group PPI group.
|
||||
*
|
||||
* @return PPI enable task address of the specified group.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_group_enable_address_get(nrf_ppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_group_enable_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the PPI disable task address of the specified group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] group PPI group.
|
||||
*
|
||||
* @return PPI disable task address of the specified group.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_group_disable_address_get(nrf_ppi_channel_group_t group);
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_group_disable_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the ENABLE task associated with the specified channel group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Channel group index.
|
||||
*
|
||||
* @return Requested ENABLE task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_enable_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_enable_task_get(NRF_PPI_Type const * p_reg,
|
||||
uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the DISABLE task associated with the specified channel group.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] index Channel group index.
|
||||
*
|
||||
* @return Requested DISABLE task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_disable_task_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_disable_task_get(NRF_PPI_Type const * p_reg,
|
||||
uint8_t index);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_enable(nrf_ppi_channel_t channel)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_enable(NRF_PPI_Type * p_reg, nrf_ppi_channel_t channel)
|
||||
{
|
||||
NRF_PPI->CHENSET = PPI_CHENSET_CH0_Set << ((uint32_t) channel);
|
||||
p_reg->CHENSET = PPI_CHENSET_CH0_Set << ((uint32_t) channel);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_disable(nrf_ppi_channel_t channel)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_disable(NRF_PPI_Type * p_reg, nrf_ppi_channel_t channel)
|
||||
{
|
||||
NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Clear << ((uint32_t) channel);
|
||||
p_reg->CHENCLR = PPI_CHENCLR_CH0_Clear << ((uint32_t) channel);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_channel_t channel)
|
||||
NRF_STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_t channel)
|
||||
{
|
||||
if (NRF_PPI->CHEN & (PPI_CHEN_CH0_Msk << ((uint32_t) channel)))
|
||||
if (p_reg->CHEN & (PPI_CHEN_CH0_Msk << ((uint32_t) channel)))
|
||||
{
|
||||
return NRF_PPI_CHANNEL_ENABLED;
|
||||
}
|
||||
@@ -376,135 +419,145 @@ __STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_chan
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_disable_all(void)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_disable_all(NRF_PPI_Type * p_reg)
|
||||
{
|
||||
NRF_PPI->CHENCLR = ((uint32_t)0xFFFFFFFFuL);
|
||||
p_reg->CHENCLR = ((uint32_t)0xFFFFFFFFuL);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channels_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_enable(NRF_PPI_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_PPI->CHENSET = mask;
|
||||
p_reg->CHENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channels_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_disable(NRF_PPI_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_PPI->CHENCLR = mask;
|
||||
p_reg->CHENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep)
|
||||
{
|
||||
NRF_PPI->CH[(uint32_t) channel].EEP = eep;
|
||||
NRF_PPI->CH[(uint32_t) channel].TEP = tep;
|
||||
p_reg->CH[(uint32_t) channel].EEP = eep;
|
||||
p_reg->CH[(uint32_t) channel].TEP = tep;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_event_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep)
|
||||
NRF_STATIC_INLINE void nrf_ppi_event_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep)
|
||||
{
|
||||
NRF_PPI->CH[(uint32_t) channel].EEP = eep;
|
||||
p_reg->CH[(uint32_t) channel].EEP = eep;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_task_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t tep)
|
||||
NRF_STATIC_INLINE void nrf_ppi_task_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t tep)
|
||||
{
|
||||
NRF_PPI->CH[(uint32_t) channel].TEP = tep;
|
||||
p_reg->CH[(uint32_t) channel].TEP = tep;
|
||||
}
|
||||
|
||||
#if defined(PPI_FEATURE_FORKS_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_fork_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t fork_tep)
|
||||
NRF_STATIC_INLINE void nrf_ppi_fork_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t fork_tep)
|
||||
{
|
||||
NRF_PPI->FORK[(uint32_t) channel].TEP = fork_tep;
|
||||
p_reg->FORK[(uint32_t) channel].TEP = fork_tep;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep,
|
||||
uint32_t fork_tep)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep,
|
||||
uint32_t fork_tep)
|
||||
{
|
||||
nrf_ppi_channel_endpoint_setup(channel, eep, tep);
|
||||
nrf_ppi_fork_endpoint_setup(channel, fork_tep);
|
||||
nrf_ppi_channel_endpoint_setup(p_reg, channel, eep, tep);
|
||||
nrf_ppi_fork_endpoint_setup(p_reg, channel, fork_tep);
|
||||
}
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] =
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] | (PPI_CHG_CH0_Included << ((uint32_t) channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channels_include_in_group(uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] =
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] | (channel_mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] =
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] & ~(PPI_CHG_CH0_Included << ((uint32_t) channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channels_remove_from_group(uint32_t channel_mask,
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_include_in_group(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] =
|
||||
NRF_PPI->CHG[(uint32_t) channel_group] & ~(channel_mask);
|
||||
p_reg->CHG[(uint32_t) channel_group] |= (PPI_CHG_CH0_Included << ((uint32_t) channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_channel_group_clear(nrf_ppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_include_in_group(NRF_PPI_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->CHG[(uint32_t) group] = 0;
|
||||
p_reg->CHG[(uint32_t) channel_group] |= channel_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_group_enable(nrf_ppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channel_remove_from_group(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->TASKS_CHG[(uint32_t) group].EN = 1UL;
|
||||
p_reg->CHG[(uint32_t) channel_group] &= ~(PPI_CHG_CH0_Included << ((uint32_t) channel));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_group_disable(nrf_ppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_ppi_channels_remove_from_group(NRF_PPI_Type * p_reg,
|
||||
uint32_t channel_mask,
|
||||
nrf_ppi_channel_group_t channel_group)
|
||||
{
|
||||
NRF_PPI->TASKS_CHG[(uint32_t) group].DIS = 1UL;
|
||||
p_reg->CHG[(uint32_t) channel_group] &= ~(channel_mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_ppi_task_trigger(nrf_ppi_task_t ppi_task)
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_clear(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task)) = 1UL;
|
||||
p_reg->CHG[(uint32_t) group] = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_address_get(nrf_ppi_task_t ppi_task)
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_enable(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return (uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task);
|
||||
p_reg->TASKS_CHG[(uint32_t) group].EN = 1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_group_enable_address_get(nrf_ppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_ppi_group_disable(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].EN;
|
||||
p_reg->TASKS_CHG[(uint32_t) group].DIS = 1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_ppi_task_group_disable_address_get(nrf_ppi_channel_group_t group)
|
||||
NRF_STATIC_INLINE void nrf_ppi_task_trigger(NRF_PPI_Type * p_reg, nrf_ppi_task_t ppi_task)
|
||||
{
|
||||
return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].DIS;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) ppi_task)) = 1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_enable_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_task_t ppi_task)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_PPI->TASKS_CHG));
|
||||
return (uint32_t) ((uint8_t *) p_reg + (uint32_t) ppi_task);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_group_enable_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return (uint32_t) &p_reg->TASKS_CHG[(uint32_t) group].EN;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_ppi_task_group_disable_address_get(NRF_PPI_Type const * p_reg,
|
||||
nrf_ppi_channel_group_t group)
|
||||
{
|
||||
return (uint32_t) &p_reg->TASKS_CHG[(uint32_t) group].DIS;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_enable_task_get(NRF_PPI_Type const * p_reg,
|
||||
uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < PPI_GROUP_NUM);
|
||||
return (nrf_ppi_task_t)NRFX_OFFSETOF(NRF_PPI_Type, TASKS_CHG[index].EN);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_disable_task_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_ppi_task_t nrf_ppi_group_disable_task_get(NRF_PPI_Type const * p_reg,
|
||||
uint8_t index)
|
||||
{
|
||||
NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_PPI->TASKS_CHG));
|
||||
NRFX_ASSERT(index < PPI_GROUP_NUM);
|
||||
return (nrf_ppi_task_t)NRFX_OFFSETOF(NRF_PPI_Type, TASKS_CHG[index].DIS);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -219,7 +219,7 @@ typedef union {
|
||||
* SEQ[n].REFRESH and SEQ[n].ENDDELAY registers in the peripheral,
|
||||
* respectively) are ignored at the end of a complex sequence
|
||||
* playback, indicated by the LOOPSDONE event.
|
||||
* See the @linkProductSpecification52 for more information.
|
||||
* See the Product Specification for more information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -244,8 +244,8 @@ typedef struct
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_task_trigger(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_pwm_task_trigger(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified PWM task register.
|
||||
@@ -255,8 +255,8 @@ __STATIC_INLINE void nrf_pwm_task_trigger(NRF_PWM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_pwm_task_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_task_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified PWM event.
|
||||
@@ -264,8 +264,8 @@ __STATIC_INLINE uint32_t nrf_pwm_task_address_get(NRF_PWM_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the PWM event.
|
||||
@@ -276,8 +276,8 @@ __STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_pwm_event_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_pwm_event_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified PWM event register.
|
||||
@@ -287,8 +287,8 @@ __STATIC_INLINE bool nrf_pwm_event_check(NRF_PWM_Type const * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_pwm_event_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_event_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
@@ -296,8 +296,8 @@ __STATIC_INLINE uint32_t nrf_pwm_event_address_get(NRF_PWM_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_shorts_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -305,8 +305,8 @@ __STATIC_INLINE void nrf_pwm_shorts_enable(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_shorts_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the configuration of PWM shortcuts.
|
||||
@@ -314,8 +314,8 @@ __STATIC_INLINE void nrf_pwm_shorts_disable(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts configuration to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_shorts_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
@@ -323,8 +323,8 @@ __STATIC_INLINE void nrf_pwm_shorts_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_int_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -332,8 +332,8 @@ __STATIC_INLINE void nrf_pwm_int_enable(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_int_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the configuration of PWM interrupts.
|
||||
@@ -341,20 +341,18 @@ __STATIC_INLINE void nrf_pwm_int_disable(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_int_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pwm_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_pwm_int_enable_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_int_mask_t pwm_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_int_enable_check(NRF_PWM_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -365,9 +363,9 @@ __STATIC_INLINE bool nrf_pwm_int_enable_check(NRF_PWM_Type const * p_reg,
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_subscribe_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_pwm_subscribe_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -376,8 +374,8 @@ __STATIC_INLINE void nrf_pwm_subscribe_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_subscribe_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_pwm_subscribe_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -387,9 +385,9 @@ __STATIC_INLINE void nrf_pwm_subscribe_clear(NRF_PWM_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_publish_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_pwm_publish_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -398,8 +396,8 @@ __STATIC_INLINE void nrf_pwm_publish_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_publish_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_pwm_publish_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -407,14 +405,14 @@ __STATIC_INLINE void nrf_pwm_publish_clear(NRF_PWM_Type * p_reg,
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_enable(NRF_PWM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_pwm_enable(NRF_PWM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the PWM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_disable(NRF_PWM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_pwm_disable(NRF_PWM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning pins to PWM output channels.
|
||||
@@ -426,8 +424,8 @@ __STATIC_INLINE void nrf_pwm_disable(NRF_PWM_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] out_pins Array with pin numbers for individual PWM output channels.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT]);
|
||||
NRF_STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT]);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the PWM peripheral.
|
||||
@@ -437,10 +435,10 @@ __STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] mode Operating mode of the pulse generator counter.
|
||||
* @param[in] top_value Value up to which the pulse generator counter counts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_clk_t base_clock,
|
||||
nrf_pwm_mode_t mode,
|
||||
uint16_t top_value);
|
||||
NRF_STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_clk_t base_clock,
|
||||
nrf_pwm_mode_t mode,
|
||||
uint16_t top_value);
|
||||
|
||||
/**
|
||||
* @brief Function for defining a sequence of PWM duty cycles.
|
||||
@@ -449,9 +447,9 @@ __STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] p_seq Pointer to the sequence definition.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_seq);
|
||||
NRF_STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_seq);
|
||||
|
||||
/**
|
||||
* @brief Function for modifying the pointer to the duty cycle values
|
||||
@@ -461,9 +459,9 @@ __STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] p_values Pointer to an array with duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_seq_ptr_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t const * p_values);
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_ptr_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t const * p_values);
|
||||
|
||||
/**
|
||||
* @brief Function for modifying the total number of duty cycle values
|
||||
@@ -473,9 +471,9 @@ __STATIC_INLINE void nrf_pwm_seq_ptr_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] length Number of duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t length);
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for modifying the additional number of PWM periods spent
|
||||
@@ -485,9 +483,9 @@ __STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] refresh Number of additional PWM periods for each duty cycle value.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_seq_refresh_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t refresh);
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_refresh_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t refresh);
|
||||
|
||||
/**
|
||||
* @brief Function for modifying the additional time added after the sequence
|
||||
@@ -497,9 +495,9 @@ __STATIC_INLINE void nrf_pwm_seq_refresh_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] end_delay Number of PWM periods added at the end of the sequence.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_seq_end_delay_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay);
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_end_delay_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the mode of loading sequence data from RAM
|
||||
@@ -509,9 +507,9 @@ __STATIC_INLINE void nrf_pwm_seq_end_delay_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] dec_load Mode of loading sequence data from RAM.
|
||||
* @param[in] dec_step Mode of advancing the active sequence.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_decoder_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_dec_load_t dec_load,
|
||||
nrf_pwm_dec_step_t dec_step);
|
||||
NRF_STATIC_INLINE void nrf_pwm_decoder_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_dec_load_t dec_load,
|
||||
nrf_pwm_dec_step_t dec_step);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the number of times the sequence playback
|
||||
@@ -523,26 +521,25 @@ __STATIC_INLINE void nrf_pwm_decoder_set(NRF_PWM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] loop_count Number of times to perform the sequence playback.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_pwm_loop_set(NRF_PWM_Type * p_reg,
|
||||
uint16_t loop_count);
|
||||
NRF_STATIC_INLINE void nrf_pwm_loop_set(NRF_PWM_Type * p_reg, uint16_t loop_count);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_task_trigger(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_pwm_task_trigger(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_pwm_task_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_task_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -551,102 +548,95 @@ __STATIC_INLINE void nrf_pwm_event_clear(NRF_PWM_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_pwm_event_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_pwm_event_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_pwm_event_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_event_address_get(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_shorts_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_enable(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_shorts_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_disable(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_shorts_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_shorts_set(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_int_enable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_enable(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_int_disable(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_disable(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_int_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_pwm_int_set(NRF_PWM_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTEN = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_pwm_int_enable_check(NRF_PWM_Type const * p_reg,
|
||||
nrf_pwm_int_mask_t pwm_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_pwm_int_enable_check(NRF_PWM_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & pwm_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_pwm_subscribe_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_pwm_subscribe_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | PWM_SUBSCRIBE_STOP_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_subscribe_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_pwm_subscribe_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_publish_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_pwm_publish_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | PWM_PUBLISH_STOPPED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_publish_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_pwm_publish_clear(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_enable(NRF_PWM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_pwm_enable(NRF_PWM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (PWM_ENABLE_ENABLE_Enabled << PWM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_disable(NRF_PWM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_pwm_disable(NRF_PWM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT])
|
||||
NRF_STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT])
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < NRF_PWM_CHANNEL_COUNT; ++i)
|
||||
@@ -655,10 +645,10 @@ __STATIC_INLINE void nrf_pwm_pins_set(NRF_PWM_Type * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_clk_t base_clock,
|
||||
nrf_pwm_mode_t mode,
|
||||
uint16_t top_value)
|
||||
NRF_STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_clk_t base_clock,
|
||||
nrf_pwm_mode_t mode,
|
||||
uint16_t top_value)
|
||||
{
|
||||
NRFX_ASSERT(top_value <= PWM_COUNTERTOP_COUNTERTOP_Msk);
|
||||
|
||||
@@ -667,9 +657,9 @@ __STATIC_INLINE void nrf_pwm_configure(NRF_PWM_Type * p_reg,
|
||||
p_reg->COUNTERTOP = top_value;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_seq)
|
||||
NRF_STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_seq)
|
||||
{
|
||||
NRFX_ASSERT(p_seq != NULL);
|
||||
|
||||
@@ -679,18 +669,18 @@ __STATIC_INLINE void nrf_pwm_sequence_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_seq_end_delay_set(p_reg, seq_id, p_seq->end_delay);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_seq_ptr_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t const * p_values)
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_ptr_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t const * p_values)
|
||||
{
|
||||
NRFX_ASSERT(seq_id <= 1);
|
||||
NRFX_ASSERT(p_values != NULL);
|
||||
p_reg->SEQ[seq_id].PTR = (uint32_t)p_values;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t length)
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint16_t length)
|
||||
{
|
||||
NRFX_ASSERT(seq_id <= 1);
|
||||
NRFX_ASSERT(length != 0);
|
||||
@@ -698,39 +688,39 @@ __STATIC_INLINE void nrf_pwm_seq_cnt_set(NRF_PWM_Type * p_reg,
|
||||
p_reg->SEQ[seq_id].CNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_seq_refresh_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t refresh)
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_refresh_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t refresh)
|
||||
{
|
||||
NRFX_ASSERT(seq_id <= 1);
|
||||
NRFX_ASSERT(refresh <= PWM_SEQ_REFRESH_CNT_Msk);
|
||||
p_reg->SEQ[seq_id].REFRESH = refresh;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_seq_end_delay_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay)
|
||||
NRF_STATIC_INLINE void nrf_pwm_seq_end_delay_set(NRF_PWM_Type * p_reg,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay)
|
||||
{
|
||||
NRFX_ASSERT(seq_id <= 1);
|
||||
NRFX_ASSERT(end_delay <= PWM_SEQ_ENDDELAY_CNT_Msk);
|
||||
p_reg->SEQ[seq_id].ENDDELAY = end_delay;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_decoder_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_dec_load_t dec_load,
|
||||
nrf_pwm_dec_step_t dec_step)
|
||||
NRF_STATIC_INLINE void nrf_pwm_decoder_set(NRF_PWM_Type * p_reg,
|
||||
nrf_pwm_dec_load_t dec_load,
|
||||
nrf_pwm_dec_step_t dec_step)
|
||||
{
|
||||
p_reg->DECODER = ((uint32_t)dec_load << PWM_DECODER_LOAD_Pos) |
|
||||
((uint32_t)dec_step << PWM_DECODER_MODE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_pwm_loop_set(NRF_PWM_Type * p_reg,
|
||||
uint16_t loop_count)
|
||||
NRF_STATIC_INLINE void nrf_pwm_loop_set(NRF_PWM_Type * p_reg,
|
||||
uint16_t loop_count)
|
||||
{
|
||||
p_reg->LOOP = loop_count;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -130,415 +130,482 @@ typedef enum
|
||||
NRF_QDEC_REPORTPER_DISABLED /**< QDEC reporting disabled. */
|
||||
} nrf_qdec_reportper_t;
|
||||
|
||||
/** @brief Function for enabling QDEC. */
|
||||
__STATIC_INLINE void nrf_qdec_enable(void);
|
||||
/**
|
||||
* @brief Function for enabling QDEC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qdec_enable(NRF_QDEC_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling QDEC. */
|
||||
__STATIC_INLINE void nrf_qdec_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling QDEC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qdec_disable(NRF_QDEC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the enable state of QDEC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return State of the register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_enable_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_enable_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling QDEC interrupts by mask.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_int_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qdec_int_enable(NRF_QDEC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling QDEC interrupts by mask.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_int_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qdec_int_disable(NRF_QDEC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the enabled interrupts of the QDEC.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Bitfield with enabled interrupts.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_int_enable_check(nrf_qdec_int_mask_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_int_enable_check(NRF_QDEC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/** @brief Function for enabling the QDEC debouncing filter. */
|
||||
__STATIC_INLINE void nrf_qdec_dbfen_enable(void);
|
||||
/**
|
||||
* @brief Function for enabling the QDEC debouncing filter.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qdec_dbfen_enable(NRF_QDEC_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling the QDEC debouncing filter. */
|
||||
__STATIC_INLINE void nrf_qdec_dbfen_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling the QDEC debouncing filter.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qdec_dbfen_disable(NRF_QDEC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the QDEC debouncing filter.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval NRF_QDEC_DBFEN_DISABLE The debouncing filter is disabled.
|
||||
* @retval NRF_QDEC_DBFEN_ENABLE The debouncing filter is enabled.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_dbfen_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_dbfen_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for assigning QDEC pins.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] psela Pin number.
|
||||
* @param[in] pselb Pin number.
|
||||
* @param[in] pselled Pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_pio_assign( uint32_t psela, uint32_t pselb, uint32_t pselled);
|
||||
NRF_STATIC_INLINE void nrf_qdec_pio_assign(NRF_QDEC_Type * p_reg,
|
||||
uint32_t psela,
|
||||
uint32_t pselb,
|
||||
uint32_t pselled);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified QDEC task.
|
||||
*
|
||||
* @param[in] task QDEC task to be triggered.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task QDEC task to be triggered.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_task_trigger(nrf_qdec_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_qdec_task_trigger(NRF_QDEC_Type * p_reg, nrf_qdec_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the address of a QDEC task register.
|
||||
*
|
||||
* @param[in] task QDEC task to get its address.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task QDEC task to get its address.
|
||||
*
|
||||
* @return Address of the specified QDEC task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_qdec_task_address_get(nrf_qdec_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_task_address_get(NRF_QDEC_Type const * p_reg,
|
||||
nrf_qdec_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified QDEC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event QDEC event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_event_clear(nrf_qdec_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_qdec_event_clear(NRF_QDEC_Type * p_reg, nrf_qdec_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the specified QDEC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event QDEC event to be checked.
|
||||
*
|
||||
* @return State of the specified QDEC event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_event_check(nrf_qdec_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_qdec_event_check(NRF_QDEC_Type const * p_reg, nrf_qdec_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the address of the specified QDEC event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event QDEC event to get its address.
|
||||
*
|
||||
* @return Address of the specified QDEC event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_qdec_event_address_get(nrf_qdec_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_event_address_get(NRF_QDEC_Type const * p_reg,
|
||||
nrf_qdec_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting QDEC shortcuts.
|
||||
*
|
||||
* @param[in] mask Mask of QDEC shortcuts to be set.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of QDEC shortcuts to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_shorts_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qdec_shorts_enable(NRF_QDEC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing shortcuts of the QDEC by mask.
|
||||
*
|
||||
* @param[in] mask Mask of QDEC shortcuts to be cleared.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of QDEC shortcuts to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_shorts_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qdec_shorts_disable(NRF_QDEC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the sampling period.
|
||||
*
|
||||
* @return Sample period @ref nrf_qdec_sampleper_t.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrf_qdec_sampleper_reg_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for converting return value of the @p nrf_qdec_sampleper_reg_get() function
|
||||
* @brief Function for converting return value of the @ref nrf_qdec_sampleper_get function
|
||||
* to microseconds.
|
||||
*
|
||||
* @param[in] sampleper The sampling period.
|
||||
*
|
||||
* @return Period in microseconds.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(uint32_t sampleper);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(nrf_qdec_sampleper_t sampleper);
|
||||
|
||||
/**
|
||||
* @brief Function for setting value of the QDEC sampling period.
|
||||
*
|
||||
* @param[in] sample_per The sampling period.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] sampleper The sampling period.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_sampleper_set(nrf_qdec_sampleper_t sample_per);
|
||||
NRF_STATIC_INLINE void nrf_qdec_sampleper_set(NRF_QDEC_Type * p_reg,
|
||||
nrf_qdec_sampleper_t sampleper);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC sampling period.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Sampling period.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_qdec_sampleper_t nrf_qdec_sampleper_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC SAMPLE register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value of the SAMPLE register.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrf_qdec_sample_get(void);
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_sample_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC ACC register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value of the ACC register.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrf_qdec_acc_get(void);
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_acc_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC ACCREAD register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value of the ACCREAD register.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrf_qdec_accread_get(void);
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_accread_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC ACCDBL register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value of the ACCDBL register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_accdbl_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_accdbl_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving value of the QDEC ACCDBLREAD register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value of the ACCDBLREAD register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_accdblread_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_accdblread_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting delay time between setting LED active state and start sampling.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] time_us Delay time (in microseconds) between setting LED active state
|
||||
* and start sampling.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_ledpre_set(uint32_t time_us);
|
||||
NRF_STATIC_INLINE void nrf_qdec_ledpre_set(NRF_QDEC_Type * p_reg, uint32_t time_us);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving how long the LED is switched on before sampling.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The gap in time in microseconds between switched LED to active state and start sampling.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_ledpre_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_ledpre_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the report period (in samples).
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] reportper The number of samples.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_reportper_set(nrf_qdec_reportper_t reportper);
|
||||
NRF_STATIC_INLINE void nrf_qdec_reportper_set(NRF_QDEC_Type * p_reg,
|
||||
nrf_qdec_reportper_t reportper);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the report period.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The report period.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_reportper_reg_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_reportper_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the value of QDEC SAMPLEPER register.
|
||||
*
|
||||
* @param [in] reportper Reportper to be converted to amount of samples per report.
|
||||
* @param[in] reportper Reportper to be converted to amount of samples per report.
|
||||
*
|
||||
* @return Number of samples per report.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the active level for the LED.
|
||||
*
|
||||
* @param[in] pol Level of the active signal of the LED.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pol Level of the active signal of the LED.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qdec_ledpol_set(nrf_qdec_ledpol_t pol);
|
||||
NRF_STATIC_INLINE void nrf_qdec_ledpol_set(NRF_QDEC_Type * p_reg, nrf_qdec_ledpol_t pol);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the active level for the LED.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Level of the active signal of the LED.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qdec_ledpol_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_ledpol_get(NRF_QDEC_Type const * p_reg);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_enable(NRF_QDEC_Type * p_reg)
|
||||
{
|
||||
NRF_QDEC->ENABLE = NRF_QDEC_ENABLE;
|
||||
p_reg->ENABLE = NRF_QDEC_ENABLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_disable(NRF_QDEC_Type * p_reg)
|
||||
{
|
||||
NRF_QDEC->ENABLE = NRF_QDEC_DISABLE;
|
||||
p_reg->ENABLE = NRF_QDEC_DISABLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_enable_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_enable_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->ENABLE;
|
||||
return p_reg->ENABLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_int_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qdec_int_enable(NRF_QDEC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_QDEC->INTENSET = mask; // writing 0 has no effect
|
||||
p_reg->INTENSET = mask; // writing 0 has no effect
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_int_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qdec_int_disable(NRF_QDEC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_QDEC->INTENCLR = mask; // writing 0 has no effect
|
||||
p_reg->INTENCLR = mask; // writing 0 has no effect
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_int_enable_check(nrf_qdec_int_mask_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_int_enable_check(NRF_QDEC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return NRF_QDEC->INTENSET & mask; // when read this register will return the value of INTEN.
|
||||
return p_reg->INTENSET & mask; // when read this register will return the value of INTEN.
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_dbfen_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_dbfen_enable(NRF_QDEC_Type * p_reg)
|
||||
{
|
||||
NRF_QDEC->DBFEN = NRF_QDEC_DBFEN_ENABLE;
|
||||
p_reg->DBFEN = NRF_QDEC_DBFEN_ENABLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_dbfen_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_dbfen_disable(NRF_QDEC_Type * p_reg)
|
||||
{
|
||||
NRF_QDEC->DBFEN = NRF_QDEC_DBFEN_DISABLE;
|
||||
p_reg->DBFEN = NRF_QDEC_DBFEN_DISABLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_dbfen_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_dbfen_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->DBFEN;
|
||||
return p_reg->DBFEN;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_pio_assign( uint32_t psela, uint32_t pselb, uint32_t pselled)
|
||||
NRF_STATIC_INLINE void nrf_qdec_pio_assign(NRF_QDEC_Type * p_reg,
|
||||
uint32_t psela,
|
||||
uint32_t pselb,
|
||||
uint32_t pselled)
|
||||
{
|
||||
#if defined(QDEC_PSEL_A_CONNECT_Pos)
|
||||
NRF_QDEC->PSEL.A = psela;
|
||||
p_reg->PSEL.A = psela;
|
||||
#else
|
||||
NRF_QDEC->PSELA = psela;
|
||||
p_reg->PSELA = psela;
|
||||
#endif
|
||||
|
||||
#if defined(QDEC_PSEL_B_CONNECT_Pos)
|
||||
NRF_QDEC->PSEL.B = pselb;
|
||||
p_reg->PSEL.B = pselb;
|
||||
#else
|
||||
NRF_QDEC->PSELB = pselb;
|
||||
p_reg->PSELB = pselb;
|
||||
#endif
|
||||
|
||||
#if defined(QDEC_PSEL_LED_CONNECT_Pos)
|
||||
NRF_QDEC->PSEL.LED = pselled;
|
||||
p_reg->PSEL.LED = pselled;
|
||||
#else
|
||||
NRF_QDEC->PSELLED = pselled;
|
||||
p_reg->PSELLED = pselled;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_task_trigger(nrf_qdec_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_qdec_task_trigger(NRF_QDEC_Type * p_reg, nrf_qdec_task_t task)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_QDEC + (uint32_t)task) ) = 1;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)task) ) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_qdec_task_address_get(nrf_qdec_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_task_address_get(NRF_QDEC_Type const * p_reg,
|
||||
nrf_qdec_task_t task)
|
||||
{
|
||||
return (uint32_t *)( (uint8_t *)NRF_QDEC + (uint32_t)task);
|
||||
return (uint32_t)( (uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_event_clear(nrf_qdec_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_qdec_event_clear(NRF_QDEC_Type * p_reg, nrf_qdec_event_t event)
|
||||
{
|
||||
*( (volatile uint32_t *)( (uint8_t *)NRF_QDEC + (uint32_t)event) ) = 0;
|
||||
*( (volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event) ) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_QDEC + event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_event_check(nrf_qdec_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_qdec_event_check(NRF_QDEC_Type const * p_reg, nrf_qdec_event_t event)
|
||||
{
|
||||
return *(volatile uint32_t *)( (uint8_t *)NRF_QDEC + (uint32_t)event);
|
||||
return (bool)*(volatile uint32_t *)( (uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_qdec_event_address_get(nrf_qdec_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_event_address_get(NRF_QDEC_Type const * p_reg,
|
||||
nrf_qdec_event_t event)
|
||||
{
|
||||
return (uint32_t *)( (uint8_t *)NRF_QDEC + (uint32_t)event);
|
||||
return (uint32_t)( (uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_shorts_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qdec_shorts_enable(NRF_QDEC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_QDEC->SHORTS |= mask;
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_shorts_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qdec_shorts_disable(NRF_QDEC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_QDEC->SHORTS &= ~mask;
|
||||
p_reg->SHORTS &= ~mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE int32_t nrf_qdec_sampleper_reg_get(void)
|
||||
{
|
||||
return NRF_QDEC->SAMPLEPER;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(uint32_t sampleper)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(nrf_qdec_sampleper_t sampleper)
|
||||
{
|
||||
return (1 << (7 + sampleper));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_sampleper_set(nrf_qdec_sampleper_t sample_per)
|
||||
NRF_STATIC_INLINE void nrf_qdec_sampleper_set(NRF_QDEC_Type * p_reg,
|
||||
nrf_qdec_sampleper_t sampleper)
|
||||
{
|
||||
NRF_QDEC->SAMPLEPER = sample_per;
|
||||
p_reg->SAMPLEPER = sampleper;
|
||||
}
|
||||
|
||||
__STATIC_INLINE int32_t nrf_qdec_sample_get(void)
|
||||
NRF_STATIC_INLINE nrf_qdec_sampleper_t nrf_qdec_sampleper_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->SAMPLE;
|
||||
return (nrf_qdec_sampleper_t)(p_reg->SAMPLEPER);
|
||||
}
|
||||
|
||||
__STATIC_INLINE int32_t nrf_qdec_acc_get(void)
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_sample_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->ACC;
|
||||
return p_reg->SAMPLE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE int32_t nrf_qdec_accread_get(void)
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_acc_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->ACCREAD;
|
||||
return p_reg->ACC;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_accdbl_get(void)
|
||||
NRF_STATIC_INLINE int32_t nrf_qdec_accread_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->ACCDBL;
|
||||
return p_reg->ACCREAD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_accdblread_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_accdbl_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->ACCDBLREAD;
|
||||
return p_reg->ACCDBL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_ledpre_set(uint32_t time_us)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_accdblread_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
NRF_QDEC->LEDPRE = time_us;
|
||||
return p_reg->ACCDBLREAD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_ledpre_get(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_ledpre_set(NRF_QDEC_Type * p_reg, uint32_t time_us)
|
||||
{
|
||||
return NRF_QDEC->LEDPRE;
|
||||
p_reg->LEDPRE = time_us;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_reportper_set(nrf_qdec_reportper_t reportper)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_ledpre_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
NRF_QDEC->REPORTPER = reportper;
|
||||
return p_reg->LEDPRE;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_reportper_reg_get(void)
|
||||
NRF_STATIC_INLINE void nrf_qdec_reportper_set(NRF_QDEC_Type * p_reg,
|
||||
nrf_qdec_reportper_t reportper)
|
||||
{
|
||||
return NRF_QDEC->REPORTPER;
|
||||
p_reg->REPORTPER = reportper;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_reportper_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->REPORTPER;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper)
|
||||
{
|
||||
return (reportper == NRF_QDEC_REPORTPER_10) ? 10 : reportper * 40;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qdec_ledpol_set(nrf_qdec_ledpol_t pol)
|
||||
NRF_STATIC_INLINE void nrf_qdec_ledpol_set(NRF_QDEC_Type * p_reg, nrf_qdec_ledpol_t pol)
|
||||
{
|
||||
NRF_QDEC->LEDPOL = pol;
|
||||
p_reg->LEDPOL = pol;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qdec_ledpol_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qdec_ledpol_get(NRF_QDEC_Type const * p_reg)
|
||||
{
|
||||
return NRF_QDEC->LEDPOL;
|
||||
return p_reg->LEDPOL;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,6 +45,34 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the QSPI peripheral.
|
||||
*/
|
||||
|
||||
#if defined(QSPI_XIPEN_XIPEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether XIP can be explicitly enabled or disabled via XIPEN register. */
|
||||
#define NRF_QSPI_HAS_XIPEN 1
|
||||
#else
|
||||
#define NRF_QSPI_HAS_XIPEN 0
|
||||
#endif
|
||||
|
||||
#if defined(QSPI_XIP_ENC_ENABLE_ENABLE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether encryption for XIP is present. */
|
||||
#define NRF_QSPI_HAS_XIP_ENC 1
|
||||
#else
|
||||
#define NRF_QSPI_HAS_XIP_ENC 0
|
||||
#endif
|
||||
|
||||
#if defined(QSPI_DMA_ENC_ENABLE_ENABLE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether encryption for EasyDMA is present. */
|
||||
#define NRF_QSPI_HAS_DMA_ENC 1
|
||||
#else
|
||||
#define NRF_QSPI_HAS_DMA_ENC 0
|
||||
#endif
|
||||
|
||||
#if defined(NRF53_SERIES) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Value representing QSPI base clock frequency. */
|
||||
#define NRF_QSPI_BASE_CLOCK_FREQ 96000000uL
|
||||
#else
|
||||
#define NRF_QSPI_BASE_CLOCK_FREQ 32000000uL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This value can be used as a parameter for the @ref nrf_qspi_pins_set
|
||||
* function to specify that a given QSPI signal (SCK, CSN, IO0, IO1, IO2, or IO3)
|
||||
@@ -78,27 +106,47 @@ typedef enum
|
||||
NRF_QSPI_INT_READY_MASK = QSPI_INTENSET_READY_Msk /**< Interrupt on READY event. */
|
||||
} nrf_qspi_int_mask_t;
|
||||
|
||||
/** @brief QSPI frequency divider values. */
|
||||
/** @brief QSPI base clock frequency divider values. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_QSPI_FREQ_32MDIV1, /**< 32.0 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV2, /**< 16.0 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV3, /**< 10.6 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV4, /**< 8.00 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV5, /**< 6.40 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV6, /**< 5.33 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV7, /**< 4.57 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV8, /**< 4.00 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV9, /**< 3.55 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV10, /**< 3.20 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV11, /**< 2.90 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV12, /**< 2.66 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV13, /**< 2.46 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV14, /**< 2.29 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV15, /**< 2.13 MHz. */
|
||||
NRF_QSPI_FREQ_32MDIV16, /**< 2.00 MHz. */
|
||||
NRF_QSPI_FREQ_DIV1, /**< Divide by 1. */
|
||||
NRF_QSPI_FREQ_DIV2, /**< Divide by 2. */
|
||||
NRF_QSPI_FREQ_DIV3, /**< Divide by 3. */
|
||||
NRF_QSPI_FREQ_DIV4, /**< Divide by 4. */
|
||||
NRF_QSPI_FREQ_DIV5, /**< Divide by 5. */
|
||||
NRF_QSPI_FREQ_DIV6, /**< Divide by 6. */
|
||||
NRF_QSPI_FREQ_DIV7, /**< Divide by 7. */
|
||||
NRF_QSPI_FREQ_DIV8, /**< Divide by 8. */
|
||||
NRF_QSPI_FREQ_DIV9, /**< Divide by 9. */
|
||||
NRF_QSPI_FREQ_DIV10, /**< Divide by 10. */
|
||||
NRF_QSPI_FREQ_DIV11, /**< Divide by 11. */
|
||||
NRF_QSPI_FREQ_DIV12, /**< Divide by 12. */
|
||||
NRF_QSPI_FREQ_DIV13, /**< Divide by 13. */
|
||||
NRF_QSPI_FREQ_DIV14, /**< Divide by 14. */
|
||||
NRF_QSPI_FREQ_DIV15, /**< Divide by 15. */
|
||||
NRF_QSPI_FREQ_DIV16, /**< Divide by 16. */
|
||||
} nrf_qspi_frequency_t;
|
||||
|
||||
#if defined(NRF52_SERIES)
|
||||
/** Symbols translation for backward compatibility. */
|
||||
#define NRF_QSPI_FREQ_32MDIV1 NRF_QSPI_FREQ_DIV1
|
||||
#define NRF_QSPI_FREQ_32MDIV2 NRF_QSPI_FREQ_DIV2
|
||||
#define NRF_QSPI_FREQ_32MDIV3 NRF_QSPI_FREQ_DIV3
|
||||
#define NRF_QSPI_FREQ_32MDIV4 NRF_QSPI_FREQ_DIV4
|
||||
#define NRF_QSPI_FREQ_32MDIV5 NRF_QSPI_FREQ_DIV5
|
||||
#define NRF_QSPI_FREQ_32MDIV6 NRF_QSPI_FREQ_DIV6
|
||||
#define NRF_QSPI_FREQ_32MDIV7 NRF_QSPI_FREQ_DIV7
|
||||
#define NRF_QSPI_FREQ_32MDIV8 NRF_QSPI_FREQ_DIV8
|
||||
#define NRF_QSPI_FREQ_32MDIV9 NRF_QSPI_FREQ_DIV9
|
||||
#define NRF_QSPI_FREQ_32MDIV10 NRF_QSPI_FREQ_DIV10
|
||||
#define NRF_QSPI_FREQ_32MDIV11 NRF_QSPI_FREQ_DIV11
|
||||
#define NRF_QSPI_FREQ_32MDIV12 NRF_QSPI_FREQ_DIV12
|
||||
#define NRF_QSPI_FREQ_32MDIV13 NRF_QSPI_FREQ_DIV13
|
||||
#define NRF_QSPI_FREQ_32MDIV14 NRF_QSPI_FREQ_DIV14
|
||||
#define NRF_QSPI_FREQ_32MDIV15 NRF_QSPI_FREQ_DIV15
|
||||
#define NRF_QSPI_FREQ_32MDIV16 NRF_QSPI_FREQ_DIV16
|
||||
#endif
|
||||
|
||||
/** @brief Interface configuration for a read operation. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -171,10 +219,10 @@ typedef struct
|
||||
uint8_t io0_pin; /**< IO0/MOSI pin number. */
|
||||
uint8_t io1_pin; /**< IO1/MISO pin number. */
|
||||
uint8_t io2_pin; /**< IO2 pin number (optional).
|
||||
* Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
|
||||
* Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
|
||||
*/
|
||||
uint8_t io3_pin; /**< IO3 pin number (optional).
|
||||
* Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
|
||||
* Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
|
||||
*/
|
||||
} nrf_qspi_pins_t;
|
||||
|
||||
@@ -215,17 +263,34 @@ typedef struct
|
||||
uint8_t sck_delay; /**< tSHSL, tWHSL, and tSHWL in number of 16 MHz periods (62.5ns). */
|
||||
bool dpmen; /**< Enable the DPM feature. */
|
||||
nrf_qspi_spi_mode_t spi_mode; /**< SPI phase and polarization. */
|
||||
nrf_qspi_frequency_t sck_freq; /**< SCK frequency given as enum @ref nrf_qspi_frequency_t. */
|
||||
nrf_qspi_frequency_t sck_freq; /**< SCK frequency given as QSPI base clock frequency divider.
|
||||
* To calculate @p sck_freq value corresponding to chosen frequency,
|
||||
* use the following equation:
|
||||
*
|
||||
* sck_freq = (NRF_QSPI_BASE_CLOCK_FREQ / frequency) - 1
|
||||
*
|
||||
* @note Achievable frequencies are determined by available
|
||||
* divider values and QSPI base clock frequency.
|
||||
*/
|
||||
} nrf_qspi_phy_conf_t;
|
||||
|
||||
|
||||
#if NRF_QSPI_HAS_XIP_ENC || NRF_QSPI_HAS_DMA_ENC
|
||||
/** @brief QSPI encryption settings for XIP and DMA transfers. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key[4]; /**< AES 128-bit key, stored on 4 32-bit words. */
|
||||
uint32_t nonce[3]; /**< AES 96-bit nonce, stored on 3 32-bit words. */
|
||||
} nrf_qspi_encryption_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for activating the specified QSPI task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified QSPI task register.
|
||||
@@ -235,8 +300,8 @@ __STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qspi_task_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_task_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified QSPI event.
|
||||
@@ -244,7 +309,7 @@ __STATIC_INLINE uint32_t nrf_qspi_task_address_get(NRF_QSPI_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_event_clear(NRF_QSPI_Type * p_reg, nrf_qspi_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_qspi_event_clear(NRF_QSPI_Type * p_reg, nrf_qspi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the QSPI event.
|
||||
@@ -255,7 +320,7 @@ __STATIC_INLINE void nrf_qspi_event_clear(NRF_QSPI_Type * p_reg, nrf_qspi_event_
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_qspi_event_check(NRF_QSPI_Type const * p_reg, nrf_qspi_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_qspi_event_check(NRF_QSPI_Type const * p_reg, nrf_qspi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified QSPI event register.
|
||||
@@ -265,7 +330,7 @@ __STATIC_INLINE bool nrf_qspi_event_check(NRF_QSPI_Type const * p_reg, nrf_qspi_
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_qspi_event_address_get(NRF_QSPI_Type const * p_reg,
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_event_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_event_t event);
|
||||
|
||||
/**
|
||||
@@ -274,7 +339,7 @@ __STATIC_INLINE uint32_t * nrf_qspi_event_address_get(NRF_QSPI_Type const * p_re
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_int_enable(NRF_QSPI_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qspi_int_enable(NRF_QSPI_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -282,33 +347,31 @@ __STATIC_INLINE void nrf_qspi_int_enable(NRF_QSPI_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_int_disable(NRF_QSPI_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_qspi_int_disable(NRF_QSPI_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] qspi_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_qspi_int_enable_check(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_int_mask_t qspi_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_int_enable_check(NRF_QSPI_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the QSPI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_enable(NRF_QSPI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_qspi_enable(NRF_QSPI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the QSPI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring QSPI pins.
|
||||
@@ -319,8 +382,8 @@ __STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_pins Pointer to the pins configuration structure. See @ref nrf_qspi_pins_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_pins_t * p_pins);
|
||||
NRF_STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_pins_t const * p_pins);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the QSPI XIPOFFSET register.
|
||||
@@ -328,8 +391,8 @@ __STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] xip_offset Address offset in the external memory for Execute in Place operation.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_xip_offset_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t xip_offset);
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_offset_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t xip_offset);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the QSPI IFCONFIG0 register.
|
||||
@@ -338,8 +401,8 @@ __STATIC_INLINE void nrf_qspi_xip_offset_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] p_config Pointer to the QSPI protocol interface configuration structure.
|
||||
* See @ref nrf_qspi_prot_conf_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_prot_conf_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_prot_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the QSPI IFCONFIG1 register.
|
||||
@@ -348,8 +411,8 @@ __STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] p_config Pointer to the QSPI physical interface configuration structure.
|
||||
* See @ref nrf_qspi_phy_conf_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_phy_conf_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_phy_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the QSPI ADDRCONF register.
|
||||
@@ -366,8 +429,8 @@ __STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] p_config Pointer to the addressing mode configuration structure.
|
||||
* See @ref nrf_qspi_addrconfig_conf_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_addrconfig_conf_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_addrconfig_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for setting write data into the peripheral register (without starting the process).
|
||||
@@ -377,10 +440,10 @@ __STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type *
|
||||
* @param[in] length Lenght of the writing data.
|
||||
* @param[in] dest_addr Address in memory to write to.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_write_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void const * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t dest_addr);
|
||||
NRF_STATIC_INLINE void nrf_qspi_write_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void const * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t dest_addr);
|
||||
|
||||
/**
|
||||
* @brief Function for setting read data into the peripheral register (without starting the process).
|
||||
@@ -390,10 +453,10 @@ __STATIC_INLINE void nrf_qspi_write_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] length Length of the read data.
|
||||
* @param[in] src_addr Address in memory to read from.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_read_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t src_addr);
|
||||
NRF_STATIC_INLINE void nrf_qspi_read_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t src_addr);
|
||||
|
||||
/**
|
||||
* @brief Function for setting erase data into the peripheral register (without starting the process).
|
||||
@@ -402,9 +465,9 @@ __STATIC_INLINE void nrf_qspi_read_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] erase_addr Start address to erase. Address must have padding set to 4 bytes.
|
||||
* @param[in] len Size of erasing area.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_erase_ptr_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t erase_addr,
|
||||
nrf_qspi_erase_len_t len);
|
||||
NRF_STATIC_INLINE void nrf_qspi_erase_ptr_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t erase_addr,
|
||||
nrf_qspi_erase_len_t len);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the peripheral status register.
|
||||
@@ -413,7 +476,7 @@ __STATIC_INLINE void nrf_qspi_erase_ptr_set(NRF_QSPI_Type * p_reg,
|
||||
*
|
||||
* @return Peripheral status register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_qspi_status_reg_get(NRF_QSPI_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_status_reg_get(NRF_QSPI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the device status register stored in the peripheral status register.
|
||||
@@ -422,7 +485,7 @@ __STATIC_INLINE uint32_t nrf_qspi_status_reg_get(NRF_QSPI_Type const * p_reg);
|
||||
*
|
||||
* @return Device status register (lower byte).
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_qspi_sreg_get(NRF_QSPI_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_qspi_sreg_get(NRF_QSPI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the peripheral is busy or not.
|
||||
@@ -432,7 +495,7 @@ __STATIC_INLINE uint8_t nrf_qspi_sreg_get(NRF_QSPI_Type const * p_reg);
|
||||
* @retval true The QSPI is busy.
|
||||
* @retval false The QSPI is ready.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_qspi_busy_check(NRF_QSPI_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_qspi_busy_check(NRF_QSPI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting registers sending with custom instruction transmission.
|
||||
@@ -444,9 +507,9 @@ __STATIC_INLINE bool nrf_qspi_busy_check(NRF_QSPI_Type const * p_reg);
|
||||
* @param[in] length Length of the custom instruction data.
|
||||
* @param[in] p_tx_data Pointer to the data to send with the custom instruction.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void const * p_tx_data);
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void const * p_tx_data);
|
||||
|
||||
/**
|
||||
* @brief Function for getting data from register after custom instruction transmission.
|
||||
@@ -455,9 +518,9 @@ __STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
* @param[in] length Length of the custom instruction data.
|
||||
* @param[in] p_rx_data Pointer to the reading buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void * p_rx_data);
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void * p_rx_data);
|
||||
|
||||
/**
|
||||
* @brief Function for sending custom instruction to external memory.
|
||||
@@ -466,9 +529,8 @@ __STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
* @param[in] p_config Pointer to the custom instruction configuration structure.
|
||||
* See @ref nrf_qspi_cinstr_conf_t.
|
||||
*/
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_cinstr_conf_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a custom instruction long transfer.
|
||||
@@ -477,8 +539,8 @@ __STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type *
|
||||
* @param[in] p_config Pointer to the custom instruction configuration structure.
|
||||
* See @ref nrf_qspi_cinstr_conf_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_cinstr_conf_t * p_config);
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for checking whether a custom instruction long transfer is ongoing.
|
||||
@@ -488,7 +550,7 @@ __STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type *
|
||||
* @retval true Custom instruction long transfer is ongoing.
|
||||
* @retval false Custom instruction long transfer is not ongoing.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_qspi_cinstr_long_transfer_is_ongoing(NRF_QSPI_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_qspi_cinstr_long_transfer_is_ongoing(NRF_QSPI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for continuing a custom instruction long transfer.
|
||||
@@ -498,61 +560,110 @@ __STATIC_INLINE bool nrf_qspi_cinstr_long_transfer_is_ongoing(NRF_QSPI_Type cons
|
||||
* @param[in] finalize True if the custom instruction long transfer is to be finalized.
|
||||
* False if the custom instruction long transfer is to be continued.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
bool finalize);
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
bool finalize);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_QSPI_HAS_XIPEN
|
||||
/**
|
||||
* @brief Function for enabling or disabling Execute in Place (XIP) operation.
|
||||
*
|
||||
* @note XIP can be enabled after reset. See Product Specification.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if XIP is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_set(NRF_QSPI_Type * p_reg, bool enable);
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_t task)
|
||||
#if NRF_QSPI_HAS_XIP_ENC
|
||||
/**
|
||||
* @brief Function for configuring the XIP encryption.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_cfg Pointer to encryption configuration structure.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_encryption_configure(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_encryption_t const * p_cfg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling or disabling the XIP encryption.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if XIP encryption is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_encryption_set(NRF_QSPI_Type * p_reg, bool enable);
|
||||
#endif
|
||||
|
||||
#if NRF_QSPI_HAS_DMA_ENC
|
||||
/**
|
||||
* @brief Function for configuring the EasyDMA encryption.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_cfg Pointer to encryption configuration structure.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qspi_dma_encryption_configure(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_encryption_t const * p_cfg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling or disabling the EasyDMA encryption.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if EasyDMA encryption is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_qspi_dma_encryption_set(NRF_QSPI_Type * p_reg, bool enable);
|
||||
#endif
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qspi_task_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_task_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_task_t task)
|
||||
{
|
||||
return ((uint32_t)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_event_clear(NRF_QSPI_Type * p_reg, nrf_qspi_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_qspi_event_clear(NRF_QSPI_Type * p_reg, nrf_qspi_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_qspi_event_check(NRF_QSPI_Type const * p_reg, nrf_qspi_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_qspi_event_check(NRF_QSPI_Type const * p_reg, nrf_qspi_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_qspi_event_address_get(NRF_QSPI_Type const * p_reg,
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_event_address_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_int_enable(NRF_QSPI_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qspi_int_enable(NRF_QSPI_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_int_disable(NRF_QSPI_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_qspi_int_disable(NRF_QSPI_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_qspi_int_enable_check(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_int_mask_t qspi_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_int_enable_check(NRF_QSPI_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & qspi_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_enable(NRF_QSPI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_qspi_enable(NRF_QSPI_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (QSPI_ENABLE_ENABLE_Enabled << QSPI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg)
|
||||
{
|
||||
// Workaround for nRF52840 anomaly 122: Current consumption is too high.
|
||||
*(volatile uint32_t *)0x40029054ul = 1ul;
|
||||
@@ -560,7 +671,7 @@ __STATIC_INLINE void nrf_qspi_disable(NRF_QSPI_Type * p_reg)
|
||||
p_reg->ENABLE = (QSPI_ENABLE_ENABLE_Disabled << QSPI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg, const nrf_qspi_pins_t * p_pins)
|
||||
NRF_STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg, nrf_qspi_pins_t const * p_pins)
|
||||
{
|
||||
p_reg->PSEL.SCK = NRF_QSPI_PIN_VAL(p_pins->sck_pin);
|
||||
p_reg->PSEL.CSN = NRF_QSPI_PIN_VAL(p_pins->csn_pin);
|
||||
@@ -570,14 +681,14 @@ __STATIC_INLINE void nrf_qspi_pins_set(NRF_QSPI_Type * p_reg, const nrf_qspi_pin
|
||||
p_reg->PSEL.IO3 = NRF_QSPI_PIN_VAL(p_pins->io3_pin);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_xip_offset_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t xip_offset)
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_offset_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t xip_offset)
|
||||
{
|
||||
p_reg->XIPOFFSET = xip_offset;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_prot_conf_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_prot_conf_t const * p_config)
|
||||
{
|
||||
uint32_t config = p_config->readoc;
|
||||
config |= ((uint32_t)p_config->writeoc) << QSPI_IFCONFIG0_WRITEOC_Pos;
|
||||
@@ -587,8 +698,8 @@ __STATIC_INLINE void nrf_qspi_ifconfig0_set(NRF_QSPI_Type * p_reg,
|
||||
p_reg->IFCONFIG0 = config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_phy_conf_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_phy_conf_t const * p_config)
|
||||
{
|
||||
// IFCONFIG1 mask for reserved fields in the register.
|
||||
uint32_t config = p_reg->IFCONFIG1 & 0x00FFFF00;
|
||||
@@ -600,8 +711,8 @@ __STATIC_INLINE void nrf_qspi_ifconfig1_set(NRF_QSPI_Type * p_reg,
|
||||
p_reg->IFCONFIG1 = config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_addrconfig_conf_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_addrconfig_conf_t const * p_config)
|
||||
{
|
||||
uint32_t config = p_config->opcode;
|
||||
config |= ((uint32_t)p_config->byte0) << QSPI_ADDRCONF_BYTE0_Pos;
|
||||
@@ -613,53 +724,53 @@ __STATIC_INLINE void nrf_qspi_addrconfig_set(NRF_QSPI_Type *
|
||||
p_reg->ADDRCONF = config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_write_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void const * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t dest_addr)
|
||||
NRF_STATIC_INLINE void nrf_qspi_write_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void const * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t dest_addr)
|
||||
{
|
||||
p_reg->WRITE.DST = dest_addr;
|
||||
p_reg->WRITE.SRC = (uint32_t) p_buffer;
|
||||
p_reg->WRITE.CNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_read_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t src_addr)
|
||||
NRF_STATIC_INLINE void nrf_qspi_read_buffer_set(NRF_QSPI_Type * p_reg,
|
||||
void * p_buffer,
|
||||
uint32_t length,
|
||||
uint32_t src_addr)
|
||||
{
|
||||
p_reg->READ.SRC = src_addr;
|
||||
p_reg->READ.DST = (uint32_t) p_buffer;
|
||||
p_reg->READ.CNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_erase_ptr_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t erase_addr,
|
||||
nrf_qspi_erase_len_t len)
|
||||
NRF_STATIC_INLINE void nrf_qspi_erase_ptr_set(NRF_QSPI_Type * p_reg,
|
||||
uint32_t erase_addr,
|
||||
nrf_qspi_erase_len_t len)
|
||||
{
|
||||
p_reg->ERASE.PTR = erase_addr;
|
||||
p_reg->ERASE.LEN = len;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_qspi_status_reg_get(NRF_QSPI_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_qspi_status_reg_get(NRF_QSPI_Type const * p_reg)
|
||||
{
|
||||
return p_reg->STATUS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_qspi_sreg_get(NRF_QSPI_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_qspi_sreg_get(NRF_QSPI_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(p_reg->STATUS & QSPI_STATUS_SREG_Msk) >> QSPI_STATUS_SREG_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_qspi_busy_check(NRF_QSPI_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_qspi_busy_check(NRF_QSPI_Type const * p_reg)
|
||||
{
|
||||
return ((p_reg->STATUS & QSPI_STATUS_READY_Msk) >>
|
||||
QSPI_STATUS_READY_Pos) == QSPI_STATUS_READY_BUSY;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void const * p_tx_data)
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void const * p_tx_data)
|
||||
{
|
||||
uint32_t reg = 0;
|
||||
uint8_t const *p_tx_data_8 = (uint8_t const *) p_tx_data;
|
||||
@@ -702,9 +813,9 @@ __STATIC_INLINE void nrf_qspi_cinstrdata_set(NRF_QSPI_Type * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void * p_rx_data)
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
void * p_rx_data)
|
||||
{
|
||||
uint8_t *p_rx_data_8 = (uint8_t *) p_rx_data;
|
||||
|
||||
@@ -744,8 +855,8 @@ __STATIC_INLINE void nrf_qspi_cinstrdata_get(NRF_QSPI_Type const * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_cinstr_conf_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_conf_t const * p_config)
|
||||
{
|
||||
p_reg->CINSTRCONF = (((uint32_t)p_config->opcode << QSPI_CINSTRCONF_OPCODE_Pos) |
|
||||
((uint32_t)p_config->length << QSPI_CINSTRCONF_LENGTH_Pos) |
|
||||
@@ -755,8 +866,8 @@ __STATIC_INLINE void nrf_qspi_cinstr_transfer_start(NRF_QSPI_Type *
|
||||
((uint32_t)p_config->wren << QSPI_CINSTRCONF_WREN_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
const nrf_qspi_cinstr_conf_t * p_config)
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_conf_t const * p_config)
|
||||
{
|
||||
p_reg->CINSTRCONF = (((uint32_t)p_config->opcode << QSPI_CINSTRCONF_OPCODE_Pos) |
|
||||
((uint32_t)p_config->length << QSPI_CINSTRCONF_LENGTH_Pos) |
|
||||
@@ -767,15 +878,15 @@ __STATIC_INLINE void nrf_qspi_cinstr_long_transfer_start(NRF_QSPI_Type *
|
||||
(QSPI_CINSTRCONF_LFEN_Msk));
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_qspi_cinstr_long_transfer_is_ongoing(NRF_QSPI_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_qspi_cinstr_long_transfer_is_ongoing(NRF_QSPI_Type const * p_reg)
|
||||
{
|
||||
return (bool)((p_reg->CINSTRCONF & (QSPI_CINSTRCONF_LFEN_Msk | QSPI_CINSTRCONF_LFSTOP_Msk))
|
||||
== QSPI_CINSTRCONF_LFEN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
bool finalize)
|
||||
NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_cinstr_len_t length,
|
||||
bool finalize)
|
||||
{
|
||||
uint32_t mask = (((uint32_t)length << QSPI_CINSTRCONF_LENGTH_Pos) | (QSPI_CINSTRCONF_LFEN_Msk));
|
||||
mask |= (finalize ? QSPI_CINSTRCONF_LFSTOP_Msk : 0);
|
||||
@@ -783,7 +894,56 @@ __STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type *
|
||||
p_reg->CINSTRCONF = mask;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_QSPI_HAS_XIPEN
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_set(NRF_QSPI_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->XIPEN = (enable ? QSPI_XIPEN_XIPEN_Enable << QSPI_XIPEN_XIPEN_Pos
|
||||
: QSPI_XIPEN_XIPEN_Disable << QSPI_XIPEN_XIPEN_Pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_QSPI_HAS_XIP_ENC
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_encryption_configure(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_encryption_t const * p_cfg)
|
||||
{
|
||||
p_reg->XIP_ENC.KEY0 = p_cfg->key[0];
|
||||
p_reg->XIP_ENC.KEY1 = p_cfg->key[1];
|
||||
p_reg->XIP_ENC.KEY2 = p_cfg->key[2];
|
||||
p_reg->XIP_ENC.KEY3 = p_cfg->key[3];
|
||||
p_reg->XIP_ENC.NONCE0 = p_cfg->nonce[0];
|
||||
p_reg->XIP_ENC.NONCE1 = p_cfg->nonce[1];
|
||||
p_reg->XIP_ENC.NONCE2 = p_cfg->nonce[2];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_qspi_xip_encryption_set(NRF_QSPI_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->XIP_ENC.ENABLE =
|
||||
(enable ? QSPI_XIP_ENC_ENABLE_ENABLE_Enabled << QSPI_XIP_ENC_ENABLE_ENABLE_Pos
|
||||
: QSPI_XIP_ENC_ENABLE_ENABLE_Disabled << QSPI_XIP_ENC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_QSPI_HAS_DMA_ENC
|
||||
NRF_STATIC_INLINE void nrf_qspi_dma_encryption_configure(NRF_QSPI_Type * p_reg,
|
||||
nrf_qspi_encryption_t const * p_cfg)
|
||||
{
|
||||
p_reg->DMA_ENC.KEY0 = p_cfg->key[0];
|
||||
p_reg->DMA_ENC.KEY1 = p_cfg->key[1];
|
||||
p_reg->DMA_ENC.KEY2 = p_cfg->key[2];
|
||||
p_reg->DMA_ENC.KEY3 = p_cfg->key[3];
|
||||
p_reg->DMA_ENC.NONCE0 = p_cfg->nonce[0];
|
||||
p_reg->DMA_ENC.NONCE1 = p_cfg->nonce[1];
|
||||
p_reg->DMA_ENC.NONCE2 = p_cfg->nonce[2];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_qspi_dma_encryption_set(NRF_QSPI_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->DMA_ENC.ENABLE =
|
||||
(enable ? QSPI_DMA_ENC_ENABLE_ENABLE_Enabled << QSPI_DMA_ENC_ENABLE_ENABLE_Pos
|
||||
: QSPI_DMA_ENC_ENABLE_ENABLE_Disabled << QSPI_DMA_ENC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,13 +45,97 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the REGULATORS peripheral.
|
||||
*/
|
||||
|
||||
#if defined(REGULATORS_MAINREGSTATUS_VREGH_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether MAINREGSTATUS register is present. */
|
||||
#define NRF_REGULATORS_HAS_MAINREGSTATUS 1
|
||||
#else
|
||||
#define NRF_REGULATORS_HAS_MAINREGSTATUS 0
|
||||
#endif
|
||||
|
||||
#if defined(REGULATORS_POFCON_POF_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether power failure comparator is present. */
|
||||
#define NRF_REGULATORS_HAS_POFCON 1
|
||||
#else
|
||||
#define NRF_REGULATORS_HAS_POFCON 0
|
||||
#endif
|
||||
|
||||
#if defined(REGULATORS_POFCON_THRESHOLDVDDH_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether power failure comparator for VDDH is present. */
|
||||
#define NRF_REGULATORS_HAS_POFCON_VDDH 1
|
||||
#else
|
||||
#define NRF_REGULATORS_HAS_POFCON_VDDH 0
|
||||
#endif
|
||||
|
||||
#if defined(REGULATORS_VREGH_DCDCEN_DCDCEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether high voltage regulator is present. */
|
||||
#define NRF_REGULATORS_HAS_DCDCEN_VDDH 1
|
||||
#else
|
||||
#define NRF_REGULATORS_HAS_DCDCEN_VDDH 0
|
||||
#endif
|
||||
|
||||
#if defined(REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Symbol indicating whether radio regulator is present. */
|
||||
#define NRF_REGULATORS_HAS_DCDCEN_RADIO 1
|
||||
#else
|
||||
#define NRF_REGULATORS_HAS_DCDCEN_RADIO 0
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_MAINREGSTATUS
|
||||
/** @brief Main regulator status. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_REGULATORS_MAINREGSTATUS_NORMAL = REGULATORS_MAINREGSTATUS_VREGH_Inactive, /**< Normal voltage mode. Voltage supplied on VDD and VDDH. */
|
||||
NRF_REGULATORS_MAINREGSTATUS_HIGH = REGULATORS_MAINREGSTATUS_VREGH_Active /**< High voltage mode. Voltage supplied on VDDH. */
|
||||
} nrf_regulators_mainregstatus_t;
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON
|
||||
/** @brief Power failure comparator thresholds. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_REGULATORS_POFTHR_V19 = REGULATORS_POFCON_THRESHOLD_V19, /**< Set threshold to 1.9 V. */
|
||||
NRF_REGULATORS_POFTHR_V20 = REGULATORS_POFCON_THRESHOLD_V20, /**< Set threshold to 2.0 V. */
|
||||
NRF_REGULATORS_POFTHR_V21 = REGULATORS_POFCON_THRESHOLD_V21, /**< Set threshold to 2.1 V. */
|
||||
NRF_REGULATORS_POFTHR_V22 = REGULATORS_POFCON_THRESHOLD_V22, /**< Set threshold to 2.2 V. */
|
||||
NRF_REGULATORS_POFTHR_V23 = REGULATORS_POFCON_THRESHOLD_V23, /**< Set threshold to 2.3 V. */
|
||||
NRF_REGULATORS_POFTHR_V24 = REGULATORS_POFCON_THRESHOLD_V24, /**< Set threshold to 2.4 V. */
|
||||
NRF_REGULATORS_POFTHR_V25 = REGULATORS_POFCON_THRESHOLD_V25, /**< Set threshold to 2.5 V. */
|
||||
NRF_REGULATORS_POFTHR_V26 = REGULATORS_POFCON_THRESHOLD_V26, /**< Set threshold to 2.6 V. */
|
||||
NRF_REGULATORS_POFTHR_V27 = REGULATORS_POFCON_THRESHOLD_V27, /**< Set threshold to 2.7 V. */
|
||||
NRF_REGULATORS_POFTHR_V28 = REGULATORS_POFCON_THRESHOLD_V28, /**< Set threshold to 2.8 V. */
|
||||
} nrf_regulators_pof_thr_t;
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
/** @brief Power failure comparator thresholds for VDDH. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_REGULATORS_POFTHRVDDH_V27 = REGULATORS_POFCON_THRESHOLDVDDH_V27, /**< Set threshold to 2.7 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V28 = REGULATORS_POFCON_THRESHOLDVDDH_V28, /**< Set threshold to 2.8 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V29 = REGULATORS_POFCON_THRESHOLDVDDH_V29, /**< Set threshold to 2.9 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V30 = REGULATORS_POFCON_THRESHOLDVDDH_V30, /**< Set threshold to 3.0 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V31 = REGULATORS_POFCON_THRESHOLDVDDH_V31, /**< Set threshold to 3.1 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V32 = REGULATORS_POFCON_THRESHOLDVDDH_V32, /**< Set threshold to 3.2 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V33 = REGULATORS_POFCON_THRESHOLDVDDH_V33, /**< Set threshold to 3.3 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V34 = REGULATORS_POFCON_THRESHOLDVDDH_V34, /**< Set threshold to 3.4 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V35 = REGULATORS_POFCON_THRESHOLDVDDH_V35, /**< Set threshold to 3.5 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V36 = REGULATORS_POFCON_THRESHOLDVDDH_V36, /**< Set threshold to 3.6 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V37 = REGULATORS_POFCON_THRESHOLDVDDH_V37, /**< Set threshold to 3.7 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V38 = REGULATORS_POFCON_THRESHOLDVDDH_V38, /**< Set threshold to 3.8 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V39 = REGULATORS_POFCON_THRESHOLDVDDH_V39, /**< Set threshold to 3.9 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V40 = REGULATORS_POFCON_THRESHOLDVDDH_V40, /**< Set threshold to 4.0 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V41 = REGULATORS_POFCON_THRESHOLDVDDH_V41, /**< Set threshold to 4.1 V. */
|
||||
NRF_REGULATORS_POFTHRVDDH_V42 = REGULATORS_POFCON_THRESHOLDVDDH_V42, /**< Set threshold to 4.2 V. */
|
||||
} nrf_regulators_pof_thrvddh_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for enabling or disabling DCDC converter.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable Set true to enable or false to disable DCDC converter.
|
||||
* @param[in] enable True if DCDC converter is to be enabled, false otherwise.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable);
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Function for putting CPU in system OFF mode.
|
||||
@@ -63,16 +147,100 @@ __STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_REGULATORS_HAS_MAINREGSTATUS
|
||||
/**
|
||||
* @brief Function for getting the main supply status.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The current main supply status.
|
||||
*/
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_mainregstatus_t nrf_regulators_mainregstatus_get(NRF_REGULATORS_Type const * p_reg);
|
||||
#endif
|
||||
|
||||
__STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable)
|
||||
#if NRF_REGULATORS_HAS_POFCON
|
||||
/**
|
||||
* @brief Function for setting the power failure comparator configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if power failure comparator is to be enabled, false otherwise.
|
||||
* @param[in] thr Voltage threshold value.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_regulators_pofcon_set(NRF_REGULATORS_Type * p_reg,
|
||||
bool enable,
|
||||
nrf_regulators_pof_thr_t thr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the power failure comparator configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[out] p_enabled Function sets this boolean variable to true
|
||||
* if power failure comparator is enabled.
|
||||
* The pointer can be NULL if we do not need this information.
|
||||
*
|
||||
* @return Threshold setting for power failure comparator.
|
||||
*/
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_pof_thr_t nrf_regulators_pofcon_get(NRF_REGULATORS_Type const * p_reg,
|
||||
bool * p_enabled);
|
||||
#endif // NRF_REGULATORS_HAS_POFCON
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
/**
|
||||
* @brief Function for setting the VDDH power failure comparator threshold.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] thr Threshold to be set.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_regulators_pofcon_vddh_set(NRF_REGULATORS_Type * p_reg,
|
||||
nrf_regulators_pof_thrvddh_t thr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the VDDH regulators failure comparator threshold.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Threshold setting for regulators failure comparator.
|
||||
*/
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_pof_thrvddh_t nrf_regulators_pofcon_vddh_get(NRF_REGULATORS_Type const * p_reg);
|
||||
#endif // NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
|
||||
#if NRF_REGULATORS_HAS_DCDCEN_VDDH
|
||||
/**
|
||||
* @brief Function for enabling or disabling the high voltage regulator.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if the high voltage regulator is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS_Type * p_reg, bool enable);
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_DCDCEN_RADIO
|
||||
/**
|
||||
* @brief Function for enabling or disabling the radio regulator.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] enable True if the radio regulator is to be enabled, false otherwise.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_radio_set(NRF_REGULATORS_Type * p_reg, bool enable);
|
||||
#endif
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable)
|
||||
{
|
||||
#if defined(REGULATORS_DCDCEN_DCDCEN_Msk)
|
||||
p_reg->DCDCEN = (enable ? REGULATORS_DCDCEN_DCDCEN_Msk : 0);
|
||||
#else
|
||||
p_reg->VREGMAIN.DCDCEN = (enable ? REGULATORS_VREGMAIN_DCDCEN_DCDCEN_Msk : 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
|
||||
{
|
||||
p_reg->SYSTEMOFF = REGULATORS_SYSTEMOFF_SYSTEMOFF_Msk;
|
||||
__DSB();
|
||||
@@ -84,7 +252,86 @@ __STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if NRF_REGULATORS_HAS_MAINREGSTATUS
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_mainregstatus_t nrf_regulators_mainregstatus_get(NRF_REGULATORS_Type const * p_reg)
|
||||
{
|
||||
return (nrf_regulators_mainregstatus_t)p_reg->MAINREGSTATUS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON
|
||||
NRF_STATIC_INLINE void nrf_regulators_pofcon_set(NRF_REGULATORS_Type * p_reg,
|
||||
bool enable,
|
||||
nrf_regulators_pof_thr_t thr)
|
||||
{
|
||||
#if NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
uint32_t pofcon = p_reg->POFCON;
|
||||
pofcon &= ~(REGULATORS_POFCON_THRESHOLD_Msk | REGULATORS_POFCON_POF_Msk);
|
||||
pofcon |=
|
||||
#else // NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
p_reg->POFCON =
|
||||
#endif
|
||||
(((uint32_t)thr) << REGULATORS_POFCON_THRESHOLD_Pos) |
|
||||
(enable ?
|
||||
(REGULATORS_POFCON_POF_Enabled << REGULATORS_POFCON_POF_Pos)
|
||||
:
|
||||
(REGULATORS_POFCON_POF_Disabled << REGULATORS_POFCON_POF_Pos));
|
||||
#if NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
p_reg->POFCON = pofcon;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_pof_thr_t nrf_regulators_pofcon_get(NRF_REGULATORS_Type const * p_reg,
|
||||
bool * p_enabled)
|
||||
{
|
||||
uint32_t pofcon = p_reg->POFCON;
|
||||
if (NULL != p_enabled)
|
||||
{
|
||||
(*p_enabled) = ((pofcon & REGULATORS_POFCON_POF_Msk) >> REGULATORS_POFCON_POF_Pos)
|
||||
== REGULATORS_POFCON_POF_Enabled;
|
||||
}
|
||||
return (nrf_regulators_pof_thr_t)((pofcon & REGULATORS_POFCON_THRESHOLD_Msk) >>
|
||||
REGULATORS_POFCON_THRESHOLD_Pos);
|
||||
}
|
||||
#endif // NRF_REGULATORS_HAS_POFCON
|
||||
|
||||
#if NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
NRF_STATIC_INLINE void nrf_regulators_pofcon_vddh_set(NRF_REGULATORS_Type * p_reg,
|
||||
nrf_regulators_pof_thrvddh_t thr)
|
||||
{
|
||||
uint32_t pofcon = p_reg->POFCON;
|
||||
pofcon &= ~REGULATORS_POFCON_THRESHOLDVDDH_Msk;
|
||||
pofcon |= (((uint32_t)thr) << REGULATORS_POFCON_THRESHOLDVDDH_Pos);
|
||||
p_reg->POFCON = pofcon;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE
|
||||
nrf_regulators_pof_thrvddh_t nrf_regulators_pofcon_vddh_get(NRF_REGULATORS_Type const * p_reg)
|
||||
{
|
||||
return (nrf_regulators_pof_thrvddh_t)((p_reg->POFCON & REGULATORS_POFCON_THRESHOLDVDDH_Msk) >>
|
||||
REGULATORS_POFCON_THRESHOLDVDDH_Pos);
|
||||
}
|
||||
#endif // NRF_REGULATORS_HAS_POFCON_VDDH
|
||||
|
||||
#if NRF_REGULATORS_HAS_DCDCEN_VDDH
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->VREGH.DCDCEN = (enable) ? REGULATORS_VREGH_DCDCEN_DCDCEN_Enabled :
|
||||
REGULATORS_VREGH_DCDCEN_DCDCEN_Disabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRF_REGULATORS_HAS_DCDCEN_RADIO
|
||||
NRF_STATIC_INLINE void nrf_regulators_dcdcen_radio_set(NRF_REGULATORS_Type * p_reg, bool enable)
|
||||
{
|
||||
p_reg->VREGRADIO.DCDCEN = (enable) ? REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Enabled :
|
||||
REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Disabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_RESET_H__
|
||||
#define NRF_RESET_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_reset_hal RESET HAL
|
||||
* @{
|
||||
* @ingroup nrf_reset
|
||||
* @brief Hardware access layer for managing the RESET peripheral.
|
||||
*/
|
||||
|
||||
/** @brief Reset reason bit masks. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RESET_RESETREAS_RESETPIN_MASK = RESET_RESETREAS_RESETPIN_Msk, ///< Bit mask of RESETPIN field.
|
||||
NRF_RESET_RESETREAS_DOG0_MASK = RESET_RESETREAS_DOG0_Msk, ///< Bit mask of DOG0 field.
|
||||
NRF_RESET_RESETREAS_CTRLAP_MASK = RESET_RESETREAS_CTRLAP_Msk, ///< Bit mask of CTRLAP field.
|
||||
NRF_RESET_RESETREAS_SREQ_MASK = RESET_RESETREAS_SREQ_Msk, ///< Bit mask of SREQ field.
|
||||
NRF_RESET_RESETREAS_LOCKUP_MASK = RESET_RESETREAS_LOCKUP_Msk, ///< Bit mask of LOCKUP field.
|
||||
NRF_RESET_RESETREAS_OFF_MASK = RESET_RESETREAS_OFF_Msk, ///< Bit mask of OFF field.
|
||||
NRF_RESET_RESETREAS_LPCOMP_MASK = RESET_RESETREAS_LPCOMP_Msk, ///< Bit mask of LPCOMP field.
|
||||
NRF_RESET_RESETREAS_DIF_MASK = RESET_RESETREAS_DIF_Msk, ///< Bit mask of DIF field.
|
||||
NRF_RESET_RESETREAS_LSREQ_MASK = RESET_RESETREAS_LSREQ_Msk, ///< Bit mask of LSREQ field.
|
||||
NRF_RESET_RESETREAS_LLOCKUP_MASK = RESET_RESETREAS_LLOCKUP_Msk, ///< Bit mask of LLOCKUP field.
|
||||
NRF_RESET_RESETREAS_LDOG_MASK = RESET_RESETREAS_LDOG_Msk, ///< Bit mask of LDOG field.
|
||||
NRF_RESET_RESETREAS_MFORCEOFF_MASK = RESET_RESETREAS_MFORCEOFF_Msk, ///< Bit mask of MFORCEOFF field.
|
||||
NRF_RESET_RESETREAS_NFC_MASK = RESET_RESETREAS_NFC_Msk, ///< Bit mask of NFC field.
|
||||
NRF_RESET_RESETREAS_DOG1_MASK = RESET_RESETREAS_DOG1_Msk, ///< Bit mask of DOG1 field.
|
||||
NRF_RESET_RESETREAS_VBUS_MASK = RESET_RESETREAS_VBUS_Msk, ///< Bit mask of VBUS field.
|
||||
NRF_RESET_RESETREAS_LCTRLAP_MASK = RESET_RESETREAS_LCTRLAP_Msk, ///< Bit mask of LCTRLAP field.
|
||||
} nrf_reset_resetreas_mask_t;
|
||||
|
||||
/**
|
||||
* @brief Function for getting the reset reason bitmask.
|
||||
*
|
||||
* This function returns the reset reason bitmask.
|
||||
* Unless cleared, the RESETREAS register is cumulative.
|
||||
* If none of the reset sources is flagged, the chip was reset from the on-chip reset generator.
|
||||
* This indicates a power-on-reset or a brown out reset.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The mask of reset reasons constructed with @ref nrf_reset_resetreas_mask_t.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_reset_resetreas_get(NRF_RESET_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the selected reset reason field.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask The mask constructed from @ref nrf_reset_resetreas_mask_t enumerator values.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_reset_resetreas_clear(NRF_RESET_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the force off signal for the Network core.
|
||||
*
|
||||
* A force off will reset the Network core and switch off its power and clocks.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] hold True if the force off signal is to be held.
|
||||
* False if the force off signal is to be released.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_reset_network_force_off(NRF_RESET_Type * p_reg, bool hold);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_reset_resetreas_get(NRF_RESET_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RESETREAS;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_reset_resetreas_clear(NRF_RESET_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->RESETREAS = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_reset_network_force_off(NRF_RESET_Type * p_reg, bool hold)
|
||||
{
|
||||
p_reg->NETWORK.FORCEOFF = (hold ? RESET_NETWORK_FORCEOFF_FORCEOFF_Hold :
|
||||
RESET_NETWORK_FORCEOFF_FORCEOFF_Release);
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_RESET_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -74,173 +74,196 @@ typedef enum
|
||||
/**
|
||||
* @brief Function for enabling interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_int_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rng_int_enable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
*
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_int_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the specified interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] mask Interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is not enabled.
|
||||
* @retval false The interrupt is enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_rng_int_get(nrf_rng_int_mask_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified task.
|
||||
*
|
||||
* This function can be used by the PPI module.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_task The specified task.
|
||||
*
|
||||
* @return Address of the specified task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_rng_task_address_get(nrf_rng_task_t rng_task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_task_address_get(NRF_RNG_Type const * p_reg,
|
||||
nrf_rng_task_t rng_task);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the specified task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_task The specified Task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_task_trigger(nrf_rng_task_t rng_task);
|
||||
NRF_STATIC_INLINE void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting address of the specified event.
|
||||
*
|
||||
* This function can be used by the PPI module.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_event The specified event.
|
||||
*
|
||||
* @return Address of the specified event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_rng_event_address_get(nrf_rng_event_t rng_event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_event_address_get(NRF_RNG_Type const * p_reg,
|
||||
nrf_rng_event_t rng_event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_event The specified event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_event_clear(nrf_rng_event_t rng_event);
|
||||
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of the specified event.
|
||||
* @brief Function for retrieving the state of the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_event The specified event.
|
||||
*
|
||||
* @retval true The event is not set.
|
||||
* @retval false The event is set.
|
||||
* @retval true The event is set.
|
||||
* @retval false The event is not set.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_rng_event_get(nrf_rng_event_t rng_event);
|
||||
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting shortcuts.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_shorts_enable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_enable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing shortcuts.
|
||||
*
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rng_shorts_disable(uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_disable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the previously generated random value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Previously generated random value.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_rng_random_value_get(void);
|
||||
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg);
|
||||
|
||||
/** @brief Function for enabling digital error correction. */
|
||||
__STATIC_INLINE void nrf_rng_error_correction_enable(void);
|
||||
/**
|
||||
* @brief Function for enabling digital error correction.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg);
|
||||
|
||||
/** @brief Function for disabling digital error correction. */
|
||||
__STATIC_INLINE void nrf_rng_error_correction_disable(void);
|
||||
/**
|
||||
* @brief Function for disabling digital error correction.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_rng_int_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rng_int_enable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG->INTENSET = mask;
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_int_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG->INTENCLR = mask;
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_rng_int_get(nrf_rng_int_mask_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(NRF_RNG->INTENCLR & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_rng_task_address_get(nrf_rng_task_t rng_task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_task_address_get(NRF_RNG_Type const * p_reg,
|
||||
nrf_rng_task_t rng_task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)rng_task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_task_trigger(nrf_rng_task_t rng_task)
|
||||
NRF_STATIC_INLINE void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_task)) = 0x1UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_rng_event_address_get(nrf_rng_event_t rng_event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_event_address_get(NRF_RNG_Type const * p_reg,
|
||||
nrf_rng_event_t rng_event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)rng_event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_event_clear(nrf_rng_event_t rng_event)
|
||||
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_event)) = 0x0UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_rng_event_get(nrf_rng_event_t rng_event)
|
||||
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event)
|
||||
{
|
||||
return (bool) * ((volatile uint32_t *)((uint8_t *)NRF_RNG + (uint32_t)rng_event));
|
||||
return (bool) * ((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_shorts_enable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_enable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG->SHORTS |= mask;
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_shorts_disable(uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_disable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_RNG->SHORTS &= ~mask;
|
||||
p_reg->SHORTS &= ~mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_rng_random_value_get(void)
|
||||
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(NRF_RNG->VALUE & RNG_VALUE_VALUE_Msk);
|
||||
return (uint8_t)(p_reg->VALUE & RNG_VALUE_VALUE_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_error_correction_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg)
|
||||
{
|
||||
NRF_RNG->CONFIG |= RNG_CONFIG_DERCEN_Msk;
|
||||
p_reg->CONFIG |= RNG_CONFIG_DERCEN_Msk;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rng_error_correction_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg)
|
||||
{
|
||||
NRF_RNG->CONFIG &= ~RNG_CONFIG_DERCEN_Msk;
|
||||
p_reg->CONFIG &= ~RNG_CONFIG_DERCEN_Msk;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -103,7 +103,7 @@ typedef enum
|
||||
* @param[in] ch Channel.
|
||||
* @param[in] cc_val Compare value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val);
|
||||
NRF_STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the compare value for a channel.
|
||||
@@ -113,7 +113,7 @@ __STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t
|
||||
*
|
||||
* @return COMPARE[ch] value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_reg, uint32_t ch);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts.
|
||||
@@ -121,7 +121,7 @@ __STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_reg, uint32_t ch);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupt mask to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
@@ -129,26 +129,17 @@ __STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupt mask to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if interrupts are enabled.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupt flags to be checked.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask with enabled interrupts.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the status of currently enabled interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Value in INTEN register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -159,9 +150,9 @@ __STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_reg);
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -170,8 +161,8 @@ __STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -181,9 +172,9 @@ __STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -192,19 +183,20 @@ __STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for checking if an event is pending.
|
||||
* @brief Function for retrieving the state of the RTC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Address of the event.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @return Mask of pending events.
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing an event.
|
||||
@@ -212,7 +204,7 @@ __STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_reg, nrf_rtc_eve
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a counter value.
|
||||
@@ -221,7 +213,7 @@ __STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t e
|
||||
*
|
||||
* @return Counter value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a prescaler value.
|
||||
@@ -229,7 +221,16 @@ __STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] val Value to set the prescaler to.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
|
||||
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Function for getting a prescaler value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Prescaler value.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_prescaler_get(NRF_RTC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of an event.
|
||||
@@ -239,7 +240,8 @@ __STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
|
||||
*
|
||||
* @return Address of the requested event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a task.
|
||||
@@ -249,7 +251,8 @@ __STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_reg, nrf_rtc
|
||||
*
|
||||
* @return Address of the requested task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_reg, nrf_rtc_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a task.
|
||||
@@ -257,7 +260,7 @@ __STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_reg, nrf_rtc_
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Requested task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling events.
|
||||
@@ -265,7 +268,7 @@ __STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t t
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of event flags to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an event.
|
||||
@@ -273,7 +276,7 @@ __STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Requested event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t event);
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the COMPARE event associated with the specified compare channel.
|
||||
@@ -282,77 +285,71 @@ __STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t event)
|
||||
*
|
||||
* @return Requested COMPARE event.
|
||||
*/
|
||||
__STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index);
|
||||
NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val)
|
||||
NRF_STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val)
|
||||
{
|
||||
p_reg->CC[ch] = cc_val;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_reg, uint32_t ch)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch)
|
||||
{
|
||||
return p_reg->CC[ch];
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (p_reg->INTENSET & mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_reg)
|
||||
{
|
||||
return p_reg->INTENSET;
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | RTC_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | RTC_PUBLISH_TICK_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type * p_reg,
|
||||
nrf_rtc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event)
|
||||
{
|
||||
return *(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -361,52 +358,55 @@ __STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t e
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->COUNTER;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
|
||||
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
|
||||
{
|
||||
NRFX_ASSERT(val <= (RTC_PRESCALER_PRESCALER_Msk >> RTC_PRESCALER_PRESCALER_Pos));
|
||||
p_reg->PRESCALER = val;
|
||||
}
|
||||
__STATIC_INLINE uint32_t rtc_prescaler_get(NRF_RTC_Type * p_reg)
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_prescaler_get(NRF_RTC_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PRESCALER;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_event_t event)
|
||||
{
|
||||
return (uint32_t)p_reg + event;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_reg, nrf_rtc_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_task_t task)
|
||||
{
|
||||
return (uint32_t)p_reg + task;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task)
|
||||
{
|
||||
*(__IO uint32_t *)((uint32_t)p_reg + task) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->EVTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->EVTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index)
|
||||
NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index)
|
||||
{
|
||||
return (nrf_rtc_event_t)NRFX_OFFSETOF(NRF_RTC_Type, EVENTS_COMPARE[index]);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,10 +45,6 @@ extern "C" {
|
||||
* @brief Hardware access layer for managing the SAADC peripheral.
|
||||
*/
|
||||
|
||||
/** @brief Number of available SAADC channels. */
|
||||
#define NRF_SAADC_CHANNEL_COUNT 8
|
||||
|
||||
|
||||
/** @brief Resolution of the analog-to-digital converter. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -70,7 +66,10 @@ typedef enum
|
||||
NRF_SAADC_INPUT_AIN5 = SAADC_CH_PSELP_PSELP_AnalogInput5, ///< Analog input 5 (AIN5).
|
||||
NRF_SAADC_INPUT_AIN6 = SAADC_CH_PSELP_PSELP_AnalogInput6, ///< Analog input 6 (AIN6).
|
||||
NRF_SAADC_INPUT_AIN7 = SAADC_CH_PSELP_PSELP_AnalogInput7, ///< Analog input 7 (AIN7).
|
||||
NRF_SAADC_INPUT_VDD = SAADC_CH_PSELP_PSELP_VDD ///< VDD as input.
|
||||
NRF_SAADC_INPUT_VDD = SAADC_CH_PSELP_PSELP_VDD, ///< VDD as input.
|
||||
#if defined(SAADC_CH_PSELP_PSELP_VDDHDIV5) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_SAADC_INPUT_VDDHDIV5 = SAADC_CH_PSELP_PSELP_VDDHDIV5 ///< VDDH/5 as input.
|
||||
#endif
|
||||
} nrf_saadc_input_t;
|
||||
|
||||
/** @brief Analog-to-digital converter oversampling mode. */
|
||||
@@ -234,103 +233,107 @@ typedef struct
|
||||
nrf_saadc_acqtime_t acq_time; ///< Acquisition time.
|
||||
nrf_saadc_mode_t mode; ///< SAADC mode. Single-ended or differential.
|
||||
nrf_saadc_burst_t burst; ///< Burst mode configuration.
|
||||
nrf_saadc_input_t pin_p; ///< Input positive pin selection.
|
||||
nrf_saadc_input_t pin_n; ///< Input negative pin selection.
|
||||
} nrf_saadc_channel_config_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the specified SAADC task.
|
||||
*
|
||||
* @param[in] task SAADC task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task SAADC task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_task_trigger(nrf_saadc_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_saadc_task_trigger(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SAADC task register.
|
||||
*
|
||||
* @param[in] task SAADC task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task SAADC task.
|
||||
*
|
||||
* @return Address of the specified SAADC task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_saadc_task_address_get(nrf_saadc_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_task_address_get(NRF_SAADC_Type const * p_reg,
|
||||
nrf_saadc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the UARTE event.
|
||||
* @brief Function for retrieving the state of the SAADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_saadc_event_check(nrf_saadc_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_saadc_event_check(NRF_SAADC_Type const * p_reg,
|
||||
nrf_saadc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specific SAADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event SAADC event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_event_clear(nrf_saadc_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_saadc_event_clear(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SAADC event register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event SAADC event.
|
||||
*
|
||||
* @return Address of the specified SAADC event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_saadc_event_address_get(nrf_saadc_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_event_address_get(NRF_SAADC_Type const * p_reg,
|
||||
nrf_saadc_event_t event);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for setting the subscribe configuration for a given
|
||||
* SAADC task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_subscribe_set(nrf_saadc_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_saadc_subscribe_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
* SAADC task.
|
||||
*
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_subscribe_clear(nrf_saadc_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_saadc_subscribe_clear(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
* SAADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_publish_set(nrf_saadc_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_saadc_publish_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
* SAADC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_publish_clear(nrf_saadc_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_saadc_publish_clear(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the SAADC limit event register,
|
||||
* as specified by the channel and the limit type.
|
||||
*
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] limit_type Low limit or high limit.
|
||||
*
|
||||
* @return Address of the specified SAADC limit event.
|
||||
*/
|
||||
__STATIC_INLINE volatile uint32_t * nrf_saadc_event_limit_address_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the SAADC channel monitoring limit events.
|
||||
*
|
||||
@@ -339,61 +342,79 @@ __STATIC_INLINE volatile uint32_t * nrf_saadc_event_limit_address_get(uint8_t
|
||||
*
|
||||
* @return The SAADC channel monitoring limit event.
|
||||
*/
|
||||
__STATIC_INLINE nrf_saadc_event_t nrf_saadc_event_limit_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type);
|
||||
NRF_STATIC_INLINE nrf_saadc_event_t nrf_saadc_limit_event_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the input pins for the specified SAADC channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] pselp Positive input.
|
||||
* @param[in] pseln Negative input. Set to NRF_SAADC_INPUT_DISABLED in single ended mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_channel_input_set(uint8_t channel,
|
||||
nrf_saadc_input_t pselp,
|
||||
nrf_saadc_input_t pseln);
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_input_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_input_t pselp,
|
||||
nrf_saadc_input_t pseln);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the positive input pin for the specified SAADC channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] pselp Positive input.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_channel_pos_input_set(uint8_t channel,
|
||||
nrf_saadc_input_t pselp);
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_pos_input_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_input_t pselp);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SAADC channel monitoring limits.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] low Low limit.
|
||||
* @param[in] high High limit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_channel_limits_set(uint8_t channel, int16_t low, int16_t high);
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_limits_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
int16_t low,
|
||||
int16_t high);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the configuration of SAADC interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts configuration to be set.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_set(NRF_SAADC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified SAADC interrupts.
|
||||
*
|
||||
* @param[in] saadc_int_mask Interrupt(s) to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_int_enable(uint32_t saadc_int_mask);
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_enable(NRF_SAADC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of specified SAADC interrupts.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] saadc_int_mask Interrupt(s) to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true All specified interrupts are enabled.
|
||||
* @retval false At least one of the given interrupts is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_saadc_int_enable_check(uint32_t saadc_int_mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_int_enable_check(NRF_SAADC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param saadc_int_mask Interrupt(s) to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_int_disable(uint32_t saadc_int_mask);
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_disable(NRF_SAADC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for generating masks for SAADC channel limit interrupts.
|
||||
@@ -403,89 +424,131 @@ __STATIC_INLINE void nrf_saadc_int_disable(uint32_t saadc_int_mask);
|
||||
*
|
||||
* @return Interrupt mask.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_saadc_limit_int_get(uint8_t channel, nrf_saadc_limit_t limit_type);
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_limit_int_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type);
|
||||
|
||||
/**
|
||||
* @brief Function for checking whether the SAADC is busy.
|
||||
*
|
||||
* This function checks whether the analog-to-digital converter is busy with a conversion.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The SAADC is busy.
|
||||
* @retval false The SAADC is not busy.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_saadc_busy_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_saadc_busy_check(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the SAADC.
|
||||
*
|
||||
* The analog-to-digital converter must be enabled before use.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_enable(void);
|
||||
NRF_STATIC_INLINE void nrf_saadc_enable(NRF_SAADC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the SAADC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_disable(void);
|
||||
NRF_STATIC_INLINE void nrf_saadc_disable(NRF_SAADC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the SAADC is enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The SAADC is enabled.
|
||||
* @retval false The SAADC is not enabled.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_saadc_enable_check(void);
|
||||
NRF_STATIC_INLINE bool nrf_saadc_enable_check(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the SAADC result buffer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the result buffer.
|
||||
* @param[in] size Size of the buffer (in 16-bit samples).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_buffer_init(nrf_saadc_value_t * p_buffer,
|
||||
uint32_t size);
|
||||
NRF_STATIC_INLINE void nrf_saadc_buffer_init(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_value_t * p_buffer,
|
||||
uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SAADC result buffer pointer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the result buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_buffer_pointer_set(nrf_saadc_value_t * p_buffer);
|
||||
NRF_STATIC_INLINE void nrf_saadc_buffer_pointer_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_value_t * p_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the SAADC result buffer pointer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to the result buffer.
|
||||
*/
|
||||
__STATIC_INLINE nrf_saadc_value_t * nrf_saadc_buffer_pointer_get(void);
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t * nrf_saadc_buffer_pointer_get(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of samples written to the result
|
||||
* buffer since the previous START task.
|
||||
*
|
||||
* @returns Number of 16-bit samples written to the buffer.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Number of 16-bit samples written to the buffer.
|
||||
*/
|
||||
__STATIC_INLINE uint16_t nrf_saadc_amount_get(void);
|
||||
NRF_STATIC_INLINE uint16_t nrf_saadc_amount_get(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SAADC sample resolution.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] resolution Bit resolution.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_resolution_set(nrf_saadc_resolution_t resolution);
|
||||
NRF_STATIC_INLINE void nrf_saadc_resolution_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_resolution_t resolution);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the SAADC sample resolution.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Sample resolution.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_saadc_resolution_t nrf_saadc_resolution_get(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the oversampling feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] oversample Oversampling mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_oversample_set(nrf_saadc_oversample_t oversample);
|
||||
NRF_STATIC_INLINE void nrf_saadc_oversample_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_oversample_t oversample);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the oversampling feature configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Oversampling configuration.
|
||||
*/
|
||||
__STATIC_INLINE nrf_saadc_oversample_t nrf_saadc_oversample_get(void);
|
||||
NRF_STATIC_INLINE nrf_saadc_oversample_t nrf_saadc_oversample_get(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the sample count needed for one averaged result for a given
|
||||
* oversampling configuration.
|
||||
*
|
||||
* @param[in] oversample Oversampling configuration.
|
||||
*
|
||||
* @return Sample count.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_oversample_sample_count_get(nrf_saadc_oversample_t oversample);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the continuous sampling.
|
||||
@@ -496,244 +559,299 @@ __STATIC_INLINE nrf_saadc_oversample_t nrf_saadc_oversample_get(void);
|
||||
*
|
||||
* @note The internal timer can only be used when a single input channel is enabled.
|
||||
*
|
||||
* @param[in] cc Capture and compare value. Sample rate is 16 MHz/cc. Valid CC range is
|
||||
* from 80 to 2047.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc Capture and compare value. Sample rate is 16 MHz/cc.
|
||||
* Valid @c CC range is from 80 to 2047.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_continuous_mode_enable(uint16_t cc);
|
||||
NRF_STATIC_INLINE void nrf_saadc_continuous_mode_enable(NRF_SAADC_Type * p_reg,
|
||||
uint16_t cc);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the continuous sampling is enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The continuous sampling is enabled.
|
||||
* @retval false The continuous sampling is disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_saadc_continuous_mode_enable_check(NRF_SAADC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the continuous sampling.
|
||||
*
|
||||
* New samples can still be acquired by manually triggering the SAMPLE task or by PPI.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_continuous_mode_disable(void);
|
||||
NRF_STATIC_INLINE void nrf_saadc_continuous_mode_disable(NRF_SAADC_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the SAADC channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] config Pointer to the channel configuration structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_channel_init(uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * const config);
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_init(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * config);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the burst mode for the specified channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] channel Channel number.
|
||||
* @param[in] burst Burst mode setting.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_saadc_burst_set(uint8_t channel,
|
||||
nrf_saadc_burst_t burst);
|
||||
NRF_STATIC_INLINE void nrf_saadc_burst_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_burst_t burst);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
/**
|
||||
* @brief Function for getting the minimum value of the conversion result.
|
||||
*
|
||||
* The minimum value of the conversion result depends on the configured resolution.
|
||||
*
|
||||
* @param[in] resolution Bit resolution.
|
||||
*
|
||||
* @return Minimum value of the conversion result.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t nrf_saadc_value_min_get(nrf_saadc_resolution_t resolution);
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_task_trigger(nrf_saadc_task_t task)
|
||||
/**
|
||||
* @brief Function for getting the maximum value of the conversion result.
|
||||
*
|
||||
* The maximum value of the conversion result depends on the configured resolution.
|
||||
*
|
||||
* @param[in] resolution Bit resolution.
|
||||
*
|
||||
* @return Maximum value of the conversion result.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t nrf_saadc_value_max_get(nrf_saadc_resolution_t resolution);
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_saadc_task_trigger(NRF_SAADC_Type * p_reg, nrf_saadc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_SAADC + (uint32_t)task)) = 0x1UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_saadc_task_address_get(nrf_saadc_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_task_address_get(NRF_SAADC_Type const * p_reg,
|
||||
nrf_saadc_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)NRF_SAADC + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_saadc_event_check(nrf_saadc_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_saadc_event_check(NRF_SAADC_Type const * p_reg, nrf_saadc_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)NRF_SAADC + (uint32_t)event);
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_event_clear(nrf_saadc_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_saadc_event_clear(NRF_SAADC_Type * p_reg, nrf_saadc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)NRF_SAADC + (uint32_t)event)) = 0x0UL;
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_SAADC + (uint32_t)event));
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_saadc_event_address_get(nrf_saadc_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_event_address_get(NRF_SAADC_Type const * p_reg,
|
||||
nrf_saadc_event_t event)
|
||||
{
|
||||
return (uint32_t )((uint8_t *)NRF_SAADC + (uint32_t)event);
|
||||
return (uint32_t )((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_saadc_subscribe_set(nrf_saadc_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_saadc_subscribe_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_SAADC + (uint32_t) task + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | SAADC_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_subscribe_clear(nrf_saadc_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_saadc_subscribe_clear(NRF_SAADC_Type * p_reg, nrf_saadc_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_SAADC + (uint32_t) task + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_publish_set(nrf_saadc_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_saadc_publish_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_SAADC + (uint32_t) event + 0x80uL)) =
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | SAADC_PUBLISH_STARTED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_publish_clear(nrf_saadc_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_saadc_publish_clear(NRF_SAADC_Type * p_reg, nrf_saadc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) NRF_SAADC + (uint32_t) event + 0x80uL)) = 0;
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE volatile uint32_t * nrf_saadc_event_limit_address_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type)
|
||||
{
|
||||
NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
|
||||
if (limit_type == NRF_SAADC_LIMIT_HIGH)
|
||||
{
|
||||
return &NRF_SAADC->EVENTS_CH[channel].LIMITH;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &NRF_SAADC->EVENTS_CH[channel].LIMITL;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_saadc_event_t nrf_saadc_event_limit_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type)
|
||||
NRF_STATIC_INLINE nrf_saadc_event_t nrf_saadc_limit_event_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type)
|
||||
{
|
||||
if (limit_type == NRF_SAADC_LIMIT_HIGH)
|
||||
{
|
||||
return (nrf_saadc_event_t)( (uint32_t) NRF_SAADC_EVENT_CH0_LIMITH +
|
||||
(uint32_t) (NRF_SAADC_EVENT_CH1_LIMITH - NRF_SAADC_EVENT_CH0_LIMITH)
|
||||
* (uint32_t) channel );
|
||||
return (nrf_saadc_event_t)NRFX_OFFSETOF(NRF_SAADC_Type, EVENTS_CH[channel].LIMITH);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (nrf_saadc_event_t)( (uint32_t) NRF_SAADC_EVENT_CH0_LIMITL +
|
||||
(uint32_t) (NRF_SAADC_EVENT_CH1_LIMITL - NRF_SAADC_EVENT_CH0_LIMITL)
|
||||
* (uint32_t) channel );
|
||||
return (nrf_saadc_event_t)NRFX_OFFSETOF(NRF_SAADC_Type, EVENTS_CH[channel].LIMITL);
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_channel_input_set(uint8_t channel,
|
||||
nrf_saadc_input_t pselp,
|
||||
nrf_saadc_input_t pseln)
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_input_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_input_t pselp,
|
||||
nrf_saadc_input_t pseln)
|
||||
{
|
||||
NRF_SAADC->CH[channel].PSELN = pseln;
|
||||
NRF_SAADC->CH[channel].PSELP = pselp;
|
||||
p_reg->CH[channel].PSELN = pseln;
|
||||
p_reg->CH[channel].PSELP = pselp;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_channel_pos_input_set(uint8_t channel,
|
||||
nrf_saadc_input_t pselp)
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_pos_input_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_input_t pselp)
|
||||
{
|
||||
NRF_SAADC->CH[channel].PSELP = pselp;
|
||||
p_reg->CH[channel].PSELP = pselp;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_channel_limits_set(uint8_t channel, int16_t low, int16_t high)
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_limits_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
int16_t low,
|
||||
int16_t high)
|
||||
{
|
||||
NRF_SAADC->CH[channel].LIMIT = (
|
||||
p_reg->CH[channel].LIMIT = (
|
||||
(((uint32_t) low << SAADC_CH_LIMIT_LOW_Pos) & SAADC_CH_LIMIT_LOW_Msk)
|
||||
| (((uint32_t) high << SAADC_CH_LIMIT_HIGH_Pos) & SAADC_CH_LIMIT_HIGH_Msk));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_int_enable(uint32_t saadc_int_mask)
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_set(NRF_SAADC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_SAADC->INTENSET = saadc_int_mask;
|
||||
p_reg->INTEN = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_saadc_int_enable_check(uint32_t saadc_int_mask)
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_enable(NRF_SAADC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(NRF_SAADC->INTENSET & saadc_int_mask);
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_int_disable(uint32_t saadc_int_mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_int_enable_check(NRF_SAADC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
NRF_SAADC->INTENCLR = saadc_int_mask;
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_saadc_limit_int_get(uint8_t channel, nrf_saadc_limit_t limit_type)
|
||||
NRF_STATIC_INLINE void nrf_saadc_int_disable(NRF_SAADC_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_limit_int_get(uint8_t channel,
|
||||
nrf_saadc_limit_t limit_type)
|
||||
{
|
||||
NRFX_ASSERT(channel < SAADC_CH_NUM);
|
||||
uint32_t mask = (limit_type == NRF_SAADC_LIMIT_LOW) ?
|
||||
NRF_SAADC_INT_CH0LIMITL : NRF_SAADC_INT_CH0LIMITH;
|
||||
return mask << (channel * 2);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_saadc_busy_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_saadc_busy_check(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
//return ((NRF_SAADC->STATUS & SAADC_STATUS_STATUS_Msk) == SAADC_STATUS_STATUS_Msk);
|
||||
//simplified for performance
|
||||
return NRF_SAADC->STATUS;
|
||||
return (p_reg->STATUS == (SAADC_STATUS_STATUS_Busy << SAADC_STATUS_STATUS_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_enable(void)
|
||||
NRF_STATIC_INLINE void nrf_saadc_enable(NRF_SAADC_Type * p_reg)
|
||||
{
|
||||
NRF_SAADC->ENABLE = (SAADC_ENABLE_ENABLE_Enabled << SAADC_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (SAADC_ENABLE_ENABLE_Enabled << SAADC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_disable(void)
|
||||
NRF_STATIC_INLINE void nrf_saadc_disable(NRF_SAADC_Type * p_reg)
|
||||
{
|
||||
NRF_SAADC->ENABLE = (SAADC_ENABLE_ENABLE_Disabled << SAADC_ENABLE_ENABLE_Pos);
|
||||
p_reg->ENABLE = (SAADC_ENABLE_ENABLE_Disabled << SAADC_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_saadc_enable_check(void)
|
||||
NRF_STATIC_INLINE bool nrf_saadc_enable_check(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
//simplified for performance
|
||||
return NRF_SAADC->ENABLE;
|
||||
return (p_reg->ENABLE == (SAADC_ENABLE_ENABLE_Enabled << SAADC_ENABLE_ENABLE_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_buffer_init(nrf_saadc_value_t * p_buffer,
|
||||
uint32_t size)
|
||||
NRF_STATIC_INLINE void nrf_saadc_buffer_init(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_value_t * p_buffer,
|
||||
uint32_t size)
|
||||
{
|
||||
NRF_SAADC->RESULT.PTR = (uint32_t)p_buffer;
|
||||
NRF_SAADC->RESULT.MAXCNT = size;
|
||||
p_reg->RESULT.PTR = (uint32_t)p_buffer;
|
||||
p_reg->RESULT.MAXCNT = size;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_buffer_pointer_set(nrf_saadc_value_t * p_buffer)
|
||||
NRF_STATIC_INLINE void nrf_saadc_buffer_pointer_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_value_t * p_buffer)
|
||||
{
|
||||
NRF_SAADC->RESULT.PTR = (uint32_t)p_buffer;
|
||||
p_reg->RESULT.PTR = (uint32_t)p_buffer;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_saadc_value_t * nrf_saadc_buffer_pointer_get(void)
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t * nrf_saadc_buffer_pointer_get(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
return (nrf_saadc_value_t *)NRF_SAADC->RESULT.PTR;
|
||||
return (nrf_saadc_value_t *)p_reg->RESULT.PTR;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint16_t nrf_saadc_amount_get(void)
|
||||
NRF_STATIC_INLINE uint16_t nrf_saadc_amount_get(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
return NRF_SAADC->RESULT.AMOUNT;
|
||||
return p_reg->RESULT.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_resolution_set(nrf_saadc_resolution_t resolution)
|
||||
NRF_STATIC_INLINE void nrf_saadc_resolution_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_resolution_t resolution)
|
||||
{
|
||||
NRF_SAADC->RESOLUTION = resolution;
|
||||
p_reg->RESOLUTION = resolution;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_oversample_set(nrf_saadc_oversample_t oversample)
|
||||
NRF_STATIC_INLINE nrf_saadc_resolution_t nrf_saadc_resolution_get(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
NRF_SAADC->OVERSAMPLE = oversample;
|
||||
return (nrf_saadc_resolution_t)p_reg->RESOLUTION;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_saadc_oversample_t nrf_saadc_oversample_get(void)
|
||||
NRF_STATIC_INLINE void nrf_saadc_oversample_set(NRF_SAADC_Type * p_reg,
|
||||
nrf_saadc_oversample_t oversample)
|
||||
{
|
||||
return (nrf_saadc_oversample_t)NRF_SAADC->OVERSAMPLE;
|
||||
p_reg->OVERSAMPLE = oversample;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_continuous_mode_enable(uint16_t cc)
|
||||
NRF_STATIC_INLINE nrf_saadc_oversample_t nrf_saadc_oversample_get(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
return (nrf_saadc_oversample_t)p_reg->OVERSAMPLE;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_saadc_oversample_sample_count_get(nrf_saadc_oversample_t oversample)
|
||||
{
|
||||
return (1 << (uint32_t)oversample);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_saadc_continuous_mode_enable(NRF_SAADC_Type * p_reg, uint16_t cc)
|
||||
{
|
||||
NRFX_ASSERT((cc >= 80) && (cc <= 2047));
|
||||
NRF_SAADC->SAMPLERATE = (SAADC_SAMPLERATE_MODE_Timers << SAADC_SAMPLERATE_MODE_Pos)
|
||||
| ((uint32_t)cc << SAADC_SAMPLERATE_CC_Pos);
|
||||
p_reg->SAMPLERATE = (SAADC_SAMPLERATE_MODE_Timers << SAADC_SAMPLERATE_MODE_Pos)
|
||||
| ((uint32_t)cc << SAADC_SAMPLERATE_CC_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_continuous_mode_disable(void)
|
||||
NRF_STATIC_INLINE bool nrf_saadc_continuous_mode_enable_check(NRF_SAADC_Type const * p_reg)
|
||||
{
|
||||
NRF_SAADC->SAMPLERATE = SAADC_SAMPLERATE_MODE_Task << SAADC_SAMPLERATE_MODE_Pos;
|
||||
return (bool)((p_reg->SAMPLERATE & SAADC_SAMPLERATE_MODE_Msk)
|
||||
== (SAADC_SAMPLERATE_MODE_Timers << SAADC_SAMPLERATE_MODE_Pos));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_channel_init(uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * const config)
|
||||
NRF_STATIC_INLINE void nrf_saadc_continuous_mode_disable(NRF_SAADC_Type * p_reg)
|
||||
{
|
||||
NRF_SAADC->CH[channel].CONFIG =
|
||||
p_reg->SAMPLERATE = SAADC_SAMPLERATE_MODE_Task << SAADC_SAMPLERATE_MODE_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_saadc_channel_init(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * config)
|
||||
{
|
||||
p_reg->CH[channel].CONFIG =
|
||||
((config->resistor_p << SAADC_CH_CONFIG_RESP_Pos) & SAADC_CH_CONFIG_RESP_Msk)
|
||||
| ((config->resistor_n << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk)
|
||||
| ((config->gain << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk)
|
||||
@@ -741,18 +859,63 @@ __STATIC_INLINE void nrf_saadc_channel_init(uint8_t
|
||||
| ((config->acq_time << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk)
|
||||
| ((config->mode << SAADC_CH_CONFIG_MODE_Pos) & SAADC_CH_CONFIG_MODE_Msk)
|
||||
| ((config->burst << SAADC_CH_CONFIG_BURST_Pos) & SAADC_CH_CONFIG_BURST_Msk);
|
||||
nrf_saadc_channel_input_set(channel, config->pin_p, config->pin_n);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_saadc_burst_set(uint8_t channel,
|
||||
nrf_saadc_burst_t burst)
|
||||
NRF_STATIC_INLINE void nrf_saadc_burst_set(NRF_SAADC_Type * p_reg,
|
||||
uint8_t channel,
|
||||
nrf_saadc_burst_t burst)
|
||||
{
|
||||
NRF_SAADC->CH[channel].CONFIG =
|
||||
(NRF_SAADC->CH[channel].CONFIG & ~SAADC_CH_CONFIG_BURST_Msk) |
|
||||
(burst << SAADC_CH_CONFIG_BURST_Pos);
|
||||
p_reg->CH[channel].CONFIG = (p_reg->CH[channel].CONFIG & ~SAADC_CH_CONFIG_BURST_Msk) |
|
||||
(burst << SAADC_CH_CONFIG_BURST_Pos);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t nrf_saadc_value_min_get(nrf_saadc_resolution_t resolution)
|
||||
{
|
||||
uint8_t res_bits = 0;
|
||||
switch (resolution)
|
||||
{
|
||||
case NRF_SAADC_RESOLUTION_8BIT:
|
||||
res_bits = 8;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_10BIT:
|
||||
res_bits = 10;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_12BIT:
|
||||
res_bits = 12;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_14BIT:
|
||||
res_bits = 14;
|
||||
break;
|
||||
default:
|
||||
NRFX_ASSERT(false);
|
||||
}
|
||||
return (nrf_saadc_value_t)(-(1 << res_bits));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_saadc_value_t nrf_saadc_value_max_get(nrf_saadc_resolution_t resolution)
|
||||
{
|
||||
uint8_t res_bits = 0;
|
||||
switch (resolution)
|
||||
{
|
||||
case NRF_SAADC_RESOLUTION_8BIT:
|
||||
res_bits = 8;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_10BIT:
|
||||
res_bits = 10;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_12BIT:
|
||||
res_bits = 12;
|
||||
break;
|
||||
case NRF_SAADC_RESOLUTION_14BIT:
|
||||
res_bits = 14;
|
||||
break;
|
||||
default:
|
||||
NRFX_ASSERT(false);
|
||||
}
|
||||
return (nrf_saadc_value_t)((1 << res_bits) - 1);
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -103,8 +103,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the SPI event.
|
||||
@@ -115,8 +115,8 @@ __STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spi_event_check(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_spi_event_check(NRF_SPI_Type const * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SPI event register.
|
||||
@@ -126,8 +126,8 @@ __STATIC_INLINE bool nrf_spi_event_check(NRF_SPI_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_spi_event_address_get(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spi_event_address_get(NRF_SPI_Type const * p_reg,
|
||||
nrf_spi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -135,8 +135,8 @@ __STATIC_INLINE uint32_t * nrf_spi_event_address_get(NRF_SPI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_int_enable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spi_int_enable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -144,34 +144,32 @@ __STATIC_INLINE void nrf_spi_int_enable(NRF_SPI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_int_disable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spi_int_disable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] spi_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spi_int_enable_check(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_int_mask_t spi_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spi_int_enable_check(NRF_SPI_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the SPI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_enable(NRF_SPI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spi_enable(NRF_SPI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the SPI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_disable(NRF_SPI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spi_disable(NRF_SPI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring SPI pins.
|
||||
@@ -184,10 +182,10 @@ __STATIC_INLINE void nrf_spi_disable(NRF_SPI_Type * p_reg);
|
||||
* @param[in] mosi_pin MOSI pin number.
|
||||
* @param[in] miso_pin MISO pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin);
|
||||
NRF_STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for writing data to the SPI transmitter register.
|
||||
@@ -195,7 +193,7 @@ __STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] data TX data to send.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_txd_set(NRF_SPI_Type * p_reg, uint8_t data);
|
||||
NRF_STATIC_INLINE void nrf_spi_txd_set(NRF_SPI_Type * p_reg, uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Function for reading data from the SPI receiver register.
|
||||
@@ -204,7 +202,7 @@ __STATIC_INLINE void nrf_spi_txd_set(NRF_SPI_Type * p_reg, uint8_t data);
|
||||
*
|
||||
* @return RX data received.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_spi_rxd_get(NRF_SPI_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_spi_rxd_get(NRF_SPI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SPI master data rate.
|
||||
@@ -212,8 +210,8 @@ __STATIC_INLINE uint8_t nrf_spi_rxd_get(NRF_SPI_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency SPI frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_frequency_set(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_frequency_t frequency);
|
||||
NRF_STATIC_INLINE void nrf_spi_frequency_set(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SPI configuration.
|
||||
@@ -222,15 +220,15 @@ __STATIC_INLINE void nrf_spi_frequency_set(NRF_SPI_Type * p_reg,
|
||||
* @param[in] spi_mode SPI mode.
|
||||
* @param[in] spi_bit_order SPI bit order.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spi_configure(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_mode_t spi_mode,
|
||||
nrf_spi_bit_order_t spi_bit_order);
|
||||
NRF_STATIC_INLINE void nrf_spi_configure(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_mode_t spi_mode,
|
||||
nrf_spi_bit_order_t spi_bit_order);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -239,50 +237,49 @@ __STATIC_INLINE void nrf_spi_event_clear(NRF_SPI_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spi_event_check(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_spi_event_check(NRF_SPI_Type const * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_spi_event_address_get(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spi_event_address_get(NRF_SPI_Type const * p_reg,
|
||||
nrf_spi_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_int_enable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spi_int_enable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_int_disable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spi_int_disable(NRF_SPI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spi_int_enable_check(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_int_mask_t spi_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spi_int_enable_check(NRF_SPI_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & spi_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_enable(NRF_SPI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spi_enable(NRF_SPI_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPI_ENABLE_ENABLE_Enabled << SPI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_disable(NRF_SPI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spi_disable(NRF_SPI_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPI_ENABLE_ENABLE_Disabled << SPI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin)
|
||||
NRF_STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin)
|
||||
{
|
||||
#if defined(SPI_PSEL_SCK_CONNECT_Pos)
|
||||
p_reg->PSEL.SCK = sck_pin;
|
||||
@@ -303,25 +300,25 @@ __STATIC_INLINE void nrf_spi_pins_set(NRF_SPI_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_txd_set(NRF_SPI_Type * p_reg, uint8_t data)
|
||||
NRF_STATIC_INLINE void nrf_spi_txd_set(NRF_SPI_Type * p_reg, uint8_t data)
|
||||
{
|
||||
p_reg->TXD = data;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_spi_rxd_get(NRF_SPI_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_spi_rxd_get(NRF_SPI_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RXD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_frequency_set(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_frequency_t frequency)
|
||||
NRF_STATIC_INLINE void nrf_spi_frequency_set(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_frequency_t frequency)
|
||||
{
|
||||
p_reg->FREQUENCY = frequency;
|
||||
p_reg->FREQUENCY = (uint32_t)frequency;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spi_configure(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_mode_t spi_mode,
|
||||
nrf_spi_bit_order_t spi_bit_order)
|
||||
NRF_STATIC_INLINE void nrf_spi_configure(NRF_SPI_Type * p_reg,
|
||||
nrf_spi_mode_t spi_mode,
|
||||
nrf_spi_bit_order_t spi_bit_order)
|
||||
{
|
||||
uint32_t config = (spi_bit_order == NRF_SPI_BIT_ORDER_MSB_FIRST ?
|
||||
SPI_CONFIG_ORDER_MsbFirst : SPI_CONFIG_ORDER_LsbFirst);
|
||||
@@ -351,7 +348,7 @@ __STATIC_INLINE void nrf_spi_configure(NRF_SPI_Type * p_reg,
|
||||
p_reg->CONFIG = config;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -52,7 +52,31 @@ extern "C" {
|
||||
*/
|
||||
#define NRF_SPIM_PIN_NOT_CONNECTED 0xFFFFFFFF
|
||||
|
||||
#if defined(SPIM_DCXCNT_DCXCNT_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Macro for checking if the hardware chip select function is available. */
|
||||
#define NRF_SPIM_HW_CSN_PRESENT \
|
||||
(NRFX_CHECK(SPIM0_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM1_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM2_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM3_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM4_FEATURE_HARDWARE_CSN_PRESENT))
|
||||
|
||||
/** @brief Macro for checking if the DCX pin control is available. */
|
||||
#define NRF_SPIM_DCX_PRESENT \
|
||||
(NRFX_CHECK(SPIM0_FEATURE_DCX_PRESENT) || \
|
||||
NRFX_CHECK(SPIM1_FEATURE_DCX_PRESENT) || \
|
||||
NRFX_CHECK(SPIM2_FEATURE_DCX_PRESENT) || \
|
||||
NRFX_CHECK(SPIM3_FEATURE_DCX_PRESENT) || \
|
||||
NRFX_CHECK(SPIM4_FEATURE_DCX_PRESENT))
|
||||
|
||||
/** @brief Macro for checking if the RXDELAY function is available. */
|
||||
#define NRF_SPIM_RXDELAY_PRESENT \
|
||||
(NRFX_CHECK(SPIM0_FEATURE_RXDELAY_PRESENT) || \
|
||||
NRFX_CHECK(SPIM1_FEATURE_RXDELAY_PRESENT) || \
|
||||
NRFX_CHECK(SPIM2_FEATURE_RXDELAY_PRESENT) || \
|
||||
NRFX_CHECK(SPIM3_FEATURE_RXDELAY_PRESENT) || \
|
||||
NRFX_CHECK(SPIM4_FEATURE_RXDELAY_PRESENT))
|
||||
|
||||
#if defined(NRF_SPIM_DCX_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief This value specified in the DCX line configuration causes this line
|
||||
* to be set low during whole transmission (all transmitted bytes are
|
||||
@@ -63,14 +87,6 @@ extern "C" {
|
||||
#define NRF_SPIM_DCX_CNT_ALL_CMD 0xF
|
||||
#endif
|
||||
|
||||
/** @brief Macro for checking if the hardware chip select function is available. */
|
||||
#define NRF_SPIM_HW_CSN_PRESENT \
|
||||
(NRFX_CHECK(SPIM0_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM1_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM2_FEATURE_HARDWARE_CSN_PRESENT) || \
|
||||
NRFX_CHECK(SPIM3_FEATURE_HARDWARE_CSN_PRESENT))
|
||||
|
||||
|
||||
/** @brief SPIM tasks. */
|
||||
typedef enum
|
||||
{
|
||||
@@ -166,8 +182,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SPIM task register.
|
||||
@@ -177,8 +193,8 @@ __STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified SPIM event.
|
||||
@@ -186,8 +202,8 @@ __STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the SPIM event.
|
||||
@@ -198,8 +214,8 @@ __STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SPIM event register.
|
||||
@@ -209,16 +225,17 @@ __STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -226,8 +243,8 @@ __STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the shortcut setting.
|
||||
@@ -236,7 +253,7 @@ __STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg,
|
||||
*
|
||||
* @return Current shortcut configuration.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -244,8 +261,8 @@ __STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -253,20 +270,18 @@ __STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] spim_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spim_int_enable_check(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_int_mask_t spim_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_int_enable_check(NRF_SPIM_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -277,9 +292,9 @@ __STATIC_INLINE bool nrf_spim_int_enable_check(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_subscribe_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_spim_subscribe_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -288,8 +303,8 @@ __STATIC_INLINE void nrf_spim_subscribe_set(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_subscribe_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_spim_subscribe_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -299,9 +314,9 @@ __STATIC_INLINE void nrf_spim_subscribe_clear(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_publish_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_spim_publish_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -310,8 +325,8 @@ __STATIC_INLINE void nrf_spim_publish_set(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_publish_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spim_publish_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -319,14 +334,14 @@ __STATIC_INLINE void nrf_spim_publish_clear(NRF_SPIM_Type * p_reg,
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the SPIM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring SPIM pins.
|
||||
@@ -339,10 +354,10 @@ __STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg);
|
||||
* @param[in] mosi_pin MOSI pin number.
|
||||
* @param[in] miso_pin MISO pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin);
|
||||
NRF_STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin);
|
||||
|
||||
#if (NRF_SPIM_HW_CSN_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -358,13 +373,13 @@ __STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg,
|
||||
* and minimum duration of CSN must stay unselected between transactions.
|
||||
* The value is specified in number of 64 MHz clock cycles (15.625 ns).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type * p_reg,
|
||||
uint32_t pin,
|
||||
nrf_spim_csn_pol_t polarity,
|
||||
uint32_t duration);
|
||||
NRF_STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type * p_reg,
|
||||
uint32_t pin,
|
||||
nrf_spim_csn_pol_t polarity,
|
||||
uint32_t duration);
|
||||
#endif // (NRF_SPIM_HW_CSN_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(SPIM_PSELDCX_CONNECT_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
#if NRF_SPIM_DCX_PRESENT || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for configuring the SPIM DCX pin.
|
||||
*
|
||||
@@ -374,8 +389,8 @@ __STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] dcx_pin DCX pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_dcx_pin_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_pin);
|
||||
NRF_STATIC_INLINE void nrf_spim_dcx_pin_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the number of command bytes.
|
||||
@@ -388,56 +403,56 @@ __STATIC_INLINE void nrf_spim_dcx_pin_set(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] count Number of command bytes preceding the data bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_dcx_cnt_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t count);
|
||||
#endif // defined(SPIM_PSELDCX_CONNECT_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_STATIC_INLINE void nrf_spim_dcx_cnt_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t count);
|
||||
#endif // NRF_SPIM_DCX_PRESENT || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(SPIM_IFTIMING_RXDELAY_RXDELAY_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
#if NRF_SPIM_RXDELAY_PRESENT || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for configuring the extended SPIM interface.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param rxdelay Sample delay for input serial data on MISO,
|
||||
* specified in 64 MHz clock cycles (15.625 ns) from the sampling edge of SCK.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rxdelay Sample delay for input serial data on MISO,
|
||||
* specified in 64 MHz clock cycles (15.625 ns) from the sampling edge of SCK.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_iftiming_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t rxdelay);
|
||||
#endif // defined(SPIM_IFTIMING_RXDELAY_RXDELAY_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_STATIC_INLINE void nrf_spim_iftiming_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t rxdelay);
|
||||
#endif // NRF_SPIM_RXDELAY_PRESENT || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(SPIM_STALLSTAT_RX_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for clearing stall status for RX EasyDMA RAM accesses.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_stallstat_rx_clear(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_stallstat_rx_clear(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting stall status for RX EasyDMA RAM accesses.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Stall status of RX EasyDMA RAM accesses.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spim_stallstat_rx_get(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_spim_stallstat_rx_get(NRF_SPIM_Type const * p_reg);
|
||||
#endif // defined(SPIM_STALLSTAT_RX_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(SPIM_STALLSTAT_TX_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for clearing stall status for TX EasyDMA RAM accesses.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_stallstat_tx_clear(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_stallstat_tx_clear(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting stall status for TX EasyDMA RAM accesses.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Stall status of TX EasyDMA RAM accesses.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spim_stallstat_tx_get(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_spim_stallstat_tx_get(NRF_SPIM_Type const * p_reg);
|
||||
#endif // defined(SPIM_STALLSTAT_TX_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -446,19 +461,19 @@ __STATIC_INLINE bool nrf_spim_stallstat_tx_get(NRF_SPIM_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency SPI frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_frequency_t frequency);
|
||||
NRF_STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the transmit buffer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_buffer Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the receive buffer.
|
||||
@@ -467,9 +482,9 @@ __STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] p_buffer Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SPI configuration.
|
||||
@@ -478,9 +493,9 @@ __STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] spi_mode SPI mode.
|
||||
* @param[in] spi_bit_order SPI bit order.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_mode_t spi_mode,
|
||||
nrf_spim_bit_order_t spi_bit_order);
|
||||
NRF_STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_mode_t spi_mode,
|
||||
nrf_spim_bit_order_t spi_bit_order);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the over-read character.
|
||||
@@ -489,54 +504,54 @@ __STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
* @param[in] orc Over-read character that is clocked out in case of
|
||||
* an over-read of the TXD buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t orc);
|
||||
NRF_STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t orc);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_spim_task_trigger(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_task_address_get(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -545,186 +560,185 @@ __STATIC_INLINE void nrf_spim_event_clear(NRF_SPIM_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_spim_event_check(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_event_address_get(NRF_SPIM_Type const * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spim_shorts_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spim_shorts_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_shorts_get(NRF_SPIM_Type const * p_reg)
|
||||
{
|
||||
return p_reg->SHORTS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spim_int_enable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spim_int_disable(NRF_SPIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spim_int_enable_check(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_int_mask_t spim_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spim_int_enable_check(NRF_SPIM_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & spim_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_spim_subscribe_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_spim_subscribe_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | SPIM_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_subscribe_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_spim_subscribe_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_publish_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_spim_publish_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | SPIM_PUBLISH_STARTED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_publish_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spim_publish_clear(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_enable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_disable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin)
|
||||
NRF_STATIC_INLINE void nrf_spim_pins_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin)
|
||||
{
|
||||
p_reg->PSEL.SCK = sck_pin;
|
||||
p_reg->PSEL.MOSI = mosi_pin;
|
||||
p_reg->PSEL.MISO = miso_pin;
|
||||
}
|
||||
|
||||
#if (NRF_SPIM_HW_CSN_PRESENT)
|
||||
__STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type * p_reg,
|
||||
uint32_t pin,
|
||||
nrf_spim_csn_pol_t polarity,
|
||||
uint32_t duration)
|
||||
#if NRF_SPIM_HW_CSN_PRESENT
|
||||
NRF_STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type * p_reg,
|
||||
uint32_t pin,
|
||||
nrf_spim_csn_pol_t polarity,
|
||||
uint32_t duration)
|
||||
{
|
||||
p_reg->PSEL.CSN = pin;
|
||||
p_reg->CSNPOL = polarity;
|
||||
p_reg->IFTIMING.CSNDUR = duration;
|
||||
}
|
||||
#endif // defined(NRF_SPIM_HW_CSN_PRESENT)
|
||||
#endif // NRF_SPIM_HW_CSN_PRESENT
|
||||
|
||||
#if defined(SPIM_PSELDCX_CONNECT_Msk)
|
||||
__STATIC_INLINE void nrf_spim_dcx_pin_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_pin)
|
||||
#if NRF_SPIM_DCX_PRESENT
|
||||
NRF_STATIC_INLINE void nrf_spim_dcx_pin_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_pin)
|
||||
{
|
||||
p_reg->PSELDCX = dcx_pin;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_dcx_cnt_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_cnt)
|
||||
NRF_STATIC_INLINE void nrf_spim_dcx_cnt_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t dcx_cnt)
|
||||
{
|
||||
p_reg->DCXCNT = dcx_cnt;
|
||||
}
|
||||
#endif // defined(SPIM_PSELDCX_CONNECT_Msk)
|
||||
#endif // NRF_SPIM_DCX_PRESENT
|
||||
|
||||
#if defined(SPIM_IFTIMING_RXDELAY_RXDELAY_Msk)
|
||||
__STATIC_INLINE void nrf_spim_iftiming_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t rxdelay)
|
||||
#if NRF_SPIM_RXDELAY_PRESENT
|
||||
NRF_STATIC_INLINE void nrf_spim_iftiming_set(NRF_SPIM_Type * p_reg,
|
||||
uint32_t rxdelay)
|
||||
{
|
||||
p_reg->IFTIMING.RXDELAY = rxdelay;
|
||||
}
|
||||
#endif // defined(SPIM_IFTIMING_RXDELAY_RXDELAY_Msk)
|
||||
#endif // NRF_SPIM_RXDELAY_PRESENT
|
||||
|
||||
#if defined(SPIM_STALLSTAT_RX_Msk)
|
||||
__STATIC_INLINE void nrf_spim_stallstat_rx_clear(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_stallstat_rx_clear(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->STALLSTAT &= ~(SPIM_STALLSTAT_RX_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spim_stallstat_rx_get(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_spim_stallstat_rx_get(NRF_SPIM_Type const * p_reg)
|
||||
{
|
||||
return (p_reg->STALLSTAT & SPIM_STALLSTAT_RX_Msk) != 0;
|
||||
}
|
||||
#endif // defined(SPIM_STALLSTAT_RX_Msk)
|
||||
|
||||
#if defined(SPIM_STALLSTAT_TX_Msk)
|
||||
__STATIC_INLINE void nrf_spim_stallstat_tx_clear(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_stallstat_tx_clear(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->STALLSTAT &= ~(SPIM_STALLSTAT_TX_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spim_stallstat_tx_get(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_spim_stallstat_tx_get(NRF_SPIM_Type const * p_reg)
|
||||
{
|
||||
return (p_reg->STALLSTAT & SPIM_STALLSTAT_TX_Msk) != 0;
|
||||
}
|
||||
#endif // defined(SPIM_STALLSTAT_TX_Msk)
|
||||
|
||||
__STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_frequency_t frequency)
|
||||
NRF_STATIC_INLINE void nrf_spim_frequency_set(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_frequency_t frequency)
|
||||
{
|
||||
p_reg->FREQUENCY = (uint32_t)frequency;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->TXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->TXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_buffer_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->RXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->RXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_mode_t spi_mode,
|
||||
nrf_spim_bit_order_t spi_bit_order)
|
||||
NRF_STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
nrf_spim_mode_t spi_mode,
|
||||
nrf_spim_bit_order_t spi_bit_order)
|
||||
{
|
||||
uint32_t config = (spi_bit_order == NRF_SPIM_BIT_ORDER_MSB_FIRST ?
|
||||
SPIM_CONFIG_ORDER_MsbFirst : SPIM_CONFIG_ORDER_LsbFirst);
|
||||
@@ -754,34 +768,34 @@ __STATIC_INLINE void nrf_spim_configure(NRF_SPIM_Type * p_reg,
|
||||
p_reg->CONFIG = config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t orc)
|
||||
NRF_STATIC_INLINE void nrf_spim_orc_set(NRF_SPIM_Type * p_reg,
|
||||
uint8_t orc)
|
||||
{
|
||||
p_reg->ORC = orc;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_list_enable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = 1;
|
||||
p_reg->TXD.LIST = SPIM_TXD_LIST_LIST_ArrayList << SPIM_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_tx_list_disable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = 0;
|
||||
p_reg->TXD.LIST = SPIM_TXD_LIST_LIST_Disabled << SPIM_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_list_enable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = 1;
|
||||
p_reg->RXD.LIST = SPIM_RXD_LIST_LIST_ArrayList << SPIM_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spim_rx_list_disable(NRF_SPIM_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = 0;
|
||||
p_reg->RXD.LIST = SPIM_RXD_LIST_LIST_Disabled << SPIM_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -119,8 +119,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SPIS task register.
|
||||
@@ -130,8 +130,8 @@ __STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified SPIS event.
|
||||
@@ -139,8 +139,8 @@ __STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the SPIS event.
|
||||
@@ -151,8 +151,8 @@ __STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified SPIS event register.
|
||||
@@ -162,8 +162,8 @@ __STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
@@ -171,8 +171,8 @@ __STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -180,8 +180,8 @@ __STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -189,8 +189,8 @@ __STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -198,20 +198,18 @@ __STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] spis_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spis_int_enable_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_int_mask_t spis_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_int_enable_check(NRF_SPIS_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -222,9 +220,9 @@ __STATIC_INLINE bool nrf_spis_int_enable_check(NRF_SPIS_Type const * p_reg,
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_subscribe_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_spis_subscribe_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -233,8 +231,8 @@ __STATIC_INLINE void nrf_spis_subscribe_set(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_subscribe_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_spis_subscribe_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -244,9 +242,9 @@ __STATIC_INLINE void nrf_spis_subscribe_clear(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_publish_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_spis_publish_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -255,8 +253,8 @@ __STATIC_INLINE void nrf_spis_publish_set(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_publish_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spis_publish_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -264,14 +262,14 @@ __STATIC_INLINE void nrf_spis_publish_clear(NRF_SPIS_Type * p_reg,
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the SPIS peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SPIS semaphore status.
|
||||
@@ -280,7 +278,7 @@ __STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_reg);
|
||||
*
|
||||
* @returns Current semaphore status.
|
||||
*/
|
||||
__STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SPIS status.
|
||||
@@ -289,7 +287,7 @@ __STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type *
|
||||
*
|
||||
* @returns Current SPIS status.
|
||||
*/
|
||||
__STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring SPIS pins.
|
||||
@@ -303,11 +301,11 @@ __STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type * p_reg
|
||||
* @param[in] miso_pin MISO pin number.
|
||||
* @param[in] csn_pin CSN pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin,
|
||||
uint32_t csn_pin);
|
||||
NRF_STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin,
|
||||
uint32_t csn_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the transmit buffer.
|
||||
@@ -316,9 +314,9 @@ __STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_buffer Pointer to the buffer that contains the data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the receive buffer.
|
||||
@@ -327,9 +325,9 @@ __STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] p_buffer Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of bytes transmitted
|
||||
@@ -339,7 +337,7 @@ __STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
*
|
||||
* @returns Number of bytes transmitted.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of bytes received
|
||||
@@ -349,7 +347,7 @@ __STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
*
|
||||
* @returns Number of bytes received.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SPI configuration.
|
||||
@@ -358,9 +356,9 @@ __STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg);
|
||||
* @param[in] spi_mode SPI mode.
|
||||
* @param[in] spi_bit_order SPI bit order.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_mode_t spi_mode,
|
||||
nrf_spis_bit_order_t spi_bit_order);
|
||||
NRF_STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_mode_t spi_mode,
|
||||
nrf_spis_bit_order_t spi_bit_order);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the default character.
|
||||
@@ -369,8 +367,8 @@ __STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] def Default character that is clocked out in case of
|
||||
* an overflow of the RXD buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t def);
|
||||
NRF_STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t def);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the over-read character.
|
||||
@@ -379,26 +377,57 @@ __STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_reg,
|
||||
* @param[in] orc Over-read character that is clocked out in case of
|
||||
* an over-read of the TXD buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t orc);
|
||||
NRF_STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t orc);
|
||||
|
||||
#if defined(SPIS_TXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for enabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_list_enable(NRF_SPIS_Type * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
/**
|
||||
* @brief Function for disabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_list_disable(NRF_SPIS_Type * p_reg);
|
||||
#endif // defined(SPIS_TXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
__STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
#if defined(SPIS_RXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for enabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_list_enable(NRF_SPIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_list_disable(NRF_SPIS_Type * p_reg);
|
||||
#endif // defined(SPIS_RXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
{
|
||||
return (uint32_t)p_reg + (uint32_t)task;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -407,104 +436,103 @@ __STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
{
|
||||
return (uint32_t)p_reg + (uint32_t)event;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spis_int_enable_check(NRF_SPIS_Type const * p_reg,
|
||||
nrf_spis_int_mask_t spis_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spis_int_enable_check(NRF_SPIS_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & spis_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_spis_subscribe_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_spis_subscribe_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | SPIS_SUBSCRIBE_ACQUIRE_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_subscribe_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_spis_subscribe_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_publish_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_spis_publish_set(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | SPIS_PUBLISH_END_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_publish_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spis_publish_clear(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPIS_ENABLE_ENABLE_Enabled << SPIS_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (SPIS_ENABLE_ENABLE_Disabled << SPIS_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type const * p_reg)
|
||||
{
|
||||
return (nrf_spis_semstat_t) ((p_reg->SEMSTAT & SPIS_SEMSTAT_SEMSTAT_Msk)
|
||||
>> SPIS_SEMSTAT_SEMSTAT_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type const * p_reg)
|
||||
{
|
||||
return (nrf_spis_status_mask_t) p_reg->STATUS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin,
|
||||
uint32_t csn_pin)
|
||||
NRF_STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
uint32_t sck_pin,
|
||||
uint32_t mosi_pin,
|
||||
uint32_t miso_pin,
|
||||
uint32_t csn_pin)
|
||||
{
|
||||
#if defined (NRF51)
|
||||
p_reg->PSELSCK = sck_pin;
|
||||
@@ -519,9 +547,9 @@ __STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
#if defined (NRF51)
|
||||
p_reg->TXDPTR = (uint32_t)p_buffer;
|
||||
@@ -532,9 +560,9 @@ __STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
#if defined (NRF51)
|
||||
p_reg->RXDPTR = (uint32_t)p_buffer;
|
||||
@@ -545,7 +573,7 @@ __STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
{
|
||||
#if defined (NRF51)
|
||||
return p_reg->AMOUNTTX;
|
||||
@@ -554,7 +582,7 @@ __STATIC_INLINE size_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
{
|
||||
#if defined (NRF51)
|
||||
return p_reg->AMOUNTRX;
|
||||
@@ -563,9 +591,9 @@ __STATIC_INLINE size_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_mode_t spi_mode,
|
||||
nrf_spis_bit_order_t spi_bit_order)
|
||||
NRF_STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
nrf_spis_mode_t spi_mode,
|
||||
nrf_spis_bit_order_t spi_bit_order)
|
||||
{
|
||||
uint32_t config = (spi_bit_order == NRF_SPIS_BIT_ORDER_MSB_FIRST ?
|
||||
SPIS_CONFIG_ORDER_MsbFirst : SPIS_CONFIG_ORDER_LsbFirst);
|
||||
@@ -596,19 +624,43 @@ __STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_reg,
|
||||
p_reg->CONFIG = config;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t orc)
|
||||
NRF_STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t orc)
|
||||
{
|
||||
p_reg->ORC = orc;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t def)
|
||||
NRF_STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_reg,
|
||||
uint8_t def)
|
||||
{
|
||||
p_reg->DEF = def;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if defined(SPIS_TXD_LIST_LIST_Msk)
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_list_enable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = SPIS_TXD_LIST_LIST_ArrayList << SPIS_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_spis_tx_list_disable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = SPIS_TXD_LIST_LIST_Disabled << SPIS_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
#endif // defined(SPIS_TXD_LIST_LIST_Msk)
|
||||
|
||||
#if defined(SPIS_RXD_LIST_LIST_Msk)
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_list_enable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = SPIS_RXD_LIST_LIST_ArrayList << SPIS_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_spis_rx_list_disable(NRF_SPIS_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = SPIS_RXD_LIST_LIST_Disabled << SPIS_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
#endif // defined(SPIS_RXD_LIST_LIST_Msk)
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -89,8 +89,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_event_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spu_event_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the SPU event.
|
||||
@@ -101,8 +101,8 @@ __STATIC_INLINE void nrf_spu_event_clear(NRF_SPU_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spu_event_check(NRF_SPU_Type const * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_spu_event_check(NRF_SPU_Type const * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
@@ -110,8 +110,8 @@ __STATIC_INLINE bool nrf_spu_event_check(NRF_SPU_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_int_enable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spu_int_enable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -119,20 +119,18 @@ __STATIC_INLINE void nrf_spu_int_enable(NRF_SPU_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_int_disable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_spu_int_disable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] spu_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spu_int_enable_check(NRF_SPU_Type const * p_reg,
|
||||
uint32_t spu_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_spu_int_enable_check(NRF_SPU_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting up publication configuration of a given SPU event.
|
||||
@@ -141,9 +139,9 @@ __STATIC_INLINE bool nrf_spu_int_enable_check(NRF_SPU_Type const * p_reg,
|
||||
* @param[in] event Event to configure.
|
||||
* @param[in] channel Channel to connect with published event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_publish_set(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event,
|
||||
uint32_t channel);
|
||||
NRF_STATIC_INLINE void nrf_spu_publish_set(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event,
|
||||
uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing publication configuration of a given SPU event.
|
||||
@@ -151,8 +149,8 @@ __STATIC_INLINE void nrf_spu_publish_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_publish_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_spu_publish_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the capabilities of the current device.
|
||||
@@ -162,7 +160,7 @@ __STATIC_INLINE void nrf_spu_publish_clear(NRF_SPU_Type * p_reg,
|
||||
* @retval true ARM TrustZone support is available.
|
||||
* @retval false ARM TrustZone support is not available.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_spu_tz_is_available(NRF_SPU_Type const * p_reg);
|
||||
NRF_STATIC_INLINE bool nrf_spu_tz_is_available(NRF_SPU_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the DPPI channels to be available in particular domains.
|
||||
@@ -175,10 +173,10 @@ __STATIC_INLINE bool nrf_spu_tz_is_available(NRF_SPU_Type const * p_reg);
|
||||
* @param[in] channels_mask Bitmask with channels configuration.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t dppi_id,
|
||||
uint32_t channels_mask,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t dppi_id,
|
||||
uint32_t channels_mask,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the GPIO pins to be available in particular domains.
|
||||
@@ -191,10 +189,10 @@ __STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] gpio_mask Bitmask with gpio configuration.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t gpio_port,
|
||||
uint32_t gpio_mask,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t gpio_port,
|
||||
uint32_t gpio_mask,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring non-secure callable flash region.
|
||||
@@ -205,11 +203,11 @@ __STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] region_number Flash region number.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t flash_nsc_id,
|
||||
nrf_spu_nsc_size_t flash_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t flash_nsc_id,
|
||||
nrf_spu_nsc_size_t flash_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring non-secure callable RAM region.
|
||||
@@ -220,11 +218,11 @@ __STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] region_number RAM region number.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t ram_nsc_id,
|
||||
nrf_spu_nsc_size_t ram_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t ram_nsc_id,
|
||||
nrf_spu_nsc_size_t ram_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring security for a particular flash region.
|
||||
@@ -237,11 +235,11 @@ __STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] permissions Flash region permissions.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring security for the RAM region.
|
||||
@@ -254,11 +252,11 @@ __STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] permissions RAM region permissions.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring access permissions of the peripheral.
|
||||
@@ -269,70 +267,81 @@ __STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
* @param[in] secure_dma DMA transfers possible only from RAM memory in secure domain.
|
||||
* @param[in] lock_conf Lock configuration until next SoC reset.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_spu_peripheral_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t peripheral_id,
|
||||
bool secure_attr,
|
||||
bool secure_dma,
|
||||
bool lock_conf);
|
||||
NRF_STATIC_INLINE void nrf_spu_peripheral_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t peripheral_id,
|
||||
bool secure_attr,
|
||||
bool secure_dma,
|
||||
bool lock_conf);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring bus access permissions of the specified external domain.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] domain_id ID number of a particular external domain.
|
||||
* @param[in] secure_attr Specifies if the bus accesses from this domain have the secure attribute set.
|
||||
* @param[in] lock_conf Specifies if the configuration should be locked until next SoC reset.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_spu_extdomain_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t domain_id,
|
||||
bool secure_attr,
|
||||
bool lock_conf);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_spu_event_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spu_event_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spu_event_check(NRF_SPU_Type const * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_spu_event_check(NRF_SPU_Type const * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_int_enable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spu_int_enable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_int_disable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_spu_int_disable(NRF_SPU_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spu_int_enable_check(NRF_SPU_Type const * p_reg,
|
||||
uint32_t spu_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_spu_int_enable_check(NRF_SPU_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & spu_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_publish_set(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event,
|
||||
uint32_t channel)
|
||||
NRF_STATIC_INLINE void nrf_spu_publish_set(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event,
|
||||
uint32_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
(channel | (SPU_PUBLISH_RAMACCERR_EN_Msk));
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_publish_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_spu_publish_clear(NRF_SPU_Type * p_reg,
|
||||
nrf_spu_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_spu_tz_is_available(NRF_SPU_Type const * p_reg)
|
||||
NRF_STATIC_INLINE bool nrf_spu_tz_is_available(NRF_SPU_Type const * p_reg)
|
||||
{
|
||||
return (p_reg->CAP & SPU_CAP_TZM_Msk ? true : false);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t dppi_id,
|
||||
uint32_t channels_mask,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t dppi_id,
|
||||
uint32_t channels_mask,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->DPPI[dppi_id].LOCK & SPU_DPPI_LOCK_LOCK_Msk));
|
||||
|
||||
@@ -344,10 +353,10 @@ __STATIC_INLINE void nrf_spu_dppi_config_set(NRF_SPU_Type * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t gpio_port,
|
||||
uint32_t gpio_mask,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t gpio_port,
|
||||
uint32_t gpio_mask,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->GPIOPORT[gpio_port].LOCK & SPU_GPIOPORT_LOCK_LOCK_Msk));
|
||||
|
||||
@@ -359,11 +368,11 @@ __STATIC_INLINE void nrf_spu_gpio_config_set(NRF_SPU_Type * p_reg,
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t flash_nsc_id,
|
||||
nrf_spu_nsc_size_t flash_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t flash_nsc_id,
|
||||
nrf_spu_nsc_size_t flash_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->FLASHNSC[flash_nsc_id].REGION & SPU_FLASHNSC_REGION_LOCK_Msk));
|
||||
NRFX_ASSERT(!(p_reg->FLASHNSC[flash_nsc_id].SIZE & SPU_FLASHNSC_SIZE_LOCK_Msk));
|
||||
@@ -374,11 +383,11 @@ __STATIC_INLINE void nrf_spu_flashnsc_set(NRF_SPU_Type * p_reg,
|
||||
(lock_conf ? SPU_FLASHNSC_SIZE_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t ram_nsc_id,
|
||||
nrf_spu_nsc_size_t ram_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t ram_nsc_id,
|
||||
nrf_spu_nsc_size_t ram_nsc_size,
|
||||
uint8_t region_number,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->RAMNSC[ram_nsc_id].REGION & SPU_RAMNSC_REGION_LOCK_Msk));
|
||||
NRFX_ASSERT(!(p_reg->RAMNSC[ram_nsc_id].SIZE & SPU_RAMNSC_SIZE_LOCK_Msk));
|
||||
@@ -389,11 +398,11 @@ __STATIC_INLINE void nrf_spu_ramnsc_set(NRF_SPU_Type * p_reg,
|
||||
(lock_conf ? SPU_RAMNSC_SIZE_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->FLASHREGION[region_id].PERM & SPU_FLASHREGION_PERM_LOCK_Msk));
|
||||
|
||||
@@ -402,11 +411,11 @@ __STATIC_INLINE void nrf_spu_flashregion_set(NRF_SPU_Type * p_reg,
|
||||
(lock_conf ? SPU_FLASHREGION_PERM_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
uint8_t region_id,
|
||||
bool secure_attr,
|
||||
uint32_t permissions,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->RAMREGION[region_id].PERM & SPU_RAMREGION_PERM_LOCK_Msk));
|
||||
|
||||
@@ -415,11 +424,11 @@ __STATIC_INLINE void nrf_spu_ramregion_set(NRF_SPU_Type * p_reg,
|
||||
(lock_conf ? SPU_RAMREGION_PERM_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_spu_peripheral_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t peripheral_id,
|
||||
bool secure_attr,
|
||||
bool secure_dma,
|
||||
bool lock_conf)
|
||||
NRF_STATIC_INLINE void nrf_spu_peripheral_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t peripheral_id,
|
||||
bool secure_attr,
|
||||
bool secure_dma,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(p_reg->PERIPHID[peripheral_id].PERM & SPU_PERIPHID_PERM_PRESENT_Msk);
|
||||
NRFX_ASSERT(!(p_reg->PERIPHID[peripheral_id].PERM & SPU_PERIPHID_PERM_LOCK_Msk));
|
||||
@@ -430,7 +439,19 @@ __STATIC_INLINE void nrf_spu_peripheral_set(NRF_SPU_Type * p_reg,
|
||||
(lock_conf ? SPU_PERIPHID_PERM_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
NRF_STATIC_INLINE void nrf_spu_extdomain_set(NRF_SPU_Type * p_reg,
|
||||
uint32_t domain_id,
|
||||
bool secure_attr,
|
||||
bool lock_conf)
|
||||
{
|
||||
NRFX_ASSERT(!(p_reg->EXTDOMAIN[domain_id].PERM & SPU_EXTDOMAIN_PERM_LOCK_Msk));
|
||||
|
||||
p_reg->EXTDOMAIN[domain_id].PERM =
|
||||
(secure_attr ? SPU_EXTDOMAIN_PERM_SECATTR_Msk : 0) |
|
||||
(lock_conf ? SPU_EXTDOMAIN_PERM_LOCK_Msk : 0);
|
||||
}
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -85,28 +85,28 @@ typedef enum {
|
||||
* @note The @ref NRF_SYSTICK_CSR_COUNTFLAG_MASK value is cleared when CSR register is read.
|
||||
* @return Values composed by @ref nrf_systick_csr_flags_t.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_systick_csr_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_csr_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for setting Configuration and Status Register.
|
||||
*
|
||||
* @param[in] val The value composed from @ref nrf_systick_csr_flags_t.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_systick_csr_set(uint32_t val);
|
||||
NRF_STATIC_INLINE void nrf_systick_csr_set(uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the current reload value.
|
||||
*
|
||||
* @return The reload register value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_systick_load_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_load_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring the reload value.
|
||||
*
|
||||
* @param[in] val The value to be set in the reload register.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_systick_load_set(uint32_t val);
|
||||
NRF_STATIC_INLINE void nrf_systick_load_set(uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the SysTick current value.
|
||||
@@ -114,7 +114,7 @@ __STATIC_INLINE void nrf_systick_load_set(uint32_t val);
|
||||
* @return The current SysTick value
|
||||
* @sa NRF_SYSTICK_VAL_MASK
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_systick_val_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_val_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the SysTick current value.
|
||||
@@ -122,54 +122,54 @@ __STATIC_INLINE uint32_t nrf_systick_val_get(void);
|
||||
* @note The SysTick does not allow setting current value.
|
||||
* Any write to VAL register would clear the timer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_systick_val_clear(void);
|
||||
NRF_STATIC_INLINE void nrf_systick_val_clear(void);
|
||||
|
||||
/**
|
||||
* @brief Function for reading the calibration register.
|
||||
*
|
||||
* @return The calibration register value.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_systick_calib_get(void);
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_calib_get(void);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_systick_csr_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_csr_get(void)
|
||||
{
|
||||
return SysTick->CTRL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_systick_csr_set(uint32_t val)
|
||||
NRF_STATIC_INLINE void nrf_systick_csr_set(uint32_t val)
|
||||
{
|
||||
SysTick->CTRL = val;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_systick_load_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_load_get(void)
|
||||
{
|
||||
return SysTick->LOAD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_systick_load_set(uint32_t val)
|
||||
NRF_STATIC_INLINE void nrf_systick_load_set(uint32_t val)
|
||||
{
|
||||
SysTick->LOAD = val;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_systick_val_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_val_get(void)
|
||||
{
|
||||
return SysTick->VAL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_systick_val_clear(void)
|
||||
NRF_STATIC_INLINE void nrf_systick_val_clear(void)
|
||||
{
|
||||
SysTick->VAL = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_systick_calib_get(void)
|
||||
NRF_STATIC_INLINE uint32_t nrf_systick_calib_get(void)
|
||||
{
|
||||
return SysTick->CALIB;
|
||||
}
|
||||
|
||||
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
|
||||
#endif /* NRF_DECLARE_ONLY */
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,44 +38,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_temp_hal_deprecated TEMP HAL (deprecated)
|
||||
* @{
|
||||
* @ingroup nrf_temp
|
||||
* @brief Temperature module init and read functions.
|
||||
*/
|
||||
|
||||
/** @brief Workaround specific define - sign mask.*/
|
||||
#define MASK_SIGN (0x00000200UL)
|
||||
|
||||
/** @brief Workaround specific define - sign extension mask.*/
|
||||
#define MASK_SIGN_EXTENSION (0xFFFFFC00UL)
|
||||
|
||||
/**
|
||||
* @brief Function for preparing the TEMP module for temperature measurement.
|
||||
*
|
||||
* This function initializes the TEMP module and writes to the hidden configuration register.
|
||||
*/
|
||||
static __INLINE void nrf_temp_init(void)
|
||||
{
|
||||
/**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */
|
||||
*(uint32_t *) 0x4000C504 = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for reading temperature measurement.
|
||||
*
|
||||
* The function reads the 10-bit 2's complement value and transforms it to a 32-bit 2's complement value.
|
||||
*/
|
||||
static __INLINE int32_t nrf_temp_read(void)
|
||||
{
|
||||
/**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */
|
||||
return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ?
|
||||
(int32_t)(NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup nrf_temp_hal TEMP HAL
|
||||
* @{
|
||||
@@ -108,7 +70,7 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_temp_int_enable(NRF_TEMP_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_temp_int_enable(NRF_TEMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
@@ -116,19 +78,17 @@ __STATIC_INLINE void nrf_temp_int_enable(NRF_TEMP_Type * p_reg, uint32_t mask);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_temp_int_disable(NRF_TEMP_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_temp_int_disable(NRF_TEMP_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] temp_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_temp_int_enable_check(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_int_mask_t temp_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_int_enable_check(NRF_TEMP_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TEMP task register.
|
||||
@@ -138,8 +98,8 @@ __STATIC_INLINE bool nrf_temp_int_enable_check(NRF_TEMP_Type const * p_reg,
|
||||
*
|
||||
* @return Address of the requested task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_temp_task_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_task_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for activating the specified TEMP task.
|
||||
@@ -147,7 +107,7 @@ __STATIC_INLINE uint32_t nrf_temp_task_address_get(NRF_TEMP_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_temp_task_trigger(NRF_TEMP_Type * p_reg, nrf_temp_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_temp_task_trigger(NRF_TEMP_Type * p_reg, nrf_temp_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TEMP event register.
|
||||
@@ -157,8 +117,8 @@ __STATIC_INLINE void nrf_temp_task_trigger(NRF_TEMP_Type * p_reg, nrf_temp_task_
|
||||
*
|
||||
* @return Address of the requested event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_temp_event_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_event_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified TEMP event.
|
||||
@@ -166,7 +126,7 @@ __STATIC_INLINE uint32_t nrf_temp_event_address_get(NRF_TEMP_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the state of a specific event.
|
||||
@@ -177,7 +137,7 @@ __STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_temp_event_check(NRF_TEMP_Type const * p_reg, nrf_temp_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_temp_event_check(NRF_TEMP_Type const * p_reg, nrf_temp_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the result of temperature measurement.
|
||||
@@ -188,44 +148,43 @@ __STATIC_INLINE bool nrf_temp_event_check(NRF_TEMP_Type const * p_reg, nrf_temp_
|
||||
*
|
||||
* @return Temperature value register contents.
|
||||
*/
|
||||
__STATIC_INLINE int32_t nrf_temp_result_get(NRF_TEMP_Type const * p_reg);
|
||||
NRF_STATIC_INLINE int32_t nrf_temp_result_get(NRF_TEMP_Type const * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_temp_int_enable(NRF_TEMP_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_temp_int_enable(NRF_TEMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_temp_int_disable(NRF_TEMP_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_temp_int_disable(NRF_TEMP_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_temp_int_enable_check(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_int_mask_t temp_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_int_enable_check(NRF_TEMP_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & temp_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_temp_task_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_task_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_temp_task_trigger(NRF_TEMP_Type * p_reg, nrf_temp_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_temp_task_trigger(NRF_TEMP_Type * p_reg, nrf_temp_task_t task)
|
||||
{
|
||||
*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task) = 1;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_temp_event_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_temp_event_address_get(NRF_TEMP_Type const * p_reg,
|
||||
nrf_temp_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -234,12 +193,12 @@ __STATIC_INLINE void nrf_temp_event_clear(NRF_TEMP_Type * p_reg, nrf_temp_event_
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_temp_event_check(NRF_TEMP_Type const * p_reg, nrf_temp_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_temp_event_check(NRF_TEMP_Type const * p_reg, nrf_temp_event_t event)
|
||||
{
|
||||
return (bool)*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
}
|
||||
|
||||
__STATIC_INLINE int32_t nrf_temp_result_get(NRF_TEMP_Type const * p_reg)
|
||||
NRF_STATIC_INLINE int32_t nrf_temp_result_get(NRF_TEMP_Type const * p_reg)
|
||||
{
|
||||
int32_t raw_measurement = p_reg->TEMP;
|
||||
|
||||
@@ -254,7 +213,7 @@ __STATIC_INLINE int32_t nrf_temp_result_get(NRF_TEMP_Type const * p_reg)
|
||||
return raw_measurement;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -128,6 +128,12 @@ typedef enum
|
||||
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE5 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[5]), ///< Task for capturing the timer value on channel 5.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE6_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE6 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[6]), ///< Task for capturing the timer value on channel 6.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE7_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE7 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[7]), ///< Task for capturing the timer value on channel 7.
|
||||
#endif
|
||||
} nrf_timer_task_t;
|
||||
|
||||
/** @brief Timer events. */
|
||||
@@ -143,6 +149,12 @@ typedef enum
|
||||
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE5 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[5]), ///< Event from compare channel 5.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE6_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE6 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[6]), ///< Event from compare channel 6.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE7_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE7 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[7]), ///< Event from compare channel 7.
|
||||
#endif
|
||||
} nrf_timer_event_t;
|
||||
|
||||
/** @brief Types of timer shortcuts. */
|
||||
@@ -241,8 +253,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified timer task register.
|
||||
@@ -252,8 +264,8 @@ __STATIC_INLINE void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_timer_task_address_get(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_task_address_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified timer event.
|
||||
@@ -261,8 +273,8 @@ __STATIC_INLINE uint32_t * nrf_timer_task_address_get(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the TIMER event.
|
||||
@@ -273,8 +285,8 @@ __STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified timer event register.
|
||||
@@ -284,8 +296,8 @@ __STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_timer_event_address_get(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_event_address_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
@@ -293,8 +305,8 @@ __STATIC_INLINE uint32_t * nrf_timer_event_address_get(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -302,8 +314,8 @@ __STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -311,8 +323,8 @@ __STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -320,20 +332,18 @@ __STATIC_INLINE void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_int_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_timer_int_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] timer_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_timer_int_enable_check(NRF_TIMER_Type * p_reg,
|
||||
uint32_t timer_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check(NRF_TIMER_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -344,9 +354,9 @@ __STATIC_INLINE bool nrf_timer_int_enable_check(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_subscribe_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_timer_subscribe_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -355,8 +365,8 @@ __STATIC_INLINE void nrf_timer_subscribe_set(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_subscribe_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_timer_subscribe_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -366,9 +376,9 @@ __STATIC_INLINE void nrf_timer_subscribe_clear(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_publish_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_timer_publish_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -377,8 +387,8 @@ __STATIC_INLINE void nrf_timer_publish_set(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_publish_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_timer_publish_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -387,8 +397,8 @@ __STATIC_INLINE void nrf_timer_publish_clear(NRF_TIMER_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mode Timer mode.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_mode_t mode);
|
||||
NRF_STATIC_INLINE void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the timer mode.
|
||||
@@ -397,7 +407,7 @@ __STATIC_INLINE void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Timer mode.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get(NRF_TIMER_Type * p_reg);
|
||||
NRF_STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get(NRF_TIMER_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer bit width.
|
||||
@@ -405,8 +415,8 @@ __STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get(NRF_TIMER_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] bit_width Timer bit width.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width);
|
||||
NRF_STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the timer bit width.
|
||||
@@ -415,7 +425,7 @@ __STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Timer bit width.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get(NRF_TIMER_Type * p_reg);
|
||||
NRF_STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get(NRF_TIMER_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer frequency.
|
||||
@@ -423,8 +433,8 @@ __STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get(NRF_TIMER_Type * p
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency Timer frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency);
|
||||
NRF_STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the timer frequency.
|
||||
@@ -433,16 +443,16 @@ __STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Timer frequency.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get(NRF_TIMER_Type * p_reg);
|
||||
NRF_STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get(NRF_TIMER_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for writing the capture/compare register for the specified channel.
|
||||
* @brief Function for setting the capture/compare register for the specified channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc_channel The specified capture/compare channel.
|
||||
* @param[in] cc_value Value to write to the capture/compare register.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_timer_cc_write(NRF_TIMER_Type * p_reg,
|
||||
NRF_STATIC_INLINE void nrf_timer_cc_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value);
|
||||
|
||||
@@ -454,8 +464,8 @@ __STATIC_INLINE void nrf_timer_cc_write(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Value from the specified capture/compare register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_timer_cc_read(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_cc_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified timer capture task.
|
||||
@@ -464,7 +474,7 @@ __STATIC_INLINE uint32_t nrf_timer_cc_read(NRF_TIMER_Type * p_reg,
|
||||
*
|
||||
* @return Capture task.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel);
|
||||
NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified timer compare event.
|
||||
@@ -473,7 +483,7 @@ __STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel);
|
||||
*
|
||||
* @return Compare event.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel);
|
||||
NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified timer compare interrupt.
|
||||
@@ -482,7 +492,7 @@ __STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel);
|
||||
*
|
||||
* @return Compare interrupt.
|
||||
*/
|
||||
__STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get(uint32_t channel);
|
||||
NRF_STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get(uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for calculating the number of timer ticks for a given time
|
||||
@@ -493,8 +503,8 @@ __STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get(uint32_t channel)
|
||||
*
|
||||
* @return Number of timer ticks.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
nrf_timer_frequency_t frequency);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
nrf_timer_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for calculating the number of timer ticks for a given time
|
||||
@@ -505,26 +515,46 @@ __STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
*
|
||||
* @return Number of timer ticks.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_timer_ms_to_ticks(uint32_t time_ms,
|
||||
nrf_timer_frequency_t frequency);
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_ms_to_ticks(uint32_t time_ms,
|
||||
nrf_timer_frequency_t frequency);
|
||||
|
||||
#if defined(TIMER_ONESHOTEN_ONESHOTEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for enabling one-shot operation for the specified capture/compare channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc_channel Capture/compare channel.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_one_shot_enable(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
/**
|
||||
* @brief Function for disabling one-shot operation for the specified capture/compare channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc_channel Capture/compare channel.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_one_shot_disable(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
__STATIC_INLINE void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
#endif // defined(TIMER_ONESHOTEN_ONESHOTEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_timer_task_address_get(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_task_address_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -533,147 +563,146 @@ __STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_timer_event_address_get(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_event_address_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_int_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_timer_int_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_timer_int_enable_check(NRF_TIMER_Type * p_reg,
|
||||
uint32_t timer_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check(NRF_TIMER_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & timer_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_timer_subscribe_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_timer_subscribe_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | TIMER_SUBSCRIBE_START_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_subscribe_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_timer_subscribe_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_publish_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_timer_publish_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | TIMER_PUBLISH_COMPARE_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_publish_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_timer_publish_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_mode_t mode)
|
||||
NRF_STATIC_INLINE void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_mode_t mode)
|
||||
{
|
||||
p_reg->MODE = (p_reg->MODE & ~TIMER_MODE_MODE_Msk) |
|
||||
((mode << TIMER_MODE_MODE_Pos) & TIMER_MODE_MODE_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get(NRF_TIMER_Type * p_reg)
|
||||
NRF_STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get(NRF_TIMER_Type const * p_reg)
|
||||
{
|
||||
return (nrf_timer_mode_t)(p_reg->MODE);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width)
|
||||
NRF_STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width)
|
||||
{
|
||||
p_reg->BITMODE = (p_reg->BITMODE & ~TIMER_BITMODE_BITMODE_Msk) |
|
||||
((bit_width << TIMER_BITMODE_BITMODE_Pos) &
|
||||
TIMER_BITMODE_BITMODE_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get(NRF_TIMER_Type * p_reg)
|
||||
NRF_STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get(NRF_TIMER_Type const * p_reg)
|
||||
{
|
||||
return (nrf_timer_bit_width_t)(p_reg->BITMODE);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency)
|
||||
NRF_STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency)
|
||||
{
|
||||
p_reg->PRESCALER = (p_reg->PRESCALER & ~TIMER_PRESCALER_PRESCALER_Msk) |
|
||||
((frequency << TIMER_PRESCALER_PRESCALER_Pos) &
|
||||
TIMER_PRESCALER_PRESCALER_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get(NRF_TIMER_Type * p_reg)
|
||||
NRF_STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get(NRF_TIMER_Type const * p_reg)
|
||||
{
|
||||
return (nrf_timer_frequency_t)(p_reg->PRESCALER);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_timer_cc_write(NRF_TIMER_Type * p_reg,
|
||||
NRF_STATIC_INLINE void nrf_timer_cc_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value)
|
||||
{
|
||||
p_reg->CC[cc_channel] = cc_value;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_timer_cc_read(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_cc_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
{
|
||||
return (uint32_t)p_reg->CC[cc_channel];
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel)
|
||||
NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel)
|
||||
{
|
||||
return (nrf_timer_task_t)NRFX_OFFSETOF(NRF_TIMER_Type, TASKS_CAPTURE[channel]);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel)
|
||||
NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel)
|
||||
{
|
||||
return (nrf_timer_event_t)NRFX_OFFSETOF(NRF_TIMER_Type, EVENTS_COMPARE[channel]);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get(uint32_t channel)
|
||||
NRF_STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get(uint32_t channel)
|
||||
{
|
||||
return (nrf_timer_int_mask_t)
|
||||
((uint32_t)NRF_TIMER_INT_COMPARE0_MASK << channel);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
nrf_timer_frequency_t frequency)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
nrf_timer_frequency_t frequency)
|
||||
{
|
||||
// The "frequency" parameter here is actually the prescaler value, and the
|
||||
// timer runs at the following frequency: f = 16 MHz / 2^prescaler.
|
||||
@@ -683,8 +712,8 @@ __STATIC_INLINE uint32_t nrf_timer_us_to_ticks(uint32_t time_us,
|
||||
return (uint32_t)ticks;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_timer_ms_to_ticks(uint32_t time_ms,
|
||||
nrf_timer_frequency_t frequency)
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_ms_to_ticks(uint32_t time_ms,
|
||||
nrf_timer_frequency_t frequency)
|
||||
{
|
||||
// The "frequency" parameter here is actually the prescaler value, and the
|
||||
// timer runs at the following frequency: f = 16000 kHz / 2^prescaler.
|
||||
@@ -694,7 +723,21 @@ __STATIC_INLINE uint32_t nrf_timer_ms_to_ticks(uint32_t time_ms,
|
||||
return (uint32_t)ticks;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#if defined(TIMER_ONESHOTEN_ONESHOTEN_Msk)
|
||||
NRF_STATIC_INLINE void nrf_timer_one_shot_enable(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
{
|
||||
p_reg->ONESHOTEN[cc_channel] = TIMER_ONESHOTEN_ONESHOTEN_Msk;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_one_shot_disable(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
{
|
||||
p_reg->ONESHOTEN[cc_channel] = 0;
|
||||
}
|
||||
#endif // defined(TIMER_ONESHOTEN_ONESHOTEN_Msk)
|
||||
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -117,8 +117,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_task_trigger(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_twi_task_trigger(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TWI task register.
|
||||
@@ -128,8 +128,8 @@ __STATIC_INLINE void nrf_twi_task_trigger(NRF_TWI_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_twi_task_address_get(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_task_address_get(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified TWI event.
|
||||
@@ -137,8 +137,8 @@ __STATIC_INLINE uint32_t * nrf_twi_task_address_get(NRF_TWI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the TWI event.
|
||||
@@ -149,8 +149,8 @@ __STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twi_event_check(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_twi_event_check(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TWI event register.
|
||||
@@ -160,8 +160,8 @@ __STATIC_INLINE bool nrf_twi_event_check(NRF_TWI_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_twi_event_address_get(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_event_address_get(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
@@ -169,8 +169,8 @@ __STATIC_INLINE uint32_t * nrf_twi_event_address_get(NRF_TWI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_shorts_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -178,8 +178,8 @@ __STATIC_INLINE void nrf_twi_shorts_enable(NRF_TWI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_shorts_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -187,8 +187,8 @@ __STATIC_INLINE void nrf_twi_shorts_disable(NRF_TWI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_int_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twi_int_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -196,34 +196,32 @@ __STATIC_INLINE void nrf_twi_int_enable(NRF_TWI_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_int_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twi_int_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] twi_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twi_int_enable_check(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_int_mask_t twi_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_int_enable_check(NRF_TWI_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the TWI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_enable(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twi_enable(NRF_TWI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TWI peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_disable(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twi_disable(NRF_TWI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring TWI pins.
|
||||
@@ -232,9 +230,9 @@ __STATIC_INLINE void nrf_twi_disable(NRF_TWI_Type * p_reg);
|
||||
* @param[in] scl_pin SCL pin number.
|
||||
* @param[in] sda_pin SDA pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin);
|
||||
NRF_STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SCL pin number.
|
||||
@@ -243,7 +241,7 @@ __STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
*
|
||||
* @return SCL pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SDA pin number.
|
||||
@@ -252,7 +250,7 @@ __STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type * p_reg);
|
||||
*
|
||||
* @return SDA pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the TWI master clock frequency.
|
||||
@@ -260,8 +258,8 @@ __STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency TWI frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_frequency_set(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_frequency_t frequency);
|
||||
NRF_STATIC_INLINE void nrf_twi_frequency_set(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the TWI error source.
|
||||
@@ -272,7 +270,7 @@ __STATIC_INLINE void nrf_twi_frequency_set(NRF_TWI_Type * p_reg,
|
||||
*
|
||||
* @return Mask with error source flags.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the address to be used in TWI transfers.
|
||||
@@ -280,7 +278,7 @@ __STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] address Address to be used in transfers.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_address_set(NRF_TWI_Type * p_reg, uint8_t address);
|
||||
NRF_STATIC_INLINE void nrf_twi_address_set(NRF_TWI_Type * p_reg, uint8_t address);
|
||||
|
||||
/**
|
||||
* @brief Function for reading data received by TWI.
|
||||
@@ -289,7 +287,7 @@ __STATIC_INLINE void nrf_twi_address_set(NRF_TWI_Type * p_reg, uint8_t address);
|
||||
*
|
||||
* @return Received data.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_twi_rxd_get(NRF_TWI_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_twi_rxd_get(NRF_TWI_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for writing data to be transmitted by TWI.
|
||||
@@ -297,7 +295,7 @@ __STATIC_INLINE uint8_t nrf_twi_rxd_get(NRF_TWI_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] data Data to be transmitted.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_txd_set(NRF_TWI_Type * p_reg, uint8_t data);
|
||||
NRF_STATIC_INLINE void nrf_twi_txd_set(NRF_TWI_Type * p_reg, uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified shortcuts.
|
||||
@@ -305,25 +303,25 @@ __STATIC_INLINE void nrf_twi_txd_set(NRF_TWI_Type * p_reg, uint8_t data);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twi_shorts_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_twi_task_trigger(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_twi_task_trigger(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_twi_task_address_get(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_task_address_get(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_task_t task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -332,61 +330,60 @@ __STATIC_INLINE void nrf_twi_event_clear(NRF_TWI_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twi_event_check(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_twi_event_check(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_twi_event_address_get(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_event_address_get(NRF_TWI_Type const * p_reg,
|
||||
nrf_twi_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_shorts_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_shorts_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_int_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twi_int_enable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_int_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twi_int_disable(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twi_int_enable_check(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_int_mask_t twi_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_int_enable_check(NRF_TWI_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & twi_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_enable(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twi_enable(NRF_TWI_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_disable(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twi_disable(NRF_TWI_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin)
|
||||
NRF_STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin)
|
||||
{
|
||||
#if defined(TWI_PSEL_SCL_CONNECT_Pos)
|
||||
p_reg->PSEL.SCL = scl_pin;
|
||||
@@ -401,7 +398,7 @@ __STATIC_INLINE void nrf_twi_pins_set(NRF_TWI_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type const * p_reg)
|
||||
{
|
||||
#if defined(TWI_PSEL_SCL_CONNECT_Pos)
|
||||
return p_reg->PSEL.SCL;
|
||||
@@ -410,7 +407,7 @@ __STATIC_INLINE uint32_t nrf_twi_scl_pin_get(NRF_TWI_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type const * p_reg)
|
||||
{
|
||||
#if defined(TWI_PSEL_SDA_CONNECT_Pos)
|
||||
return p_reg->PSEL.SDA;
|
||||
@@ -419,13 +416,13 @@ __STATIC_INLINE uint32_t nrf_twi_sda_pin_get(NRF_TWI_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_frequency_set(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_frequency_t frequency)
|
||||
NRF_STATIC_INLINE void nrf_twi_frequency_set(NRF_TWI_Type * p_reg,
|
||||
nrf_twi_frequency_t frequency)
|
||||
{
|
||||
p_reg->FREQUENCY = frequency;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg)
|
||||
{
|
||||
uint32_t error_source = p_reg->ERRORSRC;
|
||||
|
||||
@@ -435,28 +432,28 @@ __STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear(NRF_TWI_Type * p_reg)
|
||||
return error_source;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_address_set(NRF_TWI_Type * p_reg, uint8_t address)
|
||||
NRF_STATIC_INLINE void nrf_twi_address_set(NRF_TWI_Type * p_reg, uint8_t address)
|
||||
{
|
||||
p_reg->ADDRESS = address;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_twi_rxd_get(NRF_TWI_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_twi_rxd_get(NRF_TWI_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)p_reg->RXD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_txd_set(NRF_TWI_Type * p_reg, uint8_t data)
|
||||
NRF_STATIC_INLINE void nrf_twi_txd_set(NRF_TWI_Type * p_reg, uint8_t data)
|
||||
{
|
||||
p_reg->TXD = data;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twi_shorts_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twi_shorts_set(NRF_TWI_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS = mask;
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -98,22 +98,28 @@ typedef enum
|
||||
TWIM_INTENSET_RXSTARTED_Msk |
|
||||
TWIM_INTENSET_TXSTARTED_Msk |
|
||||
TWIM_INTENSET_LASTRX_Msk |
|
||||
TWIM_INTENSET_LASTTX_Msk ///< Interrupt on LASTTX event.
|
||||
TWIM_INTENSET_LASTTX_Msk ///< All TWIM interrupts.
|
||||
} nrf_twim_int_mask_t;
|
||||
|
||||
/** @brief TWIM master clock frequency. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps.
|
||||
NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps.
|
||||
NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400 ///< 400 kbps.
|
||||
NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps.
|
||||
NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps.
|
||||
NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400, ///< 400 kbps.
|
||||
#if defined(TWIM_FREQUENCY_FREQUENCY_K1000) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TWIM_FREQ_1000K = TWIM_FREQUENCY_FREQUENCY_K1000 ///< 1000 kbps.
|
||||
#endif
|
||||
} nrf_twim_frequency_t;
|
||||
|
||||
/** @brief TWIM error source. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TWIM_ERROR_ADDRESS_NACK = TWIM_ERRORSRC_ANACK_Msk, ///< NACK received after sending the address.
|
||||
NRF_TWIM_ERROR_DATA_NACK = TWIM_ERRORSRC_DNACK_Msk ///< NACK received after sending a data byte.
|
||||
NRF_TWIM_ERROR_ADDRESS_NACK = TWIM_ERRORSRC_ANACK_Msk, ///< NACK received after sending the address.
|
||||
NRF_TWIM_ERROR_DATA_NACK = TWIM_ERRORSRC_DNACK_Msk, ///< NACK received after sending a data byte.
|
||||
NRF_TWIM_ERROR_OVERRUN = TWIM_ERRORSRC_OVERRUN_Msk ///< Overrun error.
|
||||
/**< A new byte was received before the previous byte was
|
||||
* handled by peripheral. (previous data is lost). */
|
||||
} nrf_twim_error_t;
|
||||
|
||||
|
||||
@@ -123,8 +129,8 @@ typedef enum
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TWIM task register.
|
||||
@@ -134,8 +140,8 @@ __STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified task register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_task_address_get(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified TWIM event.
|
||||
@@ -143,8 +149,8 @@ __STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the TWIM event.
|
||||
@@ -155,8 +161,8 @@ __STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the specified TWIM event register.
|
||||
@@ -166,8 +172,8 @@ __STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_reg,
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_event_address_get(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
@@ -175,8 +181,8 @@ __STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
@@ -184,8 +190,8 @@ __STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -193,8 +199,8 @@ __STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -202,20 +208,18 @@ __STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] twim_int Interrupt to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_int_mask_t twim_int);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_int_enable_check(NRF_TWIM_Type const * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -226,9 +230,9 @@ __STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_subscribe_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_twim_subscribe_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -237,8 +241,8 @@ __STATIC_INLINE void nrf_twim_subscribe_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_subscribe_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_twim_subscribe_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -248,9 +252,9 @@ __STATIC_INLINE void nrf_twim_subscribe_clear(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_publish_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_twim_publish_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -259,8 +263,8 @@ __STATIC_INLINE void nrf_twim_publish_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_publish_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_twim_publish_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -268,14 +272,14 @@ __STATIC_INLINE void nrf_twim_publish_clear(NRF_TWIM_Type * p_reg,
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TWIM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring TWI pins.
|
||||
@@ -284,9 +288,9 @@ __STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg);
|
||||
* @param[in] scl_pin SCL pin number.
|
||||
* @param[in] sda_pin SDA pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin);
|
||||
NRF_STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the TWI master clock frequency.
|
||||
@@ -294,8 +298,8 @@ __STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency TWI frequency.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_frequency_t frequency);
|
||||
NRF_STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the TWI error source.
|
||||
@@ -306,7 +310,7 @@ __STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
|
||||
*
|
||||
* @return Mask with error source flags.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the address to be used in TWI transfers.
|
||||
@@ -314,8 +318,8 @@ __STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] address Address to be used in transfers.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t address);
|
||||
NRF_STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t address);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the transmit buffer.
|
||||
@@ -324,9 +328,9 @@ __STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_buffer Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the receive buffer.
|
||||
@@ -335,9 +339,9 @@ __STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_buffer Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified shortcuts.
|
||||
@@ -345,8 +349,17 @@ __STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be set.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the shortcut setting.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Current shortcut configuration.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_shorts_get(NRF_TWIM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the amount of transmitted bytes.
|
||||
@@ -355,7 +368,7 @@ __STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
|
||||
*
|
||||
* @return Amount of transmitted bytes.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the amount of received bytes.
|
||||
@@ -364,53 +377,53 @@ __STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg);
|
||||
*
|
||||
* @return Amount of received bytes.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_task_address_get(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)task);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -419,103 +432,102 @@ __STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_event_address_get(NRF_TWIM_Type const * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
{
|
||||
return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_int_mask_t twim_int)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_int_enable_check(NRF_TWIM_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & twim_int);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_twim_subscribe_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_twim_subscribe_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | TWIM_SUBSCRIBE_STARTRX_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_subscribe_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_twim_subscribe_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_publish_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_twim_publish_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | TWIM_PUBLISH_STOPPED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_publish_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_twim_publish_clear(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin)
|
||||
NRF_STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t scl_pin,
|
||||
uint32_t sda_pin)
|
||||
{
|
||||
p_reg->PSEL.SCL = scl_pin;
|
||||
p_reg->PSEL.SDA = sda_pin;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_frequency_t frequency)
|
||||
NRF_STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
|
||||
nrf_twim_frequency_t frequency)
|
||||
{
|
||||
p_reg->FREQUENCY = frequency;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
uint32_t error_source = p_reg->ERRORSRC;
|
||||
|
||||
@@ -525,64 +537,69 @@ __STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg)
|
||||
return error_source;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t address)
|
||||
NRF_STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t address)
|
||||
{
|
||||
p_reg->ADDRESS = address;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->TXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->TXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->RXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->RXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twim_shorts_get(NRF_TWIM_Type const * p_reg)
|
||||
{
|
||||
return p_reg->SHORTS;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type const * p_reg)
|
||||
{
|
||||
return p_reg->TXD.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RXD.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = 1;
|
||||
p_reg->TXD.LIST = TWIM_TXD_LIST_LIST_ArrayList << TWIM_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = 0;
|
||||
p_reg->TXD.LIST = TWIM_TXD_LIST_LIST_Disabled << TWIM_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = 1;
|
||||
p_reg->RXD.LIST = TWIM_RXD_LIST_LIST_ArrayList << TWIM_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = 0;
|
||||
p_reg->RXD.LIST = TWIM_RXD_LIST_LIST_Disabled << TWIM_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -101,16 +101,6 @@ typedef enum
|
||||
NRF_TWIS_CONFIG_ADDRESS01_MASK = TWIS_CONFIG_ADDRESS0_Msk | TWIS_CONFIG_ADDRESS1_Msk /**< Enable both address matching. */
|
||||
} nrf_twis_config_addr_mask_t;
|
||||
|
||||
/**
|
||||
* @brief Variable type to hold the amount of data for EasyDMA.
|
||||
*
|
||||
* Variable of the minimum size that can hold the amount of data to transfer.
|
||||
*
|
||||
* @note Defined to make it simple to change if EasyDMA is updated to support more data in
|
||||
* the future devices.
|
||||
*/
|
||||
typedef uint8_t nrf_twis_amount_t;
|
||||
|
||||
/**
|
||||
* @brief Smallest variable type to hold the TWI address.
|
||||
*
|
||||
@@ -121,14 +111,13 @@ typedef uint8_t nrf_twis_amount_t;
|
||||
*/
|
||||
typedef uint8_t nrf_twis_address_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for activating the specified TWIS task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * p_reg, nrf_twis_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * p_reg, nrf_twis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified TWIS task register.
|
||||
@@ -138,8 +127,8 @@ __STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * p_reg, nrf_twis_task_
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twis_task_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_task_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified event.
|
||||
@@ -147,8 +136,8 @@ __STATIC_INLINE uint32_t nrf_twis_task_address_get(NRF_TWIS_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event The specified event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the TWIS event.
|
||||
@@ -159,8 +148,8 @@ __STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg,
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twis_event_check(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_twis_event_check(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting and clearing the state of the specified event.
|
||||
@@ -173,8 +162,8 @@ __STATIC_INLINE bool nrf_twis_event_check(NRF_TWIS_Type const * p_reg,
|
||||
* @retval true The event was set.
|
||||
* @retval false The event was not set.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified TWIS event register.
|
||||
@@ -184,8 +173,8 @@ __STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twis_event_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_event_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a shortcut.
|
||||
@@ -193,7 +182,7 @@ __STATIC_INLINE uint32_t nrf_twis_event_address_get(NRF_TWIS_Type const * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing shortcuts.
|
||||
@@ -201,7 +190,7 @@ __STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * p_reg, uint32_t mask
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the shorts mask.
|
||||
@@ -212,7 +201,7 @@ __STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mas
|
||||
*
|
||||
* @return Flags of currently enabled shortcuts
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
@@ -220,18 +209,17 @@ __STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type const * p_reg);
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the specified interrupts.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true Any of the specified interrupts is enabled.
|
||||
* @retval false None of the specified interrupts is enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_twis_int_enable_check(NRF_TWIS_Type const * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_int_enable_check(NRF_TWIS_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
@@ -239,7 +227,7 @@ __STATIC_INLINE bool nrf_twis_int_enable_check(NRF_TWIS_Type const * p_reg, uint
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -250,9 +238,9 @@ __STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * p_reg, uint32_t mask);
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_subscribe_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_twis_subscribe_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -261,8 +249,8 @@ __STATIC_INLINE void nrf_twis_subscribe_set(NRF_TWIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_subscribe_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_twis_subscribe_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -272,9 +260,9 @@ __STATIC_INLINE void nrf_twis_subscribe_clear(NRF_TWIS_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_publish_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_twis_publish_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -283,8 +271,8 @@ __STATIC_INLINE void nrf_twis_publish_set(NRF_TWIS_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_publish_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_twis_publish_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
@@ -296,7 +284,7 @@ __STATIC_INLINE void nrf_twis_publish_clear(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Error source mask with values from @ref nrf_twis_error_t.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * const p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting information about which of the addresses matched.
|
||||
@@ -308,21 +296,21 @@ __STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * con
|
||||
*
|
||||
* @return Index of matched address.
|
||||
*/
|
||||
__STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling TWIS.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling TWIS.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring TWIS pins.
|
||||
@@ -331,7 +319,7 @@ __STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * p_reg);
|
||||
* @param[in] scl SCL pin number.
|
||||
* @param[in] sda SDA pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * p_reg, uint32_t scl, uint32_t sda);
|
||||
NRF_STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * p_reg, uint32_t scl, uint32_t sda);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the receive buffer.
|
||||
@@ -340,9 +328,9 @@ __STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * p_reg, uint32_t scl, uint
|
||||
* @param[in] p_buf Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_rx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function that prepares TWIS for receiving
|
||||
@@ -353,9 +341,9 @@ __STATIC_INLINE void nrf_twis_rx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
* @param[in] p_buf Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_rx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for getting number of bytes received in the last transaction.
|
||||
@@ -364,7 +352,7 @@ __STATIC_INLINE void nrf_twis_rx_prepare(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Amount of bytes received.
|
||||
* */
|
||||
__STATIC_INLINE size_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the transmit buffer.
|
||||
@@ -373,9 +361,9 @@ __STATIC_INLINE size_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
* @param[in] p_buf Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_tx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for preparing TWIS for transmitting.
|
||||
@@ -386,9 +374,9 @@ __STATIC_INLINE void nrf_twis_tx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
* @param[in] p_buf Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_tx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the number of bytes transmitted in the last transaction.
|
||||
@@ -397,7 +385,7 @@ __STATIC_INLINE void nrf_twis_tx_prepare(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Amount of bytes transmitted.
|
||||
*/
|
||||
__STATIC_INLINE size_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE size_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the slave address.
|
||||
@@ -411,9 +399,9 @@ __STATIC_INLINE size_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * p_reg);
|
||||
* @sa nrf_twis_config_address_set
|
||||
* @sa nrf_twis_config_address_get
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_address_set(NRF_TWIS_Type * p_reg,
|
||||
uint_fast8_t n,
|
||||
nrf_twis_address_t addr);
|
||||
NRF_STATIC_INLINE void nrf_twis_address_set(NRF_TWIS_Type * p_reg,
|
||||
uint_fast8_t n,
|
||||
nrf_twis_address_t addr);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving configured slave address.
|
||||
@@ -425,8 +413,8 @@ __STATIC_INLINE void nrf_twis_address_set(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Configured slave address.
|
||||
*/
|
||||
__STATIC_INLINE nrf_twis_address_t nrf_twis_address_get(NRF_TWIS_Type const * p_reg,
|
||||
uint_fast8_t n);
|
||||
NRF_STATIC_INLINE nrf_twis_address_t nrf_twis_address_get(NRF_TWIS_Type const * p_reg,
|
||||
uint_fast8_t n);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the device address configuration.
|
||||
@@ -436,8 +424,8 @@ __STATIC_INLINE nrf_twis_address_t nrf_twis_address_get(NRF_TWIS_Type const * p_
|
||||
*
|
||||
* @sa nrf_twis_address_set
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_config_address_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_config_addr_mask_t addr_mask);
|
||||
NRF_STATIC_INLINE void nrf_twis_config_address_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_config_addr_mask_t addr_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the device address configuration.
|
||||
@@ -446,7 +434,7 @@ __STATIC_INLINE void nrf_twis_config_address_set(NRF_TWIS_Type * p_r
|
||||
*
|
||||
* @return Mask of address indexes of what device should answer to.
|
||||
*/
|
||||
__STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get(
|
||||
NRF_STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get(
|
||||
NRF_TWIS_Type const * p_reg);
|
||||
|
||||
/**
|
||||
@@ -456,8 +444,8 @@ __STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get(
|
||||
* @param[in] orc Over-read character. Character clocked out in case of
|
||||
* over-read of the TXD buffer.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_twis_orc_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t orc);
|
||||
NRF_STATIC_INLINE void nrf_twis_orc_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t orc);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the over-read character.
|
||||
@@ -466,12 +454,43 @@ __STATIC_INLINE void nrf_twis_orc_set(NRF_TWIS_Type * p_reg,
|
||||
*
|
||||
* @return Over-read character configured for selected instance.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * p_reg);
|
||||
|
||||
#if defined(TWIS_TXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for enabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_list_enable(NRF_TWIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the TX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_list_disable(NRF_TWIS_Type * p_reg);
|
||||
#endif // defined(TWIS_TXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(TWIS_RXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for enabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_list_enable(NRF_TWIS_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the RX list feature.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_list_disable(NRF_TWIS_Type * p_reg);
|
||||
#endif // defined(TWIS_RXD_LIST_LIST_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/** @} */ /* End of nrf_twis_hal */
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
@@ -487,7 +506,7 @@ __STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * p_reg);
|
||||
* @attention Offset must be modulo 4 value. In other case, hardware fault can occur.
|
||||
* @return Pointer to the register.
|
||||
*/
|
||||
__STATIC_INLINE volatile uint32_t* nrf_twis_getRegPtr(NRF_TWIS_Type const * p_reg, uint32_t offset)
|
||||
NRF_STATIC_INLINE volatile uint32_t* nrf_twis_getRegPtr(NRF_TWIS_Type * p_reg, uint32_t offset)
|
||||
{
|
||||
return (volatile uint32_t*)((uint8_t *)p_reg + (uint32_t)offset);
|
||||
}
|
||||
@@ -502,8 +521,8 @@ __STATIC_INLINE volatile uint32_t* nrf_twis_getRegPtr(NRF_TWIS_Type const * p_re
|
||||
* @attention Offset must be modulo 4 value. In other case, hardware fault can occur.
|
||||
* @return Pointer to the register.
|
||||
*/
|
||||
__STATIC_INLINE volatile const uint32_t* nrf_twis_getRegPtr_c(NRF_TWIS_Type const * p_reg,
|
||||
uint32_t offset)
|
||||
NRF_STATIC_INLINE volatile const uint32_t* nrf_twis_getRegPtr_c(NRF_TWIS_Type const * p_reg,
|
||||
uint32_t offset)
|
||||
{
|
||||
return (volatile const uint32_t*)((uint8_t *)p_reg + (uint32_t)offset);
|
||||
}
|
||||
@@ -514,18 +533,18 @@ __STATIC_INLINE volatile const uint32_t* nrf_twis_getRegPtr_c(NRF_TWIS_Type cons
|
||||
*/
|
||||
|
||||
|
||||
__STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * p_reg, nrf_twis_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * p_reg, nrf_twis_task_t task)
|
||||
{
|
||||
*(nrf_twis_getRegPtr(p_reg, (uint32_t)task)) = 1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twis_task_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_task_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_twis_getRegPtr_c(p_reg, (uint32_t)task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg, nrf_twis_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg, nrf_twis_event_t event)
|
||||
{
|
||||
*(nrf_twis_getRegPtr(p_reg, (uint32_t)event)) = 0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -534,12 +553,12 @@ __STATIC_INLINE void nrf_twis_event_clear(NRF_TWIS_Type * p_reg, nrf_twis_event
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twis_event_check(NRF_TWIS_Type const * p_reg, nrf_twis_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_twis_event_check(NRF_TWIS_Type const * p_reg, nrf_twis_event_t event)
|
||||
{
|
||||
return (bool)*nrf_twis_getRegPtr_c(p_reg, (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg, nrf_twis_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg, nrf_twis_event_t event)
|
||||
{
|
||||
bool ret = nrf_twis_event_check(p_reg, event);
|
||||
if (ret)
|
||||
@@ -549,18 +568,18 @@ __STATIC_INLINE bool nrf_twis_event_get_and_clear(NRF_TWIS_Type * p_reg, nrf_tw
|
||||
return ret;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twis_event_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_event_address_get(NRF_TWIS_Type const * p_reg,
|
||||
nrf_twis_event_t event)
|
||||
{
|
||||
return (uint32_t)nrf_twis_getRegPtr_c(p_reg, (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
if (~0U == mask)
|
||||
{
|
||||
@@ -573,160 +592,187 @@ __STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * p_reg, uint32_t mas
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return p_reg->SHORTS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_twis_int_enable_check(NRF_TWIS_Type const * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_int_enable_check(NRF_TWIS_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * const p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_twis_subscribe_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_twis_subscribe_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | TWIS_SUBSCRIBE_STOP_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_subscribe_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_twis_subscribe_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_publish_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_twis_publish_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | TWIS_PUBLISH_STOPPED_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_publish_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_twis_publish_clear(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
uint32_t ret = p_reg->ERRORSRC;
|
||||
p_reg->ERRORSRC = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return (uint_fast8_t)p_reg->MATCH;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWIS_ENABLE_ENABLE_Enabled << TWIS_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (TWIS_ENABLE_ENABLE_Disabled << TWIS_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * p_reg, uint32_t scl, uint32_t sda)
|
||||
NRF_STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * p_reg, uint32_t scl, uint32_t sda)
|
||||
{
|
||||
p_reg->PSEL.SCL = scl;
|
||||
p_reg->PSEL.SDA = sda;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_rx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->RXD.PTR = (uint32_t)p_buf;
|
||||
p_reg->RXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_rx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t * p_buf,
|
||||
size_t length)
|
||||
{
|
||||
nrf_twis_rx_buffer_set(p_reg, p_buf, length);
|
||||
nrf_twis_task_trigger(p_reg, NRF_TWIS_TASK_PREPARERX);
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE size_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RXD.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_tx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_buffer_set(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->TXD.PTR = (uint32_t)p_buf;
|
||||
p_reg->TXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_tx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_prepare(NRF_TWIS_Type * p_reg,
|
||||
uint8_t const * p_buf,
|
||||
size_t length)
|
||||
{
|
||||
nrf_twis_tx_buffer_set(p_reg, p_buf, length);
|
||||
nrf_twis_task_trigger(p_reg, NRF_TWIS_TASK_PREPARETX);
|
||||
}
|
||||
|
||||
__STATIC_INLINE size_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE size_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return p_reg->TXD.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_address_set(NRF_TWIS_Type * p_reg,
|
||||
uint_fast8_t n,
|
||||
nrf_twis_address_t addr)
|
||||
NRF_STATIC_INLINE void nrf_twis_address_set(NRF_TWIS_Type * p_reg,
|
||||
uint_fast8_t n,
|
||||
nrf_twis_address_t addr)
|
||||
{
|
||||
p_reg->ADDRESS[n] = addr;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_twis_address_t nrf_twis_address_get(NRF_TWIS_Type const * p_reg, uint_fast8_t n)
|
||||
NRF_STATIC_INLINE nrf_twis_address_t nrf_twis_address_get(NRF_TWIS_Type const * p_reg,
|
||||
uint_fast8_t n)
|
||||
{
|
||||
return (nrf_twis_address_t)p_reg->ADDRESS[n];
|
||||
}
|
||||
__STATIC_INLINE void nrf_twis_config_address_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_config_addr_mask_t addr_mask)
|
||||
NRF_STATIC_INLINE void nrf_twis_config_address_set(NRF_TWIS_Type * p_reg,
|
||||
nrf_twis_config_addr_mask_t addr_mask)
|
||||
{
|
||||
/* This is the only configuration in TWIS - just write it without masking */
|
||||
p_reg->CONFIG = addr_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get(
|
||||
NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return (nrf_twis_config_addr_mask_t)(p_reg->CONFIG & TWIS_ADDRESS_ADDRESS_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_twis_orc_set(NRF_TWIS_Type * p_reg, uint8_t orc)
|
||||
NRF_STATIC_INLINE void nrf_twis_orc_set(NRF_TWIS_Type * p_reg, uint8_t orc)
|
||||
{
|
||||
p_reg->ORC = orc;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)p_reg->ORC;
|
||||
}
|
||||
|
||||
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
|
||||
#if defined(TWIS_TXD_LIST_LIST_Msk)
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_list_enable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = TWIS_TXD_LIST_LIST_ArrayList << TWIS_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_twis_tx_list_disable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->TXD.LIST = TWIS_TXD_LIST_LIST_Disabled << TWIS_TXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
#endif // defined(TWIS_TXD_LIST_LIST_Msk)
|
||||
|
||||
#if defined(TWIS_RXD_LIST_LIST_Msk)
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_list_enable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = TWIS_RXD_LIST_LIST_ArrayList << TWIS_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_twis_rx_list_disable(NRF_TWIS_Type * p_reg)
|
||||
{
|
||||
p_reg->RXD.LIST = TWIS_RXD_LIST_LIST_Disabled << TWIS_RXD_LIST_LIST_Pos;
|
||||
}
|
||||
#endif // defined(TWIS_RXD_LIST_LIST_Msk)
|
||||
|
||||
#endif /* NRF_DECLARE_ONLY */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -126,13 +126,44 @@ typedef enum
|
||||
NRF_UART_HWFC_ENABLED = UART_CONFIG_HWFC_Enabled, /**< Hardware flow control enabled. */
|
||||
} nrf_uart_hwfc_t;
|
||||
|
||||
#if defined(UART_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Types of UART stop bit modes. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_UART_STOP_ONE = UART_CONFIG_STOP_One << UART_CONFIG_STOP_Pos, ///< One stop bit.
|
||||
NRF_UART_STOP_TWO = UART_CONFIG_STOP_Two << UART_CONFIG_STOP_Pos ///< Two stop bits.
|
||||
} nrf_uart_stop_t;
|
||||
#endif
|
||||
|
||||
#if defined(UART_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Types of UART parity types. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_UART_PARITYTYPE_EVEN = UART_CONFIG_PARITYTYPE_Even << UART_CONFIG_PARITYTYPE_Pos, /**< Parity even. */
|
||||
NRF_UART_PARITYTYPE_ODD = UART_CONFIG_PARITYTYPE_Odd << UART_CONFIG_PARITYTYPE_Pos, /**< Parity odd. */
|
||||
} nrf_uart_paritytype_t;
|
||||
#endif
|
||||
|
||||
/** @brief Structure for UART transmission configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_uart_hwfc_t hwfc; ///< Flow control configuration.
|
||||
nrf_uart_parity_t parity; ///< Parity configuration.
|
||||
#if defined(UART_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_uart_stop_t stop; ///< Stop bits.
|
||||
#endif
|
||||
#if defined(UART_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_uart_paritytype_t paritytype; ///< Parity type.
|
||||
#endif
|
||||
} nrf_uart_config_t;
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified UART event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the UART event.
|
||||
@@ -143,7 +174,7 @@ __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type const * p_reg, nrf_uart_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified UART event register.
|
||||
@@ -153,187 +184,187 @@ __STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_
|
||||
*
|
||||
* @return Address of the specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
|
||||
nrf_uart_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type const * p_reg,
|
||||
nrf_uart_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupt.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a given interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_int_enable_check(NRF_UART_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting error source mask. Function is clearing error source flags after reading.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Mask with error source flags.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling UART.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling UART.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring TX/RX pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param pseltxd TXD pin number.
|
||||
* @param pselrxd RXD pin number.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pseltxd TXD pin number.
|
||||
* @param[in] pselrxd RXD pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd);
|
||||
NRF_STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg,
|
||||
uint32_t pseltxd,
|
||||
uint32_t pselrxd);
|
||||
|
||||
/**
|
||||
* @brief Function for disconnecting TX/RX pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting TX pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return TX pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RX pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return RX pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RTS pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return RTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting CTS pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return CTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring flow control pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param pselrts RTS pin number.
|
||||
* @param pselcts CTS pin number.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pselrts RTS pin number.
|
||||
* @param[in] pselcts CTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts);
|
||||
NRF_STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts);
|
||||
|
||||
/**
|
||||
* @brief Function for disconnecting flow control pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for reading RX data.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Received byte.
|
||||
*/
|
||||
__STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting Tx data.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param txd Byte.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] txd Byte.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd);
|
||||
NRF_STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd);
|
||||
|
||||
/**
|
||||
* @brief Function for starting an UART task.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified task register.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type const * p_reg,
|
||||
nrf_uart_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring UART.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param hwfc Hardware flow control. Enabled if true.
|
||||
* @param parity Parity. Included if true.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_cfg Pointer to UART settings structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
|
||||
nrf_uart_parity_t parity,
|
||||
nrf_uart_hwfc_t hwfc);
|
||||
NRF_STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
|
||||
nrf_uart_config_t const * p_cfg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting UART baud rate.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param baudrate Baud rate.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] baudrate Baud rate.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate);
|
||||
NRF_STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
|
||||
__STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -342,50 +373,52 @@ __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type const * p_reg, nrf_uart_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
|
||||
nrf_uart_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type const * p_reg,
|
||||
nrf_uart_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_int_enable_check(NRF_UART_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg)
|
||||
{
|
||||
uint32_t errsrc_mask = p_reg->ERRORSRC;
|
||||
p_reg->ERRORSRC = errsrc_mask;
|
||||
return errsrc_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = UART_ENABLE_ENABLE_Enabled;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = UART_ENABLE_ENABLE_Disabled;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd)
|
||||
NRF_STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg,
|
||||
uint32_t pseltxd,
|
||||
uint32_t pselrxd)
|
||||
{
|
||||
#if defined(UART_PSEL_RXD_CONNECT_Pos)
|
||||
p_reg->PSEL.RXD = pselrxd;
|
||||
@@ -399,12 +432,12 @@ __STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t psel
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg)
|
||||
{
|
||||
nrf_uart_txrx_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type const * p_reg)
|
||||
{
|
||||
#if defined(UART_PSEL_TXD_CONNECT_Pos)
|
||||
return p_reg->PSEL.TXD;
|
||||
@@ -413,7 +446,7 @@ __STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type const * p_reg)
|
||||
{
|
||||
#if defined(UART_PSEL_RXD_CONNECT_Pos)
|
||||
return p_reg->PSEL.RXD;
|
||||
@@ -422,7 +455,7 @@ __STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type const * p_reg)
|
||||
{
|
||||
#if defined(UART_PSEL_RTS_CONNECT_Pos)
|
||||
return p_reg->PSEL.RTS;
|
||||
@@ -431,7 +464,7 @@ __STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type const * p_reg)
|
||||
{
|
||||
#if defined(UART_PSEL_RTS_CONNECT_Pos)
|
||||
return p_reg->PSEL.CTS;
|
||||
@@ -440,7 +473,9 @@ __STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg)
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, uint32_t pselrts, uint32_t pselcts)
|
||||
NRF_STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts)
|
||||
{
|
||||
#if defined(UART_PSEL_RTS_CONNECT_Pos)
|
||||
p_reg->PSEL.RTS = pselrts;
|
||||
@@ -455,43 +490,50 @@ __STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, uint32_t psel
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg)
|
||||
{
|
||||
nrf_uart_hwfc_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RXD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd)
|
||||
NRF_STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd)
|
||||
{
|
||||
p_reg->TXD = txd;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type const * p_reg,
|
||||
nrf_uart_task_t task)
|
||||
{
|
||||
return (uint32_t)p_reg + (uint32_t)task;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
|
||||
nrf_uart_parity_t parity,
|
||||
nrf_uart_hwfc_t hwfc)
|
||||
NRF_STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
|
||||
nrf_uart_config_t const * p_cfg)
|
||||
{
|
||||
p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc;
|
||||
p_reg->CONFIG = (uint32_t)p_cfg->parity
|
||||
#if defined(UART_CONFIG_STOP_Msk)
|
||||
| (uint32_t)p_cfg->stop
|
||||
#endif
|
||||
#if defined(UART_CONFIG_PARITYTYPE_Msk)
|
||||
| (uint32_t)p_cfg->paritytype
|
||||
#endif
|
||||
| (uint32_t)p_cfg->hwfc;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate)
|
||||
NRF_STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate)
|
||||
{
|
||||
p_reg->BAUDRATE = baudrate;
|
||||
}
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -499,4 +541,4 @@ __STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_bau
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //NRF_UART_H__
|
||||
#endif // NRF_UART_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -143,14 +143,44 @@ typedef enum
|
||||
NRF_UARTE_HWFC_ENABLED = UARTE_CONFIG_HWFC_Enabled << UARTE_CONFIG_HWFC_Pos ///< Hardware flow control enabled.
|
||||
} nrf_uarte_hwfc_t;
|
||||
|
||||
#if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Types of UARTE stop bit modes. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_UARTE_STOP_ONE = UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos, ///< One stop bit.
|
||||
NRF_UARTE_STOP_TWO = UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos ///< Two stop bits.
|
||||
} nrf_uarte_stop_t;
|
||||
#endif
|
||||
|
||||
#if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Types of UARTE parity types. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_UARTE_PARITYTYPE_EVEN = UARTE_CONFIG_PARITYTYPE_Even << UARTE_CONFIG_PARITYTYPE_Pos, ///< Parity even.
|
||||
NRF_UARTE_PARITYTYPE_ODD = UARTE_CONFIG_PARITYTYPE_Odd << UARTE_CONFIG_PARITYTYPE_Pos, ///< Parity odd.
|
||||
} nrf_uarte_paritytype_t;
|
||||
#endif
|
||||
|
||||
/** @brief Structure for UARTE transmission configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_uarte_hwfc_t hwfc; ///< Flow control configuration.
|
||||
nrf_uarte_parity_t parity; ///< Parity configuration.
|
||||
#if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_uarte_stop_t stop; ///< Stop bits.
|
||||
#endif
|
||||
#if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_uarte_paritytype_t paritytype; ///< Parity type.
|
||||
#endif
|
||||
} nrf_uarte_config_t;
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified UARTE event.
|
||||
* @brief Function for clearing a specific UARTE event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the UARTE event.
|
||||
@@ -161,7 +191,8 @@ __STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_eve
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event);
|
||||
NRF_STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified UARTE event register.
|
||||
@@ -171,51 +202,50 @@ __STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type * p_reg, nrf_uarte_eve
|
||||
*
|
||||
* @return Address of specified event register.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling UARTE shortcuts.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Shortcuts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling UARTE shortcuts.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Shortcuts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling UARTE interrupts.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be enabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the specified interrupt.
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be checked.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @retval true The interrupt is enabled.
|
||||
* @retval false The interrupt is not enabled.
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
__STATIC_INLINE bool nrf_uarte_int_enable_check(NRF_UARTE_Type * p_reg, nrf_uarte_int_mask_t mask);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_int_enable_check(NRF_UARTE_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param mask Mask of interrupts to be disabled.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
NRF_STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
|
||||
|
||||
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
@@ -226,9 +256,9 @@ __STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask
|
||||
* @param[in] task Task for which to set the configuration.
|
||||
* @param[in] channel Channel through which to subscribe events.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the subscribe configuration for a given
|
||||
@@ -237,8 +267,8 @@ __STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the publish configuration for a given
|
||||
@@ -248,9 +278,9 @@ __STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
|
||||
* @param[in] event Event for which to set the configuration.
|
||||
* @param[in] channel Channel through which to publish the event.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event,
|
||||
uint8_t channel);
|
||||
NRF_STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event,
|
||||
uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the publish configuration for a given
|
||||
@@ -259,141 +289,141 @@ __STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type * p_reg,
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event for which to clear the configuration.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event);
|
||||
NRF_STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event);
|
||||
#endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for getting error source mask. Function is clearing error source flags after reading.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Mask with error source flags.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling UARTE.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling UARTE.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring TX/RX pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param pseltxd TXD pin number.
|
||||
* @param pselrxd RXD pin number.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pseltxd TXD pin number.
|
||||
* @param[in] pselrxd RXD pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pseltxd,
|
||||
uint32_t pselrxd);
|
||||
NRF_STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pseltxd,
|
||||
uint32_t pselrxd);
|
||||
|
||||
/**
|
||||
* @brief Function for disconnecting TX/RX pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting TX pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return TX pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RX pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return RX pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RTS pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return RTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting CTS pin.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return CTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring flow control pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param pselrts RTS pin number.
|
||||
* @param pselcts CTS pin number.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] pselrts RTS pin number.
|
||||
* @param[in] pselcts CTS pin number.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts);
|
||||
NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts);
|
||||
|
||||
/**
|
||||
* @brief Function for disconnecting flow control pins.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for starting an UARTE task.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task);
|
||||
NRF_STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of the specified task register.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param task Task.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for configuring UARTE.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param hwfc Hardware flow control. Enabled if true.
|
||||
* @param parity Parity. Included if true.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_cfg Pointer to UARTE settings structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_parity_t parity,
|
||||
nrf_uarte_hwfc_t hwfc);
|
||||
NRF_STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_config_t const * p_cfg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting UARTE baud rate.
|
||||
*
|
||||
* @param p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param baudrate Baud rate.
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] baudrate Baud rate.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate);
|
||||
NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_baudrate_t baudrate);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the transmit buffer.
|
||||
@@ -402,9 +432,9 @@ __STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_
|
||||
* @param[in] p_buffer Pointer to the buffer with data to send.
|
||||
* @param[in] length Maximum number of data bytes to transmit.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for getting number of bytes transmitted in the last transaction.
|
||||
@@ -413,7 +443,7 @@ __STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
*
|
||||
* @retval Amount of bytes transmitted.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the receive buffer.
|
||||
@@ -422,9 +452,9 @@ __STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type * p_reg);
|
||||
* @param[in] p_buffer Pointer to the buffer for received data.
|
||||
* @param[in] length Maximum number of data bytes to receive.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for getting number of bytes received in the last transaction.
|
||||
@@ -433,10 +463,10 @@ __STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
*
|
||||
* @retval Amount of bytes received.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type * p_reg);
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type const * p_reg);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event)
|
||||
#ifndef NRF_DECLARE_ONLY
|
||||
NRF_STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
@@ -445,179 +475,191 @@ __STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_eve
|
||||
#endif
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event)
|
||||
NRF_STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrf_uarte_int_enable_check(NRF_UARTE_Type * p_reg, nrf_uarte_int_mask_t mask)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_int_enable_check(NRF_UARTE_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return (bool)(p_reg->INTENSET & mask);
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
NRF_STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENCLR = mask;
|
||||
}
|
||||
|
||||
#if defined(DPPI_PRESENT)
|
||||
__STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
|
||||
((uint32_t)channel | UARTE_SUBSCRIBE_STARTRX_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event,
|
||||
uint8_t channel)
|
||||
NRF_STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event,
|
||||
uint8_t channel)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
|
||||
((uint32_t)channel | UARTE_PUBLISH_CTS_EN_Msk);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event)
|
||||
NRF_STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
|
||||
}
|
||||
#endif // defined(DPPI_PRESENT)
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg)
|
||||
{
|
||||
uint32_t errsrc_mask = p_reg->ERRORSRC;
|
||||
p_reg->ERRORSRC = errsrc_mask;
|
||||
return errsrc_mask;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = UARTE_ENABLE_ENABLE_Enabled;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = UARTE_ENABLE_ENABLE_Disabled;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd)
|
||||
NRF_STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pseltxd,
|
||||
uint32_t pselrxd)
|
||||
{
|
||||
p_reg->PSEL.TXD = pseltxd;
|
||||
p_reg->PSEL.RXD = pselrxd;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg)
|
||||
{
|
||||
nrf_uarte_txrx_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PSEL.TXD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PSEL.RXD;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PSEL.RTS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->PSEL.CTS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg, uint32_t pselrts, uint32_t pselcts)
|
||||
NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg,
|
||||
uint32_t pselrts,
|
||||
uint32_t pselcts)
|
||||
{
|
||||
p_reg->PSEL.RTS = pselrts;
|
||||
p_reg->PSEL.CTS = pselcts;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg)
|
||||
{
|
||||
nrf_uarte_hwfc_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task)
|
||||
NRF_STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type const * p_reg,
|
||||
nrf_uarte_task_t task)
|
||||
{
|
||||
return (uint32_t)p_reg + (uint32_t)task;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_parity_t parity,
|
||||
nrf_uarte_hwfc_t hwfc)
|
||||
NRF_STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg,
|
||||
nrf_uarte_config_t const * p_cfg)
|
||||
{
|
||||
p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc;
|
||||
p_reg->CONFIG = (uint32_t)p_cfg->parity
|
||||
#if defined(UARTE_CONFIG_STOP_Msk)
|
||||
| (uint32_t)p_cfg->stop
|
||||
#endif
|
||||
#if defined(UARTE_CONFIG_PARITYTYPE_Msk)
|
||||
| (uint32_t)p_cfg->paritytype
|
||||
#endif
|
||||
| (uint32_t)p_cfg->hwfc;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate)
|
||||
NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate)
|
||||
{
|
||||
p_reg->BAUDRATE = baudrate;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t const * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->TXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->TXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->TXD.AMOUNT;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
|
||||
uint8_t * p_buffer,
|
||||
size_t length)
|
||||
{
|
||||
p_reg->RXD.PTR = (uint32_t)p_buffer;
|
||||
p_reg->RXD.MAXCNT = length;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type * p_reg)
|
||||
NRF_STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type const * p_reg)
|
||||
{
|
||||
return p_reg->RXD.AMOUNT;
|
||||
}
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
#endif // NRF_DECLARE_ONLY
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -625,4 +667,4 @@ __STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type * p_reg)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //NRF_UARTE_H__
|
||||
#endif // NRF_UARTE_H__
|
||||
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user