Exemple #1
0
static void _tick_handler(void *context, event_type_t event_type, void *event_args) {
    if (_hold_for_receive) {
        _hold_for_receive--;
        if (_hold_for_receive == 0) {
            // data line to input high
            KB_DATA_PORT |= _BV(KB_DATA_BIT);
            KB_DATA_DDR &= ~_BV(KB_DATA_BIT);

            EIFR &= ~0x80; // clear int7 flags
            EICRB = (EICRB | 0x80) & ~0x40; // int7: trigger on falling edge
            EIMSK |= 0x80; // enable int7
        }
    }

    if (!_completed) {
        _ticks_since_last_comm++;
        if (_ticks_since_last_comm > _ticks_until_reset) {
            _completed = 1;
            _active = 0;

            void (*read_completion)(uint8_t result, uint8_t data) = _read_completion;
            void (*write_completion)(uint8_t result) = _write_completion;
            _read_completion = NULL;
            _write_completion = NULL;

            if (_reading && read_completion) {
                read_completion(1, 0);
            } else if (!_reading && write_completion) {
                write_completion(1);
            }
        }
    }
}
Exemple #2
0
void kb_postisr(void) {
    
    void (*read_completion)(uint8_t result, uint8_t data) = NULL;
    void (*write_completion)(uint8_t result) = NULL;

    uint8_t intr_state = SREG;
    cli();
    if (_completed && _active) {
        _active = 0;
        _ticks_since_last_comm = 0;

        // end of byte
        _count = ISR_CALLS_PER_BYTE + 1;

        if (_reading) {
            read_completion = _read_completion;
            
            _read_completion = NULL;
        } else {
            write_completion = _write_completion;

            _write_completion = NULL;
        }
    }
    SREG = intr_state;

    if (read_completion) {
        read_completion(0, _xfer_byte);
    }
    if (write_completion) {
        write_completion(0);
    }
}
Exemple #3
0
void pcr_write8(uint8_t pid, uint16_t offset, uint8_t indata)
{
	/* Ensure the PCR offset is correctly aligned. */
	check_pcr_offset_align(offset, sizeof(uint8_t));

	write8(__pcr_reg_address(pid, offset), indata);
	/* Ensure the writes complete. */
	write_completion(pid, offset);
}
Exemple #4
0
void pcr_write32(uint8_t pid, uint16_t offset, uint32_t indata)
{
	/* Ensure the PCR offset is correctly aligned. */
	assert(IS_ALIGNED(offset, sizeof(indata)));

	write32(__pcr_reg_address(pid, offset), indata);
	/* Ensure the writes complete. */
	write_completion(pid, offset);
}
void VDAgent::enqueue_chunk(VDIChunk* chunk)
{
    MUTEX_LOCK(_message_mutex);
    _message_queue.push(chunk);
    if (_message_queue.size() == 1) {
        write_completion(0, 0, &_write_overlapped);
    }
    MUTEX_UNLOCK(_message_mutex);
}