Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update native implementation of serial comm #767

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::get_BytesToRead___U4,
NULL,
NULL,
NULL,
Expand Down Expand Up @@ -77,7 +78,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_SerialCommunication =
{
"Windows.Devices.SerialCommunication",
0x2B84D4FF,
0x469DDCFE,
method_lookup,
{ 1, 0, 0, 0 }
};
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialD
static const int FIELD___watchChar = 16;
static const int FIELD___callbacksDataReceivedEvent = 17;

NANOCLR_NATIVE_DECLARE(get_BytesToRead___U4);
NANOCLR_NATIVE_DECLARE(NativeDispose___VOID);
NANOCLR_NATIVE_DECLARE(NativeInit___VOID);
NANOCLR_NATIVE_DECLARE(NativeConfig___VOID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,71 @@ HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_Serial
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::get_BytesToRead___U4( CLR_RT_StackFrame& stack )
{
NANOCLR_HEADER();
{
NF_PAL_UART* palUart;

// get a pointer to the managed object instance and check that it's not NULL
CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

// Choose the driver for this SerialDevice
switch ((int)pThis[ FIELD___portIndex ].NumericByRef().s4)
{
#if STM32_UART_USE_USART1
case 1 :
palUart = &Uart1_PAL;
break;
#endif
#if STM32_UART_USE_USART2
case 2 :
palUart = &Uart2_PAL;
break;
#endif
#if STM32_UART_USE_USART3
case 3 :
palUart = &Uart3_PAL;
break;
#endif
#if STM32_UART_USE_UART4
case 4 :
palUart = &Uart4_PAL;
break;
#endif
#if STM32_UART_USE_UART5
case 5 :
palUart = &Uart5_PAL;
break;
#endif
#if STM32_UART_USE_USART6
case 6 :
palUart = &Uart6_PAL;
break;
#endif
#if STM32_UART_USE_UART7
case 7 :
palUart = &Uart7_PAL;
break;
#endif
#if STM32_UART_USE_UART8
case 8 :
palUart = &Uart8_PAL;
break;
#endif
default:
// this COM port is not valid
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
break;
}

// get length of Rx ring buffer
stack.SetResult_U4(palUart->RxRingBuffer.Length());

}
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::GetDeviceSelector___STATIC__STRING( CLR_RT_StackFrame& stack )
{
NANOCLR_HEADER();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::get_BytesToRead___U4,
NULL,
NULL,
NULL,
Expand Down Expand Up @@ -77,7 +78,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_SerialCommunication =
{
"Windows.Devices.SerialCommunication",
0x2B84D4FF,
0x469DDCFE,
method_lookup,
{ 1, 0, 0, 0 }
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialD
static const int FIELD___watchChar = 16;
static const int FIELD___callbacksDataReceivedEvent = 17;

NANOCLR_NATIVE_DECLARE(get_BytesToRead___U4);
NANOCLR_NATIVE_DECLARE(NativeDispose___VOID);
NANOCLR_NATIVE_DECLARE(NativeInit___VOID);
NANOCLR_NATIVE_DECLARE(NativeConfig___VOID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,20 @@ HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_Serial

HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::NativeSetWatchChar___VOID( CLR_RT_StackFrame& stack )
{
(void) stack;
NANOCLR_HEADER();

NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub());

NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::get_BytesToRead___U4( CLR_RT_StackFrame& stack )
{
NANOCLR_HEADER();
{
// set watch char
// (uint8_t)pThis[ FIELD___watchChar ].NumericByRef().u1;

}
NANOCLR_NOCLEANUP_NOLABEL();
NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub());

NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_serial_native_Windows_Devices_SerialCommunication_SerialDevice::GetDeviceSelector___STATIC__STRING( CLR_RT_StackFrame& stack )
Expand Down