Nano RGB LED mesh
Fork of nrf51-sdk by
Revision 46:298dbe432318, committed 2016-04-28
- Comitter:
- Jackson_lv
- Date:
- Thu Apr 28 08:51:03 2016 +0000
- Parent:
- 45:4a80ff6428ab
- Commit message:
- BLE Nano Mesh;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/nordic_sdk/components/libraries/app_timer_appsh/app_timer_appsh.c Thu Apr 28 08:51:03 2016 +0000 @@ -0,0 +1,34 @@ +/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "app_timer_appsh.h" +#include "app_scheduler.h" + +static void app_timer_evt_get(void * p_event_data, uint16_t event_size) +{ + app_timer_event_t * p_timer_event = (app_timer_event_t *)p_event_data; + + APP_ERROR_CHECK_BOOL(event_size == sizeof(app_timer_event_t)); + p_timer_event->timeout_handler(p_timer_event->p_context); +} + +uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler, + void * p_context) +{ + app_timer_event_t timer_event; + + timer_event.timeout_handler = timeout_handler; + timer_event.p_context = p_context; + + return app_sched_event_put(&timer_event, sizeof(timer_event), app_timer_evt_get); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/nordic_sdk/components/libraries/app_timer_appsh/app_timer_appsh.h Thu Apr 28 08:51:03 2016 +0000 @@ -0,0 +1,45 @@ +/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + + #ifndef APP_TIMER_APPSH_H + #define APP_TIMER_APPSH_H + +#include "app_timer.h" + +#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). */ + +/**@brief Macro for initializing the application timer module to use with app_scheduler. + * + * @param[in] PRESCALER Value of the RTC1 PRESCALER register. This will decide the + * timer tick rate. Set to 0 for no prescaling. + * @param[in] MAX_TIMERS Maximum number of timers that can be created at any given time. + * @param[in] OP_QUEUES_SIZE Size of queues holding timer operations that are pending execution. + * @param[in] USE_SCHEDULER TRUE if the application is using the app_scheduler, + * FALSE otherwise. + * + * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it + * several times as long as it is from the same location, e.g. to do a reinitialization). + */ +#define APP_TIMER_APPSH_INIT(PRESCALER, MAX_TIMERS, OP_QUEUES_SIZE, USE_SCHEDULER) \ + APP_TIMER_INIT(PRESCALER, MAX_TIMERS, OP_QUEUES_SIZE, \ + (USE_SCHEDULER) ? app_timer_evt_schedule : NULL) + +typedef struct +{ + app_timer_timeout_handler_t timeout_handler; + void * p_context; +} app_timer_event_t; + +uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler, + void * p_context); +#endif // APP_TIMER_APPSH_H +