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 / swap_endian.cpp
Created May 30, 2019 20:53
HLS Blackbox Test
#include <hls_stream.h>
#include <ap_int.h>
void swap_endian(hls::stream<ap_uint<32> >& in, hls::stream<ap_uint<32> >& out)
{
ap_uint<32> data;
in >> data;
out << (data.range(7, 0), data.range(15, 8), data.range(23, 16), data.range(31, 24));
}
@ciniml
ciniml / build.rs
Created June 11, 2019 01:30
ESP-IDF Rust Bindgen
extern crate bindgen;
extern crate walkdir;
use std::env;
use std::path::PathBuf;
use walkdir::WalkDir;
fn main() {
let idf_components_path = PathBuf::from(env::var("IDF_PATH").unwrap()).join("components");
let xtensa_toolchain_path = PathBuf::from(env::var("XTENSA_TOOLCHAIN_PATH").unwrap());
@ciniml
ciniml / lib.rs
Created June 11, 2019 21:52
M5Stack Rust Example
#![no_std]
#![feature(lang_items, alloc_error_handler, alloc)]
use core::panic::PanicInfo;
use core::alloc::{GlobalAlloc, Layout};
use core::fmt;
use core::fmt::Write;
use core::convert::From;
use core::ptr;
use core::mem;
use core::str;
@ciniml
ciniml / gsm.py
Created July 8, 2019 18:22
SORACOM 3G Module Sample
import time
import machine
import network
import esp
import usocket
try:
from typing import Tuple, Callable, List, Optional
from builtins import const
except:
@ciniml
ciniml / gist:cf10115dec1dbb3bfc1455452c8b30ca
Created August 15, 2019 06:05
M5StackFire IMU Check on REPL
MicroPython v1.11-127-g71019d174 on 2019-08-02; ESP32 module with ESP32
Type "help()" for more information.
>>>
>>>
>>> import machine
>>> i2c = machine.I2C(1, sda=21, scl=22, speed=400000)
>>> i2c.scan()
[14, 104, 117]
>>> [hex(x) for x in i2c.scan()]
['0xe', '0x68', '0x75']
@ciniml
ciniml / pmu.cpp
Created August 15, 2019 16:31
AXP192 driver with IDF I2C driver
class PMU
{
private:
I2CMaster& i2c;
std::uint8_t address;
static constexpr std::uint8_t AXP192_REG_EXTEN_DCDC2_OUTPUT_CONFIG = 0x10;
static constexpr std::uint8_t AXP192_REG_LDO2_LDO3_OUTPUT_VOLTAGE = 0x28;
@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>
@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 / 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 / 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