|
|
@@ -292,7 +292,7 @@ void CAN_Config(void)
|
|
|
can_parameter.auto_wake_up = DISABLE;
|
|
|
can_parameter.auto_retrans = DISABLE;
|
|
|
can_parameter.rec_fifo_overwrite = DISABLE;
|
|
|
- can_parameter.trans_fifo_order = DISABLE;
|
|
|
+ can_parameter.trans_fifo_order = ENABLE;
|
|
|
can_parameter.working_mode = CAN_NORMAL_MODE;
|
|
|
can_parameter.resync_jump_width = CAN_BT_SJW_1TQ;
|
|
|
can_parameter.time_segment_1 = CAN_BT_BS1_5TQ;
|
|
|
@@ -448,44 +448,37 @@ void USBD_LP_CAN0_RX0_IRQHandler(void)
|
|
|
|
|
|
}
|
|
|
|
|
|
+static can_trasnmit_message_struct shark_can_log_message;
|
|
|
|
|
|
-
|
|
|
-#if 1
|
|
|
+static void shark_can_log_flush(uint8_t dest)
|
|
|
+{
|
|
|
+ shark_can_log_message.tx_efid = 3 << 24 | 1 << 19 | 1 << 14 | SELF_ID << 7 | dest;
|
|
|
+ shark_can_log_message.tx_ff = CAN_FF_EXTENDED;
|
|
|
+ shark_can_log_message.tx_ft = CAN_FT_DATA;
|
|
|
+ can_message_transmit(CAN0, &shark_can_log_message);
|
|
|
+ shark_can_log_message.tx_dlen = 0;
|
|
|
+}
|
|
|
|
|
|
//
|
|
|
//ÓÃÓÚϵͳµ÷ÓÃprintf
|
|
|
//
|
|
|
-#ifdef __GNUC__
|
|
|
- /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
|
|
|
- set to 'Yes') calls __io_putchar() */
|
|
|
-#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
|
|
-#else
|
|
|
-#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
|
|
-#endif /* __GNUC__ */
|
|
|
-
|
|
|
-PUTCHAR_PROTOTYPE
|
|
|
+int fputc(int ch, FILE *f)
|
|
|
{
|
|
|
- if(work_normal)
|
|
|
- {
|
|
|
- can_trasnmit_message_struct can_tr_m;
|
|
|
-
|
|
|
- memset(&can_tr_m,0x00,sizeof(can_tr_m));
|
|
|
-
|
|
|
- can_tr_m.tx_efid = (SELF_ID << 7)|(PRINTF_TER_ID << 0);
|
|
|
- can_tr_m.tx_ff = CAN_FF_EXTENDED;
|
|
|
- can_tr_m.tx_ft = CAN_FT_DATA;
|
|
|
- can_tr_m.tx_dlen = 1;
|
|
|
- can_tr_m.tx_data[0] = (uint8_t)ch;
|
|
|
-
|
|
|
- can_message_transmit(CAN0,&can_tr_m);
|
|
|
-
|
|
|
- delay_1us(500);
|
|
|
+ if (ch == '\n') {
|
|
|
+ if (shark_can_log_message.tx_dlen > 0) {
|
|
|
+ shark_can_log_flush(0x72);
|
|
|
+ }
|
|
|
+ } else if (shark_can_log_message.tx_dlen < sizeof(shark_can_log_message.tx_data)) {
|
|
|
+ shark_can_log_message.tx_data[shark_can_log_message.tx_dlen] = ch;
|
|
|
+ shark_can_log_message.tx_dlen++;
|
|
|
+ } else {
|
|
|
+ shark_can_log_flush(0x70);
|
|
|
+ shark_can_log_message.tx_dlen = 1;
|
|
|
+ shark_can_log_message.tx_data[0] = ch;
|
|
|
}
|
|
|
|
|
|
return ch;
|
|
|
}
|
|
|
-
|
|
|
-#endif
|
|
|
//********************************************************CAN-END**********************************************************
|
|
|
|
|
|
|