/**
* @private
* Try to verify if the char is a filtered char or not
* @return true if it was filtered (=> buffer first char will be removed), false else
*/
bool filterFirstNextChar(Buffer* inputBuffer,  filterCharFunction* inputFilterChar) {
    // read the first char (but do not pop from the FIFO)
    char deviceHeader = bufferGetCharAtIndex(inputBuffer, DEVICE_HEADER_INDEX);

    if (inputFilterChar != NULL) {
        if (!inputFilterChar(deviceHeader, &deviceHeader)) {
            // remove the char from the buffer
            bufferReadChar(inputBuffer);
            return true;
        }
    }
    return false;
}
Exemplo n.º 2
0
/**
 * Implementation of the write Function of the 24C512 chip.
 * @see eeprom.h
 * @private
 */
void _writeEeprom24C512Block (Eeprom* eeprom_, unsigned long index, unsigned int length, Buffer* buffer) {
    I2cBusConnection* i2cBusConnection = _24c512GetI2cBusConnection(eeprom_);
    I2cBus* i2cBus = i2cBusConnection->i2cBus;

    int blockAddress = get24C512BlockAddress(index);
    int address = get24C512Address(index);
    portableMasterWaitSendI2C(i2cBusConnection);
    portableMasterStartI2C(i2cBusConnection);
    WaitI2C(i2cBus);
    portableMasterWriteI2C(i2cBusConnection, blockAddress);
    WaitI2C(i2cBus);
    portableMasterWriteI2C(i2cBusConnection, address);
    WaitI2C(i2cBus);
    int i;
    for (i = 0; i <(length) ; i++) {
        char c = bufferReadChar(buffer);
        portableMasterWriteI2C(i2cBusConnection, c);
        WaitI2C(i2cBus);
    }
    portableMasterStopI2C(i2cBusConnection);
    WaitI2C(i2cBus);
}
Exemplo n.º 3
0
void printBuffer(OutputStream* outputStream, Buffer* buffer) {
	while(!isBufferEmpty(buffer)) {
        unsigned char c = bufferReadChar(buffer);
        append(outputStream, c);
    }
}
Exemplo n.º 4
0
/**
 * @private
 */
char _bufferReadChar(InputStream* inputStream) {
    Buffer* buffer = (Buffer*) inputStream->object;
    char result = bufferReadChar(buffer);
    return result;
}
/**
 * Be aware not to read before call to "availableDataFunction"
 * @private
 */
char _readCharI2C(InputStream* inputStream) {
    Buffer* buffer = _i2cMasterInputStreamGetBuffer(inputStream);
    return bufferReadChar(buffer);
}