update configuration file parser and calibration firmware creation
authorPeter Li <peter-li@ti.com>
Thu, 12 Jan 2017 16:31:57 +0000 (00:31 +0800)
committerPeter Li <peter-li@ti.com>
Thu, 12 Jan 2017 16:31:57 +0000 (00:31 +0800)
factorytest.c
speaker_l.ftcfg
speaker_r.ftcfg
tas2557.c
tas2557.h
tas2557dm_ftc.c

index 350c0ee06964ac38c4a0dbccd9f628edadea018f..d4c984b11c2f1fc55d9d3a28a7f3d3e15f527aa2 100755 (executable)
@@ -136,7 +136,11 @@ void ReadValue(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pLine, char *
        if (!strcmp(pLine, "PPC3_DEV_NONLIN_PER")) {pSpk->nPPC3_DevNonlinPer = atof(pValue); return;};
        if (!strcmp(pLine, "RE_HI")) {pSpk->nReHi = atof(pValue); return;};
        if (!strcmp(pLine, "RE_LO")) {pSpk->nReLo = atof(pValue); return;};
-       if (!strcmp(pLine, "DEV_ADDR")) {pSpk->nDevAddr = atoi(pValue); return;};
+       if (!strcmp(pLine, "DEV_ADDR")){        
+               char *endptr;
+               pSpk->nDevAddr = strtol(pValue, &endptr, 16); 
+               return;
+       };
 }
 
 void ftcc_print(TFTCConfiguration *pFTCC)
@@ -159,7 +163,7 @@ void ftcc_print(TFTCConfiguration *pFTCC)
        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(" DEVA ADDR  0x%x\n\r", pFTCC->nTSpkCharDevA.nDevAddr);
+       printf(" DEVA ADDR                = 0x%x\n\r", pFTCC->nTSpkCharDevA.nDevAddr);
        
        printf("Speaker B characterization data: \n\r");
 
@@ -173,7 +177,7 @@ void ftcc_print(TFTCConfiguration *pFTCC)
        printf(" SPKB PPC3_RTVA           = %2.2f\n\r", pFTCC->nTSpkCharDevB.nPPC3_RTVA);
        printf(" SPKB PPC3_SYSGAIN        = %2.2f\n\r", pFTCC->nTSpkCharDevB.nPPC3_SysGain);
        printf(" SPKB PPC3_DEV_NONLIN_PER = %2.2f\n\r", pFTCC->nTSpkCharDevB.nPPC3_DevNonlinPer);
-       printf(" DEVB ADDR =  0x%x\n\r", pFTCC->nTSpkCharDevB.nDevAddr);        
+       printf(" DEVB ADDR                = 0x%x\n\r", pFTCC->nTSpkCharDevB.nDevAddr);  
 
 }
 
@@ -246,7 +250,7 @@ int main(int argc, char *argv[])
        char pHint[256];
        TFTCConfiguration sFTCC;
 
-       printf("\n\rTI TAS2555 factory test calibration sequence V1.0\n\r");
+       printf("\nTI TAS2557 factory test calibration sequence V1.0\n");
 
        InitFTCC(&sFTCC);
 //     printf("argc = %d\n\r", argc);
index 6510893206eff733143015a71822ebd61bf18f07..90e173bf8358eb488b5a185f483af4be1e880bb9 100755 (executable)
@@ -8,8 +8,8 @@
 ; FTC Settings\r
 CALIBRATION_TIME          = 6000     ; Duration (in ms) of calibration phase\r
 CONFIGURATION             = 0        ; Refer to documentation\r
-CONFIGURATION_CALIBRATION = 2        ; Refer to documentation\r
-DEV_ADDR                                 = 98           ; I2C slave write addr for device A\r
+CONFIGURATION_CALIBRATION = 3        ; Refer to documentation\r
+DEV_ADDR                  = 98       ; I2C slave write addr for device A\r
 \r
 ; Obtained from Speaker Manufacturer\r
 SPK_T_MAX                 = 80       ; Speaker Maximum Temperature (C)\r
index dca1df1b7c0f157c2bec27fc96e0093e4e8572bd..56b70e7be93df0fdcfdfc22f70fe3736b553c4ad 100755 (executable)
@@ -8,8 +8,8 @@
 ; FTC Settings\r
 CALIBRATION_TIME          = 6000     ; Duration (in ms) of calibration phase\r
 CONFIGURATION             = 0        ; Refer to documentation\r
-CONFIGURATION_CALIBRATION = 2        ; Refer to documentation\r
-DEV_ADDR                                 = 98           ; I2C slave write addr for device B\r
+CONFIGURATION_CALIBRATION = 3        ; Refer to documentation\r
+DEV_ADDR                  = 9a       ; I2C slave write addr for device B\r
 \r
 ; Obtained from Speaker Manufacturer\r
 SPK_T_MAX                 = 80       ; Speaker Maximum Temperature (C)\r
index 70d255744786ac8a5168f6cb74e59d5a13e2d1af..bd138f123929e6027c4788bbf4bce8dcdc0e4ce1 100755 (executable)
--- a/tas2557.c
+++ b/tas2557.c
@@ -129,13 +129,13 @@ uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg)
 
 uint32_t tas2557_switch_device(uint8_t i2cslave)
 {
-       int device = i2cslave;
+       int addr = i2cslave;
        
        tas2557_check_node();
 
        gnDev = i2cslave;
        
-       ioctl(gTILoad, TILOAD_IOCTL_SET_CHL, &device);
+       ioctl(gTILoad, TILOAD_IOCTL_SET_CHL, &addr);
        
        return 0;
 }
@@ -160,7 +160,7 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
                                gpDevABlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
                        }
                        
-                       gnDevABlockIndex += 2;                  
+                       gnDevABlockIndex += 3;                  
                }
                else if(gnDev == gnDevB)
                {
@@ -177,7 +177,7 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
                                gpDevBBlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
                        }
                        
-                       gnDevBBlockIndex += 2;  
+                       gnDevBBlockIndex += 3;  
                }               
        }
        else
@@ -255,6 +255,10 @@ void tas2557_save_cal(TFTCConfiguration *pFTCC,
        fclose(pFile);
 }
 
+#define DDC_DESCRIPTION "Calibration Data File for TAS2557 Dual Mono"
+#define CALIBRATION_DESCRIPTION "Calibration snapshot for TAS2557 Dual Mono"
+#define DATA_DESCRIPTION "data blocks for TAS2557 Dual Mono FTCc"
+
 void tas2557_open_bin(char * pFileName, unsigned int nConfiguration, 
        unsigned char dev_a, unsigned char dev_b)
 {
@@ -265,32 +269,40 @@ void tas2557_open_bin(char * pFileName, unsigned int nConfiguration,
        
        gBinFile = open(pFileName, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
 
+       gnBinIndex = 0;
        memset(gpBin, 0, MAX_BIN_SIZE);
        memset(gpDevABlock, 0, MAX_BIN_SIZE/2);
        gnDevABlockIndex = 0;
        memset(gpDevBBlock, 0, MAX_BIN_SIZE/2);
        gnDevBBlockIndex = 0;
        
-       gpBin[3] = '2';
-       gpBin[2] = '5';
-       gpBin[1] = '5';
-       gpBin[0] = '5';
-
-       gpBin[20] = 0;
-       gpBin[21] = 0;
-       gpBin[22] = 1;  
-       gpBin[23] = 0;  //driver version 0x00000100
+       //magic number
+       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
+       
+       gpBin[gnBinIndex++] = 0;
+       gpBin[gnBinIndex++] = 0;
+       gpBin[gnBinIndex++] = 1;        
+       gpBin[gnBinIndex++] = 0;        //driver version 0x00000100
        
        time(&timestamp);
-       gpBin[24] = (unsigned char)((timestamp&0xff000000)>>24);
-       gpBin[25] = (unsigned char)((timestamp&0x00ff0000)>>16);;
-       gpBin[26] = (unsigned char)((timestamp&0x0000ff00)>>8);;        
-       gpBin[27] = (unsigned char)((timestamp&0x000000ff));;
+       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&0x000000ff));;
        
-       strcpy(&gpBin[28], "Calibration Data File");
-       strcpy(&gpBin[28 + 64], "Calibration Data File for TAS2557 Dual Mono");
-
-       gnBinIndex += 28 + 64 + strlen(&gpBin[28 + 64]) + 1;
+       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
        
@@ -312,15 +324,16 @@ void tas2557_open_bin(char * pFileName, unsigned int nConfiguration,
 
        strcpy(&gpBin[gnBinIndex], "Calibration snapshot");
        gnBinIndex += 64;
-       strcpy(&gpBin[gnBinIndex], "Calibration snapshot for TAS2557 Dual Mono");
-       gnBinIndex += strlen(&gpBin[gnBinIndex]) + 1;
+       strcpy(&gpBin[gnBinIndex], CALIBRATION_DESCRIPTION);
+       gnBinIndex += strlen(CALIBRATION_DESCRIPTION) + 1;
+       
        gpBin[gnBinIndex++] = 0x00; // compatible program = smart amp (index 0)
        gpBin[gnBinIndex++] = nConfiguration; // compatible configuration
        
        strcpy(&gpBin[gnBinIndex], "Calibration Data");
        gnBinIndex += 64;
-       strcpy(&gpBin[gnBinIndex], "Calibration Data for TAS2557 Dual Mono");
-       gnBinIndex += strlen(&gpBin[gnBinIndex]) + 1;
+       strcpy(&gpBin[gnBinIndex], DATA_DESCRIPTION);
+       gnBinIndex += strlen(DATA_DESCRIPTION) + 1;
        
        gpBin[gnBinIndex++] = 0x00; // 
        gpBin[gnBinIndex++] = 2;        // two blocks
index fafdefb8701a35672717bb1311afc32c50c036cb..cc4e776f4a903cbe08114fcd2d6ac20eafee6a03 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
@@ -48,6 +48,7 @@
 \r
 void tas2557_load_configuration(int nConfiguration);\r
 void tas2557_load_calibration(int nCalibration);\r
+void tas2557_mixer_command(char *pCommand, int nData);\r
 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
index 0a3725595eba5db452c577e720f69da512e79142..56e8821d9983b920d88e73e652572c1b45eeb3ba 100755 (executable)
@@ -63,6 +63,7 @@ uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC)
     tas2557_load_configuration(gpFTCC->nConfigurationCalibration);\r
 \r
     // STEP 2: Play calibration signal\r
+       tas2557_mixer_command("PRI_MI2S_RX Audio Mixer MultiMedia1", 1); //platform dependent\r
     nPlaybackProcess = sys_play_wav("silense.wav", "loop");\r
 \r
        // STEP 3: Play calibration signal\r