update for syntax checks
authorPeter Li <peter-li@ti.com>
Wed, 8 Mar 2017 17:33:18 +0000 (01:33 +0800)
committerPeter Li <peter-li@ti.com>
Wed, 8 Mar 2017 17:33:18 +0000 (01:33 +0800)
factorytest.c
readme.txt [new file with mode: 0755]
tas2557.c
tas2557.h
tas2557_ftc.h
tas2557_ftc_lib.h
tas2557dm_ftc.c

index 2c11645a0551ec972b713e308e61334013c610c2..1723bf10162ff1ecd88c10e0c3585a04e66c8959 100755 (executable)
@@ -58,7 +58,7 @@ void ExitWithHint(char *pHint)
        exit(-1);
 }
 
-void InitFTCC(TFTCConfiguration *pFTCC)
+void InitFTCC(struct TFTCConfiguration *pFTCC)
 {
        pFTCC->nCalibrationTime = 4000;
 
@@ -118,7 +118,7 @@ unsigned int RemoveComments(char *pData, char cCharacter, unsigned int nSize)
        return nWIndex;
 }
 
-void ReadValue(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pLine, char *pValue)
+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, "SPK_T_MAX")) {pSpk->nSpkTMax = atof(pValue); return;};
@@ -139,7 +139,7 @@ void ReadValue(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pLine, char *
        };
 }
 
-void ftcc_print(TFTCConfiguration *pFTCC)
+void ftcc_print(struct TFTCConfiguration *pFTCC)
 {
        printf("factorytest configuration: \n\r");
 
@@ -174,7 +174,7 @@ void ftcc_print(TFTCConfiguration *pFTCC)
 
 }
 
-int ftcc_parse(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pData, unsigned int nSize)
+int ftcc_parse(struct TFTCConfiguration *pFTCC, struct TSPKCharData *pSpk, char *pData, unsigned int nSize)
 {
        unsigned int nRIndex = 0;
        char *pLine;
@@ -208,7 +208,7 @@ int ftcc_parse(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pData, unsign
        return 0;
 }
 
-void LoadFTCC(char *pFileName, TFTCConfiguration *pFTCC, TSPKCharData *pSpk)
+void LoadFTCC(char *pFileName, struct TFTCConfiguration *pFTCC, struct TSPKCharData *pSpk)
 {
        struct stat st;
        char *pData;
@@ -238,7 +238,7 @@ int main(int argc, char *argv[])
        int nArg = 1;
        bool bValidArg;
        char pHint[256];
-       TFTCConfiguration sFTCC;
+       struct TFTCConfiguration sFTCC;
 
        printf("\nTI TAS2557 factory test calibration sequence V1.0\n");
 
@@ -248,26 +248,25 @@ int main(int argc, char *argv[])
        {
 //             printf("argv[%d] = %s: ", nArg, argv[nArg]);
                bValidArg = false;
-               if (!strcmp(argv[nArg], "-t"))
-               {
+               if (!strcmp(argv[nArg], "-t")) {
                        printf("nArg = %d, argc = %d\n\r", nArg, argc);
-                       if (argc <= (nArg + 1)) ExitWithHint("temperature parameter is missing");
+                       if (argc <= (nArg + 1))
+                               ExitWithHint("temperature parameter is missing");
                        nTemp = atof(argv[nArg + 1]);
                        nArg++;
                        bValidArg = true;
                }
 
-               if (!strcmp(argv[nArg], "-l"))
-               {
+               if (!strcmp(argv[nArg], "-l")) {
 //                     printf("found configuration file argument\n\r");
-                       if (argc <= (nArg + 1)) ExitWithHint("configuration file name is missing");
+                       if (argc <= (nArg + 1))
+                               ExitWithHint("configuration file name is missing");
                        LoadFTCC(argv[nArg + 1], &sFTCC, &(sFTCC.nTSpkCharDevA));
                        nArg++;
                        bValidArg = true;
                }
                
-               if (!strcmp(argv[nArg], "-r"))
-               {
+               if (!strcmp(argv[nArg], "-r")) {
 //                     printf("found configuration file argument\n\r");
                        if (argc <= (nArg + 1)) ExitWithHint("configuration file name is missing");
                        LoadFTCC(argv[nArg + 1], &sFTCC, &(sFTCC.nTSpkCharDevB));
@@ -275,31 +274,28 @@ int main(int argc, char *argv[])
                        bValidArg = true;
                }
 
-               if (!strcmp(argv[nArg], "-v"))
-               {
+               if (!strcmp(argv[nArg], "-v")) {
                        sFTCC.bVerbose = true;
                        bValidArg = true;
                }
 
-               if (!strcmp(argv[nArg], "-u"))
-               {
+               if (!strcmp(argv[nArg], "-u")) {
                        sFTCC.bLoadCalibration = true;
                        bValidArg = true;
                }
 
-               if (!bValidArg)
-               {
+               if (!bValidArg) {
                        sprintf(pHint, "don't know argument %s", argv[nArg]);
                        ExitWithHint(pHint);
                }
                nArg++;
        }
 
-       if (sFTCC.bVerbose) 
-       {
+       if (sFTCC.bVerbose) {
                printf("\n\rambient temperature = %2.1f\n\r", nTemp);
                ftcc_print(&sFTCC);
        }
+
        tas2557_ftc(nTemp, &sFTCC);
        return 0;
 }
diff --git a/readme.txt b/readme.txt
new file mode 100755 (executable)
index 0000000..77d3cdb
--- /dev/null
@@ -0,0 +1 @@
+./factorytest -t 25 -l speaker_l.ftcfg -r speaker_r.ftcfg -v
\ No newline at end of file
index 1e674083efca086db07cf7e288bda8318fe6ff49..1779380caa08eecfb2c7eb99905e6358ae89e860 100755 (executable)
--- a/tas2557.c
+++ b/tas2557.c
@@ -62,7 +62,7 @@ void tas2557_mixer_command(char *pCommand, int nData)
 
        char pData[16];
 
-       printf("TAS2555 mixer command %s = %d.\n\r", pCommand, nData);
+       printf("TAS2557 mixer command %s = %d.\n\r", pCommand, nData);
 
        sprintf(pData, "%d", nData);
        pMixer[2] = pData;
@@ -79,14 +79,6 @@ void tas2557_mixer_command(char *pCommand, int nData)
        sys_delay(500);
 }
 
-void tas2557_load_configuration(int nConfiguration)
-{
-       tas2557_check_node();
-       
-       ioctl(gTILoad, TILOAD_IOCTL_SET_CONFIG, &nConfiguration);
-       sys_delay(500);
-}
-
 void tas2557_load_calibration(int nCalibration)
 {
        tas2557_check_node();
@@ -241,7 +233,7 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
        }
 }
 
-void tas2557_save_cal(TFTCConfiguration *pFTCC, 
+void tas2557_save_cal(struct TFTCConfiguration *pFTCC, 
        double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, 
        double dev_b_re, uint32_t dev_b_rms_pow, uint32_t dev_b_t_limit, 
        double t_cal,  uint32_t nResult, char * pFileName)
@@ -254,9 +246,9 @@ void tas2557_save_cal(TFTCConfiguration *pFTCC,
        printf("    DevB rms_pow       = 0x%08X\n\r", dev_b_rms_pow);
        printf("    DevB t_limit       = 0x%08X\n\r", dev_b_t_limit);
 
-       if((nResult & RE1_CHK_MSK) == RESULT_PASS){
+       if((nResult & RE1_CHK_MSK) == RESULT_PASS)
                printf(" SPK A calibration success! \n\r");
-       }else {
+       else {
                if(nResult & RE1_FAIL_HI)
                        printf(" SPK A Calibration fail : Re is too high (limit: %1.2f).\n\r", pFTCC->nTSpkCharDevA.nReHi);
                else
@@ -305,73 +297,73 @@ void tas2557_open_bin(char * pFileName, unsigned char dev_a, unsigned char dev_b
        gnDevABlockIndex = 0;
        memset(gpDevBBlock, 0, MAX_BIN_SIZE/2);
        gnDevBBlockIndex = 0;
-       
+
        //magic number
-       gpBin[gnBinIndex++] = '5';      
+       gpBin[gnBinIndex++] = '5';
        gpBin[gnBinIndex++] = '5';
        gpBin[gnBinIndex++] = '5';
        gpBin[gnBinIndex++] = '2';
-       
-       gnBinIndex += 4;        //bypass size int
-       gnBinIndex += 4;        //bypass checksum int
-       gnBinIndex += 4;        //bypass PPC3 version int
-       gnBinIndex += 4;        //bypass DSP version int
-       
+
+       gnBinIndex += 4;        /* bypass size int */
+       gnBinIndex += 4;        /* bypass checksum int */
+       gnBinIndex += 4;        /* bypass PPC3 version int */
+       gnBinIndex += 4;        /* bypass DSP version int */
+
        gpBin[gnBinIndex++] = 0;
        gpBin[gnBinIndex++] = 0;
-       gpBin[gnBinIndex++] = 1;        
-       gpBin[gnBinIndex++] = 0;        //driver version 0x00000100
-       
+       gpBin[gnBinIndex++] = 1;
+       gpBin[gnBinIndex++] = 0; /* driver version 0x00000100 */
+
        time(&timestamp);
        gpBin[gnBinIndex++] = (unsigned char)((timestamp&0xff000000)>>24);
        gpBin[gnBinIndex++] = (unsigned char)((timestamp&0x00ff0000)>>16);;
-       gpBin[gnBinIndex++] = (unsigned char)((timestamp&0x0000ff00)>>8);;      
+       gpBin[gnBinIndex++] = (unsigned char)((timestamp&0x0000ff00)>>8);;
        gpBin[gnBinIndex++] = (unsigned char)((timestamp&0x000000ff));;
-       
-       strcpy(&gpBin[gnBinIndex], "Calibration Data File");    //DDC name
+
+       strcpy(&gpBin[gnBinIndex], "Calibration Data File");    /* DDC name */
        gnBinIndex += 64;
-               
+
        strcpy(&gpBin[gnBinIndex], DDC_DESCRIPTION);
        gnBinIndex += strlen(DDC_DESCRIPTION) + 1;
 
-       gnBinIndex += 4; //device family index
-       
-       gpBin[gnBinIndex++] = 0; //device index
-       gpBin[gnBinIndex++] = 0; //device index
-       gpBin[gnBinIndex++] = 0; //device index
+       gnBinIndex += 4; /* device family index */
+
+       gpBin[gnBinIndex++] = 0; /* device index */
+       gpBin[gnBinIndex++] = 0; /* device index */
+       gpBin[gnBinIndex++] = 0; /* device index */
        gpBin[gnBinIndex++] = 3; //device index, TAS2557 Dual Mono
-               
+
        gnBinIndex +=
-               2 +     //num PLL index
-               0 +     //array PLL index
-               2 +     //num programs index
-               0 +     //array programs index
-               2 +     //num configurations index
-               0;      //array configurations index
-       
+               2 +     /* num PLL index */
+               0 +     /* array PLL index */
+               2 +     /* num programs index */
+               0 +     /* array programs index */
+               2 +     /* num configurations index */
+               0;      /* array configurations index */
+
        gpBin[gnBinIndex++] = 0x00;
-       gpBin[gnBinIndex++] = 0x01; // one calibration data block
+       gpBin[gnBinIndex++] = 0x01; /* one calibration data block */
 
        strcpy(&gpBin[gnBinIndex], "Calibration snapshot");
        gnBinIndex += 64;
        strcpy(&gpBin[gnBinIndex], CALIBRATION_DESCRIPTION);
        gnBinIndex += strlen(CALIBRATION_DESCRIPTION) + 1;
-       
-       gpBin[gnBinIndex++] = 0x00; // compatible program = smart amp (index 0)
-       gpBin[gnBinIndex++] = 0x00; // compatible configuration
-       
+
+       gpBin[gnBinIndex++] = 0x00; /* compatible program = smart amp (index 0) */
+       gpBin[gnBinIndex++] = 0x00; /* compatible configuration */
+
        strcpy(&gpBin[gnBinIndex], "Calibration Data");
        gnBinIndex += 64;
        strcpy(&gpBin[gnBinIndex], DATA_DESCRIPTION);
        gnBinIndex += strlen(DATA_DESCRIPTION) + 1;
-       
-       gpBin[gnBinIndex++] = 0x00; // 
+
+       gpBin[gnBinIndex++] = 0x00; 
        gpBin[gnBinIndex++] = 2;        // two blocks
-       
+
        gpDevABlock[0] = 0;
        gpDevABlock[1] = 0;
        gpDevABlock[2] = 0;
-       gpDevABlock[3] = 0x03;  //o     COEFF_DEVICE_A – 0x03
+       gpDevABlock[3] = 0x03;  /* COEFF_DEVICE_A – 0x03 */
        gnDevABlockIndex = 2;
        
        gpDevBBlock[0] = 0;
@@ -384,8 +376,7 @@ void tas2557_open_bin(char * pFileName, unsigned char dev_a, unsigned char dev_b
 void tas2557_close_bin(void)
 {
        unsigned int nCommands;
-       unsigned char pCommit[] =
-       {
+       unsigned char pCommit[] = {
                0x00, 0x04, 0x85, 0x00,
                0x8C, 0x19, 0x7C, 0x00,
                0x00, 0x00, 0x01, 0x00,
@@ -393,15 +384,15 @@ void tas2557_close_bin(void)
                0x00, 0x35, 0x2c, 0x00,
                0x00, 0x00, 0x01, 0x00
        };
-       
-       // write the commit sequence
+
+       /* write the commit sequence */
        memcpy(&gpDevABlock[gnDevABlockIndex*4], pCommit, 24);
        gnDevABlockIndex += 6;
        
        memcpy(&gpDevBBlock[gnDevBBlockIndex*4], pCommit, 24);
        gnDevBBlockIndex += 6;
        
-       // write number of commands for calibration block
+       /* write number of commands for calibration block */
        gpDevABlock[4] = ((gnDevABlockIndex-2) & 0xFF000000) >> 24;
        gpDevABlock[5] = ((gnDevABlockIndex-2) & 0x00FF0000) >> 16;
        gpDevABlock[6] = ((gnDevABlockIndex-2) & 0x0000FF00) >> 8;
@@ -418,7 +409,7 @@ void tas2557_close_bin(void)
        memcpy(&gpBin[gnBinIndex], gpDevBBlock, gnDevBBlockIndex*4);
        gnBinIndex += (gnDevBBlockIndex*4);
        
-       // write bin file size
+       /* write bin file size */
        gpBin[4] = (gnBinIndex & 0xFF000000) >> 24;
        gpBin[5] = (gnBinIndex & 0x00FF0000) >> 16;
        gpBin[6] = (gnBinIndex & 0x0000FF00) >> 8;
@@ -436,21 +427,21 @@ void tas2557_close_bin(void)
 // Description: 
 //      Checks if speaker paramters are within bounds. 
 // ----------------------------------------------------------------------------- 
-uint32_t check_spk_bounds(TFTCConfiguration *pFTCC, double re1, double re2) 
+uint32_t check_spk_bounds(struct TFTCConfiguration *pFTCC, double re1, double re2) 
 { 
-    uint32_t result = RESULT_PASS; 
-    if(re1>pFTCC->nTSpkCharDevA.nReHi) 
-        result |= RE1_FAIL_HI; 
-    if(re1<pFTCC->nTSpkCharDevA.nReLo) 
-        result |= RE1_FAIL_LO; 
+       uint32_t result = RESULT_PASS; 
+
+       if(re1>pFTCC->nTSpkCharDevA.nReHi) 
+               result |= RE1_FAIL_HI; 
+       if(re1<pFTCC->nTSpkCharDevA.nReLo) 
+               result |= RE1_FAIL_LO; 
    
     if(re2>pFTCC->nTSpkCharDevB.nReHi) 
         result |= RE2_FAIL_HI; 
     if(re2<pFTCC->nTSpkCharDevB.nReLo) 
         result |= RE2_FAIL_LO; 
-       
-    return result; 
+
+       return result; 
 } 
 
 void tas2557_ftc_release(void)
index 804f0a5959853bb48375c0051871ca0854ceede7..01d8b793779770ae1b760a8e4d786c49536ba58f 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
 \r
 #define TILOAD_IOC_MAGIC   0xE0\r
 \r
-#define TILOAD_IOCTL_SET_CHL                   _IOW(TILOAD_IOC_MAGIC, 5, int)\r
-#define TILOAD_IOCTL_SET_CONFIG                _IOW(TILOAD_IOC_MAGIC, 6, int)\r
-#define TILOAD_IOCTL_SET_CALIBRATION   _IOW(TILOAD_IOC_MAGIC, 7, int)\r
+#define TILOAD_IOCTL_SET_CHL                   _IOW(TILOAD_IOC_MAGIC, 5, int)\r
+#define TILOAD_IOCTL_SET_CONFIG                        _IOW(TILOAD_IOC_MAGIC, 6, int)\r
+#define TILOAD_IOCTL_SET_CALIBRATION   _IOW(TILOAD_IOC_MAGIC, 7, int)\r
 \r
 #define RESULT_PASS                    0x00000000 \r
-#define RE1_FAIL_HI         0x00000001 \r
-#define RE1_FAIL_LO         0x00000010 \r
-#define RE1_CHK_MSK         0x00000011 \r
+#define RE1_FAIL_HI                    0x00000001 \r
+#define RE1_FAIL_LO                    0x00000010 \r
+#define RE1_CHK_MSK                    0x00000011 \r
 #define RE2_FAIL_HI         0x00000100 \r
 #define RE2_FAIL_LO         0x00001000 \r
 #define RE2_CHK_MSK         0x00001100\r
@@ -48,11 +48,11 @@ void tas2557_mixer_command(char *pCommand, int nData);
 uint32_t tas2557_switch_device(uint8_t i2cslave);\r
 uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg);\r
 void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data);\r
-void tas2557_save_cal(TFTCConfiguration *pFTCC, \r
+void tas2557_save_cal(struct TFTCConfiguration *pFTCC,\r
        double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, \r
        double dev_b_re, uint32_t dev_b_rms_pow, uint32_t dev_b_t_limit, \r
        double t_cal, uint32_t,char * pFileName);\r
-uint32_t check_spk_bounds(TFTCConfiguration *pFTCC, double re1, double re2);\r
+uint32_t check_spk_bounds(struct TFTCConfiguration *pFTCC, double re1, double re2);\r
 void tas2557_load_calibration(int nCalibration);\r
 void tas2557_open_bin(char * pFileName, unsigned char dev_a, unsigned char dev_b);\r
 void tas2557_close_bin(void);\r
index 5807e21b9e0745e54a0110d2c0e0817b1fa79408..9a23e9969f922f319a2bbd234abbb811262a37fe 100755 (executable)
 #include <stdint.h>\r
 #include <stdbool.h>\r
 \r
-typedef struct\r
-{\r
+struct TSPKCharData {\r
        double nSpkTMax;\r
        double nSpkReTolPer;\r
        double nSpkReAlpha;\r
-       \r
+\r
        double nPPC3_Re0;\r
        double nPPC3_RTV;\r
        double nPPC3_RTM;\r
@@ -46,19 +45,17 @@ typedef struct
        double nReLo;\r
        \r
        unsigned char nDevAddr;\r
-} TSPKCharData;\r
-\r
+};\r
 \r
-typedef struct\r
-{\r
+struct TFTCConfiguration {\r
        bool bVerbose;\r
        bool bLoadCalibration;\r
        unsigned int nCalibrationTime;\r
 \r
-       TSPKCharData nTSpkCharDevA;\r
-       TSPKCharData nTSpkCharDevB;\r
-} TFTCConfiguration;\r
+       struct TSPKCharData nTSpkCharDevA;\r
+       struct TSPKCharData nTSpkCharDevB;\r
+};\r
 \r
-uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC);\r
+uint32_t tas2557_ftc(double t_cal, struct TFTCConfiguration *pFTCC);\r
 \r
 #endif /* TAS2557_FTC_H_ */\r
index bd0d83c02537d1ac3a684d043a6d9a700cb2c005..de688e6e0675827cf834ecc12a4436bf02f069b0 100755 (executable)
@@ -29,6 +29,8 @@
 #include <stdint.h>\r
 #include <stdbool.h>\r
 \r
+#include "tas2557.h"\r
+\r
 int get_lib_ver(void);\r
 void tas2557_ftc_set_PGID(unsigned char nPGID);\r
 void tas2557_ftc_start(void);\r
index 10298da166acaf094e907873381aa94dbe124d52..0cd88f831fdf0b481d60dd2bbf61e354bae2cdab 100755 (executable)
@@ -35,7 +35,7 @@
 \r
 #define PI                   3.14159\r
 \r
-TFTCConfiguration *gpFTCC;\r
+static struct TFTCConfiguration *gpFTCC;\r
 \r
 // -----------------------------------------------------------------------------\r
 // tas2557_ftc\r
@@ -44,7 +44,7 @@ TFTCConfiguration *gpFTCC;
 //      Obtains Re, f0, Q and T_cal from the speaker. This only needs to be\r
 //      executed once during production line test.\r
 // -----------------------------------------------------------------------------\r
-uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC)\r
+uint32_t tas2557_ftc(double t_cal, struct TFTCConfiguration *pFTCC)\r
 {\r
        int nResult = 0;\r
     double dev_a_re = pFTCC->nTSpkCharDevA.nPPC3_Re0;   // Default Re\r