void send_packet(uint8_t byte) { uint8_t parity; parity = oparity(byte); clk(0); _delay_us(DELAY); data(0); //Start clk(1); CDDR &= ~(1 << CBIT); // Release clock CPORT |= (1 << CBIT); //Set the pull up on Clock ///////////// serout((byte & (1 << 0)) >> 0); serout((byte & (1 << 1)) >> 1); serout((byte & (1 << 2)) >> 2); serout((byte & (1 << 3)) >> 3); serout((byte & (1 << 4)) >> 4); serout((byte & (1 << 5)) >> 5); serout((byte & (1 << 6)) >> 6); serout((byte & (1 << 7)) >> 7); ///////////// serout(parity); ///////////// serout(1); //Stop DDDR &= ~(1 << DBIT); //Release the Data line DPORT |= (1 << DBIT); //Set the pull up on Data ///////////// if(serin() != ACK) send_packet(byte); // Try again if ACK has not been received return; }
bool send_packet(uint8_t byte) { /// @todo Error checking in PS/2 code uint8_t sent_retries=0; do { uint8_t parity = oparity(byte); clk(0); _delay_us(DELAY); data(0); //Start clk(1); CDDR &= ~(1 << CBIT); // Release clock CPORT |= (1 << CBIT); //Set the pull up on Clock ///////////// serout((byte & (1 << 0)) >> 0); serout((byte & (1 << 1)) >> 1); serout((byte & (1 << 2)) >> 2); serout((byte & (1 << 3)) >> 3); serout((byte & (1 << 4)) >> 4); serout((byte & (1 << 5)) >> 5); serout((byte & (1 << 6)) >> 6); serout((byte & (1 << 7)) >> 7); serout(parity); serout(1); //Stop DDDR &= ~(1 << DBIT); //Release the Data line DPORT |= (1 << DBIT); //Set the pull up on Data //if(serin() != PS2_ACK ) // send_packet(byte); // Try again if PS2_ACK has not been received sent_retries++; } while (serin() != 0 && sent_retries < 5 ); if(sent_retries >= 5) return false; return true; }
int main(void) { uint8 i; uint8 j; uint8 OutputString[10]; pausems(5000); UartSetBaudRate( B2400, PD1, PD0 ); EEAR = 0x01; i = 'C'; EEDR = i; /* Write the letter 'H' to address 0 of 511' */ asm volatile ("sbi %2, %0\n\t" "sbi %2, %1\n\t" : :"I" (EEMWE), "I" (EEWE), "I" (0x1C) ); // utoa(EEDR, OutputString, 10); /* Wait until the EEPROM write has completed */ while( (EECR & (1 << EEWE) ) == 1) {; } while(1) { EECR |= (1<<EERE); pausems(10); utoa(EEDR, OutputString, 10); serout(OutputString); } }
static void write6502(uint16_t address, uint8_t value) { if (address < RAM_SIZE) RAM[address] = value; if (address == 0xF001) { //EhBASIC simulated ASIC output serout(value); } }