Openwear requires RC oscillator to be used

Fork of nRF51822 by Nordic Semiconductor

Committer:
janekm
Date:
Thu Sep 04 21:18:28 2014 +0000
Revision:
62:4dfe75dd5769
Parent:
37:c29c330d942c
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit Grover 37:c29c330d942c 1 /*
Rohit Grover 37:c29c330d942c 2 * Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
Rohit Grover 37:c29c330d942c 3 *
Rohit Grover 37:c29c330d942c 4 * The information contained herein is confidential property of Nordic Semiconductor. The use,
Rohit Grover 37:c29c330d942c 5 * copying, transfer or disclosure of such information is prohibited except by express written
Rohit Grover 37:c29c330d942c 6 * agreement with Nordic Semiconductor.
Rohit Grover 37:c29c330d942c 7 *
Rohit Grover 37:c29c330d942c 8 */
Rohit Grover 37:c29c330d942c 9 /**
Rohit Grover 37:c29c330d942c 10 @defgroup nrf_mbr_api Master Boot Record API
Rohit Grover 37:c29c330d942c 11 @{
Rohit Grover 37:c29c330d942c 12
Rohit Grover 37:c29c330d942c 13 @brief APIs for updating SoftDevice and BootLoader
Rohit Grover 37:c29c330d942c 14
Rohit Grover 37:c29c330d942c 15 */
Rohit Grover 37:c29c330d942c 16
Rohit Grover 37:c29c330d942c 17 /* Header guard */
Rohit Grover 37:c29c330d942c 18 #ifndef NRF_MBR_H__
Rohit Grover 37:c29c330d942c 19 #define NRF_MBR_H__
Rohit Grover 37:c29c330d942c 20
Rohit Grover 37:c29c330d942c 21 #include "nrf_svc.h"
Rohit Grover 37:c29c330d942c 22 #include <stdint.h>
Rohit Grover 37:c29c330d942c 23
Rohit Grover 37:c29c330d942c 24
Rohit Grover 37:c29c330d942c 25 /** @addtogroup NRF_MBR_DEFINES Defines
Rohit Grover 37:c29c330d942c 26 * @{ */
Rohit Grover 37:c29c330d942c 27
Rohit Grover 37:c29c330d942c 28 /**@brief MBR SVC Base number. */
Rohit Grover 37:c29c330d942c 29 #define MBR_SVC_BASE 0x18
Rohit Grover 37:c29c330d942c 30 /** @} */
Rohit Grover 37:c29c330d942c 31
Rohit Grover 37:c29c330d942c 32 /** @addtogroup NRF_MBR_ENUMS Enumerations
Rohit Grover 37:c29c330d942c 33 * @{ */
Rohit Grover 37:c29c330d942c 34
Rohit Grover 37:c29c330d942c 35 /**@brief nRF Master Boot Record API SVC numbers. */
Rohit Grover 37:c29c330d942c 36 enum NRF_MBR_SVCS
Rohit Grover 37:c29c330d942c 37 {
Rohit Grover 37:c29c330d942c 38 SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
Rohit Grover 37:c29c330d942c 39 };
Rohit Grover 37:c29c330d942c 40
Rohit Grover 37:c29c330d942c 41 /**@brief Possible values for ::sd_mbr_command_t.command */
Rohit Grover 37:c29c330d942c 42 enum NRF_MBR_COMMANDS
Rohit Grover 37:c29c330d942c 43 {
Rohit Grover 37:c29c330d942c 44 SD_MBR_COMMAND_COPY_BL, /**< Copy a new a new BootLoader. @see sd_mbr_command_copy_bl_t */
Rohit Grover 37:c29c330d942c 45 SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
Rohit Grover 37:c29c330d942c 46 SD_MBR_COMMAND_INIT_SD, /**< Init forwarding interrupts to SD, and run reset function in SD*/
Rohit Grover 37:c29c330d942c 47 SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
Rohit Grover 37:c29c330d942c 48 SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
Rohit Grover 37:c29c330d942c 49 };
Rohit Grover 37:c29c330d942c 50
Rohit Grover 37:c29c330d942c 51 /** @} */
Rohit Grover 37:c29c330d942c 52
Rohit Grover 37:c29c330d942c 53 /** @addtogroup NRF_MBR_TYPES Types
Rohit Grover 37:c29c330d942c 54 * @{ */
Rohit Grover 37:c29c330d942c 55
Rohit Grover 37:c29c330d942c 56 /**@brief This command copies part of a new SoftDevice
Rohit Grover 37:c29c330d942c 57 * The destination area is erased before copying.
Rohit Grover 37:c29c330d942c 58 * If dst is in the middle of a flash page, that whole flash page will be erased.
Rohit Grover 37:c29c330d942c 59 * If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
Rohit Grover 37:c29c330d942c 60 *
Rohit Grover 37:c29c330d942c 61 * The user of this function is responsible for setting the PROTENSET registers.
Rohit Grover 37:c29c330d942c 62 *
Rohit Grover 37:c29c330d942c 63 * @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
Rohit Grover 37:c29c330d942c 64 * @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
Rohit Grover 37:c29c330d942c 65 */
Rohit Grover 37:c29c330d942c 66 typedef struct
Rohit Grover 37:c29c330d942c 67 {
Rohit Grover 37:c29c330d942c 68 uint32_t *src; /**< Pointer to the source of data to be copied.*/
Rohit Grover 37:c29c330d942c 69 uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
Rohit Grover 37:c29c330d942c 70 uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of 256 words*/
Rohit Grover 37:c29c330d942c 71 }sd_mbr_command_copy_sd_t;
Rohit Grover 37:c29c330d942c 72
Rohit Grover 37:c29c330d942c 73
Rohit Grover 37:c29c330d942c 74 /**@brief This command works like memcmp, but takes the length in words.
Rohit Grover 37:c29c330d942c 75 *
Rohit Grover 37:c29c330d942c 76 * @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
Rohit Grover 37:c29c330d942c 77 * @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
Rohit Grover 37:c29c330d942c 78 */
Rohit Grover 37:c29c330d942c 79 typedef struct
Rohit Grover 37:c29c330d942c 80 {
Rohit Grover 37:c29c330d942c 81 uint32_t *ptr1; /**< Pointer to block of memory */
Rohit Grover 37:c29c330d942c 82 uint32_t *ptr2; /**< Pointer to block of memory */
Rohit Grover 37:c29c330d942c 83 uint32_t len; /**< Number of 32 bit words to compare*/
Rohit Grover 37:c29c330d942c 84 }sd_mbr_command_compare_t;
Rohit Grover 37:c29c330d942c 85
Rohit Grover 37:c29c330d942c 86
Rohit Grover 37:c29c330d942c 87 /**@brief This command copies a new BootLoader.
Rohit Grover 37:c29c330d942c 88 * With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
Rohit Grover 37:c29c330d942c 89 *
Rohit Grover 37:c29c330d942c 90 * Destination is erased by this function.
Rohit Grover 37:c29c330d942c 91 * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
Rohit Grover 37:c29c330d942c 92 *
Rohit Grover 37:c29c330d942c 93 * This function will use PROTENSET to protect the flash that is not intended to be written.
Rohit Grover 37:c29c330d942c 94 *
Rohit Grover 37:c29c330d942c 95 * On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
Rohit Grover 37:c29c330d942c 96 *
Rohit Grover 37:c29c330d942c 97 * @retval ::NRF_ERROR_INVALID_STATE indicates that something was wrong.
Rohit Grover 37:c29c330d942c 98 * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
Rohit Grover 37:c29c330d942c 99 * @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set
Rohit Grover 37:c29c330d942c 100 * @retval ::NRF_ERROR_INVALID_LENGTH is invalid.
Rohit Grover 37:c29c330d942c 101 */
Rohit Grover 37:c29c330d942c 102 typedef struct
Rohit Grover 37:c29c330d942c 103 {
Rohit Grover 37:c29c330d942c 104 uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
Rohit Grover 37:c29c330d942c 105 uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader */
Rohit Grover 37:c29c330d942c 106 }sd_mbr_command_copy_bl_t;
Rohit Grover 37:c29c330d942c 107
Rohit Grover 37:c29c330d942c 108 /**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
Rohit Grover 37:c29c330d942c 109 *
Rohit Grover 37:c29c330d942c 110 * Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
Rohit Grover 37:c29c330d942c 111 *
Rohit Grover 37:c29c330d942c 112 * To restore default forwarding thiss function should be called with @param address set to 0.
Rohit Grover 37:c29c330d942c 113 * The MBR will then start forwarding to interrupts to the adress in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
Rohit Grover 37:c29c330d942c 114 *
Rohit Grover 37:c29c330d942c 115 * @retval ::NRF_SUCCESS
Rohit Grover 37:c29c330d942c 116 */
Rohit Grover 37:c29c330d942c 117 typedef struct
Rohit Grover 37:c29c330d942c 118 {
Rohit Grover 37:c29c330d942c 119 uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
Rohit Grover 37:c29c330d942c 120 }sd_mbr_command_vector_table_base_set_t;
Rohit Grover 37:c29c330d942c 121
Rohit Grover 37:c29c330d942c 122 typedef struct
Rohit Grover 37:c29c330d942c 123 {
Rohit Grover 37:c29c330d942c 124 uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
Rohit Grover 37:c29c330d942c 125 union
Rohit Grover 37:c29c330d942c 126 {
Rohit Grover 37:c29c330d942c 127 sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy*/
Rohit Grover 37:c29c330d942c 128 sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy SoftDevice and BootLoader*/
Rohit Grover 37:c29c330d942c 129 sd_mbr_command_compare_t compare; /**< Parameters for verify*/
Rohit Grover 37:c29c330d942c 130 sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set.*/
Rohit Grover 37:c29c330d942c 131 } params;
Rohit Grover 37:c29c330d942c 132 }sd_mbr_command_t;
Rohit Grover 37:c29c330d942c 133
Rohit Grover 37:c29c330d942c 134 /** @} */
Rohit Grover 37:c29c330d942c 135
Rohit Grover 37:c29c330d942c 136 /** @addtogroup NRF_MBR_FUNCTIONS Functions
Rohit Grover 37:c29c330d942c 137 * @{ */
Rohit Grover 37:c29c330d942c 138
Rohit Grover 37:c29c330d942c 139 /**@brief Issue Master Boot Record commands
Rohit Grover 37:c29c330d942c 140 *
Rohit Grover 37:c29c330d942c 141 * Commands used when updating a SoftDevice and bootloader
Rohit Grover 37:c29c330d942c 142 *
Rohit Grover 37:c29c330d942c 143 * @param[in] param Pointer to a struct describing the command
Rohit Grover 37:c29c330d942c 144 *
Rohit Grover 37:c29c330d942c 145 *@note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t
Rohit Grover 37:c29c330d942c 146
Rohit Grover 37:c29c330d942c 147 */
Rohit Grover 37:c29c330d942c 148 SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
Rohit Grover 37:c29c330d942c 149
Rohit Grover 37:c29c330d942c 150 /** @} */
Rohit Grover 37:c29c330d942c 151 #endif // NRF_MBR_H__
Rohit Grover 37:c29c330d942c 152
Rohit Grover 37:c29c330d942c 153 /**
Rohit Grover 37:c29c330d942c 154 @}
Rohit Grover 37:c29c330d942c 155 */