コード例 #1
0
ファイル: main.c プロジェクト: Maelok/esc32
void main(void) {
    rccInit();
    timerInit();
    configInit();
    adcInit();
    fetInit();
    serialInit();
    runInit();
    cliInit();
    owInit();

    runDisarm(REASON_STARTUP);
    inputMode = ESC_INPUT_PWM;

    fetSetDutyCycle(0);
    fetBeep(200, 100);
    fetBeep(300, 100);
    fetBeep(400, 100);
    fetBeep(500, 100);
    fetBeep(400, 100);
    fetBeep(300, 100);
    fetBeep(200, 100);

    pwmInit();

    statusLed = digitalInit(GPIO_STATUS_LED_PORT, GPIO_STATUS_LED_PIN);
    digitalHi(statusLed);
    errorLed = digitalInit(GPIO_ERROR_LED_PORT, GPIO_ERROR_LED_PIN);
    digitalHi(errorLed);
#ifdef ESC_DEBUG
    tp = digitalInit(GPIO_TP_PORT, GPIO_TP_PIN);
    digitalLo(tp);
#endif

    // self calibrating idle timer loop
    {
        volatile unsigned long cycles;
        volatile unsigned int *DWT_CYCCNT = (int *)0xE0001004;
        volatile unsigned int *DWT_CONTROL = (int *)0xE0001000;
        volatile unsigned int *SCB_DEMCR = (int *)0xE000EDFC;

        *SCB_DEMCR = *SCB_DEMCR | 0x01000000;
        *DWT_CONTROL = *DWT_CONTROL | 1;	// enable the counter

	minCycles = 0xffff;
        while (1) {
            idleCounter++;

	    NOPS_4;

            cycles = *DWT_CYCCNT;
            *DWT_CYCCNT = 0;		    // reset the counter

            // record shortest number of instructions for loop
	    totalCycles += cycles;
            if (cycles < minCycles)
                minCycles = cycles;
        }
    }
}
コード例 #2
0
ファイル: minus.c プロジェクト: vanjac/Minus
int main(int argc, char * argv[])
{
  initAll();

  if(argc != 2) {
    error("Minus takes a single argument: the program file to run.\n");
  }
  
  FILE * file = readFile(argv[1]);
  process(file);
  fclose(file);

  //printf("%s\n\n", processedProgram);
  
  runInit();
  while(1)
    runStep();
}
コード例 #3
0
ファイル: NDBT_Test.cpp プロジェクト: carrotli/ansql
int NDBT_TestCase::execute(NDBT_Context* ctx)
{
  char buf[64]; // For timestamp string
  ndbout << "- " << _name << " started ["
         << ctx->suite->getDate(buf, sizeof(buf))
	 << "]" << endl;

  ctx->setCase(this);

  // Copy test case properties to ctx
  Properties::Iterator it(&props);
  for(const char * key = it.first(); key != 0; key = it.next()){

    PropertiesType pt;
    const bool b = props.getTypeOf(key, &pt);
    require(b == true);
    switch(pt){
    case PropertiesType_Uint32:{
      Uint32 val;
      props.get(key, &val);
      ctx->setProperty(key, val);
      break;
    }
    case PropertiesType_char:{
      const char * val;
      props.get(key, &val);
      ctx->setProperty(key, val);
      break;
    }
    default:
      abort();
    }
  }

  // start timer so that we get a time even if
  // test case consist only of initializer
  startTimer(ctx);
  
  int res;
  if ((res = runInit(ctx)) == NDBT_OK){
    // If initialiser is ok, run steps
    
    res = runSteps(ctx);
    if (res == NDBT_OK){
      // If steps is ok, run verifier
      res = runVerifier(ctx);
    } 
    
  }

  stopTimer(ctx);
  printTimer(ctx);

  // Always run finalizer to clean up db
  runFinal(ctx); 

  if (res == NDBT_OK) {
    ndbout << "- " << _name << " PASSED ["
           << ctx->suite->getDate(buf, sizeof(buf))
           << "]" << endl;
  }
  else {
    ndbout << "- " << _name << " FAILED ["
           << ctx->suite->getDate(buf, sizeof(buf))
           << "]" << endl;
  }
  return res;
}
コード例 #4
0
ファイル: main.c プロジェクト: 739374663/esc32
void main(void) {
    rccInit();

    statusLed = digitalInit(GPIO_STATUS_LED_PORT, GPIO_STATUS_LED_PIN);
    errorLed = digitalInit(GPIO_ERROR_LED_PORT, GPIO_ERROR_LED_PIN);
#ifdef ESC_DEBUG
    tp = digitalInit(GPIO_TP_PORT, GPIO_TP_PIN);
    digitalLo(tp);
#endif

    timerInit();
    configInit();
    adcInit();
    fetInit();
    serialInit();
    canInit();
    runInit();
    cliInit();
    owInit();

    runDisarm(REASON_STARTUP);
    inputMode = ESC_INPUT_PWM;

    fetSetDutyCycle(0);
    fetBeep(200, 100);
    fetBeep(300, 100);
    fetBeep(400, 100);
    fetBeep(500, 100);
    fetBeep(400, 100);
    fetBeep(300, 100);
    fetBeep(200, 100);

    pwmInit();

    digitalHi(statusLed);
    digitalHi(errorLed);

    // self calibrating idle timer loop
    {
	uint32_t lastRunCount;
	uint32_t thisCycles, lastCycles;
        volatile uint32_t cycles;
        volatile uint32_t *DWT_CYCCNT = (uint32_t *)0xE0001004;
        volatile uint32_t *DWT_CONTROL = (uint32_t *)0xE0001000;
        volatile uint32_t *SCB_DEMCR = (uint32_t *)0xE000EDFC;

        *SCB_DEMCR = *SCB_DEMCR | 0x01000000;
        *DWT_CONTROL = *DWT_CONTROL | 1;	// enable the counter

	minCycles = 0xffff;
        while (1) {
            idleCounter++;

	    if (runCount != lastRunCount && !(runCount % (RUN_FREQ / 1000))) {
		if (commandMode == CLI_MODE)
		    cliCheck();
		else
		    binaryCheck();
		lastRunCount = runCount;
	    }

            thisCycles = *DWT_CYCCNT;
	    cycles = thisCycles - lastCycles;
	    lastCycles = thisCycles;

            // record shortest number of instructions for loop
	    totalCycles += cycles;
            if (cycles < minCycles)
                minCycles = cycles;
        }
    }
}