├── manifest.json ├── project.mk ├── ld ├── main_api.syms ├── usermodfx.ld └── rules.ld ├── README.md ├── LICENSE ├── tpl └── _unit.c ├── teleconf.cpp └── Makefile /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "header" : 3 | { 4 | "platform" : "nutekt-digital", 5 | "module" : "modfx", 6 | "api" : "1.1-0", 7 | "dev_id" : 0, 8 | "prg_id" : 0, 9 | "version" : "1.0-0", 10 | "name" : "teleconf", 11 | "num_param" : 0 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /project.mk: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Project Customization 3 | # ############################################################################# 4 | 5 | PROJECT = teleconf 6 | 7 | UCSRC = 8 | 9 | UCXXSRC = teleconf.cpp 10 | 11 | UINCDIR = 12 | 13 | UDEFS = 14 | 15 | ULIB = 16 | 17 | ULIBDIR = 18 | -------------------------------------------------------------------------------- /ld/main_api.syms: -------------------------------------------------------------------------------- 1 | 2 | k_fx_api_version = 0x0807b000; 3 | k_fx_api_platform = 0x0807b004; 4 | sqrtm2log_lut_f = 0x0807b100; 5 | tanpi_lut_f = 0x0807b504; 6 | log_lut_f = 0x0807b908; 7 | bitres_lut_f = 0x0807bd0c; 8 | wt_sine_lut_f = 0x0807bf10; 9 | schetzen_lut_f = 0x0807c114; 10 | cubicsat_lut_f = 0x0807c318; 11 | pow2_lut_f = 0x0807c51c; 12 | _fx_mcu_hash = 0x0807c920; 13 | _fx_rand = 0x0807c92c; 14 | _fx_white = 0x0807c964; 15 | _fx_get_bpm = 0x0807ca88; 16 | _fx_get_bpmf = 0x0807ca8c; 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Teleconf 2 | 3 | Binaries are available in [this page](https://github.com/boochow/teleconf/releases). 4 | 5 | [![top-page](https://raw.githubusercontent.com/boochow/teleconf/images/teleconf.jpg)](https://www.youtube.com/watch?v=OHrTgCjFOb0) 6 | 7 | ## About 8 | 9 | Teleconf is a modulation FX unit for Korg logue SDK compatible synthesizers. 10 | 11 | It modulates the input sounds as if it comes from a teleconference device. 12 | 13 | Technically this module applies a bandpass filter and [G.711 a-law](https://en.wikipedia.org/wiki/G.711) codec to input sounds. 14 | 15 | ## Parameters 16 | 17 | 1. Time changes the filters' resonance value. 18 | 19 | 1. Depth adds the wet signal to the output signal. 20 | 21 | ## Others 22 | 23 | My other user oscillators / modules are [here](https://blog.boochow.com/logue). 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 boochow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ld/usermodfx.ld: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, KORG INC. 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | //*/ 33 | 34 | /* 35 | * File: usermodfx.ld 36 | * 37 | * Linker Script for user modulation effects 38 | */ 39 | 40 | /* Entry Point */ 41 | ENTRY(_entry) 42 | 43 | /* Specify the memory areas */ 44 | MEMORY 45 | { 46 | SRAM (rx) : org = 0x20017800, len = 6K 47 | SDRAM (rw) : org = 0xC0400000, len = 128K 48 | } 49 | 50 | /* Include Rules */ 51 | INCLUDE rules.ld 52 | -------------------------------------------------------------------------------- /ld/rules.ld: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, KORG INC. 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | //*/ 33 | 34 | /* 35 | * File: rules.ld 36 | * 37 | * Linker Rules 38 | */ 39 | 40 | /* ----------------------------------------------------------------------------- */ 41 | /* Define output sections */ 42 | 43 | SECTIONS 44 | { 45 | 46 | .hooks : ALIGN(16) SUBALIGN(16) 47 | { 48 | . = ALIGN(4); 49 | _hooks_start = .; 50 | KEEP(*(.hooks)) 51 | . = ALIGN(4); 52 | _hooks_end = .; 53 | } > SRAM 54 | 55 | /* Constructors */ 56 | .init_array : ALIGN(4) SUBALIGN(4) 57 | { 58 | . = ALIGN(4); 59 | PROVIDE(__init_array_start = .); 60 | KEEP(*(SORT(.init_array.*))) 61 | KEEP(*(.init_array*)) 62 | . = ALIGN(4); 63 | PROVIDE(__init_array_end = .); 64 | } > SRAM 65 | 66 | /* Common Code */ 67 | .text : ALIGN(4) SUBALIGN(4) 68 | { 69 | . = ALIGN(4); 70 | _text_start = .; 71 | *(.text) 72 | *(.text.*) 73 | *(.glue_7) /* glue arm to thumb code */ 74 | *(.glue_7t) /* glue thumb to arm code */ 75 | *(.gcc*) 76 | . = ALIGN(4); 77 | _text_end = .; 78 | } > SRAM 79 | 80 | /* Constants and strings */ 81 | .rodata : ALIGN(4) SUBALIGN(4) 82 | { 83 | . = ALIGN(4); 84 | _rodata_start = .; 85 | *(.rodata) 86 | *(.rodata.*) 87 | . = ALIGN(4); 88 | _rodata_end = .; 89 | } > SRAM 90 | 91 | /* Read-write data */ 92 | .data ALIGN(8) : ALIGN(8) SUBALIGN(8) 93 | { 94 | . = ALIGN(8); 95 | _data_start = .; 96 | *(.data) 97 | *(.data.*) 98 | . = ALIGN(8); 99 | _data_end = .; 100 | } > SRAM 101 | 102 | /* Uninitialized variables */ 103 | .bss (NOLOAD) : ALIGN(4) 104 | { 105 | . = ALIGN(4); 106 | _bss_start = .; 107 | *(.bss) 108 | *(.bss.*) 109 | *(COMMON) 110 | . = ALIGN(4); 111 | _bss_end = .; 112 | } > SRAM 113 | 114 | /* Exception sections */ 115 | .ARM.extab : ALIGN(4) SUBALIGN(4) 116 | { 117 | . = ALIGN(4); 118 | __extab_start = .; 119 | *(.ARM.extab* .gnu.linkonce.armextab.*) 120 | . = ALIGN(4); 121 | __extab_end = .; 122 | } > SRAM 123 | 124 | .ARM.exidx : ALIGN(4) SUBALIGN(4) 125 | { /* Note: Aligning when there's no content for this section throws a warning. Looks like a linker bug. */ 126 | /* . = ALIGN(4); */ 127 | __exidx_start = .; 128 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 129 | /* . = ALIGN(4); */ 130 | __exidx_end = .; 131 | } > SRAM 132 | 133 | .eh_frame_hdr : ALIGN(4) SUBALIGN(4) 134 | { 135 | . = ALIGN(4); 136 | _eh_frame_hdr_start = .; 137 | *(.eh_frame_hdr) 138 | . = ALIGN(4); 139 | _eh_frame_hdr_end = .; 140 | } > SRAM 141 | 142 | .eh_frame : ALIGN(4) SUBALIGN(4) ONLY_IF_RO 143 | { 144 | . = ALIGN(4); 145 | _eh_frame_start = .; 146 | *(.eh_frame) 147 | . = ALIGN(4); 148 | _eh_frame_end = .; 149 | } > SRAM 150 | 151 | .sdram (NOLOAD) : ALIGN(4) SUBALIGN(4) 152 | { 153 | . = ALIGN(4); 154 | _usr_sdram_start = .; 155 | KEEP(*(.sdram*)) 156 | . = ALIGN(4); 157 | _usr_sdram_end = .; 158 | } > SDRAM 159 | 160 | /* 161 | /DISCARD/ 162 | { 163 | libc.a ( * ) 164 | libm.a ( * ) 165 | libgcc.a ( * ) 166 | } 167 | //*/ 168 | 169 | /* .ARM.attributes 0 : { *(.ARM.attributes) } //*/ 170 | } 171 | -------------------------------------------------------------------------------- /tpl/_unit.c: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, KORG INC. 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | //*/ 33 | 34 | /** 35 | * @file _unit.c 36 | * @brief Modulation effect entry template. 37 | * 38 | * @addtogroup api 39 | * @{ 40 | */ 41 | 42 | #include "usermodfx.h" 43 | 44 | /*===========================================================================*/ 45 | /* Externs and Types. */ 46 | /*===========================================================================*/ 47 | 48 | /** 49 | * @name Externs and Types. 50 | * @{ 51 | */ 52 | 53 | extern uint8_t _bss_start; 54 | extern uint8_t _bss_end; 55 | 56 | extern void (*__init_array_start []) (void); 57 | extern void (*__init_array_end []) (void); 58 | 59 | typedef void (*__init_fptr)(void); 60 | 61 | /** @} */ 62 | 63 | /*===========================================================================*/ 64 | /* Local Constants and Vars. */ 65 | /*===========================================================================*/ 66 | 67 | /** 68 | * @name Local Constants and Vars. 69 | * @{ 70 | */ 71 | 72 | __attribute__((used, section(".hooks"))) 73 | static const user_modfx_hook_table_t s_hook_table = { 74 | .magic = {'U','M','O','D'}, 75 | .api = USER_API_VERSION, 76 | .platform = USER_TARGET_PLATFORM>>8, 77 | .reserved0 = {0}, 78 | .func_entry = _entry, 79 | .func_process = _hook_process, 80 | .func_suspend = _hook_suspend, 81 | .func_resume = _hook_resume, 82 | .func_param = _hook_param, 83 | .reserved1 = {0} 84 | }; 85 | 86 | /** @} */ 87 | 88 | /*===========================================================================*/ 89 | /* Default Hooks. */ 90 | /*===========================================================================*/ 91 | 92 | /** 93 | * @name Default Hooks. 94 | * @{ 95 | */ 96 | 97 | __attribute__((used)) 98 | void _entry(uint32_t platform, uint32_t api) 99 | { 100 | // Ensure zero-clear BSS segment 101 | uint8_t * __restrict bss_p = (uint8_t *)&_bss_start; 102 | const uint8_t * const bss_e = (uint8_t *)&_bss_end; 103 | 104 | for (; bss_p != bss_e;) 105 | *(bss_p++) = 0; 106 | 107 | // Call constructors if any. 108 | const size_t count = __init_array_end - __init_array_start; 109 | for (size_t i = 0; i>= i; 119 | val = val * sign; 120 | return q15_to_f32(val); 121 | } 122 | 123 | void MODFX_PROCESS(const float *main_xn, float *main_yn, 124 | const float *sub_xn, float *sub_yn, 125 | uint32_t frames) 126 | { 127 | const float * mx = main_xn; 128 | float * __restrict my = main_yn; 129 | const float * my_e = my + 2*frames; 130 | 131 | const float * sx = sub_xn; 132 | float * __restrict sy = sub_yn; 133 | 134 | float vmx; 135 | float vsx; 136 | for (; my != my_e; ) { 137 | 138 | // Left channel 139 | vmx = s_bq_hpf_l.process_so(s_bq_lpf_l.process_so(*mx)); 140 | #if SUBTIMBRE 141 | vsx = s_bqs_hpf_l.process_so(s_bqs_lpf_l.process_so(*sx)); 142 | #endif 143 | 144 | if (count == 0) { 145 | lastmy_l = g711(vmx); 146 | #if SUBTIMBRE 147 | lastsy_l = g711(vsx); 148 | #endif 149 | } 150 | 151 | *my++ = dry * (*mx++) + wet * \ 152 | s_bq_lpf_out2_l.process_so(s_bq_lpf_out_l.process_so(lastmy_l)); 153 | #if SUBTIMBRE 154 | *sy++ = dry * (*sx++) + wet * \ 155 | s_bq_lpf_out2_l.process_so(s_bqs_lpf_out_l.process_so(lastsy_l)); 156 | #endif 157 | 158 | // Right channel 159 | vmx = s_bq_hpf_r.process_so(s_bq_lpf_r.process_so(*mx)); 160 | #if SUBTIMBRE 161 | vsx = s_bqs_hpf_r.process_so(s_bqs_lpf_r.process_so(*sx)); 162 | #endif 163 | 164 | if (count == 0) { 165 | lastmy_r = g711(vmx); 166 | #if SUBTIMBRE 167 | lastsy_r = g711(vsx); 168 | #endif 169 | } 170 | 171 | *my++ = dry * (*mx++) + wet * \ 172 | s_bq_lpf_out2_r.process_so(s_bq_lpf_out_r.process_so(lastmy_r)); 173 | #if SUBTIMBRE 174 | *sy++ = dry * (*sx++) + wet * \ 175 | s_bq_lpf_out2_r.process_so(s_bqs_lpf_out_r.process_so(lastsy_r)); 176 | #endif 177 | 178 | count = (count + 1) % 6; 179 | } 180 | } 181 | 182 | void MODFX_PARAM(uint8_t index, int32_t value) 183 | { 184 | const float valf = q31_to_f32(value); 185 | 186 | switch (index) { 187 | case k_user_modfx_param_time: 188 | init_lpf(LPF_FC, LPF_Q + 1.6 * valf); 189 | break; 190 | case k_user_modfx_param_depth: 191 | wet = valf; 192 | dry = 1.0 - wet; 193 | break; 194 | default: 195 | break; 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Prologue Mod. FX Makefile 3 | # ############################################################################# 4 | 5 | ifeq ($(OS),Windows_NT) 6 | ifeq ($(MSYSTEM), MSYS) 7 | detected_OS := $(shell uname -s) 8 | else 9 | detected_OS := Windows 10 | endif 11 | else 12 | detected_OS := $(shell uname -s) 13 | endif 14 | 15 | PLATFORMDIR = .. 16 | PROJECTDIR = . 17 | TOOLSDIR = $(PLATFORMDIR)/../../tools 18 | EXTDIR = $(PLATFORMDIR)/../ext 19 | 20 | CMSISDIR = $(EXTDIR)/CMSIS/CMSIS 21 | 22 | # ############################################################################# 23 | # configure archive utility 24 | # ############################################################################# 25 | 26 | ZIP = /usr/bin/zip 27 | ZIP_ARGS = -r -m -q 28 | 29 | ifeq ($(OS),Windows_NT) 30 | ifneq ($(MSYSTEM), MSYS) 31 | ifneq ($(MSYSTEM), MINGW64) 32 | ZIP = $(TOOLSDIR)/zip/bin/zip 33 | endif 34 | endif 35 | endif 36 | 37 | # ############################################################################# 38 | # Include project specific definition 39 | # ############################################################################# 40 | 41 | include ./project.mk 42 | 43 | # ############################################################################# 44 | # configure cross compilation 45 | # ############################################################################# 46 | 47 | MCU = cortex-m4 48 | 49 | GCC_TARGET = arm-none-eabi- 50 | GCC_BIN_PATH = $(TOOLSDIR)/gcc/gcc-arm-none-eabi-5_4-2016q3/bin 51 | 52 | CC = $(GCC_BIN_PATH)/$(GCC_TARGET)gcc 53 | CXXC = $(GCC_BIN_PATH)/$(GCC_TARGET)g++ 54 | LD = $(GCC_BIN_PATH)/$(GCC_TARGET)gcc 55 | #LD = $(GCC_BIN_PATH)/$(GCC_TARGET)g++ 56 | CP = $(GCC_BIN_PATH)/$(GCC_TARGET)objcopy 57 | AS = $(GCC_BIN_PATH)/$(GCC_TARGET)gcc -x assembler-with-cpp 58 | AR = $(GCC_BIN_PATH)/$(GCC_TARGET)ar 59 | OD = $(GCC_BIN_PATH)/$(GCC_TARGET)objdump 60 | SZ = $(GCC_BIN_PATH)/$(GCC_TARGET)size 61 | 62 | HEX = $(CP) -O ihex 63 | BIN = $(CP) -O binary 64 | 65 | LDDIR = $(PROJECTDIR)/ld 66 | RULESPATH = $(LDDIR) 67 | LDSCRIPT = $(LDDIR)/usermodfx.ld 68 | DLIBS = -lm 69 | 70 | DADEFS = -DSTM32F446xE -DCORTEX_USE_FPU=TRUE -DARM_MATH_CM4 71 | DDEFS = -DSTM32F446xE -DCORTEX_USE_FPU=TRUE -DARM_MATH_CM4 -D__FPU_PRESENT 72 | 73 | COPT = -std=c11 -mstructure-size-boundary=8 74 | CXXOPT = -std=c++11 -fno-rtti -fno-exceptions -fno-non-call-exceptions 75 | 76 | LDOPT = -Xlinker --just-symbols=$(LDDIR)/main_api.syms 77 | 78 | CWARN = -W -Wall -Wextra 79 | CXXWARN = 80 | 81 | FPU_OPTS = -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -fcheck-new 82 | 83 | OPT = -g -Os -mlittle-endian 84 | OPT += $(FPU_OPTS) 85 | #OPT += -flto 86 | 87 | TOPT = -mthumb -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -DTHUMB_PRESENT 88 | 89 | 90 | # ############################################################################# 91 | # set targets and directories 92 | # ############################################################################# 93 | 94 | PKGDIR = $(PROJECT) 95 | PKGARCH = $(PROJECT).ntkdigunit 96 | MANIFEST = manifest.json 97 | PAYLOAD = payload.bin 98 | BUILDDIR = $(PROJECTDIR)/build 99 | OBJDIR = $(BUILDDIR)/obj 100 | LSTDIR = $(BUILDDIR)/lst 101 | 102 | ASMSRC = $(UASMSRC) 103 | 104 | ASMXSRC = $(UASMXSRC) 105 | 106 | CSRC = $(PROJECTDIR)/tpl/_unit.c $(UCSRC) 107 | 108 | CXXSRC = $(UCXXSRC) 109 | 110 | vpath %.s $(sort $(dir $(ASMSRC))) 111 | vpath %.S $(sort $(dir $(ASMXSRC))) 112 | vpath %.c $(sort $(dir $(CSRC))) 113 | vpath %.cpp $(sort $(dir $(CXXSRC))) 114 | 115 | ASMOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) 116 | ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o))) 117 | COBJS := $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o))) 118 | CXXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(CXXSRC:.cpp=.o))) 119 | 120 | OBJS := $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CXXOBJS) 121 | 122 | DINCDIR = $(PROJECTDIR)/inc \ 123 | $(PROJECTDIR)/inc/api \ 124 | $(PLATFORMDIR)/inc \ 125 | $(PLATFORMDIR)/inc/dsp \ 126 | $(PLATFORMDIR)/inc/utils \ 127 | $(CMSISDIR)/Include 128 | 129 | INCDIR := $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) 130 | 131 | DEFS := $(DDEFS) $(UDEFS) 132 | ADEFS := $(DADEFS) $(UADEFS) 133 | 134 | LIBS := $(DLIBS) $(ULIBS) 135 | 136 | LIBDIR := $(patsubst %,-I%,$(DLIBDIR) $(ULIBDIR)) 137 | 138 | 139 | # ############################################################################# 140 | # compiler flags 141 | # ############################################################################# 142 | 143 | MCFLAGS := -mcpu=$(MCU) 144 | ODFLAGS = -x --syms 145 | ASFLAGS = $(MCFLAGS) -g $(TOPT) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS) 146 | ASXFLAGS = $(MCFLAGS) -g $(TOPT) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS) 147 | CFLAGS = $(MCFLAGS) $(TOPT) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS) 148 | CXXFLAGS = $(MCFLAGS) $(TOPT) $(OPT) $(CXXOPT) $(CXXWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS) 149 | LDFLAGS = $(MCFLAGS) $(TOPT) $(OPT) -nostartfiles $(LIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH),--script=$(LDSCRIPT) $(LDOPT) 150 | 151 | OUTFILES := $(BUILDDIR)/$(PROJECT).elf \ 152 | $(BUILDDIR)/$(PROJECT).hex \ 153 | $(BUILDDIR)/$(PROJECT).bin \ 154 | $(BUILDDIR)/$(PROJECT).dmp \ 155 | $(BUILDDIR)/$(PROJECT).list 156 | 157 | ############################################################################### 158 | # targets 159 | ############################################################################### 160 | 161 | all: PRE_ALL $(OBJS) $(OUTFILES) POST_ALL 162 | 163 | PRE_ALL: 164 | 165 | POST_ALL: package 166 | 167 | $(OBJS): | $(BUILDDIR) $(OBJDIR) $(LSTDIR) 168 | 169 | $(BUILDDIR): 170 | @echo Compiler Options 171 | @echo $(CC) -c $(CFLAGS) -I. $(INCDIR) 172 | @echo 173 | @mkdir -p $(BUILDDIR) 174 | 175 | $(OBJDIR): 176 | @mkdir -p $(OBJDIR) 177 | 178 | $(LSTDIR): 179 | @mkdir -p $(LSTDIR) 180 | 181 | $(ASMOBJS) : $(OBJDIR)/%.o : %.s Makefile 182 | @echo Assembling $( $@ 212 | @echo 213 | @$(SZ) $< 214 | @echo 215 | 216 | %.list: %.elf 217 | @echo Creating $@ 218 | @$(OD) -S $< > $@ 219 | 220 | clean: 221 | @echo Cleaning 222 | -rm -fR .dep $(BUILDDIR) $(PKGARCH) 223 | @echo 224 | @echo Done 225 | 226 | package: 227 | @echo Packaging to ./$(PKGARCH) 228 | @mkdir -p $(PKGDIR) 229 | @cp -a $(MANIFEST) $(PKGDIR)/ 230 | @cp -a $(BUILDDIR)/$(PROJECT).bin $(PKGDIR)/$(PAYLOAD) 231 | @$(ZIP) $(ZIP_ARGS) $(PROJECT).zip $(PKGDIR) 232 | @mv $(PROJECT).zip $(PKGARCH) 233 | @echo 234 | @echo Done 235 | --------------------------------------------------------------------------------