Skip to content

Commit

Permalink
Fixes #9. Update to version 2.0.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy4495 committed Jan 10, 2023
1 parent 014bb76 commit 301c6e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 - 2022 Andreas Taylor
Copyright (c) 2018 - 2023 Andreas Taylor

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void loop() {
// Write a byte to a device register:
myDevice.writeToRegister(regAddress, byte_to_write);
// Read a byte from a device register:
myDevice.readFromRegister(regAddress, &byte_to_read);
myDevice.readFromRegister(regAddress, byte_to_read);

// Write several bytes to a device register:
myDevice.writeToRegister(regAddress, buffer, 10);
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SWI2C
version=2.0.0
version=2.0.1
author=Andreas Taylor <[email protected]>
maintainer=Andreas Taylor <[email protected]>
sentence=Software I2C library.
Expand Down
3 changes: 3 additions & 0 deletions src/SWI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
07/27/2022 - Andy4495 - Support single-register devices (Issue #3)
08/19/2022 - Andy4495 - Consistently use unsigned, fix-sized types where appropriate
- Add simpler, basic high-level methods
01/10/2023 - Andy4495 - Fix #9 (send NACK after reading byte from device)
*/

#include "SWI2C.h"
Expand Down Expand Up @@ -137,6 +138,7 @@ int SWI2C::readFromDevice(uint8_t &data, bool sendStopBit) {
writeAddress(1); // 1 == Read bit
if (checkAckBit()) {stopBit(); return 0;} // Immediately end transmission and return 0 if NACK detected
data = read1Byte();
checkAckBit(); // Controller needs to send NACK when done reading data
if (sendStopBit) stopBit();
return 1; // Return 1 if no NACKs
}
Expand Down Expand Up @@ -267,6 +269,7 @@ int SWI2C::read1bFromDevice(uint8_t* data, bool sendStopBit){
writeAddress(1); // 1 == Read bit
if (checkAckBit()) {stopBit(); return 0;} // Immediately end transmission and return 0 if NACK detected
*data = read1Byte();
checkAckBit(); // Controller needs to send NACK when done reading data
if (sendStopBit) stopBit();
return 1; // Return 1 if no NACKs
}
Expand Down

0 comments on commit 301c6e7

Please sign in to comment.