Merge pull request #12 from hathach/devlocal

tested samd21 and samd51 with msc ram disk
This commit is contained in:
hathach 2018-11-22 12:16:26 +07:00 committed by GitHub
commit 2edfd5b555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 36763 additions and 3817 deletions

4
.gitignore vendored
View File

@ -10,6 +10,10 @@ tests/build
*.launch
*.map
*.axf
*.jlink
*.emSession
*.elf
*.ind
/tests/lpc175x_6x/build/
/tests/lpc18xx_43xx/build/
/demos/*/*/Board_*

View File

@ -1,237 +0,0 @@
#!/usr/bin/perl
use List::MoreUtils 'any';
use List::MoreUtils 'first_value';
use File::Spec;
use File::Find;
use File::Path;
use File::Glob;
use File::stat;
use Cwd;
use Cwd 'abs_path';
$" = "\n"; # change list separator
$KEIL_PATH = 'C:/Keil/UV4'; #'/C/Keil/UV4';
$IAR_PATH = glob ('C:/Program*/IAR*/Embedded*/common/bin');
$XPRESSO_PATH = glob ('C:/nxp/LPCXpresso_7*/lpcxpresso');
$XPRESSO_BIN_PATH = "$XPRESSO_PATH/bin";
$XPRESSO_PATH = "$XPRESSO_PATH;$XPRESSO_PATH/bin;$XPRESSO_PATH/tools/bin;$XPRESSO_PATH/msys/bin";
$ENV{'PATH'} .= ';' . $KEIL_PATH . ';' . $IAR_PATH . ';' . $XPRESSO_PATH;
$ENV{'PATH'} .= ';' . "C:/Keil/ARM/BIN";
#print $ENV{'PATH'}; die;
$repo_path = abs_path(cwd . "/..");
$device_dir = "device/";
$host_dir = "host/";
##### Command line arguments ###
$board = $ARGV[0];
$is_keil = (any { /keil/ or /all/ } @ARGV);
$is_iar = (any { /iar/ or /all/ } @ARGV);
$is_xpresso = (any { /xpresso/ or /all/ } @ARGV);
$is_download_only = (any { /download_only/ } @ARGV);
if ( any { /device_/ or /host_/ } @ARGV)
{
my $build_project;
$device_dir .= defined ($build_project = first_value { /device_/ } @ARGV) ? $build_project : "nowhere_path" ;
$host_dir .= defined ($build_project = first_value { /host_/ } @ARGV) ? $build_project : "nowhere_path";
}else
{ #default is all
$device_dir .= "*";
$host_dir .= "*";
}
#print "$device_dir $host_dir"; die;
my $log_file = "board_$board.txt";
unlink $log_file;
################## KEIL #####################
if ($is_keil)
{
@KEIL_PROJECT_LIST = (<$device_dir*/*.uvproj>, <$host_dir*/*.uvproj>);
foreach (@KEIL_PROJECT_LIST)
{
/([^\/]+).uvproj/;
print_title("Keil $1");
my $temp_log = "temp_log.txt";
my $build_cmd = "Uv4 -b $_ -t$board -j0 -o ../../$temp_log";
if ( $is_download_only || cmd_execute($build_cmd) < 2 )
{
append_file($log_file, $temp_log);
my $flash_cmd = "Uv4 -f $_ -t$board -j0 -o ../../$temp_log";
append_file($log_file, $temp_log) if flash_to_board($flash_cmd);
}
}
}
################## IAR #####################
if ($is_iar)
{
@IAR_PROJECT_LIST = (<$device_dir*/*.ewp>, <$host_dir*/*.ewp>);
foreach (@IAR_PROJECT_LIST)
{
/(.+\/)([^\/]+).ewp/;
print_title("IAR $2");
my $build_cmd = "IarBuild $_ -build $board -log warnings >> $log_file";
if ( $is_download_only || cmd_execute($build_cmd) == 0)
{
my $flash_cmd = "cd $1 & " . iar_flash_cmd($_);
flash_to_board($flash_cmd);
}
}
}
################## LPCXPRESSO #####################
if ($is_xpresso)
{
(my $repo_path_other_dash = $repo_path) =~ s/\//\\/g;
my $workspace_dir = "C:/Users/hathach/Dropbox/tinyusb/workspace7"; #projects must be opened in the workspace to be built
my %flash_tool =
( # board => (tool, chip_name)
'Board_EA4357' => ['crt_emu_lpc18_43_nxp' , 'LPC4357' ],
'Board_NGX4330' => ['crt_emu_lpc18_43_nxp' , 'LPC4330' ],
'Board_LPCXpresso1769' => ['crt_emu_cm3_nxp' , 'LPC1769' ],
'Board_LPCXpresso1347' => ['crt_emu_lpc11_13_nxp' , 'LPC1347' ],
'Board_rf1ghznode' => ['crt_emu_lpc11_13_nxp' , 'LPC11U37/401'],
);
die "board is not supported" unless $flash_tool{$board};
print "all projects in $workspace_dir must be opened and set to the correct MCU of the boards. Enter to continue:\n";
#<STDIN>;
@XPRESSO_PROJECT_LIST = (<$device_dir*/.cproject>, <$host_dir*/.cproject>);
foreach (@XPRESSO_PROJECT_LIST)
{
/(.+\/(.+))\/.cproject/;
my $proj_dir = $1;
my $proj = $2;
print_title("XPRESSO $proj");
my $build_cmd = "lpcxpressoc -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild -build $proj/$board -data $workspace_dir >> $log_file";
system("cd $proj_dir/$board & make clean >> $log_file") if !$is_download_only; # lpcxpresso have a bug that clean the current active config instead of the passed in, manual clean
if ( $is_download_only || cmd_execute($build_cmd) == 0)
{
my $flash_cmd = "$flash_tool{$board}[0] -p$flash_tool{$board}[1] -s2000 -flash-load-exec=$proj_dir/$board/$proj.axf";
$flash_cmd .= " -flash-driver=$XPRESSO_BIN_PATH/Flash/LPC18_43_SPIFI_4MB_64KB.cfx" if $board eq 'Board_NGX4330';
#print $flash_cmd; die;
flash_to_board($flash_cmd);
}
}
=pod
open (my $fout, ">$log_file") or die;
foreach (@log_content)
{
unless (/Invoking: MCU C Compiler/ or /arm-none-eabi-gcc -D/ or /Finished building:/ or /^ $/)
{
s/Building file:.+?([^\/]+\.[ch])/\1/;
s/$repo_path//;
s/$repo_path_other_dash//;
print $fout $_;
}
}
=cut
}
################## HELPER #####################
sub cmd_execute
{
print "executing: $_[0] ...";
$result = system($_[0]);
print "$result done\n";
return $result;
}
sub flash_to_board
{
my $flash_cmd = $_[0];
print "Do you want to flash y/n: ";
chomp ($ask = <STDIN>);
#$ask = "y";
cmd_execute($flash_cmd) if ( $ask eq "y" );
return ( $ask eq "y" );
}
sub print_title
{
print "---------------------------------------------------------------------\n";
print "$_[0] for $board\n";
print "---------------------------------------------------------------------\n";
}
sub append_file
{
my $log_file = $_[0];
my $temp_log = $_[1];
open(my $log_handle, ">>$log_file") or die "cannot open $log_file";
open(my $temp_handle, $temp_log) or die "cannot open $temp_log";
print $log_handle (@temp_content = <$temp_handle>);
close($temp_handle);
close($log_handle);
}
sub iar_flash_cmd
{
$_[0] =~ /^(.+)\/(.+).ewp/;
my $debug_file = "$board/Exe/$2.out";
my $arm_path = abs_path "$IAR_PATH/../../arm";
my $bin_path = "$arm_path/bin";
my $debugger_path = "$arm_path/config/debugger/NXP";
my %mcu_para_hash =
( # board => family (for macro), architecture, fpu, name
'Board_EA4357' => ['LPC18xx_LPC43xx', 'Cortex-M4', 'VFPv4', 'LPC4357_M4' ],
'Board_NGX4330' => ['LPC18xx_LPC43xx', 'Cortex-M4', 'VFPv4', 'LPC4330_M4' ],
'Board_LPCXpresso1769' => ['LPC175x_LPC176x', 'Cortex-M3', 'None' , 'LPC1769' ],
'Board_LPCXpresso1347' => ['lpc1315' , 'Cortex-M3', 'None' , 'LPC1347' ],
'Board_rf1ghznode' => ['' , 'Cortex-M0', 'None' , 'LPC11U37FBD48_401'],
);
my @mcu_para = @{$mcu_para_hash{$board}};
die "Board is not supported" unless @mcu_para;
my $cmd = "cspybat \"$bin_path/armproc.dll\" \"$bin_path/armjlink.dll\" \"$debug_file\" --download_only --plugin \"$bin_path/armbat.dll\"";
$cmd .= " --macro \"$debugger_path/Trace_$mcu_para[0].dmac\"" if $mcu_para[0];
$repo_mcu_iar = "$repo_path/mcu/lpc43xx/iar";
$cmd .= " --macro \"$repo_mcu_iar/lpc18xx_43xx_debug.mac\" --flash_loader \"$repo_mcu_iar/FlashLPC18xx_43xx_SPIFI.board\"" if $board eq 'Board_NGX4330';
$cmd .= " --backend -B \"--endian=little\" \"--cpu=$mcu_para[1]\" \"--fpu=$mcu_para[2]\" \"-p\" \"$debugger_path/$mcu_para[3].ddf\" \"--semihosting\" \"--device=$mcu_para[3]\"";
#SWD interface --> need change if use lpc43xx_m0
$cmd .= " \"--drv_communication=USB0\" \"--jlink_speed=auto\" \"--jlink_initial_speed=1000\" \"--jlink_reset_strategy=0,0\" \"--jlink_interface=SWD\" \"--drv_catch_exceptions=0x000\" --drv_swo_clock_setup=72000000,0,2000000\"";
$cmd .= " \"--jlink_script_file=$debugger_path/LPC4350_DebugCortexM4.JLinkScript\"" if $mcu_para[3] =~ /LPC43.._M4/;
$cmd =~ s/\//\\/g;
#print $cmd; die;
return $cmd;
}

View File

@ -1,154 +0,0 @@
#!/usr/bin/perl
################## HOW TO USE THIS FILE #####################
# iar keil xpresso to build with those toolchain
# clean or build for action
#############################################################
use List::MoreUtils 'any';
use File::Spec;
use File::Find;
use File::Path;
use File::Glob;
use File::stat;
use File::Basename;
use Cwd;
use Cwd 'abs_path';
#use Time::Piece;
#use Time::Seconds;
$" = "\n"; # change list separator
$KEIL_PATH = 'C:/Keil/UV4'; #'/C/Keil/UV4';
$IAR_PATH = glob ('C:/Program*/IAR*/Embedded*/common/bin');
$XPRESSO_PATH = glob ('C:/nxp/LPCXpresso_7*/lpcxpresso');
$XPRESSO_PATH = "$XPRESSO_PATH;$XPRESSO_PATH/bin;$XPRESSO_PATH/tools/bin;$XPRESSO_PATH/msys/bin";
$ENV{'PATH'} = $KEIL_PATH . ';' . $IAR_PATH . ';' . $XPRESSO_PATH . ';' . $ENV{'PATH'};
#print $ENV{'PATH'}; die;
$repo_path = abs_path(cwd . "/..");
#print $repo_path; die;
$device_dir = "device/device";
$host_dir = "host/host";
$is_build = any { /build/ } @ARGV;
$is_clean = any { /clean/ } @ARGV;
$is_build = 1 if !$is_clean; # default is build
$is_keil = (any { /keil/ } @ARGV) || (any { /all/ } @ARGV);
$is_iar = (any { /iar/ } @ARGV) || (any { /all/ } @ARGV);
$is_xpresso = (any { /xpresso/ } @ARGV) || (any { /all/ } @ARGV);
################## KEIL #####################
if ($is_keil)
{
@KEIL_PROJECT_LIST = (<$device_dir*/*.uvproj>, <$host_dir*/*.uvproj>);
foreach (@KEIL_PROJECT_LIST)
{
/([^\/]+).uvproj/;
my $log_file = "build_all_keil_" . $1 . ".txt";
my $build_cmd = "Uv4 -b $_ -z -j0 -o ../../$log_file";
cmd_execute($build_cmd);
}
}
################## IAR #####################
if ($is_iar)
{
@IAR_PROJECT_LIST = (<$device_dir*/*.ewp>, <$host_dir*/*.ewp>);
foreach (@IAR_PROJECT_LIST)
{
my $proj_dir = dirname $_;
/([^\/]+).ewp/;
my $proj_name = $1;
my $log_file = "build_all_iar_" . $proj_name . ".txt";
unlink $log_file; #delete log_file if existed
#open project file to get configure name
my $file_content = file_to_var($_);
#get configure by pattern and build
while ($file_content =~ /^\s*<configuration>\s*$^\s*<name>(.+)<\/name>\s*$/gm)
{
my $build_cmd = "IarBuild $_ -build $1 -log warnings >> $log_file";
cmd_execute($build_cmd);
my $out_file = "$proj_dir/$1/Exe/$proj_name.out";
system("size $out_file >> $log_file");
}
}
}
################## LPCXPRESSO #####################
($repo_path_other_dash = $repo_path) =~ s/\//\\/g;
if ($is_xpresso)
{
$workspace_dir = "C:/Users/hathach/Dropbox/tinyusb/workspace7"; #projects must be opened in the workspace to be built
@XPRESSO_PROJECT_LIST = (<$device_dir*/.cproject>, <$host_dir*/.cproject>);
foreach (@XPRESSO_PROJECT_LIST)
{
/([^\/]+)\/.cproject/;
my $log_file = "build_all_xpresso_" . $1 . ".txt";
my $build_cmd = "lpcxpressoc -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild -cleanBuild $1 -data $workspace_dir > $log_file";
cmd_execute($build_cmd);
#open log file to clean up output
open (my $fin, $log_file) or die;
my @log_content = <$fin>;
close($fin);
open (my $fout, ">$log_file") or die;
foreach (@log_content)
{
unless (/Invoking: MCU C Compiler/ or /arm-none-eabi-gcc -D/ or /Finished building:/ or /^ $/)
{
s/Building file:.+?([^\/]+\.[ch])/\1/;
s/$repo_path//;
s/$repo_path_other_dash//;
print $fout $_;
}
}
}
}
### call report builder ###
system("perl build_report.pl");
################## HELPER #####################
sub cmd_execute
{
print "executing: $_[0]\n...";
system($_[0]);
print "done\n";
}
sub file_to_var
{ #open project file to get configure name
my $file_content;
open(my $fin, $_[0]) or die "Can't open $_[0] to read\n";
{
local $/;
$file_content = <$fin>;
close($fin);
}
return $file_content;
}
sub var_to_file
{ # file name, content
open(my $fout, ">$_[0]") or die "Can't open $_[0] to write\n";
{
print $fout $_[1];
close($fout);
}
}

View File

@ -1,64 +0,0 @@
#!/usr/bin/perl
use Scalar::Util qw(looks_like_number);
$" = "\n"; # change list separator
$keil_size = "Program Size:.+";
%report_patterns =
( #toolchain, pattern-list
'keil' => ['Build target \'(.+)\'', '(\d+ Error.+\d+ Warning)', $keil_size . 'Code=(\d+)', $keil_size . 'RO-data=(\d+)', $keil_size . 'RW-data=(\d+)', $keil_size . 'ZI-data=(\d+)'],
'iar' => ['Building configuration.+ (.+)', 'Total number of (.+)', '((\s+\d+){4})\s+[0-9a-f]+'],
'xpresso' => ['Build of configuration (\S+) ', '(Finished) building target', '((\s+\d+){4})\s+[0-9a-f]+']
);
@report_file_list = <build_all_*.txt>;
#print "@report_file_list"; die;
open $freport, ">build_report.txt" or die "cannot open build_reprot.txt";
foreach (@report_file_list)
{
/build_all_([^_]+)_/;
build_report($_, $1);
}
sub build_report
{
my $report_file = $_[0];
my $toolchain = $_[1];
my @pattern = @{$report_patterns{$toolchain}};
open $report_handle, $report_file or die "cannot open $report_file";
$report_file =~ /build_all_(.+).txt/;
print $freport "--------------------------------------------------------------------\n";
printf $freport "%-25s", $1;
printf $freport "%13s", "" if $toolchain eq 'iar';
print $freport " text data bss dec" if $toolchain eq 'xpresso' or $toolchain eq 'iar';
print $freport " Code RO RW ZI" if $toolchain eq 'keil';
print $freport "\n--------------------------------------------------------------------";
while( my $line = <$report_handle> )
{
local $/ = "\r\n";
chomp $line;
foreach (@pattern)
{
if ($line =~ /$_/)
{
my $fmat = ($_ eq $pattern[0]) ? "\n%-25s" : "%s ";
$fmat = "%6s " if $toolchain eq 'keil' and looks_like_number($1);
printf $freport $fmat, $1;
}
}
}
close $report_handle;
print $freport "\n\n";
}

View File

@ -0,0 +1,6 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="cdc_msc_hid" target="8" version="2">
<import file_name="nrf5x/nrf5x.emProject" />
<import file_name="samd21/samd21.emProject" />
<import file_name="samd51/samd51.emProject" />
</solution>

View File

@ -19,49 +19,26 @@
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056;CFG_TUSB_MCU=OPT_MCU_NRF5X"
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include"
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
debug_register_definition_file="nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
linker_memory_map_file="$(ProjectDir)/nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="$(ProjectDir)/flash_placement.xml"
macros="DeviceHeaderFile=$(PackagesDir)/nRF/CMSIS/Device/Include/nrf.h;DeviceLibraryIdentifier=M4lf;DeviceSystemFile=$(PackagesDir)/nRF/CMSIS/Device/Source/system_nrf52840.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/ses_nrf52840_Vectors.s;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;rootDir=../../../../..;nrfxDir=../../../../../hw/mcu/nordic/nrfx"
link_use_linker_script_file="No"
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
macros="DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;rootDir=../../../../..;nrfxDir=../../../../../hw/mcu/nordic/nrfx"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/nRF_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder Name="Script Files">
<file file_name="nRF_Target.js">
<configuration Name="Common" file_type="Reset Script" />
</file>
</folder>
<folder Name="System Files">
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="src">
<file file_name="../../src/main.c" />
<file file_name="../../src/tusb_config.h" />
<file file_name="../../src/tusb_descriptors.c" />
<file file_name="../../src/tusb_descriptors.h" />
<file file_name="../../src/msc_app.c" />
<file file_name="../../src/msc_app.h" />
<file file_name="../../src/msc_flash_ram.c" />
<file file_name="../../src/msc_flash_qspi.c" />
<folder Name="segger_rtt">
<file file_name="../../src/segger_rtt/SEGGER_RTT.c" />
<file file_name="../../src/segger_rtt/SEGGER_RTT_Conf.h" />
<file file_name="../../src/segger_rtt/SEGGER_RTT.h" />
<file file_name="../../src/segger_rtt/SEGGER_RTT_SES.c" />
</folder>
</folder>
<folder Name="hw">
<folder Name="bsp">
<folder Name="pca10056">
@ -108,16 +85,25 @@
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="flash_placement.xml" />
<file file_name="nrf52840_Registers.xml" />
<file file_name="nRF52840_xxAA_MemoryMap.xml" />
<file file_name="nRF_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
</project>
<configuration
Name="Debug"
c_preprocessor_definitions="DEBUG"
gcc_debugging_level="Level 3"
gcc_optimization_level="None" />
<configuration
Name="Release"
c_preprocessor_definitions="NDEBUG"
gcc_debugging_level="None"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="Level 1" />
<configuration Name="pca10056" />
</solution>

View File

@ -0,0 +1,103 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="samd21" target="8" version="2">
<project Name="samd21">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v6M"
arm_core_type="Cortex-M0+"
arm_endian="Little"
arm_fpu_type="None"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD21G18A"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD21G18A__;__SAMD21_FAMILY;__SAM_D21_SUBFAMILY;ARM_MATH_CM0PLUS;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;CONF_XOSC32K_CONFIG=1;CONF_OSC32K_ENABLE=1;CONF_OSC32K_EN32K=1;CONF_XOSC32K_STARTUP=CONF_XOSC32K_STARTUP_TIME_2000092MCS;CONF_DFLL_ONDEMAND=0;CONF_DFLL_OVERWRITE_CALIBRATION=0;BOARD_METRO_M0_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD21"
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk;$(asf4Dir)/hpl/pm"
debug_register_definition_file="ATSAMD21G18A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="$(ProjectDir)/ATSAMD21G18A_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd21"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/SAMD21_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../../hw/bsp/board.h" />
<folder Name="metro_m0_express">
<file file_name="../../../../../hw/bsp/metro_m0_express/board_metro_m0_express.c" />
<file file_name="../../../../../hw/bsp/metro_m0_express/board_metro_m0_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd21">
<folder Name="gcc">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/core/hpl_init.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" />
</folder>
<folder Name="pm">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" />
</folder>
<folder Name="sysctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="ATSAMD21G18A_MemoryMap.xml" />
<file file_name="ATSAMD21G18A_Registers.xml" />
<file file_name="ATSAMD21G18A_Vectors.s" />
<file file_name="flash_placement.xml" />
<file file_name="SAMD21_Startup.s" />
<file file_name="SAMD21_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
</project>
<configuration Name="Metro M0 Express" />
</solution>

View File

@ -0,0 +1,107 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="samd51" target="8" version="2">
<project Name="samd51">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD51J19"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD51_FAMILY;__SAMD51J19A__;ARM_MATH_CM4;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;BOARD_METRO_M4_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD51"
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk"
debug_register_definition_file="ATSAMD51J19A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="ATSAMD51J19A_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd51"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/SAMD51_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../../hw/bsp/board.h" />
<folder Name="metro_m4_express">
<file file_name="../../../../../hw/bsp/metro_m4_express/board_metro_m4_express.c" />
<file file_name="../../../../../hw/bsp/metro_m4_express/board_metro_m4_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd51">
<folder Name="gcc">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/core/hpl_init.c" />
</folder>
<folder Name="osc32kctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" />
</folder>
<folder Name="oscctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" />
</folder>
<folder Name="mclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="ATSAMD51J19A_MemoryMap.xml" />
<file file_name="ATSAMD51J19A_Registers.xml" />
<file file_name="ATSAMD51J19A_Vectors.s" />
<file file_name="flash_placement.xml" />
<file file_name="SAMD51_Startup.s" />
<file file_name="SAMD51_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
</project>
<configuration Name="Metro M4 Express" />
</solution>

View File

@ -36,7 +36,8 @@
*/
/**************************************************************************/
#include "msc_app.h"
#include "bsp/board.h"
#include "tusb.h"
#if CFG_TUD_MSC

View File

@ -1,6 +1,6 @@
/**************************************************************************/
/*!
@file msc_flash_ram.c
@file msc_disk_ram.c
@author hathach (tinyusb.org)
@section LICENSE
@ -36,18 +36,22 @@
*/
/**************************************************************************/
#include "msc_app.h"
#include "bsp/board.h"
#include "tusb.h"
#if CFG_TUD_MSC && defined (BOARD_MSC_FLASH_RAM)
#if CFG_TUD_MSC
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
#define README_CONTENTS \
"This is tinyusb's MassStorage Class demo.\r\n\r\n\
If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
enum
{
DISK_BLOCK_NUM = 16, // 8KB is the smallest size that windows allow to mount
DISK_BLOCK_SIZE = 512
};
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN
uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
{
//------------- Boot Sector -------------//
@ -81,7 +85,7 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
// second entry is readme file
'R' , 'E' , 'A' , 'D' , 'M' , 'E' , ' ' , ' ' , 'T' , 'X' , 'T' , 0x20, 0x00, 0xC6, 0x52, 0x6D,
0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's filesize (4 Bytes)
sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's files ize (4 Bytes)
},
//------------- Readme Content -------------//
@ -93,6 +97,8 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
(void) lun;
uint8_t* addr = msc_device_ramdisk[lba] + offset;
memcpy(buffer, addr, bufsize);
@ -101,16 +107,22 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{
(void) lun;
uint8_t* addr = msc_device_ramdisk[lba] + offset;
memcpy(addr, buffer, bufsize);
return bufsize;
}
//--------------------------------------------------------------------+
// HELPER
//--------------------------------------------------------------------+
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
{
(void) lun;
*block_count = DISK_BLOCK_NUM;
*block_size = DISK_BLOCK_SIZE;
}
#endif

View File

@ -55,14 +55,8 @@
#endif
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#define CFG_TUSB_DEBUG 2
/*------------- RTOS -------------*/
#define CFG_TUSB_OS OPT_OS_NONE // be passed from IDE/command line for easy project switching
//#define CFG_TUD_TASK_PRIO 0
//#define CFG_TUD_TASK_QUEUE_SZ 16
//#define CFG_TUD_TASK_STACK_SZ 150
#define CFG_TUSB_OS OPT_OS_NONE
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
@ -87,7 +81,7 @@
//------------- CLASS -------------//
#define CFG_TUD_CDC 1
#define CFG_TUD_MSC 0
#define CFG_TUD_MSC 1
#define CFG_TUD_HID 0
#define CFG_TUD_HID_KEYBOARD 0
@ -118,12 +112,6 @@
// Buffer size of Device Mass storage
#define CFG_TUD_MSC_BUFSIZE 512
// Number of Blocks
#define CFG_TUD_MSC_BLOCK_NUM BOARD_MSC_FLASH_SIZE/CFG_TUD_MSC_BLOCK_SZ
// Block size
#define CFG_TUD_MSC_BLOCK_SZ 512
// Vendor name included in Inquiry response, max 8 bytes
#define CFG_TUD_MSC_VENDOR "tinyusb"

View File

@ -0,0 +1,6 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="cdc_msc_hid_freertos" target="8" version="2">
<import file_name="nrf5x/nrf5x.emProject" />
<import file_name="samd21/samd21.emProject" />
<import file_name="samd51/samd51.emProject" />
</solution>

View File

@ -0,0 +1,152 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="nrf5x" target="8" version="2">
<project Name="nrf5x">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="ROM;0x00000000;0x00100000;RAM;0x20000000;0x00040000"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056;CFG_TUSB_MCU=OPT_MCU_NRF5X"
c_user_include_directories="./;../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM4F"
debug_register_definition_file="nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
macros="DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;rootDir=../../../../..;nrfxDir=../../../../../hw/mcu/nordic/nrfx;freertosDir=../../../../../lib/FreeRTOS"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/nRF_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<folder Name="pca10056">
<file file_name="../../../../../hw/bsp/pca10056/board_pca10056.c" />
<file file_name="../../../../../hw/bsp/pca10056/board_pca10056.h" />
</folder>
<file file_name="../../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../../hw/bsp/board.h" />
</folder>
<folder Name="mcu">
<folder Name="nordic">
<folder Name="nrfx">
<folder Name="drivers">
<folder Name="include">
<file file_name="../../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_power_clock.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_power.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_qspi.h" />
</folder>
<folder Name="src">
<file file_name="../../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_qspi.c" />
</folder>
</folder>
<folder Name="hal">
<file file_name="../../../../../hw/mcu/nordic/nrfx/hal/nrf_power.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/hal/nrf_qspi.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/hal/nrf_usbd.h" />
</folder>
<folder Name="mdk">
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/nrf51_to_nrf52840.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_bitfields.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/nrf52840.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_peripherals.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/nrf52_to_nrf52840.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf52840.s" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf_common.s" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.c" />
<file file_name="../../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.h" />
</folder>
</folder>
<file file_name="../../../../../hw/mcu/nordic/nrfx_config.h" />
<file file_name="../../../../../hw/mcu/nordic/nrfx_glue.h" />
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="flash_placement.xml" />
<file file_name="nrf52840_Registers.xml" />
<file file_name="nRF52840_xxAA_MemoryMap.xml" />
<file file_name="nRF_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
<folder Name="lib">
<folder Name="FreeRTOS">
<folder Name="Source">
<folder Name="include">
<file file_name="../../../../../lib/FreeRTOS/Source/include/croutine.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/deprecated_definitions.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/event_groups.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/FreeRTOS.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/list.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/message_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_prototypes.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_wrappers.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/portable.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/projdefs.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/queue.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/semphr.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stack_macros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/StackMacros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stream_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/task.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/timers.h" />
</folder>
<folder Name="portable">
<folder Name="Common" />
<folder Name="GCC">
<folder Name="ARM_CM4F">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" />
</folder>
</folder>
<folder Name="MemMang">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/MemMang/heap_4.c" />
</folder>
</folder>
<file file_name="../../../../../lib/FreeRTOS/Source/list.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/queue.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/tasks.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/timers.c" />
</folder>
<file file_name="../../../../../lib/FreeRTOS/FreeRTOSConfig.h" />
<file file_name="../../../../../lib/FreeRTOS/freertos_hook.c" />
</folder>
</folder>
</project>
<configuration Name="pca10056" />
</solution>

View File

@ -0,0 +1,5 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="ATSAMD21G18A">
<MemorySegment name="FLASH" start="0x00002000" size="0x0003E000" access="ReadOnly" />
<MemorySegment name="RAM" start="0x20000000" size="0x00008000" access="Read/Write" />
</root>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,331 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
/*****************************************************************************
* Preprocessor Definitions *
* ------------------------ *
* VECTORS_IN_RAM *
* *
* If defined, an area of RAM will large enough to store the vector table *
* will be reserved. *
* *
*****************************************************************************/
.syntax unified
.code 16
.section .init, "ax"
.align 0
/*****************************************************************************
* Default Exception Handlers *
*****************************************************************************/
.thumb_func
.weak NMI_Handler
NMI_Handler:
b .
.thumb_func
.weak HardFault_Handler
HardFault_Handler:
b .
.thumb_func
.weak SVC_Handler
SVC_Handler:
b .
.thumb_func
.weak PendSV_Handler
PendSV_Handler:
b .
.thumb_func
.weak SysTick_Handler
SysTick_Handler:
b .
.thumb_func
Dummy_Handler:
b .
#if defined(__OPTIMIZATION_SMALL)
.weak PM_Handler
.thumb_set PM_Handler,Dummy_Handler
.weak SYSCTRL_Handler
.thumb_set SYSCTRL_Handler,Dummy_Handler
.weak WDT_Handler
.thumb_set WDT_Handler,Dummy_Handler
.weak RTC_Handler
.thumb_set RTC_Handler,Dummy_Handler
.weak EIC_Handler
.thumb_set EIC_Handler,Dummy_Handler
.weak NVMCTRL_Handler
.thumb_set NVMCTRL_Handler,Dummy_Handler
.weak DMAC_Handler
.thumb_set DMAC_Handler,Dummy_Handler
.weak USB_Handler
.thumb_set USB_Handler,Dummy_Handler
.weak EVSYS_Handler
.thumb_set EVSYS_Handler,Dummy_Handler
.weak SERCOM0_Handler
.thumb_set SERCOM0_Handler,Dummy_Handler
.weak SERCOM1_Handler
.thumb_set SERCOM1_Handler,Dummy_Handler
.weak SERCOM2_Handler
.thumb_set SERCOM2_Handler,Dummy_Handler
.weak SERCOM3_Handler
.thumb_set SERCOM3_Handler,Dummy_Handler
.weak SERCOM4_Handler
.thumb_set SERCOM4_Handler,Dummy_Handler
.weak SERCOM5_Handler
.thumb_set SERCOM5_Handler,Dummy_Handler
.weak TCC0_Handler
.thumb_set TCC0_Handler,Dummy_Handler
.weak TCC1_Handler
.thumb_set TCC1_Handler,Dummy_Handler
.weak TCC2_Handler
.thumb_set TCC2_Handler,Dummy_Handler
.weak TC3_Handler
.thumb_set TC3_Handler,Dummy_Handler
.weak TC4_Handler
.thumb_set TC4_Handler,Dummy_Handler
.weak TC5_Handler
.thumb_set TC5_Handler,Dummy_Handler
.weak ADC_Handler
.thumb_set ADC_Handler,Dummy_Handler
.weak AC_Handler
.thumb_set AC_Handler,Dummy_Handler
.weak DAC_Handler
.thumb_set DAC_Handler,Dummy_Handler
.weak I2S_Handler
.thumb_set I2S_Handler,Dummy_Handler
#else
.thumb_func
.weak PM_Handler
PM_Handler:
b .
.thumb_func
.weak SYSCTRL_Handler
SYSCTRL_Handler:
b .
.thumb_func
.weak WDT_Handler
WDT_Handler:
b .
.thumb_func
.weak RTC_Handler
RTC_Handler:
b .
.thumb_func
.weak EIC_Handler
EIC_Handler:
b .
.thumb_func
.weak NVMCTRL_Handler
NVMCTRL_Handler:
b .
.thumb_func
.weak DMAC_Handler
DMAC_Handler:
b .
.thumb_func
.weak USB_Handler
USB_Handler:
b .
.thumb_func
.weak EVSYS_Handler
EVSYS_Handler:
b .
.thumb_func
.weak SERCOM0_Handler
SERCOM0_Handler:
b .
.thumb_func
.weak SERCOM1_Handler
SERCOM1_Handler:
b .
.thumb_func
.weak SERCOM2_Handler
SERCOM2_Handler:
b .
.thumb_func
.weak SERCOM3_Handler
SERCOM3_Handler:
b .
.thumb_func
.weak SERCOM4_Handler
SERCOM4_Handler:
b .
.thumb_func
.weak SERCOM5_Handler
SERCOM5_Handler:
b .
.thumb_func
.weak TCC0_Handler
TCC0_Handler:
b .
.thumb_func
.weak TCC1_Handler
TCC1_Handler:
b .
.thumb_func
.weak TCC2_Handler
TCC2_Handler:
b .
.thumb_func
.weak TC3_Handler
TC3_Handler:
b .
.thumb_func
.weak TC4_Handler
TC4_Handler:
b .
.thumb_func
.weak TC5_Handler
TC5_Handler:
b .
.thumb_func
.weak ADC_Handler
ADC_Handler:
b .
.thumb_func
.weak AC_Handler
AC_Handler:
b .
.thumb_func
.weak DAC_Handler
DAC_Handler:
b .
.thumb_func
.weak I2S_Handler
I2S_Handler:
b .
#endif
/*****************************************************************************
* Vector Table *
*****************************************************************************/
.section .vectors, "ax"
.align 0
.global _vectors
.extern __stack_end__
.extern Reset_Handler
_vectors:
.word __stack_end__
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word SVC_Handler
.word 0 /* Reserved */
.word 0 /* Reserved */
.word PendSV_Handler
.word SysTick_Handler
.word PM_Handler
.word SYSCTRL_Handler
.word WDT_Handler
.word RTC_Handler
.word EIC_Handler
.word NVMCTRL_Handler
.word DMAC_Handler
.word USB_Handler
.word EVSYS_Handler
.word SERCOM0_Handler
.word SERCOM1_Handler
.word SERCOM2_Handler
.word SERCOM3_Handler
.word SERCOM4_Handler
.word SERCOM5_Handler
.word TCC0_Handler
.word TCC1_Handler
.word TCC2_Handler
.word TC3_Handler
.word TC4_Handler
.word TC5_Handler
.word Dummy_Handler /* Reserved */
.word Dummy_Handler /* Reserved */
.word ADC_Handler
.word AC_Handler
.word DAC_Handler
.word Dummy_Handler /* Reserved */
.word I2S_Handler
_vectors_end:
#ifdef VECTORS_IN_RAM
.section .vectors_ram, "ax"
.align 0
.global _vectors_ram
_vectors_ram:
.space _vectors_end - _vectors, 0
#endif

View File

@ -0,0 +1,114 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
/*****************************************************************************
* Preprocessor Definitions *
* ------------------------ *
* NO_STACK_INIT *
* *
* If defined, the stack pointer will not be initialised. *
* *
* NO_SYSTEM_INIT *
* *
* If defined, the SystemInit() function will not be called. By default *
* SystemInit() is called after reset to enable the clocks and memories to *
* be initialised prior to any C startup initialisation. *
* *
* NO_VTOR_CONFIG *
* *
* If defined, the vector table offset register will not be configured. *
* *
* MEMORY_INIT *
* *
* If defined, the MemoryInit() function will be called. By default *
* MemoryInit() is called after SystemInit() to enable an external memory *
* controller. *
* *
* STACK_INIT_VAL *
* *
* If defined, specifies the initial stack pointer value. If undefined, *
* the stack pointer will be initialised to point to the end of the *
* RAM segment. *
* *
* VECTORS_IN_RAM *
* *
* If defined, the exception vectors will be copied from Flash to RAM. *
* *
*****************************************************************************/
.syntax unified
.global Reset_Handler
.extern _vectors
.section .init, "ax"
.thumb_func
.equ VTOR_REG, 0xE000ED08
#ifndef STACK_INIT_VAL
#define STACK_INIT_VAL __RAM_segment_end__
#endif
Reset_Handler:
#ifndef NO_STACK_INIT
/* Initialise main stack */
ldr r0, =STACK_INIT_VAL
ldr r1, =0x7
bics r0, r1
mov sp, r0
#endif
#ifndef NO_SYSTEM_INIT
/* Initialise system */
ldr r0, =SystemInit
blx r0
.pushsection .init_array, "aw", %init_array
.word SystemCoreClockUpdate
.popsection
#endif
#ifdef MEMORY_INIT
ldr r0, =MemoryInit
blx r0
#endif
#ifdef VECTORS_IN_RAM
/* Copy exception vectors into RAM */
ldr r0, =__vectors_start__
ldr r1, =__vectors_end__
ldr r2, =__vectors_ram_start__
1:
cmp r0, r1
beq 2f
ldr r3, [r0]
str r3, [r2]
adds r0, r0, #4
adds r2, r2, #4
b 1b
2:
#endif
#ifndef NO_VTOR_CONFIG
/* Configure vector table offset register */
ldr r0, =VTOR_REG
#ifdef VECTORS_IN_RAM
ldr r1, =_vectors_ram
#else
ldr r1, =_vectors
#endif
str r1, [r0]
#endif
/* Jump to program start */
b _start

View File

@ -0,0 +1,19 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
function Reset() {
TargetInterface.resetAndStop();
}
function EnableTrace(traceInterfaceType) {
// TODO: Enable trace
}

View File

@ -0,0 +1,37 @@
<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
<MemorySegment name="$(FLASH_NAME:FLASH)">
<ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
<ProgramSection alignment="4" load="Yes" name=".init" />
<ProgramSection alignment="4" load="Yes" name=".init_rodata" />
<ProgramSection alignment="4" load="Yes" name=".text" />
<ProgramSection alignment="4" load="Yes" name=".dtors" />
<ProgramSection alignment="4" load="Yes" name=".ctors" />
<ProgramSection alignment="4" load="Yes" name=".rodata" />
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
</MemorySegment>
<MemorySegment name="$(RAM_NAME:RAM);SRAM">
<ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
<ProgramSection alignment="4" load="No" name=".fast_run" />
<ProgramSection alignment="4" load="No" name=".data_run" />
<ProgramSection alignment="4" load="No" name=".bss" />
<ProgramSection alignment="4" load="No" name=".tbss" />
<ProgramSection alignment="4" load="No" name=".tdata_run" />
<ProgramSection alignment="4" load="No" name=".non_init" />
<ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
<ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
<ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
</MemorySegment>
<MemorySegment name="$(FLASH2_NAME:FLASH2)">
<ProgramSection alignment="4" load="Yes" name=".text2" />
<ProgramSection alignment="4" load="Yes" name=".rodata2" />
<ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
</MemorySegment>
<MemorySegment name="$(RAM2_NAME:RAM2)">
<ProgramSection alignment="4" load="No" name=".data2_run" />
<ProgramSection alignment="4" load="No" name=".bss2" />
</MemorySegment>
</Root>

View File

@ -0,0 +1,146 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="samd21" target="8" version="2">
<project Name="samd21">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v6M"
arm_core_type="Cortex-M0+"
arm_endian="Little"
arm_fpu_type="None"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD21G18A"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD21G18A__;__SAMD21_FAMILY;__SAM_D21_SUBFAMILY;ARM_MATH_CM0PLUS;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;CONF_XOSC32K_CONFIG=1;CONF_OSC32K_ENABLE=1;CONF_OSC32K_EN32K=1;CONF_XOSC32K_STARTUP=CONF_XOSC32K_STARTUP_TIME_2000092MCS;CONF_DFLL_ONDEMAND=0;CONF_DFLL_OVERWRITE_CALIBRATION=0;BOARD_METRO_M0_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD21"
c_user_include_directories="./;../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk;$(asf4Dir)/hpl/pm;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM0"
debug_register_definition_file="ATSAMD21G18A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="$(ProjectDir)/ATSAMD21G18A_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd21;freertosDir=../../../../../lib/FreeRTOS"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/SAMD21_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../../hw/bsp/board.h" />
<folder Name="metro_m0_express">
<file file_name="../../../../../hw/bsp/metro_m0_express/board_metro_m0_express.c" />
<file file_name="../../../../../hw/bsp/metro_m0_express/board_metro_m0_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd21">
<folder Name="gcc">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/core/hpl_init.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" />
</folder>
<folder Name="pm">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" />
</folder>
<folder Name="sysctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="ATSAMD21G18A_MemoryMap.xml" />
<file file_name="ATSAMD21G18A_Registers.xml" />
<file file_name="ATSAMD21G18A_Vectors.s" />
<file file_name="flash_placement.xml" />
<file file_name="SAMD21_Startup.s" />
<file file_name="SAMD21_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
<folder Name="lib">
<folder Name="FreeRTOS">
<folder Name="Source">
<folder Name="include">
<file file_name="../../../../../lib/FreeRTOS/Source/include/croutine.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/deprecated_definitions.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/event_groups.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/FreeRTOS.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/list.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/message_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_prototypes.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_wrappers.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/portable.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/projdefs.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/queue.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/semphr.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stack_macros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/StackMacros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stream_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/task.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/timers.h" />
</folder>
<folder Name="portable">
<folder Name="Common" />
<folder Name="GCC">
<folder Name="ARM_CM0">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h" />
</folder>
</folder>
<folder Name="MemMang">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/MemMang/heap_4.c" />
</folder>
</folder>
<file file_name="../../../../../lib/FreeRTOS/Source/list.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/queue.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/tasks.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/timers.c" />
</folder>
<file file_name="../../../../../lib/FreeRTOS/FreeRTOSConfig.h" />
<file file_name="../../../../../lib/FreeRTOS/freertos_hook.c" />
</folder>
</folder>
</project>
<configuration Name="Metro M0 Express" />
</solution>

View File

@ -0,0 +1,415 @@
// **********************************************************************
// * SEGGER Microcontroller GmbH *
// * The Embedded Experts *
// **********************************************************************
// * *
// * (c) 2014 - 2018 SEGGER Microcontroller GmbH *
// * (c) 2001 - 2018 Rowley Associates Limited *
// * *
// * www.segger.com Support: support@segger.com *
// * *
// **********************************************************************
// * *
// * All rights reserved. *
// * *
// * Redistribution and use in source and binary forms, with or *
// * without modification, are permitted provided that the following *
// * conditions are met: *
// * *
// * - Redistributions of source code must retain the above copyright *
// * notice, this list of conditions and the following disclaimer. *
// * *
// * - Neither the name of SEGGER Microcontroller GmbH *
// * nor the names of its contributors may be used to endorse or *
// * promote products derived from this software without specific *
// * prior written permission. *
// * *
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
// * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
// * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
// * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
// * DISCLAIMED. *
// * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
// * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
// * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
// * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
// * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
// * DAMAGE. *
// * *
// **********************************************************************
//
//
// Preprocessor Definitions
// ------------------------
// APP_ENTRY_POINT
//
// Defines the application entry point function, if undefined this setting
// defaults to "main".
//
// INITIALIZE_STACK
//
// If defined, the contents of the stack will be initialized to a the
// value 0xCC.
//
// INITIALIZE_SECONDARY_SECTIONS
//
// If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
//
// INITIALIZE_TCM_SECTIONS
//
// If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections
// will be initialized.
//
// INITIALIZE_USER_SECTIONS
//
// If defined, the function InitializeUserMemorySections will be called prior
// to entering main in order to allow the user to initialize any user defined
// memory sections.
//
// FULL_LIBRARY
//
// If defined then
// - argc, argv are setup by the debug_getargs.
// - the exit symbol is defined and executes on return from main.
// - the exit symbol calls destructors, atexit functions and then debug_exit.
//
// If not defined then
// - argc and argv are zero.
// - the exit symbol is defined, executes on return from main and loops
//
#ifndef APP_ENTRY_POINT
#define APP_ENTRY_POINT main
#endif
#ifndef ARGSSPACE
#define ARGSSPACE 128
#endif
.syntax unified
.global _start
.extern APP_ENTRY_POINT
.global exit
.weak exit
#ifdef INITIALIZE_USER_SECTIONS
.extern InitializeUserMemorySections
#endif
.section .init, "ax"
.code 16
.balign 2
.thumb_func
_start:
/* Set up main stack if size > 0 */
ldr r1, =__stack_end__
ldr r0, =__stack_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
mov sp, r1
#ifdef INITIALIZE_STACK
movs r2, #0xCC
ldr r0, =__stack_start__
bl memory_set
#endif
1:
/* Set up process stack if size > 0 */
ldr r1, =__stack_process_end__
ldr r0, =__stack_process_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
msr psp, r1
movs r2, #2
msr control, r2
#ifdef INITIALIZE_STACK
movs r2, #0xCC
bl memory_set
#endif
1:
/* Copy initialized memory sections into RAM (if necessary). */
ldr r0, =__data_load_start__
ldr r1, =__data_start__
ldr r2, =__data_end__
bl memory_copy
ldr r0, =__text_load_start__
ldr r1, =__text_start__
ldr r2, =__text_end__
bl memory_copy
ldr r0, =__fast_load_start__
ldr r1, =__fast_start__
ldr r2, =__fast_end__
bl memory_copy
ldr r0, =__ctors_load_start__
ldr r1, =__ctors_start__
ldr r2, =__ctors_end__
bl memory_copy
ldr r0, =__dtors_load_start__
ldr r1, =__dtors_start__
ldr r2, =__dtors_end__
bl memory_copy
ldr r0, =__rodata_load_start__
ldr r1, =__rodata_start__
ldr r2, =__rodata_end__
bl memory_copy
ldr r0, =__tdata_load_start__
ldr r1, =__tdata_start__
ldr r2, =__tdata_end__
bl memory_copy
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__data2_load_start__
ldr r1, =__data2_start__
ldr r2, =__data2_end__
bl memory_copy
ldr r0, =__text2_load_start__
ldr r1, =__text2_start__
ldr r2, =__text2_end__
bl memory_copy
ldr r0, =__rodata2_load_start__
ldr r1, =__rodata2_start__
ldr r2, =__rodata2_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__data_tcm_load_start__
ldr r1, =__data_tcm_start__
ldr r2, =__data_tcm_end__
bl memory_copy
ldr r0, =__text_tcm_load_start__
ldr r1, =__text_tcm_start__
ldr r2, =__text_tcm_end__
bl memory_copy
ldr r0, =__rodata_tcm_load_start__
ldr r1, =__rodata_tcm_start__
ldr r2, =__rodata_tcm_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Zero the bss. */
ldr r0, =__bss_start__
ldr r1, =__bss_end__
movs r2, #0
bl memory_set
ldr r0, =__tbss_start__
ldr r1, =__tbss_end__
movs r2, #0
bl memory_set
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__bss2_start__
ldr r1, =__bss2_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__bss_tcm_start__
ldr r1, =__bss_tcm_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Initialize the heap */
ldr r0, = __heap_start__
ldr r1, = __heap_end__
subs r1, r1, r0
cmp r1, #8
blt 1f
movs r2, #0
str r2, [r0]
adds r0, r0, #4
str r1, [r0]
1:
#ifdef INITIALIZE_USER_SECTIONS
ldr r2, =InitializeUserMemorySections
blx r2
#endif
/* Call constructors */
ldr r0, =__ctors_start__
ldr r1, =__ctors_end__
ctor_loop:
cmp r0, r1
beq ctor_end
ldr r2, [r0]
adds r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b ctor_loop
ctor_end:
/* Setup initial call frame */
movs r0, #0
mov lr, r0
mov r12, sp
.type start, function
start:
/* Jump to application entry point */
#ifdef FULL_LIBRARY
movs r0, #ARGSSPACE
ldr r1, =args
ldr r2, =debug_getargs
blx r2
ldr r1, =args
#else
movs r0, #0
movs r1, #0
#endif
ldr r2, =APP_ENTRY_POINT
blx r2
.thumb_func
exit:
#ifdef FULL_LIBRARY
mov r5, r0 // save the exit parameter/return result
/* Call destructors */
ldr r0, =__dtors_start__
ldr r1, =__dtors_end__
dtor_loop:
cmp r0, r1
beq dtor_end
ldr r2, [r0]
add r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b dtor_loop
dtor_end:
/* Call atexit functions */
ldr r2, =_execute_at_exit_fns
blx r2
/* Call debug_exit with return result/exit parameter */
mov r0, r5
ldr r2, =debug_exit
blx r2
#endif
/* Returned from application entry point, loop forever. */
exit_loop:
b exit_loop
.thumb_func
memory_copy:
cmp r0, r1
beq 2f
subs r2, r2, r1
beq 2f
1:
ldrb r3, [r0]
adds r0, r0, #1
strb r3, [r1]
adds r1, r1, #1
subs r2, r2, #1
bne 1b
2:
bx lr
.thumb_func
memory_set:
cmp r0, r1
beq 1f
strb r2, [r0]
adds r0, r0, #1
b memory_set
1:
bx lr
// default C/C++ library helpers
.macro HELPER helper_name
.section .text.\helper_name, "ax", %progbits
.balign 2
.global \helper_name
.weak \helper_name
\helper_name:
.thumb_func
.endm
.macro JUMPTO name
#if defined(__thumb__) && !defined(__thumb2__)
mov r12, r0
ldr r0, =\name
push {r0}
mov r0, r12
pop {pc}
#else
b \name
#endif
.endm
HELPER __aeabi_read_tp
ldr r0, =__tbss_start__-8
bx lr
HELPER abort
b .
HELPER __assert
b .
HELPER __aeabi_assert
b .
HELPER __sync_synchronize
bx lr
HELPER __getchar
JUMPTO debug_getchar
HELPER __putchar
JUMPTO debug_putchar
HELPER __open
JUMPTO debug_fopen
HELPER __close
JUMPTO debug_fclose
HELPER __write
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fwrite
HELPER __read
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fread
HELPER __seek
push {r4, lr}
mov r4, r0
bl debug_fseek
cmp r0, #0
bne 1f
mov r0, r4
bl debug_ftell
pop {r4, pc}
1:
ldr r0, =-1
pop {r4, pc}
// char __user_locale_name_buffer[];
.section .bss.__user_locale_name_buffer, "aw", %nobits
.global __user_locale_name_buffer
.weak __user_locale_name_buffer
__user_locale_name_buffer:
.word 0x0
#ifdef FULL_LIBRARY
.bss
args:
.space ARGSSPACE
#endif
/* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
.section .stack, "wa", %nobits
.section .stack_process, "wa", %nobits
.section .heap, "wa", %nobits

View File

@ -0,0 +1,6 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="ATSAMD51J19A">
<MemorySegment name="FLASH" start="0x00004000" size="0x0007C000" access="ReadOnly" />
<MemorySegment name="RAM" start="0x20000000" size="0x00030000" access="Read/Write" />
<MemorySegment name="RAM2" start="0x47000000" size="0x00002000" access="Read/Write" />
</root>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
/*****************************************************************************
* Preprocessor Definitions *
* ------------------------ *
* NO_FPU_ENABLE *
* *
* If defined, FPU will not be enabled. *
* *
* NO_STACK_INIT *
* *
* If defined, the stack pointer will not be initialised. *
* *
* NO_SYSTEM_INIT *
* *
* If defined, the SystemInit() function will not be called. By default *
* SystemInit() is called after reset to enable the clocks and memories to *
* be initialised prior to any C startup initialisation. *
* *
* NO_VTOR_CONFIG *
* *
* If defined, the vector table offset register will not be configured. *
* *
* MEMORY_INIT *
* *
* If defined, the MemoryInit() function will be called. By default *
* MemoryInit() is called after SystemInit() to enable an external memory *
* controller. *
* *
* STACK_INIT_VAL *
* *
* If defined, specifies the initial stack pointer value. If undefined, *
* the stack pointer will be initialised to point to the end of the *
* RAM segment. *
* *
* VECTORS_IN_RAM *
* *
* If defined, the exception vectors will be copied from Flash to RAM. *
* *
*****************************************************************************/
.syntax unified
.global Reset_Handler
.extern _vectors
.section .init, "ax"
.thumb_func
.equ VTOR_REG, 0xE000ED08
.equ FPU_CPACR_REG, 0xE000ED88
#ifndef STACK_INIT_VAL
#define STACK_INIT_VAL __RAM_segment_end__
#endif
Reset_Handler:
#ifndef NO_STACK_INIT
/* Initialise main stack */
ldr r0, =STACK_INIT_VAL
bic r0, #0x7
mov sp, r0
#endif
#ifndef NO_SYSTEM_INIT
/* Initialise system */
ldr r0, =SystemInit
blx r0
.pushsection .init_array, "aw", %init_array
.word SystemCoreClockUpdate
.popsection
#endif
#ifdef MEMORY_INIT
ldr r0, =MemoryInit
blx r0
#endif
#ifdef VECTORS_IN_RAM
/* Copy exception vectors into RAM */
ldr r0, =__vectors_start__
ldr r1, =__vectors_end__
ldr r2, =__vectors_ram_start__
1:
cmp r0, r1
beq 2f
ldr r3, [r0]
str r3, [r2]
adds r0, r0, #4
adds r2, r2, #4
b 1b
2:
#endif
#ifndef NO_VTOR_CONFIG
/* Configure vector table offset register */
ldr r0, =VTOR_REG
#ifdef VECTORS_IN_RAM
ldr r1, =_vectors_ram
#else
ldr r1, =_vectors
#endif
str r1, [r0]
#endif
#if (defined(__ARM_ARCH_FPV4_SP_D16__) || defined(__ARM_ARCH_FPV5_D16__)) && !defined(NO_FPU_ENABLE)
/* Enable FPU */
ldr r0, =FPU_CPACR_REG
ldr r1, [r0]
orr r1, r1, #(0xF << 20)
str r1, [r0]
dsb
isb
#endif
/* Jump to program start */
b _start

View File

@ -0,0 +1,19 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
function Reset() {
TargetInterface.resetAndStop();
}
function EnableTrace(traceInterfaceType) {
// TODO: Enable trace
}

View File

@ -0,0 +1,37 @@
<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
<MemorySegment name="$(FLASH_NAME:FLASH)">
<ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
<ProgramSection alignment="4" load="Yes" name=".init" />
<ProgramSection alignment="4" load="Yes" name=".init_rodata" />
<ProgramSection alignment="4" load="Yes" name=".text" />
<ProgramSection alignment="4" load="Yes" name=".dtors" />
<ProgramSection alignment="4" load="Yes" name=".ctors" />
<ProgramSection alignment="4" load="Yes" name=".rodata" />
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
</MemorySegment>
<MemorySegment name="$(RAM_NAME:RAM);SRAM">
<ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
<ProgramSection alignment="4" load="No" name=".fast_run" />
<ProgramSection alignment="4" load="No" name=".data_run" />
<ProgramSection alignment="4" load="No" name=".bss" />
<ProgramSection alignment="4" load="No" name=".tbss" />
<ProgramSection alignment="4" load="No" name=".tdata_run" />
<ProgramSection alignment="4" load="No" name=".non_init" />
<ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
<ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
<ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
</MemorySegment>
<MemorySegment name="$(FLASH2_NAME:FLASH2)">
<ProgramSection alignment="4" load="Yes" name=".text2" />
<ProgramSection alignment="4" load="Yes" name=".rodata2" />
<ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
</MemorySegment>
<MemorySegment name="$(RAM2_NAME:RAM2)">
<ProgramSection alignment="4" load="No" name=".data2_run" />
<ProgramSection alignment="4" load="No" name=".bss2" />
</MemorySegment>
</Root>

View File

@ -0,0 +1,150 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="samd51" target="8" version="2">
<project Name="samd51">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD51J19"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD51_FAMILY;__SAMD51J19A__;ARM_MATH_CM4;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;BOARD_METRO_M4_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD51"
c_user_include_directories="./;../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM4F"
debug_register_definition_file="ATSAMD51J19A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="ATSAMD51J19A_MemoryMap.xml"
linker_section_placement_file="flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd51;freertosDir=../../../../../lib/FreeRTOS"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/SAMD51_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../../hw/bsp/board.h" />
<folder Name="metro_m4_express">
<file file_name="../../../../../hw/bsp/metro_m4_express/board_metro_m4_express.c" />
<file file_name="../../../../../hw/bsp/metro_m4_express/board_metro_m4_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd51">
<folder Name="gcc">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/core/hpl_init.c" />
</folder>
<folder Name="osc32kctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" />
</folder>
<folder Name="oscctrl">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" />
</folder>
<folder Name="mclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../../src"
recurse="Yes" />
<folder Name="System Files">
<file file_name="ATSAMD51J19A_MemoryMap.xml" />
<file file_name="ATSAMD51J19A_Registers.xml" />
<file file_name="ATSAMD51J19A_Vectors.s" />
<file file_name="flash_placement.xml" />
<file file_name="SAMD51_Startup.s" />
<file file_name="SAMD51_Target.js" />
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="segger_rtt"
exclude=""
filter="*.c;*.h"
path="../../../../../lib/segger_rtt"
recurse="No" />
<folder Name="lib">
<folder Name="FreeRTOS">
<folder Name="Source">
<folder Name="include">
<file file_name="../../../../../lib/FreeRTOS/Source/include/croutine.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/deprecated_definitions.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/event_groups.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/FreeRTOS.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/list.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/message_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_prototypes.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/mpu_wrappers.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/portable.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/projdefs.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/queue.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/semphr.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stack_macros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/StackMacros.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/stream_buffer.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/task.h" />
<file file_name="../../../../../lib/FreeRTOS/Source/include/timers.h" />
</folder>
<folder Name="portable">
<folder Name="Common" />
<folder Name="GCC">
<folder Name="ARM_CM4F">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" />
</folder>
</folder>
<folder Name="MemMang">
<file file_name="../../../../../lib/FreeRTOS/Source/portable/MemMang/heap_4.c" />
</folder>
</folder>
<file file_name="../../../../../lib/FreeRTOS/Source/list.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/queue.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/tasks.c" />
<file file_name="../../../../../lib/FreeRTOS/Source/timers.c" />
</folder>
<file file_name="../../../../../lib/FreeRTOS/FreeRTOSConfig.h" />
<file file_name="../../../../../lib/FreeRTOS/freertos_hook.c" />
</folder>
</folder>
</project>
<configuration Name="Metro M4 Express" />
</solution>

View File

@ -0,0 +1,415 @@
// **********************************************************************
// * SEGGER Microcontroller GmbH *
// * The Embedded Experts *
// **********************************************************************
// * *
// * (c) 2014 - 2018 SEGGER Microcontroller GmbH *
// * (c) 2001 - 2018 Rowley Associates Limited *
// * *
// * www.segger.com Support: support@segger.com *
// * *
// **********************************************************************
// * *
// * All rights reserved. *
// * *
// * Redistribution and use in source and binary forms, with or *
// * without modification, are permitted provided that the following *
// * conditions are met: *
// * *
// * - Redistributions of source code must retain the above copyright *
// * notice, this list of conditions and the following disclaimer. *
// * *
// * - Neither the name of SEGGER Microcontroller GmbH *
// * nor the names of its contributors may be used to endorse or *
// * promote products derived from this software without specific *
// * prior written permission. *
// * *
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
// * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
// * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
// * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
// * DISCLAIMED. *
// * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
// * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
// * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
// * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
// * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
// * DAMAGE. *
// * *
// **********************************************************************
//
//
// Preprocessor Definitions
// ------------------------
// APP_ENTRY_POINT
//
// Defines the application entry point function, if undefined this setting
// defaults to "main".
//
// INITIALIZE_STACK
//
// If defined, the contents of the stack will be initialized to a the
// value 0xCC.
//
// INITIALIZE_SECONDARY_SECTIONS
//
// If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
//
// INITIALIZE_TCM_SECTIONS
//
// If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections
// will be initialized.
//
// INITIALIZE_USER_SECTIONS
//
// If defined, the function InitializeUserMemorySections will be called prior
// to entering main in order to allow the user to initialize any user defined
// memory sections.
//
// FULL_LIBRARY
//
// If defined then
// - argc, argv are setup by the debug_getargs.
// - the exit symbol is defined and executes on return from main.
// - the exit symbol calls destructors, atexit functions and then debug_exit.
//
// If not defined then
// - argc and argv are zero.
// - the exit symbol is defined, executes on return from main and loops
//
#ifndef APP_ENTRY_POINT
#define APP_ENTRY_POINT main
#endif
#ifndef ARGSSPACE
#define ARGSSPACE 128
#endif
.syntax unified
.global _start
.extern APP_ENTRY_POINT
.global exit
.weak exit
#ifdef INITIALIZE_USER_SECTIONS
.extern InitializeUserMemorySections
#endif
.section .init, "ax"
.code 16
.balign 2
.thumb_func
_start:
/* Set up main stack if size > 0 */
ldr r1, =__stack_end__
ldr r0, =__stack_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
mov sp, r1
#ifdef INITIALIZE_STACK
movs r2, #0xCC
ldr r0, =__stack_start__
bl memory_set
#endif
1:
/* Set up process stack if size > 0 */
ldr r1, =__stack_process_end__
ldr r0, =__stack_process_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
msr psp, r1
movs r2, #2
msr control, r2
#ifdef INITIALIZE_STACK
movs r2, #0xCC
bl memory_set
#endif
1:
/* Copy initialized memory sections into RAM (if necessary). */
ldr r0, =__data_load_start__
ldr r1, =__data_start__
ldr r2, =__data_end__
bl memory_copy
ldr r0, =__text_load_start__
ldr r1, =__text_start__
ldr r2, =__text_end__
bl memory_copy
ldr r0, =__fast_load_start__
ldr r1, =__fast_start__
ldr r2, =__fast_end__
bl memory_copy
ldr r0, =__ctors_load_start__
ldr r1, =__ctors_start__
ldr r2, =__ctors_end__
bl memory_copy
ldr r0, =__dtors_load_start__
ldr r1, =__dtors_start__
ldr r2, =__dtors_end__
bl memory_copy
ldr r0, =__rodata_load_start__
ldr r1, =__rodata_start__
ldr r2, =__rodata_end__
bl memory_copy
ldr r0, =__tdata_load_start__
ldr r1, =__tdata_start__
ldr r2, =__tdata_end__
bl memory_copy
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__data2_load_start__
ldr r1, =__data2_start__
ldr r2, =__data2_end__
bl memory_copy
ldr r0, =__text2_load_start__
ldr r1, =__text2_start__
ldr r2, =__text2_end__
bl memory_copy
ldr r0, =__rodata2_load_start__
ldr r1, =__rodata2_start__
ldr r2, =__rodata2_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__data_tcm_load_start__
ldr r1, =__data_tcm_start__
ldr r2, =__data_tcm_end__
bl memory_copy
ldr r0, =__text_tcm_load_start__
ldr r1, =__text_tcm_start__
ldr r2, =__text_tcm_end__
bl memory_copy
ldr r0, =__rodata_tcm_load_start__
ldr r1, =__rodata_tcm_start__
ldr r2, =__rodata_tcm_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Zero the bss. */
ldr r0, =__bss_start__
ldr r1, =__bss_end__
movs r2, #0
bl memory_set
ldr r0, =__tbss_start__
ldr r1, =__tbss_end__
movs r2, #0
bl memory_set
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__bss2_start__
ldr r1, =__bss2_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__bss_tcm_start__
ldr r1, =__bss_tcm_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Initialize the heap */
ldr r0, = __heap_start__
ldr r1, = __heap_end__
subs r1, r1, r0
cmp r1, #8
blt 1f
movs r2, #0
str r2, [r0]
adds r0, r0, #4
str r1, [r0]
1:
#ifdef INITIALIZE_USER_SECTIONS
ldr r2, =InitializeUserMemorySections
blx r2
#endif
/* Call constructors */
ldr r0, =__ctors_start__
ldr r1, =__ctors_end__
ctor_loop:
cmp r0, r1
beq ctor_end
ldr r2, [r0]
adds r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b ctor_loop
ctor_end:
/* Setup initial call frame */
movs r0, #0
mov lr, r0
mov r12, sp
.type start, function
start:
/* Jump to application entry point */
#ifdef FULL_LIBRARY
movs r0, #ARGSSPACE
ldr r1, =args
ldr r2, =debug_getargs
blx r2
ldr r1, =args
#else
movs r0, #0
movs r1, #0
#endif
ldr r2, =APP_ENTRY_POINT
blx r2
.thumb_func
exit:
#ifdef FULL_LIBRARY
mov r5, r0 // save the exit parameter/return result
/* Call destructors */
ldr r0, =__dtors_start__
ldr r1, =__dtors_end__
dtor_loop:
cmp r0, r1
beq dtor_end
ldr r2, [r0]
add r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b dtor_loop
dtor_end:
/* Call atexit functions */
ldr r2, =_execute_at_exit_fns
blx r2
/* Call debug_exit with return result/exit parameter */
mov r0, r5
ldr r2, =debug_exit
blx r2
#endif
/* Returned from application entry point, loop forever. */
exit_loop:
b exit_loop
.thumb_func
memory_copy:
cmp r0, r1
beq 2f
subs r2, r2, r1
beq 2f
1:
ldrb r3, [r0]
adds r0, r0, #1
strb r3, [r1]
adds r1, r1, #1
subs r2, r2, #1
bne 1b
2:
bx lr
.thumb_func
memory_set:
cmp r0, r1
beq 1f
strb r2, [r0]
adds r0, r0, #1
b memory_set
1:
bx lr
// default C/C++ library helpers
.macro HELPER helper_name
.section .text.\helper_name, "ax", %progbits
.balign 2
.global \helper_name
.weak \helper_name
\helper_name:
.thumb_func
.endm
.macro JUMPTO name
#if defined(__thumb__) && !defined(__thumb2__)
mov r12, r0
ldr r0, =\name
push {r0}
mov r0, r12
pop {pc}
#else
b \name
#endif
.endm
HELPER __aeabi_read_tp
ldr r0, =__tbss_start__-8
bx lr
HELPER abort
b .
HELPER __assert
b .
HELPER __aeabi_assert
b .
HELPER __sync_synchronize
bx lr
HELPER __getchar
JUMPTO debug_getchar
HELPER __putchar
JUMPTO debug_putchar
HELPER __open
JUMPTO debug_fopen
HELPER __close
JUMPTO debug_fclose
HELPER __write
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fwrite
HELPER __read
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fread
HELPER __seek
push {r4, lr}
mov r4, r0
bl debug_fseek
cmp r0, #0
bne 1f
mov r0, r4
bl debug_ftell
pop {r4, pc}
1:
ldr r0, =-1
pop {r4, pc}
// char __user_locale_name_buffer[];
.section .bss.__user_locale_name_buffer, "aw", %nobits
.global __user_locale_name_buffer
.weak __user_locale_name_buffer
__user_locale_name_buffer:
.word 0x0
#ifdef FULL_LIBRARY
.bss
args:
.space ARGSSPACE
#endif
/* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
.section .stack, "wa", %nobits
.section .stack_process, "wa", %nobits
.section .heap, "wa", %nobits

View File

@ -36,7 +36,8 @@
*/
/**************************************************************************/
#include "msc_app.h"
#include "bsp/board.h"
#include "tusb.h"
#if CFG_TUD_MSC

View File

@ -36,18 +36,22 @@
*/
/**************************************************************************/
#include "msc_device_app.h"
#include "bsp/board.h"
#include "tusb.h"
#if CFG_TUD_MSC && defined (MSCD_APP_RAMDISK)
#if CFG_TUD_MSC
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
#define README_CONTENTS \
"This is tinyusb's MassStorage Class demo.\r\n\r\n\
If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
enum
{
DISK_BLOCK_NUM = 16, // 8KB is the smallest size that windows allow to mount
DISK_BLOCK_SIZE = 512
};
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN
uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
{
//------------- Boot Sector -------------//
@ -101,7 +105,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{
uint8_t* addr = msc_device_ramdisk[lba] + offset;
memcpy(addr, buffer, bufsize);
@ -109,8 +113,10 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buf
return bufsize;
}
//--------------------------------------------------------------------+
// HELPER
//--------------------------------------------------------------------+
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
{
*block_count = DISK_BLOCK_NUM;
*block_size = DISK_BLOCK_SIZE;
}
#endif

View File

@ -48,7 +48,11 @@
//--------------------------------------------------------------------
// COMMON CONFIGURATION
//--------------------------------------------------------------------
#define CFG_TUSB_MCU OPT_MCU_NRF5X
// defined by compiler flags for flexibility
#ifndef CFG_TUSB_MCU
#error CFG_TUSB_MCU should be defined using compiler flags
#endif
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#define CFG_TUSB_DEBUG 2
@ -113,12 +117,6 @@
// Buffer size of Device Mass storage
#define CFG_TUD_MSC_BUFSIZE 512
// Number of Blocks
#define CFG_TUD_MSC_BLOCK_NUM BOARD_MSC_FLASH_SIZE/CFG_TUD_MSC_BLOCK_SZ
// Block size
#define CFG_TUD_MSC_BLOCK_SZ 512
// Vendor name included in Inquiry response, max 8 bytes
#define CFG_TUD_MSC_VENDOR "tinyusb"

View File

@ -1,292 +0,0 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="device_composite" target="8" version="2">
<project Name="Nordic nRF5x">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="ROM;0x00000000;0x00100000;RAM;0x20000000;0x00040000"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056;CFG_TUSB_MCU=OPT_MCU_NRF5X"
c_user_include_directories="../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include"
debug_register_definition_file="ses_nrf5x/nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="ses_nrf5x/nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="ses_nrf5x/flash_placement.xml"
macros="DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;rootDir=../../../..;nrfxDir=../../../../hw/mcu/nordic/nrfx"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/ses_nrf5x/nRF_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<folder Name="pca10056">
<file file_name="../../../../hw/bsp/pca10056/board_pca10056.c" />
<file file_name="../../../../hw/bsp/pca10056/board_pca10056.h" />
</folder>
<file file_name="../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../hw/bsp/board.h" />
</folder>
<folder Name="mcu">
<folder Name="nordic">
<folder Name="nrfx">
<folder Name="drivers">
<folder Name="include">
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_power_clock.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_power.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/include/nrfx_qspi.h" />
</folder>
<folder Name="src">
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c" />
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_qspi.c" />
</folder>
</folder>
<folder Name="hal">
<file file_name="../../../../hw/mcu/nordic/nrfx/hal/nrf_power.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/hal/nrf_qspi.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/hal/nrf_usbd.h" />
</folder>
<folder Name="mdk">
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf51_to_nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_bitfields.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_peripherals.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52_to_nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf52840.s" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf_common.s" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.c" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.h" />
</folder>
</folder>
<file file_name="../../../../hw/mcu/nordic/nrfx_config.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx_glue.h" />
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder Name="ses_nrf5x">
<file file_name="ses_nrf5x/flash_placement.xml" />
<file file_name="ses_nrf5x/nrf52840_Registers.xml" />
<file file_name="ses_nrf5x/nRF52840_xxAA_MemoryMap.xml" />
<file file_name="ses_nrf5x/nRF_Target.js" />
<file file_name="ses_nrf5x/thumb_crt0.s" />
</folder>
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../src"
recurse="Yes" />
</project>
<project Name="Microchip SAMD51">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD51J19"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD51_FAMILY;__SAMD51J19A__;ARM_MATH_CM4;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;BOARD_METRO_M4_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD51"
c_user_include_directories="../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk"
debug_register_definition_file="ses_samd51/ATSAMD51J19A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="$(ProjectDir)/ses_samd51/ATSAMD51J19A_MemoryMap.xml"
linker_section_placement_file="ses_samd51/flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../..;asf4Dir=../../../../hw/mcu/microchip/samd/asf4/samd51"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/ses_samd51/SAMD51_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../hw/bsp/board.h" />
<folder Name="metro_m4_express">
<file file_name="../../../../hw/bsp/metro_m4_express/board_metro_m4_express.c" />
<file file_name="../../../../hw/bsp/metro_m4_express/board_metro_m4_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd51">
<folder Name="gcc">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/core/hpl_init.c" />
</folder>
<folder Name="osc32kctrl">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" />
</folder>
<folder Name="oscctrl">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" />
</folder>
<folder Name="mclk">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder Name="ses_samd51">
<file file_name="ses_samd51/ATSAMD51J19A_MemoryMap.xml" />
<file file_name="ses_samd51/ATSAMD51J19A_Registers.xml" />
<file file_name="ses_samd51/ATSAMD51J19A_Vectors.s" />
<file file_name="ses_samd51/flash_placement.xml" />
<file file_name="ses_samd51/SAMD51_Startup.s" />
<file file_name="ses_samd51/SAMD51_Target.js" />
<file file_name="ses_samd51/thumb_crt0.s" />
</folder>
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../src"
recurse="Yes" />
</project>
<project Name="Microchip SAMD21">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v6M"
arm_core_type="Cortex-M0+"
arm_endian="Little"
arm_fpu_type="None"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="ATSAMD21G18A"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD21G18A__;__SAMD21_FAMILY;__SAM_D21_SUBFAMILY;ARM_MATH_CM0PLUS;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;CONF_XOSC32K_CONFIG=1;CONF_OSC32K_ENABLE=1;CONF_OSC32K_EN32K=1;CONF_XOSC32K_STARTUP=CONF_XOSC32K_STARTUP_TIME_2000092MCS;CONF_DFLL_ONDEMAND=0;CONF_DFLL_OVERWRITE_CALIBRATION=0;BOARD_METRO_M0_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD21"
c_user_include_directories="../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk;$(asf4Dir)/hpl/pm"
debug_register_definition_file="ses_samd21/ATSAMD21G18A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
link_use_linker_script_file="No"
linker_memory_map_file="$(ProjectDir)/ses_samd21/ATSAMD21G18A_MemoryMap.xml"
linker_section_placement_file="ses_samd21/flash_placement.xml"
linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000"
macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../..;asf4Dir=../../../../hw/mcu/microchip/samd/asf4/samd21"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/ses_samd21/SAMD21_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../src"
recurse="Yes" />
<folder Name="hw">
<folder Name="bsp">
<file file_name="../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../hw/bsp/board.h" />
<folder Name="metro_m0_express">
<file file_name="../../../../hw/bsp/metro_m0_express/board_metro_m0_express.c" />
<file file_name="../../../../hw/bsp/metro_m0_express/board_metro_m0_express.h" />
</folder>
</folder>
<folder Name="mcu">
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
<folder Name="samd21">
<folder Name="gcc">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/core/hpl_init.c" />
</folder>
<folder Name="gclk">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" />
</folder>
<folder Name="pm">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" />
</folder>
<folder Name="sysctrl">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" />
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
<configuration Name="Debug" build_treat_warnings_as_errors="Yes" />
<folder
Name="src"
exclude=""
filter="*.c;*.h"
path="../src"
recurse="Yes" />
<folder Name="ses_samd21">
<file file_name="ses_samd21/ATSAMD21G18A_MemoryMap.xml" />
<file file_name="ses_samd21/ATSAMD21G18A_Registers.xml" />
<file file_name="ses_samd21/ATSAMD21G18A_Vectors.s" />
<file file_name="ses_samd21/flash_placement.xml" />
<file file_name="ses_samd21/SAMD21_Startup.s" />
<file file_name="ses_samd21/SAMD21_Target.js" />
<file file_name="ses_samd21/thumb_crt0.s" />
</folder>
</project>
</solution>

View File

@ -1,64 +0,0 @@
/**************************************************************************/
/*!
@file msc_app.h
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
/** \ingroup group_demo
* \defgroup Mass Storage Device App
* @{ */
#ifndef _TUSB_MSCD_DEVICE_APP_H_
#define _TUSB_MSCD_DEVICE_APP_H_
#include "bsp/board.h"
#include "tusb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define README_CONTENTS \
"This is tinyusb's MassStorage Class demo.\r\n\r\n\
If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_MSCD_DEVICE_APP_H_ */
/** @} */

View File

@ -1,124 +0,0 @@
/**************************************************************************/
/*!
@file msc_flash_qspi.c
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2018, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#include "msc_app.h"
#if CFG_TUD_MSC && defined (BOARD_MSC_FLASH_QSPI)
void flash_read (void *dst, uint32_t src, int len);
void flash_write (uint32_t dst, const void *src, int len);
void flash_flush (void);
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
//------------- IMPLEMENTATION -------------//
// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
uint32_t addr = lba * CFG_TUD_MSC_BLOCK_SZ + offset;
flash_read(buffer, addr, bufsize);
return bufsize;
}
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{
uint32_t addr = lba * CFG_TUD_MSC_BLOCK_SZ + offset;
flash_write(addr, buffer, bufsize);
return bufsize;
}
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
// used to flush any pending cache.
void tud_msc_write10_complete_cb (uint8_t lun)
{
(void) lun;
// flush pending cache when write10 is complete
flash_flush();
}
//--------------------------------------------------------------------+
// Flash caching
//--------------------------------------------------------------------+
#define FLASH_PAGE_SIZE 4096
#define NO_CACHE 0xffffffff
static uint32_t _fl_addr = NO_CACHE;
static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4)));
void flash_flush (void)
{
if ( _fl_addr == NO_CACHE ) return;
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, _fl_addr),);
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_write(_fl_buf, FLASH_PAGE_SIZE, _fl_addr),);
_fl_addr = NO_CACHE;
}
void flash_write (uint32_t dst, const void *src, int len)
{
uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1);
if ( newAddr != _fl_addr )
{
flash_flush();
_fl_addr = newAddr;
flash_read(_fl_buf, newAddr, FLASH_PAGE_SIZE);
}
memcpy(_fl_buf + (dst & (FLASH_PAGE_SIZE - 1)), src, len);
}
void flash_read (void *dst, uint32_t src, int len)
{
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_read(dst, len, src),);
}
#endif

View File

@ -1,164 +0,0 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="nrf5x_freertos" target="8" version="2">
<project Name="nrf5x_freertos">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="ROM;0x00000000;0x00100000;RAM;0x20000000;0x00040000"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_PCA10056;CFG_TUSB_MCU=OPT_MCU_NRF5X"
c_user_include_directories="../src;$(tusbDir)/hw/cmsis/Include;$(tusbDir)/hw;$(tusbDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(freertosDir)/Source/include;$(freertosDir)/Source/portable/GCC/ARM_CM4F"
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
linker_memory_map_file="$(ProjectDir)/nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="$(ProjectDir)/flash_placement.xml"
macros="DeviceHeaderFile=$(PackagesDir)/nRF/CMSIS/Device/Include/nrf.h;DeviceLibraryIdentifier=M4lf;DeviceSystemFile=$(PackagesDir)/nRF/CMSIS/Device/Source/system_nrf52840.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/ses_nrf52840_Vectors.s;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;tusbDir=../../../..;nrfxDir=../../../../hw/mcu/nordic/nrfx;freertosDir=../../../../lib/FreeRTOS"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/nRF_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder Name="Script Files">
<file file_name="nRF_Target.js">
<configuration Name="Common" file_type="Reset Script" />
</file>
</folder>
<folder Name="System Files">
<file file_name="thumb_crt0.s" />
</folder>
<folder
Name="tinyusb"
exclude=""
filter="*.c;*.h"
path="../../../../src"
recurse="Yes" />
<folder Name="src">
<file file_name="../src/main.c" />
<file file_name="../src/tusb_config.h" />
<file file_name="../src/tusb_descriptors.c" />
<file file_name="../src/tusb_descriptors.h" />
<file file_name="../src/msc_flash_qspi.c" />
<file file_name="../src/msc_app.c" />
<file file_name="../src/msc_app.h" />
<folder Name="segger_rtt">
<file file_name="../src/segger_rtt/SEGGER_RTT.c" />
<file file_name="../src/segger_rtt/SEGGER_RTT_Conf.h" />
<file file_name="../src/segger_rtt/SEGGER_RTT.h" />
<file file_name="../src/segger_rtt/SEGGER_RTT_SES.c" />
</folder>
</folder>
<folder Name="hw">
<folder Name="bsp">
<folder Name="pca10056">
<file file_name="../../../../hw/bsp/pca10056/board_pca10056.c" />
<file file_name="../../../../hw/bsp/pca10056/board_pca10056.h" />
</folder>
<file file_name="../../../../hw/bsp/ansi_escape.h" />
<file file_name="../../../../hw/bsp/board.h" />
</folder>
<folder Name="mcu">
<folder Name="nordic">
<folder Name="nrfx">
<folder Name="drivers">
<folder Name="include" />
<folder Name="src">
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c" />
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_qspi.c" />
</folder>
</folder>
<folder Name="hal" />
<folder Name="mdk">
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf51_to_nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_bitfields.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52840_peripherals.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/nrf52_to_nrf52840.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf52840.s" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/ses_startup_nrf_common.s" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.c" />
<file file_name="../../../../hw/mcu/nordic/nrfx/mdk/system_nrf52840.h" />
</folder>
<folder Name="soc">
<file file_name="../../../../hw/mcu/nordic/nrfx/soc/nrfx_irqs.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx/soc/nrfx_irqs_nrf52840.h" />
</folder>
</folder>
<file file_name="../../../../hw/mcu/nordic/nrfx_config.h" />
<file file_name="../../../../hw/mcu/nordic/nrfx_glue.h" />
</folder>
</folder>
</folder>
<configuration
Name="Debug"
build_treat_warnings_as_errors="Yes"
debug_threads_script="$(freertosDir)/FreeRTOS_ThreadScripts_ES/threads_CM4F.js" />
<folder Name="lib">
<folder Name="FreeRTOS">
<folder Name="Source">
<folder Name="include">
<file file_name="../../../../lib/FreeRTOS/Source/include/croutine.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/deprecated_definitions.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/event_groups.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/FreeRTOS.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/list.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/message_buffer.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/mpu_prototypes.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/mpu_wrappers.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/portable.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/projdefs.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/queue.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/semphr.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/stack_macros.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/StackMacros.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/stream_buffer.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/task.h" />
<file file_name="../../../../lib/FreeRTOS/Source/include/timers.h" />
</folder>
<folder Name="portable">
<folder Name="Common" />
<folder Name="GCC">
<folder Name="ARM_CM4F">
<file file_name="../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" />
<file file_name="../../../../lib/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" />
</folder>
</folder>
<folder Name="MemMang">
<file file_name="../../../../lib/FreeRTOS/Source/portable/MemMang/heap_4.c" />
</folder>
</folder>
<file file_name="../../../../lib/FreeRTOS/Source/list.c" />
<file file_name="../../../../lib/FreeRTOS/Source/queue.c" />
<file file_name="../../../../lib/FreeRTOS/Source/tasks.c" />
<file file_name="../../../../lib/FreeRTOS/Source/timers.c" />
</folder>
<file file_name="../../../../lib/FreeRTOS/FreeRTOSConfig.h" />
<file file_name="../../../../lib/FreeRTOS/freertos_hook.c" />
</folder>
</folder>
</project>
<configuration
Name="Debug"
c_preprocessor_definitions="DEBUG"
gcc_debugging_level="Level 3"
gcc_optimization_level="None" />
<configuration
Name="Release"
c_preprocessor_definitions="NDEBUG"
gcc_debugging_level="None"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="Level 1" />
</solution>

View File

@ -1,64 +0,0 @@
/**************************************************************************/
/*!
@file msc_app.h
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
/** \ingroup group_demo
* \defgroup Mass Storage Device App
* @{ */
#ifndef _TUSB_MSCD_DEVICE_APP_H_
#define _TUSB_MSCD_DEVICE_APP_H_
#include "bsp/board.h"
#include "tusb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define README_CONTENTS \
"This is tinyusb's MassStorage Class demo.\r\n\r\n\
If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_MSCD_DEVICE_APP_H_ */
/** @} */

View File

@ -1,124 +0,0 @@
/**************************************************************************/
/*!
@file msc_flash_qspi.c
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2018, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#include "msc_app.h"
#if CFG_TUD_MSC && defined (BOARD_MSC_FLASH_QSPI)
void flash_read (void *dst, uint32_t src, int len);
void flash_write (uint32_t dst, const void *src, int len);
void flash_flush (void);
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
//------------- IMPLEMENTATION -------------//
// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
uint32_t addr = lba * CFG_TUD_MSC_BLOCK_SZ + offset;
flash_read(buffer, addr, bufsize);
return bufsize;
}
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{
uint32_t addr = lba * CFG_TUD_MSC_BLOCK_SZ + offset;
flash_write(addr, buffer, bufsize);
return bufsize;
}
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
// used to flush any pending cache.
void tud_msc_write10_complete_cb (uint8_t lun)
{
(void) lun;
// flush pending cache when write10 is complete
flash_flush();
}
//--------------------------------------------------------------------+
// Flash caching
//--------------------------------------------------------------------+
#define FLASH_PAGE_SIZE 4096
#define NO_CACHE 0xffffffff
static uint32_t _fl_addr = NO_CACHE;
static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4)));
void flash_flush (void)
{
if ( _fl_addr == NO_CACHE ) return;
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, _fl_addr),);
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_write(_fl_buf, FLASH_PAGE_SIZE, _fl_addr),);
_fl_addr = NO_CACHE;
}
void flash_write (uint32_t dst, const void *src, int len)
{
uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1);
if ( newAddr != _fl_addr )
{
flash_flush();
_fl_addr = newAddr;
flash_read(_fl_buf, newAddr, FLASH_PAGE_SIZE);
}
memcpy(_fl_buf + (dst & (FLASH_PAGE_SIZE - 1)), src, len);
}
void flash_read (void *dst, uint32_t src, int len)
{
TU_ASSERT(NRFX_SUCCESS == nrfx_qspi_read(dst, len, src),);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,240 +0,0 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2014 - 2018 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* - Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* - Neither the name of SEGGER Microcontroller GmbH *
* nor the names of its contributors may be used to endorse or *
* promote products derived from this software without specific *
* prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. *
* IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT.h
Purpose : Implementation of SEGGER real-time transfer which allows
real-time communication on targets which support debugger
memory accesses while the CPU is running.
Revision: $Rev: 12804 $
----------------------------------------------------------------------
*/
#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H
#include "SEGGER_RTT_Conf.h"
#include <stdlib.h>
#include <stdarg.h>
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
/*********************************************************************
*
* Types
*
**********************************************************************
*/
//
// Description for a circular buffer (also called "ring buffer")
// which is used as up-buffer (T->H)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
unsigned WrOff; // Position of next item to be written by either target.
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
unsigned Flags; // Contains configuration flags
} SEGGER_RTT_BUFFER_UP;
//
// Description for a circular buffer (also called "ring buffer")
// which is used as down-buffer (H->T)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
unsigned RdOff; // Position of next item to be read by target (down-buffer).
unsigned Flags; // Contains configuration flags
} SEGGER_RTT_BUFFER_DOWN;
//
// RTT control block which describes the number of buffers available
// as well as the configuration for each buffer
//
//
typedef struct {
char acID[16]; // Initialized to "SEGGER RTT"
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
} SEGGER_RTT_CB;
/*********************************************************************
*
* Global data
*
**********************************************************************
*/
extern SEGGER_RTT_CB _SEGGER_RTT;
/*********************************************************************
*
* RTT API functions
*
**********************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_GetKey (void);
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
int SEGGER_RTT_HasKey (void);
unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex);
void SEGGER_RTT_Init (void);
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_WaitKey (void);
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
//
// Function macro for performance optimization
//
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
int SEGGER_RTT_SetTerminal (char TerminalId);
int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
#ifdef __cplusplus
}
#endif
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
//
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3U)
//
// Control sequences, based on ANSI.
// Can be used to control color, and clear the screen
//
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left
#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"
#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"
#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
#define RTT_CTRL_BG_RED "\x1B[24;41m"
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"
#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"
#endif
/*************************** End of file ****************************/

View File

@ -1,312 +0,0 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2014 - 2018 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* - Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* - Neither the name of SEGGER Microcontroller GmbH *
* nor the names of its contributors may be used to endorse or *
* promote products derived from this software without specific *
* prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. *
* IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT_Conf.h
Purpose : Implementation of SEGGER real-time transfer (RTT) which
allows real-time communication on targets which support
debugger memory accesses while the CPU is running.
Revision: $Rev: 12804 $
*/
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
#ifdef __IAR_SYSTEMS_ICC__
#include <intrinsics.h>
#endif
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2)
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2)
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
/*********************************************************************
*
* RTT memcpy configuration
*
* memcpy() is good for large amounts of data,
* but the overhead is big for small amounts, which are usually stored via RTT.
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
*
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
* This is may be required with memory access restrictions,
* such as on Cortex-A devices with MMU.
*/
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
//
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
//
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
//#endif
//
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
// Otherwise we would probably end up with a mixed string in the buffer.
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
//
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
// (Higher priority = lower priority number)
// Default value for embOS: 128u
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
//
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
/*********************************************************************
*
* RTT lock configuration for SEGGER Embedded Studio,
* Rowley CrossStudio and GCC
*/
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__) || (defined __clang__)
#if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__))
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, primask \n\t" \
"movs r1, $1 \n\t" \
"msr primask, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
: \
: "r" (LockState) \
: \
); \
}
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, basepri \n\t" \
"mov r1, %1 \n\t" \
"msr basepri, r1 \n\t" \
: "=r" (LockState) \
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
: \
: "r" (LockState) \
: \
); \
}
#elif defined(__ARM_ARCH_7A__)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" (LockState) \
: "r0", "r1" \
); \
}
#else
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR EWARM
*/
#ifdef __ICCARM__
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
}
#elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_BASEPRI(); \
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RX
*/
#ifdef __ICCRX__
#define SEGGER_RTT_LOCK() { \
unsigned long LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RL78
*/
#ifdef __ICCRL78__
#define SEGGER_RTT_LOCK() { \
__istate_t LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for KEIL ARM
*/
#ifdef __CC_ARM
#if (defined __TARGET_ARCH_6S_M)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char PRIMASK __asm( "primask"); \
LockState = PRIMASK; \
PRIMASK = 1u; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
__schedule_barrier(); \
}
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char BASEPRI __asm( "basepri"); \
LockState = BASEPRI; \
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
__schedule_barrier(); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for TI ARM
*/
#ifdef __TI_ARM__
#if defined (__TI_ARM_V6M0__)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
}
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() _set_interrupt_priority(LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration fallback
*/
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
#endif
#endif
/*************************** End of file ****************************/

View File

@ -1,79 +0,0 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2014 - 2018 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* - Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* - Neither the name of SEGGER Microcontroller GmbH *
* nor the names of its contributors may be used to endorse or *
* promote products derived from this software without specific *
* prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. *
* IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
-------- END-OF-HEADER ---------------------------------------------
File : SEGGER_RTT_Syscalls_SES.c
Purpose : Reimplementation of printf, puts and
implementation of __putchar and __getchar using RTT in SES.
To use RTT for printf output, include this file in your
application.
----------------------------------------------------------------------
*/
#include "SEGGER_RTT.h"
#include "__libc.h"
#include <stdarg.h>
#include <stdio.h>
int printf(const char *fmt,...) {
char buffer[128];
va_list args;
va_start (args, fmt);
int n = vsnprintf(buffer, sizeof(buffer), fmt, args);
SEGGER_RTT_Write(0, buffer, n);
va_end(args);
return n;
}
int puts(const char *s) {
return SEGGER_RTT_WriteString(0, s);
}
int __putchar(int x, __printf_tag_ptr ctx) {
(void)ctx;
SEGGER_RTT_Write(0, (char *)&x, 1);
return x;
}
int __getchar() {
return SEGGER_RTT_WaitKey();
}
/****** End Of File *************************************************/

View File

@ -1,37 +0,0 @@
#!/usr/bin/perl
use File::Spec;
use File::Find;
use File::Path;
use File::Glob;
use File::stat;
#use Time::Piece;
#use Time::Seconds;
$" = "\n"; # change list separator
@PROJECT_LIST = (<device/device*/*.uvproj>, <host/host*/*.uvproj>);
print "@PROJECT_LIST";
foreach (@PROJECT_LIST)
{
my $project_file = $_;
my $backup_file = $project_file . ".bck";
rename $project_file, $backup_file or die "cannot rename $project_file to $backup_file";
open (fin, $backup_file) or die "Can't open $backup_file to read\n";
open (fout, ">$project_file") or die "Can't open $project_file to write\n";
my $target;
while (<fin>)
{
s/(<TargetName>.+) /\1_/; # replace space by underscore in target name if found
$target = $1 and print $target . "\n" if /<TargetName>(.+)</;
my $keil_build = ".\\KeilBuild\\$target\\";
print "replace $2 by $keil_build\n--> $_\n" if s/(<OutputDirectory>)(.+)</\1$keil_build</ || s/(<ListingPath>)(.+)</\1$keil_build</;
printf fout;
}
}

View File

@ -205,16 +205,6 @@ bool mscd_control_request_complete(uint8_t rhport, tusb_control_request_t const
return true;
}
// For backwards compatibility we support static block counts.
#if defined(CFG_TUD_MSC_BLOCK_NUM) && defined(CFG_TUD_MSC_BLOCK_SZ)
ATTR_WEAK bool tud_lun_capacity_cb(uint8_t lun, uint32_t* last_valid_sector, uint16_t* block_size) {
(void) lun;
*last_valid_sector = CFG_TUD_MSC_BLOCK_NUM-1;
*block_size = CFG_TUD_MSC_BLOCK_SZ;
return true;
}
#endif
// return length of response (copied to buffer), -1 if it is not an built-in commands
int32_t proc_builtin_scsi(msc_cbw_t const * p_cbw, uint8_t* buffer, uint32_t bufsize)
{
@ -226,10 +216,14 @@ int32_t proc_builtin_scsi(msc_cbw_t const * p_cbw, uint8_t* buffer, uint32_t buf
{
scsi_read_capacity10_resp_t read_capa10;
uint32_t last_valid_sector;
uint16_t block_size;
tud_lun_capacity_cb(p_cbw->lun, &last_valid_sector, &block_size);
read_capa10.last_lba = ENDIAN_BE(last_valid_sector); // read capacity
uint32_t block_count;
uint32_t block_size;
uint16_t block_size_u16;
tud_msc_capacity_cb(p_cbw->lun, &block_count, &block_size_u16);
block_size = (uint32_t) block_size_u16;
read_capa10.last_lba = ENDIAN_BE(block_count-1);
read_capa10.block_size = ENDIAN_BE(block_size);
ret = sizeof(read_capa10);
@ -243,14 +237,15 @@ int32_t proc_builtin_scsi(msc_cbw_t const * p_cbw, uint8_t* buffer, uint32_t buf
{
.list_length = 8,
.block_num = 0,
.descriptor_type = 2, // formatted media
.descriptor_type = 2, // formatted media
.block_size_u16 = 0
};
uint32_t last_valid_sector;
uint32_t block_count;
uint16_t block_size;
tud_lun_capacity_cb(p_cbw->lun, &last_valid_sector, &block_size);
read_fmt_capa.block_num = ENDIAN_BE(last_valid_sector+1);
tud_msc_capacity_cb(p_cbw->lun, &block_count, &block_size);
read_fmt_capa.block_num = ENDIAN_BE(block_count);
read_fmt_capa.block_size_u16 = ENDIAN_BE16(block_size);
ret = sizeof(read_fmt_capa);

View File

@ -132,6 +132,9 @@ int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buf
*/
int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize);
// Invoked to determine the disk size
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size);
/**
* Callback invoked when received an SCSI command not in built-in list below.
* \param[in] lun Logical unit number
@ -152,16 +155,19 @@ int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize);
/*------------- Optional callbacks : Could be used by application to free up resources -------------*/
// Invoked when Read10 command is complete
ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
// Invoke when Write10 command is complete
ATTR_WEAK void tud_msc_write10_complete_cb(uint8_t lun);
// Invoked when command in tud_msc_scsi_cb is complete
ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[16]);
// Hook to make a mass storage device read-only.
// Hook to make a mass storage device read-only. TODO remove
ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
// Override for dynamic LUN sizes.
ATTR_WEAK bool tud_lun_capacity_cb(uint8_t lun, uint32_t* last_valid_sector, uint16_t* block_size);
/** @} */
/** @} */