This commit is contained in:
bmy
2024-05-19 16:03:21 +08:00
parent 7c7e401665
commit b954205663
7 changed files with 81 additions and 25 deletions

View File

@@ -65,6 +65,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void CAN1_RX0_IRQHandler(void);
void TMR4_GLOBAL_IRQHandler(void);
/* add user code begin exported functions */

View File

@@ -204,6 +204,25 @@ void PendSV_Handler(void)
/* add user code end PendSV_IRQ 1 */
}
/**
* @brief this function handles CAN1 RX0 handler.
* @param none
* @retval none
*/
void CAN1_RX0_IRQHandler(void)
{
/* add user code begin CAN1_RX0_IRQ 0 */
if (SET == can_interrupt_flag_get(CAN1, CAN_RF0MN_FLAG)){
can_rx_message_type can_rx_message;
can_message_receive(CAN1, CAN_RX_FIFO0, &can_rx_message);
can_flag_clear(CAN1, CAN_RF0MN_FLAG);
}
/* add user code end CAN1_RX0_IRQ 0 */
/* add user code begin CAN1_RX0_IRQ 1 */
/* add user code end CAN1_RX0_IRQ 1 */
}
/**
* @brief this function handles TMR4 handler.
* @param none

View File

@@ -189,6 +189,7 @@ void wk_nvic_config(void)
{
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
nvic_irq_enable(CAN1_RX0_IRQn, 0, 0);
nvic_irq_enable(TMR4_GLOBAL_IRQn, 0, 0);
}
@@ -224,14 +225,7 @@ void wk_gpio_config(void)
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
gpio_init_struct.gpio_pins = GPIO_PINS_6;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(GPIOB, &gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
gpio_init_struct.gpio_pins = GPIO_PINS_7;
gpio_init_struct.gpio_pins = GPIO_PINS_6 | GPIO_PINS_7;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(GPIOB, &gpio_init_struct);
@@ -457,8 +451,16 @@ void wk_can1_init(void)
can_filter_init(CAN1, &can_filter_init_struct);
/* add user code begin can1_init 2 */
/**
* Users need to configure CAN1 interrupt functions according to the actual application.
* 1. Call the below function to enable the corresponding CAN1 interrupt.
* --can_interrupt_enable(...)
* 2. Add the user's interrupt handler code into the below function in the at32f415_int.c file.
* --void CAN1_RX0_IRQHandler(void)
*/
/* add user code begin can1_init 2 */
can_interrupt_enable(CAN1, CAN_RF0MIEN_INT, TRUE);
/* add user code end can1_init 2 */
}

View File

@@ -29,9 +29,9 @@
/* private includes ----------------------------------------------------------*/
/* add user code begin private includes */
#include "vl53l0x_wmd_api.h"
#include "by_debug.h"
#include "by_led.h"
#include "by_measure.h"
/* add user code end private includes */
/* private typedef -----------------------------------------------------------*/
@@ -105,25 +105,15 @@ int main(void)
/* add user code begin 2 */
delay_init();
by_led_set(10);
delay_ms(1000);
VL53L0X_Init();
delay_ms(1000);
by_measure_init();
by_led_set(0);
/* add user code end 2 */
while (1) {
/* add user code begin 3 */
// gpio_bits_write(GPIOB, GPIO_PINS_8, !gpio_output_data_bit_read(GPIOB, GPIO_PINS_8));
// gpio_bits_set(GPIOA, GPIO_PINS_4);
// delay_ms(250);
// gpio_bits_reset(GPIOA, GPIO_PINS_4);
// delay_ms(250);
by_led_set(40);
delay_ms(10);
LOGI("distance:%d", VL53L0X_GetValue());
by_led_set(0);
delay_ms(10);
gpio_bits_write(GPIOA, GPIO_PINS_4, !gpio_output_data_bit_read(GPIOA, GPIO_PINS_4));
by_measure_run();
/* add user code end 3 */
}
}