コード例 #1
0
ファイル: platform_wiiu.c プロジェクト: frangarcj/RetroArch
static void frontend_wiiu_init(void *data)
{
   (void)data;
   DEBUG_LINE();
   verbosity_enable();
   DEBUG_LINE();
}
コード例 #2
0
ファイル: hci.c プロジェクト: LeoNiz/BLE-projet
void hci_write(const void* data1, const void* data2, uint8_t n_bytes1, uint8_t n_bytes2){
#if  HCI_LOG_ON
  DEBUG_LINE("HCI <- ");
  for(int i=0; i < n_bytes1; i++)
    DEBUG_LINE("%02X ", *((uint8_t*)data1 + i));
  for(int i=0; i < n_bytes2; i++)
    DEBUG_LINE("%02X ", *((uint8_t*)data2 + i));
  DEBUG_LINE("\n");    
#endif
  
  Hal_Write_Serial(data1, data2, n_bytes1, n_bytes2);
}
コード例 #3
0
ファイル: ne2000.c プロジェクト: 8devices/Caraboot
static bool
dp83902a_init(void)
{
	dp83902a_priv_data_t *dp = &nic;
	cyg_uint8* base;
	int i;

	DEBUG_FUNCTION();

	base = dp->base;
	if (!base) return false;  /* No device found */

	DEBUG_LINE();

	/* Prepare ESA */
	DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE1);  /* Select page 1 */
	/* Use the address from the serial EEPROM */
	for (i = 0; i < 6; i++)
		DP_IN(base, DP_P1_PAR0+i, dp->esa[i]);
	DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE0);  /* Select page 0 */

	printf("NE2000 - %s ESA: %02x:%02x:%02x:%02x:%02x:%02x\n",
	       "eeprom",
	       dp->esa[0],
	       dp->esa[1],
	       dp->esa[2],
	       dp->esa[3],
	       dp->esa[4],
	       dp->esa[5] );

	return true;
}
コード例 #4
0
ファイル: platform_wiiu.c プロジェクト: frangarcj/RetroArch
static void frontend_wiiu_get_environment_settings(int *argc, char *argv[],
      void *args, void *params_data)
{
   (void)args;
   DEBUG_LINE();

   fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port));
   DEBUG_LINE();
   RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port);

   fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port,
         "downloads", sizeof(g_defaults.dir.core_assets));
   fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port,
         "media", sizeof(g_defaults.dir.assets));
   fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port,
         "cores", sizeof(g_defaults.dir.core));
   fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core,
         "info", sizeof(g_defaults.dir.core_info));
   fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core,
         "savestates", sizeof(g_defaults.dir.savestate));
   fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core,
         "savefiles", sizeof(g_defaults.dir.sram));
   fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core,
         "system", sizeof(g_defaults.dir.system));
   fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core,
         "playlists", sizeof(g_defaults.dir.playlist));
   fill_pathname_join(g_defaults.dir.menu_config, g_defaults.dir.port,
         "config", sizeof(g_defaults.dir.menu_config));
   fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port,
         "config/remaps", sizeof(g_defaults.dir.remap));
   fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port,
         "filters", sizeof(g_defaults.dir.remap));
   fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port,
         "database/rdb", sizeof(g_defaults.dir.database));
   fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port,
         "database/cursors", sizeof(g_defaults.dir.cursor));
   fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
         file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
}
コード例 #5
0
ファイル: Sdp.cpp プロジェクト: padraicm/pr-downloader
bool CSdp::downloadStream(std::string url,std::list<CFileSystem::FileData>& files)
{
	CURL* curl;
	curl = curl_easy_init();
	if (curl) {
		CURLcode res;
		LOG_INFO("Using rapid");
		LOG_DOWNLOAD(url.c_str());

		curl_easy_setopt(curl, CURLOPT_URL, url.c_str());

		std::list<CFileSystem::FileData>::iterator it;
		int  buflen=files.size()/8;
		if (files.size()%8!=0)
			buflen++;
		char* buf=(char*)malloc(buflen); //FIXME: compress blockwise and not all at once
		memset(buf,0,buflen);
		int destlen=files.size()*2;
		DEBUG_LINE("%d %d %d\n",(int)files.size(),buflen,destlen);
		int i=0;
		for (it=files.begin(); it!=files.end(); ++it) {
			if ((*it).download==true)
				buf[i/8] = buf[i/8] + (1<<(i%8));
			i++;
		}
		char* dest=(char*)malloc(destlen);

		gzip_str(buf,buflen,dest,&destlen);

		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_streamed_data);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
		curl_easy_setopt(curl, CURLOPT_USERAGENT, PR_DOWNLOADER_AGENT);

		globalFiles=&files;
		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dest);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,destlen);
		curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
		curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);

		res = curl_easy_perform(curl);
		free(dest);
		/* always cleanup */
		curl_easy_cleanup(curl);
		if (res!=CURLE_OK) {
			LOG_ERROR("%s\n",curl_easy_strerror(res));
			return false;
		}
	}
	return true;
}
コード例 #6
0
/**
	search for a mod, searches for the short + long name
*/
std::list<IDownload>* CRapidDownloader::search(const std::string& name, IDownload::category cat){
	DEBUG_LINE("%s",name.c_str());
	reloadRepos();
	std::list<IDownload>*tmp;
	tmp=new std::list<IDownload>;

	sdps.sort(list_compare);
	std::list<CSdp*>::iterator it;
	for (it=this->sdps.begin();it!=this->sdps.end();++it){
		if (match_download_name((*it)->getShortName().c_str(),name)
				|| (match_download_name((*it)->getName().c_str(),name))){
			IDownload* dl=new IDownload((*it)->getShortName().c_str(),(*it)->getName().c_str());
			tmp->push_back(*dl);
		}
	}
	return tmp;
}
コード例 #7
0
/**
	download by name, for example "Complete Annihilation revision 1234"
*/
bool CRapidDownloader::download_name(const std::string& longname, int reccounter){
	DEBUG_LINE("%s",longname.c_str());
	std::list<CSdp*>::iterator it;
	if (reccounter>10)
		return false;
	for (it=sdps.begin();it!=sdps.end();++it){
		if (match_download_name((*it)->getName(),longname)){
			printf("Found Depends, downloading %s\n", (*it)->getName().c_str());
			if (!(*it)->download())
				return false;
			if ((*it)->getDepends().length()>0){
				if (!download_name((*it)->getDepends(),reccounter+1))
					return false;
			}
			return true;
		}
	}
	return false;
}
コード例 #8
0
ファイル: ne2000_base.c プロジェクト: nmenon/u-boot
/**
 * This function reads the MAC address from the serial EEPROM,
 * used if PROM read fails. Does nothing for ax88796 chips (sh boards)
 */
static bool
dp83902a_init(unsigned char *enetaddr)
{
    dp83902a_priv_data_t *dp = &nic;
    u8* base;
#if defined(NE2000_BASIC_INIT)
    int i;
#endif

    DEBUG_FUNCTION();

    base = dp->base;
    if (!base)
        return false;	/* No device found */

    DEBUG_LINE();

#if defined(NE2000_BASIC_INIT)
    /* AX88796L doesn't need */
    /* Prepare ESA */
    DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE1);	/* Select page 1 */
    /* Use the address from the serial EEPROM */
    for (i = 0; i < 6; i++)
        DP_IN(base, DP_P1_PAR0+i, dp->esa[i]);
    DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE0);	/* Select page 0 */

    printf("NE2000 - %s ESA: %02x:%02x:%02x:%02x:%02x:%02x\n",
           "eeprom",
           dp->esa[0],
           dp->esa[1],
           dp->esa[2],
           dp->esa[3],
           dp->esa[4],
           dp->esa[5] );

    memcpy(enetaddr, dp->esa, 6); /* Use MAC from serial EEPROM */
#endif	/* NE2000_BASIC_INIT */
    return true;
}
コード例 #9
0
ファイル: database.cpp プロジェクト: nandra/ghost
bool Database::setValue(const QString& host, const QString& value)
{
	QStringList data = host.split("://");
	QString table = data.at(0);
	QString path = data.at(1);
	if (table.isEmpty()) {
		qDebug() << "Non existing table";
		return false;
	}

	QString dta;
	if (getValue(host).isEmpty()) {
		dta = QString("INSERT INTO %1 (path, value) VALUES('%2','%3')").arg(table).arg(path).arg(value);
	} else {
		dta = QString("UPDATE %1 SET path='%2',value='%3'").arg(table).arg(path).arg(value);
	}
	QSqlQuery query(dta);
	if (!query.exec()) {
		DEBUG_LINE(query.lastError());
		return false;
	}

	return true;
}
コード例 #10
0
/**
	write the data received from curl to the rapid pool.

	the filename is read from the sdp-list (created at request start)
	filesize is read from the http-data received (could overlap!)
*/
static size_t write_streamed_data(const void* tmp, size_t size, size_t nmemb,CSdp *sdp) {
	char buf[CURL_MAX_WRITE_SIZE];
	memcpy(&buf,tmp,CURL_MAX_WRITE_SIZE);
	if (!sdp->downlooadInitialized){
		sdp->list_it=sdp->globalFiles->begin();
		sdp->downlooadInitialized=true;
		sdp->file_handle=NULL;
		sdp->file_name="";
		sdp->skipped=0;
	}
	char* buf_start=(char*)&buf;
	const char* buf_end=buf_start + size*nmemb;
	char* buf_pos=buf_start;

	while (buf_pos<buf_end){ //all bytes written?
		if (sdp->file_handle==NULL){ //no open file, create one
			while ( (!(*sdp->list_it)->download==true) && (sdp->list_it!=sdp->globalFiles->end())){ //get file
				sdp->list_it++;
			}
			sdp->file_name=fileSystem->getPoolFileName(*sdp->list_it);
			sdp->file_handle=fopen(sdp->file_name.c_str(),"wb");
//FIXME		sdp->setStatsPos(sdp->getStatsPos()+1);
			if (sdp->file_handle==NULL){
				printf("couldn't open %s\n",(*sdp->list_it)->name.c_str());
				return -1;
			}
			//here comes the init new file stuff
			sdp->file_pos=0;
		}
		if (sdp->file_handle!=NULL){
			if ((sdp->skipped>0)&&(sdp->skipped<4)){
//				printf("difficulty %d\n",skipped);
			}
			if (sdp->skipped<4){ // check if we skipped all 4 bytes, if not so, skip them
				int toskip=intmin(buf_end-buf_pos,LENGTH_SIZE-sdp->skipped); //calculate bytes we can skip, could overlap received bufs
				for (int i=0;i<toskip;i++) //copy bufs avaiable
					sdp->cursize_buf[i]=buf_pos[i];
//				printf("toskip: %d skipped: %d\n",toskip,skipped);
				sdp->skipped=toskip+sdp->skipped;
				buf_pos=buf_pos+sdp->skipped;
				if (sdp->skipped==LENGTH_SIZE){
					(*sdp->list_it)->compsize=parse_int32(sdp->cursize_buf);
				}
			}
			if (sdp->skipped==LENGTH_SIZE){
				int towrite=intmin ((*sdp->list_it)->compsize-sdp->file_pos ,  //minimum of bytes to write left in file and bytes to write left in buf
									buf_end-buf_pos);
//				printf("%s %d %ld %ld %ld %d %d %d %d %d\n",file_name.c_str(), (*list_it)->compsize, buf_pos,buf_end, buf_start, towrite, size, nmemb , skipped, file_pos);
				int res=0;
				if (towrite>0){
					res=fwrite(buf_pos,1,towrite,sdp->file_handle);
					if (res!=towrite){
						printf("fwrite error\n");
						return -1;
					}
					if (res<=0){
						printf("\nwrote error: %d\n", res);
						return -1;
					}
				}else if (towrite<0){
					DEBUG_LINE("%s","Fatal, something went wrong here!");
					return -1;
				}

				buf_pos=buf_pos+res;
				sdp->file_pos+=res;
				if (sdp->file_pos>=(*sdp->list_it)->compsize){ //file finished -> next file
					fclose(sdp->file_handle);
					if (!fileSystem->fileIsValid(*sdp->list_it,sdp->file_name.c_str())){
						printf("File is broken?!: %s\n",sdp->file_name.c_str());
						return -1;
					}
					sdp->file_handle=NULL;
					sdp->list_it++;
					sdp->file_pos=0;
					sdp->skipped=0;
				}
			}
		}
	}
	return buf_pos-buf_start;

}
コード例 #11
0
bool CSdp::download(){
	if (downloaded) //allow download only once of the same sdp
		return true;
	filename=fileSystem->getSpringDir() + PATH_DELIMITER+"packages"+PATH_DELIMITER;
	DEBUG_LINE("%s\n",filename.c_str());
	if (!fileSystem->directoryExists(filename)){
		fileSystem->createSubdirs(filename);
	}
	int count=0;
	filename  += this->md5 + ".sdp";
	CFileSystem::FileData tmp;
	md5AtoI(md5,tmp.md5);
	std::list<CFileSystem::FileData*> files;

	if (!fileSystem->parseSdp(filename,files)){ //file isn't avaiable, download it
		IDownload dl(url + "/packages/" + md5 + ".sdp", filename);
		httpDownload->download(dl);
		fileSystem->parseSdp(filename,files); //parse downloaded file
	}

	std::list<CFileSystem::FileData*>::iterator it;
	/*	CHttpDownload* tmp=httpDownload; //FIXME: extend interface?
		tmp->setCount(files.size());
	*/
	int i=0;
	it=files.begin();
	while (it!=files.end()){
		i++;
		std::string tmpmd5="";
		md5ItoA((*it)->md5, tmpmd5);
		std::string filename=tmpmd5.substr(2);
		filename.append(".gz");
		std::string path("/pool/");
		path += tmpmd5.at(0);
		path += tmpmd5.at(1);
		path += "/";

		std::string file=fileSystem->getSpringDir() + path + filename; //absolute filename

		if (!fileSystem->directoryExists(fileSystem->getSpringDir()+path)){
			fileSystem->createSubdirs(fileSystem->getSpringDir()+path);
		}
		if (!fileSystem->fileIsValid(*it,file)){ //add invalid files to download list
			count++;
			(*it)->download=true;
		}else{
			(*it)->download=false;
		}
		if (i%10==0)
			printf("\r%d/%d checked",i,(int)files.size());
		it++;
	}
	printf("\r%d/%d need to download %d files\n",i,(unsigned int)files.size(),count);
	if (count>0){
//FIXME	httpDownload->setCount(count);
		downloaded=downloadStream(this->url+"/streamer.cgi?"+this->md5,files);
		files.clear();
		printf("Sucessfully downloaded %d files: %s %s\n",count,shortname.c_str(),name.c_str());
	}else{
		printf("Already downloaded: %s\n", shortname.c_str());
		downloaded=true;
	}
	return downloaded;
}
コード例 #12
0
ファイル: wiiu_gfx.c プロジェクト: joolswills/RetroArch
static void wiiu_gfx_update_viewport(wiiu_video_t* wiiu)
{
   int x                = 0;
   int y                = 0;
   float width          = wiiu->vp.full_width;
   float height         = wiiu->vp.full_height;
   settings_t *settings = config_get_ptr();
   float desired_aspect = video_driver_get_aspect_ratio();

   if(wiiu->rotation & 0x1)
      desired_aspect = 1.0 / desired_aspect;

   if (settings->video.scale_integer)
   {
      video_viewport_get_scaled_integer(&wiiu->vp, wiiu->vp.full_width,
            wiiu->vp.full_height, desired_aspect, wiiu->keep_aspect);
   }
   else if (wiiu->keep_aspect)
   {
#if defined(HAVE_MENU)
      if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
      {
         struct video_viewport *custom = video_viewport_get_custom();

         if (custom)
         {
            x      = custom->x;
            y      = custom->y;
            width  = custom->width;
            height = custom->height;
         }
      }
      else
#endif
      {
         float delta;
         float device_aspect  = ((float)wiiu->vp.full_width) / wiiu->vp.full_height;

         if (fabsf(device_aspect - desired_aspect) < 0.0001f)
         {
            /* If the aspect ratios of screen and desired aspect
             * ratio are sufficiently equal (floating point stuff),
             * assume they are actually equal.
             */
         }
         else if (device_aspect > desired_aspect)
         {
            delta = (desired_aspect / device_aspect - 1.0f)
               / 2.0f + 0.5f;
            x     = (int)roundf(width * (0.5f - delta));
            width = (unsigned)roundf(2.0f * width * delta);
         }
         else
         {
            delta  = (device_aspect / desired_aspect - 1.0f)
               / 2.0f + 0.5f;
            y      = (int)roundf(height * (0.5f - delta));
            height = (unsigned)roundf(2.0f * height * delta);
         }
      }

      wiiu->vp.x      = x;
      wiiu->vp.y      = y;
      wiiu->vp.width  = width;
      wiiu->vp.height = height;
   }
   else
   {
      wiiu->vp.x = wiiu->vp.y = 0;
      wiiu->vp.width = width;
      wiiu->vp.height = height;
   }


   float scale_w = wiiu->color_buffer.surface.width / 854.0;
   float scale_h = wiiu->color_buffer.surface.height / 480.0;
   wiiu_set_position(wiiu->position, &wiiu->color_buffer,
                     wiiu->vp.x * scale_w,
                     wiiu->vp.y * scale_h,
                    (wiiu->vp.x + wiiu->vp.width) * scale_w,
                    (wiiu->vp.y + wiiu->vp.height) * scale_h);

   wiiu->should_resize = false;
   DEBUG_LINE();

}
コード例 #13
0
 void store( common::connection_iface *c )
 {
     DEBUG_LINE(c);
     store( c->shared_from_this( ) );
 }
コード例 #14
0
ファイル: camera.c プロジェクト: jsharf/NATCAR2015
void camera_init()
{
	Serial_puts(UART_DEBUG_MODULE, "inside \"camera_init\"\r\n", 100);
	// Calculate the PWM clock frequency
	camera_PWMClockFreq = SysCtlClockGet() / CAMERA_CLOCK_DIV;

	DEBUG_LINE("camera_init");

	// Enable the PWM peripheral
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	// Enable the GPIO port
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	// Configure PD0 as the PWM output for the drive motor
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
	GPIOPinConfigure(GPIO_PB7_M0PWM1);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);
	GPIOPinConfigure(GPIO_PB4_M0PWM2);

	// Set the camera clock pulse period
	PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, CAMERA_SAMPLE_PERIOD - 1);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, (CAMERA_SAMPLE_PERIOD / 2) - 1);

	// Set the camera enable pulse period
	PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, (CAMERA_SAMPLE_PERIOD * CAMERA_SAMPLES) - 1);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, ((CAMERA_SAMPLE_PERIOD / 2) * 2) - 1);

	DEBUG_LINE("camera_init");

	// Enable the PWM output
	PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT | PWM_OUT_2_BIT, true);
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);

	PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT | PWM_GEN_1_BIT);

	// Enable PWM trigger on zero count on Generator 0
	PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_TR_CNT_ZERO); // PWM_TR_CNT_ZERO/PWM_TR_CNT_LOAD

	// Trigger an interrupt on GEN1 load (to setup the uDMA transfer on a consistent time boundary)
	PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_1, PWM_INT_CNT_LOAD);

	DEBUG_LINE("camera_init");
	
    /********************************************
	 * 			  ADC CONFIGURATION			    *
	 ********************************************
	 */

	// Enable ADC0 module
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

	DEBUG_LINE("camera_init");

	ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);

	DEBUG_LINE("camera_init");

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    // Camera Far
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
    // Camera Near
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);

	DEBUG_LINE("camera_init");

	// Configure and enable the ADC sequence; single sample
	ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PWM0, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
	ADCSequenceEnable(ADC0_BASE, 3);

	DEBUG_LINE("camera_init");

	ADCSequenceDMAEnable(ADC0_BASE, 3);

	DEBUG_LINE("camera_init");

	// Start writing into the first buffer
	camera_DBSelected = 0;
    current_Camera = FAR;
	// Expose the other buffer
	camera_buffer = camera_DoubleBuffer[1];

	/********************************************
	 * 			  uDMA CONFIGURATION			*
	 ********************************************
	 */

	// Enable the uDMA for normal and sleep operation
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA);
	uDMAEnable();

	DEBUG_LINE("camera_init");

	// Set the position of the uDMA control table
	uDMAControlBaseSet(uDMAControlTable);

	// Put the uDMA table entry for ADC3 into a known state
	uDMAChannelAttributeDisable(UDMA_CHANNEL_ADC3,
		UDMA_ATTR_USEBURST |
		UDMA_ATTR_ALTSELECT |
		UDMA_ATTR_HIGH_PRIORITY |
		UDMA_ATTR_REQMASK);

	// Configure the primary and alternate uDMA channel structures
	uDMAChannelControlSet(UDMA_CHANNEL_ADC3 | UDMA_PRI_SELECT, UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 | UDMA_ARB_1);
	uDMAChannelControlSet(UDMA_CHANNEL_ADC3 | UDMA_ALT_SELECT, UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 | UDMA_ARB_1);

	// Configure the primary and alternate transfers for ping-pong operation
	uDMAChannelTransferSet(UDMA_CHANNEL_ADC3 | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void*) (ADC0_BASE + ADC_O_SSFIFO3), camera_DoubleBuffer[0], CAMERA_SAMPLES);
	uDMAChannelTransferSet(UDMA_CHANNEL_ADC3 | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void*) (ADC0_BASE + ADC_O_SSFIFO3), camera_DoubleBuffer[1], CAMERA_SAMPLES);

	DEBUG_LINE("camera_init");

	// Enable the ADC3 uDMA channel
	uDMAChannelEnable(UDMA_CHANNEL_ADC3);

	// Enable interrupts
	// IntEnable(INT_ADC0SS3);
	// ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS3);

	IntEnable(INT_PWM0_1);
	PWMIntEnable(PWM0_BASE, PWM_INT_GEN_1);


	DEBUG_LINE("camera_init");

}
コード例 #15
0
ファイル: tar-node.c プロジェクト: ncbi/sra-tools
static
rc_t TarNode_MakeFileList(const KXMLNode* xml_node, const TarFileList** files, char* errmsg, const char* rel_path, const char* name)
{
    rc_t rc = 0;
    time_t now = time(NULL);
    uint32_t count = 0;

    *files = NULL;
    if( (rc = KXMLNodeCountChildNodes(xml_node, &count)) == 0 ) {
        if( count == 0 ) {
            rc = RC(rcExe, rcDoc, rcValidating, rcData, rcEmpty);
        } else if( (rc = TarFileList_Make(files, count, name)) == 0 ) {
            uint32_t i = 0;
            while(rc == 0 && i < count) {
                const KXMLNode* n = NULL;
                const char* n_name;
                if( (rc = KXMLNodeGetNodeRead(xml_node, &n, i++)) == 0 && (rc = KXMLNodeElementName(n, &n_name)) == 0 ) {
                    if( strcmp(n_name, "Item") != 0 ) {
                        rc = RC(rcExe, rcDoc, rcValidating, rcNode, rcUnexpected);
                        strcpy(errmsg, n_name);
                    } else {
                        size_t sz_read;
                        char path[4096], name[4096];
                        KTime_t ts = now;
                        uint64_t fsz = 0;
                        bool exec = false;

                        if( (rc = KXMLNodeReadAttrCString(n, "path", name, sizeof(name), &sz_read)) == 0 ) {
                            if( name[0] == '\0' ) {
                                rc = RC(rcExe, rcDoc, rcValidating, rcAttr, rcEmpty);
                            } else if( name[0] == '/' ) {
                                memmove(path, name, sz_read + 1);
                            } else {
                                KDirectory* dir = NULL;
                                if( (rc = KDirectoryNativeDir(&dir)) == 0 &&
                                    (rc = KDirectoryResolvePath(dir, true, path, sizeof(path), "%s/%s", rel_path, name)) == 0 ) {
                                    DEBUG_LINE(8, "%s/%s resolved to %s", rel_path, name, path);
                                }
                                KDirectoryRelease(dir);
                            }
                            if( rc != 0 ) {
                                strcpy(errmsg, "TAR/Item/@path");
                            }
                        }
                        if( rc == 0 && (rc = XML_ParseTimestamp(n, "timestamp", &ts, true)) != 0 ) {
                            strcpy(errmsg, "TAR/Item/@timestamp");
                        }
                        if( rc == 0 && (rc = XML_ParseBool(n, "executable", &exec, true)) != 0 ) {
                            strcpy(errmsg, "TAR/Item/@executable");
                        }
                        if( rc == 0 && (rc = KXMLNodeReadAttrAsU64(n, "size", &fsz)) != 0 ) {
                            strcpy(errmsg, "TAR/Item/@size");
                        }
                        if( rc == 0 ) {
                            name[0] = '\0';
                            rc = KXMLNodeReadAttrCString(n, "name", name, sizeof(name), &sz_read);
                            if( (GetRCObject(rc) == (enum RCObject)rcAttr && GetRCState(rc) == rcNotFound) || name[0] == '\0' ) {
                                char* x = strrchr(path, '/');
                                strcpy(name, x ? x + 1 : path);
                                rc = 0;
                            } else if( rc == 0 && name[0] == '/' ) {
                                strcat(errmsg, "Item/@name cannot be absolute");
                                rc = RC(rcExe, rcDoc, rcValidating, rcName, rcInvalid);
                            } else if( rc != 0 ) {
                                strcpy(errmsg, "Item/@name");
                            }
                        }
                        if( rc == 0 ) {
                            const KNamelist* attr = NULL;
                            if( (rc = KXMLNodeListAttr(n, &attr)) == 0 ) {
                                uint32_t j = 0, count = 0;
                                if( (rc = KNamelistCount(attr, &count)) == 0 && count > 0 ) {
                                    while( rc == 0 && j < count ) {
                                        const char *attr_nm = NULL;
                                        if( (rc = KNamelistGet(attr, j++, &attr_nm)) != 0 ) {
                                            break;
                                        }
                                        if( strcmp("path", attr_nm) == 0 || strcmp("name", attr_nm) == 0 ||
                                            strcmp("timestamp", attr_nm) == 0 || strcmp("size", attr_nm) == 0 ||
                                            strcmp("executable", attr_nm) == 0 ) {
                                            continue;
                                        }
                                        rc = RC(rcExe, rcDoc, rcValidating, rcDirEntry, rcInvalid);
                                        strcpy(errmsg, "unknown attribute TAR/Item/@");
                                        strcat(errmsg, attr_nm);
                                    }
                                }
                                ReleaseComplain(KNamelistRelease, attr);
                            }
                        }
                        if( rc == 0 && (rc = TarFileList_Add(*files, path, name, fsz, ts, exec)) != 0 ) {
                            strcpy(errmsg, "adding to TAR");
                        }
                    }
                    ReleaseComplain(KXMLNodeRelease, n);
                }
            }
            if( rc != 0 ) {
                TarFileList_Release(*files);
                *files = NULL;
            }
        }
    }
    return rc;
}
コード例 #16
0
/** ******************************************************************
  * @brief  Programs a byte array to a specified address.
  *
  * @note   This function must be used when the device voltage range is from
  *         2.7V to 3.6V and an External Vpp is present.
  *
  * @param  Address specifies the address to be programmed.
  * @param  Data specifies the data to be programmed.
  * @param  length the number of bytes to be programmed
  *
  * @retval HW_NVM_OK Flash written succesfully
  * @retval HW_NVM_FLASH_NOT_RDY Flash was no ready for writing at start
  * @retval HW_NVM_FLASH_ERASE_FAILED Something went wrong while/after erasing flash
  * @retval HW_NVM_FLASH_WRITE_FAILED Something went wrong while/after writing to flash
 ******************************************************************* */
hw_nvm_ret_t hw_STM32F0_FLASH_WriteBlock(intptr_t Address, uint8_t *Data, uint32_t length)
{
  hw_nvm_ret_t result = HW_NVM_OK;
  uint32_t i;

  DEBUG_LINE("hwFlash :: waiting for flash..");

  /* Wait for last operation to be completed */
  if( FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT) != FLASH_COMPLETE)
  {
    result = HW_NVM_FLASH_NOT_RDY;
  }

  DEBUG_LINE("hwFlash :: unlocking flash..");

  /* Unlock the FLASH */
  FLASH_Unlock();

  DEBUG_STRING("hwFlash :: erasing page [");
  DEBUG_HEX((uint8_t *)&Address, 4);
  DEBUG_LINE("]");

  /* Erase FLASH and Wait for last operation to be completed */
  if( FLASH_ErasePage((uint32_t)Address)  != FLASH_COMPLETE )
  {
    result = HW_NVM_FLASH_ERASE_FAILED;
  }

  /* Clear all FLASH flags */
  FLASH_ClearFlag(  FLASH_FLAG_EOP    |
                    FLASH_FLAG_WRPERR |
                    FLASH_FLAG_BSY     );

  FLASH->CR |= FLASH_CR_PG;

  DEBUG_LINE("hwFlash :: writing to flash..");

  for(i=0;i<length;i+=2){
	//Copy data into flash.
	if(length-i == 1){ //if last (single) byte is to be copied
		((uint16_t *)Address)[i/2] = (uint16_t)Data[i] ;
	} else {
		((uint16_t *)Address)[i/2] = ((uint16_t *)Data)[i/2] ;
	}

    /* Wait for last operation to be completed */
    if( FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT) != FLASH_COMPLETE)
    {
      result = HW_NVM_FLASH_WRITE_FAILED;
    }
  }

  /* if the program operation is completed, disable the PG Bit */
  FLASH->CR &= (~FLASH_CR_PG);

  DEBUG_LINE("hwFlash :: locking flash..");

  /* Lock the FLASH */
  FLASH_Lock();

  /* Return the Program Status */
  return result;
}
コード例 #17
0
/**
	start a download
*/
bool CRapidDownloader::download(IDownload& download){
	DEBUG_LINE("%s",download.name.c_str());
	reloadRepos();
	return download_name(download.name,0);
}