GithubHelp home page GithubHelp logo

rumpeltux / hc12fw Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 68 KB

Open source replacement firmware for the HC12 board

License: GNU Affero General Public License v3.0

Makefile 4.99% C 90.58% Python 4.43%

hc12fw's Introduction

HC-12 Firmware Base

About

You can use this repository as a base to build your own HC-12 firmware.

The radio protocol is compatible with non-modified HC-12 units.

In particular the following works:

  • AT+FU3 settings (including AT+DEFAULT)
  • setting channel & TX power
  • the four modem rates (5kbs-236kbs) are supported

The following does not yet work:

  • FU-1
  • FU-2 (some efforts have started but are not quite there yet in the fu2-devel branch)

Supported Devices

  • HC12-v2.3 (sometimes identified is v2.4) using the Si4463 radio
  • HC12-v2.6 using the cheaper Si4438 radio (experimental)

Installation

# install required build tools
sudo apt-get install sdcc build-essential
# grab all submodule dependencies
git submodule update --init --recursive
# build the esp-stlink library
make -C swimcat/esp-stlink/lib
# make the esp-stlink functionality availbale
export PYTHONPATH=$PYTHONPATH:swimcat/esp-stlink/python

IMPORTANT: Make sure that your sdcc --version is at least 4.4. There are known compiler bugs in the previous version that will render the firmware non-functional.

To build the module:

  1. (for v2.3/v2.4 only) edit Makefile and update the REVISION variable, then make clean
  2. run make to build the firmware

Flashing

For flashing we use esp-stlink (pull requests for other flash methods are welcome).

To flash your code to the device run make flash. This will flash the code, but pause execution, so that no output is lost.

To read the console output, run swimcat/swimcat.py --continue.

API

See si.h for the available APIs. Notably: sending and receiving radio. radio_rx has to be called after a radio_tx to bring the sender into RX state again.

This is linked against the stm8-arduino library for convenience. All its APIs should also be readily usable.

Demo

The default application (echo_demo.c) implements a simple echo service and showcases a variety of APIs. It sends OpenHC12\r\n on boot and otherwise resends each packet as received.

For a trimmed-down and much simpler example look at range_test_demo.c, which sends packets of decreasing power to an original HC12 receiver.

Restoring the original firmware

For some versions of the chip, you can follow the firmware extraction instructions in https://github.com/rumpeltux/hc12

FW Structure

  • The main application files (e.g. echo_demo.c or range_test_demo.c) make use of stm8-arduino
  • si.c implements the radio interactions.

si.c and other libraries that are unlikely to change are bundled to a separate section of the firmware (static.lib.ihx), so that you don’t need to reflash them all the time during development.

Available GPIO PINs

The following STM8 PINs are available for you to use: A1,A2,A3* B5(SET) D1*,D3,D4,D5(TX),D6(RX)

  • A3: the original FW used this for signaling chip boot readiness
  • D1: SWIM used for programming (already has testport solder pad)

TODO: verify D4 can be used

B5(SET),D5(TX) and D6(RX) already have holes for pin-connectors.
A3,D3 are at the chip’s edge, so their legs are more easily accessible for soldering.

Useful references

hc12fw's People

Contributors

rumpeltux avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.