Skip to content

Instantly share code, notes, and snippets.

View hidsh's full-sized avatar

yakshaver hidsh

View GitHub Profile
@hidsh
hidsh / xiao_nrf52840_plus_pinout_issure.md
Last active February 28, 2026 20:44
About the "XIAO nrf52840 PLUS documentation has incorrect pinouts!" on Seeed forum.

About the XIAO nrf52840 PLUS documentation has incorrect pinouts!


No response from Seeed, so I tested the all additional pinout introduced in the Plus by running Blink on my XIAO nRF52840 Plus.

Conclusion

There are two errors. Please refer to the correction proposal diagram below.

pinout_diagram

@hidsh
hidsh / disable_esc_gpg.ahk
Last active November 5, 2025 00:16
ahk script: Disable overlay popup when pressing ESC key from Google Play Games App for Windows
; disable_esc_gpg.ahk
;
; Disable following overlay from Google Play Games App for Windows
; "shift+tabキーを押すと、ゲームを終了する、コントロールを開くなどの操作が行えます。"
#Requires AutoHotkey v2.0
#HotIf WinActive("ahk_exe crosvm.exe")
Esc::Send "^{b}"
^H::return ; ignore C-h to avoid accidentally quitting game app
@hidsh
hidsh / variadic_macro.c
Created August 17, 2025 08:36 — forked from otaon/variadic_macro.c
C言語 - gccで可変長引数マクロを使用する方法
// gccでは...で表した可変長引数を__VA_ARGS__で指定できる
// 可変長引数を全て__VA_ARGS__とマップする
#define DEBUG_PRINT(...) printf(__VA_ARGS__); fflush(stdout)
// fmt以降の可変長引数を__VA_ARGS__とマップする
#define DEBUG_PRINT2(fmt, ...) printf(fmt, __VA_ARGS__); fflush(stdout)
// _1,_2,_3,の部分・・・引数の個数だけ用意する
// NAME・・・この部分に、目的の引数個数用の関数名が入る
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
@hidsh
hidsh / CMakeLists.txt
Created August 16, 2025 06:57
zephyr button w/ "dynamic" pinctrl example for xiao_ble (seeed xiao nrf52840)
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(button)
target_sources(app PRIVATE src/main.c src/remap.c)
@hidsh
hidsh / read_bit_field.c
Created August 15, 2025 05:44
c example to use `FIELD_GET()` macro from zephyr
#include <stdint.h>
#include <stdio.h>
// zephyr-latest/zephyr-proj/zephyr/include/zephyr/sys/util_macro.h
/** @brief Extract the Least Significant Bit from @p value. */
#define LSB_GET(value) ((value) & -(value))
/**
* @brief Extract a bitfield element from @p value corresponding to
@hidsh
hidsh / custom.conf
Created August 13, 2025 15:43
zephyr button w/ "static" pinctrl example for xiao_ble (seeed xiao nrf52840)
# zephyr/samples/basic/button/boards/custom.conf
#
# "static" pinctrl to use external-uart breakout (AE-FT2232 / FTDI FT2232D) as /dev/ttyUSB0
# this file is to switch USB-CDC-ACM (/dev/ttyACM0) --> external uart (/dev/ttyUSB0)
# disable USB CDC ACM
CONFIG_USB_DEVICE_STACK=n
CONFIG_USB_DEVICE_STACK_NEXT=n
CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n
@hidsh
hidsh / xiao_ble.overlay
Created August 12, 2025 15:29
zephyr button example for xiao_ble (seeed xiao nrf52840)
// zephyr/samples/basic/button/boards/xiao_ble.overlay
//
// adopt from zephyr/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts
/{
buttons {
compatible = "gpio-keys";
button0: button_0 {
label = "Push button switch 0";
@hidsh
hidsh / main.c
Created August 7, 2025 10:49
An Arduino-style "Blinky" patching to ZMK firmware (zmk-firmware/zmk/app/src/main.c)
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/settings/settings.h>
@hidsh
hidsh / inline_func.c
Created July 30, 2025 11:12
c example for inline functions
#include <stdio.h>
int fun(int x) { return x * 10; }
// inline int fun_inline(int x) { return x * 100; } // --> causes undefined reference
extern inline int fun_inline(int x) { return x * 100; } // ok
// static inline int fun_inline(int x) { return x * 1000; } // ok, but this .c file local
int main(void) {
printf("%d, %d\n", fun(2), fun_inline(2));
@hidsh
hidsh / define-override-function-inline.c
Created July 30, 2025 10:49
c example to override functions using `#define` macros for inline functions
#include <stdio.h>
int fun0(void) { return 5; }
int fun1(int x) { return x * 10; }
// inline int fun1_inline(int x) { return x * 100; } // => undefined reference
extern inline int fun1_inline_extern(int x) { return x * 100; }
static inline int fun1_inline_static(int x) { return x * 1000; }
#define OVERRIDE 1