Skip to content

Commit 60bb0ff

Browse files
committed
add adc function
1 parent db23294 commit 60bb0ff

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compat.h

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void httpd_loop(int s);
111111
void gpio_enable(int pin, int state);
112112
void gpio_write(int pin, int value);
113113
int gpio_read(int pin);
114+
int sdk_system_adc_read();
114115

115116
// flash simulation in RAM
116117
#define SPI_FLASH_RESULT_OK 0
@@ -128,6 +129,8 @@ void httpd_loop(int s);
128129

129130
#define flash_memory ((unsigned char*)(0x40200000 + FS_ADDRESS))
130131

132+
#include <stdbool.h>
133+
#include <espressif/esp_system.h>
131134
#include "esp_spiffs.h"
132135
#include "spiffs.h"
133136

lisp.c

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,11 @@ PRIM dht(lisp pin) {
833833
return cons(mkint(t), mkint(h));
834834
}
835835

836+
PRIM adc() {
837+
int v = sdk_system_adc_read();
838+
return mkint(v);
839+
}
840+
836841
// CONTROL INTERRUPTS:
837842
// -------------------
838843
// (interrupt PIN 0) : disable
@@ -1996,7 +2001,6 @@ PRIM printf_(lisp *envp, lisp all) {
19962001
char type = *p++ = *f++;
19972002
switch (type) {
19982003
case '%':
1999-
putchar('%'); break;
20002004
case 's':
20012005
princ(car(all)); break;
20022006
case 'S':
@@ -3366,6 +3370,7 @@ lisp lisp_init() {
33663370
DEFPRIM(in, 1, in);
33673371
DEFPRIM(dht, 1, dht);
33683372
DEFPRIM(interrupt, 2, interrupt);
3373+
DEFPRIM(adc, 0, adc);
33693374

33703375
// system stuff
33713376
DEFPRIM(gc, -1, gc);

tlisp.ccc

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
void gpio_enable(int pin, int state) {}
2525
void gpio_write(int pin, int value) {}
2626
int gpio_read(int pin) { return 0; }
27+
int sdk_system_adc_read() { return 777; }
2728

2829
void interrupt_init (int pin, int changeType) {}
2930
int getInterruptCount(int pin, int mode) { return -1; }

0 commit comments

Comments
 (0)