7
31
Fork
You've already forked blackmagic
23

add voltage sensor on stm32f3 and correct the readme #1794

Open
MathieuFluidy wants to merge 1 commit from MathieuFluidy/main into main
pull from: MathieuFluidy/main
merge into: blackmagic-debug:main
blackmagic-debug:main
blackmagic-debug:feature/bmda-remote-comms
blackmagic-debug:ALTracer/feature/aarch64-ident
blackmagic-debug:feature/better-meson-optimisation-handling
blackmagic-debug:feature/am335x-support
blackmagic-debug:feature/esp32-c3-support
blackmagic-debug:feature/cortex-ar-software-breakpoints
blackmagic-debug:feature/unit-testing
blackmagic-debug:feature/windows-usb-serial-interface-naming
blackmagic-debug:fix/bmp-external-spi
blackmagic-debug:ALTracer/feature/bluepillplus-platform
blackmagic-debug:ALTracer/feature/at32f43x-unrdp
blackmagic-debug:feature/const-correctness
blackmagic-debug:ALTracer/feature/fault_handlers
blackmagic-debug:ALTracer/feature/hazard3-ice40-support
blackmagic-debug:fix/ci-cleanup
blackmagic-debug:ALTracer/fix/gdb-10-12-thread
blackmagic-debug:ALTracer/feature/blackpill-f4-adc
blackmagic-debug:ALTracer/fix/cortex-desc-allocfail-report
blackmagic-debug:ALTracer/feature/spi-perf
blackmagic-debug:ALTracer/feature/calibrate_swd
blackmagic-debug:ALTracer/feature/blank-check
blackmagic-debug:feature/avr
blackmagic-debug:v2.0
blackmagic-debug:v1.9
blackmagic-debug:v1.10
blackmagic-debug:v1.8
MathieuFluidy commented 2024年04月09日 10:40:04 +02:00 (Migrated from github.com)
Copy link

Detailed description

I implemented the ability of having a voltage sensor when flashing BM firmware on a stm32f3.
The STM32f3 isn't able of calculating voltage highter than 3.6V, when the voltage is highter it anwser 4.95V every time.

I used the libcm3 adc interface to open an adc gpio and read it when voltage is asked

Your checklist for this pull request

<!-- Filling this template is mandatory --> ## Detailed description I implemented the ability of having a voltage sensor when flashing BM firmware on a stm32f3. The STM32f3 isn't able of calculating voltage highter than 3.6V, when the voltage is highter it anwser 4.95V every time. I used the libcm3 adc interface to open an adc gpio and read it when voltage is asked ## Your checklist for this pull request * [X] I've read the [Code of Conduct](https://github.com/blackmagic-debug/blackmagic/blob/main/CODE_OF_CONDUCT.md) * [X] I've read the [guidelines for contributing](https://github.com/blackmagic-debug/blackmagic/blob/main/CONTRIBUTING.md) to this repository * [X] It builds for hardware native (see [Building the firmware](https://github.com/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-firmware)) * [X] It builds as BMDA (see [Building the BMDA](https://github.com/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-app)) * [X] I've tested it to the best of my ability * [X] My commit messages provide a useful short description of what the commits do
dragonmux left a comment
Copy link

There are some items that need fixing before we can merge this contribution, but it is looking like a good start.

Please run clang-format on your contribution, despite the lint step being broken right now this is not optional. Please correct your commit message to have the correct suffix on the commit, which for this would be f3/platform: . The rest of the commit message is fine however.

There are some items that need fixing before we can merge this contribution, but it is looking like a good start. Please run `clang-format` on your contribution, despite the `lint` step being broken right now this is not optional. Please correct your commit message to have the correct suffix on the commit, which for this would be `f3/platform: `. The rest of the commit message is fine however.
@ -115,0 +157,4 @@
* Returns the voltage in tenths of a volt (so 33 means 3.3V)
*/
adc_start_conversion_regular(ADC1);
while (!(adc_eoc(ADC1)))

As this is not being used, and likewise with the gpio-mode_setup() above, please remove them.

As this is not being used, and likewise with the `gpio-mode_setup()` above, please remove them.
@ -115,0 +159,4 @@
adc_start_conversion_regular(ADC1);
while (!(adc_eoc(ADC1)))
continue;
uint32_t val=adc_read_regular(ADC1);

Rather than defining an array, please define just a channel value and take its address below as in:

uint8_t channel = 1U;
adc_set_regular_sequence(ADC1, 1U, &channel);
Rather than defining an array, please define just a channel value and take its address below as in: ```c uint8_t channel = 1U; adc_set_regular_sequence(ADC1, 1U, &channel); ```
@ -115,1 +168,4 @@
const char *platform_target_voltage(void)

i cannot go negative, so to avoid signed overflow issues and other such unnecessary badness, please use unsigned types here. size_t is ideal.

Note that the preferred style for this sort of busy loop is the one used in the native platform for this:

	for (volatile size_t i = 0U; i < 800000U; ++i)
		continue;

The U suffix on the constants are not optional and makes them unsigned, preventing a signed-unsigned conversion that can drastically change the meaning of the code.

`i` cannot go negative, so to avoid signed overflow issues and other such unnecessary badness, please use unsigned types here. `size_t` is ideal. Note that the preferred style for this sort of busy loop is the one used in the native platform for this: ```c for (volatile size_t i = 0U; i < 800000U; ++i) continue; ``` The `U` suffix on the constants are not optional and makes them unsigned, preventing a signed-unsigned conversion that can drastically change the meaning of the code.
@ -118,2 +184,4 @@
return ret;
}

Please remove the extra ;.

Please remove the extra `;`.

This is unreachable, please remove it, along with the commented out return val;

This is unreachable, please remove it, along with the commented out `return val;`

Please remove this if you aren't including it as active code.

Please remove this if you aren't including it as active code.
This pull request has changes conflicting with the target branch.
  • src/platforms/f3/platform.c
  • src/platforms/f3/platform.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin MathieuFluidy/main:MathieuFluidy/main
git switch MathieuFluidy/main
Sign in to join this conversation.
No reviewers
Labels
Clear labels
BMD App
Black Magic Debug App (aka. PC hosted) (not firmware)
BMP Firmware
Black Magic Probe Firmware (not PC hosted software)
Bug
Confirmed bug
Build system
Build system
Can't reproduce
Maintainers can't reproduce this problem
CI
Continuous Integration System
Contribution wanted
User contributions welcome
Documentation
Project documentation
Draft
Work in progress draft
Duplicate
This issue or pull request already exists
Enhancement
General project improvement
Feedback wanted
Requires additional submitter feedback
Foreign Host Board
Non Native hardware to runing Black Magic firmware on
GDB
Issue/PR related to GDB
Good first issue
Good for newcommers
HwIssue Mitigation
Solving or mitigating a Hardware issue in Software
Information Needed
Maintainers need more information
NativeHardware
Official Black Magic Debug Hardware
New Host Board
New hardware to run Black Magic firmware on
New Target
New debug target
Off Topic
Something that does not involve the project in any way
Potential Bug
A potential, unconfirmed or very special circumstance bug
Regression
Bug caused by a regression
User Interest Needed
More user interest required before consideration
User Testing Needed
Looking for user testing reports
Won't fix
Outside of the project scope or works as intended
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/blackmagic!1794
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "MathieuFluidy/main"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?