NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
serial.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <platform.h>
#include "build_config.h"
#include "common/utils.h"
#include "drivers/system.h"
#include "drivers/serial.h"
#include "drivers/serial_softserial.h"
#include "drivers/serial_uart.h"
#include "drivers/serial_usb_vcp.h"
#include "io/serial.h"
#include "cli.h"
#include "serial_msp.h"
#include "config/config.h"
Include dependency graph for serial.c:

Data Structures

struct  findSerialPortConfigState_s
 
struct  findSharedSerialPortState_s
 

Macros

#define BAUD_RATE_COUNT   (sizeof(baudRates) / sizeof(baudRates[0]))
 
#define ALL_TELEMETRY_FUNCTIONS_MASK   (FUNCTION_TELEMETRY_FRSKY | FUNCTION_TELEMETRY_HOTT | FUNCTION_TELEMETRY_SMARTPORT | FUNCTION_TELEMETRY_LTM | FUNCTION_TELEMETRY_MAVLINK)
 
#define ALL_FUNCTIONS_SHARABLE_WITH_MSP   (FUNCTION_BLACKBOX | ALL_TELEMETRY_FUNCTIONS_MASK)
 

Typedefs

typedef struct
findSerialPortConfigState_s 
findSerialPortConfigState_t
 
typedef struct
findSharedSerialPortState_s 
findSharedSerialPortState_t
 

Functions

baudRate_e lookupBaudRateIndex (uint32_t baudRate)
 
const struct serial_port_configfindSerialPortConfig (const struct serial_config *self, serialPortFunction_e function)
 
const struct serial_port_configfindNextSerialPortConfig (const struct serial_config *self, serialPortFunction_e function)
 
portSharing_e determinePortSharing (const struct serial_port_config *portConfig, serialPortFunction_e function)
 
bool isSerialPortShared (const struct serial_port_config *portConfig, uint16_t functionMask, serialPortFunction_e sharedWithFunction)
 
bool isSerialPortOpen (const struct serial_port_config *portConfig)
 
serialPort_tfindSharedSerialPort (const struct serial_config *self, uint16_t functionMask, serialPortFunction_e sharedWithFunction)
 
serialPort_tfindNextSharedSerialPort (const struct serial_config *self, uint16_t functionMask, serialPortFunction_e sharedWithFunction)
 
bool isSerialConfigValid (const struct serial_config *serialConfigToCheck)
 
const struct serial_port_configserialFindPortConfiguration (const struct serial_config *self, serialPortIdentifier_e identifier)
 
bool doesConfigurationUsePort (const struct serial_config *self, serialPortIdentifier_e identifier)
 
serialPort_topenSerialPort (serialPortIdentifier_e identifier, serialPortFunction_e function, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, portOptions_t options)
 
void closeSerialPort (serialPort_t *serialPort)
 
void serialInit (bool softserialEnabled)
 
void serialRemovePort (serialPortIdentifier_e identifier)
 
uint8_t serialGetAvailablePortCount (void)
 
bool serialIsPortAvailable (serialPortIdentifier_e identifier)
 
void waitForSerialPortToFinishTransmitting (serialPort_t *serialPort)
 

Variables

uint8_t serialPortCount
 
const uint32_t baudRates [] = {0, 9600, 19200, 38400, 57600, 115200, 230400, 250000}
 

Macro Definition Documentation

#define ALL_FUNCTIONS_SHARABLE_WITH_MSP   (FUNCTION_BLACKBOX | ALL_TELEMETRY_FUNCTIONS_MASK)
#define BAUD_RATE_COUNT   (sizeof(baudRates) / sizeof(baudRates[0]))

Typedef Documentation

Function Documentation

void closeSerialPort ( serialPort_t serialPort)
portSharing_e determinePortSharing ( const struct serial_port_config portConfig,
serialPortFunction_e  function 
)
bool doesConfigurationUsePort ( const struct serial_config self,
serialPortIdentifier_e  identifier 
)

Here is the call graph for this function:

const struct serial_port_config* findNextSerialPortConfig ( const struct serial_config self,
serialPortFunction_e  function 
)
serialPort_t* findNextSharedSerialPort ( const struct serial_config self,
uint16_t  functionMask,
serialPortFunction_e  sharedWithFunction 
)

Here is the call graph for this function:

const struct serial_port_config* findSerialPortConfig ( const struct serial_config self,
serialPortFunction_e  function 
)

Here is the call graph for this function:

serialPort_t* findSharedSerialPort ( const struct serial_config self,
uint16_t  functionMask,
serialPortFunction_e  sharedWithFunction 
)

Here is the call graph for this function:

bool isSerialConfigValid ( const struct serial_config serialConfigToCheck)
bool isSerialPortOpen ( const struct serial_port_config portConfig)
bool isSerialPortShared ( const struct serial_port_config portConfig,
uint16_t  functionMask,
serialPortFunction_e  sharedWithFunction 
)
baudRate_e lookupBaudRateIndex ( uint32_t  baudRate)
serialPort_t* openSerialPort ( serialPortIdentifier_e  identifier,
serialPortFunction_e  function,
serialReceiveCallbackPtr  callback,
uint32_t  baudRate,
portMode_t  mode,
portOptions_t  options 
)

Here is the call graph for this function:

const struct serial_port_config* serialFindPortConfiguration ( const struct serial_config self,
serialPortIdentifier_e  identifier 
)
uint8_t serialGetAvailablePortCount ( void  )
void serialInit ( bool  softserialEnabled)
bool serialIsPortAvailable ( serialPortIdentifier_e  identifier)
void serialRemovePort ( serialPortIdentifier_e  identifier)
void waitForSerialPortToFinishTransmitting ( serialPort_t serialPort)

Here is the call graph for this function:

Variable Documentation

const uint32_t baudRates[] = {0, 9600, 19200, 38400, 57600, 115200, 230400, 250000}
uint8_t serialPortCount