Exemple #1
0
int main() {
    out = 0; myled = 0;
    //Test falling edges first
    in.rise(NULL);
    in.fall(in_handler);
    flipper();

    if(checks != 5) {
        printf("falling edges test failed: %d\n",checks);
        notify_completion(false);
    }

    //Now test rising edges
    in.rise(in_handler);
    in.fall(NULL);
    flipper();

    if (checks != 10) {
        printf("raising edges test failed: %d\n",checks);
        notify_completion(false);
    }

    //Finally test both
    in.rise(in_handler);
    in.fall(in_handler);
    flipper();

    if (checks != 20) {
        printf("Simultaneous rising and falling edges failed\n");
        notify_completion(false);
    }

    notify_completion(true);
    return 0;
}
Exemple #2
0
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(InterruptIn);
    MBED_HOSTTEST_START("MBED_A7");

    IN_OUT_CLEAR;
    //Test falling edges first
    in.rise(NULL);
    in.fall(in_handler);
    flipper();

    if(checks != 5) {
        printf("MBED: falling edges test failed: %d\r\n",checks);
        MBED_HOSTTEST_RESULT(false);
    }

    //Now test rising edges
    in.rise(in_handler);
    in.fall(NULL);
    flipper();

    if (checks != 10) {
        printf("MBED: raising edges test failed: %d\r\n", checks);
        MBED_HOSTTEST_RESULT(false);
    }

    //Now test switch off edge detection
    in.rise(NULL);
    in.fall(NULL);
    flipper();

    if (checks != 10) {
        printf("MBED: edge detection switch off test failed: %d\r\n", checks);
        MBED_HOSTTEST_RESULT(false);
    }

    //Finally test both
    in.rise(in_handler);
    in.fall(in_handler);
    flipper();

    if (checks != 20) {
        printf("MBED: Simultaneous rising and falling edges failed: %d\r\n", checks);
        MBED_HOSTTEST_RESULT(false);
    }

    MBED_HOSTTEST_RESULT(true);
}
int main(void) {
   unsigned int nextTime;
   short flip;

   if (wiringPiSetup () == -1)
    {
      fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
      fflush(stdout);
      return 1;
    }
   i2c = wiringPiI2CSetup (0x39);
   if (i2c == -1)
    {
      fprintf (stdout, "Unable to start I2C wiringPi: %s\n", strerror (errno)) ;
      fflush(stdout);
      return 1;
    }

    wiringPiI2CWriteReg8(i2c, 0x80, 0x03);
    

    nextTime = millis() + TIME_DELAY+400;
    int x = 0;
    for (;x<500;x++){
      //startReading();
      flip = !flip;
      flipper(flip);
      while (millis() < nextTime) {
      }
      readSensor();
      nextTime+=TIME_DELAY;
    }
}
Exemple #4
0
static bool test_once() {
    InterruptIn in(PIN_IN);
    checks = 0;
    printf("Interrupt table location: 0x%08X\r\n", SCB->VTOR);
    in.rise(NULL);
    in.fall(in_handler);
    flipper();
    in.fall(NULL);
    bool result = (checks == FALLING_EDGE_COUNT);
    printf("Falling edge checks counted: %d ... [%s]\r\n", checks, result ? "OK" : "FAIL");
    return result;
}