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

Dependencies:   BLE_API TB6612FNG2 mbed nRF51822

Fork of BLE_RCBController2 by Junichi Katsu

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

ライブラリ類をUpdateするとコンパイル出来なくなります。インポートした物をそのまま使って下さい。

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

Components / Wallbot
This robot has switch, line sensors and motors. It controls by mbed.

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

/media/uploads/robo8080/img_1711.jpg

/media/uploads/robo8080/img_1703.jpg

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

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/app_common/app_timer.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 1:48f6e08a3ac2 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 1:48f6e08a3ac2 2 *
jksoft 1:48f6e08a3ac2 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 1:48f6e08a3ac2 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 1:48f6e08a3ac2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 1:48f6e08a3ac2 6 *
jksoft 1:48f6e08a3ac2 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 1:48f6e08a3ac2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 1:48f6e08a3ac2 9 * the file.
jksoft 1:48f6e08a3ac2 10 *
jksoft 1:48f6e08a3ac2 11 */
jksoft 1:48f6e08a3ac2 12
jksoft 1:48f6e08a3ac2 13 /** @file
jksoft 1:48f6e08a3ac2 14 *
jksoft 1:48f6e08a3ac2 15 * @defgroup app_timer Application Timer
jksoft 1:48f6e08a3ac2 16 * @{
jksoft 1:48f6e08a3ac2 17 * @ingroup app_common
jksoft 1:48f6e08a3ac2 18 *
jksoft 1:48f6e08a3ac2 19 * @brief Application timer functionality.
jksoft 1:48f6e08a3ac2 20 *
jksoft 1:48f6e08a3ac2 21 * @details It enables the application to create multiple timer instances based on the RTC1
jksoft 1:48f6e08a3ac2 22 * peripheral. Checking for timeouts and invokation of user timeout handlers is performed
jksoft 1:48f6e08a3ac2 23 * in the RTC1 interrupt handler. List handling is done using a software interrupt (SWI0).
jksoft 1:48f6e08a3ac2 24 * Both interrupt handlers are running in APP_LOW priority level.
jksoft 1:48f6e08a3ac2 25 *
jksoft 1:48f6e08a3ac2 26 * @note When calling app_timer_start() or app_timer_stop(), the timer operation is just queued,
jksoft 1:48f6e08a3ac2 27 * and the software interrupt is triggered. The actual timer start/stop operation is
jksoft 1:48f6e08a3ac2 28 * executed by the SWI0 interrupt handler. Since the SWI0 interrupt is running in APP_LOW,
jksoft 1:48f6e08a3ac2 29 * if the application code calling the timer function is running in APP_LOW or APP_HIGH,
jksoft 1:48f6e08a3ac2 30 * the timer operation will not be performed until the application handler has returned.
jksoft 1:48f6e08a3ac2 31 * This will be the case e.g. when stopping a timer from a timeout handler when not using
jksoft 1:48f6e08a3ac2 32 * the scheduler.
jksoft 1:48f6e08a3ac2 33 *
jksoft 1:48f6e08a3ac2 34 * @details Use the USE_SCHEDULER parameter of the APP_TIMER_INIT() macro to select if the
jksoft 1:48f6e08a3ac2 35 * @ref app_scheduler is to be used or not.
jksoft 1:48f6e08a3ac2 36 *
jksoft 1:48f6e08a3ac2 37 * @note Even if the scheduler is not used, app_timer.h will include app_scheduler.h, so when
jksoft 1:48f6e08a3ac2 38 * compiling, app_scheduler.h must be available in one of the compiler include paths.
jksoft 1:48f6e08a3ac2 39 */
jksoft 1:48f6e08a3ac2 40
jksoft 1:48f6e08a3ac2 41 #ifndef APP_TIMER_H__
jksoft 1:48f6e08a3ac2 42 #define APP_TIMER_H__
jksoft 1:48f6e08a3ac2 43
jksoft 1:48f6e08a3ac2 44 #include <stdint.h>
jksoft 1:48f6e08a3ac2 45 #include <stdbool.h>
jksoft 1:48f6e08a3ac2 46 #include <stdio.h>
jksoft 1:48f6e08a3ac2 47 #include "app_error.h"
jksoft 1:48f6e08a3ac2 48 #include "app_util.h"
jksoft 1:48f6e08a3ac2 49 #include "app_scheduler.h"
jksoft 1:48f6e08a3ac2 50 #include "compiler_abstraction.h"
jksoft 1:48f6e08a3ac2 51
jksoft 1:48f6e08a3ac2 52 #ifdef __cplusplus
jksoft 1:48f6e08a3ac2 53 extern "C" {
jksoft 1:48f6e08a3ac2 54 #endif // #ifdef __cplusplus
jksoft 1:48f6e08a3ac2 55
jksoft 1:48f6e08a3ac2 56 #define APP_TIMER_SCHED_EVT_SIZE sizeof(app_timer_event_t) /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */
jksoft 1:48f6e08a3ac2 57 #define APP_TIMER_CLOCK_FREQ 32768 /**< Clock frequency of the RTC timer used to implement the app timer module. */
jksoft 1:48f6e08a3ac2 58 #define APP_TIMER_MIN_TIMEOUT_TICKS 5 /**< Minimum value of the timeout_ticks parameter of app_timer_start(). */
jksoft 1:48f6e08a3ac2 59
jksoft 1:48f6e08a3ac2 60 #define APP_TIMER_NODE_SIZE 40 /**< Size of app_timer.timer_node_t (only for use inside APP_TIMER_BUF_SIZE()). */
jksoft 1:48f6e08a3ac2 61 #define APP_TIMER_USER_OP_SIZE 24 /**< Size of app_timer.timer_user_op_t (only for use inside APP_TIMER_BUF_SIZE()). */
jksoft 1:48f6e08a3ac2 62 #define APP_TIMER_USER_SIZE 8 /**< Size of app_timer.timer_user_t (only for use inside APP_TIMER_BUF_SIZE()). */
jksoft 1:48f6e08a3ac2 63 #define APP_TIMER_INT_LEVELS 3 /**< Number of interrupt levels from where timer operations may be initiated (only for use inside APP_TIMER_BUF_SIZE()). */
jksoft 1:48f6e08a3ac2 64
jksoft 1:48f6e08a3ac2 65 /**@brief Compute number of bytes required to hold the application timer data structures.
jksoft 1:48f6e08a3ac2 66 *
jksoft 1:48f6e08a3ac2 67 * @param[in] MAX_TIMERS Maximum number of timers that can be created at any given time.
jksoft 1:48f6e08a3ac2 68 * @param[in] OP_QUEUE_SIZE Size of queues holding timer operations that are pending execution.
jksoft 1:48f6e08a3ac2 69 * NOTE: Due to the queue implementation, this size must be one more
jksoft 1:48f6e08a3ac2 70 * than the size that is actually needed.
jksoft 1:48f6e08a3ac2 71 *
jksoft 1:48f6e08a3ac2 72 * @return Required application timer buffer size (in bytes).
jksoft 1:48f6e08a3ac2 73 */
jksoft 1:48f6e08a3ac2 74 #define APP_TIMER_BUF_SIZE(MAX_TIMERS, OP_QUEUE_SIZE) \
jksoft 1:48f6e08a3ac2 75 ( \
jksoft 1:48f6e08a3ac2 76 ((MAX_TIMERS) * APP_TIMER_NODE_SIZE) \
jksoft 1:48f6e08a3ac2 77 + \
jksoft 1:48f6e08a3ac2 78 ( \
jksoft 1:48f6e08a3ac2 79 APP_TIMER_INT_LEVELS \
jksoft 1:48f6e08a3ac2 80 * \
jksoft 1:48f6e08a3ac2 81 (APP_TIMER_USER_SIZE + ((OP_QUEUE_SIZE) + 1) * APP_TIMER_USER_OP_SIZE) \
jksoft 1:48f6e08a3ac2 82 ) \
jksoft 1:48f6e08a3ac2 83 )
jksoft 1:48f6e08a3ac2 84
jksoft 1:48f6e08a3ac2 85 /**@brief Convert milliseconds to timer ticks.
jksoft 1:48f6e08a3ac2 86 *
jksoft 1:48f6e08a3ac2 87 * @note This macro uses 64 bit integer arithmetic, but as long as the macro parameters are
jksoft 1:48f6e08a3ac2 88 * constants (i.e. defines), the computation will be done by the preprocessor.
jksoft 1:48f6e08a3ac2 89 *
jksoft 1:48f6e08a3ac2 90 * @param[in] MS Milliseconds.
jksoft 1:48f6e08a3ac2 91 * @param[in] PRESCALER Value of the RTC1 PRESCALER register (must be the same value that was
jksoft 1:48f6e08a3ac2 92 * passed to APP_TIMER_INIT()).
jksoft 1:48f6e08a3ac2 93 *
jksoft 1:48f6e08a3ac2 94 * @note When using this macro, it is the responsibility of the developer to ensure that the
jksoft 1:48f6e08a3ac2 95 * values provided as input result in an output value that is supported by the
jksoft 1:48f6e08a3ac2 96 * @ref app_timer_start function. For example, when the ticks for 1 ms is needed, the
jksoft 1:48f6e08a3ac2 97 * maximum possible value of PRESCALER must be 6, when @ref APP_TIMER_CLOCK_FREQ is 32768.
jksoft 1:48f6e08a3ac2 98 * This will result in a ticks value as 5. Any higher value for PRESCALER will result in a
jksoft 1:48f6e08a3ac2 99 * ticks value that is not supported by this module.
jksoft 1:48f6e08a3ac2 100 *
jksoft 1:48f6e08a3ac2 101 * @return Number of timer ticks.
jksoft 1:48f6e08a3ac2 102 */
jksoft 1:48f6e08a3ac2 103 #define APP_TIMER_TICKS(MS, PRESCALER)\
jksoft 1:48f6e08a3ac2 104 ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
jksoft 1:48f6e08a3ac2 105
jksoft 1:48f6e08a3ac2 106 /**@brief Timer id type. */
jksoft 1:48f6e08a3ac2 107 typedef uint32_t app_timer_id_t;
jksoft 1:48f6e08a3ac2 108
jksoft 1:48f6e08a3ac2 109 /**@brief Application timeout handler type. */
jksoft 1:48f6e08a3ac2 110 typedef void (*app_timer_timeout_handler_t)(void * p_context);
jksoft 1:48f6e08a3ac2 111
jksoft 1:48f6e08a3ac2 112 /**@brief Type of function for passing events from the timer module to the scheduler. */
jksoft 1:48f6e08a3ac2 113 typedef uint32_t (*app_timer_evt_schedule_func_t) (app_timer_timeout_handler_t timeout_handler,
jksoft 1:48f6e08a3ac2 114 void * p_context);
jksoft 1:48f6e08a3ac2 115
jksoft 1:48f6e08a3ac2 116 /**@brief Timer modes. */
jksoft 1:48f6e08a3ac2 117 typedef enum
jksoft 1:48f6e08a3ac2 118 {
jksoft 1:48f6e08a3ac2 119 APP_TIMER_MODE_SINGLE_SHOT, /**< The timer will expire only once. */
jksoft 1:48f6e08a3ac2 120 APP_TIMER_MODE_REPEATED /**< The timer will restart each time it expires. */
jksoft 1:48f6e08a3ac2 121 } app_timer_mode_t;
jksoft 1:48f6e08a3ac2 122
jksoft 1:48f6e08a3ac2 123 /**@brief Macro for initializing the application timer module.
jksoft 1:48f6e08a3ac2 124 *
jksoft 1:48f6e08a3ac2 125 * @details It will handle dimensioning and allocation of the memory buffer required by the timer,
jksoft 1:48f6e08a3ac2 126 * making sure that the buffer is correctly aligned. It will also connect the timer module
jksoft 1:48f6e08a3ac2 127 * to the scheduler (if specified).
jksoft 1:48f6e08a3ac2 128 *
jksoft 1:48f6e08a3ac2 129 * @note This module assumes that the LFCLK is already running. If it isn't, the module will
jksoft 1:48f6e08a3ac2 130 * be non-functional, since the RTC will not run. If you don't use a softdevice, you'll
jksoft 1:48f6e08a3ac2 131 * have to start the LFCLK manually. See the rtc_example's \ref lfclk_config() function
jksoft 1:48f6e08a3ac2 132 * for an example of how to do this. If you use a softdevice, the LFCLK is started on
jksoft 1:48f6e08a3ac2 133 * softdevice init.
jksoft 1:48f6e08a3ac2 134 *
jksoft 1:48f6e08a3ac2 135 *
jksoft 1:48f6e08a3ac2 136 * @param[in] PRESCALER Value of the RTC1 PRESCALER register. This will decide the
jksoft 1:48f6e08a3ac2 137 * timer tick rate. Set to 0 for no prescaling.
jksoft 1:48f6e08a3ac2 138 * @param[in] MAX_TIMERS Maximum number of timers that can be created at any given time.
jksoft 1:48f6e08a3ac2 139 * @param[in] OP_QUEUES_SIZE Size of queues holding timer operations that are pending execution.
jksoft 1:48f6e08a3ac2 140 * @param[in] USE_SCHEDULER TRUE if the application is using the event scheduler,
jksoft 1:48f6e08a3ac2 141 * FALSE otherwise.
jksoft 1:48f6e08a3ac2 142 *
jksoft 1:48f6e08a3ac2 143 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
jksoft 1:48f6e08a3ac2 144 * several times as long as it is from the same location, e.g. to do a reinitialization).
jksoft 1:48f6e08a3ac2 145 */
jksoft 1:48f6e08a3ac2 146 /*lint -emacro(506, APP_TIMER_INIT) */ /* Suppress "Constant value Boolean */
jksoft 1:48f6e08a3ac2 147 #define APP_TIMER_INIT(PRESCALER, MAX_TIMERS, OP_QUEUES_SIZE, USE_SCHEDULER) \
jksoft 1:48f6e08a3ac2 148 do \
jksoft 1:48f6e08a3ac2 149 { \
jksoft 1:48f6e08a3ac2 150 static uint32_t APP_TIMER_BUF[CEIL_DIV(APP_TIMER_BUF_SIZE((MAX_TIMERS), \
jksoft 1:48f6e08a3ac2 151 (OP_QUEUES_SIZE) + 1), \
jksoft 1:48f6e08a3ac2 152 sizeof(uint32_t))]; \
jksoft 1:48f6e08a3ac2 153 uint32_t ERR_CODE = app_timer_init((PRESCALER), \
jksoft 1:48f6e08a3ac2 154 (MAX_TIMERS), \
jksoft 1:48f6e08a3ac2 155 (OP_QUEUES_SIZE) + 1, \
jksoft 1:48f6e08a3ac2 156 APP_TIMER_BUF, \
jksoft 1:48f6e08a3ac2 157 (USE_SCHEDULER) ? app_timer_evt_schedule : NULL); \
jksoft 1:48f6e08a3ac2 158 APP_ERROR_CHECK(ERR_CODE); \
jksoft 1:48f6e08a3ac2 159 } while (0)
jksoft 1:48f6e08a3ac2 160
jksoft 1:48f6e08a3ac2 161 /**@brief Function for initializing the timer module.
jksoft 1:48f6e08a3ac2 162 *
jksoft 1:48f6e08a3ac2 163 * @note Normally initialization should be done using the APP_TIMER_INIT() macro, as that will both
jksoft 1:48f6e08a3ac2 164 * allocate the buffers needed by the timer module (including aligning the buffers correctly,
jksoft 1:48f6e08a3ac2 165 * and also take care of connecting the timer module to the scheduler (if specified).
jksoft 1:48f6e08a3ac2 166 *
jksoft 1:48f6e08a3ac2 167 * @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling.
jksoft 1:48f6e08a3ac2 168 * @param[in] max_timers Maximum number of timers that can be created at any given time.
jksoft 1:48f6e08a3ac2 169 * @param[in] op_queues_size Size of queues holding timer operations that are pending
jksoft 1:48f6e08a3ac2 170 * execution. NOTE: Due to the queue implementation, this size must
jksoft 1:48f6e08a3ac2 171 * be one more than the size that is actually needed.
jksoft 1:48f6e08a3ac2 172 * @param[in] p_buffer Pointer to memory buffer for internal use in the app_timer
jksoft 1:48f6e08a3ac2 173 * module. The size of the buffer can be computed using the
jksoft 1:48f6e08a3ac2 174 * APP_TIMER_BUF_SIZE() macro. The buffer must be aligned to a
jksoft 1:48f6e08a3ac2 175 * 4 byte boundary.
jksoft 1:48f6e08a3ac2 176 * @param[in] evt_schedule_func Function for passing timeout events to the scheduler. Point to
jksoft 1:48f6e08a3ac2 177 * app_timer_evt_schedule() to connect to the scheduler. Set to NULL
jksoft 1:48f6e08a3ac2 178 * to make the timer module call the timeout handler directly from
jksoft 1:48f6e08a3ac2 179 * the timer interrupt handler.
jksoft 1:48f6e08a3ac2 180 *
jksoft 1:48f6e08a3ac2 181 * @retval NRF_SUCCESS Successful initialization.
jksoft 1:48f6e08a3ac2 182 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte
jksoft 1:48f6e08a3ac2 183 * boundary or NULL).
jksoft 1:48f6e08a3ac2 184 */
jksoft 1:48f6e08a3ac2 185 uint32_t app_timer_init(uint32_t prescaler,
jksoft 1:48f6e08a3ac2 186 uint8_t max_timers,
jksoft 1:48f6e08a3ac2 187 uint8_t op_queues_size,
jksoft 1:48f6e08a3ac2 188 void * p_buffer,
jksoft 1:48f6e08a3ac2 189 app_timer_evt_schedule_func_t evt_schedule_func);
jksoft 1:48f6e08a3ac2 190
jksoft 1:48f6e08a3ac2 191 /**@brief Function for creating a timer instance.
jksoft 1:48f6e08a3ac2 192 *
jksoft 1:48f6e08a3ac2 193 * @param[out] p_timer_id Id of the newly created timer.
jksoft 1:48f6e08a3ac2 194 * @param[in] mode Timer mode.
jksoft 1:48f6e08a3ac2 195 * @param[in] timeout_handler Function to be executed when the timer expires.
jksoft 1:48f6e08a3ac2 196 *
jksoft 1:48f6e08a3ac2 197 * @retval NRF_SUCCESS Timer was successfully created.
jksoft 1:48f6e08a3ac2 198 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter.
jksoft 1:48f6e08a3ac2 199 * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized.
jksoft 1:48f6e08a3ac2 200 * @retval NRF_ERROR_NO_MEM Maximum number of timers has already been reached.
jksoft 1:48f6e08a3ac2 201 *
jksoft 1:48f6e08a3ac2 202 * @note This function does the timer allocation in the caller's context. It is also not protected
jksoft 1:48f6e08a3ac2 203 * by a critical region. Therefore care must be taken not to call it from several interrupt
jksoft 1:48f6e08a3ac2 204 * levels simultaneously.
jksoft 1:48f6e08a3ac2 205 */
jksoft 1:48f6e08a3ac2 206 uint32_t app_timer_create(app_timer_id_t * p_timer_id,
jksoft 1:48f6e08a3ac2 207 app_timer_mode_t mode,
jksoft 1:48f6e08a3ac2 208 app_timer_timeout_handler_t timeout_handler);
jksoft 1:48f6e08a3ac2 209
jksoft 1:48f6e08a3ac2 210 /**@brief Function for starting a timer.
jksoft 1:48f6e08a3ac2 211 *
jksoft 1:48f6e08a3ac2 212 * @param[in] timer_id Id of timer to start.
jksoft 1:48f6e08a3ac2 213 * @param[in] timeout_ticks Number of ticks (of RTC1, including prescaling) to timeout event
jksoft 1:48f6e08a3ac2 214 * (minimum 5 ticks).
jksoft 1:48f6e08a3ac2 215 * @param[in] p_context General purpose pointer. Will be passed to the timeout handler when
jksoft 1:48f6e08a3ac2 216 * the timer expires.
jksoft 1:48f6e08a3ac2 217 *
jksoft 1:48f6e08a3ac2 218 * @retval NRF_SUCCESS Timer was successfully started.
jksoft 1:48f6e08a3ac2 219 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter.
jksoft 1:48f6e08a3ac2 220 * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized, or timer
jksoft 1:48f6e08a3ac2 221 * has not been created.
jksoft 1:48f6e08a3ac2 222 * @retval NRF_ERROR_NO_MEM Timer operations queue was full.
jksoft 1:48f6e08a3ac2 223 *
jksoft 1:48f6e08a3ac2 224 * @note The minimum timeout_ticks value is 5.
jksoft 1:48f6e08a3ac2 225 * @note For multiple active timers, timeouts occurring in close proximity to each other (in the
jksoft 1:48f6e08a3ac2 226 * range of 1 to 3 ticks) will have a positive jitter of maximum 3 ticks.
jksoft 1:48f6e08a3ac2 227 * @note When calling this method on a timer which is already running, the second start operation
jksoft 1:48f6e08a3ac2 228 * will be ignored.
jksoft 1:48f6e08a3ac2 229 */
jksoft 1:48f6e08a3ac2 230 uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context);
jksoft 1:48f6e08a3ac2 231
jksoft 1:48f6e08a3ac2 232 /**@brief Function for stopping the specified timer.
jksoft 1:48f6e08a3ac2 233 *
jksoft 1:48f6e08a3ac2 234 * @param[in] timer_id Id of timer to stop.
jksoft 1:48f6e08a3ac2 235 *
jksoft 1:48f6e08a3ac2 236 * @retval NRF_SUCCESS Timer was successfully stopped.
jksoft 1:48f6e08a3ac2 237 * @retval NRF_ERROR_INVALID_PARAM Invalid parameter.
jksoft 1:48f6e08a3ac2 238 * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized, or timer
jksoft 1:48f6e08a3ac2 239 * has not been created.
jksoft 1:48f6e08a3ac2 240 * @retval NRF_ERROR_NO_MEM Timer operations queue was full.
jksoft 1:48f6e08a3ac2 241 */
jksoft 1:48f6e08a3ac2 242 uint32_t app_timer_stop(app_timer_id_t timer_id);
jksoft 1:48f6e08a3ac2 243
jksoft 1:48f6e08a3ac2 244 /**@brief Function for stopping all running timers.
jksoft 1:48f6e08a3ac2 245 *
jksoft 1:48f6e08a3ac2 246 * @retval NRF_SUCCESS All timers were successfully stopped.
jksoft 1:48f6e08a3ac2 247 * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized.
jksoft 1:48f6e08a3ac2 248 * @retval NRF_ERROR_NO_MEM Timer operations queue was full.
jksoft 1:48f6e08a3ac2 249 */
jksoft 1:48f6e08a3ac2 250 uint32_t app_timer_stop_all(void);
jksoft 1:48f6e08a3ac2 251
jksoft 1:48f6e08a3ac2 252 /**@brief Function for returning the current value of the RTC1 counter.
jksoft 1:48f6e08a3ac2 253 *
jksoft 1:48f6e08a3ac2 254 * @param[out] p_ticks Current value of the RTC1 counter.
jksoft 1:48f6e08a3ac2 255 *
jksoft 1:48f6e08a3ac2 256 * @retval NRF_SUCCESS Counter was successfully read.
jksoft 1:48f6e08a3ac2 257 */
jksoft 1:48f6e08a3ac2 258 uint32_t app_timer_cnt_get(uint32_t * p_ticks);
jksoft 1:48f6e08a3ac2 259
jksoft 1:48f6e08a3ac2 260 /**@brief Function for computing the difference between two RTC1 counter values.
jksoft 1:48f6e08a3ac2 261 *
jksoft 1:48f6e08a3ac2 262 * @param[in] ticks_to Value returned by app_timer_cnt_get().
jksoft 1:48f6e08a3ac2 263 * @param[in] ticks_from Value returned by app_timer_cnt_get().
jksoft 1:48f6e08a3ac2 264 * @param[out] p_ticks_diff Number of ticks from ticks_from to ticks_to.
jksoft 1:48f6e08a3ac2 265 *
jksoft 1:48f6e08a3ac2 266 * @retval NRF_SUCCESS Counter difference was successfully computed.
jksoft 1:48f6e08a3ac2 267 */
jksoft 1:48f6e08a3ac2 268 uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to,
jksoft 1:48f6e08a3ac2 269 uint32_t ticks_from,
jksoft 1:48f6e08a3ac2 270 uint32_t * p_ticks_diff);
jksoft 1:48f6e08a3ac2 271
jksoft 1:48f6e08a3ac2 272
jksoft 1:48f6e08a3ac2 273 // Type and functions for connecting the timer to the scheduler:
jksoft 1:48f6e08a3ac2 274
jksoft 1:48f6e08a3ac2 275 /**@cond NO_DOXYGEN */
jksoft 1:48f6e08a3ac2 276 typedef struct
jksoft 1:48f6e08a3ac2 277 {
jksoft 1:48f6e08a3ac2 278 app_timer_timeout_handler_t timeout_handler;
jksoft 1:48f6e08a3ac2 279 void * p_context;
jksoft 1:48f6e08a3ac2 280 } app_timer_event_t;
jksoft 1:48f6e08a3ac2 281
jksoft 1:48f6e08a3ac2 282 static __INLINE void app_timer_evt_get(void * p_event_data, uint16_t event_size)
jksoft 1:48f6e08a3ac2 283 {
jksoft 1:48f6e08a3ac2 284 app_timer_event_t * p_timer_event = (app_timer_event_t *)p_event_data;
jksoft 1:48f6e08a3ac2 285
jksoft 1:48f6e08a3ac2 286 APP_ERROR_CHECK_BOOL(event_size == sizeof(app_timer_event_t));
jksoft 1:48f6e08a3ac2 287 p_timer_event->timeout_handler(p_timer_event->p_context);
jksoft 1:48f6e08a3ac2 288 }
jksoft 1:48f6e08a3ac2 289
jksoft 1:48f6e08a3ac2 290 static __INLINE uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler,
jksoft 1:48f6e08a3ac2 291 void * p_context)
jksoft 1:48f6e08a3ac2 292 {
jksoft 1:48f6e08a3ac2 293 app_timer_event_t timer_event;
jksoft 1:48f6e08a3ac2 294
jksoft 1:48f6e08a3ac2 295 timer_event.timeout_handler = timeout_handler;
jksoft 1:48f6e08a3ac2 296 timer_event.p_context = p_context;
jksoft 1:48f6e08a3ac2 297
jksoft 1:48f6e08a3ac2 298 return app_sched_event_put(&timer_event, sizeof(timer_event), app_timer_evt_get);
jksoft 1:48f6e08a3ac2 299 }
jksoft 1:48f6e08a3ac2 300 /**@endcond */
jksoft 1:48f6e08a3ac2 301
jksoft 1:48f6e08a3ac2 302 #ifdef __cplusplus
jksoft 1:48f6e08a3ac2 303 }
jksoft 1:48f6e08a3ac2 304 #endif // #ifdef __cplusplus
jksoft 1:48f6e08a3ac2 305
jksoft 1:48f6e08a3ac2 306 #endif // APP_TIMER_H__
jksoft 1:48f6e08a3ac2 307
jksoft 1:48f6e08a3ac2 308 /** @} */