From 348cbff2542423e30cd2d7a96bcc3f53765cb344 Mon Sep 17 00:00:00 2001 From: Alex Taradov Date: Thu, 26 Jan 2017 18:38:25 -0800 Subject: [PATCH] Minor hardware changes + bootloader mode --- hardware/d11_usb_mini.brd | 60 +- hardware/d11_usb_mini.sch | 1488 +---------------- platform/samd11/linker/samd11d14_bl.ld | 82 + .../linker/{samd11d14.ld => samd11d14_std.ld} | 2 +- platform/samd11/main.c | 7 +- .../samd11/make/{Makefile => Makefile_bl} | 4 +- platform/samd11/make/Makefile_std | 74 + platform/samd11/startup_samd11.c | 5 + platform/samd11/usb.c | 2 +- platform/samd11/usb_descriptors.c | 11 +- platform/samd11/usb_descriptors.h | 8 +- platform/samd11/utils.h | 2 - 12 files changed, 230 insertions(+), 1515 deletions(-) create mode 100644 platform/samd11/linker/samd11d14_bl.ld rename platform/samd11/linker/{samd11d14.ld => samd11d14_std.ld} (97%) rename platform/samd11/make/{Makefile => Makefile_bl} (91%) create mode 100644 platform/samd11/make/Makefile_std diff --git a/hardware/d11_usb_mini.brd b/hardware/d11_usb_mini.brd index 42956f5..7027635 100644 --- a/hardware/d11_usb_mini.brd +++ b/hardware/d11_usb_mini.brd @@ -62,7 +62,7 @@ -1/24/17 +1/26/17 AT @@ -308,34 +308,17 @@ Source: http://www.cypressindustries.com/pdf/32005-201.pdf - -<b>LEDs</b><p> -<author>Created by librarian@cadsoft.de</author><br> -Extended by Federico Battaglin <author>&lt;federico.rd@fdpinternational.com&gt;</author> with DUOLED + +Alex Taradov Library (LEDs and other indication devices) - -<b>CHIPLED</b><p> -Source: http://www.osram.convergy.de/ ... LG_LY Q971.pdf - - - - - - - ->NAME ->VALUE - - - - - - - - - - - + + + + + + + +>NAME @@ -567,7 +550,7 @@ Please make sure your boards conform to these design rules. - + @@ -660,18 +643,17 @@ Please make sure your boards conform to these design rules. - - - - - + + + + + - - + @@ -766,15 +748,15 @@ Please make sure your boards conform to these design rules. - - - + + + diff --git a/hardware/d11_usb_mini.sch b/hardware/d11_usb_mini.sch index 53f17fa..9938ef6 100644 --- a/hardware/d11_usb_mini.sch +++ b/hardware/d11_usb_mini.sch @@ -905,1064 +905,26 @@ Source: www.cypressindustries.com - -<b>LEDs</b><p> -<author>Created by librarian@cadsoft.de</author><br> -Extended by Federico Battaglin <author>&lt;federico.rd@fdpinternational.com&gt;</author> with DUOLED + +Alex Taradov Library (LEDs and other indication devices) - -<b>CHICAGO MINIATURE LAMP, INC.</b><p> -7022X Series SMT LEDs 1206 Package Size - - - - - - - - - - ->NAME ->VALUE - - - - - - - + + + + + + + +>NAME - -<B>LED</B><p> -5 mm, square, Siemens - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<B>LED</B><p> -2 x 5 mm, rectangle - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - -<B>LED</B><p> -3 mm, round - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<B>LED</B><p> -5 mm, round - - - - - - - - - - - ->NAME ->VALUE - - -<B>LED</B><p> -1 mm, round, Siemens - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<B>LED BLOCK</B><p> -1 LED, Siemens - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<b>LED HOLDER</b><p> -Siemens - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>LED HOLDER</b><p> -Siemens - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>LED HOLDER</b><p> -Siemens - - - - - - - - - - - - - - - - - -A+ -K- ->NAME ->VALUE - - - - - -<b>LED HOLDER</b><p> -Siemens - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE -+ -- - - -<B>IR LED</B><p> -infrared emitting diode, Infineon -TO-18, lead spacing 2.54 mm, cathode marking<p> -Inifineon - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<B>IR LED</B><p> -infrared emitting diode, Infineon -TO-18, lead spacing 2.54 mm, cathode marking<p> -Inifineon - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<B>LED</B><p> -rectangle, 5.7 x 3.2 mm - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<B>IR LED</B><p> -IR transmitter Siemens - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>TOPLED® High-optical Power LED (HOP)</b><p> -Source: http://www.osram.convergy.de/ ... ls_t675.pdf - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE -A -C - - - - - - - -<b>BLUE LINETM Hyper Mini TOPLED® Hyper-Bright LED</b><p> -Source: http://www.osram.convergy.de/ ... LB M676.pdf - - - - - - - - - - - - - - -A -C ->NAME ->VALUE - - - - - - - -<b>Super SIDELED® High-Current LED</b><p> -LG A672, LP A672 <br> -Source: http://www.osram.convergy.de/ ... LG_LP_A672.pdf (2004.05.13) - - - - - - - - - - - - - - - - - - - -C -A ->NAME ->VALUE - - - - - - - -<b>SmartLEDTM Hyper-Bright LED</b><p> -Source: http://www.osram.convergy.de/ ... LA_LO_LS_LY L896.pdf - - - - - - - - ->NAME ->VALUE - - - - - -<b>Hyper TOPLED® RG Hyper-Bright LED</b><p> -Source: http://www.osram.convergy.de/ ... LA_LO_LS_LY T776.pdf - - - - - - - - - - - - - - - - - - ->NAME ->VALUE -A -C - - - - - - - - - - -<b>Hyper Micro SIDELED®</b><p> -Source: http://www.osram.convergy.de/ ... LA_LO_LS_LY Y876.pdf - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - -<b>Power TOPLED®</b><p> -Source: http://www.osram.convergy.de/ ... LA_LO_LA_LY E67B.pdf - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE -C -A -C -C - - - - - - - - - - - -<b>Hyper CHIPLED Hyper-Bright LED</b><p> -LB Q993<br> -Source: http://www.osram.convergy.de/ ... Lb_q993.pdf - - - - ->NAME ->VALUE - - - - - - - -<b>Hyper CHIPLED Hyper-Bright LED</b><p> -LB R99A<br> -Source: http://www.osram.convergy.de/ ... lb_r99a.pdf - - - - ->NAME ->VALUE - - - - - - - -<b>Mini TOPLED Santana®</b><p> -Source: http://www.osram.convergy.de/ ... LG M470.pdf - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - -<b>CHIPLED</b><p> -Source: http://www.osram.convergy.de/ ... LG_R971.pdf - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - -<b>CHIPLED</b><p> -Source: http://www.osram.convergy.de/ ... LG_LY N971.pdf - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - -<b>CHIPLED</b><p> -Source: http://www.osram.convergy.de/ ... LG_LY Q971.pdf - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - -<b>CHIPLED-0603</b><p> -Recommended Solder Pad useable for SmartLEDTM and Chipled - Package 0603<br> -Package able to withstand TTW-soldering heat<br> -Package suitable for TTW-soldering<br> -Source: http://www.osram.convergy.de/ ... LO_LS_LY L89K.pdf - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - -<b>SmartLED TTW</b><p> -Recommended Solder Pad useable for SmartLEDTM and Chipled - Package 0603<br> -Package able to withstand TTW-soldering heat<br> -Package suitable for TTW-soldering<br> -Source: http://www.osram.convergy.de/ ... LO_LS_LY L89K.pdf - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - -<b>Lumileds Lighting. LUXEON®</b> with cool pad<p> -Source: K2.pdf - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>Lumileds Lighting. LUXEON®</b> without cool pad<p> -Source: K2.pdf - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - -<B>LED</B><p> -10 mm, round - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>SURFACE MOUNT LED LAMP</b> 3.5x2.8mm<p> -Source: http://www.kingbright.com/manager/upload/pdf/KA-3528ASYC(Ver1189474662.1) - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - -<b>SML0805-2CW-TR (0805 PROFILE)</b> COOL WHITE<p> -Source: http://www.ledtronics.com/ds/smd-0603/Dstr0093.pdf - - - - - - - - - - - ->NAME ->VALUE - - -<b>SML10XXKH-TR (HIGH INTENSITY) LED</b><p> -<table> -<tr><td>SML10R3KH-TR</td><td>ULTRA RED</td></tr> -<tr><td>SML10E3KH-TR</td><td>SUPER REDSUPER BLUE</td></tr> -<tr><td>SML10O3KH-TR</td><td>SUPER ORANGE</td></tr> -<tr><td>SML10PY3KH-TR</td><td>PURE YELLOW</td></tr> -<tr><td>SML10OY3KH-TR</td><td>ULTRA YELLOW</td></tr> -<tr><td>SML10AG3KH-TR</td><td>AQUA GREEN</td></tr> -<tr><td>SML10BG3KH-TR</td><td>BLUE GREEN</td></tr> -<tr><td>SML10PB1KH-TR</td><td>SUPER BLUE</td></tr> -<tr><td>SML10CW1KH-TR</td><td>WHITE</td></tr> -</table> - -Source: http://www.ledtronics.com/ds/smd-1206/dstr0094.PDF - - - - - - - ->NAME ->VALUE - - - - - - - - - -<b>SML0603-XXX (HIGH INTENSITY) LED</b><p> -<table> -<tr><td>AG3K</td><td>AQUA GREEN</td></tr> -<tr><td>B1K</td><td>SUPER BLUE</td></tr> -<tr><td>R1K</td><td>SUPER RED</td></tr> -<tr><td>R3K</td><td>ULTRA RED</td></tr> -<tr><td>O3K</td><td>SUPER ORANGE</td></tr> -<tr><td>O3KH</td><td>SOFT ORANGE</td></tr> -<tr><td>Y3KH</td><td>SUPER YELLOW</td></tr> -<tr><td>Y3K</td><td>SUPER YELLOW</td></tr> -<tr><td>2CW</td><td>WHITE</td></tr> -</table> -Source: http://www.ledtronics.com/ds/smd-0603/Dstr0092.pdf - - - - - - - - - - ->NAME ->VALUE - - + + + + + + + +>NAME @@ -1973,11 +935,10 @@ Source: http://www.ledtronics.com/ds/smd-0603/Dstr0092.pdf - ->NAME ->VALUE +>NAME +>VALUE @@ -1993,414 +954,25 @@ Source: http://www.ledtronics.com/ds/smd-0603/Dstr0092.pdf - -<b>LED</b><p> -<u>OSRAM</u>:<br> - -- <u>CHIPLED</u><br> -LG R971, LG N971, LY N971, LG Q971, LY Q971, LO R971, LY R971 -LH N974, LH R974<br> -LS Q976, LO Q976, LY Q976<br> -LO Q996<br> - -- <u>Hyper CHIPLED</u><br> -LW Q18S<br> -LB Q993, LB Q99A, LB R99A<br> - -- <u>SideLED</u><br> -LS A670, LO A670, LY A670, LG A670, LP A670<br> -LB A673, LV A673, LT A673, LW A673<br> -LH A674<br> -LY A675<br> -LS A676, LA A676, LO A676, LY A676, LW A676<br> -LS A679, LY A679, LG A679<br> - -- <u>Hyper Micro SIDELED®</u><br> -LS Y876, LA Y876, LO Y876, LY Y876<br> -LT Y87S<br> - -- <u>SmartLED</u><br> -LW L88C, LW L88S<br> -LB L89C, LB L89S, LG L890<br> -LS L89K, LO L89K, LY L89K<br> -LS L896, LA L896, LO L896, LY L896<br> - -- <u>TOPLED</u><br> -LS T670, LO T670, LY T670, LG T670, LP T670<br> -LSG T670, LSP T670, LSY T670, LOP T670, LYG T670<br> -LG T671, LOG T671, LSG T671<br> -LB T673, LV T673, LT T673, LW T673<br> -LH T674<br> -LS T676, LA T676, LO T676, LY T676, LB T676, LH T676, LSB T676, LW T676<br> -LB T67C, LV T67C, LT T67C, LS T67K, LO T67K, LY T67K, LW E67C<br> -LS E67B, LA E67B, LO E67B, LY E67B, LB E67C, LV E67C, LT E67C<br> -LW T67C<br> -LS T679, LY T679, LG T679<br> -LS T770, LO T770, LY T770, LG T770, LP T770<br> -LB T773, LV T773, LT T773, LW T773<br> -LH T774<br> -LS E675, LA E675, LY E675, LS T675<br> -LS T776, LA T776, LO T776, LY T776, LB T776<br> -LHGB T686<br> -LT T68C, LB T68C<br> - -- <u>Hyper Mini TOPLED®</u><br> -LB M676<br> - -- <u>Mini TOPLED Santana®</u><br> -LG M470<br> -LS M47K, LO M47K, LY M47K -<p> -Source: http://www.osram.convergy.de<p> - -<u>LUXEON:</u><br> -- <u>LUMILED®</u><br> -LXK2-PW12-R00, LXK2-PW12-S00, LXK2-PW14-U00, LXK2-PW14-V00<br> -LXK2-PM12-R00, LXK2-PM12-S00, LXK2-PM14-U00<br> -LXK2-PE12-Q00, LXK2-PE12-R00, LXK2-PE12-S00, LXK2-PE14-T00, LXK2-PE14-U00<br> -LXK2-PB12-K00, LXK2-PB12-L00, LXK2-PB12-M00, LXK2-PB14-N00, LXK2-PB14-P00, LXK2-PB14-Q00<br> -LXK2-PR12-L00, LXK2-PR12-M00, LXK2-PR14-Q00, LXK2-PR14-R00<br> -LXK2-PD12-Q00, LXK2-PD12-R00, LXK2-PD12-S00<br> -LXK2-PH12-R00, LXK2-PH12-S00<br> -LXK2-PL12-P00, LXK2-PL12-Q00, LXK2-PL12-R00 -<p> -Source: www.luxeon.com<p> - -<u>KINGBRIGHT:</U><p> -KA-3528ASYC<br> -Source: www.kingbright.com + +SMD_LED - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -2453,7 +1025,7 @@ Source: www.kingbright.com - + @@ -2748,8 +1320,8 @@ Source: www.kingbright.com - + diff --git a/platform/samd11/linker/samd11d14_bl.ld b/platform/samd11/linker/samd11d14_bl.ld new file mode 100644 index 0000000..a653082 --- /dev/null +++ b/platform/samd11/linker/samd11d14_bl.ld @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016-2017, Alex Taradov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the author may not 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 THE COPYRIGHT HOLDER OR 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. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00001000, LENGTH = 0x3000 + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x1000 +} + +__top_flash = ORIGIN(flash) + LENGTH(flash); +__top_ram = ORIGIN(ram) + LENGTH(ram); + +ENTRY(irq_handler_reset) + +SECTIONS +{ + .text : ALIGN(4) + { + FILL(0xff) + KEEP(*(.vectors)) + *(.text*) + *(.rodata) + *(.rodata.*) + . = ALIGN(4); + } > flash + + . = ALIGN(4); + _etext = .; + + .uninit_RESERVED : ALIGN(4) + { + KEEP(*(.bss.$RESERVED*)) + } > ram + + .data : ALIGN(4) + { + FILL(0xff) + _data = .; + *(.ramfunc .ramfunc.*); + *(vtable) + *(.data*) + . = ALIGN(4); + _edata = .; + } > ram AT > flash + + .bss : ALIGN(4) + { + _bss = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + _ebss = .; + PROVIDE(_end = .); + } > ram + + PROVIDE(_stack_top = __top_ram - 0); +} diff --git a/platform/samd11/linker/samd11d14.ld b/platform/samd11/linker/samd11d14_std.ld similarity index 97% rename from platform/samd11/linker/samd11d14.ld rename to platform/samd11/linker/samd11d14_std.ld index e75856d..d6d8217 100644 --- a/platform/samd11/linker/samd11d14.ld +++ b/platform/samd11/linker/samd11d14_std.ld @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Alex Taradov + * Copyright (c) 2016-2017, Alex Taradov * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/platform/samd11/main.c b/platform/samd11/main.c index 7cc6737..71cb44f 100644 --- a/platform/samd11/main.c +++ b/platform/samd11/main.c @@ -28,9 +28,10 @@ /*- Includes ----------------------------------------------------------------*/ #include +#include #include #include -#include +#include #include "samd11.h" #include "hal_gpio.h" #include "nvm_data.h" @@ -49,8 +50,8 @@ HAL_GPIO_PIN(LED, A, 14) #define APP_PWM_BRIGHT 0 /*- Variables ---------------------------------------------------------------*/ -ALIGNED(4) uint8_t app_request_buffer[DAP_CONFIG_PACKET_SIZE]; -ALIGNED(4) uint8_t app_response_buffer[DAP_CONFIG_PACKET_SIZE]; +alignas(4) uint8_t app_request_buffer[DAP_CONFIG_PACKET_SIZE]; +alignas(4) uint8_t app_response_buffer[DAP_CONFIG_PACKET_SIZE]; /*- Implementations ---------------------------------------------------------*/ diff --git a/platform/samd11/make/Makefile b/platform/samd11/make/Makefile_bl similarity index 91% rename from platform/samd11/make/Makefile rename to platform/samd11/make/Makefile_bl index 0f9a646..ac59ce7 100644 --- a/platform/samd11/make/Makefile +++ b/platform/samd11/make/Makefile_bl @@ -1,6 +1,6 @@ ############################################################################## BUILD = build -BIN = free_dap +BIN = free_dap_d11_bl ############################################################################## .PHONY: all directory clean size @@ -18,7 +18,7 @@ CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d LDFLAGS += -mcpu=cortex-m0plus -mthumb LDFLAGS += -Wl,--gc-sections -LDFLAGS += -Wl,--script=../linker/samd11d14.ld +LDFLAGS += -Wl,--script=../linker/samd11d14_bl.ld INCLUDES += \ -I../include \ diff --git a/platform/samd11/make/Makefile_std b/platform/samd11/make/Makefile_std new file mode 100644 index 0000000..c8128c7 --- /dev/null +++ b/platform/samd11/make/Makefile_std @@ -0,0 +1,74 @@ +############################################################################## +BUILD = build +BIN = free_dap_d11_std + +############################################################################## +.PHONY: all directory clean size + +CC = arm-none-eabi-gcc +OBJCOPY = arm-none-eabi-objcopy +SIZE = arm-none-eabi-size + +CFLAGS += -W -Wall --std=gnu99 -Os +CFLAGS += -fno-diagnostics-show-caret +CFLAGS += -fdata-sections -ffunction-sections +CFLAGS += -funsigned-char -funsigned-bitfields +CFLAGS += -mcpu=cortex-m0plus -mthumb +CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d + +LDFLAGS += -mcpu=cortex-m0plus -mthumb +LDFLAGS += -Wl,--gc-sections +LDFLAGS += -Wl,--script=../linker/samd11d14_std.ld + +INCLUDES += \ + -I../include \ + -I../../.. \ + -I.. + +SRCS += \ + ../../../dap.c \ + ../main.c \ + ../udc.c \ + ../usb.c \ + ../usb_descriptors.c \ + ../startup_samd11.c + +DEFINES += \ + -D__SAMD11C14A__ \ + -DDONT_USE_CMSIS_INIT \ + -DF_CPU=48000000 + +CFLAGS += $(INCLUDES) $(DEFINES) + +OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) + +all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size + +$(BUILD)/$(BIN).elf: $(OBJS) + @echo LD $@ + @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf + @echo OBJCOPY $@ + @$(OBJCOPY) -O ihex $^ $@ + +$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf + @echo OBJCOPY $@ + @$(OBJCOPY) -O binary $^ $@ + +%.o: + @echo CC $@ + @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ + +directory: + @gmkdir -p $(BUILD) + +size: $(BUILD)/$(BIN).elf + @echo size: + @$(SIZE) -t $^ + +clean: + @echo clean + @-rm -rf $(BUILD) + +-include $(wildcard $(BUILD)/*.d) diff --git a/platform/samd11/startup_samd11.c b/platform/samd11/startup_samd11.c index 2d53e83..77eb035 100644 --- a/platform/samd11/startup_samd11.c +++ b/platform/samd11/startup_samd11.c @@ -26,6 +26,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +//----------------------------------------------------------------------------- +#include "samd11.h" + //----------------------------------------------------------------------------- #define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy"))) @@ -125,6 +128,8 @@ void irq_handler_reset(void) while (dst < &_ebss) *dst++ = 0; + SCB->VTOR = (uint32_t)vectors; + main(); while (1); } diff --git a/platform/samd11/usb.c b/platform/samd11/usb.c index f44f257..8c6e35a 100644 --- a/platform/samd11/usb.c +++ b/platform/samd11/usb.c @@ -256,7 +256,7 @@ void usb_handle_standard_request(usb_request_t *request) length = LIMIT(length, sizeof(usb_hid_report_descriptor)); - udc_control_send(usb_hid_report_descriptor, length); + udc_control_send((uint8_t *)usb_hid_report_descriptor, length); } break; default: diff --git a/platform/samd11/usb_descriptors.c b/platform/samd11/usb_descriptors.c index 9701db3..5aaa925 100644 --- a/platform/samd11/usb_descriptors.c +++ b/platform/samd11/usb_descriptors.c @@ -28,11 +28,12 @@ /*- Includes ----------------------------------------------------------------*/ +#include #include "usb.h" #include "usb_descriptors.h" /*- Variables ---------------------------------------------------------------*/ -ALIGNED(4) usb_device_descriptor_t usb_device_descriptor = +const alignas(4) usb_device_descriptor_t usb_device_descriptor = { .bLength = sizeof(usb_device_descriptor_t), .bDescriptorType = USB_DEVICE_DESCRIPTOR, @@ -50,7 +51,7 @@ ALIGNED(4) usb_device_descriptor_t usb_device_descriptor = .bNumConfigurations = 1, }; -ALIGNED(4) usb_configuration_hierarchy_t usb_configuration_hierarchy = +const alignas(4) usb_configuration_hierarchy_t usb_configuration_hierarchy = { .configuration = { @@ -109,7 +110,7 @@ ALIGNED(4) usb_configuration_hierarchy_t usb_configuration_hierarchy = }, }; -ALIGNED(4) uint8_t usb_hid_report_descriptor[33] = +const alignas(4) uint8_t usb_hid_report_descriptor[33] = { 0x06, 0x00, 0xff, // Usage Page (Vendor Defined 0xFF00) 0x09, 0x01, // Usage (0x01) @@ -129,7 +130,7 @@ ALIGNED(4) uint8_t usb_hid_report_descriptor[33] = 0xc0, // End Collection }; -ALIGNED(4) usb_string_descriptor_zero_t usb_string_descriptor_zero = +const alignas(4) usb_string_descriptor_zero_t usb_string_descriptor_zero = { .bLength = sizeof(usb_string_descriptor_zero_t), .bDescriptorType = USB_STRING_DESCRIPTOR, @@ -145,5 +146,5 @@ char *usb_strings[] = [USB_STR_INTERFACE] = "Main Interface", }; -ALIGNED(4) uint8_t usb_string_descriptor_buffer[64]; +alignas(4) uint8_t usb_string_descriptor_buffer[64]; diff --git a/platform/samd11/usb_descriptors.h b/platform/samd11/usb_descriptors.h index e04d659..b5e4121 100644 --- a/platform/samd11/usb_descriptors.h +++ b/platform/samd11/usb_descriptors.h @@ -74,10 +74,10 @@ typedef struct PACK } usb_configuration_hierarchy_t; //----------------------------------------------------------------------------- -extern usb_device_descriptor_t usb_device_descriptor; -extern usb_configuration_hierarchy_t usb_configuration_hierarchy; -extern uint8_t usb_hid_report_descriptor[33]; -extern usb_string_descriptor_zero_t usb_string_descriptor_zero; +extern const usb_device_descriptor_t usb_device_descriptor; +extern const usb_configuration_hierarchy_t usb_configuration_hierarchy; +extern const uint8_t usb_hid_report_descriptor[33]; +extern const usb_string_descriptor_zero_t usb_string_descriptor_zero; extern char *usb_strings[]; extern uint8_t usb_string_descriptor_buffer[64]; diff --git a/platform/samd11/utils.h b/platform/samd11/utils.h index 60b8372..db6861a 100644 --- a/platform/samd11/utils.h +++ b/platform/samd11/utils.h @@ -30,8 +30,6 @@ #define _UTILS_H_ /*- Definitions -------------------------------------------------------------*/ -#define ALIGNED(a) __attribute__((__aligned__(a))) - #define PACK __attribute__((packed)) #define INLINE static inline __attribute__((always_inline))