Example #1
0
int sdc_shutdown(void) {
	
	if(!initted)
        return -1;
	
	SELECT();
	wait_ready();
	DESELECT();
	(void)spi_rec_byte();
	
	spi_shutdown();
	initted = 0;
	return 0;
}
Example #2
0
/**
 * The entry point to the application.
 */
int main(void) {
  /* Hardware Setup - Don't leave MCLK floating */
  LPC_GPIO0->DIR |= (1 << 1);

  SystemInit();

  /* Start the SPI Bus first, that's really important */
  general_spi_init();

  /* Power monitoring - Turn off the battery measurement circuit */
  pwrmon_init();

  /* LED */
  LED_ON();

  /* Initialise the flash memory first so this gets off the SPI bus */
  flash_spi_init();
  flash_init();
  flash_setup();
  spi_shutdown();

  /* Optionally wipe the memory. This may take a few seconds... */
  wipe_mem();

  /* Initialise the memory writing code */
  init_write();

  /* Try to initialise the audio interface */
  if (wm8737_init() < 0) { /* If it fails */
    while (1); /* Wait here forever! */
  }

  /**
   * This delay of approximately 5 seconds is so we can
   * re-program the chip before it goes to sleep
   */
  uint32_t i = 1000*1000*3;
  while (i-- > 0);

  /* Initialise the radio stack */
  radio_init(radio_rx_callback);
  /* Initialise the time */
  time_init();

  /* Sleep forever, let the wakeup loop in sleeping.c handle everything */
  infinite_deep_sleep();

  return 0;
}