You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/07/27 23:13:32 UTC

[03/51] [partial] incubator-mynewt-core git commit: add stm32 and nordic sdks based on new structure

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/power_system_off.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/power_system_off.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/power_system_off.c
new file mode 100644
index 0000000..674f8e7
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/power_system_off.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+#include "nrf_soc_app.h"
+#include "ble_serialization.h"
+#include "nrf_soc.h"
+
+
+uint32_t power_system_off_req_enc(uint8_t * const p_buf, uint32_t * const p_buf_len)
+{
+    uint32_t index = 0;
+
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_buf_len);
+
+    SER_ASSERT_LENGTH_LEQ(1, *p_buf_len);
+
+    p_buf[index++] = SD_POWER_SYSTEM_OFF;
+
+    *p_buf_len = index;
+
+    return NRF_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/temp_get.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/temp_get.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/temp_get.c
new file mode 100644
index 0000000..7c5dbe6
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/serializers/temp_get.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+#include "nrf_soc.h"
+#include "nrf_error.h"
+#include "ble_serialization.h"
+#include "cond_field_serialization.h"
+
+uint32_t temp_get_req_enc(int32_t const * const p_temp,
+                          uint8_t * const       p_buf,
+                          uint32_t * const      p_buf_len)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_buf_len);
+
+    uint32_t index    = 0;
+    uint32_t err_code = NRF_SUCCESS;
+
+    uint32_t total_len = *p_buf_len;
+
+    SER_ASSERT_LENGTH_LEQ(1, total_len);
+    p_buf[index++] = SD_TEMP_GET;
+
+    err_code = cond_field_enc(p_temp, p_buf, total_len, &index, NULL);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    *p_buf_len = index;
+
+    return err_code;
+}
+
+uint32_t temp_get_rsp_dec(uint8_t const * const p_buf,
+                          uint32_t              packet_len,
+                          uint32_t * const      p_result_code,
+                          int32_t * const       p_temp)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_result_code);
+    SER_ASSERT_NOT_NULL(p_temp);
+
+    uint32_t index    = 0;
+    uint32_t err_code = NRF_SUCCESS;
+
+    err_code = ser_ble_cmd_rsp_result_code_dec(p_buf,
+                                               &index,
+                                               packet_len,
+                                               SD_TEMP_GET,
+                                               p_result_code);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    if (*p_result_code != NRF_SUCCESS)
+    {
+        return NRF_SUCCESS;
+    }
+
+    err_code = uint32_t_dec(p_buf, packet_len, &index, p_temp);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    SER_ASSERT_LENGTH_EQ(index, packet_len);
+
+    return err_code;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/arm_startup_nrf51.s
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/arm_startup_nrf51.s b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/arm_startup_nrf51.s
new file mode 100644
index 0000000..441b96b
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/arm_startup_nrf51.s
@@ -0,0 +1,240 @@
+; Copyright (c) 2013, 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:
+; 
+; * Redistributions of source code must retain the above copyright notice, this
+;   list of conditions and the following disclaimer.
+; 
+; * Redistributions in binary form must reproduce the above copyright notice,
+;   this list of conditions and the following disclaimer in the documentation
+;   and/or other materials provided with the distribution.
+; 
+; * 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.
+; 
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
+; NOTE: Template files (including this one) are application specific and therefore 
+; expected to be copied into the application project folder prior to its use!
+
+; Description message
+
+Stack_Size      EQU     2048
+                AREA    STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem       SPACE   Stack_Size
+__initial_sp
+
+Heap_Size       EQU     2048
+
+                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem        SPACE   Heap_Size
+__heap_limit
+
+                PRESERVE8
+                THUMB
+
+; Vector Table Mapped to Address 0 at Reset
+
+                AREA    RESET, DATA, READONLY
+                EXPORT  __Vectors
+                EXPORT  __Vectors_End
+                EXPORT  __Vectors_Size
+
+__Vectors       DCD     __initial_sp              ; Top of Stack
+                DCD     Reset_Handler             ; Reset Handler
+                DCD     NMI_Handler               ; NMI Handler
+                DCD     HardFault_Handler         ; Hard Fault Handler
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     SVC_Handler               ; SVCall Handler
+                DCD     0                         ; Reserved
+                DCD     0                         ; Reserved
+                DCD     PendSV_Handler            ; PendSV Handler
+                DCD     SysTick_Handler           ; SysTick Handler
+
+                ; External Interrupts
+                DCD      POWER_CLOCK_IRQHandler ;POWER_CLOCK
+                DCD      RADIO_IRQHandler ;RADIO
+                DCD      UART0_IRQHandler ;UART0
+                DCD      SPI0_TWI0_IRQHandler ;SPI0_TWI0
+                DCD      SPI1_TWI1_IRQHandler ;SPI1_TWI1
+                DCD      0 ;Reserved
+                DCD      GPIOTE_IRQHandler ;GPIOTE
+                DCD      ADC_IRQHandler ;ADC
+                DCD      TIMER0_IRQHandler ;TIMER0
+                DCD      TIMER1_IRQHandler ;TIMER1
+                DCD      TIMER2_IRQHandler ;TIMER2
+                DCD      RTC0_IRQHandler ;RTC0
+                DCD      TEMP_IRQHandler ;TEMP
+                DCD      RNG_IRQHandler ;RNG
+                DCD      ECB_IRQHandler ;ECB
+                DCD      CCM_AAR_IRQHandler ;CCM_AAR
+                DCD      WDT_IRQHandler ;WDT
+                DCD      RTC1_IRQHandler ;RTC1
+                DCD      QDEC_IRQHandler ;QDEC
+                DCD      LPCOMP_IRQHandler ;LPCOMP
+                DCD      SWI0_IRQHandler ;SWI0
+                DCD      SWI1_IRQHandler ;SWI1
+                DCD      SWI2_IRQHandler ;SWI2
+                DCD      SWI3_IRQHandler ;SWI3
+                DCD      SWI4_IRQHandler ;SWI4
+                DCD      SWI5_IRQHandler ;SWI5
+                DCD      0 ;Reserved
+                DCD      0 ;Reserved
+                DCD      0 ;Reserved
+                DCD      0 ;Reserved
+                DCD      0 ;Reserved
+                DCD      0 ;Reserved
+
+
+__Vectors_End
+
+__Vectors_Size  EQU     __Vectors_End - __Vectors
+
+                AREA    |.text|, CODE, READONLY
+
+; Reset Handler
+
+NRF_POWER_RAMON_ADDRESS           EQU   0x40000524  ; NRF_POWER->RAMON address
+NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU   0x3         ; All RAM blocks on in onmode bit mask
+
+Reset_Handler   PROC
+                EXPORT  Reset_Handler             [WEAK]
+                IMPORT  SystemInit
+                IMPORT  __main
+                LDR     R0, =NRF_POWER_RAMON_ADDRESS
+                LDR     R2, [R0]
+                MOVS    R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
+                ORRS    R2, R2, R1
+                STR     R2, [R0]
+                LDR     R0, =SystemInit
+                BLX     R0
+                LDR     R0, =__main
+                BX      R0
+                ENDP
+
+; Dummy Exception Handlers (infinite loops which can be modified)
+
+NMI_Handler     PROC
+                EXPORT  NMI_Handler               [WEAK]
+                B       .
+                ENDP
+HardFault_Handler\
+                PROC
+                EXPORT  HardFault_Handler         [WEAK]
+                B       .
+                ENDP
+SVC_Handler     PROC
+                EXPORT  SVC_Handler               [WEAK]
+                B       .
+                ENDP
+PendSV_Handler  PROC
+                EXPORT  PendSV_Handler            [WEAK]
+                B       .
+                ENDP
+SysTick_Handler PROC
+                EXPORT  SysTick_Handler           [WEAK]
+                B       .
+                ENDP
+
+Default_Handler PROC
+
+                EXPORT   POWER_CLOCK_IRQHandler [WEAK]
+                EXPORT   RADIO_IRQHandler [WEAK]
+                EXPORT   UART0_IRQHandler [WEAK]
+                EXPORT   SPI0_TWI0_IRQHandler [WEAK]
+                EXPORT   SPI1_TWI1_IRQHandler [WEAK]
+                EXPORT   GPIOTE_IRQHandler [WEAK]
+                EXPORT   ADC_IRQHandler [WEAK]
+                EXPORT   TIMER0_IRQHandler [WEAK]
+                EXPORT   TIMER1_IRQHandler [WEAK]
+                EXPORT   TIMER2_IRQHandler [WEAK]
+                EXPORT   RTC0_IRQHandler [WEAK]
+                EXPORT   TEMP_IRQHandler [WEAK]
+                EXPORT   RNG_IRQHandler [WEAK]
+                EXPORT   ECB_IRQHandler [WEAK]
+                EXPORT   CCM_AAR_IRQHandler [WEAK]
+                EXPORT   WDT_IRQHandler [WEAK]
+                EXPORT   RTC1_IRQHandler [WEAK]
+                EXPORT   QDEC_IRQHandler [WEAK]
+                EXPORT   LPCOMP_IRQHandler [WEAK]
+                EXPORT   SWI0_IRQHandler [WEAK]
+                EXPORT   SWI1_IRQHandler [WEAK]
+                EXPORT   SWI2_IRQHandler [WEAK]
+                EXPORT   SWI3_IRQHandler [WEAK]
+                EXPORT   SWI4_IRQHandler [WEAK]
+                EXPORT   SWI5_IRQHandler [WEAK]
+POWER_CLOCK_IRQHandler
+RADIO_IRQHandler
+UART0_IRQHandler
+SPI0_TWI0_IRQHandler
+SPI1_TWI1_IRQHandler
+GPIOTE_IRQHandler
+ADC_IRQHandler
+TIMER0_IRQHandler
+TIMER1_IRQHandler
+TIMER2_IRQHandler
+RTC0_IRQHandler
+TEMP_IRQHandler
+RNG_IRQHandler
+ECB_IRQHandler
+CCM_AAR_IRQHandler
+WDT_IRQHandler
+RTC1_IRQHandler
+QDEC_IRQHandler
+LPCOMP_IRQHandler
+SWI0_IRQHandler
+SWI1_IRQHandler
+SWI2_IRQHandler
+SWI3_IRQHandler
+SWI4_IRQHandler
+SWI5_IRQHandler
+
+                B .
+                ENDP
+                ALIGN
+
+; User Initial Stack & Heap
+
+                IF      :DEF:__MICROLIB
+                
+                EXPORT  __initial_sp
+                EXPORT  __heap_base
+                EXPORT  __heap_limit
+
+                ELSE
+
+                IMPORT  __use_two_region_memory
+                EXPORT  __user_initial_stackheap
+__user_initial_stackheap
+
+                LDR     R0, = Heap_Mem
+                LDR     R1, = (Stack_Mem + Stack_Size)
+                LDR     R2, = (Heap_Mem + Heap_Size)
+                LDR     R3, = Stack_Mem
+                BX      LR
+
+                ALIGN
+
+                ENDIF
+
+                END
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal.h
new file mode 100644
index 0000000..358a2a2
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal.h
@@ -0,0 +1,80 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**@file
+ *
+ * @defgroup ser_app_hal Serialization Application Hardware Abstraction Layer
+ * @{
+ * @ingroup ble_sdk_lib_serialization
+ *
+ * @brief Functions which set up hardware on Application board and perform the reset of the Connectivity Board.
+ */
+
+#ifndef SER_APP_HAL_H_
+#define SER_APP_HAL_H_
+
+#include <stdint.h>
+
+typedef void (*ser_app_hal_flash_op_done_handler_t)(bool success);
+/**@brief Function for initializing hw modules.
+ *
+ * @details Function can initilize can hardware modules on application processor. It is optional to
+ * implement. It is called one connectivity chip is initialized.
+ *
+ * @param handler Flash operation event handler
+ *
+ * @return @ref NRF_SUCCESS HAL initialized successfully.
+ * @return @ref nrf_error "NRF_ERROR_..." HAL initialization failed.
+ *
+ */
+uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler);
+
+/**@brief Function for waiting for given amount of time.
+ *
+ * @param[in] ms Number of milliseconds to wait.
+ *
+ */
+void ser_app_hal_delay(uint32_t ms);
+
+/**@brief Function for clearing connectivity chip reset pin
+ *
+ */
+void ser_app_hal_nrf_reset_pin_clear(void);
+
+/**@brief Function for setting connectivity chip reset pin
+ *
+ */
+void ser_app_hal_nrf_reset_pin_set(void);
+
+
+/**@brief Function for setting softdevice event interrupt priority which is serving events incoming
+ * from connectivity chip.
+ *
+ * @note Serialization solution on application side mimics SoC solution where events are handled in
+ * the interrupt context in two ways: or directly in the interrupt context or message is posted to
+ * the scheduler. However, it is possible that application processor is not using dedicated interrupt
+ * for connectivity events. In that case this function can be left empty and
+ * \ref ser_app_hal_nrf_evt_pending will directly call an interrupt handler function.
+ */
+void ser_app_hal_nrf_evt_irq_priority_set(void);
+
+/**@brief Function for setting pending interrupt for serving events incoming from connectivity chip.
+ *
+ * @note The interrupt used for event from connectivity chip mimics behavior of SoC and it is not
+ * intended to be triggered by any hardware event. This function should be the only source of
+ * interrupt triggering.
+ */
+void ser_app_hal_nrf_evt_pending(void);
+
+
+#endif /* SER_APP_HAL_H_ */
+/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal_nrf51.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal_nrf51.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal_nrf51.c
new file mode 100644
index 0000000..507adf8
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_hal_nrf51.c
@@ -0,0 +1,139 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include "app_util_platform.h"
+#include "ser_app_hal.h"
+#include "nrf.h"
+#include "nrf_gpio.h"
+#include "nrf_soc.h"
+#include "nrf_delay.h"
+#include "nrf_nvmc.h"
+#include "boards.h"
+#include "ser_phy.h"
+#include "ser_phy_config_app_nrf51.h"
+
+#ifdef NRF51
+#define SOFTDEVICE_EVT_IRQ      SD_EVT_IRQn         /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
+#define FLASH_WRITE_MAX_LENGTH  256
+#elif defined NRF52
+#define SOFTDEVICE_EVT_IRQ      SWI2_EGU2_IRQn
+#define FLASH_WRITE_MAX_LENGTH  1024
+#endif /* NRF51 */
+
+#define BLE_FLASH_PAGE_SIZE     ((uint16_t)NRF_FICR->CODEPAGESIZE)  /**< Size of one flash page. */
+
+static ser_app_hal_flash_op_done_handler_t m_flash_op_handler;
+uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler)
+{
+    nrf_gpio_cfg_output(CONN_CHIP_RESET_PIN_NO);
+
+    NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
+    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
+    NRF_CLOCK->TASKS_LFCLKSTART    = 1;
+
+    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
+    {
+        //No implementation needed.
+    }
+
+    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
+    m_flash_op_handler = handler;
+    return NRF_SUCCESS;
+}
+
+void ser_app_hal_delay(uint32_t ms)
+{
+    nrf_delay_ms(ms);
+}
+
+void ser_app_hal_nrf_reset_pin_clear()
+{
+    nrf_gpio_pin_clear(CONN_CHIP_RESET_PIN_NO);
+}
+
+void ser_app_hal_nrf_reset_pin_set()
+{
+    nrf_gpio_pin_set(CONN_CHIP_RESET_PIN_NO);
+}
+
+void ser_app_hal_nrf_evt_irq_priority_set()
+{
+    NVIC_SetPriority(SOFTDEVICE_EVT_IRQ, APP_IRQ_PRIORITY_LOW);
+}
+
+void ser_app_hal_nrf_evt_pending()
+{
+    NVIC_SetPendingIRQ(SOFTDEVICE_EVT_IRQ);
+}
+
+uint32_t sd_ppi_channel_enable_get(uint32_t * p_channel_enable)
+{
+    *p_channel_enable = NRF_PPI->CHEN;
+    return NRF_SUCCESS;
+}
+
+uint32_t sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)
+{
+    NRF_PPI->CHEN = channel_enable_set_msk;
+    return NRF_SUCCESS;
+}
+
+uint32_t sd_ppi_channel_assign(uint8_t               channel_num,
+                               const volatile void * evt_endpoint,
+                               const volatile void * task_endpoint)
+{
+    NRF_PPI->CH[channel_num].TEP = (uint32_t)task_endpoint;
+    NRF_PPI->CH[channel_num].EEP = (uint32_t)evt_endpoint;
+    return NRF_SUCCESS;
+}
+/**
+ * @brief Check if given address is in device FLASH range.
+ *
+ * @param[in] ptr Address to check.
+ * @retval true  Given address is located in FLASH.
+ * @retval false Given address is not located in FLASH.
+ */
+__STATIC_INLINE bool addr_is_in_FLASH(void const * const ptr)
+{
+    return ((((uintptr_t)ptr) & 0xFF000000u) == 0x00000000u);
+}
+
+uint32_t sd_flash_page_erase(uint32_t page_number)
+{
+    uint32_t * p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_number);
+
+    if (!addr_is_in_FLASH(p_page))
+    {
+        return NRF_ERROR_INVALID_ADDR;
+    }
+
+    nrf_nvmc_page_erase((uint32_t) p_page);
+    m_flash_op_handler(true);
+    return NRF_SUCCESS;
+}
+
+uint32_t sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size)
+{
+    if (size > FLASH_WRITE_MAX_LENGTH)
+    {
+        return NRF_ERROR_INVALID_LENGTH;
+    }
+
+    if (!addr_is_in_FLASH(p_dst))
+    {
+        return NRF_ERROR_INVALID_ADDR;
+    }
+
+    nrf_nvmc_write_words((uint32_t) p_dst, p_src, size);
+    m_flash_op_handler(true);
+    return NRF_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.c
new file mode 100644
index 0000000..8ae84a5
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.c
@@ -0,0 +1,35 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include "nrf.h"
+#include "ser_app_power_system_off.h"
+
+static bool m_power_system_off = false;
+
+ 
+void ser_app_power_system_off_set(void)
+{
+    m_power_system_off = true;
+}
+
+bool ser_app_power_system_off_get(void)
+{
+    return m_power_system_off;
+}
+
+void ser_app_power_system_off_enter(void)
+{
+    NRF_POWER->SYSTEMOFF = POWER_SYSTEMOFF_SYSTEMOFF_Enter;
+
+    /*Only for debugging purpose, will not be reached without connected debugger*/
+    while(1);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.h
new file mode 100644
index 0000000..490b72d
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/hal/ser_app_power_system_off.h
@@ -0,0 +1,24 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#ifndef APP_POWER_SYSTEM_OFF_H
+#define APP_POWER_SYSTEM_OFF_H
+
+#include <stdbool.h>
+
+void ser_app_power_system_off_set(void);
+
+bool ser_app_power_system_off_get(void);
+
+void ser_app_power_system_off_enter(void);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.c
new file mode 100644
index 0000000..59f2906
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.c
@@ -0,0 +1,259 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+#include "ser_sd_transport.h"
+#include "ser_hal_transport.h"
+#include "nrf_error.h"
+#include "app_error.h"
+#include "ble_serialization.h"
+
+#include "ser_app_power_system_off.h"
+
+#include "app_util.h"
+
+#ifdef ENABLE_DEBUG_LOG_SUPPORT
+#include "app_trace.h"
+#define APPL_LOG                        app_trace_log             /**< Debug logger macro that will be used in this file to do logging of debug information over UART. */
+#else
+#define APPL_LOG(...)
+#endif //ENABLE_DEBUG_LOG_SUPPORT
+
+/** SoftDevice event handler. */
+static ser_sd_transport_evt_handler_t m_evt_handler = NULL;
+
+/** 'One time' handler called in task context while waiting for response to scheduled command. */
+static ser_sd_transport_rsp_wait_handler_t m_ot_rsp_wait_handler = NULL;
+
+/** Handler called in task context while waiting for response to scheduled command. */
+static ser_sd_transport_rsp_wait_handler_t m_os_rsp_wait_handler = NULL;
+
+/** Handler called in serial peripheral interrupt context when response is received. */
+static ser_sd_transport_rsp_set_handler_t m_os_rsp_set_handler = NULL;
+
+/** Handler called when hal_transport notifies that packet reception has started. */
+static ser_sd_transport_rx_notification_handler_t m_rx_notify_handler = NULL;
+
+/** User decoder handler for expected response packet. */
+static ser_sd_transport_rsp_handler_t m_rsp_dec_handler = NULL;
+
+/** Flag indicated whether module is waiting for response packet. */
+static volatile bool m_rsp_wait = false;
+
+/** SoftDevice call return value decoded by user decoder handler. */
+static uint32_t m_return_value;
+
+/**@brief Function for handling the rx packets comming from hal_transport.
+ *
+ * @details
+ *  This function is called in serial peripheral interrupt context. Response packets are handled in
+ *  this context. Events are passed to the application and it is up to application in which context
+ *  they are handled.
+ *
+ * @param[in]   p_data   Pointer to received data.
+ * @param[in]   length   Size of data.
+ */
+static void ser_sd_transport_rx_packet_handler(uint8_t * p_data, uint16_t length)
+{
+    if (p_data && (length >= SER_PKT_TYPE_SIZE))
+    {
+        const uint8_t packet_type = p_data[SER_PKT_TYPE_POS];
+        p_data += SER_PKT_TYPE_SIZE;
+        length -= SER_PKT_TYPE_SIZE;
+
+        switch (packet_type)
+        {
+            case SER_PKT_TYPE_RESP:
+            case SER_PKT_TYPE_DTM_RESP:
+
+                if (m_rsp_wait)
+                {
+                    m_return_value = m_rsp_dec_handler(p_data, length);
+                    (void)ser_sd_transport_rx_free(p_data);
+
+                    /* Reset response flag - cmd_write function is pending on it.*/
+                    m_rsp_wait = false;
+
+                    /* If os handler is set, signal os that response has arrived.*/
+                    if (m_os_rsp_set_handler)
+                    {
+                        m_os_rsp_set_handler();
+                    }
+                }
+                else
+                {
+                    /* Unexpected packet. */
+                    (void)ser_sd_transport_rx_free(p_data);
+                    APP_ERROR_HANDLER(packet_type);
+                }
+                break;
+
+            case SER_PKT_TYPE_EVT:
+                /* It is ensured during opening that handler is not NULL. No check needed. */
+                APPL_LOG("\r\n[EVT_ID]: 0x%X \r\n", uint16_decode(&p_data[SER_EVT_ID_POS])); // p_data points to EVT_ID
+                m_evt_handler(p_data, length);
+                break;
+
+            default:
+                (void)ser_sd_transport_rx_free(p_data);
+                APP_ERROR_HANDLER(packet_type);
+                break;
+        }
+    }
+}
+
+/**@brief Function for handling the event from hal_transport.
+ *
+ * @param[in]   event   Event from hal_transport.
+ */
+static void ser_sd_transport_hal_handler(ser_hal_transport_evt_t event)
+{
+    switch (event.evt_type)
+    {
+    case SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED:
+        ser_sd_transport_rx_packet_handler(event.evt_params.rx_pkt_received.p_buffer,
+                                           event.evt_params.rx_pkt_received.num_of_bytes);
+        break;
+    case SER_HAL_TRANSP_EVT_RX_PKT_RECEIVING:
+        if (m_rx_notify_handler)
+        {
+            m_rx_notify_handler();
+        }
+        break;
+    case SER_HAL_TRANSP_EVT_TX_PKT_SENT:
+        if(ser_app_power_system_off_get() == true)
+        {
+            ser_app_power_system_off_enter();
+        }
+        break;
+    case SER_HAL_TRANSP_EVT_PHY_ERROR:
+
+        if (m_rsp_wait)
+        {
+            m_return_value = NRF_ERROR_INTERNAL;
+
+            /* Reset response flag - cmd_write function is pending on it.*/
+            m_rsp_wait = false;
+
+            /* If os handler is set, signal os that response has arrived.*/
+            if (m_os_rsp_set_handler)
+            {
+                m_os_rsp_set_handler();
+            }
+        }
+        break;
+    default:
+        break;
+    }
+}
+
+uint32_t ser_sd_transport_open(ser_sd_transport_evt_handler_t             evt_handler,
+                               ser_sd_transport_rsp_wait_handler_t        os_rsp_wait_handler,
+                               ser_sd_transport_rsp_set_handler_t         os_rsp_set_handler,
+                               ser_sd_transport_rx_notification_handler_t rx_notify_handler)
+{
+    m_os_rsp_wait_handler = os_rsp_wait_handler;
+    m_os_rsp_set_handler  = os_rsp_set_handler;
+    m_rx_notify_handler   = rx_notify_handler;
+    m_ot_rsp_wait_handler = NULL;
+    m_evt_handler         = evt_handler;
+
+    if (evt_handler == NULL)
+    {
+        return NRF_ERROR_INVALID_PARAM;
+    }
+
+    return ser_hal_transport_open(ser_sd_transport_hal_handler);
+}
+
+uint32_t ser_sd_transport_close(void)
+{
+    m_evt_handler         = NULL;
+    m_os_rsp_wait_handler = NULL;
+    m_os_rsp_set_handler  = NULL;
+    m_ot_rsp_wait_handler = NULL;
+
+    ser_hal_transport_close();
+
+    return NRF_SUCCESS;
+}
+
+uint32_t ser_sd_transport_ot_rsp_wait_handler_set(ser_sd_transport_rsp_wait_handler_t handler)
+{
+    m_ot_rsp_wait_handler = handler;
+
+    return NRF_SUCCESS;
+}
+
+bool ser_sd_transport_is_busy(void)
+{
+    return m_rsp_wait;
+}
+
+uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len)
+{
+    uint32_t err_code;
+
+    if (m_rsp_wait)
+    {
+        err_code = NRF_ERROR_BUSY;
+    }
+    else
+    {
+        err_code = ser_hal_transport_tx_pkt_alloc(pp_data, p_len);
+    }
+    return err_code;
+}
+
+uint32_t ser_sd_transport_tx_free(uint8_t * p_data)
+{
+    return ser_hal_transport_tx_pkt_free(p_data);
+}
+
+uint32_t ser_sd_transport_rx_free(uint8_t * p_data)
+{
+    p_data -= SER_PKT_TYPE_SIZE;
+    return ser_hal_transport_rx_pkt_free(p_data);
+}
+
+uint32_t ser_sd_transport_cmd_write(const uint8_t *                p_buffer,
+                                    uint16_t                       length,
+                                    ser_sd_transport_rsp_handler_t cmd_rsp_decode_callback)
+{
+    uint32_t err_code = NRF_SUCCESS;
+
+    m_rsp_wait        = true;
+    m_rsp_dec_handler = cmd_rsp_decode_callback;
+    err_code          = ser_hal_transport_tx_pkt_send(p_buffer, length);
+    APP_ERROR_CHECK(err_code);
+
+    /* Execute callback for response decoding only if one was provided.*/
+    if ((err_code == NRF_SUCCESS) && cmd_rsp_decode_callback)
+    {
+        if (m_ot_rsp_wait_handler)
+        {
+            m_ot_rsp_wait_handler();
+            m_ot_rsp_wait_handler = NULL;
+        }
+
+        m_os_rsp_wait_handler();
+        err_code = m_return_value;
+    }
+    else
+    {
+        m_rsp_wait = false;
+    }
+    APPL_LOG("\r\n[SD_CALL_ID]: 0x%X, err_code= 0x%X\r\n", p_buffer[1], err_code);
+    return err_code;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.h
new file mode 100644
index 0000000..92a28d4
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_sd_transport.h
@@ -0,0 +1,153 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**
+ * @addtogroup ser_app Application side code
+ * @ingroup ble_sdk_lib_serialization
+ */
+
+/** @file
+ *
+ * @defgroup ser_sd_transport Serialization SoftDevice Transport
+ * @{
+ * @ingroup ser_app
+ *
+ * @brief   Serialization SoftDevice Transport on application side.
+ *
+ * @details This file contains declarations of functions and definitions of data structures and
+ *          identifiers (typedef enum) used as API of the serialization of SoftDevice. This layer
+ *          ensures atomic nature of SoftDevice calls (command and waiting for response). Packet
+ *          type field of incoming packets is handled in this layer - responses are handled by
+ *          ser_sd_transport (using response decoder handler provided for each SoftDevice call) but
+ *          events are forwarded to the user so it is user's responsibility to free RX buffer.
+ *
+ */
+#ifndef SER_SD_TRANSPORT_H_
+#define SER_SD_TRANSPORT_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef void (*ser_sd_transport_evt_handler_t)(uint8_t * p_buffer, uint16_t length);
+typedef void (*ser_sd_transport_rsp_wait_handler_t)(void);
+typedef void (*ser_sd_transport_rsp_set_handler_t)(void);
+typedef void (*ser_sd_transport_rx_notification_handler_t)(void);
+
+typedef uint32_t (*ser_sd_transport_rsp_handler_t)(const uint8_t * p_buffer, uint16_t length);
+
+/**@brief Function for opening the module.
+ *
+ * @note 'Wait for response' and 'Response set' callbacks can be set in RTOS environment.
+ *       It enables rescheduling while waiting for connectivity chip response. In nonOS environment
+ *       usually 'Wait for response' will only be used for handling incoming events or force
+ *       application to low power mode.
+ *
+ * @param[in] evt_handler               Handler to be called when event packet is received.
+ * @param[in] os_rsp_wait_handler       Handler to be called after request is send. It should.
+ *                                      implement 'Wait for signal' functionality in OS environment.
+ * @param[in] os_rsp_set_handler        Handler to be called after response reception. It should
+ *                                      implement 'Signal Set' functionality in OS environment
+ * @param[in] rx_not_handler            Handler to be called after transport layer notifies that
+ *                                      there is incoming rx packet detected.
+ *
+ * @retval NRF_SUCCESS              Operation success.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.
+ * @retval NRF_ERROR_INVALID_PARAM  Operation failure. Parameter propagated from ser_hal_transport
+ *                                  opening or timer creation.
+ * @retval NRF_ERROR_INVALID_STATE  Operation failure. Parameter propagated from ser_hal_transport
+ *                                  opening or timer creation.
+ * @retval NRF_ERROR_INTERNAL       Operation failure.  Parameter propagated from ser_hal_transport
+ *                                  opening or timer creation.
+ * @retval NRF_ERROR_NO_MEM         Operation failure.  Parameter propagated from timer creation.
+ */
+uint32_t ser_sd_transport_open(ser_sd_transport_evt_handler_t             evt_handler,
+                               ser_sd_transport_rsp_wait_handler_t        os_rsp_wait_handler,
+                               ser_sd_transport_rsp_set_handler_t         os_rsp_set_handler,
+                               ser_sd_transport_rx_notification_handler_t rx_not_handler);
+
+/**@brief Function setting 'One Time' handler to be called between sending next request packet and
+ *        receiving response packet.
+ * @note It is intended to be used in nonOS environment to implement concurrency.
+ * @note It is 'One Time' handler meaning that it is valid only for next softdevice call processing.
+ *
+ *
+ * @param[in] wait_handler       Handler to be called after request packet is sent.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_ot_rsp_wait_handler_set(ser_sd_transport_rsp_wait_handler_t wait_handler);
+
+
+/**@brief Function for closing the module.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_close(void);
+
+/**@brief Function for allocating tx packet to be used for request command.
+ *
+ * @param[out] pp_data       Pointer to data pointer to be set to point to allocated buffer.
+ * @param[out] p_len         Pointer to allocated buffer length.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len);
+
+
+/**@brief Function for freeing tx packet.
+ *
+ * @note Function should be called once command is processed.
+ *
+ * @param[out] p_data       Pointer to allocated tx buffer.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_tx_free(uint8_t * p_data);
+
+
+/**@brief Function for freeing RX event packet.
+ *
+ * @note Function should be called once SoftDevice event buffer is processed.
+ *
+ * @param[out] p_data       Pointer to allocated rx buffer.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_rx_free(uint8_t * p_data);
+
+
+/**@brief Function for checking if module is busy waiting for response from connectivity side.
+ *
+ * @retval true      Module busy. Cannot accept next command.
+ * @retval false     Module not busy. Can accept next command.
+ */
+bool ser_sd_transport_is_busy(void);
+
+/**@brief Function for handling SoftDevice command.
+ *
+ * @note Function blocks task context until response is received and processed.
+ * @note Non-blocking functionality can be achieved using os handlers or 'One Time' handler
+ * @warning Function shouldn't be called from interrupt context which would block switching to
+ *          serial port interrupt.
+ *
+ * @param[in] p_buffer                 Pointer to command.
+ * @param[in] length                   Pointer to allocated buffer length.
+ * @param[in] cmd_resp_decode_callback Pointer to function for decoding response packet.
+ *
+ * @retval NRF_SUCCESS          Operation success.
+ */
+uint32_t ser_sd_transport_cmd_write(const uint8_t *                p_buffer,
+                                    uint16_t                       length,
+                                    ser_sd_transport_rsp_handler_t cmd_resp_decode_callback);
+
+#endif /* SER_SD_TRANSPORT_H_ */
+/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.c
new file mode 100644
index 0000000..80b1ef8
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.c
@@ -0,0 +1,200 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+#include "ble_app.h"
+#include "app_mailbox.h"
+#include "app_scheduler.h"
+#include "softdevice_handler.h"
+#include "ser_sd_transport.h"
+#include "ser_app_hal.h"
+#include "ser_config.h"
+#include "nrf_soc.h"
+
+
+#define SD_BLE_EVT_MAILBOX_QUEUE_SIZE 5 /**< Size of mailbox queue. */
+
+/** @brief Structure used to pass packet details through mailbox.
+ */
+typedef struct
+{
+    uint32_t evt_data[CEIL_DIV(BLE_STACK_EVT_MSG_BUF_SIZE, sizeof (uint32_t))]; /**< Buffer for decoded event */
+} ser_sd_handler_evt_data_t;
+
+/** @brief
+ *   Mailbox used for communication between event handler (called from serial stream
+ *   interrupt context) and event processing function (called from scheduler or interrupt context).
+ */
+APP_MAILBOX_DEF(sd_ble_evt_mailbox, SD_BLE_EVT_MAILBOX_QUEUE_SIZE, sizeof(ser_sd_handler_evt_data_t));
+
+APP_MAILBOX_DEF(sd_soc_evt_mailbox, SD_BLE_EVT_MAILBOX_QUEUE_SIZE, sizeof(uint32_t));
+
+/**
+ * @brief Function to be replaced by user implementation if needed.
+ *
+ * Weak function - user can add different implementation of this function if application needs it.
+ */
+__WEAK void os_rsp_set_handler(void)
+{
+
+}
+
+static void connectivity_reset_low(void)
+{
+    //Signal a reset to the nRF51822 by setting the reset pin on the nRF51822 low.
+    ser_app_hal_nrf_reset_pin_clear();
+    ser_app_hal_delay(CONN_CHIP_RESET_TIME);
+
+}
+
+static void connectivity_reset_high(void)
+{
+
+    //Set the reset level to high again.
+    ser_app_hal_nrf_reset_pin_set();
+
+    //Wait for nRF51822 to be ready.
+    ser_app_hal_delay(CONN_CHIP_WAKEUP_TIME);
+}
+
+static void ser_softdevice_evt_handler(uint8_t * p_data, uint16_t length)
+{
+    ser_sd_handler_evt_data_t item;
+    uint32_t                  err_code;
+    uint32_t                  len32 = sizeof (item.evt_data);
+
+    err_code = ble_event_dec(p_data, length, (ble_evt_t *)item.evt_data, &len32);
+    APP_ERROR_CHECK(err_code);
+
+    err_code = ser_sd_transport_rx_free(p_data);
+    APP_ERROR_CHECK(err_code);
+
+    err_code = app_mailbox_put(&sd_ble_evt_mailbox, &item);
+    APP_ERROR_CHECK(err_code);
+
+    ser_app_hal_nrf_evt_pending();
+}
+
+void ser_softdevice_flash_operation_success_evt(bool success)
+{
+	uint32_t evt_type = success ? NRF_EVT_FLASH_OPERATION_SUCCESS :
+			NRF_EVT_FLASH_OPERATION_ERROR;
+
+	uint32_t err_code = app_mailbox_put(&sd_soc_evt_mailbox, &evt_type);
+	APP_ERROR_CHECK(err_code);
+
+	ser_app_hal_nrf_evt_pending();
+}
+
+/**
+ * @brief Function called while waiting for connectivity chip response. It handles incoming events.
+ */
+static void ser_sd_rsp_wait(void)
+{
+    do
+    {
+        (void)sd_app_evt_wait();
+
+        //intern_softdevice_events_execute();
+    }
+    while (ser_sd_transport_is_busy());
+}
+
+uint32_t sd_evt_get(uint32_t * p_evt_id)
+{
+    uint32_t err_code;
+
+    err_code = app_mailbox_get(&sd_soc_evt_mailbox, p_evt_id);
+    if (err_code != NRF_SUCCESS) //if anything in the mailbox
+    {
+    	err_code = NRF_ERROR_NOT_FOUND;
+    }
+
+    return err_code;
+}
+
+uint32_t sd_ble_evt_get(uint8_t * p_data, uint16_t * p_len)
+{
+    uint32_t err_code;
+
+    err_code = app_mailbox_get(&sd_ble_evt_mailbox, p_data);
+
+    if (err_code == NRF_SUCCESS) //if anything in the mailbox
+    {
+        if (((ble_evt_t *)p_data)->header.evt_len > *p_len)
+        {
+            err_code = NRF_ERROR_DATA_SIZE;
+        }
+        else
+        {
+            *p_len = ((ble_evt_t *)p_data)->header.evt_len;
+        }
+    }
+    else
+    {
+        err_code = NRF_ERROR_NOT_FOUND;
+    }
+
+    return err_code;
+}
+
+uint32_t sd_ble_evt_mailbox_length_get(uint32_t * p_mailbox_length)
+{
+    uint32_t err_code = NRF_SUCCESS;
+    
+    *p_mailbox_length = app_mailbox_length_get(&sd_ble_evt_mailbox);
+    
+    return err_code;
+}
+
+uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg,
+                              nrf_fault_handler_t assertion_handler)
+{
+    uint32_t err_code;
+
+    err_code = ser_app_hal_hw_init(ser_softdevice_flash_operation_success_evt);
+
+    if (err_code == NRF_SUCCESS)
+    {
+        connectivity_reset_low();
+
+        err_code = app_mailbox_create(&sd_soc_evt_mailbox);
+        if (err_code != NRF_SUCCESS)
+        {
+        	return err_code;
+        }
+
+        err_code = app_mailbox_create(&sd_ble_evt_mailbox);
+        if (err_code == NRF_SUCCESS)
+        {
+            err_code = ser_sd_transport_open(ser_softdevice_evt_handler,
+                                             ser_sd_rsp_wait,
+                                             os_rsp_set_handler,
+                                             NULL);
+            if (err_code == NRF_SUCCESS)
+            {
+              connectivity_reset_high();
+            }
+        }
+
+        ser_app_hal_nrf_evt_irq_priority_set();
+    }
+
+    return err_code;
+}
+
+
+uint32_t sd_softdevice_disable(void)
+{
+    return ser_sd_transport_close();
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.h
new file mode 100644
index 0000000..f9ded53
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/transport/ser_softdevice_handler.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**
+ * @addtogroup ser_app Application side code
+ * @ingroup ble_sdk_lib_serialization
+ */
+
+/** @file
+ *
+ * @defgroup ser_softdevice_handler Serialization SoftDevice Handler
+ * @{
+ * @ingroup ser_app
+ *
+ * @brief   Serialization SoftDevice Handler on application side.
+ *
+ */
+#ifndef SER_SOFTDEVICE_HANDLER_H_
+#define SER_SOFTDEVICE_HANDLER_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+
+/**@brief Function for checking if there is any more events in the internal mailbox.
+ *
+ * @param[in] p_mailbox_length Pointer to mailbox length.
+ *
+ * @retval ::NRF_SUCCESS    Length succesfully obtained.
+ * @retval ::NRF_ERROR_NULL Null pointer provided.
+ */
+uint32_t sd_ble_evt_mailbox_length_get(uint32_t * p_mailbox_length);
+
+#endif /* SER_SOFTDEVICE_HANDLER_H_ */
+/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/ble_serialization.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/ble_serialization.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/ble_serialization.c
new file mode 100644
index 0000000..953dddc
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/common/ble_serialization.c
@@ -0,0 +1,520 @@
+/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+#include "ble_serialization.h"
+#include "nrf_error.h"
+#include "app_util.h"
+#include <stddef.h>
+#include <string.h>
+
+uint32_t ser_ble_cmd_rsp_status_code_enc(uint8_t          op_code,
+                                         uint32_t         command_status,
+                                         uint8_t * const  p_buf,
+                                         uint32_t * const p_buf_len)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_buf_len);
+    uint32_t index = 0;
+
+    SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buf_len);
+
+    //Encode Op Code.
+    p_buf[index++] = op_code;
+
+    //Encode Status.
+    index     += uint32_encode(command_status, &(p_buf[index]));
+    *p_buf_len = index;
+
+    return NRF_SUCCESS;
+}
+
+
+uint32_t ser_ble_cmd_rsp_result_code_dec(uint8_t const * const p_buf,
+                                         uint32_t * const      p_pos,
+                                         uint32_t              packet_len,
+                                         uint8_t               op_code,
+                                         uint32_t * const      p_result_code)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_pos);
+    SER_ASSERT_NOT_NULL(p_result_code);
+
+    if (packet_len < SER_CMD_RSP_HEADER_SIZE)
+    {
+        return NRF_ERROR_DATA_SIZE;
+    }
+
+    if (p_buf[(*p_pos)] != op_code)
+    {
+        return NRF_ERROR_INVALID_DATA;
+    }
+
+    *p_result_code = uint32_decode(&(p_buf[(*p_pos) + SER_CMD_RSP_STATUS_CODE_POS]));
+    *p_pos        += SER_CMD_RSP_HEADER_SIZE;
+
+    return NRF_SUCCESS;
+}
+
+
+uint32_t ser_ble_cmd_rsp_dec(uint8_t const * const p_buf,
+                             uint32_t              packet_len,
+                             uint8_t               op_code,
+                             uint32_t * const      p_result_code)
+{
+    uint32_t index       = 0;
+    uint32_t result_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, op_code,
+                                                           p_result_code);
+
+    if (result_code != NRF_SUCCESS)
+    {
+        return result_code;
+    }
+
+    if (index != packet_len)
+    {
+        return NRF_ERROR_DATA_SIZE;
+    }
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint32_t_enc(void const * const p_field,
+                      uint8_t * const    p_buf,
+                      uint32_t           buf_len,
+                      uint32_t * const   p_index)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_field);
+    SER_ASSERT_NOT_NULL(p_index);
+
+    uint32_t * p_uint32 = (uint32_t *)p_field;
+
+    SER_ASSERT_LENGTH_LEQ(4, buf_len - *p_index);
+
+    *p_index += uint32_encode(*p_uint32, &p_buf[*p_index]);
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint32_t_dec(uint8_t const * const p_buf,
+                      uint32_t              buf_len,
+                      uint32_t * const      p_index,
+                      void *                p_field)
+{
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_index);
+    SER_ASSERT_NOT_NULL(p_field);
+
+    uint32_t * p_uint32 = (uint32_t *)p_field;
+
+    SER_ASSERT_LENGTH_LEQ(4, ((int32_t)buf_len - *p_index));
+
+    *p_uint32 = uint32_decode(&p_buf[*p_index]);
+    *p_index += 4;
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint16_t_enc(const void * const p_field,
+                      uint8_t * const    p_buf,
+                      uint32_t           buf_len,
+                      uint32_t * const   p_index)
+{
+    uint16_t * p_u16 = (uint16_t *)p_field;
+
+    SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index);
+
+    *p_index += uint16_encode(*p_u16, &p_buf[*p_index]);
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint16_t_dec(uint8_t const * const p_buf,
+                      uint32_t              buf_len,
+                      uint32_t * const      p_index,
+                      void *                p_field)
+{
+    uint16_t * p_u16 = (uint16_t *)p_field;
+
+    SER_ASSERT_LENGTH_LEQ(2, ((int32_t)buf_len - *p_index));
+
+    *p_u16    = uint16_decode(&p_buf[*p_index]);
+    *p_index += 2;
+
+    return NRF_SUCCESS;
+}
+
+void uint16_dec(uint8_t const * const p_buf,
+                uint32_t              buf_len,
+                uint32_t * const      index,
+                uint16_t * const      value)
+{
+    SER_ASSERT_VOID_RETURN(*index + 2 <= buf_len);
+    *value  = uint16_decode(&p_buf[*index]);
+    *index += 2;
+}
+
+uint32_t uint8_t_enc(const void * const p_field,
+                     uint8_t * const    p_buf,
+                     uint32_t           buf_len,
+                     uint32_t * const   p_index)
+{
+    SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index);
+
+    uint8_t * p_u8 = (uint8_t *)p_field;
+    p_buf[*p_index] = *p_u8;
+    *p_index       += 1;
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint8_t_dec(uint8_t const * const p_buf,
+                     uint32_t              buf_len,
+                     uint32_t * const      p_index,
+                     void *                p_field)
+{
+    uint8_t * p_u8 = (uint8_t *)p_field;
+
+    SER_ASSERT_LENGTH_LEQ(1, ((int32_t)buf_len - *p_index));
+    *p_u8     = p_buf[*p_index];
+    *p_index += 1;
+
+    return NRF_SUCCESS;
+}
+
+void uint8_dec(uint8_t const * const p_buf,
+               uint32_t              buf_len,
+               uint32_t * const      index,
+               uint8_t * const       value)
+{
+    SER_ASSERT_VOID_RETURN(*index + 1 <= buf_len);
+    *value  = p_buf[*index];
+    *index += 1;
+}
+
+
+void int8_dec(uint8_t const * const p_buf,
+              uint32_t              buf_len,
+              uint32_t * const      index,
+              int8_t * const        value)
+{
+    SER_ASSERT_VOID_RETURN(*index + 1 <= buf_len);
+    *value  = p_buf[*index];
+    *index += 1;
+}
+
+uint32_t len8data_enc(uint8_t const * const p_data,
+                      uint8_t const         dlen,
+                      uint8_t * const       p_buf,
+                      uint32_t              buf_len,
+                      uint32_t * const      p_index)
+{
+    uint32_t err_code = NRF_SUCCESS;
+
+    err_code = uint8_t_enc(&dlen, p_buf, buf_len, p_index);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    err_code = buf_enc(p_data, dlen, p_buf, buf_len, p_index);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    return err_code;
+}
+
+uint32_t len8data_dec(uint8_t const * const p_buf,
+                      uint32_t              buf_len,
+                      uint32_t * const      p_index,
+                      uint8_t * * const     pp_data,
+                      uint8_t * const       p_len)
+{
+    uint32_t err_code    = NRF_SUCCESS;
+    uint16_t out_buf_len = *p_len;
+
+    err_code = uint8_t_dec(p_buf, buf_len, p_index, p_len);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    err_code = buf_dec(p_buf, buf_len, p_index, pp_data, out_buf_len, *p_len);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    return err_code;
+}
+
+uint32_t len16data_enc(uint8_t const * const p_data,
+                       uint16_t const        dlen,
+                       uint8_t * const       p_buf,
+                       uint32_t              buf_len,
+                       uint32_t * const      p_index)
+{
+    uint32_t err_code = NRF_SUCCESS;
+
+    err_code = uint16_t_enc(&dlen, p_buf, buf_len, p_index);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    err_code = buf_enc(p_data, dlen, p_buf, buf_len, p_index);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    return err_code;
+}
+
+uint32_t len16data_dec(uint8_t const * const p_buf,
+                       uint32_t              buf_len,
+                       uint32_t * const      p_index,
+                       uint8_t * * const     pp_data,
+                       uint16_t * const      p_dlen)
+{
+    uint32_t err_code    = NRF_SUCCESS;
+    uint16_t out_buf_len = *p_dlen;
+
+    err_code = uint16_t_dec(p_buf, buf_len, p_index, p_dlen);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    err_code = buf_dec(p_buf, buf_len, p_index, pp_data, out_buf_len, *p_dlen);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    return err_code;
+}
+
+uint32_t count16_cond_data16_enc(uint16_t const * const p_data,
+                                 uint16_t const         count,
+                                 uint8_t * const        p_buf,
+                                 uint32_t               buf_len,
+                                 uint32_t * const       p_index)
+{
+    uint32_t i = 0;
+
+    SER_ASSERT_LENGTH_LEQ(3, ((int32_t)buf_len - *p_index));
+    *p_index += uint16_encode(count, &p_buf[*p_index]);
+
+    if (p_data)
+    {
+        SER_ASSERT_LENGTH_LEQ((int32_t)(2 * count + 1), ((int32_t)buf_len - (int32_t)*p_index));
+        p_buf[*p_index] = SER_FIELD_PRESENT;
+        *p_index       += 1;
+
+        //memcpy may fail in case of Endianness difference between application and connectivity processor
+        for (i = 0; i < count; i++)
+        {
+            *p_index += uint16_encode(p_data[i], &p_buf[*p_index]);
+        }
+    }
+    else
+    {
+        SER_ASSERT_LENGTH_LEQ((1), ((int32_t)buf_len - *p_index));
+        p_buf[*p_index] = SER_FIELD_NOT_PRESENT;
+        *p_index       += 1;
+    }
+
+    return NRF_SUCCESS;
+}
+
+uint32_t count16_cond_data16_dec(uint8_t const * const p_buf,
+                                 uint32_t              buf_len,
+                                 uint32_t * const      p_index,
+                                 uint16_t * * const    pp_data,
+                                 uint16_t * const      p_count)
+
+{
+    uint16_t count      = 0;
+    uint8_t  is_present = 0;
+    uint16_t i;
+
+    SER_ASSERT_NOT_NULL(p_count);
+    SER_ASSERT_NOT_NULL(pp_data);
+    SER_ASSERT_NOT_NULL(*pp_data);
+
+    SER_ASSERT_LENGTH_LEQ(3, ((int32_t)buf_len - (*p_index)));
+
+    uint16_dec(p_buf, buf_len, p_index, &count);
+
+    if (count > *p_count)
+    {
+        return NRF_ERROR_DATA_SIZE;
+    }
+
+    SER_ASSERT_LENGTH_LEQ(count, *p_count);
+
+    uint8_dec(p_buf, buf_len, p_index, &is_present);
+
+    if (!is_present)
+    {
+        *pp_data = NULL;
+        return NRF_SUCCESS;
+    }
+    else
+    {
+        for (i = 0; i < count; i++ )
+        {
+            uint16_dec(p_buf, buf_len, p_index, &((&(**pp_data))[i]) );
+        }
+        *p_count = i;
+    }
+    return NRF_SUCCESS;
+}
+
+
+
+uint32_t cond_len16_cond_data_dec(uint8_t const * const p_buf,
+                                  uint32_t              buf_len,
+                                  uint32_t * const      p_index,
+                                  uint8_t * * const     pp_data,
+                                  uint16_t * * const    pp_len)
+{
+    SER_ASSERT_NOT_NULL(pp_len);
+    SER_ASSERT_NOT_NULL(*pp_len);
+    SER_ASSERT_NOT_NULL(pp_data);
+    SER_ASSERT_NOT_NULL(*pp_data);
+
+    SER_ASSERT_LENGTH_LEQ(2, ((int32_t)buf_len - (*p_index)));
+    uint8_t is_present = 0;
+
+    uint8_dec(p_buf, buf_len, p_index, &is_present);
+
+    if (!is_present)
+    {
+        *pp_len = NULL; //if length field is not present
+        (*p_index)++;   //then data can not be present
+        *pp_data = NULL;
+        return NRF_SUCCESS;
+    }
+    else
+    {
+        return len16data_dec(p_buf, buf_len, p_index, pp_data, *pp_len);
+    }
+}
+
+uint32_t op_status_enc(uint8_t          op_code,
+                       uint32_t         return_code,
+                       uint8_t * const  p_buff,
+                       uint32_t * const p_buff_len,
+                       uint32_t * const p_index)
+{
+    SER_ASSERT_NOT_NULL(p_buff);
+    SER_ASSERT_NOT_NULL(p_buff_len);
+    SER_ASSERT_NOT_NULL(p_index);
+    SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buff_len - *p_index);
+
+    //Encode Op Code.
+    p_buff[(*p_index)++] = op_code;
+    //Encode Status.
+    *p_index += uint32_encode(return_code, &(p_buff[*p_index]));
+    //update size of used buffer
+    *p_buff_len = *p_index;
+
+    return NRF_SUCCESS;
+}
+
+uint32_t op_status_cond_uint16_enc(uint8_t          op_code,
+                                   uint32_t         return_code,
+                                   uint16_t         value,
+                                   uint8_t * const  p_buff,
+                                   uint32_t * const p_buff_len,
+                                   uint32_t * const p_index)
+{
+    uint32_t status_code;
+    uint32_t init_buff_len = *p_buff_len;
+
+    status_code = op_status_enc(op_code, return_code, p_buff, p_buff_len, p_index);
+    SER_ASSERT(status_code == NRF_SUCCESS, status_code);
+
+    if (return_code == NRF_SUCCESS) //Add 16bit value when return_code is a success
+    {
+        *p_buff_len = init_buff_len; //restore original value - it has been modified by op_status_enc
+        status_code = uint16_t_enc(&value, p_buff, *p_buff_len, p_index);
+        *p_buff_len = *p_index;
+        SER_ASSERT(status_code == NRF_SUCCESS, status_code);
+    }
+
+    return status_code;
+}
+
+uint32_t buf_enc(uint8_t const * const p_data,
+                 uint16_t const        dlen,
+                 uint8_t * const       p_buf,
+                 uint32_t              buf_len,
+                 uint32_t * const      p_index)
+{
+    uint32_t err_code   = NRF_SUCCESS;
+    uint8_t  is_present = (p_data == NULL) ? SER_FIELD_NOT_PRESENT : SER_FIELD_PRESENT;
+
+    err_code = uint8_t_enc(&is_present, p_buf, buf_len, p_index);
+    SER_ASSERT(err_code == NRF_SUCCESS, err_code);
+
+    if (p_data)
+    {
+        SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index));
+        memcpy(&p_buf[*p_index], p_data, dlen);
+        *p_index += dlen;
+    }
+
+    return err_code;
+}
+
+uint32_t buf_dec(uint8_t const * const p_buf,
+                 uint32_t              buf_len,
+                 uint32_t * const      p_index,
+                 uint8_t * * const     pp_data,
+                 uint16_t              data_len,
+                 uint16_t              dlen)
+{
+    uint8_t is_present = 0;
+
+    SER_ASSERT_LENGTH_LEQ(1, ((int32_t)buf_len - *p_index));
+    uint8_dec(p_buf, buf_len, p_index, &is_present);
+
+    if (is_present == SER_FIELD_PRESENT)
+    {
+        SER_ASSERT_NOT_NULL(pp_data);
+        SER_ASSERT_NOT_NULL(*pp_data);
+        SER_ASSERT_LENGTH_LEQ(dlen, data_len);
+        SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index));
+        memcpy(*pp_data, &p_buf[*p_index], dlen);
+        *p_index += dlen;
+    }
+    else
+    {
+        if (pp_data)
+        {
+            *pp_data = NULL;
+        }
+    }
+    return NRF_SUCCESS;
+}
+
+uint32_t uint8_vector_enc(uint8_t const * const p_data,
+                        uint16_t const        dlen,
+                        uint8_t * const       p_buf,
+                        uint32_t              buf_len,
+                        uint32_t * const      p_index)
+{
+
+    SER_ASSERT_NOT_NULL(p_data);
+    SER_ASSERT_NOT_NULL(p_buf);
+    SER_ASSERT_NOT_NULL(p_index);
+    SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index));
+    memcpy(&p_buf[*p_index], p_data, dlen);
+    *p_index += dlen;
+
+    return NRF_SUCCESS;
+}
+
+uint32_t uint8_vector_dec(uint8_t const * const p_buf,
+                 uint32_t              buf_len,
+                 uint32_t * const      p_index,
+                 uint8_t *  const      p_data,
+                 uint16_t              dlen)
+{
+    SER_ASSERT_NOT_NULL(p_data);
+    SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index));
+    memcpy(p_data, &p_buf[*p_index], dlen);
+    *p_index += dlen;
+
+    return NRF_SUCCESS;
+}
+