A collection of Analog Devices drivers for the mbed platform
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Revision 24:dae7123d432a, committed 2016-05-18
- Comitter:
- Adrian Suciu
- Date:
- Wed May 18 16:57:57 2016 +0300
- Parent:
- 23:174dd32fa661
- Child:
- 25:b9e3756c9cbb
- Child:
- 26:1b988c505139
- Child:
- 27:3c32495708f4
- Commit message:
- Improved compatibility with Linux systems
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/ADXL362_example/Makefile Wed May 18 16:57:57 2016 +0300 @@ -0,0 +1,98 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +ifeq ($(OS), Windows_NT) + # insert Windows path to arm-none-eabi toolchain + GCC_BIN = C:/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/5.2\ 2015q4/bin/ +else + # insert Linux path to arm-none-eabi toolchain + GCC_BIN = ~/workspace/tools/gcc-arm-none-eabi-5_3-2016q1/bin/ +endif + +PROJECT = ADXL362-MBED +ADI_LIBRARIES_PATH = ../../libraries +MBED_LIBRARIES_PATH = ../../mbed +OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/EVAL_ADXL362_ARDZ/Lcd.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o $(ADI_LIBRARIES_PATH)/EVAL_ADXL362_ARDZ/EVAL_ADXL362_ARDZ.o +# $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o +SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o +INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/EVAL_ADXL362_ARDZ -I$(ADI_LIBRARIES_PATH)/ADXL362 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARIES = -lmbed +LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size + +ifeq ($(HARDFP),1) + FLOAT_ABI = hard +else + FLOAT_ABI = softfp +endif + + +CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP +CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 + +LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -Og +else + CC_FLAGS += -DNDEBUG -Og +endif + +.PHONY: all clean lst size + +all: $(PROJECT).bin $(PROJECT).hex size + + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) + + +.asm.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.s.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.S.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< + + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ + +$(PROJECT).hex: $(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(PROJECT).lst: $(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(PROJECT).lst + +size: $(PROJECT).elf + $(SIZE) $(PROJECT).elf + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/ADXL362_example/main.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,88 @@
+/**
+ * @file main.cpp
+ * @brief Main file for the ADXL362-example project
+ * @author Analog Devices Inc.
+ *
+ * For support please go to:
+ * Github: https://github.com/analogdevicesinc/mbed-adi
+ * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+ * Product: www.analog.com/EVAL-ADXL362-ARDZ
+ * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+ ********************************************************************************
+ * Copyright 2016(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ********************************************************************************/
+
+#include "mbed.h"
+#include "ADXL362.h"
+#include "Lcd.h"
+#include "EVAL_ADXL362_ARDZ.h"
+
+Serial pc(USBTX, USBRX); ///< Serial interface to the pc
+Lcd lcd;
+ADXL362 adxl362(D9);
+EVAL_ADXL362_ARDZ adxl362_board(lcd, adxl362);
+
+void flush_serial_buffer(void)
+{
+ while (pc.readable())
+ pc.getc();
+ return;
+}
+
+int main()
+{
+
+ adxl362_board.LCD_setup();
+ adxl362_board.ADXL_setup();
+
+ /* Infinite loop */
+ while (1) {
+ if(adxl362_board.ADXL_get_int()) { // ADXL362 is AWAKE ?
+
+ adxl362_board.LCD_init_display(); // will only turn on if it's off
+ wait_ms(100);
+ adxl362_board.ADXL_scan_xyzt();
+ adxl362_board.LCD_display_values();
+ adxl362_board.LCD_display_level();
+
+ } else {
+
+ adxl362_board.LCD_deinit_display(); // will only turn off it it's on
+
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/CN0216_example/Makefile Wed May 18 16:57:57 2016 +0300 @@ -0,0 +1,97 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +ifeq ($(OS), Windows_NT) + # insert Windows path to arm-none-eabi toolchain + GCC_BIN = C:/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/5.2\ 2015q4/bin/ +else + # insert Linux path to arm-none-eabi toolchain + GCC_BIN = ~/workspace/tools/gcc-arm-none-eabi-5_3-2016q1/bin/ +endif + +PROJECT = CN0216-MBED +ADI_LIBRARIES_PATH = ../../libraries +MBED_LIBRARIES_PATH = ../../mbed +OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/AD7791/AD7791.o $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o +SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o +INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/AD5270 -I$(ADI_LIBRARIES_PATH)/AD7791 -I$(ADI_LIBRARIES_PATH)/CN0216 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARIES = -lmbed +LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size + +ifeq ($(HARDFP),1) + FLOAT_ABI = hard +else + FLOAT_ABI = softfp +endif + + +CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP +CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 + +LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + +.PHONY: all clean lst size + +all: $(PROJECT).bin $(PROJECT).hex size + + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) + + +.asm.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.s.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.S.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< + + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ + +$(PROJECT).hex: $(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(PROJECT).lst: $(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(PROJECT).lst + +size: $(PROJECT).elf + $(SIZE) $(PROJECT).elf + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/CN0216_example/main.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,126 @@
+/**
+* @file main.cpp
+* @brief Main file for the CN0357-example project
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0357-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+#include "mbed.h"
+#include "CN0216.h"
+
+const float CAL_WEIGHT = (500.0);
+
+
+Serial pc(USBTX, USBRX); ///< Serial interface to the pc
+
+void flush_serial_buffer(void)
+{
+ while (pc.readable()) pc.getc();
+ return;
+}
+
+void display_data(uint32_t data, float weight, uint64_t timer)
+{
+ pc.printf("\r\nADC Input Voltage input = %x V", data); /* Send valid voltage input value */
+ pc.printf("\r\nSensor Input Weight = %f grams", weight); /* Send valid grams value */
+
+
+ /* pc.printf("%d ",timer);
+ pc.printf("%x ",data);
+ pc.printf("%f ",weight);*/
+ pc.printf("\r\n");
+}
+
+/**
+ * Project entry-point - initializes the CN0216 shield, reads the data when the ADC is ready and outputs the sensor value
+ */
+
+#define SINGLE_CONVERSION
+//#define CONTINOUS_CONVERSION
+
+int main()
+{
+ /* Main variables */
+ //t.start();
+ CN0216 cn0216;
+#ifdef SINGLE_CONVERSION
+ cn0216.init(CAL_WEIGHT);
+#elif defined CONTINOUS_CONVERSION
+ cn0216.init(CAL_WEIGHT, 0x08, 0x07);
+#else
+#error define SINGLE_CONVERSION or CONTINOUS_CONVERSION, but not both
+#endif
+ /* Calibration sequence */
+
+ pc.printf("\r\n Calibrating zero scale. Remove all weights from scale. Press any key to begin ..");
+ while(!pc.readable());
+ flush_serial_buffer();
+ pc.printf("\r\n Calibrating . . . ");
+ cn0216.calibrate(CN0216::ZERO_SCALE_CALIBRATION);
+ pc.printf("done ! ");
+
+ pc.printf("\r\n Calibrating full scale. Put calibration weight on scale. Press any key to begin ..");
+ while(!pc.readable());
+ flush_serial_buffer();
+ pc.printf("\r\n Calibrating . . . ");
+ cn0216.calibrate(CN0216::FULL_SCALE_CALIBRATION);
+ pc.printf("done ! ");
+
+ pc.printf("\r\n Calibration successful ");
+ cn0216.calibrate(CN0216::COMPUTE_UNITS_PER_BIT);
+
+ /* Infinite loop */
+ uint64_t timer = 0;
+ while (1) {
+ wait_ms(1000);
+
+ uint32_t data = cn0216.read_u32();
+ float weight = cn0216.compute_weight(data); // Convert ADC data to voltage
+ display_data(data, weight, timer); // Display data thru UART
+
+ timer++;
+ }
+
+
+ /* Infinite loop, never returns. */
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/CN0357_example/Makefile Wed May 18 16:57:57 2016 +0300 @@ -0,0 +1,97 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +ifeq ($(OS), Windows_NT) + # insert Windows path to arm-none-eabi toolchain + GCC_BIN = C:/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/5.2\ 2015q4/bin/ +else + # insert Linux path to arm-none-eabi toolchain + GCC_BIN = ~/workspace/tools/gcc-arm-none-eabi-5_3-2016q1/bin/ +endif + +PROJECT = CN0357-MBED +ADI_LIBRARIES_PATH = ../../libraries +MBED_LIBRARIES_PATH = ../../mbed +OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/AD7790/AD7790.o $(ADI_LIBRARIES_PATH)/AD5270/AD5270.o $(ADI_LIBRARIES_PATH)/CN0357/CN0357.o +SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o +INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/AD5270 -I$(ADI_LIBRARIES_PATH)/AD7790 -I$(ADI_LIBRARIES_PATH)/CN0357 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +LIBRARIES = -lmbed +LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size + +ifeq ($(HARDFP),1) + FLOAT_ABI = hard +else + FLOAT_ABI = softfp +endif + + +CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP +CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 + +LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + +.PHONY: all clean lst size + +all: $(PROJECT).bin $(PROJECT).hex size + + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) + + +.asm.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.s.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.S.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< + + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ + +$(PROJECT).hex: $(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(PROJECT).lst: $(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(PROJECT).lst + +size: $(PROJECT).elf + $(SIZE) $(PROJECT).elf + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/CN0357_example/main.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,143 @@
+/**
+* @file main.cpp
+* @brief Main file for the CN0357-example project
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0357-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+#include "mbed.h"
+#include "CN0357.h"
+
+/** @mainpage
+ * CN0357 single-supply, low noise, portable gas detector circuit using an
+ * electrochemical sensor. The Alphasense CO-AX carbon monoxide sensor is used
+ * in this example. Electrochemical sensors offer several advantages for
+ * instruments that detect or measure the concentration of many toxic gases.
+ * Most sensors are gas specific and have usable resolutions under one part per
+ * million (ppm) of gas concentration.
+ *
+ * EVAL-CN0357 example program for MBED platforms. To achieve connection between
+ * the shield and the ST Nucleo, the following connections need to be made:
+ *
+ * - ICSP pin 1 -> pin 12 of the Arduino header
+ * - ICSP pin 3 -> pin 13 of the Arduino header
+ * - ICSP pin 4 -> pin 11 of the Arduino header
+ * - if VIN is not supplied, 5V to VIN
+ *
+ * @page CN0357 CN0357 Analog Devices wiki page
+ * @brief link->
+ * https://wiki.analog.com/resources/eval/user-guides/eval-adicup360/hardware/cn0357
+ * @page AD7790 AD7790 datasheet
+ * @brief link ->
+ * http://www.analog.com/media/en/technical-documentation/data-sheets/AD7790.pdf
+ * @page AD5270 AD5270 datasheet
+ * @brief link ->
+ * http://www.analog.com/media/en/technical-documentation/data-sheets/AD5270_5271.pdf
+ *
+ */
+const float SENSOR_RANGE = 2000; ///< gas sensor range in PPM
+const float SENSOR_SENSITIVITY = (65 * pow(10, -9)); ///< gas sensor sensitivity in A/ppm - 65 nA/ppm
+
+Serial pc(USBTX, USBRX); ///< Serial interface to the pc
+
+/**
+ @brief Displays CN0357 circuit readings and data to the UART
+
+ @param ui16Data - ADC data register value to be displayed
+ @param fData1 - ADC input voltage reading to be displayed
+ @param fdata2 - Gas Concentration reading to be displayed
+
+ **/
+void display_data(uint8_t ui8Status_Reg, uint16_t ui16Data, float fData1, float fdata2)
+{
+ pc.printf("\r\nStatus Register value: 0x%x", ui8Status_Reg);
+ pc.printf("\r\nADC Data Register Value = %#08x", ui16Data); /** Send valid ADC data register value*/
+ pc.printf("\r\nADC Input Voltage input = %f V", fData1); /** Send valid voltage input value */
+ pc.printf("\r\nGas Concentration = %f PPM", fdata2); /** Send valid gas concentration value */
+
+ pc.printf("\r\n");
+}
+
+/**
+ * Project entry-point - initializes the CN0357 shield, reads the data when the ADC is ready and outputs the sensor
+ * value in PPM
+ */
+
+#define SINGLE_CONVERSION
+//#define CONTINOUS_CONVERSION
+
+int main()
+{
+ /* Main variables */
+ CN0357 cn0357;
+ uint8_t ui8Status_Reg = 0;
+#ifdef SINGLE_CONVERSION
+ cn0357.init(SENSOR_RANGE, SENSOR_SENSITIVITY);
+#elif defined CONTINOUS_CONVERSION
+ cn0357.init(SENSOR_RANGE, SENSOR_SENSITIVITY, CN0357::INTERNAL_AD7790, 0x00, 0x07);
+#else
+#error define SINGLE_CONVERSION or CONTINOUS_CONVERSION, but not both
+#endif
+
+
+ /* Infinite loop */
+ while (1) {
+ wait_ms(1000);
+#ifdef CONTINOUS_CONVERSION
+ ui8Status_Reg = cn0357.read_adc_status(); // Read ADC Status Register //
+
+ if (ui8Status_Reg != 0x08) { // Checks if ADC data is available
+ pc.printf("\r\nStatus Register value: 0x%x", ui8Status_Reg);
+ } else
+#endif
+ {
+ uint16_t ui16Adcdata = cn0357.read_sensor();
+ float fAdcVoltage = cn0357.data_to_voltage(ui16Adcdata); // Convert ADC data to voltage
+ float fConcentration = cn0357.calc_ppm(fAdcVoltage); // Convert voltage to Gas concentration
+ display_data(ui8Status_Reg, ui16Adcdata, fAdcVoltage, fConcentration); // Display data thru UART
+ }
+ }
+
+
+ /* Infinite loop, never returns. */
+}
+
--- a/examples/adxl362_example/Makefile Tue May 17 18:37:29 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = adxl362-MBED -ADI_LIBRARIES_PATH = ../../libraries -MBED_LIBRARIES_PATH = ../../mbed -OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/eval_adxl362_ardz/lcd.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o $(ADI_LIBRARIES_PATH)/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.o -# $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o -SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o -INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/eval_adxl362_ardz -I$(ADI_LIBRARIES_PATH)/adxl362 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARIES = -lmbed -LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-gcc -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -ifeq ($(HARDFP),1) - FLOAT_ABI = hard -else - FLOAT_ABI = softfp -endif - - -CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP -CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys - - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -Og -else - CC_FLAGS += -DNDEBUG -Og -endif - -.PHONY: all clean lst size - -all: $(PROJECT).bin $(PROJECT).hex size - - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - - -.asm.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.s.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.S.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - - -$(PROJECT).bin: $(PROJECT).elf - $(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: $(PROJECT).elf - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - -
--- a/examples/adxl362_example/main.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/**
- * @file main.cpp
- * @brief Main file for the ADXL362-example project
- * @author Analog Devices Inc.
- *
- * For support please go to:
- * Github: https://github.com/analogdevicesinc/mbed-adi
- * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
- * Product: www.analog.com/EVAL-ADXL362-ARDZ
- * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
- ********************************************************************************
- * Copyright 2016(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ********************************************************************************/
-
-#include "mbed.h"
-#include "ADXL362.h"
-#include "lcd.h"
-#include "EVAL_ADXL362_ARDZ.h"
-
-Serial pc(USBTX, USBRX); ///< Serial interface to the pc
-Lcd lcd;
-ADXL362 adxl362(D9);
-EVAL_ADXL362_ARDZ adxl362_board(lcd, adxl362);
-
-void flush_serial_buffer(void)
-{
- while (pc.readable())
- pc.getc();
- return;
-}
-
-int main()
-{
-
- adxl362_board.LCD_setup();
- adxl362_board.ADXL_setup();
-
- /* Infinite loop */
- while (1) {
- if(adxl362_board.ADXL_get_int()) { // ADXL362 is AWAKE ?
-
- adxl362_board.LCD_init_display(); // will only turn on if it's off
- wait_ms(100);
- adxl362_board.ADXL_scan_xyzt();
- adxl362_board.LCD_display_values();
- adxl362_board.LCD_display_level();
-
- } else {
-
- adxl362_board.LCD_deinit_display(); // will only turn off it it's on
-
- }
- }
-}
-
--- a/examples/cn0216_example/Makefile Tue May 17 18:37:29 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = CN0216-MBED -ADI_LIBRARIES_PATH = ../../libraries -MBED_LIBRARIES_PATH = ../../mbed -OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/AD7791/AD7791.o $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o -SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o -INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/ad5270 -I$(ADI_LIBRARIES_PATH)/ad7791 -I$(ADI_LIBRARIES_PATH)/cn0216 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARIES = -lmbed -LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-gcc -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -ifeq ($(HARDFP),1) - FLOAT_ABI = hard -else - FLOAT_ABI = softfp -endif - - -CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP -CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys - - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -.PHONY: all clean lst size - -all: $(PROJECT).bin $(PROJECT).hex size - - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - - -.asm.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.s.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.S.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - - -$(PROJECT).bin: $(PROJECT).elf - $(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: $(PROJECT).elf - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - -
--- a/examples/cn0216_example/main.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/**
-* @file main.cpp
-* @brief Main file for the CN0357-example project
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0357-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-#include "mbed.h"
-#include "CN0216.h"
-
-const float CAL_WEIGHT = (500.0);
-
-
-Serial pc(USBTX, USBRX); ///< Serial interface to the pc
-
-void flush_serial_buffer(void)
-{
- while (pc.readable()) pc.getc();
- return;
-}
-
-void display_data(uint32_t data, float weight, uint64_t timer)
-{
- pc.printf("\r\nADC Input Voltage input = %x V", data); /* Send valid voltage input value */
- pc.printf("\r\nSensor Input Weight = %f grams", weight); /* Send valid grams value */
-
-
- /* pc.printf("%d ",timer);
- pc.printf("%x ",data);
- pc.printf("%f ",weight);*/
- pc.printf("\r\n");
-}
-
-/**
- * Project entry-point - initializes the CN0216 shield, reads the data when the ADC is ready and outputs the sensor value
- */
-
-#define SINGLE_CONVERSION
-//#define CONTINOUS_CONVERSION
-
-int main()
-{
- /* Main variables */
- //t.start();
- CN0216 cn0216;
-#ifdef SINGLE_CONVERSION
- cn0216.init(CAL_WEIGHT);
-#elif defined CONTINOUS_CONVERSION
- cn0216.init(CAL_WEIGHT, 0x08, 0x07);
-#else
-#error define SINGLE_CONVERSION or CONTINOUS_CONVERSION, but not both
-#endif
- /* Calibration sequence */
-
- pc.printf("\r\n Calibrating zero scale. Remove all weights from scale. Press any key to begin ..");
- while(!pc.readable());
- flush_serial_buffer();
- pc.printf("\r\n Calibrating . . . ");
- cn0216.calibrate(CN0216::ZERO_SCALE_CALIBRATION);
- pc.printf("done ! ");
-
- pc.printf("\r\n Calibrating full scale. Put calibration weight on scale. Press any key to begin ..");
- while(!pc.readable());
- flush_serial_buffer();
- pc.printf("\r\n Calibrating . . . ");
- cn0216.calibrate(CN0216::FULL_SCALE_CALIBRATION);
- pc.printf("done ! ");
-
- pc.printf("\r\n Calibration successful ");
- cn0216.calibrate(CN0216::COMPUTE_UNITS_PER_BIT);
-
- /* Infinite loop */
- uint64_t timer = 0;
- while (1) {
- wait_ms(1000);
-
- uint32_t data = cn0216.read_u32();
- float weight = cn0216.compute_weight(data); // Convert ADC data to voltage
- display_data(data, weight, timer); // Display data thru UART
-
- timer++;
- }
-
-
- /* Infinite loop, never returns. */
-}
-
--- a/examples/cn0357_example/Makefile Tue May 17 18:37:29 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -# This file was automagically generated by mbed.org. For more information, -# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded - -GCC_BIN = -PROJECT = CN0357-MBED -ADI_LIBRARIES_PATH = ../../libraries -MBED_LIBRARIES_PATH = ../../mbed -OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/AD7790/AD7790.o $(ADI_LIBRARIES_PATH)//AD5270/AD5270.o $(ADI_LIBRARIES_PATH)//cn0357/cn0357.o -SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o -INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/ad5270 -I$(ADI_LIBRARIES_PATH)/ad7790 -I$(ADI_LIBRARIES_PATH)/cn0357 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM -LIBRARIES = -lmbed -LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld - -############################################################################### -AS = $(GCC_BIN)arm-none-eabi-as -CC = $(GCC_BIN)arm-none-eabi-gcc -CPP = $(GCC_BIN)arm-none-eabi-g++ -LD = $(GCC_BIN)arm-none-eabi-gcc -OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy -OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump -SIZE = $(GCC_BIN)arm-none-eabi-size - -ifeq ($(HARDFP),1) - FLOAT_ABI = hard -else - FLOAT_ABI = softfp -endif - - -CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) -CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP -CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTARGET_NUCLEO_F411RE -D__CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_CORTEX_M -D__FPU_PRESENT=1 -DTARGET_LIKE_CORTEX_M4 -DMBED_BUILD_TIMESTAMP=1458639619.11 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_FF_MORPHO -DTOOLCHAIN_GCC -DTARGET_STM32F411RE -DARM_MATH_CM4 - -LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref -LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys - - -ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 -else - CC_FLAGS += -DNDEBUG -Os -endif - -.PHONY: all clean lst size - -all: $(PROJECT).bin $(PROJECT).hex size - - -clean: - rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) - - -.asm.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.s.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< -.S.o: - $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< - -.c.o: - $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< - -.cpp.o: - $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< - - - -$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) - - -$(PROJECT).bin: $(PROJECT).elf - $(OBJCOPY) -O binary $< $@ - -$(PROJECT).hex: $(PROJECT).elf - @$(OBJCOPY) -O ihex $< $@ - -$(PROJECT).lst: $(PROJECT).elf - @$(OBJDUMP) -Sdh $< > $@ - -lst: $(PROJECT).lst - -size: $(PROJECT).elf - $(SIZE) $(PROJECT).elf - -DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) --include $(DEPS) - -
--- a/examples/cn0357_example/main.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/**
-* @file main.cpp
-* @brief Main file for the CN0357-example project
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0357-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-#include "mbed.h"
-#include "CN0357.h"
-
-/** @mainpage
- * CN0357 single-supply, low noise, portable gas detector circuit using an
- * electrochemical sensor. The Alphasense CO-AX carbon monoxide sensor is used
- * in this example. Electrochemical sensors offer several advantages for
- * instruments that detect or measure the concentration of many toxic gases.
- * Most sensors are gas specific and have usable resolutions under one part per
- * million (ppm) of gas concentration.
- *
- * EVAL-CN0357 example program for MBED platforms. To achieve connection between
- * the shield and the ST Nucleo, the following connections need to be made:
- *
- * - ICSP pin 1 -> pin 12 of the Arduino header
- * - ICSP pin 3 -> pin 13 of the Arduino header
- * - ICSP pin 4 -> pin 11 of the Arduino header
- * - if VIN is not supplied, 5V to VIN
- *
- * @page CN0357 CN0357 Analog Devices wiki page
- * @brief link->
- * https://wiki.analog.com/resources/eval/user-guides/eval-adicup360/hardware/cn0357
- * @page AD7790 AD7790 datasheet
- * @brief link ->
- * http://www.analog.com/media/en/technical-documentation/data-sheets/AD7790.pdf
- * @page AD5270 AD5270 datasheet
- * @brief link ->
- * http://www.analog.com/media/en/technical-documentation/data-sheets/AD5270_5271.pdf
- *
- */
-const float SENSOR_RANGE = 2000; ///< gas sensor range in PPM
-const float SENSOR_SENSITIVITY = (65 * pow(10, -9)); ///< gas sensor sensitivity in A/ppm - 65 nA/ppm
-
-Serial pc(USBTX, USBRX); ///< Serial interface to the pc
-
-/**
- @brief Displays CN0357 circuit readings and data to the UART
-
- @param ui16Data - ADC data register value to be displayed
- @param fData1 - ADC input voltage reading to be displayed
- @param fdata2 - Gas Concentration reading to be displayed
-
- **/
-void display_data(uint8_t ui8Status_Reg, uint16_t ui16Data, float fData1, float fdata2)
-{
- pc.printf("\r\nStatus Register value: 0x%x", ui8Status_Reg);
- pc.printf("\r\nADC Data Register Value = %#08x", ui16Data); /** Send valid ADC data register value*/
- pc.printf("\r\nADC Input Voltage input = %f V", fData1); /** Send valid voltage input value */
- pc.printf("\r\nGas Concentration = %f PPM", fdata2); /** Send valid gas concentration value */
-
- pc.printf("\r\n");
-}
-
-/**
- * Project entry-point - initializes the CN0357 shield, reads the data when the ADC is ready and outputs the sensor
- * value in PPM
- */
-
-#define SINGLE_CONVERSION
-//#define CONTINOUS_CONVERSION
-
-int main()
-{
- /* Main variables */
- CN0357 cn0357;
- uint8_t ui8Status_Reg = 0;
-#ifdef SINGLE_CONVERSION
- cn0357.init(SENSOR_RANGE, SENSOR_SENSITIVITY);
-#elif defined CONTINOUS_CONVERSION
- cn0357.init(SENSOR_RANGE, SENSOR_SENSITIVITY, CN0357::INTERNAL_AD7790, 0x00, 0x07);
-#else
-#error define SINGLE_CONVERSION or CONTINOUS_CONVERSION, but not both
-#endif
-
-
- /* Infinite loop */
- while (1) {
- wait_ms(1000);
-#ifdef CONTINOUS_CONVERSION
- ui8Status_Reg = cn0357.read_adc_status(); // Read ADC Status Register //
-
- if (ui8Status_Reg != 0x08) { // Checks if ADC data is available
- pc.printf("\r\nStatus Register value: 0x%x", ui8Status_Reg);
- } else
-#endif
- {
- uint16_t ui16Adcdata = cn0357.read_sensor();
- float fAdcVoltage = cn0357.data_to_voltage(ui16Adcdata); // Convert ADC data to voltage
- float fConcentration = cn0357.calc_ppm(fAdcVoltage); // Convert voltage to Gas concentration
- display_data(ui8Status_Reg, ui16Adcdata, fAdcVoltage, fConcentration); // Display data thru UART
- }
- }
-
-
- /* Infinite loop, never returns. */
-}
-
--- a/examples/drvdiag/Makefile Tue May 17 18:37:29 2016 +0300 +++ b/examples/drvdiag/Makefile Wed May 18 16:57:57 2016 +0300 @@ -1,14 +1,21 @@ # This file was automagically generated by mbed.org. For more information, # see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded -GCC_BIN = +ifeq ($(OS), Windows_NT) + # insert Windows path to arm-none-eabi toolchain + GCC_BIN = C:/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/5.2\ 2015q4/bin/ +else + # insert Linux path to arm-none-eabi toolchain + GCC_BIN = ~/workspace/tools/gcc-arm-none-eabi-5_3-2016q1/bin/ +endif + PROJECT = drvdiag ADI_LIBRARIES_PATH = ../../libraries MBED_LIBRARIES_PATH = ../../mbed DRIVER_WRAPPER_PATH = ./driver_wrapper -OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o $(DRIVER_WRAPPER_PATH)/adxl362_diag.o $(DRIVER_WRAPPER_PATH)/cn0357_diag.o $(DRIVER_WRAPPER_PATH)/cn0216_diag.o $(DRIVER_WRAPPER_PATH)/ad7790_diag.o $(DRIVER_WRAPPER_PATH)/ad7791_diag.o $(DRIVER_WRAPPER_PATH)/ad5270_diag.o $(ADI_LIBRARIES_PATH)/AD7790/AD7790.o $(ADI_LIBRARIES_PATH)/AD7791/AD7791.o $(ADI_LIBRARIES_PATH)/AD5270/AD5270.o $(ADI_LIBRARIES_PATH)/cn0357/CN0357.o $(ADI_LIBRARIES_PATH)/cn0216/CN0216.o +OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o $(DRIVER_WRAPPER_PATH)/ADXL362_Diag.o $(DRIVER_WRAPPER_PATH)/CN0357_Diag.o $(DRIVER_WRAPPER_PATH)/CN0216_Diag.o $(DRIVER_WRAPPER_PATH)/AD7790_Diag.o $(DRIVER_WRAPPER_PATH)/AD7791_Diag.o $(DRIVER_WRAPPER_PATH)/AD5270_Diag.o $(ADI_LIBRARIES_PATH)/AD7790/AD7790.o $(ADI_LIBRARIES_PATH)/AD7791/AD7791.o $(ADI_LIBRARIES_PATH)/AD5270/AD5270.o $(ADI_LIBRARIES_PATH)/CN0357/CN0357.o $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o -INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/adxl362 -I$(ADI_LIBRARIES_PATH)/ad5270 -I$(ADI_LIBRARIES_PATH)/ad7790 -I$(ADI_LIBRARIES_PATH)/ad7791 -I$(ADI_LIBRARIES_PATH)/cn0357 -I$(ADI_LIBRARIES_PATH)/cn0216 -I$(DRIVER_WRAPPER_PATH) -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/ADXL362 -I$(ADI_LIBRARIES_PATH)/AD5270 -I$(ADI_LIBRARIES_PATH)/AD7790 -I$(ADI_LIBRARIES_PATH)/AD7791 -I$(ADI_LIBRARIES_PATH)/CN0357 -I$(ADI_LIBRARIES_PATH)/CN0216 -I$(DRIVER_WRAPPER_PATH) -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM LIBRARIES = -lmbed LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld @@ -88,4 +95,4 @@ DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) -include $(DEPS) - \ No newline at end of file +
--- a/examples/drvdiag/config.h Tue May 17 18:37:29 2016 +0300 +++ b/examples/drvdiag/config.h Wed May 18 16:57:57 2016 +0300 @@ -55,32 +55,32 @@ #ifdef AD7791_PRESENT #include "AD7791.h" -#include "ad7791_diag.h" +#include "AD7791_Diag.h" #endif #ifdef CN0216_PRESENT #include "CN0216.h" -#include "cn0216_diag.h" +#include "CN0216_Diag.h" #endif #ifdef AD7790_PRESENT #include "AD7790.h" -#include "ad7790_diag.h" +#include "AD7790_Diag.h" #endif #ifdef AD5270_PRESENT #include "AD5270.h" -#include "ad5270_diag.h" +#include "AD5270_Diag.h" #endif #ifdef CN0357_PRESENT #include "CN0357.h" -#include "cn0357_diag.h" +#include "CN0357_Diag.h" #endif #ifdef ADXL362_PRESENT #include "ADXL362.h" -#include "adxl362_diag.h" +#include "ADXL362_Diag.h" #endif using namespace std;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD5270_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,142 @@
+/**
+* @file ad5270_diag.cpp
+* @brief Source file for the AD5270 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+#include "AD5270_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+
+AD5270_Diag::AD5270_Diag(AD5270& ad) : dut(ad)
+{
+
+}
+void AD5270_Diag::enable_50TP_programming()
+{
+ dut.enable_50TP_programming();
+ pc.printf("Enabled 50TP prog");
+
+}
+void AD5270_Diag::store_50TP()
+{
+ dut.store_50TP();
+ pc.printf("50TP stored");
+}
+void AD5270_Diag::disable_50TP_programming()
+{
+ dut.disable_50TP_programming();
+ pc.printf("Disabled 50TP prog");
+}
+
+void AD5270_Diag::write_RDAC()
+{
+ float res = strtof(cmdbuffer[1].c_str(), NULL);
+ dut.write_RDAC(res);
+ pc.printf("Wrote %f", res);
+}
+void AD5270_Diag::read_RDAC()
+{
+ pc.printf("Read %f", dut.read_RDAC());
+}
+void AD5270_Diag::write_cmd()
+{
+ uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ uint8_t regVal = strtol(cmdbuffer[2].c_str(), NULL, 16);
+ pc.printf("Returned %x: ", dut.write_cmd(reg, regVal));
+}
+
+void AD5270_Diag::set_HiZ()
+{
+ pc.printf("SDO set to HiZ");
+ dut.set_SDO_HiZ();
+}
+
+void AD5270_Diag::read_50TP_last_address(void)
+{
+ pc.printf("Returned %x:", dut.read_50TP_last_address());
+}
+void AD5270_Diag::read_50TP_memory(void)
+{
+ uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ pc.printf("Returned %x", dut.read_50TP_memory(reg));
+}
+
+void AD5270_Diag::write_ctrl_reg(void)
+{
+ uint8_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_ctrl_reg(val);
+ pc.printf("Wrote %x to ctrl_reg", val );
+}
+void AD5270_Diag::read_ctrl_reg(void)
+{
+ pc.printf("Read %x from ctrl_reg", dut.read_ctrl_reg());
+}
+
+void AD5270_Diag::reset_RDAC(void)
+{
+ dut.reset_RDAC();
+ pc.printf("Resetted rdac");
+}
+void AD5270_Diag::change_mode(void)
+{
+ uint8_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.change_mode(static_cast<AD5270::AD5270Modes_t>(val));
+ pc.printf("Changed mode to %x", val);
+}
+
+void AD5270_Diag::write_wiper_reg(void)
+{
+ uint16_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_wiper_reg(val);
+ pc.printf("Wrote %x to wiper", val);
+}
+void AD5270_Diag::read_wiper_reg(void)
+{
+ pc.printf("Read %x from wiper", dut.read_wiper_reg());
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD5270_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,81 @@
+/**
+* @file ad5270_diag.h
+* @brief Header file for the AD5270 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef AD5270_DIAG_H_
+#define AD5270_DIAG_H_
+#include "AD5270.h"
+
+class AD5270_Diag
+{
+public:
+ AD5270_Diag(AD5270& ad);
+ void enable_50TP_programming(void);
+ void store_50TP(void);
+ void disable_50TP_programming(void);
+
+ void write_RDAC(void);
+ void read_RDAC(void);
+ void write_cmd(void);
+ void set_HiZ(void);
+
+ void read_50TP_last_address(void);
+ void read_50TP_memory(void);
+
+ void write_ctrl_reg(void);
+ void read_ctrl_reg(void);
+
+ void reset_RDAC(void);
+ void change_mode(void);
+
+ void write_wiper_reg(void);
+ void read_wiper_reg(void);
+
+private:
+ AD5270& dut;
+};
+
+
+#endif /* AD5270_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/AD5270_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/**
-* @file ad5270_diag.h
-* @brief Header file for the AD5270 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef AD5270_DIAG_H_
-#define AD5270_DIAG_H_
-#include "AD5270.h"
-
-class AD5270_Diag
-{
-public:
- AD5270_Diag(AD5270& ad);
- void enable_50TP_programming(void);
- void store_50TP(void);
- void disable_50TP_programming(void);
-
- void write_RDAC(void);
- void read_RDAC(void);
- void write_cmd(void);
- void set_HiZ(void);
-
- void read_50TP_last_address(void);
- void read_50TP_memory(void);
-
- void write_ctrl_reg(void);
- void read_ctrl_reg(void);
-
- void reset_RDAC(void);
- void change_mode(void);
-
- void write_wiper_reg(void);
- void read_wiper_reg(void);
-
-private:
- AD5270& dut;
-};
-
-
-#endif /* AD5270_DIAG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD7790_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,128 @@
+/**
+* @file ad7790_diag.cpp
+* @brief Source file for the AD7790 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+#include "AD7790_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+
+AD7790_Diag::AD7790_Diag(AD7790& ad) : dut(ad)
+{
+
+}
+
+void AD7790_Diag::init()
+{
+
+}
+void AD7790_Diag::reset()
+{
+ dut.reset();
+ pc.printf("Reseted AD7790");
+}
+
+void AD7790_Diag::write_mode()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_mode_reg(regVal);
+ pc.printf("Wrote mode");
+}
+void AD7790_Diag::read_mode()
+{
+ pc.printf("Mode reg: %x ", dut.read_mode_reg());
+}
+
+void AD7790_Diag::write_filter()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_filter_reg(regVal);
+ pc.printf("Wrote filter");
+}
+void AD7790_Diag::read_filter()
+{
+ pc.printf("Returned: %x ", dut.read_filter_reg());
+}
+void AD7790_Diag::read_data()
+{
+ pc.printf("Data reg: %x ", dut.read_data_reg());
+}
+
+void AD7790_Diag::read_status()
+{
+ pc.printf("Status reg: %x ", dut.read_status_reg());
+}
+
+void AD7790_Diag::read_u16()
+{
+ pc.printf("Data reg: %x ", dut.read_u16());
+}
+void AD7790_Diag::read_voltage()
+{
+ pc.printf("Voltage: %f ", dut.read_voltage());
+}
+void AD7790_Diag::set_continous_mode()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.set_conversion_mode(static_cast<AD7790::AD7790Mode_t>(regVal));
+ pc.printf("Mode set to %d", regVal);
+}
+void AD7790_Diag::set_reference_voltage()
+{
+ float ref = strtof(cmdbuffer[1].c_str(), NULL);
+ dut.set_reference_voltage(ref);
+ pc.printf("Reference Voltage set to %f", ref);
+}
+
+void AD7790_Diag::set_channel()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.set_channel(static_cast<AD7790::AD7790Channel_t>(regVal));
+ pc.printf("Mode set to %d", regVal);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD7790_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,80 @@
+/**
+* @file ad7790_diag.h
+* @brief Header file for the AD7790 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+#ifndef AD7790_DIAG_H_
+#define AD7790_DIAG_H_
+
+#include "AD7790.h"
+
+class AD7790_Diag
+{
+
+public:
+ AD7790_Diag(AD7790& ad);
+ void init(void);
+ void reset(void);
+ void write_mode(void);
+ void write_filter(void);
+ void read_mode(void);
+ void read_filter(void);
+ void read_data(void);
+ void read_status(void);
+ void read_u16(void);
+ void read_voltage(void);
+ void set_continous_mode(void);
+ void set_reference_voltage(void);
+ void set_channel(void);
+
+private:
+ AD7790& dut;
+};
+
+/*
+
+*/
+
+
+
+#endif /* AD7790_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/AD7790_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/**
-* @file ad7790_diag.cpp
-* @brief Source file for the AD7790 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "AD7790_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-AD7790_Diag::AD7790_Diag(AD7790& ad) : dut(ad)
-{
-
-}
-
-void AD7790_Diag::init()
-{
-
-}
-void AD7790_Diag::reset()
-{
- dut.reset();
- pc.printf("Reseted AD7790");
-}
-
-void AD7790_Diag::write_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_mode_reg(regVal);
- pc.printf("Wrote mode");
-}
-void AD7790_Diag::read_mode()
-{
- pc.printf("Mode reg: %x ", dut.read_mode_reg());
-}
-
-void AD7790_Diag::write_filter()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_filter_reg(regVal);
- pc.printf("Wrote filter");
-}
-void AD7790_Diag::read_filter()
-{
- pc.printf("Returned: %x ", dut.read_filter_reg());
-}
-void AD7790_Diag::read_data()
-{
- pc.printf("Data reg: %x ", dut.read_data_reg());
-}
-
-void AD7790_Diag::read_status()
-{
- pc.printf("Status reg: %x ", dut.read_status_reg());
-}
-
-void AD7790_Diag::read_u16()
-{
- pc.printf("Data reg: %x ", dut.read_u16());
-}
-void AD7790_Diag::read_voltage()
-{
- pc.printf("Voltage: %f ", dut.read_voltage());
-}
-void AD7790_Diag::set_continous_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_conversion_mode(static_cast<AD7790::AD7790Mode_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
-void AD7790_Diag::set_reference_voltage()
-{
- float ref = strtof(cmdbuffer[1].c_str(), NULL);
- dut.set_reference_voltage(ref);
- pc.printf("Reference Voltage set to %f", ref);
-}
-
-void AD7790_Diag::set_channel()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_channel(static_cast<AD7790::AD7790Channel_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD7791_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,134 @@
+/**
+* @file AD7791_diag.cpp
+* @brief Source file for the AD7791 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+#include "AD7791_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+
+AD7791_Diag::AD7791_Diag(AD7791& ad) : dut(ad)
+{
+
+}
+
+void AD7791_Diag::init()
+{
+
+}
+void AD7791_Diag::reset()
+{
+ dut.reset();
+ pc.printf("Reseted AD7791");
+}
+
+void AD7791_Diag::write_mode()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_mode_reg(regVal);
+ pc.printf("Wrote mode");
+}
+void AD7791_Diag::read_mode()
+{
+ pc.printf("Mode reg: %x ", dut.read_mode_reg());
+}
+
+void AD7791_Diag::write_filter()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.write_filter_reg(regVal);
+ pc.printf("Wrote filter");
+}
+void AD7791_Diag::read_filter()
+{
+ pc.printf("Returned: %x ", dut.read_filter_reg());
+}
+void AD7791_Diag::read_data()
+{
+ pc.printf("Data reg: %x ", dut.read_data_reg());
+}
+
+void AD7791_Diag::read_status()
+{
+ pc.printf("Status reg: %x ", dut.read_status_reg());
+}
+
+void AD7791_Diag::read_u16()
+{
+ pc.printf("Data reg: %x ", dut.read_u16());
+}
+
+void AD7791_Diag::read()
+{
+ pc.printf("Data reg: %x ", dut.read_u32());
+}
+
+void AD7791_Diag::read_voltage()
+{
+ pc.printf("Voltage: %f ", dut.read_voltage());
+}
+void AD7791_Diag::set_continous_mode()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.set_conversion_mode(static_cast<AD7791::AD7791Mode_t>(regVal));
+ pc.printf("Mode set to %d", regVal);
+}
+void AD7791_Diag::set_reference_voltage()
+{
+ float ref = strtof(cmdbuffer[1].c_str(), NULL);
+ dut.set_reference_voltage(ref);
+ pc.printf("Reference Voltage set to %f", ref);
+}
+
+void AD7791_Diag::set_channel()
+{
+ uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ dut.set_channel(static_cast<AD7791::AD7791Channel_t>(regVal));
+ pc.printf("Mode set to %d", regVal);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/AD7791_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,81 @@
+/**
+* @file ad7791_diag.h
+* @brief Header file for the AD7791 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+#ifndef AD7791_DIAG_H_
+#define AD7791_DIAG_H_
+
+#include "AD7791.h"
+
+class AD7791_Diag
+{
+
+public:
+ AD7791_Diag(AD7791& ad);
+ void init(void);
+ void reset(void);
+ void write_mode(void);
+ void write_filter(void);
+ void read_mode(void);
+ void read_filter(void);
+ void read_data(void);
+ void read_status(void);
+ void read_u16(void);
+ void read();
+ void read_voltage(void);
+ void set_continous_mode(void);
+ void set_reference_voltage(void);
+ void set_channel(void);
+
+private:
+ AD7791& dut;
+};
+
+/*
+
+*/
+
+
+
+#endif /* AD7790_DIAG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/ADXL362_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,180 @@
+/**
+ * @file ADXL362_diag.cpp
+ * @brief Source file for the ADXL362 wrapper used by the driver diag
+ * @author Analog Devices Inc.
+ *
+ * For support please go to:
+ * Github: https://github.com/analogdevicesinc/mbed-adi
+ * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+ * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+ ********************************************************************************
+ * Copyright 2016(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ********************************************************************************/
+
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+#include "ADXL362.h"
+#include "ADXL362_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+volatile bool awake;
+
+ADXL362_Diag::ADXL362_Diag(ADXL362& ad) :
+ dut(ad)
+{
+
+}
+
+/** Low level SPI bus comm methods */
+void ADXL362_Diag::reset(void)
+{
+ dut.reset();
+ pc.printf("Reseted ADXL362");
+}
+
+void ADXL362_Diag::write_reg(void)
+{
+ uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ uint8_t data = strtol(cmdbuffer[2].c_str(), NULL, 16);
+ dut.write_reg(static_cast<ADXL362::ADXL362_register_t>(reg), data);
+ pc.printf("Wrote reg");
+}
+
+void ADXL362_Diag::read_reg(void)
+{
+ uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ uint8_t data = dut.read_reg(static_cast<ADXL362::ADXL362_register_t>(reg));
+ pc.printf("Read %x ", data);
+}
+
+void ADXL362_Diag::scan(void)
+{
+ uint64_t data;
+ data = dut.scan();
+ pc.printf("Data: %x", data);
+}
+
+void ADXL362_Diag::read_status(void)
+{
+ uint8_t data = dut.read_status();
+ pc.printf("Status - %x reg", data);
+}
+
+void ADXL362_Diag::write_ctl(void)
+{
+ uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 16);
+
+ dut.set_power_ctl_reg(data);
+ pc.printf("Wrote reg %x", data);
+}
+
+void ADXL362_Diag::write_ftl(void)
+{
+ uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 16);
+
+ dut.set_filter_ctl_reg(data);
+ pc.printf("Wrote reg %x", data);
+}
+
+void ADXL362_Diag::fifo_read_nr_of_entries(void)
+{
+ uint16_t data = dut.fifo_read_nr_of_entries();
+ pc.printf("fifo entries - %d ", data);
+}
+void ADXL362_Diag::fifo_setup(void)
+{
+ uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 10);
+ uint16_t entry = strtol(cmdbuffer[2].c_str(), NULL, 10);
+ dut.fifo_setup(static_cast<bool>(data & 0x04),
+ static_cast<ADXL362::ADXL362_FIFO_modes_t>(data & 0x03), entry);
+ pc.printf("Wrote reg");
+}
+void ADXL362_Diag::fifo_read_u16(void)
+{
+ uint16_t data = dut.fifo_read_u16();
+ pc.printf("fifo entry - %x ", data);
+}
+void ADXL362_Diag::fifo_scan(void)
+{
+ uint64_t data = dut.fifo_scan();
+ pc.printf("fifo scan - %x ", data);
+}
+
+void ADXL362_Diag::intinit(void)
+{
+
+ dut.reset();
+ pc.printf("adxl362 reset\r\n");
+ wait_ms(500);
+ dut.set_activity_threshold(ACT_VAL);
+ dut.set_activity_time(ACT_TIMER / 10);
+
+ dut.set_inactivity_threshold(INACT_VAL);
+ dut.set_inactivity_time(INACT_TIMER);
+ dut.set_act_inact_ctl_reg(0x3f);
+
+ pc.printf("adxl362 set activity/inactivity\r\n");
+
+ dut.disable_interrupt1();
+ dut.set_interrupt1_pin(D2, 0x40, &rising_adxl362, &falling_adxl362);
+
+ awake = true;
+
+ pc.printf("adxl362 set interrupt\r\n");
+ dut.enable_interrupt1();
+ dut.set_mode(ADXL362::MEASUREMENT);
+ pc.printf("adxl362 measurement started\r\n");
+}
+
+void ADXL362_Diag::checkawake(void)
+{
+ if(awake) pc.printf("awaken");
+ else pc.printf("asleep");
+}
+
+void rising_adxl362()
+{
+ awake = true;
+}
+void falling_adxl362()
+{
+ awake = false;
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/ADXL362_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,84 @@
+/**
+* @file adxl362_diag.h
+* @brief Header file for the ADXL362 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+#ifndef ADXL362_DIAG_H_
+#define ADXL362_DIAG_H_
+
+#include "ADXL362.h"
+
+class ADXL362_Diag
+{
+
+public:
+ ADXL362_Diag(ADXL362& ad);
+ /** Low level SPI bus comm methods */
+ void reset(void);
+ void write_reg(void);
+ void read_reg(void);
+ void scan(void);
+ void read_status(void);
+ void write_ctl(void);
+ void write_ftl(void);
+ void fifo_read_nr_of_entries(void);
+ void fifo_setup(void);
+ void fifo_read_u16(void);
+ void fifo_scan(void);
+ void intinit(void);
+ void checkawake(void);
+
+
+private:
+ ADXL362& dut;
+
+ static const uint16_t INACT_VAL = 50;
+ static const uint16_t INACT_TIMER = 50 * 10;
+ static const uint16_t ACT_VAL = 50;
+ static const uint8_t ACT_TIMER = 100;
+ static const uint16_t SCAN_SENSOR_TIME = 500;
+};
+void rising_adxl362();
+void falling_adxl362();
+
+#endif /* ADXL362_DIAG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/CN0216_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+
+#include "CN0216_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+
+CN0216_Diag::CN0216_Diag(CN0216& cn) : dut(cn)
+{
+
+}
+
+void CN0216_Diag::init(void)
+{
+ uint16_t weight = strtol(cmdbuffer[1].c_str(), NULL, 10);
+ pc.printf("CN0216 initialized with %d calibration weight", weight);
+ dut.init(weight);
+}
+
+void CN0216_Diag::calibrate(void)
+{
+ uint8_t step = strtol(cmdbuffer[1].c_str(), NULL, 16);
+ pc.printf("Calibrating step %d ..", step);
+ dut.calibrate(static_cast<CN0216::CalibrationStep_t>(step));
+ pc.printf(".. DONE", step);
+}
+
+void CN0216_Diag::read_weight(void)
+{
+ pc.printf("Read weight is %f", dut.read_weight());
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/CN0216_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,21 @@
+
+#ifndef CN0216_DIAG_H_
+#define CN0216_DIAG_H_
+#include "CN0216.h"
+
+class CN0216_Diag
+{
+public:
+ CN0216_Diag(CN0216& cn);
+
+ void init(void);
+ void calibrate(void);
+ void read_weight(void);
+
+
+private:
+ CN0216& dut;
+};
+
+
+#endif /* CN0216_DIAG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/CN0357_Diag.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,78 @@
+/**
+* @file cn0357_diag.cpp
+* @brief Source file for the CN0357 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include <stdio.h>
+#include <vector>
+#include <string>
+#include "CN0357_Diag.h"
+
+extern Serial pc;
+extern vector<string> cmdbuffer;
+
+CN0357_Diag::CN0357_Diag(CN0357& cn) : dut(cn)
+{
+
+}
+void CN0357_Diag::set_RDAC()
+{
+ float res = strtof(cmdbuffer[1].c_str(), NULL);
+ dut.set_RDAC_value(res);
+ pc.printf("Wrote %f", res);
+
+}
+void CN0357_Diag::read_ppm(void)
+{
+ pc.printf("Wrote %f", dut.read_ppm());
+}
+
+void CN0357_Diag::set_sensor_param(void)
+{
+ float range = strtof(cmdbuffer[1].c_str(), NULL);
+ float sens = strtof(cmdbuffer[2].c_str(), NULL);
+ sens = sens * pow(10, -9);
+ pc.printf("Suggested RDAC val: %f ", dut.set_sensor_parameters(range, sens));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/drvdiag/driver_wrapper/CN0357_Diag.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,66 @@
+/**
+* @file cn0357_diag.h
+* @brief Header file for the CN0357 wrapper used by the driver diag
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef CN0357_DIAG_H_
+#define CN0357_DIAG_H_
+#include "CN0357.h"
+
+class CN0357_Diag
+{
+public:
+ CN0357_Diag(CN0357& cn);
+
+ void set_RDAC(void);
+ void read_ppm(void);
+ void set_sensor_param(void);
+
+
+private:
+ CN0357& dut;
+};
+
+
+#endif /* CN0357_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/CN0357_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
-* @file cn0357_diag.cpp
-* @brief Source file for the CN0357 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "CN0357_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-CN0357_Diag::CN0357_Diag(CN0357& cn) : dut(cn)
-{
-
-}
-void CN0357_Diag::set_RDAC()
-{
- float res = strtof(cmdbuffer[1].c_str(), NULL);
- dut.set_RDAC_value(res);
- pc.printf("Wrote %f", res);
-
-}
-void CN0357_Diag::read_ppm(void)
-{
- pc.printf("Wrote %f", dut.read_ppm());
-}
-
-void CN0357_Diag::set_sensor_param(void)
-{
- float range = strtof(cmdbuffer[1].c_str(), NULL);
- float sens = strtof(cmdbuffer[2].c_str(), NULL);
- sens = sens * pow(10, -9);
- pc.printf("Suggested RDAC val: %f ", dut.set_sensor_parameters(range, sens));
-}
--- a/examples/drvdiag/driver_wrapper/ad5270_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/**
-* @file ad5270_diag.cpp
-* @brief Source file for the AD5270 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "AD5270_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-AD5270_Diag::AD5270_Diag(AD5270& ad) : dut(ad)
-{
-
-}
-void AD5270_Diag::enable_50TP_programming()
-{
- dut.enable_50TP_programming();
- pc.printf("Enabled 50TP prog");
-
-}
-void AD5270_Diag::store_50TP()
-{
- dut.store_50TP();
- pc.printf("50TP stored");
-}
-void AD5270_Diag::disable_50TP_programming()
-{
- dut.disable_50TP_programming();
- pc.printf("Disabled 50TP prog");
-}
-
-void AD5270_Diag::write_RDAC()
-{
- float res = strtof(cmdbuffer[1].c_str(), NULL);
- dut.write_RDAC(res);
- pc.printf("Wrote %f", res);
-}
-void AD5270_Diag::read_RDAC()
-{
- pc.printf("Read %f", dut.read_RDAC());
-}
-void AD5270_Diag::write_cmd()
-{
- uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
- uint8_t regVal = strtol(cmdbuffer[2].c_str(), NULL, 16);
- pc.printf("Returned %x: ", dut.write_cmd(reg, regVal));
-}
-
-void AD5270_Diag::set_HiZ()
-{
- pc.printf("SDO set to HiZ");
- dut.set_SDO_HiZ();
-}
-
-void AD5270_Diag::read_50TP_last_address(void)
-{
- pc.printf("Returned %x:", dut.read_50TP_last_address());
-}
-void AD5270_Diag::read_50TP_memory(void)
-{
- uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
- pc.printf("Returned %x", dut.read_50TP_memory(reg));
-}
-
-void AD5270_Diag::write_ctrl_reg(void)
-{
- uint8_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_ctrl_reg(val);
- pc.printf("Wrote %x to ctrl_reg", val );
-}
-void AD5270_Diag::read_ctrl_reg(void)
-{
- pc.printf("Read %x from ctrl_reg", dut.read_ctrl_reg());
-}
-
-void AD5270_Diag::reset_RDAC(void)
-{
- dut.reset_RDAC();
- pc.printf("Resetted rdac");
-}
-void AD5270_Diag::change_mode(void)
-{
- uint8_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.change_mode(static_cast<AD5270::AD5270Modes_t>(val));
- pc.printf("Changed mode to %x", val);
-}
-
-void AD5270_Diag::write_wiper_reg(void)
-{
- uint16_t val = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_wiper_reg(val);
- pc.printf("Wrote %x to wiper", val);
-}
-void AD5270_Diag::read_wiper_reg(void)
-{
- pc.printf("Read %x from wiper", dut.read_wiper_reg());
-}
--- a/examples/drvdiag/driver_wrapper/ad5270_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/**
-* @file ad5270_diag.h
-* @brief Header file for the AD5270 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef AD5270_DIAG_H_
-#define AD5270_DIAG_H_
-#include "AD5270.h"
-
-class AD5270_Diag
-{
-public:
- AD5270_Diag(AD5270& ad);
- void enable_50TP_programming(void);
- void store_50TP(void);
- void disable_50TP_programming(void);
-
- void write_RDAC(void);
- void read_RDAC(void);
- void write_cmd(void);
- void set_HiZ(void);
-
- void read_50TP_last_address(void);
- void read_50TP_memory(void);
-
- void write_ctrl_reg(void);
- void read_ctrl_reg(void);
-
- void reset_RDAC(void);
- void change_mode(void);
-
- void write_wiper_reg(void);
- void read_wiper_reg(void);
-
-private:
- AD5270& dut;
-};
-
-
-#endif /* AD5270_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/ad7790_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/**
-* @file ad7790_diag.cpp
-* @brief Source file for the AD7790 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "AD7790_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-AD7790_Diag::AD7790_Diag(AD7790& ad) : dut(ad)
-{
-
-}
-
-void AD7790_Diag::init()
-{
-
-}
-void AD7790_Diag::reset()
-{
- dut.reset();
- pc.printf("Reseted AD7790");
-}
-
-void AD7790_Diag::write_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_mode_reg(regVal);
- pc.printf("Wrote mode");
-}
-void AD7790_Diag::read_mode()
-{
- pc.printf("Mode reg: %x ", dut.read_mode_reg());
-}
-
-void AD7790_Diag::write_filter()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_filter_reg(regVal);
- pc.printf("Wrote filter");
-}
-void AD7790_Diag::read_filter()
-{
- pc.printf("Returned: %x ", dut.read_filter_reg());
-}
-void AD7790_Diag::read_data()
-{
- pc.printf("Data reg: %x ", dut.read_data_reg());
-}
-
-void AD7790_Diag::read_status()
-{
- pc.printf("Status reg: %x ", dut.read_status_reg());
-}
-
-void AD7790_Diag::read_u16()
-{
- pc.printf("Data reg: %x ", dut.read_u16());
-}
-void AD7790_Diag::read_voltage()
-{
- pc.printf("Voltage: %f ", dut.read_voltage());
-}
-void AD7790_Diag::set_continous_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_conversion_mode(static_cast<AD7790::AD7790Mode_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
-void AD7790_Diag::set_reference_voltage()
-{
- float ref = strtof(cmdbuffer[1].c_str(), NULL);
- dut.set_reference_voltage(ref);
- pc.printf("Reference Voltage set to %f", ref);
-}
-
-void AD7790_Diag::set_channel()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_channel(static_cast<AD7790::AD7790Channel_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
--- a/examples/drvdiag/driver_wrapper/ad7790_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/**
-* @file ad7790_diag.h
-* @brief Header file for the AD7790 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-#ifndef AD7790_DIAG_H_
-#define AD7790_DIAG_H_
-
-#include "AD7790.h"
-
-class AD7790_Diag
-{
-
-public:
- AD7790_Diag(AD7790& ad);
- void init(void);
- void reset(void);
- void write_mode(void);
- void write_filter(void);
- void read_mode(void);
- void read_filter(void);
- void read_data(void);
- void read_status(void);
- void read_u16(void);
- void read_voltage(void);
- void set_continous_mode(void);
- void set_reference_voltage(void);
- void set_channel(void);
-
-private:
- AD7790& dut;
-};
-
-/*
-
-*/
-
-
-
-#endif /* AD7790_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/ad7791_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/**
-* @file AD7791_diag.cpp
-* @brief Source file for the AD7791 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "AD7791_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-AD7791_Diag::AD7791_Diag(AD7791& ad) : dut(ad)
-{
-
-}
-
-void AD7791_Diag::init()
-{
-
-}
-void AD7791_Diag::reset()
-{
- dut.reset();
- pc.printf("Reseted AD7791");
-}
-
-void AD7791_Diag::write_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_mode_reg(regVal);
- pc.printf("Wrote mode");
-}
-void AD7791_Diag::read_mode()
-{
- pc.printf("Mode reg: %x ", dut.read_mode_reg());
-}
-
-void AD7791_Diag::write_filter()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.write_filter_reg(regVal);
- pc.printf("Wrote filter");
-}
-void AD7791_Diag::read_filter()
-{
- pc.printf("Returned: %x ", dut.read_filter_reg());
-}
-void AD7791_Diag::read_data()
-{
- pc.printf("Data reg: %x ", dut.read_data_reg());
-}
-
-void AD7791_Diag::read_status()
-{
- pc.printf("Status reg: %x ", dut.read_status_reg());
-}
-
-void AD7791_Diag::read_u16()
-{
- pc.printf("Data reg: %x ", dut.read_u16());
-}
-
-void AD7791_Diag::read()
-{
- pc.printf("Data reg: %x ", dut.read_u32());
-}
-
-void AD7791_Diag::read_voltage()
-{
- pc.printf("Voltage: %f ", dut.read_voltage());
-}
-void AD7791_Diag::set_continous_mode()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_conversion_mode(static_cast<AD7791::AD7791Mode_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
-void AD7791_Diag::set_reference_voltage()
-{
- float ref = strtof(cmdbuffer[1].c_str(), NULL);
- dut.set_reference_voltage(ref);
- pc.printf("Reference Voltage set to %f", ref);
-}
-
-void AD7791_Diag::set_channel()
-{
- uint8_t regVal = strtol(cmdbuffer[1].c_str(), NULL, 16);
- dut.set_channel(static_cast<AD7791::AD7791Channel_t>(regVal));
- pc.printf("Mode set to %d", regVal);
-}
--- a/examples/drvdiag/driver_wrapper/ad7791_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/**
-* @file ad7791_diag.h
-* @brief Header file for the AD7791 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-#ifndef AD7791_DIAG_H_
-#define AD7791_DIAG_H_
-
-#include "AD7791.h"
-
-class AD7791_Diag
-{
-
-public:
- AD7791_Diag(AD7791& ad);
- void init(void);
- void reset(void);
- void write_mode(void);
- void write_filter(void);
- void read_mode(void);
- void read_filter(void);
- void read_data(void);
- void read_status(void);
- void read_u16(void);
- void read();
- void read_voltage(void);
- void set_continous_mode(void);
- void set_reference_voltage(void);
- void set_channel(void);
-
-private:
- AD7791& dut;
-};
-
-/*
-
-*/
-
-
-
-#endif /* AD7790_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/adxl362_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/**
- * @file ADXL362_diag.cpp
- * @brief Source file for the ADXL362 wrapper used by the driver diag
- * @author Analog Devices Inc.
- *
- * For support please go to:
- * Github: https://github.com/analogdevicesinc/mbed-adi
- * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
- * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
- ********************************************************************************
- * Copyright 2016(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "ADXL362.h"
-#include "ADXL362_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-volatile bool awake;
-
-ADXL362_Diag::ADXL362_Diag(ADXL362& ad) :
- dut(ad)
-{
-
-}
-
-/** Low level SPI bus comm methods */
-void ADXL362_Diag::reset(void)
-{
- dut.reset();
- pc.printf("Reseted ADXL362");
-}
-
-void ADXL362_Diag::write_reg(void)
-{
- uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
- uint8_t data = strtol(cmdbuffer[2].c_str(), NULL, 16);
- dut.write_reg(static_cast<ADXL362::ADXL362_register_t>(reg), data);
- pc.printf("Wrote reg");
-}
-
-void ADXL362_Diag::read_reg(void)
-{
- uint8_t reg = strtol(cmdbuffer[1].c_str(), NULL, 16);
- uint8_t data = dut.read_reg(static_cast<ADXL362::ADXL362_register_t>(reg));
- pc.printf("Read %x ", data);
-}
-
-void ADXL362_Diag::scan(void)
-{
- uint64_t data;
- data = dut.scan();
- pc.printf("Data: %x", data);
-}
-
-void ADXL362_Diag::read_status(void)
-{
- uint8_t data = dut.read_status();
- pc.printf("Status - %x reg", data);
-}
-
-void ADXL362_Diag::write_ctl(void)
-{
- uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 16);
-
- dut.set_power_ctl_reg(data);
- pc.printf("Wrote reg %x", data);
-}
-
-void ADXL362_Diag::write_ftl(void)
-{
- uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 16);
-
- dut.set_filter_ctl_reg(data);
- pc.printf("Wrote reg %x", data);
-}
-
-void ADXL362_Diag::fifo_read_nr_of_entries(void)
-{
- uint16_t data = dut.fifo_read_nr_of_entries();
- pc.printf("fifo entries - %d ", data);
-}
-void ADXL362_Diag::fifo_setup(void)
-{
- uint8_t data = strtol(cmdbuffer[1].c_str(), NULL, 10);
- uint16_t entry = strtol(cmdbuffer[2].c_str(), NULL, 10);
- dut.fifo_setup(static_cast<bool>(data & 0x04),
- static_cast<ADXL362::ADXL362_FIFO_modes_t>(data & 0x03), entry);
- pc.printf("Wrote reg");
-}
-void ADXL362_Diag::fifo_read_u16(void)
-{
- uint16_t data = dut.fifo_read_u16();
- pc.printf("fifo entry - %x ", data);
-}
-void ADXL362_Diag::fifo_scan(void)
-{
- uint64_t data = dut.fifo_scan();
- pc.printf("fifo scan - %x ", data);
-}
-
-void ADXL362_Diag::intinit(void)
-{
-
- dut.reset();
- pc.printf("adxl362 reset\r\n");
- wait_ms(500);
- dut.set_activity_threshold(ACT_VAL);
- dut.set_activity_time(ACT_TIMER / 10);
-
- dut.set_inactivity_threshold(INACT_VAL);
- dut.set_inactivity_time(INACT_TIMER);
- dut.set_act_inact_ctl_reg(0x3f);
-
- pc.printf("adxl362 set activity/inactivity\r\n");
-
- dut.disable_interrupt1();
- dut.set_interrupt1_pin(D2, 0x40, &rising_adxl362, &falling_adxl362);
-
- awake = true;
-
- pc.printf("adxl362 set interrupt\r\n");
- dut.enable_interrupt1();
- dut.set_mode(ADXL362::MEASUREMENT);
- pc.printf("adxl362 measurement started\r\n");
-}
-
-void ADXL362_Diag::checkawake(void)
-{
- if(awake) pc.printf("awaken");
- else pc.printf("asleep");
-}
-
-void rising_adxl362()
-{
- awake = true;
-}
-void falling_adxl362()
-{
- awake = false;
-
-}
-
--- a/examples/drvdiag/driver_wrapper/adxl362_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/**
-* @file adxl362_diag.h
-* @brief Header file for the ADXL362 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-#ifndef ADXL362_DIAG_H_
-#define ADXL362_DIAG_H_
-
-#include "ADXL362.h"
-
-class ADXL362_Diag
-{
-
-public:
- ADXL362_Diag(ADXL362& ad);
- /** Low level SPI bus comm methods */
- void reset(void);
- void write_reg(void);
- void read_reg(void);
- void scan(void);
- void read_status(void);
- void write_ctl(void);
- void write_ftl(void);
- void fifo_read_nr_of_entries(void);
- void fifo_setup(void);
- void fifo_read_u16(void);
- void fifo_scan(void);
- void intinit(void);
- void checkawake(void);
-
-
-private:
- ADXL362& dut;
-
- static const uint16_t INACT_VAL = 50;
- static const uint16_t INACT_TIMER = 50 * 10;
- static const uint16_t ACT_VAL = 50;
- static const uint8_t ACT_TIMER = 100;
- static const uint16_t SCAN_SENSOR_TIME = 500;
-};
-void rising_adxl362();
-void falling_adxl362();
-
-#endif /* ADXL362_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/cn0216_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-
-#include "cn0216_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-CN0216_Diag::CN0216_Diag(CN0216& cn) : dut(cn)
-{
-
-}
-
-void CN0216_Diag::init(void)
-{
- uint16_t weight = strtol(cmdbuffer[1].c_str(), NULL, 10);
- pc.printf("CN0216 initialized with %d calibration weight", weight);
- dut.init(weight);
-}
-
-void CN0216_Diag::calibrate(void)
-{
- uint8_t step = strtol(cmdbuffer[1].c_str(), NULL, 16);
- pc.printf("Calibrating step %d ..", step);
- dut.calibrate(static_cast<CN0216::CalibrationStep_t>(step));
- pc.printf(".. DONE", step);
-}
-
-void CN0216_Diag::read_weight(void)
-{
- pc.printf("Read weight is %f", dut.read_weight());
-}
-
--- a/examples/drvdiag/driver_wrapper/cn0216_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-#ifndef CN0216_DIAG_H_
-#define CN0216_DIAG_H_
-#include "CN0216.h"
-
-class CN0216_Diag
-{
-public:
- CN0216_Diag(CN0216& cn);
-
- void init(void);
- void calibrate(void);
- void read_weight(void);
-
-
-private:
- CN0216& dut;
-};
-
-
-#endif /* CN0216_DIAG_H_ */
--- a/examples/drvdiag/driver_wrapper/cn0357_diag.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
-* @file cn0357_diag.cpp
-* @brief Source file for the CN0357 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include <stdio.h>
-#include <vector>
-#include <string>
-#include "CN0357_diag.h"
-
-extern Serial pc;
-extern vector<string> cmdbuffer;
-
-CN0357_Diag::CN0357_Diag(CN0357& cn) : dut(cn)
-{
-
-}
-void CN0357_Diag::set_RDAC()
-{
- float res = strtof(cmdbuffer[1].c_str(), NULL);
- dut.set_RDAC_value(res);
- pc.printf("Wrote %f", res);
-
-}
-void CN0357_Diag::read_ppm(void)
-{
- pc.printf("Wrote %f", dut.read_ppm());
-}
-
-void CN0357_Diag::set_sensor_param(void)
-{
- float range = strtof(cmdbuffer[1].c_str(), NULL);
- float sens = strtof(cmdbuffer[2].c_str(), NULL);
- sens = sens * pow(10, -9);
- pc.printf("Suggested RDAC val: %f ", dut.set_sensor_parameters(range, sens));
-}
--- a/examples/drvdiag/driver_wrapper/cn0357_diag.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/**
-* @file cn0357_diag.h
-* @brief Header file for the CN0357 wrapper used by the driver diag
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef CN0357_DIAG_H_
-#define CN0357_DIAG_H_
-#include "CN0357.h"
-
-class CN0357_Diag
-{
-public:
- CN0357_Diag(CN0357& cn);
-
- void set_RDAC(void);
- void read_ppm(void);
- void set_sensor_param(void);
-
-
-private:
- CN0357& dut;
-};
-
-
-#endif /* CN0357_DIAG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD5270/AD5270.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,283 @@
+/**
+* @file AD5270.cpp
+* @brief Source file for AD5270 rheostat
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad5270
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+
+#include "mbed.h"
+#include "AD5270.h"
+
+/**
+ * @brief AD5270 constructor, sets CS pin and SPI format
+ * @param CS - (optional)chip select of the AD5270
+ * @param max_resistance - (optional) nominal resistance of the AD5270 chip in ohms
+ * @param MOSI - (optional)pin of the SPI interface
+ * @param MISO - (optional)pin of the SPI interface
+ * @param SCK - (optional)pin of the SPI interface
+ */
+AD5270::AD5270(PinName CS, float max_resistance, PinName MOSI, PinName MISO, PinName SCK):
+ ad5270(MOSI, MISO, SCK), cs(CS), _max_resistance(max_resistance)
+{
+ cs = true;
+ ad5270.format(8, _SPI_MODE);
+}
+
+/**
+ * @brief Compute for the nearest RDAC value from given resistance
+ * @param resistance - resistor
+ * @return RDAC value - closest possible to given resistance
+ */
+uint16_t AD5270::calc_RDAC(float resistance)
+{
+ return static_cast<uint16_t>( (resistance / _max_resistance) * 1024.0 );
+}
+
+/**
+ * @brief sets a new value for the RDAC
+ * @param resistance new value for the resistance
+ * @return actual value of the resistance in the RDAC
+ */
+float AD5270::write_RDAC(float resistance)
+{
+ // Compute for the RDAC code nearest to the required feedback resistance
+ uint16_t RDAC_val = calc_RDAC(resistance);
+ float RDAC_Value = ((static_cast<float> (RDAC_val) * _max_resistance) / 1024.0); // inverse operation to get actual resistance in the RDAC
+ write_wiper_reg(RDAC_val);
+ return RDAC_Value;
+}
+
+/**
+ * Reads the RDAC register
+ * @return RDAC resistor value
+ */
+float AD5270::read_RDAC()
+{
+ uint16_t RDAC_val = read_wiper_reg();
+ return ((static_cast<float> (RDAC_val) * _max_resistance) / 1024.0);
+}
+
+/**
+ * @brief Puts the AD5270 SDO line in to Hi-Z mode
+ * @return none
+ */
+void AD5270::set_SDO_HiZ(void)
+{
+ write_reg(HI_Z_Cmd);
+ wait_us(2);
+ write_reg(NO_OP_cmd);
+}
+
+/**
+ * @brief Set AD5270 SPI frequency
+ * @param hz - SPI bus frequency in hz
+ * @return none
+ */
+void AD5270::frequency(int hz)
+{
+ ad5270.frequency(hz);
+}
+
+/**
+ * @brief Issues AD5270 a command
+ * @param command - command to be sent
+ * @param data - (optional)value for the requested command
+ * @return response form the AD5270
+ */
+uint16_t AD5270::write_cmd(uint8_t command, uint16_t data)
+{
+ /* build 16 bit data to be written - Command + Value */
+ uint16_t ui16Command = ((command & 0x3C) << 8) | (data & 0x3FF);
+ return write_reg(ui16Command);
+}
+
+/**
+ * Enables the 50TP memory programming
+ */
+void AD5270::enable_50TP_programming()
+{
+ uint8_t regVal = read_ctrl_reg();
+ write_cmd(WRITE_CTRL_REG, regVal | PROGRAM_50TP_ENABLE); // RDAC register write protect - allow update of wiper position through digital interface
+}
+
+/**
+ * Stores current RDAC content to the 50TP memory
+ */
+void AD5270::store_50TP()
+{
+ write_cmd(STORE_50TP);
+ wait_ms(_WRITE_OPERATION_50TP_TIMEOUT);
+}
+
+/**
+ * Disables the 50TP memory programming
+ */
+void AD5270::disable_50TP_programming()
+{
+ uint8_t regVal = read_ctrl_reg();
+ write_cmd(WRITE_CTRL_REG, regVal & (~PROGRAM_50TP_ENABLE));
+}
+
+/**
+ * @brief Writes 16bit data to the AD5270 SPI interface
+ * @param data to be written
+ * @return data returned by the AD5270
+ */
+uint16_t AD5270::write_reg(uint16_t data)
+{
+ uint16_t result;
+ uint8_t upper_byte = (data >> 8) & 0xFF;
+ uint8_t lower_byte = data & 0xFF;
+ ad5270.format(8, _SPI_MODE);
+ cs = false;
+ result = ((ad5270.write(upper_byte)) << 8);
+ result |= ad5270.write(lower_byte);
+ cs = true;
+ return result;
+}
+
+/**
+ * @brief Gets maximum resistance of the AD5270 digital rheostat
+ * @return maximum resistance in ohms
+ */
+float AD5270::get_max_resistance()
+{
+ return _max_resistance;
+}
+
+/**
+ * Writes the wiper register. This includes reading the control register,
+ * setting write protect off, writing the wiper, and reverting the settings
+ * to the control reg.
+ * @param data to be written
+ */
+void AD5270::write_wiper_reg(uint16_t data)
+{
+ uint8_t reg_val = read_ctrl_reg();
+ write_cmd(WRITE_CTRL_REG, reg_val | RDAC_WRITE_PROTECT); // RDAC register write protect - allow update of wiper position through digital interface
+ write_cmd(WRITE_RDAC, data); // write data to the RDAC register
+ write_cmd(WRITE_CTRL_REG, reg_val); // RDAC register write protect - allow update of wiper position through digital interface
+}
+
+/**
+ * Reads the wiper register value
+ * @return value of the wiper register
+ */
+uint16_t AD5270::read_wiper_reg(void)
+{
+ uint16_t RDAC_val;
+ write_cmd(READ_RDAC);
+ wait_us(_REG_OPERATION_TIMEOUT);
+ RDAC_val = write_cmd(NO_OP);
+ return RDAC_val;
+}
+
+/**
+ * Reads the last programmed value of the 50TP memory
+ * @return last programmed value
+ */
+uint8_t AD5270::read_50TP_last_address(void)
+{
+ uint8_t ret_val;
+ write_cmd(READ_50TP_ADDRESS);
+ wait_us(_MEMORY_OPERATION_TIMEOUT);
+ ret_val = write_cmd(NO_OP);
+ return ret_val;
+}
+
+/**
+ * Reads the content of a 50TP memory address
+ * @param address memory to be read
+ * @return value stored in the 50TP address
+ */
+uint16_t AD5270::read_50TP_memory(uint8_t address)
+{
+ uint16_t ret_val;
+ write_cmd(READ_50TP_CONTENTS, address);
+ wait_us(_MEMORY_OPERATION_TIMEOUT);
+ ret_val = write_cmd(NO_OP);
+ return ret_val;
+}
+
+/**
+ * Writes the control register
+ * @param data to be written
+ */
+void AD5270::write_ctrl_reg(uint8_t data)
+{
+ write_cmd(WRITE_CTRL_REG, data);
+}
+
+/**
+ * Reads the control register
+ * @return value of the control register
+ */
+uint8_t AD5270::read_ctrl_reg(void)
+{
+ uint8_t ret_val;
+ write_cmd(READ_CTRL_REG);
+ wait_us(_REG_OPERATION_TIMEOUT);
+ ret_val = write_cmd(NO_OP);
+ return ret_val;
+}
+
+/**
+ * Resets the wiper register value to the data last written in the 50TP
+ */
+void AD5270::reset_RDAC(void)
+{
+ write_cmd(SW_RST);
+}
+
+/**
+ * Changes the device mode, enabled or shutdown
+ * @param mode - new mode of the device
+ */
+void AD5270::change_mode(AD5270Modes_t mode)
+{
+ write_cmd(SW_SHUTDOWN, static_cast<uint8_t>(mode));
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD5270/AD5270.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,136 @@
+/**
+* @file AD5270.h
+* @brief Header file for AD5270 rheostat
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad5270
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef AD5270_H
+#define AD5270_H
+
+#include "mbed.h"
+
+/**
+ * @brief Analog Devices AD5270 SPI Digital Rheostat class
+ */
+class AD5270
+{
+public:
+
+ /// AD5270 commands
+ typedef enum {
+ NO_OP = 0x00, ///< No data
+ NO_OP_cmd = 0x0000, ///< 16 bit no data
+ WRITE_RDAC = 0x04, ///< Write to the RDAC Register
+ READ_RDAC = 0x08, ///< Read from the RDAC Register
+ STORE_50TP = 0x0C, ///< Write from RDAC to memory
+ SW_RST = 0x10, ///< Software reset to last memory location
+ READ_50TP_CONTENTS = 0x14, ///< Read the last memory contents
+ READ_50TP_ADDRESS = 0x18, ///< Read the last memory address
+ WRITE_CTRL_REG = 0x1C, ///< Write to the control Register
+ READ_CTRL_REG = 0x20, ///< Read from the control Register
+ SW_SHUTDOWN = 0x24, ///< Software shutdown (0) - Normal, (1) - Shutdown
+ HI_Zupper = 0x80, ///< Get the SDO line ready for High Z
+ HI_Zlower = 0x01, ///< Puts AD5270 into High Z mode
+ HI_Z_Cmd = 0x8001 ///< Puts AD5270 into High Z mode*/
+ } AD5270Commands_t;
+
+ typedef enum {
+ NORMAL_MODE = 0,
+ SHUTDOWN_MODE = 1
+ } AD5270Modes_t;
+
+ typedef enum {
+ PROGRAM_50TP_ENABLE = 1,
+ RDAC_WRITE_PROTECT = 2,
+ R_PERFORMANCE_ENABLE = 4,
+ MEMORY_PROGRAM_SUCCESFUL = 8
+ } AD5270ControlRegisterBits_t;
+
+ // SPI configuration & constructor
+ AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
+ void frequency(int hz);
+
+ /* RDAC commands */
+ void write_ctrl_reg(uint8_t data);
+ uint8_t read_ctrl_reg(void);
+ void change_mode(AD5270Modes_t mode);
+ void set_SDO_HiZ(void);
+
+ /* Wiper R/W methods*/
+ void reset_RDAC(void);
+ void write_wiper_reg(uint16_t data);
+ uint16_t read_wiper_reg(void);
+
+
+ /* Low level methods */
+ uint16_t write_cmd(uint8_t command, uint16_t data = 0x00);
+ uint16_t write_reg(uint16_t data);
+
+ /* Methods that deal with resistance in float format*/
+ uint16_t calc_RDAC(float resistance);
+ float write_RDAC(float resistance);
+ float read_RDAC(void);
+ float get_max_resistance(void);
+
+ /* 50 TP methods */
+ void enable_50TP_programming(void);
+ void store_50TP(void);
+ void disable_50TP_programming(void);
+ uint8_t read_50TP_last_address(void);
+ uint16_t read_50TP_memory(uint8_t address);
+
+ SPI ad5270; ///< SPI instance of the AD5270
+ DigitalOut cs; ///< DigitalOut instance for the chip select of the AD5270
+
+private:
+ const static int _RESET = 0xff;
+ const static int _REG_OPERATION_TIMEOUT = 2;
+ const static int _MEMORY_OPERATION_TIMEOUT = 6;
+ const static int _WRITE_OPERATION_50TP_TIMEOUT = 350;
+ const static int _DUMMY_BYTE = 0xAA;
+ const static uint8_t _SPI_MODE = 1;
+ float _max_resistance;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD7790/AD7790.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,399 @@
+/**
+* @file AD7790.cpp
+* @brief Source file for AD7790 ADC
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad7790
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include <stdint.h>
+#include "mbed.h"
+#include "AD7790.h"
+
+/**
+ * @brief AD7790 constructor, sets CS pin and SPI format
+ * @param CS - (optional)chip select of the AD7790
+ * @param MOSI - (optional)pin of the SPI interface
+ * @param MISO - (optional)pin of the SPI interface
+ * @param SCK - (optional)pin of the SPI interface
+ */
+AD7790::AD7790(float reference_voltage,
+ PinName CS,
+ PinName MOSI,
+ PinName MISO,
+ PinName SCK) :
+ miso(MISO), ad7790(MOSI, MISO, SCK), cs(CS), _vref(reference_voltage), _PGA_gain(1)
+{
+ cs = true; // cs is active low
+ ad7790.format(8, _SPI_MODE);
+ _continous_conversion = true;
+ _channel = DIFFERENTIAL;
+}
+
+/**
+ * @brief Set AD7790 SPI frequency
+ * @param hz - SPI bus frequency in hz
+ * @return none
+ */
+void AD7790::frequency(int hz)
+{
+ ad7790.frequency(hz);
+}
+
+/**
+ * @brief Resets the AD7790
+ * @return none
+ */
+void AD7790::reset()
+{
+ ad7790.format(8, _SPI_MODE);
+ cs = false;
+ wait_us(_DELAY_TIMING);
+ ad7790.write(_RESET);
+ ad7790.write(_RESET);
+ ad7790.write(_RESET);
+ ad7790.write(_RESET);
+ wait_us(_DELAY_TIMING);
+ cs = true;
+ _continous_conversion = true;
+}
+
+/**
+ * Sets the mode register. Also sets continous mode and range based on the value
+ * written in reg_val
+ * @param reg_val
+ */
+void AD7790::write_mode_reg(uint8_t reg_val)
+{
+ write_reg(MODE_REG, reg_val);
+ uint8_t continous_mode = (reg_val & 0xC0);
+ if(continous_mode == 0x00) {
+ _continous_conversion = true;
+ } else {
+ _continous_conversion = false;
+ }
+ uint8_t range = (reg_val & 0x30);
+ _PGA_gain = 1 << (range >> 4);
+}
+
+/**
+ * Reads the mode register and returns its value
+ * @return value of the mode register
+ */
+uint8_t AD7790::read_mode_reg()
+{
+ return read_reg(MODE_REG);
+}
+
+/**
+ * Writes the filter register
+ * @param regValue value to be written.
+ */
+void AD7790::write_filter_reg(uint8_t reg_val)
+{
+ write_reg(FILTER_REG, reg_val);
+}
+
+/**
+ * Reads the filter register and returns its value
+ * @return the value of the filter register
+ */
+uint8_t AD7790::read_filter_reg()
+{
+ return read_reg(FILTER_REG);
+}
+
+/**
+ * Reads the data register and returns its value
+ * @return value of the data register
+ */
+uint16_t AD7790::read_data_reg()
+{
+ uint16_t data_result;
+ ad7790.format(8, _SPI_MODE);
+ cs = false;
+ ad7790.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
+ data_result = ((ad7790.write(_DUMMY_BYTE)) << 8);
+ data_result |= (ad7790.write(_DUMMY_BYTE));
+ cs = true;
+ return data_result;
+}
+
+/**
+ * Reads the status register of the ADC and returns its value
+ * @return value of the status reg
+ */
+uint8_t AD7790::read_status_reg()
+{
+ return read_reg(STATUS_REG);
+}
+
+
+/**
+ * @brief Enables/disables continous_conversion mode
+ * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
+ * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
+ * When the pin is driven low, data register is read back from the ADC.
+ *
+ * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
+ * the data register is read back from the ADC.
+ *
+ * @param mode
+ * true - continous conversion mode enabled
+ * false - single conversion mode enabled
+ */
+void AD7790::set_conversion_mode(AD7790Mode_t mode)
+{
+ uint8_t mode_reg_val;
+ mode_reg_val = read_mode_reg() & 0x3F;
+ mode_reg_val = mode_reg_val | (static_cast<uint8_t>(mode));
+ write_mode_reg(mode);
+}
+
+/**
+ * - From mbed AnalogIn API -
+ * @brief Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
+ * Depending on the conversion mode, this method will have different behavior. Conversion mode is set using
+ * set_continous_conversion_mode(bool).
+ *
+ * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
+ * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
+ * When the pin is driven low, data register is read back from the ADC.
+ *
+ * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
+ * the data register is read back from the ADC.
+ *
+ * @return 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
+ * returns -1 (0xFFFF) along with a debug message if conversion failed.
+ */
+uint16_t AD7790::read_u16(void)
+{
+ uint16_t data_result = 0;
+ ad7790.format(8, _SPI_MODE);
+ cs = false;
+ uint16_t timeout_cnt = 0;
+ if(_continous_conversion == false) {
+
+ uint8_t mode_reg = read_mode_reg();
+ wait_us(_DELAY_TIMING);
+
+ cs = false;
+ mode_reg = (mode_reg & 0x3F) | MD1; // mask single conversion bits
+ ad7790.write((MODE_REG << 4) | (static_cast<uint8_t>(_channel))); // start single conversion
+ ad7790.write(mode_reg);
+ timeout_cnt = _SINGLE_CONVERSION_TIMEOUT; // starts timeout
+ } else {
+ timeout_cnt = _CONTINOUS_CONVERSION_TIMEOUT; // starts timeout
+ }
+ wait_us(1);
+
+ while(miso) { // wait for the MISO pin to go low.
+ if(timeout_cnt) {
+ timeout_cnt--;
+ } else {
+ cs = true;
+#ifdef AD7790_DEBUG_MODE
+ printf("timeout occurred reading the AD7790. "); // error, MISO line didn't toggle
+#endif
+ return -1; // ERROR
+ }
+ wait_us(10);
+ }
+
+ ad7790.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
+ data_result = ((ad7790.write(_DUMMY_BYTE)) << 8);
+ data_result |= (ad7790.write(_DUMMY_BYTE));
+ cs = true;
+ return data_result;
+}
+
+/**
+ * @brief Reads a register of the AD7790
+ * @param address - address of the register
+ * @return value of the register
+ */
+uint16_t AD7790::read_reg(AD7790Register_t address)
+{
+ uint16_t data = address << 12;
+ data |= _DUMMY_BYTE;
+ data |= _READ_FLAG;
+ data |= (static_cast<uint8_t>(_channel) << 8);
+ return write_spi(data);
+}
+
+/**
+ * @brief Writes a register of the AD7790
+ * @param address - address of the register
+ * @param reg_val - value to be written
+ * @return none
+ *
+ */
+void AD7790::write_reg(AD7790Register_t address, uint8_t reg_val)
+{
+ uint16_t spi_data = address << 12;
+ spi_data |= reg_val;
+ spi_data |= (static_cast<uint8_t>(_channel) << 8);
+ write_spi(spi_data);
+}
+
+/**
+ * @brief Writes 16bit data to the AD7790 SPI interface
+ * @param reg_val to be written
+ * @return data returned by the AD7790
+ */
+uint16_t AD7790::write_spi(uint16_t reg_val)
+{
+ uint16_t data_result;
+ uint8_t upper_byte = (reg_val >> 8) & 0xFF;
+ uint8_t lower_byte = reg_val & 0xFF;
+ ad7790.format(8, _SPI_MODE);
+ cs = false;
+ data_result = (ad7790.write(upper_byte) << 8);
+ data_result |= ad7790.write(lower_byte);
+ cs = true;
+ return data_result;
+}
+
+
+/**
+ * Sets the AnalogInputRange to be used by the AD7790
+ * @param range AnalogInputRange_t to be used in voltage computations
+ */
+void AD7790::set_range(AnalogInputRange_t range)
+{
+
+ uint8_t mode_reg_val;
+ mode_reg_val = read_mode_reg() & 0xCF;
+ mode_reg_val = mode_reg_val | (range << 4);
+ write_mode_reg(mode_reg_val);
+}
+
+/**
+ * Sets the reference voltage of the AD7790
+ * @param ref reference voltage to be set
+ */
+void AD7790::set_reference_voltage(float ref)
+{
+ _vref = ref;
+}
+
+/**
+ * Gets the reference voltage of the AD7790
+ * @return reference voltage
+ */
+float AD7790::get_reference_voltage(void)
+{
+ return _vref;
+}
+
+/**
+ * Reads the data register of the ADC and converts the result to volts
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @return voltage of the ADC input
+ */
+float AD7790::read_voltage(void)
+{
+ return data_to_voltage(read_u16());
+}
+
+/**
+ * Converts an uint16_t to voltage.
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @param data in uint16_t format
+ * @return float value of voltage (in V)
+ */
+float AD7790::data_to_voltage(uint16_t data)
+{
+ return ((data / static_cast<float>(_RESOLUTION / 2)) - 1) * (_vref / _PGA_gain);
+}
+
+/**
+ * Converts voltage to an uint16_t.
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @param voltage to be converted
+ * @return data in uint16_t format
+ */
+uint16_t AD7790::voltage_to_data(float voltage)
+{
+ return (((voltage * _PGA_gain / _vref) + 1) * static_cast<float>(_RESOLUTION / 2));
+}
+
+/**
+ * Sets the conversion channel.
+ * @param channel
+ */
+void AD7790::set_channel(AD7790Channel_t channel)
+{
+ _channel = channel;
+}
+
+/**
+ * - From mbed AnalogIn API -
+ * Read the input voltage, represented as a float in the range [0.0, 1.0] - uses the read_u16 method
+ * @returns A floating-point value representing the current input voltage, measured as a percentage
+ * returns 1.0 along with a debug message if the conversion failed
+ */
+float AD7790::read(void)
+{
+ float percent;
+ uint16_t data;
+ data = read_u16();
+ percent = (data / static_cast<float>(_RESOLUTION) ); // translate bipolar conversion to [0.0, 1.0] domain
+ return percent;
+}
+
+#ifdef MBED_OPERATORS
+
+/**
+ * - From mbed AnalogIn API -
+ * An operator shorthand for read()
+ * The float() operator can be used as a shorthand for read() to simplify common code sequences
+ */
+AD7790::operator float()
+{
+ return read();
+}
+
+#endif
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD7790/AD7790.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,174 @@
+/**
+* @file AD7790.h
+* @brief Header file for AD7790 ADC
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad7790
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef AD7790_H
+#define AD7790_H
+
+#include "mbed.h"
+
+/**
+ * Comment this line if you want to turn off the debug mode.
+ * The debug mode will send a message if an exception occurs within AD7790 driver
+ */
+
+#define AD7790_DEBUG_MODE
+
+/**
+ * @brief Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC
+ */
+class AD7790
+{
+public:
+ /// AD7790 registers
+ typedef enum {
+ COMMUNICATION_REG = 0, ///< Communication register
+ STATUS_REG = 0, ///< Status register
+ MODE_REG, ///< Mode register
+ FILTER_REG, ///< Filter Register
+ DATA_REG ///< Data register
+ } AD7790Register_t;
+
+ /// AD7790 channel configuration
+ typedef enum {
+ DIFFERENTIAL = 0, ///< AIN(+)-AIN(-)
+ RESERVED, ///< reserved
+ SHORT, ///< AIN(-)-AIN(-)
+ VDDMONITOR ///< Monitor VDD
+ } AD7790Channel_t;
+
+ typedef enum {
+ CONTINOUS_CONVERSION_MODE = 0,
+ SINGLE_CONVERSION_MODE = 0x80,
+ SHUTDOWN_MODE = 0xC0
+ } AD7790Mode_t;
+
+ typedef enum {
+ MD1 = 0x80, ///< Mode Select Bit 1
+ MD0 = 0x40, ///< Mode Select Bit 0
+ G1 = 0x20, ///< Range bit 1
+ G0 = 0x10, ///< Range bit 0
+ BO = 0x08, ///< Burnout Current Enable bit
+ BUF = 0x02, ///< Buffered mode bit
+ } ModeRegisterBits_t;
+
+ typedef enum {
+ CLKDIV1 = 0x40, ///< Clock divider bit 1
+ CLKDIV0 = 0x20, ///< Clock divider bit 0
+ FS2 = 0x04, ///< Update rate bit 2
+ FS1 = 0x02, ///< Update rate bit 1
+ FS0 = 0x01, ///< Update rate bit 0
+ } FilterRegisterBits_t;
+
+ typedef enum {
+ RANGE_VREF = 0,
+ RANGE_VREF_DIV_2,
+ RANGE_VREF_DIV_4,
+ RANGE_VREF_DIV_8,
+ } AnalogInputRange_t;
+
+ /** SPI configuration & constructor */
+ AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
+ void frequency(int hz);
+
+ /** Low level SPI bus comm methods */
+ void reset(void);
+
+ /** Register access methods*/
+ void set_channel(AD7790Channel_t channel);
+ void set_conversion_mode(AD7790Mode_t mode);
+ uint16_t read_data_reg();
+ uint8_t read_status_reg(void);
+ void write_filter_reg(uint8_t regVal);
+ uint8_t read_filter_reg(void);
+ void write_mode_reg(uint8_t regVal);
+ uint8_t read_mode_reg(void);
+ void set_range(AnalogInputRange_t range);
+ AnalogInputRange_t get_range(void);
+
+ /** Reference voltage methods */
+ void set_reference_voltage(float ref);
+ float get_reference_voltage(void);
+
+ /** Voltage read methods */
+ float read_voltage(void);
+ float data_to_voltage(uint16_t data);
+ uint16_t voltage_to_data(float voltage);
+
+ /** AnalogIn API */
+ float read(void);
+ uint16_t read_u16(void);
+
+#ifdef MBED_OPERATORS
+ operator float();
+#endif
+
+private:
+ DigitalIn miso;///< DigitalIn must be initialized before SPI to prevent pin MUX overwrite
+ SPI ad7790; ///< SPI instance of the AD7790
+ DigitalOut cs; ///< DigitalOut instance for the chipselect of the AD7790
+
+ float _vref;
+ uint8_t _PGA_gain;
+ bool _continous_conversion;
+ AD7790Channel_t _channel;
+
+ void write_reg(AD7790Register_t regAddress, uint8_t regValue);
+ uint16_t write_spi(uint16_t data);
+ uint16_t read_reg (AD7790Register_t regAddress);
+
+ const static uint16_t _SINGLE_CONVERSION_TIMEOUT = 0xFFFF; // in 10us = 100ms
+ const static uint16_t _CONTINOUS_CONVERSION_TIMEOUT = 0xFFFF;
+ const static uint16_t _RESOLUTION = 0xFFFF;
+ const static uint8_t _RESET = 0xFF;
+ const static uint8_t _DUMMY_BYTE = 0xFF;
+ const static uint16_t _READ_FLAG = 0x0800;
+ const static uint8_t _DATA_READ = 0x38; // Read from the Data Register
+ const static uint8_t _DELAY_TIMING = 0x02;
+ const static uint8_t _SPI_MODE = 3;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD7791/AD7791.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,395 @@
+/**
+* @file AD7791.cpp
+* @brief Source file for AD7791 ADC
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad7791
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include <stdint.h>
+#include "mbed.h"
+#include "AD7791.h"
+
+/**
+ * @brief AD7791 constructor, sets CS pin and SPI format
+ * @param reference_voltage - the reference voltage to be used in computation
+ * @param CS - (optional)chip select of the AD7791
+ * @param MOSI - (optional)pin of the SPI interface
+ * @param MISO - (optional)pin of the SPI interface
+ * @param SCK - (optional)pin of the SPI interface
+ */
+AD7791::AD7791(float reference_voltage,
+ PinName CS,
+ PinName MOSI,
+ PinName MISO,
+ PinName SCK) :
+ miso(MISO), ad7791(MOSI, MISO, SCK), cs(CS), _vref(reference_voltage)
+{
+ cs = true; // cs is active low
+ ad7791.format(8, _SPI_MODE);
+ _continous_conversion = true;
+ _channel = DIFFERENTIAL;
+}
+
+/**
+ * @brief Set AD7791 SPI frequency
+ * @param hz - SPI bus frequency in hz
+ * @return none
+ */
+void AD7791::frequency(int hz)
+{
+ ad7791.frequency(hz);
+}
+
+/**
+ * @brief Resets the AD7791
+ * @return none
+ */
+void AD7791::reset()
+{
+ ad7791.format(8, _SPI_MODE);
+ cs = false;
+ wait_us(_DELAY_TIMING);
+ ad7791.write(_RESET);
+ ad7791.write(_RESET);
+ ad7791.write(_RESET);
+ ad7791.write(_RESET);
+ wait_us(_DELAY_TIMING);
+ cs = true;
+ _continous_conversion = true;
+}
+
+/**
+ * Sets the mode register. Also sets continous mode and range based on the value
+ * written in reg_val
+ * @param reg_val
+ */
+void AD7791::write_mode_reg(uint8_t reg_val)
+{
+ write_reg(MODE_REG, reg_val);
+ uint8_t continous_mode = (reg_val & 0xC0);
+ if(continous_mode == 0x00) {
+ _continous_conversion = true;
+ } else {
+ _continous_conversion = false;
+ }
+ /* uint8_t range = (reg_val & 0x30);
+ _PGA_gain = 1 << (range >> 4);*/
+
+}
+
+/**
+ * Reads the mode register and returns its value
+ * @return value of the mode register
+ */
+uint8_t AD7791::read_mode_reg()
+{
+ return read_reg(MODE_REG);
+}
+
+/**
+ * Writes the filter register
+ * @param regValue value to be written.
+ */
+void AD7791::write_filter_reg(uint8_t reg_val)
+{
+ write_reg(FILTER_REG, reg_val);
+}
+
+/**
+ * Reads the filter register and returns its value
+ * @return the value of the filter register
+ */
+uint8_t AD7791::read_filter_reg()
+{
+ return read_reg(FILTER_REG);
+}
+
+/**
+ * Reads the data register and returns its value
+ * @return value of the data register
+ */
+uint32_t AD7791::read_data_reg()
+{
+ uint32_t data_result;
+ ad7791.format(8, _SPI_MODE);
+ cs = false;
+ ad7791.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
+ data_result = ((ad7791.write(_DUMMY_BYTE)) << 16);
+ data_result |= ((ad7791.write(_DUMMY_BYTE)) << 8 );
+ data_result |= (ad7791.write(_DUMMY_BYTE));
+ cs = true;
+ return data_result;
+}
+
+/**
+ * Reads the status register of the ADC and returns its value
+ * @return value of the status reg
+ */
+uint8_t AD7791::read_status_reg()
+{
+ return read_reg(STATUS_REG);
+}
+
+
+/**
+ * @brief Enables/disables continous_conversion mode
+ * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
+ * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
+ * When the pin is driven low, data register is read back from the ADC.
+ *
+ * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
+ * the data register is read back from the ADC.
+ *
+ * @param mode
+ * true - continous conversion mode enabled
+ * false - single conversion mode enabled
+ */
+void AD7791::set_conversion_mode(AD7791Mode_t mode)
+{
+ uint8_t mode_reg_val;
+ mode_reg_val = read_mode_reg() & 0x3F;
+ mode_reg_val = mode_reg_val | (static_cast<uint8_t>(mode));
+ write_mode_reg(mode);
+}
+
+/**
+ * - From mbed AnalogIn API -
+ * @brief Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
+ * Depending on the conversion mode, this method will have different behavior. Conversion mode is set using
+ * set_continous_conversion_mode(bool).
+ *
+ * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
+ * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
+ * When the pin is driven low, data register is read back from the ADC.
+ *
+ * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
+ * the data register is read back from the ADC.
+ *
+ * @return 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
+ * returns -1 (0xFFFF) along with a debug message if conversion failed.
+ */
+uint32_t AD7791::read_u32(void)
+{
+ uint32_t data_result = 0;
+ ad7791.format(8, _SPI_MODE);
+ cs = false;
+ uint16_t timeout_cnt = 0;
+ if(_continous_conversion == false) {
+
+ uint8_t mode_reg = read_mode_reg();
+ wait_us(_DELAY_TIMING);
+
+ cs = false;
+ mode_reg = (mode_reg & 0x3F) | MD1; // mask single conversion bits
+ ad7791.write((MODE_REG << 4) | (static_cast<uint8_t>(_channel))); // start single conversion
+ ad7791.write(mode_reg);
+ timeout_cnt = _SINGLE_CONVERSION_TIMEOUT; // starts timeout
+ } else {
+ timeout_cnt = _CONTINOUS_CONVERSION_TIMEOUT; // starts timeout
+ }
+ wait_us(1);
+
+ while(miso) { // wait for the MISO pin to go low.
+ if(timeout_cnt) {
+ timeout_cnt--;
+ } else {
+ cs = true;
+#ifdef AD7791_DEBUG_MODE
+ printf("timeout occurred reading the AD7791. "); // error, MISO line didn't toggle
+#endif
+ return -1; // ERROR
+ }
+ wait_us(10);
+ }
+
+ ad7791.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
+ data_result = ((ad7791.write(_DUMMY_BYTE)) << 16);
+ data_result |= ((ad7791.write(_DUMMY_BYTE)) << 8 );
+ data_result |= (ad7791.write(_DUMMY_BYTE));
+ cs = true;
+ return data_result;
+}
+
+uint16_t AD7791::read_u16(void)
+{
+ uint32_t data = read_u32();
+ return static_cast<uint16_t>((data & 0xffff00) >> 8);
+}
+
+/**
+ * @brief Reads a register of the AD7791
+ * @param address - address of the register
+ * @return value of the register
+ */
+uint16_t AD7791::read_reg(AD7791Register_t address)
+{
+ uint16_t data = address << 12;
+ data |= _DUMMY_BYTE;
+ data |= _READ_FLAG;
+ data |= (static_cast<uint8_t>(_channel) << 8);
+ return write_spi(data);
+}
+
+/**
+ * @brief Writes a register of the AD7791
+ * @param address - address of the register
+ * @param reg_val - value to be written
+ * @return none
+ *
+ */
+void AD7791::write_reg(AD7791Register_t address, uint8_t reg_val)
+{
+ uint16_t spi_data = address << 12;
+ spi_data |= reg_val;
+ spi_data |= (static_cast<uint8_t>(_channel) << 8);
+ write_spi(spi_data);
+}
+
+/**
+ * @brief Writes 16bit data to the AD7791 SPI interface
+ * @param reg_val to be written
+ * @return data returned by the AD7791
+ */
+uint16_t AD7791::write_spi(uint16_t reg_val)
+{
+ uint16_t data_result;
+ uint8_t upper_byte = (reg_val >> 8) & 0xFF;
+ uint8_t lower_byte = reg_val & 0xFF;
+ ad7791.format(8, _SPI_MODE);
+ cs = false;
+ data_result = (ad7791.write(upper_byte) << 8);
+ data_result |= ad7791.write(lower_byte);
+ cs = true;
+ return data_result;
+}
+
+/**
+ * Sets the reference voltage of the AD7790
+ * @param ref reference voltage to be set
+ */
+void AD7791::set_reference_voltage(float ref)
+{
+ _vref = ref;
+}
+
+/**
+ * Gets the reference voltage of the AD7790
+ * @return reference voltage
+ */
+float AD7791::get_reference_voltage(void)
+{
+ return _vref;
+}
+
+/**
+ * Reads the data register of the ADC and converts the result to volts
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @return voltage of the ADC input
+ */
+float AD7791::read_voltage(void)
+{
+ return data_to_voltage(read_u32());
+}
+
+/**
+ * Converts an uint16_t to voltage.
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @param data in uint16_t format
+ * @return float value of voltage (in V)
+ */
+float AD7791::data_to_voltage(uint32_t data)
+{
+ return ((data / static_cast<float>(_RESOLUTION / 2)) - 1) * (_vref );
+}
+
+/**
+ * Converts voltage to an uint16_t.
+ * Gain needs to be correctly set using set_gain in order to get accurate results
+ * @param voltage to be converted
+ * @return data in uint16_t format
+ */
+uint32_t AD7791::voltage_to_data(float voltage)
+{
+ return (((voltage / _vref) + 1) * static_cast<float>(_RESOLUTION / 2));
+}
+
+/**
+ * Sets the conversion channel.
+ * @param channel
+ */
+void AD7791::set_channel(AD7791Channel_t channel)
+{
+ _channel = channel;
+}
+
+/**
+ * - From mbed AnalogIn API -
+ * Read the input voltage, represented as a float in the range [0.0, 1.0] - uses the read_u16 method
+ * @returns A floating-point value representing the current input voltage, measured as a percentage
+ * returns 1.0 along with a debug message if the conversion failed
+ */
+float AD7791::read(void)
+{
+ float percent;
+ uint32_t data;
+ data = read_u32();
+ percent = (data / static_cast<float>(_RESOLUTION) ); // translate bipolar conversion to [0.0, 1.0] domain
+ return percent;
+}
+
+#ifdef MBED_OPERATORS
+
+/**
+ * - From mbed AnalogIn API -
+ * An operator shorthand for read()
+ * The float() operator can be used as a shorthand for read() to simplify common code sequences
+ */
+AD7791::operator float()
+{
+ return read();
+}
+
+#endif
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/AD7791/AD7791.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,176 @@
+/**
+* @file AD7791.h
+* @brief Header file for AD7791 ADC
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/ad7791
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef AD7791_H
+#define AD7791_H
+
+#include "mbed.h"
+
+/**
+ * Comment this line if you want to turn off the debug mode.
+ * The debug mode will send a message if an exception occurs within AD7791 driver
+ */
+
+#define AD7791_DEBUG_MODE
+
+/**
+ * @brief Analog Devices AD7791 SPI 16-bit Buffered Sigma-Delta ADC
+ */
+class AD7791
+{
+public:
+ /// AD7791 registers
+ typedef enum {
+ COMMUNICATION_REG = 0, ///< Communication register
+ STATUS_REG = 0, ///< Status register
+ MODE_REG, ///< Mode register
+ FILTER_REG, ///< Filter Register
+ DATA_REG ///< Data register
+ } AD7791Register_t;
+
+ /// AD7791 channel configuration
+ typedef enum {
+ DIFFERENTIAL = 0, ///< AIN(+)-AIN(-)
+ RESERVED, ///< reserved
+ SHORT, ///< AIN(-)-AIN(-)
+ VDDMONITOR ///< Monitor VDD
+ } AD7791Channel_t;
+
+ typedef enum {
+ CONTINOUS_CONVERSION_MODE = 0,
+ SINGLE_CONVERSION_MODE = 0x80,
+ SHUTDOWN_MODE = 0xC0
+ } AD7791Mode_t;
+
+ typedef enum {
+ MD1 = 0x80, ///< Mode Select Bit 1
+ MD0 = 0x40, ///< Mode Select Bit 0
+// G1 = 0x20, ///< Range bit 1
+// G0 = 0x10, ///< Range bit 0
+ BO = 0x08, ///< Burnout Current Enable bit
+ UB = 0x04, ///< Unipolar/Bipolar bit
+ BUF = 0x02, ///< Buffered mode bit
+ } ModeRegisterBits_t;
+
+ typedef enum {
+ CLKDIV1 = 0x40, ///< Clock divider bit 1
+ CLKDIV0 = 0x20, ///< Clock divider bit 0
+ FS2 = 0x04, ///< Update rate bit 2
+ FS1 = 0x02, ///< Update rate bit 1
+ FS0 = 0x01, ///< Update rate bit 0
+ } FilterRegisterBits_t;
+
+ /* typedef enum {
+ RANGE_VREF = 0,
+ RANGE_VREF_DIV_2,
+ RANGE_VREF_DIV_4,
+ RANGE_VREF_DIV_8,
+ } AnalogInputRange_t;
+ */
+ /** SPI configuration & constructor */
+ AD7791( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
+ void frequency(int hz);
+
+ /** Low level SPI bus comm methods */
+ void reset(void);
+
+ /** Register access methods*/
+ void set_channel(AD7791Channel_t channel);
+ void set_conversion_mode(AD7791Mode_t mode);
+ uint32_t read_data_reg();
+ uint8_t read_status_reg(void);
+ void write_filter_reg(uint8_t regVal);
+ uint8_t read_filter_reg(void);
+ void write_mode_reg(uint8_t regVal);
+ uint8_t read_mode_reg(void);
+// void set_range(AnalogInputRange_t range);
+// AnalogInputRange_t get_range(void);
+
+ /** Reference voltage methods */
+ void set_reference_voltage(float ref);
+ float get_reference_voltage(void);
+
+ /** Voltage read methods */
+ float read_voltage(void);
+ float data_to_voltage(uint32_t data);
+ uint32_t voltage_to_data(float voltage);
+
+ /** AnalogIn API */
+ float read(void);
+ uint32_t read_u32(void);
+ uint16_t read_u16(void);
+
+#ifdef MBED_OPERATORS
+ operator float();
+#endif
+
+private:
+ DigitalIn miso;
+ SPI ad7791; ///< SPI instance of the AD7791
+ DigitalOut cs; ///< DigitalOut instance for the chipselect of the AD7791
+
+ float _vref;
+// uint8_t _PGA_gain;
+ bool _continous_conversion;
+ AD7791Channel_t _channel;
+
+ void write_reg(AD7791Register_t regAddress, uint8_t regValue);
+ uint16_t write_spi(uint16_t data);
+ uint16_t read_reg (AD7791Register_t regAddress);
+
+ const static uint16_t _SINGLE_CONVERSION_TIMEOUT = 0xFFFF; // in 10us = 100ms
+ const static uint16_t _CONTINOUS_CONVERSION_TIMEOUT = 0xFFFF;
+ const static uint32_t _RESOLUTION = 0xFFFFFF;
+ const static uint8_t _RESET = 0xFF;
+ const static uint8_t _DUMMY_BYTE = 0xFF;
+ const static uint16_t _READ_FLAG = 0x0800;
+ const static uint8_t _DATA_READ = 0x38; // Read from the Data Register
+ const static uint8_t _DELAY_TIMING = 0x02;
+ const static uint8_t _SPI_MODE = 3;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ADXL362/ADXL362.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,602 @@
+/**
+* @file ADXL362.cpp
+* @brief Source file for ADXL362
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/adxl362
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include <stdint.h>
+#include "mbed.h"
+#include "ADXL362.h"
+
+/**
+ * ADXL362 constructor. Sets CS and SPI bus
+ * @param CS - CS pin of the ADXL362
+ * @param MOSI - MOSI pin of the ADXL362
+ * @param MISO - MISO pin of the ADXL362
+ * @param SCK- SCK pin of the ADXL362
+ */
+ADXL362::ADXL362(PinName CS, PinName MOSI, PinName MISO, PinName SCK) :
+ adxl362(MOSI, MISO, SCK), cs(CS), _int1(NULL), _int2(NULL), _int1_poll(NC), _int2_poll(
+ NC)
+{
+ cs = true; // cs is active low
+ adxl362.format(8, _SPI_MODE);
+ _temp_stored_in_fifo = false;
+ _int1_act_low = true;
+ _int2_act_low = true;
+}
+
+/**
+ * Sets ADXL362 SPI bus frequency
+ * @param hz - frequency in hz
+ */
+void ADXL362::frequency(int hz)
+{
+ adxl362.frequency(hz);
+}
+
+/**
+ * Resets the ADXL362
+ * A latency of approximately 0.5 ms is required after soft reset.
+ */
+void ADXL362::reset()
+{
+ adxl362.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(SOFT_RESET, 0x52);
+ cs = true;
+
+}
+
+/**
+ * Writes the reg register with data
+ * @param reg - ADXL362_register_t register to be written
+ * @param data - data to be written
+ */
+void ADXL362::write_reg(ADXL362_register_t reg, uint8_t data)
+{
+ adxl362.format(8, _SPI_MODE);
+ cs = false;
+ adxl362.write(_WRITE_REG_CMD);
+ adxl362.write(static_cast<uint8_t>(reg));
+ adxl362.write(static_cast<uint8_t>(data));
+ cs = true;
+}
+
+/**
+ * Reads the reg register
+ * @param reg - ADXL362_register_t register to be read
+ * @return - data read from the register
+ */
+uint8_t ADXL362::read_reg(ADXL362_register_t reg)
+{
+ uint8_t ret_val;
+ adxl362.format(8, _SPI_MODE);
+ cs = false;
+ adxl362.write(_READ_REG_CMD);
+ adxl362.write(static_cast<uint8_t>(reg));
+ ret_val = adxl362.write(_DUMMY_BYTE);
+ cs = true;
+ return ret_val;
+}
+
+/**
+ * Writes 16 bit registers to the ADXL362. Performs conversion from Intel to Motorola byte order
+ * @param reg - ADXL362_register_t register to be written
+ * @param data - data to be written
+ */
+void ADXL362::write_reg_u16(ADXL362_register_t reg, uint16_t data)
+{
+ adxl362.format(8, _SPI_MODE);
+
+ cs = false;
+ adxl362.write(_WRITE_REG_CMD);
+ adxl362.write(static_cast<uint8_t>(reg));
+ adxl362.write(static_cast<uint8_t>(data & 0xff));
+ adxl362.write(static_cast<uint8_t>((data & 0xff00) >> 8));
+
+ cs = true;
+}
+
+/**
+ * Reads 16 bit registers from the ADXL362. Performs conversion from Motorola to Intel Byte order
+ * @param reg - ADXL362_register_t register to be read
+ * @return - data read from the ADXL362
+ */
+uint16_t ADXL362::read_reg_u16(ADXL362_register_t reg)
+{
+ uint16_t ret_val = 0;
+ adxl362.format(8, _SPI_MODE);
+
+ cs = false;
+ adxl362.write(_READ_REG_CMD);
+ adxl362.write(static_cast<uint8_t>(reg));
+ ret_val = adxl362.write(_DUMMY_BYTE);
+ ret_val = ret_val | (adxl362.write(_DUMMY_BYTE) << 8);
+ cs = true;
+
+ return ret_val;
+}
+
+/**
+ * Scans the X,Y,Z,T registers for data.
+ * ADXL362 needs to be in measurement mode to read data
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return a 64 bit integer with the following format 0xXXYYZZTT
+ */
+uint64_t ADXL362::scan()
+{
+ uint64_t ret_val = 0;
+ uint16_t x, y, z, t = 0;
+
+ adxl362.format(8, _SPI_MODE);
+ cs = false;
+ adxl362.write(_READ_REG_CMD);
+ adxl362.write(static_cast<uint8_t>(XDATA_L));
+
+ x = adxl362.write(_DUMMY_BYTE);
+ x = x | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+ y = adxl362.write(_DUMMY_BYTE);
+ y = y | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+ z = adxl362.write(_DUMMY_BYTE);
+ z = z | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+ t = adxl362.write(_DUMMY_BYTE);
+ t = t | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+
+ ret_val = static_cast<uint64_t>(x) << 48;
+ ret_val |= static_cast<uint64_t>(y) << 32;
+ ret_val |= static_cast<uint64_t>(z) << 16;
+ ret_val |= static_cast<uint64_t>(t);
+ cs = true;
+ return ret_val;
+}
+
+/**
+ * Reads the X 8 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 8 bit X data
+ */
+uint8_t ADXL362::scanx_u8()
+{
+ return read_reg(XDATA);
+}
+
+/**
+ * Reads the X 16 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 16 bit X data
+ */
+uint16_t ADXL362::scanx()
+{
+ return read_reg_u16(XDATA_L);
+}
+
+/**
+ * Reads the Y 8 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 8 bit Y data
+ */
+uint8_t ADXL362::scany_u8()
+{
+ return read_reg(YDATA);
+}
+
+/**
+ * Reads the Y 16 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 16 bit Y data
+ */
+uint16_t ADXL362::scany()
+{
+ return read_reg_u16(YDATA_L);
+}
+
+/**
+ * Reads the Z 8 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 8 bit Z data
+ */
+uint8_t ADXL362::scanz_u8()
+{
+ return read_reg(ZDATA);
+}
+
+/**
+ * Reads the Z 16 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 16 bit Z data
+ */
+uint16_t ADXL362::scanz()
+{
+ return read_reg_u16(ZDATA_L);
+}
+
+/**
+ * Reads the T 16 bit register from the ADXL362
+ * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
+ * @return 16 bit T data
+ */
+uint16_t ADXL362::scant()
+{
+ return read_reg_u16(TEMP_L);
+}
+
+/**
+ * Sets the STANDBY/MEASUREMENT mode of the ADXL362
+ * @param mode - ADXL362_modes_t STANDBY/MEASUREMENT mode
+ */
+void ADXL362::set_mode(ADXL362_modes_t mode)
+{
+ uint8_t reg_val;
+ reg_val = read_reg(POWER_CTL);
+ reg_val = reg_val | static_cast<uint8_t>(mode);
+ write_reg(POWER_CTL, reg_val);
+}
+
+/**
+ * Sets the activity threshold registers
+ * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
+ * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
+ * @param threshold - activity threshold in natural format
+ */
+void ADXL362::set_activity_threshold(uint16_t threshold)
+{
+ write_reg_u16(THRESH_ACT_L, threshold);
+}
+
+/**
+ * Sets the activity time register
+ * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
+ * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
+ * @param time - activity time
+ */
+void ADXL362::set_activity_time(uint8_t time)
+{
+ write_reg(TIME_ACT, time);
+}
+
+/**
+ * Sets the inactivity threshold register
+ * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
+ * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
+ * @param threshold - inactivity threshold in natural format
+ */
+void ADXL362::set_inactivity_threshold(uint16_t threshold)
+{
+ write_reg_u16(THRESH_INACT_L, threshold);
+}
+
+/**
+ * Sets the inactivity time register
+ * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
+ * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
+ * @param time - inactivity time in natural format
+ */
+void ADXL362::set_inactivity_time(uint16_t time)
+{
+ write_reg_u16(TIME_INACT_L, time);
+}
+
+/**
+ * Sets the ACT_INACT_CTL register of the ADXL362
+ * @param data - data to be written to the register
+ */
+void ADXL362::set_act_inact_ctl_reg(uint8_t data)
+{
+ write_reg(ACT_INACT_CTL, data);
+}
+
+/**
+ * Configures INT1 output of the ADXL362 for polling use
+ * @param in - uC pin connected to ADXL362's INT1
+ * @param data - data to be written to INTMAP1
+ * @param pull - (optional) configures pullup on In pin
+ */
+void ADXL362::set_polling_interrupt1_pin(PinName in, uint8_t data,
+ PinMode pull)
+{
+ if ((data & 0x7F) != 0) {
+ write_reg(INTMAP1, data);
+ _int1_poll = DigitalIn(in);
+ _int1_poll.mode(pull);
+ if (data & 0x80) {
+ _int1_act_low = true;
+ } else {
+ _int1_act_low = false;
+ }
+ }
+}
+
+/**
+ * Configures INT2 output of the ADXL362 for polling use
+ * @param in - uC pin connected to ADXL362's INT2
+ * @param data - data to be written to INTMAP2
+ * @param pull - (optional) configures pullup on In pin
+ */
+void ADXL362::set_polling_interrupt2_pin(PinName in, uint8_t data,
+ PinMode pull)
+{
+ if ((data & 0x7F) != 0) {
+ write_reg(INTMAP2, data);
+ _int2_poll = DigitalIn(in);
+ _int2_poll.mode(pull);
+ if (data & 0x80) {
+ _int2_act_low = true;
+ } else {
+ _int2_act_low = false;
+ }
+ }
+}
+
+/**
+ * Gets the active state of the INT1 pin
+ * @return true if active, false if not active
+ */
+bool ADXL362::get_int1()
+{
+ if(_int1_poll != NC) return (_int1_poll.read() != _int1_act_low); // boolean XOR
+ else return (_int1->read() != _int1_act_low);
+}
+
+/**
+ * Gets the active state of the INT2 pin
+ * @return true if active, false if not active
+ */
+bool ADXL362::get_int2()
+{
+ if(_int2_poll != NC) return (_int1_poll.read() != _int1_act_low); // boolean XOR
+ else return (_int2->read() != _int2_act_low);
+}
+
+
+/**
+ * Configures the INT1 pin of the ADXL362 to be used in interrupt mode
+ * @param in - uC pin connected to ADXL362's INT1
+ * @param data - data to be written to INTMAP1
+ * @param callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge
+ * @param callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge
+ * @param pull - (optional) configures pullup on In pin
+ */
+void ADXL362::set_interrupt1_pin(PinName in, uint8_t data,
+ void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull)
+{
+ if ((data & 0x7F) != 0) {
+ write_reg(INTMAP1, data);
+ delete _int1;
+ _int1 = new InterruptIn(in);
+ _int1->mode(pull);
+ if(callback_falling != NULL) _int1->fall(callback_falling);
+ if(callback_rising != NULL) _int1->rise(callback_rising);
+ if (data & 0x80) {
+ _int1_act_low = true;
+ } else {
+ _int1_act_low = false;
+ }
+ }
+}
+
+
+/**
+ * Configures the INT2 pin of the ADXL362 to be used in interrupt mode
+ * @param in - uC pin connected to ADXL362's INT2
+ * @param data - data to be written to INTMAP2
+ * @param callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge
+ * @param callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge
+ * @param pull - (optional) configures pullup on In pin
+ */
+void ADXL362::set_interrupt2_pin(PinName in, uint8_t data,
+ void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull)
+{
+ if ((data & 0x7F) != 0) {
+ write_reg(INTMAP2, data);
+ delete _int2;
+ _int2 = new InterruptIn(in);
+ _int2->mode(pull);
+ if(callback_falling != NULL) _int2->fall(callback_falling);
+ if(callback_rising != NULL) _int2->rise(callback_rising);
+ if (data & 0x80) {
+ _int2_act_low = true;
+ } else {
+ _int2_act_low = false;
+ }
+ }
+}
+
+/**
+ * Enables external interrupt registration for pin configured as INT1
+ * To enable this interrupt, it must first be configured using ADXL362::set_interrupt1_pin()
+ */
+void ADXL362::enable_interrupt1()
+{
+ _int1->enable_irq();
+}
+
+/**
+ * Enables external interrupt registration for pin configured as INT2
+ * * To enable this interrupt, it must first be configured using ADXL362::set_interrupt2_pin()
+ */
+void ADXL362::enable_interrupt2()
+{
+ _int2->enable_irq();
+}
+
+/**
+ * Disables external interrupt registration for pin configured as INT1
+ */
+void ADXL362::disable_interrupt1()
+{
+ _int1->disable_irq();
+}
+
+/**
+ * Disables external interrupt registration for pin configured as INT2
+ */
+void ADXL362::disable_interrupt2()
+{
+ _int2->disable_irq();
+}
+
+/**
+ * Sets the POWER_CTL register
+ * @param data - data to be written to the register
+ */
+void ADXL362::set_power_ctl_reg(uint8_t data)
+{
+ write_reg(POWER_CTL, data);
+}
+
+/**
+ * Sets the FILTER_CTL register
+ * @param data - data to be written to the register
+ */
+void ADXL362::set_filter_ctl_reg(uint8_t data)
+{
+ write_reg(FILTER_CTL, data);
+}
+
+/**
+ * Reads the STATUS register of the ADXL362
+ * @return - data in the status register
+ */
+uint8_t ADXL362::read_status()
+{
+ return read_reg(STATUS);
+}
+
+/**
+ * Reads the FIFO_ENTRIES_L and FIFO_ENTRIES_H register
+ * @return the number of entries in the FIFO
+ */
+uint16_t ADXL362::fifo_read_nr_of_entries()
+{
+ return read_reg_u16(FIFO_ENTRIES_L);
+}
+
+/**
+ * Setup for the FIFO
+ * @param store_temp - boolean, true - temperature will be stored in the fifo. false otherwise
+ * @param mode - ADXL362_FIFO_modes_t fifo mode
+ * @param nr_of_entries - number of entries in the FIFO
+ */
+void ADXL362::fifo_setup(bool store_temp, ADXL362_FIFO_modes_t mode, uint16_t nr_of_entries)
+{
+ uint8_t fifo_ctl = static_cast<uint8_t>(mode);
+ _temp_stored_in_fifo = store_temp;
+
+ fifo_ctl = fifo_ctl | (static_cast<uint8_t>(_temp_stored_in_fifo) << 2);
+
+ if (nr_of_entries > 0xff) {
+ fifo_ctl = fifo_ctl | static_cast<uint8_t>(AH);
+ }
+ write_reg(FIFO_CONTROL, fifo_ctl);
+ write_reg(FIFO_SAMPLES, static_cast<uint8_t>(nr_of_entries & 0xff));
+
+}
+
+/**
+ * Reads a FIFO entry
+ * @return FIFO entry
+ */
+uint16_t ADXL362::fifo_read_u16()
+{
+ uint16_t ret_val = 0;
+ adxl362.format(8, _SPI_MODE);
+
+ cs = false;
+ adxl362.write(_READ_FIFO_CMD);
+ ret_val = adxl362.write(_DUMMY_BYTE);
+ ret_val = (ret_val) | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+ cs = true;
+
+ return ret_val;
+}
+
+/**
+ * Reads 3(4) bytes from the FIFO(if store_temp was set), assembles the data in the format used by the scan method
+ * ADXL362::fifo_setup() needs to be called before calling fifo_scan to ensure correct fifo operation
+ * fifo_scan and fifo_read_u16 should not be used as fifo_read_u16 disaligns the fifo therefore
+ * fifo_scan will return data from multiple samples
+ * @return scanned data from the fifo in the 0xXXYYZZTT format
+ */
+uint64_t ADXL362::fifo_scan()
+{
+
+ uint64_t ret_val = 0;
+ uint16_t x = 0, y = 0, z = 0, dummy, t = 0, sample_type;
+
+ adxl362.format(8, _SPI_MODE);
+ cs = false;
+ adxl362.write(_READ_FIFO_CMD);
+ uint8_t samples = (_temp_stored_in_fifo) ? 4 : 3;
+ for(uint8_t i = 0; i < samples; i++) {
+ dummy = adxl362.write(_DUMMY_BYTE);
+ dummy = dummy | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
+ sample_type = (dummy & 0xc000) >> 14;
+ dummy = dummy & 0x3fff;
+ switch(sample_type) {
+ case 0: // x
+ x = dummy;
+ break;
+ case 1: // y
+ y = dummy;
+ break;
+ case 2: // z
+ z = dummy;
+ break;
+ case 3: // temp
+ t = dummy;
+ break;
+ }
+
+ }
+
+ // format xxyyzztt
+ ret_val = static_cast<uint64_t> (x) << 48;
+ ret_val |= static_cast<uint64_t>(y) << 32;
+ ret_val |= static_cast<uint64_t>(z) << 16;
+ ret_val |= static_cast<uint64_t>(t);
+ cs = true;
+ return ret_val;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ADXL362/ADXL362.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,257 @@
+#ifndef ADXL362_H_
+#define ADXL362_H_
+
+/**
+* @file ADXL362.cpp
+* @brief Header file for ADXL362
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: http://www.analog.com/adxl362
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+
+class ADXL362
+{
+public:
+
+ /* Temperature parameters */
+ typedef enum {
+ DEVID_AD = 0x00,
+ DEVID_MST = 0x01,
+ PARTID = 0x02,
+ REVID = 0x03,
+ XDATA = 0x08,
+ YDATA = 0x09,
+ ZDATA = 0x0A,
+ STATUS = 0x0B,
+ FIFO_ENTRIES_L = 0x0C,
+ FIFO_ENTRIES_H = 0x0D,
+ XDATA_L = 0x0E,
+ XDATA_H = 0x0F,
+ YDATA_L = 0x10,
+ YDATA_H = 0x11,
+ ZDATA_L = 0x12,
+ ZDATA_H = 0x13,
+ TEMP_L = 0x14,
+ TEMP_H = 0x15,
+ // Reserved = 0x16;
+ // Reserved = 0x17;
+ SOFT_RESET = 0x1F,
+ THRESH_ACT_L = 0x20,
+ THRESH_ACT_H = 0x21,
+ TIME_ACT = 0x22,
+ THRESH_INACT_L = 0x23,
+ THRESH_INACT_H = 0x24,
+ TIME_INACT_L = 0x25,
+ TIME_INACT_H = 0x26,
+ ACT_INACT_CTL = 0x27,
+ FIFO_CONTROL = 0x28,
+ FIFO_SAMPLES = 0x29,
+ INTMAP1 = 0x2A,
+ INTMAP2 = 0x2B,
+ FILTER_CTL = 0x2C,
+ POWER_CTL = 0x2D,
+ SELF_TEST = 0x2E,
+ } ADXL362_register_t;
+
+ typedef enum {
+ STANDBY = 0x00,
+ MEASUREMENT = 0x02
+ } ADXL362_modes_t;
+
+ typedef enum {
+ ERR_USER_REGS = 0x80,
+ AWAKE = 0x40,
+ INACT = 0x20,
+ ACT = 0x10,
+ FIFO_OVERRUN = 0x08,
+ FIFO_WATERMARK = 0x04,
+ FIFO_READY = 0x02,
+ DATA_READY = 0x01
+ } ADXL362_STATUS_reg_bits_t;
+
+ typedef enum {
+ LINKLOOP1 = 0x20,
+ LINKLOOP0 = 0x10,
+ DEFAULTMODE = 0x00,
+ LINKED_MODE = 0x10,
+ LOOP_MODE = 0x30,
+ INACT_REF = 0x08,
+ INACT_EN = 0x04,
+ ACT_REF = 0x02,
+ ACT_EN = 0x01
+ } ADXL362_ACT_INACT_CTL_reg_bits_t;
+
+ typedef enum {
+ AH = 0x08,
+ FIFO_TEMP = 0x04,
+ FIFO_MODE1 = 0x02,
+ FIFO_MODE = 0x01,
+ } ADXL362_FIFO_CONTROL_reg_bits_t;
+
+ typedef enum {
+ FIFO_DISABLED = 0x00,
+ FIFO_OLDEST = 0x01,
+ FIFO_STREAM = 0x02,
+ FIFO_TRIGGERED = 0x03,
+ } ADXL362_FIFO_modes_t;
+
+ typedef enum {
+ INT_LOW = 0x80,
+ INT_AWAKE = 0x40,
+ INT_INACT = 0x20,
+ INT_ACT = 0x10,
+ INT_FIFO_OVERRUN = 0x08,
+ INT_FIFO_WATERMARK = 0x04,
+ INT_FIFO_READY = 0x02,
+ INT_DATA_READY = 0x01
+ } ADXL362_INTMAP_reg_bits_t;
+
+ typedef enum {
+ RANGE1 = 0x80,
+ RANGE0 = 0x40,
+ RANGE2G = 0x00,
+ RANGE4G = 0x40,
+ RANGE8G = 0x80,
+ HALF_BW = 0x10,
+ EXT_SAMPLE = 0x08,
+ ODR2 = 0x04,
+ ODR1 = 0x02,
+ ODR0 = 0x01,
+ ODR12HZ = 0x00,
+ ODR25HZ = 0x01,
+ ODR50Hz = 0x02,
+ ODR100HZ = 0x03,
+ ODR200Hz = 0x04,
+ ODR400HZ = 0x07
+ } ADXL362_FILTER_CTL_reg_bits_t;
+
+ typedef enum {
+ EXT_CLK = 0x40,
+ LOW_NOISE1 = 0x20,
+ LOW_NOISE0 = 0x10,
+ NORMAL_OPERATION = 0x00,
+ LOW_NOISE = 0x10,
+ ULTRALOW_NOISE = 0x20,
+ WAKEUP = 0x08,
+ AUTOSLEEP = 0x04,
+ MEASURE1 = 0x02,
+ MEASURE0 = 0x01,
+ } ADXL362_POWER_CTL_reg_bits_t;
+
+ /** SPI configuration & constructor */
+ ADXL362(PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO =
+ SPI_MISO, PinName SCK = SPI_SCK);
+ void frequency(int hz);
+
+ /** Low level SPI bus comm methods */
+ void reset(void);
+ void write_reg(ADXL362_register_t reg, uint8_t data);
+ uint8_t read_reg(ADXL362_register_t reg);
+ uint16_t read_reg_u16(ADXL362_register_t reg);
+ void write_reg_u16(ADXL362_register_t reg, uint16_t data);
+
+ /** ADXL general register R/W methods */
+ void set_power_ctl_reg(uint8_t data);
+ void set_filter_ctl_reg(uint8_t data);
+ uint8_t read_status();
+ void set_mode(ADXL362_modes_t mode);
+
+ /** ADXL X/Y/Z/T scanning methods*/
+ uint64_t scan();
+ uint8_t scanx_u8();
+ uint16_t scanx();
+ uint8_t scany_u8();
+ uint16_t scany();
+ uint8_t scanz_u8();
+ uint16_t scanz();
+ uint16_t scant();
+
+ /** ADXL362 activity methods */
+ void set_activity_threshold(uint16_t threshold);
+ void set_activity_time(uint8_t time);
+ void set_inactivity_threshold(uint16_t threshold);
+ void set_inactivity_time(uint16_t time);
+ void set_act_inact_ctl_reg(uint8_t data);
+
+ /** ADXL362 interrupt methods */
+ void set_interrupt1_pin(PinName in, uint8_t data, void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull = PullNone);
+ void set_interrupt2_pin(PinName in, uint8_t data, void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull = PullNone);
+ void enable_interrupt1();
+ void enable_interrupt2();
+ void disable_interrupt1();
+ void disable_interrupt2();
+
+ void set_polling_interrupt1_pin(PinName in, uint8_t data, PinMode pull = PullNone);
+ void set_polling_interrupt2_pin(PinName in, uint8_t data, PinMode pull = PullNone);
+
+ bool get_int1();
+ bool get_int2();
+
+ /** ADXL362 FIFO methods */
+ uint16_t fifo_read_nr_of_entries();
+ void fifo_setup(bool store_temp, ADXL362_FIFO_modes_t mode, uint16_t nr_of_entries);
+ uint16_t fifo_read_u16();
+ uint64_t fifo_scan();
+
+ SPI adxl362; ///< SPI instance of the ADXL362
+ DigitalOut cs; ///< DigitalOut instance for the chipselect of the ADXL362
+
+private:
+
+ InterruptIn *_int1;
+ InterruptIn *_int2;
+ DigitalIn _int1_poll;
+ DigitalIn _int2_poll;
+ bool _int1_act_low;
+ bool _int2_act_low;
+ bool _temp_stored_in_fifo;
+
+ const static uint8_t _DUMMY_BYTE = 0xAA;
+ const static uint8_t _WRITE_REG_CMD = 0x0A; // write register
+ const static uint8_t _READ_REG_CMD = 0x0B; // read register
+ const static uint8_t _READ_FIFO_CMD = 0x0D; // read FIFO
+ const static uint8_t _SPI_MODE = 0;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/CN0216/CN0216.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,161 @@
+/**
+* @file cn0216.cpp
+* @brief Source file for CN0216
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0216-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include "AD7791.h"
+#include "CN0216.h"
+extern Serial pc;
+
+/**
+ * CN0216 constructor
+ * @param CSAD7791 - Chipselect of the AD7791
+ * @param MOSI - MOSI line of the SPI bus
+ * @param MISO - MISO line of the SPI bus
+ * @param SCK - SCK line of the SPI bus
+ */
+CN0216::CN0216(PinName CSAD7791, PinName MOSI, PinName MISO, PinName SCK) : ad7791(1.2, CSAD7791, MOSI, MISO, SCK)
+{
+ _cal_weight = 0;
+ _zero_scale_value = 0;
+ _full_scale_value = 0;
+ _weight_units_per_bit = 0;
+}
+
+/**
+ * Initializes the mode and filter values of the AD7791 and sets the weight to be used in calibration
+ * @param cal_weight - weight used in calibration
+ * @param mode_val - value of the mode register
+ * @param filter_val - value of the filter register
+ */
+void CN0216::init(float cal_weight, uint8_t mode_val, uint8_t filter_val)
+{
+ _cal_weight = cal_weight;
+ ad7791.frequency(500000);
+ wait_ms(50);
+ ad7791.reset();
+ wait_ms(50);
+ ad7791.write_mode_reg(mode_val);
+ wait_us(2);
+ ad7791.write_filter_reg(filter_val);
+ wait_ms(50);
+}
+
+/**
+ * Calibrates the CN0216 weigh scale
+ * @param cal - calibration step.
+ * Step CN0216::ZERO_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the minimum as value for the zero scale
+ * Step CN0216::FULL_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the average as value for the full scale
+ * Step COMPUTE_UNITS_PER_BIT will compute the grams per bit used in weight computation.
+ */
+void CN0216::calibrate(CalibrationStep_t cal)
+{
+ uint64_t sum = 0;
+ uint32_t min = 0xFFFFFFFF;
+ uint32_t sample = 0;
+ switch(cal) {
+ case ZERO_SCALE_CALIBRATION:
+ case FULL_SCALE_CALIBRATION:
+ for(int i = 0; i < _NUMBER_OF_SAMPLES; i++) {
+ sample = ad7791.read_u32();
+ min = (min < sample) ? min : sample;
+ sum += ad7791.read_u32();
+ wait_us(5);
+ }
+ if(cal == ZERO_SCALE_CALIBRATION) {
+ // pc.printf("ZERO SCALE VALUE = %x",sum);
+ _zero_scale_value = min;
+ } else {
+ // pc.printf("FULL SCALE VALUE = %x",sum);
+ sum = sum / _NUMBER_OF_SAMPLES;
+ _full_scale_value = sum;
+ }
+ break;
+
+ case COMPUTE_UNITS_PER_BIT:
+ _weight_units_per_bit = _cal_weight / (static_cast<float> (_full_scale_value - _zero_scale_value)); /* Calculate number of grams per LSB */
+ // pc.printf("GRAMS/LSB = %f", _grams_per_bit);
+ break;
+ default:
+ break;
+ }
+
+}
+
+/**
+ * Computes the weight based on the formula
+ * weight = (data - zeroscale) * weight_units_per_bit
+ * @param data read from the ADC
+ * @return weight based on data
+ */
+float CN0216::compute_weight(uint32_t data)
+{
+// pc.printf("\r\nFULL_SCALE_VALUE = %x\r\nZERO_SCALE_VALUE = %x\r\nDATA READ = %x\r\nGRAMS/LSB = %f\r\n",_full_scale_value,data,_zero_scale_value,_grams_per_bit);
+ if(data < _zero_scale_value)
+ data = _zero_scale_value; // clamp data to 0
+ float weight_in_grams = (static_cast<float>((data) - _zero_scale_value)) * _weight_units_per_bit; /* Calculate weight */
+ return weight_in_grams;
+}
+
+/**
+ * Reads the AD7791
+ * @return value read by the ADC
+ */
+uint32_t CN0216::read_u32()
+{
+ return ad7791.read_u32();
+}
+
+/**
+ * Reads the ADC and computes the weight based on the formula described above.
+ * @return weight
+ */
+float CN0216::read_weight()
+{
+ uint32_t weight = read_u32();
+ return compute_weight(weight);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/CN0216/CN0216.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,85 @@
+/**
+* @file cn0216.h
+* @brief Header file for CN0216
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0216-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include "AD7791.h"
+
+#ifndef CN0216_H_
+#define CN0216_H_
+
+class CN0216
+{
+public:
+ typedef enum {
+ ZERO_SCALE_CALIBRATION, ///< Calibration of the zero scale value
+ FULL_SCALE_CALIBRATION, ///< Calibration of the full scale value
+ COMPUTE_UNITS_PER_BIT ///< Units per LSB computation
+ } CalibrationStep_t;
+
+ CN0216(PinName CSAD7791 = D8, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
+ void init(float cal_weight = _DEFAULT_CAL_WEIGHT, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL);
+ void calibrate(CalibrationStep_t cal);
+ float compute_weight(uint32_t data);
+ uint32_t read_u32();
+ float read_weight();
+
+private:
+
+ const static int _NUMBER_OF_SAMPLES = 20; ///< Number of samples used in calibration
+ const static int _DEFAULT_MODE_VAL = AD7791::MD1 | AD7791::MD0; // POWERDOWN MODE
+ const static int _DEFAULT_FILTER_VAL = AD7791::FS0 | AD7791::FS1 | AD7791::FS2;
+ const static int _DEFAULT_CAL_WEIGHT = 1000.0;
+
+ AD7791 ad7791;
+ float _cal_weight;
+ uint32_t _zero_scale_value;
+ uint32_t _full_scale_value;
+ float _weight_units_per_bit;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/CN0357/CN0357.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,229 @@
+/**
+* @file cn0357.cpp
+* @brief Source file for CN0357
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0357-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#include "mbed.h"
+#include "AD7790.h"
+#include "AD5270.h"
+#include "CN0357.h"
+
+/**
+ * @brief CN0357 constructor
+ * @param CSAD7790 - (optional)chip select of the AD7790
+ * @param CSAD5270 - (optional)chip select of the AD5270
+ * @param MOSI - (optional)pin of the SPI interface
+ * @param MISO - (optional)pin of the SPI interface
+ * @param SCK - (optional)pin of the SPI interface
+ */
+CN0357::CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO,
+ PinName SCK) :
+ _vref(1.2), _sensor_sensitivity(0), _sensor_range(0), _RDACvalue(0),
+ ad7790(_vref, CSAD7790, MOSI, MISO, SCK), ad5270(CSAD5270, 20000.0, MOSI, MISO, SCK)
+
+{
+}
+
+/**
+ * @brief initializes the AD7790 and the AD5270
+ * @param range - range of the sensor used (in ppm)
+ * @param sensitivity - sensitivity of the sensor (A/ppm)
+ * @param jp - (optional)jumper configuration of the CN0357
+ * @param mode_val - (optional)if jp is set to InternalADC, configures the mode register of the Internal ADC
+ * @param filter_val - (optional)if jp is set to InternalADC, configures the filter register of the Internal ADC
+ */
+void CN0357::init(float range, float sensitivity, JumperConfig_t jp, uint8_t mode_val, uint8_t filter_val)
+{
+ ad5270.frequency(500000);
+ ad7790.frequency(500000);
+
+ float resistance = set_sensor_parameters(range, sensitivity);
+
+ if(jp == INTERNAL_AD7790) {
+ _AD7790_init(mode_val, filter_val);
+ }
+ _rdac_init(resistance);
+}
+
+/**
+ * @brief initializes the RDAC and sets SDO to HiZ
+ * @param resistance - resistance value to initialize the RDAC
+ * @return
+ */
+void CN0357::_rdac_init(float resistance)
+{
+ /* RDAC initialization*/
+ /* Compute for the nearest RDAC value from given resistance and save data to the structure */
+ set_RDAC_value(resistance);
+ /* Set AD5270 SDO to Hi-Z */
+ ad5270.set_SDO_HiZ();
+}
+
+/**
+ * @brief initializes the AD7790
+ * @param mode_val - configures the mode register of the Internal ADC
+ * @param filter_val - configures the filter register of the Internal ADC
+ */
+void CN0357::_AD7790_init(uint8_t mode_val, uint8_t filter_val)
+{
+ ad7790.reset();
+ wait_ms(50);
+
+ ad7790.write_mode_reg(mode_val);
+ wait_us(2);
+
+ ad7790.write_filter_reg(filter_val);
+ wait_ms(50);
+}
+
+/**
+ * @brief reads the status register of the AD7790
+ * @return status register value
+ */
+uint8_t CN0357::read_adc_status(void)
+{
+ return ad7790.read_status_reg();
+}
+
+/**
+ * @brief reads the ADC and computes the sensor voltage
+ * @return sensor voltage
+ */
+float CN0357::read_sensor_voltage(void)
+{
+ return ad7790.read_voltage();
+}
+
+/**
+ * @brief reads the data register of the AD7790
+ * @return data register value
+ */
+uint16_t CN0357::read_sensor(void)
+{
+ return ad7790.read_u16();
+}
+
+/**
+ * @brief reads and computes the sensor reading in PPM
+ * @return value of the sensor reading in PPM
+ */
+float CN0357::read_ppm()
+{
+ return calc_ppm(ad7790.read_voltage()); /* Convert voltage to Gas concentration*/
+}
+
+/**
+ * @brief computes a value in PPM from a reading received as a param
+ * @param adcVoltage - voltage to be converted to PPM
+ * @return sensor value in PPM
+ */
+float CN0357::calc_ppm(float adcVoltage)
+{
+ float fConcentration = 0;
+ fConcentration = (fabs(adcVoltage) / _RDACvalue) / _sensor_sensitivity;
+ return fConcentration;
+}
+
+/**
+ * @brief computes voltage from a 16 bit ADC value received as a parameter
+ * @param data - ADC value
+ * @return sensor voltage
+ */
+float CN0357::data_to_voltage(uint16_t data)
+{
+ return ad7790.data_to_voltage(data);
+}
+
+/**
+ * @brief sets a new value for the RDAC
+ * @param resistance new value for the resistance
+ * @return none
+ */
+void CN0357::set_RDAC_value(float resistance)
+{
+ _RDACvalue = ad5270.write_RDAC(resistance);
+}
+
+/**
+ * @brief getter method for RDAC value
+ * @return value of the RDAC in ohms
+ */
+float CN0357::get_RDAC_value()
+{
+ return _RDACvalue;
+}
+
+/**
+ * @brief set sensor range and sensitivity
+ * sets sensor range, sensitivity
+ * returns suggested resistance value for feedback resistor
+ * @param range - range of the sensor used (in ppm)
+ * @param sensitivity - sensitivity of the sensor (in A/ppm)
+ * @return suggested resistance value for feedback resistor
+ */
+float CN0357::set_sensor_parameters(float range, float sensitivity)
+{
+ _sensor_sensitivity = static_cast<float>(sensitivity);
+ _sensor_range = range;
+ return (_vref / (static_cast<float>(_sensor_range * _sensor_sensitivity)));
+}
+
+/**
+ * @brief getter method for sensor sensitivity
+ * @return sensor sensitivity (in A/ppm)
+ */
+float CN0357::get_sensor_sensitivity()
+{
+ return _sensor_sensitivity;
+}
+
+/**
+ * @brief getter method for sensor range
+ * @return sensor range (in ppm)
+ */
+float CN0357::get_sensor_range()
+{
+ return _sensor_range;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/CN0357/CN0357.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,102 @@
+/**
+* @file cn0357.h
+* @brief Header file for CN0357
+* @author Analog Devices Inc.
+*
+* For support please go to:
+* Github: https://github.com/analogdevicesinc/mbed-adi
+* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+* Product: www.analog.com/EVAL-CN0357-ARDZ
+* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+********************************************************************************
+* Copyright 2016(c) Analog Devices, Inc.
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+* - Neither the name of Analog Devices, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+* - The use of this software may or may not infringe the patent rights
+* of one or more patent holders. This license does not release you
+* from the requirement that you obtain separate licenses from these
+* patent holders to use this software.
+* - Use of the software either in source or binary form, must be run
+* on or directly connected to an Analog Devices Inc. component.
+*
+* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+********************************************************************************/
+
+#ifndef CN0357_H
+#define CN0357_H
+
+#include "mbed.h"
+#include "AD7790.h"
+#include "AD5270.h"
+
+/**
+ * @brief EVAL-CN0357 toxic gas sensor shield
+ */
+class CN0357
+{
+public:
+
+private:
+ float _vref;
+ float _sensor_sensitivity;
+ float _sensor_range;
+ float _RDACvalue;
+public:
+ AD7790 ad7790; ///< AD7790 instance - can be used for manual overriding
+ AD5270 ad5270; ///< AD5270 instance - can be used for manual overriding
+
+ /// CN0357 shield jumper configuration
+ typedef enum {
+ INTERNAL_AD7790 = 0, ///< The shield's AD7790 is used
+ EXTERNAL_ADC ///< Sensor analog output is routed to A1 pin of the shield
+ } JumperConfig_t;
+
+ CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
+ void init(float range, float sensitivity, JumperConfig_t jp = INTERNAL_AD7790, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL);
+
+ uint8_t read_adc_status(void);
+ uint16_t read_sensor(void);
+ float read_sensor_voltage(void);
+ float data_to_voltage(uint16_t data);
+ float calc_ppm(float adcVoltage);
+ float read_ppm(void);
+
+ void set_RDAC_value(float resistor_val);
+ float get_RDAC_value(void);
+ float set_sensor_parameters(float range, float sensitivity);
+ float get_sensor_range(void);
+ float get_sensor_sensitivity(void);
+
+private:
+ const static int _RESET = 0xff;
+ const static int _DEFAULT_MODE_VAL = AD7790::MD1 | AD7790::MD0; // POWERDOWN MODE
+ const static int _DEFAULT_FILTER_VAL = AD7790::FS0 | AD7790::FS1 | AD7790::FS2;
+ void _rdac_init(float resistanceValue);
+ void _AD7790_init(uint8_t mode_val, uint8_t filter_val);
+
+};
+
+#endif // CN0357_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/EVAL_ADXL362_ARDZ/EVAL_ADXL362_ARDZ.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,220 @@
+/**
+ * @file EVAL_ADXL362_ARDZ.cpp
+ * @brief Source file for the EVAL-ADXL362-ARDZ board
+ * @author Analog Devices Inc.
+ *
+ * For support please go to:
+ * Github: https://github.com/analogdevicesinc/mbed-adi
+ * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+ * Product: www.analog.com/EVAL-ADXL362-ARDZ
+ * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+ ********************************************************************************
+ * Copyright 2016(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ********************************************************************************/
+
+#include "EVAL_ADXL362_ARDZ.h"
+
+/**
+ * Constructor for the EVAL_ADXL362_ARDZ
+ * @param _lcd reference to an LCD object
+ * @param _adxl362 reference to an ADXL362 object
+ */
+EVAL_ADXL362_ARDZ::EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) : lcd(_lcd) , adxl362(_adxl362)
+{
+ _x_axis_data = 0;
+ _y_axis_data = 0;
+ _z_axis_data = 0;
+ _t_data = 0;
+ _lcd_on = 0;
+}
+
+/**
+ * Initial setup of the LCD
+ */
+void EVAL_ADXL362_ARDZ::LCD_setup()
+{
+ lcd.init();
+}
+
+/**
+ * Initial setup of the ADXL
+ */
+void EVAL_ADXL362_ARDZ::ADXL_setup()
+{
+ adxl362.reset();
+ wait_us(500);
+ adxl362.set_activity_threshold(ACT_VAL);
+ adxl362.set_activity_time(ACT_TIMER / 10);
+
+ adxl362.set_inactivity_threshold(INACT_VAL);
+ adxl362.set_inactivity_time(INACT_TIMER);
+ adxl362.set_act_inact_ctl_reg(0x3f);
+#if(ADXL_INT_SEL == INTACC_PIN_1)
+ adxl362.set_polling_interrupt1_pin(D2, 0x40);
+#elif(ADXL_INT_SEL == INTACC_PIN_2)
+ adxl362.set_polling_interrupt2_pin(D2, 0x40); /* Map the awake status to INT2 pin */
+#endif
+ adxl362.set_mode(ADXL362::MEASUREMENT);
+ _lcd_on = 0;
+
+}
+
+/**
+ * Method used to scan the ADXL axis data to the internal members
+ */
+void EVAL_ADXL362_ARDZ::ADXL_scan_xyzt()
+{
+ uint64_t acc = adxl362.scan();
+ _x_axis_data = static_cast<uint16_t>((acc & 0xffff000000000000) >> 48);
+ _y_axis_data = static_cast<uint16_t>((acc & 0x0000ffff00000000) >> 32);
+ _z_axis_data = static_cast<uint16_t>((acc & 0x00000000ffff0000) >> 16);
+ _t_data = static_cast<uint16_t> (acc & 0x000000000000ffff);
+}
+
+/**
+ * Gets the status of the interrupt
+ * @return true if interrupt is active
+ */
+bool EVAL_ADXL362_ARDZ::ADXL_get_int()
+{
+#if(ADXL_INT_SEL == INTACC_PIN_1)
+ return adxl362.get_int1();
+#elif(ADXL_INT_SEL == INTACC_PIN_2)
+ return adxl362.get_int2();
+#endif
+ return false;
+}
+
+/**
+ * Displays numeric values on the LCD
+ */
+void EVAL_ADXL362_ARDZ::LCD_display_values()
+{
+ uint8_t string[22];
+ sprintf((char *) string, "x = % 5d", _x_axis_data);
+ lcd.display_string(0, 0, (int8_t *) string);
+
+ sprintf((char *) string, "y = % 5d", _y_axis_data);
+ lcd.display_string(1, 0, (int8_t *) string);
+
+ sprintf((char *) string, "z = % 5d", _z_axis_data);
+ lcd.display_string(2, 0, (int8_t *) string);
+
+#if TEMP_ADC == 1
+ sprintf((char *)string, "t = % 5d", _t_data);
+ lcd.display_string(3, 0, (int8_t *)string);
+#else
+ float f32temp = ((float) _t_data + Lcd::ACC_TEMP_BIAS)
+ / (1 / Lcd::ACC_TEMP_SENSITIVITY); // -34.625
+ sprintf((char *) string, "t = % 4.1f", f32temp);
+ lcd.display_string(3, 0, (int8_t *) string);
+#endif
+}
+
+/**
+ * Displays the level meter on the LCD
+ */
+void EVAL_ADXL362_ARDZ::LCD_display_level()
+{
+ bool any_direction = false;
+ lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
+
+ if(_x_axis_data > Lcd::ACC_LIMIT) {
+ lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8Rec8x8);
+ any_direction = true;
+ }
+ if(_x_axis_data < -Lcd::ACC_LIMIT) {
+ lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8Rec8x8);
+ any_direction = true;
+ }
+ if(_y_axis_data > Lcd::ACC_LIMIT) {
+ lcd.display_symbol(0, Lcd::DOWN_X, 8, Lcd::pui8Rec8x8);
+ any_direction = true;
+ }
+ if(_y_axis_data < -Lcd::ACC_LIMIT) {
+ lcd.display_symbol(2, Lcd::UP_X, 8, Lcd::pui8Rec8x8);
+ any_direction = true;
+ }
+ if( any_direction ) lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
+ else lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8Rec8x8);
+
+}
+
+/**
+ * Turns on the backlight and draws the static data to the LCD
+ */
+void EVAL_ADXL362_ARDZ::LCD_init_display()
+{
+ /* Set BLLCD pin - turn on LCD backlight */
+ if(_lcd_on == true) return;
+ lcd.bl_enable();
+
+ lcd.display_string(0, 60, (int8_t *) "[mG]");
+ lcd.display_string(1, 60, (int8_t *) "[mG]");
+ lcd.display_string(2, 60, (int8_t *) "[mG]");
+
+#if (TEMP_ADC == 1)
+ lcd.display_string(3, 60, (int8_t *)"[ADC]");
+#else
+ lcd.display_string(3, 60, (int8_t *) "[C]");
+#endif
+
+ lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
+ lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
+ _lcd_on = true;
+}
+
+/**
+ * Turns off the backlight and clears the LCD
+ */
+void EVAL_ADXL362_ARDZ::LCD_deinit_display()
+{
+ if(_lcd_on == false) return;
+ /* Clear BLLCD pin - turn off LCD backlight */
+ lcd.bl_disable();
+
+ /* Clear screen */
+ lcd.fill_pages(0, 4, 0x00);
+ _lcd_on = false;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/EVAL_ADXL362_ARDZ/EVAL_ADXL362_ARDZ.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,87 @@
+/**
+ * @file EVAL_ADXL362_ARDZ.cpp
+ * @brief Header file for the EVAL-ADXL362-ARDZ board
+ * @author Analog Devices Inc.
+ *
+ * For support please go to:
+ * Github: https://github.com/analogdevicesinc/mbed-adi
+ * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
+ * Product: www.analog.com/EVAL-ADXL362-ARDZ
+ * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
+
+ ********************************************************************************
+ * Copyright 2016(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ********************************************************************************/
+
+#ifndef EVAL_ADXL362_ARDZ_H
+#define EVAL_ADXL362_ARDZ_H
+
+#include "Lcd.h"
+#include "ADXL362.h"
+
+
+class EVAL_ADXL362_ARDZ
+{
+public:
+ EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) ;
+ void ADXL_setup();
+ void ADXL_scan_xyzt();
+ bool ADXL_get_int();
+
+ void LCD_setup();
+ void LCD_init_display();
+ void LCD_deinit_display();
+ void LCD_display_level();
+ void LCD_display_values();
+
+ Lcd lcd;
+ ADXL362 adxl362;
+
+private:
+
+ uint8_t _lcd_on;
+ int16_t _x_axis_data;
+ int16_t _y_axis_data;
+ int16_t _z_axis_data;
+ int16_t _t_data;
+
+ static const uint16_t INACT_VAL = 50;
+ static const uint16_t INACT_TIMER = 100 * 10;
+ static const uint16_t ACT_VAL = 50;
+ static const uint8_t ACT_TIMER = 100;
+ static const uint16_t SCAN_SENSOR_TIME = 500;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/EVAL_ADXL362_ARDZ/Lcd.cpp Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,328 @@
+/**
+ ******************************************************************************
+ * @file Lcd.c
+ * @brief Source file for ST7565R LCD control.
+ * @author ADI
+ * @date March 2016
+ *
+ *******************************************************************************
+ * Copyright 2015(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *******************************************************************************
+ **/
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+#include "Lcd.h"
+#include "mbed.h"
+
+
+
+Lcd::Lcd(PinName rst_pin, PinName a0_pin, PinName bl_pin,
+ PinName cs_pin, PinName MOSI,
+ PinName MISO, PinName SCK) :
+
+ rst(rst_pin), a0(a0_pin), bl(bl_pin), cs(cs_pin), lcd_spi(MOSI, MISO, SCK)
+{
+ rst = 1;
+}
+
+/**
+ @brief Initialization of LCD screen
+ @return none
+ **/
+
+void Lcd::write_cmd(uint8_t cmd)
+{
+ cs = 0;
+ a0 = 0;
+ lcd_spi.write(cmd);
+ cs = 1;
+}
+
+void Lcd::write_data(uint8_t data)
+{
+ cs = 0;
+ a0 = 1;
+ lcd_spi.write(data);
+ cs = 1;
+}
+
+void Lcd::bl_enable()
+{
+ bl = 1;
+}
+
+void Lcd::bl_disable()
+{
+ bl = 0;
+}
+
+void Lcd::init(void)
+{
+
+ write_cmd(CMD_DISPLAY_OFF);
+ write_cmd(CMD_SET_BIAS_7);
+ write_cmd(CMD_SET_ADC_NORMAL);
+ write_cmd(CMD_SET_COM_REVERSE);
+ write_cmd((CMD_SET_RESISTOR_RATIO | 0x02));
+ write_cmd(CMD_SET_VOLUME_FIRST);
+ write_cmd((CMD_SET_VOLUME_SECOND | 0x04));
+ write_cmd((CMD_SET_POWER_CONTROL | 0x07));
+ fill_pages(0, 8, 0x00);
+
+}
+
+/**
+ @brief Displays a string at the specified position for with 5x7 font size.
+ @return none
+ **/
+void Lcd::display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str)
+{
+ uint8_t ui8x;
+ uint8_t ui8i;
+ uint8_t ui8ch;
+ uint8_t ui8data;
+
+ ui8ch = 0;
+ ui8x = ui8col;
+
+ while ((pi8str[ui8ch] != 0) && (ui8col < LCD_COLUMNS)) {
+ set_cursor(ui8row, ui8x); /* Set cursor position */
+
+ for (ui8i = 0; ui8i < 5; ui8i++) { /* Symbol matrix column loop */
+ ui8data = pui8font5x7[pi8str[ui8ch] - OFFS_ASCII][ui8i];
+
+ write_data(ui8data);
+ }
+
+ ui8x += 6; /* Increase column counter with 6 pixels */
+ ui8ch++; /* Increment counter */
+ }
+ write_cmd(CMD_DISPLAY_ON);
+
+}
+
+/**
+ @brief Displays a symbol (8 x width) at the specified position on the LCD.
+ @param ui8row - row number
+ @param ui8col - column number
+ @param ui8width - symbol width
+ @param pui8symbol - symbol to display
+ @return none
+ **/
+
+void Lcd::display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width,
+ const uint8_t *pui8symbol)
+{
+ uint8_t ui8i;
+ uint8_t ui8data;
+
+ set_cursor(ui8row, ui8col); /* Set cursor position */
+ for (ui8i = 0; ui8i < ui8width; ui8i++) { /* Symbol matrix column loop */
+ ui8data = pui8symbol[ui8i];
+ write_data(ui8data);
+ }
+ write_cmd(CMD_DISPLAY_ON);
+}
+
+/**
+ @brief Fills the selected LCD pages with the data specified.
+ @param ui8start - start element
+ @param ui8num - elements numbers to fill
+ @param ui8Data - data to fill
+ @return none
+ **/
+
+void Lcd::fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data)
+{
+
+ uint8_t ui8p;
+ uint8_t ui8c;
+
+ for (ui8p = ui8start; ui8p < (ui8start + ui8num); ui8p++) {
+ set_cursor(ui8p, 0);
+
+ for (ui8c = 0; ui8c < LCD_COLUMNS; ui8c++) {
+ write_data(ui8Data);
+ }
+ }
+
+ write_cmd(CMD_DISPLAY_ON);
+}
+
+/**
+ @brief Sets the start line of the LCD.
+ @param ui8line - line to start with
+ @return none
+ **/
+
+void Lcd::set_line(uint8_t ui8line)
+{
+
+ uint8_t ui8Cmd;
+ ui8Cmd = CMD_SET_DISP_START_LINE | (ui8line & 0x3F); /* Set start line */
+ write_cmd(ui8Cmd);
+
+}
+
+
+/**
+ @brief Sets the cursor position at which data will be written.
+ @param ui8PA - page number
+ @param ui8CA - column number
+ @return none
+ **/
+
+void Lcd::set_cursor(uint8_t ui8PA, uint8_t ui8CA)
+{
+ uint8_t ui8Cmd;
+
+ ui8Cmd = 0xB0 | (ui8PA & 0x0F); /* Set page address */
+ write_cmd(ui8Cmd);
+
+ ui8Cmd = ui8CA & 0x0F; /* Set column address LSB CA[3:0] */
+ write_cmd(ui8Cmd);
+
+ ui8Cmd = 0x10 | (ui8CA >> 4); /* Set column address MSB CA[7:4] */
+ write_cmd(ui8Cmd);
+}
+
+
+const uint8_t Lcd::pui8Rec8x8[8] = {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+const uint8_t Lcd::pui8RecInv8x8[8] = {
+ 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF
+};
+
+const uint8_t Lcd::pui8font5x7[96][5] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00}, /* 32 */
+ {0x00, 0x00, 0x4F, 0x00, 0x00}, /* ! 33 */
+ {0x00, 0x07, 0x00, 0x07, 0x00}, /* " 34 */
+ {0x14, 0x7F, 0x14, 0x7F, 0x14}, /* # 35 */
+ {0x24, 0x2A, 0x7F, 0x2A, 0x12}, /* $ 36 */
+ {0x23, 0x13, 0x08, 0x64, 0x62}, /* % 37 */
+ {0x36, 0x49, 0x55, 0x22, 0x50}, /* & 38 */
+ {0x00, 0x05, 0x03, 0x00, 0x00}, /* ' 39 */
+ {0x00, 0x1C, 0x22, 0x41, 0x00}, /* ( 40 */
+ {0x00, 0x41, 0x22, 0x1C, 0x00}, /* ) 41 */
+ {0x14, 0x08, 0x3E, 0x08, 0x14}, /* * 42 */
+ {0x08, 0x08, 0x3E, 0x08, 0x08}, /* + 43 */
+ {0x00, 0x50, 0x30, 0x00, 0x00}, /* , 44 */
+ {0x08, 0x08, 0x08, 0x08, 0x08}, /* - 45 */
+ {0x00, 0x60, 0x60, 0x00, 0x00}, /* . 46 */
+ {0x20, 0x10, 0x08, 0x04, 0x02}, /* / 47 */
+ {0x3E, 0x51, 0x49, 0x45, 0x3E}, /* 0 48 */
+ {0x00, 0x42, 0x7F, 0x40, 0x00}, /* 1 49 */
+ {0x42, 0x61, 0x51, 0x49, 0x46}, /* 2 50 */
+ {0x21, 0x41, 0x45, 0x4B, 0x31}, /* 3 51 */
+ {0x18, 0x14, 0x12, 0x7F, 0x10}, /* 4 52 */
+ {0x27, 0x45, 0x45, 0x45, 0x39}, /* 5 53 */
+ {0x3C, 0x4A, 0x49, 0x49, 0x30}, /* 6 54 */
+ {0x01, 0x71, 0x09, 0x05, 0x03}, /* 7 55 */
+ {0x36, 0x49, 0x49, 0x49, 0x36}, /* 8 56 */
+ {0x06, 0x49, 0x49, 0x29, 0x1E}, /* 9 57 */
+ {0x36, 0x36, 0x00, 0x00, 0x00}, /* : 58 */
+ {0x56, 0x36, 0x00, 0x00, 0x00}, /* ; 59 */
+ {0x08, 0x14, 0x22, 0x41, 0x00}, /* < 60 */
+ {0x14, 0x14, 0x14, 0x14, 0x14}, /* = 61 */
+ {0x00, 0x41, 0x22, 0x14, 0x08}, /* > 62 */
+ {0x02, 0x01, 0x51, 0x09, 0x06}, /* ? 63 */
+ {0x30, 0x49, 0x79, 0x41, 0x3E}, /* @ 64 */
+ {0x7E, 0x11, 0x11, 0x11, 0x7E}, /* A 65 */
+ {0x7F, 0x49, 0x49, 0x49, 0x36}, /* B 66 */
+ {0x3E, 0x41, 0x41, 0x41, 0x22}, /* C 67 */
+ {0x7F, 0x41, 0x41, 0x22, 0x1C}, /* D 68 */
+ {0x7F, 0x49, 0x49, 0x49, 0x41}, /* E 69 */
+ {0x7F, 0x09, 0x09, 0x09, 0x01}, /* F 70 */
+ {0x3E, 0x41, 0x49, 0x49, 0x7A}, /* G 71 */
+ {0x7F, 0x08, 0x08, 0x08, 0x7F}, /* H 72 */
+ {0x00, 0x41, 0x7F, 0x41, 0x00}, /* I 73 */
+ {0x20, 0x40, 0x41, 0x3F, 0x01}, /* J 74 */
+ {0x7F, 0x08, 0x14, 0x22, 0x41}, /* K 75 */
+ {0x7F, 0x40, 0x40, 0x40, 0x40}, /* L 76 */
+ {0x7F, 0x02, 0x0C, 0x02, 0x7F}, /* M 77 */
+ {0x7F, 0x04, 0x08, 0x10, 0x7F}, /* N 78 */
+ {0x3E, 0x41, 0x41, 0x41, 0x3E}, /* O 79 */
+ {0x7F, 0x09, 0x09, 0x09, 0x06}, /* P 80 */
+ {0x3E, 0x41, 0x51, 0x21, 0x5E}, /* Q 81 */
+ {0x7F, 0x09, 0x19, 0x29, 0x46}, /* R 82 */
+ {0x46, 0x49, 0x49, 0x49, 0x31}, /* S 83 */
+ {0x01, 0x01, 0x7F, 0x01, 0x01}, /* T 84 */
+ {0x3F, 0x40, 0x40, 0x40, 0x3F}, /* U 85 */
+ {0x1F, 0x20, 0x40, 0x20, 0x1F}, /* V 86 */
+ {0x3F, 0x40, 0x30, 0x40, 0x3F}, /* W 87 */
+ {0x63, 0x14, 0x08, 0x14, 0x63}, /* X 88 */
+ {0x07, 0x08, 0x70, 0x08, 0x07}, /* Y 89 */
+ {0x61, 0x51, 0x49, 0x45, 0x43}, /* Z 90 */
+ {0x00, 0x7F, 0x41, 0x41, 0x00}, /* [ 91 */
+ {0x02, 0x04, 0x08, 0x10, 0x20}, /* \ 92 */
+ {0x00, 0x41, 0x41, 0x7F, 0x00}, /* ] 93 */
+ {0x04, 0x02, 0x01, 0x02, 0x04}, /* ^ 94 */
+ {0x40, 0x40, 0x40, 0x40, 0x40}, /* _ 95 */
+ {0x00, 0x01, 0x02, 0x04, 0x00}, /* ` 96 */
+ {0x20, 0x54, 0x54, 0x54, 0x78}, /* a 97 */
+ {0x7F, 0x50, 0x48, 0x48, 0x30}, /* b 98 */
+ {0x38, 0x44, 0x44, 0x44, 0x20}, /* c 99 */
+ {0x38, 0x44, 0x44, 0x48, 0x7F}, /* d 100 */
+ {0x38, 0x54, 0x54, 0x54, 0x18}, /* e 101 */
+ {0x08, 0x7E, 0x09, 0x01, 0x02}, /* f 102 */
+ {0x0C, 0x52, 0x52, 0x52, 0x3E}, /* g 103 */
+ {0x7F, 0x08, 0x04, 0x04, 0x78}, /* h 104 */
+ {0x00, 0x44, 0x7D, 0x40, 0x00}, /* i 105 */
+ {0x20, 0x40, 0x44, 0x3D, 0x00}, /* j 106 */
+ {0x7F, 0x10, 0x28, 0x44, 0x00}, /* k 107 */
+ {0x00, 0x41, 0x7F, 0x40, 0x00}, /* l 108 */
+ {0x78, 0x04, 0x18, 0x04, 0x78}, /* m 109 */
+ {0x7C, 0x08, 0x04, 0x04, 0x78}, /* n 110 */
+ {0x38, 0x44, 0x44, 0x44, 0x38}, /* o 111 */
+ {0x7C, 0x14, 0x14, 0x14, 0x08}, /* p 112 */
+ {0x08, 0x14, 0x14, 0x18, 0x7C}, /* q 113 */
+ {0x7C, 0x08, 0x04, 0x04, 0x08}, /* r 114 */
+ {0x48, 0x54, 0x54, 0x54, 0x20}, /* s 115 */
+ {0x04, 0x3F, 0x44, 0x40, 0x20}, /* t 116 */
+ {0x3C, 0x40, 0x40, 0x20, 0x7C}, /* u 117 */
+ {0x1C, 0x20, 0x40, 0x20, 0x1C}, /* v 118 */
+ {0x3C, 0x40, 0x30, 0x40, 0x3C}, /* w 119 */
+ {0x44, 0x28, 0x10, 0x28, 0x44}, /* x 120 */
+ {0x0C, 0x50, 0x50, 0x50, 0x3C}, /* y 121 */
+ {0x44, 0x64, 0x54, 0x4C, 0x44}, /* z 122 */
+ {0x00, 0x08, 0x36, 0x41, 0x00}, /* { 123 */
+ {0x00, 0x00, 0x7F, 0x00, 0x00}, /* | 124 */
+ {0x00, 0x41, 0x36, 0x08, 0x00}, /* } 125 */
+ {0x0C, 0x02, 0x0C, 0x10, 0x0C}, /* ~ 126 */
+ {0x00, 0x00, 0x00, 0x00, 0x00} /* 127 */
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/EVAL_ADXL362_ARDZ/Lcd.h Wed May 18 16:57:57 2016 +0300
@@ -0,0 +1,138 @@
+/**
+ ******************************************************************************
+ * @file Lcd.c
+ * @brief Header file for ST7565R LCD control.
+ * @author ADI
+ * @date March 2016
+ *
+ *******************************************************************************
+ * Copyright 2015(c) Analog Devices, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Analog Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * - The use of this software may or may not infringe the patent rights
+ * of one or more patent holders. This license does not release you
+ * from the requirement that you obtain separate licenses from these
+ * patent holders to use this software.
+ * - Use of the software either in source or binary form, must be run
+ * on or directly connected to an Analog Devices Inc. component.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *******************************************************************************
+ **/
+#ifndef LCD_H_
+#define LCD_H_
+
+
+/******************************************************************************/
+/***************************** Include Files **********************************/
+/******************************************************************************/
+#include <stdio.h>
+#include "mbed.h"
+
+class Lcd
+{
+public:
+
+ const static uint8_t pui8Rec8x8[8];
+ const static uint8_t pui8RecInv8x8[8];
+ const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14)
+
+ Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6,
+ PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK =
+ SPI_SCK);
+ void init(void);
+ void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str);
+ void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width,
+ const uint8_t *pui8symbol);
+ void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data);
+ void set_line(uint8_t ui8line);
+ void set_cursor(uint8_t ui8PA, uint8_t ui8CA);
+ void bl_enable();
+ void bl_disable();
+
+ void write_cmd(uint8_t cmd);
+ void write_data(uint8_t data);
+
+
+ typedef enum {
+ CMD_DISPLAY_OFF = 0xAE,
+ CMD_DISPLAY_ON = 0xAF,
+ CMD_SET_DISP_START_LINE = 0x40,
+ CMD_SET_PAGE = 0xB0,
+ CMD_SET_COLUMN_UPPER = 0x10,
+ CMD_SET_COLUMN_LOWER = 0x00,
+ CMD_SET_ADC_NORMAL = 0xA0,
+ CMD_SET_ADC_REVERSE = 0xA1,
+ CMD_SET_DISP_NORMAL = 0xA6,
+ CMD_SET_DISP_REVERSE = 0xA7,
+ CMD_SET_ALLPTS_NORMAL = 0xA4,
+ CMD_SET_ALLPTS_ON = 0xA5,
+ CMD_SET_BIAS_9 = 0xA2,
+ CMD_SET_BIAS_7 = 0xA3,
+ CMD_RMW = 0xE0,
+ CMD_RMW_CLEAR = 0xEE,
+ CMD_INTERNAL_RESET = 0xE2,
+ CMD_SET_COM_NORMAL = 0xC0,
+ CMD_SET_COM_REVERSE = 0xC8,
+ CMD_SET_POWER_CONTROL = 0x28,
+ CMD_SET_RESISTOR_RATIO = 0x20,
+ CMD_SET_VOLUME_FIRST = 0x81,
+ CMD_SET_VOLUME_SECOND = 0,
+ CMD_SET_STATIC_OFF = 0xAC,
+ CMD_SET_STATIC_ON = 0xAD,
+ CMD_SET_STATIC_REG = 0x0,
+ CMD_SET_BOOSTER_FIRST = 0xF8,
+ CMD_SET_BOOSTER_234 = 0,
+ CMD_SET_BOOSTER_5 = 1,
+ CMD_SET_BOOSTER_6 = 3,
+ CMD_NOP = 0xE3,
+ CMD_TEST = 0xF0,
+ } lcd_commands_t;
+
+ static const uint8_t LCD_COLUMNS = 128u;
+ static const uint8_t LCD_PAGES = 4u;
+ static const uint8_t LCD_LINES = 64u;
+ static const uint8_t UP_X = 112;
+ static const uint8_t LEFT_X = 104;
+ static const uint8_t RIGHT_X = 120;
+ static const uint8_t DOWN_X = 112;
+ static const uint8_t CENTER_X = 112;
+ static const uint8_t ACC_LIMIT = 80;
+ static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y
+ static const uint8_t OFFS_ASCII = 32; ///< ASCII offset
+
+ static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C
+ static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code)
+
+private:
+
+ DigitalOut rst, a0, bl, cs;
+ SPI lcd_spi;
+
+
+
+};
+
+#endif /* LCD_H_ */
--- a/libraries/ad5270/AD5270.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,283 +0,0 @@
-/**
-* @file AD5270.cpp
-* @brief Source file for AD5270 rheostat
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad5270
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-
-#include "mbed.h"
-#include "AD5270.h"
-
-/**
- * @brief AD5270 constructor, sets CS pin and SPI format
- * @param CS - (optional)chip select of the AD5270
- * @param max_resistance - (optional) nominal resistance of the AD5270 chip in ohms
- * @param MOSI - (optional)pin of the SPI interface
- * @param MISO - (optional)pin of the SPI interface
- * @param SCK - (optional)pin of the SPI interface
- */
-AD5270::AD5270(PinName CS, float max_resistance, PinName MOSI, PinName MISO, PinName SCK):
- ad5270(MOSI, MISO, SCK), cs(CS), _max_resistance(max_resistance)
-{
- cs = true;
- ad5270.format(8, _SPI_MODE);
-}
-
-/**
- * @brief Compute for the nearest RDAC value from given resistance
- * @param resistance - resistor
- * @return RDAC value - closest possible to given resistance
- */
-uint16_t AD5270::calc_RDAC(float resistance)
-{
- return static_cast<uint16_t>( (resistance / _max_resistance) * 1024.0 );
-}
-
-/**
- * @brief sets a new value for the RDAC
- * @param resistance new value for the resistance
- * @return actual value of the resistance in the RDAC
- */
-float AD5270::write_RDAC(float resistance)
-{
- // Compute for the RDAC code nearest to the required feedback resistance
- uint16_t RDAC_val = calc_RDAC(resistance);
- float RDAC_Value = ((static_cast<float> (RDAC_val) * _max_resistance) / 1024.0); // inverse operation to get actual resistance in the RDAC
- write_wiper_reg(RDAC_val);
- return RDAC_Value;
-}
-
-/**
- * Reads the RDAC register
- * @return RDAC resistor value
- */
-float AD5270::read_RDAC()
-{
- uint16_t RDAC_val = read_wiper_reg();
- return ((static_cast<float> (RDAC_val) * _max_resistance) / 1024.0);
-}
-
-/**
- * @brief Puts the AD5270 SDO line in to Hi-Z mode
- * @return none
- */
-void AD5270::set_SDO_HiZ(void)
-{
- write_reg(HI_Z_Cmd);
- wait_us(2);
- write_reg(NO_OP_cmd);
-}
-
-/**
- * @brief Set AD5270 SPI frequency
- * @param hz - SPI bus frequency in hz
- * @return none
- */
-void AD5270::frequency(int hz)
-{
- ad5270.frequency(hz);
-}
-
-/**
- * @brief Issues AD5270 a command
- * @param command - command to be sent
- * @param data - (optional)value for the requested command
- * @return response form the AD5270
- */
-uint16_t AD5270::write_cmd(uint8_t command, uint16_t data)
-{
- /* build 16 bit data to be written - Command + Value */
- uint16_t ui16Command = ((command & 0x3C) << 8) | (data & 0x3FF);
- return write_reg(ui16Command);
-}
-
-/**
- * Enables the 50TP memory programming
- */
-void AD5270::enable_50TP_programming()
-{
- uint8_t regVal = read_ctrl_reg();
- write_cmd(WRITE_CTRL_REG, regVal | PROGRAM_50TP_ENABLE); // RDAC register write protect - allow update of wiper position through digital interface
-}
-
-/**
- * Stores current RDAC content to the 50TP memory
- */
-void AD5270::store_50TP()
-{
- write_cmd(STORE_50TP);
- wait_ms(_WRITE_OPERATION_50TP_TIMEOUT);
-}
-
-/**
- * Disables the 50TP memory programming
- */
-void AD5270::disable_50TP_programming()
-{
- uint8_t regVal = read_ctrl_reg();
- write_cmd(WRITE_CTRL_REG, regVal & (~PROGRAM_50TP_ENABLE));
-}
-
-/**
- * @brief Writes 16bit data to the AD5270 SPI interface
- * @param data to be written
- * @return data returned by the AD5270
- */
-uint16_t AD5270::write_reg(uint16_t data)
-{
- uint16_t result;
- uint8_t upper_byte = (data >> 8) & 0xFF;
- uint8_t lower_byte = data & 0xFF;
- ad5270.format(8, _SPI_MODE);
- cs = false;
- result = ((ad5270.write(upper_byte)) << 8);
- result |= ad5270.write(lower_byte);
- cs = true;
- return result;
-}
-
-/**
- * @brief Gets maximum resistance of the AD5270 digital rheostat
- * @return maximum resistance in ohms
- */
-float AD5270::get_max_resistance()
-{
- return _max_resistance;
-}
-
-/**
- * Writes the wiper register. This includes reading the control register,
- * setting write protect off, writing the wiper, and reverting the settings
- * to the control reg.
- * @param data to be written
- */
-void AD5270::write_wiper_reg(uint16_t data)
-{
- uint8_t reg_val = read_ctrl_reg();
- write_cmd(WRITE_CTRL_REG, reg_val | RDAC_WRITE_PROTECT); // RDAC register write protect - allow update of wiper position through digital interface
- write_cmd(WRITE_RDAC, data); // write data to the RDAC register
- write_cmd(WRITE_CTRL_REG, reg_val); // RDAC register write protect - allow update of wiper position through digital interface
-}
-
-/**
- * Reads the wiper register value
- * @return value of the wiper register
- */
-uint16_t AD5270::read_wiper_reg(void)
-{
- uint16_t RDAC_val;
- write_cmd(READ_RDAC);
- wait_us(_REG_OPERATION_TIMEOUT);
- RDAC_val = write_cmd(NO_OP);
- return RDAC_val;
-}
-
-/**
- * Reads the last programmed value of the 50TP memory
- * @return last programmed value
- */
-uint8_t AD5270::read_50TP_last_address(void)
-{
- uint8_t ret_val;
- write_cmd(READ_50TP_ADDRESS);
- wait_us(_MEMORY_OPERATION_TIMEOUT);
- ret_val = write_cmd(NO_OP);
- return ret_val;
-}
-
-/**
- * Reads the content of a 50TP memory address
- * @param address memory to be read
- * @return value stored in the 50TP address
- */
-uint16_t AD5270::read_50TP_memory(uint8_t address)
-{
- uint16_t ret_val;
- write_cmd(READ_50TP_CONTENTS, address);
- wait_us(_MEMORY_OPERATION_TIMEOUT);
- ret_val = write_cmd(NO_OP);
- return ret_val;
-}
-
-/**
- * Writes the control register
- * @param data to be written
- */
-void AD5270::write_ctrl_reg(uint8_t data)
-{
- write_cmd(WRITE_CTRL_REG, data);
-}
-
-/**
- * Reads the control register
- * @return value of the control register
- */
-uint8_t AD5270::read_ctrl_reg(void)
-{
- uint8_t ret_val;
- write_cmd(READ_CTRL_REG);
- wait_us(_REG_OPERATION_TIMEOUT);
- ret_val = write_cmd(NO_OP);
- return ret_val;
-}
-
-/**
- * Resets the wiper register value to the data last written in the 50TP
- */
-void AD5270::reset_RDAC(void)
-{
- write_cmd(SW_RST);
-}
-
-/**
- * Changes the device mode, enabled or shutdown
- * @param mode - new mode of the device
- */
-void AD5270::change_mode(AD5270Modes_t mode)
-{
- write_cmd(SW_SHUTDOWN, static_cast<uint8_t>(mode));
-}
-
-
-
--- a/libraries/ad5270/AD5270.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/**
-* @file AD5270.h
-* @brief Header file for AD5270 rheostat
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad5270
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef AD5270_H
-#define AD5270_H
-
-#include "mbed.h"
-
-/**
- * @brief Analog Devices AD5270 SPI Digital Rheostat class
- */
-class AD5270
-{
-public:
-
- /// AD5270 commands
- typedef enum {
- NO_OP = 0x00, ///< No data
- NO_OP_cmd = 0x0000, ///< 16 bit no data
- WRITE_RDAC = 0x04, ///< Write to the RDAC Register
- READ_RDAC = 0x08, ///< Read from the RDAC Register
- STORE_50TP = 0x0C, ///< Write from RDAC to memory
- SW_RST = 0x10, ///< Software reset to last memory location
- READ_50TP_CONTENTS = 0x14, ///< Read the last memory contents
- READ_50TP_ADDRESS = 0x18, ///< Read the last memory address
- WRITE_CTRL_REG = 0x1C, ///< Write to the control Register
- READ_CTRL_REG = 0x20, ///< Read from the control Register
- SW_SHUTDOWN = 0x24, ///< Software shutdown (0) - Normal, (1) - Shutdown
- HI_Zupper = 0x80, ///< Get the SDO line ready for High Z
- HI_Zlower = 0x01, ///< Puts AD5270 into High Z mode
- HI_Z_Cmd = 0x8001 ///< Puts AD5270 into High Z mode*/
- } AD5270Commands_t;
-
- typedef enum {
- NORMAL_MODE = 0,
- SHUTDOWN_MODE = 1
- } AD5270Modes_t;
-
- typedef enum {
- PROGRAM_50TP_ENABLE = 1,
- RDAC_WRITE_PROTECT = 2,
- R_PERFORMANCE_ENABLE = 4,
- MEMORY_PROGRAM_SUCCESFUL = 8
- } AD5270ControlRegisterBits_t;
-
- // SPI configuration & constructor
- AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
- void frequency(int hz);
-
- /* RDAC commands */
- void write_ctrl_reg(uint8_t data);
- uint8_t read_ctrl_reg(void);
- void change_mode(AD5270Modes_t mode);
- void set_SDO_HiZ(void);
-
- /* Wiper R/W methods*/
- void reset_RDAC(void);
- void write_wiper_reg(uint16_t data);
- uint16_t read_wiper_reg(void);
-
-
- /* Low level methods */
- uint16_t write_cmd(uint8_t command, uint16_t data = 0x00);
- uint16_t write_reg(uint16_t data);
-
- /* Methods that deal with resistance in float format*/
- uint16_t calc_RDAC(float resistance);
- float write_RDAC(float resistance);
- float read_RDAC(void);
- float get_max_resistance(void);
-
- /* 50 TP methods */
- void enable_50TP_programming(void);
- void store_50TP(void);
- void disable_50TP_programming(void);
- uint8_t read_50TP_last_address(void);
- uint16_t read_50TP_memory(uint8_t address);
-
- SPI ad5270; ///< SPI instance of the AD5270
- DigitalOut cs; ///< DigitalOut instance for the chip select of the AD5270
-
-private:
- const static int _RESET = 0xff;
- const static int _REG_OPERATION_TIMEOUT = 2;
- const static int _MEMORY_OPERATION_TIMEOUT = 6;
- const static int _WRITE_OPERATION_50TP_TIMEOUT = 350;
- const static int _DUMMY_BYTE = 0xAA;
- const static uint8_t _SPI_MODE = 1;
- float _max_resistance;
-};
-
-#endif
--- a/libraries/ad7790/AD7790.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,399 +0,0 @@
-/**
-* @file AD7790.cpp
-* @brief Source file for AD7790 ADC
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad7790
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include <stdint.h>
-#include "mbed.h"
-#include "AD7790.h"
-
-/**
- * @brief AD7790 constructor, sets CS pin and SPI format
- * @param CS - (optional)chip select of the AD7790
- * @param MOSI - (optional)pin of the SPI interface
- * @param MISO - (optional)pin of the SPI interface
- * @param SCK - (optional)pin of the SPI interface
- */
-AD7790::AD7790(float reference_voltage,
- PinName CS,
- PinName MOSI,
- PinName MISO,
- PinName SCK) :
- miso(MISO), ad7790(MOSI, MISO, SCK), cs(CS), _vref(reference_voltage), _PGA_gain(1)
-{
- cs = true; // cs is active low
- ad7790.format(8, _SPI_MODE);
- _continous_conversion = true;
- _channel = DIFFERENTIAL;
-}
-
-/**
- * @brief Set AD7790 SPI frequency
- * @param hz - SPI bus frequency in hz
- * @return none
- */
-void AD7790::frequency(int hz)
-{
- ad7790.frequency(hz);
-}
-
-/**
- * @brief Resets the AD7790
- * @return none
- */
-void AD7790::reset()
-{
- ad7790.format(8, _SPI_MODE);
- cs = false;
- wait_us(_DELAY_TIMING);
- ad7790.write(_RESET);
- ad7790.write(_RESET);
- ad7790.write(_RESET);
- ad7790.write(_RESET);
- wait_us(_DELAY_TIMING);
- cs = true;
- _continous_conversion = true;
-}
-
-/**
- * Sets the mode register. Also sets continous mode and range based on the value
- * written in reg_val
- * @param reg_val
- */
-void AD7790::write_mode_reg(uint8_t reg_val)
-{
- write_reg(MODE_REG, reg_val);
- uint8_t continous_mode = (reg_val & 0xC0);
- if(continous_mode == 0x00) {
- _continous_conversion = true;
- } else {
- _continous_conversion = false;
- }
- uint8_t range = (reg_val & 0x30);
- _PGA_gain = 1 << (range >> 4);
-}
-
-/**
- * Reads the mode register and returns its value
- * @return value of the mode register
- */
-uint8_t AD7790::read_mode_reg()
-{
- return read_reg(MODE_REG);
-}
-
-/**
- * Writes the filter register
- * @param regValue value to be written.
- */
-void AD7790::write_filter_reg(uint8_t reg_val)
-{
- write_reg(FILTER_REG, reg_val);
-}
-
-/**
- * Reads the filter register and returns its value
- * @return the value of the filter register
- */
-uint8_t AD7790::read_filter_reg()
-{
- return read_reg(FILTER_REG);
-}
-
-/**
- * Reads the data register and returns its value
- * @return value of the data register
- */
-uint16_t AD7790::read_data_reg()
-{
- uint16_t data_result;
- ad7790.format(8, _SPI_MODE);
- cs = false;
- ad7790.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
- data_result = ((ad7790.write(_DUMMY_BYTE)) << 8);
- data_result |= (ad7790.write(_DUMMY_BYTE));
- cs = true;
- return data_result;
-}
-
-/**
- * Reads the status register of the ADC and returns its value
- * @return value of the status reg
- */
-uint8_t AD7790::read_status_reg()
-{
- return read_reg(STATUS_REG);
-}
-
-
-/**
- * @brief Enables/disables continous_conversion mode
- * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
- * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
- * When the pin is driven low, data register is read back from the ADC.
- *
- * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
- * the data register is read back from the ADC.
- *
- * @param mode
- * true - continous conversion mode enabled
- * false - single conversion mode enabled
- */
-void AD7790::set_conversion_mode(AD7790Mode_t mode)
-{
- uint8_t mode_reg_val;
- mode_reg_val = read_mode_reg() & 0x3F;
- mode_reg_val = mode_reg_val | (static_cast<uint8_t>(mode));
- write_mode_reg(mode);
-}
-
-/**
- * - From mbed AnalogIn API -
- * @brief Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
- * Depending on the conversion mode, this method will have different behavior. Conversion mode is set using
- * set_continous_conversion_mode(bool).
- *
- * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
- * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
- * When the pin is driven low, data register is read back from the ADC.
- *
- * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
- * the data register is read back from the ADC.
- *
- * @return 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
- * returns -1 (0xFFFF) along with a debug message if conversion failed.
- */
-uint16_t AD7790::read_u16(void)
-{
- uint16_t data_result = 0;
- ad7790.format(8, _SPI_MODE);
- cs = false;
- uint16_t timeout_cnt = 0;
- if(_continous_conversion == false) {
-
- uint8_t mode_reg = read_mode_reg();
- wait_us(_DELAY_TIMING);
-
- cs = false;
- mode_reg = (mode_reg & 0x3F) | MD1; // mask single conversion bits
- ad7790.write((MODE_REG << 4) | (static_cast<uint8_t>(_channel))); // start single conversion
- ad7790.write(mode_reg);
- timeout_cnt = _SINGLE_CONVERSION_TIMEOUT; // starts timeout
- } else {
- timeout_cnt = _CONTINOUS_CONVERSION_TIMEOUT; // starts timeout
- }
- wait_us(1);
-
- while(miso) { // wait for the MISO pin to go low.
- if(timeout_cnt) {
- timeout_cnt--;
- } else {
- cs = true;
-#ifdef AD7790_DEBUG_MODE
- printf("timeout occurred reading the AD7790. "); // error, MISO line didn't toggle
-#endif
- return -1; // ERROR
- }
- wait_us(10);
- }
-
- ad7790.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
- data_result = ((ad7790.write(_DUMMY_BYTE)) << 8);
- data_result |= (ad7790.write(_DUMMY_BYTE));
- cs = true;
- return data_result;
-}
-
-/**
- * @brief Reads a register of the AD7790
- * @param address - address of the register
- * @return value of the register
- */
-uint16_t AD7790::read_reg(AD7790Register_t address)
-{
- uint16_t data = address << 12;
- data |= _DUMMY_BYTE;
- data |= _READ_FLAG;
- data |= (static_cast<uint8_t>(_channel) << 8);
- return write_spi(data);
-}
-
-/**
- * @brief Writes a register of the AD7790
- * @param address - address of the register
- * @param reg_val - value to be written
- * @return none
- *
- */
-void AD7790::write_reg(AD7790Register_t address, uint8_t reg_val)
-{
- uint16_t spi_data = address << 12;
- spi_data |= reg_val;
- spi_data |= (static_cast<uint8_t>(_channel) << 8);
- write_spi(spi_data);
-}
-
-/**
- * @brief Writes 16bit data to the AD7790 SPI interface
- * @param reg_val to be written
- * @return data returned by the AD7790
- */
-uint16_t AD7790::write_spi(uint16_t reg_val)
-{
- uint16_t data_result;
- uint8_t upper_byte = (reg_val >> 8) & 0xFF;
- uint8_t lower_byte = reg_val & 0xFF;
- ad7790.format(8, _SPI_MODE);
- cs = false;
- data_result = (ad7790.write(upper_byte) << 8);
- data_result |= ad7790.write(lower_byte);
- cs = true;
- return data_result;
-}
-
-
-/**
- * Sets the AnalogInputRange to be used by the AD7790
- * @param range AnalogInputRange_t to be used in voltage computations
- */
-void AD7790::set_range(AnalogInputRange_t range)
-{
-
- uint8_t mode_reg_val;
- mode_reg_val = read_mode_reg() & 0xCF;
- mode_reg_val = mode_reg_val | (range << 4);
- write_mode_reg(mode_reg_val);
-}
-
-/**
- * Sets the reference voltage of the AD7790
- * @param ref reference voltage to be set
- */
-void AD7790::set_reference_voltage(float ref)
-{
- _vref = ref;
-}
-
-/**
- * Gets the reference voltage of the AD7790
- * @return reference voltage
- */
-float AD7790::get_reference_voltage(void)
-{
- return _vref;
-}
-
-/**
- * Reads the data register of the ADC and converts the result to volts
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @return voltage of the ADC input
- */
-float AD7790::read_voltage(void)
-{
- return data_to_voltage(read_u16());
-}
-
-/**
- * Converts an uint16_t to voltage.
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @param data in uint16_t format
- * @return float value of voltage (in V)
- */
-float AD7790::data_to_voltage(uint16_t data)
-{
- return ((data / static_cast<float>(_RESOLUTION / 2)) - 1) * (_vref / _PGA_gain);
-}
-
-/**
- * Converts voltage to an uint16_t.
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @param voltage to be converted
- * @return data in uint16_t format
- */
-uint16_t AD7790::voltage_to_data(float voltage)
-{
- return (((voltage * _PGA_gain / _vref) + 1) * static_cast<float>(_RESOLUTION / 2));
-}
-
-/**
- * Sets the conversion channel.
- * @param channel
- */
-void AD7790::set_channel(AD7790Channel_t channel)
-{
- _channel = channel;
-}
-
-/**
- * - From mbed AnalogIn API -
- * Read the input voltage, represented as a float in the range [0.0, 1.0] - uses the read_u16 method
- * @returns A floating-point value representing the current input voltage, measured as a percentage
- * returns 1.0 along with a debug message if the conversion failed
- */
-float AD7790::read(void)
-{
- float percent;
- uint16_t data;
- data = read_u16();
- percent = (data / static_cast<float>(_RESOLUTION) ); // translate bipolar conversion to [0.0, 1.0] domain
- return percent;
-}
-
-#ifdef MBED_OPERATORS
-
-/**
- * - From mbed AnalogIn API -
- * An operator shorthand for read()
- * The float() operator can be used as a shorthand for read() to simplify common code sequences
- */
-AD7790::operator float()
-{
- return read();
-}
-
-#endif
-
-
-
--- a/libraries/ad7790/AD7790.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/**
-* @file AD7790.h
-* @brief Header file for AD7790 ADC
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad7790
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef AD7790_H
-#define AD7790_H
-
-#include "mbed.h"
-
-/**
- * Comment this line if you want to turn off the debug mode.
- * The debug mode will send a message if an exception occurs within AD7790 driver
- */
-
-#define AD7790_DEBUG_MODE
-
-/**
- * @brief Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC
- */
-class AD7790
-{
-public:
- /// AD7790 registers
- typedef enum {
- COMMUNICATION_REG = 0, ///< Communication register
- STATUS_REG = 0, ///< Status register
- MODE_REG, ///< Mode register
- FILTER_REG, ///< Filter Register
- DATA_REG ///< Data register
- } AD7790Register_t;
-
- /// AD7790 channel configuration
- typedef enum {
- DIFFERENTIAL = 0, ///< AIN(+)-AIN(-)
- RESERVED, ///< reserved
- SHORT, ///< AIN(-)-AIN(-)
- VDDMONITOR ///< Monitor VDD
- } AD7790Channel_t;
-
- typedef enum {
- CONTINOUS_CONVERSION_MODE = 0,
- SINGLE_CONVERSION_MODE = 0x80,
- SHUTDOWN_MODE = 0xC0
- } AD7790Mode_t;
-
- typedef enum {
- MD1 = 0x80, ///< Mode Select Bit 1
- MD0 = 0x40, ///< Mode Select Bit 0
- G1 = 0x20, ///< Range bit 1
- G0 = 0x10, ///< Range bit 0
- BO = 0x08, ///< Burnout Current Enable bit
- BUF = 0x02, ///< Buffered mode bit
- } ModeRegisterBits_t;
-
- typedef enum {
- CLKDIV1 = 0x40, ///< Clock divider bit 1
- CLKDIV0 = 0x20, ///< Clock divider bit 0
- FS2 = 0x04, ///< Update rate bit 2
- FS1 = 0x02, ///< Update rate bit 1
- FS0 = 0x01, ///< Update rate bit 0
- } FilterRegisterBits_t;
-
- typedef enum {
- RANGE_VREF = 0,
- RANGE_VREF_DIV_2,
- RANGE_VREF_DIV_4,
- RANGE_VREF_DIV_8,
- } AnalogInputRange_t;
-
- /** SPI configuration & constructor */
- AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
- void frequency(int hz);
-
- /** Low level SPI bus comm methods */
- void reset(void);
-
- /** Register access methods*/
- void set_channel(AD7790Channel_t channel);
- void set_conversion_mode(AD7790Mode_t mode);
- uint16_t read_data_reg();
- uint8_t read_status_reg(void);
- void write_filter_reg(uint8_t regVal);
- uint8_t read_filter_reg(void);
- void write_mode_reg(uint8_t regVal);
- uint8_t read_mode_reg(void);
- void set_range(AnalogInputRange_t range);
- AnalogInputRange_t get_range(void);
-
- /** Reference voltage methods */
- void set_reference_voltage(float ref);
- float get_reference_voltage(void);
-
- /** Voltage read methods */
- float read_voltage(void);
- float data_to_voltage(uint16_t data);
- uint16_t voltage_to_data(float voltage);
-
- /** AnalogIn API */
- float read(void);
- uint16_t read_u16(void);
-
-#ifdef MBED_OPERATORS
- operator float();
-#endif
-
-private:
- DigitalIn miso;///< DigitalIn must be initialized before SPI to prevent pin MUX overwrite
- SPI ad7790; ///< SPI instance of the AD7790
- DigitalOut cs; ///< DigitalOut instance for the chipselect of the AD7790
-
- float _vref;
- uint8_t _PGA_gain;
- bool _continous_conversion;
- AD7790Channel_t _channel;
-
- void write_reg(AD7790Register_t regAddress, uint8_t regValue);
- uint16_t write_spi(uint16_t data);
- uint16_t read_reg (AD7790Register_t regAddress);
-
- const static uint16_t _SINGLE_CONVERSION_TIMEOUT = 0xFFFF; // in 10us = 100ms
- const static uint16_t _CONTINOUS_CONVERSION_TIMEOUT = 0xFFFF;
- const static uint16_t _RESOLUTION = 0xFFFF;
- const static uint8_t _RESET = 0xFF;
- const static uint8_t _DUMMY_BYTE = 0xFF;
- const static uint16_t _READ_FLAG = 0x0800;
- const static uint8_t _DATA_READ = 0x38; // Read from the Data Register
- const static uint8_t _DELAY_TIMING = 0x02;
- const static uint8_t _SPI_MODE = 3;
-};
-
-#endif
--- a/libraries/ad7791/AD7791.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/**
-* @file AD7791.cpp
-* @brief Source file for AD7791 ADC
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad7791
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include <stdint.h>
-#include "mbed.h"
-#include "AD7791.h"
-
-/**
- * @brief AD7791 constructor, sets CS pin and SPI format
- * @param reference_voltage - the reference voltage to be used in computation
- * @param CS - (optional)chip select of the AD7791
- * @param MOSI - (optional)pin of the SPI interface
- * @param MISO - (optional)pin of the SPI interface
- * @param SCK - (optional)pin of the SPI interface
- */
-AD7791::AD7791(float reference_voltage,
- PinName CS,
- PinName MOSI,
- PinName MISO,
- PinName SCK) :
- miso(MISO), ad7791(MOSI, MISO, SCK), cs(CS), _vref(reference_voltage)
-{
- cs = true; // cs is active low
- ad7791.format(8, _SPI_MODE);
- _continous_conversion = true;
- _channel = DIFFERENTIAL;
-}
-
-/**
- * @brief Set AD7791 SPI frequency
- * @param hz - SPI bus frequency in hz
- * @return none
- */
-void AD7791::frequency(int hz)
-{
- ad7791.frequency(hz);
-}
-
-/**
- * @brief Resets the AD7791
- * @return none
- */
-void AD7791::reset()
-{
- ad7791.format(8, _SPI_MODE);
- cs = false;
- wait_us(_DELAY_TIMING);
- ad7791.write(_RESET);
- ad7791.write(_RESET);
- ad7791.write(_RESET);
- ad7791.write(_RESET);
- wait_us(_DELAY_TIMING);
- cs = true;
- _continous_conversion = true;
-}
-
-/**
- * Sets the mode register. Also sets continous mode and range based on the value
- * written in reg_val
- * @param reg_val
- */
-void AD7791::write_mode_reg(uint8_t reg_val)
-{
- write_reg(MODE_REG, reg_val);
- uint8_t continous_mode = (reg_val & 0xC0);
- if(continous_mode == 0x00) {
- _continous_conversion = true;
- } else {
- _continous_conversion = false;
- }
- /* uint8_t range = (reg_val & 0x30);
- _PGA_gain = 1 << (range >> 4);*/
-
-}
-
-/**
- * Reads the mode register and returns its value
- * @return value of the mode register
- */
-uint8_t AD7791::read_mode_reg()
-{
- return read_reg(MODE_REG);
-}
-
-/**
- * Writes the filter register
- * @param regValue value to be written.
- */
-void AD7791::write_filter_reg(uint8_t reg_val)
-{
- write_reg(FILTER_REG, reg_val);
-}
-
-/**
- * Reads the filter register and returns its value
- * @return the value of the filter register
- */
-uint8_t AD7791::read_filter_reg()
-{
- return read_reg(FILTER_REG);
-}
-
-/**
- * Reads the data register and returns its value
- * @return value of the data register
- */
-uint32_t AD7791::read_data_reg()
-{
- uint32_t data_result;
- ad7791.format(8, _SPI_MODE);
- cs = false;
- ad7791.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
- data_result = ((ad7791.write(_DUMMY_BYTE)) << 16);
- data_result |= ((ad7791.write(_DUMMY_BYTE)) << 8 );
- data_result |= (ad7791.write(_DUMMY_BYTE));
- cs = true;
- return data_result;
-}
-
-/**
- * Reads the status register of the ADC and returns its value
- * @return value of the status reg
- */
-uint8_t AD7791::read_status_reg()
-{
- return read_reg(STATUS_REG);
-}
-
-
-/**
- * @brief Enables/disables continous_conversion mode
- * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
- * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
- * When the pin is driven low, data register is read back from the ADC.
- *
- * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
- * the data register is read back from the ADC.
- *
- * @param mode
- * true - continous conversion mode enabled
- * false - single conversion mode enabled
- */
-void AD7791::set_conversion_mode(AD7791Mode_t mode)
-{
- uint8_t mode_reg_val;
- mode_reg_val = read_mode_reg() & 0x3F;
- mode_reg_val = mode_reg_val | (static_cast<uint8_t>(mode));
- write_mode_reg(mode);
-}
-
-/**
- * - From mbed AnalogIn API -
- * @brief Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
- * Depending on the conversion mode, this method will have different behavior. Conversion mode is set using
- * set_continous_conversion_mode(bool).
- *
- * In Single Conversion mode, read_u16 method will read the MODE register of the ADC,
- * then write the Start single conversion bit and wait for the DOUT/RDY pin to go low,
- * When the pin is driven low, data register is read back from the ADC.
- *
- * In Continous conversion mode, read_u16 method will poll the DOUT/RDY pin, if it is low,
- * the data register is read back from the ADC.
- *
- * @return 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
- * returns -1 (0xFFFF) along with a debug message if conversion failed.
- */
-uint32_t AD7791::read_u32(void)
-{
- uint32_t data_result = 0;
- ad7791.format(8, _SPI_MODE);
- cs = false;
- uint16_t timeout_cnt = 0;
- if(_continous_conversion == false) {
-
- uint8_t mode_reg = read_mode_reg();
- wait_us(_DELAY_TIMING);
-
- cs = false;
- mode_reg = (mode_reg & 0x3F) | MD1; // mask single conversion bits
- ad7791.write((MODE_REG << 4) | (static_cast<uint8_t>(_channel))); // start single conversion
- ad7791.write(mode_reg);
- timeout_cnt = _SINGLE_CONVERSION_TIMEOUT; // starts timeout
- } else {
- timeout_cnt = _CONTINOUS_CONVERSION_TIMEOUT; // starts timeout
- }
- wait_us(1);
-
- while(miso) { // wait for the MISO pin to go low.
- if(timeout_cnt) {
- timeout_cnt--;
- } else {
- cs = true;
-#ifdef AD7791_DEBUG_MODE
- printf("timeout occurred reading the AD7791. "); // error, MISO line didn't toggle
-#endif
- return -1; // ERROR
- }
- wait_us(10);
- }
-
- ad7791.write(_DATA_READ | (static_cast<uint8_t>(_channel)));
- data_result = ((ad7791.write(_DUMMY_BYTE)) << 16);
- data_result |= ((ad7791.write(_DUMMY_BYTE)) << 8 );
- data_result |= (ad7791.write(_DUMMY_BYTE));
- cs = true;
- return data_result;
-}
-
-uint16_t AD7791::read_u16(void)
-{
- uint32_t data = read_u32();
- return static_cast<uint16_t>((data & 0xffff00) >> 8);
-}
-
-/**
- * @brief Reads a register of the AD7791
- * @param address - address of the register
- * @return value of the register
- */
-uint16_t AD7791::read_reg(AD7791Register_t address)
-{
- uint16_t data = address << 12;
- data |= _DUMMY_BYTE;
- data |= _READ_FLAG;
- data |= (static_cast<uint8_t>(_channel) << 8);
- return write_spi(data);
-}
-
-/**
- * @brief Writes a register of the AD7791
- * @param address - address of the register
- * @param reg_val - value to be written
- * @return none
- *
- */
-void AD7791::write_reg(AD7791Register_t address, uint8_t reg_val)
-{
- uint16_t spi_data = address << 12;
- spi_data |= reg_val;
- spi_data |= (static_cast<uint8_t>(_channel) << 8);
- write_spi(spi_data);
-}
-
-/**
- * @brief Writes 16bit data to the AD7791 SPI interface
- * @param reg_val to be written
- * @return data returned by the AD7791
- */
-uint16_t AD7791::write_spi(uint16_t reg_val)
-{
- uint16_t data_result;
- uint8_t upper_byte = (reg_val >> 8) & 0xFF;
- uint8_t lower_byte = reg_val & 0xFF;
- ad7791.format(8, _SPI_MODE);
- cs = false;
- data_result = (ad7791.write(upper_byte) << 8);
- data_result |= ad7791.write(lower_byte);
- cs = true;
- return data_result;
-}
-
-/**
- * Sets the reference voltage of the AD7790
- * @param ref reference voltage to be set
- */
-void AD7791::set_reference_voltage(float ref)
-{
- _vref = ref;
-}
-
-/**
- * Gets the reference voltage of the AD7790
- * @return reference voltage
- */
-float AD7791::get_reference_voltage(void)
-{
- return _vref;
-}
-
-/**
- * Reads the data register of the ADC and converts the result to volts
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @return voltage of the ADC input
- */
-float AD7791::read_voltage(void)
-{
- return data_to_voltage(read_u32());
-}
-
-/**
- * Converts an uint16_t to voltage.
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @param data in uint16_t format
- * @return float value of voltage (in V)
- */
-float AD7791::data_to_voltage(uint32_t data)
-{
- return ((data / static_cast<float>(_RESOLUTION / 2)) - 1) * (_vref );
-}
-
-/**
- * Converts voltage to an uint16_t.
- * Gain needs to be correctly set using set_gain in order to get accurate results
- * @param voltage to be converted
- * @return data in uint16_t format
- */
-uint32_t AD7791::voltage_to_data(float voltage)
-{
- return (((voltage / _vref) + 1) * static_cast<float>(_RESOLUTION / 2));
-}
-
-/**
- * Sets the conversion channel.
- * @param channel
- */
-void AD7791::set_channel(AD7791Channel_t channel)
-{
- _channel = channel;
-}
-
-/**
- * - From mbed AnalogIn API -
- * Read the input voltage, represented as a float in the range [0.0, 1.0] - uses the read_u16 method
- * @returns A floating-point value representing the current input voltage, measured as a percentage
- * returns 1.0 along with a debug message if the conversion failed
- */
-float AD7791::read(void)
-{
- float percent;
- uint32_t data;
- data = read_u32();
- percent = (data / static_cast<float>(_RESOLUTION) ); // translate bipolar conversion to [0.0, 1.0] domain
- return percent;
-}
-
-#ifdef MBED_OPERATORS
-
-/**
- * - From mbed AnalogIn API -
- * An operator shorthand for read()
- * The float() operator can be used as a shorthand for read() to simplify common code sequences
- */
-AD7791::operator float()
-{
- return read();
-}
-
-#endif
-
-
-
--- a/libraries/ad7791/AD7791.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/**
-* @file AD7791.h
-* @brief Header file for AD7791 ADC
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/ad7791
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef AD7791_H
-#define AD7791_H
-
-#include "mbed.h"
-
-/**
- * Comment this line if you want to turn off the debug mode.
- * The debug mode will send a message if an exception occurs within AD7791 driver
- */
-
-#define AD7791_DEBUG_MODE
-
-/**
- * @brief Analog Devices AD7791 SPI 16-bit Buffered Sigma-Delta ADC
- */
-class AD7791
-{
-public:
- /// AD7791 registers
- typedef enum {
- COMMUNICATION_REG = 0, ///< Communication register
- STATUS_REG = 0, ///< Status register
- MODE_REG, ///< Mode register
- FILTER_REG, ///< Filter Register
- DATA_REG ///< Data register
- } AD7791Register_t;
-
- /// AD7791 channel configuration
- typedef enum {
- DIFFERENTIAL = 0, ///< AIN(+)-AIN(-)
- RESERVED, ///< reserved
- SHORT, ///< AIN(-)-AIN(-)
- VDDMONITOR ///< Monitor VDD
- } AD7791Channel_t;
-
- typedef enum {
- CONTINOUS_CONVERSION_MODE = 0,
- SINGLE_CONVERSION_MODE = 0x80,
- SHUTDOWN_MODE = 0xC0
- } AD7791Mode_t;
-
- typedef enum {
- MD1 = 0x80, ///< Mode Select Bit 1
- MD0 = 0x40, ///< Mode Select Bit 0
-// G1 = 0x20, ///< Range bit 1
-// G0 = 0x10, ///< Range bit 0
- BO = 0x08, ///< Burnout Current Enable bit
- UB = 0x04, ///< Unipolar/Bipolar bit
- BUF = 0x02, ///< Buffered mode bit
- } ModeRegisterBits_t;
-
- typedef enum {
- CLKDIV1 = 0x40, ///< Clock divider bit 1
- CLKDIV0 = 0x20, ///< Clock divider bit 0
- FS2 = 0x04, ///< Update rate bit 2
- FS1 = 0x02, ///< Update rate bit 1
- FS0 = 0x01, ///< Update rate bit 0
- } FilterRegisterBits_t;
-
- /* typedef enum {
- RANGE_VREF = 0,
- RANGE_VREF_DIV_2,
- RANGE_VREF_DIV_4,
- RANGE_VREF_DIV_8,
- } AnalogInputRange_t;
- */
- /** SPI configuration & constructor */
- AD7791( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
- void frequency(int hz);
-
- /** Low level SPI bus comm methods */
- void reset(void);
-
- /** Register access methods*/
- void set_channel(AD7791Channel_t channel);
- void set_conversion_mode(AD7791Mode_t mode);
- uint32_t read_data_reg();
- uint8_t read_status_reg(void);
- void write_filter_reg(uint8_t regVal);
- uint8_t read_filter_reg(void);
- void write_mode_reg(uint8_t regVal);
- uint8_t read_mode_reg(void);
-// void set_range(AnalogInputRange_t range);
-// AnalogInputRange_t get_range(void);
-
- /** Reference voltage methods */
- void set_reference_voltage(float ref);
- float get_reference_voltage(void);
-
- /** Voltage read methods */
- float read_voltage(void);
- float data_to_voltage(uint32_t data);
- uint32_t voltage_to_data(float voltage);
-
- /** AnalogIn API */
- float read(void);
- uint32_t read_u32(void);
- uint16_t read_u16(void);
-
-#ifdef MBED_OPERATORS
- operator float();
-#endif
-
-private:
- DigitalIn miso;
- SPI ad7791; ///< SPI instance of the AD7791
- DigitalOut cs; ///< DigitalOut instance for the chipselect of the AD7791
-
- float _vref;
-// uint8_t _PGA_gain;
- bool _continous_conversion;
- AD7791Channel_t _channel;
-
- void write_reg(AD7791Register_t regAddress, uint8_t regValue);
- uint16_t write_spi(uint16_t data);
- uint16_t read_reg (AD7791Register_t regAddress);
-
- const static uint16_t _SINGLE_CONVERSION_TIMEOUT = 0xFFFF; // in 10us = 100ms
- const static uint16_t _CONTINOUS_CONVERSION_TIMEOUT = 0xFFFF;
- const static uint32_t _RESOLUTION = 0xFFFFFF;
- const static uint8_t _RESET = 0xFF;
- const static uint8_t _DUMMY_BYTE = 0xFF;
- const static uint16_t _READ_FLAG = 0x0800;
- const static uint8_t _DATA_READ = 0x38; // Read from the Data Register
- const static uint8_t _DELAY_TIMING = 0x02;
- const static uint8_t _SPI_MODE = 3;
-};
-
-#endif
--- a/libraries/adxl362/ADXL362.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,602 +0,0 @@
-/**
-* @file ADXL362.cpp
-* @brief Source file for ADXL362
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/adxl362
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include <stdint.h>
-#include "mbed.h"
-#include "ADXL362.h"
-
-/**
- * ADXL362 constructor. Sets CS and SPI bus
- * @param CS - CS pin of the ADXL362
- * @param MOSI - MOSI pin of the ADXL362
- * @param MISO - MISO pin of the ADXL362
- * @param SCK- SCK pin of the ADXL362
- */
-ADXL362::ADXL362(PinName CS, PinName MOSI, PinName MISO, PinName SCK) :
- adxl362(MOSI, MISO, SCK), cs(CS), _int1(NULL), _int2(NULL), _int1_poll(NC), _int2_poll(
- NC)
-{
- cs = true; // cs is active low
- adxl362.format(8, _SPI_MODE);
- _temp_stored_in_fifo = false;
- _int1_act_low = true;
- _int2_act_low = true;
-}
-
-/**
- * Sets ADXL362 SPI bus frequency
- * @param hz - frequency in hz
- */
-void ADXL362::frequency(int hz)
-{
- adxl362.frequency(hz);
-}
-
-/**
- * Resets the ADXL362
- * A latency of approximately 0.5 ms is required after soft reset.
- */
-void ADXL362::reset()
-{
- adxl362.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(SOFT_RESET, 0x52);
- cs = true;
-
-}
-
-/**
- * Writes the reg register with data
- * @param reg - ADXL362_register_t register to be written
- * @param data - data to be written
- */
-void ADXL362::write_reg(ADXL362_register_t reg, uint8_t data)
-{
- adxl362.format(8, _SPI_MODE);
- cs = false;
- adxl362.write(_WRITE_REG_CMD);
- adxl362.write(static_cast<uint8_t>(reg));
- adxl362.write(static_cast<uint8_t>(data));
- cs = true;
-}
-
-/**
- * Reads the reg register
- * @param reg - ADXL362_register_t register to be read
- * @return - data read from the register
- */
-uint8_t ADXL362::read_reg(ADXL362_register_t reg)
-{
- uint8_t ret_val;
- adxl362.format(8, _SPI_MODE);
- cs = false;
- adxl362.write(_READ_REG_CMD);
- adxl362.write(static_cast<uint8_t>(reg));
- ret_val = adxl362.write(_DUMMY_BYTE);
- cs = true;
- return ret_val;
-}
-
-/**
- * Writes 16 bit registers to the ADXL362. Performs conversion from Intel to Motorola byte order
- * @param reg - ADXL362_register_t register to be written
- * @param data - data to be written
- */
-void ADXL362::write_reg_u16(ADXL362_register_t reg, uint16_t data)
-{
- adxl362.format(8, _SPI_MODE);
-
- cs = false;
- adxl362.write(_WRITE_REG_CMD);
- adxl362.write(static_cast<uint8_t>(reg));
- adxl362.write(static_cast<uint8_t>(data & 0xff));
- adxl362.write(static_cast<uint8_t>((data & 0xff00) >> 8));
-
- cs = true;
-}
-
-/**
- * Reads 16 bit registers from the ADXL362. Performs conversion from Motorola to Intel Byte order
- * @param reg - ADXL362_register_t register to be read
- * @return - data read from the ADXL362
- */
-uint16_t ADXL362::read_reg_u16(ADXL362_register_t reg)
-{
- uint16_t ret_val = 0;
- adxl362.format(8, _SPI_MODE);
-
- cs = false;
- adxl362.write(_READ_REG_CMD);
- adxl362.write(static_cast<uint8_t>(reg));
- ret_val = adxl362.write(_DUMMY_BYTE);
- ret_val = ret_val | (adxl362.write(_DUMMY_BYTE) << 8);
- cs = true;
-
- return ret_val;
-}
-
-/**
- * Scans the X,Y,Z,T registers for data.
- * ADXL362 needs to be in measurement mode to read data
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return a 64 bit integer with the following format 0xXXYYZZTT
- */
-uint64_t ADXL362::scan()
-{
- uint64_t ret_val = 0;
- uint16_t x, y, z, t = 0;
-
- adxl362.format(8, _SPI_MODE);
- cs = false;
- adxl362.write(_READ_REG_CMD);
- adxl362.write(static_cast<uint8_t>(XDATA_L));
-
- x = adxl362.write(_DUMMY_BYTE);
- x = x | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
- y = adxl362.write(_DUMMY_BYTE);
- y = y | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
- z = adxl362.write(_DUMMY_BYTE);
- z = z | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
- t = adxl362.write(_DUMMY_BYTE);
- t = t | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
-
- ret_val = static_cast<uint64_t>(x) << 48;
- ret_val |= static_cast<uint64_t>(y) << 32;
- ret_val |= static_cast<uint64_t>(z) << 16;
- ret_val |= static_cast<uint64_t>(t);
- cs = true;
- return ret_val;
-}
-
-/**
- * Reads the X 8 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 8 bit X data
- */
-uint8_t ADXL362::scanx_u8()
-{
- return read_reg(XDATA);
-}
-
-/**
- * Reads the X 16 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 16 bit X data
- */
-uint16_t ADXL362::scanx()
-{
- return read_reg_u16(XDATA_L);
-}
-
-/**
- * Reads the Y 8 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 8 bit Y data
- */
-uint8_t ADXL362::scany_u8()
-{
- return read_reg(YDATA);
-}
-
-/**
- * Reads the Y 16 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 16 bit Y data
- */
-uint16_t ADXL362::scany()
-{
- return read_reg_u16(YDATA_L);
-}
-
-/**
- * Reads the Z 8 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 8 bit Z data
- */
-uint8_t ADXL362::scanz_u8()
-{
- return read_reg(ZDATA);
-}
-
-/**
- * Reads the Z 16 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 16 bit Z data
- */
-uint16_t ADXL362::scanz()
-{
- return read_reg_u16(ZDATA_L);
-}
-
-/**
- * Reads the T 16 bit register from the ADXL362
- * ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- * @return 16 bit T data
- */
-uint16_t ADXL362::scant()
-{
- return read_reg_u16(TEMP_L);
-}
-
-/**
- * Sets the STANDBY/MEASUREMENT mode of the ADXL362
- * @param mode - ADXL362_modes_t STANDBY/MEASUREMENT mode
- */
-void ADXL362::set_mode(ADXL362_modes_t mode)
-{
- uint8_t reg_val;
- reg_val = read_reg(POWER_CTL);
- reg_val = reg_val | static_cast<uint8_t>(mode);
- write_reg(POWER_CTL, reg_val);
-}
-
-/**
- * Sets the activity threshold registers
- * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
- * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
- * @param threshold - activity threshold in natural format
- */
-void ADXL362::set_activity_threshold(uint16_t threshold)
-{
- write_reg_u16(THRESH_ACT_L, threshold);
-}
-
-/**
- * Sets the activity time register
- * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
- * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
- * @param time - activity time
- */
-void ADXL362::set_activity_time(uint8_t time)
-{
- write_reg(TIME_ACT, time);
-}
-
-/**
- * Sets the inactivity threshold register
- * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
- * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
- * @param threshold - inactivity threshold in natural format
- */
-void ADXL362::set_inactivity_threshold(uint16_t threshold)
-{
- write_reg_u16(THRESH_INACT_L, threshold);
-}
-
-/**
- * Sets the inactivity time register
- * To enable activity/inactivity, the ACT_INACT_CTL reg must also be set
- * using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method
- * @param time - inactivity time in natural format
- */
-void ADXL362::set_inactivity_time(uint16_t time)
-{
- write_reg_u16(TIME_INACT_L, time);
-}
-
-/**
- * Sets the ACT_INACT_CTL register of the ADXL362
- * @param data - data to be written to the register
- */
-void ADXL362::set_act_inact_ctl_reg(uint8_t data)
-{
- write_reg(ACT_INACT_CTL, data);
-}
-
-/**
- * Configures INT1 output of the ADXL362 for polling use
- * @param in - uC pin connected to ADXL362's INT1
- * @param data - data to be written to INTMAP1
- * @param pull - (optional) configures pullup on In pin
- */
-void ADXL362::set_polling_interrupt1_pin(PinName in, uint8_t data,
- PinMode pull)
-{
- if ((data & 0x7F) != 0) {
- write_reg(INTMAP1, data);
- _int1_poll = DigitalIn(in);
- _int1_poll.mode(pull);
- if (data & 0x80) {
- _int1_act_low = true;
- } else {
- _int1_act_low = false;
- }
- }
-}
-
-/**
- * Configures INT2 output of the ADXL362 for polling use
- * @param in - uC pin connected to ADXL362's INT2
- * @param data - data to be written to INTMAP2
- * @param pull - (optional) configures pullup on In pin
- */
-void ADXL362::set_polling_interrupt2_pin(PinName in, uint8_t data,
- PinMode pull)
-{
- if ((data & 0x7F) != 0) {
- write_reg(INTMAP2, data);
- _int2_poll = DigitalIn(in);
- _int2_poll.mode(pull);
- if (data & 0x80) {
- _int2_act_low = true;
- } else {
- _int2_act_low = false;
- }
- }
-}
-
-/**
- * Gets the active state of the INT1 pin
- * @return true if active, false if not active
- */
-bool ADXL362::get_int1()
-{
- if(_int1_poll != NC) return (_int1_poll.read() != _int1_act_low); // boolean XOR
- else return (_int1->read() != _int1_act_low);
-}
-
-/**
- * Gets the active state of the INT2 pin
- * @return true if active, false if not active
- */
-bool ADXL362::get_int2()
-{
- if(_int2_poll != NC) return (_int1_poll.read() != _int1_act_low); // boolean XOR
- else return (_int2->read() != _int2_act_low);
-}
-
-
-/**
- * Configures the INT1 pin of the ADXL362 to be used in interrupt mode
- * @param in - uC pin connected to ADXL362's INT1
- * @param data - data to be written to INTMAP1
- * @param callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge
- * @param callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge
- * @param pull - (optional) configures pullup on In pin
- */
-void ADXL362::set_interrupt1_pin(PinName in, uint8_t data,
- void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull)
-{
- if ((data & 0x7F) != 0) {
- write_reg(INTMAP1, data);
- delete _int1;
- _int1 = new InterruptIn(in);
- _int1->mode(pull);
- if(callback_falling != NULL) _int1->fall(callback_falling);
- if(callback_rising != NULL) _int1->rise(callback_rising);
- if (data & 0x80) {
- _int1_act_low = true;
- } else {
- _int1_act_low = false;
- }
- }
-}
-
-
-/**
- * Configures the INT2 pin of the ADXL362 to be used in interrupt mode
- * @param in - uC pin connected to ADXL362's INT2
- * @param data - data to be written to INTMAP2
- * @param callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge
- * @param callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge
- * @param pull - (optional) configures pullup on In pin
- */
-void ADXL362::set_interrupt2_pin(PinName in, uint8_t data,
- void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull)
-{
- if ((data & 0x7F) != 0) {
- write_reg(INTMAP2, data);
- delete _int2;
- _int2 = new InterruptIn(in);
- _int2->mode(pull);
- if(callback_falling != NULL) _int2->fall(callback_falling);
- if(callback_rising != NULL) _int2->rise(callback_rising);
- if (data & 0x80) {
- _int2_act_low = true;
- } else {
- _int2_act_low = false;
- }
- }
-}
-
-/**
- * Enables external interrupt registration for pin configured as INT1
- * To enable this interrupt, it must first be configured using ADXL362::set_interrupt1_pin()
- */
-void ADXL362::enable_interrupt1()
-{
- _int1->enable_irq();
-}
-
-/**
- * Enables external interrupt registration for pin configured as INT2
- * * To enable this interrupt, it must first be configured using ADXL362::set_interrupt2_pin()
- */
-void ADXL362::enable_interrupt2()
-{
- _int2->enable_irq();
-}
-
-/**
- * Disables external interrupt registration for pin configured as INT1
- */
-void ADXL362::disable_interrupt1()
-{
- _int1->disable_irq();
-}
-
-/**
- * Disables external interrupt registration for pin configured as INT2
- */
-void ADXL362::disable_interrupt2()
-{
- _int2->disable_irq();
-}
-
-/**
- * Sets the POWER_CTL register
- * @param data - data to be written to the register
- */
-void ADXL362::set_power_ctl_reg(uint8_t data)
-{
- write_reg(POWER_CTL, data);
-}
-
-/**
- * Sets the FILTER_CTL register
- * @param data - data to be written to the register
- */
-void ADXL362::set_filter_ctl_reg(uint8_t data)
-{
- write_reg(FILTER_CTL, data);
-}
-
-/**
- * Reads the STATUS register of the ADXL362
- * @return - data in the status register
- */
-uint8_t ADXL362::read_status()
-{
- return read_reg(STATUS);
-}
-
-/**
- * Reads the FIFO_ENTRIES_L and FIFO_ENTRIES_H register
- * @return the number of entries in the FIFO
- */
-uint16_t ADXL362::fifo_read_nr_of_entries()
-{
- return read_reg_u16(FIFO_ENTRIES_L);
-}
-
-/**
- * Setup for the FIFO
- * @param store_temp - boolean, true - temperature will be stored in the fifo. false otherwise
- * @param mode - ADXL362_FIFO_modes_t fifo mode
- * @param nr_of_entries - number of entries in the FIFO
- */
-void ADXL362::fifo_setup(bool store_temp, ADXL362_FIFO_modes_t mode, uint16_t nr_of_entries)
-{
- uint8_t fifo_ctl = static_cast<uint8_t>(mode);
- _temp_stored_in_fifo = store_temp;
-
- fifo_ctl = fifo_ctl | (static_cast<uint8_t>(_temp_stored_in_fifo) << 2);
-
- if (nr_of_entries > 0xff) {
- fifo_ctl = fifo_ctl | static_cast<uint8_t>(AH);
- }
- write_reg(FIFO_CONTROL, fifo_ctl);
- write_reg(FIFO_SAMPLES, static_cast<uint8_t>(nr_of_entries & 0xff));
-
-}
-
-/**
- * Reads a FIFO entry
- * @return FIFO entry
- */
-uint16_t ADXL362::fifo_read_u16()
-{
- uint16_t ret_val = 0;
- adxl362.format(8, _SPI_MODE);
-
- cs = false;
- adxl362.write(_READ_FIFO_CMD);
- ret_val = adxl362.write(_DUMMY_BYTE);
- ret_val = (ret_val) | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
- cs = true;
-
- return ret_val;
-}
-
-/**
- * Reads 3(4) bytes from the FIFO(if store_temp was set), assembles the data in the format used by the scan method
- * ADXL362::fifo_setup() needs to be called before calling fifo_scan to ensure correct fifo operation
- * fifo_scan and fifo_read_u16 should not be used as fifo_read_u16 disaligns the fifo therefore
- * fifo_scan will return data from multiple samples
- * @return scanned data from the fifo in the 0xXXYYZZTT format
- */
-uint64_t ADXL362::fifo_scan()
-{
-
- uint64_t ret_val = 0;
- uint16_t x = 0, y = 0, z = 0, dummy, t = 0, sample_type;
-
- adxl362.format(8, _SPI_MODE);
- cs = false;
- adxl362.write(_READ_FIFO_CMD);
- uint8_t samples = (_temp_stored_in_fifo) ? 4 : 3;
- for(uint8_t i = 0; i < samples; i++) {
- dummy = adxl362.write(_DUMMY_BYTE);
- dummy = dummy | static_cast<uint16_t>(adxl362.write(_DUMMY_BYTE) << 8);
- sample_type = (dummy & 0xc000) >> 14;
- dummy = dummy & 0x3fff;
- switch(sample_type) {
- case 0: // x
- x = dummy;
- break;
- case 1: // y
- y = dummy;
- break;
- case 2: // z
- z = dummy;
- break;
- case 3: // temp
- t = dummy;
- break;
- }
-
- }
-
- // format xxyyzztt
- ret_val = static_cast<uint64_t> (x) << 48;
- ret_val |= static_cast<uint64_t>(y) << 32;
- ret_val |= static_cast<uint64_t>(z) << 16;
- ret_val |= static_cast<uint64_t>(t);
- cs = true;
- return ret_val;
-}
--- a/libraries/adxl362/ADXL362.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-#ifndef ADXL362_H_
-#define ADXL362_H_
-
-/**
-* @file ADXL362.cpp
-* @brief Header file for ADXL362
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: http://www.analog.com/adxl362
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-
-class ADXL362
-{
-public:
-
- /* Temperature parameters */
- typedef enum {
- DEVID_AD = 0x00,
- DEVID_MST = 0x01,
- PARTID = 0x02,
- REVID = 0x03,
- XDATA = 0x08,
- YDATA = 0x09,
- ZDATA = 0x0A,
- STATUS = 0x0B,
- FIFO_ENTRIES_L = 0x0C,
- FIFO_ENTRIES_H = 0x0D,
- XDATA_L = 0x0E,
- XDATA_H = 0x0F,
- YDATA_L = 0x10,
- YDATA_H = 0x11,
- ZDATA_L = 0x12,
- ZDATA_H = 0x13,
- TEMP_L = 0x14,
- TEMP_H = 0x15,
- // Reserved = 0x16;
- // Reserved = 0x17;
- SOFT_RESET = 0x1F,
- THRESH_ACT_L = 0x20,
- THRESH_ACT_H = 0x21,
- TIME_ACT = 0x22,
- THRESH_INACT_L = 0x23,
- THRESH_INACT_H = 0x24,
- TIME_INACT_L = 0x25,
- TIME_INACT_H = 0x26,
- ACT_INACT_CTL = 0x27,
- FIFO_CONTROL = 0x28,
- FIFO_SAMPLES = 0x29,
- INTMAP1 = 0x2A,
- INTMAP2 = 0x2B,
- FILTER_CTL = 0x2C,
- POWER_CTL = 0x2D,
- SELF_TEST = 0x2E,
- } ADXL362_register_t;
-
- typedef enum {
- STANDBY = 0x00,
- MEASUREMENT = 0x02
- } ADXL362_modes_t;
-
- typedef enum {
- ERR_USER_REGS = 0x80,
- AWAKE = 0x40,
- INACT = 0x20,
- ACT = 0x10,
- FIFO_OVERRUN = 0x08,
- FIFO_WATERMARK = 0x04,
- FIFO_READY = 0x02,
- DATA_READY = 0x01
- } ADXL362_STATUS_reg_bits_t;
-
- typedef enum {
- LINKLOOP1 = 0x20,
- LINKLOOP0 = 0x10,
- DEFAULTMODE = 0x00,
- LINKED_MODE = 0x10,
- LOOP_MODE = 0x30,
- INACT_REF = 0x08,
- INACT_EN = 0x04,
- ACT_REF = 0x02,
- ACT_EN = 0x01
- } ADXL362_ACT_INACT_CTL_reg_bits_t;
-
- typedef enum {
- AH = 0x08,
- FIFO_TEMP = 0x04,
- FIFO_MODE1 = 0x02,
- FIFO_MODE = 0x01,
- } ADXL362_FIFO_CONTROL_reg_bits_t;
-
- typedef enum {
- FIFO_DISABLED = 0x00,
- FIFO_OLDEST = 0x01,
- FIFO_STREAM = 0x02,
- FIFO_TRIGGERED = 0x03,
- } ADXL362_FIFO_modes_t;
-
- typedef enum {
- INT_LOW = 0x80,
- INT_AWAKE = 0x40,
- INT_INACT = 0x20,
- INT_ACT = 0x10,
- INT_FIFO_OVERRUN = 0x08,
- INT_FIFO_WATERMARK = 0x04,
- INT_FIFO_READY = 0x02,
- INT_DATA_READY = 0x01
- } ADXL362_INTMAP_reg_bits_t;
-
- typedef enum {
- RANGE1 = 0x80,
- RANGE0 = 0x40,
- RANGE2G = 0x00,
- RANGE4G = 0x40,
- RANGE8G = 0x80,
- HALF_BW = 0x10,
- EXT_SAMPLE = 0x08,
- ODR2 = 0x04,
- ODR1 = 0x02,
- ODR0 = 0x01,
- ODR12HZ = 0x00,
- ODR25HZ = 0x01,
- ODR50Hz = 0x02,
- ODR100HZ = 0x03,
- ODR200Hz = 0x04,
- ODR400HZ = 0x07
- } ADXL362_FILTER_CTL_reg_bits_t;
-
- typedef enum {
- EXT_CLK = 0x40,
- LOW_NOISE1 = 0x20,
- LOW_NOISE0 = 0x10,
- NORMAL_OPERATION = 0x00,
- LOW_NOISE = 0x10,
- ULTRALOW_NOISE = 0x20,
- WAKEUP = 0x08,
- AUTOSLEEP = 0x04,
- MEASURE1 = 0x02,
- MEASURE0 = 0x01,
- } ADXL362_POWER_CTL_reg_bits_t;
-
- /** SPI configuration & constructor */
- ADXL362(PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO =
- SPI_MISO, PinName SCK = SPI_SCK);
- void frequency(int hz);
-
- /** Low level SPI bus comm methods */
- void reset(void);
- void write_reg(ADXL362_register_t reg, uint8_t data);
- uint8_t read_reg(ADXL362_register_t reg);
- uint16_t read_reg_u16(ADXL362_register_t reg);
- void write_reg_u16(ADXL362_register_t reg, uint16_t data);
-
- /** ADXL general register R/W methods */
- void set_power_ctl_reg(uint8_t data);
- void set_filter_ctl_reg(uint8_t data);
- uint8_t read_status();
- void set_mode(ADXL362_modes_t mode);
-
- /** ADXL X/Y/Z/T scanning methods*/
- uint64_t scan();
- uint8_t scanx_u8();
- uint16_t scanx();
- uint8_t scany_u8();
- uint16_t scany();
- uint8_t scanz_u8();
- uint16_t scanz();
- uint16_t scant();
-
- /** ADXL362 activity methods */
- void set_activity_threshold(uint16_t threshold);
- void set_activity_time(uint8_t time);
- void set_inactivity_threshold(uint16_t threshold);
- void set_inactivity_time(uint16_t time);
- void set_act_inact_ctl_reg(uint8_t data);
-
- /** ADXL362 interrupt methods */
- void set_interrupt1_pin(PinName in, uint8_t data, void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull = PullNone);
- void set_interrupt2_pin(PinName in, uint8_t data, void (*callback_rising)(void), void (*callback_falling)(void), PinMode pull = PullNone);
- void enable_interrupt1();
- void enable_interrupt2();
- void disable_interrupt1();
- void disable_interrupt2();
-
- void set_polling_interrupt1_pin(PinName in, uint8_t data, PinMode pull = PullNone);
- void set_polling_interrupt2_pin(PinName in, uint8_t data, PinMode pull = PullNone);
-
- bool get_int1();
- bool get_int2();
-
- /** ADXL362 FIFO methods */
- uint16_t fifo_read_nr_of_entries();
- void fifo_setup(bool store_temp, ADXL362_FIFO_modes_t mode, uint16_t nr_of_entries);
- uint16_t fifo_read_u16();
- uint64_t fifo_scan();
-
- SPI adxl362; ///< SPI instance of the ADXL362
- DigitalOut cs; ///< DigitalOut instance for the chipselect of the ADXL362
-
-private:
-
- InterruptIn *_int1;
- InterruptIn *_int2;
- DigitalIn _int1_poll;
- DigitalIn _int2_poll;
- bool _int1_act_low;
- bool _int2_act_low;
- bool _temp_stored_in_fifo;
-
- const static uint8_t _DUMMY_BYTE = 0xAA;
- const static uint8_t _WRITE_REG_CMD = 0x0A; // write register
- const static uint8_t _READ_REG_CMD = 0x0B; // read register
- const static uint8_t _READ_FIFO_CMD = 0x0D; // read FIFO
- const static uint8_t _SPI_MODE = 0;
-};
-
-#endif
--- a/libraries/cn0216/CN0216.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/**
-* @file cn0216.cpp
-* @brief Source file for CN0216
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0216-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include "AD7791.h"
-#include "CN0216.h"
-extern Serial pc;
-
-/**
- * CN0216 constructor
- * @param CSAD7791 - Chipselect of the AD7791
- * @param MOSI - MOSI line of the SPI bus
- * @param MISO - MISO line of the SPI bus
- * @param SCK - SCK line of the SPI bus
- */
-CN0216::CN0216(PinName CSAD7791, PinName MOSI, PinName MISO, PinName SCK) : ad7791(1.2, CSAD7791, MOSI, MISO, SCK)
-{
- _cal_weight = 0;
- _zero_scale_value = 0;
- _full_scale_value = 0;
- _weight_units_per_bit = 0;
-}
-
-/**
- * Initializes the mode and filter values of the AD7791 and sets the weight to be used in calibration
- * @param cal_weight - weight used in calibration
- * @param mode_val - value of the mode register
- * @param filter_val - value of the filter register
- */
-void CN0216::init(float cal_weight, uint8_t mode_val, uint8_t filter_val)
-{
- _cal_weight = cal_weight;
- ad7791.frequency(500000);
- wait_ms(50);
- ad7791.reset();
- wait_ms(50);
- ad7791.write_mode_reg(mode_val);
- wait_us(2);
- ad7791.write_filter_reg(filter_val);
- wait_ms(50);
-}
-
-/**
- * Calibrates the CN0216 weigh scale
- * @param cal - calibration step.
- * Step CN0216::ZERO_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the minimum as value for the zero scale
- * Step CN0216::FULL_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the average as value for the full scale
- * Step COMPUTE_UNITS_PER_BIT will compute the grams per bit used in weight computation.
- */
-void CN0216::calibrate(CalibrationStep_t cal)
-{
- uint64_t sum = 0;
- uint32_t min = 0xFFFFFFFF;
- uint32_t sample = 0;
- switch(cal) {
- case ZERO_SCALE_CALIBRATION:
- case FULL_SCALE_CALIBRATION:
- for(int i = 0; i < _NUMBER_OF_SAMPLES; i++) {
- sample = ad7791.read_u32();
- min = (min < sample) ? min : sample;
- sum += ad7791.read_u32();
- wait_us(5);
- }
- if(cal == ZERO_SCALE_CALIBRATION) {
- // pc.printf("ZERO SCALE VALUE = %x",sum);
- _zero_scale_value = min;
- } else {
- // pc.printf("FULL SCALE VALUE = %x",sum);
- sum = sum / _NUMBER_OF_SAMPLES;
- _full_scale_value = sum;
- }
- break;
-
- case COMPUTE_UNITS_PER_BIT:
- _weight_units_per_bit = _cal_weight / (static_cast<float> (_full_scale_value - _zero_scale_value)); /* Calculate number of grams per LSB */
- // pc.printf("GRAMS/LSB = %f", _grams_per_bit);
- break;
- default:
- break;
- }
-
-}
-
-/**
- * Computes the weight based on the formula
- * weight = (data - zeroscale) * weight_units_per_bit
- * @param data read from the ADC
- * @return weight based on data
- */
-float CN0216::compute_weight(uint32_t data)
-{
-// pc.printf("\r\nFULL_SCALE_VALUE = %x\r\nZERO_SCALE_VALUE = %x\r\nDATA READ = %x\r\nGRAMS/LSB = %f\r\n",_full_scale_value,data,_zero_scale_value,_grams_per_bit);
- if(data < _zero_scale_value)
- data = _zero_scale_value; // clamp data to 0
- float weight_in_grams = (static_cast<float>((data) - _zero_scale_value)) * _weight_units_per_bit; /* Calculate weight */
- return weight_in_grams;
-}
-
-/**
- * Reads the AD7791
- * @return value read by the ADC
- */
-uint32_t CN0216::read_u32()
-{
- return ad7791.read_u32();
-}
-
-/**
- * Reads the ADC and computes the weight based on the formula described above.
- * @return weight
- */
-float CN0216::read_weight()
-{
- uint32_t weight = read_u32();
- return compute_weight(weight);
-}
-
--- a/libraries/cn0216/CN0216.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/**
-* @file cn0216.h
-* @brief Header file for CN0216
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0216-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include "AD7791.h"
-
-#ifndef CN0216_H_
-#define CN0216_H_
-
-class CN0216
-{
-public:
- typedef enum {
- ZERO_SCALE_CALIBRATION, ///< Calibration of the zero scale value
- FULL_SCALE_CALIBRATION, ///< Calibration of the full scale value
- COMPUTE_UNITS_PER_BIT ///< Units per LSB computation
- } CalibrationStep_t;
-
- CN0216(PinName CSAD7791 = D8, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
- void init(float cal_weight = _DEFAULT_CAL_WEIGHT, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL);
- void calibrate(CalibrationStep_t cal);
- float compute_weight(uint32_t data);
- uint32_t read_u32();
- float read_weight();
-
-private:
-
- const static int _NUMBER_OF_SAMPLES = 20; ///< Number of samples used in calibration
- const static int _DEFAULT_MODE_VAL = AD7791::MD1 | AD7791::MD0; // POWERDOWN MODE
- const static int _DEFAULT_FILTER_VAL = AD7791::FS0 | AD7791::FS1 | AD7791::FS2;
- const static int _DEFAULT_CAL_WEIGHT = 1000.0;
-
- AD7791 ad7791;
- float _cal_weight;
- uint32_t _zero_scale_value;
- uint32_t _full_scale_value;
- float _weight_units_per_bit;
-
-};
-
-#endif
--- a/libraries/cn0357/CN0357.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-/**
-* @file cn0357.cpp
-* @brief Source file for CN0357
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0357-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#include "mbed.h"
-#include "AD7790.h"
-#include "AD5270.h"
-#include "CN0357.h"
-
-/**
- * @brief CN0357 constructor
- * @param CSAD7790 - (optional)chip select of the AD7790
- * @param CSAD5270 - (optional)chip select of the AD5270
- * @param MOSI - (optional)pin of the SPI interface
- * @param MISO - (optional)pin of the SPI interface
- * @param SCK - (optional)pin of the SPI interface
- */
-CN0357::CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO,
- PinName SCK) :
- _vref(1.2), _sensor_sensitivity(0), _sensor_range(0), _RDACvalue(0),
- ad7790(_vref, CSAD7790, MOSI, MISO, SCK), ad5270(CSAD5270, 20000.0, MOSI, MISO, SCK)
-
-{
-}
-
-/**
- * @brief initializes the AD7790 and the AD5270
- * @param range - range of the sensor used (in ppm)
- * @param sensitivity - sensitivity of the sensor (A/ppm)
- * @param jp - (optional)jumper configuration of the CN0357
- * @param mode_val - (optional)if jp is set to InternalADC, configures the mode register of the Internal ADC
- * @param filter_val - (optional)if jp is set to InternalADC, configures the filter register of the Internal ADC
- */
-void CN0357::init(float range, float sensitivity, JumperConfig_t jp, uint8_t mode_val, uint8_t filter_val)
-{
- ad5270.frequency(500000);
- ad7790.frequency(500000);
-
- float resistance = set_sensor_parameters(range, sensitivity);
-
- if(jp == INTERNAL_AD7790) {
- _AD7790_init(mode_val, filter_val);
- }
- _rdac_init(resistance);
-}
-
-/**
- * @brief initializes the RDAC and sets SDO to HiZ
- * @param resistance - resistance value to initialize the RDAC
- * @return
- */
-void CN0357::_rdac_init(float resistance)
-{
- /* RDAC initialization*/
- /* Compute for the nearest RDAC value from given resistance and save data to the structure */
- set_RDAC_value(resistance);
- /* Set AD5270 SDO to Hi-Z */
- ad5270.set_SDO_HiZ();
-}
-
-/**
- * @brief initializes the AD7790
- * @param mode_val - configures the mode register of the Internal ADC
- * @param filter_val - configures the filter register of the Internal ADC
- */
-void CN0357::_AD7790_init(uint8_t mode_val, uint8_t filter_val)
-{
- ad7790.reset();
- wait_ms(50);
-
- ad7790.write_mode_reg(mode_val);
- wait_us(2);
-
- ad7790.write_filter_reg(filter_val);
- wait_ms(50);
-}
-
-/**
- * @brief reads the status register of the AD7790
- * @return status register value
- */
-uint8_t CN0357::read_adc_status(void)
-{
- return ad7790.read_status_reg();
-}
-
-/**
- * @brief reads the ADC and computes the sensor voltage
- * @return sensor voltage
- */
-float CN0357::read_sensor_voltage(void)
-{
- return ad7790.read_voltage();
-}
-
-/**
- * @brief reads the data register of the AD7790
- * @return data register value
- */
-uint16_t CN0357::read_sensor(void)
-{
- return ad7790.read_u16();
-}
-
-/**
- * @brief reads and computes the sensor reading in PPM
- * @return value of the sensor reading in PPM
- */
-float CN0357::read_ppm()
-{
- return calc_ppm(ad7790.read_voltage()); /* Convert voltage to Gas concentration*/
-}
-
-/**
- * @brief computes a value in PPM from a reading received as a param
- * @param adcVoltage - voltage to be converted to PPM
- * @return sensor value in PPM
- */
-float CN0357::calc_ppm(float adcVoltage)
-{
- float fConcentration = 0;
- fConcentration = (fabs(adcVoltage) / _RDACvalue) / _sensor_sensitivity;
- return fConcentration;
-}
-
-/**
- * @brief computes voltage from a 16 bit ADC value received as a parameter
- * @param data - ADC value
- * @return sensor voltage
- */
-float CN0357::data_to_voltage(uint16_t data)
-{
- return ad7790.data_to_voltage(data);
-}
-
-/**
- * @brief sets a new value for the RDAC
- * @param resistance new value for the resistance
- * @return none
- */
-void CN0357::set_RDAC_value(float resistance)
-{
- _RDACvalue = ad5270.write_RDAC(resistance);
-}
-
-/**
- * @brief getter method for RDAC value
- * @return value of the RDAC in ohms
- */
-float CN0357::get_RDAC_value()
-{
- return _RDACvalue;
-}
-
-/**
- * @brief set sensor range and sensitivity
- * sets sensor range, sensitivity
- * returns suggested resistance value for feedback resistor
- * @param range - range of the sensor used (in ppm)
- * @param sensitivity - sensitivity of the sensor (in A/ppm)
- * @return suggested resistance value for feedback resistor
- */
-float CN0357::set_sensor_parameters(float range, float sensitivity)
-{
- _sensor_sensitivity = static_cast<float>(sensitivity);
- _sensor_range = range;
- return (_vref / (static_cast<float>(_sensor_range * _sensor_sensitivity)));
-}
-
-/**
- * @brief getter method for sensor sensitivity
- * @return sensor sensitivity (in A/ppm)
- */
-float CN0357::get_sensor_sensitivity()
-{
- return _sensor_sensitivity;
-}
-
-/**
- * @brief getter method for sensor range
- * @return sensor range (in ppm)
- */
-float CN0357::get_sensor_range()
-{
- return _sensor_range;
-}
--- a/libraries/cn0357/CN0357.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/**
-* @file cn0357.h
-* @brief Header file for CN0357
-* @author Analog Devices Inc.
-*
-* For support please go to:
-* Github: https://github.com/analogdevicesinc/mbed-adi
-* Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
-* Product: www.analog.com/EVAL-CN0357-ARDZ
-* More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
-********************************************************************************
-* Copyright 2016(c) Analog Devices, Inc.
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* - Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* - Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* - Neither the name of Analog Devices, Inc. nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-* - The use of this software may or may not infringe the patent rights
-* of one or more patent holders. This license does not release you
-* from the requirement that you obtain separate licenses from these
-* patent holders to use this software.
-* - Use of the software either in source or binary form, must be run
-* on or directly connected to an Analog Devices Inc. component.
-*
-* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-********************************************************************************/
-
-#ifndef CN0357_H
-#define CN0357_H
-
-#include "mbed.h"
-#include "AD7790.h"
-#include "AD5270.h"
-
-/**
- * @brief EVAL-CN0357 toxic gas sensor shield
- */
-class CN0357
-{
-public:
-
-private:
- float _vref;
- float _sensor_sensitivity;
- float _sensor_range;
- float _RDACvalue;
-public:
- AD7790 ad7790; ///< AD7790 instance - can be used for manual overriding
- AD5270 ad5270; ///< AD5270 instance - can be used for manual overriding
-
- /// CN0357 shield jumper configuration
- typedef enum {
- INTERNAL_AD7790 = 0, ///< The shield's AD7790 is used
- EXTERNAL_ADC ///< Sensor analog output is routed to A1 pin of the shield
- } JumperConfig_t;
-
- CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
- void init(float range, float sensitivity, JumperConfig_t jp = INTERNAL_AD7790, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL);
-
- uint8_t read_adc_status(void);
- uint16_t read_sensor(void);
- float read_sensor_voltage(void);
- float data_to_voltage(uint16_t data);
- float calc_ppm(float adcVoltage);
- float read_ppm(void);
-
- void set_RDAC_value(float resistor_val);
- float get_RDAC_value(void);
- float set_sensor_parameters(float range, float sensitivity);
- float get_sensor_range(void);
- float get_sensor_sensitivity(void);
-
-private:
- const static int _RESET = 0xff;
- const static int _DEFAULT_MODE_VAL = AD7790::MD1 | AD7790::MD0; // POWERDOWN MODE
- const static int _DEFAULT_FILTER_VAL = AD7790::FS0 | AD7790::FS1 | AD7790::FS2;
- void _rdac_init(float resistanceValue);
- void _AD7790_init(uint8_t mode_val, uint8_t filter_val);
-
-};
-
-#endif // CN0357_H
--- a/libraries/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/**
- * @file EVAL_ADXL362_ARDZ.cpp
- * @brief Source file for the EVAL-ADXL362-ARDZ board
- * @author Analog Devices Inc.
- *
- * For support please go to:
- * Github: https://github.com/analogdevicesinc/mbed-adi
- * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
- * Product: www.analog.com/EVAL-ADXL362-ARDZ
- * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
- ********************************************************************************
- * Copyright 2016(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ********************************************************************************/
-
-#include "EVAL_ADXL362_ARDZ.h"
-
-/**
- * Constructor for the EVAL_ADXL362_ARDZ
- * @param _lcd reference to an LCD object
- * @param _adxl362 reference to an ADXL362 object
- */
-EVAL_ADXL362_ARDZ::EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) : lcd(_lcd) , adxl362(_adxl362)
-{
- _x_axis_data = 0;
- _y_axis_data = 0;
- _z_axis_data = 0;
- _t_data = 0;
- _lcd_on = 0;
-}
-
-/**
- * Initial setup of the LCD
- */
-void EVAL_ADXL362_ARDZ::LCD_setup()
-{
- lcd.init();
-}
-
-/**
- * Initial setup of the ADXL
- */
-void EVAL_ADXL362_ARDZ::ADXL_setup()
-{
- adxl362.reset();
- wait_us(500);
- adxl362.set_activity_threshold(ACT_VAL);
- adxl362.set_activity_time(ACT_TIMER / 10);
-
- adxl362.set_inactivity_threshold(INACT_VAL);
- adxl362.set_inactivity_time(INACT_TIMER);
- adxl362.set_act_inact_ctl_reg(0x3f);
-#if(ADXL_INT_SEL == INTACC_PIN_1)
- adxl362.set_polling_interrupt1_pin(D2, 0x40);
-#elif(ADXL_INT_SEL == INTACC_PIN_2)
- adxl362.set_polling_interrupt2_pin(D2, 0x40); /* Map the awake status to INT2 pin */
-#endif
- adxl362.set_mode(ADXL362::MEASUREMENT);
- _lcd_on = 0;
-
-}
-
-/**
- * Method used to scan the ADXL axis data to the internal members
- */
-void EVAL_ADXL362_ARDZ::ADXL_scan_xyzt()
-{
- uint64_t acc = adxl362.scan();
- _x_axis_data = static_cast<uint16_t>((acc & 0xffff000000000000) >> 48);
- _y_axis_data = static_cast<uint16_t>((acc & 0x0000ffff00000000) >> 32);
- _z_axis_data = static_cast<uint16_t>((acc & 0x00000000ffff0000) >> 16);
- _t_data = static_cast<uint16_t> (acc & 0x000000000000ffff);
-}
-
-/**
- * Gets the status of the interrupt
- * @return true if interrupt is active
- */
-bool EVAL_ADXL362_ARDZ::ADXL_get_int()
-{
-#if(ADXL_INT_SEL == INTACC_PIN_1)
- return adxl362.get_int1();
-#elif(ADXL_INT_SEL == INTACC_PIN_2)
- return adxl362.get_int2();
-#endif
- return false;
-}
-
-/**
- * Displays numeric values on the LCD
- */
-void EVAL_ADXL362_ARDZ::LCD_display_values()
-{
- uint8_t string[22];
- sprintf((char *) string, "x = % 5d", _x_axis_data);
- lcd.display_string(0, 0, (int8_t *) string);
-
- sprintf((char *) string, "y = % 5d", _y_axis_data);
- lcd.display_string(1, 0, (int8_t *) string);
-
- sprintf((char *) string, "z = % 5d", _z_axis_data);
- lcd.display_string(2, 0, (int8_t *) string);
-
-#if TEMP_ADC == 1
- sprintf((char *)string, "t = % 5d", _t_data);
- lcd.display_string(3, 0, (int8_t *)string);
-#else
- float f32temp = ((float) _t_data + Lcd::ACC_TEMP_BIAS)
- / (1 / Lcd::ACC_TEMP_SENSITIVITY); // -34.625
- sprintf((char *) string, "t = % 4.1f", f32temp);
- lcd.display_string(3, 0, (int8_t *) string);
-#endif
-}
-
-/**
- * Displays the level meter on the LCD
- */
-void EVAL_ADXL362_ARDZ::LCD_display_level()
-{
- bool any_direction = false;
- lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
-
- if(_x_axis_data > Lcd::ACC_LIMIT) {
- lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8Rec8x8);
- any_direction = true;
- }
- if(_x_axis_data < -Lcd::ACC_LIMIT) {
- lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8Rec8x8);
- any_direction = true;
- }
- if(_y_axis_data > Lcd::ACC_LIMIT) {
- lcd.display_symbol(0, Lcd::DOWN_X, 8, Lcd::pui8Rec8x8);
- any_direction = true;
- }
- if(_y_axis_data < -Lcd::ACC_LIMIT) {
- lcd.display_symbol(2, Lcd::UP_X, 8, Lcd::pui8Rec8x8);
- any_direction = true;
- }
- if( any_direction ) lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
- else lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8Rec8x8);
-
-}
-
-/**
- * Turns on the backlight and draws the static data to the LCD
- */
-void EVAL_ADXL362_ARDZ::LCD_init_display()
-{
- /* Set BLLCD pin - turn on LCD backlight */
- if(_lcd_on == true) return;
- lcd.bl_enable();
-
- lcd.display_string(0, 60, (int8_t *) "[mG]");
- lcd.display_string(1, 60, (int8_t *) "[mG]");
- lcd.display_string(2, 60, (int8_t *) "[mG]");
-
-#if (TEMP_ADC == 1)
- lcd.display_string(3, 60, (int8_t *)"[ADC]");
-#else
- lcd.display_string(3, 60, (int8_t *) "[C]");
-#endif
-
- lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
- lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
- _lcd_on = true;
-}
-
-/**
- * Turns off the backlight and clears the LCD
- */
-void EVAL_ADXL362_ARDZ::LCD_deinit_display()
-{
- if(_lcd_on == false) return;
- /* Clear BLLCD pin - turn off LCD backlight */
- lcd.bl_disable();
-
- /* Clear screen */
- lcd.fill_pages(0, 4, 0x00);
- _lcd_on = false;
-}
-
-
--- a/libraries/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/**
- * @file EVAL_ADXL362_ARDZ.cpp
- * @brief Header file for the EVAL-ADXL362-ARDZ board
- * @author Analog Devices Inc.
- *
- * For support please go to:
- * Github: https://github.com/analogdevicesinc/mbed-adi
- * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
- * Product: www.analog.com/EVAL-ADXL362-ARDZ
- * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
-
- ********************************************************************************
- * Copyright 2016(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ********************************************************************************/
-
-#ifndef EVAL_ADXL362_ARDZ_H
-#define EVAL_ADXL362_ARDZ_H
-
-#include "lcd.h"
-#include "adxl362.h"
-
-
-class EVAL_ADXL362_ARDZ
-{
-public:
- EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) ;
- void ADXL_setup();
- void ADXL_scan_xyzt();
- bool ADXL_get_int();
-
- void LCD_setup();
- void LCD_init_display();
- void LCD_deinit_display();
- void LCD_display_level();
- void LCD_display_values();
-
- Lcd lcd;
- ADXL362 adxl362;
-
-private:
-
- uint8_t _lcd_on;
- int16_t _x_axis_data;
- int16_t _y_axis_data;
- int16_t _z_axis_data;
- int16_t _t_data;
-
- static const uint16_t INACT_VAL = 50;
- static const uint16_t INACT_TIMER = 100 * 10;
- static const uint16_t ACT_VAL = 50;
- static const uint8_t ACT_TIMER = 100;
- static const uint16_t SCAN_SENSOR_TIME = 500;
-};
-
-#endif
--- a/libraries/eval_adxl362_ardz/lcd.cpp Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,329 +0,0 @@
-/**
- ******************************************************************************
- * @file Lcd.c
- * @brief Source file for ST7565R LCD control.
- * @author ADI
- * @date March 2016
- *
- *******************************************************************************
- * Copyright 2015(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *******************************************************************************
- **/
-
-/******************************************************************************/
-/***************************** Include Files **********************************/
-/******************************************************************************/
-#include "../EVAL_ADXL362_ARDZ/lcd.h"
-
-#include "mbed.h"
-
-
-
-Lcd::Lcd(PinName rst_pin, PinName a0_pin, PinName bl_pin,
- PinName cs_pin, PinName MOSI,
- PinName MISO, PinName SCK) :
-
- rst(rst_pin), a0(a0_pin), bl(bl_pin), cs(cs_pin), lcd_spi(MOSI, MISO, SCK)
-{
- rst = 1;
-}
-
-/**
- @brief Initialization of LCD screen
- @return none
- **/
-
-void Lcd::write_cmd(uint8_t cmd)
-{
- cs = 0;
- a0 = 0;
- lcd_spi.write(cmd);
- cs = 1;
-}
-
-void Lcd::write_data(uint8_t data)
-{
- cs = 0;
- a0 = 1;
- lcd_spi.write(data);
- cs = 1;
-}
-
-void Lcd::bl_enable()
-{
- bl = 1;
-}
-
-void Lcd::bl_disable()
-{
- bl = 0;
-}
-
-void Lcd::init(void)
-{
-
- write_cmd(CMD_DISPLAY_OFF);
- write_cmd(CMD_SET_BIAS_7);
- write_cmd(CMD_SET_ADC_NORMAL);
- write_cmd(CMD_SET_COM_REVERSE);
- write_cmd((CMD_SET_RESISTOR_RATIO | 0x02));
- write_cmd(CMD_SET_VOLUME_FIRST);
- write_cmd((CMD_SET_VOLUME_SECOND | 0x04));
- write_cmd((CMD_SET_POWER_CONTROL | 0x07));
- fill_pages(0, 8, 0x00);
-
-}
-
-/**
- @brief Displays a string at the specified position for with 5x7 font size.
- @return none
- **/
-void Lcd::display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str)
-{
- uint8_t ui8x;
- uint8_t ui8i;
- uint8_t ui8ch;
- uint8_t ui8data;
-
- ui8ch = 0;
- ui8x = ui8col;
-
- while ((pi8str[ui8ch] != 0) && (ui8col < LCD_COLUMNS)) {
- set_cursor(ui8row, ui8x); /* Set cursor position */
-
- for (ui8i = 0; ui8i < 5; ui8i++) { /* Symbol matrix column loop */
- ui8data = pui8font5x7[pi8str[ui8ch] - OFFS_ASCII][ui8i];
-
- write_data(ui8data);
- }
-
- ui8x += 6; /* Increase column counter with 6 pixels */
- ui8ch++; /* Increment counter */
- }
- write_cmd(CMD_DISPLAY_ON);
-
-}
-
-/**
- @brief Displays a symbol (8 x width) at the specified position on the LCD.
- @param ui8row - row number
- @param ui8col - column number
- @param ui8width - symbol width
- @param pui8symbol - symbol to display
- @return none
- **/
-
-void Lcd::display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width,
- const uint8_t *pui8symbol)
-{
- uint8_t ui8i;
- uint8_t ui8data;
-
- set_cursor(ui8row, ui8col); /* Set cursor position */
- for (ui8i = 0; ui8i < ui8width; ui8i++) { /* Symbol matrix column loop */
- ui8data = pui8symbol[ui8i];
- write_data(ui8data);
- }
- write_cmd(CMD_DISPLAY_ON);
-}
-
-/**
- @brief Fills the selected LCD pages with the data specified.
- @param ui8start - start element
- @param ui8num - elements numbers to fill
- @param ui8Data - data to fill
- @return none
- **/
-
-void Lcd::fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data)
-{
-
- uint8_t ui8p;
- uint8_t ui8c;
-
- for (ui8p = ui8start; ui8p < (ui8start + ui8num); ui8p++) {
- set_cursor(ui8p, 0);
-
- for (ui8c = 0; ui8c < LCD_COLUMNS; ui8c++) {
- write_data(ui8Data);
- }
- }
-
- write_cmd(CMD_DISPLAY_ON);
-}
-
-/**
- @brief Sets the start line of the LCD.
- @param ui8line - line to start with
- @return none
- **/
-
-void Lcd::set_line(uint8_t ui8line)
-{
-
- uint8_t ui8Cmd;
- ui8Cmd = CMD_SET_DISP_START_LINE | (ui8line & 0x3F); /* Set start line */
- write_cmd(ui8Cmd);
-
-}
-
-
-/**
- @brief Sets the cursor position at which data will be written.
- @param ui8PA - page number
- @param ui8CA - column number
- @return none
- **/
-
-void Lcd::set_cursor(uint8_t ui8PA, uint8_t ui8CA)
-{
- uint8_t ui8Cmd;
-
- ui8Cmd = 0xB0 | (ui8PA & 0x0F); /* Set page address */
- write_cmd(ui8Cmd);
-
- ui8Cmd = ui8CA & 0x0F; /* Set column address LSB CA[3:0] */
- write_cmd(ui8Cmd);
-
- ui8Cmd = 0x10 | (ui8CA >> 4); /* Set column address MSB CA[7:4] */
- write_cmd(ui8Cmd);
-}
-
-
-const uint8_t Lcd::pui8Rec8x8[8] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
-};
-const uint8_t Lcd::pui8RecInv8x8[8] = {
- 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF
-};
-
-const uint8_t Lcd::pui8font5x7[96][5] = {
- {0x00, 0x00, 0x00, 0x00, 0x00}, /* 32 */
- {0x00, 0x00, 0x4F, 0x00, 0x00}, /* ! 33 */
- {0x00, 0x07, 0x00, 0x07, 0x00}, /* " 34 */
- {0x14, 0x7F, 0x14, 0x7F, 0x14}, /* # 35 */
- {0x24, 0x2A, 0x7F, 0x2A, 0x12}, /* $ 36 */
- {0x23, 0x13, 0x08, 0x64, 0x62}, /* % 37 */
- {0x36, 0x49, 0x55, 0x22, 0x50}, /* & 38 */
- {0x00, 0x05, 0x03, 0x00, 0x00}, /* ' 39 */
- {0x00, 0x1C, 0x22, 0x41, 0x00}, /* ( 40 */
- {0x00, 0x41, 0x22, 0x1C, 0x00}, /* ) 41 */
- {0x14, 0x08, 0x3E, 0x08, 0x14}, /* * 42 */
- {0x08, 0x08, 0x3E, 0x08, 0x08}, /* + 43 */
- {0x00, 0x50, 0x30, 0x00, 0x00}, /* , 44 */
- {0x08, 0x08, 0x08, 0x08, 0x08}, /* - 45 */
- {0x00, 0x60, 0x60, 0x00, 0x00}, /* . 46 */
- {0x20, 0x10, 0x08, 0x04, 0x02}, /* / 47 */
- {0x3E, 0x51, 0x49, 0x45, 0x3E}, /* 0 48 */
- {0x00, 0x42, 0x7F, 0x40, 0x00}, /* 1 49 */
- {0x42, 0x61, 0x51, 0x49, 0x46}, /* 2 50 */
- {0x21, 0x41, 0x45, 0x4B, 0x31}, /* 3 51 */
- {0x18, 0x14, 0x12, 0x7F, 0x10}, /* 4 52 */
- {0x27, 0x45, 0x45, 0x45, 0x39}, /* 5 53 */
- {0x3C, 0x4A, 0x49, 0x49, 0x30}, /* 6 54 */
- {0x01, 0x71, 0x09, 0x05, 0x03}, /* 7 55 */
- {0x36, 0x49, 0x49, 0x49, 0x36}, /* 8 56 */
- {0x06, 0x49, 0x49, 0x29, 0x1E}, /* 9 57 */
- {0x36, 0x36, 0x00, 0x00, 0x00}, /* : 58 */
- {0x56, 0x36, 0x00, 0x00, 0x00}, /* ; 59 */
- {0x08, 0x14, 0x22, 0x41, 0x00}, /* < 60 */
- {0x14, 0x14, 0x14, 0x14, 0x14}, /* = 61 */
- {0x00, 0x41, 0x22, 0x14, 0x08}, /* > 62 */
- {0x02, 0x01, 0x51, 0x09, 0x06}, /* ? 63 */
- {0x30, 0x49, 0x79, 0x41, 0x3E}, /* @ 64 */
- {0x7E, 0x11, 0x11, 0x11, 0x7E}, /* A 65 */
- {0x7F, 0x49, 0x49, 0x49, 0x36}, /* B 66 */
- {0x3E, 0x41, 0x41, 0x41, 0x22}, /* C 67 */
- {0x7F, 0x41, 0x41, 0x22, 0x1C}, /* D 68 */
- {0x7F, 0x49, 0x49, 0x49, 0x41}, /* E 69 */
- {0x7F, 0x09, 0x09, 0x09, 0x01}, /* F 70 */
- {0x3E, 0x41, 0x49, 0x49, 0x7A}, /* G 71 */
- {0x7F, 0x08, 0x08, 0x08, 0x7F}, /* H 72 */
- {0x00, 0x41, 0x7F, 0x41, 0x00}, /* I 73 */
- {0x20, 0x40, 0x41, 0x3F, 0x01}, /* J 74 */
- {0x7F, 0x08, 0x14, 0x22, 0x41}, /* K 75 */
- {0x7F, 0x40, 0x40, 0x40, 0x40}, /* L 76 */
- {0x7F, 0x02, 0x0C, 0x02, 0x7F}, /* M 77 */
- {0x7F, 0x04, 0x08, 0x10, 0x7F}, /* N 78 */
- {0x3E, 0x41, 0x41, 0x41, 0x3E}, /* O 79 */
- {0x7F, 0x09, 0x09, 0x09, 0x06}, /* P 80 */
- {0x3E, 0x41, 0x51, 0x21, 0x5E}, /* Q 81 */
- {0x7F, 0x09, 0x19, 0x29, 0x46}, /* R 82 */
- {0x46, 0x49, 0x49, 0x49, 0x31}, /* S 83 */
- {0x01, 0x01, 0x7F, 0x01, 0x01}, /* T 84 */
- {0x3F, 0x40, 0x40, 0x40, 0x3F}, /* U 85 */
- {0x1F, 0x20, 0x40, 0x20, 0x1F}, /* V 86 */
- {0x3F, 0x40, 0x30, 0x40, 0x3F}, /* W 87 */
- {0x63, 0x14, 0x08, 0x14, 0x63}, /* X 88 */
- {0x07, 0x08, 0x70, 0x08, 0x07}, /* Y 89 */
- {0x61, 0x51, 0x49, 0x45, 0x43}, /* Z 90 */
- {0x00, 0x7F, 0x41, 0x41, 0x00}, /* [ 91 */
- {0x02, 0x04, 0x08, 0x10, 0x20}, /* \ 92 */
- {0x00, 0x41, 0x41, 0x7F, 0x00}, /* ] 93 */
- {0x04, 0x02, 0x01, 0x02, 0x04}, /* ^ 94 */
- {0x40, 0x40, 0x40, 0x40, 0x40}, /* _ 95 */
- {0x00, 0x01, 0x02, 0x04, 0x00}, /* ` 96 */
- {0x20, 0x54, 0x54, 0x54, 0x78}, /* a 97 */
- {0x7F, 0x50, 0x48, 0x48, 0x30}, /* b 98 */
- {0x38, 0x44, 0x44, 0x44, 0x20}, /* c 99 */
- {0x38, 0x44, 0x44, 0x48, 0x7F}, /* d 100 */
- {0x38, 0x54, 0x54, 0x54, 0x18}, /* e 101 */
- {0x08, 0x7E, 0x09, 0x01, 0x02}, /* f 102 */
- {0x0C, 0x52, 0x52, 0x52, 0x3E}, /* g 103 */
- {0x7F, 0x08, 0x04, 0x04, 0x78}, /* h 104 */
- {0x00, 0x44, 0x7D, 0x40, 0x00}, /* i 105 */
- {0x20, 0x40, 0x44, 0x3D, 0x00}, /* j 106 */
- {0x7F, 0x10, 0x28, 0x44, 0x00}, /* k 107 */
- {0x00, 0x41, 0x7F, 0x40, 0x00}, /* l 108 */
- {0x78, 0x04, 0x18, 0x04, 0x78}, /* m 109 */
- {0x7C, 0x08, 0x04, 0x04, 0x78}, /* n 110 */
- {0x38, 0x44, 0x44, 0x44, 0x38}, /* o 111 */
- {0x7C, 0x14, 0x14, 0x14, 0x08}, /* p 112 */
- {0x08, 0x14, 0x14, 0x18, 0x7C}, /* q 113 */
- {0x7C, 0x08, 0x04, 0x04, 0x08}, /* r 114 */
- {0x48, 0x54, 0x54, 0x54, 0x20}, /* s 115 */
- {0x04, 0x3F, 0x44, 0x40, 0x20}, /* t 116 */
- {0x3C, 0x40, 0x40, 0x20, 0x7C}, /* u 117 */
- {0x1C, 0x20, 0x40, 0x20, 0x1C}, /* v 118 */
- {0x3C, 0x40, 0x30, 0x40, 0x3C}, /* w 119 */
- {0x44, 0x28, 0x10, 0x28, 0x44}, /* x 120 */
- {0x0C, 0x50, 0x50, 0x50, 0x3C}, /* y 121 */
- {0x44, 0x64, 0x54, 0x4C, 0x44}, /* z 122 */
- {0x00, 0x08, 0x36, 0x41, 0x00}, /* { 123 */
- {0x00, 0x00, 0x7F, 0x00, 0x00}, /* | 124 */
- {0x00, 0x41, 0x36, 0x08, 0x00}, /* } 125 */
- {0x0C, 0x02, 0x0C, 0x10, 0x0C}, /* ~ 126 */
- {0x00, 0x00, 0x00, 0x00, 0x00} /* 127 */
-};
--- a/libraries/eval_adxl362_ardz/lcd.h Tue May 17 18:37:29 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/**
- ******************************************************************************
- * @file Lcd.c
- * @brief Header file for ST7565R LCD control.
- * @author ADI
- * @date March 2016
- *
- *******************************************************************************
- * Copyright 2015(c) Analog Devices, Inc.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Analog Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * - The use of this software may or may not infringe the patent rights
- * of one or more patent holders. This license does not release you
- * from the requirement that you obtain separate licenses from these
- * patent holders to use this software.
- * - Use of the software either in source or binary form, must be run
- * on or directly connected to an Analog Devices Inc. component.
- *
- * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *******************************************************************************
- **/
-#ifndef LCD_H_
-#define LCD_H_
-
-
-/******************************************************************************/
-/***************************** Include Files **********************************/
-/******************************************************************************/
-#include <stdio.h>
-#include "mbed.h"
-
-class Lcd
-{
-public:
-
- const static uint8_t pui8Rec8x8[8];
- const static uint8_t pui8RecInv8x8[8];
- const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14)
-
- Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6,
- PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK =
- SPI_SCK);
- void init(void);
- void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str);
- void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width,
- const uint8_t *pui8symbol);
- void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data);
- void set_line(uint8_t ui8line);
- void set_cursor(uint8_t ui8PA, uint8_t ui8CA);
- void bl_enable();
- void bl_disable();
-
- void write_cmd(uint8_t cmd);
- void write_data(uint8_t data);
-
-
- typedef enum {
- CMD_DISPLAY_OFF = 0xAE,
- CMD_DISPLAY_ON = 0xAF,
- CMD_SET_DISP_START_LINE = 0x40,
- CMD_SET_PAGE = 0xB0,
- CMD_SET_COLUMN_UPPER = 0x10,
- CMD_SET_COLUMN_LOWER = 0x00,
- CMD_SET_ADC_NORMAL = 0xA0,
- CMD_SET_ADC_REVERSE = 0xA1,
- CMD_SET_DISP_NORMAL = 0xA6,
- CMD_SET_DISP_REVERSE = 0xA7,
- CMD_SET_ALLPTS_NORMAL = 0xA4,
- CMD_SET_ALLPTS_ON = 0xA5,
- CMD_SET_BIAS_9 = 0xA2,
- CMD_SET_BIAS_7 = 0xA3,
- CMD_RMW = 0xE0,
- CMD_RMW_CLEAR = 0xEE,
- CMD_INTERNAL_RESET = 0xE2,
- CMD_SET_COM_NORMAL = 0xC0,
- CMD_SET_COM_REVERSE = 0xC8,
- CMD_SET_POWER_CONTROL = 0x28,
- CMD_SET_RESISTOR_RATIO = 0x20,
- CMD_SET_VOLUME_FIRST = 0x81,
- CMD_SET_VOLUME_SECOND = 0,
- CMD_SET_STATIC_OFF = 0xAC,
- CMD_SET_STATIC_ON = 0xAD,
- CMD_SET_STATIC_REG = 0x0,
- CMD_SET_BOOSTER_FIRST = 0xF8,
- CMD_SET_BOOSTER_234 = 0,
- CMD_SET_BOOSTER_5 = 1,
- CMD_SET_BOOSTER_6 = 3,
- CMD_NOP = 0xE3,
- CMD_TEST = 0xF0,
- } lcd_commands_t;
-
- static const uint8_t LCD_COLUMNS = 128u;
- static const uint8_t LCD_PAGES = 4u;
- static const uint8_t LCD_LINES = 64u;
- static const uint8_t UP_X = 112;
- static const uint8_t LEFT_X = 104;
- static const uint8_t RIGHT_X = 120;
- static const uint8_t DOWN_X = 112;
- static const uint8_t CENTER_X = 112;
- static const uint8_t ACC_LIMIT = 80;
- static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y
- static const uint8_t OFFS_ASCII = 32; ///< ASCII offset
-
- static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C
- static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code)
-
-private:
-
- DigitalOut rst, a0, bl, cs;
- SPI lcd_spi;
-
-
-
-};
-
-#endif /* LCD_H_ */
CN0357 - Toxic gas measurement
CN0216 - Weight Scale