Compare commits
No commits in common. "178ab38e35c5819e61f06266f9f72c939c3982d7" and "500472b2a8404f9dc2c2c9f23578cf5194db80ce" have entirely different histories.
178ab38e35
...
500472b2a8
|
@ -223,7 +223,7 @@ pub fn main_core0() {
|
|||
// const CHUNK_SIZE: usize = 65536;
|
||||
// match stream.send((0..=255).cycle().take(CHUNK_SIZE)).await {
|
||||
match stream.send_slice(&tx_data[..]).await {
|
||||
Ok(_len) => stats_tx.borrow_mut().1 += tx_data.len(), //CHUNK_SIZE,
|
||||
Ok(len) => stats_tx.borrow_mut().1 += tx_data.len(), //CHUNK_SIZE,
|
||||
Err(e) => {
|
||||
warn!("tx: {:?}", e);
|
||||
break
|
||||
|
|
|
@ -22,17 +22,6 @@ impl<'a> EEPROM<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "target_kasli_soc")]
|
||||
pub fn new(i2c: &'a mut I2c, page_size: u8) -> Self {
|
||||
EEPROM {
|
||||
i2c: i2c,
|
||||
port: 3,
|
||||
address: 0x57,
|
||||
page_size: page_size,
|
||||
count_down: unsafe { crate::timer::GlobalTimer::get() }.countdown()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "target_zc706")]
|
||||
fn select(&mut self) -> Result<(), &'static str> {
|
||||
let mask: u16 = 1 << self.port;
|
||||
|
@ -40,14 +29,6 @@ impl<'a> EEPROM<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "target_kasli_soc")]
|
||||
fn select(&mut self) -> Result<(), &'static str> {
|
||||
let mask: u16 = 1 << self.port;
|
||||
// tca9548 is compatible with pca9548
|
||||
self.i2c.pca9548_select(0b1110001, mask as u8)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Random read
|
||||
pub fn read<'r>(&mut self, addr: u8, buf: &'r mut [u8]) -> Result<(), &'static str> {
|
||||
self.select()?;
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct I2c {
|
|||
}
|
||||
|
||||
impl I2c {
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
#[cfg(feature = "target_zc706")]
|
||||
pub fn i2c0() -> Self {
|
||||
// Route I2C 0 SCL / SDA Signals to MIO Pins 50 / 51
|
||||
slcr::RegisterBlock::unlocked(|slcr| {
|
||||
|
|
|
@ -20,7 +20,6 @@ use libregister::{
|
|||
//
|
||||
// Current compatibility:
|
||||
// zc706: GPIO 50, 51 == SCL, SDA
|
||||
// kasli_soc: GPIO 50, 51 == SCL, SDA
|
||||
|
||||
pub struct RegisterBlock {
|
||||
pub gpio_output_mask: &'static mut GPIOOutputMask,
|
||||
|
@ -40,66 +39,53 @@ impl RegisterBlock {
|
|||
}
|
||||
}
|
||||
|
||||
register!(gpio_output_mask,
|
||||
/// MASK_DATA_1_MSW:
|
||||
/// Maskable output data for MIO[53:48]
|
||||
GPIOOutputMask, RW, u32);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
// MASK_DATA_1_MSW:
|
||||
// Maskable output data for MIO[53:48]
|
||||
register!(gpio_output_mask, GPIOOutputMask, RW, u32);
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_at!(GPIOOutputMask, 0xE000A00C, new);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_output_mask,
|
||||
/// Output for SCL
|
||||
scl_o, 2);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_output_mask,
|
||||
/// Output for SDA
|
||||
sda_o, 3);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bits!(gpio_output_mask,
|
||||
/// Mask for keeping bits except SCL and SDA unchanged
|
||||
mask, u16, 16, 31);
|
||||
// Output for SCL
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_output_mask, scl_o, 2);
|
||||
// Output for SDA
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_output_mask, sda_o, 3);
|
||||
// Mask for keeping bits except SCL and SDA unchanged
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bits!(gpio_output_mask, mask, u16, 16, 31);
|
||||
|
||||
register!(gpio_input,
|
||||
/// DATA_1_RO:
|
||||
/// Input data for MIO[53:32]
|
||||
GPIOInput, RO, u32);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
// DATA_1_RO:
|
||||
// Input data for MIO[53:32]
|
||||
register!(gpio_input, GPIOInput, RO, u32);
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_at!(GPIOInput, 0xE000A064, new);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_input,
|
||||
/// Input for SCL
|
||||
scl, 18);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_input,
|
||||
/// Input for SDA
|
||||
sda, 19);
|
||||
// Input for SCL
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_input, scl, 18);
|
||||
// Input for SDA
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_input, sda, 19);
|
||||
|
||||
register!(gpio_direction,
|
||||
/// DIRM_1:
|
||||
/// Direction mode for MIO[53:32]; 0/1 = in/out
|
||||
GPIODirection, RW, u32);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
// DIRM_1:
|
||||
// Direction mode for MIO[53:32]; 0/1 = in/out
|
||||
register!(gpio_direction, GPIODirection, RW, u32);
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_at!(GPIODirection, 0xE000A244, new);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_direction,
|
||||
/// Direction for SCL
|
||||
scl, 18);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_direction,
|
||||
/// Direction for SDA
|
||||
sda, 19);
|
||||
// Direction for SCL
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_direction, scl, 18);
|
||||
// Direction for SDA
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_direction, sda, 19);
|
||||
|
||||
register!(gpio_output_enable,
|
||||
/// OEN_1:
|
||||
/// Output enable for MIO[53:32]
|
||||
GPIOOutputEnable, RW, u32);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
// OEN_1:
|
||||
// Output enable for MIO[53:32]
|
||||
register!(gpio_output_enable, GPIOOutputEnable, RW, u32);
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_at!(GPIOOutputEnable, 0xE000A248, new);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_output_enable,
|
||||
/// Output enable for SCL
|
||||
scl, 18);
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
register_bit!(gpio_output_enable,
|
||||
/// Output enable for SDA
|
||||
sda, 19);
|
||||
// Output enable for SCL
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_output_enable, scl, 18);
|
||||
// Output enable for SDA
|
||||
#[cfg(feature = "target_zc706")]
|
||||
register_bit!(gpio_output_enable, sda, 19);
|
||||
|
|
|
@ -19,7 +19,7 @@ pub mod gic;
|
|||
pub mod time;
|
||||
pub mod timer;
|
||||
pub mod sdio;
|
||||
#[cfg(any(feature = "target_zc706", feature = "target_kasli_soc"))]
|
||||
#[cfg(feature = "target_zc706")]
|
||||
pub mod i2c;
|
||||
pub mod logger;
|
||||
pub mod ps7_init;
|
||||
|
|
|
@ -30,9 +30,8 @@ pub trait RegisterRW: RegisterR + RegisterW {
|
|||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! register_common {
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, $access: ty, $inner: ty) => (
|
||||
($mod_name: ident, $struct_name: ident, $access: ty, $inner: ty) => (
|
||||
#[repr(C)]
|
||||
$(#[$outer])*
|
||||
pub struct $struct_name {
|
||||
inner: $access,
|
||||
}
|
||||
|
@ -53,7 +52,7 @@ macro_rules! register_common {
|
|||
#[macro_export]
|
||||
macro_rules! register_r {
|
||||
($mod_name: ident, $struct_name: ident) => (
|
||||
impl $crate::RegisterR for $struct_name {
|
||||
impl libregister::RegisterR for $struct_name {
|
||||
type R = $mod_name::Read;
|
||||
|
||||
#[inline]
|
||||
|
@ -68,7 +67,7 @@ macro_rules! register_r {
|
|||
#[macro_export]
|
||||
macro_rules! register_w {
|
||||
($mod_name: ident, $struct_name: ident) => (
|
||||
impl $crate::RegisterW for $struct_name {
|
||||
impl libregister::RegisterW for $struct_name {
|
||||
type W = $mod_name::Write;
|
||||
|
||||
#[inline]
|
||||
|
@ -89,7 +88,7 @@ macro_rules! register_w {
|
|||
#[macro_export]
|
||||
macro_rules! register_rw {
|
||||
($mod_name: ident, $struct_name: ident) => (
|
||||
impl $crate::RegisterRW for $struct_name {
|
||||
impl libregister::RegisterRW for $struct_name {
|
||||
#[inline]
|
||||
fn modify<F: FnOnce(Self::R, Self::W) -> Self::W>(&mut self, f: F) {
|
||||
unsafe {
|
||||
|
@ -102,7 +101,7 @@ macro_rules! register_rw {
|
|||
}
|
||||
);
|
||||
($mod_name: ident, $struct_name: ident, $mask: expr) => (
|
||||
impl $crate::RegisterRW for $struct_name {
|
||||
impl libregister::RegisterRW for $struct_name {
|
||||
#[inline]
|
||||
fn modify<F: FnOnce(Self::R, Self::W) -> Self::W>(&mut self, f: F) {
|
||||
unsafe {
|
||||
|
@ -120,7 +119,7 @@ macro_rules! register_rw {
|
|||
#[macro_export]
|
||||
macro_rules! register_vcell {
|
||||
($mod_name: ident, $struct_name: ident) => (
|
||||
impl $crate::RegisterR for $struct_name {
|
||||
impl libregister::RegisterR for $struct_name {
|
||||
type R = $mod_name::Read;
|
||||
|
||||
#[inline]
|
||||
|
@ -129,7 +128,7 @@ macro_rules! register_vcell {
|
|||
$mod_name::Read { inner }
|
||||
}
|
||||
}
|
||||
impl $crate::RegisterW for $struct_name {
|
||||
impl libregister::RegisterW for $struct_name {
|
||||
type W = $mod_name::Write;
|
||||
|
||||
#[inline]
|
||||
|
@ -142,7 +141,7 @@ macro_rules! register_vcell {
|
|||
self.inner.set(w.inner);
|
||||
}
|
||||
}
|
||||
impl $crate::RegisterRW for $struct_name {
|
||||
impl libregister::RegisterRW for $struct_name {
|
||||
#[inline]
|
||||
fn modify<F: FnOnce(Self::R, Self::W) -> Self::W>(&mut self, f: F) {
|
||||
let r = self.read();
|
||||
|
@ -158,37 +157,37 @@ macro_rules! register_vcell {
|
|||
#[macro_export]
|
||||
macro_rules! register {
|
||||
// Define read-only register
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, RO, $inner: ty) => (
|
||||
$crate::register_common!($mod_name, $(#[$outer])* $struct_name, $crate::RO<$inner>, $inner);
|
||||
$crate::register_r!($mod_name, $struct_name);
|
||||
($mod_name: ident, $struct_name: ident, RO, $inner: ty) => (
|
||||
libregister::register_common!($mod_name, $struct_name, libregister::RO<$inner>, $inner);
|
||||
libregister::register_r!($mod_name, $struct_name);
|
||||
);
|
||||
|
||||
// Define write-only register
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, WO, $inner: ty) => (
|
||||
$crate::register_common!($mod_name, $(#[$outer])* $struct_name, volatile_register::WO<$inner>, $inner);
|
||||
$crate::register_w!($mod_name, $struct_name);
|
||||
($mod_name: ident, $struct_name: ident, WO, $inner: ty) => (
|
||||
libregister::register_common!($mod_name, $struct_name, volatile_register::WO<$inner>, $inner);
|
||||
libregister::register_w!($mod_name, $struct_name);
|
||||
);
|
||||
|
||||
// Define read-write register
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, RW, $inner: ty) => (
|
||||
$crate::register_common!($mod_name, $(#[$outer])* $struct_name, volatile_register::RW<$inner>, $inner);
|
||||
$crate::register_r!($mod_name, $struct_name);
|
||||
$crate::register_w!($mod_name, $struct_name);
|
||||
$crate::register_rw!($mod_name, $struct_name);
|
||||
($mod_name: ident, $struct_name: ident, RW, $inner: ty) => (
|
||||
libregister::register_common!($mod_name, $struct_name, volatile_register::RW<$inner>, $inner);
|
||||
libregister::register_r!($mod_name, $struct_name);
|
||||
libregister::register_w!($mod_name, $struct_name);
|
||||
libregister::register_rw!($mod_name, $struct_name);
|
||||
);
|
||||
|
||||
// Define read-write register
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, VolatileCell, $inner: ty) => (
|
||||
$crate::register_common!($mod_name, $(#[$outer])* $struct_name, VolatileCell<$inner>, $inner);
|
||||
$crate::register_vcell!($mod_name, $struct_name);
|
||||
($mod_name: ident, $struct_name: ident, VolatileCell, $inner: ty) => (
|
||||
libregister::register_common!($mod_name, $struct_name, VolatileCell<$inner>, $inner);
|
||||
libregister::register_vcell!($mod_name, $struct_name);
|
||||
);
|
||||
|
||||
// Define read-write register with mask on write (for WTC mixed access.)
|
||||
($mod_name: ident, $(#[$outer:meta])* $struct_name: ident, RW, $inner: ty, $mask: expr) => (
|
||||
$crate::register_common!($mod_name, $(#[$outer])* $struct_name, volatile_register::RW<$inner>, $inner);
|
||||
$crate::register_r!($mod_name, $struct_name);
|
||||
$crate::register_w!($mod_name, $struct_name);
|
||||
$crate::register_rw!($mod_name, $struct_name, $mask);
|
||||
($mod_name: ident, $struct_name: ident, RW, $inner: ty, $mask: expr) => (
|
||||
libregister::register_common!($mod_name, $struct_name, volatile_register::RW<$inner>, $inner);
|
||||
libregister::register_r!($mod_name, $struct_name);
|
||||
libregister::register_w!($mod_name, $struct_name);
|
||||
libregister::register_rw!($mod_name, $struct_name, $mask);
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue