Bus services: Difference between revisions

No edit summary
Line 116: Line 116:


== OpenSessionForDev ==
== OpenSessionForDev ==
Takes an u32 '''port''', an u16 '''addr''', an '''AddressingMode''' (1 for 10-bit, 0 otherwise) and a '''SpeedMode''' (400000 or 100000). Returns an [[#II2cSession]].
Takes an input u32 '''BusIdx''', an input u16 '''SlaveAddress''', and 2 input u32s [[#AddressingMode]] and [[#SpeedMode]]. Returns an [[#II2cSession]].


== OpenSession ==
== OpenSession ==
Takes an [[#I2cDevice]] and returns an [[#II2cSession]].
Takes an input u32 [[#I2cDevice]]. Returns an output [[#II2cSession]].


== HasDevice ==
== HasDevice ==
Takes an [[#I2cDevice]] and returns true if the device exists or false otherwise.
Takes an input u32 [[#I2cDevice]]. Returns an output boolean success value.


== HasDeviceForDev ==
== HasDeviceForDev ==
Takes an u32 '''port''', an u16 '''addr''', an '''AddressingMode''' (1 for 10-bit, 0 otherwise) and a '''SpeedMode''' (400000 or 100000). Returns true if the device exists or false otherwise.
Takes an input u32 '''BusIdx''', an input u16 '''SlaveAddress''', and 2 input u32s [[#AddressingMode]] and [[#SpeedMode]]. Returns an output boolean success value.


== OpenSession2 ==
== OpenSession2 ==
Same as [[#OpenSession_2|OpenSession]] but takes a [[#I2cDevice|DeviceCode]].
Same as [[#OpenSession_2|OpenSession]] but takes an input u32 [[#I2cDevice|DeviceCode]].


== II2cSession ==
== II2cSession ==
Line 137: Line 137:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || [1.0.0-5.1.0] Send
| 0 || [1.0.0-5.1.0] SendOld
|-
|-
| 1 || [1.0.0-5.1.0] Receive
| 1 || [1.0.0-5.1.0] ReceiveOld
|-
|-
| 2 || [1.0.0-5.1.0] ExecuteCommandList
| 2 || [1.0.0-5.1.0] ExecuteCommandListOld
|-
|-
| 10 || [[#SendAuto]]
| 10 || [[#Send]]
|-
|-
| 11 || ReceiveAuto
| 11 || [[#Receive]]
|-
|-
| 12 || [[#ExecuteCommandListAuto]]
| 12 || [[#ExecuteCommandList]]
|-
|-
| 13 || [6.0.0+] [[#SetRetryValues]]
| 13 || [6.0.0+] [[#SetRetryValues]]
|}
|}


== SendAuto ==
== Send ==
Takes bytes to write in either a static buffer or a receive buffer, returns an error code for success.
Takes a type-0x21 input buffer '''InData''' and an input u32 [[#TransactionOption]]. No output.


== ExecuteCommandListAuto ==
== Receive ==
Takes a command list from either a static buffer or a receive buffer, returns data in either a static (or recieve?) buffer.
Takes a type-0x22 output buffer '''OutData''' and an input u32 [[#TransactionOption]]. No output.
 
== ExecuteCommandList ==
Takes a type-0x22 output buffer '''ReceiveBuffer''' and a type-0x9 input buffer '''CommandList'''. No output.


=== Commands ===
=== Commands ===
The commands use the following bits
This is "nn::i2c::I2cCommand".
 
{| class=wikitable
{| class=wikitable
! Bit || Name
! Bits || Name
|-
|-
| 0 || Receive
| 0-5 || [[#CommandId]]
|-
|-
| 6 || I2cTransactionOption_Start
| 6-7 || [[#TransactionOption]]
|-
| 7 || I2cTransactionOption_Sop
|}
|}
* If bit 0 is not set, the command will write bytes to the device and follows this format: [u8 cmd] [u8 len] <bytes>
 
* If bit 0 is set, the command will receive bytes from the device and follows this format: [u8 cmd] [u8 len]
A send command will write bytes to the device using the format: [u8 cmd_send] [u8 len] <bytes>
 
A receive command will read bytes from the device using the format: [u8 cmd_receive] [u8 len]
 
An extension sleep command will stall the device using the format: [u8 cmd_extension] [u8 ms]


== SetRetryValues ==
== SetRetryValues ==
Takes 2 u32s '''MaxRetries''' and '''RetryDelay'''. Returns 0.
Takes 2 input u32s '''MaxRetries''' and '''RetryDelay'''. No output.


= uart =
= uart =
Line 212: Line 218:


== IsSupportedBaudRate ==
== IsSupportedBaudRate ==
Takes an input [[#UartPort]] and an input u32 '''BaudRate'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPort]] and '''BaudRate'''. Returns an output boolean success value.


Supported baud rates are 57600, 115200, 1000000 and 3000000.
Supported baud rates are 57600, 115200, 1000000 and 3000000.


== IsSupportedBaudRateForDev ==
== IsSupportedBaudRateForDev ==
Takes an input [[#UartPortForDev]] and an input u32 '''BaudRate'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPortForDev]] '''BaudRate'''. Returns an output boolean success value.


Supported baud rates are 57600, 115200, 1000000 and 3000000.
Supported baud rates are 57600, 115200, 1000000 and 3000000.


== IsSupportedFlowControlMode ==
== IsSupportedFlowControlMode ==
Takes an input [[#UartPort]] and an input u32 '''FlowControlMode'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPort]] and [[#FlowControlMode]]. Returns an output boolean success value.
 
Supported modes are 0 (RTS) and 1 (CTS).


== IsSupportedFlowControlModeForDev ==
== IsSupportedFlowControlModeForDev ==
Takes an input [[#UartPortForDev]] and an input u32 '''FlowControlMode'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPortForDev]] and [[#FlowControlMode]]. Returns an output boolean success value.
 
Supported modes are 0 (RTS) and 1 (CTS).


== CreatePortSession ==
== CreatePortSession ==
Line 235: Line 237:


== IsSupportedPortEvent ==
== IsSupportedPortEvent ==
Takes an input [[#UartPort]] and an input u32 '''PortEvent'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPort]] and [[#PortEventType]]. Returns an output boolean success value.
 
Supported events are 0 (data), 1 (break), 2 (unknown) and 3 (unknown).


== IsSupportedPortEventForDev ==
== IsSupportedPortEventForDev ==
Takes an input [[#UartPortForDev]] and an input u32 '''PortEvent'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPortForDev]] and [[#PortEventType]]. Returns an output boolean success value.
 
Supported events are 0 (data), 1 (break), 2 (unknown) and 3 (unknown).


== IsSupportedDeviceVariation ==
== IsSupportedDeviceVariation ==
Takes an input [[#UartPort]] and an input u32 '''DeviceVariation'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPort]] and '''DeviceVariation'''. Returns an output boolean success value.


Supported device variations are 0 (Bluetooth) for UART-D, 0 (Joy-Con(R)) for UART-B, 0 (Joy-Con(L)) and 1 (MCU) for UART-C.
Supported device variations are 0 (Bluetooth) for UART-D, 0 (Joy-Con(R)) for UART-B, 0 (Joy-Con(L)) and 1 (MCU) for UART-C.


== IsSupportedDeviceVariationForDev ==
== IsSupportedDeviceVariationForDev ==
Takes an input [[#UartPortForDev]] and an input u32 '''DeviceVariation'''. Returns an output boolean success value.
Takes 2 input u32s [[#UartPortForDev]] and '''DeviceVariation'''. Returns an output boolean success value.


Supported device variations are 0 (Bluetooth) for UART-D, 0 (Joy-Con(R)) for UART-B, 0 (Joy-Con(L)) and 1 (MCU) for UART-C.
Supported device variations are 0 (Bluetooth) for UART-D, 0 (Joy-Con(R)) for UART-B, 0 (Joy-Con(L)) and 1 (MCU) for UART-C.
Line 279: Line 277:


=== OpenPort ===
=== OpenPort ===
Takes an input [[#UartPort]], 2 input u32s '''BaudRate''' and '''FlowControlMode''', 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.
Takes 3 input u32s [[#UartPort]], '''BaudRate''' and [[#FlowControlMode]], 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.


[6.0.0+] Takes 4 input u8s (padded as u32) '''IsInvertTx''', '''IsInvertRx''', '''IsInvertRts''' and '''IsInvertCts''', an input [[#UartPort]], 2 input u32s '''BaudRate''' and '''FlowControlMode''', 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.
[6.0.0+] Takes 4 input u8s (padded as u32) '''IsInvertTx''', '''IsInvertRx''', '''IsInvertRts''' and '''IsInvertCts''', 3 input u32s [[#UartPort]], '''BaudRate''' and [[#FlowControlMode]], 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.


[7.0.0+] Takes 4 input u8s (padded as u32) '''IsInvertTx''', '''IsInvertRx''', '''IsInvertRts''' and '''IsInvertCts''', an input [[#UartPort]], 3 input u32s '''BaudRate''', '''FlowControlMode''' and '''DeviceVariation''', 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.
[7.0.0+] Takes 4 input u8s (padded as u32) '''IsInvertTx''', '''IsInvertRx''', '''IsInvertRts''' and '''IsInvertCts''', 4 input u32s [[#UartPort]], '''BaudRate''', [[#FlowControlMode]] and '''DeviceVariation''', 2 input u64s '''SendBufferLength''' and '''ReceiveBufferLength''' and 2 input TransferMemory handles '''SendHandle''' and '''ReceiveHandle'''. Returns an output boolean success value.


=== OpenPortForDev ===
=== OpenPortForDev ===
Line 292: Line 290:


=== Send ===
=== Send ===
Takes a type-0x21 input buffer '''DataBytes'''. Returns an output u64 size.
Takes a type-0x21 input buffer '''InData'''. Returns an output u64 size.


=== GetReadableLength ===
=== GetReadableLength ===
Line 298: Line 296:


=== Receive ===
=== Receive ===
Takes a type-0x22 output buffer '''DataBytes'''. Returns an output u64 size.
Takes a type-0x22 output buffer '''OutData'''. Returns an output u64 size.


=== BindPortEvent ===
=== BindPortEvent ===
Takes an input u32 '''PortEvent''' and an input s64 '''Threshold'''. Returns an output boolean success value and an Event handle with EventClearMode=0.
Takes an input u32 [[#PortEventType]] and an input s64 '''Threshold'''. Returns an output boolean success value and an Event handle with EventClearMode=0.


=== UnbindPortEvent ===
=== UnbindPortEvent ===
Takes an input u32 '''PortEvent'''. Returns an output boolean success value.
Takes an input u32 [[#PortEventType]]. Returns an output boolean success value.


= pwm =
= pwm =
Line 787: Line 785:
|-
|-
| [8.0.0+] 31 || || 0x36000001 || 1:08 || N || 400000 || 3 || 5000000 || NFC IC || [[NFC services]] || Hoag
| [8.0.0+] 31 || || 0x36000001 || 1:08 || N || 400000 || 3 || 5000000 || NFC IC || [[NFC services]] || Hoag
|}
= AddressingMode =
This is "nn::i2c::AddressingMode".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 0 || BitWidth7
|-
| 1 || BitWidth10
|}
= TransactionOption =
This is "nn::i2c::TransactionOption".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 1 || StartCondition
|-
| 2 || StopCondition
|}
= SpeedMode =
This is "nn::i2c::SpeedMode".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 0x186A0 || Standard
|-
| 0x61A80 || Fast
|-
| 0xF4240 || FastPlus
|-
| 0x33E140 || HighSpeed
|}
= CommandId =
This is "nn::i2c::detail::CommandId".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 0 || Send
|-
| 1 || Receive
|-
| 2 || Extension
|}
= SubCommandId =
This is "nn::i2c::detail::SubCommandId".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 0 || Sleep
|}
|}


= UartPort =
= UartPort =
This is "nn::uart::UartPort".
{| class="wikitable sortable" border="1"
{| class="wikitable sortable" border="1"
|-
|-
! Name || DeviceCode (internal) || DeviceCode (mapped) || Port || Usage
! Value || Name || DeviceCode (internal) || DeviceCode (mapped) || Description
|-
|-
| 0 || 0x03000001 || || UART-A || Invalid
| 0 || UART-A || 0x03000001 || || Invalid
|-
|-
| 1 || 0x03000004 || 0x37000001 || UART-D || Bluetooth
| 1 || UART-D || 0x03000004 || 0x37000001 || Bluetooth
|-
|-
| 2 || 0x03000002 || 0x35000405 || UART-B || Joy-Con(R)
| 2 || UART-B || 0x03000002 || 0x35000405 || Joy-Con(R)
|-
|-
| 3 || 0x03000003 || 0x3500040F || UART-C || Joy-Con(L)
| 3 || UART-C || 0x03000003 || 0x3500040F || Joy-Con(L)
|-
|-
| 4 || 0x03000003 || 0x35000419 || UART-C || MCU
| 4 || UART-C || 0x03000003 || 0x35000419 || MCU
|}
|}


= UartPortForDev =
= UartPortForDev =
This is "nn::uart::UartPortForDev".
{| class="wikitable sortable" border="1"
|-
! Value || Name || DeviceCode (internal) || DeviceCode (mapped) || Description
|-
| 0 || UART-A || 0x03000001 || || Invalid
|-
| 1 || UART-B || 0x03000002 || 0x35000405 || Joy-Con(R)
|-
| 2 || UART-C || 0x03000003 || 0x3500040F || Joy-Con(L)
|-
| 3 || UART-D || 0x03000004 || 0x37000001 || Bluetooth
|}
= FlowControlMode =
This is "nn::uart::FlowControlMode".
{| class="wikitable sortable" border="1"
|-
! Value || Name
|-
| 0 || None
|-
| 1 || Hardware
|}
= PortEventType =
This is "nn::uart::PortEventType".
{| class="wikitable sortable" border="1"
{| class="wikitable sortable" border="1"
|-
|-
! Name || DeviceCode (internal) || DeviceCode (mapped) || Port || Usage
! Value || Name
|-
|-
| 0 || 0x03000001 || || UART-A || Invalid
| 0 || SendBufferEmpty
|-
|-
| 1 || 0x03000002 || 0x35000405 || UART-B || Joy-Con(R)
| 1 || SendBufferReady
|-
|-
| 2 || 0x03000003 || 0x3500040F || UART-C || Joy-Con(L)
| 2 || ReceiveBufferReady
|-
|-
| 3 || 0x03000004 || 0x37000001 || UART-D || Bluetooth
| 3 || ReceiveEnd
|}
|}