LP-480 pios board com port setup refactoring

Merged
#418 · Created  · Last updated

Merged pull request

Merged in mindnever/librepilot/LP-480_pios_board_com_port_setup_refactoring (pull request #418)

1a28929·Author: ·Closed by: ·2017-05-15

Description

This is more than just com port setup refactoring, yet it is far from ideal solution. It is hopefully manageable for reviewing, yet enough to simplify adding new hardware. F3 branch is first to benefit from these new board support APIs.

Here are the most significant changes:

  1. Deletes .irq and .init members from struct pios_usart_cfg - IRQ handler and NVIC configuration is internal detail of usart implementation, which depends on USART instance in use. There is ioctl API for changing IRQ priority. - Usart is now initialized to common sane default (9600 8N1). It is now up to usart consumer (module or lower level pios component) to set required comm parameters (which turns out to be only baud rate for most of the time, except few odd protocols (like SBUS) that require different config). PIOS_COM and com driver api both expose methods for changing configuration.

  2. Moves com parameter configuration responsibility to pios components and other modules. Changes them appropriately.

  3. Moves USB, COM, RF and Sensors setup from pios_board.c (all targets) to pios/common/pios_board_io.c and pios_board_sensors.c

  4. pios_board_sensors.c now include all supported sensors on all supported buses (SPI, I2C and ADC). There are PIOS_BOARD_HW_DEFS_Get(sensor)Cfg() methods that accept board revision in order to decide at runtime how and if the sensor should be configured. This is the place for new sensors (internal and external) to add in order to have them supported across desired targets.

  5. pios_board_io.c contains unified USART, USB and RF code. Due to different enum values for usart functions across HwSettings object, there is new enum defined, which now require mapping tables to exist in each pios_board.c. Note that this is transitional solution. Correct one would be to make all HwSettings enums that deal with serial ports to have same numerical values (i.e. to be inherited from some other common type. See how TL/DR has done it - looks clean, but inheritance implementation is not trivial feature, esp on gcs and code generator side). pios_board_io.c is the file to add new serial protocols and modules, such as various receivers and telemetry modules.

  6. Cleans up USB configuration. Takes endpoint configuration out of board_hw_defs.c back where it belongs - next to the configuration descriptor. The reason being, the config has to match the descriptor, and descriptor being always the same (hid+cdc or hid-only), there is no reason for having multiple copies of (alway same) endpoint configurations (those are tiny structures that just list which endpoint number is used in CDC and HID classes and help their drivers install endpoint callbacks at correct places).

0 attachments

0 comments

Loading commits...