/** * @brief Main program. * @param None * @retval None */ void main(void) { /* CLK configuration -------------------------------------------*/ CLK_Config(); /* Initialize Leds mounted on STM8L1526-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Turn on LED1 and LED3 */ STM_EVAL_LEDOn(LED1); STM_EVAL_LEDOn(LED3); /* TIM4 configuration -------------------------------------------*/ TIM4_Config(); while (1) { /* Toggle LED2 and LED4 */ STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED4); /* Insert 50 ms delay */ Delay(50); /* Toggle LED1 and LED3 */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED3); /* Insert 100 ms delay */ Delay(100); } }
/** * @brief Main program. * @param None * @retval None */ void main(void) { /* TIM1 configuration -----------------------------------------*/ TIM1_Config(); /* TIM4 configuration -----------------------------------------*/ TIM4_Config(); /* Main Output Enable */ TIM1_CtrlPWMOutputs(ENABLE); enableInterrupts(); while (1) {} }
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; } } }
/******************************************************************************* * 名 称: Bsp_InitTimer * 功 能: 初始化定时器 * 入口参数: 无 * 出口参数: 无 * 作 者: Roger-WY * 创建日期: 2014-08-20 * 修 改: * 修改日期: * 备 注: *******************************************************************************/ void Bsp_InitTimer(void) { uint8_t i; /*********************************************** * 描述: 清零所有的软件定时器 */ for (i = 0; i < TMR_COUNT; i++) { g_Tmr[i].Count = 0; g_Tmr[i].PreLoad = 0; g_Tmr[i].Flag = 0; g_Tmr[i].Mode = TMR_ONCE_MODE; /* 缺省是1次性工作模式 */ } /*********************************************** * 描述: 配置基本定时器4 */ TIM4_Config(); }
uint8_t LineFollow_Init() { lineFollowState = INIT_STATE; lineFollowErrorType = NO_ERR; readCycle = 0; maximumSensorValue = 0; maximumThreshold = 0; distanceCorrectionUnit = 0; maxAvgDiff = 0; edgeValueVerifyingCounter = 0; quantizedDistance = 0; distanceAddition = 0; distanceFromLine = 0; previousDistanceFromLine = 0; frontAverage = 0; rearAverage = 0; /* Controller parameters */ Kp = 3; Kd = 0; /* Init peripheral drivers */ TIM4_Config(); NVIC_TIM4(); SPI2_Init(); ADEXT_Init(); MUX_Init(); SHIFT_Init(); SERVO_Init(); return 0; }
/** * @brief Execute the demo application. * @param None * @retval None */ static void Demo_Exec(void) { RCC_ClocksTypeDef RCC_Clocks; uint8_t togglecounter = 0x00; while(1) { DemoEnterCondition = 0x00; /* Reset UserButton_Pressed variable */ UserButtonPressed = 0x00; /* Initialize LEDs to be managed by GPIO */ STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); /* Turn OFF all LEDs */ STM_EVAL_LEDOff(LED4); STM_EVAL_LEDOff(LED3); STM_EVAL_LEDOff(LED5); STM_EVAL_LEDOff(LED6); /* Waiting User Button is pressed */ while (UserButtonPressed == 0x00) { /* Toggle LED4 */ STM_EVAL_LEDToggle(LED4); Delay(10); /* Toggle LED4 */ STM_EVAL_LEDToggle(LED3); Delay(10); /* Toggle LED4 */ STM_EVAL_LEDToggle(LED5); Delay(10); /* Toggle LED4 */ STM_EVAL_LEDToggle(LED6); Delay(10); togglecounter ++; if (togglecounter == 0x10) { togglecounter = 0x00; while (togglecounter < 0x10) { STM_EVAL_LEDToggle(LED4); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED5); STM_EVAL_LEDToggle(LED6); Delay(10); togglecounter ++; } togglecounter = 0x00; } } /* Waiting User Button is Released */ while (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) {} UserButtonPressed = 0x00; /* TIM4 channels configuration */ TIM4_Config(); /* Disable all Timer4 channels */ TIM_CCxCmd(TIM4, TIM_Channel_1, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_2, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_3, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_4, DISABLE); /* MEMS configuration */ LIS302DL_InitStruct.Power_Mode = LIS302DL_LOWPOWERMODE_ACTIVE; LIS302DL_InitStruct.Output_DataRate = LIS302DL_DATARATE_100; LIS302DL_InitStruct.Axes_Enable = LIS302DL_XYZ_ENABLE; LIS302DL_InitStruct.Full_Scale = LIS302DL_FULLSCALE_2_3; LIS302DL_InitStruct.Self_Test = LIS302DL_SELFTEST_NORMAL; LIS302DL_Init(&LIS302DL_InitStruct); /* Required delay for the MEMS Accelerometre: Turn-on time = 3/Output data Rate = 3/100 = 30ms */ Delay(30); DemoEnterCondition = 0x01; /* MEMS High Pass Filter configuration */ LIS302DL_FilterStruct.HighPassFilter_Data_Selection = LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER; LIS302DL_FilterStruct.HighPassFilter_CutOff_Frequency = LIS302DL_HIGHPASSFILTER_LEVEL_1; LIS302DL_FilterStruct.HighPassFilter_Interrupt = LIS302DL_HIGHPASSFILTERINTERRUPT_1_2; LIS302DL_FilterConfig(&LIS302DL_FilterStruct); LIS302DL_Read(Buffer, LIS302DL_OUT_X_ADDR, 6); X_Offset = Buffer[0]; Y_Offset = Buffer[2]; Z_Offset = Buffer[4]; /* USB configuration */ Demo_USBConfig(); /* Waiting User Button is pressed */ while (UserButtonPressed == 0x00) {} /* Waiting User Button is Released */ while (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) {} /* Disable SPI1 used to drive the MEMS accelerometre */ SPI_Cmd(LIS302DL_SPI, DISABLE); /* Disconnect the USB device */ DCD_DevDisconnect(&USB_OTG_dev); USB_OTG_StopDevice(&USB_OTG_dev); } }
/** * @brief Execute the demo application. * @param None * @retval None */ static void Demo_Exec(void) { uint8_t togglecounter = 0x00; /* Initialize Accelerometer MEMS*/ if(BSP_ACCELERO_Init() != HAL_OK) { /* Initialization Error */ Error_Handler(); } while(1) { DemoEnterCondition = 0x00; /* Reset UserButton_Pressed variable */ UserButtonPressed = 0x00; /* Configure LEDs to be managed by GPIO */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); BSP_LED_Init(LED5); BSP_LED_Init(LED6); /* SysTick end of count event each 10ms */ SystemCoreClock = HAL_RCC_GetHCLKFreq(); SysTick_Config(SystemCoreClock / 100); /* Turn OFF all LEDs */ BSP_LED_Off(LED4); BSP_LED_Off(LED3); BSP_LED_Off(LED5); BSP_LED_Off(LED6); /* Waiting User Button is pressed */ while (UserButtonPressed == 0x00) { /* Toggle LED4 */ BSP_LED_Toggle(LED4); HAL_Delay(10); /* Toggle LED4 */ BSP_LED_Toggle(LED3); HAL_Delay(10); /* Toggle LED4 */ BSP_LED_Toggle(LED5); HAL_Delay(10); /* Toggle LED4 */ BSP_LED_Toggle(LED6); HAL_Delay(10); togglecounter ++; if (togglecounter == 0x10) { togglecounter = 0x00; while (togglecounter < 0x10) { BSP_LED_Toggle(LED4); BSP_LED_Toggle(LED3); BSP_LED_Toggle(LED5); BSP_LED_Toggle(LED6); HAL_Delay(10); togglecounter ++; } togglecounter = 0x00; } } /* Waiting User Button is Released */ while (BSP_PB_GetState(BUTTON_KEY) != KEY_NOT_PRESSED) {} UserButtonPressed = 0x00; /* TIM4 channels configuration */ TIM4_Config(); DemoEnterCondition = 0x01; /* USB configuration */ Demo_USBConfig(); /* Waiting User Button is pressed */ while (UserButtonPressed == 0x00) {} /* Waiting User Button is Released */ while (BSP_PB_GetState(BUTTON_KEY) != KEY_NOT_PRESSED) {} /* Disconnect the USB device */ USBD_Stop(&hUSBDDevice); USBD_DeInit(&hUSBDDevice); if(HAL_TIM_PWM_DeInit(&htim4) != HAL_OK) { /* Initialization Error */ Error_Handler(); } } }
// ---------------------------------------------------------------------------- void HwInit( void ) { SystemCoreClockUpdate( ); // Make sure SysTick is running at a 1ms rate. if ( SysTick_Config( SystemCoreClock / 1000 ) ) { /* Capture error */ while ( 1 ); } // SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK_Div8 ); /* Initialize Leds mounted on STM32F4-Discovery board */ STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); /* Turn on LED4 and LED5 */ STM_EVAL_LEDOn(LED4); STM_EVAL_LEDOn(LED5); /* TIM Configuration */ TIM3_Config(); TIM4_Config(); /* ----------------------------------------------------------------------- TIM3 Configuration: generate 4 PWM signals with 4 different duty cycles. In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1), since APB1 prescaler is different from 1. TIM3CLK = 2 * PCLK1 PCLK1 = HCLK / 4 => TIM3CLK = HCLK / 2 = SystemCoreClock /2 To get TIM3 counter clock at 28 MHz, the prescaler is computed as follows: Prescaler = (TIM3CLK / TIM3 counter clock) - 1 Prescaler = ((SystemCoreClock /2) /28 MHz) - 1 To get TIM3 output clock at 30 KHz, the period (ARR)) is computed as follows: ARR = (TIM3 counter clock / TIM3 output clock) - 1 = 665 TIM3 Channel1 duty cycle = (TIM3_CCR1/ TIM3_ARR)* 100 = 50% TIM3 Channel2 duty cycle = (TIM3_CCR2/ TIM3_ARR)* 100 = 37.5% TIM3 Channel3 duty cycle = (TIM3_CCR3/ TIM3_ARR)* 100 = 25% TIM3 Channel4 duty cycle = (TIM3_CCR4/ TIM3_ARR)* 100 = 12.5% Note: SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file. Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() function to update SystemCoreClock variable value. Otherwise, any configuration based on this variable will be incorrect. ----------------------------------------------------------------------- */ /* Compute the prescaler value */ PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 28000000) - 1; /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = 665; TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit( TIM3, &TIM_TimeBaseStructure ); TIM_TimeBaseInit( TIM4, &TIM_TimeBaseStructure ); /* PWM1 Mode configuration: Channel1 */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = CCR1_Val; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC1Init( TIM3, &TIM_OCInitStructure ); TIM_OC1Init( TIM4, &TIM_OCInitStructure ); TIM_OC1PreloadConfig( TIM3, TIM_OCPreload_Enable ); TIM_OC1PreloadConfig( TIM4, TIM_OCPreload_Enable ); /* PWM1 Mode configuration: Channel2 */ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = CCR2_Val; TIM_OC2Init( TIM3, &TIM_OCInitStructure ); TIM_OC2Init( TIM4, &TIM_OCInitStructure ); TIM_OC2PreloadConfig( TIM3, TIM_OCPreload_Enable ); TIM_OC2PreloadConfig( TIM4, TIM_OCPreload_Enable ); /* PWM1 Mode configuration: Channel3 */ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = CCR3_Val; TIM_OC3Init( TIM3, &TIM_OCInitStructure ); TIM_OC3Init( TIM4, &TIM_OCInitStructure ); TIM_OC3PreloadConfig( TIM3, TIM_OCPreload_Enable ); TIM_OC3PreloadConfig( TIM4, TIM_OCPreload_Enable ); /* PWM1 Mode configuration: Channel4 */ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = CCR4_Val; TIM_OC4Init( TIM3, &TIM_OCInitStructure ); TIM_OC4Init( TIM4, &TIM_OCInitStructure ); TIM_OC4PreloadConfig( TIM3, TIM_OCPreload_Enable ); TIM_OC4PreloadConfig( TIM4, TIM_OCPreload_Enable ); TIM_ARRPreloadConfig( TIM3, ENABLE ); TIM_ARRPreloadConfig( TIM4, ENABLE ); /* TIM3 enable counter */ TIM_Cmd( TIM3, ENABLE ); TIM_Cmd( TIM4, ENABLE ); vUSART2_Init(); // Start up UART2 }
void dc_moter_init() { MY_GPIO_Init(); TIM3_Config(); TIM4_Config(); }
/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* RCC configuration */ RCC_Config(); /* GPIO configuration */ GPIO_Config(); /* TIM4 configuration */ TIM4_Config(); /* UART4 configuration */ UART4_Config(); /* SPI3 configuration */ SPI3_Config(); /* NVIC configuration */ NVIC_Config(); /* Network Configuration */ NET_Config(); /* Configure SysTick */ SysTick_Config(SystemCoreClock / 1000); /* Infinite Loop */ while (1) { if(TimerCounter >= 10) { TimerCounter = 0; if(SendFlag) { //SendFlag = False; char str[30]; if(order++ < 90) { float one = NULL; float two = NULL; float thr = NULL; if(inc <= 300) { one = convertSample(EQ_SAMPLE[inc++]) * 1e-7; two = convertSample(EQ_SAMPLE[inc++]) * 1e-7; thr = convertSample(EQ_SAMPLE[inc++]) * 1e-7; } else { inc = 0; } sprintf(str, "%-0.7f,%-0.7f,%-0.7f\n", one, two, thr); } else { order = 0; } // Only when socket is established, send data if(getSn_SR(SOCK_TCPS) == SOCK_ESTABLISHED) { /* send the received data */ send(SOCK_TCPS, (uint8*)str, strlen(str)); } } } if(ParseUART4) { ParseUART4 = False; printSysCfg(); } ProcessTcpSever(); } }
void TIM4_PWM_Init(void) { TIM4_Config(); TIM4_PWM_PORT_Config(); }
/** * @brief Main program. * @param None * @retval None */ int main(void) { float capacitanceratio; /* STM32F3xx HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /******* Initialize LEDs available on STM32303E-EVAL RevC board ******************/ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /*##-1- Initialize the Key push-button and Joystick ####################################*/ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); BSP_JOY_Init(JOY_MODE_GPIO); /*##-2- Initialize the LCD #################################################*/ /* Initialize the LCD */ BSP_LCD_Init(); /*##-3- Display messages on LCD ############################################*/ /* Display Example Welcome message */ Display_ExampleDescription(); /* Wait For User inputs */ while (1) { if (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) { while (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET); break; } } /* Display Example Template */ HYGROMETER_SetHint(); /*##-4- Configure DACx #####################################################*/ /* configure DACx */ DACx_Config(); /*##-5- Configure Comparators ##############################################*/ /* configure COMPx */ COMPx_Config(); /*##-6- Configure Timers ###################################################*/ TIM3_Config(); TIM4_Config(); /*##-7- Start Example ######################################################*/ /* wait until first AvrgICReadValue is calculated */ while(AvrgICReadValue == 0); /* Enter Calibration menu */ Calibration_Menu(); /* Infinite loop */ while (1) { /* Calculate Trigger Time Value */ TriggerTime = (float) (AvrgICReadValue-ICError)/SystemCoreClock; /* Comp4 inverted input connected to DACx : * TriggerTime = RES * Capacitance * ln(VDD/(VDD - VREF)) * @VREF = 2.086V (generated by DAC), ln(VDD/(VDD - VREF)) is ~ 1 * ==> Capacitance = TriggerTime/RES */ Capacitance = (float) TriggerTime/RES; /* Calculate humidity value using reversed polynomial expression */ capacitanceratio = Capacitance/Capacitance55RH; /* RH (%) = -3.4656*10^3 * X^3 + 1.0732*10^4 * X^2 - 1.0457*10^4*X + 3.2459*10^3 with X = C (read) / C@55%RH = capacitanceratio */ RelativeHumidity = RP3 * pow(capacitanceratio, 3) + RP2 * pow(capacitanceratio, 2) + RP1 * capacitanceratio + RP0; /* Restrict Relative Humidity Value to 0-99 Domain */ if (RelativeHumidity < 0) { RelativeHumidity = 0; } if (RelativeHumidity > 99) { RelativeHumidity = 99; } /* Display the humidity value */ Display_Humidity((uint32_t) RelativeHumidity); } }
void main(void) { //CFG->GCR |= 0x01; //disable swim pin /* Configure the Fcpu to DIV1*/ CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1); /* select Clock = 16 MHz */ CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1); /* Configure the system clock to use HSI clock source and to run at 16Mhz */ CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE); CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); CLK_HSICmd(ENABLE); FLASH_Config(); EXTI_DeInit(); //You should add: // Define FLASH programming time //FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD); //optbyte1 = FLASH_ReadOptionByte(0x4803); //255 by def //optbyte2 = FLASH_ReadOptionByte(0x4804); //255 by def /* if (optbyte != 765) { FLASH_Unlock(FLASH_MEMTYPE_DATA); // unlock data memory by passing the RASS key in the proper order FLASH_ProgramOptionByte(0x4803, 0xFD); // byte OPT2 resides at address x4803, write a 1 to bit 7. This will also write to the NOPT2 complement byte FLASH_Lock(FLASH_MEMTYPE_DATA); // re-lock data memory } */ //General purpose timer TIM4_Config(); #ifdef DFS_90 HotAir_Config(); #endif #ifndef DFS_90 GPIO_Init(CONTROL_GPIO_PORT, CONTROL_GPIO_PIN, GPIO_MODE_OUT_PP_LOW_FAST); #endif Temperature_ADC_Config(); STM_EVAL_SEGInit(SEG1); STM_EVAL_SEGInit(SEG2); STM_EVAL_SEGInit(SEG3); STM_EVAL_LEDInit(LEDA); STM_EVAL_LEDInit(LEDB); STM_EVAL_LEDInit(LEDC); STM_EVAL_LEDInit(LEDD); STM_EVAL_LEDInit(LEDE); STM_EVAL_LEDInit(LEDF); STM_EVAL_LEDInit(LEDG); STM_EVAL_LEDInit(LEDP); #ifndef SOLDERING_VAR2 //STM_EVAL_LEDInit(LEDP); #endif // STM_EVAL_SEGOn(SEG1); // STM_EVAL_SEGOn(SEG2); // STM_EVAL_SEGOn(SEG3); // // STM_EVAL_LEDOn(LEDA); // STM_EVAL_LEDOn(LEDB); // STM_EVAL_LEDOn(LEDC); // STM_EVAL_LEDOn(LEDD); // STM_EVAL_LEDOn(LEDE); // STM_EVAL_LEDOn(LEDF); // STM_EVAL_LEDOn(LEDG); // // STM_EVAL_LEDOff(LEDA); // STM_EVAL_LEDOff(LEDB); // STM_EVAL_LEDOff(LEDC); // STM_EVAL_LEDOff(LEDD); // STM_EVAL_LEDOff(LEDE); // STM_EVAL_LEDOff(LEDF); // STM_EVAL_LEDOff(LEDG); // STM_EVAL_LEDOff(LEDP); // // STM_EVAL_SEGOff(SEG1); // STM_EVAL_SEGOff(SEG2); // STM_EVAL_SEGOff(SEG3); //STM_EVAL_LEDOn(LEDP); //GPIO_Init(ENC_DN_BUTTON_PORT, ENC_DN_BUTTON_PIN, GPIO_MODE_IN_PU_NO_IT); //GPIO_Init(ENC_UP_BUTTON_PORT, ENC_UP_BUTTON_PIN, GPIO_MODE_IN_PU_NO_IT); STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_REED, BUTTON_MODE_GPIO); ssegInit(); ssegWriteStr("1.0.1", 5, SEG1); enableInterrupts(); #ifdef DFS_90 HotAir_Main(); #endif #ifdef SOLDERING_HAKKO_A1321 Soldering_Main(); #endif while(1) { /* #if 0 for (level = 0; level < calUpperLimit; level +=5) { Delayms(1); } for (level = calUpperLimit; level > 0; level -=5) { Delayms(1); } #else RawData = GetAdcValue(ADC_SOLDER_TEMP_CHANNEL); SmoothData = SmoothData - (LPF_Beta * (SmoothData - RawData)); level = ((int)SmoothData)*26; #endif */ } }
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 } }