Conversation
|
Do ADC next! :) |
|
@deadprogram I'm not sure if you'll like it, but I added an alias for spi2 as spi0 for esp32c3 to test the pass, and it was easier too) |
|
It's funny, but I really need ADC) |
|
|
Shouldn't |
Sorry) |
|
@dimajolkin can you please rename that file? |
forgot push) |
src/machine/machine_esp32xx_pwm.go
Outdated
| } | ||
| freq := uint64(1e9) / period | ||
| dutyRes := uint8(10) | ||
| if freq < 100 { |
There was a problem hiding this comment.
switch {
case freq < 100:
dutyRes = 14
case freq < 1000:
dutyRes = 12
case freq > 100_000:
dutyRes = 8
}| signal := pwm.SigOutBase + uint32(ch) | ||
| pin.configure(PinConfig{Mode: PinOutput}, signal) // GPIO matrix: pin <- LEDC_LS_SIG_OUTn | ||
|
|
||
| baseOff := uintptr(ch) * ledcChannelBlockSize |
There was a problem hiding this comment.
Maybe better to add a function with a switch statement instead of the pointer arithmetic?
|
|
||
| baseOff := uintptr(ch) * ledcChannelBlockSize | ||
| conf0 := (*volatile.Register32)(unsafe.Add(unsafe.Pointer(&esp.LEDC.CH0_CONF0), baseOff)) | ||
| conf0.Set((uint32(pwm.timerNum) << 0) | (1 << 2) | (0 << 3)) // timer_sel, sig_out_en=1, idle_lv=0 |
There was a problem hiding this comment.
Better to use consts like esp.LEDC_CH_CONF0_TIMER_SEL_Pos, esp.LEDC_CH_CONF0_SIG_OUT_EN,etc.
But best to use esp.LEDC.SetCH0_CONF0_TIMER_SEL(), esp.LEDC.SetCH0_CONF0_SIG_OUT_EN(), and other setter functions.
| value = top | ||
| } | ||
| dutyVal := value << ledcDutyFracBits | ||
| baseOff := uintptr(channel) * ledcChannelBlockSize |
Added implements for esp32s3 & esp32c3 PWM.
tested with an oscilloscope:
1.bmp
TDeck lilygo brightness control was on pwm.