compiler bug, occures in "hal/pcnt_ll.h" - Expresion regarded as CONST ?
Posted: Sun Mar 01, 2020 9:14 am
simply add #include "driver/pcnt.h" in my Project
causes two Compiler-Problems in "hal/pcnt_ll.h" line 48 and in line 60 (see Code below)
C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:48:71: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed
I cannot see why the Compiler does not understand this original espressif Code
- seems to be a Compiler Bug: - Looks like he regards the struct as CONST
I have also added my BugFix
I am using the latest Eclipse-plugin, Installed 4 Days ago
- Espressif IDF Plugins for Eclipse 1.0.0.202002201116 com.espressif.idf.feature.feature.group ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD
with PCNT
causes two Compiler-Problems in "hal/pcnt_ll.h" line 48 and in line 60 (see Code below)
C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:48:71: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed
I cannot see why the Compiler does not understand this original espressif Code
- seems to be a Compiler Bug: - Looks like he regards the struct as CONST
I have also added my BugFix
I am using the latest Eclipse-plugin, Installed 4 Days ago
- Espressif IDF Plugins for Eclipse 1.0.0.202002201116 com.espressif.idf.feature.feature.group ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD
- /**
- * @brief Set PCNT counter mode
- *
- * @param hw Peripheral PCNT hardware instance address.
- * @param unit PCNT unit number
- * @param channel PCNT channel number
- * @param pos_mode Counter mode when detecting positive edge
- * @param neg_mode Counter mode when detecting negative edge
- * @param hctrl_mode Counter mode when control signal is high level
- * @param lctrl_mode Counter mode when control signal is low level
- */
- static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
- {
- // typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; //C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:48:71: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed union>'
- // if (channel == 0) {
- // conf0_reg.ch0_pos_mode = pos_mode;
- // conf0_reg.ch0_neg_mode = neg_mode;
- // conf0_reg.ch0_hctrl_mode = hctrl_mode;
- // conf0_reg.ch0_lctrl_mode = lctrl_mode;
- // } else {
- // conf0_reg.ch1_pos_mode = pos_mode;
- // conf0_reg.ch1_neg_mode = neg_mode;
- // conf0_reg.ch1_hctrl_mode = hctrl_mode;
- // conf0_reg.ch1_lctrl_mode = lctrl_mode;
- // }
- // hw->conf_unit[unit].conf0 = conf0_reg; //C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:60:33: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed union>'
- //My Bugfix for the moment
- typeof(hw->conf_unit[unit].conf0)* lConf0RegPtr = &hw->conf_unit[unit].conf0;
- if (channel == 0) {
- lConf0RegPtr->ch0_pos_mode = pos_mode;
- lConf0RegPtr->ch0_neg_mode = neg_mode;
- lConf0RegPtr->ch0_hctrl_mode = hctrl_mode;
- lConf0RegPtr->ch0_lctrl_mode = lctrl_mode;
- } else {
- lConf0RegPtr->ch1_pos_mode = pos_mode;
- lConf0RegPtr->ch1_neg_mode = neg_mode;
- lConf0RegPtr->ch1_hctrl_mode = hctrl_mode;
- lConf0RegPtr->ch1_lctrl_mode = lctrl_mode;
- }
- }