/*
Function: bprTbEachLedBlink
Description: the led blink one by one, and support four operating modes
*/
void bprTbEachLedBlink(int dly, int opt)
{
	int pin = 1;

	for(;;)
	{
		switch(opt)
		{
			case SYS:
			case BCM:
				digitalWrite(physPinToGpio(pin), HIGH);
				delay(dly);
				digitalWrite(physPinToGpio(pin), LOW);
				delay(dly);
				break;
			case WPI:
				digitalWrite(physPinToPin(pin), HIGH);
				delay(dly);
				digitalWrite(physPinToPin(pin), LOW);
				delay(dly);
				break;
			case PHY:
				digitalWrite(pin, HIGH);
				delay(dly);
				digitalWrite(pin, LOW);
				delay(dly);
				break;
		}
		
		pin = pin +1;
		if(pin > PHY_PIN_MAX)
			pin = 1;
	}

}
/*
Funciton: bprTbAllLedBlink
Description: all leds blink at the same time, and support four operating modes
*/
void bprTbAllLedBlink(int val, int opt)
{
	int pinNum;

	for(pinNum=1; pinNum<=PHY_PIN_MAX; pinNum++)
	{       
		switch(opt)
		{
			case SYS:
			case BCM:
				pinMode(physPinToGpio(pinNum), OUTPUT);
				digitalWrite(physPinToGpio(pinNum), val);
				break;
			case WPI:
				pinMode(physPinToPin(pinNum), OUTPUT);
				digitalWrite(physPinToPin(pinNum), val);
				break;
			case PHY:
				pinMode(pinNum, OUTPUT);
				digitalWrite(pinNum, val);
				break;
			default:
				printf("the BPR test Board 01 init failed!\n");
				break;
		}
	}
}
Example #3
0
static void readallPhys (int physPin)
{
  int pin ;

  if (physPinToGpio (physPin) == -1)
    printf (" |     |    ") ;
  else
    printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi [physPin]) ;

  printf (" | %s", physNames [physPin]) ;

  if (physToWpi [physPin] == -1)
    printf (" |      |  ") ;
  else
  {
    /**/ if (wpMode == WPI_MODE_GPIO)
      pin = physPinToGpio (physPin) ;
    else if (wpMode == WPI_MODE_PHYS)
      pin = physPin ;
    else
      pin = physToWpi [physPin] ;

    printf (" | %4s", alts [getAlt (pin)]) ;
    printf (" | %d", digitalRead (pin)) ;
  }

// Pin numbers:

  printf (" | %2d", physPin) ;
  ++physPin ;
  printf (" || %-2d", physPin) ;

// Same, reversed

  if (physToWpi [physPin] == -1)
    printf (" |   |     ") ;
  else
  {
    /**/ if (wpMode == WPI_MODE_GPIO)
      pin = physPinToGpio (physPin) ;
    else if (wpMode == WPI_MODE_PHYS)
      pin = physPin ;
    else
      pin = physToWpi [physPin] ;

    printf (" | %d", digitalRead (pin)) ;
    printf (" | %-4s", alts [getAlt (pin)]) ;
  }

  printf (" | %-5s", physNames [physPin]) ;

  if (physToWpi     [physPin] == -1)
    printf (" |     |    ") ;
  else
    printf (" | %-3d | %-3d", physToWpi [physPin], physPinToGpio (physPin)) ;

  printf (" |\n") ;
}
Example #4
0
static foreign_t
pl_physPinToGpio (term_t physPin_,term_t t){
	int physPin;	
	if (!PL_get_integer(physPin_,&physPin))
	{
		PL_warning("Argument 'physPin' not number");
		PL_fail;
	}

	return PL_unify_integer(t,physPinToGpio(physPin));
}
Example #5
0
/* physPinToGpio
 *
 * Parameters:
 * - physPin: int
 * Return Type: int
 */
mrb_value
mrb_Pi_physPinToGpio(mrb_state* mrb, mrb_value self) {
  mrb_int native_physPin;

  /* Fetch the args */
  mrb_get_args(mrb, "i", &native_physPin);

  /* Invocation */
  int result = physPinToGpio(native_physPin);

  /* Box the return value */
  mrb_value return_value = mrb_fixnum_value(result);

  return return_value;
}