How to derive a class from DSPI

Discussion to talk about software related topics only.
Post Reply
jpelletier
Posts: 18
Joined: Wed Dec 23, 2020 3:32 am

How to derive a class from DSPI

Post by jpelletier »

I want to do a display based on the DPSI driver. It is a class that inherits from DSPI. How should I do this exactly?

In display.h:

In display.cpp:

Code: Select all

class Display : public DSPIModule
{
    public:
        Display();
        virtual ~Display();
etc.

Code: Select all

Display::Display()
{
    m_Module = DEFAULT_DSPI_MODULE;

    /* Initialize pins needed for DSPI */
    /* definitions snipped */

    // Initialize DSPI with baudrate of 1 MHz, 8bit mode, inactive on all CS is High, assert CS1 Low
    //FIXME how to setup SPIModule?
    DSPIModule SPIFlashIC(DEFAULT_DSPI_MODULE, 1000000, 8, CHIP_SELECT_0, CS_ASSERT_LOW);
}
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: How to derive a class from DSPI

Post by pbreed »

I would make the DSPI a member variable, not derive the class...

If you do want to derive the class then that is nto the correct syntax for the base class constructor...
Take a look here:
https://en.cppreference.com/w/cpp/language/constructor
jpelletier
Posts: 18
Joined: Wed Dec 23, 2020 3:32 am

Re: How to derive a class from DSPI

Post by jpelletier »

Thanks! That will help.
Post Reply