Michael Hogan / Mbed 2 deprecated Hamamatsu_C12666MA

Dependencies:   mbed

C12666.h

Committer:
mikehogan62
Date:
2016-12-15
Revision:
0:575ebe257bd6

File content as of revision 0:575ebe257bd6:

#ifndef C1266_H
#define C1266_H
#include "mbed.h"


enum SpecState {spec_idle, spec_start, spec_sample_clock0, spec_sample_clock1, spec_sample_clock2, spec_sample_clock3};

// number of different spectral bins
#define SPEC_CHANNELS    256

// default clock pulse width
#define DEFAULT_CLOCK_PULSE_US 100

// shortest clock pulse width we will permit
#define MIN_CLOCK_PULSE_US     5

// default gain limits for hi gain and low gain
// If we exceed these levels, 
#define DEFAULT_VIDEO_AD_MAX_HI_GAIN 40000
#define DEFAULT_VIDEO_AD_MAX_LO_GAIN 32000

#define DEFAULT_VIDEO_BIAS 0
#define SPEC_SERIAL_NUM_LEN 32



void specClockFn();

class C12666_spectrometer 
{
    public:
    C12666_spectrometer();
    ~C12666_spectrometer();


        // set the serial number and calibration coefficients for that serial number
        void setCalibration(const char* psz_newSerialNum, double newA_0, double newB_1, double newB_2, double newB_3, double newB_4, double newB_5){
            strncpy(pszSerialNum, psz_newSerialNum, SPEC_SERIAL_NUM_LEN-1);
            A_0 = newA_0;
            B_1 = newB_1;
            B_2 = newB_2;
            B_3 = newB_3;
            B_4 = newB_4;
            B_5 = newB_5;
            
        }
        
        // retrieve all of the calibration coefficients
        void getCalibration(char* psz_getSerialNum, double& getA_0, double& getB_1, double& getB_2, double& getB_3, double& getB_4, double& getB_5){
            strncpy(psz_getSerialNum, pszSerialNum, SPEC_SERIAL_NUM_LEN-1);
            getA_0 = A_0;
            getB_1 = B_1;
            getB_2 = B_2;
            getB_3 = B_3;
            getB_4 = B_4;
            getB_5 = B_5;        
        }   
        
        void getVolatileParams(int& specClockSig_, int& specReady_, SpecState& specState_, int& specDataIndex_, unsigned int& specBufferFilling_);
        void getRawSpectrum(uint16_t* rawSpectrumBuffer);
        
        void Start();
        void Stop();
        void setNumDarks();
        
        void setWhiteLED(int onOrOff);
        void setUVLED(int onOrOff);
        void setClockPeriod(long clockPeriod_usec);
        inline long getClockPeriod(){ return clockPulse_us; }

        
    protected:
        
        
        timestamp_t clockPulse_us;
        

        
        


        char pszSerialNum[SPEC_SERIAL_NUM_LEN];
        double A_0;
        double B_1;
        double B_2;
        double B_3;
        double B_4;
        double B_5;
        

};

#endif