mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
new esp32 bsp for idf 5.0
This commit is contained in:
parent
d80e4f3114
commit
f9deb5b514
1
bsp/esp32c3/.gitignore
vendored
Normal file
1
bsp/esp32c3/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build/
|
@ -1,6 +1,11 @@
|
||||
# The following lines of boilerplate have to be in your project's
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
|
||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common components)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(pikascript)
|
||||
project(main)
|
||||
|
10
bsp/esp32c3/README.md
Normal file
10
bsp/esp32c3/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# SDK
|
||||
|
||||
esp-idf 5.0
|
||||
|
||||
# Compile
|
||||
|
||||
- on windows
|
||||
```
|
||||
make.bat
|
||||
```
|
8
bsp/esp32c3/components/PikaPython/main.py
Normal file
8
bsp/esp32c3/components/PikaPython/main.py
Normal file
@ -0,0 +1,8 @@
|
||||
import PikaStdLib
|
||||
import ESP32
|
||||
print('hello PikaPython')
|
||||
mem = PikaStdLib.MemChecker()
|
||||
print('mem used max:')
|
||||
mem.max()
|
||||
print('mem used now:')
|
||||
mem.now()
|
@ -1,4 +1,4 @@
|
||||
pikascript-core==v1.12.0
|
||||
PikaStdLib==v1.12.0
|
||||
PikaStdDevice==v1.11.0
|
||||
PikaStdDevice==v2.3.0
|
||||
ESP32==v0.1.0
|
@ -1,8 +0,0 @@
|
||||
file(GLOB_RECURSE SOURCES *.c)
|
||||
idf_component_register(SRCS ${SOURCES}
|
||||
INCLUDE_DIRS "pikascript-api"
|
||||
"pikascript-core"
|
||||
"pikascript-lib/PikaStdLib"
|
||||
"pikascript-lib/PikaStdDevice"
|
||||
"pikascript-lib/ESP32"
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
import PikaStdLib
|
||||
import machine
|
||||
|
||||
print('hello PikaScript!')
|
||||
mem = PikaStdLib.MemChecker()
|
||||
print('mem used max:')
|
||||
mem.max()
|
||||
|
||||
# io1 = machine.GPIO()
|
||||
|
||||
# io1.init()
|
||||
# io1.setPin('P5')
|
||||
# io1.setMode('out')
|
||||
# io1.enable()
|
||||
# io1.high()
|
||||
|
||||
# io2 = machine.GPIO()
|
||||
|
||||
# io2.init()
|
||||
# io2.setPin('P4')
|
||||
# io2.setMode('in')
|
||||
# io2.enable()
|
||||
# a = io2.read()
|
||||
|
||||
# print("OK", a)
|
@ -1,2 +1,8 @@
|
||||
# Embed the server root certificate into the final binary
|
||||
idf_build_get_property(project_dir PROJECT_DIR)
|
||||
idf_component_register(SRCS "main.c"
|
||||
INCLUDE_DIRS "")
|
||||
INCLUDE_DIRS "."
|
||||
EMBED_TXTFILES ${project_dir}/server_certs/ca_cert.pem)
|
||||
# add macro
|
||||
idf_build_set_property(
|
||||
COMPILE_DEFINITIONS "-DPIKA_CONFIG_ENABLE" APPEND)
|
||||
|
@ -1,28 +1,68 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "esp_log.h"
|
||||
#include "pikascript.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/uart.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/task.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
|
||||
char __platform_getchar()
|
||||
{
|
||||
char data = 0xff;
|
||||
do
|
||||
{
|
||||
#include "esp_http_client.h"
|
||||
#include "esp_https_ota.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "pikaScript.h"
|
||||
|
||||
static volatile char gRXC = EOF;
|
||||
static volatile uint8_t gNeedPut = 0;
|
||||
|
||||
char pika_platform_getchar() {
|
||||
gRXC = getc(stdin);
|
||||
while (gRXC == (char)EOF) {
|
||||
gRXC = getc(stdin);
|
||||
/* Replace (fflush(stdout) or printf("\n"))'s function!!! */
|
||||
if (gNeedPut) {
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t EP1_Conf_Reg = 0x00;
|
||||
/* Read USB_SERIAL_JTAG_EP1_CONF_REG (BaseAddr: 0x60043000
|
||||
* Offset: 0x0004) */
|
||||
EP1_Conf_Reg = *((uint32_t*)(0x60043004));
|
||||
|
||||
/* Set 'USB_SERIAL_JTAG_WR_DONE' bit*/
|
||||
EP1_Conf_Reg |= 0x01;
|
||||
|
||||
/* Write USB_SERIAL_JTAG_EP1_CONF_REG Back */
|
||||
*((uint32_t*)(0x60043004)) = EP1_Conf_Reg;
|
||||
|
||||
gNeedPut = 0;
|
||||
#else
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
vTaskDelay(1);
|
||||
data = getchar();
|
||||
} while (data == 0xff);
|
||||
return data;
|
||||
}
|
||||
return gRXC;
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
int pika_platform_putchar(char ch) {
|
||||
putc(ch, stdout);
|
||||
gNeedPut = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
printf("Minimum free heap size: %" PRIu32 " bytes\n",
|
||||
esp_get_minimum_free_heap_size());
|
||||
|
||||
pikaScriptShell(pikaScriptInit());
|
||||
}
|
||||
|
2
bsp/esp32c3/main/pika_config.h
Normal file
2
bsp/esp32c3/main/pika_config.h
Normal file
@ -0,0 +1,2 @@
|
||||
#define PIKA_SHELL_NO_NEWLINE 1
|
||||
#define PIKA_OPTIMIZE PIKA_OPTIMIZE_SPEED
|
2
bsp/esp32c3/make.bat
Normal file
2
bsp/esp32c3/make.bat
Normal file
@ -0,0 +1,2 @@
|
||||
cd components\PikaPython && rust-msc-latest-win10.exe && cd ..\..
|
||||
idf.py build && idf.py flash
|
1626
bsp/esp32c3/sdkconfig
Normal file
1626
bsp/esp32c3/sdkconfig
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
1623
bsp/esp32c3/sdkconfig.old
Normal file
1623
bsp/esp32c3/sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user