-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add native supporting hardware.stm32 class lib
- Add class library implementation. - Update CMakes accordingly. - Update cmake-variants template. Signed-off-by: José Simões <[email protected]>
- Loading branch information
1 parent
7453954
commit 93e8c85
Showing
9 changed files
with
644 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2017 The nanoFramework project contributors | ||
# See LICENSE file in the project root for full license information. | ||
# | ||
|
||
|
||
# native code directory | ||
set(BASE_PATH_FOR_THIS_MODULE "${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Hardware.Stm32") | ||
|
||
|
||
# set include directories | ||
# list(APPEND nanoFramework.Hardware.Stm32_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/CLR/Core") | ||
# list(APPEND nanoFramework.Hardware.Stm32_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/CLR/Include") | ||
# list(APPEND nanoFramework.Hardware.Stm32_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/HAL/Include") | ||
# list(APPEND nanoFramework.Hardware.Stm32_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/PAL/Include") | ||
list(APPEND nanoFramework.Hardware.Stm32_INCLUDE_DIRS "${BASE_PATH_FOR_THIS_MODULE}") | ||
|
||
|
||
# source files | ||
set(nanoFramework.Hardware.Stm32_SRCS | ||
|
||
nf_hardware_stm32_native.cpp | ||
nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory.cpp | ||
nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC.cpp | ||
nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Utilities.cpp | ||
) | ||
|
||
foreach(SRC_FILE ${nanoFramework.Hardware.Stm32_SRCS}) | ||
set(nanoFramework.Hardware.Stm32_SRC_FILE SRC_FILE-NOTFOUND) | ||
find_file(nanoFramework.Hardware.Stm32_SRC_FILE ${SRC_FILE} | ||
PATHS | ||
"${BASE_PATH_FOR_THIS_MODULE}" | ||
|
||
CMAKE_FIND_ROOT_PATH_BOTH | ||
) | ||
# message("${SRC_FILE} >> ${nanoFramework.Hardware.Stm32_SRC_FILE}") # debug helper | ||
list(APPEND nanoFramework.Hardware.Stm32_SOURCES ${nanoFramework.Hardware.Stm32_SRC_FILE}) | ||
endforeach() | ||
|
||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(nanoFramework.Hardware.Stm32 DEFAULT_MSG nanoFramework.Hardware.Stm32_INCLUDE_DIRS nanoFramework.Hardware.Stm32_SOURCES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
targets/CMSIS-OS/ChibiOS/nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Copyright (c) 2018 The nanoFramework project contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#include "nf_hardware_stm32_native.h" | ||
|
||
|
||
static const CLR_RT_MethodHandler method_lookup[] = | ||
{ | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory::ReadBytes___STATIC__VOID__U4__SZARRAY_U1, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory::WriteBytes___STATIC__VOID__U4__SZARRAY_U1, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory::GetSize___STATIC__I4, | ||
NULL, | ||
NULL, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC::Native_RTC_SetAlarm___STATIC__VOID__U1__U1__U1__U1, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC::Native_RTC_GetAlarm___STATIC__I8, | ||
NULL, | ||
NULL, | ||
NULL, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Utilities::NativeGetDeviceUniqueId___STATIC__VOID__SZARRAY_U1, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Utilities::NativeGetDeviceId___STATIC__U4, | ||
Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Utilities::NativeGetDeviceRevisionId___STATIC__U4, | ||
}; | ||
|
||
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Hardware_Stm32 = | ||
{ | ||
"nanoFramework.Hardware.Stm32", | ||
0x3D39A14F, | ||
method_lookup, | ||
{ 1, 0, 0, 0 } | ||
}; |
53 changes: 53 additions & 0 deletions
53
targets/CMSIS-OS/ChibiOS/nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Copyright (c) 2018 The nanoFramework project contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#ifndef _NF_HARDWARE_STM32_NATIVE_H_ | ||
#define _NF_HARDWARE_STM32_NATIVE_H_ | ||
|
||
#include <nanoCLR_Interop.h> | ||
#include <nanoCLR_Runtime.h> | ||
#include <hal.h> | ||
|
||
struct Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory | ||
{ | ||
static const int FIELD_STATIC___size = 0; | ||
|
||
NANOCLR_NATIVE_DECLARE(ReadBytes___STATIC__VOID__U4__SZARRAY_U1); | ||
NANOCLR_NATIVE_DECLARE(WriteBytes___STATIC__VOID__U4__SZARRAY_U1); | ||
NANOCLR_NATIVE_DECLARE(GetSize___STATIC__I4); | ||
|
||
//--// | ||
|
||
// need to address the fact that the majority of the series have 32 bits wide registers and F1 has 16bits wide. | ||
// the backup size is calculated with the number of available backup registers and their size (in bytes) | ||
static const int BACKUP_SIZE = RTC_BKP_NUMBER * sizeof(RTC_BKP0R_Msk); | ||
}; | ||
|
||
struct Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC | ||
{ | ||
NANOCLR_NATIVE_DECLARE(Native_RTC_SetAlarm___STATIC__VOID__U1__U1__U1__U1); | ||
NANOCLR_NATIVE_DECLARE(Native_RTC_GetAlarm___STATIC__I8); | ||
|
||
//--// | ||
|
||
}; | ||
|
||
struct Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Utilities | ||
{ | ||
static const int FIELD_STATIC___deviceUniqueId = 1; | ||
static const int FIELD_STATIC___deviceId = 2; | ||
static const int FIELD_STATIC___deviceRevisionId = 3; | ||
|
||
NANOCLR_NATIVE_DECLARE(NativeGetDeviceUniqueId___STATIC__VOID__SZARRAY_U1); | ||
NANOCLR_NATIVE_DECLARE(NativeGetDeviceId___STATIC__U4); | ||
NANOCLR_NATIVE_DECLARE(NativeGetDeviceRevisionId___STATIC__U4); | ||
|
||
//--// | ||
|
||
}; | ||
|
||
extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Hardware_Stm32; | ||
|
||
#endif //_NF_HARDWARE_STM32_NATIVE_H_ |
Oops, something went wrong.