4268e45a0aa5e7254e05db855c398c890e762de0 — Wesley Moore 7 months ago 77ec119
Working flashing LED example
7 files changed, 401 insertions(+), 0 deletions(-)

A .cargo/config
A Cargo.lock
A Cargo.toml
A jtag/gdbinit
A jtag/openocd.cfg
A memory.x
A src/main.rs
A .cargo/config => .cargo/config +5 -0
@@ 0,0 1,5 @@
+ [target.thumbv7m-none-eabi]
+ runner = "arm-none-eabi-gdb -q"
+ rustflags = [
+   "-C", "link-arg=-Tlink.x",
+ ]

A Cargo.lock => Cargo.lock +217 -0
@@ 0,0 1,217 @@
+ [[package]]
+ name = "aligned"
+ version = "0.2.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "bare-metal"
+ version = "0.2.4"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "cast"
+ version = "0.2.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "cc2650-hal"
+ version = "0.1.0"
+ dependencies = [
+  "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+  "cc2650f128 0.1.0",
+  "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
+  "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "cc2650f128"
+ version = "0.1.0"
+ dependencies = [
+  "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+  "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
+  "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "cortex-m"
+ version = "0.5.8"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+  "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+  "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "cortex-m-rt"
+ version = "0.6.7"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+  "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "cortex-m-rt-macros"
+ version = "0.1.5"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
+  "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
+  "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
+  "syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "embedded-hal"
+ version = "0.2.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+  "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "nb"
+ version = "0.1.1"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "panic-halt"
+ version = "0.2.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "proc-macro2"
+ version = "0.4.27"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "quote"
+ version = "0.6.11"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "r0"
+ version = "0.2.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "rand"
+ version = "0.5.6"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "rand_core"
+ version = "0.3.1"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "rand_core"
+ version = "0.4.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "rustc_version"
+ version = "0.2.3"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "semver"
+ version = "0.9.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "semver-parser"
+ version = "0.7.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "sensortag-test"
+ version = "0.1.0"
+ dependencies = [
+  "cc2650-hal 0.1.0",
+  "cc2650f128 0.1.0",
+  "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
+  "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
+  "panic-halt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "syn"
+ version = "0.15.28"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
+  "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
+  "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [[package]]
+ name = "unicode-xid"
+ version = "0.1.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "vcell"
+ version = "0.1.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "void"
+ version = "1.0.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ 
+ [[package]]
+ name = "volatile-register"
+ version = "0.2.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ dependencies = [
+  "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ ]
+ 
+ [metadata]
+ "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5"
+ "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a"
+ "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
+ "checksum cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dab2164a0fc216781a47fc343347365112ae6917421d3fa4bac6faf0fbaaaec7"
+ "checksum cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f69d2beca37acc3776c17201c9d1f8904fb9139fa3a4d2cf28c8436a07b21a88"
+ "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f"
+ "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33"
+ "checksum nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "69f380b5fe9fab8c0d7a6a99cda23e2cc0463bedb2cbc3aada0813b98496ecdc"
+ "checksum panic-halt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812"
+ "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
+ "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
+ "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
+ "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
+ "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
+ "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
+ "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
+ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
+ "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+ "checksum syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)" = "218aa5a01ab9805df6e9e48074c8d88f317cc9660b1ad6c3dabac2d627d185d6"
+ "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
+ "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d"
+ "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+ "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286"

A Cargo.toml => Cargo.toml +12 -0
@@ 0,0 1,12 @@
+ [package]
+ name = "sensortag-test"
+ version = "0.1.0"
+ authors = ["Wesley Moore <wes@wezm.net>"]
+ edition = "2018"
+ 
+ [dependencies]
+ cortex-m = "0.5.6"
+ panic-halt = "0.2.0"
+ cortex-m-rt = "0.6.3"
+ cc2650f128 = { path = "../../Source/dslite2svd/crates/cc2650f128" }
+ cc2650-hal = { path = "../cc2650-hal" }

A jtag/gdbinit => jtag/gdbinit +15 -0
@@ 0,0 1,15 @@
+ # GDB Init for openocd
+ 
+ set remotetimeout 20000
+ 
+ # Connect to openocd at port 3333
+ target remote localhost:3333
+ 
+ #file target/thumbv7m-none-eabi/release/sensortag
+ #file target/thumbv7m-none-eabi/debug/sensortag
+ 
+ # monitor reset halt
+ 
+ # Setup GDB for faster downloads
+ #set remote memory-write-packet-size 1024
+ #set remote memory-write-packet-size fixed

A jtag/openocd.cfg => jtag/openocd.cfg +8 -0
@@ 0,0 1,8 @@
+ # Requires patched OpenOCD (built from git)
+ source [find interface/xds110.cfg]
+ 
+ transport select jtag
+ gdb_memory_map enable
+ gdb_flash_program enable
+ source [find target/ti_cc26x0.cfg]
+ adapter_khz 5000

A memory.x => memory.x +39 -0
@@ 0,0 1,39 @@
+ /* Linker script for the STM32F103C8T6 */
+ /*
+ #define FLASH_BASE              0x0
+ #define FLASH_SIZE              0x20000
+ #define RAM_BASE                0x20000000
+ #define RAM_SIZE                0x5000
+ */
+ MEMORY
+ {
+   FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 128K
+   RAM (RWX) : ORIGIN = 0x20000000, LENGTH = 20K
+ }
+ 
+ /*
+ 
+ SECTIONS
+ {
+     .text           :   > FLASH
+     .const          :   > FLASH
+     .constdata      :   > FLASH
+     .rodata         :   > FLASH
+     .cinit          :   > FLASH
+     .pinit          :   > FLASH
+     .init_array     :   > FLASH
+     .emb_text       :   > FLASH
+     .ccfg           :   > FLASH (HIGH)
+ 
+ #ifdef __TI_COMPILER_VERSION__
+ #if __TI_COMPILER_VERSION__ >= 15009000
+     .TI.ramfunc     : {} load=FLASH, run=SRAM, table(BINIT)
+ #endif
+ #endif
+     .data           :   > SRAM
+     .bss            :   > SRAM
+     .sysmem         :   > SRAM
+     .stack          :   > SRAM (HIGH)
+     .nonretenvar    :   > SRAM
+ }
+ */

A src/main.rs => src/main.rs +105 -0
@@ 0,0 1,105 @@
+ #![deny(unsafe_code)]
+ #![no_main]
+ #![no_std]
+ 
+ #[allow(unused_extern_crates)] // NOTE(allow) bug rust-lang/rust#53964
+ extern crate panic_halt; // panic handler
+ 
+ // SensorTag is using RGZ package. VQFN (RGZ) | 48 pins, 7×7 QFN
+ 
+ use cc2650_hal as hal;
+ use cc2650f128;
+ use cortex_m_rt::entry;
+ 
+ use hal::{ddi, delay::Delay, prelude::*};
+ 
+ pub fn init() -> (Delay, cc2650f128::Peripherals) {
+     let core_peripherals = cortex_m::Peripherals::take().unwrap();
+     let device_peripherals = cc2650f128::Peripherals::take().unwrap();
+ 
+     let clocks = ddi::CFGR {
+         sysclk: Some(24_000_000),
+     }
+     .freeze();
+ 
+     let delay = Delay::new(core_peripherals.SYST, clocks);
+ 
+     // By default GPIOs are configured as inputs. Default output type is push/pull so
+     // just need to disable input, and enable output
+ 
+     // #define Board_STK_LED1              IOID_10
+     // #define Board_STK_LED2              IOID_15
+     // Board_STK_LED1   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,     [> LED initially off             <]
+     // Board_STK_LED2   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,     [> LED initially off             <]
+ 
+     // Lets configure some pins, in the IOC module
+     // • PORTID is the number for a peripheral function.
+     // • GPIO is a peripheral function with the PORTID of 0x0.
+     // • DIO (DIO0 to DIO31) are the logic names for the different I/O pins on the specific package.
+     //
+     // The PORTID and pin configuration must be set in the corresponding IOC:IOCFGn register. To
+     // select what kind of function the pin must be routed, choose the PORTID number for the
+     // desired peripheral function and write the PORTID number to the IOC:IOCFGn.PORTID bit field.
+     //
+     // The MCU GPIO is a general-purpose input/output that drives a number of physical I/O pads.
+     // GPIO supports up to 31 programmable I/O pins. These pins are configured by the IOC module.
+     //
+     // To modify a single GPIO output value, use the GPIO:DOUTn registers (see Section 11.11.2). To
+     // set up DIO1 as a GPIO output and toggle the bit, use the following procedure.
+     //
+     // 1. Map DIO1 as a GPIO output by setting the IOC:IOCFG1.PORT_ID register to 0 (GPIO PORDTID).
+     // 2. Ensure DIO1 is set as output by clearing the IOC:IOCFG1.IE bit. More port configurations
+     //    can also be set in the IOC:IOCFG1 register (for more details, see Section 11.10.1.2).
+     // 3. Set the data output enable bit for DIO1 in GPIO:DOE31_0.DIO1 by issuing a
+     //    read-modify-write operation.
+ 
+     // Configure GPIO pins for output, maximum strength
+     device_peripherals.IOC
+         .iocfg10
+         .modify(|_r, w| w.port_id().gpio().ie().clear_bit().iostr().max());
+     device_peripherals.IOC
+         .iocfg15
+         .modify(|_r, w| w.port_id().gpio().ie().clear_bit().iostr().max());
+ 
+     // Enable the PERIPH power domain and wait for it to be powered up
+     device_peripherals.PRCM.pdctl0.modify(|_r, w| w.periph_on().set_bit());
+     loop {
+         if device_peripherals.PRCM.pdstat0.read().periph_on().bit_is_set() {
+             break;
+         }
+     }
+ 
+     // Enable the GPIO clock
+     device_peripherals.PRCM.gpioclkgr.write(|w| w.clk_en().set_bit());
+ 
+     // Load settings into CLKCTRL and wait for LOAD_DONE
+     device_peripherals.PRCM.clkloadctl.modify(|_r, w| w.load().set_bit());
+     loop {
+         if device_peripherals.PRCM.clkloadctl.read().load_done().bit_is_set() {
+             break;
+         }
+     }
+ 
+     // Enable outputs
+     device_peripherals.GPIO
+         .doe31_0
+         .modify(|_r, w| w.dio10().set_bit().dio15().set_bit());
+ 
+     (delay, device_peripherals)
+ }
+ 
+ #[entry]
+ fn entry() -> ! {
+     let (mut delay, periphs) = init();
+     let half_period = 500_u16;
+ 
+     loop {
+         // Turn LED on and wait half a second
+         periphs.GPIO.dout11_8.modify(|_r, w| w.dio10().set_bit());
+         delay.delay_ms(half_period);
+ 
+         // Turn LED off and wait half a second
+         periphs.GPIO.dout11_8.modify(|_r, w| w.dio10().clear_bit());
+         delay.delay_ms(half_period);
+     }
+ }