Now you can download a copy of these docs so you can use them offline! Download now
DriverStationEnhancedIO.cpp
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2008. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #include "DriverStationEnhancedIO.h" 00008 #include "Synchronized.h" 00009 #include "WPIErrors.h" 00010 #include <strLib.h> 00011 00017 DriverStationEnhancedIO::DriverStationEnhancedIO() 00018 : m_inputValid (false) 00019 , m_outputValid (false) 00020 , m_configChanged (false) 00021 , m_requestEnhancedEnable (false) 00022 { 00023 bzero((char*)&m_inputData, sizeof(m_inputData)); 00024 bzero((char*)&m_outputData, sizeof(m_outputData)); 00025 m_outputData.size = sizeof(m_outputData) - 1; 00026 m_outputData.id = kOutputBlockID; 00027 // Expected to be active low, so initialize inactive. 00028 m_outputData.data.fixed_digital_out = 0x3; 00029 m_inputDataSemaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); 00030 m_outputDataSemaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); 00031 m_encoderOffsets[0] = 0; 00032 m_encoderOffsets[1] = 0; 00033 } 00034 00040 DriverStationEnhancedIO::~DriverStationEnhancedIO() 00041 { 00042 semDelete(m_outputDataSemaphore); 00043 semDelete(m_inputDataSemaphore); 00044 } 00045 00051 void DriverStationEnhancedIO::UpdateData() 00052 { 00053 INT32 retVal; 00054 { 00055 status_block_t tempOutputData; 00056 Synchronized sync(m_outputDataSemaphore); 00057 if (m_outputValid || m_configChanged || m_requestEnhancedEnable) 00058 { 00059 m_outputData.flags = kStatusValid; 00060 if (m_requestEnhancedEnable) 00061 { 00062 // Someone called one of the get config APIs, but we are not in enhanced mode. 00063 m_outputData.flags |= kForceEnhancedMode; 00064 } 00065 if (m_configChanged) 00066 { 00067 if (!m_outputValid) 00068 { 00069 // Someone called one of the set config APIs, but we are not in enhanced mode. 00070 m_outputData.flags |= kForceEnhancedMode; 00071 } 00072 m_outputData.flags |= kStatusConfigChanged; 00073 } 00074 overrideIOConfig((char*)&m_outputData, 5); 00075 } 00076 retVal = getDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5); 00077 if (retVal == 0) 00078 { 00079 if (m_outputValid) 00080 { 00081 if (m_configChanged) 00082 { 00083 // If our config change made the round trip then clear the flag. 00084 if (IsConfigEqual(tempOutputData, m_outputData)) 00085 { 00086 m_configChanged = false; 00087 } 00088 } 00089 else 00090 { 00091 // TODO: This won't work until artf1128 is fixed 00092 //if (tempOutputData.flags & kStatusConfigChanged) 00093 { 00094 // Configuration was updated on the DS, so update our local cache. 00095 MergeConfigIntoOutput(tempOutputData, m_outputData); 00096 } 00097 } 00098 } 00099 else 00100 { 00101 // Initialize the local cache. 00102 MergeConfigIntoOutput(tempOutputData, m_outputData); 00103 } 00104 m_requestEnhancedEnable = false; 00105 m_outputValid = true; 00106 } 00107 else 00108 { 00109 m_outputValid = false; 00110 m_inputValid = false; 00111 } 00112 } 00113 { 00114 Synchronized sync(m_inputDataSemaphore); 00115 control_block_t tempInputData; 00116 retVal = getDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5); 00117 if (retVal == 0 && tempInputData.data.api_version == kSupportedAPIVersion) 00118 { 00119 m_inputData = tempInputData; 00120 m_inputValid = true; 00121 } 00122 else 00123 { 00124 m_outputValid = false; 00125 m_inputValid = false; 00126 } 00127 } 00128 } 00129 00133 void DriverStationEnhancedIO::MergeConfigIntoOutput(const status_block_t &dsOutputBlock, status_block_t &localCache) 00134 { 00135 localCache.data.digital = (localCache.data.digital & dsOutputBlock.data.digital_oe) | 00136 (dsOutputBlock.data.digital & ~dsOutputBlock.data.digital_oe); 00137 localCache.data.digital_oe = dsOutputBlock.data.digital_oe; 00138 localCache.data.digital_pe = dsOutputBlock.data.digital_pe; 00139 localCache.data.pwm_period[0] = dsOutputBlock.data.pwm_period[0]; 00140 localCache.data.pwm_period[1] = dsOutputBlock.data.pwm_period[1]; 00141 localCache.data.enables = dsOutputBlock.data.enables; 00142 } 00143 00147 bool DriverStationEnhancedIO::IsConfigEqual(const status_block_t &dsOutputBlock, const status_block_t &localCache) 00148 { 00149 if (localCache.data.digital_oe != dsOutputBlock.data.digital_oe) return false; 00150 if ((localCache.data.digital & ~dsOutputBlock.data.digital) != 00151 (dsOutputBlock.data.digital & ~dsOutputBlock.data.digital)) return false; 00152 if (localCache.data.digital_pe != dsOutputBlock.data.digital_pe) return false; 00153 if (localCache.data.pwm_period[0] != dsOutputBlock.data.pwm_period[0]) return false; 00154 if (localCache.data.pwm_period[1] != dsOutputBlock.data.pwm_period[1]) return false; 00155 if (localCache.data.enables != dsOutputBlock.data.enables) return false; 00156 return true; 00157 } 00158 00165 double DriverStationEnhancedIO::GetAcceleration(tAccelChannel channel) 00166 { 00167 if (channel < 1 || channel > 2) 00168 { 00169 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); 00170 return 0.0; 00171 } 00172 if (!m_inputValid) 00173 { 00174 wpi_setWPIError(EnhancedIOMissing); 00175 return 0.0; 00176 } 00177 Synchronized sync(m_inputDataSemaphore); 00178 return (m_inputData.data.accel[channel] - kAccelOffset) / kAccelScale; 00179 } 00180 00187 double DriverStationEnhancedIO::GetAnalogIn(UINT32 channel) 00188 { 00189 // 3.3V is the analog reference voltage 00190 return GetAnalogInRatio(channel) * kAnalogInputReference; 00191 } 00192 00199 double DriverStationEnhancedIO::GetAnalogInRatio(UINT32 channel) 00200 { 00201 if (channel < 1 || channel > 8) 00202 { 00203 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); 00204 return 0.0; 00205 } 00206 if (!m_inputValid) 00207 { 00208 wpi_setWPIError(EnhancedIOMissing); 00209 return 0.0; 00210 } 00211 Synchronized sync(m_inputDataSemaphore); 00212 return m_inputData.data.analog[channel-1] / kAnalogInputResolution; 00213 } 00214 00224 double DriverStationEnhancedIO::GetAnalogOut(UINT32 channel) 00225 { 00226 if (channel < 1 || channel > 2) 00227 { 00228 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); 00229 return 0.0; 00230 } 00231 if (!m_outputValid) 00232 { 00233 wpi_setWPIError(EnhancedIOMissing); 00234 return 0.0; 00235 } 00236 00237 Synchronized sync(m_outputDataSemaphore); 00238 return m_outputData.data.dac[channel-1] * kAnalogOutputReference / kAnalogOutputResolution; 00239 } 00240 00254 void DriverStationEnhancedIO::SetAnalogOut(UINT32 channel, double value) 00255 { 00256 if (channel < 1 || channel > 2) 00257 { 00258 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); 00259 return; 00260 } 00261 if (!m_outputValid) 00262 { 00263 wpi_setWPIError(EnhancedIOMissing); 00264 return; 00265 } 00266 if (value < 0.0) value = 0.0; 00267 if (value > kAnalogOutputReference) value = kAnalogOutputReference; 00268 00269 Synchronized sync(m_outputDataSemaphore); 00270 m_outputData.data.dac[channel-1] = (UINT8)(value / kAnalogOutputReference * kAnalogOutputResolution); 00271 } 00272 00288 bool DriverStationEnhancedIO::GetButton(UINT32 channel) 00289 { 00290 if (channel < 1 || channel > 6) 00291 { 00292 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 6"); 00293 return false; 00294 } 00295 00296 return ((GetButtons() >> (channel-1)) & 1) != 0; 00297 } 00298 00304 UINT8 DriverStationEnhancedIO::GetButtons() 00305 { 00306 if (!m_inputValid) 00307 { 00308 wpi_setWPIError(EnhancedIOMissing); 00309 return 0; 00310 } 00311 Synchronized sync(m_inputDataSemaphore); 00312 return m_inputData.data.buttons; 00313 } 00314 00321 void DriverStationEnhancedIO::SetLED(UINT32 channel, bool value) 00322 { 00323 if (channel < 1 || channel > 8) 00324 { 00325 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); 00326 return; 00327 } 00328 if (!m_outputValid) 00329 { 00330 wpi_setWPIError(EnhancedIOMissing); 00331 return; 00332 } 00333 UINT8 leds; 00334 Synchronized sync(m_outputDataSemaphore); 00335 leds = m_outputData.data.leds; 00336 00337 leds &= ~(1 << (channel-1)); 00338 if (value) leds |= 1 << (channel-1); 00339 00340 m_outputData.data.leds = leds; 00341 } 00342 00348 void DriverStationEnhancedIO::SetLEDs(UINT8 value) 00349 { 00350 if (!m_outputValid) 00351 { 00352 wpi_setWPIError(EnhancedIOMissing); 00353 return; 00354 } 00355 Synchronized sync(m_outputDataSemaphore); 00356 m_outputData.data.leds = value; 00357 } 00358 00365 bool DriverStationEnhancedIO::GetDigital(UINT32 channel) 00366 { 00367 if (channel < 1 || channel > 16) 00368 { 00369 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); 00370 return false; 00371 } 00372 00373 return ((GetDigitals() >> (channel-1)) & 1) != 0; 00374 } 00375 00381 UINT16 DriverStationEnhancedIO::GetDigitals() 00382 { 00383 if (!m_inputValid) 00384 { 00385 wpi_setWPIError(EnhancedIOMissing); 00386 return 0; 00387 } 00388 Synchronized sync(m_inputDataSemaphore); 00389 return m_inputData.data.digital; 00390 } 00391 00398 void DriverStationEnhancedIO::SetDigitalOutput(UINT32 channel, bool value) 00399 { 00400 if (channel < 1 || channel > 16) 00401 { 00402 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); 00403 return; 00404 } 00405 if (!m_outputValid) 00406 { 00407 wpi_setWPIError(EnhancedIOMissing); 00408 return; 00409 } 00410 UINT16 digital; 00411 Synchronized sync(m_outputDataSemaphore); 00412 00413 if (m_outputData.data.digital_oe & (1 << (channel-1))) 00414 { 00415 digital = m_outputData.data.digital; 00416 00417 digital &= ~(1 << (channel-1)); 00418 if (value) digital |= 1 << (channel-1); 00419 00420 m_outputData.data.digital = digital; 00421 } 00422 else 00423 { 00424 wpi_setWPIError(LineNotOutput); 00425 } 00426 } 00427 00437 DriverStationEnhancedIO::tDigitalConfig DriverStationEnhancedIO::GetDigitalConfig(UINT32 channel) 00438 { 00439 if (channel < 1 || channel > 16) 00440 { 00441 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); 00442 return kUnknown; 00443 } 00444 if (!m_outputValid) 00445 { 00446 m_requestEnhancedEnable = true; 00447 wpi_setWPIError(EnhancedIOMissing); 00448 return kUnknown; 00449 } 00450 Synchronized sync(m_outputDataSemaphore); 00451 if ((channel >= 1) && (channel <= 4)) 00452 { 00453 if (m_outputData.data.pwm_enable & (1 << (channel - 1))) 00454 { 00455 return kPWM; 00456 } 00457 } 00458 if ((channel >= 15) && (channel <= 16)) 00459 { 00460 if (m_outputData.data.comparator_enable & (1 << (channel - 15))) 00461 { 00462 return kAnalogComparator; 00463 } 00464 } 00465 if (m_outputData.data.digital_oe & (1 << (channel - 1))) 00466 { 00467 return kOutput; 00468 } 00469 if (!(m_outputData.data.digital_pe & (1 << (channel - 1)))) 00470 { 00471 return kInputFloating; 00472 } 00473 if (m_outputData.data.digital & (1 << (channel - 1))) 00474 { 00475 return kInputPullUp; 00476 } 00477 else 00478 { 00479 return kInputPullDown; 00480 } 00481 } 00482 00506 void DriverStationEnhancedIO::SetDigitalConfig(UINT32 channel, tDigitalConfig config) 00507 { 00508 if (channel < 1 || channel > 16) 00509 { 00510 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); 00511 return; 00512 } 00513 if (config == kPWM && (channel < 1 || channel > 4)) 00514 { 00515 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel in PWM mode must be between 1 and 4"); 00516 return; 00517 } 00518 if (config == kAnalogComparator && (channel < 15 || channel > 16)) 00519 { 00520 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel in Analog Comparator mode must be between 15 and 16"); 00521 return; 00522 } 00523 00524 Synchronized sync(m_outputDataSemaphore); 00525 m_configChanged = true; 00526 00527 if ((channel >= 1) && (channel <= 4)) 00528 { 00529 if (config == kPWM) 00530 { 00531 m_outputData.data.pwm_enable |= 1 << (channel - 1); 00532 m_outputData.data.digital &= ~(1 << (channel - 1)); 00533 m_outputData.data.digital_oe |= 1 << (channel - 1); 00534 m_outputData.data.digital_pe &= ~(1 << (channel - 1)); 00535 return; 00536 } 00537 else 00538 { 00539 m_outputData.data.pwm_enable &= ~(1 << (channel - 1)); 00540 } 00541 } 00542 else if ((channel >= 15) && (channel <= 16)) 00543 { 00544 if (config == kAnalogComparator) 00545 { 00546 m_outputData.data.comparator_enable |= 1 << (channel - 15); 00547 m_outputData.data.digital &= ~(1 << (channel - 1)); 00548 m_outputData.data.digital_oe &= ~(1 << (channel - 1)); 00549 m_outputData.data.digital_pe &= ~(1 << (channel - 1)); 00550 return; 00551 } 00552 else 00553 { 00554 m_outputData.data.comparator_enable &= ~(1 << (channel - 15)); 00555 } 00556 } 00557 if (config == kInputFloating) 00558 { 00559 m_outputData.data.digital &= ~(1 << (channel - 1)); 00560 m_outputData.data.digital_oe &= ~(1 << (channel - 1)); 00561 m_outputData.data.digital_pe &= ~(1 << (channel - 1)); 00562 } 00563 else if (config == kInputPullUp) 00564 { 00565 m_outputData.data.digital |= 1 << (channel - 1); 00566 m_outputData.data.digital_oe &= ~(1 << (channel - 1)); 00567 m_outputData.data.digital_pe |= 1 << (channel - 1); 00568 } 00569 else if (config == kInputPullDown) 00570 { 00571 m_outputData.data.digital &= ~(1 << (channel - 1)); 00572 m_outputData.data.digital_oe &= ~(1 << (channel - 1)); 00573 m_outputData.data.digital_pe |= 1 << (channel - 1); 00574 } 00575 else if (config == kOutput) 00576 { 00577 m_outputData.data.digital_oe |= 1 << (channel - 1); 00578 m_outputData.data.digital_pe &= ~(1 << (channel - 1)); 00579 } 00580 else 00581 { 00582 // Something went wrong. 00583 } 00584 } 00585 00595 double DriverStationEnhancedIO::GetPWMPeriod(tPWMPeriodChannels channels) 00596 { 00597 if (channels < kPWMChannels1and2 || channels > kPWMChannels3and4) 00598 { 00599 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channels must be kPWMChannels1and2 or kPWMChannels3and4"); 00600 return 0.0; 00601 } 00602 if (!m_outputValid) 00603 { 00604 m_requestEnhancedEnable = true; 00605 wpi_setWPIError(EnhancedIOMissing); 00606 return 0.0; 00607 } 00608 00609 Synchronized sync(m_outputDataSemaphore); 00610 return m_outputData.data.pwm_period[channels] / 24000000.0; 00611 } 00612 00623 void DriverStationEnhancedIO::SetPWMPeriod(tPWMPeriodChannels channels, double period) 00624 { 00625 if (channels < kPWMChannels1and2 || channels > kPWMChannels3and4) 00626 { 00627 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channels must be kPWMChannels1and2 or kPWMChannels3and4"); 00628 return; 00629 } 00630 00631 // Convert to ticks based on the IO board's 24MHz clock 00632 double ticks = period * 24000000.0; 00633 // Limit the range of the ticks... warn if too big. 00634 if (ticks > 65534.0) 00635 { 00636 wpi_setWPIError(EnhancedIOPWMPeriodOutOfRange); 00637 ticks = 65534.0; 00638 } 00639 else if (ticks < 0.0) ticks = 0.0; 00640 // Preserve the duty cycles. 00641 double dutyCycles[2]; 00642 dutyCycles[0] = GetPWMOutput((channels << 1) + 1); 00643 dutyCycles[1] = GetPWMOutput((channels << 1) + 2); 00644 { 00645 Synchronized sync(m_outputDataSemaphore); 00646 // Update the period 00647 m_outputData.data.pwm_period[channels] = (UINT16)ticks; 00648 m_configChanged = true; 00649 } 00650 // Restore the duty cycles 00651 SetPWMOutput((channels << 1) + 1, dutyCycles[0]); 00652 SetPWMOutput((channels << 1) + 2, dutyCycles[1]); 00653 } 00654 00661 bool DriverStationEnhancedIO::GetFixedDigitalOutput(UINT32 channel) 00662 { 00663 if (channel < 1 || channel > 2) 00664 { 00665 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); 00666 return 0; 00667 } 00668 if (!m_outputValid) 00669 { 00670 wpi_setWPIError(EnhancedIOMissing); 00671 return 0; 00672 } 00673 00674 Synchronized sync(m_outputDataSemaphore); 00675 return ((m_outputData.data.fixed_digital_out >> (channel-1)) & 1) != 0; 00676 } 00677 00692 void DriverStationEnhancedIO::SetFixedDigitalOutput(UINT32 channel, bool value) 00693 { 00694 if (channel < 1 || channel > 2) 00695 { 00696 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); 00697 return; 00698 } 00699 if (!m_outputValid) 00700 { 00701 wpi_setWPIError(EnhancedIOMissing); 00702 return; 00703 } 00704 00705 UINT8 digital; 00706 Synchronized sync(m_outputDataSemaphore); 00707 digital = m_outputData.data.fixed_digital_out; 00708 00709 digital &= ~(1 << (channel-1)); 00710 if (value) digital |= 1 << (channel-1); 00711 00712 m_outputData.data.fixed_digital_out = digital; 00713 } 00714 00729 INT16 DriverStationEnhancedIO::GetEncoder(UINT32 encoderNumber) 00730 { 00731 if (encoderNumber < 1 || encoderNumber > 2) 00732 { 00733 wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); 00734 return 0; 00735 } 00736 if (!m_inputValid) 00737 { 00738 wpi_setWPIError(EnhancedIOMissing); 00739 return 0; 00740 } 00741 00742 Synchronized sync(m_inputDataSemaphore); 00743 return m_inputData.data.quad[encoderNumber - 1] - m_encoderOffsets[encoderNumber - 1]; 00744 } 00745 00754 void DriverStationEnhancedIO::ResetEncoder(UINT32 encoderNumber) 00755 { 00756 if (encoderNumber < 1 || encoderNumber > 2) 00757 { 00758 wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); 00759 return; 00760 } 00761 if (!m_inputValid) 00762 { 00763 wpi_setWPIError(EnhancedIOMissing); 00764 return; 00765 } 00766 00767 Synchronized sync(m_inputDataSemaphore); 00768 m_encoderOffsets[encoderNumber - 1] = m_inputData.data.quad[encoderNumber - 1]; 00769 } 00770 00780 bool DriverStationEnhancedIO::GetEncoderIndexEnable(UINT32 encoderNumber) 00781 { 00782 if (encoderNumber < 1 || encoderNumber > 2) 00783 { 00784 wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); 00785 return false; 00786 } 00787 if (!m_outputValid) 00788 { 00789 m_requestEnhancedEnable = true; 00790 wpi_setWPIError(EnhancedIOMissing); 00791 return false; 00792 } 00793 00794 Synchronized sync(m_outputDataSemaphore); 00795 return ((m_outputData.data.quad_index_enable >> (encoderNumber - 1)) & 1) != 0; 00796 } 00797 00811 void DriverStationEnhancedIO::SetEncoderIndexEnable(UINT32 encoderNumber, bool enable) 00812 { 00813 if (encoderNumber < 1 || encoderNumber > 2) 00814 { 00815 wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); 00816 return; 00817 } 00818 00819 Synchronized sync(m_outputDataSemaphore); 00820 m_outputData.data.quad_index_enable &= ~(1 << (encoderNumber - 1)); 00821 if (enable) m_outputData.data.quad_index_enable |= 1 << (encoderNumber - 1); 00822 m_configChanged = true; 00823 } 00824 00830 double DriverStationEnhancedIO::GetTouchSlider() 00831 { 00832 if (!m_inputValid) 00833 { 00834 wpi_setWPIError(EnhancedIOMissing); 00835 return 0.0; 00836 } 00837 00838 Synchronized sync(m_inputDataSemaphore); 00839 UINT8 value = m_inputData.data.capsense_slider; 00840 return value == 255 ? -1.0 : value / 254.0; 00841 } 00842 00849 double DriverStationEnhancedIO::GetPWMOutput(UINT32 channel) 00850 { 00851 if (channel < 1 || channel > 4) 00852 { 00853 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4"); 00854 return 0.0; 00855 } 00856 if (!m_outputValid) 00857 { 00858 wpi_setWPIError(EnhancedIOMissing); 00859 return 0.0; 00860 } 00861 00862 Synchronized sync(m_outputDataSemaphore); 00863 return (double)m_outputData.data.pwm_compare[channel - 1] / (double)m_outputData.data.pwm_period[(channel - 1) >> 1]; 00864 } 00865 00875 void DriverStationEnhancedIO::SetPWMOutput(UINT32 channel, double value) 00876 { 00877 if (channel < 1 || channel > 4) 00878 { 00879 wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4"); 00880 return; 00881 } 00882 if (!m_outputValid) 00883 { 00884 wpi_setWPIError(EnhancedIOMissing); 00885 return; 00886 } 00887 00888 if (value > 1.0) value = 1.0; 00889 else if (value < 0.0) value = 0.0; 00890 Synchronized sync(m_outputDataSemaphore); 00891 m_outputData.data.pwm_compare[channel - 1] = (UINT16)(value * (double)m_outputData.data.pwm_period[(channel - 1) >> 1]); 00892 } 00893 00903 UINT8 DriverStationEnhancedIO::GetFirmwareVersion() 00904 { 00905 if (!m_inputValid) 00906 { 00907 m_requestEnhancedEnable = true; 00908 wpi_setWPIError(EnhancedIOMissing); 00909 return 0; 00910 } 00911 00912 Synchronized sync(m_inputDataSemaphore); 00913 return m_inputData.data.fw_version; 00914 } 00915
Generated on Thu Jan 12 2012 22:35:19 for WPILibC++ by
1.7.1