1 #include <system_def.h>
\r
7 #include <rtems/error.h>
\r
8 #include <rtems/monitor.h>
\r
9 #include <rtems/shell.h>
\r
11 #include <bsp/mscan.h>
\r
12 #include <bsp/mscan-base.h>
\r
14 #include "helpers.h"
\r
18 #include <rtems/rtems_bsdnet.h>
\r
19 #include "networkconfig.h"
\r
22 static rtems_device_major_number mscan_major;
\r
23 static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY;
\r
26 * Prints can stats. (Used in debugging)
\r
28 int print_can_totals(int argc, char** argv){
\r
29 printf("Total 1: %"PRIu32", Total 2: %"PRIu32"\n", total_1, total_2);
\r
30 printf("Success 1: %"PRIu32", Success 2: %"PRIu32"\n", succ_1, succ_2);
\r
31 printf("Errors 1: %"PRIu32", Errors 2: %"PRIu32"\n", err_1, err_2);
\r
36 * Prints clocks as given by the uboot. (Used in debugging)
\r
38 int print_clocks(int argc, char** argv){
\r
39 printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq);
\r
40 printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq);
\r
41 printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq);
\r
42 printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate);
\r
47 * Single function to prepare CAN devices for read/write operation.
\r
49 * Sets up baud rate at 1M, opens fda and fdb and checks for errors.
\r
51 static int init_CAN(){
\r
52 rtems_status_code status;
\r
54 printf("Initializing CAN bus.\n");
\r
56 printf("Changing gpiopcr setting...\n");
\r
57 //Clear PCR_CHIP_SELECT bits and sets them to ALT_CAN.
\r
58 mpc5200.gpiopcr = (mpc5200.gpiopcr & (~GPIO_PCR_CHIP_SELECT_1)) | GPIO_PCR_CHIP_ALTS_CAN;
\r
60 printf("Registering CAN drivers...\n");
\r
61 status = rtems_io_register_driver(0, &mscan_driver_table, &mscan_major);
\r
62 if (status != RTEMS_SUCCESSFUL){
\r
63 printf("caninit: rtems_io_register_driver %s\n",rtems_status_text(status));
\r
70 int start_can(int argc, char** argv){
\r
72 static char inited = 0;
\r
78 printf("Error while initializing CAN\n");
\r
81 printf("CAN inited\n");
\r
87 int end_can(int argc, char** argv){
\r
91 int show_net(int argc, char** argv){
\r
92 rtems_bsdnet_show_if_stats();
\r
93 rtems_bsdnet_show_ip_stats();
\r
94 rtems_bsdnet_show_icmp_stats();
\r
95 rtems_bsdnet_show_mbuf_stats();
\r
96 rtems_bsdnet_show_inet_routes();
\r
100 int start_net(int argc, char** argv){
\r
102 printf("Initializing Network\n");
\r
103 res = rtems_bsdnet_initialize_network ();
\r
105 printf("Error while initializing network: %d %s\n", errno, strerror(errno));
\r
108 printf("Success\n");
\r
109 printf("Found routes.\n");
\r
110 rtems_bsdnet_show_inet_routes ();
\r
114 int start_load(int argc, char** argv){
\r
115 return start_thread_load();
\r
118 int stop_load(int argc, char** argv){
\r
119 return end_thread_load();
\r