update for reading Re/F0/Q/DeltaT during music playback
authorPeter Li <a0220410@ti.com>
Mon, 17 Apr 2017 16:51:02 +0000 (00:51 +0800)
committerPeter Li <a0220410@ti.com>
Mon, 17 Apr 2017 16:51:02 +0000 (00:51 +0800)
Android.mk
factorytest.c
lib/libftc32.a
lib/libftc64.a
readme.txt
speaker.ftcfg [deleted file]
tas2557_chk.c [new file with mode: 0755]
tas2557_ftc.c
tas2557_ftc.h
tas2557_ftc_lib.h
tas2557evm_aacspk_a.ftcfg [new file with mode: 0755]

index 7314c51a641c1e7fd93751a593ffae0cf6253f3d..7263fcae93581e7e45ebbc823b5cfa2ecc91312f 100755 (executable)
@@ -5,7 +5,8 @@ LOCAL_SRC_FILES += \
        factorytest.c \
        system.c \
        tas2557.c \
-       tas2557_ftc.c
+       tas2557_ftc.c \
+       tas2557_chk.c
 
 LOCAL_C_INCLUDES += ${LOCAL_PATH}/
 
index 3290e05d7be8ac56392d8556766c9ddb59e44bf4..80ecf68a738b6e0e023adbaea99fada964daa130 100755 (executable)
 
 // Obtained from PurePath Console 3 (PPC3)
 #define PPC3_RE0             7.41   // Re0 (ohm)
+#define PPC3_FWARP           891
+#define PPC3_BL              0.814
+#define PPC3_MMS             0.0666
 #define PPC3_RTV             46.5   // Rtv (K/W)
 #define PPC3_RTM             78.2   // Rtm (K/W)
 #define PPC3_RTVA            2460   // Rtva (K/W)
 #define PPC3_SYSGAIN         9.35   // System Gain (V/FS)
 #define PPC3_DEV_NONLIN_PER  1.5    // Device Non-linearity (%)
+#define PPC3_PIG                       1
 
 void ExitWithHint(char *pHint)
 {
@@ -57,7 +61,8 @@ void ExitWithHint(char *pHint)
 
 void InitFTCC(struct TFTCConfiguration *pFTCC)
 {
-       pFTCC->nCalibrationTime = 4000;
+       pFTCC->nCalibrationTime = 2000;
+       pFTCC->nPPC3_FS = 48000;
 
        pFTCC->bVerbose = false;
        pFTCC->bLoadCalibration = false;
@@ -68,11 +73,15 @@ void InitFTCC(struct TFTCConfiguration *pFTCC)
        pFTCC->nTSpkCharDevA.nReHi = PPC3_RE0*1.15;
        pFTCC->nTSpkCharDevA.nReLo = PPC3_RE0*0.85;
        pFTCC->nTSpkCharDevA.nPPC3_Re0 = PPC3_RE0;
+       pFTCC->nTSpkCharDevA.nPPC3_FWarp = PPC3_FWARP;
+       pFTCC->nTSpkCharDevA.nPPC3_Bl = PPC3_BL;
+       pFTCC->nTSpkCharDevA.nPPC3_Mms = PPC3_MMS;
        pFTCC->nTSpkCharDevA.nPPC3_RTV = PPC3_RTV;
        pFTCC->nTSpkCharDevA.nPPC3_RTM = PPC3_RTM;
        pFTCC->nTSpkCharDevA.nPPC3_RTVA = PPC3_RTVA;
        pFTCC->nTSpkCharDevA.nPPC3_SysGain = PPC3_SYSGAIN;
        pFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer = PPC3_DEV_NONLIN_PER;
+       pFTCC->nTSpkCharDevA.nPPC3_PIG = PPC3_PIG;
 }
 
 unsigned int SkipCharacter(char *pData, char cCharacter, unsigned int nSize)
@@ -104,15 +113,20 @@ unsigned int RemoveComments(char *pData, char cCharacter, unsigned int nSize)
 void ReadValue(struct TFTCConfiguration *pFTCC, struct TSPKCharData *pSpk, char *pLine, char *pValue)
 {
        if (!strcmp(pLine, "CALIBRATION_TIME")) {pFTCC->nCalibrationTime = atoi(pValue); return;};
+       if (!strcmp(pLine, "FS_RATE")) {pFTCC->nPPC3_FS = atof(pValue); return;};
        if (!strcmp(pLine, "SPK_T_MAX")) {pSpk->nSpkTMax = atof(pValue); return;};
        if (!strcmp(pLine, "SPK_RE_TOL_PER")) {pSpk->nSpkReTolPer = atof(pValue); return;};
-       if (!strcmp(pLine, "SPK_RE_ALPHA")) {pSpk->nSpkReAlpha = atof(pValue); return;};
+       if (!strcmp(pLine, "PPC3_RE_ALPHA")) {pSpk->nSpkReAlpha = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_RE0")) {pSpk->nPPC3_Re0 = atof(pValue); return;};
+       if (!strcmp(pLine, "PPC3_FWARP")) {pSpk->nPPC3_FWarp = atof(pValue); return;};
+       if (!strcmp(pLine, "PPC3_BL")) {pSpk->nPPC3_Bl = atof(pValue); return;};
+       if (!strcmp(pLine, "PPC3_MMS")) {pSpk->nPPC3_Mms = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_RTV")) {pSpk->nPPC3_RTV = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_RTM")) {pSpk->nPPC3_RTM = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_RTVA")) {pSpk->nPPC3_RTVA = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_SYSGAIN")) {pSpk->nPPC3_SysGain = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_DEV_NONLIN_PER")) {pSpk->nPPC3_DevNonlinPer = atof(pValue); return;};
+       if (!strcmp(pLine, "PPC3_PIG")) {pSpk->nPPC3_PIG = atof(pValue); return;};
        if (!strcmp(pLine, "RE_HI")) {pSpk->nReHi = atof(pValue); return;};
        if (!strcmp(pLine, "RE_LO")) {pSpk->nReLo = atof(pValue); return;};
 }
@@ -122,15 +136,22 @@ void ftcc_print(struct TFTCConfiguration *pFTCC)
        printf("factorytest configuration: \n\r");
 
        printf("  CALIBRATION_TIME   = %d\n\r", pFTCC->nCalibrationTime);
+       printf("Speaker A characterization data: \n\r");
+
        printf(" SPKA SPK_T_MAX      = %2.2f\n\r", pFTCC->nTSpkCharDevA.nSpkTMax);
        printf(" SPKA SPK_RE_TOL_PER = %2.2f\n\r", pFTCC->nTSpkCharDevA.nSpkReTolPer);
        printf(" SPKA SPK_RE_ALPHA   = %2.4f\n\r\n\r", pFTCC->nTSpkCharDevA.nSpkReAlpha);
+
        printf(" SPKA PPC3_RE0            = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_Re0);
+       printf(" SPKA PPC3_FWARP          = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_FWarp);
+       printf(" SPKA PPC3_BL             = %2.6f\n\r", pFTCC->nTSpkCharDevA.nPPC3_Bl);
+       printf(" SPKA PPC3_MMS            = %2.6f\n\r", pFTCC->nTSpkCharDevA.nPPC3_Mms);
        printf(" SPKA PPC3_RTV            = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_RTV);
        printf(" SPKA PPC3_RTM            = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_RTM);
        printf(" SPKA PPC3_RTVA           = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_RTVA);
        printf(" SPKA PPC3_SYSGAIN        = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_SysGain);
        printf(" SPKA PPC3_DEV_NONLIN_PER = %2.2f\n\r", pFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer);
+       printf(" SPKA PPC3_PIG            = %f\n\r", pFTCC->nTSpkCharDevA.nPPC3_PIG);
 }
 
 int ftcc_parse(struct TFTCConfiguration *pFTCC, struct TSPKCharData *pSpk, char *pData, unsigned int nSize)
@@ -196,6 +217,7 @@ int main(int argc, char *argv[])
        double nTemp = 20.0;
        int nArg = 1;
        bool bValidArg;
+       bool bSpkChk = false;
        char pHint[256];
        struct TFTCConfiguration sFTCC;
 
@@ -235,10 +257,16 @@ int main(int argc, char *argv[])
                        bValidArg = true;
                }
 
+               if (!strcmp(argv[nArg], "-m")) {
+                       bSpkChk = true;
+                       bValidArg = true;
+               }
+
                if (!bValidArg) {
                        sprintf(pHint, "don't know argument %s", argv[nArg]);
                        ExitWithHint(pHint);
                }
+
                nArg++;
        }
 
@@ -247,6 +275,9 @@ int main(int argc, char *argv[])
                ftcc_print(&sFTCC);
        }
 
-       tas2557_ftc(nTemp, &sFTCC);
+       if (bSpkChk)
+               tas2557_chk(nTemp, &sFTCC);
+       else
+               tas2557_ftc(nTemp, &sFTCC);
        return 0;
 }
index d4c74020122e880259858f05450ec713869af4cd..861aaae500e6d1161f5385426ce3e36910c6e4cb 100644 (file)
Binary files a/lib/libftc32.a and b/lib/libftc32.a differ
index db6f3617bcbf511a639b54f04e248b4bb4318b6e..e29a6f7ad2aadfba9a85bc9a168692aa95cd02e4 100644 (file)
Binary files a/lib/libftc64.a and b/lib/libftc64.a differ
index 91436237e148a3082c38d5e5cbf4fd885e3d9920..5af44cd5decd9566fc1d0b553dd7b75e1f51681a 100755 (executable)
@@ -1 +1,2 @@
-./factorytest -t 25 -c speaker.ftcfg -v
\ No newline at end of file
+./factorytest -t 25 -c tas2557evm_aacspk_a.ftcfg -v\r
+To do F0/Q/Re/Delta_tv readout : $./factorytest -t 25 -c tas2557evm_aacspk_a.ftcfg -v -m
\ No newline at end of file
diff --git a/speaker.ftcfg b/speaker.ftcfg
deleted file mode 100755 (executable)
index 52140ab..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-\r
-; TAS2557 Factory Test and Calibration Configuration File\r
-; -----------------------------------------------------------------------------\r
-; PPC3 File: example.ppc3\r
-; DDC Name: N48M1V2\r
-; Comments: [Write Comments Here]\r
-\r
-; FTC Settings\r
-CALIBRATION_TIME          = 6000     ; Duration (in ms) of calibration phase\r
-\r
-; Obtained from Speaker Manufacturer\r
-SPK_T_MAX                 = 80       ; Speaker Maximum Temperature (C)\r
-SPK_RE_TOL_PER            = 10       ; Re +/- tolerance (%)\r
-SPK_RE_ALPHA              = 0.0039   ; Temperature coefficient alpha (1/K)\r
-\r
-; Pass/Fail Limits\r
-RE_HI                     = 8.0\r
-RE_LO                     = 6.0\r
-\r
-; Obtained from PurePath Console 3 (PPC3)\r
-PPC3_RE0                  = 7.0     ; Re0 (ohm)\r
-PPC3_RTV                  = 44.9     ; Rtv (K/W)\r
-PPC3_RTM                  = 80.7     ; Rtm  (K/W)\r
-PPC3_RTVA                 = 1723     ; Rtva  (K/W)\r
-PPC3_SYSGAIN              = 9.35     ; System Gain (V/FS)\r
-PPC3_DEV_NONLIN_PER       = 1.5      ; Device Non-linearity (%)\r
-\r
diff --git a/tas2557_chk.c b/tas2557_chk.c
new file mode 100755 (executable)
index 0000000..060fd41
--- /dev/null
@@ -0,0 +1,77 @@
+/*\r
+** =============================================================================\r
+** Copyright (c) 2016  Texas Instruments Inc.\r
+**\r
+** This program is free software; you can redistribute it and/or modify it under\r
+** the terms of the GNU General Public License as published by the Free Software \r
+** Foundation; version 2.\r
+**\r
+** This program is distributed in the hope that it will be useful, but WITHOUT\r
+** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+**\r
+** You should have received a copy of the GNU General Public License along with\r
+** this program; if not, write to the Free Software Foundation, Inc., 51 Franklin\r
+** Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+**\r
+** File:\r
+**     tas2557_ftc.c\r
+**\r
+** Description:\r
+**     factory test program for TAS2557 Android devices\r
+**\r
+** =============================================================================\r
+*/\r
+\r
+#include <stdio.h>\r
+#include <stdint.h>\r
+#include <math.h>\r
+#include <sys/types.h>\r
+\r
+#include "system.h"\r
+#include "tas2557.h"        // TAS2557 Driver\r
+#include "tas2557_ftc_lib.h"    \r
+#include "tas2557_ftc.h"    // TAS2557 Factory Test and Calibration Tool\r
+\r
+#define PI                   3.14159\r
+\r
+// -----------------------------------------------------------------------------\r
+// tas2557_ftc\r
+// -----------------------------------------------------------------------------\r
+// Description:\r
+//      Obtains Re, f0, Q and T_cal from the speaker. This only needs to be\r
+//      executed once during production line test.\r
+// -----------------------------------------------------------------------------\r
+int tas2557_chk(double t_cal, struct TFTCConfiguration *pFTCC)\r
+{\r
+       int nResult = 0;\r
+       double nDevARe, nDevADeltaT, nDevAF0, nDevAQ;\r
+       double nDevBRe, nDevBDeltaT, nDevBF0, nDevBQ;\r
+       uint8_t nPGID;\r
+       uint32_t libVersion;\r
+\r
+       libVersion = get_lib_ver();\r
+       printf("libVersion=0x%x\r\n", libVersion);\r
+\r
+       /* get device PGID */\r
+       nPGID = tas2557_get_PGID();\r
+       printf("PGID=0x%x\r\n", nPGID);\r
+       /* set device PGID to FTC process */\r
+       tas2557_ftc_set_PGID(nPGID);\r
+\r
+       /* Get actual Re from TAS2557 */\r
+       nResult = get_Re_deltaT(pFTCC->nTSpkCharDevA.nPPC3_Re0,\r
+                                                       pFTCC->nTSpkCharDevA.nSpkReAlpha,\r
+                                                       &nDevARe, &nDevADeltaT);\r
+       nResult = get_f0_Q(pFTCC->nTSpkCharDevA.nPPC3_FWarp,\r
+                                               pFTCC->nPPC3_FS,\r
+                                               pFTCC->nTSpkCharDevA.nPPC3_Bl,\r
+                                               pFTCC->nTSpkCharDevA.nPPC3_Mms,\r
+                                               pFTCC->nTSpkCharDevA.nPPC3_Re0,\r
+                                               &nDevAF0, &nDevAQ);\r
+       printf("SPK Re = %f, DeltaT=%f, F0 = %f, Q = %f\n", nDevARe, nDevADeltaT, nDevAF0, nDevAQ);\r
+\r
+       tas2557_ftc_release();\r
+\r
+    return nResult;\r
+}\r
index 9c31224bc6daa36f26277af128c6debc15c128b6..c66431eb21e300171e1a8a9e2b6a800adf0253d4 100755 (executable)
@@ -96,7 +96,8 @@ uint32_t tas2557_ftc(double t_cal, struct TFTCConfiguration *pFTCC)
                        gpFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer, \r
                        gpFTCC->nTSpkCharDevA.nPPC3_RTV, \r
                        gpFTCC->nTSpkCharDevA.nPPC3_RTM, \r
-                       gpFTCC->nTSpkCharDevA.nPPC3_RTVA);\r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTVA,\r
+                       gpFTCC->nTSpkCharDevA.nPPC3_PIG);\r
                set_re(gpFTCC->nTSpkCharDevA.nPPC3_Re0, dev_a_re, gpFTCC->nTSpkCharDevA.nSpkReAlpha);\r
                set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
        }\r
index 269d7a360536f174b2f39651ba489be2f582bafd..3318e0e72841bb77ef8136fe3cfcd9082f51499a 100755 (executable)
@@ -35,11 +35,15 @@ struct TSPKCharData {
        double nSpkReAlpha;\r
 \r
        double nPPC3_Re0;\r
+       double nPPC3_FWarp;\r
+       double nPPC3_Bl;\r
+       double nPPC3_Mms;\r
        double nPPC3_RTV;\r
        double nPPC3_RTM;\r
        double nPPC3_RTVA;\r
        double nPPC3_SysGain;\r
        double nPPC3_DevNonlinPer;\r
+       double nPPC3_PIG;\r
 \r
        double nReHi;\r
        double nReLo;\r
@@ -49,10 +53,11 @@ struct TFTCConfiguration {
        bool bVerbose;\r
        bool bLoadCalibration;\r
        unsigned int nCalibrationTime;\r
+       double nPPC3_FS;\r
 \r
        struct TSPKCharData nTSpkCharDevA;\r
 };\r
 \r
 uint32_t tas2557_ftc(double t_cal, struct TFTCConfiguration *pFTCC);\r
-\r
+int tas2557_chk(double t_cal, struct TFTCConfiguration *pFTCC);\r
 #endif /* TAS2557_FTC_H_ */\r
index a7f96f7a2ae73851cb7d0bade78081e2a0bf94fc..d7610282b1a5f63beaff40954a9ecccc75d50601 100755 (executable)
@@ -37,7 +37,13 @@ void tas2557_ftc_start(void);
 void set_re(double re_ppc3, double re, double alpha);\r
 void set_temp_cal(uint32_t prm_pow, uint32_t prm_tlimit);\r
 double get_re(double re_ppc3);\r
+double CalcRe(double re_ppc3, uint32_t prm_r0);\r
 uint32_t calc_prm_pow(double re, double delta_t_max, double nRTV, double nRTM, double nRTVA, double nSysGain);\r
-uint32_t calc_prm_tlimit(double delta_t_max, double alpha, double nDevNonlinPer, double nRTV, double nRTM, double nRTVA);\r
+uint32_t calc_prm_tlimit(double delta_t_max, double alpha, double nDevNonlinPer, double nRTV, double nRTM, double nRTVA, double nPIG);\r
 void tas2557_ftc_stop(void);\r
+\r
+/* below functions are used in SPK measurement only */\r
+int get_Re_deltaT(double nPPC3_Re, double nPPC3_alpha, double *pnRe, double *pnDeltaT);\r
+int get_f0_Q(double nPPC3_FWarp, double nPPC3_nFS, double nPPC3_Bl, double nPPC3_Mms, double nPPC3_Re0, double *pnF0, double *pnQ);\r
+\r
 #endif /* TAS2557_LIB_FTC_H_ */\r
diff --git a/tas2557evm_aacspk_a.ftcfg b/tas2557evm_aacspk_a.ftcfg
new file mode 100755 (executable)
index 0000000..f160647
--- /dev/null
@@ -0,0 +1,45 @@
+\r
+; TAS2557 Factory Test and Calibration Configuration File\r
+; -----------------------------------------------------------------------------\r
+; PPC3 File: AAC_v2_vC3_48000_HP_TAS2557_pg2p1_dm.ppc3\r
+; DDC Name: TAS2557MSS_20170411\r
+; Comments: [Write Comments Here]\r
+\r
+; FTC Settings\r
+FTC_BYPASS                = 0       ; Refer to documentation\r
+TEST_DELTA_T              = 80      ; Delta Temperature Limit during verification phase\r
+CALIBRATION_TIME          = 2000    ; Duration (in ms) of calibration phase\r
+VERIFICATION_TIME         = 4000    ; Duration (in ms) of the verification phase\r
+CONFIGURATION             = 0       ; Refer to documentation\r
+CONFIGURATION_CALIBRATION = 1       ; Refer to documentation\r
+DEV_ADDR                  = 98      ; I2C slave write addr (in hex) for device A\r
+\r
+; Pass/Fail Limits\r
+RE_HI                     = 7.975\r
+RE_LO                     = 6.525\r
+F0_HI                     = 924\r
+F0_LO                     = 616\r
+Q_HI                      = 1.704\r
+Q_LO                      = 1.136\r
+T_HI                      = 40\r
+T_LO                      = 0\r
+\r
+; Obtained from Speaker Manufacturer\r
+SPK_T_MAX                 = 100     ; Speaker Maximum Temperature (C)\r
+SPK_RE_TOL_PER            = 10      ; Re +/- tolerance (%)\r
+\r
+; Obtained from PurePath Console 3 (PPC3)\r
+PPC3_RE0                  = 6.7     ; Re0 (ohm)\r
+PPC3_FWARP                = 891     ; CMWF (Hz)\r
+PPC3_BL                   = 0.814   ; Bl (Tm)\r
+PPC3_MMS                  = 0.0666  ; Mms (g)\r
+PPC3_RTV                  = 63.4    ; Rtv (K/W)\r
+PPC3_RTM                  = 566.7   ; Rtm  (K/W)\r
+PPC3_RTVA                 = 136     ; Rtva  (K/W)\r
+PPC3_SYSGAIN              = 9.35    ; System Gain (V/FS)\r
+PPC3_DEV_NONLIN_PER       = 1.5     ; Device Non-linearity (%)\r
+PPC3_DELTA_T_LIMIT        = 80      ; Delta Thermal Limit (C)\r
+PPC3_PIG                  = 1       ; Refer to documentation\r
+PPC3_RE_ALPHA             = 0.0033  ; Temperature coefficient alpha (1/K)\r
+FS_RATE                   = 48000   ; TAS2557 Sample Rate\r
+\r