コード例 #1
0
ファイル: SDSupport.cpp プロジェクト: Brockhold/G3Firmware
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;
}
コード例 #2
0
ファイル: SDSupport.cpp プロジェクト: Brockhold/G3Firmware
uint8_t sd_scan_reset() {
  sd_reset();
  uint8_t rsp = init_sd_card();
  if (rsp != SD_SUCCESS) {
    return rsp;
  }
  return sdcard.sd_scan_reset();
}
コード例 #3
0
ファイル: SABT_MainUnit.c プロジェクト: SusanZuo/SABTSoftware
/**
 * @brief Initialize the system and interrupts
 * @return Void
 */
void initialize_system(void)
{
  timer_interrupt = false;      // Clear the timer interrupt flag
  playing_sound = false;
  message_count = 0;
  valid_message = true;

  PORTA = 0x00;
  DDRA = 0xFF;
  PORTA = 0x00;
  // Set the data direction register values
  DDRD |= _BV(5) | _BV(6) | _BV(7);

  TCCR1A = 0x00;
  TCCR1B = 0x0D;
  OCR1A = 390;            // 1s interval
  TIMSK1 |= (1<<OCIE1A);  // Enable interrupt

  init_usart_pc();
  log_msg("SABT initialising...\n\r");
  log_msg("Setting flags...OK\n\r");
  log_msg("PC USART...OK\n\r");

  log_msg("Keypad USART...");
  init_usart_keypad();
  log_msg("OK\n\r");

  log_msg("SPI...");
  spi_initialize();
  log_msg("OK\n\r");

  log_msg("Interrupt flag...");
  sei();  // sets the interrupt flag (enables interrupts)
  log_msg("OK\n\r");

  init_sd_card(true);
  log_msg("SD card...OK\n\r");

  play_mp3_file((unsigned char*)"SYS_WELC.mp3");

  ui_check_modes();
  log_msg("Parsing modes...OK\n\r");

  log_msg("Type info\n\r");
  log_msg("char: %d bytes\n\r", sizeof(char));
  
  log_msg("int: %d bytes\n\r", sizeof(int));
  
  log_msg("short: %d bytes\n\r", sizeof(short));
  
  log_msg("long: %d bytes\n\r", sizeof(long));
  
  log_msg("void*: %d bytes\n\r", sizeof(void*));
  

  play_mp3("SYS_","MENU");
}
コード例 #4
0
ファイル: SDSupport.cpp プロジェクト: Brockhold/G3Firmware
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;
}
コード例 #5
0
ファイル: main.c プロジェクト: msolajic/1541-rebuild
int main(void)
{
    int8_t byte_str[4];	    // Wird benutzt um hier ein Byte als String abzulegen

    // LCD Display intialisieren
    lcd_init();

    // Startmeldung ausgeben
    show_start_message();

    // Stepper Initialisieren
    init_stepper();

    // Motor Initialisieren
    init_motor();

    // Steursignale BYTE_READY, SYNC und SOE Initialisieren
    init_controll_signals();

    // Schreibschutz setzen
    clear_wps();

    // Timer0 --> GCR senden
    init_timer0();

    // Tasten Initialisieren
    init_keys();

    // Timer2 --> wird alle 1ms aufgerufen
    // z.B. zu Tasten entprellen
    init_timer2();

    // Meldung ausgeben, das auf SD Karte gewartet wird
    lcd_setcursor(0,2);
    lcd_string("Wait for SD-Karte...");

    // SD Karte initialisieren
    // Partition und Filesystem öffnen
    // Warten bis alles O.K. ist
    while(init_sd_card()){}

    lcd_clear();

    view_dir_entry(0,&file_entry);

#ifdef DEBUG_MODE
    lcd_setcursor(0,4);
    lcd_string("T:");

    lcd_setcursor(5,4);
    lcd_string("M:");

    lcd_setcursor(9,4);
    lcd_string("K:");

    lcd_setcursor(2,4);
    sprintf(byte_str,"%d",akt_half_track >> 1);
    lcd_string(byte_str);
#endif

    // Interrupts erlauben
    sei();

    while(1)
    {
	// Auf Steppermotor aktivität prüfen
	// und auswerten

	if(stepper_signal_r_pos != stepper_signal_w_pos)
	{
	    uint8_t stepper = stepper_signal_puffer[stepper_signal_r_pos++]>>2 | stepper_signal_puffer[stepper_signal_r_pos-1];

	    switch(stepper)
	    {
	    case 0x30: case 0x40: case 0x90: case 0xE0:
		// DEC
		stepper_dec();
		    stepper_signal_time = 0;
		    stepper_signal = 1;
		break;

	    case 0x10: case 0x60: case 0xB0: case 0xC0:
		// INC
		stepper_inc();
		    stepper_signal_time = 0;
		    stepper_signal = 1;
		break;
	    }
#ifdef DEBUG_MODE
	    lcd_setcursor(2,4);
	    lcd_string("   ");
	    lcd_setcursor(2,4);
	    sprintf(byte_str,"%d",akt_half_track >> 1);
	    lcd_string(byte_str);
#endif
	}
	else if(stepper_signal && (stepper_signal_time >= STEPPER_DELAY_TIME))
コード例 #6
0
ファイル: yggdrasil_pv.c プロジェクト: kuriel07/Yggdrasil
Shell_Object * CreatePicViewer(void) {
	Shell_Object * parent;
	uchar buf_head[8];
	uint32 length;
	uchar is_png;
	png_structp png_ptr;
	png_infop info_ptr;
	png_infop end_ptr;
	Heap_Manager * png_heap;
	Heap_Manager * pic_heap;
	void * temp_ptr;
	png_byte * row_pointers[480];
	efat_FileSystem * fs;
	efat_File * file;
	uint32 i, j;
	uchar r, g, b;
	uint16 * background;
	uint32 p_width, p_height, p_bdepth, p_ctype;
	init_sd_card(&_osc._fm_drives[0]);
	//Uart_Printf("sd driver initialized\n");
	fs = efat_Init(0, &_osc._fm_drives[0]);
	file = efat_Open("test.png", fs, "r");
	if(file == NULL) {
		Uart_Printf("file not found\n");
		return NULL;
	}
	Uart_Printf("file found\n");
	//efat_Read(512, myFile, (uchar *)buf);
	length = file_Read(8, file, buf_head);
	if(length != 8) {
		return NULL;
	}
	//memcmp("aaaa", buf_head, 3);
	is_png = !png_sig_cmp_2(buf_head, 0, 8);
	if(!is_png) {
		Uart_Printf("this is not a png file\n");
		return NULL;
	}
	Uart_Printf("this is png file\n");
	
	png_heap = m_create_heap(1024 * 2048);
	//usr_alloc(NULL, 20);
	Uart_Printf("create read struct\n");
	png_ptr = png_create_read_struct_3(PNG_LIBPNG_VER_STRING, 
	(void *)temp_ptr, png_user_error, png_user_warning,
	(void *)png_heap, usr_alloc, usr_release);
	if(png_ptr == NULL) {
		return NULL;
	}
	Uart_Printf("create info struct\n");
	info_ptr = png_create_info_struct_2(png_ptr);
	if(info_ptr == NULL) {
		png_heap = png_get_mem_ptr_2(png_ptr);
		//png_destroy_read_struct(&png_ptr, NULL, NULL);
		m_delete_heap(png_heap);
		return NULL;
	}
	end_ptr = png_create_info_struct_2(png_ptr);
	if(end_ptr == NULL) {
		png_heap = png_get_mem_ptr_2(png_ptr);
		//png_destroy_read_struct(&png_ptr, info_ptr, NULL);
		m_delete_heap(png_heap);
		return NULL;
	}
	Uart_Printf("info created\n");
	png_set_read_fn_2(png_ptr, file, usr_read_data);
	png_set_sig_bytes_2(png_ptr, 8);
	png_set_user_limits_2(png_ptr, 640, 480);
	//row_pointers = usr_alloc(png_ptr, png_ptr->height * sizeof(png_byte *));
	Uart_Printf("allocating rows pointer\n");
	/*for(i=0;i<png_ptr->height;i++) {
		row_pointers[i] = NULL;
	}*/
	for(i=0;i<320;i++) {
	    row_pointers[i] = usr_alloc(png_ptr, png_ptr->width * 4);
	    Uart_Printf("%d\n", row_pointers[i]);
	}
	//use high level interface
	Uart_Printf("use high level interface\n");
	png_read_png_2(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_SWAP_ENDIAN, NULL);
	Uart_Printf("png decoded\n");
	p_width = png_get_image_width_2(png_ptr, info_ptr);
	p_height = png_get_image_height_2(png_ptr, info_ptr); 
	p_bdepth = png_get_bit_depth_2(png_ptr, info_ptr);
	p_ctype = png_get_color_type_2(png_ptr, info_ptr);
	Uart_Printf("allocating background\n");
	//background = m_alloc(320 * 240 * sizeof(uint16));
	png_read_image_2(png_ptr, row_pointers);
	pic_heap = m_create_heap((320 * 240 * sizeof(uint16)) + 1024);
	background = m_heap_alloc(pic_heap, 320 * 240 * sizeof(uint16));
	(p_height > 320)?(p_height = 320):(p_height = p_height);
	(p_width > 240)?(p_width = 240):(p_width = p_width);
	Uart_Printf("rendering image\n");
	for(j=0;j<p_height;j++) {
		for(i=0;i<p_width;i++) {
			r = *(uchar *)((uint32)row_pointers[j] + (3 * i));
			g = *(uchar *)((uint32)row_pointers[j] + ((3 * i) + 1));
			b = *(uchar *)((uint32)row_pointers[j] + ((3 * i) + 2));
			r >>= 3;
			g >>= 2;
			b >>= 3;
			/*r = *(uchar *)((uint32)row_pointers[j] + i);
			b = r << 2;
			g = b << 2;*/
			background[(j * 240) + i] = (uint16)((r<<11)|(g<<5)|b); 
		}
	}
	//Uart_Printf("read image\n");
	//png_read_image_2(png_ptr, row_pointers);
	Uart_Printf("png decoding success\n");
	//m_alloc(2500);
	parent = CreateFrame("Viewer", background);
	/*Uart_Printf("cleaning up\n");
	for(i=0;i<320;i++) {
		//row_pointers[i] = usr_alloc(png_ptr, png_ptr->width * 4);
		usr_release(png_ptr, row_pointers[i]);
	}
	png_destroy_struct_3(png_ptr, usr_release, (void *)png_heap);*/
	return parent;
}