Skip to content

Commit 46bab40

Browse files
author
Erik Slagter
committed
Add PWM mode to GPIO.
Period is 3000, this makes the pwm frequency about 330 Hz and the theoretical resolution about 16 bits. The effective resolution is probably about 14-15 bits, but the duty cycle can be configured to the whole 16 bit range: 0 (off), 1-65534 and 65535 (on). Values between 55000 and 65535 probably all mean "on" and values below 16 are probably all "off". Your mileage may vary.
1 parent b5d14fb commit 46bab40

File tree

4 files changed

+196
-178
lines changed

4 files changed

+196
-178
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CINC = -I$(SDKROOT)/lx106-hal/include -I$(SDKROOT)/xtensa-lx106-elf/xtensa-lx1
77
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
88
LDSCRIPT = -T$(SDKLD)/eagle.app.v6.ld
99
LDSDK = -L$(SDKROOT)/sdk/lib
10-
LDLIBS = -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa -lmain
10+
LDLIBS = -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa -lmain -lpwm
1111

1212
OBJS = application.o config.o gpios.o queue.o stats.o uart.o user_main.o util.o wlan.o
1313
HEADERS = esp-uart-register.h \

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,29 @@ These are the currently implemented commands on port 24:
6363
gd gpio-dump none dump gpio configuration and current status
6464
gg gpio-get gpio for example gpio2; reads the the gpio as input
6565
(if set to mode input)
66-
gm gpio-mode varies none: dump all gpio's
66+
gm gpio-mode VARIES none: dump all gpio's
6767
<gpio> disable: disable the gpio
6868
<gpio> input: set gpio to input
69-
<gpio> output <startup>: set gpio to output,
70-
set <startup> to 0 or 1 to define the startup
71-
value (after boot)
69+
<gpio> output <startup state>: set gpio to output,
70+
set <startup state> to 0 or 1 to configure the state
71+
of the output directly after boot.
7272
<gpio> bounce <direction> <delay> <repeat> <autotrigger>
7373
<direction> = up or down, specifying whether to bounce
7474
from "off" or "on"
7575
<delay> = value in milliseconds between triggered state
7676
and resuming normal gpio state
7777
<repeat> = 0 or 1, 0 means once, 1 means repeating
7878
until stopped manually
79-
<autotrigger> = 0 or 1, 0 means leave the gpio alone
80-
after boot, need to trigger manually (using gpio-set),
81-
1 means trigger automatically after boot
79+
<autotrigger> = 0 or 1,
80+
0 means leave the gpio alone after boot, need to
81+
trigger manually (using gpio-set),
82+
1 means trigger automatically after boot.
83+
<gpio> pwm [<startup duty cycle>]
84+
<startup duty cycle> is the duty cycle after boot,
85+
default 0 for off.
8286
gs gpio-set <gpio> (value) set the gpio if it's set as output, if set
83-
as bounce, trigger a bounce
87+
as bounce, trigger a bounce, if it's set as pwm, set
88+
the duty cycle (startup value is taken if it's missing).
8489
? help none shows list of commands
8590
pd print-debug 0 or 1 0 = enable, 1 = enable
8691
toggle printing of debug info during

0 commit comments

Comments
 (0)