完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 voidpbq 于 2022-12-8 23:35 编辑 # 前言 本章介绍如何实现迪文屏与飞凌OKT507的uart事件通信。 # 代码 从上到下是uart_example.c、dwin.c、dwin.h、makefile ```c #include "dwin.h" #include #include #include #include #include #include #include #include #include #include #include #include "stdbool.h" // #include "dwin.h" // #include "//delay.h" #define uint8_t u_int8_t #define bool _Bool extern void u8_to_char(uint8_t * , char ** ); extern int judge_dwin_cmd(uint8_t ** ); extern int get_len(uint8_t *cmd_u8); extern dwin_event_flag uart_judge_dwin_event(i_dwin_cmd * cmd); extern i_dwin_cmd temp_cmd_recv; extern dwin_event_key event_key_list[EVENT_KEY_NUM_MAX]; extern dwin_event_key_spec event_key_spec[EVENT_KEY_SPEC_NUM_MAX]; // extern char* u8_to_char(uint8_t * ); extern c_dwin_cmd cmd_recv_char; // from dwin extern c_dwin_cmd cmd_send_char; // send to dwin extern dwin_event_flag c_judge_dwin_event(c_dwin_cmd * cmd); extern void c_dwin_cmd_analysis(char * in,c_dwin_cmd *cmd); extern void c_print_cmd(c_dwin_cmd *cmd); // extern void print_uint8(uint8_t * in); // #define false FALSE // #define true TRUE /* E53模块中 * UART0_RX_M0 -> GPIO0_B6 * UART0_TX_M0 -> GPIO0_B7 */ #define UART_ID 0 #define UART_RECV_LEN 1024 #define BUF_RX_MAX 512 #define LEN_CHAR_TEMP 17 c_dwin_cmd cmd_char; int search_str_end(uint8_t *str_z, int count) { int temp_zero = 1; int temp_count = count -1; // 有效字符11个,12个是0x00 printf("init count = %d, temp_count = %dn",count,temp_count); uint8_t *str_temp1 = str_z; while(1) { printf("str = [%02X], temp_zero = [%d], temp_count = [%d]n",*str_temp1,temp_zero,temp_count); // if find 10 zero, will return count if(*str_temp1 != 0x00) { printf("value = %02X, %ldn",*str_temp1,str_temp1-str_z); temp_count += temp_zero; str_temp1++; temp_zero = 1; } else { temp_zero++; printf("value = %02X, %ldn",*str_temp1,str_temp1-str_z); } if(temp_zero > 10) break; } printf("init count = %d, temp_count = %dn",count,temp_count); return temp_count; } int my_strlen(uint8_t *str) { printf("enter my_strlen"); uint8_t *str_temp = str; // assert(str); int count = 0; // while (*str != ' |