Code used in the SICE E210/P442 lab practical
Dependencies: ADXL362 TSL2561 mbed
Revision 1:f5c993193adc, committed 2018-04-25
- Comitter:
- bhimebau
- Date:
- Wed Apr 25 21:46:22 2018 +0000
- Parent:
- 0:69b431195dc4
- Commit message:
- Finished code;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 69b431195dc4 -r f5c993193adc main.cpp --- a/main.cpp Wed Apr 25 19:11:51 2018 +0000 +++ b/main.cpp Wed Apr 25 21:46:22 2018 +0000 @@ -17,6 +17,7 @@ #define RANGE (0x7FFF) #define OFFSET (0x7FFF) +#define SPI_CYCLES 100 // Configuration for sinewave output #define BUFFER_SIZE (360) uint16_t buffer[BUFFER_SIZE]; @@ -27,10 +28,14 @@ printf("Sinewave example\n"); calculate_sinewave(); adxl362.reset(); - wait_ms(600); // we need to wait at least 500ms after ADXL362 reset + wait_ms(1000); // we need to wait at least 500ms after ADXL362 reset adxl362.set_mode(ADXL362::MEASUREMENT); - volatile int8_t x,y,z; + wait_ms(1000); // we need to wait at least 500ms after ADXL362 reset + volatile int8_t x,y,z; + volatile uint16_t whoami; volatile float light; + int spi_trigger_target = 0; + while(1) { for (int i = 0; i < BUFFER_SIZE; i++) { my_output.write_u16(buffer[i]); @@ -39,9 +44,15 @@ x=adxl362.scanx_u8(); y=adxl362.scany_u8(); z=adxl362.scanz_u8(); - // printf("Accelerometer x = %d y = %d z = %d\r\n",x,y,z); + if (spi_trigger_target++ == SPI_CYCLES){ + spi_trigger_target = 0; + whoami = adxl362.read_reg(ADXL362::DEVID_AD); + } + light = lightsensor.lux(); + // printf("Accelerometer x = %d y = %d z = %d\r\n",x,y,z); // printf("Light sensor %f\n\r",lightsensor.lux()); // wait_ms(100); + } }