Modbus Vault v1.0
Loading...
Searching...
No Matches
controller.c File Reference

Implementation of the system orchestration layer. More...

#include "controller.h"
#include "esp_err.h"
#include "esp_timer.h"
#include "metrics.h"
#include "runtime_tasks.h"
#include "slab_pool.h"
#include "system_init.h"
#include "telemetry_service.h"
Include dependency graph for controller.c:

Macros

#define CONTROLLER_WAIT_ON_LOCK_TIME_US   (100U)
 
#define CONTROLLER_YIELD_TIME_US   (1000000U)
 

Functions

static void set_state_helper (controller_state_t new_state)
 Set controller state.
 
static esp_err_t handle_init_helper (void)
 Handles system initialization.
 
static void handle_deinit_helper (void)
 Handles system deinitialization.
 
void controller_run (void)
 Start controller.
 
controller_state_t controller_get_state (void)
 Get current controller state.
 
void controller_request_stop (void)
 Stop controller.
 

Variables

static controller_state_t current_state = CONTROLLER_STATE_UNINITIALIZED
 
static SemaphoreHandle_t state_mutex = NULL
 

Detailed Description

Implementation of the system orchestration layer.

Author
Abanoub Salah
  • Goes through different controller states throughout application life
    • Initialization: Initialize system and start tasks
    • Running: System is running
    • Fault: System is in critical error state
    • Stopping: System is stopping (reversing init step)
  • Provides APIs to get/set current controller state

Macro Definition Documentation

◆ CONTROLLER_WAIT_ON_LOCK_TIME_US

#define CONTROLLER_WAIT_ON_LOCK_TIME_US   (100U)

State lock wait timeout in micro seconds

◆ CONTROLLER_YIELD_TIME_US

#define CONTROLLER_YIELD_TIME_US   (1000000U)

Yield time of control loop in micro seconds

Function Documentation

◆ controller_get_state()

controller_state_t controller_get_state ( void  )

Get current controller state.

Returns
Controller state

< State lock wait timeout in micro seconds

Here is the caller graph for this function:

◆ controller_request_stop()

void controller_request_stop ( void  )

Stop controller.

Request deinitialize and stopping of different system components

Here is the call graph for this function:

◆ controller_run()

void controller_run ( void  )

Start controller.

Initialize, setup and start different system components

< Yield time of control loop in micro seconds

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_deinit_helper()

static void handle_deinit_helper ( void  )
static

Handles system deinitialization.

  • Deinitialize different system components
  • Stop different system tasks
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_init_helper()

static esp_err_t handle_init_helper ( void  )
static

Handles system initialization.

  • Initialize different system components
  • Start different system tasks
Returns
esp_err_t Handle result
Return values
ESP_OKHandle success
anyAny error from down layers propagates upward
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_state_helper()

static void set_state_helper ( controller_state_t  new_state)
static

Set controller state.

Parameters
new_stateController state

< State lock wait timeout in micro seconds

Here is the caller graph for this function:

Variable Documentation

◆ current_state

Current controller state

◆ state_mutex

SemaphoreHandle_t state_mutex = NULL
static

State lock handle