forked from M-Labs/ionpak-thermostat
Report error pin status
This commit is contained in:
parent
1069944ea2
commit
8abeff05a1
|
@ -26,6 +26,12 @@ const IC_ADC: u8 = 0x08; // PE3
|
||||||
const FBV_ADC: u8 = 0x20; // PD5
|
const FBV_ADC: u8 = 0x20; // PD5
|
||||||
const AV_ADC: u8 = 0x40; // PD6
|
const AV_ADC: u8 = 0x40; // PD6
|
||||||
|
|
||||||
|
const FV_ERRN: u8 = 0x01; // PL0
|
||||||
|
const FBV_ERRN: u8 = 0x02; // PL1
|
||||||
|
const FBI_ERRN: u8 = 0x04; // PL2
|
||||||
|
const AV_ERRN: u8 = 0x08; // PL3
|
||||||
|
const AI_ERRN: u8 = 0x10; // PL4
|
||||||
|
|
||||||
const PWM_LOAD: u16 = (/*pwmclk*/16_000_000u32 / /*freq*/100_000) as u16;
|
const PWM_LOAD: u16 = (/*pwmclk*/16_000_000u32 / /*freq*/100_000) as u16;
|
||||||
const ADC_TIMER_LOAD: u32 = /*timerclk*/16_000_000 / /*freq*/100;
|
const ADC_TIMER_LOAD: u32 = /*timerclk*/16_000_000 / /*freq*/100;
|
||||||
|
|
||||||
|
@ -93,13 +99,14 @@ fn main() {
|
||||||
systick.enable_counter();
|
systick.enable_counter();
|
||||||
systick.enable_interrupt();
|
systick.enable_interrupt();
|
||||||
|
|
||||||
// Bring up GPIO ports D, E, F, G, K, P
|
// Bring up GPIO ports D, E, F, G, K, L, P
|
||||||
sysctl.rcgcgpio.modify(|_, w| {
|
sysctl.rcgcgpio.modify(|_, w| {
|
||||||
w.r3().bit(true)
|
w.r3().bit(true)
|
||||||
.r4().bit(true)
|
.r4().bit(true)
|
||||||
.r5().bit(true)
|
.r5().bit(true)
|
||||||
.r6().bit(true)
|
.r6().bit(true)
|
||||||
.r9().bit(true)
|
.r9().bit(true)
|
||||||
|
.r10().bit(true)
|
||||||
.r13().bit(true)
|
.r13().bit(true)
|
||||||
});
|
});
|
||||||
while !sysctl.prgpio.read().r3().bit() {}
|
while !sysctl.prgpio.read().r3().bit() {}
|
||||||
|
@ -107,6 +114,7 @@ fn main() {
|
||||||
while !sysctl.prgpio.read().r5().bit() {}
|
while !sysctl.prgpio.read().r5().bit() {}
|
||||||
while !sysctl.prgpio.read().r6().bit() {}
|
while !sysctl.prgpio.read().r6().bit() {}
|
||||||
while !sysctl.prgpio.read().r9().bit() {}
|
while !sysctl.prgpio.read().r9().bit() {}
|
||||||
|
while !sysctl.prgpio.read().r10().bit() {}
|
||||||
while !sysctl.prgpio.read().r13().bit() {}
|
while !sysctl.prgpio.read().r13().bit() {}
|
||||||
|
|
||||||
// Set up LEDs
|
// Set up LEDs
|
||||||
|
@ -119,6 +127,11 @@ fn main() {
|
||||||
gpio_p.dir.write(|w| w.dir().bits(0b111111));
|
gpio_p.dir.write(|w| w.dir().bits(0b111111));
|
||||||
gpio_p.den.write(|w| w.den().bits(0b111111));
|
gpio_p.den.write(|w| w.den().bits(0b111111));
|
||||||
|
|
||||||
|
// Set up error input pins
|
||||||
|
let gpio_l = tm4c129x::GPIO_PORTL.borrow(cs);
|
||||||
|
gpio_l.pur.write(|w| w.pue().bits(FV_ERRN|FBV_ERRN|FBI_ERRN|AV_ERRN|AI_ERRN));
|
||||||
|
gpio_l.den.write(|w| w.den().bits(FV_ERRN|FBV_ERRN|FBI_ERRN|AV_ERRN|AI_ERRN));
|
||||||
|
|
||||||
// Set up PWMs
|
// Set up PWMs
|
||||||
let gpio_f = tm4c129x::GPIO_PORTF_AHB.borrow(cs);
|
let gpio_f = tm4c129x::GPIO_PORTF_AHB.borrow(cs);
|
||||||
gpio_f.dir.write(|w| w.dir().bits(HV_PWM|FV_PWM));
|
gpio_f.dir.write(|w| w.dir().bits(HV_PWM|FV_PWM));
|
||||||
|
@ -212,6 +225,28 @@ fn main() {
|
||||||
set_fv_pwm(PWM_LOAD/16);
|
set_fv_pwm(PWM_LOAD/16);
|
||||||
set_fbv_pwm(PWM_LOAD/8);
|
set_fbv_pwm(PWM_LOAD/8);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
loop {
|
||||||
|
cortex_m::interrupt::free(|cs| {
|
||||||
|
let gpio_l = tm4c129x::GPIO_PORTL.borrow(cs);
|
||||||
|
let errors_n = gpio_l.data.read().bits() as u8;
|
||||||
|
if errors_n & FV_ERRN == 0 {
|
||||||
|
hprintln!("Filament overvolt");
|
||||||
|
}
|
||||||
|
if errors_n & FBV_ERRN == 0 {
|
||||||
|
hprintln!("Filament bias overvolt");
|
||||||
|
}
|
||||||
|
if errors_n & FBI_ERRN == 0 {
|
||||||
|
hprintln!("Filament bias overcurrent");
|
||||||
|
}
|
||||||
|
if errors_n & AV_ERRN == 0 {
|
||||||
|
hprintln!("Anode overvolt");
|
||||||
|
}
|
||||||
|
if errors_n & AI_ERRN == 0 {
|
||||||
|
hprintln!("Anode overcurrent");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue