Skip to content

SPI format and frequency may not be set in SPI constructor #4969

@ccchang12

Description

@ccchang12
  • Type: Bug
  • Priority: Major

Bug

The SPI class has a member "static SPI *_owner;" to indicate need to set SPI or not, and the default value is NULL in SPI.cpp. But after call the destructor and constructor again, it may encounter the format and frequency are not set issue due to the address is the same.

In ci-test-shield\TESTS\API\SPI\SPI.cpp, each test case calls the SPI constructor and may cause this issue. The solution should be set the _owner to be NULL in the SPI destructor as below.

diff --git a/drivers/SPI.h b/drivers/SPI.h
index 645243070..7e0ba08f4 100644
--- a/drivers/SPI.h
+++ b/drivers/SPI.h
@@ -263,6 +263,7 @@ protected:

public:
virtual ~SPI() {

  •    _owner = NULL;
    
    }

protected:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions