Esempio n. 1
0
void rangeley_sb_early_initialization(void)
{
	/* Setup all BARs required for early PCIe and raminit */
	rangeley_setup_bars();

	reset_rtc();
}
void dispatch( void )
{
    uint32_t more;
    dispatch_queue_t* q;
    uint32_t now;

    q = &timerq;

    do {
        more = 0;
        while (1) {
            if (q->head == NULL) {
                break;
            }

            now = current_time();
            if (LATTER_THAN(now, q->head->timestamp)) {
                dispatch_head_op(q, now);
                more = 1;
            } else {
                break;
            }
        }

        q = &mainq;

        if (q->head) {
            // not empty
            dispatch_head_op(q, 0);
            more = 1;
        }
    } while (more);

    reset_rtc();
}
void run_at_time(function_t func,
                 void* args, uint32_t timestamp)
{
    dispatch_queue_t* q;
    operation_t* op;
    operation_t* before;
    q = &timerq;
    op = allocate();
    if (op) {
        op->func = func;
        op->args = args;
        op->timestamp = timestamp;

        before = q->head;

        if ((before == NULL) ||
                (LATTER_THAN(before->timestamp, op->timestamp))) {
            op->next = q->head;
            q->head = op;
            if (q->tail == NULL) {
                q->tail = op;
            }
        } else {
            while (before) {
                if ((before->next == NULL) ||
                        LATTER_THAN(before->next->timestamp, op->timestamp)) {
                    op->next = before->next;
                    before->next = op;

                    if (q->tail == before) {
                        q->tail = op;
                    }
                    break;
                }
                before = before->next;
            }
        }

        reset_rtc();
    }
}
Esempio n. 4
0
void taskBackground(void* pvParameter)
{
static unsigned int val1;
static unsigned int val2;
time_t time_sec;

//	vTaskSetApplicationTaskTag( NULL, ( void * ) 'b' );	
alarm_st = 0;
#ifndef SIM_DEBUG
//sysinit
	wdi_ena = 0;
	Spi_init();
	if(get_time_rtc(&rtc_time)== FALSE)
	{
		SetError(RTC_ERR, HARWARE_ALRM_SCR);
		reset_rtc();
		while(clear_os_rtc() == FALSE);
		init_time_rtc(&rtc_time);
		
//		rtc_time.tm_sec = 0;
 //		rtc_time.tm_min = 0;
// 		rtc_time.tm_hour = 0;
//		rtc_time.tm_mday = 1;
//		rtc_time.tm_wday = 0;
//		rtc_time.tm_mon = 0;
//		rtc_time.tm_year = 100;
//		rtc_time.tm_yday = 0;
//		rtc_time.tm_isdst = 0;
		set_time_rtc(&rtc_time)/*set_date()*/;
	}
	else if(mktime(&rtc_time)==-1)
	{
		SetError(RTC_ERR, HARWARE_ALRM_SCR);
//		reset_rtc();
		init_time_rtc(&rtc_time);
		set_time_rtc(&rtc_time)/*set_date()*/;
	}
	
	time_sec  = mktime(&rtc_time); 
	set_clock(time_sec);

//	if(get_days(&calib_date) > 365)
//	if(time_sec - calib_time >= 31536000L /*365*24*60*60*/)
//	{
//			Beep(800);
//			lcd_clear();
//			beep(800,4);
//			RTclock.timer = 2000; //10sec timeout
//			draw_text( 15, LCD_TXTLINE1, (uchar*)"SEND THE PUMP", LCD_PIXEL_ON,0);
//			draw_text( 54, LCD_TXTLINE2, (uchar*)"TO", LCD_PIXEL_ON,0);
//			draw_text( 29, LCD_TXTLINE3, (uchar*)"CALIBRATE", LCD_PIXEL_ON,0);
//			while(RTclock.timer > 0);
//	}




	SST25ProtDisable();

	SST25ReadArray(PARAM_E2PIMG_BASE, &E2pImage, sizeof(E2pImage_t));
	if(crc16((unsigned char*)&E2pImage, sizeof(E2pImage_t)) != 0)
	{
		SetError(EEPROM_ERR, HARWARE_ALRM_SCR);
		set_defaults();
	}
	SST25ReadArray(CLBR_E2PIMG_BASE, &Clbr_E2pImage, sizeof(Clbr_E2pImage_t));
	if(crc16((unsigned char*)&Clbr_E2pImage, sizeof(Clbr_E2pImage_t)) != 0)
	{
		SetError(EEPROM_ERR, HARWARE_ALRM_SCR);
		set_fact_defaults();
	}
        if(GetError() != 0)
	{
		err_code = GetError();
		ClearError();
                ((unsigned int*)&E2pImage)[sizeof(E2pImage_t)/2 - 1] = crc16(&E2pImage, sizeof(E2pImage_t) - 2);
		SST25SectorErase(PARAM_E2PIMG_BASE);
		if(!SST25WriteArray(PARAM_E2PIMG_BASE, &E2pImage, sizeof(E2pImage_t)))
			/*CriticalError("eeprom err")*/;
	}

	MCP23S08Init();
	MCP4822Write(0, zero_press1 , 0);
	MCP4822Write(1, zero_press2 , 0);

	init_motor();
	init_airdet();
#endif
	init_keypad();
	init_clock();
	CheckParams();

	/* drop task priority */	 
	vTaskPrioritySet( hBACKGRNDTask, tskIDLE_PRIORITY + 1 );	
	while (1) 
	{
            vTaskDelay( 50 / portTICK_RATE_MS );   // Wait 50ms
		 
            if(val1 > 0x0fff)
                val1 = 0;
            else
                val1++;
            if(val2 > 0x0fff)
                val1 = 0;
            else
                val2++;

            if(!wdi_ena)
                toggleExpGPO(WDI_EXTIOBIT);
//	ClrWdt();
//	WD_PIN^= 1; 			 /*toggle external watch dog */
	}	
}