int main(void) { qm_rtc_config_t rtc_cfg; unsigned int count = 0; /* loop_max : Maximum number of iterations. * A value of 50 will run the application for roughly 30s. */ const unsigned int loop_max = 50; gpio_init(); pin_mux_setup(); gpio_set_out(BOARD_LED_PIN, 0); /* Configure the onboard LED pin. */ /* Clear Screen. */ QM_PUTS("Starting: Power Profiler"); QM_PUTS("Low power mode example."); QM_PRINTF("Increment = %d\n", QM_RTC_ALARM_SECOND(CLK_RTC_DIV_1)); clk_periph_enable(CLK_PERIPH_RTC_REGISTER | CLK_PERIPH_CLK); /* Initialise RTC configuration: Run, but don't interrupt. */ rtc_cfg.init_val = 0; rtc_cfg.alarm_en = 0; rtc_cfg.alarm_val = QM_RTC_ALARM_SECOND(CLK_RTC_DIV_1); rtc_cfg.callback = rtc_example_callback; rtc_cfg.prescaler = CLK_RTC_DIV_1; qm_rtc_set_config(QM_RTC_0, &rtc_cfg); QM_IR_UNMASK_INT(QM_IRQ_RTC_0_INT); QM_IRQ_REQUEST(QM_IRQ_RTC_0_INT, qm_rtc_0_isr); #if (!QM_SENSOR) test_clock_rates(); #endif /* Enable the RTC Interrupt. */ rtc_cfg.alarm_en = 1; qm_rtc_set_config(QM_RTC_0, &rtc_cfg); count = 0; while (++count < loop_max) { QM_PRINTF("\nC:%d R:%d => ", count, rtc_tick); slow_mode_test(); halt_test(); core_sleep_test(); /* TODO : Enable soc_sleep test for c1000. */ soc_sleep_test(); /* TODO : Enable soc_deep_sleep test for d2000 and c1000. */ soc_deep_sleep_test(); } SOC_WATCH_TRIGGER_FLUSH(); QM_PUTS("Finished: Power Profiler"); return 0; }
int main(void) { qm_rtc_config_t rtc_cfg; unsigned int count = 0; /* Maximum number of 3-second iterations. */ const unsigned int loop_max = 5; gpio_init(); gpio_set_out(BOARD_LED_PIN, 0); /* Configure the onboard LED pin. */ /* Clear Screen. */ QM_PUTS("Starting: Power Profiler"); QM_PUTS("Low power mode example."); QM_PRINTF("Increment = %d\n", QM_RTC_ALARM_SECOND(CLK_RTC_DIV_1)); clk_periph_enable(CLK_PERIPH_RTC_REGISTER | CLK_PERIPH_CLK); /* Initialise RTC configuration: Run, but don't interrupt. */ rtc_cfg.init_val = 0; rtc_cfg.alarm_en = 0; rtc_cfg.alarm_val = QM_RTC_ALARM_SECOND(CLK_RTC_DIV_1); rtc_cfg.callback = rtc_example_callback; rtc_cfg.prescaler = CLK_RTC_DIV_1; qm_rtc_set_config(QM_RTC_0, &rtc_cfg); qm_irq_request(QM_IRQ_RTC_0_INT, qm_rtc_0_isr); test_clock_rates(); /* Enable the RTC Interrupt. */ rtc_cfg.alarm_en = 1; qm_rtc_set_config(QM_RTC_0, &rtc_cfg); count = 0; while (++count < loop_max) { QM_PRINTF("\nC:%d R:%d => ", count, rtc_tick); slow_mode_test(); halt_test(); sleep_test(); #if DEEP_SLEEP deep_sleep_test(); #endif } QM_PUTS("Finished: Power Profiler"); return 0; }
int unicorn_test(void) { int i = 0; int idx = 0; int num_fans = 0; double celsius = 0.0; channel_tag heater, fan, pwm; if (bbp_board_type == BOARD_BBP1S) { num_fans = 6; } else if (bbp_board_type == BOARD_BBP1) { num_fans = 5; } #if 0 start_test_thread(); int count = 10; while (1) { printf("wait evtout count=%d\n", count); prussdrv_pru_wait_event(PRU_EVTOUT_1); prussdrv_pru_clear_event(PRU_EVTOUT_1, PRU1_ARM_INTERRUPT); if(count-- == 0){ return; } } #endif printf("Test 1: Fan testing...\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 1: Fan testing...\n"); printf(" Please watch the led lights and leds on board\n"); printf(" 1.1 close all fans\n"); for (idx = 0; idx < num_fans; idx++) { fan = fan_lookup_by_index(idx); if (fan) { fan_disable(fan); } } printf(" 1.2 open each fan for 1s then close one by one\n"); for (idx = 0; idx < num_fans; idx++) { fan = fan_lookup_by_index(idx); if (fan) { printf(" Open %s\n", tag_name(fan)); fan_enable(fan); fan_set_level(fan, 80); sleep(1); printf(" Close %s\n", tag_name(fan)); fan_set_level(fan, 0); fan_disable(fan); } } printf(" 1.3 turn on all fans for 1s, then turn off, repeat 3 times\n"); for (i = 0; i < 2; i++) { for (idx = 0; idx < num_fans; idx++) { fan = fan_lookup_by_index(idx); if (fan) { fan_enable(fan); fan_set_level(fan, 80); } } sleep(1); for (idx = 0; idx < num_fans; idx++) { fan = fan_lookup_by_index(idx); if (fan) { fan_disable(fan); } } sleep(1); } printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 2: LMSW testing...\n"); printf(" 2.1 Please press min x: \n"); wait_lmsw_min_test(X_AXIS); printf(" min_x ok\n"); printf(" 2.2 Please press min y: \n"); wait_lmsw_min_test(Y_AXIS); printf(" min_y ok\n"); printf(" 2.3 Please press min z: \n"); wait_lmsw_min_test(Z_AXIS); printf(" min_z ok\n"); printf(" 2.4 Please press max x: \n"); wait_lmsw_max(X_AXIS); printf(" max_x ok\n"); printf(" 2.5 Please press max y: \n"); wait_lmsw_max(Y_AXIS); printf(" max_y ok\n"); printf(" 2.6 Please press max z: \n"); wait_lmsw_max(Z_AXIS); printf(" max_z ok\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 3: Heater testing...\n"); printf(" open each heater for 1s then close\n"); printf(" Please watch the led beside the heater interface!\n"); if (bbp_board_type == BOARD_BBP1S) { pwm = pwm_lookup_by_name("pwm_ext"); if (pwm) { pwm_set_output(pwm, 80); } sleep(1); pwm_set_output(pwm, 0); sleep(1); pwm = pwm_lookup_by_name("pwm_ext2"); if (pwm) { pwm_set_output(pwm, 80); } sleep(1); pwm_set_output(pwm, 0); sleep(1); pwm = pwm_lookup_by_name("pwm_bed"); if (pwm) { pwm_set_output(pwm, 80); } sleep(1); pwm_set_output(pwm, 0); sleep(1); for (i = 0; i < 2; i++) { pwm = pwm_lookup_by_name("pwm_ext"); if (pwm) { pwm_set_output(pwm, 80); } pwm = pwm_lookup_by_name("pwm_ext2"); if (pwm) { pwm_set_output(pwm, 80); } pwm = pwm_lookup_by_name("pwm_bed"); if (pwm) { pwm_set_output(pwm, 80); } sleep(4); pwm = pwm_lookup_by_name("pwm_ext"); if (pwm) { pwm_set_output(pwm, 0); } pwm = pwm_lookup_by_name("pwm_ext2"); if (pwm) { pwm_set_output(pwm, 0); } pwm = pwm_lookup_by_name("pwm_bed"); if (pwm) { pwm_set_output(pwm, 0); } sleep(2); } } if (bbp_board_type == BOARD_BBP1) { for (idx = 0; idx < NUM_HEATERS; idx++) { heater = heater_lookup_by_index(idx); if (heater) { printf(" Open %s\n", tag_name(heater)); heater_enable(heater); heater_set_raw_pwm(heater, 40); sleep(5); printf(" Close %s\n", tag_name(heater)); heater_set_raw_pwm(heater, 0); heater_disable(heater); } } } printf("done.\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 4: Stepper testing...\n"); printf(" 4.1 Turn on all stepper\n"); stepper_test(); printf(" 4.2 Stop Stepper\n"); printf(" Please press min x to stop stepper\n"); wait_lmsw_min(X_AXIS); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 5: USB Host testing...\n"); printf(" 5.1 please insert U mass storage\n"); if(unicorn_test_usb_storage() == -1){ halt_test("Usb mass storage is BAD!!!!!!!!!!!!!!!\n"); } printf("Usb mass storage is OK\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 6: Internal emmc testing...\n"); if(unicorn_test_emmc() == -1){ halt_test("Internal emmc is BAD!!!!!!!!!!!!!!\n"); } printf("Internal emmc is OK\n"); printf("done.\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 7: eeprom testing...\n"); if(unicorn_test_eeprom() == -1){ halt_test("eeprom is BAD!!!!!!!!!!!!\n"); } printf("eeprom is OK\n"); printf("done.\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 8: rtc testing...\n"); if(unicorn_test_rtc() == -1) { halt_test("rtc is BAD!!!!!!!!!!!!\n"); } printf("rtc is OK\n"); printf("done.\n"); printf("-------------------------------------------------------------\n"); printf("\n-------------------------------------------------------------\n"); printf("Test 9: Network testing...\n"); printf(" Start to ping the router..\n"); if(unicorn_test_network() == -1) { halt_test("network is BAD!!!!!!!!!!!!\n"); } printf("done.\n"); printf("-------------------------------------------------------------\n"); printf("Test 10: USB OTG testing...\n"); printf(" 11.1 Please connect usb otg line to PC\n"); printf(" 11.2 Could you see the boot partion? If yes, Please press min_x..\n"); wait_lmsw_min_test(X_AXIS); printf("done.\n"); printf("-------------------------------------------------------------\n"); if (bbp_board_type == BOARD_BBP1S) { printf("Test 11: Test max6675 temperature...\n"); printf("long press min y key to exit\n"); if(unicorn_test_max6675() == -1) { halt_test("max6675 is BAD!!!!!!!!!!!!\n"); } printf("\n-------------------------------------------------------------\n"); } #if 0 if (bbp_board_type == BOARD_BBP1S) { #ifdef SERVO printf("Test 12: Test servo...\n"); if (unicorn_test_servo()) { halt_test("servo is BAD!!!!!!!!!!!!\n"); } printf("\n-------------------------------------------------------------\n"); #endif } #endif printf("\n-------------------------------------------------------------\n"); printf("Test 12: Temp adc testing...\n"); heater_start(); if (bbp_board_type == BOARD_BBP1S) { char *heater_array_bbp1s[] = {"heater_ext", "heater_ext2", "heater_bed"}; for (idx = 0; idx < sizeof(heater_array_bbp1s)/sizeof(heater_array_bbp1s[0]); idx++) { heater = heater_lookup_by_name(heater_array_bbp1s[idx]); if (heater) { heater_enable(heater); heater_set_setpoint(heater, TARGET_TEMP); } } for (i = 0; i < 80 && stepper_check_lmsw(X_AXIS) == 0; i++) { for (idx = 0; idx < sizeof(heater_array_bbp1s)/sizeof(heater_array_bbp1s[0]); idx++) { heater = heater_lookup_by_name(heater_array_bbp1s[idx]); if (heater) { celsius = 0.0; heater_get_celsius(heater, &celsius); printf("%s -> %f\n", tag_name(heater), celsius); sleep(1); } } } } else if (bbp_board_type == BOARD_BBP1) { for (idx = 0; idx < NUM_HEATERS; idx++) { heater = heater_lookup_by_index(idx); if (heater) { heater_enable(heater); heater_set_setpoint(heater, TARGET_TEMP); } } printf("long press min x key to exit\n"); heater = heater_lookup_by_name("heater_bed"); for (i = 0; i < 80 && stepper_check_lmsw(X_AXIS) == 0; i++) { if (heater_temp_reached(heater)) { printf("ok\n"); break; } else { sleep(1); } for (idx = 0; idx < NUM_HEATERS; idx++) { heater = heater_lookup_by_index(idx); if (heater) { celsius = 0.0; heater_get_celsius(heater, &celsius); printf("%s -> %f\n", tag_name(heater), celsius); } } printf("\n"); } } heater_stop(); printf("done.\n"); printf("-------------------------------------------------------------\n"); halt_test("All is Good!\n"); return 0; }