- Silicon Labs Community
- Welcome and Announcements
- Silicon Labs Knowledge Base
- 8-bit MCU
- 32-bit MCU
- Bluetooth / Wi-Fi
- Other Products Category
- Optical/RH/Temp Sensor
- Other Products
- Hardware and Software Tools
- Simplicity Studio and Software
- General Discussions and Suggestions
- Chinese Forum
- Software Libraries
- Development Kits
- Reference Designs
- Third Party Tools
- White Papers
- Official Blog of Silicon Labs
- Chinese Blog
07-06-2016 07:01 AM
I'm using UARTDRV from emdrv 4.4.0 on an EFM32WG940 chip. I don't use flow control in the application (neither hardware nor software flow control), so I'd like to disable that. So I edit uartdrv_config.h:
/// Set to 1 to enable hardware flow control #ifndef EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE #define EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE 0 #endif
However, when EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE is disabled, several parts of the code are #ifdeffed out, so the UARTDRV will not compile. Here is what I get:
../dependencies/emdrv/uartdrv/src/uartdrv.c: In function 'SetHandleIndex': ../dependencies/emdrv/uartdrv/src/uartdrv.c:827:8: error: 'uartdrvHandleIsInitialized' undeclared (first use in this function) if (!uartdrvHandleIsInitialized) ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c:827:8: note: each undeclared identifier is reported only once for each function it appears in dependencies/emdrv/uartdrv/src/subdir.mk:18: recipe for target 'dependencies/emdrv/uartdrv/src/uartdrv.o' failed ../dependencies/emdrv/uartdrv/src/uartdrv.c:831:7: error: 'uartdrvHandle' undeclared (first use in this function) uartdrvHandle[handleIdx] = NULL; ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c: In function 'InitializeGpioFlowControl': ../dependencies/emdrv/uartdrv/src/uartdrv.c:882:3: warning: implicit declaration of function 'GPIOINT_Init' [-Wimplicit-function-declaration] GPIOINT_Init(); ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c:883:3: warning: implicit declaration of function 'GPIOINT_CallbackRegister' [-Wimplicit-function-declaration] GPIOINT_CallbackRegister(handle->ctsPin, HwFcManageClearToSend); ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c:883:44: error: 'HwFcManageClearToSend' undeclared (first use in this function) Finished building: ../source/s1drv/rtcc.cpp GPIOINT_CallbackRegister(handle->ctsPin, HwFcManageClearToSend); ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c:887:3: warning: implicit declaration of function 'FcApplyState' [-Wimplicit-function-declaration] FcApplyState(handle); ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c: At top level: ../dependencies/emdrv/uartdrv/src/uartdrv.c:821:16: warning: 'SetHandleIndex' defined but not used [-Wunused-function] static Ecode_t SetHandleIndex(UARTDRV_Handle_t handle) ^ ../dependencies/emdrv/uartdrv/src/uartdrv.c:880:13: warning: 'InitializeGpioFlowControl' defined but not used [-Wunused-function] static void InitializeGpioFlowControl(UARTDRV_Handle_t handle) ^ make: *** [dependencies/emdrv/uartdrv/src/uartdrv.o] Error 1
Please fix this in the next UARTDRV version.
Solved! Go to Solution.
07-06-2016 08:46 AM
Sorry about this, somehow it went unnoticed by our internal testing procedures. We've already discovered and fixed this internally, and the fix will be in place in the next version of the SDK. For now, please leave the define enabled.
07-06-2016 10:54 AM - edited 07-06-2016 10:57 AM
Thank you @asmellby for the reply. Can you give me an estimate as to when the fix is going to be released?
By the way, there is another compilation issue with regards to UARTDRV. When using GCC's pedantic setting, it gives an error because it sees the last member of UARTDRV_Buffer_FifoQueue_t as a zero-length array.
All it takes to fix it is to either specify it as a one-byte array, like this:
UARTDRV_Buffer_t fifo; ///< FIFO of queue data.
Or you could also have GCC ignore this problem by adding some #pragma preprocessor directives:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
UARTDRV_Buffer_t fifo; ///< FIFO of queue data.
#pragma GCC diagnostic pop
Could you guys please add one of these fixes to UARTDRV as well?
07-06-2016 11:20 AM
We're currently not planning to do a patch release for this fix, and during summer things move a little more slowly than the rest of the year, so I can't promise a release date. Normally I wouldn't recommend this, but the fix is so easy that you could patch the release yourself if you're comfortable with that. All you need to do is to add the #if EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE guard around the two functions "InitializeGpioFlowControl" and "SetHandleIndex". They should have been excluded from the build when disabling flow control, but aren't.
Regarding the flexible array member in the UARTDRV_Buffer_FifoQueue_t: Thanks for reporting this. We'll see how we best can resolve this, considering that a flexible array member declared this way is explicitly allowed in C99.
07-06-2016 11:36 AM
I patched it for myself locally and it now compiles correctly. Thanks!
Regarding the fifo queue: yes, I know it's valid C99 and I personally believe that the C and C++ standards committees should coordinate more closely to support stuff like this, but right now (as of C++11 at least) it is just one of many small details that are valid C but isn't considered valid C++.
I just added the 3-line #pragma solution, and it'd be great if you guys could sort it out too. All the rest of the emlib/emdrv headers that I have used so far did work with C++, this is the first one that didn't.