查看: 5355|回复: 4

[其他] UART_DRV_InstallRxCallback函数,void * callbackParam 参数是什么?

[复制链接]
  • TA的每日心情
    开心
    2020-4-30 08:32
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    79

    主题

    239

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1095
    最后登录
    2025-6-7
    发表于 2016-8-4 23:15:08 | 显示全部楼层 |阅读模式

    这是ksdk 1.2中的代码,在调用UART_DRV_InstallRxCallback函数时,void * callbackParam 参数是什么,
    /*!
    * @brief Runtime state of the UART driver.
    *
    * This structure holds data that are used by the UART peripheral driver to
    * communicate between the transfer function and the interrupt handler. The
    * interrupt handler also uses this information to keep track of its progress.
    * The user passes in the memory for the run-time state structure and the
    * UART driver fills out the members.
    */
    typedef struct UartState {
        uint8_t txFifoEntryCount;      /*!< Number of data word entries in TX FIFO. */
        const uint8_t * txBuff;        /*!< The buffer of data being sent.*/
        uint8_t * rxBuff;              /*!< The buffer of received data. */
        volatile size_t txSize;        /*!< The remaining number of bytes to be transmitted. */
        volatile size_t rxSize;        /*!< The remaining number of bytes to be received. */
        volatile bool isTxBusy;        /*!< True if there is an active transmit. */
        volatile bool isRxBusy;        /*!< True if there is an active receive. */
        volatile bool isTxBlocking;    /*!< True if transmit is blocking transaction. */
        volatile bool isRxBlocking;    /*!< True if receive is blocking transaction. */
        semaphore_t txIrqSync;         /*!< Used to wait for ISR to complete its TX business. */
        semaphore_t rxIrqSync;         /*!< Used to wait for ISR to complete its RX business. */
        uart_rx_callback_t rxCallback; /*!< Callback to invoke after receiving byte.*/
        void * rxCallbackParam;        /*!< Receive callback parameter pointer.*/
        uart_tx_callback_t txCallback; /*!< Callback to invoke after transmitting byte.*/
        void * txCallbackParam;        /*!< Transmit callback parameter pointer.*/
    } uart_state_t;


    /*FUNCTION**********************************************************************
    *
    * Function Name : UART_DRV_InstallRxCallback
    * Description   : Install receive data callback function, pass in NULL pointer
    * as callback will unistall.
    *
    *END**************************************************************************/
    uart_rx_callback_t UART_DRV_InstallRxCallback(uint32_t instance,
                                                  uart_rx_callback_t function,
                                                  uint8_t * rxBuff,
                                                  void * callbackParam,
                                                  bool alwaysEnableRxIrq)
    {
        assert(instance < UART_INSTANCE_COUNT);
        UART_Type * base = g_uartBase[instance];
        uart_state_t * uartState = (uart_state_t *)g_uartStatePtr[instance];

        uart_rx_callback_t currentCallback = uartState->rxCallback;
        uartState->rxCallback = function;
        uartState->rxCallbackParam = callbackParam;
        uartState->rxBuff = rxBuff;

        /* Enable/Disable the receive data full interrupt */
        uartState->isRxBusy = true;
        UART_BWR_C2_RIE(base, alwaysEnableRxIrq);

        return currentCallback;
    }

    void uartCom0_RxCallback(uint32_t instance, void * uartState)
    {
      /* Write your code here ... */
    }

    UART_DRV_InstallRxCallback(FSL_UARTCOM0, uartCom0_RxCallback, uartCom0_RxBuffer, (void *)???, false);

    请问???处传递的是什么,应如何填写参数?
    我知道答案 目前已有4人回答
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2020-4-30 08:32
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    79

    主题

    239

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1095
    最后登录
    2025-6-7
     楼主| 发表于 2016-8-4 23:25:47 | 显示全部楼层
    这是PE中的设置界面,不知 User parameter 是自己定义的吗?有什么作用?
    PE设置界面.JPG
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    712

    主题

    6371

    帖子

    0

    超级版主

    Rank: 8Rank: 8

    积分
    24915
    最后登录
    2025-7-23
    发表于 2016-8-5 10:21:24 | 显示全部楼层
    xxs-133546 发表于 2016-8-4 23:25
    这是PE中的设置界面,不知 User parameter 是自己定义的吗?有什么作用?

    callbackParam :The LPUART receive callback parameter pointer.
    是callback参数的指针,如果你callback里面没有的,可以不定义,在PE中把user parameter勾掉。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2017-1-4 08:05
  • 签到天数: 11 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    85

    主题

    1629

    帖子

    1

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    2569

    优秀版主

    最后登录
    2019-3-28
    发表于 2016-8-5 12:51:06 | 显示全部楼层
    回调函数
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2018-7-23 21:04
  • 签到天数: 103 天

    连续签到: 1 天

    [LV.6]常住居民II

    228

    主题

    5379

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    16706
    最后登录
    1970-1-1
    发表于 2016-8-6 01:46:46 | 显示全部楼层
    自定义的回掉函数参数,根据情况可传入自己需要的数据,在PE中处理小恩GG的正解。以前也不太清楚,自己试一下调调就更清楚了
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-23 10:59 , Processed in 0.102121 second(s), 28 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表