1 #include <system_def.h>
\r
9 #include <rtems/error.h>
\r
10 #include <rtems/monitor.h>
\r
11 #include <rtems/shell.h>
\r
13 #include <bsp/mscan.h>
\r
14 #include <bsp/mscan-base.h>
\r
17 #include "helpers.h"
\r
20 #include <rtems/rtems_bsdnet.h>
\r
21 #include "networkconfig.h"
\r
24 extern unsigned long int total_1, total_2, succ_1, succ_2, err_1, err_2;
\r
26 static rtems_device_major_number mscan_major;
\r
27 static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY;
\r
30 int print_can_totals(int argc, char** argv){
\r
31 printf("Total 1: %lu, Total 2: %lu\n", total_1, total_2);
\r
32 printf("Success 1: %lu, Success 2: %lu\n", succ_1, succ_2);
\r
33 printf("Errors 1: %lu, Errors 2: %lu\n", err_1, err_2);
\r
37 int print_regs(int argc, char** argv){
\r
38 printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq);
\r
39 printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq);
\r
40 printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq);
\r
41 printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate);
\r
42 printf("BIT 27 set to 1: 0x%08lx\n", MPC5200_BIT32(27));
\r
43 printf("GPIO_PCR_CHIP_ALTS_CAN: 0x%08x\n", GPIO_PCR_CHIP_ALTS_CAN);
\r
44 printf("GPIO_PCR_CHIP_SELECT_1: 0x%08x\n", GPIO_PCR_CHIP_SELECT_1);
\r
51 * Single function to prepare CAN devices for read/write operation.
\r
53 * Sets up baud rate at 1M, opens fda and fdb and checks for errors.
\r
55 static int init_CAN(){
\r
56 rtems_status_code status;
\r
58 printf("Initializing CAN bus.\n");
\r
60 printf("Changing gpiopcr setting...\n");
\r
61 //Clear PCR_CHIP_SELECT bits and sets them to ALT_CAN.
\r
62 mpc5200.gpiopcr = (mpc5200.gpiopcr & (~GPIO_PCR_CHIP_SELECT_1)) | GPIO_PCR_CHIP_ALTS_CAN;
\r
64 printf("Registering CAN drivers...\n");
\r
65 status = rtems_io_register_driver(0, &mscan_driver_table, &mscan_major);
\r
66 if (status != RTEMS_SUCCESSFUL){
\r
67 printf("caninit: rtems_io_register_driver %s\n",rtems_status_text(status));
\r
74 int start_can(int argc, char** argv){
\r
76 static char inited = 0;
\r
82 printf("Error while initializing CAN\n");
\r
85 printf("CAN inited\n");
\r
91 int end_can(int argc, char** argv){
\r
95 int show_net(int argc, char** argv){
\r
96 rtems_bsdnet_show_if_stats();
\r
97 rtems_bsdnet_show_ip_stats();
\r
98 rtems_bsdnet_show_icmp_stats();
\r
99 rtems_bsdnet_show_tcp_stats();
\r
100 rtems_bsdnet_show_udp_stats();
\r
101 rtems_bsdnet_show_mbuf_stats();
\r
102 rtems_bsdnet_show_inet_routes();
\r
106 int start_net(int argc, char** argv){
\r
108 printf("Initializing Network\n");
\r
109 res = rtems_bsdnet_initialize_network ();
\r
111 printf("Error while initializing network: %d %s\n", errno, strerror(errno));
\r
114 printf("Success\n");
\r
115 printf("About to show routes.\n");
\r
116 rtems_bsdnet_show_inet_routes ();
\r