├── rust-toolchain ├── legacy ├── src │ ├── config │ │ ├── board.h │ │ ├── conf_board.h │ │ ├── conf_sleepmgr.h │ │ ├── conf_lcdca.h │ │ ├── conf_gloc.h │ │ ├── conf_aesa.h │ │ ├── conf_ast.h │ │ ├── conf_adcife.h │ │ ├── conf_uart_serial.h │ │ └── conf_clock.h │ ├── ASF │ │ ├── sam │ │ │ ├── utils │ │ │ │ ├── compiler.h │ │ │ │ ├── preprocessor │ │ │ │ │ ├── preprocessor.h │ │ │ │ │ ├── stringz.h │ │ │ │ │ └── tpaste.h │ │ │ │ ├── cmsis │ │ │ │ │ └── sam4l │ │ │ │ │ │ ├── source │ │ │ │ │ │ └── templates │ │ │ │ │ │ │ ├── system_sam4l.h │ │ │ │ │ │ │ ├── exceptions.h │ │ │ │ │ │ │ └── system_sam4l.c │ │ │ │ │ │ └── include │ │ │ │ │ │ ├── instance │ │ │ │ │ │ ├── instance_chipid.h │ │ │ │ │ │ ├── instance_picouart.h │ │ │ │ │ │ ├── instance_gloc.h │ │ │ │ │ │ ├── instance_trng.h │ │ │ │ │ │ ├── instance_hflashc.h │ │ │ │ │ │ ├── instance_hcache.h │ │ │ │ │ │ ├── instance_wdt.h │ │ │ │ │ │ ├── instance_parc.h │ │ │ │ │ │ ├── instance_smap.h │ │ │ │ │ │ ├── instance_dacc.h │ │ │ │ │ │ ├── instance_abdacb.h │ │ │ │ │ │ ├── instance_iisc.h │ │ │ │ │ │ ├── instance_eic.h │ │ │ │ │ │ └── instance_crccu.h │ │ │ │ │ │ ├── sam4l.h │ │ │ │ │ │ └── component │ │ │ │ │ │ └── component_chipid.h │ │ │ │ ├── header_files │ │ │ │ │ └── io.h │ │ │ │ ├── syscalls │ │ │ │ │ └── gcc │ │ │ │ │ │ └── syscalls.c │ │ │ │ └── status_codes.h │ │ │ └── drivers │ │ │ │ └── cpu │ │ │ │ └── sam4l_reset_cause.h │ │ ├── thirdparty │ │ │ └── CMSIS │ │ │ │ ├── Lib │ │ │ │ └── GCC │ │ │ │ │ └── libarm_cortexM4l_math.a │ │ │ │ ├── CMSIS END USER LICENCE AGREEMENT.pdf │ │ │ │ └── README.txt │ │ └── common │ │ │ ├── services │ │ │ └── clock │ │ │ │ └── sam4l │ │ │ │ └── pll.c │ │ │ └── utils │ │ │ ├── interrupt │ │ │ └── interrupt_sam_nvic.c │ │ │ └── interrupt.h │ ├── jumpfunc.s │ ├── attributes.c │ ├── bootloader_board.h │ ├── main.c │ ├── asf.h │ └── bootloader.ld └── README.md ├── .gitignore ├── arch ├── bootloader_cortexm │ ├── src │ │ ├── lib.rs │ │ └── jumper.rs │ └── Cargo.toml └── README.md ├── chips ├── bootloader_nrf52 │ ├── src │ │ ├── lib.rs │ │ ├── bootloader_entry_doublereset.rs │ │ └── bootloader_entry_gpregret.rs │ └── Cargo.toml └── README.md ├── tools ├── bootloader_attributes │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── README.md ├── travis-install-gcc.sh └── run_cargo_fmt.sh ├── boards ├── makepython-nrf52840 │ ├── layout.ld │ ├── README.md │ ├── Makefile │ ├── build.rs │ └── Cargo.toml ├── microbit_v2-bootloader │ ├── layout.ld │ ├── openocd.cfg │ ├── README.md │ ├── Makefile │ ├── build.rs │ └── Cargo.toml ├── nano33ble-bootloader │ ├── layout.ld │ ├── build.rs │ ├── Makefile │ ├── README.md │ └── Cargo.toml ├── nrf52840dk-bootloader │ ├── layout.ld │ ├── README.md │ ├── Makefile │ ├── build.rs │ └── Cargo.toml ├── wm1110_dev-bootloader │ ├── layout.ld │ ├── README.md │ ├── Makefile │ ├── build.rs │ └── Cargo.toml ├── clue_nrf52840-bootloader │ ├── layout.ld │ ├── build.rs │ ├── README.md │ ├── Makefile │ └── Cargo.toml ├── nrf52-bootloader │ └── README.md ├── hail-bootloader │ └── README.md └── imix-bootloader │ └── README.md ├── bootloader ├── Cargo.toml └── src │ ├── lib.rs │ ├── bootloader_entry_always.rs │ ├── active_notifier_null.rs │ ├── active_notifier_ledon.rs │ ├── null_scheduler.rs │ ├── interfaces.rs │ └── bootloader_entry_gpio.rs ├── protocol ├── examples │ └── basic_encode.rs ├── Cargo.toml └── README.md ├── .travis.yml └── .github └── workflows ├── release_microbit_v2.yml └── release_clue_nrf52840.yml /rust-toolchain: -------------------------------------------------------------------------------- 1 | nightly-2023-07-30 2 | -------------------------------------------------------------------------------- /legacy/src/config/board.h: -------------------------------------------------------------------------------- 1 | #include "conf_clock.h" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | target 3 | local_cargo 4 | Cargo.lock 5 | 6 | -------------------------------------------------------------------------------- /arch/bootloader_cortexm/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | pub mod jumper; 4 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/compiler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tock/tock-bootloader/HEAD/legacy/src/ASF/sam/utils/compiler.h -------------------------------------------------------------------------------- /chips/bootloader_nrf52/src/lib.rs: -------------------------------------------------------------------------------- 1 | // #![forbid(unsafe_code)] 2 | #![no_std] 3 | 4 | pub mod bootloader_entry_doublereset; 5 | pub mod bootloader_entry_gpregret; 6 | -------------------------------------------------------------------------------- /arch/README.md: -------------------------------------------------------------------------------- 1 | Architecture-Specific Bootloader Helpers 2 | ======================================== 3 | 4 | Code like moving the vector table is architecture-specific. 5 | 6 | -------------------------------------------------------------------------------- /legacy/src/ASF/thirdparty/CMSIS/Lib/GCC/libarm_cortexM4l_math.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tock/tock-bootloader/HEAD/legacy/src/ASF/thirdparty/CMSIS/Lib/GCC/libarm_cortexM4l_math.a -------------------------------------------------------------------------------- /tools/bootloader_attributes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Tock Project Developers "] 3 | name = "bootloader_attributes" 4 | version = "0.1.0" 5 | -------------------------------------------------------------------------------- /legacy/src/ASF/thirdparty/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tock/tock-bootloader/HEAD/legacy/src/ASF/thirdparty/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf -------------------------------------------------------------------------------- /legacy/src/config/conf_board.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief User board configuration template 5 | * 6 | */ 7 | 8 | #ifndef CONF_BOARD_H 9 | #define CONF_BOARD_H 10 | 11 | #endif // CONF_BOARD_H 12 | -------------------------------------------------------------------------------- /legacy/README.md: -------------------------------------------------------------------------------- 1 | Legacy Bootloader 2 | ================= 3 | 4 | This bootloader is written and C and works for SAM4L platforms. It is being 5 | replaced by the tock version. 6 | 7 | ``` 8 | make [hail|imix|justjump] 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /chips/README.md: -------------------------------------------------------------------------------- 1 | Chip-Specific Bootloader Code 2 | ============================= 3 | 4 | Some chips may need special chip-specific support code for detecting whether to enter 5 | the bootloader or for jumping to kernel code. This folder contains those chip-specific 6 | resources. 7 | -------------------------------------------------------------------------------- /boards/makepython-nrf52840/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 64K 4 | prog (rx) : ORIGIN = 0x00010000, LENGTH = 832K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 32K 4 | prog (rx) : ORIGIN = 0x00008000, LENGTH = 480K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/nano33ble-bootloader/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 64K 4 | prog (rx) : ORIGIN = 0x00010000, LENGTH = 832K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/nrf52840dk-bootloader/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 32K 4 | prog (rx) : ORIGIN = 0x00008000, LENGTH = 480K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/wm1110_dev-bootloader/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 64K 4 | prog (rx) : ORIGIN = 0x00010000, LENGTH = 480K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/clue_nrf52840-bootloader/layout.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | rom (rx) : ORIGIN = 0x00026000, LENGTH = 64K 4 | prog (rx) : ORIGIN = 0x00036000, LENGTH = 808K 5 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K 6 | } 7 | 8 | MPU_MIN_ALIGN = 8K; 9 | PAGE_SIZE = 4K; 10 | 11 | INCLUDE ../kernel_layout.ld 12 | -------------------------------------------------------------------------------- /boards/makepython-nrf52840/README.md: -------------------------------------------------------------------------------- 1 | MakePython nRF52840 Tock Bootloader 2 | =================================== 3 | 4 | This is the implementation of the Tock bootloader for the [MakePython 5 | nRF52840](https://www.makerfabs.com/makepython-nrf52840.html) board. The 6 | bootloader runs using the CDC-ACM over USB stack. 7 | -------------------------------------------------------------------------------- /arch/bootloader_cortexm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bootloader_cortexm" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | 6 | [dependencies] 7 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 8 | #kernel = { path = "../../../tock/kernel" } 9 | 10 | bootloader = { path = "../../bootloader" } 11 | -------------------------------------------------------------------------------- /bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 9 | #kernel = { path = "../../tock/kernel" } 10 | 11 | tock-bootloader-protocol = { path = "../protocol" } 12 | -------------------------------------------------------------------------------- /protocol/examples/basic_encode.rs: -------------------------------------------------------------------------------- 1 | extern crate tockloader_proto; 2 | 3 | use tockloader_proto::prelude::*; 4 | 5 | fn main() { 6 | let r = tockloader_proto::Response::Pong; 7 | let mut e = tockloader_proto::ResponseEncoder::new(&r).unwrap(); 8 | let mut buffer = [0xFFu8; 4]; 9 | let used = e.write(&mut buffer); 10 | println!("Buffer: {:?}", &buffer[0..used]); 11 | } 12 | -------------------------------------------------------------------------------- /bootloader/src/lib.rs: -------------------------------------------------------------------------------- 1 | // #![forbid(unsafe_code)] 2 | #![no_std] 3 | 4 | pub mod active_notifier_ledon; 5 | pub mod active_notifier_null; 6 | pub mod bootloader; 7 | pub mod bootloader_crc; 8 | pub mod bootloader_entry_always; 9 | pub mod bootloader_entry_gpio; 10 | pub mod flash_large_to_small; 11 | pub mod interfaces; 12 | pub mod null_scheduler; 13 | pub mod uart_receive_multiple_timeout; 14 | pub mod uart_receive_timeout; 15 | -------------------------------------------------------------------------------- /tools/travis-install-gcc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | pushd $HOME 7 | 8 | if [ ! -x gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-gcc ]; then 9 | wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2016q4/gcc-arm-none-eabi-6_2-2016q4-20161216-linux.tar.bz2?product=GNU%20ARM%20Embedded%20Toolchain,64-bit,,Linux,6-2016-q4-major -O gcc.tar.bz2 10 | tar -xjf gcc.tar.bz2 11 | fi 12 | 13 | -------------------------------------------------------------------------------- /protocol/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tock-bootloader-protocol" 3 | version = "0.2.2" 4 | authors = ["Jonathan 'theJPster' Pallant "] 5 | description = "A #[no_std] implementation of the protocol used by tockloader and the TockOS bootloader." 6 | license = "MIT/Apache-2.0" 7 | repository = "https://github.com/tock/tock-bootloader" 8 | 9 | [dependencies] 10 | byteorder = { version = "1", default-features = false } 11 | -------------------------------------------------------------------------------- /bootloader/src/bootloader_entry_always.rs: -------------------------------------------------------------------------------- 1 | //! Decide to enter bootloader unconditionally. 2 | 3 | use crate::interfaces; 4 | 5 | pub struct BootloaderEntryAlways {} 6 | 7 | impl BootloaderEntryAlways { 8 | pub fn new() -> BootloaderEntryAlways { 9 | BootloaderEntryAlways {} 10 | } 11 | } 12 | 13 | impl interfaces::BootloaderEntry for BootloaderEntryAlways { 14 | fn stay_in_bootloader(&self) -> bool { 15 | true 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /boards/nrf52-bootloader/README.md: -------------------------------------------------------------------------------- 1 | nRF52840dk Bootloader 2 | ===================== 3 | 4 | This is an experimental version of the Tock bootloader over UART for the nrf52 5 | series of chips. However, no actual boards ever used this version, since no 6 | Tock-compatible boards ever used the nRF52 with an FTDI chip. 7 | 8 | If you would like to use this, however, you can with an older version of the 9 | bootloader: 10 | 11 | ```shell 12 | $ git checkout v1.0.1 13 | ``` 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: rust 3 | 4 | cache: 5 | cargo: true 6 | 7 | os: 8 | - linux 9 | 10 | # If you change this, you must also change Getting_Started.md, Makefile.common, 11 | # and Vagrantfile. 12 | rust: 13 | - nightly-2018-08-16 14 | 15 | script: 16 | - export PATH=$HOME/.cargo/bin:$PATH 17 | - tools/run_cargo_fmt.sh diff 18 | - make -C boards/hail-bootloader 19 | - make -C boards/nrf52-bootloader 20 | - make -C boards/imix-bootloader 21 | 22 | -------------------------------------------------------------------------------- /bootloader/src/active_notifier_null.rs: -------------------------------------------------------------------------------- 1 | //! Do nothing when entering the bootloader. 2 | //! 3 | //! This means nothing will notifying the user the bootloader has started. 4 | 5 | use crate::interfaces; 6 | 7 | pub struct ActiveNotifierNull {} 8 | 9 | impl ActiveNotifierNull { 10 | pub fn new() -> ActiveNotifierNull { 11 | ActiveNotifierNull {} 12 | } 13 | } 14 | 15 | impl interfaces::ActiveNotifier for ActiveNotifierNull { 16 | fn active(&mut self) {} 17 | } 18 | -------------------------------------------------------------------------------- /boards/hail-bootloader/README.md: -------------------------------------------------------------------------------- 1 | The Hail Bootloader 2 | =================== 3 | 4 | Bootloader for Hail written on top of Tock. 5 | 6 | The bootloader for Hail is only implemented for an older version of the 7 | bootloader. To reduce developer overhead, we decided to not port updates to this 8 | platform, and instead stick with the old (but known to be working!) version. 9 | 10 | To build the bootloader for Hail, please use version "v1.0.1" of the bootloader. 11 | 12 | ```shell 13 | $ git checkout v1.0.1 14 | ``` 15 | -------------------------------------------------------------------------------- /boards/imix-bootloader/README.md: -------------------------------------------------------------------------------- 1 | The Imix Bootloader 2 | =================== 3 | 4 | Bootloader for Imix written on top of Tock. 5 | 6 | The bootloader for Imix is only implemented for an older version of the 7 | bootloader. To reduce developer overhead, we decided to not port updates to this 8 | platform, and instead stick with the old (but known to be working!) version. 9 | 10 | To build the bootloader for Imix, please use version "v1.0.1" of the bootloader. 11 | 12 | ```shell 13 | $ git checkout v1.0.1 14 | ``` 15 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/openocd.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/cmsis-dap.cfg] 2 | transport select swd 3 | source [find target/nrf52.cfg] 4 | 5 | # necessary to be backward compatible with openocd 0.10 6 | if { [flash list] == "" } { 7 | set WORKAREASIZE 0x40000 8 | $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0 9 | 10 | flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME 11 | flash bank $_CHIPNAME.uicr nrf51 0x10001000 0 1 1 $_TARGETNAME 12 | } 13 | -------------------------------------------------------------------------------- /boards/nano33ble-bootloader/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | 3 | fn main() { 4 | println!("cargo:rerun-if-changed=layout.ld"); 5 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 6 | 7 | let mut f = bootloader_attributes::get_file(); 8 | bootloader_attributes::write_flags(&mut f, "1.1.3", 0x10000); 9 | bootloader_attributes::write_attribute(&mut f, "board", "nano33ble"); 10 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 11 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x50000"); 12 | } 13 | -------------------------------------------------------------------------------- /boards/clue_nrf52840-bootloader/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | 3 | fn main() { 4 | println!("cargo:rerun-if-changed=layout.ld"); 5 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 6 | 7 | let mut f = bootloader_attributes::get_file(); 8 | bootloader_attributes::write_flags(&mut f, "1.1.3", 0x36000); 9 | bootloader_attributes::write_attribute(&mut f, "board", "clue_nrf52840"); 10 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 11 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x80000"); 12 | } 13 | -------------------------------------------------------------------------------- /legacy/src/jumpfunc.s: -------------------------------------------------------------------------------- 1 | 2 | .syntax unified 3 | .section .text.jumpfunc 4 | .global jump_into_user_code 5 | .thumb_func 6 | jump_into_user_code: 7 | ldr r0, =0x10000 //The address of the payload's .vectors 8 | ldr r1, =0xe000ed08 //The address of the VTOR register (0xE000E000(SCS) + 0xD00(SCB) + 0x8(VTOR)) 9 | str r0, [r1] //Move the payload's VT address into the VTOR register 10 | ldr r1, [r0] //Move the payload's initial SP into r1 11 | mov sp, r1 //Set our SP to that 12 | ldr r0, [r0, #4] //Load the payload's ENTRY into r0 13 | bx r0 //Whoopee 14 | -------------------------------------------------------------------------------- /bootloader/src/active_notifier_ledon.rs: -------------------------------------------------------------------------------- 1 | //! Turn on an LED when entering the bootloader. 2 | 3 | use crate::interfaces; 4 | 5 | pub struct ActiveNotifierLedon<'a> { 6 | led: &'a mut dyn kernel::hil::led::Led, 7 | } 8 | 9 | impl<'a> ActiveNotifierLedon<'a> { 10 | pub fn new(led: &'a mut dyn kernel::hil::led::Led) -> ActiveNotifierLedon<'a> { 11 | led.init(); 12 | led.off(); 13 | ActiveNotifierLedon { led } 14 | } 15 | } 16 | 17 | impl<'a> interfaces::ActiveNotifier for ActiveNotifierLedon<'a> { 18 | fn active(&mut self) { 19 | self.led.on(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chips/bootloader_nrf52/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bootloader_nrf52" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 9 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | 12 | #kernel = { path = "../../../tock/kernel" } 13 | #nrf52 = { path = "../../../tock/chips/nrf52" } 14 | #cortexm4 = { path = "../../../tock/arch/cortex-m4" } 15 | 16 | bootloader = { path = "../../bootloader" } 17 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/README.md: -------------------------------------------------------------------------------- 1 | BBC:MicroBit v2 Tock Bootloader 2 | =================== 3 | 4 | This is the implementation of the Tock bootloader for the BBC:MicroBit v2 5 | board. The bootloader runs using the Debugger UART. 6 | 7 | Compiling 8 | --------- 9 | 10 | To compile the bootloader, simply run the `make` command. 11 | 12 | ``` 13 | make 14 | ``` 15 | 16 | Flashing 17 | -------- 18 | 19 | OpenOCD is needed to flash the bootloader. Running `make flash` will compile it and flash it. 20 | 21 | ``` 22 | make flash 23 | ``` 24 | 25 | Entering 26 | -------- 27 | 28 | Entering the bootloader is done by holding Button A during reset. 29 | -------------------------------------------------------------------------------- /boards/nrf52840dk-bootloader/README.md: -------------------------------------------------------------------------------- 1 | BBC:MicroBit v2 Tock Bootloader 2 | =================== 3 | 4 | This is the implementation of the Tock bootloader for the BBC:MicroBit v2 5 | board. The bootloader runs using the Debugger UART. 6 | 7 | Compiling 8 | --------- 9 | 10 | To compile the bootloader, simply run the `make` command. 11 | 12 | ``` 13 | make 14 | ``` 15 | 16 | Flashing 17 | -------- 18 | 19 | OpenOCD is needed to flash the bootloader. Running `make flash` will compile it and flash it. 20 | 21 | ``` 22 | make flash 23 | ``` 24 | 25 | Entering 26 | -------- 27 | 28 | Entering the bootloader is done by holding Button A during reset. 29 | -------------------------------------------------------------------------------- /boards/wm1110_dev-bootloader/README.md: -------------------------------------------------------------------------------- 1 | BBC:MicroBit v2 Tock Bootloader 2 | =================== 3 | 4 | This is the implementation of the Tock bootloader for the BBC:MicroBit v2 5 | board. The bootloader runs using the Debugger UART. 6 | 7 | Compiling 8 | --------- 9 | 10 | To compile the bootloader, simply run the `make` command. 11 | 12 | ``` 13 | make 14 | ``` 15 | 16 | Flashing 17 | -------- 18 | 19 | OpenOCD is needed to flash the bootloader. Running `make flash` will compile it and flash it. 20 | 21 | ``` 22 | make flash 23 | ``` 24 | 25 | Entering 26 | -------- 27 | 28 | Entering the bootloader is done by holding Button A during reset. 29 | -------------------------------------------------------------------------------- /boards/nrf52840dk-bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms over UART. 2 | 3 | TOCK_ARCH=cortex-m4 4 | TARGET=thumbv7em-none-eabi 5 | PLATFORM=nrf52840dk-bootloader 6 | 7 | include ../Common.mk 8 | 9 | TOCKLOADER=tockloader 10 | 11 | OPENOCD=openocd 12 | OPENOCD_OPTIONS=-f openocd.cfg 13 | 14 | # Upload the kernel over JTAG 15 | .PHONY: flash 16 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 17 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;" 18 | 19 | .PHONY: flash 20 | flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).bin 21 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;" 22 | -------------------------------------------------------------------------------- /boards/wm1110_dev-bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms over UART. 2 | 3 | TOCK_ARCH=cortex-m4 4 | TARGET=thumbv7em-none-eabi 5 | PLATFORM=wm1110_dev-bootloader 6 | 7 | include ../Common.mk 8 | 9 | TOCKLOADER=tockloader 10 | 11 | OPENOCD=openocd 12 | OPENOCD_OPTIONS=-f openocd.cfg 13 | 14 | # Upload the kernel over JTAG 15 | .PHONY: flash 16 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 17 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;" 18 | 19 | .PHONY: flash 20 | flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).bin 21 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;" 22 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM 2 | # over USB. 3 | 4 | TOCK_ARCH=cortex-m4 5 | TARGET=thumbv7em-none-eabi 6 | PLATFORM=microbit_v2-bootloader 7 | 8 | include ../Common.mk 9 | 10 | TOCKLOADER=tockloader 11 | 12 | OPENOCD=openocd 13 | OPENOCD_OPTIONS=-f openocd.cfg 14 | 15 | # Upload the kernel over JTAG 16 | .PHONY: flash 17 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 18 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset halt; shutdown;" 19 | 20 | .PHONY: flash 21 | flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).bin 22 | $(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset halt; shutdown;" 23 | -------------------------------------------------------------------------------- /boards/clue_nrf52840-bootloader/README.md: -------------------------------------------------------------------------------- 1 | Adafruit CLUE - nRF52840 Express with Bluetooth LE Tock Bootloader 2 | =================== 3 | 4 | This is the implementation of the Tock bootloader for the Adafruit CLUE - nRF52840 Express with Bluetooth LE 5 | board. The bootloader runs using the CDC-ACM over USB stack. 6 | 7 | Compiling 8 | --------- 9 | 10 | Here are the steps: 11 | 12 | ``` 13 | make 14 | cp ../../target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.bin ./clue_nrf52840-bootloader.bin 15 | ``` 16 | 17 | Converting to UF2 18 | ----------- 19 | 20 | Install [uf2conf](https://github.com/microsoft/uf2/blob/master/utils/uf2conv.py) 21 | 22 | ``` 23 | uf2conv clue_nrf52840-bootloader.bin -f 0xADA52840 --base 0x26000 --output clue_nrf52840-bootloader.uf2 24 | ``` 25 | -------------------------------------------------------------------------------- /boards/nano33ble-bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM 2 | # over USB. 3 | 4 | TOCK_ARCH=cortex-m4 5 | TARGET=thumbv7em-none-eabi 6 | PLATFORM=nano33ble-bootloader 7 | 8 | include ../Common.mk 9 | 10 | TOCKLOADER=tockloader 11 | 12 | # Where in the flash to load the kernel with `tockloader` 13 | KERNEL_ADDRESS=0x00000 14 | 15 | ifdef PORT 16 | TOCKLOADER_GENERAL_FLAGS += --port $(PORT) 17 | endif 18 | 19 | # Upload the kernel over JTAG 20 | .PHONY: flash 21 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 22 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --jlink $< 23 | 24 | # Upload the kernel over JTAG using OpenOCD 25 | .PHONY: flash-openocd 26 | flash-openocd: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 27 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --openocd $< 28 | -------------------------------------------------------------------------------- /boards/clue_nrf52840-bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM 2 | # over USB. 3 | 4 | TOCK_ARCH=cortex-m4 5 | TARGET=thumbv7em-none-eabi 6 | PLATFORM=clue_nrf52840-bootloader 7 | 8 | include ../Common.mk 9 | 10 | TOCKLOADER=tockloader 11 | 12 | # Where in the flash to load the kernel with `tockloader` 13 | KERNEL_ADDRESS=0x26000 14 | 15 | ifdef PORT 16 | TOCKLOADER_GENERAL_FLAGS += --port $(PORT) 17 | endif 18 | 19 | # Upload the kernel over JTAG 20 | .PHONY: flash 21 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 22 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --jlink $< 23 | 24 | # Upload the kernel over JTAG using OpenOCD 25 | .PHONY: flash-openocd 26 | flash-openocd: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 27 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --openocd $< 28 | -------------------------------------------------------------------------------- /boards/makepython-nrf52840/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM 2 | # over USB. 3 | 4 | TOCK_ARCH=cortex-m4 5 | TARGET=thumbv7em-none-eabi 6 | PLATFORM=makepython-nrf52840-bootloader 7 | 8 | include ../Common.mk 9 | 10 | TOCKLOADER=tockloader 11 | 12 | # Where in the flash to load the kernel with `tockloader` 13 | KERNEL_ADDRESS=0x00000 14 | 15 | ifdef PORT 16 | TOCKLOADER_GENERAL_FLAGS += --port $(PORT) 17 | endif 18 | 19 | # Upload the kernel over JTAG 20 | .PHONY: flash 21 | flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 22 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --jlink $< 23 | 24 | # Upload the kernel over JTAG using OpenOCD 25 | .PHONY: flash-openocd 26 | flash-openocd: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin 27 | $(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --openocd $< 28 | -------------------------------------------------------------------------------- /bootloader/src/null_scheduler.rs: -------------------------------------------------------------------------------- 1 | // Licensed under the Apache License, Version 2.0 or the MIT License. 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT 3 | // Copyright Tock Contributors 2023. 4 | 5 | //! Null scheduler that does not run applications. 6 | 7 | // use crate::collections::list::{List, ListLink, ListNode}; 8 | // use crate::kernel::StoppedExecutingReason; 9 | // use crate::platform::chip::Chip; 10 | // use crate::process::Process; 11 | use kernel::platform::chip::Chip; 12 | use kernel::scheduler; 13 | use kernel::scheduler::SchedulingDecision; 14 | 15 | pub struct NullScheduler {} 16 | 17 | impl<'a> NullScheduler { 18 | pub const fn new() -> NullScheduler { 19 | NullScheduler {} 20 | } 21 | } 22 | 23 | impl<'a, C: Chip> scheduler::Scheduler for NullScheduler { 24 | fn next(&self) -> SchedulingDecision { 25 | scheduler::SchedulingDecision::TrySleep 26 | } 27 | 28 | fn result(&self, _result: kernel::process::StoppedExecutingReason, _: Option) {} 29 | } 30 | -------------------------------------------------------------------------------- /bootloader/src/interfaces.rs: -------------------------------------------------------------------------------- 1 | //! Trait definitions for the bootloader. 2 | 3 | /// Trait for implementing the decision logic on whether to run the bootloader 4 | /// or jump to application code. 5 | pub trait BootloaderEntry { 6 | /// Called to check if the bootloader should stay running (i.e. enter the 7 | /// bootloader). 8 | /// 9 | /// Returns `true` if we should stay in the bootloader, or `false` to jump 10 | /// to application code. 11 | fn stay_in_bootloader(&self) -> bool; 12 | } 13 | 14 | /// Trait for handling the jump from the bootloader to the kernel. 15 | pub trait Jumper { 16 | /// Jump execution to the specified address as though the chip had started 17 | /// executing there. 18 | fn jump(&self, address: u32) -> !; 19 | } 20 | 21 | /// Trait for notifying the user the bootloader is active. 22 | pub trait ActiveNotifier { 23 | /// Called when the bootloader decides it will stay active (i.e. not jump to 24 | /// the kernel). 25 | fn active(&mut self); 26 | } 27 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | use std::env; 3 | 4 | fn main() { 5 | println!("cargo:rerun-if-changed=layout.ld"); 6 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 7 | 8 | let mut f = bootloader_attributes::get_file(); 9 | let version = if let Ok(v) = env::var("BOOTLOADER_VERSION") { 10 | v 11 | } else { 12 | String::from("1.1.3") 13 | }; 14 | bootloader_attributes::write_flags(&mut f, &version, 0x8000); 15 | bootloader_attributes::write_attribute(&mut f, "board", "microbit_v2"); 16 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 17 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x40000"); 18 | if let Ok(bootloader) = env::var("BOOTLOADER_HASH") { 19 | bootloader_attributes::write_attribute(&mut f, "boothash", &bootloader); 20 | } 21 | if let Ok(bootloader_kernel) = env::var("BOOTLOADER_KERNEL_HASH") { 22 | bootloader_attributes::write_attribute(&mut f, "kernhash", &bootloader_kernel); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /boards/nrf52840dk-bootloader/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | use std::env; 3 | 4 | fn main() { 5 | println!("cargo:rerun-if-changed=layout.ld"); 6 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 7 | 8 | let mut f = bootloader_attributes::get_file(); 9 | let version = if let Ok(v) = env::var("BOOTLOADER_VERSION") { 10 | v 11 | } else { 12 | String::from("1.1.3") 13 | }; 14 | bootloader_attributes::write_flags(&mut f, &version, 0x8000); 15 | bootloader_attributes::write_attribute(&mut f, "board", "nrf52840dk"); 16 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 17 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x40000"); 18 | if let Ok(bootloader) = env::var("BOOTLOADER_HASH") { 19 | bootloader_attributes::write_attribute(&mut f, "boothash", &bootloader); 20 | } 21 | if let Ok(bootloader_kernel) = env::var("BOOTLOADER_KERNEL_HASH") { 22 | bootloader_attributes::write_attribute(&mut f, "kernhash", &bootloader_kernel); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /boards/wm1110_dev-bootloader/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | use std::env; 3 | 4 | fn main() { 5 | println!("cargo:rerun-if-changed=layout.ld"); 6 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 7 | 8 | let mut f = bootloader_attributes::get_file(); 9 | let version = if let Ok(v) = env::var("BOOTLOADER_VERSION") { 10 | v 11 | } else { 12 | String::from("1.1.3") 13 | }; 14 | bootloader_attributes::write_flags(&mut f, &version, 0x10000); 15 | bootloader_attributes::write_attribute(&mut f, "board", "wm1110_dev"); 16 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 17 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x50000"); 18 | if let Ok(bootloader) = env::var("BOOTLOADER_HASH") { 19 | bootloader_attributes::write_attribute(&mut f, "boothash", &bootloader); 20 | } 21 | if let Ok(bootloader_kernel) = env::var("BOOTLOADER_KERNEL_HASH") { 22 | bootloader_attributes::write_attribute(&mut f, "kernhash", &bootloader_kernel); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /boards/makepython-nrf52840/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bootloader_attributes; 2 | use std::env; 3 | 4 | fn main() { 5 | println!("cargo:rerun-if-changed=layout.ld"); 6 | println!("cargo:rerun-if-changed=../kernel_layout.ld"); 7 | 8 | let mut f = bootloader_attributes::get_file(); 9 | 10 | let version = if let Ok(v) = env::var("BOOTLOADER_VERSION") { 11 | v 12 | } else { 13 | String::from("1.1.3") 14 | }; 15 | 16 | bootloader_attributes::write_flags(&mut f, &version, 0x10000); 17 | bootloader_attributes::write_attribute(&mut f, "board", "makepython-nrf52840"); 18 | bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4"); 19 | bootloader_attributes::write_attribute(&mut f, "appaddr", "0x50000"); 20 | if let Ok(bootloader) = env::var("BOOTLOADER_HASH") { 21 | bootloader_attributes::write_attribute(&mut f, "boothash", &bootloader); 22 | } 23 | if let Ok(bootloader_kernel) = env::var("BOOTLOADER_KERNEL_HASH") { 24 | bootloader_attributes::write_attribute(&mut f, "kernhash", &bootloader_kernel); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bootloader/src/bootloader_entry_gpio.rs: -------------------------------------------------------------------------------- 1 | //! Decide to enter bootloader based on GPIO pin. 2 | //! 3 | //! This is often connected to a UART RTS pin so that the host-side UART 4 | //! hardware can toggle the pin automatically to enter bootloader mode. 5 | 6 | use kernel::hil; 7 | 8 | use crate::interfaces; 9 | 10 | pub struct BootloaderEntryGpio<'a, G: hil::gpio::Pin + 'a> { 11 | select_pin: &'a G, 12 | } 13 | 14 | impl<'a, G: hil::gpio::Pin + 'a> BootloaderEntryGpio<'a, G> { 15 | pub fn new(select_pin: &'a G) -> BootloaderEntryGpio<'a, G> { 16 | BootloaderEntryGpio { select_pin } 17 | } 18 | } 19 | 20 | impl<'a, G: hil::gpio::Pin + 'a> interfaces::BootloaderEntry for BootloaderEntryGpio<'a, G> { 21 | fn stay_in_bootloader(&self) -> bool { 22 | self.select_pin.make_input(); 23 | 24 | // Check the select pin to see if we should enter bootloader mode. 25 | let mut samples = 10000; 26 | let mut active = 0; 27 | let mut inactive = 0; 28 | while samples > 0 { 29 | if self.select_pin.read() == false { 30 | active += 1; 31 | } else { 32 | inactive += 1; 33 | } 34 | samples -= 1; 35 | } 36 | 37 | active > inactive 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /arch/bootloader_cortexm/src/jumper.rs: -------------------------------------------------------------------------------- 1 | pub struct CortexMJumper {} 2 | 3 | impl CortexMJumper { 4 | pub fn new() -> CortexMJumper { 5 | CortexMJumper {} 6 | } 7 | } 8 | 9 | impl bootloader::interfaces::Jumper for CortexMJumper { 10 | fn jump(&self, address: u32) -> ! { 11 | use core::arch::asm; 12 | unsafe { 13 | asm!( 14 | ".syntax unified \n\ 15 | mov r0, {address} // The address of the payload's .vectors \n\ 16 | ldr r1, =0xe000ed08 // The address of the VTOR register (0xE000E000(SCS) + 0xD00(SCB) + 0x8(VTOR)) \n\ 17 | str r0, [r1] // Move the payload's VT address into the VTOR register \n\ 18 | ldr r1, [r0] // Move the payload's initial SP into r1 \n\ 19 | mov sp, r1 // Set our SP to that \n\ 20 | ldr r0, [r0, #4] // Load the payload's ENTRY into r0 \n\ 21 | bx r0 // Whoopee", 22 | address = in(reg) address, 23 | ); 24 | } 25 | loop {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /boards/nano33ble-bootloader/README.md: -------------------------------------------------------------------------------- 1 | Arduino Nano 33 BLE Tock Bootloader 2 | =================== 3 | 4 | This is the implementation of the Tock bootloader for the Arduino Nano 33 BLE 5 | board. The bootloader runs using the CDC-ACM over USB stack. 6 | 7 | Compiling 8 | --------- 9 | 10 | We actually need to compile the bootloader twice, at two different addresses. 11 | The main bootloader will reside at address `0x00000000` in flash. That is the 12 | default address specified in the `layout.ld` linker script. However, we also 13 | need a temporary "helper" bootloader compiled for address `0x10000`. We will use 14 | the helper bootloader to replace the stock Nano 33 BLE bootloader with our own. 15 | 16 | Here are the steps: 17 | 18 | ``` 19 | make 20 | cp ../../target/thumbv7em-none-eabi/release/nano33ble-bootloader.bin ./nano33ble-bootloader-0x00000.bin 21 | 22 | 23 | # Edit layout.ld. 24 | # Change "rom (rx) : ORIGIN = 0x00000000, LENGTH = 64K" to 25 | # "rom (rx) : ORIGIN = 0x00010000, LENGTH = 64K" 26 | 27 | # Edit build.rs 28 | # Change "bootloader_attributes::write_flags(&mut f, "1.1.0", 0x10000);" to 29 | # "bootloader_attributes::write_flags(&mut f, "1.1.0", 0x20000);" 30 | 31 | make 32 | cp ../../target/thumbv7em-none-eabi/release/nano33ble-bootloader.bin ./nano33ble-bootloader-0x10000.bin 33 | 34 | # Undo changes 35 | git stash 36 | ``` 37 | -------------------------------------------------------------------------------- /boards/microbit_v2-bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "microbit_v2-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52833 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | 16 | # For Development 17 | # cortexm4 = { path = "../../../tock/arch/cortex-m4" } 18 | # capsules = { path = "../../../tock/capsules" } 19 | # kernel = { path = "../../../tock/kernel" } 20 | # nrf52 = { path = "../../../tock/chips/nrf52" } 21 | # nrf52833 = { path = "../../../tock/chips/nrf52833" } 22 | # components = { path = "../../../tock/boards/components" } 23 | 24 | bootloader = { path = "../../bootloader" } 25 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 26 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 27 | 28 | 29 | [build-dependencies] 30 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 31 | 32 | [profile.dev] 33 | panic = "abort" 34 | lto = false 35 | opt-level = "z" 36 | debug = true 37 | 38 | [profile.release] 39 | panic = "abort" 40 | lto = true 41 | opt-level = "z" 42 | debug = true 43 | -------------------------------------------------------------------------------- /legacy/src/attributes.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "bootloader_board.h" 4 | 5 | /* Specify a section at the beginning of flash to reserve for state 6 | * about the board. 7 | * 8 | * The first page (512 bytes) is for flags. This starts with "TOCKBOOTLOADER" 9 | * which allows tools to detect that a bootloader is present on the board. 10 | * 11 | * The second and third pages (1024 bytes) are for the attributes that the 12 | * bootloader can access. 13 | */ 14 | 15 | 16 | __attribute__ ((section(".attributes"))) 17 | struct { 18 | char flag_bootloader_exists[14]; 19 | char flag_version_string[8]; 20 | uint8_t flags_reserved[490]; 21 | char attribute00[ATTRIBUTES_00_LEN]; 22 | uint8_t attribute00_padding[64-ATTRIBUTES_00_LEN]; 23 | char attribute01[ATTRIBUTES_01_LEN]; 24 | uint8_t attribute01_padding[64-ATTRIBUTES_01_LEN]; 25 | char attribute02[ATTRIBUTES_02_LEN]; 26 | uint8_t attribute02_padding[64-ATTRIBUTES_02_LEN]; 27 | uint8_t attributes[832]; 28 | } attributes = { 29 | .flag_bootloader_exists = {'T', 'O', 'C', 'K', 'B', 'O', 'O', 'T', 'L', 'O', 'A', 'D', 'E', 'R'}, 30 | .flag_version_string = {'0', '.', '6', '.', '0', '\0', '\0', '\0'}, 31 | .flags_reserved = {0x00}, 32 | .attribute00 = ATTRIBUTES_00_DEF, 33 | .attribute00_padding = {0x00}, 34 | .attribute01 = ATTRIBUTES_01_DEF, 35 | .attribute01_padding = {0x00}, 36 | .attribute02 = ATTRIBUTES_02_DEF, 37 | .attribute02_padding = {0x00}, 38 | .attributes = {0x00} 39 | }; 40 | -------------------------------------------------------------------------------- /legacy/src/ASF/thirdparty/CMSIS/README.txt: -------------------------------------------------------------------------------- 1 | * ------------------------------------------------------------------- 2 | * Copyright (C) 2011 ARM Limited. All rights reserved. 3 | * 4 | * Date: 11 October 2011 5 | * Revision: V3.00 6 | * 7 | * Project: Cortex Microcontroller Software Interface Standard (CMSIS) 8 | * Title: Release Note for CMSIS 9 | * 10 | * ------------------------------------------------------------------- 11 | 12 | 13 | NOTE - Open the index.html file to access CMSIS documentation 14 | 15 | 16 | The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all 17 | Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects 18 | and reduces time-to-market for new embedded applications. 19 | 20 | CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf"). 21 | Any user of the software package is bound to the terms and conditions of the end user license agreement. 22 | 23 | 24 | You will find the following sub-directories: 25 | 26 | Documentation - Contains CMSIS documentation. 27 | 28 | DSP_Lib - MDK project files, Examples and source files etc.. to build the 29 | CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors. 30 | 31 | Include - CMSIS Core Support and CMSIS DSP Include Files. 32 | 33 | Lib - CMSIS DSP Libraries. 34 | 35 | RTOS - CMSIS RTOS API template header file. 36 | 37 | SVD - CMSIS SVD Schema files and Conversion Utility. 38 | -------------------------------------------------------------------------------- /boards/nrf52840dk-bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nrf52840dk-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | capsules-extra = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | nrf52840 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 16 | nrf52_components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 17 | 18 | # For Development 19 | # cortexm4 = { path = "../../../tock/arch/cortex-m4" } 20 | # capsules = { path = "../../../tock/capsules" } 21 | # kernel = { path = "../../../tock/kernel" } 22 | # nrf52 = { path = "../../../tock/chips/nrf52" } 23 | # nrf52833 = { path = "../../../tock/chips/nrf52833" } 24 | # components = { path = "../../../tock/boards/components" } 25 | 26 | bootloader = { path = "../../bootloader" } 27 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 28 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 29 | 30 | 31 | [build-dependencies] 32 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 33 | 34 | [profile.dev] 35 | panic = "abort" 36 | lto = false 37 | opt-level = "z" 38 | debug = true 39 | 40 | [profile.release] 41 | panic = "abort" 42 | lto = true 43 | opt-level = "z" 44 | debug = false 45 | -------------------------------------------------------------------------------- /boards/wm1110_dev-bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wm1110_dev-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | capsules-extra = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | nrf52840 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 16 | nrf52_components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 17 | 18 | # For Development 19 | # cortexm4 = { path = "../../../tock/arch/cortex-m4" } 20 | # capsules = { path = "../../../tock/capsules" } 21 | # kernel = { path = "../../../tock/kernel" } 22 | # nrf52 = { path = "../../../tock/chips/nrf52" } 23 | # nrf52833 = { path = "../../../tock/chips/nrf52833" } 24 | # components = { path = "../../../tock/boards/components" } 25 | 26 | bootloader = { path = "../../bootloader" } 27 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 28 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 29 | 30 | 31 | [build-dependencies] 32 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 33 | 34 | [profile.dev] 35 | panic = "abort" 36 | lto = false 37 | opt-level = "z" 38 | debug = true 39 | 40 | [profile.release] 41 | panic = "abort" 42 | lto = true 43 | opt-level = "z" 44 | debug = true 45 | -------------------------------------------------------------------------------- /boards/nano33ble-bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nano33ble-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | capsules-extra = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | nrf52840 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 16 | nrf52_components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 17 | 18 | # For Development 19 | #cortexm4 = { path = "../../../tock/arch/cortex-m4" } 20 | #capsules = { path = "../../../tock/capsules" } 21 | #kernel = { path = "../../../tock/kernel" } 22 | #nrf52 = { path = "../../../tock/chips/nrf52" } 23 | #nrf52840 = { path = "../../../tock/chips/nrf52840" } 24 | #components = { path = "../../../tock/boards/components" } 25 | #nrf52_components = { path = "../../../tock/boards/nordic/nrf52_components" } 26 | 27 | bootloader = { path = "../../bootloader" } 28 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 29 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 30 | 31 | 32 | [build-dependencies] 33 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 34 | 35 | [profile.dev] 36 | panic = "abort" 37 | lto = false 38 | opt-level = "z" 39 | debug = true 40 | 41 | [profile.release] 42 | panic = "abort" 43 | lto = true 44 | opt-level = "z" 45 | debug = true 46 | -------------------------------------------------------------------------------- /boards/makepython-nrf52840/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "makepython-nrf52840-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | capsules-extra = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | nrf52840 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 16 | nrf52_components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 17 | 18 | # For Development 19 | #cortexm4 = { path = "../../../tock/arch/cortex-m4" } 20 | #capsules = { path = "../../../tock/capsules" } 21 | #kernel = { path = "../../../tock/kernel" } 22 | #nrf52 = { path = "../../../tock/chips/nrf52" } 23 | #nrf52840 = { path = "../../../tock/chips/nrf52840" } 24 | #components = { path = "../../../tock/boards/components" } 25 | #nrf52_components = { path = "../../../tock/boards/nordic/nrf52_components" } 26 | 27 | bootloader = { path = "../../bootloader" } 28 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 29 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 30 | 31 | 32 | [build-dependencies] 33 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 34 | 35 | [profile.dev] 36 | panic = "abort" 37 | lto = false 38 | opt-level = "z" 39 | debug = true 40 | 41 | [profile.release] 42 | panic = "abort" 43 | lto = true 44 | opt-level = "z" 45 | debug = true 46 | -------------------------------------------------------------------------------- /boards/clue_nrf52840-bootloader/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "clue_nrf52840-bootloader" 3 | version = "0.1.0" 4 | authors = ["Tock Project Developers "] 5 | build = "build.rs" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | cortexm4 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 10 | capsules-core = { git = "https://github.com/tock/tock", rev = "2ff6868" } 11 | capsules-extra = { git = "https://github.com/tock/tock", rev = "2ff6868" } 12 | kernel = { git = "https://github.com/tock/tock", rev = "2ff6868" } 13 | nrf52 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 14 | nrf52840 = { git = "https://github.com/tock/tock", rev = "2ff6868" } 15 | components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 16 | nrf52_components = { git = "https://github.com/tock/tock", rev = "2ff6868" } 17 | 18 | # For Development 19 | # cortexm4 = { path = "../../../tock/arch/cortex-m4" } 20 | # capsules = { path = "../../../tock/capsules" } 21 | # kernel = { path = "../../../tock/kernel" } 22 | # nrf52 = { path = "../../../tock/chips/nrf52" } 23 | # nrf52840 = { path = "../../../tock/chips/nrf52840" } 24 | # components = { path = "../../../tock/boards/components" } 25 | # nrf52_components = { path = "../../../tock/boards/nordic/nrf52_components" } 26 | 27 | bootloader = { path = "../../bootloader" } 28 | bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" } 29 | bootloader_cortexm = { path = "../../arch/bootloader_cortexm" } 30 | 31 | 32 | [build-dependencies] 33 | bootloader_attributes = { path = "../../tools/bootloader_attributes" } 34 | 35 | [profile.dev] 36 | panic = "abort" 37 | lto = false 38 | opt-level = "z" 39 | debug = true 40 | 41 | [profile.release] 42 | panic = "abort" 43 | lto = true 44 | opt-level = "z" 45 | debug = true 46 | -------------------------------------------------------------------------------- /protocol/README.md: -------------------------------------------------------------------------------- 1 | # Tockloader Protocol 2 | 3 | Implements the Tock bootloader over-the-wire protocol. 4 | 5 | Originally from: https://github.com/thejpster/tockloader-proto-rs 6 | 7 | 8 | Usage 9 | ----- 10 | 11 | In your embedded bootloader, you need a loop that looks something like: 12 | 13 | ```rust 14 | use tockloader_proto::{ResponseEncoder, CommandDecoder}; 15 | 16 | #[no_mangle] 17 | pub extern "C" fn main() { 18 | let mut uart = uart::Uart::new(uart::UartId::Uart0, 115200, uart::NewlineMode::Binary); 19 | let mut decoder = CommandDecoder::new(); 20 | loop { 21 | if let Ok(Some(ch)) = uart.getc_try() { 22 | let mut need_reset = false; 23 | let response = match decoder.receive(ch) { 24 | Ok(None) => None, 25 | Ok(Some(tockloader_proto::Command::Ping)) => Some(tockloader_proto::Response::Pong), 26 | Ok(Some(tockloader_proto::Command::Reset)) => { 27 | need_reset = true; 28 | None 29 | }, 30 | Ok(Some(_)) => Some(tockloader_proto::Response::Unknown), 31 | Err(_) => Some(tockloader_proto::Response::InternalError), 32 | }; 33 | if need_reset { 34 | decoder.reset(); 35 | } 36 | if let Some(response) = response { 37 | let mut encoder = ResponseEncoder::new(&response).unwrap(); 38 | while let Some(byte) = encoder.next() { 39 | uart.putc(byte); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | ``` 46 | 47 | Using this library in a CLI flash tool (like tockloader) is left as an excercise 48 | for the read (hint: you want `ResponseDecoder` and `CommandEncoder`). 49 | -------------------------------------------------------------------------------- /legacy/src/bootloader_board.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if TOCK_BOARD_hail == 1 4 | #define BOOTLOADER_SELECT_PIN PIN_PA08 5 | 6 | #define BOOTLOADER_UART_TX_PIN PIN_PA12A_USART0_TXD 7 | #define BOOTLOADER_UART_TX_MUX MUX_PA12A_USART0_TXD 8 | #define BOOTLOADER_UART_RX_PIN PIN_PA11A_USART0_RXD 9 | #define BOOTLOADER_UART_RX_MUX MUX_PA11A_USART0_RXD 10 | #define BOOTLOADER_UART USART0 11 | 12 | #define ATTRIBUTES_00_LEN 13 13 | #define ATTRIBUTES_00_DEF {'b','o','a','r','d','\0','\0','\0',4,'h','a','i','l'} 14 | #define ATTRIBUTES_01_LEN 18 15 | #define ATTRIBUTES_01_DEF {'a','r','c','h','\0','\0','\0','\0',9,'c','o','r','t','e','x','-','m','4'} 16 | #define ATTRIBUTES_02_LEN 19 17 | #define ATTRIBUTES_02_DEF {'j','l','d','e','v','i','c','e',10,'A','T','S','A','M','4','L','C','8','C'} 18 | 19 | #elif TOCK_BOARD_imix == 1 20 | #define BOOTLOADER_SELECT_PIN PIN_PB06 21 | 22 | #define BOOTLOADER_UART_TX_PIN PIN_PB10A_USART3_TXD 23 | #define BOOTLOADER_UART_TX_MUX MUX_PB10A_USART3_TXD 24 | #define BOOTLOADER_UART_RX_PIN PIN_PB09A_USART3_RXD 25 | #define BOOTLOADER_UART_RX_MUX MUX_PB09A_USART3_RXD 26 | #define BOOTLOADER_UART USART3 27 | 28 | #define ATTRIBUTES_00_LEN 13 29 | #define ATTRIBUTES_00_DEF {'b','o','a','r','d','\0','\0','\0',4,'i','m','i','x'} 30 | #define ATTRIBUTES_01_LEN 18 31 | #define ATTRIBUTES_01_DEF {'a','r','c','h','\0','\0','\0','\0',9,'c','o','r','t','e','x','-','m','4'} 32 | #define ATTRIBUTES_02_LEN 19 33 | #define ATTRIBUTES_02_DEF {'j','l','d','e','v','i','c','e',10,'A','T','S','A','M','4','L','C','8','C'} 34 | 35 | #elif TOCK_BOARD_justjump == 1 36 | 37 | // unused, but defined for compilation 38 | #define BOOTLOADER_UART_TX_PIN PIN_PA12A_USART0_TXD 39 | #define BOOTLOADER_UART_TX_MUX MUX_PA12A_USART0_TXD 40 | #define BOOTLOADER_UART_RX_PIN PIN_PA11A_USART0_RXD 41 | #define BOOTLOADER_UART_RX_MUX MUX_PA11A_USART0_RXD 42 | #define BOOTLOADER_UART USART0 43 | 44 | #define ATTRIBUTES_00_LEN 1 45 | #define ATTRIBUTES_00_DEF {0x00} 46 | #define ATTRIBUTES_01_LEN 1 47 | #define ATTRIBUTES_01_DEF {0x00} 48 | #define ATTRIBUTES_02_LEN 1 49 | #define ATTRIBUTES_02_DEF {0x00} 50 | 51 | 52 | #else 53 | #error "No TOCK_BOARD defined!" 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /legacy/src/config/conf_sleepmgr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip-specific sleep manager configuration 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef CONF_SLEEPMGR_INCLUDED 44 | #define CONF_SLEEPMGR_INCLUDED 45 | 46 | // Sleep manager options 47 | #define CONFIG_SLEEPMGR_ENABLE 48 | 49 | #endif /* CONF_SLEEPMGR_INCLUDED */ 50 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/preprocessor/preprocessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor utils. 5 | * 6 | * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _PREPROCESSOR_H_ 45 | #define _PREPROCESSOR_H_ 46 | 47 | #include "tpaste.h" 48 | #include "stringz.h" 49 | #include "mrepeat.h" 50 | 51 | 52 | #endif // _PREPROCESSOR_H_ 53 | -------------------------------------------------------------------------------- /legacy/src/config/conf_lcdca.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM Liquid Crystal Display driver (LCDCA). 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef CONF_LCDCA_H_INCLUDED 44 | #define CONF_LCDCA_H_INCLUDED 45 | 46 | #include "sysclk.h" 47 | 48 | /** Source Clock of LCD Controller */ 49 | #define CONF_LCDCA_SOURCE_CLK OSC_ID_OSC32 50 | 51 | #endif /* CONF_LCDCA_H_INCLUDED */ 52 | -------------------------------------------------------------------------------- /legacy/src/config/conf_gloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief GLOC configuration. 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | /** Configuration of the GLOC module. */ 45 | 46 | #ifndef CONF_GLOC_H_INCLUDED 47 | #define CONF_GLOC_H_INCLUDED 48 | 49 | /* Generic clock setting for GLOC */ 50 | #define CONFIG_GLOC_GENCLK_SRC GENCLK_SRC_RCSYS 51 | #define CONFIG_GLOC_GENCLK_DIV 1 52 | 53 | #endif /* CONF_GLOC_H_INCLUDED */ 54 | -------------------------------------------------------------------------------- /legacy/src/config/conf_aesa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief AESA configuration. 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | /** Configuration of the AESA driver. */ 45 | 46 | #ifndef CONF_AESA_H_INCLUDED 47 | #define CONF_AESA_H_INCLUDED 48 | 49 | /* Generic clock setting for CLK_AESA */ 50 | #define CONFIG_AESA_GENERIC_SRC GENCLK_SRC_CLK_CPU 51 | #define CONFIG_AESA_GENERIC_DIV 1 52 | 53 | #endif /* CONF_AESA_H_INCLUDED */ 54 | -------------------------------------------------------------------------------- /legacy/src/config/conf_ast.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief AST configuration. 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | //! Configuration of the AST driver 45 | 46 | #ifndef CONF_AST_H_INCLUDED 47 | #define CONF_AST_H_INCLUDED 48 | 49 | //#define AST_PER_ENABLE 50 | #define AST_ALARM_ENABLE 51 | // #define AST_OVF_ENABLE 52 | // #define AST_READY_ENABLE 53 | // #define AST_CLKREADY_ENABLE 54 | 55 | #endif /* CONF_AST_H_INCLUDED */ 56 | -------------------------------------------------------------------------------- /legacy/src/config/conf_adcife.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief ADCIFE configuration. 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | //! Configuration of the ADCIFE driver 45 | 46 | #ifndef CONF_ADCIFE_H_INCLUDED 47 | #define CONF_ADCIFE_H_INCLUDED 48 | 49 | /* Generic clock setting for CLK_ADCIFE */ 50 | #define CONFIG_ADC_GENERIC_SRC GENCLK_SRC_CLK_CPU 51 | #define CONFIG_ADC_GENERIC_DIV 1 52 | #define CONFIG_ADC_STARTUP 24 53 | #define CONFIG_ADC_PDCA_RX_CHANNEL 0 54 | #define CONFIG_ADC_PDCA_TX_CHANNEL 1 55 | 56 | #endif /* CONF_ADCIFE_H_INCLUDED */ 57 | -------------------------------------------------------------------------------- /chips/bootloader_nrf52/src/bootloader_entry_doublereset.rs: -------------------------------------------------------------------------------- 1 | //! Decide to enter bootloader based on checking for rapid double resets. 2 | 3 | use kernel::utilities::cells::VolatileCell; 4 | use kernel::utilities::StaticRef; 5 | 6 | /// Magic value for the double reset memory location indicating we should stay 7 | /// in the bootloader. This value (and name) is taken from the Adafruit nRF52 8 | /// bootloader. 9 | const DFU_DBL_RESET_MAGIC: u32 = 0x5A1AD5; 10 | 11 | /// Memory location we use as a flag for detecting a double reset. 12 | /// 13 | /// I have no idea why we use address 0x20007F7C, but that is what the Adafruit 14 | /// nRF52 bootloader uses, so I copied it. 15 | const DOUBLE_RESET_MEMORY_LOCATION: StaticRef> = 16 | unsafe { StaticRef::new(0x20007F7C as *const VolatileCell) }; 17 | 18 | pub struct BootloaderEntryDoubleReset { 19 | double_reset: StaticRef>, 20 | } 21 | 22 | impl BootloaderEntryDoubleReset { 23 | pub fn new() -> BootloaderEntryDoubleReset { 24 | BootloaderEntryDoubleReset { 25 | double_reset: DOUBLE_RESET_MEMORY_LOCATION, 26 | } 27 | } 28 | } 29 | 30 | impl bootloader::interfaces::BootloaderEntry for BootloaderEntryDoubleReset { 31 | fn stay_in_bootloader(&self) -> bool { 32 | // If the retention flag is not set, then we check for the double reset 33 | // memory location. If this is set to a magic value, then we got two 34 | // resets in a short amount of time and we want to go into the 35 | // bootloader. 36 | if self.double_reset.get() == DFU_DBL_RESET_MAGIC { 37 | self.double_reset.set(0); 38 | return true; 39 | } 40 | 41 | // If neither magic value is set, then we need to check if we just got 42 | // the first of a double reset. We do this by setting our flag and 43 | // entering a busy loop. If the busy loop finishes then we must not have 44 | // gotten a second reset and we go to the kernel. If the busy loop 45 | // doesn't finish because we got a reset in the middle, then the 46 | // bootloader will restart and the check above should trigger. 47 | self.double_reset.set(DFU_DBL_RESET_MAGIC); 48 | for _ in 0..2000000 { 49 | cortexm4::support::nop(); 50 | } 51 | self.double_reset.set(0); 52 | 53 | // Default to jumping out of the bootloader. 54 | false 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/source/templates/system_sam4l.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup. 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef SYSTEM_SAM4L_H_INCLUDED 45 | #define SYSTEM_SAM4L_H_INCLUDED 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | #include 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | void SystemInit(void); 56 | void SystemCoreClockUpdate(void); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* SYSTEM_SAM4L_H_INCLUDED */ 63 | -------------------------------------------------------------------------------- /tools/run_cargo_fmt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Verify that we're running in the base directory 6 | if [ ! -x tools/run_cargo_fmt.sh ]; then 7 | echo ERROR: $0 must be run from the tock repository root. 8 | echo "" 9 | exit 1 10 | fi 11 | 12 | # Add the rustfmt component if needed. 13 | if ! rustup component list | grep 'rustfmt-preview.*(installed)' -q; then 14 | rustup component add rustfmt-preview 15 | fi 16 | 17 | # Format overwrites changes, which is probably good, but it's nice to see 18 | # what it has done 19 | # 20 | # `git status --porcelain` formats things for scripting 21 | # | M changed file, unstaged 22 | # |M changed file, staged (git add has run) 23 | # |MM changed file, some staged and some unstaged changes (git add then changes) 24 | # |?? untracked file 25 | if git status --porcelain | grep '^.M.*\.rs' -q; then 26 | echo "$(tput bold)Warning: Formatting will overwrite files in place.$(tput sgr0)" 27 | echo "While this is probably what you want, it's often useful to" 28 | echo "stage all of your changes (git add ...) before format runs," 29 | echo "just so you can double-check everything." 30 | echo "" 31 | echo "$(tput bold)git status:$(tput sgr0)" 32 | git status 33 | echo "" 34 | read -p "Continue formatting with unstaged changes? [y/N] " response 35 | if [[ ! ( "$(echo "$response" | tr :upper: :lower:)" == "y" ) ]]; then 36 | exit 0 37 | fi 38 | fi 39 | 40 | set +e 41 | let FAIL=0 42 | set -e 43 | 44 | # Find folders with Cargo.toml files in them and run `cargo fmt`. 45 | if [ "$1" == "diff" ]; then 46 | # Just print out diffs and count errors, used by Travis 47 | CARGO_FMT_ARGS="-- --check" 48 | fi 49 | for f in $(find . | grep Cargo.toml); do 50 | pushd $(dirname $f) > /dev/null 51 | cargo-fmt $CARGO_FMT_ARGS || let FAIL=FAIL+1 52 | popd > /dev/null 53 | done 54 | 55 | # rustfmt doesn't have an option for this, so do it manually 56 | # Find folders with Cargo.toml files in them and check them (avoids matching this script!) 57 | for f in $(find . | grep Cargo.toml); do 58 | pushd $(dirname $f) > /dev/null 59 | if $(git grep -q 'use .*\*;'); then 60 | echo 61 | echo "$(tput bold)Wildcard import(s) found in $(dirname $f).$(tput sgr0)" 62 | echo "Tock style rules prohibit this use of wildcard imports." 63 | echo 64 | echo "The following wildcard imports were found:" 65 | git grep 'use .*\*;' 66 | let FAIL=FAIL+1 67 | fi 68 | popd > /dev/null 69 | done 70 | 71 | if [[ $FAIL -ne 0 ]]; then 72 | echo 73 | echo "$(tput bold)Formatting errors.$(tput sgr0)" 74 | echo "See above for details" 75 | fi 76 | exit $FAIL 77 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/source/templates/exceptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief This file contains the interface for default exception handlers. 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef EXCEPTIONS_H_INCLUDED 45 | #define EXCEPTIONS_H_INCLUDED 46 | 47 | #include "sam4l.h" 48 | 49 | /* @cond 0 */ 50 | /**INDENT-OFF**/ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | /**INDENT-ON**/ 55 | /* @endcond */ 56 | 57 | /* Function prototype for exception table items (interrupt handler). */ 58 | typedef void (*IntFunc) (void); 59 | 60 | /* Default empty handler */ 61 | void Dummy_Handler(void); 62 | 63 | /* @cond 0 */ 64 | /**INDENT-OFF**/ 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | /**INDENT-ON**/ 69 | /* @endcond */ 70 | 71 | #endif /* EXCEPTIONS_H_INCLUDED */ 72 | -------------------------------------------------------------------------------- /tools/bootloader_attributes/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs::File; 3 | use std::io::Write; 4 | use std::iter; 5 | use std::path::Path; 6 | 7 | // This is the name of the file that will get generated with the static 8 | // attributes in them. 9 | pub static ATTRIBUTES_FILE: &'static str = "attributes.rs"; 10 | 11 | /// Write the "flags" region as an array. 12 | pub fn write_flags(dest: &mut W, version: &str, start_address: u32) { 13 | let _ = write!( 14 | dest, 15 | " 16 | #[link_section=\".flags\"] 17 | #[no_mangle] 18 | pub static FLAGS: [u8; 512] = [ 19 | " 20 | ); 21 | 22 | // Boot in bootloader identifier flag. 23 | for byte in "TOCKBOOTLOADER".bytes().chain(iter::repeat(0)).take(14) { 24 | let _ = write!(dest, "{:#x}, ", byte); 25 | } 26 | 27 | // Write up to 8 bytes for the bootloader version. 28 | for byte in version.bytes().chain(iter::repeat(0)).take(8) { 29 | let _ = write!(dest, "{:#x}, ", byte); 30 | } 31 | 32 | // Fill in reserved bytes 33 | for _ in 0..10 { 34 | let _ = write!(dest, "{:#x}, ", 0); 35 | } 36 | 37 | for byte in start_address.to_le_bytes().iter() { 38 | let _ = write!(dest, "{:#x}, ", byte); 39 | } 40 | 41 | // Fill in the rest of the 0 bytes 42 | for _ in 0..476 { 43 | let _ = write!(dest, "{:#x}, ", 0); 44 | } 45 | 46 | // And finish the array 47 | let _ = write!(dest, " ]; "); 48 | } 49 | 50 | /// Takes an attribute name and value and writes valid Rust to create a 51 | /// bootloader attribute. 52 | pub fn write_attribute(dest: &mut W, name: &str, value: &str) { 53 | let _ = write!( 54 | dest, 55 | " 56 | #[link_section=\".attribute.{}\"] 57 | #[no_mangle] 58 | pub static ATTRIBUTE_{}: [u8; 64] = [ 59 | ", 60 | name, 61 | name.to_ascii_uppercase() 62 | ); 63 | 64 | // Write up to 8 bytes of name ; zero-pad up to 8 bytes 65 | for byte in name.bytes().chain(iter::repeat(0)).take(8) { 66 | let _ = write!(dest, "{:#x}, ", byte); 67 | } 68 | 69 | // attribute length 70 | let _ = write!(dest, "{:#x}, ", value.len()); 71 | 72 | // Write up to 55 bytes of value ; zero-pad up to 55 bytes 73 | for byte in value.bytes().chain(iter::repeat(0)).take(55) { 74 | let _ = write!(dest, "{:#x}, ", byte); 75 | } 76 | 77 | // And finish the array 78 | let _ = write!(dest, " ]; "); 79 | } 80 | 81 | pub fn get_file() -> File { 82 | let out_dir = env::var("OUT_DIR").unwrap(); 83 | let dest_path = Path::new(&out_dir).join(ATTRIBUTES_FILE); 84 | let f = File::create(&dest_path).unwrap(); 85 | f 86 | } 87 | -------------------------------------------------------------------------------- /legacy/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of StormLoader, the Storm Bootloader 3 | * 4 | * StormLoader is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * StormLoader is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with StormLoader. If not, see . 16 | * 17 | * Copyright 2014, Michael Andersen 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "bootloader.h" 27 | #include "ASF/common/services/ioport/sam/ioport_gpio.h" 28 | #include "ASF/common/services/ioport/ioport.h" 29 | 30 | #include "bootloader_board.h" 31 | 32 | extern void jump_into_user_code(void) __attribute__((noreturn)); 33 | 34 | #if TOCK_BOARD_justjump == 1 35 | // justjump is a null bootloader that simply jumps to the start of the 36 | // kernel code. 37 | 38 | int main (void) { 39 | jump_into_user_code(); 40 | } 41 | 42 | #else 43 | // All normal bootloaders use these functions 44 | 45 | void board_init(void) { 46 | // Setup GPIO 47 | ioport_init(); 48 | 49 | // Pin which is pulled low to enter bootloader mode. 50 | ioport_set_pin_dir(BOOTLOADER_SELECT_PIN, IOPORT_DIR_INPUT); 51 | ioport_set_pin_mode(BOOTLOADER_SELECT_PIN, IOPORT_MODE_PULLUP | IOPORT_MODE_GLITCH_FILTER); 52 | 53 | // Setup Clock 54 | bpm_set_clk32_source(BPM, BPM_CLK32_SOURCE_RC32K); 55 | sysclk_init(); 56 | } 57 | 58 | int main (void) { 59 | board_init(); 60 | 61 | // Verify BL policy 62 | uint32_t active = 0; 63 | uint32_t inactive = 0; 64 | uint32_t samples = 10000; 65 | while (samples) { 66 | if (ioport_get_pin_level(BOOTLOADER_SELECT_PIN) == 0) { 67 | active++; 68 | } else { 69 | inactive++; 70 | } 71 | samples--; 72 | } 73 | 74 | if (active > inactive) { 75 | // Enter bootloader mode and wait for commands from tockloader 76 | bl_init(); 77 | while (1) { 78 | bl_loop_poll(); 79 | } 80 | } else { 81 | // Go to main application code 82 | jump_into_user_code(); 83 | } 84 | } 85 | #endif 86 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for CHIPID 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_CHIPID_INSTANCE_ 45 | #define _SAM4L_CHIPID_INSTANCE_ 46 | 47 | /* ========== Register definition for CHIPID peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_CHIPID_CIDR (0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 50 | #define REG_CHIPID_EXID (0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 51 | #else 52 | #define REG_CHIPID_CIDR (*(RoReg *)0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 53 | #define REG_CHIPID_EXID (*(RoReg *)0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | 57 | #endif /* _SAM4L_CHIPID_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /.github/workflows/release_microbit_v2.yml: -------------------------------------------------------------------------------- 1 | name: Micro:bit v2 Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version: 7 | description: 'Release version' 8 | required: true 9 | 10 | jobs: 11 | release: 12 | runs-on: "ubuntu-latest" 13 | 14 | # Steps represent a sequence of tasks that will be executed as part of the job 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions-rs/toolchain@v1 # pulls version from rust-toolchain file 18 | - name: Build bootloader 19 | run: | 20 | cd boards/microbit_v2-bootloader 21 | export BOOTLOADER_VERSION="${{ github.event.inputs.version }}" 22 | export BOOTLOADER_HASH="$(git rev-parse HEAD)" 23 | export BOOTLOADER_KERNEL_HASH="$(cat Cargo.lock | grep https://github.com/tock/tock?branch=rev=405417 | uniq | cut -d '#' -f 2 | cut -d '"' -f 1)" 24 | make 25 | - name: Version 26 | run: | 27 | echo "Version: ${{ github.event.inputs.version }}" > tock-bootloader.microbit_v2.version 28 | echo "Toolchain: $(rustc --version)" >> tock-bootloader.microbit_v2.version 29 | echo "Tock Bootloader Hash: $(git rev-parse HEAD)" >> tock-bootloader.microbit_v2.version 30 | echo Tock Hash: $(cat boards/microbit_v2-bootloader/Cargo.lock | grep https://github.com/tock/tock?branch=rev=405417 | uniq | cut -d '#' -f 2 | cut -d '"' -f 1) >> tock-bootloader.microbit_v2.version 31 | echo "Bootloader SHA256: $(sha256sum target/thumbv7em-none-eabi/release/microbit_v2-bootloader.bin | cut -d ' ' -f 1)" >> tock-bootloader.microbit_v2.version 32 | echo "Build Date: $(date)" >> tock-bootloader.microbit_v2.version 33 | - name: Upload bootloader release 34 | uses: svenstaro/upload-release-action@v2 35 | with: 36 | release_name: Micro:bit v2 ${{ github.event.inputs.version }} 37 | prerelease: true 38 | repo_token: ${{ secrets.GITHUB_TOKEN }} 39 | file: target/thumbv7em-none-eabi/release/microbit_v2-bootloader.bin 40 | asset_name: tock-bootloader.microbit_v2.${{ github.event.inputs.version }}.bin 41 | tag: microbit_v2-${{ github.event.inputs.version }} 42 | overwrite: true 43 | body: "Bootloader for Micro:bit v2 ${{ github.event.inputs.version }}" 44 | - name: Upload bootloader version 45 | uses: svenstaro/upload-release-action@v2 46 | with: 47 | release_name: Micro:bit v2 ${{ github.event.inputs.version }} 48 | prerelease: true 49 | repo_token: ${{ secrets.GITHUB_TOKEN }} 50 | file: tock-bootloader.microbit_v2.version 51 | asset_name: tock-bootloader.microbit_v2.${{ github.event.inputs.version }}.version 52 | tag: microbit_v2-${{ github.event.inputs.version }} 53 | -------------------------------------------------------------------------------- /legacy/src/config/conf_uart_serial.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Serial USART service configuration. 5 | * 6 | * Copyright (c) 2011-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef CONF_USART_SERIAL_H 45 | #define CONF_USART_SERIAL_H 46 | 47 | /* A reference setting for UART */ 48 | /** UART Interface */ 49 | //#define CONF_UART CONSOLE_UART 50 | /** Baudrate setting */ 51 | //#define CONF_UART_BAUDRATE 115200 52 | /** Parity setting */ 53 | //#define CONF_UART_PARITY UART_MR_PAR_NO 54 | 55 | 56 | /* A reference setting for USART */ 57 | /** USART Interface */ 58 | //#define CONF_UART USART1 59 | /** Baudrate setting */ 60 | //#define CONF_UART_BAUDRATE 115200 61 | /** Character length setting */ 62 | //#define CONF_UART_CHAR_LENGTH US_MR_CHRL_8_BIT 63 | /** Parity setting */ 64 | //#define CONF_UART_PARITY US_MR_PAR_NO 65 | /** Stop bits setting */ 66 | //#define CONF_UART_STOP_BITS US_MR_NBSTOP_1_BIT 67 | 68 | #endif/* CONF_USART_SERIAL_H_INCLUDED */ 69 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/source/templates/system_sam4l.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup. 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include "system_sam4l.h" 45 | #include "sam4l.h" 46 | 47 | /** 48 | * Initial system clock frequency. The System RC Oscillator (RCSYS) provides 49 | * the source for the main clock at chip startup. 50 | */ 51 | #define __SYSTEM_CLOCK (115000) 52 | 53 | uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/ 54 | 55 | /** 56 | * Initialize the system 57 | * 58 | * @brief Setup the microcontroller system. 59 | * Initialize the System and update the SystemCoreClock variable. 60 | */ 61 | void SystemInit(void) 62 | { 63 | // Keep the default device state after reset 64 | SystemCoreClock = __SYSTEM_CLOCK; 65 | return; 66 | } 67 | 68 | /** 69 | * Update SystemCoreClock variable 70 | * 71 | * @brief Updates the SystemCoreClock with current core Clock 72 | * retrieved from cpu registers. 73 | */ 74 | void SystemCoreClockUpdate(void) 75 | { 76 | // Not implemented 77 | SystemCoreClock = __SYSTEM_CLOCK; 78 | return; 79 | } 80 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/preprocessor/stringz.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor stringizing utils. 5 | * 6 | * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _STRINGZ_H_ 45 | #define _STRINGZ_H_ 46 | 47 | /** 48 | * \defgroup group_sam_utils_stringz Preprocessor - Stringize 49 | * 50 | * \ingroup group_sam_utils 51 | * 52 | * \{ 53 | */ 54 | 55 | /*! \brief Stringize. 56 | * 57 | * Stringize a preprocessing token, this token being allowed to be \#defined. 58 | * 59 | * May be used only within macros with the token passed as an argument if the token is \#defined. 60 | * 61 | * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) 62 | * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to 63 | * writing "A0". 64 | */ 65 | #define STRINGZ(x) #x 66 | 67 | /*! \brief Absolute stringize. 68 | * 69 | * Stringize a preprocessing token, this token being allowed to be \#defined. 70 | * 71 | * No restriction of use if the token is \#defined. 72 | * 73 | * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is 74 | * equivalent to writing "A0". 75 | */ 76 | #define ASTRINGZ(x) STRINGZ(x) 77 | 78 | /** 79 | * \} 80 | */ 81 | 82 | #endif // _STRINGZ_H_ 83 | -------------------------------------------------------------------------------- /legacy/src/ASF/common/services/clock/sam4l/pll.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip-specific PLL implementation 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #include 44 | #include 45 | 46 | #define SCIF_UNLOCK_PLL_REG(pll_id) \ 47 | do { \ 48 | SCIF->SCIF_UNLOCK = SCIF_UNLOCK_KEY(0xAAu) \ 49 | | SCIF_UNLOCK_ADDR((uint32_t)&SCIF->SCIF_PLL[0].SCIF_PLL \ 50 | + (4 * pll_id) - (uint32_t)SCIF); \ 51 | } while (0) 52 | 53 | void pll_config_write(const struct pll_config *cfg, uint32_t pll_id) 54 | { 55 | irqflags_t flags; 56 | 57 | Assert(pll_id < NR_PLLS); 58 | 59 | flags = cpu_irq_save(); 60 | 61 | SCIF_UNLOCK_PLL_REG(pll_id); 62 | SCIF->SCIF_PLL[pll_id].SCIF_PLL = cfg->ctrl; 63 | cpu_irq_restore(flags); 64 | } 65 | 66 | void pll_enable(const struct pll_config *cfg, uint32_t pll_id) 67 | { 68 | irqflags_t flags; 69 | 70 | Assert(pll_id < NR_PLLS); 71 | 72 | flags = cpu_irq_save(); 73 | SCIF_UNLOCK_PLL_REG(pll_id); 74 | SCIF->SCIF_PLL[pll_id].SCIF_PLL = cfg->ctrl | SCIF_PLL_PLLEN; 75 | cpu_irq_restore(flags); 76 | } 77 | 78 | void pll_disable(uint32_t pll_id) 79 | { 80 | irqflags_t flags; 81 | 82 | Assert(pll_id < NR_PLLS); 83 | 84 | flags = cpu_irq_save(); 85 | SCIF_UNLOCK_PLL_REG(pll_id); 86 | SCIF->SCIF_PLL[pll_id].SCIF_PLL = 0; 87 | cpu_irq_restore(flags); 88 | } 89 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/header_files/io.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Arch file for SAM. 5 | * 6 | * This file defines common SAM series. 7 | * 8 | * Copyright (c) 2011 - 2013 Atmel Corporation. All rights reserved. 9 | * 10 | * \asf_license_start 11 | * 12 | * \page License 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 24 | * 3. The name of Atmel may not be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * 4. This software may only be redistributed and used in connection with an 28 | * Atmel microcontroller product. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 32 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 33 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * \asf_license_stop 43 | * 44 | */ 45 | 46 | #ifndef _SAM_IO_ 47 | #define _SAM_IO_ 48 | 49 | /* SAM3 family */ 50 | 51 | /* SAM3S series */ 52 | #if (SAM3S) 53 | # if (SAM3S8 || SAM3SD8) 54 | # include "sam3s8.h" 55 | # else 56 | # include "sam3s.h" 57 | # endif 58 | #endif 59 | 60 | /* SAM3U series */ 61 | #if (SAM3U) 62 | # include "sam3u.h" 63 | #endif 64 | 65 | /* SAM3N series */ 66 | #if (SAM3N) 67 | # include "sam3n.h" 68 | #endif 69 | 70 | /* SAM3XA series */ 71 | #if (SAM3XA) 72 | # include "sam3xa.h" 73 | #endif 74 | 75 | /* SAM4S series */ 76 | #if (SAM4S) 77 | # include "sam4s.h" 78 | #endif 79 | 80 | /* SAM4L series */ 81 | #if (SAM4L) 82 | # include "sam4l.h" 83 | #endif 84 | 85 | /* SAM4E series */ 86 | #if (SAM4E) 87 | # include "sam4e.h" 88 | #endif 89 | 90 | /* SAM4N series */ 91 | #if (SAM4N) 92 | # include "sam4n.h" 93 | #endif 94 | 95 | /* SAM4C series */ 96 | #if (SAM4C) 97 | # include "sam4c.h" 98 | #endif 99 | 100 | /* SAMG51 series */ 101 | #if (SAMG51) 102 | # include "samg51.h" 103 | #endif 104 | 105 | /* SAMG53 series */ 106 | #if (SAMG53) 107 | # include "samg53.h" 108 | #endif 109 | 110 | #endif /* _SAM_IO_ */ 111 | -------------------------------------------------------------------------------- /legacy/src/asf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Autogenerated API include file for the Atmel Software Framework (ASF) 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef ASF_H 45 | #define ASF_H 46 | 47 | /* 48 | * This file includes all API header files for the selected drivers from ASF. 49 | * Note: There might be duplicate includes required by more than one driver. 50 | * 51 | * The file is automatically generated and will be re-written when 52 | * running the ASF driver selector tool. Any changes will be discarded. 53 | */ 54 | 55 | // From module: CPU Reset Cause 56 | #include 57 | 58 | // From module: Common SAM compiler driver 59 | #include 60 | #include 61 | 62 | // From module: FLASHCALW Controller Software Driver 63 | #include 64 | 65 | // From module: GPIO - General-Purpose Input/Output 66 | #include 67 | 68 | // From module: Generic board support 69 | #include 70 | 71 | // From module: IOPORT - General purpose I/O service 72 | #include 73 | 74 | // From module: Interrupt management - SAM implementation 75 | #include 76 | 77 | // From module: Power Management 78 | #include 79 | 80 | // From module: SAM4L startup code 81 | #include 82 | #include 83 | 84 | // From module: USART - Univ. Syn Async Rec/Trans 85 | #include 86 | 87 | // From module: WDT - Watchdog Timer 88 | #include 89 | 90 | #endif // ASF_H 91 | -------------------------------------------------------------------------------- /legacy/src/ASF/common/utils/interrupt/interrupt_sam_nvic.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Global interrupt management for SAM D20, SAM3 and SAM4 (NVIC based) 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include "interrupt_sam_nvic.h" 45 | 46 | #if !defined(__DOXYGEN__) 47 | /* Deprecated - global flag to determine the global interrupt state. Required by 48 | * QTouch library, however new applications should use cpu_irq_is_enabled() 49 | * which probes the true global interrupt state from the CPU special registers. 50 | */ 51 | volatile bool g_interrupt_enabled = true; 52 | #endif 53 | 54 | void cpu_irq_enter_critical(void) 55 | { 56 | if (cpu_irq_critical_section_counter == 0) { 57 | if (cpu_irq_is_enabled()) { 58 | cpu_irq_disable(); 59 | cpu_irq_prev_interrupt_state = true; 60 | } else { 61 | /* Make sure the to save the prev state as false */ 62 | cpu_irq_prev_interrupt_state = false; 63 | } 64 | 65 | } 66 | 67 | cpu_irq_critical_section_counter++; 68 | } 69 | 70 | void cpu_irq_leave_critical(void) 71 | { 72 | /* Check if the user is trying to leave a critical section when not in a critical section */ 73 | Assert(cpu_irq_critical_section_counter > 0); 74 | 75 | cpu_irq_critical_section_counter--; 76 | 77 | /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag 78 | was enabled when entering critical state */ 79 | if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) { 80 | cpu_irq_enable(); 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_picouart.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PICOUART 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_PICOUART_INSTANCE_ 45 | #define _SAM4L_PICOUART_INSTANCE_ 46 | 47 | /* ========== Register definition for PICOUART peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_PICOUART_CR (0x400F1400U) /**< \brief (PICOUART) Control Register */ 50 | #define REG_PICOUART_CFG (0x400F1404U) /**< \brief (PICOUART) Configuration Register */ 51 | #define REG_PICOUART_SR (0x400F1408U) /**< \brief (PICOUART) Status Register */ 52 | #define REG_PICOUART_RHR (0x400F140CU) /**< \brief (PICOUART) Receive Holding Register */ 53 | #define REG_PICOUART_VERSION (0x400F1420U) /**< \brief (PICOUART) Version Register */ 54 | #else 55 | #define REG_PICOUART_CR (*(WoReg *)0x400F1400U) /**< \brief (PICOUART) Control Register */ 56 | #define REG_PICOUART_CFG (*(RwReg *)0x400F1404U) /**< \brief (PICOUART) Configuration Register */ 57 | #define REG_PICOUART_SR (*(RoReg *)0x400F1408U) /**< \brief (PICOUART) Status Register */ 58 | #define REG_PICOUART_RHR (*(RoReg *)0x400F140CU) /**< \brief (PICOUART) Receive Holding Register */ 59 | #define REG_PICOUART_VERSION (*(RoReg *)0x400F1420U) /**< \brief (PICOUART) Version Register */ 60 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 61 | 62 | 63 | #endif /* _SAM4L_PICOUART_INSTANCE_ */ 64 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/sam4l.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Header file for SAM4L 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef _SAM4L_ 44 | #define _SAM4L_ 45 | 46 | #if defined (__ATSAM4LC2A__) || defined (__SAM4LC2A__) 47 | #include "sam4lc2a.h" 48 | #elif defined (__ATSAM4LC2B__) || defined (__SAM4LC2B__) 49 | #include "sam4lc2b.h" 50 | #elif defined (__ATSAM4LC2C__) || defined (__SAM4LC2C__) 51 | #include "sam4lc2c.h" 52 | #elif defined (__ATSAM4LC4A__) || defined (__SAM4LC4A__) 53 | #include "sam4lc4a.h" 54 | #elif defined (__ATSAM4LC4B__) || defined (__SAM4LC4B__) 55 | #include "sam4lc4b.h" 56 | #elif defined (__ATSAM4LC4C__) || defined (__SAM4LC4C__) 57 | #include "sam4lc4c.h" 58 | #elif defined (__ATSAM4LC8A__) || defined (__SAM4LC8A__) 59 | #include "sam4lc8a.h" 60 | #elif defined (__ATSAM4LC8B__) || defined (__SAM4LC8B__) 61 | #include "sam4lc8b.h" 62 | #elif defined (__ATSAM4LC8C__) || defined (__SAM4LC8C__) 63 | #include "sam4lc8c.h" 64 | #elif defined (__ATSAM4LS2A__) || defined (__SAM4LS2A__) 65 | #include "sam4ls2a.h" 66 | #elif defined (__ATSAM4LS2B__) || defined (__SAM4LS2B__) 67 | #include "sam4ls2b.h" 68 | #elif defined (__ATSAM4LS2C__) || defined (__SAM4LS2C__) 69 | #include "sam4ls2c.h" 70 | #elif defined (__ATSAM4LS4A__) || defined (__SAM4LS4A__) 71 | #include "sam4ls4a.h" 72 | #elif defined (__ATSAM4LS4B__) || defined (__SAM4LS4B__) 73 | #include "sam4ls4b.h" 74 | #elif defined (__ATSAM4LS4C__) || defined (__SAM4LS4C__) 75 | #include "sam4ls4c.h" 76 | #elif defined (__ATSAM4LS8A__) || defined (__SAM4LS8A__) 77 | #include "sam4ls8a.h" 78 | #elif defined (__ATSAM4LS8B__) || defined (__SAM4LS8B__) 79 | #include "sam4ls8b.h" 80 | #elif defined (__ATSAM4LS8C__) || defined (__SAM4LS8C__) 81 | #include "sam4ls8c.h" 82 | #endif 83 | 84 | #endif /* _SAM4L_ */ 85 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_gloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for GLOC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_GLOC_INSTANCE_ 45 | #define _SAM4L_GLOC_INSTANCE_ 46 | 47 | /* ========== Register definition for GLOC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_GLOC_CR0 (0x40060000U) /**< \brief (GLOC) Control Register 0 */ 50 | #define REG_GLOC_TRUTH0 (0x40060004U) /**< \brief (GLOC) Truth Register 0 */ 51 | #define REG_GLOC_CR1 (0x40060008U) /**< \brief (GLOC) Control Register 1 */ 52 | #define REG_GLOC_TRUTH1 (0x4006000CU) /**< \brief (GLOC) Truth Register 1 */ 53 | #define REG_GLOC_PARAMETER (0x40060038U) /**< \brief (GLOC) Parameter Register */ 54 | #define REG_GLOC_VERSION (0x4006003CU) /**< \brief (GLOC) Version Register */ 55 | #else 56 | #define REG_GLOC_CR0 (*(RwReg *)0x40060000U) /**< \brief (GLOC) Control Register 0 */ 57 | #define REG_GLOC_TRUTH0 (*(RwReg *)0x40060004U) /**< \brief (GLOC) Truth Register 0 */ 58 | #define REG_GLOC_CR1 (*(RwReg *)0x40060008U) /**< \brief (GLOC) Control Register 1 */ 59 | #define REG_GLOC_TRUTH1 (*(RwReg *)0x4006000CU) /**< \brief (GLOC) Truth Register 1 */ 60 | #define REG_GLOC_PARAMETER (*(RoReg *)0x40060038U) /**< \brief (GLOC) Parameter Register */ 61 | #define REG_GLOC_VERSION (*(RoReg *)0x4006003CU) /**< \brief (GLOC) Version Register */ 62 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 63 | 64 | /* ========== Instance parameters for GLOC peripheral ========== */ 65 | #define GLOC_GCLK_NUM 5 66 | #define GLOC_LUTS 2 67 | 68 | #endif /* _SAM4L_GLOC_INSTANCE_ */ 69 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_trng.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for TRNG 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_TRNG_INSTANCE_ 45 | #define _SAM4L_TRNG_INSTANCE_ 46 | 47 | /* ========== Register definition for TRNG peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_TRNG_CR (0x40068000U) /**< \brief (TRNG) Control Register */ 50 | #define REG_TRNG_IER (0x40068010U) /**< \brief (TRNG) Interrupt Enable Register */ 51 | #define REG_TRNG_IDR (0x40068014U) /**< \brief (TRNG) Interrupt Disable Register */ 52 | #define REG_TRNG_IMR (0x40068018U) /**< \brief (TRNG) Interrupt Mask Register */ 53 | #define REG_TRNG_ISR (0x4006801CU) /**< \brief (TRNG) Interrupt Status Register */ 54 | #define REG_TRNG_ODATA (0x40068050U) /**< \brief (TRNG) Output Data Register */ 55 | #define REG_TRNG_VERSION (0x400680FCU) /**< \brief (TRNG) Version Register */ 56 | #else 57 | #define REG_TRNG_CR (*(WoReg *)0x40068000U) /**< \brief (TRNG) Control Register */ 58 | #define REG_TRNG_IER (*(WoReg *)0x40068010U) /**< \brief (TRNG) Interrupt Enable Register */ 59 | #define REG_TRNG_IDR (*(WoReg *)0x40068014U) /**< \brief (TRNG) Interrupt Disable Register */ 60 | #define REG_TRNG_IMR (*(RoReg *)0x40068018U) /**< \brief (TRNG) Interrupt Mask Register */ 61 | #define REG_TRNG_ISR (*(RoReg *)0x4006801CU) /**< \brief (TRNG) Interrupt Status Register */ 62 | #define REG_TRNG_ODATA (*(RoReg *)0x40068050U) /**< \brief (TRNG) Output Data Register */ 63 | #define REG_TRNG_VERSION (*(RoReg *)0x400680FCU) /**< \brief (TRNG) Version Register */ 64 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 65 | 66 | 67 | #endif /* _SAM4L_TRNG_INSTANCE_ */ 68 | -------------------------------------------------------------------------------- /.github/workflows/release_clue_nrf52840.yml: -------------------------------------------------------------------------------- 1 | name: CLUE nRF52840 Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version: 7 | description: 'Release version' 8 | required: true 9 | 10 | jobs: 11 | release: 12 | runs-on: "ubuntu-latest" 13 | 14 | # Steps represent a sequence of tasks that will be executed as part of the job 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions-rs/toolchain@v1 # pulls version from rust-toolchain file 18 | - name: Install elf2uf2 19 | run: cargo install uf2conv 20 | - name: Build bootloader 21 | run: | 22 | cd boards/clue_nrf52840-bootloader 23 | export BOOTLOADER_VERSION="${{ github.event.inputs.version }}" 24 | export BOOTLOADER_HASH="$(git rev-parse HEAD)" 25 | export BOOTLOADER_KERNEL_HASH="$(cat Cargo.lock | grep https://github.com/tock/tock?rev=405417 | uniq | cut -d '#' -f 2 | cut -d '"' -f 1)" 26 | make 27 | - name: Build uf2 28 | run: uf2conv target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.bin -f 0xADA52840 --base 0x26000 --output target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.uf2 29 | - name: Version 30 | run: | 31 | echo "Version: ${{ github.event.inputs.version }}" > tock-bootloader.clue_nrf52840.version 32 | echo "Toolchain: $(rustc --version)" >> tock-bootloader.clue_nrf52840.version 33 | echo "Tock Bootloader Hash: $(git rev-parse HEAD)" >> tock-bootloader.clue_nrf52840.version 34 | echo Tock Hash: $(cat boards/clue_nrf52840-bootloader/Cargo.lock | grep https://github.com/tock/tock?rev=405417 | uniq | cut -d '#' -f 2 | cut -d '"' -f 1) >> tock-bootloader.clue_nrf52840.version 35 | echo "Bootloader SHA256: $(sha256sum target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.bin | cut -d ' ' -f 1)" >> tock-bootloader.clue_nrf52840.version 36 | echo "Build Date: $(date)" >> tock-bootloader.clue_nrf52840.version 37 | - name: Upload bootloader release 38 | uses: svenstaro/upload-release-action@v2 39 | with: 40 | release_name: CLUE nRF52840 Express ${{ github.event.inputs.version }} 41 | prerelease: true 42 | repo_token: ${{ secrets.GITHUB_TOKEN }} 43 | file: target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.bin 44 | asset_name: tock-bootloader.clue_nrf52840.${{ github.event.inputs.version }}.bin 45 | tag: clue_nrf52840-${{ github.event.inputs.version }} 46 | overwrite: true 47 | body: "Bootloader for CLUE nRF52840 Express ${{ github.event.inputs.version }}" 48 | - name: Upload bootloader uf2 49 | uses: svenstaro/upload-release-action@v2 50 | with: 51 | release_name: CLUE nRF52840 Express ${{ github.event.inputs.version }} 52 | prerelease: true 53 | repo_token: ${{ secrets.GITHUB_TOKEN }} 54 | file: target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.uf2 55 | asset_name: tock-bootloader.clue_nrf52840.${{ github.event.inputs.version }}.uf2 56 | tag: clue_nrf52840-${{ github.event.inputs.version }} 57 | overwrite: true 58 | body: "Bootloader for CLUE nRF52840 Express ${{ github.event.inputs.version }}" 59 | - name: Upload bootloader version 60 | uses: svenstaro/upload-release-action@v2 61 | with: 62 | release_name: CLUE nRF52840 Express ${{ github.event.inputs.version }} 63 | prerelease: true 64 | repo_token: ${{ secrets.GITHUB_TOKEN }} 65 | file: tock-bootloader.clue_nrf52840.version 66 | asset_name: tock-bootloader.clue_nrf52840.${{ github.event.inputs.version }}.version 67 | tag: clue_nrf52840-${{ github.event.inputs.version }} 68 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/component/component_chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Component description for CHIPID 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_CHIPID_COMPONENT_ 45 | #define _SAM4L_CHIPID_COMPONENT_ 46 | 47 | /* ========================================================================== */ 48 | /** SOFTWARE API DEFINITION FOR CHIPID */ 49 | /* ========================================================================== */ 50 | /** \addtogroup SAM4L_CHIPID Chip ID Registers */ 51 | /*@{*/ 52 | 53 | #define REV_CHIPID 0x100 54 | 55 | /* -------- CHIPID_CIDR : (CHIPID Offset: 0x340) (R/ 32) Chip ID Register -------- */ 56 | #define CHIPID_CIDR_OFFSET 0x340 /**< \brief (CHIPID_CIDR offset) Chip ID Register */ 57 | #define CHIPID_CIDR_RESETVALUE 0xAB0A09E0 /**< \brief (CHIPID_CIDR reset_value) Chip ID Register */ 58 | #define CHIPID_CIDR_MASK 0xFFFFFFFFu /**< \brief (CHIPID_CIDR) MASK Register */ 59 | 60 | /* -------- CHIPID_EXID : (CHIPID Offset: 0x344) (R/ 32) Chip ID Extension Register -------- */ 61 | #define CHIPID_EXID_OFFSET 0x344 /**< \brief (CHIPID_EXID offset) Chip ID Extension Register */ 62 | #define CHIPID_EXID_RESETVALUE 0x0400000F /**< \brief (CHIPID_EXID reset_value) Chip ID Extension Register */ 63 | #define CHIPID_EXID_MASK 0xFFFFFFFFu /**< \brief (CHIPID_EXID) MASK Register */ 64 | 65 | /** \brief CHIPID hardware registers */ 66 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 67 | typedef struct { 68 | RoReg8 Reserved1[0x340]; 69 | RoReg CHIPID_CIDR; /**< \brief (CHIPID Offset: 0x340) Chip ID Register */ 70 | RoReg CHIPID_EXID; /**< \brief (CHIPID Offset: 0x344) Chip ID Extension Register */ 71 | } Chipid; 72 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 73 | 74 | /*@}*/ 75 | 76 | #endif /* _SAM4L_CHIPID_COMPONENT_ */ 77 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/drivers/cpu/sam4l_reset_cause.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip-specific reset cause functions 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef SAM4L_RESET_CAUSE_H 44 | #define SAM4L_RESET_CAUSE_H 45 | 46 | #include "compiler.h" 47 | 48 | /** 49 | * \defgroup group_sam4l_drivers_cpu SAM4L reset cause 50 | * \ingroup reset_cause_group 51 | * 52 | * See \ref reset_cause_quickstart 53 | * 54 | * @{ 55 | */ 56 | 57 | /** 58 | * \brief Chip-specific reset cause type capable of holding all chip reset 59 | * causes. Typically reflects the size of the reset cause register. 60 | */ 61 | typedef uint32_t reset_cause_t; 62 | 63 | //! \internal \name Chip-specific reset causes 64 | //@{ 65 | 66 | //! \internal External reset cause 67 | # define CHIP_RESET_CAUSE_EXTRST PM_RCAUSE_EXT 68 | 69 | //! \internal Brown-out detected on CPU power domain reset cause 70 | # define CHIP_RESET_CAUSE_BOD_CPU PM_RCAUSE_BOD 71 | 72 | //! \internal Brown-out detected on I/O power domain reset cause 73 | # define CHIP_RESET_CAUSE_BOD_IO PM_RCAUSE_BOD33 74 | 75 | //! \internal On-chip debug system reset cause 76 | # define CHIP_RESET_CAUSE_OCD PM_RCAUSE_OCDRST 77 | 78 | //! \internal Power-on-reset reset cause 79 | # define CHIP_RESET_CAUSE_POR PM_RCAUSE_POR 80 | 81 | //! \internal Power-on-reset on I/O power domain reset cause 82 | # define CHIP_RESET_CAUSE_POR_IO PM_RCAUSE_POR33 83 | 84 | //! \internal Watchdog timeout reset cause 85 | # define CHIP_RESET_CAUSE_WDT PM_RCAUSE_WDT 86 | 87 | //@} 88 | 89 | static inline reset_cause_t reset_cause_get_causes(void) 90 | { 91 | return (reset_cause_t)PM->PM_RCAUSE; 92 | } 93 | 94 | static inline void reset_cause_clear_causes(reset_cause_t causes) 95 | { 96 | /** 97 | * \note Reset causes are not clearable on SAM4L. 98 | */ 99 | UNUSED(causes); 100 | } 101 | 102 | static inline void reset_do_soft_reset(void) 103 | { 104 | while (1) { 105 | NVIC_SystemReset(); 106 | } 107 | } 108 | 109 | //! @} 110 | 111 | #endif /* SAM4L_RESET_CAUSE_H */ 112 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_hflashc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for HFLASHC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_HFLASHC_INSTANCE_ 45 | #define _SAM4L_HFLASHC_INSTANCE_ 46 | 47 | /* ========== Register definition for HFLASHC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_HFLASHC_FCR (0x400A0000U) /**< \brief (HFLASHC) Flash Controller Control Register */ 50 | #define REG_HFLASHC_FCMD (0x400A0004U) /**< \brief (HFLASHC) Flash Controller Command Register */ 51 | #define REG_HFLASHC_FSR (0x400A0008U) /**< \brief (HFLASHC) Flash Controller Status Register */ 52 | #define REG_HFLASHC_FPR (0x400A000CU) /**< \brief (HFLASHC) Flash Controller Parameter Register */ 53 | #define REG_HFLASHC_VERSION (0x400A0010U) /**< \brief (HFLASHC) Flash Controller Version Register */ 54 | #define REG_HFLASHC_FGPFRHI (0x400A0014U) /**< \brief (HFLASHC) Flash Controller General Purpose Fuse Register High */ 55 | #define REG_HFLASHC_FGPFRLO (0x400A0018U) /**< \brief (HFLASHC) Flash Controller General Purpose Fuse Register Low */ 56 | #else 57 | #define REG_HFLASHC_FCR (*(RwReg *)0x400A0000U) /**< \brief (HFLASHC) Flash Controller Control Register */ 58 | #define REG_HFLASHC_FCMD (*(RwReg *)0x400A0004U) /**< \brief (HFLASHC) Flash Controller Command Register */ 59 | #define REG_HFLASHC_FSR (*(RwReg *)0x400A0008U) /**< \brief (HFLASHC) Flash Controller Status Register */ 60 | #define REG_HFLASHC_FPR (*(RoReg *)0x400A000CU) /**< \brief (HFLASHC) Flash Controller Parameter Register */ 61 | #define REG_HFLASHC_VERSION (*(RoReg *)0x400A0010U) /**< \brief (HFLASHC) Flash Controller Version Register */ 62 | #define REG_HFLASHC_FGPFRHI (*(RwReg *)0x400A0014U) /**< \brief (HFLASHC) Flash Controller General Purpose Fuse Register High */ 63 | #define REG_HFLASHC_FGPFRLO (*(RwReg *)0x400A0018U) /**< \brief (HFLASHC) Flash Controller General Purpose Fuse Register Low */ 64 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 65 | 66 | 67 | #endif /* _SAM4L_HFLASHC_INSTANCE_ */ 68 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/syscalls/gcc/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Syscalls for SAM (GCC). 5 | * 6 | * Copyright (c) 2011-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | /// @cond 0 50 | /**INDENT-OFF**/ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | /**INDENT-ON**/ 55 | /// @endcond 56 | 57 | #undef errno 58 | extern int errno; 59 | extern int _end; 60 | extern int __ram_end__; 61 | 62 | extern caddr_t _sbrk(int incr); 63 | extern int link(char *old, char *new); 64 | extern int _close(int file); 65 | extern int _fstat(int file, struct stat *st); 66 | extern int _isatty(int file); 67 | extern int _lseek(int file, int ptr, int dir); 68 | extern void _exit(int status); 69 | extern void _kill(int pid, int sig); 70 | extern int _getpid(void); 71 | 72 | extern caddr_t _sbrk(int incr) 73 | { 74 | static unsigned char *heap = NULL; 75 | unsigned char *prev_heap; 76 | int ramend = (int)&__ram_end__; 77 | 78 | if (heap == NULL) { 79 | heap = (unsigned char *)&_end; 80 | } 81 | prev_heap = heap; 82 | 83 | if (((int)prev_heap + incr) > ramend) { 84 | return (caddr_t) -1; 85 | } 86 | 87 | heap += incr; 88 | 89 | return (caddr_t) prev_heap; 90 | } 91 | 92 | extern int link(char *old, char *new) 93 | { 94 | return -1; 95 | } 96 | 97 | extern int _close(int file) 98 | { 99 | return -1; 100 | } 101 | 102 | extern int _fstat(int file, struct stat *st) 103 | { 104 | st->st_mode = S_IFCHR; 105 | 106 | return 0; 107 | } 108 | 109 | extern int _isatty(int file) 110 | { 111 | return 1; 112 | } 113 | 114 | extern int _lseek(int file, int ptr, int dir) 115 | { 116 | return 0; 117 | } 118 | 119 | extern void _exit(int status) 120 | { 121 | printf("Exiting with status %d.\n", status); 122 | 123 | for (;;); 124 | } 125 | 126 | extern void _kill(int pid, int sig) 127 | { 128 | return; 129 | } 130 | 131 | extern int _getpid(void) 132 | { 133 | return -1; 134 | } 135 | 136 | /// @cond 0 137 | /**INDENT-OFF**/ 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | /**INDENT-ON**/ 142 | /// @endcond 143 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_hcache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for HCACHE 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_HCACHE_INSTANCE_ 45 | #define _SAM4L_HCACHE_INSTANCE_ 46 | 47 | /* ========== Register definition for HCACHE peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_HCACHE_CTRL (0x400A0408U) /**< \brief (HCACHE) Control Register */ 50 | #define REG_HCACHE_SR (0x400A040CU) /**< \brief (HCACHE) Status Register */ 51 | #define REG_HCACHE_MAINT0 (0x400A0420U) /**< \brief (HCACHE) Maintenance Register 0 */ 52 | #define REG_HCACHE_MAINT1 (0x400A0424U) /**< \brief (HCACHE) Maintenance Register 1 */ 53 | #define REG_HCACHE_MCFG (0x400A0428U) /**< \brief (HCACHE) Monitor Configuration Register */ 54 | #define REG_HCACHE_MEN (0x400A042CU) /**< \brief (HCACHE) Monitor Enable Register */ 55 | #define REG_HCACHE_MCTRL (0x400A0430U) /**< \brief (HCACHE) Monitor Control Register */ 56 | #define REG_HCACHE_MSR (0x400A0434U) /**< \brief (HCACHE) Monitor Status Register */ 57 | #define REG_HCACHE_VERSION (0x400A04FCU) /**< \brief (HCACHE) Version Register */ 58 | #else 59 | #define REG_HCACHE_CTRL (*(WoReg *)0x400A0408U) /**< \brief (HCACHE) Control Register */ 60 | #define REG_HCACHE_SR (*(RwReg *)0x400A040CU) /**< \brief (HCACHE) Status Register */ 61 | #define REG_HCACHE_MAINT0 (*(WoReg *)0x400A0420U) /**< \brief (HCACHE) Maintenance Register 0 */ 62 | #define REG_HCACHE_MAINT1 (*(WoReg *)0x400A0424U) /**< \brief (HCACHE) Maintenance Register 1 */ 63 | #define REG_HCACHE_MCFG (*(RwReg *)0x400A0428U) /**< \brief (HCACHE) Monitor Configuration Register */ 64 | #define REG_HCACHE_MEN (*(RwReg *)0x400A042CU) /**< \brief (HCACHE) Monitor Enable Register */ 65 | #define REG_HCACHE_MCTRL (*(WoReg *)0x400A0430U) /**< \brief (HCACHE) Monitor Control Register */ 66 | #define REG_HCACHE_MSR (*(RoReg *)0x400A0434U) /**< \brief (HCACHE) Monitor Status Register */ 67 | #define REG_HCACHE_VERSION (*(RoReg *)0x400A04FCU) /**< \brief (HCACHE) Version Register */ 68 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 69 | 70 | 71 | #endif /* _SAM4L_HCACHE_INSTANCE_ */ 72 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for WDT 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_WDT_INSTANCE_ 45 | #define _SAM4L_WDT_INSTANCE_ 46 | 47 | /* ========== Register definition for WDT peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_WDT_CTRL (0x400F0C00U) /**< \brief (WDT) Control Register */ 50 | #define REG_WDT_CLR (0x400F0C04U) /**< \brief (WDT) Clear Register */ 51 | #define REG_WDT_SR (0x400F0C08U) /**< \brief (WDT) Status Register */ 52 | #define REG_WDT_IER (0x400F0C0CU) /**< \brief (WDT) Interrupt Enable Register */ 53 | #define REG_WDT_IDR (0x400F0C10U) /**< \brief (WDT) Interrupt Disable Register */ 54 | #define REG_WDT_IMR (0x400F0C14U) /**< \brief (WDT) Interrupt Mask Register */ 55 | #define REG_WDT_ISR (0x400F0C18U) /**< \brief (WDT) Interrupt Status Register */ 56 | #define REG_WDT_ICR (0x400F0C1CU) /**< \brief (WDT) Interrupt Clear Register */ 57 | #define REG_WDT_VERSION (0x400F0FFCU) /**< \brief (WDT) Version Register */ 58 | #else 59 | #define REG_WDT_CTRL (*(RwReg *)0x400F0C00U) /**< \brief (WDT) Control Register */ 60 | #define REG_WDT_CLR (*(WoReg *)0x400F0C04U) /**< \brief (WDT) Clear Register */ 61 | #define REG_WDT_SR (*(RoReg *)0x400F0C08U) /**< \brief (WDT) Status Register */ 62 | #define REG_WDT_IER (*(WoReg *)0x400F0C0CU) /**< \brief (WDT) Interrupt Enable Register */ 63 | #define REG_WDT_IDR (*(WoReg *)0x400F0C10U) /**< \brief (WDT) Interrupt Disable Register */ 64 | #define REG_WDT_IMR (*(RoReg *)0x400F0C14U) /**< \brief (WDT) Interrupt Mask Register */ 65 | #define REG_WDT_ISR (*(RoReg *)0x400F0C18U) /**< \brief (WDT) Interrupt Status Register */ 66 | #define REG_WDT_ICR (*(WoReg *)0x400F0C1CU) /**< \brief (WDT) Interrupt Clear Register */ 67 | #define REG_WDT_VERSION (*(RoReg *)0x400F0FFCU) /**< \brief (WDT) Version Register */ 68 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 69 | 70 | /* ========== Instance parameters for WDT peripheral ========== */ 71 | #define WDT_WDT_KEY_CONST 85 72 | 73 | #endif /* _SAM4L_WDT_INSTANCE_ */ 74 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_parc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PARC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_PARC_INSTANCE_ 45 | #define _SAM4L_PARC_INSTANCE_ 46 | 47 | /* ========== Register definition for PARC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_PARC_CFG (0x4006C000U) /**< \brief (PARC) Configuration Register */ 50 | #define REG_PARC_CR (0x4006C004U) /**< \brief (PARC) Control Register */ 51 | #define REG_PARC_IER (0x4006C008U) /**< \brief (PARC) Interrupt Enable Register */ 52 | #define REG_PARC_IDR (0x4006C00CU) /**< \brief (PARC) Interrupt Disable Register */ 53 | #define REG_PARC_IMR (0x4006C010U) /**< \brief (PARC) Interrupt Mask Register */ 54 | #define REG_PARC_SR (0x4006C014U) /**< \brief (PARC) Status Register */ 55 | #define REG_PARC_ICR (0x4006C018U) /**< \brief (PARC) Interrupt Status Clear Register */ 56 | #define REG_PARC_RHR (0x4006C01CU) /**< \brief (PARC) Receive Holding Register */ 57 | #define REG_PARC_VERSION (0x4006C020U) /**< \brief (PARC) Version Register */ 58 | #else 59 | #define REG_PARC_CFG (*(RwReg *)0x4006C000U) /**< \brief (PARC) Configuration Register */ 60 | #define REG_PARC_CR (*(RwReg *)0x4006C004U) /**< \brief (PARC) Control Register */ 61 | #define REG_PARC_IER (*(WoReg *)0x4006C008U) /**< \brief (PARC) Interrupt Enable Register */ 62 | #define REG_PARC_IDR (*(WoReg *)0x4006C00CU) /**< \brief (PARC) Interrupt Disable Register */ 63 | #define REG_PARC_IMR (*(RoReg *)0x4006C010U) /**< \brief (PARC) Interrupt Mask Register */ 64 | #define REG_PARC_SR (*(RoReg *)0x4006C014U) /**< \brief (PARC) Status Register */ 65 | #define REG_PARC_ICR (*(WoReg *)0x4006C018U) /**< \brief (PARC) Interrupt Status Clear Register */ 66 | #define REG_PARC_RHR (*(RoReg *)0x4006C01CU) /**< \brief (PARC) Receive Holding Register */ 67 | #define REG_PARC_VERSION (*(RoReg *)0x4006C020U) /**< \brief (PARC) Version Register */ 68 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 69 | 70 | /* ========== Instance parameters for PARC peripheral ========== */ 71 | #define PARC_PDCA_ID_RX 16 72 | 73 | #endif /* _SAM4L_PARC_INSTANCE_ */ 74 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_smap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for SMAP 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_SMAP_INSTANCE_ 45 | #define _SAM4L_SMAP_INSTANCE_ 46 | 47 | /* ========== Register definition for SMAP peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_SMAP_CR (0x400A3000U) /**< \brief (SMAP) Control Register */ 50 | #define REG_SMAP_SR (0x400A3004U) /**< \brief (SMAP) Status Register */ 51 | #define REG_SMAP_SCR (0x400A3008U) /**< \brief (SMAP) Status Clear Register */ 52 | #define REG_SMAP_ADDR (0x400A300CU) /**< \brief (SMAP) Address Register */ 53 | #define REG_SMAP_LENGTH (0x400A3010U) /**< \brief (SMAP) Length Register */ 54 | #define REG_SMAP_DATA (0x400A3014U) /**< \brief (SMAP) Data Register */ 55 | #define REG_SMAP_VERSION (0x400A3028U) /**< \brief (SMAP) VERSION register */ 56 | #define REG_SMAP_CIDR (0x400A30F0U) /**< \brief (SMAP) Chip ID Register */ 57 | #define REG_SMAP_EXID (0x400A30F4U) /**< \brief (SMAP) Chip ID Extension Register */ 58 | #define REG_SMAP_IDR (0x400A30FCU) /**< \brief (SMAP) AP Identification register */ 59 | #else 60 | #define REG_SMAP_CR (*(WoReg *)0x400A3000U) /**< \brief (SMAP) Control Register */ 61 | #define REG_SMAP_SR (*(RoReg *)0x400A3004U) /**< \brief (SMAP) Status Register */ 62 | #define REG_SMAP_SCR (*(WoReg *)0x400A3008U) /**< \brief (SMAP) Status Clear Register */ 63 | #define REG_SMAP_ADDR (*(RwReg *)0x400A300CU) /**< \brief (SMAP) Address Register */ 64 | #define REG_SMAP_LENGTH (*(RwReg *)0x400A3010U) /**< \brief (SMAP) Length Register */ 65 | #define REG_SMAP_DATA (*(RwReg *)0x400A3014U) /**< \brief (SMAP) Data Register */ 66 | #define REG_SMAP_VERSION (*(RoReg *)0x400A3028U) /**< \brief (SMAP) VERSION register */ 67 | #define REG_SMAP_CIDR (*(RoReg *)0x400A30F0U) /**< \brief (SMAP) Chip ID Register */ 68 | #define REG_SMAP_EXID (*(RoReg *)0x400A30F4U) /**< \brief (SMAP) Chip ID Extension Register */ 69 | #define REG_SMAP_IDR (*(RoReg *)0x400A30FCU) /**< \brief (SMAP) AP Identification register */ 70 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 71 | 72 | 73 | #endif /* _SAM4L_SMAP_INSTANCE_ */ 74 | -------------------------------------------------------------------------------- /legacy/src/bootloader.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of StormLoader, the Storm Bootloader 3 | * 4 | * StormLoader is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * StormLoader is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with StormLoader. If not, see . 16 | * 17 | * Copyright 2014, Michael Andersen 18 | * 19 | * This file is largely copied from the Atmel supplied linker scripts 20 | */ 21 | 22 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 23 | OUTPUT_ARCH(arm) 24 | SEARCH_DIR(.) 25 | 26 | /* Memory Spaces Definitions, 64K flash, 64K ram */ 27 | MEMORY 28 | { 29 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 30 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 31 | } 32 | 33 | __stack_size__ = DEFINED(__stack_size__) ? __stack_size__ : 0x1000; 34 | __ram_end__ = ORIGIN(ram) + LENGTH(ram) - 4; 35 | 36 | /* Section Definitions */ 37 | SECTIONS 38 | { 39 | .text : 40 | { 41 | . = ALIGN(4); 42 | _sfixed = .; 43 | KEEP(*(.vectors .vectors.*)) 44 | 45 | /* Reserve room for flags and attributes at address 0x400 */ 46 | . = ALIGN(1024); 47 | KEEP(*(.attributes .attributes.*)) 48 | 49 | *(.text .text.* .gnu.linkonce.t.*) 50 | *(.glue_7t) *(.glue_7) 51 | *(.rodata .rodata* .gnu.linkonce.r.*) 52 | *(.ARM.extab* .gnu.linkonce.armextab.*) 53 | 54 | . = ALIGN(4); 55 | KEEP(*(.init)) 56 | . = ALIGN(4); 57 | __preinit_array_start = .; 58 | KEEP (*(.preinit_array)) 59 | __preinit_array_end = .; 60 | 61 | . = ALIGN(4); 62 | __init_array_start = .; 63 | KEEP (*(SORT(.init_array.*))) 64 | KEEP (*(.init_array)) 65 | __init_array_end = .; 66 | 67 | . = ALIGN(0x4); 68 | KEEP (*crtbegin.o(.ctors)) 69 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 70 | KEEP (*(SORT(.ctors.*))) 71 | KEEP (*crtend.o(.ctors)) 72 | 73 | . = ALIGN(4); 74 | KEEP(*(.fini)) 75 | 76 | . = ALIGN(4); 77 | __fini_array_start = .; 78 | KEEP (*(.fini_array)) 79 | KEEP (*(SORT(.fini_array.*))) 80 | __fini_array_end = .; 81 | 82 | KEEP (*crtbegin.o(.dtors)) 83 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 84 | KEEP (*(SORT(.dtors.*))) 85 | KEEP (*crtend.o(.dtors)) 86 | 87 | . = ALIGN(4); 88 | _efixed = .; /* End of text section */ 89 | } > rom 90 | 91 | /* .ARM.exidx is sorted, so has to go in its own output section. */ 92 | PROVIDE_HIDDEN (__exidx_start = .); 93 | .ARM.exidx : 94 | { 95 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 96 | } > rom 97 | PROVIDE_HIDDEN (__exidx_end = .); 98 | 99 | . = ALIGN(4); 100 | _etext = .; 101 | 102 | .relocate : AT (_etext) 103 | { 104 | . = ALIGN(4); 105 | _srelocate = .; 106 | *(.ramfunc .ramfunc.*); 107 | *(.data .data.*); 108 | . = ALIGN(4); 109 | _erelocate = .; 110 | } > ram 111 | 112 | /* .bss section which is used for uninitialized data */ 113 | .bss (NOLOAD) : 114 | { 115 | . = ALIGN(4); 116 | _sbss = . ; 117 | _szero = .; 118 | *(.bss .bss.*) 119 | *(COMMON) 120 | . = ALIGN(4); 121 | _ebss = . ; 122 | _ezero = .; 123 | } > ram 124 | 125 | /* stack section */ 126 | .stack (NOLOAD): 127 | { 128 | . = ALIGN(8); 129 | _sstack = .; 130 | . = . + __stack_size__; 131 | . = ALIGN(8); 132 | _estack = .; 133 | } > ram 134 | 135 | . = ALIGN(4); 136 | _end = . ; 137 | } 138 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/preprocessor/tpaste.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor token pasting utils. 5 | * 6 | * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _TPASTE_H_ 45 | #define _TPASTE_H_ 46 | 47 | /** 48 | * \defgroup group_sam_utils_tpaste Preprocessor - Token Paste 49 | * 50 | * \ingroup group_sam_utils 51 | * 52 | * \{ 53 | */ 54 | 55 | /*! \name Token Paste 56 | * 57 | * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. 58 | * 59 | * May be used only within macros with the tokens passed as arguments if the tokens are \#defined. 60 | * 61 | * For example, writing TPASTE2(U, WIDTH) within a macro \#defined by 62 | * UTYPE(WIDTH) and invoked as UTYPE(UL_WIDTH) with UL_WIDTH \#defined as 32 is 63 | * equivalent to writing U32. 64 | */ 65 | //! @{ 66 | #define TPASTE2( a, b) a##b 67 | #define TPASTE3( a, b, c) a##b##c 68 | #define TPASTE4( a, b, c, d) a##b##c##d 69 | #define TPASTE5( a, b, c, d, e) a##b##c##d##e 70 | #define TPASTE6( a, b, c, d, e, f) a##b##c##d##e##f 71 | #define TPASTE7( a, b, c, d, e, f, g) a##b##c##d##e##f##g 72 | #define TPASTE8( a, b, c, d, e, f, g, h) a##b##c##d##e##f##g##h 73 | #define TPASTE9( a, b, c, d, e, f, g, h, i) a##b##c##d##e##f##g##h##i 74 | #define TPASTE10(a, b, c, d, e, f, g, h, i, j) a##b##c##d##e##f##g##h##i##j 75 | //! @} 76 | 77 | /*! \name Absolute Token Paste 78 | * 79 | * Paste N preprocessing tokens together, these tokens being allowed to be \#defined. 80 | * 81 | * No restriction of use if the tokens are \#defined. 82 | * 83 | * For example, writing ATPASTE2(U, UL_WIDTH) anywhere with UL_WIDTH \#defined 84 | * as 32 is equivalent to writing U32. 85 | */ 86 | //! @{ 87 | #define ATPASTE2( a, b) TPASTE2( a, b) 88 | #define ATPASTE3( a, b, c) TPASTE3( a, b, c) 89 | #define ATPASTE4( a, b, c, d) TPASTE4( a, b, c, d) 90 | #define ATPASTE5( a, b, c, d, e) TPASTE5( a, b, c, d, e) 91 | #define ATPASTE6( a, b, c, d, e, f) TPASTE6( a, b, c, d, e, f) 92 | #define ATPASTE7( a, b, c, d, e, f, g) TPASTE7( a, b, c, d, e, f, g) 93 | #define ATPASTE8( a, b, c, d, e, f, g, h) TPASTE8( a, b, c, d, e, f, g, h) 94 | #define ATPASTE9( a, b, c, d, e, f, g, h, i) TPASTE9( a, b, c, d, e, f, g, h, i) 95 | #define ATPASTE10(a, b, c, d, e, f, g, h, i, j) TPASTE10(a, b, c, d, e, f, g, h, i, j) 96 | //! @} 97 | 98 | /** 99 | * \} 100 | */ 101 | 102 | #endif // _TPASTE_H_ 103 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_dacc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for DACC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_DACC_INSTANCE_ 45 | #define _SAM4L_DACC_INSTANCE_ 46 | 47 | /* ========== Register definition for DACC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_DACC_CR (0x4003C000U) /**< \brief (DACC) Control Register */ 50 | #define REG_DACC_MR (0x4003C004U) /**< \brief (DACC) Mode Register */ 51 | #define REG_DACC_CDR (0x4003C008U) /**< \brief (DACC) Conversion Data Register */ 52 | #define REG_DACC_IER (0x4003C00CU) /**< \brief (DACC) Interrupt Enable Register */ 53 | #define REG_DACC_IDR (0x4003C010U) /**< \brief (DACC) Interrupt Disable Register */ 54 | #define REG_DACC_IMR (0x4003C014U) /**< \brief (DACC) Interrupt Mask Register */ 55 | #define REG_DACC_ISR (0x4003C018U) /**< \brief (DACC) Interrupt Status Register */ 56 | #define REG_DACC_WPMR (0x4003C0E4U) /**< \brief (DACC) Write Protect Mode Register */ 57 | #define REG_DACC_WPSR (0x4003C0E8U) /**< \brief (DACC) Write Protect Status Register */ 58 | #define REG_DACC_VERSION (0x4003C0FCU) /**< \brief (DACC) Version Register */ 59 | #else 60 | #define REG_DACC_CR (*(WoReg *)0x4003C000U) /**< \brief (DACC) Control Register */ 61 | #define REG_DACC_MR (*(RwReg *)0x4003C004U) /**< \brief (DACC) Mode Register */ 62 | #define REG_DACC_CDR (*(WoReg *)0x4003C008U) /**< \brief (DACC) Conversion Data Register */ 63 | #define REG_DACC_IER (*(WoReg *)0x4003C00CU) /**< \brief (DACC) Interrupt Enable Register */ 64 | #define REG_DACC_IDR (*(WoReg *)0x4003C010U) /**< \brief (DACC) Interrupt Disable Register */ 65 | #define REG_DACC_IMR (*(RoReg *)0x4003C014U) /**< \brief (DACC) Interrupt Mask Register */ 66 | #define REG_DACC_ISR (*(RoReg *)0x4003C018U) /**< \brief (DACC) Interrupt Status Register */ 67 | #define REG_DACC_WPMR (*(RwReg *)0x4003C0E4U) /**< \brief (DACC) Write Protect Mode Register */ 68 | #define REG_DACC_WPSR (*(RoReg *)0x4003C0E8U) /**< \brief (DACC) Write Protect Status Register */ 69 | #define REG_DACC_VERSION (*(RoReg *)0x4003C0FCU) /**< \brief (DACC) Version Register */ 70 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 71 | 72 | /* ========== Instance parameters for DACC peripheral ========== */ 73 | #define DACC_DACC_EXT_TRIG_MSB 0 74 | #define DACC_DAC_RES_MSB 9 75 | #define DACC_PDCA_ID_TX 35 76 | 77 | #endif /* _SAM4L_DACC_INSTANCE_ */ 78 | -------------------------------------------------------------------------------- /legacy/src/ASF/common/utils/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Global interrupt management for 8- and 32-bit AVR 5 | * 6 | * Copyright (c) 2010-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef UTILS_INTERRUPT_H 44 | #define UTILS_INTERRUPT_H 45 | 46 | #include 47 | 48 | #if XMEGA || MEGA || TINY 49 | # include "interrupt/interrupt_avr8.h" 50 | #elif UC3 51 | # include "interrupt/interrupt_avr32.h" 52 | #elif SAM3S || SAM3N || SAM3XA || SAM3U || SAM4S || SAM4L || SAM4E || SAMD20 || SAMG || SAM 53 | # include "interrupt/interrupt_sam_nvic.h" 54 | #else 55 | # error Unsupported device. 56 | #endif 57 | 58 | /** 59 | * \defgroup interrupt_group Global interrupt management 60 | * 61 | * This is a driver for global enabling and disabling of interrupts. 62 | * 63 | * @{ 64 | */ 65 | 66 | #if defined(__DOXYGEN__) 67 | /** 68 | * \def CONFIG_INTERRUPT_FORCE_INTC 69 | * \brief Force usage of the ASF INTC driver 70 | * 71 | * Predefine this symbol when preprocessing to force the use of the ASF INTC driver. 72 | * This is useful to ensure compatibility across compilers and shall be used only when required 73 | * by the application needs. 74 | */ 75 | # define CONFIG_INTERRUPT_FORCE_INTC 76 | #endif 77 | 78 | //! \name Global interrupt flags 79 | //@{ 80 | /** 81 | * \typedef irqflags_t 82 | * \brief Type used for holding state of interrupt flag 83 | */ 84 | 85 | /** 86 | * \def cpu_irq_enable 87 | * \brief Enable interrupts globally 88 | */ 89 | 90 | /** 91 | * \def cpu_irq_disable 92 | * \brief Disable interrupts globally 93 | */ 94 | 95 | /** 96 | * \fn irqflags_t cpu_irq_save(void) 97 | * \brief Get and clear the global interrupt flags 98 | * 99 | * Use in conjunction with \ref cpu_irq_restore. 100 | * 101 | * \return Current state of interrupt flags. 102 | * 103 | * \note This function leaves interrupts disabled. 104 | */ 105 | 106 | /** 107 | * \fn void cpu_irq_restore(irqflags_t flags) 108 | * \brief Restore global interrupt flags 109 | * 110 | * Use in conjunction with \ref cpu_irq_save. 111 | * 112 | * \param flags State to set interrupt flag to. 113 | */ 114 | 115 | /** 116 | * \fn bool cpu_irq_is_enabled_flags(irqflags_t flags) 117 | * \brief Check if interrupts are globally enabled in supplied flags 118 | * 119 | * \param flags Currents state of interrupt flags. 120 | * 121 | * \return True if interrupts are enabled. 122 | */ 123 | 124 | /** 125 | * \def cpu_irq_is_enabled 126 | * \brief Check if interrupts are globally enabled 127 | * 128 | * \return True if interrupts are enabled. 129 | */ 130 | //@} 131 | 132 | //! @} 133 | 134 | /** 135 | * \ingroup interrupt_group 136 | * \defgroup interrupt_deprecated_group Deprecated interrupt definitions 137 | */ 138 | 139 | #endif /* UTILS_INTERRUPT_H */ 140 | -------------------------------------------------------------------------------- /tools/bootloader_attributes/README.md: -------------------------------------------------------------------------------- 1 | Bootloader Attributes 2 | ====================== 3 | 4 | This package helps the Tock build system generate static attributes that are 5 | inserted into the bootloader binary at build time. These attributes are encoded 6 | as static arrays and the linker inserts them into the correct spot in the 7 | binary. 8 | 9 | The resulting file that gets included into the board file at compile time looks 10 | like: 11 | 12 | ```rust 13 | #[link_section=".flags"] 14 | #[no_mangle] 15 | pub static FLAGS: [u8; 512] = [ 16 | 0x54, 0x4f, 0x43, 0x4b, 0x42, 0x4f, 0x4f, 0x54, 0x4c, 0x4f, 0x41, 0x44, 17 | 0x45, 0x52, 0x30, 0x2e, 0x39, 0x2e, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 18 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 19 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 20 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 21 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 22 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 23 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 24 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 25 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 26 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 27 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 28 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 29 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 30 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 31 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 32 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 33 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 34 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 35 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 36 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 37 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 38 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 39 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 40 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 41 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 42 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 43 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 44 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 45 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 46 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 47 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 48 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 49 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 50 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ]; 51 | #[link_section=".attribute.board"] 52 | #[no_mangle] 53 | pub static ATTRIBUTE_BOARD: [u8; 64] = [ 54 | 0x62, 0x6f, 0x61, 0x72, 0x64, 0x0, 0x0, 0x0, 0x4, 0x68, 0x61, 0x69, 0x6c, 55 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 56 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 57 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 58 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ]; 59 | #[link_section=".attribute.arch"] 60 | #[no_mangle] 61 | pub static ATTRIBUTE_ARCH: [u8; 64] = [ 62 | 0x61, 0x72, 0x63, 0x68, 0x0, 0x0, 0x0, 0x0, 0x9, 0x63, 0x6f, 0x72, 0x74, 63 | 0x65, 0x78, 0x2d, 0x6d, 0x34, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 65 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 66 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ]; 67 | #[link_section=".attribute.jldevice"] 68 | #[no_mangle] 69 | pub static ATTRIBUTE_JLDEVICE: [u8; 64] = [ 70 | 0x6a, 0x6c, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0xa, 0x41, 0x54, 0x53, 0x41, 71 | 0x4d, 0x34, 0x4c, 0x43, 0x38, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 72 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 73 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 74 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ]; 75 | ``` 76 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/status_codes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Status code definitions. 5 | * 6 | * This file defines various status codes returned by functions, 7 | * indicating success or failure as well as what kind of failure. 8 | * 9 | * Copyright (c) 2011-2013 Atmel Corporation. All rights reserved. 10 | * 11 | * \asf_license_start 12 | * 13 | * \page License 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 25 | * 3. The name of Atmel may not be used to endorse or promote products derived 26 | * from this software without specific prior written permission. 27 | * 28 | * 4. This software may only be redistributed and used in connection with an 29 | * Atmel microcontroller product. 30 | * 31 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 32 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 34 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 35 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 40 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 | * POSSIBILITY OF SUCH DAMAGE. 42 | * 43 | * \asf_license_stop 44 | * 45 | */ 46 | 47 | #ifndef STATUS_CODES_H_INCLUDED 48 | #define STATUS_CODES_H_INCLUDED 49 | 50 | /* Note: this is a local workaround to avoid a pre-processor clash due to the 51 | * lwIP macro ERR_TIMEOUT. */ 52 | #if defined(__LWIP_ERR_H__) && defined(ERR_TIMEOUT) 53 | #if (ERR_TIMEOUT != -3) 54 | 55 | /* Internal check to make sure that the later restore of lwIP's ERR_TIMEOUT 56 | * macro is set to the correct value. Note that it is highly improbable that 57 | * this value ever changes in lwIP. */ 58 | #error ASF developers: check lwip err.h new value for ERR_TIMEOUT 59 | #endif 60 | #undef ERR_TIMEOUT 61 | #endif 62 | 63 | /** 64 | * Status code that may be returned by shell commands and protocol 65 | * implementations. 66 | * 67 | * \note Any change to these status codes and the corresponding 68 | * message strings is strictly forbidden. New codes can be added, 69 | * however, but make sure that any message string tables are updated 70 | * at the same time. 71 | */ 72 | enum status_code { 73 | STATUS_OK = 0, //!< Success 74 | STATUS_ERR_BUSY = 0x19, 75 | STATUS_ERR_DENIED = 0x1C, 76 | STATUS_ERR_TIMEOUT = 0x12, 77 | ERR_IO_ERROR = -1, //!< I/O error 78 | ERR_FLUSHED = -2, //!< Request flushed from queue 79 | ERR_TIMEOUT = -3, //!< Operation timed out 80 | ERR_BAD_DATA = -4, //!< Data integrity check failed 81 | ERR_PROTOCOL = -5, //!< Protocol error 82 | ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device 83 | ERR_NO_MEMORY = -7, //!< Insufficient memory 84 | ERR_INVALID_ARG = -8, //!< Invalid argument 85 | ERR_BAD_ADDRESS = -9, //!< Bad address 86 | ERR_BUSY = -10, //!< Resource is busy 87 | ERR_BAD_FORMAT = -11, //!< Data format not recognized 88 | ERR_NO_TIMER = -12, //!< No timer available 89 | ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running 90 | ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running 91 | ERR_ABORTED = -15, //!< Operation aborted by user 92 | /** 93 | * \brief Operation in progress 94 | * 95 | * This status code is for driver-internal use when an operation 96 | * is currently being performed. 97 | * 98 | * \note Drivers should never return this status code to any 99 | * callers. It is strictly for internal use. 100 | */ 101 | OPERATION_IN_PROGRESS = -128, 102 | }; 103 | 104 | typedef enum status_code status_code_t; 105 | 106 | #if defined(__LWIP_ERR_H__) 107 | #define ERR_TIMEOUT -3 108 | #endif 109 | 110 | #endif /* STATUS_CODES_H_INCLUDED */ 111 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_abdacb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for ABDACB 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_ABDACB_INSTANCE_ 45 | #define _SAM4L_ABDACB_INSTANCE_ 46 | 47 | /* ========== Register definition for ABDACB peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_ABDACB_CR (0x40064000U) /**< \brief (ABDACB) Control Register */ 50 | #define REG_ABDACB_SDR0 (0x40064004U) /**< \brief (ABDACB) Sample Data Register 0 */ 51 | #define REG_ABDACB_SDR1 (0x40064008U) /**< \brief (ABDACB) Sample Data Register 1 */ 52 | #define REG_ABDACB_VCR0 (0x4006400CU) /**< \brief (ABDACB) Volume Control Register 0 */ 53 | #define REG_ABDACB_VCR1 (0x40064010U) /**< \brief (ABDACB) Volume Control Register 1 */ 54 | #define REG_ABDACB_IER (0x40064014U) /**< \brief (ABDACB) Interrupt Enable Register */ 55 | #define REG_ABDACB_IDR (0x40064018U) /**< \brief (ABDACB) Interupt Disable Register */ 56 | #define REG_ABDACB_IMR (0x4006401CU) /**< \brief (ABDACB) Interrupt Mask Register */ 57 | #define REG_ABDACB_SR (0x40064020U) /**< \brief (ABDACB) Status Register */ 58 | #define REG_ABDACB_SCR (0x40064024U) /**< \brief (ABDACB) Status Clear Register */ 59 | #define REG_ABDACB_PARAMETER (0x40064028U) /**< \brief (ABDACB) Parameter Register */ 60 | #define REG_ABDACB_VERSION (0x4006402CU) /**< \brief (ABDACB) Version Register */ 61 | #else 62 | #define REG_ABDACB_CR (*(RwReg *)0x40064000U) /**< \brief (ABDACB) Control Register */ 63 | #define REG_ABDACB_SDR0 (*(RwReg *)0x40064004U) /**< \brief (ABDACB) Sample Data Register 0 */ 64 | #define REG_ABDACB_SDR1 (*(RwReg *)0x40064008U) /**< \brief (ABDACB) Sample Data Register 1 */ 65 | #define REG_ABDACB_VCR0 (*(RwReg *)0x4006400CU) /**< \brief (ABDACB) Volume Control Register 0 */ 66 | #define REG_ABDACB_VCR1 (*(RwReg *)0x40064010U) /**< \brief (ABDACB) Volume Control Register 1 */ 67 | #define REG_ABDACB_IER (*(WoReg *)0x40064014U) /**< \brief (ABDACB) Interrupt Enable Register */ 68 | #define REG_ABDACB_IDR (*(WoReg *)0x40064018U) /**< \brief (ABDACB) Interupt Disable Register */ 69 | #define REG_ABDACB_IMR (*(RoReg *)0x4006401CU) /**< \brief (ABDACB) Interrupt Mask Register */ 70 | #define REG_ABDACB_SR (*(RoReg *)0x40064020U) /**< \brief (ABDACB) Status Register */ 71 | #define REG_ABDACB_SCR (*(WoReg *)0x40064024U) /**< \brief (ABDACB) Status Clear Register */ 72 | #define REG_ABDACB_PARAMETER (*(RoReg *)0x40064028U) /**< \brief (ABDACB) Parameter Register */ 73 | #define REG_ABDACB_VERSION (*(RoReg *)0x4006402CU) /**< \brief (ABDACB) Version Register */ 74 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 75 | 76 | /* ========== Instance parameters for ABDACB peripheral ========== */ 77 | #define ABDACB_GCLK_NUM 6 78 | #define ABDACB_PDCA_ID_TX_CH0 31 79 | #define ABDACB_PDCA_ID_TX_CH1 32 80 | 81 | #endif /* _SAM4L_ABDACB_INSTANCE_ */ 82 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_iisc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for IISC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_IISC_INSTANCE_ 45 | #define _SAM4L_IISC_INSTANCE_ 46 | 47 | /* ========== Register definition for IISC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_IISC_CR (0x40004000U) /**< \brief (IISC) Control Register */ 50 | #define REG_IISC_MR (0x40004004U) /**< \brief (IISC) Mode Register */ 51 | #define REG_IISC_SR (0x40004008U) /**< \brief (IISC) Status Register */ 52 | #define REG_IISC_SCR (0x4000400CU) /**< \brief (IISC) Status Clear Register */ 53 | #define REG_IISC_SSR (0x40004010U) /**< \brief (IISC) Status Set Register */ 54 | #define REG_IISC_IER (0x40004014U) /**< \brief (IISC) Interrupt Enable Register */ 55 | #define REG_IISC_IDR (0x40004018U) /**< \brief (IISC) Interrupt Disable Register */ 56 | #define REG_IISC_IMR (0x4000401CU) /**< \brief (IISC) Interrupt Mask Register */ 57 | #define REG_IISC_RHR (0x40004020U) /**< \brief (IISC) Receive Holding Register */ 58 | #define REG_IISC_THR (0x40004024U) /**< \brief (IISC) Transmit Holding Register */ 59 | #define REG_IISC_VERSION (0x40004028U) /**< \brief (IISC) Version Register */ 60 | #define REG_IISC_PARAMETER (0x4000402CU) /**< \brief (IISC) Parameter Register */ 61 | #else 62 | #define REG_IISC_CR (*(WoReg *)0x40004000U) /**< \brief (IISC) Control Register */ 63 | #define REG_IISC_MR (*(RwReg *)0x40004004U) /**< \brief (IISC) Mode Register */ 64 | #define REG_IISC_SR (*(RoReg *)0x40004008U) /**< \brief (IISC) Status Register */ 65 | #define REG_IISC_SCR (*(WoReg *)0x4000400CU) /**< \brief (IISC) Status Clear Register */ 66 | #define REG_IISC_SSR (*(WoReg *)0x40004010U) /**< \brief (IISC) Status Set Register */ 67 | #define REG_IISC_IER (*(WoReg *)0x40004014U) /**< \brief (IISC) Interrupt Enable Register */ 68 | #define REG_IISC_IDR (*(WoReg *)0x40004018U) /**< \brief (IISC) Interrupt Disable Register */ 69 | #define REG_IISC_IMR (*(RoReg *)0x4000401CU) /**< \brief (IISC) Interrupt Mask Register */ 70 | #define REG_IISC_RHR (*(RoReg *)0x40004020U) /**< \brief (IISC) Receive Holding Register */ 71 | #define REG_IISC_THR (*(WoReg *)0x40004024U) /**< \brief (IISC) Transmit Holding Register */ 72 | #define REG_IISC_VERSION (*(RoReg *)0x40004028U) /**< \brief (IISC) Version Register */ 73 | #define REG_IISC_PARAMETER (*(RoReg *)0x4000402CU) /**< \brief (IISC) Parameter Register */ 74 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 75 | 76 | /* ========== Instance parameters for IISC peripheral ========== */ 77 | #define IISC_GCLK_NUM 6 78 | #define IISC_PDCA_ID_RX 14 79 | #define IISC_PDCA_ID_RX_1 15 80 | #define IISC_PDCA_ID_TX 33 81 | #define IISC_PDCA_ID_TX_1 34 82 | 83 | #endif /* _SAM4L_IISC_INSTANCE_ */ 84 | -------------------------------------------------------------------------------- /legacy/src/config/conf_clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip-specific system clock manager configuration 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | #ifndef CONF_CLOCK_H_INCLUDED 44 | #define CONF_CLOCK_H_INCLUDED 45 | 46 | #define BOARD_OSC0_HZ 16000000 47 | #define BOARD_OSC0_STARTUP_US 1000 48 | #define BOARD_OSC0_IS_XTAL true 49 | 50 | //#define CONFIG_SYSCLK_INIT_CPUMASK (1 << SYSCLK_OCD) 51 | //#define CONFIG_SYSCLK_INIT_PBAMASK (1 << SYSCLK_IISC) 52 | //#define CONFIG_SYSCLK_INIT_PBBMASK (1 << SYSCLK_USBC_REGS) 53 | //#define CONFIG_SYSCLK_INIT_PBCMASK (1 << SYSCLK_CHIPID) 54 | //#define CONFIG_SYSCLK_INIT_PBDMASK (1 << SYSCLK_AST) 55 | //#define CONFIG_SYSCLK_INIT_HSBMASK (1 << SYSCLK_PDCA_HSB) 56 | 57 | //#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RCSYS 58 | #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_OSC0 59 | //#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL0 60 | // #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_DFLL 61 | //#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC80M 62 | //#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RCFAST 63 | //#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC1M 64 | 65 | /* RCFAST frequency selection: 0 for 4MHz, 1 for 8MHz and 2 for 12MHz */ 66 | //#define CONFIG_RCFAST_FRANGE 0 67 | //#define CONFIG_RCFAST_FRANGE 1 68 | //#define CONFIG_RCFAST_FRANGE 2 69 | 70 | /* 0: disable PicoCache, 1: enable PicoCache */ 71 | #define CONFIG_HCACHE_ENABLE 1 72 | 73 | /* 74 | * To use low power mode for flash read mode (PS0, PS1), don't define it. 75 | * To use high speed mode for flash read mode (PS2), define it. 76 | * 77 | * \note 78 | * For early engineer samples, ONLY low power mode support for flash read mode. 79 | */ 80 | #define CONFIG_FLASH_READ_MODE_HIGH_SPEED_ENABLE 81 | 82 | /* Fbus = Fsys / (2 ^ BUS_div) */ 83 | #define CONFIG_SYSCLK_CPU_DIV 0 84 | #define CONFIG_SYSCLK_PBA_DIV 0 85 | #define CONFIG_SYSCLK_PBB_DIV 0 86 | #define CONFIG_SYSCLK_PBC_DIV 0 87 | #define CONFIG_SYSCLK_PBD_DIV 0 88 | 89 | //#define CONFIG_USBCLK_SOURCE USBCLK_SRC_OSC0 90 | //#define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL0 91 | //#define CONFIG_USBCLK_STARTUP_TIMEOUT (OSC0_STARTUP_TIMEOUT*(1000000/OSC_RCSYS_NOMINAL_HZ)) 92 | 93 | /* Fusb = Fsys / USB_div */ 94 | //#define CONFIG_USBCLK_DIV 1 95 | 96 | //#define CONFIG_PLL0_SOURCE PLL_SRC_OSC0 97 | 98 | /* Fpll0 = (Fclk * PLL_mul) / PLL_div */ 99 | //#define CONFIG_PLL0_MUL (48000000UL / BOARD_OSC0_HZ) 100 | //#define CONFIG_PLL0_DIV 1 101 | 102 | //#define CONFIG_DFLL0_SOURCE GENCLK_SRC_RCSYS 103 | //#define CONFIG_DFLL0_SOURCE GENCLK_SRC_OSC32K 104 | // #define CONFIG_DFLL0_SOURCE GENCLK_SRC_RC32K 105 | 106 | /* Fdfll = (Fclk * DFLL_mul) / DFLL_div */ 107 | // #define CONFIG_DFLL0_FREQ 48000000UL 108 | // #define CONFIG_DFLL0_MUL (CONFIG_DFLL0_FREQ / OSC_RC32K_NOMINAL_HZ) 109 | //#define CONFIG_DFLL0_MUL (CONFIG_DFLL0_FREQ / OSC_RCSYS_NOMINAL_HZ) 110 | // #define CONFIG_DFLL0_DIV 1 111 | 112 | #endif /* CONF_CLOCK_H_INCLUDED */ 113 | -------------------------------------------------------------------------------- /chips/bootloader_nrf52/src/bootloader_entry_gpregret.rs: -------------------------------------------------------------------------------- 1 | //! Decide to enter bootloader based on special RAM location. 2 | //! 3 | //! On the nRF52 the GPREGRET memory location is preserved on a soft reset. This 4 | //! allows the kernel to set this before resetting and resume in the bootloader. 5 | 6 | use kernel::utilities::cells::VolatileCell; 7 | use kernel::utilities::StaticRef; 8 | 9 | /// Magic value for the GPREGRET register that tells our bootloader to stay in 10 | /// bootloader mode. This value is not the same as the Adafruit nRF52 bootloader 11 | /// because we don't need them to conflict and we want to be able to chain nRF52 12 | /// bootloaders. 13 | /// 14 | /// This value is used by the kernel to set the flag so that the bootloader is 15 | /// entered after a soft reset. 16 | const DFU_MAGIC_TOCK_BOOTLOADER1: u8 = 0x90; 17 | /// Second magic value for the GPREGRET register that tells our bootloader to 18 | /// stay in bootloader mode. This value is set by the bootloader after deciding 19 | /// _not_ to stay in the bootloader just in case we want to chain bootloaders. 20 | /// That is, if there are two Tock bootloaders flashed on a chip: 21 | /// 22 | /// ``` 23 | /// Address 24 | /// 0x0: Tock Bootloader 25 | /// 0x10000: Tock Bootloader (second) 26 | /// 0x20000: Other code (or nothing) 27 | /// ``` 28 | /// 29 | /// This is an unusual situation, and is intended to only happen when 30 | /// updating/changing bootloaders. To make it easy to skip through the first but 31 | /// stay in the second, we use this magic value. 32 | const DFU_MAGIC_TOCK_BOOTLOADER2: u8 = 0x91; 33 | 34 | /// Magic value for the double reset memory location indicating we should stay 35 | /// in the bootloader. This value (and name) is taken from the Adafruit nRF52 36 | /// bootloader. 37 | const DFU_DBL_RESET_MAGIC: u32 = 0x5A1AD5; 38 | 39 | /// Memory location we use as a flag for detecting a double reset. 40 | /// 41 | /// I have no idea why we use address 0x20007F7C, but that is what the Adafruit 42 | /// nRF52 bootloader uses, so I copied it. 43 | const DOUBLE_RESET_MEMORY_LOCATION: StaticRef> = 44 | unsafe { StaticRef::new(0x20007F7C as *const VolatileCell) }; 45 | 46 | pub struct BootloaderEntryGpRegRet { 47 | nrf_power: &'static nrf52::power::Power<'static>, 48 | double_reset: StaticRef>, 49 | } 50 | 51 | impl BootloaderEntryGpRegRet { 52 | pub fn new(nrf_power: &'static nrf52::power::Power<'static>) -> BootloaderEntryGpRegRet { 53 | BootloaderEntryGpRegRet { 54 | nrf_power, 55 | double_reset: DOUBLE_RESET_MEMORY_LOCATION, 56 | } 57 | } 58 | } 59 | 60 | impl bootloader::interfaces::BootloaderEntry for BootloaderEntryGpRegRet { 61 | fn stay_in_bootloader(&self) -> bool { 62 | // Check if the retention flag matches the special variable indicating 63 | // we should stay in the bootloader. This would be set by the kernel 64 | // before doing a reset to indicate we should reboot into the 65 | // bootloader. We also allow bootloader chaining 66 | if self.nrf_power.get_gpregret() >= DFU_MAGIC_TOCK_BOOTLOADER1 { 67 | // Clear flag so we do not get stuck in the bootloader. 68 | self.nrf_power.set_gpregret(0); 69 | 70 | return true; 71 | } 72 | 73 | // Check if this is the second bootloader. If so, we want to stay in the 74 | // bootloader unconditionally. 75 | if self.nrf_power.get_gpregret() >= DFU_MAGIC_TOCK_BOOTLOADER2 { 76 | // Clear flag so we do not get stuck in the bootloader. 77 | self.nrf_power.set_gpregret(0); 78 | 79 | return true; 80 | } 81 | 82 | // If the retention flag is not set, then we check for the double reset 83 | // memory location. If this is set to a magic value, then we got two 84 | // resets in a short amount of time and we want to go into the 85 | // bootloader. 86 | if self.double_reset.get() == DFU_DBL_RESET_MAGIC { 87 | self.double_reset.set(0); 88 | return true; 89 | } 90 | 91 | // If neither magic value is set, then we need to check if we just got 92 | // the first of a double reset. We do this by setting our flag and 93 | // entering a busy loop. If the busy loop finishes then we must not have 94 | // gotten a second reset and we go to the kernel. If the busy loop 95 | // doesn't finish because we got a reset in the middle, then the 96 | // bootloader will restart and the check above should trigger. 97 | self.double_reset.set(DFU_DBL_RESET_MAGIC); 98 | for _ in 0..2000000 { 99 | cortexm4::support::nop(); 100 | } 101 | self.double_reset.set(0); 102 | 103 | // Set so that we will stick in the second bootloader if they are 104 | // chained. 105 | self.nrf_power.set_gpregret(DFU_MAGIC_TOCK_BOOTLOADER2); 106 | 107 | // Default to jumping out of the bootloader. 108 | false 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_eic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for EIC 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_EIC_INSTANCE_ 45 | #define _SAM4L_EIC_INSTANCE_ 46 | 47 | /* ========== Register definition for EIC peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_EIC_IER (0x400F1000U) /**< \brief (EIC) Interrupt Enable Register */ 50 | #define REG_EIC_IDR (0x400F1004U) /**< \brief (EIC) Interrupt Disable Register */ 51 | #define REG_EIC_IMR (0x400F1008U) /**< \brief (EIC) Interrupt Mask Register */ 52 | #define REG_EIC_ISR (0x400F100CU) /**< \brief (EIC) Interrupt Status Register */ 53 | #define REG_EIC_ICR (0x400F1010U) /**< \brief (EIC) Interrupt Clear Register */ 54 | #define REG_EIC_MODE (0x400F1014U) /**< \brief (EIC) Mode Register */ 55 | #define REG_EIC_EDGE (0x400F1018U) /**< \brief (EIC) Edge Register */ 56 | #define REG_EIC_LEVEL (0x400F101CU) /**< \brief (EIC) Level Register */ 57 | #define REG_EIC_FILTER (0x400F1020U) /**< \brief (EIC) Filter Register */ 58 | #define REG_EIC_ASYNC (0x400F1028U) /**< \brief (EIC) Asynchronous Register */ 59 | #define REG_EIC_EN (0x400F1030U) /**< \brief (EIC) Enable Register */ 60 | #define REG_EIC_DIS (0x400F1034U) /**< \brief (EIC) Disable Register */ 61 | #define REG_EIC_CTRL (0x400F1038U) /**< \brief (EIC) Control Register */ 62 | #define REG_EIC_VERSION (0x400F13FCU) /**< \brief (EIC) Version Register */ 63 | #else 64 | #define REG_EIC_IER (*(WoReg *)0x400F1000U) /**< \brief (EIC) Interrupt Enable Register */ 65 | #define REG_EIC_IDR (*(WoReg *)0x400F1004U) /**< \brief (EIC) Interrupt Disable Register */ 66 | #define REG_EIC_IMR (*(RoReg *)0x400F1008U) /**< \brief (EIC) Interrupt Mask Register */ 67 | #define REG_EIC_ISR (*(RoReg *)0x400F100CU) /**< \brief (EIC) Interrupt Status Register */ 68 | #define REG_EIC_ICR (*(WoReg *)0x400F1010U) /**< \brief (EIC) Interrupt Clear Register */ 69 | #define REG_EIC_MODE (*(RwReg *)0x400F1014U) /**< \brief (EIC) Mode Register */ 70 | #define REG_EIC_EDGE (*(RwReg *)0x400F1018U) /**< \brief (EIC) Edge Register */ 71 | #define REG_EIC_LEVEL (*(RwReg *)0x400F101CU) /**< \brief (EIC) Level Register */ 72 | #define REG_EIC_FILTER (*(RwReg *)0x400F1020U) /**< \brief (EIC) Filter Register */ 73 | #define REG_EIC_ASYNC (*(RwReg *)0x400F1028U) /**< \brief (EIC) Asynchronous Register */ 74 | #define REG_EIC_EN (*(WoReg *)0x400F1030U) /**< \brief (EIC) Enable Register */ 75 | #define REG_EIC_DIS (*(WoReg *)0x400F1034U) /**< \brief (EIC) Disable Register */ 76 | #define REG_EIC_CTRL (*(RoReg *)0x400F1038U) /**< \brief (EIC) Control Register */ 77 | #define REG_EIC_VERSION (*(RoReg *)0x400F13FCU) /**< \brief (EIC) Version Register */ 78 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 79 | 80 | /* ========== Instance parameters for EIC peripheral ========== */ 81 | #define EIC_STD_NUM 8 82 | #define EIC_EIC_EDGE_IRQ 0 83 | #define EIC_EIC_FALLING_EDGE 0 84 | #define EIC_EIC_FILTER_OFF 0 85 | #define EIC_EIC_FILTER_ON 1 86 | #define EIC_EIC_HIGH_LEVEL 1 87 | #define EIC_EIC_LEVEL_IRQ 1 88 | #define EIC_EIC_LOW_LEVEL 0 89 | #define EIC_EIC_RISING_EDGE 1 90 | #define EIC_EIC_SYNC 0 91 | #define EIC_EIC_USE_ASYNC 1 92 | 93 | #endif /* _SAM4L_EIC_INSTANCE_ */ 94 | -------------------------------------------------------------------------------- /legacy/src/ASF/sam/utils/cmsis/sam4l/include/instance/instance_crccu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for CRCCU 5 | * 6 | * Copyright (c) 2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAM4L_CRCCU_INSTANCE_ 45 | #define _SAM4L_CRCCU_INSTANCE_ 46 | 47 | /* ========== Register definition for CRCCU peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_CRCCU_DSCR (0x400A4000U) /**< \brief (CRCCU) Descriptor Base Register */ 50 | #define REG_CRCCU_DMAEN (0x400A4008U) /**< \brief (CRCCU) DMA Enable Register */ 51 | #define REG_CRCCU_DMADIS (0x400A400CU) /**< \brief (CRCCU) DMA Disable Register */ 52 | #define REG_CRCCU_DMASR (0x400A4010U) /**< \brief (CRCCU) DMA Status Register */ 53 | #define REG_CRCCU_DMAIER (0x400A4014U) /**< \brief (CRCCU) DMA Interrupt Enable Register */ 54 | #define REG_CRCCU_DMAIDR (0x400A4018U) /**< \brief (CRCCU) DMA Interrupt Disable Register */ 55 | #define REG_CRCCU_DMAIMR (0x400A401CU) /**< \brief (CRCCU) DMA Interrupt Mask Register */ 56 | #define REG_CRCCU_DMAISR (0x400A4020U) /**< \brief (CRCCU) DMA Interrupt Status Register */ 57 | #define REG_CRCCU_CR (0x400A4034U) /**< \brief (CRCCU) Control Register */ 58 | #define REG_CRCCU_MR (0x400A4038U) /**< \brief (CRCCU) Mode Register */ 59 | #define REG_CRCCU_SR (0x400A403CU) /**< \brief (CRCCU) Status Register */ 60 | #define REG_CRCCU_IER (0x400A4040U) /**< \brief (CRCCU) Interrupt Enable Register */ 61 | #define REG_CRCCU_IDR (0x400A4044U) /**< \brief (CRCCU) Interrupt Disable Register */ 62 | #define REG_CRCCU_IMR (0x400A4048U) /**< \brief (CRCCU) Interrupt Mask Register */ 63 | #define REG_CRCCU_ISR (0x400A404CU) /**< \brief (CRCCU) Interrupt Status Register */ 64 | #define REG_CRCCU_VERSION (0x400A40FCU) /**< \brief (CRCCU) Version Register */ 65 | #else 66 | #define REG_CRCCU_DSCR (*(RwReg *)0x400A4000U) /**< \brief (CRCCU) Descriptor Base Register */ 67 | #define REG_CRCCU_DMAEN (*(WoReg *)0x400A4008U) /**< \brief (CRCCU) DMA Enable Register */ 68 | #define REG_CRCCU_DMADIS (*(WoReg *)0x400A400CU) /**< \brief (CRCCU) DMA Disable Register */ 69 | #define REG_CRCCU_DMASR (*(RoReg *)0x400A4010U) /**< \brief (CRCCU) DMA Status Register */ 70 | #define REG_CRCCU_DMAIER (*(WoReg *)0x400A4014U) /**< \brief (CRCCU) DMA Interrupt Enable Register */ 71 | #define REG_CRCCU_DMAIDR (*(WoReg *)0x400A4018U) /**< \brief (CRCCU) DMA Interrupt Disable Register */ 72 | #define REG_CRCCU_DMAIMR (*(RoReg *)0x400A401CU) /**< \brief (CRCCU) DMA Interrupt Mask Register */ 73 | #define REG_CRCCU_DMAISR (*(RoReg *)0x400A4020U) /**< \brief (CRCCU) DMA Interrupt Status Register */ 74 | #define REG_CRCCU_CR (*(WoReg *)0x400A4034U) /**< \brief (CRCCU) Control Register */ 75 | #define REG_CRCCU_MR (*(RwReg *)0x400A4038U) /**< \brief (CRCCU) Mode Register */ 76 | #define REG_CRCCU_SR (*(RoReg *)0x400A403CU) /**< \brief (CRCCU) Status Register */ 77 | #define REG_CRCCU_IER (*(WoReg *)0x400A4040U) /**< \brief (CRCCU) Interrupt Enable Register */ 78 | #define REG_CRCCU_IDR (*(WoReg *)0x400A4044U) /**< \brief (CRCCU) Interrupt Disable Register */ 79 | #define REG_CRCCU_IMR (*(RoReg *)0x400A4048U) /**< \brief (CRCCU) Interrupt Mask Register */ 80 | #define REG_CRCCU_ISR (*(RoReg *)0x400A404CU) /**< \brief (CRCCU) Interrupt Status Register */ 81 | #define REG_CRCCU_VERSION (*(RoReg *)0x400A40FCU) /**< \brief (CRCCU) Version Register */ 82 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 83 | 84 | 85 | #endif /* _SAM4L_CRCCU_INSTANCE_ */ 86 | --------------------------------------------------------------------------------