问答

汇集网友智慧,解决技术难题

21ic问答首页 - AC78406 多个串口中断失效

RT ar 串口中断 失效 AC78406

AC78406 多个串口中断失效

newphj2024-03-23
各位前辈好。第一次用AC78406芯片。使用uart0 uart1中断接受不定长数据。单个串口可以接收了。两个串口同时使用只有先初始化的那个串口可以进入中断。请问哪里配置有问题吗?代码是用AutoGen Studio生成的。#include "string.h"
#include "ckgen_drv.h"
#include "gpio_drv.h"
#include "gpio_hw.h"
#include "uart_drv.h"
#include "uart_hw.h"
#include "uart_irq.h"
#include "dma_drv.h"
#include "gpio.h"

#include "drv_comm.h"
#include "FreeRTOS.h"
#include "event_groups.h"
#include "ac7840x_irq_cb.h"

#define RECELENGTHMAX 1024

static uart_state_t s_uart0State = {NULL}; /*UART运行变量状态*/
static uart_state_t s_uart1State = {NULL}; /*UART运行变量状态*/
static uart_user_config_t uart0Config;
static uart_user_config_t uart1Config;

static unsigned char g_receive0Data = 0;
static unsigned short int g_receive0Data_count = 0;
static unsigned char receive0Data_group[RECELENGTHMAX = {0};

static unsigned char g_receive1Data = 0;
static unsigned short int g_receive1Data_count = 0;
static unsigned char receive1Data_group[RECELENGTHMAX = {0};

EventGroupHandle_t EventGroupHandle_uart = NULL;

/**
* @brief This function handle UART0 rx interrupt.
* @param[in] driverState: callback parameter
* @param[in] event: callback parameter
* @param[in] userData: callback parameter
* @return none
*/
void UART0_RX_IRQHandler_Callback(void *driverState, uint32_t event, void *userData)
{
    /* USER CODE BEGIN UART0_RX_IRQHandler_Callback */
    if (event == UART_EVENT_RX_FULL)
    {
        // xEventGroupSetBits(EventGroupHandle_uart1, EVENT_UART1_RX);
        receive0Data_group[g_receive0Data_count = g_receive0Data;
        g_receive0Data_count++;
        if (g_receive0Data_count >= RECELENGTHMAX)
        {
            g_receive0Data_count = 0;
        }
    }
    UART_DRV_ReceiveData(0, &g_receive0Data, 1);
    /* USER CODE END UART0_RX_IRQHandler_Callback */
}
/**
* @brief This function handle UART1 rx interrupt.
* @param[in] driverState: callback parameter
* @param[in] event: callback parameter
* @param[in] userData: callback parameter
* @return none
*/
void UART1_RX_IRQHandler_Callback(void *driverState, uint32_t event, void *userData)
{
    /* USER CODE BEGIN UART1_RX_IRQHandler_Callback */
    if (event == UART_EVENT_RX_FULL)
    {
        // xEventGroupSetBits(EventGroupHandle_uart1, EVENT_UART1_RX);
        receive1Data_group[g_receive1Data_count = g_receive1Data;
        g_receive1Data_count++;
        if (g_receive1Data_count >= RECELENGTHMAX)
        {
            g_receive1Data_count = 0;
        }
    }
    UART_DRV_ReceiveData(1, &g_receive1Data, 1);
    /* USER CODE END UART1_RX_IRQHandler_Callback */
}
/* UART0 init function */
static void ATC_UART0_Init(void)
{
    memset(&uart0Config, 0, sizeof(uart0Config));
    /**
        GPIO Configuration for UART0
        PB1         --> UART0_TX
        PB0         --> UART0_RX
        */
    GPIO_DRV_SetMuxModeSel(PORTB, 1, PORT_MUX_ALT2);
    GPIO_DRV_SetMuxModeSel(PORTB, 0, PORT_MUX_ALT2);
    /* UART0 interrupt1 Init */
    NVIC_SetPriority(UART0_IRQn, 0);
    NVIC_EnableIRQ(UART0_IRQn);

    uart0Config.baudRate = 38400;
    uart0Config.parityMode = UART_PARITY_DISABLED;
    uart0Config.stopBitCount = UART_ONE_STOP_BIT;
    uart0Config.bitCountPerChar = UART_8_BITS_PER_CHAR;
    uart0Config.transferType = UART_USING_INTERRUPTS;
    uart0Config.rxCallback = UART0_RX_IRQHandler_Callback;
    UART_DRV_Init(0, &s_uart0State, &uart0Config);

    /* USER CODE BEGIN UART0_Init 2 */
    UART_DRV_ReceiveData(0, &g_receive0Data, 1);
    /* USER CODE END UART0_Init 2 */
}
/* UART1 init function */
static void ATC_UART1_Init(void)
{
    memset(&uart1Config, 0, sizeof(uart1Config));
    /**
         GPIO Configuration for UART1
         PC9         --> UART1_TX
         PC8         --> UART1_RX
         */
    GPIO_DRV_SetMuxModeSel(PORTC, 9, PORT_MUX_ALT2);
    GPIO_DRV_SetMuxModeSel(PORTC, 8, PORT_MUX_ALT2);
    /* UART1 interrupt1 Init */
    NVIC_SetPriority(UART1_IRQn, 1);
    NVIC_EnableIRQ(UART1_IRQn);

    uart1Config.baudRate = 38400;
    uart1Config.parityMode = UART_PARITY_DISABLED;
    uart1Config.stopBitCount = UART_ONE_STOP_BIT;
    uart1Config.bitCountPerChar = UART_8_BITS_PER_CHAR;
    uart1Config.transferType = UART_USING_INTERRUPTS;
    uart1Config.rxCallback = UART1_RX_IRQHandler_Callback;
    UART_DRV_Init(1, &s_uart1State, &uart1Config);

    /* USER CODE BEGIN UART1_Init 2 */
    UART_DRV_ReceiveData(1, &g_receive1Data, 1);
    /* USER CODE END UART1_Init 2 */
}

void drv_comm_init(void)
{
    memset(receive0Data_group, 0, sizeof(receive0Data_group));
    memset(receive1Data_group, 0, sizeof(receive1Data_group));
    EventGroupHandle_uart = xEventGroupCreate();

    ATC_UART0_Init();
    ATC_UART1_Init();
}
void drv_comm_write(unsigned char *p_data, unsigned char length)
{
}
void drv_comm_read(void)
{
}



回答 +关注 9
1829人浏览 0人回答问题 分享 举报
0 个回答

您需要登录后才可以回复 登录 | 注册