Ejemplo n.º 1
0
/***	writeEeprom
**
**	Parameters:
**		address	- location to be written
**		data	- data to be written
**
**	Return Value:
**		Returns true if the operation was successful, false otherwise
**
**	Errors:
**		none
**
**	Description:
**		Writes a data to specified address location
*/
BOOL writeEeprom(uint32_t address, uint8_t data)
{
	int i;

	if(address > max_address) {
		return fFalse;
	}

	//Try writing data to flash
	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		if(putEeprom(&eedata_addr[i][0], address, data)) {
			return fTrue;
		}
	}
	
		//Put page to buffer
	putBuffer(tempBuffer);

	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		//Clear all the pages
		eraseFlashPage(&eedata_addr[i][0]);
	}

		//Put buffer back to page
	getBuffer(tempBuffer);

	//Try writing data to flash again
	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		if(putEeprom(&eedata_addr[i][0], address, data)) {
			return fTrue;
		}
	}

	return fFalse;
}
Ejemplo n.º 2
0
/***	writeEeprom
**
**	Parameters:
**		address	- location to be written
**		data	- data to be written
**
**	Return Value:
**		Returns true or false wether the operation was successful
**		or not.
**
**	Errors:
**		none
**
**	Description:
**		Writes a data to specifed address location
*/
BOOL writeEeprom(uint32_t address, uint8_t data)
{
	int i;

	if(address > MAX_ADDRESS) {
		return fFalse;
	}

	//Try writting data to flash
	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		if(putEeprom(&eedata_addr[i][0], address, data)) {
			return fTrue;
		}
	}
	
	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		//Put page to buffer
		putBuffer(&eedata_addr[i][0], tempBuffer);

		//Clear page
		NVMErasePage(&eedata_addr[i][0]);

		//Put buffer back to page
		getBuffer(&eedata_addr[i][0], tempBuffer);
	}

	//Try writting data to flash again
	for(i=0; i < _EEPROM_PAGE_COUNT; i++) {
		if(putEeprom(&eedata_addr[i][0], address, data)) {
			return fTrue;
		}
	}

	return fFalse;
}
Ejemplo n.º 3
0
void safeBufferPut(message_t const * const msg) {
  uint8_t osStatus;

  OSSemPend(freeSlot, 0, &osStatus);
  OSSemPend(bufMutex, 0, &osStatus);
  putBuffer(msg);
  osStatus = OSSemPost(bufMutex);
  osStatus = OSSemPost(fullSlot);
}
Ejemplo n.º 4
0
unsigned AudioStream::putMono(Linear buffer, unsigned frames)
{
    Linear iobuf = buffer, dbuf = NULL;
    unsigned offset, copied = 0;
    ssize_t len;

    if(!is_streamable())
        return 0;

    if(!frames)
        ++frames;

    if(is_stereo(info.encoding)) {
        dbuf = new Sample[info.framecount * 2];
        iobuf = dbuf;
    }

    while(frames--) {
        if(dbuf) {
            for(offset = 0; offset < info.framecount; ++offset)
                dbuf[offset * 2] = dbuf[offset * 2 + 1] = buffer[offset];
        }

        if(codec) {
            codec->encode(iobuf, framebuf, info.framecount);
            len = putBuffer(framebuf);
            if(len < (ssize_t)info.framesize)
                break;
            ++copied;
            buffer += info.framecount;
            continue;
        }
        swapEndian(info, iobuf, info.framecount);
        len = putBuffer((Encoded)iobuf);
        if(len < (ssize_t)info.framesize)
            break;
        ++copied;
        buffer += info.framecount;
    }
    if(dbuf)
        delete[] dbuf;

    return copied;
}
Ejemplo n.º 5
0
 int HWNDstreambuf::overflow(int ch) {
    putBuffer();
    if(ch != EOF) {
       if(pbase() == epptr()) {
          putChar(ch);
       } else {
          sputc(ch);
       }
    }
    return 0;
 }
Ejemplo n.º 6
0
  void run()
  {
    //logger(LOG_INFO) << "USBBulkStreamer: Running Capture" << std::endl;
    if (!usbIO->resetBulkEndPoint(endpoint))
    {
      logger(LOG_ERROR) << "USBBulkStreamer: Bulk End point reset failed" << std::endl;
      return;
    }

    while(captureRunning)
    {
      if(usbIO->bulkTransfer(endpoint, usbBuffer.data(), bufSize + BULK_XFER_EXTRA_SIZE, transferred, timeout))
      {
        if(transferred == bufSize)
        {
          validFrames++;
          retriesCount = 0;
          putBuffer();
        }
        else
        {
          droppedFrames++;
          if(droppedFrames % 100 == 0)
            logger(LOG_ERROR) << "USBBulkStreamer: Dropped frames " << droppedFrames
                              << " Valid frames " << validFrames << std::endl;
        }
      }
      else
      {
        retriesCount++;
        if(retriesCount == 3)
        {
          if (!usbIO->resetBulkEndPoint(endpoint))
          {
            logger(LOG_ERROR) << "USBBulkStreamer: Bulk End point reset failed" << std::endl;
            captureRunning = false;
          }

          logger(LOG_WARNING) << "USBBulkStreamer: Resetting bulk endpoint at " << _timer.getCurentRealTime() << std::endl;
          retriesCount = 0;
          resetCount++;
          if(resetCount % 100 == 0)
          {
            logger(LOG_ERROR) << "USBBulkStreamer: Did not get a frame in 100 attempts" << std::endl;
            captureRunning = false;
          }
        }
      }
    }
  }
Ejemplo n.º 7
0
unsigned AudioStream::putEncoded(Encoded addr, unsigned frames)
{
    unsigned count = 0;
    ssize_t len;

    if(is_linear(info.encoding))
        return putMono((Linear)addr, frames);

    while(frames--) {
        len = putBuffer(addr);
        if(len < (ssize_t)info.framesize)
            break;
        addr += info.framesize;
        ++count;
    }
    return count;
}
Ejemplo n.º 8
0
 int HWNDstreambuf::sync() {
    putBuffer();
    return 0;
 }
Ejemplo n.º 9
0
  * @param format int
  */
void GLTexture::putBuffer(float *floatArray)
{