Forums - to use temp Sensor based on SPI

2 posts / 0 new
Last post
to use temp Sensor based on SPI
tnbang7
Join Date: 18 Jan 17
Posts: 1
Posted: Wed, 2017-05-10 01:50

Dear all,

We are about to attach temp sensor(MAX31855)  on RB02(QCA4010) module throuh SPI.

However, we met a problem about how we will use SPI. Because we don't have any example about SPI use except test spi flash.

Please advice a guide for use SPI in RB02.

Thanks,

Todd

  • Up1
  • Down0
raylin0530
Join Date: 15 Aug 17
Posts: 5
Posted: Wed, 2017-08-16 02:35

Dear Customer,

/*-------------------------------------------------------------*/

int test_spi_read_max31855_cs=SPI_CS_1;

int test_spi_read_max31855_init=0;

void test_spi_read_max31855(unsigned char *buf, int size)

{

                A_UINT32 req[1];

 

             if(!test_spi_read_max31855_init)

{

                qcom_spi_init(test_spi_read_max31855_cs, SPI_MOSI_1, SPI_MISO_1, SPI_SCLK_1, SPI_FREQ_400K);

}

 

                req[0] = 0; //0x9f;

                qcom_spi_request(req,4,0);

                qcom_spi_response(buf,(unsigned int )size);

 

}

 

Void test_main(void)

{

        unsigned int val=0;

        test_spi_read_max31855((unsigned char *)&val, 4);

 

        /* convert the data */

        unsigned int output;

        output = ((val&0xff)<<24) | (((val>>8)&0xff)<<16) | (((val>>16)&0xff)<<8) | (((val>>24)&0xff));

        SWAT_PTF("%s: get val 0x%x\n", __func__, output);

 

}

/*-------------------------------------------------------------*/

/*

When using mp1 board, please connect as:

                                CS :  jp4.12

                                SCK: jp4.4

                                SO :  jp4.2

*/

int test_spi_read_max31855_cs=SPI_CS_1;

int test_spi_read_max31855_init=0;

 

void test_spi_read_max31855(unsigned char *buf, int size)

{

                A_UINT32 req[1];

 

                if(!test_spi_read_max31855_init)

                {

                                qcom_spi_init(test_spi_read_max31855_cs, SPI_MOSI_1, SPI_MISO_1, SPI_SCLK_1, SPI_FREQ_400K);

                }

 

                req[0] = 0; //0x9f;

                qcom_spi_request(req,4,0);

                qcom_spi_response(buf,(unsigned int )size);

 

                if(!test_spi_read_max31855_init)

                {

                                qcom_spi_fini();

                }

 

}

Regards,

Ray

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.