Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stm32_libraries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
humanoides
tools
stm32_libraries
Commits
f0aa503e
Commit
f0aa503e
authored
3 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://gitlab.iri.upc.edu:2202/humanoides/tools/stm32_libraries
parents
ffaa8a65
efa6a130
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
f4/can/src/can.c
+23
-1
23 additions, 1 deletion
f4/can/src/can.c
with
23 additions
and
1 deletion
f4/can/src/can.c
+
23
−
1
View file @
f0aa503e
...
@@ -18,6 +18,8 @@ CAN_HandleTypeDef CANHandle;
...
@@ -18,6 +18,8 @@ CAN_HandleTypeDef CANHandle;
CAN_FilterTypeDef
CANFilterConfig
;
CAN_FilterTypeDef
CANFilterConfig
;
CAN_TxHeaderTypeDef
CAN_txHeader
;
CAN_TxHeaderTypeDef
CAN_txHeader
;
uint8_t
CAN_txMessage
[
8
];
uint8_t
CAN_txMessage
[
8
];
uint8_t
arbitrationBakCAN_txMessage
[
8
];
uint32_t
TxMailbox
;
uint32_t
TxMailbox
;
CAN_RxHeaderTypeDef
CAN_rxHeader
;
CAN_RxHeaderTypeDef
CAN_rxHeader
;
uint8_t
CAN_rxMessage
[
8
];
uint8_t
CAN_rxMessage
[
8
];
...
@@ -124,6 +126,7 @@ void can_init(TComm *comm_dev,CAN_InitTypeDef *conf,TCAN_IRQ_Priorities *priorit
...
@@ -124,6 +126,7 @@ void can_init(TComm *comm_dev,CAN_InitTypeDef *conf,TCAN_IRQ_Priorities *priorit
//Activate default interrupt when message in FIFO0
//Activate default interrupt when message in FIFO0
HAL_CAN_ActivateNotification
(
&
CANHandle
,
CAN_IT_RX_FIFO0_MSG_PENDING
);
HAL_CAN_ActivateNotification
(
&
CANHandle
,
CAN_IT_RX_FIFO0_MSG_PENDING
);
HAL_CAN_ActivateNotification
(
&
CANHandle
,
CAN_IT_TX_MAILBOX_EMPTY
);
HAL_CAN_ActivateNotification
(
&
CANHandle
,
CAN_IT_TX_MAILBOX_EMPTY
);
HAL_CAN_ActivateNotification
(
&
CANHandle
,
CAN_IT_ERROR
);
}
}
void
can_config
(
TComm
*
comm_dev
,
CAN_InitTypeDef
*
conf
)
void
can_config
(
TComm
*
comm_dev
,
CAN_InitTypeDef
*
conf
)
...
@@ -228,7 +231,10 @@ void can_set_can_id(TComm *comm_dev,unsigned int id)
...
@@ -228,7 +231,10 @@ void can_set_can_id(TComm *comm_dev,unsigned int id)
*/
*/
void
HAL_CAN_ErrorCallback
(
CAN_HandleTypeDef
*
CANHandle
)
void
HAL_CAN_ErrorCallback
(
CAN_HandleTypeDef
*
CANHandle
)
{
{
//HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4,GPIO_PIN_SET);
if
(
HAL_CAN_GetError
(
CANHandle
)
==
HAL_CAN_ERROR_TX_ALST0
)
{
HAL_CAN_AddTxMessage
(
CANHandle
,
&
CAN_txHeader
,
arbitrationBakCAN_txMessage
,
&
TxMailbox
);
}
}
}
void
HAL_CAN_RxFifo0MsgPendingCallback
(
CAN_HandleTypeDef
*
CANHandle
)
void
HAL_CAN_RxFifo0MsgPendingCallback
(
CAN_HandleTypeDef
*
CANHandle
)
...
@@ -359,12 +365,20 @@ unsigned char can_send_dma(unsigned char *data,unsigned short int length)
...
@@ -359,12 +365,20 @@ unsigned char can_send_dma(unsigned char *data,unsigned short int length)
}
}
can_send_lenght
=
length
-
8
;
can_send_lenght
=
length
-
8
;
can_send_iterations
=
1
;
can_send_iterations
=
1
;
for
(
uint8_t
i
=
0
;
i
<
8
;
i
++
)
{
arbitrationBakCAN_txMessage
[
i
]
=
can_send_data
[
i
];
}
HAL_CAN_AddTxMessage
(
&
CANHandle
,
&
CAN_txHeader
,
data
,
&
TxMailbox
);
HAL_CAN_AddTxMessage
(
&
CANHandle
,
&
CAN_txHeader
,
data
,
&
TxMailbox
);
}
}
else
{
else
{
CAN_txHeader
.
DLC
=
length
;
CAN_txHeader
.
DLC
=
length
;
can_send_lenght
=
0
;
can_send_lenght
=
0
;
can_send_iterations
=
0
;
can_send_iterations
=
0
;
for
(
uint8_t
i
=
0
;
i
<
length
;
i
++
)
{
arbitrationBakCAN_txMessage
[
i
]
=
data
[
i
];
}
HAL_CAN_AddTxMessage
(
&
CANHandle
,
&
CAN_txHeader
,
data
,
&
TxMailbox
);
HAL_CAN_AddTxMessage
(
&
CANHandle
,
&
CAN_txHeader
,
data
,
&
TxMailbox
);
uint8_t
byte
;
uint8_t
byte
;
comm_do_dma_send
(
can_comm_dev
);
comm_do_dma_send
(
can_comm_dev
);
...
@@ -386,6 +400,10 @@ void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef* CANHandle)
...
@@ -386,6 +400,10 @@ void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef* CANHandle)
}
}
can_send_lenght
=
can_send_lenght
-
8
;
can_send_lenght
=
can_send_lenght
-
8
;
can_send_iterations
++
;
can_send_iterations
++
;
for
(
uint8_t
i
=
0
;
i
<
8
;
i
++
)
{
arbitrationBakCAN_txMessage
[
i
]
=
CAN_txMessage
[
i
];
}
HAL_CAN_AddTxMessage
(
CANHandle
,
&
CAN_txHeader
,
CAN_txMessage
,
&
TxMailbox
);
HAL_CAN_AddTxMessage
(
CANHandle
,
&
CAN_txHeader
,
CAN_txMessage
,
&
TxMailbox
);
}
}
else
else
...
@@ -397,6 +415,10 @@ void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef* CANHandle)
...
@@ -397,6 +415,10 @@ void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef* CANHandle)
}
}
can_send_lenght
=
0
;
can_send_lenght
=
0
;
can_send_iterations
=
0
;
can_send_iterations
=
0
;
for
(
uint8_t
i
=
0
;
i
<
8
;
i
++
)
{
arbitrationBakCAN_txMessage
[
i
]
=
CAN_txMessage
[
i
];
}
HAL_CAN_AddTxMessage
(
CANHandle
,
&
CAN_txHeader
,
CAN_txMessage
,
&
TxMailbox
);
HAL_CAN_AddTxMessage
(
CANHandle
,
&
CAN_txHeader
,
CAN_txMessage
,
&
TxMailbox
);
uint8_t
byte
;
uint8_t
byte
;
comm_do_dma_send
(
can_comm_dev
);
comm_do_dma_send
(
can_comm_dev
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment