示例#1
0
文件: main.c 项目: ohputra/stm32-tf
int main(void) {
  Thread *shelltp = NULL;

  halInit();
  chSysInit();


  palSetPadMode(GPIOA,9,PAL_MODE_STM32_ALTERNATE_PUSHPULL);
  palSetPadMode(GPIOA,10,PAL_MODE_INPUT);
  sdStart(&SD1, NULL);

  shellInit();

  palSetPadMode(GPIOA,8,PAL_MODE_OUTPUT_PUSHPULL);
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  Lcd_Init();
  Lcd_Clear();
  Lcd_Example();

  while (TRUE) {
    if (!shelltp){
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);}
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);
      shelltp = NULL;
    }
    chThdSleepMilliseconds(500);
  }
}
示例#2
0
/*
 * Application entry point.
 */
int main(void) {
  static const evhandler_t evhndl[] = {
    InsertHandler,
    RemoveHandler
  };
  Thread *shelltp = NULL;
  struct EventListener el0, el1;

  /*
   * 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 2 using the driver default configuration.
   */
  sdStart(&SD2, NULL);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Initializes the MMC driver to work with SPI2.
   */
  palSetPadMode(IOPORT2, GPIOB_SPI2NSS, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPad(IOPORT2, GPIOB_SPI2NSS);
  mmcObjectInit(&MMCD1, &SPID2,
                &ls_spicfg, &hs_spicfg,
                mmc_is_protected, mmc_is_inserted);
  mmcStart(&MMCD1, NULL);

  /*
   * 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 listen for events.
   */
  chEvtRegister(&MMCD1.inserted_event, &el0, 0);
  chEvtRegister(&MMCD1.removed_event, &el1, 1);
  while (TRUE) {
    if (!shelltp)
      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.        */
    }
    chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS));
  }
  return 0;
}
/*
 * Application entry point.
 */
int main(void) {
  // thread representing the shell
  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();

  USBInit();

  // main activity - shell respawn upon its termination.
  while (TRUE) {
    if (!shelltp && isUSBActive()) { // Checks if shell doesnt exist and  USB is active
      /* Spawns a new shell.*/
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
    }
    else {
      /* If the previous shell exited.*/
      if (chThdTerminated(shelltp)) {
        /* Recovers memory of the previous shell.*/
        chThdRelease(shelltp);
        shelltp = NULL;
      }
    }
    chThdSleepMilliseconds(500);
  }
}
示例#4
0
文件: main.c 项目: acourt/NXT-Sensor
/*
 * Application entry point.
 */
int main(void) {
	
	/* Shell thread */
	Thread *shelltp = NULL;
	
	 /* UART Configuration Structure */
	SerialConfig sc;

	// Dummy ADC Configuration structure
	ADCConfig adc_conf;
	
	/*
	* 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();
	GPIO_Configuration();
	//ADC_Configuration();
	I2C_Configuration();
	
	 /* Start Serial Driver */
	sc.sc_speed = 115200;
	sc.sc_cr1 = 0;
	sc.sc_cr2 = USART_CR2_STOP1_BITS | USART_CR2_LINEN;
	sc.sc_cr3 = 0;
	sdStart(&SD1, &sc);
	
	/* Shell manager initialization. */
    shellInit();
	
	/*
	* Creates the example thread.
	*/
	chThdCreateStatic(waThread1, sizeof(waI2CThread), NORMALPRIO, I2CThread, NULL);
	
	/*
	* Normal main() thread activity, in this demo it does nothing except
	* sleeping in a loop and check the button state, when the button is
	* pressed the test procedure is launched with output on the serial
	* driver 1.
	*/
	while (TRUE) {
		if(!shelltp)
		{
			shelltp = shellCreate( &shell_cfg, THD_WA_SIZE(2048), NORMALPRIO);
		}
		else if(chThdTerminated(shelltp))
		{
			// Recovers memory of the previous shell.
			chThdRelease(shelltp);
			shelltp = NULL;
		}
  	}
	
}
示例#5
0
void Shell_Setup(void){
    if (!shelltp){
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);} /* create shell tread */
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);    /* Recovers memory of the previous shell.   */
      shelltp = NULL;           /* Triggers spawning of a new shell.        */
    }
}
示例#6
0
int main(void){
    
    halInit();
    chSysInit();
    
    Thread *sh = NULL;   
 
    sdStart(&SD1,&sd1conf);
    //sdStart(&SD1,NULL);
    
    chThdSleepMilliseconds(200);
    
    #if USE_I2C_STUFF 
    I2CInit_pns();
    
    #if USE_I2C_POLL_THD 
    /* Create accelerometer thread */
    chThdCreateStatic(PollAccelThreadWA,
        sizeof(PollAccelThreadWA),
        NORMALPRIO,
        PollAccelThread,
        NULL);
    chThdCreateStatic(PollColorThreadWA,
        sizeof(PollColorThreadWA),
        NORMALPRIO,
        PollColorThread,
        NULL);
    #endif
    #endif

    chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
    
    #if USE_SER_OUT_THD  
    chThdCreateStatic(waSerOutThr1, sizeof(waSerOutThr1), NORMALPRIO, SerOutThr1, NULL);
    #endif
    palSetPadMode(GPIOA, GPIOA_PA2, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 3, PAL_MODE_OUTPUT_PUSHPULL);
//TestThread(&SD1);


    shellInit();    

    while (TRUE){
        //palSetPad(GPIOA, 3);
        //TestThread(&SD1);
        //chThdSleepMilliseconds(500);
        //palClearPad(GPIOA, 3);
        //chThdSleepMilliseconds(500);
        if (!sh){
            chprintf((BaseSequentialStream *)&SD1,"Starting ChibiOS/RT Shell\n\r");
            sh = shellCreate(&shCfg, SHELL_WA_SIZE, NORMALPRIO+1);
        } else if (chThdTerminated(sh)) {
            chThdRelease(sh);
            sh = NULL;
        }
    //    chThdSleepMilliseconds(1000);
    }
}   
示例#7
0
/*
 * 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 USB driver and then the USB bus pull-up on D+.
   */
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(1000);
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);
  usbConnectBus(serusbcfg.usbp);
  palClearPad(GPIOC, GPIOC_USB_DISC);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waBurner, sizeof(waBurner), NORMALPRIO, Burner, &SDU1);

  i2cStart(&I2CD1, &i2cfg1);
  EepromOpen(&EepromFile);

  /* tune ports for I2C1*/
  palSetPadMode(IOPORT2, 6, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
  palSetPadMode(IOPORT2, 7, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);

//  BKP->DR1 = 0;
//  BKP->DR2 = 0;
//  BKP->DR3 = 0;

  /*
   * 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 *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(&SERIAL_DRIVER, NULL);

  /*
   * Initializes the PWM driver.
   */
  pwmStart(&PWM_DRIVER, &pwmcfg);

  /*
   * Initializes the GPT driver.
   */
  gptStart(&GPT_DRIVER, &gptcfg);

  /*
   * Initializes the EXT driver.
   */
  extStart(&EXT_DRIVER, &extcfg);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * 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 (!shelltp)
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);
      shelltp = NULL;
    }
    chprintf(&SERIAL_DRIVER, "M: %6umm T1: %6u T2: %6u\r\n", measure / 2, tmp1, tmp2);
    chThdSleepMilliseconds(200);
  }
}
示例#9
0
void usbcdc_process(void)
{
        if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
                  shelltp = shellCreate(&shell_cfg2, SHELLUSB_WA_SIZE, NORMALPRIO);
          else if (chThdTerminated(shelltp)) {
                  chThdRelease(shelltp); /* Recovers memory of the previous shell. */
                  shelltp = NULL; /* Triggers spawning of a new shell. */
          }
}
示例#10
0
void vshellRestart(bool_t active)
{
    if (!shelltp && 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.        */
    }
}
示例#11
0
/*
 * Application entry point.
 */
int main(void) {
  static const evhandler_t evhndl[] = {
    InsertHandler,
    RemoveHandler
  };
  Thread *shelltp = NULL;
  struct EventListener el0, el1;

  /*
   * 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 and SDC driver 1 using default
   * configuration.
   */
  sdStart(&SD1, NULL);
  sdcStart(&SDCD1, NULL);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Activates the card insertion monitor.
   */
  tmr_init(&SDCD1);

  /*
   * 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 listen for events.
   */
  chEvtRegister(&inserted_event, &el0, 0);
  chEvtRegister(&removed_event, &el1, 1);
  while (TRUE) {
    if (!shelltp)
      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.        */
    }
    chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS));
  }
}
示例#12
0
/*
 * 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);
}

}
示例#13
0
文件: main.c 项目: Paluche/Hubert
/*
 * 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();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity.
   */
  while (TRUE) {

    if (!shelltp)
      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.        */
    }
#if 0
    if (SIU.GPDI[GPIO_BUTTON1].B.PDI) {
      volatile msg_t result;
#if 0
      MemoryStream report;

      msObjectInit(&report, report_buffer, sizeof(report_buffer), 0);
      result = TestThread(&report);
#else
      result = TestThread(&SD1);
#endif
    }
#endif
    chThdSleepMilliseconds(1000);
  }
  return 0;
}
示例#14
0
/*
 * 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);
	}
}
示例#15
0
文件: main.c 项目: GotoHack/ChibiOS
/*
 * 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;
}
示例#16
0
/**
 * @brief Shell termination handler.
 *
 * @param[in] id event id.
 */
static void termination_handler(eventid_t id) {

  (void)id;
  if (shelltp1 && chThdTerminated(shelltp1)) {
    chThdWait(shelltp1);
    shelltp1 = NULL;
    chThdSleepMilliseconds(10);
    cputs("Init: shell on SD1 terminated");
    chSysLock();
    chOQResetI(&SD1.oqueue);
    chSysUnlock();
  }
  if (shelltp2 && chThdTerminated(shelltp2)) {
    chThdWait(shelltp2);
    shelltp2 = NULL;
    chThdSleepMilliseconds(10);
    cputs("Init: shell on SD2 terminated");
    chSysLock();
    chOQResetI(&SD2.oqueue);
    chSysUnlock();
  }
}
示例#17
0
文件: main.c 项目: Impact2585/convex
int main(void)
{
	Thread *shelltp = NULL;
	short	timeout = 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();

	// Init the serial port associated with the console
	vexConsoleInit();

    // use digital 10 as safety
    //if( palReadPad( VEX_DIGIO_10_PORT, VEX_DIGIO_10_PIN) == 1)
    // init VEX
    vexCortexInit();

    // wait for good spi comms
    while( vexSpiGetOnlineStatus() == 0 )
    	{
        // wait for a while
        chThdSleepMilliseconds(100);
        // dump after 5 seconds
        if(timeout++ == 50)
        	break;
    	}

    // Shell manager initialization.
    shellInit();

    // spin in loop monitoring the shell
    while (TRUE)
    	{
	    if (!shelltp)
	    	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(50);
    	}
}
示例#18
0
/*
 * Application entry point.
 */
int main(void) {
  /*
   * Shell thread
   */
  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();

  /*
   * Activate custom stuff
   */
//  mypwmInit();
//  myADCinit();
//  mySPIinit();
  motorInit();


  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   */
 // myUSBinit();


  /*
   * Main loop, does nothing except spawn a shell when the old one was terminated
   */
  while (TRUE) {
	setMotorData(1300,1490);
    if (!shelltp && isUsbActive())
      {
        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);
  }

}
示例#19
0
/*
 * 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 USB driver and then the USB bus pull-up on D+.
   */
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(100);
  usbConnectBus(serusbcfg.usbp);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * 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 (!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);
  }
}
示例#20
0
文件: main.c 项目: CNCBASHER/ChibiOS
/*
 * 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();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity.
   */
  while (TRUE) {

    if (!shelltp)
      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);
  }
  return 0;
}
示例#21
0
//-----------------------------------------------------------------------------
int main(void)
{
    halInit();
    chSysInit();
    kuroBoxInit();
    chprintf(prnt, "Starting... [%s] \n", BOARD_NAME);
    kbg_setLCDBacklight(1);

    memset(&factory_config, 0, sizeof(factory_config));

    cmd_read(prnt, 0, NULL);
    cmd_print(prnt, 0, NULL);

    Thread * shelltp = NULL;
    while ( 1 )
    {
        if (!shelltp)
        {
            shelltp = shellCreate(&shell_cfg, SHELL_WA_SIZE, NORMALPRIO);
        }
        else if (chThdTerminated(shelltp))
        {
            chThdRelease(shelltp);
            shelltp = NULL;
        }
    }

    //--------------------------------------------------------------------------
    // endless loop to say we've finished
    while(1)
    {
        kbg_setLED1(0);
        kbg_setLED2(0);
        kbg_setLED3(0);
        chThdSleepMilliseconds(200);
        kbg_setLED1(1);
        kbg_setLED2(1);
        kbg_setLED3(1);
        chThdSleepMilliseconds(200);
    }
}
int spawnShell(void) {
    const int ONE_THOUSAND_MILLISECONDS = 1000;
    const int THREAD_WORKING_AREA_SIZE = 2048;

    Thread *shellThread = NULL;

    while (TRUE) {
        // If we don't have a shell but a living USB connection, create a new thread with the shell.
        if (!shellThread && isUSBActive()) {
            shellThread = shellCreate(&shellConfiguration, THD_WA_SIZE(THREAD_WORKING_AREA_SIZE), NORMALPRIO);
        }
        else if (chThdTerminated(shellThread)) {
            // Recover memory of the previous shell.
            chThdRelease(shellThread);

            // Trigger spawning of a new shell.
            shellThread = NULL;
        }

        chThdSleepMilliseconds(ONE_THOUSAND_MILLISECONDS);
    }
}
示例#23
0
void osIdleLoopHook(void)
{
   uint_t i;

   //Loop through task table
   for(i = 0; i < OS_PORT_MAX_TASKS; i++)
   {
      //Check whether current entry is used
      if(taskTable[i].tp != NULL)
      {
         //Wait for task termination
         if(chThdTerminated(taskTable[i].tp))
         {
            //Free working area
            osFreeMem(waTable[i]);

            //Mark the entry as free
            waTable[i] = NULL;
            taskTable[i].tp = NULL;
         }
      }
   }
}
示例#24
0
int main(void) {
	halInit();
	chSysInit();
	USBinit();

	palSetPadMode(GPIOD, GPIOD_LED3, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOD, GPIOD_LED5, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOD, GPIOD_LED6, PAL_MODE_OUTPUT_PUSHPULL);

	static Thread *shelltp = NULL;

	while(1) {
		if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
			shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
		else if (chThdTerminated(shelltp)) {
			chThdRelease(shelltp);
			shelltp = NULL;
		}

		chThdSleepMilliseconds(100);
	}
}
示例#25
0
文件: main.c 项目: GotoHack/ChibiOS
/*
 * 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();

  /*
   * 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);

  /*
   * Activates the serial driver 2 using the driver default configuration.
   * PA2(TX) and PA3(RX) are routed to USART2.
   */
  sdStart(&SD2, NULL);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  /*
   * Initializes the SPI driver 1 in order to access the MEMS. The signals
   * are already initialized in the board file.
   */
  spiStart(&SPID1, &spi1cfg);

  /*
   * Initializes the SPI driver 2. The SPI2 signals are routed as follow:
   * PB12 - NSS.
   * PB13 - SCK.
   * PB14 - MISO.
   * PB15 - MOSI.
   */
  spiStart(&SPID2, &spi2cfg);
  palSetPad(GPIOB, 12);
  palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL |
                           PAL_STM32_OSPEED_HIGHEST);           /* NSS.     */
  palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) |
                           PAL_STM32_OSPEED_HIGHEST);           /* SCK.     */
  palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5));              /* MISO.    */
  palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) |
                           PAL_STM32_OSPEED_HIGHEST);           /* MOSI.    */

  /*
   * Initializes the PWM driver 4, routes the TIM4 outputs to the board LEDs.
   */
  pwmStart(&PWMD4, &pwmcfg);
  palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_ALTERNATE(2));      /* Green.   */
  palSetPadMode(GPIOD, GPIOD_LED3, PAL_MODE_ALTERNATE(2));      /* Orange.  */
  palSetPadMode(GPIOD, GPIOD_LED5, PAL_MODE_ALTERNATE(2));      /* Red.     */
  palSetPadMode(GPIOD, GPIOD_LED6, PAL_MODE_ALTERNATE(2));      /* Blue.    */

  /*
   * Creates the example thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1),
                    NORMALPRIO + 10, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it just performs
   * a shell respawn upon its termination.
   */
  while (TRUE) {
    if (!shelltp) {
      if (SDU1.config->usbp->state == USB_ACTIVE) {
        /* Spawns a new shell.*/
        shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
      }
    }
    else {
      /* If the previous shell exited.*/
      if (chThdTerminated(shelltp)) {
        /* Recovers memory of the previous shell.*/
        chThdRelease(shelltp);
        shelltp = NULL;
      }
    }
    chThdSleepMilliseconds(500);
  }
}
示例#26
0
/*
 * 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 2 using the driver default configuration.
   */
  initSerialHw();

  /*
   * Initialize GPT driver 3
   */
  gptStart(&GPT_DRIVER, &gpt3cfg);

  /*
   * Initialize the MMC over SPI hardware
   */
   chprintf((BaseSequentialStream *)&SERIAL_DRIVER, "Initializing MMC Hardware...\r\n");
   initMMCSpiHw();
   chprintf((BaseSequentialStream *)&SERIAL_DRIVER, "Mounting filesystem ...\r\n");
   /* Do an initial ls */
   if (mountFS())
   {
     chprintf((BaseSequentialStream *)&SERIAL_DRIVER, "Listing files on the SD card ...\r\n");
     scan_files((BaseSequentialStream *)&SERIAL_DRIVER, rootpath);
   }




  /* Initialize I2C1 */
  initI2CHw();

  /* Initalize CC3000 Hardware */
  chprintf((BaseSequentialStream *)&SERIAL_DRIVER,"Initializing CC3000 SPI hardware ...");
  initCC3000SpiHw();
  chprintf((BaseSequentialStream *)&SERIAL_DRIVER,"done!\r\n");
  chprintf((BaseSequentialStream *)&SERIAL_DRIVER,"Initializing CC3000 ...\r\n");
  initCC3000Hw();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);


  /*
   * Shell manager initialization.
   */
  shellInit();


  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and listen for events.
   */
  while (TRUE) {
      if (!shelltp)
          shelltp = shellCreate(&shell_cfg, 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(500);
  }

}
示例#27
0
/*
 * Application entry point.
 */
int main(void) {
    color_t color = Black;
    uint16_t pen = 0;
    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();

    gdispInit();
    ginputGetMouse(0);
    gdispSetOrientation(GDISP_ROTATE_90);

    drawScreen();

  /*
   * 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);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * 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 (!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.        */
    }

    ginputGetMouseStatus(0, &ev);
    if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
    {
        chThdSleepMicroseconds(500); // Senza questo sleep l'USB non parte
        continue;
    }

    /* inside color box ? */
    if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
      if(GET_COLOR(0))   color = Black;
      else if(GET_COLOR(1))   color = Red;
      else if(GET_COLOR(2))   color = Yellow;
      else if(GET_COLOR(3))   color = Green;
      else if(GET_COLOR(4))   color = Blue;
      else if(GET_COLOR(5))   color = White;

    /* inside pen box ? */
    } else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
      if(GET_PEN(1))             pen = 0;
      else if(GET_PEN(2))             pen = 1;
      else if(GET_PEN(3))             pen = 2;
      else if(GET_PEN(4))             pen = 3;
      else if(GET_PEN(5))             pen = 4;

    /* inside drawing area ? */
    } else if(DRAW_AREA(ev.x, ev.y)) {
      if(pen == 0)
         gdispDrawPixel(ev.x, ev.y, color);
      else
          gdispFillCircle(ev.x, ev.y, pen, color);
    }
  }
}
示例#28
0
文件: main.c 项目: pfhnr/stm32
int main(void) {
  static Thread *shelltp = NULL;
  static const evhandler_t evhndl[] = {
    InsertHandler,
    RemoveHandler,
	 packetReceivedHandler
  };
  struct EventListener el0, el1, el2;
	chEvtRegister(&packet_event, &el2, 0);
	chEvtInit(&packet_event);

  /*
   * 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);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Activates the serial driver 6 and SDC driver 1 using default
   * configuration.
   */
  sdStart(&SD6, NULL);
  sdcStart(&SDCD1, NULL);

  /*
   * Activates the card insertion monitor.
   */
  tmr_init(&SDCD1);

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Creates the LWIP threads (it changes priority internally).
   */
  chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 2,
                    lwip_thread, NULL);

  /*
   * Creates the HTTP thread (it changes priority internally).
   */
	/*
  chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
                    http_server, NULL);

	*/

	WORKING_AREA(wa_udp_receive_server, PWM_REC_STACK_SIZE);
	chThdCreateStatic(wa_udp_receive_server, sizeof(wa_udp_receive_server), NORMALPRIO +1,
							udp_receive_server_init, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and listen for events.
   */
  chEvtRegister(&inserted_event, &el0, 0);
  chEvtRegister(&removed_event, &el1, 1);
  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.        */
    }
    if (palReadPad(GPIOA, GPIOA_BUTTON_WKUP) != 0) {
    }
    chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(500)));
  }
}
示例#29
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();
    chSysInit();
    sdStart(&CONSOLE, &sdConfig);
    chprintf((BaseSequentialStream *)&CONSOLE, "GENIST SPIF\r\n");

    /*
     * Shell manager initialization.
     */
    shellInit();

    /* Get database from Flash */
    chprintf((BaseSequentialStream *)&CONSOLE, "Restoring database\r\n");
    dbRestore();
    chThdSleepMilliseconds(1000);

    // disable analog status
    // enableAstatus(0);

    palClearPad(OUT_AXLE1_PORT, OUT_AXLE1_PIN);
    palClearPad(OUT_AXLE2_PORT, OUT_AXLE2_PIN);
    palClearPad(OUT_AXLE3_PORT, OUT_AXLE3_PIN);
    palClearPad(OUT_AXLE4_PORT, OUT_AXLE4_PIN);
    palClearPad(OUT_BACKUP2_PORT, OUT_BACKUP2_PIN);
    palClearPad(OUT_BACKUP_PORT, OUT_BACKUP_PIN);
    palClearPad(OUT_ACTIVECOOL_PORT, OUT_ACTIVECOOL_PIN);
    palClearPad(OUT_FLOCK_PORT, OUT_FLOCK_PIN);
    palClearPad(OUT_LOCK_PORT, OUT_LOCK_PIN);
    palClearPad(OUT_BULBCHECK_PORT, OUT_BULBCHECK_PIN);
    palClearPad(OUT_LEDPOWER_PORT, OUT_LEDPOWER_PIN);
    palClearPad(OUT_SENSPOWER_PORT, OUT_SENSPOWER_PIN);
    palClearPad(LED_STBY_PAD, LED_STBY_PIN);

//    enableAstatus(0);

//    StateMachineMailboxInit();
//    startThreadStateMachine();
//    startThreadSpeed();
//    startThreadBlinker();
//    startThreadPressureSensor();
    startThreadSDADC();
    //startThreadMonitor();
#ifdef GENIST_USE_RTD
    startThreadRTD();
#endif
//    initHazard();
    /*
     * Normal main() thread activity, it does nothing except sleeping in a loop.
     */
#ifdef START_JSON
    startJSON();
#endif
    while (TRUE)
    {
#ifndef START_JSON
        if (!shelltp)
        {
            /* Spawns a new shell.*/
            shelltp = startConsole();
        }
        else
        {
            /* If the previous shell exited.*/
            if (chThdTerminated(shelltp))
            {
                /* Recovers memory of the previous shell.*/
                chThdRelease(shelltp);
                shelltp = NULL;
                dbgprint_enable = FALSE;
            }
        }
#else
#endif
        chThdSleepMilliseconds(10000);
    }
}
示例#30
0
/*
 * 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();

  /*
   * 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);

  /*
   * Initialise SDRAM, board.h has already configured GPIO correctly (except that ST example uses 50MHz not 100MHz?)
   */
  SDRAM_Init();
  sdram_bulk_erase();

  /*
   * Activates the LCD-related drivers.
   */
  spiStart(&SPID5, &spi_cfg5);
  ili9341Start(&ILI9341D1, &ili9341_cfg);
  initialize_lcd();
  ltdcStart(&LTDCD1, &ltdc_cfg);

  /*
   * Activates the DMA2D-related drivers.
   */
  dma2dStart(&DMA2DD1, &dma2d_cfg);
  dma2d_test();

  /*
   * Creating the blinker threads.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 10,
                    Thread1, NULL);
  chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO + 10,
                    Thread2, NULL);

  /*
   * Normal main() thread activity, in this demo it just performs
   * a shell respawn upon its termination.
   */
  while (TRUE) {
    if (!shelltp) {
      if (SDU1.config->usbp->state == USB_ACTIVE) {
        /* Spawns a new shell.*/
        shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
      }
    }
    else {
      /* If the previous shell exited.*/
      if (chThdTerminated(shelltp)) {
        /* Recovers memory of the previous shell.*/
        chThdRelease(shelltp);
        shelltp = NULL;
      }
    }
    chThdSleepMilliseconds(500);
  }
}