This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I Have a Problem About Pin_Read

Here is my code...


#include "Tus_Tarama_Deneme.h"
#include <stdbool.h>
#include <stdint.h>
#include "boards.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf.h"
#include "nrf_drv_gpiote.h"
#include "app_error.h"
#include "nrf_drv_timer.h"
#include "app_timer.h"
#include "app_button.h"
#include "nrf_drv_ppi.h"
#include "nrf_drv_timer.h"
#include "nrf_fstorage.h"
#include "nordic_common.h"
#include "ble.h"
#include "ble_err.h"
#include "ble_hci.h"
#include "ble_srv_common.h"
#include "ble_advdata.h"
#include "ble_conn_params.h"
#include "nrf_sdh.h"
#include "nrf_sdh_ble.h"
#include "ble_lbs.h"
#include "nrf_ble_gatt.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
unsigned char LED_YAN = 1;
unsigned char LED_SON = 0;
void gpio_init(void)
{
  nrf_gpio_range_cfg_input(16,10,NRF_GPIO_PIN_PULLUP);
}

void Tarama_Basla_Deneme(void)
{
  nrf_gpio_cfg_output(SUTUN_1);
  nrf_gpio_pin_set(LED_4);
  if(nrf_gpio_pin_read(SATIR_5))
  {
    nrf_gpio_pin_write(LED_DENEME, LED_YAN);
  }
  else
  {
    nrf_gpio_pin_write(LED_DENEME, LED_SON);
  }

  for(;;)
  {
    nrf_gpio_pin_clear(SUTUN_1);
    nrf_delay_ms(50);
    nrf_gpio_pin_set(SUTUN_1);
    nrf_delay_ms(50);
  }

}

and here is header file..

#define SUTUN_1       25
#define SUTUN_2       20
#define SUTUN_3       18
#define SATIR_1       16
#define SATIR_2       15
#define SATIR_3       14
#define SATIR_4       12
#define SATIR_5       10
#define LED_DENEME    15

 I want to when i pussed P0.25 P0.10 is read pulse and set I P0.15. Where is my mistake

Parents
  • #include "Tus_Tarama_Deneme.h"
    #include <stdbool.h>
    #include <stdint.h>
    #include "boards.h"
    #include "nrf_delay.h"
    #include "nrf_gpio.h"
    #include "nrf.h"
    #include "nrf_drv_gpiote.h"
    #include "app_error.h"
    #include "nrf_drv_timer.h"
    #include "app_timer.h"
    #include "app_button.h"
    #include "nrf_drv_ppi.h"
    #include "nrf_drv_timer.h"
    #include "nrf_fstorage.h"
    #include "nordic_common.h"
    #include "ble.h"
    #include "ble_err.h"
    #include "ble_hci.h"
    #include "ble_srv_common.h"
    #include "ble_advdata.h"
    #include "ble_conn_params.h"
    #include "nrf_sdh.h"
    #include "nrf_sdh_ble.h"
    #include "ble_lbs.h"
    #include "nrf_ble_gatt.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    unsigned char LED_YAN = 1;
    unsigned char LED_SON = 0;
    
    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_drv_gpiote_out_toggle(LED_DENEME);
    }
    
    void Tarama_Basla_Deneme(void)
    {
      nrf_drv_gpiote_init();
      nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
      nrf_drv_gpiote_out_init(LED_DENEME, &out_config);
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
      in_config.pull = NRF_GPIO_PIN_PULLUP;
      nrf_drv_gpiote_in_init(SATIR_4, &in_config, in_pin_handler);
      nrf_drv_gpiote_in_event_enable(SATIR_4, true);
      nrf_gpio_cfg_output(SUTUN_1);
      for(;;)
      {
        nrf_gpio_pin_clear(SUTUN_1);
        nrf_delay_ms(50);
        nrf_gpio_pin_set(SUTUN_1);
        nrf_delay_ms(50);
      }
    
    }
    

    here is my solition. 

Reply
  • #include "Tus_Tarama_Deneme.h"
    #include <stdbool.h>
    #include <stdint.h>
    #include "boards.h"
    #include "nrf_delay.h"
    #include "nrf_gpio.h"
    #include "nrf.h"
    #include "nrf_drv_gpiote.h"
    #include "app_error.h"
    #include "nrf_drv_timer.h"
    #include "app_timer.h"
    #include "app_button.h"
    #include "nrf_drv_ppi.h"
    #include "nrf_drv_timer.h"
    #include "nrf_fstorage.h"
    #include "nordic_common.h"
    #include "ble.h"
    #include "ble_err.h"
    #include "ble_hci.h"
    #include "ble_srv_common.h"
    #include "ble_advdata.h"
    #include "ble_conn_params.h"
    #include "nrf_sdh.h"
    #include "nrf_sdh_ble.h"
    #include "ble_lbs.h"
    #include "nrf_ble_gatt.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    unsigned char LED_YAN = 1;
    unsigned char LED_SON = 0;
    
    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_drv_gpiote_out_toggle(LED_DENEME);
    }
    
    void Tarama_Basla_Deneme(void)
    {
      nrf_drv_gpiote_init();
      nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
      nrf_drv_gpiote_out_init(LED_DENEME, &out_config);
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
      in_config.pull = NRF_GPIO_PIN_PULLUP;
      nrf_drv_gpiote_in_init(SATIR_4, &in_config, in_pin_handler);
      nrf_drv_gpiote_in_event_enable(SATIR_4, true);
      nrf_gpio_cfg_output(SUTUN_1);
      for(;;)
      {
        nrf_gpio_pin_clear(SUTUN_1);
        nrf_delay_ms(50);
        nrf_gpio_pin_set(SUTUN_1);
        nrf_delay_ms(50);
      }
    
    }
    

    here is my solition. 

Children
No Data
Related