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-
-
+
+
+
+
+
@@ -719,7 +719,7 @@
SDK_2.x_MK22FN512xxx12
2.12.0
middleware.baremetal.MK22F51212;platform.drivers.smc.MK22F51212;platform.drivers.port.MK22F51212;platform.drivers.dspi.MK22F51212;platform.drivers.adc16.MK22F51212;platform.drivers.uart.MK22F51212;platform.drivers.clock.MK22F51212;platform.drivers.rtc.MK22F51212;platform.drivers.common.MK22F51212;platform.drivers.i2c.MK22F51212;platform.drivers.gpio.MK22F51212;device.MK22F51212_system.MK22F51212;device.MK22F51212_CMSIS.MK22F51212;CMSIS_Include_core_cm.MK22F51212;platform.utilities.assert.MK22F51212;component.serial_manager_uart.MK22F51212;utility.debug_console.MK22F51212;component.serial_manager.MK22F51212;component.uart_adapter.MK22F51212;component.lists.MK22F51212;project_template.MK22F51212.MK22F51212;device.MK22F51212_startup.MK22F51212;
- MK22FN512VDC12
+ MK22FN512VLH12
cm4
core0_MK22FN512xxx12
diff --git a/ADIS_tinyK22_Cpp_Project/source/ADIS_tinyK22_Cpp_Project.cpp b/ADIS_tinyK22_Cpp_Project/source/ADIS_tinyK22_Cpp_Project.cpp
index 7e44da6..1f079e5 100644
--- a/ADIS_tinyK22_Cpp_Project/source/ADIS_tinyK22_Cpp_Project.cpp
+++ b/ADIS_tinyK22_Cpp_Project/source/ADIS_tinyK22_Cpp_Project.cpp
@@ -40,6 +40,7 @@
#include "MK22F51212.h"
#include "fsl_debug_console.h"
/* TODO: insert other include files here. */
+#include "car.hh"
/* TODO: insert other definitions and declarations here. */
@@ -59,14 +60,9 @@ int main(void) {
PRINTF("Hello World\n");
- /* Force the counter to be placed into memory. */
- volatile static int i = 0 ;
- /* Enter an infinite loop, just incrementing a counter. */
- while(1) {
- i++ ;
- /* 'Dummy' NOP to allow source level single stepping of
- tight while() loop */
- __asm volatile ("nop");
- }
+ CAR_Test();
+ CAR_Exit();
+
+
return 0 ;
}
diff --git a/ADIS_tinyK22_Cpp_Project/source/car.cpp b/ADIS_tinyK22_Cpp_Project/source/car.cpp
new file mode 100644
index 0000000..963f95c
--- /dev/null
+++ b/ADIS_tinyK22_Cpp_Project/source/car.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021-2022, Erich Styger
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "car.hh"
+#include // for exit()
+
+class Car {
+ private: int price;
+ public:
+ Car(void) { // constructor
+ price = 1000;
+ }
+ ~Car(void) { // destructor
+ price = -1;
+ }
+ void SetPrice(int price) { // setter method
+ this->price = price;
+ }
+};
+
+// global variables
+static Car c; // global object, shall be initialized by startup (constructor)
+static int i; // initialized by startup (zero-out)
+static int j = 0x1234; // initialized by startup (copy-down)
+
+void CAR_Test(void) {
+ Car newCar; // local object: constructor called?
+
+ c.SetPrice(i+1000);
+ newCar.SetPrice(j);
+ // destructors of newCar called?
+}
+
+extern "C" {
+ extern void __libc_fini_array(void);
+}
+
+void CAR_Exit(void) {
+ // __libc_fini_array();
+ exit(-1); // force application exit, global destructors called?
+}
diff --git a/ADIS_tinyK22_Cpp_Project/source/car.hh b/ADIS_tinyK22_Cpp_Project/source/car.hh
new file mode 100644
index 0000000..ebb87cb
--- /dev/null
+++ b/ADIS_tinyK22_Cpp_Project/source/car.hh
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2021-2022, Erich Styger
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CAR_HH_
+#define CAR_HH_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void CAR_Test(void);
+void CAR_Exit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CAR_HH_ */