RTL8772GWP芯片支持RGB模式LCD。用户不需要从头开始编写屏幕驱动程序,只需要几个简单的步骤就可以驱动LCD屏幕。RTL8772GWP的RGB信号是固定引脚,不能任意映射,只有一套,如下所示。在演示项目中,我们使用RGB888接口中的EK9716显示驱动程序,尺寸为 800 x 480 的面板作为目标显示,输入格式将使用RGB565,输出格式为RGB888。
└── Project: dashboard
└── app includes app main
├── menu_config.h
├── main.c
├── dashboard_init.c
├── flash_map.h
├── board.h
└── mem_config.h
└── Device includes startup code
├── startup_rtl.c
└── system_rtl.c
├── Lib includes all binary symbol files that user application is built on
├── Peripheral includes all peripheral drivers and module code used by the application
└── Profile includes BLE profiles or services used by the find my application
├── ancs_client.c
├── gatt_client.c
├── bas.c
├── dis.c
├── dfu_service.c
├── ota_service.c
└── tps.c tx power service
└── dfu includes the dashboard dfu application implementation
├── dfu_common.c
└── ble_dfu_transport.c
└── dfu_task includes the dashboard dfu task application implementation
├── dfu_main.c
├── dfu_task.c
└── dfu_app.c
├── rtk_gui includes all gui port
├── realgui/3rd includes Third-party library
├── realgui/app includes Reallek gui app
├── realgui/dc includes Reallek gui app
├── realgui/engine includes all gui engine
├── realgui/demo includes all gui demo
├── realgui/input includes all gui input
├── realgui/misc includes all gui misc
├── realgui/widget includes all gui widget
├── database includes all database
└── fs includes the file system
└── romfs.c
└── hal_drivers includes the dashboard hardware layer driver
├── drv_flash.c
├── drv_dlps.c
├── drv_lcd.c
└── drv_gpio.c
└── lcd_low_driver includes the dashboard hardware layer lcd driver
└── EK9716_800480_rgb.c
└── Compiler includes the dashboard compiler
├── syscall.c
└── syscall_mem.c
└── bt_app includes the dashboard bluetooth app
├── app_le_link_util.c
├── app_ble_bas.c
├── ancs.c
├── app_gap.c
├── app_task.c
├── his_ms.c
├── writband_private_service.c
├── app_ble_ota.c
├── app_ble_bwps.c
└── app_ble_dfu.c
└── communication includes all communication drivers and module code used by the application
voidapp_dashboard_create_main_display(gui_win_t*target_main_display){/* set update callback */gui_win_set_animate(target_main_display,1000,-1,paint_main_display_cb,target_main_display);/* set Image data */dashboard_background=gui_img_create_from_mem(target_main_display,"dashboard_background",BACKGROUND_BIN,0,0,800,480);speed_high_digital=gui_img_create_from_mem(target_main_display,"speed_high_digital",SPED0_BIN,360,202,40,60);speed_low_digital=gui_img_create_from_mem(target_main_display,"speed_low_digital",SPED0_BIN,406,202,40,60);bluetooth_status=gui_img_create_from_mem(target_main_display,"bluetooth_status",BTOF_BIN,48,10,23,30);left_turn_light_status=gui_img_create_from_mem(target_main_display,"left_turn_light_status",TL_OF_BIN,48,208,42,40);right_turn_light_status=gui_img_create_from_mem(target_main_display,"right_turn_light_status",TR_OF_BIN,710,208,42,40);hour_high_digital=gui_img_create_from_mem(target_main_display,"hour_high_digital",TIMER0_BIN,355,12,9,16);hour_low_digital=gui_img_create_from_mem(target_main_display,"hour_low_digital",TIMER0_BIN,366,12,9,16);min_high_digital=gui_img_create_from_mem(target_main_display,"min_high_digital",TIMER0_BIN,387,12,9,18);min_low_digital=gui_img_create_from_mem(target_main_display,"min_low_digital",TIMER0_BIN,399,12,9,18);tense_high_digital=gui_img_create_from_mem(target_main_display,"tense_high_digital",APM_A_BIN,417,12,9,18);tense_low_digital=gui_img_create_from_mem(target_main_display,"tense_low_digital",APM_M_BIN,432,12,9,18);bat_high_digital=gui_img_create_from_mem(target_main_display,"bat_high_digital",TIMER0_BIN,394,360,9,18);bat_low_digital=gui_img_create_from_mem(target_main_display,"bat_low_digital",TIMER0_BIN,406,360,9,18);tel_box=gui_img_create_from_mem(target_main_display,"tel_box",TELBOX_BIN,253,410,295,49);tel_accept=gui_img_create_from_mem(target_main_display,"tel_accept",TELBOX_BIN,253,410,295,49);tel_reject_end=gui_img_create_from_mem(target_main_display,"tel_reject_end",TELBOX_BIN,253,410,295,49);refuse_button=gui_img_create_from_mem(target_main_display,"refuse_button",REFUS_BIN,263,416,36,36);ans_button=gui_img_create_from_mem(target_main_display,"ans_button",ANS_BIN,500,416,36,36);tel_box_left_button=gui_img_create_from_mem(target_main_display,"tel_box_left_button",SYMB1_BIN,315,416,36,36);tel_box_right_button=gui_img_create_from_mem(target_main_display,"tel_box_right_button",SYMB2_BIN,479,416,36,36);dashboard_pointer=gui_img_create_from_mem(target_main_display,"dashboard_Cpointer",DASHBOARD_0_BIN,243,84,0,0);short_message=gui_img_create_from_mem(target_main_display,"short_message",MESSAGE_BIN,221,0,359,80);/* set font data */app_phone_datacurrent_phone_status;app_dashboard_data_get_phone_status(¤t_phone_status);short_tel_number=gui_text_create(target_main_display,"short_tel_number",322,415,158,30);memcpy(&show_tel_number[0],¤t_phone_status.current_phone_number[0],current_phone_status.current_phone_number_len);gui_text_set(short_tel_number,(char*)show_tel_number,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_phone_status.current_phone_number_len,28);gui_text_mode_set(short_tel_number,CENTER);short_tel_accept=gui_text_create(target_main_display,"short_tel_accept",360,415,800,30);gui_text_set(short_tel_accept,"calling",GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),7,32);app_message_datacurrent_message_status;app_dashboard_data_get_message_data_update(¤t_message_status);memcpy(&show_message_data[0],¤t_message_status.wechat_msg[0],current_message_status.wechat_msg_len);short_message_data=gui_text_create(target_main_display,"short_message_data",300,10,240,50);gui_text_set(short_message_data,(char*)show_message_data,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),(current_message_status.wechat_msg_len-1),32);gui_text_mode_set(short_message_data,MULTI_LEFT);/* Prepare the intial data */app_dashboard_update_main_display_time_info();app_dashboard_update_main_display_tense_apm_info(app_dashboard_data_get_tense_timer_info());app_dashboard_update_main_display_battery_info(app_dashboard_data_get_battery_level());app_dashboard_update_main_display_speed_info(app_dashboard_data_get_car_speed());app_dashboard_update_main_display_turn_info(app_dashboard_data_get_car_turn_info());app_dashboard_update_main_display_bluetooth_info(app_dashboard_data_get_bluetooth_status());app_dashboard_update_main_display_phone_infor(¤t_phone_status);app_dashboard_update_main_display_message_infor(¤t_message_status);}
BLE连接状态布局
voidapp_dashboard_create_connected_display(gui_win_t*target_connected_display){/* set update callback */gui_win_set_animate(target_connected_display,1000,-1,paint_connected_display_cb,target_connected_display);/* set Image data */dashboard_c_background=gui_img_create_from_mem(target_connected_display,"dashboard_c_background",BACKGROUND_C_BIN,0,0,800,480);speed_high_c_digital=gui_img_create_from_mem(target_connected_display,"speed_high_c_digital",SPED_C0_BIN,214,232,27,40);speed_low_c_digital=gui_img_create_from_mem(target_connected_display,"speed_low_c_digital",SPED_C0_BIN,251,232,27,40);hour_high_c_digital=gui_img_create_from_mem(target_connected_display,"hour_high_digital",TIMER0_BIN,355,12,9,16);hour_low_c_digital=gui_img_create_from_mem(target_connected_display,"hour_low_digital",TIMER0_BIN,366,12,9,16);min_high_c_digital=gui_img_create_from_mem(target_connected_display,"min_high_digital",TIMER0_BIN,387,12,9,18);min_low_c_digital=gui_img_create_from_mem(target_connected_display,"min_low_digital",TIMER0_BIN,399,12,9,18);tense_high_c_digital=gui_img_create_from_mem(target_connected_display,"tense_high_c_digital",APM_CA_BIN,417,12,9,18);tense_low_c_digital=gui_img_create_from_mem(target_connected_display,"tense_low_c_digital",APM_CM_BIN,432,12,9,18);bat_high_c_digital=gui_img_create_from_mem(target_connected_display,"bat_high_c_digital",TIMER0_BIN,238,371,9,18);bat_low_c_digital=gui_img_create_from_mem(target_connected_display,"bat_low_c_digital",TIMER0_BIN,250,371,9,18);left_turn_light_c_status=gui_img_create_from_mem(target_connected_display,"left_turn_light_c_status",TL_OF_C_BIN,110,10,42,40);right_turn_light_c_status=gui_img_create_from_mem(target_connected_display,"right_turn_light_c_status",TR_OF_C_BIN,665,10,42,40);navi_c_status=gui_img_create_from_mem(target_connected_display,"navi_c_status",NAVI_C1_BIN,505,170,268,218);refuse_c_button=gui_img_create_from_mem(target_connected_display,"refuse_c_button",REFUS_BIN,502,410,36,36);ans_c_button=gui_img_create_from_mem(target_connected_display,"ans_c_button",ANS_BIN,740,410,36,36);tel_box_left_c_button=gui_img_create_from_mem(target_connected_display,"tel_box_left_c_button",SYMB1_BIN,554,414,36,36);tel_box_right_c_button=gui_img_create_from_mem(target_connected_display,"tel_box_right_c_button",SYMB2_BIN,718,414,36,36);dashboard_Cpointer=gui_img_create_from_mem(target_connected_display,"dashboard_Cpointer",DASHBOARD_C2_BIN,110,133,9,18);short_c_message=gui_img_create_from_mem(target_connected_display,"short_c_message",MESSAGE_BIN,221,0,359,80);/* set font data */app_navi_datacurrent_navi_data;app_dashboard_data_get_navi_data_update(¤t_navi_data);memcpy(&show_c_navigation_msg[0],¤t_navi_data.navigation_msg[0],current_navi_data.navigation_num_len);short_c_navi_message_1=gui_text_create(target_connected_display,"short_c_navi_message_1",490,88,150,60);gui_text_set(short_c_navi_message_1,(char*)show_c_navigation_msg,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_navi_data.navigation_num_len,56);gui_text_mode_set(short_c_navi_message_1,RIGHT);memcpy(&show_c_navigation_unit[0],¤t_navi_data.navigation_unit[0],current_navi_data.navigation_unit_len);short_c_navi_message_3=gui_text_create(target_connected_display,"short_c_navi_message_3",640,108,150,40);gui_text_set(short_c_navi_message_3,(char*)show_c_navigation_unit,GUI_FONT_SRC_BMP,gui_rgb(0xcc,0xcc,0xcc),current_navi_data.navigation_unit_len,32);gui_text_mode_set(short_c_navi_message_3,LEFT);memcpy(&show_c_road_names[0],¤t_navi_data.road_names[0],current_navi_data.road_num_len);short_c_navi_message_2=gui_text_create(target_connected_display,"short_c_navi_message_2",490,148,300,40);gui_text_set(short_c_navi_message_2,(char*)show_c_road_names,GUI_FONT_SRC_BMP,gui_rgb(0xcc,0xcc,0xcc),current_navi_data.road_num_len,32);gui_text_mode_set(short_c_navi_message_2,CENTER);app_phone_datacurrent_phone_status;app_dashboard_data_get_phone_status(¤t_phone_status);short_c_tel_number=gui_text_create(target_connected_display,"short_c_tel_number",560,410,158,30);memcpy(&show_c_tel_number[0],¤t_phone_status.current_phone_number[0],current_phone_status.current_phone_number_len);gui_text_set(short_c_tel_number,(char*)show_c_tel_number,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_phone_status.current_phone_number_len,28);gui_text_mode_set(short_c_tel_number,CENTER);short_c_tel_accept=gui_text_create(target_connected_display,"short_c_tel_accept",600,410,800,30);gui_text_set(short_c_tel_accept,"calling",GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),7,28);app_message_datacurrent_message_status;app_dashboard_data_get_message_data_update(¤t_message_status);memcpy(&show_c_message_data[0],¤t_message_status.wechat_msg[0],current_message_status.wechat_msg_len);short_c_message_data=gui_text_create(target_connected_display,"short_c_message_data",300,10,240,50);gui_text_set(short_c_message_data,(char*)show_c_message_data,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),(current_message_status.wechat_msg_len-1),32);gui_text_mode_set(short_c_message_data,MULTI_LEFT);/* Prepare the intial data */app_dashboard_update_connected_display_time_info();app_dashboard_update_connected_display_tense_apm_info(app_dashboard_data_get_tense_timer_info());app_dashboard_update_connected_display_battery_info(app_dashboard_data_get_battery_level());app_dashboard_update_connected_display_speed_info(app_dashboard_data_get_car_speed());app_dashboard_update_connected_display_turn_info(app_dashboard_data_get_car_turn_info());app_dashboard_update_connected_display_phone_infor(¤t_phone_status);app_dashboard_update_connected_display_message_infor(¤t_message_status);}
通信任务负责BLE数据传输的管理,根据当前传输数据命令格式将数据打包并通过蓝牙协议栈发送出去。 客户一般使用自己的蓝牙数据交互格式,任务可以作为发送方法的参考,也可以自己实现。开发者必须参考 Bluetooth,熟悉BLE服务结构以及如何处理消息。在本设计文档中,我们将通过仪表板应用程序的指定 BLE 服务作为演示。开发人员可以根据自己的产品需求选择手机应用程序采用哪些 BLE 服务。
移动应用程序成功连接到仪表板设备后,应用程序可以使用 BLE 写入请求向设备传送必要的信息,所有消息都将通过特征写入。
/** * @brief write characteristic data from stack. ** @param ServiceId ServiceId generated when register to upper stack.* @param iAttribIndex Attribute index of getting characteristic data.* @param wLength length of data to be written.* @param pValue pointer of data to be written.* @return TProfileResult profile procedure results. */T_APP_RESULTbwps_service_attr_write_cb(uint8_tconn_id,T_SERVER_IDservice_id,uint16_tattrib_index,T_WRITE_TYPEwrite_type,uint16_tlength,uint8_t*p_value,P_FUN_WRITE_IND_POST_PROC*p_write_ind_post_proc){T_APP_RESULTwCause=APP_RESULT_SUCCESS;uint8_t*buf=NULL;APP_PRINT_INFO2("bwps_service_attr_write_cb: attrib_index = %d, data %b",attrib_index,CE_BINARY(length,p_value));if(p_value==NULL){APP_PRINT_ERROR0("bwps_service_attr_write_cb, p_value is NULL");wCause=APP_RESULT_INVALID_VALUE_SIZE;returnwCause;}switch(attrib_index){default:wCause=APP_RESULT_ATTR_NOT_FOUND;APP_PRINT_ERROR2("bwps_service_attr_write_cb Error: attrib_index 0x%x, length %d",attrib_index,length);break;caseGATT_SRV_BWPS_TX_INDEX:APP_PRINT_INFO0("bwps_service_attr_write_cb, GATT_SRV_BWPS_TX_INDEX");/* copy gatt write value in tx_buffer, the first byte is value length*/#if 1buf=malloc((length+1)*sizeof(uint8_t));buf[0]=length;memcpy(buf+1,p_value,length);externvoid*raw_data_receive_queue_handle;if(os_msg_send(raw_data_receive_queue_handle,&buf,0)==false){APP_PRINT_ERROR0("send_msg_to_l1send_task_fail");free(buf);}#endifbreak;caseGATT_SRV_BWPS_DEVNAME_INDEX:APP_PRINT_INFO0("BWPS: update device name\n");break;}returnwCause;}
/*** @brief Send CAN data.* @param notused: The parameter is not used.* @param p_data: The message data.* @note API from CANFestival* @return None*/unsignedcharcanSend(CAN_PORTnotused,Message*p_data){staticCAN_TxMsgDefCO_TxMsg;CO_TxMsg.CO_TxFrame.frame_brs_bit=CAN_BRS_NO_SWITCH_BIT_TIMING;CO_TxMsg.CO_TxFrame.standard_frame_id=p_data->cob_id;CO_TxMsg.CO_TxFrame.extend_frame_id=0x00;CO_TxMsg.CO_TxFrame.frame_type=CAN_CheckFrameType(p_data->rtr,CAN_IDE_STANDARD_FORMAT,CAN_EDL_STARDARD_FRAME);CO_TxMsg.CO_TxFrame.auto_reply_bit=RESET;CO_TxMsg.dlc=p_data->len;APP_PRINT_INFO2("[canSend] dlc = %d, std id = 0x%X",CO_TxMsg.dlc,CO_TxMsg.CO_TxFrame.standard_frame_id);for(uint8_ti=0;i<CO_TxMsg.dlc;i++){CO_TxMsg.data[i]=p_data->data[i];APP_PRINT_INFO2("[canSend] CO_TxMsg.data[%d] = 0x%X",i,CO_TxMsg.data[i]);}if(!loop_queue_is_full(p_canSend_queue,sizeof(CAN_TxMsgDef))){if(false==loop_queue_write_buf(p_canSend_queue,&CO_TxMsg,sizeof(CAN_TxMsgDef),true)){T_IO_MSGio_can_msg;io_can_msg.type=IO_MSG_TYPE_CAN_SEND;app_send_msg_to_cantask(&io_can_msg);}else{APP_PRINT_ERROR0("Write TxMsg failed!");return0xFF;}}return0;}
CAN 接收任务
/*** @brief basic configuration of CAN rx message buffer.* @param None* @return None*/voidcan_basic_rx(uint8_tMsgBuf_index){/* set CAN Rx message buffer */CANError_TypeDefrx_error;CANRxFrame_TypeDefrx_frame_type;rx_frame_type.msg_buf_id=MsgBuf_index;rx_frame_type.frame_rtr_mask=SET;rx_frame_type.frame_ide_mask=SET;rx_frame_type.frame_id_mask=CAN_FRAME_ID_MASK_MAX_VALUE;#if CAN_RX_DMA_ENrx_frame_type.rx_dma_en=SET;#elserx_frame_type.rx_dma_en=RESET;#endifrx_frame_type.auto_reply_bit=RESET;rx_error=CAN_SetMsgBufRxMode(&rx_frame_type);CAN_MBRxINTConfig(rx_frame_type.msg_buf_id,ENABLE);APP_PRINT_INFO2("[CAN] set CAN Rx MB_%d, rx_error %d",MsgBuf_index,rx_error);}/*** @brief dma initialize of CAN rx.* @param None* @return None*/voidcan_start_rx_dma(uint32_tdes_addr,uint32_tbuffer_size){/* Turn on gdma clock */RCC_PeriphClockCmd(APBPeriph_GDMA,APBPeriph_GDMA_CLOCK,ENABLE);GDMA_InitTypeDefGDMA_InitStruct;GDMA_StructInit(&GDMA_InitStruct);/* GDMA initial*/GDMA_InitStruct.GDMA_ChannelNum=GDMA_CHANNEL_NUM;GDMA_InitStruct.GDMA_DIR=GDMA_DIR_PeripheralToMemory;GDMA_InitStruct.GDMA_BufferSize=buffer_size;GDMA_InitStruct.GDMA_SourceInc=DMA_SourceInc_Fix;GDMA_InitStruct.GDMA_DestinationInc=DMA_DestinationInc_Inc;GDMA_InitStruct.GDMA_SourceDataSize=GDMA_DataSize_Word;GDMA_InitStruct.GDMA_DestinationDataSize=GDMA_DataSize_Word;GDMA_InitStruct.GDMA_SourceMsize=GDMA_Msize_8;GDMA_InitStruct.GDMA_DestinationMsize=GDMA_Msize_8;GDMA_InitStruct.GDMA_SourceAddr=(uint32_t)&(CAN->CAN_RX_DMA_DATA);GDMA_InitStruct.GDMA_DestinationAddr=des_addr;GDMA_InitStruct.GDMA_SourceHandshake=GDMA_Handshake_CAN_BUS_RX;GDMA_InitStruct.GDMA_Secure_En=ENABLE;GDMA_Init(GDMA_Channel,&GDMA_InitStruct);GDMA_INTConfig(GDMA_CHANNEL_NUM,GDMA_INT_Transfer,ENABLE);/* GDMA irq init */NVIC_InitTypeDefNVIC_InitStruct;NVIC_InitStruct.NVIC_IRQChannel=GDMA_Channel_IRQn;NVIC_InitStruct.NVIC_IRQChannelCmd=(FunctionalState)ENABLE;NVIC_InitStruct.NVIC_IRQChannelPriority=3;NVIC_Init(&NVIC_InitStruct);GDMA_Cmd(GDMA_CHANNEL_NUM,ENABLE);}