コード例 #1
0
ファイル: task_app.c プロジェクト: yujiecheung/mvp
static void app_on_timer_1s(void)
{
    if (g_is_second_led_on) {
        bsp_led_off(g_current_led);
        g_is_second_led_on = FALSE;
    } else {
        bsp_led_on(g_current_led);
        g_is_second_led_on = TRUE;
    }
}
コード例 #2
0
ファイル: task_led.c プロジェクト: yujiecheung/mvp
int task_led_second_handler(void *task, const void *msg)
{
    if (MSG_TIMER_1S == SYS_MSG) {
        if (g_is_second_led_on) {
            bsp_led_off(g_current_led);
            g_is_second_led_on = FALSE;
        } else {
            bsp_led_on(g_current_led);
            g_is_second_led_on = TRUE;
        }
    } else if (MSG_KEY_PRESS == SYS_MSG) {
        bsp_led_off(g_current_led);
        switch (get_virtual_key())
        {
        case VKEY_0: g_current_led = LED_RED; break;
        case VKEY_1: g_current_led = LED_YELLOW; break;
        case VKEY_2: g_current_led = LED_GREEN; break;
        case VKEY_3: g_current_led = LED_BLUE; break;
        default: break;
        }
    }

    return OSM_IGNORE;
}
コード例 #3
0
void service_user_led_on(void)
{
	bsp_led_on(ledUser);
	usart1_transmit_string("\r\nservice_user_led_on()\r\n");
}
コード例 #4
0
/*******************************************************************************
* Function Name  : main.
* Description    : main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

	/* Initialize the Demo */
	bsp_init_rcc();

	bsp_init_gpio();
	bsp_init_interrupt();
#ifdef DEV_KIT_ADC_CONV_TEST
    bsp_init_adc();
    DMA_Initial();
#endif /* DEV_KIT_ADC_CONV_TEST */

#ifdef DEV_KIT_STEP_MOTOR_TEST
    step_motor_enable(DISABLE);
#endif /* DEV_KIT_STEP_MOTOR_TEST */

	register_timer_function(timer2ServiceFunction, timer2_event);
#ifdef DEV_KIT_STEP_MOTOR_TEST
    register_timer_function(timer3ServiceFunction, isr_left_motor_event);
    register_timer_function(timer4ServiceFunction, isr_right_motor_event);    
#endif /* DEV_KIT_STEP_MOTOR_TEST */
	register_rtc_function(rtcServiceFunction, rtc_event);

	bsp_init_timer2();
#ifdef DEV_KIT_STEP_MOTOR_TEST
    bsp_init_timer3(DISABLE);
    bsp_init_timer4(DISABLE);    
#endif /* DEV_KIT_STEP_MOTOR_TEST */

	bsp_init_irq_usart1();
	//bsp_init_dma_usart1();

	// 10msec
	wait_10ms(1);

	// User LED ON
	bsp_led_on(ledUser);
#ifdef DEV_KIT_LED_TEST
    //led_rotate_test();
    s_satus_led_flag = 1; // Go status led
#endif /* DEV_KIT_LED_TEST */
	welcome();
	
	usart1_transmit_string("\r\n*****************************************************************************\r\n");	
	usart1_transmit_string("User led ( on )\r\n");
	usart1_transmit_string("Initialize gpio service.\r\n");
	usart1_transmit_string("Start USART1 service on mode interrupt.\r\n");
	usart1_transmit_string_format("BaudRate = %d, Databit = %dbit, StopBits = %d, Parity = no, FlowControl = none\r\n", 115200, 8, 1);
	usart1_transmit_string("\r\n*****************************************************************************\r\n");		

	display_menu();

	usart1_tx_proc();

	
#ifdef DEV_KIT_I2C_TOUCH_KEY_TEST
    i2c_GPIO_Config();
#endif /* DEV_KIT_I2C_TOUCH_KEY_TEST */

	while( 1 )
	{
#ifdef DEV_KIT_I2C_TOUCH_KEY_TEST
        i2c_Test_Example();
#endif /* DEV_KIT_I2C_TOUCH_KEY_TEST */

        
#ifdef DEV_KIT_ADC_CONV_TEST

//        test_func_adc_conv();
#endif /* DEV_KIT_ADC_CONV_TEST */
        
		if( run_menu_selection() != 0 )
			display_menu();

        motor_all(3000, ACT_GO_FORWARD, NOT_ADJUSMENT); // 300cm
        wait_1ms(2000); // 5seconds

        motor_all(3000, ACT_GO_BACKWARD, NOT_ADJUSMENT);
        wait_1ms(2000);

        motor_all(1000, ACT_GO_FORWARD, ADJUSMENT_FRONT);
        wait_1ms(2000);
        
        robot_turn(TURN_LEFT, TURN_90_DEGREE);
        wait_1ms(2000);

        robot_turn(TURN_RIGHT, TURN_90_DEGREE);
        wait_1ms(2000);
        
        motor_all(10000, ACT_GO_FORWARD, SETTING_ONLY);
        while((g_left_mot.step_count <= MM_TO_STEP(700)) || (g_right_mot.step_count <= MM_TO_STEP(700)))
        {
            if(300 < robot_read_sensor(SENSOR_TOP_AD))
            {
                motor_stop(STOP_EMERGENCY);
                break;
            }
        }
        motor_stop(STOP_NORMAL);
        wait_1ms(3000);

        test_func_robot_turn(TURN_LEFT, 200);
        wait_1ms(3000);

        test_func_robot_smooth_turn(TURN_LEFT);
        wait_1ms(5000);
	}

}