void main(void) { Init_Main(); // 초기화_MCU U8 i; //Send_Packet(); //ADC_Reset(); //Send_Packet(0); while(1) { //Send_Packet_Test(0); //Delay(1000); if(Dis[5]==0 || Dis[5]>6) { MMode = 1; while(1) {if(MMode==0) {break;}} } if(Dis[5]!=0 && Dis[5]<=6) { if(Dis[0] <= 12) { MMode=4; while(1) {if(MMode==0) {break;}} } } if(Dis[0]<4 && Dis[1]<6 && Dis[2]<=7 ) { MMode=6; while(1) { if(MMode==0) {break;} } } } }
//------------------------------------------------------------------------------ // === Main Function === //------------------------------------------------------------------------------ void main(void) { Init_Main(); // 초기화_MCU while(1) { //-------------------------------------------------------------------------- // === Function Module === //-------------------------------------------------------------------------- //Uart_Print(0, "AT&MSG=0,"); Uart_Putch(0,i); //Uart_Print(0, "\r"); i++; _delay_ms(1000); //-------------------------------------------------------------------------- } }
//------------------------------------------------------------------------------ // === Main Function === //------------------------------------------------------------------------------ void main(void) { Init_Main(); // 초기화_MCU while(1) { //-------------------------------------------------------------------------- // === Function Module === //-------------------------------------------------------------------------- if(ADC_Average(0, 10) >= 200) { //nMODE = MODERUN; AX_Action(0, 0x02, 0x00, 0x02, 0x90); _delay_ms(300); AX_Action(0, 0x02, 0x90, 0x02, 0x90); _delay_ms(300); } //-------------------------------------------------------------------------- } }
//------------------------------------------------------------------------------ // === Main Function === //------------------------------------------------------------------------------ void main(void) { Init_Main(); // 초기화_MCU Position_Homing(); while(1) { //-------------------------------------------------------------------------- // === Function Module === //-------------------------------------------------------------------------- //PacketManager((PARTNER_PACKET*)&pPacket, (UART_CONTEXT*)&pContext ); //_delay_ms(5); // delay. NECESSARY!!! if(RXstate == RXEND) { Mode = MODE_RUN; for(U08 cnt=0; cnt<RXLENGTH; cnt++) { Uart_Print(1,"\n\r Xcod : "); Uart_U08Bit_PutNum(1, CoordinateX[cnt]); Uart_Print(1," Ycod : "); Uart_U08Bit_PutNum(1, CoordinateY[cnt]); Uart_Print(1," Zcod : "); Uart_U08Bit_PutNum(1, CoordinateZ[cnt]); Moving_XYCoordinate(CoordinateX[cnt],CoordinateY[cnt]); //Change ServoPWM } RXstate = RXREADY; SendRequestPacket(IND_TX_NEXTPAGE, 0x00); } //-------------------------------------------------------------------------- } }
bool CMainConfig::Init() { //获得数据解析包的版本号 CPacketParse objPacketParse; sprintf_safe(m_szPacketVersion, MAX_BUFF_20, "%s", objPacketParse.GetPacketVersion()); //读取主配置文件 bool blState = Init_Main(MAINCONFIG); if(blState == false) { return false; } //读取报警相关配置文件 blState = Init_Alert(ALERTCONFIG); if(blState == false) { return false; } else { return true; } }
void main(void) { Init_Main(); // 초기화_MCU U8 i; SetPwmPeriod(999); while(1) { Encoder_Count1 =TIM_GetCounter(TIM4); Encoder_Count2 =TIM_GetCounter(TIM3); /* if( TIM3->CR1 & ((u16)0x0010)) { // down couting } else { // up counting } */ SetPwmDuty(1,750); Delay(5000); SetPwmDuty(1,500); Delay(5000); SetPwmDuty(2,250); Delay(5000); //Usart_Putnum(Encoder_Count1); Usart_Putnum(Encoder_Count2); Delay(1000); //-------------------------------------------------------------------------- // === Function Module === //-------------------------------------------------------------------------- //SetPwmPeriod(4, 1000); //SetPwmDuty(1, (U8)(ADCConvertedValue[0] * 100 / 4096)); //SetPwmDuty(2, (U8)(ADCConvertedValue[1] * 100 / 4096)); //SetPwmDuty(3, (U8)(ADCConvertedValue[2] * 100 / 4096)); /* Move(Forward); Delay(3000); Move(Backward); printf("%04d %04d %04d\n",ADCConvertedValue[0], ADCConvertedValue[1], ADCConvertedValue[2]); printf("%d", TIM4->ARR); Delay(3000); */ //printf("%04d %04d %04d\n",ADCConvertedValue[0], ADCConvertedValue[1], ADCConvertedValue[2]); // printf("%d", TIM4->ARR); /* Usart_Putnum(ADCConvertedValue[0]); Delay(1000); Usart_Putnum((U16)(88.2/(ADCConvertedValue[0]/819+0.1))-15); Delay(1000); Usart_Putnum((U16)(88.2/(ADCConvertedValue[0]/819+0.1))/2-10); Delay(1000); Usart_Putnum((U16) (( (11.65/(( ADCConvertedValue[0]/819) - 0.147 )) - 0.42 ) * 10)-4); Delay(1000); */ /* for(i=0;i<ADCMAXCH;i++) { Usart_Putnum(ADCConvertedValue[i]); } Delay(1000);*/ //Usart_Putnum(102); //Delay(1000); //-------------------------------------------------------------------------- /* SetPwmDuty(1,750); Delay(5000); SetPwmDuty(1,500); Delay(5000); SetPwmDuty(2,250); Delay(5000); */ //Usart_Putnum(Rx_Buffer[data]); //Delay(1000); } }
void main(void) { U8 temp_ADC = 0; // ADC value 임시저장 uint16_t CHK = 0; uint16_t i = 0; Init_Main(); // 초기화_MCU print_Reg(); // Register Print //receiver set time in 390us from trans ID to receive ID //sensor trans time needs 100~150us while(1) { CHK = 0; for(i=0; i<4; i++) { bbuf[i*2] = (U8)(ADCConvertedValue[i]>>8); CHK += bbuf[i*2]; bbuf[i*2 + 1] = (U8)ADCConvertedValue[i]; CHK += bbuf[i*2 + 1]; } bbuf[30] = (U8)(CHK>>8); bbuf[31] = (U8)CHK; // while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET); /* printf("ADC8 = %d\n", ADCConvertedValue[0]); printf("ADC9 = %d\n", ADCConvertedValue[1]); printf("ADC10 = %d\n", ADCConvertedValue[2]); printf("ADC11 = %d\n", ADCConvertedValue[3]); printf("ADC12 = %d\n", ADCConvertedValue[4]); printf("ADC13 = %d\n", ADCConvertedValue[5]); printf("ADC14 = %d\n", ADCConvertedValue[6]); printf("ADC15 = %d\n", ADCConvertedValue[7]); */ /* temp_ADC = (U8)(ADCConvertedValue[0]>>8); printf("%d\n", temp_ADC); temp_ADC = (U8)ADCConvertedValue[0]; printf("%d\n", temp_ADC); */ // falling 방식 /* while( !(nRF24_ReadReg(nRF24_REG_FIFO_STATUS) & 1)) { // GPIO_SetBits(GPIOC,GPIO_Pin_9); nRF24_ReadBuf(nRF24_CMD_R_RX_PAYLOAD,buf,1); //3 //it takes 15us , receiver sent 770 ~800 us // GPIO_ResetBits(GPIOC,GPIO_Pin_9); nRF24_RWReg(nRF24_CMD_WREG |nRF24_REG_STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) ); // USART_SendData(USART1,buf[0]); if(buf[0] == '1') // 780us * 8(ID:0~7) = 6240 { GPIO_SetBits(GPIOC,GPIO_Pin_9); nRF24_TXMode(bbbbbuf, 32); // it takes 500us GPIO_ResetBits(GPIOC,GPIO_Pin_9); nRF24_RXMode(); } } */ } }