【问题标题】:__weak HAL_GPIO_EXT1_Callback ( uint16_t GPIO_Pin) even though I have defined HAL_GPIO_EXT1_Callback ( uint16_t GPIO_Pin) in my source__weak HAL_GPIO_EXT1_Callback (uint16_t GPIO_Pin) 即使我在源代码中定义了 HAL_GPIO_EXT1_Callback (uint16_t GPIO_Pin)
【发布时间】:2020-09-01 13:49:24
【问题描述】:

我正在使用带有 Blue Pill 板的 STM32 CubeIDE 工作。

为了控制 main.c 的大小,我将函数组收集到几个 c/h 对文件中。其中一对是“myirqcallbacks.c/h”。目前我在这个 c/h 对中有两个 UART IRQ 和一个外部引脚 IRQ 回调。

UART 工作正常,但 EXT IRQ 无法调用我的代码。它在 stm32f1xx_hal_gpio.c 中运行 __weak 副本。

当代码在 main.c 中时,它运行正常。

编译器似乎看不到我的 EXT IRQ 回调函数,因此未能弃用回调的 __weak 副本。然而,它可以在那里看到两个 UART 回调函数。 GPIO 和 UART IRQ 的结构有区别吗?

myirqcallbacks.h

    /*
 * myirqcallbacks.h
 *
 *  Created on: 13 May 2020
 *      Author: Paul
 */



#ifndef SRC_MYIRQCALLBACKS_H_
#define SRC_MYIRQCALLBACKS_H_

void HAL_GPIO_EXT1_Callback ( uint16_t GPIO_Pin);  // SIM Reset detected

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);  // Outgoing debug, control and up-the-line data.

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) ; // Data from SIM


#endif /* SRC_MYIRQCALLBACKS_H_ */

myirqcallbacks.c

     * myirqcallbacks.c
 *
 *  Created on: 13 May 2020
 *      Author: Paul
 */
#include <circbuf.h>
#include "main.h"
#include "stdio.h"
#include "myfuncs.h"
#include "myirqcallbacks.h"
#include "globals.h"

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)  // Outgoing debug, control and up-the-line data.
{
    if( huart->Instance == huart1.Instance)
    {
        if( buf_tx1.count > 0)

        {
            uint8_t item;
            cb_pop_front(&buf_tx1, &item );
            if(HAL_UART_Transmit_IT(&huart1, &item, 1 )!= HAL_OK)
                    Error_Handler();
        }
    }
    __NOP();// Check all data sent
}
//HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

void HAL_GPIO_EXT1_Callback ( uint16_t GPIO_Pin)  //Reset UICC detected
{
    if( GPIO_Pin == SIM_RST_Pin)
    {
        HAL_NVIC_ClearPendingIRQ(GPIO_Pin);
          SIMState= SIM_STATE_ATR;
          SIM_ATR_Processing = 1;
          SIM_ATR_BytesExpected = 2; //  +last byte will always be TK (CheckByte)
          SIM_ATR_COUNT = 0;
          debug("\nSIM-Reset!  Proc. ATR\n");
    }
}



void    HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)  // Data from SIM
    {
        if( huart->Instance == huart2.Instance)
        {
            uint8_t item;
            if(HAL_UART_Receive_IT(&huart2, &item, 1)!=HAL_OK)
                Error_Handler();
            //cb_push_back(&buf_rx2, &item);   // Still need to send this up the line, just using local copy to set speed and to debug
            if(SIM_ATR_Processing)
                processATRByte(item);
        }
    __NOP();// Check all data received
    }

我认为这更多是关于我的片状 c 文件结构知识,但我已经研究了几天,任何指针都将非常感激。

【问题讨论】:

    标签: hal bluepill stm32cubeide


    【解决方案1】:

    有人确实发现了函数名称中的错误,谢谢。可悲的是,这并没有解决问题,我一定是在试图解决主要问题时产生了这个问题。 最后修复它的是重新生成 MX 配置器的代码,它重建 stm32F1xx_hal_gpio.c/h 和 stm32F1xx_hal_gpio.ex.c/h 文件。我先删除了本地副本。

    【讨论】:

      猜你喜欢
      • 2011-09-29
      • 2015-05-20
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多