feat: 增加速度环

This commit is contained in:
bmy
2024-04-26 16:13:07 +08:00
parent 05cab94699
commit 6bac98da0a
12 changed files with 303 additions and 136 deletions

View File

@@ -29,6 +29,7 @@
/* private includes ----------------------------------------------------------*/
/* add user code begin private includes */
#include "by_debug.h"
#include "by_motion.h"
/* add user code end private includes */
@@ -68,10 +69,10 @@
/* add user code end external variables */
/**
* @brief this function handles nmi exception.
* @param none
* @retval none
*/
* @brief this function handles nmi exception.
* @param none
* @retval none
*/
void NMI_Handler(void)
{
/* add user code begin NonMaskableInt_IRQ 0 */
@@ -84,17 +85,18 @@ void NMI_Handler(void)
}
/**
* @brief this function handles hard fault exception.
* @param none
* @retval none
*/
* @brief this function handles hard fault exception.
* @param none
* @retval none
*/
void HardFault_Handler(void)
{
/* add user code begin HardFault_IRQ 0 */
/* add user code end HardFault_IRQ 0 */
/* go to infinite loop when hard fault exception occurs */
while (1) {
while (1)
{
/* add user code begin W1_HardFault_IRQ 0 */
/* add user code end W1_HardFault_IRQ 0 */
@@ -102,17 +104,18 @@ void HardFault_Handler(void)
}
/**
* @brief this function handles memory manage exception.
* @param none
* @retval none
*/
* @brief this function handles memory manage exception.
* @param none
* @retval none
*/
void MemManage_Handler(void)
{
/* add user code begin MemoryManagement_IRQ 0 */
/* add user code end MemoryManagement_IRQ 0 */
/* go to infinite loop when memory manage exception occurs */
while (1) {
while (1)
{
/* add user code begin W1_MemoryManagement_IRQ 0 */
/* add user code end W1_MemoryManagement_IRQ 0 */
@@ -120,17 +123,18 @@ void MemManage_Handler(void)
}
/**
* @brief this function handles bus fault exception.
* @param none
* @retval none
*/
* @brief this function handles bus fault exception.
* @param none
* @retval none
*/
void BusFault_Handler(void)
{
/* add user code begin BusFault_IRQ 0 */
/* add user code end BusFault_IRQ 0 */
/* go to infinite loop when bus fault exception occurs */
while (1) {
while (1)
{
/* add user code begin W1_BusFault_IRQ 0 */
/* add user code end W1_BusFault_IRQ 0 */
@@ -138,17 +142,18 @@ void BusFault_Handler(void)
}
/**
* @brief this function handles usage fault exception.
* @param none
* @retval none
*/
* @brief this function handles usage fault exception.
* @param none
* @retval none
*/
void UsageFault_Handler(void)
{
/* add user code begin UsageFault_IRQ 0 */
/* add user code end UsageFault_IRQ 0 */
/* go to infinite loop when usage fault exception occurs */
while (1) {
while (1)
{
/* add user code begin W1_UsageFault_IRQ 0 */
/* add user code end W1_UsageFault_IRQ 0 */
@@ -156,10 +161,10 @@ void UsageFault_Handler(void)
}
/**
* @brief this function handles svcall exception.
* @param none
* @retval none
*/
* @brief this function handles svcall exception.
* @param none
* @retval none
*/
void SVC_Handler(void)
{
/* add user code begin SVCall_IRQ 0 */
@@ -171,10 +176,10 @@ void SVC_Handler(void)
}
/**
* @brief this function handles debug monitor exception.
* @param none
* @retval none
*/
* @brief this function handles debug monitor exception.
* @param none
* @retval none
*/
void DebugMon_Handler(void)
{
/* add user code begin DebugMonitor_IRQ 0 */
@@ -186,10 +191,10 @@ void DebugMon_Handler(void)
}
/**
* @brief this function handles pendsv_handler exception.
* @param none
* @retval none
*/
* @brief this function handles pendsv_handler exception.
* @param none
* @retval none
*/
void PendSV_Handler(void)
{
/* add user code begin PendSV_IRQ 0 */
@@ -201,16 +206,37 @@ void PendSV_Handler(void)
}
/**
* @brief this function handles TMR4 handler.
* @param none
* @retval none
*/
* @brief this function handles USB Low Priority or CAN1 RX0 handler.
* @param none
* @retval none
*/
void USBFS_L_CAN1_RX0_IRQHandler(void)
{
/* add user code begin USBFS_L_CAN1_RX0_IRQ 0 */
if (SET == can_flag_get(CAN1, CAN_RF0MN_FLAG)) {
can_rx_message_type can_rx_message;
can_message_receive(CAN1, CAN_RX_FIFO0, &can_rx_message);
by_motion_can_handle((uint16_t)can_rx_message.standard_id, can_rx_message.data, can_rx_message.dlc);
can_flag_clear(CAN1, CAN_RF0MN_FLAG);
}
/* add user code end USBFS_L_CAN1_RX0_IRQ 0 */
/* add user code begin USBFS_L_CAN1_RX0_IRQ 1 */
/* add user code end USBFS_L_CAN1_RX0_IRQ 1 */
}
/**
* @brief this function handles TMR4 handler.
* @param none
* @retval none
*/
void TMR4_GLOBAL_IRQHandler(void)
{
/* add user code begin TMR4_GLOBAL_IRQ 0 */
if (SET == tmr_interrupt_flag_get(TMR4, TMR_OVF_FLAG)) {
by_motion_get_speed_m1();
by_motion_get_speed_m2();
by_motion_run();
tmr_flag_clear(TMR4, TMR_OVF_FLAG);
}
/* add user code end TMR4_GLOBAL_IRQ 0 */