Added s3 ulp code

This commit is contained in:
Laurence Bank
2024-09-23 12:19:37 +01:00
parent d79046baae
commit f47f3c94ed
7 changed files with 4345 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
# 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.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mini_epaper_s3)
@@ -0,0 +1,27 @@
set(COMPONENT_SRCS "mini_epaper_s3.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES soc nvs_flash ulp driver)
register_component()
#
# ULP support additions to component CMakeLists.txt.
#
# 1. The ULP app name must be unique (if multiple components use ULP).
set(ulp_app_name ulp_${COMPONENT_NAME})
#
# 2. Specify all C and Assembly source files.
# Files should be placed into a separate directory (in this case, ulp/),
# which should not be added to COMPONENT_SRCS.
set(ulp_riscv_sources "ulp/main.c")
#
# 3. List all the component source files which include automatically
# generated ULP export file, ${ulp_app_name}.h:
set(ulp_exp_dep_srcs ${app_sources})
#
# 4. Call function to build ULP binary and embed in project using the argument
# values above.
ulp_embed_binary(${ulp_app_name} "${ulp_riscv_sources}" "${ulp_exp_dep_srcs}")
@@ -0,0 +1,46 @@
#include <stdio.h>
#include "esp_sleep.h"
#include "driver/gpio.h"
#include "driver/rtc_io.h"
#include "ulp_riscv.h"
#include "ulp_main.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end");
static void init_ulp_program(void);
void app_main(void)
{
init_ulp_program();
/* Go to sleep, only the ULP Risc-V will run */
printf("Entering in deep sleep\n\n");
/* 5 second delay to ensure we can reflash from USB */
// vTaskDelay(500);
ESP_ERROR_CHECK( esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON)); // RTC domain must be on or ULP won't work
ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
esp_deep_sleep_start(); // only wake up if the ULP allows!
}
static void init_ulp_program(void)
{
esp_err_t err = ulp_riscv_load_binary(ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start));
ESP_ERROR_CHECK(err);
/* The first argument is the period index, which is not used by the ULP-RISC-V timer
* The second argument is the period in microseconds, which gives a wakeup time period of: 20ms
*/
ulp_set_wakeup_period(0, 5000000); // 5 seconds
/* Start the program */
err = ulp_riscv_run();
ESP_ERROR_CHECK(err);
}
@@ -0,0 +1,37 @@
// Created with image_to_c
// https://github.com/bitbank2/image_to_c
//
// Roboto_Black_20r
// Data size = 404 bytes
//
// for non-Arduino builds...
#ifndef PROGMEM
#define PROGMEM
#endif
const uint8_t Roboto_Black_20r[] PROGMEM = {
0xff,0xbb,0x30,0x00,0x3a,0x00,0x2e,0x00,0x5a,0x00,0x00,0x00,0x00,0x00,0x13,0x17,
0x1c,0x00,0x02,0x00,0xe5,0xff,0x19,0x00,0x0d,0x17,0x1c,0x00,0x03,0x00,0xe5,0xff,
0x23,0x00,0x14,0x17,0x1c,0x00,0x01,0x00,0xe5,0xff,0x3f,0x00,0x14,0x17,0x1c,0x00,
0x01,0x00,0xe5,0xff,0x5f,0x00,0x15,0x17,0x1c,0x00,0x01,0x00,0xe5,0xff,0x77,0x00,
0x13,0x17,0x1c,0x00,0x02,0x00,0xe5,0xff,0x96,0x00,0x14,0x17,0x1c,0x00,0x02,0x00,
0xe5,0xff,0xb4,0x00,0x14,0x17,0x1c,0x00,0x01,0x00,0xe5,0xff,0xcc,0x00,0x13,0x17,
0x1c,0x00,0x02,0x00,0xe5,0xff,0xf0,0x00,0x14,0x17,0x1c,0x00,0x01,0x00,0xe5,0xff,
0x0e,0x01,0x07,0x0c,0x15,0x00,0x02,0x00,0xec,0xff,0x20,0xc7,0x82,0xa1,0x07,0xa7,
0xa7,0xa7,0xf1,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xd2,0xb7,0x7d,0xa6,0x16,0x18,0x41,0x85,0x00,0x28,0x91,0x4b,0x67,0x6a,0xb4,
0xf4,0xf4,0xe4,0xb5,0xeb,0xc9,0xeb,0xd3,0xba,0x72,0x03,0xfd,0xbf,0x6e,0xd7,0x11,
0x5b,0xed,0x6f,0xb5,0x86,0x16,0x0c,0x14,0x20,0x45,0x4d,0x08,0x69,0xa7,0x16,0x9f,
0xfc,0x80,0xa6,0xa0};
+70
View File
@@ -0,0 +1,70 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* ULP-RISC-V example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
This code runs on ULP-RISC-V coprocessor
*/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "ulp_riscv.h"
#include "ulp_riscv_utils.h"
#include "ulp_riscv_gpio.h"
// Tell the bb_epaper library not to include code related to
// drawing with a back buffer for the epaper panel
#define NO_RAM
#include "../../../../src/bb_epaper.h"
#include "../../../s3_ulp_io.inl"
#include "../../../../src/bb_ep.inl"
#include "../../../../src/bb_ep_gfx.inl"
#include "Roboto_Black_20r.h"
BBEPDISP bbep; // the main display structure
static bool gpio_level = false;
// Pinout for the LilyGo mini-epaper S3
#define PIN_BUSY 10
#define PIN_RST 11
#define PIN_DC 12
#define PIN_CS 13
#define PIN_SCK 14
#define PIN_MOSI 15
/* this variable will be exported as a public symbol, visible from main CPU: */
bool gpio_level_previous = false;
int main (void)
{
bbepSetPanelType(&bbep, EPD102_80x128);
bbepInitIO(&bbep, PIN_DC, PIN_RST, PIN_BUSY, PIN_CS, PIN_MOSI, PIN_SCK, 0);
bbepWakeUp(&bbep);
bbepSendCMDSequence(&bbep, bbep.pInitFull);
bbep.iPlane = 1; // clear both buffers to white
bbepRectangle(&bbep, 0, 0, 79, 127, BBEP_WHITE, 1);
bbep.iPlane = 0;
bbepRectangle(&bbep, 0, 0, 79, 127, BBEP_WHITE, 1);
bbepWriteStringCustom(&bbep, (BB_FONT *)Roboto_Black_20r, 48, 4, "12:34", BBEP_BLACK, 0);
bbepRefresh(&bbep, REFRESH_FULL);
bbepWaitBusy(&bbep);
bbepSleep(&bbep, 1);
bbepDeInitIO(&bbep); // release GPIO before going back to sleep
/* Wakes up the main CPU if pin changed its state */
// if(gpio_level != gpio_level_previous) {
// gpio_level_previous = gpio_level;
// ulp_riscv_wakeup_main_processor();
// break;
// }
// }
/* ulp_riscv_halt() is called automatically when main exits */
// ulp_set_wakeup_period(0, 5000000); // period in usec
return 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff