can_test_project/src/software_setup.c
00001 #include <includes.h>
00002
00003 #define SCHEDULE_TICK_DIVIDER 1 //number of system jiffies (should be 1 mS) per time slot
00004 #define RX_LIST_SIZE 10
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 const TASK_PTR schedule[]={
00022 (TASK_PTR)&task_heartbeat,(TASK_PTR)NULL,
00023 (TASK_PTR)&task_heartbeat,(TASK_PTR)NULL,
00024 (TASK_PTR)NULL
00025 };
00026
00027
00028 void print_int(int i){
00029
00030 printf(".");
00031 }
00032
00033
00034 CAN_FRAME_DESC rxtestdesc;
00035
00036
00037
00038
00039
00040
00041
00042 CAN_FRAME_DESC * rx_list[RX_LIST_SIZE];
00043
00044 void fill_descriptors(void){
00045 int i = 0;
00046 can_set_rx_descriptor_ii(&rxtestdesc,0x137,print_int,print_int);
00047 rx_list[i++] = &rxtestdesc;
00048
00049 rx_list[i++] = (CAN_FRAME_DESC *) 0;
00050
00051 if(i >= RX_LIST_SIZE) {
00052
00053 }
00054
00055
00056 }
00057
00058 void setup_software(void){
00059
00060
00061
00062 schedule_init(schedule,SCHEDULE_TICK_DIVIDER);
00063
00064
00065
00066
00067 set_heartbeat_period_ms(250);
00068
00069 can_test_init_ring();
00070 fill_descriptors();
00071 can_rx_init(rx_list);
00072
00073 VICVectAddr1 = (unsigned long)can_isr;
00074 VICVectCntl1 = 0x20 | VIC_CAN1TX;
00075 VICIntEnable = 1 << VIC_CAN1TX;
00076
00077 VICVectAddr2 = (unsigned long)can_isr;
00078 VICVectCntl2 = 0x20 | VIC_CAN1RX;
00079 VICIntEnable = 1 << VIC_CAN1RX;
00080 }