/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL); /* * LSM303DLHC Object Initialization */ lsm303dlhcObjectInit(&LSM303DLHCD1); /* * Activates the LSM303DLHC driver. */ lsm303dlhcStart(&LSM303DLHCD1, &lsm303dlhccfg); /* * Shell manager initialization. */ shellInit(); while(TRUE) { if (SDU1.config->usbp->state == USB_ACTIVE) { thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO + 1, shellThread, (void *)&shell_cfg1); chThdWait(shelltp); /* Waiting termination. */ } chThdSleepMilliseconds(1000); } lsm303dlhcStop(&LSM303DLHCD1); return 0; }
void usb_serial_start(void) { /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); #if HAL_USE_SERIAL /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); #endif isUsbSerialInitialized = true; }
void InitPConnection(void) { extern int32_t _flash_end; fwid = CalcCRC32((uint8_t *)(FLASH_BASE_ADDR), (uint32_t)(&_flash_end) & 0x07FFFFF); /* * Initializes a serial-over-USB CDC driver. */ mduObjectInit(&MDU1); mduStart(&MDU1, &midiusbcfg); bduObjectInit(&BDU1); bduStart(&BDU1, &bulkusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(midiusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(midiusbcfg.usbp, &usbcfg); usbConnectBus(midiusbcfg.usbp); chThdCreateStatic(waThreadUSBDMidi, sizeof(waThreadUSBDMidi), NORMALPRIO, ThreadUSBDMidi, NULL); }
/* * Application entry point. */ int main(void) { /* HAL&RTOS init */ halInit(); chSysInit(); /* SD/FATFS init */ sdcStart(&SDCD1, NULL ); wf_init(NORMALPRIO); /* POSIX compatibility layer initialization */ posix_init(); posix_init_chstream(STDIN_FILENO, (BaseSequentialStream *) &SDU1); posix_init_chstream(STDOUT_FILENO, (BaseSequentialStream *) &SDU1); posix_init_chstream(STDERR_FILENO, (BaseSequentialStream *) &SDU1); /* Initializes a serial-over-USB CDC driver */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); ngshell_init(&sh1, sh1_wa, SHELL_WA_SIZE, NORMALPRIO); while (TRUE) chThdSleepMilliseconds(500); }
int main(void) { halInit(); chSysInit(); static const evhandler_t evhndl[] = { }; // CDC. sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); chThdSleepMilliseconds(4000); uart_init(); chThdCreateStatic(uart_thread_wa, sizeof(uart_thread_wa), NORMALPRIO, uart_thread, NULL); while (true) { palTogglePad(GPIOC, GPIOC_LED); chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(100))); } }
int main(void) { halInit(); chSysInit(); chBSemObjectInit(&frame_thread_sem, false); bus_init(); power_init(); sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); chThdCreateStatic(frame_thread_wa, sizeof(frame_thread_wa), NORMALPRIO, frame_thread, NULL); while(true) { usb_rx(streamGet(&SDU1)); } }
int main(void) { thread_t *sh = NULL; PollerData.temp = 0; PollerData.press = 0;/* PollerData.uTime = 0;*/ halInit(); chSysInit(); shellInit(); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); // SPI-related pins (for display) palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5)); palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5)); spiStart(&SPID1, &spi1cfg); spiStart(&SPID2, &spi2cfg); i2cStart(&I2CD1, &i2cconfig); initGyro(); initAccel(); initMag(); // nunchuk_status = nunchuk_init(); bmp085_status = bmp085_init(); lcd5110Init(); lcd5110SetPosXY(0, 0); lcd5110WriteText("P :: "); lcd5110SetPosXY(0, 1); lcd5110WriteText("T :: "); chThdCreateStatic(waThreadBlink, sizeof(waThreadBlink), NORMALPRIO, ThreadBlink, NULL); chThdCreateStatic(waThreadButton, sizeof(waThreadButton), NORMALPRIO, ThreadButton, NULL); chThdCreateStatic(waPoller, sizeof(waPoller), NORMALPRIO, ThreadPoller, NULL); while (TRUE) { if (!sh) { sh = shellCreate(&shCfg, SHELL_WA_SIZE, NORMALPRIO); } else if (chThdTerminatedX(sh)) { chThdRelease(sh); sh = NULL; } chThdSleepMilliseconds(1000); } return 0; // never returns, lol }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Configuring USB DP and DM PINs. */ palSetPadMode(GPIOA, GPIOA_PIN11, PAL_MODE_INPUT); palSetPadMode(GPIOA, GPIOA_PIN12, PAL_MODE_INPUT); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Shell manager initialization. */ shellInit(); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, spawning shells. */ while (true) { if (SDU1.config->usbp->state == USB_ACTIVE) { thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO + 1, shellThread, (void *)&shell_cfg1); chThdWait(shelltp); /* Waiting termination. */ } chThdSleepMilliseconds(1000); } }
/* * Application entry point. */ int main(void) { Thread *shelltp = NULL; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); chThdSleepMilliseconds(100); /* * Shell manager initialization. */ shellInit(); /* * Initializes the SDIO drivers. */ mmcObjectInit(&MMCD1); mmcStart(&MMCD1, &mmccfg); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (TRUE) { if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE)) shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO); else if (chThdTerminated(shelltp)) { chThdRelease(shelltp); /* Recovers memory of the previous shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */ } chThdSleepMilliseconds(1000); } }
/* * Application entry point. */ int main(void) { thread_t *shelltp = NULL; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); #if defined(DEBUG_USB) palSetPadMode(GPIOA, 1, PAL_MODE_ALTERNATIVE_2); palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATIVE_2); sdStart(&SD1, &s0cfg); #endif /* DEBUG_USB */ /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); #if defined(DEBUG_USB) usb_debug_init(); #endif /* DEBUG_USB */ chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Shell manager initialization. */ shellInit(); while (!chThdShouldTerminateX()) { if (!shelltp && (serusbcfg.usbp->state == USB_ACTIVE)) shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO); else if (chThdTerminatedX(shelltp)) { chThdRelease(shelltp); /* Recovers memory of the previous shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */ } chThdSleepMilliseconds(1000); palTogglePad(GPIOB, GPIOB_LED); } return 0; }
//fungsi utama int main (void) { //inisialisasi HAL (Hardware Abstraction Layer) halInit(); //inisialisasi kernel chSysInit(); Adc_Init(); process_running(); //inisialisasi CAN CAN_Config(); // serial sdStart(&SD2,NULL); palSetPadMode(GPIOB,3, PAL_MODE_ALTERNATE(7)); //TX palSetPadMode(GPIOB,4, PAL_MODE_ALTERNATE(7)); //RX sdStart(&SD1,NULL); palSetPadMode(GPIOA,9, PAL_MODE_ALTERNATE(7)); //TX palSetPadMode(GPIOA,10, PAL_MODE_ALTERNATE(7)); //RX sdStart(&SD3,NULL); palSetPadMode(GPIOB,10, PAL_MODE_ALTERNATE(7)); //TX palSetPadMode(GPIOE,15, PAL_MODE_ALTERNATE(7)); //RX //inisialisasi USB sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); //aktifasi USB usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(200); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); //thread 1 chThdCreateStatic(waBacavolt, sizeof(waBacavolt), NORMALPRIO, Bacavolt, NULL); chThdCreateStatic(waBacacurrent, sizeof(waBacacurrent), NORMALPRIO, Bacacurrent, NULL); chThdCreateStatic(waThreadBMS, sizeof(waThreadBMS), NORMALPRIO, ThreadBMS, NULL); //chThdCreateStatic(waThreadkirimjoule, sizeof(waThreadkirimjoule), NORMALPRIO, Threadkirimjoule, NULL); //chThdCreateStatic(waThreadkirimjoule2, sizeof(waThreadkirimjoule2), NORMALPRIO, Threadkirimjoule2, NULL); while(TRUE) { kirim_data_usart1(); chprintf((BaseSequentialStream *)&SD1,"%d,%f,%d,%d,%f,%f,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d,%d \n",avgtemp,packsoc,packDCL,packCCL,lowvoltcell,highvoltcell,hightemp,lowtemp,packcurrent,packvolt,amphours,supply12v, deltacellvolt,avgcellvolt,mppt1_v,mppt2_v,mppt3_v,mppt4_v,mppt5_v,mppt6_v,mppt7_v,mppt8_v,mppt9_v,mppt10_v,mppt11_v,mppt12_v,mppt13_v,mppt15_v,mppt16_v, mppt1_i, mppt2_i, mppt3_i, mppt4_i, mppt5_i, mppt6_i, mppt7_i,mppt8_i, mppt9_i, mppt10_i, mppt11_i, mppt12_i, mppt13_i, mppt14_i, mppt15_i,current1,current2,current3,voltage1,voltage2,voltage3,milidetik,detik,menit,jam); //chprintf((BaseSequentialStream *)&SDU1,"%d,%f,%d,%d,%f,%f,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f \n",avgtemp,packsoc,packDCL,packCCL,lowvoltcell,highvoltcell,hightemp,lowtemp,packcurrent,packvolt,amphours,supply12v, deltacellvolt,avgcellvolt,mppt1_v,mppt2_v,mppt3_v,mppt4_v,mppt5_v,mppt6_v,mppt7_v,mppt8_v,mppt9_v,mppt10_v,mppt11_v,mppt12_v,mppt13_v,mppt15_v,mppt16_v, mppt1_i, mppt2_i, mppt3_i, mppt4_i, mppt5_i, mppt6_i, mppt7_i,mppt8_i, mppt9_i, mppt10_i, mppt11_i, mppt12_i, mppt13_i, mppt14_i, mppt15_i); //chprintf((BaseSequentialStream *)&SDU1,"%x %x %x %x %x %x %x %x \n",RxMessage33.StdId, RxMessage44.StdId, RxMessage55.StdId, RxMessage66.StdId, RxMessage77.StdId, RxMessage88.StdId, RxMessage99.StdId, RxMessage11.StdId); //chprintf((BaseSequentialStream *)&SD1,"tes \n"); chThdSleepMilliseconds(500); } return 0 ; }
void vcom_usbInit(void) { sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
EzspStatus ezspInit(void) { EzspStatus status; status = usbStart(); if (status!=EZSP_SUCCESS) { return status; } return usbResetNcp(); }
/* * Application entry point. */ int main(void) { Thread *shelltp0 = NULL; Thread *shelltp2 = NULL; //unsigned int i = 0; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* added by myself */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* added by myself */ /* * Normal main() thread activity, in this demo it just performs * a shell respawn upon its termination. */ while (1) { if (!shelltp0) { if (SDU1.config->usbp->state == USB_ACTIVE) { /* Spawns a new shell.*/ shelltp0 = shellCreate(&shell_cfg0, SHELL_WA_SIZE, NORMALPRIO); } } else { /* If the previous shell exited.*/ if (chThdTerminated(shelltp0)) { /* Recovers memory of the previous shell.*/ chThdRelease(shelltp0); shelltp0 = NULL; } } chThdSleepMilliseconds(1000); } }
/* * Initialize the USB driver */ void init_usb_driver(void) { /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(hiddebugcfg.usbp); chThdSleepMilliseconds(1500); usbStart(hiddebugcfg.usbp, &usbcfg); usbConnectBus(hiddebugcfg.usbp); }
/* * Application entry point. */ int main(void) { Thread *shelltp = NULL; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Shell manager initialization. */ shellInit(); /* * Starts the LED blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbStart(serusbcfg.usbp, &usbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbConnectBus(serusbcfg.usbp); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and listen for events. */ while (TRUE) { /* if (!shelltp) {*/ if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE)) { /* chprintf((BaseSequentialStream *)&SD1, "USB Active\r\n");*/ shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO); } else if (chThdTerminated(shelltp)) { chThdRelease(shelltp); /* Recovers memory of the previous shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */ } chThdSleepMilliseconds(100); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); /* This is needed to remap the USB pins PA11,PA12 onto the default PA9,PA10 * so that the USB works. After halInit (which changes that register). * This also means that USART1 can't be used, as it is on PA9,PA10. */ SYSCFG->CFGR1 |= SYSCFG_CFGR1_PA11_PA12_RMP; chSysInit(); palSetPadMode(GPIOB, 7, PAL_MODE_OUTPUT_PUSHPULL); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while(true) { if((palReadPad(GPIOB, GPIOB_BUTTON) == PAL_HIGH) && (SDU1.config->usbp->state == USB_ACTIVE)) { /* sdWrite(&SDU1, (uint8_t *)"hello world\r\n", 13); */ chprintf((BaseSequentialStream *)&SDU1, "Hello world\r\n"); /* chnWrite((BaseChannel *)&SDU1, (uint8_t *)"Hello, world\r\n", 14); */ } chThdSleepMilliseconds(200); } }
/* * Start all usb related threads and initiate the USB subsytem. */ void startUsbControl(void) { chMBInit (&usbTXMailbox, (msg_t *)usbTXMailboxBuffer, USB_MAILBOX_SIZE); chMBInit (&usbRXMailbox, (msg_t *)usbRXMailboxBuffer, USB_MAILBOX_SIZE); chPoolInit (&usbMemPool, USB_PACKET_SIZE, NULL); chPoolLoadArray(&usbMemPool, &usbMemPoolBuffer, USB_MEM_POOL_SIZE); chThdCreateStatic(waUsbTx, sizeof(waUsbTx), NORMALPRIO, tUsbTx, NULL); chThdCreateStatic(waUsbRx, sizeof(waUsbRx), NORMALPRIO, tUsbRx, NULL); //Start and Connect USB usbStart(usbp, &config); usbConnectBus(usbp); }
void comm_usb_serial_init(void) { sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
/* * @brief The function containing all drivers and modules to be initialized. * All initialization should be here (except internal inits). * * @note ChibiOS Sys init and HAL init shall not be in here, it's in main. */ static void vSystemInitList(void) { /* * * Add all driver and module initializations here! * */ /* Activates the USB driver and then the USB bus pull-up on D+. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
void startupInit() { usbdataEnable(); gdispSetBacklight(50); gdispSetContrast(50); geventListenerInit(&gl); gwinAttachListener(&gl); // Setup UI objects and show splash guiCreate(); gwinProgressbarSetResolution(ghProgbarLoad, 10); gwinProgressbarStart(ghProgbarLoad, 300); graphInit(); // Setup INA219 I2C Current Sensor ina219Init(); sduObjectInit(USB_SERIAL_DRIVER); sduStart(USB_SERIAL_DRIVER, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); setStartTime(); chThdCreateStatic(ledThread, sizeof(ledThread), LOWPRIO, ThreadLED, NULL); chThdCreateStatic(inaThread, sizeof(inaThread), HIGHPRIO, ThreadINA, NULL); chThdCreateStatic(gfxvalThread, sizeof(gfxvalThread), NORMALPRIO, ThreadGFXVal, NULL); chThdCreateStatic(timeThread, sizeof(timeThread), NORMALPRIO, ThreadTIME, NULL); chThdCreateStatic(gfxEventThread, sizeof(gfxEventThread), NORMALPRIO, ThreadGFXEvent, NULL); chThdSleepMilliseconds(2000); chThdCreateStatic(graphThread, sizeof(graphThread), NORMALPRIO+5, ThreadGRAPH, NULL); // Destroy splay screen and show main page gwinDestroy(ghContainerPageSplash); guiShowPage(1); }
int main(void) { halInit(); chSysInit(); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO - 1, Thread1, NULL); uint8_t my_addr, other_addr; if (true) { my_addr = 0x42; other_addr = 0x43; } else { my_addr = 0x43; other_addr = 0x42; } palSetPadMode(GPIOD, 5, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOD, 6, PAL_MODE_ALTERNATE(7) + PAL_STM32_PUPDR_PULLUP); sdStart(&SD2, NULL); // PD5 TX, PD6 RX sdStart(&SD3, NULL); // connected to stlink sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(100); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); chThdSleepMilliseconds(100); net_init(my_addr); // interface 0, USB chThdCreateStatic(net_rx0_thd_wa, sizeof(net_rx0_thd_wa), NORMALPRIO - 1, net_rx0_thd, &SDU1); // interface 1 UART connection to other node chThdCreateStatic(net_rx1_thd_wa, sizeof(net_rx1_thd_wa), NORMALPRIO - 1, net_rx1_thd, &SD2); net_route_add(&net_node, other_addr, 0xff, 1, 0); int i = 0; while (true) { chprintf((BaseSequentialStream *)&SD3, "node %x, counting %d\n", my_addr, i++); chThdSleepMilliseconds(500); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); palSetPadMode(IOPORT3, BOARD_LED1, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(IOPORT3, BOARD_LED1); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Starts the LED blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); while (true) { if (SDU1.config->usbp->state == USB_ACTIVE) { chnWrite(&SDU1, (const uint8_t *)"Hello from Arduino Leonardo!\r\n", 30); } chThdSleepMilliseconds(2113); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * GPIOI1 is programmed as output (board LED). */ palClearLine(LINE_ARD_D13); palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(&USBD2); chThdSleepMilliseconds(1500); usbStart(&USBD2, &usbcfg); usbConnectBus(&USBD2); /* * Starting threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waWriter, sizeof(waWriter), NORMALPRIO, Writer, NULL); chThdCreateStatic(waReader, sizeof(waReader), NORMALPRIO, Reader, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (true) { chThdSleepMilliseconds(1000); } }
// halInit() and chSysInit() should be called from user class, before initiating usb (before using this functions) void myUSBinit(void){ /* * Shell manager initialization. */ shellInit(); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ //Start and Connect USB usbDisconnectBus(usbp); chThdSleepMilliseconds(1000); usbStart(usbp, &config); usbConnectBus(usbp); }
int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured * device drivers and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread * and the RTOS is active. */ halInit(); chSysInit(); /* * * Initializes a serial-over-USB CDC driver. * */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * * Activates the USB driver and then the USB bus pull-up on D+. * */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * * User application. * */ while(1) { palTogglePad(GPIOC, GPIOC_LED_USR); chThdSleepMilliseconds(200); } }
void usbcdc_init(const ShellCommand * commands) { shell_cfg2.sc_commands = commands; /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
void BoardDriverStart(void) { ws281xStart(&ws281x, &ws281x_cfg); palSetPadMode(GPIOA, 1, PAL_MODE_STM32_ALTERNATE_PUSHPULL); /* * Initializes a serial-over-USB CDC driver. */ sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
void initializeUSB(void) { /* * Shell manager initialization. */ shellInit(); /* * Initializes a serial-over-USB CDC driver. */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }
void BoardDriverStart(void) { spiStart(&SPID1, &SPI1cfg); MFRC522Start(&RFID1, &RFID1_cfg); ws2811Start(&ws2811, &ws2811_cfg); palSetGroupMode(GPIOA, 0b00000010, 0, PAL_MODE_OUTPUT_PUSHPULL|PAL_STM32_OSPEED_HIGHEST|PAL_STM32_PUDR_FLOATING); /* * Initializes a serial-over-USB CDC driver. */ sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1000); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); }