Skip to content

Instantly share code, notes, and snippets.

View ciniml's full-sized avatar
🏠
Working from home

Kenta IDA ciniml

🏠
Working from home
View GitHub Profile
@ciniml
ciniml / Makefile
Created May 4, 2020 02:49
ESP32 Unaligned access compare disassembly
.PHONY: all
XTENSA_PREFIX ?= xtensa-esp32-elf-
XTENSA_BIN ?= $(HOME)/xtensa-esp32-elf/1.22.0-80/bin
CC := $(XTENSA_BIN)/$(XTENSA_PREFIX)gcc
CXX := $(XTENSA_BIN)/$(XTENSA_PREFIX)g++
CC := $(XTENSA_BIN)/$(XTENSA_PREFIX)ld
OBJDUMP := $(XTENSA_BIN)/$(XTENSA_PREFIX)objdump
CXXFLAGS := -g -Os -std=c++11
@ciniml
ciniml / gowin.py
Last active October 21, 2024 16:21
GOWIN SSPI configuration script for M5Stack
import os
import machine
import time
class GowinConfig(object):
def __init__(self, pin_cs:machine.Pin, pin_mode0:machine.Pin, pin_reconfig_n:machine.Pin, pin_ready:machine.Pin, spi:machine.SPI):
self.__pin_cs = pin_cs
self.__pin_mode0 = pin_mode0
self.__pin_reconfig_n = pin_reconfig_n
self.__pin_ready = pin_ready
@ciniml
ciniml / fs2bin.py
Created April 26, 2020 12:19
Convert GOWIN fs to bin file
#!/usr/bin/env python
import sys
input_path = sys.argv[1]
output_path = sys.argv[2]
with open(input_path, 'r') as input_file:
with open(output_path, 'wb') as output_file:
for line in iter(input_file.readline, ''): #type: str
@ciniml
ciniml / overload.hpp
Last active March 16, 2020 17:53
draw_jpg with buffer support
struct JpegDecodeBuffer
{
std::uint8_t body[4096];
};
bool draw_jpg(DataWrapper* data, int16_t x, int16_t y, int16_t maxWidth, int16_t maxHeight, int16_t offX, int16_t offY, jpeg_div_t scale, JpegDecodeBuffer& decodeBuffer)
{
//...
auto jres = jd_prepare(&jpegdec, jpg_read_data, decodeBuffer.body, sz_pool, &jpeg);
//...
@ciniml
ciniml / fixedpoint.hpp
Created February 1, 2020 06:01
simple C++ fixed point type
#ifndef FIXEDPOINT_HPP_
#define FIXEDPOINT_HPP_
#include <stdint.h>
template<typename TBaseIntegral, std::size_t TFractionBits>
class fixedpoint
{
private:
TBaseIntegral value;
@ciniml
ciniml / SerialPort.cs
Created January 26, 2020 06:42
Serial port class for Unity on Linux
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
class SerialPort : IDisposable
{
[DllImport("libc.so.6", EntryPoint="open")]
private static extern int Open(string path, int mode);
@ciniml
ciniml / crashdump
Created January 7, 2020 16:44
M5StickC Crash Dump and Disassembly
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
@ciniml
ciniml / compat.py
Created December 10, 2019 01:47
M5Stick AXP192 compat
class AXPCompat(object):
def __init__(self):
if( hasattr(axp, 'setLDO2Vol') ):
self.setLDO2Vol = axp.setLDO2Vol
else:
self.setLDO2Vol = axp.setLDO2Volt
axp = AXPCompat()
@ciniml
ciniml / wisun.m5b
Last active October 22, 2019 09:45
UIFlow M5StickC Wi-SUN HAT Custom Block
// Block __WiSUN_start
var __WiSUN_start_json = {
"previousStatement": null,
"nextStatement": null,
"message0": "%1",
"args0": [
{
"type": "field_label",
"text": "start"
}
@ciniml
ciniml / imu_sh200q.hpp
Created August 25, 2019 08:34
SH200Q FIFO driver
#ifndef IMU_HPP__
#define IMU_HPP__
#include <cstdint>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/semphr.h>
#include <esp_err.h>
#include <esp_timer.h>