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
21 extern unsigned long int total_1, total_2, succ_1, succ_2, err_1, err_2;
\r
23 static rtems_device_major_number mscan_major;
\r
24 static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY;
\r
27 int print_can_totals(int argc, char** argv){
\r
28 printf("Total 1: %lu, Total 2: %lu\n", total_1, total_2);
\r
29 printf("Success 1: %lu, Success 2: %lu\n", succ_1, succ_2);
\r
30 printf("Errors 1: %lu, Errors 2: %lu\n", err_1, err_2);
\r
34 int print_regs(int argc, char** argv){
\r
35 printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq);
\r
36 printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq);
\r
37 printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq);
\r
38 printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate);
\r
39 printf("BIT 27 set to 1: 0x%08lx\n", MPC5200_BIT32(27));
\r
40 printf("GPIO_PCR_CHIP_ALTS_CAN: 0x%08x\n", GPIO_PCR_CHIP_ALTS_CAN);
\r
41 printf("GPIO_PCR_CHIP_SELECT_1: 0x%08x\n", GPIO_PCR_CHIP_SELECT_1);
\r
48 * Single function to prepare CAN devices for read/write operation.
\r
50 * Sets up baud rate at 1M, opens fda and fdb and checks for errors.
\r
52 static int init_CAN(){
\r
53 rtems_status_code status;
\r
55 printf("Initializing CAN bus.\n");
\r
57 printf("Changing gpiopcr setting...\n");
\r
58 //Clear PCR_CHIP_SELECT bits and sets them to ALT_CAN.
\r
59 mpc5200.gpiopcr = (mpc5200.gpiopcr & (~GPIO_PCR_CHIP_SELECT_1)) | GPIO_PCR_CHIP_ALTS_CAN;
\r
61 printf("Registering CAN drivers...\n");
\r
62 status = rtems_io_register_driver(0, &mscan_driver_table, &mscan_major);
\r
63 if (status != RTEMS_SUCCESSFUL){
\r
64 printf("caninit: rtems_io_register_driver %s\n",rtems_status_text(status));
\r
71 int start_can(int argc, char** argv){
\r
73 static char inited = 0;
\r
79 printf("Error while initializing CAN\n");
\r
82 printf("CAN inited\n");
\r
88 int end_can(int argc, char** argv){
\r