#include "task_hal.h" #include "stddef.h" #include "stm32f10x.h" // Device header #include "stdio.h" #include "pt_timer.h" #include "GPIO_STM32F10x.h" // Device header #define GPIO_LED GPIOA #define PORT_LED GPIO_Pin_0 void InitSysTick(uint32_t tick_per_s) { SysTick_Config(SystemCoreClock/tick_per_s); } static int i = 0; //示波器打桩 //程闪灯任务 PT_THREAD(TaskBlinLed(struct pt *pt1 )) { static struct timer input_timer; PT_BEGIN(pt1); while(1) { timer_set(&input_timer,900); GPIO_SetBits(GPIO_LED,PORT_LED); i = 1; PT_WAIT_UNTIL(pt1,timer_expired(&input_timer)); timer_set(&input_timer,100); GPIO_ResetBits(GPIO_LED,PORT_LED); i = 0; PT_WAIT_UNTIL(pt1,timer_expired(&input_timer)); } PT_END(pt1); } void InitLEDPort(void) { GPIO_PortClock(GPIO_LED,true); GPIO_InitTypeDef InitTypeDef ; InitTypeDef.GPIO_Mode = GPIO_Mode_Out_PP; InitTypeDef.GPIO_Speed = GPIO_Speed_50MHz; InitTypeDef.GPIO_Pin = PORT_LED; //GPIO_PinConfigure(GPIO_LED,); GPIO_Init(GPIO_LED,&InitTypeDef ); } //回调接口 func SYSTICK_CALLBACK; void SysTick_Handler(void) { if(SYSTICK_CALLBACK!=NULL) SYSTICK_CALLBACK(); } void SetSYSTickCallBack(func pFunc) { SYSTICK_CALLBACK = pFunc; } #if(!EnEventRecorder) void SerialInit(void) { /* UART_InitStructure UART_initStruct; PORT_Init(PORTC, PIN2, PORTC_PIN2_UART3_RX, 1); // PORT_Init(PORTC, PIN3, PORTC_PIN3_UART3_TX, 0); // UART_initStruct.Baudrate = 115200*2; UART_initStruct.DataBits = UART_DATA_8BIT; UART_initStruct.Parity = UART_PARITY_NONE; UART_initStruct.StopBits = UART_STOP_1BIT; UART_initStruct.RXThreshold = 3; UART_initStruct.RXThresholdIEn = 0; UART_initStruct.TXThreshold = 3; UART_initStruct.TXThresholdIEn = 0; UART_initStruct.TimeoutTime = 10; UART_initStruct.TimeoutIEn = 0; UART_Init(UART3, &UART_initStruct); UART_Open(UART3); */ } int fputc(int ch, FILE *f) { /* UART_WriteByte(UART3, ch); while(UART_IsTXBusy(UART3)); */ return ch; } #elif(EnEventRecorder) #include "EventRecorder.h" void Init_EventRecorder(void) { EventRecorderInitialize(EventRecordAll,1U); EventRecorderStart(); } #endif