iOSのBLEコントローラアプリ「RCBController」とmbed HRM1017を接続し、RCサーボモータを操作するテストプログラムです。

Dependencies:   BLE_API_Native_IRC Servo mbed

Fork of BLE_RCBController by Junichi Katsu

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

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

/media/uploads/robo8080/img_1560.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) 2012 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 app_scheduler Scheduler
jksoft 0:8c643bfe55b7 16 * @{
jksoft 0:8c643bfe55b7 17 * @ingroup app_common
jksoft 0:8c643bfe55b7 18 *
jksoft 0:8c643bfe55b7 19 * @brief The scheduler is used for transferring execution from the interrupt context to the main
jksoft 0:8c643bfe55b7 20 * context.
jksoft 0:8c643bfe55b7 21 *
jksoft 0:8c643bfe55b7 22 * @details See @ref ble_sdk_apps_seq_diagrams for sequence diagrams illustrating the flow of events
jksoft 0:8c643bfe55b7 23 * when using the Scheduler.
jksoft 0:8c643bfe55b7 24 *
jksoft 0:8c643bfe55b7 25 * @section app_scheduler_req Requirements:
jksoft 0:8c643bfe55b7 26 *
jksoft 0:8c643bfe55b7 27 * @subsection main_context_logic Logic in main context:
jksoft 0:8c643bfe55b7 28 *
jksoft 0:8c643bfe55b7 29 * - Define an event handler for each type of event expected.
jksoft 0:8c643bfe55b7 30 * - Initialize the scheduler by calling the APP_SCHED_INIT() macro before entering the
jksoft 0:8c643bfe55b7 31 * application main loop.
jksoft 0:8c643bfe55b7 32 * - Call app_sched_execute() from the main loop each time the application wakes up because of an
jksoft 0:8c643bfe55b7 33 * event (typically when sd_app_evt_wait() returns).
jksoft 0:8c643bfe55b7 34 *
jksoft 0:8c643bfe55b7 35 * @subsection int_context_logic Logic in interrupt context:
jksoft 0:8c643bfe55b7 36 *
jksoft 0:8c643bfe55b7 37 * - In the interrupt handler, call app_sched_event_put()
jksoft 0:8c643bfe55b7 38 * with the appropriate data and event handler. This will insert an event into the
jksoft 0:8c643bfe55b7 39 * scheduler's queue. The app_sched_execute() function will pull this event and call its
jksoft 0:8c643bfe55b7 40 * handler in the main context.
jksoft 0:8c643bfe55b7 41 *
jksoft 0:8c643bfe55b7 42 * For an example usage of the scheduler, please see the implementations of
jksoft 0:8c643bfe55b7 43 * @ref ble_sdk_app_hids_mouse and @ref ble_sdk_app_hids_keyboard.
jksoft 0:8c643bfe55b7 44 *
jksoft 0:8c643bfe55b7 45 * @image html scheduler_working.jpg The high level design of the scheduler
jksoft 0:8c643bfe55b7 46 */
jksoft 0:8c643bfe55b7 47
jksoft 0:8c643bfe55b7 48 #ifndef APP_SCHEDULER_H__
jksoft 0:8c643bfe55b7 49 #define APP_SCHEDULER_H__
jksoft 0:8c643bfe55b7 50
jksoft 0:8c643bfe55b7 51 #include <stdint.h>
jksoft 0:8c643bfe55b7 52 #include "nordic_global.h"
jksoft 0:8c643bfe55b7 53 #include "app_error.h"
jksoft 0:8c643bfe55b7 54
jksoft 0:8c643bfe55b7 55 #define APP_SCHED_EVENT_HEADER_SIZE 8 /**< Size of app_scheduler.event_header_t (only for use inside APP_SCHED_BUF_SIZE()). */
jksoft 0:8c643bfe55b7 56
jksoft 0:8c643bfe55b7 57 /**@brief Compute number of bytes required to hold the scheduler buffer.
jksoft 0:8c643bfe55b7 58 *
jksoft 0:8c643bfe55b7 59 * @param[in] EVENT_SIZE Maximum size of events to be passed through the scheduler.
jksoft 0:8c643bfe55b7 60 * @param[in] QUEUE_SIZE Number of entries in scheduler queue (i.e. the maximum number of events
jksoft 0:8c643bfe55b7 61 * that can be scheduled for execution).
jksoft 0:8c643bfe55b7 62 *
jksoft 0:8c643bfe55b7 63 * @return Required scheduler buffer size (in bytes).
jksoft 0:8c643bfe55b7 64 */
jksoft 0:8c643bfe55b7 65 #define APP_SCHED_BUF_SIZE(EVENT_SIZE, QUEUE_SIZE) \
jksoft 0:8c643bfe55b7 66 (((EVENT_SIZE) + APP_SCHED_EVENT_HEADER_SIZE) * ((QUEUE_SIZE) + 1))
jksoft 0:8c643bfe55b7 67
jksoft 0:8c643bfe55b7 68 /**@brief Scheduler event handler type. */
jksoft 0:8c643bfe55b7 69 typedef void (*app_sched_event_handler_t)(void * p_event_data, uint16_t event_size);
jksoft 0:8c643bfe55b7 70
jksoft 0:8c643bfe55b7 71 /**@brief Macro for initializing the event scheduler.
jksoft 0:8c643bfe55b7 72 *
jksoft 0:8c643bfe55b7 73 * @details It will also handle dimensioning and allocation of the memory buffer required by the
jksoft 0:8c643bfe55b7 74 * scheduler, making sure the buffer is correctly aligned.
jksoft 0:8c643bfe55b7 75 *
jksoft 0:8c643bfe55b7 76 * @param[in] EVENT_SIZE Maximum size of events to be passed through the scheduler.
jksoft 0:8c643bfe55b7 77 * @param[in] QUEUE_SIZE Number of entries in scheduler queue (i.e. the maximum number of events
jksoft 0:8c643bfe55b7 78 * that can be scheduled for execution).
jksoft 0:8c643bfe55b7 79 *
jksoft 0:8c643bfe55b7 80 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
jksoft 0:8c643bfe55b7 81 * several times as long as it is from the same location, e.g. to do a reinitialization).
jksoft 0:8c643bfe55b7 82 */
jksoft 0:8c643bfe55b7 83 #define APP_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE) \
jksoft 0:8c643bfe55b7 84 do \
jksoft 0:8c643bfe55b7 85 { \
jksoft 0:8c643bfe55b7 86 static uint32_t APP_SCHED_BUF[CEIL_DIV(APP_SCHED_BUF_SIZE((EVENT_SIZE), (QUEUE_SIZE)), \
jksoft 0:8c643bfe55b7 87 sizeof(uint32_t))]; \
jksoft 0:8c643bfe55b7 88 uint32_t ERR_CODE = app_sched_init((EVENT_SIZE), (QUEUE_SIZE), APP_SCHED_BUF); \
jksoft 0:8c643bfe55b7 89 APP_ERROR_CHECK(ERR_CODE); \
jksoft 0:8c643bfe55b7 90 } while (0)
jksoft 0:8c643bfe55b7 91
jksoft 0:8c643bfe55b7 92 /**@brief Function for initializing the Scheduler.
jksoft 0:8c643bfe55b7 93 *
jksoft 0:8c643bfe55b7 94 * @details It must be called before entering the main loop.
jksoft 0:8c643bfe55b7 95 *
jksoft 0:8c643bfe55b7 96 * @param[in] max_event_size Maximum size of events to be passed through the scheduler.
jksoft 0:8c643bfe55b7 97 * @param[in] queue_size Number of entries in scheduler queue (i.e. the maximum number of
jksoft 0:8c643bfe55b7 98 * events that can be scheduled for execution).
jksoft 0:8c643bfe55b7 99 * @param[in] p_event_buffer Pointer to memory buffer for holding the scheduler queue. It must
jksoft 0:8c643bfe55b7 100 * be dimensioned using the APP_SCHED_BUFFER_SIZE() macro. The buffer
jksoft 0:8c643bfe55b7 101 * must be aligned to a 4 byte boundary.
jksoft 0:8c643bfe55b7 102 *
jksoft 0:8c643bfe55b7 103 * @note Normally initialization should be done using the APP_SCHED_INIT() macro, as that will both
jksoft 0:8c643bfe55b7 104 * allocate the scheduler buffer, and also align the buffer correctly.
jksoft 0:8c643bfe55b7 105 *
jksoft 0:8c643bfe55b7 106 * @retval NRF_SUCCESS Successful initialization.
jksoft 0:8c643bfe55b7 107 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte
jksoft 0:8c643bfe55b7 108 * boundary).
jksoft 0:8c643bfe55b7 109 */
jksoft 0:8c643bfe55b7 110 uint32_t app_sched_init(uint16_t max_event_size, uint16_t queue_size, void * p_evt_buffer);
jksoft 0:8c643bfe55b7 111
jksoft 0:8c643bfe55b7 112 /**@brief Function for executing all scheduled events.
jksoft 0:8c643bfe55b7 113 *
jksoft 0:8c643bfe55b7 114 * @details This function must be called from within the main loop. It will execute all events
jksoft 0:8c643bfe55b7 115 * scheduled since the last time it was called.
jksoft 0:8c643bfe55b7 116 */
jksoft 0:8c643bfe55b7 117 void app_sched_execute(void);
jksoft 0:8c643bfe55b7 118
jksoft 0:8c643bfe55b7 119 /**@brief Function for scheduling an event.
jksoft 0:8c643bfe55b7 120 *
jksoft 0:8c643bfe55b7 121 * @details Puts an event into the event queue.
jksoft 0:8c643bfe55b7 122 *
jksoft 0:8c643bfe55b7 123 * @param[in] p_event_data Pointer to event data to be scheduled.
jksoft 0:8c643bfe55b7 124 * @param[in] p_event_size Size of event data to be scheduled.
jksoft 0:8c643bfe55b7 125 * @param[in] handler Event handler to receive the event.
jksoft 0:8c643bfe55b7 126 *
jksoft 0:8c643bfe55b7 127 * @return NRF_SUCCESS on success, otherwise an error code.
jksoft 0:8c643bfe55b7 128 */
jksoft 0:8c643bfe55b7 129 uint32_t app_sched_event_put(void * p_event_data,
jksoft 0:8c643bfe55b7 130 uint16_t event_size,
jksoft 0:8c643bfe55b7 131 app_sched_event_handler_t handler);
jksoft 0:8c643bfe55b7 132
jksoft 0:8c643bfe55b7 133 #endif // APP_SCHEDULER_H__
jksoft 0:8c643bfe55b7 134
jksoft 0:8c643bfe55b7 135 /** @} */