aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp')
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.c637
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.h307
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.c172
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.h91
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.c254
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.h100
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.c77
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.h83
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_config.h135
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.c84
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.h107
11 files changed, 2047 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.c
new file mode 100644
index 0000000..3bf4d00
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.c
@@ -0,0 +1,637 @@
+/**
+ * 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.
+ *
+ */
+#include "bsp.h"
+#include <stddef.h>
+#include <stdio.h>
+#include "nordic_common.h"
+#include "nrf.h"
+#include "nrf_gpio.h"
+#include "nrf_error.h"
+#include "bsp_config.h"
+#include "boards.h"
+
+#ifndef BSP_SIMPLE
+#include "app_timer.h"
+#include "app_button.h"
+#endif // BSP_SIMPLE
+
+#if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+static bsp_indication_t m_stable_state = BSP_INDICATE_IDLE;
+static bool m_leds_clear = false;
+static uint32_t m_indication_type = 0;
+static bool m_alert_on = false;
+APP_TIMER_DEF(m_bsp_leds_tmr);
+APP_TIMER_DEF(m_bsp_alert_tmr);
+#endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+
+#if BUTTONS_NUMBER > 0
+#ifndef BSP_SIMPLE
+static bsp_event_callback_t m_registered_callback = NULL;
+static bsp_button_event_cfg_t m_events_list[BUTTONS_NUMBER] = {{BSP_EVENT_NOTHING, BSP_EVENT_NOTHING}};
+APP_TIMER_DEF(m_bsp_button_tmr);
+static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action);
+#endif // BSP_SIMPLE
+
+#ifndef BSP_SIMPLE
+static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] =
+{
+ #ifdef BSP_BUTTON_0
+ {BSP_BUTTON_0, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_0
+
+ #ifdef BSP_BUTTON_1
+ {BSP_BUTTON_1, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_1
+
+ #ifdef BSP_BUTTON_2
+ {BSP_BUTTON_2, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_2
+
+ #ifdef BSP_BUTTON_3
+ {BSP_BUTTON_3, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_3
+
+ #ifdef BSP_BUTTON_4
+ {BSP_BUTTON_4, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_4
+
+ #ifdef BSP_BUTTON_5
+ {BSP_BUTTON_5, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_5
+
+ #ifdef BSP_BUTTON_6
+ {BSP_BUTTON_6, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_6
+
+ #ifdef BSP_BUTTON_7
+ {BSP_BUTTON_7, false, BUTTON_PULL, bsp_button_event_handler},
+ #endif // BUTTON_7
+
+};
+#endif // BSP_SIMPLE
+#endif // BUTTONS_NUMBER > 0
+
+#if (BUTTONS_NUMBER > 0)
+bool bsp_button_is_pressed(uint32_t button)
+{
+ if (button < BUTTONS_NUMBER)
+ {
+ return bsp_board_button_state_get(button);
+ }
+ else
+ {
+ //If button is not present always return false
+ return false;
+ }
+}
+#endif
+
+#if (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE)
+/**@brief Function for handling button events.
+ *
+ * @param[in] pin_no The pin number of the button pressed.
+ * @param[in] button_action Action button.
+ */
+static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)
+{
+ bsp_event_t event = BSP_EVENT_NOTHING;
+ uint32_t button = 0;
+ uint32_t err_code;
+ static uint8_t current_long_push_pin_no; /**< Pin number of a currently pushed button, that could become a long push if held long enough. */
+ static bsp_event_t release_event_at_push[BUTTONS_NUMBER]; /**< Array of what the release event of each button was last time it was pushed, so that no release event is sent if the event was bound after the push of the button. */
+
+ button = bsp_board_pin_to_button_idx(pin_no);
+
+ if (button < BUTTONS_NUMBER)
+ {
+ switch (button_action)
+ {
+ case APP_BUTTON_PUSH:
+ event = m_events_list[button].push_event;
+ if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING)
+ {
+ err_code = app_timer_start(m_bsp_button_tmr, APP_TIMER_TICKS(BSP_LONG_PUSH_TIMEOUT_MS), (void*)&current_long_push_pin_no);
+ if (err_code == NRF_SUCCESS)
+ {
+ current_long_push_pin_no = pin_no;
+ }
+ }
+ release_event_at_push[button] = m_events_list[button].release_event;
+ break;
+ case APP_BUTTON_RELEASE:
+ (void)app_timer_stop(m_bsp_button_tmr);
+ if (release_event_at_push[button] == m_events_list[button].release_event)
+ {
+ event = m_events_list[button].release_event;
+ }
+ break;
+ case BSP_BUTTON_ACTION_LONG_PUSH:
+ event = m_events_list[button].long_push_event;
+ }
+ }
+
+ if ((event != BSP_EVENT_NOTHING) && (m_registered_callback != NULL))
+ {
+ m_registered_callback(event);
+ }
+}
+
+/**@brief Handle events from button timer.
+ *
+ * @param[in] p_context parameter registered in timer start function.
+ */
+static void button_timer_handler(void * p_context)
+{
+ bsp_button_event_handler(*(uint8_t *)p_context, BSP_BUTTON_ACTION_LONG_PUSH);
+}
+
+
+#endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE)
+
+
+#if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+static void leds_off(void)
+{
+ if (m_alert_on)
+ {
+ uint32_t i;
+ for (i = 0; i < LEDS_NUMBER; i++)
+ {
+ if (i != BSP_LED_ALERT)
+ {
+ bsp_board_led_off(i);
+ }
+ }
+ }
+ else
+ {
+ bsp_board_leds_off();
+ }
+}
+
+
+/**@brief Configure leds to indicate required state.
+ * @param[in] indicate State to be indicated.
+ */
+static uint32_t bsp_led_indication(bsp_indication_t indicate)
+{
+ uint32_t err_code = NRF_SUCCESS;
+ uint32_t next_delay = 0;
+
+ if (m_leds_clear)
+ {
+ m_leds_clear = false;
+ leds_off();
+ }
+
+ switch (indicate)
+ {
+ case BSP_INDICATE_IDLE:
+ leds_off();
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_SCANNING:
+ case BSP_INDICATE_ADVERTISING:
+ // in advertising blink LED_0
+ if (bsp_board_led_state_get(BSP_LED_INDICATE_INDICATE_ADVERTISING))
+ {
+ bsp_board_led_off(BSP_LED_INDICATE_INDICATE_ADVERTISING);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_OFF_INTERVAL :
+ ADVERTISING_SLOW_LED_OFF_INTERVAL;
+ }
+ else
+ {
+ bsp_board_led_on(BSP_LED_INDICATE_INDICATE_ADVERTISING);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_ON_INTERVAL :
+ ADVERTISING_SLOW_LED_ON_INTERVAL;
+ }
+
+ m_stable_state = indicate;
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL);
+ break;
+
+ case BSP_INDICATE_ADVERTISING_WHITELIST:
+ // in advertising quickly blink LED_0
+ if (bsp_board_led_state_get(BSP_LED_INDICATE_ADVERTISING_WHITELIST))
+ {
+ bsp_board_led_off(BSP_LED_INDICATE_ADVERTISING_WHITELIST);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_WHITELIST ?
+ ADVERTISING_WHITELIST_LED_OFF_INTERVAL :
+ ADVERTISING_SLOW_LED_OFF_INTERVAL;
+ }
+ else
+ {
+ bsp_board_led_on(BSP_LED_INDICATE_ADVERTISING_WHITELIST);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_WHITELIST ?
+ ADVERTISING_WHITELIST_LED_ON_INTERVAL :
+ ADVERTISING_SLOW_LED_ON_INTERVAL;
+ }
+ m_stable_state = indicate;
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL);
+ break;
+
+ case BSP_INDICATE_ADVERTISING_SLOW:
+ // in advertising slowly blink LED_0
+ if (bsp_board_led_state_get(BSP_LED_INDICATE_ADVERTISING_SLOW))
+ {
+ bsp_board_led_off(BSP_LED_INDICATE_ADVERTISING_SLOW);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_SLOW ? ADVERTISING_SLOW_LED_OFF_INTERVAL :
+ ADVERTISING_SLOW_LED_OFF_INTERVAL;
+ }
+ else
+ {
+ bsp_board_led_on(BSP_LED_INDICATE_ADVERTISING_SLOW);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_SLOW ? ADVERTISING_SLOW_LED_ON_INTERVAL :
+ ADVERTISING_SLOW_LED_ON_INTERVAL;
+ }
+ m_stable_state = indicate;
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL);
+ break;
+
+ case BSP_INDICATE_ADVERTISING_DIRECTED:
+ // in advertising very quickly blink LED_0
+ if (bsp_board_led_state_get(BSP_LED_INDICATE_ADVERTISING_DIRECTED))
+ {
+ bsp_board_led_off(BSP_LED_INDICATE_ADVERTISING_DIRECTED);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_DIRECTED ?
+ ADVERTISING_DIRECTED_LED_OFF_INTERVAL :
+ ADVERTISING_SLOW_LED_OFF_INTERVAL;
+ }
+ else
+ {
+ bsp_board_led_on(BSP_LED_INDICATE_ADVERTISING_DIRECTED);
+ next_delay = indicate ==
+ BSP_INDICATE_ADVERTISING_DIRECTED ?
+ ADVERTISING_DIRECTED_LED_ON_INTERVAL :
+ ADVERTISING_SLOW_LED_ON_INTERVAL;
+ }
+ m_stable_state = indicate;
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(next_delay), NULL);
+ break;
+
+ case BSP_INDICATE_BONDING:
+ // in bonding fast blink LED_0
+ bsp_board_led_invert(BSP_LED_INDICATE_BONDING);
+
+ m_stable_state = indicate;
+ err_code =
+ app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(BONDING_INTERVAL), NULL);
+ break;
+
+ case BSP_INDICATE_CONNECTED:
+ bsp_board_led_on(BSP_LED_INDICATE_CONNECTED);
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_SENT_OK:
+ // when sending shortly invert LED_1
+ m_leds_clear = true;
+ bsp_board_led_invert(BSP_LED_INDICATE_SENT_OK);
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(SENT_OK_INTERVAL), NULL);
+ break;
+
+ case BSP_INDICATE_SEND_ERROR:
+ // on receving error invert LED_1 for long time
+ m_leds_clear = true;
+ bsp_board_led_invert(BSP_LED_INDICATE_SEND_ERROR);
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(SEND_ERROR_INTERVAL), NULL);
+ break;
+
+ case BSP_INDICATE_RCV_OK:
+ // when receving shortly invert LED_1
+ m_leds_clear = true;
+ bsp_board_led_invert(BSP_LED_INDICATE_RCV_OK);
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(RCV_OK_INTERVAL), NULL);
+ break;
+
+ case BSP_INDICATE_RCV_ERROR:
+ // on receving error invert LED_1 for long time
+ m_leds_clear = true;
+ bsp_board_led_invert(BSP_LED_INDICATE_RCV_ERROR);
+ err_code = app_timer_start(m_bsp_leds_tmr, APP_TIMER_TICKS(RCV_ERROR_INTERVAL), NULL);
+ break;
+
+ case BSP_INDICATE_FATAL_ERROR:
+ // on fatal error turn on all leds
+ bsp_board_leds_on();
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_ALERT_0:
+ case BSP_INDICATE_ALERT_1:
+ case BSP_INDICATE_ALERT_2:
+ case BSP_INDICATE_ALERT_3:
+ case BSP_INDICATE_ALERT_OFF:
+ err_code = app_timer_stop(m_bsp_alert_tmr);
+ next_delay = (uint32_t)BSP_INDICATE_ALERT_OFF - (uint32_t)indicate;
+
+ // a little trick to find out that if it did not fall through ALERT_OFF
+ if (next_delay && (err_code == NRF_SUCCESS))
+ {
+ if (next_delay > 1)
+ {
+ err_code = app_timer_start(m_bsp_alert_tmr,
+ APP_TIMER_TICKS(((uint16_t)next_delay * ALERT_INTERVAL)),
+ NULL);
+ }
+ bsp_board_led_on(BSP_LED_ALERT);
+ m_alert_on = true;
+ }
+ else
+ {
+ bsp_board_led_off(BSP_LED_ALERT);
+ m_alert_on = false;
+
+ }
+ break;
+
+ case BSP_INDICATE_USER_STATE_OFF:
+ leds_off();
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_USER_STATE_0:
+ leds_off();
+ bsp_board_led_on(BSP_LED_INDICATE_USER_LED1);
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_USER_STATE_1:
+ leds_off();
+ bsp_board_led_on(BSP_LED_INDICATE_USER_LED2);
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_USER_STATE_2:
+ leds_off();
+ bsp_board_led_on(BSP_LED_INDICATE_USER_LED1);
+ bsp_board_led_on(BSP_LED_INDICATE_USER_LED2);
+ m_stable_state = indicate;
+ break;
+
+ case BSP_INDICATE_USER_STATE_3:
+
+ case BSP_INDICATE_USER_STATE_ON:
+ bsp_board_leds_on();
+ m_stable_state = indicate;
+ break;
+
+ default:
+ break;
+ }
+
+ return err_code;
+}
+
+
+/**@brief Handle events from leds timer.
+ *
+ * @note Timer handler does not support returning an error code.
+ * Errors from bsp_led_indication() are not propagated.
+ *
+ * @param[in] p_context parameter registered in timer start function.
+ */
+static void leds_timer_handler(void * p_context)
+{
+ UNUSED_PARAMETER(p_context);
+
+ if (m_indication_type & BSP_INIT_LEDS)
+ {
+ UNUSED_VARIABLE(bsp_led_indication(m_stable_state));
+ }
+}
+
+
+/**@brief Handle events from alert timer.
+ *
+ * @param[in] p_context parameter registered in timer start function.
+ */
+static void alert_timer_handler(void * p_context)
+{
+ UNUSED_PARAMETER(p_context);
+ bsp_board_led_invert(BSP_LED_ALERT);
+}
+#endif // #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+
+
+/**@brief Configure indicators to required state.
+ */
+uint32_t bsp_indication_set(bsp_indication_t indicate)
+{
+ uint32_t err_code = NRF_SUCCESS;
+
+#if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+
+ if (m_indication_type & BSP_INIT_LEDS)
+ {
+ err_code = bsp_led_indication(indicate);
+ }
+
+#endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+ return err_code;
+}
+
+
+uint32_t bsp_init(uint32_t type, bsp_event_callback_t callback)
+{
+ uint32_t err_code = NRF_SUCCESS;
+
+#if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+ m_indication_type = type;
+#endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+
+#if (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE)
+ m_registered_callback = callback;
+
+ // BSP will support buttons and generate events
+ if (type & BSP_INIT_BUTTONS)
+ {
+ uint32_t num;
+
+ for (num = 0; ((num < BUTTONS_NUMBER) && (err_code == NRF_SUCCESS)); num++)
+ {
+ err_code = bsp_event_to_button_action_assign(num, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_DEFAULT);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = app_button_init((app_button_cfg_t *)app_buttons,
+ BUTTONS_NUMBER,
+ APP_TIMER_TICKS(50));
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = app_button_enable();
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = app_timer_create(&m_bsp_button_tmr,
+ APP_TIMER_MODE_SINGLE_SHOT,
+ button_timer_handler);
+ }
+ }
+#elif (BUTTONS_NUMBER > 0) && (defined BSP_SIMPLE)
+ bsp_board_init(type);
+#endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE)
+
+#if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+ if (type & BSP_INIT_LEDS)
+ {
+ //handle LEDs only. Buttons are already handled.
+ bsp_board_init(BSP_INIT_LEDS);
+
+ // timers module must be already initialized!
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code =
+ app_timer_create(&m_bsp_leds_tmr, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code =
+ app_timer_create(&m_bsp_alert_tmr, APP_TIMER_MODE_REPEATED, alert_timer_handler);
+ }
+ }
+#endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE)
+
+ return err_code;
+}
+
+
+#ifndef BSP_SIMPLE
+/**@brief Assign specific event to button.
+ */
+uint32_t bsp_event_to_button_action_assign(uint32_t button, bsp_button_action_t action, bsp_event_t event)
+{
+ uint32_t err_code = NRF_SUCCESS;
+
+#if BUTTONS_NUMBER > 0
+ if (button < BUTTONS_NUMBER)
+ {
+ if (event == BSP_EVENT_DEFAULT)
+ {
+ // Setting default action: BSP_EVENT_KEY_x for PUSH actions, BSP_EVENT_NOTHING for RELEASE and LONG_PUSH actions.
+ event = (action == BSP_BUTTON_ACTION_PUSH) ? (bsp_event_t)(BSP_EVENT_KEY_0 + button) : BSP_EVENT_NOTHING;
+ }
+ switch (action)
+ {
+ case BSP_BUTTON_ACTION_PUSH:
+ m_events_list[button].push_event = event;
+ break;
+ case BSP_BUTTON_ACTION_LONG_PUSH:
+ m_events_list[button].long_push_event = event;
+ break;
+ case BSP_BUTTON_ACTION_RELEASE:
+ m_events_list[button].release_event = event;
+ break;
+ default:
+ err_code = NRF_ERROR_INVALID_PARAM;
+ break;
+ }
+ }
+ else
+ {
+ err_code = NRF_ERROR_INVALID_PARAM;
+ }
+#else
+ err_code = NRF_ERROR_INVALID_PARAM;
+#endif // BUTTONS_NUMBER > 0
+
+ return err_code;
+}
+
+#endif // BSP_SIMPLE
+
+
+uint32_t bsp_buttons_enable()
+{
+#if (BUTTONS_NUMBER > 0) && !defined(BSP_SIMPLE)
+ return app_button_enable();
+#else
+ return NRF_ERROR_NOT_SUPPORTED;
+#endif
+}
+
+uint32_t bsp_buttons_disable()
+{
+#if (BUTTONS_NUMBER > 0) && !defined(BSP_SIMPLE)
+ return app_button_disable();
+#else
+ return NRF_ERROR_NOT_SUPPORTED;
+#endif
+}
+static uint32_t wakeup_button_cfg(uint32_t button_idx, bool enable)
+{
+#if !defined(BSP_SIMPLE)
+ if (button_idx < BUTTONS_NUMBER)
+ {
+ nrf_gpio_pin_sense_t sense = enable ?
+ (BUTTONS_ACTIVE_STATE ? NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW) :
+ NRF_GPIO_PIN_NOSENSE;
+ nrf_gpio_cfg_sense_set(bsp_board_button_idx_to_pin(button_idx), sense);
+ return NRF_SUCCESS;
+ }
+#else
+ UNUSED_PARAMETER(button_idx);
+ UNUSED_PARAMETER(enable);
+#endif
+ return NRF_ERROR_NOT_SUPPORTED;
+
+}
+uint32_t bsp_wakeup_button_enable(uint32_t button_idx)
+{
+ return wakeup_button_cfg(button_idx, true);
+}
+
+uint32_t bsp_wakeup_button_disable(uint32_t button_idx)
+{
+ return wakeup_button_cfg(button_idx, false);
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.h
new file mode 100644
index 0000000..904a3d4
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp.h
@@ -0,0 +1,307 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp Board Support Package
+ * @{
+ * @ingroup app_common
+ *
+ * @brief BSP module.
+ * @details This module provides a layer of abstraction from the board.
+ * It allows the user to indicate certain states on LEDs in a simple way.
+ * Module functionality can be modified by defining BSP_SIMPLE to reduce
+ * functionality of this module to enable and read state of the buttons.
+ */
+
+#ifndef BSP_H__
+#define BSP_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "boards.h"
+
+#if !defined(BSP_DEFINES_ONLY) && !defined(BSP_SIMPLE)
+#include "app_button.h"
+
+#define BSP_BUTTON_ACTION_PUSH (APP_BUTTON_PUSH) /**< Represents pushing a button. See @ref bsp_button_action_t. */
+#define BSP_BUTTON_ACTION_RELEASE (APP_BUTTON_RELEASE) /**< Represents releasing a button. See @ref bsp_button_action_t. */
+#define BSP_BUTTON_ACTION_LONG_PUSH (2) /**< Represents pushing and holding a button for @ref BSP_LONG_PUSH_TIMEOUT_MS milliseconds. See also @ref bsp_button_action_t. */
+
+#endif
+
+/* BSP_UART_SUPPORT
+ * This define enables UART support module.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef uint8_t bsp_button_action_t; /**< The different actions that can be performed on a button. */
+
+#define BSP_INDICATIONS_LIST { \
+ "BSP_INDICATE_IDLE", \
+ "BSP_INDICATE_SCANNING", \
+ "BSP_INDICATE_ADVERTISING", \
+ "BSP_INDICATE_ADVERTISING_WHITELIST", \
+ "BSP_INDICATE_ADVERTISING_SLOW", \
+ "BSP_INDICATE_ADVERTISING_DIRECTED", \
+ "BSP_INDICATE_BONDING", \
+ "BSP_INDICATE_CONNECTED", \
+ "BSP_INDICATE_SENT_OK", \
+ "BSP_INDICATE_SEND_ERROR", \
+ "BSP_INDICATE_RCV_OK", \
+ "BSP_INDICATE_RCV_ERROR", \
+ "BSP_INDICATE_FATAL_ERROR", \
+ "BSP_INDICATE_ALERT_0", \
+ "BSP_INDICATE_ALERT_1", \
+ "BSP_INDICATE_ALERT_2", \
+ "BSP_INDICATE_ALERT_3", \
+ "BSP_INDICATE_ALERT_OFF", \
+ "BSP_INDICATE_USER_STATE_OFF", \
+ "BSP_INDICATE_USER_STATE_0", \
+ "BSP_INDICATE_USER_STATE_1", \
+ "BSP_INDICATE_USER_STATE_2", \
+ "BSP_INDICATE_USER_STATE_3", \
+ "BSP_INDICATE_USER_STATE_ON" \
+} /**< See @ref examples_bsp_states for a list of how these states are indicated for the PCA10028/PCA10040 board and the PCA10031 dongle.*/
+
+
+/**@brief BSP indication states.
+ *
+ * @details See @ref examples_bsp_states for a list of how these states are indicated for the PCA10028/PCA10040 board and the PCA10031 dongle.
+ */
+typedef enum
+{
+ BSP_INDICATE_FIRST = 0,
+ BSP_INDICATE_IDLE = BSP_INDICATE_FIRST, /**< See \ref BSP_INDICATE_IDLE.*/
+ BSP_INDICATE_SCANNING, /**< See \ref BSP_INDICATE_SCANNING.*/
+ BSP_INDICATE_ADVERTISING, /**< See \ref BSP_INDICATE_ADVERTISING.*/
+ BSP_INDICATE_ADVERTISING_WHITELIST, /**< See \ref BSP_INDICATE_ADVERTISING_WHITELIST.*/
+ BSP_INDICATE_ADVERTISING_SLOW, /**< See \ref BSP_INDICATE_ADVERTISING_SLOW.*/
+ BSP_INDICATE_ADVERTISING_DIRECTED, /**< See \ref BSP_INDICATE_ADVERTISING_DIRECTED.*/
+ BSP_INDICATE_BONDING, /**< See \ref BSP_INDICATE_BONDING.*/
+ BSP_INDICATE_CONNECTED, /**< See \ref BSP_INDICATE_CONNECTED.*/
+ BSP_INDICATE_SENT_OK, /**< See \ref BSP_INDICATE_SENT_OK.*/
+ BSP_INDICATE_SEND_ERROR, /**< See \ref BSP_INDICATE_SEND_ERROR.*/
+ BSP_INDICATE_RCV_OK, /**< See \ref BSP_INDICATE_RCV_OK.*/
+ BSP_INDICATE_RCV_ERROR, /**< See \ref BSP_INDICATE_RCV_ERROR.*/
+ BSP_INDICATE_FATAL_ERROR, /**< See \ref BSP_INDICATE_FATAL_ERROR.*/
+ BSP_INDICATE_ALERT_0, /**< See \ref BSP_INDICATE_ALERT_0.*/
+ BSP_INDICATE_ALERT_1, /**< See \ref BSP_INDICATE_ALERT_1.*/
+ BSP_INDICATE_ALERT_2, /**< See \ref BSP_INDICATE_ALERT_2.*/
+ BSP_INDICATE_ALERT_3, /**< See \ref BSP_INDICATE_ALERT_3.*/
+ BSP_INDICATE_ALERT_OFF, /**< See \ref BSP_INDICATE_ALERT_OFF.*/
+ BSP_INDICATE_USER_STATE_OFF, /**< See \ref BSP_INDICATE_USER_STATE_OFF.*/
+ BSP_INDICATE_USER_STATE_0, /**< See \ref BSP_INDICATE_USER_STATE_0.*/
+ BSP_INDICATE_USER_STATE_1, /**< See \ref BSP_INDICATE_USER_STATE_1.*/
+ BSP_INDICATE_USER_STATE_2, /**< See \ref BSP_INDICATE_USER_STATE_2.*/
+ BSP_INDICATE_USER_STATE_3, /**< See \ref BSP_INDICATE_USER_STATE_3.*/
+ BSP_INDICATE_USER_STATE_ON, /**< See \ref BSP_INDICATE_USER_STATE_ON.*/
+ BSP_INDICATE_LAST = BSP_INDICATE_USER_STATE_ON
+} bsp_indication_t;
+
+/**@brief BSP events.
+ *
+ * @note Events from BSP_EVENT_KEY_0 to BSP_EVENT_KEY_LAST are by default assigned to buttons.
+ */
+typedef enum
+{
+ BSP_EVENT_NOTHING = 0, /**< Assign this event to an action to prevent the action from generating an event (disable the action). */
+ BSP_EVENT_DEFAULT, /**< Assign this event to an action to assign the default event to the action. */
+ BSP_EVENT_CLEAR_BONDING_DATA, /**< Persistent bonding data should be erased. */
+ BSP_EVENT_CLEAR_ALERT, /**< An alert should be cleared. */
+ BSP_EVENT_DISCONNECT, /**< A link should be disconnected. */
+ BSP_EVENT_ADVERTISING_START, /**< The device should start advertising. */
+ BSP_EVENT_ADVERTISING_STOP, /**< The device should stop advertising. */
+ BSP_EVENT_WHITELIST_OFF, /**< The device should remove its advertising whitelist. */
+ BSP_EVENT_BOND, /**< The device should bond to the currently connected peer. */
+ BSP_EVENT_RESET, /**< The device should reset. */
+ BSP_EVENT_SLEEP, /**< The device should enter sleep mode. */
+ BSP_EVENT_WAKEUP, /**< The device should wake up from sleep mode. */
+ BSP_EVENT_SYSOFF, /**< The device should enter system off mode (without wakeup). */
+ BSP_EVENT_DFU, /**< The device should enter DFU mode. */
+ BSP_EVENT_KEY_0, /**< Default event of the push action of BSP_BUTTON_0 (only if this button is present). */
+ BSP_EVENT_KEY_1, /**< Default event of the push action of BSP_BUTTON_1 (only if this button is present). */
+ BSP_EVENT_KEY_2, /**< Default event of the push action of BSP_BUTTON_2 (only if this button is present). */
+ BSP_EVENT_KEY_3, /**< Default event of the push action of BSP_BUTTON_3 (only if this button is present). */
+ BSP_EVENT_KEY_4, /**< Default event of the push action of BSP_BUTTON_4 (only if this button is present). */
+ BSP_EVENT_KEY_5, /**< Default event of the push action of BSP_BUTTON_5 (only if this button is present). */
+ BSP_EVENT_KEY_6, /**< Default event of the push action of BSP_BUTTON_6 (only if this button is present). */
+ BSP_EVENT_KEY_7, /**< Default event of the push action of BSP_BUTTON_7 (only if this button is present). */
+ BSP_EVENT_KEY_LAST = BSP_EVENT_KEY_7,
+} bsp_event_t;
+
+
+typedef struct
+{
+ bsp_event_t push_event; /**< The event to fire on regular button press. */
+ bsp_event_t long_push_event; /**< The event to fire on long button press. */
+ bsp_event_t release_event; /**< The event to fire on button release. */
+} bsp_button_event_cfg_t;
+
+/**@brief BSP module event callback function type.
+ *
+ * @details Upon an event in the BSP module, this callback function will be called to notify
+ * the application about the event.
+ *
+ * @param[in] bsp_event_t BSP event type.
+ */
+typedef void (* bsp_event_callback_t)(bsp_event_t);
+
+
+/**@brief Function for initializing BSP.
+ *
+ * @details The function initializes the board support package to allow state indication and
+ * button reaction. Default events are assigned to buttons.
+ * @note Before calling this function, you must initiate the following required modules:
+ * - @ref app_timer for LED support
+ * - @ref app_gpiote for button support
+ *
+ * @param[in] type Type of peripherals used.
+ * @param[in] callback Function to be called when button press/event is detected.
+ *
+ * @retval NRF_SUCCESS If the BSP module was successfully initialized.
+ * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized.
+ * @retval NRF_ERROR_NO_MEM If the maximum number of timers has already been reached.
+ * @retval NRF_ERROR_INVALID_PARAM If GPIOTE has too many users.
+ * @retval NRF_ERROR_INVALID_STATE If button or GPIOTE has not been initialized.
+ */
+uint32_t bsp_init(uint32_t type, bsp_event_callback_t callback);
+
+
+/**@brief Function for checking button states.
+ *
+ * @details This function checks if the button is pressed. If the button ID is out of range,
+ * the function returns false.
+ *
+ * @param[in] button Button ID to check.
+ *
+ * @retval true If the button is pressed.
+ * @retval false If the button is not pressed.
+ */
+bool bsp_button_is_pressed(uint32_t button);
+
+
+/**@brief Function for assigning a specific event to a button.
+ *
+ * @details This function allows redefinition of standard events assigned to buttons.
+ * To unassign events, provide the event @ref BSP_EVENT_NOTHING.
+ *
+ * @param[in] button Button ID to be redefined.
+ * @param[in] action Button action to assign event to.
+ * @param[in] event Event to be assigned to button.
+ *
+ * @retval NRF_SUCCESS If the event was successfully assigned to button.
+ * @retval NRF_ERROR_INVALID_PARAM If the button ID or button action was invalid.
+ */
+uint32_t bsp_event_to_button_action_assign(uint32_t button, bsp_button_action_t action, bsp_event_t event);
+
+
+/**@brief Function for configuring indicators to required state.
+ *
+ * @details This function indicates the required state by means of LEDs (if enabled).
+ *
+ * @note Alerts are indicated independently.
+ *
+ * @param[in] indicate State to be indicated.
+ *
+ * @retval NRF_SUCCESS If the state was successfully indicated.
+ * @retval NRF_ERROR_NO_MEM If the internal timer operations queue was full.
+ * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized,
+ * or internal timer has not been created.
+ */
+uint32_t bsp_indication_set(bsp_indication_t indicate);
+
+
+/**@brief Function for enabling all buttons.
+ *
+ * @details After calling this function, all buttons will generate events when pressed, and
+ * all buttons will be able to wake the system up from sleep mode.
+ *
+ * @retval NRF_SUCCESS If the buttons were successfully enabled.
+ * @retval NRF_ERROR_NOT_SUPPORTED If the board has no buttons or BSP_SIMPLE is defined.
+ * @return A propagated error.
+ */
+uint32_t bsp_buttons_enable(void);
+
+
+/**@brief Function for disabling all buttons.
+ *
+ * @details After calling this function, no buttons will generate events when pressed, and
+ * no buttons will be able to wake the system up from sleep mode.
+ *
+ * @retval NRF_SUCCESS If the buttons were successfully disabled.
+ * @retval NRF_ERROR_NOT_SUPPORTED If the board has no buttons or BSP_SIMPLE is defined.
+ * @return A propagated error.
+ */
+uint32_t bsp_buttons_disable(void);
+
+
+/**@brief Function for enabling wakeup from SYSTEM OFF for given button.
+ *
+ * @details After calling this function, button can be used to wake up the chip.
+ * This function should only be called immediately before going into sleep.
+ *
+ * @param[in] button_idx Index of the button.
+ *
+ * @retval NRF_SUCCESS If the button was successfully enabled.
+ * @retval NRF_ERROR_NOT_SUPPORTED If the board has no buttons or BSP_SIMPLE is defined.
+ */
+uint32_t bsp_wakeup_button_enable(uint32_t button_idx);
+
+
+/**@brief Function for disabling wakeup for the given button.
+ *
+ * @param[in] button_idx index of the button.
+ *
+ * @retval NRF_SUCCESS If the button was successfully disabled.
+ * @retval NRF_ERROR_NOT_SUPPORTED If the board has no buttons or BSP_SIMPLE is defined.
+ */
+uint32_t bsp_wakeup_button_disable(uint32_t button_idx);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // BSP_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.c
new file mode 100644
index 0000000..6706da9
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.c
@@ -0,0 +1,172 @@
+/**
+ * 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 "sdk_common.h"
+#if NRF_MODULE_ENABLED(BSP_BTN_ANT)
+#include "bsp_btn_ant.h"
+#include "nrf_sdh_ant.h"
+#include "bsp.h"
+
+
+static bool m_connected = false; /**< Notify if channel is connected. */
+static uint8_t m_channel = UINT8_MAX; /**< ANT channel number linked to indication. */
+static uint8_t m_channel_type; /**< Type of linked ANT channel. */
+
+/**@brief Function for configuring the buttons for connection.
+ *
+ * @retval NRF_SUCCESS Configured successfully.
+ * @return A propagated error code.
+ */
+static ret_code_t connection_buttons_configure(void)
+{
+ ret_code_t err_code = bsp_event_to_button_action_assign(BSP_BTN_ANT_CONFIG_SLEEP_BTN_ID,
+ BSP_BUTTON_ACTION_RELEASE,
+ BSP_EVENT_DEFAULT);
+ if (err_code == NRF_ERROR_INVALID_PARAM)
+ {
+ return NRF_SUCCESS;
+ }
+
+ return err_code;
+}
+
+/**@brief Function for configuring the buttons for searching.
+ *
+ * @retval NRF_SUCCESS Configured successfully.
+ * @return A propagated error code.
+ */
+static ret_code_t searching_buttons_configure(void)
+{
+ ret_code_t err_code = bsp_event_to_button_action_assign(BSP_BTN_ANT_CONFIG_SLEEP_BTN_ID,
+ BSP_BUTTON_ACTION_RELEASE,
+ BSP_EVENT_SLEEP);
+ if (err_code == NRF_ERROR_INVALID_PARAM)
+ {
+ return NRF_SUCCESS;
+ }
+
+ return err_code;
+}
+
+
+ret_code_t bsp_btn_ant_sleep_mode_prepare(void)
+{
+ ret_code_t err_code = bsp_buttons_disable();
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ err_code = bsp_wakeup_button_enable(BSP_BTN_ANT_CONFIG_WAKEUP_BTN_ID);
+ if (err_code == NRF_ERROR_NOT_SUPPORTED)
+ {
+ return NRF_SUCCESS;
+ }
+
+ return err_code;
+}
+
+/**
+ * @brief Function for handling ANT events.
+ *
+ * @param[in] p_ant_evt Event received from the ANT stack.
+ * @param[in] p_context Context.
+ */
+static void ant_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
+{
+ ret_code_t err_code = NRF_SUCCESS;
+
+ if (m_channel != p_ant_evt->channel)
+ {
+ return;
+ }
+
+ switch (m_channel_type)
+ {
+ case CHANNEL_TYPE_SLAVE:
+ /* fall through */
+ case CHANNEL_TYPE_SLAVE_RX_ONLY:
+ switch (p_ant_evt->event)
+ {
+ case EVENT_RX:
+ if (!m_connected)
+ {
+ err_code = connection_buttons_configure();
+ }
+
+ m_connected = true;
+ break;
+
+ case EVENT_RX_FAIL_GO_TO_SEARCH:
+ m_connected = false;
+
+ err_code = searching_buttons_configure();
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+
+ APP_ERROR_CHECK(err_code);
+}
+
+NRF_SDH_ANT_OBSERVER(m_ant_observer, BSP_BTN_ANT_OBSERVER_PRIO, ant_evt_handler, NULL);
+
+ret_code_t bsp_btn_ant_init(uint8_t channel, uint8_t channel_type)
+{
+ ret_code_t err_code = NRF_SUCCESS;
+
+ m_channel = channel;
+ m_channel_type = channel_type;
+
+ if (!m_connected)
+ {
+ err_code = searching_buttons_configure();
+ }
+ else
+ {
+ err_code = connection_buttons_configure();
+ }
+
+ return err_code;
+}
+
+#endif // NRF_MODULE_ENABLED(BSP_BTN_ANT)
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.h
new file mode 100644
index 0000000..061fc72
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ant.h
@@ -0,0 +1,91 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp_btn_ant BSP: ANT Button Module
+ * @{
+ * @ingroup bsp
+ *
+ * @brief Module for controlling ANT behavior through button actions.
+ *
+ * @details The application must propagate ANT events to the ANT Button Module.
+ * Based on these events, the ANT Button Module configures the Board Support Package
+ * to generate BSP events for certain button actions. These BSP events should then be
+ * handled by the application's BSP event handler.
+ *
+ */
+
+#ifndef BSP_BTN_ANT_H__
+#define BSP_BTN_ANT_H__
+
+#include <stdint.h>
+#include "sdk_errors.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**@brief Function for initializing the ANT Button Module.
+ *
+ * Before calling this function, the BSP module must be initialized with buttons.
+ *
+ * @param[in] channel ANT channel number.
+ * @param[in] channel_type ANT channel type (see Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
+ *
+ * @retval NRF_SUCCESS If initialization was successful. Otherwise, a propagated error code is
+ * returned.
+ */
+ret_code_t bsp_btn_ant_init(uint8_t channel, uint8_t channel_type);
+
+/**@brief Function for setting up wakeup buttons before going into sleep mode.
+ *
+ * @retval NRF_SUCCESS If the buttons were prepared successfully. Otherwise, a propagated error
+ * code is returned.
+ */
+ret_code_t bsp_btn_ant_sleep_mode_prepare(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BSP_BTN_ANT_H__ */
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.c
new file mode 100644
index 0000000..65d7a4c
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.c
@@ -0,0 +1,254 @@
+/**
+ * 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.
+ *
+ */
+#include "bsp_btn_ble.h"
+#include "nrf_sdh_ble.h"
+#include "bsp.h"
+
+#define BTN_ID_WAKEUP 0 /**< ID of button used to wake up the application. */
+#define BTN_ID_SLEEP 0 /**< ID of button used to put the application into sleep mode. */
+#define BTN_ID_DISCONNECT 0 /**< ID of button used to gracefully terminate a connection on long press. */
+#define BTN_ID_WAKEUP_BOND_DELETE 1 /**< ID of button used to wake up the application and delete all bonding information. */
+#define BTN_ID_WHITELIST_OFF 1 /**< ID of button used to turn off usage of the whitelist. */
+
+#define BTN_ACTION_SLEEP BSP_BUTTON_ACTION_RELEASE /**< Button action used to put the application into sleep mode. */
+#define BTN_ACTION_DISCONNECT BSP_BUTTON_ACTION_LONG_PUSH /**< Button action used to gracefully terminate a connection on long press. */
+#define BTN_ACTION_WHITELIST_OFF BSP_BUTTON_ACTION_LONG_PUSH /**< Button action used to turn off usage of the whitelist. */
+
+/**@brief This macro will return from the current function if err_code
+ * is not NRF_SUCCESS or NRF_ERROR_INVALID_PARAM.
+ */
+#define RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code) \
+do \
+{ \
+ if (((err_code) != NRF_SUCCESS) && ((err_code) != NRF_ERROR_INVALID_PARAM)) \
+ { \
+ return err_code; \
+ } \
+} \
+while (0)
+
+
+/**@brief This macro will return from the current function if err_code
+ * is not NRF_SUCCESS or NRF_ERROR_NOT_SUPPORTED.
+ */
+#define RETURN_ON_ERROR_NOT_NOT_SUPPORTED(err_code) \
+do \
+{ \
+ if (((err_code) != NRF_SUCCESS) && ((err_code) != NRF_ERROR_NOT_SUPPORTED)) \
+ { \
+ return err_code; \
+ } \
+} \
+while (0)
+
+
+/**@brief This macro will call the registered error handler if err_code
+ * is not NRF_SUCCESS and the error handler is not NULL.
+ */
+#define CALL_HANDLER_ON_ERROR(err_code) \
+do \
+{ \
+ if (((err_code) != NRF_SUCCESS) && (m_error_handler != NULL)) \
+ { \
+ m_error_handler(err_code); \
+ } \
+} \
+while (0)
+
+
+static bsp_btn_ble_error_handler_t m_error_handler = NULL; /**< Error handler registered by the user. */
+static uint32_t m_num_connections = 0; /**< Number of connections the device is currently in. */
+
+
+/**@brief Function for configuring the buttons for connection.
+ *
+ * @retval NRF_SUCCESS Configured successfully.
+ * @return A propagated error code.
+ */
+static uint32_t connection_buttons_configure()
+{
+ uint32_t err_code;
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
+ BTN_ACTION_SLEEP,
+ BSP_EVENT_DEFAULT);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
+ BTN_ACTION_WHITELIST_OFF,
+ BSP_EVENT_WHITELIST_OFF);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
+ BTN_ACTION_DISCONNECT,
+ BSP_EVENT_DISCONNECT);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+ return NRF_SUCCESS;
+}
+
+
+/**@brief Function for configuring the buttons for advertisement.
+ *
+ * @retval NRF_SUCCESS Configured successfully.
+ * @return A propagated error code.
+ */
+static uint32_t advertising_buttons_configure()
+{
+ uint32_t err_code;
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
+ BTN_ACTION_DISCONNECT,
+ BSP_EVENT_DEFAULT);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
+ BTN_ACTION_WHITELIST_OFF,
+ BSP_EVENT_WHITELIST_OFF);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+ err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
+ BTN_ACTION_SLEEP,
+ BSP_EVENT_SLEEP);
+ RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
+
+ return NRF_SUCCESS;
+}
+
+
+/**@brief Function for extracting the BSP event valid at startup.
+ *
+ * @details When a button was used to wake up the device, the button press will not generate an
+ * interrupt. This function reads which button was pressed at startup, and returns the
+ * appropriate BSP event.
+ *
+ * @param[out] p_startup_event Where to put the extracted BSP event.
+ */
+static void startup_event_extract(bsp_event_t * p_startup_event)
+{
+ // React to button states
+ if (bsp_button_is_pressed(BTN_ID_WAKEUP_BOND_DELETE))
+ {
+ *p_startup_event = BSP_EVENT_CLEAR_BONDING_DATA;
+ }
+ else if (bsp_button_is_pressed(BTN_ID_WAKEUP))
+ {
+ *p_startup_event = BSP_EVENT_WAKEUP;
+ }
+ else
+ {
+ *p_startup_event = BSP_EVENT_NOTHING;
+ }
+}
+
+
+uint32_t bsp_btn_ble_sleep_mode_prepare(void)
+{
+ uint32_t err_code;
+
+ err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP);
+ RETURN_ON_ERROR_NOT_NOT_SUPPORTED(err_code);
+
+ err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP_BOND_DELETE);
+ RETURN_ON_ERROR_NOT_NOT_SUPPORTED(err_code);
+
+ return NRF_SUCCESS;
+}
+
+
+/**
+ * @brief Function for handling BLE events.
+ *
+ * @param[in] p_ble_evt Event received from the BLE stack.
+ * @param[in] p_context Context.
+ */
+static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
+{
+ uint32_t err_code;
+
+ switch (p_ble_evt->header.evt_id)
+ {
+ case BLE_GAP_EVT_CONNECTED:
+ if (m_num_connections == 0)
+ {
+ err_code = connection_buttons_configure();
+ CALL_HANDLER_ON_ERROR(err_code);
+ }
+
+ m_num_connections++;
+ break;
+
+ case BLE_GAP_EVT_DISCONNECTED:
+ m_num_connections--;
+
+ if (m_num_connections == 0)
+ {
+ err_code = advertising_buttons_configure();
+ CALL_HANDLER_ON_ERROR(err_code);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+NRF_SDH_BLE_OBSERVER(m_ble_observer, BSP_BTN_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
+
+
+uint32_t bsp_btn_ble_init(bsp_btn_ble_error_handler_t error_handler, bsp_event_t * p_startup_bsp_evt)
+{
+ uint32_t err_code = NRF_SUCCESS;
+
+ m_error_handler = error_handler;
+
+ if (p_startup_bsp_evt != NULL)
+ {
+ startup_event_extract(p_startup_bsp_evt);
+ }
+
+ if (m_num_connections == 0)
+ {
+ err_code = advertising_buttons_configure();
+ }
+
+ return err_code;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.h
new file mode 100644
index 0000000..5184b61
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_btn_ble.h
@@ -0,0 +1,100 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp_btn_ble BSP: BLE Button Module
+ * @{
+ * @ingroup bsp
+ *
+ * @brief Module for controlling BLE behavior through button actions.
+ *
+ * @details The application must propagate BLE events to the BLE Button Module.
+ * Based on these events, the BLE Button Module configures the Board Support Package
+ * to generate BSP events for certain button actions. These BSP events should then be
+ * handled by the application's BSP event handler.
+ *
+ */
+
+#ifndef BSP_BTN_BLE_H__
+#define BSP_BTN_BLE_H__
+
+#include <stdint.h>
+#include "ble.h"
+#include "bsp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief BLE Button Module error handler type. */
+typedef void (*bsp_btn_ble_error_handler_t) (uint32_t nrf_error);
+
+/**@brief Function for initializing the BLE Button Module.
+ *
+ * Before calling this function, the BSP module must be initialized with buttons.
+ *
+ * @param[out] error_handler Error handler to call in case of internal errors in BLE Button
+ * Module.
+ * @param[out] p_startup_bsp_evt If not a NULL pointer, the value is filled with an event
+ * (or BSP_EVENT_NOTHING) derived from the buttons pressed on
+ * startup. For example, if the bond delete wakeup button was pressed
+ * to wake up the device, *p_startup_bsp_evt is set to
+ * @ref BSP_EVENT_CLEAR_BONDING_DATA.
+ *
+ * @retval NRF_SUCCESS If initialization was successful. Otherwise, a propagated error code is
+ * returned.
+ */
+uint32_t bsp_btn_ble_init(bsp_btn_ble_error_handler_t error_handler, bsp_event_t * p_startup_bsp_evt);
+
+/**@brief Function for setting up wakeup buttons before going into sleep mode.
+ *
+ * @retval NRF_SUCCESS If the buttons were prepared successfully. Otherwise, a propagated error
+ * code is returned.
+ */
+uint32_t bsp_btn_ble_sleep_mode_prepare(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BSP_BTN_BLE_H__ */
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.c
new file mode 100644
index 0000000..2389d84
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.c
@@ -0,0 +1,77 @@
+/**
+ * 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 "bsp_cli.h"
+
+static bsp_event_callback_t m_bsp_cli_callback = NULL;
+
+static void cmd_btn(nrf_cli_t const * p_cli, size_t argc, char **argv)
+{
+ uint32_t id;
+ ASSERT(m_bsp_cli_callback != NULL);
+
+ sscanf(argv[1], "%"SCNu32, &id);
+ bsp_event_t ev = (bsp_event_t)(BSP_EVENT_KEY_0 + id);
+ m_bsp_cli_callback(ev);
+}
+
+static void cmd_evt(nrf_cli_t const * p_cli, size_t argc, char **argv)
+{
+ uint32_t id;
+ ASSERT(m_bsp_cli_callback != NULL);
+
+ sscanf(argv[1], "%"SCNu32, &id);
+ bsp_event_t ev = (bsp_event_t)id;
+ m_bsp_cli_callback(ev);
+}
+
+ret_code_t bsp_cli_init(bsp_event_callback_t callback)
+{
+ m_bsp_cli_callback = callback;
+
+ return NRF_SUCCESS;
+}
+
+NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_bsp)
+{
+ NRF_CLI_CMD(btn, NULL, "BSP button event key", cmd_btn),
+ NRF_CLI_CMD(evt, NULL, "BSP event id", cmd_evt),
+ NRF_CLI_SUBCMD_SET_END
+};
+NRF_CLI_CMD_REGISTER(bsp, &m_sub_bsp, "bsp", NULL);
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.h
new file mode 100644
index 0000000..8c71d6a
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_cli.h
@@ -0,0 +1,83 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp_cli BSP over CLI Module
+ * @{
+ * @ingroup bsp
+ *
+ * @brief Module for sending BSP events over CLI.
+ *
+ * @details The module uses Command Line Interface and enables user to send events
+ * to BSP. They are later handled by the event handler provided.
+ * Available commands:
+ * - bsp btn X (where X is button number) - sends BSP_EVENT_KEY_X
+ * - bsp evt X (where X is event number) - sends BSP event with X id
+ */
+
+#ifndef BSP_CLI_H__
+#define BSP_CLI_H__
+
+#include <stdint.h>
+#include "nrf_cli.h"
+#include "bsp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Function for initializing the BSP over CLI Module.
+ *
+ * Before calling this function, the BSP module must be initialized.
+ *
+ * @param[in] callback Function to be called when event is recevied.
+ *
+ * @retval NRF_SUCCESS If initialization was successful.
+ */
+
+ret_code_t bsp_cli_init(bsp_event_callback_t callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BSP_CLI_H__ */
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_config.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_config.h
new file mode 100644
index 0000000..343a0fe
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_config.h
@@ -0,0 +1,135 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp Board Support Package
+ * @{
+ * @ingroup app_common
+ *
+ * @brief BSP module.
+ * @details This module provides a layer of abstraction from the board.
+ * It allows the user to indicate certain states on LEDs in a simple way.
+ * Module functionality can be modified by additional defines:
+ * - BSP_SIMPLE - reduces functionality of this module to enable
+ * and read state of the buttons.
+ * - BSP_UART_SUPPORT - enables support for UART.
+ */
+
+#ifndef BSP_CONFIG_H__
+#define BSP_CONFIG_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "boards.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(BSP_DEFINES_ONLY) && !defined(BSP_SIMPLE)
+#include "app_button.h"
+
+#define BSP_BUTTON_ACTION_PUSH (APP_BUTTON_PUSH) /**< Represents pushing a button. See @ref bsp_button_action_t. */
+#define BSP_BUTTON_ACTION_RELEASE (APP_BUTTON_RELEASE) /**< Represents releasing a button. See @ref bsp_button_action_t. */
+#define BSP_BUTTON_ACTION_LONG_PUSH (2) /**< Represents pushing and holding a button for @ref BSP_LONG_PUSH_TIMEOUT_MS milliseconds. See also @ref bsp_button_action_t. */
+#endif
+
+#define BSP_MS_TO_TICK(MS) (m_app_ticks_per_100ms * (MS / 100))
+
+
+#define BUTTON_ERASE_BONDING BSP_BUTTON_0_MASK
+#define BUTTON_ERASE_ALL BSP_BUTTON_1_MASK
+#define BUTTON_ADVERTISE BSP_BUTTON_0_MASK
+#define BUTTON_CLEAR_EVT BSP_BUTTON_1_MASK
+#define BUTTON_CAPSLOCK BSP_BUTTON_2_MASK
+#define BSP_BUTTONS_ALL 0xFFFFFFFF
+#define BSP_BUTTONS_NONE 0
+
+#define BSP_LONG_PUSH_TIMEOUT_MS (1000) /**< The time to hold for a long push (in milliseconds). */
+/**@brief Types of BSP initialization.
+ */
+
+#define ADVERTISING_LED_ON_INTERVAL 200
+#define ADVERTISING_LED_OFF_INTERVAL 1800
+
+#define ADVERTISING_DIRECTED_LED_ON_INTERVAL 200
+#define ADVERTISING_DIRECTED_LED_OFF_INTERVAL 200
+
+#define ADVERTISING_WHITELIST_LED_ON_INTERVAL 200
+#define ADVERTISING_WHITELIST_LED_OFF_INTERVAL 800
+
+#define ADVERTISING_SLOW_LED_ON_INTERVAL 400
+#define ADVERTISING_SLOW_LED_OFF_INTERVAL 4000
+
+#define BONDING_INTERVAL 100
+
+#define SENT_OK_INTERVAL 100
+#define SEND_ERROR_INTERVAL 500
+
+#define RCV_OK_INTERVAL 100
+#define RCV_ERROR_INTERVAL 500
+
+#define ALERT_INTERVAL 200
+
+#define BSP_LED_INDICATE_SENT_OK BSP_BOARD_LED_1
+#define BSP_LED_INDICATE_SEND_ERROR BSP_BOARD_LED_1
+#define BSP_LED_INDICATE_RCV_OK BSP_BOARD_LED_1
+#define BSP_LED_INDICATE_RCV_ERROR BSP_BOARD_LED_1
+#define BSP_LED_INDICATE_CONNECTED BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_BONDING BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_ADVERTISING_DIRECTED BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_ADVERTISING_SLOW BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_ADVERTISING_WHITELIST BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_INDICATE_ADVERTISING BSP_BOARD_LED_0
+
+#define BSP_LED_INDICATE_USER_LED1 BSP_BOARD_LED_0
+#define BSP_LED_INDICATE_USER_LED2 BSP_BOARD_LED_1
+#define BSP_LED_INDICATE_USER_LED3 BSP_BOARD_LED_2
+#define BSP_LED_INDICATE_USER_LED4 BSP_BOARD_LED_3
+
+#define BSP_LED_ALERT BSP_BOARD_LED_2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // BSP_CONFIG_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.c
new file mode 100644
index 0000000..50cc01c
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.c
@@ -0,0 +1,84 @@
+/**
+ * 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 "bsp_nfc.h"
+#include "bsp.h"
+#include "nrf.h"
+#include "app_util_platform.h"
+
+#ifndef BSP_SIMPLE
+#define BTN_ACTION_SLEEP BSP_BUTTON_ACTION_RELEASE /**< Button action used to put the application into sleep mode. */
+
+ret_code_t bsp_nfc_btn_init(uint32_t sleep_button)
+{
+ uint32_t err_code = bsp_event_to_button_action_assign(sleep_button,
+ BTN_ACTION_SLEEP,
+ BSP_EVENT_SLEEP);
+ return err_code;
+}
+
+ret_code_t bsp_nfc_btn_deinit(uint32_t sleep_button)
+{
+ uint32_t err_code = bsp_event_to_button_action_assign(sleep_button,
+ BTN_ACTION_SLEEP,
+ BSP_EVENT_DEFAULT);
+ return err_code;
+}
+
+ret_code_t bsp_nfc_sleep_mode_prepare(void)
+{
+#if defined(NFCT_PRESENT)
+ // Check if peripheral is not used.
+ CRITICAL_REGION_ENTER();
+#ifdef NRF52832_XXAA
+ if ((*(uint32_t *)0x40005410 & 0x07) == 0)
+#else
+ if ((NRF_NFCT->NFCTAGSTATE & NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk)
+ == NFCT_NFCTAGSTATE_NFCTAGSTATE_Disabled)
+#endif // NRF52832_XXAA
+ {
+ NRF_NFCT->TASKS_SENSE = 1;
+ }
+ CRITICAL_REGION_EXIT();
+ return NRF_SUCCESS;
+#else
+ return NRF_ERROR_NOT_SUPPORTED;
+#endif
+}
+#endif //BSP_SIMPLE
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.h
new file mode 100644
index 0000000..90a8cc9
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/libraries/bsp/bsp_nfc.h
@@ -0,0 +1,107 @@
+/**
+ * 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.
+ *
+ */
+/**@file
+ *
+ * @defgroup bsp_nfc NFC BSP Module
+ * @{
+ * @ingroup bsp
+ *
+ * @brief Module for setting the NFCT peripheral as a wakeup source.
+ *
+ * @details The application must notify this module before going into System OFF mode.
+ * Based on this notification, the NFC BSP Module sets the NFCT peripheral as a wakeup source
+ * through the Board Support Package. Additionally, any BSP Button can be configured to
+ * generate BSP sleep events. This module is applicable only if NFCT is used exclusively for
+ * wakeup. If NFCT is used for a different purpose, this module cannot be used.
+ */
+
+#ifndef BSP_NFC_H__
+#define BSP_NFC_H__
+
+#include <stdint.h>
+#include "sdk_errors.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Function for initializing the NFC Button Module.
+ *
+ * Before calling this function, the BSP module must be initialized with buttons. The chosen
+ * button is used to generate @ref BSP_EVENT_SLEEP events.
+ *
+ * @param[in] sleep_button Button ID used to generate @ref BSP_EVENT_SLEEP event.
+ *
+ * @retval NRF_SUCCESS If initialization was successful. Otherwise, a propagated error
+ * code is returned.
+ */
+ret_code_t bsp_nfc_btn_init(uint32_t sleep_button);
+
+/**@brief Function for deinitializing the NFC Button Module.
+ *
+ * Before calling this function, the BSP module must be initialized with buttons. The chosen
+ * button is used to generate default @ref BSP_EVENT_DEFAULT events.
+ *
+ * @param[in] sleep_button Button ID used to restore default event generation.
+ *
+ * @retval NRF_SUCCESS If initialization was successful. Otherwise, a propagated error
+ * code is returned.
+ */
+ret_code_t bsp_nfc_btn_deinit(uint32_t sleep_button);
+
+/**@brief Function for setting up NFCT peripheral as wake-up source.
+ *
+ * This function must be called before going into System OFF mode.
+ *
+ * @note This function is only applicable if NFCT is used exclusively for wakeup.
+ * If NFCT is used for a different purpose, this function cannot be used.
+ *
+ * @retval NRF_SUCCESS If NFCT peripheral was prepared successfully. Otherwise,
+ * a propagated error code is returned.
+ */
+ret_code_t bsp_nfc_sleep_mode_prepare(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BSP_NFC_H__ */
+
+/** @} */