You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.3 KiB
174 lines
5.3 KiB
#ifndef MAIN_H_INCLUDED |
|
#define MAIN_H_INCLUDED |
|
|
|
typedef unsigned char U8; |
|
typedef signed char S8; |
|
typedef unsigned short U16; |
|
typedef signed short S16; |
|
typedef unsigned int U32; |
|
typedef signed int S32; |
|
typedef unsigned long long U64; |
|
typedef signed long long S64; |
|
typedef bool BIT; |
|
|
|
#define __FALSE 0 |
|
#define __TRUE 1 |
|
|
|
#define BAD_PIXELS_ARRAY_SIZE 256 |
|
#define NO_MARKER 0 // 'no marker' cluster identifier |
|
#define SN_LENGTH 128 |
|
// FIFO coordinate XY-correction |
|
#define FIFO_X_OFFSET -11 |
|
#define FIFO_Y_OFFSET -4 |
|
//--------------------------------------------------------------------------- |
|
// CMOS matrix definitions |
|
#define IMAGE_CX (320-1) |
|
#define IMAGE_CY (256-1) |
|
#define CELL_SIZE 8 // cluster cell size, in pix |
|
#define IMAGE_CELL_CX ((IMAGE_CX + CELL_SIZE - 1) / CELL_SIZE) |
|
#define IMAGE_CELL_CY ((IMAGE_CY + CELL_SIZE - 1) / CELL_SIZE) |
|
|
|
|
|
typedef struct |
|
{ |
|
U16 bfType; |
|
U32 bfSize; |
|
U16 bfReserved1; |
|
U16 bfReserved2; |
|
U32 bfOffBits; |
|
} BFHEADER; |
|
|
|
typedef struct |
|
{ |
|
U32 biSize; |
|
S32 biWidth; |
|
S32 biHeight; |
|
U16 biPlanes; |
|
U16 biBitCount; |
|
U32 biCompression; |
|
U32 biSizeImage; |
|
S32 biXPelsPerMeter; |
|
S32 biYPelsPerMeter; |
|
U32 biClrUsed; |
|
U32 biClrImportant; |
|
} BIHEADER; |
|
|
|
|
|
typedef struct |
|
{ |
|
U8 rgbBlue; |
|
U8 rgbGreen; |
|
U8 rgbRed; |
|
U8 rgbReserved; |
|
} RGBQ; |
|
|
|
typedef struct |
|
{ |
|
float x; |
|
float y; |
|
} FIFO_ITEM_f; |
|
|
|
static unsigned short read_u16(FILE *fp); |
|
static unsigned int read_u32(FILE *fp); |
|
static int read_s32(FILE *fp); |
|
|
|
|
|
#pragma pack(push, 1) |
|
typedef struct |
|
{ |
|
unsigned short left; |
|
unsigned short top; |
|
unsigned short right; |
|
unsigned short bottom; |
|
|
|
} ARM_RECT; |
|
|
|
typedef struct |
|
{ |
|
U16 x; |
|
U16 y; |
|
} FIFO_ITEM; |
|
|
|
typedef struct |
|
{ |
|
U16 count; |
|
FIFO_ITEM array[BAD_PIXELS_ARRAY_SIZE]; |
|
} BAD_PIX_FILE_STRUCTURE; |
|
|
|
typedef struct |
|
{ |
|
FIFO_ITEM *pi; |
|
U8 *pm; |
|
} THE_POINT; |
|
|
|
typedef struct |
|
{ |
|
U16 count; // number of points (pixels) in cluster |
|
U8 excluded; // flag, cluster should be ignored if TRUE |
|
U8 marker; // cluster identicator |
|
ARM_RECT rect; // rectangular area of cluster (in pixels) |
|
} CLUSTER_COORD; |
|
|
|
typedef struct |
|
{ |
|
U32 time; // time of alarm, in 10us units |
|
S16 angle1; // |
|
S16 angle2; // |
|
} COORDS_DATA; |
|
|
|
typedef struct |
|
{ |
|
U8 szSerialNumber[SN_LENGTH];// matrix serial number, zero-terminated string |
|
U16 nXc, nYc; // centers of matrices, pix |
|
U16 nRs, nRb; // lens field of view radius ('s'=small, 'b'=big), pix |
|
U8 cLc; // neighbour distance for clasters, pix |
|
U16 nLimit; // FIFO limit (10-bit) |
|
U16 nVinb, nVref; // VINB & VREF (10-bit) |
|
float fA, fB, fC; // Fi=A*x^2 + Bx + C |
|
} CONFIG_FILE_STRUCTURE; |
|
|
|
#pragma pack(pop) |
|
|
|
|
|
#define COORDS_FIFO_SIZE 16 // maximum number of items in coordinates FIFO array |
|
//---------------------------------------------------------------------------- |
|
#define ENTER_CRITICAL_SECTION() os_mut_wait(g_mutex, 0xffff) |
|
#define LEAVE_CRITICAL_SECTION() os_mut_release(g_mutex) |
|
//---------------------------------------------------------------------------- |
|
// constant variables |
|
static const char g_badpix_filename1[] = "S:\\bad_pix1.raw"; |
|
static const char g_badpix_filename2[] = "S:\\bad_pix2.raw"; |
|
static const char g_config_filename1[] = "S:\\config1.raw"; |
|
static const char g_config_filename2[] = "S:\\config2.raw"; |
|
//---------------------------------------------------------------------------- |
|
// common inter-task variables (access-protected by mutex) |
|
static U64 g_init_time_10us; |
|
static COORDS_DATA g_coords[COORDS_FIFO_SIZE]; // coordinates FIFO array |
|
static U16 g_coords_index = 0; // index of 1-st free item in array |
|
//---------------------------------------------------------------------------- |
|
// transmittion task CAN id |
|
//---------------------------------------------------------------------------- |
|
// bad pixels & config variables |
|
static BAD_PIX_FILE_STRUCTURE g_bad_pixels1; // bad pixel array for CMOS1 |
|
static BAD_PIX_FILE_STRUCTURE g_bad_pixels2; // bad pixel array for CMOS2 |
|
static CONFIG_FILE_STRUCTURE g_config1; // config settings for CMOS1 |
|
static CONFIG_FILE_STRUCTURE g_config2; // config settings for CMOS2 |
|
// shot fifo & cluster variables |
|
static FIFO_ITEM g_shot_array1[4096]; // shot XY-coordinates from FIFO1 |
|
static FIFO_ITEM g_shot_array2[4096]; // shot XY-coordinates from FIFO2 |
|
static U16 g_shot_count1; // number of shot XY-coordinate pairs in FIFO1 |
|
static U16 g_shot_count2; // number of shot XY-coordinate pairs in FIFO2 |
|
static CLUSTER_COORD g_cluster_coords1[IMAGE_CELL_CX*IMAGE_CELL_CY]; // clusters mass centre & coordinates in FIFO1 |
|
static CLUSTER_COORD g_cluster_coords2[IMAGE_CELL_CX*IMAGE_CELL_CY]; // clusters mass centre & coordinates in FIFO2 |
|
static CLUSTER_COORD *g_cluster_ptrs1[IMAGE_CELL_CX*IMAGE_CELL_CY]; // |
|
static CLUSTER_COORD *g_cluster_ptrs2[IMAGE_CELL_CX*IMAGE_CELL_CY]; // |
|
static U16 g_cluster_count1; // number of clusters (8x8) in FIFO1 |
|
static U16 g_cluster_count2; // number of clusters (8x8) in FIFO2 |
|
static CLUSTER_COORD g_super_cluster_coords1[IMAGE_CELL_CX*IMAGE_CELL_CY]; |
|
static CLUSTER_COORD g_super_cluster_coords2[IMAGE_CELL_CX*IMAGE_CELL_CY]; |
|
static U16 g_super_cluster_count1; // number of super clusters in FIFO1 |
|
static U16 g_super_cluster_count2; // number of super clusters in FIFO2 |
|
|
|
|
|
|
|
#endif // MAIN_H_INCLUDEDs
|