Update esp8266toEsp32.cpp

This commit is contained in:
stefanbode 2022-07-22 14:45:10 +02:00 committed by GitHub
parent c1fba57bb6
commit 51472ef842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef ESP32
@ -70,16 +69,16 @@ int32_t _analog_pin2chan(uint32_t pin) { // returns -1 if uallocated
void _analogWriteFreqRange(uint8_t pin) {
_analogInit(); // make sure the mapping array is initialized
if (pin = 255) {
if (pin == 255) {
for (uint32_t channel = 0; channel < MAX_PWMS; channel++) {
if (pwm_channel[channel] < 255) {
ledcSetup(channel, pwm_frequency, pwm_bit_num);
}
}
} else {
int32_t chan = _analog_pin2chan(pin);
if (chan >= 0) {
ledcSetup(chan, pwm_frequency, pwm_bit_num);
int32_t channel = _analog_pin2chan(pin);
if (channel >= 0) {
ledcSetup(channel, pwm_frequency, pwm_bit_num);
}
}
}
@ -140,7 +139,6 @@ int32_t analogAttach(uint32_t pin, bool output_invert) { // returns ledc chan
};
ledc_channel_config(&ledc_channel);
ledcSetup(channel, pwm_frequency, pwm_bit_num);
// Serial.printf("PWM: New attach pin %d to channel %d\n", pin, channel);
return channel;
@ -165,7 +163,6 @@ extern "C" void __wrap__Z11analogWritehi(uint8_t pin, int val) {
By default all phases are starting at the same moment. This means
the the power supply always takes a power hit at the start of each
new cycle, even if the average power is low.
Phase control is also of major importance for H-bridge where
both PWM lines should NEVER be active at the same time.