Skip to content

Commit 42765f5

Browse files
committed
feat(ledc): Change channel to uint8_t + add log message
1 parent 0fc3602 commit 42765f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cores/esp32/esp32-hal-ledc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static bool ledcDetachBus(void * bus){
5656
return true;
5757
}
5858

59-
bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, int channel)
59+
bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t channel)
6060
{
6161
if (channel >= LEDC_CHANNELS || resolution > LEDC_MAX_BIT_WIDTH)
6262
{
@@ -113,12 +113,13 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, int chann
113113
return false;
114114
}
115115

116+
log_i("LEDC attached to pin %u (channel %u, resolution %u)", pin, channel, resolution);
116117
return true;
117118
}
118119

119120
bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution)
120121
{
121-
int free_channel = ~ledc_handle.used_channels & (ledc_handle.used_channels+1);
122+
uint8_t free_channel = ~ledc_handle.used_channels & (ledc_handle.used_channels+1);
122123
if (free_channel == 0 || resolution > LEDC_MAX_BIT_WIDTH){
123124
log_e("No more LEDC channels available! (maximum %u) or bit width too big (maximum %u)", LEDC_CHANNELS, LEDC_MAX_BIT_WIDTH);
124125
return false;

cores/esp32/esp32-hal-ledc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef struct {
4545

4646
//channel 0-15 resolution 1-16bits freq limits depend on resolution
4747
bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution);
48-
bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, int channel);
48+
bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t channel);
4949
bool ledcWrite(uint8_t pin, uint32_t duty);
5050
uint32_t ledcWriteTone(uint8_t pin, uint32_t freq);
5151
uint32_t ledcWriteNote(uint8_t pin, note_t note, uint8_t octave);

0 commit comments

Comments
 (0)