Bug: tx buffers should be const in fsl_dspi

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Bug: tx buffers should be const in fsl_dspi

1,976 次查看
davenadler
Senior Contributor I

Using SDK2.8, MCUXpresso 11.2, Kinetis K64F

Lots of applications (like ours) will send SPI data from const structures (ie flash), so...

tx buffer pointers need to be const (and probably volatile is not required).
Please fix:
fsl_dspi.h (typdef/structs dspi_transfer_t, _dspi_master_handle, _dspi_slave_handle)
fsl_dspi.c (function DSPI_MasterTransferBlocking)

Thanks!
Best Regards, Dave

PS: Fixes attached.

标记 (3)
4 回复数

1,856 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Dave,

But also in many cases, the transmit data is variable, not from flash or const type. Customer can adjust driver due to their application. Driver can't cover all user applications.

Regards,

Jing 

0 项奖励
回复

1,856 次查看
davenadler
Senior Contributor I

nxf32199‌ - Apparently you do not understand "const" here.
"const" means "I will treat this as constant and will not modify it".
It does not mean that the input to the routine must be a constant.
Please confirm you have understood this and filed a bug report.
Thanks,
Best Regards, Dave

0 项奖励
回复

1,856 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Yes, I understand.

The benefit of this modification is buffer pointer can use on both normal variable type and const type.

The disadvantage is this pointer can't transfer to other function which want to modify the data in this buffer. But this is not a big problem.

So, yes, your suggestion is very good. I'll transmit to software team.

Thanks

Jing 

0 项奖励
回复

1,856 次查看
davenadler
Senior Contributor I

jingp18@yahoo.com‌ - To be very clear, your statement above is absolutely incorrect:
The disadvantage is this pointer can't transfer to other function which want to modify the data in this buffer.

An API for transmitting data should never modify the transmitted data.
Thus any such API should declare a tx input as const.
Just like strcpy declares it's input as const:
Got it?

   char * strcpy ( char * destination, const char * source );

0 项奖励
回复