예제 #1
0
파일: main.c 프로젝트: Shashank-Rudra/nOS
int main( void )
{
    // Stop watchdog timer to prevent time out reset
    WDTCTL = WDTPW + WDTHOLD;

    nOS_Init();
    
    nOS_ThreadSetName(NULL, "main");
    
    BTCTL = BTHOLD|BTDIV|BT_fCLK2_DIV128;
    BTCNT1 = 0;
    BTCNT2 = 0;
    IE2_bit.BTIE = 1;
    BTCTL &=~ BTHOLD;

    __enable_interrupt();

    nOS_SemCreate(&semA, 0, 1);
    nOS_SemCreate(&semB, 0, 1);
    nOS_SemCreate(&semC, 0, 1);

    nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO,   NOS_THREAD_READY, "ThreadA");
    nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB");
    nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC");

    while (1) {
        nOS_SemGive(&semC);
    }
}
예제 #2
0
void nOS_InitSignal (void)
{
    nOS_InitList(&_signalList);
    nOS_SemCreate(&_signalSem, 0, NOS_SEM_COUNT_MAX);
#if (NOS_CONFIG_SIGNAL_THREAD_ENABLE > 0)
    nOS_ThreadCreate(&_signalHandle,
                     _ThreadSignal,
                     NULL
 #ifdef NOS_SIMULATED_STACK
                     ,&_signalStack
 #else
                     ,_signalStack
 #endif
                     ,NOS_CONFIG_SIGNAL_THREAD_STACK_SIZE
 #ifdef NOS_USE_SEPARATE_CALL_STACK
                     ,NOS_CONFIG_SIGNAL_THREAD_CALL_STACK_SIZE
 #endif
 #if (NOS_CONFIG_HIGHEST_THREAD_PRIO > 0)
                     ,NOS_CONFIG_SIGNAL_THREAD_PRIO
 #endif
 #if (NOS_CONFIG_THREAD_SUSPEND_ENABLE > 0)
                     ,NOS_THREAD_READY
 #endif
 #if (NOS_CONFIG_THREAD_NAME_ENABLE > 0)
                     ,"nOS_Signal"
 #endif
                     );
#endif
}
예제 #3
0
파일: nOSTimer.c 프로젝트: therafman/nOS
void nOS_InitTimer(void)
{
    nOS_InitList(&_timerList);
    nOS_SemCreate(&_timerSem, 0, NOS_SEM_COUNT_MAX);
#if (NOS_CONFIG_TIMER_THREAD_ENABLE > 0)
    nOS_ThreadCreate(&_timerHandle,
                     _ThreadTimer,
                     NULL
#ifdef NOS_SIMULATED_STACK
                     ,&_timerStack
#else
                     ,_timerStack
#endif
                     ,NOS_CONFIG_TIMER_THREAD_STACK_SIZE
#ifdef NOS_USE_SEPARATE_CALL_STACK
                     ,NOS_CONFIG_TIMER_THREAD_CALL_STACK_SIZE
#endif
#if (NOS_CONFIG_HIGHEST_THREAD_PRIO > 0)
                     ,NOS_CONFIG_TIMER_THREAD_PRIO
#endif
#if (NOS_CONFIG_THREAD_SUSPEND_ENABLE > 0)
                     ,NOS_THREAD_READY
#endif
#if (NOS_CONFIG_THREAD_NAME_ENABLE > 0)
                     ,"nOS_Timer"
#endif
                     );
#endif  /* NOS_CONFIG_TIMER_THREAD_ENABLE */
}
예제 #4
0
int main (void)
{	
    nOS_Init();
    
    nOS_ThreadSetName(NULL, "main");
    
    nOS_SemCreate(&semA, 0, 1);
    nOS_SemCreate(&semB, 0, 1);
    nOS_SemCreate(&semC, 0, 1);
	
	nOS_ThreadCreate(&threadA, ThreadA, NULL, stackA, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO,   NOS_THREAD_READY, "ThreadA");
    nOS_ThreadCreate(&threadB, ThreadB, NULL, stackB, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB");
    nOS_ThreadCreate(&threadC, ThreadC, NULL, stackC, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC");

    nOS_Start(TimerA0_Init);

    while (1){
        nOS_SemGive(&semC);
    }
}
예제 #5
0
int main()
{
    nOS_Init();
    
    nOS_ThreadSetName(NULL, "main");

    nOS_SemCreate(&semA, 0, 1);
    nOS_SemCreate(&semB, 0, 1);
    nOS_SemCreate(&semC, 0, 1);

    nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO,   NOS_THREAD_READY, "ThreadA");
    nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB");
    nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC");

    nOS_Start(SysTick_Init);

    while (1) {
        nOS_SemGive(&semC);
    }
}
예제 #6
0
파일: main.c 프로젝트: Shashank-Rudra/nOS
int main()
{
    nOS_Init();
    
    nOS_ThreadSetName(NULL, "main");

    SystemCoreClockUpdate();
    SysTick_Config(SystemCoreClock / NOS_CONFIG_TICKS_PER_SECOND);

    nOS_SemCreate(&semA, 0, 1);
    nOS_SemCreate(&semB, 0, 1);
    nOS_SemCreate(&semC, 0, 1);

    nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO,   NOS_THREAD_READY, "ThreadA");
    nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB");
    nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC");

    while (1) {
        nOS_SemGive(&semC);
    }
}
예제 #7
0
int main(int argc, char *argv[])
{
    nOS_Init();

    nOS_ThreadSetName(NULL, "main");

    nOS_SemCreate(&semA, 0, 1);
    nOS_SemCreate(&semB, 0, 1);
    nOS_SemCreate(&semC, 0, 1);

    nOS_ThreadCreate(&threadA, ThreadA, NULL, &stackA, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO,   NOS_THREAD_READY, "ThreadA");
    nOS_ThreadCreate(&threadB, ThreadB, NULL, &stackB, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB");
    nOS_ThreadCreate(&threadC, ThreadC, NULL, &stackC, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC");

    nOS_Start(NULL);

    while (true) {
        nOS_Print("%s running\n", nOS_ThreadGetName(NULL));
        nOS_SemGive(&semC);
    }
}