mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
oem-baosec-lite support to bao-video
remap pwm lock output. This reduces power consumption in camera mode by removing an I/O conflict with the keyboard scanner.
This commit is contained in:
parent
00e70d8c1d
commit
e329ebeb1d
2 changed files with 40 additions and 13 deletions
|
|
@ -50,6 +50,7 @@ board-baosec = [
|
||||||
"blitstr2/board-baosec",
|
"blitstr2/board-baosec",
|
||||||
"no-gam",
|
"no-gam",
|
||||||
]
|
]
|
||||||
|
oem-baosec-lite = ["bao1x-hal/oem-baosec-lite"]
|
||||||
hosted-baosec = ["bao1x-emu", "ux-api/hosted-baosec", "no-gam"]
|
hosted-baosec = ["bao1x-emu", "ux-api/hosted-baosec", "no-gam"]
|
||||||
|
|
||||||
# temporary feature - remove after we have properly created a camera control API
|
# temporary feature - remove after we have properly created a camera control API
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,11 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
|
|
||||||
udma_global.udma_clock_config(PeriphId::Cam, true);
|
udma_global.udma_clock_config(PeriphId::Cam, true);
|
||||||
// ---- camera initialization
|
// ---- camera initialization
|
||||||
|
#[cfg(not(feature = "oem-baosec-lite"))]
|
||||||
|
let cam_clk = (IoxPort::PA, 0);
|
||||||
|
#[cfg(feature = "oem-baosec-lite")]
|
||||||
|
let cam_clk = (IoxPort::PA, 3);
|
||||||
|
|
||||||
#[cfg(not(feature = "hosted-baosec"))]
|
#[cfg(not(feature = "hosted-baosec"))]
|
||||||
let (mut cam, cam_pdwn) = {
|
let (mut cam, cam_pdwn) = {
|
||||||
// wait for other inits to finish so we can do this roughly atomically
|
// wait for other inits to finish so we can do this roughly atomically
|
||||||
|
|
@ -242,8 +247,8 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
|
|
||||||
// setup camera clock
|
// setup camera clock
|
||||||
iox.setup_pin(
|
iox.setup_pin(
|
||||||
IoxPort::PA,
|
cam_clk.0,
|
||||||
0,
|
cam_clk.1,
|
||||||
Some(IoxDir::Output),
|
Some(IoxDir::Output),
|
||||||
Some(IoxFunction::AF3),
|
Some(IoxFunction::AF3),
|
||||||
None,
|
None,
|
||||||
|
|
@ -251,12 +256,24 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
Some(IoxEnable::Disable),
|
Some(IoxEnable::Disable),
|
||||||
Some(IoxDriveStrength::Drive8mA),
|
Some(IoxDriveStrength::Drive8mA),
|
||||||
);
|
);
|
||||||
timer.wo(utra::pwm::REG_CH_EN, 1);
|
#[cfg(not(feature = "oem-baosec-lite"))]
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CFG_R_TIMER0_SAW, 1);
|
{
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CH0_TH_R_TIMER0_CH0_TH, 0);
|
timer.wo(utra::pwm::REG_CH_EN, 1);
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CH0_TH_R_TIMER0_CH0_MODE, 3);
|
timer.rmwf(utra::pwm::REG_TIM0_CFG_R_TIMER0_SAW, 1);
|
||||||
unsafe { timer.base().add(2).write_volatile(0) }; // for some reason the register extraction didn't get this register...
|
timer.rmwf(utra::pwm::REG_TIM0_CH0_TH_R_TIMER0_CH0_TH, 0);
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
timer.rmwf(utra::pwm::REG_TIM0_CH0_TH_R_TIMER0_CH0_MODE, 3);
|
||||||
|
unsafe { timer.base().add(2).write_volatile(0) }; // for some reason the register extraction didn't get this register...
|
||||||
|
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
||||||
|
}
|
||||||
|
#[cfg(feature = "oem-baosec-lite")]
|
||||||
|
{
|
||||||
|
timer.wo(utra::pwm::REG_CH_EN, 1);
|
||||||
|
timer.rmwf(utra::pwm::REG_TIM0_CFG_R_TIMER0_SAW, 1);
|
||||||
|
timer.rmwf(utra::pwm::REG_TIM0_CH3_TH_R_TIMER0_CH3_TH, 0);
|
||||||
|
timer.rmwf(utra::pwm::REG_TIM0_CH3_TH_R_TIMER0_CH3_MODE, 3);
|
||||||
|
unsafe { timer.base().add(2).write_volatile(0) }; // for some reason the register extraction didn't get this register...
|
||||||
|
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
||||||
|
}
|
||||||
/* // register debug
|
/* // register debug
|
||||||
for i in 0..12 {
|
for i in 0..12 {
|
||||||
println!("0x{:2x}: 0x{:08x}", i, unsafe { pwm.add(i).read_volatile() })
|
println!("0x{:2x}: 0x{:08x}", i, unsafe { pwm.add(i).read_volatile() })
|
||||||
|
|
@ -297,7 +314,16 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
tt.sleep_ms(2).ok();
|
tt.sleep_ms(2).ok();
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
||||||
timer.wo(utra::pwm::REG_CH_EN, 0);
|
timer.wo(utra::pwm::REG_CH_EN, 0);
|
||||||
iox.setup_pin(IoxPort::PA, 0, Some(IoxDir::Input), Some(IoxFunction::Gpio), None, None, None, None);
|
iox.setup_pin(
|
||||||
|
cam_clk.0,
|
||||||
|
cam_clk.1,
|
||||||
|
Some(IoxDir::Input),
|
||||||
|
Some(IoxFunction::Gpio),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
(cam, cam_pdwn)
|
(cam, cam_pdwn)
|
||||||
};
|
};
|
||||||
|
|
@ -373,8 +399,8 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
// power up the camera
|
// power up the camera
|
||||||
// starts MCLK
|
// starts MCLK
|
||||||
iox.setup_pin(
|
iox.setup_pin(
|
||||||
IoxPort::PA,
|
cam_clk.0,
|
||||||
0,
|
cam_clk.1,
|
||||||
Some(IoxDir::Output),
|
Some(IoxDir::Output),
|
||||||
Some(IoxFunction::AF3),
|
Some(IoxFunction::AF3),
|
||||||
None,
|
None,
|
||||||
|
|
@ -480,8 +506,8 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
timer.rmwf(utra::pwm::REG_TIM0_CMD_R_TIMER0_START, 0);
|
||||||
timer.wo(utra::pwm::REG_CH_EN, 0);
|
timer.wo(utra::pwm::REG_CH_EN, 0);
|
||||||
iox.setup_pin(
|
iox.setup_pin(
|
||||||
IoxPort::PA,
|
cam_clk.0,
|
||||||
0,
|
cam_clk.1,
|
||||||
Some(IoxDir::Input),
|
Some(IoxDir::Input),
|
||||||
Some(IoxFunction::Gpio),
|
Some(IoxFunction::Gpio),
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue