parent
d83f40652d
commit
774cf149c4
|
@ -1,5 +1,5 @@
|
|||
/* uLisp ARM 2.7 - www.ulisp.com
|
||||
David Johnson-Davies - www.technoblogy.com - 20th May 2019
|
||||
/* uLisp ARM 2.7b - www.ulisp.com
|
||||
David Johnson-Davies - www.technoblogy.com - 9th June 2019
|
||||
|
||||
Licensed under the MIT license: https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
@ -1100,9 +1100,14 @@ inline bool I2Cwrite(uint8_t data) {
|
|||
}
|
||||
|
||||
bool I2Cstart (uint8_t address, uint8_t read) {
|
||||
if (read == 0) Wire.beginTransmission(address);
|
||||
int ok = true;
|
||||
if (read == 0) {
|
||||
Wire.beginTransmission(address);
|
||||
ok = (Wire.endTransmission(true) == 0);
|
||||
Wire.beginTransmission(address);
|
||||
}
|
||||
else Wire.requestFrom(address, I2CCount);
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool I2Crestart (uint8_t address, uint8_t read) {
|
||||
|
@ -2981,7 +2986,7 @@ object *fn_writeline (object *args, object *env) {
|
|||
|
||||
object *fn_restarti2c (object *args, object *env) {
|
||||
(void) env;
|
||||
int stream = first(args)->integer;
|
||||
int stream = istream(first(args));
|
||||
args = cdr(args);
|
||||
int read = 0; // Write
|
||||
I2CCount = 0;
|
||||
|
@ -2991,7 +2996,7 @@ object *fn_restarti2c (object *args, object *env) {
|
|||
read = (rw != NULL);
|
||||
}
|
||||
int address = stream & 0xFF;
|
||||
if (stream>>8 != I2CSTREAM) error3(RESTARTI2C, PSTR("not i2c"));
|
||||
if (stream>>8 != I2CSTREAM) error3(RESTARTI2C, PSTR("not an i2c stream"));
|
||||
return I2Crestart(address, read) ? tee : nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue