PIXCIR

    技术2025-04-22  22

    /*******************************************//*    PIXCIR AG, Switzerland         *//*******************************************/

    //#include "compilation_definitions.h"

    /*** Compiler options ***/

    //#define AVR_gcc // ATMEL#define NC30  // RENESAS

    /*** protocol option ***/

    #define PIXCIR_I2C//#define AUO_I2C#define BUTTONS#define F48

    ////            Max number of electrodes//

    #ifdef F48

     #define XMAX  48 #define YMAX  48 #else // F32 or S32

     #define XMAX  32 #define YMAX  32

    #endif

    ////     EEPROM allocation//

    typedef struct{ unsigned char table[XMAX];

    #ifdef NC30

     int           nbr; unsigned int  reserved;

    #else // AVR_gcc

     int           offset[32];

    #endif

    #ifdef F48

     unsigned int  stamp[6]; #else // F32 or S32

     unsigned int  stamp[4];

    #endif  unsigned char sensitivity[XMAX]; unsigned int  setup; unsigned char thr;}electrode_t;

    typedef struct{ unsigned char M0_spi; unsigned char M1_spi;   unsigned char scan_en; unsigned char version[4]; int      X_res;  int      Y_res;  unsigned char move_thr; unsigned char ghost_thr; unsigned char fast; unsigned char special_borders; unsigned char Z_thr; unsigned char power_mode; unsigned char INT_mode; unsigned char INT_width; unsigned char drift_comp; unsigned char subversion; unsigned char noise_thr; unsigned char noise_delay; unsigned char noise_mode; #ifdef NC30

     unsigned char I2C_timeout;    unsigned char I2C_timeout_period; unsigned char interval; //!!!!!!!!!!!!!!!!!!!!!!! BYTE ADDED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

     unsigned char extra_offset;

    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  unsigned char extra_offset_flag; signed char   extra_offset_out[4]; signed char   extra_offset_in[4]; unsigned char raw1_delta_offset; unsigned char raw2_delta_offset; unsigned char M1_calibr;

    #ifdef BUTTONS

     unsigned char button_scan; unsigned char button_axis; int     button_setup_command; unsigned char button_nbr; unsigned char button_spi_speed; unsigned char button_thr_press; unsigned char button_thr_release;

    #ifdef F48

     unsigned char custom[201]; #else // F32 or S32

     unsigned char custom[273];

    #endif

    #else // NO BUTTONS

    #ifdef F48

     unsigned char custom[209]; #else // F32 or S32

     unsigned char custom[281];

    #endif

    #endif

    #else // AVR_gcc

    // int           offset_M1[30];// signed char   border_M1_Y[13][2]; signed char   border_M1_X[20][6]; unsigned char I2C_timeout;   // I2C time-out disabled if 0, enabled if 1 or 2    unsigned char I2C_timeout_period; // I2C time-out period = (I2C_timeout_period * 8.192) ms unsigned char interval; unsigned char extra_offset_flag; signed char   extra_offset_out[4]; signed char   extra_offset_in[4]; unsigned char raw1_delta_offset; unsigned char raw2_delta_offset;// unsigned char M1_calibr;

    #ifdef BUTTONS

     unsigned char button_scan; unsigned char button_axis; int     button_setup_command; unsigned char button_nbr; unsigned char button_spi_speed; unsigned char button_thr_press; unsigned char button_thr_release;

     unsigned char custom[35];

    #else

     unsigned char custom[43];

    #endif

    #endif

     unsigned char bootlock;  // #511 from start of eeprom structure (pinmap)}ee_options_t;

    typedef struct { char    disto[32]; electrode_t  x; electrode_t  y; ee_options_t options;}eeprom_t;

    #ifdef NC30

    ///  ME0 offsets are stored in data Flash Block B/

    #define offset_x   0x3400#define offset_y  (offset_x + ((XMAX-1)*2))

    /*typedef struct{    int x[31]; int y[31];}offset_t;*/

    ///  ME1 offsets are stored in data Flash Block C/

    #define offset_M1  0x3800

    #endif

    ////     RAM allocation//

    /****************************************************************************************************************************//*************************************   AUO I2C protocol   *************************************************//****************************************************************************************************************************/

    #ifdef AUO_I2C

    #define WAKE_UP_BUFFER_SIZE 16

    typedef struct { int posx;           // 1st finger  int posy;   

     int posx2;    // 2nd finger     int posy2;}shadow_t;

    typedef struct { // // READ ONLY  MEMBERS // // PIXCIR_algorithm () will write to these members //

     int posx;            // 1st finger position int posy;   

     int posx2;    // 2nd finger position   int posy2;  // int reserved_1[6];  // Customer reserved space

    /* int raw1;    // Customer reserved space used as debug variables int raw2;  int raw3; int raw4;  int raw5;  int raw6;*/

    // address +8 unsigned char cross_enable;  // Customer reserved space used as crossnode function variables unsigned char cross_x; unsigned char cross_y; int crossing;

    // address +13 unsigned char internal_enable; // Customer reserved space used as internal algorithm check variables  int x_signal;     int y_signal; // address +18 unsigned char noise_mode;  unsigned char noise_level;// unsigned char reserved_1[2]; // Customer reserved space

     unsigned char X1_W;    // Touch areas of each coordinates unsigned char Y1_W; unsigned char X2_W; unsigned char Y2_W;

    // address +24 int initial_distance; int distance; int ratio;// unsigned char reserved_2[6]; // Customer reserved space

     unsigned char X1_Z;    // Finger to panel distance of each coordinates unsigned char Y1_Z; unsigned char X2_Z; unsigned char Y2_Z;

    // address +34// unsigned char synch;   // Synchronization on LCM Vcom signal// unsigned char reserved_3[8];

    // int stack_count;    // Monitors the remaining space between the top of the stack and the bottom of global data section// unsigned char reserved_3[7];

     unsigned char reserved_3[9]; // Customer reserved space

     // // AUO PARAMETERS // //  PIXCIR_algorithm () will read from or write to  //  these members at each iteration.  //  int xy_raw1[31];    // AUO channels, first part

     unsigned char reserved_4;    // address +106    unsigned char subversion;

     unsigned char reserved_5[4]; // Customer reserved space

     unsigned char xthr;      // Threshold for X axis (low => more sensitive)   unsigned char ythr;      // same for Y electrodes

     unsigned char INT_mode;   // Interrupt mode

     unsigned char INT_width;  // Interrupt pulse width

     unsigned char power_mode;    // Power mode

     unsigned char version[4];  // Firmware version // address +120 unsigned char specop;    // Special operation (addr +120 from beginning of RAM table)  unsigned int EEPROM_read_addr;  // Start address of the EEPROM read operation

    // address +123 unsigned int crc;      // CRC checksum of whole program memory

     unsigned char reserved_6[3]; // Customer reserved space

    // address +128 int xy_raw2[31];    // AUO channels, second part

    // address +190 unsigned char interval;

     unsigned char buffer_level;

     int buffer[2*WAKE_UP_BUFFER_SIZE];

     // // PIXCIR PARAMETERS // //  PIXCIR_algorithm () will read from or write to //  these members at each iteration. //

    // address +256 unsigned char M0_spi;     // Method 0 Sensing speed (SPI data rate)           // high nibble for X, low nibble for Y         // high/low pulse width = ((3*k)+2)/8 us           // 2 -> SPI CLK = 500 kHz           // 5 -> SPI CLK = 235 kHz         // A -> SPI CLK = 125 kHz         // F -> SPI CLK =  85 kHz

     unsigned char M1_spi;     // Method 1 Sensing speed (SPI data rate)         // high/low pulse width = ((3*k)+2)/8 us           // 2 -> SPI CLK = 500 kHz           // 5 -> SPI CLK = 235 kHz         // A -> SPI CLK = 125 kHz         // F -> SPI CLK =  85 kHz

     unsigned int strength;   // Signal strength estimation  unsigned char touching;   // Number of fingers on the panel  unsigned char old_touching;   // Previous scan number of fingers on the panel  unsigned char offset;    // Autozero from EEPROM is done if cleared

     int xxraw[XMAX-1+2];     // PIXCIR X raw data

     int yyraw[YMAX-1+2];     // PIXCIR Y raw data

    #ifdef AVR_gcc

    } __attribute__((packed))position_t;

    #else

    }position_t;

    #endif

    #endif

    /****************************************************************************************************************************//*************************************   PIXCIR I2C protocol   *************************************************//****************************************************************************************************************************/

    #ifdef PIXCIR_I2C

    #ifdef NC30

     #define WAKE_UP_BUFFER_SIZE  16

    #else // AVR_gcc

     #define WAKE_UP_BUFFER_SIZE  8

    #endif

    typedef struct { unsigned char touching;         // Number of fingers on the panel unsigned char old_touching;  // Previous scan number of fingers on the panel

     int posx;              // 1st finger  int posy;   

     int posx2;      // 2nd finger     int posy2;

     unsigned char X1_W;    // Touch areas of each coordinates unsigned char Y1_W; unsigned char X2_W; unsigned char Y2_W;

     unsigned char X1_Z;    // Finger to panel distance of each coordinates unsigned char Y1_Z; unsigned char X2_Z; unsigned char Y2_Z;}shadow_t;

    typedef struct{// ----------------------------------------------------------------------------------------------//           Shadow protected// ----------------------------------------------------------------------------------------------

        unsigned char touching;         // Number of fingers on the panel    unsigned char old_touching;  // Previous scan number of fingers on the panel

        int posx;              // 1st finger position    int posy;         int posx2;      // 2nd finger position      int posy2;        unsigned char X1_W;    // Touch areas of each coordinates    unsigned char Y1_W;    unsigned char X2_W;    unsigned char Y2_W;

        unsigned char X1_Z;    // Finger to panel distance of each coordinates    unsigned char Y1_Z;    unsigned char X2_Z;    unsigned char Y2_Z;

    // ----------------------------------------------------------------------------------------------//          End of shadow protection// ----------------------------------------------------------------------------------------------

     unsigned int strength;   // Signal strength estimation

     unsigned char power_mode;    // Power mode unsigned char INT_mode;   // Interrupt mode unsigned char INT_width;  // Interrupt pulse width

     unsigned char noise_mode;     unsigned char noise_thr;    unsigned char noise_level;

    #ifdef BUTTONS

     char reserved_1[15];

    // address +41 char button_flags;

    #else

     char reserved_1[16];

    // char reserved_1[14];

    // address +40// int stack_count;    // Monitors the remaining space between the max top of the stack and the bottom of global data section

    #endif

    // address +42 int initial_distance; int distance; int ratio;

        unsigned char version[4];  // Firmware version    unsigned char subversion;    unsigned int crc;      // CRC checksum of whole program memory

     unsigned char specop;    // Special operation unsigned int EEPROM_read_addr;  // Start address of the EEPROM read operation

     unsigned char xthr;      // Threshold for X axis. Low => more sensible unsigned char ythr;      // same for Y electrodes

     unsigned char synch;   // Synchronization on LCM Vcom signal

    // ----------------------------------------------------------------------------------------------//       PRIVILEGE 1 (necessary for production testing)// ----------------------------------------------------------------------------------------------

    #ifdef F48

        int xy_raw1[XMAX-1];   // Customer channels, first part    int xy_raw2[XMAX-1];   // Customer channels, second part. Used for buttons RAW

    #else

     int xy_raw1[32];    // Customer channels, first part    int xy_raw2[32];    // Customer channels, second part. Used for buttons RAW #endif

        unsigned char cross_enable;  // crossnode function variables    unsigned char cross_x;    unsigned char cross_y;    int crossing;

        unsigned char internal_enable; // internal algorithm check variables    int x_signal;         int y_signal;

     unsigned char interval;   // Wake-up buffer variables unsigned char buffer_level; int buffer[2*WAKE_UP_BUFFER_SIZE];

    // ----------------------------------------------------------------------------------------------//         PRIVILEGE 2 (Private to PIXCIR)// ----------------------------------------------------------------------------------------------

        unsigned char offset;    // Autozero from EEPROM is done if cleared

        unsigned char M0_spi;     // Method 0 Sensing speed (SPI data rate)           // high nibble for X, low nibble for Y         // high/low pulse width = ((3*k)+2)/8 us           // 2 -> SPI CLK = 500 kHz           // 5 -> SPI CLK = 235 kHz         // A -> SPI CLK = 125 kHz         // F -> SPI CLK =  85 kHz

     unsigned char M1_spi;     // Method 1 Sensing speed (SPI data rate)         // high/low pulse width = ((3*k)+2)/8 us           // 2 -> SPI CLK = 500 kHz           // 5 -> SPI CLK = 235 kHz         // A -> SPI CLK = 125 kHz         // F -> SPI CLK =  85 kHz

     int xxraw[XMAX-1+2];     // PIXCIR X raw data int yyraw[YMAX-1+2];     // PIXCIR Y raw data

    #ifdef BUTTONS

     int button_raw_max[8];

    #endif

    #ifdef AVR_gcc

    } __attribute__((packed))position_t;

    #else

    }position_t;

    #endif

    #endif

    /****************************************************************************************************************************//*****************************   drift compensation filter structure   *****************************************//****************************************************************************************************************************/

    typedef struct{ long filter_content[4]; int  real_previous_raw[4];}calib_s;

    /****************************************************************************************************************************//*************************************   functions headers   *************************************************//****************************************************************************************************************************/

    char PIXCIR_algorithm (void);

    最新回复(0)