can_test.c
00001 #include <includes.h>
00002 int counter = 0;
00003 float count_float = 0;
00004 int count_int = 0;
00005
00006 #define FRAME_BUF_LEN 8
00007 CAN_RING ring;
00008 CAN_FRAME frame_buf[FRAME_BUF_LEN];
00009
00010 void can_test_init_ring(void){
00011 can_init_ring(&ring,frame_buf,FRAME_BUF_LEN);
00012 can_tx_set_ring(&ring);
00013 }
00014
00015 void can_test_send_1(void) {
00016 int i;
00017 CAN_FRAME frame;
00018 if(counter > 2000) {
00019 for(i = 1;i<100;i++){
00020 frame.addr = i;
00021 frame.dlc = 8;
00022 frame.payload.w.w1 = 1337;
00023 frame.payload.w.w2 = 0xAAAAAAAA;
00024
00025 can_tx_add_frame_to_buffer(&ring,&frame);
00026 }
00027 } else {
00028 counter++;
00029 }
00030 }
00031
00032 float get_float_count_and_inc(void){
00033 float ret = count_float;
00034 count_float = count_float + 1;
00035 return ret;
00036 }
00037
00038 int get_int_count_and_inc(void){
00039 return count_int++;
00040 }
00041
00042 void can_test_send_2(void){
00043 CAN_FRAME_DESC fd;
00044 can_set_tx_descriptor_ii(&fd,0x137,get_int_count_and_inc,get_int_count_and_inc);
00045 can_transmit(&fd);
00046 }
00047
00048