-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Alter onewire libs so other non-ibutton pins can be used as well #1635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
wdoekes
wants to merge
2
commits into
flipperdevices:dev
from
wdoekes:allow-onewire-libs-for-non-ibutton
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #include <furi_hal_onewire.h> | ||
| #include <furi_hal_interrupt.h> | ||
| #include <furi_hal_resources.h> | ||
|
|
||
| #include <stm32wbxx_ll_tim.h> | ||
| #include <stm32wbxx_ll_exti.h> | ||
|
|
||
| #include <furi.h> | ||
|
|
||
| #define FURI_HAL_IBUTTON_TIMER TIM1 | ||
| #define FURI_HAL_IBUTTON_TIMER_IRQ FuriHalInterruptIdTim1UpTim16 | ||
|
|
||
| void furi_hal_onewire_start_drive(const GpioPin* gpio) { | ||
| furi_hal_onewire_pin_high(gpio); | ||
| furi_hal_gpio_init(gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); | ||
| } | ||
|
|
||
| void furi_hal_onewire_start_drive_in_isr(const GpioPin* gpio) { | ||
| furi_hal_gpio_init(gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); | ||
| LL_EXTI_ClearFlag_0_31(gpio->pin); | ||
| } | ||
|
|
||
| void furi_hal_onewire_start_interrupt(const GpioPin* gpio) { | ||
| furi_hal_onewire_pin_high(gpio); | ||
| furi_hal_gpio_init(gpio, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); | ||
| } | ||
|
|
||
| void furi_hal_onewire_start_interrupt_in_isr(const GpioPin* gpio) { | ||
| furi_hal_gpio_init(gpio, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); | ||
| LL_EXTI_ClearFlag_0_31(gpio->pin); | ||
| } | ||
|
|
||
| void furi_hal_onewire_stop(const GpioPin* gpio) { | ||
| furi_hal_onewire_pin_high(gpio); | ||
| furi_hal_gpio_init(gpio, GpioModeAnalog, GpioPullNo, GpioSpeedLow); | ||
| } | ||
|
|
||
| void furi_hal_onewire_add_interrupt(const GpioPin* gpio, GpioExtiCallback cb, void* context) { | ||
| furi_hal_gpio_add_int_callback(gpio, cb, context); | ||
| } | ||
|
|
||
| void furi_hal_onewire_remove_interrupt(const GpioPin* gpio) { | ||
| furi_hal_gpio_remove_int_callback(gpio); | ||
| } | ||
|
|
||
| void furi_hal_onewire_pin_low(const GpioPin* gpio) { | ||
| furi_hal_gpio_write(gpio, false); | ||
| } | ||
|
|
||
| void furi_hal_onewire_pin_high(const GpioPin* gpio) { | ||
| furi_hal_gpio_write(gpio, true); | ||
| } | ||
|
|
||
| bool furi_hal_onewire_pin_get_level(const GpioPin* gpio) { | ||
| return furi_hal_gpio_read(gpio); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /** | ||
| * @file furi_hal_onewire.h | ||
| * OneWire HAL API | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include "furi_hal_gpio.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * Sets the pin to normal mode (open collector), and sets it to float | ||
| * @param gpio | ||
| */ | ||
| void furi_hal_onewire_start_drive(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to normal mode (open collector), and clears pin EXTI interrupt. | ||
| * Used in EXTI interrupt context. | ||
| * @param gpio | ||
| */ | ||
| void furi_hal_onewire_start_drive_in_isr(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and sets it to float | ||
| * @param gpio | ||
| */ | ||
| void furi_hal_onewire_start_interrupt(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and clears pin EXTI interrupt. | ||
| * Used in EXTI interrupt context. | ||
| * @param gpio | ||
| */ | ||
| void furi_hal_onewire_start_interrupt_in_isr(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to analog mode, and sets it to float | ||
| * @param gpio | ||
| */ | ||
| void furi_hal_onewire_stop(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Attach interrupt callback to OneWire pin | ||
| * @param cb callback | ||
| * @param context context | ||
| */ | ||
| void furi_hal_onewire_add_interrupt(const GpioPin* gpio, GpioExtiCallback cb, void* context); | ||
|
|
||
| /** | ||
| * Remove interrupt callback from OneWire pin | ||
| */ | ||
| void furi_hal_onewire_remove_interrupt(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to low | ||
| */ | ||
| void furi_hal_onewire_pin_low(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Sets the pin to high (float in OneWire pin modes) | ||
| */ | ||
| void furi_hal_onewire_pin_high(const GpioPin* gpio); | ||
|
|
||
| /** | ||
| * Get pin level | ||
| * @return true if level is high | ||
| * @return false if level is low | ||
| */ | ||
| bool furi_hal_onewire_pin_get_level(const GpioPin* gpio); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment which EXTI (which pin) can be used as an interrupt.
V9 table from https://docs.google.com/spreadsheets/d/1qAPFTwvMwbTp1hTAtZHlO6jpl9o-fXg49rPIQ1o7JiQ/edit?usp=sharing
(0, 1, 4, 5, 7, 8, 14).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to add this, but I'm not sure what you mean. I'm not that initimate with electronics.
Are you saying all pins on A..H are interrupt-capable if they're on EXTI{0,1,4,5,7,8,14} and all others are not?
I.e.:
?
I have no idea what I'm typing here, so I could be off by a mile 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @DrZlo13 : any hint is appreciated :)