-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daa1820
commit 16bed53
Showing
179 changed files
with
1,998 additions
and
2,226 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
_builds | ||
hello-world | ||
Testing | ||
|
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,30 @@ | ||
# Example for creating a test for CTest | ||
# to execute the `IAR C-SPY Command-line Utility (cspybat.exe)` | ||
|
||
function(iar_cspy_add_test TARGET TEST_NAME EXPECTED_OUTPUT) | ||
# Add a test for CTest | ||
add_test(NAME ${TEST_NAME} | ||
COMMAND ${TOOLKIT_DIR}/../common/bin/cspybat --silent | ||
# C-SPY drivers | ||
"${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}proc.dll" | ||
"${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}sim.dll" | ||
"--plugin=${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}bat.dll" | ||
--debug_file=$<TARGET_FILE:${TARGET}> | ||
# C-SPY macros settings | ||
"--macro=${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.mac" | ||
"--macro_param=testName=\"${TEST_NAME}\"" | ||
"--macro_param=testExpected=${EXPECTED_OUTPUT}" | ||
# C-SPY backend setup | ||
--backend | ||
-p $<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},DDF>>,$<TARGET_PROPERTY:${TARGET},DDF>,${TOOLKIT_DIR}/config/debugger/msp430f149.ddf> | ||
--hwmul_base=0x130 | ||
--hardware_multiplier=16 | ||
--hwmult_type=1 | ||
--iv_base=0xFFE0 | ||
--odd_word_check | ||
--derivativeSim=MSP430F149 | ||
-d sim ) | ||
|
||
# Set the test to interpret a C-SPY's message containing `PASS` | ||
set_tests_properties(${TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION "PASS") | ||
endfunction() |
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 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# Set the project name, [description] and [version], | ||
# while enabling its required languages | ||
project(Example1 | ||
DESCRIPTION "Mixing C and Assembly" | ||
VERSION 1.0.0 | ||
LANGUAGES C ASM ) | ||
|
||
# Fallback option for generators other than `Ninja Multi-Config` | ||
if (NOT DEFINED CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
endif() | ||
|
||
# Enable CTest | ||
enable_testing() | ||
|
||
# Add the executable for the "mixLanguages" target | ||
add_executable(mixLanguages | ||
# Source files | ||
main.c | ||
mynum.asm ) | ||
|
||
# Set a preprocessor symbol, usable from "mixLanguages" target | ||
target_compile_definitions(mixLanguages PUBLIC USE_ASM=1) | ||
|
||
# Set the compiler flags for the "mixLanguages" target | ||
target_compile_options(mixLanguages PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:--multiplier=16 --dlib_config ${TOOLKIT_DIR}/lib/dlib/dl430fn.h> | ||
-D__MSP430F149__ ) | ||
|
||
# Set the linker options for the "mixLanguages" target | ||
target_link_options(mixLanguages PRIVATE | ||
-f ${TOOLKIT_DIR}/config/linker/lnk430f149.xcl | ||
${TOOLKIT_DIR}/lib/dlib/dl430fn.r43 | ||
# The `SHELL:` prefix prevents option de-duplication | ||
"SHELL:-D_DATA16_HEAP_SIZE=50" | ||
"SHELL:-D_STACK_SIZE=50" | ||
"SHELL:-D_DATA20_HEAP_SIZE=50" ) | ||
|
||
# Optional: test the project with C-SPY | ||
include(../iar-cspy-430.cmake) | ||
iar_cspy_add_test(mixLanguages test_mynum 42) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,40 @@ | ||
# Add the executable for the "myProgram" target, | ||
# specifying its source files | ||
add_executable (myProgram | ||
# Source files | ||
main.c ) | ||
|
||
# Set the properties for the "myProgram" target | ||
set_target_properties(myProgram PROPERTIES | ||
XCL "${TOOLKIT_DIR}/config/linker/lnk430f149.xcl" | ||
# C-SPY-related properties | ||
DDF "${TOOLKIT_DIR}/config/debugger/msp430f149.ddf" ) | ||
|
||
# Set the compiler flags for the target | ||
target_compile_options(myProgram PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:--multiplier=16 --double=32 --dlib_config ${TOOLKIT_DIR}/lib/dlib/dl430fn.h> | ||
-D__MSP430F149__ ) | ||
|
||
# Set the linker flags for the target | ||
target_link_options(myProgram PRIVATE | ||
-s __program_start | ||
# Create a map file from the target's UBROF | ||
-l $<TARGET_PROPERTY:NAME>.map | ||
# The `SHELL:` prefix prevents option de-duplication | ||
"SHELL:-D_DATA16_HEAP_SIZE=50" | ||
"SHELL:-D_STACK_SIZE=50" | ||
"SHELL:-D_DATA20_HEAP_SIZE=50" | ||
# Set the linker script | ||
-f $<TARGET_PROPERTY:XCL> | ||
# The `SHELL:` prefix prevents option de-duplication | ||
"SHELL:-f ${TOOLKIT_DIR}/config/linker/multiplier.xcl" | ||
-rt ${TOOLKIT_DIR}/lib/dlib/dl430fn.r43 ) | ||
|
||
# Link "myProgram" against the "myMath" library | ||
target_link_libraries(myProgram LINK_PUBLIC myMath) | ||
|
||
# Optional: test the project with C-SPY | ||
include(../../iar-cspy-430.cmake) | ||
iar_cspy_add_test(myProgram test_add 42) | ||
iar_cspy_add_test(myProgram test_sub 38) | ||
iar_cspy_add_test(myProgram test_mul 80) |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,30 @@ | ||
# Example for creating a test for CTest | ||
# to execute the `IAR C-SPY Command-line Utility (cspybat.exe)` | ||
|
||
function(iar_cspy_add_test TARGET TEST_NAME EXPECTED_OUTPUT) | ||
# Add a test for CTest | ||
add_test(NAME ${TEST_NAME} | ||
COMMAND ${TOOLKIT_DIR}/../common/bin/cspybat --silent | ||
# C-SPY drivers | ||
"${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}proc.dll" | ||
"${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}sim.dll" | ||
"--plugin=${TOOLKIT_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}bat.dll" | ||
--debug_file=$<TARGET_FILE:${TARGET}> | ||
# C-SPY macros settings | ||
"--macro=${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.mac" | ||
"--macro_param=testName=\"${TEST_NAME}\"" | ||
"--macro_param=testExpected=${EXPECTED_OUTPUT}" | ||
# C-SPY backend setup | ||
--backend | ||
--proc_core=plain | ||
--proc_code_model=near | ||
--proc_nr_virtual_regs 8 | ||
--proc_pdata_bank_reg_addr 0xA0 | ||
--proc_dptr_nr_of=1 | ||
--proc_data_model=small | ||
-p $<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},DDF>>,$<TARGET_PROPERTY:${TARGET},DDF>,${TOOLKIT_DIR}/config/devices/_generic/io8051.ddf> | ||
--proc_driver sim ) | ||
|
||
# Set the test to interpret a C-SPY's message containing `PASS` | ||
set_tests_properties(${TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION "PASS") | ||
endfunction() |
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,57 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# Set the project name, [description] and [version], | ||
# while enabling its required languages | ||
project(Example1 | ||
DESCRIPTION "Mixing C and Assembly" | ||
VERSION 1.0.0 | ||
LANGUAGES C ASM ) | ||
|
||
# Fallback option for generators other than `Ninja Multi-Config` | ||
if (NOT DEFINED CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
endif() | ||
|
||
# Enable CTest | ||
enable_testing() | ||
|
||
# Add the executable for the "mixLanguages" target | ||
add_executable(mixLanguages | ||
# Source files | ||
main.c | ||
mynum.asm ) | ||
|
||
# Set a preprocessor symbol, usable from "mixLanguages" target | ||
target_compile_definitions(mixLanguages PUBLIC USE_ASM=1) | ||
|
||
# Set compile options for the target | ||
target_compile_options(mixLanguages PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:--core=plain --dptr=16,1 --data_model=large --code_model=near --calling_convention=xdata_reentrant --place_constants=data --nr_virtual_regs 8 --dlib --dlib_config ${TOOLKIT_DIR}/lib/dlib/dl8051Normal.h> | ||
$<$<COMPILE_LANGUAGE:ASM>:-v0 -D__CORE__=1 -D__CODE_MODEL__=1 -D__DATA_MODEL__=1 -D__CALLING_CONVENTION__=2 -D__NUMBER_OF_DPTRS__=1> ) | ||
|
||
# Set the link options for the target | ||
target_link_options(mixLanguages PRIVATE | ||
-rt | ||
-f ${TOOLKIT_DIR}/config/devices/_generic/lnk51ew_8051.xcl | ||
${TOOLKIT_DIR}/lib/dlib/dl-pli-nlxd-1e16x01n.r51 | ||
# The `SHELL:` prefix prevents option de-duplication | ||
"SHELL:-D_NR_OF_BANKS=0" | ||
"SHELL:-D_CODEBANK_END=0" | ||
"SHELL:-D_CODEBANK_START=0" | ||
"SHELL:-D_NR_OF_VIRTUAL_REGISTERS=8" | ||
"SHELL:-D?PBANK=0xA0" | ||
"SHELL:-D_IDATA_STACK_SIZE=0x40" | ||
"SHELL:-D?ESP=0" | ||
"SHELL:-D?ESP_MASK=0" | ||
"SHELL:-D_EXTENDED_STACK_START=0" | ||
"SHELL:-D_EXTENDED_STACK_SIZE=0" | ||
"SHELL:-D_PDATA_STACK_SIZE=0x80" | ||
"SHELL:-D_XDATA_STACK_SIZE=0xEFF" | ||
"SHELL:-D_XDATA_HEAP_SIZE=0xFF" | ||
"SHELL:-D_FAR_HEAP_SIZE=0xFFF" | ||
"SHELL:-D_HUGE_HEAP_SIZE=0xFFF" | ||
"SHELL:-D_FAR22_HEAP_SIZE=0xFFF" ) | ||
|
||
# Optional: test the project with CTest and IAR C-SPY | ||
include(../iar-cspy-8051.cmake) | ||
iar_cspy_add_test(mixLanguages test_mynum 42) |
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,23 @@ | ||
#include <stdio.h> | ||
#include "mynum.h" | ||
|
||
int answer; | ||
|
||
int main(void) | ||
{ | ||
#if USE_ASM | ||
answer = mynum(); | ||
#else | ||
answer = 10; | ||
#endif | ||
/* NDEBUG is set automatically for when | ||
bulding with -DCMAKE_BUILD_TYPE=Release */ | ||
#ifndef NDEBUG | ||
printf("-- app debug output begin --\n"); | ||
printf("mixLanguages v%d.%d.%d\n", 1, 0, 0); | ||
printf("The answer is: %d.\n",answer); | ||
printf("-- app debug output end --\n"); | ||
#endif | ||
|
||
return 0; | ||
} |
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,33 @@ | ||
__param testName; | ||
__param testExpected; | ||
|
||
__var _breakID; | ||
__var _result; | ||
|
||
execUserSetup() | ||
{ | ||
__message "C-SPY TEST: started..."; | ||
__message "C-SPY TEST: When the `answer` variable is read, `checkanswer()` will execute."; | ||
_breakID = __setSimBreak("answer", "R", "checkAnswer()"); | ||
} | ||
|
||
Done() | ||
{ | ||
__message "-- C-SPY TEST: Done()"; | ||
if (_result == testExpected) | ||
{ | ||
__message "-- C-SPY TEST:", testName, ". Result: PASS"; | ||
} else { | ||
__message "-- C-SPY TEST:", testName, ". Expected: ", testExpected, " Result: FAIL"; | ||
} | ||
} | ||
|
||
checkAnswer() | ||
{ | ||
__message "-- C-SPY TEST: checkAnswer()"; | ||
if (testName == "test_mynum") | ||
{ | ||
_result = answer; | ||
Done(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#ifndef MYNUM_H | ||
#define MYNUM_H | ||
extern int mynum(); | ||
#endif |
File renamed without changes.
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,50 @@ | ||
# Add the executable for the "myProgram" target, | ||
# specifying its source files | ||
add_executable (myProgram | ||
# Source files | ||
main.c ) | ||
|
||
# Set the properties for the "myProgram" target | ||
set_target_properties(myProgram PROPERTIES | ||
XCL "${TOOLKIT_DIR}/config/devices/_generic/lnk51ew_8051.xcl" | ||
# C-SPY-related properties | ||
DDF "${TOOLKIT_DIR}/config/devices/_generic/io8051.ddf" ) | ||
|
||
# Set the compiler flags for the "myProgram" target | ||
target_compile_options(myProgram PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:--core=plain --dptr=16,1 --data_model=large --code_model=near --calling_convention=xdata_reentrant --place_constants=data --nr_virtual_regs 8 --dlib --dlib_config ${TOOLKIT_DIR}/lib/dlib/dl8051Normal.h> ) | ||
|
||
# Set the linker flags for the target | ||
target_link_options(myProgram PRIVATE | ||
-rt | ||
# Set the linker script | ||
-f $<TARGET_PROPERTY:XCL> | ||
${TOOLKIT_DIR}/lib/dlib/dl-pli-nlxd-1e16x01n.r51 | ||
# Create a map file from the target's UBROF | ||
-l $<TARGET_PROPERTY:NAME>.map | ||
# The `SHELL:` prefix prevents option de-duplication | ||
"SHELL:-D_NR_OF_BANKS=0" | ||
"SHELL:-D_CODEBANK_END=0" | ||
"SHELL:-D_CODEBANK_START=0" | ||
"SHELL:-D_NR_OF_VIRTUAL_REGISTERS=8" | ||
"SHELL:-D?PBANK=0xA0" | ||
"SHELL:-D_IDATA_STACK_SIZE=0x40" | ||
"SHELL:-D?ESP=0" | ||
"SHELL:-D?ESP_MASK=0" | ||
"SHELL:-D_EXTENDED_STACK_START=0" | ||
"SHELL:-D_EXTENDED_STACK_SIZE=0" | ||
"SHELL:-D_PDATA_STACK_SIZE=0x80" | ||
"SHELL:-D_XDATA_STACK_SIZE=0xEFF" | ||
"SHELL:-D_XDATA_HEAP_SIZE=0xFF" | ||
"SHELL:-D_FAR_HEAP_SIZE=0xFFF" | ||
"SHELL:-D_HUGE_HEAP_SIZE=0xFFF" | ||
"SHELL:-D_FAR22_HEAP_SIZE=0xFFF" ) | ||
|
||
# Link "myProgram" against the "myMath" library | ||
target_link_libraries(myProgram LINK_PUBLIC myMath) | ||
|
||
# Optional: test the project with CTest and IAR C-SPY | ||
include(../../iar-cspy-8051.cmake) | ||
iar_cspy_add_test(myProgram test_add 42) | ||
iar_cspy_add_test(myProgram test_sub 38) | ||
iar_cspy_add_test(myProgram test_mul 80) |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.