{"id":867,"date":"2024-08-14T17:24:09","date_gmt":"2024-08-14T09:24:09","guid":{"rendered":"http:\/\/8.153.64.192\/?page_id=867"},"modified":"2024-08-16T14:15:23","modified_gmt":"2024-08-16T06:15:23","slug":"%e9%a9%b1%e5%8a%a8%e8%a1%a5%e5%85%85%ef%bc%9aexample_uart_rcviqr","status":"publish","type":"page","link":"http:\/\/www.agm-support.com.cn\/index.php\/sample-page\/%e9%a9%b1%e5%8a%a8%e8%a1%a5%e5%85%85%ef%bc%9aexample_uart_rcviqr\/","title":{"rendered":"\u9a71\u52a8\u8865\u5145\uff1aexample_uart_rcvIqr"},"content":{"rendered":"\n<p>\/\/example_uart_rcvIqr.c<\/p>\n\n\n\n<p>include \"example.h\"<\/p>\n\n\n\n<p>\/\/ test uart1 rcv irq<br>volatile char isRecv = 0;<br>char rxbuf[32];<br>void UART1_isr()<br>{<br>    if (UART_IsRawIntActive(UART1, UART_INT_RX)) {<br>        UART_ClearInt(UART1, UART_INT_RX);<br>        UART_Receive(UART1, rxbuf, 8, 0); \/\/half: 16\/2=8<br>        isRecv = 1;<br>    }<br>}<br>void TestUart_rcvIrq(void)<br>{<br>    const char txbuf[] = \"uart1 rx INT\\n\";<\/p>\n\n\n\n<p>    GPIO_AF_ENABLE(UART1_UARTRXD)<br>    GPIO_AF_ENABLE(UART1_UARTTXD);<br>    SYS_EnableAPBClock(APB_MASK_UART1);<\/p>\n\n\n\n<p>    UART_Init(UART1, 115200, UART_LCR_DATABITS_8, UART_LCR_STOPBITS_1,<br>    UART_LCR_PARITY_NONE, UART_LCR_FIFO_16);<\/p>\n\n\n\n<p>    UART_EnableInt(UART1, UART_INT_RX);<br>    UART_SetRxIntFifoLevel(UART1, UART_INT_FIFO_HALF);<br>    INT_EnableIRQ(UART1_IRQn, UART_PRIORITY);<\/p>\n\n\n\n<p>    UART_Send(UART1, txbuf, strlen(txbuf));<br>    while (1)<br>    {<br>        if (isRecv > 0)<br>        {<br>            UART_Send(UART1, rxbuf, 8);<br>            isRecv = 0;<br>        }<br>    }<br>}<\/p>\n\n\n\n<p>\/\/ test uart1 simple tx and rx<br>void TestUart_simple(void)<br>{<br>    char txbuf[] = \"simple uart1\\n\";<br>    char rxbuf[32];<\/p>\n\n\n\n<p>    GPIO_AF_ENABLE(UART1_UARTRXD)<br>    GPIO_AF_ENABLE(UART1_UARTTXD);<br>    SYS_EnableAPBClock(APB_MASK_UART1);<\/p>\n\n\n\n<p>    UART_Init(UART1, 115200, UART_LCR_DATABITS_8, UART_LCR_STOPBITS_1,<br>    UART_LCR_PARITY_NONE, UART_LCR_FIFO_16);<\/p>\n\n\n\n<p>    UART_Send(UART1, txbuf, strlen(txbuf));<br>    while (1)<br>    {<br>        int rLen = UART_Receive(UART1, rxbuf, 12, 0);<br>        if (rLen > 0)<br>        {<br>            UART_Send(UART1, rxbuf, rLen);<br>        }<br>    }<br>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/example_uart_rcvIqr.c include \"example.h\" \/\/ test uar [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","footnotes":""},"class_list":["post-867","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=867"}],"version-history":[{"count":2,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/867\/revisions"}],"predecessor-version":[{"id":869,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/867\/revisions\/869"}],"up":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}