示例#1
0
int main(void) {
	irInit();
	while(1) {
		if (irCTR) {
			unsigned long data = irRead;
		}
	}
}
示例#2
0
void main(void) {
  irInit();

  while (1) {
    if (irTest()) {
      P1 = irGetDataCode();
    }
  }

}
示例#3
0
void userInit(void)
{
    delayInit(72);
    uartxInit();
    rgbLedInit();
    ledGpioInit();
    rgbKeyGpioInit();
    motorInit();
    dht11Init();
    irInit();
    watchdogInit(2);    //5,625看门狗复位时间2s
    
    memset((uint8_t*)&reportData, 0, sizeof(gizwitsReport_t));
    reportData.devStatus.Motor_Speed = protocolExchangeBytes(Y2X(MOTOR_SPEED_RATIO,MOTOR_SPEED_ADDITION,MOTOR_SPEED_DEFAULT));
    motorStatus(MOTOR_SPEED_DEFAULT);
}
示例#4
0
void StartCore(void) {
    PORTB = 0xAA;
    DDRB = 0xFF;

    //  初始化小按键
    DDRP_DDRP0 = 0;
    PPSP_PPSP0 = 0;
    PERP_PERP0 = 1;

    /********************************/
    /* 初始化 */
    InitServo();
    StartServo();
    SetServo(90);

    InitSpeeder();

    irInit();

    InitADC();

    InitSCI0();

    WaitEnable();

    /*******************************/

    GetBlackAndWhite();

    PORTB = 0x55;

    Wait(1500);

    PORTB = 0xAA;

    while (PTIP_PTIP0);

    PORTB = 0x5A;

    Wait(1000);

    PORTB = 0xA5;

    CoreControl();

}
示例#5
0
int main(int argc, char* argv[]) {
  struct bParamList * paramList = NULL;
  const char *strPtr;

  int ii;

  for (ii=0; ii<TCX_MAX_CLIENTS; ii++) {
    CLIENT[ii] = NULL;
  }

  /*
   * Set some parameters
   */

  /* add some defaults */
  paramList = bParametersAddEntry(paramList, "*", "base.bps", "9600");
  paramList = bParametersAddEntry(paramList, "*", "base.dev", "/dev/cur0");
  paramList = bParametersAddEntry(paramList, "", "TCXHOST", "localhost");
  paramList = bParametersAddEntry(paramList, "", "fork", "yes");

  /* add some parameter files */
  paramList = bParametersAddFile(paramList, "etc/beeSoft.ini");

  /* add some enviroment variables */
  paramList = bParametersAddEnv(paramList, "", "TCXHOST");

  /* add command line arguements */
  paramList = bParametersAddArray(paramList, "", argc, argv);

  /* here is where we should add non "parameter format" options */


  bParametersFillParams(paramList);

  strPtr = bParametersGetParam(paramList, "robot", "name");
  if (!strPtr) {
    fprintf(stderr,
	    "Robot name not set.  Check the value in beeSoft.ini.\n");
    exit(1);
  }
  else if (!strcmp("none", strPtr)) {
    fprintf(stderr,
	    "Robot name set to 'none'.  Check value in beeSoft.ini.\n");
    exit(1);
  }

  strPtr = bParametersGetParam(paramList, strPtr, "base.type");
  if (!strPtr) {
    fprintf(stderr,
	    "Base type not set.  Check the value in beeSoft.ini.\n");
    exit(1);
  }
  else if (
	   strcmp("B14", strPtr) &&
	   strcmp("B21", strPtr) &&
	   strcmp("Ramona", strPtr)
	   ) {
    fprintf(stderr,
	    "Arm type set to unrecognized type '%s'.  Check the\n"
	    "value in beeSoft.ini.\n", strPtr);
    exit(1);
  }
  
  /*
   *
   */

  argv0 = argv[0];

  if (makeLock(BASE_SERVER_LOCK)<0) {
    fprintf(stderr,"%s:  Already running base server\n",argv[0]);
    exit(-1);
  }

  if (findArg(argc,argv,"-v")) {
    VERBOSE = TRUE;
    fprintf(stderr,"baseServer started in verbose mode\n");
  }

  if (findArg(argc,argv,"-noIrs")) {
    IRS = FALSE;
    fprintf(stderr,"baseServer started without IRs\n");
  }

  if (findArg(argc,argv,"-noTactiles")) {
    TACTILES = FALSE;
    fprintf(stderr,"baseServer started without Tactiles\n");
  }

  if (findArg(argc,argv,"-noSonars")) {
    SONARS= FALSE;
    fprintf(stderr,"baseServer started without Sonars\n");
  }

  if (findArg(argc,argv,"-simulator")) {
    useSimulator=TRUE;
    fprintf(stderr,"baseServer connecting to simulator.\n");
  }

  
  RaiInit();
  BaseInit(bRobot.base_dev, bRobot.base_bps);
  catchInterrupts();

  initBaseServerTCX(bRobot.TCXHOST);

  if (useSimulator==TRUE) {
    simulatorHandle = tcxConnectModule(TCX_SIMULATOR_MODULE_NAME);
  }

  registerWatchdogCallback(watchdogToClient);

  /*
   * GRUMBLE - It is going to be a bit ugly to get the sensor
   * structures initialized without opening /dev/abus.  tds
   */

  if (SONARS && !useSimulator) {
    sonarInit();
    registerSonarCallback(sonarToClient);
    SIM_sonarStop();  /* turn off sonar until we have a client */
  }

  if (IRS && !useSimulator) {
    irInit();
    registerIrCallback(irToClient);
    SIM_irStop();  /* turn off ir until we have a client */
  }

  if (TACTILES && !useSimulator) {
    tactileInit();
    registerTactileCallback(tactileToClient);
    tactileStop();
  }

  registerStatusCallback(statusToClient);
  registerBaseCallback(baseToClient);
  initBaseServerModules();

  if (bRobot.fork) {
    bDaemonize("baseServer.log");
  }

  rotateLimp(); 
  translateLimp(); 

  RaiStart();

  exit(0);
}
示例#6
0
文件: main.c 项目: jkramarz/kdhome
void main()
{
	SCB->VTOR = 0x08000000;
	
	// set clock source as HSI / 2 * (PLL) 4
	RCC->CFGR |= RCC_CFGR_PLLMULL8 | RCC_CFGR_PLLXTPRE_HSE_Div2 /*| RCC_CFGR_PLLSRC*/;
	RCC->CR |= RCC_CR_PLLON;
	while (!(RCC->CR & RCC_CR_PLLRDY));
	RCC->CFGR |= RCC_CFGR_SW_PLL;
	while (!(RCC->CFGR & RCC_CFGR_SWS_PLL));

	// enable peripherals
	RCC->APB1ENR = RCC_APB1ENR_TIM2EN;
	RCC->APB2ENR = RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_ADC1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_AFIOEN;

	AFIO->MAPR = AFIO_MAPR_SWJ_CFG_JTAGDISABLE; 
	
	// configure USART
	IO_ALT_PUSH_PULL(UART_TX);
	USART1->BRR = USART_BRR(230400);
	USART1->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE;
	ENABLE_INTERRUPT(USART1_IRQn);

	// enable systick
	SysTick->LOAD = SysTick->VAL = (F_CPU / 1000) / 8;
	SysTick->CTRL = /*SysTick_CTRL_CLKSOURCE |*/ SysTick_CTRL_ENABLE | SysTick_CTRL_TICKINT;

	_delay_init();
	
	IO_PUSH_PULL(LED);
	IO_HIGH(LED);

#ifndef ETHERNET_MODULE
	OW_UART_init();
	tempInit();
	ioInit();
	irInit();
#endif
#ifdef ETHERNET
	ethInit();
#endif


	uint8_t b;
	uint32_t lastCheck = 0;
	for (;;)
	{
		// if (IO_IS_LOW(IN1)) dodump = 1;
		// else dodump = 0;
		// dodump=1;
		
#ifndef ETHERNET_MODULE
		ioProcess();
	
		tempProcess();

		irProcess();
#endif
		provTmr();
#ifdef ETHERNET
		ethProcess();
#endif
	}
}