281 lines
13 KiB
C
Executable File
281 lines
13 KiB
C
Executable File
/*
|
|
************************************************************************
|
|
**
|
|
** Copyright (c) 2007 by
|
|
** Arcobel ASIC Design Centre B.V.
|
|
** Hambakenwetering 1
|
|
** 5231 DD 's-Hertogenbosch
|
|
** The Netherlands
|
|
**
|
|
** All Rights Reserved
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Project name: Dual Inventive: Zelfsignalerende Kortsluit Lans
|
|
** Filename: aft.h
|
|
** Author: Jack Weeland
|
|
** Date: April 7, 2008
|
|
** File version: 1.00 of April 7, 2008
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Definitions and inline functions for the Automated Factory Test
|
|
**
|
|
************************************************************************
|
|
*/
|
|
|
|
#ifndef _AFT_H
|
|
#define _AFT_H
|
|
|
|
#include <zkl-common.h>
|
|
|
|
/*
|
|
** Definitions and constants
|
|
*/
|
|
|
|
// This include file is also used by the log reader; the structures are
|
|
// only defined for code running on the dsPIC (ZKL3000 and derivates)
|
|
#if defined(__MCUTYPE__) && MCUTYPE_ZKL_BASED(__MCUTYPE__)
|
|
|
|
// number of measurements (x2; one run with short-cut, one run without)
|
|
#define AFT_MEASUREMENT_COUNT 10
|
|
|
|
struct AFT_INFO
|
|
{
|
|
atomic_t flags; // flags, see defintions below
|
|
unsigned int options; // options, see definitions below
|
|
int gsm_timeout; // GSM time-out in seconds
|
|
int gps_timeout; // GPS time-out in seconds
|
|
int measurements; // measurement couter
|
|
unsigned int b_a[AFT_MEASUREMENT_COUNT * 2];
|
|
unsigned int rms[AFT_MEASUREMENT_COUNT * 2];
|
|
unsigned int battery[2];
|
|
volatile unsigned int t1_timer;
|
|
// parameter and measured data bounds
|
|
struct AFT_BOUNDS
|
|
{
|
|
signed char t_lm75[2]; // LM75 temperature min/max
|
|
unsigned char v_ntc[2]; // NTC min/max (ADC read-out, 8 MSbits)
|
|
unsigned char b_a; // b/a threshold, at 150 mOhm / 256
|
|
unsigned char b_a_noshort; // b/a threshold, no short circuit / 256
|
|
unsigned char pwm_per[2]; // PWM amplitude min/max / 2
|
|
unsigned char pwm_amp[2]; // PWM amplitude min/max
|
|
unsigned int rms; // expected rms
|
|
unsigned int battery; // battery level
|
|
} bounds;
|
|
};
|
|
|
|
#endif /* ZKL3000 and derivates */
|
|
|
|
// masks for the fields in "flags"
|
|
#define AFT_ANY_DONE 0xF000 // mask for the "test done" flags
|
|
#define AFT_ANY_ERROR 0x0FFF // mask for the "error" flags
|
|
|
|
// definitions for 'sys_info.test.flags'
|
|
#define AFT_ENABLED 0x8000 // ZKL is in test mode
|
|
#define AFT_MEASUREMENT_DONE 0x1000 // short circuit measurements completed
|
|
#define AFT_GSM_DONE 0x2000 // GSM is active
|
|
#define AFT_GPS_DONE 0x4000 // GPS is responding
|
|
#define AFT_ALL_DONE (AFT_ENABLED | AFT_MEASUREMENT_DONE | AFT_GSM_DONE | AFT_GPS_DONE)
|
|
|
|
// errors
|
|
#define AFT_READ_WRITE_FAIL 0x0001 // write/read test failed
|
|
#define AFT_RELAIS_FAIL 0x0002 // relais test failed
|
|
#define AFT_FLASH_FAIL 0x0004 // flash memory test
|
|
#define AFT_OSC_FAIL 0x0008 // external oscillator failed
|
|
#define AFT_LED_FAIL 0x0010 // LED or CN input failed
|
|
#define AFT_TEMP_FAIL 0x0020 // NTC/LM75 or CN5 failed
|
|
#define AFT_BATT_FAIL 0x0040 // 12V power failed
|
|
#define AFT_MEASUREMENT_FAIL 0x0080 // measurement or auto-calibration failed
|
|
#define AFT_GSM_FAIL 0x0100 // GSM modem didn't present itself in time
|
|
#define AFT_SMS_FAIL 0x0200 // SMS didn't come back (not used)
|
|
#define AFT_SIM_FAIL 0x0400 // SIM card failure
|
|
#define AFT_GPS_FAIL 0x0800 // GPS mouse didn't present itself in time
|
|
|
|
// options
|
|
#define OPTAFT_NO_UPDATE_SN 0x0001 // do not program nor increment the serial number
|
|
#define OPTAFT_NO_BATTERY_TEST 0x0010 // skip the battery test
|
|
#define OPTAFT_NO_NTC_TEST 0x0020 // skip the NTC/external contact test
|
|
#define OPTAFT_IGNORE_MEASUREMENT 0x0040 // do not compare the measurement results
|
|
#define OPTAFT_VERSION 0xF000 // mask
|
|
#define OPTAFT_VERSION1 0x0000 // AFT, version 1 (placeholder)
|
|
#define OPTAFT_VERSION2 0x1000 // AFT, version 2
|
|
|
|
// identifiers for logging test errors, parameter for LOG_AFT_RESULT
|
|
// integer parameter:
|
|
// - LOGAFT_PRODUCT_SN, LOGAFT_READ, LOGAFT_WRITE:
|
|
|
|
// uALFAT error code
|
|
// - LOGAFT_SWITCH_DEFAULT, LOGAFT_LED_SWITCH:
|
|
// switch or LED CN X, pin Y, set to L as 0xXY0L
|
|
// - LOGAFT_GSM_TIMEOUT, LOGAFT_GPS_TIMEOUT:
|
|
// time-out period in seconds
|
|
// - LOGAFT_T_NTCx
|
|
// ADC read-out
|
|
// - LOGAFT_T_ONBOARD
|
|
// temperature in degrees Celsius
|
|
// - LOGAFT_OSC_FAIL
|
|
// actual 32,768 kHz ticks
|
|
// - All others: actual measured value
|
|
#define LOGAFT_VERSION 0x00 // AFT version (MSB: major, LSB: minor)
|
|
#define LOGAFT_READ 0x01 // read test
|
|
#define LOGAFT_WRITE 0x02 // write test
|
|
#define LOGAFT_PRODUCT_SN 0x08 // automatic product serial number update
|
|
#define LOGAFT_CONFIGFILE 0x09 // configuration file error
|
|
#define LOGAFT_REPORTFILE 0x0A // report file error
|
|
#define LOGAFT_SWITCH_DEFAULT 0x10 // switch default value failure
|
|
#define LOGAFT_LED_SWITCH 0x11 // LED to switch connectivity failure
|
|
#define LOGAFT_OSC_FAIL 0x14 // 32,768 kHz oscillator failed
|
|
#define LOGAFT_FLASH_FAIL 0x15 // flash memory programming failure
|
|
#define LOGAFT_T_NTC0 0x18 // CN14 read-out (CN5=0) out of bounds
|
|
#define LOGAFT_T_NTC1 0x19 // CN14 read-out (CN5=1) out of bounds
|
|
#define LOGAFT_T_ONBOARD 0x1A // LM75 read-out out of bounds
|
|
#define LOGAFT_T_NTC_SKIPPED 0x1B // NTC test disabled in config
|
|
#define LOGAFT_GSM_TIMEOUT 0x20 // GSM timed out
|
|
#define LOGAFT_GPS_TIMEOUT 0x21 // GPS timed out
|
|
#define LOGAFT_GSM_INIT 0x28 // GSM could not be initialized
|
|
#define LOGAFT_AUTOCAL_FAIL 0x30 // auto-calibration failed
|
|
#define LOGAFT_TOO_LOW 0x31 // rms too low (b/a is logged)
|
|
#define LOGAFT_B_A_AUTOCAL 0x34 // auto-calibrated b/a out of bounds
|
|
#define LOGAFT_B_A_SAMPLE 0x35 // sample b/a out of bounds
|
|
#define LOGAFT_B_A_NOSHORT 0x36 // no short-cut: bad b/a (should be about 1.0)
|
|
#define LOGAFT_RMS 0x38 // sample rms out of bounds (short circuit)
|
|
#define LOGAFT_RMS_NOSHORT 0x39 // sample rms out too low (no short circuit)
|
|
#define LOGAFT_PWM_PER 0x3C // PWM period out of bounds
|
|
#define LOGAFT_PWM_AMP 0x3D // PWM amplitude out of bounds
|
|
#define LOGAFT_BATT_NORMAL 0x40 // battery test failed (12V expected)
|
|
#define LOGAFT_BATT_ABSENT 0x41 // battery test failed (0V expected)
|
|
#define LOGAFT_BATT_SKIPPED 0x42 // battery test disabled in config
|
|
|
|
/*
|
|
** AFT version 2 test identifiers
|
|
** The numbering of these items is also used for the array of names in "aft2.c"
|
|
**
|
|
** Also used by the ZKL3000 to report its test results via I2C-bus
|
|
*/
|
|
|
|
// AFT2 modes
|
|
#define AFT2MODE_PWROFF 0xFF // DUT is powered off
|
|
#define AFT2MODE_UNKNOWN 0x00
|
|
#define AFT2MODE_ZKL3000 0x01
|
|
#define AFT2MODE_ZKL3000_RC 0x02 // ZKL3000, modified for RC use
|
|
#define AFT2MODE_PM3000 0x03
|
|
#define AFT2MODE_SW3000 0x04
|
|
|
|
// Error: DUT timed out
|
|
#define AFT2_NO_DUT 0 // or it's a ZKL3000 with old firmware
|
|
// Voltages, tested by AFT2 board
|
|
#define AFT2_V3_3 1 // AFT2 3.3V system power supply
|
|
#define AFT2_V1_8 2 // Q2686, 1.8V supply
|
|
#define AFT2_V2_8 3 // Q2686, 2.8V supply
|
|
#define AFT2_V3_5 4 // PM3000, 3.5V supply
|
|
#define AFT2_V_INTERM 5 // PM3000 and ZKL3000, 5.7V supply V_intermediate
|
|
#define AFT2_V_BOOST 6 // PM3000, 9.0V boosted supply
|
|
#define AFT2_V_SWPWR1 7 // PM3000, 5.7V switched power supply #1
|
|
#define AFT2_V_SWPWR1_NC 8 // PM3000, 5.7V switched power supply #1
|
|
#define AFT2_V_SWPWR2 9 // PM3000, 5.7V switched power supply #2
|
|
#define AFT2_V_SWPWR2_NC 10 // PM3000, 5.7V switched power supply #2
|
|
// Voltages, tested by PM3000 (via MCP23008) or ZKL3000
|
|
#define AFT2_V_BATT1 11 // battery #1 (12.0V supply)
|
|
#define AFT2_V_BATT1_NC 12 // battery #1 (disconnected)
|
|
#define AFT2_V_BATT2 13 // battery #2 (12.0V supply)
|
|
#define AFT2_V_BATT2_NC 14 // battery #2 (disconnected)
|
|
#define AFT2_V_CHARGE 15 // PM3000, voltage when the charger is enabled
|
|
// PM3000 items, tested by AFT2 board using the on-board devices of the PM3000
|
|
#define AFT2_PM3000_MCP23008 16 // PM3000, MCP23008 present
|
|
#define AFT2_PM3000_MCP3434 17 // PM3000, MCP3434 present
|
|
#define AFT2_PM3000_PCM3000 90 // PM3000, PCM3000 present
|
|
#define AFT2_PM3000_CHARGER 18 // PM3000, charger
|
|
#define AFT2_PM3000_SELECT_BATT1 19 // PM3000, battery #1 selection
|
|
#define AFT2_PM3000_SELECT_BATT2 20 // PM3000, battery #2 selection
|
|
#define AFT2_PM3000_GPIO_OUTPUT 21 // PM3000, GPIO pins #1 and #2 as output pins
|
|
#define AFT2_PM3000_GPIO_INPUT 22 // PM3000, GPIO pins #1 and #2 as input pins
|
|
// Switch3000 items
|
|
#define AFT2_SW3000_ON 23 // Switch3000 turned on
|
|
#define AFT2_SW3000_OFF 24 // Switch3000 turned off
|
|
#define AFT2_SW3000_EMER_ON 25 // Switch3000 turned on by emergency switch
|
|
#define AFT2_SW3000_EMER_OFF 26 // Switch3000 turned off by emergency switch
|
|
#define AFT2_SW3000_BATT1 27 // Batteries for secion #1
|
|
#define AFT2_SW3000_BATT2 28 // Batteries for secion #2
|
|
#define AFT2_SW3000_BATT3 29 // Batteries for secion #3
|
|
#define AFT2_SW3000_BATT4 30 // Batteries for secion #4
|
|
#define AFT2_SW3000_BATTE 31 // Batteries for emergency switch
|
|
#define AFT2_SW3000_SEC1 32 // Section #1 details
|
|
#define AFT2_SW3000_SEC2 33 // Section #1 details
|
|
#define AFT2_SW3000_SEC3 34 // Section #1 details
|
|
#define AFT2_SW3000_SEC4 35 // Section #1 details
|
|
#define AFT2_SW3000_TEMP 36 // Switch3000 temperature
|
|
#define AFT2_SW3000_GET_STATUS 37 // Switch3000 "get status" command
|
|
// ZKL3000 items
|
|
#define AFT2_ZKL3000_B_A_SHORT 38 // b/a w/ short present
|
|
#define AFT2_ZKL3000_B_A_NOSHORT 39 // b/a w/ short removed
|
|
#define AFT2_ZKL3000_B_A_AUTOCAL 40 // b/a after auto-calibrations
|
|
#define AFT2_ZKL3000_B_A 41 // relais failed (no short present when expected)
|
|
#define AFT2_ZKL3000_AUTOCAL 42 // auto-calibration success or failure
|
|
#define AFT2_ZKL3000_RMS_SHORT 43 // RMS w/ short present
|
|
#define AFT2_ZKL3000_RMS_NOSHORT 44 // RMS w/ short removed
|
|
#define AFT2_ZKL3000_RMS 45 // RMS okay (success) or signal too low or too high
|
|
#define AFT2_ZKL3000_PWMPER 46 // PWM periode (* 33.921e-9 * 16 = 1/frequency)
|
|
#define AFT2_ZKL3000_PWMAMP 47 // PWM amplitude (/ 655.36 = %)
|
|
#define AFT2_ZKL3000_LED_SWITCH 48 // LEDs and switch buttons
|
|
#define AFT2_ZKL3000_LED_SWITCH0 49 // green -> lantern
|
|
#define AFT2_ZKL3000_LED_SWITCH1 50 // red -> power
|
|
#define AFT2_ZKL3000_LED_SWITCH2 51 // white -> relay_fb
|
|
#define AFT2_ZKL3000_LED_SWITCH3 52 // aux -> intensity
|
|
#define AFT2_ZKL3000_TEMP_LM75 53 // on-board temperature error
|
|
#define AFT2_ZKL3000_NTC0 54 // NTC error, extern contact = 0
|
|
#define AFT2_ZKL3000_NTC1 55 // NTC error, extern contact = 1
|
|
#define AFT2_ZKL3000_BATT1_FULL 56 // battery #1, present
|
|
#define AFT2_ZKL3000_BATT1_REMOVED 57 // battery #1, removed
|
|
#define AFT2_ZKL3000_BATT2_FULL 58 // battery #2, present
|
|
#define AFT2_ZKL3000_BATT2_REMOVED 59 // battery #2, removed
|
|
#define AFT2_ZKL3000_OSC_32kHz 60 // 32.768 kHz oscillator
|
|
#define AFT2_ZKL3000_SIM 61 // SIM card
|
|
#define AFT2_ZKL3000_GSM 62 // GSM modem (Wavecom Q2686) success or failure
|
|
#define AFT2_ZKL3000_GPS 63 // GPS receiver success or failure
|
|
#define AFT2_ZKL3000_RELAY 64 // on-board relay success or failure
|
|
#define AFT2_ZKL3000_uALFAT 65 // uALFAT success or failure
|
|
#define AFT2_ZKL3000_SDCARD 66 // SD-card (file system) success or failure
|
|
#define AFT2_ZKL3000_LOGFILE 67 // Log file success or failure
|
|
#define AFT2_ZKL3000_SDCARD_WRITE 68 // SD-card write test
|
|
#define AFT2_ZKL3000_SDCARD_READ 69 // SD-card read test
|
|
#define AFT2_ZKL3000_SDCARD_REPORTFILE 70 // report file successfully written or not
|
|
#define AFT2_ZKL3000_INFO_PRODNR 71 // production number; set by AFT2 controller if entered
|
|
#define AFT2_ZKL3000_INFO_SN 72 // serial number
|
|
#define AFT2_ZKL3000_INFO_IMEI 73 // IMEI of the modem
|
|
#define AFT2_ZKL3000_INFO_FW_MCU 74 // MCU firmware version
|
|
#define AFT2_ZKL3000_INFO_FW_WCPU 75 // WCPU firmware version
|
|
#define AFT2_ZKL3000_INFO_FW_Q2686 76 // Wavecom firmware version
|
|
#define AFT2_ZKL3000_INFO_HW_Q2686 77 // Wavecom hardware version
|
|
#define AFT2_ZKL3000_INFO_FW_uALFAT 78 // uALFAT firmware version
|
|
#define AFT2_ZKL3000_INFO_REPORTFILE 79 // Filename of the report
|
|
#define AFT2_ZKL3000_INFO_LOGFILE 80 // Logfile pertaining to the test
|
|
// AFT2 reporting and errors
|
|
#define AFT2_REPORT_VERSION 81 // special: print AFT version
|
|
#define AFT2_REPORT_POWERUP 82 // power-up (RCON) register
|
|
#define AFT2_REPORT_TEMP 83 // temperature (LM75 read-out on AFT2 board)
|
|
#define AFT2_REPORT_DATETIME /*!!*/ 87 // date and time of the AFT2 controller
|
|
// Additional GSM status reporting
|
|
#define AFT2_GSM_SQ 84 // signal quality
|
|
#define AFT2_GSM_BERR 85 // bit error rate
|
|
#define AFT2_GSM_REG 86 // network registration (cf. AT+CREG)
|
|
// Aditional reporting (AFT firmware version 3.1 and up)
|
|
#define AFT2_ZKL3000_MODEM_INIT 88 // initialization error
|
|
// Debugging
|
|
#define AFT2_DEBUG 89 // generic debug info
|
|
// AFT2 generic test sequence number (mask)
|
|
|
|
#define AFT2_SW3000_DVERSION 91
|
|
#define AFT2_SW3000_MVERSION 92
|
|
|
|
#define AFT2TEST_SEQNR_MASK 0x8000
|
|
#define AFT2TEST_SEQNR(t) (AFT2TEST_SEQNR_MASK | (t))
|
|
|
|
#endif /* _AFT_H */
|