Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip #115

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Wip #115

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
682c5bb
Jos: Adapted for the ESP32
Sep 25, 2021
bf812fe
Jos: Changed resume to avoid a duplicate name.
Sep 25, 2021
1fbfeaa
Jos:Prepairing for pre-emptive mulitasking, interrupts and us@
Sep 25, 2021
9130cba
Jos:Added pre-emptive mulitasking, interrupts and us@
Sep 25, 2021
eec85ed
Jos:The esp32 version.
Sep 25, 2021
90328dc
Added interrupts
Jan 9, 2022
5ab4dd6
Jos: Adding lightsleep ESP-NOW. Modified deep-sleep
May 24, 2022
5cc1504
Jos: Adding a number of tests
May 24, 2022
70014d5
Merge pull request #81 from Jos-Ven/WIP
MitchBradley May 24, 2022
6abd00d
Jos: For better ADC results
Sep 14, 2022
62bea3b
Jos: To Show the improvement of the ADC
Sep 14, 2022
09d1e25
Merge pull request #89 from Jos-Ven/WIP
MitchBradley Sep 14, 2022
054514c
Jos: Additions for calls for an extra uart and lwip-recv-r to avoid h…
Oct 22, 2022
2ad6152
Merge branch 'MitchBradley:WIP' into WIP
Jos-Ven Oct 22, 2022
d91591a
Jos: Changed get-ticks ms and get-msecs so they are right when the fr…
Dec 15, 2022
2b4b947
Jos: Simplified deep sleep. Now it is the same as on an ESP32
Jan 4, 2023
7a873f9
Jos: lwip-recv-r is not needed when SO_RCVTIMEO is used.
Jan 4, 2023
9aa8e61
Jos: Adding more tools
Jan 13, 2023
5bd25e9
Jos: For timings, html, and svg
Jan 13, 2023
4cdff17
Jos: Updating for table_sort.f to sort different tables
Jun 30, 2023
92fcbd5
Merge pull request #90 from Jos-Ven/WIP
MitchBradley Jun 30, 2023
83c067c
Solving a bug
Jos-Ven Jul 3, 2023
33c4960
For the latest extensions
Jos-Ven Jul 3, 2023
1b40ad0
WIP branch only correction
Jos-Ven Jul 3, 2023
e782388
Needed to receive ASCII files over a wifi connection
Jos-Ven Jul 17, 2023
dce186a
New additions and updates
Jos-Ven Jul 17, 2023
5589561
Merge pull request #112 from Jos-Ven/WIP
MitchBradley Jul 17, 2023
fbb951d
bugfix
Jos-Ven Aug 4, 2023
0ed02b1
Adapting for new apps
Jos-Ven Aug 4, 2023
1422e9e
To load rcvfile.fth in a task when booting
Jos-Ven Aug 4, 2023
fcbdac5
To see the measured temperature of an NTC in a browser
Jos-Ven Aug 4, 2023
0d84828
To see the air quality in a browser
Jos-Ven Aug 4, 2023
69ca46f
Merge branch 'MitchBradley:WIP' into WIP
Jos-Ven Aug 6, 2023
19166ce
Adapted for esp8266-rtos
Jos-Ven Aug 8, 2023
7b932c3
time_t_sec is needed for date/time calculations
Jos-Ven Aug 8, 2023
fb0f1f0
Using time instead of gettimeofday
Jos-Ven Aug 9, 2023
933663c
Merge pull request #114 from Jos-Ven/WIP
MitchBradley Aug 9, 2023
f99e44d
tccall problem
Jos-Ven Aug 20, 2023
b640da3
Merge remote-tracking branch 'refs/remotes/origin/WIP' into WIP
Jos-Ven Aug 20, 2023
5202325
tccall problem
Jos-Ven Aug 20, 2023
566a5e2
Cleanup and removed short-timeout
Jos-Ven Aug 21, 2023
b187a5c
Merge pull request #119 from Jos-Ven/WIP
MitchBradley Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ UPDIR=$(realpath $(TOPDIR)/..)

CONFIG += -DBITS32
CONFIG += -DFLOATING -DMORE_FP


LIBS += -lm

CFLAGS += -m32
Expand Down
107 changes: 103 additions & 4 deletions build/esp32/sdk_build/main/interface.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ typedef int cell;
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"

#include "esp_wifi_types.h"

#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_event.h"
Expand Down Expand Up @@ -66,6 +69,19 @@ void init_uart(void)
uart_driver_install(uart_num, BUF_SIZE * 2, 0, 0, NULL, 0);
}

cell my_uart_param_config(int uart_num, int baud, int bits, int par, int stop, int flow)
{
uart_config_t uart_config = {
.baud_rate = baud,
.data_bits = bits-5,
.parity = par,
.stop_bits = stop,
.flow_ctrl = flow,
.rx_flow_ctrl_thresh = 122,
};
return uart_param_config(uart_num, &uart_config);
}

// Routines for the ccalls[] table in textend.c. Add new ones
// as necessary.

Expand Down Expand Up @@ -304,19 +320,66 @@ cell wifi_open(cell timeout, char *password, char *ssid)
return 0;
}

static esp_err_t esp_now_event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
case SYSTEM_EVENT_STA_START:
// printf ("%s \n", "WiFi for ESP-NOW started");
break;
default:
break;
}
return ESP_OK;
}

// esp_now_open and wifi_open can not both be used at the same time!

cell esp_now_open(int channel)
{
tcpip_adapter_init();
if ( esp_event_loop_init(esp_now_event_handler, NULL)) return -1;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_wifi_init(&cfg);
esp_wifi_set_storage(WIFI_STORAGE_RAM);
if ( esp_wifi_set_mode(WIFI_MODE_STA) ) return -2;
if ( esp_wifi_start()) return -3;
if ( esp_wifi_set_channel(channel,WIFI_SECOND_CHAN_NONE)) return -4;
return 0;
}

cell get_wifi_mode(void)
{
wifi_mode_t mode;
esp_wifi_get_mode(&mode);
return mode;
}

static DRAM_ATTR portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;

void IRAM_ATTR interrupt_disable()
{
if (xPortInIsrContext()) {
portENTER_CRITICAL_ISR(&global_int_mux);
} else {
portENTER_CRITICAL(&global_int_mux);
}
}

void IRAM_ATTR interrupt_restore()
{
if (xPortInIsrContext()) {
portEXIT_CRITICAL_ISR(&global_int_mux);
} else {
portEXIT_CRITICAL(&global_int_mux);
}
}

void set_log_level(char *component, int level)
{
esp_log_level_set(component, level);
}

int stream_connect(char *host, char *portstr, int timeout_msecs)
int client_socket(char *host, char *portstr, cell protocol)
{
struct addrinfo hints, *res, *res0;
int error;
Expand All @@ -325,7 +388,7 @@ int stream_connect(char *host, char *portstr, int timeout_msecs)

memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_socktype = protocol;

error = getaddrinfo(host, portstr, &hints, &res0);
if (error) {
Expand All @@ -339,7 +402,6 @@ int stream_connect(char *host, char *portstr, int timeout_msecs)
cause = "socket";
continue;
}

if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
cause = "connect";
close(s);
Expand All @@ -354,6 +416,22 @@ int stream_connect(char *host, char *portstr, int timeout_msecs)
return -2;
}

return s;
}

cell udp_client(char *host, char *portstr)
{
return client_socket(host, portstr, SOCK_DGRAM);
}

int stream_connect(char *host, char *portstr, int timeout_msecs)
{
int s = client_socket(host, portstr, SOCK_STREAM);
int error;
if (s < 0) {
return s;
}

struct timeval recv_timeout;
recv_timeout.tv_sec = timeout_msecs / 1000;
recv_timeout.tv_usec = (timeout_msecs % 1000) * 1000;
Expand Down Expand Up @@ -508,7 +586,28 @@ void restart(void)
}

#include <rom/ets_sys.h>
void us(cell us)
void IRAM_ATTR us(cell us)
{
ets_delay_us(us);
}

int IRAM_ATTR time_t_now()
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
gettimeofday(&tv, NULL);
return tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
}

int IRAM_ATTR time_t_ms()
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
gettimeofday(&tv, NULL);
return tv.tv_sec*(uint64_t)1000+tv.tv_usec/1000;
}

int IRAM_ATTR time_t_sec()
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
gettimeofday(&tv, NULL);
return tv.tv_sec;
}
14 changes: 7 additions & 7 deletions build/esp32/sdk_build/sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y
#
CONFIG_LOG_BOOTLOADER_LEVEL_NONE=
CONFIG_LOG_BOOTLOADER_LEVEL_ERROR=
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG=
CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE=
CONFIG_LOG_BOOTLOADER_LEVEL=2
CONFIG_LOG_BOOTLOADER_LEVEL=3
CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V=
CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y
CONFIG_BOOTLOADER_FACTORY_RESET=
Expand All @@ -35,7 +35,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
#
# Serial flasher config
#
CONFIG_ESPTOOLPY_PORT="COM27"
CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0"
CONFIG_ESPTOOLPY_BAUD_115200B=y
CONFIG_ESPTOOLPY_BAUD_230400B=
CONFIG_ESPTOOLPY_BAUD_921600B=
Expand Down Expand Up @@ -554,11 +554,11 @@ CONFIG_HEAP_TRACING=
#
CONFIG_LOG_DEFAULT_LEVEL_NONE=
CONFIG_LOG_DEFAULT_LEVEL_ERROR=
CONFIG_LOG_DEFAULT_LEVEL_WARN=
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
CONFIG_LOG_DEFAULT_LEVEL_INFO=
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_DEFAULT_LEVEL=2
CONFIG_LOG_COLORS=y

#
Expand Down
Loading