Skip to content
Browse files

Test program for SMI

  • Loading branch information...
1 parent c79df4e commit 97745766170b24700a684f8345a325ae81865865 @henkmuller committed Mar 21, 2012
Showing with 59 additions and 0 deletions.
  1. +11 −0 app_smi_test/Makefile
  2. +48 −0 app_smi_test/src/main.xc
View
11 app_smi_test/Makefile
@@ -0,0 +1,11 @@
+TARGET = XK-1
+APP_NAME =
+XCC_FLAGS = -g -O2
+USED_MODULES = module_ethernet_smi
+
+#=============================================================================
+# The following part of the Makefile includes the common build infrastructure
+# for compiling XMOS applications. You should not need to edit below here.
+
+XMOS_MAKE_PATH ?= ../..
+include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
View
48 app_smi_test/src/main.xc
@@ -0,0 +1,48 @@
+// Copyright (c) 2011, XMOS Ltd, All rights reserved
+// This software is freely distributable under a derivative of the
+// University of Illinois/NCSA Open Source License posted in
+// LICENSE.txt and at <http://github.xcore.com/>
+
+
+#include <xs1.h>
+#include <xclib.h>
+#include <stdio.h>
+#include <print.h>
+#include <platform.h>
+#include <stdlib.h>
+#include "smi.h"
+
+#define ETHCORE 0
+
+on stdcore[ETHCORE]: smi_interface_t smi = { 0, XS1_PORT_1M, XS1_PORT_1N };
+
+on stdcore[ETHCORE]: clock clk_smi = XS1_CLKBLK_1;
+
+void smiTest() {
+ timer tmr;
+ int resetTime;
+
+ tmr :> resetTime;
+ resetTime += 50000000;
+ tmr when timerafter(resetTime) :> void;
+
+ smi_port_init(clk_smi, smi);
+ for(int i = 0; i < 32; i++) {
+ int v2, v3, v18;
+ smi.phy_address = i;
+ v2 = smi_reg(smi, 2, 0, 1);
+ v3 = smi_reg(smi, 3, 0, 1);
+ v18 = smi_reg(smi, 18, 0, 1);
+ if ((v2 & v3 & v18) != 0xffff) {
+ printf("Phy addr %02x: reg 2, 3, 18: %04x %04x %04x\n", i, v2, v3, v18);
+ }
+ }
+}
+
+
+int main() {
+ par {
+ on stdcore[ETHCORE]: smiTest();
+ }
+ return 0;
+}

0 comments on commit 9774576

Please sign in to comment.
Something went wrong with that request. Please try again.