/******************************************************************************* * 打开关闭结点 ********************************************************************************/ void configNode(uint8 config) { //LCD_Char_1_PrintNumber(config); if(config < 19) switch(config) { case 0 : { Timer_Start(); /* 开启定时器 */ break; } case 1 : { UART_1_PutStringConst("soe"); break; } case 2 : { UART_2_PutStringConst("soe"); break; } case 3 : { Timer_Start(); UART_1_PutStringConst("soe"); UART_2_PutStringConst("soe"); break; } case 10 : { Timer_Stop(); /* 关闭定时器 */ break; } case 11 : { UART_1_PutStringConst("sce"); break; } case 12 : { UART_2_PutStringConst("sce"); break; } case 13 : { Timer_Stop(); UART_1_PutStringConst("sce"); UART_2_PutStringConst("sce"); break; } default : { break; } } }
/** ********************************************************************************* * \fn static void RSema_Test(void); * ********************************************************************************* */ static void RSema_Test(void) { Timer_Start(&tmrRSemaToggle,0); SleepMs(100); Timer_Start(&tmrRSemaToggle,4000); Con_Printf_P("Trying to lock rsema\n"); Mutex_Lock(&testRSema); Con_Printf_P("Success, Unlocking rsema\n"); Mutex_Unlock(&testRSema); }
void SPI_DRV8860_GetFaults(uint16_t * faultArray, uint16_t arrayLength) { Uint16 i = 0; EALLOW; GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0; // Configure GPIO14 as GPIO //GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0; GpioDataRegs.GPACLEAR.bit.GPIO14 = 1; //GpioDataRegs.GPACLEAR.bit.GPIO26 = 1; Timer_Start(&mDelayTimer, 2); while(mDelayTimer._timeElapsed != TRUE) { Timer_Update(); } /// Inform the DRV8860 to read fault registers SPI_CS_LOW; Timer_Start(&mDelayTimer, 2); while(mDelayTimer._timeElapsed != TRUE) { Timer_Update(); } SPI_CS_HIGH; Timer_Start(&mDelayTimer, 2); while(mDelayTimer._timeElapsed != TRUE) { Timer_Update(); } GpioDataRegs.GPASET.bit.GPIO14 = 1; GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 3; // Configure GPIO14 as SPICLKB //GpioDataRegs.GPASET.bit.GPIO26 = 1; for (i = 0; i < arrayLength; i++) { SpibRegs.SPITXBUF = 0; } //GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 3; EDIS; }
void DriverUpdateInit(void) { /* stc_params_control_t *pvReturn; pvReturn = (stc_params_control_t*)malloc( sizeof(stc_params_control_t)*5 ); pvReturn[0].value = 12.3; */ Button_Init(ButtonCallback); InitLedDriver(); // dataLED.stc_w.leds = 0xFFFFFFFF; dataLED.stc_w.backlight[0] = 0xFF; dataLED.stc_w.backlight[1] = 0xFF; dataLED.stc_w.backlight[2] = 0xFF; dataLED.stc_w.backlight[3] = 0xFF; dataLED.stc_w.backlight[4] = 0xFF; dataLED.stc_w.backlight[5] = 0xFF; UpdateLeds(); SetValueBacklight(100); /* m_unTime.stcTimeFields.u8Hours = 12; m_unTime.stcTimeFields.u8Minutes = 0; m_unTime.stcTimeFields.u8Seconds = 0; m_unTime.stcTimeFields.u8Year = 0; m_unTime.stcTimeFields.u8Month = 12; m_unTime.stcTimeFields.u8Day = 24; if (RtcExt_Init(&m_unTime, RTC_EXT_CTRL_REG_SQWE | RTC_EXT_CTRL_REG_RS_32KHZ768) == Ok) { Uart_WriteString("RTC init\r\n", TRUE); } else { Uart_WriteString("RTC init errorr\r\n", TRUE); } */ Timer_Start(TIMER_ID_MAIN, 100, TRUE, UpdateSMC); Timer_Start(TIMER_500MS, 500, TRUE, Timer_500ms); Timer_Start(TIMER_1S, 1000, TRUE, Timer_1s); Timer_Start(TIMER_60S, 60000, TRUE, Timer_60s); // Init graphical interface Hmi_Init(); }
int main() { Bdisp_AllClr_VRAM(); Bdisp_EnableColor(1); DefineStatusAreaFlags(3, SAF_BATTERY | SAF_TEXT | SAF_GLYPH | SAF_ALPHA_SHIFT, 0, 0); // disable Catalog function throughout the add-in, as we don't know how to make use of it: Bkey_SetAllFlags(0x80); printf("Welcome to Eigenmath\n"); printf("To see version information,\npress Shift then Menu.\n"); run_startup_script(); aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } //in case we're running in a strip, check if this strip has a script to run. if(is_running_in_strip()) { int MCSsize; MCSGetDlen2(DIRNAME, SCRIPTFILE, &MCSsize); if (MCSsize > 0) { // there is a script to run... unsigned char* asrc = (unsigned char*)alloca(MCSsize*sizeof(unsigned char)+5); // 5 more bytes to make sure it fits... MCSGetData1(0, MCSsize, asrc); // read script from MCS execution_in_progress = 1; run((char*)asrc); execution_in_progress = 0; } } input_eval_loop(0); }
void main(void) { M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts Timer_EnableInt();//Enable interruptes on timer Timer_Start(); //Start LCD LCD_Start(); LCD_Init(); //SW1 connected to P1[0] //1 Clock tick every (1*10^-3)/10 = 0.0001 sec per cycles = 10000 Hz = .01 MHz //SysClk = 24Mhz //VC1 = sysclk/8 = 3Mhz //VC2 = VC1/3 = 1Mhz //VC3 source is VC2 //VC3 = VC2/100 = .01Mhz //Timer clock is VC3 while(1)//Control Loop { } }
void initPSoC_Master(void){ tempTemp = 0; tempSoilHum[0] = 0; tempSoilHum[1] = 0; tempSoilHum[2] = 0; tempSoilHum[3] = 0; tempSoilHum[4] = 0; tempSoilHum[5] = 0; // ISR UART_ISR_StartEx(UART_ISR); // Starts UART interrupt component timer_ISR_StartEx(timer_ISR); // Starts timer interrupt component UART_Start(); // Starts UART component Timer_Start(); // Starts timer component // Setup of timer interrupt uint32 maxPeriod = 0xFFFFFFFF; // The max period ((2^32)-1) = 179s uint32 period = TIME_BETWEEN_TIMER_INT * 24000; if (period > maxPeriod){ period = maxPeriod; } Timer_WritePeriod(period); RedLED_Write(LED_OFF); // Turn off red LED BlueLED_Write(LED_OFF); // Turn off blue LED }
void Start() { Timer_CreateConfiguration(&synchronizationInvitationTimer, 1000000, TIMER_MODE_RELAXED_CONTINUES, SynchronizationInviter); Timer_Start(&synchronizationInvitationTimer); Network_SetRawBedDataHandler(BedData); }
/*! * @brief Thread for the bread (packets). */ void PacketThread(void *data) { for (;;) { if (!Packet_Semaphore) { OS_TimeDelay(10); continue; } OS_SemaphoreWait(Packet_Semaphore, 0); LEDs_On(LED_BLUE); Timer_Start(&PacketTimer); HandlePacket(); /* * If there is a new packet available, * turn on the blue LED, start the timer * to turn the LED off and finally * handle the packet. * * Packet_Get blocks until a packet is available. */ // if (Packet_Get()) // { // LEDs_On(LED_BLUE); // Timer_Start(&PacketTimer); // HandlePacket(); // } } }
void pollProc(void *eventData) { uint16_t val; Timer_Start(&pollTimer,1); val = MDIO_Read(1,30); bit_errs += val; }
/******************************************************************************* * 初始化函数 ********************************************************************************/ void init() { CyGlobalIntEnable; //全局中断开启 ADC_DelSig_1_Start(); /* 配置并开启ADC */ ADC_DelSig_1_StartConvert(); /* 开始进行转换 */ Uart_Rx_ISR_StartEx(RxInterruptHandler); /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */ Uart_Tx_ISR_StartEx(TxInterruptHandler); /* 开启 Uart Tx 并连接到 TxInterruptHandler */ UART_Start(); /* 开启 UART */ Uart_Rx_ISR_1_StartEx(Rx_1_InterruptHandler); /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */ Uart_Tx_ISR_1_StartEx(Tx_1_InterruptHandler); /* 开启 Uart Tx 并连接到 TxInterruptHandler */ UART_1_Start(); /* 开启 UART1 */ Uart_Rx_ISR_2_StartEx(Rx_1_InterruptHandler); /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */ Uart_Tx_ISR_2_StartEx(Tx_1_InterruptHandler); /* 开启 Uart Tx 并连接到 TxInterruptHandler */ UART_2_Start(); /* 开启 UART2 */ Timer_ISR_StartEx(TimerInterruptHandler); /* 开启 Timer 中断并连接到 TimerInterruptHandler */ Timer_Start(); /* 开启定时器 */ LCD_Char_1_Start(); /* 初始化并清除LCD */ //LCD_Char_1_PrintString("init"); }
/** ************************************************************** * Tcb * TCB_Alloc(void); * Allocate a new TCB. This is called when a new connection * is detected or opened from local side. ************************************************************** */ static Tcb * TCB_Alloc(void) { uint16_t i; Tcb *tc; for (i = 0; i < array_size(tcpConnection); i++) { tc = &tcpConnection[i]; if (tc->inUse == false) { tc->inUse = true; /* *************************************************************** * Initial sequence number should be incremented every 4 us * by one according to section 3.3 of RFC793 *************************************************************** */ tc->SND_UNA = tc->ISS = tc->SND_NXT = (TimeUs_Get() >> 2); tc->dataSink = NULL; tc->retransCanceled = false; tc->eventData = NULL; tc->closeProc = NULL; tc->txDataAvail = false; tc->nxtFlgs = 0; tc->do_close = false; tc->busy = false; tc->currDataLen = 0; tc->maxWinSz = MAX_WIN_SZ; Timer_Start(&tc->watchdogTimer, 5000); //Con_Printf("Alloced tc %08lx",tc); return tc; } }
VOID SysTime_Init(INT8 nTimerNo) { // ##################################### what count have to pass for initialization ????????????? Timer_Init(&oTimer, nTimerNo, 0x189374BC6A7EF9D, CSL_TMR_ENAMODE_CONT, NULL, NULL, INTR_ITEM_TIMER_3); Timer_Start(&oTimer); }
void Connected(event e, void* data) { Timer_Stop(&connectionTimer); Leds_GreenOn(); Timer_CreateConfiguration(&pingerTimer, 2000000, TIMER_MODE_RELAXED_CONTINUES, Pinger); Timer_Start(&pingerTimer); }
/** ****************************************************************************** ** Starts a timer and waits synchronously until it is elapsed. ** ** \param u8TimerID TIMER_ID_? (defined in timer.h) ** \param u16TimeMs duration in ms ** \param bServeHardwareWatchdog serve hardware watchdog or not (if any) ** ** \return none *****************************************************************************/ void Timer_Wait(uint8_t u8TimerID, uint16_t u16TimeMs, boolean_t bServeHardwareWatchdog) { Timer_Start(u8TimerID, u16TimeMs, FALSE, NULL); while (Timer_IsElapsed(u8TimerID, TRUE) == FALSE) { WDTCP = 0x00; } }
/*---------------------------------------------------------------------------* * Routine: MSTimerInit *---------------------------------------------------------------------------* * Description: * Initialize and start the one millisecond timer counter. * Inputs: * void * Outputs: * void *---------------------------------------------------------------------------*/ void MSTimerInit(void) { // Reset counter Timer_DisableIRQ(); G_msTimer = 0; Timer_Start(_MSTimerISR); Timer_EnableIRQ(); }
void Start() { EventDispatcher_Subscribe(EVENT_CONNECTED, Connected); Network_SetRawBedDataHandler(BedData); Timer_CreateConfiguration(&connectionTimer, 80000, TIMER_MODE_RELAXED_CONTINUES, ConnectionBlinker); Timer_Start(&connectionTimer); }
VOID DUCTx_Start(DUCTx *pThis) { memset(&oTxPacket[0], 0, sizeof(oTxPacket)); Timer_Start(&pThis->oTmrProcessJob); Task_Start(&pThis->oTskReceiveJob); Task_Start(&pThis->oTskProcessJob); }
//====================================================================== void SysTick_Handler(void) // Обработчик прерываний от SysTick { msTicks++; // инкремент счётчика времени if (msTicks >= time_out) { // Если таймаут истек if(!UART_RCV_COUNT) Timer_Start(); else{ UART_DONE=0xff; } } }
int main() { //Initializations clearPacketSBD(); clearPacketwind(); UART_Wind_Start(); UART_SBD_Start(); psoc_Start(); isr_Wind_StartEx(IntWind); SBD_reply_StartEx(SBD_int); clock_Start(); master_Start(); ADC_Start(); CyGlobalIntEnable; //Writes to magnetometer to be read from (not calibration mode) writeregister((uint8) 0x00, (uint8) 0x70); writeregister((uint8) 0x01, (uint8) 0xA0); writeregister((uint8) 0x02, (uint8) 0x00); CyDelay(15000u); clearPacketwind(); //Query Sensor for wind, pressure, temperature and humidity data UART_Wind_PutString("0R\r\n"); timeout_isr_StartEx(windtimer); timer_clock_Start(); Timer_Start(); windtime = 0; for(;;) { //When the packet is received takes other sensor data, sends packet and turns off power if(windpacketReceived){ Timer_Stop(); timer_clock_Stop(); timeout_isr_Stop(); windprocessPacket(); } //Here to clear any unexpected outputs from SBD Warrior if(SBDpacketReceived) { clearPacketSBD(); } //changes if(windtimeout == 1) { windbroke = 1; windprocessPacket(); } //end changes } }
int main() { /* Place your initialization/startup code here (e.g. MyInst_Start()) */ Timer_Start(); Timer_1_Start(); timer_int_StartEx(TIMER_ISR); timer1_int_StartEx(TIMER1_ISR); CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */ for(;;) { /* Place your application code here. */ } }
/*! * @brief This-stuff-hasn't-been-adjusted-yet thread. */ void MainThread(void *data) { for (;;) { OS_TimeDelay(10); /* * If there is a new packet available, * turn on the blue LED, start the timer * to turn the LED off and finally * handle the packet. */ // if (Packet_Get()) // { // LEDs_On(LED_BLUE); // Timer_Start(&PacketTimer); // HandlePacket(); // } /* * If the accelerometer 1Hz timer is *NOT* running and * we are in poll mode, resta rt the timer. * Also reset the flag. */ if (!AccTimerRunningFlag && (Accel_GetMode() == ACCEL_POLL)) { AccTimerRunningFlag = 1; Timer_Start(&AccTimer); } /* * If there is a pending accelerometer read, * read the XYZ values from the accelerometer * and clear the flag. */ if (PendingAccelReadFlag) { PendingAccelReadFlag = 0; Accel_ReadXYZ(AccReadData); } /* * If there is accelerometer data available, * clear the flag and handle the data. */ if (NewAccelDataFlag) { NewAccelDataFlag = 0; HandleNewAccelData(); } } }
/* #FN# Re-starts the timer an emulated Atari is based on */ void /* #AS# Nothing */ Timer_Reset( void ) { LARGE_INTEGER lnTimeFreq; int nSysFreq = (Atari800_TV_PAL == Atari800_tv_mode ? g_Timer.nPalFreq : g_Timer.nNtscFreq); QueryPerformanceFrequency( &lnTimeFreq ); s_ulDeltaT = lnTimeFreq.LowPart / (nSysFreq ? nSysFreq : 1); s_nSleepThreshold = MulDiv( lnTimeFreq.LowPart, SLEEP_TIME_IN_MS + 1, 1000L ); Timer_Start(FALSE); } /* #OF# Timer_Reset */
//returns the checksum int Zdma1Int(int srcAddr,int dstAddr,int length,int dw) { int time; zdma1Done=0; rINTMSK=~(BIT_GLOBAL|BIT_ZDMA1); rZDISRC1=srcAddr|(dw<<30)|(1<<28); // inc rZDIDES1=dstAddr|( 2<<30)|(1<<28); // inc rZDICNT1=length |( 2<<28)|(1<<26)|(3<<22)|(1<<20); //whole,unit transfer,int@TC,enable DMA rZDCON1=0x1; // start!!! Timer_Start(3);//128us resolution while(zdma1Done==0); time=Timer_Stop(); Uart_Printf(" ZDMA1 %8x->%8x,%x: time = %dms\n",srcAddr,dstAddr,length,time);//*128E-6); rINTMSK=BIT_GLOBAL; }
void Metro_start( int ix , float seconds , int count , int stage ) { if( ix < 0 || ix >= max_num_metros ){ printf("metro_start: bad index\n"); return; } Metro_t* t = &(metros[ix]); t->status = METRO_STATUS_RUNNING; t->count = count; t->stage = stage; Timer_Set_Params( ix, seconds ); Timer_Start( ix ); }
/** ****************************************************************************** ** Initialize all assigned port pins and set up timer for scanning operations. ** ** \param pfnCallback callback function pointer for button status update ** ** \return none *****************************************************************************/ void Button_Init(button_callback_func_ptr_t pfnCallback) { uint_fast8_t fu8ButtonIndex; for (fu8ButtonIndex = 0; fu8ButtonIndex < BUTTON_COUNT; fu8ButtonIndex++) { stc_button_control_t* pstcButton = &m_astcButtonCtrl[fu8ButtonIndex]; // Set pin direction to input DDR(pstcButton->u8PortNumber) &= ~pstcButton->u8PinMask; pstcButton->u8DebounceCounter = BUTTON_DEBOUNCE_COUNT - 1; pstcButton->enCurrState = StateInvalid; } m_pfnCallback = pfnCallback; // Start timer for debouncing buttons Timer_Start(TIMER_ID_BUTTON, BUTTON_SCAN_INTERVAL_MS, TRUE, ScanTimerCallback); }
void main(void) { anypio_write(LED, false); // prepare the RGB outputs for PWM (timer and digital mode) ANY_GPIO_SET_FUNCTION(0,8,TMR,IOCON_IO_ADMODE_DIGITAL); ANY_GPIO_SET_FUNCTION(0,9,TMR,IOCON_IO_ADMODE_DIGITAL); ANY_GPIO_SET_FUNCTION(0,10,TMR,IOCON_IO_ADMODE_DIGITAL); // enable the timer Timer_Enable(CT16B0, true); // And set the match value to "about half" Timer_SetMatchValue(CT16B0, 0, 32000); Timer_SetMatchBehaviour(CT16B0, 0, 0); // enable PWM on red pin ... Timer_EnablePWM(CT16B0, 0, true); // repeat for green ... Timer_SetMatchValue(CT16B0, 1, 32000); Timer_SetMatchBehaviour(CT16B0, 1, 0); Timer_EnablePWM(CT16B0, 1, true); // ... and blue Timer_SetMatchValue(CT16B0, 2, 32000); Timer_SetMatchBehaviour(CT16B0, 2, 0); Timer_EnablePWM(CT16B0, 2, true); // finally, provide an additional matchvalue to reset the timer to 0 when // it reach 65635. Not technically necessary, because the timer's // maximum value is 65635 anyway and it would wrap back to 0 by // itself. Timer_SetMatchValue(CT16B0, 3, 65535); Timer_SetMatchBehaviour(CT16B0, 3, TIMER_MATCH_RESET); // now start the timer! Timer_Start(CT16B0); // There's a `systick` routine below that updates the rainbow // animation every 10ms, activate this routine: SYSCON_StartSystick_10ms(); }
int Zdma0Int(int srcAddr,int dstAddr,int length,int dw) //returns the checksum { int time; zdma0Done=0; rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0); rZDISRC0=srcAddr|(dw<<30)|(1<<28); // inc rZDIDES0=dstAddr|( 2<<30)|(1<<28); // inc rZDICNT0=length |( 2<<28)|(1<<26)|(3<<22)|(1<<20); //whole,unit transfer,int@TC,enable DMA rZDCON0=0x1; // start!!! Timer_Start(3);//128us resolution while(zdma0Done==0); time=Timer_Stop(); Uart_Printf(" ZDMA0 %8x->%8x,%x: time = %dms\n",srcAddr,dstAddr,length,time);//*128E-6); rINTMSK=BIT_GLOBAL; return time; }
int main() { Timer_Start(); PWM_IR_Start(); PWM_MOT1_Start(); PWM_MOT2_Start(); PWM_MOT3_Start(); Comp1_Start(); Comp2_Start(); Comp3_Start(); VDAC1_Start(); VDAC2_Start(); VDAC3_Start(); CyPmAltAct(PM_ALT_ACT_TIME_NONE,PM_ALT_ACT_SRC_NONE); /* The firmware never gets to here due to the CyPmAltAct call */ for(;;) { } }
int main() { /* Start all components used on schematic */ VDAC8_1_Start(); VDAC8_2_Start(); Opamp_1_Start(); Opamp_2_Start(); Filter_Start(); Timer_Start(); ISR_Timer_StartEx(Timer_interrupt_handler); /* Enable the interrupt register bit to poll Value 1 for Channel A, Value 2 for Channel B */ Filter_INT_CTRL_REG |= (1 << Filter_CHANNEL_A); CyGlobalIntEnable; for(;;) { //CyDelay(10); } } /* End of main */