Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of COG4050_adxl355_adxl357 by
Diff: ADXL35x/ADXL355.cpp
- Revision:
- 2:14dc1ec57f3b
- Child:
- 3:ee052fdb4331
diff -r d3aeaa02781d -r 14dc1ec57f3b ADXL35x/ADXL355.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL35x/ADXL355.cpp Tue Aug 07 12:49:37 2018 +0000
@@ -0,0 +1,51 @@
+#include <stdint.h>
+#include "mbed.h"
+#include "ADXL355.h"
+
+
+//DigitalOut(cs); ///< DigitalOut instance for the chipselect of the ADXL
+//DigitalOut int1; ///< DigitalOut instance for the chipselect of the ADXL
+//DigitalOut int2; ///< DigitalOut instance for the chipselect of the ADXL
+
+ADXL355::ADXL355(PinName cs_pin, PinName MOSI, PinName MISO, PinName SCK): adxl355(MOSI, MISO, SCK), cs(cs_pin){
+ cs = 1;
+ adxl355.format(8,_SPI_MODE);
+ adxl355.lock();
+}
+
+/** SPI bus frequency */
+void ADXL355::frequency(int hz){
+ adxl355.frequency(hz);
+}
+
+/** Software resets */
+ void ADXL355::reset(void){
+ adxl355.format(8, _SPI_MODE);
+ cs = false;
+ // Writing Code 0x52 (representing the letter, R, in ASCII or unicode) to this register immediately resets the ADXL362.
+ write_reg(RESET, _RESET);
+ cs = true;
+}
+
+ /** Writes the reg register with data */
+void ADXL355::write_reg(ADXL355_register_t reg, uint8_t data){
+ adxl355.format(8, _SPI_MODE);
+ cs = false;
+ adxl355.write(reg<<1 | _WRITE_REG_CMD);
+ adxl355.write(data);
+ cs = true;
+}
+void ADXL355::write_reg_u16(ADXL355_register_t reg, uint16_t data){}
+
+/** Reads the reg register */
+uint8_t ADXL355::read_reg(ADXL355_register_t reg){
+ uint8_t ret_val;
+ adxl355.format(8, _SPI_MODE);
+ cs = false;
+ adxl355.write(reg<<1 | _READ_REG_CMD);
+ ret_val = adxl355.write(_DUMMY_BYTE);
+ cs = true;
+ return ret_val;
+}
+uint16_t ADXL355::read_reg_u16(ADXL355_register_t reg){}
+uint32_t ADXL355::read_reg_u32(ADXL355_register_t reg){}
\ No newline at end of file
