mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 14:03:55 +01:00
19538: drivers/mtd_default: add external declarations for mtd* r=benpicco a=gschorcht
### Contribution description
The `mtd_default` module defines `MTD_NUMOF`, if not present, based on the `MTD_*` defines. These defines are set to the corresponding `mtd*` MTD device pointer variables in the board definitions. However, not all `mtd*` MTD device pointer variables are always made known by external variable declarations. An example are SD Card Interfaces that are defined via the `mtd_sdcard_default` module. As a result, it may be necessary for an application using `mtd_default` to declare an external MTD device pointer variable `mtd`. To be able to use SD card for testing MTD based application, `mtd_default` also declares up to six `mtd*` MTD device pointer variables.
### Testing procedure
Use any board without SD Card definition and compile `tests/pkg_litllefs`, `tests/pkg_litllefs2` or `tests/pkg_spiffs`, for example to use a temporary connected SD Card interface.
```
CFLAGS='-DMTD_0=mtd0 -DCONFIG_USE_HARDWARE_MTD' USEMODULE='sdcard_spi mtd_sdcard_default' BOARD=nucleo-f411re make -j8 -C tests/pkg_littlefs
```
Without this PR, compilation fails due to undeclared `mtd0` variable
```
tests/pkg_littlefs/bin/nucleo-f411re/riotbuild/riotbuild.h:2:15: error: 'mtd0' undeclared (first use in this function)
2 | #define MTD_0 mtd0
| ^~~~
```
Compilation works with this PR and the temporary connected SD Card interface can be used with this test applications.
### Issues/PRs references
19547: pkg/openthread: set event callback before netdev init r=benpicco a=bergzand
### Contribution description
When using openthread with the ieee802154_submac module, a hard fault is triggered otherwise because the submac's init function calls the event_handler callback.
### Testing procedure
Flash the `examples/openthread` application on the nrf52840dk board. Without this patch the board is stuck in a hard fault loop. With this patch the application starts successfully.
### Issues/PRs references
None
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Koen Zandberg <koen@bergzand.net>
This commit is contained in:
commit
ecc324998a
@ -57,6 +57,31 @@ extern "C" {
|
||||
|
||||
#endif /* !defined(MTD_NUMOF) && !DOXYGEN */
|
||||
|
||||
#if !DOXYGEN
|
||||
|
||||
/**
|
||||
* @brief Declare `mtd*` according to the number of MTD devices
|
||||
*/
|
||||
#if MTD_NUMOF > 0
|
||||
extern mtd_dev_t *mtd0;
|
||||
#endif
|
||||
#if MTD_NUMOF > 1
|
||||
extern mtd_dev_t *mtd1;
|
||||
#endif
|
||||
#if MTD_NUMOF > 2
|
||||
extern mtd_dev_t *mtd2;
|
||||
#endif
|
||||
#if MTD_NUMOF > 3
|
||||
extern mtd_dev_t *mtd3;
|
||||
#endif
|
||||
#if MTD_NUMOF > 4
|
||||
extern mtd_dev_t *mtd4;
|
||||
#endif
|
||||
#if MTD_NUMOF > 5
|
||||
extern mtd_dev_t *mtd5;
|
||||
#endif
|
||||
#endif /* !DOXYGEN */
|
||||
|
||||
#if defined(MODULE_MTD_SDCARD_DEFAULT)
|
||||
extern mtd_sdcard_t mtd_sdcard_dev0;
|
||||
#endif
|
||||
|
||||
@ -84,8 +84,8 @@ static void *_openthread_event_loop(void *arg)
|
||||
|
||||
event_queue_init(&ev_queue);
|
||||
|
||||
netdev->driver->init(netdev);
|
||||
netdev->event_callback = _event_cb;
|
||||
netdev->driver->init(netdev);
|
||||
|
||||
netopt_enable_t enable = NETOPT_ENABLE;
|
||||
netdev->driver->set(netdev, NETOPT_TX_END_IRQ, &enable, sizeof(enable));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user