]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - rtems/gw/cangw/helpers.c
Changed all (I think) files using CRLF to use LF.
[can-benchmark.git] / rtems / gw / cangw / helpers.c
index d994a554ab904434729392b8f58b265933f203d8..f1289513aed207331f431a89a1bf4a0793e467f0 100644 (file)
-#include <system_def.h>\r
-#include <unistd.h>\r
-#include <fcntl.h>\r
-#include <stdio.h>\r
-#include <errno.h>\r
-#include <stdlib.h>\r
-#include <rtems/error.h>\r
-#include <rtems/monitor.h>\r
-#include <rtems/shell.h>\r
-\r
-#include <bsp/mscan.h>\r
-#include <bsp/mscan-base.h>\r
-\r
-#include "helpers.h"\r
-#include "gw.h"\r
-#include "load.h"\r
-\r
-#include <rtems/rtems_bsdnet.h>\r
-#include "networkconfig.h" \r
-\r
-\r
-static rtems_device_major_number mscan_major;\r
-static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY;\r
-\r
-/*\r
-* Prints can stats. (Used in debugging)\r
-*/\r
-int print_can_totals(int argc, char** argv){\r
-    printf("Total 1: %"PRIu32", Total 2: %"PRIu32"\n", total_1, total_2);\r
-    printf("Success 1: %"PRIu32", Success 2: %"PRIu32"\n", succ_1, succ_2);\r
-    printf("Errors 1: %"PRIu32", Errors 2: %"PRIu32"\n", err_1, err_2);\r
-    return 0;\r
-}\r
-\r
-/*\r
-* Prints clocks as given by the uboot. (Used in debugging)\r
-*/\r
-int print_clocks(int argc, char** argv){\r
-    printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq);\r
-    printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq);\r
-    printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq);\r
-    printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate);\r
-    return 0;\r
-}\r
-\r
-/*\r
-* Single function to prepare CAN devices for read/write operation.\r
-*\r
-* Sets up baud rate at 1M, opens fda and fdb and checks for errors.\r
-*/\r
-static int init_CAN(){\r
-    rtems_status_code status;\r
-    \r
-    printf("Initializing CAN bus.\n");\r
-    \r
-    printf("Changing gpiopcr setting...\n");    \r
-    //Clear PCR_CHIP_SELECT bits and sets them to ALT_CAN.\r
-    mpc5200.gpiopcr = (mpc5200.gpiopcr & (~GPIO_PCR_CHIP_SELECT_1)) | GPIO_PCR_CHIP_ALTS_CAN;\r
-\r
-    printf("Registering CAN drivers...\n");\r
-    status = rtems_io_register_driver(0, &mscan_driver_table, &mscan_major);\r
-    if (status != RTEMS_SUCCESSFUL){\r
-        printf("caninit: rtems_io_register_driver %s\n",rtems_status_text(status));\r
-        return 1;\r
-    }\r
-    \r
-    return 0;\r
-}\r
-\r
-int start_can(int argc, char** argv){\r
-    int res;\r
-    static char inited = 0;\r
-    if (!inited){\r
-        res = init_CAN();\r
-        inited = 1;\r
-        if (res != 0){\r
-            //TODO\r
-            printf("Error while initializing CAN\n");\r
-            return res;\r
-        }\r
-        printf("CAN inited\n");\r
-    }\r
-    res = start_GW();\r
-    return 0;\r
-}\r
-\r
-int end_can(int argc, char** argv){\r
-    return end_GW();\r
-}\r
-\r
-int show_net(int argc, char** argv){\r
-    rtems_bsdnet_show_if_stats();\r
-    rtems_bsdnet_show_ip_stats();\r
-    rtems_bsdnet_show_icmp_stats();\r
-    rtems_bsdnet_show_mbuf_stats();\r
-    rtems_bsdnet_show_inet_routes();\r
-    return 0;\r
-}\r
-\r
-int start_net(int argc, char** argv){\r
-    int res;\r
-    printf("Initializing Network\n");\r
-    res = rtems_bsdnet_initialize_network ();\r
-    if (res < 0){\r
-        printf("Error while initializing network: %d    %s\n", errno, strerror(errno));\r
-        return 1;\r
-    }\r
-    printf("Success\n");\r
-    printf("Found routes.\n");\r
-    rtems_bsdnet_show_inet_routes (); \r
-    return 0;\r
-}\r
-\r
-int start_load(int argc, char** argv){\r
-    return start_thread_load();\r
-}\r
-\r
-int stop_load(int argc, char** argv){\r
-    return end_thread_load();\r
-}\r
+#include <system_def.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <rtems/error.h>
+#include <rtems/monitor.h>
+#include <rtems/shell.h>
+
+#include <bsp/mscan.h>
+#include <bsp/mscan-base.h>
+
+#include "helpers.h"
+#include "gw.h"
+#include "load.h"
+
+#include <rtems/rtems_bsdnet.h>
+#include "networkconfig.h" 
+
+
+static rtems_device_major_number mscan_major;
+static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY;
+
+/*
+* Prints can stats. (Used in debugging)
+*/
+int print_can_totals(int argc, char** argv){
+    printf("Total 1: %"PRIu32", Total 2: %"PRIu32"\n", total_1, total_2);
+    printf("Success 1: %"PRIu32", Success 2: %"PRIu32"\n", succ_1, succ_2);
+    printf("Errors 1: %"PRIu32", Errors 2: %"PRIu32"\n", err_1, err_2);
+    return 0;
+}
+
+/*
+* Prints clocks as given by the uboot. (Used in debugging)
+*/
+int print_clocks(int argc, char** argv){
+    printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq);
+    printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq);
+    printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq);
+    printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate);
+    return 0;
+}
+
+/*
+* Single function to prepare CAN devices for read/write operation.
+*
+* Sets up baud rate at 1M, opens fda and fdb and checks for errors.
+*/
+static int init_CAN(){
+    rtems_status_code status;
+    
+    printf("Initializing CAN bus.\n");
+    
+    printf("Changing gpiopcr setting...\n");    
+    //Clear PCR_CHIP_SELECT bits and sets them to ALT_CAN.
+    mpc5200.gpiopcr = (mpc5200.gpiopcr & (~GPIO_PCR_CHIP_SELECT_1)) | GPIO_PCR_CHIP_ALTS_CAN;
+
+    printf("Registering CAN drivers...\n");
+    status = rtems_io_register_driver(0, &mscan_driver_table, &mscan_major);
+    if (status != RTEMS_SUCCESSFUL){
+        printf("caninit: rtems_io_register_driver %s\n",rtems_status_text(status));
+        return 1;
+    }
+    
+    return 0;
+}
+
+int start_can(int argc, char** argv){
+    int res;
+    static char inited = 0;
+    if (!inited){
+        res = init_CAN();
+        inited = 1;
+        if (res != 0){
+            //TODO
+            printf("Error while initializing CAN\n");
+            return res;
+        }
+        printf("CAN inited\n");
+    }
+    res = start_GW();
+    return 0;
+}
+
+int end_can(int argc, char** argv){
+    return end_GW();
+}
+
+int show_net(int argc, char** argv){
+    rtems_bsdnet_show_if_stats();
+    rtems_bsdnet_show_ip_stats();
+    rtems_bsdnet_show_icmp_stats();
+    rtems_bsdnet_show_mbuf_stats();
+    rtems_bsdnet_show_inet_routes();
+    return 0;
+}
+
+int start_net(int argc, char** argv){
+    int res;
+    printf("Initializing Network\n");
+    res = rtems_bsdnet_initialize_network ();
+    if (res < 0){
+        printf("Error while initializing network: %d    %s\n", errno, strerror(errno));
+        return 1;
+    }
+    printf("Success\n");
+    printf("Found routes.\n");
+    rtems_bsdnet_show_inet_routes (); 
+    return 0;
+}
+
+int start_load(int argc, char** argv){
+    return start_thread_load();
+}
+
+int stop_load(int argc, char** argv){
+    return end_thread_load();
+}