Ejemplo n.º 1
0
int main(void)
{
	init_led();
	init_usart();
	init_led();
	
	while (true) {
		eth_poll();		/* out of scope of this example */
		
		pin_toggle(LED);
	}
}
Ejemplo n.º 2
0
/**
** @brief		Entry point to program.
** @return		Error code.
*/
int main( void )
{
	// Initialise the Teensy's on-board LED and our LED pattern controller
	init_led();

	// Initialise the UART module for comms with the ESP module
	uart_init( UART0_BASE_PTR, 115200 );

	// The IO driver handles setting up the FTM for receiver inputs and motor
	// outputs
	IODRIVER_Setup();

	// Initialise I2C which is used to talk to the LSM9DS0 IMU module
	// TODO check status?
	i2c_init( 0, 0x01, 0x20 );

	// Create tasks
	TASK_FLIGHT_Create();
	TASK_COMMS_Create();
	TASK_LED_Create();

	// Flash a little startup sequence, this isn't necessary at all, just nice
	// to see a familiar sign before things start breaking!
	blink( STARTUP_BLINK_COUNT, STARTUP_BLINK_PERIOD );

	// Say hello - printf is piped through the uart!
	printf( "Hello from TeensyQuad!\r\n" );

	// Start the tasks and timer running, this should never return as FreeRTOS
	// will branch directly into the idle task.
	vTaskStartScheduler();

	// We should never get here, this return is just to keep the compiler happy
	return 0;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: wanborj/PSEFM
int main(void)
{
    init_led();
    init_rs232();
    enable_rs232_interrupts();
    enable_rs232();

    //vTaskCompleteInitialise();
    vAppInitialise();
    vSemaphoreInitialise();
    vParameterInitialise(); 
    vInitialiseEventLists(NUMBEROFEVENTS);


    xTaskCreate( vR_Servant, "R-Servant", SERVANT_STACK_SIZE, (void *)&pvParameters[NUMBEROFSERVANT-1],tskIDLE_PRIORITY + 1, &xTaskOfHandle[NUMBEROFSERVANT-1]);

    portBASE_TYPE i,j;
    
    for( i = 0; i < NUMBEROFTASK; ++i )
    {
        xTaskCreate( vSensor, "Sensor", SERVANT_STACK_SIZE, (void *)&pvParameters[i*(xConcurrents + 1)],NUMBEROFTASK - i + 1, &xTaskOfHandle[i*(xConcurrents + 1)]);
        for( j = 1; j <= xConcurrents; ++j )
        {
            /* j is the number of concurrent servants in one task*/
            xTaskCreate( vServant, "servant", SERVANT_STACK_SIZE, (void *)&pvParameters[i*(xConcurrents + 1) + j],NUMBEROFTASK - i + 1, &xTaskOfHandle[i*(xConcurrents + 1) + j]);
        }
    }


    /* Start running the task. */
    vTaskStartScheduler();

    return 0;
}
Ejemplo n.º 4
0
int main()
{
	init_led();

	init_button();
	enable_button_interrupts();

	init_rs232();
	enable_rs232_interrupts();
	enable_rs232();

	/* Create the queue used by the serial task.  Messages for write to
	 * the RS232. */
	serial_str_queue = xQueueCreate(10, sizeof(serial_str_msg));
	vSemaphoreCreateBinary(serial_tx_wait_sem);
	serial_rx_queue = xQueueCreate(1, sizeof(serial_ch_msg));


    // queue_str_task1 = queue_str_task2 = serial_readwrite_task > rs232_xmit_msg_task
    // 
    // 
    // 
    // queue_str_task1 ->
    // queue_str_task2 ->
    //                                                               -> [serial_str_queue] -> rs232_xmit_msg_task
    // isr -> [serial_rx_queue] -> serial_readwrite_task:receive_byte
    // 
    // ---------->
    //
    // rs232_xmit_msg_task:send_byte -> <serial_tx_wait_sem> -> isr(complete)
    // 

	/* Create tasks to queue a string to be written to the RS232 port. */
	xTaskCreate(queue_str_task1,
	            (signed portCHAR *) "Serial Write 1",
	            512 /* stack size */, NULL,
	            tskIDLE_PRIORITY + 10, NULL );
	xTaskCreate(queue_str_task2,
	            (signed portCHAR *) "Serial Write 2",
	            512 /* stack size */, NULL, 
                tskIDLE_PRIORITY + 10, NULL);

	/* Create a task to write messages from the queue to the RS232 port. */
	xTaskCreate(rs232_xmit_msg_task,
	            (signed portCHAR *) "Serial Xmit Str",
	            512 /* stack size */, NULL, 
                tskIDLE_PRIORITY + 2, NULL);

	/* Create a task to receive characters from the RS232 port and echo
	 * them back to the RS232 port. */
	xTaskCreate(serial_readwrite_task,
	            (signed portCHAR *) "Serial Read/Write",
	            512 /* stack size */, NULL,
	            tskIDLE_PRIORITY + 10, NULL);

	/* Start running the tasks. */
	vTaskStartScheduler();

	return 0;
}
Ejemplo n.º 5
0
/*TASK*----------------------------------------------------------
*
* Task Name : blink_led_task
* Comments  :
*   Set up LED and button.
*   When user presses a button this task blinks the LED and prints
*   out the number of times the system timer interrupt occurred.
*   If the button is pressed again, the LED is turned off and
*   the number of times the system timer interrupt occurred
*   is also printed out.
*END*-----------------------------------------------------------*/
void blink_led_task
    (
        uint32_t initial_data
    )
{
    /* Initialize led */
    init_led((void *)(&led1));
    /* Initialize button 1 */
    init_interrupt_btn((void *)(&btn1));
    while(1)
    {
        if(TRUE == btn_pressed)
        {
            if (TRUE == prv_btn_pressed)
            {
                prv_btn_pressed = FALSE;
                printf("\nLed starts blinking at tick No. = %d\n", num_tick);
            }
            lwgpio_toggle_value(&led1);
            _time_delay(200);
        }
        else if (FALSE == prv_btn_pressed)
        {
            prv_btn_pressed = TRUE;
            printf("\nLed is off at tick No. = %d\n", num_tick);
            lwgpio_set_value(&led1, LWGPIO_VALUE_HIGH);
        }
    }
}
Ejemplo n.º 6
0
void sc8825_pm_init(void)
{
	unsigned int cpu1_jump_addrss;
	unsigned int val;
	
	init_reset_vector();
	pm_power_off = sc8825_power_off;
	arm_pm_restart = sc8825_machine_restart;
	pr_info("power off %pf, restart %pf\n", pm_power_off, arm_pm_restart);
#ifdef FORCE_DISABLE_DSP
	/* FPGA ONLY */
	fpga_dbg_init();
#endif
	init_gr();
	cpu1_jump_addrss = virt_to_phys(secondary_startup);
	sci_glb_write(REG_AHB_JMP_ADDR_CPU1, cpu1_jump_addrss,  -1UL);
	setup_autopd_mode();
	gic_save_init();
	pm_ana_ldo_config();
	init_led();
	emc_repower_init();
#ifndef CONFIG_SPRD_PM_DEBUG
	pm_debug_init();
#endif
	val = __raw_readl(sprd_get_scu_base());
	val |= (INTC_DYNAMIC_CLK_GATE_EN | SCU_DYNAMIC_CLK_GATE_EN);
	__raw_writel(val, sprd_get_scu_base());

}
Ejemplo n.º 7
0
void user_init(void) {
    uart_div_modify(0, UART_CLK_FREQ / 115200);
    os_delay_us(500);
    printf("SDK version : %s\n", system_get_sdk_version());
    mainqueue = xQueueCreate(10, sizeof(my_event_t));

    connectToAp();
    //setap("test", 4);

    init_led();

    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
    PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO5_U); // disable pullodwn
    GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS,BIT5);
    GPIO_OUTPUT_SET(GPIO_ID_PIN(5), 1);

    char outbuffer[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    WS2812OutBuffer( outbuffer, 6 , 0); //Initialize the output.
    write_textwall_buffer(0, "BIER ", 5);


    xTaskCreate(simple_task, (signed char * )"simple_task", 256, &mainqueue, tskIDLE_PRIORITY, NULL);
    xTaskCreate(receive_udp, (signed char * )"test", 256, &mainqueue, tskIDLE_PRIORITY, NULL);

    timerHandle = xTimerCreate((signed char *) "Trigger", 50 / portTICK_RATE_MS, pdTRUE, NULL, timer_cb);
    if (timerHandle != NULL) {
        if (xTimerStart(timerHandle, 0) != pdPASS) {
            printf("%s: Unable to start Timer ...\n", __FUNCTION__);
        }
    } else {
        printf("%s: Unable to create Timer ...\n", __FUNCTION__);
    }
}
Ejemplo n.º 8
0
int main(void)
{
    init_led();

    init_button();
    enable_button_interrupts();

    init_rs232();
    enable_rs232_interrupts();
    enable_rs232();

    /* Create the queue to hold messages to be written to the RS232. */
    serial_str_queue = xQueueCreate( 10, sizeof( serial_str_msg ) );
    vSemaphoreCreateBinary(serial_tx_wait_sem);
    serial_rx_queue = xQueueCreate( 1, sizeof( serial_ch_msg ) );

    /* Create a task to flash the LED. */
    xTaskCreate( led_flash_task, ( signed portCHAR * ) "LED Flash", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 5, NULL );

    /* Create tasks to queue a string to be written to the RS232 port. */
    xTaskCreate( queue_str_task1, ( signed portCHAR * ) "Serial Write 1", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL );
    xTaskCreate( queue_str_task2, ( signed portCHAR * ) "Serial Write 2", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL );

    /* Create a task to write messages from the queue to the RS232 port. */
    xTaskCreate(rs232_xmit_msg_task, ( signed portCHAR * ) "Serial Xmit Str", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL );

    /* Create a task to receive characters from the RS232 port and echo them back to the RS232 port. */
    xTaskCreate(serial_readwrite_task, ( signed portCHAR * ) "Serial Read/Write", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL );

    /* Start running the tasks. */
    vTaskStartScheduler();

    return 0;
}
Ejemplo n.º 9
0
void APL_TaskHandler(void)
{
	static int init_done = 0;
	if(init_done == 0)
	{	
		/* Init Led */
		init_led();
		
		/* Init Serial Interface for debug */ 
		initSerialInterface();          	
		
		
		DDRD = 0x0F;
		PORTD = 0x0F;
		
		bouttonsTimer.interval = 400L;
		bouttonsTimer.mode     = TIMER_REPEAT_MODE;
		bouttonsTimer.callback = bouttons_task;
		HAL_StartAppTimer(&bouttonsTimer);
		
		init_done = 1;
		uprintf("test_bouttons : init done\r\n");
	}
	SYS_PostTask(APL_TASK_ID);
}
Ejemplo n.º 10
0
int
main (void)
{
    struct kiosk *kiosk = kiosk_new ();
    struct ucard_application *application = transport_application_new (on_password_requested);
    init_led();

    if (kiosk_devices_scan (kiosk)) {
        kiosk_set_one_shot (kiosk, false);
        kiosk_setup (kiosk, application, on_card_presented);
        kiosk_start (kiosk);

        fd_set r;
        FD_ZERO (&r);
        FD_SET (0, &r);

        while (kiosk_select (kiosk, 0, &r, NULL, NULL, NULL) > 0) {
            if (FD_ISSET (0, &r)) {
                fprintf (stderr, "Key pressed on the console.\nExiting.\n");
                break;
            }
        }
        kiosk_stop (kiosk);
    }
    kiosk_free (kiosk);

    ucard_application_free (application);

    exit (EXIT_SUCCESS);
}
Ejemplo n.º 11
0
int spl_start_uboot(void)
{
    int ret;
    int bootmode = 0;

    /*
     * GP7[14] selects bootmode:
     * 1: boot linux
     * 0: boot u-boot
     * if error accessing gpio boot U-Boot
     *
     * SPL bootmode
     * 0: boot linux
     * 1: boot u-boot
     */
    ret = gpio_request(CONFIG_IPAM390_GPIO_BOOTMODE , "bootmode");
    if (ret)
        bootmode = 1;
    if (!bootmode) {
        ret = gpio_direction_input(CONFIG_IPAM390_GPIO_BOOTMODE);
        if (ret)
            bootmode = 1;
    }
    if (!bootmode)
        ret = gpio_get_value(CONFIG_IPAM390_GPIO_BOOTMODE);
    if (!bootmode)
        if (ret == 0)
            bootmode = 1;
    if (bootmode) {
        /*
         * Booting U-Boot
         * LED Red  : on
         * LED green: off
         */
        init_led(CONFIG_IPAM390_GPIO_LED_RED, "red", LED_ON);
        init_led(CONFIG_IPAM390_GPIO_LED_GREEN, "green", LED_OFF);
    } else {
        /*
         * Booting Linux
         * LED Red  : off
         * LED green: off
         */
        init_led(CONFIG_IPAM390_GPIO_LED_RED, "red", LED_OFF);
        init_led(CONFIG_IPAM390_GPIO_LED_GREEN, "green", LED_OFF);
    }
    return bootmode;
}
Ejemplo n.º 12
0
///////////////////////////////////////////////////////////////////////////////
// Инициализация системы
///////////////////////////////////////////////////////////////////////////////
unsigned char init_system( void )
{           
	init_pio();
	init_led();
	init_systimer0();

	start_timer0();

    return OK;     
}                                
Ejemplo n.º 13
0
int main(void)
{
    init_led();

    while (1) {
        gpio_toggle(GPIOD, GPIO_Pin_2);
        delay(1000);

    }
}
Ejemplo n.º 14
0
void S3C_SysInit(void){
	int i;
	SwiHandle(4);	//SetInterruptREG
	S3C_InitTimer_PWM();
	init_led ();
	init_lcd();
	for (i = 0;i <32;++i){
		VICVectAddr[i]  = (INT32U)IRQ_UNDEF;		
	}
	VICVectAddr[5]  = (INT32U)IRQ_BUTTON;
	VICVectAddr[23] = (INT32U)IRQ_UART1;
	VICVectAddr[28] = (INT32U)IRQ_UART0;
}
Ejemplo n.º 15
0
int main(void)
{
    init_led();

    init_button();
    enable_button_interrupts();

    while(1) {
          /* Generate a software interrupt on EXTI line 0 */
          EXTI_GenerateSWInterrupt(EXTI_Line0);

          myDelay(500000);
    }
}
Ejemplo n.º 16
0
int main(void)
{
	//wait_ms(3000); /// XXX hack to give time to the person that tests the system to take a cofee
	uart_init();
	uart_com_init();
	fdevopen(uart0_dev_send, uart0_dev_recv);
	
	//--------------------------------------------------------
  // Error configuration
  error_register_emerg(log_event);
  error_register_error(log_event);
  error_register_warning(log_event);
  error_register_notice(log_event);
  error_register_debug(log_event);

  log_level = ERROR_SEVERITY_NOTICE;
  log_level = ERROR_SEVERITY_DEBUG;

	sei();
	printf("%c[2J",0x1B);
  printf("%c[0;0H",0x1B);
  printf("Robotter 2011 - Galipeur - R3D2-2K10");
  printf("Compiled "__DATE__" at "__TIME__".");

	//NOTICE(0,"Initializing r3d2");
	r3d2_init();

	//NOTICE(0,"Initializing leds");
	init_led();  
	
	//NOTICE(0,"Initializing scheduler");
	scheduler_init();

  scheduler_add_periodical_event_priority(&r3d2_monitor, NULL,
                                            300,
                                            50);	
	
	scheduler_add_periodical_event_priority(&send_periodic_position_msg, NULL,
                                            1000,
                                           60);	
		
	PORTA = ~(0x55);
	
	NOTICE(0,"Strike '?' for help");

	while (1)	
	{	
		uart_com_monitor();
	}
}
Ejemplo n.º 17
0
void show_boot_progress(int status)
{
    static int red;
    static int green;

    if (red == 0)
        red = init_led(CONFIG_IPAM390_GPIO_LED_RED, "red", LED_OFF);
    if (red != CONFIG_IPAM390_GPIO_LED_RED)
        return;
    if (green == 0)
        green = init_led(CONFIG_IPAM390_GPIO_LED_GREEN, "green",
                         LED_OFF);
    if (green != CONFIG_IPAM390_GPIO_LED_GREEN)
        return;

    switch (status) {
    case BOOTSTAGE_ID_RUN_OS:
        /*
         * set normal state
         * LED Red  : off
         * LED green: off
         */
        gpio_set_value(red, LED_OFF);
        gpio_set_value(green, LED_OFF);
        break;
    case BOOTSTAGE_ID_MAIN_LOOP:
        /*
         * U-Boot operation
         * LED Red  : on
         * LED green: on
         */
        gpio_set_value(red, LED_ON);
        gpio_set_value(green, LED_ON);
        break;
    }
}
Ejemplo n.º 18
0
void init() 
{
	prc2 = 1;			/*PACRの書込み許可*/
	pacr = 3;			/*80ピンに設定*/
	
	/*クロック設定*/
	prc0=1;
	cm21=0;
	cm06=0;
	prc0=0;
	
	//
	init_led();
	//
	init_switch();
}
Ejemplo n.º 19
0
int main()
{
	init_led();
    init_beep();
    //init_key();  轮循初始化
    //init_interrupt_for_key();   //中断的方式

    led_off_all();
    if(flag){
        led_on_all();
        beep_on();
    }
	int i;
	while(1){
	}
	return 0;
}
Ejemplo n.º 20
0
int main()
{
	init_led();

	led_off_all();
	
	int i=1;
	while (1) {
		for(i=1; i<5; i++) {
			led_on(i);
			delay(0xfff);
			led_off(i);
			delay(0xfff);
		}	
	}
	return 0;
}
Ejemplo n.º 21
0
/*main*/
int main(int argc,char** argv)
{
	int ret = 0;
	//swi_test();
    clean_bss();	
    uart0_init();
	init_led();
	init_irq();
	#ifdef _DEBUG
	/*register extern4*/	
	key_init(4,EXTINT);
	register_extern_int(EXTERNIRQ4,KeyINT2_Handle);	
	//invoking timer0 initialize and enable timer0 handle	
	register_interrupt(ISR_TIMER0_OFT,Timer0_Handle);	
	timer0_init();					
	#endif
	ret = smdk2440_machine_init();
	if(ret != 0)
	{
		goto tail;
	}	
	ret = dm9000_initialize();
	if(ret != 0)
	{
		printf("dm9000_initialize error.\n\t");
		goto tail;
	}
	ret = eth_init();
	if(ret != 0)
	{
		printf("eth_init error.\n\t");
		goto tail;	
	}	
	wait(50000);
	test_dm9000();
	wait(500000);	
	test_dm9000();
	//arp_test();
	uip_exe();
tail:	
	while(1);
	return 0;
}
Ejemplo n.º 22
0
int main()
{
	init_led();
    init_beep();
	int i;
	while(1)
	{
		for(i=1;i<=4;i++)
		{
            beep_on();
			led_on(i);
			delay(0xffff);
            beep_off();
			led_off(i);
			delay(0xffff);
		}
	}
	 return 0;
}
Ejemplo n.º 23
0
void APL_TaskHandler(void)
{
	switch (network_get_state())
	{
		case APP_INITIAL_STATE:
			
			/* Init Led */
			init_led();
			
			/* Init Serial Interface for debug */ 
  			initSerialInterface();          
			
			uid = get_uid();
			
			/* Init network */
			uid = 2;
			network_init(uid);
			
 			network_set_state(APP_NETWORK_JOIN_REQUEST);
			break;
		case APP_NETWORK_JOIN_REQUEST:
			
			/* Activate the network status led blink */
			led_start_blink();
			
			/* St	art network */
			network_start();
			
			network_set_state(APP_NETWORK_JOINING_STATE);
			
		case APP_NETWORK_JOINING_STATE:
			break;
		case APP_NETWORK_LEAVING_STATE:
			break;
		case APP_NETWORK_JOINED_STATE:
			led_stop_blink();
			break;
		default:
			break;
	}
	SYS_PostTask(APL_TASK_ID);
}
Ejemplo n.º 24
0
Archivo: main.c Proyecto: monolli/ee109
int main(void){
	
	init_serial();
	init_ISR();				//initialize all functions, ports...
	init_led();
	init_buttons();
	init_temp();
	get_temp();
	ht=temp;
	lt=temp;
	init_lcd();

	while(1){
		get_temp();				//recieve the temp, convert and print
		led_on();				//turn the led functions on
		get_serial();			//recieve the temp through serial
	}
	
	return 0;
}
Ejemplo n.º 25
0
int main(void) {
    uint8_t i;

    init_protocol();
    init_rotary0();
    init_led();
    init_adc();
    step3=0;
    sei();


    txbuffer[0]=3;//index
    txbuffer[1]=130;
    txbuffer[2]=0xff;
    i=nout;
    while(1) {
        while(i==nout);
        i=nout;
        send(0x42);
    }
}
Ejemplo n.º 26
0
int main(void)
{
	range_select();

	init_timer0();
	init_ADC();	
	init_7Seg();
	init_led();
	
	while(1)
	{
		int r = 0;
		if(read_ADC()) r = calc_resist(read_ADC());
		
		test_limits(r);
		
		printbuf(r);
        _delay_ms(150);

	}
}
Ejemplo n.º 27
0
int main()
{
	init_led();
	init_beep();
	init_key();

	led_off_all();
	int i;

	while(1)
	{
		if(i= key_press()){
			led_on(i);
			beep_on();
		}else{
			led_off_all();
			beep_off();
		}
	}
	 return 0;
}
Ejemplo n.º 28
0
int
main(void)
{
	init_os();

	/* Init sys time */
	init_sys_time();

	/* Init led */
	init_led();

	char *str = "hello";

	create_task(main_task, str, &main_stk[STK_SIZE - 1], 0);
	create_task(second_task, str, &second_stk[STK_SIZE - 1], 10);
	create_task(third_task, NULL, &third_stk[STK_SIZE - 1], 30);

	start_os();

	return 0;
}
Ejemplo n.º 29
0
int main(void)
{
    int last_button_state, new_button_state;
    uint32_t hclk_ticks_per_sec, ext_clock_ticks_per_sec;

    init_led();
    init_button();

    /* The Cortex System Timer (SysTick) clock can be driven by the Cortex
     * clock (HCLK), which is the output of the AHB prescaler, or from the
     * external clock, which is HLCK divided by 8.
     * Call SysTick_Config with the number of ticks between Systick interrupts.
     * We will choose this value such that there is one second
     * between interrupts when the external clock (HCLK / 8) is selected.
     * Initially, the Cortex clock (HCLK) will be selected, which means an
     * interrupt every 1/8th of a second.
     */
    hclk_ticks_per_sec = SystemCoreClock;
    ext_clock_ticks_per_sec = hclk_ticks_per_sec / 8;
    if (SysTick_Config(ext_clock_ticks_per_sec))
    {
        /* If SysTick_Config returns 1, that means the number ticks exceeds the
         * limit. */
        while (1);
    }

    /* Infinite loop - when the button changes state, toggle the SysTick clock
     * source.
     */
    last_button_state = GPIOA->IDR & 0x00000001;
    while(1) {
        new_button_state = GPIOA->IDR & 0x00000001;
        if(new_button_state ^ last_button_state) {
            if(new_button_state) {
                SysTick->CTRL ^= SysTick_CTRL_CLKSOURCE_Msk;
            }
        }
        last_button_state = new_button_state;
    }
}
Ejemplo n.º 30
0
void main()
{
    unsigned short val = 0;
    unsigned int show_data = 0;
    //unsigned short last_data = 0;
    uart2_init();
    init_led();
    init_motor();
    init_steering();
    init_speed();
    show_byte(0);

    //led_vcc_on();
    while(1) {
        //		show_byte(0x12,1);

        if((uart_data >= '0') && (uart_data <= 'z')) {
            //last_data = val;
            val = uart_data;
        }
        //show_data = (cmd_func << 8) | (val & 0xff);
        show_data = ((left_dis << 8)&0xff00) | (right_dis & 0xff);
        //show_data = (left_diff << 8) | (right_diff & 0xff);

        show_byte(show_data);

        if(sg_flag == 1) {
            sg_flag = 0;
            delay1ms_show(1000 * 3,show_data);
            if(sg_flag == 0) { //maybe call up() twice in 3s
                stop_sg();
            }


        }
        //uart2_send('a');
        //uart2_send('b');
        //uart2_send('c');
    }
}