Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
haoJin750TFT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
时昊
haoJin750TFT
Commits
8441a8f1
Commit
8441a8f1
authored
Jul 11, 2024
by
时昊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:增加can接收buffer
parent
c9abbe84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
59 deletions
+111
-59
CAN_CH0_CAN_Communication_Matrix.c
...are/Source/Application/CAN_CH0_CAN_Communication_Matrix.c
+1
-1
CAN_CH0_CAN_Communication_Matrix.h
...are/Source/Application/CAN_CH0_CAN_Communication_Matrix.h
+1
-3
Can_User.c
Firmware/Source/Application/Can_User.c
+99
-45
rte_can.c
Firmware/Source/Device/Cmsemicon/BAT32A279/RTE/CAN/rte_can.c
+10
-10
No files found.
Firmware/Source/Application/CAN_CH0_CAN_Communication_Matrix.c
View file @
8441a8f1
...
...
@@ -6,7 +6,7 @@ st_CanMsgTxOp CAN_CH0_CanMsgTxOp;
const
st_CAN_SendAttribute
CAN_CH0_CANSendAttr
[
CAN_CH0_ID_SEND_TOTAL
]
=
{
{
0
}
{
0
}
};
const
st_CANMsgAttribute
CAN_CH0_CAN_MSG_CONST_ARRAY
[
CAN_CH0_ID_TOTAL_MAX
]
=
...
...
Firmware/Source/Application/CAN_CH0_CAN_Communication_Matrix.h
View file @
8441a8f1
...
...
@@ -3,9 +3,7 @@
#include "Components.h"
#include "CAN_Signal\CAN_Lib.h"
extern
st_CanMsgOp
CAN_CH0_CanMsgOp
;
extern
st_CanMsgTxOp
CAN_CH0_CanMsgTxOp
;
typedef
enum
...
...
@@ -23,7 +21,7 @@ typedef enum
typedef
enum
{
TEST
,
TEST
,
CAN_CH0_ID_SEND_TOTAL
,
}
CAN_CH0_CAN_MSG_SEND_ID_t
;
...
...
Firmware/Source/Application/Can_User.c
View file @
8441a8f1
...
...
@@ -45,6 +45,60 @@ void Can_RX_Apply_Buff(void)
CAN_MessageCache_Init
(
CAN0MSG01
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG01
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x111
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG02
);
CAN_MessageCache_Init
(
CAN0MSG02
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG02
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x401
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG03
);
CAN_MessageCache_Init
(
CAN0MSG03
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG03
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x402
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG04
);
CAN_MessageCache_Init
(
CAN0MSG04
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG04
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x12B
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG05
);
CAN_MessageCache_Init
(
CAN0MSG05
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG05
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x450
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG06
);
CAN_MessageCache_Init
(
CAN0MSG06
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG06
,
ENABLE
);
CAN_RecvMsg
.
Id
=
0x37B
;
CAN_RecvMsg
.
IDE
=
CAN_Id_Standard
;
CAN_RecvMsg
.
CacheType
=
CAN_CacheType_Rx_NoMask
;
CAN_RecvMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
ENABLE
;
CAN_MessageCache_DeInit
(
CAN0MSG07
);
CAN_MessageCache_Init
(
CAN0MSG07
,
&
CAN_RecvMsg
);
CAN_MessageCache_OverWriteConfig
(
CAN0MSG07
,
ENABLE
);
// CAN_RecvMsg.Id = DIAG_ID_Rx_PHY;
// CAN_RecvMsg.IDE = CAN_Id_Standard;
...
...
@@ -71,21 +125,21 @@ void Can_RX_Apply_Buff(void)
*/
void
Can_Tx_Apply_Buff
(
void
)
{
CanTxRxMsg
CAN_SendMsg
;
CanTxRxMsg
CAN_SendMsg_Diag_Tx
;
CAN_SendMsg
.
Id
=
0x500
;
CAN_SendMsg
.
IDE
=
CAN_Id_Standard
;
CAN_SendMsg
.
CacheType
=
CAN_CacheType_Tx
;
CAN_SendMsg
.
RTR
=
CAN_RTR_Data
;
CAN_RecvMsg
.
Interrupt
=
DISABLE
;
CAN_SendMsg
.
DLC
=
8
;
for
(
uint8_t
i
=
0
;
i
<
CAN_SendMsg
.
DLC
;
i
++
)
{
CAN_SendMsg
.
Data
[
i
]
=
0
;
}
//
CanTxRxMsg CAN_SendMsg;
//
CanTxRxMsg CAN_SendMsg_Diag_Tx;
//
CAN_SendMsg.Id = 0x500;
//
CAN_SendMsg.IDE = CAN_Id_Standard;
//
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
//
CAN_SendMsg.RTR = CAN_RTR_Data;
//
CAN_RecvMsg.Interrupt = DISABLE;
//
CAN_SendMsg.DLC = 8;
//
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
//
{
//
CAN_SendMsg.Data[i] = 0;
//
}
CAN_MessageCache_DeInit
(
CAN0MSG08
);
CAN_MessageCache_Init
(
CAN0MSG08
,
&
CAN_SendMsg
);
//
CAN_MessageCache_DeInit(CAN0MSG08);
//
CAN_MessageCache_Init(CAN0MSG08, &CAN_SendMsg);
// CAN_SendMsg_Diag_Tx.Id = DIAG_ID_Tx;
...
...
@@ -129,10 +183,10 @@ void COM_CAN_Init(void)
Can_RX_BuffInit
(
&
CAN_CH0_CanMsgOp
,
CAN_CH0_CAN_MSG_CONST_ARRAY
,
CAN_CH0_ID_TOTAL_MAX
);
CAN_RX_SetEnable
(
&
CAN_CH0_CanMsgOp
,
CAN_N_RX_Enable
);
memset
(
pTXBuff
,
0
,
sizeof
(
pTXBuff
));
CAN_CH0_CanMsgTxOp
.
CanMsg
=
(
st_CAN_SendOperation
*
)
pTXBuff
;
Can_TX_BuffInit
(
&
CAN_CH0_CanMsgTxOp
,
CAN_CH0_CANSendAttr
,
CAN_CH0_ID_SEND_TOTAL
,
COM_APP_Process
);
CAN_TX_SetEnable
(
&
CAN_CH0_CanMsgTxOp
,
CAN_N_TX_Enable
);
//
memset(pTXBuff, 0, sizeof(pTXBuff));
//
CAN_CH0_CanMsgTxOp.CanMsg = (st_CAN_SendOperation *)pTXBuff;
//
Can_TX_BuffInit(&CAN_CH0_CanMsgTxOp, CAN_CH0_CANSendAttr, CAN_CH0_ID_SEND_TOTAL, COM_APP_Process);
//
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
}
...
...
@@ -198,35 +252,35 @@ uint8_t Get_Busoff_Status(void)
return
get_can_busoff
(
CAN_CH_0
);
}
uint8_t
COM_APP_Process
(
st_CAN_Msg
*
Msg
)
{
Can_Write
((
st_CAN_Msg
*
)
Msg
);
return
0
;
}
//
uint8_t COM_APP_Process(st_CAN_Msg *Msg)
//
{
//
Can_Write((st_CAN_Msg *)Msg);
//
return 0;
//
}
void
Can_Write
(
st_CAN_Msg
*
Msg
)
{
uint32_t
i
=
0
;
CanTxRxMsg
CAN_SendMsg
;
//
void Can_Write(st_CAN_Msg *Msg)
//
{
//
uint32_t i = 0;
//
CanTxRxMsg CAN_SendMsg;
CAN_SendMsg
.
Id
=
Msg
->
MsgID
;
/* ID */
CAN_SendMsg
.
DLC
=
Msg
->
MsgDLC
;
/* Len */
CAN_SendMsg
.
RTR
=
Msg
->
MsgRTR
;
/* Default 0 */
CAN_SendMsg
.
IDE
=
CAN_Id_Standard
;
/* Stand 0 Ext 1 */
CAN_SendMsg
.
CacheType
=
CAN_CacheType_Tx
;
//
CAN_SendMsg.Id = Msg->MsgID; /* ID */
//
CAN_SendMsg.DLC = Msg->MsgDLC; /* Len */
//
CAN_SendMsg.RTR = Msg->MsgRTR; /* Default 0 */
//
CAN_SendMsg.IDE = CAN_Id_Standard; /* Stand 0 Ext 1 */
//
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
for
(
i
=
0
;
i
<
CAN_SendMsg
.
DLC
;
i
++
)
/* 获取数据 */
{
CAN_SendMsg
.
Data
[
i
]
=
Msg
->
Msg
[
i
];
}
//
for (i = 0; i < CAN_SendMsg.DLC; i++) /* 获取数据 */
//
{
//
CAN_SendMsg.Data[i] = Msg->Msg[i];
//
}
switch
(
CAN_SendMsg
.
Id
)
{
case
0x500
:
CAN_Transmit
(
CAN0MSG08
,
&
CAN_SendMsg
);
break
;
//
switch (CAN_SendMsg.Id)
//
{
//
case 0x500:
//
CAN_Transmit(CAN0MSG08, &CAN_SendMsg);
//
break;
default:
break
;
}
}
//
default:
//
break;
//
}
//
}
Firmware/Source/Device/Cmsemicon/BAT32A279/RTE/CAN/rte_can.c
View file @
8441a8f1
...
...
@@ -20,8 +20,8 @@ static void can_recv_handler(void *msg)
if
(
CAN_GetFlagStatus
(
CAN0
,
CAN_FLAG_REC
)
!=
RESET
)
{
CAN_ClearFlag
(
CAN0
,
CAN_FLAG_REC
);
//
CANMSG = CAN_Get_CANxMSGy(CAN0);
//
CAN_Receive_IT(CAN0, &CAN_RecvMsg);
//
CANMSG = CAN_Get_CANxMSGy(CAN0);
//
CAN_Receive_IT(CAN0, &CAN_RecvMsg);
if
(
can_rx_handler
!=
NULL
)
{
...
...
@@ -31,9 +31,9 @@ static void can_recv_handler(void *msg)
}
/**
* @brief CAN初始?
* @brief CAN初始
�
?
*
* @param config CAN初始结构体指?
* @param config CAN初始结构体指
�
?
* @return uint8_t 0成功 1失败
*/
uint8_t
rte_can_init
(
can_config_st_t
*
config
)
...
...
@@ -98,7 +98,7 @@ uint8_t rte_can_init(can_config_st_t *config)
/**
* @brief can反初始化
* @param CANx CAN0 ? CAN1
* @param CANx CAN0
�
? CAN1
*
* @return uint8_t 0成功 1失败
*/
...
...
@@ -124,10 +124,10 @@ uint8_t rte_can_deinit(CAN_CH ch)
/**
* @brief 获取CAN是否BusOff
* @param CANx CAN0 ? CAN1
* @param CANx CAN0
�
? CAN1
*
* @return uint8_t 0 没有busoff
* 1 错误的操? 2 busoff
* 1 错误的操
�
? 2 busoff
*/
uint8_t
get_can_busoff
(
CAN_CH
ch
)
{
...
...
@@ -151,9 +151,9 @@ uint8_t get_can_busoff(CAN_CH ch)
}
/**
* @brief 从busoff状态恢?
* @brief 从busoff状态恢
�
?
*
* @param CANx CAN0 ? CAN1
* @param CANx CAN0
�
? CAN1
* @return uint8_t 0成功 1失败
*/
uint8_t
reset_busoff
(
CAN_CH
ch
)
...
...
@@ -189,7 +189,7 @@ uint8_t reset_busoff(CAN_CH ch)
return
0
;
}
/* 下面是一些例
? 自己
?
/* 下面是一些例
�? 自己�
?
CAN_SendMsg.Id = 0x00aa0432;
CAN_SendMsg.IDE = CAN_Id_Extended;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment