AndroidのBLEラジコンプロポアプリ「BLEPropo」と接続し、RCサーボとDCモータを制御するプログラムです。 BLE Nanoで動作を確認しています。 BLEPropo → https://github.com/lipoyang/BLEPropo

Dependencies:   BLE_API mbed

BLEを使ったAndroid用ラジコンプロポアプリ「BLEPropo」に対応するBLE Nano用ファームウェアです。
BLEPropoは、GitHubにて公開中。
https://github.com/lipoyang/BLEPropo
/media/uploads/lipoyang/blepropo_ui.png
ラジコンは、mbed HRM1017とRCサーボやDCモータを組み合わせて作ります。
/media/uploads/lipoyang/ministeer3.jpg
回路図
/media/uploads/lipoyang/ministeer3.pdf

Committer:
lipoyang
Date:
Sat Mar 14 12:02:48 2015 +0000
Revision:
5:7f89fca19a9e
-convert nRF51822 library to a folder

Who changed what in which revision?

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