コード例 #1
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);
}
コード例 #2
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);
}