Example #1
0
File: main.c Project: IOIOI/nRF51
 */

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "boards.h"
#include "nrf_drv_clock.h"
#include "nrf_drv_gpiote.h"
#include "nrf_drv_rtc.h"
#include "nrf_drv_ppi.h"
#include "nrf_gpiote.h"
#include "app_error.h"

const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(1);

void rtc_evt_handler(nrf_drv_rtc_int_type_t int_type){}

void setup_example(void)
{
    uint32_t event;
    nrf_ppi_channel_t ppi_channel;
    uint32_t err_code;

    nrf_gpio_cfg_output(BSP_LED_0);

    err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_evt_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_rtc_tick_enable(&rtc, false);
Example #2
0
/** @file rtc_blinky.c (changed by pcbreflux)
 * @brief Blinky Example Application main file.
 *
 */
#include <stdlib.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf_drv_clock.h"
#include "nrf_drv_rtc.h"
#include "app_error.h"

// see nrf_drv_config.h for defining RTC1
#define RTC1_CC_VALUE           8   // 125ms*8*1=1s
// Softdevice S110, S120, S130 blocks RTC0
const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */

const uint32_t led_pin1 = 19;

/** @brief Function initialization and configuration of RTC driver instance.
 */
static void gpio_config(void) {
    // Configure LED-pin as outputs and clear.
    nrf_gpio_cfg_output(led_pin1);
    nrf_gpio_pin_clear(led_pin1);
}

static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) {
//    uint32_t err_code;

    if (int_type == NRF_DRV_RTC_INT_COMPARE0) {   // Interrupt from COMPARE0 event.
Example #3
0
#define UART_RX_BUF_SIZE            1

#define APP_TIMER_PRESCALER         0
#define APP_TIMER_OP_QUEUE_SIZE     2

// Pin number for indicating communication with sensors.
#ifdef BSP_LED_3
    #define READ_ALL_INDICATOR  BSP_LED_3
#else
    #error "Please choose an output pin"
#endif


static app_twi_t m_app_twi = APP_TWI_INSTANCE(0);

static nrf_drv_rtc_t const m_rtc = NRF_DRV_RTC_INSTANCE(0);


// Buffer for data read from sensors.
#define BUFFER_SIZE  11
static uint8_t m_buffer[BUFFER_SIZE];

// Data structures needed for averaging of data read from sensors.
// [max 32, otherwise "int16_t" won't be sufficient to hold the sum
//  of temperature samples]
#define NUMBER_OF_SAMPLES  16
typedef struct
{
    int16_t temp;
    int16_t x;
    int16_t y;