RCBControllerでモータを制御します。うおーるぼっとも動かせました。

Dependencies:   BLE_API_Native_IRC TB6612FNG2 mbed

Fork of BLE_RCBController by Junichi Katsu

  • 古いBLEライブラリを使っているのでプラットフォームは”Nordic nRF51822”を選択してください。
  • ライブラリ類はUpdateしないでください。コンパイルエラーになります。

うまく接続できない時は、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアしてみてください。

RCBControllerでうおーるぼっとを操縦する例 /media/uploads/robo8080/img_1671.jpg

RCBControllerでの操縦は次の4種類あります。 それぞれうおーるぼっとの動きが異なりますので試してみてください。

  • 左十字ボタン
  • 左のみアナログ
  • 右のみアナログ
  • 両方アナログ

うおーるぼっと(LPC1768のソケット)とHRM1017の接続はこれです。

LPC1768 ー HRM1017

p11 ーーー P0_0

p12 ーーー P0_1

p13 ーーー P0_28

p14 ーーー P0_29

p21 ーーー P0_30

p22 ーーー P0_25

GND ーーー GND

HRM1017の電源はうおーるぼっとのUSBコネクタからとります。 /media/uploads/robo8080/img_1674.jpg

Committer:
jksoft
Date:
Thu Jul 10 14:21:52 2014 +0000
Revision:
0:8c643bfe55b7
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8c643bfe55b7 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8c643bfe55b7 2 *
jksoft 0:8c643bfe55b7 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:8c643bfe55b7 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:8c643bfe55b7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:8c643bfe55b7 6 *
jksoft 0:8c643bfe55b7 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:8c643bfe55b7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:8c643bfe55b7 9 * the file.
jksoft 0:8c643bfe55b7 10 *
jksoft 0:8c643bfe55b7 11 */
jksoft 0:8c643bfe55b7 12
jksoft 0:8c643bfe55b7 13 /** @file
jksoft 0:8c643bfe55b7 14 *
jksoft 0:8c643bfe55b7 15 * @defgroup softdevice_handler SoftDevice Event Handler
jksoft 0:8c643bfe55b7 16 * @{
jksoft 0:8c643bfe55b7 17 * @ingroup app_common
jksoft 0:8c643bfe55b7 18 * @brief API for initializing and disabling the SoftDevice
jksoft 0:8c643bfe55b7 19 *
jksoft 0:8c643bfe55b7 20 * @details This API contains the functions and defines exposed by the @ref lib_softdevice_handler.
jksoft 0:8c643bfe55b7 21 * For more information on the library and how the application should use it, please refer
jksoft 0:8c643bfe55b7 22 * @ref lib_softdevice_handler.
jksoft 0:8c643bfe55b7 23 *
jksoft 0:8c643bfe55b7 24 * @note Use the USE_SCHEDULER parameter of the SOFTDEVICE_HANDLER_INIT() macro to select if
jksoft 0:8c643bfe55b7 25 * the @ref app_scheduler is to be used or not.
jksoft 0:8c643bfe55b7 26 *
jksoft 0:8c643bfe55b7 27 * @note Even if the scheduler is not used, softdevice_handler.h will include app_scheduler.h.
jksoft 0:8c643bfe55b7 28 * So when compiling, app_scheduler.h must be available in one of the compiler include
jksoft 0:8c643bfe55b7 29 * paths.
jksoft 0:8c643bfe55b7 30 */
jksoft 0:8c643bfe55b7 31
jksoft 0:8c643bfe55b7 32 #ifndef SOFTDEVICE_HANDLER_H__
jksoft 0:8c643bfe55b7 33 #define SOFTDEVICE_HANDLER_H__
jksoft 0:8c643bfe55b7 34
jksoft 0:8c643bfe55b7 35 #include <stdlib.h>
jksoft 0:8c643bfe55b7 36 #include "nordic_global.h"
jksoft 0:8c643bfe55b7 37 #include "nrf_sdm.h"
jksoft 0:8c643bfe55b7 38 #include "app_error.h"
jksoft 0:8c643bfe55b7 39 #include "app_scheduler.h"
jksoft 0:8c643bfe55b7 40 #include "app_util.h"
jksoft 0:8c643bfe55b7 41 #include "ble_stack_handler_types.h"
jksoft 0:8c643bfe55b7 42 #include "ant_stack_handler_types.h"
jksoft 0:8c643bfe55b7 43
jksoft 0:8c643bfe55b7 44 #define SOFTDEVICE_SCHED_EVT_SIZE 0 /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). For SoftDevice events, this size is 0, since the events are being pulled in the event handler. */
jksoft 0:8c643bfe55b7 45 #define SYS_EVT_MSG_BUF_SIZE sizeof(uint32_t) /**< Size of System (SOC) event message buffer. */
jksoft 0:8c643bfe55b7 46
jksoft 0:8c643bfe55b7 47 /**@brief Type of function for passing events from the stack handler module to the scheduler. */
jksoft 0:8c643bfe55b7 48 typedef uint32_t (*softdevice_evt_schedule_func_t) (void);
jksoft 0:8c643bfe55b7 49
jksoft 0:8c643bfe55b7 50 /**@brief Application System (SOC) event handler type. */
jksoft 0:8c643bfe55b7 51 typedef void (*sys_evt_handler_t) (uint32_t evt_id);
jksoft 0:8c643bfe55b7 52
jksoft 0:8c643bfe55b7 53
jksoft 0:8c643bfe55b7 54 /**@brief Macro for initializing the stack event handler.
jksoft 0:8c643bfe55b7 55 *
jksoft 0:8c643bfe55b7 56 * @details It will handle dimensioning and allocation of the memory buffer required for reading
jksoft 0:8c643bfe55b7 57 * events from the stack, making sure the buffer is correctly aligned. It will also
jksoft 0:8c643bfe55b7 58 * connect the stack event handler to the scheduler (if specified).
jksoft 0:8c643bfe55b7 59 *
jksoft 0:8c643bfe55b7 60 * @param[in] CLOCK_SOURCE Low frequency clock source and accuracy (type nrf_clock_lfclksrc_t,
jksoft 0:8c643bfe55b7 61 * see sd_softdevice_enable() for details).
jksoft 0:8c643bfe55b7 62 * @param[in] USE_SCHEDULER TRUE if the application is using the event scheduler, FALSE
jksoft 0:8c643bfe55b7 63 * otherwise.
jksoft 0:8c643bfe55b7 64 *
jksoft 0:8c643bfe55b7 65 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
jksoft 0:8c643bfe55b7 66 * several times as long as it is from the same location, that is to do a
jksoft 0:8c643bfe55b7 67 * reinitialization).
jksoft 0:8c643bfe55b7 68 */
jksoft 0:8c643bfe55b7 69 /*lint -emacro(506, SOFTDEVICE_HANDLER_INIT) */ /* Suppress "Constant value Boolean */
jksoft 0:8c643bfe55b7 70 #define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, \
jksoft 0:8c643bfe55b7 71 USE_SCHEDULER) \
jksoft 0:8c643bfe55b7 72 do \
jksoft 0:8c643bfe55b7 73 { \
jksoft 0:8c643bfe55b7 74 static uint32_t EVT_BUFFER[CEIL_DIV(MAX( \
jksoft 0:8c643bfe55b7 75 MAX(BLE_STACK_EVT_MSG_BUF_SIZE, \
jksoft 0:8c643bfe55b7 76 ANT_STACK_EVT_STRUCT_SIZE), \
jksoft 0:8c643bfe55b7 77 SYS_EVT_MSG_BUF_SIZE \
jksoft 0:8c643bfe55b7 78 ), \
jksoft 0:8c643bfe55b7 79 sizeof(uint32_t))]; \
jksoft 0:8c643bfe55b7 80 uint32_t ERR_CODE; \
jksoft 0:8c643bfe55b7 81 ERR_CODE = softdevice_handler_init((CLOCK_SOURCE), \
jksoft 0:8c643bfe55b7 82 EVT_BUFFER, \
jksoft 0:8c643bfe55b7 83 sizeof(EVT_BUFFER), \
jksoft 0:8c643bfe55b7 84 (USE_SCHEDULER) ? softdevice_evt_schedule : NULL); \
jksoft 0:8c643bfe55b7 85 APP_ERROR_CHECK(ERR_CODE); \
jksoft 0:8c643bfe55b7 86 } while (0)
jksoft 0:8c643bfe55b7 87
jksoft 0:8c643bfe55b7 88
jksoft 0:8c643bfe55b7 89 /**@brief Function for initializing the stack handler module.
jksoft 0:8c643bfe55b7 90 *
jksoft 0:8c643bfe55b7 91 * @details Enables the SoftDevice and the stack event interrupt handler.
jksoft 0:8c643bfe55b7 92 *
jksoft 0:8c643bfe55b7 93 * @note This function must be called before calling any function in the SoftDevice API.
jksoft 0:8c643bfe55b7 94 *
jksoft 0:8c643bfe55b7 95 * @note Normally initialization should be done using the SOFTDEVICE_HANDLER_INIT() macro,
jksoft 0:8c643bfe55b7 96 * as that will both allocate the event buffer, and also align the buffer correctly.
jksoft 0:8c643bfe55b7 97 *
jksoft 0:8c643bfe55b7 98 * @param[in] clock_source Low frequency clock source to be used by the SoftDevice.
jksoft 0:8c643bfe55b7 99 * @param[in] p_evt_buffer Buffer for holding one stack event. Since heap is not being
jksoft 0:8c643bfe55b7 100 * used, this buffer must be provided by the application. The
jksoft 0:8c643bfe55b7 101 * buffer must be large enough to hold the biggest stack event the
jksoft 0:8c643bfe55b7 102 * application is supposed to handle. The buffer must be aligned to
jksoft 0:8c643bfe55b7 103 * a 4 byte boundary. This parameter is unused if neither BLE nor
jksoft 0:8c643bfe55b7 104 * ANT stack support is required.
jksoft 0:8c643bfe55b7 105 * @param[in] evt_buffer_size Size of SoftDevice event buffer. This parameter is unused if
jksoft 0:8c643bfe55b7 106 * BLE stack support is not required.
jksoft 0:8c643bfe55b7 107 * @param[in] evt_schedule_func Function for passing events to the scheduler. Point to
jksoft 0:8c643bfe55b7 108 * ble_ant_stack_evt_schedule() to connect to the scheduler.
jksoft 0:8c643bfe55b7 109 * Set to NULL to make the stack handler module call the event
jksoft 0:8c643bfe55b7 110 * handler directly from the stack event interrupt handler.
jksoft 0:8c643bfe55b7 111 *
jksoft 0:8c643bfe55b7 112 * @retval NRF_SUCCESS Successful initialization.
jksoft 0:8c643bfe55b7 113 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte
jksoft 0:8c643bfe55b7 114 * boundary) or NULL.
jksoft 0:8c643bfe55b7 115 */
jksoft 0:8c643bfe55b7 116 uint32_t softdevice_handler_init(nrf_clock_lfclksrc_t clock_source,
jksoft 0:8c643bfe55b7 117 void * p_evt_buffer,
jksoft 0:8c643bfe55b7 118 uint16_t evt_buffer_size,
jksoft 0:8c643bfe55b7 119 softdevice_evt_schedule_func_t evt_schedule_func);
jksoft 0:8c643bfe55b7 120
jksoft 0:8c643bfe55b7 121
jksoft 0:8c643bfe55b7 122 /**@brief Function for disabling the SoftDevice.
jksoft 0:8c643bfe55b7 123 *
jksoft 0:8c643bfe55b7 124 * @details This function will disable the SoftDevice. It will also update the internal state
jksoft 0:8c643bfe55b7 125 * of this module.
jksoft 0:8c643bfe55b7 126 */
jksoft 0:8c643bfe55b7 127 uint32_t softdevice_handler_sd_disable(void);
jksoft 0:8c643bfe55b7 128
jksoft 0:8c643bfe55b7 129
jksoft 0:8c643bfe55b7 130 /**@brief Function for registering for System (SOC) events.
jksoft 0:8c643bfe55b7 131 *
jksoft 0:8c643bfe55b7 132 * @details The application should use this function to register for receiving System (SOC)
jksoft 0:8c643bfe55b7 133 * events from the SoftDevice. If the application does not call this function, then any
jksoft 0:8c643bfe55b7 134 * System (SOC) events that may be generated by the SoftDevice will NOT be fetched. Once
jksoft 0:8c643bfe55b7 135 * the application has registered for the events, it is not possible to possible to
jksoft 0:8c643bfe55b7 136 * cancel the registration. However, it is possible to register a different function for
jksoft 0:8c643bfe55b7 137 * handling the events at any point of time.
jksoft 0:8c643bfe55b7 138 *
jksoft 0:8c643bfe55b7 139 * @param[in] sys_evt_handler Function to be called for each received System (SOC) event.
jksoft 0:8c643bfe55b7 140 *
jksoft 0:8c643bfe55b7 141 * @retval NRF_SUCCESS Successful registration.
jksoft 0:8c643bfe55b7 142 * @retval NRF_ERROR_NULL Null pointer provided as input.
jksoft 0:8c643bfe55b7 143 */
jksoft 0:8c643bfe55b7 144 uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler);
jksoft 0:8c643bfe55b7 145
jksoft 0:8c643bfe55b7 146
jksoft 0:8c643bfe55b7 147 // Functions for connecting the Stack Event Handler to the scheduler:
jksoft 0:8c643bfe55b7 148 /**@cond NO_DOXYGEN */
jksoft 0:8c643bfe55b7 149 void intern_softdevice_events_execute(void);
jksoft 0:8c643bfe55b7 150
jksoft 0:8c643bfe55b7 151 static __INLINE void softdevice_evt_get(void * p_event_data, uint16_t event_size)
jksoft 0:8c643bfe55b7 152 {
jksoft 0:8c643bfe55b7 153 APP_ERROR_CHECK_BOOL(event_size == 0);
jksoft 0:8c643bfe55b7 154 intern_softdevice_events_execute();
jksoft 0:8c643bfe55b7 155 }
jksoft 0:8c643bfe55b7 156
jksoft 0:8c643bfe55b7 157 static __INLINE uint32_t softdevice_evt_schedule(void)
jksoft 0:8c643bfe55b7 158 {
jksoft 0:8c643bfe55b7 159 return app_sched_event_put(NULL, 0, softdevice_evt_get);
jksoft 0:8c643bfe55b7 160 }
jksoft 0:8c643bfe55b7 161 /**@endcond */
jksoft 0:8c643bfe55b7 162
jksoft 0:8c643bfe55b7 163 #endif // SOFTDEVICE_HANDLER_H__
jksoft 0:8c643bfe55b7 164
jksoft 0:8c643bfe55b7 165 /** @} */