In this chapter, we will connect tpm36 to our dragonboard. 

Hardware setup:

I am trying to avoid soldering as much as I can, so I brought an Linker Mezzanine card from 96 boards. This is the only reason I have this card, otherwise I would have preferred a I2C temeprature sensor (and there are better options) using a level shifter (DB 410c is 1.8v!)

It is a very good card for quick prototyping and interfacing of peripherals (it does come with some peripherals, tpm36 is part of that). But disappointing that it does not have any good documentation and the support also has been not that great. 

There are some design examples online that will help you understand what is going on the board but a datasheet would have been better. 

So my hardware setup has the following:

  • Linker Mezzanine card - set to 5v

  • TPM36 connected to ADC 1 on the card

DB410c with Mezzanine card

ADC1 on the card communicates with Dragonboard using SPI 0 and GPIO 18 is used for chip select. 

Please do read about GPIO and SPI control in Linux Kernel documentation. This will make it easier to follow the source code.

Summary of the source code:

  • Request a GPIO (18) for chip select (CS)

  • Once created, set the direction to OUT 

  • Setup SPI 0 for ADC 1

    • Set the mode of transfer

    • Set bits per word

    • Set the transfer speed 

  • Create a thread to read temperature

    • CS LOW is active, so turn it HIGH for a short time and pull it LOW

    • Read data from SPI 

    • ADC is 10 bit, so convert it appropriately 

    • Convert it into your preferred unit.

  • Once aborted, cancel the thread, clean up and exit 

All the source code is at this github location: tpm36_spi

If all goes well, you should see the following output on dragonboard

Temperature readings on DB410c





Add comment

Security code