Example #1
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();

  /*
   * Starting and configuring the I2S driver 2.
   */
  i2sStart(&I2SD2, &i2scfg);
  palSetPadMode(GPIOB, 10, PAL_MODE_ALTERNATE(5));
  palSetPadMode(GPIOC, 3, PAL_MODE_ALTERNATE(5));

  /*
   * Starting continuous I2S transfer.
   */
  i2sStartExchange(&I2SD2);

  /*
   * Normal main() thread activity, if the button is pressed then the I2S
   * transfer is stopped.
   */
  while (true) {
    if (palReadPad(GPIOA, GPIOA_BUTTON))
      i2sStopExchange(&I2SD2);
    chThdSleepMilliseconds(500);
  }
  return 0;
}
void mp45dt02Shutdown(void)
{
    i2sStopExchange(&MP45DT02_I2S_DRIVER);
    i2sStop(&MP45DT02_I2S_DRIVER);

    chThdTerminate(pMp45dt02ProcessingThd);
    chSemReset(&mp45dt02ProcessingSem, 1);
    chThdWait(pMp45dt02ProcessingThd);
    pMp45dt02ProcessingThd = NULL;
}