Example #1
0
int main(void)
{
	uint8_t bStatus = LCD_DRIVER_BUSY;
	
	BoardConfig_vfnInit();
	SWTimer_Init();
	LCDDriver_Init();
	Heartbeat_Init();
	
	for(;;) 
	{	   
		SWTimer_ServiceTimers();
		LCDDriver_Task();
		
		if(bStatus == LCD_DRIVER_BUSY)
		{
#if TEST == 1
			bStatus = LCDDriver_WriteString(&gbaTestString[0], sizeof(gbaTestString)-1u);
#elif TEST == 2
			
			bStatus = LCDDriver_MoveCursor(5,2);
			
#endif
		}
		
	}
	
	return 0;
}
Example #2
0
// Create a scheduler
Scheduler_t Scheduler_Init_us(Int_Func func, unsigned int time_delay,
                              uint8_t repeat) {

    uint32_t timer_id = 0;
    uint32_t mr_id = 0;
    uint32_t sw_mr_id = 0;

    if (_next_ts < (HW_TIMER_MR_AMOUNT * HW_TIMER_AMOUNT)) {
        timer_id = (_next_ts % HW_TIMER_AMOUNT) + HW_TIMER_OFFSET;
        mr_id    = _next_ts / HW_TIMER_AMOUNT;
        _next_ts++;
    } else {
        if (_swtimer == NULL) {
            _swtimer = SWTimer_Init(SW_TIMER_MR_AMOUNT);
        }

        // Modify values appropriately
        timer_id = SW_TIMER_ID;
        mr_id = SWTimer_Store(_swtimer, func, time_delay, repeat,
                              &sw_mr_id);
        time_delay = SWTimer_Get_Reload(_swtimer, mr_id);
        func = NULL;
        repeat = 1;
    }

    // Check if this timer is initialized
    if (_sch_timers[timer_id] == NULL) {
        _sch_timers_init(timer_id);
    }

    Scheduler_t scheduler = { timer_id, mr_id, sw_mr_id };

    if (sw_mr_id == 0) {
        _timer_set_mr(timer_id, mr_id, time_delay);
    } else {
        _timer_update_mr(timer_id, mr_id, time_delay);
    }

    // Store the scheduling structure
    _timer_sch_store(&(_sch_timers[timer_id][mr_id]),
                     func, time_delay, repeat);

    return scheduler;
}