Browse Source

Add two example programs.

pull/21/head
Jonathan 'theJPster' Pallant 4 years ago
parent
commit
a0f9b988db
  1. 12
      Cargo.toml
  2. 13
      examples/tiva-c-connected-launchpad/.cargo/config
  3. 5
      examples/tiva-c-connected-launchpad/.gitignore
  4. 25
      examples/tiva-c-connected-launchpad/Cargo.toml
  5. 20
      examples/tiva-c-connected-launchpad/README.md
  6. 4
      examples/tiva-c-connected-launchpad/openocd.cfg
  7. 32
      examples/tiva-c-connected-launchpad/openocd.gdb
  8. 46
      examples/tiva-c-connected-launchpad/src/main.rs
  9. 13
      examples/tiva-c-launchpad/.cargo/config
  10. 5
      examples/tiva-c-launchpad/.gitignore
  11. 25
      examples/tiva-c-launchpad/Cargo.toml
  12. 20
      examples/tiva-c-launchpad/README.md
  13. 4
      examples/tiva-c-launchpad/openocd.cfg
  14. 32
      examples/tiva-c-launchpad/openocd.gdb
  15. 46
      examples/tiva-c-launchpad/src/main.rs

12
Cargo.toml

@ -1,3 +1,13 @@
[workspace]
members = ["tm4c123x-hal", "tm4c129x-hal", "tm4c-hal"]
members = [
"tm4c123x-hal",
"tm4c129x-hal",
"tm4c-hal",
"examples/tiva-c-launchpad",
"examples/tiva-c-connected-launchpad",
]
[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations

13
examples/tiva-c-connected-launchpad/.cargo/config

@ -0,0 +1,13 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
rustflags = [
"-C", "link-arg=-Tlink.x",
]
[build]
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

5
examples/tiva-c-connected-launchpad/.gitignore vendored

@ -0,0 +1,5 @@
**/*.rs.bk
.#*
.gdb_history
Cargo.lock
target/

25
examples/tiva-c-connected-launchpad/Cargo.toml

@ -0,0 +1,25 @@
[package]
authors = [
"Jonathan 'theJPster' Pallant <github@thejpster.org.uk>",
]
edition = "2018"
readme = "README.md"
name = "tiva-c-connected-launchpad"
version = "0.1.0"
[dependencies]
cortex-m = "0.5.8"
cortex-m-rt = "0.6.5"
cortex-m-semihosting = "0.3.2"
panic-halt = "0.2.0"
[dependencies.tm4c129x-hal]
# version = "0.7.0"
path = "../../tm4c129x-hal"
features = ["rt"]
# this lets you use `cargo fix`!
[[bin]]
name = "tiva-c-connected-launchpad"
test = false
bench = false

20
examples/tiva-c-connected-launchpad/README.md

@ -0,0 +1,20 @@
# Tiva-C Connected Launchpad Demo Application
> For the Tiva-C Series TM4C1294 Connected Launchpad, [EK-TM4C1294XL](https://www.ti.com/tool/EK-TM4C1294XL)
## License
This template is licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

4
examples/tiva-c-connected-launchpad/openocd.cfg

@ -0,0 +1,4 @@
# Sample OpenOCD configuration for the Tiva-C Connected Launchpad development board
source [find board/ek-tm4c1294xl.cfg]

32
examples/tiva-c-connected-launchpad/openocd.gdb

@ -0,0 +1,32 @@
target extended-remote :3333
# print demangled symbols
set print asm-demangle on
# detect unhandled exceptions, hard faults and panics
break DefaultHandler
break UserHardFault
break rust_begin_unwind
# *try* to stop at the user entry point (it might be gone due to inlining)
break main
monitor arm semihosting enable
# # send captured ITM to the file itm.fifo
# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
# # 8000000 must match the core clock frequency
# monitor tpiu config internal itm.txt uart off 8000000
# # OR: make the microcontroller SWO pin output compatible with UART (8N1)
# # 8000000 must match the core clock frequency
# # 2000000 is the frequency of the SWO pin
# monitor tpiu config external uart off 8000000 2000000
# # enable ITM port 0
# monitor itm port 0 on
load
# start the process but immediately halt the processor
stepi

46
examples/tiva-c-connected-launchpad/src/main.rs

@ -0,0 +1,46 @@
#![no_std]
#![no_main]
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
extern crate tm4c129x_hal as hal;
use core::fmt::Write;
use cortex_m_rt::entry;
use hal::prelude::*;
#[entry]
fn main() -> ! {
let p = hal::Peripherals::take().unwrap();
let mut sc = p.SYSCTL.constrain();
sc.clock_setup.oscillator = hal::sysctl::Oscillator::Main(
hal::sysctl::CrystalFrequency::_16mhz,
hal::sysctl::SystemClock::UsePll(hal::sysctl::PllOutputFrequency::_120mhz),
);
let clocks = sc.clock_setup.freeze();
let mut porta = p.GPIO_PORTA_AHB.split(&sc.power_control);
// Activate UART
let mut uart = hal::serial::Serial::uart0(
p.UART0,
porta
.pa1
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
porta
.pa0
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
(),
(),
115200_u32.bps(),
hal::serial::NewlineMode::SwapLFtoCRLF,
&clocks,
&sc.power_control,
);
let mut counter = 0u32;
loop {
writeln!(uart, "Hello, world! counter={}", counter).unwrap();
counter = counter.wrapping_add(1);
}
}

13
examples/tiva-c-launchpad/.cargo/config

@ -0,0 +1,13 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
rustflags = [
"-C", "link-arg=-Tlink.x",
]
[build]
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

5
examples/tiva-c-launchpad/.gitignore vendored

@ -0,0 +1,5 @@
**/*.rs.bk
.#*
.gdb_history
Cargo.lock
target/

25
examples/tiva-c-launchpad/Cargo.toml

@ -0,0 +1,25 @@
[package]
authors = [
"Jonathan 'theJPster' Pallant <github@thejpster.org.uk>",
]
edition = "2018"
readme = "README.md"
name = "tiva-c-launchpad"
version = "0.1.0"
[dependencies]
cortex-m = "0.5.8"
cortex-m-rt = "0.6.5"
cortex-m-semihosting = "0.3.2"
panic-halt = "0.2.0"
[dependencies.tm4c123x-hal]
# version = "0.8.0"
path = "../../tm4c123x-hal"
features = ["rt"]
# this lets you use `cargo fix`!
[[bin]]
name = "tiva-c-launchpad"
test = false
bench = false

20
examples/tiva-c-launchpad/README.md

@ -0,0 +1,20 @@
# Tiva-C Launchpad Demo Application
> For the Tiva-C Series TM4C123G Launchpad, [EK-TM4C123GXL](https://www.ti.com/tool/EK-TM4C123GXL)
## License
This template is licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](../../LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](../../LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

4
examples/tiva-c-launchpad/openocd.cfg

@ -0,0 +1,4 @@
# Sample OpenOCD configuration for the Tiva-C Launchpad development board
source [find board/ek-tm4c124gxl.cfg]

32
examples/tiva-c-launchpad/openocd.gdb

@ -0,0 +1,32 @@
target extended-remote :3333
# print demangled symbols
set print asm-demangle on
# detect unhandled exceptions, hard faults and panics
break DefaultHandler
break UserHardFault
break rust_begin_unwind
# *try* to stop at the user entry point (it might be gone due to inlining)
break main
monitor arm semihosting enable
# # send captured ITM to the file itm.fifo
# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
# # 8000000 must match the core clock frequency
# monitor tpiu config internal itm.txt uart off 8000000
# # OR: make the microcontroller SWO pin output compatible with UART (8N1)
# # 8000000 must match the core clock frequency
# # 2000000 is the frequency of the SWO pin
# monitor tpiu config external uart off 8000000 2000000
# # enable ITM port 0
# monitor itm port 0 on
load
# start the process but immediately halt the processor
stepi

46
examples/tiva-c-launchpad/src/main.rs

@ -0,0 +1,46 @@
#![no_std]
#![no_main]
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
extern crate tm4c123x_hal as hal;
use core::fmt::Write;
use cortex_m_rt::entry;
use hal::prelude::*;
#[entry]
fn main() -> ! {
let p = hal::Peripherals::take().unwrap();
let mut sc = p.SYSCTL.constrain();
sc.clock_setup.oscillator = hal::sysctl::Oscillator::Main(
hal::sysctl::CrystalFrequency::_16mhz,
hal::sysctl::SystemClock::UsePll(hal::sysctl::PllOutputFrequency::_80_00mhz),
);
let clocks = sc.clock_setup.freeze();
let mut porta = p.GPIO_PORTA_AHB.split(&sc.power_control);
// Activate UART
let mut uart = hal::serial::Serial::uart0(
p.UART0,
porta
.pa1
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
porta
.pa0
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
(),
(),
115200_u32.bps(),
hal::serial::NewlineMode::SwapLFtoCRLF,
&clocks,
&sc.power_control,
);
let mut counter = 0u32;
loop {
writeln!(uart, "Hello, world! counter={}", counter).unwrap();
counter = counter.wrapping_add(1);
}
}
Loading…
Cancel
Save