From: p15692025051 <846603105@qq.com> Date: Tue, 30 Sep 2025 08:02:44 +0000 (+0800) Subject: 马达驱动提交 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=1dfc1e9b35621858d9c79e82f4bf372df6c78a46;p=mirrors%2FFX01.git 马达驱动提交 恢复make.py --- diff --git a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c index a440f87..801ded4 100644 --- a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c +++ b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c @@ -35,7 +35,11 @@ #include "app_msg.h" #include "aic_ogg.h" #include "efuse.h" -// #include "bk_make_time.h" +#if SUPPORT_MOT +#include "mot_dev.h" +#endif +#include "bk_make_time.h" + // #include "opus/include/opus.h" char FXH01_Version[100]; @@ -492,8 +496,9 @@ int check_text(char *text,int ret_str_len) } is_save_VC_cfg = 1; ret = 0; - + #if BK_SOCKET_IOT IOT_update_statu(3,"",""); + #endif goto RET; } @@ -1518,8 +1523,9 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 strncpy(AI_ASR_str,AI_ASR_str_tmp,AI_ASR_STR_MAX_LEN); bk_printf("vad间隔时间长,判断为两次对话:%s",AI_ASR_str); } - - IOT_update_statu(1,"thinking",""); + #if BK_SOCKET_IOT + IOT_update_statu(1,"thinking",""); + #endif } } else if(strstr(recv_buff,"\"vad.active\""))//vad触发 @@ -1552,9 +1558,9 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 VC_state = VC_State_TTSStart; play_data_len = 0; - + #if BK_SOCKET_IOT IOT_update_statu(1,"speaking",""); - + #endif one_receive_bin=0; if(outbound_attributes_format == attributes_format_OPUS){ @@ -1586,9 +1592,9 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 // AI_AMP_MSG_put(0,0,VC_PLAY_START);//打开声音 startsave_tts=0; - + #if BK_SOCKET_IOT IOT_update_statu(1,"idle",""); - + #endif // fp_tts_save=fopen("C:/cmd_local_301.pcm","wb"); // bk_printf("C:/cmd_local_301.pcm %d",one_receive_bin); @@ -2958,8 +2964,8 @@ int AI_VC_start(char is_greeting) // aic_gpio_output(GPIO_25,GPIO_OUTPUT_LVL_HIGH );//led // aic_gpio_output(GPIO_30,GPIO_OUTPUT_LVL_HIGH );//led // aic_gpio_output(GPIO_31,GPIO_OUTPUT_LVL_HIGH );//led - // aic_gpio_output(GPIO_GPO_8,GPIO_OUTPUT_LVL_HIGH );//马达 - // aic_gpio_output(GPIO_GPO_1,GPIO_OUTPUT_LVL_LOW );//马达 + + // aic_gpio_output(GPIO_20,GPIO_OUTPUT_LVL_HIGH );//马达 // app_audio_set_master_volume(8); @@ -3050,8 +3056,9 @@ int AI_VC_start(char is_greeting) } - - IOT_update_statu(1,"listening",""); + #if BK_SOCKET_IOT + IOT_update_statu(1,"listening",""); + #endif net_status_count=0; //aos_sleep(5); AI_VC_send_satrt(is_greeting);// @@ -3080,10 +3087,10 @@ void AI_VC_Close(void) // aic_gpio_output(GPIO_25,GPIO_OUTPUT_LVL_LOW ); // aic_gpio_output(GPIO_30,GPIO_OUTPUT_LVL_LOW ); // aic_gpio_output(GPIO_31,GPIO_OUTPUT_LVL_LOW ); - // aic_gpio_output(GPIO_GPO_8,GPIO_OUTPUT_LVL_LOW ); - // aic_gpio_output(GPIO_GPO_1,GPIO_OUTPUT_LVL_LOW); + // aic_gpio_output(MOT_EN_FWD,GPIO_OUTPUT_LVL_LOW ); + // aic_gpio_output(MOT_EN_REV,GPIO_OUTPUT_LVL_LOW); // aic_gpio_output(GPIO_20,GPIO_OUTPUT_LVL_LOW ); - + MTO_stop(); bk_printf("AI_VC_Close!!!!!!!!!!!!"); websocket_deconnect_VC();//断开连接 //销毁录音线程 @@ -3258,7 +3265,7 @@ void AI_VC_Close(void) AI_VC_Close_lock = 0; } - +int MSG_Type_error = 0; aos_status AI_AMP_MSG_put(const char *data,u32 len,AI_AMP_MSG_Type MSG_Type) { AI_AMP_MSG_queue_t AI_AMP_MSG_queue_data = {0}; @@ -3279,11 +3286,18 @@ aos_status AI_AMP_MSG_put(const char *data,u32 len,AI_AMP_MSG_Type MSG_Type) AI_AMP_MSG_queue_data.MSG_Type=MSG_Type; if(AI_AMP_task_queue && AOS_SUCCESS!=aos_send_to_queue(AI_AMP_task_queue,&AI_AMP_MSG_queue_data,AOS_NO_WAIT)) { - bk_printf("AI_AMP_MSG_put :aos_send_to_queue ERROR\n\n"); + //bk_msg_printf("AI_AMP_MSG_put :aos_send_to_queue ERROR MSG_Type:%d\n\n",MSG_Type); + MSG_Type_error = MSG_Type; if(!AI_AMP_MSG_queue_data.data) aic_free(AI_AMP_MSG_queue_data.data); return AOS_ERROR; } + if(MSG_Type_error!=0) + { + bk_msg_printf("AI_AMP_MSG_put :aos_send_to_queue ERROR MSG_Type:%d\n\n",MSG_Type_error); + MSG_Type_error = 0; + } + //bk_msg_printf("AI_AMP_MSG_put2 MSG_Type:%d",MSG_Type); return AOS_SUCCESS; } @@ -3301,7 +3315,7 @@ static void sys_60S_timeout(void *param) - IOT_heart(); + //IOT_heart(); } @@ -3370,7 +3384,7 @@ static void sys_10S_timeout_even(void) // extern char *ota_url; - const char *bk_make_timer = "V1_2_250730_8"; + //const char *bk_make_timer = "V1_2_250730_8"; void play_tts_my_local(char *filename) { @@ -3452,7 +3466,6 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 dev_authentication_init(); - count =50; while(count --) { @@ -3553,8 +3566,9 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 // { // aos_sleep(1000); // } - - + #if SUPPORT_MOT + mot_init(); +#endif if(vc_cfg.dev_type == DEV_JSWM)//金三完美使用dmp配置开场白 { AI_VC_start(1); @@ -3681,6 +3695,17 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 if(AI_AMP_msg.data) uart_write(ai_uart_handle,AI_AMP_msg.data, AI_AMP_msg.len); break; + case AI_KEY2_PRESS: + bk_printf("AI_KEY2_PRESS"); + #if SUPPORT_MOT + mot_nod(5); + #endif + break; + case MOT_GPIO_HANDLE_CB: + + mot_gpio_handle_cb(AI_AMP_msg.data); + break; + default: break; } diff --git a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h index 4eb7bb9..08b8871 100644 --- a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h +++ b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h @@ -1,15 +1,15 @@ #include "aic_osa.h" #define SUPPORT_OPUS 1 - -#define BK_SOCKET_IOT 1 +#define SUPPORT_MOT 0 //马达驱动 +#define BK_SOCKET_IOT 0 #define BK_LOG_NONE 0//不打印 #define BK_LOG_UART 1//串口打印 #define BK_LOG_USB 2//USB打印 - #define BK_LOG_CFG BK_LOG_USB +#define BK_LOG_CFG BK_LOG_UART typedef enum { @@ -78,10 +78,12 @@ typedef enum AI_AMP_MSG AI_KEY_RELEASE,//AI键释放 AI_KEY_LONG_PRESS,//AI键长按 AI_KEY_LONG_RELEASE,//AI键长按释放 + AI_KEY2_PRESS,//KEY2 PWK_KEY_RELEASE,//侧键 PLAY_AUDIO_FILE,//播放本地音频文件 PLAY_FILE_STREAM_DATA,//播放本地文件,用音频流的方式 AI_TIMER_EVENT,//定时器事件 + MOT_GPIO_HANDLE_CB, AI_PRINTF,//打印 } AI_AMP_MSG_Type; typedef struct diff --git a/2.code/aicos/app/AI_AMP_2_5/CMakeLists.txt b/2.code/aicos/app/AI_AMP_2_5/CMakeLists.txt index ccbf66c..27346ec 100644 --- a/2.code/aicos/app/AI_AMP_2_5/CMakeLists.txt +++ b/2.code/aicos/app/AI_AMP_2_5/CMakeLists.txt @@ -12,6 +12,7 @@ aic_library_sources_ifdef( ${AIC_SOURCE_ROOT}/app/AI_AMP_2_5/dev_authentication.c ${AIC_SOURCE_ROOT}/app/AI_AMP_2_5/bk_opus_coder.c ${AIC_SOURCE_ROOT}/app/AI_AMP_2_5/bk_iot.c + ${AIC_SOURCE_ROOT}/app/AI_AMP_2_5/mot_dev.c ) diff --git a/2.code/aicos/app/AI_AMP_2_5/bk_key.c b/2.code/aicos/app/AI_AMP_2_5/bk_key.c index 203d896..cf5ca49 100644 --- a/2.code/aicos/app/AI_AMP_2_5/bk_key.c +++ b/2.code/aicos/app/AI_AMP_2_5/bk_key.c @@ -32,12 +32,14 @@ static int32_t bk_kpc_callback(void *p_param, uint32_t size) switch (key_arr->key[i].key_event) { case KPC_KEY_EVENT_PRESS://按下 // bk_printf("[%d]AI_key_press",key_arr->key[i].key_value); - if (key_arr->key[i].key_value == 0) {//AI键 AI_AMP_MSG_put(0, 0, AI_KEY_PRESS); }else if(key_arr->key[i].key_value == 1) {//AI键 AI_AMP_MSG_put(0, 0, AI_KEY_PRESS); + }else if(key_arr->key[i].key_value == 2) {//按键2键 + + AI_AMP_MSG_put(0, 0, AI_KEY2_PRESS); } break; case KPC_KEY_EVENT_RELEASE://释放 @@ -67,7 +69,7 @@ static int32_t bk_kpc_callback(void *p_param, uint32_t size) AI_AMP_MSG_put(0, 0, AI_KEY_LONG_RELEASE); } else if(key_arr->key[i].key_value == 2) {//PWK键 - AI_AMP_MSG_put(0, 0, PWK_KEY_RELEASE); + //AI_AMP_MSG_put(0, 0, PWK_KEY_RELEASE); } // bk_printf("[%d]AI_key_long_press",key_arr->key[i].key_value); diff --git a/2.code/aicos/app/AI_AMP_2_5/mot_dev.c b/2.code/aicos/app/AI_AMP_2_5/mot_dev.c new file mode 100644 index 0000000..dce46d9 --- /dev/null +++ b/2.code/aicos/app/AI_AMP_2_5/mot_dev.c @@ -0,0 +1,427 @@ +#include +#include +#include +#include +#include "app_msg.h" +#include "aic_net_pdp_mgr.h" +#include "aic_network_pcap.h" +#include "aic_websocket_client.h" +#include "cJSON.h" +#include +#include "aic_osa.h" +#include "app_audio.h" +#include "bk_ringbuf.h" +#include "bk_websocket.h" +#include "mot_dev.h" +#include "bk_key.h" +#include "aic_srv_tele_sim.h" +#include +#include "aic_version.h" + + +#include "dev_authentication.h" +#include "imsl_vad.h" +#include "imsl_kws.h" +#include "aic_srv_tele_ex.h" +#include "power_supply.h" +#include "sysoff.h" +#include "app_msg.h" +#include "aic_ogg.h" +#include "efuse.h" +#include "gpo_inc.h" +#include "mot_dev.h" +#define MOT_EN_FWD_IO GPO_2 //马达驱动正反转,20脚 GPO2 +#define MOT_EN_REV_IO GPIO_14 //马达驱动正反转,74脚 GPIO_14 +#define MOT_TOP_SITE_IO GPIO_1 //马达转到最上位置io,56脚 +#define MOT_MIDDLE_SITE_IO GPIO_0 //马达转到最中位置io,77脚 +#define MOT_BOOTOM_SITE_IO GPIO_7//马达转到最下位置io ,81脚 +static unsigned char mot_nod_count = 0;//点头次数 +static unsigned char mot_nod_state = 0;//当前点头方向,0向下,1向上 +static unsigned char mot_MIDDLE_flag = 0;//判断当前有没有回正 +static void mot_gpio_handle(void *param) +{ + // aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//停止马达 + // aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 + //mot_dev_MSG_put((char *)param,strlen(param),MOT_GPIO_HANDLE_CB); +} +void mot_gpio_handle_cb(void *param) +{ + if(!param) + return; + static char old_mot_state = 0; + char mot_state = 0; + bk_printf("mot_gpio_handle:%s",param); + if(strcmp(param,"TOP") == 0) + { + bk_printf("mot_gpio_handle:TOP"); + mot_state = 1; + } + if(strcmp(param,"MIDDLE") == 0) + { + bk_printf("mot_gpio_handle:MIDDLE"); + mot_state = 2; + } + if(strcmp(param,"BOOTOM") == 0) + { + bk_printf("mot_gpio_handle:BOOTOM"); + mot_state = 3; + } + + if(aic_gpio_level_get(MOT_TOP_SITE_IO) == 0) + { + mot_state = 1; + } + else if(aic_gpio_level_get(MOT_MIDDLE_SITE_IO) == 0) + { + mot_state = 2; + } + else if(aic_gpio_level_get(MOT_BOOTOM_SITE_IO) == 0) + { + mot_state = 3; + } + bk_printf("mot_gpio_handle:mot_nod_state:%d,mot_nod_count:%d,mot_state:%d",mot_nod_count,mot_nod_count,mot_state); + // bk_printf("mot_gpio_handle:MOT_MIDDLE_SITE_IO:%d",aic_gpio_level_get(MOT_MIDDLE_SITE_IO)); + // bk_printf("mot_gpio_handle:MOT_BOOTOM_SITE_IO:%d",aic_gpio_level_get(MOT_BOOTOM_SITE_IO)); + if(mot_nod_count|| mot_MIDDLE_flag) + { + if( mot_state == 1 )//到最顶端 + { + + head_drop(); + if(old_mot_state != mot_state && mot_nod_count>0) + mot_nod_count--; + mot_nod_state = 0;//向下 + bk_printf("到顶部,向下"); + }else if(mot_state == 2)//到中间 + { + if(mot_nod_state == 0)//向下 + { + head_drop(); + bk_printf("到中间,向下"); + }else + { + bk_printf("到中间,向上"); + head_up(); + } + if(mot_nod_count == 0) + { + bk_printf("跑完,停止"); + MTO_stop(); + } + }else if(mot_state == 3)//到底部 + { + + // if(mot_nod_state == 0) + // { + bk_printf("到底部,向上"); + head_up(); + mot_nod_state = 1;//向上 + // }else + // { + // bk_printf("到底部,向上"); + // head_drop(); + // } + + } + + }else + { + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//停止马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 + } + old_mot_state = mot_state; +} +static void mot_nod1(void);//点头处理; +static void mot_nod2(void);//点头处理; +static void mot_nod3(void);//点头处理3 +static aos_thread_id mot_dev_task_id = 0; +static aos_queue_ptr mot_dev_task_queue = NULL; +aos_status mot_dev_MSG_put(const char *data,u32 len,mot_dev_MSG_Type MSG_Type) +{ + mot_dev_MSG_queue_t mot_dev_MSG_queue_data = {0}; + //bk_msg_printf("mot_dev_MSG_put1 MSG_Type:%d",MSG_Type); + if(len >0) + { + mot_dev_MSG_queue_data.data = aic_malloc(len+1); + memset(mot_dev_MSG_queue_data.data ,0,len+1); + if(!mot_dev_MSG_queue_data.data) + { + //bk_msg_printf("AI_VC_send_data aic_malloc ERROR!!!!!!!!!!"); + return AOS_ERROR; + } + memcpy(mot_dev_MSG_queue_data.data,data,len); + mot_dev_MSG_queue_data.len=len; + } + + mot_dev_MSG_queue_data.MSG_Type=MSG_Type; + if(mot_dev_task_queue && AOS_SUCCESS!=aos_send_to_queue(mot_dev_task_queue,&mot_dev_MSG_queue_data,AOS_NO_WAIT)) + { + //bk_msg_printf("mot_dev_MSG_put :aos_send_to_queue ERROR MSG_Type:%d\n\n",MSG_Type); + if(!mot_dev_MSG_queue_data.data) + aic_free(mot_dev_MSG_queue_data.data); + return AOS_ERROR; + } + + + //bk_msg_printf("mot_dev_MSG_put2 MSG_Type:%d",MSG_Type); + return AOS_SUCCESS; +} +static void mot_dev_task(void *thread_input)//马达线程 +{ + char count = 30; + + mot_dev_MSG_queue_t mot_dev_msg = {0}; + + + while (1) { + if(mot_dev_task_queue) + { + aos_recv_from_queue(mot_dev_task_queue,&mot_dev_msg,AOS_WAIT_FOREVER) ; + aic_get_wakelock(); + + switch (mot_dev_msg.MSG_Type) + { + + case MOT_NOD1://点头 + mot_nod1(); + break; + case MOT_NOD2://点头 + mot_nod2(); + break; + case MOT_NOD3://点头 + mot_nod3(); + break; + + default: + break; + } + if(mot_dev_msg.data) + aic_free(mot_dev_msg.data); + + aic_put_wakelock(); + }else + { + aos_sleep(10); + } + + + } +} +void mot_init(void) +{ + bk_printf("mot_init:!!!!"); + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 + // aic_gpo_output( GPO_2,GPIO_OUTPUT_LVL_LOW );//马达 + // aic_gpio_output(GPIO_14,GPIO_OUTPUT_LVL_LOW );//马达 + bk_printf("mot_init:22!!!!"); + // aic_gpio_input(MOT_TOP_SITE_IO, GPIO_TRIGGER_EDGE_FALLING, + // mot_gpio_handle, "TOP"); + // aic_gpio_input(MOT_MIDDLE_SITE_IO, GPIO_TRIGGER_EDGE_FALLING, + // mot_gpio_handle, "MIDDLE"); + // aic_gpio_input(MOT_BOOTOM_SITE_IO, GPIO_TRIGGER_EDGE_FALLING, + // mot_gpio_handle, "BOOTOM"); + //创建mot_dev_task队列 + if(mot_dev_task_queue == NULL) + { + mot_dev_task_queue = aos_create_queue("mot_dev_task_queue", + sizeof(mot_dev_MSG_queue_t), + 200); + } + + mot_dev_task_id = aos_create_thread( + "mot_task", + mot_dev_task, + &mot_dev_task_id, + 1024, + 0, + NULL, + 35, + AOS_AUTO_START); +} +void head_drop(void)//低头 +{ + bk_printf("head_drop"); + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_HIGH );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 +} +void head_up(void)//抬头 +{ + bk_printf("head_up"); + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_HIGH );//马达 +} +void MTO_stop(void) +{ + bk_printf("MTO_stop"); + mot_nod_count=0; + mot_MIDDLE_flag = 0; + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 +} +//马达归位 +void MTO_restert(void) +{ + bk_printf("MTO_restert:中间IO:%d",aic_gpio_level_get(MOT_MIDDLE_SITE_IO)); + bk_printf("MTO_restert:底部IO:%d",aic_gpio_level_get(MOT_BOOTOM_SITE_IO)); + bk_printf("MTO_restert:顶部IO:%d",aic_gpio_level_get(MOT_TOP_SITE_IO)); + if(aic_gpio_level_get(MOT_BOOTOM_SITE_IO) == 0)//到低部 + { + head_up();//抬头 + bk_printf("MTO_restert:向上归位"); + + }else if(aic_gpio_level_get(MOT_TOP_SITE_IO) == 0)//到顶部 + { + bk_printf("MTO_restert:向下归位"); + head_drop();//低头 + }else//已经到中间了 + { + bk_printf("MTO_restert:已经到中间"); + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 + return; + } + int count = 10000; + while (count--) + { + // bk_printf("MTO_restert:中间IO:%d",aic_gpio_level_get(MOT_MIDDLE_SITE_IO)); + // bk_printf("MTO_restert:底部IO:%d",aic_gpio_level_get(MOT_BOOTOM_SITE_IO)); + // bk_printf("MTO_restert:顶部IO:%d",aic_gpio_level_get(MOT_TOP_SITE_IO)); + if(aic_gpio_level_get(MOT_MIDDLE_SITE_IO) == 0) + break; + aos_sleep(1); + } + aos_sleep(50); + aic_gpo_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 +} +static void mot_nod3(void)//点头处理 +{ + head_drop();//抬头 + int count = 255; + while(count--) + { + count = 10000; + while (count--) + { + if(aic_gpio_level_get(MOT_BOOTOM_SITE_IO) == 0)//到顶部 + break; + aos_sleep(1); + } + head_up();//低头 + aos_sleep(300); + head_drop();//抬头 + if(mot_nod_count>0) + mot_nod_count--; + if(mot_nod_count ==0) + break; + } + MTO_restert();//回中间 +} +static void mot_nod2(void) +{ + head_up();//抬头 + int count = 255; + while(count--) + { + count = 10000; + while (count--) + { + if(aic_gpio_level_get(MOT_TOP_SITE_IO) == 0)//到顶部 + break; + aos_sleep(1); + } + head_drop();//低头 + aos_sleep(300); + head_up();//抬头 + if(mot_nod_count>0) + mot_nod_count--; + if(mot_nod_count ==0) + break; + } + MTO_restert();//回中间 +} +static void mot_nod1(void)//点头处理 +{ + head_drop();//直接低头 + int count = 255; + while(count--) + { + count = 10000; + while (count--) + { + if(aic_gpio_level_get(MOT_BOOTOM_SITE_IO) == 0)//到低部 + break; + aos_sleep(1); + } + head_up();//抬头 + count = 10000; + while (count--) + { + if(aic_gpio_level_get(MOT_TOP_SITE_IO) == 0)//到顶部 + break; + aos_sleep(1); + } + head_drop(); + if(mot_nod_count>0) + mot_nod_count--; + if(mot_nod_count ==0) + break; + } + MTO_restert();//回中间 +} + +void mot_nod(unsigned char count) +{ + static char nod_flag = 0; + nod_flag++; + mot_nod_count = count; + mot_MIDDLE_flag = 1; + if (nod_flag == 1) + mot_dev_MSG_put(NULL,0,MOT_NOD1); + else if (nod_flag == 2) + mot_dev_MSG_put(NULL,0,MOT_NOD2); + else if (nod_flag == 3) + { + nod_flag = 0; + mot_dev_MSG_put(NULL,0,MOT_NOD3); + } + else + nod_flag = 0; + // if(aic_gpio_level_get(MOT_TOP_SITE_IO) != 0) + // { + // head_up(); + // }else{ + // head_drop(); + // } + //mot_test(); +} +void mot_test(void) +{ + static char mot_test_flag = 0; + MTO_stop(); + aos_sleep(20); + for(int i =0;i<5;i++) + { + head_up(); + aos_sleep(1500); + + head_drop(); + aos_sleep(1500); + + } + MTO_stop(); + // if(mot_test_flag == 0) + // { + // mot_test_flag =1; + // aic_gpio_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_HIGH );//马达 + // aic_gpo_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_LOW );//马达 + // bk_printf("AI_KEY2_PRESS 0"); + // }else + // { + // mot_test_flag =0; + // aic_gpio_output(MOT_EN_FWD_IO,GPIO_OUTPUT_LVL_LOW );//马达 + // aic_gpio_output(MOT_EN_REV_IO,GPIO_OUTPUT_LVL_HIGH );//马达 + // bk_printf("AI_KEY2_PRESS 1"); + // } +} \ No newline at end of file diff --git a/2.code/aicos/app/AI_AMP_2_5/mot_dev.h b/2.code/aicos/app/AI_AMP_2_5/mot_dev.h new file mode 100644 index 0000000..bc15320 --- /dev/null +++ b/2.code/aicos/app/AI_AMP_2_5/mot_dev.h @@ -0,0 +1,21 @@ +#ifndef _MOT_DEV_H +#define _MOT_DEV_H +typedef enum mot_dev_MSG +{ + MOT_NOD1,//点头1 + MOT_NOD2,//点头2 + MOT_NOD3,//点头3 +} mot_dev_MSG_Type; +typedef struct +{ + char *data; + u32 len; + mot_dev_MSG_Type MSG_Type; +}mot_dev_MSG_queue_t; +void head_up(void);//抬头 +void head_drop(void);//低头 +void MTO_stop(void); +void mot_init(void); +void mot_nod(unsigned char count); +void mot_gpio_handle_cb(void *param); +#endif \ No newline at end of file diff --git a/2.code/aicos/projects/banyan/ap/gx306l_h3_d_sms_aichat/config/pin_cfg.h b/2.code/aicos/projects/banyan/ap/gx306l_h3_d_sms_aichat/config/pin_cfg.h index f1e03c6..3518ee7 100644 --- a/2.code/aicos/projects/banyan/ap/gx306l_h3_d_sms_aichat/config/pin_cfg.h +++ b/2.code/aicos/projects/banyan/ap/gx306l_h3_d_sms_aichat/config/pin_cfg.h @@ -9,7 +9,7 @@ /* @@Platform: GX306 */ /* @@Author: */ /* @@Version: */ -/* @@Time: 2025/7/22 17:13:54 */ +/* @@Time: 2025/9/29 9:52:28 */ #ifndef __PIN_CFG_H__ #define __PIN_CFG_H__ @@ -66,16 +66,16 @@ const u32 pin_cfg0[][2] = { {REG_IOMUX_UART1_TXD, BIT_FUNC_SEL(0)},//DEBUG_TXD {REG_PG2_PAD_CTRL_UART1_TXD, BIT_PAD_DRV(1)|BIT_PAD_PX|BIT_PAD_SLP_TOP|BIT_PAD_SLP_WPU|BIT_PAD_SLP_Z}, /* Group3 */ -{REG_IOMUX_SSP_CS1, BIT_FUNC_SEL(3)},//MOT_EN_REV_GPO14 -{REG_PG3_PAD_CTRL_SSP_CS1, BIT_PAD_DRV(1)|BIT_PAD_WPD|BIT_PAD_SLP_TOP|BIT_PAD_SLP_PX|BIT_PAD_SLP_OE}, +{REG_IOMUX_SSP_CS1, BIT_FUNC_SEL(3)},//GPO14 +{REG_PG3_PAD_CTRL_SSP_CS1, BIT_PAD_DRV(1)|BIT_PAD_WPD|BIT_PAD_SLP_TOP|BIT_PAD_SLP_WPD|BIT_PAD_SLP_Z}, {REG_IOMUX_SSP_CLK, BIT_FUN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OP|BIT_PAD_SLP_PX|BIT_PAD_SLP_OE}, +{REG_IOMUX_SPI_LCD_SDI, BIT_FUNC_SEL(6)},//GPIO26 +{REG_PG11_PAD_CTRL_SPI_LCD_SDI, BIT_PAD_DRV(1)|BIT_PAD_WPU|BIT_PAD_SLP_TOP|BIT_PAD_SLP_WPU|BIT_PAD_SLP_IE}, {REG_IOMUX_SPI_LCD_SDO, BIT_FUNC_SEL(5)},//SPI_D0 {REG_PG11_PAD_CTRL_SPI_LCD_SDO, BIT_PAD_DRV(1)|BIT_PAD_PX|BIT_PAD_SLP_MCU|BIT_PAD_SLP_WPD|BIT_PAD_SLP_Z}, {REG_IOMUX_SPI_LCD_DCX, BIT_FUNC_SEL(5)},//SPI_D1 diff --git a/2.code/make.py b/2.code/make.py index 0e672a6..f5f9353 100644 --- a/2.code/make.py +++ b/2.code/make.py @@ -6,6 +6,7 @@ import os, sys, time, re, shutil, platform import subprocess, fileinput from multiprocessing import cpu_count from colorama import init +from datetime import datetime init(autoreset=True) # set global path and value @@ -22,7 +23,9 @@ global md_board_name, nv_board_name, nvram_board_config global subsys_config, board_config global binary_path, board_path, common_path global maincmd, subcmd, thirdcmd - +# 获取当前日期时间 +now = datetime.now() +build_start_time_str = now.strftime("%Y_%m_%d_%H_%M_%S") # # Get build command parameter # @@ -682,7 +685,7 @@ def aicos_build(cmd): global common_path global script_path global board_path - + global build_start_time_str if cmd == "mkpkg": set_subsys_config("ap") else: @@ -762,7 +765,7 @@ def aicos_build(cmd): suffix = "release" else: suffix = "debug" - + suffix +="_{}".format(build_start_time_str) pkg_cfg_dir = targets_path + "/" + chip_name + "/" + project_name + "/pkg" for root, dirs, files in os.walk(pkg_cfg_dir): for pkg_cfg_name in files: @@ -1060,8 +1063,13 @@ def kconfig_build(subsys, kcfg_cmd): except: print("Unexpected error:", sys.exc_info()) exit(1) - +def add_make_time_file(): + global build_start_time_str + with open('aicos/app/AI_AMP_2_5/bk_make_time.h', 'w', encoding='utf-8') as file: + file.write('const char *bk_make_timer = \"{}\";\n'.format(build_start_time_str)) if __name__ == '__main__': + #创建版本.h文件 + add_make_time_file() # Init global board parameters. get_board_config()