Hello,
I'm using Ceedling, Unity + CMock to implement unit tests but I'm running into issues when it comes to mocking nrf_drv_gpiote.h.
I'm trying to test a file, call it foo.c, which includes nrf_drv_gpiote.h, therefore in my test (test_foo.c) I'll include "mock_nrf_drv_gpiote.h".
The problem is that when Ceedling builds the test I have the following kind of errors :
components/drivers_nrf/hal/nrf_gpiote.h:71:32: error: 'GPIOTE_CONFIG_POLARITY_LoToHi' undeclared here (not in a function)
I understand where this error comes from but I don't know how to get rid of it. Basically, 'GPIOTE_CONFIG_POLARITY_LoToHi' is defined in nrf52840_bitfields.h, which is included by nrf.h if _WIN32 is not defined (see the code below), but _WIN32 is automatically defined when building on Windows. So how can I run my unit test on Windows if nrf.h doesn't allow me to include what's necessary to mock nrf_drv_gpiote.h ?
As a side note, I know that some people already requested this on this forum but if you could provide a minimalist Ceedling environment (or any other test framework) for unit tests it would be greatly appreciated !
Code in nrf.h that prevents from including nrf52840_bitfields.h :
if defined(_WIN32)
/* Do not include nrf specific files when building for PC host */
#elif defined(__unix)
/* Do not include nrf specific files when building for PC host */
#elif defined(__APPLE__)
/* Do not include nrf specific files when building for PC host */
#else
/* Device selection for device includes. */
#if defined (NRF51)
#include "nrf51.h"
#include "nrf51_bitfields.h"
#include "nrf51_deprecated.h"
#elif defined (NRF52840_XXAA)
#include "nrf52840.h"
#include "nrf52840_bitfields.h"
#include "nrf51_to_nrf52840.h"
#include "nrf52_to_nrf52840.h"
#elif defined (NRF52832_XXAA)
#include "nrf52.h"
#include "nrf52_bitfields.h"
#include "nrf51_to_nrf52.h"
#include "nrf52_name_change.h"
#else
#error "Device must be defined. See nrf.h."
#endif /* NRF51, NRF52832_XXAA, NRF52840_XXAA */
#include "compiler_abstraction.h"
#endif /* _WIN32 || __unix || __APPLE__ */