Open ein-shved opened 1 year ago
Hi Yuri,
Thanks for your PR. I had a quick look at the code and yes, some things definitely seem useful right away. For instance, the preprocessor macros.
I will review the PR thoroughly and let you know my thoughts. Please don't expect a quick review, I'm going to a vacation for two weeks and after that I'm going to be pretty busy with work for another week or two at least. My apologies for not being able to review faster.
Best, Kirill.
Excellent. I abandoned my PR for an alternative approach, but would love to see this polished and merged.
@r2axz no problem. As I wrote, there is already well known problems, which should be fixed first. For some of them I have no much knowledge to resolve quick (need to longread manuals first). Another problems I will fix soon - for example duplication code with withing cdc_shell.c. And there more minor ideas for improvement the code (starting from applying clang-format, till adding the functionality like gpio-notiffications). I will go through patches by myself and left my thoughts withing comments.
I got used to gerrit-review with per-commit discussion and tried to split commits on complete functionality blocks, some of them are not really needed here (like nix build) but it is up to you.
BTW Im going to one week vocation right after you =)
@kzyapkov it's a pity you abandoned it. Fill free to participate in discussions here.
I needed a device with two two-pinned uarts and several gpio and with control via usb. This project was close to my needs, but lucks of gpio controls and had extra functionality which blocks almost all pins.
I suggest the basic version of dynamic controlling the gpio pins via shell to allow user use extra pins as gpio. Current version of this PR is not suitable to release, because it was not properly tested, definitely will brake some generic functionality and not optimal and pretty in some places.
Additionally I used here some language features like macro-metaprogramming and format output which was not used previously for some reason. It may be found not suitable by maintainers.
But from now I can use it for my purpose and I do not know when I will make it perfect. So I made this PR to bring maintainers' attention so they may find something useful from it.
This PR adds new control to shell:
gpio
.This command accepts the gpio name as first argument in view
[gpio_][pin_][p]<P><N>
wheregpio_
,pin_
andp
are optional prefixes,<P>
is the name of port likea
,b
orc
.<N>
is the number of pin.Examples:
pa1
,gpio_pin_pa10
,b3
More on this, it accepts massive aliases:
all
- apply command to all pinsfree
- apply commands to all pins which havefree
status (see later about statuses)occupied
- apply commands to all pins which haveoccupied
statusblocked
- apply commands to all pins which haveblocked
statusuartN
- apply commands to all pins which may be used by uartcontrol
,config
,shell
- aliases forpb5
led
- alias forpb13
The pin may be in one of 3 states:
blocked
- the pin is used by critical functionality like USB, boot control, or serial debugoccupied
- the pin is occupied by generic functionality like uart, led status or configuration contolfree
- the pin is free to be modified from shell as generic io.The second argument may be:
show
- show current status of pin like next:free
- set pin's status to free. If one of tx or rx pin of uart goes to free state, the uart will be swithed off.occupy
- set pin's status to occupied.get
- print value of pinset [args]
- configure pin behaviourup
- make output pin updown
- make output pin downThere are defaults for first two arguments:
show
all
So command
gpio
,gpio all
andgpio all show
are equal.