コード例 #1
0
ファイル: user_main.c プロジェクト: KrystianD/kdhome
//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
	uart_process();
	wifiProcess();
	commProcess();

	os_delay_us(10000);
	ticks += 10;

	system_os_post(user_procTaskPrio, 0, 0);
}
コード例 #2
0
void main_loop()
{
    uart_default_config(&current_config);
    if (uart_init(&uart,
                  handle_write_completed,
                  handle_read_completed,
                  handle_notify_read) < 0)
        errx(EXIT_FAILURE, "uart_init failed");

    struct erlcmd *handler = malloc(sizeof(struct erlcmd));
    erlcmd_init(handler, handle_elixir_request, NULL);

    for (;;) {
        struct pollfd fdset[3];

        fdset[0].fd = STDIN_FILENO;
        fdset[0].events = POLLIN;
        fdset[0].revents = 0;

        int timeout = -1; // Wait forever unless told by otherwise
        int count = uart_add_poll_events(uart, &fdset[1], &timeout);

        int rc = poll(fdset, count + 1, timeout);
        if (rc < 0) {
            // Retry if EINTR
            if (errno == EINTR)
                continue;

            err(EXIT_FAILURE, "poll");
        }

        if (fdset[0].revents & (POLLIN | POLLHUP)) {
            if (erlcmd_process(handler))
                break;
        }

        // Call uart_process if it added any events
        if (count)
            uart_process(uart, &fdset[1]);
    }

    // Exit due to Erlang trying to end the process.
    //
    if (uart_is_open(uart))
        uart_flush_all(uart);
}
コード例 #3
0
ファイル: main.c プロジェクト: hdznrrd/alphafluid
int main(void)
{
	
	uint8_t delay1 = 0, delay2 = 0, delay3 = 0;
	
	seg_init();
	mat_init();
	uart_init();
	sei();
	
	uart_puts("\n\n");
	uart_puts("/o/i/booting\r\n");
	
    while(1)
    {	
		
		for(uint8_t i=0; i<3;i++) uart_process();
		
		
		delay2++;
		if(delay2 == 200){
			delay2 = 0;
			mat_check();		
			
			
			delay1++;
			if(delay1 == 200){
				delay1 = 0;
				mat_debug();
				test();
				uart_puts("d\r\n");
				
				if(delay3 == 10){
					delay3 = 0;
					uart_puts("\n");
				}
				connect(); //checks hastoconnect variable
			}
		}			
		_delay_us(5);
    }
}
コード例 #4
0
ファイル: main.c プロジェクト: nikkoCheng/gitTest1
void main(void)
{
		//////////////////////
			TMUNUM_INFO xx;
		TMUNUM_INFO  yy;
	///////////////////////////
    unsigned char index;   
		static unsigned char num_byte = 0;
		char y =0;
		EA = 0;
    Soft_WDT_Disnable();

    mcu_f340_init();

    delay_ms(10);

    var_init();
		fmu_cmd_init();
    uart1_init();

#ifdef ID_ONE_WIRE
    one_wire_init( ONE_WIRE_STANDARD_SPEED);
#endif

    delay_ms(10);
    tmu_address_init(); 				    
    EA = 1;     

    WatchDog_Init();

    index = 0;
		countnum = 0;
		port_num = 0;
		
		while(1)
		{		
				xx.c[0] = 2;
				xx.c[1] = 2;
				xx.c[2] = 2;
				xx.c[3] = 2;
				xx.c[4] = 2;
				xx.c[5] = 2;
				write_tmunum_info(&xx);
				read_tmunum_info(&yy);
		}
while(1)
{
	
	char x[10]={1,2,3,4,5,6,7,8,9,10};
	char temp[10];
	int i;
	unsigned char code * data ptrCode;
	x[0] = y++;
	WatchDog();
	earseCodeFlash(TMU_NUM_INFO_ADDR);
	WatchDog();
	writeInnerFlash(TMU_NUM_INFO_ADDR, 10, x);
  ptrCode = (char code *)TMU_NUM_INFO_ADDR;
	for(i = 0;i<10;i++)
	{
		temp[i] = 0;
	}
	for (i = 0; i <10; i++)
	{
		temp[i] = *ptrCode++;
	}
		WatchDog();
}

 while(1)
    { 	
        WatchDog();
        uart_process();

				if(flag30ms)
				{
					/*sssssssssssssssss*/
					flag30ms = 0;
						if(num_byte == 0)
						{
							num_byte = 1;
							read_id(0,0,(unsigned char*)localid_buf);
							WatchDog();
						}
						else
						{
								num_byte = 0;
								read_id(0,1,(unsigned char*)localid_buf);
								WatchDog();
								refresh_current_id();
								memory_clear((unsigned char*)localid_buf,sizeof(localid_buf));
								read_id_96();
						}
				}
					
        if( flag60ms )             
        {
            flag60ms = 0;
            index ++; 
						uart1_timeout();				
					  port_state_process();
            slot_aging_time();	
			
					if(index >= 20)
					{
							index = 0;
							fmu_cmd_update_file_timer_count();
					}
        }
    }
}