-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Refactor realtek-ambz, cleanup, reformat, add missing copyrights
- Loading branch information
Showing
103 changed files
with
1,228 additions
and
9,936 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
AlignAfterOpenBracket: BlockIndent | ||
AlignArrayOfStructures: Left | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveMacros: AcrossComments | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: false | ||
AllowShortBlocksOnASingleLine: Empty | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeTernaryOperators: true | ||
ColumnLimit: 120 | ||
ContinuationIndentWidth: 4 | ||
EmptyLineBeforeAccessModifier: Always | ||
FixNamespaceComments: true | ||
IndentAccessModifiers: false | ||
IndentCaseLabels: true | ||
IndentWidth: 4 | ||
LambdaBodyIndentation: Signature | ||
MaxEmptyLinesToKeep: 1 | ||
# PointerAlignment: Left # TODO enable this and reformat project | ||
QualifierAlignment: Left | ||
ReflowComments: true | ||
SeparateDefinitionBlocks: Always | ||
TabWidth: 4 | ||
UseTab: Always |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* Copyright (c) Kuba Szczodrzyński 2022-04-24. */ | ||
|
||
#pragma once | ||
|
||
#include <stdbool.h> | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* Copyright (c) Kuba Szczodrzyński 2022-04-28. */ | ||
|
||
#pragma once | ||
|
||
// LibreTuya version macros | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* Copyright (c) Kuba Szczodrzyński 2022-04-28. */ | ||
|
||
#pragma once | ||
|
||
// see docs/API Configuration | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* Copyright (c) Kuba Szczodrzyński 2022-04-28. */ | ||
|
||
#include "lt_logger.h" | ||
|
||
#include <Arduino.h> | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* Copyright (c) Kuba Szczodrzyński 2022-04-28. */ | ||
|
||
#pragma once | ||
|
||
#include "LibreTuyaConfig.h" | ||
|
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,55 @@ | ||
/* | ||
Copyright (c) 2014 Arduino. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <Arduino.h> | ||
|
||
void randomSeed(uint32_t dwSeed) { | ||
if (dwSeed != 0) { | ||
srand(dwSeed); | ||
} | ||
} | ||
|
||
long random(long howbig) { | ||
if (howbig == 0) { | ||
return 0; | ||
} | ||
|
||
return rand() % howbig; | ||
} | ||
|
||
long random(long howsmall, long howbig) { | ||
if (howsmall >= howbig) { | ||
return howsmall; | ||
} | ||
|
||
long diff = howbig - howsmall; | ||
|
||
return random(diff) + howsmall; | ||
} | ||
|
||
extern long map(long x, long in_min, long in_max, long out_min, long out_max) { | ||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | ||
} | ||
|
||
extern uint16_t makeWord(uint16_t w) { | ||
return w; | ||
} | ||
|
||
extern uint16_t makeWord(uint8_t h, uint8_t l) { | ||
return (h << 8) | l; | ||
} |
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,111 @@ | ||
/* | ||
Copyright (c) 2014 Arduino LLC. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
char *ltoa(long value, char *string, int radix) { | ||
char tmp[33]; | ||
char *tp = tmp; | ||
long i; | ||
unsigned long v; | ||
int sign; | ||
char *sp; | ||
|
||
if (string == NULL) { | ||
return 0; | ||
} | ||
|
||
if (radix > 36 || radix <= 1) { | ||
return 0; | ||
} | ||
|
||
sign = (radix == 10 && value < 0); | ||
if (sign) { | ||
v = -value; | ||
} else { | ||
v = (unsigned long)value; | ||
} | ||
|
||
while (v || tp == tmp) { | ||
i = v % radix; | ||
v = v / radix; | ||
if (i < 10) | ||
*tp++ = i + '0'; | ||
else | ||
*tp++ = i + 'a' - 10; | ||
} | ||
|
||
sp = string; | ||
|
||
if (sign) | ||
*sp++ = '-'; | ||
while (tp > tmp) | ||
*sp++ = *--tp; | ||
*sp = 0; | ||
|
||
return string; | ||
} | ||
|
||
char *ultoa(unsigned long value, char *string, int radix) { | ||
char tmp[33]; | ||
char *tp = tmp; | ||
long i; | ||
unsigned long v = value; | ||
char *sp; | ||
|
||
if (string == NULL) { | ||
return 0; | ||
} | ||
|
||
if (radix > 36 || radix <= 1) { | ||
return 0; | ||
} | ||
|
||
while (v || tp == tmp) { | ||
i = v % radix; | ||
v = v / radix; | ||
if (i < 10) | ||
*tp++ = i + '0'; | ||
else | ||
*tp++ = i + 'a' - 10; | ||
} | ||
|
||
sp = string; | ||
|
||
while (tp > tmp) | ||
*sp++ = *--tp; | ||
*sp = 0; | ||
|
||
return string; | ||
} | ||
|
||
char *itoa(int value, char *string, int radix) { | ||
return ltoa(value, string, radix); | ||
} | ||
|
||
char *utoa(unsigned int value, char *string, int radix) { | ||
return ultoa(value, string, radix); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif |
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,54 @@ | ||
/* | ||
Copyright (c) 2014 Arduino. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <stdint.h> | ||
|
||
uint8_t shiftIn(pin_size_t ulDataPin, pin_size_t ulClockPin, BitOrder ulBitOrder) { | ||
uint8_t value = 0; | ||
uint8_t i; | ||
|
||
for (i = 0; i < 8; ++i) { | ||
digitalWrite(ulClockPin, HIGH); | ||
|
||
if (ulBitOrder == LSBFIRST) { | ||
value |= digitalRead(ulDataPin) << i; | ||
} else { | ||
value |= digitalRead(ulDataPin) << (7 - i); | ||
} | ||
|
||
digitalWrite(ulClockPin, LOW); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
void shiftOut(pin_size_t ulDataPin, pin_size_t ulClockPin, BitOrder ulBitOrder, uint8_t ulVal) { | ||
uint8_t i; | ||
|
||
for (i = 0; i < 8; i++) { | ||
if (ulBitOrder == LSBFIRST) { | ||
digitalWrite(ulDataPin, !!(ulVal & (1 << i))); | ||
} else { | ||
digitalWrite(ulDataPin, !!(ulVal & (1 << (7 - i)))); | ||
} | ||
|
||
digitalWrite(ulClockPin, HIGH); | ||
digitalWrite(ulClockPin, LOW); | ||
} | ||
} |
Oops, something went wrong.