main function is now executed as kosmos thread
This commit is contained in:
parent
2fb1904de5
commit
2e874a9d56
@ -76,7 +76,7 @@ __initialize_args (int*, char***);
|
|||||||
// by redefining __initialize_args(), which is done when the
|
// by redefining __initialize_args(), which is done when the
|
||||||
// semihosting configurations are used.
|
// semihosting configurations are used.
|
||||||
extern int
|
extern int
|
||||||
main (int argc, char* argv[]);
|
start_application (int argc, char* argv[]);
|
||||||
|
|
||||||
// The implementation for the exit routine; for embedded
|
// The implementation for the exit routine; for embedded
|
||||||
// applications, a system reset will be performed.
|
// applications, a system reset will be performed.
|
||||||
@ -311,7 +311,7 @@ _start (void)
|
|||||||
__run_init_array ();
|
__run_init_array ();
|
||||||
|
|
||||||
// Call the main entry point, and save the exit code.
|
// Call the main entry point, and save the exit code.
|
||||||
int code = main (argc, argv);
|
int code = start_application (argc, argv);
|
||||||
|
|
||||||
// Run the C++ static destructors.
|
// Run the C++ static destructors.
|
||||||
__run_fini_array ();
|
__run_fini_array ();
|
||||||
|
31
source/firmware/kernel/application.c
Normal file
31
source/firmware/kernel/application.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* application.c
|
||||||
|
*
|
||||||
|
* Created on: Aug 20, 2016
|
||||||
|
* Author: tkl
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "queue.h"
|
||||||
|
#include "stack.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
|
||||||
|
static struct thread_context main_task;
|
||||||
|
static stack_t main_stack[0xFF];
|
||||||
|
|
||||||
|
extern void main(void *arg);
|
||||||
|
|
||||||
|
int start_application (int argc, char* argv[])
|
||||||
|
{
|
||||||
|
board_init();
|
||||||
|
|
||||||
|
thread_create(&main_task, main_stack, 0xFF, main, NULL, THREAD_PRIO_IDLE);
|
||||||
|
schedule_start();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -16,10 +16,7 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|
||||||
#define TH_STACK_SIZE 256
|
int main(void)
|
||||||
stack_t th_stack[TH_STACK_SIZE];
|
|
||||||
struct thread_context th_ctx;
|
|
||||||
static void th_func(void *arg)
|
|
||||||
{
|
{
|
||||||
drv_open(&pwm_1);
|
drv_open(&pwm_1);
|
||||||
drv_open(&pwm_2);
|
drv_open(&pwm_2);
|
||||||
@ -41,13 +38,6 @@ static void th_func(void *arg)
|
|||||||
sleep_ms(10);
|
sleep_ms(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
board_init();
|
|
||||||
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
|
|
||||||
schedule_start();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,12 @@ static struct command cmd = {
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
|
||||||
shell_init(&uart_1);
|
shell_init(&uart_1);
|
||||||
shell_add_command(&cmd);
|
shell_add_command(&cmd);
|
||||||
schedule_start();
|
|
||||||
|
while(1) {
|
||||||
|
sleep_ms(1000);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -20,26 +20,13 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||||
#pragma GCC diagnostic ignored "-Wreturn-type"
|
#pragma GCC diagnostic ignored "-Wreturn-type"
|
||||||
|
|
||||||
#define TH_STACK_SIZE 256
|
int main(int argc, char* argv[])
|
||||||
stack_t th_stack[TH_STACK_SIZE];
|
|
||||||
struct thread_context th_ctx;
|
|
||||||
static void th_func(void *arg)
|
|
||||||
{
|
{
|
||||||
drv_open(&uart_1);
|
drv_open(&uart_1);
|
||||||
while(1) {
|
while(1) {
|
||||||
drv_write(&uart_1, "test\r\n", 6);
|
drv_write(&uart_1, "test\r\n", 6);
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
board_init();
|
|
||||||
timer_open(&timer_1);
|
|
||||||
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
|
|
||||||
|
|
||||||
schedule_start();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user