/** * \b main * * Initialize atomthreads and start a test_thread to run the Atomthreads test suite. * */ int main (void) { uint32_t failures ; printf ("atomthreads starting %s... ", ATOMTHREADS_TEST) ; atomOSInit(&idle_stack[0], IDLE_STACK_BYTE_SIZE, TRUE) ; atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[0], TEST_STACK_BYTE_SIZE, TRUE); atomOSStart() ; return 0 ; }
/** * \b main * * Program entry point. * * Sets up the MicroBlaze hardware resources (system tick timer interrupt) necessary * for the OS to be started. Creates an application thread and starts the OS. */ int main ( void ) { int8_t status; ATOMLOG("\n\nAtomThreads MicroBlaze Starting\n\n"); /** * Initialise the OS before creating our threads. */ status = atomOSInit(&idle_thread_stack[0], IDLE_STACK_SIZE_BYTES, TRUE); if (status == ATOM_OK) { /* Enable the system tick timer */ microblazeInitSystemTickTimer(); /* Create an application thread */ status = atomThreadCreate(&main_tcb, TEST_THREAD_PRIO, main_thread_func, 0, &main_thread_stack[0], MAIN_STACK_SIZE_BYTES, TRUE); if (status == ATOM_OK) { /** * First application thread successfully created. It is * now possible to start the OS. Execution will not return * from atomOSStart(), which will restore the context of * our application thread and start executing it. * * Note that interrupts are still disabled at this point. * They will be enabled as we restore and execute our first * thread in archFirstThreadRestore(). */ atomOSStart(); } } while (1) ; /* There was an error starting the OS if we reach here */ return (0); }
int main ( void ) { int8_t status; /** * Reuse part of the idle thread's stack for the stack required * during this startup function. */ SP = (int)&idle_thread_stack[(IDLE_STACK_SIZE_BYTES/2) - 1]; /** * Note: to protect OS structures and data during initialisation, * interrupts must remain disabled until the first thread * has been restored. They are reenabled at the very end of * the first thread restore, at which point it is safe for a * reschedule to take place. */ /** * Initialise the OS before creating our threads. * * Note that we tell the OS that the idle stack is half its actual * size. This prevents it prefilling the bottom half with known * values for stack-checkig purposes, which we cannot allow because * we are temporarily using it for our own stack. The remainder will * still be available once the OS is started, this only prevents the * OS from prefilling it. * * If you are not reusing the idle thread's stack during startup then * you should pass in the correct size here. */ status = atomOSInit(&idle_thread_stack[IDLE_STACK_SIZE_BYTES - 1], (IDLE_STACK_SIZE_BYTES/2)); if (status == ATOM_OK) { /* Enable the system tick timer */ avrInitSystemTickTimer(); /* Create an application thread */ status = atomThreadCreate(&main_tcb, 16, main_thread_func, 0, &main_thread_stack[MAIN_STACK_SIZE_BYTES - 1], MAIN_STACK_SIZE_BYTES); if (status == ATOM_OK) { /** * First application thread successfully created. It is * now possible to start the OS. Execution will not return * from atomOSStart(), which will restore the context of * our application thread and start executing it. * * Note that interrupts are still disabled at this point. * They will be enabled as we restore and execute our first * thread in archFirstThreadRestore(). */ atomOSStart(); } } while (1) ; /* There was an error starting the OS if we reach here */ return (0); }
int main ( void ) { int8_t status; sei(); SerialInit(MYUBRR); InitWatch(); /** * Reuse part of the idle thread's stack for the stack required * during this startup function. */ SP = (int)&idle_thread_stack[(IDLE_STACK_SIZE_BYTES/2) - 1]; /** * Note: to protect OS structures and data during initialisation, * interrupts must remain disabled until the first thread * has been restored. They are reenabled at the very end of * the first thread restore, at which point it is safe for a * reschedule to take place. */ /** * Initialise the OS before creating our threads. * * Note that we cannot enable stack-checking on the idle thread on * this platform because we are already using part of the idle * thread's stack now as our startup stack. Prefilling for stack * checking would overwrite our current stack. * * If you are not reusing the idle thread's stack during startup then * you are free to enable stack-checking here. */ status = atomOSInit(&idle_thread_stack[0], IDLE_STACK_SIZE_BYTES, FALSE); if (status == ATOM_OK) { /* Enable the system tick timer */ avrInitSystemTickTimer(); /* Create the main thread */ status = atomThreadCreate(&main_tcb, MAIN_THREAD_PRIO, main_thread_func, 0, &main_thread_stack[0], MAIN_STACK_SIZE_BYTES, FALSE); if (status == ATOM_OK) { /** * Application threads successfully created. It is * now possible to start the OS. Execution will not return * from atomOSStart(), which will restore the context of * our application thread and start executing it. * * Note that interrupts are still disabled at this point. * They will be enabled as we restore and execute our first * thread in archFirstThreadRestore(). */ atomOSStart(); } } while (1) { atomTimerDelay (2 * SYSTEM_TICKS_PER_SEC); // wait 2 sec } /* There was an error starting the OS if we reach here */ return (0); }
int main ( void ) { int8_t status; uint32_t loop; /** * Brief delay to give the debugger a chance to stop the core before we * muck around with the chip's configuration. */ for(loop = 0; loop < 1000000; ++loop){ __asm__("nop"); } /** * Note: to protect OS structures and data during initialisation, * interrupts must remain disabled until the first thread * has been restored. They are reenabled at the very end of * the first thread restore, at which point it is safe for a * reschedule to take place. */ board_setup(); /** * Initialise the OS before creating our threads. * * Note that we cannot enable stack-checking on the idle thread on * this platform because we are already using part of the idle * thread's stack now as our startup stack. Prefilling for stack * checking would overwrite our current stack. * * If you are not reusing the idle thread's stack during startup then * you are free to enable stack-checking here. */ status = atomOSInit(&idle_thread_stack[0], IDLE_STACK_SIZE_BYTES, FALSE); if (status == ATOM_OK) { /* Create an application thread */ status = atomThreadCreate(&main_tcb, TEST_THREAD_PRIO, main_thread_func, 0, &main_thread_stack[0], MAIN_STACK_SIZE_BYTES, TRUE); if (status == ATOM_OK) { /** * First application thread successfully created. It is * now possible to start the OS. Execution will not return * from atomOSStart(), which will restore the context of * our application thread and start executing it. * * Note that interrupts are still disabled at this point. * They will be enabled as we restore and execute our first * thread in archFirstThreadRestore(). */ atomOSStart(); } } while (1) ; /* There was an error starting the OS if we reach here */ return (0); }