forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latest Release RM0416-0359-0.100.4-22e2176 on PATREON & GitHub - MAIN…
… APP TWEAKS
- Loading branch information
1 parent
ae27678
commit f9b0b54
Showing
26 changed files
with
888 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,23 @@ | ||
#include "gpio_i2c_scanner_control.h" | ||
#include <furi.h> | ||
|
||
void gpio_i2c_scanner_run_once(I2CScannerState* i2c_scanner_state) { | ||
//Reset the number of items for rewriting the array | ||
i2c_scanner_state->items = 0; | ||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); | ||
|
||
uint32_t response_timeout_ticks = furi_ms_to_ticks(5.f); | ||
|
||
//Addresses 0 to 7 are reserved and won't be scanned | ||
for(int i = FIRST_NON_RESERVED_I2C_ADDRESS; i <= HIGHEST_I2C_ADDRESS; i++) { | ||
if(furi_hal_i2c_is_device_ready( | ||
&furi_hal_i2c_handle_external, | ||
i << 1, | ||
response_timeout_ticks)) { //Bitshift of 1 bit to convert 7-Bit Address into 8-Bit Address | ||
i2c_scanner_state->responding_address[i2c_scanner_state->items] = i; | ||
i2c_scanner_state->items++; | ||
} | ||
} | ||
|
||
furi_hal_i2c_release(&furi_hal_i2c_handle_external); | ||
} |
This file contains 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,21 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#include <furi_hal_i2c.h> | ||
|
||
#define FIRST_NON_RESERVED_I2C_ADDRESS 8 | ||
#define HIGHEST_I2C_ADDRESS 127 | ||
#define AVAILABLE_NONRESVERED_I2C_ADDRESSES 120 | ||
|
||
typedef struct { | ||
uint8_t items; | ||
uint8_t responding_address[AVAILABLE_NONRESVERED_I2C_ADDRESSES]; | ||
} I2CScannerState; | ||
|
||
/** Scans the I2C-Bus (SDA: Pin 15, SCL: Pin 16) for available 7-Bit slave addresses. Saves the number of detected slaves and their addresses. | ||
* | ||
* @param i2c_scanner_state State including the detected addresses and the number of addresses saved. | ||
*/ | ||
void gpio_i2c_scanner_run_once(I2CScannerState* st); |
Oops, something went wrong.