Beispiel #1
0
void FAST2420_READ_FIFO_BYTE(TiSpiAdapter * spi,uint8 *b)
   {
        CC2420_SPI_ENABLE();
        FAST2420_RX_ADDR(spi,CC2420_RXFIFO);
        spi_get(spi,(char*)b);
        CC2420_SPI_DISABLE();
    }
Beispiel #2
0
/* No private data for IPC */
void ipc_platform_do_cmd(struct ipc *ipc)
{
	struct sof_ipc_reply reply;
	int32_t err;

	/* perform command and return any error */
	err = ipc_cmd();
	if (err > 0) {
		mailbox_hostbox_read(&reply, SOF_IPC_MSG_MAX_SIZE,
				     0, sizeof(reply));
		goto done; /* reply created and copied by cmd() */
	} else if (err < 0) {
		/* send std error reply */
		reply.error = err;
	} else if (err == 0) {
		/* send std reply */
		reply.error = 0;
	}

	/* send std error/ok reply */
	reply.hdr.cmd = SOF_IPC_GLB_REPLY;
	reply.hdr.size = sizeof(reply);

done:
	spi_push(spi_get(SOF_SPI_INTEL_SLAVE), &reply, sizeof(reply));

	ipc->host_pending = 0;

	// TODO: signal audio work to enter D3 in normal context
	/* are we about to enter D3 ? */
	if (ipc->pm_prepare_D3) {
		while (1)
			wait_for_interrupt(0);
	}
}
Beispiel #3
0
void FAST2420_READ_FIFO_NO_WAIT(TiSpiAdapter * spi,uint8 *p, uint8 c)
    {
        uint8 n = 0;
        CC2420_SPI_ENABLE();
        FAST2420_RX_ADDR(spi,CC2420_RXFIFO);
        for (n = 0; n < (c); n++) {
            spi_get(spi,(char*)(p + n));
        }
        CC2420_SPI_DISABLE();
    }
Beispiel #4
0
uint8 spi_read(TiSpiAdapter * spi, char * buf, uint8 capacity, uint8 opt )
{
	uint8 n = 0;
        
    for (n = 0; n < capacity; n++) 
	{ 
		spi_get(spi,buf + n); 
	} 
       
    return 0;
}
Beispiel #5
0
void FAST2420_READ_RAM_LE(TiSpiAdapter * spi,uint8 *p,uint16 a,uint8 c)
   {
   	uint8 n;
        CC2420_SPI_ENABLE();
        spi_put(spi,0x80 | (a & 0x7F));
        spi_put(spi,((a >> 1) & 0xC0) | 0x20);
        for (n = 0; n < (c); n++) {
            spi_get(spi,(char*)(p + n));
        }
        CC2420_SPI_DISABLE();
    }
char SPI_L(char TX_Data) 
{	
/* Send pattern. */
	spi_put(&NRF24L01_L_SPI,TX_Data);

	/* Wait for transmission complete. */
	while(!(spi_is_tx_ok(&NRF24L01_L_SPI)));
	/* Read received data. */
	uint8_t result = spi_get(&NRF24L01_L_SPI);

	return(result);
}
Beispiel #7
0
void FAST2420_READ_RAM(TiSpiAdapter * spi,uint8 *p,uint16 a,uint8 c)
    {
    	uint8 n;
        CC2420_SPI_ENABLE();
        spi_put(spi,0x80 | (a & 0x7F));
        spi_put(spi,((a >> 1) & 0xC0) | 0x20);
        n = c;
        do {
            spi_get(spi,(char*)(p + (--n)));
        } while (n);
        CC2420_SPI_DISABLE();
    }
Beispiel #8
0
void FAST2420_READ_FIFO(TiSpiAdapter * spi,uint8 *p,uint8 c)
    {
        uint8 n = 0;

        CC2420_SPI_ENABLE();
        FAST2420_RX_ADDR(spi,CC2420_RXFIFO);
        for (n = 0; n < (c); n++) {
            while (!VALUE_OF_FIFO());
            spi_get(spi,(char*)(p + n));
        }
        CC2420_SPI_DISABLE();
    }
Beispiel #9
0
/**
 * \brief Interrupt callback for SPI interrupt
 *  \param none
 */
static void spi_interrupt_callback(void)
{
	uint8_t data = spi_get(SPI_SLAVE_EXAMPLE);

	if (data_transfer == true) {
		spi_put(SPI_SLAVE_EXAMPLE, data_slave_tx[count++]);
	} else {
		data_slave_rx[count++] = data;
		if (data_slave_rx[0] == SLAVE_RD_CMD) {
			data_transfer = true;
			count = 0;
			spi_put(SPI_SLAVE_EXAMPLE, data_slave_tx[count++]);
		}
	}
}
Beispiel #10
0
// Updates the SPI status byte
void FAST2420_UPD_STATUS(TiSpiAdapter * spi,uint8 *s)
    {
        CC2420_SPI_ENABLE();
        spi_get(spi,(char*)s);
        CC2420_SPI_DISABLE();
    }
/*! \brief Request and reads all sensor output data from IMU.

	\details This function uses the IMU burst read functionallity in which all
	IMU sensor data (rotation, specific force, temperature, and supply voltage)
	is output by the IMU after a single request. This way only two clock
	cycles are required between each read operation. This is faster than only
	reading out rotation and specific force.
	The functions first reads in the values in 16-bit intermediate variables
	and then call the help functions convert_inert_readings() and
	convert_auxiliary_data() to shift out status bits and scale to SI units.
	
	@param[out] angular_rates_in		Vector containing the 3 (x,y,z) angular rates in [rad/sec].
	@param[out] accelerations_in		Vector containing the 3 (x,y,z) specific force in [m/s^2].
	@param[out] imu_temperatures		Vector containing the 3 (x,y,z) temperatur readings in [C].
	@param[out] imu_supply_voltage		Supply voltage measurement in [V].
*/
void imu_burst_read(void){
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,BURST_READ);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	supply = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	xgyro = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	ygyro = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	zgyro = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	xacc = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	yacc = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	zacc = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	xtemp = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	ytemp = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	ztemp = spi_get(SPI_IMU);
	while (!spi_is_tx_ready(SPI_IMU)) {;}
	spi_put(SPI_IMU,CONFIG_SPI_MASTER_DUMMY);
	while (!spi_is_rx_ready(SPI_IMU)) {;}
	aux_adc = spi_get(SPI_IMU);
	
	convert_inert_readings();
	convert_auxiliary_data();
}