/* * @Brief: Initializes the servo peripheral * @param none * @return nothing * @IMPORTANT: this function uses Timer 1, 2 and 3 to generate the servo signals, so * they won't be available to use. */ static void servoInitTimers(void){ Timer_Init( TIMER1, Timer_microsecondsToTicks(SERVO_COMPLETECYCLE_PERIOD), timer1CompareMatch0func ); Timer_Init( TIMER2, Timer_microsecondsToTicks(SERVO_COMPLETECYCLE_PERIOD), timer2CompareMatch0func ); Timer_Init( TIMER3, Timer_microsecondsToTicks(SERVO_COMPLETECYCLE_PERIOD), timer3CompareMatch0func ); }
void Global_Init(void) { // Initialize system SystemInit(); // Initialize button and LEDs init_GPIO(); // Initialize delay TM_DELAY_Init(); // Init sounds InitSounds(); // Initialize accelerometer AccInit(); // Initialize USB, IO, SysTick, and all those other things you do in the morning init(); //timerINit Timer_Init(); }
int main( void) { uint16_t pdu_len = 0; BACNET_ADDRESS src; /* source address */ uint8_t pdu[MAX_MPDU]; /* PDU data */ Timer_Init(); bacnet_init(); /* broadcast an I-Am on startup */ Send_I_Am(&Handler_Transmit_Buffer[0]); for (;;) { millisecond_timer(); if (!DCC_Timer) { dcc_timer_seconds(1); DCC_Timer = 1000; } /* BACnet handling */ pdu_len = datalink_receive(&src, &pdu[0], MAX_MPDU, 0); if (pdu_len) { #ifndef DLMSTP_TEST npdu_handler(&src, &pdu[0], pdu_len); #endif } } }
/* void run_selection(sora::Device *dev) { //selection test sora::selection::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::selection::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::selection::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_shadow_map(sora::Device *dev) { //depth map test sora::shadowmap::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::shadowmap::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::shadowmap::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { exit(0); } } } void run_celshading(sora::Device *dev) { //celshading test sora::celshading::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::celshading::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::celshading::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_depthmap(sora::Device *dev) { //celshading test sora::depthmap::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::depthmap::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::depthmap::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_gles_1_test() { while(true) { SORA_test_draw(kWinWidth, kWinHeight); glfwSwapBuffers(); } } void run_gles_2_test() { SORA_init_gl_env(); //glewInit(); while(true) { SORA_test_draw2(kWinWidth, kWinHeight); glfwSwapBuffers(); } } */ int main(int argc, char *argv[]) { if( !glfwInit() ) { exit( EXIT_FAILURE ); } // Open an OpenGL window if( !glfwOpenWindow( kWinWidth,kWinHeight, 0,0,0,0,0,0, GLFW_WINDOW ) ) { glfwTerminate(); exit( EXIT_FAILURE ); } //gl test //run_gles_1_test(); //run_gles_2_test(); // init glew glewInit(); Timer_Init(); sora::Device::CreateDevice(); sora::Device *device = sora::Device::GetInstance(); run_main(device); //logic end //run_post_effect(device); //run_freeglutfont(device); //run_sysfont(device); //run_selection(device); //run_depthmap(device); //run_shadow_map(device); sora::Device::DestroyDevice(); glfwTerminate(); return 0; }
void Libdeng_Init(void) { R_BuildTexGammaLut(0.f); bamsInit(); Timer_Init(); Z_Init(); }
void init() { // Clock Initialize Clock_Init(); Timer_Init(); _NSTDIS = 1; //Interrupt Nesting Disable // Digital Communication Initialize //UART1_Init(); ADC_Init(); I2C1_Init(); // Peripherals Initialize LCD_Init(); // Interrupt 3 Initialize SW_TRIS = TRIS_INPUT; // RA2/INT3 as input; _INT3IP = 1; _INT3IF = 0; _INT3IE = 1; _INT3EP = 1; //Interrupt on negative edge // Make relay drive port as output RELAY_SOURCE_TRIS = TRIS_OUTPUT; RELAY_LED_TRIS = TRIS_OUTPUT; // Select battery as voltage source and turn on LED light RELAY_SOURCE = SOURCE_BATTERY; RELAY_LED = TURN_OFF_LED; SDC_Start(); }
// Initialization function for device, // Call Init_Device() from your main program void Init_Device(void) {Oscillator_Init(); Timer_Init(); // UART_Init(); // ADC_Init(); Port_IO_Init(); SPI_Init(); Timer2_Init(); Interrupts_Init(); one = 0; two = 0; msek = 0; TR2 = 1; // Timer0 enabled // reset reset = 1; while (!one); // 100ucek 1 reset = 0; while (!two); // 5 mcek 0 _nop_(); TR2 = 0; }
s32 __SDHC_Initialize(u32 *queuehandle) { void *buffer = NULL; s32 ret; /* Initialize memory heap */ Mem_Init(); /* Initialize timer subsystem */ Timer_Init(); /* Allocate queue buffer */ buffer = Mem_Alloc(0x80); if (!buffer) return IPC_ENOMEM; /* Create message queue */ ret = os_message_queue_create(buffer, 32); if (ret < 0) return ret; /* Register devices */ os_device_register(DEVICE_NAME, ret); /* Copy queue handler */ *queuehandle = ret; return 0; }
s32 __MLoad_Initialize(u32 *queuehandle) { void *buffer = NULL; s32 ret; /* Initialize memory heap */ Mem_Init(); /* Initialize timer subsystem */ Timer_Init(); /* Allocate queue buffer */ buffer = Mem_Alloc(0x20); if (!buffer) return IPC_ENOMEM; /* Create message queue */ ret = os_message_queue_create(buffer, 8); if (ret < 0) return ret; /* Enable PPC HW access */ os_ppc_access(1); /* Software interrupt */ os_software_IRQ(9); /* Register devices */ os_device_register(DEVICE_NAME, ret); /* Copy queue handler */ *queuehandle = ret; return 0; }
int main(void) { uint16_t ui1; LCD_init(); i2cInit(); Timer_Init(); KbdInit(); LCD_busy LCD_CLRSCR LCD_WR_LINE(0, 0, "Starting!!!"); for (ui1=0; ui1<0x3F; ui1++) LCD_busy; LCD_WR_LINE(0, 0, "Press any key!!!"); LCD_WR_LINE(1, 0, "Shall displayed!"); KBD_RESET_KEY; while (1) { KBD_GET_KEY; LCD_POS(1, 0); LCD_WR("Scan Code : "); LCD_PUT_UINT8X(KbdData); for (ui1=0; ui1<0xFF; ui1++) {} KBD_RESET_KEY; } return 0; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { #if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); #elif (ARCH == ARCH_XMEGA) /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; #endif /* Hardware Initialization */ LEDs_Init(); Buttons_Init(); USB_Init(); Timer_Init(); // AES module soft reset: put the module into a known state #if (ARCH == ARCH_XMEGA) AES.CTRL = AES_RESET_bm; #endif }
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 LineFollower_Init() { MotorDriver_Init(); LineSensor_Init(); Timer_Init(); _lf_I = 0; _lf_state = STATE_WAITING; }
void ADXL345_Init() { uint8_t test = 0; Timer_Init(); ADXL345_AccelVCCInit(); SPI1_Init(); TestLeds_GPIO_Init(); //EXTI_Init(); NSS_Low(); test = ADXL345_read(DEVID_ADDRESS); if (test != DEVID) { GPIOE->BSRR |= (1 << TEST_LEDS[0]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[0]) << 16; } ADXL345_write(INT_MAPPING_ADDRESS, DATA_READY_INT0_MAPPING); test = ADXL345_read(INT_MAPPING_ADDRESS); if (test != DATA_READY_INT0_MAPPING) { GPIOE->BSRR |= (1 << TEST_LEDS[1]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[1]) << 16; } ADXL345_write(POWER_CTL_ADDRESS, MEASUREMENT_MODE); test = ADXL345_read(POWER_CTL_ADDRESS); if (test != MEASUREMENT_MODE) { GPIOE->BSRR |= (1 << TEST_LEDS[2]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[2]) << 16; } ADXL345_write(DATA_FORMAT_ADDRESS, FULL_RES_MODE); test = ADXL345_read(DATA_FORMAT_ADDRESS); if (test != FULL_RES_MODE) { GPIOE->BSRR |= (1 << TEST_LEDS[3]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[3]) << 16; } ADXL345_write(BW_RATE_ADDRESS, ACCEL_FREQ); test = ADXL345_read(BW_RATE_ADDRESS); if (test != ACCEL_FREQ) { GPIOE->BSRR |= (1 << TEST_LEDS[4]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[4]) << 16; } ADXL345_write(INT_ENABLE_ADDRESS, DATA_READY_INT); test = ADXL345_read(INT_ENABLE_ADDRESS); if (test != DATA_READY_INT) { GPIOE->BSRR |= (1 << TEST_LEDS[5]); } else { GPIOE->BSRR |= (1 << TEST_LEDS[5]) << 16; } NSS_High(); }
void setupHardware(void) { MCUSR &= ~(1 << WDRF); // Disable watchdog if enabled by bootloader/fuses // wdt_disable(); // LEDs_Init(); UART_Init(115200); ADC_Init(); Timer_Init(); }
/** ****************************************************************************** ** Main application to control the program flow *****************************************************************************/ void main(void) { // Initialize all interrupt levels of resources Vectors_InitIrqLevels(); // Allow all interrupt levels __set_il(7); // Enable interrupts __EI(); Flash_EnableWriting(); InitLCD(); #if ((SMC_TYPE != SMC_TYPE_R200) && (ZPD == ZPD_ENABLE)) ZPD_Init(); //ќжидание окончани¤ ZPD while (m_enSmcMode == Zpd) { WDTCP = 0x00; } #else m_enSmcMode = NormalDriving; #endif InitSMC(20); Timer_Init(); InitADC(); InitRTC(); // ≈сли двигатель R200 или ZPD не активно #if ((SMC_TYPE == SMC_TYPE_R200) || (ZPD == ZPD_DISABLE)) ZeroPosSMC(); Timer_Wait(TIMER_ID_MAIN, 2000, TRUE); #endif ClearPosSMC(); DriverInit(); InitFRTimer0(); InitExtInt0(); //test Init_4_imp(); InitBacklight(); Button_Init(ButtonCallback); CAN_Init(); J1939_init(); InitUsart0(); if (Button_GetCurrentButtonState(BUTTON_ID_B1) == StateLow) SetModePass(); while(1) { WDTCP_ = 0x00; Timer_Main(); } }
/* MainInit routine This routine performs the main initialisation. */ void MainInit(void) { PortInit(); Timer_Init(); IIC_Init(); UART_Init(); sei(); // Enable global interrupts WM8960_Init(); WM8960_Init();//again }
void Inicia_Tiva() { // Configura o clock para 50MHz SysCtlClockSet(SYSCTL_SYSDIV_2 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN); LCD_Init(); ADC_Init(); Bluetooth_Init(); I2C_Init(); Valvula_Init(); Timer_Init(); }
// Initialization function for device, // Call Init_Device() from your main program void Init_Device(void) { Reset_Sources_Init(); PCA_Init(); Timer_Init(); ADC_Init(); Voltage_Reference_Init(); Port_IO_Init(); Oscillator_Init(); Interrupts_Init(); }
int main(void) { // Enable interrupts as early as possible sei(); Timer_Init(); Serial_Init(); uint8_t returnval = Can_Init(); if (returnval != CAN_OK) { } Can_Message_t txMsg; txMsg.Id = (CAN_NMT_APP_START << CAN_SHIFT_NMT_TYPE) | (NODE_ID << CAN_SHIFT_NMT_SID); txMsg.DataLength = 4; txMsg.RemoteFlag = 0; txMsg.ExtendedFlag = 1; txMsg.Data.words[0] = APP_TYPE; txMsg.Data.words[1] = APP_VERSION; // Set up callback for CAN reception, this is optional if only sending is required. BIOS_CanCallback = &can_receive; // Send CAN_NMT_APP_START BIOS_CanSend(&txMsg); while (1) { if (extRxMsgFull) { txMsg.Id = extRxMsg.Id; txMsg.DataLength = extRxMsg.DataLength; txMsg.RemoteFlag = extRxMsg.RemoteFlag; txMsg.ExtendedFlag = extRxMsg.ExtendedFlag; for (uint8_t i = 0; i < txMsg.DataLength; i++) { txMsg.Data.bytes[i] = extRxMsg.Data.bytes[i]; } BIOS_CanSend(&txMsg); extRxMsgFull = 0; // } if (rxMsgFull) { extTxMsg.Id = rxMsg.Id; extTxMsg.DataLength = rxMsg.DataLength; extTxMsg.RemoteFlag = rxMsg.RemoteFlag; extTxMsg.ExtendedFlag = rxMsg.ExtendedFlag; for (uint8_t i = 0; i < extTxMsg.DataLength; i++) { extTxMsg.Data.bytes[i] = rxMsg.Data.bytes[i]; } Can_Send(&extTxMsg); rxMsgFull = 0; // } } return 0; }
// *************** Sensor_InitCCP *************** int Sensor_InitCCPPeriod ( PORT_T *port ) { switch ( port->port_number ) { case 1: { Timer_Init ( Timer0A, Timer_CCP, POS_EDGE, false ); Timer_SetInterruptTask ( Timer0A, Sensor_ReadCCP0Period, true ); break; } case 2: { Timer_Init ( Timer0B, Timer_CCP, POS_EDGE, false ); Timer_SetInterruptTask ( Timer0B, Sensor_ReadCCP1Period, true ); break; } case 3: { Timer_Init ( Timer1A, Timer_CCP, POS_EDGE, false ); Timer_SetInterruptTask ( Timer1A, Sensor_ReadCCP2Period, true ); break; } case 4: { Timer_Init ( Timer1B, Timer_CCP, POS_EDGE, false ); Timer_SetInterruptTask ( Timer1B, Sensor_ReadCCP3Period, true ); break; } default: { return SENSOR_ERROR; } } return SENSOR_SUCCESS; }
void Metro_Init(void) { max_num_metros = Timer_Init( Metro_bang ); metros = malloc( sizeof(Metro_t) * max_num_metros ); for( int i=0; i<max_num_metros; i++ ){ metros[i].ix = i; metros[i].status = METRO_STATUS_STOPPED; metros[i].seconds = 1.0; metros[i].count = -1; metros[i].stage = 0; } }
/** * \brief Main control sequence for sensor node * @return Constant 0, but it has nowhere to go. */ int main(void) { Board_Init(); Timer_Init(); SPI_Init(); // Start SPI Radio_Init(); // Prep the radio while(True) { // Some merge example test lines. // More testing. } }
void Init_Peripherals(void) { InitCpuTimers(); Timer_Init(); SCI_Init(); EPwmTimerInit(); I2CA_Init(); SPI_Init(); ECAN_Init(); EQEP_Init(); ADC_Init(); USB_Init(); }
//--------------------------------------------------------------------------- void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; P2DIR |= 0x01; Crystal_Init(); //UART_Init(COM1); Timer_Init(); I2C_Init(); //-- 啟動I2C uart_GPS_init(); //-- 啟動GPS Get_Diff_Init(); //-- 啟動IO中斷 P1DIR |= (BIT0+BIT1+BIT2); // LED1 2 // P1OUT |= (BIT0+BIT1); // LED1 2 P1OUT &= ~(BIT0+BIT1+BIT2); // LED1 2 senscan_Rtc.is_leapyear=false; senscan_Rtc.rtc_mode = 1; senscan_Rtc.RTC_Serial[0]=10; senscan_Rtc.RTC_Serial[1]=20; senscan_Rtc.RTC_Serial[2]=11; senscan_Rtc.RTC_Serial[3]=15; senscan_Rtc.RTC_Serial[4]=12; senscan_Rtc.RTC_Serial[5]=11; senscan_Rtc.RTC_Serial[6]=22; senscan_Rtc.gps_flag = 0; while(1){ __bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit if(senscan_Rtc.gps_flag == 1){ P1OUT|=BIT0; } else{ P1OUT&= ~BIT0; } } //return 0; }
void USB_Device_CDC() { int numBytesToRead, numBytesRead, numAvailByte; static char serBuf [USB_CDC_BUFSIZE]; static unsigned char b[1]; b[0] = 'h'; #if PORT_NUM CDC_Init (1); #else CDC_Init (0); #endif Timer_Init(); LED_Init(); USB_Init(); USB_Connect(TRUE); // USB Connect while (!USB_Configuration) ; // wait until USB is configured uint8_t buffer[10]; uint32_t idx, len; while(1) { len = 0; while(len == 0) { len = UARTReceive((LPC_UART_TypeDef *)LPC_UART0, buffer, sizeof(buffer)); } idx = 0; while (idx < len) { UARTSend((LPC_UART_TypeDef *)LPC_UART0, &buffer[idx], 1); idx++; } USB_WriteEP (CDC_DEP_IN, buffer, len); /* CDC_OutBufAvailChar (&numAvailByte); if (numAvailByte > 0) { numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte; numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead); USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead); }*/ /* else { Timer_Delay(100); USB_WriteEP (CDC_DEP_IN, b, 1); }*/ } }
// Initialization function for device, // Call Init_Device() from your main program void Init_Device(void) { Reset_Sources_Init(); Timer_Init(); UART_Init(); SPI_Init(); ADC_Init(0); DAC_Init(); EMI_Init(); Voltage_Reference_Init(); Port_IO_Init(); Oscillator_Init(); Interrupts_Init(); }
int main(void) { Timer_Init(); //Initialize timers Ultrasonic_Init(); //Initialize sensors LED_Init(); //Initialize LEDs UART_Init(); //Initialize UART Motors_Init(); //Initialize motors sei(); //Enable interrupts while(1) //Main loop { state = 1; if (check_command(REMOTECONTROLMODE)) { state = 0; manual(); } else if (check_command(LATERALPARKINGMODE)) { state = 0; lateral_parking(); } else if (check_command(MAINPARKINGMODE)) { state = 0; random_parking(); } else if (check_command(FIXEDPARKINGMODE)) { state = 0; fixed_parking(); } else if (check_command(OBSTACLEDODGEMODE)) { state = 0; obstacle_dodge(); } else if (check_command(FOLLOWMODE)) { state = 0; follow(); }/* else if (confirm_input(DANCE)) { state = 4; dance(); }*/ } }
/*-------------------------------------------------------------------------------------------------------------------- Function: Main Description: Main routine Revisions: --------------------------------------------------------------------------------------------------------------------*/ void main(void) { General_Init(); Oscillator_Init(); Timer_Init(); Voltage_Reference_Init(); DAC_Init(); Interrupts_Init(); initLCD(); P2 = 0x0; while(1) { //Allow user to change current gamestate. i.e. menu or playing Check_State_Change(); //STILL NEEDED AS OF 5:41PM 4/5/15 //Execute the current state chosen switch (gameState) { case 0: /* Volume Menu */ //Clear any previous visuals printLCD("Volume Levels"); blink(); Change_Volume(); Display_Volume(); Change_Octave(); break; case 1: /* Play Menu */ PORT1_TO_PLAY_TONE(); break; } } //This is a debug counter that should never, EVER execute. So, delete it when you have no issues at the end. // while(1) // { // debugcounter +=1; // } }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ static void SetupHardware(void) { SystemInit(); Board_Init(); MyUSB_Init(); UARTInit(115200); #ifdef _MY_UNIT_TEST_ main_blinky(); #else Timer_Init(); #endif // #ifdef _MY_UNIT_TEST_ I2CInit(); ADCInit(); }