LibSpindle-C-Library 1.0
Library Code documentation
Loading...
Searching...
No Matches
Spindle.h File Reference
#include "Console.h"
+ Include dependency graph for Spindle.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SpindlePhysicalParams
 

Typedefs

typedef struct SpindleHandle * SpindleHandle_t
 
typedef struct SpindlePhysicalParams SpindlePhysicalParams_t
 

Functions

SpindleHandle_t SPINDLE_CreateInstance (unsigned int uxStackDepth, int xPrio, ConsoleHandle_t cH, SpindlePhysicalParams_t *p)
 

Typedef Documentation

◆ SpindleHandle_t

typedef struct SpindleHandle* SpindleHandle_t

The SpindleHandle_t handle is an instance pointer of the spindle library which is generated whenever the SPINDLE_CreateInstance function returns with success.

◆ SpindlePhysicalParams_t

The SpindlePhysicalParams_t structure is represents the abstraction functions and members as a container. The objetcs are passed as structure pointer when calling SPINDLE_CreateInstance. It contains function pointers to platform specific functions which enable the spindle or regulate the speed and direction of it. There are also limit values for the maximum, minimum and absolute minimum RPM and an additional context pointer which is passed the the abstraction functions. The user must provide a configured structure in its design when calling SPINDLE_CreateInstance.

Function Documentation

◆ SPINDLE_CreateInstance()

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!