Skip to content

Instantly share code, notes, and snippets.

@hexeguitar
hexeguitar / sysclk_test.c
Last active July 15, 2023 21:32
ch32v003 project for testing various clock configurations
/**
* @file sysclk_test.c
* @author Piotr Zapart
* @brief Testing various sysclock configurations for the ch32v003
* LED Pin definition for the NanoCH32V003 board
* Try different conbinations in the funconfig.h file, ie:
*
* #define FUNCONF_USE_HSI 1
* #define FUNCONF_USE_PLL 1
* #define CH32V003 1
@hexeguitar
hexeguitar / ch32v003_i2c.h
Last active November 14, 2023 10:43
Single header file i2c library for ch32v003 - work in progress!
#ifndef _CH32V003_I2C_H
#define _CH32V003_I2C_H
/**
* @file ch32v003_i2c.h
* @author Piotr Zapart (www.hexefx.com)
* @brief i2c driver for the CH32V003 MCU
* @version 0.1
* @date 2023-07-01
*
* 07-2023 - for now only the master and 7 bit address mode is implemented

Using pioasm in platformio projects

Here is somethig you might find useful: automatic pio assembly -> h file generation for platformio.
I have tested it on Linux only.

This is the state as of Nov 2022. The arduino core for RP2040 will most likely change in the future and make this method obsolete.

Step 1:

Contrary to the docs, stating the pioasm is installed together with the dev platform:
https://registry.platformio.org/tools/earlephilhower/tool-pioasm-rp2040-earlephilhower/installation
the json file
https://github.com/maxgerhardt/platform-raspberrypi/blob/develop/platform.json

@hexeguitar
hexeguitar / gpio.h
Last active January 25, 2020 22:45
CH559 pin setup/control macros
#ifndef _GPIO_H
#define _GPIO_H
/**
* CH559 GPIO settings
* An acrobatic macro way to generate functions to setup
* and access pins on Port0 to Port3.
* Not the most flash-wise efficient way, but convinient.
* Usage example:
* Lets make a LED_1 on P10:
@hexeguitar
hexeguitar / vscode_sdcc.h
Last active March 29, 2024 16:22
Trick to avoid sdcc (not supported keywords) errors in VScode
#ifndef _VSCODE_SDCC_H
#define _VSCODE_SDCC_H
/*
There is currently no support for sdcc syntax (Intellisense) in VScode.
These defines will limit the number of reported errors due to undecognized
sdcc keywords like __code, __at etc.
The trick is, when editing the code in VScode, the SDCC is not defined,
it happens only at compile time. So we can use the "#ifndef SDCC" condition
to redefine the sdcc keywords as empty and make the errors go away.
When compiling, the SDCC is defined and the below redefinitions will not be