/* * ISDM.h * */ #ifndef ISDM_H_ #define ISDM_H_ // 1byte #define byte unsigned char // 2bytes #define word unsigned short int // 4 bytes #define uint unsigned int #ifdef __APP_EWO_VARIABLE_C__ #define _EXTERN #else #define _EXTERN extern #endif _EXTERN byte G14_ISDM_isdm_stat; // 3,2,1: still counting, 0: calculation done _EXTERN byte G14_ISDM_isdm_avg_done; // 0: noise background calculation is going on, not allowed to kill process // 1: background calculation done process kill is allowed _EXTERN unsigned char G14uc_ISDM_init; _EXTERN unsigned char G14uc_ISDM_reset; _EXTERN unsigned char G14uc_ISDM_WPTP_gain; _EXTERN unsigned char G14uc_ISDM_EWO_gain; typedef struct G14_ISDM_conf { int E_Bgnd; // below this we have nothing int E_Proc; // above this is strong signal word NB_SNR; // if peak is higher (above noise background) than this value it can be narrow band word NB_Pw_SN; // peak width calculated at (peak*NB_Pw_SN)/256 byte NB_Pw_Lines; // peak width at (peak - NB_Pw_SN) bigger than this it is not narrow word Mid_SNR; // if peak is higher (above noise background) than this value it can be mid band word Mid_Pw_SN; // peak width calculated at (peak*Mid_Pw_SN)/256 byte Mid_Pw_Lines; // peak width at (peak - Mid_Pw_SN) bigger than this it is not mid word WB_SNR; // if peak is higher (above noise background) than this value it can be wide band word WB_Pw_SN; // peak width calculated at (peak*WB_Pw_SN)/256 byte WB_Pw_Lines; // peak width at (peak - WB_Pw_SN) bigger than this it is not wide word Multi_SNR; // if more than 2 peak is higher (above noise background) than this value it can be multi peak word Multi_Pw_SN; // peak width calculated at (peak*Multi_Pw_SN)/256 byte Multi_Pw_Lines; // peak width at (peak - Multi_Pw_SN) bigger than this it is not peak for multi word Init[7]; // [0] peak energy limit - only above this energy value we call a peak to peak // [1] frame limit - above this number of frames we have long signal // [2] peak high limit - only above this this heigth value we call a peak to peak // [3] below this energy delta quality is 0 // [4] below this energy delta quality is 1 // [5] below this energy delta quality is 2 above this 3 // [6] low byte: allowed position delta for long discrete // high byte: sm_points value. The number of points averaged when smoothing spectrum. }__attribute__((__packed__)) G14_ISDM_configstr; struct G14_ISDM_event_str { byte Event; int e_time; }; struct G14_ISDM_peak_buffer{ byte pos; byte wide; int h; }__attribute__((__packed__)); // Moved from app14_EWO_ISDM.c (T.Imachi) // ============================================================================ #ifdef __APP_EWO_VARIABLE_C__ // 実体宣言 G14_ISDM_configstr G14_ISDM_Config; // config values word G14_ISDM_RefSpect[256]; // reference spectrum int G14_ISDM_sm_points=5; // number of points to average int G14_ISDM_sm_pointsd2=2; // number of points left or right from middle point unsigned int G14_ISDM_noiseback_cnt[256]; // summ of last 16 spectra line unsigned short G14_ISDM_noiseback[256]; // averaged noise background byte G14_ISDM_noiseback_ptr = 16; // pointer for last unsigned short G14_ISDM_in_spect[17][256]; // last 16 incoming spectra line int G14_ISDM_energy_ns = 0; // energy of noise bacground byte G14_ISDM_event_on = 0; // 1: inside event, 0: no event byte G14_ISDM_event_fcnt = 0; // counting frames during event struct G14_ISDM_peak_buffer G14_ISDM_peak_b[17][4]; // buffer for storage 4 largest peaks for every frame in in_spect buffer byte G14_ISDM_pb_cnt[17] = {0}; // buffer peak_cnt byte G14_ISDM_avg_lock = 0; // when 16 noise background contains valid spectra byte G14_ISDM_isdm_stat = 0; // 3,2,1: still counting, 0: calculation done byte G14_ISDM_isdm_avg_done = 0; // 0: background calculation is going not allowed to kill process // 1: background calculation done process kill is allowed #else // extern 宣言 extern G14_ISDM_configstr G14_ISDM_Config; // config values extern word G14_ISDM_RefSpect[256]; // reference spectrum extern int G14_ISDM_sm_points; // number of points to average extern int G14_ISDM_sm_pointsd2; // number of points left or right from middle point extern unsigned int G14_ISDM_noiseback_cnt[256]; // summ of last 16 spectra line extern unsigned short G14_ISDM_noiseback[256]; // averaged noise background extern byte G14_ISDM_noiseback_ptr ; // pointer for last extern unsigned short G14_ISDM_in_spect[17][256]; // last 16 incoming spectra line extern int G14_ISDM_energy_ns; // energy of noise bacground extern byte G14_ISDM_event_on; // 1: inside event, 0: no event extern byte G14_ISDM_event_fcnt; // counting frames during event extern struct G14_ISDM_peak_buffer G14_ISDM_peak_b[17][4]; // buffer for storage 4 largest peaks for every frame in in_spect buffer extern byte G14_ISDM_pb_cnt[17]; // buffer peak_cnt extern byte G14_ISDM_avg_lock; // when 16 noise background contains valid spectra extern byte G14_ISDM_isdm_stat; // 3,2,1: still counting, 0: calculation done extern byte G14_ISDM_isdm_avg_done ; // 0: background calculation is going not allowed to kill process // 1: background calculation done process kill is allowed #endif // ============================================================================ // ISDM table // ROM table for test #ifdef __APP_EWO_VARIABLE_C__ /* unsigned char G14uc_ISDM_table[74] = { // Config parameters 42 bytes 0x7C, 0x01, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x03, 0xB3, 0x00, 0x06, 0x00, 0x03, 0xB3, 0x00, 0x0A, 0x00, 0x03, 0xB3, 0x00, 0x14, 0x00, 0x03, 0xB3, 0x00, 0x04, 0x4C, 0x01, 0x05, 0x00, 0x80, 0x02, 0x00, 0x02, 0x00, 0x0A, 0x40, 0x1F, 0x02, 0x05, // Reference Spectrum 32 bytes 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; */ unsigned char G14uc_ISDM_table[74]; #else extern unsigned char G14uc_ISDM_table[74]; #endif // Function prototype (T.Imachi) _EXTERN struct G14_ISDM_event_str app14_ISDM(int Time, unsigned short* Spect, byte Init, byte GainChanged); #endif /* ISDM_H_ */