Compare commits
9 Commits
master
...
213-backpo
Author | SHA1 | Date |
---|---|---|
Egor Savkin | 33097f26d5 | |
Egor Savkin | 709aa8195b | |
Sebastien Bourdeauducq | 733f270819 | |
Sebastien Bourdeauducq | d30fb96674 | |
mwojcik | facc5808ef | |
mwojcik | 6f74cff4c5 | |
Sebastien Bourdeauducq | 3ea2690f15 | |
Sebastien Bourdeauducq | e02b8e25fe | |
Sebastien Bourdeauducq | 561efb0466 |
|
@ -4,7 +4,7 @@ ARTIQ on Zynq
|
||||||
How to use
|
How to use
|
||||||
----------
|
----------
|
||||||
|
|
||||||
1. Install ARTIQ-6 or newer.
|
1. Install ARTIQ-7 or newer.
|
||||||
2. Select the latest successful build on Hydra: https://nixbld.m-labs.hk/jobset/artiq/zynq
|
2. Select the latest successful build on Hydra: https://nixbld.m-labs.hk/jobset/artiq/zynq
|
||||||
3. Search for the job named ``<board>-<variant>-sd`` (for example: ``zc706-nist_clock-sd`` or ``zc706-nist_qc2-sd``).
|
3. Search for the job named ``<board>-<variant>-sd`` (for example: ``zc706-nist_clock-sd`` or ``zc706-nist_qc2-sd``).
|
||||||
4. Download the ``boot.bin`` "binary distribution" and place it at the root of a FAT-formatted SD card.
|
4. Download the ``boot.bin`` "binary distribution" and place it at the root of a FAT-formatted SD card.
|
||||||
|
@ -33,7 +33,7 @@ not implemented as it seems not very useful.
|
||||||
Development instructions
|
Development instructions
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
ARTIQ on Zynq is packaged using the [Nix](https://nixos.org) Flakes system. Install Nix 2.4+ and enable flakes by adding ``experimental-features = nix-command flakes`` to ``nix.conf`` (e.g. ``~/.config/nix/nix.conf``).
|
ARTIQ on Zynq is packaged using the [Nix](https://nixos.org) Flakes system. Install Nix 2.8+ and enable flakes by adding ``experimental-features = nix-command flakes`` to ``nix.conf`` (e.g. ``~/.config/nix/nix.conf``).
|
||||||
|
|
||||||
Pure build with Nix and execution on a remote JTAG server:
|
Pure build with Nix and execution on a remote JTAG server:
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ device_db = {
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"host": "192.168.1.52",
|
"host": "192.168.1.52",
|
||||||
"ref_period": 1e-9,
|
"ref_period": 1e-9,
|
||||||
"ref_multiplier": 1,
|
"ref_multiplier": 8,
|
||||||
"target": "cortexa9"
|
"target": "cortexa9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
79
flake.lock
79
flake.lock
|
@ -11,21 +11,23 @@
|
||||||
"src-pythonparser": "src-pythonparser"
|
"src-pythonparser": "src-pythonparser"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654087576,
|
"lastModified": 1666210907,
|
||||||
"narHash": "sha256-d+LCvCXikhhEjsf4qBZakx3Sda85p+4vVZVwE1YuS90=",
|
"narHash": "sha256-q0ehAZ608F0evqDeq2/OQyqQkRoqNAy7Ioo7d9yjtRQ=",
|
||||||
"ref": "master",
|
"ref": "release-7",
|
||||||
"rev": "68ef0073ea66fe9c7f7c178979ecb8c681c47caa",
|
"rev": "ab8bb9ef31390ed9feb39c82211f6887924bcde3",
|
||||||
"revCount": 8068,
|
"revCount": 8131,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/m-labs/artiq.git"
|
"url": "https://github.com/m-labs/artiq.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
"ref": "release-7",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/m-labs/artiq.git"
|
"url": "https://github.com/m-labs/artiq.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"artiq-comtools": {
|
"artiq-comtools": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"artiq",
|
"artiq",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
|
@ -36,11 +38,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654007592,
|
"lastModified": 1664405593,
|
||||||
"narHash": "sha256-vaDFhE1ItjqtIcinC/6RAJGbj44pxxMUEeQUa3FtgEE=",
|
"narHash": "sha256-yP441NerlLGig7n+9xHsx8yCtZ+Ggd0VqfBSzc20E04=",
|
||||||
"owner": "m-labs",
|
"owner": "m-labs",
|
||||||
"repo": "artiq-comtools",
|
"repo": "artiq-comtools",
|
||||||
"rev": "cb73281154656ee8f74db1866859e31bf42755cd",
|
"rev": "15ddac62813ef623a076ccf982b3bc63d314e651",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -49,14 +51,29 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"mozilla-overlay": {
|
"mozilla-overlay": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650459918,
|
"lastModified": 1664789696,
|
||||||
"narHash": "sha256-sroCK+QJTmoXtcRkwZyKOP9iAYOPID2Bwdxn4GkG16w=",
|
"narHash": "sha256-UGWJHQShiwLCr4/DysMVFrYdYYHcOqAOVsWNUu+l6YU=",
|
||||||
"owner": "mozilla",
|
"owner": "mozilla",
|
||||||
"repo": "nixpkgs-mozilla",
|
"repo": "nixpkgs-mozilla",
|
||||||
"rev": "e1f7540fc0a8b989fb8cf701dc4fd7fc76bcf168",
|
"rev": "80627b282705101e7b38e19ca6e8df105031b072",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -68,11 +85,11 @@
|
||||||
"mozilla-overlay_2": {
|
"mozilla-overlay_2": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650459918,
|
"lastModified": 1664789696,
|
||||||
"narHash": "sha256-sroCK+QJTmoXtcRkwZyKOP9iAYOPID2Bwdxn4GkG16w=",
|
"narHash": "sha256-UGWJHQShiwLCr4/DysMVFrYdYYHcOqAOVsWNUu+l6YU=",
|
||||||
"owner": "mozilla",
|
"owner": "mozilla",
|
||||||
"repo": "nixpkgs-mozilla",
|
"repo": "nixpkgs-mozilla",
|
||||||
"rev": "e1f7540fc0a8b989fb8cf701dc4fd7fc76bcf168",
|
"rev": "80627b282705101e7b38e19ca6e8df105031b072",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -99,11 +116,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1653920503,
|
"lastModified": 1666056570,
|
||||||
"narHash": "sha256-BBeCZwZImtjP3oYy4WogkQYy5OxNyfNciVSc1AfZgLQ=",
|
"narHash": "sha256-e7EkIY68Tp7NKyp9JSHh6CgPPdsKYYWxiL4wZQN8Cwg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "a634c8f6c1fbf9b9730e01764999666f3436f10a",
|
"rev": "47edaa313fc3767ce3026037a5b62352f22f3602",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -128,11 +145,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654006751,
|
"lastModified": 1664319253,
|
||||||
"narHash": "sha256-OWAnoTCutvTQcYdtdtLQuL6uRtG+7Jz7sbRhcScv8bo=",
|
"narHash": "sha256-hycJAgy+NFF9f5I6++7yo8KdhMSyKCPKJazRPxeedI4=",
|
||||||
"owner": "m-labs",
|
"owner": "m-labs",
|
||||||
"repo": "sipyco",
|
"repo": "sipyco",
|
||||||
"rev": "b3d03a94c751a24769c54a61a0dbe9d6af52dade",
|
"rev": "d58ded7280e0f020be2446d4fee70f4393e6045f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -144,11 +161,11 @@
|
||||||
"src-migen": {
|
"src-migen": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650337393,
|
"lastModified": 1662111470,
|
||||||
"narHash": "sha256-rm1SlFmF2ASz0vIy2nDEzGlyRw2oYNeJRr8Kh8Mg2Qc=",
|
"narHash": "sha256-IPyhoFZLhY8d3jHB8jyvGdbey7V+X5eCzBZYSrJ18ec=",
|
||||||
"owner": "m-labs",
|
"owner": "m-labs",
|
||||||
"repo": "migen",
|
"repo": "migen",
|
||||||
"rev": "d4e3f34177c32f09904397179e6ed9c83175e528",
|
"rev": "639e66f4f453438e83d86dc13491b9403bbd8ec6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -160,11 +177,11 @@
|
||||||
"src-misoc": {
|
"src-misoc": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1649324486,
|
"lastModified": 1665395741,
|
||||||
"narHash": "sha256-Mw/fQS3lHFvCm7L1k63joRkz5uyijQfywcOq+X2+o2s=",
|
"narHash": "sha256-7ULMGBPPn5NxZX6rdxU5GheoSNBiJklHQEVf04jU9tI=",
|
||||||
"ref": "master",
|
"ref": "master",
|
||||||
"rev": "f1dc58d2b8c222ba41c25cee4301626625f46e43",
|
"rev": "4fb0730db4c5de7e86f82fa3bd204e6c4608af85",
|
||||||
"revCount": 2420,
|
"revCount": 2427,
|
||||||
"submodules": true,
|
"submodules": true,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/m-labs/misoc.git"
|
"url": "https://github.com/m-labs/misoc.git"
|
||||||
|
@ -200,11 +217,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654002148,
|
"lastModified": 1665118676,
|
||||||
"narHash": "sha256-Ztzx7ze8o0gdu+sDpc+PS2M88h/b22rwFq0b12wMqZQ=",
|
"narHash": "sha256-9hX80tRMFNehL7jSUrlctKMe7k8Br14O93gr9P5Zl7w=",
|
||||||
"ref": "master",
|
"ref": "master",
|
||||||
"rev": "6cd32f6ee0e7bb7ce5a279f8be943903a393a476",
|
"rev": "0a3a7776520fa0359fe7dbf40146b9bd22bbc0f8",
|
||||||
"revCount": 617,
|
"revCount": 622,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
|
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
description = "ARTIQ port to the Zynq-7000 platform";
|
description = "ARTIQ port to the Zynq-7000 platform";
|
||||||
|
|
||||||
inputs.artiq.url = git+https://github.com/m-labs/artiq.git;
|
inputs.artiq.url = git+https://github.com/m-labs/artiq.git?ref=release-7;
|
||||||
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
|
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
|
||||||
inputs.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs;
|
inputs.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs;
|
||||||
inputs.zynq-rs.inputs.nixpkgs.follows = "artiq/nixpkgs";
|
inputs.zynq-rs.inputs.nixpkgs.follows = "artiq/nixpkgs";
|
||||||
|
|
|
@ -118,7 +118,7 @@ class GenericStandalone(SoCCore):
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
])
|
])
|
||||||
ident = self.__class__.__name__
|
ident = description["variant"]
|
||||||
if self.acpki:
|
if self.acpki:
|
||||||
ident = "acpki_" + ident
|
ident = "acpki_" + ident
|
||||||
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
||||||
|
@ -204,7 +204,7 @@ class GenericMaster(SoCCore):
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
])
|
])
|
||||||
ident = self.__class__.__name__
|
ident = description["variant"]
|
||||||
if self.acpki:
|
if self.acpki:
|
||||||
ident = "acpki_" + ident
|
ident = "acpki_" + ident
|
||||||
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
||||||
|
@ -329,7 +329,7 @@ class GenericSatellite(SoCCore):
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
])
|
])
|
||||||
ident = self.__class__.__name__
|
ident = description["variant"]
|
||||||
if self.acpki:
|
if self.acpki:
|
||||||
ident = "acpki_" + ident
|
ident = "acpki_" + ident
|
||||||
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident)
|
||||||
|
|
|
@ -427,8 +427,8 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
|
||||||
moninj::start(timer, aux_mutex, drtio_routing_table);
|
moninj::start(timer, aux_mutex, drtio_routing_table);
|
||||||
|
|
||||||
let control: Rc<RefCell<kernel::Control>> = Rc::new(RefCell::new(kernel::Control::start()));
|
let control: Rc<RefCell<kernel::Control>> = Rc::new(RefCell::new(kernel::Control::start()));
|
||||||
let idle_kernel = Rc::new(cfg.read("idle").ok());
|
let idle_kernel = Rc::new(cfg.read("idle_kernel").ok());
|
||||||
if let Ok(buffer) = cfg.read("startup") {
|
if let Ok(buffer) = cfg.read("startup_kernel") {
|
||||||
info!("Loading startup kernel...");
|
info!("Loading startup kernel...");
|
||||||
if let Ok(()) = task::block_on(load_kernel(&buffer, &control, None)) {
|
if let Ok(()) = task::block_on(load_kernel(&buffer, &control, None)) {
|
||||||
info!("Starting startup kernel...");
|
info!("Starting startup kernel...");
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
use crate::i2c;
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
// Only the bare minimum registers. Bits/IO connections equivalent between IC types.
|
||||||
|
struct Registers {
|
||||||
|
// PCA9539 equivalent register names in comments
|
||||||
|
iodira: u8, // Configuration Port 0
|
||||||
|
iodirb: u8, // Configuration Port 1
|
||||||
|
gpioa: u8, // Output Port 0
|
||||||
|
gpiob: u8, // Output Port 1
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct IoExpander {
|
||||||
|
busno: i32,
|
||||||
|
port: u8,
|
||||||
|
address: i32,
|
||||||
|
iodir: [u8; 2],
|
||||||
|
out_current: [u8; 2],
|
||||||
|
out_target: [u8; 2],
|
||||||
|
registers: Registers,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl IoExpander {
|
||||||
|
pub fn new(index: u8) -> Result<Self, &'static str> {
|
||||||
|
|
||||||
|
// Both expanders on SHARED I2C bus
|
||||||
|
let mut io_expander = match index {
|
||||||
|
0 => IoExpander {
|
||||||
|
busno: 0,
|
||||||
|
port: 11,
|
||||||
|
address: 0x40,
|
||||||
|
iodir: [0xff; 2],
|
||||||
|
out_current: [0; 2],
|
||||||
|
out_target: [0; 2],
|
||||||
|
registers: Registers {
|
||||||
|
iodira: 0x00,
|
||||||
|
iodirb: 0x01,
|
||||||
|
gpioa: 0x12,
|
||||||
|
gpiob: 0x13,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
1 => IoExpander {
|
||||||
|
busno: 0,
|
||||||
|
port: 11,
|
||||||
|
address: 0x42,
|
||||||
|
iodir: [0xff; 2],
|
||||||
|
out_current: [0; 2],
|
||||||
|
out_target: [0; 2],
|
||||||
|
registers: Registers {
|
||||||
|
iodira: 0x00,
|
||||||
|
iodirb: 0x01,
|
||||||
|
gpioa: 0x12,
|
||||||
|
gpiob: 0x13,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
_ => return Err("incorrect I/O expander index"),
|
||||||
|
};
|
||||||
|
if !io_expander.check_ack()? {
|
||||||
|
info!(
|
||||||
|
"MCP23017 io expander {} not found. Checking for PCA9539.",
|
||||||
|
index
|
||||||
|
);
|
||||||
|
io_expander.address += 0xa8; // translate to PCA9539 addresses (see schematic)
|
||||||
|
io_expander.registers = Registers {
|
||||||
|
iodira: 0x06,
|
||||||
|
iodirb: 0x07,
|
||||||
|
gpioa: 0x02,
|
||||||
|
gpiob: 0x03,
|
||||||
|
};
|
||||||
|
if !io_expander.check_ack()? {
|
||||||
|
return Err("Neither MCP23017 nor PCA9539 io expander found.");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Ok(io_expander)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn select(&self) -> Result<(), &'static str> {
|
||||||
|
let mask: u16 = 1 << self.port;
|
||||||
|
i2c::switch_select(self.busno, 0x70, mask as u8 as i32);
|
||||||
|
i2c::switch_select(self.busno, 0x71, (mask >> 8) as u8 as i32);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write(&self, addr: u8, value: u8) -> Result<(), &'static str> {
|
||||||
|
i2c::start(self.busno);
|
||||||
|
i2c::write(self.busno, self.address as i32);
|
||||||
|
i2c::write(self.busno, addr as i32);
|
||||||
|
i2c::write(self.busno, value as i32);
|
||||||
|
i2c::stop(self.busno);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_ack(&self) -> Result<bool, &'static str> {
|
||||||
|
// Check for ack from io expander
|
||||||
|
self.select()?;
|
||||||
|
i2c::start(self.busno);
|
||||||
|
let ack = i2c::write(self.busno, self.address);
|
||||||
|
i2c::stop(self.busno);
|
||||||
|
Ok(ack)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_iodir(&self) -> Result<(), &'static str> {
|
||||||
|
self.write(self.registers.iodira, self.iodir[0])?;
|
||||||
|
self.write(self.registers.iodirb, self.iodir[1])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init(&mut self) -> Result<(), &'static str> {
|
||||||
|
self.select()?;
|
||||||
|
self.update_iodir()?;
|
||||||
|
|
||||||
|
self.out_current[0] = 0x00;
|
||||||
|
self.write(self.registers.gpioa, 0x00)?;
|
||||||
|
self.out_current[1] = 0x00;
|
||||||
|
self.write(self.registers.gpiob, 0x00)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_oe(&mut self, port: u8, outputs: u8) -> Result<(), &'static str> {
|
||||||
|
self.iodir[port as usize] &= !outputs;
|
||||||
|
self.update_iodir()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set(&mut self, port: u8, bit: u8, high: bool) {
|
||||||
|
if high {
|
||||||
|
self.out_target[port as usize] |= 1 << bit;
|
||||||
|
} else {
|
||||||
|
self.out_target[port as usize] &= !(1 << bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn service(&mut self) -> Result<(), &'static str> {
|
||||||
|
if self.out_target != self.out_current {
|
||||||
|
self.select()?;
|
||||||
|
if self.out_target[0] != self.out_current[0] {
|
||||||
|
self.write(self.registers.gpioa, self.out_target[0])?;
|
||||||
|
self.out_current[0] = self.out_target[0];
|
||||||
|
}
|
||||||
|
if self.out_target[1] != self.out_current[1] {
|
||||||
|
self.write(self.registers.gpiob, self.out_target[1])?;
|
||||||
|
self.out_current[1] = self.out_target[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,6 +45,8 @@ mod mgmt;
|
||||||
mod analyzer;
|
mod analyzer;
|
||||||
mod irq;
|
mod irq;
|
||||||
mod i2c;
|
mod i2c;
|
||||||
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
|
mod io_expander;
|
||||||
|
|
||||||
static mut SEEN_ASYNC_ERRORS: u8 = 0;
|
static mut SEEN_ASYNC_ERRORS: u8 = 0;
|
||||||
|
|
||||||
|
@ -109,10 +111,29 @@ pub fn main_core0() {
|
||||||
gic::InterruptController::gic(mpcore::RegisterBlock::mpcore()).enable_interrupts();
|
gic::InterruptController::gic(mpcore::RegisterBlock::mpcore()).enable_interrupts();
|
||||||
|
|
||||||
init_gateware();
|
init_gateware();
|
||||||
info!("detected gateware: {}", identifier_read(&mut [0; 64]));
|
info!("gateware ident: {}", identifier_read(&mut [0; 64]));
|
||||||
|
|
||||||
i2c::init();
|
i2c::init();
|
||||||
|
|
||||||
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
|
{
|
||||||
|
let (mut io_expander0, mut io_expander1) = (io_expander::IoExpander::new(0).unwrap(), io_expander::IoExpander::new(1).unwrap());
|
||||||
|
io_expander0.init().expect("I2C I/O expander #0 initialization failed");
|
||||||
|
io_expander1.init().expect("I2C I/O expander #1 initialization failed");
|
||||||
|
|
||||||
|
// Actively drive TX_DISABLE to false on SFP0..3
|
||||||
|
io_expander0.set_oe(0, 1 << 1).unwrap();
|
||||||
|
io_expander0.set_oe(1, 1 << 1).unwrap();
|
||||||
|
io_expander1.set_oe(0, 1 << 1).unwrap();
|
||||||
|
io_expander1.set_oe(1, 1 << 1).unwrap();
|
||||||
|
io_expander0.set(0, 1, false);
|
||||||
|
io_expander0.set(1, 1, false);
|
||||||
|
io_expander1.set(0, 1, false);
|
||||||
|
io_expander1.set(1, 1, false);
|
||||||
|
io_expander0.service().unwrap();
|
||||||
|
io_expander1.service().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let cfg = match Config::new() {
|
let cfg = match Config::new() {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Reference in New Issue