![]() |
LibSpindle-C-Library 1.0
Library Code documentation
|
#include "Spindle.h"#include "FreeRTOS.h"#include "task.h"#include "semphr.h"#include "queue.h"#include "timers.h"#include <malloc.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/queue.h>#include <math.h>
Include dependency graph for Spindle.c:Data Structures | |
| struct | StepCommandResponse |
| struct | CtrlCommand |
| struct | stepSyncEventElement |
| struct | SpindleHandle |
Macros | |
| #define | ON_NULL_GOTO_ERROR(x) |
Typedefs | |
| typedef struct StepCommandResponse | StepCommandResponse_t |
| typedef struct CtrlCommand | CtrlCommand_t |
| typedef struct stepSyncEventElement | stepSyncEventElement_t |
Enumerations | |
| enum | CtrlCommandType_t { cctNONE = 0x00 , cctSTART = 0x01 , cctSTOP = 0x02 , cctSTATUS = 0x04 } |
Functions | |
| static void | SpindleFunction (void *arg) |
| static SemaphoreHandle_t | GetCommandEvent (SpindleHandle_t h) |
| static void | ReleaseCommandEvent (SpindleHandle_t h, SemaphoreHandle_t s) |
| static int | SpindleConsoleFunction (int argc, char **argv, void *ctx) |
| static void | SpindleRegisterBasicCommands (SpindleHandle_t h, ConsoleHandle_t cH) |
| SpindleHandle_t | SPINDLE_CreateInstance (unsigned int uxStackDepth, int xPrio, ConsoleHandle_t cH, SpindlePhysicalParams_t *p) |
Variables | |
| static SpindleHandle_t | SpindleInstancePointer = NULL |
| #define ON_NULL_GOTO_ERROR | ( | x | ) |
| SpindleHandle_t SPINDLE_CreateInstance | ( | unsigned int | uxStackDepth, |
| int | xPrio, | ||
| ConsoleHandle_t | cH, | ||
| SpindlePhysicalParams_t * | p ) |
The SPINDLE_CreateInstance function is used to create the spindle controller. There is a singleton pattern implemented for the controller so there is only one instance possible for the design. In case it is called multiple times, it returns the instance pointer of the first created spindle controller
The return value of SPINDLE_CreateInstance is a null pointer in case an error occured or a pointer of type SpindleHandle_t.
param uxStackDepth is the stack depth of the console processor thread in words param xPrio is the spindle controller priority. param cH of type ConsoleHandle_t is the handle pointer of a console processor instance which is required to register the console command for the spindle controller param p of type SpindlePhysicalParams_t* is a pointer to the platform abstraction functions
ATTENTION: This function is not locked or guarded and therefore its never thread safe when calling from two different threads at the same or nearly the same time while no instance has been created before! One pointer and its ressources could be lost which leads to a memory leak and/or to console command registration issues at runtime when using the spindle command!