libnx  v4.2.0
Data Structures | Enumerations | Functions
uart.h File Reference

UART service IPC wrapper. More...

#include "../types.h"
#include "../kernel/event.h"
#include "../sf/service.h"

Go to the source code of this file.

Data Structures

struct  UartPortSession
 PortSession. More...
 

Enumerations

enum  UartPort {
  UartPort_Bluetooth = 1,
  UartPort_JoyConR = 2,
  UartPort_JoyConL = 3,
  UartPort_MCU = 4
}
 UartPort. More...
 
enum  UartPortForDev {
  UartPortForDev_JoyConR = 1,
  UartPortForDev_JoyConL = 2,
  UartPortForDev_Bluetooth = 3
}
 UartPortForDev. More...
 
enum  UartFlowControlMode {
  UartFlowControlMode_None = 0,
  UartFlowControlMode_Hardware = 1
}
 FlowControlMode. More...
 
enum  UartPortEventType {
  UartPortEventType_SendBufferEmpty = 0,
  UartPortEventType_SendBufferReady = 1,
  UartPortEventType_ReceiveBufferReady = 2,
  UartPortEventType_ReceiveEnd = 3
}
 PortEventType. More...
 

Functions

Result uartInitialize (void)
 Initialize uart.
 
void uartExit (void)
 Exit uart.
 
ServiceuartGetServiceSession (void)
 Gets the Service object for the actual uart service session.
 
Result uartHasPort (UartPort port, bool *out)
 HasPort. More...
 
Result uartHasPortForDev (UartPortForDev port, bool *out)
 HasPortForDev. More...
 
Result uartIsSupportedBaudRate (UartPort port, u32 baud_rate, bool *out)
 IsSupportedBaudRate. More...
 
Result uartIsSupportedBaudRateForDev (UartPortForDev port, u32 baud_rate, bool *out)
 IsSupportedBaudRateForDev. More...
 
Result uartIsSupportedFlowControlMode (UartPort port, UartFlowControlMode flow_control_mode, bool *out)
 IsSupportedFlowControlMode. More...
 
Result uartIsSupportedFlowControlModeForDev (UartPortForDev port, UartFlowControlMode flow_control_mode, bool *out)
 IsSupportedFlowControlModeForDev. More...
 
Result uartCreatePortSession (UartPortSession *s)
 Creates an UartPortSession. More...
 
Result uartIsSupportedPortEvent (UartPort port, UartPortEventType port_event_type, bool *out)
 IsSupportedPortEvent. More...
 
Result uartIsSupportedPortEventForDev (UartPortForDev port, UartPortEventType port_event_type, bool *out)
 IsSupportedPortEventForDev. More...
 
Result uartIsSupportedDeviceVariation (UartPort port, u32 device_variation, bool *out)
 IsSupportedDeviceVariation. More...
 
Result uartIsSupportedDeviceVariationForDev (UartPortForDev port, u32 device_variation, bool *out)
 IsSupportedDeviceVariationForDev. More...
 
IPortSession
void uartPortSessionClose (UartPortSession *s)
 Close an UartPortSession. More...
 
Result uartPortSessionOpenPort (UartPortSession *s, bool *out, UartPort port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void *send_buffer, u64 send_buffer_length, void *receive_buffer, u64 receive_buffer_length)
 OpenPort. More...
 
Result uartPortSessionOpenPortForDev (UartPortSession *s, bool *out, UartPortForDev port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void *send_buffer, u64 send_buffer_length, void *receive_buffer, u64 receive_buffer_length)
 OpenPortForDev. More...
 
Result uartPortSessionGetWritableLength (UartPortSession *s, u64 *out)
 GetWritableLength. More...
 
Result uartPortSessionSend (UartPortSession *s, const void *in_data, size_t size, u64 *out)
 Send. More...
 
Result uartPortSessionGetReadableLength (UartPortSession *s, u64 *out)
 GetReadableLength. More...
 
Result uartPortSessionReceive (UartPortSession *s, void *out_data, size_t size, u64 *out)
 Receive. More...
 
Result uartPortSessionBindPortEvent (UartPortSession *s, UartPortEventType port_event_type, s64 threshold, bool *out, Event *out_event)
 BindPortEvent. More...
 
Result uartPortSessionUnbindPortEvent (UartPortSession *s, UartPortEventType port_event_type, bool *out)
 UnbindPortEvent. More...
 

Detailed Description

UART service IPC wrapper.

Author
yellows8

Enumeration Type Documentation

◆ UartFlowControlMode

FlowControlMode.

Enumerator
UartFlowControlMode_None 

None.

UartFlowControlMode_Hardware 

Hardware.

◆ UartPort

enum UartPort

UartPort.

Enumerator
UartPort_Bluetooth 

Bluetooth.

UartPort_JoyConR 

Joy-Con(R)

UartPort_JoyConL 

Joy-Con(L)

UartPort_MCU 

MCU.

◆ UartPortEventType

PortEventType.

Enumerator
UartPortEventType_SendBufferEmpty 

SendBufferEmpty.

UartPortEventType_SendBufferReady 

SendBufferReady.

UartPortEventType_ReceiveBufferReady 

ReceiveBufferReady.

UartPortEventType_ReceiveEnd 

ReceiveEnd.

◆ UartPortForDev

UartPortForDev.

Enumerator
UartPortForDev_JoyConR 

Joy-Con(R)

UartPortForDev_JoyConL 

Joy-Con(L)

UartPortForDev_Bluetooth 

Bluetooth.

Function Documentation

◆ uartCreatePortSession()

Result uartCreatePortSession ( UartPortSession s)

Creates an UartPortSession.

Note
Use uartPortSessionOpenPort or uartPortSessionOpenPortForDev before using any other cmds.
Parameters
[out]sUartPortSession

◆ uartHasPort()

Result uartHasPort ( UartPort  port,
bool *  out 
)

HasPort.

Parameters
[in]portUartPort
[out]outOutput success flag.

◆ uartHasPortForDev()

Result uartHasPortForDev ( UartPortForDev  port,
bool *  out 
)

HasPortForDev.

Parameters
[in]portUartPortForDev
[out]outOutput success flag.

◆ uartIsSupportedBaudRate()

Result uartIsSupportedBaudRate ( UartPort  port,
u32  baud_rate,
bool *  out 
)

IsSupportedBaudRate.

Parameters
[in]portUartPort
[in]baud_rateBaudRate
[out]outOutput success flag.

◆ uartIsSupportedBaudRateForDev()

Result uartIsSupportedBaudRateForDev ( UartPortForDev  port,
u32  baud_rate,
bool *  out 
)

IsSupportedBaudRateForDev.

Parameters
[in]portUartPortForDev
[in]baud_rateBaudRate
[out]outOutput success flag.

◆ uartIsSupportedDeviceVariation()

Result uartIsSupportedDeviceVariation ( UartPort  port,
u32  device_variation,
bool *  out 
)

IsSupportedDeviceVariation.

Note
Only available on [7.0.0+].
Parameters
[in]portUartPort
[in]device_variationDeviceVariation
[out]outOutput success flag.

◆ uartIsSupportedDeviceVariationForDev()

Result uartIsSupportedDeviceVariationForDev ( UartPortForDev  port,
u32  device_variation,
bool *  out 
)

IsSupportedDeviceVariationForDev.

Note
Only available on [7.0.0+].
Parameters
[in]portUartPortForDev
[in]device_variationDeviceVariation
[out]outOutput success flag.

◆ uartIsSupportedFlowControlMode()

Result uartIsSupportedFlowControlMode ( UartPort  port,
UartFlowControlMode  flow_control_mode,
bool *  out 
)

IsSupportedFlowControlMode.

Parameters
[in]portUartPort
[in]flow_control_modeUartFlowControlMode
[out]outOutput success flag.

◆ uartIsSupportedFlowControlModeForDev()

Result uartIsSupportedFlowControlModeForDev ( UartPortForDev  port,
UartFlowControlMode  flow_control_mode,
bool *  out 
)

IsSupportedFlowControlModeForDev.

Parameters
[in]portUartPortForDev
[in]flow_control_modeUartFlowControlMode
[out]outOutput success flag.

◆ uartIsSupportedPortEvent()

Result uartIsSupportedPortEvent ( UartPort  port,
UartPortEventType  port_event_type,
bool *  out 
)

IsSupportedPortEvent.

Parameters
[in]portUartPort
[in]port_event_typeUartPortEventType
[out]outOutput success flag.

◆ uartIsSupportedPortEventForDev()

Result uartIsSupportedPortEventForDev ( UartPortForDev  port,
UartPortEventType  port_event_type,
bool *  out 
)

IsSupportedPortEventForDev.

Parameters
[in]portUartPortForDev
[in]port_event_typeUartPortEventType
[out]outOutput success flag.

◆ uartPortSessionBindPortEvent()

Result uartPortSessionBindPortEvent ( UartPortSession s,
UartPortEventType  port_event_type,
s64  threshold,
bool *  out,
Event out_event 
)

BindPortEvent.

Note
The Event must be closed by the user after using uartPortSessionUnbindPortEvent.
Parameters
sUartPortSession
[in]port_event_typeUartPortEventType
[in]thresholdThreshold
[out]outOutput success flag.
[out]out_eventOutput Event with autoclear=false.

◆ uartPortSessionClose()

void uartPortSessionClose ( UartPortSession s)

Close an UartPortSession.

Parameters
sUartPortSession

◆ uartPortSessionGetReadableLength()

Result uartPortSessionGetReadableLength ( UartPortSession s,
u64 out 
)

GetReadableLength.

Parameters
sUartPortSession
[out]outOutput ReadableLength.

◆ uartPortSessionGetWritableLength()

Result uartPortSessionGetWritableLength ( UartPortSession s,
u64 out 
)

GetWritableLength.

Parameters
sUartPortSession
[out]outOutput WritableLength.

◆ uartPortSessionOpenPort()

Result uartPortSessionOpenPort ( UartPortSession s,
bool *  out,
UartPort  port,
u32  baud_rate,
UartFlowControlMode  flow_control_mode,
u32  device_variation,
bool  is_invert_tx,
bool  is_invert_rx,
bool  is_invert_rts,
bool  is_invert_cts,
void *  send_buffer,
u64  send_buffer_length,
void *  receive_buffer,
u64  receive_buffer_length 
)

OpenPort.

Note
This is not usable when the specified UartPort is already being used.
Parameters
sUartPortSession
[out]outOutput success flag.
[in]portUartPort
[in]baud_rateBaudRate
[in]flow_control_modeUartFlowControlMode
[in]device_variation[7.0.0+] DeviceVariation
[in]is_invert_tx[6.0.0+] IsInvertTx
[in]is_invert_rx[6.0.0+] IsInvertRx
[in]is_invert_rts[6.0.0+] IsInvertRts
[in]is_invert_cts[6.0.0+] IsInvertCts
[in]send_bufferSend buffer, must be 0x1000-byte aligned.
[in]send_buffer_lengthSend buffer size, must be 0x1000-byte aligned.
[in]receive_bufferReceive buffer, must be 0x1000-byte aligned.
[in]receive_buffer_lengthReceive buffer size, must be 0x1000-byte aligned.

◆ uartPortSessionOpenPortForDev()

Result uartPortSessionOpenPortForDev ( UartPortSession s,
bool *  out,
UartPortForDev  port,
u32  baud_rate,
UartFlowControlMode  flow_control_mode,
u32  device_variation,
bool  is_invert_tx,
bool  is_invert_rx,
bool  is_invert_rts,
bool  is_invert_cts,
void *  send_buffer,
u64  send_buffer_length,
void *  receive_buffer,
u64  receive_buffer_length 
)

OpenPortForDev.

Note
See the notes for uartPortSessionOpenPort.
Parameters
sUartPortSession
[out]outOutput success flag.
[in]portUartPortForDev
[in]baud_rateBaudRate
[in]flow_control_modeUartFlowControlMode
[in]device_variation[7.0.0+] DeviceVariation
[in]is_invert_tx[6.0.0+] IsInvertTx
[in]is_invert_rx[6.0.0+] IsInvertRx
[in]is_invert_rts[6.0.0+] IsInvertRts
[in]is_invert_cts[6.0.0+] IsInvertCts
[in]send_bufferSend buffer, must be 0x1000-byte aligned.
[in]send_buffer_lengthSend buffer size, must be 0x1000-byte aligned.
[in]receive_bufferReceive buffer, must be 0x1000-byte aligned.
[in]receive_buffer_lengthReceive buffer size, must be 0x1000-byte aligned.

◆ uartPortSessionReceive()

Result uartPortSessionReceive ( UartPortSession s,
void *  out_data,
size_t  size,
u64 out 
)

Receive.

Parameters
sUartPortSession
[out]out_dataOutput data buffer.
[in]sizeOutput data buffer size.
[out]outOutput size.

◆ uartPortSessionSend()

Result uartPortSessionSend ( UartPortSession s,
const void *  in_data,
size_t  size,
u64 out 
)

Send.

Parameters
sUartPortSession
[in]in_dataInput data buffer.
[in]sizeInput data buffer size.
[out]outOutput size.

◆ uartPortSessionUnbindPortEvent()

Result uartPortSessionUnbindPortEvent ( UartPortSession s,
UartPortEventType  port_event_type,
bool *  out 
)

UnbindPortEvent.

Parameters
sUartPortSession
[in]port_event_typeUartPortEventType
[out]outOutput success flag.