Theo Havercroft / nrf51-sdk

Fork of nrf51-sdk by Lancaster University

Committer:
TheoHavercroft
Date:
Thu Dec 15 16:19:22 2016 +0000
Revision:
9:28787cb6ab0d
Parent:
0:bc2961fa1ef0
First Efects pedal commit
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan Austin 0:bc2961fa1ef0 1 /*
Jonathan Austin 0:bc2961fa1ef0 2 * Copyright (c) Nordic Semiconductor ASA
Jonathan Austin 0:bc2961fa1ef0 3 * All rights reserved.
Jonathan Austin 0:bc2961fa1ef0 4 *
Jonathan Austin 0:bc2961fa1ef0 5 * Redistribution and use in source and binary forms, with or without modification,
Jonathan Austin 0:bc2961fa1ef0 6 * are permitted provided that the following conditions are met:
Jonathan Austin 0:bc2961fa1ef0 7 *
Jonathan Austin 0:bc2961fa1ef0 8 * 1. Redistributions of source code must retain the above copyright notice, this
Jonathan Austin 0:bc2961fa1ef0 9 * list of conditions and the following disclaimer.
Jonathan Austin 0:bc2961fa1ef0 10 *
Jonathan Austin 0:bc2961fa1ef0 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Jonathan Austin 0:bc2961fa1ef0 12 * list of conditions and the following disclaimer in the documentation and/or
Jonathan Austin 0:bc2961fa1ef0 13 * other materials provided with the distribution.
Jonathan Austin 0:bc2961fa1ef0 14 *
Jonathan Austin 0:bc2961fa1ef0 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Jonathan Austin 0:bc2961fa1ef0 16 * contributors to this software may be used to endorse or promote products
Jonathan Austin 0:bc2961fa1ef0 17 * derived from this software without specific prior written permission.
Jonathan Austin 0:bc2961fa1ef0 18 *
Jonathan Austin 0:bc2961fa1ef0 19 *
Jonathan Austin 0:bc2961fa1ef0 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Jonathan Austin 0:bc2961fa1ef0 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Jonathan Austin 0:bc2961fa1ef0 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jonathan Austin 0:bc2961fa1ef0 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Jonathan Austin 0:bc2961fa1ef0 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Jonathan Austin 0:bc2961fa1ef0 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Jonathan Austin 0:bc2961fa1ef0 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Jonathan Austin 0:bc2961fa1ef0 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Jonathan Austin 0:bc2961fa1ef0 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Jonathan Austin 0:bc2961fa1ef0 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jonathan Austin 0:bc2961fa1ef0 30 *
Jonathan Austin 0:bc2961fa1ef0 31 */
Jonathan Austin 0:bc2961fa1ef0 32
Jonathan Austin 0:bc2961fa1ef0 33 /**@file
Jonathan Austin 0:bc2961fa1ef0 34 *
Jonathan Austin 0:bc2961fa1ef0 35 * @defgroup nrf_bootloader Bootloader API.
Jonathan Austin 0:bc2961fa1ef0 36 * @{
Jonathan Austin 0:bc2961fa1ef0 37 *
Jonathan Austin 0:bc2961fa1ef0 38 * @brief Bootloader module interface.
Jonathan Austin 0:bc2961fa1ef0 39 */
Jonathan Austin 0:bc2961fa1ef0 40
Jonathan Austin 0:bc2961fa1ef0 41 #ifndef BOOTLOADER_H__
Jonathan Austin 0:bc2961fa1ef0 42 #define BOOTLOADER_H__
Jonathan Austin 0:bc2961fa1ef0 43
Jonathan Austin 0:bc2961fa1ef0 44 #include <stdbool.h>
Jonathan Austin 0:bc2961fa1ef0 45 #include <stdint.h>
Jonathan Austin 0:bc2961fa1ef0 46 #include "bootloader_types.h"
Jonathan Austin 0:bc2961fa1ef0 47 #include <dfu_types.h>
Jonathan Austin 0:bc2961fa1ef0 48
Jonathan Austin 0:bc2961fa1ef0 49 /**@brief Function for initializing the Bootloader.
Jonathan Austin 0:bc2961fa1ef0 50 *
Jonathan Austin 0:bc2961fa1ef0 51 * @retval NRF_SUCCESS If bootloader was succesfully initialized.
Jonathan Austin 0:bc2961fa1ef0 52 */
Jonathan Austin 0:bc2961fa1ef0 53 uint32_t bootloader_init(void);
Jonathan Austin 0:bc2961fa1ef0 54
Jonathan Austin 0:bc2961fa1ef0 55 /**@brief Function for validating application region in flash.
Jonathan Austin 0:bc2961fa1ef0 56 *
Jonathan Austin 0:bc2961fa1ef0 57 * @param[in] app_addr Address to the region in flash where the application is stored.
Jonathan Austin 0:bc2961fa1ef0 58 *
Jonathan Austin 0:bc2961fa1ef0 59 * @retval true If Application region is valid.
Jonathan Austin 0:bc2961fa1ef0 60 * @retval false If Application region is not valid.
Jonathan Austin 0:bc2961fa1ef0 61 */
Jonathan Austin 0:bc2961fa1ef0 62 bool bootloader_app_is_valid(uint32_t app_addr);
Jonathan Austin 0:bc2961fa1ef0 63
Jonathan Austin 0:bc2961fa1ef0 64 /**@brief Function for starting the Device Firmware Update.
Jonathan Austin 0:bc2961fa1ef0 65 *
Jonathan Austin 0:bc2961fa1ef0 66 * @retval NRF_SUCCESS If new application image was successfully transferred.
Jonathan Austin 0:bc2961fa1ef0 67 */
Jonathan Austin 0:bc2961fa1ef0 68 uint32_t bootloader_dfu_start(void);
Jonathan Austin 0:bc2961fa1ef0 69
Jonathan Austin 0:bc2961fa1ef0 70 /**@brief Function for exiting bootloader and booting into application.
Jonathan Austin 0:bc2961fa1ef0 71 *
Jonathan Austin 0:bc2961fa1ef0 72 * @details This function will disable SoftDevice and all interrupts before jumping to application.
Jonathan Austin 0:bc2961fa1ef0 73 * The SoftDevice vector table base for interrupt forwarding will be set the application
Jonathan Austin 0:bc2961fa1ef0 74 * address.
Jonathan Austin 0:bc2961fa1ef0 75 *
Jonathan Austin 0:bc2961fa1ef0 76 * @param[in] app_addr Address to the region where the application is stored.
Jonathan Austin 0:bc2961fa1ef0 77 */
Jonathan Austin 0:bc2961fa1ef0 78 void bootloader_app_start(uint32_t app_addr);
Jonathan Austin 0:bc2961fa1ef0 79
Jonathan Austin 0:bc2961fa1ef0 80 /**@brief Function for retrieving the bootloader settings.
Jonathan Austin 0:bc2961fa1ef0 81 *
Jonathan Austin 0:bc2961fa1ef0 82 * @param[out] p_settings A copy of the current bootloader settings is returned in the structure
Jonathan Austin 0:bc2961fa1ef0 83 * provided.
Jonathan Austin 0:bc2961fa1ef0 84 */
Jonathan Austin 0:bc2961fa1ef0 85 void bootloader_settings_get(bootloader_settings_t * const p_settings);
Jonathan Austin 0:bc2961fa1ef0 86
Jonathan Austin 0:bc2961fa1ef0 87 /**@brief Function for processing DFU status update.
Jonathan Austin 0:bc2961fa1ef0 88 *
Jonathan Austin 0:bc2961fa1ef0 89 * @param[in] update_status DFU update status.
Jonathan Austin 0:bc2961fa1ef0 90 */
Jonathan Austin 0:bc2961fa1ef0 91 void bootloader_dfu_update_process(dfu_update_status_t update_status);
Jonathan Austin 0:bc2961fa1ef0 92
Jonathan Austin 0:bc2961fa1ef0 93 /**@brief Function getting state of SoftDevice update in progress.
Jonathan Austin 0:bc2961fa1ef0 94 * After a successfull SoftDevice transfer the system restarts in orderto disable SoftDevice
Jonathan Austin 0:bc2961fa1ef0 95 * and complete the update.
Jonathan Austin 0:bc2961fa1ef0 96 *
Jonathan Austin 0:bc2961fa1ef0 97 * @retval true A SoftDevice update is in progress. This indicates that second stage
Jonathan Austin 0:bc2961fa1ef0 98 * of a SoftDevice update procedure can be initiated.
Jonathan Austin 0:bc2961fa1ef0 99 * @retval false No SoftDevice update is in progress.
Jonathan Austin 0:bc2961fa1ef0 100 */
Jonathan Austin 0:bc2961fa1ef0 101 bool bootloader_dfu_sd_in_progress(void);
Jonathan Austin 0:bc2961fa1ef0 102
Jonathan Austin 0:bc2961fa1ef0 103 /**@brief Function for continuing the Device Firmware Update of a SoftDevice.
Jonathan Austin 0:bc2961fa1ef0 104 *
Jonathan Austin 0:bc2961fa1ef0 105 * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful.
Jonathan Austin 0:bc2961fa1ef0 106 */
Jonathan Austin 0:bc2961fa1ef0 107 uint32_t bootloader_dfu_sd_update_continue(void);
Jonathan Austin 0:bc2961fa1ef0 108
Jonathan Austin 0:bc2961fa1ef0 109 /**@brief Function for finalizing the Device Firmware Update of a SoftDevice.
Jonathan Austin 0:bc2961fa1ef0 110 *
Jonathan Austin 0:bc2961fa1ef0 111 * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful.
Jonathan Austin 0:bc2961fa1ef0 112 */
Jonathan Austin 0:bc2961fa1ef0 113 uint32_t bootloader_dfu_sd_update_finalize(void);
Jonathan Austin 0:bc2961fa1ef0 114
Jonathan Austin 0:bc2961fa1ef0 115 #endif // BOOTLOADER_H__
Jonathan Austin 0:bc2961fa1ef0 116
Jonathan Austin 0:bc2961fa1ef0 117 /**@} */