Closed kisielk closed 1 year ago
Ok. It is actually not my scheme, but ST guys. They did things as they did.
You can follow the includes route starting from my usbd_midi.c
file:
usbd_midi.c
-> usbd_midi.h
-> usbd_ioreq.h
-> usbd_def.h
-> usbd_conf.h
-> main.h
Perhaps you are using some old ST libraries, that's why this issue occurs. But you can always put MIDI_IN_PORTS_NUM
and MIDI_OUT_PORTS_NUM
in usbd_desc.h
for example.
I'm using the latest HAL for STM32G0. I went down the chain and it seems that usbd_conf.h
doesn't include main.h
in a freshly-generated project. Maybe it would be better to suggest those defines go in there?
Actually I like more when all macros are located in one place in main.h
Anyway I've added alternative path for those defines below in the README as well
Sure. I'm gonna leave them in usbd_conf.h
since that's where all the other USB-related macros are, seems to make sense rather than having the USB stack depend on the application main.
Yes, this will be the best place to have them (logically). But usbd_conf.h
doesn't seem to have any "user sections". So, when you generate new code with CubeMX, you may lose these macros.
In mine it has this section:
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
#define MIDI_IN_PORTS_NUM 0x01 // Specify input ports number of your device
#define MIDI_OUT_PORTS_NUM 0x01 // Specify output ports number of your device
/* USER CODE END PV */
Interesting...)
Ok. I'll mention this file instead.
I followed the README and put
MIDI_IN_PORTS_NUM
andMIDI_OUT_PORTS_NUM
intomain.h
but I get an error when compilingusbd_midi.c
:I notice that file does not
#include "main.h"
anywhere so I'm not sure how it's supposed to pick up the number of ports based on your scheme?