示例#1
0
size_t UartBridge::write(byte value) {
  /*
  
    Write byte to UART.
 
   */
  while (readRegister(TXLVL) == 0) {
    // Wait for space in TX buffer
  };
  writeRegister(THR, value); 
  return 1;
}
示例#2
0
/*
 * setIWU (void) - sets the Inertial Wake-UP interrupt
 */
uint8_t MakeSureACC::setIWU(void)
{
	// clear the FF interrupt if active
	unsetIWU();
   
	// configure the different registers to 
	// handle acceleration detection on the X, Y, or Z axis
	writeRegister(CTRL_REG3,0x00);
  
	writeRegister(INT1_THS,0x10);  
	writeRegister(INT1_DURATION,0x00);  
	writeRegister(INT1_CFG,0x0A); 
	
	// attach the hardware interrupt to the pin
	enableInterrupts(ACC_INT);
	
	// IWU interruption set
	accInt=IWU_INT;

	return flag;
}
示例#3
0
void ADXL345::setRange(range_t range)
{	
	switch(range)
	{
		case RANGE_16G:
		case RANGE_8G:
		case RANGE_4G:
		case RANGE_2G:
			writeRegister(ADXL345::DATA_FORMAT, 1, (byte *)&range);
			break;
	}
}
示例#4
0
bool
LSM9DS1_G::activate(void)
{
    uint8_t data;

    data = readRegister(addr(), AG_CTRL_REG1_G);
    //data |= POWER_UP;
    data |= AG_ODR_SET;
    writeRegister(addr(), AG_CTRL_REG1_G, data);

    return true;
}
Magnetometer::Magnetometer(): I2cDevice(LSM303_ADDRESS_MAG){
	//enable magnetometer at 220hz
	writeRegister(LSM303_REGISTER_MAG_CRA_REG_M,LSM303_MAGRATE_220 << 2);

	//set to continuous conversion
	writeRegister(LSM303_REGISTER_MAG_MR_REG_M,0x00);

	//assume its all good
	//uint8_t reg1_a = readRegister(LSM303_REGISTER_ACCEL_CTRL_REG1_A);
	//DEBUGSPRINTLN((reg1_a,HEX));

	//set gain
	
	writeRegister(LSM303_REGISTER_MAG_CRB_REG_M,LSM303_MAGGAIN_1_3 << 4);

	xOffset = 0;
	yOffset = 0;
	zOffset = 0;

	ready = true;
}
示例#6
0
/*
 * set6DPosition (void) - sets the Inertial Wake-UP interrupt
 */
uint8_t MakeSureACC::set6DPosition(void)
{
	// clear the FF interrupt if active
	unset6DPosition();
   
	// configure the different registers to 
	// handle acceleration detection on the X, Y, or Z axis
	writeRegister(CTRL_REG3,0x04);
  
	writeRegister(INT1_THS,0x10);  // threshold L
	writeRegister(INT1_DURATION,0x00);  // threshold H
	writeRegister(INT1_CFG,0xFF);  // event duration

	// attach the hardware interrupt to the pin
	enableInterrupts(ACC_INT);

	// 6D Position interruption set
	accInt=_6DPOS_INT;

	return flag;
}
示例#7
0
void TICC1100::initChip()
{
	try
	{
		if(_fileDescriptor->descriptor == -1)
		{
			_out.printError("Error: Could not initialize TI CC1100. The spi device's file descriptor is not valid.");
			return;
		}
		reset();

		int32_t index = 0;
		for(std::vector<uint8_t>::const_iterator i = _config.begin(); i != _config.end(); ++i)
		{
			writeRegister((Registers::Enum)index, *i, true);
			index++;
		}
		writeRegister(Registers::Enum::FSTEST, 0x59, true);
		writeRegister(Registers::Enum::TEST2, 0x81, true); //Determined by SmartRF Studio
		writeRegister(Registers::Enum::TEST1, 0x35, true); //Determined by SmartRF Studio
		writeRegister(Registers::Enum::PATABLE, _settings->txPowerSetting, true);

		sendCommandStrobe(CommandStrobes::Enum::SFRX);
		usleep(20);

		enableRX(true);
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
示例#8
0
void TLC59116::begin() {
    if (_begun == 0) {
        Wire.begin();
        writeRegister(TLC59116_MODE1, 0x01);
        delay(1);
        writeRegister(TLC59116_MODE2, 0x00);
        writeRegister(TLC59116_LEDOUT0, 0b10101010);
        writeRegister(TLC59116_LEDOUT1, 0b10101010);
        writeRegister(TLC59116_LEDOUT2, 0b10101010);
        writeRegister(TLC59116_LEDOUT3, 0b10101010);
        this->analogWrite(0, 0);
        this->analogWrite(1, 0);
        this->analogWrite(2, 0);
        this->analogWrite(3, 0);
        this->analogWrite(4, 0);
        this->analogWrite(5, 0);
        this->analogWrite(6, 0);
        this->analogWrite(7, 0);
        this->analogWrite(8, 0);
        this->analogWrite(9, 0);
        this->analogWrite(10, 0);
        this->analogWrite(11, 0);
        this->analogWrite(12, 0);
        this->analogWrite(13, 0);
        this->analogWrite(14, 0);
        this->analogWrite(15, 0);
        setPinMapping(pinmap);
    }
    _begun = 1;
}
示例#9
0
文件: fpa11_cprt.c 项目: 274914765/C
unsigned int PerformFIX(const unsigned int opcode)
{
    FPA11 *fpa11 = GET_FPA11();
    unsigned int Fn = getFm(opcode);
    struct roundingData roundData;

    roundData.mode = SetRoundingMode(opcode);
    roundData.precision = SetRoundingPrecision(opcode);
    roundData.exception = 0;

    switch (fpa11->fType[Fn]) {
    case typeSingle:
        {
            writeRegister(getRd(opcode), float32_to_int32(&roundData, fpa11->fpreg[Fn].fSingle));
        }
        break;

    case typeDouble:
        {
            writeRegister(getRd(opcode), float64_to_int32(&roundData, fpa11->fpreg[Fn].fDouble));
        }
        break;

#ifdef CONFIG_FPE_NWFPE_XP
    case typeExtended:
        {
            writeRegister(getRd(opcode), floatx80_to_int32(&roundData, fpa11->fpreg[Fn].fExtended));
        }
        break;
#endif

    default:
        return 0;
    }

    if (roundData.exception)
        float_raise(roundData.exception);

    return 1;
}
示例#10
0
boolean SpiUartDevice::uartConnected() {
  /*
  
     Check that UART is connected and operational.
  
   */
  // Perform read/write test to check if UART is working
  const char TEST_CHARACTER = 'H';
  
  writeRegister(SPR, TEST_CHARACTER);

  return (readRegister(SPR) == TEST_CHARACTER);
}
示例#11
0
void DW1000::sendFrame(uint8_t* message, uint16_t length) {
    if (length >= 125) length = 125;                                // check for maximim length a frame can have with 127 Byte frames
    writeRegister(DW1000_TX_BUFFER, 0, message, length);            // fill buffer

    uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame
    length += 2;                                                    // including 2 CRC Bytes
    length = ((backup & 0xFC) << 8) | (length & 0x03FF);
    writeRegister16(DW1000_TX_FCTRL, 0, length);

    stopTRX();                                                      // stop receiving
    writeRegister8(DW1000_SYS_CTRL, 0, 0x02);                       // trigger sending process by setting the TXSTRT bit
    startRX();                                                      // enable receiver again
}
示例#12
0
static PDDebugState update(void* userData, PDAction action, PDReader* reader, PDWriter* writer)
{
    PluginData* plugin = (PluginData*)userData;

    plugin->hasUpdatedRegistes = false;
    plugin->hasUpdatedExceptionLocation = false;

    onAction(plugin, action);

    processEvents(plugin, reader, writer);

	updateEvents(plugin, writer);

    if (plugin->hasUpdatedRegistes)
    {
        PDWrite_eventBegin(writer, PDEventType_setRegisters);
        PDWrite_arrayBegin(writer, "registers");

        writeStatusRegister(writer, "flags", plugin->regs.flags);
        writeRegister(writer, "pc", 2, plugin->regs.pc, 1);
        writeRegister(writer, "sp", 1, plugin->regs.sp, 0);
        writeRegister(writer, "a", 1, plugin->regs.a, 0);
        writeRegister(writer, "x", 1, plugin->regs.x, 0);
        writeRegister(writer, "y", 1, plugin->regs.y, 0);

        PDWrite_arrayEnd(writer);
        PDWrite_eventEnd(writer);
    }

    if (plugin->hasUpdatedExceptionLocation)
    {
        PDWrite_eventBegin(writer, PDEventType_setExceptionLocation);
        PDWrite_u64(writer, "address", plugin->regs.pc);
        PDWrite_u8(writer, "address_size", 2);
        PDWrite_eventEnd(writer);
    }

    return plugin->state;
}
示例#13
0
void PTApplicationCardPlugin::setSPIClock(unsigned short pCLKData,SPI_SELECT peSPISelect)
{
    unsigned short l_nSPICLKArray[6] =
    {
        PT_APPCARD_MODULES::PT_SPI1_APPCARD_SCLKDIV,
        PT_APPCARD_MODULES::PT_SPI2_APPCARD_SCLKDIV,
        PT_APPCARD_MODULES::PT_SPI3_APPCARD_SCLKDIV,
        PT_APPCARD_MODULES::PT_SPI4_APPCARD_SCLKDIV,
        PT_APPCARD_MODULES::PT_SPI5_APPCARD_SCLKDIV,
        PT_APPCARD_MODULES::PT_SPI6_APPCARD_SCLKDIV
    };
	writeRegister(pCLKData,l_nSPICLKArray[peSPISelect-1]);
}
示例#14
0
void PTApplicationCardPlugin::setDSOReceiveFIFOConfiguration(DSO_RECEIVE_FIFO pSelFIFO,bool pADC1Rst,bool pADC1ClkDivRst,bool pFIFORst)
{
	unsigned short l_nReceFIFO[2]= {PT_APPCARD_MODULES::PT_DSOR1FIFO_CFG,
	                                PT_APPCARD_MODULES::PT_DSOR2FIFO_CFG};
	unsigned short l_nData=0;
	if(pADC1Rst == true)
		l_nData = 1;
	if(pADC1ClkDivRst==true)
		l_nData |= 2;
	if(pFIFORst == true)
		l_nData |=4;
	writeRegister(l_nData,l_nReceFIFO[pSelFIFO-1]);
}
示例#15
0
void PTApplicationCardPlugin::setSPITXMSW(unsigned short pMSWData, SPI_SELECT peSPISelect)
{
    unsigned short l_nTXARRAY[6]= {PT_APPCARD_MODULES::PT_SPI1_APPCARD_TXR_MSW,
                                   PT_APPCARD_MODULES::PT_SPI2_APPCARD_TXR_MSW,
                                   PT_APPCARD_MODULES::PT_SPI3_APPCARD_TXR_MSW,
                                   PT_APPCARD_MODULES::PT_SPI4_APPCARD_TXR_MSW,
                                   PT_APPCARD_MODULES::PT_SPI5_APPCARD_TXR_MSW,
                                   PT_APPCARD_MODULES::PT_SPI6_APPCARD_TXR_MSW,
                               };
//    qDebug()<<"SPITXMSW"<<"\tData:"<<hex<<pMSWData<<"\tAddress:"<<hex<<l_nTXARRAY[peSPISelect-1];
    writeRegister(pMSWData,l_nTXARRAY[peSPISelect-1]);

}
示例#16
0
uint8_t nrf24l01p::setPower(uint8_t power) {
 uint8_t nrf_power = 0;
    switch(power) {
        case PWRLOW: nrf_power = 0; break;
        case PWRMEDIUM:   nrf_power = 1; break;
        case PWRHIGH:  nrf_power = 2; break;
        case PWRMAX: nrf_power = 3; break;
        default:            nrf_power = 0; break;
    };
    // Power is in range 0..3 for nRF24L01
    rf_setup = (rf_setup & 0xF9) | ((nrf_power & 0x03) << 1);
    return writeRegister(RF_SETUP, rf_setup);
}
示例#17
0
void Adafruit_ADS1015::startComparator_SingleEnded(uint8_t channel, int16_t threshold)
{
  uint16_t value;

  // Start with default values
  uint16_t config = ADS1015_REG_CONFIG_CQUE_1CONV   | // Comparator enabled and asserts on 1 match
                    ADS1015_REG_CONFIG_CLAT_LATCH   | // Latching mode
                    ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low   (default val)
                    ADS1015_REG_CONFIG_CMODE_TRAD   | // Traditional comparator (default val)
                    ADS1015_REG_CONFIG_DR_1600SPS   | // 1600 samples per second (default)
                    ADS1015_REG_CONFIG_MODE_CONTIN  | // Continuous conversion mode
                    ADS1015_REG_CONFIG_PGA_6_144V   | // +/- 6.144V range (limited to VDD +0.3V max!)
                    ADS1015_REG_CONFIG_MODE_CONTIN;   // Continuous conversion mode

  // Set single-ended input channel
  switch (channel)
  {
    case (0):
      config |= ADS1015_REG_CONFIG_MUX_SINGLE_0;
      break;
    case (1):
      config |= ADS1015_REG_CONFIG_MUX_SINGLE_1;
      break;
    case (2):
      config |= ADS1015_REG_CONFIG_MUX_SINGLE_2;
      break;
    case (3):
      config |= ADS1015_REG_CONFIG_MUX_SINGLE_3;
      break;
  }

  // Set the high threshold register
  // Shift 12-bit results left 4 bits for the ADS1015
  writeRegister(m_i2cAddress, ADS1015_REG_POINTER_HITHRESH, threshold << m_bitShift);

  // Write config register to the ADC
  writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config);
}
示例#18
0
/*
 * setFF (void) - sets the Free Fall interrupt
 */
uint8_t WaspACC::setFF(void)
{
	// reboot ACC in order to clean the ACC Interruption 
	// pin in the it has been locked to '1'
	boot();
	delay(100);

	// clear the FF interrupt if active
	unsetFF();
   
	// configure the different registers to 
	// handle acceleration detection on the X, Y, or Z axis
				
	// set latch interrupt request: when an interrupt condition is applied,
	// the interrupt signal remains high even if the condition returns to a 
	// non-interrupt status, until a reading of the INTx_SRC register is performed.
	writeRegister(CTRL_REG2,0x00);
	writeRegister(CTRL_REG3,0x04);		
  
	// set Free-Fall threshold. Beware of the full scale selection!
	uint8_t val=INT1_THS_val*2/fsSelection;
	writeRegister(INT1_THS, val); 		
	 
	// set minimum event duration	
	writeRegister(INT1_DURATION, INT1_DURATION_val);	 
	
	// set interrupt configuration	
	writeRegister(INT1_CFG, INT1_CFG_val); 
    
    // Free-Fall interruption set
	accInt=FF_INT;	
	
    delay(100);
	// attach the hardware interrupt to the pin
	enableInterrupts(ACC_INT);

	return flag;
}
示例#19
0
unsigned int PerformSTF(const unsigned int opcode)
{
	unsigned int __user *pBase, *pAddress, *pFinal;
	unsigned int nRc = 1, write_back = WRITE_BACK(opcode);
	struct roundingData roundData;

	roundData.mode = SetRoundingMode(opcode);
	roundData.precision = SetRoundingPrecision(opcode);
	roundData.exception = 0;

	pBase = (unsigned int __user *) readRegister(getRn(opcode));
	if (REG_PC == getRn(opcode)) {
		pBase += 2;
		write_back = 0;
	}

	pFinal = pBase;
	if (BIT_UP_SET(opcode))
		pFinal += getOffset(opcode);
	else
		pFinal -= getOffset(opcode);

	if (PREINDEXED(opcode))
		pAddress = pFinal;
	else
		pAddress = pBase;

	switch (opcode & MASK_TRANSFER_LENGTH) {
	case TRANSFER_SINGLE:
		storeSingle(&roundData, getFd(opcode), pAddress);
		break;
	case TRANSFER_DOUBLE:
		storeDouble(&roundData, getFd(opcode), pAddress);
		break;
#ifdef CONFIG_FPE_NWFPE_XP
	case TRANSFER_EXTENDED:
		storeExtended(getFd(opcode), pAddress);
		break;
#endif
	default:
		nRc = 0;
	}

	if (roundData.exception)
		float_raise(roundData.exception);

	if (write_back)
		writeRegister(getRn(opcode), (unsigned long) pFinal);
	return nRc;
}
示例#20
0
// reset for vs10xx
void VS10XX::reset()
{
  putInReset();
  delay(100);//it is a must
  /* Send dummy SPI byte to initialize atmel SPI */
  ////SPIPutCharWithoutWaiting(0xFF);  
  deselectControlBus();
  deselectDataBus();
  releaseFromReset();
  while (!readDREQ());
  /* Set clock register, doubler etc. */
  writeRegister(SPI_CLOCKF, 0xc0, 0x00); 
  /* Wait for DREQ */
  while (!readDREQ());
  softReset();//comment this, as it will be executed everytime playing a music file.

  writeRegister(SPI_WRAMADDR, 0xc0, 0x13);
  
  /* Switch on the analog parts */
  setVolume(40,40);
  //setVolume(0xff,0xff);
  //SPISetFastClock();
}
示例#21
0
RGBC ColorSensor::read() {
  RGBC color = RGBC();

  writeRegister(CTRL, 0x01);
  while (readRegister(CTRL) != 0)
    ;

  color.red = readRegisterLong(DATA_RED_LO);
  color.green = readRegisterLong(DATA_GREEN_LO);
  color.blue = readRegisterLong(DATA_BLUE_LO);
  color.clear = readRegisterLong(DATA_CLEAR_LO);

  return color;
}
示例#22
0
/////////////////////////////////////
//    Method:   Setup to receive continuously
//////////////////////////////////////
void startReceiving(int Channel)
{
	// writeRegister(Channel, REG_MODEM_CONFIG, Config.LoRaDevices[Channel].ImplicitOrExplicit | Config.LoRaDevices[Channel].ErrorCoding | Config.LoRaDevices[Channel].Bandwidth);
	// writeRegister(Channel, REG_MODEM_CONFIG2, Config.LoRaDevices[Channel].SpreadingFactor | CRC_ON);
	// writeRegister(Channel, REG_MODEM_CONFIG3, 0x04 | Config.LoRaDevices[Channel].LowDataRateOptimize);									// 0x04: AGC sets LNA gain
	// writeRegister(Channel, REG_DETECT_OPT, (readRegister(Channel, REG_DETECT_OPT) & 0xF8) | ((Config.LoRaDevices[Channel].SpreadingFactor == SPREADING_6) ? 0x05 : 0x03));	// 0x05 For SF6; 0x03 otherwise
	// writeRegister(Channel, REG_DETECTION_THRESHOLD, (Config.LoRaDevices[Channel].SpreadingFactor == SPREADING_6) ? 0x0C : 0x0A);		// 0x0C for SF6, 0x0A otherwise

	// writeRegister(Channel, REG_PAYLOAD_LENGTH, Config.LoRaDevices[Channel].PayloadLength);
	// writeRegister(Channel, REG_RX_NB_BYTES, Config.LoRaDevices[Channel].PayloadLength);
	
	writeRegister(Channel, REG_PAYLOAD_LENGTH, 255);
	writeRegister(Channel, REG_RX_NB_BYTES, 255);

	// writeRegister(Channel, REG_HOP_PERIOD,0xFF);
	
	// writeRegister(Channel, REG_FIFO_ADDR_PTR, readRegister(Channel, REG_FIFO_RX_BASE_AD));   
	writeRegister(Channel, REG_FIFO_RX_BASE_AD, 0);
	writeRegister(Channel, REG_FIFO_ADDR_PTR, 0);
  
	// Setup Receive Continous Mode
	setMode(Channel, RF96_MODE_RX_CONTINUOUS); 
}
示例#23
0
//[[--------------------------------------- Receive Relays -----------------------------------------------
void PTApplicationCardPlugin::setReceiversConfiguration(RECEIVER_CONF peReceConf, R1CR pSTReceiver1)
{
    unsigned short l_nR1CR =0;
    if(pSTReceiver1.m_bHSHA == true)
        l_nR1CR = 1;
    if(pSTReceiver1.m_bHAAC == true)
        l_nR1CR|= 1 << 1;
    if(pSTReceiver1.m_bRMSIN == true)
        l_nR1CR|= 1 << 2;
    if(pSTReceiver1.m_bRMSGAIN == true)
        l_nR1CR|= 1 << 3;
    if(pSTReceiver1.m_bRMSAVG == true)
        l_nR1CR|= 1 << 4;
    if(pSTReceiver1.m_bHAIPR1_ICMSELR2 == true) // ICM Selection for Receiver 2
        l_nR1CR|= 1 << 5;
    if(pSTReceiver1.m_bHSVI == true)
        l_nR1CR|= 1 << 6;
    l_nR1CR|= pSTReceiver1.m_eCoupling << 7;
    if(peReceConf == RECEIVER1)
        writeRegister(l_nR1CR,PT_APPCARD_MODULES::PT_RECERLY_APPCARD_R1CR);
    if(peReceConf == RECEIVER2)
        writeRegister(l_nR1CR,PT_APPCARD_MODULES::PT_RECERLY_APPCARD_R2CR);
}
示例#24
0
void PTApplicationCardPlugin::setSPI1CommandWord(SPI1_CONFIGURATION m_stSPI1)
{
    unsigned short l_nSPI1CW=0;
    l_nSPI1CW = m_stSPI1.m_eCSSEL;
    l_nSPI1CW |= (m_stSPI1.m_eCSEN) << 5;
    if(m_stSPI1.m_bLDAC_AD5318 == true)
        l_nSPI1CW |= (1) << 4;
    if(m_stSPI1.m_bCD == true)
        l_nSPI1CW |= (1) << 3;
    l_nSPI1CW |= m_stSPI1.m_eMode << 1;
    if(m_stSPI1.m_bSD == true)
        l_nSPI1CW |= 1;
    writeRegister(l_nSPI1CW,PT_APPCARD_MODULES::PT_SPI1_APPCARD_CR);
}
示例#25
0
void PTApplicationCardPlugin::setDDSConfiguration1(DDSR1CONFIG pObjR1Configuration)
{
    unsigned short l_nDDRR1Configuration=0;
    if(pObjR1Configuration.m_bSINEorCOSINE == false)
        l_nDDRR1Configuration |= (1<<3);
    if(pObjR1Configuration.m_bBaseClockorMSBRAM == false)
        l_nDDRR1Configuration |= (1<<2);
    if(pObjR1Configuration.m_bPTWRAMorREG == false)
        l_nDDRR1Configuration |= (1<<1);
    if(pObjR1Configuration.m_bFTWRAMorREG== false)
        l_nDDRR1Configuration |= 1;

    writeRegister(l_nDDRR1Configuration,PT_APPCARD_MODULES::PT_DDS_APPCARD_CFG1R);
}
示例#26
0
void config_rf(){
	// Sets the important registers in the MiRF module and powers the module
	// in receiving mode
	// NB: channel and payload must be set now.

	/* set tranceiver address */
	setRADDR((uint8_t*)"robot");

	//uint8_t result = 0x07;
	uint8_t result = 0x27;
	writeRegister(RF_SETUP,&result,1);//1mbps

	// Set RF channel
	writeRegister(RF_CH,&channel,1);

	// Set length of incoming payload
	writeRegister(RX_PW_P0, &payload,1);
	writeRegister(RX_PW_P1, &payload,1);

	// Start receiver
	powerUpRx();
	flushRx();
}
示例#27
0
void UartBridge::configureCommunication(byte databit, byte stopbit, boolean parity) {
  /*
  
     Configure the settings of the UART.
  
   */
  // TODO: Improve with use of constants and calculations.
//  setBaudRate(baudrate);

	byte bits = 0; // same with the default
	bits |= LCR_WORD_LENGTH_BITS & (databit - 5);
	if ( stopbit != 1 ) {
		bits |= LCR_NUMBER_OF_STOP_BITS;
	}
	if ( parity ) {
		bits |= LCR_SET_PARITY | LCR_PARITY_TYPE_SELECT | LCR_PARITY_ENABLE;
	}
	writeRegister(LCR, bits);
	writeRegister(EFR, EFR_ENABLE_ENHANCED_FUNCTIONS); // enable enhanced registers
	writeRegister(FCR, FCR_TXFIFO_RESET | FCR_RXFIFO_RESET); // reset TXFIFO, reset RXFIFO
	// wait two clock
	writeRegister(FCR, FCR_FIFO_ENABLE); // enable FIFO mode
}
示例#28
0
void QRF24::startWrite( const void* buf, quint8 len )
{
    // Transmitter power-up
    writeRegister(CONFIG, ( readRegister(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) );
    delayMicroseconds(150);

    // Send the payload
    writePayload( buf, len );

    // Allons!
    bcm2835_gpio_write(ce_pin, HIGH);
    delayMicroseconds(15);
    bcm2835_gpio_write(ce_pin, LOW);
}
//configure
Gyroscope::Gyroscope(): I2cDevice(L2GD20H_ADDRESS){
	//check if device is correct
	uint8_t who = readRegister(GYRO_REGISTER_WHO_AM_I);
	if(who != 0xd7){
		DEBUGSPRINTLN("expecting gyroscope! invalid device");
		DEBUGSPRINTLN((who,HEX));
		ready = false;
		return;
	}

	//clear and set config reg 1
	writeRegister(GYRO_REGISTER_CTRL_REG1,0x00);
	writeRegister(GYRO_REGISTER_CTRL_REG1,0xef);

	//set config reg 4, default 245 dps
	maxAngularVelocity = DPS500;
	writeRegister(GYRO_REGISTER_CTRL_REG4,maxAngularVelocity);

	x=0;y=0;z=0;
	xOffset=0;yOffset=0;zOffset=0;

	ready = true;
}
uint16_t RFduinoProXShield::analogRead(uint8_t pin){
	if (pin > 15) {
	  pin = 15;
	}
	uint8_t gpio;

	// read the GPIOA output latches and reset the lower 4 MUX address bits
	gpio = readRegister(MCP23017_OLATA) & 0xF0;

	// write the new GPIO value with the MUX address bits OR'd in
	writeRegister(MCP23017_GPIOA,gpio|pin);

  	return ::analogRead(GPIO_MUX_COMMON);
}