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

Files at this revision

API Documentation at this revision

Comitter:
Adrian Suciu
Date:
Thu Aug 18 14:46:41 2016 +0300
Parent:
24:dae7123d432a
Child:
26:1b988c505139
Commit message:
index on cn0391: 86ec328 Improved compatibility with Linux systems

Changed in this revision

examples/CN0391_example/Makefile Show annotated file Show diff for this revision Revisions of this file
examples/CN0391_example/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/CN0391_example/Makefile	Thu Aug 18 14:46:41 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/CN0391_example/main.cpp	Thu Aug 18 14:46:41 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. */
+}
+