-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ambiguous for TwoWire::requestFrom() methods and align API with A…
…rduino.cc (#8817) * Fix ambiguous for TwoWire::requestFrom() methods. * Remove TwoWire::begin(int) overload Inside the function, this overload truncated the data type to a shorter one. This could break some users' hopes. * Rewrite TwoWire with using HardwareI2C - implement proposal #8818 (comment) to bring the HARDWARE interface into compliance * Fix TwoWire::end() return type. * Fix TwoWire::setClock() return type. * Fix no return statement in the TwoWire::requestFrom. * fix(libraries/Wire): fix bad return-statement Remove non-void values of the return-statements in function returning 'void'. * style(libraries/Wire): replace tabs with spaces * refactor(libraries/Wire): use slave without support TwoWire::begin(uint8_t address) should be available without slave support by SoC? * refactor(libraries/Wire): remove unused variables Compiler reports "Wire.cpp:393:15: error: variable 'err' set but not used [-Werror=unused-but-set-variable]". * refactor(libraries/Wire): remove unused variables Compiler reports "Wire.cpp:337:15: error: variable 'err' set but not used [-Werror=unused-but-set-variable]". * fix(libraries/Wire): hide slave support elements TwoWire::user_onRequest is used only in conjunction with slave support? * refactor(libraries/Wire): remove temporary comment * fix(libraries/Wire): restore an accidentally deleted implementation TwoWire::endTransmission() was accidentally deleted from a cpp file. * refactor(libraries/Wire): return return types In TwoWire class return return types. * fix(libraries/Wire): fix return type * refactor(libraries/Wire): add return statement if slave isn't supported Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> * refactor(libraries/Wire): fix indentation Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> * refactor(libraries/Wire): fix indentation Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> * refactor(libraries/Wire): fix indentation Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> * refactor(libraries/Wire): remove unnecessary empty lines --------- Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
- Loading branch information
1 parent
cceebb5
commit 7966f4a
Showing
3 changed files
with
109 additions
and
137 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,42 @@ | ||
/* | ||
Copyright (c) 2016 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 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inttypes.h> | ||
#include "Stream.h" | ||
|
||
class HardwareI2C : public Stream | ||
{ | ||
public: | ||
virtual bool begin() = 0; | ||
virtual bool begin(uint8_t address) = 0; | ||
virtual bool end() = 0; | ||
|
||
virtual bool setClock(uint32_t freq) = 0; | ||
|
||
virtual void beginTransmission(uint8_t address) = 0; | ||
virtual uint8_t endTransmission(bool stopBit) = 0; | ||
virtual uint8_t endTransmission(void) = 0; | ||
|
||
virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit) = 0; | ||
virtual size_t requestFrom(uint8_t address, size_t len) = 0; | ||
|
||
virtual void onReceive(void(*)(int)) = 0; | ||
virtual void onRequest(void(*)(void)) = 0; | ||
}; |
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