On 9/30/2024 12:25 PM, michal.lyszc...@bofc.pl wrote:
On 2024-09-30 12:51:06, Matteo Golin wrote:
Hello,
I did find a function called `stm32_get_uart()` which returns the UART
device; this is more what I am looking for. It doesn't seem like most
other platforms implement a similar function though, and I'm not sure if
it is good design to require that an architecture first implement
something similar before being able to use this driver. I don't want to
introduce this pattern to NuttX without first checking for other
suggestions.
Whatever Greg said, plus from me: your lora chip is mcu agnostic, so do
not use anything from the arch/ to implement the driver. There should be
absolutely zero arch related code in that driver.
This will allow driver to be used with any MCU that has serial interface.
Also design your rn2483_init() funtion driver to accept struct to initialized
serial driver. It's not your drivers responsibility to initialize serial
device, it should be provided to you by code in boards/ directory. So
in pseudocode it would look like this
stm32_init_rn2483() {
struct serial *serial;
/* get serial device specific to the board, one board will use USART1
* other might user USART2. Decision which uart to use depends on board
* hardware wiring and may be different even for the very same mcu */
serial = stm32_get_serial_for_lora();
/* initialize rn2483 lora driver and give it handle to the serial device,
* rn2483 driver can immediately use it from on to initialize the rn2483
* chip driver */
rn2483_init(serial);
}
Yep... There is also a an existing (SPI-based) LoRa driver at
drivers/wireless/lpwan. You LoRa driver should go in that same directory.