move main page to README and fix documentation

This commit is contained in:
King Kévin 2016-04-04 19:55:27 +02:00
parent d91507f63e
commit a8b37de546
4 changed files with 111 additions and 123 deletions

View File

@ -879,7 +879,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = README.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing

View File

@ -167,7 +167,7 @@ list: $(BINARY).list
$(Q)grep -o -e " ${LIB}\/[^ ]*\.h" $(<) | sed -e 's/\.h$$/.c/g' -e 's/^/LIB_CSRC +=/' > $(@)
# doxygen documentation
doc: Doxyfile $(CSRC) $(CHDR) $(LIB_CSRC) $(LIB_CHDR)
doc: Doxyfile README.md $(CSRC) $(CHDR) $(LIB_CSRC) $(LIB_CHDR)
$(Q)doxygen $(<)
clean:

189
README.md
View File

@ -1,110 +1,139 @@
this firmware template is designed for development boards based around [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031).
The LED clock is an add-on for round wall clocks.
LEDs need to be attached to the border of the clock.
The micro-controller will then show how much time of the day passed using light.
dependencies
============
project
=======
the source code uses the [libopencm3 library](http://libopencm3.org/), designed for such micro-controllers.
it also uses the [STM32duino-bootloader](https://github.com/rogerclarkmelbourne/STM32duino-bootloader) for easier flashing
summary
-------
both project are already git submodules.
to initialize and get them you just need to run once:
```bash
git submodule init
git submodule update
```
The time will be shown as arc progress bars, instead of hands pointing at the current time.
The hours passed since the beginning of the midday are shown using blue LEDs.
The minutes passed sine the beginning of the hour are shown using green LEDs.
The (gamma corrected) brightness of the last LED shows how much of the hours or minutes has passed.
Whichever progress is higher will be shown on top of the other.
For example if it's 6:45, the first half of the circle will be blue, and an additional quarter will be green.
The seconds passed since the beginning of the minute are shown using a running red LED, similar to the seconds hand.
The red color might be added on top of the blue, or green color, then showing as violet or yellow.
technology
----------
The LEDs are controlled using a [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031) (based on an ARM Cortex-M3 32-bit processor).
The board needs to include a 32.678 kHz oscillator for the Real-Time-Clock (RTC).
Preferably use a [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill) board.
The board needs to be powered by an external 5 V power supply (e.g. using the USB port).
To set the time connect using serial over the USB port (providing the CDC ACM profile) or USART1 port (TX and RX are on pin PA9 and PA10) and enter "time HH:MM:SS".
Optionally connect a 3 V coin battery on the VBAT pin for the RTC to keep the correct time in case the main power supply gets disconnected.
To know the charge of the coin cell connect its positive terminal to ADC channel 1 on pin PA1 through a 10 kOhm resistor.
The voltage of the battery will be shown over serial while the board is booting.
For the LEDs use a 1 meter LED strip with 60 red-green-blue WS2812b LEDs.
Tape the LED strip along the border/edge of the clock.
Ideally the wall clock has a diameter of 32 cm for the 1 m LED strip to completely fit.
Connect the 5 V power rail of the LED strip to the 5 V pin of the board.
Connect the DIN signal line of the LED strip to the MISO pin of the micro-controller on PA6.
SPI is used to efficiently shift out the LED color values to the WS2812b LEDs.
A custom clock is provided for this operation using channel 3 of timer 3 on pin PB0.
Simply connect this clock to the SPI CLK input on pin PA5.
The brightness of LEDs is dependant on the ambient luminosity.
To measure the ambient luminosity a 5528 photo-resistor is used.
Connect one leg of the photo-resistor to ADC channel 0 on pin PA0 and the other to ground.
Connect one leg of a 1 kOhm resistor to ADC channel 0 on pin PA0 and the other to a 3.3 V pin.
If the board does not provide a 32.678 kHz oscillator for the internal RTC it is also possible to use an external RTC such as the Maxim DS1307.
The time is then read over I2C and incremented using the square wave output.
Working example code is under the `DS1307_4096Hz_timer` tag.
board
=====
currently the following development boards are supported:
The current implementation uses a [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill).
The underlying template also supports following board:
- [Maple Mini](http://leaflabs.com/docs/hardware/maple-mini.html), based on a STM32F103CBT6
- [System Board](http://www.aliexpress.com/item/stm32f103c8t6-stm32f103-stm32f1-stm32-system-board-learning-board-evaluation-kit-development-board/2042654667.html), based on a STM32F103C8T6
- [blue pill](http://www.aliexpress.com/item/1pcs-STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-arduino/32478120209.html), based on a STM32F103C8T6
- [System Board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#system_board), based on a STM32F103C8T6
- [blue pill](ihttps://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill), based on a STM32F103C8T6
**you need to define which board you are using in the Makefile**
this is required:
**Which board is used is defined in the Makefile**.
This is required:
- for the linker script to know the memory layout (flash and RAM)
- to flash the corresponding bootloader
- map the user LEDs and buttons provided on the board
flash
=====
code
====
the `Makefile` offers two ways of flashing the firmware on the board:
dependencies
------------
The source code uses the [libopencm3](http://libopencm3.org/) library.
It also uses the [STM32duino-bootloader](https://github.com/rogerclarkmelbourne/STM32duino-bootloader) for easier DFU flashing.
Both projects are already git submodules.
To initialize and get them you just need to run once: `git submodule init` and `git submodule update`.
firmware
--------
To compile the firmware run `make`.
documentation
-------------
To generate doxygen documentation run `make doc`.
flash
-----
The `Makefile` offers two ways of flashing the firmware on the board:
- over the SWD port (Serial Wire Debug)
- using the USB DFU interface (Device Firmware Upgrade)
the default mechanism `make flash` uses DFU.
The default mechanism `make flash` uses DFU.
SWD
---
### SWD
to flash over SWD you need an SWD adapter.
the `Makefile` uses a ST-Link V2, along with the OpenOCD software.
To flash over SWD you need an SWD adapter.
The `Makefile` uses a ST-Link V2, along with the OpenOCD software.
the main firmware will be placed after the bootloader.
thus you first need to flash the bootloader first (see below), else the main firmware will not be started.
to flash the bootloader run `make bootloader`.
The main firmware will be placed after the bootloader.
Thus you first need to flash the bootloader, else the main firmware will not be started.
To flash the bootloader run `make bootloader`.
SWD is nice because it will always work, even if USB is buggy, or the code on the board is stuck.
it also does not require to press on any reset button.
SWD is nice because it will always works, even if USB is buggy or the code on the board is stuck.
It also does not require to press on any reset button.
to flash using SWD run `make flash-swd`
To flash using SWD run `make flash-swd`
SWD also allows you to debug the code running on the micro-controller using GDB.
to start the debugging session use `make debug`.
SWD also allows to debug the code running on the micro-controller using GDB.
To start the debugging session run `make debug`.
DFU
---
### DFU
to flash using DFU you just need to connect the USB port.
when booting the micro-controller will start the STM32duino-bootloader bootloader.
this configures the USB to accept firmware updates.
after a short timeout (<1s) it will start the main firmware.
the main firmware will not be started if the bootloader is missing.
you only have to flash the bootloader once, using the SWD method.
to flash the bootloader run `make bootloader`.
To flash using DFU you just need to connect the USB port.
When booting the micro-controller will start the STM32duino-bootloader bootloader.
This configures the USB to accept firmware updates.
After a short timeout (<1s) it will start the main firmware.
to then flash using DFU run `make flash-dfu`.
this will try to reset the board to start the bootloader.
else you will need to reset the board manually using the reset button.
The main firmware will not be started if the bootloader is missing.
You only have to flash the bootloader once, using the SWD method.
To flash the bootloader run `make bootloader`.
firmware
========
To then flash using DFU run `make flash-dfu` or simply `make flash`.
This will try to reset the board to start the bootloader.
Else you will need to reset the board manually using the reset button.
the firmware provides basic example code for various peripherals.
The firmware also offer serial communication over USB using the CDC ACM device class.
Since the micro-controller first starts the bootloader, it is recognised a DFU device.
To provide the CDC ACM interface the host needs to re-enumerate the USB device.
For this a USB disconnect is simulated by pulling USB D+ low for a short time (in software or using a dedicated circuit).
Then the host will re-enumerate the USB device and see the CDC ACM interface.
to compile the firmware run `make`
button
------
if a button is present on the board, pressing it will toggle the LED.
UART
-----
whatever you send over UART (USART1) will be echoed back (also over USB).
USB
---
the firmware also offer serial communication over USB using the CDC ACM device class.
since the micro-controller first starts the bootloader, it is recognised a DFU device.
to provide the CDC ACM interface the host needs to re-enumerate the USB device.
for this a disconnect disconnect is simulated by pulling USB D+ low for a short time (in software or using a dedicated circuit).
then the host will re-enumerate the USB device and see the CDC ACM interface.
whatever you send over USB (CDC ACM) will be echoed back (also over UART).
additionally you can reset the board by setting the serial width to 5 bits.
this allows to restart the bootloader and flash new firmware using DFU.
to reset the board run `make reset`.
this only works if the USB CDC ACM run correctly and the micro-controller isn't stuck.
documentation
=============
to generate doxygen documentation run `make doc`.
You can also reset the board by setting the serial width to 5 bits.
This allows to restart the bootloader and flash new firmware using DFU.
To reset the board run `make reset`.
This only works if the USB CDC ACM is running correctly and the micro-controller isn't stuck.

41
main.c
View File

@ -16,47 +16,6 @@
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016
* @brief show the time on a LED strip
*
* @mainpage LED clock
* The LED clock is an add-on for round wall clocks.
* LEDs need to be attached to the border of the clock.
* The micro-controller will then show how much time of the day passed using light.
*
* The time will be shown as arc progress bars, instead of hands pointing at the current time.
* The hours passed since the beginning of the midday are shown using blue LEDs.
* The minutes passed sine the beginning of the hour are shown using green LEDs.
* The (gamma corrected) brightness of the last LED shows how much of the hours or minutes has passed.
* Whichever progress is higher will be shown on top of the other.
* For example if it's 6:45, the first half of the circle will be blue, and an additional quarter will be green.
* The seconds passed since the beginning of the minute are shown using a running red LED, similar to the seconds hand.
* The red color might be added on top of the blue, or green color, then showing as violet or yellow.
*
* The LEDs are controlled using a STM32F1XX micro-controller (based on an ARM Cortex-M3 32-bit processor).
* The board needs to include a 32.678 kHz oscillator for the Real-Time-Clock (RTC).
* Preferably use a <a href="https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill">blue pill</a> board.
* The board needs to be powered by an external 5 V power supply (e.g. using the USB port).
* To set the time connect using serial over the USB port (providing the CDC ACM profile) or USART1 port (TX and RX are on pin PA9 and PA10) and enter "time HH:MM:SS".
* Optionally connect a 3 V coin battery on the VBAT pin for the RTC to keep the correct time in case the main power supply gets disconnected.
* To know the charge of the coin cell connect its positive terminal to ADC channel 1 on pin PA1 through a 10 kOhm resistor.
* The voltage of the battery will be shown over serial while the board is booting.
*
* For the LEDs use a 1 meter LED strip with 60 red-green-blue WS2812b LEDs.
* Tape the LED strip along the border/edge of the clock.
* Ideally the wall clock has a diameter of 32 cm for the 1 m LED strip to completely fit.
* Connect the 5 V power rail of the LED strip to the 5 V pin of the board.
* Connect the DIN signal line of the LED strip to the MISO pin of the micro-controller on PA6.
* SPI is used to efficiently shift out the LED color values to the WS2812b LEDs.
* A custom clock is provided for this operation using channel 3 of timer 3 on pin PB0.
* Simply connect this clock to the SPI CLK input on pin PA5.
*
* The brightness of LEDs is dependant on the ambient luminosity.
* To measure the ambient luminosity a 5528 photo-resistor is used.
* Connect one leg of the photo-resistor to ADC channel 0 on pin PA0 and the other to ground.
* Connect one leg of a 1 kOhm resistor to ADC channel 0 on pin PA0 and the other to a 3.3 V pin.
*
* If the board does not provide a 32.678 kHz oscillator for the internal RTC it is also possible to use an external RTC such as the Maxim DS1307.
* The time is then read over I2C and incremented using the square wave output.
* Working example code is under the DS1307_4096Hz_timer tag.
*/
/* standard libraries */