Exemplo n.º 1
0
/*
 * Application entry point.
 */
int main(void) {

  /* performance counters */
  int32_t adc_ints = 0;
  int32_t spi_ints = 0;
  int32_t uart_ints = 0;
  int32_t adc_idle_ints = 0;
  int32_t spi_idle_ints = 0;
  int32_t uart_idle_ints = 0;
  uint32_t background_cnt = 0;
  systime_t T = 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();

#if STM32_NAND_USE_EXT_INT
  extStart(&EXTD1, &extcfg);
#endif
  chTMObjectInit(&tmu_driver_start);
  chTMStartMeasurementX(&tmu_driver_start);
#if USE_BAD_MAP
  nandStart(&NAND, &nandcfg, &badblock_map);
#else
  nandStart(&NAND, &nandcfg, NULL);
#endif
  chTMStopMeasurementX(&tmu_driver_start);

  chThdSleepMilliseconds(4000);

  chThdCreateStatic(BackgroundThreadWA,
        sizeof(BackgroundThreadWA),
        NORMALPRIO - 20,
        BackgroundThread,
        NULL);

  nand_wp_release();

  /*
   * run NAND test in parallel with DMA load and background thread
   */
  dma_storm_adc_start();
  dma_storm_uart_start();
  dma_storm_spi_start();
  T = chVTGetSystemTimeX();
  general_test(&NAND, NAND_TEST_START_BLOCK, NAND_TEST_END_BLOCK, 1);
  T = chVTGetSystemTimeX() - T;
  adc_ints = dma_storm_adc_stop();
  uart_ints = dma_storm_uart_stop();
  spi_ints = dma_storm_spi_stop();
  chSysLock();
  background_cnt = BackgroundThdCnt;
  BackgroundThdCnt = 0;
  chSysUnlock();

  /*
   * run DMA load and background thread _without_ NAND test
   */
  dma_storm_adc_start();
  dma_storm_uart_start();
  dma_storm_spi_start();
  chThdSleep(T);
  adc_idle_ints = dma_storm_adc_stop();
  uart_idle_ints = dma_storm_uart_stop();
  spi_idle_ints = dma_storm_spi_stop();

  /*
   * ensure that NAND code have negligible impact on other subsystems
   */
  osalDbgCheck(background_cnt > (BackgroundThdCnt / 4));
  osalDbgCheck(abs(adc_ints  - adc_idle_ints)  < (adc_idle_ints  / 20));
  osalDbgCheck(abs(uart_ints - uart_idle_ints) < (uart_idle_ints / 20));
  osalDbgCheck(abs(spi_ints  - spi_idle_ints)  < (spi_idle_ints  / 10));

  /*
   * perform ECC calculation test
   */
  ecc_test(&NAND, NAND_TEST_END_BLOCK);

#if USE_KILL_BLOCK_TEST
  kill_block(&NAND, NAND_TEST_KILL_BLOCK);
#endif

  nand_wp_assert();

  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (true) {
    chThdSleepMilliseconds(500);
  }
}
Exemplo n.º 2
0
/*
 * Application entry point.
 */
int main(void) {

  size_t start = 1100;
  size_t end = 1150;
  volatile int32_t adc_its = 0;
  volatile int32_t spi_its = 0;
  volatile int32_t uart_its = 0;
  volatile int32_t adc_its_idle = 0;
  volatile int32_t spi_its_idle = 0;
  volatile int32_t uart_its_idle = 0;
  volatile uint32_t idle_thread_cnt = 0;

  #if EMCNAND_USE_KILL_TEST
  size_t kill = 8000;
  #endif

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

  emcStart(&EMCD1, &emccfg);
#if !STM32_EMC_EMCNAND_USE_FSMC_INT
  extStart(&EXTD1, &extcfg);
#endif
  emcnandStart(&EMCNANDD1, &nandcfg);

  chThdSleepMilliseconds(4000);

  chThdCreateStatic(fsmcIdleThreadWA,
        sizeof(fsmcIdleThreadWA),
        NORMALPRIO - 20,
        fsmcIdleThread,
        NULL);

  nand_wp_release();

  dma_storm_adc_start();
  dma_storm_uart_start();
  dma_storm_spi_start();
  T = chVTGetSystemTimeX();
  general_test(&EMCNANDD1, start, end, 1);
  T = chVTGetSystemTimeX() - T;
  adc_its = dma_storm_adc_stop();
  uart_its = dma_storm_uart_stop();
  spi_its = dma_storm_spi_stop();
  chSysLock();
  idle_thread_cnt = IdleCnt;
  IdleCnt = 0;
  chSysUnlock();

  dma_storm_adc_start();
  dma_storm_uart_start();
  dma_storm_spi_start();
  chThdSleep(T);
  adc_its_idle = dma_storm_adc_stop();
  uart_its_idle = dma_storm_uart_stop();
  spi_its_idle = dma_storm_spi_stop();

  osalDbgCheck(idle_thread_cnt > (IdleCnt / 4));
  osalDbgCheck(abs(adc_its - adc_its_idle)   < (adc_its_idle  / 20));
  osalDbgCheck(abs(uart_its - uart_its_idle) < (uart_its_idle / 20));
  osalDbgCheck(abs(spi_its - spi_its_idle)   < (spi_its_idle  / 10));

  ecc_test(&EMCNANDD1, end);

#if EMCNAND_USE_KILL_TEST
  kill_block(&EMCNANDD1, kill);
#endif

  nand_wp_assert();

  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (TRUE) {
    chThdSleepMilliseconds(500);
  }
}