diff options
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx')
37 files changed, 8543 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/apply_old_config.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/apply_old_config.h new file mode 100644 index 0000000..62ef475 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/apply_old_config.h @@ -0,0 +1,1385 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 APPLY_OLD_CONFIG_H__ +#define APPLY_OLD_CONFIG_H__ + +//------------------------------------------------------------------------------ +// Peripheral Resource Sharing (PRS) + +#if defined(PERIPHERAL_RESOURCE_SHARING_ENABLED) + +#define NRFX_PRS_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_0_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_1_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_2_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_3_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED +#define NRFX_PRS_BOX_4_ENABLED PERIPHERAL_RESOURCE_SHARING_ENABLED + +#if defined(COMMON_CONFIG_LOG_ENABLED) +#undef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED COMMON_CONFIG_LOG_ENABLED +#endif +#if defined(COMMON_CONFIG_LOG_LEVEL) +#undef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL COMMON_CONFIG_LOG_LEVEL +#endif +#if defined(COMMON_CONFIG_INFO_COLOR) +#undef NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR COMMON_CONFIG_INFO_COLOR +#endif +#if defined(COMMON_CONFIG_DEBUG_COLOR) +#undef NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR COMMON_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PERIPHERAL_RESOURCE_SHARING_ENABLED) + +//------------------------------------------------------------------------------ +// CLOCK + +#if defined(CLOCK_ENABLED) + +#undef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED CLOCK_ENABLED + +#if defined(CLOCK_CONFIG_LF_SRC) +#undef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC CLOCK_CONFIG_LF_SRC +#endif +#if defined(CLOCK_CONFIG_IRQ_PRIORITY) +#undef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY CLOCK_CONFIG_IRQ_PRIORITY +#endif + +#if defined(CLOCK_CONFIG_LOG_ENABLED) +#undef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED CLOCK_CONFIG_LOG_ENABLED +#endif +#if defined(CLOCK_CONFIG_LOG_LEVEL) +#undef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL +#endif +#if defined(CLOCK_CONFIG_INFO_COLOR) +#undef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR +#endif +#if defined(CLOCK_CONFIG_DEBUG_COLOR) +#undef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(CLOCK_ENABLED) + +//------------------------------------------------------------------------------ +// COMP + +#if defined(COMP_ENABLED) + +#undef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED COMP_ENABLED + +#if defined(COMP_CONFIG_REF) +#undef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF COMP_CONFIG_REF +#endif +#if defined(COMP_CONFIG_MAIN_MODE) +#undef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE COMP_CONFIG_MAIN_MODE +#endif +#if defined(COMP_CONFIG_SPEED_MODE) +#undef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE COMP_CONFIG_SPEED_MODE +#endif +#if defined(COMP_CONFIG_HYST) +#undef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST COMP_CONFIG_HYST +#endif +#if defined(COMP_CONFIG_ISOURCE) +#undef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE COMP_CONFIG_ISOURCE +#endif +#if defined(COMP_CONFIG_INPUT) +#undef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT COMP_CONFIG_INPUT +#endif +#if defined(COMP_CONFIG_IRQ_PRIORITY) +#undef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY COMP_CONFIG_IRQ_PRIORITY +#endif + +#if defined(COMP_CONFIG_LOG_ENABLED) +#undef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED COMP_CONFIG_LOG_ENABLED +#endif +#if defined(COMP_CONFIG_LOG_LEVEL) +#undef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL COMP_CONFIG_LOG_LEVEL +#endif +#if defined(COMP_CONFIG_INFO_COLOR) +#undef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR COMP_CONFIG_INFO_COLOR +#endif +#if defined(COMP_CONFIG_DEBUG_COLOR) +#undef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR COMP_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(COMP_ENABLED) + +//------------------------------------------------------------------------------ +// GPIOTE + +#if defined(GPIOTE_ENABLED) + +#undef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED GPIOTE_ENABLED + +#if defined(GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS) +#undef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#endif + +#if defined(GPIOTE_CONFIG_IRQ_PRIORITY) +#undef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY GPIOTE_CONFIG_IRQ_PRIORITY +#endif + +#if defined(GPIOTE_CONFIG_LOG_ENABLED) +#undef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED GPIOTE_CONFIG_LOG_ENABLED +#endif +#if defined(GPIOTE_CONFIG_LOG_LEVEL) +#undef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL GPIOTE_CONFIG_LOG_LEVEL +#endif +#if defined(GPIOTE_CONFIG_INFO_COLOR) +#undef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR GPIOTE_CONFIG_INFO_COLOR +#endif +#if defined(GPIOTE_CONFIG_DEBUG_COLOR) +#undef NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR GPIOTE_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(GPIOTE_ENABLED) + +//------------------------------------------------------------------------------ +// I2S + +#if defined(I2S_ENABLED) + +#undef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED I2S_ENABLED + +#if defined(I2S_CONFIG_SCK_PIN) +#undef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN I2S_CONFIG_SCK_PIN +#endif +#if defined(I2S_CONFIG_LRCK_PIN) +#undef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN I2S_CONFIG_LRCK_PIN +#endif +#if defined(I2S_CONFIG_MCK_PIN) +#undef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN I2S_CONFIG_MCK_PIN +#endif +#if defined(I2S_CONFIG_SDOUT_PIN) +#undef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN I2S_CONFIG_SDOUT_PIN +#endif +#if defined(I2S_CONFIG_SDIN_PIN) +#undef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN I2S_CONFIG_SDIN_PIN +#endif + +#if defined(I2S_CONFIG_MASTER) +#undef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER I2S_CONFIG_MASTER +#endif +#if defined(I2S_CONFIG_FORMAT) +#undef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT I2S_CONFIG_FORMAT +#endif +#if defined(I2S_CONFIG_ALIGN) +#undef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN I2S_CONFIG_ALIGN +#endif +#if defined(I2S_CONFIG_SWIDTH) +#undef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH I2S_CONFIG_SWIDTH +#endif +#if defined(I2S_CONFIG_CHANNELS) +#undef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS I2S_CONFIG_CHANNELS +#endif +#if defined(I2S_CONFIG_MCK_SETUP) +#undef NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP I2S_CONFIG_MCK_SETUP +#endif +#if defined(I2S_CONFIG_RATIO) +#undef NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO I2S_CONFIG_RATIO +#endif +#if defined(I2S_CONFIG_IRQ_PRIORITY) +#undef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY I2S_CONFIG_IRQ_PRIORITY +#endif + +#if defined(I2S_CONFIG_LOG_ENABLED) +#undef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED I2S_CONFIG_LOG_ENABLED +#endif +#if defined(I2S_CONFIG_LOG_LEVEL) +#undef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL I2S_CONFIG_LOG_LEVEL +#endif +#if defined(I2S_CONFIG_INFO_COLOR) +#undef NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR I2S_CONFIG_INFO_COLOR +#endif +#if defined(I2S_CONFIG_DEBUG_COLOR) +#undef NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR I2S_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(I2S_ENABLED) + +//------------------------------------------------------------------------------ +// LPCOMP + +#if defined(LPCOMP_ENABLED) + +#undef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED LPCOMP_ENABLED + +#if defined(LPCOMP_CONFIG_REFERENCE) +#undef NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE LPCOMP_CONFIG_REFERENCE +#endif +#if defined(LPCOMP_CONFIG_DETECTION) +#undef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION LPCOMP_CONFIG_DETECTION +#endif +#if defined(LPCOMP_CONFIG_INPUT) +#undef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT LPCOMP_CONFIG_INPUT +#endif +#if defined(LPCOMP_CONFIG_HYST) +#undef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST LPCOMP_CONFIG_HYST +#endif +#if defined(LPCOMP_CONFIG_IRQ_PRIORITY) +#undef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY LPCOMP_CONFIG_IRQ_PRIORITY +#endif + +#if defined(LPCOMP_CONFIG_LOG_ENABLED) +#undef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED LPCOMP_CONFIG_LOG_ENABLED +#endif +#if defined(LPCOMP_CONFIG_LOG_LEVEL) +#undef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL LPCOMP_CONFIG_LOG_LEVEL +#endif +#if defined(LPCOMP_CONFIG_INFO_COLOR) +#undef NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR LPCOMP_CONFIG_INFO_COLOR +#endif +#if defined(LPCOMP_CONFIG_DEBUG_COLOR) +#undef NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR LPCOMP_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(LPCOMP_ENABLED) + +//------------------------------------------------------------------------------ +// PDM + +#if defined(PDM_ENABLED) + +#undef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED PDM_ENABLED + +#if defined(PDM_CONFIG_MODE) +#undef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE PDM_CONFIG_MODE +#endif +#if defined(PDM_CONFIG_EDGE) +#undef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE PDM_CONFIG_EDGE +#endif +#if defined(PDM_CONFIG_CLOCK_FREQ) +#undef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ PDM_CONFIG_CLOCK_FREQ +#endif +#if defined(PDM_CONFIG_IRQ_PRIORITY) +#undef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY PDM_CONFIG_IRQ_PRIORITY +#endif + +#if defined(PDM_CONFIG_LOG_ENABLED) +#undef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED PDM_CONFIG_LOG_ENABLED +#endif +#if defined(PDM_CONFIG_LOG_LEVEL) +#undef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL PDM_CONFIG_LOG_LEVEL +#endif +#if defined(PDM_CONFIG_INFO_COLOR) +#undef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR PDM_CONFIG_INFO_COLOR +#endif +#if defined(PDM_CONFIG_DEBUG_COLOR) +#undef NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR PDM_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PDM_ENABLED) + +//------------------------------------------------------------------------------ +// POWER + +#if defined(POWER_ENABLED) + +#undef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED POWER_ENABLED + +#if defined(POWER_CONFIG_IRQ_PRIORITY) +#undef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY POWER_CONFIG_IRQ_PRIORITY +#endif + +#if defined(POWER_CONFIG_DEFAULT_DCDCEN) +#undef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN POWER_CONFIG_DEFAULT_DCDCEN +#endif +#if defined(POWER_CONFIG_DEFAULT_DCDCENHV) +#undef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV POWER_CONFIG_DEFAULT_DCDCENHV +#endif + +#endif // defined(POWER_ENABLED) + +//------------------------------------------------------------------------------ +// PPI + +#if defined(PPI_ENABLED) + +#undef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED PPI_ENABLED + +#if defined(PPI_CONFIG_LOG_ENABLED) +#undef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED PPI_CONFIG_LOG_ENABLED +#endif +#if defined(PPI_CONFIG_LOG_LEVEL) +#undef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL PPI_CONFIG_LOG_LEVEL +#endif +#if defined(PPI_CONFIG_INFO_COLOR) +#undef NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR PPI_CONFIG_INFO_COLOR +#endif +#if defined(PPI_CONFIG_DEBUG_COLOR) +#undef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR PPI_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(PPI_ENABLED) + +//------------------------------------------------------------------------------ +// PWM + +#if defined(PWM_ENABLED) + +#undef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED PWM_ENABLED + +#if defined(PWM0_ENABLED) +#undef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED PWM0_ENABLED +#endif +#if defined(PWM1_ENABLED) +#undef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED PWM1_ENABLED +#endif +#if defined(PWM2_ENABLED) +#undef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED PWM2_ENABLED +#endif +#if defined(PWM3_ENABLED) +#undef NRFX_PWM3_ENABLED +#define NRFX_PWM3_ENABLED PWM3_ENABLED +#endif + +#if defined(PWM_DEFAULT_CONFIG_OUT0_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN PWM_DEFAULT_CONFIG_OUT0_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT1_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN PWM_DEFAULT_CONFIG_OUT1_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT2_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN PWM_DEFAULT_CONFIG_OUT2_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_OUT3_PIN) +#undef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN PWM_DEFAULT_CONFIG_OUT3_PIN +#endif +#if defined(PWM_DEFAULT_CONFIG_BASE_CLOCK) +#undef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK PWM_DEFAULT_CONFIG_BASE_CLOCK +#endif +#if defined(PWM_DEFAULT_CONFIG_COUNT_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE PWM_DEFAULT_CONFIG_COUNT_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_TOP_VALUE) +#undef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE PWM_DEFAULT_CONFIG_TOP_VALUE +#endif +#if defined(PWM_DEFAULT_CONFIG_LOAD_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE PWM_DEFAULT_CONFIG_LOAD_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_STEP_MODE) +#undef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE PWM_DEFAULT_CONFIG_STEP_MODE +#endif +#if defined(PWM_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(PWM_CONFIG_LOG_ENABLED) +#undef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED PWM_CONFIG_LOG_ENABLED +#endif +#if defined(PWM_CONFIG_LOG_LEVEL) +#undef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL PWM_CONFIG_LOG_LEVEL +#endif +#if defined(PWM_CONFIG_INFO_COLOR) +#undef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR PWM_CONFIG_INFO_COLOR +#endif +#if defined(PWM_CONFIG_DEBUG_COLOR) +#undef NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR PWM_CONFIG_DEBUG_COLOR +#endif + +#if defined(PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif +#if defined(PWM_NRF52_ANOMALY_109_EGU_INSTANCE) +#undef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#endif + +#endif // defined(PWM_ENABLED) + +//------------------------------------------------------------------------------ +// QDEC + +#if defined(QDEC_ENABLED) + +#undef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED QDEC_ENABLED + +#if defined(QDEC_CONFIG_REPORTPER) +#undef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER QDEC_CONFIG_REPORTPER +#endif +#if defined(QDEC_CONFIG_SAMPLEPER) +#undef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER QDEC_CONFIG_SAMPLEPER +#endif +#if defined(QDEC_CONFIG_PIO_A) +#undef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A QDEC_CONFIG_PIO_A +#endif +#if defined(QDEC_CONFIG_PIO_B) +#undef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B QDEC_CONFIG_PIO_B +#endif +#if defined(QDEC_CONFIG_PIO_LED) +#undef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED QDEC_CONFIG_PIO_LED +#endif +#if defined(QDEC_CONFIG_LEDPRE) +#undef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE QDEC_CONFIG_LEDPRE +#endif +#if defined(QDEC_CONFIG_LEDPOL) +#undef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL QDEC_CONFIG_LEDPOL +#endif +#if defined(QDEC_CONFIG_DBFEN) +#undef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN QDEC_CONFIG_DBFEN +#endif +#if defined(QDEC_CONFIG_SAMPLE_INTEN) +#undef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN QDEC_CONFIG_SAMPLE_INTEN +#endif +#if defined(QDEC_CONFIG_IRQ_PRIORITY) +#undef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY QDEC_CONFIG_IRQ_PRIORITY +#endif + +#if defined(QDEC_CONFIG_LOG_ENABLED) +#undef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED QDEC_CONFIG_LOG_ENABLED +#endif +#if defined(QDEC_CONFIG_LOG_LEVEL) +#undef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL QDEC_CONFIG_LOG_LEVEL +#endif +#if defined(QDEC_CONFIG_INFO_COLOR) +#undef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR QDEC_CONFIG_INFO_COLOR +#endif +#if defined(QDEC_CONFIG_DEBUG_COLOR) +#undef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR QDEC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(QDEC_ENABLED) + +//------------------------------------------------------------------------------ +// QSPI + +#if defined(QSPI_ENABLED) + +#undef NRFX_QSPI_ENABLED +#define NRFX_QSPI_ENABLED QSPI_ENABLED + +#if defined(QSPI_CONFIG_SCK_DELAY) +#undef NRFX_QSPI_CONFIG_SCK_DELAY +#define NRFX_QSPI_CONFIG_SCK_DELAY QSPI_CONFIG_SCK_DELAY +#endif +#if defined(QSPI_CONFIG_XIP_OFFSET) +#undef NRFX_QSPI_CONFIG_XIP_OFFSET +#define NRFX_QSPI_CONFIG_XIP_OFFSET QSPI_CONFIG_XIP_OFFSET +#endif +#if defined(QSPI_CONFIG_READOC) +#undef NRFX_QSPI_CONFIG_READOC +#define NRFX_QSPI_CONFIG_READOC QSPI_CONFIG_READOC +#endif +#if defined(QSPI_CONFIG_WRITEOC) +#undef NRFX_QSPI_CONFIG_WRITEOC +#define NRFX_QSPI_CONFIG_WRITEOC QSPI_CONFIG_WRITEOC +#endif +#if defined(QSPI_CONFIG_ADDRMODE) +#undef NRFX_QSPI_CONFIG_ADDRMODE +#define NRFX_QSPI_CONFIG_ADDRMODE QSPI_CONFIG_ADDRMODE +#endif +#if defined(QSPI_CONFIG_MODE) +#undef NRFX_QSPI_CONFIG_MODE +#define NRFX_QSPI_CONFIG_MODE QSPI_CONFIG_MODE +#endif +#if defined(QSPI_CONFIG_FREQUENCY) +#undef NRFX_QSPI_CONFIG_FREQUENCY +#define NRFX_QSPI_CONFIG_FREQUENCY QSPI_CONFIG_FREQUENCY +#endif +#if defined(QSPI_CONFIG_IRQ_PRIORITY) +#undef NRFX_QSPI_CONFIG_IRQ_PRIORITY +#define NRFX_QSPI_CONFIG_IRQ_PRIORITY QSPI_CONFIG_IRQ_PRIORITY +#endif + +#if defined(QSPI_PIN_SCK) +#undef NRFX_QSPI_PIN_SCK +#define NRFX_QSPI_PIN_SCK QSPI_PIN_SCK +#endif +#if defined(QSPI_PIN_CSN) +#undef NRFX_QSPI_PIN_CSN +#define NRFX_QSPI_PIN_CSN QSPI_PIN_CSN +#endif +#if defined(QSPI_PIN_IO0) +#undef NRFX_QSPI_PIN_IO0 +#define NRFX_QSPI_PIN_IO0 QSPI_PIN_IO0 +#endif +#if defined(QSPI_PIN_IO0) +#undef NRFX_QSPI_PIN_IO0 +#define NRFX_QSPI_PIN_IO0 QSPI_PIN_IO0 +#endif +#if defined(QSPI_PIN_IO1) +#undef NRFX_QSPI_PIN_IO1 +#define NRFX_QSPI_PIN_IO1 QSPI_PIN_IO1 +#endif +#if defined(QSPI_PIN_IO2) +#undef NRFX_QSPI_PIN_IO2 +#define NRFX_QSPI_PIN_IO2 QSPI_PIN_IO2 +#endif +#if defined(QSPI_PIN_IO3) +#undef NRFX_QSPI_PIN_IO3 +#define NRFX_QSPI_PIN_IO3 QSPI_PIN_IO3 +#endif + +#endif // defined(QSPI_ENABLED) + +//------------------------------------------------------------------------------ +// RNG + +#if defined(RNG_ENABLED) + +#undef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED RNG_ENABLED + +#if defined(RNG_CONFIG_ERROR_CORRECTION) +#undef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION RNG_CONFIG_ERROR_CORRECTION +#endif + +#if defined(RNG_CONFIG_IRQ_PRIORITY) +#undef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY RNG_CONFIG_IRQ_PRIORITY +#endif + +#if defined(RNG_CONFIG_LOG_ENABLED) +#undef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED RNG_CONFIG_LOG_ENABLED +#endif +#if defined(RNG_CONFIG_LOG_LEVEL) +#undef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL RNG_CONFIG_LOG_LEVEL +#endif +#if defined(RNG_CONFIG_INFO_COLOR) +#undef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR RNG_CONFIG_INFO_COLOR +#endif +#if defined(RNG_CONFIG_DEBUG_COLOR) +#undef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR RNG_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(RNG_ENABLED) + +//------------------------------------------------------------------------------ +// RTC + +#if defined(RTC_ENABLED) + +#undef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED RTC_ENABLED + +#if defined(RTC0_ENABLED) +#undef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED RTC0_ENABLED +#endif +#if defined(RTC1_ENABLED) +#undef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED RTC1_ENABLED +#endif +#if defined(RTC2_ENABLED) +#undef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED RTC2_ENABLED +#endif + +#if defined(RTC_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY RTC_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(RTC_DEFAULT_CONFIG_RELIABLE) +#undef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE RTC_DEFAULT_CONFIG_RELIABLE +#endif +#if defined(RTC_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(NRF_MAXIMUM_LATENCY_US) +#undef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US NRF_MAXIMUM_LATENCY_US +#endif + +#if defined(RTC_CONFIG_LOG_ENABLED) +#undef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED RTC_CONFIG_LOG_ENABLED +#endif +#if defined(RTC_CONFIG_LOG_LEVEL) +#undef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL RTC_CONFIG_LOG_LEVEL +#endif +#if defined(RTC_CONFIG_INFO_COLOR) +#undef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR RTC_CONFIG_INFO_COLOR +#endif +#if defined(RTC_CONFIG_DEBUG_COLOR) +#undef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR RTC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(RTC_ENABLED) + +//------------------------------------------------------------------------------ +// SAADC + +#if defined(SAADC_ENABLED) + +#undef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED SAADC_ENABLED + +#if defined(SAADC_CONFIG_RESOLUTION) +#undef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION SAADC_CONFIG_RESOLUTION +#endif +#if defined(SAADC_CONFIG_OVERSAMPLE) +#undef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE SAADC_CONFIG_OVERSAMPLE +#endif +#if defined(SAADC_CONFIG_LP_MODE) +#undef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE SAADC_CONFIG_LP_MODE +#endif +#if defined(SAADC_CONFIG_IRQ_PRIORITY) +#undef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY SAADC_CONFIG_IRQ_PRIORITY +#endif + +#if defined(SAADC_CONFIG_LOG_ENABLED) +#undef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED SAADC_CONFIG_LOG_ENABLED +#endif +#if defined(SAADC_CONFIG_LOG_LEVEL) +#undef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL SAADC_CONFIG_LOG_LEVEL +#endif +#if defined(SAADC_CONFIG_INFO_COLOR) +#undef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR SAADC_CONFIG_INFO_COLOR +#endif +#if defined(SAADC_CONFIG_DEBUG_COLOR) +#undef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR SAADC_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(SAADC_ENABLED) + +//------------------------------------------------------------------------------ +// SPI + +#if defined(SPI_ENABLED) + +#undef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED \ + (SPI_ENABLED && (NRFX_SPI0_ENABLED || NRFX_SPI1_ENABLED || NRFX_SPI2_ENABLED)) +#undef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED \ + (SPI_ENABLED && (NRFX_SPIM0_ENABLED || NRFX_SPIM1_ENABLED || NRFX_SPIM2_ENABLED)) + +#if defined(SPI_PRESENT) && !defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED SPI0_ENABLED +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED SPI1_ENABLED +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED SPI2_ENABLED +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 + +#elif !defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED SPI0_ENABLED + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED SPI1_ENABLED + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED SPI2_ENABLED + +#else // -> defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#undef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED (SPI0_ENABLED && !SPI0_USE_EASY_DMA) +#undef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED (SPI0_ENABLED && SPI0_USE_EASY_DMA) + +#undef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED (SPI1_ENABLED && !SPI1_USE_EASY_DMA) +#undef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED (SPI1_ENABLED && SPI1_USE_EASY_DMA) + +#undef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED (SPI2_ENABLED && !SPI2_USE_EASY_DMA) +#undef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED (SPI2_ENABLED && SPI2_USE_EASY_DMA) + +#endif // -> defined(SPI_PRESENT) && defined(SPIM_PRESENT) + +#if defined(NRF_SPI_DRV_MISO_PULLUP_CFG) +#undef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG NRF_SPI_DRV_MISO_PULLUP_CFG +#undef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG NRF_SPI_DRV_MISO_PULLUP_CFG +#endif + +#if defined(SPI_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(SPI_CONFIG_LOG_ENABLED) +#undef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED SPI_CONFIG_LOG_ENABLED +#undef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED SPI_CONFIG_LOG_ENABLED +#endif +#if defined(SPI_CONFIG_LOG_LEVEL) +#undef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL SPI_CONFIG_LOG_LEVEL +#undef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL SPI_CONFIG_LOG_LEVEL +#endif +#if defined(SPI_CONFIG_INFO_COLOR) +#undef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR SPI_CONFIG_INFO_COLOR +#undef NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR SPI_CONFIG_INFO_COLOR +#endif +#if defined(SPI_CONFIG_DEBUG_COLOR) +#undef NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR SPI_CONFIG_DEBUG_COLOR +#undef NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR SPI_CONFIG_DEBUG_COLOR +#endif + +#if defined(SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(SPI_ENABLED) + +//------------------------------------------------------------------------------ +// SPIS + +#if defined(SPIS_ENABLED) + +#undef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED SPIS_ENABLED + +#if defined(SPIS0_ENABLED) +#undef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED SPIS0_ENABLED +#endif +#if defined(SPIS1_ENABLED) +#undef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED SPIS1_ENABLED +#endif +#if defined(SPIS2_ENABLED) +#undef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED SPIS2_ENABLED +#endif + +#if defined(SPIS_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#endif +#if defined(SPIS_DEFAULT_MODE) +#undef NRFX_SPIS_DEFAULT_MODE +#define NRFX_SPIS_DEFAULT_MODE SPIS_DEFAULT_MODE +#endif +#if defined(SPIS_DEFAULT_BIT_ORDER) +#undef NRFX_SPIS_DEFAULT_BIT_ORDER +#define NRFX_SPIS_DEFAULT_BIT_ORDER SPIS_DEFAULT_BIT_ORDER +#endif +#if defined(SPIS_DEFAULT_DEF) +#undef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF SPIS_DEFAULT_DEF +#endif +#if defined(SPIS_DEFAULT_ORC) +#undef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC SPIS_DEFAULT_ORC +#endif + +#if defined(SPIS_CONFIG_LOG_ENABLED) +#undef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED SPIS_CONFIG_LOG_ENABLED +#endif +#if defined(SPIS_CONFIG_LOG_LEVEL) +#undef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL SPIS_CONFIG_LOG_LEVEL +#endif +#if defined(SPIS_CONFIG_INFO_COLOR) +#undef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR SPIS_CONFIG_INFO_COLOR +#endif +#if defined(SPIS_CONFIG_DEBUG_COLOR) +#undef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR SPIS_CONFIG_DEBUG_COLOR +#endif + +#if defined(SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(SPIS_ENABLED) + +//------------------------------------------------------------------------------ +// SWI + +#if defined(SWI_DISABLE0) +#undef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 1 +#endif +#if defined(SWI_DISABLE1) +#undef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 1 +#endif +#if defined(SWI_DISABLE2) +#undef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 1 +#endif +#if defined(SWI_DISABLE3) +#undef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 1 +#endif +#if defined(SWI_DISABLE4) +#undef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 1 +#endif +#if defined(SWI_DISABLE5) +#undef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 1 +#endif + +#if defined(EGU_ENABLED) +#undef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED EGU_ENABLED +#endif + +#if defined(SWI_CONFIG_LOG_ENABLED) +#undef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED SWI_CONFIG_LOG_ENABLED +#endif +#if defined(SWI_CONFIG_LOG_LEVEL) +#undef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL SWI_CONFIG_LOG_LEVEL +#endif +#if defined(SWI_CONFIG_INFO_COLOR) +#undef NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR SWI_CONFIG_INFO_COLOR +#endif +#if defined(SWI_CONFIG_DEBUG_COLOR) +#undef NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR SWI_CONFIG_DEBUG_COLOR +#endif + +//------------------------------------------------------------------------------ +// SysTick + +#if defined(SYSTICK_ENABLED) + +#undef NRFX_SYSTICK_ENABLED +#define NRFX_SYSTICK_ENABLED SYSTICK_ENABLED + +#endif // defined(SYSTICK_ENABLED) + +//------------------------------------------------------------------------------ +// TIMER + +#if defined(TIMER_ENABLED) + +#undef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED TIMER_ENABLED + +#if defined(TIMER0_ENABLED) +#undef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED TIMER0_ENABLED +#endif +#if defined(TIMER1_ENABLED) +#undef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED TIMER1_ENABLED +#endif +#if defined(TIMER2_ENABLED) +#undef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED TIMER2_ENABLED +#endif +#if defined(TIMER3_ENABLED) +#undef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED TIMER3_ENABLED +#endif +#if defined(TIMER4_ENABLED) +#undef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED TIMER4_ENABLED +#endif + +#if defined(TIMER_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY TIMER_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(TIMER_DEFAULT_CONFIG_MODE) +#undef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE TIMER_DEFAULT_CONFIG_MODE +#endif +#if defined(TIMER_DEFAULT_CONFIG_BIT_WIDTH) +#undef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH TIMER_DEFAULT_CONFIG_BIT_WIDTH +#endif +#if defined(TIMER_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TIMER_CONFIG_LOG_ENABLED) +#undef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED TIMER_CONFIG_LOG_ENABLED +#endif +#if defined(TIMER_CONFIG_LOG_LEVEL) +#undef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL TIMER_CONFIG_LOG_LEVEL +#endif +#if defined(TIMER_CONFIG_INFO_COLOR) +#undef NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR TIMER_CONFIG_INFO_COLOR +#endif +#if defined(TIMER_CONFIG_DEBUG_COLOR) +#undef NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR TIMER_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(TIMER_ENABLED) + +//------------------------------------------------------------------------------ +// TWI +#define TWI_ONLY ( defined(TWI_PRESENT) && !defined(TWIM_PRESENT)) +#define TWIM_ONLY (!defined(TWI_PRESENT) && defined(TWIM_PRESENT)) +#define TWI_AND_TWIM ( defined(TWI_PRESENT) && defined(TWIM_PRESENT)) + +#if defined(TWI_ENABLED) + +#undef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED (TWI_ENABLED && (NRFX_TWI0_ENABLED || NRFX_TWI1_ENABLED)) +#undef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED (TWI_ENABLED && (NRFX_TWIM0_ENABLED || NRFX_TWIM1_ENABLED)) + +#if defined(TWI_PRESENT) && !defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED TWI0_ENABLED +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED TWI1_ENABLED +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 + +#elif !defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED TWI0_ENABLED + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED TWI1_ENABLED + +#else // -> defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#undef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED (TWI0_ENABLED && !TWI0_USE_EASY_DMA) +#undef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED (TWI0_ENABLED && TWI0_USE_EASY_DMA) + +#undef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED (TWI1_ENABLED && !TWI1_USE_EASY_DMA) +#undef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED (TWI1_ENABLED && TWI1_USE_EASY_DMA) + +#endif // -> defined(TWI_PRESENT) && defined(TWIM_PRESENT) + +#if defined(TWI_DEFAULT_CONFIG_FREQUENCY) +#undef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY TWI_DEFAULT_CONFIG_FREQUENCY +#undef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY TWI_DEFAULT_CONFIG_FREQUENCY +#endif +#if defined(TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT) +#undef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#undef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#endif +#if defined(TWI_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TWI_CONFIG_LOG_ENABLED) +#undef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED TWI_CONFIG_LOG_ENABLED +#undef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED TWI_CONFIG_LOG_ENABLED +#endif +#if defined(TWI_CONFIG_LOG_LEVEL) +#undef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL TWI_CONFIG_LOG_LEVEL +#undef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL TWI_CONFIG_LOG_LEVEL +#endif +#if defined(TWI_CONFIG_INFO_COLOR) +#undef NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR TWI_CONFIG_INFO_COLOR +#undef NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR TWI_CONFIG_INFO_COLOR +#endif +#if defined(TWI_CONFIG_DEBUG_COLOR) +#undef NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR +#undef NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR TWI_CONFIG_DEBUG_COLOR +#endif + +#if defined(TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED) +#undef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#endif + +#endif // defined(TWI_ENABLED) + +//------------------------------------------------------------------------------ +// TWIS + +#if defined(TWIS_ENABLED) + +#undef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED TWIS_ENABLED + +#if defined(TWIS0_ENABLED) +#undef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED TWIS0_ENABLED +#endif +#if defined(TWIS1_ENABLED) +#undef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED TWIS1_ENABLED +#endif + +#if defined(TWIS_ASSUME_INIT_AFTER_RESET_ONLY) +#undef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#endif +#if defined(TWIS_NO_SYNC_MODE) +#undef NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE TWIS_NO_SYNC_MODE +#endif + +#if defined(TWIS_DEFAULT_CONFIG_ADDR0) +#undef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 TWIS_DEFAULT_CONFIG_ADDR0 +#endif +#if defined(TWIS_DEFAULT_CONFIG_ADDR1) +#undef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 TWIS_DEFAULT_CONFIG_ADDR1 +#endif +#if defined(TWIS_DEFAULT_CONFIG_SCL_PULL) +#undef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL TWIS_DEFAULT_CONFIG_SCL_PULL +#endif +#if defined(TWIS_DEFAULT_CONFIG_SDA_PULL) +#undef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL TWIS_DEFAULT_CONFIG_SDA_PULL +#endif +#if defined(TWIS_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(TWIS_CONFIG_LOG_ENABLED) +#undef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED TWIS_CONFIG_LOG_ENABLED +#endif +#if defined(TWIS_CONFIG_LOG_LEVEL) +#undef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL TWIS_CONFIG_LOG_LEVEL +#endif +#if defined(TWIS_CONFIG_INFO_COLOR) +#undef NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR TWIS_CONFIG_INFO_COLOR +#endif +#if defined(TWIS_CONFIG_DEBUG_COLOR) +#undef NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR TWIS_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(TWIS_ENABLED) + +//------------------------------------------------------------------------------ +// UART + +#if defined(UART_ENABLED) + +#undef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED (UART_ENABLED && NRFX_UART0_ENABLED) +#undef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED (UART_ENABLED && (NRFX_UARTE0_ENABLED || NRFX_UARTE1_ENABLED)) + +#if defined(UART0_ENABLED) +#undef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED (UART0_ENABLED && UART_LEGACY_SUPPORT) +#undef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED (UART0_ENABLED && UART_EASY_DMA_SUPPORT) +#endif +#if defined(UART1_ENABLED) +#undef NRFX_UARTE1_ENABLED +#define NRFX_UARTE1_ENABLED (UART1_ENABLED && UART_EASY_DMA_SUPPORT) +#endif + +#if defined(UART_DEFAULT_CONFIG_HWFC) +#undef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC UART_DEFAULT_CONFIG_HWFC +#undef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC UART_DEFAULT_CONFIG_HWFC +#endif +#if defined(UART_DEFAULT_CONFIG_PARITY) +#undef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY UART_DEFAULT_CONFIG_PARITY +#undef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY UART_DEFAULT_CONFIG_PARITY +#endif +#if defined(UART_DEFAULT_CONFIG_BAUDRATE) +#undef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE UART_DEFAULT_CONFIG_BAUDRATE +#undef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE UART_DEFAULT_CONFIG_BAUDRATE +#endif +#if defined(UART_DEFAULT_CONFIG_IRQ_PRIORITY) +#undef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY UART_DEFAULT_CONFIG_IRQ_PRIORITY +#undef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY UART_DEFAULT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(UART_CONFIG_LOG_ENABLED) +#undef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED UART_CONFIG_LOG_ENABLED +#undef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED UART_CONFIG_LOG_ENABLED +#endif +#if defined(UART_CONFIG_LOG_LEVEL) +#undef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL UART_CONFIG_LOG_LEVEL +#undef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL UART_CONFIG_LOG_LEVEL +#endif +#if defined(UART_CONFIG_INFO_COLOR) +#undef NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR UART_CONFIG_INFO_COLOR +#undef NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR UART_CONFIG_INFO_COLOR +#endif +#if defined(UART_CONFIG_DEBUG_COLOR) +#undef NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR UART_CONFIG_DEBUG_COLOR +#undef NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR UART_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(UART_ENABLED) + +//------------------------------------------------------------------------------ +// WDT + +#if defined(WDT_ENABLED) + +#undef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED WDT_ENABLED + +#if defined(WDT_CONFIG_BEHAVIOUR) +#undef NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR WDT_CONFIG_BEHAVIOUR +#endif +#if defined(WDT_CONFIG_RELOAD_VALUE) +#undef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE WDT_CONFIG_RELOAD_VALUE +#endif +#if defined(WDT_CONFIG_IRQ_PRIORITY) +#undef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY WDT_CONFIG_IRQ_PRIORITY +#endif + +#if defined(WDT_CONFIG_LOG_ENABLED) +#undef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED WDT_CONFIG_LOG_ENABLED +#endif +#if defined(WDT_CONFIG_LOG_LEVEL) +#undef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL WDT_CONFIG_LOG_LEVEL +#endif +#if defined(WDT_CONFIG_INFO_COLOR) +#undef NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR WDT_CONFIG_INFO_COLOR +#endif +#if defined(WDT_CONFIG_DEBUG_COLOR) +#undef NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR WDT_CONFIG_DEBUG_COLOR +#endif + +#endif // defined(WDT_ENABLED) + +#endif // APPLY_OLD_CONFIG_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.c new file mode 100644 index 0000000..84bca88 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.c @@ -0,0 +1,603 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include <nordic_common.h> +#include "nrf_drv_clock.h" + +#if NRF_MODULE_ENABLED(CLOCK) + +#ifdef SOFTDEVICE_PRESENT +#include "nrf_sdh.h" +#include "nrf_sdh_soc.h" +#endif + +#define NRF_LOG_MODULE_NAME clock +#if CLOCK_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR +#else //CLOCK_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL 0 +#endif //CLOCK_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#define EVT_TO_STR(event) \ + (event == NRF_CLOCK_EVENT_HFCLKSTARTED ? "NRF_CLOCK_EVENT_HFCLKSTARTED" : \ + (event == NRF_CLOCK_EVENT_LFCLKSTARTED ? "NRF_CLOCK_EVENT_LFCLKSTARTED" : \ + (event == NRF_CLOCK_EVENT_DONE ? "NRF_CLOCK_EVENT_DONE" : \ + (event == NRF_CLOCK_EVENT_CTTO ? "NRF_CLOCK_EVENT_CTTO" : \ + "UNKNOWN EVENT")))) + + +/*lint -save -e652 */ +#define NRF_CLOCK_LFCLK_RC CLOCK_LFCLKSRC_SRC_RC +#define NRF_CLOCK_LFCLK_Xtal CLOCK_LFCLKSRC_SRC_Xtal +#define NRF_CLOCK_LFCLK_Synth CLOCK_LFCLKSRC_SRC_Synth +/*lint -restore */ + +#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) && !defined(SOFTDEVICE_PRESENT) +#define CALIBRATION_SUPPORT 1 +#else +#define CALIBRATION_SUPPORT 0 +#endif +typedef enum +{ + CAL_STATE_IDLE, + CAL_STATE_CT, + CAL_STATE_HFCLK_REQ, + CAL_STATE_CAL, + CAL_STATE_ABORT, +} nrf_drv_clock_cal_state_t; + +/**@brief CLOCK control block. */ +typedef struct +{ + bool module_initialized; /*< Indicate the state of module */ + volatile bool hfclk_on; /*< High-frequency clock state. */ + volatile bool lfclk_on; /*< Low-frequency clock state. */ + volatile uint32_t hfclk_requests; /*< High-frequency clock request counter. */ + volatile nrf_drv_clock_handler_item_t * p_hf_head; + volatile uint32_t lfclk_requests; /*< Low-frequency clock request counter. */ + volatile nrf_drv_clock_handler_item_t * p_lf_head; +#if CALIBRATION_SUPPORT + nrf_drv_clock_handler_item_t cal_hfclk_started_handler_item; + nrf_drv_clock_event_handler_t cal_done_handler; + volatile nrf_drv_clock_cal_state_t cal_state; +#endif // CALIBRATION_SUPPORT +} nrf_drv_clock_cb_t; + +static nrf_drv_clock_cb_t m_clock_cb; + +static void clock_irq_handler(nrfx_clock_evt_type_t evt); + +static void lfclk_stop(void) +{ +#if CALIBRATION_SUPPORT + nrfx_clock_calibration_timer_stop(); +#endif + +#ifdef SOFTDEVICE_PRESENT + // If LFCLK is requested to stop while SD is still enabled, + // it indicates an error in the application. + // Enabling SD should increment the LFCLK request. + ASSERT(!nrf_sdh_is_enabled()); +#endif // SOFTDEVICE_PRESENT + + nrfx_clock_lfclk_stop(); + m_clock_cb.lfclk_on = false; +} + +static void hfclk_start(void) +{ +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + (void)sd_clock_hfclk_request(); + return; + } +#endif // SOFTDEVICE_PRESENT + + nrfx_clock_hfclk_start(); +} + +static void hfclk_stop(void) +{ +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + (void)sd_clock_hfclk_release(); + m_clock_cb.hfclk_on = false; + return; + } +#endif // SOFTDEVICE_PRESENT + + nrfx_clock_hfclk_stop(); + m_clock_cb.hfclk_on = false; +} + +bool nrf_drv_clock_init_check(void) +{ + return m_clock_cb.module_initialized; +} + +ret_code_t nrf_drv_clock_init(void) +{ + ret_code_t err_code = NRF_SUCCESS; + if (m_clock_cb.module_initialized) + { + err_code = NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } + else + { + m_clock_cb.p_hf_head = NULL; + m_clock_cb.hfclk_requests = 0; + m_clock_cb.p_lf_head = NULL; + m_clock_cb.lfclk_requests = 0; + err_code = nrfx_clock_init(clock_irq_handler); +#ifdef SOFTDEVICE_PRESENT + if (!nrf_sdh_is_enabled()) +#endif + { + nrfx_clock_enable(); + } + +#if CALIBRATION_SUPPORT + m_clock_cb.cal_state = CAL_STATE_IDLE; +#endif + + m_clock_cb.module_initialized = true; + } + + NRF_LOG_INFO("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +} + +void nrf_drv_clock_uninit(void) +{ + ASSERT(m_clock_cb.module_initialized); + nrfx_clock_disable(); + nrfx_clock_uninit(); +} + +static void item_enqueue(nrf_drv_clock_handler_item_t ** p_head, + nrf_drv_clock_handler_item_t * p_item) +{ + nrf_drv_clock_handler_item_t * p_next = *p_head; + while (p_next) + { + if (p_next == p_item) + { + return; + } + p_next = p_next->p_next; + } + + p_item->p_next = (*p_head ? *p_head : NULL); + *p_head = p_item; +} + +static nrf_drv_clock_handler_item_t * item_dequeue(nrf_drv_clock_handler_item_t ** p_head) +{ + nrf_drv_clock_handler_item_t * p_item = *p_head; + if (p_item) + { + *p_head = p_item->p_next; + } + return p_item; +} + +void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item) +{ + ASSERT(m_clock_cb.module_initialized); + + if (m_clock_cb.lfclk_on) + { + if (p_handler_item) + { + p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_LFCLK_STARTED); + } + CRITICAL_REGION_ENTER(); + ++(m_clock_cb.lfclk_requests); + CRITICAL_REGION_EXIT(); + } + else + { + CRITICAL_REGION_ENTER(); + if (p_handler_item) + { + item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head, + p_handler_item); + } + if (m_clock_cb.lfclk_requests == 0) + { + nrfx_clock_lfclk_start(); + } + ++(m_clock_cb.lfclk_requests); + CRITICAL_REGION_EXIT(); + } + + ASSERT(m_clock_cb.lfclk_requests > 0); +} + +void nrf_drv_clock_lfclk_release(void) +{ + ASSERT(m_clock_cb.module_initialized); + ASSERT(m_clock_cb.lfclk_requests > 0); + + CRITICAL_REGION_ENTER(); + --(m_clock_cb.lfclk_requests); + if (m_clock_cb.lfclk_requests == 0) + { + lfclk_stop(); + } + CRITICAL_REGION_EXIT(); +} + +bool nrf_drv_clock_lfclk_is_running(void) +{ + ASSERT(m_clock_cb.module_initialized); + +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + return true; + } +#endif // SOFTDEVICE_PRESENT + + return nrfx_clock_lfclk_is_running(); +} + +void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item) +{ + ASSERT(m_clock_cb.module_initialized); + + if (m_clock_cb.hfclk_on) + { + if (p_handler_item) + { + p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); + } + CRITICAL_REGION_ENTER(); + ++(m_clock_cb.hfclk_requests); + CRITICAL_REGION_EXIT(); + } + else + { + CRITICAL_REGION_ENTER(); + if (p_handler_item) + { + item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head, + p_handler_item); + } + if (m_clock_cb.hfclk_requests == 0) + { + hfclk_start(); + } + ++(m_clock_cb.hfclk_requests); + CRITICAL_REGION_EXIT(); + } + + ASSERT(m_clock_cb.hfclk_requests > 0); +} + +void nrf_drv_clock_hfclk_release(void) +{ + ASSERT(m_clock_cb.module_initialized); + ASSERT(m_clock_cb.hfclk_requests > 0); + + CRITICAL_REGION_ENTER(); + --(m_clock_cb.hfclk_requests); + if (m_clock_cb.hfclk_requests == 0) + { + hfclk_stop(); + } + CRITICAL_REGION_EXIT(); +} + +bool nrf_drv_clock_hfclk_is_running(void) +{ + ASSERT(m_clock_cb.module_initialized); + +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + uint32_t is_running; + UNUSED_VARIABLE(sd_clock_hfclk_is_running(&is_running)); + return (is_running ? true : false); + } +#endif // SOFTDEVICE_PRESENT + + return nrfx_clock_hfclk_is_running(); +} + +#if CALIBRATION_SUPPORT +static void clock_calibration_hf_started(nrf_drv_clock_evt_type_t event) +{ + if (m_clock_cb.cal_state == CAL_STATE_ABORT) + { + nrf_drv_clock_hfclk_release(); + m_clock_cb.cal_state = CAL_STATE_IDLE; + if (m_clock_cb.cal_done_handler) + { + m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED); + } + } + else + { + ASSERT(event == NRF_DRV_CLOCK_EVT_HFCLK_STARTED); + if (nrfx_clock_calibration_start() != NRFX_SUCCESS) + { + ASSERT(false); + } + } +} +#endif // CALIBRATION_SUPPORT + +ret_code_t nrf_drv_clock_calibration_start(uint8_t interval, nrf_drv_clock_event_handler_t handler) +{ + ret_code_t err_code = NRF_SUCCESS; +#if CALIBRATION_SUPPORT + ASSERT(m_clock_cb.cal_state == CAL_STATE_IDLE); + if (m_clock_cb.lfclk_on == false) + { + err_code = NRF_ERROR_INVALID_STATE; + } + else if (m_clock_cb.cal_state == CAL_STATE_IDLE) + { + m_clock_cb.cal_done_handler = handler; + m_clock_cb.cal_hfclk_started_handler_item.event_handler = clock_calibration_hf_started; + if (interval == 0) + { + m_clock_cb.cal_state = CAL_STATE_HFCLK_REQ; + nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); + } + else + { + m_clock_cb.cal_state = CAL_STATE_CT; + nrfx_clock_calibration_timer_start(interval); + } + } + else + { + err_code = NRF_ERROR_BUSY; + } + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#else + UNUSED_PARAMETER(interval); + UNUSED_PARAMETER(handler); + err_code = NRF_ERROR_FORBIDDEN; + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#endif // CALIBRATION_SUPPORT +} + +ret_code_t nrf_drv_clock_calibration_abort(void) +{ + ret_code_t err_code = NRF_SUCCESS; +#if CALIBRATION_SUPPORT + CRITICAL_REGION_ENTER(); + switch (m_clock_cb.cal_state) + { + case CAL_STATE_CT: + nrfx_clock_calibration_timer_stop(); + m_clock_cb.cal_state = CAL_STATE_IDLE; + if (m_clock_cb.cal_done_handler) + { + m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED); + } + break; + case CAL_STATE_HFCLK_REQ: + /* fall through. */ + case CAL_STATE_CAL: + m_clock_cb.cal_state = CAL_STATE_ABORT; + break; + default: + break; + } + CRITICAL_REGION_EXIT(); + + NRF_LOG_INFO("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#else + err_code = NRF_ERROR_FORBIDDEN; + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#endif // CALIBRATION_SUPPORT +} + +ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating) +{ + ret_code_t err_code = NRF_SUCCESS; +#if CALIBRATION_SUPPORT + ASSERT(m_clock_cb.module_initialized); + *p_is_calibrating = (m_clock_cb.cal_state != CAL_STATE_IDLE); + NRF_LOG_INFO("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#else + UNUSED_PARAMETER(p_is_calibrating); + err_code = NRF_ERROR_FORBIDDEN; + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + return err_code; +#endif // CALIBRATION_SUPPORT +} + +__STATIC_INLINE void clock_clk_started_notify(nrf_drv_clock_evt_type_t evt_type) +{ + nrf_drv_clock_handler_item_t **p_head; + if (evt_type == NRF_DRV_CLOCK_EVT_HFCLK_STARTED) + { + p_head = (nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head; + } + else + { + p_head = (nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head; + } + + while (1) + { + nrf_drv_clock_handler_item_t * p_item = item_dequeue(p_head); + if (!p_item) + { + break; + } + + p_item->event_handler(evt_type); + } +} + +static void clock_irq_handler(nrfx_clock_evt_type_t evt) +{ + if (evt == NRFX_CLOCK_EVT_HFCLK_STARTED) + { + m_clock_cb.hfclk_on = true; + clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); + } + if (evt == NRFX_CLOCK_EVT_LFCLK_STARTED) + { + m_clock_cb.lfclk_on = true; + clock_clk_started_notify(NRF_DRV_CLOCK_EVT_LFCLK_STARTED); + } +#if CALIBRATION_SUPPORT + if (evt == NRFX_CLOCK_EVT_CTTO) + { + nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); + } + + if (evt == NRFX_CLOCK_EVT_CAL_DONE) + { + nrf_drv_clock_hfclk_release(); + bool aborted = (m_clock_cb.cal_state == CAL_STATE_ABORT); + m_clock_cb.cal_state = CAL_STATE_IDLE; + if (m_clock_cb.cal_done_handler) + { + m_clock_cb.cal_done_handler(aborted ? + NRF_DRV_CLOCK_EVT_CAL_ABORTED : NRF_DRV_CLOCK_EVT_CAL_DONE); + } + } +#endif // CALIBRATION_SUPPORT +} + +#ifdef SOFTDEVICE_PRESENT +/** + * @brief SoftDevice SoC event handler. + * + * @param[in] evt_id SoC event. + * @param[in] p_context Context. + */ +static void soc_evt_handler(uint32_t evt_id, void * p_context) +{ + if (evt_id == NRF_EVT_HFCLKSTARTED) + { + m_clock_cb.hfclk_on = true; + clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); + } +} +NRF_SDH_SOC_OBSERVER(m_soc_evt_observer, CLOCK_CONFIG_SOC_OBSERVER_PRIO, soc_evt_handler, NULL); + +/** + * @brief SoftDevice enable/disable state handler. + * + * @param[in] state State. + * @param[in] p_context Context. + */ +static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context) +{ + switch (state) + { + case NRF_SDH_EVT_STATE_ENABLE_PREPARE: + NVIC_DisableIRQ(POWER_CLOCK_IRQn); + break; + + case NRF_SDH_EVT_STATE_ENABLED: + CRITICAL_REGION_ENTER(); + /* Make sure that nrf_drv_clock module is initialized */ + if (!m_clock_cb.module_initialized) + { + (void)nrf_drv_clock_init(); + } + /* SD is one of the LFCLK requesters, but it will enable it by itself. */ + ++(m_clock_cb.lfclk_requests); + m_clock_cb.lfclk_on = true; + CRITICAL_REGION_EXIT(); + break; + + case NRF_SDH_EVT_STATE_DISABLED: + /* Reinit interrupts */ + ASSERT(m_clock_cb.module_initialized); + nrfx_clock_enable(); + + /* SD leaves LFCLK enabled - disable it if it is no longer required. */ + nrf_drv_clock_lfclk_release(); + break; + + default: + break; + } +} + +NRF_SDH_STATE_OBSERVER(m_sd_state_observer, CLOCK_CONFIG_STATE_OBSERVER_PRIO) = +{ + .handler = sd_state_evt_handler, + .p_context = NULL, +}; + +#endif // SOFTDEVICE_PRESENT + +#undef NRF_CLOCK_LFCLK_RC +#undef NRF_CLOCK_LFCLK_Xtal +#undef NRF_CLOCK_LFCLK_Synth + +#endif // NRF_MODULE_ENABLED(CLOCK) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.h new file mode 100644 index 0000000..5873bf2 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_clock.h @@ -0,0 +1,297 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_CLOCK_H__ +#define NRF_DRV_CLOCK_H__ + +#include <nrfx_clock.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_clock Clock driver - legacy layer + * @{ + * @ingroup nrf_clock + * + * @brief Layer providing compatibility with the former API. + */ + +/** + * @brief Clock events. + */ +typedef enum +{ + NRF_DRV_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started. + NRF_DRV_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started. + NRF_DRV_CLOCK_EVT_CAL_DONE, ///< Calibration is done. + NRF_DRV_CLOCK_EVT_CAL_ABORTED, ///< Calibration has been aborted. +} nrf_drv_clock_evt_type_t; + +/** + * @brief Clock event handler. + * + * @param[in] event Event. + */ +typedef void (*nrf_drv_clock_event_handler_t)(nrf_drv_clock_evt_type_t event); + +// Forward declaration of the nrf_drv_clock_handler_item_t type. +typedef struct nrf_drv_clock_handler_item_s nrf_drv_clock_handler_item_t; + +struct nrf_drv_clock_handler_item_s +{ + nrf_drv_clock_handler_item_t * p_next; ///< A pointer to the next handler that should be called when the clock is started. + nrf_drv_clock_event_handler_t event_handler; ///< Function to be called when the clock is started. +}; + +/** + * @brief Function for checking if driver is already initialized + * + * @retval true Driver is initialized + * @retval false Driver is uninitialized + */ +bool nrf_drv_clock_init_check(void); + +/** + * @brief Function for initializing the nrf_drv_clock module. + * + * After initialization, the module is in power off state (clocks are not requested). + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the driver was already initialized. + */ +ret_code_t nrf_drv_clock_init(void); + +/** + * @brief Function for uninitializing the clock module. + * + */ +void nrf_drv_clock_uninit(void); + +/** + * @brief Function for requesting the LFCLK. + * + * The low-frequency clock can be requested by different modules + * or contexts. The driver ensures that the clock will be started only when it is requested + * the first time. If the clock is not ready but it was already started, the handler item that is + * provided as an input parameter is added to the list of handlers that will be notified + * when the clock is started. If the clock is already enabled, user callback is called from the + * current context. + * + * The first request will start the selected LFCLK source. If an event handler is + * provided, it will be called once the LFCLK is started. If the LFCLK was already started at this + * time, the event handler will be called from the context of this function. Additionally, + * the @ref nrf_drv_clock_lfclk_is_running function can be polled to check if the clock has started. + * + * @note When a SoftDevice is enabled, the LFCLK is always running and the driver cannot control it. + * + * @note The handler item provided by the user cannot be an automatic variable. + * + * @param[in] p_handler_item A pointer to the event handler structure. + */ +void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item); + +/** + * @brief Function for releasing the LFCLK. + * + * If there are no more requests, the LFCLK source will be stopped. + * + * @note When a SoftDevice is enabled, the LFCLK is always running. + */ +void nrf_drv_clock_lfclk_release(void); + +/** + * @brief Function for checking the LFCLK state. + * + * @retval true If the LFCLK is running. + * @retval false If the LFCLK is not running. + */ +bool nrf_drv_clock_lfclk_is_running(void); + +/** + * @brief Function for requesting the high-accuracy source HFCLK. + * + * The high-accuracy source + * can be requested by different modules or contexts. The driver ensures that the high-accuracy + * clock will be started only when it is requested the first time. If the clock is not ready + * but it was already started, the handler item that is provided as an input parameter is added + * to the list of handlers that will be notified when the clock is started. + * + * If an event handler is provided, it will be called once the clock is started. If the clock was already + * started at this time, the event handler will be called from the context of this function. Additionally, + * the @ref nrf_drv_clock_hfclk_is_running function can be polled to check if the clock has started. + * + * @note If a SoftDevice is running, the clock is managed by the SoftDevice and all requests are handled by + * the SoftDevice. This function cannot be called from all interrupt priority levels in that case. + * @note The handler item provided by the user cannot be an automatic variable. + * + * @param[in] p_handler_item A pointer to the event handler structure. + */ +void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item); + +/** + * @brief Function for releasing the high-accuracy source HFCLK. + * + * If there are no more requests, the high-accuracy source will be released. + */ +void nrf_drv_clock_hfclk_release(void); + +/** + * @brief Function for checking the HFCLK state. + * + * @retval true If the HFCLK is running (for \nRFXX XTAL source). + * @retval false If the HFCLK is not running. + */ +bool nrf_drv_clock_hfclk_is_running(void); + +/** + * @brief Function for starting a single calibration process. + * + * This function can also delay the start of calibration by a user-specified value. The delay will use + * a low-power timer that is part of the CLOCK module. @ref nrf_drv_clock_is_calibrating can be called to + * check if calibration is still in progress. If a handler is provided, the user can be notified when + * calibration is completed. The ext calibration can be started from the handler context. + * + * The calibration process consists of three phases: + * - Delay (optional) + * - Requesting the high-accuracy HFCLK + * - Hardware-supported calibration + * + * @param[in] delay Time after which the calibration will be started (in 0.25 s units). + * @param[in] handler NULL or user function to be called when calibration is completed or aborted. + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + * @retval NRF_ERROR_INVALID_STATE If the low-frequency clock is off. + * @retval NRF_ERROR_BUSY If calibration is in progress. + */ +ret_code_t nrf_drv_clock_calibration_start(uint8_t delay, nrf_drv_clock_event_handler_t handler); + +/** + * @brief Function for aborting calibration. + * + * This function aborts on-going calibration. If calibration was started, it cannot be stopped. If a handler + * was provided by @ref nrf_drv_clock_calibration_start, this handler will be called once + * aborted calibration is completed. @ref nrf_drv_clock_is_calibrating can also be used to check + * if the system is calibrating. + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + */ +ret_code_t nrf_drv_clock_calibration_abort(void); + +/** + * @brief Function for checking if calibration is in progress. + * + * This function indicates that the system is + * in calibration if it is in any of the calibration process phases (see @ref nrf_drv_clock_calibration_start). + * + * @param[out] p_is_calibrating True if calibration is in progress, false if not. + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator. + */ +ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating); + +/**@brief Function for returning a requested task address for the clock driver module. + * + * @param[in] task One of the peripheral tasks. + * + * @return Task address. + */ +__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr(nrf_clock_task_t task); + +/**@brief Function for returning a requested event address for the clock driver module. + * + * @param[in] event One of the peripheral events. + * + * @return Event address. + */ +__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event); + + +#ifdef SOFTDEVICE_PRESENT +/** + * @brief Function called by the SoftDevice handler if an @ref NRF_SOC_EVTS event is received from the SoftDevice. + * + * @param[in] evt_id One of NRF_SOC_EVTS values. + */ +void nrf_drv_clock_on_soc_event(uint32_t evt_id); + +/** + * @brief Function called by the SoftDevice handler when the SoftDevice has been enabled. + * + * This function is called just after the SoftDevice has been properly enabled. + * Its main purpose is to mark that LFCLK has been requested by SD. + */ +void nrf_drv_clock_on_sd_enable(void); + +/** + * @brief Function called by the SoftDevice handler when the SoftDevice has been disabled. + * + * This function is called just after the SoftDevice has been properly disabled. + * It has two purposes: + * 1. Releases the LFCLK from the SD. + * 2. Reinitializes an interrupt after the SD releases POWER_CLOCK_IRQ. + */ +void nrf_drv_clock_on_sd_disable(void); + +#endif +/** + *@} + **/ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION +__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr(nrf_clock_task_t task) +{ + return nrf_clock_task_address_get(task); +} + +__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event) +{ + return nrf_clock_event_address_get(event); +} +#endif //SUPPRESS_INLINE_IMPLEMENTATION + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_CLOCK_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_common.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_common.h new file mode 100644 index 0000000..66439a3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_common.h @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_COMMON_H__ +#define NRF_DRV_COMMON_H__ + +#include <nrfx.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define INTERRUPT_PRIORITY_VALIDATION(pri) STATIC_ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) +#define INTERRUPT_PRIORITY_ASSERT(pri) ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri))) + +#define nrf_drv_irq_handler_t nrfx_irq_handler_t +#define nrf_drv_bitpos_to_event nrfx_bitpos_to_event +#define nrf_drv_event_to_bitpos nrfx_event_to_bitpos +#define nrf_drv_get_IRQn nrfx_get_irq_number +#define nrf_drv_is_in_RAM nrfx_is_in_ram + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_COMMON_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_comp.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_comp.h new file mode 100644 index 0000000..7bde88b --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_comp.h @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_COMP_H__ +#define NRF_DRV_COMP_H__ + +#include <nrfx_comp.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_comp COMP driver - legacy layer + * @{ + * @ingroup nrf_comp + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_comp_config_t nrf_drv_comp_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define VOLTAGE_THRESHOLD_TO_INT NRFX_VOLTAGE_THRESHOLD_TO_INT +/** @brief Macro for forwarding the new implementation. */ +#define COMP_CONFIG_TH NRFX_COMP_CONFIG_TH +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_DEFAULT_CONFIG NRFX_COMP_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define comp_events_handler_t nrfx_comp_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT NRFX_COMP_SHORT_STOP_AFTER_UP_EVT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_short_mask_t nrfx_comp_short_mask_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_CROSS_MASK NRFX_COMP_EVT_EN_CROSS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_UP_MASK NRFX_COMP_EVT_EN_UP_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_DOWN_MASK NRFX_COMP_EVT_EN_DOWN_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_COMP_EVT_EN_READY_MASK NRFX_COMP_EVT_EN_READY_MASK +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_evt_en_mask_t nrfx_comp_evt_en_mask_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_uninit nrfx_comp_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_pin_select nrfx_comp_pin_select +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_start nrfx_comp_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_stop nrfx_comp_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_sample nrfx_comp_sample + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_task_address_get nrfx_comp_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_comp_event_address_get nrfx_comp_event_address_get + +/** + * @brief Function for initializing the COMP driver. + * + * This function initializes the COMP driver, but does not enable the peripheral or any interrupts. + * To start the driver, call the function @ref nrf_drv_comp_start() after initialization. + * + * If no configuration structure is provided, the driver is initialized with the default settings. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] event_handler Handler function. + * + * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid. + * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized. + * @retval NRF_ERROR_BUSY If the LPCOMP driver is initialized. + */ +__STATIC_INLINE ret_code_t nrf_drv_comp_init(nrf_drv_comp_config_t const * p_config, + comp_events_handler_t event_handler) +{ + if (p_config == NULL) + { + static nrfx_comp_config_t const default_config = NRFX_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_0); + p_config = &default_config; + } + return nrfx_comp_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_COMP_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_gpiote.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_gpiote.h new file mode 100644 index 0000000..31bccb0 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_gpiote.h @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_GPIOTE_H__ +#define NRF_DRV_GPIOTE_H__ + +#include <nrfx_gpiote.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_gpiote GPIOTE driver - legacy layer + * @{ + * @ingroup nrf_gpiote + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_in_config_t nrf_drv_gpiote_in_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_pin_t nrf_drv_gpiote_pin_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_out_config_t nrf_drv_gpiote_out_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_gpiote_evt_handler_t nrf_drv_gpiote_evt_handler_t; + +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_LOTOHI NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_HITOLO NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_IN_SENSE_TOGGLE NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_SIMPLE NRFX_GPIOTE_CONFIG_OUT_SIMPLE +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_LOW NRFX_GPIOTE_CONFIG_OUT_TASK_LOW +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_HIGH NRFX_GPIOTE_CONFIG_OUT_TASK_HIGH +/** @brief Macro for forwarding the new implementation. */ +#define GPIOTE_CONFIG_OUT_TASK_TOGGLE NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_init nrfx_gpiote_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_is_init nrfx_gpiote_is_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_uninit nrfx_gpiote_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_init nrfx_gpiote_out_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_uninit nrfx_gpiote_out_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_set nrfx_gpiote_out_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_clear nrfx_gpiote_out_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_toggle nrfx_gpiote_out_toggle +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_enable nrfx_gpiote_out_task_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_disable nrfx_gpiote_out_task_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_addr_get nrfx_gpiote_out_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_init nrfx_gpiote_in_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_uninit nrfx_gpiote_in_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_enable nrfx_gpiote_in_event_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_disable nrfx_gpiote_in_event_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_is_set nrfx_gpiote_in_is_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_in_event_addr_get nrfx_gpiote_in_event_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_set_task_addr_get nrfx_gpiote_set_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_clr_task_addr_get nrfx_gpiote_clr_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_force nrfx_gpiote_out_task_force +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_out_task_trigger nrfx_gpiote_out_task_trigger +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_set_task_trigger nrfx_gpiote_set_task_trigger +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_gpiote_clr_task_trigger nrfx_gpiote_clr_task_trigger + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif //NRF_DRV_GPIOTE_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_i2s.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_i2s.h new file mode 100644 index 0000000..56f2743 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_i2s.h @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_I2S_H__ +#define NRF_DRV_I2S_H__ + +#include <nrfx_i2s.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_i2s I2S driver - legacy layer + * @{ + * @ingroup nrf_i2s + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_i2s_config_t nrf_drv_i2s_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_i2s_buffers_t nrf_drv_i2s_buffers_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_PIN_NOT_USED NRFX_I2S_PIN_NOT_USED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE NRFX_I2S_FLAG_SYNCHRONIZED_MODE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_I2S_DEFAULT_CONFIG NRFX_I2S_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_data_handler_t nrfx_i2s_data_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_uninit nrfx_i2s_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_start nrfx_i2s_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_next_buffers_set nrfx_i2s_next_buffers_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_i2s_stop nrfx_i2s_stop + +/** + * @brief Function for initializing the I2S driver. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * If NULL, the default configuration is used. + * @param[in] handler Data handler provided by the user. Must not be NULL. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. + * @retval NRF_ERROR_INVALID_PARAM If the requested combination of configuration + * options is not allowed by the I2S peripheral. + */ +__STATIC_INLINE ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, + nrf_drv_i2s_data_handler_t handler) +{ + if (p_config == NULL) + { + static nrfx_i2s_config_t const default_config = NRFX_I2S_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_i2s_init(p_config, handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_I2S_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_lpcomp.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_lpcomp.h new file mode 100644 index 0000000..5831834 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_lpcomp.h @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2014 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_LPCOMP_H__ +#define NRF_DRV_LPCOMP_H__ + +#include <nrfx_lpcomp.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_lpcomp LPCOMP driver - legacy layer + * @{ + * @ingroup nrf_lpcomp + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_lpcomp_config_t nrf_drv_lpcomp_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_LPCOMP_DEFAULT_CONFIG NRFX_LPCOMP_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define lpcomp_events_handler_t nrfx_lpcomp_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_init nrfx_lpcomp_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_uninit nrfx_lpcomp_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_enable nrfx_lpcomp_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_lpcomp_disable nrfx_lpcomp_disable + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_LPCOMP_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pdm.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pdm.h new file mode 100644 index 0000000..c7baac3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pdm.h @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_PDM_H__ +#define NRF_DRV_PDM_H__ + +#include <nrfx_pdm.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_pdm PDM driver - legacy layer + * @{ + * @ingroup nrf_pdm + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pdm_config_t nrf_drv_pdm_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pdm_evt_t nrf_drv_pdm_evt_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PDM_MAX_BUFFER_SIZE NRFX_PDM_MAX_BUFFER_SIZE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PDM_DEFAULT_CONFIG NRFX_PDM_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define PDM_NO_ERROR NRFX_PDM_NO_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define PDM_ERROR_OVERFLOW NRFX_PDM_ERROR_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_error_t nrfx_pdm_error_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_event_handler_t nrfx_pdm_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_uninit nrfx_pdm_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_task_address_get nrfx_pdm_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_enable_check nrfx_pdm_enable_check +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_start nrfx_pdm_start +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_stop nrfx_pdm_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pdm_buffer_set nrfx_pdm_buffer_set + +/** + * @brief Function for initializing the PDM interface. + * + * @param[in] p_config Pointer to the structure with initial configuration. Cannot be NULL. + * @param[in] event_handler Event handler provided by the user. Cannot be NULL. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. + * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were specified. + */ +__STATIC_INLINE ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, + nrf_drv_pdm_event_handler_t event_handler) +{ + if (p_config == NULL) + { + return NRFX_ERROR_INVALID_PARAM; + } + return nrfx_pdm_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PDM_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.c new file mode 100644 index 0000000..2db6155 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.c @@ -0,0 +1,412 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(POWER) +#include "nrf_drv_power.h" +#include <nrf_drv_clock.h> +#ifdef SOFTDEVICE_PRESENT +#include "nrf_sdh.h" +#include "nrf_sdh_soc.h" +#endif + +#include <app_util.h> + +// The structure with default configuration data. +static const nrfx_power_config_t m_drv_power_config_default = +{ + .dcdcen = NRFX_POWER_CONFIG_DEFAULT_DCDCEN, +#if NRF_POWER_HAS_VDDH + .dcdcenhv = NRFX_POWER_CONFIG_DEFAULT_DCDCENHV, +#endif +}; + +static bool m_initialized; + +bool nrf_drv_power_init_check(void) +{ + return m_initialized; +} + +ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config) +{ +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + return NRF_ERROR_INVALID_STATE; + } +#endif + if (p_config == NULL) + { + p_config = &m_drv_power_config_default; + } + + ret_code_t err_code = nrfx_power_init(p_config); + if (err_code == NRFX_SUCCESS) + { + m_initialized = true; + } + return err_code; +} + +void nrf_drv_power_uninit() +{ + nrfx_power_uninit(); + nrf_drv_power_pof_uninit(); +#if NRF_POWER_HAS_SLEEPEVT + nrf_drv_power_sleepevt_uninit(); +#endif +#if NRF_POWER_HAS_USBREG + nrf_drv_power_usbevt_uninit(); +#endif + m_initialized = false; +} + +ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_config) +{ + ret_code_t err_code = NRF_SUCCESS; + nrfx_power_pof_init(p_config); +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + /* Currently when SD is enabled - the configuration can be changed + * in very limited range. + * It is the SoftDevice limitation. + */ +#if NRF_POWER_HAS_VDDH + if (p_config->thrvddh != nrf_power_pofcon_vddh_get()) + { + /* Cannot change THRVDDH with current SD API */ + return NRF_ERROR_INVALID_STATE; + } +#endif + if (p_config->thr != nrf_power_pofcon_get(NULL)) + { + /* Only limited number of THR values are supported and + * the values taken by SD is different than the one in hardware + */ + uint8_t thr; + switch(p_config->thr) + { + case NRF_POWER_POFTHR_V21: + thr = NRF_POWER_THRESHOLD_V21; + break; + case NRF_POWER_POFTHR_V23: + thr = NRF_POWER_THRESHOLD_V23; + break; + case NRF_POWER_POFTHR_V25: + thr = NRF_POWER_THRESHOLD_V25; + break; + case NRF_POWER_POFTHR_V27: + thr = NRF_POWER_THRESHOLD_V27; + break; + default: + /* Cannot configure */ + nrfx_power_pof_uninit(); + return NRF_ERROR_INVALID_STATE; + } + err_code = sd_power_pof_threshold_set(thr); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + err_code = sd_power_pof_enable(true); + } + else +#endif /* SOFTDEVICE_PRESENT */ + { + nrfx_power_pof_enable(p_config); + } + return err_code; +} + +void nrf_drv_power_pof_uninit() +{ +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + ret_code_t err_code = sd_power_pof_enable(false); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case + } + else +#endif + { + nrfx_power_pof_disable(); + } + nrfx_power_pof_uninit(); +} + +#if NRF_POWER_HAS_SLEEPEVT +ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p_config) +{ + if (p_config->handler != NULL) + { +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + if ((p_config->en_enter) || (p_config->en_exit)) + { + return NRF_ERROR_INVALID_STATE; + } + } + else +#endif + { + nrfx_power_sleepevt_enable(p_config); + } + } + return NRF_SUCCESS; +} + +void nrf_drv_power_sleepevt_uninit(void) +{ +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + /* Nothing to do */ + } + else +#endif + { + nrfx_power_sleepevt_disable(); + } + nrfx_power_sleepevt_uninit(); +} +#endif /* NRF_POWER_HAS_SLEEPEVT */ + +#if NRF_POWER_HAS_USBREG + +#ifdef SOFTDEVICE_PRESENT +static ret_code_t nrf_drv_power_sd_usbevt_enable(bool enable) +{ + ret_code_t err_code; + err_code = sd_power_usbdetected_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = sd_power_usbpwrrdy_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = sd_power_usbremoved_enable(enable); + ASSERT(err_code == NRF_SUCCESS); + return err_code; +} +#endif // SOFTDEVICE_PRESENT + +ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config) +{ + nrf_drv_power_usbevt_uninit(); + nrfx_power_usbevt_init(p_config); +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(true); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + uint32_t regstatus; + err_code = sd_power_usbregstatus_get(®status); + ASSERT(err_code == NRF_SUCCESS); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (regstatus & POWER_USBREGSTATUS_VBUSDETECT_Msk) + { + nrfx_power_usb_event_handler_t usbevt_handler = nrfx_power_usb_handler_get(); + ASSERT(usbevt_handler != NULL); + usbevt_handler(NRFX_POWER_USB_EVT_DETECTED); + } + } + else +#endif + { + nrfx_power_usbevt_enable(); + } + return NRF_SUCCESS; +} + +void nrf_drv_power_usbevt_uninit(void) +{ +#ifdef SOFTDEVICE_PRESENT + CRITICAL_REGION_ENTER(); + if (nrf_sdh_is_enabled()) + { + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(false); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); + } + else +#endif + { + nrfx_power_usbevt_disable(); + } +#ifdef SOFTDEVICE_PRESENT + CRITICAL_REGION_EXIT(); +#endif + nrfx_power_usbevt_uninit(); +} +#endif /* NRF_POWER_HAS_USBREG */ + +#ifdef SOFTDEVICE_PRESENT +static void nrf_drv_power_sdh_soc_evt_handler(uint32_t evt_id, void * p_context); +static void nrf_drv_power_sdh_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context); + +NRF_SDH_SOC_OBSERVER(m_soc_observer, POWER_CONFIG_SOC_OBSERVER_PRIO, + nrf_drv_power_sdh_soc_evt_handler, NULL); + +NRF_SDH_STATE_OBSERVER(m_sd_observer, POWER_CONFIG_STATE_OBSERVER_PRIO) = +{ + .handler = nrf_drv_power_sdh_state_evt_handler, + .p_context = NULL +}; + +static void nrf_drv_power_sdh_soc_evt_handler(uint32_t evt_id, void * p_context) +{ + if (evt_id == NRF_EVT_POWER_FAILURE_WARNING) + { + nrfx_power_pofwarn_event_handler_t pofwarn_handler = nrfx_power_pof_handler_get(); + /* Cannot be null if event is enabled */ + ASSERT(pofwarn_handler != NULL); + pofwarn_handler(); + } + +#if NRF_POWER_HAS_USBREG + nrfx_power_usb_event_handler_t usbevt_handler = nrfx_power_usb_handler_get(); + if (usbevt_handler != NULL) + { + switch (evt_id) + { + case NRF_EVT_POWER_USB_POWER_READY: + usbevt_handler(NRFX_POWER_USB_EVT_READY); + break; + + case NRF_EVT_POWER_USB_DETECTED: + usbevt_handler(NRFX_POWER_USB_EVT_DETECTED); + break; + + case NRF_EVT_POWER_USB_REMOVED: + usbevt_handler(NRFX_POWER_USB_EVT_REMOVED); + break; + + default: + break; + + } + } +#endif +} + +static void nrf_drv_power_on_sd_enable(void) +{ + ASSERT(m_initialized); /* This module has to be enabled first */ + CRITICAL_REGION_ENTER(); + if (nrfx_power_pof_handler_get() != NULL) + { + ret_code_t err_code = sd_power_pof_enable(true); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case + } + CRITICAL_REGION_EXIT(); + +#if NRF_POWER_HAS_USBREG + if (nrfx_power_usb_handler_get() != NULL) + { + ret_code_t err_code = nrf_drv_power_sd_usbevt_enable(true); + ASSERT(err_code == NRF_SUCCESS); + UNUSED_VARIABLE(err_code); //handle no-debug case + } +#endif +} + +static void nrf_drv_power_on_sd_disable(void) +{ + /* Reinit interrupts */ + ASSERT(m_initialized); + NRFX_IRQ_PRIORITY_SET(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY); + NRFX_IRQ_ENABLE(POWER_CLOCK_IRQn); + if (nrfx_power_pof_handler_get() != NULL) + { + nrf_power_int_enable(NRF_POWER_INT_POFWARN_MASK); + } + +#if NRF_POWER_HAS_USBREG + if (nrfx_power_usb_handler_get() != NULL) + { + nrf_power_int_enable( + NRF_POWER_INT_USBDETECTED_MASK | + NRF_POWER_INT_USBREMOVED_MASK | + NRF_POWER_INT_USBPWRRDY_MASK); + } +#endif +} + +static void nrf_drv_power_sdh_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context) +{ + switch (state) + { + case NRF_SDH_EVT_STATE_ENABLED: + nrf_drv_power_on_sd_enable(); + break; + + case NRF_SDH_EVT_STATE_DISABLED: + nrf_drv_power_on_sd_disable(); + break; + + default: + break; + } +} + +#endif // SOFTDEVICE_PRESENT +#endif //POWER_ENABLED diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.h new file mode 100644 index 0000000..c176a03 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.h @@ -0,0 +1,232 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_POWER_H__ +#define NRF_DRV_POWER_H__ + +#include <nrfx_power.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_power POWER driver - legacy layer + * @{ + * @ingroup nrf_power + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_config_t nrf_drv_power_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_pofwarn_config_t nrf_drv_power_pofwarn_config_t; +#if NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_sleepevt_config_t nrf_drv_power_sleepevt_config_t; +#endif +#if NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_power_usbevt_config_t nrf_drv_power_usbevt_config_t; +#endif + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_MODE_CONSTLAT NRFX_POWER_MODE_CONSTLAT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_MODE_LOWPWR NRFX_POWER_MODE_LOWPWR +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_mode_t nrfx_power_mode_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_SLEEP_EVT_ENTER NRFX_POWER_SLEEP_EVT_ENTER +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_SLEEP_EVT_EXIT NRFX_POWER_SLEEP_EVT_EXIT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_sleep_evt_t nrfx_power_sleep_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_DETECTED NRFX_POWER_USB_EVT_DETECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_REMOVED NRFX_POWER_USB_EVT_REMOVED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_EVT_READY NRFX_POWER_USB_EVT_READY +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_evt_t nrfx_power_usb_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_DISCONNECTED NRFX_POWER_USB_STATE_DISCONNECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_CONNECTED NRFX_POWER_USB_STATE_CONNECTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_POWER_USB_STATE_READY NRFX_POWER_USB_STATE_READY +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_state_t nrfx_power_usb_state_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_pofwarn_event_handler_t nrfx_power_pofwarn_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_sleep_event_handler_t nrfx_power_sleep_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usb_event_handler_t nrfx_power_usb_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_power_usbstatus_get nrfx_power_usbstatus_get + +/** + * @brief Function for checking if driver is already initialized + * + * This function is used to check whether common POWER_CLOCK interrupt + * should be disabled or not if @ref nrf_drv_clock tries to disable the interrupt. + * + * @retval true Driver is initialized + * @retval false Driver is uninitialized + * + * @sa nrf_drv_power_uninit + */ +bool nrf_drv_power_init_check(void); + +/** + * @brief Initialize power module driver + * + * Enabled power module driver would process all the interrupts from power system. + * + * @param[in] p_config Driver configuration. Can be NULL - the default configuration + * from @em sdk_config.h file would be used then. + * + * @retval NRF_ERROR_INVALID_STATE Power driver has to be enabled + * before SoftDevice. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED Module is initialized already. + * @retval NRF_SUCCESS Successfully initialized. + */ +ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config); + +/** + * @brief Unintialize power module driver + * + * Disables all the interrupt handling in the module. + * + * @sa nrf_drv_power_init + */ +void nrf_drv_power_uninit(void); + +/** + * @brief Initialize power failure comparator + * + * Configures and setups the power failure comparator and enables it. + * + * @param[in] p_config Configuration with values and event handler. + * If event handler is set to NULL, interrupt would be disabled. + * + * @retval NRF_ERROR_INVALID_STATE POF is initialized when SD is enabled and + * the configuration differs from the old one and + * is not possible to be set using SD interface. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_pof_init(nrf_drv_power_pofwarn_config_t const * p_config); + +/** + * @brief Turn off the power failure comparator + * + * Disables and clears the settings of the power failure comparator. + */ +void nrf_drv_power_pof_uninit(void); + +#if NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) + +/** + * @brief Initialize sleep entering and exiting events processing + * + * Configures and setups the sleep event processing. + * + * @param[in] p_config Configuration with values and event handler. + * + * @sa nrf_drv_power_sleepevt_uninit + * + * @note Sleep events are not available when SoftDevice is enabled. + * @note If sleep event is enabled when SoftDevice is initialized, sleep events + * would be automatically disabled - it is the limitation of the + * SoftDevice itself. + * + * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized + * when SD is enabled. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_sleepevt_init(nrf_drv_power_sleepevt_config_t const * p_config); + +/** + * @brief Uninitialize sleep entering and exiting events processing + * + * @sa nrf_drv_power_sleepevt_init + */ +void nrf_drv_power_sleepevt_uninit(void); + +#endif // NRF_POWER_HAS_SLEEPEVT || defined(__SDK_DOXYGEN__) + +#if NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) + +/** + * @brief Initialize USB power event processing + * + * Configures and setups the USB power event processing. + * + * @param[in] p_config Configuration with values and event handler. + * + * @sa nrf_drv_power_usbevt_uninit + * + * @retval NRF_ERROR_INVALID_STATE This event cannot be initialized + * when SD is enabled and SD does not support + * USB power events. + * @retval NRF_SUCCESS Successfully initialized and configured. + */ +ret_code_t nrf_drv_power_usbevt_init(nrf_drv_power_usbevt_config_t const * p_config); + +/** + * @brief Uninitalize USB power event processing + * + * @sa nrf_drv_power_usbevt_init + */ +void nrf_drv_power_usbevt_uninit(void); + +#endif // NRF_POWER_HAS_USBREG || defined(__SDK_DOXYGEN__) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_POWER_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.c new file mode 100644 index 0000000..8a78960 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.c @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_ppi.h" + +static nrfx_drv_state_t m_drv_state; /**< Driver state */ + +ret_code_t nrf_drv_ppi_init(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + m_drv_state = NRFX_DRV_STATE_INITIALIZED; + } + else + { + return NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } + return NRF_SUCCESS; +} + +ret_code_t nrf_drv_ppi_uninit(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + return NRF_ERROR_INVALID_STATE; + } + + m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; + nrfx_ppi_free_all(); + return NRF_SUCCESS; +} + diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.h new file mode 100644 index 0000000..4059c60 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_ppi.h @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_PPI_H__ +#define NRF_DRV_PPI_H__ + +#include <nrfx_ppi.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_ppi PPI driver - legacy layer + * @{ + * @ingroup nrf_ppi + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_ALL_APP_CHANNELS_MASK NRFX_PPI_ALL_APP_CHANNELS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_PROG_APP_CHANNELS_MASK NRFX_PPI_PROG_APP_CHANNELS_MASK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_PPI_ALL_APP_GROUPS_MASK NRFX_PPI_ALL_APP_GROUPS_MASK + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_alloc nrfx_ppi_channel_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_free nrfx_ppi_channel_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_assign nrfx_ppi_channel_assign +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_fork_assign nrfx_ppi_channel_fork_assign +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_enable nrfx_ppi_channel_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_disable nrfx_ppi_channel_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_to_mask nrfx_ppi_channel_to_mask +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channels_include_in_group nrfx_ppi_channels_include_in_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_include_in_group nrfx_ppi_channel_include_in_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channels_remove_from_group nrfx_ppi_channels_remove_from_group +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_channel_remove_from_group nrfx_ppi_channel_remove_from_group + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_alloc nrfx_ppi_group_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_free nrfx_ppi_group_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_clear nrfx_ppi_group_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_enable nrfx_ppi_group_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_group_disable nrfx_ppi_group_disable + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_get nrfx_ppi_task_addr_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_group_enable_get nrfx_ppi_task_addr_group_enable_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_ppi_task_addr_group_disable_get nrfx_ppi_task_addr_group_disable_get + +/** + * @brief Function for initializing PPI module. + * + * @retval NRF_SUCCESS If the module was successfully initialized. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. + */ +ret_code_t nrf_drv_ppi_init(void); + +/** + * @brief Function for uninitializing the PPI module. + * + * This function also disables all channels and clears the channel groups. + * + * @retval NRF_SUCCESS If the module was successfully uninitialized. + * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. + */ +ret_code_t nrf_drv_ppi_uninit(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PPI_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pwm.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pwm.h new file mode 100644 index 0000000..396afec --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_pwm.h @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_PWM_H__ +#define NRF_DRV_PWM_H__ + +#include <nrfx_pwm.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_pwm PWM driver - legacy layer + * @{ + * @ingroup nrf_pwm + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pwm_t nrf_drv_pwm_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_pwm_config_t nrf_drv_pwm_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_INSTANCE NRFX_PWM_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_PIN_NOT_USED NRFX_PWM_PIN_NOT_USED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_PIN_INVERTED NRFX_PWM_PIN_INVERTED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_DEFAULT_CONFIG NRFX_PWM_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_STOP NRFX_PWM_FLAG_STOP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_LOOP NRFX_PWM_FLAG_LOOP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 NRFX_PWM_FLAG_SIGNAL_END_SEQ0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 NRFX_PWM_FLAG_SIGNAL_END_SEQ1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_NO_EVT_FINISHED NRFX_PWM_FLAG_NO_EVT_FINISHED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_FLAG_START_VIA_TASK NRFX_PWM_FLAG_START_VIA_TASK +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_flag_t nrfx_pwm_flag_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_FINISHED NRFX_PWM_EVT_FINISHED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_END_SEQ0 NRFX_PWM_EVT_END_SEQ0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_END_SEQ1 NRFX_PWM_EVT_END_SEQ1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_PWM_EVT_STOPPED NRFX_PWM_EVT_STOPPED +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_evt_type_t nrfx_pwm_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_handler_t nrfx_pwm_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_init nrfx_pwm_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_uninit nrfx_pwm_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_simple_playback nrfx_pwm_simple_playback +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_complex_playback nrfx_pwm_complex_playback +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_step nrfx_pwm_step +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_stop nrfx_pwm_stop +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_is_stopped nrfx_pwm_is_stopped +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_update nrfx_pwm_sequence_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_values_update nrfx_pwm_sequence_values_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_length_update nrfx_pwm_sequence_length_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_repeats_update nrfx_pwm_sequence_repeats_update +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_sequence_end_delay_update nrfx_pwm_sequence_end_delay_update + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_task_address_get nrfx_pwm_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_pwm_event_address_get nrfx_pwm_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_PWM_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qdec.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qdec.h new file mode 100644 index 0000000..73fd1b1 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qdec.h @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_QDEC_H__ +#define NRF_DRV_QDEC_H__ + +#include <nrfx_qdec.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_qdec QDEC driver - legacy layer + * @{ + * @ingroup nrf_qdec + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_config_t nrf_drv_qdec_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_sample_data_evt_t nrf_drv_qdec_sample_data_evt_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_report_data_evt_t nrf_drv_qdec_report_data_evt_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qdec_event_t nrf_drv_qdec_event_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QDEC_DEFAULT_CONFIG NRFX_QDEC_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define qdec_event_handler_t nrfx_qdec_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_uninit nrfx_qdec_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_enable nrfx_qdec_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_disable nrfx_qdec_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qdec_accumulators_read nrfx_qdec_accumulators_read + +/** + * @brief Function for initializing QDEC. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * @param[in] event_handler Event handler function. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were supplied. + * @retval NRF_ERROR_INVALID_STATE If QDEC was already initialized. + */ +__STATIC_INLINE ret_code_t nrf_drv_qdec_init(nrf_drv_qdec_config_t const * p_config, + qdec_event_handler_t event_handler) +{ + if (p_config == NULL) + { + static nrf_drv_qdec_config_t const default_config = NRFX_QDEC_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_qdec_init(p_config, event_handler); +} + +/** + * @brief Function for returning the address of a specific timer task. + * + * @param[in] task QDEC task. + * @param[out] p_task Task address. + */ +void nrf_drv_qdec_task_address_get(nrf_qdec_task_t task, uint32_t * p_task) +{ + *p_task = nrfx_qdec_task_address_get(task); +} + +/** + * @brief Function for returning the address of a specific timer event. + * + * @param[in] event QDEC event. + * @param[out] p_event Event address. + */ +void nrf_drv_qdec_event_address_get(nrf_qdec_event_t event, uint32_t * p_event) +{ + *p_event = nrfx_qdec_event_address_get(event); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_QDEC_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qspi.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qspi.h new file mode 100644 index 0000000..67a2225 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_qspi.h @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_QSPI_H__ +#define NRF_DRV_QSPI_H__ + +#include <nrfx_qspi.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_qspi QSPI driver - legacy layer + * @{ + * @ingroup nrf_qspi + * + * @brief @tagAPI52840 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_qspi_config_t nrf_drv_qspi_config_t; + +#if QSPI_PIN_SCK == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_SCK + #define QSPI_PIN_SCK BSP_QSPI_SCK_PIN +#endif +#if QSPI_PIN_CSN == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_CSN + #define QSPI_PIN_CSN BSP_QSPI_CSN_PIN +#endif +#if QSPI_PIN_IO0 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO0 + #define QSPI_PIN_IO0 BSP_QSPI_IO0_PIN +#endif +#if QSPI_PIN_IO1 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO1 + #define QSPI_PIN_IO1 BSP_QSPI_IO1_PIN +#endif +#if QSPI_PIN_IO2 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO2 + #define QSPI_PIN_IO2 BSP_QSPI_IO2_PIN +#endif +#if QSPI_PIN_IO3 == NRF_QSPI_PIN_NOT_CONNECTED + #undef QSPI_PIN_IO3 + #define QSPI_PIN_IO3 BSP_QSPI_IO3_PIN +#endif + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_DEFAULT_CONFIG NRFX_QSPI_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_DEFAULT_CINSTR NRFX_QSPI_DEFAULT_CINSTR +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_QSPI_EVENT_DONE NRFX_QSPI_EVENT_DONE +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_evt_t nrfx_qspi_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_handler_t nrfx_qspi_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_init nrfx_qspi_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_uninit nrfx_qspi_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_read nrfx_qspi_read +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_write nrfx_qspi_write +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_erase nrfx_qspi_erase +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_chip_erase nrfx_qspi_chip_erase +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_mem_busy_check nrfx_qspi_mem_busy_check +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_cinstr_xfer nrfx_qspi_cinstr_xfer +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_qspi_cinstr_quick_send nrfx_qspi_cinstr_quick_send + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_QSPI_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.c new file mode 100644 index 0000000..a3aed4b --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.c @@ -0,0 +1,283 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(RNG) + +#include <stdint.h> +#include <stddef.h> +#include "nrf_drv_rng.h" +#include "nordic_common.h" +#include "app_util_platform.h" +#include "nrf_assert.h" +#include "nrf_queue.h" + +#ifdef SOFTDEVICE_PRESENT + #include "nrf_sdh.h" +#endif // SOFTDEVICE_PRESENT + +#define NRF_LOG_MODULE_NAME rng + +#if RNG_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL RNG_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR RNG_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR RNG_CONFIG_DEBUG_COLOR +#else //RNG_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL 0 +#endif //RNG_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +typedef struct +{ + nrfx_drv_state_t state; + nrf_drv_rng_config_t config; +} nrf_drv_rng_cb_t; + +static nrf_drv_rng_cb_t m_rng_cb; +NRF_QUEUE_DEF(uint8_t, m_rand_pool, RNG_CONFIG_POOL_SIZE, NRF_QUEUE_MODE_OVERFLOW); +static const nrf_drv_rng_config_t m_default_config = NRF_DRV_RNG_DEFAULT_CONFIG; + +#ifdef SOFTDEVICE_PRESENT + #define SD_RAND_POOL_SIZE (64) + + STATIC_ASSERT(RNG_CONFIG_POOL_SIZE == SD_RAND_POOL_SIZE); + + #define NRF_DRV_RNG_LOCK() CRITICAL_REGION_ENTER() + #define NRF_DRV_RNG_RELEASE() CRITICAL_REGION_EXIT() + #define NRF_DRV_RNG_SD_IS_ENABLED() nrf_sdh_is_enabled() +#else + #define NRF_DRV_RNG_LOCK() do { } while (0) + #define NRF_DRV_RNG_RELEASE() do { } while (0) + #define NRF_DRV_RNG_SD_IS_ENABLED() false +#endif // SOFTDEVICE_PRESENT + + +static void nrfx_rng_handler(uint8_t rng_val) +{ + NRF_DRV_RNG_LOCK(); + if (!NRF_DRV_RNG_SD_IS_ENABLED()) + { + UNUSED_RETURN_VALUE(nrf_queue_push(&m_rand_pool, &rng_val)); + + if (nrf_queue_is_full(&m_rand_pool)) + { + nrfx_rng_stop(); + } + + NRF_LOG_DEBUG("Event: NRF_RNG_EVENT_VALRDY."); + } + NRF_DRV_RNG_RELEASE(); + +} + +ret_code_t nrf_drv_rng_init(nrf_drv_rng_config_t const * p_config) +{ + ret_code_t err_code = NRF_SUCCESS; + if (m_rng_cb.state != NRFX_DRV_STATE_UNINITIALIZED) + { + return NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } + + if (p_config == NULL) + { + p_config = &m_default_config; + } + m_rng_cb.config = *p_config; + + NRF_DRV_RNG_LOCK(); + + if (!NRF_DRV_RNG_SD_IS_ENABLED()) + { + err_code = nrfx_rng_init(&m_rng_cb.config, nrfx_rng_handler); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + nrfx_rng_start(); + } + m_rng_cb.state = NRFX_DRV_STATE_INITIALIZED; + + NRF_DRV_RNG_RELEASE(); + + return err_code; +} + +void nrf_drv_rng_uninit(void) +{ + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); + + NRF_DRV_RNG_LOCK(); + + if (!NRF_DRV_RNG_SD_IS_ENABLED()) + { + nrfx_rng_stop(); + nrfx_rng_uninit(); + } + + NRF_DRV_RNG_RELEASE(); + + nrf_queue_reset(&m_rand_pool); + m_rng_cb.state = NRFX_DRV_STATE_UNINITIALIZED; + NRF_LOG_INFO("Uninitialized."); +} + +void nrf_drv_rng_bytes_available(uint8_t * p_bytes_available) +{ + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); + +#ifdef SOFTDEVICE_PRESENT + if (NRF_DRV_RNG_SD_IS_ENABLED()) + { + if (NRF_SUCCESS == sd_rand_application_bytes_available_get(p_bytes_available)) + { + return; + } + } +#endif // SOFTDEVICE_PRESENT + + *p_bytes_available = nrf_queue_utilization_get(&m_rand_pool); + + NRF_LOG_INFO("Function: %s, available bytes: %d.", (uint32_t)__func__, *p_bytes_available); +} + +ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length) +{ + ret_code_t err_code = NRF_SUCCESS; + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); + +#ifdef SOFTDEVICE_PRESENT + do { + bool sd_is_enabled; + NRF_DRV_RNG_LOCK(); + sd_is_enabled = NRF_DRV_RNG_SD_IS_ENABLED(); + if (!sd_is_enabled) +#endif // SOFTDEVICE_PRESENT + { + err_code = nrf_queue_read(&m_rand_pool, p_buff, (uint32_t)length); + nrfx_rng_start(); + } +#ifdef SOFTDEVICE_PRESENT + NRF_DRV_RNG_RELEASE(); + + if (sd_is_enabled) + { + err_code = sd_rand_application_vector_get(p_buff, length); + if (err_code == NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES) + { + err_code = NRF_ERROR_NOT_FOUND; + } + } + } while (err_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED); +#endif // SOFTDEVICE_PRESENT + ASSERT((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_NOT_FOUND)); + +#if defined(RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED) && (RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED != 0) + NRF_LOG_DEBUG("Rand buffer data:"); + NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_buff, length); +#endif // RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED + NRF_LOG_WARNING("Function: %s, error code: %s.", + (uint32_t)__func__, + (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code)); + + return err_code; +} + +void nrf_drv_rng_block_rand(uint8_t * p_buff, uint32_t length) +{ + ASSERT(m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED); + + while (length) + { + uint32_t len = MIN(length, RNG_CONFIG_POOL_SIZE); + ret_code_t err_code; + + do { + err_code = nrf_drv_rng_rand(p_buff, len); + } while (err_code != NRF_SUCCESS); + + length -= len; + p_buff += len; + } + + NRF_LOG_DEBUG("Rand buffer data:"); + NRF_LOG_HEXDUMP_DEBUG((uint8_t *)p_buff, length); +} + +#ifdef SOFTDEVICE_PRESENT +static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context) +{ + switch (state) + { + case NRF_SDH_EVT_STATE_ENABLE_PREPARE: + if (m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED) + { + nrfx_rng_stop(); + nrfx_rng_uninit(); + } + break; + + case NRF_SDH_EVT_STATE_DISABLED: + NRF_DRV_RNG_LOCK(); + if (m_rng_cb.state == NRFX_DRV_STATE_INITIALIZED) + { + ret_code_t err_code = nrfx_rng_init(&m_rng_cb.config, nrfx_rng_handler); + if (err_code != NRF_SUCCESS) + { + ASSERT(false); + } + nrfx_rng_start(); + } + NRF_DRV_RNG_RELEASE(); + break; + + default: + break; + } +} + +NRF_SDH_STATE_OBSERVER(m_sd_state_observer, RNG_CONFIG_STATE_OBSERVER_PRIO) = +{ + .handler = sd_state_evt_handler, + .p_context = NULL, +}; + +#endif // SOFTDEVICE_PRESENT + +#endif // NRF_MODULE_ENABLED(RNG) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.h new file mode 100644 index 0000000..3a4b306 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rng.h @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_RNG_H__ +#define NRF_DRV_RNG_H__ + +#include <nrfx_rng.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_rng RNG driver - legacy layer + * @{ + * @ingroup nrf_rng + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rng_config_t nrf_drv_rng_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RNG_DEFAULT_CONFIG NRFX_RNG_DEFAULT_CONFIG + +/** + * @brief Function for initializing the nrf_drv_rng module. + * + * @param[in] p_config Initial configuration. + * + * @retval NRF_SUCCESS Driver was successfully initialized. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED Driver was already initialized. + */ +ret_code_t nrf_drv_rng_init(nrf_drv_rng_config_t const * p_config); + +/** + * @brief Function for uninitializing the nrf_drv_rng module. + */ +void nrf_drv_rng_uninit(void); + +/** + * @brief Function for getting the number of currently available random bytes. + * + * @param[out] p_bytes_available The number of bytes currently available in the pool. + */ +void nrf_drv_rng_bytes_available(uint8_t * p_bytes_available); + +/** + * @brief Function for getting the vector of random numbers. + * + * @param[out] p_buff Pointer to uint8_t buffer for storing the bytes. + * @param[in] length Number of bytes to take from the pool and place in p_buff. + * + * @retval NRF_SUCCESS If the requested bytes were written to p_buff. + * @retval NRF_ERROR_NOT_FOUND If no bytes were written to the buffer because there were + * not enough bytes available in the pool. + */ +ret_code_t nrf_drv_rng_rand(uint8_t * p_buff, uint8_t length); + +/** + * @brief Blocking function for getting an arbitrary array of random numbers. + * + * @note This function may execute for a substantial amount of time depending on the length + * of the buffer required and on the state of the current internal pool of random numbers. + * + * @param[out] p_buff Pointer to uint8_t buffer for storing the bytes. + * @param[in] length Number of bytes place in p_buff. + */ +void nrf_drv_rng_block_rand(uint8_t * p_buff, uint32_t length); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_RNG_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rtc.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rtc.h new file mode 100644 index 0000000..1e5d82f --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_rtc.h @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2014 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_RTC_H__ +#define NRF_DRV_RTC_H__ + +#include <nrfx_rtc.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_rtc RTC driver - legacy layer + * @{ + * @ingroup nrf_rtc + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rtc_t nrf_drv_rtc_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_rtc_config_t nrf_drv_rtc_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INSTANCE NRFX_RTC_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_DEFAULT_CONFIG NRFX_RTC_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define RTC_US_TO_TICKS NRFX_RTC_US_TO_TICKS + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE0 NRFX_RTC_INT_COMPARE0 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE1 NRFX_RTC_INT_COMPARE1 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE2 NRFX_RTC_INT_COMPARE2 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_COMPARE3 NRFX_RTC_INT_COMPARE3 +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_TICK NRFX_RTC_INT_TICK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_RTC_INT_OVERFLOW NRFX_RTC_INT_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_type_t nrfx_rtc_int_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_handler_t nrfx_rtc_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_init nrfx_rtc_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_uninit nrfx_rtc_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_enable nrfx_rtc_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_disable nrfx_rtc_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_cc_set nrfx_rtc_cc_set +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_cc_disable nrfx_rtc_cc_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_tick_enable nrfx_rtc_tick_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_tick_disable nrfx_rtc_tick_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_overflow_enable nrfx_rtc_overflow_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_overflow_disable nrfx_rtc_overflow_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_max_ticks_get nrfx_rtc_max_ticks_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_disable nrfx_rtc_int_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_int_enable nrfx_rtc_int_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_counter_get nrfx_rtc_counter_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_counter_clear nrfx_rtc_counter_clear + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_task_address_get nrfx_rtc_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_rtc_event_address_get nrfx_rtc_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_RTC_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_saadc.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_saadc.h new file mode 100644 index 0000000..8c25b06 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_saadc.h @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_SAADC_H__ +#define NRF_DRV_SAADC_H__ + +#include <nrfx_saadc.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_saadc SAADC driver - legacy layer + * @{ + * @ingroup nrf_saadc + * + * @brief @tagAPI52 Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_saadc_config_t nrf_drv_saadc_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_DONE NRFX_SAADC_EVT_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_LIMIT NRFX_SAADC_EVT_LIMIT +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_EVT_CALIBRATEDONE NRFX_SAADC_EVT_CALIBRATEDONE +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_evt_type_t nrfx_saadc_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_done_evt_t nrfx_saadc_done_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_limit_evt_t nrfx_saadc_limit_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_evt_t nrfx_saadc_evt_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_event_handler_t nrfx_saadc_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_LIMITH_DISABLED NRFX_SAADC_LIMITH_DISABLED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_LIMITL_DISABLED NRFX_SAADC_LIMITL_DISABLED +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CONFIG NRFX_SAADC_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE \ + NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL \ + NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_uninit nrfx_saadc_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_channel_init nrfx_saadc_channel_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_channel_uninit nrfx_saadc_channel_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample nrfx_saadc_sample +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample_convert nrfx_saadc_sample_convert +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_buffer_convert nrfx_saadc_buffer_convert +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_calibrate_offset nrfx_saadc_calibrate_offset +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_is_busy nrfx_saadc_is_busy +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_abort nrfx_saadc_abort +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_limits_set nrfx_saadc_limits_set + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_saadc_sample_task_get nrfx_saadc_sample_task_get + +/** + * @brief Function for initializing the SAADC. + * + * @param[in] p_config Pointer to the structure with initial configuration. + * If NULL, the default one is used. + * @param[in] event_handler Event handler provided by the user. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized. + * @retval NRF_ERROR_INVALID_PARAM If event_handler is NULL. + */ +__STATIC_INLINE ret_code_t nrf_drv_saadc_init(nrf_drv_saadc_config_t const * p_config, + nrf_drv_saadc_event_handler_t event_handler) +{ + if (p_config == NULL) + { + static const nrfx_saadc_config_t default_config = NRFX_SAADC_DEFAULT_CONFIG; + p_config = &default_config; + } + return nrfx_saadc_init(p_config, event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SAADC_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.c new file mode 100644 index 0000000..1835a64 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.c @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_spi.h" + +#ifdef SPIM_PRESENT +#define INSTANCE_COUNT SPIM_COUNT +#else +#define INSTANCE_COUNT SPI_COUNT +#endif + +static nrf_drv_spi_evt_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +#ifdef SPIM_PRESENT +static void spim_evt_handler(nrfx_spim_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_spi_evt_t const event = + { + .type = (nrf_drv_spi_evt_type_t)p_event->type, + .data = + { + .done = + { + .p_tx_buffer = p_event->xfer_desc.p_tx_buffer, + .tx_length = p_event->xfer_desc.tx_length, + .p_rx_buffer = p_event->xfer_desc.p_rx_buffer, + .rx_length = p_event->xfer_desc.rx_length, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // SPIM_PRESENT + +#ifdef SPI_PRESENT +static void spi_evt_handler(nrfx_spi_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_spi_evt_t const event = + { + .type = (nrf_drv_spi_evt_type_t)p_event->type, + .data = + { + .done = + { + .p_tx_buffer = p_event->xfer_desc.p_tx_buffer, + .tx_length = p_event->xfer_desc.tx_length, + .p_rx_buffer = p_event->xfer_desc.p_rx_buffer, + .rx_length = p_event->xfer_desc.rx_length, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // SPI_PRESENT + +ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_config_t const * p_config, + nrf_drv_spi_evt_handler_t handler, + void * p_context) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = handler; + m_contexts[inst_idx] = p_context; + + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { +#ifdef SPIM_PRESENT + nrfx_spim_config_t config_spim = NRFX_SPIM_DEFAULT_CONFIG; + config_spim.sck_pin = p_config->sck_pin; + config_spim.mosi_pin = p_config->mosi_pin; + config_spim.miso_pin = p_config->miso_pin; + config_spim.ss_pin = p_config->ss_pin; + config_spim.irq_priority = p_config->irq_priority; + config_spim.orc = p_config->orc; + config_spim.frequency = (nrf_spim_frequency_t)p_config->frequency; + config_spim.mode = (nrf_spim_mode_t)p_config->mode; + config_spim.bit_order = (nrf_spim_bit_order_t)p_config->bit_order; + result = nrfx_spim_init(&p_instance->u.spim, + &config_spim, + handler ? spim_evt_handler : NULL, + (void *)inst_idx); +#endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + result = nrfx_spi_init(&p_instance->u.spi, + (nrfx_spi_config_t const *)p_config, + handler ? spi_evt_handler : NULL, + (void *)inst_idx); + } + return result; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.h new file mode 100644 index 0000000..8656a49 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spi.h @@ -0,0 +1,615 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_SPI_H__ +#define NRF_DRV_SPI_H__ + +#include <nrfx.h> +#ifdef SPIM_PRESENT + #include <nrfx_spim.h> +#else + // Compilers (at least the smart ones) will remove the SPIM related code + // (blocks starting with "if (NRF_DRV_SPI_USE_SPIM)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_spim_init(...) 0 + #define nrfx_spim_uninit(...) + #define nrfx_spim_start_task_get(...) 0 + #define nrfx_spim_end_event_get(...) 0 + #define nrfx_spim_abort(...) +#endif + +#ifdef SPI_PRESENT + #include <nrfx_spi.h> +#else + // Compilers (at least the smart ones) will remove the SPI related code + // (blocks starting with "if (NRF_DRV_SPI_USE_SPI)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_spi_init(...) 0 + #define nrfx_spi_uninit(...) + #define nrfx_spi_start_task_get(...) 0 + #define nrfx_spi_end_event_get(...) 0 + #define nrfx_spi_abort(...) + + // This part is for old modules that use directly SPI HAL definitions + // (to make them compilable for chips that have only SPIM). + #define NRF_SPI_FREQ_125K NRF_SPIM_FREQ_125K + #define NRF_SPI_FREQ_250K NRF_SPIM_FREQ_250K + #define NRF_SPI_FREQ_500K NRF_SPIM_FREQ_500K + #define NRF_SPI_FREQ_1M NRF_SPIM_FREQ_1M + #define NRF_SPI_FREQ_2M NRF_SPIM_FREQ_2M + #define NRF_SPI_FREQ_4M NRF_SPIM_FREQ_4M + #define NRF_SPI_FREQ_8M NRF_SPIM_FREQ_8M + #define NRF_SPI_MODE_0 NRF_SPIM_MODE_0 + #define NRF_SPI_MODE_1 NRF_SPIM_MODE_1 + #define NRF_SPI_MODE_2 NRF_SPIM_MODE_2 + #define NRF_SPI_MODE_3 NRF_SPIM_MODE_3 + #define NRF_SPI_BIT_ORDER_MSB_FIRST NRF_SPIM_BIT_ORDER_MSB_FIRST + #define NRF_SPI_BIT_ORDER_LSB_FIRST NRF_SPIM_BIT_ORDER_LSB_FIRST +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_spi SPI master driver + * @{ + * @ingroup nrf_spi + * @brief Layer providing compatibility with the former API. + */ + +/** + * @brief SPI master driver instance data structure. + */ +typedef struct +{ + uint8_t inst_idx; + union + { +#ifdef SPIM_PRESENT + nrfx_spim_t spim; +#endif +#ifdef SPI_PRESENT + nrfx_spi_t spi; +#endif + } u; + bool use_easy_dma; +} nrf_drv_spi_t; + +/** + * @brief Macro for creating an SPI master driver instance. + */ +#define NRF_DRV_SPI_INSTANCE(id) NRF_DRV_SPI_INSTANCE_(id) +#define NRF_DRV_SPI_INSTANCE_(id) NRF_DRV_SPI_INSTANCE_ ## id +#if NRFX_CHECK(NRFX_SPIM0_ENABLED) + #define NRF_DRV_SPI_INSTANCE_0 \ + { 0, { .spim = NRFX_SPIM_INSTANCE(0) }, true } +#elif NRFX_CHECK(NRFX_SPI0_ENABLED) + #define NRF_DRV_SPI_INSTANCE_0 \ + { 0, { .spi = NRFX_SPI_INSTANCE(0) }, false } +#endif +#if NRFX_CHECK(NRFX_SPIM1_ENABLED) + #define NRF_DRV_SPI_INSTANCE_1 \ + { 1, { .spim = NRFX_SPIM_INSTANCE(1) }, true } +#elif NRFX_CHECK(NRFX_SPI1_ENABLED) + #define NRF_DRV_SPI_INSTANCE_1 \ + { 1, { .spi = NRFX_SPI_INSTANCE(1) }, false } +#endif +#if NRFX_CHECK(NRFX_SPIM2_ENABLED) + #define NRF_DRV_SPI_INSTANCE_2 \ + { 2, { .spim = NRFX_SPIM_INSTANCE(2) }, true } +#elif NRFX_CHECK(NRFX_SPI2_ENABLED) + #define NRF_DRV_SPI_INSTANCE_2 \ + { 2, { .spi = NRFX_SPI_INSTANCE(2) }, false } +#endif + +/** + * @brief This value can be provided instead of a pin number for signals MOSI, + * MISO, and Slave Select to specify that the given signal is not used and + * therefore does not need to be connected to a pin. + */ +#define NRF_DRV_SPI_PIN_NOT_USED 0xFF + +/** + * @brief SPI data rates. + */ +typedef enum +{ + NRF_DRV_SPI_FREQ_125K = NRF_SPI_FREQ_125K, ///< 125 kbps. + NRF_DRV_SPI_FREQ_250K = NRF_SPI_FREQ_250K, ///< 250 kbps. + NRF_DRV_SPI_FREQ_500K = NRF_SPI_FREQ_500K, ///< 500 kbps. + NRF_DRV_SPI_FREQ_1M = NRF_SPI_FREQ_1M, ///< 1 Mbps. + NRF_DRV_SPI_FREQ_2M = NRF_SPI_FREQ_2M, ///< 2 Mbps. + NRF_DRV_SPI_FREQ_4M = NRF_SPI_FREQ_4M, ///< 4 Mbps. + NRF_DRV_SPI_FREQ_8M = NRF_SPI_FREQ_8M ///< 8 Mbps. +} nrf_drv_spi_frequency_t; + +/** + * @brief SPI modes. + */ +typedef enum +{ + NRF_DRV_SPI_MODE_0 = NRF_SPI_MODE_0, ///< SCK active high, sample on leading edge of clock. + NRF_DRV_SPI_MODE_1 = NRF_SPI_MODE_1, ///< SCK active high, sample on trailing edge of clock. + NRF_DRV_SPI_MODE_2 = NRF_SPI_MODE_2, ///< SCK active low, sample on leading edge of clock. + NRF_DRV_SPI_MODE_3 = NRF_SPI_MODE_3 ///< SCK active low, sample on trailing edge of clock. +} nrf_drv_spi_mode_t; + +/** + * @brief SPI bit orders. + */ +typedef enum +{ + NRF_DRV_SPI_BIT_ORDER_MSB_FIRST = NRF_SPI_BIT_ORDER_MSB_FIRST, ///< Most significant bit shifted out first. + NRF_DRV_SPI_BIT_ORDER_LSB_FIRST = NRF_SPI_BIT_ORDER_LSB_FIRST ///< Least significant bit shifted out first. +} nrf_drv_spi_bit_order_t; + +/** + * @brief SPI master driver instance configuration structure. + */ +typedef struct +{ + uint8_t sck_pin; ///< SCK pin number. + uint8_t mosi_pin; ///< MOSI pin number (optional). + /**< Set to @ref NRF_DRV_SPI_PIN_NOT_USED + * if this signal is not needed. */ + uint8_t miso_pin; ///< MISO pin number (optional). + /**< Set to @ref NRF_DRV_SPI_PIN_NOT_USED + * if this signal is not needed. */ + uint8_t ss_pin; ///< Slave Select pin number (optional). + /**< Set to @ref NRF_DRV_SPI_PIN_NOT_USED + * if this signal is not needed. The driver + * supports only active low for this signal. + * If the signal should be active high, + * it must be controlled externally. */ + uint8_t irq_priority; ///< Interrupt priority. + uint8_t orc; ///< Over-run character. + /**< This character is used when all bytes from the TX buffer are sent, + but the transfer continues due to RX. */ + nrf_drv_spi_frequency_t frequency; ///< SPI frequency. + nrf_drv_spi_mode_t mode; ///< SPI mode. + nrf_drv_spi_bit_order_t bit_order; ///< SPI bit order. +} nrf_drv_spi_config_t; + +/** + * @brief SPI master instance default configuration. + */ +#define NRF_DRV_SPI_DEFAULT_CONFIG \ +{ \ + .sck_pin = NRF_DRV_SPI_PIN_NOT_USED, \ + .mosi_pin = NRF_DRV_SPI_PIN_NOT_USED, \ + .miso_pin = NRF_DRV_SPI_PIN_NOT_USED, \ + .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \ + .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \ + .orc = 0xFF, \ + .frequency = NRF_DRV_SPI_FREQ_4M, \ + .mode = NRF_DRV_SPI_MODE_0, \ + .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST, \ +} + +#define NRF_DRV_SPI_FLAG_TX_POSTINC (1UL << 0) /**< TX buffer address incremented after transfer. */ +#define NRF_DRV_SPI_FLAG_RX_POSTINC (1UL << 1) /**< RX buffer address incremented after transfer. */ +#define NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER (1UL << 2) /**< Interrupt after each transfer is suppressed, and the event handler is not called. */ +#define NRF_DRV_SPI_FLAG_HOLD_XFER (1UL << 3) /**< Set up the transfer but do not start it. */ +#define NRF_DRV_SPI_FLAG_REPEATED_XFER (1UL << 4) /**< Flag indicating that the transfer will be executed multiple times. */ + +/** + * @brief Single transfer descriptor structure. + */ +typedef struct +{ + uint8_t const * p_tx_buffer; ///< Pointer to TX buffer. + uint8_t tx_length; ///< TX buffer length. + uint8_t * p_rx_buffer; ///< Pointer to RX buffer. + uint8_t rx_length; ///< RX buffer length. +}nrf_drv_spi_xfer_desc_t; + +/** + * @brief Macro for setting up single transfer descriptor. + * + * This macro is for internal use only. + */ +#define NRF_DRV_SPI_SINGLE_XFER(p_tx, tx_len, p_rx, rx_len) \ + { \ + .p_tx_buffer = (uint8_t const *)(p_tx), \ + .tx_length = (tx_len), \ + .p_rx_buffer = (p_rx), \ + .rx_length = (rx_len), \ + } + +/** + * @brief Macro for setting duplex TX RX transfer. + */ +#define NRF_DRV_SPI_XFER_TRX(p_tx_buf, tx_length, p_rx_buf, rx_length) \ + NRF_DRV_SPI_SINGLE_XFER(p_tx_buf, tx_length, p_rx_buf, rx_length) + +/** + * @brief Macro for setting TX transfer. + */ +#define NRF_DRV_SPI_XFER_TX(p_buf, length) \ + NRF_DRV_SPI_SINGLE_XFER(p_buf, length, NULL, 0) + +/** + * @brief Macro for setting RX transfer. + */ +#define NRF_DRV_SPI_XFER_RX(p_buf, length) \ + NRF_DRV_SPI_SINGLE_XFER(NULL, 0, p_buf, length) + +/** + * @brief SPI master driver event types, passed to the handler routine provided + * during initialization. + */ +typedef enum +{ + NRF_DRV_SPI_EVENT_DONE, ///< Transfer done. +} nrf_drv_spi_evt_type_t; + +typedef struct +{ + nrf_drv_spi_evt_type_t type; ///< Event type. + union + { + nrf_drv_spi_xfer_desc_t done; ///< Event data for DONE event. + } data; +} nrf_drv_spi_evt_t; + +/** + * @brief SPI master driver event handler type. + */ +typedef void (* nrf_drv_spi_evt_handler_t)(nrf_drv_spi_evt_t const * p_event, + void * p_context); + + +/** + * @brief Function for initializing the SPI master driver instance. + * + * This function configures and enables the specified peripheral. + * + * @note MISO pin has pull down enabled. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Pointer to the structure with the initial configuration. + * + * @param handler Event handler provided by the user. If NULL, transfers + * will be performed in blocking mode. + * @param p_context Context passed to event handler. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. + * @retval NRF_ERROR_BUSY If some other peripheral with the same + * instance ID is already in use. This is + * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED + * is set to a value other than zero. + */ +ret_code_t nrf_drv_spi_init(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_config_t const * p_config, + nrf_drv_spi_evt_handler_t handler, + void * p_context); + +/** + * @brief Function for uninitializing the SPI master driver instance. + * + * @note Configuration of pins is kept. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_spi_uninit(nrf_drv_spi_t const * const p_instance); + +/** + * @brief Function for starting the SPI data transfer. + * + * If an event handler was provided in the @ref nrf_drv_spi_init call, this function + * returns immediately and the handler is called when the transfer is done. + * Otherwise, the transfer is performed in blocking mode, which means that this function + * returns when the transfer is finished. + * + * @note Peripherals using EasyDMA (for example, SPIM) require the transfer buffers + * to be placed in the Data RAM region. If they are not and an SPIM instance is + * used, this function will fail with the error code NRF_ERROR_INVALID_ADDR. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_tx_buffer Pointer to the transmit buffer. Can be NULL + * if there is nothing to send. + * @param tx_buffer_length Length of the transmit buffer. + * @param[in] p_rx_buffer Pointer to the receive buffer. Can be NULL + * if there is nothing to receive. + * @param rx_buffer_length Length of the receive buffer. + * + * @retval NRF_SUCCESS If the operation was successful. + * @retval NRF_ERROR_BUSY If a previously started transfer has not finished + * yet. + * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data + * RAM region. + */ +__STATIC_INLINE +ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, + uint8_t const * p_tx_buffer, + uint8_t tx_buffer_length, + uint8_t * p_rx_buffer, + uint8_t rx_buffer_length); + +/** + * @brief Function for starting the SPI data transfer with additional option flags. + * + * Function enables customizing the transfer by using option flags. + * + * Additional options are provided using the flags parameter: + * + * - @ref NRF_DRV_SPI_FLAG_TX_POSTINC and @ref NRF_DRV_SPI_FLAG_RX_POSTINC<span></span>: + * Post-incrementation of buffer addresses. Supported only by SPIM. + * - @ref NRF_DRV_SPI_FLAG_HOLD_XFER<span></span>: Driver is not starting the transfer. Use this + * flag if the transfer is triggered externally by PPI. Supported only by SPIM. Use + * @ref nrf_drv_spi_start_task_get to get the address of the start task. + * - @ref NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER<span></span>: No user event handler after transfer + * completion. This also means no interrupt at the end of the transfer. Supported only by SPIM. + * If @ref NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER is used, the driver does not set the instance into + * busy state, so you must ensure that the next transfers are set up when SPIM is not active. + * @ref nrf_drv_spi_end_event_get function can be used to detect end of transfer. Option can be used + * together with @ref NRF_DRV_SPI_FLAG_REPEATED_XFER to prepare a sequence of SPI transfers + * without interruptions. + * - @ref NRF_DRV_SPI_FLAG_REPEATED_XFER<span></span>: Prepare for repeated transfers. You can set + * up a number of transfers that will be triggered externally (for example by PPI). An example is + * a TXRX transfer with the options @ref NRF_DRV_SPI_FLAG_RX_POSTINC, + * @ref NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER, and @ref NRF_DRV_SPI_FLAG_REPEATED_XFER. After the + * transfer is set up, a set of transfers can be triggered by PPI that will read, for example, + * the same register of an external component and put it into a RAM buffer without any interrupts. + * @ref nrf_drv_spi_end_event_get can be used to get the address of the END event, which can be + * used to count the number of transfers. If @ref NRF_DRV_SPI_FLAG_REPEATED_XFER is used, + * the driver does not set the instance into busy state, so you must ensure that the next + * transfers are set up when SPIM is not active. Supported only by SPIM. + * @note Function is intended to be used only in non-blocking mode. + * + * @param p_instance Pointer to the driver instance structure. + * @param p_xfer_desc Pointer to the transfer descriptor. + * @param flags Transfer options (0 for default settings). + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_BUSY If the driver is not ready for a new transfer. + * @retval NRF_ERROR_NOT_SUPPORTED If the provided parameters are not supported. + * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data + * RAM region. + */ +__STATIC_INLINE +ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_xfer_desc_t const * p_xfer_desc, + uint32_t flags); + +/** + * @brief Function for returning the address of a SPIM start task. + * + * This function should be used if @ref nrf_drv_spi_xfer was called with the flag @ref NRF_DRV_SPI_FLAG_HOLD_XFER. + * In that case, the transfer is not started by the driver, but it must be started externally by PPI. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return Start task address. + */ +__STATIC_INLINE +uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance); + +/** + * @brief Function for returning the address of a END SPIM event. + * + * A END event can be used to detect the end of a transfer if the @ref NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER + * option is used. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return END event address. + */ +__STATIC_INLINE +uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance); + +/** + * @brief Function for aborting ongoing transfer. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance); + + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(SPI_PRESENT) && !defined(SPIM_PRESENT) +#define NRF_DRV_SPI_WITH_SPI +#elif !defined(SPI_PRESENT) && defined(SPIM_PRESENT) +#define NRF_DRV_SPI_WITH_SPIM +#else +#if (NRFX_CHECK(SPI0_ENABLED) && NRFX_CHECK(SPI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI1_ENABLED) && NRFX_CHECK(SPI1_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI2_ENABLED) && NRFX_CHECK(SPI2_USE_EASY_DMA)) + #define NRF_DRV_SPI_WITH_SPIM +#endif +#if (NRFX_CHECK(SPI0_ENABLED) && !NRFX_CHECK(SPI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI1_ENABLED) && !NRFX_CHECK(SPI1_USE_EASY_DMA)) || \ + (NRFX_CHECK(SPI2_ENABLED) && !NRFX_CHECK(SPI2_USE_EASY_DMA)) + #define NRF_DRV_SPI_WITH_SPI +#endif +#endif +#if defined(NRF_DRV_SPI_WITH_SPIM) && defined(NRF_DRV_SPI_WITH_SPI) + #define NRF_DRV_SPI_USE_SPIM (p_instance->use_easy_dma) +#elif defined(NRF_DRV_SPI_WITH_SPIM) + #define NRF_DRV_SPI_USE_SPIM true +#else + #define NRF_DRV_SPI_USE_SPIM false +#endif +#define NRF_DRV_SPI_USE_SPI (!NRF_DRV_SPI_USE_SPIM) + +__STATIC_INLINE +void nrf_drv_spi_uninit(nrf_drv_spi_t const * p_instance) +{ + if (NRF_DRV_SPI_USE_SPIM) + { + nrfx_spim_uninit(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + nrfx_spi_uninit(&p_instance->u.spi); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance, + uint8_t const * p_tx_buffer, + uint8_t tx_buffer_length, + uint8_t * p_rx_buffer, + uint8_t rx_buffer_length) +{ + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + #ifdef SPIM_PRESENT + nrfx_spim_xfer_desc_t const spim_xfer_desc = + { + .p_tx_buffer = p_tx_buffer, + .tx_length = tx_buffer_length, + .p_rx_buffer = p_rx_buffer, + .rx_length = rx_buffer_length, + }; + result = nrfx_spim_xfer(&p_instance->u.spim, &spim_xfer_desc, 0); + #endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + #ifdef SPI_PRESENT + nrfx_spi_xfer_desc_t const spi_xfer_desc = + { + .p_tx_buffer = p_tx_buffer, + .tx_length = tx_buffer_length, + .p_rx_buffer = p_rx_buffer, + .rx_length = rx_buffer_length, + }; + result = nrfx_spi_xfer(&p_instance->u.spi, &spi_xfer_desc, 0); + #endif + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance, + nrf_drv_spi_xfer_desc_t const * p_xfer_desc, + uint32_t flags) +{ + ret_code_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + #ifdef SPIM_PRESENT + nrfx_spim_xfer_desc_t const spim_xfer_desc = + { + .p_tx_buffer = p_xfer_desc->p_tx_buffer, + .tx_length = p_xfer_desc->tx_length, + .p_rx_buffer = p_xfer_desc->p_rx_buffer, + .rx_length = p_xfer_desc->rx_length, + }; + result = nrfx_spim_xfer(&p_instance->u.spim, &spim_xfer_desc, flags); + #endif + } + else if (NRF_DRV_SPI_USE_SPI) + { + #ifdef SPI_PRESENT + nrfx_spi_xfer_desc_t const spi_xfer_desc = + { + .p_tx_buffer = p_xfer_desc->p_tx_buffer, + .tx_length = p_xfer_desc->tx_length, + .p_rx_buffer = p_xfer_desc->p_rx_buffer, + .rx_length = p_xfer_desc->rx_length, + }; + result = nrfx_spi_xfer(&p_instance->u.spi, &spi_xfer_desc, flags); + #endif + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + result = nrfx_spim_start_task_get(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_SPI_USE_SPIM) + { + result = nrfx_spim_end_event_get(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance) +{ + if (NRF_DRV_SPI_USE_SPIM) + { + nrfx_spim_abort(&p_instance->u.spim); + } + else if (NRF_DRV_SPI_USE_SPI) + { + nrfx_spi_abort(&p_instance->u.spi); + } +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SPI_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.c new file mode 100644 index 0000000..0293f76 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.c @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2018 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_spis.h" + +static nrf_drv_spis_event_handler_t m_handlers[SPIS_COUNT]; + +static void spis_event_handler(nrfx_spis_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + m_handlers[inst_idx](*p_event); +} + +ret_code_t nrf_drv_spis_init(nrf_drv_spis_t const * const p_instance, + nrf_drv_spis_config_t const * p_config, + nrf_drv_spis_event_handler_t event_handler) +{ + uint32_t inst_idx = p_instance->drv_inst_idx; + m_handlers[inst_idx] = event_handler; + + return nrfx_spis_init(p_instance, + p_config, + spis_event_handler, + (void *)inst_idx); +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.h new file mode 100644 index 0000000..ff8b521 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_spis.h @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2014 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_SPIS_H__ +#define NRF_DRV_SPIS_H__ + +#include <nrfx_spis.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_spis SPIS driver - legacy layer + * @{ + * @ingroup nrf_spis + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_t nrf_drv_spis_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_config_t nrf_drv_spis_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_spis_evt_t nrf_drv_spis_event_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_INSTANCE NRFX_SPIS_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_CONFIG NRFX_SPIS_DEFAULT_CONFIG +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_CSN_PULLUP NRFX_SPIS_DEFAULT_CSN_PULLUP +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_DEFAULT_MISO_DRIVE NRFX_SPIS_DEFAULT_MISO_DRIVE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_PIN_NOT_USED NRFX_SPIS_PIN_NOT_USED + +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_BIT_ORDER_LSB_FIRST NRF_SPIS_BIT_ORDER_LSB_FIRST +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST NRF_SPIS_BIT_ORDER_MSB_FIRST +/** @brief Macro for providing API backward compatibility. */ +#define nrf_drv_spis_endian_t nrf_spis_bit_order_t +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_0 NRF_SPIS_MODE_0 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_1 NRF_SPIS_MODE_1 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_2 NRF_SPIS_MODE_2 +/** @brief Macro for providing API backward compatibility. */ +#define NRF_DRV_SPIS_MODE_3 NRF_SPIS_MODE_3 +/** @brief Macro for providing API backward compatibility. */ +#define nrf_drv_spis_mode_t nrf_spis_mode_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_BUFFERS_SET_DONE NRFX_SPIS_BUFFERS_SET_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_XFER_DONE NRFX_SPIS_XFER_DONE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_SPIS_EVT_TYPE_MAX NRFX_SPIS_EVT_TYPE_MAX +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_event_type_t nrfx_spis_evt_type_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_uninit nrfx_spis_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_spis_buffers_set nrfx_spis_buffers_set + +/** @brief SPI slave event callback function type. + * + * @param[in] event SPI slave driver event. + */ +typedef void (*nrf_drv_spis_event_handler_t)(nrf_drv_spis_event_t event); + +/** @brief Function for initializing the SPI slave driver instance. + * + * @note When the nRF52 Anomaly 109 workaround for SPIS is enabled, this function + * initializes the GPIOTE driver as well, and uses one of GPIOTE channels + * to detect falling edges on CSN pin. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Pointer to the structure with the initial configuration. + * If NULL, the default configuration will be used. + * @param[in] event_handler Function to be called by the SPI slave driver upon event. + * + * @retval NRF_SUCCESS If the initialization was successful. + * @retval NRF_ERROR_INVALID_PARAM If an invalid parameter is supplied. + * @retval NRFX_ERROR_INVALID_STATE If the instance is already initialized. + * @retval NRF_ERROR_BUSY If some other peripheral with the same + * instance ID is already in use. This is + * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED + * is set to a value other than zero. + * @retval NRF_ERROR_INTERNAL GPIOTE channel for detecting falling edges + * on CSN pin cannot be initialized. Possible + * only when using nRF52 Anomaly 109 workaround. + */ +ret_code_t nrf_drv_spis_init(nrf_drv_spis_t const * const p_instance, + nrf_drv_spis_config_t const * p_config, + nrf_drv_spis_event_handler_t event_handler); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SPIS_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.c new file mode 100644 index 0000000..3807d3e --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.c @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_swi.h" + +static nrfx_drv_state_t m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; + +ret_code_t nrf_drv_swi_init(void) +{ + if (m_drv_state == NRFX_DRV_STATE_INITIALIZED) + { + return NRF_ERROR_MODULE_ALREADY_INITIALIZED; + } + + m_drv_state = NRFX_DRV_STATE_INITIALIZED; + return NRF_SUCCESS; +} + +ret_code_t nrf_drv_swi_uninit(void) +{ + if (m_drv_state == NRFX_DRV_STATE_UNINITIALIZED) + { + return NRF_ERROR_INVALID_STATE; + } + + nrfx_swi_all_free(); + m_drv_state = NRFX_DRV_STATE_UNINITIALIZED; + return NRF_SUCCESS; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.h new file mode 100644 index 0000000..9b14cee --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_swi.h @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_SWI_H__ +#define NRF_DRV_SWI_H__ + +#include <nrfx_swi.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_swi SWI driver - legacy layer + * @{ + * @ingroup nrf_swi_egu + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_SWI_UNALLOCATED NRFX_SWI_UNALLOCATED +/** @brief Macro for forwarding the new implementation. */ +#define SWI_DEFAULT_PRIORITY NRFX_SWI_DEFAULT_PRIORITY + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_t nrfx_swi_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_flags_t nrfx_swi_flags_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_swi_handler_t nrfx_swi_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_alloc nrfx_swi_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_free nrfx_swi_free +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_trigger nrfx_swi_trigger + +#if NRF_MODULE_ENABLED(EGU) || defined(__SDK_DOXYGEN__) +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_task_trigger_address_get nrfx_swi_task_trigger_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_swi_event_triggered_address_get nrfx_swi_event_triggered_address_get +#endif // NRF_MODULE_ENABLED(EGU) || defined(__SDK_DOXYGEN__) + +/** + * @brief Function for initializing the SWI module. + * + * @retval NRF_SUCCESS If the module was successfully initialized. + * @retval NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized. + */ +ret_code_t nrf_drv_swi_init(void); + +/** + * @brief Function for uninitializing the SWI module. + * + * This function also frees all SWIs. + * + * @retval NRF_SUCCESS If the module was successfully uninitialized. + * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. + */ +ret_code_t nrf_drv_swi_uninit(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SWI_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_systick.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_systick.h new file mode 100644 index 0000000..5399d78 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_systick.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2016 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_SYSTICK_H__ +#define NRF_DRV_SYSTICK_H__ + +#include <nrfx_systick.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_systick ARM(R) SysTick driver - legacy layer + * @{ + * @ingroup nrf_systick + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_systick_state_t nrf_drv_systick_state_t; + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_init nrfx_systick_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_get nrfx_systick_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_test nrfx_systick_test +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_ticks nrfx_systick_delay_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_us nrfx_systick_delay_us +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_systick_delay_ms nrfx_systick_delay_ms + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_SYSTICK_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_timer.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_timer.h new file mode 100644 index 0000000..dbe91bc --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_timer.h @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_TIMER_H__ +#define NRF_DRV_TIMER_H__ + +#include <nrfx_timer.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_timer TIMER driver - legacy layer + * @{ + * @ingroup nrf_timer + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_timer_t nrf_drv_timer_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_timer_config_t nrf_drv_timer_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TIMER_INSTANCE NRFX_TIMER_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TIMER_DEFAULT_CONFIG NRFX_TIMER_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_timer_event_handler_t nrfx_timer_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_init nrfx_timer_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_uninit nrfx_timer_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_enable nrfx_timer_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_disable nrfx_timer_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_is_enabled nrfx_timer_is_enabled +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_pause nrfx_timer_pause +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_resume nrfx_timer_resume +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_clear nrfx_timer_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_increment nrfx_timer_increment +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture nrfx_timer_capture +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture_get nrfx_timer_capture_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare nrfx_timer_compare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_extended_compare nrfx_timer_extended_compare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_us_to_ticks nrfx_timer_us_to_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_ms_to_ticks nrfx_timer_ms_to_ticks +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_int_enable nrfx_timer_compare_int_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_int_disable nrfx_timer_compare_int_disable + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_task_address_get nrfx_timer_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_capture_task_address_get nrfx_timer_capture_task_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_event_address_get nrfx_timer_event_address_get +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_timer_compare_event_address_get nrfx_timer_compare_event_address_get + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_TIMER_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.c new file mode 100644 index 0000000..9e619df --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.c @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_twi.h" +#include <nrf_delay.h> +#include <hal/nrf_gpio.h> + +#ifdef TWIM_PRESENT +#define INSTANCE_COUNT TWIM_COUNT +#else +#define INSTANCE_COUNT TWI_COUNT +#endif + +#define SCL_PIN_INIT_CONF \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) + +#define SDA_PIN_INIT_CONF SCL_PIN_INIT_CONF + +#define SDA_PIN_UNINIT_CONF \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)) + +#define SCL_PIN_UNINIT_CONF SDA_PIN_UNINIT_CONF + +#define SCL_PIN_INIT_CONF_CLR \ + ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ + | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \ + | (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) \ + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)) + +#define SDA_PIN_INIT_CONF_CLR SCL_PIN_INIT_CONF_CLR + +static nrf_drv_twi_evt_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +static void twi_clear_bus(nrf_drv_twi_config_t const * p_config) +{ + NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF; + NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF; + + nrf_gpio_pin_set(p_config->scl); + nrf_gpio_pin_set(p_config->sda); + + NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF_CLR; + NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF_CLR; + + nrf_delay_us(4); + + for (int i = 0; i < 9; i++) + { + if (nrf_gpio_pin_read(p_config->sda)) + { + if (i == 0) + { + return; + } + else + { + break; + } + } + nrf_gpio_pin_clear(p_config->scl); + nrf_delay_us(4); + nrf_gpio_pin_set(p_config->scl); + nrf_delay_us(4); + } + nrf_gpio_pin_clear(p_config->sda); + nrf_delay_us(4); + nrf_gpio_pin_set(p_config->sda); +} + +#ifdef TWIM_PRESENT +static void twim_evt_handler(nrfx_twim_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_twi_evt_t const event = + { + .type = (nrf_drv_twi_evt_type_t)p_event->type, + .xfer_desc = + { + .type = (nrf_drv_twi_xfer_type_t)p_event->xfer_desc.type, + .address = p_event->xfer_desc.address, + .primary_length = p_event->xfer_desc.primary_length, + .secondary_length = p_event->xfer_desc.secondary_length, + .p_primary_buf = p_event->xfer_desc.p_primary_buf, + .p_secondary_buf = p_event->xfer_desc.p_secondary_buf, + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // TWIM_PRESENT + +#ifdef TWI_PRESENT +static void twi_evt_handler(nrfx_twi_evt_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_twi_evt_t const event = + { + .type = (nrf_drv_twi_evt_type_t)p_event->type, + .xfer_desc = + { + .type = (nrf_drv_twi_xfer_type_t)p_event->xfer_desc.type, + .address = p_event->xfer_desc.address, + .primary_length = p_event->xfer_desc.primary_length, + .secondary_length = p_event->xfer_desc.secondary_length, + .p_primary_buf = p_event->xfer_desc.p_primary_buf, + .p_secondary_buf = p_event->xfer_desc.p_secondary_buf, + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // TWI_PRESENT + +ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_config_t const * p_config, + nrf_drv_twi_evt_handler_t event_handler, + void * p_context) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = event_handler; + m_contexts[inst_idx] = p_context; + + if(p_config->clear_bus_init) + { + /* Send clocks (max 9) until slave device back from stuck mode */ + twi_clear_bus(p_config); + } + + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_init(&p_instance->u.twim, + (nrfx_twim_config_t const *)p_config, + event_handler ? twim_evt_handler : NULL, + (void *)inst_idx); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_init(&p_instance->u.twi, + (nrfx_twi_config_t const *)p_config, + event_handler ? twi_evt_handler : NULL, + (void *)inst_idx); + } + return result; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.h new file mode 100644 index 0000000..60abce6 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twi.h @@ -0,0 +1,686 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_TWI_H__ +#define NRF_DRV_TWI_H__ + +#include <nrfx.h> +#ifdef TWIM_PRESENT + #include <nrfx_twim.h> +#else + // Compilers (at least the smart ones) will remove the TWIM related code + // (blocks starting with "if (NRF_DRV_TWI_USE_TWIM)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_twim_init(...) 0 + #define nrfx_twim_uninit(...) + #define nrfx_twim_enable(...) + #define nrfx_twim_disable(...) + #define nrfx_twim_tx(...) 0 + #define nrfx_twim_rx(...) 0 + #define nrfx_twim_is_busy(...) 0 + #define nrfx_twim_start_task_get(...) 0 + #define nrfx_twim_stopped_event_get(...) 0 +#endif + +#ifdef TWI_PRESENT + #include <nrfx_twi.h> +#else + // Compilers (at least the smart ones) will remove the TWI related code + // (blocks starting with "if (NRF_DRV_TWI_USE_TWI)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_twi_init(...) 0 + #define nrfx_twi_uninit(...) + #define nrfx_twi_enable(...) + #define nrfx_twi_disable(...) + #define nrfx_twi_tx(...) 0 + #define nrfx_twi_rx(...) 0 + #define nrfx_twi_is_busy(...) 0 + #define nrfx_twi_data_count_get(...) 0 + #define nrfx_twi_stopped_event_get(...) 0 + + // This part is for old modules that use directly TWI HAL definitions + // (to make them compilable for chips that have only TWIM). + #define NRF_TWI_ERROR_ADDRESS_NACK NRF_TWIM_ERROR_ADDRESS_NACK + #define NRF_TWI_ERROR_DATA_NACK NRF_TWIM_ERROR_DATA_NACK + #define NRF_TWI_FREQ_100K NRF_TWIM_FREQ_100K + #define NRF_TWI_FREQ_250K NRF_TWIM_FREQ_250K + #define NRF_TWI_FREQ_400K NRF_TWIM_FREQ_400K +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_twi TWI driver - legacy layer + * @{ + * @ingroup nrf_twi + * @brief Layer providing compatibility with the former API. + */ + +/** + * @brief Structure for the TWI master driver instance. + */ +typedef struct +{ + uint8_t inst_idx; + union + { +#ifdef TWIM_PRESENT + nrfx_twim_t twim; +#endif +#ifdef TWI_PRESENT + nrfx_twi_t twi; +#endif + } u; + bool use_easy_dma; +} nrf_drv_twi_t; + +/** + * @brief Macro for creating a TWI master driver instance. + */ +#define NRF_DRV_TWI_INSTANCE(id) NRF_DRV_TWI_INSTANCE_(id) +#define NRF_DRV_TWI_INSTANCE_(id) NRF_DRV_TWI_INSTANCE_ ## id +#if NRFX_CHECK(NRFX_TWIM0_ENABLED) + #define NRF_DRV_TWI_INSTANCE_0 \ + { 0, { .twim = NRFX_TWIM_INSTANCE(0) }, true } +#elif NRFX_CHECK(NRFX_TWI0_ENABLED) + #define NRF_DRV_TWI_INSTANCE_0 \ + { 0, { .twi = NRFX_TWI_INSTANCE(0) }, false } +#endif +#if NRFX_CHECK(NRFX_TWIM1_ENABLED) + #define NRF_DRV_TWI_INSTANCE_1 \ + { 1, { .twim = NRFX_TWIM_INSTANCE(1) }, true } +#elif NRFX_CHECK(NRFX_TWI1_ENABLED) + #define NRF_DRV_TWI_INSTANCE_1 \ + { 1, { .twi = NRFX_TWI_INSTANCE(1) }, false } +#endif + +/** + * @brief TWI master clock frequency. + */ +typedef enum +{ + NRF_DRV_TWI_FREQ_100K = NRF_TWI_FREQ_100K , ///< 100 kbps. + NRF_DRV_TWI_FREQ_250K = NRF_TWI_FREQ_250K , ///< 250 kbps. + NRF_DRV_TWI_FREQ_400K = NRF_TWI_FREQ_400K ///< 400 kbps. +} nrf_drv_twi_frequency_t; + +/** + * @brief Structure for the TWI master driver instance configuration. + */ +typedef struct +{ + uint32_t scl; ///< SCL pin number. + uint32_t sda; ///< SDA pin number. + nrf_drv_twi_frequency_t frequency; ///< TWI frequency. + uint8_t interrupt_priority; ///< Interrupt priority. + bool clear_bus_init; ///< Clear bus during init. + bool hold_bus_uninit; ///< Hold pull up state on gpio pins after uninit. +} nrf_drv_twi_config_t; + +/** + * @brief TWI master driver instance default configuration. + */ +#define NRF_DRV_TWI_DEFAULT_CONFIG \ +{ \ + .frequency = (nrf_drv_twi_frequency_t)TWI_DEFAULT_CONFIG_FREQUENCY, \ + .scl = 31, \ + .sda = 31, \ + .interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \ + .clear_bus_init = TWI_DEFAULT_CONFIG_CLR_BUS_INIT, \ + .hold_bus_uninit = TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \ +} + +#define NRF_DRV_TWI_FLAG_TX_POSTINC (1UL << 0) /**< TX buffer address incremented after transfer. */ +#define NRF_DRV_TWI_FLAG_RX_POSTINC (1UL << 1) /**< RX buffer address incremented after transfer. */ +#define NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER (1UL << 2) /**< Interrupt after each transfer is suppressed, and the event handler is not called. */ +#define NRF_DRV_TWI_FLAG_HOLD_XFER (1UL << 3) /**< Set up the transfer but do not start it. */ +#define NRF_DRV_TWI_FLAG_REPEATED_XFER (1UL << 4) /**< Flag indicating that the transfer will be executed multiple times. */ +#define NRF_DRV_TWI_FLAG_TX_NO_STOP (1UL << 5) /**< Flag indicating that the TX transfer will not end with a stop condition. */ + +/** + * @brief TWI master driver event types. + */ +typedef enum +{ + NRF_DRV_TWI_EVT_DONE, ///< Transfer completed event. + NRF_DRV_TWI_EVT_ADDRESS_NACK, ///< Error event: NACK received after sending the address. + NRF_DRV_TWI_EVT_DATA_NACK ///< Error event: NACK received after sending a data byte. +} nrf_drv_twi_evt_type_t; + +/** + * @brief TWI master driver transfer types. + */ +typedef enum +{ + NRF_DRV_TWI_XFER_TX, ///< TX transfer. + NRF_DRV_TWI_XFER_RX, ///< RX transfer. + NRF_DRV_TWI_XFER_TXRX, ///< TX transfer followed by RX transfer with repeated start. + NRF_DRV_TWI_XFER_TXTX ///< TX transfer followed by TX transfer with repeated start. +} nrf_drv_twi_xfer_type_t; + +/** + * @brief Structure for a TWI transfer descriptor. + */ +typedef struct +{ + nrf_drv_twi_xfer_type_t type; ///< Type of transfer. + uint8_t address; ///< Slave address. + uint8_t primary_length; ///< Number of bytes transferred. + uint8_t secondary_length; ///< Number of bytes transferred. + uint8_t * p_primary_buf; ///< Pointer to transferred data. + uint8_t * p_secondary_buf; ///< Pointer to transferred data. +} nrf_drv_twi_xfer_desc_t; + + +/**@brief Macro for setting the TX transfer descriptor. */ +#define NRF_DRV_TWI_XFER_DESC_TX(addr, p_data, length) \ + { \ + .type = NRF_DRV_TWI_XFER_TX, \ + .address = addr, \ + .primary_length = length, \ + .p_primary_buf = p_data, \ + } + +/**@brief Macro for setting the RX transfer descriptor. */ +#define NRF_DRV_TWI_XFER_DESC_RX(addr, p_data, length) \ + { \ + .type = NRF_DRV_TWI_XFER_RX, \ + .address = addr, \ + .primary_length = length, \ + .p_primary_buf = p_data, \ + } + +/**@brief Macro for setting the TXRX transfer descriptor. */ +#define NRF_DRV_TWI_XFER_DESC_TXRX(addr, p_tx, tx_len, p_rx, rx_len) \ + { \ + .type = NRF_DRV_TWI_XFER_TXRX, \ + .address = addr, \ + .primary_length = tx_len, \ + .secondary_length = rx_len, \ + .p_primary_buf = p_tx, \ + .p_secondary_buf = p_rx, \ + } + +/**@brief Macro for setting the TXTX transfer descriptor. */ +#define NRF_DRV_TWI_XFER_DESC_TXTX(addr, p_tx, tx_len, p_tx2, tx_len2) \ + { \ + .type = NRF_DRV_TWI_XFER_TXTX, \ + .address = addr, \ + .primary_length = tx_len, \ + .secondary_length = tx_len2, \ + .p_primary_buf = p_tx, \ + .p_secondary_buf = p_tx2, \ + } + +/** + * @brief Structure for a TWI event. + */ +typedef struct +{ + nrf_drv_twi_evt_type_t type; ///< Event type. + nrf_drv_twi_xfer_desc_t xfer_desc; ///< Transfer details. +} nrf_drv_twi_evt_t; + +/** + * @brief TWI event handler prototype. + */ +typedef void (* nrf_drv_twi_evt_handler_t)(nrf_drv_twi_evt_t const * p_event, + void * p_context); + +/** + * @brief Function for initializing the TWI driver instance. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Initial configuration. + * @param[in] event_handler Event handler provided by the user. If NULL, blocking mode is enabled. + * @param[in] p_context Context passed to event handler. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_INVALID_STATE If the driver is in invalid state. + * @retval NRF_ERROR_BUSY If some other peripheral with the same + * instance ID is already in use. This is + * possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED + * is set to a value other than zero. + */ +ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_config_t const * p_config, + nrf_drv_twi_evt_handler_t event_handler, + void * p_context); + +/** + * @brief Function for uninitializing the TWI instance. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance); + +/** + * @brief Function for enabling the TWI instance. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance); + +/** + * @brief Function for disabling the TWI instance. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_twi_disable(nrf_drv_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 NRF_ERROR_BUSY. + * + * @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 NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_BUSY If the driver is not ready for a new transfer. + * @retval NRF_ERROR_INTERNAL If an error was detected by hardware. + * @retval NRF_ERROR_INVALID_ADDR If the EasyDMA is used and memory adress in not in RAM. + * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address in polling mode. + * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte in polling mode. + */ +__STATIC_INLINE +ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t const * p_data, + uint8_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 NRF_ERROR_BUSY. + * + * @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 NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_BUSY If the driver is not ready for a new transfer. + * @retval NRF_ERROR_INTERNAL If an error was detected by hardware. + * @retval NRF_ERROR_DRV_TWI_ERR_OVERRUN If the unread data was replaced by new data + * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address in polling mode. + * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte in polling mode. + */ +__STATIC_INLINE +ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t * p_data, + uint8_t length); + +/** + * @brief Function for preparing a TWI transfer. + * + * The following transfer types can be configured (@ref nrf_drv_twi_xfer_desc_t::type): + * - @ref NRF_DRV_TWI_XFER_TXRX<span></span>: Write operation followed by a read operation (without STOP condition in between). + * - @ref NRF_DRV_TWI_XFER_TXTX<span></span>: Write operation followed by a write operation (without STOP condition in between). + * - @ref NRF_DRV_TWI_XFER_TX<span></span>: Write operation (with or without STOP condition). + * - @ref NRF_DRV_TWI_XFER_RX<span></span>: Read operation (with STOP condition). + * + * Additional options are provided using the flags parameter: + * - @ref NRF_DRV_TWI_FLAG_TX_POSTINC and @ref NRF_DRV_TWI_FLAG_RX_POSTINC<span></span>: Post-incrementation of buffer addresses. Supported only by TWIM. + * - @ref NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER<span></span>: No user event handler after transfer completion. In most cases, this also means no interrupt at the end of the transfer. + * - @ref NRF_DRV_TWI_FLAG_HOLD_XFER<span></span>: Driver is not starting the transfer. Use this flag if the transfer is triggered externally by PPI. Supported only by TWIM. + * Use @ref nrf_drv_twi_start_task_get to get the address of the start task. + * - @ref NRF_DRV_TWI_FLAG_REPEATED_XFER<span></span>: Prepare for repeated transfers. You can set up a number of transfers that will be triggered externally (for example by PPI). + * An example is a TXRX transfer with the options @ref NRF_DRV_TWI_FLAG_RX_POSTINC, @ref NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER, and @ref NRF_DRV_TWI_FLAG_REPEATED_XFER. + * After the transfer is set up, a set of transfers can be triggered by PPI that will read, for example, the same register of an + * external component and put it into a RAM buffer without any interrupts. @ref nrf_drv_twi_stopped_event_get can be used to get the + * address of the STOPPED event, which can be used to count the number of transfers. If @ref NRF_DRV_TWI_FLAG_REPEATED_XFER is used, + * 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. Supported only by TWIM. + * - @ref NRF_DRV_TWI_FLAG_TX_NO_STOP<span></span>: No stop condition after TX transfer. + * + * @note + * Some flag combinations are invalid: + * - @ref NRF_DRV_TWI_FLAG_TX_NO_STOP with @ref nrf_drv_twi_xfer_desc_t::type different than @ref NRF_DRV_TWI_XFER_TX + * - @ref NRF_DRV_TWI_FLAG_REPEATED_XFER with @ref nrf_drv_twi_xfer_desc_t::type set to @ref NRF_DRV_TWI_XFER_TXTX + * + * If @ref nrf_drv_twi_xfer_desc_t::type is set to @ref NRF_DRV_TWI_XFER_TX and the @ref NRF_DRV_TWI_FLAG_TX_NO_STOP and @ref NRF_DRV_TWI_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. + * + * @note + * This function should be used only if the instance is configured to work in non-blocking mode. If the function is used in blocking mode, the driver asserts. + * @note If you are using this function with TWI, the only supported flag is @ref NRF_DRV_TWI_FLAG_TX_NO_STOP. All other flags require TWIM. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_xfer_desc Pointer to the transfer descriptor. + * @param[in] flags Transfer options (0 for default settings). + * + * @retval NRF_SUCCESS If the procedure was successful. + * @retval NRF_ERROR_BUSY If the driver is not ready for a new transfer. + * @retval NRF_ERROR_NOT_SUPPORTED If the provided parameters are not supported. + * @retval NRF_ERROR_INTERNAL If an error was detected by hardware. + * @retval NRF_ERROR_INVALID_ADDR If the EasyDMA is used and memory adress in not in RAM + * @retval NRF_ERROR_DRV_TWI_ERR_OVERRUN If the unread data was replaced by new data (TXRX and RX) + * @retval NRF_ERROR_DRV_TWI_ERR_ANACK If NACK received after sending the address. + * @retval NRF_ERROR_DRV_TWI_ERR_DNACK If NACK received after sending a data byte. + */ +__STATIC_INLINE +ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_xfer_desc_t const * p_xfer_desc, + uint32_t flags); + +/** + * @brief Function for checking the TWI driver state. + * + * @param[in] p_instance TWI instance. + * + * @retval true If the TWI driver is currently busy performing a transfer. + * @retval false If the TWI driver is ready for a new transfer. + */ +__STATIC_INLINE +bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance); + +/** + * @brief Function for getting the transferred data count. + * + * This function provides valid results only in legacy mode. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return Data count. + */ +__STATIC_INLINE +uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance); + +/** + * @brief Function for returning the address of a TWI/TWIM start task. + * + * This function should be used if @ref nrf_drv_twi_xfer was called with the flag @ref NRF_DRV_TWI_FLAG_HOLD_XFER. + * In that case, the transfer is not started by the driver, but it must be started externally by PPI. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] xfer_type Transfer type used in the last call of the @ref nrf_drv_twi_xfer function. + * + * @return Start task address (TX or RX) depending on the value of xfer_type. + */ +__STATIC_INLINE +uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, nrf_drv_twi_xfer_type_t xfer_type); + +/** + * @brief Function for returning the address of a STOPPED TWI/TWIM event. + * + * A STOPPED event can be used to detect the end of a transfer if the @ref NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER + * option is used. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @return STOPPED event address. + */ +__STATIC_INLINE +uint32_t nrf_drv_twi_stopped_event_get(nrf_drv_twi_t const * p_instance); + + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(TWI_PRESENT) && !defined(TWIM_PRESENT) +#define NRF_DRV_TWI_WITH_TWI +#elif !defined(TWI_PRESENT) && defined(TWIM_PRESENT) +#define NRF_DRV_TWI_WITH_TWIM +#else +#if (NRFX_CHECK(TWI0_ENABLED) && NRFX_CHECK(TWI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(TWI1_ENABLED) && NRFX_CHECK(TWI1_USE_EASY_DMA)) + #define NRF_DRV_TWI_WITH_TWIM +#endif +#if (NRFX_CHECK(TWI0_ENABLED) && !NRFX_CHECK(TWI0_USE_EASY_DMA)) || \ + (NRFX_CHECK(TWI1_ENABLED) && !NRFX_CHECK(TWI1_USE_EASY_DMA)) + #define NRF_DRV_TWI_WITH_TWI +#endif +#endif +#if defined(NRF_DRV_TWI_WITH_TWIM) && defined(NRF_DRV_TWI_WITH_TWI) + #define NRF_DRV_TWI_USE_TWIM (p_instance->use_easy_dma) +#elif defined(NRF_DRV_TWI_WITH_TWIM) + #define NRF_DRV_TWI_USE_TWIM true +#else + #define NRF_DRV_TWI_USE_TWIM false +#endif +#define NRF_DRV_TWI_USE_TWI (!NRF_DRV_TWI_USE_TWIM) + +__STATIC_INLINE +void nrf_drv_twi_uninit(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_uninit(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_uninit(&p_instance->u.twi); + } +} + +__STATIC_INLINE +void nrf_drv_twi_enable(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_enable(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_enable(&p_instance->u.twi); + } +} + +__STATIC_INLINE +void nrf_drv_twi_disable(nrf_drv_twi_t const * p_instance) +{ + if (NRF_DRV_TWI_USE_TWIM) + { + nrfx_twim_disable(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + nrfx_twi_disable(&p_instance->u.twi); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t const * p_data, + uint8_t length, + bool no_stop) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_tx(&p_instance->u.twim, + address, p_data, length, no_stop); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_tx(&p_instance->u.twi, + address, p_data, length, no_stop); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance, + uint8_t address, + uint8_t * p_data, + uint8_t length) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_rx(&p_instance->u.twim, + address, p_data, length); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_rx(&p_instance->u.twi, + address, p_data, length); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_xfer_desc_t const * p_xfer_desc, + uint32_t flags) +{ + ret_code_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + #ifdef TWIM_PRESENT + nrfx_twim_xfer_desc_t const twim_xfer_desc = + { + .type = (nrfx_twim_xfer_type_t)p_xfer_desc->type, + .address = p_xfer_desc->address, + .primary_length = p_xfer_desc->primary_length, + .secondary_length = p_xfer_desc->secondary_length, + .p_primary_buf = p_xfer_desc->p_primary_buf, + .p_secondary_buf = p_xfer_desc->p_secondary_buf, + }; + result = nrfx_twim_xfer(&p_instance->u.twim, &twim_xfer_desc, flags); + #endif + } + else if (NRF_DRV_TWI_USE_TWI) + { + #ifdef TWI_PRESENT + nrfx_twi_xfer_desc_t const twi_xfer_desc = + { + .type = (nrfx_twi_xfer_type_t)p_xfer_desc->type, + .address = p_xfer_desc->address, + .primary_length = p_xfer_desc->primary_length, + .secondary_length = p_xfer_desc->secondary_length, + .p_primary_buf = p_xfer_desc->p_primary_buf, + .p_secondary_buf = p_xfer_desc->p_secondary_buf, + }; + result = nrfx_twi_xfer(&p_instance->u.twi, &twi_xfer_desc, flags); + #endif + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_is_busy(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_is_busy(&p_instance->u.twi); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_data_count_get(nrf_drv_twi_t const * const p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_data_count_get(&p_instance->u.twi); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_start_task_get(nrf_drv_twi_t const * p_instance, + nrf_drv_twi_xfer_type_t xfer_type) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_start_task_get(&p_instance->u.twim, + (nrfx_twim_xfer_type_t)xfer_type); + } + else if (NRF_DRV_TWI_USE_TWI) + { + NRFX_ASSERT(false); // not supported + result = 0; + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_twi_stopped_event_get(nrf_drv_twi_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_TWI_USE_TWIM) + { + result = nrfx_twim_stopped_event_get(&p_instance->u.twim); + } + else if (NRF_DRV_TWI_USE_TWI) + { + result = nrfx_twi_stopped_event_get(&p_instance->u.twi); + } + return result; +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_TWI_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twis.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twis.h new file mode 100644 index 0000000..4f0f042 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_twis.h @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_TWIS_H__ +#define NRF_DRV_TWIS_H__ + +#include <nrfx_twis.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_twis TWIS driver - legacy layer + * @{ + * @ingroup nrf_twis + * + * @brief Layer providing compatibility with the former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_t nrf_drv_twis_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_config_t nrf_drv_twis_config_t; +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_twis_evt_t nrf_drv_twis_evt_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_INSTANCE NRFX_TWIS_INSTANCE +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_DEFAULT_CONFIG NRFX_TWIS_DEFAULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_REQ NRFX_TWIS_EVT_READ_REQ +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_DONE NRFX_TWIS_EVT_READ_DONE +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_READ_ERROR NRFX_TWIS_EVT_READ_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_REQ NRFX_TWIS_EVT_WRITE_REQ +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_DONE NRFX_TWIS_EVT_WRITE_DONE +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_WRITE_ERROR NRFX_TWIS_EVT_WRITE_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define TWIS_EVT_GENERAL_ERROR NRFX_TWIS_EVT_GENERAL_ERROR +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_evt_type_t nrfx_twis_evt_type_t +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_OVERFLOW NRFX_TWIS_ERROR_OVERFLOW +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_DATA_NACK NRFX_TWIS_ERROR_DATA_NACK +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_OVERREAD NRFX_TWIS_ERROR_OVERREAD +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_TWIS_ERROR_UNEXPECTED_EVENT NRFX_TWIS_ERROR_UNEXPECTED_EVENT +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_error_t nrfx_twis_error_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_event_handler_t nrfx_twis_event_handler_t + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_init nrfx_twis_init +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_uninit nrfx_twis_uninit +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_enable nrfx_twis_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_disable nrfx_twis_disable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_error_get_and_clear nrfx_twis_error_get_and_clear +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_tx_prepare nrfx_twis_tx_prepare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_tx_amount nrfx_twis_tx_amount +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_rx_prepare nrfx_twis_rx_prepare +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_rx_amount nrfx_twis_rx_amount +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_busy nrfx_twis_is_busy +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_waiting_tx_buff nrfx_twis_is_waiting_tx_buff +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_waiting_rx_buff nrfx_twis_is_waiting_rx_buff +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_pending_tx nrfx_twis_is_pending_tx +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_twis_is_pending_rx nrfx_twis_is_pending_rx + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_TWIS_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.c new file mode 100644 index 0000000..af59029 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.c @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ + +#include "nrf_drv_uart.h" + +#ifdef UARTE_PRESENT +#define INSTANCE_COUNT UARTE_COUNT +#else +#define INSTANCE_COUNT UART_COUNT +#endif + +static nrf_uart_event_handler_t m_handlers[INSTANCE_COUNT]; +static void * m_contexts[INSTANCE_COUNT]; + +#if defined(UARTE_PRESENT) && defined(UART_PRESENT) +uint8_t nrf_drv_uart_use_easy_dma[INSTANCE_COUNT]; +#endif + +#if defined(NRF_DRV_UART_WITH_UARTE) +static void uarte_evt_handler(nrfx_uarte_event_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_uart_event_t event = + { + .type = (nrf_drv_uart_evt_type_t)p_event->type, + .data = + { + .error = + { + .rxtx = + { + .p_data = p_event->data.error.rxtx.p_data, + .bytes = p_event->data.error.rxtx.bytes, + }, + .error_mask = p_event->data.error.error_mask, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // defined(NRF_DRV_UART_WITH_UARTE) + +#if defined(NRF_DRV_UART_WITH_UART) +static void uart_evt_handler(nrfx_uart_event_t const * p_event, + void * p_context) +{ + uint32_t inst_idx = (uint32_t)p_context; + nrf_drv_uart_event_t event = + { + .type = (nrf_drv_uart_evt_type_t)p_event->type, + .data = + { + .error = + { + .rxtx = + { + .p_data = p_event->data.error.rxtx.p_data, + .bytes = p_event->data.error.rxtx.bytes, + }, + .error_mask = p_event->data.error.error_mask, + } + } + }; + m_handlers[inst_idx](&event, m_contexts[inst_idx]); +} +#endif // defined(NRF_DRV_UART_WITH_UART) + +ret_code_t nrf_drv_uart_init(nrf_drv_uart_t const * p_instance, + nrf_drv_uart_config_t const * p_config, + nrf_uart_event_handler_t event_handler) +{ + uint32_t inst_idx = p_instance->inst_idx; + m_handlers[inst_idx] = event_handler; + m_contexts[inst_idx] = p_config->p_context; + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + nrf_drv_uart_use_easy_dma[inst_idx] = p_config->use_easy_dma; +#endif + + nrf_drv_uart_config_t config = *p_config; + config.p_context = (void *)inst_idx; + + ret_code_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_init(&p_instance->uarte, + (nrfx_uarte_config_t const *)&config, + event_handler ? uarte_evt_handler : NULL); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_init(&p_instance->uart, + (nrfx_uart_config_t const *)&config, + event_handler ? uart_evt_handler : NULL); + } + return result; +} diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.h new file mode 100644 index 0000000..92bb71b --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_uart.h @@ -0,0 +1,654 @@ +/** + * Copyright (c) 2015 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_UART_H__ +#define NRF_DRV_UART_H__ + +#include <nrfx.h> + +#if defined(UARTE_PRESENT) && NRFX_CHECK(NRFX_UARTE_ENABLED) + #define NRF_DRV_UART_WITH_UARTE +#endif +#if defined(UART_PRESENT) && NRFX_CHECK(NRFX_UART_ENABLED) + #define NRF_DRV_UART_WITH_UART +#endif + +#if defined(NRF_DRV_UART_WITH_UARTE) + #include <nrfx_uarte.h> + #define NRF_DRV_UART_CREATE_UARTE(id) \ + .uarte = NRFX_UARTE_INSTANCE(id), +#else + // Compilers (at least the smart ones) will remove the UARTE related code + // (blocks starting with "if (NRF_DRV_UART_USE_UARTE)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_uarte_init(...) 0 + #define nrfx_uarte_uninit(...) + #define nrfx_uarte_task_address_get(...) 0 + #define nrfx_uarte_event_address_get(...) 0 + #define nrfx_uarte_tx(...) 0 + #define nrfx_uarte_tx_in_progress(...) 0 + #define nrfx_uarte_tx_abort(...) + #define nrfx_uarte_rx(...) 0 + #define nrfx_uarte_rx_ready(...) 0 + #define nrfx_uarte_rx_abort(...) + #define nrfx_uarte_errorsrc_get(...) 0 + #define NRF_DRV_UART_CREATE_UARTE(id) +#endif + +#if defined(NRF_DRV_UART_WITH_UART) + #include <nrfx_uart.h> + #define NRF_DRV_UART_CREATE_UART(id) \ + .uart = NRFX_UART_INSTANCE(id), +#else + // Compilers (at least the smart ones) will remove the UART related code + // (blocks starting with "if (NRF_DRV_UART_USE_UART)") when it is not used, + // but to perform the compilation they need the following definitions. + #define nrfx_uart_init(...) 0 + #define nrfx_uart_uninit(...) + #define nrfx_uart_task_address_get(...) 0 + #define nrfx_uart_event_address_get(...) 0 + #define nrfx_uart_tx(...) 0 + #define nrfx_uart_tx_in_progress(...) 0 + #define nrfx_uart_tx_abort(...) + #define nrfx_uart_rx(...) 0 + #define nrfx_uart_rx_enable(...) + #define nrfx_uart_rx_disable(...) + #define nrfx_uart_rx_ready(...) 0 + #define nrfx_uart_rx_abort(...) + #define nrfx_uart_errorsrc_get(...) 0 + #define NRF_DRV_UART_CREATE_UART(id) + + // This part is for old modules that use directly UART HAL definitions + // (to make them compilable for chips that have only UARTE). + #define NRF_UART_BAUDRATE_1200 NRF_UARTE_BAUDRATE_1200 + #define NRF_UART_BAUDRATE_2400 NRF_UARTE_BAUDRATE_2400 + #define NRF_UART_BAUDRATE_4800 NRF_UARTE_BAUDRATE_4800 + #define NRF_UART_BAUDRATE_9600 NRF_UARTE_BAUDRATE_9600 + #define NRF_UART_BAUDRATE_14400 NRF_UARTE_BAUDRATE_14400 + #define NRF_UART_BAUDRATE_19200 NRF_UARTE_BAUDRATE_19200 + #define NRF_UART_BAUDRATE_28800 NRF_UARTE_BAUDRATE_28800 + #define NRF_UART_BAUDRATE_38400 NRF_UARTE_BAUDRATE_38400 + #define NRF_UART_BAUDRATE_57600 NRF_UARTE_BAUDRATE_57600 + #define NRF_UART_BAUDRATE_76800 NRF_UARTE_BAUDRATE_76800 + #define NRF_UART_BAUDRATE_115200 NRF_UARTE_BAUDRATE_115200 + #define NRF_UART_BAUDRATE_230400 NRF_UARTE_BAUDRATE_230400 + #define NRF_UART_BAUDRATE_250000 NRF_UARTE_BAUDRATE_250000 + #define NRF_UART_BAUDRATE_460800 NRF_UARTE_BAUDRATE_460800 + #define NRF_UART_BAUDRATE_921600 NRF_UARTE_BAUDRATE_921600 + #define NRF_UART_BAUDRATE_1000000 NRF_UARTE_BAUDRATE_1000000 + typedef nrf_uarte_baudrate_t nrf_uart_baudrate_t; + #define NRF_UART_ERROR_OVERRUN_MASK NRF_UARTE_ERROR_OVERRUN_MASK + #define NRF_UART_ERROR_PARITY_MASK NRF_UARTE_ERROR_PARITY_MASK + #define NRF_UART_ERROR_FRAMING_MASK NRF_UARTE_ERROR_PARITY_MASK + #define NRF_UART_ERROR_BREAK_MASK NRF_UARTE_ERROR_BREAK_MASK + typedef nrf_uarte_error_mask_t nrf_uart_error_mask_t; + #define NRF_UART_HWFC_DISABLED NRF_UARTE_HWFC_DISABLED + #define NRF_UART_HWFC_ENABLED NRF_UARTE_HWFC_ENABLED + typedef nrf_uarte_hwfc_t nrf_uart_hwfc_t; + #define NRF_UART_PARITY_EXCLUDED NRF_UARTE_PARITY_EXCLUDED + #define NRF_UART_PARITY_INCLUDED NRF_UARTE_PARITY_INCLUDED + typedef nrf_uarte_parity_t nrf_uart_parity_t; + typedef nrf_uarte_task_t nrf_uart_task_t; + typedef nrf_uarte_event_t nrf_uart_event_t; + #define NRF_UART_PSEL_DISCONNECTED NRF_UARTE_PSEL_DISCONNECTED + #define nrf_uart_event_clear(...) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_uart UART driver - legacy layer + * @{ + * @ingroup nrf_uart + * @brief Layer providing compatibility with the former API. + */ + +/** + * @brief Structure for the UART driver instance. + */ +typedef struct +{ + uint8_t inst_idx; +#if defined(NRF_DRV_UART_WITH_UARTE) + nrfx_uarte_t uarte; +#endif +#if defined(NRF_DRV_UART_WITH_UART) + nrfx_uart_t uart; +#endif +} nrf_drv_uart_t; + +/** + * @brief Macro for creating an UART driver instance. + */ +#define NRF_DRV_UART_INSTANCE(id) \ +{ \ + .inst_idx = id, \ + NRF_DRV_UART_CREATE_UARTE(id) \ + NRF_DRV_UART_CREATE_UART(id) \ +} + +/** + * @brief Types of UART driver events. + */ +typedef enum +{ + NRF_DRV_UART_EVT_TX_DONE, ///< Requested TX transfer completed. + NRF_DRV_UART_EVT_RX_DONE, ///< Requested RX transfer completed. + NRF_DRV_UART_EVT_ERROR, ///< Error reported by UART peripheral. +} nrf_drv_uart_evt_type_t; + +/**@brief Structure for UART configuration. */ +typedef struct +{ + uint32_t pseltxd; ///< TXD pin number. + uint32_t pselrxd; ///< RXD pin number. + 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; ///< Baudrate. + uint8_t interrupt_priority; ///< Interrupt priority. +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + bool use_easy_dma; +#endif +} nrf_drv_uart_config_t; + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) +extern uint8_t nrf_drv_uart_use_easy_dma[]; +#define NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA .use_easy_dma = true, +#else +#define NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA +#endif + +/**@brief UART default configuration. */ +#define NRF_DRV_UART_DEFAULT_CONFIG \ +{ \ + .pseltxd = NRF_UART_PSEL_DISCONNECTED, \ + .pselrxd = NRF_UART_PSEL_DISCONNECTED, \ + .pselcts = NRF_UART_PSEL_DISCONNECTED, \ + .pselrts = NRF_UART_PSEL_DISCONNECTED, \ + .p_context = NULL, \ + .hwfc = (nrf_uart_hwfc_t)UART_DEFAULT_CONFIG_HWFC, \ + .parity = (nrf_uart_parity_t)UART_DEFAULT_CONFIG_PARITY, \ + .baudrate = (nrf_uart_baudrate_t)UART_DEFAULT_CONFIG_BAUDRATE, \ + .interrupt_priority = UART_DEFAULT_CONFIG_IRQ_PRIORITY, \ + NRF_DRV_UART_DEFAULT_CONFIG_USE_EASY_DMA \ +} + +/**@brief Structure for UART transfer completion event. */ +typedef struct +{ + uint8_t * p_data; ///< Pointer to memory used for transfer. + uint8_t bytes; ///< Number of bytes transfered. +} nrf_drv_uart_xfer_evt_t; + +/**@brief Structure for UART error event. */ +typedef struct +{ + nrf_drv_uart_xfer_evt_t rxtx; ///< Transfer details includes number of bytes transfered. + uint32_t error_mask;///< Mask of error flags that generated the event. +} nrf_drv_uart_error_evt_t; + +/**@brief Structure for UART event. */ +typedef struct +{ + nrf_drv_uart_evt_type_t type; ///< Event type. + union + { + nrf_drv_uart_xfer_evt_t rxtx; ///< Data provided for transfer completion events. + nrf_drv_uart_error_evt_t error;///< Data provided for error event. + } data; +} nrf_drv_uart_event_t; + +/** + * @brief UART interrupt event handler. + * + * @param[in] p_event Pointer to event structure. Event is allocated on the stack so it is available + * only within the context of the event handler. + * @param[in] p_context Context passed to interrupt handler, set on initialization. + */ +typedef void (*nrf_uart_event_handler_t)(nrf_drv_uart_event_t * p_event, void * p_context); + +/** + * @brief Function for initializing the UART driver. + * + * This function configures and enables UART. After this function GPIO pins are controlled by UART. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_config Initial configuration. + * @param[in] event_handler Event handler provided by the user. If not provided driver works in + * blocking mode. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_INVALID_STATE If driver is already initialized. + */ +ret_code_t nrf_drv_uart_init(nrf_drv_uart_t const * p_instance, + nrf_drv_uart_config_t const * p_config, + nrf_uart_event_handler_t event_handler); + +/** + * @brief Function for uninitializing the UART driver. + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_uninit(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for getting the address of a specific UART task. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] task Task. + * + * @return Task address. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_task_t task); + +/** + * @brief Function for getting the address of a specific UART event. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] event Event. + * + * @return Event address. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_event_t event); + +/** + * @brief Function for sending data over UART. + * + * If an event handler was provided in nrf_drv_uart_init() call, this function + * returns immediately and the handler is called when the transfer is done. + * Otherwise, the transfer is performed in blocking mode, i.e. this function + * returns when the transfer is finished. Blocking mode is not using interrupt so + * there is no context switching inside the function. + * + * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers + * are placed in the Data RAM region. If they are not and UARTE instance is + * used, this function will fail with error code NRFX_ERROR_INVALID_ADDR. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to send. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_BUSY If driver is already transferring. + * @retval NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context + * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). + * @retval NRFX_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). + */ +__STATIC_INLINE +ret_code_t nrf_drv_uart_tx(nrf_drv_uart_t const * p_instance, + uint8_t const * const p_data, + uint8_t length); + +/** + * @brief Function for checking if UART is currently transmitting. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval true If UART is transmitting. + * @retval false If UART is not transmitting. + */ +__STATIC_INLINE +bool nrf_drv_uart_tx_in_progress(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for aborting any ongoing transmission. + * @note @ref NRF_DRV_UART_EVT_TX_DONE event will be generated in non-blocking mode. Event will + * contain number of bytes sent until abort was called. If Easy DMA is not used event will be + * called from the function context. If Easy DMA is used it will be called from UART interrupt + * context. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_tx_abort(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for receiving data over UART. + * + * If an event handler was provided in the nrf_drv_uart_init() call, this function + * returns immediately and the handler is called when the transfer is done. + * Otherwise, the transfer is performed in blocking mode, i.e. this function + * returns when the transfer is finished. Blocking mode is not using interrupt so + * there is no context switching inside the function. + * The receive buffer pointer is double buffered in non-blocking mode. The secondary + * buffer can be set immediately after starting the transfer and will be filled + * when the primary buffer is full. The double buffering feature allows + * receiving data continuously. + * + * @note Peripherals using EasyDMA (i.e. UARTE) require that the transfer buffers + * are placed in the Data RAM region. If they are not and UARTE driver instance + * is used, this function will fail with error code NRFX_ERROR_INVALID_ADDR. + * + * @param[in] p_instance Pointer to the driver instance structure. + * @param[in] p_data Pointer to data. + * @param[in] length Number of bytes to receive. + * + * @retval NRFX_SUCCESS If initialization was successful. + * @retval NRFX_ERROR_BUSY If the driver is already receiving + * (and the secondary buffer has already been set + * in non-blocking mode). + * @retval NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context + * (blocking mode only, also see @ref nrf_drv_uart_rx_disable). + * @retval NRFX_ERROR_INTERNAL If UART peripheral reported an error. + * @retval NRFX_ERROR_INVALID_ADDR If p_data does not point to RAM buffer (UARTE only). + */ +__STATIC_INLINE +ret_code_t nrf_drv_uart_rx(nrf_drv_uart_t const * p_instance, + uint8_t * p_data, + uint8_t length); + + + +/** + * @brief Function for testing the receiver state in blocking mode. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval true If the receiver has at least one byte of data to get. + * @retval false If the receiver is empty. + */ +__STATIC_INLINE +bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for enabling the receiver. + * + * UART has a 6-byte-long RX FIFO and it is used to store incoming data. If a user does not call the + * UART receive function before the FIFO is filled, an overrun error will appear. Enabling the receiver + * without specifying an RX buffer is supported only in UART mode (without Easy DMA). The receiver must be + * explicitly closed by the user @sa nrf_drv_uart_rx_disable. This function asserts if the mode is wrong. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for disabling the receiver. + * + * This function must be called to close the receiver after it has been explicitly enabled by + * @sa nrf_drv_uart_rx_enable. The feature is supported only in UART mode (without Easy DMA). The function + * asserts if mode is wrong. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_disable(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for aborting any ongoing reception. + * @note @ref NRF_DRV_UART_EVT_RX_DONE event will be generated in non-blocking mode. The event will + * contain the number of bytes received until abort was called. The event is called from UART interrupt + * context. + * + * @param[in] p_instance Pointer to the driver instance structure. + */ +__STATIC_INLINE +void nrf_drv_uart_rx_abort(nrf_drv_uart_t const * p_instance); + +/** + * @brief Function for reading error source mask. Mask contains values from @ref nrf_uart_error_mask_t. + * @note Function should be used in blocking mode only. In case of non-blocking mode, an error event is + * generated. Function clears error sources after reading. + * + * @param[in] p_instance Pointer to the driver instance structure. + * + * @retval Mask of reported errors. + */ +__STATIC_INLINE +uint32_t nrf_drv_uart_errorsrc_get(nrf_drv_uart_t const * p_instance); + + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + #define NRF_DRV_UART_USE_UARTE (nrf_drv_uart_use_easy_dma[p_instance->inst_idx]) +#elif defined(NRF_DRV_UART_WITH_UARTE) + #define NRF_DRV_UART_USE_UARTE true +#else + #define NRF_DRV_UART_USE_UARTE false +#endif +#define NRF_DRV_UART_USE_UART (!NRF_DRV_UART_USE_UARTE) + +__STATIC_INLINE +void nrf_drv_uart_uninit(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_uninit(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_uninit(&p_instance->uart); + } +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_task_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_task_t task) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_task_address_get(&p_instance->uarte, + (nrf_uarte_task_t)task); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_task_address_get(&p_instance->uart, task); + } + return result; +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_event_address_get(nrf_drv_uart_t const * p_instance, + nrf_uart_event_t event) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_event_address_get(&p_instance->uarte, + (nrf_uarte_event_t)event); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_event_address_get(&p_instance->uart, event); + } + return result; +} + +__STATIC_INLINE +ret_code_t nrf_drv_uart_tx(nrf_drv_uart_t const * p_instance, + uint8_t const * p_data, + uint8_t length) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_tx(&p_instance->uarte, + p_data, + length); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_tx(&p_instance->uart, + p_data, + length); + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_uart_tx_in_progress(nrf_drv_uart_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_tx_in_progress(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_tx_in_progress(&p_instance->uart); + } + return result; +} + +__STATIC_INLINE +void nrf_drv_uart_tx_abort(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_tx_abort(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_tx_abort(&p_instance->uart); + } +} + +__STATIC_INLINE +ret_code_t nrf_drv_uart_rx(nrf_drv_uart_t const * p_instance, + uint8_t * p_data, + uint8_t length) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_rx(&p_instance->uarte, + p_data, + length); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_rx(&p_instance->uart, + p_data, + length); + } + return result; +} + +__STATIC_INLINE +bool nrf_drv_uart_rx_ready(nrf_drv_uart_t const * p_instance) +{ + bool result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_rx_ready(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + result = nrfx_uart_rx_ready(&p_instance->uart); + } + return result; +} + +__STATIC_INLINE +void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + NRFX_ASSERT(false); // not supported + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_enable(&p_instance->uart); + } +} + +__STATIC_INLINE +void nrf_drv_uart_rx_disable(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + NRFX_ASSERT(false); // not supported + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_disable(&p_instance->uart); + } +} + +__STATIC_INLINE +void nrf_drv_uart_rx_abort(nrf_drv_uart_t const * p_instance) +{ + if (NRF_DRV_UART_USE_UARTE) + { + nrfx_uarte_rx_abort(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrfx_uart_rx_abort(&p_instance->uart); + } +} + +__STATIC_INLINE +uint32_t nrf_drv_uart_errorsrc_get(nrf_drv_uart_t const * p_instance) +{ + uint32_t result = 0; + if (NRF_DRV_UART_USE_UARTE) + { + result = nrfx_uarte_errorsrc_get(&p_instance->uarte); + } + else if (NRF_DRV_UART_USE_UART) + { + nrf_uart_event_clear(p_instance->uart.p_reg, NRF_UART_EVENT_ERROR); + result = nrfx_uart_errorsrc_get(&p_instance->uart); + } + return result; +} + +#endif // SUPPRESS_INLINE_IMPLEMENTATION + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_UART_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_wdt.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_wdt.h new file mode 100644 index 0000000..8499be9 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_wdt.h @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2014 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_DRV_WDT_H__ +#define NRF_DRV_WDT_H__ + +#include <nrfx_wdt.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrf_drv_wdt WDT driver - legacy layer + * @{ + * @ingroup nrf_wdt + * + * @brief A layer providing compatibility with former API. + */ + +/** @brief Type definition for forwarding the new implementation. */ +typedef nrfx_wdt_config_t nrf_drv_wdt_config_t; + +/** @brief Macro for forwarding the new implementation. */ +#define NRF_DRV_WDT_DEAFULT_CONFIG NRFX_WDT_DEAFULT_CONFIG + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_wdt_event_handler_t nrfx_wdt_event_handler_t +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_id nrfx_wdt_channel_id + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_alloc nrfx_wdt_channel_alloc +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_enable nrfx_wdt_enable +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_feed nrfx_wdt_feed +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_channel_feed nrfx_wdt_channel_feed + +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_ppi_task_addr nrfx_wdt_ppi_task_addr +/** @brief Macro for forwarding the new implementation. */ +#define nrf_drv_wdt_ppi_event_addr nrfx_wdt_ppi_event_addr + +/** + * @brief This function initializes watchdog. + * + * @param[in] p_config Pointer to the structure with initial configuration. Default + * configuration used if NULL. + * @param[in] wdt_event_handler Specifies event handler provided by user. + * + * @note Function asserts if wdt_event_handler is NULL. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +__STATIC_INLINE ret_code_t nrf_drv_wdt_init(nrf_drv_wdt_config_t const * p_config, + nrf_wdt_event_handler_t wdt_event_handler) +{ + if (p_config == NULL) + { + static const nrfx_wdt_config_t default_config = NRFX_WDT_DEAFULT_CONFIG; + p_config = &default_config; + } + return nrfx_wdt_init(p_config, wdt_event_handler); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_DRV_WDT_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_config.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_config.h new file mode 100644 index 0000000..72577ef --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_config.h @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_CONFIG_H__ +#define NRFX_CONFIG_H__ + +// TODO - temporary redirection +#include <sdk_config.h> + +#endif // NRFX_CONFIG_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_glue.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_glue.h new file mode 100644 index 0000000..fbaff66 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_glue.h @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_GLUE_H__ +#define NRFX_GLUE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup nrfx_glue nrfx_glue.h + * @{ + * @ingroup nrfx + * + * @brief This file contains macros that should be implemented according to + * the needs of the host environment into which @em nrfx is integrated. + */ + +#include <legacy/apply_old_config.h> + +#include <soc/nrfx_irqs.h> + +//------------------------------------------------------------------------------ + +#include <nrf_assert.h> +/** + * @brief Macro for placing a runtime assertion. + * + * @param expression Expression to evaluate. + */ +#define NRFX_ASSERT(expression) ASSERT(expression) + +#include <app_util.h> +/** + * @brief Macro for placing a compile time assertion. + * + * @param expression Expression to evaluate. + */ +#define NRFX_STATIC_ASSERT(expression) STATIC_ASSERT(expression) + +//------------------------------------------------------------------------------ + +#ifdef NRF51 +#ifdef SOFTDEVICE_PRESENT +#define INTERRUPT_PRIORITY_IS_VALID(pri) (((pri) == 1) || ((pri) == 3)) +#else +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 4) +#endif //SOFTDEVICE_PRESENT +#else +#ifdef SOFTDEVICE_PRESENT +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((((pri) > 1) && ((pri) < 4)) || \ + (((pri) > 4) && ((pri) < 8))) +#else +#define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 8) +#endif //SOFTDEVICE_PRESENT +#endif //NRF52 + +/** + * @brief Macro for setting the priority of a specific IRQ. + * + * @param irq_number IRQ number. + * @param priority Priority to set. + */ +#define NRFX_IRQ_PRIORITY_SET(irq_number, priority) \ + _NRFX_IRQ_PRIORITY_SET(irq_number, priority) +static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number, + uint8_t priority) +{ + ASSERT(INTERRUPT_PRIORITY_IS_VALID(priority)); + NVIC_SetPriority(irq_number, priority); +} + +/** + * @brief Macro for enabling a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_ENABLE(irq_number) _NRFX_IRQ_ENABLE(irq_number) +static inline void _NRFX_IRQ_ENABLE(IRQn_Type irq_number) +{ + NVIC_ClearPendingIRQ(irq_number); + NVIC_EnableIRQ(irq_number); +} + +/** + * @brief Macro for checking if a specific IRQ is enabled. + * + * @param irq_number IRQ number. + * + * @retval true If the IRQ is enabled. + * @retval false Otherwise. + */ +#define NRFX_IRQ_IS_ENABLED(irq_number) _NRFX_IRQ_IS_ENABLED(irq_number) +static inline bool _NRFX_IRQ_IS_ENABLED(IRQn_Type irq_number) +{ + return 0 != (NVIC->ISER[irq_number / 32] & (1UL << (irq_number % 32))); +} + +/** + * @brief Macro for disabling a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_DISABLE(irq_number) _NRFX_IRQ_DISABLE(irq_number) +static inline void _NRFX_IRQ_DISABLE(IRQn_Type irq_number) +{ + NVIC_DisableIRQ(irq_number); +} + +/** + * @brief Macro for setting a specific IRQ as pending. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_PENDING_SET(irq_number) _NRFX_IRQ_PENDING_SET(irq_number) +static inline void _NRFX_IRQ_PENDING_SET(IRQn_Type irq_number) +{ + NVIC_SetPendingIRQ(irq_number); +} + +/** + * @brief Macro for clearing the pending status of a specific IRQ. + * + * @param irq_number IRQ number. + */ +#define NRFX_IRQ_PENDING_CLEAR(irq_number) _NRFX_IRQ_PENDING_CLEAR(irq_number) +static inline void _NRFX_IRQ_PENDING_CLEAR(IRQn_Type irq_number) +{ + NVIC_ClearPendingIRQ(irq_number); +} + +/** + * @brief Macro for checking the pending status of a specific IRQ. + * + * @retval true If the IRQ is pending. + * @retval false Otherwise. + */ +#define NRFX_IRQ_IS_PENDING(irq_number) _NRFX_IRQ_IS_PENDING(irq_number) +static inline bool _NRFX_IRQ_IS_PENDING(IRQn_Type irq_number) +{ + return (NVIC_GetPendingIRQ(irq_number) == 1); +} + +#include <nordic_common.h> +#include <app_util_platform.h> +/** + * @brief Macro for entering into a critical section. + */ +#define NRFX_CRITICAL_SECTION_ENTER() CRITICAL_REGION_ENTER() + +/** + * @brief Macro for exiting from a critical section. + */ +#define NRFX_CRITICAL_SECTION_EXIT() CRITICAL_REGION_EXIT() + +//------------------------------------------------------------------------------ + +/** + * @brief When set to a non-zero value, this macro specifies that + * @ref nrfx_coredep_delay_us uses a precise DWT-based solution. + * A compilation error is generated if the DWT unit is not present + * in the SoC used. + */ +#define NRFX_DELAY_DWT_BASED 0 + +#include <soc/nrfx_coredep.h> + +#define NRFX_DELAY_US(us_time) nrfx_coredep_delay_us(us_time) + +//------------------------------------------------------------------------------ + +#include <sdk_errors.h> +/** + * @brief When set to a non-zero value, this macro specifies that the + * @ref nrfx_error_codes and the @ref ret_code_t type itself are defined + * in a customized way and the default definitions from @c <nrfx_error.h> + * should not be used. + */ +#define NRFX_CUSTOM_ERROR_CODES 1 + +typedef ret_code_t nrfx_err_t; + +#define NRFX_SUCCESS NRF_SUCCESS +#define NRFX_ERROR_INTERNAL NRF_ERROR_INTERNAL +#define NRFX_ERROR_NO_MEM NRF_ERROR_NO_MEM +#define NRFX_ERROR_NOT_SUPPORTED NRF_ERROR_NOT_SUPPORTED +#define NRFX_ERROR_INVALID_PARAM NRF_ERROR_INVALID_PARAM +#define NRFX_ERROR_INVALID_STATE NRF_ERROR_INVALID_STATE +#define NRFX_ERROR_INVALID_LENGTH NRF_ERROR_INVALID_LENGTH +#define NRFX_ERROR_TIMEOUT NRF_ERROR_TIMEOUT +#define NRFX_ERROR_FORBIDDEN NRF_ERROR_FORBIDDEN +#define NRFX_ERROR_NULL NRF_ERROR_NULL +#define NRFX_ERROR_INVALID_ADDR NRF_ERROR_INVALID_ADDR +#define NRFX_ERROR_BUSY NRF_ERROR_BUSY +#define NRFX_ERROR_ALREADY_INITIALIZED NRF_ERROR_MODULE_ALREADY_INITIALIZED + +#define NRFX_ERROR_DRV_TWI_ERR_OVERRUN NRF_ERROR_DRV_TWI_ERR_OVERRUN +#define NRFX_ERROR_DRV_TWI_ERR_ANACK NRF_ERROR_DRV_TWI_ERR_ANACK +#define NRFX_ERROR_DRV_TWI_ERR_DNACK NRF_ERROR_DRV_TWI_ERR_DNACK + +//------------------------------------------------------------------------------ + +#include <sdk_resources.h> +/** + * @brief Bitmask defining PPI channels reserved to be used outside of nrfx. + */ +#define NRFX_PPI_CHANNELS_USED NRF_PPI_CHANNELS_USED + +/** + * @brief Bitmask defining PPI groups reserved to be used outside of nrfx. + */ +#define NRFX_PPI_GROUPS_USED NRF_PPI_GROUPS_USED + +/** + * @brief Bitmask defining SWI instances reserved to be used outside of nrfx. + */ +#define NRFX_SWI_USED NRF_SWI_USED + +/** + * @brief Bitmask defining TIMER instances reserved to be used outside of nrfx. + */ +#define NRFX_TIMERS_USED NRF_TIMERS_USED + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRFX_GLUE_H__ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_log.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_log.h new file mode 100644 index 0000000..4c2546e --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/integration/nrfx/nrfx_log.h @@ -0,0 +1,152 @@ +/** + * Copyright (c) 2017 - 2018, 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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_LOG_H__ +#define NRFX_LOG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(NRFX_LOG_MODULE) +#define NRF_LOG_MODULE_NAME NRFX_LOG_MODULE + +#define NRFX_CONFIG_ENTRY(x) CONCAT_3(NRFX_, NRFX_LOG_MODULE, x) + +#if NRFX_CHECK(NRFX_CONFIG_ENTRY(_CONFIG_LOG_ENABLED)) +#define NRF_LOG_LEVEL NRFX_CONFIG_ENTRY(_CONFIG_LOG_LEVEL) +#define NRF_LOG_INFO_COLOR NRFX_CONFIG_ENTRY(_CONFIG_INFO_COLOR) +#define NRF_LOG_DEBUG_COLOR NRFX_CONFIG_ENTRY(_CONFIG_DEBUG_COLOR) +#else +#define NRF_LOG_LEVEL 0 +#endif +#endif // defined(NRFX_LOG_MODULE) + +#include <nrf_log.h> + +#if defined(NRFX_LOG_MODULE) +NRF_LOG_MODULE_REGISTER(); +#endif + +#define TEST_MACRO_INFO(...) NRF_LOG_INFO(__VA_ARGS__) +/** + * @defgroup nrfx_log nrfx_log.h + * @{ + * @ingroup nrfx + * + * @brief This file contains macros that should be implemented according to + * the needs of the host environment into which @em nrfx is integrated. + */ + +/** + * @brief Macro for logging a message with the severity level ERROR. + */ +#define NRFX_LOG_ERROR(...) NRF_LOG_ERROR(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level WARNING. + */ +#define NRFX_LOG_WARNING(...) NRF_LOG_WARNING(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level INFO. + */ +#define NRFX_LOG_INFO(...) TEST_MACRO_INFO(__VA_ARGS__) + +/** + * @brief Macro for logging a message with the severity level DEBUG. + */ +#define NRFX_LOG_DEBUG(...) NRF_LOG_DEBUG(__VA_ARGS__) + + +/** + * @brief Macro for logging a memory dump with the severity level ERROR. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_ERROR(p_memory, length) \ + NRF_LOG_HEXDUMP_ERROR(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level WARNING. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_WARNING(p_memory, length) \ + NRF_LOG_HEXDUMP_WARNING(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level INFO. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_INFO(p_memory, length) \ + NRF_LOG_HEXDUMP_INFO(p_memory, length) + +/** + * @brief Macro for logging a memory dump with the severity level DEBUG. + * + * @param[in] p_memory Pointer to the memory region to be dumped. + * @param[in] length Length of the memory region in bytes. + */ +#define NRFX_LOG_HEXDUMP_DEBUG(p_memory, length) \ + NRF_LOG_HEXDUMP_DEBUG(p_memory, length) + + +/** + * @brief Macro for getting the textual representation of a given error code. + * + * @param[in] error_code Error code. + * + * @return String containing the textual representation of the error code. + */ +#define NRFX_LOG_ERROR_STRING_GET(error_code) \ + NRF_LOG_ERROR_STRING_GET(error_code) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRFX_LOG_H__ |