dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
System

Implementation of annunciation and simple color blending for RGB LEDs. More...

Files

file  systemmod.h
 System module.
 
file  systemmod.c
 System module.
 

Data Structures

struct  EventCallbackInfo
 
struct  PeriodicObjectListStruct
 

Macros

#define DEBUG_MSG(format,...)
 
#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD   995998
 
#define STACK_SIZE_BYTES   1024
 
#define TASK_PRIORITY   PIOS_THREAD_PRIO_NORMAL
 
#define SYSTEM_UPDATE_PERIOD_MS   117
 
#define SYSTEM_UPDATE_PERIOD_MS4TH   (SYSTEM_UPDATE_PERIOD_MS)
 
#define MAX_UPDATE_PERIOD_MS   350
 

Typedefs

typedef struct
PeriodicObjectListStruct 
PeriodicObjectList
 

Functions

void systemmod_process_rgb_leds (bool led_override, bool led_override_active, uint8_t blink_prio, bool is_armed, bool force_dim)
 
int32_t SystemModInitialize (void)
 
static void systemPeriodicCb (const UAVObjEvent *ev, void *ctx, void *obj_data, int len)
 
static void objectUpdatedCb (const UAVObjEvent *ev, void *ctx, void *obj, int len)
 
static uint32_t processPeriodicUpdates ()
 
static int32_t eventPeriodicCreate (UAVObjEvent *ev, UAVObjEventCallback cb, struct pios_queue *queue, uint16_t periodMs)
 
static int32_t eventPeriodicUpdate (UAVObjEvent *ev, UAVObjEventCallback cb, struct pios_queue *queue, uint16_t periodMs)
 
static void configurationUpdatedCb (const UAVObjEvent *ev, void *ctx, void *obj, int len)
 
void system_task ()
 
static void updateStats ()
 
static void updateSystemAlarms ()
 
int32_t SystemModStart (void)
 
 DONT_BUILD_IF (ANNUNCIATORSETTINGS_ANNUNCIATEAFTERARMING_NUMELEM!=ANNUNCIATORSETTINGS_ANNUNCIATEANYTIME_NUMELEM, AnnuncSettingsMismatch1)
 
 DONT_BUILD_IF (ANNUNCIATORSETTINGS_ANNUNCIATEAFTERARMING_MAXOPTVAL!=ANNUNCIATORSETTINGS_ANNUNCIATEANYTIME_MAXOPTVAL, AnnuncSettingsMismatch2)
 
void system_annunc_custom_string (const char *string)
 
void vApplicationIdleHook (void)
 
void EventGetStats (EventStats *statsOut)
 
void EventClearStats ()
 
int32_t EventPeriodicCallbackCreate (UAVObjEvent *ev, UAVObjEventCallback cb, uint16_t periodMs)
 
int32_t EventPeriodicCallbackUpdate (UAVObjEvent *ev, UAVObjEventCallback cb, uint16_t periodMs)
 
int32_t EventPeriodicQueueCreate (UAVObjEvent *ev, struct pios_queue *queue, uint16_t periodMs)
 
int32_t EventPeriodicQueueUpdate (UAVObjEvent *ev, struct pios_queue *queue, uint16_t periodMs)
 
 DONT_BUILD_IF (ANNUNCIATORSETTINGS_MANUALBUZZER_MAXOPTVAL > MANUALCONTROLCOMMAND_ACCESSORY_NUMELEM, TooManyManualBuzzers)
 

Variables

static PeriodicObjectListobjList
 
static struct
pios_recursive_mutex
mutex
 
static EventStats stats
 
static volatile uint32_t idleCounter
 
static volatile uint32_t idleCounterClear
 
static struct pios_thread * systemTaskHandle
 
static struct pios_queueobjectPersistenceQueue
 
static volatile bool config_check_needed
 
static const char *volatile custom_blink_string
 

Detailed Description

Implementation of annunciation and simple color blending for RGB LEDs.

Macro Definition Documentation

#define DEBUG_MSG (   format,
  ... 
)

Definition at line 71 of file systemmod.c.

#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD   995998

Definition at line 75 of file systemmod.c.

#define MAX_UPDATE_PERIOD_MS   350

Definition at line 1008 of file systemmod.c.

#define STACK_SIZE_BYTES   1024

Definition at line 83 of file systemmod.c.

#define SYSTEM_UPDATE_PERIOD_MS   117

Definition at line 100 of file systemmod.c.

#define SYSTEM_UPDATE_PERIOD_MS4TH   (SYSTEM_UPDATE_PERIOD_MS)

Definition at line 101 of file systemmod.c.

#define TASK_PRIORITY   PIOS_THREAD_PRIO_NORMAL

Definition at line 86 of file systemmod.c.

Typedef Documentation

Definition at line 125 of file systemmod.c.

Function Documentation

static void configurationUpdatedCb ( const UAVObjEvent ev,
void *  ctx,
void *  obj,
int  len 
)
static

Called whenever a critical configuration component changes

Definition at line 707 of file systemmod.c.

DONT_BUILD_IF ( ANNUNCIATORSETTINGS_ANNUNCIATEAFTERARMING_NUMELEM!  = ANNUNCIATORSETTINGS_ANNUNCIATEANYTIME_NUMELEM,
AnnuncSettingsMismatch1   
)
DONT_BUILD_IF ( ANNUNCIATORSETTINGS_ANNUNCIATEAFTERARMING_MAXOPTVAL!  = ANNUNCIATORSETTINGS_ANNUNCIATEANYTIME_MAXOPTVAL,
AnnuncSettingsMismatch2   
)
DONT_BUILD_IF ( ANNUNCIATORSETTINGS_MANUALBUZZER_MAXOPTVAL  ,
MANUALCONTROLCOMMAND_ACCESSORY_NUMELEM  ,
TooManyManualBuzzers   
)
void EventClearStats ( )

Clear the statistics counters

Definition at line 869 of file systemmod.c.

void EventGetStats ( EventStats statsOut)

Get the statistics counters

Parameters
[out]statsOutThe statistics counters will be copied there

Definition at line 859 of file systemmod.c.

int32_t EventPeriodicCallbackCreate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
uint16_t  periodMs 
)

Dispatch an event at periodic intervals.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)
Todo:
would be nice to get context record logic in these

Definition at line 884 of file systemmod.c.

int32_t EventPeriodicCallbackUpdate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
uint16_t  periodMs 
)

Update the period of a periodic event.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 896 of file systemmod.c.

static int32_t eventPeriodicCreate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
struct pios_queue queue,
uint16_t  periodMs 
)
static

Dispatch an event through a callback at periodic intervals.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked or zero if none
[in]queueThe queue or zero if none
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 933 of file systemmod.c.

int32_t EventPeriodicQueueCreate ( UAVObjEvent ev,
struct pios_queue queue,
uint16_t  periodMs 
)

Dispatch an event at periodic intervals.

Parameters
[in]evThe event to be dispatched
[in]queueThe queue that the event will be pushed in
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 908 of file systemmod.c.

int32_t EventPeriodicQueueUpdate ( UAVObjEvent ev,
struct pios_queue queue,
uint16_t  periodMs 
)

Update the period of a periodic event.

Parameters
[in]evThe event to be dispatched
[in]queueThe queue
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 920 of file systemmod.c.

static int32_t eventPeriodicUpdate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
struct pios_queue queue,
uint16_t  periodMs 
)
static

Update the period of a periodic event.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked or zero if none
[in]queueThe queue or zero if none
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 978 of file systemmod.c.

static void objectUpdatedCb ( const UAVObjEvent ev,
void *  ctx,
void *  obj_data,
int  len 
)
static

Function called in response to object updates

Definition at line 634 of file systemmod.c.

static uint32_t processPeriodicUpdates ( )
static

Handle periodic updates for all objects.

Returns
The system time until the next update (in ms) or -1 if failed

Definition at line 1014 of file systemmod.c.

void system_annunc_custom_string ( const char *  string)

Definition at line 417 of file systemmod.c.

void system_task ( )

Definition at line 223 of file systemmod.c.

void systemmod_process_rgb_leds ( bool  led_override,
bool  led_override_active,
uint8_t  blink_prio,
bool  is_armed,
bool  force_dim 
)
int32_t SystemModInitialize ( void  )

Initialize the module, called on startup.

Returns
0 on success or -1 if initialization failed

Definition at line 188 of file systemmod.c.

int32_t SystemModStart ( void  )

Create the module task.

Returns
0 on success or -1 if initialization failed

Definition at line 172 of file systemmod.c.

static void systemPeriodicCb ( const UAVObjEvent ev,
void *  ctx,
void *  obj_data,
int  len 
)
static

Definition at line 422 of file systemmod.c.

static void updateStats ( )
inlinestatic

Called periodically to update the WDG statistics Called periodically to update the system stats

Definition at line 735 of file systemmod.c.

static void updateSystemAlarms ( )
inlinestatic

Update system alarms

Definition at line 777 of file systemmod.c.

void vApplicationIdleHook ( void  )

Called by the RTOS when the CPU is idle, used to measure the CPU idle time.

Definition at line 844 of file systemmod.c.

Variable Documentation

volatile bool config_check_needed
static

Definition at line 139 of file systemmod.c.

const char* volatile custom_blink_string
static

Definition at line 140 of file systemmod.c.

volatile uint32_t idleCounter
static

Definition at line 134 of file systemmod.c.

volatile uint32_t idleCounterClear
static

Definition at line 135 of file systemmod.c.

struct pios_recursive_mutex* mutex
static

Definition at line 131 of file systemmod.c.

struct pios_queue* objectPersistenceQueue
static

Definition at line 137 of file systemmod.c.

PeriodicObjectList* objList
static

Definition at line 130 of file systemmod.c.

EventStats stats
static

Definition at line 132 of file systemmod.c.

struct pios_thread* systemTaskHandle
static

Definition at line 136 of file systemmod.c.