打印

AC78406 多个串口中断失效

[复制链接]
1932|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
newphj|  楼主 | 2024-3-23 13:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
各位前辈好。第一次用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)
{
}



使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

15

主题

79

帖子

2

粉丝