├── README.md
├── README_en.md
├── demo
    ├── .gitignore
    ├── .skip.MCU_CXD56
    ├── .skip.MCU_MSP430x5xx
    ├── .skip.MCU_VALENTYUSB_EPTRI
    ├── CMakeLists.txt
    ├── Makefile
    ├── sdkconfig
    ├── sdkconfig.defaults
    ├── ses
    │   ├── cdc_msc_hid_freertos.emProject
    │   ├── lpc175x_6x
    │   │   ├── FreeRTOSConfig.h
    │   │   ├── LPC1700_Startup.s
    │   │   ├── LPC1700_Target.js
    │   │   ├── LPC1769_MemoryMap.xml
    │   │   ├── LPC176x5x_Registers.xml
    │   │   ├── LPC176x5x_Vectors.s
    │   │   ├── flash_placement.xml
    │   │   ├── lpc175x_6x.emProject
    │   │   └── thumb_crt0.s
    │   ├── nrf5x
    │   │   ├── flash_placement.xml
    │   │   ├── nRF52840_xxAA_MemoryMap.xml
    │   │   ├── nRF_Target.js
    │   │   ├── nrf52840_Registers.xml
    │   │   ├── nrf5x.emProject
    │   │   └── thumb_crt0.s
    │   ├── samd21
    │   │   ├── ATSAMD21G18A_MemoryMap.xml
    │   │   ├── ATSAMD21G18A_Registers.xml
    │   │   ├── ATSAMD21G18A_Vectors.s
    │   │   ├── SAMD21_Startup.s
    │   │   ├── SAMD21_Target.js
    │   │   ├── flash_placement.xml
    │   │   ├── samd21.emProject
    │   │   └── thumb_crt0.s
    │   └── samd51
    │   │   ├── ATSAMD51J19A_MemoryMap.xml
    │   │   ├── ATSAMD51J19A_Registers.xml
    │   │   ├── ATSAMD51J19A_Vectors.s
    │   │   ├── SAMD51_Startup.s
    │   │   ├── SAMD51_Target.js
    │   │   ├── flash_placement.xml
    │   │   ├── samd51.emProject
    │   │   └── thumb_crt0.s
    ├── src
    │   ├── CMakeLists.txt
    │   ├── FreeRTOSConfig.h
    │   ├── freertos_hook.c
    │   ├── main.c
    │   ├── msc_disk.c
    │   ├── tusb_config.h
    │   └── usb_descriptors.c
    └── tags
├── doc
    ├── CH340SER.EXE
    ├── esp32-s2-wroom_esp32-s2-wroom-i_datasheet_en.pdf
    ├── esp32-s2-wrover_esp32-s2-wrover-i_datasheet_en.pdf
    ├── esp32-s2_datasheet_en.pdf
    ├── esp32-s2_technical_reference_manual_cn.pdf
    └── nanoESP32-S2.jpg
├── firmware
    ├── flash_dump.sh
    ├── flash_erase.sh
    ├── flash_image_cdc_msc.bin
    └── flash_write.sh
└── schematic
    └── nanoESP32S2-v1.2.pdf
/README.md:
--------------------------------------------------------------------------------
 1 | nanoESP32-S2
 2 | -----------
 3 | [中文](./README.md) [English](./README_en.md)
 4 | 
 5 | * [nanoESP32-S2介绍](#nanoESP32-S2介绍) 
 6 | * [模组规格](#模组规格)
 7 | * [ESP32-S2 vs ESP32](#ESP32-S2-vs-ESP32)
 8 | * [demo说明](#demo说明)
 9 | * [产品链接](#产品链接)
10 | * [参考](#参考)
11 | 
12 | 
13 | # nanoESP32-S2介绍
14 | nanoESP32-S2 是MuseLab基于乐鑫ESP32-S2系列模组推出的开发板,板载USB转串口,TYPE-C、全彩LED,引脚兼容官方开发板,同时引出调试烧录串口和ESP32-S2本身的USB接口,更方便日常的开发测试。
15 | 
16 | 
17 | # 模组规格 
18 | nanoESP32-S2支持乐鑫官方推出的四种模组,模组之间的差异说明如下
19 | 
20 | 模组|PCB天线 | IPEX天线|PSRAM|
21 | ----|----|----|-----|
22 | ESP32-S2-WROOM | Yes | No |No|
23 | ESP32-S2-WROOM-I | No  | Yes|No|
24 | ESP32-S2-WROVER | Yes   | No|Yes|
25 | ESP32-S2-WROVER-I | No  | Yes | Yes|
26 | 
27 | # ESP32-S2 vs ESP32
28 | ESP32-S2芯片和ESP32相比,差异说明如下
29 | 模组|ESP32 | ESP32-S2|
30 | ----|----|----|
31 | Microcontroller | Xtensa dual-core 32-bit LX6 | Xtensa single-core 32-bit LX7 |
32 | Clock Frequency | 160/240 MHz | 160/240 MHz|
33 | Co-processor | ULP   |  ULP (RISC-V)|
34 | SRAM | 520 KB| 320 KB |
35 | ROM | 448 KB| 128 KB |
36 | RTC Memory | 16 KB| 16 KB |
37 | External SPIRAM | Up to 16MB| Up to 128MB |
38 | External Flash | No| Up to 1G |
39 | Wi-Fi (802.11 b/g/n) | HT20 | HT20 |
40 | ESP-MESH | Yes| Yes |
41 | Bluetooth | BT 4.2 BR/EDR & BLE |  No |
42 | Ethernet | 10/100 Mbps| No |
43 | CAN | 2.0| No |
44 | Time of Flight |  No | Yes |
45 | GPIO (total) | 34| 43 |
46 | Touch Sensors | 10 | 14 |
47 | SPI | 4| 4 (OSPI) |
48 | I2C | 2| 2 |
49 | I2S | 2| 1 |
50 | UART | 3 | 2 |
51 | ADC | 18 (12-bit)| 20 (12-bit) |
52 | DAC | 2 (8-bit)| 2 (8-bit) |
53 | PWM (soft) | 16 | 8 |
54 | SDMMC | Yes| No |
55 | RMT (remote control) | Yes| Yes |
56 | USB OTG | No| Yes |
57 | LCD Interface | No| Yes |
58 | Camera Interface | No| Yes |
59 | Temperature sensor | Yes| Yes |
60 | Hall sensor | Yes| No |
61 | Security | Secure boot Flash encryption 1024-bit OTP| Secure boot Flash encryption 4096-bit OTP |
62 | Crypto | AES, SHA-2, RSA, ECC, RNG| AES-128/192/256, SHA-2, RSA, RNG, HMAC, Digital Signature|
63 | Low Power Consumption | 10uA deep sleep| Automatic RF power management 5uA in idle mode 24uA at 1% duty cycle |
64 | 
65 | 
66 | # demo说明
67 | 预置的出厂测试固件源码位于demo目录下,上电之后预期RGB LED应该会开始闪烁,两个TYPE-C接口一个为CH340 USB,用于调试下载,另一个为ESP32-S2的USB,若插入ESP32-S2 USB,预期会出现一个名为"ESP32-S2 MSC"的的U盘以及一个CDC串口设备。
68 | 固件编译参考:
69 | ```
70 | $git clone https://github.com/espressif/esp-idf.git
71 | $cd /path/to/esp-idf && ./install.sh && . ./export.sh && cd -
72 | $git clone https://github.com/hathach/tinyusb.git
73 | $cd tinyusb/examples/device/cdc_msc_freertos/
74 | $idf.py set-target esp32s2
75 | $idf.py -p /dev/ttyUSB0 flash monitor
76 | ```
77 | # 产品链接
78 | [nanoESP32-S2 Board](https://item.taobao.com/item.htm?id=620291976381)
79 | 
80 | # 参考
81 | ### esp-idf
82 | https://github.com/espressif/esp-idf
83 | ### esp32-s2 get-started
84 | https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/
85 | ### esp32-s2
86 | https://www.espressif.com/zh-hans/products/socs/esp32-s2
87 | 
--------------------------------------------------------------------------------
/README_en.md:
--------------------------------------------------------------------------------
 1 | nanoESP32-S2
 2 | -----------
 3 | * [nanoESP32-S2 Introduce](#nanoESP32-S2-Introduce) 
 4 | * [Module Specifications](#Module-Specifications)
 5 | * [ESP32-S2 vs ESP32](#ESP32-S2-vs-ESP32)
 6 | * [Demo](#Demo)
 7 | * [Product Link](#Product-Link)
 8 | * [Reference](#Reference)
 9 | 
10 | 
11 | # nanoESP32-S2 Introduce
12 | nanoESP32-S2 is ESP32-S2 dev board made by MuseLab, base on ESP32-S2 Modules manufactured by Expressif, with on-board usb-to-serial, TYPE-C, RGB LED, the pin is compatible with Expressif's official development board ESP32-S2-Saola series, and the dual-USB include usb-to-serial and the USB ESP32-S2 itself, more convenient for development and test.  
13 | 
14 | 
15 | # Module Specifications 
16 | nanoESP32-S2 support four Modules made by Espressif, the differences between the modules are explained as follows
17 | Module|PCB Antenna | IPEX Antenna|PSRAM|
18 | ----|----|----|-----|
19 | ESP32-S2-WROOM | Yes | No |No|
20 | ESP32-S2-WROOM-I | No  | Yes|No|
21 | ESP32-S2-WROVER | Yes   | No|Yes (2MB)|
22 | ESP32-S2-WROVER-I | No  | Yes | Yes (2MB)|
23 | 
24 | # ESP32-S2 vs ESP32
25 | Compared with ESP32-S2 and ESP32, the difference is explained as follows
26 | Module|ESP32 | ESP32-S2|
27 | ----|----|----|
28 | Microcontroller | Xtensa dual-core 32-bit LX6 | Xtensa single-core 32-bit LX7 |
29 | Clock Frequency | 160/240 MHz | 160/240 MHz|
30 | Co-processor | ULP   |  ULP (RISC-V)|
31 | SRAM | 520 KB| 320 KB |
32 | ROM | 448 KB| 128 KB |
33 | RTC Memory | 16 KB| 16 KB |
34 | External SPIRAM | Up to 16MB| Up to 128MB |
35 | External Flash | No| Up to 1G |
36 | Wi-Fi (802.11 b/g/n) | HT20 | HT20 |
37 | ESP-MESH | Yes| Yes |
38 | Bluetooth | BT 4.2 BR/EDR & BLE |  No |
39 | Ethernet | 10/100 Mbps| No |
40 | CAN | 2.0| No |
41 | Time of Flight |  No | Yes |
42 | GPIO (total) | 34| 43 |
43 | Touch Sensors | 10 | 14 |
44 | SPI | 4| 4 (OSPI) |
45 | I2C | 2| 2 |
46 | I2S | 2| 1 |
47 | UART | 3 | 2 |
48 | ADC | 18 (12-bit)| 20 (12-bit) |
49 | DAC | 2 (8-bit)| 2 (8-bit) |
50 | PWM (soft) | 16 | 8 |
51 | SDMMC | Yes| No |
52 | RMT (remote control) | Yes| Yes |
53 | USB OTG | No| Yes |
54 | LCD Interface | No| Yes |
55 | Camera Interface | No| Yes |
56 | Temperature sensor | Yes| Yes |
57 | Hall sensor | Yes| No |
58 | Security | Secure boot Flash encryption 1024-bit OTP| Secure boot Flash encryption 4096-bit OTP |
59 | Crypto | AES, SHA-2, RSA, ECC, RNG| AES-128/192/256, SHA-2, RSA, RNG, HMAC, Digital Signature|
60 | Low Power Consumption | 10uA deep sleep| Automatic RF power management 5uA in idle mode 24uA at 1% duty cycle |
61 | 
62 | 
63 | # Demo
64 | The preset factory test firmware source code is located in the demo directory. and the firmware is in firmware directory, expected that the RGB LED should start to flash after power-on. One of the two TYPE-C interfaces is CH340 USB for debugging and downloading, and the other is the USB of ESP32-S2, when plug ESP32-S2 USB, a U disk named "ESP32-S2 MSC" and a CDC serial device are expected, how to compile the source code show here (for reference, may be outdated, cause the esp-idf is always updating)
65 | ```
66 | $git clone https://github.com/espressif/esp-idf.git
67 | $cd /path/to/esp-idf && ./install.sh && . ./export.sh && cd -
68 | $git clone https://github.com/hathach/tinyusb.git
69 | $cd tinyusb/examples/device/cdc_msc_freertos/
70 | $idf.py set-target esp32s2
71 | $idf.py -p /dev/ttyUSB0 flash monitor
72 | ```
73 | # Product Link
74 | [Aliexpress](https://www.aliexpress.com/item/1005001403045642.html?gps-id=pcStoreNewArrivals&scm=1007.23409.123629.0&scm_id=1007.23409.123629.0&scm-url=1007.23409.123629.0&pvid=6c59d14d-bb7b-4d0f-b0b8-fc5f6ae78288&spm=a2g0o.store_home.smartNewArrivals_1285899620.1005001403045642)  
75 | [Tindie](https://www.tindie.com/products/johnnywu/nanoesp32-s2-development-board)
76 | 
77 | # Reference
78 | ### esp-idf
79 | https://github.com/espressif/esp-idf
80 | ### esp32-s2 get-started
81 | https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/
82 | ### esp32-s2
83 | https://www.espressif.com/zh-hans/products/socs/esp32-s2
84 | 
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | 
--------------------------------------------------------------------------------
/demo/.skip.MCU_CXD56:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxx/nanoESP32-S2/edc358effe77ef6ed4f0d7c1e39f62a2416b70e3/demo/.skip.MCU_CXD56
--------------------------------------------------------------------------------
/demo/.skip.MCU_MSP430x5xx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxx/nanoESP32-S2/edc358effe77ef6ed4f0d7c1e39f62a2416b70e3/demo/.skip.MCU_MSP430x5xx
--------------------------------------------------------------------------------
/demo/.skip.MCU_VALENTYUSB_EPTRI:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxx/nanoESP32-S2/edc358effe77ef6ed4f0d7c1e39f62a2416b70e3/demo/.skip.MCU_VALENTYUSB_EPTRI
--------------------------------------------------------------------------------
/demo/CMakeLists.txt:
--------------------------------------------------------------------------------
 1 | # The following five lines of boilerplate have to be in your project's
 2 | # CMakeLists in this exact order for cmake to work correctly
 3 | cmake_minimum_required(VERSION 3.5)
 4 | 
 5 | # TOP is absolute path to root directory of TinyUSB git repo
 6 | set(TOP "../../..")
 7 | get_filename_component(TOP "${TOP}" REALPATH)
 8 | 
 9 | # Add example src and bsp directories
10 | set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2_saola_1")
11 | 
12 | include($ENV{IDF_PATH}/tools/cmake/project.cmake)
13 | set(SUPPORTED_TARGETS esp32s2)
14 | 
15 | project(cdc_msc_freertos)
16 | 
--------------------------------------------------------------------------------
/demo/Makefile:
--------------------------------------------------------------------------------
 1 | include ../../../tools/top.mk
 2 | include ../../make.mk
 3 | 
 4 | FREERTOS_SRC = lib/FreeRTOS/FreeRTOS/Source
 5 | 
 6 | INC += \
 7 | 	src \
 8 | 	$(TOP)/hw \
 9 | 	$(TOP)/$(FREERTOS_SRC)/include \
10 | 	$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)
11 | 	
12 | # Example source
13 | EXAMPLE_SOURCE += $(wildcard src/*.c)
14 | SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
15 | 
16 | # FreeRTOS source, all files in port folder
17 | SRC_C += \
18 | 	$(FREERTOS_SRC)/list.c \
19 | 	$(FREERTOS_SRC)/queue.c \
20 | 	$(FREERTOS_SRC)/tasks.c \
21 | 	$(FREERTOS_SRC)/timers.c \
22 | 	$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
23 | 
24 | # FreeRTOS (lto + Os) linker issue
25 | LDFLAGS += -Wl,--undefined=vTaskSwitchContext
26 | 
27 | include ../../rules.mk
28 | 
--------------------------------------------------------------------------------
/demo/sdkconfig.defaults:
--------------------------------------------------------------------------------
1 | CONFIG_IDF_CMAKE=y
2 | CONFIG_IDF_TARGET="esp32s2"
3 | CONFIG_IDF_TARGET_ESP32S2=y
4 | CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
5 | CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
6 | 
--------------------------------------------------------------------------------
/demo/ses/cdc_msc_hid_freertos.emProject:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   
4 |   
5 |   
6 |   
7 | 
8 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
  1 | #ifndef __FREERTOS_CONFIG__H
  2 | #define __FREERTOS_CONFIG__H
  3 | 
  4 | //--------------------------------------------------------------------+
  5 | // See http://www.freertos.org/a00110.html.
  6 | //--------------------------------------------------------------------+
  7 | #include "chip.h"
  8 | 
  9 | #define configCPU_CLOCK_HZ                   SystemCoreClock
 10 | 
 11 | #if 0
 12 | #if CFG_TUSB_MCU == OPT_MCU_LPC43XX
 13 |   // TODO remove
 14 |   #include "lpc43xx_cgu.h"
 15 |   #define configCPU_CLOCK_HZ                   CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)
 16 | #endif
 17 | #endif
 18 | 
 19 | #define configUSE_PREEMPTION                    1
 20 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
 21 | #define configTICK_RATE_HZ                      ( 1000 )
 22 | #define configMAX_PRIORITIES                    (8)
 23 | #define configMINIMAL_STACK_SIZE                (128 )
 24 | #define configTOTAL_HEAP_SIZE                   ( ( size_t ) ( 16*1024 ) )
 25 | #define configMAX_TASK_NAME_LEN                 32
 26 | #define configUSE_16_BIT_TICKS      		        0
 27 | #define configIDLE_SHOULD_YIELD                 1
 28 | #define configUSE_MUTEXES                       1
 29 | #define configUSE_RECURSIVE_MUTEXES             0
 30 | #define configUSE_COUNTING_SEMAPHORES           1
 31 | #define configQUEUE_REGISTRY_SIZE               10 // used to name queue/semaphore with debugger
 32 | #define configUSE_QUEUE_SETS                    0
 33 | #define configUSE_TIME_SLICING                  0
 34 | #define configUSE_NEWLIB_REENTRANT              0
 35 | #define configENABLE_BACKWARD_COMPATIBILITY     1
 36 | 
 37 | #define configSUPPORT_STATIC_ALLOCATION         1
 38 | #define configSUPPORT_DYNAMIC_ALLOCATION        1
 39 | 
 40 | /* Hook function related definitions. */
 41 | #define configUSE_IDLE_HOOK                    0
 42 | #define configUSE_TICK_HOOK                    0
 43 | #define configUSE_MALLOC_FAILED_HOOK           1
 44 | #define configCHECK_FOR_STACK_OVERFLOW         2
 45 | 
 46 | /* Run time and task stats gathering related definitions. */
 47 | #define configGENERATE_RUN_TIME_STATS          0
 48 | #define configUSE_TRACE_FACILITY               1 // legacy trace
 49 | #define configUSE_STATS_FORMATTING_FUNCTIONS   0
 50 | 
 51 | /* Co-routine definitions. */
 52 | #define configUSE_CO_ROUTINES                  0
 53 | #define configMAX_CO_ROUTINE_PRIORITIES        2
 54 | 
 55 | /* Software timer related definitions. */
 56 | #define configUSE_TIMERS                       1
 57 | #define configTIMER_TASK_PRIORITY              ( configMAX_PRIORITIES - 3 )
 58 | #define configTIMER_QUEUE_LENGTH               10
 59 | #define configTIMER_TASK_STACK_DEPTH	         configMINIMAL_STACK_SIZE
 60 | 
 61 | /* Optional functions - most linkers will remove unused functions anyway. */
 62 | #define INCLUDE_vTaskPrioritySet               0
 63 | #define INCLUDE_uxTaskPriorityGet              0
 64 | #define INCLUDE_vTaskDelete                    0
 65 | #define INCLUDE_vTaskSuspend                   1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
 66 | #define INCLUDE_xResumeFromISR                 0
 67 | #define INCLUDE_vTaskDelayUntil                1
 68 | #define INCLUDE_vTaskDelay                     1
 69 | #define INCLUDE_xTaskGetSchedulerState         0
 70 | #define INCLUDE_xTaskGetCurrentTaskHandle      0
 71 | #define INCLUDE_uxTaskGetStackHighWaterMark    0
 72 | #define INCLUDE_xTaskGetIdleTaskHandle         0
 73 | #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
 74 | #define INCLUDE_pcTaskGetTaskName              0
 75 | #define INCLUDE_eTaskGetState                  0
 76 | #define INCLUDE_xEventGroupSetBitFromISR       0
 77 | #define INCLUDE_xTimerPendFunctionCall         0
 78 | 
 79 | /* Define to trap errors during development. */
 80 | 
 81 | // Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
 82 | #if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
 83 | 
 84 | static inline void configASSERT_breakpoint(void)
 85 | {
 86 |   // Cortex M CoreDebug->DHCSR
 87 |   volatile uint32_t* ARM_CM_DHCSR =  ((volatile uint32_t*) 0xE000EDF0UL);
 88 | 
 89 |   // Only halt mcu if debugger is attached
 90 |   if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n");
 91 | }
 92 | 
 93 | #else
 94 | #define configASSERT_breakpoint()
 95 | #endif
 96 | 
 97 | 
 98 | #define configASSERT( x )                      if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); configASSERT_breakpoint(); }
 99 | 
100 | /* FreeRTOS hooks to NVIC vectors */
101 | #define xPortPendSVHandler    PendSV_Handler
102 | #define xPortSysTickHandler   SysTick_Handler
103 | #define vPortSVCHandler       SVC_Handler
104 | 
105 | //--------------------------------------------------------------------+
106 | // Interrupt nesting behaviour configuration.
107 | //--------------------------------------------------------------------+
108 | /* Cortex-M specific definitions. __NVIC_PRIO_BITS is defined in mcu_variant.h */
109 | #ifdef __NVIC_PRIO_BITS
110 | 	#define configPRIO_BITS       __NVIC_PRIO_BITS
111 | #else
112 |   #error "This port requires __NVIC_PRIO_BITS to be defined"
113 | #endif
114 | 
115 | 
116 | /* The lowest interrupt priority that can be used in a call to a "set priority"
117 | function. */
118 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY			  0x1f
119 | 
120 | /* The highest interrupt priority that can be used by any interrupt service
121 | routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
122 | INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
123 | PRIORITY THAN THIS! (higher priorities are lower numeric values. */
124 | #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY	2
125 | 
126 | /* Interrupt priorities used by the kernel port layer itself.  These are generic
127 | to all Cortex-M ports, and do not rely on any particular library functions. */
128 | #define configKERNEL_INTERRUPT_PRIORITY 		          ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
129 | 
130 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
131 | See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
132 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 	        ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
133 | 
134 | #endif /* __FREERTOS_CONFIG__H */
135 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/LPC1700_Startup.s:
--------------------------------------------------------------------------------
  1 | /*****************************************************************************
  2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
  3 |  *            Solutions for real time microcontroller applications           *
  4 |  *****************************************************************************
  5 |  *                                                                           *
  6 |  *               (c) 2015 SEGGER Microcontroller GmbH & Co. KG               *
  7 |  *                                                                           *
  8 |  *           Internet: www.segger.com   Support: support@segger.com          *
  9 |  *                                                                           *
 10 |  *****************************************************************************/
 11 | 
 12 | /*****************************************************************************
 13 |  *                         Preprocessor Definitions                          *
 14 |  *                         ------------------------                          *
 15 |  * NO_STACK_INIT                                                             *
 16 |  *                                                                           *
 17 |  *   If defined, the stack pointer will not be initialised.                  *
 18 |  *                                                                           *
 19 |  * NO_SYSTEM_INIT                                                            *
 20 |  *                                                                           *
 21 |  *   If defined, the SystemInit() function will not be called. By default    *
 22 |  *   SystemInit() is called after reset to enable the clocks and memories to *
 23 |  *   be initialised prior to any C startup initialisation.                   *
 24 |  *                                                                           *
 25 |  * NO_VTOR_CONFIG                                                            *
 26 |  *                                                                           *
 27 |  *   If defined, the vector table offset register will not be configured.    *
 28 |  *                                                                           *
 29 |  * MEMORY_INIT                                                               *
 30 |  *                                                                           *
 31 |  *   If defined, the MemoryInit() function will be called. By default        *
 32 |  *   MemoryInit() is called after SystemInit() to enable an external memory  *
 33 |  *   controller.                                                             *
 34 |  *                                                                           *
 35 |  * STACK_INIT_VAL                                                            *
 36 |  *                                                                           *
 37 |  *   If defined, specifies the initial stack pointer value. If undefined,    *
 38 |  *   the stack pointer will be initialised to point to the end of the        *
 39 |  *   RAM segment.                                                            *
 40 |  *                                                                           *
 41 |  * VECTORS_IN_RAM                                                            *
 42 |  *                                                                           *
 43 |  *   If defined, the exception vectors will be copied from Flash to RAM.     *
 44 |  *                                                                           *
 45 |  *****************************************************************************/
 46 | 
 47 |   .syntax unified
 48 | 
 49 |   .global Reset_Handler
 50 |   .extern _vectors
 51 | 
 52 |   .section .init, "ax"
 53 |   .thumb_func
 54 | 
 55 |   .equ VTOR_REG, 0xE000ED08
 56 | 
 57 | #ifndef STACK_INIT_VAL
 58 | #define STACK_INIT_VAL __RAM_segment_end__
 59 | #endif
 60 | 
 61 | Reset_Handler:
 62 | #ifndef NO_STACK_INIT
 63 |   /* Initialise main stack */
 64 |   ldr r0, =STACK_INIT_VAL
 65 |   bic r0, #0x7
 66 |   mov sp, r0
 67 | #endif
 68 | #ifndef NO_SYSTEM_INIT
 69 |   /* Initialise system */
 70 |   ldr r0, =SystemInit
 71 |   blx r0
 72 | #endif
 73 | 
 74 | #ifdef MEMORY_INIT
 75 |   ldr r0, =MemoryInit
 76 |   blx r0
 77 | #endif
 78 | 
 79 | #ifdef VECTORS_IN_RAM
 80 |   /* Copy exception vectors into RAM */
 81 |   ldr r0, =__vectors_start__
 82 |   ldr r1, =__vectors_end__
 83 |   ldr r2, =__vectors_ram_start__
 84 | 1:
 85 |   cmp r0, r1
 86 |   beq 2f
 87 |   ldr r3, [r0]
 88 |   str r3, [r2]
 89 |   adds r0, r0, #4
 90 |   adds r2, r2, #4
 91 |   b 1b
 92 | 2:
 93 | #endif
 94 | 
 95 | #ifndef NO_VTOR_CONFIG
 96 |   /* Configure vector table offset register */
 97 |   ldr r0, =VTOR_REG
 98 | #ifdef VECTORS_IN_RAM
 99 |   ldr r1, =_vectors_ram
100 | #else
101 |   ldr r1, =_vectors
102 | #endif
103 |   str r1, [r0]
104 | #endif
105 | 
106 |   /* Jump to program start */
107 |   b _start
108 | 
109 | 
110 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/LPC1700_Target.js:
--------------------------------------------------------------------------------
 1 | /*****************************************************************************
 2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
 3 |  *            Solutions for real time microcontroller applications           *
 4 |  *****************************************************************************
 5 |  *                                                                           *
 6 |  *               (c) 2015 SEGGER Microcontroller GmbH & Co. KG               *
 7 |  *                                                                           *
 8 |  *           Internet: www.segger.com   Support: support@segger.com          *
 9 |  *                                                                           *
10 |  *****************************************************************************/
11 | 
12 | function Reset() {
13 |   TargetInterface.resetAndStop();
14 | }
15 | 
16 | function EnableTrace(traceInterfaceType) {
17 |   // TODO: Enable trace
18 | }
19 | 
20 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/LPC1769_MemoryMap.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   
4 |   
5 |   
6 | 
7 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/LPC176x5x_Vectors.s:
--------------------------------------------------------------------------------
  1 | /*****************************************************************************
  2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
  3 |  *            Solutions for real time microcontroller applications           *
  4 |  *****************************************************************************
  5 |  *                                                                           *
  6 |  *               (c) 2015 SEGGER Microcontroller GmbH & Co. KG               *
  7 |  *                                                                           *
  8 |  *           Internet: www.segger.com   Support: support@segger.com          *
  9 |  *                                                                           *
 10 |  *****************************************************************************/
 11 | 
 12 | /*****************************************************************************
 13 |  *                         Preprocessor Definitions                          *
 14 |  *                         ------------------------                          *
 15 |  * VECTORS_IN_RAM                                                            *
 16 |  *                                                                           *
 17 |  *   If defined, an area of RAM will large enough to store the vector table  *
 18 |  *   will be reserved.                                                       *
 19 |  *                                                                           *
 20 |  *****************************************************************************/
 21 | 
 22 |   .syntax unified
 23 |   .code 16
 24 | 
 25 |   .section .init, "ax"
 26 |   .align 0
 27 | 
 28 | /*****************************************************************************
 29 |  * Default Exception Handlers                                                *
 30 |  *****************************************************************************/
 31 | 
 32 |   .thumb_func
 33 |   .weak NMI_Handler
 34 | NMI_Handler:
 35 |   b .
 36 | 
 37 |   .thumb_func
 38 |   .weak HardFault_Handler
 39 | HardFault_Handler:
 40 |   b .
 41 | 
 42 |   .thumb_func
 43 |   .weak SVC_Handler
 44 | SVC_Handler:
 45 |   b .
 46 | 
 47 |   .thumb_func
 48 |   .weak PendSV_Handler
 49 | PendSV_Handler:
 50 |   b .
 51 | 
 52 |   .thumb_func
 53 |   .weak SysTick_Handler
 54 | SysTick_Handler:
 55 |   b .
 56 | 
 57 |   .thumb_func
 58 | Dummy_Handler:
 59 |   b .
 60 | 
 61 | #if defined(__OPTIMIZATION_SMALL)
 62 | 
 63 |   .weak WDT_IRQHandler
 64 |   .thumb_set WDT_IRQHandler,Dummy_Handler
 65 | 
 66 |   .weak TIMER0_IRQHandler
 67 |   .thumb_set TIMER0_IRQHandler,Dummy_Handler
 68 | 
 69 |   .weak TIMER1_IRQHandler
 70 |   .thumb_set TIMER1_IRQHandler,Dummy_Handler
 71 | 
 72 |   .weak TIMER2_IRQHandler
 73 |   .thumb_set TIMER2_IRQHandler,Dummy_Handler
 74 | 
 75 |   .weak TIMER3_IRQHandler
 76 |   .thumb_set TIMER3_IRQHandler,Dummy_Handler
 77 | 
 78 |   .weak UART0_IRQHandler
 79 |   .thumb_set UART0_IRQHandler,Dummy_Handler
 80 | 
 81 |   .weak UART1_IRQHandler
 82 |   .thumb_set UART1_IRQHandler,Dummy_Handler
 83 | 
 84 |   .weak UART2_IRQHandler
 85 |   .thumb_set UART2_IRQHandler,Dummy_Handler
 86 | 
 87 |   .weak UART3_IRQHandler
 88 |   .thumb_set UART3_IRQHandler,Dummy_Handler
 89 | 
 90 |   .weak PWM1_IRQHandler
 91 |   .thumb_set PWM1_IRQHandler,Dummy_Handler
 92 | 
 93 |   .weak I2C0_IRQHandler
 94 |   .thumb_set I2C0_IRQHandler,Dummy_Handler
 95 | 
 96 |   .weak I2C1_IRQHandler
 97 |   .thumb_set I2C1_IRQHandler,Dummy_Handler
 98 | 
 99 |   .weak I2C2_IRQHandler
100 |   .thumb_set I2C2_IRQHandler,Dummy_Handler
101 | 
102 |   .weak SPI_IRQHandler
103 |   .thumb_set SPI_IRQHandler,Dummy_Handler
104 | 
105 |   .weak SSP0_IRQHandler
106 |   .thumb_set SSP0_IRQHandler,Dummy_Handler
107 | 
108 |   .weak SSP1_IRQHandler
109 |   .thumb_set SSP1_IRQHandler,Dummy_Handler
110 | 
111 |   .weak PLL0_IRQHandler
112 |   .thumb_set PLL0_IRQHandler,Dummy_Handler
113 | 
114 |   .weak RTC_IRQHandler
115 |   .thumb_set RTC_IRQHandler,Dummy_Handler
116 | 
117 |   .weak EINT0_IRQHandler
118 |   .thumb_set EINT0_IRQHandler,Dummy_Handler
119 | 
120 |   .weak EINT1_IRQHandler
121 |   .thumb_set EINT1_IRQHandler,Dummy_Handler
122 | 
123 |   .weak EINT2_IRQHandler
124 |   .thumb_set EINT2_IRQHandler,Dummy_Handler
125 | 
126 |   .weak EINT3_IRQHandler
127 |   .thumb_set EINT3_IRQHandler,Dummy_Handler
128 | 
129 |   .weak ADC_IRQHandler
130 |   .thumb_set ADC_IRQHandler,Dummy_Handler
131 | 
132 |   .weak BOD_IRQHandler
133 |   .thumb_set BOD_IRQHandler,Dummy_Handler
134 | 
135 |   .weak USB_IRQHandler
136 |   .thumb_set USB_IRQHandler,Dummy_Handler
137 | 
138 |   .weak CAN_IRQHandler
139 |   .thumb_set CAN_IRQHandler,Dummy_Handler
140 | 
141 |   .weak DMA_IRQHandler
142 |   .thumb_set DMA_IRQHandler,Dummy_Handler
143 | 
144 |   .weak I2S_IRQHandler
145 |   .thumb_set I2S_IRQHandler,Dummy_Handler
146 | 
147 |   .weak ENET_IRQHandler
148 |   .thumb_set ENET_IRQHandler,Dummy_Handler
149 | 
150 |   .weak RIT_IRQHandler
151 |   .thumb_set RIT_IRQHandler,Dummy_Handler
152 | 
153 |   .weak MCPWM_IRQHandler
154 |   .thumb_set MCPWM_IRQHandler,Dummy_Handler
155 | 
156 |   .weak QEI_IRQHandler
157 |   .thumb_set QEI_IRQHandler,Dummy_Handler
158 | 
159 |   .weak PLL1_IRQHandler
160 |   .thumb_set PLL1_IRQHandler,Dummy_Handler
161 | 
162 |   .weak USBActivity_IRQHandler
163 |   .thumb_set USBActivity_IRQHandler,Dummy_Handler
164 | 
165 |   .weak CANActivity_IRQHandler
166 |   .thumb_set CANActivity_IRQHandler,Dummy_Handler
167 | 
168 | #else
169 | 
170 |   .thumb_func
171 |   .weak WDT_IRQHandler
172 | WDT_IRQHandler:
173 |   b .
174 | 
175 |   .thumb_func
176 |   .weak TIMER0_IRQHandler
177 | TIMER0_IRQHandler:
178 |   b .
179 | 
180 |   .thumb_func
181 |   .weak TIMER1_IRQHandler
182 | TIMER1_IRQHandler:
183 |   b .
184 | 
185 |   .thumb_func
186 |   .weak TIMER2_IRQHandler
187 | TIMER2_IRQHandler:
188 |   b .
189 | 
190 |   .thumb_func
191 |   .weak TIMER3_IRQHandler
192 | TIMER3_IRQHandler:
193 |   b .
194 | 
195 |   .thumb_func
196 |   .weak UART0_IRQHandler
197 | UART0_IRQHandler:
198 |   b .
199 | 
200 |   .thumb_func
201 |   .weak UART1_IRQHandler
202 | UART1_IRQHandler:
203 |   b .
204 | 
205 |   .thumb_func
206 |   .weak UART2_IRQHandler
207 | UART2_IRQHandler:
208 |   b .
209 | 
210 |   .thumb_func
211 |   .weak UART3_IRQHandler
212 | UART3_IRQHandler:
213 |   b .
214 | 
215 |   .thumb_func
216 |   .weak PWM1_IRQHandler
217 | PWM1_IRQHandler:
218 |   b .
219 | 
220 |   .thumb_func
221 |   .weak I2C0_IRQHandler
222 | I2C0_IRQHandler:
223 |   b .
224 | 
225 |   .thumb_func
226 |   .weak I2C1_IRQHandler
227 | I2C1_IRQHandler:
228 |   b .
229 | 
230 |   .thumb_func
231 |   .weak I2C2_IRQHandler
232 | I2C2_IRQHandler:
233 |   b .
234 | 
235 |   .thumb_func
236 |   .weak SPI_IRQHandler
237 | SPI_IRQHandler:
238 |   b .
239 | 
240 |   .thumb_func
241 |   .weak SSP0_IRQHandler
242 | SSP0_IRQHandler:
243 |   b .
244 | 
245 |   .thumb_func
246 |   .weak SSP1_IRQHandler
247 | SSP1_IRQHandler:
248 |   b .
249 | 
250 |   .thumb_func
251 |   .weak PLL0_IRQHandler
252 | PLL0_IRQHandler:
253 |   b .
254 | 
255 |   .thumb_func
256 |   .weak RTC_IRQHandler
257 | RTC_IRQHandler:
258 |   b .
259 | 
260 |   .thumb_func
261 |   .weak EINT0_IRQHandler
262 | EINT0_IRQHandler:
263 |   b .
264 | 
265 |   .thumb_func
266 |   .weak EINT1_IRQHandler
267 | EINT1_IRQHandler:
268 |   b .
269 | 
270 |   .thumb_func
271 |   .weak EINT2_IRQHandler
272 | EINT2_IRQHandler:
273 |   b .
274 | 
275 |   .thumb_func
276 |   .weak EINT3_IRQHandler
277 | EINT3_IRQHandler:
278 |   b .
279 | 
280 |   .thumb_func
281 |   .weak ADC_IRQHandler
282 | ADC_IRQHandler:
283 |   b .
284 | 
285 |   .thumb_func
286 |   .weak BOD_IRQHandler
287 | BOD_IRQHandler:
288 |   b .
289 | 
290 |   .thumb_func
291 |   .weak USB_IRQHandler
292 | USB_IRQHandler:
293 |   b .
294 | 
295 |   .thumb_func
296 |   .weak CAN_IRQHandler
297 | CAN_IRQHandler:
298 |   b .
299 | 
300 |   .thumb_func
301 |   .weak DMA_IRQHandler
302 | DMA_IRQHandler:
303 |   b .
304 | 
305 |   .thumb_func
306 |   .weak I2S_IRQHandler
307 | I2S_IRQHandler:
308 |   b .
309 | 
310 |   .thumb_func
311 |   .weak ENET_IRQHandler
312 | ENET_IRQHandler:
313 |   b .
314 | 
315 |   .thumb_func
316 |   .weak RIT_IRQHandler
317 | RIT_IRQHandler:
318 |   b .
319 | 
320 |   .thumb_func
321 |   .weak MCPWM_IRQHandler
322 | MCPWM_IRQHandler:
323 |   b .
324 | 
325 |   .thumb_func
326 |   .weak QEI_IRQHandler
327 | QEI_IRQHandler:
328 |   b .
329 | 
330 |   .thumb_func
331 |   .weak PLL1_IRQHandler
332 | PLL1_IRQHandler:
333 |   b .
334 | 
335 |   .thumb_func
336 |   .weak USBActivity_IRQHandler
337 | USBActivity_IRQHandler:
338 |   b .
339 | 
340 |   .thumb_func
341 |   .weak CANActivity_IRQHandler
342 | CANActivity_IRQHandler:
343 |   b .
344 | 
345 | #endif
346 | 
347 | /*****************************************************************************
348 |  * Vector Table                                                              *
349 |  *****************************************************************************/
350 | 
351 |   .section .vectors, "ax"
352 |   .align 0
353 |   .global _vectors
354 |   .extern __stack_end__
355 |   .extern Reset_Handler
356 | 
357 | _vectors:
358 |   .word __stack_end__
359 |   .word Reset_Handler
360 |   .word NMI_Handler
361 |   .word HardFault_Handler
362 |   .word 0 /* Reserved */
363 |   .word 0 /* Reserved */
364 |   .word 0 /* Reserved */
365 |   .word 0 /* Reserved */
366 |   .word 0 /* Reserved */
367 |   .word 0 /* Reserved */
368 |   .word 0 /* Reserved */
369 |   .word SVC_Handler
370 |   .word 0 /* Reserved */
371 |   .word 0 /* Reserved */
372 |   .word PendSV_Handler
373 |   .word SysTick_Handler
374 |   .word WDT_IRQHandler
375 |   .word TIMER0_IRQHandler
376 |   .word TIMER1_IRQHandler
377 |   .word TIMER2_IRQHandler
378 |   .word TIMER3_IRQHandler
379 |   .word UART0_IRQHandler
380 |   .word UART1_IRQHandler
381 |   .word UART2_IRQHandler
382 |   .word UART3_IRQHandler
383 |   .word PWM1_IRQHandler
384 |   .word I2C0_IRQHandler
385 |   .word I2C1_IRQHandler
386 |   .word I2C2_IRQHandler
387 |   .word SPI_IRQHandler
388 |   .word SSP0_IRQHandler
389 |   .word SSP1_IRQHandler
390 |   .word PLL0_IRQHandler
391 |   .word RTC_IRQHandler
392 |   .word EINT0_IRQHandler
393 |   .word EINT1_IRQHandler
394 |   .word EINT2_IRQHandler
395 |   .word EINT3_IRQHandler
396 |   .word ADC_IRQHandler
397 |   .word BOD_IRQHandler
398 |   .word USB_IRQHandler
399 |   .word CAN_IRQHandler
400 |   .word DMA_IRQHandler
401 |   .word I2S_IRQHandler
402 |   .word ENET_IRQHandler
403 |   .word RIT_IRQHandler
404 |   .word MCPWM_IRQHandler
405 |   .word QEI_IRQHandler
406 |   .word PLL1_IRQHandler
407 |   .word USBActivity_IRQHandler
408 |   .word CANActivity_IRQHandler
409 | _vectors_end:
410 | 
411 | #ifdef VECTORS_IN_RAM
412 |   .section .vectors_ram, "ax"
413 |   .align 0
414 |   .global _vectors_ram
415 | 
416 | _vectors_ram:
417 |   .space _vectors_end - _vectors, 0
418 | #endif
419 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/flash_placement.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     
 5 |     
 6 |     
 7 |     
 8 |     
 9 |     
10 |     
11 |     
12 |     
13 |     
14 |     
15 |   
16 |   
17 |     
18 |     
19 |     
20 |     
21 |     
22 |     
23 |     
24 |     
25 |     
26 |     
27 |   
28 |   
29 |     
30 |     
31 |     
32 |   
33 |   
34 |     
35 |     
36 |   
37 | 
38 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/lpc175x_6x.emProject:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 |   
  4 |     
 38 |     
 44 |     
 45 |       
 46 |         
 47 |         
 48 |           
 49 |         
 50 |       
 51 |       
 52 |         
 53 |           
 54 |             
 55 |               
 56 |                 
 57 |                 
 58 |                 
 59 |                 
 60 |                 
 61 |                 
 62 |                 
 63 |               
 64 |             
 65 |           
 66 |         
 67 |       
 68 |     
 69 |     
 70 |     
 76 |     
 77 |       
 78 |       
 79 |       
 80 |       
 81 |       
 82 |       
 83 |       
 84 |     
 85 |     
 91 |     
 92 |       
 93 |         
 94 |           
 95 |             
 96 |             
 97 |             
 98 |             
 99 |             
100 |             
101 |             
102 |             
103 |             
104 |             
105 |             
106 |             
107 |             
108 |             
109 |             
110 |             
111 |             
112 |           
113 |           
114 |             
115 |               
116 |                 
117 |                 
118 |               
119 |             
120 |             
121 |               
122 |             
123 |           
124 |           
125 |           
126 |           
127 |           
128 |         
129 |         
130 |       
131 |     
132 |     
135 |   
136 |   
137 | 
138 | 
--------------------------------------------------------------------------------
/demo/ses/lpc175x_6x/thumb_crt0.s:
--------------------------------------------------------------------------------
  1 | // **********************************************************************
  2 | // *                    SEGGER Microcontroller GmbH                     *
  3 | // *                        The Embedded Experts                        *
  4 | // **********************************************************************
  5 | // *                                                                    *
  6 | // *            (c) 2014 - 2018 SEGGER Microcontroller GmbH             *
  7 | // *            (c) 2001 - 2018 Rowley Associates Limited               *
  8 | // *                                                                    *
  9 | // *           www.segger.com     Support: support@segger.com           *
 10 | // *                                                                    *
 11 | // **********************************************************************
 12 | // *                                                                    *
 13 | // * All rights reserved.                                               *
 14 | // *                                                                    *
 15 | // * Redistribution and use in source and binary forms, with or         *
 16 | // * without modification, are permitted provided that the following    *
 17 | // * conditions are met:                                                *
 18 | // *                                                                    *
 19 | // * - Redistributions of source code must retain the above copyright   *
 20 | // *   notice, this list of conditions and the following disclaimer.    *
 21 | // *                                                                    *
 22 | // * - Neither the name of SEGGER Microcontroller GmbH                  *
 23 | // *   nor the names of its contributors may be used to endorse or      *
 24 | // *   promote products derived from this software without specific     *
 25 | // *   prior written permission.                                        *
 26 | // *                                                                    *
 27 | // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
 28 | // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
 29 | // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
 30 | // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
 31 | // * DISCLAIMED.                                                        *
 32 | // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
 33 | // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
 34 | // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
 35 | // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
 36 | // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
 37 | // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
 38 | // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
 39 | // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
 40 | // * DAMAGE.                                                            *
 41 | // *                                                                    *
 42 | // **********************************************************************
 43 | //
 44 | //
 45 | //                           Preprocessor Definitions
 46 | //                           ------------------------
 47 | // APP_ENTRY_POINT
 48 | //
 49 | //   Defines the application entry point function, if undefined this setting
 50 | //   defaults to "main".
 51 | //
 52 | // INITIALIZE_STACK
 53 | //
 54 | //   If defined, the contents of the stack will be initialized to a the
 55 | //   value 0xCC.
 56 | //
 57 | // INITIALIZE_SECONDARY_SECTIONS
 58 | //
 59 | //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
 60 | //
 61 | // INITIALIZE_TCM_SECTIONS
 62 | //
 63 | //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
 64 | //   will be initialized.
 65 | //
 66 | // INITIALIZE_USER_SECTIONS
 67 | //
 68 | //   If defined, the function InitializeUserMemorySections will be called prior
 69 | //   to entering main in order to allow the user to initialize any user defined
 70 | //   memory sections.
 71 | //
 72 | // FULL_LIBRARY
 73 | //
 74 | //  If defined then 
 75 | //    - argc, argv are setup by the debug_getargs.
 76 | //    - the exit symbol is defined and executes on return from main.
 77 | //    - the exit symbol calls destructors, atexit functions and then debug_exit.
 78 | //  
 79 | //  If not defined then
 80 | //    - argc and argv are zero.
 81 | //    - the exit symbol is defined, executes on return from main and loops
 82 | //
 83 | 
 84 | #ifndef APP_ENTRY_POINT
 85 | #define APP_ENTRY_POINT main
 86 | #endif
 87 | 
 88 | #ifndef ARGSSPACE
 89 | #define ARGSSPACE 128
 90 | #endif
 91 |   .syntax unified
 92 | 
 93 |   .global _start
 94 |   .extern APP_ENTRY_POINT
 95 |   .global exit
 96 |   .weak exit
 97 | 
 98 | #ifdef INITIALIZE_USER_SECTIONS
 99 |   .extern InitializeUserMemorySections
100 | #endif
101 | 
102 |   .section .init, "ax"
103 |   .code 16
104 |   .balign 2
105 |   .thumb_func
106 | 
107 | _start:
108 |   /* Set up main stack if size > 0 */
109 |   ldr r1, =__stack_end__
110 |   ldr r0, =__stack_start__
111 |   subs r2, r1, r0
112 |   beq 1f
113 | #ifdef __ARM_EABI__
114 |   movs r2, #0x7
115 |   bics r1, r2
116 | #endif
117 |   mov sp, r1
118 | #ifdef INITIALIZE_STACK
119 |   movs r2, #0xCC
120 |   ldr r0, =__stack_start__
121 |   bl memory_set
122 | #endif
123 | 1:
124 | 
125 |   /* Set up process stack if size > 0 */
126 |   ldr r1, =__stack_process_end__
127 |   ldr r0, =__stack_process_start__
128 |   subs r2, r1, r0
129 |   beq 1f
130 | #ifdef __ARM_EABI__
131 |   movs r2, #0x7
132 |   bics r1, r2
133 | #endif
134 |   msr psp, r1
135 |   movs r2, #2
136 |   msr control, r2
137 | #ifdef INITIALIZE_STACK
138 |   movs r2, #0xCC
139 |   bl memory_set
140 | #endif
141 | 1:
142 | 
143 |   /* Copy initialized memory sections into RAM (if necessary). */
144 |   ldr r0, =__data_load_start__
145 |   ldr r1, =__data_start__
146 |   ldr r2, =__data_end__
147 |   bl memory_copy
148 |   ldr r0, =__text_load_start__
149 |   ldr r1, =__text_start__
150 |   ldr r2, =__text_end__
151 |   bl memory_copy
152 |   ldr r0, =__fast_load_start__
153 |   ldr r1, =__fast_start__
154 |   ldr r2, =__fast_end__
155 |   bl memory_copy
156 |   ldr r0, =__ctors_load_start__
157 |   ldr r1, =__ctors_start__
158 |   ldr r2, =__ctors_end__
159 |   bl memory_copy
160 |   ldr r0, =__dtors_load_start__
161 |   ldr r1, =__dtors_start__
162 |   ldr r2, =__dtors_end__
163 |   bl memory_copy
164 |   ldr r0, =__rodata_load_start__
165 |   ldr r1, =__rodata_start__
166 |   ldr r2, =__rodata_end__
167 |   bl memory_copy
168 |   ldr r0, =__tdata_load_start__
169 |   ldr r1, =__tdata_start__
170 |   ldr r2, =__tdata_end__
171 |   bl memory_copy
172 | #ifdef INITIALIZE_SECONDARY_SECTIONS
173 |   ldr r0, =__data2_load_start__
174 |   ldr r1, =__data2_start__
175 |   ldr r2, =__data2_end__
176 |   bl memory_copy
177 |   ldr r0, =__text2_load_start__
178 |   ldr r1, =__text2_start__
179 |   ldr r2, =__text2_end__
180 |   bl memory_copy
181 |   ldr r0, =__rodata2_load_start__
182 |   ldr r1, =__rodata2_start__
183 |   ldr r2, =__rodata2_end__
184 |   bl memory_copy
185 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
186 | #ifdef INITIALIZE_TCM_SECTIONS
187 |   ldr r0, =__data_tcm_load_start__
188 |   ldr r1, =__data_tcm_start__
189 |   ldr r2, =__data_tcm_end__
190 |   bl memory_copy
191 |   ldr r0, =__text_tcm_load_start__
192 |   ldr r1, =__text_tcm_start__
193 |   ldr r2, =__text_tcm_end__
194 |   bl memory_copy
195 |   ldr r0, =__rodata_tcm_load_start__
196 |   ldr r1, =__rodata_tcm_start__
197 |   ldr r2, =__rodata_tcm_end__
198 |   bl memory_copy
199 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
200 | 
201 |   /* Zero the bss. */
202 |   ldr r0, =__bss_start__
203 |   ldr r1, =__bss_end__
204 |   movs r2, #0
205 |   bl memory_set
206 |   ldr r0, =__tbss_start__
207 |   ldr r1, =__tbss_end__
208 |   movs r2, #0
209 |   bl memory_set
210 | #ifdef INITIALIZE_SECONDARY_SECTIONS
211 |   ldr r0, =__bss2_start__
212 |   ldr r1, =__bss2_end__
213 |   mov r2, #0
214 |   bl memory_set
215 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
216 | #ifdef INITIALIZE_TCM_SECTIONS
217 |   ldr r0, =__bss_tcm_start__
218 |   ldr r1, =__bss_tcm_end__
219 |   mov r2, #0
220 |   bl memory_set
221 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
222 | 
223 |   /* Initialize the heap */
224 |   ldr r0, = __heap_start__
225 |   ldr r1, = __heap_end__
226 |   subs r1, r1, r0
227 |   cmp r1, #8
228 |   blt 1f
229 |   movs r2, #0
230 |   str r2, [r0]
231 |   adds r0, r0, #4
232 |   str r1, [r0]
233 | 1:
234 | 
235 | #ifdef INITIALIZE_USER_SECTIONS
236 |   ldr r2, =InitializeUserMemorySections
237 |   blx r2
238 | #endif
239 | 
240 |   /* Call constructors */
241 |   ldr r0, =__ctors_start__
242 |   ldr r1, =__ctors_end__
243 | ctor_loop:
244 |   cmp r0, r1
245 |   beq ctor_end
246 |   ldr r2, [r0]
247 |   adds r0, #4
248 |   push {r0-r1}  
249 |   blx r2
250 |   pop {r0-r1}
251 |   b ctor_loop
252 | ctor_end:
253 | 
254 |   /* Setup initial call frame */
255 |   movs r0, #0
256 |   mov lr, r0
257 |   mov r12, sp
258 | 
259 |   .type start, function
260 | start:
261 |   /* Jump to application entry point */
262 | #ifdef FULL_LIBRARY
263 |   movs r0, #ARGSSPACE
264 |   ldr r1, =args
265 |   ldr r2, =debug_getargs  
266 |   blx r2
267 |   ldr r1, =args
268 | #else
269 |   movs r0, #0
270 |   movs r1, #0
271 | #endif
272 |   ldr r2, =APP_ENTRY_POINT
273 |   blx r2
274 | 
275 |   .thumb_func
276 | exit:
277 | #ifdef FULL_LIBRARY  
278 |   mov r5, r0 // save the exit parameter/return result
279 | 
280 |   /* Call destructors */
281 |   ldr r0, =__dtors_start__
282 |   ldr r1, =__dtors_end__
283 | dtor_loop:
284 |   cmp r0, r1
285 |   beq dtor_end
286 |   ldr r2, [r0]
287 |   add r0, #4
288 |   push {r0-r1}
289 |   blx r2
290 |   pop {r0-r1}
291 |   b dtor_loop
292 | dtor_end:
293 | 
294 |   /* Call atexit functions */
295 |   ldr r2, =_execute_at_exit_fns  
296 |   blx r2
297 | 
298 |   /* Call debug_exit with return result/exit parameter */
299 |   mov r0, r5
300 |   ldr r2, =debug_exit  
301 |   blx r2
302 | #endif
303 | 
304 |   /* Returned from application entry point, loop forever. */
305 | exit_loop:
306 |   b exit_loop
307 | 
308 |   .thumb_func
309 | memory_copy:
310 |   cmp r0, r1
311 |   beq 2f
312 |   subs r2, r2, r1
313 |   beq 2f
314 | 1:
315 |   ldrb r3, [r0]
316 |   adds r0, r0, #1
317 |   strb r3, [r1]
318 |   adds r1, r1, #1
319 |   subs r2, r2, #1
320 |   bne 1b
321 | 2:
322 |   bx lr
323 | 
324 |   .thumb_func
325 | memory_set:
326 |   cmp r0, r1
327 |   beq 1f
328 |   strb r2, [r0]
329 |   adds r0, r0, #1
330 |   b memory_set
331 | 1:
332 |   bx lr
333 | 
334 |   // default C/C++ library helpers
335 | 
336 | .macro HELPER helper_name
337 |   .section .text.\helper_name, "ax", %progbits
338 |   .balign 2
339 |   .global \helper_name
340 |   .weak \helper_name  
341 | \helper_name:
342 |   .thumb_func
343 | .endm
344 | 
345 | .macro JUMPTO name
346 | #if defined(__thumb__) && !defined(__thumb2__)
347 |   mov r12, r0
348 |   ldr r0, =\name
349 |   push {r0}
350 |   mov r0, r12
351 |   pop {pc}
352 | #else
353 |   b \name
354 | #endif
355 | .endm
356 | 
357 | HELPER __aeabi_read_tp
358 |   ldr r0, =__tbss_start__-8
359 |   bx lr
360 | HELPER abort
361 |   b .
362 | HELPER __assert
363 |   b .
364 | HELPER __aeabi_assert
365 |   b .
366 | HELPER __sync_synchronize
367 |   bx lr
368 | HELPER __getchar
369 |   JUMPTO debug_getchar
370 | HELPER __putchar
371 |   JUMPTO debug_putchar
372 | HELPER __open
373 |   JUMPTO debug_fopen
374 | HELPER __close
375 |   JUMPTO debug_fclose
376 | HELPER __write   
377 |   mov r3, r0
378 |   mov r0, r1
379 |   movs r1, #1  
380 |   JUMPTO debug_fwrite
381 | HELPER __read  
382 |   mov r3, r0
383 |   mov r0, r1
384 |   movs r1, #1 
385 |   JUMPTO debug_fread
386 | HELPER __seek
387 |   push {r4, lr}
388 |   mov r4, r0
389 |   bl debug_fseek
390 |   cmp r0, #0
391 |   bne 1f
392 |   mov r0, r4
393 |   bl debug_ftell
394 |   pop {r4, pc}
395 | 1:
396 |   ldr r0, =-1
397 |   pop {r4, pc}
398 |   // char __user_locale_name_buffer[];
399 |   .section .bss.__user_locale_name_buffer, "aw", %nobits
400 |   .global __user_locale_name_buffer
401 |   .weak __user_locale_name_buffer
402 |   __user_locale_name_buffer:
403 |   .word 0x0
404 | 
405 | #ifdef FULL_LIBRARY
406 |   .bss
407 | args:
408 |   .space ARGSSPACE
409 | #endif
410 | 
411 |   /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
412 |   .section .stack, "wa", %nobits
413 |   .section .stack_process, "wa", %nobits
414 |   .section .heap, "wa", %nobits
415 | 
416 | 
--------------------------------------------------------------------------------
/demo/ses/nrf5x/flash_placement.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     
 5 |     
 6 |     
 7 |     
 8 |     
 9 |     
10 |     
11 |     
12 |     
13 |     
14 |     
15 |   
16 |   
17 |     
18 |     
19 |     
20 |     
21 |     
22 |     
23 |     
24 |     
25 |     
26 |     
27 |   
28 |   
29 |     
30 |     
31 |     
32 |   
33 |   
34 |     
35 |     
36 |   
37 | 
38 | 
--------------------------------------------------------------------------------
/demo/ses/nrf5x/nRF52840_xxAA_MemoryMap.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   
4 |   
5 | 
6 | 
--------------------------------------------------------------------------------
/demo/ses/nrf5x/nRF_Target.js:
--------------------------------------------------------------------------------
 1 | /*****************************************************************************
 2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
 3 |  *            Solutions for real time microcontroller applications           *
 4 |  *****************************************************************************
 5 |  *                                                                           *
 6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
 7 |  *                                                                           *
 8 |  *           Internet: www.segger.com   Support: support@segger.com          *
 9 |  *                                                                           *
10 |  *****************************************************************************/
11 | 
12 | function Reset() {
13 |   TargetInterface.resetAndStop();
14 | }
15 | 
16 | function EnableTrace(traceInterfaceType) {
17 |   // TODO: Enable trace
18 | }
19 | 
20 | 
--------------------------------------------------------------------------------
/demo/ses/nrf5x/nrf5x.emProject:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 |   
  4 |     
 37 |     
 43 |     
 44 |       
 45 |         
 46 |           
 47 |         
 48 |         
 49 |       
 50 |       
 51 |         
 52 |           
 53 |             
 54 |               
 55 |                 
 56 |                 
 57 |                 
 58 |               
 59 |               
 60 |                 
 61 |                 
 62 |               
 63 |             
 64 |             
 65 |               
 66 |               
 67 |               
 68 |             
 69 |             
 70 |               
 71 |               
 72 |               
 73 |               
 74 |               
 75 |               
 76 |               
 77 |               
 78 |               
 79 |             
 80 |           
 81 |           
 82 |           
 83 |         
 84 |       
 85 |     
 86 |     
 87 |     
 93 |     
 94 |       
 95 |       
 96 |       
 97 |       
 98 |       
 99 |     
100 |     
106 |     
107 |       
108 |         
109 |           
110 |             
111 |             
112 |             
113 |             
114 |             
115 |             
116 |             
117 |             
118 |             
119 |             
120 |             
121 |             
122 |             
123 |             
124 |             
125 |             
126 |             
127 |           
128 |           
129 |             
130 |               
131 |                 
132 |                 
133 |               
134 |             
135 |             
136 |               
137 |             
138 |           
139 |           
140 |           
141 |           
142 |           
143 |         
144 |       
145 |     
146 |     
149 |   
150 |   
151 | 
152 | 
--------------------------------------------------------------------------------
/demo/ses/nrf5x/thumb_crt0.s:
--------------------------------------------------------------------------------
  1 | // SEGGER Embedded Studio, runtime support.
  2 | //
  3 | // Copyright (c) 2014-2017 SEGGER Microcontroller GmbH & Co KG
  4 | // Copyright (c) 2001-2017 Rowley Associates Limited.
  5 | //
  6 | // This file may be distributed under the terms of the License Agreement
  7 | // provided with this software.
  8 | //
  9 | // THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
 10 | // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 11 | //
 12 | //
 13 | //                           Preprocessor Definitions
 14 | //                           ------------------------
 15 | // APP_ENTRY_POINT
 16 | //
 17 | //   Defines the application entry point function, if undefined this setting
 18 | //   defaults to "main".
 19 | //
 20 | // INITIALIZE_STACK
 21 | //
 22 | //   If defined, the contents of the stack will be initialized to a the
 23 | //   value 0xCC.
 24 | //
 25 | // INITIALIZE_SECONDARY_SECTIONS
 26 | //
 27 | //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
 28 | //
 29 | // INITIALIZE_TCM_SECTIONS
 30 | //
 31 | //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
 32 | //   will be initialized.
 33 | //
 34 | // INITIALIZE_USER_SECTIONS
 35 | //
 36 | //   If defined, the function InitializeUserMemorySections will be called prior
 37 | //   to entering main in order to allow the user to initialize any user defined
 38 | //   memory sections.
 39 | //
 40 | // FULL_LIBRARY
 41 | //
 42 | //  If defined then 
 43 | //    - argc, argv are setup by the debug_getargs.
 44 | //    - the exit symbol is defined and executes on return from main.
 45 | //    - the exit symbol calls destructors, atexit functions and then debug_exit.
 46 | //  
 47 | //  If not defined then
 48 | //    - argc and argv are zero.
 49 | //    - the exit symbol is defined, executes on return from main and loops
 50 | //
 51 | 
 52 | #ifndef APP_ENTRY_POINT
 53 | #define APP_ENTRY_POINT main
 54 | #endif
 55 | 
 56 | #ifndef ARGSSPACE
 57 | #define ARGSSPACE 128
 58 | #endif
 59 |   .syntax unified
 60 | 
 61 |   .global _start
 62 |   .extern APP_ENTRY_POINT
 63 |   .global exit
 64 |   .weak exit
 65 | 
 66 | #ifdef INITIALIZE_USER_SECTIONS
 67 |   .extern InitializeUserMemorySections
 68 | #endif
 69 | 
 70 |   .section .init, "ax"
 71 |   .code 16
 72 |   .align 2
 73 |   .thumb_func
 74 | 
 75 | _start:
 76 |   /* Set up main stack if size > 0 */
 77 |   ldr r1, =__stack_end__
 78 |   ldr r0, =__stack_start__
 79 |   subs r2, r1, r0
 80 |   beq 1f
 81 | #ifdef __ARM_EABI__
 82 |   movs r2, #0x7
 83 |   bics r1, r2
 84 | #endif
 85 |   mov sp, r1
 86 | #ifdef INITIALIZE_STACK
 87 |   movs r2, #0xCC
 88 |   ldr r0, =__stack_start__
 89 |   bl memory_set
 90 | #endif
 91 | 1:
 92 | 
 93 |   /* Set up process stack if size > 0 */
 94 |   ldr r1, =__stack_process_end__
 95 |   ldr r0, =__stack_process_start__
 96 |   subs r2, r1, r0
 97 |   beq 1f
 98 | #ifdef __ARM_EABI__
 99 |   movs r2, #0x7
100 |   bics r1, r2
101 | #endif
102 |   msr psp, r1
103 |   movs r2, #2
104 |   msr control, r2
105 | #ifdef INITIALIZE_STACK
106 |   movs r2, #0xCC
107 |   bl memory_set
108 | #endif
109 | 1:
110 | 
111 |   /* Copy initialized memory sections into RAM (if necessary). */
112 |   ldr r0, =__data_load_start__
113 |   ldr r1, =__data_start__
114 |   ldr r2, =__data_end__
115 |   bl memory_copy
116 |   ldr r0, =__text_load_start__
117 |   ldr r1, =__text_start__
118 |   ldr r2, =__text_end__
119 |   bl memory_copy
120 |   ldr r0, =__fast_load_start__
121 |   ldr r1, =__fast_start__
122 |   ldr r2, =__fast_end__
123 |   bl memory_copy
124 |   ldr r0, =__ctors_load_start__
125 |   ldr r1, =__ctors_start__
126 |   ldr r2, =__ctors_end__
127 |   bl memory_copy
128 |   ldr r0, =__dtors_load_start__
129 |   ldr r1, =__dtors_start__
130 |   ldr r2, =__dtors_end__
131 |   bl memory_copy
132 |   ldr r0, =__rodata_load_start__
133 |   ldr r1, =__rodata_start__
134 |   ldr r2, =__rodata_end__
135 |   bl memory_copy
136 |   ldr r0, =__tdata_load_start__
137 |   ldr r1, =__tdata_start__
138 |   ldr r2, =__tdata_end__
139 |   bl memory_copy
140 | #ifdef INITIALIZE_SECONDARY_SECTIONS
141 |   ldr r0, =__data2_load_start__
142 |   ldr r1, =__data2_start__
143 |   ldr r2, =__data2_end__
144 |   bl memory_copy
145 |   ldr r0, =__text2_load_start__
146 |   ldr r1, =__text2_start__
147 |   ldr r2, =__text2_end__
148 |   bl memory_copy
149 |   ldr r0, =__rodata2_load_start__
150 |   ldr r1, =__rodata2_start__
151 |   ldr r2, =__rodata2_end__
152 |   bl memory_copy
153 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
154 | #ifdef INITIALIZE_TCM_SECTIONS
155 |   ldr r0, =__data_tcm_load_start__
156 |   ldr r1, =__data_tcm_start__
157 |   ldr r2, =__data_tcm_end__
158 |   bl memory_copy
159 |   ldr r0, =__text_tcm_load_start__
160 |   ldr r1, =__text_tcm_start__
161 |   ldr r2, =__text_tcm_end__
162 |   bl memory_copy
163 |   ldr r0, =__rodata_tcm_load_start__
164 |   ldr r1, =__rodata_tcm_start__
165 |   ldr r2, =__rodata_tcm_end__
166 |   bl memory_copy
167 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
168 | 
169 |   /* Zero the bss. */
170 |   ldr r0, =__bss_start__
171 |   ldr r1, =__bss_end__
172 |   movs r2, #0
173 |   bl memory_set
174 |   ldr r0, =__tbss_start__
175 |   ldr r1, =__tbss_end__
176 |   movs r2, #0
177 |   bl memory_set
178 | #ifdef INITIALIZE_SECONDARY_SECTIONS
179 |   ldr r0, =__bss2_start__
180 |   ldr r1, =__bss2_end__
181 |   mov r2, #0
182 |   bl memory_set
183 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
184 | #ifdef INITIALIZE_TCM_SECTIONS
185 |   ldr r0, =__bss_tcm_start__
186 |   ldr r1, =__bss_tcm_end__
187 |   mov r2, #0
188 |   bl memory_set
189 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
190 | 
191 |   /* Initialize the heap */
192 |   ldr r0, = __heap_start__
193 |   ldr r1, = __heap_end__
194 |   subs r1, r1, r0
195 |   cmp r1, #8
196 |   blt 1f
197 |   movs r2, #0
198 |   str r2, [r0]
199 |   adds r0, r0, #4
200 |   str r1, [r0]
201 | 1:
202 | 
203 | #ifdef INITIALIZE_USER_SECTIONS
204 |   ldr r2, =InitializeUserMemorySections
205 |   blx r2
206 | #endif
207 | 
208 |   /* Call constructors */
209 |   ldr r0, =__ctors_start__
210 |   ldr r1, =__ctors_end__
211 | ctor_loop:
212 |   cmp r0, r1
213 |   beq ctor_end
214 |   ldr r2, [r0]
215 |   adds r0, #4
216 |   push {r0-r1}  
217 |   blx r2
218 |   pop {r0-r1}
219 |   b ctor_loop
220 | ctor_end:
221 | 
222 |   /* Setup initial call frame */
223 |   movs r0, #0
224 |   mov lr, r0
225 |   mov r12, sp
226 | 
227 |   .type start, function
228 | start:
229 |   /* Jump to application entry point */
230 | #ifdef FULL_LIBRARY
231 |   movs r0, #ARGSSPACE
232 |   ldr r1, =args
233 |   ldr r2, =debug_getargs  
234 |   blx r2
235 |   ldr r1, =args
236 | #else
237 |   movs r0, #0
238 |   movs r1, #0
239 | #endif
240 |   ldr r2, =APP_ENTRY_POINT
241 |   blx r2
242 | 
243 |   .thumb_func
244 | exit:
245 | #ifdef FULL_LIBRARY  
246 |   mov r5, r0 // save the exit parameter/return result
247 | 
248 |   /* Call destructors */
249 |   ldr r0, =__dtors_start__
250 |   ldr r1, =__dtors_end__
251 | dtor_loop:
252 |   cmp r0, r1
253 |   beq dtor_end
254 |   ldr r2, [r0]
255 |   add r0, #4
256 |   push {r0-r1}
257 |   blx r2
258 |   pop {r0-r1}
259 |   b dtor_loop
260 | dtor_end:
261 | 
262 |   /* Call atexit functions */
263 |   ldr r2, =_execute_at_exit_fns  
264 |   blx r2
265 | 
266 |   /* Call debug_exit with return result/exit parameter */
267 |   mov r0, r5
268 |   ldr r2, =debug_exit  
269 |   blx r2
270 | #endif
271 | 
272 |   /* Returned from application entry point, loop forever. */
273 | exit_loop:
274 |   b exit_loop
275 | 
276 |   .thumb_func
277 | memory_copy:
278 |   cmp r0, r1
279 |   beq 2f
280 |   subs r2, r2, r1
281 |   beq 2f
282 | 1:
283 |   ldrb r3, [r0]
284 |   adds r0, r0, #1
285 |   strb r3, [r1]
286 |   adds r1, r1, #1
287 |   subs r2, r2, #1
288 |   bne 1b
289 | 2:
290 |   bx lr
291 | 
292 |   .thumb_func
293 | memory_set:
294 |   cmp r0, r1
295 |   beq 1f
296 |   strb r2, [r0]
297 |   adds r0, r0, #1
298 |   b memory_set
299 | 1:
300 |   bx lr
301 | 
302 |   // default C/C++ library helpers
303 | 
304 | .macro HELPER helper_name
305 |   .section .text.\helper_name, "ax", %progbits
306 |   .global \helper_name
307 |   .weak \helper_name  
308 | \helper_name:
309 |   .thumb_func
310 | .endm
311 | 
312 | .macro JUMPTO name
313 | #if defined(__thumb__) && !defined(__thumb2__)
314 |   mov r12, r0
315 |   ldr r0, =\name
316 |   push {r0}
317 |   mov r0, r12
318 |   pop {pc}
319 | #else
320 |   b \name
321 | #endif
322 | .endm
323 | 
324 | HELPER __aeabi_read_tp
325 |   ldr r0, =__tbss_start__-8
326 |   bx lr
327 | HELPER __heap_lock
328 |   bx lr
329 | HELPER __heap_unlock
330 |   bx lr
331 | HELPER __printf_lock
332 |   bx lr
333 | HELPER __printf_unlock
334 |   bx lr
335 | HELPER __scanf_lock
336 |   bx lr
337 | HELPER __scanf_unlock
338 |   bx lr
339 | HELPER __debug_io_lock
340 |   bx lr
341 | HELPER __debug_io_unlock
342 |   bx lr
343 | HELPER abort
344 |   b .
345 | HELPER __assert
346 |   b .
347 | HELPER __aeabi_assert
348 |   b .
349 | HELPER __cxa_pure_virtual
350 |   b .
351 | HELPER __cxa_guard_acquire
352 |   ldr r3, [r0]
353 | #if defined(__thumb__) && !defined(__thumb2__)
354 |   movs r0, #1
355 |   tst r3, r0
356 | #else
357 |   tst r3, #1
358 | #endif
359 |   beq 1f
360 |   movs r0, #0
361 |   bx lr
362 | 1:
363 |   movs r0, #1
364 |   bx lr
365 | HELPER __cxa_guard_release
366 |   movs r3, #1
367 |   str r3, [r0]
368 |   bx lr
369 | HELPER __cxa_guard_abort
370 |   bx lr
371 | HELPER __sync_synchronize
372 |   bx lr
373 | HELPER __getchar
374 |   JUMPTO debug_getchar
375 | HELPER __putchar
376 |   JUMPTO debug_putchar
377 | HELPER __open
378 |   JUMPTO debug_fopen
379 | HELPER __close
380 |   JUMPTO debug_fclose
381 | HELPER __write   
382 |   mov r3, r0
383 |   mov r0, r1
384 |   movs r1, #1  
385 |   JUMPTO debug_fwrite
386 | HELPER __read  
387 |   mov r3, r0
388 |   mov r0, r1
389 |   movs r1, #1 
390 |   JUMPTO debug_fread
391 | HELPER __seek
392 |   push {r4, lr}
393 |   mov r4, r0
394 |   bl debug_fseek
395 |   cmp r0, #0
396 |   bne 1f
397 |   mov r0, r4
398 |   bl debug_ftell
399 |   pop {r4, pc}
400 | 1:
401 |   ldr r0, =-1
402 |   pop {r4, pc}
403 |   // char __user_locale_name_buffer[];
404 |   .section .bss.__user_locale_name_buffer, "aw", %nobits
405 |   .global __user_locale_name_buffer
406 |   .weak __user_locale_name_buffer
407 |   __user_locale_name_buffer:
408 |   .word 0x0
409 | 
410 | #ifdef FULL_LIBRARY
411 |   .bss
412 | args:
413 |   .space ARGSSPACE
414 | #endif
415 | 
416 |   /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
417 |   .section .stack, "wa", %nobits
418 |   .section .stack_process, "wa", %nobits
419 |   .section .heap, "wa", %nobits
420 | 
421 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/ATSAMD21G18A_MemoryMap.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   
4 |   
5 | 
6 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/ATSAMD21G18A_Vectors.s:
--------------------------------------------------------------------------------
  1 | /*****************************************************************************
  2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
  3 |  *            Solutions for real time microcontroller applications           *
  4 |  *****************************************************************************
  5 |  *                                                                           *
  6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
  7 |  *                                                                           *
  8 |  *           Internet: www.segger.com   Support: support@segger.com          *
  9 |  *                                                                           *
 10 |  *****************************************************************************/
 11 | 
 12 | /*****************************************************************************
 13 |  *                         Preprocessor Definitions                          *
 14 |  *                         ------------------------                          *
 15 |  * VECTORS_IN_RAM                                                            *
 16 |  *                                                                           *
 17 |  *   If defined, an area of RAM will large enough to store the vector table  *
 18 |  *   will be reserved.                                                       *
 19 |  *                                                                           *
 20 |  *****************************************************************************/
 21 | 
 22 |   .syntax unified
 23 |   .code 16
 24 | 
 25 |   .section .init, "ax"
 26 |   .align 0
 27 | 
 28 | /*****************************************************************************
 29 |  * Default Exception Handlers                                                *
 30 |  *****************************************************************************/
 31 | 
 32 |   .thumb_func
 33 |   .weak NMI_Handler
 34 | NMI_Handler:
 35 |   b .
 36 | 
 37 |   .thumb_func
 38 |   .weak HardFault_Handler
 39 | HardFault_Handler:
 40 |   b .
 41 | 
 42 |   .thumb_func
 43 |   .weak SVC_Handler
 44 | SVC_Handler:
 45 |   b .
 46 | 
 47 |   .thumb_func
 48 |   .weak PendSV_Handler
 49 | PendSV_Handler:
 50 |   b .
 51 | 
 52 |   .thumb_func
 53 |   .weak SysTick_Handler
 54 | SysTick_Handler:
 55 |   b .
 56 | 
 57 |   .thumb_func
 58 | Dummy_Handler:
 59 |   b .
 60 | 
 61 | #if defined(__OPTIMIZATION_SMALL)
 62 | 
 63 |   .weak PM_Handler
 64 |   .thumb_set PM_Handler,Dummy_Handler
 65 | 
 66 |   .weak SYSCTRL_Handler
 67 |   .thumb_set SYSCTRL_Handler,Dummy_Handler
 68 | 
 69 |   .weak WDT_Handler
 70 |   .thumb_set WDT_Handler,Dummy_Handler
 71 | 
 72 |   .weak RTC_Handler
 73 |   .thumb_set RTC_Handler,Dummy_Handler
 74 | 
 75 |   .weak EIC_Handler
 76 |   .thumb_set EIC_Handler,Dummy_Handler
 77 | 
 78 |   .weak NVMCTRL_Handler
 79 |   .thumb_set NVMCTRL_Handler,Dummy_Handler
 80 | 
 81 |   .weak DMAC_Handler
 82 |   .thumb_set DMAC_Handler,Dummy_Handler
 83 | 
 84 |   .weak USB_Handler
 85 |   .thumb_set USB_Handler,Dummy_Handler
 86 | 
 87 |   .weak EVSYS_Handler
 88 |   .thumb_set EVSYS_Handler,Dummy_Handler
 89 | 
 90 |   .weak SERCOM0_Handler
 91 |   .thumb_set SERCOM0_Handler,Dummy_Handler
 92 | 
 93 |   .weak SERCOM1_Handler
 94 |   .thumb_set SERCOM1_Handler,Dummy_Handler
 95 | 
 96 |   .weak SERCOM2_Handler
 97 |   .thumb_set SERCOM2_Handler,Dummy_Handler
 98 | 
 99 |   .weak SERCOM3_Handler
100 |   .thumb_set SERCOM3_Handler,Dummy_Handler
101 | 
102 |   .weak SERCOM4_Handler
103 |   .thumb_set SERCOM4_Handler,Dummy_Handler
104 | 
105 |   .weak SERCOM5_Handler
106 |   .thumb_set SERCOM5_Handler,Dummy_Handler
107 | 
108 |   .weak TCC0_Handler
109 |   .thumb_set TCC0_Handler,Dummy_Handler
110 | 
111 |   .weak TCC1_Handler
112 |   .thumb_set TCC1_Handler,Dummy_Handler
113 | 
114 |   .weak TCC2_Handler
115 |   .thumb_set TCC2_Handler,Dummy_Handler
116 | 
117 |   .weak TC3_Handler
118 |   .thumb_set TC3_Handler,Dummy_Handler
119 | 
120 |   .weak TC4_Handler
121 |   .thumb_set TC4_Handler,Dummy_Handler
122 | 
123 |   .weak TC5_Handler
124 |   .thumb_set TC5_Handler,Dummy_Handler
125 | 
126 |   .weak ADC_Handler
127 |   .thumb_set ADC_Handler,Dummy_Handler
128 | 
129 |   .weak AC_Handler
130 |   .thumb_set AC_Handler,Dummy_Handler
131 | 
132 |   .weak DAC_Handler
133 |   .thumb_set DAC_Handler,Dummy_Handler
134 | 
135 |   .weak I2S_Handler
136 |   .thumb_set I2S_Handler,Dummy_Handler
137 | 
138 | #else
139 | 
140 |   .thumb_func
141 |   .weak PM_Handler
142 | PM_Handler:
143 |   b .
144 | 
145 |   .thumb_func
146 |   .weak SYSCTRL_Handler
147 | SYSCTRL_Handler:
148 |   b .
149 | 
150 |   .thumb_func
151 |   .weak WDT_Handler
152 | WDT_Handler:
153 |   b .
154 | 
155 |   .thumb_func
156 |   .weak RTC_Handler
157 | RTC_Handler:
158 |   b .
159 | 
160 |   .thumb_func
161 |   .weak EIC_Handler
162 | EIC_Handler:
163 |   b .
164 | 
165 |   .thumb_func
166 |   .weak NVMCTRL_Handler
167 | NVMCTRL_Handler:
168 |   b .
169 | 
170 |   .thumb_func
171 |   .weak DMAC_Handler
172 | DMAC_Handler:
173 |   b .
174 | 
175 |   .thumb_func
176 |   .weak USB_Handler
177 | USB_Handler:
178 |   b .
179 | 
180 |   .thumb_func
181 |   .weak EVSYS_Handler
182 | EVSYS_Handler:
183 |   b .
184 | 
185 |   .thumb_func
186 |   .weak SERCOM0_Handler
187 | SERCOM0_Handler:
188 |   b .
189 | 
190 |   .thumb_func
191 |   .weak SERCOM1_Handler
192 | SERCOM1_Handler:
193 |   b .
194 | 
195 |   .thumb_func
196 |   .weak SERCOM2_Handler
197 | SERCOM2_Handler:
198 |   b .
199 | 
200 |   .thumb_func
201 |   .weak SERCOM3_Handler
202 | SERCOM3_Handler:
203 |   b .
204 | 
205 |   .thumb_func
206 |   .weak SERCOM4_Handler
207 | SERCOM4_Handler:
208 |   b .
209 | 
210 |   .thumb_func
211 |   .weak SERCOM5_Handler
212 | SERCOM5_Handler:
213 |   b .
214 | 
215 |   .thumb_func
216 |   .weak TCC0_Handler
217 | TCC0_Handler:
218 |   b .
219 | 
220 |   .thumb_func
221 |   .weak TCC1_Handler
222 | TCC1_Handler:
223 |   b .
224 | 
225 |   .thumb_func
226 |   .weak TCC2_Handler
227 | TCC2_Handler:
228 |   b .
229 | 
230 |   .thumb_func
231 |   .weak TC3_Handler
232 | TC3_Handler:
233 |   b .
234 | 
235 |   .thumb_func
236 |   .weak TC4_Handler
237 | TC4_Handler:
238 |   b .
239 | 
240 |   .thumb_func
241 |   .weak TC5_Handler
242 | TC5_Handler:
243 |   b .
244 | 
245 |   .thumb_func
246 |   .weak ADC_Handler
247 | ADC_Handler:
248 |   b .
249 | 
250 |   .thumb_func
251 |   .weak AC_Handler
252 | AC_Handler:
253 |   b .
254 | 
255 |   .thumb_func
256 |   .weak DAC_Handler
257 | DAC_Handler:
258 |   b .
259 | 
260 |   .thumb_func
261 |   .weak I2S_Handler
262 | I2S_Handler:
263 |   b .
264 | 
265 | #endif
266 | 
267 | /*****************************************************************************
268 |  * Vector Table                                                              *
269 |  *****************************************************************************/
270 | 
271 |   .section .vectors, "ax"
272 |   .align 0
273 |   .global _vectors
274 |   .extern __stack_end__
275 |   .extern Reset_Handler
276 | 
277 | _vectors:
278 |   .word __stack_end__
279 |   .word Reset_Handler
280 |   .word NMI_Handler
281 |   .word HardFault_Handler
282 |   .word 0 /* Reserved */
283 |   .word 0 /* Reserved */
284 |   .word 0 /* Reserved */
285 |   .word 0 /* Reserved */
286 |   .word 0 /* Reserved */
287 |   .word 0 /* Reserved */
288 |   .word 0 /* Reserved */
289 |   .word SVC_Handler
290 |   .word 0 /* Reserved */
291 |   .word 0 /* Reserved */
292 |   .word PendSV_Handler
293 |   .word SysTick_Handler
294 |   .word PM_Handler
295 |   .word SYSCTRL_Handler
296 |   .word WDT_Handler
297 |   .word RTC_Handler
298 |   .word EIC_Handler
299 |   .word NVMCTRL_Handler
300 |   .word DMAC_Handler
301 |   .word USB_Handler
302 |   .word EVSYS_Handler
303 |   .word SERCOM0_Handler
304 |   .word SERCOM1_Handler
305 |   .word SERCOM2_Handler
306 |   .word SERCOM3_Handler
307 |   .word SERCOM4_Handler
308 |   .word SERCOM5_Handler
309 |   .word TCC0_Handler
310 |   .word TCC1_Handler
311 |   .word TCC2_Handler
312 |   .word TC3_Handler
313 |   .word TC4_Handler
314 |   .word TC5_Handler
315 |   .word Dummy_Handler /* Reserved */
316 |   .word Dummy_Handler /* Reserved */
317 |   .word ADC_Handler
318 |   .word AC_Handler
319 |   .word DAC_Handler
320 |   .word Dummy_Handler /* Reserved */
321 |   .word I2S_Handler
322 | _vectors_end:
323 | 
324 | #ifdef VECTORS_IN_RAM
325 |   .section .vectors_ram, "ax"
326 |   .align 0
327 |   .global _vectors_ram
328 | 
329 | _vectors_ram:
330 |   .space _vectors_end - _vectors, 0
331 | #endif
332 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/SAMD21_Startup.s:
--------------------------------------------------------------------------------
  1 | /*****************************************************************************
  2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
  3 |  *            Solutions for real time microcontroller applications           *
  4 |  *****************************************************************************
  5 |  *                                                                           *
  6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
  7 |  *                                                                           *
  8 |  *           Internet: www.segger.com   Support: support@segger.com          *
  9 |  *                                                                           *
 10 |  *****************************************************************************/
 11 | 
 12 | /*****************************************************************************
 13 |  *                         Preprocessor Definitions                          *
 14 |  *                         ------------------------                          *
 15 |  * NO_STACK_INIT                                                             *
 16 |  *                                                                           *
 17 |  *   If defined, the stack pointer will not be initialised.                  *
 18 |  *                                                                           *
 19 |  * NO_SYSTEM_INIT                                                            *
 20 |  *                                                                           *
 21 |  *   If defined, the SystemInit() function will not be called. By default    *
 22 |  *   SystemInit() is called after reset to enable the clocks and memories to *
 23 |  *   be initialised prior to any C startup initialisation.                   *
 24 |  *                                                                           *
 25 |  * NO_VTOR_CONFIG                                                            *
 26 |  *                                                                           *
 27 |  *   If defined, the vector table offset register will not be configured.    *
 28 |  *                                                                           *
 29 |  * MEMORY_INIT                                                               *
 30 |  *                                                                           *
 31 |  *   If defined, the MemoryInit() function will be called. By default        *
 32 |  *   MemoryInit() is called after SystemInit() to enable an external memory  *
 33 |  *   controller.                                                             *
 34 |  *                                                                           *
 35 |  * STACK_INIT_VAL                                                            *
 36 |  *                                                                           *
 37 |  *   If defined, specifies the initial stack pointer value. If undefined,    *
 38 |  *   the stack pointer will be initialised to point to the end of the        *
 39 |  *   RAM segment.                                                            *
 40 |  *                                                                           *
 41 |  * VECTORS_IN_RAM                                                            *
 42 |  *                                                                           *
 43 |  *   If defined, the exception vectors will be copied from Flash to RAM.     *
 44 |  *                                                                           *
 45 |  *****************************************************************************/
 46 | 
 47 |   .syntax unified
 48 | 
 49 |   .global Reset_Handler
 50 |   .extern _vectors
 51 | 
 52 |   .section .init, "ax"
 53 |   .thumb_func
 54 | 
 55 |   .equ VTOR_REG, 0xE000ED08
 56 | 
 57 | #ifndef STACK_INIT_VAL
 58 | #define STACK_INIT_VAL __RAM_segment_end__
 59 | #endif
 60 | 
 61 | Reset_Handler:
 62 | #ifndef NO_STACK_INIT
 63 |   /* Initialise main stack */
 64 |   ldr r0, =STACK_INIT_VAL
 65 |   ldr r1, =0x7
 66 |   bics r0, r1
 67 |   mov sp, r0
 68 | #endif
 69 | 
 70 | #ifndef NO_SYSTEM_INIT
 71 |   /* Initialise system */
 72 |   ldr r0, =SystemInit
 73 |   blx r0
 74 |   .pushsection .init_array, "aw", %init_array
 75 |   .word SystemCoreClockUpdate
 76 |   .popsection
 77 | #endif
 78 | 
 79 | #ifdef MEMORY_INIT
 80 |   ldr r0, =MemoryInit
 81 |   blx r0
 82 | #endif
 83 | 
 84 | #ifdef VECTORS_IN_RAM
 85 |   /* Copy exception vectors into RAM */
 86 |   ldr r0, =__vectors_start__
 87 |   ldr r1, =__vectors_end__
 88 |   ldr r2, =__vectors_ram_start__
 89 | 1:
 90 |   cmp r0, r1
 91 |   beq 2f
 92 |   ldr r3, [r0]
 93 |   str r3, [r2]
 94 |   adds r0, r0, #4
 95 |   adds r2, r2, #4
 96 |   b 1b
 97 | 2:
 98 | #endif
 99 | 
100 | #ifndef NO_VTOR_CONFIG
101 |   /* Configure vector table offset register */
102 |   ldr r0, =VTOR_REG
103 | #ifdef VECTORS_IN_RAM
104 |   ldr r1, =_vectors_ram
105 | #else
106 |   ldr r1, =_vectors
107 | #endif
108 |   str r1, [r0]
109 | #endif
110 | 
111 |   /* Jump to program start */
112 |   b _start
113 | 
114 | 
115 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/SAMD21_Target.js:
--------------------------------------------------------------------------------
 1 | /*****************************************************************************
 2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
 3 |  *            Solutions for real time microcontroller applications           *
 4 |  *****************************************************************************
 5 |  *                                                                           *
 6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
 7 |  *                                                                           *
 8 |  *           Internet: www.segger.com   Support: support@segger.com          *
 9 |  *                                                                           *
10 |  *****************************************************************************/
11 | 
12 | function Reset() {
13 |   TargetInterface.resetAndStop();
14 | }
15 | 
16 | function EnableTrace(traceInterfaceType) {
17 |   // TODO: Enable trace
18 | }
19 | 
20 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/flash_placement.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     
 5 |     
 6 |     
 7 |     
 8 |     
 9 |     
10 |     
11 |     
12 |     
13 |     
14 |     
15 |   
16 |   
17 |     
18 |     
19 |     
20 |     
21 |     
22 |     
23 |     
24 |     
25 |     
26 |     
27 |   
28 |   
29 |     
30 |     
31 |     
32 |   
33 |   
34 |     
35 |     
36 |   
37 | 
38 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/samd21.emProject:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 |   
  4 |     
 36 |     
 42 |     
 43 |       
 44 |         
 45 |         
 46 |           
 47 |         
 48 |       
 49 |       
 50 |         
 51 |           
 52 |             
 53 |               
 54 |                 
 55 |                   
 56 |                 
 57 |                 
 58 |                   
 59 |                     
 60 |                   
 61 |                   
 62 |                     
 63 |                   
 64 |                   
 65 |                     
 66 |                   
 67 |                   
 68 |                     
 69 |                   
 70 |                 
 71 |               
 72 |             
 73 |           
 74 |         
 75 |       
 76 |     
 77 |     
 78 |     
 84 |     
 85 |       
 86 |       
 87 |       
 88 |       
 89 |       
 90 |       
 91 |       
 92 |     
 93 |     
 99 |     
100 |       
101 |         
102 |           
103 |             
104 |             
105 |             
106 |             
107 |             
108 |             
109 |             
110 |             
111 |             
112 |             
113 |             
114 |             
115 |             
116 |             
117 |             
118 |             
119 |             
120 |           
121 |           
122 |             
123 |               
124 |                 
125 |                 
126 |               
127 |             
128 |             
129 |               
130 |             
131 |           
132 |           
133 |           
134 |           
135 |           
136 |         
137 |         
138 |       
139 |     
140 |   
141 |   
142 | 
143 | 
--------------------------------------------------------------------------------
/demo/ses/samd21/thumb_crt0.s:
--------------------------------------------------------------------------------
  1 | // **********************************************************************
  2 | // *                    SEGGER Microcontroller GmbH                     *
  3 | // *                        The Embedded Experts                        *
  4 | // **********************************************************************
  5 | // *                                                                    *
  6 | // *            (c) 2014 - 2018 SEGGER Microcontroller GmbH             *
  7 | // *            (c) 2001 - 2018 Rowley Associates Limited               *
  8 | // *                                                                    *
  9 | // *           www.segger.com     Support: support@segger.com           *
 10 | // *                                                                    *
 11 | // **********************************************************************
 12 | // *                                                                    *
 13 | // * All rights reserved.                                               *
 14 | // *                                                                    *
 15 | // * Redistribution and use in source and binary forms, with or         *
 16 | // * without modification, are permitted provided that the following    *
 17 | // * conditions are met:                                                *
 18 | // *                                                                    *
 19 | // * - Redistributions of source code must retain the above copyright   *
 20 | // *   notice, this list of conditions and the following disclaimer.    *
 21 | // *                                                                    *
 22 | // * - Neither the name of SEGGER Microcontroller GmbH                  *
 23 | // *   nor the names of its contributors may be used to endorse or      *
 24 | // *   promote products derived from this software without specific     *
 25 | // *   prior written permission.                                        *
 26 | // *                                                                    *
 27 | // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
 28 | // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
 29 | // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
 30 | // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
 31 | // * DISCLAIMED.                                                        *
 32 | // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
 33 | // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
 34 | // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
 35 | // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
 36 | // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
 37 | // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
 38 | // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
 39 | // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
 40 | // * DAMAGE.                                                            *
 41 | // *                                                                    *
 42 | // **********************************************************************
 43 | //
 44 | //
 45 | //                           Preprocessor Definitions
 46 | //                           ------------------------
 47 | // APP_ENTRY_POINT
 48 | //
 49 | //   Defines the application entry point function, if undefined this setting
 50 | //   defaults to "main".
 51 | //
 52 | // INITIALIZE_STACK
 53 | //
 54 | //   If defined, the contents of the stack will be initialized to a the
 55 | //   value 0xCC.
 56 | //
 57 | // INITIALIZE_SECONDARY_SECTIONS
 58 | //
 59 | //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
 60 | //
 61 | // INITIALIZE_TCM_SECTIONS
 62 | //
 63 | //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
 64 | //   will be initialized.
 65 | //
 66 | // INITIALIZE_USER_SECTIONS
 67 | //
 68 | //   If defined, the function InitializeUserMemorySections will be called prior
 69 | //   to entering main in order to allow the user to initialize any user defined
 70 | //   memory sections.
 71 | //
 72 | // FULL_LIBRARY
 73 | //
 74 | //  If defined then 
 75 | //    - argc, argv are setup by the debug_getargs.
 76 | //    - the exit symbol is defined and executes on return from main.
 77 | //    - the exit symbol calls destructors, atexit functions and then debug_exit.
 78 | //  
 79 | //  If not defined then
 80 | //    - argc and argv are zero.
 81 | //    - the exit symbol is defined, executes on return from main and loops
 82 | //
 83 | 
 84 | #ifndef APP_ENTRY_POINT
 85 | #define APP_ENTRY_POINT main
 86 | #endif
 87 | 
 88 | #ifndef ARGSSPACE
 89 | #define ARGSSPACE 128
 90 | #endif
 91 |   .syntax unified
 92 | 
 93 |   .global _start
 94 |   .extern APP_ENTRY_POINT
 95 |   .global exit
 96 |   .weak exit
 97 | 
 98 | #ifdef INITIALIZE_USER_SECTIONS
 99 |   .extern InitializeUserMemorySections
100 | #endif
101 | 
102 |   .section .init, "ax"
103 |   .code 16
104 |   .balign 2
105 |   .thumb_func
106 | 
107 | _start:
108 |   /* Set up main stack if size > 0 */
109 |   ldr r1, =__stack_end__
110 |   ldr r0, =__stack_start__
111 |   subs r2, r1, r0
112 |   beq 1f
113 | #ifdef __ARM_EABI__
114 |   movs r2, #0x7
115 |   bics r1, r2
116 | #endif
117 |   mov sp, r1
118 | #ifdef INITIALIZE_STACK
119 |   movs r2, #0xCC
120 |   ldr r0, =__stack_start__
121 |   bl memory_set
122 | #endif
123 | 1:
124 | 
125 |   /* Set up process stack if size > 0 */
126 |   ldr r1, =__stack_process_end__
127 |   ldr r0, =__stack_process_start__
128 |   subs r2, r1, r0
129 |   beq 1f
130 | #ifdef __ARM_EABI__
131 |   movs r2, #0x7
132 |   bics r1, r2
133 | #endif
134 |   msr psp, r1
135 |   movs r2, #2
136 |   msr control, r2
137 | #ifdef INITIALIZE_STACK
138 |   movs r2, #0xCC
139 |   bl memory_set
140 | #endif
141 | 1:
142 | 
143 |   /* Copy initialized memory sections into RAM (if necessary). */
144 |   ldr r0, =__data_load_start__
145 |   ldr r1, =__data_start__
146 |   ldr r2, =__data_end__
147 |   bl memory_copy
148 |   ldr r0, =__text_load_start__
149 |   ldr r1, =__text_start__
150 |   ldr r2, =__text_end__
151 |   bl memory_copy
152 |   ldr r0, =__fast_load_start__
153 |   ldr r1, =__fast_start__
154 |   ldr r2, =__fast_end__
155 |   bl memory_copy
156 |   ldr r0, =__ctors_load_start__
157 |   ldr r1, =__ctors_start__
158 |   ldr r2, =__ctors_end__
159 |   bl memory_copy
160 |   ldr r0, =__dtors_load_start__
161 |   ldr r1, =__dtors_start__
162 |   ldr r2, =__dtors_end__
163 |   bl memory_copy
164 |   ldr r0, =__rodata_load_start__
165 |   ldr r1, =__rodata_start__
166 |   ldr r2, =__rodata_end__
167 |   bl memory_copy
168 |   ldr r0, =__tdata_load_start__
169 |   ldr r1, =__tdata_start__
170 |   ldr r2, =__tdata_end__
171 |   bl memory_copy
172 | #ifdef INITIALIZE_SECONDARY_SECTIONS
173 |   ldr r0, =__data2_load_start__
174 |   ldr r1, =__data2_start__
175 |   ldr r2, =__data2_end__
176 |   bl memory_copy
177 |   ldr r0, =__text2_load_start__
178 |   ldr r1, =__text2_start__
179 |   ldr r2, =__text2_end__
180 |   bl memory_copy
181 |   ldr r0, =__rodata2_load_start__
182 |   ldr r1, =__rodata2_start__
183 |   ldr r2, =__rodata2_end__
184 |   bl memory_copy
185 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
186 | #ifdef INITIALIZE_TCM_SECTIONS
187 |   ldr r0, =__data_tcm_load_start__
188 |   ldr r1, =__data_tcm_start__
189 |   ldr r2, =__data_tcm_end__
190 |   bl memory_copy
191 |   ldr r0, =__text_tcm_load_start__
192 |   ldr r1, =__text_tcm_start__
193 |   ldr r2, =__text_tcm_end__
194 |   bl memory_copy
195 |   ldr r0, =__rodata_tcm_load_start__
196 |   ldr r1, =__rodata_tcm_start__
197 |   ldr r2, =__rodata_tcm_end__
198 |   bl memory_copy
199 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
200 | 
201 |   /* Zero the bss. */
202 |   ldr r0, =__bss_start__
203 |   ldr r1, =__bss_end__
204 |   movs r2, #0
205 |   bl memory_set
206 |   ldr r0, =__tbss_start__
207 |   ldr r1, =__tbss_end__
208 |   movs r2, #0
209 |   bl memory_set
210 | #ifdef INITIALIZE_SECONDARY_SECTIONS
211 |   ldr r0, =__bss2_start__
212 |   ldr r1, =__bss2_end__
213 |   mov r2, #0
214 |   bl memory_set
215 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
216 | #ifdef INITIALIZE_TCM_SECTIONS
217 |   ldr r0, =__bss_tcm_start__
218 |   ldr r1, =__bss_tcm_end__
219 |   mov r2, #0
220 |   bl memory_set
221 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
222 | 
223 |   /* Initialize the heap */
224 |   ldr r0, = __heap_start__
225 |   ldr r1, = __heap_end__
226 |   subs r1, r1, r0
227 |   cmp r1, #8
228 |   blt 1f
229 |   movs r2, #0
230 |   str r2, [r0]
231 |   adds r0, r0, #4
232 |   str r1, [r0]
233 | 1:
234 | 
235 | #ifdef INITIALIZE_USER_SECTIONS
236 |   ldr r2, =InitializeUserMemorySections
237 |   blx r2
238 | #endif
239 | 
240 |   /* Call constructors */
241 |   ldr r0, =__ctors_start__
242 |   ldr r1, =__ctors_end__
243 | ctor_loop:
244 |   cmp r0, r1
245 |   beq ctor_end
246 |   ldr r2, [r0]
247 |   adds r0, #4
248 |   push {r0-r1}  
249 |   blx r2
250 |   pop {r0-r1}
251 |   b ctor_loop
252 | ctor_end:
253 | 
254 |   /* Setup initial call frame */
255 |   movs r0, #0
256 |   mov lr, r0
257 |   mov r12, sp
258 | 
259 |   .type start, function
260 | start:
261 |   /* Jump to application entry point */
262 | #ifdef FULL_LIBRARY
263 |   movs r0, #ARGSSPACE
264 |   ldr r1, =args
265 |   ldr r2, =debug_getargs  
266 |   blx r2
267 |   ldr r1, =args
268 | #else
269 |   movs r0, #0
270 |   movs r1, #0
271 | #endif
272 |   ldr r2, =APP_ENTRY_POINT
273 |   blx r2
274 | 
275 |   .thumb_func
276 | exit:
277 | #ifdef FULL_LIBRARY  
278 |   mov r5, r0 // save the exit parameter/return result
279 | 
280 |   /* Call destructors */
281 |   ldr r0, =__dtors_start__
282 |   ldr r1, =__dtors_end__
283 | dtor_loop:
284 |   cmp r0, r1
285 |   beq dtor_end
286 |   ldr r2, [r0]
287 |   add r0, #4
288 |   push {r0-r1}
289 |   blx r2
290 |   pop {r0-r1}
291 |   b dtor_loop
292 | dtor_end:
293 | 
294 |   /* Call atexit functions */
295 |   ldr r2, =_execute_at_exit_fns  
296 |   blx r2
297 | 
298 |   /* Call debug_exit with return result/exit parameter */
299 |   mov r0, r5
300 |   ldr r2, =debug_exit  
301 |   blx r2
302 | #endif
303 | 
304 |   /* Returned from application entry point, loop forever. */
305 | exit_loop:
306 |   b exit_loop
307 | 
308 |   .thumb_func
309 | memory_copy:
310 |   cmp r0, r1
311 |   beq 2f
312 |   subs r2, r2, r1
313 |   beq 2f
314 | 1:
315 |   ldrb r3, [r0]
316 |   adds r0, r0, #1
317 |   strb r3, [r1]
318 |   adds r1, r1, #1
319 |   subs r2, r2, #1
320 |   bne 1b
321 | 2:
322 |   bx lr
323 | 
324 |   .thumb_func
325 | memory_set:
326 |   cmp r0, r1
327 |   beq 1f
328 |   strb r2, [r0]
329 |   adds r0, r0, #1
330 |   b memory_set
331 | 1:
332 |   bx lr
333 | 
334 |   // default C/C++ library helpers
335 | 
336 | .macro HELPER helper_name
337 |   .section .text.\helper_name, "ax", %progbits
338 |   .balign 2
339 |   .global \helper_name
340 |   .weak \helper_name  
341 | \helper_name:
342 |   .thumb_func
343 | .endm
344 | 
345 | .macro JUMPTO name
346 | #if defined(__thumb__) && !defined(__thumb2__)
347 |   mov r12, r0
348 |   ldr r0, =\name
349 |   push {r0}
350 |   mov r0, r12
351 |   pop {pc}
352 | #else
353 |   b \name
354 | #endif
355 | .endm
356 | 
357 | HELPER __aeabi_read_tp
358 |   ldr r0, =__tbss_start__-8
359 |   bx lr
360 | HELPER abort
361 |   b .
362 | HELPER __assert
363 |   b .
364 | HELPER __aeabi_assert
365 |   b .
366 | HELPER __sync_synchronize
367 |   bx lr
368 | HELPER __getchar
369 |   JUMPTO debug_getchar
370 | HELPER __putchar
371 |   JUMPTO debug_putchar
372 | HELPER __open
373 |   JUMPTO debug_fopen
374 | HELPER __close
375 |   JUMPTO debug_fclose
376 | HELPER __write   
377 |   mov r3, r0
378 |   mov r0, r1
379 |   movs r1, #1  
380 |   JUMPTO debug_fwrite
381 | HELPER __read  
382 |   mov r3, r0
383 |   mov r0, r1
384 |   movs r1, #1 
385 |   JUMPTO debug_fread
386 | HELPER __seek
387 |   push {r4, lr}
388 |   mov r4, r0
389 |   bl debug_fseek
390 |   cmp r0, #0
391 |   bne 1f
392 |   mov r0, r4
393 |   bl debug_ftell
394 |   pop {r4, pc}
395 | 1:
396 |   ldr r0, =-1
397 |   pop {r4, pc}
398 |   // char __user_locale_name_buffer[];
399 |   .section .bss.__user_locale_name_buffer, "aw", %nobits
400 |   .global __user_locale_name_buffer
401 |   .weak __user_locale_name_buffer
402 |   __user_locale_name_buffer:
403 |   .word 0x0
404 | 
405 | #ifdef FULL_LIBRARY
406 |   .bss
407 | args:
408 |   .space ARGSSPACE
409 | #endif
410 | 
411 |   /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
412 |   .section .stack, "wa", %nobits
413 |   .section .stack_process, "wa", %nobits
414 |   .section .heap, "wa", %nobits
415 | 
416 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/ATSAMD51J19A_MemoryMap.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   
4 |   
5 |   
6 | 
7 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/ATSAMD51J19A_Vectors.s:
--------------------------------------------------------------------------------
   1 | /*****************************************************************************
   2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
   3 |  *            Solutions for real time microcontroller applications           *
   4 |  *****************************************************************************
   5 |  *                                                                           *
   6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
   7 |  *                                                                           *
   8 |  *           Internet: www.segger.com   Support: support@segger.com          *
   9 |  *                                                                           *
  10 |  *****************************************************************************/
  11 | 
  12 | /*****************************************************************************
  13 |  *                         Preprocessor Definitions                          *
  14 |  *                         ------------------------                          *
  15 |  * STARTUP_FROM_RESET                                                        *
  16 |  *                                                                           *
  17 |  *   If defined, the program will startup from power-on/reset. If not        *
  18 |  *   defined the program will just loop endlessly from power-on/reset.       *
  19 |  *                                                                           *
  20 |  * VECTORS_IN_RAM                                                            *
  21 |  *                                                                           *
  22 |  *   If defined, an area of RAM will large enough to store the vector table  *
  23 |  *   will be reserved.                                                       *
  24 |  *                                                                           *
  25 |  *****************************************************************************/
  26 | 
  27 |   .syntax unified
  28 |   .code 16
  29 | 
  30 |   .section .init, "ax"
  31 |   .align 0
  32 | 
  33 | /*****************************************************************************
  34 |  * Default Exception Handlers                                                *
  35 |  *****************************************************************************/
  36 | 
  37 | #ifndef STARTUP_FROM_RESET
  38 | 
  39 |   .thumb_func
  40 |   .weak Reset_Wait
  41 | Reset_Wait:
  42 |   b .
  43 | 
  44 | #endif
  45 | 
  46 |   .thumb_func
  47 |   .weak NMI_Handler
  48 | NMI_Handler:
  49 |   b .
  50 | 
  51 |   .thumb_func
  52 |   .weak HardFault_Handler
  53 | HardFault_Handler:
  54 |   b .
  55 | 
  56 |   .thumb_func
  57 |   .weak SVC_Handler
  58 | SVC_Handler:
  59 |   b .
  60 | 
  61 |   .thumb_func
  62 |   .weak PendSV_Handler
  63 | PendSV_Handler:
  64 |   b .
  65 | 
  66 |   .thumb_func
  67 |   .weak SysTick_Handler
  68 | SysTick_Handler:
  69 |   b .
  70 | 
  71 |   .thumb_func
  72 | Dummy_Handler:
  73 |   b .
  74 | 
  75 | #if defined(__OPTIMIZATION_SMALL)
  76 | 
  77 |   .weak PM_Handler
  78 |   .thumb_set PM_Handler,Dummy_Handler
  79 | 
  80 |   .weak MCLK_Handler
  81 |   .thumb_set MCLK_Handler,Dummy_Handler
  82 | 
  83 |   .weak OSCCTRL_0_Handler
  84 |   .thumb_set OSCCTRL_0_Handler,Dummy_Handler
  85 | 
  86 |   .weak OSCCTRL_1_Handler
  87 |   .thumb_set OSCCTRL_1_Handler,Dummy_Handler
  88 | 
  89 |   .weak OSCCTRL_2_Handler
  90 |   .thumb_set OSCCTRL_2_Handler,Dummy_Handler
  91 | 
  92 |   .weak OSCCTRL_3_Handler
  93 |   .thumb_set OSCCTRL_3_Handler,Dummy_Handler
  94 | 
  95 |   .weak OSCCTRL_4_Handler
  96 |   .thumb_set OSCCTRL_4_Handler,Dummy_Handler
  97 | 
  98 |   .weak OSC32KCTRL_Handler
  99 |   .thumb_set OSC32KCTRL_Handler,Dummy_Handler
 100 | 
 101 |   .weak SUPC_0_Handler
 102 |   .thumb_set SUPC_0_Handler,Dummy_Handler
 103 | 
 104 |   .weak SUPC_1_Handler
 105 |   .thumb_set SUPC_1_Handler,Dummy_Handler
 106 | 
 107 |   .weak WDT_Handler
 108 |   .thumb_set WDT_Handler,Dummy_Handler
 109 | 
 110 |   .weak RTC_Handler
 111 |   .thumb_set RTC_Handler,Dummy_Handler
 112 | 
 113 |   .weak EIC_0_Handler
 114 |   .thumb_set EIC_0_Handler,Dummy_Handler
 115 | 
 116 |   .weak EIC_1_Handler
 117 |   .thumb_set EIC_1_Handler,Dummy_Handler
 118 | 
 119 |   .weak EIC_2_Handler
 120 |   .thumb_set EIC_2_Handler,Dummy_Handler
 121 | 
 122 |   .weak EIC_3_Handler
 123 |   .thumb_set EIC_3_Handler,Dummy_Handler
 124 | 
 125 |   .weak EIC_4_Handler
 126 |   .thumb_set EIC_4_Handler,Dummy_Handler
 127 | 
 128 |   .weak EIC_5_Handler
 129 |   .thumb_set EIC_5_Handler,Dummy_Handler
 130 | 
 131 |   .weak EIC_6_Handler
 132 |   .thumb_set EIC_6_Handler,Dummy_Handler
 133 | 
 134 |   .weak EIC_7_Handler
 135 |   .thumb_set EIC_7_Handler,Dummy_Handler
 136 | 
 137 |   .weak EIC_8_Handler
 138 |   .thumb_set EIC_8_Handler,Dummy_Handler
 139 | 
 140 |   .weak EIC_9_Handler
 141 |   .thumb_set EIC_9_Handler,Dummy_Handler
 142 | 
 143 |   .weak EIC_10_Handler
 144 |   .thumb_set EIC_10_Handler,Dummy_Handler
 145 | 
 146 |   .weak EIC_11_Handler
 147 |   .thumb_set EIC_11_Handler,Dummy_Handler
 148 | 
 149 |   .weak EIC_12_Handler
 150 |   .thumb_set EIC_12_Handler,Dummy_Handler
 151 | 
 152 |   .weak EIC_13_Handler
 153 |   .thumb_set EIC_13_Handler,Dummy_Handler
 154 | 
 155 |   .weak EIC_14_Handler
 156 |   .thumb_set EIC_14_Handler,Dummy_Handler
 157 | 
 158 |   .weak EIC_15_Handler
 159 |   .thumb_set EIC_15_Handler,Dummy_Handler
 160 | 
 161 |   .weak FREQM_Handler
 162 |   .thumb_set FREQM_Handler,Dummy_Handler
 163 | 
 164 |   .weak NVMCTRL_0_Handler
 165 |   .thumb_set NVMCTRL_0_Handler,Dummy_Handler
 166 | 
 167 |   .weak NVMCTRL_1_Handler
 168 |   .thumb_set NVMCTRL_1_Handler,Dummy_Handler
 169 | 
 170 |   .weak DMAC_0_Handler
 171 |   .thumb_set DMAC_0_Handler,Dummy_Handler
 172 | 
 173 |   .weak DMAC_1_Handler
 174 |   .thumb_set DMAC_1_Handler,Dummy_Handler
 175 | 
 176 |   .weak DMAC_2_Handler
 177 |   .thumb_set DMAC_2_Handler,Dummy_Handler
 178 | 
 179 |   .weak DMAC_3_Handler
 180 |   .thumb_set DMAC_3_Handler,Dummy_Handler
 181 | 
 182 |   .weak DMAC_4_Handler
 183 |   .thumb_set DMAC_4_Handler,Dummy_Handler
 184 | 
 185 |   .weak EVSYS_0_Handler
 186 |   .thumb_set EVSYS_0_Handler,Dummy_Handler
 187 | 
 188 |   .weak EVSYS_1_Handler
 189 |   .thumb_set EVSYS_1_Handler,Dummy_Handler
 190 | 
 191 |   .weak EVSYS_2_Handler
 192 |   .thumb_set EVSYS_2_Handler,Dummy_Handler
 193 | 
 194 |   .weak EVSYS_3_Handler
 195 |   .thumb_set EVSYS_3_Handler,Dummy_Handler
 196 | 
 197 |   .weak EVSYS_4_Handler
 198 |   .thumb_set EVSYS_4_Handler,Dummy_Handler
 199 | 
 200 |   .weak PAC_Handler
 201 |   .thumb_set PAC_Handler,Dummy_Handler
 202 | 
 203 |   .weak TAL_0_Handler
 204 |   .thumb_set TAL_0_Handler,Dummy_Handler
 205 | 
 206 |   .weak TAL_1_Handler
 207 |   .thumb_set TAL_1_Handler,Dummy_Handler
 208 | 
 209 |   .weak RAMECC_Handler
 210 |   .thumb_set RAMECC_Handler,Dummy_Handler
 211 | 
 212 |   .weak SERCOM0_0_Handler
 213 |   .thumb_set SERCOM0_0_Handler,Dummy_Handler
 214 | 
 215 |   .weak SERCOM0_1_Handler
 216 |   .thumb_set SERCOM0_1_Handler,Dummy_Handler
 217 | 
 218 |   .weak SERCOM0_2_Handler
 219 |   .thumb_set SERCOM0_2_Handler,Dummy_Handler
 220 | 
 221 |   .weak SERCOM0_3_Handler
 222 |   .thumb_set SERCOM0_3_Handler,Dummy_Handler
 223 | 
 224 |   .weak SERCOM1_0_Handler
 225 |   .thumb_set SERCOM1_0_Handler,Dummy_Handler
 226 | 
 227 |   .weak SERCOM1_1_Handler
 228 |   .thumb_set SERCOM1_1_Handler,Dummy_Handler
 229 | 
 230 |   .weak SERCOM1_2_Handler
 231 |   .thumb_set SERCOM1_2_Handler,Dummy_Handler
 232 | 
 233 |   .weak SERCOM1_3_Handler
 234 |   .thumb_set SERCOM1_3_Handler,Dummy_Handler
 235 | 
 236 |   .weak SERCOM2_0_Handler
 237 |   .thumb_set SERCOM2_0_Handler,Dummy_Handler
 238 | 
 239 |   .weak SERCOM2_1_Handler
 240 |   .thumb_set SERCOM2_1_Handler,Dummy_Handler
 241 | 
 242 |   .weak SERCOM2_2_Handler
 243 |   .thumb_set SERCOM2_2_Handler,Dummy_Handler
 244 | 
 245 |   .weak SERCOM2_3_Handler
 246 |   .thumb_set SERCOM2_3_Handler,Dummy_Handler
 247 | 
 248 |   .weak SERCOM3_0_Handler
 249 |   .thumb_set SERCOM3_0_Handler,Dummy_Handler
 250 | 
 251 |   .weak SERCOM3_1_Handler
 252 |   .thumb_set SERCOM3_1_Handler,Dummy_Handler
 253 | 
 254 |   .weak SERCOM3_2_Handler
 255 |   .thumb_set SERCOM3_2_Handler,Dummy_Handler
 256 | 
 257 |   .weak SERCOM3_3_Handler
 258 |   .thumb_set SERCOM3_3_Handler,Dummy_Handler
 259 | 
 260 |   .weak SERCOM4_0_Handler
 261 |   .thumb_set SERCOM4_0_Handler,Dummy_Handler
 262 | 
 263 |   .weak SERCOM4_1_Handler
 264 |   .thumb_set SERCOM4_1_Handler,Dummy_Handler
 265 | 
 266 |   .weak SERCOM4_2_Handler
 267 |   .thumb_set SERCOM4_2_Handler,Dummy_Handler
 268 | 
 269 |   .weak SERCOM4_3_Handler
 270 |   .thumb_set SERCOM4_3_Handler,Dummy_Handler
 271 | 
 272 |   .weak SERCOM5_0_Handler
 273 |   .thumb_set SERCOM5_0_Handler,Dummy_Handler
 274 | 
 275 |   .weak SERCOM5_1_Handler
 276 |   .thumb_set SERCOM5_1_Handler,Dummy_Handler
 277 | 
 278 |   .weak SERCOM5_2_Handler
 279 |   .thumb_set SERCOM5_2_Handler,Dummy_Handler
 280 | 
 281 |   .weak SERCOM5_3_Handler
 282 |   .thumb_set SERCOM5_3_Handler,Dummy_Handler
 283 | 
 284 |   .weak USB_0_Handler
 285 |   .thumb_set USB_0_Handler,Dummy_Handler
 286 | 
 287 |   .weak USB_1_Handler
 288 |   .thumb_set USB_1_Handler,Dummy_Handler
 289 | 
 290 |   .weak USB_2_Handler
 291 |   .thumb_set USB_2_Handler,Dummy_Handler
 292 | 
 293 |   .weak USB_3_Handler
 294 |   .thumb_set USB_3_Handler,Dummy_Handler
 295 | 
 296 |   .weak TCC0_0_Handler
 297 |   .thumb_set TCC0_0_Handler,Dummy_Handler
 298 | 
 299 |   .weak TCC0_1_Handler
 300 |   .thumb_set TCC0_1_Handler,Dummy_Handler
 301 | 
 302 |   .weak TCC0_2_Handler
 303 |   .thumb_set TCC0_2_Handler,Dummy_Handler
 304 | 
 305 |   .weak TCC0_3_Handler
 306 |   .thumb_set TCC0_3_Handler,Dummy_Handler
 307 | 
 308 |   .weak TCC0_4_Handler
 309 |   .thumb_set TCC0_4_Handler,Dummy_Handler
 310 | 
 311 |   .weak TCC0_5_Handler
 312 |   .thumb_set TCC0_5_Handler,Dummy_Handler
 313 | 
 314 |   .weak TCC0_6_Handler
 315 |   .thumb_set TCC0_6_Handler,Dummy_Handler
 316 | 
 317 |   .weak TCC1_0_Handler
 318 |   .thumb_set TCC1_0_Handler,Dummy_Handler
 319 | 
 320 |   .weak TCC1_1_Handler
 321 |   .thumb_set TCC1_1_Handler,Dummy_Handler
 322 | 
 323 |   .weak TCC1_2_Handler
 324 |   .thumb_set TCC1_2_Handler,Dummy_Handler
 325 | 
 326 |   .weak TCC1_3_Handler
 327 |   .thumb_set TCC1_3_Handler,Dummy_Handler
 328 | 
 329 |   .weak TCC1_4_Handler
 330 |   .thumb_set TCC1_4_Handler,Dummy_Handler
 331 | 
 332 |   .weak TCC2_0_Handler
 333 |   .thumb_set TCC2_0_Handler,Dummy_Handler
 334 | 
 335 |   .weak TCC2_1_Handler
 336 |   .thumb_set TCC2_1_Handler,Dummy_Handler
 337 | 
 338 |   .weak TCC2_2_Handler
 339 |   .thumb_set TCC2_2_Handler,Dummy_Handler
 340 | 
 341 |   .weak TCC2_3_Handler
 342 |   .thumb_set TCC2_3_Handler,Dummy_Handler
 343 | 
 344 |   .weak TCC3_0_Handler
 345 |   .thumb_set TCC3_0_Handler,Dummy_Handler
 346 | 
 347 |   .weak TCC3_1_Handler
 348 |   .thumb_set TCC3_1_Handler,Dummy_Handler
 349 | 
 350 |   .weak TCC3_2_Handler
 351 |   .thumb_set TCC3_2_Handler,Dummy_Handler
 352 | 
 353 |   .weak TCC4_0_Handler
 354 |   .thumb_set TCC4_0_Handler,Dummy_Handler
 355 | 
 356 |   .weak TCC4_1_Handler
 357 |   .thumb_set TCC4_1_Handler,Dummy_Handler
 358 | 
 359 |   .weak TCC4_2_Handler
 360 |   .thumb_set TCC4_2_Handler,Dummy_Handler
 361 | 
 362 |   .weak TC0_Handler
 363 |   .thumb_set TC0_Handler,Dummy_Handler
 364 | 
 365 |   .weak TC1_Handler
 366 |   .thumb_set TC1_Handler,Dummy_Handler
 367 | 
 368 |   .weak TC2_Handler
 369 |   .thumb_set TC2_Handler,Dummy_Handler
 370 | 
 371 |   .weak TC3_Handler
 372 |   .thumb_set TC3_Handler,Dummy_Handler
 373 | 
 374 |   .weak TC4_Handler
 375 |   .thumb_set TC4_Handler,Dummy_Handler
 376 | 
 377 |   .weak TC5_Handler
 378 |   .thumb_set TC5_Handler,Dummy_Handler
 379 | 
 380 |   .weak PDEC_0_Handler
 381 |   .thumb_set PDEC_0_Handler,Dummy_Handler
 382 | 
 383 |   .weak PDEC_1_Handler
 384 |   .thumb_set PDEC_1_Handler,Dummy_Handler
 385 | 
 386 |   .weak PDEC_2_Handler
 387 |   .thumb_set PDEC_2_Handler,Dummy_Handler
 388 | 
 389 |   .weak ADC0_0_Handler
 390 |   .thumb_set ADC0_0_Handler,Dummy_Handler
 391 | 
 392 |   .weak ADC0_1_Handler
 393 |   .thumb_set ADC0_1_Handler,Dummy_Handler
 394 | 
 395 |   .weak ADC1_0_Handler
 396 |   .thumb_set ADC1_0_Handler,Dummy_Handler
 397 | 
 398 |   .weak ADC1_1_Handler
 399 |   .thumb_set ADC1_1_Handler,Dummy_Handler
 400 | 
 401 |   .weak AC_Handler
 402 |   .thumb_set AC_Handler,Dummy_Handler
 403 | 
 404 |   .weak DAC_0_Handler
 405 |   .thumb_set DAC_0_Handler,Dummy_Handler
 406 | 
 407 |   .weak DAC_1_Handler
 408 |   .thumb_set DAC_1_Handler,Dummy_Handler
 409 | 
 410 |   .weak DAC_2_Handler
 411 |   .thumb_set DAC_2_Handler,Dummy_Handler
 412 | 
 413 |   .weak DAC_3_Handler
 414 |   .thumb_set DAC_3_Handler,Dummy_Handler
 415 | 
 416 |   .weak DAC_4_Handler
 417 |   .thumb_set DAC_4_Handler,Dummy_Handler
 418 | 
 419 |   .weak I2S_Handler
 420 |   .thumb_set I2S_Handler,Dummy_Handler
 421 | 
 422 |   .weak PCC_Handler
 423 |   .thumb_set PCC_Handler,Dummy_Handler
 424 | 
 425 |   .weak AES_Handler
 426 |   .thumb_set AES_Handler,Dummy_Handler
 427 | 
 428 |   .weak TRNG_Handler
 429 |   .thumb_set TRNG_Handler,Dummy_Handler
 430 | 
 431 |   .weak ICM_Handler
 432 |   .thumb_set ICM_Handler,Dummy_Handler
 433 | 
 434 |   .weak QSPI_Handler
 435 |   .thumb_set QSPI_Handler,Dummy_Handler
 436 | 
 437 |   .weak SDHC0_Handler
 438 |   .thumb_set SDHC0_Handler,Dummy_Handler
 439 | 
 440 | #else
 441 | 
 442 |   .thumb_func
 443 |   .weak PM_Handler
 444 | PM_Handler:
 445 |   b .
 446 | 
 447 |   .thumb_func
 448 |   .weak MCLK_Handler
 449 | MCLK_Handler:
 450 |   b .
 451 | 
 452 |   .thumb_func
 453 |   .weak OSCCTRL_0_Handler
 454 | OSCCTRL_0_Handler:
 455 |   b .
 456 | 
 457 |   .thumb_func
 458 |   .weak OSCCTRL_1_Handler
 459 | OSCCTRL_1_Handler:
 460 |   b .
 461 | 
 462 |   .thumb_func
 463 |   .weak OSCCTRL_2_Handler
 464 | OSCCTRL_2_Handler:
 465 |   b .
 466 | 
 467 |   .thumb_func
 468 |   .weak OSCCTRL_3_Handler
 469 | OSCCTRL_3_Handler:
 470 |   b .
 471 | 
 472 |   .thumb_func
 473 |   .weak OSCCTRL_4_Handler
 474 | OSCCTRL_4_Handler:
 475 |   b .
 476 | 
 477 |   .thumb_func
 478 |   .weak OSC32KCTRL_Handler
 479 | OSC32KCTRL_Handler:
 480 |   b .
 481 | 
 482 |   .thumb_func
 483 |   .weak SUPC_0_Handler
 484 | SUPC_0_Handler:
 485 |   b .
 486 | 
 487 |   .thumb_func
 488 |   .weak SUPC_1_Handler
 489 | SUPC_1_Handler:
 490 |   b .
 491 | 
 492 |   .thumb_func
 493 |   .weak WDT_Handler
 494 | WDT_Handler:
 495 |   b .
 496 | 
 497 |   .thumb_func
 498 |   .weak RTC_Handler
 499 | RTC_Handler:
 500 |   b .
 501 | 
 502 |   .thumb_func
 503 |   .weak EIC_0_Handler
 504 | EIC_0_Handler:
 505 |   b .
 506 | 
 507 |   .thumb_func
 508 |   .weak EIC_1_Handler
 509 | EIC_1_Handler:
 510 |   b .
 511 | 
 512 |   .thumb_func
 513 |   .weak EIC_2_Handler
 514 | EIC_2_Handler:
 515 |   b .
 516 | 
 517 |   .thumb_func
 518 |   .weak EIC_3_Handler
 519 | EIC_3_Handler:
 520 |   b .
 521 | 
 522 |   .thumb_func
 523 |   .weak EIC_4_Handler
 524 | EIC_4_Handler:
 525 |   b .
 526 | 
 527 |   .thumb_func
 528 |   .weak EIC_5_Handler
 529 | EIC_5_Handler:
 530 |   b .
 531 | 
 532 |   .thumb_func
 533 |   .weak EIC_6_Handler
 534 | EIC_6_Handler:
 535 |   b .
 536 | 
 537 |   .thumb_func
 538 |   .weak EIC_7_Handler
 539 | EIC_7_Handler:
 540 |   b .
 541 | 
 542 |   .thumb_func
 543 |   .weak EIC_8_Handler
 544 | EIC_8_Handler:
 545 |   b .
 546 | 
 547 |   .thumb_func
 548 |   .weak EIC_9_Handler
 549 | EIC_9_Handler:
 550 |   b .
 551 | 
 552 |   .thumb_func
 553 |   .weak EIC_10_Handler
 554 | EIC_10_Handler:
 555 |   b .
 556 | 
 557 |   .thumb_func
 558 |   .weak EIC_11_Handler
 559 | EIC_11_Handler:
 560 |   b .
 561 | 
 562 |   .thumb_func
 563 |   .weak EIC_12_Handler
 564 | EIC_12_Handler:
 565 |   b .
 566 | 
 567 |   .thumb_func
 568 |   .weak EIC_13_Handler
 569 | EIC_13_Handler:
 570 |   b .
 571 | 
 572 |   .thumb_func
 573 |   .weak EIC_14_Handler
 574 | EIC_14_Handler:
 575 |   b .
 576 | 
 577 |   .thumb_func
 578 |   .weak EIC_15_Handler
 579 | EIC_15_Handler:
 580 |   b .
 581 | 
 582 |   .thumb_func
 583 |   .weak FREQM_Handler
 584 | FREQM_Handler:
 585 |   b .
 586 | 
 587 |   .thumb_func
 588 |   .weak NVMCTRL_0_Handler
 589 | NVMCTRL_0_Handler:
 590 |   b .
 591 | 
 592 |   .thumb_func
 593 |   .weak NVMCTRL_1_Handler
 594 | NVMCTRL_1_Handler:
 595 |   b .
 596 | 
 597 |   .thumb_func
 598 |   .weak DMAC_0_Handler
 599 | DMAC_0_Handler:
 600 |   b .
 601 | 
 602 |   .thumb_func
 603 |   .weak DMAC_1_Handler
 604 | DMAC_1_Handler:
 605 |   b .
 606 | 
 607 |   .thumb_func
 608 |   .weak DMAC_2_Handler
 609 | DMAC_2_Handler:
 610 |   b .
 611 | 
 612 |   .thumb_func
 613 |   .weak DMAC_3_Handler
 614 | DMAC_3_Handler:
 615 |   b .
 616 | 
 617 |   .thumb_func
 618 |   .weak DMAC_4_Handler
 619 | DMAC_4_Handler:
 620 |   b .
 621 | 
 622 |   .thumb_func
 623 |   .weak EVSYS_0_Handler
 624 | EVSYS_0_Handler:
 625 |   b .
 626 | 
 627 |   .thumb_func
 628 |   .weak EVSYS_1_Handler
 629 | EVSYS_1_Handler:
 630 |   b .
 631 | 
 632 |   .thumb_func
 633 |   .weak EVSYS_2_Handler
 634 | EVSYS_2_Handler:
 635 |   b .
 636 | 
 637 |   .thumb_func
 638 |   .weak EVSYS_3_Handler
 639 | EVSYS_3_Handler:
 640 |   b .
 641 | 
 642 |   .thumb_func
 643 |   .weak EVSYS_4_Handler
 644 | EVSYS_4_Handler:
 645 |   b .
 646 | 
 647 |   .thumb_func
 648 |   .weak PAC_Handler
 649 | PAC_Handler:
 650 |   b .
 651 | 
 652 |   .thumb_func
 653 |   .weak TAL_0_Handler
 654 | TAL_0_Handler:
 655 |   b .
 656 | 
 657 |   .thumb_func
 658 |   .weak TAL_1_Handler
 659 | TAL_1_Handler:
 660 |   b .
 661 | 
 662 |   .thumb_func
 663 |   .weak RAMECC_Handler
 664 | RAMECC_Handler:
 665 |   b .
 666 | 
 667 |   .thumb_func
 668 |   .weak SERCOM0_0_Handler
 669 | SERCOM0_0_Handler:
 670 |   b .
 671 | 
 672 |   .thumb_func
 673 |   .weak SERCOM0_1_Handler
 674 | SERCOM0_1_Handler:
 675 |   b .
 676 | 
 677 |   .thumb_func
 678 |   .weak SERCOM0_2_Handler
 679 | SERCOM0_2_Handler:
 680 |   b .
 681 | 
 682 |   .thumb_func
 683 |   .weak SERCOM0_3_Handler
 684 | SERCOM0_3_Handler:
 685 |   b .
 686 | 
 687 |   .thumb_func
 688 |   .weak SERCOM1_0_Handler
 689 | SERCOM1_0_Handler:
 690 |   b .
 691 | 
 692 |   .thumb_func
 693 |   .weak SERCOM1_1_Handler
 694 | SERCOM1_1_Handler:
 695 |   b .
 696 | 
 697 |   .thumb_func
 698 |   .weak SERCOM1_2_Handler
 699 | SERCOM1_2_Handler:
 700 |   b .
 701 | 
 702 |   .thumb_func
 703 |   .weak SERCOM1_3_Handler
 704 | SERCOM1_3_Handler:
 705 |   b .
 706 | 
 707 |   .thumb_func
 708 |   .weak SERCOM2_0_Handler
 709 | SERCOM2_0_Handler:
 710 |   b .
 711 | 
 712 |   .thumb_func
 713 |   .weak SERCOM2_1_Handler
 714 | SERCOM2_1_Handler:
 715 |   b .
 716 | 
 717 |   .thumb_func
 718 |   .weak SERCOM2_2_Handler
 719 | SERCOM2_2_Handler:
 720 |   b .
 721 | 
 722 |   .thumb_func
 723 |   .weak SERCOM2_3_Handler
 724 | SERCOM2_3_Handler:
 725 |   b .
 726 | 
 727 |   .thumb_func
 728 |   .weak SERCOM3_0_Handler
 729 | SERCOM3_0_Handler:
 730 |   b .
 731 | 
 732 |   .thumb_func
 733 |   .weak SERCOM3_1_Handler
 734 | SERCOM3_1_Handler:
 735 |   b .
 736 | 
 737 |   .thumb_func
 738 |   .weak SERCOM3_2_Handler
 739 | SERCOM3_2_Handler:
 740 |   b .
 741 | 
 742 |   .thumb_func
 743 |   .weak SERCOM3_3_Handler
 744 | SERCOM3_3_Handler:
 745 |   b .
 746 | 
 747 |   .thumb_func
 748 |   .weak SERCOM4_0_Handler
 749 | SERCOM4_0_Handler:
 750 |   b .
 751 | 
 752 |   .thumb_func
 753 |   .weak SERCOM4_1_Handler
 754 | SERCOM4_1_Handler:
 755 |   b .
 756 | 
 757 |   .thumb_func
 758 |   .weak SERCOM4_2_Handler
 759 | SERCOM4_2_Handler:
 760 |   b .
 761 | 
 762 |   .thumb_func
 763 |   .weak SERCOM4_3_Handler
 764 | SERCOM4_3_Handler:
 765 |   b .
 766 | 
 767 |   .thumb_func
 768 |   .weak SERCOM5_0_Handler
 769 | SERCOM5_0_Handler:
 770 |   b .
 771 | 
 772 |   .thumb_func
 773 |   .weak SERCOM5_1_Handler
 774 | SERCOM5_1_Handler:
 775 |   b .
 776 | 
 777 |   .thumb_func
 778 |   .weak SERCOM5_2_Handler
 779 | SERCOM5_2_Handler:
 780 |   b .
 781 | 
 782 |   .thumb_func
 783 |   .weak SERCOM5_3_Handler
 784 | SERCOM5_3_Handler:
 785 |   b .
 786 | 
 787 |   .thumb_func
 788 |   .weak USB_0_Handler
 789 | USB_0_Handler:
 790 |   b .
 791 | 
 792 |   .thumb_func
 793 |   .weak USB_1_Handler
 794 | USB_1_Handler:
 795 |   b .
 796 | 
 797 |   .thumb_func
 798 |   .weak USB_2_Handler
 799 | USB_2_Handler:
 800 |   b .
 801 | 
 802 |   .thumb_func
 803 |   .weak USB_3_Handler
 804 | USB_3_Handler:
 805 |   b .
 806 | 
 807 |   .thumb_func
 808 |   .weak TCC0_0_Handler
 809 | TCC0_0_Handler:
 810 |   b .
 811 | 
 812 |   .thumb_func
 813 |   .weak TCC0_1_Handler
 814 | TCC0_1_Handler:
 815 |   b .
 816 | 
 817 |   .thumb_func
 818 |   .weak TCC0_2_Handler
 819 | TCC0_2_Handler:
 820 |   b .
 821 | 
 822 |   .thumb_func
 823 |   .weak TCC0_3_Handler
 824 | TCC0_3_Handler:
 825 |   b .
 826 | 
 827 |   .thumb_func
 828 |   .weak TCC0_4_Handler
 829 | TCC0_4_Handler:
 830 |   b .
 831 | 
 832 |   .thumb_func
 833 |   .weak TCC0_5_Handler
 834 | TCC0_5_Handler:
 835 |   b .
 836 | 
 837 |   .thumb_func
 838 |   .weak TCC0_6_Handler
 839 | TCC0_6_Handler:
 840 |   b .
 841 | 
 842 |   .thumb_func
 843 |   .weak TCC1_0_Handler
 844 | TCC1_0_Handler:
 845 |   b .
 846 | 
 847 |   .thumb_func
 848 |   .weak TCC1_1_Handler
 849 | TCC1_1_Handler:
 850 |   b .
 851 | 
 852 |   .thumb_func
 853 |   .weak TCC1_2_Handler
 854 | TCC1_2_Handler:
 855 |   b .
 856 | 
 857 |   .thumb_func
 858 |   .weak TCC1_3_Handler
 859 | TCC1_3_Handler:
 860 |   b .
 861 | 
 862 |   .thumb_func
 863 |   .weak TCC1_4_Handler
 864 | TCC1_4_Handler:
 865 |   b .
 866 | 
 867 |   .thumb_func
 868 |   .weak TCC2_0_Handler
 869 | TCC2_0_Handler:
 870 |   b .
 871 | 
 872 |   .thumb_func
 873 |   .weak TCC2_1_Handler
 874 | TCC2_1_Handler:
 875 |   b .
 876 | 
 877 |   .thumb_func
 878 |   .weak TCC2_2_Handler
 879 | TCC2_2_Handler:
 880 |   b .
 881 | 
 882 |   .thumb_func
 883 |   .weak TCC2_3_Handler
 884 | TCC2_3_Handler:
 885 |   b .
 886 | 
 887 |   .thumb_func
 888 |   .weak TCC3_0_Handler
 889 | TCC3_0_Handler:
 890 |   b .
 891 | 
 892 |   .thumb_func
 893 |   .weak TCC3_1_Handler
 894 | TCC3_1_Handler:
 895 |   b .
 896 | 
 897 |   .thumb_func
 898 |   .weak TCC3_2_Handler
 899 | TCC3_2_Handler:
 900 |   b .
 901 | 
 902 |   .thumb_func
 903 |   .weak TCC4_0_Handler
 904 | TCC4_0_Handler:
 905 |   b .
 906 | 
 907 |   .thumb_func
 908 |   .weak TCC4_1_Handler
 909 | TCC4_1_Handler:
 910 |   b .
 911 | 
 912 |   .thumb_func
 913 |   .weak TCC4_2_Handler
 914 | TCC4_2_Handler:
 915 |   b .
 916 | 
 917 |   .thumb_func
 918 |   .weak TC0_Handler
 919 | TC0_Handler:
 920 |   b .
 921 | 
 922 |   .thumb_func
 923 |   .weak TC1_Handler
 924 | TC1_Handler:
 925 |   b .
 926 | 
 927 |   .thumb_func
 928 |   .weak TC2_Handler
 929 | TC2_Handler:
 930 |   b .
 931 | 
 932 |   .thumb_func
 933 |   .weak TC3_Handler
 934 | TC3_Handler:
 935 |   b .
 936 | 
 937 |   .thumb_func
 938 |   .weak TC4_Handler
 939 | TC4_Handler:
 940 |   b .
 941 | 
 942 |   .thumb_func
 943 |   .weak TC5_Handler
 944 | TC5_Handler:
 945 |   b .
 946 | 
 947 |   .thumb_func
 948 |   .weak PDEC_0_Handler
 949 | PDEC_0_Handler:
 950 |   b .
 951 | 
 952 |   .thumb_func
 953 |   .weak PDEC_1_Handler
 954 | PDEC_1_Handler:
 955 |   b .
 956 | 
 957 |   .thumb_func
 958 |   .weak PDEC_2_Handler
 959 | PDEC_2_Handler:
 960 |   b .
 961 | 
 962 |   .thumb_func
 963 |   .weak ADC0_0_Handler
 964 | ADC0_0_Handler:
 965 |   b .
 966 | 
 967 |   .thumb_func
 968 |   .weak ADC0_1_Handler
 969 | ADC0_1_Handler:
 970 |   b .
 971 | 
 972 |   .thumb_func
 973 |   .weak ADC1_0_Handler
 974 | ADC1_0_Handler:
 975 |   b .
 976 | 
 977 |   .thumb_func
 978 |   .weak ADC1_1_Handler
 979 | ADC1_1_Handler:
 980 |   b .
 981 | 
 982 |   .thumb_func
 983 |   .weak AC_Handler
 984 | AC_Handler:
 985 |   b .
 986 | 
 987 |   .thumb_func
 988 |   .weak DAC_0_Handler
 989 | DAC_0_Handler:
 990 |   b .
 991 | 
 992 |   .thumb_func
 993 |   .weak DAC_1_Handler
 994 | DAC_1_Handler:
 995 |   b .
 996 | 
 997 |   .thumb_func
 998 |   .weak DAC_2_Handler
 999 | DAC_2_Handler:
1000 |   b .
1001 | 
1002 |   .thumb_func
1003 |   .weak DAC_3_Handler
1004 | DAC_3_Handler:
1005 |   b .
1006 | 
1007 |   .thumb_func
1008 |   .weak DAC_4_Handler
1009 | DAC_4_Handler:
1010 |   b .
1011 | 
1012 |   .thumb_func
1013 |   .weak I2S_Handler
1014 | I2S_Handler:
1015 |   b .
1016 | 
1017 |   .thumb_func
1018 |   .weak PCC_Handler
1019 | PCC_Handler:
1020 |   b .
1021 | 
1022 |   .thumb_func
1023 |   .weak AES_Handler
1024 | AES_Handler:
1025 |   b .
1026 | 
1027 |   .thumb_func
1028 |   .weak TRNG_Handler
1029 | TRNG_Handler:
1030 |   b .
1031 | 
1032 |   .thumb_func
1033 |   .weak ICM_Handler
1034 | ICM_Handler:
1035 |   b .
1036 | 
1037 |   .thumb_func
1038 |   .weak QSPI_Handler
1039 | QSPI_Handler:
1040 |   b .
1041 | 
1042 |   .thumb_func
1043 |   .weak SDHC0_Handler
1044 | SDHC0_Handler:
1045 |   b .
1046 | 
1047 | #endif
1048 | 
1049 | /*****************************************************************************
1050 |  * Vector Table                                                              *
1051 |  *****************************************************************************/
1052 | 
1053 |   .section .vectors, "ax"
1054 |   .align 0
1055 |   .global _vectors
1056 |   .extern __stack_end__
1057 | #ifdef STARTUP_FROM_RESET
1058 |   .extern Reset_Handler
1059 | #endif
1060 | 
1061 | _vectors:
1062 |   .word __stack_end__
1063 | #ifdef STARTUP_FROM_RESET
1064 |   .word Reset_Handler
1065 | #else
1066 |   .word Reset_Wait
1067 | #endif
1068 |   .word NMI_Handler
1069 |   .word HardFault_Handler
1070 |   .word 0 /* Reserved */
1071 |   .word 0 /* Reserved */
1072 |   .word 0 /* Reserved */
1073 |   .word 0 /* Reserved */
1074 |   .word 0 /* Reserved */
1075 |   .word 0 /* Reserved */
1076 |   .word 0 /* Reserved */
1077 |   .word SVC_Handler
1078 |   .word 0 /* Reserved */
1079 |   .word 0 /* Reserved */
1080 |   .word PendSV_Handler
1081 |   .word SysTick_Handler
1082 |   .word PM_Handler
1083 |   .word MCLK_Handler
1084 |   .word OSCCTRL_0_Handler
1085 |   .word OSCCTRL_1_Handler
1086 |   .word OSCCTRL_2_Handler
1087 |   .word OSCCTRL_3_Handler
1088 |   .word OSCCTRL_4_Handler
1089 |   .word OSC32KCTRL_Handler
1090 |   .word SUPC_0_Handler
1091 |   .word SUPC_1_Handler
1092 |   .word WDT_Handler
1093 |   .word RTC_Handler
1094 |   .word EIC_0_Handler
1095 |   .word EIC_1_Handler
1096 |   .word EIC_2_Handler
1097 |   .word EIC_3_Handler
1098 |   .word EIC_4_Handler
1099 |   .word EIC_5_Handler
1100 |   .word EIC_6_Handler
1101 |   .word EIC_7_Handler
1102 |   .word EIC_8_Handler
1103 |   .word EIC_9_Handler
1104 |   .word EIC_10_Handler
1105 |   .word EIC_11_Handler
1106 |   .word EIC_12_Handler
1107 |   .word EIC_13_Handler
1108 |   .word EIC_14_Handler
1109 |   .word EIC_15_Handler
1110 |   .word FREQM_Handler
1111 |   .word NVMCTRL_0_Handler
1112 |   .word NVMCTRL_1_Handler
1113 |   .word DMAC_0_Handler
1114 |   .word DMAC_1_Handler
1115 |   .word DMAC_2_Handler
1116 |   .word DMAC_3_Handler
1117 |   .word DMAC_4_Handler
1118 |   .word EVSYS_0_Handler
1119 |   .word EVSYS_1_Handler
1120 |   .word EVSYS_2_Handler
1121 |   .word EVSYS_3_Handler
1122 |   .word EVSYS_4_Handler
1123 |   .word PAC_Handler
1124 |   .word TAL_0_Handler
1125 |   .word TAL_1_Handler
1126 |   .word Dummy_Handler /* Reserved */
1127 |   .word RAMECC_Handler
1128 |   .word SERCOM0_0_Handler
1129 |   .word SERCOM0_1_Handler
1130 |   .word SERCOM0_2_Handler
1131 |   .word SERCOM0_3_Handler
1132 |   .word SERCOM1_0_Handler
1133 |   .word SERCOM1_1_Handler
1134 |   .word SERCOM1_2_Handler
1135 |   .word SERCOM1_3_Handler
1136 |   .word SERCOM2_0_Handler
1137 |   .word SERCOM2_1_Handler
1138 |   .word SERCOM2_2_Handler
1139 |   .word SERCOM2_3_Handler
1140 |   .word SERCOM3_0_Handler
1141 |   .word SERCOM3_1_Handler
1142 |   .word SERCOM3_2_Handler
1143 |   .word SERCOM3_3_Handler
1144 |   .word SERCOM4_0_Handler
1145 |   .word SERCOM4_1_Handler
1146 |   .word SERCOM4_2_Handler
1147 |   .word SERCOM4_3_Handler
1148 |   .word SERCOM5_0_Handler
1149 |   .word SERCOM5_1_Handler
1150 |   .word SERCOM5_2_Handler
1151 |   .word SERCOM5_3_Handler
1152 |   .word Dummy_Handler /* Reserved */
1153 |   .word Dummy_Handler /* Reserved */
1154 |   .word Dummy_Handler /* Reserved */
1155 |   .word Dummy_Handler /* Reserved */
1156 |   .word Dummy_Handler /* Reserved */
1157 |   .word Dummy_Handler /* Reserved */
1158 |   .word Dummy_Handler /* Reserved */
1159 |   .word Dummy_Handler /* Reserved */
1160 |   .word Dummy_Handler /* Reserved */
1161 |   .word Dummy_Handler /* Reserved */
1162 |   .word USB_0_Handler
1163 |   .word USB_1_Handler
1164 |   .word USB_2_Handler
1165 |   .word USB_3_Handler
1166 |   .word Dummy_Handler /* Reserved */
1167 |   .word TCC0_0_Handler
1168 |   .word TCC0_1_Handler
1169 |   .word TCC0_2_Handler
1170 |   .word TCC0_3_Handler
1171 |   .word TCC0_4_Handler
1172 |   .word TCC0_5_Handler
1173 |   .word TCC0_6_Handler
1174 |   .word TCC1_0_Handler
1175 |   .word TCC1_1_Handler
1176 |   .word TCC1_2_Handler
1177 |   .word TCC1_3_Handler
1178 |   .word TCC1_4_Handler
1179 |   .word TCC2_0_Handler
1180 |   .word TCC2_1_Handler
1181 |   .word TCC2_2_Handler
1182 |   .word TCC2_3_Handler
1183 |   .word TCC3_0_Handler
1184 |   .word TCC3_1_Handler
1185 |   .word TCC3_2_Handler
1186 |   .word TCC4_0_Handler
1187 |   .word TCC4_1_Handler
1188 |   .word TCC4_2_Handler
1189 |   .word TC0_Handler
1190 |   .word TC1_Handler
1191 |   .word TC2_Handler
1192 |   .word TC3_Handler
1193 |   .word TC4_Handler
1194 |   .word TC5_Handler
1195 |   .word Dummy_Handler /* Reserved */
1196 |   .word Dummy_Handler /* Reserved */
1197 |   .word PDEC_0_Handler
1198 |   .word PDEC_1_Handler
1199 |   .word PDEC_2_Handler
1200 |   .word ADC0_0_Handler
1201 |   .word ADC0_1_Handler
1202 |   .word ADC1_0_Handler
1203 |   .word ADC1_1_Handler
1204 |   .word AC_Handler
1205 |   .word DAC_0_Handler
1206 |   .word DAC_1_Handler
1207 |   .word DAC_2_Handler
1208 |   .word DAC_3_Handler
1209 |   .word DAC_4_Handler
1210 |   .word I2S_Handler
1211 |   .word PCC_Handler
1212 |   .word AES_Handler
1213 |   .word TRNG_Handler
1214 |   .word ICM_Handler
1215 |   .word Dummy_Handler /* Reserved */
1216 |   .word QSPI_Handler
1217 |   .word SDHC0_Handler
1218 | _vectors_end:
1219 | 
1220 | #ifdef VECTORS_IN_RAM
1221 |   .section .vectors_ram, "ax"
1222 |   .align 0
1223 |   .global _vectors_ram
1224 | 
1225 | _vectors_ram:
1226 |   .space _vectors_end - _vectors, 0
1227 | #endif
1228 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/SAMD51_Startup.s:
--------------------------------------------------------------------------------
  1 | /*****************************************************************************
  2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
  3 |  *            Solutions for real time microcontroller applications           *
  4 |  *****************************************************************************
  5 |  *                                                                           *
  6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
  7 |  *                                                                           *
  8 |  *           Internet: www.segger.com   Support: support@segger.com          *
  9 |  *                                                                           *
 10 |  *****************************************************************************/
 11 | 
 12 | /*****************************************************************************
 13 |  *                         Preprocessor Definitions                          *
 14 |  *                         ------------------------                          *
 15 |  * NO_FPU_ENABLE                                                             *
 16 |  *                                                                           *
 17 |  *   If defined, FPU will not be enabled.                                    *
 18 |  *                                                                           *
 19 |  * NO_STACK_INIT                                                             *
 20 |  *                                                                           *
 21 |  *   If defined, the stack pointer will not be initialised.                  *
 22 |  *                                                                           *
 23 |  * NO_SYSTEM_INIT                                                            *
 24 |  *                                                                           *
 25 |  *   If defined, the SystemInit() function will not be called. By default    *
 26 |  *   SystemInit() is called after reset to enable the clocks and memories to *
 27 |  *   be initialised prior to any C startup initialisation.                   *
 28 |  *                                                                           *
 29 |  * NO_VTOR_CONFIG                                                            *
 30 |  *                                                                           *
 31 |  *   If defined, the vector table offset register will not be configured.    *
 32 |  *                                                                           *
 33 |  * MEMORY_INIT                                                               *
 34 |  *                                                                           *
 35 |  *   If defined, the MemoryInit() function will be called. By default        *
 36 |  *   MemoryInit() is called after SystemInit() to enable an external memory  *
 37 |  *   controller.                                                             *
 38 |  *                                                                           *
 39 |  * STACK_INIT_VAL                                                            *
 40 |  *                                                                           *
 41 |  *   If defined, specifies the initial stack pointer value. If undefined,    *
 42 |  *   the stack pointer will be initialised to point to the end of the        *
 43 |  *   RAM segment.                                                            *
 44 |  *                                                                           *
 45 |  * VECTORS_IN_RAM                                                            *
 46 |  *                                                                           *
 47 |  *   If defined, the exception vectors will be copied from Flash to RAM.     *
 48 |  *                                                                           *
 49 |  *****************************************************************************/
 50 | 
 51 |   .syntax unified
 52 | 
 53 |   .global Reset_Handler
 54 |   .extern _vectors
 55 | 
 56 |   .section .init, "ax"
 57 |   .thumb_func
 58 | 
 59 |   .equ VTOR_REG, 0xE000ED08
 60 |   .equ FPU_CPACR_REG, 0xE000ED88
 61 | 
 62 | #ifndef STACK_INIT_VAL
 63 | #define STACK_INIT_VAL __RAM_segment_end__
 64 | #endif
 65 | 
 66 | Reset_Handler:
 67 | #ifndef NO_STACK_INIT
 68 |   /* Initialise main stack */
 69 |   ldr r0, =STACK_INIT_VAL
 70 |   bic r0, #0x7
 71 |   mov sp, r0
 72 | #endif
 73 | 
 74 | #ifndef NO_SYSTEM_INIT
 75 |   /* Initialise system */
 76 |   ldr r0, =SystemInit
 77 |   blx r0
 78 |   .pushsection .init_array, "aw", %init_array
 79 |   .word SystemCoreClockUpdate
 80 |   .popsection
 81 | #endif
 82 | 
 83 | #ifdef MEMORY_INIT
 84 |   ldr r0, =MemoryInit
 85 |   blx r0
 86 | #endif
 87 | 
 88 | #ifdef VECTORS_IN_RAM
 89 |   /* Copy exception vectors into RAM */
 90 |   ldr r0, =__vectors_start__
 91 |   ldr r1, =__vectors_end__
 92 |   ldr r2, =__vectors_ram_start__
 93 | 1:
 94 |   cmp r0, r1
 95 |   beq 2f
 96 |   ldr r3, [r0]
 97 |   str r3, [r2]
 98 |   adds r0, r0, #4
 99 |   adds r2, r2, #4
100 |   b 1b
101 | 2:
102 | #endif
103 | 
104 | #ifndef NO_VTOR_CONFIG
105 |   /* Configure vector table offset register */
106 |   ldr r0, =VTOR_REG
107 | #ifdef VECTORS_IN_RAM
108 |   ldr r1, =_vectors_ram
109 | #else
110 |   ldr r1, =_vectors
111 | #endif
112 |   str r1, [r0]
113 | #endif
114 | 
115 | #if (defined(__ARM_ARCH_FPV4_SP_D16__) || defined(__ARM_ARCH_FPV5_D16__)) && !defined(NO_FPU_ENABLE)
116 |   /* Enable FPU */
117 |   ldr r0, =FPU_CPACR_REG
118 |   ldr r1, [r0]
119 |   orr r1, r1, #(0xF << 20)
120 |   str r1, [r0]
121 |   dsb
122 |   isb
123 | #endif
124 | 
125 |   /* Jump to program start */
126 |   b _start
127 | 
128 | 
129 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/SAMD51_Target.js:
--------------------------------------------------------------------------------
 1 | /*****************************************************************************
 2 |  *                   SEGGER Microcontroller GmbH & Co. KG                    *
 3 |  *            Solutions for real time microcontroller applications           *
 4 |  *****************************************************************************
 5 |  *                                                                           *
 6 |  *               (c) 2017 SEGGER Microcontroller GmbH & Co. KG               *
 7 |  *                                                                           *
 8 |  *           Internet: www.segger.com   Support: support@segger.com          *
 9 |  *                                                                           *
10 |  *****************************************************************************/
11 | 
12 | function Reset() {
13 |   TargetInterface.resetAndStop();
14 | }
15 | 
16 | function EnableTrace(traceInterfaceType) {
17 |   // TODO: Enable trace
18 | }
19 | 
20 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/flash_placement.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     
 5 |     
 6 |     
 7 |     
 8 |     
 9 |     
10 |     
11 |     
12 |     
13 |     
14 |     
15 |   
16 |   
17 |     
18 |     
19 |     
20 |     
21 |     
22 |     
23 |     
24 |     
25 |     
26 |     
27 |   
28 |   
29 |     
30 |     
31 |     
32 |   
33 |   
34 |     
35 |     
36 |   
37 | 
38 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/samd51.emProject:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 |   
  4 |     
 37 |     
 43 |     
 44 |       
 45 |         
 46 |         
 47 |           
 48 |         
 49 |       
 50 |       
 51 |         
 52 |           
 53 |             
 54 |               
 55 |                 
 56 |                   
 57 |                 
 58 |                 
 59 |                   
 60 |                     
 61 |                   
 62 |                   
 63 |                     
 64 |                   
 65 |                   
 66 |                     
 67 |                   
 68 |                   
 69 |                     
 70 |                   
 71 |                   
 72 |                     
 73 |                   
 74 |                 
 75 |               
 76 |             
 77 |           
 78 |         
 79 |       
 80 |     
 81 |     
 82 |     
 88 |     
 89 |       
 90 |       
 91 |       
 92 |       
 93 |       
 94 |       
 95 |       
 96 |     
 97 |     
103 |     
104 |       
105 |         
106 |           
107 |             
108 |             
109 |             
110 |             
111 |             
112 |             
113 |             
114 |             
115 |             
116 |             
117 |             
118 |             
119 |             
120 |             
121 |             
122 |             
123 |             
124 |           
125 |           
126 |             
127 |               
128 |                 
129 |                 
130 |               
131 |             
132 |             
133 |               
134 |             
135 |           
136 |           
137 |           
138 |           
139 |           
140 |         
141 |         
142 |       
143 |     
144 |   
145 |   
146 | 
147 | 
--------------------------------------------------------------------------------
/demo/ses/samd51/thumb_crt0.s:
--------------------------------------------------------------------------------
  1 | // **********************************************************************
  2 | // *                    SEGGER Microcontroller GmbH                     *
  3 | // *                        The Embedded Experts                        *
  4 | // **********************************************************************
  5 | // *                                                                    *
  6 | // *            (c) 2014 - 2018 SEGGER Microcontroller GmbH             *
  7 | // *            (c) 2001 - 2018 Rowley Associates Limited               *
  8 | // *                                                                    *
  9 | // *           www.segger.com     Support: support@segger.com           *
 10 | // *                                                                    *
 11 | // **********************************************************************
 12 | // *                                                                    *
 13 | // * All rights reserved.                                               *
 14 | // *                                                                    *
 15 | // * Redistribution and use in source and binary forms, with or         *
 16 | // * without modification, are permitted provided that the following    *
 17 | // * conditions are met:                                                *
 18 | // *                                                                    *
 19 | // * - Redistributions of source code must retain the above copyright   *
 20 | // *   notice, this list of conditions and the following disclaimer.    *
 21 | // *                                                                    *
 22 | // * - Neither the name of SEGGER Microcontroller GmbH                  *
 23 | // *   nor the names of its contributors may be used to endorse or      *
 24 | // *   promote products derived from this software without specific     *
 25 | // *   prior written permission.                                        *
 26 | // *                                                                    *
 27 | // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
 28 | // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
 29 | // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
 30 | // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
 31 | // * DISCLAIMED.                                                        *
 32 | // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
 33 | // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
 34 | // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
 35 | // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
 36 | // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
 37 | // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
 38 | // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
 39 | // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
 40 | // * DAMAGE.                                                            *
 41 | // *                                                                    *
 42 | // **********************************************************************
 43 | //
 44 | //
 45 | //                           Preprocessor Definitions
 46 | //                           ------------------------
 47 | // APP_ENTRY_POINT
 48 | //
 49 | //   Defines the application entry point function, if undefined this setting
 50 | //   defaults to "main".
 51 | //
 52 | // INITIALIZE_STACK
 53 | //
 54 | //   If defined, the contents of the stack will be initialized to a the
 55 | //   value 0xCC.
 56 | //
 57 | // INITIALIZE_SECONDARY_SECTIONS
 58 | //
 59 | //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
 60 | //
 61 | // INITIALIZE_TCM_SECTIONS
 62 | //
 63 | //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
 64 | //   will be initialized.
 65 | //
 66 | // INITIALIZE_USER_SECTIONS
 67 | //
 68 | //   If defined, the function InitializeUserMemorySections will be called prior
 69 | //   to entering main in order to allow the user to initialize any user defined
 70 | //   memory sections.
 71 | //
 72 | // FULL_LIBRARY
 73 | //
 74 | //  If defined then 
 75 | //    - argc, argv are setup by the debug_getargs.
 76 | //    - the exit symbol is defined and executes on return from main.
 77 | //    - the exit symbol calls destructors, atexit functions and then debug_exit.
 78 | //  
 79 | //  If not defined then
 80 | //    - argc and argv are zero.
 81 | //    - the exit symbol is defined, executes on return from main and loops
 82 | //
 83 | 
 84 | #ifndef APP_ENTRY_POINT
 85 | #define APP_ENTRY_POINT main
 86 | #endif
 87 | 
 88 | #ifndef ARGSSPACE
 89 | #define ARGSSPACE 128
 90 | #endif
 91 |   .syntax unified
 92 | 
 93 |   .global _start
 94 |   .extern APP_ENTRY_POINT
 95 |   .global exit
 96 |   .weak exit
 97 | 
 98 | #ifdef INITIALIZE_USER_SECTIONS
 99 |   .extern InitializeUserMemorySections
100 | #endif
101 | 
102 |   .section .init, "ax"
103 |   .code 16
104 |   .balign 2
105 |   .thumb_func
106 | 
107 | _start:
108 |   /* Set up main stack if size > 0 */
109 |   ldr r1, =__stack_end__
110 |   ldr r0, =__stack_start__
111 |   subs r2, r1, r0
112 |   beq 1f
113 | #ifdef __ARM_EABI__
114 |   movs r2, #0x7
115 |   bics r1, r2
116 | #endif
117 |   mov sp, r1
118 | #ifdef INITIALIZE_STACK
119 |   movs r2, #0xCC
120 |   ldr r0, =__stack_start__
121 |   bl memory_set
122 | #endif
123 | 1:
124 | 
125 |   /* Set up process stack if size > 0 */
126 |   ldr r1, =__stack_process_end__
127 |   ldr r0, =__stack_process_start__
128 |   subs r2, r1, r0
129 |   beq 1f
130 | #ifdef __ARM_EABI__
131 |   movs r2, #0x7
132 |   bics r1, r2
133 | #endif
134 |   msr psp, r1
135 |   movs r2, #2
136 |   msr control, r2
137 | #ifdef INITIALIZE_STACK
138 |   movs r2, #0xCC
139 |   bl memory_set
140 | #endif
141 | 1:
142 | 
143 |   /* Copy initialized memory sections into RAM (if necessary). */
144 |   ldr r0, =__data_load_start__
145 |   ldr r1, =__data_start__
146 |   ldr r2, =__data_end__
147 |   bl memory_copy
148 |   ldr r0, =__text_load_start__
149 |   ldr r1, =__text_start__
150 |   ldr r2, =__text_end__
151 |   bl memory_copy
152 |   ldr r0, =__fast_load_start__
153 |   ldr r1, =__fast_start__
154 |   ldr r2, =__fast_end__
155 |   bl memory_copy
156 |   ldr r0, =__ctors_load_start__
157 |   ldr r1, =__ctors_start__
158 |   ldr r2, =__ctors_end__
159 |   bl memory_copy
160 |   ldr r0, =__dtors_load_start__
161 |   ldr r1, =__dtors_start__
162 |   ldr r2, =__dtors_end__
163 |   bl memory_copy
164 |   ldr r0, =__rodata_load_start__
165 |   ldr r1, =__rodata_start__
166 |   ldr r2, =__rodata_end__
167 |   bl memory_copy
168 |   ldr r0, =__tdata_load_start__
169 |   ldr r1, =__tdata_start__
170 |   ldr r2, =__tdata_end__
171 |   bl memory_copy
172 | #ifdef INITIALIZE_SECONDARY_SECTIONS
173 |   ldr r0, =__data2_load_start__
174 |   ldr r1, =__data2_start__
175 |   ldr r2, =__data2_end__
176 |   bl memory_copy
177 |   ldr r0, =__text2_load_start__
178 |   ldr r1, =__text2_start__
179 |   ldr r2, =__text2_end__
180 |   bl memory_copy
181 |   ldr r0, =__rodata2_load_start__
182 |   ldr r1, =__rodata2_start__
183 |   ldr r2, =__rodata2_end__
184 |   bl memory_copy
185 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
186 | #ifdef INITIALIZE_TCM_SECTIONS
187 |   ldr r0, =__data_tcm_load_start__
188 |   ldr r1, =__data_tcm_start__
189 |   ldr r2, =__data_tcm_end__
190 |   bl memory_copy
191 |   ldr r0, =__text_tcm_load_start__
192 |   ldr r1, =__text_tcm_start__
193 |   ldr r2, =__text_tcm_end__
194 |   bl memory_copy
195 |   ldr r0, =__rodata_tcm_load_start__
196 |   ldr r1, =__rodata_tcm_start__
197 |   ldr r2, =__rodata_tcm_end__
198 |   bl memory_copy
199 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
200 | 
201 |   /* Zero the bss. */
202 |   ldr r0, =__bss_start__
203 |   ldr r1, =__bss_end__
204 |   movs r2, #0
205 |   bl memory_set
206 |   ldr r0, =__tbss_start__
207 |   ldr r1, =__tbss_end__
208 |   movs r2, #0
209 |   bl memory_set
210 | #ifdef INITIALIZE_SECONDARY_SECTIONS
211 |   ldr r0, =__bss2_start__
212 |   ldr r1, =__bss2_end__
213 |   mov r2, #0
214 |   bl memory_set
215 | #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
216 | #ifdef INITIALIZE_TCM_SECTIONS
217 |   ldr r0, =__bss_tcm_start__
218 |   ldr r1, =__bss_tcm_end__
219 |   mov r2, #0
220 |   bl memory_set
221 | #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
222 | 
223 |   /* Initialize the heap */
224 |   ldr r0, = __heap_start__
225 |   ldr r1, = __heap_end__
226 |   subs r1, r1, r0
227 |   cmp r1, #8
228 |   blt 1f
229 |   movs r2, #0
230 |   str r2, [r0]
231 |   adds r0, r0, #4
232 |   str r1, [r0]
233 | 1:
234 | 
235 | #ifdef INITIALIZE_USER_SECTIONS
236 |   ldr r2, =InitializeUserMemorySections
237 |   blx r2
238 | #endif
239 | 
240 |   /* Call constructors */
241 |   ldr r0, =__ctors_start__
242 |   ldr r1, =__ctors_end__
243 | ctor_loop:
244 |   cmp r0, r1
245 |   beq ctor_end
246 |   ldr r2, [r0]
247 |   adds r0, #4
248 |   push {r0-r1}  
249 |   blx r2
250 |   pop {r0-r1}
251 |   b ctor_loop
252 | ctor_end:
253 | 
254 |   /* Setup initial call frame */
255 |   movs r0, #0
256 |   mov lr, r0
257 |   mov r12, sp
258 | 
259 |   .type start, function
260 | start:
261 |   /* Jump to application entry point */
262 | #ifdef FULL_LIBRARY
263 |   movs r0, #ARGSSPACE
264 |   ldr r1, =args
265 |   ldr r2, =debug_getargs  
266 |   blx r2
267 |   ldr r1, =args
268 | #else
269 |   movs r0, #0
270 |   movs r1, #0
271 | #endif
272 |   ldr r2, =APP_ENTRY_POINT
273 |   blx r2
274 | 
275 |   .thumb_func
276 | exit:
277 | #ifdef FULL_LIBRARY  
278 |   mov r5, r0 // save the exit parameter/return result
279 | 
280 |   /* Call destructors */
281 |   ldr r0, =__dtors_start__
282 |   ldr r1, =__dtors_end__
283 | dtor_loop:
284 |   cmp r0, r1
285 |   beq dtor_end
286 |   ldr r2, [r0]
287 |   add r0, #4
288 |   push {r0-r1}
289 |   blx r2
290 |   pop {r0-r1}
291 |   b dtor_loop
292 | dtor_end:
293 | 
294 |   /* Call atexit functions */
295 |   ldr r2, =_execute_at_exit_fns  
296 |   blx r2
297 | 
298 |   /* Call debug_exit with return result/exit parameter */
299 |   mov r0, r5
300 |   ldr r2, =debug_exit  
301 |   blx r2
302 | #endif
303 | 
304 |   /* Returned from application entry point, loop forever. */
305 | exit_loop:
306 |   b exit_loop
307 | 
308 |   .thumb_func
309 | memory_copy:
310 |   cmp r0, r1
311 |   beq 2f
312 |   subs r2, r2, r1
313 |   beq 2f
314 | 1:
315 |   ldrb r3, [r0]
316 |   adds r0, r0, #1
317 |   strb r3, [r1]
318 |   adds r1, r1, #1
319 |   subs r2, r2, #1
320 |   bne 1b
321 | 2:
322 |   bx lr
323 | 
324 |   .thumb_func
325 | memory_set:
326 |   cmp r0, r1
327 |   beq 1f
328 |   strb r2, [r0]
329 |   adds r0, r0, #1
330 |   b memory_set
331 | 1:
332 |   bx lr
333 | 
334 |   // default C/C++ library helpers
335 | 
336 | .macro HELPER helper_name
337 |   .section .text.\helper_name, "ax", %progbits
338 |   .balign 2
339 |   .global \helper_name
340 |   .weak \helper_name  
341 | \helper_name:
342 |   .thumb_func
343 | .endm
344 | 
345 | .macro JUMPTO name
346 | #if defined(__thumb__) && !defined(__thumb2__)
347 |   mov r12, r0
348 |   ldr r0, =\name
349 |   push {r0}
350 |   mov r0, r12
351 |   pop {pc}
352 | #else
353 |   b \name
354 | #endif
355 | .endm
356 | 
357 | HELPER __aeabi_read_tp
358 |   ldr r0, =__tbss_start__-8
359 |   bx lr
360 | HELPER abort
361 |   b .
362 | HELPER __assert
363 |   b .
364 | HELPER __aeabi_assert
365 |   b .
366 | HELPER __sync_synchronize
367 |   bx lr
368 | HELPER __getchar
369 |   JUMPTO debug_getchar
370 | HELPER __putchar
371 |   JUMPTO debug_putchar
372 | HELPER __open
373 |   JUMPTO debug_fopen
374 | HELPER __close
375 |   JUMPTO debug_fclose
376 | HELPER __write   
377 |   mov r3, r0
378 |   mov r0, r1
379 |   movs r1, #1  
380 |   JUMPTO debug_fwrite
381 | HELPER __read  
382 |   mov r3, r0
383 |   mov r0, r1
384 |   movs r1, #1 
385 |   JUMPTO debug_fread
386 | HELPER __seek
387 |   push {r4, lr}
388 |   mov r4, r0
389 |   bl debug_fseek
390 |   cmp r0, #0
391 |   bne 1f
392 |   mov r0, r4
393 |   bl debug_ftell
394 |   pop {r4, pc}
395 | 1:
396 |   ldr r0, =-1
397 |   pop {r4, pc}
398 |   // char __user_locale_name_buffer[];
399 |   .section .bss.__user_locale_name_buffer, "aw", %nobits
400 |   .global __user_locale_name_buffer
401 |   .weak __user_locale_name_buffer
402 |   __user_locale_name_buffer:
403 |   .word 0x0
404 | 
405 | #ifdef FULL_LIBRARY
406 |   .bss
407 | args:
408 |   .space ARGSSPACE
409 | #endif
410 | 
411 |   /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
412 |   .section .stack, "wa", %nobits
413 |   .section .stack_process, "wa", %nobits
414 |   .section .heap, "wa", %nobits
415 | 
416 | 
--------------------------------------------------------------------------------
/demo/src/CMakeLists.txt:
--------------------------------------------------------------------------------
 1 | idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
 2 |                     INCLUDE_DIRS "."
 3 |                     REQUIRES freertos soc)
 4 | 
 5 | target_compile_options(${COMPONENT_TARGET} PUBLIC
 6 |   "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
 7 | )
 8 | 
 9 | idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
10 | target_include_directories(${COMPONENT_TARGET} PUBLIC
11 |   "${FREERTOS_ORIG_INCLUDE_PATH}"
12 |   "${TOP}/hw"
13 |   "${TOP}/src"
14 | )
15 | 
16 | target_sources(${COMPONENT_TARGET} PUBLIC
17 |   "${TOP}/src/tusb.c"
18 |   "${TOP}/src/common/tusb_fifo.c"
19 |   "${TOP}/src/device/usbd.c"
20 |   "${TOP}/src/device/usbd_control.c"
21 |   "${TOP}/src/class/cdc/cdc_device.c"
22 |   "${TOP}/src/class/dfu/dfu_rt_device.c"
23 |   "${TOP}/src/class/hid/hid_device.c"
24 |   "${TOP}/src/class/midi/midi_device.c"
25 |   "${TOP}/src/class/msc/msc_device.c"
26 |   "${TOP}/src/class/net/net_device.c"
27 |   "${TOP}/src/class/usbtmc/usbtmc_device.c"
28 |   "${TOP}/src/class/vendor/vendor_device.c"
29 |   "${TOP}/src/portable/espressif/esp32s2/dcd_esp32s2.c"
30 | )
31 | 
--------------------------------------------------------------------------------
/demo/src/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * FreeRTOS Kernel V10.0.0
  3 |  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
  4 |  *
  5 |  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6 |  * this software and associated documentation files (the "Software"), to deal in
  7 |  * the Software without restriction, including without limitation the rights to
  8 |  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9 |  * the Software, and to permit persons to whom the Software is furnished to do so,
 10 |  * subject to the following conditions:
 11 |  *
 12 |  * The above copyright notice and this permission notice shall be included in all
 13 |  * copies or substantial portions of the Software. If you wish to use our Amazon
 14 |  * FreeRTOS name, please do so in a fair use way that does not cause confusion.
 15 |  *
 16 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 18 |  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 19 |  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 20 |  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 21 |  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 22 |  *
 23 |  * http://www.FreeRTOS.org
 24 |  * http://aws.amazon.com/freertos
 25 |  *
 26 |  * 1 tab == 4 spaces!
 27 |  */
 28 | 
 29 | 
 30 | #ifndef FREERTOS_CONFIG_H
 31 | #define FREERTOS_CONFIG_H
 32 | 
 33 | /*-----------------------------------------------------------
 34 |  * Application specific definitions.
 35 |  *
 36 |  * These definitions should be adjusted for your particular hardware and
 37 |  * application requirements.
 38 |  *
 39 |  * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
 40 |  * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
 41 |  *
 42 |  * See http://www.freertos.org/a00110.html.
 43 |  *----------------------------------------------------------*/
 44 | 
 45 | // Include MCU header
 46 | #include "bsp/board_mcu.h"
 47 | 
 48 | extern uint32_t SystemCoreClock;
 49 | 
 50 | /* Cortex M23/M33 port configuration. */
 51 | #define configENABLE_MPU								        0
 52 | #define configENABLE_FPU								        1
 53 | #define configENABLE_TRUSTZONE					        0
 54 | #define configMINIMAL_SECURE_STACK_SIZE					( 1024 )
 55 | 
 56 | #define configUSE_PREEMPTION                    1
 57 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
 58 | #define configCPU_CLOCK_HZ                      SystemCoreClock
 59 | #define configTICK_RATE_HZ                      ( 1000 )
 60 | #define configMAX_PRIORITIES                    ( 5 )
 61 | #define configMINIMAL_STACK_SIZE                ( 128 )
 62 | #define configTOTAL_HEAP_SIZE                   ( 0*1024 ) // dynamic is not used
 63 | #define configMAX_TASK_NAME_LEN                 16
 64 | #define configUSE_16_BIT_TICKS                  0
 65 | #define configIDLE_SHOULD_YIELD                 1
 66 | #define configUSE_MUTEXES                       1
 67 | #define configUSE_RECURSIVE_MUTEXES             1
 68 | #define configUSE_COUNTING_SEMAPHORES           1
 69 | #define configQUEUE_REGISTRY_SIZE               2
 70 | #define configUSE_QUEUE_SETS                    0
 71 | #define configUSE_TIME_SLICING                  0
 72 | #define configUSE_NEWLIB_REENTRANT              0
 73 | #define configENABLE_BACKWARD_COMPATIBILITY     1
 74 | 
 75 | #define configSUPPORT_STATIC_ALLOCATION         1
 76 | #define configSUPPORT_DYNAMIC_ALLOCATION        0
 77 | 
 78 | /* Hook function related definitions. */
 79 | #define configUSE_IDLE_HOOK                    0
 80 | #define configUSE_TICK_HOOK                    0
 81 | #define configUSE_MALLOC_FAILED_HOOK           0 // cause nested extern warning
 82 | #define configCHECK_FOR_STACK_OVERFLOW         2
 83 | 
 84 | /* Run time and task stats gathering related definitions. */
 85 | #define configGENERATE_RUN_TIME_STATS          0
 86 | #define configUSE_TRACE_FACILITY               1 // legacy trace
 87 | #define configUSE_STATS_FORMATTING_FUNCTIONS   0
 88 | 
 89 | /* Co-routine definitions. */
 90 | #define configUSE_CO_ROUTINES                  0
 91 | #define configMAX_CO_ROUTINE_PRIORITIES        2
 92 | 
 93 | /* Software timer related definitions. */
 94 | #define configUSE_TIMERS                       1
 95 | #define configTIMER_TASK_PRIORITY              (configMAX_PRIORITIES-2)
 96 | #define configTIMER_QUEUE_LENGTH               32
 97 | #define configTIMER_TASK_STACK_DEPTH           configMINIMAL_STACK_SIZE
 98 | 
 99 | /* Optional functions - most linkers will remove unused functions anyway. */
100 | #define INCLUDE_vTaskPrioritySet               0
101 | #define INCLUDE_uxTaskPriorityGet              0
102 | #define INCLUDE_vTaskDelete                    0
103 | #define INCLUDE_vTaskSuspend                   1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
104 | #define INCLUDE_xResumeFromISR                 0
105 | #define INCLUDE_vTaskDelayUntil                1
106 | #define INCLUDE_vTaskDelay                     1
107 | #define INCLUDE_xTaskGetSchedulerState         0
108 | #define INCLUDE_xTaskGetCurrentTaskHandle      0
109 | #define INCLUDE_uxTaskGetStackHighWaterMark    0
110 | #define INCLUDE_xTaskGetIdleTaskHandle         0
111 | #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
112 | #define INCLUDE_pcTaskGetTaskName              0
113 | #define INCLUDE_eTaskGetState                  0
114 | #define INCLUDE_xEventGroupSetBitFromISR       0
115 | #define INCLUDE_xTimerPendFunctionCall         0
116 | 
117 | /* Define to trap errors during development. */
118 | // Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
119 | #if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
120 |   #define configASSERT(_exp) \
121 |     do {\
122 |       if ( !(_exp) ) { \
123 |         volatile uint32_t* ARM_CM_DHCSR =  ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
124 |         if ( (*ARM_CM_DHCSR) & 1UL ) {  /* Only halt mcu if debugger is attached */ \
125 |           taskDISABLE_INTERRUPTS(); \
126 |            __asm("BKPT #0\n"); \
127 |         }\
128 |       }\
129 |     } while(0)
130 | #else
131 |   #define configASSERT( x )
132 | #endif
133 | 
134 | /* FreeRTOS hooks to NVIC vectors */
135 | #define xPortPendSVHandler    PendSV_Handler
136 | #define xPortSysTickHandler   SysTick_Handler
137 | #define vPortSVCHandler       SVC_Handler
138 | 
139 | //--------------------------------------------------------------------+
140 | // Interrupt nesting behavior configuration.
141 | //--------------------------------------------------------------------+
142 | /* Cortex-M specific definitions. __NVIC_PRIO_BITS is defined in core_cmx.h */
143 | #ifdef __NVIC_PRIO_BITS
144 | 	#define configPRIO_BITS       __NVIC_PRIO_BITS
145 | #else
146 |   #error "This port requires __NVIC_PRIO_BITS to be defined"
147 | #endif
148 | 
149 | /* The lowest interrupt priority that can be used in a call to a "set priority" function. */
150 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY			  ((1<
 27 | #include 
 28 | #include 
 29 | 
 30 | #include "FreeRTOS.h"
 31 | #include "task.h"
 32 | #include "timers.h"
 33 | #include "queue.h"
 34 | #include "semphr.h"
 35 | 
 36 | #include "bsp/board.h"
 37 | #include "tusb.h"
 38 | 
 39 | //--------------------------------------------------------------------+
 40 | // MACRO CONSTANT TYPEDEF PROTYPES
 41 | //--------------------------------------------------------------------+
 42 | 
 43 | /* Blink pattern
 44 |  * - 250 ms  : device not mounted
 45 |  * - 1000 ms : device mounted
 46 |  * - 2500 ms : device is suspended
 47 |  */
 48 | enum  {
 49 |   BLINK_NOT_MOUNTED = 250,
 50 |   BLINK_MOUNTED = 1000,
 51 |   BLINK_SUSPENDED = 2500,
 52 | };
 53 | 
 54 | // static timer
 55 | StaticTimer_t blinky_tmdef;
 56 | TimerHandle_t blinky_tm;
 57 | 
 58 | // static task for usbd
 59 | // Increase stack size when debug log is enabled
 60 | #if CFG_TUSB_DEBUG
 61 |   #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE)
 62 | #else
 63 |   #define USBD_STACK_SIZE     (3*configMINIMAL_STACK_SIZE/2)
 64 | #endif
 65 | 
 66 | StackType_t  usb_device_stack[USBD_STACK_SIZE];
 67 | StaticTask_t usb_device_taskdef;
 68 | 
 69 | // static task for cdc
 70 | #define CDC_STACK_SZIE      configMINIMAL_STACK_SIZE
 71 | StackType_t  cdc_stack[CDC_STACK_SZIE];
 72 | StaticTask_t cdc_taskdef;
 73 | 
 74 | 
 75 | void led_blinky_cb(TimerHandle_t xTimer);
 76 | void usb_device_task(void* param);
 77 | void cdc_task(void* params);
 78 | 
 79 | //--------------------------------------------------------------------+
 80 | // Main
 81 | //--------------------------------------------------------------------+
 82 | 
 83 | void gpio_test_0()
 84 | {
 85 | 
 86 | }
 87 | 
 88 | void gpio_test_1()
 89 | {
 90 | 
 91 | }
 92 | 
 93 | extern void led_strip_main(void);
 94 | 
 95 | extern void board_led_write_rgb(int r, int g, int b);
 96 | 
 97 | uint8_t rgb_map[7][3] = {
 98 |         { 32,   0,   0},
 99 |         {  0,  32,   0},
100 |         {  0,   0,  32},
101 |         { 32,  32,   0},
102 |         { 32,   0,  32},
103 |         {  0,  32,  32},
104 |         { 32,  32,  32}
105 | };
106 | 
107 | int main(void)
108 | {
109 |   board_init();
110 |   tusb_init();
111 | 
112 | 
113 |   // soft timer for blinky
114 |   blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef);
115 |   xTimerStart(blinky_tm, 0);
116 | 
117 |   // Create a task for tinyusb device stack
118 |   (void) xTaskCreateStatic( usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES-1, usb_device_stack, &usb_device_taskdef);
119 | 
120 |   // Create CDC task
121 |   (void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, cdc_stack, &cdc_taskdef);
122 | 
123 | #if 1
124 |   while (true) {
125 |       for (int i = 0; i < 7; i++) {
126 |           /* nanoESP32-S2 WS2812B is GRB */
127 |           board_led_write_rgb(rgb_map[i][1], rgb_map[i][0], rgb_map[i][2]);
128 | 
129 |           vTaskDelay(pdMS_TO_TICKS(1000));
130 |       }
131 |   }
132 | #endif
133 | 
134 |   // skip starting scheduler (and return) for ESP32-S2
135 | #if CFG_TUSB_MCU != OPT_MCU_ESP32S2
136 |   vTaskStartScheduler();
137 |   NVIC_SystemReset();
138 |   return 0;
139 | #endif
140 | }
141 | 
142 | #if CFG_TUSB_MCU == OPT_MCU_ESP32S2
143 | void app_main(void)
144 | {
145 |   main();
146 | }
147 | #endif
148 | 
149 | // USB Device Driver task
150 | // This top level thread process all usb events and invoke callbacks
151 | void usb_device_task(void* param)
152 | {
153 |   (void) param;
154 | 
155 |   // RTOS forever loop
156 |   while (1)
157 |   {
158 |     // tinyusb device task
159 |     tud_task();
160 |   }
161 | }
162 | 
163 | //--------------------------------------------------------------------+
164 | // Device callbacks
165 | //--------------------------------------------------------------------+
166 | 
167 | // Invoked when device is mounted
168 | void tud_mount_cb(void)
169 | {
170 |   xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_MOUNTED), 0);
171 | }
172 | 
173 | // Invoked when device is unmounted
174 | void tud_umount_cb(void)
175 | {
176 |   xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), 0);
177 | }
178 | 
179 | // Invoked when usb bus is suspended
180 | // remote_wakeup_en : if host allow us  to perform remote wakeup
181 | // Within 7ms, device must draw an average of current less than 2.5 mA from bus
182 | void tud_suspend_cb(bool remote_wakeup_en)
183 | {
184 |   (void) remote_wakeup_en;
185 |   xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_SUSPENDED), 0);
186 | }
187 | 
188 | // Invoked when usb bus is resumed
189 | void tud_resume_cb(void)
190 | {
191 |   xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_MOUNTED), 0);
192 | }
193 | 
194 | //--------------------------------------------------------------------+
195 | // USB CDC
196 | //--------------------------------------------------------------------+
197 | void cdc_task(void* params)
198 | {
199 |   (void) params;
200 | 
201 |   // RTOS forever loop
202 |   while ( 1 )
203 |   {
204 |     if ( tud_cdc_connected() )
205 |     {
206 |       // connected and there are data available
207 |       if ( tud_cdc_available() )
208 |       {
209 |         uint8_t buf[64];
210 | 
211 |         // read and echo back
212 |         uint32_t count = tud_cdc_read(buf, sizeof(buf));
213 | 
214 |         for(uint32_t i=0; i\
 37 | \
 38 | \
 39 | \
 40 | MuseLab Shop Website Shortcut\
 41 | \
 42 | \
 43 | \
 46 | \
 47 | "
 48 | 
 49 | enum
 50 | {
 51 |   DISK_BLOCK_NUM  = 16, // 8KB is the smallest size that windows allow to mount
 52 |   DISK_BLOCK_SIZE = 512
 53 | };
 54 | 
 55 | #ifdef CFG_EXAMPLE_MSC_READONLY
 56 | const
 57 | #endif
 58 | uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
 59 | {
 60 |   //------------- Block0: Boot Sector -------------//
 61 |   // byte_per_sector    = DISK_BLOCK_SIZE; fat12_sector_num_16  = DISK_BLOCK_NUM;
 62 |   // sector_per_cluster = 1; reserved_sectors = 1;
 63 |   // fat_num            = 1; fat12_root_entry_num = 16;
 64 |   // sector_per_fat     = 1; sector_per_track = 1; head_num = 1; hidden_sectors = 0;
 65 |   // drive_number       = 0x80; media_type = 0xf8; extended_boot_signature = 0x29;
 66 |   // filesystem_type    = "FAT12   "; volume_serial_number = 0x1234; volume_label = "TinyUSB MSC";
 67 |   // FAT magic code at offset 510-511
 68 |   {
 69 |       0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00,
 70 |       0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
 71 |       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 'T' , 'i' , 'n' , 'y' , 'U' ,
 72 |       'S' , 'B' , ' ' , 'M' , 'S' , 'C' , 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
 73 | 
 74 |       // Zero up to 2 last bytes of FAT magic code
 75 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 76 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 77 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 78 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 79 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 80 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 81 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 82 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 83 | 
 84 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 85 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 86 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 87 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 88 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 89 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 90 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 91 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 92 | 
 93 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 94 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 95 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 96 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 97 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 98 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 99 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
101 | 
102 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
104 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA
106 |   },
107 | 
108 |   //------------- Block1: FAT12 Table -------------//
109 |   {
110 |       0xF8, 0xFF, 0xFF, 0xFF, 0x0F // // first 2 entries must be F8FF, third entry is cluster end of readme file
111 |   },
112 | 
113 |   //------------- Block2: Root Directory -------------//
114 |   {
115 |       // first entry is volume label
116 |       'E' , 'S' , 'P' , '3' , '2' , 'S' , '2' , ' ' , 'M' , 'S' , 'C' , 0x08, 0x00, 0x00, 0x00, 0x00,
117 |       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118 |       // second entry is readme file
119 |       'R' , 'E' , 'A' , 'D' , 'M' , 'E' , ' ' , ' ' , 'H' , 'T' , 'M' , 0x20, 0x00, 0xC6, 0x52, 0x6D,
120 |       0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
121 |       sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's files size (4 Bytes)
122 |   },
123 | 
124 |   //------------- Block3: Readme Content -------------//
125 |   README_CONTENTS
126 | };
127 | 
128 | // Invoked when received SCSI_CMD_INQUIRY
129 | // Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
130 | void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4])
131 | {
132 |   (void) lun;
133 | 
134 |   const char vid[] = "TinyUSB";
135 |   const char pid[] = "Mass Storage";
136 |   const char rev[] = "1.0";
137 | 
138 |   memcpy(vendor_id  , vid, strlen(vid));
139 |   memcpy(product_id , pid, strlen(pid));
140 |   memcpy(product_rev, rev, strlen(rev));
141 | }
142 | 
143 | // Invoked when received Test Unit Ready command.
144 | // return true allowing host to read/write this LUN e.g SD card inserted
145 | bool tud_msc_test_unit_ready_cb(uint8_t lun)
146 | {
147 |   (void) lun;
148 | 
149 |   return true; // RAM disk is always ready
150 | }
151 | 
152 | // Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
153 | // Application update block count and block size
154 | void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
155 | {
156 |   (void) lun;
157 | 
158 |   *block_count = DISK_BLOCK_NUM;
159 |   *block_size  = DISK_BLOCK_SIZE;
160 | }
161 | 
162 | // Invoked when received Start Stop Unit command
163 | // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
164 | // - Start = 1 : active mode, if load_eject = 1 : load disk storage
165 | bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
166 | {
167 |   (void) lun;
168 |   (void) power_condition;
169 | 
170 |   if ( load_eject )
171 |   {
172 |     if (start)
173 |     {
174 |       // load disk storage
175 |     }else
176 |     {
177 |       // unload disk storage
178 |     }
179 |   }
180 | 
181 |   return true;
182 | }
183 | 
184 | // Callback invoked when received READ10 command.
185 | // Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
186 | int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
187 | {
188 |   (void) lun;
189 | 
190 |   uint8_t const* addr = msc_disk[lba] + offset;
191 |   memcpy(buffer, addr, bufsize);
192 | 
193 |   return bufsize;
194 | }
195 | 
196 | // Callback invoked when received WRITE10 command.
197 | // Process data in buffer to disk's storage and return number of written bytes
198 | int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
199 | {
200 |   (void) lun;
201 | 
202 | #ifndef CFG_EXAMPLE_MSC_READONLY
203 |   uint8_t* addr = msc_disk[lba] + offset;
204 |   memcpy(addr, buffer, bufsize);
205 | #else
206 |   (void) lba; (void) offset; (void) buffer;
207 | #endif
208 | 
209 |   return bufsize;
210 | }
211 | 
212 | // Callback invoked when received an SCSI command not in built-in list below
213 | // - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
214 | // - READ10 and WRITE10 has their own callbacks
215 | int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
216 | {
217 |   // read10 & write10 has their own callback and MUST not be handled here
218 | 
219 |   void const* response = NULL;
220 |   uint16_t resplen = 0;
221 | 
222 |   // most scsi handled is input
223 |   bool in_xfer = true;
224 | 
225 |   switch (scsi_cmd[0])
226 |   {
227 |     case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
228 |       // Host is about to read/write etc ... better not to disconnect disk
229 |       resplen = 0;
230 |     break;
231 | 
232 |     default:
233 |       // Set Sense = Invalid Command Operation
234 |       tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
235 | 
236 |       // negative means error -> tinyusb could stall and/or response with failed status
237 |       resplen = -1;
238 |     break;
239 |   }
240 | 
241 |   // return resplen must not larger than bufsize
242 |   if ( resplen > bufsize ) resplen = bufsize;
243 | 
244 |   if ( response && (resplen > 0) )
245 |   {
246 |     if(in_xfer)
247 |     {
248 |       memcpy(buffer, response, resplen);
249 |     }else
250 |     {
251 |       // SCSI output
252 |     }
253 |   }
254 | 
255 |   return resplen;
256 | }
257 | 
258 | #endif
259 | 
--------------------------------------------------------------------------------
/demo/src/tusb_config.h:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * The MIT License (MIT)
  3 |  *
  4 |  * Copyright (c) 2019 Ha Thach (tinyusb.org)
  5 |  *
  6 |  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7 |  * of this software and associated documentation files (the "Software"), to deal
  8 |  * in the Software without restriction, including without limitation the rights
  9 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10 |  * copies of the Software, and to permit persons to whom the Software is
 11 |  * furnished to do so, subject to the following conditions:
 12 |  *
 13 |  * The above copyright notice and this permission notice shall be included in
 14 |  * all copies or substantial portions of the Software.
 15 |  *
 16 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19 |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22 |  * THE SOFTWARE.
 23 |  *
 24 |  */
 25 | 
 26 | #ifndef _TUSB_CONFIG_H_
 27 | #define _TUSB_CONFIG_H_
 28 | 
 29 | #ifdef __cplusplus
 30 |  extern "C" {
 31 | #endif
 32 | 
 33 | //--------------------------------------------------------------------
 34 | // COMMON CONFIGURATION
 35 | //--------------------------------------------------------------------
 36 | 
 37 | // defined by compiler flags for flexibility
 38 | #ifndef CFG_TUSB_MCU
 39 |   #error CFG_TUSB_MCU must be defined
 40 | #endif
 41 | 
 42 | #if CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
 43 |     CFG_TUSB_MCU == OPT_MCU_NUC505  || CFG_TUSB_MCU == OPT_MCU_CXD56
 44 |   #define CFG_TUSB_RHPORT0_MODE     (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
 45 | #else
 46 |   #define CFG_TUSB_RHPORT0_MODE     OPT_MODE_DEVICE
 47 | #endif
 48 | 
 49 | #define CFG_TUSB_OS                 OPT_OS_FREERTOS
 50 | 
 51 | // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
 52 | // #define CFG_TUSB_DEBUG           0
 53 | 
 54 | /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
 55 |  * Tinyusb use follows macros to declare transferring memory so that they can be put
 56 |  * into those specific section.
 57 |  * e.g
 58 |  * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
 59 |  * - CFG_TUSB_MEM_ALIGN   : __attribute__ ((aligned(4)))
 60 |  */
 61 | #ifndef CFG_TUSB_MEM_SECTION
 62 | #define CFG_TUSB_MEM_SECTION
 63 | #endif
 64 | 
 65 | #ifndef CFG_TUSB_MEM_ALIGN
 66 | #define CFG_TUSB_MEM_ALIGN          __attribute__ ((aligned(4)))
 67 | #endif
 68 | 
 69 | //--------------------------------------------------------------------
 70 | // DEVICE CONFIGURATION
 71 | //--------------------------------------------------------------------
 72 | 
 73 | #ifndef CFG_TUD_ENDPOINT0_SIZE
 74 | #define CFG_TUD_ENDPOINT0_SIZE    64
 75 | #endif
 76 | 
 77 | //------------- CLASS -------------//
 78 | #define CFG_TUD_CDC              1
 79 | #define CFG_TUD_MSC              1
 80 | #define CFG_TUD_HID              0
 81 | 
 82 | #define CFG_TUD_MIDI             0
 83 | #define CFG_TUD_VENDOR           0
 84 | 
 85 | // CDC FIFO size of TX and RX
 86 | #define CFG_TUD_CDC_RX_BUFSIZE   64
 87 | #define CFG_TUD_CDC_TX_BUFSIZE   64
 88 | 
 89 | // MSC Buffer size of Device Mass storage
 90 | #define CFG_TUD_MSC_BUFSIZE      512
 91 | 
 92 | // HID buffer size Should be sufficient to hold ID (if any) + Data
 93 | #define CFG_TUD_HID_BUFSIZE      16
 94 | 
 95 | #ifdef __cplusplus
 96 |  }
 97 | #endif
 98 | 
 99 | #endif /* _TUSB_CONFIG_H_ */
100 | 
--------------------------------------------------------------------------------
/demo/src/usb_descriptors.c:
--------------------------------------------------------------------------------
  1 | /* 
  2 |  * The MIT License (MIT)
  3 |  *
  4 |  * Copyright (c) 2019 Ha Thach (tinyusb.org)
  5 |  *
  6 |  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7 |  * of this software and associated documentation files (the "Software"), to deal
  8 |  * in the Software without restriction, including without limitation the rights
  9 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10 |  * copies of the Software, and to permit persons to whom the Software is
 11 |  * furnished to do so, subject to the following conditions:
 12 |  *
 13 |  * The above copyright notice and this permission notice shall be included in
 14 |  * all copies or substantial portions of the Software.
 15 |  *
 16 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19 |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22 |  * THE SOFTWARE.
 23 |  *
 24 |  */
 25 | 
 26 | #include "tusb.h"
 27 | 
 28 | /* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
 29 |  * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
 30 |  *
 31 |  * Auto ProductID layout's Bitmap:
 32 |  *   [MSB]         HID | MSC | CDC          [LSB]
 33 |  */
 34 | #define _PID_MAP(itf, n)  ( (CFG_TUD_##itf) << (n) )
 35 | #define USB_PID           (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
 36 |                            _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
 37 | 
 38 | //--------------------------------------------------------------------+
 39 | // Device Descriptors
 40 | //--------------------------------------------------------------------+
 41 | tusb_desc_device_t const desc_device =
 42 | {
 43 |     .bLength            = sizeof(tusb_desc_device_t),
 44 |     .bDescriptorType    = TUSB_DESC_DEVICE,
 45 |     .bcdUSB             = 0x0200,
 46 | 
 47 |     // Use Interface Association Descriptor (IAD) for CDC
 48 |     // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
 49 |     .bDeviceClass       = TUSB_CLASS_MISC,
 50 |     .bDeviceSubClass    = MISC_SUBCLASS_COMMON,
 51 |     .bDeviceProtocol    = MISC_PROTOCOL_IAD,
 52 | 
 53 |     .bMaxPacketSize0    = CFG_TUD_ENDPOINT0_SIZE,
 54 | 
 55 |     .idVendor           = 0xCafe,
 56 |     .idProduct          = USB_PID,
 57 |     .bcdDevice          = 0x0100,
 58 | 
 59 |     .iManufacturer      = 0x01,
 60 |     .iProduct           = 0x02,
 61 |     .iSerialNumber      = 0x03,
 62 | 
 63 |     .bNumConfigurations = 0x01
 64 | };
 65 | 
 66 | // Invoked when received GET DEVICE DESCRIPTOR
 67 | // Application return pointer to descriptor
 68 | uint8_t const * tud_descriptor_device_cb(void)
 69 | {
 70 |   return (uint8_t const *) &desc_device;
 71 | }
 72 | 
 73 | //--------------------------------------------------------------------+
 74 | // Configuration Descriptor
 75 | //--------------------------------------------------------------------+
 76 | 
 77 | enum
 78 | {
 79 |   ITF_NUM_CDC = 0,
 80 |   ITF_NUM_CDC_DATA,
 81 |   ITF_NUM_MSC,
 82 |   ITF_NUM_TOTAL
 83 | };
 84 | 
 85 | #define CONFIG_TOTAL_LEN    (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
 86 | 
 87 | #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
 88 |   // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
 89 |   // 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
 90 |   #define EPNUM_CDC_NOTIF   0x81
 91 |   #define EPNUM_CDC_OUT     0x02
 92 |   #define EPNUM_CDC_IN      0x82
 93 | 
 94 |   #define EPNUM_MSC_OUT     0x05
 95 |   #define EPNUM_MSC_IN      0x85
 96 | 
 97 | #elif CFG_TUSB_MCU == OPT_MCU_SAMG
 98 |   // SAMG doesn't support a same endpoint number with different direction IN and OUT
 99 |   //    e.g EP1 OUT & EP1 IN cannot exist together
100 |   #define EPNUM_CDC_NOTIF   0x81
101 |   #define EPNUM_CDC_OUT     0x02
102 |   #define EPNUM_CDC_IN      0x83
103 | 
104 |   #define EPNUM_MSC_OUT     0x04
105 |   #define EPNUM_MSC_IN      0x85
106 | 
107 | #else
108 |   #define EPNUM_CDC_NOTIF   0x81
109 |   #define EPNUM_CDC_OUT     0x02
110 |   #define EPNUM_CDC_IN      0x82
111 | 
112 |   #define EPNUM_MSC_OUT     0x03
113 |   #define EPNUM_MSC_IN      0x83
114 | 
115 | #endif
116 | 
117 | uint8_t const desc_configuration[] =
118 | {
119 |   // Config number, interface count, string index, total length, attribute, power in mA
120 |   TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
121 | 
122 |   // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
123 |   TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
124 | 
125 |   // Interface number, string index, EP Out & EP In address, EP size
126 |   TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : 64),
127 | };
128 | 
129 | 
130 | // Invoked when received GET CONFIGURATION DESCRIPTOR
131 | // Application return pointer to descriptor
132 | // Descriptor contents must exist long enough for transfer to complete
133 | uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
134 | {
135 |   (void) index; // for multiple configurations
136 |   return desc_configuration;
137 | }
138 | 
139 | //--------------------------------------------------------------------+
140 | // String Descriptors
141 | //--------------------------------------------------------------------+
142 | 
143 | // array of pointer to string descriptors
144 | char const* string_desc_arr [] =
145 | {
146 |   (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
147 |   "TinyUSB",                     // 1: Manufacturer
148 |   "TinyUSB Device",              // 2: Product
149 |   "123456",                      // 3: Serials, should use chip ID
150 |   "TinyUSB CDC",                 // 4: CDC Interface
151 |   "TinyUSB MSC",                 // 5: MSC Interface
152 | };
153 | 
154 | static uint16_t _desc_str[32];
155 | 
156 | // Invoked when received GET STRING DESCRIPTOR request
157 | // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
158 | uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
159 | {
160 |   (void) langid;
161 | 
162 |   uint8_t chr_count;
163 | 
164 |   if ( index == 0)
165 |   {
166 |     memcpy(&_desc_str[1], string_desc_arr[0], 2);
167 |     chr_count = 1;
168 |   }else
169 |   {
170 |     // Convert ASCII string into UTF-16
171 | 
172 |     if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL;
173 | 
174 |     const char* str = string_desc_arr[index];
175 | 
176 |     // Cap at max char
177 |     chr_count = strlen(str);
178 |     if ( chr_count > 31 ) chr_count = 31;
179 | 
180 |     for(uint8_t i=0; i