Initialize updateReadme
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
build
|
||||
main/build
|
||||
sdkconfig.old
|
||||
*.bak
|
||||
*.old
|
||||
.vscode
|
42
.gitmodules
vendored
Normal file
42
.gitmodules
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
[submodule "esp-idf"]
|
||||
path = esp-idf
|
||||
url = https://github.com/espressif/esp-idf.git
|
||||
[submodule "components/bus-i2c"]
|
||||
path = components/bus-i2c
|
||||
url = https://github.com/Nicolai-Electronics/esp32-component-bus-i2c.git
|
||||
[submodule "components/i2c-bno055"]
|
||||
path = components/i2c-bno055
|
||||
url = https://github.com/Nicolai-Electronics/esp32-component-i2c-bno055.git
|
||||
[submodule "components/spi-ili9341"]
|
||||
path = components/spi-ili9341
|
||||
url = https://github.com/Nicolai-Electronics/esp32-component-spi-ili9341.git
|
||||
[submodule "components/spi-ice40"]
|
||||
path = components/spi-ice40
|
||||
url = https://github.com/Nicolai-Electronics/esp32-component-spi-ice40.git
|
||||
[submodule "components/sdcard"]
|
||||
path = components/sdcard
|
||||
url = https://github.com/Nicolai-Electronics/esp32-component-sdcard.git
|
||||
[submodule "components/pax-graphics"]
|
||||
path = components/pax-graphics
|
||||
url = https://github.com/robotman2412/pax-graphics.git
|
||||
[submodule "components/mch2022-rp2040"]
|
||||
path = components/mch2022-rp2040
|
||||
url = https://github.com/badgeteam/esp32-component-mch2022-rp2040.git
|
||||
[submodule "components/esp32-component-appfs"]
|
||||
path = components/appfs
|
||||
url = https://github.com/badgeteam/esp32-component-appfs.git
|
||||
[submodule "components/ws2812"]
|
||||
path = components/ws2812
|
||||
url = https://github.com/badgeteam/esp32-component-ws2812.git
|
||||
[submodule "components/mch2022-efuse"]
|
||||
path = components/mch2022-efuse
|
||||
url = https://github.com/badgeteam/esp32-component-mch2022-efuse.git
|
||||
[submodule "components/mch2022-bsp"]
|
||||
path = components/mch2022-bsp
|
||||
url = https://github.com/badgeteam/esp32-component-mch2022-bsp.git
|
||||
[submodule "components/pax-codecs"]
|
||||
path = components/pax-codecs
|
||||
url = https://github.com/robotman2412/pax-codecs.git
|
||||
[submodule "main/pax-keyboard"]
|
||||
path = components/pax-keyboard
|
||||
url = https://github.com/robotman2412/pax-keyboard
|
8
CMakeLists.txt
Normal file
8
CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(PROJECT_NAME "MCH2022 launcher")
|
||||
set(PROJECT_VER "0.1")
|
||||
|
||||
project(main)
|
||||
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@@ -0,0 +1,9 @@
|
||||
Copyright 2022 Julian Scheffers
|
||||
Copyright 2022 Jeroen Domburg
|
||||
Copyright 2022 Renze Nicolai
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
Makefile
Normal file
31
Makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
PORT ?= /dev/ttyACM0
|
||||
BUILDDIR ?= build
|
||||
IDF_PATH ?= $(shell pwd)/esp-idf
|
||||
IDF_EXPORT_QUIET ?= 0
|
||||
SHELL := /usr/bin/env bash
|
||||
|
||||
.PHONY: prepare clean build flash erase monitor menuconfig
|
||||
|
||||
all: prepare build
|
||||
|
||||
prepare:
|
||||
git submodule update --init --recursive
|
||||
cd esp-idf; bash install.sh
|
||||
|
||||
clean:
|
||||
rm -rf "$(BUILDDIR)"
|
||||
|
||||
build:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py build
|
||||
|
||||
flash: build
|
||||
source "$(IDF_PATH)/export.sh" && idf.py flash -p $(PORT)
|
||||
|
||||
erase:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py erase-flash -p $(PORT)
|
||||
|
||||
monitor:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py monitor -p $(PORT)
|
||||
|
||||
menuconfig:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py menuconfig
|
33
README.md
Normal file
33
README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# MCH2022 template app
|
||||
|
||||
This repository contains a template app for the MCH2022 badge.
|
||||
|
||||
## License
|
||||
|
||||
The source code contained in this repository is licensed under terms of the MIT license, more information can be found in the LICENSE file.
|
||||
|
||||
Source code included as submodules is licensed separately, please check the following table for details.
|
||||
|
||||
| Submodule | License | Author |
|
||||
|-----------------------------|-----------------------------------|--------------------------------------------------------|
|
||||
| esp-idf | Apache License 2.0 | Espressif Systems (Shanghai) CO LTD |
|
||||
| components/appfs | THE BEER-WARE LICENSE Revision 42 | Jeroen Domburg <jeroen@spritesmods.com> |
|
||||
| components/bus-i2c | MIT | Nicolai Electronics |
|
||||
| components/i2c-bno055 | MIT | Nicolai Electronics |
|
||||
| components/mch2022-rp2040 | MIT | Renze Nicolai |
|
||||
| components/pax-graphics | MIT | Julian Scheffers |
|
||||
| components/pax-keyboard | MIT | Julian Scheffers |
|
||||
| components/sdcard | MIT | Nicolai Electronics |
|
||||
| components/spi-ice40 | MIT | Nicolai Electronics |
|
||||
| components/spi-ili9341 | MIT | Nicolai Electronics |
|
||||
| components/ws2812 | MIT | Unlicense / Public domain |
|
||||
|
||||
## How to make
|
||||
```sh
|
||||
git clone --recursive https://github.com/badgeteam/mch2022-template-app
|
||||
cd mch2022-template-app
|
||||
make prepare
|
||||
make
|
||||
```
|
||||
|
||||
This will produce the `main.bin` file in the `build` folder that contains the compiled application.
|
1
components/appfs
Submodule
1
components/appfs
Submodule
Submodule components/appfs added at 3311e975db
1
components/bus-i2c
Submodule
1
components/bus-i2c
Submodule
Submodule components/bus-i2c added at f775f174c3
5
components/i2c-bme680/CMakeLists.txt
Normal file
5
components/i2c-bme680/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "bme680.c"
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES "bus-i2c"
|
||||
)
|
47
components/i2c-bme680/bme680.c
Normal file
47
components/i2c-bme680/bme680.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Nicolai Electronics
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <sdkconfig.h>
|
||||
#include <esp_log.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
#include <freertos/task.h>
|
||||
#include "bme680.h"
|
||||
#include "managed_i2c.h"
|
||||
|
||||
static const char *TAG = "BME680";
|
||||
|
||||
esp_err_t bme680_check_id(BME680* device) {
|
||||
uint8_t chip_id;
|
||||
esp_err_t res = i2c_read_reg(device->i2c_bus, device->i2c_address, BME680_REG_CHIP_ID, &chip_id, 1);
|
||||
if (res != ESP_OK) return res;
|
||||
if (chip_id != BME680_CHIP_ID) {
|
||||
ESP_LOGE(TAG, "Unexpected chip id value 0x%02X, expected 0x%02X", chip_id, BME680_CHIP_ID);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bme680_reset(BME680* device) {
|
||||
uint8_t value = 0xFF;
|
||||
esp_err_t res = i2c_write_reg_n(device->i2c_bus, device->i2c_address, BME680_REG_RESET, &value, 1);
|
||||
if (res != ESP_OK) return res;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bme680_init(BME680* device) {
|
||||
esp_err_t res = bme680_reset(device);
|
||||
if (res != ESP_OK) return res;
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
res = bme680_check_id(device);
|
||||
if (res != ESP_OK) return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t bme680_deinit(BME680* device) {
|
||||
return bme680_reset(device);
|
||||
}
|
19
components/i2c-bme680/include/bme680.h
Normal file
19
components/i2c-bme680/include/bme680.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <esp_err.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define BME680_REG_RESET 0xE0
|
||||
#define BME680_REG_CHIP_ID 0xD0
|
||||
|
||||
#define BME680_CHIP_ID 0x61
|
||||
|
||||
typedef struct BME680 {
|
||||
int i2c_bus;
|
||||
int i2c_address;
|
||||
} BME680;
|
||||
|
||||
esp_err_t bme680_init(BME680* device);
|
||||
esp_err_t bme680_deinit(BME680* device);
|
||||
esp_err_t bme680_check_id(BME680* device);
|
||||
esp_err_t bme680_reset(BME680* device);
|
1
components/i2c-bno055
Submodule
1
components/i2c-bno055
Submodule
Submodule components/i2c-bno055 added at 0812d28db9
1
components/mch2022-bsp
Submodule
1
components/mch2022-bsp
Submodule
Submodule components/mch2022-bsp added at b4e6038d44
1
components/mch2022-efuse
Submodule
1
components/mch2022-efuse
Submodule
Submodule components/mch2022-efuse added at e45054f561
1
components/mch2022-rp2040
Submodule
1
components/mch2022-rp2040
Submodule
Submodule components/mch2022-rp2040 added at ab002e9d65
1
components/pax-codecs
Submodule
1
components/pax-codecs
Submodule
Submodule components/pax-codecs added at d8a9ad7253
1
components/pax-graphics
Submodule
1
components/pax-graphics
Submodule
Submodule components/pax-graphics added at c2d3451de9
1
components/pax-keyboard
Submodule
1
components/pax-keyboard
Submodule
Submodule components/pax-keyboard added at 78f781d031
1
components/sdcard
Submodule
1
components/sdcard
Submodule
Submodule components/sdcard added at 2b6630e85e
1
components/spi-ice40
Submodule
1
components/spi-ice40
Submodule
Submodule components/spi-ice40 added at abdc7b2350
1
components/spi-ili9341
Submodule
1
components/spi-ili9341
Submodule
Submodule components/spi-ili9341 added at 62f7cef36f
1
components/ws2812
Submodule
1
components/ws2812
Submodule
Submodule components/ws2812 added at c1c750d2ce
1
esp-idf
Submodule
1
esp-idf
Submodule
Submodule esp-idf added at 9f303290d8
41
fpga/fpga.py
Normal file
41
fpga/fpga.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import binascii, serial, time, sys, argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='MCH2022 badge FPGA bitstream programming tool')
|
||||
parser.add_argument("port", help="Serial port")
|
||||
parser.add_argument("bitstream", help="Bitstream binary")
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.bitstream, "rb") as f:
|
||||
bitstream = f.read()
|
||||
|
||||
port = serial.Serial(args.port, 921600, timeout=1)
|
||||
print("Waiting for badge...")
|
||||
while True:
|
||||
data = port.read(4)
|
||||
if (data == b"FPGA"):
|
||||
break
|
||||
port.write(b'FPGA' + (len(bitstream).to_bytes(4, byteorder='little')) + binascii.crc32(bitstream).to_bytes(4, byteorder='little'))
|
||||
time.sleep(0.5)
|
||||
sent = 0
|
||||
print("Sending data", end="")
|
||||
while len(bitstream) - sent > 0:
|
||||
print(".", end="")
|
||||
sys.stdout.flush()
|
||||
txLength = len(bitstream)
|
||||
if txLength > 2048:
|
||||
txLength = 2048
|
||||
port.write(bitstream[sent:sent + txLength])
|
||||
time.sleep(0.05)
|
||||
sent += txLength
|
||||
while port.is_open:
|
||||
inLen = port.in_waiting
|
||||
if inLen > 0:
|
||||
data = port.read(inLen).decode('utf-8','ignore');
|
||||
if data == 'FPGA':
|
||||
print(data)
|
||||
else:
|
||||
print(data, end='')
|
||||
port.close()
|
||||
print("\n")
|
6
main/CMakeLists.txt
Normal file
6
main/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
idf_component_register(
|
||||
SRCS
|
||||
"main.c"
|
||||
INCLUDE_DIRS
|
||||
"." "include"
|
||||
)
|
20
main/include/main.h
Normal file
20
main/include/main.h
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hardware.h"
|
||||
#include "pax_gfx.h"
|
||||
#include "pax_codecs.h"
|
||||
#include "ili9341.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "wifi_connect.h"
|
||||
#include "wifi_connection.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
void disp_flush();
|
||||
void exit_to_launcher();
|
62
main/main.c
Normal file
62
main/main.c
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
// This file contains a simple hello world app which you can base you own apps on.
|
||||
|
||||
#include "main.h"
|
||||
|
||||
static pax_buf_t buf;
|
||||
xQueueHandle buttonQueue;
|
||||
|
||||
static const char *TAG = "mch2022-demo-app";
|
||||
|
||||
void disp_flush() {
|
||||
ili9341_write(get_ili9341(), buf.buf);
|
||||
}
|
||||
|
||||
void exit_to_launcher() {
|
||||
REG_WRITE(RTC_CNTL_STORE0_REG, 0);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
void app_main() {
|
||||
// Init HW.
|
||||
bsp_init();
|
||||
bsp_rp2040_init();
|
||||
buttonQueue = get_rp2040()->queue;
|
||||
|
||||
// Init GFX.
|
||||
pax_buf_init(&buf, NULL, 320, 240, PAX_BUF_16_565RGB);
|
||||
|
||||
// Init NVS.
|
||||
nvs_flash_init();
|
||||
|
||||
// Init (but not connect to) WiFi.
|
||||
wifi_init();
|
||||
|
||||
while (1) {
|
||||
// Pick a random background color.
|
||||
int hue = esp_random() & 255;
|
||||
pax_col_t col = pax_col_hsv(hue, 255 /*saturation*/, 255 /*brighness*/);
|
||||
|
||||
// Show some random color hello world.
|
||||
pax_background(&buf, col);
|
||||
char *text = "Hello, World!";
|
||||
const pax_font_t *font = pax_get_font("saira condensed");
|
||||
pax_vec1_t dims = pax_text_size(font, font->default_size, text);
|
||||
pax_draw_text(
|
||||
&buf, 0xff000000, font, font->default_size,
|
||||
(buf.width - dims.x) / 2.0,
|
||||
(buf.height - dims.y) / 2.0,
|
||||
text
|
||||
);
|
||||
disp_flush();
|
||||
|
||||
// Await any button press and do another cycle.
|
||||
rp2040_input_message_t message;
|
||||
xQueueReceive(buttonQueue, &message, portMAX_DELAY);
|
||||
|
||||
if (message.input == RP2040_INPUT_BUTTON_HOME && message.state) {
|
||||
// If home is pressed, exit to launcher.
|
||||
exit_to_launcher();
|
||||
}
|
||||
}
|
||||
}
|
9
partitions.csv
Normal file
9
partitions.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
# ESP-IDF Partition Table
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0xA000, 12K,
|
||||
otadata, data, ota, 0xD000, 8K,
|
||||
phy_init, data, phy, 0xF000, 4K,
|
||||
ota_0, 0, ota_0, 0x10000, 1600K,
|
||||
ota_1, 0, ota_1, 0x1A0000, 1600K,
|
||||
appfs, 0x43, 3, 0x330000, 8000K,
|
||||
locfd, data, fat, 0xB00000, 5120K,
|
|
BIN
partitions.ods
Normal file
BIN
partitions.ods
Normal file
Binary file not shown.
Reference in New Issue
Block a user