static void ser_phy_init_gpiote(void)
{
    if (!nrf_drv_gpiote_is_init())
    {
        (void)nrf_drv_gpiote_init();
    }
    NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_HIGH);

    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    /* Enable pullup to ensure high state while connectivity device is reset */
    config.pull = NRF_GPIO_PIN_PULLUP;
    (void)nrf_drv_gpiote_in_init(SER_PHY_SPI_MASTER_PIN_SLAVE_REQUEST, &config,
        ser_phy_spi_master_request);
    nrf_drv_gpiote_in_event_enable(SER_PHY_SPI_MASTER_PIN_SLAVE_REQUEST,true);
    m_slave_request_flag = !(nrf_gpio_pin_read(SER_PHY_SPI_MASTER_PIN_SLAVE_REQUEST));

#ifdef _SPI_5W_
    m_slave_ready_flag = true;
#else
    (void)nrf_drv_gpiote_in_init(SER_PHY_SPI_MASTER_PIN_SLAVE_READY, &config,
        ser_phy_spi_master_ready);
    nrf_drv_gpiote_in_event_enable(SER_PHY_SPI_MASTER_PIN_SLAVE_READY,true);
    m_slave_ready_flag = !(nrf_gpio_pin_read(SER_PHY_SPI_MASTER_PIN_SLAVE_READY));
#endif

    NVIC_ClearPendingIRQ(SW_IRQn);
}
Example #2
0
static void gpio_apply_config(uint8_t pin)
{
    if (m_gpio_initialized & (1UL << pin)) {
        if ((m_gpio_cfg[pin].direction == PIN_OUTPUT) && (!m_gpio_cfg[pin].used_as_irq)) {
            nrf_drv_gpiote_out_uninit(pin);
        }
        else {
            nrf_drv_gpiote_in_uninit(pin);
        }
    }

    if (m_gpio_cfg[pin].used_as_gpio || m_gpio_cfg[pin].used_as_irq) {
        if ((m_gpio_cfg[pin].direction == PIN_INPUT)
            || (m_gpio_cfg[pin].used_as_irq)) {
            //Configure as input.
            nrf_drv_gpiote_in_config_t cfg;

            cfg.hi_accuracy = false;
            cfg.is_watcher = false;
            cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE;
            if (m_gpio_cfg[pin].used_as_irq) {
                cfg.pull = NRF_GPIO_PIN_PULLUP;
                nrf_drv_gpiote_in_init(pin, &cfg, gpiote_irq_handler);
                if ((m_gpio_irq_enabled & (1 << pin))
                    && (m_gpio_cfg[pin].irq_rise || m_gpio_cfg[pin].irq_fall))
                {
                    nrf_drv_gpiote_in_event_enable(pin, true);
                }
            }
            else {
                switch(m_gpio_cfg[pin].pull) {
                    case PullUp:
                        cfg.pull = NRF_GPIO_PIN_PULLUP;
                    break;
                    case PullDown:
                        cfg.pull = NRF_GPIO_PIN_PULLDOWN;
                    break;
                    default:
                        cfg.pull = NRF_GPIO_PIN_NOPULL;
                    break;
                }
                nrf_drv_gpiote_in_init(pin, &cfg, NULL);
            }
        }
        else {
            // Configure as output.
            nrf_drv_gpiote_out_config_t cfg = GPIOTE_CONFIG_OUT_SIMPLE(m_gpio_cfg[pin].init_high);
            nrf_drv_gpiote_out_init(pin, &cfg);
        }
        m_gpio_initialized |= (1UL << pin);
    }
    else {
        m_gpio_initialized &= ~(1UL << pin);
    }
}
Example #3
0
static void qenc_init_gpiote(nrf_qdec_ledpol_t led_pol)
{
    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

    config.pull = NRF_GPIO_PIN_PULLUP;

    if (!nrf_drv_gpiote_is_init())
    {
        (void)nrf_drv_gpiote_init();
    }

    // change state on inactive edge of led pulse
    if (led_pol == NRF_QDEC_LEPOL_ACTIVE_LOW)
    {
        config.sense = NRF_GPIOTE_POLARITY_HITOLO;
    }

    (void)nrf_drv_gpiote_in_init(QENC_CONFIG_PIO_LED,&config,gpiote_event_handler);
    nrf_drv_gpiote_in_event_enable(QENC_CONFIG_PIO_LED, true);

    //Configure output pins.
    (void)nrf_drv_gpiote_out_init(QENC_CONFIG_PIO_A, &out_config);
    (void)nrf_drv_gpiote_out_init(QENC_CONFIG_PIO_B, &out_config);
}
Example #4
0
void BSP_init(void) {
	uint32_t err_code;
    err_code = nrf_drv_timer_init(&TIMER1, NULL, Timer1_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_timer_extended_compare(&TIMER1, NRF_TIMER_CC_CHANNEL0
    		, nrf_drv_timer_ms_to_ticks(&TIMER1, 1000/BSP_TICKS_PER_SEC)
			, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    // Configure button 1 for low accuracy (why not high accuracy?)
    Q_ALLEGE(nrf_drv_gpiote_init() == NRF_SUCCESS);

    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    config.pull = NRF_GPIO_PIN_PULLUP;

    Q_ALLEGE(nrf_drv_gpiote_in_init(BTN_PIN, &config, btn1_event_handler)
    		== NRF_SUCCESS);
    nrf_drv_gpiote_in_event_enable(BTN_PIN, /* int enable = */ true);

    NRF_GPIO->DIRSET = 1 << GPIO_TP;

    /* initialize the QS software tracing... */
    if (QS_INIT((void *)0) == 0) {
        Q_ERROR();
    }
}
Example #5
0
int main(void) {
    uint32_t err_code;
nrf_drv_gpiote_in_config_t temp_t = {NRF_GPIOTE_POLARITY_HITOLO, NRF_GPIO_PIN_NOPULL, false, false};


    // Initialization
    led_init(LED_0);
    //led_on(LED_0);
    led_init(LED_1);
    led_init(LED_2);
    //led_on(LED_1);

    // Setup clock
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, false);
    
    //nrf_gpio_cfg_input(22, NRF_GPIO_PIN_NOPULL);
    //nrf_gpio_cfg_input(21, NRF_GPIO_PIN_NOPULL);
    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    }
    nrf_drv_gpiote_in_init(21, &temp_t, &pin_handler);
    nrf_gpio_cfg_sense_input(21, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
    

    nrf_drv_gpiote_in_init(22, &temp_t, &pin_handler);    
    nrf_gpio_cfg_sense_input(22, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);

    // nrf_drv_gpiote_in_init(0, &temp_t, &pin_handler);

    NRF_GPIOTE->INTENSET = 0x8000000F;
    NVIC_EnableIRQ(GPIOTE_IRQn);

    // Setup and start timer
    //timers_init();
    //timers_start();

    while (1) {
        power_manage();
    
    }
}
Example #6
0
uint32_t gpio_init(gpio_cfg_t *gpio_cfgs,
                   uint8_t gpio_count) {
   // assert(gpio_count < NUM_GPIO_PINS);
    uint32_t err_code;

    // TODO: WE MIGHT OR MIGHT NOT NEED THIS!! probably do tho
    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        _pin_direction_reset();
    }

    // Save configuration.
    _gpio_cfgs = gpio_cfgs;
    _gpio_count = gpio_count;
    
    while (gpio_count--) {
        gpio_cfg_t* curr_input = &_gpio_cfgs[gpio_count];

       // assert(curr_input->pin_no < NUM_GPIO_PINS && _pin_direction[curr_input->pin_no] == PIN_UNDEFINED);
       // assert(curr_input->pin_direction != PIN_UNDEFINED);

        if (curr_input->pin_direction == PIN_OUT) {
            nrf_gpio_cfg_output(curr_input->pin_no);
        } else { // (PIN_GPIOTE_IN || PIN_PORT_IN)
            nrf_drv_gpiote_in_config_t p_config =
                {curr_input->polarity, curr_input->pull_cfg,
                 false, (curr_input->pin_direction == PIN_GPIOTE_IN) ? true : false};

            err_code = nrf_drv_gpiote_in_init(curr_input->pin_no, 
                                              &p_config,
                                              curr_input->gpio_handler);

            if (curr_input->pin_direction == PIN_PORT_IN) {
                nrf_gpio_cfg_sense_input(curr_input->pin_no, curr_input->pull_cfg,
                                         curr_input->polarity);
            }
        }

        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }

        _pin_direction[curr_input->pin_no] = curr_input->pin_direction;

    }

    return NRF_SUCCESS;
}
Example #7
0
IOEventFlags jshPinWatch(Pin pin, bool shouldWatch) {
  if (!jshIsPinValid(pin)) return EV_NONE;
  uint32_t p = (uint32_t)pinInfo[pin].pin;
  if (shouldWatch) {
    nrf_drv_gpiote_in_config_t cls_1_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    nrf_drv_gpiote_in_init(p, &cls_1_config, jsvPinWatchHandler);
    nrf_drv_gpiote_in_event_enable(p, true);
    return jshGetEventFlagsForWatchedPin(p);
  } else {
    nrf_drv_gpiote_in_event_disable(p);
    return EV_NONE;
  }
} // start watching pin - return the EXTI associated with it
void nrf_gpiote_init(void){

    uint32_t err_code;
    if(!nrf_drv_gpiote_is_init())
      {
        err_code = nrf_drv_gpiote_init();
      }
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t rfid_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    rfid_config.pull = NRF_GPIO_PIN_PULLDOWN;

    nrf_drv_gpiote_in_init(RFID_INTERRUPT_PIN, &rfid_config, pin_event_handler);

    nrf_drv_gpiote_in_event_enable(RFID_INTERRUPT_PIN, true);
}
Example #9
0
uint32_t app_button_init(app_button_cfg_t *             p_buttons,
                         uint8_t                        button_count,
                         uint32_t                       detection_delay)
{
    uint32_t err_code;
    
    if (detection_delay < APP_TIMER_MIN_TIMEOUT_TICKS)
    {
        return NRF_ERROR_INVALID_PARAM;
    }

    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    }

    // Save configuration.
    mp_buttons          = p_buttons;
    m_button_count      = button_count;
    m_detection_delay   = detection_delay;

    m_pin_state      = 0;
    m_pin_transition = 0;
    
    while (button_count--)
    {
        app_button_cfg_t * p_btn = &p_buttons[button_count];

        nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        config.pull = p_btn->pull_cfg;
        
        err_code = nrf_drv_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    }

    // Create polling timer.
    return app_timer_create(&m_detection_delay_timer_id,
                            APP_TIMER_MODE_SINGLE_SHOT,
                            detection_delay_timeout_handler);
}
Example #10
0
uint32_t app_gpiote_user_register(app_gpiote_user_id_t     * p_user_id,
                                  uint32_t                   pins_low_to_high_mask,
                                  uint32_t                   pins_high_to_low_mask,
                                  app_gpiote_event_handler_t event_handler)
{
    uint32_t user_pin_mask;
    uint32_t ret_val = NRF_SUCCESS;

    // Check state and parameters.
    VERIFY_MODULE_INITIALIZED();

    if (event_handler == NULL)
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (m_user_count >= m_user_array_size)
    {
        return NRF_ERROR_NO_MEM;
    }

    user_pin_mask = pins_low_to_high_mask | pins_high_to_low_mask;
    // Allocate new user.
    mp_users[m_user_count].pins_mask             = user_pin_mask;
    mp_users[m_user_count].pins_low_to_high_mask = pins_low_to_high_mask;
    mp_users[m_user_count].pins_high_to_low_mask = pins_high_to_low_mask;
    mp_users[m_user_count].event_handler         = event_handler;
    mp_users[m_user_count].enabled               = false;

    *p_user_id = m_user_count++;

    uint32_t mask = 1;
    uint32_t i;
    const nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    for (i = 0; i < 32; i++)
    {
        if ((mask & user_pin_mask) & ~m_pins)
        {
            ret_val = nrf_drv_gpiote_in_init(i, &config, gpiote_handler);
            VERIFY_SUCCESS(ret_val);
            m_pins |= mask;
        }
        mask <<= 1;
    }
    return ret_val;
}
Example #11
0
static void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

    err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}
Example #12
0
/**
 * @brief GPIO初期化
 */
static void gpio_init(void)
{
    ret_code_t err_code;
    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(true);	/* 初期値 : 1 */
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);	/* 立ち下がり,EVENT使用 */

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

	/* output */
    err_code = nrf_drv_gpiote_out_init(LED_PIN_NO_ADVERTISING, &out_config);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_out_init(LED_PIN_NO_CONNECTED, &out_config);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_out_init(LED_PIN_NO_ASSERT, &out_config);
    APP_ERROR_CHECK(err_code);

	/* input */
    in_config.pull = NRF_GPIO_PIN_NOPULL;
    err_code = nrf_drv_gpiote_in_init(RCS730_IRQ, &in_config, gpiote_irq_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_gpiote_in_event_enable(RCS730_IRQ, true);
}
Example #13
0
uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params,
                       app_uart_buffers_t           * p_buffers,
                       app_uart_event_handler_t       event_handler,
                       app_irq_priority_t             irq_priority,
                       uint16_t                     * p_app_uart_uid)
{
    uint32_t err_code;

    m_current_state = UART_OFF;
    m_event_handler = event_handler;
    m_rx_byte       = BYTE_INVALID;


    // Configure RX and TX pins.
    nrf_gpio_pin_set(p_comm_params->tx_pin_no);
    nrf_gpio_cfg_output(p_comm_params->tx_pin_no);
    nrf_gpio_cfg_input(p_comm_params->rx_pin_no, NRF_GPIO_PIN_PULLUP);


    NRF_UART0->PSELTXD = p_comm_params->tx_pin_no;
    NRF_UART0->PSELRXD = p_comm_params->rx_pin_no;

    // Configure baud rate and parity.
    NRF_UART0->BAUDRATE = (p_comm_params->baud_rate << UART_BAUDRATE_BAUDRATE_Pos);

    if (p_comm_params->use_parity)
    {
        NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos);
    }
    else
    {
        NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos);
    }

    if (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_LOW_POWER)
    {
        if (!nrf_drv_gpiote_is_init())
        {
            err_code = nrf_drv_gpiote_init();
            if (err_code != NRF_SUCCESS)
            {
                return err_code;
            }
        }

        // Configure hardware flow control.
        nrf_drv_gpiote_out_config_t rts_config = GPIOTE_CONFIG_OUT_SIMPLE(true);
        err_code = nrf_drv_gpiote_out_init(p_comm_params->rts_pin_no, &rts_config);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }

        NRF_UART0->PSELCTS = UART_PIN_DISCONNECTED;
        NRF_UART0->PSELRTS = p_comm_params->rts_pin_no;
        NRF_UART0->CONFIG |= (UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos);

        // Setup the gpiote to handle pin events on cts-pin.
        // For the UART we want to detect both low->high and high->low transitions in order to
        // know when to activate/de-activate the TX/RX in the UART.
        // Configure pin.
        nrf_drv_gpiote_in_config_t cts_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        err_code = nrf_drv_gpiote_in_init(p_comm_params->cts_pin_no, &cts_config, gpiote_uart_event_handler);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }

        nrf_drv_gpiote_in_event_enable(p_comm_params->cts_pin_no, true);

        // UART CTS pin is active when low.
        if (nrf_drv_gpiote_in_is_set(p_comm_params->cts_pin_no))
        {
            on_uart_event(ON_CTS_HIGH);
        }
        else
        {
            on_uart_event(ON_CTS_LOW);
        }
    }
    else if (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_ENABLED)
    {
        uart_standard_flow_control_init(p_comm_params);
        m_current_state = UART_READY;
    }
    else
    {
        uart_no_flow_control_init();
        m_current_state = UART_READY;
    }
    if (*p_app_uart_uid == UART_INSTANCE_ID_INVALID)
    {
        *p_app_uart_uid = m_instance_counter++;
    }

    // Enable UART interrupt
    NRF_UART0->INTENCLR = 0xffffffffUL;
    NRF_UART0->INTENSET = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) |
                          (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) |
                          (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);

    NVIC_ClearPendingIRQ(UART_IRQ);
    NVIC_SetPriority(UART_IRQ, irq_priority);
    NVIC_EnableIRQ(UART_IRQ);

    return NRF_SUCCESS;
}
Example #14
0
    nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
    NVIC_SetPriority(ADC_IRQn, APP_IRQ_PRIORITY_LOW);
    NVIC_EnableIRQ(ADC_IRQn);
}

static void btn_initialize(void)
{
    nrf_drv_gpiote_in_config_t cfg = {
        .is_watcher = false,
        .hi_accuracy = false,
        .pull = NRF_GPIO_PIN_PULLUP,
        .sense = NRF_GPIOTE_POLARITY_HITOLO,
    };
    ret_code_t err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_in_init(BUTTON_USER, &cfg, btn_pressed_cb);
    APP_ERROR_CHECK(err_code);
    nrf_drv_gpiote_in_event_enable(BUTTON_USER, true);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    unsigned role = role_get();
    g_role = role & ROLE_MASK;
    BUG_ON(g_role >= MAX_GR_ROLES);
    nrf_gpio_cfg_output(LED_PWR);
    btn_initialize();
    adc_initialize();
Example #15
0
/** @brief Function for initializing PPI used in infrared signal decoding
 *   The PPI is needed to convert the timer event into a task.
 */
uint32_t ir_ppi_init(void)
{

    uint32_t gpiote_event_addr;
    uint32_t timer_task_addr;
    nrf_ppi_channel_t ppi_channel;
    ret_code_t err_code;
    nrf_drv_gpiote_in_config_t config; 

    config.sense = NRF_GPIOTE_POLARITY_HITOLO;
    config.pull = NRF_GPIO_PIN_PULLUP;
    config.hi_accuracy = false;
    config.is_watcher = false;

    nrf_drv_timer_config_t timer_config;

    timer_config.frequency            = NRF_TIMER_FREQ_1MHz;
    timer_config.mode                 = NRF_TIMER_MODE_TIMER;
    timer_config.bit_width            = NRF_TIMER_BIT_WIDTH_32;
    timer_config.interrupt_priority   = 3;

    err_code = nrf_drv_timer_init(&ir_timer, &timer_config, timer_dummy_handler);
    APP_ERROR_CHECK(err_code);


    // Set up GPIOTE
    err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_1, &config, ir_in_pin_handler);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_2, &config, ir_in_pin_handler);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_3, &config, ir_in_pin_handler);
    APP_ERROR_CHECK(err_code);



    // Set up timer for capturing
    nrf_drv_timer_capture_get(&ir_timer, NRF_TIMER_CC_CHANNEL0);

    // Set up PPI channel
    err_code = nrf_drv_ppi_channel_alloc(&ppi_channel);
    APP_ERROR_CHECK(err_code);

    timer_task_addr = nrf_drv_timer_capture_task_address_get(&ir_timer, NRF_TIMER_CC_CHANNEL0);
    gpiote_event_addr = nrf_drv_gpiote_in_event_addr_get(IR_RECEIVER_PIN_1);

    //err_code = nrf_drv_ppi_channel_assign(ppi_channel, gpiote_event_addr, timer_task_addr);
    //APP_ERROR_CHECK(err_code);

    //err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    //APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_1, true);
    nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_2, true);
    nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_3, true);


    
    // Enable timer
    nrf_drv_timer_enable(&ir_timer);

    return 0;

}