bool I2CMasterPollingFeature::writeBytes(const uint8_t *address,const uint8_t *input,uint32_t count) const { // do the protocol up to and including the address transfer if(!prepareWrite(address)) return false; // now start transferring the data while(count--) { // send data I2C_SendData(_i2c,*input++); // test on I2C EV8 and clear it if(!checkEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED)) return false; } // send STOP condition I2C_GenerateSTOP(_i2c,ENABLE); return true; }
bool physfsFile::Write(Bit8u * data,Bit16u * size) { if ((this->flags & 0xf) == OPEN_READ) { // check if file opened in read-only mode DOS_SetError(DOSERR_ACCESS_DENIED); return false; } if (last_action==READ) prepareWrite(); last_action=WRITE; if (*size==0) { if (PHYSFS_tell(fhandle) == 0) { PHYSFS_close(PHYSFS_openWrite(pname)); return false; //LOG_MSG("Truncate %s (%s)",name,PHYSFS_getLastError()); } else { LOG_MSG("PHYSFS TODO: truncate not yet implemented (%s at %lld)",pname,PHYSFS_tell(fhandle)); return false; } } else { PHYSFS_sint64 mysize = PHYSFS_write(fhandle,data,1,(PHYSFS_uint32)*size); //LOG_MSG("Wrote %i bytes (wanted %i) at %i of %s (%s)",(int)mysize,(int)*size,(int)PHYSFS_tell(fhandle),name,PHYSFS_getLastError()); *size = (Bit16u)mysize; return true; } }