mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-17 21:32:52 +01:00
Fix all compiler warnings and migrate off depreciated ADC and I2C libraries. --------- Co-authored-by: Erik Olof Gunnar Andersson <eandersson@users.noreply.github.com>
27 lines
579 B
C
27 lines
579 B
C
#include "common.h"
|
|
|
|
unsigned char _reverse_bits(unsigned char num)
|
|
{
|
|
unsigned char reversed = 0;
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
reversed <<= 1; // Left shift the reversed variable by 1
|
|
reversed |= num & 1; // Use bitwise OR to set the rightmost bit of reversed to the current bit of num
|
|
num >>= 1; // Right shift num by 1 to get the next bit
|
|
}
|
|
|
|
return reversed;
|
|
}
|
|
|
|
int _largest_power_of_two(int num)
|
|
{
|
|
int power = 0;
|
|
|
|
while (num > 1) {
|
|
num = num >> 1;
|
|
power++;
|
|
}
|
|
|
|
return 1 << power;
|
|
} |