#include #include #include #include "twi_master.h" #include #include "nrf.h" #include "nrf_gpio.h" #include "app_timer.h" #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ #define APP_TIMER_MAX_TIMERS 5 /**< Maximum number of simultaneously created timers. 1 for Battery measurement, 2 for flashing Advertising LED and Alert LED, 1 for connection parameters module, 1 for button polling timer needed by the app_button module, */ #define APP_TIMER_OP_QUEUE_SIZE 6 /**< Size of timer operation queues. */ #define SEND_TO_BLE_STACK_FOR_EVERY_2hours APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER) static app_timer_id_t m_ble_stack_timer_id; /**< Battery measurement timer. */ int i=0; uint8_t seconds=0; uint8_t minits=0; uint8_t hours=0; static void ble_stack_level_meas_timeout_handler(void * p_context) { // UNUSED_PARAMETER(p_context); // i=~i; // NRF_GPIO->OUT=(i<<17); seconds++; if(seconds==60) { minits++; seconds=0; } if(minits==60) { hours=1; seconds=0; minits=0; } } static void timers_init(void) { uint32_t err_code; // Initialize timer module APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); // Create battery timer err_code = app_timer_create(& m_ble_stack_timer_id, APP_TIMER_MODE_REPEATED, ble_stack_level_meas_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_start(m_ble_stack_timer_id, SEND_TO_BLE_STACK_FOR_EVERY_2hours, NULL); APP_ERROR_CHECK(err_code); } int main() { NRF_GPIO->DIRSET=(1<<17); timers_init(); }