Esempio n. 1
0
void Task_P3()
{
    Task_Sleep(10);
    Mutex_Lock(mut2);
    Task_Sleep(20);
    Mutex_Unlock(mut2);
    for(;;);
}
void Task_P1()
{
    Mutex_Lock(mut1);
    Mutex_Lock(mut1);
    
    Task_Sleep(5);

    Mutex_Unlock(mut1);
    Mutex_Unlock(mut1);

    Task_Sleep(5);

    for(;;){
    }
}
Esempio n. 3
0
void Task_P1()
{
    Task_Sleep(30);
    Mutex_Lock(mut1);
    Mutex_Unlock(mut1);
    for(;;);
}
void Task_P1()
{
    Event_Signal(evt);

    Task_Sleep(100);
    for(;;){
    }
}
void Task_P1()
{
    Mutex_Lock(mut1);

    Task_Sleep(2);

    Task_Suspend(task2);

    Mutex_Unlock(mut1);

    Task_Resume(task2);

    Task_Sleep(3);

    for(;;){
    }
}
Esempio n. 6
0
/***** Core System Tasks *****/
void Task_WriteBluetooth()
{
    for(;;){
        uart1_putchar(joystickDirection);
        uart1_putchar(buttonState);
        uart1_putchar('\n');
        Task_Sleep(5);
    }
}
Esempio n. 7
0
void Pong()
{
	for(;;){
		PORTA|=(1<<PA1);
		PORTA&=~(1<<PA1);
		Task_Sleep(100);
		Event_Signal(e);
		Task_Yield();
	}
}
Esempio n. 8
0
void Task_P2(){
    PORTB   = 0x20;
    _delay_ms(10);
    PORTB   = 0x00;
    
    Task_Sleep(20); // sleep 2000ms

    PORTB   = 0x20;
    _delay_ms(10);
    PORTB   = 0x00;

    Event_Signal(evt);
    for(;;);
}
Esempio n. 9
0
void Task_ReadJoystick()
{
    for(;;)
    {
        // The button reads ~0 when pushed, and anything from 10 to 1024 when released
        buttonState = (read_ADC(JOYSTICK_PIN_BUTN) < 10) ? '1' : '0' ;

        // Read the joystick analog value and save the corresponding direction to joystickDirection, n, e, s, w, and 0 for stop
        int joy_horz = read_ADC(JOYSTICK_PIN_HORZ);
        int joy_vert = read_ADC(JOYSTICK_PIN_VERT);

        /* map joystick values to:
        *   0 (west or north), 1 (middle), or 2 (east or south)
        */
        int dir_horz = map(joy_horz, JOYSTICK_MIN, JOYSTICK_MAX, 0, 2);
        int dir_vert = map(joy_vert, JOYSTICK_MIN, JOYSTICK_MAX, 0, 2);

        // horizontal directions take precedence over vertical
        if(dir_horz == 0)
        {
            joystickDirection = WEST;
        }
        else if(dir_horz == 1)
        {
            if(dir_vert == 0)
            {
                joystickDirection = NORTH;
            }
            else if(dir_vert == 1)
            {
                joystickDirection = NONE;
            }
            else if(dir_vert == 2)
            {
                joystickDirection = SOUTH;
            }
        }
        else if(dir_horz == 2)
        {
            joystickDirection = EAST;
        }

        Task_Sleep(5);
    }
}
Esempio n. 10
0
void Task_P1(){
    PORTB   = 0x10;
    _delay_ms(10);
    PORTB   = 0x00;
    
    Task_Sleep(10); // sleep 1000ms

    PORTB   = 0x10;
    _delay_ms(10);
    PORTB   = 0x00;
    
    Mutex_Lock(mut);

    PORTB   = 0x10;
    _delay_ms(10);
    PORTB   = 0x00;
    for(;;);
}
Esempio n. 11
0
void
Task_Dispatch(void) {
int i;
Task_t *p;

    for(i=0;i<TASK_MAXCNT;i++) {
        p = &Task_List[i];
        if( p->func ) {
            if( p->elapsed >= p->period ) {
                p->state = p->func(p->state);      // call task function
                p->elapsed = 0;
            }
            p->elapsed++;
        }
    }

    Task_Flag = 0;
    while( ! Task_Flag ) {
        Task_Sleep();
    }

}
void Task_P2(int parameter)
{
    Task_Sleep(20); // sleep 200ms
    Event_Signal(evt);
    for(;;);
}
void Task_P1(int parameter)
{
    Task_Sleep(10); // sleep 100ms
    Mutex_Lock(mut);
    for(;;);
}
Esempio n. 14
0
void Task_P2(int parameter)
{
	Task_Sleep(20); // sleep 200ms
	Task_Resume(pid);
    for(;;);
}
Esempio n. 15
0
PeripheralResult_t Peripheral_Mode( PeripheralHandle_t* peripheral, PeripheralModeReg_t reg, void* data)
{
    int timeout = (int) data;
    switch(reg)
    {

    case MODE_RX_POLL:
    case MODE_RX_BUFFER:
    case MODE_RX_RTOS:
        do
        {
            if (peripheral->StateRx == PS_OPEN)
            {
                // Reserve this.
                if(reg == MODE_RX_POLL)
                    peripheral->StateRx = PS_POLL_RX_IDLE;
                else
                    peripheral->StateRx = PS_BUF_RX_IDLE;
                peripheral->TaskRx = Task_Active->ID;
                return PR_OK;
            }
            //Timeout 0 -> instant access
            if(timeout == 0)
                return PR_BLOCKED;

            // Timeout < 0 -> Timeout
            if(timeout <= 0)
                return PR_TIMEOUT;

            timeout-=25;
            Task_Sleep(25);
        }
        while(peripheral->TaskRx != Task_Active->ID);
        peripheral->TaskRx = Task_Active->ID;
        return PR_OK;

        break;

    case MODE_TX_POLL:
    case MODE_TX_BUFFER:
    case MODE_TX_RTOS:
        do
        {
            if (peripheral->StateTx == PS_OPEN)
            {
                // Reserve this.
                if(reg == MODE_TX_POLL)
                    peripheral->StateTx = PS_POLL_TX_IDLE;
                else
                    peripheral->StateTx = PS_BUF_TX_IDLE;
                peripheral->TaskTx = Task_Active->ID;
                return PR_OK;

            }
            //Timeout 0 -> instant access
            if(timeout == 0)
                return PR_BLOCKED;

            // Timeout < 0 -> Timeout
            if(timeout <= 0)
                return PR_TIMEOUT;

            timeout-=25;
            Task_Sleep(25);
        }
        while(peripheral->TaskTx != Task_Active->ID);
        peripheral->TaskTx = Task_Active->ID;
        return PR_OK;

        break;


    // Any remaining register are for the driver.
    default:
        return __PeripheralDrivers[peripheral->Driver].fncMode(peripheral, reg, data);
        break;
    }

}