Looked at your .js code... wondered why you use WREN for just reading the busy flag...
AT25.prototype.isBusy= function() { if (add===undefined) { add=this.ca; } var t=new Uint8Array([0]); this.spi.send(6,this.cspin); //WREN // this.spi.send(6,this.cspin); //WREN var i=0; t[i++]=0x05; var ov=new Uint8Array([255]); do { ov[0]=this.spi.send(t,this.cspin); }while((ov[0] & 0x01) == 0x01); print("\r\n ov is :" +ov[0]); };
I could imagine that this could mess up the whole thing... I would just go for this simple approach:
// returns true if busy AT25.prototype.isBusy= function() { return ((this.spi.send([0x05],this.cspin)[0] & 0x01) === 0x01); }
You can then use this method in the read, write, erase, etc. at the begin like this:
... while (this.isBuys()) { ""; } ...
Invoke .isBusy() Is no big deal, because you want to - and have to - waste time anyway...
If you do not like the extra invocation, you could just imbed the code in the while condition:
... while ((this.spi.send([0x05],this.cspin)[0] & 0x01) === 0x01) { ""; } ...
@Gordon, is the below code about the same as the above - assuming both work?
... while ((this.spi.send(5,this.cspin)[0] & 1) === 1) { ""; } ...
And if both work, which one would you prefer?
I'm asking, because of the conversion of literal ints to uInt8?
@allObjects started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Looked at your .js code... wondered why you use WREN for just reading the busy flag...
I could imagine that this could mess up the whole thing... I would just go for this simple approach:
You can then use this method in the read, write, erase, etc. at the begin like this:
Invoke .isBusy() Is no big deal, because you want to - and have to - waste time anyway...
If you do not like the extra invocation, you could just imbed the code in the while condition:
@Gordon, is the below code about the same as the above - assuming both work?
And if both work, which one would you prefer?
I'm asking, because of the conversion of literal ints to uInt8?