Skip to content

Commit

Permalink
p2 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronRP committed Sep 4, 2023
1 parent cbf19f6 commit a070ad6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ name = "tc2-agent"
maintainer = "Cacophony Developers <[email protected]>"
depends = ""
assets = [
["target/release/tc2-agent", "/usr/bin/", "755"], # Binary asset
["target/release/tc2-agent", "/usr/bin/", "755"],
["_releases/tc2-agent.service", "/etc/systemd/system/tc2-agent.service", "664"],
["_releases/rp2040-firmware.elf", "/etc/cacophony/rp2040-firmware.elf", "664"],
]
maintainer-scripts = "_releases/scripts"
Binary file added _releases/rp2040-firmware.elf
Binary file not shown.
9 changes: 7 additions & 2 deletions _releases/scripts/postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
systemctl daemon-reload
systemctl enable tc2-agent.service
systemctl restart tc2-agent.service
systemctl stop tc2-agent.service

## Program RP2040 firmware
#openocd -f /etc/cacophony/raspberrypi-swd.cfg -f /target/rp2040.cfg -c /etc/cacophony/rp2040.elf
tc2-hat-rp2040 --elf /etc/cacophony/rp2040-firmware.elf

systemctl start tc2-agent.service
2 changes: 1 addition & 1 deletion _releases/tc2-agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/tc2-agent
Restart=on-failure
Restart=always
RestartSec=5s

# Give real-time priority
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ fn main() {
let mut raw_read_buffer = [0u8; 1024 * 1024];

//let spi_speed = 30_000_000; // rPi4 can handle this in PIO mode
let spi_speed = config.spi_speed * 1_000_000; // rPi3 can handle 12Mhz (@600Mhz), may need to back it off a little to have some slack.
//let spi_speed = config.spi_speed * 1_000_000; // rPi3 can handle 12Mhz (@600Mhz), may need to back it off a little to have some slack.
let spi_speed = 8_000_000;
println!("Initialising SPI at {}Mhz", config.spi_speed);
let mut spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, spi_speed, Mode::Mode2).unwrap();
spi.set_bits_per_word(8).unwrap();
Expand Down

0 comments on commit a070ad6

Please sign in to comment.