mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
POC
This commit is contained in:
parent
6a2bcbad27
commit
fb8c29a5ff
3 changed files with 37 additions and 3 deletions
|
@ -1594,13 +1594,41 @@ static int luaMultiBuffer(lua_State * L)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*luadoc
|
||||||
|
@function serialSetup(port, baudrate)
|
||||||
|
|
||||||
|
@param port (number) ID of the port you want to setup. (AUX1: 0, AUX2:1)
|
||||||
|
|
||||||
|
@param baudrate (number) baudrate for the port
|
||||||
|
|
||||||
|
@status current Introduced in 2.3.10
|
||||||
|
*/
|
||||||
|
static int luaSerialSetup(lua_State * L)
|
||||||
|
{
|
||||||
|
uint8_t port = luaL_checkunsigned(L, 1);
|
||||||
|
uint16_t baudrate = luaL_checkunsigned(L, 2);
|
||||||
|
|
||||||
|
#if !defined(SIMU)
|
||||||
|
#if defined(AUX_SERIAL)
|
||||||
|
if (port == 0)
|
||||||
|
auxSerialSetup(baudrate, false);
|
||||||
|
#endif
|
||||||
|
#if defined(AUX2_SERIAL)
|
||||||
|
if (port == 1)
|
||||||
|
aux2SerialSetup(baudrate, false);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*luadoc
|
/*luadoc
|
||||||
@function serialWrite(str)
|
@function serialWrite(str)
|
||||||
@param str (string) String to be written to the serial port.
|
@param str (string) String to be written to the serial port.
|
||||||
|
|
||||||
Writes a string to the serial port. The string is allowed to contain any character, including 0.
|
Writes a string to the serial port. The string is allowed to contain any character, including 0.
|
||||||
|
|
||||||
@status current Introduced in TODO
|
@status current Introduced in 2.3.8
|
||||||
*/
|
*/
|
||||||
static int luaSerialWrite(lua_State * L)
|
static int luaSerialWrite(lua_State * L)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ uint8_t auxSerialMode = 0;
|
||||||
Fifo<uint8_t, 512> auxSerialTxFifo;
|
Fifo<uint8_t, 512> auxSerialTxFifo;
|
||||||
AuxSerialRxFifo auxSerialRxFifo __DMA (AUX_SERIAL_DMA_Stream_RX);
|
AuxSerialRxFifo auxSerialRxFifo __DMA (AUX_SERIAL_DMA_Stream_RX);
|
||||||
|
|
||||||
void auxSerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1)
|
void auxSerialSetup(unsigned int baudrate, bool dma, uint16_t lenght, uint16_t parity, uint16_t stop)
|
||||||
{
|
{
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
@ -230,7 +230,7 @@ uint8_t aux2SerialMode = 0;
|
||||||
Fifo<uint8_t, 512> aux2SerialTxFifo;
|
Fifo<uint8_t, 512> aux2SerialTxFifo;
|
||||||
AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX);
|
AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX);
|
||||||
|
|
||||||
void aux2SerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1)
|
void aux2SerialSetup(unsigned int baudrate, bool dma, uint16_t lenght, uint16_t parity, uint16_t stop)
|
||||||
{
|
{
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
|
|
@ -637,6 +637,9 @@ void sportUpdatePowerInit();
|
||||||
#if defined(AUX_SERIAL_GPIO)
|
#if defined(AUX_SERIAL_GPIO)
|
||||||
#define DEBUG_BAUDRATE 115200
|
#define DEBUG_BAUDRATE 115200
|
||||||
extern uint8_t auxSerialMode;
|
extern uint8_t auxSerialMode;
|
||||||
|
#if defined __cplusplus
|
||||||
|
void auxSerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1);
|
||||||
|
#endif
|
||||||
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
||||||
void auxSerialPutc(char c);
|
void auxSerialPutc(char c);
|
||||||
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
||||||
|
@ -656,6 +659,9 @@ void auxSerialPowerOff();
|
||||||
// Aux2 serial port driver
|
// Aux2 serial port driver
|
||||||
#if defined(AUX2_SERIAL)
|
#if defined(AUX2_SERIAL)
|
||||||
extern uint8_t aux2SerialMode;
|
extern uint8_t aux2SerialMode;
|
||||||
|
#if defined __cplusplus
|
||||||
|
void aux2SerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1);
|
||||||
|
#endif
|
||||||
void aux2SerialInit(unsigned int mode, unsigned int protocol);
|
void aux2SerialInit(unsigned int mode, unsigned int protocol);
|
||||||
void aux2SerialPutc(char c);
|
void aux2SerialPutc(char c);
|
||||||
#define aux2SerialTelemetryInit(protocol) aux2SerialInit(UART_MODE_TELEMETRY, protocol)
|
#define aux2SerialTelemetryInit(protocol) aux2SerialInit(UART_MODE_TELEMETRY, protocol)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue