This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
51,140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.bak | ||
D11mouseplay THUMB Debug/* | ||
D11mouseplay THUMB Release/* | ||
*.hzs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!DOCTYPE Board_Memory_Definition_File> | ||
<root name="ATSAMD11D14AM"> | ||
<MemorySegment name="FLASH" start="0x00000400" size="0x00003C00" access="ReadOnly" /> | ||
<MemorySegment name="RAM" start="0x20000000" size="0x00001000" access="Read/Write" /> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!DOCTYPE CrossStudio_Project_File> | ||
<solution Name="D11mouseplay" target="8" version="2"> | ||
<project Name="D11mouseplay"> | ||
<configuration | ||
CMSIS_CORE="Yes" | ||
Name="Common" | ||
Placement="Flash" | ||
Startup="Release Only" | ||
Target="ATSAMD11D14AM" | ||
arm_architecture="v6M" | ||
arm_core_type="Cortex-M0+" | ||
arm_endian="Little" | ||
arm_fpu_type="None" | ||
arm_interwork="No" | ||
arm_linker_heap_size="256" | ||
arm_linker_process_stack_size="0" | ||
arm_linker_stack_size="256" | ||
arm_simulator_memory_simulation_filename="$(TargetsDir)/SAM_D/Simulator/SAM_D_SimulatorMemory_$(HostOS)_$(HostArch)$(HostDLLExt)" | ||
arm_simulator_memory_simulation_parameter="SAM D,SAM D11;FLASH,0x00000000,0x00004000,ROM;RAM,0x20000000,0x00001000,RAM" | ||
arm_target_debug_interface_type="ADIv5" | ||
arm_target_device_name="ATSAMD11D14AM" | ||
arm_target_interface_type="SWD" | ||
arm_target_loader_applicable_loaders="Flash" | ||
arm_target_loader_default_loader="Flash" | ||
c_preprocessor_definitions="DONT_USE_CMSIS_INIT;F_CPU=48000000" | ||
c_user_include_directories="$(ProjectDir);$(ProjectDir)/include" | ||
debug_register_definition_file="$(DeviceRegisterDefinitionFile)" | ||
gcc_entry_point="Reset_Handler" | ||
linker_keep_symbols="vectors" | ||
linker_memory_map_file="$(DeviceMemoryMapFile)" | ||
linker_output_format="bin" | ||
linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml" | ||
macros="DeviceLoaderFile=$(TargetsDir)/SAM_D/Loader/SAM_D11_Loader.elf;DeviceMemoryMapFile=$(TargetsDir)/SAM_D/XML/ATSAMD11D14AM_MemoryMap.xml;DeviceRegisterDefinitionFile=$(TargetsDir)/SAM_D/XML/ATSAMD11D14AM_Registers.xml;DeviceFamily=SAM D;DeviceSubFamily=SAM D11" | ||
package_dependencies="Atmel_ATSAMD11-XPRO" | ||
project_directory="" | ||
project_type="Executable" | ||
property_groups_file_path="$(TargetsDir)/SAM_D/XML/property_groups.xml" | ||
target_get_partname_script="GetPartName()" | ||
target_match_partname_script="MatchPartName("$(Target)")" | ||
target_reset_script="Reset();" | ||
target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> | ||
<configuration | ||
Name="Flash" | ||
arm_target_flash_loader_file_path="$(DeviceLoaderFile)" /> | ||
<folder Name="Script Files"> | ||
<file file_name="$(TargetsDir)/SAM_D/Scripts/SAM_D_Target.js"> | ||
<configuration Name="Common" file_type="Reset Script" /> | ||
</file> | ||
</folder> | ||
<folder Name="Source Files"> | ||
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" /> | ||
<file file_name="main.c" /> | ||
<file file_name="startup_samd11.c" /> | ||
<file file_name="usb.c" /> | ||
<file file_name="usb_descriptors.c" /> | ||
<file file_name="usb_std.c" /> | ||
<file file_name="usb_hid.c" /> | ||
</folder> | ||
<folder Name="System Files"> | ||
<file file_name="ATSAMD11D14AM_MemoryMap.xml" /> | ||
</folder> | ||
</project> | ||
<configuration Name="THUMB Debug" inherited_configurations="THUMB;Debug" /> | ||
<configuration | ||
Name="THUMB" | ||
Platform="ARM" | ||
arm_instruction_set="Thumb" | ||
arm_library_instruction_set="Thumb" | ||
c_preprocessor_definitions="__THUMB" | ||
hidden="Yes" /> | ||
<configuration | ||
Name="Debug" | ||
c_preprocessor_definitions="DEBUG" | ||
gcc_debugging_level="Level 3" | ||
gcc_omit_frame_pointer="Yes" | ||
gcc_optimization_level="None" | ||
hidden="Yes" /> | ||
<configuration | ||
Name="THUMB Release" | ||
inherited_configurations="THUMB;Release" /> | ||
<configuration | ||
Name="Release" | ||
c_preprocessor_definitions="NDEBUG" | ||
gcc_debugging_level="None" | ||
gcc_omit_frame_pointer="Yes" | ||
gcc_optimization_level="Level 1" | ||
hidden="Yes" /> | ||
</solution> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
mouseplay: example HID mouse | ||
============================ | ||
|
||
## Introduction | ||
|
||
This functions like the example app "mouseplay" included with [USB DFU Bootloader for PIC16F1454/5/9](https://github.com/majbthrd/PIC16F1-USB-DFU-Bootloader). | ||
|
||
The USB stack source code owes its origins to both [vcp](https://github.com/ataradov/vcp) and [free-dap](https://github.com/ataradov/free-dap). The [vcp](https://github.com/ataradov/vcp) USB stack is newer and more sophisticated, but is not a HID implementation like [free-dap](https://github.com/ataradov/free-dap). Using the two code bases, I made an educated guess at what sort of USB HID implementation the author might have written after written vcp. | ||
|
||
The linker memory maps have been adjusted to exclude the first 0x400 bytes so as allow operation with the [USB DFU Bootloader for SAMD11](https://github.com/majbthrd/SAMD11-USB-DFU-Bootloader/). | ||
|
||
## Build Requirements | ||
|
||
One approach is to use [Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) to compile this code. It is not free software, but has been my favorite go-to ARM development tool for a decade and counting. | ||
|
||
*OR* | ||
|
||
Use the Makefile in the make subdirectory. With this approach, the code can be built using only open-source software. In Ubuntu-derived distributions, this is likely achieved with as little as: | ||
|
||
``` | ||
sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential | ||
``` | ||
|
||
## Customizing | ||
|
||
usb_descriptors.c contains the USB VID:PID. All unique USB device implementations must have their own unique USB VID:PID identifiers. | ||
|
||
If modifying usb_hid_report_descriptor in usb_hid.c, the USB_HID_REPORT_DESCRIPTOR_LENGTH define in usb_hid.h *MUST* exactly match the new size of usb_hid_report_descriptor. | ||
|
||
As with any USB HID device, the HID report size (nominally sent by send_buffer() in main.c) *MUST* exactly match the metadata conveyed in the usb_hid_report_descriptor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Copyright (c) 2014-2016, Alex Taradov <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The name of the author may not be used to endorse or promote products | ||
* derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef _HAL_GPIO_H_ | ||
#define _HAL_GPIO_H_ | ||
|
||
/*- Definitions -------------------------------------------------------------*/ | ||
#define HAL_GPIO_PORTA 0 | ||
#define HAL_GPIO_PORTB 1 | ||
#define HAL_GPIO_PORTC 2 | ||
|
||
#define HAL_GPIO_PMUX_A 0 | ||
#define HAL_GPIO_PMUX_B 1 | ||
#define HAL_GPIO_PMUX_C 2 | ||
#define HAL_GPIO_PMUX_D 3 | ||
#define HAL_GPIO_PMUX_E 4 | ||
#define HAL_GPIO_PMUX_F 5 | ||
#define HAL_GPIO_PMUX_G 6 | ||
#define HAL_GPIO_PMUX_H 7 | ||
#define HAL_GPIO_PMUX_I 8 | ||
|
||
#define HAL_GPIO_PIN(name, port, pin) \ | ||
static inline void HAL_GPIO_##name##_set(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTSET.reg = (1 << pin); \ | ||
(void)HAL_GPIO_##name##_set; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_clr(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTCLR.reg = (1 << pin); \ | ||
(void)HAL_GPIO_##name##_clr; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_toggle(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTTGL.reg = (1 << pin); \ | ||
(void)HAL_GPIO_##name##_toggle; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_write(int value) \ | ||
{ \ | ||
if (value) \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTSET.reg = (1 << pin); \ | ||
else \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTCLR.reg = (1 << pin); \ | ||
(void)HAL_GPIO_##name##_write; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_in(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].DIRCLR.reg = (1 << pin); \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg |= PORT_PINCFG_INEN; \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg &= ~PORT_PINCFG_PULLEN; \ | ||
(void)HAL_GPIO_##name##_in; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_out(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].DIRSET.reg = (1 << pin); \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg |= PORT_PINCFG_INEN; \ | ||
(void)HAL_GPIO_##name##_out; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_pullup(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].OUTSET.reg = (1 << pin); \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg |= PORT_PINCFG_PULLEN; \ | ||
(void)HAL_GPIO_##name##_pullup; \ | ||
} \ | ||
\ | ||
static inline int HAL_GPIO_##name##_read(void) \ | ||
{ \ | ||
return (PORT->Group[HAL_GPIO_PORT##port].IN.reg & (1 << pin)) != 0; \ | ||
(void)HAL_GPIO_##name##_read; \ | ||
} \ | ||
\ | ||
static inline int HAL_GPIO_##name##_state(void) \ | ||
{ \ | ||
return (PORT->Group[HAL_GPIO_PORT##port].DIR.reg & (1 << pin)) != 0; \ | ||
(void)HAL_GPIO_##name##_state; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_pmuxen(int mux) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg |= PORT_PINCFG_PMUXEN; \ | ||
if (pin & 1) \ | ||
PORT->Group[HAL_GPIO_PORT##port].PMUX[pin>>1].bit.PMUXO = mux; \ | ||
else \ | ||
PORT->Group[HAL_GPIO_PORT##port].PMUX[pin>>1].bit.PMUXE = mux; \ | ||
(void)HAL_GPIO_##name##_pmuxen; \ | ||
} \ | ||
\ | ||
static inline void HAL_GPIO_##name##_pmuxdis(void) \ | ||
{ \ | ||
PORT->Group[HAL_GPIO_PORT##port].PINCFG[pin].reg &= ~PORT_PINCFG_PMUXEN; \ | ||
(void)HAL_GPIO_##name##_pmuxdis; \ | ||
} \ | ||
|
||
#endif // _HAL_GPIO_H_ | ||
|
Oops, something went wrong.