void sendEeprom( uint16_t address ) { uint8_t data[34] ; uint8_t count ; data[0] = address ; data[1] = address >> 8 ; eeprom_read_block( &data[2], (const void*)address, 32 ) ; count = fillTxBuffer( data, 0x81, 34 ) ; startTx( count ) ; }
void sendControls() { uint8_t count ; uint16_t analog ; uint8_t controls[20] ; getADC_osmp() ; count = ~PINB & 0x7E ; if ( keyState( (EnumKeys)(SW_Trainer) ) ) { count |= 1 ; } controls[0] = count ; // Buttons + Trainer switch controls[1] = ~PIND ; // Trims controls[2] = getCurrentSwitchStates() ; analog = s_anaFilt[0] ; controls[3] = analog ; controls[4] = analog >> 8 ; analog = s_anaFilt[1] ; controls[5] = analog ; controls[6] = analog >> 8 ; analog = s_anaFilt[2] ; controls[7] = analog ; controls[8] = analog >> 8 ; analog = s_anaFilt[3] ; controls[9] = analog ; controls[10] = analog >> 8 ; analog = s_anaFilt[4] ; controls[11] = analog ; controls[12] = analog >> 8 ; analog = s_anaFilt[5] ; controls[13] = analog ; controls[14] = analog >> 8 ; analog = s_anaFilt[6] ; controls[15] = analog ; controls[16] = analog >> 8 ; analog = s_anaFilt[7] ; controls[17] = analog ; controls[18] = analog >> 8 ; count = fillTxBuffer( controls, 0x80, 19 ) ; startTx( count ) ; }
// the loop function runs over and over again forever void checkM64() { uint8_t count ; // int16_t byte ; poll_mega64() ; if ( M64SetContrast ) { if ( TxBusy == 0 ) { uint8_t buf[2] ; buf[0] = M64Contrast ; buf[1] = 50 ; // Brightness - unused count = fillTxBuffer( buf, 0x13, 2 ) ; txPdcUsart( TxBuffer, count ) ; M64SetContrast = 0 ; } } if ( SendDisplay ) { if ( TxBusy == 0 ) { count = fillTxBuffer( M64Display, 0, 64 ) ; DisplaySequence = 0x81 ; txPdcUsart( TxBuffer, count ) ; SendDisplay = 0 ; } } // if ( ReadingEeprom == 1 ) // { // if ( StartDelay ) // { // if ( EepromAddress < 4096 ) // { // if ( TxBusy == 0 ) // { // uint8_t temp[2] ; // temp[0] = EepromAddress ; // temp[0] = EepromAddress >> 8 ; // // 0x01, 0x12, 16 bit address, 0x01 - send 32 bytes EEPROM data @ address // count = fillTxBuffer( temp, 0x12, 2 ) ; // ReadingEeprom = 2 ; // txPdcUsart( TxBuffer, count ) ; // } // } // else // { // ReadingEeprom = 0 ; // Done // } // } // } if ( DisplaySequence ) { if ( TxBusy == 0 ) { count = fillTxBuffer( &M64Display[64*(DisplaySequence & 0x0F)], DisplaySequence & 0x0F, 64 ) ; txPdcUsart( TxBuffer, count ) ; DisplaySequence += 1 ; if ( DisplaySequence > 0x8F) { DisplaySequence = 0 ; if ( ResendDisplay ) { memcpy( M64Display, DisplayBuf, sizeof(M64Display) ) ; ResendDisplay = 0 ; SendDisplay = 1 ; } } } } // while ( ( byte = get_fifo64( &mega64_fifo ) ) != -1 ) // { // processSlaveByte( byte ) ; // if (SlaveActionRequired) // { // SlaveActionRequired = 0 ; // if ( SlaveType == 0x80 ) // { // byte = SlaveTempReceiveBuffer[0] ; // Buttons = byte & 0x7E ; // Trims = SlaveTempReceiveBuffer[1] ; // Switches = SlaveTempReceiveBuffer[2] | ( ( byte & 1 ) << 8 ) ; // Analog[0] = SlaveTempReceiveBuffer[3] | ( SlaveTempReceiveBuffer[4] << 8 ) ; // Analog[1] = SlaveTempReceiveBuffer[5] | ( SlaveTempReceiveBuffer[6] << 8 ) ; // Analog[2] = SlaveTempReceiveBuffer[7] | ( SlaveTempReceiveBuffer[8] << 8 ) ; // Analog[3] = SlaveTempReceiveBuffer[9] | ( SlaveTempReceiveBuffer[10] << 8 ) ; // Analog[4] = SlaveTempReceiveBuffer[11] | ( SlaveTempReceiveBuffer[12] << 8 ) ; // Analog[5] = SlaveTempReceiveBuffer[13] | ( SlaveTempReceiveBuffer[14] << 8 ) ; // Analog[6] = SlaveTempReceiveBuffer[15] | ( SlaveTempReceiveBuffer[16] << 8 ) ; // Analog[7] = SlaveTempReceiveBuffer[17] | ( SlaveTempReceiveBuffer[18] << 8 ) ; // } // else if ( SlaveType == 0x81 ) // EEPROM data // { // uint16_t address ; // uint32_t i ; // address = SlaveTempReceiveBuffer[0] | ( SlaveTempReceiveBuffer[1] << 8 ) ; // for ( i = 2 ; i < 34 ; i += 1 ) // { // EepromImage[address++] = SlaveTempReceiveBuffer[i] ; // } // EepromAddress += 32 ; // ReadingEeprom = 1 ; // } // } // } // wdt_reset() ; }