Page 1 of 1

How to derive a class from DSPI

Posted: Fri Dec 25, 2020 1:13 am
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);
}

Re: How to derive a class from DSPI

Posted: Fri Dec 25, 2020 8:22 am
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

Re: How to derive a class from DSPI

Posted: Sat Dec 26, 2020 4:33 am
by jpelletier
Thanks! That will help.