Platform interface

The platform interface

The platform interface is the part of eLua that makes it easily portable between different hardware platforms by grouping the common elements of all platforms supported by eLua in a common interface. For more details about the platform interface and the overall structure of eLua in general, check this link.

The platform interface is defined in the inc/platform.h header file from the eLua source distribution. It is a collection of various components (UART, SPI, timers ...), each of them is detailed in the next subsections. Each such component has an id which is a number that identifies that component in eLua. Generally, numbers are assigned to components in their "natural" order; for example, PORTA will have the id 0, PORTB will have 1 and so on. Similarly, the second SPI interface (SPI1) of the MCU will probably have an id equal to 1. However, this is not a strict rule. The implementation of the platform interface might choose to expose only some of the peripherals (components) of the MCU, thus this rule might be broken. For example, if a board has 3 UARTs, but for some reason the second UART (UART1) is dedicated and can't be touched by eLua, then UART0 will have the id 0 and UART2 will have the id 1, so UART1 won't ever be accesible to the code.

With some exceptions (most notably the low-level support functions), the different modules supported by the platform interface are mirrored more or less accurately in separate Lua modules that can be used directly from eLua. Check the reference manual for a complete description of these modules.