如何使用MT6323的AUX_IN pin来作为一般的ADC pin使用
时间:10-02
整理:3721RD
点击:
如何使用MT6323的AUX_IN pin来作为一般的ADC pin使用
目前MT6323这边ADC有6个external pin可供使用AUX_IN0,AUX_IN1这边跟一般的ADC使用是一样的
AUX_IN2_XP, AUX_IN3_YP, AUX_IN4_XM, AUX_IN5_YM
因其原本是给touch panel使用的,故不能直接作为一般的ADC使用需要按照如下方式修改code才可以
解决方法:
下面以使用AUX_IN5_YM作为一般的ADC使用采取的修改方式
其他的ADC pin均是一样的方式修改
alps\mediatek\platform\MT6572\kernel\core\mt_auxadc.c
最后一段代码就是需要增加的修改的代码~
目前MT6323这边ADC有6个external pin可供使用AUX_IN0,AUX_IN1这边跟一般的ADC使用是一样的
AUX_IN2_XP, AUX_IN3_YP, AUX_IN4_XM, AUX_IN5_YM
因其原本是给touch panel使用的,故不能直接作为一般的ADC使用需要按照如下方式修改code才可以
解决方法:
下面以使用AUX_IN5_YM作为一般的ADC使用采取的修改方式
其他的ADC pin均是一样的方式修改
alps\mediatek\platform\MT6572\kernel\core\mt_auxadc.c
- /*add for PAD_YM used as general ADC */
- static u16 mt_tpd_read_adc(u16 pos) {
- AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_ADDR, pos);
- AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_CON0, 0x01);
- while(0x01 & AUXADC_DRV_ReadReg16((volatile u16 *)AUXADC_TP_CON0)) { ; } //wait for write finish
- return AUXADC_DRV_ReadReg16((volatile u16 *)AUXADC_TP_DATA0);
- }
- static void mt_auxadc_disable_penirq(void)
- {
- //Turn off PENIRQ detection circuit
- AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_CMD, 1);
- //run once touch function
- mt_tpd_read_adc(TP_CMD_ADDR_X);
- }
- #define PAD_AUX_YM 15
- /* add end */
- //step1 check con2 if auxadc is busy
- //step2 clear bit
- //step3 read channle and make sure old ready bit ==0
- //step4 set bit to trigger sample
- //step5 read channle and make sure ready bit ==1
- //step6 read data
- int IMM_GetOneChannelValue(int dwChannel, int data[4], int* rawdata)
- {
- unsigned int channel[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- int idle_count =0;
- int data_ready_count=0;
- mutex_lock(&mutex_get_cali_value);
- if(enable_clock(MT65XX_PDN_PERI_AUXADC,"AUXADC"))
- {
- //printk("hwEnableClock AUXADC !.");
- if(enable_clock(MT65XX_PDN_PERI_AUXADC,"AUXADC"))
- {printk("hwEnableClock AUXADC failed.");}
- }
- /* add for PAD_YM used as general ADC */
- if(dwChannel == PAD_AUX_YM)
- {
- printk("[adc_api]: channel 15 : disable penirq ################\n");
- mt_auxadc_disable_penirq();
- }
- /* add end */
最后一段代码就是需要增加的修改的代码~