// The DiceDriver module needs to be able to tell us what is happening. The most // important information is the request for a change of clock rate or source. // The eDDR_MSG_CLOCK_CHG is the only one we are required to handle. // The other messages are used to show the connection status on some LED's, // and those are of course application dependent. static HRESULT myDiceDriverCallBack (DICE_DRIVER_MSG_ENUM msg, DICE_DRIVER_CB_DATA * pData) { // why did the driver call us? switch (msg) { case eDDR_MSG_CLOCK_CHG: // The computer has requested a change of clock and source //SYS_TRACE1(SYSDEBUG_TRACE_GENERAL, pData->rate); myAppChangeSR(pData); break; case eDDR_MSG_ATTACH: // The computer attached itself to this device // this typically happens after the computer boots, but also after // bus resets or the first time the driver is installed // In this application we don't care //SYS_TRACE1(SYSDEBUG_TRACE_GENERAL, 0); break; case eDDR_MSG_DETACH: // The computer detached itself from this device // this typically happens when the computer shuts down // or at a bus reset. // In this application we don't care //SYS_TRACE1(SYSDEBUG_TRACE_GENERAL, 0); break; case eDDR_MSG_ENABLE: // The computer has enabled streaming //SYS_TRACE1(SYSDEBUG_TRACE_GENERAL, 0); driverAttached = true; updateStatusLEDs(); break; case eDDR_MSG_DISABLE: // The computer has disabled streaming //SYS_TRACE1(SYSDEBUG_TRACE_GENERAL, 0); driverAttached = false; updateStatusLEDs(); break; case eDDR_MSG_AC3_CHG: //AC3 flags for one of the transmitter or receiver has changed sysDebugPrintf("AC3 Enable Change\r\n"); sysDebugPrintf("Stream0: 0x%04x\r\nStream1: 0x%04x\r\n", diceDriverGetState()->RxParameters.IsocReceiver[0].AC3Enable, diceDriverGetState()->RxParameters.IsocReceiver[1].AC3Enable); break; } return NO_ERROR; }
int main(void) { initRobotBase(); setLEDs(0b111111); mSleep(1500); setLEDs(0b000000); // Set Bumpers state changed event handler: BUMPERS_setStateChangedHandler(bumpersStateChanged); powerON(); // Turn Encoders, Motor Current Sensors // ATTENTION: Automatic Motor control will not work without this! /* RP6 SAGAN GENERATED COMMANDS START */ /*{SAGAN1_COMMANDS_HERE}*/ /* RP6 SAGAN GENERATED COMMANDS STOP */ stop(); moveAtSpeed(0, 0); BUMPERS_setStateChangedHandler(BUMPERS_stateChanged_empty); setLEDs(0b000000); while (true) { statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... statusLEDs.LED5 = !statusLEDs.LED5; updateStatusLEDs(); mSleep(500); task_RP6System(); } return 0; }
/** * Here we react on any obstacle that we may hit. * If any of the bumpers detects an obstacle, we stop the motors and start * LED blink. */ void bumpersStateChanged(void) { if (bumper_left || bumper_right) { stop(); moveAtSpeed(0, 0); // stop moving! setLEDs(0b111111); updateStatusLEDs(); mSleep(500); while (true) { statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... statusLEDs.LED5 = !statusLEDs.LED5; updateStatusLEDs(); mSleep(500); task_RP6System(); } } }
// The actual callback function called by DAL static HRESULT myDalCallBack (DAL_CB_EVENT_MASK events, DAL_EVENTS * pExtEvents, uint32 data) { uint16 aesStatus; uint32 extStatus=0; //extended status to the driver DAL_STATUS dalStatus; // We want to tell the diceDriver about the locked status of the clock domain // and sample rate etc. // let's collect AES/ADAT/AVS interface lock status. // We pass this on to the driver. It is not needed for the driver/streaming operation // but it can be obtained by control panels to provide visual feedback to the user aesGetStatus (&aesStatus); if (aesStatus & AES_STAT_LOCK0) extStatus |= DD_EXT_STATUS_AES0_LOCKED; if (aesStatus & AES_STAT_LOCK1) extStatus |= DD_EXT_STATUS_AES1_LOCKED; if (aesStatus & AES_STAT_LOCK2) extStatus |= DD_EXT_STATUS_AES2_LOCKED; if (aesStatus & AES_STAT_LOCK3) extStatus |= DD_EXT_STATUS_AES3_LOCKED; //let's update the slip information if (pExtEvents->aes_events & (DAL_CB_AES0_SLIP | DAL_CB_AES0_RPT)) extStatus |= DD_EXT_STATUS_AES0_SLIP; if (pExtEvents->aes_events & (DAL_CB_AES1_SLIP | DAL_CB_AES1_RPT)) extStatus |= DD_EXT_STATUS_AES1_SLIP; if (pExtEvents->aes_events & (DAL_CB_AES2_SLIP | DAL_CB_AES2_RPT)) extStatus |= DD_EXT_STATUS_AES2_SLIP; if (pExtEvents->aes_events & (DAL_CB_AES3_SLIP | DAL_CB_AES3_RPT)) extStatus |= DD_EXT_STATUS_AES3_SLIP; //let's collect ADAT interface lock status. if (adatIsLocked()) extStatus |= DD_EXT_STATUS_ADAT_LOCKED; //let's update the slip information //if (pExtEvents->adat_events & (DAL_CB_ADAT_SLIP | DAL_CB_ADAT_RPT)) extStatus |= DD_EXT_STATUS_ADAT_SLIP; //let's collect AVS interface lock status (for debuggin purposes) if (avsRxIsLocked(AVS_PLUG_ID1)) extStatus |= DD_EXT_STATUS_ARX1_LOCKED; if (avsRxIsLocked(AVS_PLUG_ID2)) extStatus |= DD_EXT_STATUS_ARX2_LOCKED; //let's update the slip information if (pExtEvents->avs_events & (DAL_CB_AVS1_SLIP | DAL_CB_AVS1_RPT)) extStatus |= DD_EXT_STATUS_ARX1_SLIP; if (pExtEvents->avs_events & (DAL_CB_AVS2_SLIP | DAL_CB_AVS2_RPT)) extStatus |= DD_EXT_STATUS_ARX2_SLIP; // At last the most important thing, get the "dal" status and call diceDriver // The diceDriver must know when the device is unlocked and locked so it can perform // proper synchronization of streams. dalGetCurrentStatus (eDAL_INTERFACE_1, &dalStatus); diceDriverSetStatus (dalStatus.state == eDAL_STATE_LOCKED, dalStatus.lockedNominalRate, dalStatus.lockedRateHz, extStatus); // And make sure the codecs gets updated, see function defined above. updateCodec(&dalStatus); // Now some application specific stuff, we do the LED's updateStatusLEDs(); return NO_ERROR; }
// updateCodec is called whenever DAL tells us that things have changed. // The function checks if any important stuff changed such as the rateMode // or the locked state. // We also handle some appliction specific LED stuff here. static void updateCodec(DAL_STATUS * pStatus) { if (((pStatus->state == eDAL_STATE_LOCKED) && !isLocked) || ((pStatus->state == eDAL_STATE_LOCKED) && (pStatus->lockedRateMode != lastLockedMode))) { //So either we became locked, or we slid into a new rate mode, in all cases //the codec/ADC/DAC should be told. //Call the codec function for the selected mode pCurrentMode->fMsg(MM_GOT_LOCK,pStatus->lockedRateMode,0); isLocked = true; lastLockedMode = pStatus->lockedRateMode; updateStatusLEDs(); } else if ((pStatus->state != eDAL_STATE_LOCKED) && isLocked) { //we just lost lock //Call the codec function for the selected mode pCurrentMode->fMsg(MM_LOST_LOCK,0,0); isLocked = false; updateStatusLEDs(); } }
HRESULT myAppSetLEDMode (bool mode) { LEDmode = mode; updateStatusLEDs(); return NO_ERROR; }