Closed samuelsd1 closed 2 years ago
Thank you for your feedback. I'll look in it more in deep next week but as far as I can see you are referring to files (s2lp_general.c and s2lp_types.c) that actually are in the driver code but are not used in the projects (you can check opening one of them), that's probably why they were not updated in the refactoring of original S2-LP Driver.
Next version of the package will include original S2-LP Driver from S2LP-DK, and wrap it in a different way, avoiding these kind of problems.
Coming back to your problem, how did you produce the project? I think that If you remove from it those unused files, it should compile. By the way, STM32CubeMX tool can be used to migrate to other platforms and generate code, and x-cube-subg2 is integrated into it.
BR, Marco
@mgrella Thank you for your response :)
I commented on the pull request about the technical details.
I have some questions: In the pull request (and also here), you mentioned next version will include the driver with a different approach.
With much thanks, David
Hello David,
let me start from your question number two :) This repo is intended to delivery the x-cube-subg2 package that delivers a set of Examples (P2P demo) and Applications (projects that uses not only the Drivers but also a Middleware, in this case Contiki-NG) on top of S2-LP radio.
As you know, the radio driver itself can be found in Drivers/BSP/Components/S2LP. But this is not the direct focus of this repository, and it is a "readapted" version of the original S2LP Driver that you can find in the STSW-S2LP-DK: https://www.st.com/en/embedded-software/stsw-s2lp-dk.html This package contains the "original" driver, currently not yet distributed via GitHub.
I wrote "readapted" because the x-cube-subg2 package is also a pack for STM32CubeMX: https://www.st.com/en/development-tools/stm32cubemx.html a tool that, among other things, allows you to reconfigure a given sw solution for different families of MCU. This task requests a different approach for the bus communication, that's why the original S2-LP driver, here, is wrapped by means of specific Board Support Packages (Drivers/BSP/S2868A1, ...) and provides a different kind of interface (s2lp.c/h).
In the context of this "adaptation", also a refactoring of the functions was performed, and this causes the inconsistency that you correctly point out, since some files (unused by our projects) have not been refactored.
Coming back to your question number 1: the new release will include the original S2LP_Library coming from STSW-S2LP-DK, as a core part of x-cube-subg2 S2-LP Component Driver, with no refactoring. Backward compatibility with current "refactored" API will be granted by means of proper mapping h file. In my opinion, this will makes things more clear and will also be more future-proof in case S2-LP core driver will be hosted on a separate repository.
BR, Marco
Closing this issue, S2-LP Component Driver now contains official S2-LP Library from S2-LP DK. We'll check the other feedbacks for further updates in following months
Driver code does not compile due to incorrect code.
Setup
Context
I am comparing the code of this repository - to the S2LP driver code I acquired using STM32CubeIDE software package manager (following STMicroelectronics YouTube tutorial)
I will refer to the code acquired following this tutorial as the original code, since it is a release version, therefore it is safe to assume more people have the same driver code.
Bug details
Code that causes the problem:
S2LPSpiReadRegisters
instead ofS2LP_ReadRegister
(The first one is not defined therefore incorrect)s2lp_general.c
,s2lp_types.c
ModeExtRef
enum:s2lp.h
(exists in current release of x-cube-subg2)s2lp_general.h
Calls to undefined function/macro
s_assert_param
(not defined at all in the repository).s2lp_general.c
Additional code problems
s2lp_general.h
ins2lp.h
.s2lp_general
files. but this does not prevent the compilation errors.s2lp_general
files exist in the repo and their purpose seems correct.S2LPGeneralLibraryVersion()
s2lp.h
,s2lp_general.h
s2lp.h
s2lp_general
files, which already defined ins2lp.h
and implemented ins2lp.c
:S2LPGeneralGetDevicePN
, already exists asS2LP_GetDevicePN
S2LPGeneralGetVersion
, already exists asS2LP_GetVersion
S2LPGeneralSetExtRef
, already exists asS2LP_SetExtRef
S2LPGeneralGetExtRef
, already exists asS2LP_GetExtRef
S2LPRadioSetExternalSmpsMode
, already exists asS2LP_SetExternalSmpsMode
S2LPRefreshStatus
, already exists (and widely used) asS2LP_RefreshStatus
Since the functions already exist, it would be incorrect to delete them (as this would break compatibility to the previous release version). Therefore - a good solution would be to keep the existing functions, move them intos2lp_general
files, while removing the duplicate functions defined in thes2lp_general
files. This way the functionality and compatibility will be preserved. In addition, this solution seems to align with the purpose ofs2lp_general
files.g_xStatus
variables2lp.c
s2lp_types.c
This does not cause compilation error, but it is incorrect. A fix to this would be to choose one between the two.s2lp_types
should not contain the definition ofg_xStatus
since it is not a type. It is rather a global instance variable. Therefore I believe it should be declared ins2lp.h
and defined ins2lp.c
(similar to theIO_func
variable ins2lp.c
)_How to reproduce the bug
Copy the source files located in
Drivers/BSP/Components/S2LP
to your project, then compile.Additional context
I am using the driver code to write S2-LP high-level interface, which is platform independent. Therefore, the code is more sensitive to platform dependent definitions. Example of such platform dependent code:
s_assert_failed
, and calls to undefineds_assert_param
macro. The current behavior of a failed assert is aprintf
call, and infinite error loop. Driver code should not behave this way. Parameter validations are important and should be performed, but the result of bad parameter should be returning an error code. Therefore, in my patch I temporarily defined empty macro fors_assert_param
, but I believe boths_assert_param
ands_assert_failed
should be removed from the driver code.Solution
I have patched the mentioned problems, compiled and tested my patch by running simple P2P app. Soon I will open a pull request containing my tested patch.