/* * 函数名:main * 描述 :主函数 * 输入 :无 * 输出 :无 */ int main(void) { uint8_t i = 0; /* USART1 config 115200 8-N-1 */ USART1_Config(); /* 使能CRC时钟 */ CRC_Config(); printf("\r\n 这是一个 CRC(循环冗余校验)实验 \r\n"); /* Compute the CRC of "DataBuffer" */ for(i=0; i<BUFFER_SIZE; i++ ) { CRCValue = CRC_CalcBlockCRC((uint32_t *)DataBuffer, BUFFER_SIZE); printf("\r\n32-bit CRC 校验码为:0X%X\r\n", CRCValue); } printf("\r\nCRC(循环冗余校验)测试成功\r\n"); for(;;) { } }
/** * @brief Ö÷º¯Êý * @param ÎÞ * @retval ÎÞ */ int main(void) { uint16_t Buf[10], i; delay_init(72); /* USART1 config 9600 8-N-1 */ USART1_Config(); Init_Mouse(); for(;;) { if(PS2_Status&0x80) { Mouse_Data_Pro(); PS2_Status=MOUSE; printf("X = %d Y = %d \r", MouseX.x_pos, MouseX.y_pos); PS2_En_Data_Report(); } else if(PS2_Status&0x40) { PS2_Status=MOUSE; } delay_ms(1); } }
void ClockWise(uint16_t ID,uint16_t speed,uint16_t angle) /* 舵机模式 0<= speed<= 100 0<= angle<=1023 */ { uint16_t buf2,buf1; buf1=speed; speed_H=(uint8_t)(buf1>>8); speed_L=(uint8_t)buf1; buf2=angle; angle_H=(u8)(buf2>>8); angle_L=(u8)buf2; USART1_Config(); Delayus(10000); Send(0xFF); Send(0xFF); Send(ID); Send(0x07); Send(0x03); Send(0x1E); Send(angle_L); Send(angle_H); Send(speed_L); Send(speed_H); Sum=~(ID+0x07+0x03+0x1E + angle_H+angle_L+speed_L+speed_H); Send(Sum); RECEIVE_Config(); Delayus(10000); }
/** * @brief 主函数 * @param 无 * @retval 无 */ int main(void) { /* LED 端口初始化 */ LED_GPIO_Config(); /* 初始化触屏 */ Touch_Init(); /* 初始化定时器 */ SysTick_Init(); /*CRC和emWin没有关系,只是他们为了库的保护而做的,这样STemWin的库只能用在ST的芯片上面,别的芯片是无法使用的。 */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); /* 初始化GUI */ GUI_Init(); /* 初始化串口*/ USART1_Config(); DEBUG("\r\n wildfire ISO board emWin test \r\n"); GUI_Delay (20); /* 触摸校准demo */ Touch_MainTask(); }
/* * 函数名:main * 描述 : "主机"的主函数 * 输入 :无 * 输出 : 无 */ int main(void) { /*初始化串口模块*/ USART1_Config(); /* 配置CAN模块 */ CAN_Config(); printf( "\r\n***** 这是一个双CAN通讯实验******** \r\n"); printf( "\r\n 这是 “主机端” 的反馈信息: \r\n"); /*设置要通过CAN发送的信息*/ CAN_SetMsg(); printf("\r\n将要发送的报文内容为:\r\n"); printf("\r\n 扩展ID号ExtId:0x%x",TxMessage.ExtId); printf("\r\n 数据段的内容:Data[0]=0x%x ,Data[1]=0x%x \r\n",TxMessage.Data[0],TxMessage.Data[1]); /*发送消息 “ABCD”**/ CAN_Transmit(CAN1, &TxMessage); while( flag == 0xff ); //flag =0 ,success printf( "\r\n 成功接收到“从机”返回的数据\r\n "); printf("\r\n 接收到的报文为:\r\n"); printf("\r\n 扩展ID号ExtId:0x%x",RxMessage.ExtId); printf("\r\n 数据段的内容:Data[0]= 0x%x ,Data[1]=0x%x \r\n",RxMessage.Data[0],RxMessage.Data[1]); while(1); }
int main(void) { //int flag=0; USART1_Config(); NVIC_Configuration(); while(1){ LCD_DispStr(5, 5, (uint8_t *)"�����ϳ������", RED); if((Key_Scan(GPIOA,GPIO_Pin_0)== KEY_ON)){ printf("\r\n ˮ�������緽��, \r\n"); } Delay(0xFFFFF); if((Key_Scan(GPIOA,GPIO_Pin_0)== KEY_ON)){ printf("\r\n ɽɫ�՝�������. \r\n"); } Delay(0xFFFFF); if((Key_Scan(GPIOA,GPIO_Pin_0)== KEY_ON)){ printf("\r\n ��������������, \r\n"); } Delay(0xFFFFF); if((Key_Scan(GPIOA,GPIO_Pin_0)== KEY_ON)){ printf("\r\n ��ױŨĨ������. \r\n"); Delay(0xFFFFF); } } }
/** * @brief ������ * @param �� * @retval �� */ int main(void) { /* ���� led */ LED_GPIO_Config(); /* ����exti�ж� */ EXTI_Key_Config(); /* ���ô���Ϊ�ж�ģʽ */ USART1_Config(); printf("\r\n Ұ��ISO-MINI�����壬˯��ʵ�� \r\n"); while(1) { /* wait interrupt */ LED1( ON ); // �� Delay(0xFFFFF); LED1( OFF ); // �� LED2( ON ); // �� Delay(0xFFFFF); LED2( OFF ); // �� LED3( ON ); // �� Delay(0xFFFFF); LED3( OFF ); // �� __WFI(); //����˯��ģʽ���ȴ��жϻ��� } }
int main(void) { /* USART1 config */ USART1_Config(); LED_GPIO_Config(); /*初始化SD卡*/ Set_System(); /*设置USB时钟为48M*/ Set_USBClock(); /*配置USB中断(包括SDIO中断)*/ USB_Interrupts_Config(); /*USB初始化*/ USB_Init(); while (bDeviceState != CONFIGURED); //等待配置完成 printf("\r\n 野火 ISO STM32 USB MASS STORAGE 实验\r\n"); while (1) { LED1_TOGGLE; USB_Delay(0x0FFFFF); } }
/* * 函数名:BSP_Init * 描述 :时钟初始化、硬件初始化 * 输入 :无 * 输出 :无 */ void BSP_Init(void) { SysTick_init(); switch (RCC_GetSYSCLKSource()) { case 0x00 : printf("\r\n HSI used as system clock.\r\n"); break; case 0x04 : printf("\r\n HSE used as system clock.\r\n"); break; case 0x08 : printf("\r\n PLL used as system clock.\r\n"); break; default: printf("\r\n * unkonwn clock soure. *"); break; } /* LED 端口初始化 */ LED_GPIO_Config(); //EXTI_Cfg(); USART1_Config(); ADC1_Init(); //DAC_Config(); //RTC_Configuration(); //SoftTimerInit(); //NVIC_Configuration(); }
void Baud_Config(uint16_t ID,uint32_t baud) /* 前六个波特率断电保存 */ { uint32_t rate; rate=baud; switch(rate) { case 1000000 : baud=1;break; case 500000 : baud=3;break; case 250000 : baud=7;break; case 115200 : baud=16;break; case 57600 : baud=34;break; case 19200 : baud=103;break; default:baud=2000000/rate-1;break; } USART1_Config(); Delayus(10000); Send(0xFF); Send(0xFF); Send(ID); Send(0x03); Send(0x03); Send(0x04); Send(baud); Sum=~(0x03+0x07+ID+baud); Send(Sum); RECEIVE_Config(); Delayus(10000); }
//------------------------------------------------ void PrintfConfig(void) { #if N == 1 USART1_Config(); #endif }
/* * 初始化液晶,串口,触摸屏,flash及sd卡 * */ void ISO_Init(void) { uint8_t k; /* 液晶初始化先于串口,不然会有bug,至于是什么原因我也不知道:( */ LCD_Init(); LCD_Clear(0,0,240,320,WHITE); LCD_DispStr(20,150,"board init,please wait... ",RED); USART1_Config(); /* 初始化sd卡文件系统,因为汉字的字库放在了sd卡里面 */ Sd_fs_init(); #ifdef WORD_MODE /* 显示界面图片 */ Lcd_show_bmp(0, 0,"/boardtest/boardtest.bmp"); #else /* 显示界面图片 */ Lcd_show_bmp(0, 0,"/boardtest/ISO/ui_boardtest.bmp"); #endif Lcd_List(1); /* 初始化外部FLASH */ SPI_FLASH_Init(); //SPI_FLASH_SectorErase(0); /* 触摸屏IO和中断初始化 */ Touch_Init(); /*-------------------------------------------------------------------------------------------------------*/ #if 1 SPI_FLASH_BufferRead(&cal_flag, 0, 1); if( cal_flag == 0x55 ) { SPI_FLASH_BufferRead((void*)cal_p, 1, sizeof(cal_p)); SPI_FLASH_CS_HIGH(); for( k=0; k<6; k++ ) printf("\r\n rx = %LF \r\n",cal_p[k]); } else { /* 等待触摸屏校正完毕 */ while(Touch_Calibrate() !=0); } #elif 0 /* 等待触摸屏校正完毕 */ while(Touch_Calibrate() !=0); #endif }
/* * 函数名:main * 描述 :主函数 * 输入 :无 * 输出 :无 */ int main(void) { uint8_t k; /* 配置串口1为:115200 8-N-1 */ USART1_Config(); printf("\r\n 这是一个2M串行flash(W25Q16)实验 \r\n"); /* 2M串行flash W25X16初始化 */ SPI_FLASH_Init(); /* Get SPI Flash Device ID */ DeviceID = SPI_FLASH_ReadDeviceID(); Delay( 200 ); /* Get SPI Flash ID */ FlashID = SPI_FLASH_ReadID(); printf("\r\n FlashID is 0x%X, Manufacturer Device ID is 0x%X\r\n", FlashID, DeviceID); /* Check the SPI Flash ID */ if (FlashID == sFLASH_ID) /* #define sFLASH_ID 0xEF3015 */ { printf("\r\n 检测到华邦串行flash W25Q16 !\r\n"); /* Erase SPI FLASH Sector to write on */ SPI_FLASH_SectorErase(FLASH_SectorToErase); /* 将发送缓冲区的数据写到flash中 */ SPI_FLASH_BufferWrite(Tx_Buffer, FLASH_WriteAddress, BufferSize); for( k=0; k<6; k++ ) printf("\r\n 写入的数据为:%d \r\n", Tx_Buffer[k]); /* 将刚刚写入的数据读出来放到接收缓冲区中 */ SPI_FLASH_BufferRead(Rx_Buffer, FLASH_ReadAddress, BufferSize); for( k=0; k<6; k++ ) printf("\r\n 读出的数据为:%d \r\n", Tx_Buffer[k]); /* 检查写入的数据与读出的数据是否相等 */ TransferStatus1 = Buffercmp(Tx_Buffer, Rx_Buffer, BufferSize); if( PASSED == TransferStatus1 ) { printf("\r\n 2M串行flash(W25Q16)测试成功!\n\r"); } else { printf("\r\n 2M串行flash(W25Q16)测试失败!\n\r"); } }// if (FlashID == sFLASH_ID) else { printf("\r\n 获取不到 W25Q16 ID!\n\r"); } SPI_Flash_PowerDown(); while(1); }
int main1() { //网络模块开始 // //中断开启,配置net管脚和传感器data管脚中断 // NVIC_Configuration(); // /*按键输入初始化*/ // GPIO_INPUT_INIT(); // // /*输出初始化*/ // IO_OUTPUT_Config(); // //中断开启,配置net管脚和传感器data管脚中断 // NVIC_Configuration(); // SPI1_Init(); // InitNet(); /* 初始化网络设备以及UIP协议栈,配置IP地址 */ ///* 配置SysTick 为10ms中断一次 */ //// SysTick_Init(); // while(1) // { // /* 下面是网络检测的程序,处理uip事件,必须插入到用户程序的循环体中 */ // UipPro(); //中断触发读取网络接收缓存 // eth_poll(); //定时查询TCP及UDP连接收发状态 ARP表更新, 并响应 // } //网络模块结束 /* 配置SysTick 为1us中断一次 */ SysTick_Init(); DelayInit(); USART1_Config(); printf("\r\n***野火ISO dht11 温湿度传感器实验***\r\n"); /*初始化DTT11的引脚*/ DHT11_GPIO_Config(); while(1) /*调用Read_DHT11读取温湿度,若成功则输出该信息*/ { if( Read_DHT11(&DHT11_Data)==SUCCESS) { printf("\r\n读取DHT11成功!\r\n\r\n湿度为%d.%d %RH ,温度为 %d.%d℃ \r\n",\ DHT11_Data.humi_int,DHT11_Data.humi_deci,DHT11_Data.temp_int,DHT11_Data.temp_deci); //printf("\r\n 湿度:%d,温度:%d \r\n" ,DHT11_Data.humi_int,DHT11_Data.temp_int); } else { printf("Read DHT11 ERROR!\r\n"); } } }
/** * @brief Main program. * @param None * @retval : None */ int main() { /* 配置RTC秒中断优先级 */ RTC_NVIC_Config(); USART1_Config(); RTC_CheckAndConfig(&systmtime); /* Display time in infinite loop */ Time_Show(&systmtime); }
int main(void) { /* USART1 config */ USART1_Config(); SysTick_Init(); LCD_Init(); /* LCD ��ʼ��*/ sd_fs_init(); Sd_fs_test(); // /*��ʾͼ��*/ // Lcd_show_bmp(0, 0,"/pic3.bmp"); // Lcd_show_bmp( 40,200,"/pic2.bmp"); // Lcd_show_bmp( 100,100,"/pic1.bmp"); // // /*������ʾ*/ // LCD_Str_O(20, 10, "lCD_DEMO",0); // LCD_Str_CH(20,30,"��Ī��̳Ұ��ר��",0,0xffff); // LCD_Str_CH_O(20,50,"��Ī��̳Ұ��ר��",0); // LCD_Num_6x12_O(20, 70, 65535, BLACK); // LCD_Str_6x12_O(20, 90,"LOVE STM32", BLACK); // /*������ʾ*/ // LCD_Str_O_P(300, 10, "Runing", 0); // LCD_Str_CH_P(280,10,"��Ī��̳Ұ��ר����ӭ��",0xff,0xffff); // LCD_Str_CH_O_P(260,10,"��Ī��̳Ұ��ר��",0); // LCD_Str_6x12_O_P(240, 10,"LOVE STM32", 0); // LCD_Str_ENCH_O_P(220,10,"��ӭʹ��Ұ��stm32������",0); // // /*��ͼ*/ // LCD_Str_CH(20,150,"���ڽ�ͼ",0,0xffff); // Screen_shot(0, 0, 240,320 , "/myScreen"); // LCD_Str_CH(20,150,"��ͼ���",0,0xffff); // // // LCD_test(); // lcd_PutChar(50,30,'A',BLACK,WHITE); GUI_Text(20,30,"AAAAAAAAAAAAA",sizeof("AAAAAAAAAAAAA"),0,0xffff); LCD_Char_CH(200,100,"��",0,0xffff); LCD_Str_CH(100,200,"�Ǻǣ���ͤǿ����ţ��",0,BLUE); LCD_Str_O(50,60,str2,BLACK,BLUE); while (1) { // LCD_test(); } }
int main(void) { int dianya_fly = 0; SysTick_Init(); Tim3_Init(500); Nvic_Init(); LED_Init(); ADC1_Init(); USART1_Config(115200); KEY_Init(); NRF24L01_Init(); while (NRF24L01_Check()) //检查NRF24L01是否在位.要放在设置TX_MODE之前,否则设置的发送地址会变成check中的0XA5 ,将与原接收地址对不上 { LED2_ON; LED1_OFF; printf("no"); } LED1_ON; LED2_OFF; //TX mode //NRF24L01_TX_Mode(); //NRF24L01_Mode_Config(2); //RX mode NRF24L01_Mode_Config(3); while (1) { key = KEY_scan(); if (NRF24L01_RxPacket(tmp_buf) == 0) { NRF24L01_TxPacket_AP(rc_buf); LED1_ON; if(tmp_buf[0]==0x88 && tmp_buf[1]==0xAE && tmp_buf[2]==0x1C) { dianya_fly = tmp_buf[17]<<8|tmp_buf[18]; if(dianya_fly<36 && dianya_fly>20) { LED2_ON; } } send_wave(32,tmp_buf); } else { LED1_OFF; } } }
int main(void) { BYTE nI; LED_Init(); USART1_Config(); //串口初始化 WT_GPIO_Config(); //控制WT1000的IO引脚初始化 AMBEReset(); //复位WT1K和WT1027 SOCK(0); SOSTRB(1); PD2(0); //串行模式下PD2必须下拉或者接地 pFrameData[0] = 0x13; pFrameData[1] = 0xec; for(nI = 2; nI < 34; nI++) { pFrameData[nI] = 0; //初始化pFrameData数组 } while(!EPR); AMBEReadSerial(); while(1) { LED0=~LED0; while(!EPR); //读EPR信号 AMBEReadSerial(); //串行读WT1K编码数据 LoadreadBUF(); //将独到的语音编码数据放到发送缓冲区pTXBUF中 UART1SendData(pTXBUF,VOICELENGTH+2); //串口发送 while(!DPE); //读DPE信号 if(bReceived ==1) //串口中断接收到一包完整的数据bReceived=1;收到的数据放在接收缓冲区pRXBUF { noReceived=0; LoadFrame(); //将接收缓冲区pRXBUF的语音数据移到pFrameData中 AMBEWriteSerial(); //串行写WT1K bReceived = 0; } else { noReceived++; if(noReceived==4) //连续4包没收到完整数据向WT1K写静音数据 { noReceived=3; LoadNoVoice(); AMBEWriteSerial(); } } } }
void RetnMode(uint8_t ID,u8 Mode) { USART1_Config(); Delayus(10000); Send(0xFF); Send(0xFF); Send(ID); Send(0x04); Send(0x03); Send(0x10); Send(Mode); Sum=0xFF+0xFF+ID+0x04+0x03+0x10+Mode; Send(Sum); }
/* * ³õʼ»¯Òº¾§£¬´®¿Ú£¬´¥ÃþÆÁ£¬flash¼°sd¿¨ * */ void ISO_Init(void) { uint8_t k; /* ÅäÖÃUSART1 */ USART1_Config(); /* ÅäÖÃUSART2 */ USART2_Config(); /* ÉèÖà TIM */ TIM2_Configuration(); USART2_DMATxd_Init(); Set_PrintfPort(1); //ÉèÖÃDebugPf´Ó´®¿Ú1Êä³ö }
int main(void) { uint16_t temp, humi; //温湿度 char HTTP_Buf[400]; //HTTP报文缓存区 char tempStr[5]; //字符串格式温度 char humiStr[5]; //字符串格式湿度 int len; USART1_Config(); //USART1作为调试串口 USART2_Config(); //USART2用于连接ESP8266模块 Hal_I2C_Init(); //I2C初始化,用于连接温湿度传感器 ESP8266_Init(); //ESP8266初始化 printf("ESP8266 init over\r\n"); //SHT20_loop(); // while(1) { /* 获取温湿度 */ SHT2x_MeasureHM(SHT20_Measurement_T_HM, &temp); mDelay(500); SHT2x_MeasureHM(SHT20_Measurement_RH_HM, &humi); /* 转化为字符串形式 */ sprintf(tempStr, "%d", temp); sprintf(humiStr, "%d", humi); //printf("%s %s\r\n", tempStr, humiStr); USART2_Clear(); len = HTTP_PostPkt(HTTP_Buf, API_KEY, DEV_ID, "temp", tempStr); //HTTP组包 USART2_Write(USART2, (unsigned char *)(HTTP_Buf), len); //报文发送 printf("send HTTP msg:\r\n%s\r\n", HTTP_Buf); mDelay(1000); printf("rcv response:\r\n%s\r\n", usart2_rcv_buf); USART2_Clear(); len = HTTP_PostPkt(HTTP_Buf, API_KEY, DEV_ID, "humi", humiStr); //HTTP组包 USART2_Write(USART2, (unsigned char *)(HTTP_Buf), len); //报文发送 printf("send HTTP msg:\r\n%s\r\n", HTTP_Buf); mDelay(1000); printf("rcv response:\r\n%s\r\n", usart2_rcv_buf); mDelay(5000); } }
int main(void) { /* 串口1初始化 */ USART1_Config(); /*SPI接口初始化*/ SPI_NRF_Init(); printf("\r\n 这是一个 NRF24L01 无线传输实验 \r\n"); printf("\r\n 这是无线传输 从机端 的反馈信息\r\n"); printf("\r\n 正在检测NRF与MCU是否正常连接。。。\r\n"); /*检测NRF模块与MCU的连接*/ status = NRF_Check(); if(status == SUCCESS) printf("\r\n NRF与MCU连接成功\r\n"); else printf("\r\n 正在检测NRF与MCU是否正常连接。。。\r\n"); while(1) { printf("\r\n 从机端 进入接收模式\r\n"); NRF_RX_Mode(); /*等待接收数据*/ status = NRF_Rx_Dat(rxbuf); /*判断接收状态*/ if(status == RX_DR) { for(i=0; i<4; i++) { printf("\r\n 从机端 接收到 主机端 发送的数据为:%d \r\n",rxbuf[i]); /*把接收的数据+1后发送给主机*/ rxbuf[i]+=1; txbuf[i] = rxbuf[i]; } } printf("\r\n 从机端 进入自应答发送模式\r\n"); NRF_TX_Mode(); /*不断重发,直至发送成功*/ do { status = NRF_Tx_Dat(txbuf); } while(status == MAX_RT); } }
int main(void) { LED_GPIO_config(); USART1_Config(); printf("\r\n CAN回环测试 \r\n"); USER_CAN_Init(); printf("\r\n CAN回环测试初始化 \r\n"); USER_CAN_Test(); printf("\r\n CAN回环测试结束 \r\n"); while (1); }
int main(void) { led_hw_init(); USART1_Config(); while (1) { printf("hello !!\r\n"); led_hw_on(LED0); delay_ms(500); led_hw_off(LED0); delay_ms(500); led_hw_on(LED1); delay_ms(500); led_hw_off(LED1); delay_ms(500); } }
int main(void) { USART1_Config(); chuck_init(); while(1){ printf("Joystick Angle: %d\r\n",getJoyAngle()); printf("Roll: %d\r\n",getRoll()); printf("Pitch: %d\r\n",getPitch()); printf("C: %d\r\n",getCstate()); printf("Z: %d\r\n",getZstate()); Delay(0xFFFFF); } }
/** * @brief * @param 无 * @retval 无 */ int main(void) { /* USART1 115200 8-N-1, */ USART1_Config(); NVIC_Configuration(); /* 10us*/ SysTick_Init(); MOTOR_GPIO_Config(); TIM2_Configuration(); TIM2_NVIC_Configuration(); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , ENABLE); //printf(READY); printf("POLARGRAPH ON!"); setAcceleration(&motorA,currentAcceleration); setAcceleration(&motorB,currentAcceleration); mmPerStep = mmPerRev / motorStepsPerRev; stepsPerMM = motorStepsPerRev / mmPerRev; motorA._name = 0; motorB._name = 1; setAcceleration(&motorA,currentAcceleration); setAcceleration(&motorB,currentAcceleration); pixel_drawSquarePixel(990,486,18,23); for(;;) { if(getNewComms) { exec_executeBasicCommand(); getNewComms = 0; } } }
/** * @file main * @brief Main program. * @param None * @retval None */ int main(void) { SYSTICK_Init(); USART1_Config(); LED_GPIO_Config(); I2C_Configuration(); printf("\r\n 这是一个I2C外设(AT24C08)读写测试例程 \r\n"); I2C_Test(); while (1) { LEDXToggle(LED1); LEDXToggle(LED2); LEDXToggle(LED3); delay_ms(500); } }
void Reset_Config(uint8_t ID) /* 复位一个舵机 从电机模式后要复位 */ { USART1_Config(); Delayus(10000); Send(0xFF); Send(0xFF); Send(ID); Send(0x02); Send(0x06); Sum=~(ID+0x02+0x06); Send(Sum); RECEIVE_Config(); Delayus(10000); }
/** * @file main * @brief Main program. * @param None * @retval None */ int main(void) { SYSTICK_Init(); USART1_Config(); LED_GPIO_Config(); I2C_Configuration(); BMP180_Init(); while (1) { LEDXToggle(LED1); LEDXToggle(LED2); LEDXToggle(LED3); delay_ms(1000); BMP180_TEST(); } }
int main(void) { delay_init(); NVIC_Configuration(); /*设置NVIC中断分组2:2位抢占优先级,2位响应优先级*/ LED_Init(); MotorPin_Init(); /*舵机初始化信号线引脚*/ USART1_Config(); Init_TotalArray(); /*计算执行数组*/ Exti_Init(); TIM3_Int_Init(100,100); TIM4_Int_Init(10000,7199); /*定时1S*/ //TIM_Cmd(TIM3, DISABLE); /*接收到指令之后,再打开TIM3*/ //while(!rece_flag); while(1) { /*警告:外部中断ABCDEF的顺序不要颠倒*/ if(rece_flag==1) { if(rece_string[0]=='#') { TIM_Cmd(TIM3, DISABLE); /*先关闭TIM3,避免全局变量被修改*/ motor_speed=250; SolvecubeArray_ToBufferArray(); } change(); TIM_Cmd(TIM3, ENABLE); /*接收到指令之后,再打开TIM3*/ rece_flag=0; } if(flag_vpwm==1) { vpwm(); /*插补角度*/ flag_vpwm=0; } } }