diff --git a/src/gsensor.c b/src/gsensor.c index 805820e..95c909b 100644 --- a/src/gsensor.c +++ b/src/gsensor.c @@ -21,7 +21,7 @@ typedef struct { int8_t g; } pakketje; -void * GSensorTask(void *args) { +void * GSensorThread(void *args) { I2C_Handle speedyBoy; @@ -44,10 +44,10 @@ void * GSensorTask(void *args) { while(1) { bool success = I2C_transfer(speedyBoy, &RW_Trans); if (success == false) { - while(1); // als een connectie niet kan worden gemaakt, blijf hier.w + while(1); // als een connectie niet kan worden gemaakt, blijf hier } // publish read into mailbox (defined in mqtt.c) - timer++; + timer += 0.1; sleeper = 6000000; pakketje pakket; diff --git a/src/header.h b/src/header.h index d73ea59..4478da7 100644 --- a/src/header.h +++ b/src/header.h @@ -1,4 +1,4 @@ -void * GSensorTask(void *args); +void * GSensorThread(void *args); void * MQTTTask(void *args); void * SocketTask(void *args); diff --git a/src/main.c b/src/main.c index 9819806..dda3ee5 100644 --- a/src/main.c +++ b/src/main.c @@ -3,28 +3,63 @@ #include #include #include "ti_drivers_config.h" +#include +#include -#include "debug/debug.h" -#include "header.h" +#include "./header.h" + +#define BIGOLTHREADSTACK 4096 void Hardware_init(){ - Board_init(); - GPIO_init(); - uartHandle = InitTerm(); - LOG_TRACE("Hardware initialisation done\r\n"); + Board_init(); + GPIO_init(); + I2C_init(); } int main(void){ - Hardware_init(); // initilize hardware - // ============================================== - // === tread for G sensor ======================= - // ============================================== + pthread_t thread; + pthread_attr_t attrs; + struct sched_param priParam; + int retc; + + Hardware_init(); // initialize hardware + + /* Initialize the attributes structure with default values */ + pthread_attr_init(&attrs); + + /* Set priority, detach state, and stack size attributes */ + priParam.sched_priority = 1; + retc = pthread_attr_setschedparam(&attrs, &priParam); + retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); + retc |= pthread_attr_setstacksize(&attrs, BIGOLTHREADSTACK); + if (retc != 0) { + /* failed to set attributes */ + while(1); + } + /* ============================================== + === tread for G sensor ======================= + ============================================== + */ + retc = pthread_create(&thread, &attrs, GSensorThread, NULL); + if (retc != 0) { + /* pthread_create() failed */ + while(1); + } - BIOS_start(); + BIOS_start(); - return 0; + return (0); +} + +/* + * ======== dummyOutput ======== + * Dummy SysMin output function needed for benchmarks and size comparison + * of FreeRTOS and TI-RTOS solutions. + */ +void dummyOutput(void) +{ }