Beispiel #1
0
void app_start(int, char *[])
{
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(rtc_auto);
    MBED_HOSTTEST_DESCRIPTION(Calendar test);
    MBED_HOSTTEST_START("Calendar");

    /* set unix time */
    struct timeval localTVS;
    localTVS.tv_sec = 1451606397;
    settimeofday(&localTVS, NULL);

    /* schedule tasks */
    minar::Scheduler::postCallback(printTime)
        .period(minar::milliseconds(1000));
}
Beispiel #2
0
void app_start(int, char*[]) {
    // !!! FIXME: make this asynchronous

    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(wait_us_auto);
    MBED_HOSTTEST_DESCRIPTION(Time us);
    MBED_HOSTTEST_START("MBED_25");

    while (true) {
        for (int i = 0; i < MS_INTERVALS; i++) {
            wait_us(1000);
        }
        led = !led; // Blink
        print_char();
    }
}
Beispiel #3
0
int main(void) {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(wait_us_auto);
    MBED_HOSTTEST_DESCRIPTION(Timer);
    MBED_HOSTTEST_START("RTOS_7");

    RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
    RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
    RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
    RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);

    led_1_timer.start(200);
    led_2_timer.start(100);
    led_3_timer.start(50);
    led_4_timer.start(25);

    Thread::wait(osWaitForever);
}
Beispiel #4
0
int main()
{
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(DigitalInOut);
    MBED_HOSTTEST_START("MBED_A6");

    bool check = true;

    d1.output();
    d2.input();
    d1 = 1;
    wait(0.1);
    if (d2 != 1) {
        printf("MBED: First check failed! d2 is %d\n", (int)d2);
        check = false;
    }
    d1 = 0;
    wait(0.1);
    if (d2 != 0) {
        printf("MBED: Second check failed! d2 is %d\n", (int)d2);
        check = false;
    }

    d1.input();
    d2.output();
    d2 = 1;
    wait(0.1);
    if (d1 != 1) {
        printf("MBED: Third check failed! d1 is %d\n", (int)d1);
        check = false;
    }
    d2 = 0;
    wait(0.1);
    if (d1 != 0) {
        printf("MBED: Fourth check failed! d1 is %d\n", (int)d1);
        check = false;
    }

    MBED_HOSTTEST_RESULT(check);
}
Beispiel #5
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(dev_null);
    MBED_HOSTTEST_DESCRIPTION(CAN Loopback);
    MBED_HOSTTEST_START("MBED_A27");

#if !defined(TARGET_VK_RZ_A1H)
    can1.mode(CAN::Reset);
#endif

    if (!can1.mode(CAN::LocalTest)) {
        printf("Mode change failed\n");
    }

    char success_count = 0;
    for (char i=0; i < TEST_ITERATIONS; i++) {
        unsigned int id = 1337;
        CANMessage tx_msg(id, &i, sizeof(i));
        bool sent = false;
        if (can1.write(tx_msg)) {
            printf("Sent %u: %d\n", id, i);
            sent = true;
        }
        wait_ms(50);

        bool read = false;
        CANMessage rx_msg;
        if (can1.read(rx_msg)) {
            printf("Read %u: %d\n", rx_msg.id, rx_msg.data[0]);
            read = (rx_msg.id == id) && (rx_msg.data[0] == i);
        }

        bool success = sent && read;

        if (success) {
            success_count++;
        }
    }

    MBED_HOSTTEST_RESULT(success_count == TEST_ITERATIONS);
}
Beispiel #6
0
int main() {
    Serial *pc = new Serial(USBTX, USBRX);

    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(serial_nc_rx_auto);
    MBED_HOSTTEST_DESCRIPTION(Serial NC RX);
    MBED_HOSTTEST_START("MBED_37");

    char c = pc->getc();


    // This should be true, sync the start of test
    if (c == 'S') {
        pc->printf("RX OK - Start NC test\r\n");

        // disconnect TX and  get char
        delete pc;
        pc = new Serial(NC, USBRX);
        c = pc->getc();
        if (c == 'E') {
            // ok disconnect Rx and answer to host
            delete pc;
            pc = new Serial(USBTX, NC);
            pc->printf("RX OK - Expected\r\n");

            c = pc->getc();
            // This should be false/not get here
            if (c == 'U') {
                pc->printf("RX OK - Unexpected\r\n");
            }
        }
        delete pc;
    }

    while (1) {
    }
}
Beispiel #7
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(PortOut PortIn);
    MBED_HOSTTEST_START("MBED_A10");

    port_out = MASK_1;
    wait(0.1);
    int value = port_in.read();
    if (value != MASK_2) {
        printf("[Test high] expected (0x%x) received (0x%x)\n", MASK_2, value);
        notify_completion(false);
    }

    port_out = 0;
    wait(0.1);
    value = port_in.read();
    if (value != 0) {
        printf("[Test low] expected (0x%x) received (0x%x)\n", 0, value);
        notify_completion(false);
    }

    notify_completion(true);
}
Beispiel #8
0
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(I2C EEPROM read write test);
    MBED_HOSTTEST_START("MBED_A19");

    const int EEPROM_MEM_ADDR = 0xA0;
    const char MARK = 0x66;
    int fw = 0;
    int fr = 0;
    int fc = 0;
    int i2c_stat = 0;
    bool result = true;

    i2c.frequency(i2c_freq_hz);
    printf("I2C: I2C Frequency: %d Hz\r\n", i2c_freq_hz);

    printf("I2C: Write 0x%2X at address 0x0000 test ... \r\n", MARK);
    // Data write
    {
        char data[] = { 0, 0, MARK };
        if ((i2c_stat = i2c.write(EEPROM_MEM_ADDR, data, sizeof(data))) != 0) {
            printf("Unable to write data to EEPROM (i2c_stat = 0x%02X), aborting\r\n", i2c_stat);
            notify_completion(false);
            return 1;
        }

        // ACK polling (assumes write will be successful eventually)
        while (i2c.write(EEPROM_MEM_ADDR, data, 0) != 0)
            ;
    }

    printf("I2C: Read data from address 0x0000 test ... \r\n");
    // Data read (actual test)
    for (int i = 0; i < ntests; i++) {
        // Write data to EEPROM memory
        {
            char data[] = { 0, 0 };
            if ((i2c_stat = i2c.write(EEPROM_MEM_ADDR, data, 2, true)) != 0) {
                printf("Test %d failed at write, i2c_stat is 0x%02X\r\n", i, i2c_stat);
                fw++;
                continue;
            }
        }

        // us delay if specified
        if (i2c_delay_us != 0)
            wait_us(i2c_delay_us);

        // Read data
        {
            char data[1] = { 0 };
            if ((i2c_stat = i2c.read(EEPROM_MEM_ADDR, data, 1)) != 0) {
                printf("Test %d failed at read, i2c_stat is 0x%02X\r\n", i, i2c_stat);
                fr++;
                continue;
            }

            if (data[0] != MARK) {
                printf("Test %d failed at data match\r\n", i);
                fc++;
            }
        }
    }

    result = (fw + fr + fc == 0);
    printf("EEPROM: Test result ... [%s]\r\n", result ? "OK" : "FAIL");

    if (!result) {
        printf("Test Statistics:\r\n");
        printf("\tTotal tests:     %d\r\n", ntests);
        printf("\tFailed at write: %d\r\n", fw);
        printf("\tFailed at read:  %d\r\n", fr);
        printf("\tData mismatch:   %d\r\n", fc);
        printf("\tTotal failures:  %d\r\n", fw + fr + fc);
    }

    MBED_HOSTTEST_RESULT(result);
}