CachedGlobalStatus definition for FX3 v.60

cached_global_state_v60.h
// --------------------------------------------
#pragma pack(push, 1)
// --------------------------------------------
 
// global state of periferals cached in a single place for convenient access from everywhere
// this also allows us to implement API access to "internals" for debugging and monitoring
struct CachedGlobalState{
    uint16_t last_usb_log_idx;          // for drainig the logs out
    bool     force_fan_on_aux_pwr  :1;  // automatically turn the fan on if running on AUX power
    bool     sfp_present           :1;  // `1` if there's a device present in SFP+ cage
    uint8_t  last_error_code;           // last error code (if any) saved in fatal error handler
    float    awb_convergence_speed;     // in range 0..1 (for AWB)
    ///////////////////////////////// 8
    uint32_t awb_oe_trig_count;     // FPGA reported a red overexposure event during AWB stats' accumulation
    uint16_t awb_temp_hysteresis;
    uint8_t  awb_hysteresis;
    uint8_t  ae_hysteresis;
    ///////////////////////////////// 8
    PUInt32  sensor_exposure;
    PUInt16  sensor_gain_global;
    PUInt16  sensor_tgt_gain_g;
    ///////////////////////////////// 8
    uint8_t  sensor_tgt_y_avg;
    uint8_t  r3;
    PUInt16  sensor_gain_r;
    PUInt16  sensor_gain_b;
    PInt16   fpga_gain_r;
    ///////////////////////////////// 8
    PInt16   fpga_gain_b;
    // background scheduler is based off of the sleep(interval_main_step) in the main loop which non-blockingly waits before running tasks
    PUInt16 bg_main_step;           // minimal polling interval for BG tasks
    uint16_t r1;
    uint16_t r2;
    ///////////////////////////////// 8
    struct{
        PUInt16 color_grading       // push Color Grading tables from cache to FPGA
              , autoexp             // autoexposure
              , awb                 // auto white balance
              , sfp                 // SFP+ cage's PnP
              , log                 // send accumulated logs from gl_UsbLogBuffer using CyU3PDebugPrint()
              , health              // check for internal errors and report via CyU3PDebugPrint()
              , aux_pwr;            // use power more liberally when running on AUX
    } bg_interval                   // frequency of running a background task (the shorter the interval - the higher the frequency)
    , bg_clock                      // bg task's timer counter
    , bg_active_work;               // count how many times bg task performed meaningful work (should usually be <= bg_invocation's counter)
    char    last_error_text[63];    // human-readable text of the fatal error
};
C_ASSERT(sizeof(CachedGlobalState) == 40+7*2*3+63);
 
// --------------------------------------------
#pragma pack(pop)
// --------------------------------------------