Ejemplo n.º 1
0
uint8_t start_capture(char* filename) 
{
  sd_reset();
  uint8_t result = init_sd_card();
  if (result != SD_SUCCESS) {
    return result;
  }
  capturedBytes = 0L;
  file = NULL;
  // Always operate in truncation mode.
  sdcard.delete_file(filename);
  uint8_t rc = sdcard.create_file(filename);
  if (rc == 0) {
    return SD_ERR_FILE_NOT_FOUND;
    //return rc;
  }
  rc = sdcard.open_file(filename,&file);

  if (rc == 0) {
    return SD_ERR_PARTITION_READ;
  }
  if (file == NULL) {
    return SD_ERR_GENERIC;
  }

  capturing = true;
  return SD_SUCCESS;
}
Ejemplo n.º 2
0
uint8_t sd_scan_reset() {
  sd_reset();
  uint8_t rsp = init_sd_card();
  if (rsp != SD_SUCCESS) {
    return rsp;
  }
  return sdcard.sd_scan_reset();
}
Ejemplo n.º 3
0
static void _init( u16 hard )
{
   if ( hard == 0 ) // 0 is soft reset
   {
      VDP_drawText ( "BUG HUNT", 16, 9 );
      VDP_drawText ( "FOR SEGA MEGADRIVE", 11, 11 );
      VDP_drawText ( "BY THE AFROMONKEYS, 2015", 8, 13 );

      waitMs(3000);


      // That's weird.
      // Resetting in SGDK v1.11 invokes JOY_init() that
      // makes Justifier | Menacer not to be detected if
      // mouse is on PORT_1

      if ( JOY_getPortType(PORT_1) != PORT_TYPE_PAD )
      {
         VDP_drawText ( "PLEASE, REBOOT YOUR SYSTEM", 7, 19 );

         while ( 1 );
      }

      _start_entry(); // even more reset
   }


   sd_reset();
   SYS_assertReset(); // makes gensKmod crash, WTF?!



   VDP_init();
   //JOY_init();  // can cause mouse + justifer issues

   h_scroll = 0;
   VDP_setScrollingMode ( HSCROLL_PLANE, VSCROLL_PLANE );     /* The scroll mode never change during the game */
   VDP_setPlanSize(64,32);

   save_init( );

   SPR_init(0);                                             /* Sprite Engine INIT */
   VDP_setPalette(PAL3, sprpal.data);                       /* Sprite Palette (never change during the game) */

   /* PAD & Mouse (PORT_1) & Lightgun (PORT_2) Support */
   _JOYint ( TRUE );
   LightgunInit ( PORT_2 );

   VINT_SCROLL_FLAG  = FALSE;
   VINT_JOY_UPDATE   = FALSE;

   SYS_setVIntCallback((_voidCallback*) VIntCallback);

   FIRST_TIME_FLAG = TRUE;
}
Ejemplo n.º 4
0
static void ss_reset(ss_t *s, const size_t alloc_size, const sbool_t ext_buf)
{
	S_ASSERT(s);
	if (s) { /* do not change 'ext_buffer' */
		sd_reset((sd_t *)s, sd_alloc_size_to_is_big(alloc_size, &ssf),
			 alloc_size, ext_buf);
		set_unicode_size_cached(s, S_TRUE);
		if (s->is_full) {
			set_unicode_size_h(s, 0);
		}
		set_encoding_errors(s, S_FALSE);
		set_unicode_size(s, 0);
	}
}
Ejemplo n.º 5
0
uint8_t start_playback(char* filename) {
  sd_reset();
  uint8_t result = init_sd_card();
  if (result != SD_SUCCESS) {
    return result;
  }
  capturedBytes = 0L;
  file = NULL;
  uint8_t rc = sdcard.open_file(filename, &file);

  if (rc == 0 || file == NULL) {
    return SD_ERR_FILE_NOT_FOUND;
  }

  playing = true;
  fetch_next_byte();
  return SD_SUCCESS;
}
Ejemplo n.º 6
0
DSTATUS disk_initialize (void)
{
	DSTATUS stat;
	
	send_data_uart0_str("Init of sd card\r\n");

	if(sd_reset() == SD_NO_ERROR)
	{
		stat = 0;
		sd_init = TRUE;
	}
	else
	{
		stat = STA_NOINIT;
	}

	
	return stat;
}
Ejemplo n.º 7
0
int main(void) {
	uint32_t sysTickRate;

	Board_Init();

#ifdef DEBUG
	// Set up UART for debug
	init_uart(115200);
	putLineUART("\n");
#endif

	// Enable EEPROM clock and reset EEPROM controller
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_EEPROM);
	Chip_SYSCTL_PeriphReset(RESET_EEPROM);

	// Set up clocking for SD lib
	SystemCoreClockUpdate();
	DWT_Init();

	// Set up the FatFS Object
	f_mount(fatfs,"",0);

	// Initialize SD card
	Board_LED_Color(LED_CYAN);
	if(sd_reset(&cardinfo) != SD_OK) {
		error(ERROR_SD_INIT);
	}
	sd_state = SD_READY;

	// Setup config
	Board_LED_Color(LED_CYAN);
	configStart();
	Board_LED_Color(LED_GREEN);

	// Allow MSC mode on startup
	msc_state = MSC_ENABLED;

	// Log startup
	log_string("Startup");

	// Set up ADC for reading battery voltage
	read_vBat_setup();

	// Initialize ring buffer used to buffer raw data samples
	rawBuff = RingBuffer_initWithBuffer(RAW_BUFF_SIZE, RAM1_BASE);

	// Set up MRT used by pb and daq
	Chip_MRT_Init();
	NVIC_ClearPendingIRQ(MRT_IRQn);
	NVIC_EnableIRQ(MRT_IRQn);
	NVIC_SetPriority(MRT_IRQn, 0x02); // Set higher than systick, but lower than sampling

	// Initialize push button
	pb_init();

	// Enable and setup SysTick Timer at a periodic rate
	Chip_Clock_SetSysTickClockDiv(1);
	sysTickRate = Chip_Clock_GetSysTickClockRate();
	SysTick_Config(sysTickRate / TICKRATE_HZ1);

	// Idle and run systick loop until triggered or plugged in as a USB device
	system_state = STATE_IDLE;
	enterIdleTime = Chip_RTC_GetCount(LPC_RTC);

    // Wait for interrupts
    while (1) {
    	__WFI();
    }

    return 0 ;
}
Ejemplo n.º 8
0
uint8_t sd_init() {
    uint8_t i,r1, time = 0;

	//sd reset
	sd_reset();
	
    //set CS low  
    cs_enable();

    //check interface operating condition  
    r1 = sd_send_cmd(CMD8, 0x000001aa, 0x87);
    //if support Ver1.x,but do not support Ver2.0,set CS high and return r1  
    if (r1 == 0x05) {
        //set CS high and send 8 clocks  
        cs_disable();
        sd_type = SD_CARD_TYPE_SD1;
        return r1;
    }
    //read the other 4 bytes of response(the response of CMD8 is 5 bytes)  
    for(i=0;i<4;i++) r1 = spi_read_byte();
    
    sd_type = SD_CARD_TYPE_SD2;
    serial_printf("support Ver2.0\n");
    
	//send CMD55+ACMD41 to initial SD card  
    do {
        do {
            r1 = sd_send_cmd(CMD55, 0, 0xff);
            time++;
            //if time out,set CS high and return r1  
            if (time > 254){
                //set CS high and send 8 clocks
                cs_disable();
                return r1;
            }
        } while (r1 != 0x01);

        r1 = sd_send_cmd(ACMD41, 0x40000000, 0xff);

        //send CMD1 to initial SD card  
        // r1 = sd_send_cmd(CMD1,0x00ffc000,0xff);  
        time++;

        //if time out,set CS high and return r1  
        if (time > 254) {
            //set CS high and send 8 clocks  
            cs_disable();
            return r1;
        }
    } while (r1 != 0x00);

    // if SD2 read OCR register to check for SDHC card
    r1 = sd_send_cmd(CMD58,0,0xFF);
    if (r1 == 0x05) {
        cs_disable();
        return r1;
    }
    r1 = spi_read_byte();
	
    if(r1 & 0x40){
        sd_type = SD_CARD_TYPE_SDHC;
        serial_printf("SDHC card \n");
    }
    for(i=0;i<3;i++) r1 = spi_read_byte();
	
    //set CS high and send 8 clocks  
    cs_disable();
    
    serial_printf("sd_init ok\n");
    return 0;
}