/* * * aic3204_test( ) * * Test different configurations of the AIC3204 */ Int16 aic3204_test( ) { /* Initialize I2C */ EZDSP5535_I2C_init( ); EZDSP5535_wait( 100 ); // Wait printf( "<-> Audio Loopback from Stereo IN --> to HP OUT\n" ); if ( aic3204_loop_linein( ) ) // Loop test return 3; return 0; }
/* * * AIC3204_rGet( regnum, *regval ) * * Return value of codec register regnum * */ Int16 AIC3204_rget( Uint16 regnum, Uint16* regval ) { Int16 retcode = 0; Uint16 cmd[2]; cmd[0] = regnum & 0x007F; // 7-bit Device Register cmd[1] = 0; retcode |= EZDSP5535_I2C_write( AIC3204_I2C_ADDR, cmd, 1 ); retcode |= EZDSP5535_I2C_read( AIC3204_I2C_ADDR, cmd, 1 ); *regval = cmd[0]; EZDSP5535_wait( 10 ); return retcode; }
ECG_Status ECG_LEADOFF_DETECT_INIT() { PSP_Result Status = PSP_SOK; Uint8 i2cdata[2], i2cRxData[2] = {0,0},pca9535PolReg[2] = {0,0}; extern Uint16 LeadOffStatus; Uint8 A1=0,A2=0,B1=0,B2=0,nA1=0,nA2=0,nB1=0,nB2 =0, PortA =0, PortB = 0; /* Value to set PA0 -PA7 as input*/ i2cdata[0] = 0xFF; /*Value to set PB0 as input, PB0 -PB7 as input*/ i2cdata[1] = 0xFF; EZDSP5535_wait(200); /* Read ConfigPort0 - 1 represents Input*/ i2c_read_reg(CMD_PCA9535_CP0,&i2cRxData[0]); EZDSP5535_wait(200); /* Read ConfigPort1*/ i2c_read_reg(CMD_PCA9535_CP1,&i2cRxData[1]); EZDSP5535_wait(200); /* Read PolarityInPort0 - 0 represents no inversion*/ i2c_read_reg(CMD_PCA9535_PIP0,&pca9535PolReg[0]); EZDSP5535_wait(200); /* Read PolarityInPort1*/ i2c_read_reg(CMD_PCA9535_PIP1,&pca9535PolReg[1]); EZDSP5535_wait(200); /* Read the Ports A and B once so as to clear any interrupts Set the currnt Lead off status as the init status. */ i2cRxData[0] = 0; i2cRxData[1] = 0; EZDSP5535_wait(200); i2c_read_reg(CMD_PCA9535_IP0,&i2cRxData[0]);/* Read Input Port0*/ EZDSP5535_wait(200); i2c_read_reg(CMD_PCA9535_IP1,&i2cRxData[1]);/* Read Input Port1*/ /* Getting the Leadoff value by XOR ing with the corresponding Polarity register value so as to avoid any polarity changes */ A1 = i2cRxData[0]; A2 = i2cRxData[1]; B1 = pca9535PolReg[0]; B2 = pca9535PolReg[1]; nA1 = LEADOFFMASK - i2cRxData[0]; nA2 = LEADOFFMASK - i2cRxData[1]; nB1 = LEADOFFMASK - pca9535PolReg[0]; nB2 = LEADOFFMASK - pca9535PolReg[1]; PortA = ( nA1 & B1 ) | (A1 & nB1); PortB = ( nA2 & B2 ) | (A2 & nB2); LeadOffStatus = ((PortB << 8) | PortA); /*Gayathri*/ // LeadOffStatus = 0x01FF; return Status; }
//need to double check every function, somehow ECG_Status ECG_C5505Init() { ECG_Status Status; //printf("debug jb\n");//jb // clock enable to Timer, SPI, DMA, UART,SAR, LCD. // *IDLE_PCGCRL_ADDR = 0x4BB1; // *IDLE_PCGCRM_ADDR = 0x0004; /*making Serial Port 0 and Serial Port 1 to mode 10 so that serial port 0 pins are configured as GPIO*/ // set parallel port to 5 //*PERIPHSEL0_ADDR = 0x5A00; //Disable all interrupts // *CPU_IER0_ADDR = 0; // *CPU_IER1_ADDR = 0; // // clear interrupt flags // *CPU_IFR0_ADDR = *CPU_IFR0_ADDR; // *CPU_IFR1_ADDR = *CPU_IFR1_ADDR; //asm("\tBIT (ST1, #ST1_INTM) = #1"); /*Disable GLobal Int.Mask*/ /*//making Serial Port 0 Mode to 10 here */ //*PERIPHSEL0_ADDR = *PERIPHSEL0_ADDR & 0xFEFF; //clearing bit 8//ravi27/03/2009 //*PERIPHSEL0_ADDR = *PERIPHSEL0_ADDR | 0x0200; // setting bit 9//ravi27/03/2009 /*Enable interrupt for Leadoff - INT1 of CPU*/ //*CPU_IER0_ADDR = *CPU_IER0_ADDR | 0x0008; /* Call GPIO Init*/ //ECG_GPIO_INIT(); //printf("debug GPIO success jb\n");//jb /* Call I2C init*/ //Status = ECG_I2C_INIT(); //printf("debug I2C success jb\n");//jb //if(Status != ECG_OK) //{ //printf("I2C Init FAIL\n"); //while(1); //} //else //{ //printf("I2C Init PASS\n"); //} //EZDSP5535_wait(1000); // /* Call SPI Init*/ // Status = ECG_SPI_INIT(); // if(Status != ECG_OK) // { // printf("SPI Init FAIL\n"); // while(1); // } // else // { // printf("SPI Init PASS\n"); // } // // EZDSP5535_wait(1000); // // /* Call UART initialisation*/ // //ECG_UART_INIT(); // // EZDSP5535_wait(1000); // // /* Call Front End Init*/ // Status = ECG_FE_INIT(); //not sure if correct, leadoff causes problem // if(Status != ECG_OK) // { // printf("FE Init FAIL\n"); // while(1); // } // else // { // printf("FE Init PASS\n"); // } // // EZDSP5535_wait(1000); #if 1 /* Call LCD initialisation*/ //ECG_LCD_INIT(); //EZDSP5535_wait(1000); #endif /* Call SAR Init*/ Status = ECG_SAR_INIT(); // if(Status != ECG_OK) // { // printf("SAR Init FAIL\n"); // while(1); // } // else // { // printf("SAR Init PASS\n"); // } EZDSP5535_wait(1000); /* Call DMA Init*/ // Status = ECG_DMA_INIT(); // if(Status != ECG_OK) // { // printf("DMA Init FAIL\n"); // while(1); // } // else // { // printf("DMA Init PASS\n"); // } // // EZDSP5535_wait(1000); /* Call Timer Initialization*/ //ECG_TIMER_INIT(); // // Enable Interrupt SAR,Timer // *CPU_IER0_ADDR = *CPU_IER0_ADDR | 0x3090; // /*Enable interrupt for Leadoff - INT1 of CPU*/ // *CPU_IER0_ADDR = *CPU_IER0_ADDR | 0x0008; // // asm("\tBIT (ST1, #ST1_INTM) = #0"); /*Enalbe GLobal Int.Mask*/ return Status; }