stm32f1/README.md

112 lines
3.4 KiB
Markdown
Raw Permalink Normal View History

2018-10-15 22:06:48 +02:00
This firmware is for the spark strober, using an [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031).
project
=======
summary
-------
2018-10-15 22:06:48 +02:00
The spark strober switches mains electricity.
This allows to switch on a flood light or stroboscope for a short time to create a light pulse.
technology
----------
2018-10-15 22:06:48 +02:00
components:
2016-01-29 12:12:04 +01:00
2019-08-13 23:26:04 +02:00
- [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill), based on a STM32F103C8T6: development board to control everything
2018-10-15 22:06:48 +02:00
- HLK-PM01 power module: 100-240V AC to 5V DC power supply to power the board and other peripherals (protected with a 0.25A glass fuse)
- VS1838b: 38 kHz infrared demodulator to receive the codes from a remote control (connected using a 3.5 mm TRS jack)
- G3MB-202P: compact 240V AC 2A solid state relay to switch mains electricity (protected with a 2A fuse)
2018-10-28 22:28:13 +01:00
- infrared remote control sending NEC codes (low power version salvages from a multimedia player, high power version from Jedi iDual)
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
connections
===========
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
Hi-Link HLK-PM01:
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
- AC: 100-240V AC mains
- +Vo: 5V
- -Vo: ground
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
Omron G3MB-202P:
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
- 1: 100-240V AC mains line input
- 2: 100-240V AC mains line output
- 3: 5V with 330 Ohm resistor
- 4: blue pill, PB6
VS1838b:
- 1, OUT: 3.5 mm TRS jack plug, ring
- 2, GND: ground
- 3, VCC: 5V (with 100 nF decoupling capacitor)
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
3.5 mm TRS jack socket:
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
- tip: 5V
- ring: blue pill, PB8, TIM4_CH3
- sleeve: ground
2018-10-15 22:06:48 +02:00
blue pill:
- PB8, TIM4_CH3: IR demodulator OUT
- PB6: SSR control
- 5V: 5V
- GND: ground
2016-01-29 12:12:04 +01:00
code
====
2016-01-29 12:12:04 +01:00
2018-10-15 22:06:48 +02:00
control
-------
Have a look at the `application.c` *ir_action* to changes the AC on/off switch animations and corresponding remote control code.
dependencies
------------
2016-01-29 12:12:04 +01:00
The source code uses the [libopencm3](http://libopencm3.org/) library.
The projects is already a git submodules.
2017-08-07 23:13:30 +02:00
It will be initialized when compiling the firmware.
Alternatively you can run once: `git submodule init` and `git submodule update`.
2016-01-29 12:12:04 +01:00
firmware
--------
2016-01-29 12:12:04 +01:00
2017-08-07 23:13:30 +02:00
To compile the firmware run `rake`.
2016-01-29 12:12:04 +01:00
documentation
-------------
2017-08-07 23:13:30 +02:00
To generate doxygen documentation run `rake doc`.
2016-01-29 12:12:04 +01:00
flash
-----
2017-04-15 13:58:39 +02:00
There are two firmware images: `bootloader` and `application`.
The `bootloader` image allows to flash the `application` over USB using the DFU protocol.
The `bootloader` is started first and immediately jumps to the `application` if it is valid and the DFU mode is not forced (i.e. by pressing the user button on the board or requesting a DFU detach in the `application`).
2017-08-07 23:13:30 +02:00
The `application` image is the main application and is implemented in `application.c`.
2017-04-15 13:58:39 +02:00
It is up to the application to advertise USB DFU support (i.e. as does the provided USB CDC ACM example).
2017-08-07 23:13:30 +02:00
The `bootlaoder` image will be flashed using SWD (Serial Wire Debug).
For that you need an SWD adapter.
2017-04-03 13:12:18 +02:00
The `Makefile` uses a Black Magic Probe (per default), or a ST-Link V2 along OpenOCD software.
2017-08-07 23:13:30 +02:00
To flash the `booltoader` using SWD run `rake flash_booloader`.
2017-04-15 13:58:39 +02:00
2017-08-07 23:13:30 +02:00
Once the `bootloader` is flashed it is possible to flash the `application` over USB using the DFU protocol by running `rake flash`.
2017-04-15 13:58:39 +02:00
To force the bootloader to start the DFU mode press the user button or short a pin, depending on the board.
2017-08-07 23:13:30 +02:00
It is also possible to flash the `application` image using SWD by running `rake flash_application`.
2016-01-29 12:12:04 +01:00
debug
2016-01-29 12:12:04 +01:00
-----
SWD also allows to debug the code running on the micro-controller using GDB.
2017-08-07 23:13:30 +02:00
To start the debugging session run `rake debug`.
2016-01-29 12:12:04 +01:00
USB
---
The firmware offers serial communication over USART1 and USB (using the CDC ACM device class).