I had no idea they'd changed the accelerometer. So does the LIS302DL code not work at all?
1.- Power On Reset (Combination of commands through control registers 4 & 6 maybe?)
Sounds like that's what you need - however I wonder if there's any real need to reset it?
2.- Reading packages ONLY when they are READY (Combination of commands through control registers 3 & 6 maybe and digitalRead(E0)?)
You might be able to use setWatch(function() { .. get data .. }, E0, { edge:"rising",repeat:true}) which will call the function as soon as the edge rises. You'd have to be careful not to get data too fast though - probably the most you'd want is 500Hz, probably less.
3.- Reading Temperature (I think I am not getting the Payload in the correct format)
Do you have any examples of what you get for the temperature value and what you'd expect the temperature to be?
4.- Generate "STALL" using the internal tone generator within the "CS43L22" DAC (have not touch it, and I hope I2S is not necessary)
I'm not quite sure what you mean here? I'm not 100% sure but I assumed that the DAC wasn't initialised by default, so would be ok being left alone.
In terms of your code, it looks fine (looks like you're not using the avrx/y/etc as averages, but you'd need an avrz=0 outside the function if you were going to do that).
If you wanted to make the SPI slightly faster, you might be able to fit all 3 queries into one command with:
var d = SPI1.send([0xA9,0xAB,0xAD,0x0C,0], E3)[1];
var accx = d[1], accy = d[2], accz = d[3], tmp = d[4];
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.
Hi, thanks for posting up!
I had no idea they'd changed the accelerometer. So does the LIS302DL code not work at all?
Sounds like that's what you need - however I wonder if there's any real need to reset it?
You might be able to use
setWatch(function() { .. get data .. }, E0, { edge:"rising",repeat:true})
which will call the function as soon as the edge rises. You'd have to be careful not to get data too fast though - probably the most you'd want is 500Hz, probably less.Do you have any examples of what you get for the temperature value and what you'd expect the temperature to be?
4.- Generate "STALL" using the internal tone generator within the "CS43L22" DAC (have not touch it, and I hope I2S is not necessary)
I'm not quite sure what you mean here? I'm not 100% sure but I assumed that the DAC wasn't initialised by default, so would be ok being left alone.
In terms of your code, it looks fine (looks like you're not using the avrx/y/etc as averages, but you'd need an
avrz=0
outside the function if you were going to do that).If you wanted to make the SPI slightly faster, you might be able to fit all 3 queries into one command with:
Whether that works depends on the chip though...