Compare commits

...

59 Commits

Author SHA1 Message Date
discip
107ed7ea70 Revert "Translations/: set Zzzz as SleepingSimpleString in all translations for unification" 2024-01-10 22:53:24 +01:00
discip
a1fb535d50 Merge pull request #1866 from ia/z-sleep
Translations/: set Zzzz as SleepingSimpleString in all translations for unification
2024-01-10 07:19:18 +01:00
Ivan Zorin
e7fd88be1e Translations/: change Zzzz to Zzz as SleepingSimpleString in all translations for unification & update maxLen for SleepingSimpleString 2024-01-10 05:11:55 +03:00
discip
fa762d42ec Merge branch 'dev' into z-sleep 2024-01-09 21:18:51 +01:00
discip
5db70c48f6 Merge pull request #1867 from eslng/uk-translation-2
Update translation_UK.json
2024-01-09 21:18:20 +01:00
yegor
f0340488e5 Update translation_UK.json 2024-01-09 22:13:15 +02:00
Ivan Zorin
aebbd28741 Translations/: set Zzzz as SleepingSimpleString in all translations for unification 2024-01-09 13:25:21 +03:00
discip
7d9bbbcd9f Merge pull request #1863 from ColoMAX/DjedenOfficial/dev
Dutch translations
2024-01-08 19:52:47 +01:00
discip
38a3696df8 Merge branch 'dev' into DjedenOfficial/dev 2024-01-02 17:41:50 +01:00
discip
166cf934ea Merge pull request #1864 from NunkyJoe/patch-1
Update translation_RU.json. Fixed a phrase that was too long causing …
2024-01-02 16:12:27 +01:00
NunkyJoe
00836793e0 Update translation_RU.json. Fixed a phrase that was too long causing temperature values to not fit on the sleep screen.
The sleep indication phrase in simple mode is too long "Хххррп". The temperature value does not fit on the screen. Replaced it with the original phrase "Zzzz", understandable in all languages.
2024-01-01 14:47:57 +03:00
Max Suurland
8126535a60 Merge branch 'DjedenOfficial/dev' of https://github.com/ColoMAX/IronOS into DjedenOfficial/dev 2023-12-29 11:33:25 +01:00
Max Suurland
4ebb6b81a7 Some messages were cut-ff 2023-12-29 11:29:59 +01:00
discip
37a78e4c97 Merge branch 'dev' into DjedenOfficial/dev 2023-12-29 01:00:53 +01:00
Max Suurland
411ac2d24b Fixed some wrong spelling and totally wrong translations.
Added some missing translations.
Modified single char option in menu.
Not tested on display.
2023-12-28 21:20:22 +01:00
discip
c914ca3969 Merge pull request #1862 from LasseVa/dev
Add Estonian translation
2023-12-28 01:43:31 +01:00
Lasse
3c761bdcd1 Update translation_ET.json 2023-12-28 01:10:39 +02:00
discip
3b9c63a0a9 Merge branch 'dev' into dev 2023-12-27 22:50:35 +01:00
discip
2344194f22 corrected some formatting issues 2023-12-27 22:38:08 +01:00
Lasse
e2cf2adc10 Update translation_ET.json 2023-12-27 19:37:59 +02:00
Lasse
ca128ceab8 Update translation_ET.json 2023-12-27 19:35:53 +02:00
Lasse
8aa0802521 Add files via upload 2023-12-27 19:33:40 +02:00
Ivan Zorin
624674a479 UploadV4 metadata workaround (#1855)
* chore(deps): bump actions/upload-artifact from 3 to 4

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* push.yml: split metadata artifacts into two separated packages since now it's error by design in uploadV4 to stuff multiple files from different jobs/steps into artifact with the same name

* push.yml: add metadata per model artifact since now it's error by design in uploadV4 to stuff multiple files from different jobs/steps into one artifact with the same name

* push.yml: testing proposed by github solution for actions:#472

* push.yml: "fixing" upload as github team suggested

* push.yml: rename upload metadata step to unify build steps naming pattern

* push.yml: upload_metadata: add if-no-files-found: error directive since metadata.zip is essential

* push.yml: giving a second chance for cache save/restore actions

* push.yml: remove unsupported name field from cache actions

* push.yml: add tar to deps so cache action can collect cached files on github

* push.yml: try to retrieve cache by key properly

* push.yml: try to retrieve cache by key properly

* push.yml: remove wildcards from keys

* push.yml: try retrieve cache by explicit name

* push.yml: trying with enableCrossOsArchive == true

* push.yml: revert changes back from cache save/restore to actions download/upload

* push.yml: set retention-days == 1 and testing dot file name hoping it will hide artifacts

* push.yml: upload_metadata - download jsons: fix pattern for testing

* push.yml: adding 3rd party step for testing to delete created artifacts

* push.yml: trying to fix syntax in 3rd party step

* push.yml: revert changes to working workaround but keep retention-days == 1

* push.yml: upload_metadata: download prebuilt artifacts, generate jsons, upload them as metadata.zip - Work in Progress

* push.yml: upload_metadata: trying to fix pattern for artifacts [WiP]

* push.yml: upload_metadata: remove matrix since it doesn't work [WiP]

* push.yml: upload_metadata: remove pattern to download all prebuilt artifacts

* push.yml: add every json to every model of artifact

* push.yml: remove uploading/reuploading individual json files as zips

* push.yml: pushing to see which error will be at this time...

* ci

* Revert "push.yml: pushing to see which error will be at this time..."

This reverts commit ed3ac204ca.

* push.yml: revert manually due to accidential commit from different branch of different repo

* Remove the image of my frustration with github checkout update

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
2023-12-27 10:21:02 +11:00
Ben V. Brown
8ebd3e3eed Update ubuntu base image for github CI 2023-12-27 09:28:24 +11:00
Ben V. Brown
ec5f07ec0c Cleanup make includes and formatting rules (#1860)
* Draft cleanup of the folder definition mess

* Move old startup

* Fixup! broken hacky includes

* Update Makefile

* Update Makefile

* Update Makefile

* Bulk format

* Who knew, header guards are a wise idea

* Squash some sizing warnings

* Drop broken usb stack

* Fix BLE headers to be sensible

* Cleaning up proper c styling

* We have newer clang, it does bracketing now

* Run clang-format brackets

* We can drop the old messy bracket-checker with newer clang format

* WiP formatter

* Align grids of scripts by right side

Massively easier to read in nearly all cases

* Excempt the table for compression from formatter
2023-12-27 09:23:12 +11:00
Ben V. Brown
849d1f7d40 Update compilers (#1858)
* Update Alpine Image

* Update push.yml

* Style updates
2023-12-26 19:54:47 +11:00
Ivan Zorin
9931afdb0f Settings: disable Bluetooth LE by default (for PinecilV2) #1856 (#1857) 2023-12-19 14:16:57 +11:00
Ben V. Brown
8ea79e3f7d MHP30: GD32 doesnt implement analog mode (#1845) 2023-12-19 13:53:03 +11:00
dependabot[bot]
9d2f90b140 chore(deps): bump actions/setup-python from 4 to 5 (#1852)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-12 06:45:38 +11:00
discip
19f909e5ed Merge branch 'dev' into dev 2023-12-11 08:03:05 +01:00
Ben V. Brown
ea72aea47d Enforce no EPR polling for non >20V devices 2023-12-09 23:02:20 +11:00
discip
698026eb36 Merge branch 'dev' into dev 2023-11-29 18:02:36 +01:00
discip
20ad63d020 Merge pull request #1850 from dmitrygribenchuk/dev
update translation_BE.json
2023-11-29 10:10:29 +01:00
Dmitry Gribenchuk
79a887718b update translation_BE.json 2023-11-29 10:47:38 +02:00
discip
9579b6a5ad Merge pull request #1841 from ia/animation-loop
Implement optional looping for animated boot logo [#1839]
2023-11-23 09:53:42 +01:00
discip
0a4344c197 Merge branch 'dev' into animation-loop 2023-11-23 09:28:45 +01:00
Ivan Zorin
c97e3eb29b Updating references in the docs (#1843)
* Documentation: add links to firmware mirror backup [#1840]

* Documentation/Flashing: replace out-of-dated external wiki links by internal references

* Documentation/Flashing: add missing space
2023-11-23 19:23:20 +11:00
Ivan Zorin
fac46e2187 Font.h: remove extra spaces 2023-11-23 09:34:34 +03:00
Ivan Zorin
1519f655ae Manually merge icon set using git cli from discip/animation-loop 2023-11-23 09:33:38 +03:00
Ivan Zorin
0298356efc Merge branch 'dev' into discip/animation-loop 2023-11-23 09:23:34 +03:00
discip
602bd772ba Merge branch 'dev' into animation-loop 2023-11-22 20:13:03 +01:00
discip
8eebb01047 Update Font.h 2023-11-22 18:45:41 +01:00
discip
229ae9b30e Update Font.h 2023-11-22 18:41:02 +01:00
discip
9bfb36e349 Update Font.h 2023-11-22 18:34:25 +01:00
discip
00c3d150dd Update settingsGUI.cpp 2023-11-22 09:21:24 +01:00
discip
37420d3ee1 Update Font.h 2023-11-22 09:20:02 +01:00
discip
faf2c6733e Update settingsGUI.cpp 2023-11-22 00:07:10 +01:00
discip
cf8d6ee783 Update Font.h 2023-11-22 00:05:51 +01:00
Ivan Zorin
f914240cad Update links to the original Miniware firmware [#1840] (#1842) 2023-11-22 09:36:38 +11:00
discip
4f5bbcf370 Update settingsGUI.cpp 2023-11-21 17:11:21 +01:00
discip
92f74e5881 extend infinity icon 2023-11-21 17:05:23 +01:00
discip
fd3366e286 Merge pull request #75 from ia/animation-loop
Animation loop
2023-11-21 17:00:50 +01:00
Ivan Zorin
7338a68652 Use half of infinity logo as icon for one-time loop animation setting in the menu 2023-11-21 18:22:27 +03:00
Ivan Zorin
a02f8c8ae3 Implement optional looping for animated boot logo [#1839] 2023-11-21 01:38:10 +03:00
discip
be41415717 Merge branch 'dev' into dev 2023-11-20 18:30:56 +01:00
Ben V. Brown
e3bad2adae Migrate all Miniware devices to use Bit-Bang I2C (#1838)
* MHP30 move to I2C Bit Banging

* Fixup Accelerometer drivers so all can use I2CBB

* No STM32 I2C driver anymore

* TS100 on I2CBB

* Miniware on BB

* Fixup S60 build

* format

format
2023-11-16 21:32:56 +11:00
DjedenOfficial
d5934a0093 Improved translation for NL and NL V3_BE
Fully translated NL and NL_BE to dutch.
2023-10-27 18:39:38 +02:00
DjedenOfficial
f96e21be90 Fixed some text after testing
It works after testing. However I fixed some minor issues. A second test is required.
2023-10-23 00:21:25 +02:00
DjedenOfficial
f58a91861c Improved translations for NL and NL_BE
As the title says.
2023-10-22 20:31:20 +02:00
307 changed files with 59119 additions and 78614 deletions

View File

@@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
- run: |

View File

@@ -3,23 +3,31 @@ name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
strategy:
matrix:
model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30", "Pinecilv2", "S60", "TS101"]
model:
[
"TS100",
"TS80",
"TS80P",
"Pinecil",
"MHP30",
"Pinecilv2",
"S60",
"TS101",
]
fail-fast: true
steps:
- name: Install dependencies (apk)
run: apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash
run: apk add --no-cache gcc-riscv-none-elf g++-riscv-none-elf gcc-arm-none-eabi g++-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash
- name: Install dependencies (python)
run: python3 -m pip install bdflib
run: python3 -m pip install --break-system-packages bdflib
- uses: actions/checkout@v4
with:
@@ -37,32 +45,27 @@ jobs:
- name: Copy license files
run: cp LICENSE scripts/LICENSE_RELEASE.md source/Hexfile/
- name: Generate json index file
run: ./source/metadata.py ${{ matrix.model }}.json
- name: Archive ${{ matrix.model }} artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.model }}
path: |
source/Hexfile/${{ matrix.model }}_*.hex
source/Hexfile/${{ matrix.model }}_*.dfu
source/Hexfile/${{ matrix.model }}_*.bin
source/Hexfile/${{ matrix.model }}.json
source/Hexfile/LICENSE
source/Hexfile/LICENSE_RELEASE.md
if-no-files-found: error
- name: Generate json index file
run: ./source/metadata.py ${{ matrix.model }}.json
- name: Archive ${{ matrix.model }} index file
uses: actions/upload-artifact@v3
with:
name: metadata
path: source/Hexfile/${{ matrix.model }}.json
build_multi-lang:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
strategy:
matrix:
model: ["Pinecil", "Pinecilv2"]
@@ -70,9 +73,9 @@ jobs:
steps:
- name: Install dependencies (apk)
run: apk add --no-cache gcc-riscv-none-elf newlib-riscv-none-elf findutils python3 py3-pip make git bash musl-dev
run: apk add --no-cache gcc-riscv-none-elf g++-riscv-none-elf gcc-arm-none-eabi g++-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash musl-dev
- name: Install dependencies (python)
run: python3 -m pip install bdflib
run: python3 -m pip install --break-system-packages bdflib
- uses: actions/checkout@v4
with:
@@ -90,32 +93,47 @@ jobs:
- name: Copy license files
run: cp LICENSE scripts/LICENSE_RELEASE.md source/Hexfile/
- name: Generate json index file
run: ./source/metadata.py ${{ matrix.model }}_multi-lang.json
- name: Archive ${{ matrix.model }} artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.model }}_multi-lang
path: |
source/Hexfile/${{ matrix.model }}_*.hex
source/Hexfile/${{ matrix.model }}_*.dfu
source/Hexfile/${{ matrix.model }}_*.bin
source/Hexfile/${{ matrix.model }}_multi-lang.json
source/Hexfile/LICENSE
source/Hexfile/LICENSE_RELEASE.md
if-no-files-found: error
- name: Generate json index file
run: ./source/metadata.py ${{ matrix.model }}_multi-lang.json
- name: Archive ${{ matrix.model }} index file
uses: actions/upload-artifact@v3
upload_metadata:
needs: [build, build_multi-lang]
runs-on: ubuntu-20.04
steps:
- name: Download all prebuilts
uses: actions/download-artifact@v4
with:
path: source/Hexfile/
merge-multiple: true
- run: ls -R source/Hexfile
- name: Upload JSONs in bulk as metadata
uses: actions/upload-artifact@v4
with:
name: metadata
path: source/Hexfile/${{ matrix.model }}_multi-lang.json
path: source/Hexfile/*.json
if-no-files-found: error
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
steps:
- name: Install dependencies (apk)
@@ -126,7 +144,7 @@ jobs:
submodules: true
- name: Install dependencies (python)
run: python3 -m pip install bdflib
run: python3 -m pip install --break-system-packages bdflib
- name: Run python tests
run: ./Translations/make_translation_test.py
@@ -134,11 +152,10 @@ jobs:
- name: Run BriefLZ tests
run: make -C source/ Objects/host/brieflz/libbrieflz.so && ./Translations/brieflz_test.py
check_c-cpp:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
steps:
- name: Install dependencies (apk)
@@ -151,11 +168,10 @@ jobs:
- name: Check format style with clang-format
run: make clean check-style
check_python:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
steps:
- name: Install dependencies (apk)
@@ -166,7 +182,7 @@ jobs:
submodules: true
- name: Install dependencies (python)
run: python3 -m pip install bdflib flake8
run: python3 -m pip install --break-system-packages bdflib flake8
- name: Check python formatting with black
run: black --check Translations
@@ -174,7 +190,6 @@ jobs:
- name: Check python with flake8
run: flake8 Translations
check_shell:
name: check_shell
runs-on: ubuntu-latest
@@ -188,11 +203,10 @@ jobs:
exclude: "./.git/*" # Optional.
check_all_files_with_shebangs: "false" # Optional.
check_readme:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: alpine:3.16
image: alpine:3.19
steps:
- name: Install dependencies (apk)

View File

@@ -26,9 +26,9 @@ Then this works the same as a production release (use the correct file).
# MHP30
This is completely safe, but if it goes wrong just put the `.hex` file from the official website ([MHP30](https://www.minidso.com/forum.php?mod=viewthread&tid=4385&extra=page%3D1) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called MHP30.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `MHP30_{Language-Code}.hex`.
This is completely safe, but if it goes wrong just put the corresponding `.hex` file from [the official website](https://e-design.com.cn/en/NewsDetail/4203645.html) ([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called MHP30.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `MHP30_{Language-Code}.hex`.
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under Mac, and can be made to work under Linux _sometimes_. Details over on the [wiki page](https://github.com/Ralim/IronOS/wiki/Upgrading-Firmware).
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under [Mac](#mac), and can be made to work under [Linux](#linux) _sometimes_ (look for details below).
1. Hold the button closest to the tip (MHP30 the left button on the back), and plug in the USB to the computer.
2. The unit will appear as a USB drive. (Screen will say `DFU` on it.)

View File

@@ -26,9 +26,9 @@ Then this works the same as a production release (use the correct file).
# TS100
This is completely safe, but if it goes wrong just put the `.hex` file from the official website ([TS100](https://www.minidso.com/forum.php?mod=viewthread&tid=868&extra=page%3D1) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called TS100.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `TS100_{Language-Code}.hex`.
This is completely safe, but if it goes wrong just put the corresponding `.hex` file from [the official website](https://e-design.com.cn/en/NewsDetail/4203645.html) ([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called TS100.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `TS100_{Language-Code}.hex`.
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under Mac, and can be made to work under Linux _sometimes_. Details over on the [wiki page](https://github.com/Ralim/IronOS/wiki/Upgrading-Firmware).
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under [Mac](#mac), and can be made to work under [Linux](#linux) _sometimes_ (look for details below).
1. Hold the button closest to the tip (MHP30 the left button on the back), and plug in the USB to the computer.
2. The unit will appear as a USB drive. (Screen will say `DFU` on it.)

View File

@@ -26,9 +26,9 @@ Then this works the same as a production release (use the correct file).
# TS80 / TS80P
This is completely safe, but if it goes wrong just put the `.hex` file from the official website ([TS80](https://www.minidso.com/forum.php?mod=viewthread&tid=868&extra=page%3D1)/[TS80P](https://www.minidso.com/forum.php?mod=viewthread&tid=4070&extra=page%3D1) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called TS80.zip or TS80P.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `TS80_{Language-Code}.hex`/`TS80P_{Language-Code}.hex`.
This is completely safe, but if it goes wrong just put the corresponding `.hex` file from [the official website](https://e-design.com.cn/en/NewsDetail/4203645.html) ([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)) onto the unit and you're back to the old firmware. Downloads for the `.hex` files to flash are available on the [releases page.](https://github.com/Ralim/IronOS/releases) The file you want is called TS80.zip or TS80P.zip. Inside the zip file (make sure to extract the file before flashing with it) will be a file called `TS80_{Language-Code}.hex`/`TS80P_{Language-Code}.hex`.
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under Mac, and can be made to work under Linux _sometimes_. Details over on the [wiki page](https://github.com/Ralim/TS80/wiki/Upgrading-Firmware).
Officially the bootloader on the devices only works under Windows (use the built-in File Explorer, as alternative file managers or copy handlers like Teracopy will fail). However, users have reported that it does work under [Mac](#mac), and can be made to work under [Linux](#linux) _sometimes_ (look for details below).
1. Hold the button closest to the tip (MHP30 the left button on the back), and plug in the USB to the computer.
2. The unit will appear as a USB drive. (Screen will say `DFU` on it.)

View File

@@ -8,7 +8,7 @@ TS100\* is a neat soldering iron:
- can run from 9-25V DC;
- provides a power range that is determined by the input voltage;
- voltages below 12V don't overly work well for any substantial mass;
- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=892&extra=page%3D1).
- the original firmware can be found [here](https://e-design.com.cn/en/NewsDetail/4203645.html)([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)).
![](https://brushlesswhoop.com/images/ts100-og.jpg)
@@ -19,7 +19,7 @@ TS80\* is a successor to TS100:
- uses _Quick Charge 3.0_ / _QC3_ capable charger only (18W max);
- doesn't support PD as it is not designed on the hardware level;
- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=3208&extra=page%3D1).
- the original firmware can be found [here](https://e-design.com.cn/en/NewsDetail/4203645.html)([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)).
![](https://core-electronics.com.au/media/catalog/product/4/2/4244-01.jpg)
@@ -30,7 +30,7 @@ TS80P\* is a successor to TS80:
- supports _Quick Charge 3.0_ (_QC3_: 9V/3A, 18W max);
- supports _Power Delivery_ (_PD_: 9V/3A & 12V/3A, 30W max)\*\*;
- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=4085&extra=page%3D1).
- the original firmware can be found [here](https://e-design.com.cn/en/NewsDetail/4203645.html)([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)).
\*\*: use valid PD device that supports 12V/3A as power source to get full 30W potential, otherwise the iron will fall back to 9V/18W power mode.
@@ -44,7 +44,8 @@ MHP30 is a **M**ini **H**ot **P**late:
- accelerometer is the MSA301, this is mounted roughly in the middle of the unit;
- USB-PD is using the FUSB302;
- the hardware I2C bus on PB6/7 is used for the MSA301 and FUSB302;
- the OLED is the same SSD1306 as everything else, but its on a bit-banged bus.
- the OLED is the same SSD1306 as everything else, but its on a bit-banged bus;
- the original firmware can be found [here](https://e-design.com.cn/en/NewsDetail/4203645.html)([mirror backup](https://github.com/Ralim/IronOS-Meta/tree/main/Firmware/Miniware)).
### Pinecil

View File

@@ -31,7 +31,7 @@
"message": "Некантралюемае\nразаграванне"
},
"WarningTipShorted": {
"message": "!Tip Shorted!"
"message": "!Кароткае замыканне на джале!"
},
"SettingsCalibrationWarning": {
"message": "Пераканайцеся, што пры наступнай загрузцы наканечнік і ручка маюць пакаёвую тэмпературу!"
@@ -64,16 +64,16 @@
"message": "Выкл."
},
"ProfilePreheatString": {
"message": "Preheat\n"
"message": "Разагрэць\n"
},
"ProfileCooldownString": {
"message": "Cooldown\n"
"message": "Астудзіць\n"
},
"DeviceFailedValidationWarning": {
"message": "Ваша прылада, хутчэй за ўсё, падробка!"
},
"TooHotToStartProfileWarning": {
"message": "Too hot to\nstart profile"
"message": "Занадта горача\nкаб запусціць профіль"
}
},
"characters": {
@@ -157,23 +157,23 @@
},
"ProfilePhases": {
"displayText": "Profile\nPhases",
"description": "Number of phases in profile mode"
"description": "Колькасць фаз у рэжыме профілю"
},
"ProfilePreheatTemp": {
"displayText": "Preheat\nTemp",
"description": "Preheat to this temperature at the start of profile mode"
"description": "Разагрэйце да гэтай тэмпературы ў пачатку профільнага рэжыму"
},
"ProfilePreheatSpeed": {
"displayText": "Preheat\nSpeed",
"description": "Preheat at this rate (degrees per second)"
"description": "Разагрэйце з гэтай хуткасцю (градусы ў секунду)"
},
"ProfilePhase1Temp": {
"displayText": "Phase 1\nTemp",
"description": "Target temperature for the end of this phase"
"description": "Мэтавая тэмпература ў канцы гэтай фазы"
},
"ProfilePhase1Duration": {
"displayText": "Phase 1\nDuration",
"description": "Target duration of this phase (seconds)"
"description": "Мэтавая працягласць гэтай фазы (секунды)"
},
"ProfilePhase2Temp": {
"displayText": "Phase 2\nTemp",
@@ -209,7 +209,7 @@
},
"ProfileCooldownSpeed": {
"displayText": "Cooldown\nSpeed",
"description": "Cooldown at this rate at the end of profile mode (degrees per second)"
"description": "Астуджаць з гэтай хуткасцю ў канцы профільнага рэжыму (градусы ў секунду)"
},
"MotionSensitivity": {
"displayText": "Адчувальнасць\nакселерометра",
@@ -281,7 +281,7 @@
},
"BluetoothLE": {
"displayText": "Bluetooth\n",
"description": "Enables BLE"
"description": "Уключыць BLE"
},
"PowerLimit": {
"displayText": "Межы\nмагутнасці",

View File

@@ -0,0 +1,319 @@
{
"languageCode": "ET",
"languageLocalName": "Eesti",
"tempUnitFahrenheit": false,
"messagesWarn": {
"CalibrationDone": {
"message": "Kalibreerimine\ntehtud!"
},
"ResetOKMessage": {
"message": "Vaikesätted\ntaastatud"
},
"SettingsResetMessage": {
"message": "Osad seadistused\non muutunud!"
},
"NoAccelerometerMessage": {
"message": "Kiirendusandurit\nei tuvastatud!"
},
"NoPowerDeliveryMessage": {
"message": "USB-PD IC\nei tuvastatud!"
},
"LockingKeysString": {
"message": "LUKUS"
},
"UnlockingKeysString": {
"message": "AVATUD"
},
"WarningKeysLockedString": {
"message": "!LUKUS!"
},
"WarningThermalRunaway": {
"message": "Termiline\närajooks"
},
"WarningTipShorted": {
"message": "!Otsik lühises!"
},
"SettingsCalibrationWarning": {
"message": "Enne taaskäivitamist veenduge, et otsik ja käepide on toatemperatuuril!"
},
"CJCCalibrating": {
"message": "kalibreerimine\n"
},
"SettingsResetWarning": {
"message": "Kas olete kindel, et soovite taastada vaikesätted?"
},
"UVLOWarningString": {
"message": "DC MADAL"
},
"UndervoltageString": {
"message": "Alapinge\n"
},
"InputVoltageString": {
"message": "Sisend V: \n"
},
"SleepingSimpleString": {
"message": "Zzzz"
},
"SleepingAdvancedString": {
"message": "Unerežiim...\n"
},
"SleepingTipAdvancedString": {
"message": "Otsik: \n"
},
"OffString": {
"message": "Väljas"
},
"ProfilePreheatString": {
"message": "Eelkuumutus\n"
},
"ProfileCooldownString": {
"message": "Jahtumine\n"
},
"DeviceFailedValidationWarning": {
"message": "Teie seade on tõenäoliselt võltsing!"
},
"TooHotToStartProfileWarning": {
"message": "Liiga kuum,\net alustada profiili"
}
},
"characters": {
"SettingRightChar": "P",
"SettingLeftChar": "V",
"SettingAutoChar": "A",
"SettingOffChar": "V",
"SettingSlowChar": "A",
"SettingMediumChar": "K",
"SettingFastChar": "T",
"SettingStartNoneChar": "V",
"SettingStartSolderingChar": "J",
"SettingStartSleepChar": "Z",
"SettingStartSleepOffChar": "P",
"SettingLockDisableChar": "V",
"SettingLockBoostChar": "B",
"SettingLockFullChar": "T"
},
"menuGroups": {
"PowerMenu": {
"displayText": "Toiteseaded\n",
"description": ""
},
"SolderingMenu": {
"displayText": "Jootmise\nseaded",
"description": ""
},
"PowerSavingMenu": {
"displayText": "Unerežiimi\nseaded",
"description": ""
},
"UIMenu": {
"displayText": "Kasutaja-\nliides",
"description": ""
},
"AdvancedMenu": {
"displayText": "Täpsemad\nseaded",
"description": ""
}
},
"menuOptions": {
"DCInCutoff": {
"displayText": "Toiteallikas\nDC",
"description": "Määrab katkestuspinge, et vältida aku liigset tühjenemist. (DC 10V) (S=3,3V elemendi kohta, eemaldab voolupiirangud)"
},
"MinVolCell": {
"displayText": "Minimaalne\npinge",
"description": "Minimaalne lubatud pinge akuelemendi kohta (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)"
},
"QCMaxVoltage": {
"displayText": "QC\npinge",
"description": "Maks. QC pinge, mida jootekolb läbirääkima peaks"
},
"PDNegTimeout": {
"displayText": "PD\naegumine",
"description": "PD läbirääkimise aegumine 100ms sammudena, et tagada ühilduvus osade QC laadijatega"
},
"PDVpdo": {
"displayText": "PD\nVPDO",
"description": "Võimaldab PPS- ja EPR-režiimi"
},
"BoostTemperature": {
"displayText": "Boost\ntemp",
"description": "Kolviotsiku temperatuur \"boost režiimis\""
},
"AutoStart": {
"displayText": "Käitumine\nkäivitusel",
"description": "V=väljas | J=kuumuta jootmistemperatuurini | Z=unerežiim, kuni seadet liigutatakse | P=unerežiim toatemperatuuril, kuni seadet liigutatakse"
},
"TempChangeShortStep": {
"displayText": "Temp. muut\nlühike",
"description": "Temperatuuri muutmine lühikese vajutusega"
},
"TempChangeLongStep": {
"displayText": "Temp. muut\npikk",
"description": "Temperatuuri muutmine pika vajutusega"
},
"LockingMode": {
"displayText": "Luba nuppude\nlukustamine",
"description": "Hoidke jootmise ajal mõlemad nupud all, et lülitada nende lukustamist (V=väljas | B=ainult boostrežiimis | T=täielik lukustamine)."
},
"ProfilePhases": {
"displayText": "Profiil\nfaasid",
"description": "Faaside arv profiilirežiimis"
},
"ProfilePreheatTemp": {
"displayText": "Eelkuumutus\ntemp.",
"description": "Eelkuumuta sellele temperatuurile profiilirežiimi alguses"
},
"ProfilePreheatSpeed": {
"displayText": "Eelkuumutus\nkiirus",
"description": "Eelkuumuta sellise kiirusega (kraadi sekundis)."
},
"ProfilePhase1Temp": {
"displayText": "Faas 1\ntemp.",
"description": "Selle faasi lõpu sihttemperatuur"
},
"ProfilePhase1Duration": {
"displayText": "Faas 1\nkestus",
"description": "Selle faasi sihtkestus (sekundites)"
},
"ProfilePhase2Temp": {
"displayText": "Faas 2\ntemp.",
"description": ""
},
"ProfilePhase2Duration": {
"displayText": "Faas 2\nkestus",
"description": ""
},
"ProfilePhase3Temp": {
"displayText": "Faas 3\ntemp.",
"description": ""
},
"ProfilePhase3Duration": {
"displayText": "Faas 3\nkestus",
"description": ""
},
"ProfilePhase4Temp": {
"displayText": "Faas 4\ntemp.",
"description": ""
},
"ProfilePhase4Duration": {
"displayText": "Faas 4\nkestus",
"description": ""
},
"ProfilePhase5Temp": {
"displayText": "Faas 5\ntemp.",
"description": ""
},
"ProfilePhase5Duration": {
"displayText": "Faas 5\nkestus",
"description": ""
},
"ProfileCooldownSpeed": {
"displayText": "Jahtumise\nkiirus",
"description": "Jahtumine selle kiirusega profiilirežiimi lõpus (kraadi sekundis)"
},
"MotionSensitivity": {
"displayText": "Liikumise\ntundlikkus",
"description": "0=väljas | 1=vähetundlikuim | ... | 9=kõige tundlikum"
},
"SleepTemperature": {
"displayText": "Unerežiimi\ntemp",
"description": "Kolviotsiku temperatuur \"unerežiimis\""
},
"SleepTimeout": {
"displayText": "Unerežiimi\nviide",
"description": "Aeg enne \"unerežiimi\" algust (s=sekundid | m=minutid)"
},
"ShutdownTimeout": {
"displayText": "Seiskumise\nviide",
"description": "Aeg enne jootekolvi välja lülitamist (m=minutid)"
},
"HallEffSensitivity": {
"displayText": "Halli anduri\ntundlikkus",
"description": "Tundlikkus magnetite suhtes (0=väljas | 1=vähetundlikum | ... | 9=kõige tundlikum)"
},
"TemperatureUnit": {
"displayText": "Temperatuuri\nühik",
"description": "C=°Celsius | F=°Fahrenheit"
},
"DisplayRotation": {
"displayText": "Ekraani\norienteeritus",
"description": "P=paremakäeline | V=vasakukäeline | A=automaatne"
},
"CooldownBlink": {
"displayText": "Jahtumisel\nvilkumine",
"description": "Vilguta otsiku temperatuuri, kui see jahtub ja on veel ohtlikult kuum"
},
"ScrollingSpeed": {
"displayText": "Kerimise\nkiirus",
"description": "Infoteksti kerimise kiirus (A = aeglane | K = kiire)"
},
"ReverseButtonTempChange": {
"displayText": "Vaheta\n+ - nupud",
"description": "Temperatuurinuppude asukohtade vahetus"
},
"AnimSpeed": {
"displayText": "Anim.\nkiirus",
"description": "Menüüikoonide animatsiooni kiirus (V=väljas | A=aeglane | K=keskmine | T=tempokas)"
},
"AnimLoop": {
"displayText": "Pidevad\nanim.",
"description": "Esitage menüüs pidevalt animatsioone"
},
"Brightness": {
"displayText": "Ekraani\nheledus",
"description": "Seadista OLED ekraani heledust"
},
"ColourInversion": {
"displayText": "Ekraani\ninverteerimine",
"description": "Inverteeri OLED ekraani värvid"
},
"LOGOTime": {
"displayText": "Alguslogo\nkestus",
"description": "Aeg, mille jooksul näidatakse logo peale kolvi käivitamist (s=sekundites)"
},
"AdvancedIdle": {
"displayText": "Andmed\npuhkeolekus",
"description": "Näita unerežiimis üksikasjalikumat teavet väiksemas kirjas"
},
"AdvancedSoldering": {
"displayText": "Andmed\njootmisel",
"description": "Näita jootmisel üksikasjalikumat teavet väiksemas kirjas"
},
"BluetoothLE": {
"displayText": "Bluetooth\n",
"description": "Luba BLE"
},
"PowerLimit": {
"displayText": "Võimsus-\npiirang",
"description": "Suurim lubatud võimsus mida kolb võib kasutada (W=vatti)"
},
"CalibrateCJC": {
"displayText": "Kalibr. CJC\ntuleval käivit.",
"description": "Kalibreeri külmaühenduse kompensatsioon (CJC) järgmisel käivitamisel (ei ole vajalik, kui Delta T on < 5°C)"
},
"VoltageCalibration": {
"displayText": "Kalibreeri\nsisendpinge",
"description": "Sisendpinge (VIN) kalibreerimine (väljumiseks vajutage pikalt)"
},
"PowerPulsePower": {
"displayText": "Impulsi\ntugevus",
"description": "Ärkvelolekuimpulsi tugevus (vattides). Vajalik, vältimaks akupanga uinumist."
},
"PowerPulseWait": {
"displayText": "Impulsi\nviivitus",
"description": "Viivitus enne ärkvelolekuimpulsi käivitumist (x 2,5s)"
},
"PowerPulseDuration": {
"displayText": "Impulsi\nkestus",
"description": "Ärkvelolekuimpulsi kestus (x 250ms)"
},
"SettingsReset": {
"displayText": "Taasta\nvaikesätted",
"description": "Nulli kõik seadistused vaikesätetele"
},
"LanguageSwitch": {
"displayText": "Keel:\n ET Eesti",
"description": ""
}
}
}

View File

@@ -4,40 +4,40 @@
"tempUnitFahrenheit": false,
"messagesWarn": {
"CalibrationDone": {
"message": "Calibration\ndone!"
"message": "Kalibratie\nklaar!"
},
"ResetOKMessage": {
"message": "Reset OK"
},
"SettingsResetMessage": {
"message": "Instellingen\nzijn gereset!"
"message": "Sommige instellingen\nzijn veranderd!"
},
"NoAccelerometerMessage": {
"message": "Geen accelerometer\ngedetecteerd!"
},
"NoPowerDeliveryMessage": {
"message": "Geen USB-PD IC \ngedetecteerd!"
"message": "Geen USB-PD IC\ngedetecteerd!"
},
"LockingKeysString": {
"message": "GEBLOKKEERD"
},
"UnlockingKeysString": {
"message": "GEDEBLOKKEERD"
"message": "VRIJ"
},
"WarningKeysLockedString": {
"message": "!GEBLOKKEERD!"
},
"WarningThermalRunaway": {
"message": "Verwarming\nOncontroleerbaar"
"message": "Thermisch\nop hol geslagen"
},
"WarningTipShorted": {
"message": "!Tip Shorted!"
"message": "!Kortgesloten Soldeerpunt!"
},
"SettingsCalibrationWarning": {
"message": "Before rebooting, make sure tip & handle are at room temperature!"
"message": "Voordat je opnieuw opstart: zorg dat de soldeerpunt op kamertemperatuur is!"
},
"CJCCalibrating": {
"message": "calibrating\n"
"message": "Kalibreren\n"
},
"SettingsResetWarning": {
"message": "Weet je zeker dat je de fabrieksinstellingen terug wilt zetten?"
@@ -46,16 +46,16 @@
"message": "DC Laag"
},
"UndervoltageString": {
"message": "Onderspanning\n"
"message": "Te lage spanning\n"
},
"InputVoltageString": {
"message": "Voeding V: \n"
"message": "Ingangs spanning: \n"
},
"SleepingSimpleString": {
"message": "Zzzz"
"message": "Zzz "
},
"SleepingAdvancedString": {
"message": "Slaapstand...\n"
"message": "Slaapt...\n"
},
"SleepingTipAdvancedString": {
"message": "Punt: \n"
@@ -64,16 +64,16 @@
"message": "Uit"
},
"ProfilePreheatString": {
"message": "Preheat\n"
"message": "Voorverwarmen\n"
},
"ProfileCooldownString": {
"message": "Cooldown\n"
"message": "Afkoelen\n"
},
"DeviceFailedValidationWarning": {
"message": "Jouw toestel is wellicht een namaak-versie!"
"message": "Jou apparaat is waarschijnlijk een namaak!"
},
"TooHotToStartProfileWarning": {
"message": "Too hot to\nstart profile"
"message": "Te warm om\nprofiel te starten"
}
},
"characters": {
@@ -82,19 +82,19 @@
"SettingAutoChar": "A",
"SettingOffChar": "U",
"SettingSlowChar": "L",
"SettingMediumChar": "G",
"SettingMediumChar": "M",
"SettingFastChar": "S",
"SettingStartNoneChar": "U",
"SettingStartSolderingChar": "G",
"SettingStartSolderingChar": "T",
"SettingStartSleepChar": "S",
"SettingStartSleepOffChar": "B",
"SettingStartSleepOffChar": "Z",
"SettingLockDisableChar": "U",
"SettingLockBoostChar": "B",
"SettingLockFullChar": "V"
},
"menuGroups": {
"PowerMenu": {
"displayText": "Voeding\ninstellingen",
"displayText": "Energie-\ninstellingen",
"description": ""
},
"SolderingMenu": {
@@ -102,11 +102,11 @@
"description": ""
},
"PowerSavingMenu": {
"displayText": "Slaap\nModes",
"displayText": "Slaap-\nstand",
"description": ""
},
"UIMenu": {
"displayText": "Weergave\ninstellingen",
"displayText": "Gebruiker-\nsomgeving",
"description": ""
},
"AdvancedMenu": {
@@ -116,100 +116,100 @@
},
"menuOptions": {
"DCInCutoff": {
"displayText": "Spannings-\nbron",
"description": "Spanningsbron. Stelt drempelspanning in. (DC 10V) (S 3.3V per cel)"
"displayText": "Vermogens\nbron",
"description": "Minimale spanning om de batterij te beschermen tegen te ver ontladen (DC 10V) (S=3,3V per cell, zet PWR limiet uit)"
},
"MinVolCell": {
"displayText": "Minimum\nvoltage",
"description": "Minimum toegestaan voltage per cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)"
"displayText": "Minimum\nspanning",
"description": "Minimale toegelaten voltage per cel (3S: 3 - 3,7V | 4-6S: 2,4 - 3,7V)"
},
"QCMaxVoltage": {
"displayText": "QC\nvoltage",
"description": "Maximaal QC voltage dat gevraagd mag worden"
"displayText": "QC\nspanning",
"description": "Maximale QC spanning de soldeerbout zou moeten aanvragen"
},
"PDNegTimeout": {
"displayText": "PD\ntimeout",
"description": "PD afstemmingsduur in stappen van 100ms (voor compatibiliteit met sommige QC laders)"
"displayText": "PD ver-\nloop tijd",
"description": "PD onderhandelings verlooptijd, afstemmingsduur in stappen van 100 ms (voor compatibiliteit met sommige QC laders)"
},
"PDVpdo": {
"displayText": "PD\nVPDO",
"description": "Enables PPS & EPR modes"
"description": "Zet PPS & EPR modes aan"
},
"BoostTemperature": {
"displayText": "Boost\ntemp",
"description": "Punt temperatuur in boostmode"
"description": "Tip temperatuur tijdens \"boost-modus\""
},
"AutoStart": {
"displayText": "Opstart\ngedrag",
"description": "Gedrag bij opstarten (U=Uit | G=Gebruiks-temperatuur | S=Slaapstand-temperatuur tot beweging | B=Uit tot beweging)"
"displayText": "start-\ngedrag",
"description": "U=uit | T=verwarm naar soldeer temp | S=standby op slaap temp tot bewogen | Z=standby zonder verwarmen tot bewogen"
},
"TempChangeShortStep": {
"displayText": "Temp veranderen\nkort",
"description": "Temperatuur verandering bij kort drukken"
"displayText": "temp veran-\ndering kort",
"description": "Temperatuur veranderings stap bij korte druk op de knop"
},
"TempChangeLongStep": {
"displayText": "Temp veranderen\nlang",
"description": "Temperatuur verandering bij lang drukken"
"displayText": "temp veran-\ndering lang",
"description": "Temperatuur veranderings stap bij lange druk op de knop"
},
"LockingMode": {
"displayText": "Knopblokkering\ninschakelen",
"description": "Tijdens solderen lang op beide knoppen drukken blokkeert de knoppen (U=Uit | B=Alleen boost mode | V=Volledig blokkeren)"
"displayText": "Vergrendel-\nings knoppen",
"description": "Houd tijdens het solderen beide knoppen ingedrukt om de vergrendeling in of uit te schakelen (U=uit | B=alleen boost-modus | V=volledige vergrendeling)"
},
"ProfilePhases": {
"displayText": "Profile\nPhases",
"description": "Number of phases in profile mode"
"displayText": "Profiel\nfases",
"description": "Nummer van fases in profiel modus"
},
"ProfilePreheatTemp": {
"displayText": "Preheat\nTemp",
"description": "Preheat to this temperature at the start of profile mode"
"displayText": "Voorverwarm\ntemperatuur",
"description": "Voorverwarm naar deze temperatuur op de start van profiel modus"
},
"ProfilePreheatSpeed": {
"displayText": "Preheat\nSpeed",
"description": "Preheat at this rate (degrees per second)"
"displayText": "Voorverwarm\nsnelheid",
"description": "Voorverwarm op deze snelheid (graden per seconden)"
},
"ProfilePhase1Temp": {
"displayText": "Phase 1\nTemp",
"description": "Target temperature for the end of this phase"
"displayText": "Fase 1\ntemperatuur",
"description": "Doel temperatuur op het einde van deze fase"
},
"ProfilePhase1Duration": {
"displayText": "Phase 1\nDuration",
"description": "Target duration of this phase (seconds)"
"displayText": "Fase\nduur",
"description": "Doel tijdsduur van deze fase (in seconden)"
},
"ProfilePhase2Temp": {
"displayText": "Phase 2\nTemp",
"displayText": "Fase 2\ntemperatuur",
"description": ""
},
"ProfilePhase2Duration": {
"displayText": "Phase 2\nDuration",
"displayText": "Fase 2\nduur",
"description": ""
},
"ProfilePhase3Temp": {
"displayText": "Phase 3\nTemp",
"displayText": "Fase 3\ntemperatuur",
"description": ""
},
"ProfilePhase3Duration": {
"displayText": "Phase 3\nDuration",
"displayText": "Fase 3\nduur",
"description": ""
},
"ProfilePhase4Temp": {
"displayText": "Phase 4\nTemp",
"displayText": "Fase 4\ntemperatuur",
"description": ""
},
"ProfilePhase4Duration": {
"displayText": "Phase 4\nDuration",
"displayText": "Fase 4\nduur",
"description": ""
},
"ProfilePhase5Temp": {
"displayText": "Phase 5\nTemp",
"displayText": "Fase 5\ntemperatuur",
"description": ""
},
"ProfilePhase5Duration": {
"displayText": "Phase 5\nDuration",
"displayText": "Fase 5\nduur",
"description": ""
},
"ProfileCooldownSpeed": {
"displayText": "Cooldown\nSpeed",
"description": "Cooldown at this rate at the end of profile mode (degrees per second)"
"displayText": "Afkoel\nsnelheid",
"description": "De snelheid van afkoelen op het eind van profiel modus (graden per seconden)"
},
"MotionSensitivity": {
"displayText": "Bewegings-\ngevoeligheid",
@@ -217,99 +217,99 @@
},
"SleepTemperature": {
"displayText": "Slaap\ntemp",
"description": "Punt temperatuur in slaapstand"
"description": "Temperatuur in slaapstand (°C)"
},
"SleepTimeout": {
"displayText": "Slaap\ntime-out",
"description": "Tijd voordat slaapmodus wordt geactiveerd (S=seconden | M=minuten)"
"displayText": "Slaap ver-\ntraging",
"description": "Interval voor \"slaap stand\" start (Minuten | Seconden)"
},
"ShutdownTimeout": {
"displayText": "Uitschakel\ntime-out",
"description": "Tijd voordat soldeerbout automatisch uitschakelt (M=minuten)"
"displayText": "Uitschakel\nna",
"description": "Automatisch afsluiten na (Minuten)"
},
"HallEffSensitivity": {
"displayText": "Hall sensor\ngevoeligheid",
"description": "Gevoeligheid van de Hall effect sensor om naar slaapmodus te gaan (0=uit | 1=minst gevoelig | ... | 9=meest gevoelig)"
"description": "Gevoeligheid naar de magneten (0=uit | 1=minst gevoelig | ... | 9=meest gevoelig)"
},
"TemperatureUnit": {
"displayText": "Temperatuur\neenheid",
"description": "Temperatuureenheid (C=Celsius | F=Fahrenheit)"
"description": "C=°Celsius | F=°Fahrenheit"
},
"DisplayRotation": {
"displayText": "Scherm-\noriëntatie",
"description": "Schermoriëntatie (R=Rechtshandig | L=Linkshandig | A=Automatisch)"
"description": "R=Rechtshandig | L=Linkshandig | A=Automatisch"
},
"CooldownBlink": {
"displayText": "Afkoel\nflitsen",
"description": "Temperatuur laten flitsen in het hoofdmenu zo lang de punt nog warm is"
"displayText": "Afkoel\nknipper",
"description": "Temperatuur knippert in hoofdmenu tijdens afkoeling"
},
"ScrollingSpeed": {
"displayText": "Scroll\nsnelheid",
"description": "Snelheid waarmee de tekst scrolt (S=Snel | L=Langzaam)"
"description": "Scrollsnelheid van de tekst. (Langzaam | Snel)"
},
"ReverseButtonTempChange": {
"displayText": "Draai\n+ - knoppen om",
"description": "Keer de +- knoppen van de temperatuurregeling om"
"displayText": "Wissel\n+ - knoppen",
"description": "Wissel de knoppen voor temperatuur controle om"
},
"AnimSpeed": {
"displayText": "Animatie\nsnelheid",
"description": "Tempo van de icoon animaties in het hoofdmenu (U=uit | L=langzaam | G=gemiddeld | S=snel)"
"displayText": "Anim.\nsnelheid",
"description": "Snelheid van de icoon animaties in het menu (Uit | Langzaam | Middel | Snel)"
},
"AnimLoop": {
"displayText": "Animatie\nherhaling",
"displayText": "Anim.\nherhaling",
"description": "Herhaal icoon animaties in hoofdmenu"
},
"Brightness": {
"displayText": "Scherm\nhelderheid",
"description": "Pas helderheid van het OLED scherm aan"
"description": "Verander de helderheid van het OLED scherm"
},
"ColourInversion": {
"displayText": "Inverteer\nscherm",
"description": "Inverteer de kleuren van het OLED scherm"
"description": "Keer de kleuren van het OLED scherm om"
},
"LOGOTime": {
"displayText": "Opstart logo\nduur",
"description": "Stelt de weergaveduur van het opstartlogo in (s=seconden)"
"displayText": "Opstart\nlogo duur",
"description": "Zet het duur van het opstart logo (s=seconden)"
},
"AdvancedIdle": {
"displayText": "Gedetailleerd\nstartscherm",
"description": "Gedetailleerde informatie weergeven in een kleine letters op het startscherm."
"displayText": "Detail\nslaapscherm",
"description": "Gedetailleerde informatie in een kleiner lettertype in het slaapscherm"
},
"AdvancedSoldering": {
"displayText": "Gedetailleerd\nsoldeerscherm",
"description": "Gedetailleerde informatie weergeven in een kleiner lettertype op het soldeerscherm"
"displayText": "Detail\nsoldeerscherm",
"description": "Gedetailleerde informatie in kleiner lettertype in soldeerscherm"
},
"BluetoothLE": {
"displayText": "Bluetooth\n",
"description": "Enables BLE"
"displayText": "Blue-\ntooth",
"description": "Zet Bluetooth aan"
},
"PowerLimit": {
"displayText": "Vermogen\nlimiet",
"description": "Maximaal vermogen (W=Watt)"
"displayText": "P\nlimiet",
"description": "Gemiddelde maximale vermogen dat de soldeerbout mag gebruiken (W=watt)"
},
"CalibrateCJC": {
"displayText": "Calibrate CJC\nat next boot",
"description": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)"
"displayText": "Kalibreer CJC\nbij opstart",
"description": "Bij de volgende opstart tip \"Cold Junction Compensation\" wordt gekalibreerd (niet nodig als Delta T < 5°C)"
},
"VoltageCalibration": {
"displayText": "Kalibreer\ninput-voltage?",
"description": "Start VIN Kalibratie (druk lang om te sluiten)"
"displayText": "Kalibreer vo-\nedingsspanning",
"description": "VIN Kalibreren (lang in te drukken om te annuleren)"
},
"PowerPulsePower": {
"displayText": "Stroom\nPuls",
"description": "Intensiteit van stroompuls om voeding aan te houden (watt)"
"displayText": "Power\npuls",
"description": "Power van de aanhoud puls (W=watt)"
},
"PowerPulseWait": {
"displayText": "Stroompuls\ninterval",
"description": "Tijdsduur tussen voeding wakker-blijf-pulsen (x 2.5s)"
"displayText": "Energie pulse\nvertraging",
"description": "Vertraging voordat de aanhoud puls wordt geactiveerd (x 2,5s)"
},
"PowerPulseDuration": {
"displayText": "Power pulse\nduur",
"description": "Duur van voeding-wakker-blijf-pulsen (x 250ms)"
"description": "Aanhoud pulse duur (x 250 ms)"
},
"SettingsReset": {
"displayText": "Instellingen\nresetten?",
"description": "Alle instellingen terugzetten naar fabrieksinstellingen"
"description": "Alle instellingen terug zetten naar fabrieksinstellingen"
},
"LanguageSwitch": {
"displayText": "Taal:\n NL Nederlands",

View File

@@ -4,19 +4,19 @@
"tempUnitFahrenheit": false,
"messagesWarn": {
"CalibrationDone": {
"message": "Calibration\ndone!"
"message": "Calibratie\ngedaan!"
},
"ResetOKMessage": {
"message": "Reset OK"
},
"SettingsResetMessage": {
"message": "Certain settings\nwere changed!"
"message": "Sommige settings\nzijn veranderd!"
},
"NoAccelerometerMessage": {
"message": "No accelerometer\ndetected!"
"message": "Geen accelerometer\ngedectecteerd!"
},
"NoPowerDeliveryMessage": {
"message": "No USB-PD IC\ndetected!"
"message": "Geen USB-PD IC\ngedetecteerd!"
},
"LockingKeysString": {
"message": "LOCKED"
@@ -28,22 +28,22 @@
"message": "!LOCKED!"
},
"WarningThermalRunaway": {
"message": "Thermal\nRunaway"
"message": "Thermisch\nop hol geslagen"
},
"WarningTipShorted": {
"message": "!Tip Shorted!"
"message": "!Soldeerpunt kortgesloten!"
},
"SettingsCalibrationWarning": {
"message": "Before rebooting, make sure tip & handle are at room temperature!"
"message": "Voordat je opnieuw opstart: stel zeker dat de soldeerpunt op kamertemperatuur is!"
},
"CJCCalibrating": {
"message": "calibrating\n"
"message": "Calibreren\n"
},
"SettingsResetWarning": {
"message": "Ben je zeker dat je alle standaardwaarden wil resetten?"
"message": "Weet je zeker dat je de fabrieksinstellingen terug wilt zetten?"
},
"UVLOWarningString": {
"message": "Voedingsspanning LAAG"
"message": "Onderspanning"
},
"UndervoltageString": {
"message": "Onderspanning\n"
@@ -70,10 +70,10 @@
"message": "Cooldown\n"
},
"DeviceFailedValidationWarning": {
"message": "Your device is most likely a counterfeit!"
"message": "Jou apparaat is waarschijnlijk namaak!"
},
"TooHotToStartProfileWarning": {
"message": "Too hot to\nstart profile"
"message": "Te warm om\nprofiel te starten!"
}
},
"characters": {
@@ -94,122 +94,122 @@
},
"menuGroups": {
"PowerMenu": {
"displayText": "Power\nsettings",
"displayText": "Vermogens-\ninstellingen",
"description": ""
},
"SolderingMenu": {
"displayText": "Soldeer\nInstellingen",
"displayText": "Soldeer\ninstellingen",
"description": ""
},
"PowerSavingMenu": {
"displayText": "Slaap\nstanden",
"displayText": "Slaap-\nstanden",
"description": ""
},
"UIMenu": {
"displayText": "Gebruikers-\nInterface",
"displayText": "Gebruikers-\ninterface",
"description": ""
},
"AdvancedMenu": {
"displayText": "Gevorderde\nInstellingen",
"displayText": "Geavanceerde\ninstellingen",
"description": ""
}
},
"menuOptions": {
"DCInCutoff": {
"displayText": "Spannings-\nbron",
"description": "Spanningsbron. Stelt minimumspanning in. (DC 10V) (S 3.3V per cel)"
"description": "Minimale toegelate voltage"
},
"MinVolCell": {
"displayText": "Minimum\nvoltage",
"description": "Minimum allowed voltage per cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)"
"description": "Minimale toegelaten voltage per cel (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)"
},
"QCMaxVoltage": {
"displayText": "Vermogen\nWatt",
"displayText": "Vermogen\nwatt",
"description": "Vermogen van de adapter"
},
"PDNegTimeout": {
"displayText": "PD\ntimeout",
"description": "PD negotiation timeout in 100ms steps for compatibility with some QC chargers"
"description": "PD afstemmingsduur in stappen van 100ms (voor compatibiliteit met sommige QC laders)"
},
"PDVpdo": {
"displayText": "PD\nVPDO",
"description": "Enables PPS & EPR modes"
"description": "Zet PPS & EPR modes aan"
},
"BoostTemperature": {
"displayText": "Verhogings\ntemp",
"displayText": "Verhog\nings temp",
"description": "Verhogingstemperatuur"
},
"AutoStart": {
"displayText": "Auto\nstart",
"displayText": "start-\ntemperatuur",
"description": "Breng de soldeerbout op temperatuur bij het opstarten. (F=Uit | T=Soldeertemperatuur | S=Slaapstand-temperatuur | K=Slaapstand kamertemperatuur)"
},
"TempChangeShortStep": {
"displayText": "Temp change\nshort",
"description": "Temperature-change-increment on short button press"
"displayText": "temp veran\ndering kort",
"description": "Temperatuurveranderingsstap bij korte druk op de knop"
},
"TempChangeLongStep": {
"displayText": "Temp change\nlong",
"description": "Temperature-change-increment on long button press"
"displayText": "temp veran\ndering lang",
"description": "Temperatuurveranderingsstap bij lange druk op de knop"
},
"LockingMode": {
"displayText": "Allow locking\nbuttons",
"description": "While soldering, hold down both buttons to toggle locking them (D=disable | B=boost mode only | F=full locking)"
"displayText": "Vergrendel-\ning knoppen",
"description": "Houd tijdens het solderen beide knoppen ingedrukt om de vergrendeling in of uit te schakelen (D=uit | B=alleen boost-modus | F=volledige vergrendeling)"
},
"ProfilePhases": {
"displayText": "Profile\nPhases",
"description": "Number of phases in profile mode"
"displayText": "Profiel\nfases",
"description": "Nummer van fases in profiel modus"
},
"ProfilePreheatTemp": {
"displayText": "Preheat\nTemp",
"description": "Preheat to this temperature at the start of profile mode"
"displayText": "Voorverwarm\ntemperatuur",
"description": "Voorverwarm naar deze temperatuur op de start van profiel modus"
},
"ProfilePreheatSpeed": {
"displayText": "Preheat\nSpeed",
"description": "Preheat at this rate (degrees per second)"
"displayText": "Voorverwarm\nsnelheid",
"description": "Voorverwarm op deze snelheid (graden per seconden)"
},
"ProfilePhase1Temp": {
"displayText": "Phase 1\nTemp",
"description": "Target temperature for the end of this phase"
"displayText": "Fase 1\ntemperatuur",
"description": "Doel temperatuur op het einde van deze fase"
},
"ProfilePhase1Duration": {
"displayText": "Phase 1\nDuration",
"description": "Target duration of this phase (seconds)"
"displayText": "Fase\nduur",
"description": "Doel tijdsduur van deze fase (in seconden)"
},
"ProfilePhase2Temp": {
"displayText": "Phase 2\nTemp",
"displayText": "Fase 2\ntemperatuur",
"description": ""
},
"ProfilePhase2Duration": {
"displayText": "Phase 2\nDuration",
"displayText": "Fase 2\nduur",
"description": ""
},
"ProfilePhase3Temp": {
"displayText": "Phase 3\nTemp",
"displayText": "Fase 3\ntemperatuur",
"description": ""
},
"ProfilePhase3Duration": {
"displayText": "Phase 3\nDuration",
"displayText": "Fase 3\nduur",
"description": ""
},
"ProfilePhase4Temp": {
"displayText": "Phase 4\nTemp",
"displayText": "Fase 4\ntemperatuur",
"description": ""
},
"ProfilePhase4Duration": {
"displayText": "Phase 4\nDuration",
"displayText": "Fase 4\nduur",
"description": ""
},
"ProfilePhase5Temp": {
"displayText": "Phase 5\nTemp",
"displayText": "Fase 5\ntemperatuur",
"description": ""
},
"ProfilePhase5Duration": {
"displayText": "Phase 5\nDuration",
"displayText": "Fase 5\nduur",
"description": ""
},
"ProfileCooldownSpeed": {
"displayText": "Cooldown\nSpeed",
"description": "Cooldown at this rate at the end of profile mode (degrees per second)"
"displayText": "Afkoel\nsnelheid",
"description": "De snelheid van afkoelen op het eind van profiel modus (graden per seconden)"
},
"MotionSensitivity": {
"displayText": "Bewegings-\ngevoeligheid",
@@ -228,8 +228,8 @@
"description": "Automatisch afsluiten time-out (Minuten)"
},
"HallEffSensitivity": {
"displayText": "Hall sensor\nsensitivity",
"description": "Sensitivity to magnets (0=uit | 1=minst gevoelig | ... | 9=meest gevoelig)"
"displayText": "Hall sensor\ngevoeligheid",
"description": "Gevoeligheid naar de magneten (0=uit | 1=minst gevoelig | ... | 9=meest gevoelig)"
},
"TemperatureUnit": {
"displayText": "Temperatuur\nschaal",
@@ -244,72 +244,72 @@
"description": "Temperatuur knippert in hoofdmenu tijdens afkoeling."
},
"ScrollingSpeed": {
"displayText": "Scrol\nsnelheid",
"description": "Scrolsnelheid van de tekst."
"displayText": "Scroll\nsnelheid",
"description": "Scrollsnelheid van de tekst."
},
"ReverseButtonTempChange": {
"displayText": "Swap\n+ - keys",
"description": "Reverse assignment of buttons for temperature adjustment"
"displayText": "Wissel\n+ - knoppen",
"description": "Wissel de knoppen voor temperatuur controle"
},
"AnimSpeed": {
"displayText": "Anim.\nspeed",
"description": "Pace of icon animations in menu (O=off | T=slow | M=medium | S=fast)"
"displayText": "Anim.\nsnelheid",
"description": "Snelheid van de icoon animaties in het menu (O=uit | T=sloom | M=middel | S=snel)"
},
"AnimLoop": {
"displayText": "Anim.\nloop",
"description": "Loop icon animations in main menu"
"displayText": "Anim.\nherhaling",
"description": "Herhaal icoon animaties in hoofdmenu"
},
"Brightness": {
"displayText": "Screen\nbrightness",
"description": "Adjust the OLED screen brightness"
"displayText": "Scherm\nhelderheid",
"description": "Verander de helderheid van het OLED scherm"
},
"ColourInversion": {
"displayText": "Invert\nscreen",
"description": "Invert the OLED screen colors"
"displayText": "Omkeer\nscherm",
"description": "Omkeer de kleuren van het OLED scherm"
},
"LOGOTime": {
"displayText": "Boot logo\nduration",
"description": "Set boot logo duration (s=seconds)"
"displayText": "Opstart\nlogo lengte",
"description": "Zet het lengte van het opstart logo (s=seconden)"
},
"AdvancedIdle": {
"displayText": "Gedetailleerd\nslaapscherm",
"description": "Gedetailleerde informatie in een kleiner lettertype in het slaapscherm."
"description": "Gedetailleerde informatie in een kleiner lettertype in het slaapscherm"
},
"AdvancedSoldering": {
"displayText": "Gedetailleerd\nsoldeerscherm",
"description": "Gedetailleerde informatie in kleiner lettertype in soldeerscherm."
"description": "Gedetailleerde informatie in kleiner lettertype in soldeerscherm"
},
"BluetoothLE": {
"displayText": "Bluetooth\n",
"description": "Enables BLE"
"description": "Zet Bluetooth aan"
},
"PowerLimit": {
"displayText": "Power\nlimit",
"description": "Average maximum power the iron can use (W=watt)"
"description": "Gemiddelde maximale power dat de soldeerbout mag gebruiken (W=watt)"
},
"CalibrateCJC": {
"displayText": "Calibrate CJC\nat next boot",
"description": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)"
"displayText": "Calibreer CJC\nbij opstart",
"description": "Bij de volgende opstart tip Cold Junction Compensation wordt gecalibreerd (niet nodig als Delta T < 5°C)"
},
"VoltageCalibration": {
"displayText": "Calibreer\nvoedingsspanning?",
"displayText": "Calibreervo-\nedingsspanning?",
"description": "VIN Calibreren. Bevestigen door knoppen lang in te drukken."
},
"PowerPulsePower": {
"displayText": "Power\npulse",
"description": "Intensity of power of keep-awake-pulse (W=watt)"
"displayText": "Power\npuls",
"description": "Power van de wakker-houd-puls (W=watt)"
},
"PowerPulseWait": {
"displayText": "Power pulse\ndelay",
"description": "Delay before keep-awake-pulse is triggered (x 2.5s)"
"displayText": "Power pulse\nvertraging",
"description": "Vertraging voordat de wakker-houd-puls wordt geactiveerd (x 2,5s)"
},
"PowerPulseDuration": {
"displayText": "Power pulse\nduration",
"displayText": "Power pulse\nduur",
"description": "Keep-awake-pulse duration (x 250ms)"
},
"SettingsReset": {
"displayText": "Instellingen\nresetten?",
"description": "Alle instellingen resetten."
"description": "Alle instellingen resetten"
},
"LanguageSwitch": {
"displayText": "Spraak:\n NL_BE Vlaams",

View File

@@ -52,7 +52,7 @@
"message": "Питание(В):\n"
},
"SleepingSimpleString": {
"message": "Хххррп"
"message": "Zzzz"
},
"SleepingAdvancedString": {
"message": "Сон...\n"

View File

@@ -31,7 +31,7 @@
"message": "Некерований\nрозігрів"
},
"WarningTipShorted": {
"message": "!Tip Shorted!"
"message": "!Жало закорочено!"
},
"SettingsCalibrationWarning": {
"message": "Під час наступного завантаження переконайтеся, що жало і ручка мають кімнатну температуру!"

View File

@@ -1,6 +1,7 @@
# Default Reference Distro for development env & deploy:
# * Alpine Linux, version 3.16 *
FROM alpine:3.16
# * Alpine Linux, version 3.19 *
FROM alpine:3.19
LABEL maintainer="Ben V. Brown <ralim@ralimtek.com>"
# Default current dir when container starts
@@ -14,7 +15,7 @@ WORKDIR /build/ironos
## - clang (required for clang-format to check C++ code formatting)
## - shellcheck (to check sh scripts)
ARG APK_COMPS="gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi"
ARG APK_COMPS="gcc-riscv-none-elf g++-riscv-none-elf gcc-arm-none-eabi g++-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi"
ARG APK_PYTHON="python3 py3-pip black"
ARG APK_MISC="findutils make git diffutils zip"
ARG APK_DEV="musl-dev clang bash clang-extra-tools shellcheck"
@@ -25,8 +26,8 @@ ARG PIP_PKGS='bdflib flake8 pymdown-extensions mkdocs mkdocs-autolinks-plugin mk
# Install system packages using alpine package manager
RUN apk add --no-cache ${APK_COMPS} ${APK_PYTHON} ${APK_MISC} ${APK_DEV}
# Install Python3 packages as modules using pip
RUN python3 -m pip install ${PIP_PKGS}
# Install Python3 packages as modules using pip, yes we dont care if packages break
RUN python3 -m pip install --break-system-packages ${PIP_PKGS}
# Git trust to avoid related warning
RUN git config --global --add safe.directory /build/ironos

View File

@@ -91,21 +91,6 @@ check_style_file()
fi;
ret=1
fi;
# - clang-format has neat option for { } in condition blocks but it's available only since version 15:
# * https://clang.llvm.org/docs/ClangFormatStyleOptions.html#insertbraces
# - since reference env is alpine 3.16 with clang-format 13, implement custom parser to do the similar thing here with grep:
# it used to trace missing { and } for if/else/do/while/for BUT IT'S VERY SPECULATIVE, very-very hacky & dirty.
# - if file is problematic but filename only requested make final grep in pipe silent ... UPD: make code messy but shellcheck happy
if [ -z "${LIST}" ]; then
grep -H -n -e "^ .*if .*)$" -e "^ .*else$" -e "^ .* do$" -e "^ .*while .*)$" -e "^ .*for .*)$" "${src}" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -e "^.*$"
else
grep -H -n -e "^ .*if .*)$" -e "^ .*else$" -e "^ .* do$" -e "^ .*while .*)$" -e "^ .*for .*)$" "${src}" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -q -e "^.*$"
fi;
if [ "${?}" -ne 1 ]; then
# ... and only print the filename
test -z "${LIST}" || echo "${src}"
ret=1;
fi;
return "${ret}"
}

View File

@@ -1,139 +1,236 @@
# Roughly based on LLVM, tweaked a tad for readability on wide screens
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AllowShortEnumsOnASingleLine: false ### <<< Keeps enums as is
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 200
CommentPragmas: '^ IWYU pragma:'
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
CaseSensitive: false
- Regex: ".*"
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
CaseSensitive: false
IncludeIsMainRegex: "(Test)?$"
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
---

View File

@@ -230,8 +230,9 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
static uint32_t samples[BATTFILTERDEPTH];
static uint8_t index = 0;
if (preFillneeded) {
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++) {
samples[i] = getADC(1);
}
preFillneeded--;
}
if (sample) {
@@ -240,8 +241,9 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
}
uint32_t sum = 0;
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++) {
sum += samples[i];
}
sum /= BATTFILTERDEPTH;
if (divisor == 0) {
@@ -263,25 +265,6 @@ void unstick_I2C() {
int timeout = 100;
int timeout_cnt = 0;
// 1. Clear PE bit.
hi2c1.Instance->CR1 &= ~(0x0001);
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
// 2. Configure the SCL and SDA I/Os as General Purpose Output Open-Drain, High level (Write 1 to GPIOx_ODR).
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = SCL_Pin;
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
GPIO_InitStruct.Pin = SDA_Pin;
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
while (GPIO_PIN_SET != HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin)) {
// Move clock to release I2C
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET);
@@ -292,39 +275,10 @@ void unstick_I2C() {
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
timeout_cnt++;
if (timeout_cnt > timeout)
if (timeout_cnt > timeout) {
return;
}
// 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = SCL_Pin;
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = SDA_Pin;
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
// 13. Set SWRST bit in I2Cx_CR1 register.
hi2c1.Instance->CR1 |= 0x8000;
asm("nop");
// 14. Clear SWRST bit in I2Cx_CR1 register.
hi2c1.Instance->CR1 &= ~0x8000;
asm("nop");
// 15. Enable the I2C peripheral by setting the PE bit in I2Cx_CR1 register
hi2c1.Instance->CR1 |= 0x0001;
// Call initialization function.
HAL_I2C_Init(&hi2c1);
}
}
uint8_t getButtonA() { return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0; }
@@ -341,15 +295,9 @@ void setPlatePullup(bool pullingUp) {
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = PLATE_SENSOR_PULLUP_Pin;
GPIO_InitStruct.Pull = GPIO_NOPULL;
if (pullingUp) {
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port, PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_SET);
} else {
// Hi-z
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port, PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_RESET);
}
GPIO_InitStruct.Mode = pullingUp ? GPIO_MODE_OUTPUT_PP : GPIO_MODE_INPUT;
HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port, PLATE_SENSOR_PULLUP_Pin, pullingUp ? GPIO_PIN_SET : GPIO_PIN_RESET);
}
void performTipMeasurementStep(bool start) {

View File

@@ -1,91 +0,0 @@
/*
* FRToSI2C.cpp
*
* Created on: 14Apr.,2018
* Author: Ralim
*/
#include "BSP.h"
#include "Setup.h"
#include <I2C_Wrapper.hpp>
SemaphoreHandle_t FRToSI2C::I2CSemaphore = nullptr;
StaticSemaphore_t FRToSI2C::xSemaphoreBuffer;
void FRToSI2C::CpltCallback() {
hi2c1.State = HAL_I2C_STATE_READY; // Force state reset (even if tx error)
if (I2CSemaphore) {
xSemaphoreGiveFromISR(I2CSemaphore, NULL);
}
}
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
unlock();
return true;
}
bool FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) { return Mem_Write(address, reg, &data, 1); }
uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
uint8_t tx_data[1];
Mem_Read(add, reg, tx_data, 1);
return tx_data[0];
}
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
unlock();
return true;
}
bool FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Master_Transmit_DMA(&hi2c1, DevAddress, pData, Size) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
return true;
}
bool FRToSI2C::probe(uint16_t DevAddress) {
if (!lock())
return false;
uint8_t buffer[1];
bool worked = HAL_I2C_Mem_Read(&hi2c1, DevAddress, 0x0F, I2C_MEMADD_SIZE_8BIT, buffer, 1, 1000) == HAL_OK;
unlock();
return worked;
}
void FRToSI2C::I2C_Unstick() { unstick_I2C(); }
void FRToSI2C::unlock() { xSemaphoreGive(I2CSemaphore); }
bool FRToSI2C::lock() { return xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE; }
bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
for (int index = 0; index < registersLength; index++) {
if (!I2C_RegisterWrite(address, registers[index].reg, registers[index].val)) {
return false;
}
if (registers[index].pause_ms)
delay_ms(registers[index].pause_ms);
}
return true;
}

View File

@@ -27,12 +27,6 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
}
}
}
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
extern osThreadId POWTaskHandle;
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {

View File

@@ -18,12 +18,6 @@
extern "C" {
#endif
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc);
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_GPIO_EXTI_Callback(uint16_t);
#ifdef __cplusplus

View File

@@ -11,10 +11,6 @@ ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
DMA_HandleTypeDef hdma_adc1;
I2C_HandleTypeDef hi2c1;
DMA_HandleTypeDef hdma_i2c1_rx;
DMA_HandleTypeDef hdma_i2c1_tx;
IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
@@ -25,7 +21,7 @@ uint32_t ADCReadings[ADC_SAMPLES * ADC_CHANNELS]; // room for 32 lots of the pai
// Functions
static void SystemClock_Config(void);
static void MX_ADC1_Init(void);
static void MX_I2C1_Init(void);
static void MX_IWDG_Init(void);
static void MX_TIM3_Init(void);
static void MX_TIM2_Init(void);
@@ -39,7 +35,7 @@ void Setup_HAL() {
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_TIM3_Init();
@@ -196,19 +192,6 @@ static void MX_ADC2_Init(void) {
;
}
}
/* I2C1 init function */
static void MX_I2C1_Init(void) {
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 300000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
HAL_I2C_Init(&hi2c1);
}
/* IWDG init function */
static void MX_IWDG_Init(void) {
@@ -353,8 +336,8 @@ static void MX_GPIO_Init(void) {
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_10 | GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12
| GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |
GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */

View File

@@ -20,7 +20,6 @@ extern DMA_HandleTypeDef hdma_adc1;
extern DMA_HandleTypeDef hdma_i2c1_rx;
extern DMA_HandleTypeDef hdma_i2c1_tx;
extern I2C_HandleTypeDef hi2c1;
extern IWDG_HandleTypeDef hiwdg;

View File

@@ -18,13 +18,26 @@
#define SOFT_SDA2_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
#define SOFT_SDA2_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port, SDA2_Pin) == GPIO_PIN_SET ? 1 : 0)
#define SOFT_SCL2_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port, SCL2_Pin) == GPIO_PIN_SET ? 1 : 0)
#endif
#ifdef I2C_SOFT_BUS_1
#define SOFT_SCL1_HIGH() HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET)
#define SOFT_SCL1_LOW() HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET)
#define SOFT_SDA1_HIGH() HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET)
#define SOFT_SDA1_LOW() HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_RESET)
#define SOFT_SDA1_READ() (HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin) == GPIO_PIN_SET ? 1 : 0)
#define SOFT_SCL1_READ() (HAL_GPIO_ReadPin(SCL_GPIO_Port, SCL_Pin) == GPIO_PIN_SET ? 1 : 0)
#endif
#define SOFT_I2C_DELAY() \
{ \
for (int xx = 0; xx < 20; xx++) { \
for (int xx = 0; xx < 15; xx++) { \
asm("nop"); \
} \
}
#endif
// 40 ~= 100kHz; 15 gives around 250kHz or so which is fast _and_ stable
#endif /* BSP_MINIWARE_SOFTWARE_I2C_H_ */

View File

@@ -1,728 +0,0 @@
/**
******************************************************************************
* @file stm32f1xx_hal_i2c.h
* @author MCD Application Team
* @brief Header file of I2C HAL module.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_I2C_H
#define __STM32F1xx_HAL_I2C_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal_def.h"
/** @addtogroup STM32F1xx_HAL_Driver
* @{
*/
/** @addtogroup I2C
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup I2C_Exported_Types I2C Exported Types
* @{
*/
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
* @brief I2C Configuration Structure definition
* @{
*/
typedef struct {
uint32_t ClockSpeed; /*!< Specifies the clock frequency.
This parameter must be set to a value lower than 400kHz */
uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
uint32_t OwnAddress1; /*!< Specifies the first device own address.
This parameter can be a 7-bit or 10-bit address. */
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
This parameter can be a value of @ref I2C_addressing_mode */
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
This parameter can be a value of @ref I2C_dual_addressing_mode */
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
This parameter can be a 7-bit address. */
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
This parameter can be a value of @ref I2C_general_call_addressing_mode */
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
This parameter can be a value of @ref I2C_nostretch_mode */
} I2C_InitTypeDef;
/**
* @}
*/
/** @defgroup HAL_state_structure_definition HAL state structure definition
* @brief HAL State structure definition
* @note HAL I2C State value coding follow below described bitmap :
* b7-b6 Error information
* 00 : No Error
* 01 : Abort (Abort user request on going)
* 10 : Timeout
* 11 : Error
* b5 Peripheral initilisation status
* 0 : Reset (Peripheral not initialized)
* 1 : Init done (Peripheral initialized and ready to use. HAL I2C Init function called)
* b4 (not used)
* x : Should be set to 0
* b3
* 0 : Ready or Busy (No Listen mode ongoing)
* 1 : Listen (Peripheral in Address Listen Mode)
* b2 Intrinsic process state
* 0 : Ready
* 1 : Busy (Peripheral busy with some configuration or internal operations)
* b1 Rx state
* 0 : Ready (no Rx operation ongoing)
* 1 : Busy (Rx operation ongoing)
* b0 Tx state
* 0 : Ready (no Tx operation ongoing)
* 1 : Busy (Tx operation ongoing)
* @{
*/
typedef enum {
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
process is ongoing */
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
process is ongoing */
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
} HAL_I2C_StateTypeDef;
/**
* @}
*/
/** @defgroup HAL_mode_structure_definition HAL mode structure definition
* @brief HAL Mode structure definition
* @note HAL I2C Mode value coding follow below described bitmap :\n
* b7 (not used)\n
* x : Should be set to 0\n
* b6\n
* 0 : None\n
* 1 : Memory (HAL I2C communication is in Memory Mode)\n
* b5\n
* 0 : None\n
* 1 : Slave (HAL I2C communication is in Slave Mode)\n
* b4\n
* 0 : None\n
* 1 : Master (HAL I2C communication is in Master Mode)\n
* b3-b2-b1-b0 (not used)\n
* xxxx : Should be set to 0000
* @{
*/
typedef enum {
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
} HAL_I2C_ModeTypeDef;
/**
* @}
*/
/** @defgroup I2C_Error_Code_definition I2C Error Code definition
* @brief I2C Error Code definition
* @{
*/
#define HAL_I2C_ERROR_NONE 0x00000000U /*!< No error */
#define HAL_I2C_ERROR_BERR 0x00000001U /*!< BERR error */
#define HAL_I2C_ERROR_ARLO 0x00000002U /*!< ARLO error */
#define HAL_I2C_ERROR_AF 0x00000004U /*!< AF error */
#define HAL_I2C_ERROR_OVR 0x00000008U /*!< OVR error */
#define HAL_I2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
#define HAL_I2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout Error */
#define HAL_I2C_ERROR_SIZE 0x00000040U /*!< Size Management error */
#define HAL_I2C_ERROR_DMA_PARAM 0x00000080U /*!< DMA Parameter Error */
#define HAL_I2C_WRONG_START 0x00000200U /*!< Wrong start Error */
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
#define HAL_I2C_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid Callback error */
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
/**
* @}
*/
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
* @brief I2C handle Structure definition
* @{
*/
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
typedef struct __I2C_HandleTypeDef
#else
typedef struct
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
{
I2C_TypeDef *Instance; /*!< I2C registers base address */
I2C_InitTypeDef Init; /*!< I2C communication parameters */
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
uint16_t XferSize; /*!< I2C transfer size */
__IO uint16_t XferCount; /*!< I2C transfer counter */
__IO uint32_t XferOptions; /*!< I2C transfer options */
__IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
context for internal usage */
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
HAL_LockTypeDef Lock; /*!< I2C locking object */
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
__IO uint32_t ErrorCode; /*!< I2C Error code */
__IO uint32_t Devaddress; /*!< I2C Target device address */
__IO uint32_t Memaddress; /*!< I2C Target memory address */
__IO uint32_t MemaddSize; /*!< I2C Target memory address size */
__IO uint32_t EventCount; /*!< I2C Event counter */
#ifndef USE_HAL_I2C_REGISTER_CALLBACKS
#define USE_HAL_I2C_REGISTER_CALLBACKS 0
#endif
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
void (*MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Tx Transfer completed callback */
void (*MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Rx Transfer completed callback */
void (*SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Tx Transfer completed callback */
void (*SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Rx Transfer completed callback */
void (*ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Listen Complete callback */
void (*MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Tx Transfer completed callback */
void (*MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Rx Transfer completed callback */
void (*ErrorCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Error callback */
void (*AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Abort callback */
void (*AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< I2C Slave Address Match callback */
void (*MspInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp Init callback */
void (*MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp DeInit callback */
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
} I2C_HandleTypeDef;
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
/**
* @brief HAL I2C Callback ID enumeration definition
*/
typedef enum {
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */
} HAL_I2C_CallbackIDTypeDef;
/**
* @brief HAL I2C Callback pointer definition
*/
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c); /*!< pointer to an I2C callback function */
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an I2C Address Match callback function */
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
/**
* @}
*/
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup I2C_Exported_Constants I2C Exported Constants
* @{
*/
/** @defgroup I2C_duty_cycle_in_fast_mode I2C duty cycle in fast mode
* @{
*/
#define I2C_DUTYCYCLE_2 0x00000000U
#define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
/**
* @}
*/
/** @defgroup I2C_addressing_mode I2C addressing mode
* @{
*/
#define I2C_ADDRESSINGMODE_7BIT 0x00004000U
#define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | 0x00004000U)
/**
* @}
*/
/** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
* @{
*/
#define I2C_DUALADDRESS_DISABLE 0x00000000U
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_ENDUAL
/**
* @}
*/
/** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
* @{
*/
#define I2C_GENERALCALL_DISABLE 0x00000000U
#define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
/**
* @}
*/
/** @defgroup I2C_nostretch_mode I2C nostretch mode
* @{
*/
#define I2C_NOSTRETCH_DISABLE 0x00000000U
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
/**
* @}
*/
/** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
* @{
*/
#define I2C_MEMADD_SIZE_8BIT 0x00000001U
#define I2C_MEMADD_SIZE_16BIT 0x00000010U
/**
* @}
*/
/** @defgroup I2C_XferDirection_definition I2C XferDirection definition
* @{
*/
#define I2C_DIRECTION_RECEIVE 0x00000000U
#define I2C_DIRECTION_TRANSMIT 0x00000001U
/**
* @}
*/
/** @defgroup I2C_XferOptions_definition I2C XferOptions definition
* @{
*/
#define I2C_FIRST_FRAME 0x00000001U
#define I2C_FIRST_AND_NEXT_FRAME 0x00000002U
#define I2C_NEXT_FRAME 0x00000004U
#define I2C_FIRST_AND_LAST_FRAME 0x00000008U
#define I2C_LAST_FRAME_NO_STOP 0x00000010U
#define I2C_LAST_FRAME 0x00000020U
/* List of XferOptions in usage of :
* 1- Restart condition in all use cases (direction change or not)
*/
#define I2C_OTHER_FRAME (0x00AA0000U)
#define I2C_OTHER_AND_LAST_FRAME (0xAA000000U)
/**
* @}
*/
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
* @brief I2C Interrupt definition
* Elements values convention: 0xXXXXXXXX
* - XXXXXXXX : Interrupt control mask
* @{
*/
#define I2C_IT_BUF I2C_CR2_ITBUFEN
#define I2C_IT_EVT I2C_CR2_ITEVTEN
#define I2C_IT_ERR I2C_CR2_ITERREN
/**
* @}
*/
/** @defgroup I2C_Flag_definition I2C Flag definition
* @{
*/
#define I2C_FLAG_OVR 0x00010800U
#define I2C_FLAG_AF 0x00010400U
#define I2C_FLAG_ARLO 0x00010200U
#define I2C_FLAG_BERR 0x00010100U
#define I2C_FLAG_TXE 0x00010080U
#define I2C_FLAG_RXNE 0x00010040U
#define I2C_FLAG_STOPF 0x00010010U
#define I2C_FLAG_ADD10 0x00010008U
#define I2C_FLAG_BTF 0x00010004U
#define I2C_FLAG_ADDR 0x00010002U
#define I2C_FLAG_SB 0x00010001U
#define I2C_FLAG_DUALF 0x00100080U
#define I2C_FLAG_GENCALL 0x00100010U
#define I2C_FLAG_TRA 0x00100004U
#define I2C_FLAG_BUSY 0x00100002U
#define I2C_FLAG_MSL 0x00100001U
/**
* @}
*/
/**
* @}
*/
/* Exported macros -----------------------------------------------------------*/
/** @defgroup I2C_Exported_Macros I2C Exported Macros
* @{
*/
/** @brief Reset I2C handle state.
* @param __HANDLE__ specifies the I2C Handle.
* @retval None
*/
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) \
do { \
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \
(__HANDLE__)->MspInitCallback = NULL; \
(__HANDLE__)->MspDeInitCallback = NULL; \
} while (0)
#else
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
#endif
/** @brief Enable or disable the specified I2C interrupts.
* @param __HANDLE__ specifies the I2C Handle.
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
* This parameter can be one of the following values:
* @arg I2C_IT_BUF: Buffer interrupt enable
* @arg I2C_IT_EVT: Event interrupt enable
* @arg I2C_IT_ERR: Error interrupt enable
* @retval None
*/
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
/** @brief Checks if the specified I2C interrupt source is enabled or disabled.
* @param __HANDLE__ specifies the I2C Handle.
* @param __INTERRUPT__ specifies the I2C interrupt source to check.
* This parameter can be one of the following values:
* @arg I2C_IT_BUF: Buffer interrupt enable
* @arg I2C_IT_EVT: Event interrupt enable
* @arg I2C_IT_ERR: Error interrupt enable
* @retval The new state of __INTERRUPT__ (TRUE or FALSE).
*/
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
/** @brief Checks whether the specified I2C flag is set or not.
* @param __HANDLE__ specifies the I2C Handle.
* @param __FLAG__ specifies the flag to check.
* This parameter can be one of the following values:
* @arg I2C_FLAG_OVR: Overrun/Underrun flag
* @arg I2C_FLAG_AF: Acknowledge failure flag
* @arg I2C_FLAG_ARLO: Arbitration lost flag
* @arg I2C_FLAG_BERR: Bus error flag
* @arg I2C_FLAG_TXE: Data register empty flag
* @arg I2C_FLAG_RXNE: Data register not empty flag
* @arg I2C_FLAG_STOPF: Stop detection flag
* @arg I2C_FLAG_ADD10: 10-bit header sent flag
* @arg I2C_FLAG_BTF: Byte transfer finished flag
* @arg I2C_FLAG_ADDR: Address sent flag
* Address matched flag
* @arg I2C_FLAG_SB: Start bit flag
* @arg I2C_FLAG_DUALF: Dual flag
* @arg I2C_FLAG_GENCALL: General call header flag
* @arg I2C_FLAG_TRA: Transmitter/Receiver flag
* @arg I2C_FLAG_BUSY: Bus busy flag
* @arg I2C_FLAG_MSL: Master/Slave flag
* @retval The new state of __FLAG__ (TRUE or FALSE).
*/
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) \
((((uint8_t)((__FLAG__) >> 16U)) == 0x01U) ? (((((__HANDLE__)->Instance->SR1) & ((__FLAG__)&I2C_FLAG_MASK)) == ((__FLAG__)&I2C_FLAG_MASK)) ? SET : RESET) \
: (((((__HANDLE__)->Instance->SR2) & ((__FLAG__)&I2C_FLAG_MASK)) == ((__FLAG__)&I2C_FLAG_MASK)) ? SET : RESET))
/** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
* @param __HANDLE__ specifies the I2C Handle.
* @param __FLAG__ specifies the flag to clear.
* This parameter can be any combination of the following values:
* @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
* @arg I2C_FLAG_AF: Acknowledge failure flag
* @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
* @arg I2C_FLAG_BERR: Bus error flag
* @retval None
*/
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__)&I2C_FLAG_MASK))
/** @brief Clears the I2C ADDR pending flag.
* @param __HANDLE__ specifies the I2C Handle.
* This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
* @retval None
*/
#define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
do { \
__IO uint32_t tmpreg = 0x00U; \
tmpreg = (__HANDLE__)->Instance->SR1; \
tmpreg = (__HANDLE__)->Instance->SR2; \
UNUSED(tmpreg); \
} while (0)
/** @brief Clears the I2C STOPF pending flag.
* @param __HANDLE__ specifies the I2C Handle.
* @retval None
*/
#define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
do { \
__IO uint32_t tmpreg = 0x00U; \
tmpreg = (__HANDLE__)->Instance->SR1; \
SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE); \
UNUSED(tmpreg); \
} while (0)
/** @brief Enable the specified I2C peripheral.
* @param __HANDLE__ specifies the I2C Handle.
* @retval None
*/
#define __HAL_I2C_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
/** @brief Disable the specified I2C peripheral.
* @param __HANDLE__ specifies the I2C Handle.
* @retval None
*/
#define __HAL_I2C_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup I2C_Exported_Functions
* @{
*/
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
* @{
*/
/* Initialization and de-initialization functions******************************/
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
/* Callbacks Register/UnRegister functions ***********************************/
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID, pI2C_CallbackTypeDef pCallback);
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID);
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback);
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c);
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
/**
* @}
*/
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
* @{
*/
/* IO operation functions ****************************************************/
/******* Blocking mode: Polling */
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
/******* Non-Blocking mode: Interrupt */
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
/******* Non-Blocking mode: DMA */
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
/**
* @}
*/
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
* @{
*/
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
/**
* @}
*/
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
* @{
*/
/* Peripheral State, Mode and Error functions *********************************/
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
/**
* @}
*/
/**
* @}
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/** @defgroup I2C_Private_Constants I2C Private Constants
* @{
*/
#define I2C_FLAG_MASK 0x0000FFFFU
#define I2C_MIN_PCLK_FREQ_STANDARD 2000000U /*!< 2 MHz */
#define I2C_MIN_PCLK_FREQ_FAST 4000000U /*!< 4 MHz */
/**
* @}
*/
/* Private macros ------------------------------------------------------------*/
/** @defgroup I2C_Private_Macros I2C Private Macros
* @{
*/
#define I2C_MIN_PCLK_FREQ(__PCLK__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__PCLK__) < I2C_MIN_PCLK_FREQ_STANDARD) : ((__PCLK__) < I2C_MIN_PCLK_FREQ_FAST))
#define I2C_CCR_CALCULATION(__PCLK__, __SPEED__, __COEFF__) (((((__PCLK__)-1U) / ((__SPEED__) * (__COEFF__))) + 1U) & I2C_CCR_CCR)
#define I2C_FREQRANGE(__PCLK__) ((__PCLK__) / 1000000U)
#define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__)*300U) / 1000U) + 1U))
#define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) ((I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U) < 4U) ? 4U : I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U))
#define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) \
(((__DUTYCYCLE__) == I2C_DUTYCYCLE_2) ? I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 3U) : (I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 25U) | I2C_DUTYCYCLE_16_9))
#define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) \
(((__SPEED__) <= 100000U) ? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) \
: ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U) ? 1U \
: ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
#define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (uint8_t)(~I2C_OAR1_ADD0)))
#define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0))
#define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
#define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)0x00F0)))
#define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)(0x00F1))))
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8)))
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
/** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
* @{
*/
#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || ((CYCLE) == I2C_DUTYCYCLE_16_9))
#define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || ((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || ((ADDRESS) == I2C_DUALADDRESS_ENABLE))
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || ((CALL) == I2C_GENERALCALL_ENABLE))
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || ((STRETCH) == I2C_NOSTRETCH_ENABLE))
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || ((SIZE) == I2C_MEMADD_SIZE_16BIT))
#define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0U) && ((SPEED) <= 400000U))
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1)&0xFFFFFC00U) == 0U)
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2)&0xFFFFFF01U) == 0U)
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) \
(((REQUEST) == I2C_FIRST_FRAME) || ((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || ((REQUEST) == I2C_NEXT_FRAME) || ((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || ((REQUEST) == I2C_LAST_FRAME) \
|| ((REQUEST) == I2C_LAST_FRAME_NO_STOP) || IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST))
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || ((REQUEST) == I2C_OTHER_AND_LAST_FRAME))
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__)&I2C_FLAG_MASK)) == ((__FLAG__)&I2C_FLAG_MASK)) ? SET : RESET)
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET)
/**
* @}
*/
/**
* @}
*/
/* Private functions ---------------------------------------------------------*/
/** @defgroup I2C_Private_Functions I2C Private Functions
* @{
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_HAL_I2C_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -139,8 +139,8 @@ HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
HAL_StatusTypeDef HAL_Init(void) {
/* Configure Flash prefetch */
#if (PREFETCH_ENABLE != 0)
#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6) || defined(STM32F103xB) \
|| defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6) || defined(STM32F103xB) || \
defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
/* Prefetch buffer is not available on value line devices */
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
@@ -347,7 +347,8 @@ __weak void HAL_Delay(uint32_t Delay) {
wait += (uint32_t)(uwTickFreq);
}
while ((HAL_GetTick() - tickstart) < wait) {}
while ((HAL_GetTick() - tickstart) < wait) {
}
}
/**

View File

@@ -620,12 +620,12 @@ HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc) {
__HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_AWD | ADC_FLAG_JEOC | ADC_FLAG_EOC | ADC_FLAG_JSTRT | ADC_FLAG_STRT));
/* Reset register CR1 */
CLEAR_BIT(hadc->Instance->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN | ADC_CR1_JAUTO | ADC_CR1_AWDSGL | ADC_CR1_SCAN | ADC_CR1_JEOCIE | ADC_CR1_AWDIE
| ADC_CR1_EOCIE | ADC_CR1_AWDCH));
CLEAR_BIT(hadc->Instance->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN | ADC_CR1_JAUTO | ADC_CR1_AWDSGL | ADC_CR1_SCAN | ADC_CR1_JEOCIE |
ADC_CR1_AWDIE | ADC_CR1_EOCIE | ADC_CR1_AWDCH));
/* Reset register CR2 */
CLEAR_BIT(hadc->Instance->CR2, (ADC_CR2_TSVREFE | ADC_CR2_SWSTART | ADC_CR2_JSWSTART | ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL | ADC_CR2_JEXTTRIG | ADC_CR2_JEXTSEL | ADC_CR2_ALIGN | ADC_CR2_DMA
| ADC_CR2_RSTCAL | ADC_CR2_CAL | ADC_CR2_CONT | ADC_CR2_ADON));
CLEAR_BIT(hadc->Instance->CR2, (ADC_CR2_TSVREFE | ADC_CR2_SWSTART | ADC_CR2_JSWSTART | ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL | ADC_CR2_JEXTTRIG | ADC_CR2_JEXTSEL | ADC_CR2_ALIGN | ADC_CR2_DMA |
ADC_CR2_RSTCAL | ADC_CR2_CAL | ADC_CR2_CONT | ADC_CR2_ADON));
/* Reset register SMPR1 */
CLEAR_BIT(hadc->Instance->SMPR1, (ADC_SMPR1_SMP17 | ADC_SMPR1_SMP16 | ADC_SMPR1_SMP15 | ADC_SMPR1_SMP14 | ADC_SMPR1_SMP13 | ADC_SMPR1_SMP12 | ADC_SMPR1_SMP11 | ADC_SMPR1_SMP10));
@@ -1874,8 +1874,8 @@ HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, ADC_AnalogWDG
assert_param(IS_ADC_RANGE(AnalogWDGConfig->HighThreshold));
assert_param(IS_ADC_RANGE(AnalogWDGConfig->LowThreshold));
if ((AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REG) || (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_INJEC)
|| (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC)) {
if ((AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REG) || (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_INJEC) ||
(AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC)) {
assert_param(IS_ADC_CHANNEL(AnalogWDGConfig->Channel));
}

View File

@@ -941,8 +941,8 @@ HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_I
ADC_JSQR_JL | ADC_JSQR_RK_JL(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion),
ADC_JSQR_JL_SHIFT(sConfigInjected->InjectedNbrOfConversion)
| ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion));
ADC_JSQR_JL_SHIFT(sConfigInjected->InjectedNbrOfConversion) |
ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion));
} else {
/* Clear the old SQx bits for the selected rank */
MODIFY_REG(hadc->Instance->JSQR,

View File

@@ -305,9 +305,9 @@ void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init) {
assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size));
MPU->RBAR = MPU_Init->BaseAddress;
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) | ((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) | ((uint32_t)MPU_Init->TypeExtField << MPU_RASR_TEX_Pos)
| ((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) | ((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) | ((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos)
| ((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) | ((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) | ((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos);
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) | ((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) | ((uint32_t)MPU_Init->TypeExtField << MPU_RASR_TEX_Pos) |
((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) | ((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) | ((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos) |
((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) | ((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) | ((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos);
} else {
MPU->RBAR = 0x00U;
MPU->RASR = 0x00U;

File diff suppressed because it is too large Load Diff

View File

@@ -387,8 +387,8 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) {
assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));
/* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */
if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI)
|| ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI_DIV2))) {
if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI) ||
((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI_DIV2))) {
/* When HSI is used as system clock it will not disabled */
if ((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON)) {
return HAL_ERROR;
@@ -535,8 +535,8 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) {
if ((RCC_OscInitStruct->PLL2.PLL2State) != RCC_PLL2_NONE) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
if ((RCC_OscInitStruct->PLL2.PLL2State) == RCC_PLL2_ON) {

View File

@@ -654,8 +654,8 @@ HAL_StatusTypeDef HAL_RCCEx_EnablePLL2(RCC_PLL2InitTypeDef *PLL2Init) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
/* Check the parameters */
@@ -714,8 +714,8 @@ HAL_StatusTypeDef HAL_RCCEx_DisablePLL2(void) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
/* Disable the main PLL2. */

View File

@@ -2450,8 +2450,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t Outpu
UNUSED(OutputChannel);
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -2541,8 +2541,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t Ou
UNUSED(OutputChannel);
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -2874,8 +2874,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channe
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
}
} else {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
} else {
TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
@@ -2997,8 +2997,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Cha
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
}
} else {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
} else {
TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
@@ -3142,11 +3142,11 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Ch
return HAL_ERROR;
}
} else {
if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) || (channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY) || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY)
|| (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)) {
if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) || (channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY) || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) ||
(complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)) {
return HAL_BUSY;
} else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY) && (channel_2_state == HAL_TIM_CHANNEL_STATE_READY) && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY)
&& (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY)) {
} else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY) && (channel_2_state == HAL_TIM_CHANNEL_STATE_READY) && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY) &&
(complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY)) {
if ((((pData1 == NULL) || (pData2 == NULL))) && (Length > 0U)) {
return HAL_ERROR;
} else {

View File

@@ -311,8 +311,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim) {
assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -382,8 +382,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim) {
assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}

View File

@@ -154,8 +154,12 @@
#define POW_PD 1
#define POW_PD_EXT 0
#define USB_PD_EPR_WATTAGE 0 /*No EPR*/
#define TEMP_NTC
#define I2C_SOFT_BUS_2
#define I2C_SOFT_BUS_2 1
#define I2C_SOFT_BUS_1 1
#define OLED_I2CBB1 1
#define ACCEL_I2CBB1 1
#define BATTFILTERDEPTH 8
#define OLED_I2CBB2
#define ACCEL_EXITS_ON_MOVEMENT

View File

@@ -1,13 +1,13 @@
#include "configuration.h"
#ifdef POW_PD
#include "BSP.h"
#include "I2C_Wrapper.hpp"
#include "I2CBB1.hpp"
#include "Pins.h"
#include "Setup.h"
#include "USBPD.h"
bool fusb_read_buf(const uint8_t deviceAddr, const uint8_t registerAdd, const uint8_t size, uint8_t *buf) { return FRToSI2C::Mem_Read(deviceAddr, registerAdd, buf, size); }
bool fusb_read_buf(const uint8_t deviceAddr, const uint8_t registerAdd, const uint8_t size, uint8_t *buf) { return I2CBB1::Mem_Read(deviceAddr, registerAdd, buf, size); }
bool fusb_write_buf(const uint8_t deviceAddr, const uint8_t registerAdd, const uint8_t size, uint8_t *buf) { return FRToSI2C::Mem_Write(deviceAddr, registerAdd, (uint8_t *)buf, size); }
bool fusb_write_buf(const uint8_t deviceAddr, const uint8_t registerAdd, const uint8_t size, uint8_t *buf) { return I2CBB1::Mem_Write(deviceAddr, registerAdd, (uint8_t *)buf, size); }
void setupFUSBIRQ() {
GPIO_InitTypeDef GPIO_InitStruct;

View File

@@ -6,6 +6,7 @@
*/
#include "BSP.h"
#include "I2CBB1.hpp"
#include "I2CBB2.hpp"
#include "Pins.h"
#include "Setup.h"
@@ -18,6 +19,5 @@ void preRToSInit() {
Setup_HAL(); // Setup all the HAL objects
BSPInit();
I2CBB2::init();
/* Init the IPC objects */
FRToSI2C::FRToSInit();
I2CBB1::init();
}

View File

@@ -75,55 +75,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
}
}
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
GPIO_InitTypeDef GPIO_InitStruct;
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_I2C1_CLK_ENABLE();
/* I2C1 DMA Init */
/* I2C1_RX Init */
hdma_i2c1_rx.Instance = DMA1_Channel7;
hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_i2c1_rx);
__HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
/* I2C1_TX Init */
hdma_i2c1_tx.Instance = DMA1_Channel6;
hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
HAL_DMA_Init(&hdma_i2c1_tx);
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
/* I2C1 interrupt Init */
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
}
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base) {
if (htim_base->Instance == TIM3) {

View File

@@ -44,10 +44,5 @@ void ADC1_2_IRQHandler(void) { HAL_ADC_IRQHandler(&hadc1); }
// used for hal ticks
void TIM4_IRQHandler(void) { HAL_TIM_IRQHandler(&htim4); }
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
void I2C1_ER_IRQHandler(void) { HAL_I2C_ER_IRQHandler(&hi2c1); }
void DMA1_Channel6_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_tx); }
void DMA1_Channel7_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_rx); }
void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(INT_PD_Pin); }

View File

@@ -207,9 +207,10 @@ void unstick_I2C() {
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
timeout_cnt++;
if (timeout_cnt > timeout)
if (timeout_cnt > timeout) {
return;
}
}
// 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

View File

@@ -1,91 +0,0 @@
/*
* FRToSI2C.cpp
*
* Created on: 14Apr.,2018
* Author: Ralim
*/
#include "BSP.h"
#include "Setup.h"
#include <I2C_Wrapper.hpp>
SemaphoreHandle_t FRToSI2C::I2CSemaphore = nullptr;
StaticSemaphore_t FRToSI2C::xSemaphoreBuffer;
void FRToSI2C::CpltCallback() {
hi2c1.State = HAL_I2C_STATE_READY; // Force state reset (even if tx error)
if (I2CSemaphore) {
xSemaphoreGiveFromISR(I2CSemaphore, NULL);
}
}
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
unlock();
return true;
}
bool FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) { return Mem_Write(address, reg, &data, 1); }
uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
uint8_t tx_data[1];
Mem_Read(add, reg, tx_data, 1);
return tx_data[0];
}
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
unlock();
return true;
}
bool FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Master_Transmit_IT(&hi2c1, DevAddress, pData, Size) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
}
return true;
}
bool FRToSI2C::probe(uint16_t DevAddress) {
if (!lock())
return false;
uint8_t buffer[1];
bool worked = HAL_I2C_Mem_Read(&hi2c1, DevAddress, 0x0F, I2C_MEMADD_SIZE_8BIT, buffer, 1, 1000) == HAL_OK;
unlock();
return worked;
}
void FRToSI2C::I2C_Unstick() { unstick_I2C(); }
void FRToSI2C::unlock() { xSemaphoreGive(I2CSemaphore); }
bool FRToSI2C::lock() { return xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE; }
bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
for (int index = 0; index < registersLength; index++) {
if (!I2C_RegisterWrite(address, registers[index].reg, registers[index].val)) {
return false;
}
if (registers[index].pause_ms)
delay_ms(registers[index].pause_ms);
}
return true;
}

View File

@@ -23,12 +23,6 @@ void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc) {
}
}
}
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
extern osThreadId POWTaskHandle;

View File

@@ -18,12 +18,6 @@
extern "C" {
#endif
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc);
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_GPIO_EXTI_Callback(uint16_t);
#ifdef __cplusplus

View File

@@ -7,16 +7,13 @@
#include "Setup.h"
#include "BSP.h"
#include "Pins.h"
#include "configuration.h"
#include "history.hpp"
#include <stdint.h>
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
DMA_HandleTypeDef hdma_adc1;
I2C_HandleTypeDef hi2c1;
DMA_HandleTypeDef hdma_i2c1_rx;
DMA_HandleTypeDef hdma_i2c1_tx;
IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htimADC;
TIM_HandleTypeDef htimTip;
@@ -27,7 +24,6 @@ uint16_t ADCReadings[ADC_SAMPLES]; // Used to store the adc readings for the han
// Functions
static void SystemClock_Config(void);
static void MX_ADC1_Init(void);
static void MX_I2C1_Init(void);
static void MX_IWDG_Init(void);
static void MX_TIP_CONTROL_TIMER_Init(void);
static void MX_ADC_CONTROL_TIMER_Init(void);
@@ -46,7 +42,7 @@ void Setup_HAL() {
MX_GPIO_Init();
MX_DMA_Init();
#ifndef I2C_SOFT_BUS_1
MX_I2C1_Init();
#error "Only Bit-Bang now"
#endif
MX_ADC1_Init();
MX_ADC2_Init();
@@ -277,20 +273,6 @@ static void MX_ADC2_Init(void) {
;
}
}
/* I2C1 init function */
static void MX_I2C1_Init(void) {
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 75000;
// OLED doesnt handle >100k when its asleep (off).
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
HAL_I2C_Init(&hi2c1);
}
/* IWDG init function */
static void MX_IWDG_Init(void) {

View File

@@ -18,10 +18,6 @@ extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc2;
extern DMA_HandleTypeDef hdma_adc1;
extern DMA_HandleTypeDef hdma_i2c1_rx;
extern DMA_HandleTypeDef hdma_i2c1_tx;
extern I2C_HandleTypeDef hi2c1;
extern IWDG_HandleTypeDef hiwdg;
extern TIM_HandleTypeDef htimADC;

View File

@@ -0,0 +1,344 @@
/**
******************************************************************************
* @file startup_stm32.s
* @author Ac6
* @version V1.0.0
* @date 12-June-2014
******************************************************************************
*/
.syntax unified
.cpu cortex-m3
.thumb
.global g_pfnVectors
.global Default_Handler
/* start address for the initialization values of the .data section.
defined in linker script */
.word _sidata
/* start address for the .data section. defined in linker script */
.word _sdata
/* end address for the .data section. defined in linker script */
.word _edata
/* start address for the .bss section. defined in linker script */
.word _sbss
/* end address for the .bss section. defined in linker script */
.word _ebss
.equ BootRAM, 0xF1E0F85F
/**
* @brief This is the code that gets called when the processor first
* starts execution following a reset event. Only the absolutely
* necessary set is performed, after which the application
* supplied main() routine is called.
* @param None
* @retval : None
*/
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2]
adds r2, r2, #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array
/* Call the application's entry point.*/
bl main
LoopForever:
b LoopForever
.size Reset_Handler, .-Reset_Handler
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
* the system state for examination by a debugger.
*
* @param None
* @retval : None
*/
.section .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop
.size Default_Handler, .-Default_Handler
/******************************************************************************
*
* The minimal vector table for a Cortex-M. Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
******************************************************************************/
.section .isr_vector,"a",%progbits
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
.word 0
.word 0
.word 0
.word 0
.word SVC_Handler
.word DebugMon_Handler
.word 0
.word PendSV_Handler
.word SysTick_Handler
.word WWDG_IRQHandler
.word PVD_IRQHandler
.word TAMPER_IRQHandler
.word RTC_IRQHandler
.word FLASH_IRQHandler
.word RCC_IRQHandler
.word EXTI0_IRQHandler
.word EXTI1_IRQHandler
.word EXTI2_IRQHandler
.word EXTI3_IRQHandler
.word EXTI4_IRQHandler
.word DMA1_Channel1_IRQHandler
.word DMA1_Channel2_IRQHandler
.word DMA1_Channel3_IRQHandler
.word DMA1_Channel4_IRQHandler
.word DMA1_Channel5_IRQHandler
.word DMA1_Channel6_IRQHandler
.word DMA1_Channel7_IRQHandler
.word ADC1_2_IRQHandler
.word USB_HP_CAN1_TX_IRQHandler
.word USB_LP_CAN1_RX0_IRQHandler
.word CAN1_RX1_IRQHandler
.word CAN1_SCE_IRQHandler
.word EXTI9_5_IRQHandler
.word TIM1_BRK_IRQHandler
.word TIM1_UP_IRQHandler
.word TIM1_TRG_COM_IRQHandler
.word TIM1_CC_IRQHandler
.word TIM2_IRQHandler
.word TIM3_IRQHandler
.word TIM4_IRQHandler
.word I2C1_EV_IRQHandler
.word I2C1_ER_IRQHandler
.word I2C2_EV_IRQHandler
.word I2C2_ER_IRQHandler
.word SPI1_IRQHandler
.word SPI2_IRQHandler
.word USART1_IRQHandler
.word USART2_IRQHandler
.word USART3_IRQHandler
.word EXTI15_10_IRQHandler
.word RTC_Alarm_IRQHandler
.word USBWakeUp_IRQHandler
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word BootRAM /* @0x108. This is for boot in RAM mode for
STM32F10x Medium Density devices. */
/*******************************************************************************
*
* Provide weak aliases for each Exception handler to the Default_Handler.
* As they are weak aliases, any function with the same name will override
* this definition.
*
*******************************************************************************/
.weak NMI_Handler
.thumb_set NMI_Handler,Default_Handler
.weak HardFault_Handler
.thumb_set HardFault_Handler,Default_Handler
.weak MemManage_Handler
.thumb_set MemManage_Handler,Default_Handler
.weak BusFault_Handler
.thumb_set BusFault_Handler,Default_Handler
.weak UsageFault_Handler
.thumb_set UsageFault_Handler,Default_Handler
.weak SVC_Handler
.thumb_set SVC_Handler,Default_Handler
.weak DebugMon_Handler
.thumb_set DebugMon_Handler,Default_Handler
.weak PendSV_Handler
.thumb_set PendSV_Handler,Default_Handler
.weak SysTick_Handler
.thumb_set SysTick_Handler,Default_Handler
.weak WWDG_IRQHandler
.thumb_set WWDG_IRQHandler,Default_Handler
.weak PVD_IRQHandler
.thumb_set PVD_IRQHandler,Default_Handler
.weak TAMPER_IRQHandler
.thumb_set TAMPER_IRQHandler,Default_Handler
.weak RTC_IRQHandler
.thumb_set RTC_IRQHandler,Default_Handler
.weak FLASH_IRQHandler
.thumb_set FLASH_IRQHandler,Default_Handler
.weak RCC_IRQHandler
.thumb_set RCC_IRQHandler,Default_Handler
.weak EXTI0_IRQHandler
.thumb_set EXTI0_IRQHandler,Default_Handler
.weak EXTI1_IRQHandler
.thumb_set EXTI1_IRQHandler,Default_Handler
.weak EXTI2_IRQHandler
.thumb_set EXTI2_IRQHandler,Default_Handler
.weak EXTI3_IRQHandler
.thumb_set EXTI3_IRQHandler,Default_Handler
.weak EXTI4_IRQHandler
.thumb_set EXTI4_IRQHandler,Default_Handler
.weak DMA1_Channel1_IRQHandler
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
.weak DMA1_Channel2_IRQHandler
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
.weak DMA1_Channel3_IRQHandler
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
.weak DMA1_Channel4_IRQHandler
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
.weak DMA1_Channel5_IRQHandler
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
.weak DMA1_Channel6_IRQHandler
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
.weak DMA1_Channel7_IRQHandler
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
.weak ADC1_2_IRQHandler
.thumb_set ADC1_2_IRQHandler,Default_Handler
.weak USB_HP_CAN1_TX_IRQHandler
.thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
.weak USB_LP_CAN1_RX0_IRQHandler
.thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
.weak CAN1_RX1_IRQHandler
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
.weak CAN1_SCE_IRQHandler
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
.weak EXTI9_5_IRQHandler
.thumb_set EXTI9_5_IRQHandler,Default_Handler
.weak TIM1_BRK_IRQHandler
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
.weak TIM1_UP_IRQHandler
.thumb_set TIM1_UP_IRQHandler,Default_Handler
.weak TIM1_TRG_COM_IRQHandler
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
.weak TIM1_CC_IRQHandler
.thumb_set TIM1_CC_IRQHandler,Default_Handler
.weak TIM2_IRQHandler
.thumb_set TIM2_IRQHandler,Default_Handler
.weak TIM3_IRQHandler
.thumb_set TIM3_IRQHandler,Default_Handler
.weak TIM4_IRQHandler
.thumb_set TIM4_IRQHandler,Default_Handler
.weak I2C1_EV_IRQHandler
.thumb_set I2C1_EV_IRQHandler,Default_Handler
.weak I2C1_ER_IRQHandler
.thumb_set I2C1_ER_IRQHandler,Default_Handler
.weak I2C2_EV_IRQHandler
.thumb_set I2C2_EV_IRQHandler,Default_Handler
.weak I2C2_ER_IRQHandler
.thumb_set I2C2_ER_IRQHandler,Default_Handler
.weak SPI1_IRQHandler
.thumb_set SPI1_IRQHandler,Default_Handler
.weak SPI2_IRQHandler
.thumb_set SPI2_IRQHandler,Default_Handler
.weak USART1_IRQHandler
.thumb_set USART1_IRQHandler,Default_Handler
.weak USART2_IRQHandler
.thumb_set USART2_IRQHandler,Default_Handler
.weak USART3_IRQHandler
.thumb_set USART3_IRQHandler,Default_Handler
.weak EXTI15_10_IRQHandler
.thumb_set EXTI15_10_IRQHandler,Default_Handler
.weak RTC_Alarm_IRQHandler
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
.weak USBWakeUp_IRQHandler
.thumb_set USBWakeUp_IRQHandler,Default_Handler
/************************ (C) COPYRIGHT Ac6 *****END OF FILE****/

View File

@@ -155,8 +155,8 @@ HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
HAL_StatusTypeDef HAL_Init(void) {
/* Configure Flash prefetch */
#if (PREFETCH_ENABLE != 0)
#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6) || defined(STM32F103xB) \
|| defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6) || defined(STM32F103xB) || \
defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
/* Prefetch buffer is not available on value line devices */
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
@@ -352,7 +352,8 @@ __weak void HAL_Delay(uint32_t Delay) {
wait += (uint32_t)(uwTickFreq);
}
while ((HAL_GetTick() - tickstart) < wait) {}
while ((HAL_GetTick() - tickstart) < wait) {
}
}
/**

View File

@@ -555,12 +555,12 @@ HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc) {
__HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_AWD | ADC_FLAG_JEOC | ADC_FLAG_EOC | ADC_FLAG_JSTRT | ADC_FLAG_STRT));
/* Reset register CR1 */
CLEAR_BIT(hadc->Instance->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN | ADC_CR1_JAUTO | ADC_CR1_AWDSGL | ADC_CR1_SCAN | ADC_CR1_JEOCIE | ADC_CR1_AWDIE
| ADC_CR1_EOCIE | ADC_CR1_AWDCH));
CLEAR_BIT(hadc->Instance->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN | ADC_CR1_JAUTO | ADC_CR1_AWDSGL | ADC_CR1_SCAN | ADC_CR1_JEOCIE |
ADC_CR1_AWDIE | ADC_CR1_EOCIE | ADC_CR1_AWDCH));
/* Reset register CR2 */
CLEAR_BIT(hadc->Instance->CR2, (ADC_CR2_TSVREFE | ADC_CR2_SWSTART | ADC_CR2_JSWSTART | ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL | ADC_CR2_JEXTTRIG | ADC_CR2_JEXTSEL | ADC_CR2_ALIGN | ADC_CR2_DMA
| ADC_CR2_RSTCAL | ADC_CR2_CAL | ADC_CR2_CONT | ADC_CR2_ADON));
CLEAR_BIT(hadc->Instance->CR2, (ADC_CR2_TSVREFE | ADC_CR2_SWSTART | ADC_CR2_JSWSTART | ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL | ADC_CR2_JEXTTRIG | ADC_CR2_JEXTSEL | ADC_CR2_ALIGN | ADC_CR2_DMA |
ADC_CR2_RSTCAL | ADC_CR2_CAL | ADC_CR2_CONT | ADC_CR2_ADON));
/* Reset register SMPR1 */
CLEAR_BIT(hadc->Instance->SMPR1, (ADC_SMPR1_SMP17 | ADC_SMPR1_SMP16 | ADC_SMPR1_SMP15 | ADC_SMPR1_SMP14 | ADC_SMPR1_SMP13 | ADC_SMPR1_SMP12 | ADC_SMPR1_SMP11 | ADC_SMPR1_SMP10));
@@ -1194,7 +1194,6 @@ HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, ui
/* Set the DMA transfer complete callback */
hadc->DMA_Handle->XferCpltCallback = ADC_DMAConvCplt;
/* Manage ADC and DMA start: ADC overrun interruption, DMA start, ADC */
/* start (in case of SW start): */
@@ -1352,7 +1351,6 @@ void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc) {
}
}
/* Clear regular group conversion flag */
__HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_STRT | ADC_FLAG_EOC);
}
@@ -1393,12 +1391,8 @@ void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc) {
__HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_JSTRT | ADC_FLAG_JEOC));
}
}
}
/**
* @}
*/
@@ -1472,8 +1466,6 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConf
MODIFY_REG(hadc->Instance->SMPR2, ADC_SMPR2(ADC_SMPR2_SMP0, sConfig->Channel), ADC_SMPR2(sConfig->SamplingTime, sConfig->Channel));
}
/* Process unlocked */
__HAL_UNLOCK(hadc);
@@ -1503,8 +1495,8 @@ HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, ADC_AnalogWDG
assert_param(IS_ADC_RANGE(AnalogWDGConfig->HighThreshold));
assert_param(IS_ADC_RANGE(AnalogWDGConfig->LowThreshold));
if ((AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REG) || (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_INJEC)
|| (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC)) {
if ((AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REG) || (AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_INJEC) ||
(AnalogWDGConfig->WatchdogMode == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC)) {
assert_param(IS_ADC_CHANNEL(AnalogWDGConfig->Channel));
}
@@ -1712,11 +1704,6 @@ void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma) {
}
}
/**
* @}
*/

View File

@@ -661,7 +661,6 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t
/* Set the DMA transfer complete callback */
hadc->DMA_Handle->XferCpltCallback = ADC_DMAConvCplt;
/* Manage ADC and DMA start: ADC overrun interruption, DMA start, ADC */
/* start (in case of SW start): */
@@ -964,8 +963,8 @@ HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_I
ADC_JSQR_JL | ADC_JSQR_RK_JL(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion),
ADC_JSQR_JL_SHIFT(sConfigInjected->InjectedNbrOfConversion)
| ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion));
ADC_JSQR_JL_SHIFT(sConfigInjected->InjectedNbrOfConversion) |
ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank, sConfigInjected->InjectedNbrOfConversion));
} else {
/* Clear the old SQx bits for the selected rank */
MODIFY_REG(hadc->Instance->JSQR,
@@ -1028,9 +1027,6 @@ HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_I
MODIFY_REG(hadc->Instance->SMPR2, ADC_SMPR2(ADC_SMPR2_SMP0, sConfigInjected->InjectedChannel), ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel));
}
/* Configure the offset: offset enable/disable, InjectedChannel, offset value */
switch (sConfigInjected->InjectedRank) {
case 1:
@@ -1051,7 +1047,6 @@ HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_I
break;
}
/* Process unlocked */
__HAL_UNLOCK(hadc);

View File

@@ -321,9 +321,9 @@ void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init) {
assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size));
MPU->RBAR = MPU_Init->BaseAddress;
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) | ((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) | ((uint32_t)MPU_Init->TypeExtField << MPU_RASR_TEX_Pos)
| ((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) | ((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) | ((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos)
| ((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) | ((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) | ((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos);
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) | ((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) | ((uint32_t)MPU_Init->TypeExtField << MPU_RASR_TEX_Pos) |
((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) | ((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) | ((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos) |
((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) | ((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) | ((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos);
} else {
MPU->RBAR = 0x00U;
MPU->RASR = 0x00U;

View File

@@ -956,8 +956,6 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
/* Clear ADDR flag */
__HAL_I2C_CLEAR_ADDRFLAG(hi2c);
while (hi2c->XferSize > 0U) {
/* Wait until TXE flag is set */
if (I2C_WaitOnTXEFlagUntilTimeout(hi2c, Timeout, tickstart) != HAL_OK) {
@@ -3183,8 +3181,8 @@ void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c) {
tmp2 = hi2c->XferCount;
tmp3 = hi2c->State;
tmp4 = hi2c->PreviousState;
if ((tmp1 == HAL_I2C_MODE_SLAVE) && (tmp2 == 0U)
&& ((tmp3 == HAL_I2C_STATE_BUSY_TX) || (tmp3 == HAL_I2C_STATE_BUSY_TX_LISTEN) || ((tmp3 == HAL_I2C_STATE_LISTEN) && (tmp4 == I2C_STATE_SLAVE_BUSY_TX)))) {
if ((tmp1 == HAL_I2C_MODE_SLAVE) && (tmp2 == 0U) &&
((tmp3 == HAL_I2C_STATE_BUSY_TX) || (tmp3 == HAL_I2C_STATE_BUSY_TX_LISTEN) || ((tmp3 == HAL_I2C_STATE_LISTEN) && (tmp4 == I2C_STATE_SLAVE_BUSY_TX)))) {
} else {
hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
@@ -3717,7 +3715,6 @@ static HAL_StatusTypeDef I2C_Master_SB(I2C_HandleTypeDef *hi2c) {
return HAL_OK;
}
/**
* @brief Handle ADDR flag for Master
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
@@ -3964,7 +3961,6 @@ static HAL_StatusTypeDef I2C_MasterRequestWrite(I2C_HandleTypeDef *hi2c, uint16_
hi2c->Instance->DR = I2C_7BIT_ADD_WRITE(DevAddress);
}
/* Wait until ADDR flag is set */
if (I2C_WaitOnMasterAddressFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, Timeout, Tickstart) != HAL_OK) {
if (hi2c->ErrorCode == HAL_I2C_ERROR_AF) {
@@ -4013,7 +4009,6 @@ static HAL_StatusTypeDef I2C_MasterRequestRead(I2C_HandleTypeDef *hi2c, uint16_t
hi2c->Instance->DR = I2C_7BIT_ADD_READ(DevAddress);
}
/* Wait until ADDR flag is set */
if (I2C_WaitOnMasterAddressFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, Timeout, Tickstart) != HAL_OK) {
if (hi2c->ErrorCode == HAL_I2C_ERROR_AF) {

View File

@@ -360,8 +360,8 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) {
assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));
/* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */
if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI)
|| ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI_DIV2))) {
if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI) ||
((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI_DIV2))) {
/* When HSI is used as system clock it will not disabled */
if ((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON)) {
return HAL_ERROR;
@@ -416,8 +416,8 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) {
if ((RCC_OscInitStruct->PLL2.PLL2State) != RCC_PLL2_NONE) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
if ((RCC_OscInitStruct->PLL2.PLL2State) == RCC_PLL2_ON) {

View File

@@ -670,8 +670,8 @@ HAL_StatusTypeDef HAL_RCCEx_EnablePLL2(RCC_PLL2InitTypeDef *PLL2Init) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
/* Check the parameters */
@@ -730,8 +730,8 @@ HAL_StatusTypeDef HAL_RCCEx_DisablePLL2(void) {
/* This bit can not be cleared if the PLL2 clock is used indirectly as system
clock (i.e. it is used as PLL clock entry that is used as system clock). */
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK)
&& ((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
if ((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) &&
((READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2)) {
return HAL_ERROR;
} else {
/* Disable the main PLL2. */

View File

@@ -2450,8 +2450,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t Outpu
UNUSED(OutputChannel);
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -2541,8 +2541,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t Ou
UNUSED(OutputChannel);
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -2874,8 +2874,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channe
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
}
} else {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
} else {
TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
@@ -2997,8 +2997,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Cha
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
}
} else {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
} else {
TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
@@ -3142,11 +3142,11 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Ch
return HAL_ERROR;
}
} else {
if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) || (channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY) || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY)
|| (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)) {
if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) || (channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY) || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY) ||
(complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)) {
return HAL_BUSY;
} else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY) && (channel_2_state == HAL_TIM_CHANNEL_STATE_READY) && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY)
&& (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY)) {
} else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY) && (channel_2_state == HAL_TIM_CHANNEL_STATE_READY) && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY) &&
(complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY)) {
if ((((pData1 == NULL) || (pData2 == NULL))) && (Length > 0U)) {
return HAL_ERROR;
} else {

View File

@@ -311,8 +311,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim) {
assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}
@@ -382,8 +382,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim) {
assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
/* Check the TIM channels state */
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
|| (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY) || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY) || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY) ||
(complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY)) {
return HAL_ERROR;
}

View File

@@ -156,6 +156,10 @@
#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C
#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F
// Miniware cant be trusted, and keep using the GD32 randomly now, so assume they will clones in the future
#define I2C_SOFT_BUS_1 1
#ifdef MODEL_TS100
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
@@ -166,7 +170,8 @@
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100
#define TEMP_uV_LOOKUP_HAKKO
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define OLED_I2CBB1 1
#define ACCEL_I2CBB1 1
#define HARDWARE_MAX_WATTAGE_X10 750
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for ts100 tips
@@ -193,8 +198,8 @@
#define TIP_HAS_DIRECT_PWM 1
#define POW_DC 1
#define POW_PD 1
#define USB_PD_EPR_WATTAGE 140 /* EPR Supported */
#define I2C_SOFT_BUS_2 1
#define I2C_SOFT_BUS_1 1
#define OLED_I2CBB1 1
#define USB_PD_I2CBB2 1
#define USB_PD_VMAX 28 // Device supposedly can do 28V; looks like vmax is 33 ish
@@ -218,7 +223,7 @@
#define TIP_THERMAL_MASS 40
#define TIP_RESISTANCE 45 // x10 ohms, 4.5 typical for ts80 tips
#define I2C_SOFT_BUS_2 1
#define LIS_ORI_FLIP
#define OLED_FLIP
#endif /* TS80(P) */
@@ -228,6 +233,8 @@
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define PID_POWER_LIMIT 35 // Sets the max pwm power limit
#define POWER_LIMIT 32 // 24 watts default power limit
#define OLED_I2CBB1 1
#define ACCEL_I2CBB1 1
#define HARDWARE_MAX_WATTAGE_X10 320
@@ -241,13 +248,15 @@
#define CALIBRATION_OFFSET 1500 // the adc offset in uV
#define PID_POWER_LIMIT 35 // Sets the max pwm power limit
#define POWER_LIMIT 32 // 30 watts default power limit
#define I2C_SOFT_BUS_2 1
#define HARDWARE_MAX_WATTAGE_X10 320
#define OLED_I2CBB1 1
#define ACCEL_I2CBB1 1
#define POW_PD 1
#define USB_PD_EPR_WATTAGE 0 /*No EPR*/
#define POW_QC 1
#define TEMP_NTC
#define I2C_SOFT_BUS_2 1
#define SC7_ORI_FLIP
#endif /* TS80P */

View File

@@ -208,7 +208,8 @@ static void prvTaskExitError(void) {
// therefore not output an 'unreachable code' warning for code that appears
// after it. */
// }
for (;;) {}
for (;;) {
}
}
/*-----------------------------------------------------------*/

View File

@@ -25,7 +25,4 @@ void preRToSInit() {
#ifdef I2C_SOFT_BUS_1
I2CBB1::init();
#endif
/* Init the IPC objects */
FRToSI2C::FRToSInit();
}

View File

@@ -81,55 +81,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
}
}
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
GPIO_InitTypeDef GPIO_InitStruct;
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_I2C1_CLK_ENABLE();
/* I2C1 DMA Init */
/* I2C1_RX Init */
hdma_i2c1_rx.Instance = DMA1_Channel7;
hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_i2c1_rx);
__HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
/* I2C1_TX Init */
hdma_i2c1_tx.Instance = DMA1_Channel6;
hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
HAL_DMA_Init(&hdma_i2c1_tx);
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
/* I2C1 interrupt Init */
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
}
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base) {
if (htim_base->Instance == TIM3) {
/* Peripheral clock enable */

View File

@@ -57,13 +57,6 @@ void TIM4_IRQHandler(void) {
HAL_TIM_IRQHandler(handle);
}
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
void I2C1_ER_IRQHandler(void) { HAL_I2C_ER_IRQHandler(&hi2c1); }
void DMA1_Channel6_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_tx); }
void DMA1_Channel7_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_rx); }
void EXTI9_5_IRQHandler(void) {
#ifdef INT_PD_Pin
HAL_GPIO_EXTI_IRQHandler(INT_PD_Pin);

View File

@@ -145,11 +145,13 @@ void perform_i2c_step() {
if (currentState.numberOfBytes == 1) {
/* disable acknowledge */
i2c_master_addressing(I2C0, currentState.deviceAddress, I2C_RECEIVER);
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
}
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
/* wait for the byte to be received */
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
}
/* read the byte received from the EEPROM */
*currentState.buffer = i2c_data_receive(I2C0);
while (i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
@@ -163,10 +165,12 @@ void perform_i2c_step() {
} else if (currentState.numberOfBytes == 2) {
/* disable acknowledge */
i2c_master_addressing(I2C0, currentState.deviceAddress, I2C_RECEIVER);
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) {
}
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
/* wait for the byte to be received */
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
}
i2c_ackpos_config(I2C0, I2C_ACKPOS_CURRENT);
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
@@ -175,7 +179,8 @@ void perform_i2c_step() {
currentState.buffer++;
/* wait for the byte to be received */
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
}
/* read the byte received from the EEPROM */
*currentState.buffer = i2c_data_receive(I2C0);
while (i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
@@ -204,20 +209,23 @@ void perform_i2c_step() {
if (3 == currentState.numberOfBytes) {
/* wait until BTC bit is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_BTC)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_BTC)) {
}
i2c_ackpos_config(I2C0, I2C_ACKPOS_CURRENT);
/* disable acknowledge */
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
} else if (2 == currentState.numberOfBytes) {
/* wait until BTC bit is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_BTC)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_BTC)) {
}
/* disable acknowledge */
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
/* send a stop condition to I2C bus */
i2c_stop_on_bus(I2C0);
}
/* wait until RBNE bit is set */
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {}
while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE)) {
}
/* read a byte from the EEPROM */
*currentState.buffer = i2c_data_receive(I2C0);
@@ -296,8 +304,9 @@ bool perform_i2c_transaction(uint16_t DevAddress, uint16_t memory_address, uint8
}
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_buffer, uint16_t number_of_byte) {
if (!lock())
if (!lock()) {
return false;
}
bool res = perform_i2c_transaction(DevAddress, read_address, p_buffer, number_of_byte, false, false);
if (!res) {
I2C_Unstick();
@@ -307,8 +316,9 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
}
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_buffer, uint16_t number_of_byte) {
if (!lock())
if (!lock()) {
return false;
}
bool res = perform_i2c_transaction(DevAddress, MemAddress, p_buffer, number_of_byte, true, false);
if (!res) {
I2C_Unstick();
@@ -349,8 +359,9 @@ bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *register
bool FRToSI2C::wakePart(uint16_t DevAddress) {
// wakepart is a special case where only the device address is sent
if (!lock())
if (!lock()) {
return false;
}
bool res = perform_i2c_transaction(DevAddress, 0, NULL, 0, false, true);
if (!res) {
I2C_Unstick();

View File

@@ -34,7 +34,7 @@
#include "task.h"
#include <stdio.h>
//#define ENABLE_KERNEL_DEBUG
// #define ENABLE_KERNEL_DEBUG
#ifdef ENABLE_KERNEL_DEBUG
#define FREERTOS_PORT_DEBUG(...) printf(__VA_ARGS__)

View File

@@ -46,8 +46,8 @@ static uint16_t USBFS_TX_FIFO_SIZE[USBFS_MAX_EP_COUNT] = {(uint16_t)TX0_FIFO_FS_
#elif defined(USB_HS_CORE)
uint16_t USBHS_TX_FIFO_SIZE[USBHS_MAX_EP_COUNT]
= {(uint16_t)TX0_FIFO_HS_SIZE, (uint16_t)TX1_FIFO_HS_SIZE, (uint16_t)TX2_FIFO_HS_SIZE, (uint16_t)TX3_FIFO_HS_SIZE, (uint16_t)TX4_FIFO_HS_SIZE, (uint16_t)TX5_FIFO_HS_SIZE};
uint16_t USBHS_TX_FIFO_SIZE[USBHS_MAX_EP_COUNT] = {(uint16_t)TX0_FIFO_HS_SIZE, (uint16_t)TX1_FIFO_HS_SIZE, (uint16_t)TX2_FIFO_HS_SIZE,
(uint16_t)TX3_FIFO_HS_SIZE, (uint16_t)TX4_FIFO_HS_SIZE, (uint16_t)TX5_FIFO_HS_SIZE};
#endif /* USBFS_CORE */

View File

@@ -32,7 +32,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
OF SUCH DAMAGE.
*/
#include "gd32vf103_libopt.h"
//#include "usbd_conf.h"
// #include "usbd_conf.h"
#include "drv_usbd_int.h"
#include "usbd_transc.h"
@@ -45,8 +45,8 @@ static uint32_t usbd_int_suspend(usb_core_driver *udev);
static uint32_t usbd_emptytxfifo_write(usb_core_driver *udev, uint32_t ep_num);
static const uint8_t USB_SPEED[4]
= {[DSTAT_EM_HS_PHY_30MHZ_60MHZ] = USB_SPEED_HIGH, [DSTAT_EM_FS_PHY_30MHZ_60MHZ] = USB_SPEED_FULL, [DSTAT_EM_FS_PHY_48MHZ] = USB_SPEED_FULL, [DSTAT_EM_LS_PHY_6MHZ] = USB_SPEED_LOW};
static const uint8_t USB_SPEED[4] = {
[DSTAT_EM_HS_PHY_30MHZ_60MHZ] = USB_SPEED_HIGH, [DSTAT_EM_FS_PHY_30MHZ_60MHZ] = USB_SPEED_FULL, [DSTAT_EM_FS_PHY_48MHZ] = USB_SPEED_FULL, [DSTAT_EM_LS_PHY_6MHZ] = USB_SPEED_LOW};
__IO uint8_t setupc_flag = 0U;
@@ -230,7 +230,8 @@ void usbd_isr(usb_core_driver *udev) {
/* OTG mode interrupt */
if (intr & GINTF_OTGIF) {
if (udev->regs.gr->GOTGINTF & GOTGINTF_SESEND) {}
if (udev->regs.gr->GOTGINTF & GOTGINTF_SESEND) {
}
/* Clear OTG interrupt */
udev->regs.gr->GINTF = GINTF_OTGIF;

View File

@@ -70,8 +70,8 @@ static usb_reqsta (*_std_dev_req[])(usb_core_driver *udev, usb_req *req) = {
};
/* get standard descriptor handler */
static uint8_t *(*std_desc_get[])(usb_core_driver *udev, uint8_t index, uint16_t *len)
= {[USB_DESCTYPE_DEV - 1] = _usb_dev_desc_get, [USB_DESCTYPE_CONFIG - 1] = _usb_config_desc_get, [USB_DESCTYPE_STR - 1] = _usb_str_desc_get};
static uint8_t *(*std_desc_get[])(usb_core_driver *udev, uint8_t index,
uint16_t *len) = {[USB_DESCTYPE_DEV - 1] = _usb_dev_desc_get, [USB_DESCTYPE_CONFIG - 1] = _usb_config_desc_get, [USB_DESCTYPE_STR - 1] = _usb_str_desc_get};
/*!
\brief handle USB standard device request

View File

@@ -72,8 +72,8 @@ usbh_status usbh_devdesc_get(usb_core_driver *pudev, usbh_host *puhost, uint8_t
usbh_control *usb_ctl = &puhost->control;
if (CTL_IDLE == usb_ctl->ctl_state) {
usb_ctl->setup.req
= (usb_req){.bmRequestType = USB_TRX_IN | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_GET_DESCRIPTOR, .wValue = USBH_DESC(USB_DESCTYPE_DEV), .wIndex = 0U, .wLength = len};
usb_ctl->setup.req =
(usb_req){.bmRequestType = USB_TRX_IN | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_GET_DESCRIPTOR, .wValue = USBH_DESC(USB_DESCTYPE_DEV), .wIndex = 0U, .wLength = len};
usbh_ctlstate_config(puhost, pudev->host.rx_buf, len);
}
@@ -102,8 +102,8 @@ usbh_status usbh_cfgdesc_get(usb_core_driver *pudev, usbh_host *puhost, uint16_t
usbh_control *usb_ctl = &puhost->control;
if (CTL_IDLE == usb_ctl->ctl_state) {
usb_ctl->setup.req
= (usb_req){.bmRequestType = USB_TRX_IN | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_GET_DESCRIPTOR, .wValue = USBH_DESC(USB_DESCTYPE_CONFIG), .wIndex = 0U, .wLength = len};
usb_ctl->setup.req =
(usb_req){.bmRequestType = USB_TRX_IN | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_GET_DESCRIPTOR, .wValue = USBH_DESC(USB_DESCTYPE_CONFIG), .wIndex = 0U, .wLength = len};
usbh_ctlstate_config(puhost, pudev->host.rx_buf, len);
}
@@ -266,13 +266,15 @@ usbh_status usbh_clrfeature(usb_core_driver *pudev, usbh_host *puhost, uint8_t e
\retval operation status
*/
static void usbh_devdesc_parse(usb_desc_dev *dev_desc, uint8_t *buf, uint16_t len) {
*dev_desc = (usb_desc_dev){.header = {.bLength = *(uint8_t *)(buf + 0U), .bDescriptorType = *(uint8_t *)(buf + 1U)},
*dev_desc = (usb_desc_dev){
.header = {.bLength = *(uint8_t *)(buf + 0U), .bDescriptorType = *(uint8_t *)(buf + 1U)},
.bcdUSB = BYTE_SWAP(buf + 2U),
.bDeviceClass = *(uint8_t *)(buf + 4U),
.bDeviceSubClass = *(uint8_t *)(buf + 5U),
.bDeviceProtocol = *(uint8_t *)(buf + 6U),
.bMaxPacketSize0 = *(uint8_t *)(buf + 7U)};
.bMaxPacketSize0 = *(uint8_t *)(buf + 7U)
};
if (len > 8U) {
/* for 1st time after device connection, host may issue only 8 bytes for device descriptor length */
@@ -295,8 +297,9 @@ static void usbh_devdesc_parse(usb_desc_dev *dev_desc, uint8_t *buf, uint16_t le
*/
static void usbh_cfgdesc_parse(usb_desc_config *cfg_desc, uint8_t *buf) {
/* parse configuration descriptor */
*cfg_desc = (usb_desc_config) {
.header = {
*cfg_desc = (usb_desc_config){
.header =
{
.bLength = *(uint8_t *)(buf + 0U),
.bDescriptorType = *(uint8_t *)(buf + 1U),
},
@@ -318,7 +321,7 @@ static void usbh_cfgdesc_parse(usb_desc_config *cfg_desc, uint8_t *buf) {
\retval operation status
*/
static void usbh_cfgset_parse(usb_dev_prop *udev, uint8_t *buf) {
usb_desc_ep * ep = NULL;
usb_desc_ep *ep = NULL;
usb_desc_itf *itf = NULL, itf_value;
usb_desc_header *pdesc = (usb_desc_header *)buf;
@@ -388,8 +391,9 @@ static void usbh_cfgset_parse(usb_dev_prop *udev, uint8_t *buf) {
\retval operation status
*/
static void usbh_itfdesc_parse(usb_desc_itf *itf_desc, uint8_t *buf) {
*itf_desc = (usb_desc_itf) {
.header = {
*itf_desc = (usb_desc_itf){
.header =
{
.bLength = *(uint8_t *)(buf + 0U),
.bDescriptorType = *(uint8_t *)(buf + 1U),
},
@@ -412,12 +416,14 @@ static void usbh_itfdesc_parse(usb_desc_itf *itf_desc, uint8_t *buf) {
\retval operation status
*/
static void usbh_epdesc_parse(usb_desc_ep *ep_desc, uint8_t *buf) {
*ep_desc = (usb_desc_ep){.header = {.bLength = *(uint8_t *)(buf + 0U), .bDescriptorType = *(uint8_t *)(buf + 1U)},
*ep_desc = (usb_desc_ep){
.header = {.bLength = *(uint8_t *)(buf + 0U), .bDescriptorType = *(uint8_t *)(buf + 1U)},
.bEndpointAddress = *(uint8_t *)(buf + 2U),
.bmAttributes = *(uint8_t *)(buf + 3U),
.wMaxPacketSize = BYTE_SWAP(buf + 4U),
.bInterval = *(uint8_t *)(buf + 6U)};
.bInterval = *(uint8_t *)(buf + 6U)
};
}
/*!

View File

@@ -199,11 +199,13 @@ void adc_calibration_enable(uint32_t adc_periph) {
/* reset the selected ADC1 calibration registers */
ADC_CTL1(adc_periph) |= (uint32_t)ADC_CTL1_RSTCLB;
/* check the RSTCLB bit state */
while ((uint32_t)RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_RSTCLB)) {}
while ((uint32_t)RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_RSTCLB)) {
}
/* enable ADC calibration process */
ADC_CTL1(adc_periph) |= ADC_CTL1_CLB;
/* check the CLB bit state */
while ((uint32_t)RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_CLB)) {}
while ((uint32_t)RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_CLB)) {
}
}
/*!

View File

@@ -38,7 +38,8 @@ OF SUCH DAMAGE.
#include "gd32vf103_rcu.h"
#define DMA_WRONG_HANDLE \
while (1) {}
while (1) { \
}
/* check whether peripheral matches channels or not */
static ErrStatus dma_periph_and_channel_check(uint32_t dma_periph, dma_channel_enum channelx);

View File

@@ -114,14 +114,14 @@ void exmc_norsram_init(exmc_norsram_parameter_struct *exmc_norsram_init_struct)
/* clear relative bits */
snctl &= ((uint32_t) ~(EXMC_SNCTL_NREN | EXMC_SNCTL_NRTP | EXMC_SNCTL_NRW | EXMC_SNCTL_NRWTPOL | EXMC_SNCTL_WREN | EXMC_SNCTL_NRWTEN | EXMC_SNCTL_ASYNCWAIT | EXMC_SNCTL_NRMUX));
snctl |= (uint32_t)((uint32_t)exmc_norsram_init_struct->address_data_mux << SNCTL_NRMUX_OFFSET) | exmc_norsram_init_struct->memory_type | exmc_norsram_init_struct->databus_width
| exmc_norsram_init_struct->nwait_polarity | ((uint32_t)exmc_norsram_init_struct->memory_write << SNCTL_WREN_OFFSET)
| ((uint32_t)exmc_norsram_init_struct->nwait_signal << SNCTL_NRWTEN_OFFSET) | ((uint32_t)exmc_norsram_init_struct->asyn_wait << SNCTL_ASYNCWAIT_OFFSET);
snctl |= (uint32_t)((uint32_t)exmc_norsram_init_struct->address_data_mux << SNCTL_NRMUX_OFFSET) | exmc_norsram_init_struct->memory_type | exmc_norsram_init_struct->databus_width |
exmc_norsram_init_struct->nwait_polarity | ((uint32_t)exmc_norsram_init_struct->memory_write << SNCTL_WREN_OFFSET) |
((uint32_t)exmc_norsram_init_struct->nwait_signal << SNCTL_NRWTEN_OFFSET) | ((uint32_t)exmc_norsram_init_struct->asyn_wait << SNCTL_ASYNCWAIT_OFFSET);
sntcfg = (uint32_t)((exmc_norsram_init_struct->read_write_timing->asyn_address_setuptime - 1U) & EXMC_SNTCFG_ASET)
| (((exmc_norsram_init_struct->read_write_timing->asyn_address_holdtime - 1U) << SNTCFG_AHLD_OFFSET) & EXMC_SNTCFG_AHLD)
| (((exmc_norsram_init_struct->read_write_timing->asyn_data_setuptime - 1U) << SNTCFG_DSET_OFFSET) & EXMC_SNTCFG_DSET)
| (((exmc_norsram_init_struct->read_write_timing->bus_latency - 1U) << SNTCFG_BUSLAT_OFFSET) & EXMC_SNTCFG_BUSLAT);
sntcfg = (uint32_t)((exmc_norsram_init_struct->read_write_timing->asyn_address_setuptime - 1U) & EXMC_SNTCFG_ASET) |
(((exmc_norsram_init_struct->read_write_timing->asyn_address_holdtime - 1U) << SNTCFG_AHLD_OFFSET) & EXMC_SNTCFG_AHLD) |
(((exmc_norsram_init_struct->read_write_timing->asyn_data_setuptime - 1U) << SNTCFG_DSET_OFFSET) & EXMC_SNTCFG_DSET) |
(((exmc_norsram_init_struct->read_write_timing->bus_latency - 1U) << SNTCFG_BUSLAT_OFFSET) & EXMC_SNTCFG_BUSLAT);
/* nor flash access enable */
if (EXMC_MEMORY_TYPE_NOR == exmc_norsram_init_struct->memory_type) {

View File

@@ -188,7 +188,8 @@ void ob_unlock(void) {
}
/* wait until OBWEN bit is set by hardware */
while (RESET == (FMC_CTL & FMC_CTL_OBWEN)) {}
while (RESET == (FMC_CTL & FMC_CTL_OBWEN)) {
}
}
/*!

View File

@@ -54,8 +54,8 @@ void rcu_deinit(void) {
RCU_CTL &= ~RCU_CTL_HXTALBPS;
RCU_CTL &= ~(RCU_CTL_PLL1EN | RCU_CTL_PLL2EN);
/* reset CFG0 register */
RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC | RCU_CFG0_ADCPSC | RCU_CFG0_PLLSEL | RCU_CFG0_PREDV0_LSB | RCU_CFG0_PLLMF | RCU_CFG0_USBFSPSC | RCU_CFG0_CKOUT0SEL
| RCU_CFG0_ADCPSC_2 | RCU_CFG0_PLLMF_4);
RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC | RCU_CFG0_ADCPSC | RCU_CFG0_PLLSEL | RCU_CFG0_PREDV0_LSB | RCU_CFG0_PLLMF | RCU_CFG0_USBFSPSC |
RCU_CFG0_CKOUT0SEL | RCU_CFG0_ADCPSC_2 | RCU_CFG0_PLLMF_4);
/* reset INT and CFG1 register */
RCU_INT = 0x00ff0000U;
RCU_CFG1 &= ~(RCU_CFG1_PREDV0 | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PLL2MF | RCU_CFG1_PREDV0SEL | RCU_CFG1_I2S1SEL | RCU_CFG1_I2S2SEL);

View File

@@ -97,7 +97,8 @@ void rtc_prescaler_set(uint32_t psc) {
*/
void rtc_lwoff_wait(void) {
/* loop until LWOFF flag is set */
while (RESET == (RTC_CTL & RTC_CTL_LWOFF)) {}
while (RESET == (RTC_CTL & RTC_CTL_LWOFF)) {
}
}
/*!
@@ -110,7 +111,8 @@ void rtc_register_sync_wait(void) {
/* clear RSYNF flag */
RTC_CTL &= ~RTC_CTL_RSYNF;
/* loop until RSYNF flag is set */
while (RESET == (RTC_CTL & RTC_CTL_RSYNF)) {}
while (RESET == (RTC_CTL & RTC_CTL_RSYNF)) {
}
}
/*!

View File

@@ -482,8 +482,8 @@ void timer_break_struct_para_init(timer_break_parameter_struct *breakpara) {
\retval none
*/
void timer_break_config(uint32_t timer_periph, timer_break_parameter_struct *breakpara) {
TIMER_CCHP(timer_periph) = (uint32_t)(((uint32_t)(breakpara->runoffstate)) | ((uint32_t)(breakpara->ideloffstate)) | ((uint32_t)(breakpara->deadtime)) | ((uint32_t)(breakpara->breakpolarity))
| ((uint32_t)(breakpara->outputautostate)) | ((uint32_t)(breakpara->protectmode)) | ((uint32_t)(breakpara->breakstate)));
TIMER_CCHP(timer_periph) = (uint32_t)(((uint32_t)(breakpara->runoffstate)) | ((uint32_t)(breakpara->ideloffstate)) | ((uint32_t)(breakpara->deadtime)) | ((uint32_t)(breakpara->breakpolarity)) |
((uint32_t)(breakpara->outputautostate)) | ((uint32_t)(breakpara->protectmode)) | ((uint32_t)(breakpara->breakstate)));
}
/*!

View File

@@ -44,9 +44,10 @@ uint64_t get_timer_value(void) {
while (1) {
uint32_t hi = mtime_hi();
uint32_t lo = mtime_lo();
if (hi == mtime_hi())
if (hi == mtime_hi()) {
return ((uint64_t)hi << 32) | lo;
}
}
}
uint32_t get_timer_freq(void) { return TIMER_FREQ; }

View File

@@ -110,7 +110,8 @@ static void system_clock_108m_hxtal(void) {
/* if fail */
if (0U == (RCU_CTL & RCU_CTL_HXTALSTB)) {
while (1) {}
while (1) {
}
}
/* HXTAL is stable */
@@ -133,12 +134,14 @@ static void system_clock_108m_hxtal(void) {
/* enable PLL1 */
RCU_CTL |= RCU_CTL_PLL1EN;
/* wait till PLL1 is ready */
while (0U == (RCU_CTL & RCU_CTL_PLL1STB)) {}
while (0U == (RCU_CTL & RCU_CTL_PLL1STB)) {
}
/* enable PLL1 */
RCU_CTL |= RCU_CTL_PLL2EN;
/* wait till PLL1 is ready */
while (0U == (RCU_CTL & RCU_CTL_PLL2STB)) {}
while (0U == (RCU_CTL & RCU_CTL_PLL2STB)) {
}
} else if (HXTAL_VALUE == 8000000) {
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 | RCU_PREDV1_DIV2 | RCU_PLL1_MUL20 | RCU_PLL2_MUL20);
@@ -146,25 +149,29 @@ static void system_clock_108m_hxtal(void) {
/* enable PLL1 */
RCU_CTL |= RCU_CTL_PLL1EN;
/* wait till PLL1 is ready */
while (0U == (RCU_CTL & RCU_CTL_PLL1STB)) {}
while (0U == (RCU_CTL & RCU_CTL_PLL1STB)) {
}
/* enable PLL2 */
RCU_CTL |= RCU_CTL_PLL2EN;
/* wait till PLL1 is ready */
while (0U == (RCU_CTL & RCU_CTL_PLL2STB)) {}
while (0U == (RCU_CTL & RCU_CTL_PLL2STB)) {
}
}
/* enable PLL */
RCU_CTL |= RCU_CTL_PLLEN;
/* wait until PLL is stable */
while (0U == (RCU_CTL & RCU_CTL_PLLSTB)) {}
while (0U == (RCU_CTL & RCU_CTL_PLLSTB)) {
}
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
/* wait until PLL is selected as system clock */
while (0U == (RCU_CFG0 & RCU_SCSS_PLL)) {}
while (0U == (RCU_CFG0 & RCU_SCSS_PLL)) {
}
}
/*!
@@ -343,8 +350,8 @@ static void system_default_exception_handler(unsigned long mcause, unsigned long
printf("MCAUSE: 0x%lx\r\n", mcause);
printf("MEPC : 0x%lx\r\n", __RV_CSR_READ(CSR_MEPC));
printf("MTVAL : 0x%lx\r\n", __RV_CSR_READ(CSR_MBADADDR));
while (1)
;
while (1) {
}
}
/**

View File

@@ -146,6 +146,7 @@
#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F
#define POW_PD 1
#define USB_PD_EPR_WATTAGE 0 /*No EPR (Yet?) */
#define POW_PD_EXT 0
#define POW_QC 1
#define POW_DC 1

View File

@@ -79,15 +79,15 @@
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
#if (configSUPPORT_DYNAMIC_ALLOCATION == 0)
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
#endif
/* Block sizes must not get too small. */
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )
#define heapMINIMUM_BLOCK_SIZE ((size_t)(xHeapStructSize << 1))
/* Assumes 8bit bytes! */
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
#define heapBITS_PER_BYTE ((size_t)8)
/* Define the linked list structure. This is used to link free blocks in order
* of their memory address. */
@@ -104,13 +104,13 @@ typedef struct A_BLOCK_LINK {
* the block in front it and/or the block behind it if the memory blocks are
* adjacent to each other.
*/
static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );
static void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert);
/*-----------------------------------------------------------*/
/* The size of the structure placed at the beginning of each allocated memory
* block must by correctly byte aligned. */
static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
static const size_t xHeapStructSize = (sizeof(BlockLink_t) + ((size_t)(portBYTE_ALIGNMENT - 1))) & ~((size_t)portBYTE_ALIGNMENT_MASK);
/* Create a couple of list links to mark the start and end of the list. */
static BlockLink_t xStart, *pxEnd = NULL;
@@ -130,13 +130,13 @@ static size_t xBlockAllocatedBit = 0;
/*-----------------------------------------------------------*/
void *pvPortMalloc( size_t xWantedSize ) {
void *pvPortMalloc(size_t xWantedSize) {
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
void *pvReturn = NULL;
/* The heap must be initialised before the first call to
* prvPortMalloc(). */
configASSERT( pxEnd );
configASSERT(pxEnd);
vTaskSuspendAll();
{
@@ -144,17 +144,17 @@ void *pvPortMalloc( size_t xWantedSize ) {
* set. The top bit of the block size member of the BlockLink_t structure
* is used to determine who owns the block - the application or the
* kernel, so it must be free. */
if ( ( xWantedSize & xBlockAllocatedBit ) == 0 ) {
if ((xWantedSize & xBlockAllocatedBit) == 0) {
/* The wanted size is increased so it can contain a BlockLink_t
* structure in addition to the requested amount of bytes. */
if ( xWantedSize > 0 ) {
if (xWantedSize > 0) {
xWantedSize += xHeapStructSize;
/* Ensure that blocks are always aligned to the required number
* of bytes. */
if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) {
if ((xWantedSize & portBYTE_ALIGNMENT_MASK) != 0x00) {
/* Byte alignment required. */
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
xWantedSize += (portBYTE_ALIGNMENT - (xWantedSize & portBYTE_ALIGNMENT_MASK));
} else {
mtCOVERAGE_TEST_MARKER();
}
@@ -162,23 +162,23 @@ void *pvPortMalloc( size_t xWantedSize ) {
mtCOVERAGE_TEST_MARKER();
}
if ( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) {
if ((xWantedSize > 0) && (xWantedSize <= xFreeBytesRemaining)) {
/* Traverse the list from the start (lowest address) block until
* one of adequate size is found. */
pxPreviousBlock = &xStart;
pxBlock = xStart.pxNextFreeBlock;
while ( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) {
while ((pxBlock->xBlockSize < xWantedSize) && (pxBlock->pxNextFreeBlock != NULL)) {
pxPreviousBlock = pxBlock;
pxBlock = pxBlock->pxNextFreeBlock;
}
/* If the end marker was reached then a block of adequate size
* was not found. */
if ( pxBlock != pxEnd ) {
if (pxBlock != pxEnd) {
/* Return the memory space pointed to - jumping over the
* BlockLink_t structure at its start. */
pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );
pvReturn = (void *)(((uint8_t *)pxPreviousBlock->pxNextFreeBlock) + xHeapStructSize);
/* This block is being returned for use so must be taken out
* of the list of free blocks. */
@@ -186,12 +186,12 @@ void *pvPortMalloc( size_t xWantedSize ) {
/* If the block is larger than required it can be split into
* two. */
if ( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) {
if ((pxBlock->xBlockSize - xWantedSize) > heapMINIMUM_BLOCK_SIZE) {
/* This block is to be split into two. Create a new
* block following the number of bytes requested. The void
* cast is used to prevent byte alignment warnings from the
* compiler. */
pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
pxNewBlockLink = (void *)(((uint8_t *)pxBlock) + xWantedSize);
/* Calculate the sizes of two blocks split from the
* single block. */
@@ -199,14 +199,14 @@ void *pvPortMalloc( size_t xWantedSize ) {
pxBlock->xBlockSize = xWantedSize;
/* Insert the new block into the list of free blocks. */
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
prvInsertBlockIntoFreeList((pxNewBlockLink));
} else {
mtCOVERAGE_TEST_MARKER();
}
xFreeBytesRemaining -= pxBlock->xBlockSize;
if ( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) {
if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) {
xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;
} else {
mtCOVERAGE_TEST_MARKER();
@@ -227,14 +227,14 @@ void *pvPortMalloc( size_t xWantedSize ) {
mtCOVERAGE_TEST_MARKER();
}
traceMALLOC( pvReturn, xWantedSize );
traceMALLOC(pvReturn, xWantedSize);
}
( void ) xTaskResumeAll();
(void)xTaskResumeAll();
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
#if (configUSE_MALLOC_FAILED_HOOK == 1)
{
if ( pvReturn == NULL ) {
extern void vApplicationMallocFailedHook( void );
if (pvReturn == NULL) {
extern void vApplicationMallocFailedHook(void);
vApplicationMallocFailedHook();
} else {
mtCOVERAGE_TEST_MARKER();
@@ -246,24 +246,24 @@ void *pvPortMalloc( size_t xWantedSize ) {
}
/*-----------------------------------------------------------*/
void vPortFree( void *pv ) {
uint8_t *puc = ( uint8_t * ) pv;
void vPortFree(void *pv) {
uint8_t *puc = (uint8_t *)pv;
BlockLink_t *pxLink;
if ( pv != NULL ) {
if (pv != NULL) {
/* The memory being freed will have an BlockLink_t structure immediately
* before it. */
puc -= xHeapStructSize;
/* This casting is to keep the compiler from issuing warnings. */
pxLink = ( void * ) puc;
pxLink = (void *)puc;
/* Check the block is actually allocated. */
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
configASSERT( pxLink->pxNextFreeBlock == NULL );
configASSERT((pxLink->xBlockSize & xBlockAllocatedBit) != 0);
configASSERT(pxLink->pxNextFreeBlock == NULL);
if ( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) {
if ( pxLink->pxNextFreeBlock == NULL ) {
if ((pxLink->xBlockSize & xBlockAllocatedBit) != 0) {
if (pxLink->pxNextFreeBlock == NULL) {
/* The block is being returned to the heap - it is no longer
* allocated. */
pxLink->xBlockSize &= ~xBlockAllocatedBit;
@@ -272,11 +272,11 @@ void vPortFree( void *pv ) {
{
/* Add this block to the list of free blocks. */
xFreeBytesRemaining += pxLink->xBlockSize;
traceFREE( pv, pxLink->xBlockSize );
prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
traceFREE(pv, pxLink->xBlockSize);
prvInsertBlockIntoFreeList(((BlockLink_t *)pxLink));
xNumberOfSuccessfulFrees++;
}
( void ) xTaskResumeAll();
(void)xTaskResumeAll();
} else {
mtCOVERAGE_TEST_MARKER();
}
@@ -287,27 +287,27 @@ void vPortFree( void *pv ) {
}
/*-----------------------------------------------------------*/
size_t xPortGetFreeHeapSize( void ) { return xFreeBytesRemaining; }
size_t xPortGetFreeHeapSize(void) { return xFreeBytesRemaining; }
/*-----------------------------------------------------------*/
size_t xPortGetMinimumEverFreeHeapSize( void ) { return xMinimumEverFreeBytesRemaining; }
size_t xPortGetMinimumEverFreeHeapSize(void) { return xMinimumEverFreeBytesRemaining; }
/*-----------------------------------------------------------*/
static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) {
static void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert) {
BlockLink_t *pxIterator;
uint8_t *puc;
/* Iterate through the list until a block is found that has a higher address
* than the block being inserted. */
for ( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) {
for (pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock) {
/* Nothing to do here, just iterate to the right position. */
}
/* Do the block being inserted, and the block it is being inserted after
* make a contiguous block of memory? */
puc = ( uint8_t * ) pxIterator;
puc = (uint8_t *)pxIterator;
if ( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) {
if ((puc + pxIterator->xBlockSize) == (uint8_t *)pxBlockToInsert) {
pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;
pxBlockToInsert = pxIterator;
} else {
@@ -316,10 +316,10 @@ static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) {
/* Do the block being inserted, and the block it is being inserted before
* make a contiguous block of memory? */
puc = ( uint8_t * ) pxBlockToInsert;
puc = (uint8_t *)pxBlockToInsert;
if ( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) {
if ( pxIterator->pxNextFreeBlock != pxEnd ) {
if ((puc + pxBlockToInsert->xBlockSize) == (uint8_t *)pxIterator->pxNextFreeBlock) {
if (pxIterator->pxNextFreeBlock != pxEnd) {
/* Form one big block from the two blocks. */
pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;
@@ -334,7 +334,7 @@ static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) {
* before and the block after, then it's pxNextFreeBlock pointer will have
* already been set, and should not be set here as that would make it point
* to itself. */
if ( pxIterator != pxBlockToInsert ) {
if (pxIterator != pxBlockToInsert) {
pxIterator->pxNextFreeBlock = pxBlockToInsert;
} else {
mtCOVERAGE_TEST_MARKER();
@@ -342,7 +342,7 @@ static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) {
}
/*-----------------------------------------------------------*/
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) {
void vPortDefineHeapRegions(const HeapRegion_t *const pxHeapRegions) {
BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;
size_t xAlignedHeap;
size_t xTotalRegionSize, xTotalHeapSize = 0;
@@ -351,39 +351,39 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) {
const HeapRegion_t *pxHeapRegion;
/* Can only call once! */
configASSERT( pxEnd == NULL );
configASSERT(pxEnd == NULL);
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
pxHeapRegion = &(pxHeapRegions[xDefinedRegions]);
while ( pxHeapRegion->xSizeInBytes > 0 ) {
while (pxHeapRegion->xSizeInBytes > 0) {
xTotalRegionSize = pxHeapRegion->xSizeInBytes;
/* Ensure the heap region starts on a correctly aligned boundary. */
xAddress = ( size_t ) pxHeapRegion->pucStartAddress;
xAddress = (size_t)pxHeapRegion->pucStartAddress;
if ( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) {
xAddress += ( portBYTE_ALIGNMENT - 1 );
if ((xAddress & portBYTE_ALIGNMENT_MASK) != 0) {
xAddress += (portBYTE_ALIGNMENT - 1);
xAddress &= ~portBYTE_ALIGNMENT_MASK;
/* Adjust the size for the bytes lost to alignment. */
xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;
xTotalRegionSize -= xAddress - (size_t)pxHeapRegion->pucStartAddress;
}
xAlignedHeap = xAddress;
/* Set xStart if it has not already been set. */
if ( xDefinedRegions == 0 ) {
if (xDefinedRegions == 0) {
/* xStart is used to hold a pointer to the first item in the list of
* free blocks. The void cast is used to prevent compiler warnings. */
xStart.pxNextFreeBlock = ( BlockLink_t * ) xAlignedHeap;
xStart.xBlockSize = ( size_t ) 0;
xStart.pxNextFreeBlock = (BlockLink_t *)xAlignedHeap;
xStart.xBlockSize = (size_t)0;
} else {
/* Should only get here if one region has already been added to the
* heap. */
configASSERT( pxEnd != NULL );
configASSERT(pxEnd != NULL);
/* Check blocks are passed in with increasing start addresses. */
configASSERT( xAddress > ( size_t ) pxEnd );
configASSERT(xAddress > (size_t)pxEnd);
}
/* Remember the location of the end marker in the previous region, if
@@ -396,20 +396,20 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) {
xAddress -= xHeapStructSize;
xAddress &= ~portBYTE_ALIGNMENT_MASK;
pxEnd = ( BlockLink_t * ) xAddress;
pxEnd = (BlockLink_t *)xAddress;
pxEnd->xBlockSize = 0;
pxEnd->pxNextFreeBlock = NULL;
/* To start with there is a single free block in this region that is
* sized to take up the entire heap region minus the space taken by the
* free block structure. */
pxFirstFreeBlockInRegion = ( BlockLink_t * ) xAlignedHeap;
pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion;
pxFirstFreeBlockInRegion = (BlockLink_t *)xAlignedHeap;
pxFirstFreeBlockInRegion->xBlockSize = xAddress - (size_t)pxFirstFreeBlockInRegion;
pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;
/* If this is not the first region that makes up the entire heap space
* then link the previous region to this region. */
if ( pxPreviousFreeBlock != NULL ) {
if (pxPreviousFreeBlock != NULL) {
pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion;
}
@@ -417,21 +417,21 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) {
/* Move onto the next HeapRegion_t structure. */
xDefinedRegions++;
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
pxHeapRegion = &(pxHeapRegions[xDefinedRegions]);
}
xMinimumEverFreeBytesRemaining = xTotalHeapSize;
xFreeBytesRemaining = xTotalHeapSize;
/* Check something was actually defined before it is accessed. */
configASSERT( xTotalHeapSize );
configASSERT(xTotalHeapSize);
/* Work out the position of the top bit in a size_t variable. */
xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
xBlockAllocatedBit = ((size_t)1) << ((sizeof(size_t) * heapBITS_PER_BYTE) - 1);
}
/*-----------------------------------------------------------*/
void vPortGetHeapStats( HeapStats_t *pxHeapStats ) {
void vPortGetHeapStats(HeapStats_t *pxHeapStats) {
BlockLink_t *pxBlock;
size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */
@@ -441,21 +441,21 @@ void vPortGetHeapStats( HeapStats_t *pxHeapStats ) {
/* pxBlock will be NULL if the heap has not been initialised. The heap
* is initialised automatically when the first allocation is made. */
if ( pxBlock != NULL ) {
if (pxBlock != NULL) {
do {
/* Increment the number of blocks and record the largest block seen
* so far. */
xBlocks++;
if ( pxBlock->xBlockSize > xMaxSize ) {
if (pxBlock->xBlockSize > xMaxSize) {
xMaxSize = pxBlock->xBlockSize;
}
/* Heap five will have a zero sized block at the end of each
* each region - the block is only used to link to the next
* heap region so it not a real block. */
if ( pxBlock->xBlockSize != 0 ) {
if ( pxBlock->xBlockSize < xMinSize ) {
if (pxBlock->xBlockSize != 0) {
if (pxBlock->xBlockSize < xMinSize) {
xMinSize = pxBlock->xBlockSize;
}
}
@@ -463,10 +463,10 @@ void vPortGetHeapStats( HeapStats_t *pxHeapStats ) {
/* Move to the next block in the chain until the last block is
* reached. */
pxBlock = pxBlock->pxNextFreeBlock;
} while ( pxBlock != pxEnd );
} while (pxBlock != pxEnd);
}
}
( void ) xTaskResumeAll();
(void)xTaskResumeAll();
pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize;
pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize;

View File

@@ -23,8 +23,8 @@ extern uint8_t _heap_start;
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
static HeapRegion_t xHeapRegions[] = {
{&_heap_start, (unsigned int)&_heap_size},
{NULL, 0}, /* Terminates the array. */
{NULL, 0} /* Terminates the array. */
{ NULL, 0}, /* Terminates the array. */
{ NULL, 0} /* Terminates the array. */
};
// Functions
@@ -86,8 +86,8 @@ void setup_pwm(void) {
PWM_Channel_Disable(PWM_Channel);
}
const ADC_Chan_Type adc_tip_pos_chans[]
= {TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL};
const ADC_Chan_Type adc_tip_pos_chans[] = {TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL,
TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL};
const ADC_Chan_Type adc_tip_neg_chans[] = {ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND};
static_assert(sizeof(adc_tip_pos_chans) == sizeof(adc_tip_neg_chans));

View File

@@ -36,7 +36,8 @@ static uint8_t uart_dbg_disable = 0;
struct heap_info mmheap_root;
static struct heap_region system_mmheap[] = {
{NULL, 0}, {NULL, 0}, /* Terminates the array. */
{NULL, 0},
{NULL, 0}, /* Terminates the array. */
};
__WEAK__ void board_init(void) {}

View File

@@ -203,7 +203,8 @@ void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) { return NULL; }
/* for exit() and abort() */
void __attribute__((noreturn)) _exit(int status) {
while (1) {}
while (1) {
}
}
void _system(const char *s) {}

View File

@@ -1,194 +0,0 @@
/**
* @file uart_interface.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "bflb_platform.h"
#include "hal_gpio.h"
#include "uart_interface.h"
#include "hal_usb.h"
#include "hal_dma.h"
#define USB_OUT_RINGBUFFER_SIZE (8 * 1024)
#define UART_RX_RINGBUFFER_SIZE (8 * 1024)
#define UART_TX_DMA_SIZE (4095)
uint8_t usb_rx_mem[USB_OUT_RINGBUFFER_SIZE] __attribute__((section(".system_ram")));
uint8_t uart_rx_mem[UART_RX_RINGBUFFER_SIZE] __attribute__((section(".system_ram")));
uint8_t src_buffer[UART_TX_DMA_SIZE] __attribute__((section(".tcm_code")));
struct device *uart1;
struct device *dma_ch2;
Ring_Buffer_Type usb_rx_rb;
Ring_Buffer_Type uart1_rx_rb;
void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
if (state == UART_EVENT_RX_FIFO) {
if (size && size < Ring_Buffer_Get_Empty_Length(&uart1_rx_rb)) {
Ring_Buffer_Write(&uart1_rx_rb, (uint8_t *)args, size);
} else {
MSG("RF OV\r\n");
}
} else if (state == UART_EVENT_RTO) {
if (size && size < Ring_Buffer_Get_Empty_Length(&uart1_rx_rb)) {
Ring_Buffer_Write(&uart1_rx_rb, (uint8_t *)args, size);
} else {
MSG("RTO OV\r\n");
}
} else if (state == UART_RX_FER_IT) {
MSG("RX ERR\r\n");
}
}
void uart1_init(void)
{
#ifdef UART1_INDEX
uart_register(UART1_INDEX, "uart1");
uart1 = device_find("uart1");
if (uart1) {
// device_open(uart1, DEVICE_OFLAG_DMA_TX | DEVICE_OFLAG_INT_RX);
// device_set_callback(uart1, uart_irq_callback);
// device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
}
dma_register(DMA0_CH2_INDEX, "ch2");
dma_ch2 = device_find("ch2");
if (dma_ch2) {
DMA_DEV(dma_ch2)->direction = DMA_MEMORY_TO_PERIPH;
DMA_DEV(dma_ch2)->transfer_mode = DMA_LLI_ONCE_MODE;
DMA_DEV(dma_ch2)->src_req = DMA_REQUEST_NONE;
DMA_DEV(dma_ch2)->dst_req = DMA_REQUEST_UART1_TX;
DMA_DEV(dma_ch2)->src_addr_inc = DMA_ADDR_INCREMENT_ENABLE;
DMA_DEV(dma_ch2)->dst_addr_inc = DMA_ADDR_INCREMENT_DISABLE;
DMA_DEV(dma_ch2)->src_burst_size = DMA_BURST_1BYTE;
DMA_DEV(dma_ch2)->dst_burst_size = DMA_BURST_1BYTE;
DMA_DEV(dma_ch2)->src_width = DMA_TRANSFER_WIDTH_8BIT;
DMA_DEV(dma_ch2)->dst_width = DMA_TRANSFER_WIDTH_8BIT;
device_open(dma_ch2, 0);
}
#endif
}
void uart1_config(uint32_t baudrate, uart_databits_t databits, uart_parity_t parity, uart_stopbits_t stopbits)
{
device_close(uart1);
UART_DEV(uart1)->baudrate = baudrate;
UART_DEV(uart1)->stopbits = stopbits;
UART_DEV(uart1)->parity = parity;
UART_DEV(uart1)->databits = (databits - 5);
device_open(uart1, DEVICE_OFLAG_DMA_TX | DEVICE_OFLAG_INT_RX);
device_set_callback(uart1, uart_irq_callback);
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
Ring_Buffer_Reset(&usb_rx_rb);
Ring_Buffer_Reset(&uart1_rx_rb);
}
static uint8_t uart1_dtr;
static uint8_t uart1_rts;
void uart1_set_dtr_rts(uint8_t dtr, uint8_t rts)
{
uart1_dtr = dtr;
uart1_rts = rts;
}
void uart1_dtr_init(void)
{
gpio_set_mode(uart1_dtr, GPIO_OUTPUT_MODE);
}
void uart1_rts_init(void)
{
gpio_set_mode(uart1_rts, GPIO_OUTPUT_MODE);
}
void uart1_dtr_deinit(void)
{
gpio_set_mode(uart1_dtr, GPIO_INPUT_MODE);
}
void uart1_rts_deinit(void)
{
gpio_set_mode(uart1_rts, GPIO_INPUT_MODE);
}
void dtr_pin_set(uint8_t status)
{
gpio_write(uart1_dtr, status);
}
void rts_pin_set(uint8_t status)
{
gpio_write(uart1_rts, status);
}
void ringbuffer_lock()
{
cpu_global_irq_disable();
}
void ringbuffer_unlock()
{
cpu_global_irq_enable();
}
void uart_ringbuffer_init(void)
{
/* init mem for ring_buffer */
memset(usb_rx_mem, 0, USB_OUT_RINGBUFFER_SIZE);
memset(uart_rx_mem, 0, UART_RX_RINGBUFFER_SIZE);
/* init ring_buffer */
Ring_Buffer_Init(&usb_rx_rb, usb_rx_mem, USB_OUT_RINGBUFFER_SIZE, ringbuffer_lock, ringbuffer_unlock);
Ring_Buffer_Init(&uart1_rx_rb, uart_rx_mem, UART_RX_RINGBUFFER_SIZE, ringbuffer_lock, ringbuffer_unlock);
}
static dma_control_data_t uart_dma_ctrl_cfg = {
.bits.fix_cnt = 0,
.bits.dst_min_mode = 0,
.bits.dst_add_mode = 0,
.bits.SI = 1,
.bits.DI = 0,
.bits.SWidth = DMA_TRANSFER_WIDTH_8BIT,
.bits.DWidth = DMA_TRANSFER_WIDTH_8BIT,
.bits.SBSize = 0,
.bits.DBSize = 0,
.bits.I = 0,
.bits.TransferSize = 4095
};
static dma_lli_ctrl_t uart_lli_list = {
.src_addr = (uint32_t)src_buffer,
.dst_addr = DMA_ADDR_UART1_TDR,
.nextlli = 0
};
void uart_send_from_ringbuffer(void)
{
if (Ring_Buffer_Get_Length(&usb_rx_rb)) {
if (!dma_channel_check_busy(dma_ch2)) {
uint32_t avalibleCnt = Ring_Buffer_Read(&usb_rx_rb, src_buffer, UART_TX_DMA_SIZE);
if (avalibleCnt) {
dma_channel_stop(dma_ch2);
uart_dma_ctrl_cfg.bits.TransferSize = avalibleCnt;
memcpy(&uart_lli_list.cfg, &uart_dma_ctrl_cfg, sizeof(dma_control_data_t));
dma_channel_update(dma_ch2, (void *)((uint32_t)&uart_lli_list));
dma_channel_start(dma_ch2);
}
}
}
}

View File

@@ -1,44 +0,0 @@
/**
* @file uart_interface.h
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#ifndef __UART_IF_H__
#define __UART_IF_H__
#include "hal_uart.h"
#include "ring_buffer.h"
extern Ring_Buffer_Type usb_rx_rb;
extern Ring_Buffer_Type uart1_rx_rb;
void uart1_init(void);
void uart1_config(uint32_t baudrate, uart_databits_t databits, uart_parity_t parity, uart_stopbits_t stopbits);
void uart1_set_dtr_rts(uint8_t dtr, uint8_t rts);
void uart1_dtr_init(void);
void uart1_rts_init(void);
void uart1_dtr_deinit(void);
void uart1_rts_deinit(void);
void dtr_pin_set(uint8_t status);
void rts_pin_set(uint8_t status);
void uart_ringbuffer_init(void);
void uart_send_from_ringbuffer(void);
#endif

View File

@@ -1,82 +0,0 @@
/**
* @file usb_dc.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "hal_usb.h"
#include "stdbool.h"
#include "usbd_core.h"
struct device *usb;
#ifdef USB_INDEX
static void usb_dc_event_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
usbd_event_notify_handler(state, args);
}
#endif
struct device *usb_dc_init(void)
{
#ifdef USB_INDEX
usb_dc_register(USB_INDEX, "usb");
usb = device_find("usb");
device_set_callback(usb, usb_dc_event_callback);
device_open(usb, 0);
return usb;
#endif
return NULL;
}
int usbd_set_address(const uint8_t addr)
{
return usb_dc_set_dev_address(addr);
}
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
{
return usb_dc_ep_open(usb, (const struct usb_dc_ep_cfg *)ep_cfg);
}
int usbd_ep_close(const uint8_t ep)
{
return usb_dc_ep_close(ep);
}
int usbd_ep_set_stall(const uint8_t ep)
{
return usb_dc_ep_set_stall(ep);
}
int usbd_ep_clear_stall(const uint8_t ep)
{
return usb_dc_ep_clear_stall(ep);
}
int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled)
{
return usb_dc_ep_is_stalled(usb, ep, stalled);
}
int usbd_ep_write(const uint8_t ep, const uint8_t *data, uint32_t data_len, uint32_t *ret_bytes)
{
return usb_dc_ep_write(usb, ep, data, data_len, ret_bytes);
}
int usbd_ep_read(const uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_t *read_bytes)
{
return usb_dc_ep_read(usb, ep, data, max_data_len, read_bytes);
}

View File

@@ -23,8 +23,7 @@
#include "arm_dsp_wrapper.h"
void arm_fill_f32(float32_t value, float32_t *pDst, uint32_t blockSize)
{
void arm_fill_f32(float32_t value, float32_t *pDst, uint32_t blockSize) {
uint32_t blkCnt = blockSize >> 2u;
float32_t in1 = value;

View File

@@ -38,10 +38,7 @@ dlist_t device_head = DLIST_OBJECT_INIT(device_head);
*
* @return device header
*/
dlist_t *device_get_list_header(void)
{
return &device_head;
}
dlist_t *device_get_list_header(void) { return &device_head; }
/**
* This function registers a device driver with specified name.
@@ -52,12 +49,10 @@ dlist_t *device_get_list_header(void)
*
* @return the error code, DEVICE_EOK on initialization successfully.
*/
int device_register(struct device *dev, const char *name)
{
int device_register(struct device *dev, const char *name) {
dlist_t *node;
dlist_for_each(node, &device_head)
{
dlist_for_each(node, &device_head) {
struct device *dev_obj;
dev_obj = dlist_entry(node, struct device, list);
@@ -82,8 +77,7 @@ int device_register(struct device *dev, const char *name)
*
* @return the error code, DEVICE_EOK on initialization successfully.
*/
int device_unregister(const char *name)
{
int device_unregister(const char *name) {
struct device *dev = device_find(name);
if (!dev) {
@@ -102,13 +96,11 @@ int device_unregister(const char *name)
*
* @return the registered device driver on successful, or NULL on failure.
*/
struct device *device_find(const char *name)
{
struct device *device_find(const char *name) {
struct device *dev;
dlist_t *node;
dlist_for_each(node, &device_head)
{
dlist_for_each(node, &device_head) {
dev = dlist_entry(node, struct device, list);
if (strncmp(dev->name, name, DEVICE_NAME_MAX) == 0) {
@@ -126,8 +118,7 @@ struct device *device_find(const char *name)
*
* @return the result
*/
int device_open(struct device *dev, uint16_t oflag)
{
int device_open(struct device *dev, uint16_t oflag) {
#ifdef DEVICE_CHECK_PARAM
int retval = DEVICE_EOK;
@@ -155,8 +146,7 @@ int device_open(struct device *dev, uint16_t oflag)
*
* @return the result
*/
int device_close(struct device *dev)
{
int device_close(struct device *dev) {
#ifdef DEVICE_CHECK_PARAM
int retval = DEVICE_EOK;
@@ -186,8 +176,7 @@ int device_close(struct device *dev)
*
* @return the result
*/
int device_control(struct device *dev, int cmd, void *args)
{
int device_control(struct device *dev, int cmd, void *args) {
#ifdef DEVICE_CHECK_PARAM
int retval = DEVICE_EOK;
@@ -216,8 +205,7 @@ int device_control(struct device *dev, int cmd, void *args)
*
* @return the actually written size on successful, otherwise negative returned.
*/
int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size)
{
int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size) {
#ifdef DEVICE_CHECK_PARAM
int retval = DEVICE_EOK;
@@ -246,8 +234,7 @@ int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t
*
* @return the actually read size on successful, otherwise negative returned.
*/
int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
{
int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size) {
#ifdef DEVICE_CHECK_PARAM
int retval = DEVICE_EOK;
@@ -276,8 +263,7 @@ int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
*
* @return the actually read size on successful, otherwise negative returned.
*/
int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event))
{
int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event)) {
int retval = DEVICE_EOK;
if (dev->status > DEVICE_UNREGISTER) {

View File

@@ -33,8 +33,7 @@
* @return Destination pointer
*
*******************************************************************************/
__WEAK__ void *ATTR_TCM_SECTION arch_memcpy(void *dst, const void *src, uint32_t n)
{
__WEAK__ void *ATTR_TCM_SECTION arch_memcpy(void *dst, const void *src, uint32_t n) {
const uint8_t *p = src;
uint8_t *q = dst;
@@ -55,8 +54,7 @@ __WEAK__ void *ATTR_TCM_SECTION arch_memcpy(void *dst, const void *src, uint32_t
* @return Destination pointer
*
*******************************************************************************/
__WEAK__ uint32_t *ATTR_TCM_SECTION arch_memcpy4(uint32_t *dst, const uint32_t *src, uint32_t n)
{
__WEAK__ uint32_t *ATTR_TCM_SECTION arch_memcpy4(uint32_t *dst, const uint32_t *src, uint32_t n) {
const uint32_t *p = src;
uint32_t *q = dst;
@@ -77,8 +75,7 @@ __WEAK__ uint32_t *ATTR_TCM_SECTION arch_memcpy4(uint32_t *dst, const uint32_t *
* @return Destination pointer
*
*******************************************************************************/
__WEAK__ void *ATTR_TCM_SECTION arch_memcpy_fast(void *pdst, const void *psrc, uint32_t n)
{
__WEAK__ void *ATTR_TCM_SECTION arch_memcpy_fast(void *pdst, const void *psrc, uint32_t n) {
uint32_t left, done, i = 0;
uint8_t *dst = (uint8_t *)pdst;
uint8_t *src = (uint8_t *)psrc;
@@ -109,8 +106,7 @@ __WEAK__ void *ATTR_TCM_SECTION arch_memcpy_fast(void *pdst, const void *psrc, u
* @return Destination pointer
*
*******************************************************************************/
__WEAK__ void *ATTR_TCM_SECTION arch_memset(void *s, uint8_t c, uint32_t n)
{
__WEAK__ void *ATTR_TCM_SECTION arch_memset(void *s, uint8_t c, uint32_t n) {
uint8_t *p = (uint8_t *)s;
while (n > 0) {
@@ -130,8 +126,7 @@ __WEAK__ void *ATTR_TCM_SECTION arch_memset(void *s, uint8_t c, uint32_t n)
* @return Destination pointer
*
*******************************************************************************/
__WEAK__ uint32_t *ATTR_TCM_SECTION arch_memset4(uint32_t *dst, const uint32_t val, uint32_t n)
{
__WEAK__ uint32_t *ATTR_TCM_SECTION arch_memset4(uint32_t *dst, const uint32_t val, uint32_t n) {
uint32_t *q = dst;
while (n--) {
@@ -151,8 +146,7 @@ __WEAK__ uint32_t *ATTR_TCM_SECTION arch_memset4(uint32_t *dst, const uint32_t v
* @return compare result
*
*******************************************************************************/
__WEAK__ int ATTR_TCM_SECTION arch_memcmp(const void *s1, const void *s2, uint32_t n)
{
__WEAK__ int ATTR_TCM_SECTION arch_memcmp(const void *s1, const void *s2, uint32_t n) {
const unsigned char *c1 = s1, *c2 = s2;
int d = 0;
@@ -168,8 +162,7 @@ __WEAK__ int ATTR_TCM_SECTION arch_memcmp(const void *s1, const void *s2, uint32
}
#endif
void memcopy_to_fifo(void *fifo_addr, uint8_t *data, uint32_t length)
{
void memcopy_to_fifo(void *fifo_addr, uint8_t *data, uint32_t length) {
uint8_t *p = (uint8_t *)fifo_addr;
uint8_t *q = data;
@@ -178,8 +171,7 @@ void memcopy_to_fifo(void *fifo_addr, uint8_t *data, uint32_t length)
}
}
void fifocopy_to_mem(void *fifo_addr, uint8_t *data, uint32_t length)
{
void fifocopy_to_mem(void *fifo_addr, uint8_t *data, uint32_t length) {
uint8_t *p = (uint8_t *)fifo_addr;
uint8_t *q = data;
@@ -196,9 +188,8 @@ void fifocopy_to_mem(void *fifo_addr, uint8_t *data, uint32_t length)
*
* @return SUCCESS or ERROR
*
*******************************************************************************/
int arch_ffsll(uint64_t *val, uint32_t *bit)
{
*******************************************************************************/
int arch_ffsll(uint64_t *val, uint32_t *bit) {
if (!*val) {
return ERROR;
}
@@ -208,20 +199,20 @@ int arch_ffsll(uint64_t *val, uint32_t *bit)
return 0;
}
int arch_ctzll(uint64_t *val, uint32_t *bit)
{
if (!*val)
int arch_ctzll(uint64_t *val, uint32_t *bit) {
if (!*val) {
return -1;
}
*bit = __builtin_ctzll(*val);
*val &= ~((1ULL) << (*bit));
return 0;
}
int arch_clzll(uint64_t *val, uint32_t *bit)
{
if (!*val)
int arch_clzll(uint64_t *val, uint32_t *bit) {
if (!*val) {
return -1;
}
*bit = __builtin_clzll(*val);
*val &= ~((1ULL) << (*bit));
@@ -238,11 +229,10 @@ int arch_clzll(uint64_t *val, uint32_t *bit)
* @return None
*******************************************************************************/
void check_failed(uint8_t *file, uint32_t line)
{
void check_failed(uint8_t *file, uint32_t line) {
/* Infinite loop */
while (1)
;
while (1) {
}
}
#endif /* DEBUG */

View File

@@ -35,8 +35,8 @@
*/
#include "partition.h"
#include "softcrc.h"
#include "bflb_platform.h"
#include "softcrc.h"
/** @addtogroup BFLB_Common_Driver
* @{
@@ -92,9 +92,8 @@ extern int main(void);
*
* @return 0 for invalid and 1 for valid
*
*******************************************************************************/
static uint8_t pt_table_valid(pt_table_stuff_config *pt_stuff)
{
*******************************************************************************/
static uint8_t pt_table_valid(pt_table_stuff_config *pt_stuff) {
pt_table_config *pt_table = &pt_stuff->pt_table;
pt_table_entry_config *pt_entries = pt_stuff->pt_entries;
uint32_t *p_crc32;
@@ -106,8 +105,7 @@ static uint8_t pt_table_valid(pt_table_stuff_config *pt_stuff)
return 0;
}
if (pt_table->crc32 !=
BFLB_Soft_CRC32((uint8_t *)pt_table, sizeof(pt_table_config) - 4)) {
if (pt_table->crc32 != BFLB_Soft_CRC32((uint8_t *)pt_table, sizeof(pt_table_config) - 4)) {
MSG("PT CRC Error\r\n");
return 0;
}
@@ -141,9 +139,8 @@ static uint8_t pt_table_valid(pt_table_stuff_config *pt_stuff)
*
* @return None
*
*******************************************************************************/
void pt_table_set_flash_operation(p_pt_table_flash_erase erase, p_pt_table_flash_write write, p_pt_table_flash_read read)
{
*******************************************************************************/
void pt_table_set_flash_operation(p_pt_table_flash_erase erase, p_pt_table_flash_write write, p_pt_table_flash_read read) {
gp_pt_table_flash_erase = erase;
gp_pt_table_flash_write = write;
gp_pt_table_flash_read = read;
@@ -156,10 +153,9 @@ void pt_table_set_flash_operation(p_pt_table_flash_erase erase, p_pt_table_flash
*
* @return Active partition table ID
*
*******************************************************************************/
pt_table_id_type pt_table_get_active_partition_need_lock(pt_table_stuff_config ptStuff[2])
{
uint32_t pt_valid[2] = { 0, 0 };
*******************************************************************************/
pt_table_id_type pt_table_get_active_partition_need_lock(pt_table_stuff_config ptStuff[2]) {
uint32_t pt_valid[2] = {0, 0};
pt_table_id_type activePtID;
if (ptStuff == NULL) {
@@ -198,11 +194,8 @@ pt_table_id_type pt_table_get_active_partition_need_lock(pt_table_stuff_config p
*
* @return PT_ERROR_SUCCESS or PT_ERROR_ENTRY_NOT_FOUND or PT_ERROR_PARAMETER
*
*******************************************************************************/
pt_table_error_type pt_table_get_active_entries_by_id(pt_table_stuff_config *pt_stuff,
pt_table_entry_type type,
pt_table_entry_config *pt_entry)
{
*******************************************************************************/
pt_table_error_type pt_table_get_active_entries_by_id(pt_table_stuff_config *pt_stuff, pt_table_entry_type type, pt_table_entry_config *pt_entry) {
uint32_t i = 0;
if (pt_stuff == NULL || pt_entry == NULL) {
@@ -228,11 +221,8 @@ pt_table_error_type pt_table_get_active_entries_by_id(pt_table_stuff_config *pt_
*
* @return PT_ERROR_SUCCESS or PT_ERROR_ENTRY_NOT_FOUND or PT_ERROR_PARAMETER
*
*******************************************************************************/
pt_table_error_type pt_table_get_active_entries_by_name(pt_table_stuff_config *pt_stuff,
uint8_t *name,
pt_table_entry_config *pt_entry)
{
*******************************************************************************/
pt_table_error_type pt_table_get_active_entries_by_name(pt_table_stuff_config *pt_stuff, uint8_t *name, pt_table_entry_config *pt_entry) {
uint32_t i = 0;
uint32_t len = strlen((char *)name);
@@ -241,8 +231,7 @@ pt_table_error_type pt_table_get_active_entries_by_name(pt_table_stuff_config *p
}
for (i = 0; i < pt_stuff->pt_table.entryCnt; i++) {
if (strlen((char *)pt_stuff->pt_entries[i].name) == len &&
memcmp((char *)pt_stuff->pt_entries[i].name, (char *)name, len) == 0) {
if (strlen((char *)pt_stuff->pt_entries[i].name) == len && memcmp((char *)pt_stuff->pt_entries[i].name, (char *)name, len) == 0) {
ARCH_MemCpy_Fast(pt_entry, &pt_stuff->pt_entries[i], sizeof(pt_table_entry_config));
return PT_ERROR_SUCCESS;
}
@@ -260,11 +249,8 @@ pt_table_error_type pt_table_get_active_entries_by_name(pt_table_stuff_config *p
*
* @return Partition update result
*
*******************************************************************************/
pt_table_error_type pt_table_update_entry(pt_table_id_type target_table_id,
pt_table_stuff_config *pt_stuff,
pt_table_entry_config *pt_entry)
{
*******************************************************************************/
pt_table_error_type pt_table_update_entry(pt_table_id_type target_table_id, pt_table_stuff_config *pt_stuff, pt_table_entry_config *pt_entry) {
uint32_t i = 0;
BL_Err_Type ret;
uint32_t write_addr;
@@ -319,7 +305,7 @@ pt_table_error_type pt_table_update_entry(pt_table_id_type target_table_id,
/* Write back to flash */
/* Erase flash first */
//ret = gp_pt_table_flash_erase(write_addr, write_addr + sizeof(pt_table_config) + entries_len + 4 - 1);
// ret = gp_pt_table_flash_erase(write_addr, write_addr + sizeof(pt_table_config) + entries_len + 4 - 1);
ret = gp_pt_table_flash_erase(write_addr, sizeof(pt_table_config) + entries_len + 4);
if (ret != SUCCESS) {
@@ -345,9 +331,8 @@ pt_table_error_type pt_table_update_entry(pt_table_id_type target_table_id,
*
* @return Partition create result
*
*******************************************************************************/
pt_table_error_type pt_table_create(pt_table_id_type pt_id)
{
*******************************************************************************/
pt_table_error_type pt_table_create(pt_table_id_type pt_id) {
uint32_t write_addr;
BL_Err_Type ret;
pt_table_config pt_table;
@@ -369,8 +354,8 @@ pt_table_error_type pt_table_create(pt_table_id_type pt_id)
pt_table.age = 0;
pt_table.crc32 = BFLB_Soft_CRC32((uint8_t *)&pt_table, sizeof(pt_table_config) - 4);
/* Write back to flash */
//ret = gp_pt_table_flash_erase(write_addr, write_addr + sizeof(pt_table_config) - 1);
ret = gp_pt_table_flash_erase(write_addr,sizeof(pt_table_config));
// ret = gp_pt_table_flash_erase(write_addr, write_addr + sizeof(pt_table_config) - 1);
ret = gp_pt_table_flash_erase(write_addr, sizeof(pt_table_config));
if (ret != SUCCESS) {
MSG_ERR("Flash Erase error\r\n");
@@ -387,9 +372,8 @@ pt_table_error_type pt_table_create(pt_table_id_type pt_id)
return PT_ERROR_SUCCESS;
}
pt_table_error_type pt_table_dump(void)
{
uint32_t pt_valid[2] = { 0, 0 };
pt_table_error_type pt_table_dump(void) {
uint32_t pt_valid[2] = {0, 0};
pt_table_stuff_config pt_stuff[2];
gp_pt_table_flash_read(BFLB_PT_TABLE0_ADDRESS, (uint8_t *)&pt_stuff[0], sizeof(pt_table_stuff_config));
@@ -435,9 +419,8 @@ pt_table_error_type pt_table_dump(void)
return PT_ERROR_SUCCESS;
}
pt_table_error_type pt_table_get_iap_para(pt_table_iap_param_type *para)
{
uint32_t pt_valid[2] = { 0, 0 };
pt_table_error_type pt_table_get_iap_para(pt_table_iap_param_type *para) {
uint32_t pt_valid[2] = {0, 0};
pt_table_stuff_config pt_stuff[2];
uint8_t active_index;
@@ -479,8 +462,7 @@ pt_table_error_type pt_table_get_iap_para(pt_table_iap_param_type *para)
return PT_ERROR_SUCCESS;
}
pt_table_error_type pt_table_set_iap_para(pt_table_iap_param_type *para)
{
pt_table_error_type pt_table_set_iap_para(pt_table_iap_param_type *para) {
pt_table_stuff_config pt_stuff, pt_stuff_write;
int32_t ret;
uint32_t *p_crc32;
@@ -497,12 +479,12 @@ pt_table_error_type pt_table_set_iap_para(pt_table_iap_param_type *para)
pt_stuff_write.pt_entries[0].active_index = !(pt_stuff_write.pt_entries[0].active_index & 0x01);
pt_stuff_write.pt_table.crc32 = BFLB_Soft_CRC32((uint8_t *)&pt_stuff_write, sizeof(pt_table_config) - 4);
entries_len = sizeof(pt_table_entry_config) * pt_stuff_write.pt_table.entryCnt;
//pt_stuff_write.crc32 = BFLB_Soft_CRC32((uint8_t*)pt_stuff_write.pt_entries,entries_len);
// pt_stuff_write.crc32 = BFLB_Soft_CRC32((uint8_t*)pt_stuff_write.pt_entries,entries_len);
p_crc32 = (uint32_t *)((uintptr_t)pt_stuff_write.pt_entries + entries_len);
*p_crc32 = BFLB_Soft_CRC32((uint8_t *)pt_stuff_write.pt_entries, entries_len);
if (para->inactive_table_index == 1) {
//ret = gp_pt_table_flash_erase(BFLB_PT_TABLE1_ADDRESS, BFLB_PT_TABLE1_ADDRESS + sizeof(pt_table_stuff_config) - 1);
// ret = gp_pt_table_flash_erase(BFLB_PT_TABLE1_ADDRESS, BFLB_PT_TABLE1_ADDRESS + sizeof(pt_table_stuff_config) - 1);
ret = gp_pt_table_flash_erase(BFLB_PT_TABLE1_ADDRESS, sizeof(pt_table_stuff_config));
if (ret != SUCCESS) {
@@ -517,7 +499,7 @@ pt_table_error_type pt_table_set_iap_para(pt_table_iap_param_type *para)
return PT_ERROR_FALSH_WRITE;
}
} else if (para->inactive_table_index == 0) {
//ret = gp_pt_table_flash_erase(BFLB_PT_TABLE0_ADDRESS, BFLB_PT_TABLE0_ADDRESS + sizeof(pt_table_stuff_config) - 1);
// ret = gp_pt_table_flash_erase(BFLB_PT_TABLE0_ADDRESS, BFLB_PT_TABLE0_ADDRESS + sizeof(pt_table_stuff_config) - 1);
ret = gp_pt_table_flash_erase(BFLB_PT_TABLE0_ADDRESS, sizeof(pt_table_stuff_config));
if (ret != SUCCESS) {

View File

@@ -23,8 +23,7 @@
#include "pid.h"
void pid_init(pid_alg_t *pid)
{
void pid_init(pid_alg_t *pid) {
pid->set_val = 0.0f;
pid->out_val = 0.0f;
@@ -43,8 +42,7 @@ void pid_init(pid_alg_t *pid)
}
// standard pid
float standard_pid_cal(pid_alg_t *pid, float next_val)
{
float standard_pid_cal(pid_alg_t *pid, float next_val) {
pid->set_val = next_val;
pid->i_error = pid->set_val - pid->out_val;
pid->sum_error += pid->i_error;
@@ -55,8 +53,7 @@ float standard_pid_cal(pid_alg_t *pid, float next_val)
}
// increment pid
float increment_pid_cal(pid_alg_t *pid, float next_val)
{
float increment_pid_cal(pid_alg_t *pid, float next_val) {
pid->set_val = next_val;
pid->i_error = pid->set_val - pid->out_val;
float increment = pid->kp * (pid->i_error - pid->prev_error) + pid->ki * pid->i_error + pid->kd * (pid->i_error - 2 * pid->prev_error + pid->last_error);

View File

@@ -81,9 +81,8 @@
*
* @return SUCCESS
*
*******************************************************************************/
BL_Err_Type Ring_Buffer_Init(Ring_Buffer_Type *rbType, uint8_t *buffer, uint32_t size, ringBuffer_Lock_Callback *lockCb, ringBuffer_Lock_Callback *unlockCb)
{
*******************************************************************************/
BL_Err_Type Ring_Buffer_Init(Ring_Buffer_Type *rbType, uint8_t *buffer, uint32_t size, ringBuffer_Lock_Callback *lockCb, ringBuffer_Lock_Callback *unlockCb) {
/* Init ring buffer pointer */
rbType->pointer = buffer;
@@ -110,9 +109,8 @@ BL_Err_Type Ring_Buffer_Init(Ring_Buffer_Type *rbType, uint8_t *buffer, uint32_t
*
* @return SUCCESS
*
*******************************************************************************/
BL_Err_Type Ring_Buffer_Reset(Ring_Buffer_Type *rbType)
{
*******************************************************************************/
BL_Err_Type Ring_Buffer_Reset(Ring_Buffer_Type *rbType) {
if (rbType->lock != NULL) {
rbType->lock();
}
@@ -140,9 +138,8 @@ BL_Err_Type Ring_Buffer_Reset(Ring_Buffer_Type *rbType)
*
* @return Length of data actually write
*
*******************************************************************************/
uint32_t Ring_Buffer_Write_Callback(Ring_Buffer_Type *rbType, uint32_t length, ringBuffer_Write_Callback *writeCb, void *parameter)
{
*******************************************************************************/
uint32_t Ring_Buffer_Write_Callback(Ring_Buffer_Type *rbType, uint32_t length, ringBuffer_Write_Callback *writeCb, void *parameter) {
uint32_t sizeRemained = Ring_Buffer_Get_Empty_Length(rbType);
if (writeCb == NULL) {
@@ -198,9 +195,8 @@ uint32_t Ring_Buffer_Write_Callback(Ring_Buffer_Type *rbType, uint32_t length, r
*
* @return None
*
*******************************************************************************/
static void Ring_Buffer_Write_Copy(void *parameter, uint8_t *dest, uint32_t length)
{
*******************************************************************************/
static void Ring_Buffer_Write_Copy(void *parameter, uint8_t *dest, uint32_t length) {
uint8_t **src = (uint8_t **)parameter;
ARCH_MemCpy_Fast(dest, *src, length);
@@ -216,11 +212,8 @@ static void Ring_Buffer_Write_Copy(void *parameter, uint8_t *dest, uint32_t leng
*
* @return Length of data writted actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Write(Ring_Buffer_Type *rbType, const uint8_t *data, uint32_t length)
{
return Ring_Buffer_Write_Callback(rbType, length, Ring_Buffer_Write_Copy, &data);
}
*******************************************************************************/
uint32_t Ring_Buffer_Write(Ring_Buffer_Type *rbType, const uint8_t *data, uint32_t length) { return Ring_Buffer_Write_Callback(rbType, length, Ring_Buffer_Write_Copy, &data); }
/****************************************************************************/ /**
* @brief Write 1 byte to ring buffer function
@@ -230,9 +223,8 @@ uint32_t Ring_Buffer_Write(Ring_Buffer_Type *rbType, const uint8_t *data, uint32
*
* @return Length of data writted actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Write_Byte(Ring_Buffer_Type *rbType, const uint8_t data)
{
*******************************************************************************/
uint32_t Ring_Buffer_Write_Byte(Ring_Buffer_Type *rbType, const uint8_t data) {
if (rbType->lock != NULL) {
rbType->lock();
}
@@ -273,9 +265,8 @@ uint32_t Ring_Buffer_Write_Byte(Ring_Buffer_Type *rbType, const uint8_t data)
*
* @return Length of data writted actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Write_Force(Ring_Buffer_Type *rbType, const uint8_t *data, uint32_t length)
{
*******************************************************************************/
uint32_t Ring_Buffer_Write_Force(Ring_Buffer_Type *rbType, const uint8_t *data, uint32_t length) {
uint32_t sizeRemained = Ring_Buffer_Get_Empty_Length(rbType);
uint32_t indexRemained = rbType->size - rbType->writeIndex;
@@ -328,9 +319,8 @@ uint32_t Ring_Buffer_Write_Force(Ring_Buffer_Type *rbType, const uint8_t *data,
*
* @return Length of data writted actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Write_Byte_Force(Ring_Buffer_Type *rbType, const uint8_t data)
{
*******************************************************************************/
uint32_t Ring_Buffer_Write_Byte_Force(Ring_Buffer_Type *rbType, const uint8_t data) {
Ring_Buffer_Status_Type status = Ring_Buffer_Get_Status(rbType);
if (rbType->lock != NULL) {
@@ -375,9 +365,8 @@ uint32_t Ring_Buffer_Write_Byte_Force(Ring_Buffer_Type *rbType, const uint8_t da
*
* @return Length of data actually read
*
*******************************************************************************/
uint32_t Ring_Buffer_Read_Callback(Ring_Buffer_Type *rbType, uint32_t length, ringBuffer_Read_Callback *readCb, void *parameter)
{
*******************************************************************************/
uint32_t Ring_Buffer_Read_Callback(Ring_Buffer_Type *rbType, uint32_t length, ringBuffer_Read_Callback *readCb, void *parameter) {
uint32_t size = Ring_Buffer_Get_Length(rbType);
if (readCb == NULL) {
@@ -433,9 +422,8 @@ uint32_t Ring_Buffer_Read_Callback(Ring_Buffer_Type *rbType, uint32_t length, ri
*
* @return None
*
*******************************************************************************/
static void Ring_Buffer_Read_Copy(void *parameter, uint8_t *data, uint32_t length)
{
*******************************************************************************/
static void Ring_Buffer_Read_Copy(void *parameter, uint8_t *data, uint32_t length) {
uint8_t **dest = (uint8_t **)parameter;
ARCH_MemCpy_Fast(*dest, data, length);
@@ -451,11 +439,8 @@ static void Ring_Buffer_Read_Copy(void *parameter, uint8_t *data, uint32_t lengt
*
* @return Length of data read actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Read(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t length)
{
return Ring_Buffer_Read_Callback(rbType, length, Ring_Buffer_Read_Copy, &data);
}
*******************************************************************************/
uint32_t Ring_Buffer_Read(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t length) { return Ring_Buffer_Read_Callback(rbType, length, Ring_Buffer_Read_Copy, &data); }
/****************************************************************************/ /**
* @brief Read 1 byte from ring buffer function
@@ -465,9 +450,8 @@ uint32_t Ring_Buffer_Read(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t leng
*
* @return Length of data actually read
*
*******************************************************************************/
uint32_t Ring_Buffer_Read_Byte(Ring_Buffer_Type *rbType, uint8_t *data)
{
*******************************************************************************/
uint32_t Ring_Buffer_Read_Byte(Ring_Buffer_Type *rbType, uint8_t *data) {
if (rbType->lock != NULL) {
rbType->lock();
}
@@ -508,9 +492,8 @@ uint32_t Ring_Buffer_Read_Byte(Ring_Buffer_Type *rbType, uint8_t *data)
*
* @return Length of data read actually
*
*******************************************************************************/
uint32_t Ring_Buffer_Peek(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t length)
{
*******************************************************************************/
uint32_t Ring_Buffer_Peek(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t length) {
uint32_t size = Ring_Buffer_Get_Length(rbType);
if (rbType->lock != NULL) {
@@ -558,9 +541,8 @@ uint32_t Ring_Buffer_Peek(Ring_Buffer_Type *rbType, uint8_t *data, uint32_t leng
*
* @return Length of data actually read
*
*******************************************************************************/
uint32_t Ring_Buffer_Peek_Byte(Ring_Buffer_Type *rbType, uint8_t *data)
{
*******************************************************************************/
uint32_t Ring_Buffer_Peek_Byte(Ring_Buffer_Type *rbType, uint8_t *data) {
if (rbType->lock != NULL) {
rbType->lock();
}
@@ -591,9 +573,8 @@ uint32_t Ring_Buffer_Peek_Byte(Ring_Buffer_Type *rbType, uint8_t *data)
*
* @return Length of data
*
*******************************************************************************/
uint32_t Ring_Buffer_Get_Length(Ring_Buffer_Type *rbType)
{
*******************************************************************************/
uint32_t Ring_Buffer_Get_Length(Ring_Buffer_Type *rbType) {
uint32_t readMirror = 0;
uint32_t writeMirror = 0;
uint32_t readIndex = 0;
@@ -628,11 +609,8 @@ uint32_t Ring_Buffer_Get_Length(Ring_Buffer_Type *rbType)
*
* @return Length of space remained
*
*******************************************************************************/
uint32_t Ring_Buffer_Get_Empty_Length(Ring_Buffer_Type *rbType)
{
return (rbType->size - Ring_Buffer_Get_Length(rbType));
}
*******************************************************************************/
uint32_t Ring_Buffer_Get_Empty_Length(Ring_Buffer_Type *rbType) { return (rbType->size - Ring_Buffer_Get_Length(rbType)); }
/****************************************************************************/ /**
* @brief Get ring buffer status function
@@ -641,9 +619,8 @@ uint32_t Ring_Buffer_Get_Empty_Length(Ring_Buffer_Type *rbType)
*
* @return Status of ring buffer
*
*******************************************************************************/
Ring_Buffer_Status_Type Ring_Buffer_Get_Status(Ring_Buffer_Type *rbType)
{
*******************************************************************************/
Ring_Buffer_Status_Type Ring_Buffer_Get_Status(Ring_Buffer_Type *rbType) {
if (rbType->lock != NULL) {
rbType->lock();
}

View File

@@ -28,57 +28,26 @@
// we use 0x8005 here and
const uint8_t chCRCHTalbe[] = {
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40
};
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40};
const uint8_t chCRCLTalbe[] = {
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7,
0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E,
0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9,
0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC,
0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32,
0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D,
0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38,
0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF,
0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1,
0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4,
0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB,
0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA,
0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97,
0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E,
0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89,
0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83,
0x41, 0x81, 0x80, 0x40
};
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8,
0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10,
0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38,
0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0,
0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98,
0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40};
uint16_t BFLB_Soft_CRC16(void *dataIn, uint32_t len)
{
uint16_t BFLB_Soft_CRC16(void *dataIn, uint32_t len) {
uint8_t chCRCHi = 0xFF;
uint8_t chCRCLo = 0xFF;
uint16_t wIndex;
@@ -97,53 +66,24 @@ uint16_t BFLB_Soft_CRC16(void *dataIn, uint32_t len)
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1
*/
const uint32_t crc32Tab[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
uint32_t BFLB_Soft_CRC32_Table(void *dataIn, uint32_t len)
{
uint32_t BFLB_Soft_CRC32_Table(void *dataIn, uint32_t len) {
uint32_t crc = 0;
uint8_t *data = (uint8_t *)dataIn;
@@ -157,27 +97,26 @@ uint32_t BFLB_Soft_CRC32_Table(void *dataIn, uint32_t len)
}
/******************************************************************************
* Name: CRC-32 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
* Poly: 0x4C11DB7
* Init: 0xFFFFFFF
* Refin: True
* Refout: True
* Xorout: 0xFFFFFFF
* Alias: CRC_32/ADCCP
* Use: WinRAR,ect.
*****************************************************************************/
uint32_t ATTR_TCM_SECTION BFLB_Soft_CRC32_Ex(uint32_t initial, void *dataIn, uint32_t len)
{
* Name: CRC-32 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
* Poly: 0x4C11DB7
* Init: 0xFFFFFFF
* Refin: True
* Refout: True
* Xorout: 0xFFFFFFF
* Alias: CRC_32/ADCCP
* Use: WinRAR,ect.
*****************************************************************************/
uint32_t ATTR_TCM_SECTION BFLB_Soft_CRC32_Ex(uint32_t initial, void *dataIn, uint32_t len) {
uint8_t i;
uint32_t crc = ~initial; // Initial value
uint8_t *data=(uint8_t *)dataIn;
uint8_t *data = (uint8_t *)dataIn;
while(len--){
while (len--) {
crc ^= *data++; // crc ^= *data; data++;
for (i = 0; i < 8; ++i){
if (crc & 1){
crc = (crc >> 1) ^ 0xEDB88320;// 0xEDB88320= reverse 0x04C11DB7
}else{
for (i = 0; i < 8; ++i) {
if (crc & 1) {
crc = (crc >> 1) ^ 0xEDB88320; // 0xEDB88320= reverse 0x04C11DB7
} else {
crc = (crc >> 1);
}
}
@@ -187,8 +126,5 @@ uint32_t ATTR_TCM_SECTION BFLB_Soft_CRC32_Ex(uint32_t initial, void *dataIn, uin
#ifndef BFLB_USE_ROM_DRIVER
__WEAK__
uint32_t ATTR_TCM_SECTION BFLB_Soft_CRC32(void *dataIn, uint32_t len)
{
return BFLB_Soft_CRC32_Ex(0,dataIn,len);
}
uint32_t ATTR_TCM_SECTION BFLB_Soft_CRC32(void *dataIn, uint32_t len) { return BFLB_Soft_CRC32_Ex(0, dataIn, len); }
#endif

View File

@@ -23,23 +23,22 @@
#include "timestamp.h"
#define FOUR_YEAR_DAY ((365 << 2) + 1) //The total number of days in a 4-year cycle
#define TIMEZONE (8) //Beijing time Zone adjustment
#define FOUR_YEAR_DAY ((365 << 2) + 1) // The total number of days in a 4-year cycle
#define TIMEZONE (8) // Beijing time Zone adjustment
#define SEC_NUM_PER_DAY (24 * 60 * 60)
#define SEC_NUM_PER_HOUR (60 * 60)
#define SEC_NUM_PER_MINUTE (60)
static uint8_t month_day[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //平年
static uint8_t Leap_month_day[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //闰年
static uint8_t month_day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 平年
static uint8_t Leap_month_day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 闰年
/**
* @bref judge if it is a leap year
* @para year to be judge
* @return 1leap year 0 nonleap year
*/
bool check_leap_year(uint16_t year)
{
* @bref judge if it is a leap year
* @para year to be judge
* @return 1leap year 0 nonleap year
*/
bool check_leap_year(uint16_t year) {
if (year % 4) {
return false;
} else {
@@ -51,17 +50,15 @@ bool check_leap_year(uint16_t year)
}
}
void cal_weekday(rtc_time *beijing_time)
{
uint32_t y,m,d,w;
void cal_weekday(rtc_time *beijing_time) {
uint32_t y, m, d, w;
y=beijing_time->year;
m=beijing_time->month;
d=beijing_time->day;
y = beijing_time->year;
m = beijing_time->month;
d = beijing_time->day;
if((m==1)||(m==2))
{
m+=12;
if ((m == 1) || (m == 2)) {
m += 12;
y--;
}
/*
@@ -69,13 +66,12 @@ void cal_weekday(rtc_time *beijing_time)
以公元元年为参考公元元年1月1日为星期一</PRE><PRE>程序如下:
利用基姆拉尔森计算日期公式 w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)
*/
w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
w = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7;
beijing_time->week=(uint8_t)w;
beijing_time->week = (uint8_t)w;
}
void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time)
{
void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time) {
uint32_t totle_day_num;
uint32_t current_sec_num;
@@ -85,8 +81,8 @@ void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time)
uint8_t *p = NULL;
totle_day_num = unixtime / SEC_NUM_PER_DAY; //The total number of days
current_sec_num = unixtime % SEC_NUM_PER_DAY; //The number of seconds this day
totle_day_num = unixtime / SEC_NUM_PER_DAY; // The total number of days
current_sec_num = unixtime % SEC_NUM_PER_DAY; // The number of seconds this day
/* use the number of seconds this day, To calculate hour\minute\second */
beijing_time->hour = current_sec_num / SEC_NUM_PER_HOUR;
@@ -100,10 +96,9 @@ void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time)
totle_day_num++;
}
/* calculate year */
beijing_time->year = 1970 + (totle_day_num / FOUR_YEAR_DAY) * 4; // 4-year as a cycle
remain_day = totle_day_num % FOUR_YEAR_DAY; //remaining day nym( < 4 year )
remain_day = totle_day_num % FOUR_YEAR_DAY; // remaining day nym( < 4 year )
/* calculate year & day */
temp_year = check_leap_year(beijing_time->year) ? 366 : 365;
@@ -115,22 +110,20 @@ void unixtime2bejingtime(uint32_t unixtime, rtc_time *beijing_time)
/* Calculate specific dates(month\day)*/
p = check_leap_year(beijing_time->year) ? Leap_month_day : month_day;
remain_day++; //The actual day starts at 1
remain_day++; // The actual day starts at 1
beijing_time->month = 0;
while (remain_day > *(p + beijing_time->month)) {
remain_day -= *(p + beijing_time->month);
beijing_time->month++;
}
beijing_time->month++; //The actual month starts at 1
beijing_time->month++; // The actual month starts at 1
beijing_time->day = remain_day;
/*利用基姆拉尔森计算日期公式 w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)*/
beijing_time->week = beijing_time->day + 2*beijing_time->month + 3*(beijing_time->month+1)/5 + \
beijing_time->year + beijing_time->year/4 - beijing_time->year/100 +beijing_time->year/400 ;
beijing_time->week =
beijing_time->day + 2 * beijing_time->month + 3 * (beijing_time->month + 1) / 5 + beijing_time->year + beijing_time->year / 4 - beijing_time->year / 100 + beijing_time->year / 400;
cal_weekday(beijing_time);
}

View File

@@ -1,23 +1,23 @@
/*****************************************************************************************
*
* @file bl_hci_wrapper.c
*
* @brief Bouffalo Lab hci wrapper functions
*
* Copyright (C) Bouffalo Lab 2018
*
* History: 2018-08 crealted by llgong @ Shanghai
*
*****************************************************************************************/
*
* @file bl_hci_wrapper.c
*
* @brief Bouffalo Lab hci wrapper functions
*
* Copyright (C) Bouffalo Lab 2018
*
* History: 2018-08 crealted by llgong @ Shanghai
*
*****************************************************************************************/
#include <string.h>
#include <log.h>
#include "hci_host.h"
#include "bl_hci_wrapper.h"
#include "hci_driver.h"
#include "../common/include/errno.h"
#include "byteorder.h"
#include "hci_driver.h"
#include "hci_host.h"
#include "hci_onchip.h"
#include <log.h>
#include <string.h>
#define DATA_MSG_CNT 10
@@ -27,8 +27,7 @@ struct k_queue msg_queue;
extern void ble_controller_notify_adv_discarded(uint8_t *adv_bd_addr, uint8_t adv_type);
#endif
struct rx_msg_struct *bl_find_valid_data_msg()
{
struct rx_msg_struct *bl_find_valid_data_msg() {
struct rx_msg_struct empty_msg;
memset(&empty_msg, 0, sizeof(struct rx_msg_struct));
@@ -41,8 +40,7 @@ struct rx_msg_struct *bl_find_valid_data_msg()
return NULL;
}
int bl_onchiphci_send_2_controller(struct net_buf *buf)
{
int bl_onchiphci_send_2_controller(struct net_buf *buf) {
uint16_t opcode;
uint16_t dest_id = 0x00;
uint8_t buf_type;
@@ -66,10 +64,10 @@ int bl_onchiphci_send_2_controller(struct net_buf *buf)
pkt_type = BT_HCI_CMD;
opcode = sys_le16_to_cpu(chdr->opcode);
//move buf to the payload
// move buf to the payload
net_buf_pull(buf, sizeof(struct bt_hci_cmd_hdr));
switch (opcode) {
//ble refer to hci_cmd_desc_tab_le, for the ones of which dest_ll is BLE_CTRL
// ble refer to hci_cmd_desc_tab_le, for the ones of which dest_ll is BLE_CTRL
case BT_HCI_OP_LE_CONN_UPDATE:
case BT_HCI_OP_LE_READ_CHAN_MAP:
case BT_HCI_OP_LE_READ_REMOTE_FEATURES:
@@ -81,11 +79,11 @@ int bl_onchiphci_send_2_controller(struct net_buf *buf)
case BT_HCI_OP_LE_SET_DATA_LEN:
case BT_HCI_OP_LE_READ_PHY:
case BT_HCI_OP_LE_SET_PHY:
//bredr identify link id, according to dest_id
// bredr identify link id, according to dest_id
case BT_HCI_OP_READ_REMOTE_FEATURES:
case BT_HCI_OP_READ_REMOTE_EXT_FEATURES:
case BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE: {
//dest_id is connectin handle
// dest_id is connectin handle
dest_id = buf->data[0];
}
default:
@@ -100,7 +98,7 @@ int bl_onchiphci_send_2_controller(struct net_buf *buf)
case BT_BUF_ACL_OUT: {
struct bt_hci_acl_hdr *acl;
//connhandle +l2cap field
// connhandle +l2cap field
uint16_t connhdl_l2cf, tlt_len;
if (buf->len < sizeof(struct bt_hci_acl_hdr)) {
@@ -111,14 +109,14 @@ int bl_onchiphci_send_2_controller(struct net_buf *buf)
acl = (void *)buf->data;
tlt_len = sys_le16_to_cpu(acl->len);
connhdl_l2cf = sys_le16_to_cpu(acl->handle);
//move buf to the payload
// move buf to the payload
net_buf_pull(buf, sizeof(struct bt_hci_acl_hdr));
if (buf->len < tlt_len) {
return -EINVAL;
}
//get connection_handle
// get connection_handle
dest_id = bt_acl_handle(connhdl_l2cf);
pkt.p.acl_data.conhdl = dest_id;
pkt.p.acl_data.pb_bc_flag = bt_acl_flags(connhdl_l2cf);
@@ -135,8 +133,7 @@ int bl_onchiphci_send_2_controller(struct net_buf *buf)
return bt_onchiphci_send(pkt_type, dest_id, &pkt);
}
void bl_packet_to_host(uint8_t pkt_type, uint16_t src_id, uint8_t *param, uint8_t param_len, struct net_buf *buf)
{
void bl_packet_to_host(uint8_t pkt_type, uint16_t src_id, uint8_t *param, uint8_t param_len, struct net_buf *buf) {
uint16_t tlt_len;
bool prio = true;
uint8_t nb_h2c_cmd_pkts = 0x01;
@@ -208,8 +205,7 @@ void bl_packet_to_host(uint8_t pkt_type, uint16_t src_id, uint8_t *param, uint8_
}
}
void bl_trigger_queued_msg()
{
void bl_trigger_queued_msg() {
struct net_buf *buf = NULL;
struct rx_msg_struct *msg = NULL;
@@ -220,8 +216,9 @@ void bl_trigger_queued_msg()
break;
}
if (bt_buf_get_rx_avail_cnt() <= CONFIG_BT_RX_BUF_RSV_COUNT)
if (bt_buf_get_rx_avail_cnt() <= CONFIG_BT_RX_BUF_RSV_COUNT) {
break;
}
buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_NO_WAIT);
if (!buf) {
@@ -244,8 +241,7 @@ void bl_trigger_queued_msg()
} while (buf);
}
static void bl_onchiphci_rx_packet_handler(uint8_t pkt_type, uint16_t src_id, uint8_t *param, uint8_t param_len)
{
static void bl_onchiphci_rx_packet_handler(uint8_t pkt_type, uint16_t src_id, uint8_t *param, uint8_t param_len) {
struct net_buf *buf = NULL;
struct rx_msg_struct *rx_msg = NULL;
@@ -262,8 +258,9 @@ static void bl_onchiphci_rx_packet_handler(uint8_t pkt_type, uint16_t src_id, ui
return;
}
buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_NO_WAIT);
if (buf)
if (buf) {
bl_packet_to_host(pkt_type, src_id, param, param_len, buf);
}
return;
} else {
if (pkt_type != BT_HCI_ACL_DATA) {
@@ -293,8 +290,7 @@ static void bl_onchiphci_rx_packet_handler(uint8_t pkt_type, uint16_t src_id, ui
bl_trigger_queued_msg();
}
uint8_t bl_onchiphci_interface_init(void)
{
uint8_t bl_onchiphci_interface_init(void) {
for (int i = 0; i < DATA_MSG_CNT; i++) {
memset(data_msg + i, 0, sizeof(struct rx_msg_struct));
}
@@ -304,8 +300,7 @@ uint8_t bl_onchiphci_interface_init(void)
return bt_onchiphci_interface_init(bl_onchiphci_rx_packet_handler);
}
void bl_onchiphci_interface_deinit(void)
{
void bl_onchiphci_interface_deinit(void) {
struct rx_msg_struct *msg;
do {

View File

@@ -17,11 +17,11 @@
*
* (originally from x86's atomic.c)
*/
#include "bl_port.h"
#include <FreeRTOS.h>
#include <include/atomic.h>
#include "bl_port.h"
//#include <toolchain.h>
//#include <arch/cpu.h>
// #include <toolchain.h>
// #include <arch/cpu.h>
/**
*
@@ -43,9 +43,7 @@
* @param new_value value to compare against
* @return Returns 1 if <new_value> is written, 0 otherwise.
*/
int atomic_cas(atomic_t *target, atomic_val_t old_value,
atomic_val_t new_value)
{
int atomic_cas(atomic_t *target, atomic_val_t old_value, atomic_val_t new_value) {
unsigned int key;
int ret = 0;
@@ -74,8 +72,7 @@ int atomic_cas(atomic_t *target, atomic_val_t old_value,
*
* @return The previous value from <target>
*/
atomic_val_t atomic_add(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_add(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -102,8 +99,7 @@ atomic_val_t atomic_add(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -128,8 +124,7 @@ atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value)
*
* @return The value from <target> before the increment
*/
atomic_val_t atomic_inc(atomic_t *target)
{
atomic_val_t atomic_inc(atomic_t *target) {
unsigned int key;
atomic_val_t ret;
@@ -154,8 +149,7 @@ atomic_val_t atomic_inc(atomic_t *target)
*
* @return The value from <target> prior to the decrement
*/
atomic_val_t atomic_dec(atomic_t *target)
{
atomic_val_t atomic_dec(atomic_t *target) {
unsigned int key;
atomic_val_t ret;
@@ -181,10 +175,7 @@ atomic_val_t atomic_dec(atomic_t *target)
*
* @return The value read from <target>
*/
atomic_val_t atomic_get(const atomic_t *target)
{
return *target;
}
atomic_val_t atomic_get(const atomic_t *target) { return *target; }
/**
*
@@ -198,8 +189,7 @@ atomic_val_t atomic_get(const atomic_t *target)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_set(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -225,8 +215,7 @@ atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_clear(atomic_t *target)
{
atomic_val_t atomic_clear(atomic_t *target) {
unsigned int key;
atomic_val_t ret;
@@ -253,8 +242,7 @@ atomic_val_t atomic_clear(atomic_t *target)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_or(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -281,8 +269,7 @@ atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -309,8 +296,7 @@ atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_and(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;
@@ -337,8 +323,7 @@ atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value)
{
atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value) {
unsigned int key;
atomic_val_t ret;

View File

@@ -13,14 +13,14 @@
#endif
#include <log.h>
//LOG_MODULE_REGISTER(LOG_MODULE_NAME);
// LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <stdio.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <misc/byteorder.h>
#include <net/buf.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#if defined(BFLB_BLE)
#if defined(BFLB_DYNAMIC_ALLOC_MEM)
#include "bl_port.h"
@@ -29,8 +29,7 @@
#endif
#if defined(CONFIG_NET_BUF_LOG)
#define NET_BUF_DBG(fmt, ...) LOG_DBG("(%p) " fmt, k_current_get(), \
##__VA_ARGS__)
#define NET_BUF_DBG(fmt, ...) LOG_DBG("(%p) " fmt, k_current_get(), ##__VA_ARGS__)
#define NET_BUF_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
#define NET_BUF_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
#define NET_BUF_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
@@ -50,7 +49,7 @@
#endif /* CONFIG_NET_BUF_LOG */
#if defined(CONFIG_NET_BUF_WARN_ALLOC_INTERVAL) && (CONFIG_NET_BUF_WARN_ALLOC_INTERVAL > 0)
//#if CONFIG_NET_BUF_WARN_ALLOC_INTERVAL > 0
// #if CONFIG_NET_BUF_WARN_ALLOC_INTERVAL > 0
#define WARN_ALLOC_INTERVAL K_SECONDS(CONFIG_NET_BUF_WARN_ALLOC_INTERVAL)
#else
#define WARN_ALLOC_INTERVAL K_FOREVER
@@ -71,7 +70,7 @@ extern struct net_buf_pool acl_in_pool;
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
extern struct net_buf_pool frag_pool;
#endif
#endif //CONFIG_BT_CONN
#endif // CONFIG_BT_CONN
#if defined(CONFIG_BT_DISCARDABLE_BUF_COUNT)
extern struct net_buf_pool discardable_pool;
#endif
@@ -80,7 +79,7 @@ extern struct net_buf_pool adv_buf_pool;
extern struct net_buf_pool loopback_buf_pool;
#if defined(CONFIG_BT_MESH_FRIEND)
extern struct net_buf_pool friend_buf_pool;
#endif //CONFIG_BT_MESH_FRIEND
#endif // CONFIG_BT_MESH_FRIEND
#endif
#if defined(CONFIG_BT_BREDR)
extern struct net_buf_pool br_sig_pool;
@@ -95,12 +94,10 @@ extern struct net_buf_pool data_pool;
#endif
struct net_buf_pool *_net_buf_pool_list[] = {
&hci_cmd_pool,
&hci_rx_pool,
&hci_cmd_pool, &hci_rx_pool,
#if defined(CONFIG_BT_CONN)
&acl_tx_pool,
&num_complete_pool,
&acl_tx_pool, &num_complete_pool,
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
&prep_pool,
#endif
@@ -110,36 +107,30 @@ struct net_buf_pool *_net_buf_pool_list[] = {
#if CONFIG_BT_L2CAP_TX_FRAG_COUNT > 0
&frag_pool,
#endif
#endif //defined(CONFIG_BT_CONN)
#endif // defined(CONFIG_BT_CONN)
#if defined(CONFIG_BT_DISCARDABLE_BUF_COUNT)
discardable_pool,
#endif
#ifdef CONFIG_BT_MESH
&adv_buf_pool,
&loopback_buf_pool,
&adv_buf_pool, &loopback_buf_pool,
#if defined(CONFIG_BT_MESH_FRIEND)
&friend_buf_pool,
#endif
#endif
#if defined(CONFIG_BT_BREDR)
&sdp_pool,
&br_sig_pool,
&hf_pool,
&dummy_pool,
&sdp_pool, &br_sig_pool, &hf_pool, &dummy_pool,
#endif
#if defined(CONFIG_AUTO_PTS)
&server_pool,
&data_pool,
&server_pool, &data_pool,
#endif
};
#else
extern struct net_buf_pool _net_buf_pool_list[];
#endif //BFLB_DYNAMIC_ALLOC_MEM
#endif // BFLB_DYNAMIC_ALLOC_MEM
#if defined(BFLB_DYNAMIC_ALLOC_MEM)
void net_buf_init(struct net_buf_pool *buf_pool, u16_t buf_count, size_t data_size, destroy_cb_t destroy)
{
void net_buf_init(struct net_buf_pool *buf_pool, u16_t buf_count, size_t data_size, destroy_cb_t destroy) {
struct net_buf_pool_fixed *buf_fixed;
buf_pool->alloc = (struct net_buf_data_alloc *)k_malloc(sizeof(void *));
buf_pool->alloc->alloc_data = (struct net_buf_pool_fixed *)k_malloc(sizeof(void *));
@@ -160,8 +151,7 @@ void net_buf_init(struct net_buf_pool *buf_pool, u16_t buf_count, size_t data_si
k_lifo_init(&(buf_pool->free), buf_count);
}
void net_buf_deinit(struct net_buf_pool *buf_pool)
{
void net_buf_deinit(struct net_buf_pool *buf_pool) {
extern void bt_delete_queue(struct k_fifo * queue_to_del);
bt_delete_queue((struct k_fifo *)(&(buf_pool->free)));
@@ -173,8 +163,7 @@ void net_buf_deinit(struct net_buf_pool *buf_pool)
}
#endif
struct net_buf_pool *net_buf_pool_get(int id)
{
struct net_buf_pool *net_buf_pool_get(int id) {
#if defined(BFLB_DYNAMIC_ALLOC_MEM)
return _net_buf_pool_list[id];
#else
@@ -182,8 +171,7 @@ struct net_buf_pool *net_buf_pool_get(int id)
#endif
}
static int pool_id(struct net_buf_pool *pool)
{
static int pool_id(struct net_buf_pool *pool) {
#if defined(BFLB_DYNAMIC_ALLOC_MEM)
int index;
@@ -199,16 +187,13 @@ static int pool_id(struct net_buf_pool *pool)
#endif
}
int net_buf_id(struct net_buf *buf)
{
int net_buf_id(struct net_buf *buf) {
struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
return buf - pool->__bufs;
}
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
u16_t uninit_count)
{
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool, u16_t uninit_count) {
struct net_buf *buf;
buf = &pool->__bufs[pool->buf_count - uninit_count];
@@ -218,8 +203,7 @@ static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
return buf;
}
void net_buf_reset(struct net_buf *buf)
{
void net_buf_reset(struct net_buf *buf) {
NET_BUF_ASSERT(buf->flags == 0U);
NET_BUF_ASSERT(buf->frags == NULL);
@@ -227,8 +211,7 @@ void net_buf_reset(struct net_buf *buf)
}
#if !defined(BFLB_BLE)
static u8_t *generic_data_ref(struct net_buf *buf, u8_t *data)
{
static u8_t *generic_data_ref(struct net_buf *buf, u8_t *data) {
u8_t *ref_count;
ref_count = data - 1;
@@ -237,18 +220,14 @@ static u8_t *generic_data_ref(struct net_buf *buf, u8_t *data)
return data;
}
static u8_t *mem_pool_data_alloc(struct net_buf *buf, size_t *size,
s32_t timeout)
{
static u8_t *mem_pool_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) {
struct net_buf_pool *buf_pool = net_buf_pool_get(buf->pool_id);
struct k_mem_pool *pool = buf_pool->alloc->alloc_data;
struct k_mem_block block;
u8_t *ref_count;
/* Reserve extra space for k_mem_block_id and ref-count (u8_t) */
if (k_mem_pool_alloc(pool, &block,
sizeof(struct k_mem_block_id) + 1 + *size,
timeout)) {
if (k_mem_pool_alloc(pool, &block, sizeof(struct k_mem_block_id) + 1 + *size, timeout)) {
return NULL;
}
@@ -262,8 +241,7 @@ static u8_t *mem_pool_data_alloc(struct net_buf *buf, size_t *size,
return ref_count + 1;
}
static void mem_pool_data_unref(struct net_buf *buf, u8_t *data)
{
static void mem_pool_data_unref(struct net_buf *buf, u8_t *data) {
struct k_mem_block_id id;
u8_t *ref_count;
@@ -284,8 +262,7 @@ const struct net_buf_data_cb net_buf_var_cb = {
};
#endif
static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
{
static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) {
struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
@@ -294,9 +271,7 @@ static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
return fixed->data_pool + fixed->data_size * net_buf_id(buf);
}
static void fixed_data_unref(struct net_buf *buf, u8_t *data)
{
/* Nothing needed for fixed-size data pools */
static void fixed_data_unref(struct net_buf *buf, u8_t *data) { /* Nothing needed for fixed-size data pools */
}
const struct net_buf_data_cb net_buf_fixed_cb = {
@@ -306,8 +281,7 @@ const struct net_buf_data_cb net_buf_fixed_cb = {
#if defined(CONFIG_HEAP_MEM_POOL_SIZE) && (CONFIG_HEAP_MEM_POOL_SIZE > 0)
static u8_t *heap_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
{
static u8_t *heap_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) {
u8_t *ref_count;
ref_count = k_malloc(1 + *size);
@@ -320,8 +294,7 @@ static u8_t *heap_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
return ref_count + 1;
}
static void heap_data_unref(struct net_buf *buf, u8_t *data)
{
static void heap_data_unref(struct net_buf *buf, u8_t *data) {
u8_t *ref_count;
ref_count = data - 1;
@@ -344,22 +317,19 @@ const struct net_buf_data_alloc net_buf_heap_alloc = {
#endif /* CONFIG_HEAP_MEM_POOL_SIZE > 0 */
static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
{
static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) {
struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
return pool->alloc->cb->alloc(buf, size, timeout);
}
static u8_t *data_ref(struct net_buf *buf, u8_t *data)
{
static u8_t *data_ref(struct net_buf *buf, u8_t *data) {
struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
return pool->alloc->cb->ref(buf, data);
}
static void data_unref(struct net_buf *buf, u8_t *data)
{
static void data_unref(struct net_buf *buf, u8_t *data) {
struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
if (buf->flags & NET_BUF_EXTERNAL_DATA) {
@@ -370,12 +340,9 @@ static void data_unref(struct net_buf *buf, u8_t *data)
}
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size,
s32_t timeout, const char *func,
int line)
struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size, s32_t timeout, const char *func, int line)
#else
struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
s32_t timeout)
struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, s32_t timeout)
#endif
{
u32_t alloc_start = k_uptime_get_32();
@@ -384,8 +351,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
NET_BUF_ASSERT(pool);
NET_BUF_DBG("%s():%d: pool %p size %zu timeout %d", func, line, pool,
size, timeout);
NET_BUF_DBG("%s():%d: pool %p size %zu timeout %d", func, line, pool, size, timeout);
/* We need to lock interrupts temporarily to prevent race conditions
* when accessing pool->uninit_count.
@@ -425,21 +391,15 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
buf = k_lifo_get(&pool->free, K_NO_WAIT);
while (!buf) {
#if defined(CONFIG_NET_BUF_POOL_USAGE)
NET_BUF_WARN("%s():%d: Pool %s low on buffers.",
func, line, pool->name);
NET_BUF_WARN("%s():%d: Pool %s low on buffers.", func, line, pool->name);
#else
NET_BUF_WARN("%s():%d: Pool %p low on buffers.",
func, line, pool);
NET_BUF_WARN("%s():%d: Pool %p low on buffers.", func, line, pool);
#endif
buf = k_lifo_get(&pool->free, WARN_ALLOC_INTERVAL);
#if defined(CONFIG_NET_BUF_POOL_USAGE)
NET_BUF_WARN("%s():%d: Pool %s blocked for %u secs",
func, line, pool->name,
(k_uptime_get_32() - ref) / MSEC_PER_SEC);
NET_BUF_WARN("%s():%d: Pool %s blocked for %u secs", func, line, pool->name, (k_uptime_get_32() - ref) / MSEC_PER_SEC);
#else
NET_BUF_WARN("%s():%d: Pool %p blocked for %u secs",
func, line, pool,
(k_uptime_get_32() - ref) / MSEC_PER_SEC);
NET_BUF_WARN("%s():%d: Pool %p blocked for %u secs", func, line, pool, (k_uptime_get_32() - ref) / MSEC_PER_SEC);
#endif
}
} else {
@@ -465,8 +425,7 @@ success:
buf->__buf = data_alloc(buf, &size, timeout);
if (!buf->__buf) {
NET_BUF_ERR("%s():%d: Failed to allocate data",
func, line);
NET_BUF_ERR("%s():%d: Failed to allocate data", func, line);
net_buf_destroy(buf);
return NULL;
}
@@ -489,18 +448,13 @@ success:
}
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
s32_t timeout, const char *func,
int line)
{
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout, const char *func, int line) {
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
return net_buf_alloc_len_debug(pool, fixed->data_size, timeout, func,
line);
return net_buf_alloc_len_debug(pool, fixed->data_size, timeout, func, line);
}
#else
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout)
{
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout) {
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
return net_buf_alloc_len(pool, fixed->data_size, timeout);
@@ -508,14 +462,9 @@ struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout)
#endif
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
void *data, size_t size,
s32_t timeout, const char *func,
int line)
struct net_buf *net_buf_alloc_with_data_debug(struct net_buf_pool *pool, void *data, size_t size, s32_t timeout, const char *func, int line)
#else
struct net_buf *net_buf_alloc_with_data(struct net_buf_pool *pool,
void *data, size_t size,
s32_t timeout)
struct net_buf *net_buf_alloc_with_data(struct net_buf_pool *pool, void *data, size_t size, s32_t timeout)
#endif
{
struct net_buf *buf;
@@ -539,8 +488,7 @@ struct net_buf *net_buf_alloc_with_data(struct net_buf_pool *pool,
}
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_get_debug(struct k_fifo *fifo, s32_t timeout,
const char *func, int line)
struct net_buf *net_buf_get_debug(struct k_fifo *fifo, s32_t timeout, const char *func, int line)
#else
struct net_buf *net_buf_get(struct k_fifo *fifo, s32_t timeout)
#endif
@@ -571,17 +519,14 @@ struct net_buf *net_buf_get(struct k_fifo *fifo, s32_t timeout)
return buf;
}
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
void *data, size_t size)
{
void net_buf_simple_init_with_data(struct net_buf_simple *buf, void *data, size_t size) {
buf->__buf = data;
buf->data = data;
buf->size = size;
buf->len = size;
}
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
{
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve) {
NET_BUF_ASSERT(buf);
NET_BUF_ASSERT(buf->len == 0U);
NET_BUF_DBG("buf %p reserve %zu", buf, reserve);
@@ -589,8 +534,7 @@ void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
buf->data = buf->__buf + reserve;
}
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
{
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf) {
struct net_buf *tail;
unsigned int key;
@@ -606,8 +550,7 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
irq_unlock(key);
}
struct net_buf *net_buf_slist_get(sys_slist_t *list)
{
struct net_buf *net_buf_slist_get(sys_slist_t *list) {
struct net_buf *buf, *frag;
unsigned int key;
@@ -639,8 +582,7 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list)
return buf;
}
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf)
{
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf) {
struct net_buf *tail;
NET_BUF_ASSERT(fifo);
@@ -667,13 +609,11 @@ void net_buf_unref(struct net_buf *buf)
#if defined(CONFIG_NET_BUF_LOG)
if (!buf->ref) {
NET_BUF_ERR("%s():%d: buf %p double free", func, line,
buf);
NET_BUF_ERR("%s():%d: buf %p double free", func, line, buf);
return;
}
#endif
NET_BUF_DBG("buf %p ref %u pool_id %u frags %p", buf, buf->ref,
buf->pool_id, buf->frags);
NET_BUF_DBG("buf %p ref %u pool_id %u frags %p", buf, buf->ref, buf->pool_id, buf->frags);
unsigned int key = irq_lock(); /* Added by bouffalo lab, to protect ref decrease */
if (--buf->ref > 0) {
@@ -714,12 +654,10 @@ void net_buf_unref(struct net_buf *buf)
}
}
struct net_buf *net_buf_ref(struct net_buf *buf)
{
struct net_buf *net_buf_ref(struct net_buf *buf) {
NET_BUF_ASSERT(buf);
NET_BUF_DBG("buf %p (old) ref %u pool_id %u",
buf, buf->ref, buf->pool_id);
NET_BUF_DBG("buf %p (old) ref %u pool_id %u", buf, buf->ref, buf->pool_id);
unsigned int key = irq_lock(); /* Added by bouffalo lab, to protect ref increase */
buf->ref++;
@@ -727,8 +665,7 @@ struct net_buf *net_buf_ref(struct net_buf *buf)
return buf;
}
struct net_buf *net_buf_clone(struct net_buf *buf, s32_t timeout)
{
struct net_buf *net_buf_clone(struct net_buf *buf, s32_t timeout) {
u32_t alloc_start = k_uptime_get_32();
struct net_buf_pool *pool;
struct net_buf *clone;
@@ -773,8 +710,7 @@ struct net_buf *net_buf_clone(struct net_buf *buf, s32_t timeout)
return clone;
}
struct net_buf *net_buf_frag_last(struct net_buf *buf)
{
struct net_buf *net_buf_frag_last(struct net_buf *buf) {
NET_BUF_ASSERT(buf);
while (buf->frags) {
@@ -784,8 +720,7 @@ struct net_buf *net_buf_frag_last(struct net_buf *buf)
return buf;
}
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
{
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag) {
NET_BUF_ASSERT(parent);
NET_BUF_ASSERT(frag);
@@ -796,8 +731,7 @@ void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
parent->frags = frag;
}
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag)
{
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag) {
NET_BUF_ASSERT(frag);
if (!head) {
@@ -810,9 +744,7 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag)
}
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
struct net_buf *frag,
const char *func, int line)
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent, struct net_buf *frag, const char *func, int line)
#else
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
#endif
@@ -840,9 +772,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
return next_frag;
}
size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
size_t offset, size_t len)
{
size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src, size_t offset, size_t len) {
struct net_buf *frag;
size_t to_copy;
size_t copied;
@@ -880,10 +810,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
* the data in current fragment then create new fragment and add it to
* the buffer. It assumes that the buffer has at least one fragment.
*/
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
const void *value, s32_t timeout,
net_buf_allocator_cb allocate_cb, void *user_data)
{
size_t net_buf_append_bytes(struct net_buf *buf, size_t len, const void *value, s32_t timeout, net_buf_allocator_cb allocate_cb, void *user_data) {
struct net_buf *frag = net_buf_frag_last(buf);
size_t added_len = 0;
const u8_t *value8 = value;
@@ -926,14 +853,9 @@ size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
#define NET_BUF_SIMPLE_ASSERT(cond)
#endif /* CONFIG_NET_BUF_SIMPLE_LOG */
void net_buf_simple_clone(const struct net_buf_simple *original,
struct net_buf_simple *clone)
{
memcpy(clone, original, sizeof(struct net_buf_simple));
}
void net_buf_simple_clone(const struct net_buf_simple *original, struct net_buf_simple *clone) { memcpy(clone, original, sizeof(struct net_buf_simple)); }
void *net_buf_simple_add(struct net_buf_simple *buf, size_t len)
{
void *net_buf_simple_add(struct net_buf_simple *buf, size_t len) {
u8_t *tail = net_buf_simple_tail(buf);
NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len);
@@ -944,16 +866,13 @@ void *net_buf_simple_add(struct net_buf_simple *buf, size_t len)
return tail;
}
void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
size_t len)
{
void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, size_t len) {
NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len);
return memcpy(net_buf_simple_add(buf, len), mem, len);
}
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
{
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val) {
u8_t *u8;
NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val);
@@ -964,50 +883,43 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
return u8;
}
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val)
{
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le16(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val)
{
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be16(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val)
{
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le24(val, net_buf_simple_add(buf, 3));
}
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val)
{
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be24(val, net_buf_simple_add(buf, 3));
}
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val)
{
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le32(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val)
{
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be32(val, net_buf_simple_add(buf, sizeof(val)));
}
void *net_buf_simple_push(struct net_buf_simple *buf, size_t len)
{
void *net_buf_simple_push(struct net_buf_simple *buf, size_t len) {
NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len);
NET_BUF_SIMPLE_ASSERT(net_buf_simple_headroom(buf) >= len);
@@ -1017,43 +929,37 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len)
return buf->data;
}
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val)
{
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le16(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val)
{
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be16(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val)
{
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val) {
u8_t *data = net_buf_simple_push(buf, 1);
*data = val;
}
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val)
{
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le24(val, net_buf_simple_push(buf, 3));
}
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
{
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val) {
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be24(val, net_buf_simple_push(buf, 3));
}
void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len)
{
void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len) {
NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len);
NET_BUF_SIMPLE_ASSERT(buf->len >= len);
@@ -1062,8 +968,7 @@ void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len)
return buf->data += len;
}
void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
{
void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len) {
void *data = buf->data;
NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len);
@@ -1076,8 +981,7 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
return data;
}
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
{
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf) {
u8_t val;
val = buf->data[0];
@@ -1086,8 +990,7 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
return val;
}
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
{
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf) {
u16_t val;
val = UNALIGNED_GET((u16_t *)buf->data);
@@ -1096,8 +999,7 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
return sys_le16_to_cpu(val);
}
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
{
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf) {
u16_t val;
val = UNALIGNED_GET((u16_t *)buf->data);
@@ -1106,8 +1008,7 @@ u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
return sys_be16_to_cpu(val);
}
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
{
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf) {
u32_t val;
val = UNALIGNED_GET((u32_t *)buf->data);
@@ -1116,8 +1017,7 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
return sys_le32_to_cpu(val);
}
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
{
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf) {
u32_t val;
val = UNALIGNED_GET((u32_t *)buf->data);
@@ -1126,12 +1026,6 @@ u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
return sys_be32_to_cpu(val);
}
size_t net_buf_simple_headroom(struct net_buf_simple *buf)
{
return buf->data - buf->__buf;
}
size_t net_buf_simple_headroom(struct net_buf_simple *buf) { return buf->data - buf->__buf; }
size_t net_buf_simple_tailroom(struct net_buf_simple *buf)
{
return buf->size - net_buf_simple_headroom(buf) - buf->len;
}
size_t net_buf_simple_tailroom(struct net_buf_simple *buf) { return buf->size - net_buf_simple_headroom(buf) - buf->len; }

View File

@@ -6,8 +6,7 @@
#include <util.h>
u8_t u8_to_dec(char *buf, u8_t buflen, u8_t value)
{
u8_t u8_to_dec(char *buf, u8_t buflen, u8_t value) {
u8_t divisor = 100;
u8_t num_digits = 0;
u8_t digit;

View File

@@ -33,8 +33,7 @@ BUILD_ASSERT(CONFIG_BT_CTLR_RX_PRIO < CONFIG_BT_HCI_TX_PRIO);
* since it introduces ISR latency due to outputting log messages with
* interrupts disabled.
*/
#if !defined(CONFIG_TEST) && !defined(CONFIG_ARCH_POSIX) && \
(defined(CONFIG_BT_LL_SW_SPLIT) || defined(CONFIG_BT_LL_SW_LEGACY))
#if !defined(CONFIG_TEST) && !defined(CONFIG_ARCH_POSIX) && (defined(CONFIG_BT_LL_SW_SPLIT) || defined(CONFIG_BT_LL_SW_LEGACY))
BUILD_ASSERT_MSG(!IS_ENABLED(CONFIG_LOG_IMMEDIATE), "Immediate logging not "
"supported with the software Link Layer");
#endif

View File

@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <stddef.h>
#include <zephyr/types.h>
#include <errno.h>
// #include <sys/util.h>

View File

@@ -12,15 +12,14 @@
* in a single printk call.
*/
#include <stddef.h>
#include <zephyr/types.h>
#include <zephyr.h>
#include <misc/util.h>
#include <bluetooth.h>
#include <hci_host.h>
#include <misc/util.h>
#include <stddef.h>
#include <zephyr.h>
#include <zephyr/types.h>
const char *bt_hex_real(const void *buf, size_t len)
{
const char *bt_hex_real(const void *buf, size_t len) {
static const char hex[] = "0123456789abcdef";
#if defined(CONFIG_BT_DEBUG_MONITOR)
static char str[255];
@@ -42,8 +41,7 @@ const char *bt_hex_real(const void *buf, size_t len)
return str;
}
const char *bt_addr_str_real(const bt_addr_t *addr)
{
const char *bt_addr_str_real(const bt_addr_t *addr) {
static char str[BT_ADDR_STR_LEN];
bt_addr_to_str(addr, str, sizeof(str));
@@ -51,8 +49,7 @@ const char *bt_addr_str_real(const bt_addr_t *addr)
return str;
}
const char *bt_addr_le_str_real(const bt_addr_le_t *addr)
{
const char *bt_addr_le_str_real(const bt_addr_le_t *addr) {
static char str[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(addr, str, sizeof(str));

View File

@@ -16,19 +16,16 @@
#include <stdio.h>
#include <misc/__assert.h>
#include <misc/dlist.h>
#include <misc/slist.h>
#include <zephyr.h>
#include <zephyr/types.h>
#include <misc/slist.h>
#include <misc/dlist.h>
#include <misc/__assert.h>
struct k_sem g_poll_sem;
void k_poll_event_init(struct k_poll_event *event, u32_t type,
int mode, void *obj)
{
__ASSERT(mode == K_POLL_MODE_NOTIFY_ONLY,
"only NOTIFY_ONLY mode is supported\n");
void k_poll_event_init(struct k_poll_event *event, u32_t type, int mode, void *obj) {
__ASSERT(mode == K_POLL_MODE_NOTIFY_ONLY, "only NOTIFY_ONLY mode is supported\n");
__ASSERT(type < (1 << _POLL_NUM_TYPES), "invalid type\n");
__ASSERT(obj, "must provide an object\n");
@@ -42,8 +39,7 @@ void k_poll_event_init(struct k_poll_event *event, u32_t type,
}
/* must be called with interrupts locked */
static inline int is_condition_met(struct k_poll_event *event, u32_t *state)
{
static inline int is_condition_met(struct k_poll_event *event, u32_t *state) {
switch (event->type) {
case K_POLL_TYPE_SEM_AVAILABLE:
if (k_sem_count_get(event->sem) > 0) {
@@ -73,16 +69,10 @@ static inline int is_condition_met(struct k_poll_event *event, u32_t *state)
return 0;
}
static inline void add_event(sys_dlist_t *events, struct k_poll_event *event,
struct _poller *poller)
{
sys_dlist_append(events, &event->_node);
}
static inline void add_event(sys_dlist_t *events, struct k_poll_event *event, struct _poller *poller) { sys_dlist_append(events, &event->_node); }
/* must be called with interrupts locked */
static inline int register_event(struct k_poll_event *event,
struct _poller *poller)
{
static inline int register_event(struct k_poll_event *event, struct _poller *poller) {
switch (event->type) {
case K_POLL_TYPE_SEM_AVAILABLE:
__ASSERT(event->sem, "invalid semaphore\n");
@@ -110,8 +100,7 @@ static inline int register_event(struct k_poll_event *event,
}
/* must be called with interrupts locked */
static inline void clear_event_registration(struct k_poll_event *event)
{
static inline void clear_event_registration(struct k_poll_event *event) {
event->poller = NULL;
switch (event->type) {
@@ -137,10 +126,7 @@ static inline void clear_event_registration(struct k_poll_event *event)
}
/* must be called with interrupts locked */
static inline void clear_event_registrations(struct k_poll_event *events,
int last_registered,
unsigned int key)
{
static inline void clear_event_registrations(struct k_poll_event *events, int last_registered, unsigned int key) {
for (; last_registered >= 0; last_registered--) {
clear_event_registration(&events[last_registered]);
irq_unlock(key);
@@ -148,15 +134,12 @@ static inline void clear_event_registrations(struct k_poll_event *events,
}
}
static inline void set_event_ready(struct k_poll_event *event, u32_t state)
{
static inline void set_event_ready(struct k_poll_event *event, u32_t state) {
event->poller = NULL;
event->state |= state;
}
static bool polling_events(struct k_poll_event *events, int num_events,
s32_t timeout, int *last_registered)
{
static bool polling_events(struct k_poll_event *events, int num_events, s32_t timeout, int *last_registered) {
int rc;
bool polling = true;
unsigned int key;
@@ -180,8 +163,7 @@ static bool polling_events(struct k_poll_event *events, int num_events,
return polling;
}
int k_poll(struct k_poll_event *events, int num_events, s32_t timeout)
{
int k_poll(struct k_poll_event *events, int num_events, s32_t timeout) {
__ASSERT(events, "NULL events\n");
__ASSERT(num_events > 0, "zero events\n");
@@ -208,16 +190,13 @@ exit:
}
/* must be called with interrupts locked */
static int _signal_poll_event(struct k_poll_event *event, u32_t state,
int *must_reschedule)
{
static int _signal_poll_event(struct k_poll_event *event, u32_t state, int *must_reschedule) {
*must_reschedule = 0;
set_event_ready(event, state);
return 0;
}
int k_poll_signal_raise(struct k_poll_signal *signal, int result)
{
int k_poll_signal_raise(struct k_poll_signal *signal, int result) {
unsigned int key = irq_lock();
struct k_poll_event *poll_event;
int must_reschedule;
@@ -231,8 +210,7 @@ int k_poll_signal_raise(struct k_poll_signal *signal, int result)
return 0;
}
int rc = _signal_poll_event(poll_event, K_POLL_STATE_SIGNALED,
&must_reschedule);
int rc = _signal_poll_event(poll_event, K_POLL_STATE_SIGNALED, &must_reschedule);
k_sem_give(&g_poll_sem);
irq_unlock(key);

View File

@@ -10,29 +10,28 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <stddef.h>
#include <errno.h>
#include <string.h>
#include <FreeRTOS.h>
#include <errno.h>
#include <include/atomic.h>
#include <misc/util.h>
#include <misc/byteorder.h>
#include <misc/stack.h>
#include <misc/util.h>
#include <stddef.h>
#include <string.h>
#include <zephyr.h>
#include <constants.h>
#include <aes.h>
#include <utils.h>
#include <cmac_mode.h>
#include <../include/bluetooth/crypto.h>
#include <aes.h>
#include <cmac_mode.h>
#include <constants.h>
#include <utils.h>
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_RPA)
#define LOG_MODULE_NAME bt_rpa
#include "log.h"
#if defined(CONFIG_BT_CTLR_PRIVACY) || defined(CONFIG_BT_PRIVACY) || defined(CONFIG_BT_SMP)
static int ah(const u8_t irk[16], const u8_t r[3], u8_t out[3])
{
static int ah(const u8_t irk[16], const u8_t r[3], u8_t out[3]) {
u8_t res[16];
int err;
@@ -61,8 +60,7 @@ static int ah(const u8_t irk[16], const u8_t r[3], u8_t out[3])
#endif
#if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_CTLR_PRIVACY)
bool bt_rpa_irk_matches(const u8_t irk[16], const bt_addr_t *addr)
{
bool bt_rpa_irk_matches(const u8_t irk[16], const bt_addr_t *addr) {
u8_t hash[3];
int err;
@@ -78,8 +76,7 @@ bool bt_rpa_irk_matches(const u8_t irk[16], const bt_addr_t *addr)
#endif
#if defined(CONFIG_BT_PRIVACY) || defined(CONFIG_BT_CTLR_PRIVACY)
int bt_rpa_create(const u8_t irk[16], bt_addr_t *rpa)
{
int bt_rpa_create(const u8_t irk[16], bt_addr_t *rpa) {
int err;
err = bt_rand(rpa->val + 3, 3);
@@ -99,8 +96,5 @@ int bt_rpa_create(const u8_t irk[16], bt_addr_t *rpa)
return 0;
}
#else
int bt_rpa_create(const u8_t irk[16], bt_addr_t *rpa)
{
return -ENOTSUP;
}
int bt_rpa_create(const u8_t irk[16], bt_addr_t *rpa) { return -ENOTSUP; }
#endif /* CONFIG_BT_PRIVACY */

View File

@@ -35,34 +35,16 @@
#include <utils.h>
static const uint8_t inv_sbox[256] = {
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e,
0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32,
0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49,
0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50,
0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05,
0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41,
0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8,
0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b,
0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59,
0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d,
0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63,
0x55, 0x21, 0x0c, 0x7d
};
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d};
int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k)
{
return tc_aes128_set_encrypt_key(s, k);
}
int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k) { return tc_aes128_set_encrypt_key(s, k); }
#define mult8(a) (_double_byte(_double_byte(_double_byte(a))))
#define mult9(a) (mult8(a) ^ (a))
@@ -70,16 +52,14 @@ int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k)
#define multd(a) (mult8(a) ^ _double_byte(_double_byte(a)) ^ (a))
#define multe(a) (mult8(a) ^ _double_byte(_double_byte(a)) ^ _double_byte(a))
static inline void mult_row_column(uint8_t *out, const uint8_t *in)
{
static inline void mult_row_column(uint8_t *out, const uint8_t *in) {
out[0] = multe(in[0]) ^ multb(in[1]) ^ multd(in[2]) ^ mult9(in[3]);
out[1] = mult9(in[0]) ^ multe(in[1]) ^ multb(in[2]) ^ multd(in[3]);
out[2] = multd(in[0]) ^ mult9(in[1]) ^ multe(in[2]) ^ multb(in[3]);
out[3] = multb(in[0]) ^ multd(in[1]) ^ mult9(in[2]) ^ multe(in[3]);
}
static inline void inv_mix_columns(uint8_t *s)
{
static inline void inv_mix_columns(uint8_t *s) {
uint8_t t[Nb * Nk];
mult_row_column(t, s);
@@ -89,8 +69,7 @@ static inline void inv_mix_columns(uint8_t *s)
(void)_copy(s, sizeof(t), t, sizeof(t));
}
static inline void add_round_key(uint8_t *s, const unsigned int *k)
{
static inline void add_round_key(uint8_t *s, const unsigned int *k) {
s[0] ^= (uint8_t)(k[0] >> 24);
s[1] ^= (uint8_t)(k[0] >> 16);
s[2] ^= (uint8_t)(k[0] >> 8);
@@ -109,8 +88,7 @@ static inline void add_round_key(uint8_t *s, const unsigned int *k)
s[15] ^= (uint8_t)(k[3]);
}
static inline void inv_sub_bytes(uint8_t *s)
{
static inline void inv_sub_bytes(uint8_t *s) {
unsigned int i;
for (i = 0; i < (Nb * Nk); ++i) {
@@ -123,8 +101,7 @@ static inline void inv_sub_bytes(uint8_t *s)
* inv_mix_columns, but performs it here to reduce the number of memory
* operations.
*/
static inline void inv_shift_rows(uint8_t *s)
{
static inline void inv_shift_rows(uint8_t *s) {
uint8_t t[Nb * Nk];
t[0] = s[0];
@@ -146,8 +123,7 @@ static inline void inv_shift_rows(uint8_t *s)
(void)_copy(s, sizeof(t), t, sizeof(t));
}
int tc_aes_decrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s)
{
int tc_aes_decrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s) {
uint8_t state[Nk * Nb];
unsigned int i;

Some files were not shown because too many files have changed in this diff Show More