├── LICENSE ├── README.md ├── bin └── free_dap_rp2040.uf2 ├── dap.c ├── dap.h ├── hardware ├── d11-nano-dbg │ ├── .gitignore │ ├── d11-nano-dbg-gerbers.zip │ ├── d11-nano-dbg.kicad_pcb │ ├── d11-nano-dbg.kicad_prl │ ├── d11-nano-dbg.kicad_pro │ ├── d11-nano-dbg.kicad_sch │ ├── d11-nano-dbg.pdf │ ├── pcb.kicad_wks │ └── sch.kicad_wks ├── d11_micro_std_vcp │ ├── d11_micro_std_vcp.brd │ ├── d11_micro_std_vcp.pdf │ ├── d11_micro_std_vcp.sch │ └── d11_micro_std_vcp_gerber.zip ├── d11_micro_std_vcp_v2 │ ├── d11_micro_std_vcp_v2-gerbers.zip │ ├── d11_micro_std_vcp_v2.brd │ ├── d11_micro_std_vcp_v2.pdf │ └── d11_micro_std_vcp_v2.sch ├── d11_micro_std_vcp_v3 │ ├── d11_micro_std_vcp_v3-gerbers.zip │ ├── d11_micro_std_vcp_v3.brd │ ├── d11_micro_std_vcp_v3.pdf │ └── d11_micro_std_vcp_v3.sch ├── d11_micro_std_vcp_v4 │ ├── d11_micro_vcp_v4-gerbers.zip │ ├── d11_micro_vcp_v4-layers.zip │ ├── d11_micro_vcp_v4.brd │ ├── d11_micro_vcp_v4.pdf │ └── d11_micro_vcp_v4.sch ├── d11_micro_usb_std │ ├── d11_micro_usb_std.brd │ ├── d11_micro_usb_std.pdf │ ├── d11_micro_usb_std.sch │ └── d11_micro_usb_std_gerber.zip ├── d11_micro_usb_std_v2 │ ├── d11_micro_usb_std_v2-gerbers.zip │ ├── d11_micro_usb_std_v2-layers.zip │ ├── d11_micro_usb_std_v2.brd │ ├── d11_micro_usb_std_v2.pdf │ └── d11_micro_usb_std_v2.sch ├── d11_pogo │ ├── d11_pogo-gerbers.zip │ ├── d11_pogo.brd │ ├── d11_pogo.pdf │ └── d11_pogo.sch ├── d11_usb_mini │ ├── d11_usb_mini.brd │ ├── d11_usb_mini.pdf │ ├── d11_usb_mini.sch │ └── d11_usb_mini_gerber.zip ├── d11_usb_std │ ├── d11_usb_std.brd │ ├── d11_usb_std.sch │ └── d11_usb_std_gerber.zip └── m484-dap │ ├── .gitignore │ ├── m484-dap.kicad_pcb │ ├── m484-dap.kicad_prl │ ├── m484-dap.kicad_pro │ ├── m484-dap.kicad_sch │ ├── output │ ├── m484-dap-Assembly.pdf │ ├── m484-dap-gerbers.zip │ └── m484-dap.pdf │ ├── pcb.kicad_wks │ └── sch.kicad_wks └── platform ├── m484 ├── dap_config.h ├── hal_config.h ├── hal_gpio.h ├── include │ ├── M480.h │ ├── NuMicro.h │ ├── acmp_reg.h │ ├── bpwm_reg.h │ ├── can_reg.h │ ├── ccap_reg.h │ ├── clk_reg.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── crc_reg.h │ ├── crypto_reg.h │ ├── dac_reg.h │ ├── eadc_reg.h │ ├── ebi_reg.h │ ├── ecap_reg.h │ ├── emac_reg.h │ ├── epwm_reg.h │ ├── fmc_reg.h │ ├── gpio_reg.h │ ├── hsotg_reg.h │ ├── hsusbd_reg.h │ ├── hsusbh_reg.h │ ├── i2c_reg.h │ ├── i2s_reg.h │ ├── opa_reg.h │ ├── otg_reg.h │ ├── pdma_reg.h │ ├── qei_reg.h │ ├── qspi_reg.h │ ├── rtc_reg.h │ ├── sc_reg.h │ ├── sdh_reg.h │ ├── spi_reg.h │ ├── spim_reg.h │ ├── sys_reg.h │ ├── system_M480.h │ ├── timer_reg.h │ ├── trng_reg.h │ ├── uart_reg.h │ ├── ui2c_reg.h │ ├── usbd_reg.h │ ├── usbh_reg.h │ ├── uspi_reg.h │ ├── uuart_reg.h │ ├── wdt_reg.h │ └── wwdt_reg.h ├── linker │ └── m484.ld ├── main.c ├── make │ ├── .gitignore │ └── Makefile ├── startup_m480.c ├── uart.c ├── uart.h ├── usb │ ├── usb.h │ ├── usb_cdc.c │ ├── usb_cdc.h │ ├── usb_hid.c │ ├── usb_hid.h │ ├── usb_m484.c │ ├── usb_std.c │ ├── usb_std.h │ ├── usb_winusb.c │ └── usb_winusb.h ├── usb_descriptors.c └── usb_descriptors.h ├── rp2040 ├── dap_config.h ├── hal_config.h ├── hal_gpio.h ├── include │ ├── cmsis_compiler.h │ ├── cmsis_gcc.h │ ├── cmsis_version.h │ ├── core_cm0plus.h │ ├── mpu_armv7.h │ └── rp2040.h ├── linker │ └── rp2040.ld ├── main.c ├── make │ ├── .gitignore │ └── Makefile ├── startup_rp2040.c ├── uart.c ├── uart.h ├── usb │ ├── usb.h │ ├── usb_cdc.c │ ├── usb_cdc.h │ ├── usb_hid.c │ ├── usb_hid.h │ ├── usb_rp2040.c │ ├── usb_std.c │ ├── usb_std.h │ ├── usb_winusb.c │ └── usb_winusb.h ├── usb_descriptors.c └── usb_descriptors.h ├── samd11 ├── dap_config.h ├── hal_config.h ├── hal_gpio.h ├── include │ ├── component │ │ ├── ac.h │ │ ├── adc.h │ │ ├── dac.h │ │ ├── dmac.h │ │ ├── dsu.h │ │ ├── eic.h │ │ ├── evsys.h │ │ ├── gclk.h │ │ ├── hmatrixb.h │ │ ├── mtb.h │ │ ├── nvmctrl.h │ │ ├── pac.h │ │ ├── pm.h │ │ ├── port.h │ │ ├── rtc.h │ │ ├── sercom.h │ │ ├── sysctrl.h │ │ ├── tc.h │ │ ├── tcc.h │ │ ├── usb.h │ │ └── wdt.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── instance │ │ ├── ac.h │ │ ├── adc.h │ │ ├── dac.h │ │ ├── dmac.h │ │ ├── dsu.h │ │ ├── eic.h │ │ ├── evsys.h │ │ ├── gclk.h │ │ ├── mtb.h │ │ ├── nvmctrl.h │ │ ├── pac0.h │ │ ├── pac1.h │ │ ├── pac2.h │ │ ├── pm.h │ │ ├── port.h │ │ ├── ptc.h │ │ ├── rtc.h │ │ ├── sbmatrix.h │ │ ├── sercom0.h │ │ ├── sercom1.h │ │ ├── sercom2.h │ │ ├── sysctrl.h │ │ ├── tc1.h │ │ ├── tc2.h │ │ ├── tcc0.h │ │ ├── usb.h │ │ └── wdt.h │ ├── pio │ │ ├── samd11c14a.h │ │ ├── samd11d14am.h │ │ ├── samd11d14as.h │ │ └── samd11d14au.h │ ├── samd11.h │ ├── samd11c14a.h │ ├── samd11d14am.h │ ├── samd11d14as.h │ └── samd11d14au.h ├── linker │ ├── samd11d14_bl_2k.ld │ └── samd11d14_nobl.ld ├── main.c ├── make │ ├── .gitignore │ ├── Makefile_bl_2k │ └── Makefile_nobl ├── nvm_data.h ├── startup_samd11.c ├── uart.c ├── uart.h ├── usb │ ├── usb.h │ ├── usb_cdc.c │ ├── usb_cdc.h │ ├── usb_hid.c │ ├── usb_hid.h │ ├── usb_samd11.c │ ├── usb_std.c │ ├── usb_std.h │ ├── usb_winusb.c │ └── usb_winusb.h ├── usb_descriptors.c └── usb_descriptors.h ├── samd21 ├── dap_config.h ├── hal_config.h ├── hal_gpio.h ├── include │ ├── component │ │ ├── ac.h │ │ ├── adc.h │ │ ├── dac.h │ │ ├── dmac.h │ │ ├── dsu.h │ │ ├── eic.h │ │ ├── evsys.h │ │ ├── gclk.h │ │ ├── hmatrixb.h │ │ ├── i2s.h │ │ ├── mtb.h │ │ ├── nvmctrl.h │ │ ├── pac.h │ │ ├── pm.h │ │ ├── port.h │ │ ├── rtc.h │ │ ├── sercom.h │ │ ├── sysctrl.h │ │ ├── tc.h │ │ ├── tcc.h │ │ ├── usb.h │ │ └── wdt.h │ ├── core_cm0plus.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── instance │ │ ├── ac.h │ │ ├── adc.h │ │ ├── dac.h │ │ ├── dmac.h │ │ ├── dsu.h │ │ ├── eic.h │ │ ├── evsys.h │ │ ├── gclk.h │ │ ├── i2s.h │ │ ├── mtb.h │ │ ├── nvmctrl.h │ │ ├── pac0.h │ │ ├── pac1.h │ │ ├── pac2.h │ │ ├── pm.h │ │ ├── port.h │ │ ├── ptc.h │ │ ├── rtc.h │ │ ├── sbmatrix.h │ │ ├── sercom0.h │ │ ├── sercom1.h │ │ ├── sercom2.h │ │ ├── sercom3.h │ │ ├── sercom4.h │ │ ├── sercom5.h │ │ ├── sysctrl.h │ │ ├── tc3.h │ │ ├── tc4.h │ │ ├── tc5.h │ │ ├── tc6.h │ │ ├── tc7.h │ │ ├── tcc0.h │ │ ├── tcc1.h │ │ ├── tcc2.h │ │ ├── usb.h │ │ └── wdt.h │ ├── pio │ │ ├── samd21e15a.h │ │ ├── samd21e16a.h │ │ ├── samd21e17a.h │ │ ├── samd21e18a.h │ │ ├── samd21g15a.h │ │ ├── samd21g16a.h │ │ ├── samd21g17a.h │ │ ├── samd21g17au.h │ │ ├── samd21g18a.h │ │ ├── samd21g18au.h │ │ ├── samd21j15a.h │ │ ├── samd21j16a.h │ │ ├── samd21j17a.h │ │ └── samd21j18a.h │ ├── samd21.h │ ├── samd21e15a.h │ ├── samd21e16a.h │ ├── samd21e17a.h │ ├── samd21e18a.h │ ├── samd21g15a.h │ ├── samd21g16a.h │ ├── samd21g17a.h │ ├── samd21g17au.h │ ├── samd21g18a.h │ ├── samd21g18au.h │ ├── samd21j15a.h │ ├── samd21j16a.h │ ├── samd21j17a.h │ └── samd21j18a.h ├── linker │ └── samd21j18_nobl.ld ├── main.c ├── make │ ├── .gitignore │ └── Makefile_nobl ├── nvm_data.h ├── startup_samd21.c ├── uart.c ├── uart.h ├── usb │ ├── usb.h │ ├── usb_cdc.c │ ├── usb_cdc.h │ ├── usb_hid.c │ ├── usb_hid.h │ ├── usb_samd21.c │ ├── usb_std.c │ ├── usb_std.h │ ├── usb_winusb.c │ └── usb_winusb.h ├── usb_descriptors.c └── usb_descriptors.h └── same70 ├── dap_config.h ├── hal_gpio.h ├── include ├── cmsis_compiler.h ├── cmsis_gcc.h ├── cmsis_version.h ├── component │ ├── acc.h │ ├── aes.h │ ├── afec.h │ ├── chipid.h │ ├── dacc.h │ ├── efc.h │ ├── gmac.h │ ├── gpbr.h │ ├── hsmci.h │ ├── i2sc.h │ ├── icm.h │ ├── isi.h │ ├── matrix.h │ ├── mcan.h │ ├── pio.h │ ├── pmc.h │ ├── pwm.h │ ├── qspi.h │ ├── rstc.h │ ├── rswdt.h │ ├── rtc.h │ ├── rtt.h │ ├── sdramc.h │ ├── smc.h │ ├── spi.h │ ├── ssc.h │ ├── supc.h │ ├── tc.h │ ├── trng.h │ ├── twihs.h │ ├── uart.h │ ├── usart.h │ ├── usbhs.h │ ├── utmi.h │ ├── wdt.h │ └── xdmac.h ├── core_cm7.h ├── instance │ ├── acc.h │ ├── aes.h │ ├── afec0.h │ ├── afec1.h │ ├── chipid.h │ ├── dacc.h │ ├── efc.h │ ├── gmac.h │ ├── gpbr.h │ ├── hsmci.h │ ├── i2sc0.h │ ├── i2sc1.h │ ├── icm.h │ ├── isi.h │ ├── matrix.h │ ├── mcan0.h │ ├── mcan1.h │ ├── pioa.h │ ├── piob.h │ ├── pioc.h │ ├── piod.h │ ├── pioe.h │ ├── pmc.h │ ├── pwm0.h │ ├── pwm1.h │ ├── qspi.h │ ├── rstc.h │ ├── rswdt.h │ ├── rtc.h │ ├── rtt.h │ ├── sdramc.h │ ├── smc.h │ ├── spi0.h │ ├── spi1.h │ ├── ssc.h │ ├── supc.h │ ├── tc0.h │ ├── tc1.h │ ├── tc2.h │ ├── tc3.h │ ├── trng.h │ ├── twihs0.h │ ├── twihs1.h │ ├── twihs2.h │ ├── uart0.h │ ├── uart1.h │ ├── uart2.h │ ├── uart3.h │ ├── uart4.h │ ├── usart0.h │ ├── usart1.h │ ├── usart2.h │ ├── usbhs.h │ ├── utmi.h │ ├── wdt.h │ └── xdmac.h ├── mpu_armv7.h ├── pio │ ├── same70j19.h │ ├── same70j19b.h │ ├── same70j20.h │ ├── same70j20b.h │ ├── same70j21.h │ ├── same70j21b.h │ ├── same70n19.h │ ├── same70n19b.h │ ├── same70n20.h │ ├── same70n20b.h │ ├── same70n21.h │ ├── same70n21b.h │ ├── same70q19.h │ ├── same70q19b.h │ ├── same70q20.h │ ├── same70q20b.h │ ├── same70q21.h │ └── same70q21b.h ├── same70.h ├── same70j19.h ├── same70j19b.h ├── same70j20.h ├── same70j20b.h ├── same70j21.h ├── same70j21b.h ├── same70n19.h ├── same70n19b.h ├── same70n20.h ├── same70n20b.h ├── same70n21.h ├── same70n21b.h ├── same70q19.h ├── same70q19b.h ├── same70q20.h ├── same70q20b.h ├── same70q21.h └── same70q21b.h ├── linker └── same70n20.ld ├── main.c ├── make ├── .gitignore └── Makefile ├── startup_same70.c ├── timer.c ├── timer.h ├── usb.c ├── usb.h ├── usb_descriptors.c ├── usb_descriptors.h ├── usb_hid.c ├── usb_hid.h ├── usb_std.c ├── usb_std.h └── utils.h /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Alex Taradov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of free-dap nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /bin/free_dap_rp2040.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/bin/free_dap_rp2040.uf2 -------------------------------------------------------------------------------- /dap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _DAP_H_ 30 | #define _DAP_H_ 31 | 32 | /*- Includes ----------------------------------------------------------------*/ 33 | #include 34 | #include 35 | 36 | /*- Prototypes --------------------------------------------------------------*/ 37 | void dap_init(void); 38 | uint8_t dap_req_get_byte(void); 39 | uint16_t dap_req_get_half(void); 40 | uint32_t dap_req_get_word(void); 41 | void dap_resp_add_byte(uint8_t value); 42 | void dap_resp_add_word(uint32_t value); 43 | void dap_resp_set_byte(int index, uint8_t value); 44 | bool dap_is_buf_error(void); 45 | bool dap_filter_request(uint8_t *req); 46 | int dap_process_request(uint8_t *req, int req_size, uint8_t *resp, int resp_size); 47 | void dap_clock_test(int delay); 48 | 49 | #endif // _DAP_H_ 50 | 51 | -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | fp-info-cache 3 | 4 | -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/d11-nano-dbg-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11-nano-dbg/d11-nano-dbg-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/d11-nano-dbg.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 31, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.3100000023841858 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": true, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fcffff_80000001", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "d11-nano-dbg.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/d11-nano-dbg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11-nano-dbg/d11-nano-dbg.pdf -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/pcb.kicad_wks: -------------------------------------------------------------------------------- 1 | (kicad_wks (version 20210606) (generator pl_editor) 2 | (setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15) 3 | (left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10)) 4 | (line (name "segm1:Line") (start 0 0) (end 0 0)) 5 | ) 6 | -------------------------------------------------------------------------------- /hardware/d11-nano-dbg/sch.kicad_wks: -------------------------------------------------------------------------------- 1 | (kicad_wks (version 20210606) (generator pl_editor) 2 | (setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15) 3 | (left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10)) 4 | (rect (name "") (start 0 0 ltcorner) (end 0 0) (repeat 2) (incrx 2) (incry 2)) 5 | (line (name "") (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50)) 6 | (tbtext "1" (name "") (pos 25 1 ltcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50)) 7 | (line (name "") (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50)) 8 | (tbtext "1" (name "") (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50)) 9 | (line (name "") (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50)) 10 | (tbtext "A" (name "") (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50)) 11 | (line (name "") (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50)) 12 | (tbtext "A" (name "") (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50)) 13 | (tbtext "${TITLE}${SHEETNAME} ${FILENAME}, rev ${REVISION} (${ISSUE_DATE}), page ${#} of ${##}" (name "") (pos 3 4) (justify right) (comment "Sheet id") 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp/d11_micro_std_vcp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp/d11_micro_std_vcp.pdf -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp/d11_micro_std_vcp_gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp/d11_micro_std_vcp_gerber.zip -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v2/d11_micro_std_vcp_v2-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v2/d11_micro_std_vcp_v2-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v2/d11_micro_std_vcp_v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v2/d11_micro_std_vcp_v2.pdf -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v3/d11_micro_std_vcp_v3-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v3/d11_micro_std_vcp_v3-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v3/d11_micro_std_vcp_v3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v3/d11_micro_std_vcp_v3.pdf -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4-layers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4-layers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_std_vcp_v4/d11_micro_vcp_v4.pdf -------------------------------------------------------------------------------- /hardware/d11_micro_usb_std/d11_micro_usb_std.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_usb_std/d11_micro_usb_std.pdf -------------------------------------------------------------------------------- /hardware/d11_micro_usb_std/d11_micro_usb_std_gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_usb_std/d11_micro_usb_std_gerber.zip -------------------------------------------------------------------------------- /hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2-layers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2-layers.zip -------------------------------------------------------------------------------- /hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_micro_usb_std_v2/d11_micro_usb_std_v2.pdf -------------------------------------------------------------------------------- /hardware/d11_pogo/d11_pogo-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_pogo/d11_pogo-gerbers.zip -------------------------------------------------------------------------------- /hardware/d11_pogo/d11_pogo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_pogo/d11_pogo.pdf -------------------------------------------------------------------------------- /hardware/d11_usb_mini/d11_usb_mini.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_usb_mini/d11_usb_mini.pdf -------------------------------------------------------------------------------- /hardware/d11_usb_mini/d11_usb_mini_gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_usb_mini/d11_usb_mini_gerber.zip -------------------------------------------------------------------------------- /hardware/d11_usb_std/d11_usb_std_gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/d11_usb_std/d11_usb_std_gerber.zip -------------------------------------------------------------------------------- /hardware/m484-dap/.gitignore: -------------------------------------------------------------------------------- 1 | output/* 2 | !output/*.pdf 3 | !output/*.zip 4 | fp-info-cache 5 | 6 | -------------------------------------------------------------------------------- /hardware/m484-dap/m484-dap.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.3100000023841858 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": true, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fcffff_80000001", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "m484-dap.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hardware/m484-dap/output/m484-dap-Assembly.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/m484-dap/output/m484-dap-Assembly.pdf -------------------------------------------------------------------------------- /hardware/m484-dap/output/m484-dap-gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/m484-dap/output/m484-dap-gerbers.zip -------------------------------------------------------------------------------- /hardware/m484-dap/output/m484-dap.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ataradov/free-dap/49a30aa350828b6ce16c09620c8d65985a7fdda8/hardware/m484-dap/output/m484-dap.pdf -------------------------------------------------------------------------------- /hardware/m484-dap/pcb.kicad_wks: -------------------------------------------------------------------------------- 1 | (kicad_wks (version 20210606) (generator pl_editor) 2 | (setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15) 3 | (left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10)) 4 | (line (name "segm1:Line") (start 0 0) (end 0 0)) 5 | ) 6 | -------------------------------------------------------------------------------- /hardware/m484-dap/sch.kicad_wks: -------------------------------------------------------------------------------- 1 | (kicad_wks (version 20210606) (generator pl_editor) 2 | (setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15) 3 | (left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10)) 4 | (rect (name "") (start 0 0 ltcorner) (end 0 0) (repeat 2) (incrx 2) (incry 2)) 5 | (line (name "") (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50)) 6 | (tbtext "1" (name "") (pos 25 1 ltcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50)) 7 | (line (name "") (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50)) 8 | (tbtext "1" (name "") (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50)) 9 | (line (name "") (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50)) 10 | (tbtext "A" (name "") (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50)) 11 | (line (name "") (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50)) 12 | (tbtext "A" (name "") (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50)) 13 | (tbtext "${TITLE}${SHEETNAME} ${FILENAME}, rev ${REVISION} (${ISSUE_DATE}), page ${#} of ${##}" (name "") (pos 3 4) (justify right) (comment "Sheet id") 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /platform/m484/hal_config.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _HAL_CONFIG_H_ 5 | #define _HAL_CONFIG_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "M480.h" 9 | #include "hal_gpio.h" 10 | 11 | /*- Definitions -------------------------------------------------------------*/ 12 | //#define HAL_BOARD_GENERIC 13 | #define HAL_BOARD_M484_DAP 14 | 15 | #if defined(HAL_BOARD_GENERIC) 16 | #define HAL_CONFIG_ENABLE_VCP 17 | 18 | HAL_GPIO_PIN(SWCLK_TCK, B, 0) 19 | HAL_GPIO_PIN(SWDIO_TMS, B, 1) 20 | HAL_GPIO_PIN(TDI, B, 2) 21 | HAL_GPIO_PIN(TDO, B, 3) 22 | HAL_GPIO_PIN(nRESET, B, 4) 23 | 24 | HAL_GPIO_PIN(VCP_STATUS, A, 5); 25 | HAL_GPIO_PIN(DAP_STATUS, C, 14); 26 | 27 | HAL_GPIO_PIN(BOOT_ENTER, A, 7); 28 | 29 | HAL_GPIO_PIN(UART_RX, A, 0) 30 | HAL_GPIO_PIN(UART_TX, A, 1) 31 | 32 | #define UART_PER UART0 33 | #define UART_RX_MPF 7 34 | #define UART_TX_MPF 7 35 | #define UART_APBCLK_EN CLK_APBCLK0_UART0CKEN_Msk 36 | #define UART_CLKSEL_REG CLKSEL1 37 | #define UART_CLKSEL_POS CLK_CLKSEL1_UART0SEL_Pos 38 | #define UART_CLKSEL_MSK CLK_CLKSEL1_UART0SEL_Msk 39 | #define UART_IRQ_INDEX UART0_IRQn 40 | #define UART_IRQ_HANDLER irq_handler_uart0 41 | #define UART_CLOCK 192000000 42 | 43 | #elif defined(HAL_BOARD_M484_DAP) 44 | HAL_GPIO_PIN(SWCLK_TCK, B, 2) 45 | HAL_GPIO_PIN(SWDIO_TMS, B, 5) 46 | HAL_GPIO_PIN(TDI, A, 8) 47 | HAL_GPIO_PIN(TDO, A, 11) 48 | HAL_GPIO_PIN(nRESET, F, 5) 49 | 50 | HAL_GPIO_PIN(DAP_STATUS, B, 7); 51 | 52 | HAL_GPIO_PIN(BOOT_ENTER, A, 6); 53 | 54 | #else 55 | #error No board defined 56 | #endif 57 | 58 | #endif // _HAL_CONFIG_H_ 59 | 60 | -------------------------------------------------------------------------------- /platform/m484/include/NuMicro.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file NuMicro.h 3 | * @version V1.00 4 | * @brief NuMicro peripheral access layer header file. 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved. 8 | *****************************************************************************/ 9 | #ifndef __NUMICRO_H__ 10 | #define __NUMICRO_H__ 11 | 12 | #include "M480.h" 13 | 14 | #endif /* __NUMICRO_H__ */ 15 | 16 | 17 | -------------------------------------------------------------------------------- /platform/m484/include/system_M480.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_M480.h 3 | * @version V1.00 4 | * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File for M480 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved. 8 | *****************************************************************************/ 9 | 10 | #ifndef __SYSTEM_M480_H__ 11 | #define __SYSTEM_M480_H__ 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include 18 | 19 | 20 | /*---------------------------------------------------------------------------- 21 | Define clocks 22 | *----------------------------------------------------------------------------*/ 23 | 24 | #ifndef __HSI 25 | #define __HSI (12000000UL) /*!< PLL default output is 50MHz */ 26 | #endif 27 | 28 | #ifndef __HXT 29 | #define __HXT (12000000UL) /*!< External Crystal Clock Frequency */ 30 | #endif 31 | 32 | #ifndef __LXT 33 | #define __LXT (32768UL) /*!< External Crystal Clock Frequency 32.768KHz */ 34 | #endif 35 | 36 | #define __HIRC (12000000UL) /*!< Internal 12M RC Oscillator Frequency */ 37 | #define __LIRC (10000UL) /*!< Internal 10K RC Oscillator Frequency */ 38 | #define __SYS_OSC_CLK ( ___HSI) /* Main oscillator frequency */ 39 | 40 | 41 | #define __SYSTEM_CLOCK (1UL*__HXT) 42 | 43 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 44 | extern uint32_t CyclesPerUs; /*!< Cycles per micro second */ 45 | extern uint32_t PllClock; /*!< PLL Output Clock Frequency */ 46 | 47 | 48 | /** 49 | * Initialize the system 50 | * 51 | * @param none 52 | * @return none 53 | * 54 | * @brief Setup the micro controller system. 55 | * Initialize the System and update the SystemCoreClock variable. 56 | */ 57 | extern void SystemInit (void); 58 | 59 | /** 60 | * Update SystemCoreClock variable 61 | * 62 | * @param none 63 | * @return none 64 | * 65 | * @brief Updates the SystemCoreClock with current core Clock 66 | * retrieved from cpu registers. 67 | */ 68 | extern void SystemCoreClockUpdate (void); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* __SYSTEM_M480_H__ */ 75 | 76 | /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/ 77 | -------------------------------------------------------------------------------- /platform/m484/linker/m484.ld: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-License-Identifier: BSD-3-Clause 3 | Copyright (c) 2022, Alex Taradov . All rights reserved. 4 | */ 5 | 6 | MEMORY 7 | { 8 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000 /* 512k */ 9 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128k */ 10 | } 11 | 12 | __top_flash = ORIGIN(flash) + LENGTH(flash); 13 | __top_ram = ORIGIN(ram) + LENGTH(ram); 14 | 15 | ENTRY(irq_handler_reset) 16 | 17 | SECTIONS 18 | { 19 | .text : ALIGN(4) 20 | { 21 | FILL(0xff) 22 | KEEP(*(.rom_vectors)) 23 | KEEP(*(.reset_handler)) 24 | . = ALIGN(4); 25 | } > flash 26 | 27 | . = ALIGN(4); 28 | _etext = .; 29 | 30 | .uninit_RESERVED : ALIGN(4) 31 | { 32 | KEEP(*(.bss.$RESERVED*)) 33 | } > ram 34 | 35 | .data : ALIGN(4) 36 | { 37 | FILL(0xff) 38 | _data = .; 39 | *(.vectors) 40 | *(.text*) 41 | *(.rodata) 42 | *(.rodata.*) 43 | *(.ramfunc .ramfunc.*); 44 | *(vtable) 45 | *(.data*) 46 | . = ALIGN(4); 47 | _edata = .; 48 | } > ram AT > flash 49 | 50 | .bss : ALIGN(4) 51 | { 52 | _bss = .; 53 | *(.bss*) 54 | *(COMMON) 55 | . = ALIGN(4); 56 | _ebss = .; 57 | PROVIDE(_end = .); 58 | } > ram 59 | 60 | PROVIDE(_stack_top = __top_ram - 0); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /platform/m484/make/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /platform/m484/make/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap_m484_nobl 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | 12 | ifeq ($(OS), Windows_NT) 13 | MKDIR = gmkdir 14 | else 15 | MKDIR = mkdir 16 | endif 17 | 18 | CFLAGS += -W -Wall --std=gnu11 -Os 19 | CFLAGS += -fno-diagnostics-show-caret 20 | CFLAGS += -fdata-sections -ffunction-sections 21 | CFLAGS += -funsigned-char -funsigned-bitfields 22 | CFLAGS += -mcpu=cortex-m4 -mthumb 23 | CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 24 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 25 | 26 | LDFLAGS += -mcpu=cortex-m4 -mthumb 27 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 28 | LDFLAGS += -Wl,--gc-sections 29 | LDFLAGS += -Wl,--script=../linker/m484.ld 30 | 31 | INCLUDES += \ 32 | -I../include \ 33 | -I../usb \ 34 | -I../../.. \ 35 | -I.. 36 | 37 | SRCS += \ 38 | ../main.c \ 39 | ../uart.c \ 40 | ../../../dap.c \ 41 | ../startup_m480.c \ 42 | ../usb/usb_m484.c \ 43 | ../usb/usb_std.c \ 44 | ../usb/usb_cdc.c \ 45 | ../usb/usb_hid.c \ 46 | ../usb/usb_winusb.c \ 47 | ../usb_descriptors.c \ 48 | 49 | DEFINES += \ 50 | -DDONT_USE_CMSIS_INIT \ 51 | 52 | CFLAGS += $(INCLUDES) $(DEFINES) 53 | 54 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 55 | 56 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size 57 | 58 | $(BUILD)/$(BIN).elf: $(OBJS) 59 | @echo LD $@ 60 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 61 | 62 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 63 | @echo OBJCOPY $@ 64 | @$(OBJCOPY) -O ihex $^ $@ 65 | 66 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 67 | @echo OBJCOPY $@ 68 | @$(OBJCOPY) -O binary $^ $@ 69 | 70 | %.o: 71 | @echo CC $@ 72 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 73 | 74 | directory: 75 | @$(MKDIR) -p $(BUILD) 76 | 77 | size: $(BUILD)/$(BIN).elf 78 | @echo size: 79 | @$(SIZE) -t $^ 80 | 81 | clean: 82 | @echo clean 83 | @-rm -rf $(BUILD) 84 | 85 | -include $(wildcard $(BUILD)/*.d) 86 | 87 | -------------------------------------------------------------------------------- /platform/m484/uart.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2017-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _UART_H_ 5 | #define _UART_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_cdc.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void uart_init(usb_cdc_line_coding_t *line_coding); 14 | void uart_close(void); 15 | bool uart_write_byte(int byte); 16 | bool uart_read_byte(int *byte); 17 | void uart_set_break(bool brk); 18 | 19 | #endif // _UART_H_ 20 | 21 | -------------------------------------------------------------------------------- /platform/m484/usb/usb.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_H_ 5 | #define _USB_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_descriptors.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void usb_hw_init(void); 14 | void usb_attach(void); 15 | void usb_detach(void); 16 | void usb_configure_endpoint(usb_endpoint_descriptor_t *ep_desc); 17 | bool usb_endpoint_configured(int ep, int dir); 18 | int usb_endpoint_get_status(int ep, int dir); 19 | void usb_endpoint_set_feature(int ep, int dir); 20 | void usb_endpoint_clear_feature(int ep, int dir); 21 | void usb_set_address(int address); 22 | void usb_send(int ep, uint8_t *data, int size); 23 | void usb_recv(int ep, uint8_t *data, int size); 24 | void usb_control_send_zlp(void); 25 | void usb_control_stall(void); 26 | void usb_control_send(uint8_t *data, int size); 27 | void usb_control_recv(void (*callback)(uint8_t *data, int size)); 28 | void usb_task(void); 29 | 30 | void usb_configuration_callback(int config); 31 | 32 | #endif // _USB_H_ 33 | 34 | -------------------------------------------------------------------------------- /platform/m484/usb/usb_hid.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_hid.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | void usb_hid_init(void) 14 | { 15 | usb_set_send_callback(USB_HID_EP_SEND, usb_hid_send_callback); 16 | usb_set_recv_callback(USB_HID_EP_RECV, usb_hid_recv_callback); 17 | } 18 | 19 | //----------------------------------------------------------------------------- 20 | void usb_hid_send(uint8_t *data, int size) 21 | { 22 | usb_send(USB_HID_EP_SEND, data, size); 23 | } 24 | 25 | //----------------------------------------------------------------------------- 26 | void usb_hid_recv(uint8_t *data, int size) 27 | { 28 | usb_recv(USB_HID_EP_RECV, data, size); 29 | } 30 | 31 | //----------------------------------------------------------------------------- 32 | bool usb_hid_handle_request(usb_request_t *request) 33 | { 34 | int length = request->wLength; 35 | 36 | switch (USB_CMD_VALUE(request)) 37 | { 38 | case USB_CMD(IN, INTERFACE, STANDARD, GET_DESCRIPTOR): 39 | { 40 | length = USB_LIMIT(length, sizeof(usb_hid_report_descriptor)); 41 | 42 | usb_control_send((uint8_t *)usb_hid_report_descriptor, length); 43 | } break; 44 | 45 | default: 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /platform/m484/usb/usb_hid.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_HID_H_ 5 | #define _USB_HID_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | 10 | /*- Definitions -------------------------------------------------------------*/ 11 | #define USB_HID_BDC_V1_11 0x0111 12 | 13 | #define USB_HID_NO_COUNTRY_CODE 0 14 | 15 | enum 16 | { 17 | USB_HID_GET_REPORT = 0x01, 18 | USB_HID_GET_IDLE = 0x02, 19 | USB_HID_GET_PROTOCOL = 0x03, 20 | USB_HID_SET_REPORT = 0x09, 21 | USB_HID_SET_IDLE = 0x0a, 22 | USB_HID_SET_PROTOCOL = 0x0b, 23 | }; 24 | 25 | enum 26 | { 27 | USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class 28 | }; 29 | 30 | enum 31 | { 32 | USB_HID_SUB_CLASS_NOBOOT = 0x00, 33 | USB_HID_SUB_CLASS_BOOT = 0x01, 34 | }; 35 | 36 | enum 37 | { 38 | USB_HID_PROTOCOL_GENERIC = 0x00, 39 | USB_HID_PROTOCOL_KEYBOARD = 0x01, 40 | USB_HID_PROTOCOL_MOUSE = 0x02, 41 | }; 42 | 43 | enum 44 | { 45 | USB_HID_DESCRIPTOR = 0x21, 46 | USB_HID_REPORT_DESCRIPTOR = 0x22, 47 | USB_HID_PHYSICAL_DESCRIPTOR = 0x23, 48 | }; 49 | 50 | enum 51 | { 52 | USB_HID_REPORT_TYPE_INPUT = 1, 53 | USB_HID_REPORT_TYPE_OUTPUT = 2, 54 | USB_HID_REPORT_TYPE_FEATURE = 3, 55 | }; 56 | 57 | enum 58 | { 59 | USB_HID_PROCOTOL_BOOT = 0, 60 | USB_HID_PROCOTOL_REPORT = 1, 61 | }; 62 | 63 | /*- Types -------------------------------------------------------------------*/ 64 | typedef struct USB_PACK 65 | { 66 | uint8_t bLength; 67 | uint8_t bDescriptorType; 68 | uint16_t bcdHID; 69 | uint8_t bCountryCode; 70 | uint8_t bNumDescriptors; 71 | uint8_t bDescriptorType1; 72 | uint16_t wDescriptorLength; 73 | } usb_hid_descriptor_t; 74 | 75 | /*- Prototypes --------------------------------------------------------------*/ 76 | void usb_hid_init(void); 77 | bool usb_hid_handle_request(usb_request_t *request); 78 | void usb_hid_send(uint8_t *data, int size); 79 | void usb_hid_recv(uint8_t *data, int size); 80 | 81 | void usb_hid_send_callback(void); 82 | void usb_hid_recv_callback(int size); 83 | 84 | #endif // _USB_HID_H_ 85 | -------------------------------------------------------------------------------- /platform/m484/usb/usb_winusb.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_winusb.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | bool usb_winusb_handle_request(usb_request_t *request) 14 | { 15 | int length = request->wLength; 16 | 17 | switch (USB_CMD_VALUE(request)) 18 | { 19 | case USB_CMD(IN, DEVICE, VENDOR, WINUSB_VENDOR_CODE): 20 | { 21 | if (USB_WINUSB_DESCRIPTOR_INDEX == request->wIndex) 22 | { 23 | length = USB_LIMIT(length, sizeof(usb_msos_descriptor_set_t)); 24 | usb_control_send((uint8_t *)&usb_msos_descriptor_set, length); 25 | } 26 | else 27 | { 28 | return false; 29 | } 30 | } break; 31 | 32 | default: 33 | return false; 34 | } 35 | 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /platform/rp2040/hal_config.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _HAL_CONFIG_H_ 5 | #define _HAL_CONFIG_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "hal_gpio.h" 9 | 10 | /*- Definitions -------------------------------------------------------------*/ 11 | HAL_GPIO_PIN(SWCLK_TCK, 0, 11, sio_11) 12 | HAL_GPIO_PIN(SWDIO_TMS, 0, 12, sio_12) 13 | HAL_GPIO_PIN(TDI, 0, 13, sio_13) 14 | HAL_GPIO_PIN(TDO, 0, 14, sio_14) 15 | HAL_GPIO_PIN(nRESET, 0, 15, sio_15) 16 | 17 | HAL_GPIO_PIN(VCP_STATUS, 0, 2, sio_2); 18 | HAL_GPIO_PIN(DAP_STATUS, 0, 25, sio_25); 19 | 20 | HAL_GPIO_PIN(UART_TX, 0, 0, uart0_tx) 21 | HAL_GPIO_PIN(UART_RX, 0, 1, uart0_rx) 22 | 23 | #define UART_PER UART0 24 | #define UART_RESET_MASK RESETS_RESET_uart0_Msk 25 | #define UART_IRQ_INDEX UART0_IRQ_IRQn 26 | #define UART_IRQ_HANDLER irq_handler_uart0 27 | #define UART_CLOCK 120000000 28 | 29 | #endif // _HAL_CONFIG_H_ 30 | 31 | 32 | -------------------------------------------------------------------------------- /platform/rp2040/hal_gpio.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2021, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _HAL_GPIO_H_ 5 | #define _HAL_GPIO_H_ 6 | 7 | /*- Definitions -------------------------------------------------------------*/ 8 | #define HAL_GPIO_PIN(name, port, pin, func) \ 9 | static inline void HAL_GPIO_##name##_set(void) \ 10 | { \ 11 | SIO->GPIO_OUT_SET = (1 << pin); \ 12 | (void)HAL_GPIO_##name##_set; \ 13 | } \ 14 | \ 15 | static inline void HAL_GPIO_##name##_clr(void) \ 16 | { \ 17 | SIO->GPIO_OUT_CLR = (1 << pin); \ 18 | (void)HAL_GPIO_##name##_clr; \ 19 | } \ 20 | \ 21 | static inline void HAL_GPIO_##name##_toggle(void) \ 22 | { \ 23 | SIO->GPIO_OUT_XOR = (1 << pin); \ 24 | (void)HAL_GPIO_##name##_toggle; \ 25 | } \ 26 | \ 27 | static inline void HAL_GPIO_##name##_write(int value) \ 28 | { \ 29 | if (value) \ 30 | SIO->GPIO_OUT_SET = (1 << pin); \ 31 | else \ 32 | SIO->GPIO_OUT_CLR = (1 << pin); \ 33 | (void)HAL_GPIO_##name##_write; \ 34 | } \ 35 | \ 36 | static inline void HAL_GPIO_##name##_in(void) \ 37 | { \ 38 | SIO->GPIO_OE_CLR = (1 << pin); \ 39 | IO_BANK##port->GPIO##pin##_CTRL = IO_BANK##port##_GPIO##pin##_CTRL_FUNCSEL_sio_##pin; \ 40 | PADS_BANK##port##_CLR->GPIO##pin = PADS_BANK##port##_GPIO##pin##_PDE_Msk | PADS_BANK##port##_GPIO##pin##_PUE_Msk; \ 41 | PADS_BANK##port##_SET->GPIO##pin = PADS_BANK##port##_GPIO##pin##_IE_Msk; \ 42 | (void)HAL_GPIO_##name##_in; \ 43 | } \ 44 | \ 45 | static inline void HAL_GPIO_##name##_out(void) \ 46 | { \ 47 | SIO->GPIO_OE_SET = (1 << pin); \ 48 | IO_BANK##port->GPIO##pin##_CTRL = IO_BANK##port##_GPIO##pin##_CTRL_FUNCSEL_sio_##pin; \ 49 | (void)HAL_GPIO_##name##_out; \ 50 | } \ 51 | \ 52 | static inline void HAL_GPIO_##name##_init(void) \ 53 | { \ 54 | IO_BANK##port->GPIO##pin##_CTRL = IO_BANK##port##_GPIO##pin##_CTRL_FUNCSEL_##func; \ 55 | (void)HAL_GPIO_##name##_init; \ 56 | } \ 57 | \ 58 | static inline void HAL_GPIO_##name##_pullup(void) \ 59 | { \ 60 | PADS_BANK##port##_SET->GPIO##pin = PADS_BANK##port##_GPIO##pin##_PUE_Msk; \ 61 | PADS_BANK##port##_CLR->GPIO##pin = PADS_BANK##port##_GPIO##pin##_PDE_Msk; \ 62 | (void)HAL_GPIO_##name##_pullup; \ 63 | } \ 64 | \ 65 | static inline void HAL_GPIO_##name##_pulldown(void) \ 66 | { \ 67 | PADS_BANK##port##_SET->GPIO##pin = PADS_BANK##port##_GPIO##pin##_PDE_Msk; \ 68 | PADS_BANK##port##_CLR->GPIO##pin = PADS_BANK##port##_GPIO##pin##_PUE_Msk; \ 69 | (void)HAL_GPIO_##name##_pulldown; \ 70 | } \ 71 | \ 72 | static inline int HAL_GPIO_##name##_read(void) \ 73 | { \ 74 | return (SIO->GPIO_IN & (1 << pin)) != 0; \ 75 | (void)HAL_GPIO_##name##_read; \ 76 | } \ 77 | \ 78 | static inline void HAL_GPIO_##name##_funcsel(int fn) \ 79 | { \ 80 | IO_BANK##port->GPIO##pin##_CTRL_b.FUNCSEL = fn; \ 81 | (void)HAL_GPIO_##name##_funcsel; \ 82 | } \ 83 | 84 | #endif // _HAL_GPIO_H_ 85 | 86 | -------------------------------------------------------------------------------- /platform/rp2040/include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.4 5 | * @date 23. July 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 4U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /platform/rp2040/linker/rp2040.ld: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-License-Identifier: BSD-3-Clause 3 | Copyright (c) 2021, Alex Taradov . All rights reserved. 4 | */ 5 | 6 | MEMORY 7 | { 8 | boot (rx) : ORIGIN = 0x10000000, LENGTH = 256 9 | flash (rx) : ORIGIN = 0x10000100, LENGTH = 2048K - 256 10 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 264K 11 | } 12 | 13 | ENTRY(boot_entry) 14 | 15 | SECTIONS 16 | { 17 | .boot : ALIGN(4) 18 | { 19 | KEEP(*(.boot.entry)) 20 | *(.boot*) 21 | . = 256-4; 22 | LONG(0xcccccccc) /* CRC */ 23 | } > boot 24 | 25 | .text : ALIGN(4) 26 | { 27 | _text = .; 28 | KEEP(*(.vectors)) 29 | *(.text*) 30 | *(.rodata) 31 | *(.rodata.*) 32 | . = ALIGN(4); 33 | _etext = .; 34 | } > ram AT > flash 35 | 36 | .data : ALIGN(4) 37 | { 38 | _data = .; 39 | *(.ramfunc .ramfunc.*); 40 | *(vtable) 41 | *(.data*) 42 | . = ALIGN(4); 43 | _edata = .; 44 | } > ram AT > flash 45 | 46 | .bss : ALIGN(4) 47 | { 48 | _bss = .; 49 | *(.bss*) 50 | *(COMMON) 51 | . = ALIGN(4); 52 | _ebss = .; 53 | } > ram 54 | 55 | PROVIDE(_end = .); 56 | PROVIDE(_text_start = ORIGIN(flash)); 57 | PROVIDE(_stack_top = ORIGIN(ram) + LENGTH(ram)); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /platform/rp2040/make/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /platform/rp2040/make/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap_rp2040 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size release 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | BIN2UF2 = bin2uf2 12 | 13 | ifeq ($(OS), Windows_NT) 14 | MKDIR = gmkdir 15 | else 16 | MKDIR = mkdir 17 | endif 18 | 19 | CFLAGS += -W -Wall --std=gnu11 -Os 20 | CFLAGS += -ffreestanding 21 | CFLAGS += -fno-diagnostics-show-caret 22 | CFLAGS += -fdata-sections -ffunction-sections 23 | CFLAGS += -funsigned-char -funsigned-bitfields 24 | CFLAGS += -mcpu=cortex-m0plus -mthumb 25 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 26 | 27 | LDFLAGS += -mcpu=cortex-m0plus -mthumb 28 | LDFLAGS += -nostartfiles 29 | LDFLAGS += -Wl,--gc-sections 30 | LDFLAGS += -Wl,--script=../linker/rp2040.ld 31 | 32 | INCLUDES += \ 33 | -I../include \ 34 | -I../usb \ 35 | -I../../.. \ 36 | -I.. 37 | 38 | SRCS += \ 39 | ../main.c \ 40 | ../uart.c \ 41 | ../usb/usb_rp2040.c \ 42 | ../usb/usb_std.c \ 43 | ../usb/usb_cdc.c \ 44 | ../usb/usb_hid.c \ 45 | ../usb/usb_winusb.c \ 46 | ../usb_descriptors.c \ 47 | ../startup_rp2040.c \ 48 | ../../../dap.c \ 49 | 50 | DEFINES += \ 51 | 52 | CFLAGS += $(INCLUDES) $(DEFINES) 53 | 54 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 55 | 56 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 release size 57 | 58 | $(BUILD)/$(BIN).elf: $(OBJS) 59 | @echo LD $@ 60 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 61 | 62 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 63 | @echo OBJCOPY $@ 64 | @$(OBJCOPY) -O ihex $^ $@ 65 | 66 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 67 | @echo OBJCOPY $@ 68 | @$(OBJCOPY) -O binary $^ $@ 69 | 70 | $(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin 71 | @echo BIN2UF2 $@ 72 | @$(BIN2UF2) -i $^ -o $@ 73 | 74 | %.o: 75 | @echo CC $@ 76 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 77 | 78 | release: $(BUILD)/$(BIN).uf2 79 | @echo release 80 | @cp $(BUILD)/$(BIN).uf2 ../../../bin/ 81 | 82 | directory: 83 | @$(MKDIR) -p $(BUILD) 84 | 85 | size: $(BUILD)/$(BIN).elf 86 | @echo size: 87 | @$(SIZE) -t $^ 88 | 89 | clean: 90 | @echo clean 91 | @-rm -rf $(BUILD) 92 | 93 | -include $(wildcard $(BUILD)/*.d) 94 | 95 | -------------------------------------------------------------------------------- /platform/rp2040/uart.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _UART_H_ 5 | #define _UART_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_cdc.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void uart_init(usb_cdc_line_coding_t *line_coding); 14 | void uart_close(void); 15 | bool uart_write_byte(int byte); 16 | bool uart_read_byte(int *byte); 17 | void uart_set_break(bool brk); 18 | 19 | #endif // _UART_H_ 20 | 21 | -------------------------------------------------------------------------------- /platform/rp2040/usb/usb.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_H_ 5 | #define _USB_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_descriptors.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void usb_hw_init(void); 14 | void usb_attach(void); 15 | void usb_detach(void); 16 | void usb_configure_endpoint(usb_endpoint_descriptor_t *ep_desc); 17 | bool usb_endpoint_configured(int ep, int dir); 18 | int usb_endpoint_get_status(int ep, int dir); 19 | void usb_endpoint_set_feature(int ep, int dir); 20 | void usb_endpoint_clear_feature(int ep, int dir); 21 | void usb_set_address(int address); 22 | void usb_send(int ep, uint8_t *data, int size); 23 | void usb_recv(int ep, uint8_t *data, int size); 24 | void usb_control_send_zlp(void); 25 | void usb_control_stall(void); 26 | void usb_control_send(uint8_t *data, int size); 27 | void usb_control_recv(void (*callback)(uint8_t *data, int size)); 28 | void usb_task(void); 29 | 30 | void usb_configuration_callback(int config); 31 | 32 | #endif // _USB_H_ 33 | 34 | -------------------------------------------------------------------------------- /platform/rp2040/usb/usb_hid.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_hid.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | void usb_hid_init(void) 14 | { 15 | usb_set_send_callback(USB_HID_EP_SEND, usb_hid_send_callback); 16 | usb_set_recv_callback(USB_HID_EP_RECV, usb_hid_recv_callback); 17 | } 18 | 19 | //----------------------------------------------------------------------------- 20 | void usb_hid_send(uint8_t *data, int size) 21 | { 22 | usb_send(USB_HID_EP_SEND, data, size); 23 | } 24 | 25 | //----------------------------------------------------------------------------- 26 | void usb_hid_recv(uint8_t *data, int size) 27 | { 28 | usb_recv(USB_HID_EP_RECV, data, size); 29 | } 30 | 31 | //----------------------------------------------------------------------------- 32 | bool usb_hid_handle_request(usb_request_t *request) 33 | { 34 | int length = request->wLength; 35 | 36 | switch (USB_CMD_VALUE(request)) 37 | { 38 | case USB_CMD(IN, INTERFACE, STANDARD, GET_DESCRIPTOR): 39 | { 40 | length = USB_LIMIT(length, sizeof(usb_hid_report_descriptor)); 41 | 42 | usb_control_send((uint8_t *)usb_hid_report_descriptor, length); 43 | } break; 44 | 45 | default: 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /platform/rp2040/usb/usb_hid.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_HID_H_ 5 | #define _USB_HID_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | 10 | /*- Definitions -------------------------------------------------------------*/ 11 | enum 12 | { 13 | USB_HID_DESCRIPTOR = 0x21, 14 | USB_HID_REPORT_DESCRIPTOR = 0x22, 15 | USB_HID_PHYSICAL_DESCRIPTOR = 0x23, 16 | }; 17 | 18 | enum 19 | { 20 | USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class 21 | }; 22 | 23 | /*- Types -------------------------------------------------------------------*/ 24 | typedef struct USB_PACK 25 | { 26 | uint8_t bLength; 27 | uint8_t bDescriptorType; 28 | uint16_t bcdHID; 29 | uint8_t bCountryCode; 30 | uint8_t bNumDescriptors; 31 | uint8_t bDescriptorType1; 32 | uint16_t wDescriptorLength; 33 | } usb_hid_descriptor_t; 34 | 35 | /*- Prototypes --------------------------------------------------------------*/ 36 | void usb_hid_init(void); 37 | bool usb_hid_handle_request(usb_request_t *request); 38 | void usb_hid_send(uint8_t *data, int size); 39 | void usb_hid_recv(uint8_t *data, int size); 40 | 41 | void usb_hid_send_callback(void); 42 | void usb_hid_recv_callback(int size); 43 | 44 | #endif // _USB_HID_H_ 45 | -------------------------------------------------------------------------------- /platform/rp2040/usb/usb_winusb.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_winusb.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | bool usb_winusb_handle_request(usb_request_t *request) 14 | { 15 | int length = request->wLength; 16 | 17 | switch (USB_CMD_VALUE(request)) 18 | { 19 | case USB_CMD(IN, DEVICE, VENDOR, WINUSB_VENDOR_CODE): 20 | { 21 | if (USB_WINUSB_DESCRIPTOR_INDEX == request->wIndex) 22 | { 23 | length = USB_LIMIT(length, sizeof(usb_msos_descriptor_set_t)); 24 | usb_control_send((uint8_t *)&usb_msos_descriptor_set, length); 25 | } 26 | else 27 | { 28 | return false; 29 | } 30 | } break; 31 | 32 | default: 33 | return false; 34 | } 35 | 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /platform/rp2040/usb_descriptors.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_DESCRIPTORS_H_ 5 | #define _USB_DESCRIPTORS_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | #include "usb_cdc.h" 10 | #include "usb_hid.h" 11 | #include "usb_winusb.h" 12 | 13 | /*- Definitions -------------------------------------------------------------*/ 14 | #define USB_ENABLE_BOS 15 | #define USB_BCD_VERSION 0x0210 16 | 17 | enum 18 | { 19 | USB_STR_ZERO, 20 | USB_STR_MANUFACTURER, 21 | USB_STR_PRODUCT, 22 | USB_STR_SERIAL_NUMBER, 23 | USB_STR_CMSIS_DAP_V1, 24 | USB_STR_CMSIS_DAP_V2, 25 | USB_STR_COM_PORT, 26 | USB_STR_COUNT, 27 | }; 28 | 29 | enum 30 | { 31 | USB_HID_EP_SEND = 1, 32 | USB_HID_EP_RECV = 2, 33 | USB_BULK_EP_RECV = 3, 34 | USB_BULK_EP_SEND = 4, 35 | USB_CDC_EP_COMM = 5, 36 | USB_CDC_EP_SEND = 6, 37 | USB_CDC_EP_RECV = 7, 38 | }; 39 | 40 | enum 41 | { 42 | USB_INTF_HID, 43 | USB_INTF_BULK, 44 | USB_INTF_CDC_COMM, 45 | USB_INTF_CDC_DATA, 46 | USB_INTF_COUNT, 47 | }; 48 | 49 | /*- Types -------------------------------------------------------------------*/ 50 | typedef struct USB_PACK 51 | { 52 | usb_configuration_descriptor_t configuration; 53 | 54 | usb_interface_descriptor_t hid_interface; 55 | usb_hid_descriptor_t hid; 56 | usb_endpoint_descriptor_t hid_ep_in; 57 | usb_endpoint_descriptor_t hid_ep_out; 58 | 59 | usb_interface_descriptor_t bulk_interface; 60 | usb_endpoint_descriptor_t bulk_ep_out; 61 | usb_endpoint_descriptor_t bulk_ep_in; 62 | 63 | usb_interface_association_descriptor_t iad; 64 | usb_interface_descriptor_t interface_comm; 65 | usb_cdc_header_functional_descriptor_t cdc_header; 66 | usb_cdc_abstract_control_managment_descriptor_t cdc_acm; 67 | usb_cdc_call_managment_functional_descriptor_t cdc_call_mgmt; 68 | usb_cdc_union_functional_descriptor_t cdc_union; 69 | usb_endpoint_descriptor_t ep_comm; 70 | usb_interface_descriptor_t interface_data; 71 | usb_endpoint_descriptor_t ep_in; 72 | usb_endpoint_descriptor_t ep_out; 73 | } usb_configuration_hierarchy_t; 74 | 75 | typedef struct USB_PACK 76 | { 77 | usb_binary_object_store_descriptor_t bos; 78 | usb_winusb_capability_descriptor_t winusb; 79 | } usb_bos_hierarchy_t; 80 | 81 | typedef struct USB_PACK 82 | { 83 | usb_winusb_subset_header_function_t header; 84 | usb_winusb_feature_compatble_id_t comp_id; 85 | usb_winusb_feature_reg_property_guids_t property; 86 | } usb_msos_descriptor_subset_t; 87 | 88 | typedef struct USB_PACK 89 | { 90 | usb_winusb_set_header_descriptor_t header; 91 | usb_msos_descriptor_subset_t subset; 92 | } usb_msos_descriptor_set_t; 93 | 94 | //----------------------------------------------------------------------------- 95 | extern const usb_device_descriptor_t usb_device_descriptor; 96 | extern const usb_configuration_hierarchy_t usb_configuration_hierarchy; 97 | extern const usb_bos_hierarchy_t usb_bos_hierarchy; 98 | extern const usb_msos_descriptor_set_t usb_msos_descriptor_set; 99 | extern const uint8_t usb_hid_report_descriptor[28]; 100 | extern const usb_string_descriptor_zero_t usb_string_descriptor_zero; 101 | extern const char *usb_strings[]; 102 | extern const usb_class_handler_t usb_class_handlers[3]; 103 | extern char usb_serial_number[16]; 104 | 105 | #endif // _USB_DESCRIPTORS_H_ 106 | -------------------------------------------------------------------------------- /platform/samd11/hal_config.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2017-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _HAL_CONFIG_H_ 5 | #define _HAL_CONFIG_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "samd11.h" 9 | #include "hal_gpio.h" 10 | 11 | /*- Definitions -------------------------------------------------------------*/ 12 | #define HAL_BOARD_STD 13 | //#define HAL_BOARD_VCP_V1 14 | //#define HAL_BOARD_VCP_V3 15 | //#define HAL_BOARD_OBD 16 | 17 | #if defined(HAL_BOARD_CUSTOM) 18 | // Externally supplied board configuration takes precedence 19 | #include HAL_BOARD_CUSTOM 20 | 21 | #elif defined(HAL_BOARD_STD) 22 | #define DAP_CONFIG_ENABLE_JTAG 23 | 24 | HAL_GPIO_PIN(SWCLK_TCK, A, 14) 25 | HAL_GPIO_PIN(SWDIO_TMS, A, 15) 26 | HAL_GPIO_PIN(TDO, A, 9) 27 | HAL_GPIO_PIN(TDI, A, 8) 28 | HAL_GPIO_PIN(nRESET, A, 5) 29 | 30 | HAL_GPIO_PIN(DAP_STATUS, A, 4); 31 | HAL_GPIO_PIN(BOOT_ENTER, A, 31); 32 | 33 | #elif defined(HAL_BOARD_VCP_V1) 34 | #define HAL_CONFIG_ENABLE_VCP 35 | 36 | HAL_GPIO_PIN(SWCLK_TCK, A, 14) 37 | HAL_GPIO_PIN(SWDIO_TMS, A, 15) 38 | HAL_GPIO_PIN(nRESET, A, 9) 39 | 40 | HAL_GPIO_PIN(VCP_STATUS, A, 2); 41 | HAL_GPIO_PIN(DAP_STATUS, A, 4); 42 | HAL_GPIO_PIN(BOOT_ENTER, A, 31); 43 | 44 | HAL_GPIO_PIN(UART_TX, A, 8); 45 | HAL_GPIO_PIN(UART_RX, A, 5); 46 | 47 | #define UART_SERCOM SERCOM0 48 | #define UART_SERCOM_PMUX PORT_PMUX_PMUXE_D_Val 49 | #define UART_SERCOM_GCLK_ID SERCOM0_GCLK_ID_CORE 50 | #define UART_SERCOM_APBCMASK PM_APBCMASK_SERCOM0 51 | #define UART_SERCOM_IRQ_INDEX SERCOM0_IRQn 52 | #define UART_SERCOM_IRQ_HANDLER irq_handler_sercom0 53 | #define UART_SERCOM_TXPO 1 54 | #define UART_SERCOM_RXPO 1 55 | 56 | #elif defined(HAL_BOARD_VCP_V3) 57 | #define HAL_CONFIG_ENABLE_VCP 58 | #define DAP_CONFIG_ENABLE_JTAG 59 | 60 | HAL_GPIO_PIN(SWCLK_TCK, A, 9) 61 | HAL_GPIO_PIN(SWDIO_TMS, A, 8) 62 | HAL_GPIO_PIN(TDI, A, 14) 63 | HAL_GPIO_PIN(TDO, A, 10) 64 | HAL_GPIO_PIN(nRESET, A, 15) 65 | 66 | HAL_GPIO_PIN(VCP_STATUS, A, 3); 67 | HAL_GPIO_PIN(DAP_STATUS, A, 6); 68 | HAL_GPIO_PIN(BOOT_ENTER, A, 31); 69 | 70 | HAL_GPIO_PIN(UART_TX, A, 16); 71 | HAL_GPIO_PIN(UART_RX, A, 17); 72 | 73 | #define UART_SERCOM SERCOM1 74 | #define UART_SERCOM_PMUX PORT_PMUX_PMUXE_C_Val 75 | #define UART_SERCOM_GCLK_ID SERCOM1_GCLK_ID_CORE 76 | #define UART_SERCOM_APBCMASK PM_APBCMASK_SERCOM1 77 | #define UART_SERCOM_IRQ_INDEX SERCOM1_IRQn 78 | #define UART_SERCOM_IRQ_HANDLER irq_handler_sercom1 79 | #define UART_SERCOM_TXPO 1 80 | #define UART_SERCOM_RXPO 3 81 | 82 | #elif defined(HAL_BOARD_OBD) 83 | #define HAL_CONFIG_ENABLE_VCP 84 | 85 | HAL_GPIO_PIN(SWCLK_TCK, A, 9) 86 | HAL_GPIO_PIN(SWDIO_TMS, A, 14) 87 | HAL_GPIO_PIN(nRESET, A, 15) 88 | 89 | HAL_GPIO_PIN(VCP_STATUS, A, 2); 90 | HAL_GPIO_PIN(DAP_STATUS, A, 4); 91 | HAL_GPIO_PIN(BOOT_ENTER, A, 31); 92 | 93 | HAL_GPIO_PIN(UART_TX, A, 8); 94 | HAL_GPIO_PIN(UART_RX, A, 5); 95 | 96 | #define UART_SERCOM SERCOM0 97 | #define UART_SERCOM_PMUX PORT_PMUX_PMUXE_D_Val 98 | #define UART_SERCOM_GCLK_ID SERCOM0_GCLK_ID_CORE 99 | #define UART_SERCOM_APBCMASK PM_APBCMASK_SERCOM0 100 | #define UART_SERCOM_IRQ_INDEX SERCOM0_IRQn 101 | #define UART_SERCOM_IRQ_HANDLER irq_handler_sercom0 102 | #define UART_SERCOM_TXPO 1 103 | #define UART_SERCOM_RXPO 1 104 | 105 | #else 106 | #error No board defined 107 | #endif 108 | 109 | #endif // _HAL_CONFIG_H_ 110 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/dac.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for DAC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_DAC_INSTANCE_ 31 | #define _SAMD11_DAC_INSTANCE_ 32 | 33 | /* ========== Register definition for DAC peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_DAC_CTRLA (0x42002800) /**< \brief (DAC) Control A */ 36 | #define REG_DAC_CTRLB (0x42002801) /**< \brief (DAC) Control B */ 37 | #define REG_DAC_EVCTRL (0x42002802) /**< \brief (DAC) Event Control */ 38 | #define REG_DAC_INTENCLR (0x42002804) /**< \brief (DAC) Interrupt Enable Clear */ 39 | #define REG_DAC_INTENSET (0x42002805) /**< \brief (DAC) Interrupt Enable Set */ 40 | #define REG_DAC_INTFLAG (0x42002806) /**< \brief (DAC) Interrupt Flag Status and Clear */ 41 | #define REG_DAC_STATUS (0x42002807) /**< \brief (DAC) Status */ 42 | #define REG_DAC_DATA (0x42002808) /**< \brief (DAC) Data */ 43 | #define REG_DAC_DATABUF (0x4200280C) /**< \brief (DAC) Data Buffer */ 44 | #else 45 | #define REG_DAC_CTRLA (*(RwReg8 *)0x42002800UL) /**< \brief (DAC) Control A */ 46 | #define REG_DAC_CTRLB (*(RwReg8 *)0x42002801UL) /**< \brief (DAC) Control B */ 47 | #define REG_DAC_EVCTRL (*(RwReg8 *)0x42002802UL) /**< \brief (DAC) Event Control */ 48 | #define REG_DAC_INTENCLR (*(RwReg8 *)0x42002804UL) /**< \brief (DAC) Interrupt Enable Clear */ 49 | #define REG_DAC_INTENSET (*(RwReg8 *)0x42002805UL) /**< \brief (DAC) Interrupt Enable Set */ 50 | #define REG_DAC_INTFLAG (*(RwReg8 *)0x42002806UL) /**< \brief (DAC) Interrupt Flag Status and Clear */ 51 | #define REG_DAC_STATUS (*(RoReg8 *)0x42002807UL) /**< \brief (DAC) Status */ 52 | #define REG_DAC_DATA (*(RwReg16*)0x42002808UL) /**< \brief (DAC) Data */ 53 | #define REG_DAC_DATABUF (*(RwReg16*)0x4200280CUL) /**< \brief (DAC) Data Buffer */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for DAC peripheral ========== */ 57 | #define DAC_DMAC_ID_EMPTY 19 // Index of DMAC EMPTY trigger 58 | #define DAC_GCLK_ID 22 // Index of Generic Clock 59 | 60 | #endif /* _SAMD11_DAC_INSTANCE_ */ 61 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/eic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for EIC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_EIC_INSTANCE_ 31 | #define _SAMD11_EIC_INSTANCE_ 32 | 33 | /* ========== Register definition for EIC peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_EIC_CTRL (0x40001800) /**< \brief (EIC) Control */ 36 | #define REG_EIC_STATUS (0x40001801) /**< \brief (EIC) Status */ 37 | #define REG_EIC_NMICTRL (0x40001802) /**< \brief (EIC) Non-Maskable Interrupt Control */ 38 | #define REG_EIC_NMIFLAG (0x40001803) /**< \brief (EIC) Non-Maskable Interrupt Flag Status and Clear */ 39 | #define REG_EIC_EVCTRL (0x40001804) /**< \brief (EIC) Event Control */ 40 | #define REG_EIC_INTENCLR (0x40001808) /**< \brief (EIC) Interrupt Enable Clear */ 41 | #define REG_EIC_INTENSET (0x4000180C) /**< \brief (EIC) Interrupt Enable Set */ 42 | #define REG_EIC_INTFLAG (0x40001810) /**< \brief (EIC) Interrupt Flag Status and Clear */ 43 | #define REG_EIC_WAKEUP (0x40001814) /**< \brief (EIC) Wake-Up Enable */ 44 | #define REG_EIC_CONFIG0 (0x40001818) /**< \brief (EIC) Configuration 0 */ 45 | #else 46 | #define REG_EIC_CTRL (*(RwReg8 *)0x40001800UL) /**< \brief (EIC) Control */ 47 | #define REG_EIC_STATUS (*(RoReg8 *)0x40001801UL) /**< \brief (EIC) Status */ 48 | #define REG_EIC_NMICTRL (*(RwReg8 *)0x40001802UL) /**< \brief (EIC) Non-Maskable Interrupt Control */ 49 | #define REG_EIC_NMIFLAG (*(RwReg8 *)0x40001803UL) /**< \brief (EIC) Non-Maskable Interrupt Flag Status and Clear */ 50 | #define REG_EIC_EVCTRL (*(RwReg *)0x40001804UL) /**< \brief (EIC) Event Control */ 51 | #define REG_EIC_INTENCLR (*(RwReg *)0x40001808UL) /**< \brief (EIC) Interrupt Enable Clear */ 52 | #define REG_EIC_INTENSET (*(RwReg *)0x4000180CUL) /**< \brief (EIC) Interrupt Enable Set */ 53 | #define REG_EIC_INTFLAG (*(RwReg *)0x40001810UL) /**< \brief (EIC) Interrupt Flag Status and Clear */ 54 | #define REG_EIC_WAKEUP (*(RwReg *)0x40001814UL) /**< \brief (EIC) Wake-Up Enable */ 55 | #define REG_EIC_CONFIG0 (*(RwReg *)0x40001818UL) /**< \brief (EIC) Configuration 0 */ 56 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 57 | 58 | /* ========== Instance parameters for EIC peripheral ========== */ 59 | #define EIC_CONFIG_NUM 1 // Number of CONFIG registers 60 | #define EIC_EXTINT_NUM 8 // Number of External Interrupts 61 | #define EIC_GCLK_ID 5 // Index of Generic Clock 62 | 63 | #endif /* _SAMD11_EIC_INSTANCE_ */ 64 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/gclk.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for GCLK 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_GCLK_INSTANCE_ 31 | #define _SAMD11_GCLK_INSTANCE_ 32 | 33 | /* ========== Register definition for GCLK peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_GCLK_CTRL (0x40000C00) /**< \brief (GCLK) Control */ 36 | #define REG_GCLK_STATUS (0x40000C01) /**< \brief (GCLK) Status */ 37 | #define REG_GCLK_CLKCTRL (0x40000C02) /**< \brief (GCLK) Generic Clock Control */ 38 | #define REG_GCLK_GENCTRL (0x40000C04) /**< \brief (GCLK) Generic Clock Generator Control */ 39 | #define REG_GCLK_GENDIV (0x40000C08) /**< \brief (GCLK) Generic Clock Generator Division */ 40 | #else 41 | #define REG_GCLK_CTRL (*(RwReg8 *)0x40000C00UL) /**< \brief (GCLK) Control */ 42 | #define REG_GCLK_STATUS (*(RoReg8 *)0x40000C01UL) /**< \brief (GCLK) Status */ 43 | #define REG_GCLK_CLKCTRL (*(RwReg16*)0x40000C02UL) /**< \brief (GCLK) Generic Clock Control */ 44 | #define REG_GCLK_GENCTRL (*(RwReg *)0x40000C04UL) /**< \brief (GCLK) Generic Clock Generator Control */ 45 | #define REG_GCLK_GENDIV (*(RwReg *)0x40000C08UL) /**< \brief (GCLK) Generic Clock Generator Division */ 46 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 47 | 48 | /* ========== Instance parameters for GCLK peripheral ========== */ 49 | #define GCLK_GENDIV_BITS 16 50 | #define GCLK_GEN_NUM 6 // Number of Generic Clock Generators 51 | #define GCLK_GEN_NUM_MSB 5 // Number of Generic Clock Generators - 1 52 | #define GCLK_GEN_SOURCE_NUM_MSB 8 // Number of Generic Clock Sources - 1 53 | #define GCLK_NUM 24 // Number of Generic Clock Users 54 | #define GCLK_SOURCE_DFLL48M 7 55 | #define GCLK_SOURCE_DPLL96M 8 56 | #define GCLK_SOURCE_GCLKGEN1 2 57 | #define GCLK_SOURCE_GCLKIN 1 58 | #define GCLK_SOURCE_NUM 9 // Number of Generic Clock Sources 59 | #define GCLK_SOURCE_OSCULP32K 3 60 | #define GCLK_SOURCE_OSC8M 6 61 | #define GCLK_SOURCE_OSC32K 4 62 | #define GCLK_SOURCE_XOSC 0 63 | #define GCLK_SOURCE_XOSC32K 5 64 | 65 | #endif /* _SAMD11_GCLK_INSTANCE_ */ 66 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/nvmctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for NVMCTRL 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_NVMCTRL_INSTANCE_ 31 | #define _SAMD11_NVMCTRL_INSTANCE_ 32 | 33 | /* ========== Register definition for NVMCTRL peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_NVMCTRL_CTRLA (0x41004000) /**< \brief (NVMCTRL) Control A */ 36 | #define REG_NVMCTRL_CTRLB (0x41004004) /**< \brief (NVMCTRL) Control B */ 37 | #define REG_NVMCTRL_PARAM (0x41004008) /**< \brief (NVMCTRL) NVM Parameter */ 38 | #define REG_NVMCTRL_INTENCLR (0x4100400C) /**< \brief (NVMCTRL) Interrupt Enable Clear */ 39 | #define REG_NVMCTRL_INTENSET (0x41004010) /**< \brief (NVMCTRL) Interrupt Enable Set */ 40 | #define REG_NVMCTRL_INTFLAG (0x41004014) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */ 41 | #define REG_NVMCTRL_STATUS (0x41004018) /**< \brief (NVMCTRL) Status */ 42 | #define REG_NVMCTRL_ADDR (0x4100401C) /**< \brief (NVMCTRL) Address */ 43 | #define REG_NVMCTRL_LOCK (0x41004020) /**< \brief (NVMCTRL) Lock Section */ 44 | #else 45 | #define REG_NVMCTRL_CTRLA (*(RwReg16*)0x41004000UL) /**< \brief (NVMCTRL) Control A */ 46 | #define REG_NVMCTRL_CTRLB (*(RwReg *)0x41004004UL) /**< \brief (NVMCTRL) Control B */ 47 | #define REG_NVMCTRL_PARAM (*(RwReg *)0x41004008UL) /**< \brief (NVMCTRL) NVM Parameter */ 48 | #define REG_NVMCTRL_INTENCLR (*(RwReg8 *)0x4100400CUL) /**< \brief (NVMCTRL) Interrupt Enable Clear */ 49 | #define REG_NVMCTRL_INTENSET (*(RwReg8 *)0x41004010UL) /**< \brief (NVMCTRL) Interrupt Enable Set */ 50 | #define REG_NVMCTRL_INTFLAG (*(RwReg8 *)0x41004014UL) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */ 51 | #define REG_NVMCTRL_STATUS (*(RwReg16*)0x41004018UL) /**< \brief (NVMCTRL) Status */ 52 | #define REG_NVMCTRL_ADDR (*(RwReg *)0x4100401CUL) /**< \brief (NVMCTRL) Address */ 53 | #define REG_NVMCTRL_LOCK (*(RwReg16*)0x41004020UL) /**< \brief (NVMCTRL) Lock Section */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for NVMCTRL peripheral ========== */ 57 | #define NVMCTRL_AUX0_ADDRESS 0x00804000 58 | #define NVMCTRL_AUX1_ADDRESS 0x00806000 59 | #define NVMCTRL_AUX2_ADDRESS 0x00808000 60 | #define NVMCTRL_AUX3_ADDRESS 0x0080A000 61 | #define NVMCTRL_CLK_AHB_ID 4 // Index of AHB Clock in PM.AHBMASK register 62 | #define NVMCTRL_FACTORY_WORD_IMPLEMENTED_MASK 0xC0000007FFFFFFFF 63 | #define NVMCTRL_FLASH_SIZE 16384 64 | #define NVMCTRL_LOCKBIT_ADDRESS 0x00802000 65 | #define NVMCTRL_PAGE_HW 32 66 | #define NVMCTRL_PAGE_SIZE 64 67 | #define NVMCTRL_PAGE_W 16 68 | #define NVMCTRL_PMSB 3 69 | #define NVMCTRL_PSZ_BITS 6 70 | #define NVMCTRL_ROW_PAGES 4 71 | #define NVMCTRL_ROW_SIZE 256 72 | #define NVMCTRL_USER_PAGE_ADDRESS 0x00800000 73 | #define NVMCTRL_USER_PAGE_OFFSET 0x00800000 74 | #define NVMCTRL_USER_WORD_IMPLEMENTED_MASK 0xC01FFFFFFFFFFFFF 75 | 76 | #endif /* _SAMD11_NVMCTRL_INSTANCE_ */ 77 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/pac0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC0 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_PAC0_INSTANCE_ 31 | #define _SAMD11_PAC0_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC0 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC0_WPCLR (0x40000000) /**< \brief (PAC0) Write Protection Clear */ 36 | #define REG_PAC0_WPSET (0x40000004) /**< \brief (PAC0) Write Protection Set */ 37 | #else 38 | #define REG_PAC0_WPCLR (*(RwReg *)0x40000000UL) /**< \brief (PAC0) Write Protection Clear */ 39 | #define REG_PAC0_WPSET (*(RwReg *)0x40000004UL) /**< \brief (PAC0) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC0 peripheral ========== */ 43 | #define PAC0_WPROT_DEFAULT_VAL 0x00000000 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD11_PAC0_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/pac1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC1 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_PAC1_INSTANCE_ 31 | #define _SAMD11_PAC1_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC1 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC1_WPCLR (0x41000000) /**< \brief (PAC1) Write Protection Clear */ 36 | #define REG_PAC1_WPSET (0x41000004) /**< \brief (PAC1) Write Protection Set */ 37 | #else 38 | #define REG_PAC1_WPCLR (*(RwReg *)0x41000000UL) /**< \brief (PAC1) Write Protection Clear */ 39 | #define REG_PAC1_WPSET (*(RwReg *)0x41000004UL) /**< \brief (PAC1) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC1 peripheral ========== */ 43 | #define PAC1_WPROT_DEFAULT_VAL 0x00000002 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD11_PAC1_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/pac2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC2 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_PAC2_INSTANCE_ 31 | #define _SAMD11_PAC2_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC2 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC2_WPCLR (0x42000000) /**< \brief (PAC2) Write Protection Clear */ 36 | #define REG_PAC2_WPSET (0x42000004) /**< \brief (PAC2) Write Protection Set */ 37 | #else 38 | #define REG_PAC2_WPCLR (*(RwReg *)0x42000000UL) /**< \brief (PAC2) Write Protection Clear */ 39 | #define REG_PAC2_WPSET (*(RwReg *)0x42000004UL) /**< \brief (PAC2) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC2 peripheral ========== */ 43 | #define PAC2_WPROT_DEFAULT_VAL 0x00001000 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD11_PAC2_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/ptc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PTC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_PTC_INSTANCE_ 31 | #define _SAMD11_PTC_INSTANCE_ 32 | 33 | /* ========== Instance parameters for PTC peripheral ========== */ 34 | #define PTC_GCLK_ID 23 // Index of Generic Clock 35 | 36 | #endif /* _SAMD11_PTC_INSTANCE_ */ 37 | -------------------------------------------------------------------------------- /platform/samd11/include/instance/wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for WDT 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_WDT_INSTANCE_ 31 | #define _SAMD11_WDT_INSTANCE_ 32 | 33 | /* ========== Register definition for WDT peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_WDT_CTRL (0x40001000) /**< \brief (WDT) Control */ 36 | #define REG_WDT_CONFIG (0x40001001) /**< \brief (WDT) Configuration */ 37 | #define REG_WDT_EWCTRL (0x40001002) /**< \brief (WDT) Early Warning Interrupt Control */ 38 | #define REG_WDT_INTENCLR (0x40001004) /**< \brief (WDT) Interrupt Enable Clear */ 39 | #define REG_WDT_INTENSET (0x40001005) /**< \brief (WDT) Interrupt Enable Set */ 40 | #define REG_WDT_INTFLAG (0x40001006) /**< \brief (WDT) Interrupt Flag Status and Clear */ 41 | #define REG_WDT_STATUS (0x40001007) /**< \brief (WDT) Status */ 42 | #define REG_WDT_CLEAR (0x40001008) /**< \brief (WDT) Clear */ 43 | #else 44 | #define REG_WDT_CTRL (*(RwReg8 *)0x40001000UL) /**< \brief (WDT) Control */ 45 | #define REG_WDT_CONFIG (*(RwReg8 *)0x40001001UL) /**< \brief (WDT) Configuration */ 46 | #define REG_WDT_EWCTRL (*(RwReg8 *)0x40001002UL) /**< \brief (WDT) Early Warning Interrupt Control */ 47 | #define REG_WDT_INTENCLR (*(RwReg8 *)0x40001004UL) /**< \brief (WDT) Interrupt Enable Clear */ 48 | #define REG_WDT_INTENSET (*(RwReg8 *)0x40001005UL) /**< \brief (WDT) Interrupt Enable Set */ 49 | #define REG_WDT_INTFLAG (*(RwReg8 *)0x40001006UL) /**< \brief (WDT) Interrupt Flag Status and Clear */ 50 | #define REG_WDT_STATUS (*(RoReg8 *)0x40001007UL) /**< \brief (WDT) Status */ 51 | #define REG_WDT_CLEAR (*(WoReg8 *)0x40001008UL) /**< \brief (WDT) Clear */ 52 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | 54 | /* ========== Instance parameters for WDT peripheral ========== */ 55 | #define WDT_GCLK_ID 3 // Index of Generic Clock 56 | 57 | #endif /* _SAMD11_WDT_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /platform/samd11/include/samd11.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Top header file for SAMD11 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD11_ 31 | #define _SAMD11_ 32 | 33 | /** 34 | * \defgroup SAMD11_definitions SAMD11 Device Definitions 35 | * \brief SAMD11 CMSIS Definitions. 36 | */ 37 | 38 | #if defined(__SAMD11C14A__) || defined(__ATSAMD11C14A__) 39 | #include "samd11c14a.h" 40 | #elif defined(__SAMD11D14AM__) || defined(__ATSAMD11D14AM__) 41 | #include "samd11d14am.h" 42 | #elif defined(__SAMD11D14AS__) || defined(__ATSAMD11D14AS__) 43 | #include "samd11d14as.h" 44 | #elif defined(__SAMD11D14AU__) || defined(__ATSAMD11D14AU__) 45 | #include "samd11d14au.h" 46 | #else 47 | #error Library does not support the specified device. 48 | #endif 49 | 50 | #endif /* _SAMD11_ */ 51 | -------------------------------------------------------------------------------- /platform/samd11/linker/samd11d14_bl_2k.ld: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-License-Identifier: BSD-3-Clause 3 | Copyright (c) 2016-2017, Alex Taradov . All rights reserved. 4 | */ 5 | 6 | MEMORY 7 | { 8 | flash (rx) : ORIGIN = 0x00000800, LENGTH = 14K 9 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K 10 | } 11 | 12 | __top_flash = ORIGIN(flash) + LENGTH(flash); 13 | __top_ram = ORIGIN(ram) + LENGTH(ram); 14 | 15 | ENTRY(irq_handler_reset) 16 | 17 | SECTIONS 18 | { 19 | .text : ALIGN(4) 20 | { 21 | FILL(0xff) 22 | KEEP(*(.vectors)) 23 | *(.text*) 24 | *(.rodata) 25 | *(.rodata.*) 26 | . = ALIGN(4); 27 | } > flash 28 | 29 | . = ALIGN(4); 30 | _etext = .; 31 | 32 | .uninit_RESERVED : ALIGN(4) 33 | { 34 | KEEP(*(.bss.$RESERVED*)) 35 | } > ram 36 | 37 | .data : ALIGN(4) 38 | { 39 | FILL(0xff) 40 | _data = .; 41 | *(.ramfunc .ramfunc.*); 42 | *(vtable) 43 | *(.data*) 44 | . = ALIGN(4); 45 | _edata = .; 46 | } > ram AT > flash 47 | 48 | .bss : ALIGN(4) 49 | { 50 | _bss = .; 51 | *(.bss*) 52 | *(COMMON) 53 | . = ALIGN(4); 54 | _ebss = .; 55 | PROVIDE(_end = .); 56 | } > ram 57 | 58 | PROVIDE(_stack_top = __top_ram - 0); 59 | } 60 | -------------------------------------------------------------------------------- /platform/samd11/linker/samd11d14_nobl.ld: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-License-Identifier: BSD-3-Clause 3 | Copyright (c) 2016-2017, Alex Taradov . All rights reserved. 4 | */ 5 | 6 | MEMORY 7 | { 8 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x4000 /* 16k */ 9 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x1000 /* 4k */ 10 | } 11 | 12 | __top_flash = ORIGIN(flash) + LENGTH(flash); 13 | __top_ram = ORIGIN(ram) + LENGTH(ram); 14 | 15 | ENTRY(irq_handler_reset) 16 | 17 | SECTIONS 18 | { 19 | .text : ALIGN(4) 20 | { 21 | FILL(0xff) 22 | KEEP(*(.vectors)) 23 | *(.text*) 24 | *(.rodata) 25 | *(.rodata.*) 26 | . = ALIGN(4); 27 | } > flash 28 | 29 | . = ALIGN(4); 30 | _etext = .; 31 | 32 | .uninit_RESERVED : ALIGN(4) 33 | { 34 | KEEP(*(.bss.$RESERVED*)) 35 | } > ram 36 | 37 | .data : ALIGN(4) 38 | { 39 | FILL(0xff) 40 | _data = .; 41 | *(.ramfunc .ramfunc.*); 42 | *(vtable) 43 | *(.data*) 44 | . = ALIGN(4); 45 | _edata = .; 46 | } > ram AT > flash 47 | 48 | .bss : ALIGN(4) 49 | { 50 | _bss = .; 51 | *(.bss*) 52 | *(COMMON) 53 | . = ALIGN(4); 54 | _ebss = .; 55 | PROVIDE(_end = .); 56 | } > ram 57 | 58 | PROVIDE(_stack_top = __top_ram - 0); 59 | } 60 | -------------------------------------------------------------------------------- /platform/samd11/make/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /platform/samd11/make/Makefile_bl_2k: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap_d11_bl_2k 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size dfu 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | 12 | ifeq ($(OS), Windows_NT) 13 | MKDIR = gmkdir 14 | else 15 | MKDIR = mkdir 16 | endif 17 | 18 | CFLAGS += -W -Wall --std=gnu11 -Os 19 | CFLAGS += -fno-diagnostics-show-caret 20 | CFLAGS += -fdata-sections -ffunction-sections 21 | CFLAGS += -funsigned-char -funsigned-bitfields 22 | CFLAGS += -mcpu=cortex-m0plus -mthumb 23 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 24 | CFLAGS += -flto 25 | 26 | LDFLAGS += -mcpu=cortex-m0plus -mthumb 27 | LDFLAGS += -Wl,--gc-sections 28 | LDFLAGS += -Wl,--script=../linker/samd11d14_bl_2k.ld 29 | LDFLAGS += -flto 30 | 31 | INCLUDES += \ 32 | -I../include \ 33 | -I../usb \ 34 | -I../../.. \ 35 | -I.. 36 | 37 | SRCS += \ 38 | ../main.c \ 39 | ../uart.c \ 40 | ../usb/usb_samd11.c \ 41 | ../usb/usb_std.c \ 42 | ../usb/usb_cdc.c \ 43 | ../usb/usb_hid.c \ 44 | ../usb/usb_winusb.c \ 45 | ../usb_descriptors.c \ 46 | ../startup_samd11.c \ 47 | ../../../dap.c \ 48 | 49 | DEFINES += \ 50 | -D__SAMD11C14A__ \ 51 | -DDONT_USE_CMSIS_INIT \ 52 | -DF_CPU=48000000 53 | 54 | CFLAGS += $(INCLUDES) $(DEFINES) 55 | 56 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 57 | 58 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size 59 | 60 | $(BUILD)/$(BIN).elf: $(OBJS) 61 | @echo LD $@ 62 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 63 | 64 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 65 | @echo OBJCOPY $@ 66 | @$(OBJCOPY) -O ihex $^ $@ 67 | 68 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 69 | @echo OBJCOPY $@ 70 | @$(OBJCOPY) -O binary $^ $@ 71 | 72 | %.o: 73 | @echo CC $@ 74 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 75 | 76 | directory: 77 | @$(MKDIR) -p $(BUILD) 78 | 79 | size: $(BUILD)/$(BIN).elf 80 | @echo size: 81 | @$(SIZE) -t $^ 82 | 83 | clean: 84 | @echo clean 85 | @-rm -rf $(BUILD) 86 | 87 | dfu: $(BUILD)/$(BIN).bin 88 | @echo DFU $^ 89 | @cp $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).dfu 90 | @dfu-suffix -a $(BUILD)/$(BIN).dfu -v ffff -p ffff -d ffff 91 | 92 | -include $(wildcard $(BUILD)/*.d) 93 | 94 | -------------------------------------------------------------------------------- /platform/samd11/make/Makefile_nobl: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap_d11_nobl 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | 12 | ifeq ($(OS), Windows_NT) 13 | MKDIR = gmkdir 14 | else 15 | MKDIR = mkdir 16 | endif 17 | 18 | CFLAGS += -W -Wall --std=gnu11 -Os 19 | CFLAGS += -fno-diagnostics-show-caret 20 | CFLAGS += -fdata-sections -ffunction-sections 21 | CFLAGS += -funsigned-char -funsigned-bitfields 22 | CFLAGS += -mcpu=cortex-m0plus -mthumb 23 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 24 | CFLAGS += -flto 25 | 26 | LDFLAGS += -mcpu=cortex-m0plus -mthumb 27 | LDFLAGS += -Wl,--gc-sections 28 | LDFLAGS += -Wl,--script=../linker/samd11d14_nobl.ld 29 | LDFLAGS += -flto 30 | 31 | INCLUDES += \ 32 | -I../include \ 33 | -I../usb \ 34 | -I../../.. \ 35 | -I.. 36 | 37 | SRCS += \ 38 | ../main.c \ 39 | ../uart.c \ 40 | ../usb/usb_samd11.c \ 41 | ../usb/usb_std.c \ 42 | ../usb/usb_cdc.c \ 43 | ../usb/usb_hid.c \ 44 | ../usb/usb_winusb.c \ 45 | ../usb_descriptors.c \ 46 | ../startup_samd11.c \ 47 | ../../../dap.c \ 48 | 49 | DEFINES += \ 50 | -D__SAMD11C14A__ \ 51 | -DDONT_USE_CMSIS_INIT \ 52 | -DF_CPU=48000000 53 | 54 | CFLAGS += $(INCLUDES) $(DEFINES) 55 | 56 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 57 | 58 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size 59 | 60 | $(BUILD)/$(BIN).elf: $(OBJS) 61 | @echo LD $@ 62 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 63 | 64 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 65 | @echo OBJCOPY $@ 66 | @$(OBJCOPY) -O ihex $^ $@ 67 | 68 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 69 | @echo OBJCOPY $@ 70 | @$(OBJCOPY) -O binary $^ $@ 71 | 72 | %.o: 73 | @echo CC $@ 74 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 75 | 76 | directory: 77 | @$(MKDIR) -p $(BUILD) 78 | 79 | size: $(BUILD)/$(BIN).elf 80 | @echo size: 81 | @$(SIZE) -t $^ 82 | 83 | clean: 84 | @echo clean 85 | @-rm -rf $(BUILD) 86 | 87 | -include $(wildcard $(BUILD)/*.d) 88 | 89 | -------------------------------------------------------------------------------- /platform/samd11/nvm_data.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _NVM_DATA_H_ 5 | #define _NVM_DATA_H_ 6 | 7 | /*- Definitions -------------------------------------------------------------*/ 8 | #define NVM_ADC_LINEARITY_POS 27 9 | #define NVM_ADC_LINEARITY_SIZE 8 10 | 11 | #define NVM_ADC_BIASCAL_POS 35 12 | #define NVM_ADC_BIASCAL_SIZE 3 13 | 14 | #define NVM_OSC32K_CAL_POS 38 15 | #define NVM_OSC32K_CAL_SIZE 7 16 | 17 | #define NVM_USB_TRANSN_POS 45 18 | #define NVM_USB_TRANSN_SIZE 5 19 | 20 | #define NVM_USB_TRANSP_POS 50 21 | #define NVM_USB_TRANSP_SIZE 5 22 | 23 | #define NVM_USB_TRIM_POS 55 24 | #define NVM_USB_TRIM_SIZE 3 25 | 26 | #define NVM_DFLL48M_COARSE_CAL_POS 58 27 | #define NVM_DFLL48M_COARSE_CAL_SIZE 6 28 | 29 | #define NVM_DFLL48M_FINE_CAL_POS 64 30 | #define NVM_DFLL48M_FINE_CAL_SIZE 10 31 | 32 | #define NVM_READ_CAL(cal) \ 33 | ((*((uint32_t *)NVMCTRL_OTP4 + cal##_POS / 32)) >> (cal##_POS % 32)) & ((1 << cal##_SIZE) - 1) 34 | 35 | #endif // _NVM_DATA_H_ 36 | -------------------------------------------------------------------------------- /platform/samd11/uart.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2017-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _UART_H_ 5 | #define _UART_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_cdc.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void uart_init(usb_cdc_line_coding_t *line_coding); 14 | void uart_close(void); 15 | bool uart_write_byte(int byte); 16 | bool uart_read_byte(int *byte); 17 | void uart_set_break(bool brk); 18 | 19 | #endif // _UART_H_ 20 | 21 | -------------------------------------------------------------------------------- /platform/samd11/usb/usb.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_H_ 5 | #define _USB_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_descriptors.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void usb_hw_init(void); 14 | void usb_attach(void); 15 | void usb_detach(void); 16 | void usb_configure_endpoint(usb_endpoint_descriptor_t *ep_desc); 17 | bool usb_endpoint_configured(int ep, int dir); 18 | int usb_endpoint_get_status(int ep, int dir); 19 | void usb_endpoint_set_feature(int ep, int dir); 20 | void usb_endpoint_clear_feature(int ep, int dir); 21 | void usb_set_address(int address); 22 | void usb_send(int ep, uint8_t *data, int size); 23 | void usb_recv(int ep, uint8_t *data, int size); 24 | void usb_control_send_zlp(void); 25 | void usb_control_stall(void); 26 | void usb_control_send(uint8_t *data, int size); 27 | void usb_control_recv(void (*callback)(uint8_t *data, int size)); 28 | void usb_task(void); 29 | 30 | void usb_configuration_callback(int config); 31 | 32 | #endif // _USB_H_ 33 | 34 | -------------------------------------------------------------------------------- /platform/samd11/usb/usb_hid.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_hid.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | void usb_hid_init(void) 14 | { 15 | usb_set_send_callback(USB_HID_EP_SEND, usb_hid_send_callback); 16 | usb_set_recv_callback(USB_HID_EP_RECV, usb_hid_recv_callback); 17 | } 18 | 19 | //----------------------------------------------------------------------------- 20 | void usb_hid_send(uint8_t *data, int size) 21 | { 22 | usb_send(USB_HID_EP_SEND, data, size); 23 | } 24 | 25 | //----------------------------------------------------------------------------- 26 | void usb_hid_recv(uint8_t *data, int size) 27 | { 28 | usb_recv(USB_HID_EP_RECV, data, size); 29 | } 30 | 31 | //----------------------------------------------------------------------------- 32 | bool usb_hid_handle_request(usb_request_t *request) 33 | { 34 | int length = request->wLength; 35 | 36 | switch (USB_CMD_VALUE(request)) 37 | { 38 | case USB_CMD(IN, INTERFACE, STANDARD, GET_DESCRIPTOR): 39 | { 40 | length = USB_LIMIT(length, sizeof(usb_hid_report_descriptor)); 41 | 42 | usb_control_send((uint8_t *)usb_hid_report_descriptor, length); 43 | } break; 44 | 45 | default: 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /platform/samd11/usb/usb_hid.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_HID_H_ 5 | #define _USB_HID_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | 10 | /*- Definitions -------------------------------------------------------------*/ 11 | enum 12 | { 13 | USB_HID_DESCRIPTOR = 0x21, 14 | USB_HID_REPORT_DESCRIPTOR = 0x22, 15 | USB_HID_PHYSICAL_DESCRIPTOR = 0x23, 16 | }; 17 | 18 | enum 19 | { 20 | USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class 21 | }; 22 | 23 | /*- Types -------------------------------------------------------------------*/ 24 | typedef struct USB_PACK 25 | { 26 | uint8_t bLength; 27 | uint8_t bDescriptorType; 28 | uint16_t bcdHID; 29 | uint8_t bCountryCode; 30 | uint8_t bNumDescriptors; 31 | uint8_t bDescriptorType1; 32 | uint16_t wDescriptorLength; 33 | } usb_hid_descriptor_t; 34 | 35 | /*- Prototypes --------------------------------------------------------------*/ 36 | void usb_hid_init(void); 37 | bool usb_hid_handle_request(usb_request_t *request); 38 | void usb_hid_send(uint8_t *data, int size); 39 | void usb_hid_recv(uint8_t *data, int size); 40 | 41 | void usb_hid_send_callback(void); 42 | void usb_hid_recv_callback(int size); 43 | 44 | #endif // _USB_HID_H_ 45 | -------------------------------------------------------------------------------- /platform/samd11/usb/usb_winusb.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_winusb.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | bool usb_winusb_handle_request(usb_request_t *request) 14 | { 15 | int length = request->wLength; 16 | 17 | switch (USB_CMD_VALUE(request)) 18 | { 19 | case USB_CMD(IN, DEVICE, VENDOR, WINUSB_VENDOR_CODE): 20 | { 21 | if (USB_WINUSB_DESCRIPTOR_INDEX == request->wIndex) 22 | { 23 | length = USB_LIMIT(length, sizeof(usb_msos_descriptor_set_t)); 24 | usb_control_send((uint8_t *)&usb_msos_descriptor_set, length); 25 | } 26 | else 27 | { 28 | return false; 29 | } 30 | } break; 31 | 32 | default: 33 | return false; 34 | } 35 | 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /platform/samd11/usb_descriptors.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_DESCRIPTORS_H_ 5 | #define _USB_DESCRIPTORS_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | #include "usb_cdc.h" 10 | #include "usb_hid.h" 11 | #include "usb_winusb.h" 12 | #include "hal_config.h" 13 | 14 | /*- Definitions -------------------------------------------------------------*/ 15 | #define USB_ENABLE_BOS 16 | #define USB_BCD_VERSION 0x0210 17 | 18 | enum 19 | { 20 | USB_STR_ZERO, 21 | USB_STR_MANUFACTURER, 22 | USB_STR_PRODUCT, 23 | USB_STR_SERIAL_NUMBER, 24 | USB_STR_CMSIS_DAP_V1, 25 | USB_STR_CMSIS_DAP_V2, 26 | #ifdef HAL_CONFIG_ENABLE_VCP 27 | USB_STR_COM_PORT, 28 | #endif 29 | USB_STR_COUNT, 30 | }; 31 | 32 | enum 33 | { 34 | USB_HID_EP_SEND = 1, 35 | USB_HID_EP_RECV = 2, 36 | USB_BULK_EP_RECV = 3, 37 | USB_BULK_EP_SEND = 4, 38 | USB_CDC_EP_COMM = 5, 39 | USB_CDC_EP_SEND = 6, 40 | USB_CDC_EP_RECV = 7, 41 | }; 42 | 43 | enum 44 | { 45 | USB_INTF_HID, 46 | USB_INTF_BULK, 47 | #ifdef HAL_CONFIG_ENABLE_VCP 48 | USB_INTF_CDC_COMM, 49 | USB_INTF_CDC_DATA, 50 | #endif 51 | USB_INTF_COUNT, 52 | }; 53 | 54 | /*- Types -------------------------------------------------------------------*/ 55 | typedef struct USB_PACK 56 | { 57 | usb_configuration_descriptor_t configuration; 58 | 59 | usb_interface_descriptor_t hid_interface; 60 | usb_hid_descriptor_t hid; 61 | usb_endpoint_descriptor_t hid_ep_in; 62 | usb_endpoint_descriptor_t hid_ep_out; 63 | 64 | usb_interface_descriptor_t bulk_interface; 65 | usb_endpoint_descriptor_t bulk_ep_out; 66 | usb_endpoint_descriptor_t bulk_ep_in; 67 | 68 | #ifdef HAL_CONFIG_ENABLE_VCP 69 | usb_interface_association_descriptor_t iad; 70 | usb_interface_descriptor_t interface_comm; 71 | usb_cdc_header_functional_descriptor_t cdc_header; 72 | usb_cdc_abstract_control_managment_descriptor_t cdc_acm; 73 | usb_cdc_call_managment_functional_descriptor_t cdc_call_mgmt; 74 | usb_cdc_union_functional_descriptor_t cdc_union; 75 | usb_endpoint_descriptor_t ep_comm; 76 | usb_interface_descriptor_t interface_data; 77 | usb_endpoint_descriptor_t ep_in; 78 | usb_endpoint_descriptor_t ep_out; 79 | #endif 80 | } usb_configuration_hierarchy_t; 81 | 82 | typedef struct USB_PACK 83 | { 84 | usb_binary_object_store_descriptor_t bos; 85 | usb_winusb_capability_descriptor_t winusb; 86 | } usb_bos_hierarchy_t; 87 | 88 | typedef struct USB_PACK 89 | { 90 | usb_winusb_subset_header_function_t header; 91 | usb_winusb_feature_compatble_id_t comp_id; 92 | usb_winusb_feature_reg_property_guids_t property; 93 | } usb_msos_descriptor_subset_t; 94 | 95 | typedef struct USB_PACK 96 | { 97 | usb_winusb_set_header_descriptor_t header; 98 | usb_msos_descriptor_subset_t subset; 99 | } usb_msos_descriptor_set_t; 100 | 101 | //----------------------------------------------------------------------------- 102 | extern const usb_device_descriptor_t usb_device_descriptor; 103 | extern const usb_configuration_hierarchy_t usb_configuration_hierarchy; 104 | extern const usb_bos_hierarchy_t usb_bos_hierarchy; 105 | extern const usb_msos_descriptor_set_t usb_msos_descriptor_set; 106 | extern const uint8_t usb_hid_report_descriptor[28]; 107 | extern const usb_string_descriptor_zero_t usb_string_descriptor_zero; 108 | extern const char *usb_strings[]; 109 | #ifdef HAL_CONFIG_ENABLE_VCP 110 | extern const usb_class_handler_t usb_class_handlers[3]; 111 | #else 112 | extern const usb_class_handler_t usb_class_handlers[2]; 113 | #endif 114 | extern char usb_serial_number[16]; 115 | 116 | #endif // _USB_DESCRIPTORS_H_ 117 | -------------------------------------------------------------------------------- /platform/samd21/hal_config.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2024, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _HAL_CONFIG_H_ 5 | #define _HAL_CONFIG_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "samd21.h" 9 | #include "hal_gpio.h" 10 | 11 | /*- Definitions -------------------------------------------------------------*/ 12 | #define HAL_BOARD_GENERIC 13 | 14 | #if defined(HAL_BOARD_CUSTOM) 15 | // Externally supplied board configuration takes precedence 16 | #include HAL_BOARD_CUSTOM 17 | 18 | #elif defined(HAL_BOARD_GENERIC) 19 | #define HAL_CONFIG_ENABLE_VCP 20 | #define DAP_CONFIG_ENABLE_JTAG 21 | 22 | HAL_GPIO_PIN(SWCLK_TCK, B, 0) 23 | HAL_GPIO_PIN(SWDIO_TMS, B, 1) 24 | HAL_GPIO_PIN(TDI, B, 2) 25 | HAL_GPIO_PIN(TDO, B, 3) 26 | HAL_GPIO_PIN(nRESET, B, 4) 27 | 28 | HAL_GPIO_PIN(VCP_STATUS, A, 10); 29 | HAL_GPIO_PIN(DAP_STATUS, B, 30); 30 | HAL_GPIO_PIN(BOOT_ENTER, A, 31); 31 | 32 | HAL_GPIO_PIN(UART_TX, A, 4); 33 | HAL_GPIO_PIN(UART_RX, A, 5); 34 | 35 | #define UART_SERCOM SERCOM0 36 | #define UART_SERCOM_PMUX PORT_PMUX_PMUXE_D_Val 37 | #define UART_SERCOM_GCLK_ID SERCOM0_GCLK_ID_CORE 38 | #define UART_SERCOM_APBCMASK PM_APBCMASK_SERCOM0 39 | #define UART_SERCOM_IRQ_INDEX SERCOM0_IRQn 40 | #define UART_SERCOM_IRQ_HANDLER irq_handler_sercom0 41 | #define UART_SERCOM_TXPO 0 // PAD[0] 42 | #define UART_SERCOM_RXPO 1 // PAD[1] 43 | 44 | #else 45 | #error No board defined 46 | #endif 47 | 48 | #endif // _HAL_CONFIG_H_ 49 | 50 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/dac.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for DAC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_DAC_INSTANCE_ 31 | #define _SAMD21_DAC_INSTANCE_ 32 | 33 | /* ========== Register definition for DAC peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_DAC_CTRLA (0x42004800) /**< \brief (DAC) Control A */ 36 | #define REG_DAC_CTRLB (0x42004801) /**< \brief (DAC) Control B */ 37 | #define REG_DAC_EVCTRL (0x42004802) /**< \brief (DAC) Event Control */ 38 | #define REG_DAC_INTENCLR (0x42004804) /**< \brief (DAC) Interrupt Enable Clear */ 39 | #define REG_DAC_INTENSET (0x42004805) /**< \brief (DAC) Interrupt Enable Set */ 40 | #define REG_DAC_INTFLAG (0x42004806) /**< \brief (DAC) Interrupt Flag Status and Clear */ 41 | #define REG_DAC_STATUS (0x42004807) /**< \brief (DAC) Status */ 42 | #define REG_DAC_DATA (0x42004808) /**< \brief (DAC) Data */ 43 | #define REG_DAC_DATABUF (0x4200480C) /**< \brief (DAC) Data Buffer */ 44 | #else 45 | #define REG_DAC_CTRLA (*(RwReg8 *)0x42004800UL) /**< \brief (DAC) Control A */ 46 | #define REG_DAC_CTRLB (*(RwReg8 *)0x42004801UL) /**< \brief (DAC) Control B */ 47 | #define REG_DAC_EVCTRL (*(RwReg8 *)0x42004802UL) /**< \brief (DAC) Event Control */ 48 | #define REG_DAC_INTENCLR (*(RwReg8 *)0x42004804UL) /**< \brief (DAC) Interrupt Enable Clear */ 49 | #define REG_DAC_INTENSET (*(RwReg8 *)0x42004805UL) /**< \brief (DAC) Interrupt Enable Set */ 50 | #define REG_DAC_INTFLAG (*(RwReg8 *)0x42004806UL) /**< \brief (DAC) Interrupt Flag Status and Clear */ 51 | #define REG_DAC_STATUS (*(RoReg8 *)0x42004807UL) /**< \brief (DAC) Status */ 52 | #define REG_DAC_DATA (*(RwReg16*)0x42004808UL) /**< \brief (DAC) Data */ 53 | #define REG_DAC_DATABUF (*(RwReg16*)0x4200480CUL) /**< \brief (DAC) Data Buffer */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for DAC peripheral ========== */ 57 | #define DAC_DMAC_ID_EMPTY 40 // Index of DMAC EMPTY trigger 58 | #define DAC_GCLK_ID 33 // Index of Generic Clock 59 | 60 | #endif /* _SAMD21_DAC_INSTANCE_ */ 61 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/eic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for EIC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_EIC_INSTANCE_ 31 | #define _SAMD21_EIC_INSTANCE_ 32 | 33 | /* ========== Register definition for EIC peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_EIC_CTRL (0x40001800) /**< \brief (EIC) Control */ 36 | #define REG_EIC_STATUS (0x40001801) /**< \brief (EIC) Status */ 37 | #define REG_EIC_NMICTRL (0x40001802) /**< \brief (EIC) Non-Maskable Interrupt Control */ 38 | #define REG_EIC_NMIFLAG (0x40001803) /**< \brief (EIC) Non-Maskable Interrupt Flag Status and Clear */ 39 | #define REG_EIC_EVCTRL (0x40001804) /**< \brief (EIC) Event Control */ 40 | #define REG_EIC_INTENCLR (0x40001808) /**< \brief (EIC) Interrupt Enable Clear */ 41 | #define REG_EIC_INTENSET (0x4000180C) /**< \brief (EIC) Interrupt Enable Set */ 42 | #define REG_EIC_INTFLAG (0x40001810) /**< \brief (EIC) Interrupt Flag Status and Clear */ 43 | #define REG_EIC_WAKEUP (0x40001814) /**< \brief (EIC) Wake-Up Enable */ 44 | #define REG_EIC_CONFIG0 (0x40001818) /**< \brief (EIC) Configuration 0 */ 45 | #define REG_EIC_CONFIG1 (0x4000181C) /**< \brief (EIC) Configuration 1 */ 46 | #else 47 | #define REG_EIC_CTRL (*(RwReg8 *)0x40001800UL) /**< \brief (EIC) Control */ 48 | #define REG_EIC_STATUS (*(RoReg8 *)0x40001801UL) /**< \brief (EIC) Status */ 49 | #define REG_EIC_NMICTRL (*(RwReg8 *)0x40001802UL) /**< \brief (EIC) Non-Maskable Interrupt Control */ 50 | #define REG_EIC_NMIFLAG (*(RwReg8 *)0x40001803UL) /**< \brief (EIC) Non-Maskable Interrupt Flag Status and Clear */ 51 | #define REG_EIC_EVCTRL (*(RwReg *)0x40001804UL) /**< \brief (EIC) Event Control */ 52 | #define REG_EIC_INTENCLR (*(RwReg *)0x40001808UL) /**< \brief (EIC) Interrupt Enable Clear */ 53 | #define REG_EIC_INTENSET (*(RwReg *)0x4000180CUL) /**< \brief (EIC) Interrupt Enable Set */ 54 | #define REG_EIC_INTFLAG (*(RwReg *)0x40001810UL) /**< \brief (EIC) Interrupt Flag Status and Clear */ 55 | #define REG_EIC_WAKEUP (*(RwReg *)0x40001814UL) /**< \brief (EIC) Wake-Up Enable */ 56 | #define REG_EIC_CONFIG0 (*(RwReg *)0x40001818UL) /**< \brief (EIC) Configuration 0 */ 57 | #define REG_EIC_CONFIG1 (*(RwReg *)0x4000181CUL) /**< \brief (EIC) Configuration 1 */ 58 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 59 | 60 | /* ========== Instance parameters for EIC peripheral ========== */ 61 | #define EIC_CONFIG_NUM 2 // Number of CONFIG registers 62 | #define EIC_GCLK_ID 5 // Index of Generic Clock 63 | 64 | #endif /* _SAMD21_EIC_INSTANCE_ */ 65 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/gclk.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for GCLK 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_GCLK_INSTANCE_ 31 | #define _SAMD21_GCLK_INSTANCE_ 32 | 33 | /* ========== Register definition for GCLK peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_GCLK_CTRL (0x40000C00) /**< \brief (GCLK) Control */ 36 | #define REG_GCLK_STATUS (0x40000C01) /**< \brief (GCLK) Status */ 37 | #define REG_GCLK_CLKCTRL (0x40000C02) /**< \brief (GCLK) Generic Clock Control */ 38 | #define REG_GCLK_GENCTRL (0x40000C04) /**< \brief (GCLK) Generic Clock Generator Control */ 39 | #define REG_GCLK_GENDIV (0x40000C08) /**< \brief (GCLK) Generic Clock Generator Division */ 40 | #else 41 | #define REG_GCLK_CTRL (*(RwReg8 *)0x40000C00UL) /**< \brief (GCLK) Control */ 42 | #define REG_GCLK_STATUS (*(RoReg8 *)0x40000C01UL) /**< \brief (GCLK) Status */ 43 | #define REG_GCLK_CLKCTRL (*(RwReg16*)0x40000C02UL) /**< \brief (GCLK) Generic Clock Control */ 44 | #define REG_GCLK_GENCTRL (*(RwReg *)0x40000C04UL) /**< \brief (GCLK) Generic Clock Generator Control */ 45 | #define REG_GCLK_GENDIV (*(RwReg *)0x40000C08UL) /**< \brief (GCLK) Generic Clock Generator Division */ 46 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 47 | 48 | /* ========== Instance parameters for GCLK peripheral ========== */ 49 | #define GCLK_GENDIV_BITS 16 50 | #define GCLK_GEN_NUM 9 // Number of Generic Clock Generators 51 | #define GCLK_GEN_NUM_MSB 8 // Number of Generic Clock Generators - 1 52 | #define GCLK_GEN_SOURCE_NUM_MSB 8 // Number of Generic Clock Sources - 1 53 | #define GCLK_NUM 37 // Number of Generic Clock Users 54 | #define GCLK_SOURCE_DFLL48M 7 55 | #define GCLK_SOURCE_DPLL96M 8 56 | #define GCLK_SOURCE_GCLKGEN1 2 57 | #define GCLK_SOURCE_GCLKIN 1 58 | #define GCLK_SOURCE_NUM 9 // Number of Generic Clock Sources 59 | #define GCLK_SOURCE_OSCULP32K 3 60 | #define GCLK_SOURCE_OSC8M 6 61 | #define GCLK_SOURCE_OSC32K 4 62 | #define GCLK_SOURCE_XOSC 0 63 | #define GCLK_SOURCE_XOSC32K 5 64 | 65 | #endif /* _SAMD21_GCLK_INSTANCE_ */ 66 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/nvmctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for NVMCTRL 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_NVMCTRL_INSTANCE_ 31 | #define _SAMD21_NVMCTRL_INSTANCE_ 32 | 33 | /* ========== Register definition for NVMCTRL peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_NVMCTRL_CTRLA (0x41004000) /**< \brief (NVMCTRL) Control A */ 36 | #define REG_NVMCTRL_CTRLB (0x41004004) /**< \brief (NVMCTRL) Control B */ 37 | #define REG_NVMCTRL_PARAM (0x41004008) /**< \brief (NVMCTRL) NVM Parameter */ 38 | #define REG_NVMCTRL_INTENCLR (0x4100400C) /**< \brief (NVMCTRL) Interrupt Enable Clear */ 39 | #define REG_NVMCTRL_INTENSET (0x41004010) /**< \brief (NVMCTRL) Interrupt Enable Set */ 40 | #define REG_NVMCTRL_INTFLAG (0x41004014) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */ 41 | #define REG_NVMCTRL_STATUS (0x41004018) /**< \brief (NVMCTRL) Status */ 42 | #define REG_NVMCTRL_ADDR (0x4100401C) /**< \brief (NVMCTRL) Address */ 43 | #define REG_NVMCTRL_LOCK (0x41004020) /**< \brief (NVMCTRL) Lock Section */ 44 | #else 45 | #define REG_NVMCTRL_CTRLA (*(RwReg16*)0x41004000UL) /**< \brief (NVMCTRL) Control A */ 46 | #define REG_NVMCTRL_CTRLB (*(RwReg *)0x41004004UL) /**< \brief (NVMCTRL) Control B */ 47 | #define REG_NVMCTRL_PARAM (*(RwReg *)0x41004008UL) /**< \brief (NVMCTRL) NVM Parameter */ 48 | #define REG_NVMCTRL_INTENCLR (*(RwReg8 *)0x4100400CUL) /**< \brief (NVMCTRL) Interrupt Enable Clear */ 49 | #define REG_NVMCTRL_INTENSET (*(RwReg8 *)0x41004010UL) /**< \brief (NVMCTRL) Interrupt Enable Set */ 50 | #define REG_NVMCTRL_INTFLAG (*(RwReg8 *)0x41004014UL) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */ 51 | #define REG_NVMCTRL_STATUS (*(RwReg16*)0x41004018UL) /**< \brief (NVMCTRL) Status */ 52 | #define REG_NVMCTRL_ADDR (*(RwReg *)0x4100401CUL) /**< \brief (NVMCTRL) Address */ 53 | #define REG_NVMCTRL_LOCK (*(RwReg16*)0x41004020UL) /**< \brief (NVMCTRL) Lock Section */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for NVMCTRL peripheral ========== */ 57 | #define NVMCTRL_AUX0_ADDRESS 0x00804000 58 | #define NVMCTRL_AUX1_ADDRESS 0x00806000 59 | #define NVMCTRL_AUX2_ADDRESS 0x00808000 60 | #define NVMCTRL_AUX3_ADDRESS 0x0080A000 61 | #define NVMCTRL_CLK_AHB_ID 4 // Index of AHB Clock in PM.AHBMASK register 62 | #define NVMCTRL_FACTORY_WORD_IMPLEMENTED_MASK 0xC0000007FFFFFFFF 63 | #define NVMCTRL_FLASH_SIZE 262144 64 | #define NVMCTRL_LOCKBIT_ADDRESS 0x00802000 65 | #define NVMCTRL_PAGE_HW 32 66 | #define NVMCTRL_PAGE_SIZE 64 67 | #define NVMCTRL_PAGE_W 16 68 | #define NVMCTRL_PMSB 3 69 | #define NVMCTRL_PSZ_BITS 6 70 | #define NVMCTRL_ROW_PAGES 4 71 | #define NVMCTRL_ROW_SIZE 256 72 | #define NVMCTRL_TEMP_LOG_ADDRESS 0x00806030 73 | #define NVMCTRL_USER_PAGE_ADDRESS 0x00800000 74 | #define NVMCTRL_USER_PAGE_OFFSET 0x00800000 75 | #define NVMCTRL_USER_WORD_IMPLEMENTED_MASK 0xC01FFFFFFFFFFFFF 76 | 77 | #endif /* _SAMD21_NVMCTRL_INSTANCE_ */ 78 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/pac0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC0 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_PAC0_INSTANCE_ 31 | #define _SAMD21_PAC0_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC0 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC0_WPCLR (0x40000000) /**< \brief (PAC0) Write Protection Clear */ 36 | #define REG_PAC0_WPSET (0x40000004) /**< \brief (PAC0) Write Protection Set */ 37 | #else 38 | #define REG_PAC0_WPCLR (*(RwReg *)0x40000000UL) /**< \brief (PAC0) Write Protection Clear */ 39 | #define REG_PAC0_WPSET (*(RwReg *)0x40000004UL) /**< \brief (PAC0) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC0 peripheral ========== */ 43 | #define PAC0_WPROT_DEFAULT_VAL 0x00000000 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD21_PAC0_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/pac1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC1 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_PAC1_INSTANCE_ 31 | #define _SAMD21_PAC1_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC1 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC1_WPCLR (0x41000000) /**< \brief (PAC1) Write Protection Clear */ 36 | #define REG_PAC1_WPSET (0x41000004) /**< \brief (PAC1) Write Protection Set */ 37 | #else 38 | #define REG_PAC1_WPCLR (*(RwReg *)0x41000000UL) /**< \brief (PAC1) Write Protection Clear */ 39 | #define REG_PAC1_WPSET (*(RwReg *)0x41000004UL) /**< \brief (PAC1) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC1 peripheral ========== */ 43 | #define PAC1_WPROT_DEFAULT_VAL 0x00000002 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD21_PAC1_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/pac2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC2 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_PAC2_INSTANCE_ 31 | #define _SAMD21_PAC2_INSTANCE_ 32 | 33 | /* ========== Register definition for PAC2 peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PAC2_WPCLR (0x42000000) /**< \brief (PAC2) Write Protection Clear */ 36 | #define REG_PAC2_WPSET (0x42000004) /**< \brief (PAC2) Write Protection Set */ 37 | #else 38 | #define REG_PAC2_WPCLR (*(RwReg *)0x42000000UL) /**< \brief (PAC2) Write Protection Clear */ 39 | #define REG_PAC2_WPSET (*(RwReg *)0x42000004UL) /**< \brief (PAC2) Write Protection Set */ 40 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 41 | 42 | /* ========== Instance parameters for PAC2 peripheral ========== */ 43 | #define PAC2_WPROT_DEFAULT_VAL 0x00800000 // PAC protection mask at reset 44 | 45 | #endif /* _SAMD21_PAC2_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/pm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PM 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_PM_INSTANCE_ 31 | #define _SAMD21_PM_INSTANCE_ 32 | 33 | /* ========== Register definition for PM peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_PM_CTRL (0x40000400) /**< \brief (PM) Control */ 36 | #define REG_PM_SLEEP (0x40000401) /**< \brief (PM) Sleep Mode */ 37 | #define REG_PM_CPUSEL (0x40000408) /**< \brief (PM) CPU Clock Select */ 38 | #define REG_PM_APBASEL (0x40000409) /**< \brief (PM) APBA Clock Select */ 39 | #define REG_PM_APBBSEL (0x4000040A) /**< \brief (PM) APBB Clock Select */ 40 | #define REG_PM_APBCSEL (0x4000040B) /**< \brief (PM) APBC Clock Select */ 41 | #define REG_PM_AHBMASK (0x40000414) /**< \brief (PM) AHB Mask */ 42 | #define REG_PM_APBAMASK (0x40000418) /**< \brief (PM) APBA Mask */ 43 | #define REG_PM_APBBMASK (0x4000041C) /**< \brief (PM) APBB Mask */ 44 | #define REG_PM_APBCMASK (0x40000420) /**< \brief (PM) APBC Mask */ 45 | #define REG_PM_INTENCLR (0x40000434) /**< \brief (PM) Interrupt Enable Clear */ 46 | #define REG_PM_INTENSET (0x40000435) /**< \brief (PM) Interrupt Enable Set */ 47 | #define REG_PM_INTFLAG (0x40000436) /**< \brief (PM) Interrupt Flag Status and Clear */ 48 | #define REG_PM_RCAUSE (0x40000438) /**< \brief (PM) Reset Cause */ 49 | #else 50 | #define REG_PM_CTRL (*(RwReg8 *)0x40000400UL) /**< \brief (PM) Control */ 51 | #define REG_PM_SLEEP (*(RwReg8 *)0x40000401UL) /**< \brief (PM) Sleep Mode */ 52 | #define REG_PM_CPUSEL (*(RwReg8 *)0x40000408UL) /**< \brief (PM) CPU Clock Select */ 53 | #define REG_PM_APBASEL (*(RwReg8 *)0x40000409UL) /**< \brief (PM) APBA Clock Select */ 54 | #define REG_PM_APBBSEL (*(RwReg8 *)0x4000040AUL) /**< \brief (PM) APBB Clock Select */ 55 | #define REG_PM_APBCSEL (*(RwReg8 *)0x4000040BUL) /**< \brief (PM) APBC Clock Select */ 56 | #define REG_PM_AHBMASK (*(RwReg *)0x40000414UL) /**< \brief (PM) AHB Mask */ 57 | #define REG_PM_APBAMASK (*(RwReg *)0x40000418UL) /**< \brief (PM) APBA Mask */ 58 | #define REG_PM_APBBMASK (*(RwReg *)0x4000041CUL) /**< \brief (PM) APBB Mask */ 59 | #define REG_PM_APBCMASK (*(RwReg *)0x40000420UL) /**< \brief (PM) APBC Mask */ 60 | #define REG_PM_INTENCLR (*(RwReg8 *)0x40000434UL) /**< \brief (PM) Interrupt Enable Clear */ 61 | #define REG_PM_INTENSET (*(RwReg8 *)0x40000435UL) /**< \brief (PM) Interrupt Enable Set */ 62 | #define REG_PM_INTFLAG (*(RwReg8 *)0x40000436UL) /**< \brief (PM) Interrupt Flag Status and Clear */ 63 | #define REG_PM_RCAUSE (*(RoReg8 *)0x40000438UL) /**< \brief (PM) Reset Cause */ 64 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 65 | 66 | /* ========== Instance parameters for PM peripheral ========== */ 67 | #define PM_CTRL_MCSEL_DFLL48M 3 68 | #define PM_CTRL_MCSEL_GCLK 0 69 | #define PM_CTRL_MCSEL_OSC8M 1 70 | #define PM_CTRL_MCSEL_XOSC 2 71 | #define PM_PM_CLK_APB_NUM 2 72 | 73 | #endif /* _SAMD21_PM_INSTANCE_ */ 74 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/ptc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PTC 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_PTC_INSTANCE_ 31 | #define _SAMD21_PTC_INSTANCE_ 32 | 33 | /* ========== Instance parameters for PTC peripheral ========== */ 34 | #define PTC_GCLK_ID 34 // Index of Generic Clock 35 | 36 | #endif /* _SAMD21_PTC_INSTANCE_ */ 37 | -------------------------------------------------------------------------------- /platform/samd21/include/instance/wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for WDT 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_WDT_INSTANCE_ 31 | #define _SAMD21_WDT_INSTANCE_ 32 | 33 | /* ========== Register definition for WDT peripheral ========== */ 34 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 35 | #define REG_WDT_CTRL (0x40001000) /**< \brief (WDT) Control */ 36 | #define REG_WDT_CONFIG (0x40001001) /**< \brief (WDT) Configuration */ 37 | #define REG_WDT_EWCTRL (0x40001002) /**< \brief (WDT) Early Warning Interrupt Control */ 38 | #define REG_WDT_INTENCLR (0x40001004) /**< \brief (WDT) Interrupt Enable Clear */ 39 | #define REG_WDT_INTENSET (0x40001005) /**< \brief (WDT) Interrupt Enable Set */ 40 | #define REG_WDT_INTFLAG (0x40001006) /**< \brief (WDT) Interrupt Flag Status and Clear */ 41 | #define REG_WDT_STATUS (0x40001007) /**< \brief (WDT) Status */ 42 | #define REG_WDT_CLEAR (0x40001008) /**< \brief (WDT) Clear */ 43 | #else 44 | #define REG_WDT_CTRL (*(RwReg8 *)0x40001000UL) /**< \brief (WDT) Control */ 45 | #define REG_WDT_CONFIG (*(RwReg8 *)0x40001001UL) /**< \brief (WDT) Configuration */ 46 | #define REG_WDT_EWCTRL (*(RwReg8 *)0x40001002UL) /**< \brief (WDT) Early Warning Interrupt Control */ 47 | #define REG_WDT_INTENCLR (*(RwReg8 *)0x40001004UL) /**< \brief (WDT) Interrupt Enable Clear */ 48 | #define REG_WDT_INTENSET (*(RwReg8 *)0x40001005UL) /**< \brief (WDT) Interrupt Enable Set */ 49 | #define REG_WDT_INTFLAG (*(RwReg8 *)0x40001006UL) /**< \brief (WDT) Interrupt Flag Status and Clear */ 50 | #define REG_WDT_STATUS (*(RoReg8 *)0x40001007UL) /**< \brief (WDT) Status */ 51 | #define REG_WDT_CLEAR (*(WoReg8 *)0x40001008UL) /**< \brief (WDT) Clear */ 52 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | 54 | /* ========== Instance parameters for WDT peripheral ========== */ 55 | #define WDT_GCLK_ID 3 // Index of Generic Clock 56 | 57 | #endif /* _SAMD21_WDT_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /platform/samd21/include/samd21.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Top header file for SAMD21 5 | * 6 | * Copyright (c) 2018 Microchip Technology Inc. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the Licence at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * \asf_license_stop 27 | * 28 | */ 29 | 30 | #ifndef _SAMD21_ 31 | #define _SAMD21_ 32 | 33 | /** 34 | * \defgroup SAMD21_definitions SAMD21 Device Definitions 35 | * \brief SAMD21 CMSIS Definitions. 36 | */ 37 | 38 | #if defined(__SAMD21E15A__) || defined(__ATSAMD21E15A__) 39 | #include "samd21e15a.h" 40 | #elif defined(__SAMD21E16A__) || defined(__ATSAMD21E16A__) 41 | #include "samd21e16a.h" 42 | #elif defined(__SAMD21E17A__) || defined(__ATSAMD21E17A__) 43 | #include "samd21e17a.h" 44 | #elif defined(__SAMD21E18A__) || defined(__ATSAMD21E18A__) 45 | #include "samd21e18a.h" 46 | #elif defined(__SAMD21G15A__) || defined(__ATSAMD21G15A__) 47 | #include "samd21g15a.h" 48 | #elif defined(__SAMD21G16A__) || defined(__ATSAMD21G16A__) 49 | #include "samd21g16a.h" 50 | #elif defined(__SAMD21G17A__) || defined(__ATSAMD21G17A__) 51 | #include "samd21g17a.h" 52 | #elif defined(__SAMD21G17AU__) || defined(__ATSAMD21G17AU__) 53 | #include "samd21g17au.h" 54 | #elif defined(__SAMD21G18A__) || defined(__ATSAMD21G18A__) 55 | #include "samd21g18a.h" 56 | #elif defined(__SAMD21G18AU__) || defined(__ATSAMD21G18AU__) 57 | #include "samd21g18au.h" 58 | #elif defined(__SAMD21J15A__) || defined(__ATSAMD21J15A__) 59 | #include "samd21j15a.h" 60 | #elif defined(__SAMD21J16A__) || defined(__ATSAMD21J16A__) 61 | #include "samd21j16a.h" 62 | #elif defined(__SAMD21J17A__) || defined(__ATSAMD21J17A__) 63 | #include "samd21j17a.h" 64 | #elif defined(__SAMD21J18A__) || defined(__ATSAMD21J18A__) 65 | #include "samd21j18a.h" 66 | #else 67 | #error Library does not support the specified device. 68 | #endif 69 | 70 | #endif /* _SAMD21_ */ 71 | -------------------------------------------------------------------------------- /platform/samd21/linker/samd21j18_nobl.ld: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-License-Identifier: BSD-3-Clause 3 | Copyright (c) 2015, Alex Taradov . All rights reserved. 4 | */ 5 | 6 | MEMORY 7 | { 8 | flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256k */ 9 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32k */ 10 | } 11 | 12 | __top_flash = ORIGIN(flash) + LENGTH(flash); 13 | __top_ram = ORIGIN(ram) + LENGTH(ram); 14 | 15 | ENTRY(irq_handler_reset) 16 | 17 | SECTIONS 18 | { 19 | .text : ALIGN(4) 20 | { 21 | FILL(0xff) 22 | KEEP(*(.vectors)) 23 | *(.text*) 24 | *(.rodata) 25 | *(.rodata.*) 26 | . = ALIGN(4); 27 | } > flash 28 | 29 | . = ALIGN(4); 30 | _etext = .; 31 | 32 | .uninit_RESERVED : ALIGN(4) 33 | { 34 | KEEP(*(.bss.$RESERVED*)) 35 | } > ram 36 | 37 | .data : ALIGN(4) 38 | { 39 | FILL(0xff) 40 | _data = .; 41 | *(vtable) 42 | *(.data*) 43 | . = ALIGN(4); 44 | _edata = .; 45 | } > ram AT > flash 46 | 47 | .bss : ALIGN(4) 48 | { 49 | _bss = .; 50 | *(.bss*) 51 | *(COMMON) 52 | . = ALIGN(4); 53 | _ebss = .; 54 | PROVIDE(_end = .); 55 | } > ram 56 | 57 | PROVIDE(_stack_top = __top_ram - 0); 58 | } 59 | -------------------------------------------------------------------------------- /platform/samd21/make/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /platform/samd21/make/Makefile_nobl: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap_d21_nobl 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | 12 | ifeq ($(OS), Windows_NT) 13 | MKDIR = gmkdir 14 | else 15 | MKDIR = mkdir 16 | endif 17 | 18 | CFLAGS += -W -Wall --std=gnu11 -Os 19 | CFLAGS += -fno-diagnostics-show-caret 20 | CFLAGS += -fdata-sections -ffunction-sections 21 | CFLAGS += -funsigned-char -funsigned-bitfields 22 | CFLAGS += -mcpu=cortex-m0plus -mthumb 23 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 24 | CFLAGS += -flto 25 | 26 | LDFLAGS += -mcpu=cortex-m0plus -mthumb 27 | LDFLAGS += -Wl,--gc-sections 28 | LDFLAGS += -Wl,--script=../linker/samd21j18_nobl.ld 29 | LDFLAGS += -flto 30 | 31 | INCLUDES += \ 32 | -I../include \ 33 | -I../usb \ 34 | -I../../.. \ 35 | -I.. 36 | 37 | SRCS += \ 38 | ../main.c \ 39 | ../uart.c \ 40 | ../usb/usb_samd21.c \ 41 | ../usb/usb_std.c \ 42 | ../usb/usb_cdc.c \ 43 | ../usb/usb_hid.c \ 44 | ../usb/usb_winusb.c \ 45 | ../usb_descriptors.c \ 46 | ../startup_samd21.c \ 47 | ../../../dap.c \ 48 | 49 | DEFINES += \ 50 | -D__SAMD21J18A__ \ 51 | -DDONT_USE_CMSIS_INIT \ 52 | -DF_CPU=48000000 53 | 54 | CFLAGS += $(INCLUDES) $(DEFINES) 55 | 56 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 57 | 58 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size 59 | 60 | $(BUILD)/$(BIN).elf: $(OBJS) 61 | @echo LD $@ 62 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 63 | 64 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 65 | @echo OBJCOPY $@ 66 | @$(OBJCOPY) -O ihex $^ $@ 67 | 68 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 69 | @echo OBJCOPY $@ 70 | @$(OBJCOPY) -O binary $^ $@ 71 | 72 | %.o: 73 | @echo CC $@ 74 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 75 | 76 | directory: 77 | @$(MKDIR) -p $(BUILD) 78 | 79 | size: $(BUILD)/$(BIN).elf 80 | @echo size: 81 | @$(SIZE) -t $^ 82 | 83 | clean: 84 | @echo clean 85 | @-rm -rf $(BUILD) 86 | 87 | -include $(wildcard $(BUILD)/*.d) 88 | 89 | -------------------------------------------------------------------------------- /platform/samd21/nvm_data.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _NVM_DATA_H_ 5 | #define _NVM_DATA_H_ 6 | 7 | /*- Definitions -------------------------------------------------------------*/ 8 | #define NVM_ADC_LINEARITY_POS 27 9 | #define NVM_ADC_LINEARITY_SIZE 8 10 | 11 | #define NVM_ADC_BIASCAL_POS 35 12 | #define NVM_ADC_BIASCAL_SIZE 3 13 | 14 | #define NVM_OSC32K_CAL_POS 38 15 | #define NVM_OSC32K_CAL_SIZE 7 16 | 17 | #define NVM_USB_TRANSN_POS 45 18 | #define NVM_USB_TRANSN_SIZE 5 19 | 20 | #define NVM_USB_TRANSP_POS 50 21 | #define NVM_USB_TRANSP_SIZE 5 22 | 23 | #define NVM_USB_TRIM_POS 55 24 | #define NVM_USB_TRIM_SIZE 3 25 | 26 | #define NVM_DFLL48M_COARSE_CAL_POS 58 27 | #define NVM_DFLL48M_COARSE_CAL_SIZE 6 28 | 29 | #define NVM_DFLL48M_FINE_CAL_POS 64 30 | #define NVM_DFLL48M_FINE_CAL_SIZE 10 31 | 32 | #define NVM_READ_CAL(cal) \ 33 | ((*((uint32_t *)NVMCTRL_OTP4 + cal##_POS / 32)) >> (cal##_POS % 32)) & ((1 << cal##_SIZE) - 1) 34 | 35 | #endif // _NVM_DATA_H_ 36 | -------------------------------------------------------------------------------- /platform/samd21/uart.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2017-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _UART_H_ 5 | #define _UART_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_cdc.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void uart_init(usb_cdc_line_coding_t *line_coding); 14 | void uart_close(void); 15 | bool uart_write_byte(int byte); 16 | bool uart_read_byte(int *byte); 17 | void uart_set_break(bool brk); 18 | 19 | #endif // _UART_H_ 20 | 21 | -------------------------------------------------------------------------------- /platform/samd21/usb/usb.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2016-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_H_ 5 | #define _USB_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include 9 | #include 10 | #include "usb_descriptors.h" 11 | 12 | /*- Prototypes --------------------------------------------------------------*/ 13 | void usb_hw_init(void); 14 | void usb_attach(void); 15 | void usb_detach(void); 16 | void usb_configure_endpoint(usb_endpoint_descriptor_t *ep_desc); 17 | bool usb_endpoint_configured(int ep, int dir); 18 | int usb_endpoint_get_status(int ep, int dir); 19 | void usb_endpoint_set_feature(int ep, int dir); 20 | void usb_endpoint_clear_feature(int ep, int dir); 21 | void usb_set_address(int address); 22 | void usb_send(int ep, uint8_t *data, int size); 23 | void usb_recv(int ep, uint8_t *data, int size); 24 | void usb_control_send_zlp(void); 25 | void usb_control_stall(void); 26 | void usb_control_send(uint8_t *data, int size); 27 | void usb_control_recv(void (*callback)(uint8_t *data, int size)); 28 | void usb_task(void); 29 | 30 | void usb_configuration_callback(int config); 31 | 32 | #endif // _USB_H_ 33 | 34 | -------------------------------------------------------------------------------- /platform/samd21/usb/usb_hid.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_hid.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | void usb_hid_init(void) 14 | { 15 | usb_set_send_callback(USB_HID_EP_SEND, usb_hid_send_callback); 16 | usb_set_recv_callback(USB_HID_EP_RECV, usb_hid_recv_callback); 17 | } 18 | 19 | //----------------------------------------------------------------------------- 20 | void usb_hid_send(uint8_t *data, int size) 21 | { 22 | usb_send(USB_HID_EP_SEND, data, size); 23 | } 24 | 25 | //----------------------------------------------------------------------------- 26 | void usb_hid_recv(uint8_t *data, int size) 27 | { 28 | usb_recv(USB_HID_EP_RECV, data, size); 29 | } 30 | 31 | //----------------------------------------------------------------------------- 32 | bool usb_hid_handle_request(usb_request_t *request) 33 | { 34 | int length = request->wLength; 35 | 36 | switch (USB_CMD_VALUE(request)) 37 | { 38 | case USB_CMD(IN, INTERFACE, STANDARD, GET_DESCRIPTOR): 39 | { 40 | length = USB_LIMIT(length, sizeof(usb_hid_report_descriptor)); 41 | 42 | usb_control_send((uint8_t *)usb_hid_report_descriptor, length); 43 | } break; 44 | 45 | default: 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /platform/samd21/usb/usb_hid.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2019-2022, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_HID_H_ 5 | #define _USB_HID_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | 10 | /*- Definitions -------------------------------------------------------------*/ 11 | enum 12 | { 13 | USB_HID_DESCRIPTOR = 0x21, 14 | USB_HID_REPORT_DESCRIPTOR = 0x22, 15 | USB_HID_PHYSICAL_DESCRIPTOR = 0x23, 16 | }; 17 | 18 | enum 19 | { 20 | USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class 21 | }; 22 | 23 | /*- Types -------------------------------------------------------------------*/ 24 | typedef struct USB_PACK 25 | { 26 | uint8_t bLength; 27 | uint8_t bDescriptorType; 28 | uint16_t bcdHID; 29 | uint8_t bCountryCode; 30 | uint8_t bNumDescriptors; 31 | uint8_t bDescriptorType1; 32 | uint16_t wDescriptorLength; 33 | } usb_hid_descriptor_t; 34 | 35 | /*- Prototypes --------------------------------------------------------------*/ 36 | void usb_hid_init(void); 37 | bool usb_hid_handle_request(usb_request_t *request); 38 | void usb_hid_send(uint8_t *data, int size); 39 | void usb_hid_recv(uint8_t *data, int size); 40 | 41 | void usb_hid_send_callback(void); 42 | void usb_hid_recv_callback(int size); 43 | 44 | #endif // _USB_HID_H_ 45 | -------------------------------------------------------------------------------- /platform/samd21/usb/usb_winusb.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2022, Alex Taradov . All rights reserved. 3 | 4 | /*- Includes ----------------------------------------------------------------*/ 5 | #include "usb.h" 6 | #include "usb_std.h" 7 | #include "usb_winusb.h" 8 | #include "usb_descriptors.h" 9 | 10 | /*- Implementations ---------------------------------------------------------*/ 11 | 12 | //----------------------------------------------------------------------------- 13 | bool usb_winusb_handle_request(usb_request_t *request) 14 | { 15 | int length = request->wLength; 16 | 17 | switch (USB_CMD_VALUE(request)) 18 | { 19 | case USB_CMD(IN, DEVICE, VENDOR, WINUSB_VENDOR_CODE): 20 | { 21 | if (USB_WINUSB_DESCRIPTOR_INDEX == request->wIndex) 22 | { 23 | length = USB_LIMIT(length, sizeof(usb_msos_descriptor_set_t)); 24 | usb_control_send((uint8_t *)&usb_msos_descriptor_set, length); 25 | } 26 | else 27 | { 28 | return false; 29 | } 30 | } break; 31 | 32 | default: 33 | return false; 34 | } 35 | 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /platform/samd21/usb_descriptors.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | // Copyright (c) 2024, Alex Taradov . All rights reserved. 3 | 4 | #ifndef _USB_DESCRIPTORS_H_ 5 | #define _USB_DESCRIPTORS_H_ 6 | 7 | /*- Includes ----------------------------------------------------------------*/ 8 | #include "usb_std.h" 9 | #include "usb_cdc.h" 10 | #include "usb_hid.h" 11 | #include "usb_winusb.h" 12 | #include "hal_config.h" 13 | 14 | /*- Definitions -------------------------------------------------------------*/ 15 | #define USB_ENABLE_BOS 16 | #define USB_BCD_VERSION 0x0210 17 | 18 | enum 19 | { 20 | USB_STR_ZERO, 21 | USB_STR_MANUFACTURER, 22 | USB_STR_PRODUCT, 23 | USB_STR_SERIAL_NUMBER, 24 | USB_STR_CMSIS_DAP_V1, 25 | USB_STR_CMSIS_DAP_V2, 26 | #ifdef HAL_CONFIG_ENABLE_VCP 27 | USB_STR_COM_PORT, 28 | #endif 29 | USB_STR_COUNT, 30 | }; 31 | 32 | enum 33 | { 34 | USB_HID_EP_SEND = 1, 35 | USB_HID_EP_RECV = 2, 36 | USB_BULK_EP_RECV = 3, 37 | USB_BULK_EP_SEND = 4, 38 | USB_CDC_EP_COMM = 5, 39 | USB_CDC_EP_SEND = 6, 40 | USB_CDC_EP_RECV = 7, 41 | }; 42 | 43 | enum 44 | { 45 | USB_INTF_HID, 46 | USB_INTF_BULK, 47 | #ifdef HAL_CONFIG_ENABLE_VCP 48 | USB_INTF_CDC_COMM, 49 | USB_INTF_CDC_DATA, 50 | #endif 51 | USB_INTF_COUNT, 52 | }; 53 | 54 | /*- Types -------------------------------------------------------------------*/ 55 | typedef struct USB_PACK 56 | { 57 | usb_configuration_descriptor_t configuration; 58 | 59 | usb_interface_descriptor_t hid_interface; 60 | usb_hid_descriptor_t hid; 61 | usb_endpoint_descriptor_t hid_ep_in; 62 | usb_endpoint_descriptor_t hid_ep_out; 63 | 64 | usb_interface_descriptor_t bulk_interface; 65 | usb_endpoint_descriptor_t bulk_ep_out; 66 | usb_endpoint_descriptor_t bulk_ep_in; 67 | 68 | #ifdef HAL_CONFIG_ENABLE_VCP 69 | usb_interface_association_descriptor_t iad; 70 | usb_interface_descriptor_t interface_comm; 71 | usb_cdc_header_functional_descriptor_t cdc_header; 72 | usb_cdc_abstract_control_managment_descriptor_t cdc_acm; 73 | usb_cdc_call_managment_functional_descriptor_t cdc_call_mgmt; 74 | usb_cdc_union_functional_descriptor_t cdc_union; 75 | usb_endpoint_descriptor_t ep_comm; 76 | usb_interface_descriptor_t interface_data; 77 | usb_endpoint_descriptor_t ep_in; 78 | usb_endpoint_descriptor_t ep_out; 79 | #endif 80 | } usb_configuration_hierarchy_t; 81 | 82 | typedef struct USB_PACK 83 | { 84 | usb_binary_object_store_descriptor_t bos; 85 | usb_winusb_capability_descriptor_t winusb; 86 | } usb_bos_hierarchy_t; 87 | 88 | typedef struct USB_PACK 89 | { 90 | usb_winusb_subset_header_function_t header; 91 | usb_winusb_feature_compatble_id_t comp_id; 92 | usb_winusb_feature_reg_property_guids_t property; 93 | } usb_msos_descriptor_subset_t; 94 | 95 | typedef struct USB_PACK 96 | { 97 | usb_winusb_set_header_descriptor_t header; 98 | usb_msos_descriptor_subset_t subset; 99 | } usb_msos_descriptor_set_t; 100 | 101 | //----------------------------------------------------------------------------- 102 | extern const usb_device_descriptor_t usb_device_descriptor; 103 | extern const usb_configuration_hierarchy_t usb_configuration_hierarchy; 104 | extern const usb_bos_hierarchy_t usb_bos_hierarchy; 105 | extern const usb_msos_descriptor_set_t usb_msos_descriptor_set; 106 | extern const uint8_t usb_hid_report_descriptor[28]; 107 | extern const usb_string_descriptor_zero_t usb_string_descriptor_zero; 108 | extern const char *usb_strings[]; 109 | #ifdef HAL_CONFIG_ENABLE_VCP 110 | extern const usb_class_handler_t usb_class_handlers[3]; 111 | #else 112 | extern const usb_class_handler_t usb_class_handlers[2]; 113 | #endif 114 | extern char usb_serial_number[16]; 115 | 116 | #endif // _USB_DESCRIPTORS_H_ 117 | -------------------------------------------------------------------------------- /platform/same70/include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /platform/same70/include/component/gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_GPBR_COMPONENT_ 36 | #define _SAME70_GPBR_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR General Purpose Backup Registers */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAME70_GPBR General Purpose Backup Registers */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Gpbr hardware registers */ 46 | typedef struct { 47 | __IO uint32_t SYS_GPBR[8]; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register */ 48 | } Gpbr; 49 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | /* -------- SYS_GPBR[8] : (GPBR Offset: 0x0) General Purpose Backup Register -------- */ 51 | #define SYS_GPBR_GPBR_VALUE_Pos 0 52 | #define SYS_GPBR_GPBR_VALUE_Msk (0xffffffffu << SYS_GPBR_GPBR_VALUE_Pos) /**< \brief (SYS_GPBR[8]) Value of GPBR x */ 53 | #define SYS_GPBR_GPBR_VALUE(value) ((SYS_GPBR_GPBR_VALUE_Msk & ((value) << SYS_GPBR_GPBR_VALUE_Pos))) 54 | 55 | /*@}*/ 56 | 57 | 58 | #endif /* _SAME70_GPBR_COMPONENT_ */ 59 | -------------------------------------------------------------------------------- /platform/same70/include/component/rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_RTT_COMPONENT_ 36 | #define _SAME70_RTT_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR Real-time Timer */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAME70_RTT Real-time Timer */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Rtt hardware registers */ 46 | typedef struct { 47 | __IO uint32_t RTT_MR; /**< \brief (Rtt Offset: 0x00) Mode Register */ 48 | __IO uint32_t RTT_AR; /**< \brief (Rtt Offset: 0x04) Alarm Register */ 49 | __I uint32_t RTT_VR; /**< \brief (Rtt Offset: 0x08) Value Register */ 50 | __I uint32_t RTT_SR; /**< \brief (Rtt Offset: 0x0C) Status Register */ 51 | } Rtt; 52 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | /* -------- RTT_MR : (RTT Offset: 0x00) Mode Register -------- */ 54 | #define RTT_MR_RTPRES_Pos 0 55 | #define RTT_MR_RTPRES_Msk (0xffffu << RTT_MR_RTPRES_Pos) /**< \brief (RTT_MR) Real-time Timer Prescaler Value */ 56 | #define RTT_MR_RTPRES(value) ((RTT_MR_RTPRES_Msk & ((value) << RTT_MR_RTPRES_Pos))) 57 | #define RTT_MR_ALMIEN (0x1u << 16) /**< \brief (RTT_MR) Alarm Interrupt Enable */ 58 | #define RTT_MR_RTTINCIEN (0x1u << 17) /**< \brief (RTT_MR) Real-time Timer Increment Interrupt Enable */ 59 | #define RTT_MR_RTTRST (0x1u << 18) /**< \brief (RTT_MR) Real-time Timer Restart */ 60 | #define RTT_MR_RTTDIS (0x1u << 20) /**< \brief (RTT_MR) Real-time Timer Disable */ 61 | #define RTT_MR_RTC1HZ (0x1u << 24) /**< \brief (RTT_MR) Real-Time Clock 1Hz Clock Selection */ 62 | /* -------- RTT_AR : (RTT Offset: 0x04) Alarm Register -------- */ 63 | #define RTT_AR_ALMV_Pos 0 64 | #define RTT_AR_ALMV_Msk (0xffffffffu << RTT_AR_ALMV_Pos) /**< \brief (RTT_AR) Alarm Value */ 65 | #define RTT_AR_ALMV(value) ((RTT_AR_ALMV_Msk & ((value) << RTT_AR_ALMV_Pos))) 66 | /* -------- RTT_VR : (RTT Offset: 0x08) Value Register -------- */ 67 | #define RTT_VR_CRTV_Pos 0 68 | #define RTT_VR_CRTV_Msk (0xffffffffu << RTT_VR_CRTV_Pos) /**< \brief (RTT_VR) Current Real-time Value */ 69 | /* -------- RTT_SR : (RTT Offset: 0x0C) Status Register -------- */ 70 | #define RTT_SR_ALMS (0x1u << 0) /**< \brief (RTT_SR) Real-time Alarm Status (cleared on read) */ 71 | #define RTT_SR_RTTINC (0x1u << 1) /**< \brief (RTT_SR) Prescaler Roll-over Status (cleared on read) */ 72 | 73 | /*@}*/ 74 | 75 | 76 | #endif /* _SAME70_RTT_COMPONENT_ */ 77 | -------------------------------------------------------------------------------- /platform/same70/include/component/utmi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_UTMI_COMPONENT_ 36 | #define _SAME70_UTMI_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR USB Transmitter Interface Macrocell */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAME70_UTMI USB Transmitter Interface Macrocell */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Utmi hardware registers */ 46 | typedef struct { 47 | __I uint32_t Reserved1[4]; 48 | __IO uint32_t UTMI_OHCIICR; /**< \brief (Utmi Offset: 0x10) OHCI Interrupt Configuration Register */ 49 | __I uint32_t Reserved2[7]; 50 | __IO uint32_t UTMI_CKTRIM; /**< \brief (Utmi Offset: 0x30) UTMI Clock Trimming Register */ 51 | } Utmi; 52 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | /* -------- UTMI_OHCIICR : (UTMI Offset: 0x10) OHCI Interrupt Configuration Register -------- */ 54 | #define UTMI_OHCIICR_RES0 (0x1u << 0) /**< \brief (UTMI_OHCIICR) USB PORTx Reset */ 55 | #define UTMI_OHCIICR_ARIE (0x1u << 4) /**< \brief (UTMI_OHCIICR) OHCI Asynchronous Resume Interrupt Enable */ 56 | #define UTMI_OHCIICR_APPSTART (0x1u << 5) /**< \brief (UTMI_OHCIICR) Reserved */ 57 | #define UTMI_OHCIICR_UDPPUDIS (0x1u << 23) /**< \brief (UTMI_OHCIICR) USB Device Pull-up Disable */ 58 | /* -------- UTMI_CKTRIM : (UTMI Offset: 0x30) UTMI Clock Trimming Register -------- */ 59 | #define UTMI_CKTRIM_FREQ_Pos 0 60 | #define UTMI_CKTRIM_FREQ_Msk (0x3u << UTMI_CKTRIM_FREQ_Pos) /**< \brief (UTMI_CKTRIM) UTMI Reference Clock Frequency */ 61 | #define UTMI_CKTRIM_FREQ(value) ((UTMI_CKTRIM_FREQ_Msk & ((value) << UTMI_CKTRIM_FREQ_Pos))) 62 | #define UTMI_CKTRIM_FREQ_XTAL12 (0x0u << 0) /**< \brief (UTMI_CKTRIM) 12 MHz reference clock */ 63 | #define UTMI_CKTRIM_FREQ_XTAL16 (0x1u << 0) /**< \brief (UTMI_CKTRIM) 16 MHz reference clock */ 64 | 65 | /*@}*/ 66 | 67 | 68 | #endif /* _SAME70_UTMI_COMPONENT_ */ 69 | -------------------------------------------------------------------------------- /platform/same70/include/component/wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_WDT_COMPONENT_ 36 | #define _SAME70_WDT_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR Watchdog Timer */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAME70_WDT Watchdog Timer */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Wdt hardware registers */ 46 | typedef struct { 47 | __O uint32_t WDT_CR; /**< \brief (Wdt Offset: 0x00) Control Register */ 48 | __IO uint32_t WDT_MR; /**< \brief (Wdt Offset: 0x04) Mode Register */ 49 | __I uint32_t WDT_SR; /**< \brief (Wdt Offset: 0x08) Status Register */ 50 | } Wdt; 51 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 52 | /* -------- WDT_CR : (WDT Offset: 0x00) Control Register -------- */ 53 | #define WDT_CR_WDRSTT (0x1u << 0) /**< \brief (WDT_CR) Watchdog Restart */ 54 | #define WDT_CR_KEY_Pos 24 55 | #define WDT_CR_KEY_Msk (0xffu << WDT_CR_KEY_Pos) /**< \brief (WDT_CR) Password */ 56 | #define WDT_CR_KEY(value) ((WDT_CR_KEY_Msk & ((value) << WDT_CR_KEY_Pos))) 57 | #define WDT_CR_KEY_PASSWD (0xA5u << 24) /**< \brief (WDT_CR) Writing any other value in this field aborts the write operation. */ 58 | /* -------- WDT_MR : (WDT Offset: 0x04) Mode Register -------- */ 59 | #define WDT_MR_WDV_Pos 0 60 | #define WDT_MR_WDV_Msk (0xfffu << WDT_MR_WDV_Pos) /**< \brief (WDT_MR) Watchdog Counter Value */ 61 | #define WDT_MR_WDV(value) ((WDT_MR_WDV_Msk & ((value) << WDT_MR_WDV_Pos))) 62 | #define WDT_MR_WDFIEN (0x1u << 12) /**< \brief (WDT_MR) Watchdog Fault Interrupt Enable */ 63 | #define WDT_MR_WDRSTEN (0x1u << 13) /**< \brief (WDT_MR) Watchdog Reset Enable */ 64 | #define WDT_MR_WDDIS (0x1u << 15) /**< \brief (WDT_MR) Watchdog Disable */ 65 | #define WDT_MR_WDD_Pos 16 66 | #define WDT_MR_WDD_Msk (0xfffu << WDT_MR_WDD_Pos) /**< \brief (WDT_MR) Watchdog Delta Value */ 67 | #define WDT_MR_WDD(value) ((WDT_MR_WDD_Msk & ((value) << WDT_MR_WDD_Pos))) 68 | #define WDT_MR_WDDBGHLT (0x1u << 28) /**< \brief (WDT_MR) Watchdog Debug Halt */ 69 | #define WDT_MR_WDIDLEHLT (0x1u << 29) /**< \brief (WDT_MR) Watchdog Idle Halt */ 70 | /* -------- WDT_SR : (WDT Offset: 0x08) Status Register -------- */ 71 | #define WDT_SR_WDUNF (0x1u << 0) /**< \brief (WDT_SR) Watchdog Underflow (cleared on read) */ 72 | #define WDT_SR_WDERR (0x1u << 1) /**< \brief (WDT_SR) Watchdog Error (cleared on read) */ 73 | 74 | /*@}*/ 75 | 76 | 77 | #endif /* _SAME70_WDT_COMPONENT_ */ 78 | -------------------------------------------------------------------------------- /platform/same70/include/instance/acc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_ACC_INSTANCE_ 36 | #define _SAME70_ACC_INSTANCE_ 37 | 38 | /* ========== Register definition for ACC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_ACC_CR (0x40044000U) /**< \brief (ACC) Control Register */ 41 | #define REG_ACC_MR (0x40044004U) /**< \brief (ACC) Mode Register */ 42 | #define REG_ACC_IER (0x40044024U) /**< \brief (ACC) Interrupt Enable Register */ 43 | #define REG_ACC_IDR (0x40044028U) /**< \brief (ACC) Interrupt Disable Register */ 44 | #define REG_ACC_IMR (0x4004402CU) /**< \brief (ACC) Interrupt Mask Register */ 45 | #define REG_ACC_ISR (0x40044030U) /**< \brief (ACC) Interrupt Status Register */ 46 | #define REG_ACC_ACR (0x40044094U) /**< \brief (ACC) Analog Control Register */ 47 | #define REG_ACC_WPMR (0x400440E4U) /**< \brief (ACC) Write Protection Mode Register */ 48 | #define REG_ACC_WPSR (0x400440E8U) /**< \brief (ACC) Write Protection Status Register */ 49 | #define REG_ACC_VER (0x400440FCU) /**< \brief (ACC) Version Register */ 50 | #else 51 | #define REG_ACC_CR (*(__O uint32_t*)0x40044000U) /**< \brief (ACC) Control Register */ 52 | #define REG_ACC_MR (*(__IO uint32_t*)0x40044004U) /**< \brief (ACC) Mode Register */ 53 | #define REG_ACC_IER (*(__O uint32_t*)0x40044024U) /**< \brief (ACC) Interrupt Enable Register */ 54 | #define REG_ACC_IDR (*(__O uint32_t*)0x40044028U) /**< \brief (ACC) Interrupt Disable Register */ 55 | #define REG_ACC_IMR (*(__I uint32_t*)0x4004402CU) /**< \brief (ACC) Interrupt Mask Register */ 56 | #define REG_ACC_ISR (*(__I uint32_t*)0x40044030U) /**< \brief (ACC) Interrupt Status Register */ 57 | #define REG_ACC_ACR (*(__IO uint32_t*)0x40044094U) /**< \brief (ACC) Analog Control Register */ 58 | #define REG_ACC_WPMR (*(__IO uint32_t*)0x400440E4U) /**< \brief (ACC) Write Protection Mode Register */ 59 | #define REG_ACC_WPSR (*(__I uint32_t*)0x400440E8U) /**< \brief (ACC) Write Protection Status Register */ 60 | #define REG_ACC_VER (*(__I uint32_t*)0x400440FCU) /**< \brief (ACC) Version Register */ 61 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 62 | 63 | #endif /* _SAME70_ACC_INSTANCE_ */ 64 | -------------------------------------------------------------------------------- /platform/same70/include/instance/chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_CHIPID_INSTANCE_ 36 | #define _SAME70_CHIPID_INSTANCE_ 37 | 38 | /* ========== Register definition for CHIPID peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_CHIPID_CIDR (0x400E0940U) /**< \brief (CHIPID) Chip ID Register */ 41 | #define REG_CHIPID_EXID (0x400E0944U) /**< \brief (CHIPID) Chip ID Extension Register */ 42 | #else 43 | #define REG_CHIPID_CIDR (*(__I uint32_t*)0x400E0940U) /**< \brief (CHIPID) Chip ID Register */ 44 | #define REG_CHIPID_EXID (*(__I uint32_t*)0x400E0944U) /**< \brief (CHIPID) Chip ID Extension Register */ 45 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 46 | 47 | #endif /* _SAME70_CHIPID_INSTANCE_ */ 48 | -------------------------------------------------------------------------------- /platform/same70/include/instance/efc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_EFC_INSTANCE_ 36 | #define _SAME70_EFC_INSTANCE_ 37 | 38 | /* ========== Register definition for EFC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_EFC_FMR (0x400E0C00U) /**< \brief (EFC) EEFC Flash Mode Register */ 41 | #define REG_EFC_FCR (0x400E0C04U) /**< \brief (EFC) EEFC Flash Command Register */ 42 | #define REG_EFC_FSR (0x400E0C08U) /**< \brief (EFC) EEFC Flash Status Register */ 43 | #define REG_EFC_FRR (0x400E0C0CU) /**< \brief (EFC) EEFC Flash Result Register */ 44 | #define REG_EFC_VERSION (0x400E0C14U) /**< \brief (EFC) EEFC Version Register */ 45 | #define REG_EFC_WPMR (0x400E0CE4U) /**< \brief (EFC) Write Protection Mode Register */ 46 | #else 47 | #define REG_EFC_FMR (*(__IO uint32_t*)0x400E0C00U) /**< \brief (EFC) EEFC Flash Mode Register */ 48 | #define REG_EFC_FCR (*(__O uint32_t*)0x400E0C04U) /**< \brief (EFC) EEFC Flash Command Register */ 49 | #define REG_EFC_FSR (*(__I uint32_t*)0x400E0C08U) /**< \brief (EFC) EEFC Flash Status Register */ 50 | #define REG_EFC_FRR (*(__I uint32_t*)0x400E0C0CU) /**< \brief (EFC) EEFC Flash Result Register */ 51 | #define REG_EFC_VERSION (*(__I uint32_t*)0x400E0C14U) /**< \brief (EFC) EEFC Version Register */ 52 | #define REG_EFC_WPMR (*(__IO uint32_t*)0x400E0CE4U) /**< \brief (EFC) Write Protection Mode Register */ 53 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 54 | 55 | #endif /* _SAME70_EFC_INSTANCE_ */ 56 | -------------------------------------------------------------------------------- /platform/same70/include/instance/gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_GPBR_INSTANCE_ 36 | #define _SAME70_GPBR_INSTANCE_ 37 | 38 | /* ========== Register definition for GPBR peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_GPBR_GPBR (0x400E1890U) /**< \brief (GPBR) General Purpose Backup Register */ 41 | #else 42 | #define REG_GPBR_GPBR (*(__IO uint32_t*)0x400E1890U) /**< \brief (GPBR) General Purpose Backup Register */ 43 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 44 | 45 | #endif /* _SAME70_GPBR_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /platform/same70/include/instance/rstc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_RSTC_INSTANCE_ 36 | #define _SAME70_RSTC_INSTANCE_ 37 | 38 | /* ========== Register definition for RSTC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RSTC_CR (0x400E1800U) /**< \brief (RSTC) Control Register */ 41 | #define REG_RSTC_SR (0x400E1804U) /**< \brief (RSTC) Status Register */ 42 | #define REG_RSTC_MR (0x400E1808U) /**< \brief (RSTC) Mode Register */ 43 | #else 44 | #define REG_RSTC_CR (*(__O uint32_t*)0x400E1800U) /**< \brief (RSTC) Control Register */ 45 | #define REG_RSTC_SR (*(__I uint32_t*)0x400E1804U) /**< \brief (RSTC) Status Register */ 46 | #define REG_RSTC_MR (*(__IO uint32_t*)0x400E1808U) /**< \brief (RSTC) Mode Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAME70_RSTC_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /platform/same70/include/instance/rswdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | #ifndef _SAME70_RSWDT_INSTANCE_ 35 | #define _SAME70_RSWDT_INSTANCE_ 36 | 37 | /* ========== Register definition for RSWDT peripheral ========== */ 38 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 39 | #define REG_RSWDT_CR (0x400E1900U) /**< \brief (RSWDT) Control Register */ 40 | #define REG_RSWDT_MR (0x400E1904U) /**< \brief (RSWDT) Mode Register */ 41 | #define REG_RSWDT_SR (0x400E1908U) /**< \brief (RSWDT) Status Register */ 42 | #else 43 | #define REG_RSWDT_CR (*(__O uint32_t*)0x400E1900U) /**< \brief (RSWDT) Control Register */ 44 | #define REG_RSWDT_MR (*(__IO uint32_t*)0x400E1904U) /**< \brief (RSWDT) Mode Register */ 45 | #define REG_RSWDT_SR (*(__I uint32_t*)0x400E1908U) /**< \brief (RSWDT) Status Register */ 46 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 47 | 48 | #endif /* _SAME70_RSWDT_INSTANCE_ */ 49 | -------------------------------------------------------------------------------- /platform/same70/include/instance/rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_RTT_INSTANCE_ 36 | #define _SAME70_RTT_INSTANCE_ 37 | 38 | /* ========== Register definition for RTT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RTT_MR (0x400E1830U) /**< \brief (RTT) Mode Register */ 41 | #define REG_RTT_AR (0x400E1834U) /**< \brief (RTT) Alarm Register */ 42 | #define REG_RTT_VR (0x400E1838U) /**< \brief (RTT) Value Register */ 43 | #define REG_RTT_SR (0x400E183CU) /**< \brief (RTT) Status Register */ 44 | #else 45 | #define REG_RTT_MR (*(__IO uint32_t*)0x400E1830U) /**< \brief (RTT) Mode Register */ 46 | #define REG_RTT_AR (*(__IO uint32_t*)0x400E1834U) /**< \brief (RTT) Alarm Register */ 47 | #define REG_RTT_VR (*(__I uint32_t*)0x400E1838U) /**< \brief (RTT) Value Register */ 48 | #define REG_RTT_SR (*(__I uint32_t*)0x400E183CU) /**< \brief (RTT) Status Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAME70_RTT_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /platform/same70/include/instance/supc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_SUPC_INSTANCE_ 36 | #define _SAME70_SUPC_INSTANCE_ 37 | 38 | /* ========== Register definition for SUPC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_SUPC_CR (0x400E1810U) /**< \brief (SUPC) Supply Controller Control Register */ 41 | #define REG_SUPC_SMMR (0x400E1814U) /**< \brief (SUPC) Supply Controller Supply Monitor Mode Register */ 42 | #define REG_SUPC_MR (0x400E1818U) /**< \brief (SUPC) Supply Controller Mode Register */ 43 | #define REG_SUPC_WUMR (0x400E181CU) /**< \brief (SUPC) Supply Controller Wake-up Mode Register */ 44 | #define REG_SUPC_WUIR (0x400E1820U) /**< \brief (SUPC) Supply Controller Wake-up Inputs Register */ 45 | #define REG_SUPC_SR (0x400E1824U) /**< \brief (SUPC) Supply Controller Status Register */ 46 | #define REG_SYSC_VERSION (0x400E190CU) /**< \brief (SUPC) Version Register */ 47 | #else 48 | #define REG_SUPC_CR (*(__O uint32_t*)0x400E1810U) /**< \brief (SUPC) Supply Controller Control Register */ 49 | #define REG_SUPC_SMMR (*(__IO uint32_t*)0x400E1814U) /**< \brief (SUPC) Supply Controller Supply Monitor Mode Register */ 50 | #define REG_SUPC_MR (*(__IO uint32_t*)0x400E1818U) /**< \brief (SUPC) Supply Controller Mode Register */ 51 | #define REG_SUPC_WUMR (*(__IO uint32_t*)0x400E181CU) /**< \brief (SUPC) Supply Controller Wake-up Mode Register */ 52 | #define REG_SUPC_WUIR (*(__IO uint32_t*)0x400E1820U) /**< \brief (SUPC) Supply Controller Wake-up Inputs Register */ 53 | #define REG_SUPC_SR (*(__I uint32_t*)0x400E1824U) /**< \brief (SUPC) Supply Controller Status Register */ 54 | #define REG_SYSC_VERSION (*(__I uint32_t*)0x400E190CU) /**< \brief (SUPC) Version Register */ 55 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 56 | 57 | #endif /* _SAME70_SUPC_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /platform/same70/include/instance/trng.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_TRNG_INSTANCE_ 36 | #define _SAME70_TRNG_INSTANCE_ 37 | 38 | /* ========== Register definition for TRNG peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_TRNG_CR (0x40070000U) /**< \brief (TRNG) Control Register */ 41 | #define REG_TRNG_IER (0x40070010U) /**< \brief (TRNG) Interrupt Enable Register */ 42 | #define REG_TRNG_IDR (0x40070014U) /**< \brief (TRNG) Interrupt Disable Register */ 43 | #define REG_TRNG_IMR (0x40070018U) /**< \brief (TRNG) Interrupt Mask Register */ 44 | #define REG_TRNG_ISR (0x4007001CU) /**< \brief (TRNG) Interrupt Status Register */ 45 | #define REG_TRNG_ODATA (0x40070050U) /**< \brief (TRNG) Output Data Register */ 46 | #define REG_TRNG_VERSION (0x400700FCU) /**< \brief (TRNG) Version Register */ 47 | #else 48 | #define REG_TRNG_CR (*(__O uint32_t*)0x40070000U) /**< \brief (TRNG) Control Register */ 49 | #define REG_TRNG_IER (*(__O uint32_t*)0x40070010U) /**< \brief (TRNG) Interrupt Enable Register */ 50 | #define REG_TRNG_IDR (*(__O uint32_t*)0x40070014U) /**< \brief (TRNG) Interrupt Disable Register */ 51 | #define REG_TRNG_IMR (*(__I uint32_t*)0x40070018U) /**< \brief (TRNG) Interrupt Mask Register */ 52 | #define REG_TRNG_ISR (*(__I uint32_t*)0x4007001CU) /**< \brief (TRNG) Interrupt Status Register */ 53 | #define REG_TRNG_ODATA (*(__I uint32_t*)0x40070050U) /**< \brief (TRNG) Output Data Register */ 54 | #define REG_TRNG_VERSION (*(__I uint32_t*)0x400700FCU) /**< \brief (TRNG) Version Register */ 55 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 56 | 57 | #endif /* _SAME70_TRNG_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /platform/same70/include/instance/utmi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_UTMI_INSTANCE_ 36 | #define _SAME70_UTMI_INSTANCE_ 37 | 38 | /* ========== Register definition for UTMI peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_UTMI_OHCIICR (0x400E0410U) /**< \brief (UTMI) OHCI Interrupt Configuration Register */ 41 | #define REG_UTMI_CKTRIM (0x400E0430U) /**< \brief (UTMI) UTMI Clock Trimming Register */ 42 | #else 43 | #define REG_UTMI_OHCIICR (*(__IO uint32_t*)0x400E0410U) /**< \brief (UTMI) OHCI Interrupt Configuration Register */ 44 | #define REG_UTMI_CKTRIM (*(__IO uint32_t*)0x400E0430U) /**< \brief (UTMI) UTMI Clock Trimming Register */ 45 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 46 | 47 | #endif /* _SAME70_UTMI_INSTANCE_ */ 48 | -------------------------------------------------------------------------------- /platform/same70/include/instance/wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAME70_WDT_INSTANCE_ 36 | #define _SAME70_WDT_INSTANCE_ 37 | 38 | /* ========== Register definition for WDT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_WDT_CR (0x400E1850U) /**< \brief (WDT) Control Register */ 41 | #define REG_WDT_MR (0x400E1854U) /**< \brief (WDT) Mode Register */ 42 | #define REG_WDT_SR (0x400E1858U) /**< \brief (WDT) Status Register */ 43 | #else 44 | #define REG_WDT_CR (*(__O uint32_t*)0x400E1850U) /**< \brief (WDT) Control Register */ 45 | #define REG_WDT_MR (*(__IO uint32_t*)0x400E1854U) /**< \brief (WDT) Mode Register */ 46 | #define REG_WDT_SR (*(__I uint32_t*)0x400E1858U) /**< \brief (WDT) Status Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAME70_WDT_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /platform/same70/include/same70.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | #ifndef _SAME70_ 35 | #define _SAME70_ 36 | 37 | #if defined (__SAME70J19__) 38 | #include "same70j19.h" 39 | #elif defined (__SAME70J20__) 40 | #include "same70j20.h" 41 | #elif defined (__SAME70J21__) 42 | #include "same70j21.h" 43 | #elif defined (__SAME70N19__) 44 | #include "same70n19.h" 45 | #elif defined (__SAME70N20__) 46 | #include "same70n20.h" 47 | #elif defined (__SAME70N21__) 48 | #include "same70n21.h" 49 | #elif defined (__SAME70Q19__) 50 | #include "same70q19.h" 51 | #elif defined (__SAME70Q20__) 52 | #include "same70q20.h" 53 | #elif defined (__SAME70Q21__) 54 | #include "same70q21.h" 55 | #elif defined (__SAME70J19B__) 56 | #include "same70j19b.h" 57 | #elif defined (__SAME70J20B__) 58 | #include "same70j20b.h" 59 | #elif defined (__SAME70J21B__) 60 | #include "same70j21b.h" 61 | #elif defined (__SAME70N19B__) 62 | #include "same70n19b.h" 63 | #elif defined (__SAME70N20B__) 64 | #include "same70n20b.h" 65 | #elif defined (__SAME70N21B__) 66 | #include "same70n21b.h" 67 | #elif defined (__SAME70Q19B__) 68 | #include "same70q19b.h" 69 | #elif defined (__SAME70Q20B__) 70 | #include "same70q20b.h" 71 | #elif defined (__SAME70Q21B__) 72 | #include "same70q21b.h" 73 | #else 74 | #error Library does not support the specified device. 75 | #endif 76 | 77 | #endif /* _SAME70_ */ 78 | -------------------------------------------------------------------------------- /platform/same70/linker/same70n20.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | MEMORY 30 | { 31 | flash (rx) : ORIGIN = 0x00400000, LENGTH = 0x100000 /* 1M */ 32 | ram (rwx) : ORIGIN = 0x20400000, LENGTH = 0x60000 /* 384k */ 33 | } 34 | 35 | __top_flash = ORIGIN(flash) + LENGTH(flash); 36 | __top_ram = ORIGIN(ram) + LENGTH(ram); 37 | 38 | ENTRY(irq_handler_reset) 39 | 40 | SECTIONS 41 | { 42 | .text : ALIGN(4) 43 | { 44 | FILL(0xff) 45 | KEEP(*(.vectors)) 46 | *(.text*) 47 | *(.rodata) 48 | *(.rodata.*) 49 | . = ALIGN(4); 50 | } > flash 51 | 52 | . = ALIGN(4); 53 | _etext = .; 54 | 55 | .uninit_RESERVED : ALIGN(4) 56 | { 57 | KEEP(*(.bss.$RESERVED*)) 58 | } > ram 59 | 60 | .data : ALIGN(4) 61 | { 62 | FILL(0xff) 63 | _data = .; 64 | *(.ramfunc .ramfunc.*); 65 | *(vtable) 66 | *(.data*) 67 | . = ALIGN(4); 68 | _edata = .; 69 | } > ram AT > flash 70 | 71 | .bss : ALIGN(4) 72 | { 73 | _bss = .; 74 | *(.bss*) 75 | *(COMMON) 76 | . = ALIGN(4); 77 | _ebss = .; 78 | PROVIDE(_end = .); 79 | } > ram 80 | 81 | PROVIDE(_stack_top = __top_ram - 0); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /platform/same70/make/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /platform/same70/make/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | BUILD = build 3 | BIN = free_dap 4 | 5 | ############################################################################## 6 | .PHONY: all directory clean size 7 | 8 | CC = arm-none-eabi-gcc 9 | OBJCOPY = arm-none-eabi-objcopy 10 | SIZE = arm-none-eabi-size 11 | 12 | ifeq ($(OS), Windows_NT) 13 | MKDIR = gmkdir 14 | else 15 | MKDIR = mkdir 16 | endif 17 | 18 | CFLAGS += -W -Wall --std=gnu11 -Os 19 | CFLAGS += -fno-diagnostics-show-caret 20 | CFLAGS += -fdata-sections -ffunction-sections 21 | CFLAGS += -funsigned-char -funsigned-bitfields 22 | CFLAGS += -mcpu=cortex-m7 -mthumb 23 | CFLAGS += -mfloat-abi=hard -mfpu=fpv5-d16 24 | CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d 25 | 26 | LDFLAGS += -mcpu=cortex-m7 -mthumb 27 | LDFLAGS += -mfloat-abi=hard -mfpu=fpv5-d16 28 | LDFLAGS += -Wl,--gc-sections 29 | LDFLAGS += -Wl,--script=../linker/same70n20.ld 30 | 31 | INCLUDES += \ 32 | -I../include \ 33 | -I../../.. \ 34 | -I.. 35 | 36 | SRCS += \ 37 | ../main.c \ 38 | ../timer.c \ 39 | ../usb.c \ 40 | ../usb_std.c \ 41 | ../usb_hid.c \ 42 | ../usb_descriptors.c \ 43 | ../startup_same70.c \ 44 | ../../../dap.c \ 45 | 46 | DEFINES += \ 47 | -D__SAME70N20B__ \ 48 | -DDONT_USE_CMSIS_INIT \ 49 | -DF_CPU=150000000 # peripheral frequency 50 | 51 | CFLAGS += $(INCLUDES) $(DEFINES) 52 | 53 | OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) 54 | 55 | all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size 56 | 57 | $(BUILD)/$(BIN).elf: $(OBJS) 58 | @echo LD $@ 59 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 60 | 61 | $(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf 62 | @echo OBJCOPY $@ 63 | @$(OBJCOPY) -O ihex $^ $@ 64 | 65 | $(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf 66 | @echo OBJCOPY $@ 67 | @$(OBJCOPY) -O binary $^ $@ 68 | 69 | %.o: 70 | @echo CC $@ 71 | @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ 72 | 73 | directory: 74 | @$(MKDIR) -p $(BUILD) 75 | 76 | size: $(BUILD)/$(BIN).elf 77 | @echo size: 78 | @$(SIZE) -t $^ 79 | 80 | clean: 81 | @echo clean 82 | @-rm -rf $(BUILD) 83 | 84 | prog: 85 | @edbg -b -t same70 -s 7A9ACC17 -pv -f $(BUILD)/$(BIN).bin 86 | 87 | -include $(wildcard $(BUILD)/*.d) 88 | 89 | -------------------------------------------------------------------------------- /platform/same70/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _TIMER_H_ 30 | #define _TIMER_H_ 31 | 32 | /*- Definitions -------------------------------------------------------------*/ 33 | #define TIMER_TICK 10 // ms 34 | #define TIMER_COUNT 4 35 | 36 | /*- Types -------------------------------------------------------------------*/ 37 | typedef struct 38 | { 39 | int interval; 40 | bool repeat; 41 | bool expired; 42 | int timeout; 43 | } Timer; 44 | 45 | /*- Prototypes --------------------------------------------------------------*/ 46 | void timer_init(void); 47 | void timer_start(Timer *timer); 48 | void timer_stop(Timer *timer); 49 | 50 | #endif // _TIMER_H_ 51 | 52 | -------------------------------------------------------------------------------- /platform/same70/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _USB_H_ 30 | #define _USB_H_ 31 | 32 | /*- Includes ----------------------------------------------------------------*/ 33 | #include 34 | #include 35 | #include "usb_descriptors.h" 36 | 37 | /*- Definitions -------------------------------------------------------------*/ 38 | #define USB_ASYNC 39 | #define USB_EP_NUM 8 40 | #define USB_EP_BANKS { 1, 1, 1, 1, 1, 1, 1, 1 } 41 | 42 | /*- Prototypes --------------------------------------------------------------*/ 43 | void usb_hw_init(void); 44 | void usb_attach(void); 45 | void usb_detach(void); 46 | void usb_reset_endpoint(int ep, int dir); 47 | void usb_configure_endpoint(usb_endpoint_descriptor_t *ep_desc); 48 | bool usb_endpoint_configured(int ep, int dir); 49 | int usb_endpoint_get_status(int ep, int dir); 50 | void usb_endpoint_set_feature(int ep, int dir); 51 | void usb_endpoint_clear_feature(int ep, int dir); 52 | void usb_set_address(int address); 53 | void usb_send(int ep, uint8_t *data, int size); 54 | void usb_recv(int ep, uint8_t *data, int size); 55 | void usb_control_send_zlp(void); 56 | void usb_control_stall(void); 57 | void usb_control_send(uint8_t *data, int size); 58 | void usb_control_recv(void (*callback)(uint8_t *data, int size)); 59 | void usb_task(void); 60 | 61 | void usb_configuration_callback(int config); 62 | 63 | #endif // _USB_H_ 64 | 65 | -------------------------------------------------------------------------------- /platform/same70/usb_descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _USB_DESCRIPTORS_H_ 30 | #define _USB_DESCRIPTORS_H_ 31 | 32 | /*- Includes ----------------------------------------------------------------*/ 33 | #include "usb.h" 34 | #include "usb_std.h" 35 | #include "usb_hid.h" 36 | 37 | /*- Definitions -------------------------------------------------------------*/ 38 | enum 39 | { 40 | USB_STR_ZERO, 41 | USB_STR_MANUFACTURER, 42 | USB_STR_PRODUCT, 43 | USB_STR_SERIAL_NUMBER, 44 | USB_STR_COUNT, 45 | }; 46 | 47 | enum 48 | { 49 | USB_HID_EP_SEND = 1, 50 | USB_HID_EP_RECV = 2, 51 | }; 52 | 53 | /*- Types -------------------------------------------------------------------*/ 54 | typedef struct PACK 55 | { 56 | usb_configuration_descriptor_t configuration; 57 | usb_interface_descriptor_t hid_interface; 58 | usb_hid_descriptor_t hid; 59 | usb_endpoint_descriptor_t hid_ep_in; 60 | usb_endpoint_descriptor_t hid_ep_out; 61 | } usb_configuration_hierarchy_t; 62 | 63 | //----------------------------------------------------------------------------- 64 | extern const usb_device_descriptor_t usb_device_descriptor; 65 | extern const usb_configuration_hierarchy_t usb_configuration_hierarchy; 66 | extern const uint8_t usb_hid_report_descriptor[30]; 67 | extern const usb_string_descriptor_zero_t usb_string_descriptor_zero; 68 | extern const char *usb_strings[]; 69 | extern char usb_serial_number[16]; 70 | 71 | #endif // _USB_DESCRIPTORS_H_ 72 | 73 | -------------------------------------------------------------------------------- /platform/same70/usb_hid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /*- Includes ----------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | #include "utils.h" 34 | #include "usb.h" 35 | #include "usb_std.h" 36 | #include "usb_hid.h" 37 | #include "usb_descriptors.h" 38 | 39 | /*- Prototypes --------------------------------------------------------------*/ 40 | static void usb_hid_ep_send_callback(int size); 41 | static void usb_hid_ep_recv_callback(int size); 42 | 43 | /*- Implementations ---------------------------------------------------------*/ 44 | 45 | //----------------------------------------------------------------------------- 46 | void usb_hid_init(void) 47 | { 48 | usb_set_callback(USB_HID_EP_SEND, usb_hid_ep_send_callback); 49 | usb_set_callback(USB_HID_EP_RECV, usb_hid_ep_recv_callback); 50 | } 51 | 52 | //----------------------------------------------------------------------------- 53 | void usb_hid_send(uint8_t *data, int size) 54 | { 55 | usb_send(USB_HID_EP_SEND, data, size); 56 | } 57 | 58 | //----------------------------------------------------------------------------- 59 | void usb_hid_recv(uint8_t *data, int size) 60 | { 61 | usb_recv(USB_HID_EP_RECV, data, size); 62 | } 63 | 64 | //----------------------------------------------------------------------------- 65 | static void usb_hid_ep_send_callback(int size) 66 | { 67 | usb_hid_send_callback(); 68 | (void)size; 69 | } 70 | 71 | //----------------------------------------------------------------------------- 72 | static void usb_hid_ep_recv_callback(int size) 73 | { 74 | usb_hid_recv_callback(size); 75 | } 76 | 77 | //----------------------------------------------------------------------------- 78 | bool usb_hid_handle_request(usb_request_t *request) 79 | { 80 | int length = request->wLength; 81 | 82 | switch ((request->bRequest << 8) | request->bmRequestType) 83 | { 84 | case USB_CMD(IN, INTERFACE, STANDARD, GET_DESCRIPTOR): 85 | { 86 | length = LIMIT(length, sizeof(usb_hid_report_descriptor)); 87 | 88 | usb_control_send((uint8_t *)usb_hid_report_descriptor, length); 89 | } break; 90 | 91 | default: 92 | return false; 93 | } 94 | 95 | return true; 96 | } 97 | 98 | -------------------------------------------------------------------------------- /platform/same70/usb_hid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _USB_HID_H_ 30 | #define _USB_HID_H_ 31 | 32 | /*- Includes ----------------------------------------------------------------*/ 33 | #include 34 | #include 35 | #include "utils.h" 36 | #include "usb_std.h" 37 | 38 | /*- Definitions -------------------------------------------------------------*/ 39 | enum 40 | { 41 | USB_HID_DESCRIPTOR = 0x21, 42 | USB_HID_REPORT_DESCRIPTOR = 0x22, 43 | USB_HID_PHYSICAL_DESCRIPTOR = 0x23, 44 | }; 45 | 46 | enum 47 | { 48 | USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class 49 | }; 50 | 51 | /*- Types -------------------------------------------------------------------*/ 52 | typedef struct PACK 53 | { 54 | uint8_t bLength; 55 | uint8_t bDescriptorType; 56 | uint16_t bcdHID; 57 | uint8_t bCountryCode; 58 | uint8_t bNumDescriptors; 59 | uint8_t bDescriptorType1; 60 | uint16_t wDescriptorLength; 61 | } usb_hid_descriptor_t; 62 | 63 | /*- Prototypes --------------------------------------------------------------*/ 64 | void usb_hid_init(void); 65 | bool usb_hid_handle_request(usb_request_t *request); 66 | void usb_hid_send(uint8_t *data, int size); 67 | void usb_hid_recv(uint8_t *data, int size); 68 | 69 | void usb_hid_send_callback(void); 70 | void usb_hid_recv_callback(int size); 71 | 72 | #endif // _USB_HID_H_ 73 | 74 | -------------------------------------------------------------------------------- /platform/same70/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Alex Taradov 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _UTILS_H_ 30 | #define _UTILS_H_ 31 | 32 | /*- Definitions -------------------------------------------------------------*/ 33 | #define PACK __attribute__((packed)) 34 | #define WEAK __attribute__((weak)) 35 | #define INLINE static inline __attribute__((always_inline)) 36 | 37 | static inline int LIMIT(int a, int b) 38 | { 39 | return (a > b) ? b : a; 40 | } 41 | 42 | #define ATOMIC_SECTION_ENTER \ 43 | { \ 44 | uint32_t __atomic = __get_PRIMASK(); \ 45 | __disable_irq(); 46 | 47 | #define ATOMIC_SECTION_LEAVE \ 48 | __set_PRIMASK(__atomic); \ 49 | } 50 | 51 | #endif // _UTILS_H_ 52 | 53 | --------------------------------------------------------------------------------