/** 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); #endif /* Hardware Initialization */ Serial_Init(9600, false); LEDs_Init(); Buttons_Init(); Joystick_Init(); USB_Init(); /* Create a stdio stream for the serial port for stdin and stdout */ Serial_CreateStream(NULL); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Configure all button pins to use internal pullup */ PORTD |= (1<<7) | (1<<4) | (1<<2) | (1<<0) | (1<<6) | (1<<1); PORTE |= (1<<2); PORTB |= (1<<0) | (1<<4) | (1<<5) | (1<<7); /* Subsystem Initialization */ EncoderInit(); DebounceInit(); LedInit(); USB_Init(); }
/** 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); #endif /* Hardware Initialization */ LEDs_Init(); USB_Init(); /* Timer Initialization */ OCR0A = 100; TCCR0A = (1 << WGM01); TCCR0B = (1 << CS00); TIMSK0 = (1 << OCIE0A); }
/*------------------------------------------------------------ * Function Name : All_Init * Description : 全局初始化 * Input : None * Output : None * Return : None *------------------------------------------------------------*/ void All_Init( void ) { NVIC_Configuration(); /* 配置优先级分组 */ bsp_InitTimer(); /* 定时器初始化 */ key_init(); /* 按键初始化 */ print_init(); /* 打印机初始化 */ uart1_init(38400); /* 通讯串口初始化 */ rtc_init(); /* 时钟初始化 */ lcd_init(); /* LCD初始化 */ font_init(); /* 字体初始化 */ SysTick_Init(); /* 滴答定时器初始化 */ bsp_InitSFlash(); /* 外置 FLASH 初始化 */ USB_Init(); /* USB初始化 */ Ethernet_Init(); /* LWIP初始化 */ #ifdef ENABLE_BEEP BEEP_START(); #endif SetPage(SYS_INIT); }
/** Configures all hardware required for the bootloader. */ static void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Relocate the interrupt vector table to the bootloader section */ MCUCR = (1 << IVCE); MCUCR = (1 << IVSEL); /* Initialize the USB and other board hardware drivers */ USB_Init(); LEDs_Init(); /* Bootloader active LED toggle timer initialization */ TIMSK1 = (1 << TOIE1); TCCR1B = ((1 << CS11) | (1 << CS10)); }
/** Configures the board hardware and chip peripherals for the application'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); #endif /* Hardware Initialization */ USB_Init(); /* Power up the HD44780 Interface */ HD44780_Initialize(); HD44780_WriteCommand(CMD_DISPLAY_ON); /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ TCCR0B = (1 << CS02); }
int main (void) { PINSEL10 = 0; /* Disable ETM interface */ FIO2DIR = LEDMSK; /* LEDs, port 2, bit 0~7 output only */ lcd_init(); lcd_clear(); lcd_print ("MCB2300 HID Demo"); set_cursor (0, 1); lcd_print (" www.keil.com "); Nr = 128; Nk = Nr / 32; Nr = Nk + 6; KeyExpansion(Key, Nk, Nr); USB_Init(); /* USB Initialization */ USB_Connect(TRUE); /* USB Connect */ while (1); /* Loop forever */ }
/** Main program entry point. This routine configures the hardware required by the application, then * starts the scheduler to run the USB management task. */ int main(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); /* Initialize Scheduler so that it can be used */ Scheduler_Init(); /* Initialize USB Subsystem */ USB_Init(); /* Scheduling - routine never returns, so put this last in the main function */ Scheduler_Start(); }
void CDC_Init(void) { u8CDCState=0; /* USB Initialization */ USB_Init(); /** Enable SOF ouput */ PORTC_PCR7 |= PORT_PCR_MUX(3); /* Line Coding Initialization */ //LineCoding.DTERate=LWordSwap(9600); LineCoding.DTERate=(9600); LineCoding.CharFormat=0; LineCoding.ParityType=0; LineCoding.Databits=0x08; /* Initialize Data Buffers */ Buffer_Init(CDC_OUT_Data,CDC_BUFFER_SIZE); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { MCUSR = 0; /* Disable watchdog if enabled by bootloader/fuses */ wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); serial_init(); GlobalInterruptEnable(); /* Hardware Initialization */ LEDs_Init(); while(!started); USB_Init(); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ //LEDs_Init(); USB_Init(); TWI_Init(); /* PCICR |= (1 << PCIE0); // enable PCMSK0 scan on PCIE0 PCMSK0 |= (1 << PCINT7); // PCINT7 (PB7) to trigger interrupt on pin change sei(); */ }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* 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; // LED PORTD.DIRSET = PIN5_bm; // DIR PORTC.DIRSET = PIN1_bm; // LED ON PORTD.OUTSET = PIN5_bm; // Receiving PORTC.OUTCLR = PIN1_bm; /* Hardware Initialization */ // USART RX/TX 1 /* PIN3 (TXD0) as output. */ PORTC.DIRSET = PIN3_bm; /* PC2 (RXD0) as input. */ PORTC.DIRCLR = PIN2_bm; USART_InterruptDriver_Initialize(&USART_data, &USART, USART_DREINTLVL_OFF_gc); USART_RxdInterruptLevel_Set(USART_data.usart, USART_RXCINTLVL_LO_gc); /* Enable global interrupts. */ sei(); USB_Init(); }
/** Main program entry point. This routine configures the hardware required by the application, then * starts the scheduler to run the USB management task. */ int main(void) { /* After reset start bootloader? */ if ((AVR_IS_WDT_RESET()) && (boot_key == DFU_BOOT_KEY_VAL)) { boot_key = 0; Bootloader(); } /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ LEDs_Init(); /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); /* Initialize Scheduler so that it can be used */ Scheduler_Init(); /* Initialize USB Subsystem */ USB_Init(); /* Initialize I/O lines */ //IO_Init(); /* Initialize Timers */ Timer_Init(); /* Initialize Motors */ Motor_Init(); /* Scheduling - routine never returns, so put this last in the main function */ Scheduler_Start(); }
int32_t PIOS_USB_Init(uintptr_t * usb_id, const struct pios_usb_cfg * cfg) { PIOS_Assert(usb_id); PIOS_Assert(cfg); struct pios_usb_dev * usb_dev; usb_dev = (struct pios_usb_dev *) PIOS_USB_alloc(); if (!usb_dev) goto out_fail; /* Bind the configuration to the device instance */ usb_dev->cfg = cfg; PIOS_USB_Reenumerate(); /* * This is a horrible hack to make this available to * the interrupt callbacks. This should go away ASAP. */ pios_usb_com_id = (uintptr_t) usb_dev; /* Enable the USB Interrupts */ NVIC_Init((NVIC_InitTypeDef*)&usb_dev->cfg->irq.init); /* Select USBCLK source */ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); /* Enable the USB clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); USB_Init(); USB_SIL_Init(); *usb_id = (uintptr_t) usb_dev; return 0; /* No error */ out_fail: return(-1); }
int main (void) { SystemInit(); USBIOClkConfig(); /* P0.1 is push-button input, P2.0~3 are LED output. */ // LPC_GPIO2->DIR |= (0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3); // LPC_GPIO0->DIR &= ~(0x1<<1); /* 16-bit timer 0. */ // init_timer16(0, /*TIME_INTERVAL*/10); // enable_timer16(0); /* Set port 2_0 to output */ // GPIOSetDir( 2, 0, 1 ); USB_Init(); /* USB Initialization */ USB_Connect(TRUE); /* USB Connect */ while (1) /* Loop forever */ { #if 0 /* I/O configuration and LED setting pending. */ if ( (timer16_0_counter > 0) && (timer16_0_counter <= 200) ) { GPIOSetValue( 2, 0, 0 ); } if ( (timer16_0_counter > 200) && (timer16_0_counter <= 400) ) { GPIOSetValue( 2, 0, 1 ); } else if ( timer16_0_counter > 400 ) { timer16_0_counter = 0; } #endif } }
serialPort_t *usbVcpOpen(void) { vcpPort_t *s; #ifdef STM32F40_41xxx USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); #else Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); #endif s = &vcpPort; s->port.vTable = usbVTable; return (serialPort_t *)s; }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ static void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Relocate the interrupt vector table to the bootloader section */ MCUCR = (1 << IVCE); MCUCR = (1 << IVSEL); /* Hardware Initialization */ LEDs_Init(); USB_Init(); /* configure opendeck led */ DDRE |= 0b01000000; //led output PORTE |= 0b01000000; //led high }
T_VOID Pub_Standby() { T_EVT_PARAM param; param.w.Param1 = M_EVT_RESTART; Fwl_DetectorEnable(DEVICE_USB, AK_FALSE); pStandBy->WakeupType = Fwl_SysSleep(AK_TRUE); Fwl_DetectorEnable(DEVICE_USB, AK_TRUE); if(WAKE_USB == pStandBy->WakeupType) { AK_DEBUG_OUTPUT("usb wakeup! s:%d\n", Fwl_DetectorGetStatus(DEVICE_CHG)); if (Fwl_DetectorGetStatus(DEVICE_CHG)) { if(Fwl_UsbSlaveDetect()) { VME_EvtQueuePut(M_EVT_EXIT, ¶m); USB_Init(); } else { VME_EvtQueuePut(M_EVT_EXIT, ¶m); } } else { VME_EvtQueuePut(M_EVT_EXIT, ¶m); } } else if(pStandBy->WakeupType != WAKE_NULL) { VME_EvtQueuePut(M_EVT_EXIT, ¶m); } else { } pStandBy->key_cnt = 0; pStandBy->delay = 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); #endif /* Hardware Initialization */ LEDs_Init(); USB_Init(); /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ TCCR0B = (1 << CS02); /* Pull target /RESET line high */ AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; }
/******************************************************************************* * Function Name : Mass_Storage_Start * Description : Starts the mass storage demo. * Input : None * Output : None * Return : None *******************************************************************************/ void Mass_Storage_Start (void) { NVIC_InitTypeDef NVIC_InitStructure; #if 1 /* Enable and GPIOD clock */ USB_Disconnect_Config(); #endif /* MAL configuration */ MAL_Config(); Set_USBClock(); NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = USB_HP_CAN1_TX_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USB_Init(); }
void KeyboardInit(USB_Device_Definition* deviceDefinition, USB_Device_Struct* device, USBHID_Behaviour_Struct* hid, uint8_t* inBuffer, uint8_t* outBuffer, uint8_t* idleValue, uint8_t* currentProtocol, HidInReportHandler inReportHandler, HidOutReportHandler outReportHandler) { deviceDefinition->deviceDescriptor = kbd_deviceDescriptor; deviceDefinition->configurationCount = 1; deviceDefinition->configurationDescriptors[0] = kbd_configDescriptor; deviceDefinition->stringCount = 4; deviceDefinition->strings[0] = kbd_languages; deviceDefinition->strings[1] = kbd_manufacturerName; deviceDefinition->strings[2] = kbd_deviceName; deviceDefinition->strings[3] = kbd_serialName; deviceDefinition->behaviourCount = 1; deviceDefinition->behaviours[0] = (USB_Behaviour_Struct*)hid; hid->baseBehaviour.extendedControlSetupCallback = USBHID_ExtendedControlSetupHandler; hid->baseBehaviour.endpointDataCallback = USBHID_EndpointDataHandler; hid->baseBehaviour.frameCallback = NULL; hid->baseBehaviour.interfaceAltCallback = NULL; hid->baseBehaviour.configChangeCallback = USBHID_ConfigChangeHandler; hid->interfaceNumber = 0; hid->hidDescriptor = kbd_configDescriptor+18; hid->reportDescriptor = kbd_reportDescriptor; hid->reportDescriptorLen = sizeof(kbd_reportDescriptor); hid->inReportHandler = inReportHandler; hid->outReportHandler = outReportHandler; hid->inBuffer = inBuffer; hid->outBuffer = outBuffer; hid->idleValue = idleValue; hid->currentProtocol = currentProtocol; USB_Init(deviceDefinition,device); }
static void setup_usb(void) { // Leonardo needs. Without this USB device is not recognized. USB_Disable(); USB_Init(); // for Console_Task USB_Device_EnableSOFEvents(); print_set_sendchar(sendchar); /* wait for USB startup & debug output */ uint8_t timeout = 255; // timeout when USB is not available while (timeout-- &&USB_DeviceState != DEVICE_STATE_Configured) { wait_ms(4); #if defined(INTERRUPT_CONTROL_ENDPOINT) ; #else USB_USBTask(); #endif } print("USB configured.\n"); }
/******************************************************************************* * Function Name : main. * Descriptioan : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while (1) { if (bDeviceState == CONFIGURED) { CDC_Receive_DATA(); /*Check to see if we have data yet */ if (Receive_length != 0) { if (packet_sent == 1) CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length); Receive_length = 0; } } } }
/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); while (1) { if (bDeviceState == CONFIGURED) { if ((JoyState() != 0) && (PrevXferComplete)) { Joystick_Send(JoyState()); } } } }
int main(void) { SystemInit(); Set_System(); if(rcc_clock.SYSCLK_Frequency != SYSTEM_FREQUENCY) Error_Handler(); Buzzer_Start(); Delay_ms(1000); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); Delay_ms(1000); RF_Init(); GPIO_SetBits(LED_PORT, LED_GREEN_PIN); while (1) { USB_Hanlder(); RF_Handler(); Watch_Handler(); } }
int main(void) { /* Enable CT32B1 Timer, IOCON, and USB */ LPC_SYSCON->SYSAHBCLKCTRL |= (EN_CT32B1 | EN_USB_REG | EN_IOCON); /* Initialize GPIO */ GPIOInit(); /* Set LED port pin to output */ GPIOSetDir(LED_PORT, LED_BIT, 1); GPIOSetValue(LED_PORT, LED_BIT, 0); /* CDC Initialization */ CDC_Init(); /* USB Initialization */ USB_Init(); /* Connect to USB port */ USB_Connect(1); /* Update System Core Clock Value */ SystemCoreClockUpdate(); /* NVIC is installed inside UARTInit file. */ UARTInit(115200, 0); /* the following text is printed on the serial port as vTasksRunning * is not yet set to TRUE in serial_task - which will redirect * debug output to the CDC ACM USB serial device. */ debug_printf("Hello World!\n"); /* Create CDC ACM task */ xTaskCreate(serial_task, (const signed char*) "Serial", TASK_SERIAL_STACK_SIZE, NULL, TASK_SERIAL_PRIORITY, NULL); /* Start the tasks running. */ vTaskStartScheduler(); return 0; }
/******************************************************************************* * Function Name : main. * Descriptioan : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); init_USART1(); Led_init(); //Configure Systick timing if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ STM_EVAL_LEDOn(LED10); while (1); } char dat[7]; strcpy(dat, conv_f2c(1.53)); while (1) { // if (bDeviceState == CONFIGURED) // { /* CDC_Receive_DATA(); //Check to see if we have data yet if (Receive_length != 0) { if (packet_sent == 1) CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length); Receive_length = 0; }*/ /* Toggle LED3 */ STM_EVAL_LEDToggle(LED3); /* Insert 100 ms delay */ USART_puts( USART1, dat); Delay(500); // } } }
/** 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(); Joystick_Init(); Buttons_Init(); Dataflash_Init(); USB_Init(); /* Check if the Dataflash is working, abort if not */ if (!(DataflashManager_CheckDataflashOperation())) { LEDs_SetAllLEDs(LEDMASK_USB_ERROR); for(;;); } /* Clear Dataflash sector protections, if enabled */ DataflashManager_ResetDataflashProtections(); }
/** Initializes all of the hardware. */ void initialize(void){ CPU_PRESCALE(0x00); //LED DDRE |= (1<<PE2); //RGB LED DDRB |= (1<<PB5) | (1<<PB6); DDRC |= (1<<PC6); /** LUFA USB related inits */ USB_Init(); CDC_Device_CreateBlockingStream (&VirtualSerial_CDC_Interface, &USBSerialStream); touch_init(); pwm16_rgb_init(); /** enable interrupts*/ sei(); }
// Get the Leonardo ready for USB communication void setupHardware(void) { // Disable the watch-dog timer if enabled by boot-loader or fuses MCUSR &= ~(1 << WDRF); wdt_disable(); // Disable clock division clock_prescale_set(clock_div_1); // Initialise the hardware USART module #ifdef USART_DEBUG Serial_Init(115200, true); Serial_CreateStream(NULL); printf("USART Debug enabled\r\n"); #endif // Initialise the EEPROM settings eepromInit(); // Initialise the LUFA board driver and USB library LEDs_Init(); USB_Init(); }