Announcement

Collapse
No announcement yet.

Default power on state of GPIO

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default power on state of GPIO

    I have two Matchport ARs that both have their inputs connected to a common wire that is used to signal to both of the input is high or low.

    It seems like sometimes there is a race condition where one of the Matchports read zero on start up, one is pulling the other down?

    Is this setup possible? Are the gpio inputs tri-state when powering up?

  • #2
    Need a bit more information. Which pins exactly, Evolution OS? Standard firmware, or custom firmware? Is the CP Manager being used?
    Normally, at boot up, the pins should be inputs.

    Comment


    • #3
      Hi Gary,

      Thank you for responding,

      Linux OS, Standard Firmware, with GPIO enabled for the pins, CP Manager is disabled, I am driving the GPIO pins using the libcp calls like in the LED example:

      So after the initial cp_config_init() call, if it matches 7 for the number of Matchport AR Pins I use almost all the pins in various ways as inputs and outputs:

      Code:
      #define LAN_CAB_ID_A_PIN (6)
      #define LAN_CAB_ID_B_PIN (7)
      
              /* Configure Lantronix CPM pins 1 to 7 IO */
      
              int ret = 0;
              for(i = 1; i < (NUM_CPM_PINS + 1); i++)
              {
                  ret = cp_config_invert_set(i, 0 ); /* TURN OFF PIN INVERSION */
      
                  switch(i)
                  {
                      case AVR_BOOT_PIN:
                      {
                          ret = cp_config_state_set(AVR_BOOT_PIN, 1);      /* ENABLED PIN */
      
                          if (ret < 0)
                          {
                              fprintf(stderr, "\nFAILED TO ENABLE PIN [%d]\n", i);
                          }
      
                          ret = cp_config_type_set(AVR_BOOT_PIN, CPM_OUTPUT);    /* CPM1 OUTPUT */
      
                          if (ret < 0)
                          {
                              fprintf(stderr, "\nFAILED TO SET OUTPUT PIN [%d]\n", i);
                          }
      
                          ret = cp_config_data_output(AVR_BOOT_PIN, 0);          /* OUTPUT LOW */
      
                          if (ret < 0)
                          {
                              fprintf(stderr, "\nFAILED TO SET PIN [%d] OUTPUT LOW\n", i);
                          }
      
                          break;
                      }
                      case AVR_RESET_PIN:
                          cp_config_state_set(AVR_RESET_PIN, 1);              /* ENABLED PIN */
                          cp_config_type_set(AVR_RESET_PIN, CPM_OUTPUT);   /* CPM2 OUTPUT */
                          cp_config_data_output(AVR_RESET_PIN, 0);         /* OUTPUT LOW */
                          break;
      
                      case LAN_ETH_ID_PIN:
                          cp_config_state_set(LAN_ETH_ID_PIN, 1);      /* ENABLED PIN */
                          cp_config_type_set(LAN_ETH_ID_PIN, CPM_INPUT);      /* CPM3 INPUT */
      
                          break;
      
                      case LAN_UNUSED_PIN4:
                          cp_config_type_set(LAN_UNUSED_PIN4, CPM_INPUT); /* CPM4 INPUT */
                          cp_config_state_set(LAN_UNUSED_PIN4, 0);      /* DISABLED PIN */
                          break;    
      
                      case LAN_UNUSED_PIN5:
                          cp_config_type_set(LAN_UNUSED_PIN5, CPM_INPUT); /* CPM5 INPUT */
                          cp_config_state_set(LAN_UNUSED_PIN5, 0);      /* DISABLED PIN */
                          break;    
                  case LAN_CAB_ID_A_PIN:
                  {
                      ret = cp_config_state_set(LAN_CAB_ID_A_PIN, 1);      /* ENABLED PIN */
                      if (ret < 0)
                      {
                          fprintf(stderr, "\nFAILED TO ENABLE PIN [%d] CAB_ID_A GPIO\n", i);
                      }
                      else
                      {
                          fprintf(stderr, "\nENABLED PIN [%d] CAB_ID_A GPIO\n", i);
                      }
      
                      ret = cp_config_type_set(LAN_CAB_ID_A_PIN, CPM_INPUT); /* CPM6 INPUT */
      
                      if (ret < 0)
                      {
                          fprintf(stderr, "\nFAILED TO SET PIN CAB_ID_A GPIO [%d] AS INPUT\n", i);
                      }
                      else
                      {
                          fprintf(stderr, "\nSET PIN [%d] CAB_ID_A GPIO AS INPUT\n", i);
                      }
                      break;
                  }
                  case LAN_CAB_ID_B_PIN:
                      ret = cp_config_state_set(LAN_CAB_ID_B_PIN, 1);      /* ENABLED PIN */
                      if (ret < 0)
                      {
                          fprintf(stderr, "\nFAILED TO ENABLE PIN CAB_ID_B GPIO [%d]\n", i);
                      }
                      else
                      {
                          fprintf(stderr, "\nENABLED PIN CAB_ID_B GPIO[%d]\n", i);
                      }
                      ret = cp_config_type_set(LAN_CAB_ID_B_PIN, CPM_INPUT); /* CPM7 INPUT */
                      if (ret < 0)
                      {
                          fprintf(stderr, "\nFAILED TO SET PIN [%d] CAB_ID_B GPIO AS INPUT\n", i);
                      }
                      else
                      {
                          fprintf(stderr, "\nSET PIN [%d] CAB_ID_B GPIO AS INPUT\n", i);
                      }
                      break;
      
                  default:
                      // TODO: GENERATE EVENT?
                      printf("\nNOT SUPPOSED TO BE HERE \n");
                      cp_config_type_set(i, CPM_INPUT); /* SET CPM TO INPUT, SAFEST */
                      cp_config_state_set(i, 0);      /* DISABLED PIN */
                      cp_config_exit();
                      break;
      
              }

      The two Matchport ARs power up at the same time, and GPIO Pin 6 is connect to the other GPIO pin 6 so both Matchports get the input at the same time, same with GPIO Pin 7:

      Picture of setup:


      https://ibb.co/dGdshHw



      Am I initializing the GPIO correctly?

      Thank you
      Last edited by zacharoni16; 04-30-2019, 12:09 PM.

      Comment


      • #4
        Try setting the 'type / direction' before enabling 'state_set the pin'

        Comment


        • #5
          Thank you, I will try this later today! Do you know the difference between cp_input_data and cp_input_level? Would cp_input_level() be better for reading if a signal was high or low ?

          Comment

          Working...
          X