查看ESP32 Onchip Sensor的源代码
←
ESP32 Onchip Sensor
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Study == * The Hall Sensor uses Channel_0 and Channel_3 of ADC1. * Set the width of ADC1 module to 12bit by calling adc1_config_width before calling hall_sensor_read. * Please do not use Channel_0 and Channel_3 of ADC1 as ADC channels when you use the hall sensor. <source lang=cpp> static int hall_sensor_get_value() //hall sensor without LNA { int Sens_Vp0; int Sens_Vn0; int Sens_Vp1; int Sens_Vn1; int hall_value; portENTER_CRITICAL(&rtc_spinlock); // XPD HALL is controlled by SW SET_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_XPD_HALL_FORCE_M); // Power on hall sensor and connect to VP and VN SET_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_XPD_HALL); // HALL PHASE is controlled by SW SET_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_HALL_PHASE_FORCE_M); // normal phase of hall sensor CLEAR_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_HALL_PHASE); Sens_Vp0 = adc1_get_voltage(ADC1_CHANNEL_0); Sens_Vn0 = adc1_get_voltage(ADC1_CHANNEL_3); // Reverse phase of hall sensor SET_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_HALL_PHASE); Sens_Vp1 = adc1_get_voltage(ADC1_CHANNEL_0); Sens_Vn1 = adc1_get_voltage(ADC1_CHANNEL_3); // SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S); CLEAR_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_XPD_HALL_FORCE); CLEAR_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_HALL_PHASE_FORCE); portEXIT_CRITICAL(&rtc_spinlock); hall_value = (Sens_Vp1 - Sens_Vp0) - (Sens_Vn1 - Sens_Vn0); return hall_value; } int hall_sensor_read() { adc1_pad_init(ADC1_CHANNEL_0); adc1_pad_init(ADC1_CHANNEL_3); adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_0db); adc1_config_channel_atten(ADC1_CHANNEL_3, ADC_ATTEN_0db); return hall_sensor_get_value(); } </source> <br><br>
返回到
ESP32 Onchip Sensor
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面