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