Index: ADuCM360_demo_cn0359/.cproject
===================================================================
diff -u
--- ADuCM360_demo_cn0359/.cproject (revision 0)
+++ ADuCM360_demo_cn0359/.cproject (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,419 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: ADuCM360_demo_cn0359/.project
===================================================================
diff -u
--- ADuCM360_demo_cn0359/.project (revision 0)
+++ ADuCM360_demo_cn0359/.project (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,41 @@
+
+
+ ADuCM360_demo_cn0359
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+ com.analog.crosscore.managedbuilder.core.cleanbuilder
+ clean,
+
+
+
+
+ com.analog.crosscore.deviceprogrammer.deviceprogrammerbuilder
+ auto,full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.analog.crosscore.managedbuilder.core.CCESProjectNature
+ com.arm.cmsis.pack.project.RteNature
+ org.eclipse.cdt.core.ccnature
+
+
Index: ADuCM360_demo_cn0359/.settings/DefaultProjectAttribute.prefs
===================================================================
diff -u
--- ADuCM360_demo_cn0359/.settings/DefaultProjectAttribute.prefs (revision 0)
+++ ADuCM360_demo_cn0359/.settings/DefaultProjectAttribute.prefs (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,5 @@
+ArtifactType=org.eclipse.cdt.build.core.buildArtefactType.exe
+CoreId=0
+Processor=ADuCM360
+Revision=none
+eclipse.preferences.version=1
Index: ADuCM360_demo_cn0359/.settings/ToolChain.prefs
===================================================================
diff -u
--- ADuCM360_demo_cn0359/.settings/ToolChain.prefs (revision 0)
+++ ADuCM360_demo_cn0359/.settings/ToolChain.prefs (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+version=2.11.0.0
Index: ADuCM360_demo_cn0359/RTE/Device/ADuCM360/ADuCM360.ld
===================================================================
diff -u
--- ADuCM360_demo_cn0359/RTE/Device/ADuCM360/ADuCM360.ld (revision 0)
+++ ADuCM360_demo_cn0359/RTE/Device/ADuCM360/ADuCM360.ld (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,321 @@
+/*
+ * Portions Copyright (c) 2017 Analog Devices, Inc.
+ *
+ * Based on Device/ARM/ARMCM3/Source/GCC/gcc_arm.ld file in
+ * ARM.CMSIS.4.5.0.pack.
+ */
+
+/*
+ * Placeholder to list other libraries required by the application.
+
+GROUP(
+)
+
+ */
+
+ /*
+ * Memory Spaces Definitions.
+ *
+ * Need modifying for a specific board.
+ * FLASH.ORIGIN: starting address of flash
+ * FLASH.LENGTH: length of flash
+ * RAM.ORIGIN: starting address of RAM bank 0
+ * RAM.LENGTH: length of RAM bank 0
+ *
+ * The values below can be addressed in further linker scripts
+ * using functions like 'ORIGIN(RAM)' or 'LENGTH(RAM)'.
+ */
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
+
+ /*
+ * Optional sections; define the origin and length to match
+ * the the specific requirements of your hardware. The zero
+ * length prevents inadvertent allocation.
+ */
+ CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0
+ FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
+ EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
+ EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
+ EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
+ EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
+}
+
+/*
+ * For external ram use something like:
+ * RAM (xrw) : ORIGIN = 0x64000000, LENGTH = 2048K
+ *
+ * For special RAM areas use something like:
+ * MEMORY_ARRAY (xrw) : ORIGIN = 0x20002000, LENGTH = 32
+ */
+
+/*
+ * The entry point is informative, for debuggers and simulators,
+ * since the Cortex-M vector points to it anyway.
+ */
+ENTRY(Reset_Handler)
+
+
+/* Sections Definitions */
+
+SECTIONS
+{
+ /*
+ * For Cortex-M devices, the beginning of the startup code is stored in
+ * the .vectors section, which goes to FLASH
+ */
+ .vectors :
+ {
+ . = ALIGN(4);
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+
+ /*
+ * This section is here for convenience, to store the
+ * startup code at the beginning of the flash area, hoping that
+ * this will increase the readability of the listing.
+ */
+ *(.after_vectors .after_vectors.*) /* Startup code and ISR */
+
+ __end__ = .;
+ . = ALIGN(4);
+ } > FLASH
+
+ /*
+ * The program code is stored in the .text section,
+ * which goes to FLASH.
+ */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+
+ } >FLASH
+
+ /* ARM magic sections */
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.c */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.c */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ /*
+ * The initialised data section.
+ * The program executes knowing that the data is in the RAM
+ * but the loader puts the initial values in the FLASH (inidata).
+ * It is one task of the startup to copy the initial values from
+ * FLASH to RAM.
+ */
+
+ __etext = .;
+
+ .data : AT ( __etext )
+ {
+ . = ALIGN(4);
+
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } >RAM
+
+
+ /*
+ * The uninitialised data section. NOLOAD is used to avoid
+ * the "section `.bss' type changed to PROGBITS" warning
+ */
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of DSRAM_A, and move stack limit down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds DSRAM_A limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region DSRAM_A overflowed with stack")
+
+ /* For external memory assign */
+ .bss_CCMRAM : ALIGN(4)
+ {
+ *(.bss.CCMRAM .bss.CCMRAM.*)
+ } > CCMRAM
+
+ /*
+ * The FLASH Bank1.
+ * The C or assembly source must explicitly place the code
+ * or data there using the "section" attribute.
+ */
+ .b1text :
+ {
+ *(.b1text) /* remaining code */
+ *(.b1rodata) /* read-only data (constants) */
+ *(.b1rodata.*)
+ } >FLASHB1
+
+ /*
+ * The EXTMEM.
+ * The C or assembly source must explicitly place the code or data there
+ * using the "section" attribute.
+ */
+
+ /* EXTMEM Bank0 */
+ .eb0text :
+ {
+ *(.eb0text) /* remaining code */
+ *(.eb0rodata) /* read-only data (constants) */
+ *(.eb0rodata.*)
+ } >EXTMEMB0
+
+ /* EXTMEM Bank1 */
+ .eb1text :
+ {
+ *(.eb1text) /* remaining code */
+ *(.eb1rodata) /* read-only data (constants) */
+ *(.eb1rodata.*)
+ } >EXTMEMB1
+
+ /* EXTMEM Bank2 */
+ .eb2text :
+ {
+ *(.eb2text) /* remaining code */
+ *(.eb2rodata) /* read-only data (constants) */
+ *(.eb2rodata.*)
+ } >EXTMEMB2
+
+ /* EXTMEM Bank0 */
+ .eb3text :
+ {
+ *(.eb3text) /* remaining code */
+ *(.eb3rodata) /* read-only data (constants) */
+ *(.eb3rodata.*)
+ } >EXTMEMB3
+
+
+ /* After that there are only debugging sections. */
+
+ /* This can remove the debugging information from the standard libraries */
+ /*
+ DISCARD :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+ */
+
+}
+
\ No newline at end of file
Index: ADuCM360_demo_cn0359/RTE/Device/ADuCM360/startup_ADuCM360.c
===================================================================
diff -u
--- ADuCM360_demo_cn0359/RTE/Device/ADuCM360/startup_ADuCM360.c (revision 0)
+++ ADuCM360_demo_cn0359/RTE/Device/ADuCM360/startup_ADuCM360.c (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,404 @@
+/* File: startup_ADuCM360.c
+ * Purpose: startup file for Cortex-M3 devices.
+ * Should be used with GCC 'GNU Tools ARM Embedded'
+ * Version: V1.01
+ * Date: 12 June 2014
+ *
+ */
+/* Copyright (c) 2011 - 2014 ARM LIMITED
+
+ 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 ARM nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+ *
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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.
+
+ Portions Copyright (c) 2017 Analog Devices, Inc.
+ ---------------------------------------------------------------------------*/
+
+#include
+
+// ----------------------------------------------------------------------------
+/*----------------------------------------------------------------------------
+ Linker generated Symbols
+ *----------------------------------------------------------------------------*/
+extern uint32_t __etext;
+extern uint32_t __data_start__;
+extern uint32_t __data_end__;
+extern uint32_t __copy_table_start__;
+extern uint32_t __copy_table_end__;
+extern uint32_t __zero_table_start__;
+extern uint32_t __zero_table_end__;
+extern uint32_t __bss_start__;
+extern uint32_t __bss_end__;
+extern uint32_t __StackTop;
+
+extern unsigned int _sidata;
+// Begin address for the .data section; defined in linker script
+extern unsigned int _sdata;
+// End address for the .data section; defined in linker script
+extern unsigned int _edata;
+
+/*----------------------------------------------------------------------------
+ Exception / Interrupt Handler Function Prototype
+ *----------------------------------------------------------------------------*/
+typedef void( *pFunc )( void );
+
+/*----------------------------------------------------------------------------
+ External References
+ *----------------------------------------------------------------------------*/
+#ifndef __START
+extern void _start(void) __attribute__((
+ noreturn)); /* PreeMain (C library entry point) */
+#else
+extern int __START(void) __attribute__((noreturn)); /* main entry point */
+#endif
+
+#ifndef __NO_SYSTEM_INIT
+extern void SystemInit (void); /* CMSIS System Initialization */
+#endif
+
+
+/*----------------------------------------------------------------------------
+ Internal References
+ *----------------------------------------------------------------------------*/
+void Default_Handler(void); /* Default empty handler */
+
+
+/*----------------------------------------------------------------------------
+ User Initial Stack & Heap
+ *----------------------------------------------------------------------------*/
+#ifndef __STACK_SIZE
+#define __STACK_SIZE 0x00000400
+#endif
+static uint8_t stack[__STACK_SIZE] __attribute__ ((aligned(8), used,
+ section(".stack")));
+
+#ifndef __HEAP_SIZE
+#define __HEAP_SIZE 0x00000C00
+#endif
+#if __HEAP_SIZE > 0
+static uint8_t heap[__HEAP_SIZE] __attribute__ ((aligned(8), used,
+ section(".heap")));
+#endif
+
+/*----------------------------------------------------------------------------
+ Exception / Interrupt Handler
+ *----------------------------------------------------------------------------*/
+/* Cortex-M3 Processor Exceptions */
+void Reset_Handler (void) __attribute__ ((weak));
+void NMI_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void HardFault_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void MemManage_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void BusFault_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void UsageFault_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void SVC_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void DebugMon_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void PendSV_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+void SysTick_Handler (void) __attribute__ ((weak,
+ alias("Default_Handler")));
+
+// Forward declaration of the specific IRQ handlers. These are aliased
+// to the Default_Handler, which is a 'forever' loop. When the application
+// defines a handler (with the same name), this will automatically take
+// precedence over these weak definitions
+//
+
+void WakeUp_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 0]
+void Ext_Int0_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 1]
+void Ext_Int1_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 2]
+void Ext_Int2_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 3]
+void Ext_Int3_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 4]
+void Ext_Int4_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 5]
+void Ext_Int5_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 6]
+void Ext_Int6_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 7]
+void Ext_Int7_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 8]
+void WDog_Tmr_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[ 9]
+void GP_Tmr0_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[11]
+void GP_Tmr1_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[12]
+void ADC0_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[13]
+void ADC1_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[14]
+void SINC2_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[15]
+void Flsh_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[16]
+void UART_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[17]
+void SPI0_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[18]
+void SPI1_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[19]
+void I2C0_Slave_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[20]
+void I2C0_Master_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[21]
+void DMA_Err_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[22]
+void DMA_SPI1_TX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[23]
+void DMA_SPI1_RX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[24]
+void DMA_UART_TX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[25]
+void DMA_UART_RX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[26]
+void DMA_I2C0_STX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[27]
+void DMA_I2C0_SRX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[28]
+void DMA_I2C0_MTX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[29]
+void DMA_I2C0_MRX_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[30]
+void DMA_DAC_Out_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[31]
+void DMA_ADC0_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[32]
+void DMA_ADC1_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[33]
+void DMA_SINC2_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[34]
+void PWMTRIP_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[35]
+void PWM0_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[36]
+void PWM1_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[37]
+void PWM2_Int_Handler (void) __attribute__ ((weak,
+ alias ("Default_Handler"))); //[38]
+
+// ----------------------------------------------------------------------------
+
+// The vector table.
+// This relies on the linker script to place at correct location in memory.
+const pFunc __Vectors[] __attribute__ ((section(".vectors"))) = {
+ //
+ (pFunc) &__StackTop, // The initial stack pointer
+ Reset_Handler, // The reset handler
+
+ NMI_Handler, // The NMI handler
+ HardFault_Handler, // The hard fault handler
+
+#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
+ MemManage_Handler, // The MPU fault handler
+ BusFault_Handler,// The bus fault handler
+ UsageFault_Handler,// The usage fault handler
+#else
+ 0, 0, 0, // Reserved
+#endif
+ 0, // Reserved
+ 0, // Reserved
+ 0, // Reserved
+ 0, // Reserved
+ SVC_Handler, // SVCall handler
+#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
+ DebugMon_Handler, // Debug monitor handler
+#else
+ 0, // Reserved
+#endif
+ 0, // Reserved
+ PendSV_Handler, // The PendSV handler
+ SysTick_Handler, // The SysTick handler
+
+ // ----------------------------------------------------------------------
+ // ADuCM360 vectors
+ WakeUp_Int_Handler, //[ 0]
+ Ext_Int0_Handler, //[ 1]
+ Ext_Int1_Handler, //[ 2]
+ Ext_Int2_Handler, //[ 3]
+ Ext_Int3_Handler, //[ 4]
+ Ext_Int4_Handler, //[ 5]
+ Ext_Int5_Handler, //[ 6]
+ Ext_Int6_Handler, //[ 7]
+ Ext_Int7_Handler, //[ 8]
+ WDog_Tmr_Int_Handler, //[ 9]
+ 0, //[10]
+ GP_Tmr0_Int_Handler, //[11]
+ GP_Tmr1_Int_Handler, //[12]
+ ADC0_Int_Handler, //[13]
+ ADC1_Int_Handler, //[14]
+ SINC2_Int_Handler, //[15]
+ Flsh_Int_Handler, //[16]
+ UART_Int_Handler, //[17]
+ SPI0_Int_Handler, //[18]
+ SPI1_Int_Handler, //[19]
+ I2C0_Slave_Int_Handler, //[20]
+ I2C0_Master_Int_Handler, //[21]
+ DMA_Err_Int_Handler, //[22]
+ DMA_SPI1_TX_Int_Handler, //[23]
+ DMA_SPI1_RX_Int_Handler, //[24]
+ DMA_UART_TX_Int_Handler, //[25]
+ DMA_UART_RX_Int_Handler, //[26]
+ DMA_I2C0_STX_Int_Handler, //[27]
+ DMA_I2C0_SRX_Int_Handler, //[28]
+ DMA_I2C0_MTX_Int_Handler, //[29]
+ DMA_I2C0_MRX_Int_Handler, //[30]
+ DMA_DAC_Out_Int_Handler, //[31]
+ DMA_ADC0_Int_Handler, //[32]
+ DMA_ADC1_Int_Handler, //[33]
+ DMA_SINC2_Int_Handler, //[34]
+ PWMTRIP_Int_Handler, //[35]
+ PWM0_Int_Handler, //[36]
+ PWM1_Int_Handler, //[37]
+ PWM2_Int_Handler, //[38]
+ 0, //[39]
+};
+
+// ----------------------------------------------------------------------------
+
+/*----------------------------------------------------------------------------
+ Reset Handler called on controller reset
+ *----------------------------------------------------------------------------*/
+void Reset_Handler(void)
+{
+ uint32_t *pSrc, *pDest;
+ uint32_t *pTable __attribute__((unused));
+
+ /* Firstly it copies data from read only memory to RAM. There are two schemes
+ * to copy. One can copy more than one sections. Another can only copy
+ * one section. The former scheme needs more instructions and read-only
+ * data to implement than the latter.
+ * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
+
+#ifdef __STARTUP_COPY_MULTIPLE
+ /* Multiple sections scheme.
+ *
+ * Between symbol address __copy_table_start__ and __copy_table_end__,
+ * there are array of triplets, each of which specify:
+ * offset 0: LMA of start of a section to copy from
+ * offset 4: VMA of start of a section to copy to
+ * offset 8: size of the section to copy. Must be multiply of 4
+ *
+ * All addresses must be aligned to 4 bytes boundary.
+ */
+ pTable = &__copy_table_start__;
+
+ for (; pTable < &__copy_table_end__; pTable = pTable + 3) {
+ pSrc = (uint32_t*)*(pTable + 0);
+ pDest = (uint32_t*)*(pTable + 1);
+ for (; pDest < (uint32_t*)(*(pTable + 1) + *(pTable + 2)) ; ) {
+ *pDest++ = *pSrc++;
+ }
+ }
+#else
+ /* Single section scheme.
+ *
+ * The ranges of copy from/to are specified by following symbols
+ * __etext: LMA of start of the section to copy from. Usually end of text
+ * __data_start__: VMA of start of the section to copy to
+ * __data_end__: VMA of end of the section to copy to
+ *
+ * All addresses must be aligned to 4 bytes boundary.
+ */
+ pSrc = &__etext;
+ pDest = &__data_start__;
+
+ for ( ; pDest < &__data_end__ ; ) {
+ *pDest++ = *pSrc++;
+ }
+#endif /*__STARTUP_COPY_MULTIPLE */
+
+ /* This part of work usually is done in C library startup code. Otherwise,
+ * define this macro to enable it in this startup.
+ *
+ * There are two schemes too. One can clear multiple BSS sections. Another
+ * can only clear one section. The former is more size expensive than the
+ * latter.
+ *
+ * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
+ * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later.
+ */
+#ifdef __STARTUP_CLEAR_BSS_MULTIPLE
+ /* Multiple sections scheme.
+ *
+ * Between symbol address __copy_table_start__ and __copy_table_end__,
+ * there are array of tuples specifying:
+ * offset 0: Start of a BSS section
+ * offset 4: Size of this BSS section. Must be multiply of 4
+ */
+ pTable = &__zero_table_start__;
+
+ for (; pTable < &__zero_table_end__; pTable = pTable + 2) {
+ pDest = (uint32_t*)*(pTable + 0);
+ for (; pDest < (uint32_t*)(*(pTable + 0) + *(pTable + 1)) ; ) {
+ *pDest++ = 0;
+ }
+ }
+#elif defined (__STARTUP_CLEAR_BSS)
+ /* Single BSS section scheme.
+ *
+ * The BSS section is specified by following symbols
+ * __bss_start__: start of the BSS section.
+ * __bss_end__: end of the BSS section.
+ *
+ * Both addresses must be aligned to 4 bytes boundary.
+ */
+ pDest = &__bss_start__;
+
+ for ( ; pDest < &__bss_end__ ; ) {
+ *pDest++ = 0ul;
+ }
+#endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
+
+#ifndef __NO_SYSTEM_INIT
+ SystemInit();
+#endif
+
+#ifndef __START
+#define __START _start
+#endif
+ __START();
+
+}
+
+/*----------------------------------------------------------------------------
+ Default Handler for Exceptions / Interrupts
+ *----------------------------------------------------------------------------*/
+void Default_Handler(void)
+{
+
+ while(1);
+}
+
+
+// ----------------------------------------------------------------------------
Index: ADuCM360_demo_cn0359/RTE/Device/ADuCM360/system_ADuCM360.c
===================================================================
diff -u
--- ADuCM360_demo_cn0359/RTE/Device/ADuCM360/system_ADuCM360.c (revision 0)
+++ ADuCM360_demo_cn0359/RTE/Device/ADuCM360/system_ADuCM360.c (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ * @file system_ADuCM360.c
+ * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Source File for
+ * Device ADuCM360
+ * @version V3.10
+ * @date 23. November 2012
+ *
+ * @note
+ *
+ ******************************************************************************/
+/* Copyright (c) 2012 ARM LIMITED
+
+ 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 ARM nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+ *
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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.
+
+ Portions Copyright (c) 2017 Analog Devices, Inc.
+ ---------------------------------------------------------------------------*/
+
+#include
+
+#include "ADuCM360.h"
+
+/*----------------------------------------------------------------------------
+ DEFINES
+ *----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Define clocks
+ *----------------------------------------------------------------------------*/
+#define __HFOSC (16000000UL) /* Oscillator frequency */
+#define __XTAL (32768UL) /* 32kHz Frequency */
+
+#define SYSTEM_CLOCK (__HFOSC)
+
+/*----------------------------------------------------------------------------
+ Clock Variable definitions
+ *----------------------------------------------------------------------------*/
+uint32_t SystemCoreClock =
+ SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/
+uint32_t uClk; /* Undivided System Clock Frequency (UCLK) */
+
+/* Frequency of the external clock source connected to P1.0 */
+uint32_t SystemExtClock;
+
+
+/*----------------------------------------------------------------------------
+ Clock functions
+ *----------------------------------------------------------------------------*/
+/*!
+ * Update the clock
+ *
+ * @return none
+ *
+ * @brief Updates the variable SystemCoreClock. It must be called before using
+ * SystemCoreClock variable and whenever the core clock is changed
+ * during program excution.
+*/
+void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
+{
+ int iDiv;
+
+ switch (pADI_CLKCTL->CLKCON0 & CLKCON0_CLKMUX_MSK ) {
+ case CLKCON0_CLKMUX_HFOSC:
+ uClk = __HFOSC >> (pADI_CLKCTL->CLKSYSDIV & CLKSYSDIV_DIV2EN_MSK);
+ break;
+
+ case CLKCON0_CLKMUX_LFOSC:
+ case CLKCON0_CLKMUX_LFXTAL:
+ uClk = __XTAL;
+ break;
+
+ case CLKCON0_CLKMUX_EXTCLK:
+ uClk = SystemExtClock;
+ break;
+
+ default:
+ break;
+ }
+
+ iDiv = (pADI_CLKCTL->CLKCON0 &
+ CLKCON0_CD_MSK); // Read CLKCON0 divider bits
+ SystemCoreClock = uClk >> iDiv;
+}
+
+/**
+ * Initialize the system
+ *
+ * @param none
+ * @return none
+ *
+ * @brief Setup the microcontroller system.
+ * Initialize the System.
+ */
+void SystemInit (void)
+{
+ /* SetSystemExtClkFreq(Freq); // if an external clock is used SetSystemExtClkFreq must be called
+ // before calling SystemCoreClockUpdate() */
+
+ pADI_WDT->T3CON = 0; /* disable watchdog */
+ pADI_CLKCTL->CLKCON0 = 0x0; /* 16MHz output of UCLK divide */
+ pADI_CLKCTL->CLKSYSDIV = 0; /* No divide of 16MHz system clock */
+ pADI_CLKCTL->CLKCON1 =
+ 0x0; /* PWM = 16MHz, UART = 16MHz, SPI1 = 16MHz, SPI0=16MHz */
+ pADI_CLKCTL->CLKDIS = 0x0; /* Enable clock to all peripherals */
+
+ /* compute internal clocks */
+ SystemCoreClockUpdate();
+}
+
+/**
+ * @brief Sets the system external clock frequency
+ *
+ * @param ExtClkFreq External clock frequency in Hz
+ * @return none
+ *
+ * Sets the clock frequency of the source connected to P1.0 clock input source
+ */
+void SetSystemExtClkFreq (uint32_t ExtClkFreq)
+{
+ SystemExtClock = ExtClkFreq;
+}
+
+/**
+ * @brief Gets the system external clock frequency
+ *
+ * @return External Clock frequency
+ *
+ * Gets the clock frequency of the source connected to P1.0 clock input source
+ */
+uint32_t GetSystemExtClkFreq (void)
+{
+ return SystemExtClock;
+}
Index: ADuCM360_demo_cn0359/RTE/RTE_Components.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/RTE/RTE_Components.h (revision 0)
+++ ADuCM360_demo_cn0359/RTE/RTE_Components.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,17 @@
+/*
+ * Auto generated Run-Time-Environment Component Configuration File
+ * *** Do not modify ! ***
+ *
+ * Project: ADuCM360_demo_cn0359
+ * RTE configuration: system.rteconfig
+*/
+#ifndef RTE_COMPONENTS_H
+#define RTE_COMPONENTS_H
+
+/*
+ * Define the Device Header File:
+*/
+#define CMSIS_device_header "ADuCM360.h"
+
+
+#endif /* RTE_COMPONENTS_H */
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_cellconstant.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_cellconstant.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_cellconstant.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_cellconstant.h
+ * @brief Implementation of cmd_cellconstant.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_CELLCONSTANT_H__
+#define __CMD_CELLCONSTANT_H__
+
+extern int cmd_cellconstant(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_coefficient.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_coefficient.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_coefficient.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_coefficient.h
+ * @brief Implementation of cmd_coefficient.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_COEFFICIENT_H__
+#define __CMD_COEFFICIENT_H__
+
+extern int cmd_coefficient(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_frequency.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_frequency.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_frequency.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_frequency.h
+ * @brief Implementation of cmd_frequency.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_FREQUENCY_H__
+#define __CMD_FREQUENCY_H__
+
+extern int cmd_frequency(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_holdtime.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_holdtime.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_holdtime.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_holdtime.h
+ * @brief Implementation of cmd_holdtime.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_HOLDTIME_H__
+#define __CMD_HOLDTIME_H__
+
+extern int cmd_holdtime(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_poll.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_poll.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_poll.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_poll.h
+ * @brief Implementation of cmd_poll.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_POLL_H__
+#define __CMD_POLL_H__
+
+extern int cmd_poll(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_setuptime.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_setuptime.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_setuptime.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_setuptime.h
+ * @brief Implementation of cmd_setuptime.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_SETUPTIME_H__
+#define __CMD_SETUPTIME_H__
+
+extern int cmd_setuptime(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/command/cmd_voltage.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/command/cmd_voltage.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/command/cmd_voltage.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file cmd_voltage.h
+ * @brief Implementation of cmd_voltage.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CMD_VOLTAGE_H__
+#define __CMD_VOLTAGE_H__
+
+extern int cmd_voltage(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/BaudRateDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/BaudRateDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/BaudRateDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file BaudRateDialog.h
+ * @brief Implementation of BaudRateDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __BAUDRATEDIALOG_H__
+#define __BAUDRATEDIALOG_H__
+
+#include
+#include
+
+class CBaudRateDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::baud_rate) baud_rate;
+
+ enum {
+ br, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CBaudRateDialog BaudRateDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/CellConstantDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/CellConstantDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/CellConstantDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file CellConstantDialog.h
+ * @brief Implementation of CellConstantDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CELLCONSTANTDIALOG_H__
+#define __CELLCONSTANTDIALOG_H__
+
+#include
+#include
+
+class CCellConstantDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::cell_const) constant;
+
+ enum {
+ c10, c1, c0_1, c0_01, c0_001, c0_0001, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CCellConstantDialog CellConstantDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/CoefficientDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/CoefficientDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/CoefficientDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file CoefficientDialog.h
+ * @brief Implementation of CoefficientDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __COEFFICIENTDIALOG_H__
+#define __COEFFICIENTDIALOG_H__
+
+#include
+#include
+
+class CCoefficientDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::temp_coef) coefficient;
+
+ enum {
+ c1, c0_1, c0_01, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CCoefficientDialog CoefficientDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/ContrastDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/ContrastDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/ContrastDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,64 @@
+/***************************************************************************//**
+ * @file ContrastDialog.h
+ * @brief Implementation of ContrastDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __CONTRASTDIALOG_H__
+#define __CONTRASTDIALOG_H__
+
+#include
+#include
+
+class CContrastDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::brightness) brightness;
+};
+
+extern CContrastDialog ContrastDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/Dialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/Dialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/Dialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,72 @@
+/***************************************************************************//**
+ * @file Dialog.h
+ * @brief Implementation of Dialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __DIALOG_H__
+#define __DIALOG_H__
+
+extern int on_cw(int argc, char *argv[]);
+
+extern int on_ccw(int argc, char *argv[]);
+
+extern int on_button_down(int argc, char *argv[]);
+
+extern int on_button_up(int argc, char *argv[]);
+
+extern int on_conductivity(int argc, char *argv[]);
+
+extern int on_rtd(int argc, char *argv[]);
+
+class CDialog
+{
+public:
+ virtual void OnCreat(void) = 0;
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+ virtual void OnButtonDown(void);
+ virtual void OnButtonUp(void);
+ virtual void OnConductivity(void);
+ virtual void OnRTD(void);
+
+protected:
+ CDialog(void);
+};
+
+extern CDialog *p_dialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/FirmwareDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/FirmwareDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/FirmwareDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,64 @@
+/***************************************************************************//**
+ * @file FirmwareDialog.h
+ * @brief Implementation of FirmwareDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __FIRMWAREDIALOG_H__
+#define __FIRMWAREDIALOG_H__
+
+#include
+#include
+
+class CFirmwareDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ int first_line;
+ void OnDraw(void);
+ flash_file * p_flash_file = nullptr;
+};
+
+extern CFirmwareDialog FirmwareDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/FrequencyDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/FrequencyDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/FrequencyDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,72 @@
+/***************************************************************************//**
+ * @file FrequencyDialog.h
+ * @brief Implementation of FrequencyDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __FREQUENCYDIALOG_H__
+#define __FREQUENCYDIALOG_H__
+
+#include
+
+class CFrequencyDialog: public CDialog
+{
+public:
+ CFrequencyDialog(void);
+
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ int multiple, max_multiple, min_multiple;
+ int base, max_base, min_base;
+
+ enum {
+ freq, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CFrequencyDialog FrequencyDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/HoldTimeDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/HoldTimeDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/HoldTimeDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file HoldTimeDialog.h
+ * @brief Implementation of HoldTimeDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __HOLDTIMEDIALOG_H__
+#define __HOLDTIMEDIALOG_H__
+
+#include
+#include
+
+class CHoldTimeDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::hold) hold_time;
+
+ enum {
+ h10, h1, h0_1, h0_01, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CHoldTimeDialog HoldTimeDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/HomeDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/HomeDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/HomeDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,69 @@
+/***************************************************************************//**
+ * @file HomeDialog.h
+ * @brief Implementation of HomeDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __HOMEDIALOG_H__
+#define __HOMEDIALOG_H__
+
+#include
+#include
+
+class CHomeDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnButtonDown(void);
+
+ virtual void OnConductivity(void);
+ virtual void OnRTD(void);
+
+private:
+ void OnDraw(void);
+
+ float conductivity;
+ float temperature;
+ int rtd_wire;
+ int rtd_type;
+
+ flash_file * p_flash_file = nullptr;
+};
+
+extern CHomeDialog HomeDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/SettingDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/SettingDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/SettingDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,65 @@
+/***************************************************************************//**
+ * @file SettingDialog.h
+ * @brief Implementation of SettingDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __SETTINGDIALOG_H__
+#define __SETTINGDIALOG_H__
+
+#include
+
+class CSettingDialog: public CDialog
+{
+public:
+ CSettingDialog(void);
+
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ int first_item;
+ int selected_line;
+ void OnDraw(void);
+};
+
+extern CSettingDialog SettingDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/SetupTimeDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/SetupTimeDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/SetupTimeDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file SetupTimeDialog.h
+ * @brief Implementation of SetupTimeDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __SETUPTIMEDIALOG_H__
+#define __SETUPTIMEDIALOG_H__
+
+#include
+#include
+
+class CSetupTimeDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::setup) setup_time;
+
+ enum {
+ s10, s1, s0_1, s0_01, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CSetupTimeDialog SetupTimeDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/SplashDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/SplashDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/SplashDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,55 @@
+/***************************************************************************//**
+ * @file SplashDialog.h
+ * @brief Implementation of SplashDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __SPLASHDIALOG_H__
+#define __SPLASHDIALOG_H__
+
+#include
+
+class CSplashDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnButtonDown(void);
+};
+
+extern CSplashDialog SplashDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/dialog/VoltageDialog.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/dialog/VoltageDialog.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/dialog/VoltageDialog.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ * @file VoltageDialog.h
+ * @brief Implementation of VoltageDialog.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __VOLTAGEDIALOG_H__
+#define __VOLTAGEDIALOG_H__
+
+#include
+#include
+
+class CVoltageDialog: public CDialog
+{
+public:
+ virtual void OnCreat(void);
+
+ virtual void OnEncoderCW(void);
+ virtual void OnEncoderCCW(void);
+
+ virtual void OnButtonDown(void);
+
+private:
+ void OnDraw(void);
+
+ decltype(flash_file::voltage) voltage;
+
+ enum {
+ v1, v0_1, save, cancel
+ } menu_item;
+
+ bool in_edit;
+};
+
+extern CVoltageDialog VoltageDialog;
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/message.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/message.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/message.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,55 @@
+/***************************************************************************//**
+ * @file message.h
+ * @brief Implementation of message.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __MESSAGE_H__
+#define __MESSAGE_H__
+
+struct app {
+ int (*fun)(int argc, char *argv[]);
+ int argc = 0;
+ char **argv;
+};
+
+extern void ts_post_message(struct app &msg);
+
+extern void post_message(struct app &msg);
+
+extern void message_loop(void);
+
+#endif
Index: ADuCM360_demo_cn0359/include/applications/uart_exec.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/applications/uart_exec.h (revision 0)
+++ ADuCM360_demo_cn0359/include/applications/uart_exec.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file uart_exec.h
+ * @brief Implementation of uart_exec.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __UART_EXEC_H__
+#define __UART_EXEC_H__
+
+extern int rx_line(int argc, char *argv[]);
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/Initial.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/Initial.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/Initial.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file Initial.h
+ * @brief Implementation of Initial.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __INITIAL_H__
+#define __INITIAL_H__
+
+extern void InitialCPU(void);
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/RTD.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/RTD.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/RTD.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,48 @@
+/***************************************************************************//**
+ * @file RTD.h
+ * @brief Implementation of RTD.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __RTD_H__
+#define __RTD_H__
+
+extern float temp2res(float t);
+
+extern float res2temp(float r);
+
+#endif
+
Index: ADuCM360_demo_cn0359/include/hal/devices.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/devices.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/devices.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,49 @@
+/***************************************************************************//**
+ * @file devices.h
+ * @brief Implementation of devices.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __DEVICES_H__
+#define __DEVICES_H__
+
+#include
+
+extern FILE *p_lcd, *p_uart, *p_flash, *p_dac, *p_adc, *p_pwm, *p_ad8253;
+
+extern void initial_devices(void);
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/Sampling.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/Sampling.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/Sampling.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,64 @@
+/***************************************************************************//**
+ * @file Sampling.h
+ * @brief Implementation of Sampling.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __SAMPLING_H__
+#define __SAMPLING_H__
+
+#define AVERAGING_NUMBER 4
+
+class CAveraging
+{
+public:
+ double GetAveraging(void);
+ void InsertNumber(double dResult);
+
+private:
+ double m_adArray[AVERAGING_NUMBER];
+ int m_iTail;
+};
+
+extern void OnCurrent(void);
+
+extern void OnVoltage(void);
+
+extern void OnRTD(void);
+
+extern CAveraging RawCurrent, RawVoltage, RawTermprature;
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/ad8253.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/ad8253.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/ad8253.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,58 @@
+/***************************************************************************//**
+ * @file ad8253.h
+ * @brief Implementation of ad8253.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __AD8253_H__
+#define __AD8253_H__
+
+#include
+
+extern ssize_t ad8253_read(void *buf, size_t count);
+
+extern ssize_t ad8253_write(const void *buf, size_t count);
+
+extern off_t ad8253_lseek(off_t offset, int whence);
+
+extern void ad8253_open(void);
+
+struct ad8253_file {
+ int v_gain;
+ int i_gain;
+};
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/adc.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/adc.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/adc.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,71 @@
+/***************************************************************************//**
+ * @file adc.h
+ * @brief Implementation of adc.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __ADC_H__
+#define __ADC_H__
+
+#include
+
+extern void adc_open(void);
+
+extern ssize_t adc_read(void *buf, size_t count);
+
+extern ssize_t adc_write(const void *buf, size_t count);
+
+extern off_t adc_lseek(off_t offset, int whence);
+
+struct adc_file {
+ float p_curt;
+ float n_curt;
+ float p_volt;
+ float n_volt;
+ int p_curt_gain;
+ int p_volt_gain;
+ int n_curt_gain;
+ int n_volt_gain;
+
+ int rtd_type;
+ int wire_mode;
+ float temp;
+
+ unsigned long adc0_hit;
+ unsigned long adc1_hit;
+};
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/buzzer.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/buzzer.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/buzzer.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,49 @@
+/***************************************************************************//**
+ * @file buzzer.h
+ * @brief Implementation of buzzer.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __BUZZER_H__
+#define __BUZZER_H__
+
+extern void buzzer_open(void);
+
+extern void _beep(int time, ...);
+
+#define beep(args...) _beep(args, -1)
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/dac.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/dac.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/dac.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,55 @@
+/***************************************************************************//**
+ * @file dac.h
+ * @brief Implementation of dac.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __DAC_H__
+#define __DAC_H__
+
+extern ssize_t dac_read(void *buf, size_t count);
+
+extern ssize_t dac_write(const void *buf, size_t count);
+
+extern off_t dac_lseek(off_t offset, int whence);
+
+extern void dac_open(void);
+
+struct dac_file {
+ float voltage;
+};
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/encoder.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/encoder.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/encoder.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,45 @@
+/***************************************************************************//**
+ * @file encoder.h
+ * @brief Implementation of encoder.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __ENCODER_H__
+#define __ENCODER_H__
+
+extern void encoder_open(void);
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/flash.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/flash.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/flash.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,104 @@
+/***************************************************************************//**
+ * @file flash.h
+ * @brief Implementation of flash.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __FLASH_H__
+#define __FLASH_H__
+
+#include
+
+extern ssize_t flash_write(const void *buf, size_t count);
+
+extern ssize_t flash_read(void *buf, size_t count);
+
+extern off_t flash_lseek(off_t offset, int whence);
+
+extern void flash_open(void);
+
+#ifndef __TIMESTAMP__
+#define __TIMESTAMP__
+#endif
+
+#ifndef __VERSION__
+#define __VERSION__
+#endif
+
+#define CN0359_VERSION "<" __TIME__ ">, <" __DATE__ ">, <" __VERSION__ ">, <" __TIMESTAMP__ ">, " ", " " "
+
+struct flash_file {
+ int baud_rate = 115200;
+ float voltage = 1.f;
+ float frequency = 100.f;
+ float temp_coef = 2.f;
+ float cell_const = 1.f;
+ float setup = 10.f;
+ float hold = 1.f;
+ int brightness = 32;
+} const default_setting;
+
+struct {
+ const int min_baud_rate = 9600;
+ const int max_baud_rate = 460800;
+
+ const float min_voltage = 0.1f;
+ const float max_voltage = 10.f;
+
+ const float min_freq = 10.f;
+ const float max_freq = 100.e3f;
+
+ const float min_temp_coef = -10.f;
+ const float max_temp_coef = 10.f;
+
+ const float min_cell_const = 0.01f;
+ const float max_cell_const = 100.f;
+
+ const float min_setup = 0.f;
+ const float max_setup = 80.f;
+
+ const float min_hold = 0.f;
+ const float max_hold = 10.f;
+
+ const int min_brightness = 0;
+ const int max_brightness = 63;
+
+ const char version[sizeof(CN0359_VERSION)] = CN0359_VERSION;
+} const configure_file;
+
+const char zeros[512] = {};
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/lcd.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/lcd.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/lcd.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,54 @@
+/***************************************************************************//**
+ * @file lcd.h
+ * @brief Implementation of lcd.h
+ * @author Rbolboac (ramona.bolboaca@analog.com)
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+
+extern void lcd_open(void);
+
+extern ssize_t lcd_tty_write(const void *buf, size_t count);
+
+extern off_t lcd_tty_lseek(off_t offset, int whence);
+
+extern uint8_t framebuffer_memory[4][128];
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/pwm.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/pwm.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/pwm.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,58 @@
+/***************************************************************************//**
+ * @file pwm.h
+ * @brief Implementation of pwm.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __PWM_H__
+#define __PWM_H__
+
+extern void pwm_open(void);
+
+extern off_t pwm_lseek(off_t offset, int whence);
+
+extern ssize_t pwm_read(void *buf, size_t count);
+
+extern ssize_t pwm_write(const void *buf, size_t count);
+
+struct pwm_file {
+ float freq;
+ float setup;
+ float hold;
+ bool inv;
+};
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/drivers/uart.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/drivers/uart.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/drivers/uart.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,53 @@
+/***************************************************************************//**
+ * @file uart.h
+ * @brief Implementation of uart.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __UART_H__
+#define __UART_H__
+
+#include
+
+extern float uart_baud(float baud);
+
+extern void uart_open(void);
+
+extern ssize_t uart_read(void *buf, size_t count);
+
+extern ssize_t uart_write(const void *buf, size_t count);
+
+#endif
Index: ADuCM360_demo_cn0359/include/hal/timer.h
===================================================================
diff -u
--- ADuCM360_demo_cn0359/include/hal/timer.h (revision 0)
+++ ADuCM360_demo_cn0359/include/hal/timer.h (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,56 @@
+/***************************************************************************//**
+ * @file timer.h
+ * @brief Implementation of timer.h
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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 __TIMER_H__
+#define __TIMER_H__
+
+#include
+
+struct timer {
+ struct app timer_app;
+ unsigned int time;
+};
+
+extern void new_timer(timer t);
+
+extern void delete_timer(const timer &t);
+
+extern void update_timer(const timer &t);
+
+#endif
Index: ADuCM360_demo_cn0359/ld_script/gcc_arm.ld
===================================================================
diff -u
--- ADuCM360_demo_cn0359/ld_script/gcc_arm.ld (revision 0)
+++ ADuCM360_demo_cn0359/ld_script/gcc_arm.ld (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,238 @@
+/***************************************************************************//**
+ * @file gcc_arm.ld
+ * @brief Implementation of gcc_arm.ld
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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.
+ ******************************************************************************/
+
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x20000 /* 128k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x02000 /* 8k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ . = ALIGN(512);
+ *(.flash_disk)
+ . = ALIGN(512);
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_cellconstant.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_cellconstant.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_cellconstant.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,73 @@
+/***************************************************************************//**
+ * @file cmd_cellconstant.cpp
+ * @brief Implementation of cmd_cellconstant.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+
+int cmd_cellconstant(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s CELL_CONSTANT_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ float constant = -1;
+ sscanf(argv[1], "%f", &constant);
+
+ if (constant <= configure_file.max_cell_const
+ && constant >= configure_file.min_cell_const) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ decltype(p_flash_file->cell_const) cell_const = constant;
+
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&cell_const, sizeof(flash_file::cell_const), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the cell constant is set to: %f/cm\n\n", argv[0], constant);
+ } else {
+ printf("%s: error, cell constant input: %s is not in range: %f~%f\n\n", argv[0],
+ argv[1],
+ configure_file.min_cell_const, configure_file.max_cell_const);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_coefficient.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_coefficient.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_coefficient.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,74 @@
+/***************************************************************************//**
+ * @file cmd_coefficient.cpp
+ * @brief Implementation of cmd_coefficient.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+
+int cmd_coefficient(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s COEFFICIENT_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ float coefficient = -1;
+ sscanf(argv[1], "%f", &coefficient);
+
+ if (coefficient <= configure_file.max_temp_coef
+ && coefficient >= configure_file.min_temp_coef) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ decltype(p_flash_file->temp_coef) temp_coef = coefficient;
+
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&temp_coef, sizeof(flash_file::temp_coef), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the temperature coefficient is set to: %f%%/'C\n\n", argv[0],
+ coefficient);
+ } else {
+ printf("%s: error, temperature coefficient input: %s is not in range: %f~%f\n\n",
+ argv[0], argv[1],
+ configure_file.min_temp_coef, configure_file.max_temp_coef);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_frequency.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_frequency.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_frequency.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,79 @@
+/***************************************************************************//**
+ * @file cmd_frequency.cpp
+ * @brief Implementation of cmd_frequency.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+int cmd_frequency(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s FREQUENCY_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ pwm_file pwm;
+ pwm.freq = -1;
+
+ sscanf(argv[1], "%f", &pwm.freq);
+
+ if (pwm.freq <= configure_file.max_freq
+ && pwm.freq >= configure_file.min_freq) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ fseek(p_pwm, (int) (&pwm.freq) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.freq, sizeof(pwm_file::freq), 1, p_pwm);
+ fflush(p_pwm);
+
+ decltype(p_flash_file->frequency) frequency = pwm.freq;
+ fseek(p_flash, (int) (&p_flash_file->frequency) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&frequency, sizeof(flash_file::frequency), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the frequency is set to: %fHz\n\n", argv[0], pwm.freq);
+ } else {
+ printf("%s: error, frequency input: %s is not in range: %f~%f\n\n", argv[0],
+ argv[1], configure_file.min_freq,
+ configure_file.max_freq);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_holdtime.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_holdtime.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_holdtime.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,78 @@
+/***************************************************************************//**
+ * @file cmd_holdtime.cpp
+ * @brief Implementation of cmd_holdtime.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+int cmd_holdtime(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s HOLD_TIME_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ pwm_file pwm;
+ pwm.hold = -1;
+
+ sscanf(argv[1], "%f", &pwm.hold);
+
+ if (pwm.hold <= configure_file.max_hold
+ && pwm.hold >= configure_file.min_hold) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ fseek(p_pwm, (int) (&pwm.hold) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.hold, sizeof(pwm_file::hold), 1, p_pwm);
+ fflush(p_pwm);
+
+ decltype(p_flash_file->hold) hold = pwm.hold;
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&hold, sizeof(flash_file::hold), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the hold time is set to: %f%%\n\n", argv[0], pwm.hold);
+ } else {
+ printf("%s: error, hold time: %s is not in range: %f~%f\n\n", argv[0], argv[1],
+ configure_file.min_hold,
+ configure_file.max_hold);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_poll.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_poll.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_poll.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,125 @@
+/***************************************************************************//**
+ * @file cmd_poll.cpp
+ * @brief Implementation of cmd_poll.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+int cmd_poll(int argc, char *argv[])
+{
+ if (argc != 1) {
+ printf("%s: syntax error, please use the following syntax: %s\n\n", argv[0], argv[0]);
+ } else {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ decltype(p_flash_file->voltage) voltage;
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fread(&voltage, sizeof(flash_file::voltage), 1, p_flash);
+
+ printf("EXC V: %fV\n", voltage);
+
+ decltype(p_flash_file->frequency) frequency;
+ fseek(p_flash, (int) (&p_flash_file->frequency) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&frequency, sizeof(flash_file::frequency), 1, p_flash);
+
+ printf("EXC FREQ: %fHz\n", frequency);
+
+ decltype(p_flash_file->setup) setup;
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fread(&setup, sizeof(flash_file::setup), 1, p_flash);
+
+ printf("EXC setup time: %f%%\n", setup);
+
+ decltype(p_flash_file->hold) hold;
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fread(&hold, sizeof(flash_file::hold), 1, p_flash);
+
+ printf("EXC hold time: %f%%\n", hold);
+
+ decltype(p_flash_file->temp_coef) temp_coef;
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&temp_coef, sizeof(flash_file::temp_coef), 1, p_flash);
+
+ printf("TEMP COEF: %f%%/'C\n", temp_coef);
+
+ decltype(p_flash_file->cell_const) cell_const;
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&cell_const, sizeof(flash_file::cell_const), 1, p_flash);
+
+ printf("cell K: %f/cm\n", cell_const);
+
+ adc_file adc;
+
+ rewind(p_adc);
+ fread(&adc, sizeof(adc_file), 1, p_adc);
+
+ printf("ADC0 hits: %lu\n", adc.adc0_hit);
+
+ printf("+I gain: %i\n", adc.p_curt_gain);
+ printf("+Ip-p: %eA\n", adc.p_curt);
+
+ printf("-I gain: %i\n", adc.n_curt_gain);
+ printf("-Ip-p: %eA\n", adc.n_curt);
+
+ printf("+V gain: %i\n", adc.p_volt_gain);
+ printf("+Vp-p: %eV\n", adc.p_volt);
+
+ printf("-V gain: %i\n", adc.n_volt_gain);
+ printf("-Vp-p: %eV\n", adc.n_volt);
+
+ printf("ADC1 hits: %lu\n", adc.adc1_hit);
+
+ printf("RTD: PT%i\n", adc.rtd_type);
+ printf("RTD wire: %i wire\n", adc.wire_mode);
+ printf("TEMP: %f'C\n\n", adc.temp);
+
+ float conductivity = (cell_const * (adc.p_curt - adc.n_curt) /
+ (adc.p_volt - adc.n_volt))
+ * (100 / (100 + temp_coef * (adc.temp - 25)));
+
+ printf("conductivity: %eS/cm\n\n", conductivity);
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_setuptime.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_setuptime.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_setuptime.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,78 @@
+/***************************************************************************//**
+ * @file cmd_setuptime.cpp
+ * @brief Implementation of cmd_setuptime.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+int cmd_setuptime(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s SETUP_TIME_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ pwm_file pwm;
+ pwm.setup = -1;
+
+ sscanf(argv[1], "%f", &pwm.setup);
+
+ if (pwm.setup <= configure_file.max_setup
+ && pwm.setup >= configure_file.min_setup) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ fseek(p_pwm, (int) (&pwm.setup) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.setup, sizeof(pwm_file::setup), 1, p_pwm);
+ fflush(p_pwm);
+
+ decltype(p_flash_file->setup) setup = pwm.setup;
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&setup, sizeof(flash_file::setup), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the setup time is set to: %f%%\n\n", argv[0], pwm.setup);
+ } else {
+ printf("%s: error, setup time: %s is not in range: %f~%f\n\n", argv[0], argv[1],
+ configure_file.min_setup,
+ configure_file.max_setup);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/command/cmd_voltage.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/command/cmd_voltage.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/command/cmd_voltage.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,78 @@
+/***************************************************************************//**
+ * @file cmd_voltage.cpp
+ * @brief Implementation of cmd_voltage.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+int cmd_voltage(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("%s: syntax error, please use the following syntax: %s VOLTAGE_VALUE\n\n", argv[0], argv[0]);
+ } else {
+ dac_file dac;
+ dac.voltage = -1;
+
+ sscanf(argv[1], "%f", &dac.voltage);
+
+ if (dac.voltage <= configure_file.max_voltage
+ && dac.voltage >= configure_file.min_voltage) {
+ flash_file flash_var;
+ flash_file * p_flash_file = &flash_var;
+
+ fseek(p_dac, (int) (&dac.voltage) - (int) (&dac), SEEK_SET);
+ fwrite(&dac.voltage, sizeof(dac_file::voltage), 1, p_dac);
+ fflush(p_dac);
+
+ decltype(p_flash_file->voltage) voltage = dac.voltage;
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&voltage, sizeof(flash_file::voltage), 1, p_flash);
+ fflush(p_flash);
+
+ printf("%s: the voltage is set to: %fV\n\n", argv[0], dac.voltage);
+ } else {
+ printf("%s: error, voltage input: %s is not in range: %f~%f\n\n", argv[0],
+ argv[1], configure_file.min_voltage,
+ configure_file.max_voltage);
+ }
+ }
+
+ fflush(stdout);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/BaudRateDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/BaudRateDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/BaudRateDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,200 @@
+/***************************************************************************//**
+ * @file BaudRateDialog.cpp
+ * @brief Implementation of BaudRateDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+
+CBaudRateDialog BaudRateDialog;
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+static const int BAUD_RATE[] = {9600, 19200, 38400, 57600, 115200, 230400, 460800};
+
+void CBaudRateDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("Baud rate:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = br;
+
+ flash_file * p_flash_file;
+ fseek(p_flash, (int) (&p_flash_file->baud_rate) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&baud_rate, sizeof(flash_file::baud_rate), 1, p_flash);
+
+ OnDraw();
+}
+
+void CBaudRateDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ for (int i = 0; i < SIZE(BAUD_RATE); ++i) {
+ if (i == SIZE(BAUD_RATE) - 1) {
+ beep(10);
+ return;
+ }
+
+ if (baud_rate == BAUD_RATE[i]) {
+ baud_rate = BAUD_RATE[i + 1];
+ break;
+ }
+ }
+ } else {
+ switch (menu_item) {
+ default:
+ case br:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CBaudRateDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ for (int i = SIZE(BAUD_RATE) - 1; i >= 0; --i) {
+ if (i == 0) {
+ beep(10);
+ return;
+ }
+
+ if (baud_rate == BAUD_RATE[i]) {
+ baud_rate = BAUD_RATE[i - 1];
+ break;
+ }
+ }
+ } else {
+ switch (menu_item) {
+ case br:
+ beep(10);
+ return;
+ break;
+ case save:
+ menu_item = br;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CBaudRateDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ switch (menu_item) {
+ default:
+ menu_item = br;
+ case br:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->baud_rate) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&baud_rate, sizeof(flash_file::baud_rate), 1, p_flash);
+ fflush(p_flash);
+ uart_baud(baud_rate);
+ case cancel:
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CBaudRateDialog::OnDraw(void)
+{
+ fseek(p_lcd, 100, SEEK_SET);
+ fwrite(zeros, 6, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 36, SEEK_SET);
+ fprintf(p_lcd, "%6ibps", baud_rate);
+
+ switch (menu_item) {
+ default:
+ menu_item = br;
+ case br:
+ fseek(p_lcd, 100, SEEK_SET);
+ if (in_edit) {
+ fputs("\2\2\2\2\2\2", p_lcd);
+ } else {
+ fputs("\1\1\1\1\1\1", p_lcd);
+ }
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
+
Index: ADuCM360_demo_cn0359/src/applications/dialog/CellConstantDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/CellConstantDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/CellConstantDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,278 @@
+/***************************************************************************//**
+ * @file CellConstantDialog.cpp
+ * @brief Implementation of CellConstantDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+CCellConstantDialog CellConstantDialog;
+
+void CCellConstantDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("Cell constant:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = c10;
+
+ flash_file * p_flash_file;
+
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&constant, sizeof(flash_file::cell_const), 1, p_flash);
+
+ OnDraw();
+}
+
+void CCellConstantDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = c10;
+ case c10:
+ constant += 10;
+ break;
+ case c1:
+ constant += 1;
+ break;
+ case c0_1:
+ constant += 0.1f;
+ break;
+ case c0_01:
+ constant += 0.01f;
+ break;
+ case c0_001:
+ constant += 0.001f;
+ break;
+ case c0_0001:
+ constant += 0.0001f;
+ break;
+ }
+
+ if (constant > configure_file.max_cell_const) {
+ constant = configure_file.max_cell_const;
+ beep(10);
+ }
+ } else {
+ switch (menu_item) {
+ default:
+ case c10:
+ menu_item = c1;
+ break;
+ case c1:
+ menu_item = c0_1;
+ break;
+ case c0_1:
+ menu_item = c0_01;
+ break;
+ case c0_01:
+ menu_item = c0_001;
+ break;
+ case c0_001:
+ menu_item = c0_0001;
+ break;
+ case c0_0001:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CCellConstantDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = c10;
+ case c10:
+ constant -= 10;
+ break;
+ case c1:
+ constant -= 1;
+ break;
+ case c0_1:
+ constant -= 0.1f;
+ break;
+ case c0_01:
+ constant -= 0.01f;
+ break;
+ case c0_001:
+ constant -= 0.001f;
+ break;
+ case c0_0001:
+ constant -= 0.0001f;
+ break;
+ }
+
+ if (constant < configure_file.min_cell_const) {
+ constant = configure_file.min_cell_const;
+ beep(10);
+ }
+ } else {
+ switch (menu_item) {
+ case c10:
+ beep(10);
+ return;
+ break;
+ case c1:
+ menu_item = c10;
+ break;
+ case c0_1:
+ menu_item = c1;
+ break;
+ case c0_01:
+ menu_item = c0_1;
+ break;
+ case c0_001:
+ menu_item = c0_01;
+ break;
+ case c0_0001:
+ menu_item = c0_001;
+ break;
+ case save:
+ menu_item = c0_0001;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CCellConstantDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ switch (menu_item) {
+ default:
+ menu_item = c10;
+ case c10:
+ case c1:
+ case c0_1:
+ case c0_01:
+ case c0_001:
+ case c0_0001:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&constant, sizeof(flash_file::cell_const), 1, p_flash);
+ fflush(p_flash);
+ case cancel:
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CCellConstantDialog::OnDraw(void)
+{
+ fseek(p_lcd, 99, SEEK_SET);
+ fwrite(zeros, 7, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 34, SEEK_SET);
+
+ fprintf(p_lcd, "%8.4f/cm", constant);
+
+ switch (menu_item) {
+ default:
+ menu_item = c10;
+ case c10:
+ fseek(p_lcd, 99, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c1:
+ fseek(p_lcd, 100, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_1:
+ fseek(p_lcd, 102, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_01:
+ fseek(p_lcd, 103, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_001:
+ fseek(p_lcd, 104, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_0001:
+ fseek(p_lcd, 105, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/CoefficientDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/CoefficientDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/CoefficientDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,232 @@
+/***************************************************************************//**
+ * @file CoefficientDialog.cpp
+ * @brief Implementation of CoefficientDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+
+CCoefficientDialog CoefficientDialog;
+
+void CCoefficientDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("Temperature", p_lcd);
+
+ fseek(p_lcd, 16, SEEK_SET);
+ fputs("coefficient:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = c1;
+
+ flash_file * p_flash_file;
+
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&coefficient, sizeof(flash_file::temp_coef), 1, p_flash);
+
+ OnDraw();
+}
+
+void CCoefficientDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = c1;
+ case c1:
+ coefficient += 1;
+ break;
+ case c0_1:
+ coefficient += 0.1f;
+ break;
+ case c0_01:
+ coefficient += 0.01f;
+ break;
+ }
+
+ if (coefficient > configure_file.max_temp_coef) {
+ coefficient = configure_file.max_temp_coef;
+ beep(10);
+ }
+ } else {
+ switch (menu_item) {
+ default:
+ case c1:
+ menu_item = c0_1;
+ break;
+ case c0_1:
+ menu_item = c0_01;
+ break;
+ case c0_01:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CCoefficientDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = c1;
+ case c1:
+ coefficient -= 1;
+ break;
+ case c0_1:
+ coefficient -= 0.1f;
+ break;
+ case c0_01:
+ coefficient -= 0.01f;
+ break;
+ }
+
+ if (coefficient < configure_file.min_temp_coef) {
+ coefficient = configure_file.min_temp_coef;
+ beep(10);
+ }
+ } else {
+ switch (menu_item) {
+ case c1:
+ beep(10);
+ return;
+ break;
+ case c0_1:
+ menu_item = c1;
+ break;
+ case c0_01:
+ menu_item = c0_1;
+ break;
+ case save:
+ menu_item = c0_01;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CCoefficientDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ switch (menu_item) {
+ default:
+ menu_item = c1;
+ case c1:
+ case c0_1:
+ case c0_01:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&coefficient, sizeof(flash_file::temp_coef), 1, p_flash);
+ fflush(p_flash);
+ case cancel:
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CCoefficientDialog::OnDraw(void)
+{
+ fseek(p_lcd, 101, SEEK_SET);
+ fwrite(zeros, 4, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 35, SEEK_SET);
+
+ fprintf(p_lcd, "%+6.2f%%/\xf8\C", coefficient);
+
+ switch (menu_item) {
+ default:
+ menu_item = c1;
+ case c1:
+ fseek(p_lcd, 101, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_1:
+ fseek(p_lcd, 103, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case c0_01:
+ fseek(p_lcd, 104, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
+
Index: ADuCM360_demo_cn0359/src/applications/dialog/ContrastDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/ContrastDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/ContrastDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,135 @@
+/***************************************************************************//**
+ * @file ContrastDialog.cpp
+ * @brief Implementation of ContrastDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+
+CContrastDialog ContrastDialog;
+
+#define CONTRAST_STEP 5
+
+void CContrastDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ flash_file * p_flash_file;
+ fseek(p_flash, (int) (&p_flash_file->brightness) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&brightness, sizeof(flash_file::brightness), 1, p_flash);
+
+ OnDraw();
+}
+
+void CContrastDialog::OnEncoderCW(void)
+{
+ brightness += CONTRAST_STEP;
+
+ if (brightness > configure_file.max_brightness) {
+ brightness = configure_file.max_brightness;
+ beep(10);
+ }
+
+ flash_file * p_flash_file;
+
+ fseek(p_flash, (int) (&p_flash_file->brightness) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&brightness, sizeof(flash_file::brightness), 1, p_flash);
+
+ fflush(p_flash);
+ FILE * p_file;
+ p_file = freopen("lcd", "rb+", p_lcd);
+ setvbuf(p_lcd, nullptr, _IOFBF, 16);
+
+ OnDraw();
+}
+
+void CContrastDialog::OnEncoderCCW(void)
+{
+ brightness -= CONTRAST_STEP;
+
+ if (brightness < configure_file.min_brightness) {
+ brightness = configure_file.min_brightness;
+ beep(10);
+ }
+
+ flash_file * p_flash_file;
+
+ fseek(p_flash, (int) (&p_flash_file->brightness) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&brightness, sizeof(flash_file::brightness), 1, p_flash);
+
+ fflush(p_flash);
+
+ FILE * p_file;
+ p_file = freopen("lcd", "rb+", p_lcd);
+ setvbuf(p_lcd, nullptr, _IOFBF, 16);
+
+ OnDraw();
+}
+
+void CContrastDialog::OnButtonDown(void)
+{
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+}
+
+void CContrastDialog::OnDraw(void)
+{
+ rewind(p_lcd);
+ fputs("LCD contrast:", p_lcd);
+
+ fseek(p_lcd, 16, SEEK_SET);
+ fputs("turn knob to", p_lcd);
+
+ fseek(p_lcd, 32, SEEK_SET);
+ fputs("adjust contrast", p_lcd);
+
+ fseek(p_lcd, 53, SEEK_SET);
+ fputs("Return", p_lcd);
+
+ fseek(p_lcd, 117, SEEK_SET);
+ fputs("\x1\x1\x1\x1\x1\x1", p_lcd);
+
+ fflush(p_lcd);
+}
+
Index: ADuCM360_demo_cn0359/src/applications/dialog/Dialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/Dialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/Dialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,107 @@
+/***************************************************************************//**
+ * @file Dialog.cpp
+ * @brief Implementation of Dialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+
+CDialog *p_dialog;
+
+int on_cw(int argc, char *argv[])
+{
+ p_dialog->OnEncoderCW();
+}
+
+int on_ccw(int argc, char *argv[])
+{
+ p_dialog->OnEncoderCCW();
+}
+
+int on_button_down(int argc, char *argv[])
+{
+ p_dialog->OnButtonDown();
+}
+
+int on_button_up(int argc, char *argv[])
+{
+ p_dialog->OnButtonUp();
+}
+
+int on_conductivity(int argc, char *argv[])
+{
+ p_dialog->OnConductivity();
+}
+
+int on_rtd(int argc, char *argv[])
+{
+ p_dialog->OnRTD();
+}
+
+void CDialog::OnEncoderCW(void)
+{
+
+}
+
+void CDialog::OnEncoderCCW(void)
+{
+
+}
+
+void CDialog::OnButtonDown(void)
+{
+
+}
+
+void CDialog::OnButtonUp(void)
+{
+
+}
+
+void CDialog::OnConductivity(void)
+{
+
+}
+
+void CDialog::OnRTD(void)
+{
+
+}
+
+CDialog::CDialog(void)
+{
+
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/FirmwareDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/FirmwareDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/FirmwareDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,93 @@
+/***************************************************************************//**
+ * @file FirmwareDialog.cpp
+ * @brief Implementation of FirmwareDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+
+CFirmwareDialog FirmwareDialog;
+
+void CFirmwareDialog::OnCreat(void)
+{
+ first_line = 0;
+
+ OnDraw();
+}
+
+void CFirmwareDialog::OnEncoderCW(void)
+{
+ if (first_line < ((sizeof(configure_file.version) + 14) / 16) - 4) {
+ ++first_line;
+ } else {
+ beep(10);
+ }
+
+ OnDraw();
+}
+
+void CFirmwareDialog::OnEncoderCCW(void)
+{
+ if (first_line > 0) {
+ --first_line;
+ } else {
+ beep(10);
+ }
+
+ OnDraw();
+}
+
+void CFirmwareDialog::OnButtonDown(void)
+{
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+}
+
+void CFirmwareDialog::OnDraw(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+
+ fprintf(p_lcd, "%.64s", &configure_file.version[first_line * 16]);
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/FrequencyDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/FrequencyDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/FrequencyDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,277 @@
+/***************************************************************************//**
+ * @file FrequencyDialog.cpp
+ * @brief Implementation of FrequencyDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+CFrequencyDialog FrequencyDialog;
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+static const int E24[] =
+{10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91};
+
+CFrequencyDialog::CFrequencyDialog(void)
+{
+ max_multiple = pow(10, floor(log10(configure_file.max_freq)) - 1);
+ max_base = lround(configure_file.max_freq / max_multiple);
+ min_multiple = pow(10, floor(log10(configure_file.min_freq)) - 1);
+ min_base = lround(configure_file.min_freq / min_multiple);
+}
+
+/*
+ * frequency = base * multiple
+ *
+ */
+void CFrequencyDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("EXC frequency:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = freq;
+
+ pwm_file pwm;
+ fseek(p_pwm, (int) (&pwm.freq) - (int) (&pwm), SEEK_SET);
+ fread(&pwm.freq, sizeof(pwm_file::freq), 1, p_pwm);
+
+ multiple = pow(10, floor(log10(pwm.freq)) - 1);
+ base = lround(pwm.freq / multiple);
+
+ OnDraw();
+}
+
+void CFrequencyDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ for (int i = 0; i < SIZE(E24); ++i) {
+ if (i == SIZE(E24) - 1) {
+ base = E24[0];
+ multiple *= 10;
+ break;
+ }
+
+ if (base < E24[i]) {
+ base = E24[i];
+ break;
+ }
+ }
+
+ if ((base * multiple) > configure_file.max_freq) {
+ base = max_base;
+ multiple = max_multiple;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.freq = base * multiple;
+
+ fseek(p_pwm, (int) (&pwm.freq) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.freq, sizeof(pwm_file::freq), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ default:
+ case freq:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CFrequencyDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ for (int i = SIZE(E24) - 1; i >= 0; --i) {
+ if (i == 0) {
+ base = E24[SIZE(E24) - 1];
+ multiple /= 10;
+ break;
+ }
+
+ if (base > E24[i]) {
+ base = E24[i];
+ break;
+ }
+ }
+
+ if ((base * multiple) < configure_file.min_freq) {
+ base = min_base;
+ multiple = min_multiple;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.freq = base * multiple;
+
+ fseek(p_pwm, (int) (&pwm.freq) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.freq, sizeof(pwm_file::freq), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ case freq:
+ beep(10);
+ return;
+ break;
+ case save:
+ menu_item = freq;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CFrequencyDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ decltype(flash_file::frequency) frequency;
+
+ pwm_file pwm;
+
+ switch (menu_item) {
+ default:
+ menu_item = freq;
+ case freq:
+ in_edit = !in_edit;
+ break;
+ case save:
+ pwm.freq = base * multiple;
+
+ frequency = pwm.freq;
+
+ fseek(p_flash, (int) (&p_flash_file->frequency) - (int) (p_flash_file),
+ SEEK_SET);
+ fwrite(&frequency, sizeof(flash_file::frequency), 1, p_flash);
+ fflush(p_flash);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ case cancel:
+ fseek(p_flash, (int) (&p_flash_file->frequency) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&frequency, sizeof(flash_file::frequency), 1, p_flash);
+
+ pwm.freq = frequency;
+
+ fseek(p_pwm, (int) (&pwm.freq) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.freq, sizeof(pwm_file::freq), 1, p_pwm);
+ fflush(p_pwm);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CFrequencyDialog::OnDraw(void)
+{
+ fseek(p_lcd, 100, SEEK_SET);
+ fwrite(zeros, 8, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 36, SEEK_SET);
+ fwrite(zeros, 8, 1, p_lcd);
+
+ fseek(p_lcd, 36, SEEK_SET);
+
+ if ((base * multiple) < 1000) {
+ fprintf(p_lcd, "%5.1fHz", (float) (base * multiple));
+ } else {
+ fprintf(p_lcd, "%5.1fkHz", (base * multiple) / 1000.f);
+ }
+
+ switch (menu_item) {
+ default:
+ menu_item = freq;
+ case freq:
+ fseek(p_lcd, 100, SEEK_SET);
+ if (in_edit) {
+ fputs("\2\2\2\2\2\2\2\2", p_lcd);
+ } else {
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ }
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/HoldTimeDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/HoldTimeDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/HoldTimeDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,274 @@
+/***************************************************************************//**
+ * @file HoldTimeDialog.cpp
+ * @brief Implementation of HoldTimeDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+
+CHoldTimeDialog HoldTimeDialog;
+
+void CHoldTimeDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("Hold time:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = h10;
+
+ flash_file * p_flash_file;
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fread(&hold_time, sizeof(flash_file::hold), 1, p_flash);
+
+ OnDraw();
+}
+
+void CHoldTimeDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = h10;
+ case h10:
+ hold_time += 10;
+ break;
+ case h1:
+ hold_time += 1;
+ break;
+ case h0_1:
+ hold_time += 0.1f;
+ break;
+ case h0_01:
+ hold_time += 0.01f;
+ break;
+ }
+
+ if (hold_time > configure_file.max_hold) {
+ hold_time = configure_file.max_hold;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.hold = hold_time;
+
+ fseek(p_pwm, (int) (&pwm.hold) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.hold, sizeof(pwm_file::hold), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ default:
+ case h10:
+ menu_item = h1;
+ break;
+ case h1:
+ menu_item = h0_1;
+ break;
+ case h0_1:
+ menu_item = h0_01;
+ break;
+ case h0_01:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CHoldTimeDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = h10;
+ case h10:
+ hold_time -= 10;
+ break;
+ case h1:
+ hold_time -= 1;
+ break;
+ case h0_1:
+ hold_time -= 0.1f;
+ break;
+ case h0_01:
+ hold_time -= 0.01f;
+ break;
+ }
+
+ if (hold_time < configure_file.min_hold) {
+ hold_time = configure_file.min_hold;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.hold = hold_time;
+
+ fseek(p_pwm, (int) (&pwm.hold) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.hold, sizeof(pwm_file::hold), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ case h10:
+ beep(10);
+ return;
+ break;
+ case h1:
+ menu_item = h10;
+ break;
+ case h0_1:
+ menu_item = h1;
+ break;
+ case h0_01:
+ menu_item = h0_1;
+ break;
+ case save:
+ menu_item = h0_01;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CHoldTimeDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ pwm_file pwm;
+
+ switch (menu_item) {
+ default:
+ menu_item = h10;
+ case h10:
+ case h1:
+ case h0_1:
+ case h0_01:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&hold_time, sizeof(flash_file::hold), 1, p_flash);
+ fflush(p_flash);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ case cancel:
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fread(&hold_time, sizeof(flash_file::hold), 1, p_flash);
+
+ pwm.hold = hold_time;
+ fseek(p_pwm, (int) (&pwm.hold) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.hold, sizeof(pwm_file::hold), 1, p_pwm);
+ fflush(p_pwm);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CHoldTimeDialog::OnDraw(void)
+{
+ fseek(p_lcd, 101, SEEK_SET);
+ fwrite(zeros, 5, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 37, SEEK_SET);
+
+ fprintf(p_lcd, "%5.2f%%", hold_time);
+
+ switch (menu_item) {
+ default:
+ menu_item = h10;
+ case h10:
+ fseek(p_lcd, 101, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case h1:
+ fseek(p_lcd, 102, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case h0_1:
+ fseek(p_lcd, 104, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case h0_01:
+ fseek(p_lcd, 105, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/HomeDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/HomeDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/HomeDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,166 @@
+/***************************************************************************//**
+ * @file HomeDialog.cpp
+ * @brief Implementation of HomeDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+
+CHomeDialog HomeDialog;
+
+using namespace std;
+
+void CHomeDialog::OnCreat(void)
+{
+ conductivity = 0;
+ temperature = 25;
+ rtd_wire = -1;
+ rtd_type = -1;
+
+ OnDraw();
+}
+
+void CHomeDialog::OnButtonDown(void)
+{
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+}
+
+void CHomeDialog::OnConductivity(void)
+{
+ adc_file adc;
+ decltype(flash_file::cell_const) k;
+ decltype(flash_file::temp_coef) conf;
+
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&k, sizeof(flash_file::cell_const), 1, p_flash);
+
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&conf, sizeof(flash_file::temp_coef), 1, p_flash);
+
+ rewind(p_adc);
+ fread(&adc, sizeof(adc_file), 1, p_adc);
+
+ conductivity = (k * (adc.p_curt - adc.n_curt) / (adc.p_volt - adc.n_volt))
+ * (100 / (100 + conf * (temperature - 25)));
+
+ if (!(isfinite(conductivity) && conductivity >= 1e-24 && conductivity < 1e27)) {
+ beep(100);
+ }
+
+ OnDraw();
+}
+
+void CHomeDialog::OnRTD(void)
+{
+ adc_file adc;
+ decltype(flash_file::cell_const) k;
+ decltype(flash_file::temp_coef) conf;
+
+ fseek(p_flash, (int) (&p_flash_file->cell_const) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&k, sizeof(flash_file::cell_const), 1, p_flash);
+
+ fseek(p_flash, (int) (&p_flash_file->temp_coef) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&conf, sizeof(flash_file::temp_coef), 1, p_flash);
+
+ rewind(p_adc);
+ fread(&adc, sizeof(adc_file), 1, p_adc);
+
+ temperature = adc.temp;
+ rtd_wire = adc.wire_mode;
+ rtd_type = adc.rtd_type;
+
+ conductivity = (k * (adc.p_curt - adc.n_curt) / (adc.p_volt - adc.n_volt))
+ * (100 / (100 + conf * (temperature - 25)));
+
+ if (rtd_wire == -1) {
+ beep(10);
+ }
+
+ OnDraw();
+}
+
+void CHomeDialog::OnDraw(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+ rewind(p_lcd);
+
+ if (rtd_wire == -1) {
+ fputs(" RTD Error ", p_lcd);
+ fputs(" use 25\xf8" "C", p_lcd);
+ } else {
+ fprintf(p_lcd, " RTD: %iW PT%i", rtd_wire, rtd_type);
+ fseek(p_lcd, 20, SEEK_SET);
+ fprintf(p_lcd, "%6.2f\xf8" "C", temperature);
+ }
+
+ fseek(p_lcd, 32, SEEK_SET);
+ fputs("Conductivity:", p_lcd);
+
+ fseek(p_lcd, 51, SEEK_SET);
+
+ if (isfinite(conductivity) && conductivity >= 1e-24 && conductivity < 1e27) {
+ char prefix[] = "y\0z\0\a\0\f\0p\0n\0u\0m\0\0\0k\0M\0G\0T\0P\0E\0Z\0Y";
+ int index = floor(log10(conductivity) / 3);
+
+ float f = conductivity / pow(1000, index);
+
+ if (f < 10) {
+ fprintf(p_lcd, "%6.4f%sS/cm", f, &prefix[index * 2 + 16]);
+ } else {
+ if (f < 100) {
+ fprintf(p_lcd, "%6.3f%sS/cm", f, &prefix[index * 2 + 16]);
+ } else {
+ fprintf(p_lcd, "%6.2f%sS/cm", f, &prefix[index * 2 + 16]);
+ }
+ }
+ } else {
+ fputs("sensor error", p_lcd);
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/SettingDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/SettingDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/SettingDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,138 @@
+/***************************************************************************//**
+ * @file SettingDialog.cpp
+ * @brief Implementation of SettingDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+CSettingDialog SettingDialog;
+
+struct {
+ const char caption[18];
+ CDialog * const p_dialog;
+} static const menu[] = {{"EXC Voltage", &VoltageDialog},
+ {"EXC Frequency", &FrequencyDialog},
+ {"T-H setup time", &SetupTimeDialog},
+ {"T-H hold time", &HoldTimeDialog},
+ {"TEMP Coefficient", &CoefficientDialog},
+ {"Cell Constant", &CellConstantDialog},
+ {"Baud Rate", &BaudRateDialog},
+ {"Return To Home", &HomeDialog},
+ {"LCD Contrast", &ContrastDialog},
+ {"Firmware Info", &FirmwareDialog}
+};
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+CSettingDialog::CSettingDialog(void)
+{
+ first_item = 5; //Cell Constant
+ selected_line = 3; //Return To Home
+}
+
+void CSettingDialog::OnCreat(void)
+{
+ OnDraw();
+}
+
+void CSettingDialog::OnEncoderCW(void)
+{
+ if (selected_line < 3) {
+ ++selected_line;
+ } else {
+
+ if (first_item < SIZE(menu) - 4) {
+ ++first_item;
+ } else {
+ beep(1);
+ }
+ }
+
+ OnDraw();
+}
+
+void CSettingDialog::OnEncoderCCW(void)
+{
+ if (selected_line > 0) {
+ --selected_line;
+ } else {
+ if (first_item > 0) {
+ --first_item;
+ } else {
+ beep(1);
+ }
+ }
+
+ OnDraw();
+}
+
+void CSettingDialog::OnButtonDown(void)
+{
+ p_dialog = menu[first_item + selected_line].p_dialog;
+ p_dialog->OnCreat();
+}
+
+void CSettingDialog::OnDraw(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+ rewind(p_lcd);
+
+ for (int y = 0; y < 4; ++y) {
+ fseek(p_lcd, y * 16, SEEK_SET);
+ fprintf(p_lcd, "%s", menu[first_item + y].caption);
+ }
+
+ fseek(p_lcd, selected_line * 16 + 64, SEEK_SET);
+
+ fputs("\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1", p_lcd);
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/SetupTimeDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/SetupTimeDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/SetupTimeDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,274 @@
+/***************************************************************************//**
+ * @file SetupTimeDialog.cpp
+ * @brief Implementation of SetupTimeDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+
+CSetupTimeDialog SetupTimeDialog;
+
+void CSetupTimeDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("Setup time:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = s10;
+
+ flash_file * p_flash_file;
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fread(&setup_time, sizeof(flash_file::setup), 1, p_flash);
+
+ OnDraw();
+}
+
+void CSetupTimeDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = s10;
+ case s10:
+ setup_time += 10;
+ break;
+ case s1:
+ setup_time += 1;
+ break;
+ case s0_1:
+ setup_time += 0.1f;
+ break;
+ case s0_01:
+ setup_time += 0.01f;
+ break;
+ }
+
+ if (setup_time > configure_file.max_setup) {
+ setup_time = configure_file.max_setup;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.setup = setup_time;
+
+ fseek(p_pwm, (int) (&pwm.setup) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.setup, sizeof(pwm_file::setup), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ default:
+ case s10:
+ menu_item = s1;
+ break;
+ case s1:
+ menu_item = s0_1;
+ break;
+ case s0_1:
+ menu_item = s0_01;
+ break;
+ case s0_01:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CSetupTimeDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ switch (menu_item) {
+ default:
+ menu_item = s10;
+ case s10:
+ setup_time -= 10;
+ break;
+ case s1:
+ setup_time -= 1;
+ break;
+ case s0_1:
+ setup_time -= 0.1f;
+ break;
+ case s0_01:
+ setup_time -= 0.01f;
+ break;
+ }
+
+ if (setup_time < configure_file.min_setup) {
+ setup_time = configure_file.min_setup;
+ beep(10);
+ }
+
+ pwm_file pwm;
+
+ pwm.setup = setup_time;
+
+ fseek(p_pwm, (int) (&pwm.setup) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.setup, sizeof(pwm_file::setup), 1, p_pwm);
+ fflush(p_pwm);
+ } else {
+ switch (menu_item) {
+ case s10:
+ beep(10);
+ return;
+ break;
+ case s1:
+ menu_item = s10;
+ break;
+ case s0_1:
+ menu_item = s1;
+ break;
+ case s0_01:
+ menu_item = s0_1;
+ break;
+ case save:
+ menu_item = s0_01;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CSetupTimeDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ pwm_file pwm;
+
+ switch (menu_item) {
+ default:
+ menu_item = s10;
+ case s10:
+ case s1:
+ case s0_1:
+ case s0_01:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&setup_time, sizeof(flash_file::setup), 1, p_flash);
+ fflush(p_flash);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ case cancel:
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fread(&setup_time, sizeof(flash_file::setup), 1, p_flash);
+
+ pwm.setup = setup_time;
+ fseek(p_pwm, (int) (&pwm.setup) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.setup, sizeof(pwm_file::setup), 1, p_pwm);
+ fflush(p_pwm);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CSetupTimeDialog::OnDraw(void)
+{
+ fseek(p_lcd, 101, SEEK_SET);
+ fwrite(zeros, 5, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 37, SEEK_SET);
+
+ fprintf(p_lcd, "%5.2f%%", setup_time);
+
+ switch (menu_item) {
+ default:
+ menu_item = s10;
+ case s10:
+ fseek(p_lcd, 101, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case s1:
+ fseek(p_lcd, 102, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case s0_1:
+ fseek(p_lcd, 104, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case s0_01:
+ fseek(p_lcd, 105, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/dialog/SplashDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/SplashDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/SplashDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,91 @@
+/***************************************************************************//**
+ * @file SplashDialog.cpp
+ * @brief Implementation of SplashDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+CSplashDialog SplashDialog;
+
+static int on_time(int argc, char *argv[])
+{
+ beep(200);
+ p_dialog = &HomeDialog;
+ p_dialog->OnCreat();
+}
+
+void CSplashDialog::OnButtonDown(void)
+{
+ timer t;
+ t.time = 100;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = on_time;
+
+ delete_timer(t);
+
+ beep(100, 100, 100);
+ p_dialog = &ContrastDialog;
+ p_dialog->OnCreat();
+}
+
+void CSplashDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+
+ fputs(" ANALOG DEVICES ", p_lcd);
+ fputs("AHEAD OF WHAT'S ", p_lcd);
+ fputs(" POSSIBLE ", p_lcd);
+ fputs("EVAL-CN0359-EB1Z", p_lcd);
+
+ fflush(p_lcd);
+
+ timer t;
+ t.time = 3000;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = on_time;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+}
+
Index: ADuCM360_demo_cn0359/src/applications/dialog/VoltageDialog.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/dialog/VoltageDialog.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/dialog/VoltageDialog.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,226 @@
+/***************************************************************************//**
+ * @file VoltageDialog.cpp
+ * @brief Implementation of VoltageDialog.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+
+CVoltageDialog VoltageDialog;
+
+void CVoltageDialog::OnCreat(void)
+{
+ rewind(p_lcd);
+ fwrite(zeros, 128, 1, p_lcd);
+
+ rewind(p_lcd);
+ fputs("EXC voltage:", p_lcd);
+
+ fseek(p_lcd, 48, SEEK_SET);
+ fputs(" Save Cancel", p_lcd);
+
+ in_edit = false;
+ menu_item = v1;
+
+ flash_file * p_flash_file;
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fread(&voltage, sizeof(flash_file::voltage), 1, p_flash);
+
+ OnDraw();
+}
+
+void CVoltageDialog::OnEncoderCW(void)
+{
+ if (in_edit) {
+ if (menu_item == v1) {
+ voltage += 1;
+ } else {
+ voltage += 0.1f;
+ }
+
+ if (voltage > configure_file.max_voltage) {
+ voltage = configure_file.max_voltage;
+ beep(10);
+ }
+
+ dac_file dac;
+ dac.voltage = voltage;
+ fseek(p_dac, (int) (&dac.voltage) - (int) (&dac), SEEK_SET);
+ fwrite(&dac.voltage, sizeof(dac_file::voltage), 1, p_dac);
+ fflush(p_dac);
+ } else {
+ switch (menu_item) {
+ default:
+ case v1:
+ menu_item = v0_1;
+ break;
+ case v0_1:
+ menu_item = save;
+ break;
+ case save:
+ menu_item = cancel;
+ break;
+ case cancel:
+ beep(10);
+ return;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CVoltageDialog::OnEncoderCCW(void)
+{
+ if (in_edit) {
+ if (menu_item == v1) {
+ voltage -= 1;
+ } else {
+ voltage -= 0.1f;
+ }
+
+ if (voltage < configure_file.min_voltage) {
+ voltage = configure_file.min_voltage;
+ beep(10);
+ }
+
+ dac_file dac;
+ dac.voltage = voltage;
+ fseek(p_dac, (int) (&dac.voltage) - (int) (&dac), SEEK_SET);
+ fwrite(&dac.voltage, sizeof(dac_file::voltage), 1, p_dac);
+ fflush(p_dac);
+ } else {
+ switch (menu_item) {
+ case v1:
+ beep(10);
+ return;
+ break;
+ case v0_1:
+ menu_item = v1;
+ break;
+ case save:
+ menu_item = v0_1;
+ break;
+ default:
+ case cancel:
+ menu_item = save;
+ break;
+ }
+ }
+
+ OnDraw();
+}
+
+void CVoltageDialog::OnButtonDown(void)
+{
+ flash_file * p_flash_file;
+
+ switch (menu_item) {
+ default:
+ menu_item = v1;
+ case v1:
+ case v0_1:
+ in_edit = !in_edit;
+ break;
+ case save:
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fwrite(&voltage, sizeof(flash_file::voltage), 1, p_flash);
+ fflush(p_flash);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ case cancel:
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fread(&voltage, sizeof(flash_file::voltage), 1, p_flash);
+
+ dac_file dac;
+ dac.voltage = voltage;
+ fseek(p_dac, (int) (&dac.voltage) - (int) (&dac), SEEK_SET);
+ fwrite(&dac.voltage, sizeof(dac_file::voltage), 1, p_dac);
+ fflush(p_dac);
+
+ p_dialog = &SettingDialog;
+ p_dialog->OnCreat();
+ return;
+ break;
+ }
+
+ OnDraw();
+}
+
+void CVoltageDialog::OnDraw(void)
+{
+ fseek(p_lcd, 102, SEEK_SET);
+ fwrite(zeros, 3, 1, p_lcd);
+
+ fseek(p_lcd, 112, SEEK_SET);
+ fwrite(zeros, 16, 1, p_lcd);
+
+ fseek(p_lcd, 37, SEEK_SET);
+
+ fprintf(p_lcd, "%4.1fV", voltage);
+
+ switch (menu_item) {
+ default:
+ menu_item = v1;
+ case v1:
+ fseek(p_lcd, 102, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case v0_1:
+ fseek(p_lcd, 104, SEEK_SET);
+ fputc(0x1 + in_edit, p_lcd);
+ break;
+ case save:
+ fseek(p_lcd, 112, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ case cancel:
+ fseek(p_lcd, 120, SEEK_SET);
+ fputs("\1\1\1\1\1\1\1\1", p_lcd);
+ break;
+ }
+
+ fflush(p_lcd);
+}
Index: ADuCM360_demo_cn0359/src/applications/main.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/main.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/main.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,63 @@
+/***************************************************************************//**
+ * @file main.cpp
+ * @brief Implementation of main.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+
+#include
+#include
+#include
+#include
+#include
+
+int main(void)
+{
+ SystemCoreClockUpdate(); // SystemCoreClock in bss, cleared by _start
+
+ initial_devices();
+
+ SysTick_Config(SystemCoreClock /
+ CLK_TCK); //system tick 100Hz = 10ms, defined in time.h
+
+ p_dialog = &SplashDialog;
+ p_dialog->OnCreat();
+
+ while (true) {
+ message_loop();
+ }
+}
Index: ADuCM360_demo_cn0359/src/applications/message.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/message.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/message.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,112 @@
+/***************************************************************************//**
+ * @file message.cpp
+ * @brief Implementation of message.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+
+#include
+#include
+
+using namespace std;
+
+list msg_l;
+
+#define MAX_SIZE 32
+
+//ts: thread safe
+#define TS_BUF_LEN 16
+static struct app ts_msg_buf[TS_BUF_LEN];
+static volatile int ts_msg_front = 0, ts_msg_back = 0;
+
+void ts_post_message(struct app &msg)
+{
+ assert(ts_msg_back != (ts_msg_front - 1));
+ assert(!(ts_msg_back == (TS_BUF_LEN - 1) && ts_msg_front == 0));
+ assert(msg.argc == 0); // new and delete parameter is not thread safe
+
+ ts_msg_buf[ts_msg_back] = msg;
+
+ if (ts_msg_back == TS_BUF_LEN - 1) {
+ ts_msg_back = 0;
+ } else {
+ ++ts_msg_back;
+ }
+}
+
+void post_message(struct app &msg)
+{
+ if (msg_l.size() < MAX_SIZE) {
+ msg_l.push_back(msg);
+ } else {
+ assert(false);
+ }
+}
+
+void execute(struct app application)
+{
+ (*application.fun)(application.argc, application.argv);
+
+ for (int i = 0; i < application.argc; ++i) {
+ delete[] application.argv[i];
+ }
+
+ delete application.argv;
+}
+
+void message_loop(void)
+{
+ while (ts_msg_front != ts_msg_back) {
+ ts_msg_buf[ts_msg_front].argv = new
+ char*; //ts_post_message not thread safe for new
+
+ post_message(ts_msg_buf[ts_msg_front]);
+
+ if (ts_msg_front == TS_BUF_LEN - 1) {
+ ts_msg_front = 0;
+ } else {
+ ++ts_msg_front;
+ }
+ }
+
+ if (!msg_l.empty()) {
+ execute(msg_l.front());
+
+ msg_l.pop_front();
+ }
+}
Index: ADuCM360_demo_cn0359/src/applications/uart_exec.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/applications/uart_exec.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/applications/uart_exec.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,113 @@
+/***************************************************************************//**
+ * @file uart_exec.cpp
+ * @brief Implementation of uart_exec.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+struct command {
+ const char *cmd;
+ int (*fun)(int argc, char *argv[]);
+};
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+struct command command_table[] = {{"poll", cmd_poll},
+ {"setvolt", cmd_voltage},
+ {"setfreq", cmd_frequency},
+ {"setk", cmd_cellconstant},
+ {"setcof", cmd_coefficient},
+ {"setstm", cmd_setuptime},
+ {"sethtm", cmd_holdtime}
+};
+
+int rx_line(int argc, char *argv[])
+{
+ char line[128];
+
+ rewind(stdin);
+ fgets(line, 128, stdin);
+
+ char *p;
+ p = strtok(line, ", \t\r\n");
+
+ for (int i = 0; i < SIZE(command_table); ++i) {
+ if (!strcmp(p, command_table[i].cmd)) {
+ app msg;
+ msg.fun = command_table[i].fun;
+ msg.argc = 1;
+ msg.argv = new char*[1];
+ msg.argv[0] = new char[strlen(command_table[i].cmd) + 1];
+ strcpy(msg.argv[0], command_table[i].cmd);
+
+ for (p = strtok(nullptr, ", \t\r\n"); p != nullptr;
+ p = strtok(nullptr, ", \t\r\n")) {
+ char **old_argv;
+ old_argv = msg.argv;
+
+ msg.argv = new char*[msg.argc + 1];
+
+ for (int j = 0; j < msg.argc; ++j) {
+ msg.argv[j] = old_argv[j];
+ }
+
+ msg.argv[msg.argc] = new char[strlen(p) + 1];
+
+ strcpy(msg.argv[msg.argc], p);
+
+ delete[] old_argv;
+ ++msg.argc;
+ }
+
+ post_message(msg);
+
+ break;
+ }
+ }
+}
Index: ADuCM360_demo_cn0359/src/hal/Exceptions.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/Exceptions.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/Exceptions.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,90 @@
+/***************************************************************************//**
+ * @file Exceptions.cpp
+ * @brief Implementation of Exceptions.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+
+using namespace std;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void HardFault_Handler(void)
+{
+ int CFSR = SCB->CFSR;
+ int HFSR = SCB->HFSR;
+ int DFSR = SCB->DFSR;
+ int MMFAR = SCB->MMFAR;
+ int BFAR = SCB->BFAR;
+ int AFSR = SCB->AFSR;
+
+ while (true)
+ ;
+}
+
+void MemManage_Handler(void)
+{
+ int CFSR = SCB->CFSR;
+ int MMFAR = SCB->MMFAR;
+
+ while (true)
+ ;
+}
+
+void BusFault_Handler(void)
+{
+ int CFSR = SCB->CFSR;
+ int BFAR = SCB->BFAR;
+
+ while (true)
+ ;
+}
+
+void UsageFault_Handler(void)
+{
+ int CFSR = SCB->CFSR;
+
+ while (true)
+ ;
+}
+
+#ifdef __cplusplus
+}
+#endif
Index: ADuCM360_demo_cn0359/src/hal/RTD.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/RTD.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/RTD.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,176 @@
+/***************************************************************************//**
+ * @file RTD.cpp
+ * @brief Implementation of RTD.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+
+#include
+#include
+
+#include
+
+#include
+
+#define ORDER 4
+
+#define FLOAT_TYPE float
+
+#define MAX_T 850.f
+#define MIN_T -200.f
+
+#define MIN_R 0.1852008f
+#define MAX_R 3.90481125f
+
+FLOAT_TYPE rtd_coeff[] = {1.e0l, 3.9083e-3l, -5.775e-7l, 4.183e-10l, -4.183e-12l};
+
+/* num_coeff[] is numerator polynomial coefficient list
+ * den_ceoff[] is denominator polynomial coefficient list
+ * ORDER defined rational polynomial precision
+ */
+
+#if ORDER == 4
+
+//effective bits 15.616
+FLOAT_TYPE num_coeff[] = {-2.42580348918581e2l, 4.43575581447635e2l, -8.6570608699616e2l, 7.34933695653457e2l, -7.02396810482965e1l};
+FLOAT_TYPE den_coeff[] = {1.e0l, -8.87493143817912e-1l, 2.75291524634514e0l, -3.88521936154463e-1l, 9.08722079164108e-3l};
+
+#endif
+
+#if ORDER == 5
+
+//effective bits 17.8245
+FLOAT_TYPE num_coeff[] = {-2.41711451348096e2l, 1.54212010305297e2l, 5.54970679760118e2l, -1.26796609113434e3l, 8.56166744043382e2l, -5.56764891254276e1l};
+FLOAT_TYPE den_coeff[] = {1.e0l, 2.63302632747995e-1l, -1.84510086458895e0l, 3.2746227792845e0l, -3.25653791878951e-1l, 3.44022334655219e-3l};
+
+#endif
+
+#if ORDER == 6
+
+//effective bits 19.82
+FLOAT_TYPE num_coeff[] = {-2.42142843978731e2l, 5.92083047602897e2l, -9.25895464531705e2l, 1.39340166396238e3l,
+ -1.47225489959494e3l, 7.09664483583688e2l, -5.48565127920454e1l
+ };
+FLOAT_TYPE den_coeff[] = {1.e0l, -1.51978059117102e0l, 2.48277654313265e0l, -3.47112904866882e0l, 2.80056808288615e0l,
+ -3.19022897847929e-1l, 6.25422836057902e-3l
+ };
+
+#endif
+
+#if ORDER == 7
+
+//effective bits 21.5
+FLOAT_TYPE num_coeff[] = {-2.41929621588221e2l, 4.82396434080762e2l, -1.67121893244441e1l, -1.37315140916645e3l,
+ 2.81292843561081e3l, -2.67151104549731e3l, 1.08281818377997e3l, -7.48389592163684e1l
+ };
+FLOAT_TYPE den_coeff[] = {1.e0l, -1.08173661281902e0l, -7.63181691057539e-1l, 4.60429829752353e0l, -6.86578653181876e0l,
+ 4.30546544990275e0l, -4.37253401604816e-1l, 7.00961785543309e-3l
+ };
+
+#endif
+
+#if ORDER == 8
+
+//effective bits 23.337
+FLOAT_TYPE num_coeff[] = {-2.42050820471513e2l, 9.03922568256792e2l, -1.59215856239e3l, 2.05579651580702e3l,
+ -2.5023311275312e3l, 2.58715968247352e3l, -1.72836289632771e3l, 5.56615054519548e2l,
+ -3.85904217448201e1l
+ };
+FLOAT_TYPE den_coeff[] = {1.e0l, -2.81393474700247e0l, 4.07953003378532e0l, -4.96524658655131e0l, 5.95307465876528e0l,
+ -5.20533093922899e0l, 2.29944525926975e0l, -2.31214523979689e-1l, 4.3399532290543e-3l
+ };
+
+#endif
+
+#if ORDER == 9
+
+//effective bits 24.6
+FLOAT_TYPE num_coeff[] = {-2.41968339549439e2l, 2.91135402145953e2l, 1.20532207372212e3l, -4.6631158165784e3l,
+ 9.54173545500971e3l, -1.408246803981e4l, 1.4213332684621e4l, -8.59797958055946e3l,
+ 2.49954894344233e3l, -1.65542792821347e2l
+ };
+FLOAT_TYPE den_coeff[] = {1.e0l, -2.89485047831221e-1l, -5.08894034154434e0l, 1.42530537624761e1l, -2.58291119118538e1l,
+ 3.35473327796638e1l, -2.67543757779824e1l, 1.04025522724728e1l, -9.94173619261334e-1l,
+ 1.76585466116337e-2l
+ };
+
+#endif
+
+/*
+ * temperature to resistance convert based on IEC751/ITS-90
+ * temperature t in celsius degree
+ * resistance normalized to 1 at 0°C
+ *
+ */
+
+float temp2res(float t)
+{
+ assert(t >= MIN_T && t <= MAX_T);
+
+ FLOAT_TYPE res = rtd_coeff[t >= 0 ? 2 : 4];
+
+ for (int i = (t >= 0 ? 1 : 3); i >= 0; --i) {
+ res = res * t + rtd_coeff[i];
+ }
+
+ return (res);
+}
+
+/*
+ * resistance to temperature convert based on rational polynomial
+ * resistance r normalized to 1 at 0°C
+ * temperature in celsius degree
+ *
+ */
+
+float res2temp(float r)
+{
+ assert(r >= MIN_R && r <= MAX_R);
+
+ FLOAT_TYPE num_poly = num_coeff[sizeof(num_coeff) / sizeof(num_coeff[0]) - 1];
+ FLOAT_TYPE den_poly = den_coeff[sizeof(den_coeff) / sizeof(den_coeff[0]) - 1];
+
+ for (int i = (sizeof(num_coeff) / sizeof(num_coeff[0]) - 2); i >= 0; --i) {
+ num_poly = num_poly * r + num_coeff[i];
+ }
+
+ for (int i = (sizeof(den_coeff) / sizeof(den_coeff[0]) - 2); i >= 0; --i) {
+ den_poly = den_poly * r + den_coeff[i];
+ }
+
+ return (num_poly / den_poly);
+}
Index: ADuCM360_demo_cn0359/src/hal/devices.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/devices.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/devices.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,115 @@
+/***************************************************************************//**
+ * @file devices.cpp
+ * @brief Implementation of devices.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+FILE *p_lcd, *p_uart, *p_flash, *p_dac, *p_adc, *p_pwm, *p_ad8253;
+
+void initial_devices(void)
+{
+ setvbuf(stdout, nullptr, _IOLBF, 64);
+ setvbuf(stdin, nullptr, _IOFBF, 16);
+ setvbuf(stderr, nullptr, _IONBF, 0);
+
+ NVIC_SetPriorityGrouping(6); //2 groups, each group have 4 subpriorities
+
+ buzzer_open();
+
+ p_flash = fopen("flash", "rb+");
+ setvbuf(p_flash, nullptr, _IOFBF, sizeof(flash_file));
+
+ flash_file setting;
+ rewind(p_flash);
+ fread(&setting, sizeof(flash_file), 1, p_flash);
+
+ if (setting.baud_rate <= configure_file.max_baud_rate
+ && setting.baud_rate >= configure_file.min_baud_rate
+ && setting.cell_const <= configure_file.max_cell_const
+ && setting.cell_const >= configure_file.min_cell_const
+ && setting.frequency <= configure_file.max_freq
+ && setting.frequency >= configure_file.min_freq
+ && setting.temp_coef <= configure_file.max_temp_coef
+ && setting.temp_coef >= configure_file.min_temp_coef
+ && setting.voltage <= configure_file.max_voltage
+ && setting.voltage >= configure_file.min_voltage
+ && setting.setup <= configure_file.max_setup
+ && setting.setup >= configure_file.min_setup
+ && setting.hold <= configure_file.max_hold
+ && setting.hold >= configure_file.min_hold
+ && setting.brightness <= configure_file.max_brightness
+ && setting.brightness >= configure_file.min_brightness) { //check flash_disk
+ beep(50); // disk ok
+ } else { // disk error
+ rewind(p_flash);
+ fwrite(&default_setting, sizeof(flash_file), 1, p_flash);
+ fflush(p_flash);
+
+ beep(50, 50, 50, 50, 50, 50, 50, 50, 50);
+ }
+
+ p_uart = fopen("uart", "r");
+ setvbuf(p_uart, nullptr, _IONBF, 0);
+
+ p_lcd = fopen("lcd", "rb+");
+ setvbuf(p_lcd, nullptr, _IOFBF, 16);
+
+ p_dac = fopen("dac", "rb+");
+ setvbuf(p_dac, nullptr, _IOFBF, sizeof(dac_file));
+
+ p_pwm = fopen("pwm", "rb+");
+ setvbuf(p_pwm, nullptr, _IOFBF, sizeof(pwm_file));
+
+ p_ad8253 = fopen("ad8253", "rb+");
+ setvbuf(p_ad8253, nullptr, _IOFBF, sizeof(ad8253_file));
+
+ p_adc = fopen("adc", "rb");
+ setvbuf(p_adc, nullptr, _IOFBF, sizeof(adc_file));
+
+ encoder_open();
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/ad8253.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/ad8253.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/ad8253.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,214 @@
+/***************************************************************************//**
+ * @file ad8253.cpp
+ * @brief Implementation of ad8253.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+static int position;
+
+static int i_gain, v_gain;
+
+ssize_t ad8253_read(void *buf, size_t count)
+{
+ ad8253_file file;
+
+ file.i_gain = i_gain;
+ file.v_gain = v_gain;
+
+ if ((position + count) > sizeof(ad8253_file)) {
+ count = sizeof(ad8253_file) - position;
+ }
+
+ memcpy(buf, (char*) (&file) + position, count);
+
+ position += count;
+
+ return count;
+}
+
+ssize_t ad8253_write(const void *buf, size_t count)
+{
+ ad8253_file file;
+
+ file.i_gain = i_gain;
+ file.v_gain = v_gain;
+
+ if ((position + count) > sizeof(ad8253_file)) {
+ count = sizeof(ad8253_file) - position;
+ }
+
+ memcpy((char*) (&file) + position, buf, count);
+
+ if (file.v_gain != v_gain) {
+ switch (file.v_gain) {
+ case 1:
+ GP1CLR_CLR2_BBA = true;
+ GP2CLR_CLR1_BBA = true;
+ break;
+ case 10:
+ GP1SET_SET2_BBA = true;
+ GP2CLR_CLR1_BBA = true;
+ break;
+ case 100:
+ GP1CLR_CLR2_BBA = true;
+ GP2SET_SET1_BBA = true;
+ break;
+ case 1000:
+ GP1SET_SET2_BBA = true;
+ GP2SET_SET1_BBA = true;
+ break;
+ default:
+ goto end_v;
+ break;
+ }
+ GP0CLR_CLR0_BBA = true;
+ GP0SET_SET0_BBA = true;
+ v_gain = file.v_gain;
+end_v:
+ ;
+ }
+
+ if (file.i_gain != i_gain) {
+ switch (file.i_gain) {
+ case 1:
+ GP1CLR_CLR2_BBA = true;
+ GP2CLR_CLR1_BBA = true;
+ break;
+ case 10:
+ GP1SET_SET2_BBA = true;
+ GP2CLR_CLR1_BBA = true;
+ break;
+ case 100:
+ GP1CLR_CLR2_BBA = true;
+ GP2SET_SET1_BBA = true;
+ break;
+ case 1000:
+ GP1SET_SET2_BBA = true;
+ GP2SET_SET1_BBA = true;
+ break;
+ default:
+ goto end_i;
+ break;
+ }
+ GP2CLR_CLR0_BBA = true;
+ GP2SET_SET0_BBA = true;
+ i_gain = file.i_gain;
+end_i:
+ ;
+ }
+
+ position += count;
+
+ return count;
+}
+
+off_t ad8253_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(ad8253_file) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = offset;
+ }
+ break;
+ case SEEK_CUR:
+ if ((position + offset) > sizeof(ad8253_file) || (position + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position += offset;
+ }
+ break;
+ case SEEK_END:
+ if (offset > 0 || (sizeof(ad8253_file) + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = sizeof(ad8253_file) + offset;
+ }
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ break;
+ }
+
+ return position;
+}
+
+void ad8253_open(void)
+{
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON0_MSK) | GP0CON_CON0_GPIO;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON2_MSK) | GP1CON_CON2_GPIO;
+ pADI_GP2->GPCON = (pADI_GP2->GPCON & ~GP2CON_CON0_MSK) | GP2CON_CON0_GPIO;
+ pADI_GP2->GPCON = (pADI_GP2->GPCON & ~GP2CON_CON1_MSK) | GP2CON_CON1_GPIO;
+
+ GP0OCE_OCE0_BBA = false;
+ GP1OCE_OCE2_BBA = false;
+ GP2OCE_OCE0_BBA = false;
+ GP2OCE_OCE1_BBA = false;
+
+ GP1CLR_CLR2_BBA = true;
+ GP2CLR_CLR1_BBA = true;
+
+ GP0SET_SET0_BBA = true;
+ GP2SET_SET0_BBA = true;
+
+ GP0OEN_OEN0_BBA = true;
+ GP1OEN_OEN2_BBA = true;
+ GP2OEN_OEN0_BBA = true;
+ GP2OEN_OEN1_BBA = true;
+
+ GP0PUL_PUL0_BBA = true;
+ GP1PUL_PUL2_BBA = true;
+ GP2PUL_PUL0_BBA = true;
+ GP2PUL_PUL1_BBA = true;
+
+ GP0CLR_CLR0_BBA = true; //write 0
+ GP0SET_SET0_BBA = true;
+ v_gain = 1;
+
+ GP2CLR_CLR0_BBA = true; //write 0
+ GP2SET_SET0_BBA = true;
+ i_gain = 1;
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/adc.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/adc.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/adc.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,559 @@
+/***************************************************************************//**
+ * @file adc.cpp
+ * @brief Implementation of adc.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define ADC0FLT_AF (15<<8)
+#define ADC0FLT_SF 124
+
+#define ADC1FLT_AF (15<<8)
+#define ADC1FLT_SF 124
+
+/* ad8253 output p-p voltage Vref 7.5kΩ 3.3V 7.5kΩ
+ * ─────────────────────────── = ─────── * ─────── = ──────────── * ─────── = 7.68341124057769775390625e-8
+ * data 2^^28 1.2kΩ 0x10000000 1.2kΩ
+ */
+#define ADC0_GAIN 7.68341124057769775390625e-8
+
+static volatile int adc0_result,
+ adc1_result; //transfer value from IRQ to on_adc?()
+static int adc0_cfg = 0;
+
+static adc_file result;
+
+static int position = 0;
+
+ssize_t adc_read(void *buf, size_t count)
+{
+ if ((position + count) > sizeof(adc_file)) {
+ count = sizeof(adc_file) - position;
+ }
+
+ memcpy(buf, (char*) (&result) + position, count);
+
+ position += count;
+
+ return count;
+}
+
+ssize_t adc_write(const void *buf, size_t count)
+{
+ if ((position + count) > sizeof(adc_file)) {
+ count = sizeof(adc_file) - position;
+ }
+
+ position += count;
+
+ return count;
+}
+
+off_t adc_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(adc_file) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = offset;
+ }
+ break;
+ case SEEK_CUR:
+ if ((position + offset) > sizeof(adc_file) || (position + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position += offset;
+ }
+ break;
+ case SEEK_END:
+ if (offset > 0 || (sizeof(adc_file) + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = sizeof(adc_file) + offset;
+ }
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ break;
+ }
+
+ return position;
+}
+
+static int start_adc0(int argc, char *argv[])
+{
+ pADI_ADC0->MDE = (pADI_ADC0->MDE & ~ADC0MDE_ADCMD_MSK) | ADC0MDE_ADCMD_SINGLE;
+ ADC0CON_ADCEN_BBA = true;
+
+ return 0;
+}
+
+void adc_open(void)
+{
+ CLKDIS_DISADCCLK_BBA = false;
+
+ pADI_ANA->REFCTRL = REFCTRL_REFPD_DIS;
+
+ pADI_ADC0->MDE = ADC0MDE_PGA_G1 | ADC0MDE_ADCMOD2_MOD2OFF |
+ ADC0MDE_ADCMD_SINGLE;
+
+ pADI_ADC0->FLT = ADC0FLT_CHOP_ON | ADC0FLT_RAVG2_ON | ADC0FLT_SINC4EN_DIS |
+ ADC0FLT_AF | ADC0FLT_NOTCH2_EN | ADC0FLT_SF;
+
+ pwm_file pwm;
+ pwm.inv = false;
+ fseek(p_pwm, (int) (&pwm.inv) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.inv, sizeof(pwm_file::inv), 1, p_pwm);
+ fflush(p_pwm);
+
+ pADI_ADC0->CON = ADC0CON_ADCEN_DIS | ADC0CON_ADCCODE_INT | ADC0CON_BUFPOWN_EN |
+ ADC0CON_BUFPOWP_EN
+ | ADC0CON_BUFBYPP_EN | ADC0CON_BUFBYPN_EN | ADC0CON_ADCREF_AVDDREF |
+ ADC0CON_ADCDIAG_DIAG_OFF
+ | ADC0CON_ADCCP_AIN0 | ADC0CON_ADCCN_AIN1;
+ adc0_cfg = 0;
+ result.adc0_hit = 0;
+ result.adc1_hit = 0;
+ result.temp = 25;
+ result.wire_mode = -1;
+ result.rtd_type = -1;
+
+ pADI_ADC0->ADCCFG = ADCCFG_SIMU_DIS | ADCCFG_BOOST30_DIS | ADCCFG_PINSEL_DIS |
+ ADCCFG_GNDSWON_EN
+ | ADCCFG_GNDSWRESEN_DIS | ADCCFG_EXTBUF_OFF;
+
+ pADI_ADC0->MSKI = ADC0MSKI_ATHEX_DIS | ADC0MSKI_THEX_DIS | ADC0MSKI_OVR_DIS |
+ ADC0MSKI_RDY_EN;
+
+ pADI_ADC1->MDE = ADC1MDE_PGA_G1 | ADC1MDE_ADCMOD2_MOD2OFF |
+ ADC1MDE_ADCMD_SINGLE;
+
+ pADI_ADC1->FLT = ADC1FLT_CHOP_ON | ADC1FLT_RAVG2_ON | ADC1FLT_SINC4EN_DIS |
+ ADC1FLT_AF | ADC1FLT_NOTCH2_EN
+ | ADC1FLT_SF;
+
+ pADI_ADC1->CON = ADC1CON_ADCEN_DIS | ADC1CON_ADCCODE_UINT | ADC1CON_BUFPOWN_EN |
+ ADC1CON_BUFPOWP_EN
+ | ADC1CON_BUFBYPP_EN | ADC1CON_BUFBYPN_EN | ADC1CON_ADCREF_INTREF |
+ ADC1CON_ADCDIAG_DIAG_ALL
+ | ADC1CON_ADCCP_AIN6 | ADC1CON_ADCCN_AGND;
+
+ pADI_ANA->IEXCCON = IEXCCON_PD_off | IEXCCON_REFSEL_Int | IEXCCON_IPSEL1_AIN7 |
+ IEXCCON_IPSEL0_Off;
+
+ pADI_ANA->IEXCDAT = IEXCDAT_IDAT_600uA | IEXCDAT_IDAT0_EN; //610uA
+
+ pADI_ADC1->ADCCFG = ADCSCFG1_SIMU_DIS | ADCSCFG1_BOOST30_DIS |
+ ADCSCFG1_PINSEL_DIS | ADCSCFG1_GNDSWON_EN
+ | ADCSCFG1_GNDSWRESEN_DIS | ADCSCFG1_EXTBUF_OFF;
+
+ pADI_ADC1->MSKI = ADC1MSKI_ATHEX_DIS | ADC1MSKI_THEX_DIS | ADC1MSKI_OVR_DIS |
+ ADC1MSKI_RDY_EN;
+
+ NVIC_SetPriority(ADC0_IRQn, NVIC_EncodePriority(6, 1, 1));
+
+ NVIC_SetPriority(ADC1_IRQn, NVIC_EncodePriority(6, 1, 1));
+
+ NVIC_EnableIRQ(ADC0_IRQn);
+
+ NVIC_EnableIRQ(ADC1_IRQn);
+
+ timer t;
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+
+ ADC1CON_ADCEN_BBA = true;
+}
+
+/*
+ * ┌──────────────┬──────┬───────┬──────────┐
+ * | adc0_cfg │ IN+ │ IN- │ pwm1 inv │
+ * ├──────────────┼──────┼───────┼──────────┤
+ * | 0 │ ADC0 │ ADC1 │ 0 │
+ * ├──────────────┼──────┼───────┼──────────┤
+ * | 1 │ ADC2 │ ADC3 │ 0 │
+ * ├──────────────┼──────┼───────┼──────────┤
+ * | 2 │ ADC0 │ ADC1 │ 1 │
+ * ├──────────────┼──────┼───────┼──────────┤
+ * | 3 │ ADC2 │ ADC3 │ 1 │
+ * └──────────────┴──────┴───────┴──────────┘
+ *
+ * chopping setup time 50ms
+ *
+ */
+static int on_adc0(int argc, char *argv[])
+{
+ ad8253_file ad8253;
+ timer t;
+
+ rewind(p_ad8253);
+ fread(&ad8253, sizeof(ad8253_file), 1, p_ad8253);
+
+ if (abs(adc0_result) > (0x10000000 * 0.94)) { //upper threshold is 0.94*FS
+ if ((adc0_cfg & 0x1) == 0x0) { //current channel
+ if (ad8253.i_gain > 1) {
+ ad8253.i_gain /= 10;
+
+ fseek(p_ad8253, (int) (&ad8253.i_gain) - (int) (&ad8253), SEEK_SET);
+
+ fwrite(&ad8253.i_gain, sizeof(ad8253_file::i_gain), 1, p_ad8253);
+
+ fflush(p_ad8253);
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+
+ return 0;
+ }
+ } else { //voltage channel
+ if (ad8253.v_gain > 1) {
+ ad8253.v_gain /= 10;
+
+ fseek(p_ad8253, (int) (&ad8253.v_gain) - (int) (&ad8253), SEEK_SET);
+
+ fwrite(&ad8253.v_gain, sizeof(ad8253_file::v_gain), 1, p_ad8253);
+
+ fflush(p_ad8253);
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+
+ return 0;
+ }
+ }
+ }
+
+ if (abs(adc0_result) < (0x10000000 * 0.088)) { //lower threshold is 0.088*FS
+ if ((adc0_cfg & 0x1) == 0x0) { //current channel
+ if (ad8253.i_gain < 1000) {
+ ad8253.i_gain *= 10;
+
+ fseek(p_ad8253, (int) (&ad8253.i_gain) - (int) (&ad8253), SEEK_SET);
+
+ fwrite(&ad8253.i_gain, sizeof(ad8253_file::i_gain), 1, p_ad8253);
+
+ fflush(p_ad8253);
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+
+ return 0;
+ }
+ } else { //voltage channel
+ if (ad8253.v_gain < 1000) {
+ ad8253.v_gain *= 10;
+
+ fseek(p_ad8253, (int) (&ad8253.v_gain) - (int) (&ad8253), SEEK_SET);
+
+ fwrite(&ad8253.v_gain, sizeof(ad8253_file::v_gain), 1, p_ad8253);
+
+ fflush(p_ad8253);
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+
+ return 0;
+ }
+ }
+ }
+
+ pwm_file pwm;
+
+ switch (adc0_cfg) {
+ default:
+ adc0_cfg = 0;
+ case 0:
+ result.p_curt = ((adc0_result * ADC0_GAIN) / ad8253.i_gain) / 1000; // R47 = 1k
+ result.p_curt_gain = ad8253.i_gain;
+
+ pADI_ADC0->CON = (pADI_ADC0->CON & ~ADC0CON_ADCCP_MSK & ~ADC0CON_ADCCN_MSK) |
+ ADC0CON_ADCCP_AIN2
+ | ADC0CON_ADCCN_AIN3;
+ adc0_cfg = 1;
+ start_adc0(0, nullptr);
+ break;
+ case 1:
+ result.p_volt = (adc0_result * ADC0_GAIN) / ad8253.v_gain;
+ result.p_volt_gain = ad8253.v_gain;
+
+ pwm.inv = true;
+ fseek(p_pwm, (int) (&pwm.inv) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.inv, sizeof(pwm_file::inv), 1, p_pwm);
+ fflush(p_pwm);
+
+ pADI_ADC0->CON = (pADI_ADC0->CON & ~ADC0CON_ADCCP_MSK & ~ADC0CON_ADCCN_MSK) |
+ ADC0CON_ADCCP_AIN0
+ | ADC0CON_ADCCN_AIN1;
+ adc0_cfg = 2;
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+ break;
+ case 2:
+ result.n_curt = ((adc0_result * ADC0_GAIN) / ad8253.i_gain) / 1000; // R47 = 1k
+ result.n_curt_gain = ad8253.i_gain;
+
+ pADI_ADC0->CON = (pADI_ADC0->CON & ~ADC0CON_ADCCP_MSK & ~ADC0CON_ADCCN_MSK) |
+ ADC0CON_ADCCP_AIN2
+ | ADC0CON_ADCCN_AIN3;
+ adc0_cfg = 3;
+ start_adc0(0, nullptr);
+ break;
+ case 3:
+ result.n_volt = (adc0_result * ADC0_GAIN) / ad8253.v_gain;
+ result.n_volt_gain = ad8253.v_gain;
+
+ pwm.inv = false;
+ fseek(p_pwm, (int) (&pwm.inv) - (int) (&pwm), SEEK_SET);
+ fwrite(&pwm.inv, sizeof(pwm_file::inv), 1, p_pwm);
+ fflush(p_pwm);
+
+ pADI_ADC0->CON = (pADI_ADC0->CON & ~ADC0CON_ADCCP_MSK & ~ADC0CON_ADCCN_MSK) |
+ ADC0CON_ADCCP_AIN0
+ | ADC0CON_ADCCN_AIN1;
+ adc0_cfg = 0;
+
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = start_adc0;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+ break;
+ }
+
+ ++result.adc0_hit;
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = on_conductivity;
+ msg.argv = new char*;
+ post_message(msg);
+
+ return 0;
+}
+
+/*
+ * ┌─────────────┬────────────┐
+ * | temperature │ resistance │
+ * ├─────────────┼────────────┤
+ * | 120°C │ 1.4607 │
+ * ├─────────────┼────────────┤
+ * | -20°C │ 0.9216 │
+ * └─────────────┴────────────┘
+ *
+ * unbuffer mode ADC input resistance:
+ *
+ * 1V
+ * Radc = ───────── = 2MΩ
+ * 500nA/V
+ *
+ * 2MΩ//RTD 1074547130368 * RTD
+ * ADC1DATA = ──────────── * 0x10000000 = ─────────────────────
+ * 2MΩ//1.5kΩ 6M + 3 * RTD
+ *
+ * 6M * ADC1DATA
+ * RTD = ────────────────────────────────
+ * 1074547130368 - (3 * ADC1DATA)
+ *
+ * for PT1000
+ *
+ * 120°C 2MΩ//1.4607kΩ
+ * ADC1DATA = ─────────────── * 0x10000000 = 0x0f94c35c
+ * 2MΩ//1.5kΩ
+ *
+ * -20°C 2MΩ//921.6kΩ
+ * ADC1DATA = ─────────────── * 0x10000000 = 0x09d54f53
+ * 2MΩ//1.5kΩ
+ *
+ * for PT100
+ *
+ * 120°C 2MΩ//146.07Ω
+ * ADC1DATA = ─────────────── * 0x10000000 = 0x018f2373
+ * 2MΩ//1.5kΩ
+ *
+ * -20°C 2MΩ//92.16Ω
+ * ADC1DATA = ─────────────── * 0x10000000 = 0x00fbd5db
+ * 2MΩ//1.5kΩ
+ *
+ */
+static int on_adc1(int argc, char *argv[])
+{
+ static int wire = 4;
+
+ if ((pADI_ADC1->CON & ADC1CON_ADCDIAG_MSK) !=
+ ADC1CON_ADCDIAG_DIAG_OFF) { //diagnostic mode
+ if ((pADI_ADC1->CON & ADC1CON_ADCCP_MSK) ==
+ ADC1CON_ADCCP_AIN6) { //AIN6 diagnostic
+ if (adc1_result < 0xfff0000) { //available
+ wire = 4;
+ pADI_ADC1->CON = (pADI_ADC1->CON & ~ADC1CON_ADCREF_MSK & ~ADC1CON_ADCDIAG_MSK &
+ ~ADC1CON_ADCCP_MSK
+ & ~ADC1CON_ADCCN_MSK) | ADC1CON_ADCREF_EXTREF2 | ADC1CON_ADCDIAG_DIAG_OFF |
+ ADC1CON_ADCCP_AIN6 | ADC1CON_ADCCN_AIN5;
+ pADI_ANA->IEXCCON = (pADI_ANA->IEXCCON & ~IEXCCON_IPSEL0_MSK) |
+ IEXCCON_IPSEL0_Off;
+ } else {
+ pADI_ADC1->CON = (pADI_ADC1->CON & ~ADC1CON_ADCCP_MSK) | ADC1CON_ADCCP_AIN5;
+ }
+ } else { //AIN5 diagnostic
+ if (adc1_result < 0xfff0000) { //available
+ wire = 3;
+ pADI_ADC1->CON = (pADI_ADC1->CON & ~ADC1CON_ADCREF_MSK & ~ADC1CON_ADCDIAG_MSK &
+ ~ADC1CON_ADCCP_MSK
+ & ~ADC1CON_ADCCN_MSK) | ADC1CON_ADCREF_EXTREF2 | ADC1CON_ADCDIAG_DIAG_OFF |
+ ADC1CON_ADCCP_AIN8 | ADC1CON_ADCCN_AIN5;
+ pADI_ANA->IEXCCON = (pADI_ANA->IEXCCON & ~IEXCCON_IPSEL0_MSK) |
+ IEXCCON_IPSEL0_AIN5;
+ } else {
+ wire = 2;
+ pADI_ADC1->CON = (pADI_ADC1->CON & ~ADC1CON_ADCREF_MSK & ~ADC1CON_ADCDIAG_MSK &
+ ~ADC1CON_ADCCP_MSK
+ & ~ADC1CON_ADCCN_MSK) | ADC1CON_ADCREF_EXTREF2 | ADC1CON_ADCDIAG_DIAG_OFF |
+ ADC1CON_ADCCP_AIN8 | ADC1CON_ADCCN_AIN9;
+ pADI_ANA->IEXCCON = (pADI_ANA->IEXCCON & ~IEXCCON_IPSEL0_MSK) |
+ IEXCCON_IPSEL0_Off;
+ }
+ }
+ } else { //normal mode
+ if ((adc1_result >= 0x09d54f53 && adc1_result <= 0x0f94c35c)
+ || (adc1_result >= 0x00fbd5db && adc1_result <= 0x018f2373)) {
+ if (adc1_result >= 0x09d54f53) { //PT1000
+ result.temp = res2temp(6.e3f * adc1_result / (1074547130368ll -
+ (3ll * adc1_result))); //normalized to 1 at 0°C
+ result.rtd_type = 1000;
+ } else { //PT100
+ result.temp = res2temp(6.e4f * adc1_result / (1074547130368ll -
+ (3ll * adc1_result))); //normalized to 1 at 0°C
+ result.rtd_type = 100;
+ }
+
+ result.wire_mode = wire;
+ ++result.adc1_hit;
+ } else { //data not reliable
+ result.wire_mode = -1;
+ result.rtd_type = -1;
+ result.temp = 25;
+ }
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = on_rtd;
+ msg.argv = new char*;
+ post_message(msg);
+
+ pADI_ADC1->CON = (pADI_ADC1->CON & ~ADC1CON_ADCREF_MSK & ~ADC1CON_ADCDIAG_MSK &
+ ~ADC1CON_ADCCP_MSK & ~ADC1CON_ADCCN_MSK)
+ | ADC1CON_ADCREF_INTREF | ADC1CON_ADCDIAG_DIAG_ALL | ADC1CON_ADCCP_AIN6 |
+ ADC1CON_ADCCN_AGND; //enter diagnostic mode
+ }
+
+ pADI_ADC1->MDE = (pADI_ADC1->MDE & ~ADC1MDE_ADCMD_MSK) | ADC1MDE_ADCMD_SINGLE;
+ ADC1CON_ADCEN_BBA = true;
+
+ return 0;
+}
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+void ADC0_Int_Handler(void)
+{
+ adc0_result = pADI_ADC0->DAT;
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = on_adc0;
+ ts_post_message(msg);
+}
+
+void ADC1_Int_Handler(void)
+{
+ adc1_result = pADI_ADC1->DAT;
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = on_adc1;
+ ts_post_message(msg);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
Index: ADuCM360_demo_cn0359/src/hal/drivers/buzzer.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/buzzer.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/buzzer.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,109 @@
+/***************************************************************************//**
+ * @file buzzer.cpp
+ * @brief Implementation of buzzer.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+
+#include
+
+using namespace std;
+
+list beep_l;
+
+void buzzer_open(void)
+{
+ pADI_GP2->GPCON = (pADI_GP2->GPCON & ~GP2CON_CON2_MSK) | GP2CON_CON2_GPIO;
+
+ GP2OCE_OCE2_BBA = false;
+
+ GP2SET_SET2_BBA = true;
+
+ GP2OEN_OEN2_BBA = true;
+
+ GP2PUL_PUL2_BBA = true;
+}
+
+int static beep_loop(int argc, char *argv[])
+{
+ timer t;
+
+ if (!beep_l.empty()) {
+ t.time = beep_l.front();
+ beep_l.pop_front();
+
+ t.timer_app.fun = beep_loop;
+ t.timer_app.argc = 0;
+ t.timer_app.argv = new char*;
+
+ GP2TGL_TGL2_BBA = 0x1;
+
+ update_timer(t);
+ } else {
+ t.timer_app.fun = beep_loop;
+ t.timer_app.argc = 0;
+
+ delete_timer(t);
+ GP2SET_SET2_BBA = 0x1; //stop
+ }
+}
+
+void _beep(int time, ...)
+{
+ GP2SET_SET2_BBA = 0x1; //stop
+
+ beep_l.clear();
+
+ timer t;
+ t.timer_app.fun = beep_loop;
+ t.timer_app.argc = 0;
+
+ delete_timer(t);
+
+ va_list ap;
+ va_start(ap, time);
+
+ for (int i = time; i > 0; i = va_arg(ap, int)) {
+ beep_l.push_back(i);
+ }
+
+ va_end(ap);
+
+ beep_loop(0, nullptr); //start
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/dac.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/dac.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/dac.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,149 @@
+/***************************************************************************//**
+ * @file dac.cpp
+ * @brief Implementation of dac.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+
+//schematic: (0x0fff0000 * 15k) / (1.2v * (15k + 110k)) = 26836992
+#define GAIN 26836992.f
+
+static int position = 0;
+
+ssize_t dac_read(void *buf, size_t count)
+{
+ dac_file file;
+
+ file.voltage = pADI_DAC->DACDAT / GAIN;
+
+ if ((position + count) > sizeof(dac_file)) {
+ count = sizeof(dac_file) - position;
+ }
+
+ memcpy(buf, (char*) (&file) + position, count);
+
+ position += count;
+
+ return count;
+}
+
+ssize_t dac_write(const void *buf, size_t count)
+{
+ dac_file file;
+
+ file.voltage = pADI_DAC->DACDAT / GAIN;
+
+ if ((position + count) > sizeof(dac_file)) {
+ count = sizeof(dac_file) - position;
+ }
+
+ memcpy((char*) (&file) + position, buf, count);
+
+ position += count;
+
+ if (file.voltage <= configure_file.max_voltage
+ && file.voltage >= configure_file.min_voltage) {
+ pADI_DAC->DACDAT = lround(file.voltage * GAIN);
+ }
+
+ return count;
+}
+
+off_t dac_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(dac_file) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = offset;
+ }
+ break;
+ case SEEK_CUR:
+ if ((position + offset) > sizeof(dac_file) || (position + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position += offset;
+ }
+ break;
+ case SEEK_END:
+ if (offset > 0 || (sizeof(dac_file) + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = sizeof(dac_file) + offset;
+ }
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ break;
+ }
+
+ return position;
+}
+
+void dac_open(void)
+{
+ CLKDIS_DISDACCLK_BBA = false;
+
+ pADI_ANA->REFCTRL = REFCTRL_REFPD_DIS;
+
+ pADI_DAC->DACCON = DACCON_DMAEN_Off | DACCON_PD_DIS | DACCON_NPN_DIS |
+ DACCON_BUFBYP_DIS | DACCON_CLK_HCLK
+ | DACCON_CLR_On | DACCON_MDE_16BitFast |
+ DACCON_RNG_IntVref; //please check with user guide, DACCON_MDE_16BitFast is slow mode
+
+ DACCON_CLR_BBA = true;
+
+ flash_file * p_flash_file;
+
+ decltype(flash_file::voltage) voltage;
+
+ fseek(p_flash, (int) (&p_flash_file->voltage) - (int) (p_flash_file), SEEK_SET);
+ fread(&voltage, sizeof(dac_file::voltage), 1, p_flash);
+
+ pADI_DAC->DACDAT = lround(voltage * GAIN);
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/encoder.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/encoder.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/encoder.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,189 @@
+/***************************************************************************//**
+ * @file encoder.cpp
+ * @brief Implementation of encoder.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+
+void encoder_open(void)
+{
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON1_MSK) | GP1CON_CON1_GPIOIRQ4;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON5_MSK) | GP1CON_CON5_GPIOIRQ5;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON7_MSK) | GP1CON_CON7_GPIOIRQ7;
+
+ GP1OCE_OCE1_BBA = false;
+ GP1OCE_OCE5_BBA = false;
+ GP1OCE_OCE7_BBA = false;
+
+ GP1PUL_PUL1_BBA = true;
+ GP1PUL_PUL5_BBA = true;
+ GP1PUL_PUL7_BBA = true;
+
+ GP1OEN_OEN1_BBA = false;
+ GP1OEN_OEN5_BBA = false;
+ GP1OEN_OEN7_BBA = false;
+
+ pADI_INTERRUPT->EI1CFG = (pADI_INTERRUPT->EI1CFG & ~EI1CFG_IRQ4MDE_MSK) |
+ EI1CFG_IRQ4MDE_RISEORFALL;
+ pADI_INTERRUPT->EI1CFG = (pADI_INTERRUPT->EI1CFG & ~EI1CFG_IRQ5MDE_MSK) |
+ EI1CFG_IRQ5MDE_RISEORFALL;
+ pADI_INTERRUPT->EI1CFG = (pADI_INTERRUPT->EI1CFG & ~EI1CFG_IRQ7MDE_MSK) |
+ EI1CFG_IRQ7MDE_RISEORFALL;
+
+ EI1CFG_IRQ4EN_BBA = true;
+ EI1CFG_IRQ5EN_BBA = true;
+ EI1CFG_IRQ7EN_BBA = true;
+
+ NVIC_SetPriority(EINT4_IRQn, NVIC_EncodePriority(6, 1, 2));
+ NVIC_SetPriority(EINT5_IRQn, NVIC_EncodePriority(6, 1, 2));
+ NVIC_SetPriority(EINT7_IRQn, NVIC_EncodePriority(6, 1, 2));
+
+ NVIC_EnableIRQ(EINT4_IRQn);
+ NVIC_EnableIRQ(EINT5_IRQn);
+ NVIC_EnableIRQ(EINT7_IRQn);
+}
+
+static int debounce(int argc, char *argv[])
+{
+ app msg;
+ msg.argc = 0;
+ msg.argv = new char*;
+
+ if (GP1IN_IN7_BBA) {
+ msg.fun = on_button_up;
+ } else {
+
+ msg.fun = on_button_down;
+ }
+
+ post_message(msg);
+
+ EI1CFG_IRQ7EN_BBA = true;
+}
+
+static int on_int7(int argc, char *argv[])
+{
+ timer t;
+ t.time = 50;
+ t.timer_app.argc = 0;
+ t.timer_app.fun = debounce;
+ t.timer_app.argv = new char*;
+
+ new_timer(t);
+}
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+static int in1, in5, count;
+
+void Ext_Int4_Handler(void) //encoder
+{
+ EI1CFG_IRQ4EN_BBA = false;
+
+ if (count < 3) {
+ ++count;
+ } else {
+ count = 0;
+
+ app msg;
+ msg.argc = 0;
+
+ if (GP1IN_IN5_BBA == in1) {
+ msg.fun = on_cw;
+ } else {
+ msg.fun = on_ccw;
+ }
+
+ ts_post_message(msg);
+ }
+
+ in5 = GP1IN_IN5_BBA;
+
+ EICLR_IRQ4_BBA = true;
+ EI1CFG_IRQ5EN_BBA = true;
+ __DSB();
+}
+
+void Ext_Int5_Handler(void) //encoder
+{
+ EI1CFG_IRQ5EN_BBA = false;
+
+ if (count < 3) {
+ ++count;
+ } else {
+ count = 0;
+
+ app msg;
+ msg.argc = 0;
+
+ if (GP1IN_IN1_BBA == in5) {
+ msg.fun = on_ccw;
+ } else {
+ msg.fun = on_cw;
+ }
+
+ ts_post_message(msg);
+ }
+
+ in1 = GP1IN_IN1_BBA;
+
+ EICLR_IRQ5_BBA = true;
+ EI1CFG_IRQ4EN_BBA = true;
+ __DSB();
+}
+
+void Ext_Int7_Handler(void) //encoder button
+{
+ EI1CFG_IRQ7EN_BBA = false;
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = on_int7;
+
+ ts_post_message(msg);
+
+ EICLR_IRQ7_BBA = true;
+ __DSB();
+}
+#ifdef __cplusplus
+}
+#endif
Index: ADuCM360_demo_cn0359/src/hal/drivers/flash.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/flash.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/flash.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,165 @@
+/***************************************************************************//**
+ * @file flash.cpp
+ * @brief Implementation of flash.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+
+static int position = 0;
+
+//flash_disk exclusive in his own flash sector
+static const struct flash_file flash_disk __attribute__ ((aligned (512),
+ section (".flash_disk")));
+
+static const char * const p_flash_disk = (const char *) (&flash_disk);
+
+ssize_t flash_write(const void *buf, size_t count)
+{
+ if (position >= sizeof(flash_file)) {
+ errno = ENOSPC;
+ return -1;
+ }
+
+ int start_page = position >> 9;
+
+ int end_page = ((position + count) < sizeof(flash_file) ?
+ (position + count - 1) : (sizeof(flash_file) - 1)) >> 9;
+
+ int remain_bytes = count;
+ const char *remain_buf;
+ remain_buf = (const char *) buf;
+
+ for (int i = start_page; i <= end_page; ++i) {
+ char buffer[512] __attribute__ ((aligned (sizeof(unsigned long))));
+
+ memcpy(buffer, &p_flash_disk[i << 9], 512);
+
+ pADI_FEE->FEEADR0H = (((int) (&p_flash_disk[i << 9]) >> 16) & 0x1);
+ pADI_FEE->FEEADR0L = ((int) (&p_flash_disk[i << 9]) & 0xfe00);
+
+ pADI_FEE->FEEKEY = FEEKEY_VALUE_USERKEY1;
+ pADI_FEE->FEEKEY = FEEKEY_VALUE_USERKEY2;
+
+ pADI_FEE->FEECMD = FEECMD_CMD_ERASEPAGE; // erase
+ while (FEESTA_CMDBUSY_BBA)
+ ;
+
+ int write_count = (position & 0x1ff) + remain_bytes > 512 ? 512 -
+ (position & 0x1ff) : remain_bytes;
+
+ memcpy(&buffer[position & 0x1ff], remain_buf, write_count);
+
+ FEECON0_WREN_BBA = true;
+
+ unsigned long *p_src, *p_dst;
+ p_src = (unsigned long *) buffer;
+ p_dst = (unsigned long *) (&p_flash_disk[i << 9]);
+
+ for (int i = 0; i < 128; ++i) {
+ while (FEESTA_WRBUSY_BBA)
+ ;
+ p_dst[i] = p_src[i];
+ }
+
+ FEECON0_WREN_BBA = false;
+
+ position += write_count;
+ remain_bytes -= write_count;
+ remain_buf += write_count;
+ }
+
+ return (count - remain_bytes);
+}
+
+ssize_t flash_read(void *buf, size_t count)
+{
+ if ((position + count) > sizeof(flash_file)) {
+ count = sizeof(flash_file) - position;
+ }
+
+ memcpy(buf, &p_flash_disk[position], count);
+
+ position += count;
+
+ return count;
+}
+
+off_t flash_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(flash_file) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = offset;
+ }
+
+ break;
+ case SEEK_CUR:
+ if ((position + offset) > sizeof(flash_file) || (position + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position += offset;
+ }
+ break;
+ case SEEK_END:
+ if (offset > 0 || sizeof(flash_file) + offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = sizeof(flash_file) + offset;
+ }
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ break;
+ }
+
+ return position;
+}
+
+void flash_open(void)
+{
+
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/lcd.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/lcd.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/lcd.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,584 @@
+/***************************************************************************//**
+ * @file lcd.cpp
+ * @brief Implementation of lcd.cpp
+ * @author Rbolboac (ramona.bolboaca@analog.com)
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define LCD_REVERSE 0x1
+#define LCD_BLINK 0x2
+
+#define LCD_BLINK_INTERVAL 500
+
+#define FB_FLUSH_DELAY 30
+
+uint8_t framebuffer_memory[4][128]; //512 bytes
+
+static uint8_t lcd_tty_buffer[128];
+
+static int tty_cursor = 0;
+
+static bool blink_on = false;
+
+static const uint8_t ASC16[256][8] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x00},
+ {0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x00},
+ {0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x00},
+ {0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x00},
+ {0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x00},
+ {0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00},
+ {0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0x00},
+ {0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00},
+ {0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0x00},
+ {0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x00},
+ {0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x00},
+ {0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x00},
+ {0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x00},
+ {0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x00},
+ {0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x00},
+ {0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x00},
+ {0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x00},
+ {0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x00},
+ {0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x00},
+ {0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00},
+ {0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x00},
+ {0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00},
+ {0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x00},
+ {0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, 0x00},
+ {0x00, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x00},
+ {0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x00},
+ {0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x00},
+ {0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00},
+ {0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x00},
+ {0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x00},
+ {0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00},
+ {0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00},
+ {0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x00},
+ {0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x00},
+ {0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00},
+ {0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x00},
+ {0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x00},
+ {0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00},
+ {0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x00},
+ {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00},
+ {0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00},
+ {0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00},
+ {0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x00},
+ {0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x00},
+ {0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x00},
+ {0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x00},
+ {0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x00},
+ {0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x00},
+ {0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x00},
+ {0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00},
+ {0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x00},
+ {0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x00},
+ {0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x00},
+ {0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x00},
+ {0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00},
+ {0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x00},
+ {0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00},
+ {0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x00},
+ {0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x00},
+ {0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x00},
+ {0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x00},
+ {0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, 0x00},
+ {0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00},
+ {0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
+ {0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x00},
+ {0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x00},
+ {0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00},
+ {0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00},
+ {0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x00},
+ {0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x00},
+ {0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00},
+ {0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x00},
+ {0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x00},
+ {0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x00},
+ {0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x00},
+ {0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x00},
+ {0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x00},
+ {0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00},
+ {0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x00},
+ {0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00},
+ {0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x00},
+ {0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
+ {0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x00},
+ {0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x00},
+ {0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x00},
+ {0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, 0x00},
+ {0x00, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x00},
+ {0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00},
+ {0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x00},
+ {0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x00},
+ {0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00},
+ {0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x00},
+ {0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x00},
+ {0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x00},
+ {0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x00},
+ {0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00},
+ {0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00},
+ {0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x00},
+ {0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x00},
+ {0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x00},
+ {0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x00},
+ {0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x00},
+ {0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x00},
+ {0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x00},
+ {0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x00},
+ {0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00},
+ {0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x00},
+ {0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00},
+ {0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x00},
+ {0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x00},
+ {0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00},
+ {0x00, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x00, 0x00},
+ {0x00, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x00, 0x00},
+ {0x00, 0x38, 0x54, 0x54, 0x55, 0x59, 0x00, 0x00},
+ {0x00, 0x21, 0x55, 0x55, 0x79, 0x41, 0x00, 0x00},
+ {0x00, 0x22, 0x54, 0x54, 0x78, 0x42, 0x00, 0x00},
+ {0x00, 0x21, 0x55, 0x54, 0x78, 0x40, 0x00, 0x00},
+ {0x00, 0x20, 0x54, 0x55, 0x79, 0x40, 0x00, 0x00},
+ {0x00, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x00, 0x00},
+ {0x00, 0x39, 0x55, 0x55, 0x55, 0x59, 0x00, 0x00},
+ {0x00, 0x39, 0x54, 0x54, 0x54, 0x59, 0x00, 0x00},
+ {0x00, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x00},
+ {0x00, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x00},
+ {0x00, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x00, 0x00},
+ {0x00, 0x7D, 0x12, 0x11, 0x12, 0x7D, 0x00, 0x00},
+ {0x00, 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x00, 0x00},
+ {0x00, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x00, 0x00},
+ {0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x00, 0x00},
+ {0x00, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x00, 0x00},
+ {0x00, 0x32, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00},
+ {0x00, 0x3A, 0x44, 0x44, 0x44, 0x3A, 0x00, 0x00},
+ {0x00, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x00, 0x00},
+ {0x00, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x00, 0x00},
+ {0x00, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x00},
+ {0x00, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x00, 0x00},
+ {0x00, 0x3D, 0x42, 0x42, 0x42, 0x3D, 0x00, 0x00},
+ {0x00, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x00, 0x00},
+ {0x00, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x00, 0x00},
+ {0x00, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x00, 0x00},
+ {0x00, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0x00, 0x00},
+ {0x00, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0x00, 0x00},
+ {0x00, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x00, 0x00},
+ {0x00, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x00, 0x00},
+ {0x00, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x00, 0x00},
+ {0x00, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x00},
+ {0x00, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x00, 0x00},
+ {0x00, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x00, 0x00},
+ {0x00, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x00, 0x00},
+ {0x00, 0x26, 0x29, 0x29, 0x29, 0x26, 0x00, 0x00},
+ {0x00, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x00, 0x00},
+ {0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00},
+ {0x00, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00},
+ {0x00, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x00, 0x00},
+ {0x00, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x00, 0x00},
+ {0x00, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x00, 0x00},
+ {0x00, 0x55, 0x00, 0x55, 0x00, 0x55, 0x00, 0x00},
+ {0x00, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00},
+ {0x00, 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x17, 0x10, 0x17, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0x17, 0x14, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x00, 0x00},
+ {0x00, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x00, 0x00},
+ {0x00, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x00, 0x00},
+ {0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},
+ {0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00},
+ {0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00},
+ {0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00},
+ {0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x00, 0x00},
+ {0x00, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, 0x00, 0x00},
+ {0x00, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x00, 0x00},
+ {0x00, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x00, 0x00},
+ {0x00, 0x63, 0x55, 0x49, 0x41, 0x63, 0x00, 0x00},
+ {0x00, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x00, 0x00},
+ {0x00, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x00, 0x00},
+ {0x00, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x00, 0x00},
+ {0x00, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x00, 0x00},
+ {0x00, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x00, 0x00},
+ {0x00, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x00, 0x00},
+ {0x00, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x00, 0x00},
+ {0x00, 0x30, 0x48, 0x78, 0x48, 0x30, 0x00, 0x00},
+ {0x00, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x00, 0x00},
+ {0x00, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00},
+ {0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x00, 0x00},
+ {0x00, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, 0x00},
+ {0x00, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x00, 0x00},
+ {0x00, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x00, 0x00},
+ {0x00, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xFF, 0x01, 0x03, 0x00, 0x00},
+ {0x00, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x00, 0x00},
+ {0x00, 0x36, 0x12, 0x36, 0x24, 0x36, 0x00, 0x00},
+ {0x00, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00},
+ {0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x00},
+ {0x00, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x00},
+ {0x00, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x00},
+ {0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+void static lcd_write_control(const unsigned char &data)
+{
+ GP0CLR_CLR4_BBA = true;
+ pADI_SPI1->SPITX = data;
+ while ((pADI_SPI1->SPISTA & SPI1STA_TXFSTA_MSK) != SPI1STA_TXFSTA_EMPTY)
+ ;
+}
+
+void static lcd_write_image(const unsigned char data)
+{
+ GP0SET_SET4_BBA = true;
+ pADI_SPI1->SPITX = data;
+ while ((pADI_SPI1->SPISTA & SPI1STA_TXFSTA_MSK) != SPI1STA_TXFSTA_EMPTY)
+ ;
+}
+
+int send_spi_image(int argc, char *argv[])
+{
+ unsigned char page = 0xB0;
+ // lcd_write_control(0xAE); // Display OFF
+ lcd_write_control(0x40); // Display start address + 0x40
+ for (unsigned int i = 0; i < 4; i++) {
+ // 32pixel display / 8 pixels per page = 4 pages
+ lcd_write_control(page); // send page address
+ lcd_write_control(0x10); // column address upper 4 bits + 0x10
+ lcd_write_control(0x00); // column address lower 4 bits + 0x00
+ for (unsigned int j = 0; j < 128; j++) {
+ // 128 columns wide
+ // todo
+ lcd_write_image(framebuffer_memory[i][j]); // send picture data
+ }
+ page++; // after 128 columns, go to next page
+ }
+ // lcd_write_control(0xAF); // Display on
+ return 0;
+}
+
+void static lcd_framebuffer_flush(void)
+{
+ timer t;
+ t.time = FB_FLUSH_DELAY;
+ t.timer_app.fun = send_spi_image;
+ t.timer_app.argc = 0;
+ t.timer_app.argv = new char*;
+ update_timer(t);
+}
+
+/*
+ * lcd tty buffer size 128
+ * address 0~63 for character display
+ * address 64~127 for reverse and blink control
+ *
+ * character register address map to LCD position
+ * 8 x 16 pixel for each position
+ * ┌───┬───┬──────┬───┬───┐
+ * │ 0 │ 1 │......│14 │15 │
+ * ├───┼───┼──────┼───┼───┤
+ * │16 │17 │......│30 │31 │
+ * ├───┼───┼──────┼───┼───┤
+ * │32 │33 │......│46 │47 │
+ * ├───┼───┼──────┼───┼───┤
+ * │48 │49 │......│62 │63 │
+ * └───┴───┴──────┴───┴───┘
+ *
+ * reverse and blink register address map to LCD position
+ * 8 x 16 pixel for each position
+ * ┌───┬───┬──────┬───┬───┐
+ * │64 │65 │......│78 │79 │
+ * ├───┼───┼──────┼───┼───┤
+ * │80 │81 │......│94 │95 │
+ * ├───┼───┼──────┼───┼───┤
+ * │96 │97 │......│110│111│
+ * ├───┼───┼──────┼───┼───┤
+ * │112│113│......│126│127│
+ * └───┴───┴──────┴───┴───┘
+ *
+ * reverse and blink register bit definition
+ * B: 1 blink, 0 gaze
+ * R: 1 reverse, 0 normal
+ * others: null
+ * ┌─┬─┬─┬─┬─┬─┬─┬─┐
+ * │7│6│5│4│3│2│B│R│
+ * └─┴─┴─┴─┴─┴─┴─┴─┘
+ */
+
+ssize_t lcd_tty_write(const void *buf, size_t count)
+{
+ if ((tty_cursor + count) > sizeof(lcd_tty_buffer)) {
+ count = sizeof(lcd_tty_buffer) - tty_cursor;
+ }
+
+ memcpy(&lcd_tty_buffer[tty_cursor], buf, count);
+
+ for (int j = 0; j < count; ++j) {
+ int cursor = (tty_cursor + j) % 64;
+ int y = cursor >> 4; // page
+ int x = (cursor & 0xf) << 3; // segment
+
+ for (int i = 0; i < 8; i++)
+ framebuffer_memory[y][x+i] = ASC16[lcd_tty_buffer[cursor]][i];
+ }
+
+ lcd_framebuffer_flush();
+
+ tty_cursor += count;
+
+ return count;
+}
+
+int static lcd_blinking(int argc, char *argv[])
+{
+ blink_on = !blink_on;
+
+ for (int cursor = 0; cursor < 64; ++cursor) {
+ int y = cursor >> 4; // page
+ int x = (cursor & 0xf) << 3; // segment
+ if ((((lcd_tty_buffer[cursor + 64] & LCD_BLINK) == LCD_BLINK) && blink_on) ||
+ (((lcd_tty_buffer[cursor + 64] & LCD_REVERSE) == LCD_REVERSE))) {
+ for (int i = 0; i < 8; i++)
+ framebuffer_memory[y][x+i] = ~ASC16[lcd_tty_buffer[cursor]][i];
+
+ } else {
+ for (int i = 0; i < 8; i++)
+ framebuffer_memory[y][x+i] = ASC16[lcd_tty_buffer[cursor]][i];
+ }
+ }
+
+ lcd_framebuffer_flush();
+
+ timer t;
+ t.time = LCD_BLINK_INTERVAL / 2;
+ t.timer_app.fun = lcd_blinking;
+ t.timer_app.argc = 0;
+ t.timer_app.argv = new char*;
+
+ update_timer(t);
+
+ return 0;
+}
+
+off_t lcd_tty_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(lcd_tty_buffer) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ tty_cursor = offset;
+ break;
+ case SEEK_CUR:
+ if ((tty_cursor + offset) > sizeof(lcd_tty_buffer)
+ || (tty_cursor + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ tty_cursor += offset;
+ break;
+ case SEEK_END:
+ if (offset > 0 || (sizeof(lcd_tty_buffer) + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ tty_cursor = sizeof(lcd_tty_buffer) + offset;
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ }
+
+ return tty_cursor;
+}
+
+void init_lcd(void)
+{
+ flash_file * p_flash_file;
+ decltype(flash_file::brightness) brightness;
+
+ lcd_write_control(0xA0); // ADC select
+ lcd_write_control(0xAE); // Display OFF
+ lcd_write_control(0xC8); // COM direction scan
+ lcd_write_control(0xA2); // LCD bias set
+ lcd_write_control(0x2F); // Power Control set
+ lcd_write_control(0x21); // Resistor Ratio Set
+
+ fseek(p_flash, (int) (&p_flash_file->brightness) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&brightness, sizeof(flash_file::brightness), 1, p_flash);
+
+ lcd_write_control(
+ 0x81); // Electronic Volume Command (set contrast) Double Btye: 1 of 2
+ lcd_write_control(
+ brightness &
+ 0xFF); // Electronic Volume value (contrast value) Double Byte: 2 of 2
+ lcd_write_control(0xAF); // Display ON
+}
+
+void clear_lcd(void)
+{
+ unsigned char page = 0xB0;
+ // lcd_write_control(0xAE); // Display OFF
+ lcd_write_control(0x40); // Display start address + 0x40
+ for (unsigned int i = 0; i < 4; i++) {
+ // 32pixel display / 8 pixels per page = 4 pages
+ lcd_write_control(page); // send page address
+
+ // Sets the most significant 4 bits of the display RAM column address.
+ lcd_write_control(0x10); // column address upper 4 bits + 0x10
+ // Sets the least significant 4 bits of the display RAM column address.
+ lcd_write_control(0x00); // column address lower 4 bits + 0x00
+ for (unsigned int j = 0; j < 128; j++) {
+ // 128 columns wide
+ lcd_write_image(0x00); // send picture data
+ }
+ page++; // after 128 columns, go to next page
+ }
+ lcd_write_control(0xAF); // Display on
+}
+
+void lcd_open(void)
+{
+
+ CLKDIS_DISSPI1CLK_BBA = false;
+ pADI_CLKCTL->CLKCON1 = (pADI_CLKCTL->CLKCON1 & ~CLKCON1_SPI1CD_MSK) |
+ CLKCON1_SPI1CD_DIV1;
+
+// according schematic
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON1_MSK) | GP0CON_CON1_SPI1SCLK;
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON2_MSK) | GP0CON_CON2_SPI1MOSI;
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON3_MSK) | GP0CON_CON3_SPI1CS0;
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON4_MSK) | GP0CON_CON4_GPIO;
+
+ GP0OCE_OCE1_BBA = false;
+ GP0OCE_OCE2_BBA = false;
+ GP0OCE_OCE3_BBA = false;
+ GP0OCE_OCE4_BBA = false;
+
+ GP0OEN_OEN1_BBA = true;
+ GP0OEN_OEN2_BBA = true;
+ GP0OEN_OEN3_BBA = true;
+ GP0OEN_OEN4_BBA = true;
+
+ GP0PUL_PUL1_BBA = true;
+ GP0PUL_PUL2_BBA = true;
+ GP0PUL_PUL3_BBA = true;
+ GP0PUL_PUL4_BBA = true;
+
+ pADI_SPI1->SPIDIV = SPI1DIV_BCRST_DIS | (SPI1DIV_DIV_MSK & 0x0);
+
+ pADI_SPI1->SPICON = SPI1CON_MOD_TX4RX4 | SPI1CON_TFLUSH_DIS | SPI1CON_RFLUSH_EN
+ | SPI1CON_CON_EN
+ | SPI1CON_LOOPBACK_DIS | SPI1CON_SOEN_DIS | SPI1CON_RXOF_EN | SPI1CON_ZEN_DIS |
+ SPI1CON_TIM_TXWR
+ | SPI1CON_LSB_DIS | SPI1CON_WOM_DIS | SPI1CON_CPOL_HIGH |
+ SPI1CON_CPHA_SAMPLETRAILING
+ | SPI1CON_MASEN_EN | SPI1CON_ENABLE_EN;
+
+ init_lcd();
+ clear_lcd();
+ lcd_tty_lseek(0, SEEK_SET);
+
+ lcd_blinking(0, nullptr);
+}
Index: ADuCM360_demo_cn0359/src/hal/drivers/pwm.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/pwm.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/pwm.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,258 @@
+/***************************************************************************//**
+ * @file pwm.cpp
+ * @brief Implementation of pwm.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static int position = 0;
+
+static pwm_file pwm;
+
+off_t pwm_lseek(off_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > sizeof(pwm_file) || offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = offset;
+ }
+ break;
+ case SEEK_CUR:
+ if ((position + offset) > sizeof(pwm_file) || (position + offset) < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position += offset;
+ }
+ break;
+ case SEEK_END:
+ if (offset > 0 || sizeof(pwm_file) + offset < 0) {
+ errno = EINVAL;
+ return -1;
+ } else {
+ position = sizeof(pwm_file) + offset;
+ }
+ break;
+ default:
+ errno = ENXIO;
+ return -1;
+ break;
+ }
+
+ return position;
+}
+
+/* UCLK UCLK
+ * PWM frequency F = ──────────────────────── = ──────
+ * 2^^PRE * 2 * (LEN + 1) DIV
+ * DIV = 2^^(PRE + 1) * (LEN + 1)
+ * DIV / 2^^(PRE + 1) <= 0x10000
+ *
+ */
+static void pwm_update(const pwm_file &file)
+{
+ pwm = file;
+
+ float div = SystemCoreClock / file.freq;
+
+ assert(div >= 8);
+
+ int pre = 0;
+
+ while (div / (0x2 << pre) > 0x10000) {
+ ++pre;
+ }
+
+ assert(pre <= 0x7);
+
+ int len = lround(div / (0x2 << pre));
+
+ PWMCON0_ENABLE_BBA = false;
+
+ pADI_PWM->PWMCON0 = (pADI_PWM->PWMCON0 & ~PWMCON0_PRE_MSK) | (pre << 6);
+
+ pADI_PWM->PWM0LEN = pADI_PWM->PWM1LEN = pADI_PWM->PWM2LEN = len - 1;
+
+ pADI_PWM->PWM0COM2 = pADI_PWM->PWM0LEN >> 1; //pwm1 50% duty
+
+ pADI_PWM->PWM1COM1 = lround(pADI_PWM->PWM0COM2 * file.setup / 100.f); //setup
+ pADI_PWM->PWM1COM0 = pADI_PWM->PWM0COM2 - lround(pADI_PWM->PWM0COM2 *
+ file.hold / 100.f); //hold
+
+ pADI_PWM->PWM2COM1 = pADI_PWM->PWM0COM2 + pADI_PWM->PWM1COM1; //setup
+ pADI_PWM->PWM2COM0 = pADI_PWM->PWM2LEN - (pADI_PWM->PWM0COM2 -
+ pADI_PWM->PWM1COM0); //hold
+
+ PWMCON0_PWM1INV_BBA = file.inv;
+
+ PWMCON0_SYNC_BBA = true;
+
+ PWMCON0_ENABLE_BBA = true;
+
+ GP1TGL_TGL2_BBA = true;
+
+ GP1TGL_TGL2_BBA = true;
+
+ PWMCON0_ENABLE_BBA = false;
+
+ PWMCON0_SYNC_BBA = false;
+
+ PWMCON0_ENABLE_BBA = true;
+
+ PWMCON0_LCOMP_BBA = true;
+}
+
+ssize_t pwm_read(void *buf, size_t count)
+{
+ if ((position + count) > sizeof(pwm_file)) {
+ count = sizeof(pwm_file) - position;
+ }
+
+ memcpy(buf, (char*) (&pwm) + position, count);
+
+ position += count;
+
+ return count;
+}
+
+ssize_t pwm_write(const void *buf, size_t count)
+{
+ pwm_file file = pwm;
+
+ if ((position + count) > sizeof(pwm_file)) {
+ count = sizeof(pwm_file) - position;
+ }
+
+ memcpy((char*) (&file) + position, buf, count);
+
+ position += count;
+
+ if (file.freq <= configure_file.max_freq && file.freq >= configure_file.min_freq
+ && file.setup <= configure_file.max_setup
+ && file.setup >= configure_file.min_setup
+ && file.hold <= configure_file.max_hold
+ && file.hold >= configure_file.min_hold) {
+ pwm_update(file);
+ }
+
+ return count;
+}
+
+void pwm_open(void)
+{
+ CLKDIS_DISPWMCLK_BBA = false;
+ pADI_CLKCTL->CLKCON1 = (pADI_CLKCTL->CLKCON1 & ~CLKCON1_PWMCD_MSK) |
+ CLKCON1_PWMCD_DIV1;
+
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON0_MSK) | GP1CON_CON0_PWMSYNC;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON3_MSK) | GP1CON_CON3_PWM1;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON4_MSK) | GP1CON_CON4_PWM2;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON6_MSK) | GP1CON_CON6_PWM4;
+ pADI_GP1->GPCON = (pADI_GP1->GPCON & ~GP1CON_CON2_MSK) | GP1CON_CON2_GPIO;
+
+ GP1OCE_OCE0_BBA = false;
+ GP1OCE_OCE3_BBA = false;
+ GP1OCE_OCE4_BBA = false;
+ GP1OCE_OCE6_BBA = false;
+ GP1OCE_OCE2_BBA = false;
+
+ GP1OEN_OEN0_BBA = true;
+ GP1OEN_OEN3_BBA = true;
+ GP1OEN_OEN4_BBA = true;
+ GP1OEN_OEN6_BBA = true;
+ GP1OEN_OEN2_BBA = true;
+
+ GP1PUL_PUL0_BBA = true;
+ GP1PUL_PUL3_BBA = true;
+ GP1PUL_PUL4_BBA = true;
+ GP1PUL_PUL6_BBA = true;
+ GP1PUL_PUL2_BBA = true;
+
+ PWMCON0_ENABLE_BBA = false;
+
+ pADI_PWM->PWMCON0 = PWMCON0_SYNC_DIS | PWMCON0_PWM5INV_DIS | PWMCON0_PWM3INV_DIS
+ | PWMCON0_PWM1INV_DIS
+ | PWMCON0_PWMIEN_DIS | PWMCON0_ENA_DIS | PWMCON0_POINV_DIS | PWMCON0_HOFF_DIS |
+ PWMCON0_LCOMP_DIS
+ | PWMCON0_DIR_DIS | PWMCON0_MOD_DIS | PWMCON0_ENABLE_DIS;
+
+ PWMCON1_TRIPEN_BBA = false;
+
+ pADI_PWM->PWM0COM0 = 0x0; //pwm0 always high
+ pADI_PWM->PWM0COM1 = 0xffff; //pwm0 always high
+ pADI_PWM->PWM1COM2 = 0x0; //pwm3 not use
+ pADI_PWM->PWM2COM2 = 0x0; //pwm5 not use
+
+ flash_file * p_flash_file;
+
+ decltype(flash_file::frequency) frequency;
+
+ fseek(p_flash, (int) (&p_flash_file->frequency) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&frequency, sizeof(flash_file::frequency), 1, p_flash);
+
+ pwm.freq = frequency;
+
+ decltype(flash_file::setup) setup;
+
+ fseek(p_flash, (int) (&p_flash_file->setup) - (int) (p_flash_file), SEEK_SET);
+ fread(&setup, sizeof(flash_file::setup), 1, p_flash);
+
+ pwm.setup = setup;
+
+ decltype(flash_file::hold) hold;
+
+ fseek(p_flash, (int) (&p_flash_file->hold) - (int) (p_flash_file), SEEK_SET);
+ fread(&hold, sizeof(flash_file::hold), 1, p_flash);
+
+ pwm.hold = hold;
+
+ pwm.inv = false;
+
+ pwm_update(pwm);
+}
+
Index: ADuCM360_demo_cn0359/src/hal/drivers/uart.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/drivers/uart.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/drivers/uart.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,285 @@
+/***************************************************************************//**
+ * @file uart.cpp
+ * @brief Implementation of uart.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static char tx_fifo[512];
+static volatile int tx_fifo_front = 0, tx_fifo_back = 0;
+
+static char rx_pingpong[2][128];
+static volatile int rd_count[2] = {0, 0};
+static volatile int rx_length[2] = {0, 0};
+static volatile char * volatile p_rx_buf = rx_pingpong[0];
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+float uart_baud(float baud)
+{
+ /*
+ * k = 1000, M = 1000k
+ *
+ * UCLK/DIV 16M/1 500k 1024M
+ * baud rate = ──────────────────────── = ──────────────────────── = ─────────────────── = ───────────────────
+ * 2*(M+N/2048)*16*COMDIV 2*16*(M+N/2048)*COMDIV (M+N/2048)*COMDIV (2048*M+N)*COMDIV
+ *
+ * set F = (2048*M+N), M = 1~3, N = 0~2047, F = 2048~8191
+ *
+ * 1024M 1024M
+ * baud rate = ────────── = ───────
+ * F*COMDIV UDIV
+ */
+
+ assert(baud >= 2 && baud <= 500000);
+
+ int high_udiv = ceil(1.024e9f / baud), low_udiv = floor(1.024e9f / baud),
+ udiv = lround(1.024e9f / baud);
+
+ int min_comdiv = ceil(udiv / 8191.f), max_comdiv = floor(udiv / 2048.f);
+
+ while (true) {
+ for (int comdiv = min_comdiv; comdiv <= max_comdiv; ++comdiv) {
+ if (udiv % comdiv == 0) {
+ int DIVM, DIVN;
+
+ DIVM = floor((udiv / comdiv) / 2048);
+ DIVN = (udiv / comdiv) % 2048;
+
+ pADI_UART->COMDIV = comdiv;
+
+ pADI_UART->COMFBR = COMFBR_ENABLE_EN | (DIVM << 11) | DIVN;
+
+ return (1.024e9f / ((2048 * DIVM + DIVN) * comdiv));
+ }
+ }
+
+// no matched udiv, search closest value
+ if (udiv == high_udiv) {
+// max udiv = (2048 * 3 + 2047) * 65535
+ if (high_udiv < 536797185) {
+ ++high_udiv;
+ }
+
+ udiv = low_udiv;
+ } else {
+// min udiv = (2048 * 1 + 0) * 1
+ if (low_udiv > 2048) {
+ --low_udiv;
+ }
+
+ udiv = high_udiv;
+ }
+
+ min_comdiv = ceil(udiv / 8191.f);
+ max_comdiv = floor(udiv / 2048.f);
+ }
+}
+
+void uart_open(void)
+{
+ CLKDIS_DISUARTCLK_BBA = false;
+ pADI_CLKCTL->CLKCON1 = (pADI_CLKCTL->CLKCON1 & ~CLKCON1_UARTCD_MSK) |
+ CLKCON1_UARTCD_DIV1;
+
+ // schematic
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON6_MSK) | GP0CON_CON6_UARTRXD;
+ pADI_GP0->GPCON = (pADI_GP0->GPCON & ~GP0CON_CON7_MSK) | GP0CON_CON7_UARTTXD;
+
+ GP0OCE_OCE6_BBA = false;
+ GP0OCE_OCE7_BBA = false;
+
+ GP0OEN_OEN6_BBA = false;
+ GP0OEN_OEN7_BBA = true;
+
+ GP0PUL_PUL6_BBA = true;
+ GP0PUL_PUL7_BBA = true;
+
+ pADI_UART->COMCON = COMCON_DISABLE_DIS;
+
+ pADI_UART->COMLCR = COMLCR_BRK_DIS | COMLCR_SP_DIS | COMLCR_EPS_DIS |
+ COMLCR_PEN_DIS | COMLCR_STOP_EN
+ | COMLCR_WLS_8BITS;
+
+ pADI_UART->COMMCR = COMMCR_LOOPBACK_DIS | COMMCR_OUT1_DIS | COMMCR_OUT2_DIS |
+ COMMCR_RTS_DIS | COMMCR_DTR_DIS;
+
+ flash_file * p_flash_file;
+ decltype(flash_file::baud_rate) baud_rate;
+
+ fseek(p_flash, (int) (&p_flash_file->baud_rate) - (int) (p_flash_file),
+ SEEK_SET);
+ fread(&baud_rate, sizeof(flash_file::baud_rate), 1, p_flash);
+
+ uart_baud(baud_rate);
+
+ pADI_UART->COMIEN = COMIEN_EDMAR_DIS | COMIEN_EDMAT_DIS | COMIEN_EDSSI_DIS |
+ COMIEN_ELSI_DIS | COMIEN_ETBEI_EN
+ | COMIEN_ERBFI_EN;
+
+ NVIC_SetPriority(UART_IRQn, NVIC_EncodePriority(6, 1, 2));
+
+ NVIC_EnableIRQ(UART_IRQn);
+}
+
+ssize_t uart_read(void *buf, size_t count)
+{
+ if (p_rx_buf == rx_pingpong[0]) {
+ if (rd_count[1] + count > rx_length[1]) {
+ count = rx_length[1] - rd_count[1];
+ }
+
+ memcpy(buf, &rx_pingpong[1][rd_count[1]], count);
+
+ rd_count[1] += count;
+ } else {
+ if (rd_count[0] + count > rx_length[0]) {
+ count = rx_length[0] - rd_count[0];
+ }
+
+ memcpy(buf, &rx_pingpong[0][rd_count[0]], count);
+
+ rd_count[0] += count;
+ }
+
+ return count;
+}
+
+ssize_t uart_write(const void *buf, size_t count)
+{
+ for (int i = 0; i < count; ++i) {
+ tx_fifo[tx_fifo_back] = ((char*) (buf))[i];
+
+ if (tx_fifo_back == SIZE(tx_fifo) - 1) {
+ tx_fifo_back = 0;
+ } else {
+ ++tx_fifo_back;
+ }
+
+ assert(tx_fifo_back != tx_fifo_front); // overflow
+ }
+
+ if (COMLSR_TEMT_BBA) {
+ char c = tx_fifo[tx_fifo_front];
+
+ if (tx_fifo_front == SIZE(tx_fifo) - 1) {
+ tx_fifo_front = 0;
+ } else {
+ ++tx_fifo_front;
+ }
+
+ pADI_UART->COMTX = c;
+ }
+
+ return count;
+}
+
+static int tx_empty(int argc, char *argv[])
+{
+ if (!COMLSR_TEMT_BBA) {
+ app msg;
+ msg.argc = 0;
+ msg.fun = tx_empty;
+ msg.argv = new char*;
+ post_message(msg);
+ }
+}
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+void UART_Int_Handler(void)
+{
+ if ((pADI_UART->COMIIR & COMIIR_STA_TXBUFEMPTY) == COMIIR_STA_TXBUFEMPTY) {
+ if (tx_fifo_front != tx_fifo_back) {
+ pADI_UART->COMTX = tx_fifo[tx_fifo_front];
+
+ if (tx_fifo_front == SIZE(tx_fifo) - 1) {
+ tx_fifo_front = 0;
+ } else {
+ ++tx_fifo_front;
+ }
+ } else {
+ app msg;
+ msg.argc = 0;
+ msg.fun = tx_empty;
+ ts_post_message(msg);
+ }
+ }
+
+ if ((pADI_UART->COMIIR & COMIIR_STA_RXBUFFULL) == COMIIR_STA_RXBUFFULL) {
+ if (p_rx_buf == rx_pingpong[0]) {
+ if (rx_length[0] < SIZE(rx_pingpong[0])) {
+ p_rx_buf[rx_length[0]++] = pADI_UART->COMRX;
+ }
+ } else {
+ if (rx_length[1] < SIZE(rx_pingpong[1])) {
+ p_rx_buf[rx_length[1]++] = pADI_UART->COMRX;
+ }
+ }
+
+ if (pADI_UART->COMRX == '\n') {
+ if (p_rx_buf == rx_pingpong[0]) {
+ p_rx_buf = rx_pingpong[1];
+ rx_length[1] = 0;
+ rd_count[1] = 0;
+ } else {
+ p_rx_buf = rx_pingpong[0];
+ rx_length[0] = 0;
+ rd_count[0] = 0;
+ }
+
+ app msg;
+ msg.argc = 0;
+ msg.fun = rx_line;
+ ts_post_message(msg);
+ }
+ }
+}
+#ifdef __cplusplus
+}
+#endif
Index: ADuCM360_demo_cn0359/src/hal/syscalls.cpp
===================================================================
diff -u
--- ADuCM360_demo_cn0359/src/hal/syscalls.cpp (revision 0)
+++ ADuCM360_demo_cn0359/src/hal/syscalls.cpp (revision 8d80f35bf88694bd50d769b9bab31db8364a9004)
@@ -0,0 +1,225 @@
+/***************************************************************************//**
+ * @file syscalls.cpp
+ * @brief Implementation of syscalls.cpp
+ * @author
+ *******************************************************************************
+ * Copyright 2022(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.
+ ******************************************************************************/
+
+/* Support files for GNU libc. Files in the system namespace go here.
+ Files in the C namespace (ie those that do not start with an
+ underscore) go in .c. */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include