From 1e312f194c6b402f8bfcd729c8bc48df8440bd78 Mon Sep 17 00:00:00 2001 From: ReclaimerLabs Date: Thu, 12 Nov 2020 22:20:53 -0800 Subject: [PATCH] Stability upgrades Migrated to Microchip Studio (formerly Atmel Studio), I2C to 1 MHz, SPI uses DMA, Power Delivery code doesn't send Get_Source_Cap messages, screen update code optimized to bring response times in line with USB PD Spec, and other minor upgrades. --- .../.vs/USB-C Explorer/v14/.atsuo | Bin 157184 -> 168960 bytes .../USB-C Explorer/USB-C Explorer.cproj | 48 +- firmware/USB-C Explorer/USB-C Explorer/main.c | 28 +- .../components/display/ssd1306/ssd1306.c | 39 +- .../components/display/ssd1306/ssd1306.h | 2 + .../src/ASF/sam0/drivers/dma/dma.c | 644 +++++++++++++ .../src/ASF/sam0/drivers/dma/dma.h | 873 ++++++++++++++++++ .../src/ASF/sam0/drivers/dma/dma_crc.h | 220 +++++ .../drivers/dma/quick_start/qs_dma_basic.h | 148 +++ .../src/ASF/sam0/drivers/rtc/rtc_count.h | 48 +- .../sam0/drivers/rtc/rtc_count_interrupt.h | 46 +- .../drivers/rtc/rtc_sam_d_r_h/rtc_count.c | 48 +- .../rtc/rtc_sam_d_r_h/rtc_count_interrupt.c | 46 +- .../src/ASF/sam0/drivers/rtc/rtc_tamper.h | 48 +- .../USB-C Explorer/src/FUSB302/FUSB302.c | 4 +- .../src/FUSB302/usb_pd_driver.c | 19 +- .../src/USBC_PD/usb_pd_protocol.c | 33 +- .../USB-C Explorer/USB-C Explorer/src/asf.h | 27 +- .../USB-C Explorer/src/config/conf_dma.h | 41 + .../USB-C Explorer/src/config/conf_spi.h | 2 +- .../USB-C Explorer/src/config/conf_ssd1306.h | 1 + 21 files changed, 2151 insertions(+), 214 deletions(-) create mode 100644 firmware/USB-C Explorer/USB-C Explorer/src/ASF/sam0/drivers/dma/dma.c create mode 100644 firmware/USB-C Explorer/USB-C Explorer/src/ASF/sam0/drivers/dma/dma.h create mode 100644 firmware/USB-C Explorer/USB-C Explorer/src/ASF/sam0/drivers/dma/dma_crc.h create mode 100644 firmware/USB-C Explorer/USB-C Explorer/src/ASF/sam0/drivers/dma/quick_start/qs_dma_basic.h create mode 100644 firmware/USB-C Explorer/USB-C Explorer/src/config/conf_dma.h diff --git a/firmware/USB-C Explorer/.vs/USB-C Explorer/v14/.atsuo b/firmware/USB-C Explorer/.vs/USB-C Explorer/v14/.atsuo index 29226d9375421d13bf6e3f895ac72ebf1e598288..37abb5fb5633168cd118b751caed69e0bc4c7885 100644 GIT binary patch delta 13799 zcmeHNd3@C6nV5CU=yl9^<#D1pp<-&bb1ocq3KGKWe6?snIDL4KAO zTbBa0^su!^tidi?P`6cUg|=?n-MSU6N4KAPv`f1!yUITA95Ebr>#qHL`iJi)-@Nzp zd*A1H-{*bb8GnBE_?KJuZdy`gFc=Mh_b*<&2oZw`*a%oebFODSoEk?HRBT>KGx(nB zu^*!`(!xWRo66KqME{<8f9!53SU^f4Gy~oPGW9SE@`Nl2jga0}%NHQN1;7K$14ID- z3|Io_1qc8=041u@TL$UP02iPga1CH30LYGA9EL;(fCX3#kODRU76O(7ZUPJeRs+aD z)KvpZW&8T~SpL^l8EwzGmGb#u%4&>*6q*kIfBCma^ z=2h205fLbMuT?=%$03uT&1|n0!{y!~K(3+VtC9}IkrnG6p;_E+5g8e|A^!STQ zuvOSVrcQ5aeN9Rd&%uYk2Y4Pp@-IMq25=VegId{7Abt@*jP1v@vY$e{4lx+CZ|?m| zc0*zh;5Gmu^0yFw3h;N6rvqEizSNf|S{`U472BY217Hh)ex!vv=7+>4zz|?FfHWG0 zI0p~|BmgOZl*=Jj0P+A8Kn>6UNSzL1J-`6)0ZafhzycukHi+#2M=kG!*o8o6w$=)^ zL%gGwjza7PcmUp7*=Q{eLL35w0g+l+tQM0Gk&uFX8jz`#lQL3QM-j?PfHH!W=jK|Y zTOr;B7$bT5z1d&-t7O>bt1^sC?9XBtZ3--w{`u_r5bnU&Cg$au`hinVuBXfM%1yU{ zHa@YQzA#VS43!nTqx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