CachedGlobalStatus definition for FX3 v.59

cached_global_state_v59.h
// --------------------------------------------
#pragma pack(push, 1)
// --------------------------------------------
 
typedef struct UvcSelectedMode{
    float           fps;
    UvcFrameGeom    geometry: 2; // just an enum
    UvcFrameFmt     format: 2;   // just an enum
    uint8_t         reserved: 4;
} UvcMode;
C_ASSERT(sizeof(UvcMode) == 5);
 
typedef union FpgaCtrlReg{
    uint8_t bm;
    struct{
        uint8_t video_en : 1;
        uint8_t audio_en : 1;
        uint8_t hsub_en : 1;
        uint8_t dpc_en : 1;
        uint8_t fmt_select : 1;    // 0 - YUY2, 1 - NV12
        uint8_t video_raw : 1;
        uint8_t fan_en : 1;
        uint8_t cfg_en : 1;
    };
} FpgaCtrlReg;
C_ASSERT(sizeof(FpgaCtrlReg) == 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
typedef struct {
    uint16_t fpga_build;
    FpgaCtrlReg fpga_ctrl;              // FX3 controls the state of this FPGA register so makes sense to cache it here for faster read access
    uint8_t  gpif_initialized      :1;  // whether the GPIF init function has been called
    uint8_t  fpga_cfg_ready        :1;  // true if FPGA Configuration DMA has been configured
    uint8_t  force_fan_on_aux_pwr  :1;  // automatically turn the fan on if running on AUX power
    uint8_t  uvc_streaming_started :1;  // whether USB host has started streaming video
    uint8_t  uac_streaming_started :1;  // whether USB host has started streaming audio
    uint8_t  sfp_present           :1;  // `1` if there's a device present in SFP+ cage
    UvcMode  uvc_mode;
    uint8_t  sensor_tgt_y_avg;
    uint16_t sensor_tgt_gain_g;
    int16_t  sensor_gain_r;
    int16_t  sensor_gain_b;
    int16_t  fpga_gain_r;
    int16_t  fpga_gain_b;
    uint32_t awb_oe_trig_count;     // FPGA reported a red overexposure event during AWB stats' accumulation
    uint16_t last_usb_log_idx;      // for drainig the logs out
    // background scheduler is based off of the CyU3PThreadSleep(interval_main_step) in the main loop which non-blockingly waits before running tasks
    uint16_t bg_main_step;          // minimal polling interval for BG tasks
    struct{
        uint16_t color_grading      // push Color Grading tables from cache to FPGA
               , autoexp            // AE
               , awb                // AWB
               , 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_invocation                 // bg task's invocation counter
    , bg_active_work;               // count how many times bg task performed meaningful work (should usually be <= bg_invocation's counter)
} CachedGlobalState;
C_ASSERT(sizeof(CachedGlobalState) == 84);
 
// --------------------------------------------
#pragma pack(pop)
// --------------------------------------------