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 / 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 / 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 / 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 / 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 / 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 / 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 / lib.rs
Last active May 14, 2019 20:02
ESP32 Rust Hello World
#![no_std]
#![feature(lang_items, core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;
use core::alloc::{GlobalAlloc, Layout};
use core::fmt;
use core::fmt::Write;
extern {
fn malloc(size: usize) -> *mut u8;
@ciniml
ciniml / Program.cs
Created February 24, 2019 05:07
Enumerate network device ID
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
@ciniml
ciniml / firmware.json
Created February 13, 2019 01:20
M5Burner custom firmware.json
[
{
"name": "M5Stack WiSUN",
"version": "v0.1",
"path": "WiSUN",
"commands": [
"--chip esp32 --port %port --baud %baud --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 %PATH/bootloader.bin 0xf000 %PATH/phy_init_data.bin 0x10000 %PATH/MicroPython.bin 0x8000 %PATH/partitions_mpy.bin 0x1D0000 %PATH/spiffs_image.img"
]
}
]
@ciniml
ciniml / bootstrap.py
Last active December 10, 2018 22:22
MicroPython with FTP server initial bootstrap before configuring Wi-Fi
"""
Setup development environment
"""
import time
import network
import machine
import gc
try: