Skip to content

Commit

Permalink
Update Devices.Adc declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes committed Nov 26, 2018
1 parent 0d55236 commit ae24842
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeReadValue___I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeDisposeChannel___VOID,
NULL,
Expand All @@ -39,6 +40,8 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeOpenChannel___VOID__I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeGetChannelCount___I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeGetMaxValue___I4,
Expand All @@ -49,12 +52,15 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::GetDeviceSelector___STATIC__STRING,
NULL,
NULL,
NULL,
NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Adc =
{
"Windows.Devices.Adc",
0x26B0229A,
0xD21F3E86,
method_lookup,
{ 1, 0, 2, 9 }
{ 1, 0, 2, 17 }
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel
{
static const int FIELD___channelNumber = 1;
static const int FIELD___adcController = 2;
static const int FIELD___syncLock = 3;
static const int FIELD___disposedValue = 4;
static const int FIELD___syncLock = 1;
static const int FIELD___channelNumber = 2;
static const int FIELD___adcController = 3;
static const int FIELD___disposed = 4;

NANOCLR_NATIVE_DECLARE(NativeReadValue___I4);
NANOCLR_NATIVE_DECLARE(NativeDisposeChannel___VOID);
Expand All @@ -28,10 +28,10 @@ struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcController
{
static const int FIELD_STATIC__s_deviceCollection = 0;

static const int FIELD___deviceId = 1;
static const int FIELD___channelMode = 2;
static const int FIELD___syncLock = 1;
static const int FIELD___controllerId = 2;
static const int FIELD___channelMode = 3;
static const int FIELD__s_deviceCollection = 4;

NANOCLR_NATIVE_DECLARE(NativeOpenChannel___VOID__I4);
NANOCLR_NATIVE_DECLARE(NativeGetChannelCount___I4);
Expand All @@ -46,6 +46,16 @@ struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcController

};

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcControllerManager
{
static const int FIELD_STATIC___syncLock = 0;
static const int FIELD_STATIC__s_controllersCollection = 1;


//--//

};

extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Adc;

struct NF_PAL_ADC_PORT_PIN_CHANNEL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeReadVal
// Get channel from _channelNumber field
int channelNumber = pThis[FIELD___channelNumber].NumericByRef().s4;

// need to get the deviceId for the ADC controller of this channel
// need to get the controllerId for the ADC controller of this channel
// get pointer to AdcController field
CLR_RT_HeapBlock* adcController = pThis[FIELD___adcController].Dereference();

// get pointer to _deviceId field in AdcController
int deviceId = adcController[Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::FIELD___deviceId].NumericByRef().s4;
// get pointer to _controllerId field in AdcController
int controllerId = adcController[Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::FIELD___controllerId].NumericByRef().s4;

// we are filling this bellow with the appropriate ADC port pin config and ADC driver
NF_PAL_ADC_PORT_PIN_CHANNEL adcDefinition;
ADCDriver* adcDriver = NULL;

// only one ADC controller for now, but check it anyways
if(deviceId == 1)
if(controllerId == 1)
{
adcDefinition = AdcPortPinConfig[channelNumber];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeOpen
// Get channel from argument
int channel = stack.Arg1().NumericByRef().s4;

// get device ID
int deviceId = pThis[FIELD___deviceId].NumericByRef().s4;
// get controller ID
int controllerId = pThis[FIELD___controllerId].NumericByRef().s4;

// we are filling this bellow with the appropriate ADC port pin config and ADC driver
NF_PAL_ADC_PORT_PIN_CHANNEL adcDefinition;
ADCDriver* adcDriver = NULL;

// only one ADC controller for now, but check it anyways
if(deviceId == 1)
if(controllerId == 1)
{
adcDefinition = AdcPortPinConfig[channel];

Expand Down Expand Up @@ -88,9 +88,9 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeGetC

CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

int deviceId = pThis[ FIELD___deviceId ].NumericByRefConst().s4;
int controllerId = pThis[ FIELD___controllerId ].NumericByRefConst().s4;

switch(deviceId)
switch(controllerId)
{
case 1:
channelCount = AdcChannelCount;
Expand Down Expand Up @@ -153,11 +153,11 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeInit
NANOCLR_HEADER();
{
// Get device Id from argument
int deviceId = stack.Arg1().NumericByRef().s4;
int controllerId = stack.Arg1().NumericByRef().s4;

// all required initialization for ADC is already handled in ChibiOS driver

switch(deviceId)
switch(controllerId)
{
case 1:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeReadValue___I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeDisposeChannel___VOID,
NULL,
Expand All @@ -39,6 +40,8 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeOpenChannel___VOID__I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeGetChannelCount___I4,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeGetMaxValue___I4,
Expand All @@ -49,12 +52,15 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::GetDeviceSelector___STATIC__STRING,
NULL,
NULL,
NULL,
NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Adc =
{
"Windows.Devices.Adc",
0x26B0229A,
0xD21F3E86,
method_lookup,
{ 1, 0, 2, 9 }
};
{ 1, 0, 2, 17 }
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel
{
static const int FIELD___channelNumber = 1;
static const int FIELD___adcController = 2;
static const int FIELD___syncLock = 3;
static const int FIELD___disposedValue = 4;
static const int FIELD___syncLock = 1;
static const int FIELD___channelNumber = 2;
static const int FIELD___adcController = 3;
static const int FIELD___disposed = 4;

NANOCLR_NATIVE_DECLARE(NativeReadValue___I4);
NANOCLR_NATIVE_DECLARE(NativeDisposeChannel___VOID);
Expand All @@ -27,10 +27,10 @@ struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcController
{
static const int FIELD_STATIC__s_deviceCollection = 0;

static const int FIELD___deviceId = 1;
static const int FIELD___channelMode = 2;
static const int FIELD___syncLock = 1;
static const int FIELD___controllerId = 2;
static const int FIELD___channelMode = 3;
static const int FIELD__s_deviceCollection = 4;

NANOCLR_NATIVE_DECLARE(NativeOpenChannel___VOID__I4);
NANOCLR_NATIVE_DECLARE(NativeGetChannelCount___I4);
Expand All @@ -45,6 +45,16 @@ struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcController

};

struct Library_win_dev_adc_native_Windows_Devices_Adc_AdcControllerManager
{
static const int FIELD_STATIC___syncLock = 0;
static const int FIELD_STATIC__s_controllersCollection = 1;


//--//

};

extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Adc;

#endif //_WIN_DEV_ADC_NATIVE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcChannel::NativeReadVal
// Get channel from _channelNumber field
int channelNumber = pThis[FIELD___channelNumber].NumericByRef().s4;

// need to get the deviceId for the ADC controller of this channel
// need to get the controllerId for the ADC controller of this channel
// get pointer to AdcController field
//CLR_RT_HeapBlock* adcController = pThis[FIELD___adcController].Dereference();

// get pointer to _deviceId field
// int adcNumber = adcController[Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::FIELD___deviceId].NumericByRef().s4;
// get pointer to _controllerId field
// int adcNumber = adcController[Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::FIELD___controllerId].NumericByRef().s4;
int adcNumber = channelNumber <= 9 ? 1 : 2;

if ( adcNumber == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ HRESULT Library_win_dev_adc_native_Windows_Devices_Adc_AdcController::NativeInit
NANOCLR_HEADER();
{
// Get device Id from argument
int deviceId = stack.Arg1().NumericByRef().s4;
int controllerId = stack.Arg1().NumericByRef().s4;

// all required initialization for ADC are already handled
// this is only to check if the requested deviceId is available in hardware
// this is only to check if the requested controllerId is available in hardware

// expect only 1
if(deviceId == 1)
if(controllerId == 1)
{
// we are OK
}
Expand Down

0 comments on commit ae24842

Please sign in to comment.