打印

不得不吐槽下GD的固件库

[复制链接]
2073|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xad74|  楼主 | 2017-11-16 08:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
2.0库和3.0库不能通用互换不说,还没说明文档,且是一库难求,而且库中的例程是漏洞百出,
在GD的GD32F1x0_Firmware_Library_V3.0.0库中有一个Receivertimeout串口接收超时的例程,看看里面的程序是如何写的
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    uint32_t i=0, j=0;
    nvic_config();
    gd_eval_COMinit(EVAL_COM1);
    printf("a usart receive timeout test example!");
   
    while (1){
        if(0 == rxcount){
            /* enable the USART receive interrupt */
            usart_interrupt_enable( EVAL_COM1, USART_INT_RBNEIE);
        }else{
            /* enable the USART receive timeout and configure the time of timeout */
            usart_receiver_timeout_enable(EVAL_COM1);
            usart_receiver_timeout_config(EVAL_COM1, 115200*3);

            while(RESET == usart_flag_get(EVAL_COM1, USART_STAT_RTF));
            
            for(i=0; i<rxcount; i++){
                txbuffer=rxbuffer[j++];
            }
            /* disable the USART receive interrupt and enable the USART transmit interrupt */
            usart_interrupt_disable(EVAL_COM1 , USART_INT_RBNEIE);
            usart_interrupt_enable(EVAL_COM1, USART_INT_TBEIE);

            while(txcount < rxcount);
            usart_flag_clear(EVAL_COM1, USART_STAT_RTF);
            txcount=0;
            rxcount=0;
            i=0;
            j=0;
        }
    }
}

在看看gd32f1x0_usart.c中对于串口中断的定义
/*!
    \brief      enable usart interrupt
    \param[in]  usart_periph: USARTx(x=0)
    \param[in]  inttype:      interrupt type
      \arg        USART_INT_IDLEIE:   idle interrupt
      \arg        USART_INT_RBNEIE: read data buffer not empty interrupt and
                                   overrun error interrupt enable interrupt
      \arg        USART_INT_TCIE:   transmission complete interrupt   
      \arg        USART_INT_TBEIE:  transmit data register empty interrupt  
      \arg        USART_INT_PERRIE:   parity error interrupt
      \arg        USART_INT_AMIE:   address match interrupt   
      \arg        USART_INT_RTIE:   receiver timeout interrupt   
      \arg        USART_INT_EBIE:   end of block interrupt  
      \arg        USART_INT_LBDIE:  LIN break detection interrupt   
      \arg        USART_INT_ERRIE:   error interrupt enable in multibuffer communication  
      \arg        USART_INT_CTSIE:  CTS interrupt
      \arg        USART_INT_WUIE:   wakeup from Deep-sleep mode interrupt   
    \param[out] none
    \retval     none
*/
GD让我爱你不容易啊
沙发
Houtz| | 2017-11-16 11:48 | 只看该作者
楼主实际应用中陪到什么样的问题呢?GD32起步晚,经过不断的完善和进步,相信以后会越做越好。

使用特权

评论回复
板凳
angerbird| | 2017-11-16 20:43 | 只看该作者
串口中断的使用还是要谨慎的

使用特权

评论回复
地板
zhangbo1985| | 2017-11-19 16:30 | 只看该作者
官方提供的固件库只是作为参考而已的呀

使用特权

评论回复
5
mdqsdaf| | 2017-11-20 15:42 | 只看该作者
知足吧,便宜的芯片,有库就不错了

使用特权

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

本版积分规则

26

主题

163

帖子

3

粉丝