예제 #1
0
// Begin executing the specified proc.
// NOTE: place the current proc into the correct queue before calling
void SwitchToProc(PCB *next_proc, UserContext *user_context) {
    TracePrintf(TRACE_LEVEL_FUNCTION_INFO, ">>> SwitchToProc()\n");
    assert(user_context);
    assert(next_proc);

    // Save current user state
    current_proc->user_context = *user_context;

    TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc context into %p\n", user_context);
    TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc PID: %d\n", next_proc->pid);
    *user_context = next_proc->user_context;
    // Set the TLB registers for the region 1 page table.
    WriteRegister(REG_PTBR1, (unsigned int) next_proc->region_1_page_table);
    WriteRegister(REG_TLB_FLUSH, TLB_FLUSH_1);

    PCB *old_proc = current_proc;
    current_proc = next_proc;
    int rc = KernelContextSwitch(&SaveKernelContextAndSwitch, old_proc, next_proc);
    if (SUCCESS == rc) {
        TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Succesfully switched kernel context!\n");
    } else {
        TracePrintf(TRACE_LEVEL_NON_TERMINAL_PROBLEM, "Failed to save kernel context!\n");
        char *err_str = calloc(TERMINAL_MAX_LINE, sizeof(char));
        sprintf(err_str, "KernelContextSwitch failed!!! HALTING!!!\n", current_proc->pid);
        KernelTtyWriteInternal(0, err_str, strnlen(err_str, TERMINAL_MAX_LINE), user_context);
        free(err_str);
        Halt();
    }

    // Restore user state of new current process
    *user_context = current_proc->user_context;

    TracePrintf(TRACE_LEVEL_FUNCTION_INFO, "<<< SwitchToProc()\n");
}
예제 #2
0
void TurboNRF24L01::SetPayloadSize(uint8_t payload)
{
	m_Payload = payload;
	// Set length of incoming payload 
	WriteRegister(RX_PW_P0, m_Payload);
	WriteRegister(RX_PW_P1, m_Payload);
}
예제 #3
0
void LoadNextProc(UserContext *context, int block) {
    DelayPop();
    if (!queueIsEmpty(ready_queue)) {
        if (current_process)  {
            current_process->user_context = *context;
            if (block == NO_BLOCK) {
                queuePush(ready_queue, current_process);
            }
        }

        PCB *next = queuePop(ready_queue);
        TracePrintf(1, "LoadNextProc: Next Process Id: %d\n", next->id);
        if(next->id == 2) 
            TracePrintf(3, "LoadNextProc: PCB has %p child\n", next->parent->children->head);
        WriteRegister(REG_PTBR1, (unsigned int) &(next->cow.pageTable)); 
        WriteRegister(REG_TLB_FLUSH, TLB_FLUSH_1);


        KernelContextSwitch(MyKCS, current_process, next);
        TracePrintf(1, "LoadNextProc: Got past MyKCS\n");
        *context = current_process->user_context;

        TracePrintf(3, "LoadNextProc: current user context pc is %p\n", context->pc);
    }
}
예제 #4
0
void NRF24L01p::Transmit(uint8_t* data, uint8_t size)
{
    uint8_t reg = 0;
    reg = ReadRegister(NRF24L01p_REGISTER_ADDRESS_CONFIG);
	reg &= ~((uint8_t)(0b1<<NRF24L01p_MNEMONIC_CONFIG_PRIM_RX)); //Put the device in TX mode.
	WriteRegister(NRF24L01p_REGISTER_ADDRESS_CONFIG, reg);

    CyDelayUs(150); //Wait for the device to switch to TX mode.

    uint8_t buffer[33] = {0};
	buffer[0] = NRF24L01p_INSTRUCTION_W_TX_PAYLOAD_NO_ACK;
	memcpy(&buffer[1], data, size);
    NRF24L01p_CS_Write(0);
	NRF24L01p_SPI_CONTROLLER_PutArray(buffer, size+1);
    CyDelayUs(10);
	NRF24L01p_CS_Write(1);

	NRF24L01p_CE_Write(1); //Make the NRF24L01p transmit the data.
	CyDelayUs(10);
	NRF24L01p_CE_Write(0);

	reg |= 0b1<<NRF24L01p_MNEMONIC_CONFIG_PRIM_RX; //Put the device in RX mode.
    CyDelayUs(1400);
	WriteRegister(NRF24L01p_REGISTER_ADDRESS_CONFIG, reg);

}
예제 #5
0
void SetHardwareAttenuator(unsigned char attenuatormode) {
	unsigned char old_value;	
	old_value = ReadRegister(CONFIG_REG_ADDR);
	if (attenuatormode != 0)
		WriteRegister(CONFIG_REG_ADDR, old_value |= HARDWAREATT_SET_FLAG);
	else
		WriteRegister(CONFIG_REG_ADDR, old_value &= ~HARDWAREATT_SET_FLAG);
}
예제 #6
0
void SetRadioEnabledState(unsigned char mode) {
	unsigned char old_value;	
	old_value = ReadRegister(CONFIG_REG_ADDR);
	if (mode != 0)
		WriteRegister(CONFIG_REG_ADDR, old_value |= RADIO_ENABLED_FLAG);
	else
		WriteRegister(CONFIG_REG_ADDR, old_value &= ~RADIO_ENABLED_FLAG);
}
예제 #7
0
void TurboNRF24L01::PowerUpRX()
{
	m_IsSendState = 0;
	m_CE.Low();
	WriteRegister(CONFIG, CRC_CONFIG | ((1 << PWR_UP) | (1 << PRIM_RX)));
	m_CE.High();
	WriteRegister(STATUS, (1 << TX_DS) | (1 << MAX_RT));
}
예제 #8
0
static
void rfid_task(void *pvParameters)
{
	int i;
	static unsigned char data[80];

	/* touch unused Parameter */
	(void) pvParameters;

	/* release reset line after 400ms */
	vTaskDelay( 400 / portTICK_RATE_MS);
	rfid_reset(1);
	/* wait for PN532 to boot */
	vTaskDelay( 100 / portTICK_RATE_MS);

	/* read firmware revision */
	debug_printf("\nreading firmware version...\n");
	data[0] = PN532_CMD_GetFirmwareVersion;
	rfid_execute(&data, 1, sizeof(data));

	/* enable debug output */
	debug_printf("\nenabling debug output...\n");
	WriteRegister(0x6328, 0xFC);
	// select test bus signal
	WriteRegister(0x6321, 6);
	// select test bus type
	WriteRegister(0x6322, 0x07);

	while (1)
	{
		/* wait 100ms */
		vTaskDelay( 100 / portTICK_RATE_MS);

		/* detect cards in field */
		GPIOSetValue(LED_PORT, LED_BIT, LED_ON);
		debug_printf("\nchecking for cards...\n");
		data[0] = PN532_CMD_InListPassiveTarget;
		data[1] = 0x01; /* MaxTg - maximum cards    */
		data[2] = 0x00; /* BrTy - 106 kbps type A   */
		if (((i = rfid_execute(&data, 3, sizeof(data))) >= 11) && (data[1]
				== 0x01) && (data[2] == 0x01))
		{
			debug_printf("card id: ");
			rfid_hexdump(&data[7], data[6]);
		}
		else
			debug_printf("unknown response of %i bytes\n", i);
		GPIOSetValue(LED_PORT, LED_BIT, LED_OFF);

		/* turning field off */
		debug_printf("\nturning field off again...\n");
		data[0] = PN532_CMD_RFConfiguration;
		data[1] = 0x01; /* CfgItem = 0x01           */
		data[2] = 0x00; /* RF Field = off           */
		rfid_execute(&data, 3, sizeof(data));
	}
}
예제 #9
0
bool BME280::WriteSettings()
{
   uint8_t ctrlHum, ctrlMeas, config;

   CalculateRegisters(ctrlHum, ctrlMeas, config);

   WriteRegister(CTRL_HUM_ADDR, ctrlHum);
   WriteRegister(CTRL_MEAS_ADDR, ctrlMeas);
   WriteRegister(CONFIG_ADDR, config);
}
예제 #10
0
int main(void)
{
  WDTCTL = WDTPW | WDTHOLD;                      // Interrompe o watchdog timer.
  
  BCSCTL1 = CALBC1_16MHZ;                        // Configura o DCO para 16MHz.
  DCOCTL  = CALDCO_16MHZ;
  
  BCSCTL2 = BCSCTL2 | DIVS_0;                    // Configura SMCLK para 16MHz.

  P2DIR = P2DIR & (~PIN_INT1) & (~PIN_INT2);     // Configura pinos INT1 e INT2.

  P4OUT = P4OUT | PIN_CS_ACC;                    // Configura pino CS do acelerômetro.
  P4DIR = P4DIR | PIN_CS_ACC;

  P3SEL = P3SEL | PIN_MOSI | PIN_MISO | PIN_SCK; // Configura pinos SPI.

  UCB0CTL0 = UCB0CTL0 | UCSYNC | UCMODE_1 | UCMST | UCMSB | UCCKPH;    // Configura SPI.
  UCB0CTL1 = UCB0CTL1 | UCSSEL_2;
  UCB0BR0  = 0x08;                // SPI Speed = 16MHz/8 = 2MHz // Maximum Speed = 4MHz.
  UCB0BR1  = 0x00;
  UCB0CTL1 = UCB0CTL1 & (~UCSWRST);

  P4OUT = P4OUT & (~PIN_CS_ACC);              // Configura acelerômetro.
  WriteRegister(MCTL, 0x05);
  
  if (ReadRegister(MCTL) == 0x05)
  {
    P2OUT = ~PIN_LED1 | ~PIN_LED2 | ~PIN_LED3;
    P2DIR = PIN_LED1 | PIN_LED2 | PIN_LED3;
  }
  
  acc_id = ReadRegister(WHOAMI);
  
  while(1);  
}
예제 #11
0
파일: rf.c 프로젝트: 40Grit/rfTest
/*XmitPacket: send a data byte/block to the rf module*/
BYTE XmitPacket(BYTE *data, BYTE length)
{
	RF_CE = 0;

	//early return if packet length is too long
	if (length > 32)
		return 1;
	
	//Clear Interrupts
	WriteRegister(STATUS, (STATUS_TX_DS | STATUS_RX_DR | STATUS_MAX_RT));

	//load tx fifo
	WriteTxPayload(data, length);

	//send packet
	PulseCe();

	//block until acknowledge or timeout
	while (1)
	{
		if (CheckInterrupt(STATUS_MAX_RT))
		{
			OutCommand(FLUSH_TX);
			return 2;
		}
		if (CheckInterrupt(STATUS_TX_DS))
			return 0;
	}

	/*FIXME:implement state?*/
	//set state
}
예제 #12
0
uint8_t cc1101_t::Init() {
    // ==== GPIO ====
    PinSetupOut      (CC_GPIO, CC_CS,   omPushPull);
    PinSetupAlterFunc(CC_GPIO, CC_SCK,  omPushPull, pudNone, CC_SPI_AF);
    PinSetupAlterFunc(CC_GPIO, CC_MISO, omPushPull, pudNone, CC_SPI_AF);
    PinSetupAlterFunc(CC_GPIO, CC_MOSI, omPushPull, pudNone, CC_SPI_AF);
    IGdo0.Init(ttFalling);
    //PinSetupAnalog   (CC_GPIO, CC_GDO2);    // GDO2 not used
    CsHi();
    // ==== SPI ====
    // MSB first, master, ClkLowIdle, FirstEdge, Baudrate no more than 6.5MHz
    ISpi.Setup(boMSB, cpolIdleLow, cphaFirstEdge, sbFdiv16);
    ISpi.Enable();
    // ==== Init CC ====
    if(Reset() != OK) {
        ISpi.Disable();
        Uart.Printf("\rCC Rst Fail");
        return FAILURE;
    }
    // Check if success
    WriteRegister(CC_PKTLEN, 7);
    uint8_t Rpl = ReadRegister(CC_PKTLEN);
    if(Rpl != 7) {
        ISpi.Disable();
        Uart.Printf("\rCC R/W Fail; rpl=%u", Rpl);
        return FAILURE;
    }
    // Proceed with init
    FlushRxFIFO();
    RfConfig();
    IGdo0.EnableIrq(IRQ_PRIO_HIGH);
    return OK;
}
예제 #13
0
/*****************************************************************************
	Modifica la base de exposicion
    nBaseExposicion - en microsegundos
    Devuelve true si todo bien
*****************************************************************************/
bool  ModificaBaseExposicion(int nBaseExposicion)
{
    if (Address == 0) //Primera vez que se accede al registro avanzado de la base de exposicion
    {
        Address = LeeAddressTimeBase();

        if (Address == 0)
            return false;

        // Leer cabecera (COMPROBACION)
        if (ReadRegister(M_sistema, M_DEV0, Address + 0) == 0)
            return false;
    }

    // Escribir shutter time base
    float fShutterTimeBase = (float)nBaseExposicion/(float)1000000;
    QUADLET qTimeBase = *((QUADLET *)&fShutterTimeBase);
    WriteRegister(M_sistema, M_DEV0, Address + 16, qTimeBase);

    // Leer shutter time base (COMPROBACION)
    QUADLET Value = ReadRegister(M_sistema, M_DEV0, Address + 16);
    float base = *((float *)&Value);
    base = base * 1000000;
    ASSERT((int)base == nBaseExposicion);

    return true;
}
예제 #14
0
bool NRF24L01p::Receive(uint8_t* data, uint8_t size)
{
    NRF24L01p_CE_Write(1); //Start listening.
    CyDelay(2); //Give it some time to receive the package.

	uint8_t status = ReadRegister(NRF24L01p_REGISTER_ADDRESS_STATUS);
    if(status&(0b1<<NRF24L01p_MNEMONIC_STATUS_RX_DR)) //Check if we received a package.
    {
        WriteRegister(NRF24L01p_REGISTER_ADDRESS_STATUS, 0b1<<NRF24L01p_MNEMONIC_STATUS_RX_DR); //Clear the bit that says we received a package.

        NRF24L01p_CS_Write(0);
        NRF24L01p_SPI_CONTROLLER_WriteTxData(NRF24L01p_INSTRUCTION_R_RX_PAYLOAD); //Prepare to read the payload.
        CyDelayUs(5);
        
        for(uint8_t c=0; c<size; c++) //Receive the data.
        {
            NRF24L01p_SPI_CONTROLLER_WriteTxData(NRF24L01p_INSTRUCTION_NOP); //Sending NOPs all day long. Sending NOPs while I sing this song.
            CyDelayUs(5); //Give the received data some time to settle in.
            data[c] = NRF24L01p_SPI_INPUT_REG_ReadRegValue();
        }
        
        CyDelayUs(10); //TODO: Check why this one is here.
        NRF24L01p_CS_Write(1);
        NRF24L01p_CE_Write(0);
        
        NRF24L01p_SPI_CONTROLLER_WriteTxData(NRF24L01p_INSTRUCTION_FLUSH_RX); //Clean up any other packets.
        CyDelayUs(5);
        
        return true;
    }
    
    NRF24L01p_CE_Write(0);
    
    return false;
}
예제 #15
0
/**
 * Set the display window area with a upper, left-hand corner at (x, y)
 * that is sx pixels wide and sy pixels high.
 *
 * @param x upper left hand X coordinate window position
 * @param y upper left hand Y coordinate window position
 * @param sx width of window in pixels
 * @param sy height of window in pixels
 */
void OSD0201QILK::Window(uint32_t x, uint32_t y, uint32_t sx, uint32_t sy)
{
    // Vertical start address.
    WriteRegister (0x35, y);

    // Vertical end address.
    WriteRegister (0x36, y + sy - 1);

    // Horizontal address range.
    WriteRegister (0x37, ((x + 0x20) << 8) | (x + sx + 0x20 - 1));

    // X start address.
    WriteRegister (0x20, x + 0x20);

    // Y start address.
    WriteRegister (0x21, y);
}
예제 #16
0
void TurboNRF24L01::GetRecvData(uint8_t * val)
{
	m_CSN.Low();// Pull down chip select
	m_SPI.Send(R_RX_PAYLOAD);// Send cmd to read rx payload
	m_SPI.Receive(val, m_Payload);// Read payload
	m_CSN.High();                               // Pull up chip select
	WriteRegister(STATUS, (1 << RX_DR));   // Reset status register
}
예제 #17
0
void OGNRadio::SendPacket(uint8_t *Packet, uint16_t Size, uint16_t Freq, uint8_t TxPower)
{
  uint8_t i;
  
  SetTxPower(TxPower);
  SetFrequency(Freq);
  
  WriteRegister(REG_PAYLOADLENGTH, Size);
  WriteRegister(REG_SYNCCONFIG,RF_SYNC_OFF);
  
  WriteRegister(REG_PREAMBLEMSB, 0x00);
  WriteRegister(REG_PREAMBLELSB, 0x80);
  
  ClearIRQFlags();
  
  for(i=0;i<Size;i++)
  {
    WriteRegister(REG_FIFO,Packet[i]);
  }
  
  WriteRegister(REG_OPMODE , RF_DATAMODUL_MODULATIONTYPE_FSK  | RF_OPMODE_LISTEN_OFF | RF_OPMODE_TRANSMITTER);
  
  do {} while( (ReadRegister(REG_IRQFLAGS2) & RF_IRQFLAGS2_PACKETSENT ) != RF_IRQFLAGS2_PACKETSENT);

  WriteRegister(REG_OPMODE, RF_DATAMODUL_MODULATIONTYPE_FSK  | RF_OPMODE_LISTEN_OFF | RF_OPMODE_STANDBY);
}
예제 #18
0
파일: MPU6050.cpp 프로젝트: albi08/AF_HF
IMU::IMU(void)
{	 

	char buf[1];
	bcm2835_init();
	bcm2835_i2c_begin();
	bcm2835_i2c_setSlaveAddress(MPU6050_ADDRESS);
	WriteRegister(SMPRT_DIV,0x07);	// Set the sample rate to 1000Hz - 8kHz/(7+1) = 1000Hz
	WriteRegister(CONFIG,0x00); // Disable FSYNC and set 260 Hz Acc filtering, 256 Hz Gyro filtering, 8 KHz sampling
	WriteRegister(GYRO_CONFIG,0x00); //250dpi
	WriteRegister(ACCEL_CONFIG,0x00); //2g resolution
	WriteRegister(PWR_MGMT_1,0x00); //sleep mode disabled

	
	regaddr[0]=WHO_AM_I;
	bcm2835_i2c_write(regaddr, 1);
	bcm2835_i2c_read(buf, 1);
	if(buf[0]==0x88)
	{
		printf("sensor config was successful WHO_AM_I: %x\n",buf[0]);
	}
	else
	{
		printf("sensor config was unsuccessful, %x\n",buf[0]);
	}
	
	bcm2835_i2c_end();
	///////////SETUP VARIABLES

	ReadGyr();
	ReadAccel();
	#ifdef RESTRICT_PITCH // Eq. 25 and 26
	  KFData.roll  = atan2(AData.y, AData.z) * RAD_TO_DEG;
	  KFData.pitch = atan(-AData.x / sqrt(AData.y * AData.y + AData.z * AData.z)) * RAD_TO_DEG;
	#else // Eq. 28 and 29
	  KFData.roll  = atan(AData.y / sqrt(AData.x * AData.x + AData.z * AData.z)) * RAD_TO_DEG;
	  KFData.pitch = atan2(-AData.x, AData.z) * RAD_TO_DEG;
	#endif

	kalmanX.setAngle(KFData.roll); // Set starting angle
  	kalmanY.setAngle(KFData.pitch);


}
bool
RegisterContextPOSIXProcessMonitor_arm64::WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
{
    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];

    if (IsGPR(reg))
        return WriteRegister(reg, value);

    return false;
}
예제 #20
0
    void Beep(unsigned frequency)
    {
      if (!m_hasBeeper)
        return;

      if (frequency == 0) {
        WriteRegister(0x1a, 0x1);     // Turn Beeper off
        return;
      }

      int divisor = 46875 / frequency - 1;
      if (divisor < 1)
	divisor = 1;
      else if (divisor > 255)
	divisor = 255;

      WriteRegister(0x18, divisor); // set frequency
      WriteRegister(0x1a, 0x9);     // Turn Beeper on
    }
예제 #21
0
파일: rf.c 프로젝트: 40Grit/rfTest
//Write individual bits of the configure register
void RfConfigure(BYTE bitNum, BYTE enable)
{
	BYTE config = 0;
	config = ReadRegister(CONFIG);
	if (enable)
		config |= 1 << bitNum;
	else
		config &= ~(1 << bitNum);
	WriteRegister(CONFIG, config);
}
예제 #22
0
void SetFrequency( U8 radio, U32 frequency_hz )
{
	//this function should have greater than 1khz resolution.
	U8 hbsel_val = 0;
	U8 fb = 0;
	U16 fc = 0;
	U32 temp = 0;
	U8 reg = 0;

	if( frequency_hz < 240000000 )
		return;

	if( frequency_hz > 930000000 )
		return;


	//check if high band should be enabled.
	if( frequency_hz >= 480000000 )
		hbsel_val = 1;

	//find fband, integer component.
	fb = ((frequency_hz-(240000000 * (hbsel_val + 1)))/10000000);

	if( hbsel == 1 )
		fb = ((frequency_hz-480000000)/10000000);


	//fc = ( frequency_hz / ( 10000000 * (hbsel + 1) ) - fb - 24 ) * 64000;
	temp = ( 24ul + fb ) * 10000000ul * ( hbsel_val + 1 );
	temp = frequency_hz - temp;
	temp = temp * 64;
	temp = temp / (10000 * (hbsel_val + 1));
	fc = temp;

	reg = fb | ( hbsel_val << 5 ) | sbsel;
	WriteRegister( radio, RFREG_FREQ_BAND_SEL, sbsel | reg );
	WriteRegister( radio, RFREG_NOMINAL_CARRIER_FREQ_1, fc >> 8 ); //fc[15:8]
	WriteRegister( radio, RFREG_NOMINAL_CARRIER_FREQ_0, fc ); //fc[7:0]



}
예제 #23
0
static void OPL_SDL_PortWrite(opl_port_t port, unsigned int value)
{
    if (port == OPL_REGISTER_PORT)
    {
        register_num = value;
    }
    else if (port == OPL_DATA_PORT)
    {
        WriteRegister(register_num, value);
    }
}
예제 #24
0
/**
 *
 * IChannACGainCal() .. returns true on a successful gain setting to 1 and successful
 * calibration send.
 */
bool cs5463spi::IChannACGainCal() {
	bool bSuccess = false;
	int registerWrite, result;
	registerWrite = WriteRegister(m_cs5463NumList[i_gain].addr, 0x40, 0x00, 0x00);  //sets Gain to 1;
	result = sendCmd(m_sysCalGain.V_CHAN_AC_GAIN);  // Inits I channel AC Gain Calibration

	if(registerWrite >= 0 && result >= 0)
	  bSuccess = true;

	return bSuccess;
}
예제 #25
0
void Flea3Camera::SetRawBayerOutput(bool& raw_bayer_output) {
  // Because this only works in standard video mode, we only enable this if
  // video mode is not format 7
  const auto video_mode_frame_rate_pg = GetVideoModeAndFrameRate(camera_);
  if (video_mode_frame_rate_pg.first == VIDEOMODE_FORMAT7) {
    raw_bayer_output = false;
    return;
  }
  // See Point Grey Register Reference document section 5.8
  WriteRegister(camera_, 0x1050, static_cast<unsigned>(raw_bayer_output));
}
예제 #26
0
void SetDataRate( U8 radio, U32 dataRate_bps )
{
	U8	txdr_lower = 0x00;
	U8	txdr_upper = 0x00;
	U16 txdr = 0x0000;
	if ( dataRate_bps < 30000 ) { // Use txdtrtscale = 1.
		WriteRegister( radio, RFREG_MOD_MODE_CTRL_1, txdtrtscale );
	} else {
		WriteRegister( radio, RFREG_MOD_MODE_CTRL_1, 0x00 );
	}
	
	txdr = ComputeTxRateReg( dataRate_bps );
	txdr_lower = (U8)txdr;
	txdr_upper = (U8)( txdr >> 8 );
	//data rate below 30 kbps. manchester off. data whitening off.
	//WriteRegister( radio, RFREG_TX_DATA_RATE_1, 0x27 ); //txdr[15:8]
	//WriteRegister( radio, RFREG_TX_DATA_RATE_0, 0x52 ); //txdr[7:0]
	WriteRegister( radio, RFREG_TX_DATA_RATE_1, txdr_upper ); //txdr[15:8]
	WriteRegister( radio, RFREG_TX_DATA_RATE_0, txdr_lower ); //txdr[7:0]
}
/**
 * Constructor.
 */
ADIS16448_IMU::ADIS16448_IMU() : m_spi(SPI::Port::kMXP) {
  m_spi.SetClockRate(1000000);
  m_spi.SetMSBFirst();
  m_spi.SetSampleDataOnFalling();
  m_spi.SetClockActiveLow();
  m_spi.SetChipSelectActiveLow();

  ReadRegister(kRegPROD_ID); // dummy read

  // Validate the part ID
  if (ReadRegister(kRegPROD_ID) != 16448) {
    DriverStation::ReportError("could not find ADIS16448");
    return;
  }

  // Set IMU internal decimation to 102.4 SPS
  WriteRegister(kRegSMPL_PRD, 769);

  // Enable Data Ready (LOW = Good Data) on DIO1 (PWM0 on MXP)
  WriteRegister(kRegMSC_CTRL, 4);

  // Configure IMU internal Bartlett filter
  WriteRegister(kRegSENS_AVG, 1030);

  m_cmd[0] = kGLOB_CMD;
  m_cmd[1] = 0;

  // Configure interrupt on MXP DIO0
  m_interrupt.reset(new InterruptSource(10));
  m_interrupt->RequestInterrupts();
  m_interrupt->SetUpSourceEdge(false, true);

  // Start monitoring thread
  m_freed = false;
  m_task = std::thread(&ADIS16448_IMU::Calculate, this);

  Calibrate();

  //HALReport(HALUsageReporting::kResourceType_ADIS16448, 0);
  LiveWindow::GetInstance()->AddSensor("ADIS16448_IMU", 0, this);
}
예제 #28
0
bool cs5463spi::IchannACoffsetCal() {
   bool bCalRdy = false;
   int result, registerWrite;

   registerWrite = WriteRegister(m_cs5463NumList[i_ac_offset].addr,0x00, 0x00, 0x00);// Clears I_AC_Offset Register
   result = sendCmd(m_sysCalOffset.I_CHAN_AC_OFFSET);  // Inits I channel AC Offset Calibration

   if(result >= 0 && registerWrite >= 0)
   	   bCalRdy = CalStatusReadyCheck(6E9);

   return bCalRdy;
}
예제 #29
0
// devuelve 0 si no es posible acceder a la caracteristica avanzada de base de exposicion
QUADLET LeeAddressTimeBase()
{
    const int nACR = 0xF2F00000; //direccion del ACR (Access Control Register) (para todos los features)

    // Set feature set ID to unlock advanced features. NO ES NECESARIO, SIEMPRE HABILITADO EN CAMARAS BASLER
    QUADLET
      Enabled1,
      Enabled2;
    WriteRegister(M_sistema, M_DEV0, nACR + 0x00, 0x0030533B);
    WriteRegister(M_sistema, M_DEV0, nACR + 0x04, 0x73C3F000);//last three zeros represent a timeout value, 000 means always available
    Enabled1 = ReadRegister(M_sistema, M_DEV0, nACR + 0x00);
    Enabled2 = ReadRegister(M_sistema, M_DEV0, nACR + 0x04);

    if (Enabled1 == 0xFFFFFFFF && Enabled2 == 0xFFFFFFFF)
        return false;

    // Recuperamos la direccion CSR (Control and Status Register) para el shutter time base feature

        // Escribimos al Smart Features Inquiry Register (que esta 0x10 despues respecto al ACR)
        // El Inquiry Register esta ordenado asi: D1 | D3 | D2 | D4[3] | D4[2] | D4[1] | D4[0] | D4[7] | D4[6] | D4[5] | D4[4]
        // El CSR GUID para el shutter time base es D1:648BE1DA   D2:A416   D3:11D8   D4:9B47 00105A5BAE55
        WriteRegister(M_sistema, M_DEV0, nACR + 0x10, 0x648BE1DA);
        WriteRegister(M_sistema, M_DEV0, nACR + 0x14, 0x11D8A416);
        WriteRegister(M_sistema, M_DEV0, nACR + 0x18, 0x1000479B);
        WriteRegister(M_sistema, M_DEV0, nACR + 0x1C, 0x55AE5B5A);
        // Al haber "preguntado" por nuestro CSR GUID, obtenemos la direccion CSR
        // la direccion estará en el Smart Features Addres Register (desplazado 0x20 del ACR
        return ReadRegister(M_sistema, M_DEV0, nACR + 0x20);
}
예제 #30
0
bool cs5463spi::DisableInterrupts(){

   bool action = false;

   if(WriteRegister(m_cs5463NumList[status].addr, 0x00, 0x00, 0x00)) {  //disables interrupts
	  action = true;
   }
   else
    //  m_mySPISysLog->writeErrLog("Disable Interrupts failed.");
   m_pMyLogger->WriteLocal(LOG_LOCAL0, LOG_ERR, "Disable Interrupts failed.");

  return action;
}