Beispiel #1
0
/* To be called not faster than 30Hz */
void baro_MS5534A_send(void)
{
  if (!SpiCheckAvailable()) {
    SpiOverRun();
    return;
  }

  if (status == STATUS_RESET) {
    uint8_t i;
    for (i = 0; i < 3; i++) {
      buf_output[i] = reset[i];
    }
    spi_buffer_length = 3;
  } else {
    if (status_read_data) {
      buf_output[0] = buf_output[1] = 0;
    } else {
      buf_output[0] = (InitStatus() ? CMD_INIT : CMD_MEASUREMENT);
      buf_output[1] = cmds[status];
    }
    spi_buffer_length = 2;
  }

  spi_buffer_input = (uint8_t *)&buf_input;
  spi_buffer_output = (uint8_t *)&buf_output;
  if (status_read_data) {
    SpiSetCPHA();
  } else {
    SpiClrCPHA();
  }
  SpiStart();
}
Beispiel #2
0
/**********************************************************************
***********							 Write TI_Command							*****************
***********************************************************************
	Aim  : command strobe acces
	NOTE :[ R/W bit (0)] + [ Burst bit (0)] + [6 bit addres]
				 No data is expected. Chip_status_Byte is returned from chip
**********************************************************************/
void TI_Command( char command )
{
    SpiStart();																								//Start SPI by CSn Low
    wait_CHIP_RDYn; 																					//Wait for TI's christal to be stabilized
    SPI_Send(command);																				//Send chip command
    SpiStop();	                               								//Stop SPI by CSn High
}
Beispiel #3
0
static void send1_on_spi(uint8_t d) {
  buf_output[0] = d;
  spi_buffer_length = 1;

  spi_buffer_input = (uint8_t*)&buf_input;
  spi_buffer_output = (uint8_t*)&buf_output;
  SpiStart();
}
Beispiel #4
0
/**********************************************************************
***********							 TI_Write							*************************
***********************************************************************
	Aim  : write 1 byte data to chip via SPI
	NOTE :[ R/W bit (0)] + [ Burst bit (0)] + [6 bit addres] + 8 bit data
**********************************************************************/
void TI_WriteByte( char addr,  char data)
{
//int dly;
    SpiStart();																										//Start SPI by CSn Low
    wait_CHIP_RDYn; 																								//Wait for TI's christal to be stabilized
    SPI_Send(addr);																							  // Send 1 byte addr and write command
    SPI_Send(data);																								// Send 1 byte data
    SpiStop();	                               											//Stop SPI by CSn High
}
Beispiel #5
0
char TI_Command_Read(char command)
{
    char ret;
    SpiStart();																								//Start SPI by CSn Low
    wait_CHIP_RDYn; 																					//Wait for TI's christal to be stabilized
    SPI_Send(command|READ_SINGLE);														//Send chip command with READ bit
    ret=SPI_Send(0x00);																				//send dummy byte so read status byte
    SpiStop();	                               								//Stop SPI by CSn High
    return ret;
}
Beispiel #6
0
/**********************************************************************
***********							 TI_Read							*************************
***********************************************************************
	Aim  : Read 1 byte data from chip via SPI
	NOTE :[ R/W bit (1)] + [ Burst bit (0)] + [6 bit addres]
**********************************************************************/
char TI_ReadByte(char addr)
{
    char data = 0;

    SpiStart();																										//Start SPI by CSn Low
    wait_CHIP_RDYn; 																								//Wait for TI's christal to be stabilized
    SPI_Send( READ_SINGLE | addr);																  // R/w bit (1) + Burst bit (0)+ 6 bit addres
    data = SPI_Send(0x00);             														// Data read (read 1byte data) via dummy write
    SpiStop();																											//Stop SPI by CSn High
    return data;
}
Beispiel #7
0
/**********************************************************************
***********							 TI_Init							*************************
***********************************************************************
	Aim  : wait for initialization of CC1120
	NOTE :
**********************************************************************/
void TI_Init(void)
{
    TI_HW_Reset();

    SpiStart();																										//Start SPI by CSn Low
    wait_CHIP_RDYn; 																							//Wait for TI's christal to be stabilized
//	while((SPI_Send(0x00) & 0x80) != 0);
//	x= SPI_Send(0x00);
    //	Delay(0x5000);
    SpiStop();																										//Stop SPI by CSn High

}
Beispiel #8
0
/**********************************************************************
***********							 TI_READ_brst							*********************
***********************************************************************
	Aim  : burst read to TI chip
	NOTE :[ R/W bit (1)] + [ Burst bit (1)] + [6 bit addres]
**********************************************************************/
int TI_Read_brst(int addr, char* buf,int len)
{
    int i = 0;

    SpiStart();					                             	  	//Start SPI by CSn Low
    wait_CHIP_RDYn; 																			//Wait for TI's christal to be stabilized
    SPI_Send ( READ_BURST | addr );												// Address byte 1
    for(i = 0; i < len; i++)                    				  // Write data in loop
    {
        buf[i] = SPI_Send(0x00);													//write data to buffer with size of "len"
    }
    SpiStop();																						//Stop SPI by CSn High
    return len;
}
Beispiel #9
0
/**********************************************************************
***********							 TI_Write_brst							*******************
***********************************************************************
	Aim  : burst write to TI chip
	NOTE :[ R/W bit (0)] + [ Burst bit (1)] + [6 bit addres stars with 0x2F00]
**********************************************************************/
int TI_Write_brst(int addr,char* buf,int len)
{
    int i = 0;

    SpiStart();					                             	  	//Start SPI by CSn Low
    wait_CHIP_RDYn; 																			//Wait for TI's christal to be stabilized
    SPI_Send ( WRITE_BURST | addr );											// Send the adrr

    for(i = 0; i < len; i++)              								// Burst Write the data
    {
        SPI_Send (buf[i]);
    }

    SpiStop();																						//Stop SPI by CSn High
    return len;
}
Beispiel #10
0
void ins_periodic_task( void ) {
  if (!SpiCheckAvailable()) {
    SpiOverRun();
    return;
  }

  if (!ins_configure()) return;

  // Fill request for QMR
  last_send_packet.CmdID = VN100_CmdID_ReadRegister;
  last_send_packet.RegID = VN100_REG_YMR;

  spi_buffer_input = (uint8_t*)&last_received_packet;
  spi_buffer_output = (uint8_t*)&last_send_packet;
  spi_buffer_length = 4+VN100_REG_YMR_SIZE;
  SpiSelectSlave0();
  SpiStart();

}
Beispiel #11
0
void wt_baro_periodic(void) {
  if (!SpiCheckAvailable()) {
    SpiOverRun();
    return;
  }

  if (status_read_data) {
    buf_output[0] = buf_output[1] = buf_output[2] = 0;
    spi_buffer_length = 3;
  }
  else {
    buf_output[0] = CMD_MEASUREMENT;
    spi_buffer_length = 1;
  }

  spi_buffer_input = (uint8_t*)&buf_input;
  spi_buffer_output = (uint8_t*)&buf_output;
  //if (status_read_data)
  //  SpiSetCPHA();
  //else
  //  SpiClrCPHA();
  SpiStart();
}
Beispiel #12
0
void setup() {
	configure_CAN();
	SpiStart();
}