int main(int argc, char** argv) { WORD KeyVal; char ResString[10]; void Ludacris_Speed_GO(void); Ludacris_Speed_GO(); InitGlobals(); InitLCD(); Timer1_Setup(); UART1_Config(); Pin_Setup(); printf("\nUART Configured\n\n"); while(1) { __delay_ms(250); PutsXLCD("No Workie! "); if(!Calculate) { if(TriggerGetKeys) { KeyVal = GetKeyPressed(); FindKey(KeyVal); if(Key != NULL) { ParseInput(Key); } TriggerGetKeys = 0; } } else { DoCalculate(); printf("%f\n", Terms.Result); sprintf(ResString, "%f", Terms.Result); PutsXLCD(ResString); TriggerGetKeys = 0; Calculate = 0; GotOperand1 = 0; GotOperand2 = 0; Operation = NO_OP; } } return (EXIT_SUCCESS); }
void main(void) { /* Clock configuration -----------------------------------------*/ CLK_Config(); /* GPIO configuration ------------------------------------------*/ GPIO_Config_Init(); TIM3_Config(); TIM4_Config(); UART1_Config(); UART3_Config(); enableInterrupts(); DeviceStatus.workState = 16; Delay(200); //beep Set_Beep_OptionByte(); Beep_Init(BEEP_FREQUENCY_4KHZ); BEEP_LSICalibrationConfig(LSI_128kHz); showAll(); PowerOnBeep(); clear(); TIM2_Config(); showTemp(Temperature[DeviceStatus.workState], ON); showSymbol(SYMBOL_DEFAULT); FunctionReport(DeviceStatus.workState); while (1) { if(DeviceStatus.Time_100ms == 1) { if(UART1_GetFlagStatus(UART1_FLAG_IDLE) == SET) { if(DataSize != 0) { DataResolve(RxRecvBuffer, DataSize); DataSize = 0; } } DeviceStatus.Time_100ms = 0; } } }
/** * @brief Main program. * @param None * @retval None */ void main(void) { /* Clock configuration -----------------------------------------*/ CLK_Config(); /* GPIO configuration -----------------------------------------*/ GPIO_Config(); /* UART1 configuration -----------------------------------------*/ UART1_Config(); while (1) { STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED4); Delay((uint32_t)0xFFFF); } }
int main(void) { int i; RCC_Configuration(); //????????????? NVIC_Configuration(); LED_Config(); TIM7_Configuration(10) ; RCC_Config(); ADC_initial(); UART1_Init(); UART1_Config(9600); UART1_Cmd(ENABLE); UART1_Write("stm start",9); LCD_GLASS_Configure_GPIO(); LCD_GLASS_Init(); while (1) { int wdt=0; int adc_wdt=0; double adc=0; //// solution 2 working String i=0; memcpy(buff2,buff, strlen(buff)); // ? buff ??? buff2 memset(buff, 0, strlen(buff)); // ?? buff ??????? while(1) { if(USART_GetFlagStatus(USART1,USART_FLAG_RXNE) != RESET) { char c = USART_ReceiveData(USART1); i=i+1; if(c == '\r') break; else if (c == '\n') break; else sprintf (buff, "%s%c", buff,c); }else { wdt++; adc_wdt++; if(adc_wdt%100==0) { adc=(adc*99.0+GetADC())/100.0; } if(adc_wdt>10000) { adc_wdt=0; LCDPrint(" %0.1f ",adc); } if(wdt==50) { wdt=0; for(i=0;i<4;i++) { if(flag[i]==0) { LED[i]++; if(LED[i]>300) { flag[i]=1; } }else { LED[i]--; if(LED[i]==0) { flag[i]=0; } } } } } } /* strcat(buff,"\n"); UART1_Write(buff, strlen(buff)); Lcd_print(buff); */ // UART1_Write(")",1); USART_ClearFlag(USART1, USART_FLAG_RXNE); } }
int main(int argc, char** argv) { int xVal, yVal; void Ludacris_Speed_GO(void); Ludacris_Speed_GO(); UART1_Config(); Timer1_Setup(); Pin_Setup(); Interrupt_Setup(); printf("\nWe're gon-na to get you...\n"); while(1) { switch (PromptState) { case GETXINPUT: case GETYINPUT: if (PromptState == GETXINPUT) { if(!Prompted) { printf("x = "); Prompted++; } if(RX_Done) { xVal = atoi(RX_Data); PromptState = GETYINPUT; Prompted = 0; RX_Done = 0; ClearString(); } } if (PromptState == GETYINPUT) { if(!Prompted) { printf("y = "); Prompted++; } if(RX_Done) { yVal = atoi(RX_Data); PromptState = CALCULATE; Prompted = 0; RX_Done = 0; ClearString(); } } Prompted = 1; break; case CALCULATE: Calculate(xVal, yVal); printf("Press Enter to play again..."); break; case WAITING: Nop(); if(RX_Done) { PromptState = RESET; RX_Done = 0; } break; case RESET: Prompted = 0; T1CONbits.TON = 1; PromptState = WAITING; } } return (EXIT_SUCCESS); }
void main(void) { /* Clock configuration -----------------------------------------*/ CLK_Config(); /* GPIO configuration ------------------------------------------*/ GPIO_Config_Init(); UART1_Config(); UART3_Config(); PWM_Config(); TIM2_Config(); TIM3_Config(); TIM4_Config(); I2C_RTC_Init(); /* Enable general interrupts */ enableInterrupts(); //【秒, 分, 时, 日, 星期, 月, 年】 uint8_t time[] = {00, 12, 10, 1, 1, 6, 15}; //Set_RT8563(time, 2, 7); ResetNetMode(); #if 0 uint8_t Alarm[5][3] = {1, 16, 31, 1, 16, 33, 1, 16, 35}; uint8_t Time[7] = {0}; uint8_t AlarmState = 0; uint8_t AlarmDelay = 1; unsigned int NET_AUTO_SEND = 0; #endif while (1) { #if 0 Delay(1000); Send_BAT_Voltage(Get_BAT_Value()); UART3_SendString("\n", 1); AQI2PM25(Get_DS_Value()); #endif if(DeviceStatus.Time_30ms == 1) { TouchKey_Read(); DeviceStatus.Time_30ms = 0; } if(DeviceStatus.Time_100ms == 1) { if(UART1_GetFlagStatus(UART1_FLAG_IDLE) == SET) { if(DataSize != 0) { DataResolve(RxRecvBuffer, DataSize); NetProcess(); DataSize = 0; } } DeviceStatus.Time_100ms = 0; } if(DeviceStatus.Time_1_s == 1) { Get_RT8563(time, 2, 7); #if 0 ArrayCopy((uint8_t *)&NetMode.SendData, time, 7); UART3_SendString((uint8_t *)&NetMode.SendData, 7); if(NetMode.Status & NET_CONNECT) { NET_LED_FLASH; NET_AUTO_SEND++; if(NET_AUTO_SEND == 10)//自动发送数据 { NetSendDataLength(); NET_AUTO_SEND = 0; } } else NET_AUTO_SEND = 0; #endif DeviceStatus.Time_1_s = 0; } if(DeviceStatus.Time_30_s == 1) { NetModeErrorFix(); DeviceStatus.Time_30_s = 0; } #if 0 GetTime(Time); if(ArrayCMP(Alarm, Time, 3) == 0 && AlarmState == 0) { GPIO_WriteHigh(GPIOF, GPIO_PIN_5); FAN_SPEED_HIGH; //高速 Alarm[2] += AlarmDelay; AlarmState = 1; } else if(ArrayCMP(Alarm, Time, 3) == 0 && AlarmState == 1) { GPIO_WriteLow(GPIOF, GPIO_PIN_5); FAN_SPEED_OFF; AlarmState = 0; Alarm[2] -= AlarmDelay; } #endif } }