Mbed-os: SPI format and frequency may not be set in SPI constructor

Created on 24 Aug 2017  路  4Comments  路  Source: ARMmbed/mbed-os

  • 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:

CLOSED drivers mirrored bug

All 4 comments

cc @deepikabhavnani @c1728p9 @bulislaw
[Mirrored to Jira]

@ccchang12 Do you mind pushing PR with a fix?
[Mirrored to Jira]

@bulislaw I think it is better the owner can modify the code directly in next release.
[Mirrored to Jira]

Internal Jira reference: https://jira.arm.com/browse/IOTHAL-223

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bmcdonnell-ionx picture bmcdonnell-ionx  路  4Comments

drahnr picture drahnr  路  4Comments

bulislaw picture bulislaw  路  3Comments

pilotak picture pilotak  路  3Comments

DuyTrandeLion picture DuyTrandeLion  路  3Comments