suikan4github / murasaki

STM32 HAL class library
MIT License
17 stars 3 forks source link

Conditional compile on debug port. #143

Closed suikan4github closed 2 years ago

suikan4github commented 2 years ago

Is your feature request related to a problem? Please describe. At the demonstration on the Nucleo board, some times programmer must modify the init_platform(). For example, debug port name is different between the Nucleo project template, while the init_platform() uses a hardcoded name.

Thus, sometimes compile error is shown at first time, for example on the Nucleo-G431RE.

The error is OK for the none Nucleo board because init_platform() has to be customized by the programmer for each board. But for the demonstration, it is not comfortable.

Describe the solution you'd like In the current implementation, the port name is hardcoded. https://github.com/suikan4github/murasaki/blob/84f391b99617027151565349012e5fc367da857e/template/murasaki_platform.cpp#L49

It should be changed to like this :

#ifdef STM32G431xx
extern UART_HandleTypeDef hlpuart1;
#define HDEBUGPORT hlpuart1
#elseif defined( STM32F446xx )
extern UART_HandleTypeDef huart2;
#define HDEBUGPORT huart2
#elseif ...

 ...

murasaki::platform.uart_console = new murasaki::DebuggerUart(&HDEBUGPORT);

We can do it same way for the status LED.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

suikan4github commented 2 years ago

Merged to develop. Ready to release.