Compare commits
247
Commits
v19.0-branch
...
v21.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5196694e42 | ||
|
|
613e454fed | ||
|
|
1943533360 | ||
|
|
8d8a8f06ad | ||
|
|
fac325d423 | ||
|
|
cc0bdc1004 | ||
|
|
daff69550f | ||
|
|
ede29544d2 | ||
|
|
bc61a29bed | ||
|
|
b4483129c2 | ||
|
|
faf3bde214 | ||
|
|
94dc0d9a3f | ||
|
|
b2707067ac | ||
|
|
d2b4eb7f7e | ||
|
|
3f11266838 | ||
|
|
3b68bc1bcc | ||
|
|
5e02ab2292 | ||
|
|
8c7a18662e | ||
|
|
a06f14b63c | ||
|
|
483e09d1a2 | ||
|
|
c87e5f974a | ||
|
|
2bbba0ba13 | ||
|
|
cfeec975c1 | ||
|
|
98c1daa865 | ||
|
|
f8d7b25648 | ||
|
|
01ca3b4f15 | ||
|
|
f6aeaa79db | ||
|
|
6aa015a140 | ||
|
|
fc71934010 | ||
|
|
c151213325 | ||
|
|
a9b0a278ad | ||
|
|
a5c1d46d63 | ||
|
|
35b390ff24 | ||
|
|
269ce762a0 | ||
|
|
ed29e54d20 | ||
|
|
bdf405fb7b | ||
|
|
1b1ed838eb | ||
|
|
2de110b0b7 | ||
|
|
4eaf89154a | ||
|
|
830315cda0 | ||
|
|
24742fefcb | ||
|
|
fec60aacbb | ||
|
|
a352d6b98c | ||
|
|
941545ea7e | ||
|
|
0f109297e4 | ||
|
|
e63a2db9e5 | ||
|
|
bcf54f6698 | ||
|
|
3653b88d25 | ||
|
|
e5b42ace72 | ||
|
|
9ba540ec8c | ||
|
|
755e555611 | ||
|
|
a2ab1ebd45 | ||
|
|
4f4bdc70ae | ||
|
|
76ee3dc28f | ||
|
|
583924a9b9 | ||
|
|
e5e27c10bc | ||
|
|
cb4d4ea1d9 | ||
|
|
47c1614ed0 | ||
|
|
5c3e227928 | ||
|
|
3d9c4589cd | ||
|
|
62d28d9e5e | ||
|
|
b63cdaa06d | ||
|
|
0756341b29 | ||
|
|
7cd89bc04a | ||
|
|
1a29aa1a6e | ||
|
|
1e64c253ac | ||
|
|
1e71ed043e | ||
|
|
42759947f8 | ||
|
|
c6709f8f00 | ||
|
|
75e2969274 | ||
|
|
213e2e30b6 | ||
|
|
b40a419e3e | ||
|
|
62338711bc | ||
|
|
db9c9c5b1c | ||
|
|
c38f1c8348 | ||
|
|
a65bcfe3c2 | ||
|
|
06499a2409 | ||
|
|
bb39ff6236 | ||
|
|
9d09f1431b | ||
|
|
ef9c8571cc | ||
|
|
4008a09f3b | ||
|
|
3bb4a86b5c | ||
|
|
16c629ed86 | ||
|
|
1356de230f | ||
|
|
716fb367a8 | ||
|
|
073c04967a | ||
|
|
f55b236a56 | ||
|
|
d274ca6980 | ||
|
|
314075545a | ||
|
|
6be4e20f04 | ||
|
|
ab63204adb | ||
|
|
5b024dcd60 | ||
|
|
b110918797 | ||
|
|
5e5f2c6680 | ||
|
|
c78c5431a4 | ||
|
|
3aada5dbcc | ||
|
|
d2e833716a | ||
|
|
c8fa15a860 | ||
|
|
e427b45352 | ||
|
|
ee5846323f | ||
|
|
176af4188f | ||
|
|
445359c3b5 | ||
|
|
8f96343cf1 | ||
|
|
bbd1312fe5 | ||
|
|
dc85b46477 | ||
|
|
01650917fd | ||
|
|
79ba9006e7 | ||
|
|
5e213fdfb1 | ||
|
|
c2ef955a63 | ||
|
|
8e06357a7d | ||
|
|
70baedf95d | ||
|
|
3b486f3193 | ||
|
|
ed374e8e99 | ||
|
|
dc4576c8b4 | ||
|
|
27cdcb3bf6 | ||
|
|
a584904470 | ||
|
|
b8fe6d7023 | ||
|
|
3012501358 | ||
|
|
6316dcd57f | ||
|
|
7dfcac4037 | ||
|
|
7af7d1c4ee | ||
|
|
3fcd27cdba | ||
|
|
8a28d8bc22 | ||
|
|
705abbed6b | ||
|
|
2a3e50f6ca | ||
|
|
a7f4ccaa91 | ||
|
|
d283436747 | ||
|
|
1b6c56d25b | ||
|
|
3c9a6e49f1 | ||
|
|
1dc5cdd7ef | ||
|
|
54bc5eaee8 | ||
|
|
3185ff32a1 | ||
|
|
a768f059a1 | ||
|
|
9f02287a03 | ||
|
|
fb3251b88a | ||
|
|
fc0276e72c | ||
|
|
2875ea1519 | ||
|
|
3eb70e9a01 | ||
|
|
dfde83d8be | ||
|
|
b288ffdf35 | ||
|
|
a6c0eecf20 | ||
|
|
7769e4063c | ||
|
|
0e5e2f89b1 | ||
|
|
cfed3ed6e9 | ||
|
|
81aefff168 | ||
|
|
882f281333 | ||
|
|
1bd8734a2e | ||
|
|
9a5004e81d | ||
|
|
faf19ee9e0 | ||
|
|
e1c7f97f63 | ||
|
|
d292ad425a | ||
|
|
3d4da66955 | ||
|
|
efc0bc8fdc | ||
|
|
7da96abbe4 | ||
|
|
f2c063b291 | ||
|
|
5e94d72117 | ||
|
|
4011370646 | ||
|
|
e76709f2af | ||
|
|
9f258b6e69 | ||
|
|
c856b28082 | ||
|
|
6f490df537 | ||
|
|
9787397708 | ||
|
|
8380b928df | ||
|
|
a412117b5b | ||
|
|
4a70293375 | ||
|
|
8dd576e40e | ||
|
|
ce7f63b888 | ||
|
|
90c1e7fcf5 | ||
|
|
2d3594d254 | ||
|
|
1252a1ffa1 | ||
|
|
d2dd50fe99 | ||
|
|
5523f93544 | ||
|
|
affaa9d8e8 | ||
|
|
4e6f6c7365 | ||
|
|
38125f3da3 | ||
|
|
ab504e3dfa | ||
|
|
64b771cd42 | ||
|
|
c25640b987 | ||
|
|
9efa2f8f77 | ||
|
|
2a71d02aeb | ||
|
|
2d74a3a554 | ||
|
|
2c2e59c072 | ||
|
|
91d4ec4424 | ||
|
|
84f7a4afdd | ||
|
|
daf43fb967 | ||
|
|
1a9c290485 | ||
|
|
651f66616b | ||
|
|
a20644f145 | ||
|
|
0e918e6b2e | ||
|
|
7722f12a0c | ||
|
|
46630f88cb | ||
|
|
8307314000 | ||
|
|
2154a1cb72 | ||
|
|
fa9d15e796 | ||
|
|
3c0bc41164 | ||
|
|
d40dafd8d9 | ||
|
|
8539fa3557 | ||
|
|
0c20545f88 | ||
|
|
6af8e6d93d | ||
|
|
cdb9183c11 | ||
|
|
68e0336279 | ||
|
|
b717dea6d1 | ||
|
|
30968e471c | ||
|
|
08974169ab | ||
|
|
c4d4372953 | ||
|
|
9b2162b12e | ||
|
|
14249492a3 | ||
|
|
5f1d76ef74 | ||
|
|
7940acccf4 | ||
|
|
5dda805dab | ||
|
|
43f90eea7c | ||
|
|
a7d6dbc3b5 | ||
|
|
f0e99cd80f | ||
|
|
86bfce8a0c | ||
|
|
20fbefc19b | ||
|
|
c31f8d5014 | ||
|
|
83d7c36778 | ||
|
|
3a8103457f | ||
|
|
1b6a7f82d7 | ||
|
|
e078b87553 | ||
|
|
81c0764f2c | ||
|
|
8c3a6b7160 | ||
|
|
eed8c9114c | ||
|
|
c04081fc8a | ||
|
|
05292c12ba | ||
|
|
dc394cc198 | ||
|
|
a457c2cc9b | ||
|
|
24f751b2e5 | ||
|
|
d5ce578aeb | ||
|
|
64bd1930b0 | ||
|
|
f830389c33 | ||
|
|
41b4607cc7 | ||
|
|
69747a588d | ||
|
|
10f7d44bdf | ||
|
|
d5ea6b5653 | ||
|
|
0c01c3d013 | ||
|
|
a76b92c27b | ||
|
|
632eb5a4f7 | ||
|
|
27bb53bbeb | ||
|
|
cb988639ce | ||
|
|
04f0d42970 | ||
|
|
90f4c9af00 | ||
|
|
e1915ab501 | ||
|
|
16ca793bb3 | ||
|
|
7bd9bdeafd | ||
|
|
d654324860 | ||
|
|
7f4aaf97c3 |
+1
-4
@@ -3,13 +3,10 @@
|
||||
.gcc-flags.json
|
||||
.vscode/browse.vc.db*
|
||||
.vscode
|
||||
src/config.cpp
|
||||
src/config.h
|
||||
src/version.h
|
||||
.west
|
||||
html
|
||||
memory.map
|
||||
custom.ini
|
||||
zephyr/build
|
||||
tools
|
||||
*.bak
|
||||
*_bak
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[submodule "lib/thingset"]
|
||||
path = lib/thingset
|
||||
url = https://github.com/LibreSolar/thingset-device-library
|
||||
[submodule "lib/oled-display"]
|
||||
path = lib/oled-display
|
||||
url = https://github.com/LibreSolar/oled-display-library
|
||||
+7
-6
@@ -10,7 +10,9 @@ env:
|
||||
- PLATFORMIO_CI_SRC=src
|
||||
|
||||
install:
|
||||
- pip install wheel
|
||||
- pip install -U platformio
|
||||
- platformio platform install native
|
||||
- platformio update
|
||||
|
||||
addons:
|
||||
@@ -20,11 +22,10 @@ addons:
|
||||
|
||||
script:
|
||||
# check for trailing white spaces (comparing with first commit in git log)
|
||||
- git diff --check `git rev-list HEAD | tail -n 1`..$TRAVIS_BRANCH
|
||||
- cp src/config.h_template src/config.h
|
||||
- platformio run -e mppt-2420-lc-v0.10 -e mppt-1210-hus-v0.7 -e pwm-2420-lus-v0.3
|
||||
- platformio test -e unit-test-native
|
||||
- platformio check -e mppt-1210-hus-v0.7 -e pwm-2420-lus-v0.3
|
||||
- git diff --check `git rev-list HEAD | tail -n 1`..
|
||||
- platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
|
||||
- platformio test -e unit_test
|
||||
- platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
|
||||
- doxygen Doxyfile
|
||||
|
||||
deploy:
|
||||
@@ -34,4 +35,4 @@ deploy:
|
||||
github_token: $GH_REPO_TOKEN
|
||||
on:
|
||||
repo: LibreSolar/charge-controller-firmware
|
||||
branch: master
|
||||
branch: main
|
||||
|
||||
@@ -2094,7 +2094,7 @@ PERLMOD_MAKEVAR_PREFIX =
|
||||
# C-preprocessor directives found in the sources and include files.
|
||||
# The default value is: YES.
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
ENABLE_PREPROCESSING = NO
|
||||
|
||||
# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
|
||||
# in the source code. If set to NO, only conditional compilation will be
|
||||
|
||||
@@ -1,63 +1,191 @@
|
||||
# Libre Solar Charge Controller Firmware
|
||||
|
||||

|
||||

|
||||
|
||||
This repository contains the firmware for the different Libre Solar Charge Controllers. Originally, the firmware was based on [ARM Mbed OS](https://www.mbed.com). The current version also supports using [Zephyr RTOS](https://www.zephyrproject.org/) for some boards.
|
||||
This repository contains the firmware for the different Libre Solar Charge Controllers based on [Zephyr RTOS](https://www.zephyrproject.org/).
|
||||
|
||||
Coding style is described [here](https://libre.solar/docs/coding_style/).
|
||||
Coding style is described [here](https://github.com/LibreSolar/coding-style).
|
||||
|
||||
## Development and release model
|
||||
|
||||
The `main` branch contains the latest release of the firmware plus some cherry-picked bug-fixes. So you can always pull this branch to get a stable and working firmware for your charge controller.
|
||||
|
||||
New features are developed in the `develop` branch and merged into `main` after passing tests with multiple boards. The `develop` branch is changed frequently and may even be rebased to fix previous commits. Use this branch only if you want to try out most recent features and be aware that something might be broken.
|
||||
|
||||
Releases are generated from `main` after significant changes have been made. The year is used as the major version number. The minor version number starts at zero and is increased for each release in that year.
|
||||
|
||||
## Supported devices
|
||||
|
||||
The software is configurable to support different charge controller PCBs with either STM32F072 (including CAN support) or low-power STM32L072/3 MCUs.
|
||||
The software is configurable to support different charge controller PCBs with STM32F072, low-power STM32L072 or most recent STM32G431 MCUs:
|
||||
|
||||
- [Libre Solar MPPT 12/24V 20A with CAN](https://github.com/LibreSolar/MPPT-2420-LC)
|
||||
- [Libre Solar MPPT 12V 10A with USB](https://github.com/LibreSolar/MPPT-1210-HUS)
|
||||
- [Libre Solar PWM 12/24V 20A](https://github.com/LibreSolar/PWM-2420-LUS)
|
||||
| Board | Default revision | Older revisions |
|
||||
|-----------------------------------------------------|------------------|-----------------|
|
||||
| [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) | 0.2 | 0.1 |
|
||||
| [Libre Solar MPPT 2420 LC](https://github.com/LibreSolar/mppt-2420-lc) | 0.10 | |
|
||||
| [Libre Solar MPPT 1210 HUS](https://github.com/LibreSolar/mppt-1210-hus) | 0.7 | 0.4 |
|
||||
| [Libre Solar PWM 2420 LUS](https://github.com/LibreSolar/pwm-2420-lus) | 0.3 | 0.2 |
|
||||
|
||||
## Building and flashing the firmware
|
||||
|
||||
### ARM Mbed OS
|
||||
This repository contains git submodules, so you need to clone (download) it by calling:
|
||||
|
||||
```
|
||||
git clone --recursive https://github.com/LibreSolar/charge-controller-firmware
|
||||
```
|
||||
|
||||
Unfortunately, the green GitHub "Clone or download" button does not include submodules. If you cloned the repository already and want to pull the submodules, run `git submodule update --init --recursive`.
|
||||
|
||||
### PlatformIO
|
||||
|
||||
It is suggested to use Visual Studio Code and PlatformIO for firmware development, as it simplifies compiling and uploading the code a lot:
|
||||
|
||||
1. Install Visual Studio Code and [PlatformIO](https://platformio.org/platformio-ide) to build the firmware.
|
||||
|
||||
2. Copy `src/config.h_template` to `src/config.h`, and adjust basic settings. `config.h` is ignored by git, so your changes are kept after software updates using `git pull`.
|
||||
2. Adjust configuration in `zephyr/prj.conf` if necessary.
|
||||
|
||||
3. Select the correct board in `platformio.ini` by removing the comment before the board name under `[platformio]` or create a file `custom.ini` with your personal settings.
|
||||
3. Select the correct board in `platformio.ini` by removing the comment before the board name under `[platformio]` or create a file `custom.ini` with your personal settings. PlatformIO is configured for latest revision of the boards (see table above). For older revisions adjust `platformio.ini` and the `.json` files in `boards` folder manually or use native Zephyr environment.
|
||||
|
||||
4. Connect the board via a programmer. See the Libre Solar website for [further project-agnostic instructions](http://libre.solar/docs/flashing).
|
||||
|
||||
5. Press the upload button at the bottom left corner in VS Code.
|
||||
|
||||
### Zephyr
|
||||
### Native Zephyr environment
|
||||
|
||||
Support for Zephyr was recently [included in PlatformIO](https://github.com/platformio/platformio-core/issues/1613) and is currently in beta status. In order to try it out, install the developer version of PlatformIO and run update to get also the development version of the `ststm32` package:
|
||||
You can also use the Zephyr build system directly for advanced configuration with `menuconfig` or if you need more recently added features.
|
||||
|
||||
This guide assumes you have already installed the Zephyr SDK and the west tool according to the [Zephyr documentation](https://docs.zephyrproject.org/latest/getting_started/). Also make sure that `west` is at least at version `0.8.0`.
|
||||
|
||||
Now after you cloned the repository (see above), go into the root firmware directory and initialize a west workspace:
|
||||
|
||||
west init -l zephyr
|
||||
|
||||
This command will create a `.west/config` file and set up the repository as specified in `zephyr/west.yml` file. Afterwards the following command pulls the Zephyr source and all necessary modules, which might take a while:
|
||||
|
||||
west update
|
||||
|
||||
The CMake entry point is in the `zephyr` subfolder, so you need to run `west build` and `west flash` command in that directory.
|
||||
|
||||
cd zephyr
|
||||
|
||||
Initial board selection (see `boards` subfolder for correct names):
|
||||
|
||||
west build -b <board-name>@<revision>
|
||||
|
||||
The appended `@<revision>` specifies the board version according to the above table. It can be omitted if only a single board revision is available or if the default (most recent) version should be used. See also [here](https://docs.zephyrproject.org/latest/application/index.html#application-board-version) for more details regarding board revision handling in Zephyr.
|
||||
|
||||
Flash with specific debug probe (runner), e.g. J-Link:
|
||||
|
||||
west flash -r jlink
|
||||
|
||||
User configuration using menuconfig:
|
||||
|
||||
west build -t menuconfig
|
||||
|
||||
Report of used memory (RAM and flash):
|
||||
|
||||
west build -t rom_report
|
||||
west build -t ram_report
|
||||
|
||||
## Firmware customization
|
||||
|
||||
This firmware is developed to allow easy customization for individual use-cases. Below options based on the Zephyr devicetree and Kconfig systems try to allow customization without changing any of the files tracked by git, so that a `git pull` does not lead to conflicts with local changes.
|
||||
|
||||
### Hardware-specific changes
|
||||
|
||||
In Zephyr, all hardware-specific configuration is described in the [devicetree](https://docs.zephyrproject.org/latest/guides/dts/index.html).
|
||||
|
||||
The file `boards/arm/board_name/board_name.dts` contains the default devicetree specification (DTS) for a board. It is based on the DTS of the used MCU, which is included from the main Zephyr repository.
|
||||
|
||||
In order to overwrite the default devicetree specification, so-called overlays can be used. An overlay file can be specified via the west command line. If it is stored as `board_name.overlay` in the `zephyr` subfolder, it will be recognized automatically when building the firmware for that board (also with PlatformIO).
|
||||
|
||||
### Application firmware configuration
|
||||
|
||||
For configuration of the application-specific features, Zephyr uses the [Kconfig system](https://docs.zephyrproject.org/latest/guides/kconfig/index.html).
|
||||
|
||||
The configuration can be changed using `west build -t menuconfig` command or manually by changing the prj.conf file (see `Kconfig` file for possible options).
|
||||
|
||||
Similar to DTS overlays, Kconfig can also be customized per board. Create a folder `zephyr/boards` and a file `board_name.conf` in that folder. The configuration from this file will be merged with the `prj.conf` automatically.
|
||||
|
||||
#### Change the battery type
|
||||
|
||||
By default, the charge controller is configured for maintainance-free VRLA gel battery (`CONFIG_BAT_TYPE_GEL`). Possible other pre-defined options are `CONFIG_BAT_TYPE_FLOODED`, `CONFIG_BAT_TYPE_AGM`, `CONFIG_BAT_TYPE_LFP`, `CONFIG_BAT_TYPE_NMC` and `CONFIG_BAT_TYPE_NMC_HV`.
|
||||
|
||||
The number of cells is automatically selected by Kconfig to get 12V nominal voltage. It can also be manually specified via `CONFIG_BAT_NUM_CELLS`.
|
||||
|
||||
To compile the firmware with default settings for 12V LiFePO4 batteries, add the following to `prj.conf` or the board-specific `.conf` file:
|
||||
|
||||
```
|
||||
platformio upgrade --dev
|
||||
platformio update
|
||||
CONFIG_BAT_TYPE_LFP=y
|
||||
CONFIG_BAT_NUM_CELLS=4
|
||||
```
|
||||
|
||||
Now you should be able to compile and flash Zephyr for supported boards (-zephyr suffix in platformio.ini) in the same way as explained above for Mbed.
|
||||
#### Configure serial for ThingSet protocol
|
||||
|
||||
As the build system in PlatformIO is not the same as the native Zephyr build system, there might still be some issues. Generally, also `west build` should work if called from within the zephyr subdirectory.
|
||||
By default, the charge controller uses the serial interface in the UEXT connector for the [ThingSet protocol](https://libre.solar/thingset/). This allows to use WiFi modules with ESP32 without any firmware change.
|
||||
|
||||
### Troubleshooting
|
||||
Add the following configuration if you prefer to use the serial of the LS.one port or the additional debug RX/TX pins present on most boards:
|
||||
|
||||
#### Errors with STM32L072 MCU using OpenOCD
|
||||
```
|
||||
CONFIG_UEXT_SERIAL_THINGSET=n
|
||||
```
|
||||
|
||||
To disable regular data publication in one-second interval on ThingSet serial at startup add the following configuration:
|
||||
|
||||
```
|
||||
CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
|
||||
```
|
||||
|
||||
### Custom functions (separate C/C++ files)
|
||||
|
||||
If you want experiment with some completely new functions for the charge controller, new files should be stored in a subfolder `src/custom`.
|
||||
|
||||
To add the files to the firmware build, create an own CMakeLists.txt in the folder and enable the Kconfig option `CONFIG_CUSTOMIZATION`.
|
||||
|
||||
If you think the customization could be relevant for others, please consider sending a pull request. Integrating features into the upstream charge controller firmware guarantees that the feature stays up-to-date and that it will not accidentally break after changes in the original firmware.
|
||||
|
||||
## API documentation
|
||||
|
||||
The documentation auto-generated by Doxygen can be found [here](https://libre.solar/charge-controller-firmware/).
|
||||
|
||||
## Conformance testing
|
||||
|
||||
We are using Travis CI to perform several checks for each commit or pull-request. In order to run
|
||||
the same tests locally (recommended before pushing to the server) use the script `check.sh` or ` check.bat`:
|
||||
|
||||
bash check.sh # Linux
|
||||
cmd check.bat # Windows
|
||||
|
||||
### Unit-tests
|
||||
|
||||
Core functions of the firmware are covered by unit-tests (located in test directory). Run the tests with the following command:
|
||||
|
||||
platformio test -e unit_test
|
||||
|
||||
### Static code analysis
|
||||
|
||||
PlatformIO integrates cppcheck and clangtidy. The following command is an example to run the checks for MPPT 1210 HUS charge controller code:
|
||||
|
||||
platformio check -e mppt_1210_hus
|
||||
|
||||
## Additional firmware documentation (docs folder)
|
||||
|
||||
- [Charge controller basic concepts](docs/charger-concepts.md)
|
||||
|
||||
- [Firmware module overview](docs/module-overview.md)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Errors with STM32L072 MCU using OpenOCD
|
||||
|
||||
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the MPPT 1210 HUS and the PWM charge controller.
|
||||
|
||||
Try one of these workarounds:
|
||||
|
||||
1. Change OpenOCD settings to `set WORKAREASIZE 0x1000` in the file `~/.platformio/packages/tool-openocd/scripts/board/st_nucleo_l073rz.cfg`.
|
||||
1. Change OpenOCD settings to `adapter_khz 500` in line 70 in `~/.platformio/packages/tool-openocd/scripts/target/stm32l0.cfg`.
|
||||
|
||||
2. Use ST-Link tools. For Windows there is a GUI tool. Under Linux, uncomment the `upload_command` line in `platformio.ini`.
|
||||
2. Use other tools or debug probes such as [STM32CubeProgrammer](https://www.st.com/en/development-tools/stm32cubeprog.html) or [Segger J-Link](https://www.segger.com/products/debug-probes/j-link/).
|
||||
|
||||
3. Use other debuggers and tools, e.g. Segger J-Link.
|
||||
|
||||
#### Connection failures
|
||||
### Connection failures
|
||||
|
||||
If flashing fails like this in PlatformIO:
|
||||
|
||||
@@ -78,35 +206,3 @@ st-flash 1.5.1
|
||||
```
|
||||
|
||||
check the connection between the programmer (for example the ST-Link of the Nucleo board) and the charge controller.
|
||||
|
||||
## Bootloader Support (STM32L07x only)
|
||||
|
||||
The custom linker script file STM32L073XZ.ld.link_script.ld needs to be updated before generating the application firmware binary. For each application, the flash start address and the maximum code size need to be updated in this file. Currently, the locations 0x08001000 and 0x08018000 are used for applications 1 & 2 respectively.
|
||||
|
||||
## API documentation
|
||||
|
||||
The documentation auto-generated by Doxygen can be found [here](https://libre.solar/charge-controller-firmware/).
|
||||
|
||||
## Conformance testing
|
||||
|
||||
We are using Travis CI to perform several checks for each commit or pull-request. In order to run
|
||||
the same tests locally (recommended before each pull-request) use the script `check.sh`:
|
||||
|
||||
bash check.sh
|
||||
|
||||
### Unit-tests
|
||||
|
||||
In order to run the unit tests, you need a PlatformIO Plus account. Run tests with the following command:
|
||||
|
||||
platformio test -e unit-test-native
|
||||
|
||||
### Static code analysis
|
||||
|
||||
PlatformIO integrates cppcheck and clangtidy. The following command is an example to run the checks for MPPT 1210 HUS charge controller code:
|
||||
|
||||
platformio check -e mppt-1210-hus-v0.7
|
||||
|
||||
## Additional firmware documentation (docs folder)
|
||||
|
||||
- [MPPT charger firmware details](docs/firmware.md)
|
||||
- [Charger state machine](docs/charger.md)
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08018000, LENGTH = 94k
|
||||
RAM (rwx) : ORIGIN = 0x200000C0, LENGTH = 20K - 0xC0
|
||||
}
|
||||
ENTRY(Reset_Handler)
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*)
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
*(.rodata*)
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
__etext = .;
|
||||
_sidata = .;
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
_sdata = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
. = ALIGN(8);
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
. = ALIGN(8);
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
. = ALIGN(8);
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(8);
|
||||
__data_end__ = .;
|
||||
_edata = .;
|
||||
} > RAM
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__bss_start__ = .;
|
||||
_sbss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(8);
|
||||
__bss_end__ = .;
|
||||
_ebss = .;
|
||||
} > RAM
|
||||
.heap (COPY):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > RAM
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
_estack = __StackTop;
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Configuration of supported boards
|
||||
|
||||
## Zephyr board definition
|
||||
|
||||
The definitions found in `boards/arm/my-board/` folders are used directly by Zephyr.
|
||||
|
||||
More detiails can be found in Zephyr
|
||||
[porting guide](https://docs.zephyrproject.org/latest/guides/porting/board_porting.html) and
|
||||
[Kconfig description](https://docs.zephyrproject.org/latest/guides/kconfig/setting.html#the-initial-configuration).
|
||||
|
||||
- `board.cmake`, `CMakeLists.txt`: CMake definitions for board, normally don't need to be touched.
|
||||
- `Kconfig.board`: Defines the name of the board as used in DTS config.
|
||||
- `Kconfig.defconfig`: Configuration of invisible Kconfig symbols, i.e. symbols that should not be adjustable by the user via menuconfig.
|
||||
- `<BOARD>_defconfig`: Default configuration of the board (can be overwritten by prj.conf)
|
||||
- `<BOARD>.dts`: Main board device tree specification.
|
||||
- `<BOARD>.yaml`:
|
||||
- `pinmux.c`: Defines which pins should be used for peripherals like SPI1, SPI2, SPI3 if selected by the user.
|
||||
|
||||
## PlatformIO configuration
|
||||
|
||||
PlatformIO needs an additional definition file for each board. It is stored as `boards/my-board.json`
|
||||
@@ -1,7 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_PINMUX)
|
||||
zephyr_library()
|
||||
zephyr_library_sources(pinmux.c)
|
||||
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
|
||||
endif()
|
||||
@@ -1,10 +0,0 @@
|
||||
# Kconfig - Libre Solar MPPT 1210 HUS v0.4
|
||||
#
|
||||
# Copyright (c) 2019 Martin Jäger (Libre Solar)
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
config BOARD_MPPT1210HUS_0V4
|
||||
bool "Libre Solar MPPT 1210 HUS v0.4"
|
||||
depends on SOC_STM32L073XX
|
||||
@@ -1,37 +0,0 @@
|
||||
# Kconfig - Libre Solar MPPT 1210 HUS v0.4
|
||||
#
|
||||
# Copyright (c) 2019 Martin Jäger (Libre Solar)
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if BOARD_MPPT1210HUS_0V4
|
||||
|
||||
config BOARD
|
||||
default "mppt1210hus_0v4"
|
||||
|
||||
if UART_CONSOLE
|
||||
|
||||
config UART_2
|
||||
default y
|
||||
|
||||
endif # UART_CONSOLE
|
||||
|
||||
if I2C
|
||||
|
||||
config I2C_1
|
||||
default y
|
||||
|
||||
endif # I2C
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_1
|
||||
default y
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT1210HUS_0V4
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Martin Jäger (Libre Solar)
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/l0/stm32l073Xz.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 1210 HUS v0.4";
|
||||
compatible = "st,stm32l073rz-nucleo", "st,stm32l073";
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
led_pin_gnd: led_gnd {
|
||||
gpios = <&gpiob 14 GPIO_INT_ACTIVE_LOW>;
|
||||
label = "LED GND";
|
||||
};
|
||||
led_pin_soc12: led_soc12 {
|
||||
gpios = <&gpiob 13 GPIO_INT_ACTIVE_HIGH>;
|
||||
label = "LED SOC12";
|
||||
};
|
||||
led_pin_soc3: led_soc3 {
|
||||
gpios = <&gpiob 2 GPIO_INT_ACTIVE_HIGH>;
|
||||
label = "LED SOC3";
|
||||
};
|
||||
led_pin_rxtx: led_rxtx {
|
||||
gpios = <&gpiob 11 GPIO_INT_ACTIVE_HIGH>;
|
||||
label = "LED RXTX";
|
||||
};
|
||||
led_pin_load: led_load {
|
||||
gpios = <&gpiob 10 GPIO_INT_ACTIVE_HIGH>;
|
||||
label = "LED Load";
|
||||
};
|
||||
pin_usb_pwr_en: tmp_usb_pwr_en {
|
||||
gpios = <&gpiob 12 GPIO_INT_ACTIVE_HIGH>;
|
||||
label = "USB power enable";
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
led-a = &led_pin_gnd;
|
||||
led-b = &led_pin_soc12;
|
||||
led-c = &led_pin_soc3;
|
||||
led-d = &led_pin_rxtx;
|
||||
led-e = &led_pin_load;
|
||||
usb-pwr-en = &pin_usb_pwr_en;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&adc1 {
|
||||
status = "okay";
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Martin Jäger / Libre Solar
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <drivers/pinmux.h>
|
||||
#include <sys/sys_io.h>
|
||||
|
||||
#include <pinmux/stm32/pinmux_stm32.h>
|
||||
|
||||
// preliminary fix until PR for pinmux_stm32l0.h got accepted and merged to Zephyr master branch,
|
||||
// see also here: https://github.com/zephyrproject-rtos/zephyr/pull/20997
|
||||
#ifndef STM32L0_PINMUX_FUNC_PB6_I2C1_SCL
|
||||
#define STM32L0_PINMUX_FUNC_PB6_I2C1_SCL \
|
||||
(STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP)
|
||||
#endif
|
||||
#ifndef STM32L0_PINMUX_FUNC_PB7_I2C1_SDA
|
||||
#define STM32L0_PINMUX_FUNC_PB7_I2C1_SDA \
|
||||
(STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP)
|
||||
#endif
|
||||
|
||||
/* pin assignments for NUCLEO-L073RZ board */
|
||||
static const struct pin_config pinconf[] = {
|
||||
#ifdef CONFIG_UART_1
|
||||
{STM32_PIN_PA9, STM32L0_PINMUX_FUNC_PA9_USART1_TX},
|
||||
{STM32_PIN_PA10, STM32L0_PINMUX_FUNC_PA10_USART1_RX},
|
||||
#endif /* CONFIG_UART_1 */
|
||||
#ifdef CONFIG_UART_2
|
||||
{STM32_PIN_PA2, STM32L0_PINMUX_FUNC_PA2_USART2_TX},
|
||||
{STM32_PIN_PA3, STM32L0_PINMUX_FUNC_PA3_USART2_RX},
|
||||
#endif /* CONFIG_UART_2 */
|
||||
#ifdef CONFIG_I2C_1
|
||||
{STM32_PIN_PB6, STM32L0_PINMUX_FUNC_PB6_I2C1_SCL},
|
||||
{STM32_PIN_PB7, STM32L0_PINMUX_FUNC_PB7_I2C1_SDA},
|
||||
#endif /* CONFIG_I2C_1 */
|
||||
#ifdef CONFIG_SPI_1
|
||||
{STM32_PIN_PA5, STM32L0_PINMUX_FUNC_PA5_SPI1_SCK},
|
||||
{STM32_PIN_PA6, STM32L0_PINMUX_FUNC_PA6_SPI1_MISO},
|
||||
{STM32_PIN_PA7, STM32L0_PINMUX_FUNC_PA7_SPI1_MOSI},
|
||||
#endif /* CONFIG_SPI_1 */
|
||||
#ifdef CONFIG_ADC_1
|
||||
{STM32_PIN_PA0, STM32L0_PINMUX_FUNC_PA0_ADC_IN0},
|
||||
#endif /* CONFIG_ADC_1 */
|
||||
};
|
||||
|
||||
static int pinmux_stm32_init(struct device *port)
|
||||
{
|
||||
ARG_UNUSED(port);
|
||||
|
||||
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
|
||||
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_MPPT_1210_HUS
|
||||
bool "Libre Solar MPPT 1210 HUS"
|
||||
depends on SOC_STM32L072XX
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_MPPT_1210_HUS
|
||||
|
||||
config BOARD
|
||||
default "mppt_1210_hus"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 4
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT_1210_HUS_0V7
|
||||
Executable → Regular
+1
-1
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(jlink "--device=STM32L073RZ" "--speed=4000")
|
||||
board_runner_args(jlink "--device=STM32L072RZ" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/l0/stm32l072Xz.dtsi>
|
||||
#include <st/l0/stm32l072r(b-z)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 1210 HUS";
|
||||
compatible = "st,stm32l072";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 1210 HUS";
|
||||
|
||||
hs-voltage-max = <40>;
|
||||
ls-voltage-max = <16>;
|
||||
dcdc-current-max = <10>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>, /* Pin A */
|
||||
<&gpiob 14 GPIO_ACTIVE_HIGH>, /* Pin B */
|
||||
<&gpiob 2 GPIO_ACTIVE_HIGH>; /* Pin C */
|
||||
|
||||
soc_1 {
|
||||
states = <1 2 0>; /* LED1 */
|
||||
};
|
||||
|
||||
soc_2 {
|
||||
states = <0 2 1>; /* LED2 */
|
||||
};
|
||||
|
||||
soc_3 {
|
||||
states = <1 0 2>; /* LED3 */
|
||||
};
|
||||
|
||||
load {
|
||||
states = <2 0 1>; /* LED4 */
|
||||
};
|
||||
|
||||
rxtx {
|
||||
states = <2 1 0>; /* LED5 */
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
load {
|
||||
label = "Load output";
|
||||
gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
|
||||
current-max = <10>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
usb-pwr {
|
||||
label = "USB charging port enable";
|
||||
gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
boot0 {
|
||||
label = "BOOT0 pin trigger";
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 0>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 1>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
enable-gpios = <&gpioc 14 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc1 5>;
|
||||
// amp gain: 50, resistor: 3 mOhm
|
||||
multiplier = <1000>;
|
||||
divider = <150>; // 3*50
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc1 6>;
|
||||
// amp gain: 50, resistor: 3 mOhm
|
||||
multiplier = <1000>;
|
||||
divider = <150>; // 3*50
|
||||
};
|
||||
|
||||
temp-bat {
|
||||
io-channels = <&adc1 7>;
|
||||
multiplier = <10000>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 17>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <10000>;
|
||||
divider = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
|
||||
soc {
|
||||
// not (yet) provided by Zephyr dts, but necessary for dcdc node
|
||||
timers3: timers@40000400 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40000400 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000002>;
|
||||
interrupts = <16 0>;
|
||||
interrupt-names = "global";
|
||||
status = "disabled";
|
||||
label = "TIMERS_3";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>;
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers3 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim3_ch3_pb0 &tim3_ch4_pb1>;
|
||||
frequency = <50000>;
|
||||
deadtime = <230>;
|
||||
};
|
||||
};
|
||||
|
||||
&eeprom {
|
||||
status = "okay";
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
identifier: mppt_1210_hus
|
||||
name: MPPT-1210-HUS
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 20
|
||||
flash: 192
|
||||
supported:
|
||||
- arduino_i2c
|
||||
- gpio
|
||||
- i2c
|
||||
- spi
|
||||
- watchdog
|
||||
- adc
|
||||
- eeprom
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# empty (using defaults from _defconfig file)
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.4";
|
||||
version-num = <4>;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 14 GPIO_ACTIVE_HIGH>, /* GND */
|
||||
<&gpiob 13 GPIO_ACTIVE_HIGH>, /* SOC_12 */
|
||||
<&gpiob 2 GPIO_ACTIVE_HIGH>, /* SOC_3 */
|
||||
<&gpiob 11 GPIO_ACTIVE_HIGH>, /* RXTX */
|
||||
<&gpiob 10 GPIO_ACTIVE_HIGH>; /* LOAD */
|
||||
|
||||
soc_1 {
|
||||
states = <1 0 0 0 0>;
|
||||
};
|
||||
|
||||
soc_2 {
|
||||
states = <0 1 0 0 0>;
|
||||
};
|
||||
|
||||
soc_3 {
|
||||
states = <0 0 1 0 0>;
|
||||
};
|
||||
|
||||
rxtx {
|
||||
states = <0 0 0 1 0>;
|
||||
};
|
||||
|
||||
load {
|
||||
states = <0 0 0 0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
load {
|
||||
gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
|
||||
label = "Load enable";
|
||||
};
|
||||
|
||||
usb-pwr {
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
|
||||
label = "USB charging port enable";
|
||||
};
|
||||
|
||||
/delete-node/ v-solar;
|
||||
/delete-node/ boot0;
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc1 6>;
|
||||
// amp gain: 50, resistor: 4 mOhm
|
||||
multiplier = <1000>;
|
||||
divider = <200>; // 4*50
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc1 7>;
|
||||
// amp gain: 50, resistor: 4 mOhm
|
||||
multiplier = <1000>;
|
||||
divider = <200>; // 4*50
|
||||
};
|
||||
|
||||
/delete-node/ temp-bat;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# empty (using defaults from _defconfig file)
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.7.1";
|
||||
version-num = <7>; // minor version .1 includes no HW change
|
||||
};
|
||||
};
|
||||
Executable → Regular
+5
-7
@@ -1,12 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Zephyr Kernel Configuration
|
||||
CONFIG_ARM=y
|
||||
CONFIG_SOC_SERIES_STM32L0X=y
|
||||
|
||||
# Platform Configuration
|
||||
CONFIG_SOC_STM32L073XX=y
|
||||
CONFIG_BOARD_MPPT1210HUS_0V4=y
|
||||
CONFIG_SOC_STM32L072XX=y
|
||||
|
||||
# General Kernel Options
|
||||
CONFIG_CORTEX_M_SYSTICK=y
|
||||
@@ -15,7 +10,6 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000
|
||||
# Serial Drivers
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
# enable console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
@@ -29,9 +23,13 @@ CONFIG_GPIO=y
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
# SYSCLK selection
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# PLL configuration
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=4
|
||||
CONFIG_CLOCK_STM32_PLL_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_STM32=y
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_check_revision(
|
||||
FORMAT MAJOR.MINOR.PATCH
|
||||
DEFAULT_REVISION 0.7.1
|
||||
)
|
||||
Executable → Regular
+2
-2
@@ -1,5 +1,5 @@
|
||||
# This is an ST NUCLEO-L073RZ board with single STM32L073RZ chip.
|
||||
# http://www.st.com/en/evaluation-tools/nucleo-l073rz.html
|
||||
# STM32L072 MCU
|
||||
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_MPPT_2420_HC
|
||||
bool "Libre Solar MPPT 2420 HC"
|
||||
depends on SOC_STM32G431XX
|
||||
@@ -0,0 +1,12 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_MPPT_2420_HC
|
||||
|
||||
config BOARD
|
||||
default "mppt_2420_hc"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 8
|
||||
|
||||
endif # BOARD_MPPT_2420_HC
|
||||
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(pyocd "--target=stm32g431rbtx")
|
||||
board_runner_args(jlink "--device=STM32G431RB" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/g4/stm32g431Xb.dtsi>
|
||||
#include <st/g4/stm32g431c(6-8-b)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 2420 HC";
|
||||
compatible = "st,stm32g431";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 2420 HC";
|
||||
|
||||
hs-voltage-max = <90>;
|
||||
ls-voltage-max = <32>;
|
||||
dcdc-current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
/* temporary solution only using green color LED */
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpioa 6 GPIO_ACTIVE_LOW>, /* chg red */
|
||||
<&gpioc 14 GPIO_ACTIVE_LOW>, /* chg green */
|
||||
<&gpiob 9 GPIO_ACTIVE_LOW>, /* dis red */
|
||||
<&gpioc 15 GPIO_ACTIVE_LOW>; /* dis green */
|
||||
|
||||
pwr {
|
||||
states = <0 1 0 0>;
|
||||
};
|
||||
|
||||
load {
|
||||
states = <0 0 0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
load {
|
||||
label = "Load output";
|
||||
gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
|
||||
current-max = <20>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
charge_pump {
|
||||
label = "Charge pump for HS MOSFET drivers";
|
||||
pwms = <&pwm8 2 200000 PWM_POLARITY_NORMAL>; /* 200 us period = 5 kHz */
|
||||
};
|
||||
|
||||
can_en {
|
||||
label = "CAN disable / standby";
|
||||
gpios = <&gpiob 11 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 12>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 15>;
|
||||
multiplier = <102200>;
|
||||
divider = <2200>;
|
||||
};
|
||||
|
||||
temp-fets {
|
||||
io-channels = <&adc1 11>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 16>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc2 1>;
|
||||
// amp gain: 25, resistor: 2 mOhm
|
||||
multiplier = <1000>; // 1000
|
||||
divider = <50>; // 2*25
|
||||
};
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc2 2>;
|
||||
// amp gain: 25, resistor: 2 mOhm
|
||||
multiplier = <1000>; // 1000
|
||||
divider = <50>; // 2*25
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>;
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi2 {
|
||||
pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>;
|
||||
cs-gpios = <&gpioa 5 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pc13>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
|
||||
/* TIM8 (CH2) used for charge pump */
|
||||
&timers8 {
|
||||
status = "okay";
|
||||
pwm8: pwm {
|
||||
status = "okay";
|
||||
st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */
|
||||
pinctrl-0 = <&tim8_ch2_pb8>;
|
||||
};
|
||||
};
|
||||
|
||||
&can1 {
|
||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
||||
bus-speed = <250000>;
|
||||
bus-speed-data = <250000>;
|
||||
sjw = <1>;
|
||||
sjw-data = <1>;
|
||||
sample-point = <875>;
|
||||
sample-point-data = <875>;
|
||||
status = "okay";
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
identifier: mppt_2420_hc
|
||||
name: MPPT-2420-HC
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 32
|
||||
flash: 128
|
||||
supported:
|
||||
- nvs
|
||||
- pwm
|
||||
- i2c
|
||||
- gpio
|
||||
- usb device
|
||||
- counter
|
||||
- spi
|
||||
@@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_AT24=y
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.1";
|
||||
version-num = <1>;
|
||||
};
|
||||
|
||||
/* temporary solution w/o using RGB LED */
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 14 GPIO_ACTIVE_LOW>, /* red */
|
||||
<&gpiob 15 GPIO_ACTIVE_LOW>, /* green */
|
||||
<&gpiob 9 GPIO_ACTIVE_LOW>; /* blue */
|
||||
|
||||
pwr {
|
||||
states = <1 0 0>;
|
||||
};
|
||||
|
||||
load {
|
||||
states = <0 1 0>;
|
||||
};
|
||||
|
||||
rxtx {
|
||||
states = <0 0 1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
/*
|
||||
* timeout of 5 ms as suggested in datasheet seems too optimistic
|
||||
* (several write errors occured during testing)
|
||||
*/
|
||||
timeout = <7>;
|
||||
};
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers1 {
|
||||
halfbridge {
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||
};
|
||||
};
|
||||
|
||||
&spi2 {
|
||||
status = "disabled";
|
||||
|
||||
/delete-node/ pinctrl-0;
|
||||
/delete-node/ cs-gpios;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_FLASH=y
|
||||
CONFIG_FLASH_PAGE_LAYOUT=y
|
||||
CONFIG_FLASH_LOG_LEVEL_WRN=y
|
||||
#CONFIG_MPU_ALLOW_FLASH_WRITE=y
|
||||
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_NOR=y
|
||||
CONFIG_SPI_NOR_SFDP_RUNTIME=y
|
||||
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
|
||||
|
||||
CONFIG_NVS=y
|
||||
CONFIG_NVS_LOG_LEVEL_WRN=y
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.2";
|
||||
version-num = <2>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
};
|
||||
};
|
||||
|
||||
&spi2 {
|
||||
w25q80dv: w25q80dv@0 {
|
||||
compatible = "jedec,spi-nor";
|
||||
label = "W25Q80DV";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <4000000>;
|
||||
size = <0x800000>; /* bits */
|
||||
has-dpd;
|
||||
t-enter-dpd = <4000>;
|
||||
t-exit-dpd = <25000>;
|
||||
jedec-id = [ef 40 14];
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Below partition layout allows to use MCUboot if CONFIG_BOOTLOADER_MCUBOOT is enabled. Otherwise,
|
||||
* the code will just use the entire available flash of the MCU.
|
||||
*/
|
||||
&flash0 {
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* bootloader slot: 32 KiB */
|
||||
boot_partition: partition@0 {
|
||||
label = "mcuboot";
|
||||
reg = <0x00000000 0x8000>;
|
||||
read-only;
|
||||
};
|
||||
|
||||
/* application image slot: 96 KiB */
|
||||
slot0_partition: partition@8000 {
|
||||
label = "image-0";
|
||||
reg = <0x00008000 0x18000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&w25q80dv {
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* backup slot: 96 KiB */
|
||||
slot1_partition: partition@0 {
|
||||
label = "image-1";
|
||||
reg = <0x00000000 0x18000>;
|
||||
};
|
||||
|
||||
/* swap slot: 96 KiB */
|
||||
scratch_partition: partition@18000 {
|
||||
label = "image-scratch";
|
||||
reg = <0x00018000 0x00018000>;
|
||||
};
|
||||
|
||||
/* remaining 832 KiB of SPI flash used as storage */
|
||||
storage_partition: partition@30000 {
|
||||
label = "storage";
|
||||
reg = <0x00030000 0x000D0000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32G4X=y
|
||||
CONFIG_SOC_STM32G431XX=y
|
||||
|
||||
# 170MHz system clock only in 'boost power' mode. RM0440, section
|
||||
# 5.1.5 states that the R1MODE bit must be cleared before system can
|
||||
# be 170MHz. This requires an update to the stm32 clock control
|
||||
# driver, so default to 150MHz until then.
|
||||
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
|
||||
|
||||
# 150MHz system clock in 'normal power' mode
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
# Use PLLCLK for SYSCLK
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# Use HSI (16MHz) to feed into PLL
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
|
||||
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
|
||||
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
|
||||
|
||||
# Produce 150MHz clock at PLLCLK output
|
||||
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
|
||||
|
||||
# Comment out above and uncomment below for 170MHz. Note that you
|
||||
# must have configured the mcu for boost power mode.
|
||||
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
|
||||
|
||||
# Produce Max (150MHz or 170MHz) HCLK
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
|
||||
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
|
||||
|
||||
# Console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
CONFIG_PWM=y
|
||||
|
||||
CONFIG_CAN=y
|
||||
CONFIG_THINGSET_CAN=y
|
||||
|
||||
CONFIG_ISOTP=y
|
||||
CONFIG_ISOTP_RX_BUF_COUNT=2
|
||||
CONFIG_ISOTP_RX_BUF_SIZE=100
|
||||
CONFIG_ISOTP_RX_SF_FF_BUF_COUNT=2
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_check_revision(FORMAT MAJOR.MINOR.PATCH)
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_MPPT_2420_HPX
|
||||
bool "Libre Solar MPPT 2420 HPX"
|
||||
depends on SOC_STM32G431XX
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_MPPT_2420_HPX
|
||||
|
||||
config BOARD
|
||||
default "mppt_2420_hpx"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 7
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT_2420_HPX
|
||||
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(pyocd "--target=stm32g431rbtx")
|
||||
board_runner_args(jlink "--device=STM32G431RB" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/g4/stm32g431Xb.dtsi>
|
||||
#include <st/g4/stm32g431r(6-8-b)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 2420 HPX";
|
||||
compatible = "st,stm32g431";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 2420 HPX";
|
||||
version-str = "v0.1";
|
||||
version-num = <1>;
|
||||
|
||||
hs-voltage-max = <80>;
|
||||
ls-voltage-max = <32>;
|
||||
dcdc-current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpioc 15 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
pwr {
|
||||
states = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
pwm_switch {
|
||||
label = "PWM power switch (solar panel)";
|
||||
pwms = <&pwm3 2 (20*1000*1000) PWM_POLARITY_NORMAL>; /* 20 ms period = 50 Hz */
|
||||
current-max = <20>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
load {
|
||||
label = "Load output";
|
||||
gpios = <&gpiob 15 GPIO_ACTIVE_LOW>;
|
||||
current-max = <20>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
charge_pump {
|
||||
label = "Charge pump for HS MOSFET drivers";
|
||||
pwms = <&pwm8 1 200000 PWM_POLARITY_NORMAL>; /* 200 us period = 5 kHz */
|
||||
};
|
||||
|
||||
hv-out {
|
||||
label = "HV output sense and enable switch";
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 12>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 15>;
|
||||
multiplier = <102200>;
|
||||
divider = <2200>;
|
||||
};
|
||||
|
||||
hv-ext-sense {
|
||||
io-channels = <&adc1 11>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
v-pwm {
|
||||
io-channels = <&adc1 4>;
|
||||
multiplier = <25224>; // (12*8.2 + 120*8.2 + 120*12) * 10
|
||||
divider = <984>; // (8.2*12) * 10
|
||||
offset = <37414>; // 65536 / (1 + 8.2/120 + 8.2/12)
|
||||
};
|
||||
|
||||
temp-fets {
|
||||
io-channels = <&adc1 6>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 16>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc2 1>;
|
||||
// amp gain: 20, resistor: 2 mOhm
|
||||
multiplier = <1000>; // 1000
|
||||
divider = <40>; // 2*20
|
||||
};
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc2 2>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <136>; // 2*68
|
||||
};
|
||||
|
||||
i-pwm {
|
||||
io-channels = <&adc2 5>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <136>; // 2*68
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart3;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart3 {
|
||||
pinctrl-0 = <&usart3_tx_pc10 &usart3_rx_pc11>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpiod 2 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&rtc {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
/*
|
||||
* For more information, see:
|
||||
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
|
||||
*/
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Set 4Kb of storage at the end of the 128Kb of flash */
|
||||
storage_partition: partition@1f000 {
|
||||
label = "storage";
|
||||
reg = <0x0001f000 0x00001000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
|
||||
/* TIM3 (CH2) used for PWM power switch */
|
||||
&timers3 {
|
||||
status = "okay";
|
||||
pwm3: pwm {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&tim3_ch2_pc7>;
|
||||
};
|
||||
};
|
||||
|
||||
/* TIM8 (CH1) used for charge pump */
|
||||
&timers8 {
|
||||
status = "okay";
|
||||
pwm8: pwm {
|
||||
status = "okay";
|
||||
st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */
|
||||
pinctrl-0 = <&tim8_ch1_pc6>;
|
||||
};
|
||||
};
|
||||
|
||||
&i2c3 {
|
||||
pinctrl-0 = <&i2c3_scl_pc8 &i2c3_sda_pc9>;
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
/*
|
||||
* timeout of 5 ms as suggested in datasheet seems too optimistic
|
||||
* (several write errors occured during testing)
|
||||
*/
|
||||
timeout = <7>;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
identifier: mppt_2420_hpx
|
||||
name: MPPT-2420-HPX
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 32
|
||||
flash: 128
|
||||
supported:
|
||||
- nvs
|
||||
- pwm
|
||||
- i2c
|
||||
- gpio
|
||||
- usb device
|
||||
- counter
|
||||
- spi
|
||||
@@ -0,0 +1,63 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32G4X=y
|
||||
CONFIG_SOC_STM32G431XX=y
|
||||
|
||||
# 170MHz system clock only in 'boost power' mode. RM0440, section
|
||||
# 5.1.5 states that the R1MODE bit must be cleared before system can
|
||||
# be 170MHz. This requires an update to the stm32 clock control
|
||||
# driver, so default to 150MHz until then.
|
||||
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
|
||||
|
||||
# 150MHz system clock in 'normal power' mode
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
# Use PLLCLK for SYSCLK
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# Use HSI (16MHz) to feed into PLL
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
|
||||
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
|
||||
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
|
||||
|
||||
# Produce 150MHz clock at PLLCLK output
|
||||
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
|
||||
|
||||
# Comment out above and uncomment below for 170MHz. Note that you
|
||||
# must have configured the mcu for boost power mode.
|
||||
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
|
||||
|
||||
# Produce Max (150MHz or 170MHz) HCLK
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
|
||||
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
|
||||
|
||||
# Console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
CONFIG_PWM=y
|
||||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_AT24=y
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_MPPT_2420_LC
|
||||
bool "Libre Solar MPPT 2420 LC"
|
||||
depends on SOC_STM32F072XB
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_MPPT_2420_LC
|
||||
|
||||
config BOARD
|
||||
default "mppt_2420_lc"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 1
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT_2420_LC_0V10
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(jlink "--device=STM32F072CB" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/f0/stm32f072Xb.dtsi>
|
||||
#include <st/f0/stm32f072c(8-b)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 2420 LC";
|
||||
compatible = "st,stm32f072";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 2420 LC";
|
||||
version-str = "v0.10";
|
||||
version-num = <10>;
|
||||
|
||||
hs-voltage-max = <55>;
|
||||
ls-voltage-max = <32>;
|
||||
dcdc-current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 14 GPIO_ACTIVE_HIGH>,
|
||||
<&gpiob 15 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
pwr {
|
||||
states = <1 0>;
|
||||
};
|
||||
|
||||
load {
|
||||
states = <0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
load {
|
||||
label = "Load output";
|
||||
gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
|
||||
current-max = <20>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
uext_en {
|
||||
label = "UEXT enable";
|
||||
gpios = <&gpioc 14 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
can_en {
|
||||
label = "CAN disable / standby";
|
||||
gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
aux_en {
|
||||
label = "5V output enable";
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
vbus_en {
|
||||
label = "CAN bus power supply enable";
|
||||
gpios = <&gpioc 15 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
temp-bat {
|
||||
io-channels = <&adc1 0>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-fets {
|
||||
io-channels = <&adc1 1>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref {
|
||||
io-channels = <&adc1 5>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 6>;
|
||||
multiplier = <110000>;
|
||||
divider = <10000>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 7>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc1 8>;
|
||||
// amp gain: 150/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <300>; // 2*150
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc1 9>;
|
||||
// amp gain: 150/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <300>; // 2*150
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 16>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 17>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>;
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
};
|
||||
|
||||
&i2c2 {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>;
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>; // 24AA01: 8 bytes
|
||||
address-width = <16>; // 24AA01: 8 bit
|
||||
/*
|
||||
* timeout of 5 ms as suggested in datasheet seems too optimistic
|
||||
* (several write errors occured during testing)
|
||||
*/
|
||||
timeout = <7>;
|
||||
};
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
|
||||
&can1 {
|
||||
pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>;
|
||||
bus-speed = <250000>;
|
||||
status = "okay";
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
identifier: mppt_2420_lc
|
||||
name: MPPT-2420-LC
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 16
|
||||
flash: 128
|
||||
supported:
|
||||
- arduino_i2c
|
||||
- gpio
|
||||
- i2c
|
||||
- spi
|
||||
- watchdog
|
||||
- adc
|
||||
@@ -0,0 +1,38 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32F0X=y
|
||||
CONFIG_SOC_STM32F072XB=y
|
||||
|
||||
# General Kernel Options
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000
|
||||
|
||||
# Serial Drivers
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Pinmux Driver
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# GPIO Controller
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# Clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
# SYSCLK selection
|
||||
CONFIG_CLOCK_STM32_HSE_CLOCK=8000000
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
# PLL configuration
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=6
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
|
||||
CONFIG_CAN=y
|
||||
CONFIG_THINGSET_CAN=y
|
||||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_AT24=y
|
||||
@@ -0,0 +1,12 @@
|
||||
source [find board/st_nucleo_f0.cfg]
|
||||
|
||||
$_TARGETNAME configure -event gdb-attach {
|
||||
echo "Debugger attaching: halting execution"
|
||||
reset halt
|
||||
gdb_breakpoint_override hard
|
||||
}
|
||||
|
||||
$_TARGETNAME configure -event gdb-detach {
|
||||
echo "Debugger detaching: resuming execution"
|
||||
resume
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_MPPT_2420_RC
|
||||
bool "Libre Solar MPPT 2420 RC"
|
||||
depends on SOC_STM32G431XX
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_MPPT_2420_RC
|
||||
|
||||
config BOARD
|
||||
default "mppt_2420_rc"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 0
|
||||
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT_2420_RC
|
||||
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(pyocd "--target=stm32g431rbtx")
|
||||
board_runner_args(jlink "--device=STM32G431RB" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/g4/stm32g431Xb.dtsi>
|
||||
#include <st/g4/stm32g431c(6-8-b)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 2420 RC";
|
||||
compatible = "st,stm32g431";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 2420 RC";
|
||||
version-str = "v0.1";
|
||||
version-num = <1>;
|
||||
|
||||
hs-voltage-max = <80>;
|
||||
ls-voltage-max = <32>;
|
||||
dcdc-current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 15 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
pwr {
|
||||
states = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
can_en {
|
||||
label = "CAN disable / standby";
|
||||
gpios = <&gpiob 14 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
hv-out {
|
||||
label = "HV output sense and enable switch";
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 12>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 15>;
|
||||
multiplier = <102200>;
|
||||
divider = <2200>;
|
||||
};
|
||||
|
||||
hv-ext-sense {
|
||||
io-channels = <&adc1 11>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-fets {
|
||||
io-channels = <&adc1 2>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-bat {
|
||||
io-channels = <&adc1 14>;
|
||||
multiplier = <10000>; // 10k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 16>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc2 1>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <136>; // 2*68
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
/*
|
||||
* For more information, see:
|
||||
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
|
||||
*/
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Set 4Kb of storage at the end of the 128Kb of flash */
|
||||
storage_partition: partition@1f000 {
|
||||
label = "storage";
|
||||
reg = <0x0001f000 0x00001000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
/* shared between UEXT and EEPROM */
|
||||
status = "okay";
|
||||
pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>;
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
/*
|
||||
* timeout of 5 ms as suggested in datasheet seems too optimistic
|
||||
* (several write errors occured during testing)
|
||||
*/
|
||||
timeout = <7>;
|
||||
};
|
||||
};
|
||||
|
||||
&can1 {
|
||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
||||
bus-speed = <250000>;
|
||||
bus-speed-data = <250000>;
|
||||
sjw = <1>;
|
||||
sjw-data = <1>;
|
||||
sample-point = <875>;
|
||||
sample-point-data = <875>;
|
||||
status = "okay";
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
identifier: mppt_2420_rc
|
||||
name: MPPT-2420-RC
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 32
|
||||
flash: 128
|
||||
supported:
|
||||
- nvs
|
||||
- pwm
|
||||
- i2c
|
||||
- gpio
|
||||
- usb device
|
||||
- counter
|
||||
- spi
|
||||
@@ -0,0 +1,69 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32G4X=y
|
||||
CONFIG_SOC_STM32G431XX=y
|
||||
|
||||
# 170MHz system clock only in 'boost power' mode. RM0440, section
|
||||
# 5.1.5 states that the R1MODE bit must be cleared before system can
|
||||
# be 170MHz. This requires an update to the stm32 clock control
|
||||
# driver, so default to 150MHz until then.
|
||||
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
|
||||
|
||||
# 150MHz system clock in 'normal power' mode
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
# Use PLLCLK for SYSCLK
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# Use HSI (16MHz) to feed into PLL
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
|
||||
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
|
||||
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
|
||||
|
||||
# Produce 150MHz clock at PLLCLK output
|
||||
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
|
||||
|
||||
# Comment out above and uncomment below for 170MHz. Note that you
|
||||
# must have configured the mcu for boost power mode.
|
||||
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
|
||||
|
||||
# Produce Max (150MHz or 170MHz) HCLK
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
|
||||
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
|
||||
|
||||
# Console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_AT24=y
|
||||
|
||||
CONFIG_CAN=y
|
||||
CONFIG_THINGSET_CAN=y
|
||||
|
||||
CONFIG_ISOTP=y
|
||||
CONFIG_ISOTP_RX_BUF_COUNT=1
|
||||
CONFIG_ISOTP_RX_BUF_SIZE=100
|
||||
CONFIG_ISOTP_RX_SF_FF_BUF_COUNT=2
|
||||
@@ -0,0 +1,8 @@
|
||||
# STM32G474RE Nucleo board configuration
|
||||
|
||||
# Copyright (c) 2019 STMicroelectronics.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_NUCLEO_G474RE
|
||||
bool "Nucleo G474RE Development Board"
|
||||
depends on SOC_STM32G474XX
|
||||
@@ -0,0 +1,14 @@
|
||||
# STM32G474RE Nucleo board configuration
|
||||
|
||||
# Copyright (c) 2019 STMicroelectronics.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_NUCLEO_G474RE
|
||||
|
||||
config BOARD
|
||||
default "nucleo_g474re"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 0
|
||||
|
||||
endif # BOARD_NUCLEO_G431RB
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# use target=stm32g474rbtx instead of stm32g474retx
|
||||
# to allow board re-flashing (see PR #23230)
|
||||
board_runner_args(pyocd "--target=stm32g474rbtx")
|
||||
|
||||
board_runner_args(jlink "--device=STM32G474RE" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a dummy charge controller board for testing new features using the STM32G474 MCU
|
||||
*
|
||||
* IMPORTANT: You have to remove the VREF jumper on the Nucleo board to make it work. Otherwise
|
||||
* the MCU will get stuck while trying to generate a reference voltage at VREF+ pin.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/g4/stm32g474Xe.dtsi>
|
||||
#include <st/g4/stm32g474r(b-c-e)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "STMicroelectronics STM32G474RE-NUCLEO board";
|
||||
compatible = "st,stm32g474re-nucleo";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "Nucleo G474 dummy charge controller";
|
||||
version-str = "v0.1";
|
||||
version-num = <1>;
|
||||
|
||||
hs-voltage-max = <80>;
|
||||
ls-voltage-max = <32>;
|
||||
dcdc-current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &lpuart1;
|
||||
zephyr,shell-uart = &lpuart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,can-primary = &can1;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
pwr {
|
||||
states = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
can_en {
|
||||
label = "CAN disable / standby";
|
||||
gpios = <&gpiob 11 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 12>;
|
||||
multiplier = <105600>;
|
||||
divider = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
io-channels = <&adc1 15>;
|
||||
multiplier = <102200>;
|
||||
divider = <2200>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 16>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
io-channels = <&adc2 1>;
|
||||
// amp gain: 25, resistor: 2 mOhm
|
||||
multiplier = <1000>; // 1000
|
||||
divider = <50>; // 2*25
|
||||
};
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
user_button: button {
|
||||
label = "User";
|
||||
gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
sw0 = &user_button;
|
||||
uart-dbg = &lpuart1;
|
||||
uart-uext = &usart1;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
|
||||
soc {
|
||||
hrtim1: timers@40016800 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40016800 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x04000000>;
|
||||
interrupts = <67 0>, <68 0>, <69 0>, <70 0>,
|
||||
<71 0>, <72 0>, <73 0>, <74 0>;
|
||||
interrupt-names = "master", "tima", "timb", "timc",
|
||||
"timd", "time", "flt", "timf";
|
||||
status = "okay";
|
||||
label = "HRTIM_1";
|
||||
};
|
||||
|
||||
/* below nodes are required until following PR is merged:
|
||||
* https://github.com/zephyrproject-rtos/hal_stm32/pull/87
|
||||
*/
|
||||
pinctrl: pin-controller@48000000 {
|
||||
hrtim1_cha1_pa8: hrtim1_cha1_pa8 {
|
||||
pinmux = <STM32_PINMUX('A', 8, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_cha2_pa9: hrtim1_cha2_pa9 {
|
||||
pinmux = <STM32_PINMUX('A', 9, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chb1_pa10: hrtim1_chb1_pa10 {
|
||||
pinmux = <STM32_PINMUX('A', 10, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chb2_pa11: hrtim1_chb2_pa11 {
|
||||
pinmux = <STM32_PINMUX('A', 11, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chc1_pb12: hrtim1_chc1_pb12 {
|
||||
pinmux = <STM32_PINMUX('B', 12, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chc2_pb13: hrtim1_chc2_pb13 {
|
||||
pinmux = <STM32_PINMUX('B', 13, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chd1_pb14: hrtim1_chd1_pb14 {
|
||||
pinmux = <STM32_PINMUX('B', 14, AF13)>;
|
||||
};
|
||||
|
||||
hrtim1_chd2_pb15: hrtim1_chd2_pb15 {
|
||||
pinmux = <STM32_PINMUX('B', 15, AF13)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pc4 &usart1_rx_pc5>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&lpuart1 {
|
||||
pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pb3
|
||||
&spi1_miso_pa6 &spi1_mosi_pa7>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&hrtim1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&hrtim1_cha1_pa8 &hrtim1_cha2_pa9>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
// alternative to HRTIM
|
||||
&timers1 {
|
||||
status = "okay";
|
||||
|
||||
halfbridge {
|
||||
compatible = "half-bridge";
|
||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||
frequency = <70000>;
|
||||
deadtime = <300>;
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
&rtc {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
/*
|
||||
* For more information, see:
|
||||
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
|
||||
*/
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Set 2Kb of storage at the end of the 128Kb of flash */
|
||||
storage_partition: partition@1f800 {
|
||||
label = "storage";
|
||||
reg = <0x0001f800 0x00000800>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&rng {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&adc1 {
|
||||
pinctrl-0 = <&adc1_in1_pa0>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&can1 {
|
||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
||||
bus-speed = <250000>;
|
||||
bus-speed-data = <250000>;
|
||||
sjw = <1>;
|
||||
sjw-data = <1>;
|
||||
sample-point = <875>;
|
||||
sample-point-data = <875>;
|
||||
status = "okay";
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
identifier: nucleo_g474re
|
||||
name: ST Nucleo G474RE
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 128
|
||||
flash: 512
|
||||
supported:
|
||||
- nvs
|
||||
- pwm
|
||||
- i2c
|
||||
- gpio
|
||||
- usb device
|
||||
- counter
|
||||
- spi
|
||||
- watchdog
|
||||
- adc
|
||||
- can
|
||||
- canfd
|
||||
@@ -0,0 +1,68 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32G4X=y
|
||||
CONFIG_SOC_STM32G474XX=y
|
||||
|
||||
# 170MHz system clock only in 'boost power' mode.
|
||||
# RM0440, section 5.1.5 states that the R1MODE bit
|
||||
# must be cleared before system can be 170MHz.
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
|
||||
|
||||
# 150MHz system clock in 'normal power' mode
|
||||
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
# Use PLLCLK for SYSCLK
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# Use HSE (24MHz) to feed into PLL
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
|
||||
CONFIG_CLOCK_STM32_HSE_CLOCK=24000000
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
|
||||
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
|
||||
|
||||
# Produce 150MHz clock at PLLCLK output
|
||||
# CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
|
||||
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
|
||||
|
||||
# Produce 170MHz clock at PLLCLK output
|
||||
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=6
|
||||
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
|
||||
|
||||
# Produce Max (150MHz or 170MHz) HCLK
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
|
||||
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
|
||||
|
||||
# Console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
# Enable HW stack protection
|
||||
CONFIG_HW_STACK_PROTECTION=y
|
||||
|
||||
CONFIG_CAN=y
|
||||
CONFIG_THINGSET_CAN=y
|
||||
|
||||
CONFIG_ISOTP=y
|
||||
CONFIG_ISOTP_RX_BUF_COUNT=2
|
||||
CONFIG_ISOTP_RX_BUF_SIZE=100
|
||||
CONFIG_ISOTP_RX_SF_FF_BUF_COUNT=2
|
||||
@@ -0,0 +1,7 @@
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
source [find target/stm32g4x.cfg]
|
||||
|
||||
reset_config srst_only
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD_PWM_2420_LUS
|
||||
bool "Libre Solar PWM 2420 LUS"
|
||||
depends on SOC_STM32L072XX
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (c) The Libre Solar Project Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_PWM_2420_LUS
|
||||
|
||||
config BOARD
|
||||
default "pwm_2420_lus"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 5
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
|
||||
endif # BOARD_PWM_2420_LUS
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(jlink "--device=STM32L072RZ" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/l0/stm32l072Xz.dtsi>
|
||||
#include <st/l0/stm32l072r(b-z)tx-pinctrl.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar PWM 2420 LUS";
|
||||
compatible = "st,stm32l072";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "PWM 2420 LUS";
|
||||
|
||||
hs-voltage-max = <55>;
|
||||
ls-voltage-max = <32>;
|
||||
// The MCU, where internal temperature is measured, is close to the MOSFETs. Tests
|
||||
// showed that temperature at heat sink is only 10-20°C above measured internal
|
||||
// temp. As PWM CC doesn't use electrolytic cap for core charging function,
|
||||
// internal temperature of 70°C can be allowed (instead of default 50°C).
|
||||
internal-tref-max = <70>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,shell-uart = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "charlieplexing-leds";
|
||||
gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>, /* Pin A */
|
||||
<&gpiob 14 GPIO_ACTIVE_HIGH>, /* Pin B */
|
||||
<&gpiob 15 GPIO_ACTIVE_HIGH>; /* Pin C */
|
||||
|
||||
soc_1 {
|
||||
states = <1 0 2>;
|
||||
};
|
||||
|
||||
soc_2 {
|
||||
states = <0 1 2>;
|
||||
};
|
||||
|
||||
soc_3 {
|
||||
states = <1 2 0>;
|
||||
};
|
||||
|
||||
load {
|
||||
states = <2 1 0>;
|
||||
};
|
||||
|
||||
rxtx {
|
||||
states = <2 0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
outputs {
|
||||
compatible = "outputs";
|
||||
|
||||
pwm_switch {
|
||||
label = "PWM power switch (solar panel)";
|
||||
pwms = <&pwm3 4 (20*1000*1000) PWM_POLARITY_NORMAL>; /* 20 ms period = 50 Hz */
|
||||
// Current reduced to 15A. Increase to 20A PCB max values
|
||||
// only if attached to a big heat sink.
|
||||
current-max = <15>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
load {
|
||||
label = "Load output";
|
||||
gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
|
||||
current-max = <15>;
|
||||
kconfig-flag; /* make node visible in Kconfig */
|
||||
};
|
||||
|
||||
usb-pwr {
|
||||
label = "USB charging port disable";
|
||||
gpios = <&gpiob 5 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
boot0 {
|
||||
label = "BOOT0 pin trigger";
|
||||
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
v-low {
|
||||
io-channels = <&adc1 0>;
|
||||
multiplier = <132000>;
|
||||
divider = <12000>;
|
||||
};
|
||||
|
||||
v-pwm {
|
||||
io-channels = <&adc1 1>;
|
||||
multiplier = <25224>; // (12*8.2 + 120*8.2 + 120*12) * 10
|
||||
divider = <984>; // (8.2*12) * 10
|
||||
offset = <37414>; // 65536 / (1 + 8.2/120 + 8.2/12)
|
||||
};
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc1 5>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
// fix for hardware bug in overcurrent comparator voltage divider wiring
|
||||
multiplier = <2931>; // 1000 * (39+12+8.2) / (12+8.2) = 2930.69
|
||||
divider = <62>; // 2*68/2.2 = 61.8181
|
||||
};
|
||||
|
||||
i-pwm {
|
||||
io-channels = <&adc1 6>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
multiplier = <2200>; // 1000*2.2
|
||||
divider = <136>; // 2*68
|
||||
};
|
||||
|
||||
temp-bat {
|
||||
io-channels = <&adc1 7>;
|
||||
multiplier = <8200>; // 8.2k NTC series resistor
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
vref-mcu {
|
||||
io-channels = <&adc1 17>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
|
||||
temp-mcu {
|
||||
io-channels = <&adc1 18>;
|
||||
multiplier = <1>;
|
||||
divider = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart1;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
|
||||
// this should normally go to Zephyr repo
|
||||
soc {
|
||||
timers3: timers@40000400 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40000400 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000002>;
|
||||
status = "okay";
|
||||
label = "TIMERS_3";
|
||||
|
||||
pwm3: pwm {
|
||||
compatible = "st,stm32-pwm";
|
||||
status = "okay";
|
||||
st,prescaler = <10000>;
|
||||
label = "PWM_3";
|
||||
#pwm-cells = <3>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>;
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>;
|
||||
cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&timers3 {
|
||||
status = "okay";
|
||||
pwm3: pwm {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&tim3_ch4_pb1>;
|
||||
};
|
||||
};
|
||||
|
||||
&eeprom {
|
||||
status = "okay";
|
||||
};
|
||||
Executable → Regular
+3
-2
@@ -1,5 +1,5 @@
|
||||
identifier: mppt1210hus_0v4
|
||||
name: MPPT-1210-HUS-0V4
|
||||
identifier: pwm_2420_lus
|
||||
name: PWM-2420-LUS
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
@@ -15,3 +15,4 @@ supported:
|
||||
- spi
|
||||
- watchdog
|
||||
- adc
|
||||
- eeprom
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# empty (using defaults from _defconfig file)
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.2";
|
||||
version-num = <2>;
|
||||
};
|
||||
|
||||
adc-inputs {
|
||||
compatible = "adc-inputs";
|
||||
|
||||
i-load {
|
||||
io-channels = <&adc1 5>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
multiplier = <1000>;
|
||||
divider = <62>; // 2*68/2.2 = 61.8181
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# empty (using defaults from _defconfig file)
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) The Libre Solar Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
pcb {
|
||||
version-str = "v0.3";
|
||||
version-num = <3>;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32L0X=y
|
||||
CONFIG_SOC_STM32L072XX=y
|
||||
|
||||
# General Kernel Options
|
||||
CONFIG_CORTEX_M_SYSTICK=y
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000
|
||||
|
||||
# Serial Drivers
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Pinmux Driver
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# GPIO Controller
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# Clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
# SYSCLK selection
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# PLL configuration
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=4
|
||||
CONFIG_CLOCK_STM32_PLL_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_STM32=y
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_check_revision(
|
||||
FORMAT MAJOR.MINOR.PATCH
|
||||
DEFAULT_REVISION 0.3
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
set WORKAREASIZE 0x2000
|
||||
|
||||
source [find target/stm32l0.cfg]
|
||||
|
||||
# Add the second flash bank.
|
||||
set _FLASHNAME $_CHIPNAME.flash1
|
||||
flash bank $_FLASHNAME stm32lx 0 0 0 0 $_TARGETNAME
|
||||
|
||||
# There is only system reset line and JTAG/SWD command can be issued when SRST
|
||||
reset_config srst_only
|
||||
|
||||
$_TARGETNAME configure -event gdb-attach {
|
||||
echo "Debugger attaching: halting execution"
|
||||
reset halt
|
||||
gdb_breakpoint_override hard
|
||||
}
|
||||
|
||||
$_TARGETNAME configure -event gdb-detach {
|
||||
echo "Debugger detaching: resuming execution"
|
||||
resume
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-DSTM32L073xx",
|
||||
"extra_flags": "-DSTM32L072xx",
|
||||
"f_cpu": "32000000L",
|
||||
"framework_extra_flags": {
|
||||
"arduino": "-D__CORTEX_SC=0"
|
||||
},
|
||||
"mcu": "stm32l073rz",
|
||||
"mcu": "stm32l072rz",
|
||||
"variant": "MPPT-1210-HUS"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32L073RZ",
|
||||
"jlink_device": "STM32L072RZ",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
@@ -26,7 +26,7 @@
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 1210 HUS v0.4",
|
||||
"name": "Libre Solar MPPT 1210 HUS",
|
||||
"upload": {
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 196608,
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
|
||||
"f_cpu": "150000000L",
|
||||
"mcu": "stm32g431rb",
|
||||
"variant": "MPPT-2420-HC"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"jlink"
|
||||
],
|
||||
"jlink_device": "STM32G431RB",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_g431rb",
|
||||
"svd_path": "STM32G431xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 2420 HC",
|
||||
"upload": {
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "jlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "https://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
|
||||
"f_cpu": "150000000L",
|
||||
"mcu": "stm32g431rb",
|
||||
"variant": "MPPT-2420-HPX"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"jlink"
|
||||
],
|
||||
"jlink_device": "STM32G431RB",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_g431rb",
|
||||
"svd_path": "STM32G431xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 2420 HPX",
|
||||
"upload": {
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "jlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "http://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m0",
|
||||
"extra_flags": "-DSTM32F072xB",
|
||||
"f_cpu": "48000000L",
|
||||
"mcu": "stm32f072rbt6"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32F072RB",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_f0",
|
||||
"svd_path": "STM32F072x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"mbed",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 2420 LC",
|
||||
"upload": {
|
||||
"maximum_ram_size": 16384,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "http://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
|
||||
"f_cpu": "150000000L",
|
||||
"mcu": "stm32g431rb",
|
||||
"variant": "MPPT-2420-RC"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"jlink"
|
||||
],
|
||||
"jlink_device": "STM32G431RB",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_g431rb",
|
||||
"svd_path": "STM32G431xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 2420 RC",
|
||||
"upload": {
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "jlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "http://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32G4xx -DSTM32G474xx",
|
||||
"f_cpu": "170000000L",
|
||||
"mcu": "stm32g474ret6",
|
||||
"product_line": "STM32G474xx",
|
||||
"variant": "NUCLEO_G474RE"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"jlink_device": "STM32G474RE",
|
||||
"openocd_target": "stm32g4x",
|
||||
"svd_path": "STM32G474xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"cmsis",
|
||||
"mbed",
|
||||
"libopencm3",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Nucleo G474RE",
|
||||
"upload": {
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "mbed",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"cmsis-dap",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "https://www.st.com/en/evaluation-tools/nucleo-g474re.html",
|
||||
"vendor": "ST"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-DSTM32L072xx",
|
||||
"f_cpu": "32000000L",
|
||||
"framework_extra_flags": {
|
||||
"arduino": "-D__CORTEX_SC=0"
|
||||
},
|
||||
"mcu": "stm32l072rz",
|
||||
"variant": "PWM-2420-LUS"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32L072RZ",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_l073rz",
|
||||
"svd_path": "STM32L07x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"mbed",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar PWM 2420 LUS",
|
||||
"upload": {
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 196608,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "http://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@ECHO OFF
|
||||
:: This batch file performs the same checks as TravisCI and should be run after each commit and
|
||||
:: before pushing the commits
|
||||
|
||||
echo "---------- Trailing whitespace check -------------"
|
||||
:: check uncommitted changes
|
||||
git diff --check HEAD
|
||||
if errorlevel 1 (
|
||||
echo Failure Reason is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
:: check all commits starting from initial commit
|
||||
for /F %i in ('"git rev-list --max-parents=0 HEAD"') do git diff --check %i..HEAD
|
||||
if errorlevel 1 (
|
||||
echo Failure Reason is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo "---------- Running compile check -------------"
|
||||
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
|
||||
if errorlevel 1 (
|
||||
echo Failure Reason is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo "---------- Running unit-tests -------------"
|
||||
platformio test -e unit_test
|
||||
if errorlevel 1 (
|
||||
echo Failure Reason is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo "---------- Running static code checks -------------"
|
||||
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
|
||||
if errorlevel 1 (
|
||||
echo Failure Reason is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo "---------- All tests passed -------------"
|
||||
@@ -5,39 +5,33 @@
|
||||
#
|
||||
|
||||
echo "---------- Trailing whitespace check -------------"
|
||||
git diff --check `git rev-list HEAD | tail -n 1`..$TRAVIS_BRANCH
|
||||
# check uncommitted changes
|
||||
git diff --check HEAD
|
||||
if [ $? != 0 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
# check all commits starting from initial commit
|
||||
git diff --check `git rev-list --max-parents=0 HEAD`..HEAD
|
||||
if [ $? != 0 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "---------- Preparation of config -------------"
|
||||
if [ -f "src/config.h" ]; then
|
||||
echo "Making backup of existing config"
|
||||
mv src/config.h src/config.h_backup_checksh
|
||||
fi
|
||||
cp src/config.h_template src/config.h
|
||||
|
||||
echo "---------- Running compile check -------------"
|
||||
platformio run -e mppt-2420-lc-v0.10 -e mppt-1210-hus-v0.7 -e pwm-2420-lus-v0.3
|
||||
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
|
||||
if [ $? != 0 ]; then
|
||||
mv src/config.h_backup_checksh src/config.h
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "---------- Running unit-tests -------------"
|
||||
platformio test -e unit-test-native
|
||||
platformio test -e unit_test
|
||||
if [ $? != 0 ]; then
|
||||
mv src/config.h_backup_checksh src/config.h
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "---------- Running static code checks -------------"
|
||||
platformio check -e mppt-1210-hus-v0.7 -e pwm-2420-lus-v0.3
|
||||
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
|
||||
if [ $? != 0 ]; then
|
||||
mv src/config.h_backup_checksh src/config.h
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
mv src/config.h_backup_checksh src/config.h
|
||||
|
||||
echo "---------- All tests passed -------------"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Libre Solar Charge Controller Firmware
|
||||
|
||||
## Charge controller basic concepts
|
||||
|
||||
[charger-concepts.md](charger-concepts.md)
|
||||
|
||||
## Firmware module overview
|
||||
|
||||
[module-overview.md](module-overview.md)
|
||||
|
||||
## API documentation
|
||||
|
||||
The documentation auto-generated by Doxygen can be found [here](https://libre.solar/charge-controller-firmware/).
|
||||
|
||||
## Further information
|
||||
|
||||
[Zephyr Project documentation](https://docs.zephyrproject.org/latest/)
|
||||
|
||||
[Zephyr / West cheatsheet](zephyr-cheatsheet.md)
|
||||
@@ -0,0 +1,43 @@
|
||||
# Charge controller concepts
|
||||
|
||||
## Bus and port structure
|
||||
|
||||
In order to handle multiple different types of charge controllers, the power flow in the charge controller is abstracted using the two base components DC bus and Power Port:
|
||||
|
||||
- A **DC bus**, which is a connection of two or more electrical circuits such that the electric potential at each connection point can be considered equal. This can be achieved either by connecting each participant very close to each other or by using large copper cross-section such that voltage drop introduced by current flow is negligible. The voltage control targets of the bus can only be set by one of the connected ports.
|
||||
|
||||
- A **Power port**, which connects a DC bus with an internal or external device or sub-circuit. A port usually contains a current measurement. Its voltage is determined by the DC bus it is connected to. A port can also contain a switching element.
|
||||
|
||||
The following image gives an overview of the maximum set of features for a charge controller currently considered in the firmware. It contains two DC buses: High-voltage side (typically solar panel or wind turbine) and low-voltage side (typically determined by battery voltage). Most of the power ports are connected at the low voltage side (12V or 24V).
|
||||
|
||||

|
||||
|
||||
The image also shows the direction of positive current flow.
|
||||
|
||||
## Charger state machine
|
||||
|
||||
For general information about battery charging, please check out the [battery chapter at learn.libre.solar](https://learn.libre.solar/system/battery.html#charge-methods).
|
||||
|
||||
The charger module in the firmware has the following states:
|
||||
|
||||
### 0. Standby
|
||||
|
||||
Initial state of the charge controller. If the solar voltage is high enough and the battery is not full, charging in CC mode is started.
|
||||
|
||||
### 1. Bulk stage
|
||||
|
||||
This first charging stage adds about 70 percent of the stored energy. The battery is charged with a constant current (CC), typically the maximum current the charger can supply. In case of a solar charge controller, this is where the Maximum Power Point Tracking (MPPT) takes place. As a result, the terminal voltage increases until the peak charge voltage limit is reached and topping phase is entered.
|
||||
|
||||
### 2. Topping stage
|
||||
|
||||
During the topping (sometimes also called boost or absorption) the remaining 30 percent of the energy is continued being charged at a constant voltage (CV) while gradually decreasing the charge current until the battery is fully charged.
|
||||
|
||||
### 3. Equalization stage
|
||||
|
||||
An additional equalization charging is beneficial for flooded lead-acid batteries only. It can be considered as a periodic controlled overcharge that brings the cells to the same charge level and removes the sulphation by increasing the voltage to a higher value than the peak charge voltage limit. The current during equlization is controlled at a very low value.
|
||||
|
||||
### 4. Trickle stage
|
||||
|
||||
The trickle or float charging stage is the final phase upon the completion of the absorption or equalization phase which maintains the battery at full charge. During this stage, the charge voltage is reduced and held constant. The current reduces to a very low value.
|
||||
|
||||

|
||||
@@ -1,20 +0,0 @@
|
||||
# Charger state machine
|
||||
|
||||
The charge management has the following states:
|
||||
|
||||
### Standby
|
||||
Initial state of the charge controller. If the solar voltage is high enough and the battery is not full, charging in CC mode is started.
|
||||
|
||||
### CC / bulk charging
|
||||
The battery is charged with maximum possible current (MPPT algorithm is active) until the CV voltage limit is reached.
|
||||
|
||||
### CV / absorption charging
|
||||
Lead-acid batteries are charged for some time using a slightly higher charge voltage. After a current cutoff limit or a time limit is reached, the charger goes into trickle or equalization mode for lead-acid batteries or back into Standby for Li-ion batteries.
|
||||
|
||||
### Trickle charging
|
||||
This mode is kept forever for a lead-acid battery and keeps the battery at full state of charge. If too much power is drawn from the battery, the charger switches back into CC / bulk charging mode.
|
||||
|
||||
### Equalization charging
|
||||
This mode is only used for lead-acid batteries after several deep-discharge cycles or a very long period of time with no equalization. Voltage is increased to 15V or above, so care must be taken for the other system components attached to the battery. (currently, no equalization charging is enabled in the software)
|
||||
|
||||

|
||||
@@ -1,29 +0,0 @@
|
||||
# MPPT charger firmware structure
|
||||
|
||||
## Important remarks
|
||||
|
||||
- Do **not** use mbed Ticker class, as it disturbs the timer settings and might cause the charge controller to crash. In addition to that, it contains a lot of overhead and is not very efficient. Timers are programmed bare metal.
|
||||
|
||||
- The PWM signal generation for the DC/DC controller inside the charge controller is done in the file half_bridge_xxx.cpp and dcdc.cpp. Most of the dangerous functions which could turn your MOSFETs into magic smoke are implemented here, so don't touch it unless you know what you're doing.
|
||||
|
||||
## Toolchain and flashing instructions
|
||||
|
||||
See the Libre Solar website for a detailed instruction how to [develop software](http://libre.solar/docs/toolchain) and [flash new firmware](http://libre.solar/docs/flashing).
|
||||
|
||||
|
||||
## Timer configuration
|
||||
- mbed us_ticker (cannot be changed)
|
||||
- TIM2 for STM32F0
|
||||
- TIM21 for STM32L0
|
||||
- PWM generation for DC/DC half bridge (50-70 kHz)
|
||||
- TIM1 for STM32F0 (advanced timer)
|
||||
- TIM3 for STM32L0 (standard timer)
|
||||
- ADC and DMA (1 kHz)
|
||||
- TIM15 for STM32F0
|
||||
- TIM6 for STM32L0
|
||||
- DC/DC control function (10 Hz)
|
||||
- TIM16 for STM32F0
|
||||
- TIM7 for STM32L0
|
||||
- LED light control
|
||||
- TIM17 for STM32F0
|
||||
- TIM22 for STM32L0
|
||||
@@ -0,0 +1,582 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="600"
|
||||
height="170"
|
||||
viewBox="0 0 158.75 44.97918"
|
||||
version="1.1"
|
||||
id="svg5625"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||
sodipodi:docname="charge-controller-structure.svg"
|
||||
inkscape:export-filename="/home/martin/test.png"
|
||||
inkscape:export-xdpi="200.1694"
|
||||
inkscape:export-ydpi="200.1694"
|
||||
style="enable-background:new">
|
||||
<defs
|
||||
id="defs5619">
|
||||
<marker
|
||||
inkscape:stockid="DotS"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="DotS"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path16850"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.2,0,0,0.2,1.48,0.2)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="DotM"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path16847"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-1"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-3"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-6"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7-6"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0-2"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7-6-1"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0-2-8"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0-20"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7-9-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0-20-2"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotM"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7066-2-7-9-9-3"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7064-7-0-20-2-6"
|
||||
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.0000001"
|
||||
inkscape:cx="290.19529"
|
||||
inkscape:cy="110.23898"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
showguides="false"
|
||||
inkscape:snap-grids="true"
|
||||
inkscape:snap-to-guides="true"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1156"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="0"
|
||||
units="px"
|
||||
scale-x="2">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid6225"
|
||||
spacingx="2.6458333"
|
||||
spacingy="2.6458333"
|
||||
dotted="false" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5622">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Martin Jäger</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Ebene 2"
|
||||
style="display:inline"
|
||||
transform="translate(0,-261.70842)" />
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-261.70842)">
|
||||
<rect
|
||||
style="display:inline;fill:none;fill-opacity:1;stroke:#6b6b6b;stroke-width:0.26458335;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
|
||||
id="rect6825"
|
||||
width="113.77083"
|
||||
height="26.458336"
|
||||
x="29.104166"
|
||||
y="269.6459"
|
||||
ry="0.076052353" />
|
||||
<rect
|
||||
style="display:inline;fill:none;fill-opacity:1;stroke:#005e85;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
|
||||
id="rect6825-9-8-36-1"
|
||||
width="50.270832"
|
||||
height="5.2916832"
|
||||
x="87.3125"
|
||||
y="280.22925"
|
||||
ry="0.01521052" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2);enable-background:new"
|
||||
d="M 68.79166,282.87508 H 58.208333"
|
||||
id="path6950-0"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<rect
|
||||
style="display:inline;fill:none;fill-opacity:1;stroke:#005e85;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
|
||||
id="rect6825-9-8-36-1-2"
|
||||
width="26.458338"
|
||||
height="5.2916832"
|
||||
x="34.395832"
|
||||
y="280.22925"
|
||||
ry="0.01521052" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-9);enable-background:new"
|
||||
d="m 79.375001,282.87509 h 10.58333"
|
||||
id="path6950-0-2"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-6);enable-background:new"
|
||||
d="m 39.687503,298.75008 -10e-7,-15.875"
|
||||
id="path6950-0-9-6"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7);enable-background:new"
|
||||
d="m 52.916666,290.8126 -10e-7,-7.9375"
|
||||
id="path6950-0-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 52.916669,290.8126 1.5875,2.11666"
|
||||
id="path2655"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 52.916669,293.45843 v 5.29166"
|
||||
id="path2657"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-6-1);enable-background:new"
|
||||
d="m 95.249999,298.75008 v -15.875"
|
||||
id="path6950-0-9-6-7"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9);enable-background:new"
|
||||
d="m 105.83333,290.8126 v -7.9375"
|
||||
id="path6950-0-9-3"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 105.83333,290.8126 1.5875,2.11666"
|
||||
id="path2655-7"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 105.83333,293.45843 v 5.29166"
|
||||
id="path2657-5"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9-9);enable-background:new"
|
||||
d="m 119.0625,290.8126 v -7.9375"
|
||||
id="path6950-0-9-3-8"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 119.0625,290.8126 1.5875,2.11666"
|
||||
id="path2655-7-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 119.0625,293.45843 v 5.29166"
|
||||
id="path2657-5-7"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9-9-3);enable-background:new"
|
||||
d="m 132.29166,290.8126 v -7.9375"
|
||||
id="path6950-0-9-3-8-2"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 132.29166,290.8126 1.5875,2.11666"
|
||||
id="path2655-7-9-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 132.29166,293.45843 v 5.29166"
|
||||
id="path2657-5-7-3"
|
||||
inkscape:connector-curvature="0" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#005e85;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
x="41.576717"
|
||||
y="278.35446"
|
||||
id="text3483"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3481"
|
||||
x="41.576717"
|
||||
y="278.35446"
|
||||
style="fill:#005e85;fill-opacity:1;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none">hv_bus</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#005e85;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
x="108.93037"
|
||||
y="278.27698"
|
||||
id="text3487"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3485"
|
||||
x="108.93037"
|
||||
y="278.27698"
|
||||
style="fill:#005e85;fill-opacity:1;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none">lv_bus</tspan></text>
|
||||
<g
|
||||
id="g3517"
|
||||
transform="matrix(1.3333333,0,0,1.3333336,12.347285,-124.27817)"
|
||||
style="stroke-width:0.74999994">
|
||||
<rect
|
||||
ry="0.022815673"
|
||||
y="301.39612"
|
||||
x="42.333282"
|
||||
height="7.9374866"
|
||||
width="7.9375014"
|
||||
id="rect6825-9-8-1"
|
||||
style="display:inline;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.19843747;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path7008"
|
||||
d="m 42.33328,309.33361 7.9375,-7.9375 v 0 0 0"
|
||||
style="display:inline;fill:none;stroke:#000000;stroke-width:0.19843747px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 43.920782,303.77737 h 1.984375"
|
||||
id="path7786"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 43.920782,302.58674 h 1.984375"
|
||||
id="path7788"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
|
||||
d="m 46.698908,308.14294 h 1.984375"
|
||||
id="path7786-1"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
|
||||
d="m 46.698908,306.95231 h 1.984375"
|
||||
id="path7788-9"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="93.662498"
|
||||
y="304.04181"
|
||||
id="text8274"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8272"
|
||||
x="93.662498"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">lv</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="101.59998"
|
||||
y="304.04181"
|
||||
id="text8278"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8276"
|
||||
x="101.59998"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">load</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="114.30003"
|
||||
y="304.04181"
|
||||
id="text8282"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8280"
|
||||
x="114.30003"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">pwm</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="129.1167"
|
||||
y="304.04181"
|
||||
id="text8286"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8284"
|
||||
x="129.1167"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">usb</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="47.095833"
|
||||
y="304.04181"
|
||||
id="text8290"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8288"
|
||||
x="47.095833"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">dump</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="38.099998"
|
||||
y="304.04181"
|
||||
id="text8294"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8292"
|
||||
x="38.099998"
|
||||
y="304.04181"
|
||||
style="stroke-width:0.26458332">hv</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="69.453125"
|
||||
y="275.73135"
|
||||
id="text8298"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan8296"
|
||||
x="69.453125"
|
||||
y="275.73135"
|
||||
style="stroke-width:0.26458332">dcdc</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
x="8.9222355"
|
||||
y="303.98309"
|
||||
id="text8548"><tspan
|
||||
sodipodi:role="line"
|
||||
x="8.9222355"
|
||||
y="303.98309"
|
||||
style="stroke-width:0.26458332"
|
||||
id="tspan8550">Power Ports:</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332;enable-background:new"
|
||||
x="29.10416"
|
||||
y="268.05841"
|
||||
id="text1902"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan1900"
|
||||
x="29.10416"
|
||||
y="268.05841"
|
||||
style="stroke-width:0.26458332">Charge Controller</tspan></text>
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 63.499999,282.87509 1.058323,0.66147 2.4e-5,-1.32291 z"
|
||||
id="path1050-1"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 84.666666,282.87509 -1.058323,-0.66147 -2.4e-5,1.32291 z"
|
||||
id="path1050-1-3"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 39.687499,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
|
||||
id="path1050-1-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 52.916669,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
|
||||
id="path1050-1-6-1"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 95.249999,288.16675 0.661475,-1.05832 -1.322915,-2e-5 z"
|
||||
id="path1050-1-6-1-0"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 105.83333,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
|
||||
id="path1050-1-6-1-0-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 119.0625,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
|
||||
id="path1050-1-6-1-0-6-3"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
|
||||
d="m 132.29167,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
|
||||
id="path1050-1-6-1-0-6-2"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -0,0 +1,81 @@
|
||||
# Firmware modules
|
||||
|
||||
## Data Acquisition
|
||||
|
||||
Files: daq*.h/cpp
|
||||
|
||||
Handles current and voltage measurement through the ADC with direct memory access (DMA). As a reference for current measurement, a digital-analog-converter (DAC) is used and also configured in this module.
|
||||
|
||||
The measurements are filtered and afterwards stored in the different sub-component objects.
|
||||
|
||||
## DC/DC converter
|
||||
|
||||
Files: dcdc.h/cpp
|
||||
|
||||
High-level functions to control the DC/DC converter. This module does not directly access any hardware. The PWM signal for the half bridge is generated in a separate module (see below).
|
||||
|
||||
## Data Objects for ThingSet protocol
|
||||
|
||||
Files: data_objects.h/cpp
|
||||
|
||||
The charge controller uses the [ThingSet protocol](https://thingset.github.io/) for communication with external devices. Internal data that should be exposed via the protocol is defined in the Data Objects module.
|
||||
|
||||
## Device status
|
||||
|
||||
Files: device_status.h/cpp
|
||||
|
||||
Stores global error flags and system-level measurements that are not specific to one sub-component.
|
||||
|
||||
## EEPROM
|
||||
|
||||
Files: eeprom.h/cpp
|
||||
|
||||
Stores data in ThingSet protocol format in the internal or external EEPROM (depending on the board).
|
||||
|
||||
## Half bridge
|
||||
|
||||
Files: half_bridge.h/cpp
|
||||
|
||||
Generates the synchronous PWM signal for the half bridge in the DC/DC converter. Depending on the MCU, either the advanced timer TIM1 or the basic timer TIM3 is used.
|
||||
|
||||
## LEDs
|
||||
|
||||
Files: leds.h/cpp
|
||||
|
||||
Provides higher-level access to different LEDs (e.g. blinking and flickering). Internally, charlieplexing is used to optimize power consumption and needed pin numbers.
|
||||
|
||||
## Load Output
|
||||
|
||||
Files: load*.h/cpp
|
||||
|
||||
Load output and USB charging output functions. Hardware-access is defined in load_drv.cpp file.
|
||||
|
||||
## Power Port and DC bus
|
||||
|
||||
Files: power_port.h/cpp
|
||||
|
||||
Contains DcBus and PowerPort classes. See [charger concepts](charger-concepts.md) for further details.
|
||||
|
||||
## PWM Switch
|
||||
|
||||
Files: pwm_switch.h/cpp
|
||||
|
||||
Only used for PWM solar charge controllers. This module is currently not yet separated into hardware-level and high-level functions.
|
||||
|
||||
## Timer configuration in mbed firmware
|
||||
|
||||
- mbed us_ticker (cannot be changed)
|
||||
- TIM2 for STM32F0
|
||||
- TIM21 for STM32L0
|
||||
- PWM generation for DC/DC half bridge (50-70 kHz)
|
||||
- TIM1 for STM32F0 (advanced timer)
|
||||
- TIM3 for STM32L0 (standard timer)
|
||||
- ADC and DMA (1 kHz)
|
||||
- TIM15 for STM32F0
|
||||
- TIM6 for STM32L0
|
||||
- DC/DC control function (10 Hz)
|
||||
- TIM16 for STM32F0
|
||||
- TIM7 for STM32L0
|
||||
- LED light control
|
||||
- TIM17 for STM32F0
|
||||
- TIM22 for STM32L0
|
||||
@@ -0,0 +1,20 @@
|
||||
# Zephyr cheat sheet
|
||||
|
||||
## West commands
|
||||
|
||||
Initial board selection
|
||||
|
||||
west build -b <board-name>
|
||||
|
||||
Flash with specific debug probe (runner), e.g. J-Link
|
||||
|
||||
west flash -r jlink
|
||||
|
||||
Report of used memory (RAM and flash)
|
||||
|
||||
west build -t rom_report
|
||||
west build -t ram_report
|
||||
|
||||
User configuration using menuconfig
|
||||
|
||||
west build -t menuconfig
|
||||
@@ -1,19 +0,0 @@
|
||||
# Custom script to generate src/version.h file containing the git commit hash
|
||||
#
|
||||
# See also http://docs.platformio.org/en/latest/projectconf.html#extra-script
|
||||
#
|
||||
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
|
||||
except:
|
||||
commit_hash = ""
|
||||
|
||||
f = open("src/version.h","w+")
|
||||
f.write("/* Auto-generated file with git commit hash to be included by C code\n")
|
||||
f.write(" * Do not change this file manually!\n")
|
||||
f.write(" */\n")
|
||||
f.write("\n")
|
||||
f.write('#define COMMIT_HASH "' + commit_hash.decode('utf-8') + '"\n')
|
||||
f.close
|
||||
@@ -1,442 +0,0 @@
|
||||
/***********************************
|
||||
This is a our graphics core library, for all our displays.
|
||||
We'll be adapting all the
|
||||
existing libaries to use this core to make updating, support
|
||||
and upgrading easier!
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
****************************************/
|
||||
|
||||
/*
|
||||
* Modified by Neal Horman 7/14/2012 for use in mbed
|
||||
*
|
||||
* Further modified by Martin Jäger (11/2019) to make it independent of mbed and useable in Zephyr
|
||||
*/
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "glcdfont.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if defined(GFX_WANT_ABSTRACTS)
|
||||
|
||||
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
|
||||
{
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
drawPixel(x0, y0+r, color);
|
||||
drawPixel(x0, y0-r, color);
|
||||
drawPixel(x0+r, y0, color);
|
||||
drawPixel(x0-r, y0, color);
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
drawPixel(x0 + x, y0 + y, color);
|
||||
drawPixel(x0 - x, y0 + y, color);
|
||||
drawPixel(x0 + x, y0 - y, color);
|
||||
drawPixel(x0 - x, y0 - y, color);
|
||||
drawPixel(x0 + y, y0 + x, color);
|
||||
drawPixel(x0 - y, y0 + x, color);
|
||||
drawPixel(x0 + y, y0 - x, color);
|
||||
drawPixel(x0 - y, y0 - x, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
|
||||
{
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
if (cornername & 0x4) {
|
||||
drawPixel(x0 + x, y0 + y, color);
|
||||
drawPixel(x0 + y, y0 + x, color);
|
||||
}
|
||||
|
||||
if (cornername & 0x2) {
|
||||
drawPixel(x0 + x, y0 - y, color);
|
||||
drawPixel(x0 + y, y0 - x, color);
|
||||
}
|
||||
|
||||
if (cornername & 0x8) {
|
||||
drawPixel(x0 - y, y0 + x, color);
|
||||
drawPixel(x0 - x, y0 + y, color);
|
||||
}
|
||||
|
||||
if (cornername & 0x1) {
|
||||
drawPixel(x0 - y, y0 - x, color);
|
||||
drawPixel(x0 - x, y0 - y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
|
||||
{
|
||||
drawFastVLine(x0, y0-r, 2*r+1, color);
|
||||
fillCircleHelper(x0, y0, r, 3, 0, color);
|
||||
}
|
||||
|
||||
// used to do circles and roundrects!
|
||||
void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
|
||||
{
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
if (cornername & 0x1) {
|
||||
drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);
|
||||
drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);
|
||||
}
|
||||
|
||||
if (cornername & 0x2) {
|
||||
drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);
|
||||
drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
|
||||
|
||||
// bresenham's algorithm - thx wikpedia
|
||||
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
|
||||
{
|
||||
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
|
||||
if (steep) {
|
||||
swap(x0, y0);
|
||||
swap(x1, y1);
|
||||
}
|
||||
|
||||
if (x0 > x1) {
|
||||
swap(x0, x1);
|
||||
swap(y0, y1);
|
||||
}
|
||||
|
||||
int16_t dx, dy;
|
||||
dx = x1 - x0;
|
||||
dy = abs(y1 - y0);
|
||||
|
||||
int16_t err = dx / 2;
|
||||
int16_t ystep;
|
||||
|
||||
if (y0 < y1)
|
||||
ystep = 1;
|
||||
else
|
||||
ystep = -1;
|
||||
|
||||
for (; x0<=x1; x0++)
|
||||
{
|
||||
if (steep)
|
||||
drawPixel(y0, x0, color);
|
||||
else
|
||||
drawPixel(x0, y0, color);
|
||||
|
||||
err -= dy;
|
||||
if (err < 0)
|
||||
{
|
||||
y0 += ystep;
|
||||
err += dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
|
||||
{
|
||||
// stupidest version - update in subclasses if desired!
|
||||
drawLine(x, y, x, y+h-1, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
|
||||
{
|
||||
// stupidest version - update in subclasses if desired!
|
||||
for (int16_t i=x; i<x+w; i++) {
|
||||
drawFastVLine(i, y, h, color);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GFX_WANT_ABSTRACTS)
|
||||
|
||||
void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
|
||||
{
|
||||
drawFastHLine(x, y, w, color);
|
||||
drawFastHLine(x, y+h-1, w, color);
|
||||
drawFastVLine(x, y, h, color);
|
||||
drawFastVLine(x+w-1, y, h, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
|
||||
{
|
||||
// stupidest version - update in subclasses if desired!
|
||||
drawLine(x, y, x+w-1, y, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillScreen(uint16_t color)
|
||||
{
|
||||
fillRect(0, 0, _width, _height, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
|
||||
{
|
||||
// smarter version
|
||||
drawFastHLine(x+r , y , w-2*r, color); // Top
|
||||
drawFastHLine(x+r , y+h-1, w-2*r, color); // Bottom
|
||||
drawFastVLine( x , y+r , h-2*r, color); // Left
|
||||
drawFastVLine( x+w-1, y+r , h-2*r, color); // Right
|
||||
// draw four corners
|
||||
drawCircleHelper(x+r , y+r , r, 1, color);
|
||||
drawCircleHelper(x+w-r-1, y+r , r, 2, color);
|
||||
drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
|
||||
drawCircleHelper(x+r , y+h-r-1, r, 8, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
|
||||
{
|
||||
// smarter version
|
||||
fillRect(x+r, y, w-2*r, h, color);
|
||||
|
||||
// draw four corners
|
||||
fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);
|
||||
fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
|
||||
{
|
||||
drawLine(x0, y0, x1, y1, color);
|
||||
drawLine(x1, y1, x2, y2, color);
|
||||
drawLine(x2, y2, x0, y0, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
|
||||
{
|
||||
int16_t a, b, y, last;
|
||||
|
||||
// Sort coordinates by Y order (y2 >= y1 >= y0)
|
||||
if (y0 > y1) {
|
||||
swap(y0, y1); swap(x0, x1);
|
||||
}
|
||||
|
||||
if (y1 > y2) {
|
||||
swap(y2, y1); swap(x2, x1);
|
||||
}
|
||||
|
||||
if (y0 > y1) {
|
||||
swap(y0, y1); swap(x0, x1);
|
||||
}
|
||||
|
||||
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
|
||||
a = b = x0;
|
||||
if (x1 < a)
|
||||
a = x1;
|
||||
else if (x1 > b)
|
||||
b = x1;
|
||||
|
||||
if (x2 < a)
|
||||
a = x2;
|
||||
else if (x2 > b) b = x2;
|
||||
drawFastHLine(a, y0, b-a+1, color);
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t
|
||||
dx01 = x1 - x0,
|
||||
dy01 = y1 - y0,
|
||||
dx02 = x2 - x0,
|
||||
dy02 = y2 - y0,
|
||||
dx12 = x2 - x1,
|
||||
dy12 = y2 - y1,
|
||||
sa = 0,
|
||||
sb = 0;
|
||||
|
||||
// For upper part of triangle, find scanline crossings for segments
|
||||
// 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1
|
||||
// is included here (and second loop will be skipped, avoiding a /0
|
||||
// error there), otherwise scanline y1 is skipped here and handled
|
||||
// in the second loop...which also avoids a /0 error here if y0=y1
|
||||
// (flat-topped triangle).
|
||||
if(y1 == y2)
|
||||
last = y1; // Include y1 scanline
|
||||
else
|
||||
last = y1-1; // Skip it
|
||||
|
||||
for(y=y0; y<=last; y++)
|
||||
{
|
||||
a = x0 + sa / dy01;
|
||||
b = x0 + sb / dy02;
|
||||
sa += dx01;
|
||||
sb += dx02;
|
||||
/* longhand:
|
||||
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
|
||||
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
||||
*/
|
||||
if(a > b)
|
||||
swap(a,b);
|
||||
drawFastHLine(a, y, b-a+1, color);
|
||||
}
|
||||
|
||||
// For lower part of triangle, find scanline crossings for segments
|
||||
// 0-2 and 1-2. This loop is skipped if y1=y2.
|
||||
sa = dx12 * (y - y1);
|
||||
sb = dx02 * (y - y0);
|
||||
for(; y <= y2; y++) {
|
||||
a = x1 + sa / dy12;
|
||||
b = x0 + sb / dy02;
|
||||
sa += dx12;
|
||||
sb += dx02;
|
||||
/* longhand:
|
||||
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
|
||||
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
||||
*/
|
||||
if(a > b)
|
||||
swap(a,b);
|
||||
drawFastHLine(a, y, b-a+1, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
|
||||
{
|
||||
for (int16_t j=0; j<h; j++) {
|
||||
for (int16_t i=0; i<w; i++ ) {
|
||||
if (bitmap[i + (j/8)*w] & _BV(j%8))
|
||||
drawPixel(x+i, y+j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Adafruit_GFX::writeChar(uint8_t c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
cursor_y += textsize*8;
|
||||
cursor_x = 0;
|
||||
}
|
||||
else if (c == '\r') {
|
||||
cursor_x = 0;
|
||||
|
||||
}
|
||||
else {
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
|
||||
cursor_x += textsize*6;
|
||||
if (wrap && (cursor_x > (_width - textsize*6)))
|
||||
{
|
||||
cursor_y += textsize*8;
|
||||
cursor_x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::writeString(const char *buf, size_t len)
|
||||
{
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
writeChar(buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
|
||||
{
|
||||
if ((x >= _width) || // Clip right
|
||||
(y >= _height) || // Clip bottom
|
||||
((x + 5 * size - 1) < 0) || // Clip left
|
||||
((y + 8 * size - 1) < 0)) // Clip top
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int8_t i = 0; i < 6; i++) {
|
||||
uint8_t line = 0;
|
||||
|
||||
if (i == 5) {
|
||||
line = 0x0;
|
||||
}
|
||||
else {
|
||||
line = font[(c*5)+i];
|
||||
}
|
||||
|
||||
for (int8_t j = 0; j<8; j++) {
|
||||
if (line & 0x1) {
|
||||
#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
|
||||
if (size == 1) // default size
|
||||
drawPixel(x+i, y+j, color);
|
||||
else // big size
|
||||
fillRect(x+(i*size), y+(j*size), size, size, color);
|
||||
#else
|
||||
drawPixel(x+i, y+j, color);
|
||||
#endif
|
||||
}
|
||||
else if (bg != color) {
|
||||
#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
|
||||
if (size == 1) // default size
|
||||
drawPixel(x+i, y+j, bg);
|
||||
else // big size
|
||||
fillRect(x+i*size, y+j*size, size, size, bg);
|
||||
#else
|
||||
drawPixel(x+i, y+j, bg);
|
||||
#endif
|
||||
}
|
||||
line >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setRotation(uint8_t x)
|
||||
{
|
||||
x %= 4; // cant be higher than 3
|
||||
rotation = x;
|
||||
switch (x)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
_width = _rawWidth;
|
||||
_height = _rawHeight;
|
||||
break;
|
||||
case 1:
|
||||
case 3:
|
||||
_width = _rawHeight;
|
||||
_height = _rawWidth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/***********************************
|
||||
This is a our graphics core library, for all our displays.
|
||||
We'll be adapting all the
|
||||
existing libaries to use this core to make updating, support
|
||||
and upgrading easier!
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
****************************************/
|
||||
|
||||
/*
|
||||
* Modified by Neal Horman 7/14/2012 for use in mbed
|
||||
*
|
||||
* Further modified by Martin Jäger (11/2019) to make it independent of mbed and useable in Zephyr
|
||||
*/
|
||||
|
||||
#ifndef ADAFRUIT_GFX_H_
|
||||
#define ADAFRUIT_GFX_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// Uncomment this to enable all functionality
|
||||
#define GFX_WANT_ABSTRACTS
|
||||
|
||||
static inline void swap(int16_t &a, int16_t &b)
|
||||
{
|
||||
int16_t t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
#ifndef _BV
|
||||
#define _BV(bit) (1<<(bit))
|
||||
#endif
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
|
||||
/**
|
||||
* This is a Text and Graphics element drawing class.
|
||||
* These functions draw to the display buffer.
|
||||
*
|
||||
* Display drivers should be derived from here.
|
||||
* The Display drivers push the display buffer to the
|
||||
* hardware based on application control.
|
||||
*
|
||||
*/
|
||||
class Adafruit_GFX
|
||||
{
|
||||
public:
|
||||
Adafruit_GFX(int16_t w, int16_t h) :
|
||||
_rawWidth(w),
|
||||
_rawHeight(h),
|
||||
_width(w),
|
||||
_height(h),
|
||||
cursor_x(0),
|
||||
cursor_y(0),
|
||||
textcolor(WHITE),
|
||||
textbgcolor(BLACK),
|
||||
textsize(1),
|
||||
rotation(0),
|
||||
wrap(true)
|
||||
{};
|
||||
|
||||
/// Paint one BLACK or WHITE pixel in the display buffer
|
||||
// this must be defined by the subclass
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
||||
|
||||
// this is optional
|
||||
virtual void invert(bool i) {};
|
||||
|
||||
#ifdef GFX_WANT_ABSTRACTS
|
||||
// these are 'generic' drawing functions, so we can share them!
|
||||
|
||||
/** Draw a Horizontal Line
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
/** Draw a rectangle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
|
||||
/** Fill the entire display
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void fillScreen(uint16_t color);
|
||||
|
||||
/** Draw a circle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
|
||||
|
||||
/** Draw and fill a circle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
|
||||
|
||||
/** Draw a triangle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
|
||||
|
||||
/** Draw and fill a triangle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
|
||||
|
||||
/** Draw a rounded rectangle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
|
||||
|
||||
/** Draw and fill a rounded rectangle
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
|
||||
|
||||
/** Draw a bitmap
|
||||
* @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
|
||||
#endif
|
||||
|
||||
#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
|
||||
/** Draw a line
|
||||
* @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
|
||||
|
||||
/** Draw a vertical line
|
||||
* @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
|
||||
/** Draw and fill a rectangle
|
||||
* @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
|
||||
*/
|
||||
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
#endif
|
||||
|
||||
/// Draw a text character at a specified pixel location
|
||||
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
|
||||
|
||||
/// Draw a text character at the text cursor location
|
||||
void writeChar(uint8_t);
|
||||
|
||||
/// Draw a string at the text cursor location
|
||||
void writeString(const char *buf, size_t len);
|
||||
|
||||
/// Get the width of the display in pixels
|
||||
inline int16_t width(void) { return _width; };
|
||||
|
||||
/// Get the height of the display in pixels
|
||||
inline int16_t height(void) { return _height; };
|
||||
|
||||
/// Set the text cursor location, based on the size of the text
|
||||
inline void setTextCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; };
|
||||
|
||||
#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
|
||||
/** Set the size of the text to be drawn
|
||||
* @note Make sure to enable either GFX_SIZEABLE_TEXT or GFX_WANT_ABSTRACTS
|
||||
*/
|
||||
inline void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; };
|
||||
#endif
|
||||
|
||||
/// Set the text foreground and background colors to be the same
|
||||
inline void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; }
|
||||
|
||||
/// Set the text foreground and background colors independantly
|
||||
inline void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; };
|
||||
|
||||
/// Set text wraping mode true or false
|
||||
inline void setTextWrap(bool w) { wrap = w; };
|
||||
|
||||
/// Set the display rotation, 1, 2, 3, or 4
|
||||
void setRotation(uint8_t r);
|
||||
|
||||
/// Get the current rotation
|
||||
inline uint8_t getRotation(void) { rotation %= 4; return rotation; };
|
||||
|
||||
protected:
|
||||
int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes
|
||||
int16_t _width, _height; // dependent on rotation
|
||||
int16_t cursor_x, cursor_y;
|
||||
uint16_t textcolor, textbgcolor;
|
||||
uint8_t textsize;
|
||||
uint8_t rotation;
|
||||
bool wrap; // If set, 'wrap' text at right edge of display
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012 Adafruit Industries. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2012 Adafruit Industries. All rights reserved.
|
||||
*
|
||||
* This class is partly based on the library developed by Adafruit and modified by Neal Horman
|
||||
* 7/14/2012 for use in mbed.
|
||||
*
|
||||
* Significant modifications were done by Martin Jäger (11/2019) to use it also in Zephyr
|
||||
*/
|
||||
|
||||
#include "OledSSD1306.h"
|
||||
#include "logo.h"
|
||||
|
||||
#define SSD1306_SETCONTRAST 0x81
|
||||
#define SSD1306_DISPLAYALLON_RESUME 0xA4
|
||||
#define SSD1306_DISPLAYALLON 0xA5
|
||||
#define SSD1306_NORMALDISPLAY 0xA6
|
||||
#define SSD1306_INVERTDISPLAY 0xA7
|
||||
#define SSD1306_DISPLAYOFF 0xAE
|
||||
#define SSD1306_DISPLAYON 0xAF
|
||||
#define SSD1306_SETDISPLAYOFFSET 0xD3
|
||||
#define SSD1306_SETCOMPINS 0xDA
|
||||
#define SSD1306_SETVCOMDETECT 0xDB
|
||||
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
|
||||
#define SSD1306_SETPRECHARGE 0xD9
|
||||
#define SSD1306_SETMULTIPLEX 0xA8
|
||||
#define SSD1306_SETLOWCOLUMN 0x00
|
||||
#define SSD1306_SETHIGHCOLUMN 0x10
|
||||
#define SSD1306_SETSTARTLINE 0x40
|
||||
#define SSD1306_MEMORYMODE 0x20
|
||||
#define SSD1306_COMSCANINC 0xC0
|
||||
#define SSD1306_COMSCANDEC 0xC8
|
||||
#define SSD1306_SEGREMAP 0xA0
|
||||
#define SSD1306_CHARGEPUMP 0x8D
|
||||
|
||||
#if defined(__MBED__)
|
||||
|
||||
OledSSD1306::OledSSD1306(I2C &i2c, uint8_t i2cAddress) :
|
||||
Adafruit_GFX(SSD1306_WIDTH, SSD1306_HEIGHT),
|
||||
_i2c(i2c),
|
||||
_i2cAddress(i2cAddress)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
#elif defined(__ZEPHYR__)
|
||||
|
||||
OledSSD1306::OledSSD1306(const char *i2c_name, uint8_t i2cAddress) :
|
||||
Adafruit_GFX(SSD1306_WIDTH, SSD1306_HEIGHT),
|
||||
_i2cAddress(i2cAddress)
|
||||
{
|
||||
_i2c = device_get_binding(i2c_name);
|
||||
if (!_i2c) {
|
||||
printk("I2C: Device driver not found.\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void OledSSD1306::init(uint8_t brightness)
|
||||
{
|
||||
command(SSD1306_DISPLAYOFF);
|
||||
command(SSD1306_SETDISPLAYCLOCKDIV);
|
||||
command(0x80); // the suggested ratio 0x80
|
||||
|
||||
command(SSD1306_SETMULTIPLEX);
|
||||
command(_rawHeight-1);
|
||||
|
||||
command(SSD1306_SETDISPLAYOFFSET);
|
||||
command(0x0); // no offset
|
||||
|
||||
command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
|
||||
command(SSD1306_CHARGEPUMP);
|
||||
command((SSD1306_SWITCHCAPVCC == SSD1306_EXTERNALVCC) ? 0x10 : 0x14);
|
||||
|
||||
command(SSD1306_MEMORYMODE);
|
||||
command(0x00); // 0x0 act like ks0108
|
||||
|
||||
command(SSD1306_SEGREMAP | 0x1);
|
||||
|
||||
command(SSD1306_COMSCANDEC);
|
||||
|
||||
command(SSD1306_SETCOMPINS);
|
||||
command(_rawHeight == 32 ? 0x02 : 0x12); // TODO - calculate based on _rawHieght ?
|
||||
|
||||
command(SSD1306_SETCONTRAST);
|
||||
command(_rawHeight == 32 ? 0x8F : ((SSD1306_SWITCHCAPVCC == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF) );
|
||||
|
||||
command(SSD1306_SETPRECHARGE);
|
||||
command((SSD1306_SWITCHCAPVCC == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1);
|
||||
|
||||
command(SSD1306_SETVCOMDETECT);
|
||||
command(0x40);
|
||||
|
||||
command(SSD1306_DISPLAYALLON_RESUME);
|
||||
|
||||
command(SSD1306_NORMALDISPLAY);
|
||||
|
||||
command(SSD1306_DISPLAYON);
|
||||
|
||||
// make sure that display has not shifted even without power on reset
|
||||
command(0x22);
|
||||
command(0x00);
|
||||
command(0x07);
|
||||
|
||||
command(SSD1306_SETCONTRAST);
|
||||
command(brightness);
|
||||
|
||||
splash();
|
||||
display();
|
||||
}
|
||||
|
||||
void OledSSD1306::drawPixel(int16_t x, int16_t y, uint16_t color)
|
||||
{
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
switch (getRotation())
|
||||
{
|
||||
case 1:
|
||||
swap(x, y);
|
||||
x = _rawWidth - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = _rawWidth - x - 1;
|
||||
y = _rawHeight - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
swap(x, y);
|
||||
y = _rawHeight - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// x is which column
|
||||
if (color == WHITE) {
|
||||
buffer[x + (y/8)*_rawWidth] |= _BV((y % 8));
|
||||
}
|
||||
else {
|
||||
buffer[x + (y/8)*_rawWidth] &= ~_BV((y % 8));
|
||||
}
|
||||
}
|
||||
|
||||
void OledSSD1306::invert(bool i)
|
||||
{
|
||||
command(i ? SSD1306_INVERTDISPLAY : SSD1306_NORMALDISPLAY);
|
||||
}
|
||||
|
||||
// Send the display buffer out to the display
|
||||
void OledSSD1306::display(void)
|
||||
{
|
||||
command(SSD1306_SETLOWCOLUMN | 0x0); // low col = 0
|
||||
command(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0
|
||||
command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
sendBuffer();
|
||||
}
|
||||
|
||||
void OledSSD1306::clear(void)
|
||||
{
|
||||
std::fill(buffer.begin(), buffer.end(), 0);
|
||||
}
|
||||
|
||||
void OledSSD1306::splash(void)
|
||||
{
|
||||
std::copy(&logo[0], &logo[0] + sizeof(logo), buffer.begin());
|
||||
}
|
||||
|
||||
void OledSSD1306::command(uint8_t c)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
buf[0] = 0; // Command Mode
|
||||
buf[1] = c;
|
||||
#if defined(__MBED__)
|
||||
_i2c.write(_i2cAddress, (char *)buf, sizeof(buf));
|
||||
#elif defined(__ZEPHYR__)
|
||||
i2c_write(_i2c, buf, sizeof(buf), _i2cAddress);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OledSSD1306::data(uint8_t c)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
buf[0] = 0x40; // Data Mode
|
||||
buf[1] = c;
|
||||
#if defined(__MBED__)
|
||||
_i2c.write(_i2cAddress, (char *)buf, sizeof(buf));
|
||||
#elif defined(__ZEPHYR__)
|
||||
i2c_write(_i2c, buf, sizeof(buf), _i2cAddress);
|
||||
#endif
|
||||
};
|
||||
|
||||
void OledSSD1306::sendBuffer()
|
||||
{
|
||||
uint8_t buf[17];
|
||||
buf[0] = 0x40; // Data Mode
|
||||
|
||||
// send display buffer in 16 byte chunks
|
||||
for (uint16_t i = 0; i < buffer.size(); i += 16)
|
||||
{
|
||||
for(uint8_t x = 1; x < sizeof(buf); x++) {
|
||||
uint16_t pos = i + x - 1;
|
||||
if (buffer.size() > pos) {
|
||||
buf[x] = buffer[pos];
|
||||
}
|
||||
}
|
||||
#if defined(__MBED__)
|
||||
_i2c.write(_i2cAddress, (char *)buf, sizeof(buf));
|
||||
#elif defined(__ZEPHYR__)
|
||||
i2c_write(_i2c, buf, sizeof(buf), _i2cAddress);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2012 Adafruit Industries. All rights reserved.
|
||||
*
|
||||
* This class is partly based on the library developed by Adafruit and modified by Neal Horman
|
||||
* 7/14/2012 for use in mbed.
|
||||
*
|
||||
* Significant modifications were done by Martin Jäger (11/2019) to use it also in Zephyr
|
||||
*/
|
||||
|
||||
#ifndef OLEDSSD1306_H_
|
||||
#define OLEDSSD1306_H_
|
||||
|
||||
#if defined(__MBED__)
|
||||
#include "mbed.h"
|
||||
#elif defined(__ZEPHYR__)
|
||||
#include <zephyr.h>
|
||||
#include <drivers/i2c.h>
|
||||
#endif
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
#define SSD1306_I2C_ADDRESS 0x3c // needs to be left-shifted by 1 for mbed (=0x78)
|
||||
|
||||
#define SSD1306_WIDTH 128
|
||||
#define SSD1306_HEIGHT 64
|
||||
|
||||
#define SSD1306_EXTERNALVCC 0x1
|
||||
#define SSD1306_SWITCHCAPVCC 0x2
|
||||
|
||||
/** SSD1306 OLED display driver based on Adafruit GFX library
|
||||
*/
|
||||
class OledSSD1306 : public Adafruit_GFX
|
||||
{
|
||||
public:
|
||||
/** Create a SSD1306 I2C transport display driver instance
|
||||
*
|
||||
* @param i2c A reference to an initialized I2C object
|
||||
* @param i2cAddress The i2c address of the display
|
||||
* @param brightness Sets contrast between 0x01-0xFF or 1-255
|
||||
*/
|
||||
#if defined(__MBED__)
|
||||
OledSSD1306(I2C &i2c, uint8_t i2cAddress = (SSD1306_I2C_ADDRESS << 1));
|
||||
#elif defined(__ZEPHYR__)
|
||||
OledSSD1306(const char *i2c_name, uint8_t i2cAddress = SSD1306_I2C_ADDRESS);
|
||||
#endif
|
||||
|
||||
void init(uint8_t brightness = 0x01);
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
void clear(void);
|
||||
|
||||
void invert(bool i);
|
||||
|
||||
/// Cause the display to be updated with the buffer content.
|
||||
void display();
|
||||
|
||||
/// Fill the buffer with the logo splash screen.
|
||||
void splash();
|
||||
|
||||
void command(uint8_t c);
|
||||
|
||||
void data(uint8_t c);
|
||||
|
||||
protected:
|
||||
void sendBuffer();
|
||||
|
||||
std::array<uint8_t, SSD1306_HEIGHT * SSD1306_WIDTH / 8> buffer;
|
||||
|
||||
#if defined(__MBED__)
|
||||
I2C &_i2c;
|
||||
#elif defined(__ZEPHYR__)
|
||||
struct device *_i2c;
|
||||
#endif
|
||||
|
||||
uint8_t _i2cAddress;
|
||||
};
|
||||
|
||||
#endif // OLEDSSD1306_H_
|
||||
@@ -1,272 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2012 Adafruit Industries. All rights reserved.
|
||||
*/
|
||||
|
||||
// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
|
||||
// See gfxfont.h for newer custom bitmap font info.
|
||||
|
||||
#ifndef FONT5X7_H
|
||||
#define FONT5X7_H
|
||||
|
||||
// Standard ASCII 5x7 font
|
||||
static const unsigned char font[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
|
||||
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
|
||||
};
|
||||
#endif // FONT5X7_H
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Jäger / Libre Solar
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t logo[64 * 128 / 8] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F,
|
||||
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0xE7, 0xC7,
|
||||
0xC3, 0x87, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1E, 0x1F, 0x1F, 0x3F,
|
||||
0x3E, 0x7E, 0x7E, 0xFC, 0xFC, 0xF8, 0xF0, 0xC0, 0x01, 0x03, 0x87, 0x87, 0x87, 0x87, 0x87, 0x00,
|
||||
0x30, 0x30, 0x30, 0x20, 0x20, 0x60, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE,
|
||||
0xFE, 0xFC, 0xF8, 0xF0, 0xE3, 0xC7, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x03, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x60, 0xC0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x80, 0xC0,
|
||||
0x60, 0x20, 0x20, 0x20, 0x20, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x60, 0x20,
|
||||
0x20, 0x60, 0x40, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xE0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x60, 0x40, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x77,
|
||||
0xC0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x30, 0xD0, 0x08, 0x04, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F,
|
||||
0x08, 0x18, 0x18, 0x10, 0x10, 0x30, 0xE0, 0x80, 0x00, 0x00, 0x10, 0xFF, 0x81, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC7, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x8F, 0x81, 0x80, 0x87, 0x9C, 0xF0, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0x30, 0xF0, 0x88, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0C, 0x06,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0E, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x02, 0x06,
|
||||
0x04, 0x04, 0x0C, 0x04, 0x04, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x04, 0x0C,
|
||||
0x0C, 0x04, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
|
||||
0x0C, 0x0C, 0x00, 0x08, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x0C, 0x00,
|
||||
0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
@@ -1,215 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Jäger / Libre Solar
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "ESP32.h"
|
||||
#include "mbed.h"
|
||||
|
||||
ESP32::ESP32(UARTSerial &s) :
|
||||
_serial(s),
|
||||
_at(&_serial, "\r\n", 200, 4000)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ESP32::~ESP32()
|
||||
{ }
|
||||
|
||||
// Soft reset of ESP32
|
||||
int ESP32::reset(void)
|
||||
{
|
||||
_at.set_timeout(3000);
|
||||
_at.send("AT+RST");
|
||||
|
||||
char buf[100];
|
||||
_at.read(buf, sizeof(buf));
|
||||
printf(buf);
|
||||
|
||||
return _at.recv("ready");
|
||||
}
|
||||
|
||||
void ESP32::print_firmware()
|
||||
{
|
||||
_at.set_timeout(1000);
|
||||
char buf[100];
|
||||
_at.send("AT+GMR");
|
||||
_at.read(buf, sizeof(buf));
|
||||
printf(buf);
|
||||
}
|
||||
|
||||
int ESP32::set_wifi_mode(ESP32_wifi_mode_t mode)
|
||||
{
|
||||
_at.set_timeout(1000);
|
||||
_at.flush();
|
||||
_at.send("AT+CWMODE=%d", mode);
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
void ESP32::list_APs(char *buf, int size)
|
||||
{
|
||||
_at.set_timeout(5000); // use long timeout
|
||||
_at.send("AT+CWLAP");
|
||||
_at.read(buf, size);
|
||||
}
|
||||
|
||||
int ESP32::join_AP(const char *ssid, const char *pwd)
|
||||
{
|
||||
_at.set_timeout(2000);
|
||||
_at.send("AT+CWJAP=\"%s\",\"%s\"", ssid, pwd);
|
||||
char buf[100];
|
||||
_at.read(buf, sizeof(buf));
|
||||
printf(buf);
|
||||
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::quit_AP(void)
|
||||
{
|
||||
_at.send("AT+CWQAP");
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::get_IP(char *ip, int size)
|
||||
{
|
||||
int ip_arr[4] = {0};
|
||||
|
||||
_at.set_timeout(500);
|
||||
_at.flush();
|
||||
_at.send("AT+CIFSR");
|
||||
// valid answer:
|
||||
// +CIFSR:STAIP,"192.168.178.50"
|
||||
// +CIFSR:STAMAC,"30:ae:a4:c3:70:88"
|
||||
//
|
||||
// OK
|
||||
|
||||
// hack to obtain IP address, as _at.recv seems to contain a bug (it returns 192.168.0.4 instead of 192.168.0.43)
|
||||
char buf[100];
|
||||
char *ip_start = buf;
|
||||
_at.read(buf, sizeof(buf));
|
||||
//printf(buf);
|
||||
for (unsigned int i = 0; i < sizeof(buf); i++) {
|
||||
if (strncmp(&buf[i], "busy now", 8) == 0) {
|
||||
printf("IP busy now!!\n");
|
||||
snprintf(ip, size, "ERROR");
|
||||
_at.flush();
|
||||
return 0;
|
||||
}
|
||||
else if (buf[i] < '0' || buf[i] > '9') { // find first numeric character
|
||||
ip_start++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
int res = sscanf(ip_start, "%d.%d.%d.%d", &ip_arr[0], &ip_arr[1], &ip_arr[2], &ip_arr[3]);
|
||||
|
||||
// TODO: figure out bug in _at.recv and correct it
|
||||
//int res = _at.recv("%d.%d.%d.%d\r", &ip_arr[0], &ip_arr[1], &ip_arr[2], &ip_arr[3]);
|
||||
|
||||
if (res > 0)
|
||||
snprintf(ip, size, "%d.%d.%d.%d", ip_arr[0], ip_arr[1], ip_arr[2], ip_arr[3]);
|
||||
else
|
||||
snprintf(ip, size, "ERROR");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ESP32::ping(const char *ip)
|
||||
{
|
||||
_at.set_timeout(2000);
|
||||
_at.send("AT+PING=\"%s\"", ip);
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::set_single()
|
||||
{
|
||||
_at.send("AT+CIPMUX=0");
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::set_multiple()
|
||||
{
|
||||
_at.send("AT+CIPMUX=1");
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::get_conn_status()
|
||||
{
|
||||
int status = -1;
|
||||
_at.set_timeout(2000);
|
||||
_at.flush();
|
||||
_at.send("AT+CIPSTATUS");
|
||||
//char buf[100];
|
||||
//_at.read(buf, sizeof(buf));
|
||||
//printf(buf);
|
||||
_at.recv("STATUS:%d", &status);
|
||||
return status;
|
||||
}
|
||||
|
||||
int ESP32::set_ip_mode(ESP32_ip_mode_t mode)
|
||||
{
|
||||
_at.set_timeout(500);
|
||||
_at.send("AT+CIPMODE=%d", mode);
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::start_TCP_conn(const char *ip, const char *port, bool ssl)
|
||||
{
|
||||
_at.set_timeout(2000);
|
||||
if (ssl) {
|
||||
printf("Setting SSL conf... ");
|
||||
_at.send("AT+CIPSSLCCONF=0");
|
||||
int res = _at.recv("OK");
|
||||
printf((res > 0) ? "OK\n" : "ERROR\n");
|
||||
_at.send("AT+CIPSTART=\"SSL\",\"%s\",%s", ip, port);
|
||||
}
|
||||
else {
|
||||
_at.send("AT+CIPSTART=\"TCP\",\"%s\",%s", ip, port);
|
||||
}
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::close_TCP_conn()
|
||||
{
|
||||
_at.set_timeout(500);
|
||||
_at.send("AT+CIPCLOSE");
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::send_URL(char *url, char *host)
|
||||
{
|
||||
char request[500];
|
||||
snprintf(request, sizeof(request), "GET %s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n", url, host);
|
||||
|
||||
_at.send("AT+CIPSEND=%d", strlen(request));
|
||||
_at.recv("> ");
|
||||
|
||||
_at.send(request);
|
||||
return _at.recv("SEND OK");
|
||||
}
|
||||
|
||||
int ESP32::send_TCP_data(uint8_t *data, int length)
|
||||
{
|
||||
_at.send("AT+CIPSEND=%d", length);
|
||||
_at.recv("> ");
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
_at.putc(data[i]);
|
||||
}
|
||||
return _at.recv("SEND OK");
|
||||
}
|
||||
|
||||
int ESP32::start_TCP_server(int port)
|
||||
{
|
||||
_at.set_timeout(500);
|
||||
_at.send("AT+CIPSERVER=1,%d", port);
|
||||
return _at.recv("OK");
|
||||
}
|
||||
|
||||
int ESP32::close_TCP_server()
|
||||
{
|
||||
_at.set_timeout(500);
|
||||
_at.send("AT+CIPSERVER=0");
|
||||
return _at.recv("OK");
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Martin Jäger / Libre Solar
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP32_H__
|
||||
#define __ESP32_H__
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
enum ESP32_status_t {
|
||||
ESP32_STATUS_AP_CONNECTED = 2,
|
||||
ESP32_STATUS_TCP_ACTIVE,
|
||||
ESP32_STATUS_TCP_DIS,
|
||||
ESP32_STATUS_AP_DISCONNECTED
|
||||
};
|
||||
|
||||
enum ESP32_wifi_mode_t {
|
||||
ESP32_WIFI_MODE_NULL = 0,
|
||||
ESP32_WIFI_MODE_STATION,
|
||||
ESP32_WIFI_MODE_SOFTAP,
|
||||
ESP32_WIFI_MODE_BOTH
|
||||
};
|
||||
|
||||
enum ESP32_ip_mode_t {
|
||||
ESP32_IP_MODE_NORMAL = 0,
|
||||
ESP32_IP_MODE_PASSTHROUGH
|
||||
};
|
||||
|
||||
class ESP32
|
||||
{
|
||||
public:
|
||||
ESP32(UARTSerial &s);
|
||||
~ESP32();
|
||||
|
||||
int reset();
|
||||
void print_firmware();
|
||||
|
||||
int set_wifi_mode(ESP32_wifi_mode_t mode);
|
||||
int get_conn_status();
|
||||
void list_APs(char *buf, int size);
|
||||
int join_AP(const char *id, const char *pwd);
|
||||
int quit_AP();
|
||||
|
||||
int get_IP(char* ip, int size);
|
||||
int ping(const char* ip);
|
||||
|
||||
int set_single();
|
||||
int set_multiple();
|
||||
|
||||
int set_ip_mode(ESP32_ip_mode_t mode);
|
||||
|
||||
int start_TCP_conn(const char *ip, const char *port, bool ssl=false);
|
||||
int close_TCP_conn();
|
||||
int send_URL(char *url, char *host);
|
||||
int send_TCP_data(uint8_t *data, int length);
|
||||
|
||||
int start_TCP_server(int port);
|
||||
int close_TCP_server();
|
||||
|
||||
private:
|
||||
UARTSerial &_serial;
|
||||
ATCmdParser _at;
|
||||
};
|
||||
|
||||
#endif /* __ESP32_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user