微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 如何使用MT6323的AUX_IN pin来作为一般的ADC pin使用

如何使用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

  1. /*add for PAD_YM used as general ADC */
  2. static u16 mt_tpd_read_adc(u16 pos) {
  3. AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_ADDR, pos);
  4. AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_CON0, 0x01);
  5. while(0x01 & AUXADC_DRV_ReadReg16((volatile u16 *)AUXADC_TP_CON0)) { ; } //wait for write finish
  6. return AUXADC_DRV_ReadReg16((volatile u16 *)AUXADC_TP_DATA0);
  7. }
  8. static void mt_auxadc_disable_penirq(void)
  9. {
  10. //Turn off PENIRQ detection circuit
  11. AUXADC_DRV_SetBits16((volatile u16 *)AUXADC_TP_CMD, 1);
  12. //run once touch function
  13. mt_tpd_read_adc(TP_CMD_ADDR_X);
  14. }
  15. #define PAD_AUX_YM 15
  16. /* add end */
  17. //step1 check con2 if auxadc is busy
  18. //step2 clear bit
  19. //step3 read channle and make sure old ready bit ==0
  20. //step4 set bit to trigger sample
  21. //step5 read channle and make sure ready bit ==1
  22. //step6 read data
  23. int IMM_GetOneChannelValue(int dwChannel, int data[4], int* rawdata)
  24. {
  25. unsigned int channel[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  26. int idle_count =0;
  27. int data_ready_count=0;
  28. mutex_lock(&mutex_get_cali_value);
  29. if(enable_clock(MT65XX_PDN_PERI_AUXADC,"AUXADC"))
  30. {
  31. //printk("hwEnableClock AUXADC !.");
  32. if(enable_clock(MT65XX_PDN_PERI_AUXADC,"AUXADC"))
  33. {printk("hwEnableClock AUXADC failed.");}
  34. }

复制代码

  1. /* add for PAD_YM used as general ADC */
  2. if(dwChannel == PAD_AUX_YM)
  3. {
  4. printk("[adc_api]: channel 15 : disable penirq ################\n");
  5. mt_auxadc_disable_penirq();
  6. }
  7. /* add end */

复制代码


最后一段代码就是需要增加的修改的代码~

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top