This repository has been archived by the owner on Jul 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic pin control for tm4c123gh6pm. Can light up a LED!
- Loading branch information
Showing
15 changed files
with
595 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ impl Pin { | |
port: port, | ||
pin: pin_index, | ||
}; | ||
|
||
pin.setup_regs(function, gpiodir); | ||
|
||
pin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! Custom register access interface | ||
use util::volatile_cell::VolatileCell; | ||
use core::intrinsics::{volatile_load, volatile_store}; | ||
|
||
/// Hardware register interface | ||
pub struct Reg { | ||
/// Register address | ||
addr: u32, | ||
} | ||
|
||
impl Reg { | ||
/// create a new Reg from a 32bit register address | ||
pub fn new(addr: u32) -> Reg { | ||
Reg { addr: addr } | ||
} | ||
|
||
/// Write to a 32bit register | ||
#[inline] | ||
pub fn write32(&self, val: u32) { | ||
unsafe { | ||
let r = self.addr as *mut u32; | ||
volatile_store(r, val); | ||
} | ||
} | ||
|
||
/// Read from a 32bit register | ||
#[inline] | ||
pub fn read32(&self) -> u32 { | ||
unsafe { | ||
let r = self.addr as *const u32; | ||
volatile_load(r) | ||
} | ||
} | ||
|
||
/// Write single bit to a register using hardware bitbanding | ||
#[inline] | ||
pub fn bitband_write(&self, bit: u8, set: bool) { | ||
/* bitband offset */ | ||
let mut bitband = (self.addr & 0xf0000000) | 0x02000000; | ||
|
||
/* register offset */ | ||
bitband |= (self.addr & 0x00fffff) << 5; | ||
/* bit offset */ | ||
bitband |= (bit as u32) << 2; | ||
|
||
unsafe { | ||
let r = bitband as *mut u32; | ||
volatile_store(r, set as u32); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
use core::option::{Option, None}; | ||
|
||
static ISRCount: uint = 139; | ||
|
||
#[link_section=".isr_vector_nvic"] | ||
#[no_mangle] | ||
pub static NVIC_VECTOR: [Option<unsafe extern fn()>, ..ISRCount] = [ | ||
None, // GPIO Port A | ||
None, // GPIO Port B | ||
None, // GPIO Port C | ||
None, // GPIO Port D | ||
None, // GPIO Port E | ||
None, // UART0 Rx and Tx | ||
None, // UART1 Rx and Tx | ||
None, // SSI0 Rx and Tx | ||
None, // I2C0 Master and Slave | ||
None, // PWM Fault | ||
None, // PWM Generator 0 | ||
None, // PWM Generator 1 | ||
None, // PWM Generator 2 | ||
None, // Quadrature Encoder 0 | ||
None, // ADC Sequence 0 | ||
None, // ADC Sequence 1 | ||
None, // ADC Sequence 2 | ||
None, // ADC Sequence 3 | ||
None, // Watchdog timer | ||
None, // Timer 0 subtimer A | ||
None, // Timer 0 subtimer B | ||
None, // Timer 1 subtimer A | ||
None, // Timer 1 subtimer B | ||
None, // Timer 2 subtimer A | ||
None, // Timer 2 subtimer B | ||
None, // Analog Comparator 0 | ||
None, // Analog Comparator 1 | ||
None, // Analog Comparator 2 | ||
None, // System Control (PLL, OSC, BO) | ||
None, // FLASH Control | ||
None, // GPIO Port F | ||
None, // GPIO Port G | ||
None, // GPIO Port H | ||
None, // UART2 Rx and Tx | ||
None, // SSI1 Rx and Tx | ||
None, // Timer 3 subtimer A | ||
None, // Timer 3 subtimer B | ||
None, // I2C1 Master and Slave | ||
None, // Quadrature Encoder 1 | ||
None, // CAN0 | ||
None, // CAN1 | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Hibernate | ||
None, // USB0 | ||
None, // PWM Generator 3 | ||
None, // uDMA Software Transfer | ||
None, // uDMA Error | ||
None, // ADC1 Sequence 0 | ||
None, // ADC1 Sequence 1 | ||
None, // ADC1 Sequence 2 | ||
None, // ADC1 Sequence 3 | ||
None, // Reserved | ||
None, // Reserved | ||
None, // GPIO Port J | ||
None, // GPIO Port K | ||
None, // GPIO Port L | ||
None, // SSI2 Rx and Tx | ||
None, // SSI3 Rx and Tx | ||
None, // UART3 Rx and Tx | ||
None, // UART4 Rx and Tx | ||
None, // UART5 Rx and Tx | ||
None, // UART6 Rx and Tx | ||
None, // UART7 Rx and Tx | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // I2C2 Master and Slave | ||
None, // I2C3 Master and Slave | ||
None, // Timer 4 subtimer A | ||
None, // Timer 4 subtimer B | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Reserved | ||
None, // Timer 5 subtimer A | ||
None, // Timer 5 subtimer B | ||
None, // Wide Timer 0 subtimer A | ||
None, // Wide Timer 0 subtimer B | ||
None, // Wide Timer 1 subtimer A | ||
None, // Wide Timer 1 subtimer B | ||
None, // Wide Timer 2 subtimer A | ||
None, // Wide Timer 2 subtimer B | ||
None, // Wide Timer 3 subtimer A | ||
None, // Wide Timer 3 subtimer B | ||
None, // Wide Timer 4 subtimer A | ||
None, // Wide Timer 4 subtimer B | ||
None, // Wide Timer 5 subtimer A | ||
None, // Wide Timer 5 subtimer B | ||
None, // FPU | ||
None, // Reserved | ||
None, // Reserved | ||
None, // I2C4 Master and Slave | ||
None, // I2C5 Master and Slave | ||
None, // GPIO Port M | ||
None, // GPIO Port N | ||
None, // Quadrature Encoder 2 | ||
None, // Reserved | ||
None, // Reserved | ||
None, // GPIO Port P (Summary or P0) | ||
None, // GPIO Port P1 | ||
None, // GPIO Port P2 | ||
None, // GPIO Port P3 | ||
None, // GPIO Port P4 | ||
None, // GPIO Port P5 | ||
None, // GPIO Port P6 | ||
None, // GPIO Port P7 | ||
None, // GPIO Port Q (Summary or Q0) | ||
None, // GPIO Port Q1 | ||
None, // GPIO Port Q2 | ||
None, // GPIO Port Q3 | ||
None, // GPIO Port Q4 | ||
None, // GPIO Port Q5 | ||
None, // GPIO Port Q6 | ||
None, // GPIO Port Q7 | ||
None, // GPIO Port R | ||
None, // GPIO Port S | ||
None, // PWM 1 Generator 0 | ||
None, // PWM 1 Generator 1 | ||
None, // PWM 1 Generator 2 | ||
None, // PWM 1 Generator 3 | ||
None, // PWM 1 Fault*/ | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//! HAL for TI TM4C123GH6PM | ||
//! This MCU is used on the TI stellaris and Tiva C launchpad development boards. | ||
pub mod io; | ||
pub mod sysctl; | ||
pub mod pin; | ||
|
||
#[path="../../util/ioreg.rs"] mod util; |
Oops, something went wrong.