From 412308b39d8414dc7d97a31b09e0bc8c2b0334a5 Mon Sep 17 00:00:00 2001 From: occheung Date: Fri, 11 Sep 2020 17:36:41 +0800 Subject: [PATCH] tcp_client: minor change --- examples/tcp_client.rs | 35 ++++++++++++++++++++++++++--------- examples/util/logger.rs | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/examples/tcp_client.rs b/examples/tcp_client.rs index adce952..0666f11 100644 --- a/examples/tcp_client.rs +++ b/examples/tcp_client.rs @@ -37,6 +37,7 @@ use rtic::cyccnt::{Instant, U32Ext}; use log::info; use log::debug; use log::trace; +use log::warn; use nb::block; @@ -113,7 +114,7 @@ fn main() -> ! { let mut green_led = gpiob.pb0.into_push_pull_output(); green_led.set_low().unwrap(); - gpiob.pb3.into_alternate_af0().set_speed(Speed::VeryHigh); + // gpiob.pb3.into_alternate_af0().set_speed(Speed::VeryHigh); logger::init(); @@ -148,11 +149,11 @@ fn main() -> ! { let mut neighbor_cache_entries = [None; 8]; let mut neighbor_cache = net::iface::NeighborCache::new(&mut neighbor_cache_entries[..]); - // neighbor_cache.fill( - // net::wire::IpAddress::v4(192, 168, 1, 125), - // net::wire::EthernetAddress([0x2C, 0xF0, 0x5D, 0x26, 0xB8, 0x2F]), - // clock.elapsed(), - // ); + neighbor_cache.fill( + net::wire::IpAddress::v4(192, 168, 1, 125), + net::wire::EthernetAddress([0x2C, 0xF0, 0x5D, 0x26, 0xB8, 0x2F]), + clock.elapsed(), + ); let mut net_interface = net::iface::EthernetInterfaceBuilder::new(eth_dma) .ethernet_addr(mac_addr) @@ -231,6 +232,11 @@ fn main() -> ! { red_led.set_high().unwrap(); let mut green = true; + // let mut eth_status = 0; + // unsafe { + // eth_status = (*pac::ETHERNET_MAC::ptr()).macdr.read().bits(); + // debug!("eth_status: {:X}", eth_status); + // } loop { // let timestamp = net::time::Instant::from_millis(TIME.load(Ordering::Relaxed) as i64); @@ -241,6 +247,17 @@ fn main() -> ! { } } + // unsafe { + // // let p = &DES_RING as *const _; + // // let tdeses = core::ptr::read_volatile(p as *const [u32; 16]); + // // debug!("{:X?}", core::ptr::read_volatile(tdeses[0] as *const [u32; 20])) + // let new_eth_status = (*pac::ETHERNET_MAC::ptr()).macdr.read().bits(); + // if new_eth_status != eth_status { + // eth_status = new_eth_status; + // debug!("eth_status: {:X}", eth_status); + // } + // } + { let mut socket = sockets.get::(handle); @@ -267,9 +284,9 @@ fn main() -> ! { continue; } Some(time_delay) => { - // green_led.set_low().unwrap(); - // delay.delay_ms(time_delay.total_millis() as u32); - // green_led.set_high().unwrap(); + green_led.set_low().unwrap(); + delay.delay_ms(time_delay.total_millis() as u32); + green_led.set_high().unwrap(); clock.advance(time_delay) }, None => { diff --git a/examples/util/logger.rs b/examples/util/logger.rs index 356b4de..c6ab530 100644 --- a/examples/util/logger.rs +++ b/examples/util/logger.rs @@ -26,7 +26,7 @@ pub unsafe fn enable_itm( *(0x5c00_4fb0 as *mut u32) = 0xC5ACCE55; // SWO CODR Register: Set SWO speed - *(0x5c00_3010 as *mut _) = 199; + *(0x5c00_3010 as *mut _) = 200; // SWO SPPR Register: // 1 = Manchester